commit d6b16f5e06aa708682724ae473006acdc7c8569b Author: Claude Code Date: Sat Jul 4 05:36:43 2026 +0000 Initial commit: design-018 Phases 0-5 (stomping.me) Auth BFF (OIDC + prompt=none silent SSO), Mongo data layer, admin CRUD (folders/tags/stories/chapters with TipTap), public reader with tag filtering. Built and verified same-session per design-018-stories.md. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2e8157a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules/ +.env +*.log diff --git a/ecosystem.config.js b/ecosystem.config.js new file mode 100644 index 0000000..5adc616 --- /dev/null +++ b/ecosystem.config.js @@ -0,0 +1,16 @@ +module.exports = { + apps: [ + { + name: 'stomping.me', + script: 'app.js', + cwd: '/opt/stomping/src', + instances: 1, + autorestart: true, + watch: false, + env: { + NODE_ENV: 'production' + }, + env_file: '/etc/AGWOL/stomping/.env' + } + ] +}; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..2547fb5 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,2741 @@ +{ + "name": "stomping.me", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "stomping.me", + "version": "1.0.0", + "dependencies": { + "@tiptap/core": "^3.27.1", + "@tiptap/extension-image": "^3.27.1", + "@tiptap/html": "^3.27.1", + "@tiptap/starter-kit": "^3.27.1", + "cookie-parser": "^1.4.7", + "cors": "^2.8.6", + "dotenv": "^17.3.1", + "ejs": "^4.0.1", + "express": "^5.2.1", + "helmet": "^8.1.0", + "ioredis": "^5.9.3", + "jsonwebtoken": "^9.0.3", + "mongodb": "^7.1.0", + "sanitize-html": "^2.17.5" + }, + "devDependencies": { + "esbuild": "^0.28.1" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.1.tgz", + "integrity": "sha512-Svl7tq8k/08+p6CXPpRjQ1fKX+1odH/BQbb48fV6fj3CWHhsoIOoY87w1oHXm0qEpkIK3ZfVgp0hed3XBXzXMQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.1.tgz", + "integrity": "sha512-0k2F129Xdio1TdJfzJ8sy1Q47vUD2NnwdhiAf7drUN1EBTfPf4hsFCtmMgu/6m8JSzsBrlmVjudMBQqOfG8usQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.1.tgz", + "integrity": "sha512-34EGEbCIAgosYz6goLcopX6Mo7NyGv9tfwEM2/7Ce2VcVRk568iSvniGWcUXIy7wEDR1wzolcxcriFVrWYcwBg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.1.tgz", + "integrity": "sha512-dbwY7ltSMDWsRatcRpCnES4F+im88OCUgGZjy52shC7GqHRE/cYlxNbB4Z4UpJswpcc4Qxd2oE/ufM0p61IKng==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.1.tgz", + "integrity": "sha512-TZbWkQY7kvTAXbXUT7uVACR5cMHsDiSz9z7ZKAX/RTq/WJEk3QyRr0wZpNhBDX+/0CtdqUIJlOiodQcta6tY3Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.1.tgz", + "integrity": "sha512-zfdzgK9ACBNZLI/CyHTOx81SyNbM6YXn7rxSgX97VjyiPl9W1i4Ka4fgKECEoFCKGpvBj5qArWIGgQjOwkgskQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.1.tgz", + "integrity": "sha512-wG2EA8ENdEI0qhkSZMjfqrdY+ziCYCPMmtZjjIwOmXFjmyzEHn+UUxk5of+SYsjtfs3VpnlC7QLzSI5hY/rOAw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.1.tgz", + "integrity": "sha512-i7dZ9vQgnvSCzi/rYCXNgtF/U+eKZNJBzu3eTQbRgHnM7tNSizLOkRFAl3qzVc/Op/u5YkHHa4pf/3DOYHthLQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.1.tgz", + "integrity": "sha512-qVXBOHQS+d5Y722GwJzJUtOLlX7km3CraOaGormF1pDtPd2C/l1SHRPgjLunLGe51Sh5YYWKMFDyV4SxgMQYTQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.1.tgz", + "integrity": "sha512-yHs+0uc8+nvEAfAfxrWQKK5peSNzBc4PegcMO0EJ2hT71uA7vB8Ihg2e77R2P7SG5uYjPbHlLLmve4LLLRCf0g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.1.tgz", + "integrity": "sha512-d1z4ZuP0ajrfz/FhGT4vv278rX8KnPPJx8i5+AtK7TYbx9Le9F1hyzurZpkEyjkGa9dUGhQow4C1NmeGvqxN2w==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.1.tgz", + "integrity": "sha512-M5sRjUVZrkm1OAPR3dlOYzNmN+loZKGVi1VUQGrwuqLcbR6qeAz+famMhjASeH3YVKvZz+zT1jlh/keC3Rj/lg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.1.tgz", + "integrity": "sha512-mRObBZeHh2OxcBFPWE/FjylkRgZdYuiTR3vaTozquCGOH14iP9oN4x4Ge81CoIDYQrXmIxpFumJBu5MtZpnQJQ==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.1.tgz", + "integrity": "sha512-slScBsMAb3GFDcdrCgLwZtPYRoH2H/youv10QiZyRjmsP48fznoveWytSgCI/R0ZcUgpc0ZhIUEx6LHts8yrfQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.1.tgz", + "integrity": "sha512-kw0owk1o0GFETUJyW0jc0G4Yzs0BHZn0JDZ8JRT088vjJYX777BAs1fDGxAC+q831qOs2DTC96mNsG2opdfyyQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.1.tgz", + "integrity": "sha512-/lAIjX8aYFRByhh6L5rYtPEDRqa9de/4V/juOXcta5frjvzXO4/sqEtyytse0g3zZFuWu5cDN0MkLz2qRDD2Ag==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.1.tgz", + "integrity": "sha512-u/anNYF2mmVOEDwLtnQ1wOr3EZ9sTNGLWrsYGYwHWzGA3Si84IOkHXlbWTD1NB+9/1lcnweYKO54uhxZydNzfA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.1.tgz", + "integrity": "sha512-oks0DYbLwWMmaakTsCb+zL4E+aHRVLom9IJZOAthMQEPiQmydXHkziYEsGYRx0uNV/IjEKGAV941JzH02pflqw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.1.tgz", + "integrity": "sha512-aeL6lAnN89Hz43Mlh1G8ARasbuoYvSITDEx0tHh5b7jJnHcssqgjy9Yx430GDpmCa6OyrKoS0aNRjKundRizGg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.1.tgz", + "integrity": "sha512-MEFJe5C3R8pwXdZ5Y21oo6m7ePiS0d9pWucn99O/wvyJZChoIQKrQDxKrGeW8F5+T0okTHesAmDeiHDTIq0V/Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.1.tgz", + "integrity": "sha512-i/ZLIOafE0Z8cI/XANJAixoJL/uRAoS2xOA3rb0xN+KK0K177cMAsQYkzHtBrtMXAKuAc7HGgcWiZ/sRC1Nxgw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.1.tgz", + "integrity": "sha512-ge+Z7EXFNt2BO1oAMsVpiQ8EwndV9i1xXerAeTIK7AtPs3bKFXQM7nlRxDSIUIMeueR1CNXxqztLzdNeReKBJg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.1.tgz", + "integrity": "sha512-BEjgtECkL3vY+SaSQ6nzVfiALUeFxpawyp8Jmf5PtYhf1Ug40N1h/hxlhts+f1FvSvarEigdxS3BlSMI2PJLcQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.1.tgz", + "integrity": "sha512-lCv9eK/H6ZJWbE7bh2nw54CZ9M2nupBxJcTsdk/QQnWkdSjKGuxmmH8/GWrlT1eMmZfn4dGcCjRte397WqfQXA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.1.tgz", + "integrity": "sha512-zvb/mB2bSCoJOpoCBgYKKpX6YM6mJBlBUVUtVj41DlZJVEB6/0CKlRYxP5wWl1C1ILiCoAU5wZZ4q1P3qeS6Eg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.1.tgz", + "integrity": "sha512-bm4Mowrv+GXMlpWX++EcXw/iLyd1o3+bJkC2DkWXYVvgZCqD/bSj9ctZeAMC3cIxgjRVR2Dufaiu4YPxr5gW1A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@ioredis/commands": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.10.0.tgz", + "integrity": "sha512-UmeW7z4LfctwoQ5wkhVzgq8tXkreED2xZGpX+Bg+zA+WJFZCT6c062AfCK/Dfk81xZnnwdhJCUMkitihRaoC2Q==", + "license": "MIT" + }, + "node_modules/@mongodb-js/saslprep": { + "version": "1.4.12", + "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.4.12.tgz", + "integrity": "sha512-QAfAMwNgnYxZ2C6D1HgeP7Gc4i/uvJRim415PCIL9ptRxWMNbWeLBYb2/9R4pGKny/s1FVu2JA2cxCUBUOggrA==", + "license": "MIT", + "dependencies": { + "sparse-bitfield": "^3.0.3" + } + }, + "node_modules/@tiptap/core": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/core/-/core-3.27.1.tgz", + "integrity": "sha512-rV6Qn4wmC6BxfF+4mu6bqGWj9vA4oXXhsrpXaJL2uhjxeHAGofjwcHof2X84VYzeyXgdlsGmqKie4TAppVXZUQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/pm": "3.27.1" + } + }, + "node_modules/@tiptap/extension-blockquote": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-blockquote/-/extension-blockquote-3.27.1.tgz", + "integrity": "sha512-VMF7xJx6qEGiX6DTKNiL31NLqypOcd/4sNjFSe8rb41PwejBJh/nOqVIbBvWkiT6NMGFLxMhj7zJ8/zPo1hXeg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "3.27.1" + } + }, + "node_modules/@tiptap/extension-bold": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-bold/-/extension-bold-3.27.1.tgz", + "integrity": "sha512-TlC5bsS+pqETTrlz4CZz9RO/cKBYtELGIxwtKeivUn3eNfnOxQbbu4WDsiwIfzRFyd0OMnKl6BPM2KnYEehoEQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "3.27.1" + } + }, + "node_modules/@tiptap/extension-bullet-list": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-bullet-list/-/extension-bullet-list-3.27.1.tgz", + "integrity": "sha512-faCUHnRP47o9Zh9VZZX6EX/569udw9Vopm2PgEKPWuKLE2qaS5WBuUVU0iItdJmKUqaWiOZkpoW4jvnDmj0dfg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/extension-list": "3.27.1" + } + }, + "node_modules/@tiptap/extension-code": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-code/-/extension-code-3.27.1.tgz", + "integrity": "sha512-epOUpFfEmBzjvnqvjv2qHX7NAuLo5dlOGV690lWu+sAYMjibuJBeVvAiKPyFCfRCCTUxdbDB3jbaOA1yEcEJ7w==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "3.27.1" + } + }, + "node_modules/@tiptap/extension-code-block": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-code-block/-/extension-code-block-3.27.1.tgz", + "integrity": "sha512-pHlzmZx2OlHfyQ0yRlT5UL4mGokz947DthZuYefN1OleVqOkHpWBG+2JQwqoNq6bmzMne92zbH32rhcJUEYSjA==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "3.27.1", + "@tiptap/pm": "3.27.1" + } + }, + "node_modules/@tiptap/extension-document": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-document/-/extension-document-3.27.1.tgz", + "integrity": "sha512-8FbBTkfnRP4iVaoj+2h3iWa+H0eGDD3yTyVCwrmue/sQTkqUNUoSuAZa3GDG4Sd41xdPwTJxl9nUWGgM1qDCnw==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "3.27.1" + } + }, + "node_modules/@tiptap/extension-dropcursor": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-dropcursor/-/extension-dropcursor-3.27.1.tgz", + "integrity": "sha512-blFf9x9RG0Qr7P3FoAH/033ffa+mMLZn34trVs8Vi0Ppk6FmJAg5HpYFOtmYoeREdNDJ5rHJKV7SoACbOHgskQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/extensions": "3.27.1" + } + }, + "node_modules/@tiptap/extension-gapcursor": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-gapcursor/-/extension-gapcursor-3.27.1.tgz", + "integrity": "sha512-QoezN0wdvXIwLQ4ee2ccWDaX3RG0lzgQpIMpMz55oPDhpUVax1+19ApsS53LkcktpS4EbnPL4xO4DaJk0Vp7PQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/extensions": "3.27.1" + } + }, + "node_modules/@tiptap/extension-hard-break": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-hard-break/-/extension-hard-break-3.27.1.tgz", + "integrity": "sha512-iv/m9hzl6jfSj9Q8UEjAxONvCoUDaP7M9SRCPx3PaLNxA230TTD6RE0Ye4zFJ8ze7ZVoJJMAqg9Qpq1iYg2JOQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "3.27.1" + } + }, + "node_modules/@tiptap/extension-heading": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-heading/-/extension-heading-3.27.1.tgz", + "integrity": "sha512-SrC4l1kEIyv9ZXFaI/8LQqU2MyMmjczw7XXsWUQOTN4YXv0JyVgMNR3cI/wz0d2xsTfBdZ1N85Tdng+Ga1t0Sg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "3.27.1" + } + }, + "node_modules/@tiptap/extension-horizontal-rule": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-horizontal-rule/-/extension-horizontal-rule-3.27.1.tgz", + "integrity": "sha512-QlKE7qn5qMnIGVGhXQlvYedvLtNJ9z0dmit5w8vPb8tKzW4Spk6M7N2kruprrDA8GBwHfeR5wmF+njfUm34qxg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "3.27.1", + "@tiptap/pm": "3.27.1" + } + }, + "node_modules/@tiptap/extension-image": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-image/-/extension-image-3.27.1.tgz", + "integrity": "sha512-+JTahgQT+NxiGjduaB3qJVyhU/wh4m3pVkht1Earioku2bm/apj5Lb8rSowa/NJYP3B+oQgV/V4YLw5dtDgBoA==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "3.27.1" + } + }, + "node_modules/@tiptap/extension-italic": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-italic/-/extension-italic-3.27.1.tgz", + "integrity": "sha512-jGGeyn9uRUnNjSTHpbqhiGsp6KaYTSbV09jDXPJI9cDwfV9hpugLvpaCZd0BMBbhU1B1W6kOfX0BE15qX/HQfA==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "3.27.1" + } + }, + "node_modules/@tiptap/extension-link": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-link/-/extension-link-3.27.1.tgz", + "integrity": "sha512-/2jBfsxBZUDGJmpZifqRQPz7f1E5qpS1BckTZ39TADzUJX+feKy7RJ3DtQ02+8y6SSMzvP9loGVjrk6zEMTk4g==", + "license": "MIT", + "dependencies": { + "linkifyjs": "^4.3.3" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "3.27.1", + "@tiptap/pm": "3.27.1" + } + }, + "node_modules/@tiptap/extension-list": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-list/-/extension-list-3.27.1.tgz", + "integrity": "sha512-c2Upru7lj0/ZV/Ibww6cNz6sUS8m6Dp/9uygFhYcZOd3X8M0xBIEk42c6m6SQehkPziVA8QOgNJz7sMqsbz1OQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "3.27.1", + "@tiptap/pm": "3.27.1" + } + }, + "node_modules/@tiptap/extension-list-item": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-list-item/-/extension-list-item-3.27.1.tgz", + "integrity": "sha512-zwRl01ETfCkWUvtvK5fw9bXtAajMPkvlkE3Cq6JvH3LF7XXJwDtNj5Tj7exacMpCaSZmlNc43vFb2rAYnrnwMA==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/extension-list": "3.27.1" + } + }, + "node_modules/@tiptap/extension-list-keymap": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-list-keymap/-/extension-list-keymap-3.27.1.tgz", + "integrity": "sha512-OIMZNlzPSO8WRd4ic73Fxckzl4N1tesjjLL2XApaNA/uMpO0LoF6WSRPAWv+Z24Wp92ARRJAnRP7iZoI5+Jxig==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/extension-list": "3.27.1" + } + }, + "node_modules/@tiptap/extension-ordered-list": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-ordered-list/-/extension-ordered-list-3.27.1.tgz", + "integrity": "sha512-GYrKqD//9nHJ2r80uXqbDMzRnFpGzbaEQRTSGaO/SH7DvXWFMow8evkOdjQ7PCQO07jNjJo75+A85Jwu3Ov3AA==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/extension-list": "3.27.1" + } + }, + "node_modules/@tiptap/extension-paragraph": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-paragraph/-/extension-paragraph-3.27.1.tgz", + "integrity": "sha512-7K7eo1gruOgAsnbK+GCV23AUVUI0cL1bTig8HaPneoFMVbig7vddk8jNLKBWO8TXVbG7TuHdnDN4F98vdtwh5Q==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "3.27.1" + } + }, + "node_modules/@tiptap/extension-strike": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-strike/-/extension-strike-3.27.1.tgz", + "integrity": "sha512-Y3DW1jlSlCNCyMGHP3+3qBNNPS83wuFz4RTYGjZtvRRTCRh7apZme9XRWMq1rN5mJ2Cr7fKocA2/5Bs13KgN6Q==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "3.27.1" + } + }, + "node_modules/@tiptap/extension-text": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-text/-/extension-text-3.27.1.tgz", + "integrity": "sha512-6ZwaZwSrDh+KFFv6V1J79oO37yPs7y1bFxvk1/9Ih2rn3Xr5AWz+eMS+n8RpH3djBVVAQpdIAeYQgcn+VCSsTg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "3.27.1" + } + }, + "node_modules/@tiptap/extension-underline": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-underline/-/extension-underline-3.27.1.tgz", + "integrity": "sha512-N889J4nXN/TPfVt8uF9N1A0SY82E90zwc1y26lqOcw6KWNLmQrlhMh/9OD4ikLDbekmFpOBq/UicpHf/6S8hbQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "3.27.1" + } + }, + "node_modules/@tiptap/extensions": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/extensions/-/extensions-3.27.1.tgz", + "integrity": "sha512-1Tdx9faw8k0/83V6X+xCDVhV8yElGt95JxeW3YMkKQJI56QdlPz0xOdJPlMiSGJKinPyVier+x9LJD/YZUZIaw==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "3.27.1", + "@tiptap/pm": "3.27.1" + } + }, + "node_modules/@tiptap/html": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/html/-/html-3.27.1.tgz", + "integrity": "sha512-DKZv6B/I9JgveIHMMsZDdx2K974HHNIh5o1CeYk1L4xHTWDTa64pXW18IrU8xMFm6RibW3LFCX7f3RTn7Pbq0g==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "3.27.1", + "@tiptap/pm": "3.27.1", + "happy-dom": "^20.8.9" + } + }, + "node_modules/@tiptap/pm": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/pm/-/pm-3.27.1.tgz", + "integrity": "sha512-Ffjx+vimmBU7zH/KrpXzJid3+pziCe/VL2aexSTP63cyQwKQ65LkFkCKaIsSpFdQQuakVZBGWjCA5RoBV852pw==", + "license": "MIT", + "dependencies": { + "prosemirror-changeset": "^2.3.0", + "prosemirror-commands": "^1.6.2", + "prosemirror-dropcursor": "^1.8.1", + "prosemirror-gapcursor": "^1.3.2", + "prosemirror-history": "^1.4.1", + "prosemirror-inputrules": "^1.4.0", + "prosemirror-keymap": "^1.2.3", + "prosemirror-model": "^1.25.7", + "prosemirror-schema-list": "^1.5.0", + "prosemirror-state": "^1.4.4", + "prosemirror-tables": "^1.8.0", + "prosemirror-transform": "^1.12.0", + "prosemirror-view": "^1.41.8" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + } + }, + "node_modules/@tiptap/starter-kit": { + "version": "3.27.1", + "resolved": "https://registry.npmjs.org/@tiptap/starter-kit/-/starter-kit-3.27.1.tgz", + "integrity": "sha512-vfxRsqW8rCc0k4pzo0ilU3wobVi2wqVj88VZI2SlgZlNnUAkrDGDIAph7CTa9k9fshV+O1ivpEgPC5yC046jow==", + "license": "MIT", + "dependencies": { + "@tiptap/core": "^3.27.1", + "@tiptap/extension-blockquote": "^3.27.1", + "@tiptap/extension-bold": "^3.27.1", + "@tiptap/extension-bullet-list": "^3.27.1", + "@tiptap/extension-code": "^3.27.1", + "@tiptap/extension-code-block": "^3.27.1", + "@tiptap/extension-document": "^3.27.1", + "@tiptap/extension-dropcursor": "^3.27.1", + "@tiptap/extension-gapcursor": "^3.27.1", + "@tiptap/extension-hard-break": "^3.27.1", + "@tiptap/extension-heading": "^3.27.1", + "@tiptap/extension-horizontal-rule": "^3.27.1", + "@tiptap/extension-italic": "^3.27.1", + "@tiptap/extension-link": "^3.27.1", + "@tiptap/extension-list": "^3.27.1", + "@tiptap/extension-list-item": "^3.27.1", + "@tiptap/extension-list-keymap": "^3.27.1", + "@tiptap/extension-ordered-list": "^3.27.1", + "@tiptap/extension-paragraph": "^3.27.1", + "@tiptap/extension-strike": "^3.27.1", + "@tiptap/extension-text": "^3.27.1", + "@tiptap/extension-underline": "^3.27.1", + "@tiptap/extensions": "^3.27.1", + "@tiptap/pm": "^3.27.1" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + } + }, + "node_modules/@types/node": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-26.1.0.tgz", + "integrity": "sha512-O0A1G3xPGy4w7AgQdAQYUlQ+BKk2Oovw8eRpofyp5KdBZULnbe+WqaOVNrm705SHphCiG4XHsACrSmPu1f+Kgw==", + "license": "MIT", + "peer": true, + "dependencies": { + "undici-types": "~8.3.0" + } + }, + "node_modules/@types/webidl-conversions": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz", + "integrity": "sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA==", + "license": "MIT" + }, + "node_modules/@types/whatwg-mimetype": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/whatwg-mimetype/-/whatwg-mimetype-3.0.2.tgz", + "integrity": "sha512-c2AKvDT8ToxLIOUlN51gTiHXflsfIFisS4pO7pDPoKouJCESkhZnEy623gwP9laCy5lnLDAw1vAzu2vM2YLOrA==", + "license": "MIT", + "peer": true + }, + "node_modules/@types/whatwg-url": { + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-13.0.0.tgz", + "integrity": "sha512-N8WXpbE6Wgri7KUSvrmQcqrMllKZ9uxkYWMt+mCSGwNc0Hsw9VQTW7ApqI4XNrx6/SaM2QQJCzMPDEXE058s+Q==", + "license": "MIT", + "dependencies": { + "@types/webidl-conversions": "*" + } + }, + "node_modules/@types/ws": { + "version": "8.18.1", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.1.tgz", + "integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==", + "license": "MIT", + "peer": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/accepts": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "license": "MIT", + "dependencies": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/async": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", + "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", + "license": "MIT" + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "license": "MIT" + }, + "node_modules/body-parser": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.3.0.tgz", + "integrity": "sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==", + "license": "MIT", + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^2.0.0", + "debug": "^4.4.3", + "http-errors": "^2.0.1", + "iconv-lite": "^0.7.2", + "on-finished": "^2.4.1", + "qs": "^6.15.2", + "raw-body": "^3.0.2", + "type-is": "^2.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/body-parser/node_modules/content-type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.0.0.tgz", + "integrity": "sha512-j/O/d7GcZCyNl7/hwZAb606rzqkyvaDctLmckbxLzHvFBzTJHuGEdodATcP3yIRoDrLHkIATJuvzbFlp/ki2cQ==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/brace-expansion": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.1.tgz", + "integrity": "sha512-WR1cURNjuvBLMZBMbqM0UoE+WAfdUcEV1ccD8PVBVOI+Z3ND4+SZbN8RsfT2bMuG1qwz5RFvPukSZm5fF2D5eA==", + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/bson": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/bson/-/bson-7.3.1.tgz", + "integrity": "sha512-h/C0qe6857pQhcSJHLfsR1uYGj98Ge3wKAD3Ed9KqH3wcVh+BM4Jq4xISD7vs9OPuT07n+q3QQVjslJ286j6ag==", + "license": "Apache-2.0", + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", + "license": "BSD-3-Clause" + }, + "node_modules/buffer-image-size": { + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/buffer-image-size/-/buffer-image-size-0.6.4.tgz", + "integrity": "sha512-nEh+kZOPY1w+gcCMobZ6ETUp9WfibndnosbpwB1iJk/8Gt5ZF2bhS6+B6bPYz424KtwsR6Rflc3tCz1/ghX2dQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "@types/node": "*" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/cluster-key-slot": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.1.tgz", + "integrity": "sha512-rwHwUfXL40Chm1r08yrhU3qpUvdVlgkKNeyeGPOxnW8/SyVDvgRaed/Uz54AqWNaTCAThlj6QAs3TZcKI0xDEw==", + "license": "Apache-2.0", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/content-disposition": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.1.0.tgz", + "integrity": "sha512-5jRCH9Z/+DRP7rkvY83B+yGIGX96OYdJmzngqnw2SBSxqCFPd0w2km3s5iawpGX8krnwSGmF0FW5Nhr0Hfai3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-parser": { + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.7.tgz", + "integrity": "sha512-nGUvgXnotP3BsjiLX2ypbQnWoGUPIIfHQNZkkC668ntrzGWEZVW70HDEB1qnNGMicPje6EttlIgzo51YSwNQGw==", + "license": "MIT", + "dependencies": { + "cookie": "0.7.2", + "cookie-signature": "1.0.6" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==", + "license": "MIT" + }, + "node_modules/cors": { + "version": "2.8.6", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz", + "integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==", + "license": "MIT", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/dayjs": { + "version": "1.11.21", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.21.tgz", + "integrity": "sha512-98IT+HOahAisibz/yjKbzuOBwYcjJ7BCLPzARyHiyEBmRz4fatF+KPJszEHXsGYjUG234aH/cOjW1wwTbKUZlA==", + "license": "MIT" + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/denque": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz", + "integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==", + "license": "Apache-2.0", + "engines": { + "node": ">=0.10" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "license": "MIT", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/dom-serializer/node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "license": "BSD-2-Clause" + }, + "node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "license": "BSD-2-Clause", + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/domutils": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.2.2.tgz", + "integrity": "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==", + "license": "BSD-2-Clause", + "dependencies": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, + "node_modules/dotenv": { + "version": "17.4.2", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.4.2.tgz", + "integrity": "sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "license": "Apache-2.0", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/ejs": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-4.0.1.tgz", + "integrity": "sha512-krvQtxc0btwSm/nvnt1UpnaFDFVJpJ0fdckmALpCgShsr/iGYHTnJiUliZTgmzq/UxTX33TtOQVKaNigMQp/6Q==", + "license": "Apache-2.0", + "dependencies": { + "jake": "^10.9.1" + }, + "bin": { + "ejs": "bin/cli.js" + }, + "engines": { + "node": ">=0.12.18" + } + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/entities": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz", + "integrity": "sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/esbuild": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.1.tgz", + "integrity": "sha512-HrJrvZv5ayxBzPfwphOoNzkzOIIlifzk0KJrGK2c8R4+LKpMtpYLQeUdjnwjWv/LZlkH2laZk+4w78pi99D4Vw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.28.1", + "@esbuild/android-arm": "0.28.1", + "@esbuild/android-arm64": "0.28.1", + "@esbuild/android-x64": "0.28.1", + "@esbuild/darwin-arm64": "0.28.1", + "@esbuild/darwin-x64": "0.28.1", + "@esbuild/freebsd-arm64": "0.28.1", + "@esbuild/freebsd-x64": "0.28.1", + "@esbuild/linux-arm": "0.28.1", + "@esbuild/linux-arm64": "0.28.1", + "@esbuild/linux-ia32": "0.28.1", + "@esbuild/linux-loong64": "0.28.1", + "@esbuild/linux-mips64el": "0.28.1", + "@esbuild/linux-ppc64": "0.28.1", + "@esbuild/linux-riscv64": "0.28.1", + "@esbuild/linux-s390x": "0.28.1", + "@esbuild/linux-x64": "0.28.1", + "@esbuild/netbsd-arm64": "0.28.1", + "@esbuild/netbsd-x64": "0.28.1", + "@esbuild/openbsd-arm64": "0.28.1", + "@esbuild/openbsd-x64": "0.28.1", + "@esbuild/openharmony-arm64": "0.28.1", + "@esbuild/sunos-x64": "0.28.1", + "@esbuild/win32-arm64": "0.28.1", + "@esbuild/win32-ia32": "0.28.1", + "@esbuild/win32-x64": "0.28.1" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", + "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", + "license": "MIT", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.2.1", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.0", + "depd": "^2.0.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "merge-descriptors": "^2.0.0", + "mime-types": "^3.0.0", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.7", + "qs": "^6.14.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", + "send": "^1.1.0", + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.0.1", + "vary": "^1.1.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/express/node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/filelist": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.6.tgz", + "integrity": "sha512-5giy2PkLYY1cP39p17Ech+2xlpTRL9HLspOfEgm0L6CwBXBTgsK5ou0JtzYuepxkaQ/tvhCFIJ5uXo0OrM2DxA==", + "license": "Apache-2.0", + "dependencies": { + "minimatch": "^5.0.1" + } + }, + "node_modules/finalhandler": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", + "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/happy-dom": { + "version": "20.10.6", + "resolved": "https://registry.npmjs.org/happy-dom/-/happy-dom-20.10.6.tgz", + "integrity": "sha512-6QD0ilzDDt93tX44y8tbmZdAcdTRYDhUP+Asgi6pC8Pp5IA3cvaZGyoVN/EGtlq9ziT65iPuBBn3ASLr6hCgVw==", + "license": "MIT", + "peer": true, + "dependencies": { + "@types/node": ">=20.0.0", + "@types/whatwg-mimetype": "^3.0.2", + "@types/ws": "^8.18.1", + "buffer-image-size": "^0.6.4", + "entities": "^7.0.1", + "whatwg-mimetype": "^3.0.0", + "ws": "^8.21.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/helmet": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/helmet/-/helmet-8.2.0.tgz", + "integrity": "sha512-DRgTIUgnWcJ62KyarxxziuqYxKGnR6Rgg19BlbucN/dpmJbl1XOit6qvoOX0ZT+HhWe5OUVhU/a1zpGyc1xA0Q==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/EvanHahn" + } + }, + "node_modules/htmlparser2": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-10.1.0.tgz", + "integrity": "sha512-VTZkM9GWRAtEpveh7MSF6SjjrpNVNNVJfFup7xTY3UpFtm67foy9HDVXneLtFVt4pMz5kZtgNcvCniNFb1hlEQ==", + "funding": [ + "https://github.com/fb55/htmlparser2?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "license": "MIT", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.2.2", + "entities": "^7.0.1" + } + }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/iconv-lite": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz", + "integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ioredis": { + "version": "5.11.1", + "resolved": "https://registry.npmjs.org/ioredis/-/ioredis-5.11.1.tgz", + "integrity": "sha512-ehuGcf94bQXhfagULNXrJdfnWO38v070jxSx/qE87Kjzmu2fU7ro5EFAb+OPituLqgfyuQaym5DlrNydW2sJ9A==", + "license": "MIT", + "dependencies": { + "@ioredis/commands": "1.10.0", + "cluster-key-slot": "1.1.1", + "debug": "4.4.3", + "denque": "2.1.0", + "redis-errors": "1.2.0", + "redis-parser": "3.0.0", + "standard-as-callback": "2.1.0" + }, + "engines": { + "node": ">=12.22.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/ioredis" + } + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "license": "MIT" + }, + "node_modules/jake": { + "version": "10.9.4", + "resolved": "https://registry.npmjs.org/jake/-/jake-10.9.4.tgz", + "integrity": "sha512-wpHYzhxiVQL+IV05BLE2Xn34zW1S223hvjtqk0+gsPrwd/8JNLXJgZZM/iPFsYc1xyphF+6M6EvdE5E9MBGkDA==", + "license": "Apache-2.0", + "dependencies": { + "async": "^3.2.6", + "filelist": "^1.0.4", + "picocolors": "^1.1.1" + }, + "bin": { + "jake": "bin/cli.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jsonwebtoken": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.3.tgz", + "integrity": "sha512-MT/xP0CrubFRNLNKvxJ2BYfy53Zkm++5bX9dtuPbqAeQpTVe0MQTFhao8+Cp//EmJp244xt6Drw/GVEGCUj40g==", + "license": "MIT", + "dependencies": { + "jws": "^4.0.1", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=12", + "npm": ">=6" + } + }, + "node_modules/jwa": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.1.tgz", + "integrity": "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==", + "license": "MIT", + "dependencies": { + "buffer-equal-constant-time": "^1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.1.tgz", + "integrity": "sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA==", + "license": "MIT", + "dependencies": { + "jwa": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/launder": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/launder/-/launder-1.7.1.tgz", + "integrity": "sha512-mU6WRz5EusL9ZZuiZ5SO4Y6C0P9PAUR9iwdb6bzj4KDihm28DiHFw+/yk9DBH4f+Pv1wuzQ4e2jV3oQ7mkIqvw==", + "license": "MIT", + "dependencies": { + "dayjs": "^1.11.7" + } + }, + "node_modules/linkifyjs": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/linkifyjs/-/linkifyjs-4.3.3.tgz", + "integrity": "sha512-P8aEP5U/D1/IlTY2OeYsErdwh9bGuLE30NcXtKEjgdHcahveQoQwM2yZNsioQHsWFz0P7KKudisbrzCgR0sDHg==", + "license": "MIT" + }, + "node_modules/lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==", + "license": "MIT" + }, + "node_modules/lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==", + "license": "MIT" + }, + "node_modules/lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==", + "license": "MIT" + }, + "node_modules/lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==", + "license": "MIT" + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "license": "MIT" + }, + "node_modules/lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==", + "license": "MIT" + }, + "node_modules/lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", + "license": "MIT" + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/memory-pager": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", + "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==", + "license": "MIT" + }, + "node_modules/merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/minimatch": { + "version": "5.1.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.9.tgz", + "integrity": "sha512-7o1wEA2RyMP7Iu7GNba9vc0RWWGACJOCZBJX2GJWip0ikV+wcOsgVuY9uE8CPiyQhkGFSlhuSkZPavN7u1c2Fw==", + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mongodb": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-7.4.0.tgz", + "integrity": "sha512-giySkkdYiwoBFo/oCc8nzov3xOYZ/sB8OpAYk5GINRLEjVw0LDsm8xgQL0XMTyU4extQlDZjhdUr1ZEwKFaazw==", + "license": "Apache-2.0", + "dependencies": { + "@mongodb-js/saslprep": "^1.3.0", + "bson": "^7.2.0", + "mongodb-connection-string-url": "^7.0.0" + }, + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@aws-sdk/credential-providers": "^3.806.0", + "@mongodb-js/zstd": "^7.0.0", + "gcp-metadata": "^7.0.1", + "kerberos": "^7.0.0", + "mongodb-client-encryption": ">=7.0.0 <7.1.0", + "snappy": "^7.3.2", + "socks": "^2.8.6" + }, + "peerDependenciesMeta": { + "@aws-sdk/credential-providers": { + "optional": true + }, + "@mongodb-js/zstd": { + "optional": true + }, + "gcp-metadata": { + "optional": true + }, + "kerberos": { + "optional": true + }, + "mongodb-client-encryption": { + "optional": true + }, + "snappy": { + "optional": true + }, + "socks": { + "optional": true + } + } + }, + "node_modules/mongodb-connection-string-url": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-7.0.1.tgz", + "integrity": "sha512-h0AZ9A7IDVwwHyMxmdMXKy+9oNlF0zFoahHiX3vQ8e3KFcSP3VmsmfvtRSuLPxmyv2vjIDxqty8smTgie/SNRQ==", + "license": "Apache-2.0", + "dependencies": { + "@types/whatwg-url": "^13.0.0", + "whatwg-url": "^14.1.0" + }, + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.15", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.15.tgz", + "integrity": "sha512-y7Wygv/7mEOvxTuEQDB8StXdMRBWf1kR/tlhAzBRUFkB2jfcLOAxO/SHmOO2zgz1pVgK29/kyupn059/bCHdjA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/negotiator": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", + "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/orderedmap": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/orderedmap/-/orderedmap-2.1.1.tgz", + "integrity": "sha512-TvAWxi0nDe1j/rtMcWcIj94+Ffe6n7zhow33h40SKxmsmozs6dz/e+EajymfoFcHd7sxNn8yHM8839uixMOV6g==", + "license": "MIT" + }, + "node_modules/parse-srcset": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/parse-srcset/-/parse-srcset-1.0.2.tgz", + "integrity": "sha512-/2qh0lav6CmI15FzA3i/2Bzk2zCgQhGMkvhOhKNcBVQ1ldgpbfiNTVslmooUmWJcADi1f1kIeynbDRVzNlfR6Q==", + "license": "MIT" + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz", + "integrity": "sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "license": "ISC" + }, + "node_modules/postcss": { + "version": "8.5.16", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.16.tgz", + "integrity": "sha512-vuwillviilfKZsg0VGj5R/YwwcHx4SLsIOI/7K6mQkWx+l5cUHTjj5g0AasTBcyXsbfTgrwsUNmVUb5xVwyPwg==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.12", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/prosemirror-changeset": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/prosemirror-changeset/-/prosemirror-changeset-2.4.1.tgz", + "integrity": "sha512-96WBLhOaYhJ+kPhLg3uW359Tz6I/MfcrQfL4EGv4SrcqKEMC1gmoGrXHecPE8eOwTVCJ4IwgfzM8fFad25wNfw==", + "license": "MIT", + "dependencies": { + "prosemirror-transform": "^1.0.0" + } + }, + "node_modules/prosemirror-commands": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/prosemirror-commands/-/prosemirror-commands-1.7.1.tgz", + "integrity": "sha512-rT7qZnQtx5c0/y/KlYaGvtG411S97UaL6gdp6RIZ23DLHanMYLyfGBV5DtSnZdthQql7W+lEVbpSfwtO8T+L2w==", + "license": "MIT", + "dependencies": { + "prosemirror-model": "^1.0.0", + "prosemirror-state": "^1.0.0", + "prosemirror-transform": "^1.10.2" + } + }, + "node_modules/prosemirror-dropcursor": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/prosemirror-dropcursor/-/prosemirror-dropcursor-1.8.2.tgz", + "integrity": "sha512-CCk6Gyx9+Tt2sbYk5NK0nB1ukHi2ryaRgadV/LvyNuO3ena1payM2z6Cg0vO1ebK8cxbzo41ku2DE5Axj1Zuiw==", + "license": "MIT", + "dependencies": { + "prosemirror-state": "^1.0.0", + "prosemirror-transform": "^1.1.0", + "prosemirror-view": "^1.1.0" + } + }, + "node_modules/prosemirror-gapcursor": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/prosemirror-gapcursor/-/prosemirror-gapcursor-1.4.1.tgz", + "integrity": "sha512-pMdYaEnjNMSwl11yjEGtgTmLkR08m/Vl+Jj443167p9eB3HVQKhYCc4gmHVDsLPODfZfjr/MmirsdyZziXbQKw==", + "license": "MIT", + "dependencies": { + "prosemirror-keymap": "^1.0.0", + "prosemirror-model": "^1.0.0", + "prosemirror-state": "^1.0.0", + "prosemirror-view": "^1.0.0" + } + }, + "node_modules/prosemirror-history": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/prosemirror-history/-/prosemirror-history-1.5.0.tgz", + "integrity": "sha512-zlzTiH01eKA55UAf1MEjtssJeHnGxO0j4K4Dpx+gnmX9n+SHNlDqI2oO1Kv1iPN5B1dm5fsljCfqKF9nFL6HRg==", + "license": "MIT", + "dependencies": { + "prosemirror-state": "^1.2.2", + "prosemirror-transform": "^1.0.0", + "prosemirror-view": "^1.31.0", + "rope-sequence": "^1.3.0" + } + }, + "node_modules/prosemirror-inputrules": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/prosemirror-inputrules/-/prosemirror-inputrules-1.5.1.tgz", + "integrity": "sha512-7wj4uMjKaXWAQ1CDgxNzNtR9AlsuwzHfdFH1ygEHA2KHF2DOEaXl1CJfNPAKCg9qNEh4rum975QLaCiQPyY6Fw==", + "license": "MIT", + "dependencies": { + "prosemirror-state": "^1.0.0", + "prosemirror-transform": "^1.0.0" + } + }, + "node_modules/prosemirror-keymap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/prosemirror-keymap/-/prosemirror-keymap-1.2.3.tgz", + "integrity": "sha512-4HucRlpiLd1IPQQXNqeo81BGtkY8Ai5smHhKW9jjPKRc2wQIxksg7Hl1tTI2IfT2B/LgX6bfYvXxEpJl7aKYKw==", + "license": "MIT", + "dependencies": { + "prosemirror-state": "^1.0.0", + "w3c-keyname": "^2.2.0" + } + }, + "node_modules/prosemirror-model": { + "version": "1.25.9", + "resolved": "https://registry.npmjs.org/prosemirror-model/-/prosemirror-model-1.25.9.tgz", + "integrity": "sha512-pRTklkDDMMRopyoAcrr9wV/8g/RYgrLHBuJAb5hlEuYZRdm5yqmPjWId83fpBwPpSFqEdja0H7Dfd7z1X/npcA==", + "license": "MIT", + "dependencies": { + "orderedmap": "^2.0.0" + } + }, + "node_modules/prosemirror-schema-list": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/prosemirror-schema-list/-/prosemirror-schema-list-1.5.1.tgz", + "integrity": "sha512-927lFx/uwyQaGwJxLWCZRkjXG0p48KpMj6ueoYiu4JX05GGuGcgzAy62dfiV8eFZftgyBUvLx76RsMe20fJl+Q==", + "license": "MIT", + "dependencies": { + "prosemirror-model": "^1.0.0", + "prosemirror-state": "^1.0.0", + "prosemirror-transform": "^1.7.3" + } + }, + "node_modules/prosemirror-state": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/prosemirror-state/-/prosemirror-state-1.4.4.tgz", + "integrity": "sha512-6jiYHH2CIGbCfnxdHbXZ12gySFY/fz/ulZE333G6bPqIZ4F+TXo9ifiR86nAHpWnfoNjOb3o5ESi7J8Uz1jXHw==", + "license": "MIT", + "dependencies": { + "prosemirror-model": "^1.0.0", + "prosemirror-transform": "^1.0.0", + "prosemirror-view": "^1.27.0" + } + }, + "node_modules/prosemirror-tables": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/prosemirror-tables/-/prosemirror-tables-1.8.5.tgz", + "integrity": "sha512-V/0cDCsHKHe/tfWkeCmthNUcEp1IVO3p6vwN8XtwE9PZQLAZJigbw3QoraAdfJPir4NKJtNvOB8oYGKRl+t0Dw==", + "license": "MIT", + "dependencies": { + "prosemirror-keymap": "^1.2.3", + "prosemirror-model": "^1.25.4", + "prosemirror-state": "^1.4.4", + "prosemirror-transform": "^1.10.5", + "prosemirror-view": "^1.41.4" + } + }, + "node_modules/prosemirror-transform": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.12.0.tgz", + "integrity": "sha512-GxboyN4AMIsoHNtz5uf2r2Ru551i5hWeCMD6E2Ib4Eogqoub0NflniaBPVQ4MrGE5yZ8JV9tUHg9qcZTTrcN4w==", + "license": "MIT", + "dependencies": { + "prosemirror-model": "^1.21.0" + } + }, + "node_modules/prosemirror-view": { + "version": "1.42.0", + "resolved": "https://registry.npmjs.org/prosemirror-view/-/prosemirror-view-1.42.0.tgz", + "integrity": "sha512-N54DF3OXNWDuP81G1kbfCys8ZzIjuL1VnvJ2mk5STSu/fNxWIcX/EutQLA3s9KR/2wVhgDi4hzBB/1fINVxk0A==", + "license": "MIT", + "dependencies": { + "prosemirror-model": "^1.25.8", + "prosemirror-state": "^1.0.0", + "prosemirror-transform": "^1.1.0" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/qs": { + "version": "6.15.3", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.3.tgz", + "integrity": "sha512-O9gl3zCl5h5blw1KGUzQKhA5oUXSl8rwUIM5o0S3nCXMliSvy5Dzx7/DJcI+SwgICv+IneSZwhBh1oSyEHA71A==", + "license": "BSD-3-Clause", + "dependencies": { + "es-define-property": "^1.0.1", + "side-channel": "^1.1.1" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.3.0.tgz", + "integrity": "sha512-hek2mFQpPuI4E1BBKrSto+BU3e3x4xuarsbiwr3+lf7p44juvFMV0XFWQAP3xUyqXA4RrXLIoaSUGbSt056ZMw==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/raw-body": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", + "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.7.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/redis-errors": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz", + "integrity": "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/redis-parser": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz", + "integrity": "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==", + "license": "MIT", + "dependencies": { + "redis-errors": "^1.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/rope-sequence": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/rope-sequence/-/rope-sequence-1.3.4.tgz", + "integrity": "sha512-UT5EDe2cu2E/6O4igUr5PSFs23nvvukicWHx6GnOPlHAiiYbzNuCRQCuiUdHJQcqKalLKlrYJnjY0ySGsXNQXQ==", + "license": "MIT" + }, + "node_modules/router": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", + "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "depd": "^2.0.0", + "is-promise": "^4.0.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^8.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/sanitize-html": { + "version": "2.17.5", + "resolved": "https://registry.npmjs.org/sanitize-html/-/sanitize-html-2.17.5.tgz", + "integrity": "sha512-ZmU1joGRrvoyctKIiuwUxqR6moLoU2Wk+2bMccN6f7UwhAmwYDvWziqPxRDDN2Qip62NqnIrVrT9akbL6Wretg==", + "license": "MIT", + "dependencies": { + "deepmerge": "^4.2.2", + "escape-string-regexp": "^4.0.0", + "htmlparser2": "^10.1.0", + "is-plain-object": "^5.0.0", + "launder": "^1.7.1", + "parse-srcset": "^1.0.2", + "postcss": "^8.3.11" + } + }, + "node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/send": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", + "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.3", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.1", + "mime-types": "^3.0.2", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/serve-static": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz", + "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==", + "license": "MIT", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/side-channel": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz", + "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4", + "side-channel-list": "^1.0.1", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/sparse-bitfield": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", + "integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==", + "license": "MIT", + "dependencies": { + "memory-pager": "^1.0.2" + } + }, + "node_modules/standard-as-callback": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/standard-as-callback/-/standard-as-callback-2.1.0.tgz", + "integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==", + "license": "MIT" + }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/tr46": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-5.1.1.tgz", + "integrity": "sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==", + "license": "MIT", + "dependencies": { + "punycode": "^2.3.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/type-is": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.1.0.tgz", + "integrity": "sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==", + "license": "MIT", + "dependencies": { + "content-type": "^2.0.0", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/type-is/node_modules/content-type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.0.0.tgz", + "integrity": "sha512-j/O/d7GcZCyNl7/hwZAb606rzqkyvaDctLmckbxLzHvFBzTJHuGEdodATcP3yIRoDrLHkIATJuvzbFlp/ki2cQ==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/undici-types": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.3.0.tgz", + "integrity": "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ==", + "license": "MIT", + "peer": true + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/w3c-keyname": { + "version": "2.2.8", + "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz", + "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==", + "license": "MIT" + }, + "node_modules/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/whatwg-mimetype": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz", + "integrity": "sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/whatwg-url": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.2.0.tgz", + "integrity": "sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw==", + "license": "MIT", + "dependencies": { + "tr46": "^5.1.0", + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" + }, + "node_modules/ws": { + "version": "8.21.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz", + "integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..ea9d842 --- /dev/null +++ b/package.json @@ -0,0 +1,30 @@ +{ + "name": "stomping.me", + "version": "1.0.0", + "description": "AGWOL Stories Service (stomping.me)", + "main": "src/app.js", + "scripts": { + "start": "node src/app.js", + "dev": "NODE_ENV=development node --watch src/app.js", + "build:editor": "esbuild src/editor/main.js --bundle --outfile=src/public/admin-js/editor-bundle.js --format=iife --minify" + }, + "dependencies": { + "@tiptap/core": "^3.27.1", + "@tiptap/extension-image": "^3.27.1", + "@tiptap/html": "^3.27.1", + "@tiptap/starter-kit": "^3.27.1", + "cookie-parser": "^1.4.7", + "cors": "^2.8.6", + "dotenv": "^17.3.1", + "ejs": "^4.0.1", + "express": "^5.2.1", + "helmet": "^8.1.0", + "ioredis": "^5.9.3", + "jsonwebtoken": "^9.0.3", + "mongodb": "^7.1.0", + "sanitize-html": "^2.17.5" + }, + "devDependencies": { + "esbuild": "^0.28.1" + } +} diff --git a/src/app.js b/src/app.js new file mode 100644 index 0000000..e21f92a --- /dev/null +++ b/src/app.js @@ -0,0 +1,68 @@ +'use strict'; + +require('dotenv').config({ path: '/etc/AGWOL/stomping/.env' }); + +const path = require('path'); +const express = require('express'); +const helmet = require('helmet'); +const cors = require('cors'); +const cookieParser = require('cookie-parser'); + +const { env } = require('./config/env'); +const { connectMongo } = require('./config/mongo'); +const { createRedis } = require('./config/redis'); +const { router: authRoutes } = require('./routes/auth'); +const indexRoutes = require('./routes/index'); +const adminPagesRoutes = require('./routes/adminPages'); +const adminFoldersRoutes = require('./routes/adminFolders'); +const adminTagsRoutes = require('./routes/adminTags'); +const adminStoriesRoutes = require('./routes/adminStories'); +const adminChaptersRoutes = require('./routes/adminChapters'); +const publicPagesRoutes = require('./routes/publicPages'); + +async function start() { + await connectMongo(); + createRedis(); + + const app = express(); + + // nginx is the only proxy hop — trust loopback only. + app.set('trust proxy', 'loopback'); + + app.use(helmet({ + // Stories/covers are image-by-URL (design-018 §4 — no upload pipeline in + // v1), so images can come from any https host, not just our own. + contentSecurityPolicy: { + directives: { + ...helmet.contentSecurityPolicy.getDefaultDirectives(), + 'img-src': ["'self'", 'data:', 'https:'], + }, + }, + })); + app.use(cors({ origin: env.ALLOWED_ORIGINS, credentials: true })); + app.use(cookieParser(env.COOKIE_SECRET)); + app.use(express.json()); + app.use(express.urlencoded({ extended: false })); + + app.set('view engine', 'ejs'); + app.set('views', path.join(__dirname, 'views')); + app.use(express.static(path.join(__dirname, 'public'))); + + app.use('/', authRoutes); + app.use('/', adminPagesRoutes); + app.use('/', adminFoldersRoutes); + app.use('/', adminTagsRoutes); + app.use('/', adminStoriesRoutes); + app.use('/', adminChaptersRoutes); + app.use('/', indexRoutes); + app.use('/', publicPagesRoutes); + + app.listen(env.PORT, '127.0.0.1', () => { + console.log(`stomping.me running on port ${env.PORT}`); + }); +} + +start().catch(err => { + console.error('[startup] fatal:', err.message); + process.exit(1); +}); diff --git a/src/config/env.js b/src/config/env.js new file mode 100644 index 0000000..4bdff37 --- /dev/null +++ b/src/config/env.js @@ -0,0 +1,45 @@ +'use strict'; + +require('dotenv').config({ path: '/etc/AGWOL/stomping/.env' }); + +const env = { + NODE_ENV: process.env.NODE_ENV || 'production', + PORT: parseInt(process.env.PORT || '5003', 10), + + // Auth — shared platform HS256 secret, must match auth.agwol.com + ACCESS_TOKEN_SECRET: process.env.ACCESS_TOKEN_SECRET, + COOKIE_SECRET: process.env.COOKIE_SECRET, + + // MongoDB — own `stomping` database, per-service pattern + MONGODB_URI: process.env.MONGODB_URI, + + // Redis — shared instance (revocation checks, same DB as auth/api/hub/chat) + REDIS_HOST: process.env.REDIS_HOST || 'localhost', + REDIS_PORT: parseInt(process.env.REDIS_PORT || '6379', 10), + REDIS_PASSWORD: process.env.REDIS_PASSWORD || undefined, + REDIS_DB: parseInt(process.env.REDIS_DB || '0', 10), + + // CORS + ALLOWED_ORIGINS: (process.env.ALLOWED_ORIGINS || 'https://stomping.me').split(','), + + // OIDC — standard client of auth.agwol.com + AUTH_PUBLIC_ORIGIN: process.env.AUTH_PUBLIC_ORIGIN || 'https://auth.agwol.com', + AUTH_INTERNAL_URL: process.env.AUTH_INTERNAL_URL || 'http://127.0.0.1:3001', + OIDC_CLIENT_ID: process.env.OIDC_CLIENT_ID, + OIDC_CLIENT_SECRET: process.env.OIDC_CLIENT_SECRET, + OIDC_REDIRECT_URI: process.env.OIDC_REDIRECT_URI, + OIDC_POST_LOGOUT_URI: process.env.OIDC_POST_LOGOUT_URI, +}; + +const required = [ + 'ACCESS_TOKEN_SECRET', 'COOKIE_SECRET', 'MONGODB_URI', + 'REDIS_PASSWORD', 'OIDC_CLIENT_ID', 'OIDC_CLIENT_SECRET', 'OIDC_REDIRECT_URI', +]; +for (const key of required) { + if (!env[key]) { + console.error(`[ENV] Missing required environment variable: ${key}`); + process.exit(1); + } +} + +module.exports = { env }; diff --git a/src/config/mongo.js b/src/config/mongo.js new file mode 100644 index 0000000..c0677f2 --- /dev/null +++ b/src/config/mongo.js @@ -0,0 +1,56 @@ +'use strict'; + +const { MongoClient, ServerApiVersion } = require('mongodb'); +const { env } = require('./env'); + +let client = null; +let db = null; + +async function connectMongo() { + client = new MongoClient(env.MONGODB_URI, { + serverApi: { + version: ServerApiVersion.v1, + strict: true, + deprecationErrors: true, + }, + serverSelectionTimeoutMS: 10000, + }); + + await client.connect(); + db = client.db('stomping'); + + // Collections + indexes (design-018 §2.1–2.4). comments/ratings (§2.5–2.6) + // are schema-reserved only — not created until Phase 6. createIndex is a + // no-op if the index already exists, so this is safe to run on every boot. + const folders = db.collection('folders'); + await folders.createIndex({ slug: 1 }, { unique: true }); + await folders.createIndex({ parent_id: 1 }); + + const stories = db.collection('stories'); + await stories.createIndex({ slug: 1 }, { unique: true }); + await stories.createIndex({ folder_id: 1 }); + await stories.createIndex({ status: 1, folder_id: 1 }); + await stories.createIndex({ story_type: 1 }); + await stories.createIndex({ published_at: 1 }); + + const chapters = db.collection('chapters'); + await chapters.createIndex({ story_id: 1, slug: 1 }, { unique: true }); + await chapters.createIndex({ story_id: 1, display_order: 1 }); + + const tags = db.collection('tags'); + await tags.createIndex({ slug: 1 }, { unique: true }); + + console.log('[MongoDB] Connected to stomping database, indexes ready'); + return db; +} + +function getDb() { + if (!db) throw new Error('MongoDB not initialized'); + return db; +} + +async function closeMongo() { + if (client) await client.close(); +} + +module.exports = { connectMongo, getDb, closeMongo }; diff --git a/src/config/redis.js b/src/config/redis.js new file mode 100644 index 0000000..3b1690d --- /dev/null +++ b/src/config/redis.js @@ -0,0 +1,28 @@ +'use strict'; + +const Redis = require('ioredis'); +const { env } = require('./env'); + +let redisClient = null; + +function createRedis() { + redisClient = new Redis({ + host: env.REDIS_HOST, + port: env.REDIS_PORT, + password: env.REDIS_PASSWORD, + db: env.REDIS_DB, + retryStrategy: (times) => Math.min(times * 50, 2000), + }); + + redisClient.on('connect', () => console.log('[Redis] Connected')); + redisClient.on('error', (err) => console.error('[Redis] Error', err.message)); + + return redisClient; +} + +function getRedis() { + if (!redisClient) throw new Error('Redis not initialized'); + return redisClient; +} + +module.exports = { createRedis, getRedis }; diff --git a/src/editor/main.js b/src/editor/main.js new file mode 100644 index 0000000..cc8e7b8 --- /dev/null +++ b/src/editor/main.js @@ -0,0 +1,21 @@ +// editor/main.js — bundled locally with esbuild (design-018 §4: "no CDN +// dependency"). Entry point for the browser-side TipTap instance; shares +// the exact extension list the server uses to render/sanitize +// (tiptapExtensions.js) so what you see in the editor is what gets saved. +import { Editor } from '@tiptap/core'; +import { StarterKit } from '@tiptap/starter-kit'; +import { Image } from '@tiptap/extension-image'; + +function createEditor({ element, content, onUpdate, onSelectionUpdate }) { + const editor = new Editor({ + element, + extensions: [StarterKit, Image], + content: content || '', + onUpdate: ({ editor }) => { if (onUpdate) onUpdate(editor); }, + onSelectionUpdate: ({ editor }) => { if (onSelectionUpdate) onSelectionUpdate(editor); }, + onTransaction: ({ editor }) => { if (onSelectionUpdate) onSelectionUpdate(editor); }, + }); + return editor; +} + +window.StompingEditor = { createEditor }; diff --git a/src/lib/folderTree.js b/src/lib/folderTree.js new file mode 100644 index 0000000..8e7672b --- /dev/null +++ b/src/lib/folderTree.js @@ -0,0 +1,58 @@ +// folderTree.js — re-parent cycle detection for admin folder CRUD +// (design-018 §6 Phase 3: "incl. re-parent — must reject cycles"). +'use strict'; + +// Would setting `folderId`'s parent to `newParentId` create a cycle? Walks up +// from the proposed new parent; if folderId's own id is ever reached, the +// move would make folderId an ancestor of itself. +async function wouldCreateCycle(db, folderId, newParentId) { + if (!newParentId) return false; + + const folderKey = String(folderId); + if (String(newParentId) === folderKey) return true; + + const folders = db.collection('folders'); + const seen = new Set(); + let current = newParentId; + + while (current) { + const key = String(current); + if (key === folderKey) return true; + if (seen.has(key)) break; // defensive — stop on a pre-existing corrupt loop + seen.add(key); + + const doc = await folders.findOne({ _id: current }, { projection: { parent_id: 1 } }); + if (!doc) break; + current = doc.parent_id; + } + + return false; +} + +// Flattens a folder list into depth-first tree order, annotating each with +// `depth` (0 = root) for indentation. Orphaned folders (parent_id points at +// something no longer present) are appended at depth 0 rather than dropped. +function buildFolderTree(folders) { + const byParent = new Map(); + const ids = new Set(folders.map(f => String(f._id))); + for (const folder of folders) { + const parentKey = folder.parent_id && ids.has(String(folder.parent_id)) + ? String(folder.parent_id) + : 'root'; + if (!byParent.has(parentKey)) byParent.set(parentKey, []); + byParent.get(parentKey).push(folder); + } + for (const list of byParent.values()) list.sort((a, b) => a.display_order - b.display_order); + + const out = []; + function walk(parentKey, depth) { + for (const folder of byParent.get(parentKey) || []) { + out.push({ ...folder, depth }); + walk(String(folder._id), depth + 1); + } + } + walk('root', 0); + return out; +} + +module.exports = { wouldCreateCycle, buildFolderTree }; diff --git a/src/lib/normalize.js b/src/lib/normalize.js new file mode 100644 index 0000000..110f725 --- /dev/null +++ b/src/lib/normalize.js @@ -0,0 +1,127 @@ +// normalize.js — shared strip-empty-to-null normalizer (design-018 §2, same +// pattern as design-015's castNormalizer.js). Every write passes through one +// of these before hitting Mongo, so render-if-present is enforced at the +// write path, not scattered across templates. +// +// created_at/updated_at are set by the caller at insert/update time, not +// here — matches the established convention (see castRoutes.js). +'use strict'; + +const { renderBodyHtml } = require('./renderTiptap'); +const { sanitizeBodyHtml } = require('./sanitizeHtml'); +const { countWords } = require('./wordCount'); + +const STORY_TYPES = ['one_shot', 'serial', 'bite_size']; +const CONTENT_RATINGS = ['general', 'teen', 'mature', 'adult']; +const SERIAL_STATUSES = ['ongoing', 'completed', 'hiatus']; +const ENTITY_STATUSES = ['draft', 'published']; +const TAG_KINDS = ['explicit', 'general']; + +function stripEmpty(value) { + if (typeof value === 'string') return value.trim() === '' ? null : value; + if (value !== null && typeof value === 'object' && !Array.isArray(value)) { + return normalizeObject(value); + } + return value; +} + +function normalizeObject(obj) { + const out = {}; + for (const key of Object.keys(obj)) out[key] = stripEmpty(obj[key]); + return out; +} + +function normalizeSlugArray(raw) { + if (!Array.isArray(raw)) return []; + return raw + .map(v => (typeof v === 'string' ? v.trim() : '')) + .filter(v => v !== ''); +} + +// ── folders (§2.1) ──────────────────────────────────────────────────────── + +function normalizeFolder(raw) { + return { + slug: String(raw.slug || '').trim(), + name: String(raw.name || '').trim(), + parent_id: raw.parent_id ?? null, + display_order: raw.display_order != null ? Number(raw.display_order) : 0, + }; +} + +// ── stories (§2.2) ──────────────────────────────────────────────────────── + +function normalizeStory(raw) { + return { + slug: String(raw.slug || '').trim(), + folder_id: raw.folder_id ?? null, + title: String(raw.title || '').trim(), + subtitle: stripEmpty(raw.subtitle ?? null), + badges: normalizeSlugArray(raw.badges), + summary: stripEmpty(raw.summary ?? null), + cover_url: stripEmpty(raw.cover_url ?? null), + story_type: STORY_TYPES.includes(raw.story_type) ? raw.story_type : 'one_shot', + content_rating: CONTENT_RATINGS.includes(raw.content_rating) ? raw.content_rating : 'general', + explicit_tags: normalizeSlugArray(raw.explicit_tags), + general_tags: normalizeSlugArray(raw.general_tags), + status: ENTITY_STATUSES.includes(raw.status) ? raw.status : 'draft', + serial_status: SERIAL_STATUSES.includes(raw.serial_status) ? raw.serial_status : null, + display_order: raw.display_order != null ? Number(raw.display_order) : 0, + chronological_order: raw.chronological_order != null && raw.chronological_order !== '' + ? Number(raw.chronological_order) : null, + published_at: raw.published_at ?? null, + word_count: 0, + rating_avg: null, + rating_count: 0, + author_user_id: Number(raw.author_user_id), + }; +} + +// ── chapters (§2.3) ─────────────────────────────────────────────────────── +// body_html/word_count are always derived from body_json here — never +// accepted from the caller — so JSON stays the one source of truth. + +function normalizeChapter(raw) { + const bodyJson = raw.body_json && typeof raw.body_json === 'object' + ? raw.body_json + : { type: 'doc', content: [] }; + + return { + story_id: raw.story_id, + slug: String(raw.slug || '').trim(), + title: String(raw.title || '').trim(), + display_order: raw.display_order != null ? Number(raw.display_order) : 0, + status: ENTITY_STATUSES.includes(raw.status) ? raw.status : 'draft', + body_json: bodyJson, + body_html: sanitizeBodyHtml(renderBodyHtml(bodyJson)), + note_top: stripEmpty(raw.note_top ?? null), + note_bottom: stripEmpty(raw.note_bottom ?? null), + word_count: countWords(bodyJson), + published_at: raw.published_at ?? null, + }; +} + +// ── tags (§2.4) ─────────────────────────────────────────────────────────── + +function normalizeTag(raw) { + return { + slug: String(raw.slug || '').trim().toLowerCase(), + label: String(raw.label || '').trim(), + kind: TAG_KINDS.includes(raw.kind) ? raw.kind : 'general', + description: stripEmpty(raw.description ?? null), + }; +} + +module.exports = { + stripEmpty, + normalizeObject, + normalizeFolder, + normalizeStory, + normalizeChapter, + normalizeTag, + STORY_TYPES, + CONTENT_RATINGS, + SERIAL_STATUSES, + ENTITY_STATUSES, + TAG_KINDS, +}; diff --git a/src/lib/renderTiptap.js b/src/lib/renderTiptap.js new file mode 100644 index 0000000..8ee1987 --- /dev/null +++ b/src/lib/renderTiptap.js @@ -0,0 +1,14 @@ +// renderTiptap.js — TipTap JSON -> HTML, server-side. JSON is the canonical +// source (design-018 §2.3); HTML is re-rendered from it on every save, never +// hand-edited, never trusted from the client directly. +'use strict'; + +const { generateHTML } = require('@tiptap/html/server'); +const extensions = require('./tiptapExtensions'); + +function renderBodyHtml(bodyJson) { + if (!bodyJson || typeof bodyJson !== 'object') return ''; + return generateHTML(bodyJson, extensions); +} + +module.exports = { renderBodyHtml }; diff --git a/src/lib/sanitizeHtml.js b/src/lib/sanitizeHtml.js new file mode 100644 index 0000000..630e4ec --- /dev/null +++ b/src/lib/sanitizeHtml.js @@ -0,0 +1,32 @@ +// sanitizeHtml.js — whitelist sanitizer for chapter body_html. TipTap's own +// output is structured, but this is sanitized anyway (design-018 §2.3) since +// it's a write path that will eventually be shared with other content +// (comments, someday). Whitelist matches exactly the tags/marks the v1 +// editor extensions (StarterKit + Image, see tiptapExtensions.js) can emit — +// nothing else is expected here, so nothing else is allowed through. +'use strict'; + +const sanitizeHtml = require('sanitize-html'); + +const OPTIONS = { + allowedTags: [ + 'p', 'br', 'hr', + 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', + 'strong', 'em', 's', + 'ul', 'ol', 'li', + 'blockquote', + 'a', 'img', + ], + allowedAttributes: { + a: ['href', 'target', 'rel'], + img: ['src', 'alt'], + }, + allowedSchemes: ['http', 'https', 'mailto'], + allowProtocolRelative: false, +}; + +function sanitizeBodyHtml(html) { + return sanitizeHtml(html || '', OPTIONS); +} + +module.exports = { sanitizeBodyHtml }; diff --git a/src/lib/storyAggregate.js b/src/lib/storyAggregate.js new file mode 100644 index 0000000..8ef90e9 --- /dev/null +++ b/src/lib/storyAggregate.js @@ -0,0 +1,21 @@ +// storyAggregate.js — story.word_count is the sum of its published chapters' +// word counts (design-018 §2.2). Recomputed on every chapter save/publish- +// toggle/delete — full recount each time, matching this project's established +// "cheap at this scale, full recount is correct" convention (design-018 §2.6 +// documents the same tradeoff for rating aggregates). +'use strict'; + +async function recomputeStoryWordCount(db, storyId) { + const chapters = await db.collection('chapters') + .find({ story_id: storyId, status: 'published' }, { projection: { word_count: 1 } }) + .toArray(); + const wordCount = chapters.reduce((sum, c) => sum + (c.word_count || 0), 0); + + await db.collection('stories').updateOne( + { _id: storyId }, + { $set: { word_count: wordCount, updated_at: new Date() } } + ); + return wordCount; +} + +module.exports = { recomputeStoryWordCount }; diff --git a/src/lib/tiptapExtensions.js b/src/lib/tiptapExtensions.js new file mode 100644 index 0000000..5e585eb --- /dev/null +++ b/src/lib/tiptapExtensions.js @@ -0,0 +1,11 @@ +// tiptapExtensions.js — shared extension set for server-side rendering +// (renderTiptap.js) and, later, the admin editor bundle (Phase 3). One list, +// one source of truth, per design-018 §4: StarterKit + image-by-URL. Link is +// bundled inside StarterKit v3 by default — do not add @tiptap/extension-link +// separately, it registers a duplicate 'link' extension name. +'use strict'; + +const { StarterKit } = require('@tiptap/starter-kit'); +const { Image } = require('@tiptap/extension-image'); + +module.exports = [StarterKit, Image]; diff --git a/src/lib/wordCount.js b/src/lib/wordCount.js new file mode 100644 index 0000000..faa99ab --- /dev/null +++ b/src/lib/wordCount.js @@ -0,0 +1,26 @@ +// wordCount.js — word count from TipTap JSON, computed on every chapter +// save (design-018 §2.3). Walks the document tree collecting text node +// content, joining across node boundaries with whitespace so words never +// merge across a paragraph/heading/list-item break. +'use strict'; + +function collectText(node, parts) { + if (!node || typeof node !== 'object') return; + if (typeof node.text === 'string') { + parts.push(node.text); + return; + } + if (Array.isArray(node.content)) { + for (const child of node.content) collectText(child, parts); + } +} + +function countWords(bodyJson) { + if (!bodyJson || typeof bodyJson !== 'object') return 0; + const parts = []; + collectText(bodyJson, parts); + const words = parts.join(' ').trim().split(/\s+/).filter(Boolean); + return words.length; +} + +module.exports = { countWords }; diff --git a/src/public/admin-js/chapter-editor.js b/src/public/admin-js/chapter-editor.js new file mode 100644 index 0000000..b8623c0 --- /dev/null +++ b/src/public/admin-js/chapter-editor.js @@ -0,0 +1,138 @@ +(function () { + var storyId = document.body.dataset.storyId; + var chapterId = document.body.dataset.chapterId || null; + + async function api(method, url, body) { + const res = await fetch(url, { + method, + headers: body ? { 'Content-Type': 'application/json' } : undefined, + body: body ? JSON.stringify(body) : undefined, + }); + const data = await res.json().catch(() => ({})); + if (!res.ok) throw new Error(data.error || res.statusText); + return data; + } + + function wordCount(editor) { + return editor.getText().trim().split(/\s+/).filter(Boolean).length; + } + + function updateToolbarState(editor) { + document.querySelectorAll('.toolbar button[data-cmd]').forEach(function (btn) { + var cmd = btn.dataset.cmd; + var active = false; + if (cmd === 'bold') active = editor.isActive('bold'); + else if (cmd === 'italic') active = editor.isActive('italic'); + else if (cmd === 'strike') active = editor.isActive('strike'); + else if (cmd === 'heading1') active = editor.isActive('heading', { level: 1 }); + else if (cmd === 'heading2') active = editor.isActive('heading', { level: 2 }); + else if (cmd === 'bulletList') active = editor.isActive('bulletList'); + else if (cmd === 'orderedList') active = editor.isActive('orderedList'); + else if (cmd === 'blockquote') active = editor.isActive('blockquote'); + btn.classList.toggle('is-active', active); + }); + document.getElementById('word-count').textContent = wordCount(editor) + ' words'; + } + + let publishState = null; + + async function init() { + let content = { type: 'doc', content: [{ type: 'paragraph' }] }; + + if (chapterId) { + const chapter = await api('GET', '/api/admin/stories/' + storyId + '/chapters/' + chapterId); + document.getElementById('slug').value = chapter.slug; + document.getElementById('title').value = chapter.title; + document.getElementById('display_order').value = chapter.display_order; + document.getElementById('note_top').value = chapter.note_top || ''; + document.getElementById('note_bottom').value = chapter.note_bottom || ''; + content = chapter.body_json; + publishState = chapter.status; + + const publishBtn = document.getElementById('publish-btn'); + publishBtn.textContent = publishState === 'published' ? 'Unpublish' : 'Publish'; + publishBtn.addEventListener('click', async function () { + const nextStatus = publishState === 'published' ? 'draft' : 'published'; + try { + await api('PATCH', '/api/admin/stories/' + storyId + '/chapters/' + chapterId + '/status', { status: nextStatus }); + window.location.reload(); + } catch (err) { + alert('Failed: ' + err.message); + } + }); + } + + const editor = window.StompingEditor.createEditor({ + element: document.getElementById('editor'), + content, + onUpdate: updateToolbarState, + onSelectionUpdate: updateToolbarState, + }); + updateToolbarState(editor); + + document.querySelectorAll('.toolbar button[data-cmd]').forEach(function (btn) { + btn.addEventListener('click', function () { + const chain = editor.chain().focus(); + switch (btn.dataset.cmd) { + case 'bold': chain.toggleBold().run(); break; + case 'italic': chain.toggleItalic().run(); break; + case 'strike': chain.toggleStrike().run(); break; + case 'heading1': chain.toggleHeading({ level: 1 }).run(); break; + case 'heading2': chain.toggleHeading({ level: 2 }).run(); break; + case 'bulletList': chain.toggleBulletList().run(); break; + case 'orderedList': chain.toggleOrderedList().run(); break; + case 'blockquote': chain.toggleBlockquote().run(); break; + case 'horizontalRule': chain.setHorizontalRule().run(); break; + case 'undo': chain.undo().run(); break; + case 'redo': chain.redo().run(); break; + case 'link': { + const url = window.prompt('Link URL (blank to remove):'); + if (url === null) break; + if (url.trim() === '') chain.unsetLink().run(); + else chain.extendMarkRange('link').setLink({ href: url.trim() }).run(); + break; + } + case 'image': { + const src = window.prompt('Image URL:'); + if (src && src.trim()) chain.setImage({ src: src.trim() }).run(); + break; + } + } + }); + }); + + document.getElementById('save-btn').addEventListener('click', async function () { + const statusEl = document.getElementById('save-status'); + statusEl.textContent = ''; + statusEl.className = 'status-msg'; + + const body = { + slug: document.getElementById('slug').value.trim(), + title: document.getElementById('title').value.trim(), + display_order: Number(document.getElementById('display_order').value), + note_top: document.getElementById('note_top').value, + note_bottom: document.getElementById('note_bottom').value, + body_json: editor.getJSON(), + }; + + try { + if (chapterId) { + await api('PUT', '/api/admin/stories/' + storyId + '/chapters/' + chapterId, body); + statusEl.textContent = 'Saved.'; + statusEl.className = 'status-msg ok'; + } else { + const created = await api('POST', '/api/admin/stories/' + storyId + '/chapters', body); + window.location.href = '/admin/stories/' + storyId + '/chapters/' + created._id; + } + } catch (err) { + statusEl.textContent = err.message; + statusEl.className = 'status-msg error'; + } + }); + } + + init().catch(function (err) { + document.getElementById('save-status').textContent = 'Failed to load: ' + err.message; + document.getElementById('save-status').className = 'status-msg error'; + }); +})(); diff --git a/src/public/admin-js/editor-bundle.js b/src/public/admin-js/editor-bundle.js new file mode 100644 index 0000000..e4e8f07 --- /dev/null +++ b/src/public/admin-js/editor-bundle.js @@ -0,0 +1,151 @@ +(()=>{function se(n){this.content=n}se.prototype={constructor:se,find:function(n){for(var e=0;e>1}};se.from=function(n){if(n instanceof se)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new se(e)};var Gi=se;function $l(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){let o=i.text,l=s.text,a=0;for(;o[a]==l[a];a++)t++;return a&&a0&&f>0&&c[d-1]==u[f-1];)d--,f--,t--,r--;return d&&f&&d=56320&&n<57344}function Wl(n){return n>=55296&&n<56320}var k=class n{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;re&&r(a,i+l,s||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);se)for(let s=0,o=0;oe&&((ot)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new n(r,i)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new n(i,s)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),s=r+i.nodeSize;if(s>=e)return s==e?rr(t+1,s):rr(t,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return n.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,r=0;for(let i=0;ithis.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;tr.type.rank-i.type.rank),t}};F.none=[];var nt=class extends Error{},S=class n{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=jl(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(e,t){return new n(Jl(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return n.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(k.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new n(e,r,i)}};S.empty=new S(k.empty,0,0);function Jl(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(Jl(s.content,e-i-1,t-i-1)))}function jl(n,e,t,r,i,s){let{index:o,offset:l}=n.findIndex(e),a=n.maybeChild(o);if(l==e||a.isText)return s&&r<=0&&i<=0&&!s.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=jl(a.content,e-l-1,t,o==0?r-1:0,o==n.childCount-1?i-1:0,a);return c&&n.replaceChild(o,a.copy(c))}function If(n,e,t){if(t.openStart>n.depth)throw new nt("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new nt("Inconsistent open depths");return Kl(n,e,t,0)}function Kl(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function an(n,e,t,r){let i=(e||n).node(t),s=0,o=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(ft(n.nodeAfter,r),s++));for(let l=s;li&&Yi(n,e,i+1),o=r.depth>i&&Yi(t,r,i+1),l=[];return an(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(Ul(s,o),ft(ht(s,ql(n,e,t,r,i+1)),l)):(s&&ft(ht(s,lr(n,e,i+1)),l),an(e,t,i,l),o&&ft(ht(o,lr(t,r,i+1)),l)),an(r,null,i,l),new k(l)}function lr(n,e,t){let r=[];if(an(null,n,t,r),n.depth>t){let i=Yi(n,e,t+1);ft(ht(i,lr(n,e,t+1)),r)}return an(e,null,t,r),new k(r)}function Df(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(k.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}var ar=class n{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new pt(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(r.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new n(t,r,s)}static resolveCached(e,t){let r=Rl.get(e);if(r)for(let s=0;se&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Gl(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=k.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;at.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=k.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};ye.prototype.text=void 0;var Zi=class n extends ye{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Gl(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new n(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Gl(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}var mt=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new es(e,t);if(r.next==null)return n.empty;let i=Xl(r);r.next&&r.err("Unexpected trailing text");let s=_f(Vf(i));return Wf(s,r),s}matchType(e){for(let t=0;tc.createAndFill()));for(let c=0;c=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(r.next[o].next);return s}).join(` +`)}};mt.empty=new mt(!0);var es=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function Xl(n){let e=[];do e.push(zf(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function zf(n){let e=[];do e.push(Bf(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Bf(n){let e=$f(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Ff(n,e);else break;return e}function Il(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Ff(n,e){let t=Il(n),r=t;return n.eat(",")&&(n.next!="}"?r=Il(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Hf(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let o=t[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function $f(n){if(n.eat("(")){let e=Xl(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Hf(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Vf(n){let e=[[]];return i(s(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=s(o.exprs[a],l);if(a==o.exprs.length-1)return c;i(c,l=t())}else if(o.type=="star"){let a=t();return r(l,a),i(s(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();return i(s(o.expr,l),a),i(s(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c{n[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new mt(r.indexOf(n.length-1)>-1);for(let o=0;o-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Zl(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ye(this,this.computeAttrs(e),k.from(t),F.setFrom(r))}createChecked(e=null,t,r){return t=k.from(t),this.checkContent(t),new ye(this,this.computeAttrs(e),t,F.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=k.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(k.empty,!0);return s?new ye(this,e,t.append(s),F.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[s]=new n(s,t,o));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Jf(n,e,t){let r=t.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}var ts=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Jf(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},un=class n{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=ta(e,i.attrs),this.excluded=null;let s=Ql(this.attrs);this.instance=s?new F(this,s):null}create(e=null){return!e&&this.instance?this.instance:new F(this,Zl(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new n(s,i++,t,o)),r}removeFromSet(e){for(var t=0;t-1}},Ht=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=Gi.from(e.nodes),t.marks=Gi.from(e.marks||{}),this.nodes=cr.compile(this.spec.nodes,this),this.marks=un.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=mt.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?Pl(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:Pl(this,o.split(" "))}this.nodeFromJSON=i=>ye.fromJSON(this,i),this.markFromJSON=i=>F.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof cr){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new Zi(r,r.defaultAttrs,e,F.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};function Pl(n,e){let t=[];for(let r=0;r-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function jf(n){return n.tag!=null}function Kf(n){return n.style!=null}var Ie=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(jf(i))this.tags.push(i);else if(Kf(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new ur(this,t,!1);return r.addAll(e,F.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new ur(this,t,!0);return r.addAll(e,F.none,t.from,t.to),S.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o{r(o=zl(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=zl(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},na={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Uf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ra={ol:!0,ul:!0},dn=1,ns=2,cn=4;function Ll(n,e,t){return e!=null?(e?dn:0)|(e==="full"?ns:0):n&&n.whitespace=="pre"?dn|ns:t&~cn}var Ft=class{constructor(e,t,r,i,s,o){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=F.none,this.match=s||(o&cn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(k.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&dn)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=k.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(k.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!na.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},ur=class{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=Ll(null,t.preserveWhitespace,0)|(r?cn:0);i?s=new Ft(i.type,i.attrs,F.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new Ft(null,null,F.none,!0,null,o):s=new Ft(e.schema.topNodeType,null,F.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top,s=i.options&ns?"full":this.localPreserveWS||(i.options&dn)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,` +`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,i){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,t.attrs||null,r,t.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,r){let i,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,s=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o(o.type?o.type.allowsMarkType(c.type):Bl(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Ft(e,t,a,i,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=dn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}};function qf(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&ra.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Gf(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function zl(n){let e={};for(let t in n)e[t]=n[t];return e}function Bl(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let s=[],o=l=>{s.push(l);for(let a=0;a{if(s.length||o.marks.length){let l=0,a=0;for(;l=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&sr(ir(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:sr(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Fl(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Fl(e.marks)}};function Fl(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function ir(n){return n.document||window.document}var Hl=new WeakMap;function Xf(n){let e=Hl.get(n);return e===void 0&&Hl.set(n,e=Yf(n)),e}function Yf(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let l,a=t?n.createElementNS(t,i):n.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;du)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof f=="string")a.appendChild(n.createTextNode(f));else{let{dom:h,contentDOM:p}=sr(n,f,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}var oa=65535,la=Math.pow(2,16);function Qf(n,e){return n+e*la}function ia(n){return n&oa}function Zf(n){return(n-(n&oa))/la}var aa=1,ca=2,dr=4,ua=8,pn=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&ua)>0}get deletedBefore(){return(this.delInfo&(aa|dr))>0}get deletedAfter(){return(this.delInfo&(ca|dr))>0}get deletedAcross(){return(this.delInfo&dr)>0}},We=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,r=ia(e);if(!this.inverted)for(let i=0;ie)break;let c=this.ranges[l+s],u=this.ranges[l+o],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,h=a+i+(f<0?0:u);if(r)return h;let p=e==(t<0?a:d)?null:Qf(l/3,e-a),m=e==a?ca:e==d?aa:dr;return(t<0?e!=a:e!=d)&&(m|=ua),new pn(h,m,p)}i+=u-c}return r?e+i:new pn(e+i,0,null)}touches(e,t){let r=0,i=ia(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;le)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new n;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;rs&&a!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return ee.fromReplace(e,this.from,this.to,s)}invert(){return new Je(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};Y.jsonID("addMark",gn);var Je=class n extends Y{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new S(cs(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return ee.fromReplace(e,this.from,this.to,r)}invert(){return new gn(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};Y.jsonID("removeMark",Je);var yn=class n extends Y{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ee.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ee.fromReplace(e,this.pos,this.pos+1,new S(k.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new n(t.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new n(t.from,t.to,t.gapFrom,t.gapTo,S.fromJSON(e,t.slice),t.insert,!!t.structure)}};Y.jsonID("replaceAround",U);function ls(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function eh(n,e,t,r){let i=[],s=[],o,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(d);for(let m=0;mn.step(a)),s.forEach(a=>n.step(a))}function th(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(r instanceof un){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let u=0;un.step(new Je(o.from,o.to,o.style)))}function us(n,e,t,r=t.contentMatch,i=!0){let s=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a=0;a--)n.step(o[a])}function nh(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function je(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,s=0;;--r){let o=n.$from.node(r),l=n.$from.index(r)+i,a=n.$to.indexAfter(r)-s;if(rt;p--)m||r.index(p)>0?(m=!0,u=k.from(r.node(p).copy(u)),d++):a--;let f=k.empty,h=0;for(let p=s,m=!1;p>t;p--)m||i.after(p+1)=0;o--){if(r.size){let l=t[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=k.from(t[o].type.create(t[o].attrs,r))}let i=e.start,s=e.end;n.step(new U(i,s,i,s,new S(r,0,0),t.length,!0))}function lh(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,a)&&ah(n.doc,n.mapping.slice(s).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&fa(n,o,l,s),us(n,n.mapping.slice(s).map(l,1),r,void 0,c===null);let u=n.mapping.slice(s),d=u.map(l,1),f=u.map(l+o.nodeSize,1);return n.step(new U(d,f,d+1,f-1,new S(k.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&da(n,o,l,s),!1}})}function da(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+s+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function fa(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(` +`))}})}function ah(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function ch(n,e,t,r,i){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new U(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new S(k.from(o),0,0),1,!0))}function be(n,e,t=1,r){let i=n.resolve(e),s=i.depth-t,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=t-2;c>s;c--,u--){let d=i.node(c),f=i.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!m.type.validContent(h))return!1}let l=i.indexAfter(s),a=r&&r[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function uh(n,e,t=1,r){let i=n.doc.resolve(e),s=k.empty,o=k.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){s=k.from(i.node(l).copy(s));let u=r&&r[c];o=k.from(u?u.type.create(u.attrs,o):i.node(l).copy(o))}n.step(new te(e,e,new S(s.append(o),t,t),!0))}function we(n,e){let t=n.resolve(e),r=t.index();return ha(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function dh(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i0?(s=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(s=r.node(i).maybeChild(l-1),o=r.node(i+1)),s&&!s.isTextblock&&ha(s,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function fh(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,s=n.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let u=o.whitespace=="pre",d=!!o.contentMatch.matchType(i);u&&!d?r=!1:!u&&d&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);fa(n,u.node(),u.before(),l)}o.inlineContent&&us(n,e+t-1,o,s.node().contentMatchAt(s.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new te(c,a.map(e+t,-1),S.empty,!0)),r===!0){let u=n.doc.resolve(c);da(n,u.node(),u.before(),n.steps.length)}return n}function hh(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,t))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,t))return r.after(i+1);if(s=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),u=!1;if(s==1)u=c.canReplace(a,a,i);else{let d=c.contentMatchAt(a).findWrapping(i.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function kn(n,e,t=e,r=S.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return pa(i,s,r)?new te(e,t,r):new as(i,s,r).fit()}function pa(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var as=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=k.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=k.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new S(s,o,l);return e>-1?new U(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new te(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=is(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(t==1&&(o?c.matchType(o.type)||(d=c.fillBefore(k.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:d};if(t==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=is(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new S(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=is(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new S(fn(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new S(fn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m1||a==0||m.content.size)&&(d=g,u.push(ma(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=hn(this.placed,t,k.from(u)),this.frontier[t].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],s=t=0;l--){let{match:a,type:c}=this.frontier[l],u=ss(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=hn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=hn(this.placed,this.depth,k.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(k.empty,!0);t.childCount&&(this.placed=hn(this.placed,this.frontier.length,t))}};function fn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(fn(n.firstChild.content,e-1,t)))}function hn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(hn(n.lastChild.content,e-1,t)))}function is(n,e){for(let t=0;t1&&(r=r.replaceChild(0,ma(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(k.empty,!0)))),n.copy(r)}function ss(n,e,t,r,i){let s=n.node(e),o=i?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!ph(t,s.content,o)?l:null}function ph(n,e,t){for(let r=t;r0;f--,h--){let p=i.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?l=f:i.before(f)==h&&o.splice(1,0,-f)}let a=o.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=mh(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m=0&&(n.replace(e,t,r),!(n.steps.length>d));f--){let h=o[f];h<0||(e=i.before(h),t=s.after(h))}}function ga(n,e,t,r,i){if(er){let s=i.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(k.empty,!0))}return n}function yh(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=hh(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new S(k.from(r),0,0))}function kh(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let o=r.sharedDepth(t),l=!1;for(let a=r.depth;a>o;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>o;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=i.depth;a>0&&t==i.start(a);a--)t=i.before(a);r=n.doc.resolve(e),i=n.doc.resolve(t)}}let s=ya(r,i);for(let o=0;o0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&i.end(o)-t!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return n.delete(r.before(o),t);n.delete(e,t)}function ya(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(se.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}var fr=class n extends Y{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return ee.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return ee.fromReplace(e,this.pos,this.pos+1,new S(k.from(i),0,t.isLeaf?0:1))}getMap(){return We.empty}invert(e){return new n(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new n(t.pos,t.attr,t.value)}};Y.jsonID("attr",fr);var hr=class n extends Y{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return ee.ok(r)}getMap(){return We.empty}invert(e){return new n(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new n(t.attr,t.value)}};Y.jsonID("docAttr",hr);var Vt=class extends Error{};Vt=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Vt.prototype=Object.create(Error.prototype);Vt.prototype.constructor=Vt;Vt.prototype.name="TransformError";var _t=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new mn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Vt(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let r=0;r{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=S.empty){let i=kn(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new S(k.from(r),0,0))}delete(e,t){return this.replace(e,t,S.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return gh(this,e,t,r),this}replaceRangeWith(e,t,r){return yh(this,e,t,r),this}deleteRange(e,t){return kh(this,e,t),this}lift(e,t){return rh(this,e,t),this}join(e,t=1){return fh(this,e,t),this}wrap(e,t){return oh(this,e,t),this}setBlockType(e,t=e,r,i=null){return lh(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return ch(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new fr(e,t,r)),this}setDocAttribute(e,t){return this.step(new hr(e,t)),this}addNodeMark(e,t){return this.step(new yn(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof F)t.isInSet(r.marks)&&this.step(new $t(e,t));else{let i=r.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new $t(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,r){return uh(this,e,t,r),this}addMark(e,t,r){return eh(this,e,t,r),this}removeMark(e,t,r){return th(this,e,t,r),this}clearIncompatible(e,t,r){return us(this,e,t,r),this}};var ds=Object.create(null),O=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new gr(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t=0;s--){let o=t<0?Jt(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):Jt(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new fe(e.node(0))}static atStart(e){return Jt(e,e,0,0,1)||new fe(e)}static atEnd(e){return Jt(e,e,e.content.size,e.childCount,-1)||new fe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=ds[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in ds)throw new RangeError("Duplicate use of selection JSON ID "+e);return ds[e]=t,t.prototype.jsonID=e,t}getBookmark(){return C.between(this.$anchor,this.$head).getBookmark()}};O.prototype.visible=!0;var gr=class{constructor(e,t){this.$from=e,this.$to=t}},ka=!1;function xa(n){!ka&&!n.parent.inlineContent&&(ka=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var C=class n extends O{constructor(e,t=e){xa(e),xa(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return O.near(r);let i=e.resolve(t.map(this.anchor));return new n(i.parent.inlineContent?i:r,r)}replace(e,t=S.empty){if(super.replace(e,t),t==S.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new yr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=O.findFrom(t,r,!0)||O.findFrom(t,-r,!0);if(s)t=s.$head;else return O.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(O.findFrom(e,-r,!0)||O.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?o=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&M.isSelectable(l))return M.create(n,t-(i<0?l.nodeSize:0))}else{let a=Jt(n,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function ba(n,e,t){let r=n.steps.length-1;if(r{o==null&&(o=u)}),n.setSelection(O.near(n.doc.resolve(o),t))}var Sa=1,mr=2,wa=4,ps=class extends _t{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=mr,this}ensureMarks(e){return F.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&mr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~mr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||F.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,s)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(O.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=wa,this}get scrolledIntoView(){return(this.updated&wa)>0}};function va(n,e){return!e||!n?n:n.bind(e)}var yt=class{constructor(e,t,r){this.name=e,this.init=va(t.init,r),this.apply=va(t.apply,r)}},bh=[new yt("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new yt("selection",{init(n,e){return n.selection||O.atStart(e.doc)},apply(n){return n.selection}}),new yt("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new yt("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],xn=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=bh.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new yt(r.key,r.spec.state,r))})}},kr=class n{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new xn(e.schema,e.plugins),s=new n(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=ye.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=O.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=c.fromJSON.call(a,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}};function Ma(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Ma(i,e,{})),t[r]=i}return t}var N=class{constructor(e){this.spec=e,this.props={},e.props&&Ma(e.props,this,this.props),this.key=e.key?e.key.key:Ca("plugin")}getState(e){return e[this.key]}},fs=Object.create(null);function Ca(n){return n in fs?n+"$"+ ++fs[n]:(fs[n]=0,n+"$")}var I=class{constructor(e="key"){this.key=Ca(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var Ea=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Aa(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var gs=(n,e,t)=>{let r=Aa(n,t);if(!r)return!1;let i=ks(r);if(!i){let o=r.blockRange(),l=o&&je(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(Ba(n,i,e,-1))return!0;if(r.parent.content.size==0&&(jt(s,"end")||M.isSelectable(s)))for(let o=r.depth;;o--){let l=kn(n.doc,r.before(o),r.after(o),S.empty);if(l&&l.slice.size1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},Na=(n,e,t)=>{let r=Aa(n,t);if(!r)return!1;let i=ks(r);return i?Ra(n,i,e):!1},Oa=(n,e,t)=>{let r=Ia(n,t);if(!r)return!1;let i=Ss(r);return i?Ra(n,i,e):!1};function Ra(n,e,t){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=kn(n.doc,s,a,S.empty);if(!c||c.from!=s||c instanceof te&&c.slice.size>=a-s)return!1;if(t){let u=n.tr.step(c);u.setSelection(C.create(u.doc,s)),t(u.scrollIntoView())}return!0}function jt(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}var ys=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=ks(r)}let o=s&&s.nodeBefore;return!o||!M.isSelectable(o)?!1:(e&&e(n.tr.setSelection(M.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function ks(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Ia(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset{let r=Ia(n,t);if(!r)return!1;let i=Ss(r);if(!i)return!1;let s=i.nodeAfter;if(Ba(n,i,e,1))return!0;if(r.parent.content.size==0&&(jt(s,"start")||M.isSelectable(s))){let o=kn(n.doc,r.before(),r.after(),S.empty);if(o&&o.slice.size{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset=0;e--){let t=n.node(e);if(n.index(e)+1{let t=n.selection,r=t instanceof M,i;if(r){if(t.node.isTextblock||!we(n.doc,t.from))return!1;i=t.from}else if(i=gt(n.doc,t.from,-1),i==null)return!1;if(e){let s=n.tr.join(i);r&&s.setSelection(M.create(s.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Pa=(n,e)=>{let t=n.selection,r;if(t instanceof M){if(t.node.isTextblock||!we(n.doc,t.to))return!1;r=t.to}else if(r=gt(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},La=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),s=i&&je(i);return s==null?!1:(e&&e(n.tr.lift(i,s).scrollIntoView()),!0)},ws=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(` +`).scrollIntoView()),!0)};function vs(n){for(let e=0;e{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=vs(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(O.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Cs=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof fe||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=vs(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index(){let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(be(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&je(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Sh(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof M&&e.selection.node.isBlock)return!r.parentOffset||!be(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],o,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=vs(r.node(h-1).contentMatchAt(r.indexAfter(h-1)));let m=n&&n(i.parent,a,r);s.unshift(m||(a&&l?{type:l}:null)),o=h;break}else{if(h==1)return!1;s.unshift(null)}let u=e.tr;(e.selection instanceof C||e.selection instanceof fe)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=be(u.doc,d,s.length,s);if(f||(s[0]=l?{type:l}:null,f=be(u.doc,d,s.length,s)),!f)return!1;if(u.split(d,s.length,s),!a&&c&&r.node(o).type!=l){let h=u.mapping.map(r.before(o)),p=u.doc.resolve(h);l&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(o)),l)}return t&&t(u.scrollIntoView()),!0}}var wh=Sh();var za=(n,e)=>{let{$from:t,to:r}=n.selection,i,s=t.sharedDepth(r);return s==0?!1:(i=t.before(s),e&&e(n.tr.setSelection(M.create(n.doc,i))),!0)},vh=(n,e)=>(e&&e(n.tr.setSelection(new fe(n.doc))),!0);function Mh(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||we(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Ba(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Mh(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let h=e.pos+s.nodeSize,p=k.empty;for(let y=o.length-1;y>=0;y--)p=k.from(o[y].create(null,p));p=k.from(i.copy(p));let m=n.tr.step(new U(e.pos-1,h,e.pos,h,new S(p,1,0),o.length,!0)),g=m.doc.resolve(h+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&we(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&a?null:O.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&je(d);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(d,f).scrollIntoView()),!0;if(c&&jt(s,"start",!0)&&jt(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let y=k.empty;for(let v=p.length-1;v>=0;v--)y=k.from(p[v].copy(y));let b=n.tr.step(new U(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new S(y,p.length,0),0,!0));t(b.scrollIntoView())}return!0}}return!1}function Fa(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(C.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}var Es=Fa(-1),As=Fa(1);function Ha(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&Wt(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Ns(n,e=null){return function(t,r){let i=!1;for(let s=0;s{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let u=t.doc.resolve(c),d=u.index();i=u.parent.canReplaceWith(d,d+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let o=0;o=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);s=new pt(a,a,e.depth),e.endIndex=0;u--)s=k.from(t[u].type.create(t[u].attrs,s));n.step(new U(e.start-(r?2:0),e.end,e.start,e.end,new S(s,0,0),t.length,!0));let o=0;for(let u=0;uo.childCount>0&&o.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?Ah(e,t,n,s):Nh(e,t,s):!0:!1}}function Ah(n,e,t,r){let i=n.tr,s=r.end,o=r.$to.end(r.depth);sm;p--)h-=i.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(t.start),o=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,o.content.append(a?k.empty:k.from(i))))return!1;let d=s.pos,f=d+o.nodeSize;return r.step(new U(d-(l?1:0),f+(a?1:0),d+1,f-1,new S((l?k.empty:k.from(i.copy(k.empty))).append(a?k.empty:k.from(i.copy(k.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function _a(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=k.from(c?n.create():null),d=new S(k.from(n.create(null,k.from(l.type.create(null,u)))),c?3:1,0),f=s.start,h=s.end;t(e.tr.step(new U(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}var ne=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Gt=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},zs=null,Ue=function(n,e,t){let r=zs||(zs=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Oh=function(){zs=null},Ct=function(n,e,t,r){return t&&(Wa(n,e,t,r,-1)||Wa(n,e,t,r,1))},Rh=/^(img|br|input|textarea|hr)$/i;function Wa(n,e,t,r,i){for(var s;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Me(n))){let o=n.parentNode;if(!o||o.nodeType!=1||En(n)||Rh.test(n.nodeName)||n.contentEditable=="false")return!1;e=ne(n)+(i<0?0:1),n=o}else if(n.nodeType==1){let o=n.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else n=o,e=i<0?Me(n):0}else return!1}}function Me(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Ih(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Me(n)}else if(n.parentNode&&!En(n))e=ne(n),n=n.parentNode;else return null}}function Dh(n,e){for(;;){if(n.nodeType==3&&e2),ve=Xt||(De?/Mac/.test(De.platform):!1),wc=De?/Win/.test(De.platform):!1,qe=/Android \d/.test(at),An=!!Ja&&"webkitFontSmoothing"in Ja.documentElement.style,Bh=An?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Fh(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Ke(n,e){return typeof n=="number"?n:n[e]}function Hh(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function ja(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let o=t||n.dom;o;){if(o.nodeType!=1){o=Gt(o);continue}let l=o,a=l==s.body,c=a?Fh(s):Hh(l),u=0,d=0;if(e.topc.bottom-Ke(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+Ke(i,"top")-c.top:e.bottom-c.bottom+Ke(i,"bottom")),e.leftc.right-Ke(r,"right")&&(u=e.right-c.right+Ke(i,"right")),u||d)if(a)s.defaultView.scrollBy(u,d);else{let h=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let m=l.scrollLeft-h,g=l.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let f=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(f))break;o=f=="absolute"?o.offsetParent:Gt(o)}}function $h(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=t+1;o=t-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:vc(n.dom)}}function vc(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Gt(r));return e}function Vh({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Mc(t,r==0?0:r-e)}function Mc(n,e){for(let t=0;t=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=d+1)}}return!t&&a&&(t=a,i=c,r=0),t&&t.nodeType==3?Wh(t,i):!t||r&&t.nodeType==1?{node:n,offset:s}:Cc(t,i)}function Wh(n,e){let t=n.nodeValue.length,r=document.createRange(),i;for(let s=0;s=(o.left+o.right)/2?1:0)};break}}return r.detach(),i||{node:n,offset:0}}function to(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Jh(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,i,s)}function Kh(n,e,t,r){let i=-1;for(let s=e,o=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&a.left>r.left||a.top>r.top?i=l.posBefore:(!o&&a.right-1?i:n.docView.posFromDOM(e,t,-1)}function Tc(n,e,t){let r=n.childNodes.length;if(r&&t.tope.top&&i++}let c;An&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=Kh(n,r,i,e))}l==null&&(l=jh(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ka(n){return n.top=0&&i==r.nodeValue.length?(a--,u=1):t<0?a--:c++,bn(it(Ue(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==Me(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return Rs(a.getBoundingClientRect(),!1)}if(s==null&&i=0)}if(s==null&&i&&(t<0||i==Me(r))){let a=r.childNodes[i-1],c=a.nodeType==3?Ue(a,Me(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return bn(it(c,1),!1)}if(s==null&&i=0)}function bn(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Rs(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Ac(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function Gh(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Ac(n,e,()=>{let{node:s}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=Ec(n,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Ue(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;cu.top+1&&(t=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}var Xh=/[\u0590-\u08ac]/;function Yh(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,l=n.domSelection();return l?!Xh.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:Ac(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}var Ua=null,qa=null,Ga=!1;function Qh(n,e,t){return Ua==e&&qa==t?Ga:(Ua=e,qa=t,Ga=t=="up"||t=="down"?Gh(n,e,t):Yh(n,e,t))}var Te=0,Xa=1,xt=2,Oe=3,Tt=class{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Te,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tne(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!t||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;te||o instanceof Sr){i=e-s;break}s=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof xr&&s.side>=0;r--);if(t<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?ne(s.dom)+1:0}}else{let s,o=!0;for(;s=r=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=o;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=ne(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;up&&ot){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i=r:er){let l=r+s.border,a=o-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==o?xt:Xa,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Oe:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?xt:Oe}r=o}this.dirty=xt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?xt:Xa;t.dirty{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Te&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},$s=class extends Tt{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},St=class n extends Tt{constructor(e,t,r,i,s){super(e,[],r,i),this.mark=t,this.spec=s}static create(e,t,r,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,r);return(!o||!o.dom)&&(o=_e.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new n(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Oe||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Oe&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Te){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(s=Js(s,0,e,r));for(let l=0;l{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,i),u=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=_e.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Rc(u,r,t),c?a=new Vs(e,t,r,i,u,d||null,f,c):t.isText?new br(e,t,r,i,u,f):new n(e,t,r,i,u,d||null,f)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>k.empty)}return e}matchesNode(e,t,r){return this.dirty==Te&&e.eq(this.node)&&wr(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new Ws(this,o&&o.node,e);np(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e,u):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?F.none:this.node.child(u).marks,r,e,u),a.placeWidget(c,e,i)},(c,u,d,f)=>{a.syncToMarks(c.marks,r,e,f);let h;a.findNodeMatch(c,u,d,f)||l&&e.state.selection.from>i&&e.state.selection.to-1&&a.updateNodeAt(c,u,d,h,e)||a.updateNextNode(c,u,d,e,f,i)||a.addNode(c,u,d,e,i),i+=c.nodeSize}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==xt)&&(o&&this.protectLocalComposition(e,o),Nc(this.contentDOM,this.children,e),Xt&&rp(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof C)||rt+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=ip(this.node.content,o,r-t,i-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new $s(this,s,t,i);e.input.compositionNodes.push(o),this.children=Js(this.children,r,r+i.length,e,o)}update(e,t,r,i){return this.dirty==Oe||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Te}updateOuterDeco(e){if(wr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Oc(this.dom,this.nodeDOM,_s(this.outerDeco,this.node,t),_s(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function Ya(n,e,t,r,i){Rc(r,e,n);let s=new lt(void 0,n,e,t,r,r,r);return s.contentDOM&&s.updateChildren(i,0),s}var br=class n extends lt{constructor(e,t,r,i,s,o){super(e,t,r,i,s,null,o)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==Oe||this.dirty!=Te&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Te||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Te,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new n(this.parent,i,this.outerDeco,this.innerDeco,s,s)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Oe)}get domAtom(){return!1}isText(e){return this.node.text==e}},Sr=class extends Tt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Te&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Vs=class extends lt{constructor(e,t,r,i,s,o,l,a){super(e,t,r,i,s,o,l),this.spec=a}update(e,t,r,i){if(this.dirty==Oe)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Nc(n,e,t){let r=n.firstChild,i=!1;for(let s=0;s>1,l=Math.min(o,e.length);for(;s-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=St.create(this.top,e[o],t,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,r))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof St)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function tp(n,e){return n.type.side-e.type.side}function np(n,e,t,r){let i=e.locals(n),s=0;if(i.length==0){for(let c=0;cs;)l.push(i[o++]);let p=s+f.nodeSize;if(f.isText){let g=p;o!g.inline):l.slice();r(f,m,e.forChild(s,f),h),s=p}}function rp(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function ip(n,e,t,r){for(let i=0,s=0;i=t){if(s>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Js(n,e,t,r,i){let s=[];for(let o=0,l=0;o=t||u<=e?s.push(a):(ct&&s.push(a.slice(t-c,a.size,r)))}return s}function no(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(Or(t)){for(a=o;i&&!i.node;)i=i.parent;let d=i.node;if(i&&d.isAtom&&M.isSelectable(d)&&i.parent&&!(d.isInline&&Ph(t.focusNode,t.focusOffset,i.dom))){let f=i.posBefore;c=new M(o==f?l:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=o,f=o;for(let h=0;h{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Ic(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function op(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,ne(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&ke&&ot<=11&&(t.disabled=!0,t.disabled=!1)}function Dc(n,e){if(e instanceof M){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(nc(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else nc(n)}function nc(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function ro(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||C.between(e,t,r)}function rc(n){return n.editable&&!n.hasFocus()?!1:Pc(n)}function Pc(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function lp(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Ct(e.node,e.offset,t.anchorNode,t.anchorOffset)}function js(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),s=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return s&&O.findFrom(s,e)}function st(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function ic(n,e,t){let r=n.state.selection;if(r instanceof C)if(t.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=n.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return st(n,new C(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=js(n.state,e);return i&&i instanceof M?st(n,i):!1}else if(!(ve&&t.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?M.isSelectable(s)?st(n,new M(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):An?st(n,new C(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof M&&r.node.isInline)return st(n,new C(e>0?r.$to:r.$from));{let i=js(n.state,e);return i?st(n,i):!1}}}function vr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function wn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Ut(n,e){return e<0?ap(n):cp(n)}function ap(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,s,o=!1;for(Ce&&t.nodeType==1&&r0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(wn(l,-1))i=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Lc(t))break;{let l=t.previousSibling;for(;l&&wn(l,-1);)i=t.parentNode,s=ne(l),l=l.previousSibling;if(l)t=l,r=vr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?Ks(n,t,r):i&&Ks(n,i,s)}function cp(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=vr(t),s,o;for(;;)if(r{n.state==i&&Xe(n)},50)}function sc(n,e){let t=n.state.doc.resolve(e);if(!(Q||wc)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o1)return s.lefti.top&&o1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function oc(n,e,t){let r=n.state.selection;if(r instanceof C&&!r.empty||t.indexOf("s")>-1||ve&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=js(n.state,e);if(o&&o instanceof M)return st(n,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof fe?O.near(o,e):O.findFrom(o,e);return l?st(n,l):!1}return!1}function lc(n,e){if(!(n.state.selection instanceof C))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=n.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),n.dispatch(o),!0}return!1}function ac(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function fp(n){if(!le||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;ac(n,r,"true"),setTimeout(()=>ac(n,r,"false"),20)}return!1}function hp(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function pp(n,e){let t=e.keyCode,r=hp(e);if(t==8||ve&&t==72&&r=="c")return lc(n,-1)||Ut(n,-1);if(t==46&&!e.shiftKey||ve&&t==68&&r=="c")return lc(n,1)||Ut(n,1);if(t==13||t==27)return!0;if(t==37||ve&&t==66&&r=="c"){let i=t==37?sc(n,n.state.selection.from)=="ltr"?-1:1:-1;return ic(n,i,r)||Ut(n,i)}else if(t==39||ve&&t==70&&r=="c"){let i=t==39?sc(n,n.state.selection.from)=="ltr"?1:-1:1;return ic(n,i,r)||Ut(n,i)}else{if(t==38||ve&&t==80&&r=="c")return oc(n,-1,r)||Ut(n,-1);if(t==40||ve&&t==78&&r=="c")return fp(n)||oc(n,1,r)||Ut(n,1);if(r==(ve?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function io(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=n.someProp("clipboardSerializer")||_e.fromSchema(n.state.schema),l=Vc(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=$c[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,` + +`);return{dom:a,text:f,slice:e}}function zc(n,e,t,r,i){let s=i.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=!!e&&(r||s||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,s||r,n)}),s)return l=new S(k.from(n.state.schema.text(e.replace(/\r\n?/g,` +`))),0,0),n.someProp("transformPasted",f=>{l=f(l,n,!0)}),l;let d=n.someProp("clipboardTextParser",f=>f(e,i,r,n));if(d)l=d;else{let f=i.marks(),{schema:h}=n.state,p=_e.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),o=kp(t),An&&xp(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Ie.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!mp.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=bp(cc(l,+u[1],+u[2]),u[4]);else if(l=S.maxOpen(gp(l.content,i),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d{l=d(l,n,a)}),l}var mp=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function gp(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&Fc(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Hc(o[o.length-1],s.length));let u=Bc(l,a);o.push(u),i=i.matchType(u.type),s=a}}),o)return k.from(o)}return n}function Bc(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,k.from(n));return n}function Fc(n,e,t,r,i){if(i1&&(s=0),i=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(k.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function cc(n,e,t){return et})),Ds.createHTML(n)):n}function kp(n){let e=/^(\s*]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Vc(),r=t.body,i=/<([a-z][^>\s]+)/i.exec(n),s;if((s=i&&$c[i[1].toLowerCase()])&&(n=s.map(o=>"<"+o+">").join("")+n+s.map(o=>"").reverse().join("")),r.innerHTML=yp(n),s)for(let o=0;o=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=k.from(a.create(r[l+1],i)),s++,o++}return new S(i,s,o)}var he={},pe={},Sp={touchstart:!0,touchmove:!0},qs=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function wp(n){for(let e in he){let t=he[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Mp(n,r)&&!so(n,r)&&(n.editable||!(r.type in pe))&&t(n,r)},Sp[e]?{passive:!0}:void 0)}le&&n.dom.addEventListener("input",()=>null),Gs(n)}function Ge(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function vp(n){n.input.mouseDown&&n.input.mouseDown.done(),n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Gs(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>so(n,r))})}function so(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Mp(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Cp(n,e){!so(n,e)&&he[e.type]&&(n.editable||!(e.type in pe))&&he[e.type](n,e)}pe.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Jc(n)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(qe&&Q&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Xt&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,kt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||pp(n,t)?t.preventDefault():Ge(n,"key")};pe.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};pe.keypress=(n,e)=>{let t=e;if(Jc(n)||!t.charCode||t.ctrlKey&&!t.altKey||ve&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof C)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode),s=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,i,s))&&n.dispatch(s()),t.preventDefault()}};function Nn(n){return{left:n.clientX,top:n.clientY}}function Tp(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function oo(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(n.someProp(e,l=>o>s.depth?l(n,t,s.nodeAfter,s.before(o),i,!0):l(n,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function On(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);t=="pointer"&&r.setMeta("pointer",!0),n.dispatch(r)}function Ep(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&M.isSelectable(r)?(On(n,new M(t),"pointer"),!0):!1}function Ap(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof M&&(r=t.node);let s=n.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(M.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(On(n,M.create(n.state.doc,i),"pointer"),!0):!1}function Np(n,e,t,r,i){return oo(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?Ap(n,t):Ep(n,t))}function Op(n,e,t,r){return oo(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Rp(n,e,t,r){return oo(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||Ip(n,t,r)}function Ip(n,e,t){if(t.button!=0)return!1;let r=_c(n,e,!0),i=n.state.doc;return r?(On(n,r,"pointer"),r instanceof C&&i.eq(n.state.doc)&&(n.input.mouseDown=new Ys(n,r)),!0):!1}function _c(n,e,t){let r=n.state.doc;if(e==-1)return r.inlineContent?C.create(r,0,r.content.size):null;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)return C.create(r,l+1,l+1+o.content.size);if(t&&M.isSelectable(o))return M.create(r,l)}return null}function lo(n){return Cr(n)}var Wc=ve?"metaKey":"ctrlKey";he.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=lo(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&Tp(t,n.input.lastClick)&&!t[Wc]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let o=n.posAtCoords(Nn(t));o&&(s=="singleClick"?n.input.mouseDown=new Xs(n,o,t,!!r):(s=="doubleClick"?Op:Rp)(n,o.pos,o.inside,t)?t.preventDefault():Ge(n,"pointer"))};var Mr=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},Xs=class extends Mr{constructor(e,t,r,i){super(e),this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[Wc],this.allowDefault=r.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,o=u.depth?u.before():0}let l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof M&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ce&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),Ge(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||Xe(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Nn(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ge(this.view,"pointer"):Np(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||le&&this.mightDrag&&!this.mightDrag.node.isAtom||Q&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(On(this.view,O.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Ge(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ge(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},Ys=class extends Mr{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),Ge(this.view,"pointer");let t=this.view.posAtCoords(Nn(e)),r=t&&_c(this.view,t.inside,!1);if(!r)return;let{doc:i}=this.view.state,s=this.startSelection,[o,l]=r.from{n.input.lastTouch=Date.now(),lo(n),Ge(n,"pointer")};he.touchmove=n=>{n.input.lastTouch=Date.now(),Ge(n,"pointer")};he.contextmenu=n=>lo(n);function Jc(n,e){return n.composing?!0:le&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var Dp=qe?5e3:-1;pe.compositionstart=pe.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof C&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Q&&wc&&Pp(n)))n.markCursor=n.state.storedMarks||t.marks(),Cr(n,!0),n.markCursor=null;else if(Cr(n,!e.selection.empty),Ce&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}n.input.composing=!0}jc(n,Dp)};function Pp(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}pe.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now(),n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,jc(n,20))};function jc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Cr(n),e))}function Kc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Lp(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Ih(e.focusNode,e.focusOffset),r=Dh(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return r}}return t||r}function Cr(n,e=!1){if(!(qe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Kc(n),e||n.docView&&n.docView.dirty){let t=no(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function zp(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var vn=ke&&ot<15||Xt&&Bh<604;he.copy=pe.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=vn?null:t.clipboardData,o=r.content(),{dom:l,text:a}=io(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):zp(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Bp(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Fp(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Mn(n,r.value,null,i,e):Mn(n,r.textContent,r.innerHTML,i,e)},50)}function Mn(n,e,t,r,i){let s=zc(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,s||S.empty)))return!0;if(!s)return!1;let o=Bp(s),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Uc(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}pe.paste=(n,e)=>{let t=e;if(n.composing&&!qe)return;let r=vn?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Mn(n,Uc(r),r.getData("text/html"),i,t)?t.preventDefault():Fp(n,t)};var Tr=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},Hp=ve?"altKey":"ctrlKey";function qc(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[Hp]}he.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(Nn(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof M?i.to-1:i.to))){if(r&&r.mightDrag)o=M.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(o=M.create(n.state.doc,d.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c,slice:u}=io(n,l);(!t.dataTransfer.files.length||!Q||Sc>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(vn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",vn||t.dataTransfer.setData("text/plain",c),n.dragging=new Tr(u,qc(n,t),o)};he.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};pe.dragover=pe.dragenter=(n,e)=>e.preventDefault();pe.drop=(n,e)=>{try{$p(n,e,n.dragging)}finally{n.dragging=null}};function $p(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(Nn(e));if(!r)return;let i=n.state.doc.resolve(r.pos),s=t&&t.slice;s?n.someProp("transformPasted",h=>{s=h(s,n,!1)}):s=zc(n,Uc(e.dataTransfer),vn?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(t&&qc(n,e));if(n.someProp("handleDrop",h=>h(n,e,s||S.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?pr(n.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let a=n.state.tr;if(o){let{node:h}=t;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,s.content.firstChild):a.replaceRange(c,c,s),a.doc.eq(d))return;let f=a.doc.resolve(c);if(u&&M.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new M(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,y)=>h=y),a.setSelection(ro(n,f,a.doc.resolve(h)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}he.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Xe(n)},20))};he.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};he.beforeinput=(n,e)=>{if(Q&&qe&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,kt(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in pe)he[n]=pe[n];function Cn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}var Er=class n{constructor(e,t){this.toDOM=e,this.spec=t||vt,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new ae(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Cn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},wt=class n{constructor(e,t){this.attrs=e,this.spec=t||vt}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new ae(s,o,this)}valid(e,t){return t.from=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;oe){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,i+l,s)}}map(e,t,r){return this==oe||e.maps.length==0?this:this.mapInner(e,t,0,0,r||vt)}mapInner(e,t,r,i,s){let o;for(let l=0;l{let c=a+r,u;if(u=Xc(t,l,c)){for(i||(i=this.children.slice());sl&&d.to=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;ls&&a.type instanceof wt){let c=Math.max(s,a.from)-s,u=Math.min(o,a.to)-s;ci.map(e,t,vt));return n.from(r)}forChild(e,t){if(t.isLeaf)return K.empty;let r=[];for(let i=0;it instanceof K)?e:e.reduce((t,r)=>t.concat(r instanceof K?r:r.members),[]))}}forEachSet(e){for(let t=0;t{let g=m-p-(h-f);for(let y=0;yb+u-d)continue;let v=l[y]+u-d;h>=v?l[y+1]=f<=v?-2:-1:f>=u&&g&&(l[y]+=g,l[y+1]+=g)}d+=g}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c=r.content.size){a=!0;continue}let f=t.map(n[c+1]+s,-1),h=f-i,{index:p,offset:m}=r.content.findIndex(d),g=r.maybeChild(p);if(g&&m==d&&m+g.nodeSize==h){let y=l[c+2].mapInner(t,g,u+1,n[c]+s+1,o);y!=oe?(l[c]=d,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=_p(l,n,e,t,i,s,o),u=Nr(c,r,0,o);e=u.local;for(let d=0;dt&&o.to{let c=Xc(n,l,a+t);if(c){s=!0;let u=Nr(c,l,t+a+1,r);u!=oe&&i.push(a,a+l.nodeSize,u)}});let o=Gc(s?Yc(n):n,-t).sort(Mt);for(let l=0;l0;)e++;n.splice(e,0,t)}function Ps(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=oe&&e.push(r)}),n.cursorWrapper&&e.push(K.create(n.state.doc,[n.cursorWrapper.deco])),Ar.from(e)}var Wp={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Jp=ke&&ot<=11,Zs=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},eo=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Zs,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():le&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Jp&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Wp)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;tthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(rc(this.view)){if(this.suppressingSelectionUpdates)return Xe(this.view);if(ke&&ot<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ct(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let s=e.focusNode;s;s=Gt(s))t.add(s);for(let s=e.anchorNode;s;s=Gt(s))if(t.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&rc(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let u=0;uu.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||Q&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&d.nodeType==1;){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(Ce&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!d||Up(e,d)!=h)&&f.remove()}}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(s>-1&&(e.docView.markDirty(s,o),jp(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,qp(e,a)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Xe(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;ui;g--){let y=r.childNodes[g-1],b=y.pmViewDesc;if(y.nodeName=="BR"&&!b){s=g;break}if(!b||b.size)break}let d=n.state.doc,f=n.someProp("domParser")||Ie.fromSchema(n.state.schema),h=d.resolve(o),p=null,m=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Xp,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),p={anchor:g+o,head:y+o}}return{doc:m,sel:p,from:o,to:l}}function Xp(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(le&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||le&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}var Yp=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Qp(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let E=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,L=no(n,E);if(L&&!n.state.selection.eq(L)){if(Q&&qe&&n.input.lastKeyCode===13&&Date.now()-100G(n,kt(13,"Enter"))))return;let z=n.state.tr.setSelection(L);E=="pointer"?z.setMeta("pointer",!0):E=="key"&&z.scrollIntoView(),s&&z.setMeta("composition",s),n.dispatch(z)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Gp(n,e,t),u=n.state.doc,d=u.slice(c.from,c.to),f,h;n.input.lastKeyCode===8&&Date.now()-100Date.now()-225||qe)&&i.some(E=>E.nodeType==1&&!Yp.test(E.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",E=>E(n,kt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof C&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let E=pc(n,n.state.doc,c.sel);if(E&&!E.eq(n.state.selection)){let L=n.state.tr.setSelection(E);s&&L.setMeta("composition",s),n.dispatch(L)}}return}n.state.selection.fromn.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),ke&&ot<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=u.resolve(p.start),b=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((Xt&&n.input.lastIOSEnter>Date.now()-225&&(!b||i.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!b&&m.posE(n,kt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&em(u,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",E=>E(n,kt(8,"Backspace")))){qe&&Q&&n.domObserver.suppressSelectionUpdates();return}Q&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),qe&&!b&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(E){return E(n,kt(13,"Enter"))})},20));let v=p.start,w=p.endA,A=E=>{let L=E||n.state.tr.replace(v,w,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let z=pc(n,L.doc,c.sel);z&&!(Q&&n.composing&&z.empty&&(p.start!=p.endB||n.input.lastChromeDeleteXe(n),20));let E=A(n.state.tr.delete(v,w)),L=u.resolve(p.start).marksAcross(u.resolve(p.endA));L&&E.ensureMarks(L),n.dispatch(E)}else if(p.endA==p.endB&&(R=Zp(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let E=A(n.state.tr);R.type=="add"?E.addMark(v,w,R.mark):E.removeMark(v,w,R.mark),n.dispatch(E)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let E=m.parent.textBetween(m.parentOffset,g.parentOffset),L=()=>A(n.state.tr.insertText(E,v,w));n.someProp("handleTextInput",z=>z(n,v,w,E,L))||n.dispatch(L())}else n.dispatch(A());else n.dispatch(A())}function pc(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:ro(n,e.resolve(t.anchor),e.resolve(t.head))}function Zp(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,s=r,o,l,a;for(let u=0;uu.mark(l.addToSet(u.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;ut||Ls(o,!0,!1)0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function tm(n,e,t,r,i){let s=n.findDiffStart(e,t),o=t+n.size,l=t+e.size;if(s==null)return null;let{a,b:c}=n.findDiffEnd(e,o,l);if(i=="end"){let u=Math.max(0,s-Math.min(a,c));r-=a+u-s}if(a=a?s-r:0;s-=u,c=s+(c-a),a=s}else if(c=c?s-r:0;s-=u,a=s+(a-c),c=s}return{start:s,endA:a,endB:c}}var Tn=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new qs,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(xc),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=yc(this),gc(this),this.nodeViews=kc(this),this.docView=Ya(this.state.doc,mc(this),Ps(this),this.dom,this),this.domObserver=new eo(this,(r,i,s,o)=>Qp(this,r,i,s,o)),this.domObserver.start(),wp(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Gs(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(xc),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(Kc(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=kc(this);rm(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Gs(this),this.editable=yc(this),gc(this);let a=Ps(this),c=mc(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",d=s||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(i.selection))&&(o=!0);let f=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&$h(this);if(o){this.domObserver.stop();let h=d&&(ke||Q)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&nm(i.selection,e.selection);if(d){let m=Q?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Lp(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Ya(e.doc,c,a,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let p=this.input.mouseDown;h||!(p&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&lp(this)&&p.delaySelUpdate())?Xe(this,h):(Dc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&Vh(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof M){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&ja(this,t.getBoundingClientRect(),e)}else ja(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t0&&st.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Uh(this,e)}coordsAtPos(e,t=1){return Ec(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return Qh(this,t||this.state,e)}pasteHTML(e,t){return Mn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Mn(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return io(this,e)}destroy(){this.docView&&(vp(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ps(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Oh())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Cp(this,e)}domSelectionRange(){let e=this.domSelection();return e?le&&this.root.nodeType===11&&Lh(this.dom.ownerDocument)==this.dom&&Kp(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Tn.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function mc(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[ae.node(0,n.state.doc.content.size,e)]}function gc(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:ae.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function yc(n){return!n.someProp("editable",e=>e(n.state)===!1)}function nm(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function kc(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function rm(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function xc(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Ye={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Ir={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},im=typeof navigator<"u"&&/Mac/.test(navigator.platform),sm=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(q=0;q<10;q++)Ye[48+q]=Ye[96+q]=String(q);var q;for(q=1;q<=24;q++)Ye[q+111]="F"+q;var q;for(q=65;q<=90;q++)Ye[q]=String.fromCharCode(q+32),Ir[q]=String.fromCharCode(q);var q;for(Rr in Ye)Ir.hasOwnProperty(Rr)||(Ir[Rr]=Ye[Rr]);var Rr;function Qc(n){var e=im&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||sm&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Ir:Ye)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var om=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),lm=typeof navigator<"u"&&/Win/.test(navigator.platform);function am(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,s,o;for(let l=0;l{for(var t in e)um(n,t,{get:e[t],enumerable:!0})};function $r(n){let{state:e,transaction:t}=n,{selection:r}=t,{doc:i}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=t.selection,i=t.doc,s=t.storedMarks,t}}}var Vr=class{constructor(n){this.editor=n.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=n.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:n,editor:e,state:t}=this,{view:r}=e,{tr:i}=t,s=this.buildProps(i);return Object.fromEntries(Object.entries(n).map(([o,l])=>[o,(...c)=>{let u=l(...c)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,e=!0){let{rawCommands:t,editor:r,state:i}=this,{view:s}=r,o=[],l=!!n,a=n||i.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(a),o.every(d=>d===!0)),u={...Object.fromEntries(Object.entries(t).map(([d,f])=>[d,(...p)=>{let m=this.buildProps(a,e),g=f(...p)(m);return o.push(g),u}])),run:c};return u}createCan(n){let{rawCommands:e,state:t}=this,r=!1,i=n||t.tr,s=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(n,e=!0){let{rawCommands:t,editor:r,state:i}=this,{view:s}=r,o={tr:n,editor:r,view:s,state:$r({state:i,transaction:n}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(n,e),can:()=>this.createCan(n),get commands(){return Object.fromEntries(Object.entries(t).map(([l,a])=>[l,(...c)=>a(...c)(o)]))}};return o}},du={};yo(du,{blur:()=>dm,clearContent:()=>fm,clearNodes:()=>hm,command:()=>pm,createParagraphNear:()=>mm,cut:()=>gm,deleteCurrentNode:()=>ym,deleteNode:()=>km,deleteRange:()=>xm,deleteSelection:()=>wm,enter:()=>vm,exitCode:()=>Mm,extendMarkRange:()=>Cm,first:()=>Tm,focus:()=>Am,forEach:()=>Nm,insertContent:()=>Om,insertContentAt:()=>Dm,joinBackward:()=>zm,joinDown:()=>Lm,joinForward:()=>Bm,joinItemBackward:()=>Fm,joinItemForward:()=>Hm,joinTextblockBackward:()=>$m,joinTextblockForward:()=>Vm,joinUp:()=>Pm,keyboardShortcut:()=>Wm,lift:()=>Jm,liftEmptyBlock:()=>jm,liftListItem:()=>Km,newlineInCode:()=>Um,resetAttributes:()=>qm,scrollIntoView:()=>Gm,selectAll:()=>Xm,selectNodeBackward:()=>Ym,selectNodeForward:()=>Qm,selectParentNode:()=>Zm,selectTextblockEnd:()=>eg,selectTextblockStart:()=>tg,setContent:()=>ng,setMark:()=>xg,setMeta:()=>bg,setNode:()=>Sg,setNodeSelection:()=>wg,setTextDirection:()=>vg,setTextSelection:()=>Mg,sinkListItem:()=>Cg,splitBlock:()=>Tg,splitListItem:()=>Eg,toggleList:()=>Ng,toggleMark:()=>Og,toggleNode:()=>Rg,toggleWrap:()=>Ig,undoInputRule:()=>Dg,unsetAllMarks:()=>Pg,unsetMark:()=>Lg,unsetTextDirection:()=>zg,updateAttributes:()=>Bg,wrapIn:()=>Fg,wrapInList:()=>Hg});var dm=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())==null||t.removeAllRanges())}),!0),fm=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),hm=()=>({state:n,tr:e,dispatch:t})=>{let{selection:r}=e,{ranges:i}=r;return t&&i.forEach(({$from:s,$to:o})=>{n.doc.nodesBetween(s.pos,o.pos,(l,a)=>{if(l.type.isText)return;let{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),f=c.resolve(u.map(a+l.nodeSize)),h=d.blockRange(f);if(!h)return;let p=je(h);if(l.type.isTextblock){let{defaultType:m}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},pm=n=>e=>n(e),mm=()=>({state:n,dispatch:e})=>Cs(n,e),gm=(n,e)=>({editor:t,tr:r})=>{let{state:i}=t,s=i.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);let o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new C(r.doc.resolve(Math.max(o-1,0)))),!0},ym=()=>({tr:n,dispatch:e})=>{let{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;let i=n.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){let l=i.before(s),a=i.after(s);n.delete(l,a).scrollIntoView()}return!0}return!1};function _(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}var km=n=>({tr:e,state:t,dispatch:r})=>{let i=_(n,t.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){let a=s.before(o),c=s.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},xm=n=>({tr:e,dispatch:t})=>{let{from:r,to:i}=n;return t&&e.delete(r,i),!0},bm=n=>n.content?/^text(\*|\+)/.test(n.content):!1,eu=(n,e,t)=>{if(!n.parent.isInline||t==="left"&&n.pos>n.start()||t==="right"&&n.pos{let r=eu(n,t,"left"),i=eu(e,t,"right");return{from:r,to:i}},wm=()=>({state:n,dispatch:e})=>{let{$from:t,$to:r}=n.selection;if(n.selection.empty)return!1;let{from:i,to:s}=Sm(t,r,n.schema);return e&&(n.tr.deleteRange(i,s).scrollIntoView(),e(n.tr)),!0},vm=()=>({commands:n})=>n.keyboardShortcut("Enter"),Mm=()=>({state:n,dispatch:e})=>Ms(n,e);function ko(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function Fr(n,e,t={strict:!0}){let r=Object.keys(e);return r.length?r.every(i=>t.strict?e[i]===n[i]:ko(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function fu(n,e,t={}){return n.find(r=>r.type===e&&Fr(Object.fromEntries(Object.keys(t).map(i=>[i,r.attrs[i]])),t))}function tu(n,e,t={}){return!!fu(n,e,t)}function xo(n,e,t){if(!n||!e)return;let r=n.parent.childAfter(n.parentOffset);if((!r.node||!r.node.marks.some(c=>c.type===e))&&(r=n.parent.childBefore(n.parentOffset)),!r.node||!r.node.marks.some(c=>c.type===e))return;if(!t){let c=r.node.marks.find(u=>u.type===e);c&&(t=c.attrs)}if(!fu([...r.node.marks],e,t))return;let s=r.index,o=n.start()+r.offset,l=s+1,a=o+r.node.nodeSize;for(;s>0&&tu([...n.parent.child(s-1).marks],e,t);)s-=1,o-=n.parent.child(s).nodeSize;for(;l({tr:t,state:r,dispatch:i})=>{let s=Qe(n,r.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:u}=l;if(i){let d=xo(a,s,e);if(d&&d.from<=c&&d.to>=u){let f=C.create(o,d.from,d.to);t.setSelection(f)}}return!0},Tm=n=>e=>{let t=typeof n=="function"?n(e):n;for(let r=0;r({editor:t,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};let o=()=>{(Hr()||nu())&&r.dom.focus(),Em()&&!Hr()&&!nu()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};try{if(r.hasFocus()&&n===null||n===!1)return!0}catch{return!1}if(s&&n===null&&!hu(t.state.selection))return o(),!0;let l=pu(i.doc,n)||t.state.selection,a=t.state.selection.eq(l);return s&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},Nm=(n,e)=>t=>n.every((r,i)=>e(r,{...t,index:i})),Om=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),mu=n=>{let e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){let r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&mu(r)}return n};function Dr(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");let e=`${n}`,t=new window.DOMParser().parseFromString(e,"text/html").body;return mu(t)}function Pn(n,e,t){if(n instanceof ye||n instanceof k)return n;t={slice:!0,parseOptions:{},...t};let r=typeof n=="object"&&n!==null,i=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return k.fromArray(n.map(l=>e.nodeFromJSON(l)));let o=e.nodeFromJSON(n);return t.errorOnInvalidContent&&o.check(),o}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),Pn("",e,t)}if(i){if(t.errorOnInvalidContent){let o=!1,l="",a=new Ht({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?Ie.fromSchema(a).parseSlice(Dr(n),t.parseOptions):Ie.fromSchema(a).parse(Dr(n),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let s=Ie.fromSchema(e);return t.slice?s.parseSlice(Dr(n),t.parseOptions).content:s.parse(Dr(n),t.parseOptions)}return Pn("",e,t)}function Rm(n,e,t){let r=n.steps.length-1;if(r{o===0&&(o=u)}),n.setSelection(O.near(n.doc.resolve(o),t))}var Im=n=>!("type"in n),Dm=(n,e,t)=>({tr:r,dispatch:i,editor:s})=>{var o;if(i){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l,a=g=>{s.emit("contentError",{editor:s,error:g,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{Pn(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=Pn(e,s.schema,{parseOptions:c,errorOnInvalidContent:(o=t.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(g){return a(g),!1}let{from:u,to:d}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},f=!0,h=!0;if((Im(l)?l:[l]).forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),u===d&&h){let{parent:g}=r.doc.resolve(u);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(u-=1,d+=1)}let m;if(f){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof k){let g="";e.forEach(y=>{y.text&&(g+=y.text)}),m=g}else typeof e=="object"&&e&&e.text?m=e.text:m=e;r.insertText(m,u,d)}else{m=l;let g=r.doc.resolve(u),y=g.node(),b=g.parentOffset===0,v=y.isText||y.isTextblock,w=y.content.size>0;b&&v&&w&&h&&(u=Math.max(0,u-1)),r.replaceWith(u,d,m)}t.updateSelection&&Rm(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:m}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:m})}return!0},Pm=()=>({state:n,dispatch:e})=>Da(n,e),Lm=()=>({state:n,dispatch:e})=>Pa(n,e),zm=()=>({state:n,dispatch:e})=>gs(n,e),Bm=()=>({state:n,dispatch:e})=>xs(n,e),Fm=()=>({state:n,dispatch:e,tr:t})=>{try{let r=gt(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Hm=()=>({state:n,dispatch:e,tr:t})=>{try{let r=gt(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},$m=()=>({state:n,dispatch:e})=>Na(n,e),Vm=()=>({state:n,dispatch:e})=>Oa(n,e);function gu(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function _m(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t==="Space"&&(t=" ");let r,i,s,o;for(let l=0;l({editor:e,view:t,tr:r,dispatch:i})=>{let s=_m(n).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a?.steps.forEach(c=>{let u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function Pe(n,e,t={}){let{from:r,to:i,empty:s}=n.selection,o=e?_(e,n.schema):null,l=[];n.doc.nodesBetween(r,i,(d,f)=>{if(d.isText)return;let h=Math.max(r,f),p=Math.min(i,f+d.nodeSize);l.push({node:d,from:h,to:p})});let a=i-r,c=l.filter(d=>o?o.name===d.node.type.name:!0).filter(d=>Fr(d.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=a}var Jm=(n,e={})=>({state:t,dispatch:r})=>{let i=_(n,t.schema);return Pe(t,i,e)?La(t,r):!1},jm=()=>({state:n,dispatch:e})=>Ts(n,e),Km=n=>({state:e,dispatch:t})=>{let r=_(n,e.schema);return Va(r)(e,t)},Um=()=>({state:n,dispatch:e})=>ws(n,e);function _r(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function ru(n,e){let t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,i)=>(t.includes(i)||(r[i]=n[i]),r),{})}var qm=(n,e)=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null,l=_r(typeof n=="string"?n:n.name,r.schema);if(!l)return!1;l==="node"&&(s=_(n,r.schema)),l==="mark"&&(o=Qe(n,r.schema));let a=!1;return t.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{s&&s===u.type&&(a=!0,i&&t.setNodeMarkup(d,void 0,ru(u.attrs,e))),o&&u.marks.length&&u.marks.forEach(f=>{o===f.type&&(a=!0,i&&t.addMark(d,d+u.nodeSize,o.create(ru(f.attrs,e))))})})}),a},Gm=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),Xm=()=>({tr:n,dispatch:e})=>{if(e){let t=new fe(n.doc);n.setSelection(t)}return!0},Ym=()=>({state:n,dispatch:e})=>ys(n,e),Qm=()=>({state:n,dispatch:e})=>bs(n,e),Zm=()=>({state:n,dispatch:e})=>za(n,e),eg=()=>({state:n,dispatch:e})=>As(n,e),tg=()=>({state:n,dispatch:e})=>Es(n,e);function mo(n,e,t={},r={}){return Pn(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}var ng=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{let{doc:a}=s;if(r.preserveWhitespace!=="full"){let c=mo(n,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&s.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!t),!0}return o&&s.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:a.content.size},n,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function yu(n,e){let t=Qe(e,n.schema),{from:r,to:i,empty:s}=n.selection,o=[];s?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,i,a=>{o.push(...a.marks)});let l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function bo(n,e){let t=new _t(n);return e.forEach(r=>{r.steps.forEach(i=>{t.step(i)})}),t}function rg(n){for(let e=0;e{t(i)&&r.push({node:i,pos:s})}),r}function ig(n,e){for(let t=n.depth;t>0;t-=1){let r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function Wr(n){return e=>ig(e.$from,n)}function T(n,e,t){return n.config[e]===void 0&&n.parent?T(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?T(n.parent,e,t):null}):n.config[e]}function So(n){return n.map(e=>{let t={name:e.name,options:e.options,storage:e.storage},r=T(e,"addExtensions",t);return r?[e,...So(r())]:e}).flat(10)}function wo(n,e){let t=_e.fromSchema(e).serializeFragment(n),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}function xu(n){return typeof n=="function"}function H(n,e=void 0,...t){return xu(n)?e?n.bind(e)(...t):n(...t):n}function sg(n={}){return Object.keys(n).length===0&&n.constructor===Object}function Yt(n){let e=n.filter(i=>i.type==="extension"),t=n.filter(i=>i.type==="node"),r=n.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function bu(n){let e=[],{nodeExtensions:t,markExtensions:r}=Yt(n),i=[...t,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=t.filter(c=>c.name!=="text").map(c=>c.name),l=r.map(c=>c.name),a=[...o,...l];return n.forEach(c=>{let u={name:c.name,options:c.options,storage:c.storage,extensions:i},d=T(c,"addGlobalAttributes",u);if(!d)return;d().forEach(h=>{let p;Array.isArray(h.types)?p=h.types:h.types==="*"?p=a:h.types==="nodes"?p=o:h.types==="marks"?p=l:p=[],p.forEach(m=>{Object.entries(h.attributes).forEach(([g,y])=>{e.push({type:m,name:g,attribute:{...s,...y}})})})})}),i.forEach(c=>{let u={name:c.name,options:c.options,storage:c.storage},d=T(c,"addAttributes",u);if(!d)return;let f=d();Object.entries(f).forEach(([h,p])=>{let m={...s,...p};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,e.push({type:c.name,name:h,attribute:m})})}),e}function og(n){let e=[],t="",r=!1,i=!1,s=0,o=n.length;for(let l=0;l0){s-=1,t+=a;continue}if(a===";"&&s===0){e.push(t),t="";continue}}t+=a}return t&&e.push(t),e}function iu(n){let e=[],t=og(n||""),r=t.length;for(let i=0;i!!e).reduce((e,t)=>{let r={...e};return Object.entries(t).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){let l=s?String(s).split(" "):[],a=r[i]?r[i].split(" "):[],c=l.filter(u=>!a.includes(u));r[i]=[...a,...c].join(" ")}else if(i==="style"){let l=new Map([...iu(r[i]),...iu(s)]);r[i]=Array.from(l.entries()).map(([a,c])=>`${a}: ${c}`).join("; ")}else r[i]=s}),r},{})}function Qt(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>D(t,r),{})}function lg(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function su(n,e){return"style"in n?n:{...n,getAttrs:t=>{let r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;let i=e.reduce((s,o)=>{let l=o.attribute.parseHTML?o.attribute.parseHTML(t):lg(t.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...r,...i}}}}function ou(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&sg(t)?!1:t!=null))}function lu(n){var e,t;let r={};return!((e=n?.attribute)!=null&&e.isRequired)&&"default"in(n?.attribute||{})&&(r.default=n.attribute.default),((t=n?.attribute)==null?void 0:t.validate)!==void 0&&(r.validate=n.attribute.validate),[n.name,r]}function ag(n,e){var t;let r=bu(n),{nodeExtensions:i,markExtensions:s}=Yt(n),o=(t=i.find(c=>T(c,"topNode")))==null?void 0:t.name,l=Object.fromEntries(i.map(c=>{let u=r.filter(y=>y.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((y,b)=>{let v=T(b,"extendNodeSchema",d);return{...y,...v?v(c):{}}},{}),h=ou({...f,content:H(T(c,"content",d)),marks:H(T(c,"marks",d)),group:H(T(c,"group",d)),inline:H(T(c,"inline",d)),atom:H(T(c,"atom",d)),selectable:H(T(c,"selectable",d)),draggable:H(T(c,"draggable",d)),code:H(T(c,"code",d)),whitespace:H(T(c,"whitespace",d)),linebreakReplacement:H(T(c,"linebreakReplacement",d)),defining:H(T(c,"defining",d)),isolating:H(T(c,"isolating",d)),attrs:Object.fromEntries(u.map(lu))}),p=H(T(c,"parseHTML",d));p&&(h.parseDOM=p.map(y=>su(y,u)));let m=T(c,"renderHTML",d);m&&(h.toDOM=y=>m({node:y,HTMLAttributes:Qt(y,u)}));let g=T(c,"renderText",d);return g&&(h.toText=g),[c.name,h]})),a=Object.fromEntries(s.map(c=>{let u=r.filter(g=>g.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((g,y)=>{let b=T(y,"extendMarkSchema",d);return{...g,...b?b(c):{}}},{}),h=ou({...f,inclusive:H(T(c,"inclusive",d)),excludes:H(T(c,"excludes",d)),group:H(T(c,"group",d)),spanning:H(T(c,"spanning",d)),code:H(T(c,"code",d)),attrs:Object.fromEntries(u.map(lu))}),p=H(T(c,"parseHTML",d));p&&(h.parseDOM=p.map(g=>su(g,u)));let m=T(c,"renderHTML",d);return m&&(h.toDOM=g=>m({mark:g,HTMLAttributes:Qt(g,u)})),[c.name,h]}));return new Ht({topNode:o,nodes:l,marks:a})}function cg(n){let e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}function Dn(n){return n.sort((t,r)=>{let i=T(t,"priority")||100,s=T(r,"priority")||100;return i>s?-1:ir.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function wu(n,e,t){let{from:r,to:i}=e,{blockSeparator:s=` + +`,textSerializers:o={}}=t||{},l="";return n.nodesBetween(r,i,(a,c,u,d)=>{var f;a.isBlock&&c>r&&(l+=s);let h=o?.[a.type.name];if(h)return u&&(l+=h({node:a,pos:c,parent:u,index:d,range:e})),!1;a.isText&&(l+=(f=a?.text)==null?void 0:f.slice(Math.max(r,c)-c,i-c))}),l}function ug(n,e){let t={from:0,to:n.content.size};return wu(n,t,e)}function vu(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function dg(n,e){let t=_(e,n.schema),{from:r,to:i}=n.selection,s=[];n.doc.nodesBetween(r,i,l=>{s.push(l)});let o=s.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function vo(n,e){let t=_r(typeof e=="string"?e:e.name,n.schema);return t==="node"?dg(n,e):t==="mark"?yu(n,e):{}}function fg(n,e=JSON.stringify){let t={};return n.filter(r=>{let i=e(r);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function hg(n){let e=fg(n);return e.length===1?e:e.filter((t,r)=>!e.filter((s,o)=>o!==r).some(s=>t.oldRange.from>=s.oldRange.from&&t.oldRange.to<=s.oldRange.to&&t.newRange.from>=s.newRange.from&&t.newRange.to<=s.newRange.to))}function Mo(n){let{mapping:e,steps:t}=n,r=[];return e.maps.forEach((i,s)=>{let o=[];if(i.ranges.length)i.forEach((l,a)=>{o.push({from:l,to:a})});else{let{from:l,to:a}=t[s];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{let c=e.slice(s).map(l,-1),u=e.slice(s).map(a),d=e.invert().map(c,-1),f=e.invert().map(u);r.push({oldRange:{from:d,to:f},newRange:{from:c,to:u}})})}),hg(r)}function Jr(n,e,t){let r=[];return n===e?t.resolve(n).marks().forEach(i=>{let s=t.resolve(n),o=xo(s,i.type);o&&r.push({mark:i,...o})}):t.nodesBetween(n,e,(i,s)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}var Mu=(n,e,t,r=20)=>{let i=n.doc.resolve(t),s=r,o=null;for(;s>0&&o===null;){let l=i.node(s);l?.type.name===e?o=l:s-=1}return[o,s]};function Rn(n,e){return e.nodes[n]||e.marks[n]||null}function Br(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{let i=n.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}var pg=(n,e=500)=>{let t="",r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(i,s,o,l)=>{var a,c;let u=((c=(a=i.type.spec).toText)==null?void 0:c.call(a,{node:i,pos:s,parent:o,index:l}))||i.textContent||"%leaf%";t+=i.isAtom&&!i.isText?u:u.slice(0,Math.max(0,r-s))}),t};function go(n,e,t={}){let{empty:r,ranges:i}=n.selection,s=e?Qe(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>Fr(d.attrs,t,{strict:!1}));let o=0,l=[];if(i.forEach(({$from:d,$to:f})=>{let h=d.pos,p=f.pos;n.doc.nodesBetween(h,p,(m,g)=>{if(s&&m.inlineContent&&!m.type.allowsMarkType(s))return!1;if(!m.isText&&!m.marks.length)return;let y=Math.max(h,g),b=Math.min(p,g+m.nodeSize),v=b-y;o+=v,l.push(...m.marks.map(w=>({mark:w,from:y,to:b})))})}),o===0)return!1;let a=l.filter(d=>s?s.name===d.mark.type.name:!0).filter(d=>Fr(d.mark.attrs,t,{strict:!1})).reduce((d,f)=>d+f.to-f.from,0),c=l.filter(d=>s?d.mark.type!==s&&d.mark.type.excludes(s):!0).reduce((d,f)=>d+f.to-f.from,0);return(a>0?a+c:a)>=o}function mg(n,e,t={}){if(!e)return Pe(n,null,t)||go(n,null,t);let r=_r(e,n.schema);return r==="node"?Pe(n,e,t):r==="mark"?go(n,e,t):!1}var Cu=(n,e)=>{let{$from:t,$to:r,$anchor:i}=n.selection;if(e){let s=Wr(l=>l.type.name===e)(n.selection);if(!s)return!1;let o=n.doc.resolve(s.pos+1);return i.pos+1===o.end()}return!(r.parentOffset{let{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function au(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function fo(n,e){let{nodeExtensions:t}=Yt(e),r=t.find(o=>o.name===n);if(!r)return!1;let i={name:r.name,options:r.options,storage:r.storage},s=H(T(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function Zt(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return!/\S/.test((r=n.text)!=null?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let i=!0;return n.content.forEach(s=>{i!==!1&&(Zt(s,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function jr(n){return n instanceof M}var Eu=class Au{constructor(e){this.position=e}static fromJSON(e){return new Au(e.position)}toJSON(){return{position:this.position}}};function gg(n,e){let t=e.mapping.mapResult(n.position);return{position:new Eu(t.pos),mapResult:t}}function yg(n){return new Eu(n)}function kg(n,e,t){var r;let{selection:i}=e,s=null;if(hu(i)&&(s=i.$cursor),s){let l=(r=n.storedMarks)!=null?r:s.marks();return s.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(c=>c.type.excludes(t)))}let{ranges:o}=i;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){let h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(t));c=h&&p}return!c}),c})}var xg=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let{selection:s}=t,{empty:o,ranges:l}=s,a=Qe(n,r.schema);if(i)if(o){let c=yu(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{let u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{let p=Math.max(h,u),m=Math.min(h+f.nodeSize,d);f.marks.find(y=>y.type===a)?f.marks.forEach(y=>{a===y.type&&t.addMark(p,m,a.create({...y.attrs,...e}))}):t.addMark(p,m,a.create(e))})});return kg(r,t,a)},bg=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),Sg=(n,e={})=>({state:t,dispatch:r,chain:i})=>{let s=_(n,t.schema),o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:l})=>Ns(s,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Ns(s,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},wg=n=>({tr:e,dispatch:t})=>{if(t){let{doc:r}=e,i=Et(n,0,r.content.size),s=M.create(r,i);e.setSelection(s)}return!0},vg=(n,e)=>({tr:t,state:r,dispatch:i})=>{let{selection:s}=r,o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=s.from,l=s.to),i&&t.doc.nodesBetween(o,l,(a,c)=>{a.isText||t.setNodeMarkup(c,void 0,{...a.attrs,dir:n})}),!0},Mg=n=>({tr:e,dispatch:t})=>{if(t){let{doc:r}=e,{from:i,to:s}=typeof n=="number"?{from:n,to:n}:n,o=C.atStart(r).from,l=C.atEnd(r).to,a=Et(i,o,l),c=Et(s,o,l),u=C.create(r,a,c);e.setSelection(u)}return!0},Cg=n=>({state:e,dispatch:t})=>{let r=_(n,e.schema);return _a(r)(e,t)};function cu(n,e){let t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){let r=t.filter(i=>e?.includes(i.type.name));n.tr.ensureMarks(r)}}var Tg=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:i})=>{let{selection:s,doc:o}=e,{$from:l,$to:a}=s,c=i.extensionManager.attributes,u=Br(c,l.node().type.name,l.node().attrs);if(s instanceof M&&s.node.isBlock)return!l.parentOffset||!be(o,l.pos)?!1:(r&&(n&&cu(t,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let d=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:rg(l.node(-1).contentMatchAt(l.indexAfter(-1))),h=d&&f?[{type:f,attrs:u}]:void 0,p=be(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&be(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:u}]:void 0),r){if(p&&(s instanceof C&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),f&&!d&&!l.parentOffset&&l.parent.type!==f)){let m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}n&&cu(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return p},Eg=(n,e={})=>({tr:t,state:r,dispatch:i,editor:s})=>{var o;let l=_(n,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;let d=a.node(-1);if(d.type!==l)return!1;let f=s.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(i){let y=k.empty,b=a.index(-1)?1:a.index(-2)?2:3;for(let L=a.depth-b;L>=a.depth-3;L-=1)y=k.from(a.node(L).copy(y));let v=a.indexAfter(-1){if(E>-1)return!1;L.isTextblock&&L.content.size===0&&(E=z+1)}),E>-1&&t.setSelection(C.near(t.doc.resolve(E))),t.scrollIntoView()}return!0}let h=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,p={...Br(f,d.type.name,d.attrs),...e},m={...Br(f,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);let g=h?[{type:l,attrs:p},{type:h,attrs:m}]:[{type:l,attrs:p}];if(!be(t.doc,a.pos,2))return!1;if(i){let{selection:y,storedMarks:b}=r,{splittableMarks:v}=s.extensionManager,w=b||y.$to.parentOffset&&y.$from.marks();if(t.split(a.pos,2,g).scrollIntoView(),!w||!i)return!0;let A=w.filter(R=>v.includes(R.type.name));t.ensureMarks(A)}return!0};function uu(n){return!n||n==="1"?null:n}function Nu(n,e){return uu(n)===uu(e)}var ho=(n,e)=>{let t=Wr(o=>o.type===e)(n.selection);if(!t)return!0;let r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;let i=n.doc.nodeAt(r);return!(t.node.type===i?.type&&we(n.doc,t.pos))||!Nu(t.node.attrs.type,i?.attrs.type)||n.join(t.pos),!0},po=(n,e)=>{let t=Wr(o=>o.type===e)(n.selection);if(!t)return!0;let r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;let i=n.doc.nodeAt(r);return!(t.node.type===i?.type&&we(n.doc,r))||!Nu(t.node.attrs.type,i?.attrs.type)||n.join(r),!0};function Ag(n){let e=n.doc,t=e.firstChild;if(!t)return null;let r=e.resolve(1),i=e.resolve(t.nodeSize-1);return C.between(r,i)}var Ng=(n,e,t,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:a,commands:c,can:u})=>{let{extensions:d,splittableMarks:f}=i.extensionManager,h=_(n,o.schema),p=_(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:b}=m,v=y.blockRange(b),w=g||m.$to.parentOffset&&m.$from.marks();if(!v)return!1;let A=Wr(ie=>fo(ie.type.name,d))(m),R=m.from===0&&m.to===o.doc.content.size,E=o.doc.content.content,L=E.length===1?E[0]:null,z=R&&L&&fo(L.type.name,d)?{node:L,pos:0,depth:0}:null,G=A??z,Ve=!!A&&v.depth>=1&&v.depth-A.depth<=1,Re=!!z;if((Ve||Re)&&G){if(G.node.type===h)return R&&Re?a().command(({tr:ie,dispatch:X})=>{let j=Ag(ie);return j?(ie.setSelection(j),X&&X(ie),!0):!1}).liftListItem(p).run():c.liftListItem(p);if(fo(G.node.type.name,d)&&h.validContent(G.node.content))return a().command(()=>(s.setNodeMarkup(G.pos,h),!0)).command(()=>ho(s,h)).command(()=>po(s,h)).run()}return!t||!w||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>ho(s,h)).command(()=>po(s,h)).run():a().command(()=>{let ie=u().wrapInList(h,r),X=w.filter(j=>f.includes(j.type.name));return s.ensureMarks(X),ie?!0:c.clearNodes()}).wrapInList(h,r).command(()=>ho(s,h)).command(()=>po(s,h)).run()},Og=(n,e={},t={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:s=!1}=t,o=Qe(n,r.schema);return go(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},Rg=(n,e,t={})=>({state:r,commands:i})=>{let s=_(n,r.schema),o=_(e,r.schema),l=Pe(r,s,t),a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?i.setNode(o,a):i.setNode(s,{...a,...t})},Ig=(n,e={})=>({state:t,commands:r})=>{let i=_(n,t.schema);return Pe(t,i,e)?r.lift(i):r.wrapIn(i,e)},Dg=()=>({state:n,dispatch:e})=>{let t=n.plugins;for(let r=0;r=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(s.text){let a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,n.schema.text(s.text,a))}else o.delete(s.from,s.to)}return!0}}return!1},Pg=(n={})=>({tr:e,dispatch:t,editor:r})=>{let{ignoreClearable:i=!1}=n,{selection:s}=e,{empty:o,ranges:l}=s;if(o)return!0;let{nonClearableMarks:a}=r.extensionManager;if(t){let c=Object.values(r.schema.marks).filter(u=>i||!a.includes(u.name));l.forEach(u=>{for(let d of c)e.removeMark(u.$from.pos,u.$to.pos,d)})}return!0},Lg=(n,e={})=>({tr:t,state:r,dispatch:i})=>{var s;let{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=Qe(n,r.schema),{$from:c,empty:u,ranges:d}=l;if(!i)return!0;if(u&&o){let{from:f,to:h}=l,p=(s=c.marks().find(g=>g.type===a))==null?void 0:s.attrs,m=xo(c,a,p);m&&(f=m.from,h=m.to),t.removeMark(f,h,a)}else d.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},zg=n=>({tr:e,state:t,dispatch:r})=>{let{selection:i}=t,s,o;return typeof n=="number"?(s=n,o=n):n&&"from"in n&&"to"in n?(s=n.from,o=n.to):(s=i.from,o=i.to),r&&e.doc.nodesBetween(s,o,(l,a)=>{if(l.isText)return;let c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},Bg=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null,l=_r(typeof n=="string"?n:n.name,r.schema);if(!l)return!1;l==="node"&&(s=_(n,r.schema)),l==="mark"&&(o=Qe(n,r.schema));let a=!1;return t.selection.ranges.forEach(c=>{let u=c.$from.pos,d=c.$to.pos,f,h,p,m;t.selection.empty?r.doc.nodesBetween(u,d,(g,y)=>{s&&s===g.type&&(a=!0,p=Math.max(y,u),m=Math.min(y+g.nodeSize,d),f=y,h=g)}):r.doc.nodesBetween(u,d,(g,y)=>{y=u&&y<=d&&(s&&s===g.type&&(a=!0,i&&t.setNodeMarkup(y,void 0,{...g.attrs,...e})),o&&g.marks.length&&g.marks.forEach(b=>{if(o===b.type&&(a=!0,i)){let v=Math.max(y,u),w=Math.min(y+g.nodeSize,d);t.addMark(v,w,o.create({...b.attrs,...e}))}}))}),h&&(f!==void 0&&i&&t.setNodeMarkup(f,void 0,{...h.attrs,...e}),o&&h.marks.length&&h.marks.forEach(g=>{o===g.type&&i&&t.addMark(p,m,o.create({...g.attrs,...e}))}))}),a},Fg=(n,e={})=>({state:t,dispatch:r})=>{let i=_(n,t.schema);return Ha(i,e)(t,r)},Hg=(n,e={})=>({state:t,dispatch:r})=>{let i=_(n,t.schema);return $a(i,e)(t,r)},$g=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){let t=this.callbacks[n];return t&&t.forEach(r=>r.apply(this,e)),this}off(n,e){let t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(r=>r!==e):delete this.callbacks[n]),this}once(n,e){let t=(...r)=>{this.off(n,t),e.apply(this,r)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}};function Ou(n,e){let{selection:t}=n,{$from:r}=t;if(t instanceof M){let s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let i=r.depth;for(;i>=0;){let s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}function Co(n,e,t){let r=document.querySelector(`style[data-tiptap-style${t?`-${t}`:""}]`);if(r!==null)return r;let i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute(`data-tiptap-style${t?`-${t}`:""}`,""),i.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(i),i}function Vg(n){return typeof n=="number"}function _g(n){return Object.prototype.toString.call(n).slice(8,-1)}function Pr(n){return _g(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}var Wg={};yo(Wg,{createAtomBlockMarkdownSpec:()=>Jg,createBlockMarkdownSpec:()=>jg,createInlineMarkdownSpec:()=>qg,parseAttributes:()=>To,parseIndentedBlocks:()=>Kr,renderNestedMarkdownContent:()=>Ln,serializeAttributes:()=>Eo});function To(n){if(!n?.trim())return{};let e={},t=[],r=n.replace(/["']([^"']*)["']/g,c=>(t.push(c),`__QUOTED_${t.length-1}__`)),i=r.match(/(?:^|\s)\.([\w-]+)/g);if(i){let c=i.map(u=>u.trim().slice(1));e.class=c.join(" ")}let s=r.match(/(?:^|\s)#([\w-]+)/);s&&(e.id=s[1]);let o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,c,u])=>{var d;let f=parseInt(((d=u.match(/__QUOTED_(\d+)__/))==null?void 0:d[1])||"0",10),h=t[f];h&&(e[c]=h.slice(1,-1))});let a=r.replace(/(?:^|\s)\.([\w-]+)/g,"").replace(/(?:^|\s)#([\w-]+)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function Eo(n){if(!n||Object.keys(n).length===0)return"";let e=[];return n.class&&String(n.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),n.id&&e.push(`#${n.id}`),Object.entries(n).forEach(([t,r])=>{t==="class"||t==="id"||(r===!0?e.push(t):r!==!1&&r!=null&&e.push(`${t}="${String(r)}"`))}),e.join(" ")}function Jg(n){let{nodeName:e,name:t,parseAttributes:r=To,serializeAttributes:i=Eo,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:l}=n,a=t||e,c=u=>{if(!l)return u;let d={};return l.forEach(f=>{f in u&&(d[f]=u[f])}),d};return{parseMarkdown:(u,d)=>{let f={...s,...u.attributes};return d.createNode(e,f,[])},markdownTokenizer:{name:e,level:"block",start(u){var d;let f=new RegExp(`^:::${a}(?:\\s|$)`,"m"),h=(d=u.match(f))==null?void 0:d.index;return h!==void 0?h:-1},tokenize(u,d,f){let h=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=u.match(h);if(!p)return;let m=p[1]||"",g=r(m);if(!o.find(b=>!(b in g)))return{type:e,raw:p[0],attributes:g}}},renderMarkdown:u=>{let d=c(u.attrs||{}),f=i(d),h=f?` {${f}}`:"";return`:::${a}${h} :::`}}}function jg(n){let{nodeName:e,name:t,getContent:r,parseAttributes:i=To,serializeAttributes:s=Eo,defaultAttributes:o={},content:l="block",allowedAttributes:a}=n,c=t||e,u=d=>{if(!a)return d;let f={};return a.forEach(h=>{h in d&&(f[h]=d[h])}),f};return{parseMarkdown:(d,f)=>{let h;if(r){let m=r(d);h=typeof m=="string"?[{type:"text",text:m}]:m}else l==="block"?h=f.parseChildren(d.tokens||[]):h=f.parseInline(d.tokens||[]);let p={...o,...d.attributes};return f.createNode(e,p,h)},markdownTokenizer:{name:e,level:"block",start(d){var f;let h=new RegExp(`^:::${c}`,"m"),p=(f=d.match(h))==null?void 0:f.index;return p!==void 0?p:-1},tokenize(d,f,h){var p;let m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=d.match(m);if(!g)return;let[y,b=""]=g,v=i(b),w=1,A=y.length,R="",E=/^:::([\w-]*)(\s.*)?/gm,L=d.slice(A);for(E.lastIndex=0;;){let z=E.exec(L);if(z===null)break;let G=z.index,Ve=z[1];if(!((p=z[2])!=null&&p.endsWith(":::"))){if(Ve)w+=1;else if(w-=1,w===0){let Re=L.slice(0,G);R=Re.trim();let ie=d.slice(0,A+G+z[0].length),X=[];if(R)if(l==="block")for(X=h.blockTokens(Re),X.forEach(j=>{j.text&&(!j.tokens||j.tokens.length===0)&&(j.tokens=h.inlineTokens(j.text))});X.length>0;){let j=X[X.length-1];if(j.type==="paragraph"&&(!j.text||j.text.trim()===""))X.pop();else break}else X=h.inlineTokens(R);return{type:e,raw:ie,attributes:v,content:R,tokens:X}}}}}},renderMarkdown:(d,f)=>{let h=u(d.attrs||{}),p=s(h),m=p?` {${p}}`:"",g=f.renderChildren(d.content||[],` + +`);return`:::${c}${m} + +${g} + +:::`}}}function Kg(n){if(!n.trim())return{};let e={},t=/(\w+)=(?:"([^"]*)"|'([^']*)')/g,r=t.exec(n);for(;r!==null;){let[,i,s,o]=r;e[i]=s||o,r=t.exec(n)}return e}function Ug(n){return Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(" ")}function qg(n){let{nodeName:e,name:t,getContent:r,parseAttributes:i=Kg,serializeAttributes:s=Ug,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:a}=n,c=t||e,u=f=>{if(!a)return f;let h={};return a.forEach(p=>{let m=typeof p=="string"?p:p.name,g=typeof p=="string"?void 0:p.skipIfDefault;if(m in f){let y=f[m];if(g!==void 0&&y===g)return;h[m]=y}}),h},d=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(f,h)=>{let p={...o,...f.attributes};if(l)return h.createNode(e,p);let m=r?r(f):f.content||"";return m?h.createNode(e,p,[h.createTextNode(m)]):h.createNode(e,p,[])},markdownTokenizer:{name:e,level:"inline",start(f){let h=l?new RegExp(`\\[${d}\\s*[^\\]]*\\]`):new RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),p=f.match(h),m=p?.index;return m!==void 0?m:-1},tokenize(f,h,p){let m=l?new RegExp(`^\\[${d}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),g=f.match(m);if(!g)return;let y="",b="";if(l){let[,w]=g;b=w}else{let[,w,A]=g;b=w,y=A||""}let v=i(b.trim());return{type:e,raw:g[0],content:y.trim(),attributes:v}}},renderMarkdown:f=>{let h="";r?h=r(f):f.content&&f.content.length>0&&(h=f.content.filter(y=>y.type==="text").map(y=>y.text).join(""));let p=u(f.attrs||{}),m=s(p),g=m?` ${m}`:"";return l?`[${c}${g}]`:`[${c}${g}]${h}[/${c}]`}}}function Kr(n,e,t){var r,i,s,o;let l=n.split(` +`),a=[],c="",u=0,d=e.baseIndentSize||2;for(;u0)break;if(f.trim()===""){u+=1,c=`${c}${f} +`;continue}else return}let p=e.extractItemData(h),{indentLevel:m,mainContent:g}=p;c=`${c}${f} +`;let y=[g];for(u+=1;uG.trim()!=="");if(E===-1)break;if((((i=(r=l[u+1+E].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>m){y.push(A),c=`${c}${A} +`,u+=1;continue}else break}if((((o=(s=A.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:o.length)||0)>m)y.push(A),c=`${c}${A} +`,u+=1;else break}let b,v=y.slice(1);if(v.length>0){let A=v.map(R=>R.slice(m+d)).join(` +`);A.trim()&&(e.customNestedParser?b=e.customNestedParser(A):b=t.blockTokens(A))}let w=e.createToken(p,b);a.push(w)}if(a.length!==0)return{items:a,raw:c}}function Ln(n,e,t,r){if(!n||!Array.isArray(n.content))return"";let i=typeof t=="function"?t(r):t,[s,...o]=n.content,l=e.renderChildren([s]),a=`${i}${l}`;return o&&o.length>0&&o.forEach((c,u)=>{var d,f;let h=(f=(d=e.renderChild)==null?void 0:d.call(e,c,u+1))!=null?f:e.renderChildren([c]);if(h!=null){let p=h.split(` +`).map(m=>m?e.indent(m):e.indent("")).join(` +`);a+=c.type==="paragraph"?` + +${p}`:` +${p}`}}),a}function Ru(n,e){let t={...n};return Pr(n)&&Pr(e)&&Object.keys(e).forEach(r=>{Pr(e[r])&&Pr(n[r])?t[r]=Ru(n[r],e[r]):t[r]=e[r]}),t}function Gg(n,e,t={}){let{state:r}=e,{doc:i,tr:s}=r,o=n;i.descendants((l,a)=>{let c=s.mapping.map(a),u=s.mapping.map(a)+l.nodeSize,d=null;if(l.marks.forEach(h=>{if(h!==o)return!1;d=h}),!d)return;let f=!1;if(Object.keys(t).forEach(h=>{t[h]!==d.attrs[h]&&(f=!0)}),f){let h=n.type.create({...n.attrs,...t});s.removeMark(c,u,n.type),s.addMark(c,u,h)}}),s.docChanged&&e.view.dispatch(s)}var Ur=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!=null?e:!0}},Xg=(n,e)=>{if(ko(e))return e.exec(n);let t=e(n);if(!t)return null;let r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function Lr(n){var e;let{editor:t,from:r,to:i,text:s,rules:o,plugin:l}=n,{view:a}=t;if(a.composing)return!1;let c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(f=>f.type.spec.code))return!1;let u=!1,d=pg(c)+s;return o.forEach(f=>{if(u)return;let h=Xg(d,f.find);if(!h)return;let p=a.state.tr,m=$r({state:a.state,transaction:p}),g={from:r-(h[0].length-s.length),to:i},{commands:y,chain:b,can:v}=new Vr({editor:t,state:m});f.handler({state:m,range:g,match:h,commands:y,chain:b,can:v})===null||!p.steps.length||(f.undoable&&p.setMeta(l,{transform:p,from:r,to:i,text:s}),a.dispatch(p),u=!0)}),u}function Yg(n){let{editor:e,rules:t}=n,r=new N({state:{init(){return null},apply(i,s,o){let l=i.getMeta(r);if(l)return l;let a=i.getMeta("applyInputRules");return a&&setTimeout(()=>{let{text:u}=a;typeof u=="string"?u=u:u=wo(k.from(u),o.schema);let{from:d}=a,f=d+u.length;Lr({editor:e,from:d,to:f,text:u,rules:t,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,l){return Lr({editor:e,from:s,to:o,text:l,rules:t,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{let{$cursor:s}=i.state.selection;s&&Lr({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;let{$cursor:o}=i.state.selection;return o?Lr({editor:e,from:o.pos,to:o.pos,text:` +`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}var Ao=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...H(T(this,"addOptions",{name:this.name}))}}get storage(){return{...H(T(this,"addStorage",{name:this.name,options:this.options}))}}configure(n={}){let e=this.extend({...this.config,addOptions:()=>Ru(this.options,n)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(n={}){let e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},Se=class Iu extends Ao{constructor(){super(...arguments),this.type="mark"}static create(e={}){let t=typeof e=="function"?e():e;return new Iu(t)}static handleExit({editor:e,mark:t}){let{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){let o=i.marks();if(!!!o.find(c=>c?.type.name===t.name))return!1;let a=o.find(c=>c?.type.name===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){let t=typeof e=="function"?e():e;return super.extend(t)}},Qg=class{constructor(n){this.find=n.find,this.handler=n.handler}},Zg=(n,e,t)=>{if(ko(e))return[...n.matchAll(e)];let r=e(n,t);return r?r.map(i=>{let s=[i.text];return s.index=i.index,s.input=n,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function ey(n){let{editor:e,state:t,from:r,to:i,rule:s,pasteEvent:o,dropEvent:l}=n,{commands:a,chain:c,can:u}=new Vr({editor:e,state:t}),d=[];return t.doc.nodesBetween(r,i,(h,p)=>{var m,g,y,b,v;if((g=(m=h.type)==null?void 0:m.spec)!=null&&g.code||!(h.isText||h.isTextblock||h.isInline))return;let w=(v=(b=(y=h.content)==null?void 0:y.size)!=null?b:h.nodeSize)!=null?v:0,A=Math.max(r,p),R=Math.min(i,p+w);if(A>=R)return;let E=h.isText?h.text||"":h.textBetween(A-p,R-p,void 0,"\uFFFC");Zg(E,s.find,o).forEach(z=>{if(z.index===void 0)return;let G=A+z.index+1,Ve=G+z[0].length,Re={from:t.tr.mapping.map(G),to:t.tr.mapping.map(Ve)},ie=s.handler({state:t,range:Re,match:z,commands:a,chain:c,can:u,pasteEvent:o,dropEvent:l});d.push(ie)})}),d.every(h=>h!==null)}var zr=null,ty=n=>{var e;let t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)==null||e.setData("text/html",n),t};function ny(n){let{editor:e,rules:t}=n,r=null,i=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}let a=({state:u,from:d,to:f,rule:h,pasteEvt:p})=>{let m=u.tr,g=$r({state:u,transaction:m});if(!(!ey({editor:e,state:g,from:Math.max(d-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:l})||!m.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return t.map(u=>new N({view(d){let f=p=>{var m;r=(m=d.dom.parentElement)!=null&&m.contains(p.target)?d.dom.parentElement:null,r&&(zr=e)},h=()=>{zr&&(zr=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(d,f)=>{if(s=r===d.dom.parentElement,l=f,!s){let h=zr;h?.isEditable&&setTimeout(()=>{let p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(d,f)=>{var h;let p=(h=f.clipboardData)==null?void 0:h.getData("text/html");return o=f,i=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(d,f,h)=>{let p=d[0],m=p.getMeta("uiEvent")==="paste"&&!i,g=p.getMeta("uiEvent")==="drop"&&!s,y=p.getMeta("applyPasteRules"),b=!!y;if(!m&&!g&&!b)return;if(b){let{text:A}=y;typeof A=="string"?A=A:A=wo(k.from(A),h.schema);let{from:R}=y,E=R+A.length,L=ty(A);return a({rule:u,state:h,from:R,to:{b:E},pasteEvt:L})}let v=f.doc.content.findDiffStart(h.doc.content),w=f.doc.content.findDiffEnd(h.doc.content);if(!(!Vg(v)||!w||v===w.b))return a({rule:u,state:h,from:v,to:w,pasteEvt:o})}}))}var qr=class{constructor(n,e){this.splittableMarks=[],this.nonClearableMarks=[],this.editor=e,this.baseExtensions=n,this.extensions=Su(n),this.schema=ag(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{let t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Rn(e.name,this.schema)},r=T(e,"addCommands",t);return r?{...n,...r()}:n},{})}get plugins(){let{editor:n}=this;return Dn([...this.extensions].reverse()).flatMap(r=>{let i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:n,type:Rn(r.name,this.schema)},s=[],o=T(r,"addKeyboardShortcuts",i),l={};if(r.type==="mark"&&T(r,"exitable",i)&&(l.ArrowRight=()=>Se.handleExit({editor:n,mark:r})),o){let f=Object.fromEntries(Object.entries(o()).map(([h,p])=>[h,()=>p({editor:n})]));l={...l,...f}}let a=Zc(l);s.push(a);let c=T(r,"addInputRules",i);if(au(r,n.options.enableInputRules)&&c){let f=c();if(f&&f.length){let h=Yg({editor:n,rules:f}),p=Array.isArray(h)?h:[h];s.push(...p)}}let u=T(r,"addPasteRules",i);if(au(r,n.options.enablePasteRules)&&u){let f=u();if(f&&f.length){let h=ny({editor:n,rules:f});s.push(...h)}}let d=T(r,"addProseMirrorPlugins",i);if(d){let f=d();s.push(...f)}return s})}get attributes(){return bu(this.extensions)}get nodeViews(){let{editor:n}=this,{nodeExtensions:e}=Yt(this.extensions);return Object.fromEntries(e.filter(t=>!!T(t,"addNodeView")).map(t=>{let r=this.attributes.filter(a=>a.type===t.name),i={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:_(t.name,this.schema)},s=T(t,"addNodeView",i);if(!s)return[];let o=s();if(!o)return[];let l=(a,c,u,d,f)=>{let h=Qt(a,r);return o({node:a,view:c,getPos:u,decorations:d,innerDecorations:f,editor:n,extension:t,HTMLAttributes:h})};return[t.name,l]}))}dispatchTransaction(n){let{editor:e}=this;return Dn([...this.extensions].reverse()).reduceRight((r,i)=>{let s={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:Rn(i.name,this.schema)},o=T(i,"dispatchTransaction",s);return o?l=>{o.call(s,{transaction:l,next:r})}:r},n)}transformPastedHTML(n){let{editor:e}=this;return Dn([...this.extensions]).reduce((r,i)=>{let s={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:Rn(i.name,this.schema)},o=T(i,"transformPastedHTML",s);return o?(l,a)=>{let c=r(l,a);return o.call(s,c)}:r},n||(r=>r))}get markViews(){let{editor:n}=this,{markExtensions:e}=Yt(this.extensions);return Object.fromEntries(e.filter(t=>!!T(t,"addMarkView")).map(t=>{let r=this.attributes.filter(l=>l.type===t.name),i={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:Qe(t.name,this.schema)},s=T(t,"addMarkView",i);if(!s)return[];let o=(l,a,c)=>{let u=Qt(l,r);return s()({mark:l,view:a,inline:c,editor:n,extension:t,HTMLAttributes:u,updateAttributes:d=>{Gg(l,n,d)}})};return[t.name,o]}))}destroy(){this.extensions.forEach(n=>{let e=n;for(;e.parent;){let t=e.parent;t.child===e&&(t.child=null),e=t}}),this.extensions=[],this.baseExtensions=[],this.schema=null,this.editor=null}setupExtensions(){let n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{var t,r;let i={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Rn(e.name,this.schema)};e.type==="mark"&&(((t=H(T(e,"keepOnSplit",i)))==null||t)&&this.splittableMarks.push(e.name),(r=H(T(e,"clearable",i)))==null||r||this.nonClearableMarks.push(e.name));let s=T(e,"onBeforeCreate",i),o=T(e,"onCreate",i),l=T(e,"onUpdate",i),a=T(e,"onSelectionUpdate",i),c=T(e,"onTransaction",i),u=T(e,"onFocus",i),d=T(e,"onBlur",i),f=T(e,"onDestroy",i);s&&this.editor.on("beforeCreate",s),o&&this.editor.on("create",o),l&&this.editor.on("update",l),a&&this.editor.on("selectionUpdate",a),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};qr.resolve=Su;qr.sort=Dn;qr.flatten=So;var ry={};yo(ry,{ClipboardTextSerializer:()=>Pu,Commands:()=>Lu,Delete:()=>zu,Drop:()=>Bu,Editable:()=>Fu,FocusEvents:()=>$u,Keymap:()=>Vu,Paste:()=>_u,Tabindex:()=>Wu,TextDirection:()=>Ju,focusEventsPluginKey:()=>Hu});var B=class Du extends Ao{constructor(){super(...arguments),this.type="extension"}static create(e={}){let t=typeof e=="function"?e():e;return new Du(t)}configure(e){return super.configure(e)}extend(e){let t=typeof e=="function"?e():e;return super.extend(t)}},Pu=B.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new N({key:new I("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:i}=e,s=vu(t),{blockSeparator:o}=this.options,l={...o!==void 0?{blockSeparator:o}:{},textSerializers:s};return[...i.ranges].sort((c,u)=>c.$from.pos-u.$from.pos).map(({$from:c,$to:u})=>wu(r,{from:c.pos,to:u.pos},l)).join(o??` + +`)}}})]}}),Lu=B.create({name:"commands",addCommands(){return{...du}}}),zu=B.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,r,i;let s=()=>{var o,l,a,c;if((c=(a=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,n))!=null?c:n.getMeta("y-sync$"))return;let u=bo(n.before,[n,...e]);Mo(u).forEach(h=>{u.mapping.mapResult(h.oldRange.from).deletedAfter&&u.mapping.mapResult(h.oldRange.to).deletedBefore&&u.before.nodesBetween(h.oldRange.from,h.oldRange.to,(p,m)=>{let g=m+p.nodeSize-2,y=h.oldRange.from<=m&&g<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:m,to:g,newFrom:u.mapping.map(m),newTo:u.mapping.map(g),deletedRange:h.oldRange,newRange:h.newRange,partial:!y,editor:this.editor,transaction:n,combinedTransform:u})})});let f=u.mapping;u.steps.forEach((h,p)=>{var m,g;if(h instanceof Je){let y=f.slice(p).map(h.from,-1),b=f.slice(p).map(h.to),v=f.invert().map(y,-1),w=f.invert().map(b),A=y>0?(m=u.doc.nodeAt(y-1))==null?void 0:m.marks.some(E=>E.eq(h.mark)):!1,R=(g=u.doc.nodeAt(b))==null?void 0:g.marks.some(E=>E.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:v,to:w},newRange:{from:y,to:b},partial:!!(R||A),editor:this.editor,transaction:n,combinedTransform:u})}})};(i=(r=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:r.async)==null||i?setTimeout(s,0):s()}}),Bu=B.create({name:"drop",addProseMirrorPlugins(){return[new N({key:new I("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),Fu=B.create({name:"editable",addProseMirrorPlugins(){return[new N({key:new I("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Hu=new I("focusEvents"),$u=B.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:n}=this;return[new N({key:Hu,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;let r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;let r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Vu=B.create({name:"keymap",addKeyboardShortcuts(){let n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{let{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:f,parent:h}=d,p=d.parent.isTextblock&&f>0?l.doc.resolve(f-1):d,m=p.parent.type.spec.isolating,g=d.pos-d.parentOffset,y=m&&p.parent.childCount===1?g===d.pos:O.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!y||y&&d.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Hr()||gu()?s:i},addProseMirrorPlugins(){return[new N({key:new I("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(m=>m.getMeta("composition")))return;let r=n.some(m=>m.docChanged)&&!e.doc.eq(t.doc),i=n.some(m=>m.getMeta("preventClearDocument"));if(!r||i)return;let{empty:s,from:o,to:l}=e.selection,a=O.atStart(e.doc).from,c=O.atEnd(e.doc).to;if(s||!(o===a&&l===c)||!Zt(t.doc))return;let f=t.tr,h=$r({state:t,transaction:f}),{commands:p}=new Vr({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),_u=B.create({name:"paste",addProseMirrorPlugins(){return[new N({key:new I("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),Wu=B.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new N({key:new I("tabindex"),props:{attributes:()=>{var n;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(n=this.options.value)!=null?n:"0"}}}})]}}),Ju=B.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:n}=Yt(this.extensions);return[{types:n.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let t=e.getAttribute("dir");return t&&(t==="ltr"||t==="rtl"||t==="auto")?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new N({key:new I("textDirection"),props:{attributes:()=>{let n=this.options.direction;return n?{dir:n}:{}}}})]}}),iy=class In{constructor(e,t,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=i}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;let e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new In(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new In(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new In(e,this.editor)}get children(){let e=[];return this.node.content.forEach((t,r)=>{let i=t.isBlock&&!t.isTextblock,s=t.isAtom&&!t.isText,o=t.isInline,l=this.pos+r+(s?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;let a=this.resolvedPos.doc.resolve(l);if(!i&&!o&&a.depth<=this.depth)return;let c=new In(a,this.editor,i,i||o?t:null);i&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(t).length>0){let s=i.node.attrs,o=Object.keys(t);for(let l=0;l{r&&i.length>0||(o.node.type.name===e&&s.every(a=>t[a]===o.node.attrs[a])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,t,r))))}),i}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},sy=`.ProseMirror { + position: relative; +} + +.ProseMirror { + word-wrap: break-word; + white-space: pre-wrap; + white-space: break-spaces; + -webkit-font-variant-ligatures: none; + font-variant-ligatures: none; + font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */ +} + +.ProseMirror [contenteditable="false"] { + white-space: normal; +} + +.ProseMirror [contenteditable="false"] [contenteditable="true"] { + white-space: pre-wrap; +} + +.ProseMirror pre { + white-space: pre-wrap; +} + +img.ProseMirror-separator { + display: inline !important; + border: none !important; + margin: 0 !important; + width: 0 !important; + height: 0 !important; +} + +.ProseMirror-gapcursor { + display: none; + pointer-events: none; + position: absolute; + margin: 0; +} + +.ProseMirror-gapcursor:after { + content: ""; + display: block; + position: absolute; + top: -2px; + width: 20px; + border-top: 1px solid black; + animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; +} + +@keyframes ProseMirror-cursor-blink { + to { + visibility: hidden; + } +} + +.ProseMirror-hideselection *::selection { + background: transparent; +} + +.ProseMirror-hideselection *::-moz-selection { + background: transparent; +} + +.ProseMirror-hideselection * { + caret-color: transparent; +} + +.ProseMirror-focused .ProseMirror-gapcursor { + display: block; +}`,ju=class extends $g{constructor(n={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:gg,createMappablePosition:yg},this.setOptions(n),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:i,moved:s})=>this.options.onDrop(r,i,s)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);let e=this.createDoc(),t=pu(e,this.options.autofocus);this.editorState=kr.create({doc:e,schema:this.schema,selection:t||void 0}),this.options.element&&this.mount(this.options.element)}mount(n){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(n),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){let n=this.editorView.dom;n?.editor&&delete n.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(n){console.warn("Failed to remove CSS element:",n)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=Co(sy,this.options.injectNonce))}setOptions(n={}){this.options={...this.options,...n},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(n,e=!0){this.setOptions({editable:n}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:n=>{this.editorState=n},dispatch:n=>{this.dispatchTransaction(n)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(n,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in n)return Reflect.get(n,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(n,e){let t=xu(e)?e(n,[...this.state.plugins]):[...this.state.plugins,n],r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}unregisterPlugin(n){if(this.isDestroyed)return;let e=this.state.plugins,t=e;if([].concat(n).forEach(i=>{let s=typeof i=="string"?`${i}$`:i.key;t=t.filter(o=>!o.key.startsWith(s))}),e.length===t.length)return;let r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}createExtensionManager(){var n,e,t,r;let s=[...this.options.enableCoreExtensions?[Fu,Pu.configure({blockSeparator:(e=(n=this.options.coreExtensionOptions)==null?void 0:n.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Lu,$u,Vu,Wu.configure({value:(r=(t=this.options.coreExtensionOptions)==null?void 0:t.tabindex)==null?void 0:r.value}),Bu,_u,zu,Ju.configure({direction:this.options.textDirection})].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o?.type));this.extensionManager=new qr(s,this)}createCommandManager(){this.commandManager=new Vr({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let n;try{n=mo(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(t=>t.name!=="collaboration"),this.createExtensionManager()}}),n=mo(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return n}createView(n){let{editorProps:e,enableExtensionDispatchTransaction:t}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),i=t?this.extensionManager.dispatchTransaction(r):r,s=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(s);this.editorView=new Tn(n,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:i,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();let a=this.view.dom;a.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(n){this.isCapturingTransaction=!0,n(),this.isCapturingTransaction=!1;let e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(n){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=n;return}n.steps.forEach(c=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(c)});return}let{state:e,transactions:t}=this.state.applyTransaction(n),r=!this.state.selection.eq(e.selection),i=t.includes(n),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:n,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:n,appendedTransactions:t.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:n});let o=t.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=o?.getMeta("focus"),a=o?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),a&&this.emit("blur",{editor:this,event:a.event,transaction:o}),!(n.getMeta("preventUpdate")||!t.some(c=>c.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:n,appendedTransactions:t.slice(1)})}getAttributes(n){return vo(this.state,n)}isActive(n,e){let t=typeof n=="string"?n:null,r=typeof n=="string"?e:n;return mg(this.state,t,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return wo(this.state.doc.content,this.schema)}getText(n){let{blockSeparator:e=` + +`,textSerializers:t={}}=n||{};return ug(this.state.doc,{blockSeparator:e,textSerializers:{...vu(this.schema),...t}})}get isEmpty(){return Zt(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var n,e;return(e=(n=this.editorView)==null?void 0:n.isDestroyed)!=null?e:!0}$node(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelector(n,e))||null}$nodes(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelectorAll(n,e))||null}$pos(n){let e=this.state.doc.resolve(n),t=n>0&&e.nodeAfter&&!e.nodeAfter.isText?e.nodeAfter:null;return new iy(e,this,!1,t)}get $doc(){return this.$pos(0)}};function Le(n){return new Ur({find:n.find,handler:({state:e,range:t,match:r})=>{let i=H(n.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:s}=e,o=r[r.length-1],l=r[0];if(o){let a=l.search(/\S/),c=t.from+l.indexOf(o),u=c+o.length;if(Jr(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===n.type&&m!==h.mark.type)).filter(h=>h.to>c).length)return null;ut.from&&s.delete(t.from+a,c);let f=t.from+a+o.length;s.addMark(t.from+a,f,n.type.create(i||{})),s.removeStoredMark(n.type)}},undoable:n.undoable})}function Gr(n){return new Ur({find:n.find,handler:({state:e,range:t,match:r})=>{let i=H(n.getAttributes,void 0,r)||{},{tr:s}=e,o=t.from,l=t.to,a=n.type.create(i);if(r[1]){let c=r[0].lastIndexOf(r[1]),u=o+c;u>l?u=l:l=u+r[1].length;let d=r[0][r[0].length-1];s.insertText(d,o+r[0].length-1),s.replaceWith(u,l,a)}else if(r[0]){let c=n.type.isInline?o:o-1;s.insert(c,n.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:n.undoable})}function zn(n){return new Ur({find:n.find,handler:({state:e,range:t,match:r})=>{let i=e.doc.resolve(t.from),s=H(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)},undoable:n.undoable})}function ze(n){return new Ur({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{let s=H(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),a=o.doc.resolve(t.from).blockRange(),c=a&&Wt(a,n.type,s);if(!c)return null;if(o.wrap(a,c),n.keepMarks&&n.editor){let{selection:d,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,p=f||d.$to.parentOffset&&d.$from.marks();if(p){let m=p.filter(g=>h.includes(g.type.name));o.ensureMarks(m)}}if(n.keepAttributes){let d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(d,s).run()}let u=o.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&we(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&o.join(t.from-1)},undoable:n.undoable})}var oy=n=>"touches"in n,Ku=class{constructor(n){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.clientX-this.startX,c=l.clientY-this.startY;this.handleResize(a,c)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.touches[0];if(!a)return;let c=a.clientX-this.startX,u=a.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;let l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,t,r,i,s,o;this.node=n.node,this.editor=n.editor,this.element=n.element,this.element.draggable=!1,this.contentElement=n.contentElement,this.getPos=n.getPos,this.onResize=n.onResize,this.onCommit=n.onCommit,this.onUpdate=n.onUpdate,(e=n.options)!=null&&e.min&&(this.minSize={...this.minSize,...n.options.min}),(t=n.options)!=null&&t.max&&(this.maxSize=n.options.max),(r=n?.options)!=null&&r.directions&&(this.directions=n.options.directions),(i=n.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=n.options.preserveAspectRatio),(s=n.options)!=null&&s.className&&(this.classNames={container:n.options.className.container||"",wrapper:n.options.className.wrapper||"",handle:n.options.className.handle||"",resizing:n.options.className.resizing||""}),(o=n.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=n.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var n;return(n=this.contentElement)!=null?n:null}handleEditorUpdate(){let n=this.editor.isEditable;n!==this.lastEditableState&&(this.lastEditableState=n,n?n&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(n,e,t){return n.type!==this.node.type?!1:(this.node=n,this.onUpdate?this.onUpdate(n,e,t):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){let n=document.createElement("div");return n.dataset.resizeContainer="",n.dataset.node=this.node.type.name,n.style.display=this.node.type.isInline?"inline-flex":"flex",this.classNames.container&&(n.className=this.classNames.container),n.appendChild(this.wrapper),n}createWrapper(){let n=document.createElement("div");return n.style.position="relative",n.style.display="block",n.dataset.resizeWrapper="",this.classNames.wrapper&&(n.className=this.classNames.wrapper),n.appendChild(this.element),n}createHandle(n){let e=document.createElement("div");return e.dataset.resizeHandle=n,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(n,e){let t=e.includes("top"),r=e.includes("bottom"),i=e.includes("left"),s=e.includes("right");t&&(n.style.top="0"),r&&(n.style.bottom="0"),i&&(n.style.left="0"),s&&(n.style.right="0"),(e==="top"||e==="bottom")&&(n.style.left="0",n.style.right="0"),(e==="left"||e==="right")&&(n.style.top="0",n.style.bottom="0")}attachHandles(){this.directions.forEach(n=>{let e;this.createCustomHandle?e=this.createCustomHandle(n):e=this.createHandle(n),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${n}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(n)),this.createCustomHandle||this.positionHandle(e,n),e.addEventListener("mousedown",t=>this.handleResizeStart(t,n)),e.addEventListener("touchstart",t=>this.handleResizeStart(t,n)),this.handleMap.set(n,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(n=>n.remove()),this.handleMap.clear()}applyInitialSize(){let n=this.node.attrs.width,e=this.node.attrs.height;n?(this.element.style.width=`${n}px`,this.initialWidth=n):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(n,e){n.preventDefault(),n.stopPropagation(),this.isResizing=!0,this.activeHandle=e,oy(n)?(this.startX=n.touches[0].clientX,this.startY=n.touches[0].clientY):(this.startX=n.clientX,this.startY=n.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight);let t=this.getPos();this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(n,e){if(!this.activeHandle)return;let t=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,n,e),s=this.applyConstraints(r,i,t);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(n,e,t){let r=this.startWidth,i=this.startHeight,s=n.includes("right"),o=n.includes("left"),l=n.includes("bottom"),a=n.includes("top");return s?r=this.startWidth+e:o&&(r=this.startWidth-e),l?i=this.startHeight+t:a&&(i=this.startHeight-t),(n==="right"||n==="left")&&(r=this.startWidth+(s?e:-e)),(n==="top"||n==="bottom")&&(i=this.startHeight+(l?t:-t)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,n):{width:r,height:i}}applyConstraints(n,e,t){var r,i,s,o;if(!t){let c=Math.max(this.minSize.width,n),u=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(c=Math.min(this.maxSize.width,c)),(i=this.maxSize)!=null&&i.height&&(u=Math.min(this.maxSize.height,u)),{width:c,height:u}}let l=n,a=e;return lthis.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(n,e,t){let r=t==="left"||t==="right",i=t==="top"||t==="bottom";return r?{width:n,height:n/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:n,height:n/this.aspectRatio}}};var $=class Uu extends Ao{constructor(){super(...arguments),this.type="node"}static create(e={}){let t=typeof e=="function"?e():e;return new Uu(t)}configure(e){return super.configure(e)}extend(e){let t=typeof e=="function"?e():e;return super.extend(t)}};function Ee(n){return new Qg({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{let s=H(n.getAttributes,void 0,r,i);if(s===!1||s===null)return null;let{tr:o}=e,l=r[r.length-1],a=r[0],c=t.to;if(l){let u=a.search(/\S/),d=t.from+a.indexOf(l),f=d+l.length;if(Jr(t.from,t.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===n.type&&y!==m.mark.type)).filter(m=>m.to>d).length)return null;ft.from&&o.delete(t.from+u,d),c=t.from+u+l.length,o.addMark(t.from+u,c,n.type.create(s||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(n.type)}}})}var en=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);let{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,r,t]};function id(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)t++;return t}if(i.content.size||s.content.size){let o=id(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function sd(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=0,u=Math.min(o.text.length,l.text.length);for(;ce&&r(a,i+l,s||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);se)for(let s=0,o=0;oe&&((ot)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new me(r,i)}cutByIndex(e,t){return e==t?me.empty:e==0&&t==this.content.length?this:new me(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new me(i,s)}addToStart(e){return new me([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new me(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),s=r+i.nodeSize;if(s>=e)return s==e?Xr(t+1,s):Xr(t,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return me.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return me.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return me.empty;let t,r=0;for(let i=0;ithis.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;tr.type.rank-i.type.rank),t}};At.none=[];var ri=class extends Error{},W=class tn{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=ld(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new tn(r,this.openStart,this.openEnd)}removeBetween(e,t){return new tn(od(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return tn.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new tn(ce.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new tn(e,r,i)}};W.empty=new W(ce.empty,0,0);function od(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(od(s.content,e-i-1,t-i-1)))}function ld(n,e,t,r,i,s){let{index:o,offset:l}=n.findIndex(e),a=n.maybeChild(o);if(l==e||a.isText)return s&&r<=0&&i<=0&&!s.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=ld(a.content,e-l-1,t,o==0?r-1:0,o==n.childCount-1?i-1:0,a);return c&&n.replaceChild(o,a.copy(c))}function ly(n,e,t){if(t.openStart>n.depth)throw new ri("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new ri("Inconsistent open depths");return ad(n,e,t,0)}function ad(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Wn(n,e,t,r){let i=(e||n).node(t),s=0,o=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(Nt(n.nodeAfter,r),s++));for(let l=s;li&&Do(n,e,i+1),o=r.depth>i&&Do(t,r,i+1),l=[];return Wn(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(cd(s,o),Nt(Ot(s,ud(n,e,t,r,i+1)),l)):(s&&Nt(Ot(s,ii(n,e,i+1)),l),Wn(e,t,i,l),o&&Nt(Ot(o,ii(t,r,i+1)),l)),Wn(r,null,i,l),new ce(l)}function ii(n,e,t){let r=[];if(Wn(null,n,t,r),n.depth>t){let i=Do(n,e,t+1);Nt(Ot(i,ii(n,e,t+1)),r)}return Wn(e,null,t,r),new ce(r)}function ay(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(ce.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}var qu=class Po{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new dy(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(r.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new Po(t,r,s)}static resolveCached(e,t){let r=Gu.get(e);if(r)for(let s=0;se&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),py(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=ce.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;at.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=ce.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};hy.prototype.text=void 0;function py(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}var zo=class dd{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new my(e,t);if(r.next==null)return dd.empty;let i=fd(r);r.next&&r.err("Unexpected trailing text");let s=wy(Sy(i));return vy(s,r),s}matchType(e){for(let t=0;tc.createAndFill()));for(let c=0;c=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(r.next[o].next);return s}).join(` +`)}};zo.empty=new zo(!0);var my=class{constructor(n,e){this.string=n,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=n.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(n){return this.next==n&&(this.pos++||!0)}err(n){throw new SyntaxError(n+" (in content expression '"+this.string+"')")}};function fd(n){let e=[];do e.push(gy(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function gy(n){let e=[];do e.push(yy(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function yy(n){let e=by(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=ky(n,e);else break;return e}function Xu(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function ky(n,e){let t=Xu(n),r=t;return n.eat(",")&&(n.next!="}"?r=Xu(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function xy(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let o=t[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function by(n){if(n.eat("(")){let e=fd(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=xy(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Sy(n){let e=[[]];return i(s(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=s(o.exprs[a],l);if(a==o.exprs.length-1)return c;i(c,l=t())}else if(o.type=="star"){let a=t();return r(l,a),i(s(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();return i(s(o.expr,l),a),i(s(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c{n[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new zo(r.indexOf(n.length-1)>-1);for(let o=0;o0}get deletedBefore(){return(this.delInfo&(gd|Qr))>0}get deletedAfter(){return(this.delInfo&(yd|Qr))>0}get deletedAcross(){return(this.delInfo&Qr)>0}},Rt=class nn{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&nn.empty)return nn.empty}recover(e){let t=0,r=Qu(e);if(!this.inverted)for(let i=0;ie)break;let c=this.ranges[l+s],u=this.ranges[l+o],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,h=a+i+(f<0?0:u);if(r)return h;let p=e==(t<0?a:d)?null:My(l/3,e-a),m=e==a?yd:e==d?gd:Qr;return(t<0?e!=a:e!=d)&&(m|=kd),new Zu(h,m,p)}i+=u-c}return r?e+i:new Zu(e+i,0,null)}touches(e,t){let r=0,i=Qu(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;le)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return ge.fromReplace(e,this.from,this.to,s)}invert(){return new bd(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Fn(t.pos,r.pos,this.mark)}merge(e){return e instanceof Fn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Fn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Fn(t.from,t.to,e.markFromJSON(t.mark))}};ue.jsonID("addMark",xd);var bd=class Hn extends ue{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new W($o(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return ge.fromReplace(e,this.from,this.to,r)}invert(){return new xd(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Hn(t.pos,r.pos,this.mark)}merge(e){return e instanceof Hn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Hn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Hn(t.from,t.to,e.markFromJSON(t.mark))}};ue.jsonID("removeMark",bd);var Sd=class $n extends ue{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ge.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ge.fromReplace(e,this.pos,this.pos+1,new W(ce.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new Zr(t.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Zr(t.from,t.to,t.gapFrom,t.gapTo,W.fromJSON(e,t.slice),t.insert,!!t.structure)}};ue.jsonID("replaceAround",vd);function Fo(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}var Ty=class ei extends ue{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return ge.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return ge.fromReplace(e,this.pos,this.pos+1,new W(ce.from(i),0,t.isLeaf?0:1))}getMap(){return Rt.empty}invert(e){return new ei(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ei(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new ei(t.pos,t.attr,t.value)}};ue.jsonID("attr",Ty);var Ey=class Ho extends ue{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return ge.ok(r)}getMap(){return Rt.empty}invert(e){return new Ho(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ho(t.attr,t.value)}};ue.jsonID("docAttr",Ey);var jn=class extends Error{};jn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};jn.prototype=Object.create(Error.prototype);jn.prototype.constructor=jn;jn.prototype.name="TransformError";var Ro=Object.create(null),Z=class{constructor(n,e,t){this.$anchor=n,this.$head=e,this.ranges=t||[new Ay(n.min(e),n.max(e))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let n=this.ranges;for(let e=0;e=0;i--){let s=e<0?rn(n.node(0),n.node(i),n.before(i+1),n.index(i),e,t):rn(n.node(0),n.node(i),n.after(i+1),n.index(i)+1,e,t);if(s)return s}return null}static near(n,e=1){return this.findFrom(n,e)||this.findFrom(n,-e)||new Jn(n.node(0))}static atStart(n){return rn(n,n,0,0,1)||new Jn(n)}static atEnd(n){return rn(n,n,n.content.size,n.childCount,-1)||new Jn(n)}static fromJSON(n,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let t=Ro[e.type];if(!t)throw new RangeError(`No selection type ${e.type} defined`);return t.fromJSON(n,e)}static jsonID(n,e){if(n in Ro)throw new RangeError("Duplicate use of selection JSON ID "+n);return Ro[n]=e,e.prototype.jsonID=n,e}getBookmark(){return sn.between(this.$anchor,this.$head).getBookmark()}};Z.prototype.visible=!0;var Ay=class{constructor(n,e){this.$from=n,this.$to=e}},ed=!1;function td(n){!ed&&!n.parent.inlineContent&&(ed=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var sn=class Vn extends Z{constructor(e,t=e){td(e),td(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return Z.near(r);let i=e.resolve(t.map(this.anchor));return new Vn(i.parent.inlineContent?i:r,r)}replace(e,t=W.empty){if(super.replace(e,t),t==W.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Vn&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Md(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Vn(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=Z.findFrom(t,r,!0)||Z.findFrom(t,-r,!0);if(s)t=s.$head;else return Z.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(Z.findFrom(e,-r,!0)||Z.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?o=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&on.isSelectable(l))return on.create(n,t-(i<0?l.nodeSize:0))}else{let a=rn(n,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function nd(n,e,t){let r=n.steps.length-1;if(r{o==null&&(o=u)}),n.setSelection(Z.near(n.doc.resolve(o),t))}function rd(n,e){return!e||!n?n:n.bind(e)}var Yr=class{constructor(n,e,t){this.name=n,this.init=rd(e.init,t),this.apply=rd(e.apply,t)}},Ob=[new Yr("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Yr("selection",{init(n,e){return n.selection||Z.atStart(e.doc)},apply(n){return n.selection}}),new Yr("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Yr("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],Ry=(n,e)=>{var t;let{state:r,view:i}=n,{selection:s}=r;if(!s.empty)return!1;let{$from:o}=s;if(o.parentOffset!==0)return!1;let l=o.depth-1,a=o.node(l),c=o.index(l);if(c===0)return!1;if(a.type===e)return n.commands.lift(e.name);let u=a.child(c-1);if(u.type!==e||!((t=u.lastChild)!=null&&t.isTextblock))return!1;let d=o.before(),h=d-1-1,{tr:p}=r;return p.delete(d,o.after()).insert(h,o.parent.content),p.setSelection(sn.create(p.doc,h)),i.dispatch(p.scrollIntoView()),!0},Iy=/^\s*>\s$/,Ed=$.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return en("blockquote",{...D(this.options.HTMLAttributes,n),children:en("slot",{})})},parseMarkdown:(n,e)=>{var t;let r=(t=e.parseBlockChildren)!=null?t:e.parseChildren;return e.createNode("blockquote",void 0,r(n.tokens||[]))},renderMarkdown:(n,e)=>{if(!n.content)return"";let t=">",r=[];return n.content.forEach((i,s)=>{var o,l;let u=((l=(o=e.renderChild)==null?void 0:o.call(e,i,s))!=null?l:e.renderChildren([i])).split(` +`).map(d=>d.trim()===""?t:`${t} ${d}`);r.push(u.join(` +`))}),r.join(` +${t} +`)},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>Ry(this.editor,this.type)}},addInputRules(){return[ze({find:Iy,type:this.type})]}});var Dy=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Py=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Ly=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,zy=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Ad=Se.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return en("strong",{...D(this.options.HTMLAttributes,n),children:en("slot",{})})},markdownTokenName:"strong",parseMarkdown:(n,e)=>e.applyMark("bold",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"",close:""}},renderMarkdown:(n,e)=>`**${e.renderChildren(n)}**`,addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Le({find:Dy,type:this.type}),Le({find:Ly,type:this.type})]},addPasteRules(){return[Ee({find:Py,type:this.type}),Ee({find:zy,type:this.type})]}});var By=n=>{let e=/`([^`]+)`(?!`)$/.exec(n);return!e||e.index>0&&n[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},Fy=n=>{let e=/`([^`]+)`(?!`)/g,t=[],r;for(;(r=e.exec(n))!==null;)r.index>0&&n[r.index-1]==="`"||t.push({index:r.index,text:r[0],replaceWith:r[1]});return t},Nd=Se.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",D(this.options.HTMLAttributes,n),0]},markdownTokenName:"codespan",parseMarkdown:(n,e)=>e.applyMark("code",[{type:"text",text:n.text||""}]),renderMarkdown:(n,e)=>n.content?`\`${e.renderChildren(n.content)}\``:"",addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Le({find:By,type:this.type})]},addPasteRules(){return[Ee({find:Fy,type:this.type})]}});var _o=4,Hy=/^```([a-z]+)?[\s\n]$/,$y=/^~~~([a-z]+)?[\s\n]$/,Od=$.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:_o,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;let{languageClassPrefix:t}=this.options;if(!t)return null;let s=[...((e=n.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",D(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(n,e)=>{var t,r;return((t=n.raw)==null?void 0:t.startsWith("```"))===!1&&((r=n.raw)==null?void 0:r.startsWith("~~~"))===!1&&n.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:n.lang||null},n.text?[e.createTextNode(n.text)]:[])},renderMarkdown:(n,e)=>{var t;let r="",i=((t=n.attrs)==null?void 0:t.language)||"";return n.content?r=[`\`\`\`${i}`,e.renderChildren(n.content),"```"].join(` +`):r=`\`\`\`${i} + +\`\`\``,r},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:n})=>{var e;if(!this.options.enableTabIndentation)return!1;let t=(e=this.options.tabSize)!=null?e:_o,{state:r}=n,{selection:i}=r,{$from:s,empty:o}=i;if(s.parent.type!==this.type)return!1;let l=" ".repeat(t);return o?n.commands.insertContent(l):n.commands.command(({tr:a})=>{let{from:c,to:u}=i,h=r.doc.textBetween(c,u,` +`,` +`).split(` +`).map(p=>l+p).join(` +`);return a.replaceWith(c,u,r.schema.text(h)),!0})},"Shift-Tab":({editor:n})=>{var e;if(!this.options.enableTabIndentation)return!1;let t=(e=this.options.tabSize)!=null?e:_o,{state:r}=n,{selection:i}=r,{$from:s,empty:o}=i;return s.parent.type!==this.type?!1:o?n.commands.command(({tr:l})=>{var a;let{pos:c}=s,u=s.start(),d=s.end(),h=r.doc.textBetween(u,d,` +`,` +`).split(` +`),p=0,m=0,g=c-u;for(let R=0;R=g){p=R;break}m+=h[R].length+1}let b=((a=h[p].match(/^ */))==null?void 0:a[0])||"",v=Math.min(b.length,t);if(v===0)return!0;let w=u;for(let R=0;R{let{from:a,to:c}=i,f=r.doc.textBetween(a,c,` +`,` +`).split(` +`).map(h=>{var p;let m=((p=h.match(/^ */))==null?void 0:p[0])||"",g=Math.min(m.length,t);return h.slice(g)}).join(` +`);return l.replaceWith(a,c,r.schema.text(f)),!0})},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:e}=n,{selection:t}=e,{$from:r,empty:i}=t;if(!i||r.parent.type!==this.type)return!1;let s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` + +`);return!s||!o?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;let{state:e}=n,{selection:t,doc:r}=e,{$from:i,empty:s}=t;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;let l=i.after();return l===void 0?!1:r.nodeAt(l)?n.commands.command(({tr:c})=>(c.setSelection(O.near(r.resolve(l))),!0)):n.commands.exitCode()}}},addInputRules(){return[zn({find:Hy,type:this.type,getAttributes:n=>({language:n[1]})}),zn({find:$y,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new N({key:new I("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;let t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=i?.mode;if(!t||!s)return!1;let{tr:o,schema:l}=n.state,a=l.text(t.replace(/\r\n?/g,` +`));return o.replaceSelectionWith(this.type.create({language:s},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(C.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}});var Rd=$.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` + +`):""});var Id=$.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",D(this.options.HTMLAttributes,n)]},renderText(){return` +`},renderMarkdown:()=>` +`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{let{selection:i,storedMarks:s}=t;if(i.$from.parent.type.spec.isolating)return!1;let{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&o){let d=a.filter(f=>l.includes(f.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var Dd=$.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,D(this.options.HTMLAttributes,e),0]},parseMarkdown:(n,e)=>e.createNode("heading",{level:n.depth||1},e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>{var t;let r=(t=n.attrs)!=null&&t.level?parseInt(n.attrs.level,10):1,i="#".repeat(r);return n.content?`${i} ${e.renderChildren(n.content)}`:""},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>zn({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var Pd=$.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",D(this.options.HTMLAttributes,n)]},markdownTokenName:"hr",parseMarkdown:(n,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!Ou(e,e.schema.nodes[this.name]))return!1;let{selection:t}=e,{$to:r}=t,i=n();return jr(t)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:s,tr:o,dispatch:l})=>{if(l){let{$to:a}=o.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?o.setSelection(C.create(o.doc,a.pos+1)):a.nodeAfter.isBlock?o.setSelection(M.create(o.doc,a.pos)):o.setSelection(C.create(o.doc,a.pos));else{let u=s.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,d=u?.create();d&&(o.insert(c,d),o.setSelection(C.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Gr({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var Vy=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,_y=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Wy=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Jy=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Ld=Se.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",D(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,e)=>e.applyMark("italic",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"",close:""}},renderMarkdown:(n,e)=>`*${e.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Le({find:Vy,type:this.type}),Le({find:Wy,type:this.type})]},addPasteRules(){return[Ee({find:_y,type:this.type}),Ee({find:Jy,type:this.type})]}});var jy="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Ky="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",Go="numeric",Xo="ascii",Yo="alpha",qn="asciinumeric",Un="alphanumeric",Qo="domain",Vd="emoji",Uy="scheme",qy="slashscheme",Wo="whitespace";function Gy(n,e){return n in e||(e[n]=[]),e[n]}function It(n,e,t){e[Go]&&(e[qn]=!0,e[Un]=!0),e[Xo]&&(e[qn]=!0,e[Yo]=!0),e[qn]&&(e[Un]=!0),e[Yo]&&(e[Un]=!0),e[Un]&&(e[Qo]=!0),e[Vd]&&(e[Qo]=!0);for(let r in e){let i=Gy(r,t);i.indexOf(n)<0&&i.push(n)}}function Xy(n,e){let t={};for(let r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function xe(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}xe.groups={};xe.prototype={accepts(){return!!this.t},go(n){let e=this,t=e.j[n];if(t)return t;for(let r=0;rn.ta(e,t,r,i),J=(n,e,t,r,i)=>n.tr(e,t,r,i),zd=(n,e,t,r,i)=>n.ts(e,t,r,i),x=(n,e,t,r,i)=>n.tt(e,t,r,i),tt="WORD",Zo="UWORD",_d="ASCIINUMERICAL",Wd="ALPHANUMERICAL",er="LOCALHOST",el="TLD",tl="UTLD",ai="SCHEME",ln="SLASH_SCHEME",rl="NUM",nl="WS",il="NL",Gn="OPENBRACE",Xn="CLOSEBRACE",ci="OPENBRACKET",ui="CLOSEBRACKET",di="OPENPAREN",fi="CLOSEPAREN",hi="OPENANGLEBRACKET",pi="CLOSEANGLEBRACKET",mi="FULLWIDTHLEFTPAREN",gi="FULLWIDTHRIGHTPAREN",yi="LEFTCORNERBRACKET",ki="RIGHTCORNERBRACKET",xi="LEFTWHITECORNERBRACKET",bi="RIGHTWHITECORNERBRACKET",Si="FULLWIDTHLESSTHAN",wi="FULLWIDTHGREATERTHAN",vi="AMPERSAND",Mi="APOSTROPHE",Ci="ASTERISK",dt="AT",Ti="BACKSLASH",Ei="BACKTICK",Ai="CARET",Dt="COLON",sl="COMMA",Ni="DOLLAR",Be="DOT",Oi="EQUALS",ol="EXCLAMATION",Ne="HYPHEN",Yn="PERCENT",Ri="PIPE",Ii="PLUS",Di="POUND",Qn="QUERY",ll="QUOTE",Jd="FULLWIDTHMIDDLEDOT",al="SEMI",Fe="SLASH",Zn="TILDE",Pi="UNDERSCORE",jd="EMOJI",Li="SYM",Kd=Object.freeze({__proto__:null,ALPHANUMERICAL:Wd,AMPERSAND:vi,APOSTROPHE:Mi,ASCIINUMERICAL:_d,ASTERISK:Ci,AT:dt,BACKSLASH:Ti,BACKTICK:Ei,CARET:Ai,CLOSEANGLEBRACKET:pi,CLOSEBRACE:Xn,CLOSEBRACKET:ui,CLOSEPAREN:fi,COLON:Dt,COMMA:sl,DOLLAR:Ni,DOT:Be,EMOJI:jd,EQUALS:Oi,EXCLAMATION:ol,FULLWIDTHGREATERTHAN:wi,FULLWIDTHLEFTPAREN:mi,FULLWIDTHLESSTHAN:Si,FULLWIDTHMIDDLEDOT:Jd,FULLWIDTHRIGHTPAREN:gi,HYPHEN:Ne,LEFTCORNERBRACKET:yi,LEFTWHITECORNERBRACKET:xi,LOCALHOST:er,NL:il,NUM:rl,OPENANGLEBRACKET:hi,OPENBRACE:Gn,OPENBRACKET:ci,OPENPAREN:di,PERCENT:Yn,PIPE:Ri,PLUS:Ii,POUND:Di,QUERY:Qn,QUOTE:ll,RIGHTCORNERBRACKET:ki,RIGHTWHITECORNERBRACKET:bi,SCHEME:ai,SEMI:al,SLASH:Fe,SLASH_SCHEME:ln,SYM:Li,TILDE:Zn,TLD:el,UNDERSCORE:Pi,UTLD:tl,UWORD:Zo,WORD:tt,WS:nl}),Ze=/[a-z]/,Kn=/\p{L}/u,Jo=/\p{Emoji}/u;var et=/\d/,jo=/\s/;var Bd="\r",Ko=` +`,Yy="\uFE0F",Qy="\u200D",Uo="\uFFFC",si=null,oi=null;function Zy(n=[]){let e={};xe.groups=e;let t=new xe;si==null&&(si=Fd(jy)),oi==null&&(oi=Fd(Ky)),x(t,"'",Mi),x(t,"{",Gn),x(t,"}",Xn),x(t,"[",ci),x(t,"]",ui),x(t,"(",di),x(t,")",fi),x(t,"<",hi),x(t,">",pi),x(t,"\uFF08",mi),x(t,"\uFF09",gi),x(t,"\u300C",yi),x(t,"\u300D",ki),x(t,"\u300E",xi),x(t,"\u300F",bi),x(t,"\uFF1C",Si),x(t,"\uFF1E",wi),x(t,"&",vi),x(t,"*",Ci),x(t,"@",dt),x(t,"`",Ei),x(t,"^",Ai),x(t,":",Dt),x(t,",",sl),x(t,"$",Ni),x(t,".",Be),x(t,"=",Oi),x(t,"!",ol),x(t,"-",Ne),x(t,"%",Yn),x(t,"|",Ri),x(t,"+",Ii),x(t,"#",Di),x(t,"?",Qn),x(t,'"',ll),x(t,"/",Fe),x(t,";",al),x(t,"~",Zn),x(t,"_",Pi),x(t,"\\",Ti),x(t,"\u30FB",Jd);let r=J(t,et,rl,{[Go]:!0});J(r,et,r);let i=J(r,Ze,_d,{[qn]:!0}),s=J(r,Kn,Wd,{[Un]:!0}),o=J(t,Ze,tt,{[Xo]:!0});J(o,et,i),J(o,Ze,o),J(i,et,i),J(i,Ze,i);let l=J(t,Kn,Zo,{[Yo]:!0});J(l,Ze),J(l,et,s),J(l,Kn,l),J(s,et,s),J(s,Ze),J(s,Kn,s);let a=x(t,Ko,il,{[Wo]:!0}),c=x(t,Bd,nl,{[Wo]:!0}),u=J(t,jo,nl,{[Wo]:!0});x(t,Uo,u),x(c,Ko,a),x(c,Uo,u),J(c,jo,u),x(u,Bd),x(u,Ko),J(u,jo,u),x(u,Uo,u);let d=J(t,Jo,jd,{[Vd]:!0});x(d,"#"),J(d,Jo,d),x(d,Yy,d);let f=x(d,Qy);x(f,"#"),J(f,Jo,d);let h=[[Ze,o],[et,i]],p=[[Ze,null],[Kn,l],[et,s]];for(let m=0;mm[0]>g[0]?1:-1);for(let m=0;m=0?b[Qo]=!0:Ze.test(g)?et.test(g)?b[qn]=!0:b[Xo]=!0:b[Go]=!0,zd(t,g,g,b)}return zd(t,"localhost",er,{ascii:!0}),t.jd=new xe(Li),{start:t,tokens:Object.assign({groups:e},Kd)}}function Ud(n,e){let t=e0(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,i=[],s=0,o=0;for(;o=0&&(d+=t[o].length,f++),c+=t[o].length,s+=t[o].length,o++;s-=d,o-=f,c-=d,i.push({t:u.t,v:e.slice(s-c,s),s:s-c,e:s})}return i}function e0(n){let e=[],t=n.length,r=0;for(;r56319||r+1===t||(s=n.charCodeAt(r+1))<56320||s>57343?n[r]:n.slice(r,r+2);e.push(o),r+=o.length}return e}function ut(n,e,t,r,i){let s,o=e.length;for(let l=0;l=0;)s++;if(s>0){e.push(t.join(""));for(let o=parseInt(n.substring(r,r+s),10);o>0;o--)t.pop();r+=s}else t.push(n[r]),r++}return e}var tr={defaultProtocol:"http",events:null,format:Hd,formatHref:Hd,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function cl(n,e=null){let t=Object.assign({},tr);n&&(t=Object.assign(t,n instanceof cl?n.o:n));let r=t.ignoreTags,i=[];for(let s=0;st?r.substring(0,t)+"\u2026":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=tr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){let e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),i=n.get("tagName",t,e),s=this.toFormattedString(n),o={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),u=n.getObj("attributes",t,e),d=n.getObj("events",t,e);return o.href=r,l&&(o.class=l),a&&(o.target=a),c&&(o.rel=c),u&&Object.assign(o,u),{tagName:i,attributes:o,content:s,eventListeners:d}}};function zi(n,e){class t extends qd{constructor(i,s){super(i,s),this.t=n}}for(let r in e)t.prototype[r]=e[r];return t.t=n,t}var t0=zi("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),$d=zi("text"),n0=zi("nl"),li=zi("url",{isLink:!0,toHref(n=tr.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){let n=this.tk;return n.length>=2&&n[0].t!==er&&n[1].t===Dt}});var Ae=n=>new xe(n);function r0({groups:n}){let e=n.domain.concat([vi,Ci,dt,Ti,Ei,Ai,Ni,Oi,Ne,rl,Yn,Ri,Ii,Di,Fe,Li,Zn,Pi]),t=[Mi,Dt,sl,Be,ol,Yn,Qn,ll,al,hi,pi,Gn,Xn,ui,ci,di,fi,mi,gi,yi,ki,xi,bi,Si,wi],r=[vi,Mi,Ci,Ti,Ei,Ai,Ni,Oi,Ne,Gn,Xn,Yn,Ri,Ii,Di,Qn,Fe,Li,Zn,Pi],i=Ae(),s=x(i,Zn);P(s,r,s),P(s,n.domain,s);let o=Ae(),l=Ae(),a=Ae();P(i,n.domain,o),P(i,n.scheme,l),P(i,n.slashscheme,a),P(o,r,s),P(o,n.domain,o);let c=x(o,dt);x(s,dt,c),x(l,dt,c),x(a,dt,c);let u=x(s,Be);P(u,r,s),P(u,n.domain,s);let d=Ae();P(c,n.domain,d),P(d,n.domain,d);let f=x(d,Be);P(f,n.domain,d);let h=Ae(t0);P(f,n.tld,h),P(f,n.utld,h),x(c,er,h);let p=x(d,Ne);x(p,Ne,p),P(p,n.domain,d),P(h,n.domain,d),x(h,Be,f),x(h,Ne,p);let m=x(o,Ne),g=x(o,Be);x(m,Ne,m),P(m,n.domain,o),P(g,r,s),P(g,n.domain,o);let y=Ae(li);P(g,n.tld,y),P(g,n.utld,y),P(y,n.domain,o),P(y,r,s),x(y,Be,g),x(y,Ne,m),x(y,dt,c);let b=x(y,Dt),v=Ae(li);P(b,n.numeric,v);let w=Ae(li),A=Ae();P(w,e,w),P(w,t,A),P(A,e,w),P(A,t,A),x(y,Fe,w),x(v,Fe,w);let R=x(l,Dt),E=x(a,Dt),L=x(E,Fe),z=x(L,Fe);P(l,n.domain,o),x(l,Be,g),x(l,Ne,m),P(a,n.domain,o),x(a,Be,g),x(a,Ne,m),P(R,n.domain,w),x(R,Fe,w),x(R,Qn,w),P(z,n.domain,w),P(z,e,w),x(z,Fe,w);let G=[[Gn,Xn],[ci,ui],[di,fi],[hi,pi],[mi,gi],[yi,ki],[xi,bi],[Si,wi]];for(let Ve=0;Ve=0&&f++,i++,u++;if(f<0)i-=u,i0&&(s.push(qo($d,e,o)),o=[]),i-=f,u-=f;let h=d.t,p=t.slice(i-u,i);s.push(qo(h,e,p))}}return o.length>0&&s.push(qo($d,e,o)),s}function qo(n,e,t){let r=t[0].s,i=t[t.length-1].e,s=e.slice(r,i);return new n(s,t)}var s0=typeof console<"u"&&console&&console.warn||(()=>{}),o0="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",V={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Gd(){return xe.groups={},V.scanner=null,V.parser=null,V.tokenQueue=[],V.pluginQueue=[],V.customSchemes=[],V.initialized=!1,V}function ul(n,e=!1){if(V.initialized&&s0(`linkifyjs: already initialized - will not register custom scheme "${n}" ${o0}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format. +1. Must only contain digits, lowercase ASCII letters or "-" +2. Cannot start or end with "-" +3. "-" cannot repeat`);V.customSchemes.push([n,e])}function l0(){V.scanner=Zy(V.customSchemes);for(let n=0;n{let i=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),s=e.some(c=>c.getMeta("preventAutolink"));if(!i||s)return;let{tr:o}=r,l=bo(t.doc,[...e]);if(Mo(l).forEach(({newRange:c})=>{let u=ku(r.doc,c,h=>h.isTextblock),d,f;if(u.length>1)d=u[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(u.length){let h=r.doc.textBetween(c.from,c.to," "," ");if(!c0.test(h))return;d=u[0],f=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&f){let h=f.split(a0).filter(Boolean);if(h.length<=0)return!1;let p=h[h.length-1],m=d.pos+f.lastIndexOf(p);if(!p)return!1;let g=Bi(p).map(y=>y.toObject(n.defaultProtocol));if(!d0(g))return!1;g.filter(y=>y.isLink).map(y=>({...y,from:m+y.start+1,to:m+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>n.validate(y.value)).filter(y=>n.shouldAutoLink(y.value)).forEach(y=>{Jr(y.from,y.to,r.doc).some(b=>b.mark.type===n.type)||o.addMark(y.from,y.to,n.type.create({href:y.href}))})}}),!!o.steps.length)return o}})}function h0(n){return new N({key:new I("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,s;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let a=r.target;if(!a)return!1;let c=n.editor.view.dom;o=a.closest("a"),o&&!c.contains(o)&&(o=null)}if(!o)return!1;let l=!1;if(n.enableClickSelection&&(l=n.editor.commands.extendMarkRange(n.type.name)),n.openOnClick){let a=vo(e.state,n.type.name),c=(i=o.href)!=null?i:a.href,u=(s=o.target)!=null?s:a.target;c&&(window.open(c,u),l=!0)}return l}}})}function p0(n){return new N({key:new I("handlePasteLink"),props:{handlePaste:(e,t,r)=>{let{shouldAutoLink:i}=n,{state:s}=e,{selection:o}=s,{empty:l}=o;if(l)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});let c=Fi(a,{defaultProtocol:n.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c||i!==void 0&&!i(c.value)?!1:n.editor.commands.setMark(n.type,{href:c.href})}}})}function Pt(n,e){let t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{let i=typeof r=="string"?r:r.scheme;i&&t.push(i)}),!n||n.replace(u0,"").match(new RegExp(`^(?:(?:${t.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}var Xd=Se.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){ul(n);return}ul(n.scheme,n.optionalSlashes)})},onDestroy(){Gd()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!Pt(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>{let e=/^[a-z][a-z0-9+.-]*:\/\//i.test(n),t=/^[a-z][a-z0-9+.-]*:/i.test(n);if(e||t&&!n.includes("@"))return!0;let i=(n.includes("@")?n.split("@").pop():n).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(i)||!/\./.test(i))}}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{let e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!Pt(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!Pt(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",D(this.options.HTMLAttributes,n),0]:["a",D(this.options.HTMLAttributes,{...n,href:""}),0]},markdownTokenName:"link",parseMarkdown:(n,e)=>e.applyMark("link",e.parseInline(n.tokens||[]),{href:n.href,title:n.title||null}),renderMarkdown:(n,e)=>{var t,r,i,s;let o=(r=(t=n.attrs)==null?void 0:t.href)!=null?r:"",l=(s=(i=n.attrs)==null?void 0:i.title)!=null?s:"",a=e.renderChildren(n);return l?`[${a}](${o} "${l}")`:`[${a}](${o})`},addCommands(){return{setLink:n=>({chain:e})=>{let{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!Pt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{let{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:r=>!!Pt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Ee({find:n=>{let e=[];if(n){let{protocols:t,defaultProtocol:r}=this.options,i=Fi(n).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:o=>!!Pt(o,t),protocols:t,defaultProtocol:r}));i.length&&i.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){let n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(f0({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Pt(i,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),n.push(h0({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(p0({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}});var m0=Object.defineProperty,g0=(n,e)=>{for(var t in e)m0(n,t,{get:e[t],enumerable:!0})},y0="listItem",Yd="textStyle",Qd=/^\s*([-+*])\s$/,ml=$.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",D(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>n.type!=="list"||n.ordered?[]:{type:"bulletList",content:n.items?e.parseChildren(n.items):[]},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` +`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(y0,this.editor.getAttributes(Yd)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=ze({find:Qd,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=ze({find:Qd,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Yd),editor:this.editor})),[n]}}),k0=(n,e,t)=>{let{selection:r}=n;if(!r.empty)return null;let{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let s=-1;for(let h=i.depth;h>0;h-=1)if(i.node(h).type.name===e){s=h;break}if(s<0)return null;let o=i.node(s),l=i.index(s);if(l+1>=o.childCount)return null;let a=o.child(l+1);if(!t.includes(a.type.name))return null;let c=n.schema.nodes[e],u=!1;if(a.forEach(h=>{h.type===c&&h.childCount>1&&(u=!0)}),!u)return null;let d=n.doc.resolve(i.after()).nodeAfter;if(!d||!t.includes(d.type.name))return null;let f=[];return d.forEach(h=>{f.push(h)}),f.length===0?null:{listItemDepth:s,nestedList:d,nestedListPos:i.after(),insertPos:i.after(s),items:f}},x0=(n,e,t,r)=>{let i=k0(n,t,r);if(!i)return!1;let{selection:s}=n,{nestedList:o,nestedListPos:l,insertPos:a,items:c}=i,u=n.tr;u.delete(l,l+o.nodeSize);let d=u.mapping.map(a);return u.insert(d,k.from(c)),u.setSelection(s.map(u.doc,u.mapping)),e&&e(u),!0},b0=(n,e,t)=>x0(n.state,n.view.dispatch,e,t),nf=(n,e)=>B.create({name:`${n}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let t=()=>b0(this.editor,n,e);return{Delete:t,"Mod-Delete":t}}}),rf=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],Hi="abcdefghijklmnopqrstuvwxyz",S0="[a-zA-Z]{1,2}",gl=String.raw`\d+|[ivxlcdmIVXLCDM]+|${S0}`;function Vi(n){let e=n,t="";for(let[r,i]of rf)for(;e>=r;)t+=i,e-=r;return t}function yl(n){return Vi(n).toUpperCase()}function sf(n){let e=n.toLowerCase(),t=0,r=0;for(;t0?r:1}let t=parseInt(n,10);return Number.isNaN(t)?1:t}function M0(n,e){if(n==="numeric")return String(e);switch(n){case"a":return $i(e);case"A":return $i(e).toUpperCase();case"i":return Vi(e);case"I":return yl(e);default:return String(e)}}function C0(n){var e;if(n.length===0)return!1;let t=(e=_i(n[0]))!=null?e:"numeric",r=kl(n[0]);if(r<1)return!1;for(let i=0;i{var t;if(n.type!=="list_item")return[];let r=(t=e.parseBlockChildren)!=null?t:e.parseChildren,i=[];if(n.tokens&&n.tokens.length>0){if(N0(n))return{type:"listItem",content:[{type:"paragraph",content:O0(n.text||"",e)}]};if(n.tokens.some(o=>o.type==="paragraph"))i=r(n.tokens);else{let o=n.tokens[0];if(o&&o.type==="text"&&o.tokens&&o.tokens.length>0){if(i=[{type:"paragraph",content:e.parseInline(o.tokens)}],n.tokens.length>1){let a=n.tokens.slice(1),c=r(a);i.push(...c)}}else i=r(n.tokens)}}return i.length===0&&(i=[{type:"paragraph",content:[]}]),{type:"listItem",content:i}},renderMarkdown:(n,e,t)=>Ln(n,e,r=>{var i,s,o,l;if(r.parentType==="bulletList")return"- ";if(r.parentType==="orderedList"){let a=((s=(i=r.meta)==null?void 0:i.parentAttrs)==null?void 0:s.start)||1,c=(l=(o=r.meta)==null?void 0:o.parentAttrs)==null?void 0:l.type,u=a-1+(r.index||0);return A0(c,u,". ")}return"- "},t),addExtensions(){return[nf(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),R0={};g0(R0,{findListItemPos:()=>Wi,getNextListDepth:()=>bl,handleBackspace:()=>fl,handleDelete:()=>hl,hasListBefore:()=>of,hasListItemAfter:()=>I0,hasListItemBefore:()=>D0,listItemHasSubList:()=>P0,nextListIsDeeper:()=>lf,nextListIsHigher:()=>af});var Wi=(n,e)=>{let{$from:t}=e.selection,r=_(n,e.schema),i=null,s=t.depth,o=t.pos,l=null;for(;s>0&&l===null;)i=t.node(s),i.type===r?l=s:(s-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},bl=(n,e)=>{let t=Wi(n,e);if(!t)return!1;let[,r]=Mu(e,n,t.$pos.pos+4);return r},of=(n,e,t)=>{let{$anchor:r}=n.selection,i=Math.max(0,r.pos-2),s=n.doc.resolve(i).node();return!(!s||!t.includes(s.type.name))},fl=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!Pe(n.state,e)&&of(n.state,e,t)){let{$anchor:r}=n.state.selection,i=n.state.doc.resolve(r.before()-1),s=[];i.node().descendants((a,c)=>{a.type.name===e&&s.push({node:a,pos:c})});let o=s.at(-1);if(!o)return!1;let l=n.state.doc.resolve(i.start()+o.pos+1);return n.chain().cut({from:r.start()-1,to:r.end()+1},l.end()).joinForward().run()}return!Pe(n.state,e)||!Tu(n.state)?!1:n.chain().liftListItem(e).run()},lf=(n,e)=>{let t=bl(n,e),r=Wi(n,e);return!r||!t?!1:t>r.depth},af=(n,e)=>{let t=bl(n,e),r=Wi(n,e);return!r||!t?!1:t{if(!Pe(n.state,e)||!Cu(n.state,e))return!1;let{selection:t}=n.state,{$from:r,$to:i}=t;return!t.empty&&r.sameParent(i)?!1:lf(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():af(e,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},I0=(n,e)=>{var t;let{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-r.parentOffset-2);return!(i.index()===i.parent.childCount-1||((t=i.nodeAfter)==null?void 0:t.type.name)!==n)},D0=(n,e)=>{var t;let{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-2);return!(i.index()===0||((t=i.nodeBefore)==null?void 0:t.type.name)!==n)},P0=(n,e,t)=>{if(!t)return!1;let r=_(n,e.schema),i=!1;return t.descendants(s=>{s.type===r&&(i=!0)}),i},Sl=B.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&hl(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&hl(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&fl(n,t,r)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&fl(n,t,r)&&(e=!0)}),e}}}}),pl=new RegExp(`^(\\s*)(${gl})([.)])\\s+(.*)$`),L0=new RegExp(`^(\\s*)(${gl})([.)])\\s+`),z0=/^\s/;function B0(n){return pl.test(n.trimStart())}function F0(n){let e=n.trimStart();return/^[-+*]\s+/.test(e)||B0(e)||/^>\s?/.test(e)||/^```/.test(e)||/^~~~/.test(e)}function H0(n){let e=[],t=[],r=!1;return n.forEach(i=>{if(r){t.push(i);return}if(i.trim()===""){r=!0,t.push(i);return}if(e.length>0&&F0(i)){r=!0,t.push(i);return}e.push(i)}),{paragraphLines:e,blockLines:t}}function $0(n){let e=[],t=0,r=0;for(;ts.trim().length>0);if(e.length===0)return null;let t=[];for(let s of e){let o=s.trim().match(V0);if(!o)return null;t.push({marker:o[1],content:o[3]})}let r=t.map(s=>s.marker);return C0(r)?{type:"orderedList",attrs:E0(t[0].marker),content:t.map(s=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:s.content}]}]}))}:null}function cf(n,e,t){let r=[],i=0;for(;ie;)f.push(n[d]),d+=1;if(f.length>0){let h=Math.min(...f.map(m=>m.indent)),p=cf(f,h,t);c.push({type:"list",ordered:!0,start:f[0].number,typeMarker:f[0].type,items:p,raw:f.map(m=>m.raw).join(` +`)})}r.push({type:"list_item",raw:s.raw,tokens:c}),i=d}else i+=1}return r}function W0(n,e){return n.map(t=>{if(t.type!=="list_item")return e.parseChildren([t])[0];let r=[];return t.tokens&&t.tokens.length>0&&t.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){let s=e.parseChildren([i]);r.push({type:"paragraph",content:s})}else{let s=e.parseChildren([i]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var J0="listItem",Zd="textStyle",ef=/^(\d+)\.\s$/;function tf(n){let e=n.match(/list-style-type\s*:\s*([^;]+)/i);if(!e)return null;switch(e[1].trim().toLowerCase()){case"upper-roman":return"I";case"lower-roman":return"i";case"upper-alpha":case"upper-latin":return"A";case"lower-alpha":case"lower-latin":return"a";default:return null}}var wl=$.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>{let e=n.getAttribute("type");if(e)return e;let t=n.getAttribute("style");if(t){let i=tf(t);if(i)return i}let r=n.querySelector("li");if(r){let i=r.getAttribute("style");if(i){let s=tf(i);if(s)return s}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){let{start:e,type:t,...r}=n,i=D(this.options.HTMLAttributes,r);return e!==1&&(i.start=e),t&&t!=="1"&&(i.type=t),["ol",i,0]},markdownTokenName:"list",parseMarkdown:(n,e)=>{if(n.type!=="list"||!n.ordered)return[];let t=n.start||1,r=n.typeMarker,i=n.items?W0(n.items,e):[],s={};return t!==1&&(s.start=t),r&&(s.type=r),Object.keys(s).length>0?{type:"orderedList",attrs:s,content:i}:{type:"orderedList",content:i}},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` +`):"",markdownTokenizer:{name:"orderedList",level:"block",start:n=>{let e=n.match(L0),t=e?.index;return t!==void 0?t:-1},tokenize:(n,e,t)=>{var r,i;let s=n.split(` +`),[o,l]=$0(s);if(o.length===0)return;let a=cf(o,0,t);if(a.length===0)return;let c=((r=o[0])==null?void 0:r.number)||1,u=(i=o[0])==null?void 0:i.type;return{type:"list",ordered:!0,start:c,typeMarker:u,items:a,raw:s.slice(0,l).join(` +`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(J0,this.editor.getAttributes(Zd)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new N({props:{handlePaste:(n,e)=>{var t,r;let i=(t=e.clipboardData)==null?void 0:t.getData("text/html");if(i?.trim())return!1;let s=(r=e.clipboardData)==null?void 0:r.getData("text/plain");if(!s)return!1;let o=_0(s);if(!o)return!1;try{let l=n.state.schema.nodeFromJSON(o),a=n.state.tr.replaceSelectionWith(l);return n.dispatch(a),!0}catch{return!1}}}})]},addInputRules(){let n=(t,r)=>(!r.attrs.type||r.attrs.type==="1")&&r.childCount+r.attrs.start===+t[1],e=ze({find:ef,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:n});return(this.options.keepMarks||this.options.keepAttributes)&&(e=ze({find:ef,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(Zd)}),joinPredicate:n,editor:this.editor})),[e]}}),j0=/^\s*(\[([( |x])?\])\s$/,K0=$.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>{let e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",D(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(n,e)=>{let t=[];if(n.tokens&&n.tokens.length>0?t.push(e.createNode("paragraph",{},e.parseInline(n.tokens))):n.text?t.push(e.createNode("paragraph",{},[e.createNode("text",{text:n.text})])):t.push(e.createNode("paragraph",{},[])),n.nestedTokens&&n.nestedTokens.length>0){let r=e.parseChildren(n.nestedTokens);t.push(...r)}return e.createNode("taskItem",{checked:n.checked||!1},t)},renderMarkdown:(n,e)=>{var t;let i=`- [${(t=n.attrs)!=null&&t.checked?"x":" "}] `;return Ln(n,e,i)},addExtensions(){return this.options.nested?[nf(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{let i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=d=>{var f,h;l.ariaLabel=((h=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:h.call(f,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};c(n),s.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}let{checked:f}=d.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{let p=t();if(typeof p!="number")return!1;let m=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...m?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{i.setAttribute(d,f)}),i.dataset.checked=n.attrs.checked,l.checked=n.attrs.checked,s.append(l,o),i.append(s,a),Object.entries(e).forEach(([d,f])=>{i.setAttribute(d,f)});let u=new Set(Object.keys(e));return{dom:i,contentDOM:a,update:d=>{if(d.type!==this.type)return!1;i.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,c(d);let f=r.extensionManager.attributes,h=Qt(d,f),p=new Set(Object.keys(h)),m=this.options.HTMLAttributes;return u.forEach(g=>{p.has(g)||(g in m?i.setAttribute(g,m[g]):i.removeAttribute(g))}),Object.entries(h).forEach(([g,y])=>{y==null?g in m?i.setAttribute(g,m[g]):i.removeAttribute(g):i.setAttribute(g,y)}),u=p,!0}}}},addInputRules(){return[ze({find:j0,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),U0=$.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",D(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},parseMarkdown:(n,e)=>e.createNode("taskList",{},e.parseChildren(n.items||[])),renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` +`):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;let t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){let r=s=>{let o=Kr(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:t.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},t);return o?[{type:"taskList",raw:o.raw,items:o.items}]:t.blockTokens(s)},i=Kr(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,o)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:t.inlineTokens(s.mainContent),nestedTokens:o}),customNestedParser:r},t);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),PS=B.create({name:"listKit",addExtensions(){let n=[];return this.options.bulletList!==!1&&n.push(ml.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(xl.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(Sl.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(wl.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(K0.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(U0.configure(this.options.taskList)),n}});var Ji=" ",vl="\xA0",uf=$.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",D(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{let t=n.tokens||[];if(t.length===1&&t[0].type==="image")return e.parseChildren([t[0]]);let r=e.parseInline(t);return t.length===1&&t[0].type==="text"&&(t[0].raw===Ji||t[0].text===Ji||t[0].raw===vl||t[0].text===vl)&&r.length===1&&r[0].type==="text"&&(r[0].text===Ji||r[0].text===vl)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(n,e,t)=>{var r,i;if(!n)return"";let s=Array.isArray(n.content)?n.content:[];if(s.length===0){let o=Array.isArray((r=t?.previousNode)==null?void 0:r.content)?t.previousNode.content:[];return((i=t?.previousNode)==null?void 0:i.type)==="paragraph"&&o.length===0?Ji:""}return e.renderChildren(s)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var q0=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,G0=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,df=Se.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",D(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,e)=>e.applyMark("strike",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`~~${e.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Le({find:q0,type:this.type})]},addPasteRules(){return[Ee({find:G0,type:this.type})]}});var ff=$.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""});var hf=Se.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",D(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){let i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!i)return;let s=i[2].trim();return{type:"underline",raw:i[0],text:s,tokens:t.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function pf(n={}){return new N({view(e){return new Ml(e,n)}})}var Ml=class{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,l=s.height/i.offsetHeight;if(t){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let p=h.getBoundingClientRect(),m=d?p.bottom:p.top;d&&f&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!s){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=pr(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var de=class n extends O{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return n.valid(r)?new n(r):O.near(r)}content(){return S.empty}eq(e){return e instanceof n&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new n(e.resolve(t.pos))}getBookmark(){return new Cl(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!X0(e)||!Y0(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&n.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)0){s=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let a=e.doc.resolve(i);if(n.valid(a))return a}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!M.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),r=!1;continue e}break}s=o,i+=t;let l=e.doc.resolve(i);if(n.valid(l))return l}return null}}};de.prototype.visible=!1;de.findFrom=de.findGapCursorFrom;O.jsonID("gapcursor",de);var Cl=class n{constructor(e){this.pos=e}map(e){return new n(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return de.valid(t)?new de(t):O.near(t)}};function mf(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function X0(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||mf(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Y0(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||mf(i.type))return!0;if(i.inlineContent)return!1}}return!0}function gf(){return new N({props:{decorations:tk,createSelectionBetween(n,e,t){return e.pos==t.pos&&de.valid(t)?new de(t):null},handleClick:Z0,handleKeyDown:Q0,handleDOMEvents:{beforeinput:ek}}})}var Q0=uo({ArrowLeft:ji("horiz",-1),ArrowRight:ji("horiz",1),ArrowUp:ji("vert",-1),ArrowDown:ji("vert",1)});function ji(n,e){let t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof C){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=de.findGapCursorFrom(l,e,a);return c?(i&&i(r.tr.setSelection(new de(c))),!0):!1}}function Z0(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!de.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&M.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new de(r))),!0)}function ek(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof de))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=k.empty;for(let o=r.length-1;o>=0;o--)i=k.from(r[o].createAndFill(null,i));let s=n.state.tr.replace(t.pos,t.pos,new S(i,0,0));return s.setSelection(C.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function tk(n){if(!(n.selection instanceof de))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",K.create(n.doc,[ae.widget(n.selection.head,e,{key:"gapcursor"})])}var Ki=200,re=function(){};re.prototype.append=function(e){return e.length?(e=re.from(e),!this.length&&e||e.length=t?re.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};re.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};re.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};re.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},t,r),i};re.from=function(e){return e instanceof re?e:e&&e.length?new yf(e):re.empty};var yf=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,l){for(var a=s;a=o;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Ki)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Ki)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(re);re.empty=new yf([]);var nk=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return rl&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(s,l)-l,o+l)===!1||s=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(re),Tl=re;var rk=500,zt=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;t&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){i||(i=this.remapping(r,f+1),s=i.maps.length),s--,u.push(d);return}if(i){u.push(new He(d.map));let h=d.step.map(i.slice(s)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new He(p,void 0,void 0,c.length+u.length))),s--,p&&i.appendMap(p,s)}else o.maybeStep(d.step);if(d.selection)return l=i?d.selection.map(i.slice(s)):d.selection,a=new n(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,r,i){let s=[],o=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let u=0;usk&&(l=ik(l,c),o-=c),new n(l.append(s),o)}remapping(e,t){let r=new mn;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new He(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},i);let a=t;this.items.forEach(f=>{let h=s.getMirror(--a);if(h==null)return;o=Math.min(o,h);let p=s.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(s.slice(a+1,h));g&&l++,r.push(new He(p,m,g))}else r.push(new He(p))},i);let c=[];for(let f=t;frk&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&s++;else if(o.step){let a=o.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=o.selection&&o.selection.map(t.slice(r));u&&s++;let d=new He(c.invert(),a,u),f,h=i.length-1;(f=i.length&&i[h].merge(d))?i[h]=f:i.push(d)}}else o.map&&r--},this.items.length,0),new n(Tl.from(i.reverse()),s)}};zt.empty=new zt(Tl.empty,0);function ik(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}var He=class n{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},$e=class{constructor(e,t,r,i,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}},sk=20;function ok(n,e,t,r){let i=t.getMeta(Lt),s;if(i)return i.historyState;t.getMeta(ck)&&(n=new $e(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(Lt))return o.getMeta(Lt).redo?new $e(n.done.addTransform(t,void 0,r,Ui(e)),n.undone,kf(t.mapping.maps),n.prevTime,n.prevComposition):new $e(n.done,n.undone.addTransform(t,void 0,r,Ui(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!lk(t,n.prevRanges)),c=o?El(n.prevRanges,t.mapping):kf(t.mapping.maps);return new $e(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Ui(e)),zt.empty,c,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new $e(n.done.rebased(t,s),n.undone.rebased(t,s),El(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new $e(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),El(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function lk(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let s=0;s=e[s]&&(t=!0)}),t}function kf(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,s,o)=>e.push(s,o));return e}function El(n,e){if(!n)return null;let t=[];for(let r=0;r{let i=Lt.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let s=ak(i,t,n);s&&r(e?s.scrollIntoView():s)}return!0}}var Nl=qi(!1,!0),Ol=qi(!0,!0),o1=qi(!1,!1),l1=qi(!0,!1);var h1=B.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{let e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){let r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{let e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new N({key:new I("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;let i=this.options.limit,s=this.options.autoTrim;if(i==null||i===0||s===!1){n=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let l=o-i,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let u=r.tr.deleteRange(a,c);return n=!0,u}n=!0},filterTransaction:(e,t)=>{let r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;let i=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;let l=e.selection.$head.pos,a=s-r,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}}),Cf=B.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[pf(this.options)]}}),x1=B.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new N({key:new I("focus"),props:{decorations:({doc:n,selection:e})=>{let{isEditable:t,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!t||!r)return K.create(n,[]);let o=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(a.isText)return;if(!(i>=c&&i<=c+a.nodeSize-1))return!1;o+=1});let l=0;return n.descendants((a,c)=>{if(a.isText||!(i>=c&&i<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";s.push(ae.node(c,c+a.nodeSize,{class:this.options.className}))}),K.create(n,s)}}})]}}),Tf=B.create({name:"gapCursor",addProseMirrorPlugins(){return[gf()]},extendNodeSchema(n){var e;let t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=H(T(n,"allowGapCursor",t)))!=null?e:null}}}),Ef="placeholder",nr=new I("tiptap__placeholder"),Sf=200;function wf(n){let{editor:e,placeholder:t,dataAttribute:r,pos:i,node:s,isEmptyDoc:o,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=n,u=[a];return o&&u.push(c),ae.node(i,i+s.nodeSize,{class:u.join(" "),[r]:typeof t=="function"?t({editor:e,node:s,pos:i,hasAnchor:l}):t})}function vf(n,e){return typeof n=="function"?n(e):n}function uk({editor:n,options:e,dataAttribute:t,doc:r,selection:i}){var s,o;if(!(n.isEditable||!e.showOnlyWhenEditable))return null;let{anchor:a}=i,c=[],u=n.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){let f=r.resolve(a),h=f.depth>0?f.node(1):f.nodeAfter,p=f.depth>0?f.before(1):a;if(h&&h.type.isTextblock&&Zt(h)){let m=a>=p&&a<=p+h.nodeSize;c.push(wf({editor:n,isEmptyDoc:u,dataAttribute:t,hasAnchor:m,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:vf(e.emptyNodeClass,{editor:n,node:h,pos:p,hasAnchor:m})},node:h,pos:p}))}}else{let f=nr.getState(n.state),h=(s=f?.topPos)!=null?s:0,p=(o=f?.bottomPos)!=null?o:r.content.size;r.nodesBetween(h,p,(m,g)=>{let y=a>=g&&a<=g+m.nodeSize,b=!m.isLeaf&&Zt(m);return m.type.isTextblock&&(y||!e.showOnlyCurrent)&&b&&c.push(wf({editor:n,isEmptyDoc:u,dataAttribute:t,hasAnchor:y,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:vf(e.emptyNodeClass,{editor:n,node:m,pos:g,hasAnchor:y})},node:m,pos:g})),e.includeChildren})}return K.create(r,c)}function dk(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function fk(n){let e=getComputedStyle(n),t=`${e.overflow} ${e.overflowY} ${e.overflowX}`;return/auto|scroll|overlay/.test(t)}function hk(n){let e=n;for(;e;){if(fk(e))return e;let t=e.parentElement;if(!t){let r=e.getRootNode();if(r instanceof ShadowRoot){e=r.host;continue}return window}e=t}return window}function pk(n){return n===window?{top:0,bottom:window.innerHeight}:n.getBoundingClientRect()}function mk({view:n,scrollContainer:e}){let t=n.dom.getBoundingClientRect();if(t.width<=0||t.height<=0)return null;let r=e?pk(e):{top:0,bottom:window.innerHeight},i=Math.max(t.top,r.top)-Sf,s=Math.min(t.bottom,r.bottom)+Sf;if(i>=s)return null;let o=t.left+1,l=t.right-1;if(o>l)return null;let c=getComputedStyle(n.dom).direction==="rtl"?t.right-2:t.left+2,u=Math.min(Math.max(c,o),l),d=Math.max(i+2,t.top+1),f=Math.min(s-2,t.bottom-1);if(d>f)return null;let h=n.posAtCoords({left:u,top:d}),p=n.posAtCoords({left:u,top:f});return!h||!p?null:{top:h.pos,bottom:p.pos}}var gk={init(){return{topPos:null,bottomPos:null}},apply(n,e){let t=n.getMeta(nr);return t?.positions?{topPos:t.positions.top,bottomPos:t.positions.bottom}:n.docChanged?{topPos:e.topPos!==null?n.mapping.map(e.topPos):null,bottomPos:e.bottomPos!==null?n.mapping.map(e.bottomPos):null}:e}};function yk(n){let e=hk(n.dom),t=()=>{let c=mk({view:n,scrollContainer:e});if(c===null)return;let u=nr.getState(n.state);if(u?.topPos===c.top&&u?.bottomPos===c.bottom)return;let d=n.state.tr.setMeta(nr,{positions:c});n.dispatch(d)},r=null,i=0,s=150,o=()=>{r===null&&(r=requestAnimationFrame(()=>{r=null;let c=performance.now();c-i>=s?(i=c,t()):o()}))};e.addEventListener("scroll",o,{passive:!0});let l=typeof ResizeObserver<"u"?new ResizeObserver(o):null;l?.observe(n.dom);let a=typeof IntersectionObserver<"u"?new IntersectionObserver(o):null;return a?.observe(n.dom),n.dom.addEventListener("focus",o),t(),{update(c,u){n.state.doc.content.size!==u.doc.content.size&&o()},destroy:()=>{r!==null&&cancelAnimationFrame(r),e.removeEventListener("scroll",o),l?.disconnect(),a?.disconnect(),n.dom.removeEventListener("focus",o)}}}function kk({editor:n,options:e}){let t=e.dataAttribute?`data-${dk(e.dataAttribute)}`:`data-${Ef}`;return new N({key:nr,state:gk,view:yk,props:{decorations:({doc:r,selection:i})=>uk({editor:n,options:e,dataAttribute:t,doc:r,selection:i})}})}var A1=B.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Ef,placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[kk({editor:this.editor,options:this.options})]}}),xk=`.ProseMirror:not(.ProseMirror-focused) *::selection { + background: transparent; +} + +.ProseMirror:not(.ProseMirror-focused) *::-moz-selection { + background: transparent; +}`,I1=B.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:n,options:e}=this;return n.options.injectCSS&&typeof document<"u"&&Co(xk,n.options.injectNonce,"selection"),[new N({key:new I("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||jr(t.selection)||n.view.dragging?null:K.create(t.doc,[ae.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}}),bk="skipTrailingNode";function Mf({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var Af=B.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;let e=new I(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(t).includes(i.name));return[new N({key:e,appendTransaction:(i,s,o)=>{let{doc:l,tr:a,schema:c}=o,u=e.getState(o),d=l.content.size,f=c.nodes[t];if(!i.some(h=>h.getMeta(bk))&&u)return a.insert(d,f.create())},state:{init:(i,s)=>{let o=s.tr.doc.lastChild;return!Mf({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;let o=i.doc.lastChild;return!Mf({node:o,types:r})}}})]}}),Nf=B.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Nl(n,e),redo:()=>({state:n,dispatch:e})=>Ol(n,e)}},addProseMirrorPlugins(){return[bf(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var Of=B.create({name:"starterKit",addExtensions(){var n,e,t,r;let i=[];return this.options.bold!==!1&&i.push(Ad.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(Ed.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(ml.configure(this.options.bulletList)),this.options.code!==!1&&i.push(Nd.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(Od.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(Rd.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(Cf.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(Tf.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(Id.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(Dd.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(Nf.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(Pd.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(Ld.configure(this.options.italic)),this.options.listItem!==!1&&i.push(xl.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(Sl.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&i.push(Xd.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(wl.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(uf.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(df.configure(this.options.strike)),this.options.text!==!1&&i.push(ff.configure(this.options.text)),this.options.underline!==!1&&i.push(hf.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&i.push(Af.configure((r=this.options)==null?void 0:r.trailingNode)),i}});var Sk=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Rf=$.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:n}){return["img",D(this.options.HTMLAttributes,n)]},parseMarkdown:(n,e)=>e.createNode("image",{src:n.href,title:n.title,alt:n.text}),renderMarkdown:n=>{var e,t,r,i,s,o;let l=(t=(e=n.attrs)==null?void 0:e.src)!=null?t:"",a=(i=(r=n.attrs)==null?void 0:r.alt)!=null?i:"",c=(o=(s=n.attrs)==null?void 0:s.title)!=null?o:"";return c?`![${a}](${l} "${c}")`:`![${a}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;let{directions:n,minWidth:e,minHeight:t,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:s,HTMLAttributes:o,editor:l})=>{let a=document.createElement("img");a.draggable=!1;let c=D(this.options.HTMLAttributes,o);Object.entries(c).forEach(([f,h])=>{if(h!=null)switch(f){case"width":case"height":break;default:a.setAttribute(f,h);break}}),c.src!==null&&(a.src=c.src);let u=new Ku({element:a,editor:l,node:i,getPos:s,onResize:(f,h)=>{a.style.width=`${f}px`,a.style.height=`${h}px`},onCommit:(f,h)=>{let p=s();p!==void 0&&this.editor.chain().setNodeSelection(p).updateAttributes(this.name,{width:f,height:h}).run()},onUpdate:(f,h,p)=>f.type===i.type,options:{directions:n,min:{width:e,height:t},preserveAspectRatio:r===!0}}),d=u.dom;return d.style.visibility="hidden",d.style.pointerEvents="none",a.onload=()=>{d.style.visibility="",d.style.pointerEvents=""},u}},addCommands(){return{setImage:n=>({commands:e})=>e.insertContent({type:this.name,attrs:n})}},addInputRules(){return[Gr({find:Sk,type:this.type,getAttributes:n=>{let[,,e,t,r]=n;return{src:t,alt:e,title:r}}})]}});function wk({element:n,content:e,onUpdate:t,onSelectionUpdate:r}){return new ju({element:n,extensions:[Of,Rf],content:e||"",onUpdate:({editor:s})=>{t&&t(s)},onSelectionUpdate:({editor:s})=>{r&&r(s)},onTransaction:({editor:s})=>{r&&r(s)}})}window.StompingEditor={createEditor:wk};})(); diff --git a/src/public/admin-js/folders.js b/src/public/admin-js/folders.js new file mode 100644 index 0000000..eb55e04 --- /dev/null +++ b/src/public/admin-js/folders.js @@ -0,0 +1,57 @@ +(function () { + async function api(method, url, body) { + const res = await fetch(url, { + method, + headers: body ? { 'Content-Type': 'application/json' } : undefined, + body: body ? JSON.stringify(body) : undefined, + }); + const data = await res.json().catch(() => ({})); + if (!res.ok) throw new Error(data.error || res.statusText); + return data; + } + + document.querySelectorAll('#folder-table tbody tr').forEach(function (row) { + const id = row.dataset.id; + + row.querySelector('.f-save').addEventListener('click', async function () { + try { + await api('PUT', '/api/admin/folders/' + id, { + name: row.querySelector('.f-name').value, + parent_id: row.querySelector('.f-parent').value || null, + display_order: Number(row.querySelector('.f-order').value), + }); + window.location.reload(); + } catch (err) { + alert('Save failed: ' + err.message); + } + }); + + row.querySelector('.f-delete').addEventListener('click', async function () { + if (!confirm('Delete this folder?')) return; + try { + await api('DELETE', '/api/admin/folders/' + id); + window.location.reload(); + } catch (err) { + alert('Delete failed: ' + err.message); + } + }); + }); + + document.getElementById('create-folder').addEventListener('click', async function () { + const statusEl = document.getElementById('create-status'); + statusEl.textContent = ''; + statusEl.className = 'status-msg'; + try { + await api('POST', '/api/admin/folders', { + slug: document.getElementById('new-slug').value.trim(), + name: document.getElementById('new-name').value.trim(), + parent_id: document.getElementById('new-parent').value || null, + display_order: Number(document.getElementById('new-order').value), + }); + window.location.reload(); + } catch (err) { + statusEl.textContent = err.message; + statusEl.className = 'status-msg error'; + } + }); +})(); diff --git a/src/public/admin-js/stories.js b/src/public/admin-js/stories.js new file mode 100644 index 0000000..ed87bfb --- /dev/null +++ b/src/public/admin-js/stories.js @@ -0,0 +1,35 @@ +(function () { + async function api(method, url, body) { + const res = await fetch(url, { + method, + headers: body ? { 'Content-Type': 'application/json' } : undefined, + body: body ? JSON.stringify(body) : undefined, + }); + const data = await res.json().catch(() => ({})); + if (!res.ok) throw new Error(data.error || res.statusText); + return data; + } + + document.querySelectorAll('#story-table tbody tr').forEach(function (row) { + const id = row.dataset.id; + + row.querySelector('.s-toggle').addEventListener('click', async function (e) { + try { + await api('PATCH', '/api/admin/stories/' + id + '/status', { status: e.target.dataset.status }); + window.location.reload(); + } catch (err) { + alert('Failed: ' + err.message); + } + }); + + row.querySelector('.s-delete').addEventListener('click', async function () { + if (!confirm('Delete this story and all its chapters?')) return; + try { + await api('DELETE', '/api/admin/stories/' + id); + window.location.reload(); + } catch (err) { + alert('Delete failed: ' + err.message); + } + }); + }); +})(); diff --git a/src/public/admin-js/story-form.js b/src/public/admin-js/story-form.js new file mode 100644 index 0000000..586604e --- /dev/null +++ b/src/public/admin-js/story-form.js @@ -0,0 +1,83 @@ +(function () { + var storyId = document.body.dataset.storyId || null; + + async function api(method, url, body) { + const res = await fetch(url, { + method, + headers: body ? { 'Content-Type': 'application/json' } : undefined, + body: body ? JSON.stringify(body) : undefined, + }); + const data = await res.json().catch(() => ({})); + if (!res.ok) throw new Error(data.error || res.statusText); + return data; + } + + function checkedValues(selector) { + return Array.prototype.map.call(document.querySelectorAll(selector + ':checked'), function (el) { return el.value; }); + } + + document.getElementById('story-form').addEventListener('submit', async function (e) { + e.preventDefault(); + const statusEl = document.getElementById('save-status'); + statusEl.textContent = ''; + statusEl.className = 'status-msg'; + + const body = { + slug: document.getElementById('slug').value.trim(), + title: document.getElementById('title').value.trim(), + subtitle: document.getElementById('subtitle').value, + summary: document.getElementById('summary').value, + folder_id: document.getElementById('folder_id').value || null, + story_type: document.getElementById('story_type').value, + content_rating: document.getElementById('content_rating').value, + serial_status: document.getElementById('serial_status').value || null, + badges: document.getElementById('badges').value.split(',').map(function (s) { return s.trim(); }).filter(Boolean), + cover_url: document.getElementById('cover_url').value, + explicit_tags: checkedValues('.tag-explicit'), + general_tags: checkedValues('.tag-general'), + display_order: Number(document.getElementById('display_order').value), + chronological_order: document.getElementById('chronological_order').value || null, + author_user_id: Number(document.getElementById('author_user_id').value), + }; + + try { + if (storyId) { + await api('PUT', '/api/admin/stories/' + storyId, body); + statusEl.textContent = 'Saved.'; + statusEl.className = 'status-msg ok'; + } else { + const created = await api('POST', '/api/admin/stories', body); + window.location.href = '/admin/stories/' + created._id; + } + } catch (err) { + statusEl.textContent = err.message; + statusEl.className = 'status-msg error'; + } + }); + + var chapterBody = document.getElementById('chapter-table-body'); + if (chapterBody) { + chapterBody.querySelectorAll('tr').forEach(function (row) { + var cid = row.dataset.id; + + row.querySelector('.c-toggle').addEventListener('click', async function (e) { + try { + await api('PATCH', '/api/admin/stories/' + storyId + '/chapters/' + cid + '/status', { status: e.target.dataset.status }); + window.location.reload(); + } catch (err) { + alert('Failed: ' + err.message); + } + }); + + row.querySelector('.c-delete').addEventListener('click', async function () { + if (!confirm('Delete this chapter?')) return; + try { + await api('DELETE', '/api/admin/stories/' + storyId + '/chapters/' + cid); + window.location.reload(); + } catch (err) { + alert('Delete failed: ' + err.message); + } + }); + }); + } +})(); diff --git a/src/public/admin-js/tags.js b/src/public/admin-js/tags.js new file mode 100644 index 0000000..26896a1 --- /dev/null +++ b/src/public/admin-js/tags.js @@ -0,0 +1,57 @@ +(function () { + async function api(method, url, body) { + const res = await fetch(url, { + method, + headers: body ? { 'Content-Type': 'application/json' } : undefined, + body: body ? JSON.stringify(body) : undefined, + }); + const data = await res.json().catch(() => ({})); + if (!res.ok) throw new Error(data.error || res.statusText); + return data; + } + + document.querySelectorAll('#tag-table tbody tr').forEach(function (row) { + const id = row.dataset.id; + + row.querySelector('.t-save').addEventListener('click', async function () { + try { + await api('PUT', '/api/admin/tags/' + id, { + label: row.querySelector('.t-label').value, + kind: row.querySelector('.t-kind').value, + description: row.querySelector('.t-description').value, + }); + window.location.reload(); + } catch (err) { + alert('Save failed: ' + err.message); + } + }); + + row.querySelector('.t-delete').addEventListener('click', async function () { + if (!confirm('Delete this tag?')) return; + try { + await api('DELETE', '/api/admin/tags/' + id); + window.location.reload(); + } catch (err) { + alert('Delete failed: ' + err.message); + } + }); + }); + + document.getElementById('create-tag').addEventListener('click', async function () { + const statusEl = document.getElementById('create-status'); + statusEl.textContent = ''; + statusEl.className = 'status-msg'; + try { + await api('POST', '/api/admin/tags', { + slug: document.getElementById('new-slug').value.trim(), + label: document.getElementById('new-label').value.trim(), + kind: document.getElementById('new-kind').value, + description: document.getElementById('new-description').value, + }); + window.location.reload(); + } catch (err) { + statusEl.textContent = err.message; + statusEl.className = 'status-msg error'; + } + }); +})(); diff --git a/src/public/silent-auth.js b/src/public/silent-auth.js new file mode 100644 index 0000000..d1303ff --- /dev/null +++ b/src/public/silent-auth.js @@ -0,0 +1,13 @@ +// Silent SSO check — if the visitor already has a session at auth.agwol.com +// (from another AGWOL site), recognize them here too without an explicit +// click. A top-level redirect is required (not a hidden iframe): the identity +// cookie is SameSite=Lax, scoped to .agwol.com, and stomping.me is a +// different site, so it's only sent on real top-level navigation. Anonymous +// visitors get bounced through and straight back (prompt=none never shows a +// login form), landing on the same page with nothing changed. Runs at most +// once per tab, so a failed check doesn't loop. +(function () { + if (sessionStorage.getItem('stompingSilentAuthDone')) return; + sessionStorage.setItem('stompingSilentAuthDone', '1'); + window.location.href = '/auth/login?silent=1&returnTo=' + encodeURIComponent(window.location.pathname + window.location.search); +})(); diff --git a/src/routes/adminChapters.js b/src/routes/adminChapters.js new file mode 100644 index 0000000..e6d6702 --- /dev/null +++ b/src/routes/adminChapters.js @@ -0,0 +1,195 @@ +// adminChapters.js — chapter CRUD (TipTap body) + publish toggle, +// admin.content gated (design-018 §2.3/§6) +'use strict'; + +const express = require('express'); +const { ObjectId } = require('mongodb'); +const { getDb } = require('../config/mongo'); +const { normalizeChapter } = require('../lib/normalize'); +const { recomputeStoryWordCount } = require('../lib/storyAggregate'); +const { requireAdminContent } = require('./auth'); + +const router = express.Router(); + +function parseId(raw) { + try { + return new ObjectId(raw); + } catch { + return null; + } +} + +async function loadStory(db, sid) { + const storyId = parseId(sid); + if (!storyId) return null; + return db.collection('stories').findOne({ _id: storyId }); +} + +router.get('/api/admin/stories/:sid/chapters', requireAdminContent, async (req, res) => { + try { + const story = await loadStory(getDb(), req.params.sid); + if (!story) return res.status(404).json({ error: 'story not found' }); + + const chapters = await getDb().collection('chapters') + .find({ story_id: story._id }, { projection: { body_json: 0 } }) + .sort({ display_order: 1 }) + .toArray(); + res.json(chapters); + } catch (err) { + console.error('[chapters] list', err.message); + res.status(500).json({ error: 'internal' }); + } +}); + +router.get('/api/admin/stories/:sid/chapters/:cid', requireAdminContent, async (req, res) => { + try { + const story = await loadStory(getDb(), req.params.sid); + if (!story) return res.status(404).json({ error: 'story not found' }); + + const cid = parseId(req.params.cid); + if (!cid) return res.status(400).json({ error: 'invalid id' }); + + const chapter = await getDb().collection('chapters').findOne({ _id: cid, story_id: story._id }); + if (!chapter) return res.status(404).json({ error: 'not found' }); + res.json(chapter); + } catch (err) { + console.error('[chapters] get one', err.message); + res.status(500).json({ error: 'internal' }); + } +}); + +router.post('/api/admin/stories/:sid/chapters', requireAdminContent, async (req, res) => { + try { + const db = getDb(); + const story = await loadStory(db, req.params.sid); + if (!story) return res.status(404).json({ error: 'story not found' }); + + const { slug } = req.body; + if (!slug || !/^[a-z0-9-]+$/.test(slug)) { + return res.status(400).json({ error: 'slug required (lowercase letters, digits, hyphens only)' }); + } + if (!req.body.title || !String(req.body.title).trim()) { + return res.status(400).json({ error: 'title required' }); + } + + const normalized = normalizeChapter({ ...req.body, story_id: story._id }); + const now = new Date(); + const doc = { ...normalized, created_at: now, updated_at: now }; + const result = await db.collection('chapters').insertOne(doc); + + if (doc.status === 'published') await recomputeStoryWordCount(db, story._id); + + res.status(201).json({ ...doc, _id: result.insertedId }); + } catch (err) { + if (err.code === 11000) return res.status(409).json({ error: 'a chapter with that slug already exists on this story' }); + console.error('[chapters] create', err.message); + res.status(500).json({ error: 'internal' }); + } +}); + +// slug/status/published_at are not editable here — status has its own +// publish-toggle endpoint below, matching the story-level convention. +router.put('/api/admin/stories/:sid/chapters/:cid', requireAdminContent, async (req, res) => { + try { + const db = getDb(); + const story = await loadStory(db, req.params.sid); + if (!story) return res.status(404).json({ error: 'story not found' }); + + const cid = parseId(req.params.cid); + if (!cid) return res.status(400).json({ error: 'invalid id' }); + + const existing = await db.collection('chapters').findOne({ _id: cid, story_id: story._id }); + if (!existing) return res.status(404).json({ error: 'not found' }); + + if (!req.body.title || !String(req.body.title).trim()) { + return res.status(400).json({ error: 'title required' }); + } + + const normalized = normalizeChapter({ ...req.body, story_id: story._id, slug: existing.slug, status: existing.status }); + + const after = await db.collection('chapters').findOneAndUpdate( + { _id: cid }, + { $set: { + title: normalized.title, + display_order: normalized.display_order, + body_json: normalized.body_json, + body_html: normalized.body_html, + note_top: normalized.note_top, + note_bottom: normalized.note_bottom, + word_count: normalized.word_count, + updated_at: new Date(), + } }, + { returnDocument: 'after' } + ); + + if (after.status === 'published') await recomputeStoryWordCount(db, story._id); + + res.json(after); + } catch (err) { + console.error('[chapters] update', err.message); + res.status(500).json({ error: 'internal' }); + } +}); + +// Chapters publish individually (§2.3). published_at is set once, on first +// publish, same rule as the story-level toggle. +router.patch('/api/admin/stories/:sid/chapters/:cid/status', requireAdminContent, async (req, res) => { + try { + const { status } = req.body; + if (status !== 'draft' && status !== 'published') { + return res.status(400).json({ error: 'status must be draft or published' }); + } + + const db = getDb(); + const story = await loadStory(db, req.params.sid); + if (!story) return res.status(404).json({ error: 'story not found' }); + + const cid = parseId(req.params.cid); + if (!cid) return res.status(400).json({ error: 'invalid id' }); + + const existing = await db.collection('chapters').findOne({ _id: cid, story_id: story._id }); + if (!existing) return res.status(404).json({ error: 'not found' }); + + const set = { status, updated_at: new Date() }; + if (status === 'published' && !existing.published_at) { + set.published_at = new Date(); + } + + const after = await db.collection('chapters').findOneAndUpdate( + { _id: cid }, + { $set: set }, + { returnDocument: 'after' } + ); + + await recomputeStoryWordCount(db, story._id); + + res.json(after); + } catch (err) { + console.error('[chapters] status toggle', err.message); + res.status(500).json({ error: 'internal' }); + } +}); + +router.delete('/api/admin/stories/:sid/chapters/:cid', requireAdminContent, async (req, res) => { + try { + const db = getDb(); + const story = await loadStory(db, req.params.sid); + if (!story) return res.status(404).json({ error: 'story not found' }); + + const cid = parseId(req.params.cid); + if (!cid) return res.status(400).json({ error: 'invalid id' }); + + const existing = await db.collection('chapters').findOne({ _id: cid, story_id: story._id }); + if (!existing) return res.status(404).json({ error: 'not found' }); + + await db.collection('chapters').deleteOne({ _id: cid }); + await recomputeStoryWordCount(db, story._id); + + res.json({ deleted: req.params.cid }); + } catch (err) { + console.error('[chapters] delete', err.message); + res.status(500).json({ error: 'internal' }); + } +}); + +module.exports = router; diff --git a/src/routes/adminFolders.js b/src/routes/adminFolders.js new file mode 100644 index 0000000..1287e06 --- /dev/null +++ b/src/routes/adminFolders.js @@ -0,0 +1,129 @@ +// adminFolders.js — folder CRUD, admin.content gated (design-018 §3/§6 Phase 3) +'use strict'; + +const express = require('express'); +const { ObjectId } = require('mongodb'); +const { getDb } = require('../config/mongo'); +const { normalizeFolder } = require('../lib/normalize'); +const { wouldCreateCycle } = require('../lib/folderTree'); +const { requireAdminContent } = require('./auth'); + +const router = express.Router(); + +function parseId(raw) { + try { + return new ObjectId(raw); + } catch { + return null; + } +} + +router.get('/api/admin/folders', requireAdminContent, async (req, res) => { + try { + const folders = await getDb().collection('folders') + .find({}) + .sort({ parent_id: 1, display_order: 1 }) + .toArray(); + res.json(folders); + } catch (err) { + console.error('[folders] list', err.message); + res.status(500).json({ error: 'internal' }); + } +}); + +router.post('/api/admin/folders', requireAdminContent, async (req, res) => { + try { + const { slug } = req.body; + if (!slug || !/^[a-z0-9-]+$/.test(slug)) { + return res.status(400).json({ error: 'slug required (lowercase letters, digits, hyphens only)' }); + } + if (!req.body.name || !String(req.body.name).trim()) { + return res.status(400).json({ error: 'name required' }); + } + + let parentId = null; + if (req.body.parent_id) { + parentId = parseId(req.body.parent_id); + if (!parentId) return res.status(400).json({ error: 'invalid parent_id' }); + const parent = await getDb().collection('folders').findOne({ _id: parentId }); + if (!parent) return res.status(400).json({ error: 'parent folder not found' }); + } + + const now = new Date(); + const doc = { + ...normalizeFolder({ ...req.body, parent_id: parentId }), + created_at: now, + updated_at: now, + }; + const result = await getDb().collection('folders').insertOne(doc); + res.status(201).json({ ...doc, _id: result.insertedId }); + } catch (err) { + if (err.code === 11000) return res.status(409).json({ error: 'slug already exists' }); + console.error('[folders] create', err.message); + res.status(500).json({ error: 'internal' }); + } +}); + +// slug is unique/permanent (§2.1) — not editable here, matches the +// established "update, slug is permanent" convention (castRoutes.js). +router.put('/api/admin/folders/:id', requireAdminContent, async (req, res) => { + try { + const id = parseId(req.params.id); + if (!id) return res.status(400).json({ error: 'invalid id' }); + + const existing = await getDb().collection('folders').findOne({ _id: id }); + if (!existing) return res.status(404).json({ error: 'not found' }); + + if (!req.body.name || !String(req.body.name).trim()) { + return res.status(400).json({ error: 'name required' }); + } + + let parentId = null; + if (req.body.parent_id) { + parentId = parseId(req.body.parent_id); + if (!parentId) return res.status(400).json({ error: 'invalid parent_id' }); + const parent = await getDb().collection('folders').findOne({ _id: parentId }); + if (!parent) return res.status(400).json({ error: 'parent folder not found' }); + + if (await wouldCreateCycle(getDb(), id, parentId)) { + return res.status(400).json({ error: 'that move would create a folder cycle' }); + } + } + + const normalized = normalizeFolder({ ...req.body, slug: existing.slug, parent_id: parentId }); + const after = await getDb().collection('folders').findOneAndUpdate( + { _id: id }, + { $set: { name: normalized.name, parent_id: normalized.parent_id, display_order: normalized.display_order, updated_at: new Date() } }, + { returnDocument: 'after' } + ); + res.json(after); + } catch (err) { + console.error('[folders] update', err.message); + res.status(500).json({ error: 'internal' }); + } +}); + +// Conservative delete — no cascade. Must be empty of child folders and stories. +router.delete('/api/admin/folders/:id', requireAdminContent, async (req, res) => { + try { + const id = parseId(req.params.id); + if (!id) return res.status(400).json({ error: 'invalid id' }); + + const existing = await getDb().collection('folders').findOne({ _id: id }); + if (!existing) return res.status(404).json({ error: 'not found' }); + + const childFolder = await getDb().collection('folders').findOne({ parent_id: id }); + if (childFolder) return res.status(409).json({ error: 'folder has child folders — move or delete them first' }); + + const childStory = await getDb().collection('stories').findOne({ folder_id: id }); + if (childStory) return res.status(409).json({ error: 'folder has stories in it — move or delete them first' }); + + await getDb().collection('folders').deleteOne({ _id: id }); + res.json({ deleted: req.params.id }); + } catch (err) { + console.error('[folders] delete', err.message); + res.status(500).json({ error: 'internal' }); + } +}); + +module.exports = router; diff --git a/src/routes/adminPages.js b/src/routes/adminPages.js new file mode 100644 index 0000000..a3d38c7 --- /dev/null +++ b/src/routes/adminPages.js @@ -0,0 +1,123 @@ +// adminPages.js — admin page routes (design-018 §3), gated admin.content +// from birth via requireAdminContentPage (redirect-to-login / 403 page, +// browser-navigation-friendly — the JSON APIs in adminFolders/Tags/Stories/ +// Chapters.js use the 401/403-JSON requireAdminContent instead). +'use strict'; + +const express = require('express'); +const { ObjectId } = require('mongodb'); +const { getDb } = require('../config/mongo'); +const { buildFolderTree } = require('../lib/folderTree'); +const { requireAdminContentPage } = require('./auth'); + +const router = express.Router(); + +function parseId(raw) { + try { + return new ObjectId(raw); + } catch { + return null; + } +} + +router.get('/admin', requireAdminContentPage, (req, res) => { + res.render('admin/dashboard', { user: req.user }); +}); + +router.get('/admin/folders', requireAdminContentPage, async (req, res) => { + try { + const raw = await getDb().collection('folders').find({}).toArray(); + res.render('admin/folders', { folders: buildFolderTree(raw) }); + } catch (err) { + console.error('[admin/folders] page', err.message); + res.status(500).send('Something went wrong.'); + } +}); + +router.get('/admin/tags', requireAdminContentPage, async (req, res) => { + try { + const tags = await getDb().collection('tags').find({}).sort({ kind: 1, slug: 1 }).toArray(); + res.render('admin/tags', { tags }); + } catch (err) { + console.error('[admin/tags] page', err.message); + res.status(500).send('Something went wrong.'); + } +}); + +router.get('/admin/stories', requireAdminContentPage, async (req, res) => { + try { + const stories = await getDb().collection('stories').find({}).sort({ updated_at: -1 }).toArray(); + res.render('admin/stories', { stories }); + } catch (err) { + console.error('[admin/stories] page', err.message); + res.status(500).send('Something went wrong.'); + } +}); + +router.get('/admin/stories/new', requireAdminContentPage, async (req, res) => { + try { + const db = getDb(); + const [rawFolders, tags] = await Promise.all([ + db.collection('folders').find({}).toArray(), + db.collection('tags').find({}).sort({ label: 1 }).toArray(), + ]); + res.render('admin/story-form', { + story: null, + chapters: [], + folders: buildFolderTree(rawFolders), + explicitTags: tags.filter(t => t.kind === 'explicit'), + generalTags: tags.filter(t => t.kind === 'general'), + currentUserId: req.user.id, + }); + } catch (err) { + console.error('[admin/stories/new] page', err.message); + res.status(500).send('Something went wrong.'); + } +}); + +router.get('/admin/stories/:id', requireAdminContentPage, async (req, res) => { + try { + const id = parseId(req.params.id); + if (!id) return res.status(404).send('Not found'); + + const db = getDb(); + const story = await db.collection('stories').findOne({ _id: id }); + if (!story) return res.status(404).send('Not found'); + + const [rawFolders, tags, chapters] = await Promise.all([ + db.collection('folders').find({}).toArray(), + db.collection('tags').find({}).sort({ label: 1 }).toArray(), + db.collection('chapters').find({ story_id: id }, { projection: { body_json: 0 } }).sort({ display_order: 1 }).toArray(), + ]); + + res.render('admin/story-form', { + story, + chapters, + folders: buildFolderTree(rawFolders), + explicitTags: tags.filter(t => t.kind === 'explicit'), + generalTags: tags.filter(t => t.kind === 'general'), + currentUserId: req.user.id, + }); + } catch (err) { + console.error('[admin/stories/:id] page', err.message); + res.status(500).send('Something went wrong.'); + } +}); + +router.get('/admin/stories/:id/chapters/new', requireAdminContentPage, async (req, res) => { + const id = parseId(req.params.id); + if (!id) return res.status(404).send('Not found'); + const story = await getDb().collection('stories').findOne({ _id: id }); + if (!story) return res.status(404).send('Not found'); + res.render('admin/chapter-editor', { storyId: req.params.id, chapterId: null }); +}); + +router.get('/admin/stories/:id/chapters/:cid', requireAdminContentPage, async (req, res) => { + const id = parseId(req.params.id); + if (!id) return res.status(404).send('Not found'); + const story = await getDb().collection('stories').findOne({ _id: id }); + if (!story) return res.status(404).send('Not found'); + res.render('admin/chapter-editor', { storyId: req.params.id, chapterId: req.params.cid }); +}); + +module.exports = router; diff --git a/src/routes/adminStories.js b/src/routes/adminStories.js new file mode 100644 index 0000000..9a91381 --- /dev/null +++ b/src/routes/adminStories.js @@ -0,0 +1,218 @@ +// adminStories.js — story CRUD + publish toggle, admin.content gated (design-018 §2.2/§6) +'use strict'; + +const express = require('express'); +const { ObjectId } = require('mongodb'); +const { getDb } = require('../config/mongo'); +const { normalizeStory } = require('../lib/normalize'); +const { requireAdminContent } = require('./auth'); + +const router = express.Router(); + +function parseId(raw) { + try { + return new ObjectId(raw); + } catch { + return null; + } +} + +// Tag slugs referenced by a story must exist in the curated vocabulary, and +// under the matching kind — stories don't get to invent tags inline. +async function validateTagSlugs(db, slugs, kind) { + if (!slugs.length) return true; + const count = await db.collection('tags').countDocuments({ slug: { $in: slugs }, kind }); + return count === slugs.length; +} + +router.get('/api/admin/stories', requireAdminContent, async (req, res) => { + try { + const stories = await getDb().collection('stories') + .find({}) + .sort({ folder_id: 1, display_order: 1 }) + .toArray(); + res.json(stories); + } catch (err) { + console.error('[stories] list', err.message); + res.status(500).json({ error: 'internal' }); + } +}); + +router.get('/api/admin/stories/:id', requireAdminContent, async (req, res) => { + try { + const id = parseId(req.params.id); + if (!id) return res.status(400).json({ error: 'invalid id' }); + const story = await getDb().collection('stories').findOne({ _id: id }); + if (!story) return res.status(404).json({ error: 'not found' }); + res.json(story); + } catch (err) { + console.error('[stories] get one', err.message); + res.status(500).json({ error: 'internal' }); + } +}); + +router.post('/api/admin/stories', requireAdminContent, async (req, res) => { + try { + const { slug } = req.body; + if (!slug || !/^[a-z0-9-]+$/.test(slug)) { + return res.status(400).json({ error: 'slug required (lowercase letters, digits, hyphens only)' }); + } + if (!req.body.title || !String(req.body.title).trim()) { + return res.status(400).json({ error: 'title required' }); + } + + const db = getDb(); + + let folderId = null; + if (req.body.folder_id) { + folderId = parseId(req.body.folder_id); + if (!folderId) return res.status(400).json({ error: 'invalid folder_id' }); + if (!(await db.collection('folders').findOne({ _id: folderId }))) { + return res.status(400).json({ error: 'folder not found' }); + } + } + + const normalized = normalizeStory({ + ...req.body, + folder_id: folderId, + author_user_id: req.body.author_user_id ?? req.user.id, + }); + + if (!(await validateTagSlugs(db, normalized.explicit_tags, 'explicit'))) { + return res.status(400).json({ error: 'one or more explicit_tags are not valid explicit tags' }); + } + if (!(await validateTagSlugs(db, normalized.general_tags, 'general'))) { + return res.status(400).json({ error: 'one or more general_tags are not valid general tags' }); + } + + const now = new Date(); + const doc = { ...normalized, created_at: now, updated_at: now }; + const result = await db.collection('stories').insertOne(doc); + res.status(201).json({ ...doc, _id: result.insertedId }); + } catch (err) { + if (err.code === 11000) return res.status(409).json({ error: 'slug already exists' }); + console.error('[stories] create', err.message); + res.status(500).json({ error: 'internal' }); + } +}); + +// slug is unique/permanent, status/published_at are owned by the publish-toggle +// endpoint below, word_count/rating_* are derived — none are editable here. +router.put('/api/admin/stories/:id', requireAdminContent, async (req, res) => { + try { + const id = parseId(req.params.id); + if (!id) return res.status(400).json({ error: 'invalid id' }); + + const db = getDb(); + const existing = await db.collection('stories').findOne({ _id: id }); + if (!existing) return res.status(404).json({ error: 'not found' }); + + if (!req.body.title || !String(req.body.title).trim()) { + return res.status(400).json({ error: 'title required' }); + } + + let folderId = null; + if (req.body.folder_id) { + folderId = parseId(req.body.folder_id); + if (!folderId) return res.status(400).json({ error: 'invalid folder_id' }); + if (!(await db.collection('folders').findOne({ _id: folderId }))) { + return res.status(400).json({ error: 'folder not found' }); + } + } + + const normalized = normalizeStory({ + ...req.body, + slug: existing.slug, + folder_id: folderId, + author_user_id: req.body.author_user_id ?? existing.author_user_id, + }); + + if (!(await validateTagSlugs(db, normalized.explicit_tags, 'explicit'))) { + return res.status(400).json({ error: 'one or more explicit_tags are not valid explicit tags' }); + } + if (!(await validateTagSlugs(db, normalized.general_tags, 'general'))) { + return res.status(400).json({ error: 'one or more general_tags are not valid general tags' }); + } + + const after = await db.collection('stories').findOneAndUpdate( + { _id: id }, + { $set: { + folder_id: normalized.folder_id, + title: normalized.title, + subtitle: normalized.subtitle, + badges: normalized.badges, + summary: normalized.summary, + cover_url: normalized.cover_url, + story_type: normalized.story_type, + content_rating: normalized.content_rating, + explicit_tags: normalized.explicit_tags, + general_tags: normalized.general_tags, + serial_status: normalized.serial_status, + display_order: normalized.display_order, + chronological_order: normalized.chronological_order, + author_user_id: normalized.author_user_id, + updated_at: new Date(), + } }, + { returnDocument: 'after' } + ); + res.json(after); + } catch (err) { + console.error('[stories] update', err.message); + res.status(500).json({ error: 'internal' }); + } +}); + +// published_at is set once, on first publish (§2.2: "release-order sort +// key") — unpublishing and republishing later does not move it. +router.patch('/api/admin/stories/:id/status', requireAdminContent, async (req, res) => { + try { + const { status } = req.body; + if (status !== 'draft' && status !== 'published') { + return res.status(400).json({ error: 'status must be draft or published' }); + } + + const id = parseId(req.params.id); + if (!id) return res.status(400).json({ error: 'invalid id' }); + + const db = getDb(); + const existing = await db.collection('stories').findOne({ _id: id }); + if (!existing) return res.status(404).json({ error: 'not found' }); + + const set = { status, updated_at: new Date() }; + if (status === 'published' && !existing.published_at) { + set.published_at = new Date(); + } + + const after = await db.collection('stories').findOneAndUpdate( + { _id: existing._id }, + { $set: set }, + { returnDocument: 'after' } + ); + res.json(after); + } catch (err) { + console.error('[stories] status toggle', err.message); + res.status(500).json({ error: 'internal' }); + } +}); + +// Cascades to the story's chapters — they have no independent meaning +// without their parent story. +router.delete('/api/admin/stories/:id', requireAdminContent, async (req, res) => { + try { + const id = parseId(req.params.id); + if (!id) return res.status(400).json({ error: 'invalid id' }); + + const db = getDb(); + const existing = await db.collection('stories').findOne({ _id: id }); + if (!existing) return res.status(404).json({ error: 'not found' }); + + await db.collection('chapters').deleteMany({ story_id: id }); + await db.collection('stories').deleteOne({ _id: id }); + res.json({ deleted: req.params.id }); + } catch (err) { + console.error('[stories] delete', err.message); + res.status(500).json({ error: 'internal' }); + } +}); + +module.exports = router; diff --git a/src/routes/adminTags.js b/src/routes/adminTags.js new file mode 100644 index 0000000..da51f0c --- /dev/null +++ b/src/routes/adminTags.js @@ -0,0 +1,95 @@ +// adminTags.js — curated tag vocabulary CRUD, admin.content gated (design-018 §2.4/§6) +'use strict'; + +const express = require('express'); +const { ObjectId } = require('mongodb'); +const { getDb } = require('../config/mongo'); +const { normalizeTag } = require('../lib/normalize'); +const { requireAdminContent } = require('./auth'); + +const router = express.Router(); + +function parseId(raw) { + try { + return new ObjectId(raw); + } catch { + return null; + } +} + +router.get('/api/admin/tags', requireAdminContent, async (req, res) => { + try { + const tags = await getDb().collection('tags').find({}).sort({ kind: 1, slug: 1 }).toArray(); + res.json(tags); + } catch (err) { + console.error('[tags] list', err.message); + res.status(500).json({ error: 'internal' }); + } +}); + +router.post('/api/admin/tags', requireAdminContent, async (req, res) => { + try { + const normalized = normalizeTag(req.body); + if (!normalized.slug || !/^[a-z0-9-]+$/.test(normalized.slug)) { + return res.status(400).json({ error: 'slug required (lowercase letters, digits, hyphens only)' }); + } + if (!normalized.label) return res.status(400).json({ error: 'label required' }); + + const now = new Date(); + const doc = { ...normalized, created_at: now, updated_at: now }; + const result = await getDb().collection('tags').insertOne(doc); + res.status(201).json({ ...doc, _id: result.insertedId }); + } catch (err) { + if (err.code === 11000) return res.status(409).json({ error: 'slug already exists' }); + console.error('[tags] create', err.message); + res.status(500).json({ error: 'internal' }); + } +}); + +// slug is unique/permanent — not editable here. +router.put('/api/admin/tags/:id', requireAdminContent, async (req, res) => { + try { + const id = parseId(req.params.id); + if (!id) return res.status(400).json({ error: 'invalid id' }); + + const existing = await getDb().collection('tags').findOne({ _id: id }); + if (!existing) return res.status(404).json({ error: 'not found' }); + + const normalized = normalizeTag({ ...req.body, slug: existing.slug }); + if (!normalized.label) return res.status(400).json({ error: 'label required' }); + + const after = await getDb().collection('tags').findOneAndUpdate( + { _id: id }, + { $set: { label: normalized.label, kind: normalized.kind, description: normalized.description, updated_at: new Date() } }, + { returnDocument: 'after' } + ); + res.json(after); + } catch (err) { + console.error('[tags] update', err.message); + res.status(500).json({ error: 'internal' }); + } +}); + +// §2.4: deleting a tag requires it be unused. +router.delete('/api/admin/tags/:id', requireAdminContent, async (req, res) => { + try { + const id = parseId(req.params.id); + if (!id) return res.status(400).json({ error: 'invalid id' }); + + const existing = await getDb().collection('tags').findOne({ _id: id }); + if (!existing) return res.status(404).json({ error: 'not found' }); + + const inUse = await getDb().collection('stories').findOne({ + $or: [{ explicit_tags: existing.slug }, { general_tags: existing.slug }], + }); + if (inUse) return res.status(409).json({ error: 'tag is in use on at least one story' }); + + await getDb().collection('tags').deleteOne({ _id: id }); + res.json({ deleted: req.params.id }); + } catch (err) { + console.error('[tags] delete', err.message); + res.status(500).json({ error: 'internal' }); + } +}); + +module.exports = router; diff --git a/src/routes/auth.js b/src/routes/auth.js new file mode 100644 index 0000000..a47d66b --- /dev/null +++ b/src/routes/auth.js @@ -0,0 +1,281 @@ +// src/routes/auth.js — BFF OIDC client (authorization code + PKCE), design-018 §3 +'use strict'; + +const express = require('express'); +const jwt = require('jsonwebtoken'); +const crypto = require('crypto'); +const { env } = require('../config/env'); +const { getRedis } = require('../config/redis'); + +const router = express.Router(); + +const SESSION_COOKIE_NAME = 'stompingSession'; +const SESSION_COOKIE_MAX_AGE = 7 * 24 * 60 * 60 * 1000; +const SESSION_TOKEN_TYPE = 'stomping-session'; + +const OIDC_STATE_COOKIE = 'stomping_oidc_state'; +const OIDC_STATE_MAX_AGE = 5 * 60 * 1000; + +// ── Session helpers ─────────────────────────────────────────────────────────── + +function signSession(user) { + return jwt.sign( + { + type: SESSION_TOKEN_TYPE, + sub: user.id, + username: user.username, + displayName: user.displayName || user.username, + permissions: user.permissions || [], + }, + env.ACCESS_TOKEN_SECRET, + { expiresIn: '7d' } + ); +} + +function parseSession(cookieValue) { + if (!cookieValue) return null; + try { + const decoded = jwt.verify(cookieValue, env.ACCESS_TOKEN_SECRET, { algorithms: ['HS256'] }); + if (decoded.type !== SESSION_TOKEN_TYPE) return null; + return decoded; + } catch { + return null; + } +} + +function setSessionCookie(res, sessionJwt) { + res.cookie(SESSION_COOKIE_NAME, sessionJwt, { + httpOnly: true, + secure: true, + sameSite: 'lax', + maxAge: SESSION_COOKIE_MAX_AGE, + path: '/', + }); +} + +// ── PKCE helpers ────────────────────────────────────────────────────────────── + +function generateCodeVerifier() { + return crypto.randomBytes(32).toString('base64url'); +} + +function generateCodeChallenge(verifier) { + return crypto.createHash('sha256').update(verifier).digest('base64url'); +} + +// ── Session resolution — shared by requireSession and optional-auth reads ──── +// Returns the user object, or null if absent/invalid/revoked. Never rejects +// on a missing session — that's the caller's call (strict vs. optional). +async function resolveSession(req) { + const session = parseSession(req.cookies?.[SESSION_COOKIE_NAME]); + if (!session) return null; + + try { + const redis = getRedis(); + const revokedBefore = await redis.get(`access:user:revoked_before:${session.sub}`); + if (revokedBefore && session.iat < parseInt(revokedBefore, 10)) return null; + } catch (err) { + console.error('[Session] revoked_before check failed (fail-closed)', err.message); + return null; + } + + return { + id: String(session.sub), + username: session.username, + displayName: session.displayName || session.username, + permissions: session.permissions || [], + }; +} + +// ── requireSession middleware — 401 JSON, for API-style routes ─────────────── + +async function requireSession(req, res, next) { + const user = await resolveSession(req); + if (!user) return res.status(401).json({ error: 'unauthorized' }); + req.user = user; + next(); +} + +// ── optionalSession middleware — never rejects, just populates req.user ───── +// For public pages (design-018: "public reading requires no login") that still +// want to show logged-in state when a session is present. +async function optionalSession(req, res, next) { + req.user = await resolveSession(req); + next(); +} + +// ── requireAdminContent — every admin route, from birth (design-018 §3) ───── +// Scoped to admin.content (never a bare 'admin' check) — design-016 scoped- +// perm doctrine, same gate the hub cast/news admin already uses. Migrates to +// stories.write once a non-operator author exists (design-018 §7). +async function requireAdminContent(req, res, next) { + const user = await resolveSession(req); + if (!user) return res.status(401).json({ error: 'unauthorized' }); + if (!user.permissions.includes('admin.content')) { + return res.status(403).json({ error: 'forbidden' }); + } + req.user = user; + next(); +} + +// ── requireAdminContentPage — same gate, browser-navigation-friendly outcome +// (redirect to login vs. a 401 JSON blob) — for the admin page routes rather +// than their underlying JSON APIs. +async function requireAdminContentPage(req, res, next) { + const user = await resolveSession(req); + if (!user) { + return res.redirect(`/auth/login?returnTo=${encodeURIComponent(req.originalUrl)}`); + } + if (!user.permissions.includes('admin.content')) { + return res.status(403).render('admin/forbidden'); + } + req.user = user; + next(); +} + +// ── OIDC routes ─────────────────────────────────────────────────────────────── + +router.get('/auth/login', (req, res) => { + const returnTo = req.query.returnTo || '/'; + const silent = req.query.silent === '1'; + const codeVerifier = generateCodeVerifier(); + const codeChallenge = generateCodeChallenge(codeVerifier); + const state = crypto.randomBytes(16).toString('base64url'); + + const oidcState = JSON.stringify({ codeVerifier, state, returnTo, silent }); + res.cookie(OIDC_STATE_COOKIE, oidcState, { + httpOnly: true, + secure: true, + sameSite: 'lax', + maxAge: OIDC_STATE_MAX_AGE, + signed: true, + path: '/', + }); + + const params = new URLSearchParams({ + client_id: env.OIDC_CLIENT_ID, + redirect_uri: env.OIDC_REDIRECT_URI, + response_type: 'code', + scope: 'openid profile agwol:permissions', + state, + code_challenge: codeChallenge, + code_challenge_method: 'S256', + }); + if (silent) params.set('prompt', 'none'); + + return res.redirect(`${env.AUTH_PUBLIC_ORIGIN}/auth/authorize?${params.toString()}`); +}); + +// A silent check (prompt=none, auto-triggered — see public/silent-auth.js) +// failing is the ordinary outcome for an anonymous visitor: land back on the +// page they started from with no error shown, rather than an error page they +// never asked to see. An explicit, user-clicked login failure still shows one. +function failCallback(res, silent, returnTo, status, message) { + if (silent) { + const destination = returnTo?.startsWith('/') ? returnTo : '/'; + return res.redirect(302, destination); + } + return res.status(status).send(message); +} + +router.get('/auth/callback', async (req, res) => { + const { code, state, error, error_description } = req.query; + + if (!state) { + return res.status(400).send('Missing state parameter'); + } + + const rawState = req.signedCookies?.[OIDC_STATE_COOKIE]; + res.clearCookie(OIDC_STATE_COOKIE, { path: '/' }); + + if (!rawState) { + console.warn('[OIDC] Missing state cookie — possible CSRF or expired flow'); + return res.redirect('/auth/login'); + } + + let oidcState; + try { + oidcState = JSON.parse(rawState); + } catch { + console.warn('[OIDC] Malformed state cookie'); + return res.redirect('/auth/login'); + } + + if (oidcState.state !== state) { + console.warn('[OIDC] State mismatch — possible CSRF'); + return res.status(400).send('Invalid state parameter'); + } + + const { codeVerifier, returnTo, silent } = oidcState; + + if (error) { + // login_required is the expected outcome of a silent check for an + // anonymous visitor — not a real error, don't log it as one. + if (error !== 'login_required') { + console.error('[OIDC] Authorize error', error, error_description); + } + return failCallback(res, silent, returnTo, 400, `Authentication failed: ${error_description || error}`); + } + + if (!code) { + return failCallback(res, silent, returnTo, 400, 'Missing authorization code'); + } + + try { + const tokenRes = await fetch(`${env.AUTH_INTERNAL_URL}/auth/token`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + grant_type: 'authorization_code', + code, + redirect_uri: env.OIDC_REDIRECT_URI, + client_id: env.OIDC_CLIENT_ID, + client_secret: env.OIDC_CLIENT_SECRET, + code_verifier: codeVerifier, + }), + }); + + if (!tokenRes.ok) { + const errBody = await tokenRes.text(); + console.error('[OIDC] Token exchange failed', tokenRes.status, errBody); + return failCallback(res, silent, returnTo, 401, 'Authentication failed'); + } + + const tokenData = await tokenRes.json(); + const idPayload = JSON.parse( + Buffer.from(tokenData.id_token.split('.')[1], 'base64url').toString() + ); + + const sessionJwt = signSession({ + id: idPayload.sub, + username: idPayload.preferred_username, + displayName: idPayload.name || idPayload.preferred_username, + permissions: idPayload.permissions || [], + }); + + setSessionCookie(res, sessionJwt); + + const destination = returnTo?.startsWith('/') ? returnTo : '/'; + return res.redirect(302, destination); + + } catch (err) { + console.error('[OIDC] Callback error', err.message); + return failCallback(res, silent, returnTo, 500, 'Authentication error'); + } +}); + +router.get('/auth/logout', (req, res) => { + res.clearCookie(SESSION_COOKIE_NAME, { + httpOnly: true, + secure: true, + sameSite: 'lax', + path: '/', + }); + return res.redirect(302, `${env.AUTH_PUBLIC_ORIGIN}/logout`); +}); + +router.get('/auth/me', requireSession, (req, res) => { + res.json(req.user); +}); + +module.exports = { router, requireSession, optionalSession, requireAdminContent, requireAdminContentPage }; diff --git a/src/routes/index.js b/src/routes/index.js new file mode 100644 index 0000000..d1d2663 --- /dev/null +++ b/src/routes/index.js @@ -0,0 +1,10 @@ +'use strict'; + +const express = require('express'); +const router = express.Router(); + +router.get('/health', (req, res) => { + res.json({ status: 'ok', service: 'stomping.me', ts: new Date() }); +}); + +module.exports = router; diff --git a/src/routes/publicPages.js b/src/routes/publicPages.js new file mode 100644 index 0000000..61b8f22 --- /dev/null +++ b/src/routes/publicPages.js @@ -0,0 +1,148 @@ +// publicPages.js — public reader (design-018 §3/§6 Phase 4). Published-only +// throughout; draft/unknown slugs 404 identically — every lookup below +// queries {slug, status: 'published'} directly, so a draft and a nonexistent +// slug take the exact same code path to the exact same not-found response. +'use strict'; + +const express = require('express'); +const { getDb } = require('../config/mongo'); +const { buildFolderTree } = require('../lib/folderTree'); +const { optionalSession } = require('./auth'); + +const router = express.Router(); + +const LANDING_STORY_COUNT = 12; + +function resolveTagLabels(slugs, tags) { + const bySlug = new Map(tags.map(t => [t.slug, t.label])); + return (slugs || []).map(slug => ({ slug, label: bySlug.get(slug) || slug })); +} + +// Simple v1 browse filter (design-018 §5/§6 Phase 5): one tag slug via +// ?tag=, matched against either array. Scoped to whatever the page already +// scopes to (root or a specific folder) — filtering doesn't search outside it. +function tagFilterClause(tagSlug) { + if (!tagSlug) return {}; + return { $or: [{ explicit_tags: tagSlug }, { general_tags: tagSlug }] }; +} + +router.get('/', optionalSession, async (req, res) => { + try { + const db = getDb(); + const stories = await db.collection('stories') + .find({ status: 'published' }) + .sort({ published_at: -1 }) + .limit(LANDING_STORY_COUNT) + .toArray(); + res.render('site/landing', { stories, user: req.user }); + } catch (err) { + console.error('[public] landing', err.message); + res.status(500).send('Something went wrong.'); + } +}); + +router.get('/browse', optionalSession, async (req, res) => { + try { + const db = getDb(); + const activeTag = req.query.tag || null; + const [rawFolders, stories, tags] = await Promise.all([ + db.collection('folders').find({}).toArray(), + db.collection('stories') + .find({ folder_id: null, status: 'published', ...tagFilterClause(activeTag) }) + .sort({ display_order: 1 }).toArray(), + db.collection('tags').find({}).sort({ kind: 1, label: 1 }).toArray(), + ]); + const tree = buildFolderTree(rawFolders); + const topLevel = tree.filter(f => f.depth === 0); + res.render('site/browse', { folder: null, subfolders: topLevel, stories, tags, activeTag, user: req.user }); + } catch (err) { + console.error('[public] browse root', err.message); + res.status(500).send('Something went wrong.'); + } +}); + +router.get('/browse/:folderSlug', optionalSession, async (req, res) => { + try { + const db = getDb(); + const folder = await db.collection('folders').findOne({ slug: req.params.folderSlug }); + if (!folder) return res.status(404).render('site/not-found', { kind: 'folder', user: req.user }); + + let parent = null; + if (folder.parent_id) parent = await db.collection('folders').findOne({ _id: folder.parent_id }); + + const activeTag = req.query.tag || null; + const [rawFolders, stories, tags] = await Promise.all([ + db.collection('folders').find({ parent_id: folder._id }).sort({ display_order: 1 }).toArray(), + db.collection('stories') + .find({ folder_id: folder._id, status: 'published', ...tagFilterClause(activeTag) }) + .sort({ display_order: 1 }).toArray(), + db.collection('tags').find({}).sort({ kind: 1, label: 1 }).toArray(), + ]); + const subfolders = rawFolders.map(f => ({ ...f, depth: 0 })); + + res.render('site/browse', { folder, parent, subfolders, stories, tags, activeTag, user: req.user }); + } catch (err) { + console.error('[public] browse folder', err.message); + res.status(500).send('Something went wrong.'); + } +}); + +router.get('/story/:slug', optionalSession, async (req, res) => { + try { + const db = getDb(); + const story = await db.collection('stories').findOne({ slug: req.params.slug, status: 'published' }); + if (!story) return res.status(404).render('site/not-found', { kind: 'story', user: req.user }); + + const [chapters, tags] = await Promise.all([ + db.collection('chapters') + .find({ story_id: story._id, status: 'published' }, { projection: { body_json: 0 } }) + .sort({ display_order: 1 }) + .toArray(), + db.collection('tags').find({}).toArray(), + ]); + + res.render('site/story', { + story, + chapters, + singleChapter: chapters.length === 1 ? chapters[0] : null, + explicitTags: resolveTagLabels(story.explicit_tags, tags), + generalTags: resolveTagLabels(story.general_tags, tags), + user: req.user, + }); + } catch (err) { + console.error('[public] story', err.message); + res.status(500).send('Something went wrong.'); + } +}); + +router.get('/story/:storySlug/:chapterSlug', optionalSession, async (req, res) => { + try { + const db = getDb(); + const story = await db.collection('stories').findOne({ slug: req.params.storySlug, status: 'published' }); + if (!story) return res.status(404).render('site/not-found', { kind: 'story', user: req.user }); + + const chapter = await db.collection('chapters') + .findOne({ story_id: story._id, slug: req.params.chapterSlug, status: 'published' }); + if (!chapter) return res.status(404).render('site/not-found', { kind: 'chapter', user: req.user }); + + const allChapters = await db.collection('chapters') + .find({ story_id: story._id, status: 'published' }, { projection: { body_json: 0, body_html: 0 } }) + .sort({ display_order: 1 }) + .toArray(); + + const idx = allChapters.findIndex(c => String(c._id) === String(chapter._id)); + const prev = idx > 0 ? allChapters[idx - 1] : null; + const next = idx >= 0 && idx < allChapters.length - 1 ? allChapters[idx + 1] : null; + + res.render('site/chapter', { + story, chapter, prev, next, + showNav: allChapters.length > 1, + user: req.user, + }); + } catch (err) { + console.error('[public] chapter', err.message); + res.status(500).send('Something went wrong.'); + } +}); + +module.exports = router; diff --git a/src/views/admin/chapter-editor.ejs b/src/views/admin/chapter-editor.ejs new file mode 100644 index 0000000..593f990 --- /dev/null +++ b/src/views/admin/chapter-editor.ejs @@ -0,0 +1,64 @@ + + + + + Chapter editor — stomping.me admin + <%- include('../partials/siteStyles') %> + + + + <%- include('../partials/adminNav', { active: 'stories' }) %> +
+

← back to story

+

<%= chapterId ? 'Edit chapter' : 'New chapter' %>

+ +
+
+
+ + > +
+
+
+
+
+ + +
+ + + + + + + + + + + + + +
+
+ +
+ +
+ + <% if (chapterId) { %><% } %> + +
+
+
+
+ + + + diff --git a/src/views/admin/dashboard.ejs b/src/views/admin/dashboard.ejs new file mode 100644 index 0000000..fd776cc --- /dev/null +++ b/src/views/admin/dashboard.ejs @@ -0,0 +1,16 @@ + + +Admin — stomping.me<%- include('../partials/siteStyles') %> + + <%- include('../partials/adminNav', { active: 'dashboard' }) %> +
+

stomping.me admin

+

Logged in as <%= user.displayName %> (<%= user.username %>).

+ +
+ + diff --git a/src/views/admin/folders.ejs b/src/views/admin/folders.ejs new file mode 100644 index 0000000..d8dbe45 --- /dev/null +++ b/src/views/admin/folders.ejs @@ -0,0 +1,60 @@ + + +Folders — stomping.me admin<%- include('../partials/siteStyles') %> + + <%- include('../partials/adminNav', { active: 'folders' }) %> +
+

Folders

+ + + + + <% folders.forEach(f => { %> + + + + + + + + <% }) %> + +
NameSlugParentOrder
<%= f.slug %> + + + + +
+ +
+

New folder

+
+
+
+
+
+
+ + +
+
+
+ +
+
+
+ + + diff --git a/src/views/admin/forbidden.ejs b/src/views/admin/forbidden.ejs new file mode 100644 index 0000000..4732fba --- /dev/null +++ b/src/views/admin/forbidden.ejs @@ -0,0 +1,10 @@ + + +Forbidden — stomping.me admin<%- include('../partials/siteStyles') %> + +
+

403 — Forbidden

+

Your account doesn't have the admin.content permission required to use this area.

+
+ + diff --git a/src/views/admin/stories.ejs b/src/views/admin/stories.ejs new file mode 100644 index 0000000..f09b237 --- /dev/null +++ b/src/views/admin/stories.ejs @@ -0,0 +1,32 @@ + + +Stories — stomping.me admin<%- include('../partials/siteStyles') %> + + <%- include('../partials/adminNav', { active: 'stories' }) %> +
+

Stories

+

+ New story

+ + + + + <% stories.forEach(s => { %> + + + + + + + + <% }) %> + +
TitleTypeStatusWords
<%= s.title %> <%= s.slug %><%= s.story_type %><%= s.status %><%= s.word_count %> + + +
+
+ + + diff --git a/src/views/admin/story-form.ejs b/src/views/admin/story-form.ejs new file mode 100644 index 0000000..b88855c --- /dev/null +++ b/src/views/admin/story-form.ejs @@ -0,0 +1,134 @@ + + +<%= story ? 'Edit' : 'New' %> story — stomping.me admin<%- include('../partials/siteStyles') %> + + <%- include('../partials/adminNav', { active: 'stories' }) %> +
+

<%= story ? 'Edit story' : 'New story' %>

+ +
+
+
+
+ + > +
+
+
+
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+ +

Tags

+
+ + <% explicitTags.forEach(t => { %> + + <% }) %> + <% if (!explicitTags.length) { %>No explicit tags yet — add some on the Tags page.<% } %> +
+
+ + <% generalTags.forEach(t => { %> + + <% }) %> + <% if (!generalTags.length) { %>No general tags yet — add some on the Tags page.<% } %> +
+ +
+
+
+
+
+ + +
+
+
+ + <% if (story) { %> +

Chapters

+ <% if (story.story_type === 'one_shot' || story.story_type === 'bite_size') { %> +

+ This is where the actual writing goes. One-shot and bite-size stories still use a + single chapter as their content — add one below; the reader won't show a chapter + list when there's only one. +

+ <% } %> + + + + <% chapters.forEach(c => { %> + + + + + + + + <% }) %> + +
OrderTitleStatusWords
<%= c.display_order %><%= c.title %><%= c.status %><%= c.word_count %> + + +
+

+ New chapter

+ <% } %> +
+ + + diff --git a/src/views/admin/tags.ejs b/src/views/admin/tags.ejs new file mode 100644 index 0000000..112d4a9 --- /dev/null +++ b/src/views/admin/tags.ejs @@ -0,0 +1,52 @@ + + +Tags — stomping.me admin<%- include('../partials/siteStyles') %> + + <%- include('../partials/adminNav', { active: 'tags' }) %> +
+

Tags

+ + + + + <% tags.forEach(t => { %> + + + + + + + + <% }) %> + +
LabelSlugKindDescription
<%= t.slug %> + + + + +
+ +
+

New tag

+
+
+
+
+ + +
+
+
+ +
+
+
+ + + diff --git a/src/views/partials/adminNav.ejs b/src/views/partials/adminNav.ejs new file mode 100644 index 0000000..ba59df0 --- /dev/null +++ b/src/views/partials/adminNav.ejs @@ -0,0 +1,6 @@ + diff --git a/src/views/partials/siteNav.ejs b/src/views/partials/siteNav.ejs new file mode 100644 index 0000000..214395e --- /dev/null +++ b/src/views/partials/siteNav.ejs @@ -0,0 +1,9 @@ + diff --git a/src/views/partials/siteStyles.ejs b/src/views/partials/siteStyles.ejs new file mode 100644 index 0000000..e197ce0 --- /dev/null +++ b/src/views/partials/siteStyles.ejs @@ -0,0 +1,94 @@ + diff --git a/src/views/partials/story-card.ejs b/src/views/partials/story-card.ejs new file mode 100644 index 0000000..d4d8cc5 --- /dev/null +++ b/src/views/partials/story-card.ejs @@ -0,0 +1,15 @@ + + <% if (story.cover_url) { %> + + <% } else { %> +
+ <% } %> +

<%= story.title %>

+ <% if (story.subtitle) { %>
<%= story.subtitle %>
<% } %> +
+ <%= story.story_type %> + <%= story.content_rating %> + <% (story.badges || []).forEach(b => { %><%= b %><% }) %> +
+ <% if (story.summary) { %>
<%= story.summary %>
<% } %> +
diff --git a/src/views/site/browse.ejs b/src/views/site/browse.ejs new file mode 100644 index 0000000..83801dc --- /dev/null +++ b/src/views/site/browse.ejs @@ -0,0 +1,51 @@ + + +<%= folder ? folder.name : 'Browse' %> — stomping.me<%- include('../partials/siteStyles') %> + + <%- include('../partials/siteNav', { user }) %> +
+ <% if (folder) { %> +

← <%= parent ? parent.name : 'Browse' %>

+

<%= folder.name %>

+ <% } else { %> +

Browse

+ <% } %> + + <% if (subfolders.length) { %> +

Folders

+
+ <% subfolders.forEach(f => { %> + <%= f.name %> + <% }) %> +
+ <% } %> + + <% var basePath = folder ? '/browse/' + folder.slug : '/browse'; %> + <% if (tags.length) { %> +

Filter by tag

+
+ All + <% tags.forEach(t => { %> + <%= t.label %> + <% }) %> +
+ <% } %> + + <% if (stories.length) { %> +

Stories

+
+ <% stories.forEach(story => { %> + <%- include('../partials/story-card', { story }) %> + <% }) %> +
+ <% } else if (activeTag) { %> +

No stories here tagged "<%= activeTag %>".

+ <% } %> + + <% if (!subfolders.length && !stories.length && !activeTag) { %> +

Nothing here yet.

+ <% } %> +
+ + diff --git a/src/views/site/chapter.ejs b/src/views/site/chapter.ejs new file mode 100644 index 0000000..4c4d14a --- /dev/null +++ b/src/views/site/chapter.ejs @@ -0,0 +1,26 @@ + + +<%= chapter.title %> — <%= story.title %> — stomping.me<%- include('../partials/siteStyles') %> + + <%- include('../partials/siteNav', { user }) %> +
+

← <%= story.title %>

+

<%= chapter.title %>

+ + <% if (chapter.note_top) { %>
<%= chapter.note_top %>
<% } %> +
<%- chapter.body_html %>
+ <% if (chapter.note_bottom) { %>
<%= chapter.note_bottom %>
<% } %> + + <% if (showNav) { %> +
+
+ <% if (prev) { %>← <%= prev.title %><% } %> +
+
+ <% if (next) { %><%= next.title %> →<% } %> +
+
+ <% } %> +
+ + diff --git a/src/views/site/landing.ejs b/src/views/site/landing.ejs new file mode 100644 index 0000000..1b54c06 --- /dev/null +++ b/src/views/site/landing.ejs @@ -0,0 +1,19 @@ + + +stomping.me<%- include('../partials/siteStyles') %> + + <%- include('../partials/siteNav', { user }) %> +
+

Recent stories

+ <% if (!stories.length) { %> +

Nothing published yet — check back soon.

+ <% } else { %> +
+ <% stories.forEach(story => { %> + <%- include('../partials/story-card', { story }) %> + <% }) %> +
+ <% } %> +
+ + diff --git a/src/views/site/not-found.ejs b/src/views/site/not-found.ejs new file mode 100644 index 0000000..f95a282 --- /dev/null +++ b/src/views/site/not-found.ejs @@ -0,0 +1,13 @@ + + +Not found — stomping.me<%- include('../partials/siteStyles') %> + + <%- include('../partials/siteNav', { user }) %> +
+
+

Not found

+

There's nothing here.

+
+
+ + diff --git a/src/views/site/story.ejs b/src/views/site/story.ejs new file mode 100644 index 0000000..4081587 --- /dev/null +++ b/src/views/site/story.ejs @@ -0,0 +1,49 @@ + + +<%= story.title %> — stomping.me<%- include('../partials/siteStyles') %> + + <%- include('../partials/siteNav', { user }) %> +
+

<%= story.title %>

+ <% if (story.subtitle) { %>

<%= story.subtitle %>

<% } %> + +
+ <%= story.story_type %> + <%= story.content_rating %> + <% if (story.serial_status) { %><%= story.serial_status %><% } %> + <% (story.badges || []).forEach(b => { %><%= b %><% }) %> +
+ + <% if (explicitTags.length) { %> +
+ <% explicitTags.forEach(t => { %><%= t.label %><% }) %> +
+ <% } %> + <% if (generalTags.length) { %> +
+ <% generalTags.forEach(t => { %><%= t.label %><% }) %> +
+ <% } %> + + <% if (story.cover_url) { %><% } %> + <% if (story.summary) { %>

<%= story.summary %>

<% } %> + +

<%= story.word_count %> words

+ + <% if (singleChapter) { %> + <% if (singleChapter.note_top) { %>
<%= singleChapter.note_top %>
<% } %> +
<%- singleChapter.body_html %>
+ <% if (singleChapter.note_bottom) { %>
<%= singleChapter.note_bottom %>
<% } %> + <% } else if (chapters.length) { %> +

Chapters

+
+ <% chapters.forEach(c => { %> + <%= c.title %> <%= c.word_count %> words + <% }) %> +
+ <% } else { %> +

No chapters published yet.

+ <% } %> +
+ +