@surething/cockpit 1.0.186 → 1.0.187
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next-prod/BUILD_ID +1 -1
- package/.next-prod/app-path-routes-manifest.json +23 -23
- package/.next-prod/build-manifest.json +2 -2
- package/.next-prod/prerender-manifest.json +3 -3
- package/.next-prod/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/_global-error.html +2 -2
- package/.next-prod/server/app/_global-error.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next-prod/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/_not-found.html +2 -2
- package/.next-prod/server/app/_not-found.rsc +2 -2
- package/.next-prod/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next-prod/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next-prod/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/.next-prod/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next-prod/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next-prod/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next-prod/server/app/api/bash/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/chat/codex/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/chat/kimi/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/chat/ollama/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/chat/route.js +3 -3
- package/.next-prod/server/app/api/chat/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/claude-stats/route.js +1 -1
- package/.next-prod/server/app/api/claude-stats/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/commands/route.js +1 -1
- package/.next-prod/server/app/api/commands/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/comments/route.js +1 -1
- package/.next-prod/server/app/api/comments/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/db/columns/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/db/connect/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/db/disconnect/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/db/export/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/db/query/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/db/schemas/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/extension/version/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/file/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/files/blame/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/files/clipboard/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/files/copy/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/files/delete/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/files/expanded/route.js +1 -1
- package/.next-prod/server/app/api/files/expanded/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/files/index/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/files/init/route.js +1 -1
- package/.next-prod/server/app/api/files/init/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/files/paste/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/files/read/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/files/readdir/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/files/recent/route.js +1 -1
- package/.next-prod/server/app/api/files/recent/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/files/save/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/files/search/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/git/branch-diff/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/git/branches/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/git/commit-diff/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/git/commits/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/git/diff/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/git/discard/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/git/stage/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/git/status/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/git/unstage/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/git/worktree/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/global-state/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/jupyter/load/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/jupyter/save/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/jupyter/shutdown/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/lsp/definition/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/lsp/hover/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/lsp/references/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/lsp/status/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/lsp/warmup/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/mysql/columns/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/mysql/connect/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/mysql/disconnect/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/mysql/export/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/mysql/query/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/mysql/schemas/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/neo4j/connect/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/neo4j/disconnect/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/neo4j/query/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/neo4j/schema/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/note/route.js +1 -1
- package/.next-prod/server/app/api/note/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/ollama/models/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/ollama/start/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/open-cursor/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/open-vscode/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/pick-folder/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/pinned-sessions/route.js +1 -1
- package/.next-prod/server/app/api/pinned-sessions/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/project-settings/route.js +1 -1
- package/.next-prod/server/app/api/project-settings/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/project-state/route.js +1 -1
- package/.next-prod/server/app/api/project-state/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/projects/route.js +1 -1
- package/.next-prod/server/app/api/projects/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/redis/command/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/redis/connect/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/redis/delete/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/redis/disconnect/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/redis/get/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/redis/keys/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/redis/set/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/review/[id]/comments/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/review/[id]/replies/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/review/[id]/route.js +1 -1
- package/.next-prod/server/app/api/review/[id]/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/review/identify/route.js +1 -1
- package/.next-prod/server/app/api/review/identify/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/review/order/route.js +1 -1
- package/.next-prod/server/app/api/review/order/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/review/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/review/share-info/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/review/users/route.js +1 -1
- package/.next-prod/server/app/api/review/users/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/scheduled-tasks/route.js +1 -1
- package/.next-prod/server/app/api/scheduled-tasks/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/services/config/route.js +1 -1
- package/.next-prod/server/app/api/services/config/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/services/scripts/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/session/[sessionId]/fork/route.js +1 -1
- package/.next-prod/server/app/api/session/[sessionId]/fork/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/session/[sessionId]/history/route.js +1 -1
- package/.next-prod/server/app/api/session/[sessionId]/history/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/session-by-path/route.js +1 -1
- package/.next-prod/server/app/api/session-by-path/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js +1 -1
- package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/sessions/projects/route.js +1 -1
- package/.next-prod/server/app/api/sessions/projects/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/sessions/route.js +1 -1
- package/.next-prod/server/app/api/sessions/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/settings/route.js +1 -1
- package/.next-prod/server/app/api/settings/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/terminal/aliases/route.js +1 -1
- package/.next-prod/server/app/api/terminal/aliases/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/terminal/autocomplete/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/terminal/bubble-order/route.js +1 -1
- package/.next-prod/server/app/api/terminal/bubble-order/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/terminal/env/route.js +1 -1
- package/.next-prod/server/app/api/terminal/env/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/terminal/history/route.js +1 -1
- package/.next-prod/server/app/api/terminal/history/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/api/version/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/manifest.webmanifest/route_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/page.js +1 -1
- package/.next-prod/server/app/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/project/page.js +4 -4
- package/.next-prod/server/app/project/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/review/[id]/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app-paths-manifest.json +23 -23
- package/.next-prod/server/chunks/4098.js +1 -1
- package/.next-prod/server/chunks/5394.js +1 -1
- package/.next-prod/server/chunks/6062.js +1 -1
- package/.next-prod/server/chunks/7284.js +1 -1
- package/.next-prod/server/pages/404.html +2 -2
- package/.next-prod/server/pages/500.html +2 -2
- package/.next-prod/server/server-reference-manifest.json +1 -1
- package/.next-prod/static/chunks/{1593-7902218f5b10761f.js → 1593-d845ec6e5c8de67e.js} +1 -1
- package/.next-prod/static/chunks/{5493-482fc2bbb049e7a4.js → 5493-83d6a5ec42d6cbb3.js} +1 -1
- package/.next-prod/static/chunks/app/page-cc2b332242bc2c93.js +1 -0
- package/.next-prod/static/chunks/app/project/page-95039285184e0c74.js +25 -0
- package/.next-prod/static/css/bbd65867698c479b.css +3 -0
- package/.next-prod/trace +12 -12
- package/.next-prod/trace-build +1 -1
- package/dist/{chunk-VV5VMA4B.mjs → chunk-KLV3PBIZ.mjs} +17 -0
- package/dist/scheduledTasks.mjs +7 -2
- package/dist/wsServer.mjs +1 -1
- package/package.json +2 -2
- package/.next-prod/static/chunks/app/page-cc2bf3ca4c337090.js +0 -1
- package/.next-prod/static/chunks/app/project/page-62d5a8ed458279b8.js +0 -25
- package/.next-prod/static/css/1573b510894a4234.css +0 -3
- /package/.next-prod/static/{0mBqfZkcLM2Y1ikI9uxKG → Avd2f2SegjGOElSYvrTlK}/_buildManifest.js +0 -0
- /package/.next-prod/static/{0mBqfZkcLM2Y1ikI9uxKG → Avd2f2SegjGOElSYvrTlK}/_ssgManifest.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(()=>{var a={};a.id=8974,a.ids=[8974],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},1482:(a,b,c)=>{"use strict";c.d(b,{EmptyState:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({onSelectSession:a}){let{t:b}=(0,f.Bd)(),[c,g]=(0,e.useState)([]),[h,i]=(0,e.useState)({}),[j,k]=(0,e.useState)(!1),[l,m]=(0,e.useState)(null),[n,o]=(0,e.useState)(""),p=(0,e.useRef)(null);(0,e.useCallback)(async()=>{k(!0),m(null),i({});try{let a=await fetch("/api/sessions/projects");if(!a.ok)throw Error("Failed to load projects");let b=await a.json();g(b)}catch(a){m(a instanceof Error?a.message:"Unknown error")}finally{k(!1)}},[]);let q=(0,e.useCallback)(async a=>{i(b=>({...b,[a]:{...b[a],isExpanded:!0,isLoading:!0,sessions:[],error:null}}));try{let b=await fetch(`/api/sessions/projects/${encodeURIComponent(a)}`);if(!b.ok)throw Error("Failed to load sessions");let c=await b.json();i(b=>({...b,[a]:{...b[a],isLoading:!1,sessions:c}}))}catch(b){i(c=>({...c,[a]:{...c[a],isLoading:!1,error:b instanceof Error?b.message:"Unknown error"}}))}},[]),r=(0,e.useCallback)(a=>{let b=h[a];b?.isExpanded?i(b=>({...b,[a]:{...b[a],isExpanded:!1}})):b?.sessions?.length?i(b=>({...b,[a]:{...b[a],isExpanded:!0}})):q(a)},[h,q]);return(0,d.jsxs)("div",{className:"flex-1 flex flex-col bg-card",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[(0,d.jsx)("h2",{className:"text-lg font-medium text-foreground",children:b("workspace.selectProject")}),(0,d.jsx)("input",{ref:p,type:"text",placeholder:b("workspace.searchProjectPath"),value:n,onChange:a=>o(a.target.value),className:"px-3 py-1.5 text-sm border border-border rounded-lg bg-card text-foreground placeholder-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-6",children:[j&&(0,d.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-5 w-5",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:b("workspace.loadingProjects")})]})}),l&&(0,d.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,d.jsx)("div",{className:"text-sm text-red-500",children:l})}),!j&&!l&&0===c.length&&(0,d.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,d.jsx)("div",{className:"text-sm text-muted-foreground",children:b("workspace.projectNotFound")})}),!j&&!l&&(0,d.jsx)("div",{className:"space-y-2",children:c.filter(a=>a.fullPath.toLowerCase().includes(n.toLowerCase())).map(c=>{let e=h[c.encodedPath]||{isExpanded:!1,isLoading:!1,sessions:[],error:null};return(0,d.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,d.jsxs)("button",{onClick:()=>r(c.encodedPath),className:"w-full flex items-center gap-3 p-3 hover:bg-accent transition-colors text-left",children:[(0,d.jsx)("svg",{className:`w-4 h-4 text-muted-foreground transition-transform ${e.isExpanded?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),(0,d.jsx)("svg",{className:"w-5 h-5 text-brand",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-sm font-medium text-foreground truncate",children:c.name}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:c.fullPath})]}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground bg-secondary px-2 py-0.5 rounded",children:b("workspace.sessions",{count:c.sessionCount})})]}),e.isExpanded&&(0,d.jsxs)("div",{className:"border-t border-border bg-secondary/30",children:[e.isLoading&&(0,d.jsxs)("div",{className:"flex items-center gap-2 p-3 text-xs text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:b("workspace.loadingSessions")})]}),e.error&&(0,d.jsx)("div",{className:"p-3 text-xs text-red-500",children:e.error}),!e.isLoading&&!e.error&&0===e.sessions.length&&(0,d.jsx)("div",{className:"p-3 text-xs text-muted-foreground",children:b("workspace.noSessions")}),!e.isLoading&&!e.error&&e.sessions.map(b=>(0,d.jsxs)("button",{onClick:()=>{a(c.fullPath,(b.path.split("/").pop()||"").replace(".jsonl",""))},className:"w-full flex items-start gap-3 p-3 hover:bg-accent transition-colors text-left border-t border-border first:border-t-0",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-sm text-foreground truncate",children:b.title}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:new Date(b.modifiedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),b.firstMessages.length>0&&(0,d.jsx)("div",{className:"text-xs text-muted-foreground mt-1 truncate",children:b.firstMessages[0]})]})]},b.path))]})]},c.encodedPath)})})]})]})}},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},14024:(a,b,c)=>{"use strict";c.d(b,{ProjectSidebar:()=>q});var d=c(48249),e=c(67484),f=c(44384),g=c(33932);function h({currentCwd:a,onSwitchProject:b,collapsed:c,sessions:g}){let{t:h}=(0,f.Bd)(),[i,j]=(0,e.useState)(!1),[k,l]=(0,e.useState)(0),m=(0,e.useRef)(null),n=(0,e.useCallback)(a=>{b(a.cwd,a.sessionId),j(!1)},[b]),o=g.filter(a=>"loading"===a.status).length,p=g.filter(a=>"unread"===a.status).length,q=(0,e.useCallback)(a=>{let b=Math.floor((k-a)/6e4);if(b<1)return h("common.justNow");if(b<60)return h("common.minutesAgo",{count:b});let c=Math.floor(b/60);return c<24?h("common.hoursAgo",{count:c}):h("common.daysAgo",{count:Math.floor(c/24)})},[h,k]);return(0,d.jsxs)("div",{className:"relative",ref:m,children:[(0,d.jsxs)("button",{onClick:()=>{l(Date.now()),j(!i)},className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${c?"w-full justify-center":"w-full"}`,title:h("sessions.recentSessions"),children:[(0,d.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),!c&&(0,d.jsx)("span",{className:"text-sm flex-1 text-left",children:h("sessions.recentSessions")}),o>0&&(0,d.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-white text-xs font-medium rounded-full flex items-center justify-center bg-orange-9 animate-pulse ${c?"absolute -top-1 -right-1":""}`,children:o}),p>0&&(0,d.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-white text-xs font-medium rounded-full flex items-center justify-center bg-red-500 ${c&&!o?"absolute -top-1 -right-1":""}`,children:p})]}),i&&(0,d.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-80 h-[450px] bg-popover border border-border rounded-lg shadow-lg z-50 flex flex-col",children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 flex-shrink-0 rounded-t-lg",children:[(0,d.jsx)("span",{className:"text-sm font-medium",children:h("sessions.recentSessions")}),o>0&&(0,d.jsxs)("span",{className:"ml-2 text-xs text-orange-11",children:["(",h("sessions.runningCount",{count:o}),")"]}),p>0&&(0,d.jsxs)("span",{className:"ml-2 text-xs text-red-500",children:["(",h("sessions.unreadCount",{count:p}),")"]})]}),(0,d.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===g.length?(0,d.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:h("sessions.noSessions")}):g.map((b,c)=>{let e;return(0,d.jsxs)("button",{onClick:()=>n(b),className:`w-full px-3 py-2 text-left hover:bg-accent transition-colors flex items-start gap-2 ${c!==g.length-1?"border-b border-border/50":""} ${a===b.cwd?"bg-accent/50":""}`,children:[(0,d.jsx)("span",{className:`mt-1.5 w-2 h-2 rounded-full flex-shrink-0 ${"loading"===b.status?"bg-orange-9 animate-pulse":"unread"===b.status?"bg-red-500":"bg-muted-foreground/30"}`}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",title:b.cwd,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"font-medium text-sm truncate",children:(e=b.cwd).split("/").pop()||e}),"loading"===b.status&&(0,d.jsx)("span",{className:"text-xs text-orange-11 flex-shrink-0",children:h("sessions.running")}),"unread"===b.status&&(0,d.jsx)("span",{className:"text-xs text-red-500 flex-shrink-0",children:h("sessions.done")}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:q(b.lastActive)})]}),(b.lastUserMessage||b.title)&&(0,d.jsx)("div",{className:"text-xs text-foreground/80 truncate",children:b.lastUserMessage||b.title})]})]},`${b.cwd}-${b.sessionId}`)})})]})]})}function i({collapsed:a,pinnedSessions:b,onSwitchProject:c,onUnpin:g,onUpdateTitle:h,onReorder:i}){let{t:j}=(0,f.Bd)(),[k,l]=(0,e.useState)(!1),m=(0,e.useRef)(null),[n,o]=(0,e.useState)(null),[p,q]=(0,e.useState)(""),r=(0,e.useRef)(null),[s,t]=(0,e.useState)(null),[u,v]=(0,e.useState)(null),w=(0,e.useCallback)(a=>{n||(c(a.cwd,a.sessionId),l(!1))},[c,n]),x=(0,e.useCallback)((a,b)=>{b.stopPropagation(),o(a.sessionId),q(a.customTitle||"")},[]),y=(0,e.useCallback)(()=>{n&&p.trim()&&h(n,p.trim()),o(null)},[n,p,h]),z=(0,e.useCallback)(a=>{t(a)},[]),A=(0,e.useCallback)((a,b)=>{a.preventDefault(),v(b)},[]),B=(0,e.useCallback)(a=>{if(null===s||s===a){t(null),v(null);return}let c=[...b],[d]=c.splice(s,1);c.splice(a,0,d),i(c),t(null),v(null)},[s,b,i]),C=(0,e.useCallback)(()=>{t(null),v(null)},[]);return(0,d.jsxs)("div",{className:"relative",ref:m,children:[(0,d.jsxs)("button",{onClick:()=>l(!k),className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${a?"w-full justify-center":"w-full"}`,title:j("sessions.pinnedSessions"),children:[(0,d.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})}),!a&&(0,d.jsx)("span",{className:"text-sm flex-1 text-left",children:j("sessions.pinnedSessions")}),a&&b.length>0&&(0,d.jsx)("span",{className:"absolute -top-1 -right-1 min-w-[18px] h-[18px] px-1 text-muted-foreground text-xs font-medium rounded-full flex items-center justify-center bg-accent",children:b.length})]}),k&&(0,d.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-80 max-h-[450px] bg-popover border border-border rounded-lg shadow-lg z-50 flex flex-col",children:[(0,d.jsx)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 flex-shrink-0 rounded-t-lg",children:(0,d.jsx)("span",{className:"text-sm font-medium",children:j("sessions.pinnedSessions")})}),(0,d.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===b.length?(0,d.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:j("sessions.noPinnedSessions")}):b.map((a,c)=>{let e;return(0,d.jsxs)("div",{draggable:!0,onDragStart:()=>z(c),onDragOver:a=>A(a,c),onDrop:()=>B(c),onDragEnd:C,onClick:()=>w(a),className:`group w-full px-3 py-2 text-left hover:bg-accent transition-colors flex items-start gap-2 cursor-pointer ${c!==b.length-1?"border-b border-border/50":""} ${s===c?"opacity-50":""} ${u===c?"border-t-2 border-brand":""}`,children:[(0,d.jsx)("span",{className:"mt-1.5 text-muted-foreground/30 flex-shrink-0 cursor-grab",children:(0,d.jsxs)("svg",{className:"w-3 h-3",viewBox:"0 0 10 16",fill:"currentColor",children:[(0,d.jsx)("circle",{cx:"3",cy:"2",r:"1.5"}),(0,d.jsx)("circle",{cx:"7",cy:"2",r:"1.5"}),(0,d.jsx)("circle",{cx:"3",cy:"8",r:"1.5"}),(0,d.jsx)("circle",{cx:"7",cy:"8",r:"1.5"}),(0,d.jsx)("circle",{cx:"3",cy:"14",r:"1.5"}),(0,d.jsx)("circle",{cx:"7",cy:"14",r:"1.5"})]})}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",title:a.cwd,children:[(0,d.jsx)("div",{className:"flex items-center gap-2",children:(0,d.jsx)("span",{className:"font-medium text-sm truncate",children:(e=a.cwd).split("/").pop()||e})}),n===a.sessionId?(0,d.jsx)("input",{ref:r,type:"text",value:p,onChange:a=>q(a.target.value),onKeyDown:a=>{a.nativeEvent.isComposing||("Enter"===a.key&&y(),"Escape"===a.key&&o(null))},onBlur:y,onClick:a=>a.stopPropagation(),className:"w-full text-xs px-1 py-0.5 border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring mt-0.5"}):(0,d.jsx)("div",{className:"text-xs text-foreground/80 truncate",children:a.customTitle||a.sessionId.slice(0,8)})]}),n!==a.sessionId&&(0,d.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity mt-0.5",children:[(0,d.jsx)("button",{onClick:b=>x(a,b),className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:j("sessions.editTitle"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})})}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),g(a.sessionId)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:j("sessions.remove"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]},a.sessionId)})})]})]})}var j=c(31037);function k(a,b){if("once"===a.type)return b("scheduledTasks.onceType",{minutes:a.delayMinutes});if("interval"===a.type){let c=b("scheduledTasks.everyNMinutes",{minutes:a.intervalMinutes});return a.activeFrom&&a.activeTo?`${c} (${a.activeFrom}-${a.activeTo})`:c}return"cron"===a.type?a.cron||"cron":a.type}function l(a){return a.unread?"bg-red-500":a.completed?"bg-muted-foreground":a.paused?"bg-yellow-500":"error"===a.lastResult?"bg-red-500":"bg-green-500"}function m({collapsed:a,tasks:b,unreadCount:c,onSwitchProject:g,onPause:h,onResume:i,onTrigger:m,onDelete:n,onMarkRead:o,onUpdateTask:p,onReorder:q}){let{t:r}=(0,f.Bd)(),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(null),w=(0,e.useRef)(null),x=b.filter(a=>!a.completed),y=x.filter(a=>!a.paused).length,z=b.filter(a=>a.completed),[A,B]=(0,e.useState)(null),[C,D]=(0,e.useState)(null),E=(0,e.useCallback)(a=>{B(a)},[]),F=(0,e.useCallback)((a,b)=>{a.preventDefault(),D(b)},[]),G=(0,e.useCallback)(a=>{if(null===A||A===a){B(null),D(null);return}let b=[...x],[c]=b.splice(A,1);b.splice(a,0,c),q([...b,...z].map(a=>a.id)),B(null),D(null)},[A,x,z,q]),H=(0,e.useCallback)(()=>{B(null),D(null)},[]),[,I]=(0,e.useState)(0);return(0,d.jsxs)("div",{className:"relative",ref:w,children:[(0,d.jsxs)("button",{onClick:()=>t(!s),className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${a?"w-full justify-center":"w-full"}`,title:r("scheduledTasks.title"),children:[(0,d.jsxs)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6l4 2"})]}),!a&&(0,d.jsx)("span",{className:"text-sm flex-1 text-left",children:r("scheduledTasks.title")}),c>0?(0,d.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-white text-xs font-medium rounded-full flex items-center justify-center bg-red-500 ${a?"absolute -top-1 -right-1":""}`,children:c}):a&&b.length>0?(0,d.jsx)("span",{className:"absolute -top-1 -right-1 min-w-[18px] h-[18px] px-1 text-muted-foreground text-xs font-medium rounded-full flex items-center justify-center bg-accent",children:b.length}):null]}),s&&(0,d.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-96 max-h-[500px] bg-popover border border-border rounded-lg shadow-lg z-50 flex flex-col",children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 flex-shrink-0 rounded-t-lg flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-sm font-medium",children:r("scheduledTasks.title")}),x.length>0&&(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:[r("scheduledTasks.activeCount",{running:y}),x.length-y>0?` \xb7 ${r("scheduledTasks.pausedCount",{paused:x.length-y})}`:""]})]}),(0,d.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===b.length?(0,d.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:r("scheduledTasks.noScheduledTasks")}):(0,d.jsxs)(d.Fragment,{children:[x.map((a,b)=>{var c;return(0,d.jsx)("div",{draggable:!0,onDragStart:()=>E(b),onDragOver:a=>F(a,b),onDrop:()=>G(b),onDragEnd:H,className:`group px-3 py-2 hover:bg-accent transition-colors border-b border-border/50 cursor-pointer ${a.unread?"bg-brand/5":""} ${A===b?"opacity-50":""} ${C===b?"border-t-2 border-brand":""}`,onClick:()=>{g(a.cwd,a.sessionId),a.unread&&o(a.id),t(!1)},children:(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)("span",{className:`mt-1.5 w-2 h-2 rounded-full flex-shrink-0 ${l(a)}`}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:(c=a.cwd).split("/").pop()||c}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"\xb7"}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:a.completed?r("scheduledTasks.completed"):a.paused?r("scheduledTasks.paused"):r("common.running")})]}),(0,d.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5",title:a.message,children:a.message}),(0,d.jsxs)("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{children:k(a,r)}),(0,d.jsx)("span",{children:"\xb7"}),(0,d.jsx)("span",{children:a.paused?r("scheduledTasks.paused"):function(a,b){if(!a)return"-";let c=a-Date.now();if(c<=0)return b("scheduledTasks.aboutToTrigger");if(c<6e4)return b("scheduledTasks.secondsLater",{count:Math.ceil(c/1e3)});if(c<36e5)return b("scheduledTasks.minutesLater",{count:Math.ceil(c/6e4)});if(c<864e5){let a=Math.floor(c/36e5),d=Math.ceil(c%36e5/6e4);return d>0?b("scheduledTasks.hoursMinutesLater",{h:a,m:d}):b("scheduledTasks.hoursLater",{h:a})}return new Date(a).toLocaleDateString("zh-CN",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}(a.nextFireTime,r)}),a.lastFiredAt&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{children:"\xb7"}),(0,d.jsxs)("span",{children:[r("scheduledTasks.lastResult"),": ","success"===a.lastResult?"✓":"✗"]})]})]})]}),(0,d.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),m(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-brand",title:r("scheduledTasks.runNow"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{d:"M8 5v14l11-7z"})})}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),v(a)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:r("common.edit"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),a.paused?(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),i(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-green-500",title:r("scheduledTasks.resume"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"})})}):(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),h(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-yellow-500",title:r("scheduledTasks.pause"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 9v6m4-6v6"})})}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),n(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:r("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]})},a.id)}),z.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground bg-muted/30 border-b border-border/50",children:r("scheduledTasks.completedCount",{count:z.length})}),z.map(a=>(0,d.jsx)("div",{className:"group px-3 py-2 hover:bg-accent transition-colors border-b border-border/50 opacity-60 cursor-pointer",onClick:()=>{g(a.cwd,a.sessionId),t(!1)},children:(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)("span",{className:`mt-1.5 w-2 h-2 rounded-full flex-shrink-0 ${l(a)}`}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-sm text-foreground truncate",children:a.message}),(0,d.jsxs)("div",{className:"text-xs text-muted-foreground mt-0.5",children:[k(a,r)," \xb7 ","success"===a.lastResult?r("scheduledTasks.success"):r("scheduledTasks.failure")]})]}),(0,d.jsx)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),n(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:r("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})})]})},a.id))]})]})})]}),u&&(0,d.jsxs)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/30",onClick:()=>v(null)}),(0,d.jsx)("div",{className:"relative",children:(0,d.jsx)(j.E,{onClose:()=>v(null),onCreate:()=>{},editTask:{id:u.id,message:u.message,type:u.type,delayMinutes:u.delayMinutes,intervalMinutes:u.intervalMinutes,activeFrom:u.activeFrom,activeTo:u.activeTo,cron:u.cron},onUpdate:(a,b)=>{p(a,b),v(null)}})})]})]})}var n=c(132),o=c(21108),p=c(13928);function q({projects:a,activeIndex:b,collapsed:c,currentCwd:j,onSelectProject:k,onRemoveProject:l,onReorderProjects:q,onToggleCollapse:r,onOpenSessionBrowser:s,onOpenSettings:t,onOpenNote:u,onSwitchProject:v,onAddProject:w}){let{t:x}=(0,f.Bd)(),{pinnedSessions:y,unpinSession:z,updateTitle:A,reorder:B}=(0,n.P)(),{tasks:C,unreadCount:D,reload:E,pauseTask:F,resumeTask:G,triggerTask:H,deleteTask:I,updateTask:J,markRead:K,reorderTasks:L}=(0,o.n)(),[M,N]=(0,e.useState)(!1),[O,P]=(0,e.useState)(null),[Q,R]=(0,e.useState)(null),[S,T]=(0,e.useState)([]);(0,e.useRef)(S);let U=(0,e.useRef)(E),V=(0,e.useCallback)(a=>{try{if("task-fired"===a.type)return void U.current();let{data:b}=a;if(!b)return;T(b.sessions||[])}catch{}},[]);(0,p.h)({url:"/ws/global-state",onMessage:V});let W=new Set(S.filter(a=>"loading"===a.status).map(a=>a.cwd)),X=new Set(S.filter(a=>"unread"===a.status).map(a=>a.cwd)),Y=(0,e.useCallback)(a=>{P(a)},[]),Z=(0,e.useCallback)((a,b)=>{a.preventDefault(),null!==O&&O!==b&&R(b)},[O]),$=(0,e.useCallback)(b=>{if(null!==O&&O!==b){let c=[...a],[d]=c.splice(O,1);c.splice(b,0,d),q(c)}P(null),R(null)},[O,a,q]),_=(0,e.useCallback)(()=>{P(null),R(null)},[]);return(0,d.jsxs)("div",{className:`h-full bg-card border-r border-border flex flex-col transition-all duration-200 ${c?"w-12":"w-56"}`,children:[(0,d.jsxs)("div",{className:"p-2 border-b border-border relative",onMouseEnter:()=>N(!0),onMouseLeave:()=>N(!1),children:[(0,d.jsxs)("button",{className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${c?"justify-center":""}`,onClick:s,title:x("workspace.openProject"),children:[(0,d.jsxs)("svg",{className:"w-5 h-5 flex-shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),(0,d.jsx)("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),(0,d.jsx)("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),(0,d.jsx)("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})]}),!c&&(0,d.jsx)("span",{className:"text-sm",children:x("workspace.openProject")})]}),M&&(c?(0,d.jsx)("button",{className:"absolute inset-0 m-2 flex items-center justify-center px-2 py-2 rounded-lg bg-accent text-foreground transition-colors z-10",onClick:r,title:x("workspace.expandSidebar"),children:(0,d.jsx)("svg",{className:"w-5 h-5 flex-shrink-0 rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}):(0,d.jsx)("button",{className:"absolute top-1/2 -translate-y-1/2 right-2 p-2 rounded-lg bg-accent text-foreground transition-colors z-10",onClick:r,title:x("workspace.collapseSidebar"),children:(0,d.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}))]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:a.map((a,e)=>{var f;let h;return(0,d.jsx)("div",{draggable:!0,onDragStart:()=>Y(e),onDragOver:a=>Z(a,e),onDrop:()=>$(e),onDragEnd:_,className:`${Q===e?"border-t-2 border-brand":""} ${O===e?"opacity-50":""}`,children:(0,d.jsx)(g.ProjectItem,{index:e,name:(h=(f=a.cwd).split("/").filter(Boolean))[h.length-1]||f,cwd:a.cwd,isActive:e===b,collapsed:c,hasUnread:X.has(a.cwd),isLoading:W.has(a.cwd),onClick:()=>k(e),onRemove:()=>l(e),onOpenNote:()=>u(a.cwd)})},a.cwd)})}),(0,d.jsxs)("div",{className:"p-2 border-t border-border space-y-1",children:[(0,d.jsx)(h,{currentCwd:j,onSwitchProject:v,collapsed:c,sessions:S}),(0,d.jsx)(i,{collapsed:c,pinnedSessions:y,onSwitchProject:v,onUnpin:z,onUpdateTitle:A,onReorder:B}),(0,d.jsx)(m,{collapsed:c,tasks:C,unreadCount:D,onSwitchProject:v,onPause:F,onResume:G,onTrigger:H,onDelete:I,onMarkRead:K,onUpdateTask:J,onReorder:L}),(0,d.jsxs)("button",{className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${c?"justify-center":""}`,onClick:()=>u(),title:x("workspace.notes"),children:[(0,d.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})}),!c&&(0,d.jsx)("span",{className:"text-sm",children:x("workspace.notes")})]}),(0,d.jsxs)("button",{className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${c?"justify-center":""}`,onClick:t,title:x("workspace.settings"),children:[(0,d.jsxs)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),!c&&(0,d.jsx)("span",{className:"text-sm",children:x("workspace.settings")})]})]})]})}},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},20999:(a,b,c)=>{"use strict";a.exports=c(41421)},23765:a=>{var b=!0,c=!1,d=!1;function e(a,b,c){var d=a.attrIndex(b),e=[b,c];d<0?a.attrPush(e):a.attrs[d]=e}a.exports=function(a,f){f&&(b=!f.enabled,c=!!f.label,d=!!f.labelAfter),a.core.ruler.after("inline","github-task-lists",function(a){for(var f=a.tokens,g=2;g<f.length;g++)(function(a,b){var c;return"inline"===a[b].type&&"paragraph_open"===a[b-1].type&&"list_item_open"===a[b-2].type&&(0===(c=a[b]).content.indexOf("[ ] ")||0===c.content.indexOf("[x] ")||0===c.content.indexOf("[X] "))})(f,g)&&(function(a,e){if(a.children.unshift(function(a,c){var d=new c("html_inline","",0),e=b?' disabled="" ':"";return 0===a.content.indexOf("[ ] ")?d.content='<input class="task-list-item-checkbox"'+e+'type="checkbox">':(0===a.content.indexOf("[x] ")||0===a.content.indexOf("[X] "))&&(d.content='<input class="task-list-item-checkbox" checked=""'+e+'type="checkbox">'),d}(a,e)),a.children[1].content=a.children[1].content.slice(3),a.content=a.content.slice(3),c)if(d){a.children.pop();var f="task-item-"+Math.ceil(1e7*Math.random()-1e3);a.children[0].content=a.children[0].content.slice(0,-1)+' id="'+f+'">',a.children.push(function(a,b,c){var d=new c("html_inline","",0);return d.content='<label class="task-list-item-label" for="'+b+'">'+a+"</label>",d.attrs=[{for:b}],d}(a.content,f,e))}else a.children.unshift(function(a){var b=new a("html_inline","",0);return b.content="<label>",b}(e)),a.children.push(function(a){var b=new a("html_inline","",0);return b.content="</label>",b}(e))}(f[g],a.Token),e(f[g-2],"class","task-list-item"+(b?"":" enabled")),e(f[function(a,b){for(var c=a[b].level-1,d=b-1;d>=0;d--)if(a[d].level===c)return d;return -1}(f,g-2)],"class","contains-task-list"))})}},26713:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/is-bot")},28354:a=>{"use strict";a.exports=require("util")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:a=>{"use strict";a.exports=require("path")},33932:(a,b,c)=>{"use strict";c.d(b,{ProjectItem:()=>h});var d=c(48249),e=c(67484),f=c(44384);function g({number:a,isActive:b}){return(0,d.jsxs)("svg",{className:`w-6 h-6 flex-shrink-0 ${b?"text-brand":"text-muted-foreground"}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"4"}),(0,d.jsx)("text",{x:"12",y:"16",textAnchor:"middle",fill:"currentColor",stroke:"none",fontSize:"12",fontWeight:"500",children:a})]})}function h({index:a,name:b,cwd:c,isActive:h,collapsed:i,hasUnread:j,isLoading:k,onClick:l,onRemove:m,onOpenNote:n}){let{t:o}=(0,f.Bd)(),[p,q]=(0,e.useState)(!1);return(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1 rounded-lg cursor-pointer transition-colors relative ${i?"justify-center":""} ${h?"bg-accent text-foreground":"text-muted-foreground hover:bg-secondary hover:text-foreground"}`,onClick:l,onMouseEnter:()=>q(!0),onMouseLeave:()=>q(!1),title:c,children:[(0,d.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,d.jsx)(g,{number:a+1,isActive:h}),j&&!h&&!k&&(0,d.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-red-500"}),k&&(0,d.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-orange-9 animate-pulse"})]}),!i&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"flex-1 truncate text-sm",children:b}),!k&&h?(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-brand flex-shrink-0"}):null]}),p&&!i&&(0,d.jsxs)("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 flex items-center gap-0.5",children:[n&&(0,d.jsx)("button",{className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",onClick:a=>{a.stopPropagation(),n()},title:o("workspace.projectNotes"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,d.jsx)("button",{className:"p-1 rounded hover:bg-red-500/20 text-muted-foreground hover:text-red-500 transition-colors",onClick:a=>{a.stopPropagation(),m()},title:o("workspace.closeProject"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]})}},34396:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>h,dynamic:()=>f,generateMetadata:()=>g});var d=c(5735),e=c(51675);c(43647),c(49090),c(41824);let f="force-dynamic";async function g({searchParams:a}){let b=(await a).cwd,c=b?.split("/").filter(Boolean).pop();return{title:c?`Cockpit - ${c}`:"Cockpit"}}async function h({searchParams:a}){let{cwd:b,sessionId:c}=await a;return(0,d.jsx)(e.Workspace,{initialCwd:b,initialSessionId:c})}},39017:(a,b,c)=>{Promise.resolve().then(c.bind(c,1482)),Promise.resolve().then(c.bind(c,33932)),Promise.resolve().then(c.bind(c,14024)),Promise.resolve().then(c.bind(c,89010))},41025:a=>{"use strict";a.exports=require("next/dist/server/app-render/dynamic-access-async-storage.external.js")},41421:(a,b,c)=>{"use strict";var d=c(67484),e=c(42237),f="function"==typeof Object.is?Object.is:function(a,b){return a===b&&(0!==a||1/a==1/b)||a!=a&&b!=b},g=e.useSyncExternalStore,h=d.useRef,i=d.useEffect,j=d.useMemo,k=d.useDebugValue;b.useSyncExternalStoreWithSelector=function(a,b,c,d,e){var l=h(null);if(null===l.current){var m={hasValue:!1,value:null};l.current=m}else m=l.current;var n=g(a,(l=j(function(){function a(a){if(!i){if(i=!0,g=a,a=d(a),void 0!==e&&m.hasValue){var b=m.value;if(e(b,a))return h=b}return h=a}if(b=h,f(g,a))return b;var c=d(a);return void 0!==e&&e(b,c)?(g=a,b):(g=a,h=c)}var g,h,i=!1,j=void 0===c?null:c;return[function(){return a(b())},null===j?void 0:function(){return a(j())}]},[b,c,d,e]))[0],l[1]);return i(function(){m.hasValue=!0,m.value=n},[n]),k(n),n}},41824:(a,b,c)=>{"use strict";c.d(b,{EmptyState:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call EmptyState() from the server but EmptyState is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/src/components/workspace/EmptyState.tsx","EmptyState")},43647:(a,b,c)=>{"use strict";c.d(b,{ProjectSidebar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call ProjectSidebar() from the server but ProjectSidebar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/src/components/workspace/ProjectSidebar.tsx","ProjectSidebar")},43954:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/interception-routes")},48745:(a,b,c)=>{Promise.resolve().then(c.bind(c,41824)),Promise.resolve().then(c.bind(c,49090)),Promise.resolve().then(c.bind(c,43647)),Promise.resolve().then(c.bind(c,51675))},49090:(a,b,c)=>{"use strict";c.d(b,{ProjectItem:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call ProjectItem() from the server but ProjectItem is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/src/components/workspace/ProjectItem.tsx","ProjectItem")},51675:(a,b,c)=>{"use strict";c.d(b,{Workspace:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call Workspace() from the server but Workspace is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/src/components/workspace/Workspace.tsx","Workspace")},55749:(a,b,c)=>{"use strict";c.r(b),c.d(b,{GlobalError:()=>C.default,__next_app__:()=>K,handler:()=>M,routeModule:()=>L});var d=c(7553),e=c(84006),f=c(67798),g=c(34775),h=c(99373),i=c(73461),j=c(1020),k=c(26349),l=c(54365),m=c(16023),n=c(63747),o=c(24235),p=c(23938),q=c(261),r=c(66758),s=c(77243),t=c(26713),u=c(37527),v=c(22820),w=c(88216),x=c(47929),y=c(79551),z=c(89125),A=c(86439),B=c(77068),C=c(81227),D=c(61287),E=c(81494),F=c(70722),G=c(70753),H=c(43954),I={};for(let a in D)0>["default","GlobalError","__next_app__","routeModule","handler"].indexOf(a)&&(I[a]=()=>D[a]);c.d(b,I);let J={children:["",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(c.bind(c,34396)),"/home/runner/work/cockpit/cockpit/src/app/page.tsx"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,70440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:"/manifest.webmanifest"}}]},{layout:[()=>Promise.resolve().then(c.bind(c,76537)),"/home/runner/work/cockpit/cockpit/src/app/layout.tsx"],"global-error":[()=>Promise.resolve().then(c.bind(c,81227)),"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx"],"not-found":[()=>Promise.resolve().then(c.t.bind(c,55091,23)),"next/dist/client/components/builtin/not-found.js"],forbidden:[()=>Promise.resolve().then(c.t.bind(c,45270,23)),"next/dist/client/components/builtin/forbidden.js"],unauthorized:[()=>Promise.resolve().then(c.t.bind(c,28193,23)),"next/dist/client/components/builtin/unauthorized.js"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,70440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:"/manifest.webmanifest"}}]}.children,K={require:c,loadChunk:()=>Promise.resolve()},L=new d.AppPageRouteModule({definition:{kind:e.RouteKind.APP_PAGE,page:"/page",pathname:"/",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:J},distDir:".next-prod",relativeProjectDir:""});async function M(a,b,d){var I;L.isDev&&(0,h.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let N=!!(0,h.getRequestMeta)(a,"minimalMode"),O="/page";"/index"===O&&(O="/");let P=await L.prepare(a,b,{srcPage:O,multiZoneDraftMode:!1});if(!P)return b.statusCode=400,b.end("Bad Request"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let{buildId:Q,query:R,params:S,pageIsDynamic:T,buildManifest:U,nextFontManifest:V,reactLoadableManifest:W,serverActionsManifest:X,clientReferenceManifest:Y,subresourceIntegrityManifest:Z,prerenderManifest:$,isDraftMode:_,resolvedPathname:aa,revalidateOnlyGenerated:ab,routerServerContext:ac,nextConfig:ad,parsedUrl:ae,interceptionRoutePatterns:af,deploymentId:ag}=P,ah=(0,q.normalizeAppPath)(O),{isOnDemandRevalidate:ai}=P,aj=ad.experimental.ppr&&!ad.cacheComponents&&(0,H.isInterceptionRouteAppPath)(aa)?null:L.match(aa,$),ak=!!$.routes[aa],al=a.headers["user-agent"]||"",am=(0,t.getBotType)(al),an=(0,p.isHtmlBotRequest)(a),ao=(0,h.getRequestMeta)(a,"isPrefetchRSCRequest")??"1"===a.headers[s.NEXT_ROUTER_PREFETCH_HEADER],ap=(0,h.getRequestMeta)(a,"isRSCRequest")??!!a.headers[s.RSC_HEADER],aq=(0,r.getIsPossibleServerAction)(a),ar=(0,m.checkIsAppPPREnabled)(ad.experimental.ppr);if(!(0,h.getRequestMeta)(a,"postponed")&&ar&&"1"===a.headers[x.NEXT_RESUME_HEADER]&&"POST"===a.method){let b=[];for await(let c of a)b.push(c);let c=Buffer.concat(b).toString("utf8");(0,h.addRequestMeta)(a,"postponed",c)}let as=ar&&(null==(I=$.routes[ah]??$.dynamicRoutes[ah])?void 0:I.renderingMode)==="PARTIALLY_STATIC",at=!1,au=!1,av=as?(0,h.getRequestMeta)(a,"postponed"):void 0,aw=as&&ap&&!ao;N&&(aw=aw&&!!av);let ax=(0,h.getRequestMeta)(a,"segmentPrefetchRSCRequest"),ay=(!an||!as)&&(!al||(0,p.shouldServeStreamingMetadata)(al,ad.htmlLimitedBots)),az=!!((aj||ak||$.routes[ah])&&!(an&&as)),aA=as&&!0===ad.cacheComponents,aB=!0===L.isDev||!az||"string"==typeof av||(aA&&(0,h.getRequestMeta)(a,"onCacheEntryV2")?aw&&!N:aw),aC=an&&as,aD=null;_||!az||aB||aq||av||aw||(aD=aa);let aE=aD;!aE&&L.isDev&&(aE=aa),L.isDev||_||!az||!ap||aw||(0,k.d)(a.headers);let aF={...D,tree:J,GlobalError:C.default,handler:M,routeModule:L,__next_app__:K};X&&Y&&(0,o.setManifestsSingleton)({page:O,clientReferenceManifest:Y,serverActionsManifest:X});let aG=a.method||"GET",aH=(0,g.getTracer)(),aI=aH.getActiveScopeSpan(),aJ=async()=>((null==ac?void 0:ac.render404)?await ac.render404(a,b,ae,!1):b.end("This page could not be found"),null);try{let f=L.getVaryHeader(aa,af);b.setHeader("Vary",f);let k=async(c,d)=>{let e=new l.NodeNextRequest(a),f=new l.NodeNextResponse(b);return L.render(e,f,d).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let a=aH.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==i.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let d=a.get("next.route");if(d){let a=`${aG} ${d}`;c.setAttributes({"next.route":d,"http.route":d,"next.span_name":a}),c.updateName(a)}else c.updateName(`${aG} ${O}`)})},m=(0,h.getRequestMeta)(a,"incrementalCache"),o=async({span:e,postponed:f,fallbackRouteParams:g,forceStaticRender:i})=>{let l={query:R,params:S,page:ah,sharedContext:{buildId:Q},serverComponentsHmrCache:(0,h.getRequestMeta)(a,"serverComponentsHmrCache"),fallbackRouteParams:g,renderOpts:{App:()=>null,Document:()=>null,pageConfig:{},ComponentMod:aF,Component:(0,j.T)(aF),params:S,routeModule:L,page:O,postponed:f,shouldWaitOnAllReady:aC,serveStreamingMetadata:ay,supportsDynamicResponse:"string"==typeof f||aB,buildManifest:U,nextFontManifest:V,reactLoadableManifest:W,subresourceIntegrityManifest:Z,setCacheStatus:null==ac?void 0:ac.setCacheStatus,setIsrStatus:null==ac?void 0:ac.setIsrStatus,setReactDebugChannel:null==ac?void 0:ac.setReactDebugChannel,sendErrorsToBrowser:null==ac?void 0:ac.sendErrorsToBrowser,dir:c(33873).join(process.cwd(),L.relativeProjectDir),isDraftMode:_,botType:am,isOnDemandRevalidate:ai,isPossibleServerAction:aq,assetPrefix:ad.assetPrefix,nextConfigOutput:ad.output,crossOrigin:ad.crossOrigin,trailingSlash:ad.trailingSlash,images:ad.images,previewProps:$.preview,deploymentId:ag,enableTainting:ad.experimental.taint,htmlLimitedBots:ad.htmlLimitedBots,reactMaxHeadersLength:ad.reactMaxHeadersLength,multiZoneDraftMode:!1,incrementalCache:m,cacheLifeProfiles:ad.cacheLife,basePath:ad.basePath,serverActions:ad.experimental.serverActions,...at||au?{nextExport:!0,supportsDynamicResponse:!1,isStaticGeneration:!0,isDebugDynamicAccesses:at}:{},cacheComponents:!!ad.cacheComponents,experimental:{isRoutePPREnabled:as,expireTime:ad.expireTime,staleTimes:ad.experimental.staleTimes,dynamicOnHover:!!ad.experimental.dynamicOnHover,inlineCss:!!ad.experimental.inlineCss,authInterrupts:!!ad.experimental.authInterrupts,clientTraceMetadata:ad.experimental.clientTraceMetadata||[],clientParamParsingOrigins:ad.experimental.clientParamParsingOrigins,maxPostponedStateSizeBytes:(0,B.parseMaxPostponedStateSize)(ad.experimental.maxPostponedStateSize)},waitUntil:d.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:()=>{},onInstrumentationRequestError:(b,c,d,e)=>L.onRequestError(a,b,d,e,ac),err:(0,h.getRequestMeta)(a,"invokeError"),dev:L.isDev}};at&&(l.renderOpts.nextExport=!0,l.renderOpts.supportsDynamicResponse=!1,l.renderOpts.isDebugDynamicAccesses=at),i&&(l.renderOpts.supportsDynamicResponse=!1);let n=await k(e,l),{metadata:o}=n,{cacheControl:p,headers:q={},fetchTags:r,fetchMetrics:s}=o;if(r&&(q[x.NEXT_CACHE_TAGS_HEADER]=r),a.fetchMetrics=s,az&&(null==p?void 0:p.revalidate)===0&&!L.isDev&&!as){let a=o.staticBailoutInfo,b=Object.defineProperty(Error(`Page changed from static to dynamic at runtime ${aa}${(null==a?void 0:a.description)?`, reason: ${a.description}`:""}
|
|
2
|
-
see more here https://nextjs.org/docs/messages/app-static-to-dynamic-error`),"__NEXT_ERROR_CODE",{value:"E132",enumerable:!1,configurable:!0});if(null==a?void 0:a.stack){let c=a.stack;b.stack=b.message+c.substring(c.indexOf("\n"))}throw b}return{value:{kind:u.CachedRouteKind.APP_PAGE,html:n,headers:q,rscData:o.flightData,postponed:o.postponed,status:o.statusCode,segmentData:o.segmentData},cacheControl:p}},p=async({hasResolved:c,previousCacheEntry:f,isRevalidating:g,span:i,forceStaticRender:j=!1})=>{let k,l=!1===L.isDev,q=c||b.writableEnded;if(ai&&ab&&!f&&!N)return(null==ac?void 0:ac.render404)?await ac.render404(a,b):(b.statusCode=404,b.end("This page could not be found")),null;if(aj&&(k=(0,v.parseFallbackField)(aj.fallback)),k===v.FallbackMode.PRERENDER&&(0,t.isBot)(al)&&(!as||an)&&(k=v.FallbackMode.BLOCKING_STATIC_RENDER),(null==f?void 0:f.isStale)===-1&&(ai=!0),ai&&(k!==v.FallbackMode.NOT_FOUND||f)&&(k=v.FallbackMode.BLOCKING_STATIC_RENDER),!N&&k!==v.FallbackMode.BLOCKING_STATIC_RENDER&&aE&&!q&&!_&&T&&(l||!ak)){if((l||aj)&&k===v.FallbackMode.NOT_FOUND){if(ad.experimental.adapterPath)return await aJ();throw new A.NoFallbackError}if(as&&(ad.cacheComponents?!aw:!ap)){let b=l&&"string"==typeof(null==aj?void 0:aj.fallback)?aj.fallback:ah,c=l&&(null==aj?void 0:aj.fallbackRouteParams)?(0,n.createOpaqueFallbackRouteParams)(aj.fallbackRouteParams):au?(0,n.getFallbackRouteParams)(ah,L):null,f=await L.handleResponse({cacheKey:b,req:a,nextConfig:ad,routeKind:e.RouteKind.APP_PAGE,isFallback:!0,prerenderManifest:$,isRoutePPREnabled:as,responseGenerator:async()=>o({span:i,postponed:void 0,fallbackRouteParams:c,forceStaticRender:!1}),waitUntil:d.waitUntil,isMinimalMode:N});if(null===f)return null;if(f)return delete f.cacheControl,f}}let r=ai||g||!av?void 0:av;if(aA&&!N&&m&&aw&&!j){let b=await m.get(aa,{kind:u.IncrementalCacheKind.APP_PAGE,isRoutePPREnabled:!0,isFallback:!1});b&&b.value&&b.value.kind===u.CachedRouteKind.APP_PAGE&&(r=b.value.postponed,b&&(-1===b.isStale||!0===b.isStale)&&(0,G.scheduleOnNextTick)(async()=>{let b=L.getResponseCache(a);try{await b.revalidate(aa,m,as,!1,a=>p({...a,forceStaticRender:!0}),null,c,d.waitUntil)}catch(a){console.error("Error revalidating the page in the background",a)}}))}if(at&&void 0!==r)return{cacheControl:{revalidate:1,expire:void 0},value:{kind:u.CachedRouteKind.PAGES,html:w.default.EMPTY,pageData:{},headers:void 0,status:void 0}};let s=l&&(null==aj?void 0:aj.fallbackRouteParams)&&(0,h.getRequestMeta)(a,"renderFallbackShell")?(0,n.createOpaqueFallbackRouteParams)(aj.fallbackRouteParams):au?(0,n.getFallbackRouteParams)(ah,L):null;return o({span:i,postponed:r,fallbackRouteParams:s,forceStaticRender:j})},q=async c=>{var f,g,i,j,k;let l,m=await L.handleResponse({cacheKey:aD,responseGenerator:a=>p({span:c,...a}),routeKind:e.RouteKind.APP_PAGE,isOnDemandRevalidate:ai,isRoutePPREnabled:as,req:a,nextConfig:ad,prerenderManifest:$,waitUntil:d.waitUntil,isMinimalMode:N});if(_&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate"),L.isDev&&b.setHeader("Cache-Control","no-store, must-revalidate"),!m){if(aD)throw Object.defineProperty(Error("invariant: cache entry required but not generated"),"__NEXT_ERROR_CODE",{value:"E62",enumerable:!1,configurable:!0});return null}if((null==(f=m.value)?void 0:f.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant app-page handler received invalid cache entry ${null==(i=m.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E707",enumerable:!1,configurable:!0});let n="string"==typeof m.value.postponed;az&&!aw&&(!n||ao)&&(N||b.setHeader("x-nextjs-cache",ai?"REVALIDATED":m.isMiss?"MISS":m.isStale?"STALE":"HIT"),b.setHeader(s.NEXT_IS_PRERENDER_HEADER,"1"));let{value:q}=m;if(av)l={revalidate:0,expire:void 0};else if(aw)l={revalidate:0,expire:void 0};else if(!L.isDev)if(_)l={revalidate:0,expire:void 0};else if(az){if(m.cacheControl)if("number"==typeof m.cacheControl.revalidate){if(m.cacheControl.revalidate<1)throw Object.defineProperty(Error(`Invalid revalidate configuration provided: ${m.cacheControl.revalidate} < 1`),"__NEXT_ERROR_CODE",{value:"E22",enumerable:!1,configurable:!0});l={revalidate:m.cacheControl.revalidate,expire:(null==(j=m.cacheControl)?void 0:j.expire)??ad.expireTime}}else l={revalidate:x.CACHE_ONE_YEAR,expire:void 0}}else b.getHeader("Cache-Control")||(l={revalidate:0,expire:void 0});if(m.cacheControl=l,"string"==typeof ax&&(null==q?void 0:q.kind)===u.CachedRouteKind.APP_PAGE&&q.segmentData){b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"2");let c=null==(k=q.headers)?void 0:k[x.NEXT_CACHE_TAGS_HEADER];N&&az&&c&&"string"==typeof c&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,c);let d=q.segmentData.get(ax);return void 0!==d?(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:w.default.fromStatic(d,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl}):(b.statusCode=204,(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl}))}let r=aA?(0,h.getRequestMeta)(a,"onCacheEntryV2")??(0,h.getRequestMeta)(a,"onCacheEntry"):(0,h.getRequestMeta)(a,"onCacheEntry");if(r&&await r(m,{url:(0,h.getRequestMeta)(a,"initURL")??a.url}))return null;if(q.headers){let a={...q.headers};for(let[c,d]of(N&&az||delete a[x.NEXT_CACHE_TAGS_HEADER],Object.entries(a)))if(void 0!==d)if(Array.isArray(d))for(let a of d)b.appendHeader(c,a);else"number"==typeof d&&(d=d.toString()),b.appendHeader(c,d)}let t=null==(g=q.headers)?void 0:g[x.NEXT_CACHE_TAGS_HEADER];if(N&&az&&t&&"string"==typeof t&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,t),!q.status||ap&&as||(b.statusCode=q.status),!N&&q.status&&E.RedirectStatusCode[q.status]&&ap&&(b.statusCode=200),n&&!aw&&b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"1"),ap&&!_){if(void 0===q.rscData){if(q.html.contentType!==s.RSC_CONTENT_TYPE_HEADER)if(ad.cacheComponents)return b.statusCode=404,(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl});else throw Object.defineProperty(new F.InvariantError(`Expected RSC response, got ${q.html.contentType}`),"__NEXT_ERROR_CODE",{value:"E789",enumerable:!1,configurable:!0});return(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:q.html,cacheControl:m.cacheControl})}return(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:w.default.fromStatic(q.rscData,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl})}let v=q.html;if(!n||N||ap)return(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:v,cacheControl:m.cacheControl});if(at)return v.push(new ReadableStream({start(a){a.enqueue(y.ENCODED_TAGS.CLOSED.BODY_AND_HTML),a.close()}})),(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}});let A=new TransformStream;return v.push(A.readable),o({span:c,postponed:q.postponed,fallbackRouteParams:null,forceStaticRender:!1}).then(async a=>{var b,c;if(!a)throw Object.defineProperty(Error("Invariant: expected a result to be returned"),"__NEXT_ERROR_CODE",{value:"E463",enumerable:!1,configurable:!0});if((null==(b=a.value)?void 0:b.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant: expected a page response, got ${null==(c=a.value)?void 0:c.kind}`),"__NEXT_ERROR_CODE",{value:"E305",enumerable:!1,configurable:!0});await a.value.html.pipeTo(A.writable)}).catch(a=>{A.writable.abort(a).catch(a=>{console.error("couldn't abort transformer",a)})}),(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}})};if(!aI)return await aH.withPropagatedContext(a.headers,()=>aH.trace(i.BaseServerSpan.handleRequest,{spanName:`${aG} ${O}`,kind:g.SpanKind.SERVER,attributes:{"http.method":aG,"http.target":a.url}},q));await q(aI)}catch(b){throw b instanceof A.NoFallbackError||await L.onRequestError(a,b,{routerKind:"App Router",routePath:O,routeType:"render",revalidateReason:(0,f.c)({isStaticGeneration:az,isOnDemandRevalidate:ai})},!1,ac),b}}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},70722:a=>{"use strict";a.exports=require("next/dist/shared/lib/invariant-error")},77068:a=>{"use strict";a.exports=require("next/dist/shared/lib/size-limit")},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},89010:(a,b,c)=>{"use strict";let d,e;c.d(b,{Workspace:()=>oV});var f,g,h,i,j,k,l,m,n,o,p,q,r,s={};c.r(s),c.d(s,{decode:()=>lU,encode:()=>lX,format:()=>lY,parse:()=>l7});var t={};c.r(t),c.d(t,{Any:()=>ma,Cc:()=>mb,Cf:()=>mc,P:()=>l8,S:()=>l9,Z:()=>md});var u={};c.r(u),c.d(u,{arrayReplaceAt:()=>mt,assign:()=>ms,escapeHtml:()=>mF,escapeRE:()=>mH,fromCodePoint:()=>mv,has:()=>mr,isMdAsciiPunct:()=>mL,isPunctChar:()=>mK,isSpace:()=>mI,isString:()=>mp,isValidEntityCode:()=>mu,isWhiteSpace:()=>mJ,lib:()=>mN,normalizeReference:()=>mM,unescapeAll:()=>mA,unescapeMd:()=>mz});var v={};c.r(v),c.d(v,{parseLinkDestination:()=>mP,parseLinkLabel:()=>mO,parseLinkTitle:()=>mQ});var w=c(48249),x=c(67484),y=c(44384),z=c(14024),A=c(1482),B=c(64874),C=c(60306);let D={"claude-opus-4-6":{label:"Opus 4.6",input:5,output:25,cacheRead:.5,cacheWrite:6.25,color:"#f97316"},"claude-opus-4-5-20251101":{label:"Opus 4.5",input:5,output:25,cacheRead:.5,cacheWrite:6.25,color:"#fb923c"},"claude-sonnet-4-6":{label:"Sonnet 4.6",input:3,output:15,cacheRead:.3,cacheWrite:3.75,color:"#3b82f6"},"claude-sonnet-4-5-20250929":{label:"Sonnet 4.5",input:3,output:15,cacheRead:.3,cacheWrite:3.75,color:"#60a5fa"},"claude-haiku-4-5-20251001":{label:"Haiku 4.5",input:1,output:5,cacheRead:.1,cacheWrite:1.25,color:"#22c55e"}},E={label:"",input:3,output:15,cacheRead:.3,cacheWrite:3.75,color:"#94a3b8"};function F(a){if(D[a])return D[a];let b=a.toLowerCase();return b.includes("opus")?{...E,input:5,output:25,cacheRead:.5,cacheWrite:6.25,color:"#f97316"}:b.includes("haiku")?{...E,input:1,output:5,cacheRead:.1,cacheWrite:1.25,color:"#22c55e"}:E}function G(a){let b=D[a];return b?b.label:a.replace(/^claude-/,"").replace(/-\d{8}$/,"").replace(/-/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function H(a){return(D[a]??F(a)).color}function I(a){return a>=1e9?`${(a/1e9).toFixed(1)}B`:a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:String(a)}function J(a){return a>=1e3?`$${a.toFixed(0)}`:a>=100?`$${a.toFixed(1)}`:`$${a.toFixed(2)}`}function K({data:a,height:b=200,formatValue:c=I}){let d=(0,x.useRef)(null),e=(0,x.useRef)(null),[f,g]=(0,x.useState)(null),h=(0,x.useRef)([]);(0,x.useCallback)(()=>{let f=d.current,g=e.current;if(!f||!g)return;let i=window.devicePixelRatio||1,j=g.getBoundingClientRect().width;f.width=j*i,f.height=b*i,f.style.width=`${j}px`,f.style.height=`${b}px`;let k=f.getContext("2d");k.scale(i,i),k.clearRect(0,0,j,b);let{labels:l,datasets:m}=a;if(0===l.length)return;let n=j-50-12,o=b-8-28,p=function(a){if(a<=0)return 1;let b=Math.pow(10,Math.floor(Math.log10(a))),c=a/b;return c<=1?b:c<=2?2*b:c<=5?5*b:10*b}(Math.max(1,...l.map((a,b)=>m.reduce((a,c)=>a+c.data[b],0))));k.fillStyle=getComputedStyle(f).getPropertyValue("color")||"#888",k.font="10px ui-monospace, monospace",k.textAlign="right",k.textBaseline="middle";for(let a=0;a<=4;a++){var q;let b=p/4*a,d=8+o-b/p*o;k.fillText(c(b),44,d),k.strokeStyle=(q="--border",getComputedStyle(f).getPropertyValue(q).trim()||"#333"),k.lineWidth=.5,k.beginPath(),k.moveTo(50,d),k.lineTo(50+n,d),k.stroke()}let r=n/l.length,s=Math.max(4,Math.min(.6*r,32)),t=[];l.forEach((a,b)=>{let c=50+b*r+(r-s)/2,d=0;m.forEach(e=>{var f,g,h,i,j,l;let m=e.data[b];if(m<=0)return;let n=m/p*o,q=8+o-d-n;k.fillStyle=e.color,f=k,g=c,h=q,i=s,l=2,(j=n)<1||(l=Math.min(l,j/2,i/2),f.beginPath(),f.moveTo(g+l,h),f.lineTo(g+i-l,h),f.quadraticCurveTo(g+i,h,g+i,h+l),f.lineTo(g+i,h+j-l),f.quadraticCurveTo(g+i,h+j,g+i-l,h+j),f.lineTo(g+l,h+j),f.quadraticCurveTo(g,h+j,g,h+j-l),f.lineTo(g,h+l),f.quadraticCurveTo(g,h,g+l,h),f.fill()),t.push({x:c,y:q,w:s,h:n,label:a,value:m,dataset:e.label,color:e.color}),d+=n}),k.fillStyle=getComputedStyle(f).getPropertyValue("color")||"#888",k.font="9px ui-monospace, monospace",k.textAlign="center",k.textBaseline="top",b%(l.length>20?Math.ceil(l.length/15):1)==0&&k.fillText(a,c+s/2,8+o+6)}),h.current=t},[a,b,c]);let i=(0,x.useCallback)(a=>{let b=d.current?.getBoundingClientRect();if(!b)return;let e=a.clientX-b.left,f=a.clientY-b.top,i=h.current.find(a=>e>=a.x&&e<=a.x+a.w&&f>=a.y&&f<=a.y+a.h);i?g({x:a.clientX-b.left,y:i.y-4,content:`${i.dataset}: ${c(i.value)}`}):g(null)},[c]);return(0,w.jsxs)("div",{ref:e,className:"relative w-full text-muted-foreground",children:[(0,w.jsx)("canvas",{ref:d,className:"w-full",style:{height:b},onMouseMove:i,onMouseLeave:()=>g(null)}),f&&(0,w.jsx)("div",{className:"absolute pointer-events-none bg-popover text-popover-foreground text-[10px] px-2 py-1 rounded shadow-lg border border-border whitespace-nowrap z-10",style:{left:f.x,top:f.y,transform:"translate(-50%, -100%)"},children:f.content})]})}function L({hourCounts:a}){let{t:b}=(0,y.Bd)(),c=Math.max(1,...Object.values(a)),d=Array.from({length:24},(a,b)=>b);return(0,w.jsxs)("div",{children:[(0,w.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:b("tokenStats.activeHours")}),(0,w.jsx)("div",{className:"flex gap-[2px] items-end h-16",children:d.map(d=>{let e=a[String(d)]||0,f=e/c;return(0,w.jsxs)("div",{className:"flex-1 flex flex-col items-center gap-0.5",title:b("tokenStats.hourSessions",{h:d,count:e}),children:[(0,w.jsx)("div",{className:"w-full rounded-sm transition-all",style:{height:`${Math.max(2,48*f)}px`,backgroundColor:f>0?`rgba(59, 130, 246, ${.2+.8*f})`:"var(--muted)"}}),d%3==0&&(0,w.jsx)("span",{className:"text-[8px] text-muted-foreground",children:d})]},d)})})]})}function M({isOpen:a,onClose:b}){var c;let d,e,{t:f}=(0,y.Bd)(),[g,h]=(0,x.useState)(null),[i,j]=(0,x.useState)(!0),[k,l]=(0,x.useState)("day"),[m,n]=(0,x.useState)("tokens"),o=(0,x.useMemo)(()=>g?.modelUsage?Object.entries(g.modelUsage).filter(([a])=>!a.startsWith("<")).map(([a,b])=>{let c;return{id:a,label:G(a),color:H(a),usage:b,cost:(c=F(a),b.inputTokens/1e6*c.input+b.outputTokens/1e6*c.output+b.cacheReadInputTokens/1e6*c.cacheRead+b.cacheCreationInputTokens/1e6*c.cacheWrite),totalTokens:b.inputTokens+b.outputTokens+b.cacheReadInputTokens+b.cacheCreationInputTokens}}).sort((a,b)=>b.cost-a.cost):[],[g]),p=(0,x.useMemo)(()=>o.reduce((a,b)=>a+b.cost,0),[o]),q=(0,x.useMemo)(()=>o.map(a=>a.id),[o]),r=(0,x.useMemo)(()=>{let a={};for(let b of o)a[b.id]=b.totalTokens>0?b.cost/b.totalTokens:0;return a},[o]),{activityChart:s,tokenChart:t,costChart:u}=(0,x.useMemo)(()=>{let a=g?.dailyActivity||[],b=g?.dailyModelTokens||[];if("day"===k){let c=a.slice(-60),d=b.slice(-60),e={labels:c.map(a=>a.date.slice(5)),datasets:[{label:f("tokenStats.messages"),data:c.map(a=>a.messageCount),color:"#3b82f6"},{label:f("tokenStats.toolCalls"),data:c.map(a=>a.toolCallCount),color:"#22c55e"}]},g=d.map(a=>a.date.slice(5));return{activityChart:e,tokenChart:{labels:g,datasets:q.map(a=>({label:G(a),data:d.map(b=>b.tokensByModel[a]||0),color:H(a)}))},costChart:{labels:g,datasets:q.map(a=>({label:G(a),data:d.map(b=>(b.tokensByModel[a]||0)*(r[a]||0)),color:H(a)}))}}}if("week"===k){let c=function(a,b){let c=new Map;for(let b of a){let a=new Date(b.date),d=new Date(a);d.setDate(a.getDate()-a.getDay());let e=d.toISOString().slice(0,10),f=e.slice(5);c.has(e)||c.set(e,{label:f,messages:0,sessions:0,tools:0,tokensByModel:{}});let g=c.get(e);g.messages+=b.messageCount,g.sessions+=b.sessionCount,g.tools+=b.toolCallCount}for(let a of b){let b=new Date(a.date),d=new Date(b);d.setDate(b.getDate()-b.getDay());let e=d.toISOString().slice(0,10);c.has(e)||c.set(e,{label:e.slice(5),messages:0,sessions:0,tools:0,tokensByModel:{}});let f=c.get(e);for(let[b,c]of Object.entries(a.tokensByModel))f.tokensByModel[b]=(f.tokensByModel[b]||0)+c}return Array.from(c.values()).sort((a,b)=>a.label.localeCompare(b.label))}(a,b),d=c.map(a=>a.label),e={labels:d,datasets:[{label:f("tokenStats.messages"),data:c.map(a=>a.messages),color:"#3b82f6"},{label:f("tokenStats.toolCalls"),data:c.map(a=>a.tools),color:"#22c55e"}]};return{activityChart:e,tokenChart:{labels:d,datasets:q.map(a=>({label:G(a),data:c.map(b=>b.tokensByModel[a]||0),color:H(a)}))},costChart:{labels:d,datasets:q.map(a=>({label:G(a),data:c.map(b=>(b.tokensByModel[a]||0)*(r[a]||0)),color:H(a)}))}}}let c=function(a,b){let c=new Map;for(let b of a){let a=b.date.slice(0,7);c.has(a)||c.set(a,{label:a,messages:0,sessions:0,tools:0,tokensByModel:{}});let d=c.get(a);d.messages+=b.messageCount,d.sessions+=b.sessionCount,d.tools+=b.toolCallCount}for(let a of b){let b=a.date.slice(0,7);c.has(b)||c.set(b,{label:b,messages:0,sessions:0,tools:0,tokensByModel:{}});let d=c.get(b);for(let[b,c]of Object.entries(a.tokensByModel))d.tokensByModel[b]=(d.tokensByModel[b]||0)+c}return Array.from(c.values()).sort((a,b)=>a.label.localeCompare(b.label))}(a,b),d=c.map(a=>a.label),e={labels:d,datasets:[{label:f("tokenStats.messages"),data:c.map(a=>a.messages),color:"#3b82f6"},{label:f("tokenStats.toolCalls"),data:c.map(a=>a.tools),color:"#22c55e"}]};return{activityChart:e,tokenChart:{labels:d,datasets:q.map(a=>({label:G(a),data:c.map(b=>b.tokensByModel[a]||0),color:H(a)}))},costChart:{labels:d,datasets:q.map(a=>({label:G(a),data:c.map(b=>(b.tokensByModel[a]||0)*(r[a]||0)),color:H(a)}))}}},[g,k,q,r,f]);if(!a)return null;let v=[{key:"day",label:f("tokenStats.day")},{key:"week",label:f("tokenStats.week")},{key:"month",label:f("tokenStats.month")}];return(0,w.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,w.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:b}),(0,w.jsxs)("div",{className:"relative bg-card rounded-xl shadow-xl w-full max-w-4xl mx-4 max-h-[90vh] flex flex-col overflow-hidden",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between px-6 py-3 border-b border-border flex-shrink-0",children:[(0,w.jsxs)("div",{className:"flex items-center gap-3",children:[(0,w.jsx)("h2",{className:"text-sm font-medium text-foreground",children:f("tokenStats.title")}),(0,w.jsx)("div",{className:"flex bg-muted rounded-md p-0.5",children:v.map(a=>(0,w.jsx)("button",{className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${k===a.key?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>l(a.key),children:a.label},a.key))})]}),(0,w.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,w.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,w.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,w.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-6",children:i?(0,w.jsx)("div",{className:"text-center text-muted-foreground py-12",children:f("common.loading")}):g?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)("div",{className:"grid grid-cols-5 gap-3",children:[(0,w.jsx)(N,{label:f("tokenStats.totalSessions"),value:String(g.totalSessions??0)}),(0,w.jsx)(N,{label:f("tokenStats.totalMessages"),value:I(g.totalMessages??0)}),(0,w.jsx)(N,{label:f("tokenStats.equivalentApiCost"),value:J(p),highlight:!0}),(0,w.jsx)(N,{label:f("tokenStats.longestSession"),value:g.longestSession?(d=Math.floor((c=g.longestSession.duration)/36e5),e=Math.floor(c%36e5/6e4),d>0?`${d}h ${e}m`:`${e}m`):"-"}),(0,w.jsx)(N,{label:f("tokenStats.firstUse"),value:g.firstSessionDate?g.firstSessionDate.slice(0,10):"-"})]}),(0,w.jsxs)("div",{children:[(0,w.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,w.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:f("tokenStats.activityTrend")}),(0,w.jsxs)("div",{className:"flex items-center gap-3 text-[10px]",children:[(0,w.jsxs)("span",{className:"flex items-center gap-1",children:[(0,w.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{backgroundColor:"#3b82f6"}}),f("tokenStats.messages")]}),(0,w.jsxs)("span",{className:"flex items-center gap-1",children:[(0,w.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{backgroundColor:"#22c55e"}}),f("tokenStats.toolCalls")]})]})]}),(0,w.jsx)("div",{className:"border border-border rounded-lg p-3 bg-muted/20",children:(0,w.jsx)(K,{data:s,height:180})})]}),(0,w.jsxs)("div",{children:[(0,w.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[(0,w.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:f("tokenStats.byModel")}),(0,w.jsxs)("div",{className:"flex bg-muted rounded-md p-0.5",children:[(0,w.jsx)("button",{className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${"tokens"===m?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>n("tokens"),children:f("tokenStats.tokenUsage")}),(0,w.jsx)("button",{className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${"cost"===m?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>n("cost"),children:f("tokenStats.equivalentCost")})]})]}),(0,w.jsx)("div",{className:"flex items-center gap-3 text-[10px] flex-wrap",children:o.map(a=>(0,w.jsxs)("span",{className:"flex items-center gap-1",children:[(0,w.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{backgroundColor:a.color}}),a.label]},a.id))})]}),(0,w.jsx)("div",{className:"border border-border rounded-lg p-3 bg-muted/20",children:(0,w.jsx)(K,{data:"tokens"===m?t:u,height:180,formatValue:"tokens"===m?I:J})})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:f("tokenStats.modelCostDetail")}),(0,w.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:(0,w.jsxs)("table",{className:"w-full text-xs",children:[(0,w.jsx)("thead",{children:(0,w.jsxs)("tr",{className:"bg-muted/50 text-muted-foreground",children:[(0,w.jsx)("th",{className:"text-left px-3 py-2 font-medium",children:f("tokenStats.model")}),(0,w.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Input"}),(0,w.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Output"}),(0,w.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Cache Read"}),(0,w.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Cache Write"}),(0,w.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:f("tokenStats.share")}),(0,w.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:f("tokenStats.equivalentCost")})]})}),(0,w.jsxs)("tbody",{children:[o.map(a=>(0,w.jsxs)("tr",{className:"border-t border-border",children:[(0,w.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:(0,w.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,w.jsx)("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:a.color}}),a.label]})}),(0,w.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:I(a.usage.inputTokens)}),(0,w.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:I(a.usage.outputTokens)}),(0,w.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:I(a.usage.cacheReadInputTokens)}),(0,w.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:I(a.usage.cacheCreationInputTokens)}),(0,w.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:p>0?`${(a.cost/p*100).toFixed(1)}%`:"-"}),(0,w.jsx)("td",{className:"px-3 py-2 text-right font-medium text-foreground",children:J(a.cost)})]},a.id)),(0,w.jsxs)("tr",{className:"border-t-2 border-border bg-muted/30",children:[(0,w.jsx)("td",{className:"px-3 py-2 font-medium text-foreground",children:f("tokenStats.total")}),(0,w.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:I(o.reduce((a,b)=>a+b.usage.inputTokens,0))}),(0,w.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:I(o.reduce((a,b)=>a+b.usage.outputTokens,0))}),(0,w.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:I(o.reduce((a,b)=>a+b.usage.cacheReadInputTokens,0))}),(0,w.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:I(o.reduce((a,b)=>a+b.usage.cacheCreationInputTokens,0))}),(0,w.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:"100%"}),(0,w.jsx)("td",{className:"px-3 py-2 text-right font-bold text-foreground",children:J(p)})]})]})]})})]}),g.hourCounts&&Object.keys(g.hourCounts).length>0&&(0,w.jsx)("div",{className:"border border-border rounded-lg p-3 bg-muted/20",children:(0,w.jsx)(L,{hourCounts:g.hourCounts})})]}):(0,w.jsx)("div",{className:"text-center text-muted-foreground py-12",children:f("tokenStats.notFound")})})]})]})}function N({label:a,value:b,highlight:c}){return(0,w.jsxs)("div",{className:"bg-muted/30 rounded-lg px-3 py-2.5",children:[(0,w.jsx)("div",{className:"text-[10px] text-muted-foreground",children:a}),(0,w.jsx)("div",{className:`text-sm font-semibold mt-0.5 ${c?"text-brand":"text-foreground"}`,children:b})]})}var O=c(41564),P=c(74429),Q=c(42237);function R(a){this.content=a}R.prototype={constructor:R,find:function(a){for(var b=0;b<this.content.length;b+=2)if(this.content[b]===a)return b;return -1},get:function(a){var b=this.find(a);return -1==b?void 0:this.content[b+1]},update:function(a,b,c){var d=c&&c!=a?this.remove(c):this,e=d.find(a),f=d.content.slice();return -1==e?f.push(c||a,b):(f[e+1]=b,c&&(f[e]=c)),new R(f)},remove:function(a){var b=this.find(a);if(-1==b)return this;var c=this.content.slice();return c.splice(b,2),new R(c)},addToStart:function(a,b){return new R([a,b].concat(this.remove(a).content))},addToEnd:function(a,b){var c=this.remove(a).content.slice();return c.push(a,b),new R(c)},addBefore:function(a,b,c){var d=this.remove(b),e=d.content.slice(),f=d.find(a);return e.splice(-1==f?e.length:f,0,b,c),new R(e)},forEach:function(a){for(var b=0;b<this.content.length;b+=2)a(this.content[b],this.content[b+1])},prepend:function(a){return(a=R.from(a)).size?new R(a.content.concat(this.subtract(a).content)):this},append:function(a){return(a=R.from(a)).size?new R(this.subtract(a).content.concat(a.content)):this},subtract:function(a){var b=this;a=R.from(a);for(var c=0;c<a.content.length;c+=2)b=b.remove(a.content[c]);return b},toObject:function(){var a={};return this.forEach(function(b,c){a[b]=c}),a},get size(){return this.content.length>>1}},R.from=function(a){if(a instanceof R)return a;var b=[];if(a)for(var c in a)b.push(c,a[c]);return new R(b)};class S{constructor(a,b){if(this.content=a,this.size=b||0,null==b)for(let b=0;b<a.length;b++)this.size+=a[b].nodeSize}nodesBetween(a,b,c,d=0,e){for(let f=0,g=0;g<b;f++){let h=this.content[f],i=g+h.nodeSize;if(i>a&&!1!==c(h,d+g,e||null,f)&&h.content.size){let e=g+1;h.nodesBetween(Math.max(0,a-e),Math.min(h.content.size,b-e),c,d+e)}g=i}}descendants(a){this.nodesBetween(0,this.size,a)}textBetween(a,b,c,d){let e="",f=!0;return this.nodesBetween(a,b,(g,h)=>{let i=g.isText?g.text.slice(Math.max(a,h)-h,b-h):g.isLeaf?d?"function"==typeof d?d(g):d:g.type.spec.leafText?g.type.spec.leafText(g):"":"";g.isBlock&&(g.isLeaf&&i||g.isTextblock)&&c&&(f?f=!1:e+=c),e+=i},0),e}append(a){if(!a.size)return this;if(!this.size)return a;let b=this.lastChild,c=a.firstChild,d=this.content.slice(),e=0;for(b.isText&&b.sameMarkup(c)&&(d[d.length-1]=b.withText(b.text+c.text),e=1);e<a.content.length;e++)d.push(a.content[e]);return new S(d,this.size+a.size)}cut(a,b=this.size){if(0==a&&b==this.size)return this;let c=[],d=0;if(b>a)for(let e=0,f=0;f<b;e++){let g=this.content[e],h=f+g.nodeSize;h>a&&((f<a||h>b)&&(g=g.isText?g.cut(Math.max(0,a-f),Math.min(g.text.length,b-f)):g.cut(Math.max(0,a-f-1),Math.min(g.content.size,b-f-1))),c.push(g),d+=g.nodeSize),f=h}return new S(c,d)}cutByIndex(a,b){return a==b?S.empty:0==a&&b==this.content.length?this:new S(this.content.slice(a,b))}replaceChild(a,b){let c=this.content[a];if(c==b)return this;let d=this.content.slice(),e=this.size+b.nodeSize-c.nodeSize;return d[a]=b,new S(d,e)}addToStart(a){return new S([a].concat(this.content),this.size+a.nodeSize)}addToEnd(a){return new S(this.content.concat(a),this.size+a.nodeSize)}eq(a){if(this.content.length!=a.content.length)return!1;for(let b=0;b<this.content.length;b++)if(!this.content[b].eq(a.content[b]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(a){let b=this.content[a];if(!b)throw RangeError("Index "+a+" out of range for "+this);return b}maybeChild(a){return this.content[a]||null}forEach(a){for(let b=0,c=0;b<this.content.length;b++){let d=this.content[b];a(d,c,b),c+=d.nodeSize}}findDiffStart(a,b=0){return function a(b,c,d){for(let e=0;;e++){if(e==b.childCount||e==c.childCount)return b.childCount==c.childCount?null:d;let f=b.child(e),g=c.child(e);if(f==g){d+=f.nodeSize;continue}if(!f.sameMarkup(g))return d;if(f.isText&&f.text!=g.text){for(let a=0;f.text[a]==g.text[a];a++)d++;return d}if(f.content.size||g.content.size){let b=a(f.content,g.content,d+1);if(null!=b)return b}d+=f.nodeSize}}(this,a,b)}findDiffEnd(a,b=this.size,c=a.size){return function a(b,c,d,e){for(let f=b.childCount,g=c.childCount;;){if(0==f||0==g)return f==g?null:{a:d,b:e};let h=b.child(--f),i=c.child(--g),j=h.nodeSize;if(h==i){d-=j,e-=j;continue}if(!h.sameMarkup(i))return{a:d,b:e};if(h.isText&&h.text!=i.text){let a=0,b=Math.min(h.text.length,i.text.length);for(;a<b&&h.text[h.text.length-a-1]==i.text[i.text.length-a-1];)a++,d--,e--;return{a:d,b:e}}if(h.content.size||i.content.size){let b=a(h.content,i.content,d-1,e-1);if(b)return b}d-=j,e-=j}}(this,a,b,c)}findIndex(a){if(0==a)return U(0,a);if(a==this.size)return U(this.content.length,a);if(a>this.size||a<0)throw RangeError(`Position ${a} outside of fragment (${this})`);for(let b=0,c=0;;b++){let d=c+this.child(b).nodeSize;if(d>=a){if(d==a)return U(b+1,d);return U(b,c)}c=d}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(a=>a.toJSON()):null}static fromJSON(a,b){if(!b)return S.empty;if(!Array.isArray(b))throw RangeError("Invalid input for Fragment.fromJSON");return new S(b.map(a.nodeFromJSON))}static fromArray(a){if(!a.length)return S.empty;let b,c=0;for(let d=0;d<a.length;d++){let e=a[d];c+=e.nodeSize,d&&e.isText&&a[d-1].sameMarkup(e)?(b||(b=a.slice(0,d)),b[b.length-1]=e.withText(b[b.length-1].text+e.text)):b&&b.push(e)}return new S(b||a,c)}static from(a){if(!a)return S.empty;if(a instanceof S)return a;if(Array.isArray(a))return this.fromArray(a);if(a.attrs)return new S([a],a.nodeSize);throw RangeError("Can not convert "+a+" to a Fragment"+(a.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}S.empty=new S([],0);let T={index:0,offset:0};function U(a,b){return T.index=a,T.offset=b,T}function V(a,b){if(a===b)return!0;if(!(a&&"object"==typeof a)||!(b&&"object"==typeof b))return!1;let c=Array.isArray(a);if(Array.isArray(b)!=c)return!1;if(c){if(a.length!=b.length)return!1;for(let c=0;c<a.length;c++)if(!V(a[c],b[c]))return!1}else{for(let c in a)if(!(c in b)||!V(a[c],b[c]))return!1;for(let c in b)if(!(c in a))return!1}return!0}class W{constructor(a,b){this.type=a,this.attrs=b}addToSet(a){let b,c=!1;for(let d=0;d<a.length;d++){let e=a[d];if(this.eq(e))return a;if(this.type.excludes(e.type))b||(b=a.slice(0,d));else{if(e.type.excludes(this.type))return a;!c&&e.type.rank>this.type.rank&&(b||(b=a.slice(0,d)),b.push(this),c=!0),b&&b.push(e)}}return b||(b=a.slice()),c||b.push(this),b}removeFromSet(a){for(let b=0;b<a.length;b++)if(this.eq(a[b]))return a.slice(0,b).concat(a.slice(b+1));return a}isInSet(a){for(let b=0;b<a.length;b++)if(this.eq(a[b]))return!0;return!1}eq(a){return this==a||this.type==a.type&&V(this.attrs,a.attrs)}toJSON(){let a={type:this.type.name};for(let b in this.attrs){a.attrs=this.attrs;break}return a}static fromJSON(a,b){if(!b)throw RangeError("Invalid input for Mark.fromJSON");let c=a.marks[b.type];if(!c)throw RangeError(`There is no mark type ${b.type} in this schema`);let d=c.create(b.attrs);return c.checkAttrs(d.attrs),d}static sameSet(a,b){if(a==b)return!0;if(a.length!=b.length)return!1;for(let c=0;c<a.length;c++)if(!a[c].eq(b[c]))return!1;return!0}static setFrom(a){if(!a||Array.isArray(a)&&0==a.length)return W.none;if(a instanceof W)return[a];let b=a.slice();return b.sort((a,b)=>a.type.rank-b.type.rank),b}}W.none=[];class X extends Error{}class Y{constructor(a,b,c){this.content=a,this.openStart=b,this.openEnd=c}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(a,b){let c=function a(b,c,d,e){let{index:f,offset:g}=b.findIndex(c),h=b.maybeChild(f);if(g==c||h.isText)return e&&!e.canReplace(f,f,d)?null:b.cut(0,c).append(d).append(b.cut(c));let i=a(h.content,c-g-1,d,h);return i&&b.replaceChild(f,h.copy(i))}(this.content,a+this.openStart,b);return c&&new Y(c,this.openStart,this.openEnd)}removeBetween(a,b){return new Y(function a(b,c,d){let{index:e,offset:f}=b.findIndex(c),g=b.maybeChild(e),{index:h,offset:i}=b.findIndex(d);if(f==c||g.isText){if(i!=d&&!b.child(h).isText)throw RangeError("Removing non-flat range");return b.cut(0,c).append(b.cut(d))}if(e!=h)throw RangeError("Removing non-flat range");return b.replaceChild(e,g.copy(a(g.content,c-f-1,d-f-1)))}(this.content,a+this.openStart,b+this.openStart),this.openStart,this.openEnd)}eq(a){return this.content.eq(a.content)&&this.openStart==a.openStart&&this.openEnd==a.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let a={content:this.content.toJSON()};return this.openStart>0&&(a.openStart=this.openStart),this.openEnd>0&&(a.openEnd=this.openEnd),a}static fromJSON(a,b){if(!b)return Y.empty;let c=b.openStart||0,d=b.openEnd||0;if("number"!=typeof c||"number"!=typeof d)throw RangeError("Invalid input for Slice.fromJSON");return new Y(S.fromJSON(a,b.content),c,d)}static maxOpen(a,b=!0){let c=0,d=0;for(let d=a.firstChild;d&&!d.isLeaf&&(b||!d.type.spec.isolating);d=d.firstChild)c++;for(let c=a.lastChild;c&&!c.isLeaf&&(b||!c.type.spec.isolating);c=c.lastChild)d++;return new Y(a,c,d)}}function Z(a,b){if(!b.type.compatibleContent(a.type))throw new X("Cannot join "+b.type.name+" onto "+a.type.name)}function $(a,b,c){let d=a.node(c);return Z(d,b.node(c)),d}function _(a,b){let c=b.length-1;c>=0&&a.isText&&a.sameMarkup(b[c])?b[c]=a.withText(b[c].text+a.text):b.push(a)}function aa(a,b,c,d){let e=(b||a).node(c),f=0,g=b?b.index(c):e.childCount;a&&(f=a.index(c),a.depth>c?f++:a.textOffset&&(_(a.nodeAfter,d),f++));for(let a=f;a<g;a++)_(e.child(a),d);b&&b.depth==c&&b.textOffset&&_(b.nodeBefore,d)}function ab(a,b){return a.type.checkContent(b),a.copy(b)}function ac(a,b,c){let d=[];return aa(null,a,c,d),a.depth>c&&_(ab($(a,b,c+1),ac(a,b,c+1)),d),aa(b,null,c,d),new S(d)}Y.empty=new Y(S.empty,0,0);class ad{constructor(a,b,c){this.pos=a,this.path=b,this.parentOffset=c,this.depth=b.length/3-1}resolveDepth(a){return null==a?this.depth:a<0?this.depth+a:a}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(a){return this.path[3*this.resolveDepth(a)]}index(a){return this.path[3*this.resolveDepth(a)+1]}indexAfter(a){return a=this.resolveDepth(a),this.index(a)+(a!=this.depth||this.textOffset?1:0)}start(a){return 0==(a=this.resolveDepth(a))?0:this.path[3*a-1]+1}end(a){return a=this.resolveDepth(a),this.start(a)+this.node(a).content.size}before(a){if(!(a=this.resolveDepth(a)))throw RangeError("There is no position before the top-level node");return a==this.depth+1?this.pos:this.path[3*a-1]}after(a){if(!(a=this.resolveDepth(a)))throw RangeError("There is no position after the top-level node");return a==this.depth+1?this.pos:this.path[3*a-1]+this.path[3*a].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let a=this.parent,b=this.index(this.depth);if(b==a.childCount)return null;let c=this.pos-this.path[this.path.length-1],d=a.child(b);return c?a.child(b).cut(c):d}get nodeBefore(){let a=this.index(this.depth),b=this.pos-this.path[this.path.length-1];return b?this.parent.child(a).cut(0,b):0==a?null:this.parent.child(a-1)}posAtIndex(a,b){b=this.resolveDepth(b);let c=this.path[3*b],d=0==b?0:this.path[3*b-1]+1;for(let b=0;b<a;b++)d+=c.child(b).nodeSize;return d}marks(){let a=this.parent,b=this.index();if(0==a.content.size)return W.none;if(this.textOffset)return a.child(b).marks;let c=a.maybeChild(b-1),d=a.maybeChild(b);if(!c){let a=c;c=d,d=a}let e=c.marks;for(var f=0;f<e.length;f++)!1!==e[f].type.spec.inclusive||d&&e[f].isInSet(d.marks)||(e=e[f--].removeFromSet(e));return e}marksAcross(a){let b=this.parent.maybeChild(this.index());if(!b||!b.isInline)return null;let c=b.marks,d=a.parent.maybeChild(a.index());for(var e=0;e<c.length;e++)!1!==c[e].type.spec.inclusive||d&&c[e].isInSet(d.marks)||(c=c[e--].removeFromSet(c));return c}sharedDepth(a){for(let b=this.depth;b>0;b--)if(this.start(b)<=a&&this.end(b)>=a)return b;return 0}blockRange(a=this,b){if(a.pos<this.pos)return a.blockRange(this);for(let c=this.depth-(this.parent.inlineContent||this.pos==a.pos?1:0);c>=0;c--)if(a.pos<=this.end(c)&&(!b||b(this.node(c))))return new ah(this,a,c);return null}sameParent(a){return this.pos-this.parentOffset==a.pos-a.parentOffset}max(a){return a.pos>this.pos?a:this}min(a){return a.pos<this.pos?a:this}toString(){let a="";for(let b=1;b<=this.depth;b++)a+=(a?"/":"")+this.node(b).type.name+"_"+this.index(b-1);return a+":"+this.parentOffset}static resolve(a,b){if(!(b>=0&&b<=a.content.size))throw RangeError("Position "+b+" out of range");let c=[],d=0,e=b;for(let b=a;;){let{index:a,offset:f}=b.content.findIndex(e),g=e-f;if(c.push(b,a,d+f),!g||(b=b.child(a)).isText)break;e=g-1,d+=f+1}return new ad(b,c,e)}static resolveCached(a,b){let c=ag.get(a);if(c)for(let a=0;a<c.elts.length;a++){let d=c.elts[a];if(d.pos==b)return d}else ag.set(a,c=new ae);let d=c.elts[c.i]=ad.resolve(a,b);return c.i=(c.i+1)%af,d}}class ae{constructor(){this.elts=[],this.i=0}}let af=12,ag=new WeakMap;class ah{constructor(a,b,c){this.$from=a,this.$to=b,this.depth=c}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}let ai=Object.create(null);class aj{constructor(a,b,c,d=W.none){this.type=a,this.attrs=b,this.marks=d,this.content=c||S.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(a){return this.content.child(a)}maybeChild(a){return this.content.maybeChild(a)}forEach(a){this.content.forEach(a)}nodesBetween(a,b,c,d=0){this.content.nodesBetween(a,b,c,d,this)}descendants(a){this.nodesBetween(0,this.content.size,a)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(a,b,c,d){return this.content.textBetween(a,b,c,d)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(a){return this==a||this.sameMarkup(a)&&this.content.eq(a.content)}sameMarkup(a){return this.hasMarkup(a.type,a.attrs,a.marks)}hasMarkup(a,b,c){return this.type==a&&V(this.attrs,b||a.defaultAttrs||ai)&&W.sameSet(this.marks,c||W.none)}copy(a=null){return a==this.content?this:new aj(this.type,this.attrs,a,this.marks)}mark(a){return a==this.marks?this:new aj(this.type,this.attrs,this.content,a)}cut(a,b=this.content.size){return 0==a&&b==this.content.size?this:this.copy(this.content.cut(a,b))}slice(a,b=this.content.size,c=!1){if(a==b)return Y.empty;let d=this.resolve(a),e=this.resolve(b),f=c?0:d.sharedDepth(b),g=d.start(f);return new Y(d.node(f).content.cut(d.pos-g,e.pos-g),d.depth-f,e.depth-f)}replace(a,b,c){var d=this.resolve(a),e=this.resolve(b);if(c.openStart>d.depth)throw new X("Inserted content deeper than insertion position");if(d.depth-c.openStart!=e.depth-c.openEnd)throw new X("Inconsistent open depths");return function a(b,c,d,e){let f=b.index(e),g=b.node(e);if(f==c.index(e)&&e<b.depth-d.openStart){let h=a(b,c,d,e+1);return g.copy(g.content.replaceChild(f,h))}if(!d.content.size)return ab(g,ac(b,c,e));if(d.openStart||d.openEnd||b.depth!=e||c.depth!=e){let{start:a,end:f}=function(a,b){let c=b.depth-a.openStart,d=b.node(c).copy(a.content);for(let a=c-1;a>=0;a--)d=b.node(a).copy(S.from(d));return{start:d.resolveNoCache(a.openStart+c),end:d.resolveNoCache(d.content.size-a.openEnd-c)}}(d,b);return ab(g,function a(b,c,d,e,f){let g=b.depth>f&&$(b,c,f+1),h=e.depth>f&&$(d,e,f+1),i=[];return aa(null,b,f,i),g&&h&&c.index(f)==d.index(f)?(Z(g,h),_(ab(g,a(b,c,d,e,f+1)),i)):(g&&_(ab(g,ac(b,c,f+1)),i),aa(c,d,f,i),h&&_(ab(h,ac(d,e,f+1)),i)),aa(e,null,f,i),new S(i)}(b,a,f,c,e))}{let a=b.parent,e=a.content;return ab(a,e.cut(0,b.parentOffset).append(d.content).append(e.cut(c.parentOffset)))}}(d,e,c,0)}nodeAt(a){for(let b=this;;){let{index:c,offset:d}=b.content.findIndex(a);if(!(b=b.maybeChild(c)))return null;if(d==a||b.isText)return b;a-=d+1}}childAfter(a){let{index:b,offset:c}=this.content.findIndex(a);return{node:this.content.maybeChild(b),index:b,offset:c}}childBefore(a){if(0==a)return{node:null,index:0,offset:0};let{index:b,offset:c}=this.content.findIndex(a);if(c<a)return{node:this.content.child(b),index:b,offset:c};let d=this.content.child(b-1);return{node:d,index:b-1,offset:c-d.nodeSize}}resolve(a){return ad.resolveCached(this,a)}resolveNoCache(a){return ad.resolve(this,a)}rangeHasMark(a,b,c){let d=!1;return b>a&&this.nodesBetween(a,b,a=>(c.isInSet(a.marks)&&(d=!0),!d)),d}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 a=this.type.name;return this.content.size&&(a+="("+this.content.toStringInner()+")"),al(this.marks,a)}contentMatchAt(a){let b=this.type.contentMatch.matchFragment(this.content,0,a);if(!b)throw Error("Called contentMatchAt on a node with invalid content");return b}canReplace(a,b,c=S.empty,d=0,e=c.childCount){let f=this.contentMatchAt(a).matchFragment(c,d,e),g=f&&f.matchFragment(this.content,b);if(!g||!g.validEnd)return!1;for(let a=d;a<e;a++)if(!this.type.allowsMarks(c.child(a).marks))return!1;return!0}canReplaceWith(a,b,c,d){if(d&&!this.type.allowsMarks(d))return!1;let e=this.contentMatchAt(a).matchType(c),f=e&&e.matchFragment(this.content,b);return!!f&&f.validEnd}canAppend(a){return a.content.size?this.canReplace(this.childCount,this.childCount,a.content):this.type.compatibleContent(a.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let a=W.none;for(let b=0;b<this.marks.length;b++){let c=this.marks[b];c.type.checkAttrs(c.attrs),a=c.addToSet(a)}if(!W.sameSet(a,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(a=>a.type.name)}`);this.content.forEach(a=>a.check())}toJSON(){let a={type:this.type.name};for(let b in this.attrs){a.attrs=this.attrs;break}return this.content.size&&(a.content=this.content.toJSON()),this.marks.length&&(a.marks=this.marks.map(a=>a.toJSON())),a}static fromJSON(a,b){let c;if(!b)throw RangeError("Invalid input for Node.fromJSON");if(b.marks){if(!Array.isArray(b.marks))throw RangeError("Invalid mark data for Node.fromJSON");c=b.marks.map(a.markFromJSON)}if("text"==b.type){if("string"!=typeof b.text)throw RangeError("Invalid text node in JSON");return a.text(b.text,c)}let d=S.fromJSON(a,b.content),e=a.nodeType(b.type).create(b.attrs,d,c);return e.type.checkAttrs(e.attrs),e}}aj.prototype.text=void 0;class ak extends aj{constructor(a,b,c,d){if(super(a,b,null,d),!c)throw RangeError("Empty text nodes are not allowed");this.text=c}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):al(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(a,b){return this.text.slice(a,b)}get nodeSize(){return this.text.length}mark(a){return a==this.marks?this:new ak(this.type,this.attrs,this.text,a)}withText(a){return a==this.text?this:new ak(this.type,this.attrs,a,this.marks)}cut(a=0,b=this.text.length){return 0==a&&b==this.text.length?this:this.withText(this.text.slice(a,b))}eq(a){return this.sameMarkup(a)&&this.text==a.text}toJSON(){let a=super.toJSON();return a.text=this.text,a}}function al(a,b){for(let c=a.length-1;c>=0;c--)b=a[c].type.name+"("+b+")";return b}class am{constructor(a){this.validEnd=a,this.next=[],this.wrapCache=[]}static parse(a,b){var c;let d,e=new an(a,b);if(null==e.next)return am.empty;let f=function a(b){let c=[];do c.push(function(b){let c=[];do c.push(function(b){let c=function(b){if(b.eat("(")){let c=a(b);return b.eat(")")||b.err("Missing closing paren"),c}if(/\W/.test(b.next))b.err("Unexpected token '"+b.next+"'");else{let a=(function(a,b){let c=a.nodeTypes,d=c[b];if(d)return[d];let e=[];for(let a in c){let d=c[a];d.isInGroup(b)&&e.push(d)}return 0==e.length&&a.err("No node type or group '"+b+"' found"),e})(b,b.next).map(a=>(null==b.inline?b.inline=a.isInline:b.inline!=a.isInline&&b.err("Mixing inline and block content"),{type:"name",value:a}));return b.pos++,1==a.length?a[0]:{type:"choice",exprs:a}}}(b);for(;;)if(b.eat("+"))c={type:"plus",expr:c};else if(b.eat("*"))c={type:"star",expr:c};else if(b.eat("?"))c={type:"opt",expr:c};else if(b.eat("{"))c=function(a,b){let c=ao(a),d=c;return a.eat(",")&&(d="}"!=a.next?ao(a):-1),a.eat("}")||a.err("Unclosed braced range"),{type:"range",min:c,max:d,expr:b}}(b,c);else break;return c}(b));while(b.next&&")"!=b.next&&"|"!=b.next);return 1==c.length?c[0]:{type:"seq",exprs:c}}(b));while(b.eat("|"));return 1==c.length?c[0]:{type:"choice",exprs:c}}(e);e.next&&e.err("Unexpected trailing text");let g=(c=function(a){let b=[[]];return e(function a(b,f){if("choice"==b.type)return b.exprs.reduce((b,c)=>b.concat(a(c,f)),[]);if("seq"==b.type)for(let d=0;;d++){let g=a(b.exprs[d],f);if(d==b.exprs.length-1)return g;e(g,f=c())}else if("star"==b.type){let g=c();return d(f,g),e(a(b.expr,g),g),[d(g)]}else if("plus"==b.type){let g=c();return e(a(b.expr,f),g),e(a(b.expr,g),g),[d(g)]}else if("opt"==b.type)return[d(f)].concat(a(b.expr,f));else if("range"==b.type){let g=f;for(let d=0;d<b.min;d++){let d=c();e(a(b.expr,g),d),g=d}if(-1==b.max)e(a(b.expr,g),g);else for(let f=b.min;f<b.max;f++){let f=c();d(g,f),e(a(b.expr,g),f),g=f}return[d(g)]}else if("name"==b.type)return[d(f,void 0,b.value)];else throw Error("Unknown expr type")}(a,0),c()),b;function c(){return b.push([])-1}function d(a,c,d){let e={term:d,to:c};return b[a].push(e),e}function e(a,b){a.forEach(a=>a.to=b)}}(f),d=Object.create(null),function a(b){let e=[];b.forEach(a=>{c[a].forEach(({term:a,to:b})=>{let d;if(a){for(let b=0;b<e.length;b++)e[b][0]==a&&(d=e[b][1]);aq(c,b).forEach(b=>{d||e.push([a,d=[]]),-1==d.indexOf(b)&&d.push(b)})}})});let f=d[b.join(",")]=new am(b.indexOf(c.length-1)>-1);for(let b=0;b<e.length;b++){let c=e[b][1].sort(ap);f.next.push({type:e[b][0],next:d[c.join(",")]||a(c)})}return f}(aq(c,0)));return function(a,b){for(let c=0,d=[a];c<d.length;c++){let a=d[c],e=!a.validEnd,f=[];for(let b=0;b<a.next.length;b++){let{type:c,next:g}=a.next[b];f.push(c.name),e&&!(c.isText||c.hasRequiredAttrs())&&(e=!1),-1==d.indexOf(g)&&d.push(g)}e&&b.err("Only non-generatable nodes ("+f.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(g,e),g}matchType(a){for(let b=0;b<this.next.length;b++)if(this.next[b].type==a)return this.next[b].next;return null}matchFragment(a,b=0,c=a.childCount){let d=this;for(let e=b;d&&e<c;e++)d=d.matchType(a.child(e).type);return d}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let a=0;a<this.next.length;a++){let{type:b}=this.next[a];if(!(b.isText||b.hasRequiredAttrs()))return b}return null}compatible(a){for(let b=0;b<this.next.length;b++)for(let c=0;c<a.next.length;c++)if(this.next[b].type==a.next[c].type)return!0;return!1}fillBefore(a,b=!1,c=0){let d=[this];return function e(f,g){let h=f.matchFragment(a,c);if(h&&(!b||h.validEnd))return S.from(g.map(a=>a.createAndFill()));for(let a=0;a<f.next.length;a++){let{type:b,next:c}=f.next[a];if(!(b.isText||b.hasRequiredAttrs())&&-1==d.indexOf(c)){d.push(c);let a=e(c,g.concat(b));if(a)return a}}return null}(this,[])}findWrapping(a){for(let b=0;b<this.wrapCache.length;b+=2)if(this.wrapCache[b]==a)return this.wrapCache[b+1];let b=this.computeWrapping(a);return this.wrapCache.push(a,b),b}computeWrapping(a){let b=Object.create(null),c=[{match:this,type:null,via:null}];for(;c.length;){let d=c.shift(),e=d.match;if(e.matchType(a)){let a=[];for(let b=d;b.type;b=b.via)a.push(b.type);return a.reverse()}for(let a=0;a<e.next.length;a++){let{type:f,next:g}=e.next[a];f.isLeaf||f.hasRequiredAttrs()||f.name in b||d.type&&!g.validEnd||(c.push({match:f.contentMatch,type:f,via:d}),b[f.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(a){if(a>=this.next.length)throw RangeError(`There's no ${a}th edge in this content match`);return this.next[a]}toString(){let a=[];return!function b(c){a.push(c);for(let d=0;d<c.next.length;d++)-1==a.indexOf(c.next[d].next)&&b(c.next[d].next)}(this),a.map((b,c)=>{let d=c+(b.validEnd?"*":" ")+" ";for(let c=0;c<b.next.length;c++)d+=(c?", ":"")+b.next[c].type.name+"->"+a.indexOf(b.next[c].next);return d}).join("\n")}}am.empty=new am(!0);class an{constructor(a,b){this.string=a,this.nodeTypes=b,this.inline=null,this.pos=0,this.tokens=a.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(a){return this.next==a&&(this.pos++||!0)}err(a){throw SyntaxError(a+" (in content expression '"+this.string+"')")}}function ao(a){/\D/.test(a.next)&&a.err("Expected number, got '"+a.next+"'");let b=Number(a.next);return a.pos++,b}function ap(a,b){return b-a}function aq(a,b){let c=[];return function b(d){let e=a[d];if(1==e.length&&!e[0].term)return b(e[0].to);c.push(d);for(let a=0;a<e.length;a++){let{term:d,to:f}=e[a];d||-1!=c.indexOf(f)||b(f)}}(b),c.sort(ap)}function ar(a){let b=Object.create(null);for(let c in a){let d=a[c];if(!d.hasDefault)return null;b[c]=d.default}return b}function as(a,b){let c=Object.create(null);for(let d in a){let e=b&&b[d];if(void 0===e){let b=a[d];if(b.hasDefault)e=b.default;else throw RangeError("No value supplied for attribute "+d)}c[d]=e}return c}function at(a,b,c,d){for(let d in b)if(!(d in a))throw RangeError(`Unsupported attribute ${d} for ${c} of type ${d}`);for(let c in a){let d=a[c];d.validate&&d.validate(b[c])}}function au(a,b){let c=Object.create(null);if(b)for(let d in b)c[d]=new aw(a,d,b[d]);return c}class av{constructor(a,b,c){this.name=a,this.schema=b,this.spec=c,this.markSet=null,this.groups=c.group?c.group.split(" "):[],this.attrs=au(a,c.attrs),this.defaultAttrs=ar(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(c.inline||"text"==a),this.isText="text"==a}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==am.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(a){return this.groups.indexOf(a)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let a in this.attrs)if(this.attrs[a].isRequired)return!0;return!1}compatibleContent(a){return this==a||this.contentMatch.compatible(a.contentMatch)}computeAttrs(a){return!a&&this.defaultAttrs?this.defaultAttrs:as(this.attrs,a)}create(a=null,b,c){if(this.isText)throw Error("NodeType.create can't construct text nodes");return new aj(this,this.computeAttrs(a),S.from(b),W.setFrom(c))}createChecked(a=null,b,c){return b=S.from(b),this.checkContent(b),new aj(this,this.computeAttrs(a),b,W.setFrom(c))}createAndFill(a=null,b,c){if(a=this.computeAttrs(a),(b=S.from(b)).size){let a=this.contentMatch.fillBefore(b);if(!a)return null;b=a.append(b)}let d=this.contentMatch.matchFragment(b),e=d&&d.fillBefore(S.empty,!0);return e?new aj(this,a,b.append(e),W.setFrom(c)):null}validContent(a){let b=this.contentMatch.matchFragment(a);if(!b||!b.validEnd)return!1;for(let b=0;b<a.childCount;b++)if(!this.allowsMarks(a.child(b).marks))return!1;return!0}checkContent(a){if(!this.validContent(a))throw RangeError(`Invalid content for node ${this.name}: ${a.toString().slice(0,50)}`)}checkAttrs(a){at(this.attrs,a,"node",this.name)}allowsMarkType(a){return null==this.markSet||this.markSet.indexOf(a)>-1}allowsMarks(a){if(null==this.markSet)return!0;for(let b=0;b<a.length;b++)if(!this.allowsMarkType(a[b].type))return!1;return!0}allowedMarks(a){let b;if(null==this.markSet)return a;for(let c=0;c<a.length;c++)this.allowsMarkType(a[c].type)?b&&b.push(a[c]):b||(b=a.slice(0,c));return b?b.length?b:W.none:a}static compile(a,b){let c=Object.create(null);a.forEach((a,d)=>c[a]=new av(a,b,d));let d=b.spec.topNode||"doc";if(!c[d])throw RangeError("Schema is missing its top node type ('"+d+"')");if(!c.text)throw RangeError("Every schema needs a 'text' type");for(let a in c.text.attrs)throw RangeError("The text node type should not have attributes");return c}}class aw{constructor(a,b,c){this.hasDefault=Object.prototype.hasOwnProperty.call(c,"default"),this.default=c.default,this.validate="string"==typeof c.validate?function(a,b,c){let d=c.split("|");return c=>{let e=null===c?"null":typeof c;if(0>d.indexOf(e))throw RangeError(`Expected value of type ${d} for attribute ${b} on type ${a}, got ${e}`)}}(a,b,c.validate):c.validate}get isRequired(){return!this.hasDefault}}class ax{constructor(a,b,c,d){this.name=a,this.rank=b,this.schema=c,this.spec=d,this.attrs=au(a,d.attrs),this.excluded=null;let e=ar(this.attrs);this.instance=e?new W(this,e):null}create(a=null){return!a&&this.instance?this.instance:new W(this,as(this.attrs,a))}static compile(a,b){let c=Object.create(null),d=0;return a.forEach((a,e)=>c[a]=new ax(a,d++,b,e)),c}removeFromSet(a){for(var b=0;b<a.length;b++)a[b].type==this&&(a=a.slice(0,b).concat(a.slice(b+1)),b--);return a}isInSet(a){for(let b=0;b<a.length;b++)if(a[b].type==this)return a[b]}checkAttrs(a){at(this.attrs,a,"mark",this.name)}excludes(a){return this.excluded.indexOf(a)>-1}}class ay{constructor(a){this.linebreakReplacement=null,this.cached=Object.create(null);let b=this.spec={};for(let c in a)b[c]=a[c];b.nodes=R.from(a.nodes),b.marks=R.from(a.marks||{}),this.nodes=av.compile(this.spec.nodes,this),this.marks=ax.compile(this.spec.marks,this);let c=Object.create(null);for(let a in this.nodes){if(a in this.marks)throw RangeError(a+" can not be both a node and a mark");let b=this.nodes[a],d=b.spec.content||"",e=b.spec.marks;if(b.contentMatch=c[d]||(c[d]=am.parse(d,this.nodes)),b.inlineContent=b.contentMatch.inlineContent,b.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError("Multiple linebreak nodes defined");if(!b.isInline||!b.isLeaf)throw RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=b}b.markSet="_"==e?null:e?az(this,e.split(" ")):""!=e&&b.inlineContent?null:[]}for(let a in this.marks){let b=this.marks[a],c=b.spec.excludes;b.excluded=null==c?[b]:""==c?[]:az(this,c.split(" "))}this.nodeFromJSON=a=>aj.fromJSON(this,a),this.markFromJSON=a=>W.fromJSON(this,a),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(a,b=null,c,d){if("string"==typeof a)a=this.nodeType(a);else if(a instanceof av){if(a.schema!=this)throw RangeError("Node type from different schema used ("+a.name+")")}else throw RangeError("Invalid node type: "+a);return a.createChecked(b,c,d)}text(a,b){let c=this.nodes.text;return new ak(c,c.defaultAttrs,a,W.setFrom(b))}mark(a,b){return"string"==typeof a&&(a=this.marks[a]),a.create(b)}nodeType(a){let b=this.nodes[a];if(!b)throw RangeError("Unknown node type: "+a);return b}}function az(a,b){let c=[];for(let d=0;d<b.length;d++){let e=b[d],f=a.marks[e],g=f;if(f)c.push(f);else for(let b in a.marks){let d=a.marks[b];("_"==e||d.spec.group&&d.spec.group.split(" ").indexOf(e)>-1)&&c.push(g=d)}if(!g)throw SyntaxError("Unknown mark type: '"+b[d]+"'")}return c}class aA{constructor(a,b){this.schema=a,this.rules=b,this.tags=[],this.styles=[];let c=this.matchedStyles=[];b.forEach(a=>{if(null!=a.tag)this.tags.push(a);else if(null!=a.style){let b=/[^=]*/.exec(a.style)[0];0>c.indexOf(b)&&c.push(b),this.styles.push(a)}}),this.normalizeLists=!this.tags.some(b=>{if(!/^(ul|ol)\b/.test(b.tag)||!b.node)return!1;let c=a.nodes[b.node];return c.contentMatch.matchType(c)})}parse(a,b={}){let c=new aG(this,b,!1);return c.addAll(a,W.none,b.from,b.to),c.finish()}parseSlice(a,b={}){let c=new aG(this,b,!0);return c.addAll(a,W.none,b.from,b.to),Y.maxOpen(c.finish())}matchTag(a,b,c){for(let f=c?this.tags.indexOf(c)+1:0;f<this.tags.length;f++){var d,e;let c=this.tags[f];if(d=a,e=c.tag,(d.matches||d.msMatchesSelector||d.webkitMatchesSelector||d.mozMatchesSelector).call(d,e)&&(void 0===c.namespace||a.namespaceURI==c.namespace)&&(!c.context||b.matchesContext(c.context))){if(c.getAttrs){let b=c.getAttrs(a);if(!1===b)continue;c.attrs=b||void 0}return c}}}matchStyle(a,b,c,d){for(let e=d?this.styles.indexOf(d)+1:0;e<this.styles.length;e++){let d=this.styles[e],f=d.style;if(0==f.indexOf(a)&&(!d.context||c.matchesContext(d.context))&&(!(f.length>a.length)||61==f.charCodeAt(a.length)&&f.slice(a.length+1)==b)){if(d.getAttrs){let a=d.getAttrs(b);if(!1===a)continue;d.attrs=a||void 0}return d}}}static schemaRules(a){let b=[];function c(a){let c=null==a.priority?50:a.priority,d=0;for(;d<b.length;d++){let a=b[d];if((null==a.priority?50:a.priority)<c)break}b.splice(d,0,a)}for(let b in a.marks){let d=a.marks[b].spec.parseDOM;d&&d.forEach(a=>{c(a=aH(a)),a.mark||a.ignore||a.clearMark||(a.mark=b)})}for(let b in a.nodes){let d=a.nodes[b].spec.parseDOM;d&&d.forEach(a=>{c(a=aH(a)),a.node||a.ignore||a.mark||(a.node=b)})}return b}static fromSchema(a){return a.cached.domParser||(a.cached.domParser=new aA(a,aA.schemaRules(a)))}}let aB={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},aC={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},aD={ol:!0,ul:!0};function aE(a,b,c){return null!=b?!!b|2*("full"===b):a&&"pre"==a.whitespace?3:-5&c}class aF{constructor(a,b,c,d,e,f){this.type=a,this.attrs=b,this.marks=c,this.solid=d,this.options=f,this.content=[],this.activeMarks=W.none,this.match=e||(4&f?null:a.contentMatch)}findWrapping(a){if(!this.match){if(!this.type)return[];let b=this.type.contentMatch.fillBefore(S.from(a));if(b)this.match=this.type.contentMatch.matchFragment(b);else{let b=this.type.contentMatch,c;return(c=b.findWrapping(a.type))?(this.match=b,c):null}}return this.match.findWrapping(a.type)}finish(a){if(!(1&this.options)){let a=this.content[this.content.length-1],b;a&&a.isText&&(b=/[ \t\r\n\u000c]+$/.exec(a.text))&&(a.text.length==b[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-b[0].length)))}let b=S.from(this.content);return!a&&this.match&&(b=b.append(this.match.fillBefore(S.empty,!0))),this.type?this.type.create(this.attrs,b,this.marks):b}inlineContext(a){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:a.parentNode&&!aB.hasOwnProperty(a.parentNode.nodeName.toLowerCase())}}class aG{constructor(a,b,c){this.parser=a,this.options=b,this.isOpen=c,this.open=0,this.localPreserveWS=!1;let d=b.topNode,e,f=aE(null,b.preserveWhitespace,0)|4*!!c;e=d?new aF(d.type,d.attrs,W.none,!0,b.topMatch||d.type.contentMatch,f):c?new aF(null,null,W.none,!0,null,f):new aF(a.schema.topNodeType,null,W.none,!0,null,f),this.nodes=[e],this.find=b.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(a,b){3==a.nodeType?this.addTextNode(a,b):1==a.nodeType&&this.addElement(a,b)}addTextNode(a,b){let c=a.nodeValue,d=this.top,e=2&d.options?"full":this.localPreserveWS||(1&d.options)>0,{schema:f}=this.parser;if("full"===e||d.inlineContext(a)||/[^ \t\r\n\u000c]/.test(c)){if(e)if("full"===e)c=c.replace(/\r\n?/g,"\n");else if(f.linebreakReplacement&&/[\r\n]/.test(c)&&this.top.findWrapping(f.linebreakReplacement.create())){let a=c.split(/\r?\n|\r/);for(let c=0;c<a.length;c++)c&&this.insertNode(f.linebreakReplacement.create(),b,!0),a[c]&&this.insertNode(f.text(a[c]),b,!/\S/.test(a[c]));c=""}else c=c.replace(/\r?\n|\r/g," ");else if(c=c.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(c)&&this.open==this.nodes.length-1){let b=d.content[d.content.length-1],e=a.previousSibling;(!b||e&&"BR"==e.nodeName||b.isText&&/[ \t\r\n\u000c]$/.test(b.text))&&(c=c.slice(1))}c&&this.insertNode(f.text(c),b,!/\S/.test(c)),this.findInText(a)}else this.findInside(a)}addElement(a,b,c){let d=this.localPreserveWS,e=this.top;("PRE"==a.tagName||/pre/.test(a.style&&a.style.whiteSpace))&&(this.localPreserveWS=!0);let f=a.nodeName.toLowerCase(),g;aD.hasOwnProperty(f)&&this.parser.normalizeLists&&function(a){for(let b=a.firstChild,c=null;b;b=b.nextSibling){let a=1==b.nodeType?b.nodeName.toLowerCase():null;a&&aD.hasOwnProperty(a)&&c?(c.appendChild(b),b=c):"li"==a?c=b:a&&(c=null)}}(a);let h=this.options.ruleFromNode&&this.options.ruleFromNode(a)||(g=this.parser.matchTag(a,this,c));a:if(h?h.ignore:aC.hasOwnProperty(f))this.findInside(a),this.ignoreFallback(a,b);else if(!h||h.skip||h.closeParent){h&&h.closeParent?this.open=Math.max(0,this.open-1):h&&h.skip.nodeType&&(a=h.skip);let c,d=this.needsBlock;if(aB.hasOwnProperty(f))e.content.length&&e.content[0].isInline&&this.open&&(this.open--,e=this.top),c=!0,e.type||(this.needsBlock=!0);else if(!a.firstChild){this.leafFallback(a,b);break a}let g=h&&h.skip?b:this.readStyles(a,b);g&&this.addAll(a,g),c&&this.sync(e),this.needsBlock=d}else{let c=this.readStyles(a,b);c&&this.addElementByRule(a,h,c,!1===h.consuming?g:void 0)}this.localPreserveWS=d}leafFallback(a,b){"BR"==a.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(a.ownerDocument.createTextNode("\n"),b)}ignoreFallback(a,b){"BR"!=a.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),b,!0)}readStyles(a,b){let c=a.style;if(c&&c.length)for(let a=0;a<this.parser.matchedStyles.length;a++){let d=this.parser.matchedStyles[a],e=c.getPropertyValue(d);if(e)for(let a;;){let c=this.parser.matchStyle(d,e,this,a);if(!c)break;if(c.ignore)return null;if(b=c.clearMark?b.filter(a=>!c.clearMark(a)):b.concat(this.parser.schema.marks[c.mark].create(c.attrs)),!1===c.consuming)a=c;else break}}return b}addElementByRule(a,b,c,d){let e,f;if(b.node)if((f=this.parser.schema.nodes[b.node]).isLeaf)this.insertNode(f.create(b.attrs),c,"BR"==a.nodeName)||this.leafFallback(a,c);else{let a=this.enter(f,b.attrs||null,c,b.preserveWhitespace);a&&(e=!0,c=a)}else{let a=this.parser.schema.marks[b.mark];c=c.concat(a.create(b.attrs))}let g=this.top;if(f&&f.isLeaf)this.findInside(a);else if(d)this.addElement(a,c,d);else if(b.getContent)this.findInside(a),b.getContent(a,this.parser.schema).forEach(a=>this.insertNode(a,c,!1));else{let d=a;"string"==typeof b.contentElement?d=a.querySelector(b.contentElement):"function"==typeof b.contentElement?d=b.contentElement(a):b.contentElement&&(d=b.contentElement),this.findAround(a,d,!0),this.addAll(d,c),this.findAround(a,d,!1)}e&&this.sync(g)&&this.open--}addAll(a,b,c,d){let e=c||0;for(let f=c?a.childNodes[c]:a.firstChild,g=null==d?null:a.childNodes[d];f!=g;f=f.nextSibling,++e)this.findAtPoint(a,e),this.addDOM(f,b);this.findAtPoint(a,e)}findPlace(a,b,c){let d,e;for(let b=this.open,f=0;b>=0;b--){let g=this.nodes[b],h=g.findWrapping(a);if(h&&(!d||d.length>h.length+f)&&(d=h,e=g,!h.length))break;if(g.solid){if(c)break;f+=2}}if(!d)return null;this.sync(e);for(let a=0;a<d.length;a++)b=this.enterInner(d[a],null,b,!1);return b}insertNode(a,b,c){if(a.isInline&&this.needsBlock&&!this.top.type){let a=this.textblockFromContext();a&&(b=this.enterInner(a,null,b))}let d=this.findPlace(a,b,c);if(d){this.closeExtra();let b=this.top;b.match&&(b.match=b.match.matchType(a.type));let c=W.none;for(let e of d.concat(a.marks))(b.type?b.type.allowsMarkType(e.type):aI(e.type,a.type))&&(c=e.addToSet(c));return b.content.push(a.mark(c)),!0}return!1}enter(a,b,c,d){let e=this.findPlace(a.create(b),c,!1);return e&&(e=this.enterInner(a,b,c,!0,d)),e}enterInner(a,b,c,d=!1,e){this.closeExtra();let f=this.top;f.match=f.match&&f.match.matchType(a);let g=aE(a,e,f.options);4&f.options&&0==f.content.length&&(g|=4);let h=W.none;return c=c.filter(b=>(f.type?!f.type.allowsMarkType(b.type):!aI(b.type,a))||(h=b.addToSet(h),!1)),this.nodes.push(new aF(a,b,h,d,null,g)),this.open++,c}closeExtra(a=!1){let b=this.nodes.length-1;if(b>this.open){for(;b>this.open;b--)this.nodes[b-1].content.push(this.nodes[b].finish(a));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(a){for(let b=this.open;b>=0;b--)if(this.nodes[b]==a)return this.open=b,!0;else this.localPreserveWS&&(this.nodes[b].options|=1);return!1}get currentPos(){this.closeExtra();let a=0;for(let b=this.open;b>=0;b--){let c=this.nodes[b].content;for(let b=c.length-1;b>=0;b--)a+=c[b].nodeSize;b&&a++}return a}findAtPoint(a,b){if(this.find)for(let c=0;c<this.find.length;c++)this.find[c].node==a&&this.find[c].offset==b&&(this.find[c].pos=this.currentPos)}findInside(a){if(this.find)for(let b=0;b<this.find.length;b++)null==this.find[b].pos&&1==a.nodeType&&a.contains(this.find[b].node)&&(this.find[b].pos=this.currentPos)}findAround(a,b,c){if(a!=b&&this.find)for(let d=0;d<this.find.length;d++)null==this.find[d].pos&&1==a.nodeType&&a.contains(this.find[d].node)&&b.compareDocumentPosition(this.find[d].node)&(c?2:4)&&(this.find[d].pos=this.currentPos)}findInText(a){if(this.find)for(let b=0;b<this.find.length;b++)this.find[b].node==a&&(this.find[b].pos=this.currentPos-(a.nodeValue.length-this.find[b].offset))}matchesContext(a){if(a.indexOf("|")>-1)return a.split(/\s*\|\s*/).some(this.matchesContext,this);let b=a.split("/"),c=this.options.context,d=!this.isOpen&&(!c||c.parent.type==this.nodes[0].type),e=-(c?c.depth+1:0)+ +!d,f=(a,g)=>{for(;a>=0;a--){let h=b[a];if(""==h){if(a==b.length-1||0==a)continue;for(;g>=e;g--)if(f(a-1,g))return!0;return!1}{let a=g>0||0==g&&d?this.nodes[g].type:c&&g>=e?c.node(g-e).type:null;if(!a||a.name!=h&&!a.isInGroup(h))return!1;g--}}return!0};return f(b.length-1,this.open)}textblockFromContext(){let a=this.options.context;if(a)for(let b=a.depth;b>=0;b--){let c=a.node(b).contentMatchAt(a.indexAfter(b)).defaultType;if(c&&c.isTextblock&&c.defaultAttrs)return c}for(let a in this.parser.schema.nodes){let b=this.parser.schema.nodes[a];if(b.isTextblock&&b.defaultAttrs)return b}}}function aH(a){let b={};for(let c in a)b[c]=a[c];return b}function aI(a,b){let c=b.schema.nodes;for(let d in c){let e=c[d];if(!e.allowsMarkType(a))continue;let f=[],g=a=>{f.push(a);for(let c=0;c<a.edgeCount;c++){let{type:d,next:e}=a.edge(c);if(d==b||0>f.indexOf(e)&&g(e))return!0}};if(g(e.contentMatch))return!0}}class aJ{constructor(a,b){this.nodes=a,this.marks=b}serializeFragment(a,b={},c){c||(c=aL(b).createDocumentFragment());let d=c,e=[];return a.forEach(a=>{if(e.length||a.marks.length){let c=0,f=0;for(;c<e.length&&f<a.marks.length;){let b=a.marks[f];if(!this.marks[b.type.name]){f++;continue}if(!b.eq(e[c][0])||!1===b.type.spec.spanning)break;c++,f++}for(;c<e.length;)d=e.pop()[1];for(;f<a.marks.length;){let c=a.marks[f++],g=this.serializeMark(c,a.isInline,b);g&&(e.push([c,d]),d.appendChild(g.dom),d=g.contentDOM||g.dom)}}d.appendChild(this.serializeNodeInner(a,b))}),c}serializeNodeInner(a,b){let{dom:c,contentDOM:d}=aN(aL(b),this.nodes[a.type.name](a),null,a.attrs);if(d){if(a.isLeaf)throw RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(a.content,b,d)}return c}serializeNode(a,b={}){let c=this.serializeNodeInner(a,b);for(let d=a.marks.length-1;d>=0;d--){let e=this.serializeMark(a.marks[d],a.isInline,b);e&&((e.contentDOM||e.dom).appendChild(c),c=e.dom)}return c}serializeMark(a,b,c={}){let d=this.marks[a.type.name];return d&&aN(aL(c),d(a,b),null,a.attrs)}static renderSpec(a,b,c=null,d){return aN(a,b,c,d)}static fromSchema(a){return a.cached.domSerializer||(a.cached.domSerializer=new aJ(this.nodesFromSchema(a),this.marksFromSchema(a)))}static nodesFromSchema(a){let b=aK(a.nodes);return b.text||(b.text=a=>a.text),b}static marksFromSchema(a){return aK(a.marks)}}function aK(a){let b={};for(let c in a){let d=a[c].spec.toDOM;d&&(b[c]=d)}return b}function aL(a){return a.document||window.document}let aM=new WeakMap;function aN(a,b,c,d){let e,f,g;if("string"==typeof b)return{dom:a.createTextNode(b)};if(null!=b.nodeType)return{dom:b};if(b.dom&&null!=b.dom.nodeType)return b;let h=b[0],i;if("string"!=typeof h)throw RangeError("Invalid array passed to renderSpec");if(d&&(void 0===(f=aM.get(d))&&aM.set(d,(g=null,!function a(b){if(b&&"object"==typeof b)if(Array.isArray(b))if("string"==typeof b[0])g||(g=[]),g.push(b);else for(let c=0;c<b.length;c++)a(b[c]);else for(let c in b)a(b[c])}(d),f=g)),i=f)&&i.indexOf(b)>-1)throw RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let j=h.indexOf(" ");j>0&&(c=h.slice(0,j),h=h.slice(j+1));let k=c?a.createElementNS(c,h):a.createElement(h),l=b[1],m=1;if(l&&"object"==typeof l&&null==l.nodeType&&!Array.isArray(l)){for(let a in m=2,l)if(null!=l[a]){let b=a.indexOf(" ");b>0?k.setAttributeNS(a.slice(0,b),a.slice(b+1),l[a]):"style"==a&&k.style?k.style.cssText=l[a]:k.setAttribute(a,l[a])}}for(let f=m;f<b.length;f++){let g=b[f];if(0===g){if(f<b.length-1||f>m)throw RangeError("Content hole must be the only child of its parent node");return{dom:k,contentDOM:k}}{let{dom:b,contentDOM:f}=aN(a,g,c,d);if(k.appendChild(b),f){if(e)throw RangeError("Multiple content holes");e=f}}}return{dom:k,contentDOM:e}}class aO{constructor(a,b,c){this.pos=a,this.delInfo=b,this.recover=c}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class aP{constructor(a,b=!1){if(this.ranges=a,this.inverted=b,!a.length&&aP.empty)return aP.empty}recover(a){let b=0,c=65535&a;if(!this.inverted)for(let a=0;a<c;a++)b+=this.ranges[3*a+2]-this.ranges[3*a+1];return this.ranges[3*c]+b+(a-(65535&a))/65536}mapResult(a,b=1){return this._map(a,b,!1)}map(a,b=1){return this._map(a,b,!0)}_map(a,b,c){let d=0,e=this.inverted?2:1,f=this.inverted?1:2;for(let g=0;g<this.ranges.length;g+=3){let h=this.ranges[g]-(this.inverted?d:0);if(h>a)break;let i=this.ranges[g+e],j=this.ranges[g+f],k=h+i;if(a<=k){let e=i?a==h?-1:a==k?1:b:b,f=h+d+(e<0?0:j);if(c)return f;let l=a==(b<0?h:k)?null:g/3+(a-h)*65536,m=a==h?2:a==k?1:4;return(b<0?a!=h:a!=k)&&(m|=8),new aO(f,m,l)}d+=j-i}return c?a+d:new aO(a+d,0,null)}touches(a,b){let c=0,d=65535&b,e=this.inverted?2:1,f=this.inverted?1:2;for(let b=0;b<this.ranges.length;b+=3){let g=this.ranges[b]-(this.inverted?c:0);if(g>a)break;let h=this.ranges[b+e];if(a<=g+h&&b==3*d)return!0;c+=this.ranges[b+f]-h}return!1}forEach(a){let b=this.inverted?2:1,c=this.inverted?1:2;for(let d=0,e=0;d<this.ranges.length;d+=3){let f=this.ranges[d],g=f-(this.inverted?e:0),h=f+(this.inverted?0:e),i=this.ranges[d+b],j=this.ranges[d+c];a(g,g+i,h,h+j),e+=j-i}}invert(){return new aP(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(a){return 0==a?aP.empty:new aP(a<0?[0,-a,0]:[0,0,a])}}aP.empty=new aP([]);class aQ{constructor(a,b,c=0,d=a?a.length:0){this.mirror=b,this.from=c,this.to=d,this._maps=a||[],this.ownData=!(a||b)}get maps(){return this._maps}slice(a=0,b=this.maps.length){return new aQ(this._maps,this.mirror,a,b)}appendMap(a,b){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(a),null!=b&&this.setMirror(this._maps.length-1,b)}appendMapping(a){for(let b=0,c=this._maps.length;b<a._maps.length;b++){let d=a.getMirror(b);this.appendMap(a._maps[b],null!=d&&d<b?c+d:void 0)}}getMirror(a){if(this.mirror){for(let b=0;b<this.mirror.length;b++)if(this.mirror[b]==a)return this.mirror[b+(b%2?-1:1)]}}setMirror(a,b){this.mirror||(this.mirror=[]),this.mirror.push(a,b)}appendMappingInverted(a){for(let b=a.maps.length-1,c=this._maps.length+a._maps.length;b>=0;b--){let d=a.getMirror(b);this.appendMap(a._maps[b].invert(),null!=d&&d>b?c-d-1:void 0)}}invert(){let a=new aQ;return a.appendMappingInverted(this),a}map(a,b=1){if(this.mirror)return this._map(a,b,!0);for(let c=this.from;c<this.to;c++)a=this._maps[c].map(a,b);return a}mapResult(a,b=1){return this._map(a,b,!1)}_map(a,b,c){let d=0;for(let c=this.from;c<this.to;c++){let e=this._maps[c].mapResult(a,b);if(null!=e.recover){let b=this.getMirror(c);if(null!=b&&b>c&&b<this.to){c=b,a=this._maps[b].recover(e.recover);continue}}d|=e.delInfo,a=e.pos}return c?a:new aO(a,d,null)}}let aR=Object.create(null);class aS{getMap(){return aP.empty}merge(a){return null}static fromJSON(a,b){if(!b||!b.stepType)throw RangeError("Invalid input for Step.fromJSON");let c=aR[b.stepType];if(!c)throw RangeError(`No step type ${b.stepType} defined`);return c.fromJSON(a,b)}static jsonID(a,b){if(a in aR)throw RangeError("Duplicate use of step JSON ID "+a);return aR[a]=b,b.prototype.jsonID=a,b}}class aT{constructor(a,b){this.doc=a,this.failed=b}static ok(a){return new aT(a,null)}static fail(a){return new aT(null,a)}static fromReplace(a,b,c,d){try{return aT.ok(a.replace(b,c,d))}catch(a){if(a instanceof X)return aT.fail(a.message);throw a}}}function aU(a,b,c){let d=[];for(let e=0;e<a.childCount;e++){let f=a.child(e);f.content.size&&(f=f.copy(aU(f.content,b,f))),f.isInline&&(f=b(f,c,e)),d.push(f)}return S.fromArray(d)}class aV extends aS{constructor(a,b,c){super(),this.from=a,this.to=b,this.mark=c}apply(a){let b=a.slice(this.from,this.to),c=a.resolve(this.from),d=c.node(c.sharedDepth(this.to)),e=new Y(aU(b.content,(a,b)=>a.isAtom&&b.type.allowsMarkType(this.mark.type)?a.mark(this.mark.addToSet(a.marks)):a,d),b.openStart,b.openEnd);return aT.fromReplace(a,this.from,this.to,e)}invert(){return new aW(this.from,this.to,this.mark)}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1);return b.deleted&&c.deleted||b.pos>=c.pos?null:new aV(b.pos,c.pos,this.mark)}merge(a){return a instanceof aV&&a.mark.eq(this.mark)&&this.from<=a.to&&this.to>=a.from?new aV(Math.min(this.from,a.from),Math.max(this.to,a.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to)throw RangeError("Invalid input for AddMarkStep.fromJSON");return new aV(b.from,b.to,a.markFromJSON(b.mark))}}aS.jsonID("addMark",aV);class aW extends aS{constructor(a,b,c){super(),this.from=a,this.to=b,this.mark=c}apply(a){let b=a.slice(this.from,this.to),c=new Y(aU(b.content,a=>a.mark(this.mark.removeFromSet(a.marks)),a),b.openStart,b.openEnd);return aT.fromReplace(a,this.from,this.to,c)}invert(){return new aV(this.from,this.to,this.mark)}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1);return b.deleted&&c.deleted||b.pos>=c.pos?null:new aW(b.pos,c.pos,this.mark)}merge(a){return a instanceof aW&&a.mark.eq(this.mark)&&this.from<=a.to&&this.to>=a.from?new aW(Math.min(this.from,a.from),Math.max(this.to,a.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to)throw RangeError("Invalid input for RemoveMarkStep.fromJSON");return new aW(b.from,b.to,a.markFromJSON(b.mark))}}aS.jsonID("removeMark",aW);class aX extends aS{constructor(a,b){super(),this.pos=a,this.mark=b}apply(a){let b=a.nodeAt(this.pos);if(!b)return aT.fail("No node at mark step's position");let c=b.type.create(b.attrs,null,this.mark.addToSet(b.marks));return aT.fromReplace(a,this.pos,this.pos+1,new Y(S.from(c),0,+!b.isLeaf))}invert(a){let b=a.nodeAt(this.pos);if(b){let a=this.mark.addToSet(b.marks);if(a.length==b.marks.length){for(let c=0;c<b.marks.length;c++)if(!b.marks[c].isInSet(a))return new aX(this.pos,b.marks[c]);return new aX(this.pos,this.mark)}}return new aY(this.pos,this.mark)}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new aX(b.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(a,b){if("number"!=typeof b.pos)throw RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new aX(b.pos,a.markFromJSON(b.mark))}}aS.jsonID("addNodeMark",aX);class aY extends aS{constructor(a,b){super(),this.pos=a,this.mark=b}apply(a){let b=a.nodeAt(this.pos);if(!b)return aT.fail("No node at mark step's position");let c=b.type.create(b.attrs,null,this.mark.removeFromSet(b.marks));return aT.fromReplace(a,this.pos,this.pos+1,new Y(S.from(c),0,+!b.isLeaf))}invert(a){let b=a.nodeAt(this.pos);return b&&this.mark.isInSet(b.marks)?new aX(this.pos,this.mark):this}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new aY(b.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(a,b){if("number"!=typeof b.pos)throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new aY(b.pos,a.markFromJSON(b.mark))}}aS.jsonID("removeNodeMark",aY);class aZ extends aS{constructor(a,b,c,d=!1){super(),this.from=a,this.to=b,this.slice=c,this.structure=d}apply(a){return this.structure&&a_(a,this.from,this.to)?aT.fail("Structure replace would overwrite content"):aT.fromReplace(a,this.from,this.to,this.slice)}getMap(){return new aP([this.from,this.to-this.from,this.slice.size])}invert(a){return new aZ(this.from,this.from+this.slice.size,a.slice(this.from,this.to))}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1);return b.deletedAcross&&c.deletedAcross?null:new aZ(b.pos,Math.max(b.pos,c.pos),this.slice,this.structure)}merge(a){if(!(a instanceof aZ)||a.structure||this.structure)return null;if(this.from+this.slice.size!=a.from||this.slice.openEnd||a.slice.openStart)if(a.to!=this.from||this.slice.openStart||a.slice.openEnd)return null;else{let b=this.slice.size+a.slice.size==0?Y.empty:new Y(a.slice.content.append(this.slice.content),a.slice.openStart,this.slice.openEnd);return new aZ(a.from,this.to,b,this.structure)}{let b=this.slice.size+a.slice.size==0?Y.empty:new Y(this.slice.content.append(a.slice.content),this.slice.openStart,a.slice.openEnd);return new aZ(this.from,this.to+(a.to-a.from),b,this.structure)}}toJSON(){let a={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(a.slice=this.slice.toJSON()),this.structure&&(a.structure=!0),a}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to)throw RangeError("Invalid input for ReplaceStep.fromJSON");return new aZ(b.from,b.to,Y.fromJSON(a,b.slice),!!b.structure)}}aS.jsonID("replace",aZ);class a$ extends aS{constructor(a,b,c,d,e,f,g=!1){super(),this.from=a,this.to=b,this.gapFrom=c,this.gapTo=d,this.slice=e,this.insert=f,this.structure=g}apply(a){if(this.structure&&(a_(a,this.from,this.gapFrom)||a_(a,this.gapTo,this.to)))return aT.fail("Structure gap-replace would overwrite content");let b=a.slice(this.gapFrom,this.gapTo);if(b.openStart||b.openEnd)return aT.fail("Gap is not a flat range");let c=this.slice.insertAt(this.insert,b.content);return c?aT.fromReplace(a,this.from,this.to,c):aT.fail("Content does not fit in gap")}getMap(){return new aP([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(a){let b=this.gapTo-this.gapFrom;return new a$(this.from,this.from+this.slice.size+b,this.from+this.insert,this.from+this.insert+b,a.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1),d=this.from==this.gapFrom?b.pos:a.map(this.gapFrom,-1),e=this.to==this.gapTo?c.pos:a.map(this.gapTo,1);return b.deletedAcross&&c.deletedAcross||d<b.pos||e>c.pos?null:new a$(b.pos,c.pos,d,e,this.slice,this.insert,this.structure)}toJSON(){let a={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(a.slice=this.slice.toJSON()),this.structure&&(a.structure=!0),a}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to||"number"!=typeof b.gapFrom||"number"!=typeof b.gapTo||"number"!=typeof b.insert)throw RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new a$(b.from,b.to,b.gapFrom,b.gapTo,Y.fromJSON(a,b.slice),b.insert,!!b.structure)}}function a_(a,b,c){let d=a.resolve(b),e=c-b,f=d.depth;for(;e>0&&f>0&&d.indexAfter(f)==d.node(f).childCount;)f--,e--;if(e>0){let a=d.node(f).maybeChild(d.indexAfter(f));for(;e>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,e--}}return!1}function a0(a,b,c,d=c.contentMatch,e=!0){let f=a.doc.nodeAt(b),g=[],h=b+1;for(let b=0;b<f.childCount;b++){let i=f.child(b),j=h+i.nodeSize,k=d.matchType(i.type);if(k){d=k;for(let b=0;b<i.marks.length;b++)c.allowsMarkType(i.marks[b].type)||a.step(new aW(h,j,i.marks[b]));if(e&&i.isText&&"pre"!=c.whitespace){let a,b=/\r?\n|\r/g,d;for(;a=b.exec(i.text);)d||(d=new Y(S.from(c.schema.text(" ",c.allowedMarks(i.marks))),0,0)),g.push(new aZ(h+a.index,h+a.index+a[0].length,d))}}else g.push(new aZ(h,j,Y.empty));h=j}if(!d.validEnd){let b=d.fillBefore(S.empty,!0);a.replace(h,h,new Y(b,0,0))}for(let b=g.length-1;b>=0;b--)a.step(g[b])}function a1(a){let b=a.parent.content.cutByIndex(a.startIndex,a.endIndex);for(let c=a.depth,d=0,e=0;;--c){let f=a.$from.node(c),g=a.$from.index(c)+d,h=a.$to.indexAfter(c)-e;if(c<a.depth&&f.canReplace(g,h,b))return c;if(0==c||f.type.spec.isolating||!((0==g||f.canReplace(g,f.childCount))&&(h==f.childCount||f.canReplace(0,h))))break;g&&(d=1),h<f.childCount&&(e=1)}return null}function a2(a,b,c=null,d=a){let e=function(a,b){let{parent:c,startIndex:d,endIndex:e}=a,f=c.contentMatchAt(d).findWrapping(b);if(!f)return null;let g=f.length?f[0]:b;return c.canReplaceWith(d,e,g)?f:null}(a,b),f=e&&function(a,b){let{parent:c,startIndex:d,endIndex:e}=a,f=c.child(d),g=b.contentMatch.findWrapping(f.type);if(!g)return null;let h=(g.length?g[g.length-1]:b).contentMatch;for(let a=d;h&&a<e;a++)h=h.matchType(c.child(a).type);return h&&h.validEnd?g:null}(d,b);return f?e.map(a3).concat({type:b,attrs:c}).concat(f.map(a3)):null}function a3(a){return{type:a,attrs:null}}function a4(a,b,c,d){b.forEach((e,f)=>{if(e.isText){let g,h=/\r?\n|\r/g;for(;g=h.exec(e.text);){let e=a.mapping.slice(d).map(c+1+f+g.index);a.replaceWith(e,e+1,b.type.schema.linebreakReplacement.create())}}})}function a5(a,b,c,d){b.forEach((e,f)=>{if(e.type==e.type.schema.linebreakReplacement){let e=a.mapping.slice(d).map(c+1+f);a.replaceWith(e,e+1,b.type.schema.text("\n"))}})}function a6(a,b,c=1,d){let e=a.resolve(b),f=e.depth-c,g=d&&d[d.length-1]||e.parent;if(f<0||e.parent.type.spec.isolating||!e.parent.canReplace(e.index(),e.parent.childCount)||!g.type.validContent(e.parent.content.cutByIndex(e.index(),e.parent.childCount)))return!1;for(let a=e.depth-1,b=c-2;a>f;a--,b--){let c=e.node(a),f=e.index(a);if(c.type.spec.isolating)return!1;let g=c.content.cutByIndex(f,c.childCount),h=d&&d[b+1];h&&(g=g.replaceChild(0,h.type.create(h.attrs)));let i=d&&d[b]||c;if(!c.canReplace(f+1,c.childCount)||!i.type.validContent(g))return!1}let h=e.indexAfter(f),i=d&&d[0];return e.node(f).canReplaceWith(h,h,i?i.type:e.node(f+1).type)}function a7(a,b){let c=a.resolve(b),d=c.index();return a8(c.nodeBefore,c.nodeAfter)&&c.parent.canReplace(d,d+1)}function a8(a,b){return!!(a&&b&&!a.isLeaf&&function(a,b){b.content.size||a.type.compatibleContent(b.type);let c=a.contentMatchAt(a.childCount),{linebreakReplacement:d}=a.type.schema;for(let e=0;e<b.childCount;e++){let f=b.child(e),g=f.type==d?a.type.schema.nodes.text:f.type;if(!(c=c.matchType(g))||!a.type.allowsMarks(f.marks))return!1}return c.validEnd}(a,b))}function a9(a,b,c=-1){let d=a.resolve(b);for(let a=d.depth;;a--){let e,f,g=d.index(a);if(a==d.depth?(e=d.nodeBefore,f=d.nodeAfter):c>0?(e=d.node(a+1),g++,f=d.node(a).maybeChild(g)):(e=d.node(a).maybeChild(g-1),f=d.node(a+1)),e&&!e.isTextblock&&a8(e,f)&&d.node(a).canReplace(g,g+1))return b;if(0==a)break;b=c<0?d.before(a):d.after(a)}}function ba(a,b,c){let d=a.resolve(b);if(!c.content.size)return b;let e=c.content;for(let a=0;a<c.openStart;a++)e=e.firstChild.content;for(let a=1;a<=(0==c.openStart&&c.size?2:1);a++)for(let b=d.depth;b>=0;b--){let c=b==d.depth?0:d.pos<=(d.start(b+1)+d.end(b+1))/2?-1:1,f=d.index(b)+ +(c>0),g=d.node(b),h=!1;if(1==a)h=g.canReplace(f,f,e);else{let a=g.contentMatchAt(f).findWrapping(e.firstChild.type);h=a&&g.canReplaceWith(f,f,a[0])}if(h)return 0==c?d.pos:c<0?d.before(b+1):d.after(b+1)}return null}function bb(a,b,c=b,d=Y.empty){if(b==c&&!d.size)return null;let e=a.resolve(b),f=a.resolve(c);return bc(e,f,d)?new aZ(b,c,d):new bd(e,f,d).fit()}function bc(a,b,c){return!c.openStart&&!c.openEnd&&a.start()==b.start()&&a.parent.canReplace(a.index(),b.index(),c.content)}aS.jsonID("replaceAround",a$);class bd{constructor(a,b,c){this.$from=a,this.$to=b,this.unplaced=c,this.frontier=[],this.placed=S.empty;for(let b=0;b<=a.depth;b++){let c=a.node(b);this.frontier.push({type:c.type,match:c.contentMatchAt(a.indexAfter(b))})}for(let b=a.depth;b>0;b--)this.placed=S.from(a.node(b).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let a=this.findFittable();a?this.placeNodes(a):this.openMore()||this.dropNode()}let a=this.mustMoveInline(),b=this.placed.size-this.depth-this.$from.depth,c=this.$from,d=this.close(a<0?this.$to:c.doc.resolve(a));if(!d)return null;let e=this.placed,f=c.depth,g=d.depth;for(;f&&g&&1==e.childCount;)e=e.firstChild.content,f--,g--;let h=new Y(e,f,g);return a>-1?new a$(c.pos,a,this.$to.pos,this.$to.end(),h,b):h.size||c.pos!=this.$to.pos?new aZ(c.pos,d.pos,h):null}findFittable(){let a=this.unplaced.openStart;for(let b=this.unplaced.content,c=0,d=this.unplaced.openEnd;c<a;c++){let e=b.firstChild;if(b.childCount>1&&(d=0),e.type.spec.isolating&&d<=c){a=c;break}b=e.content}for(let b=1;b<=2;b++)for(let c=1==b?a:this.unplaced.openStart;c>=0;c--){let a=null,d=(c?(a=bg(this.unplaced.content,c-1).firstChild).content:this.unplaced.content).firstChild;for(let e=this.depth;e>=0;e--){let{type:f,match:g}=this.frontier[e],h,i=null;if(1==b&&(d?g.matchType(d.type)||(i=g.fillBefore(S.from(d),!1)):a&&f.compatibleContent(a.type)))return{sliceDepth:c,frontierDepth:e,parent:a,inject:i};if(2==b&&d&&(h=g.findWrapping(d.type)))return{sliceDepth:c,frontierDepth:e,parent:a,wrap:h};if(a&&g.matchType(a.type))break}}}openMore(){let{content:a,openStart:b,openEnd:c}=this.unplaced,d=bg(a,b);return!!d.childCount&&!d.firstChild.isLeaf&&(this.unplaced=new Y(a,b+1,Math.max(c,d.size+b>=a.size-c?b+1:0)),!0)}dropNode(){let{content:a,openStart:b,openEnd:c}=this.unplaced,d=bg(a,b);if(d.childCount<=1&&b>0){let e=a.size-b<=b+d.size;this.unplaced=new Y(be(a,b-1,1),b-1,e?b-1:c)}else this.unplaced=new Y(be(a,b,1),b,c)}placeNodes({sliceDepth:a,frontierDepth:b,parent:c,inject:d,wrap:e}){for(;this.depth>b;)this.closeFrontierNode();if(e)for(let a=0;a<e.length;a++)this.openFrontierNode(e[a]);let f=this.unplaced,g=c?c.content:f.content,h=f.openStart-a,i=0,j=[],{match:k,type:l}=this.frontier[b];if(d){for(let a=0;a<d.childCount;a++)j.push(d.child(a));k=k.matchFragment(d)}let m=g.size+a-(f.content.size-f.openEnd);for(;i<g.childCount;){let a=g.child(i),b=k.matchType(a.type);if(!b)break;(++i>1||0==h||a.content.size)&&(k=b,j.push(function a(b,c,d){if(c<=0)return b;let e=b.content;return c>1&&(e=e.replaceChild(0,a(e.firstChild,c-1,1==e.childCount?d-1:0))),c>0&&(e=b.type.contentMatch.fillBefore(e).append(e),d<=0&&(e=e.append(b.type.contentMatch.matchFragment(e).fillBefore(S.empty,!0)))),b.copy(e)}(a.mark(l.allowedMarks(a.marks)),1==i?h:0,i==g.childCount?m:-1)))}let n=i==g.childCount;n||(m=-1),this.placed=bf(this.placed,b,S.from(j)),this.frontier[b].match=k,n&&m<0&&c&&c.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let a=0,b=g;a<m;a++){let a=b.lastChild;this.frontier.push({type:a.type,match:a.contentMatchAt(a.childCount)}),b=a.content}this.unplaced=n?0==a?Y.empty:new Y(be(f.content,a-1,1),a-1,m<0?f.openEnd:a-1):new Y(be(f.content,a,i),f.openStart,f.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return -1;let a=this.frontier[this.depth],b;if(!a.type.isTextblock||!bh(this.$to,this.$to.depth,a.type,a.match,!1)||this.$to.depth==this.depth&&(b=this.findCloseLevel(this.$to))&&b.depth==this.depth)return -1;let{depth:c}=this.$to,d=this.$to.after(c);for(;c>1&&d==this.$to.end(--c);)++d;return d}findCloseLevel(a){b:for(let b=Math.min(this.depth,a.depth);b>=0;b--){let{match:c,type:d}=this.frontier[b],e=b<a.depth&&a.end(b+1)==a.pos+(a.depth-(b+1)),f=bh(a,b,d,c,e);if(f){for(let c=b-1;c>=0;c--){let{match:b,type:d}=this.frontier[c],e=bh(a,c,d,b,!0);if(!e||e.childCount)continue b}return{depth:b,fit:f,move:e?a.doc.resolve(a.after(b+1)):a}}}}close(a){let b=this.findCloseLevel(a);if(!b)return null;for(;this.depth>b.depth;)this.closeFrontierNode();b.fit.childCount&&(this.placed=bf(this.placed,b.depth,b.fit)),a=b.move;for(let c=b.depth+1;c<=a.depth;c++){let b=a.node(c),d=b.type.contentMatch.fillBefore(b.content,!0,a.index(c));this.openFrontierNode(b.type,b.attrs,d)}return a}openFrontierNode(a,b=null,c){let d=this.frontier[this.depth];d.match=d.match.matchType(a),this.placed=bf(this.placed,this.depth,S.from(a.create(b,c))),this.frontier.push({type:a,match:a.contentMatch})}closeFrontierNode(){let a=this.frontier.pop().match.fillBefore(S.empty,!0);a.childCount&&(this.placed=bf(this.placed,this.frontier.length,a))}}function be(a,b,c){return 0==b?a.cutByIndex(c,a.childCount):a.replaceChild(0,a.firstChild.copy(be(a.firstChild.content,b-1,c)))}function bf(a,b,c){return 0==b?a.append(c):a.replaceChild(a.childCount-1,a.lastChild.copy(bf(a.lastChild.content,b-1,c)))}function bg(a,b){for(let c=0;c<b;c++)a=a.firstChild.content;return a}function bh(a,b,c,d,e){let f=a.node(b),g=e?a.indexAfter(b):a.index(b);if(g==f.childCount&&!c.compatibleContent(f.type))return null;let h=d.fillBefore(f.content,!0,g);return h&&!function(a,b,c){for(let d=c;d<b.childCount;d++)if(!a.allowsMarks(b.child(d).marks))return!0;return!1}(c,f.content,g)?h:null}function bi(a,b){let c=[],d=Math.min(a.depth,b.depth);for(let e=d;e>=0;e--){let d=a.start(e);if(d<a.pos-(a.depth-e)||b.end(e)>b.pos+(b.depth-e)||a.node(e).type.spec.isolating||b.node(e).type.spec.isolating)break;(d==b.start(e)||e==a.depth&&e==b.depth&&a.parent.inlineContent&&b.parent.inlineContent&&e&&b.start(e-1)==d-1)&&c.push(e)}return c}class bj extends aS{constructor(a,b,c){super(),this.pos=a,this.attr=b,this.value=c}apply(a){let b=a.nodeAt(this.pos);if(!b)return aT.fail("No node at attribute step's position");let c=Object.create(null);for(let a in b.attrs)c[a]=b.attrs[a];c[this.attr]=this.value;let d=b.type.create(c,null,b.marks);return aT.fromReplace(a,this.pos,this.pos+1,new Y(S.from(d),0,+!b.isLeaf))}getMap(){return aP.empty}invert(a){return new bj(this.pos,this.attr,a.nodeAt(this.pos).attrs[this.attr])}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new bj(b.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(a,b){if("number"!=typeof b.pos||"string"!=typeof b.attr)throw RangeError("Invalid input for AttrStep.fromJSON");return new bj(b.pos,b.attr,b.value)}}aS.jsonID("attr",bj);class bk extends aS{constructor(a,b){super(),this.attr=a,this.value=b}apply(a){let b=Object.create(null);for(let c in a.attrs)b[c]=a.attrs[c];b[this.attr]=this.value;let c=a.type.create(b,a.content,a.marks);return aT.ok(c)}getMap(){return aP.empty}invert(a){return new bk(this.attr,a.attrs[this.attr])}map(a){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(a,b){if("string"!=typeof b.attr)throw RangeError("Invalid input for DocAttrStep.fromJSON");return new bk(b.attr,b.value)}}aS.jsonID("docAttr",bk);let bl=class extends Error{};(bl=function a(b){let c=Error.call(this,b);return c.__proto__=a.prototype,c}).prototype=Object.create(Error.prototype),bl.prototype.constructor=bl,bl.prototype.name="TransformError";class bm{constructor(a){this.doc=a,this.steps=[],this.docs=[],this.mapping=new aQ}get before(){return this.docs.length?this.docs[0]:this.doc}step(a){let b=this.maybeStep(a);if(b.failed)throw new bl(b.failed);return this}maybeStep(a){let b=a.apply(this.doc);return b.failed||this.addStep(a,b.doc),b}get docChanged(){return this.steps.length>0}changedRange(){let a=1e9,b=-1e9;for(let c=0;c<this.mapping.maps.length;c++){let d=this.mapping.maps[c];c&&(a=d.map(a,1),b=d.map(b,-1)),d.forEach((c,d,e,f)=>{a=Math.min(a,e),b=Math.max(b,f)})}return 1e9==a?null:{from:a,to:b}}addStep(a,b){this.docs.push(this.doc),this.steps.push(a),this.mapping.appendMap(a.getMap()),this.doc=b}replace(a,b=a,c=Y.empty){let d=bb(this.doc,a,b,c);return d&&this.step(d),this}replaceWith(a,b,c){return this.replace(a,b,new Y(S.from(c),0,0))}delete(a,b){return this.replace(a,b,Y.empty)}insert(a,b){return this.replaceWith(a,a,b)}replaceRange(a,b,c){return!function(a,b,c,d){if(!d.size)return a.deleteRange(b,c);let e=a.doc.resolve(b),f=a.doc.resolve(c);if(bc(e,f,d))return a.step(new aZ(b,c,d));let g=bi(e,f);0==g[g.length-1]&&g.pop();let h=-(e.depth+1);g.unshift(h);for(let a=e.depth,b=e.pos-1;a>0;a--,b--){let c=e.node(a).type.spec;if(c.defining||c.definingAsContext||c.isolating)break;g.indexOf(a)>-1?h=a:e.before(a)==b&&g.splice(1,0,-a)}let i=g.indexOf(h),j=[],k=d.openStart;for(let a=d.content,b=0;;b++){let c=a.firstChild;if(j.push(c),b==d.openStart)break;a=c.content}for(let a=k-1;a>=0;a--){var l;let b=j[a],c=(l=b.type).spec.defining||l.spec.definingForContent;if(c&&!b.sameMarkup(e.node(Math.abs(h)-1)))k=a;else if(c||!b.type.isTextblock)break}for(let b=d.openStart;b>=0;b--){let h=(b+k+1)%(d.openStart+1),l=j[h];if(l)for(let b=0;b<g.length;b++){let j=g[(b+i)%g.length],k=!0;j<0&&(k=!1,j=-j);let m=e.node(j-1),n=e.index(j-1);if(m.canReplaceWith(n,n,l.type,l.marks))return a.replace(e.before(j),k?f.after(j):c,new Y(function a(b,c,d,e,f){if(c<d){let f=b.firstChild;b=b.replaceChild(0,f.copy(a(f.content,c+1,d,e,f)))}if(c>e){let a=f.contentMatchAt(0),c=a.fillBefore(b).append(b);b=c.append(a.matchFragment(c).fillBefore(S.empty,!0))}return b}(d.content,0,d.openStart,h),h,d.openEnd))}}let m=a.steps.length;for(let h=g.length-1;h>=0&&(a.replace(b,c,d),!(a.steps.length>m));h--){let a=g[h];a<0||(b=e.before(a),c=f.after(a))}}(this,a,b,c),this}replaceRangeWith(a,b,c){var d=a,e=b;if(!c.isInline&&d==e&&this.doc.resolve(d).parent.content.size){let a=function(a,b,c){let d=a.resolve(b);if(d.parent.canReplaceWith(d.index(),d.index(),c))return b;if(0==d.parentOffset)for(let a=d.depth-1;a>=0;a--){let b=d.index(a);if(d.node(a).canReplaceWith(b,b,c))return d.before(a+1);if(b>0)return null}if(d.parentOffset==d.parent.content.size)for(let a=d.depth-1;a>=0;a--){let b=d.indexAfter(a);if(d.node(a).canReplaceWith(b,b,c))return d.after(a+1);if(b<d.node(a).childCount)break}return null}(this.doc,d,c.type);null!=a&&(d=e=a)}return this.replaceRange(d,e,new Y(S.from(c),0,0)),this}deleteRange(a,b){return!function(a,b,c){let d=a.doc.resolve(b),e=a.doc.resolve(c),f=bi(d,e);for(let b=0;b<f.length;b++){let c=f[b],g=b==f.length-1;if(g&&0==c||d.node(c).type.contentMatch.validEnd)return a.delete(d.start(c),e.end(c));if(c>0&&(g||d.node(c-1).canReplace(d.index(c-1),e.indexAfter(c-1))))return a.delete(d.before(c),e.after(c))}for(let f=1;f<=d.depth&&f<=e.depth;f++)if(b-d.start(f)==d.depth-f&&c>d.end(f)&&e.end(f)-c!=e.depth-f&&d.start(f-1)==e.start(f-1)&&d.node(f-1).canReplace(d.index(f-1),e.index(f-1)))return a.delete(d.before(f),c);a.delete(b,c)}(this,a,b),this}lift(a,b){return!function(a,b,c){let{$from:d,$to:e,depth:f}=b,g=d.before(f+1),h=e.after(f+1),i=g,j=h,k=S.empty,l=0;for(let a=f,b=!1;a>c;a--)b||d.index(a)>0?(b=!0,k=S.from(d.node(a).copy(k)),l++):i--;let m=S.empty,n=0;for(let a=f,b=!1;a>c;a--)b||e.after(a+1)<e.end(a)?(b=!0,m=S.from(e.node(a).copy(m)),n++):j++;a.step(new a$(i,j,g,h,new Y(k.append(m),l,n),k.size-l,!0))}(this,a,b),this}join(a,b=1){return!function(a,b,c){let d=null,{linebreakReplacement:e}=a.doc.type.schema,f=a.doc.resolve(b-c),g=f.node().type;if(e&&g.inlineContent){let a="pre"==g.whitespace,b=!!g.contentMatch.matchType(e);a&&!b?d=!1:!a&&b&&(d=!0)}let h=a.steps.length;if(!1===d){let d=a.doc.resolve(b+c);a5(a,d.node(),d.before(),h)}g.inlineContent&&a0(a,b+c-1,g,f.node().contentMatchAt(f.index()),null==d);let i=a.mapping.slice(h),j=i.map(b-c);if(a.step(new aZ(j,i.map(b+c,-1),Y.empty,!0)),!0===d){let b=a.doc.resolve(j);a4(a,b.node(),b.before(),a.steps.length)}}(this,a,b),this}wrap(a,b){return!function(a,b,c){let d=S.empty;for(let a=c.length-1;a>=0;a--){if(d.size){let b=c[a].type.contentMatch.matchFragment(d);if(!b||!b.validEnd)throw RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}d=S.from(c[a].type.create(c[a].attrs,d))}let e=b.start,f=b.end;a.step(new a$(e,f,e,f,new Y(d,0,0),c.length,!0))}(this,a,b),this}setBlockType(a,b=a,c,d=null){var e=this;if(!c.isTextblock)throw RangeError("Type given to setBlockType should be a textblock");let f=e.steps.length;return e.doc.nodesBetween(a,b,(a,b)=>{var g,h,i;let j,k,l="function"==typeof d?d(a):d;if(a.isTextblock&&!a.hasMarkup(c,l)&&(g=e.doc,h=e.mapping.slice(f).map(b),i=c,k=(j=g.resolve(h)).index(),j.parent.canReplaceWith(k,k+1,i))){let d=null;if(c.schema.linebreakReplacement){let a="pre"==c.whitespace,b=!!c.contentMatch.matchType(c.schema.linebreakReplacement);a&&!b?d=!1:!a&&b&&(d=!0)}!1===d&&a5(e,a,b,f),a0(e,e.mapping.slice(f).map(b,1),c,void 0,null===d);let g=e.mapping.slice(f),h=g.map(b,1),i=g.map(b+a.nodeSize,1);return e.step(new a$(h,i,h+1,i-1,new Y(S.from(c.create(l,null,a.marks)),0,0),1,!0)),!0===d&&a4(e,a,b,f),!1}}),this}setNodeMarkup(a,b,c=null,d){return!function(a,b,c,d,e){let f=a.doc.nodeAt(b);if(!f)throw RangeError("No node at given position");c||(c=f.type);let g=c.create(d,null,e||f.marks);if(f.isLeaf)return a.replaceWith(b,b+f.nodeSize,g);if(!c.validContent(f.content))throw RangeError("Invalid content for node type "+c.name);a.step(new a$(b,b+f.nodeSize,b+1,b+f.nodeSize-1,new Y(S.from(g),0,0),1,!0))}(this,a,b,c,d),this}setNodeAttribute(a,b,c){return this.step(new bj(a,b,c)),this}setDocAttribute(a,b){return this.step(new bk(a,b)),this}addNodeMark(a,b){return this.step(new aX(a,b)),this}removeNodeMark(a,b){let c=this.doc.nodeAt(a);if(!c)throw RangeError("No node at position "+a);if(b instanceof W)b.isInSet(c.marks)&&this.step(new aY(a,b));else{let d=c.marks,e,f=[];for(;e=b.isInSet(d);)f.push(new aY(a,e)),d=e.removeFromSet(d);for(let a=f.length-1;a>=0;a--)this.step(f[a])}return this}split(a,b=1,c){return!function(a,b,c=1,d){let e=a.doc.resolve(b),f=S.empty,g=S.empty;for(let a=e.depth,b=e.depth-c,h=c-1;a>b;a--,h--){f=S.from(e.node(a).copy(f));let b=d&&d[h];g=S.from(b?b.type.create(b.attrs,g):e.node(a).copy(g))}a.step(new aZ(b,b,new Y(f.append(g),c,c),!0))}(this,a,b,c),this}addMark(a,b,c){var d;let e,f,g,h;return d=this,g=[],h=[],d.doc.nodesBetween(a,b,(d,i,j)=>{if(!d.isInline)return;let k=d.marks;if(!c.isInSet(k)&&j.type.allowsMarkType(c.type)){let j=Math.max(i,a),l=Math.min(i+d.nodeSize,b),m=c.addToSet(k);for(let a=0;a<k.length;a++)k[a].isInSet(m)||(e&&e.to==j&&e.mark.eq(k[a])?e.to=l:g.push(e=new aW(j,l,k[a])));f&&f.to==j?f.to=l:h.push(f=new aV(j,l,c))}}),g.forEach(a=>d.step(a)),h.forEach(a=>d.step(a)),this}removeMark(a,b,c){var d;let e,f;return d=this,e=[],f=0,d.doc.nodesBetween(a,b,(d,g)=>{if(!d.isInline)return;f++;let h=null;if(c instanceof ax){let a=d.marks,b;for(;b=c.isInSet(a);)(h||(h=[])).push(b),a=b.removeFromSet(a)}else c?c.isInSet(d.marks)&&(h=[c]):h=d.marks;if(h&&h.length){let c=Math.min(g+d.nodeSize,b);for(let b=0;b<h.length;b++){let d=h[b],i;for(let a=0;a<e.length;a++){let b=e[a];b.step==f-1&&d.eq(e[a].style)&&(i=b)}i?(i.to=c,i.step=f):e.push({style:d,from:Math.max(g,a),to:c,step:f})}}}),e.forEach(a=>d.step(new aW(a.from,a.to,a.style))),this}clearIncompatible(a,b,c){return a0(this,a,b,c),this}}let bn=Object.create(null);class bo{constructor(a,b,c){this.$anchor=a,this.$head=b,this.ranges=c||[new bp(a.min(b),a.max(b))]}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 a=this.ranges;for(let b=0;b<a.length;b++)if(a[b].$from.pos!=a[b].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(a,b=Y.empty){let c=b.content.lastChild,d=null;for(let a=0;a<b.openEnd;a++)d=c,c=c.lastChild;let e=a.steps.length,f=this.ranges;for(let g=0;g<f.length;g++){let{$from:h,$to:i}=f[g],j=a.mapping.slice(e);a.replaceRange(j.map(h.pos),j.map(i.pos),g?Y.empty:b),0==g&&bz(a,e,(c?c.isInline:d&&d.isTextblock)?-1:1)}}replaceWith(a,b){let c=a.steps.length,d=this.ranges;for(let e=0;e<d.length;e++){let{$from:f,$to:g}=d[e],h=a.mapping.slice(c),i=h.map(f.pos),j=h.map(g.pos);e?a.deleteRange(i,j):(a.replaceRangeWith(i,j,b),bz(a,c,b.isInline?-1:1))}}static findFrom(a,b,c=!1){let d=a.parent.inlineContent?new bs(a):by(a.node(0),a.parent,a.pos,a.index(),b,c);if(d)return d;for(let d=a.depth-1;d>=0;d--){let e=b<0?by(a.node(0),a.node(d),a.before(d+1),a.index(d),b,c):by(a.node(0),a.node(d),a.after(d+1),a.index(d)+1,b,c);if(e)return e}return null}static near(a,b=1){return this.findFrom(a,b)||this.findFrom(a,-b)||new bw(a.node(0))}static atStart(a){return by(a,a,0,0,1)||new bw(a)}static atEnd(a){return by(a,a,a.content.size,a.childCount,-1)||new bw(a)}static fromJSON(a,b){if(!b||!b.type)throw RangeError("Invalid input for Selection.fromJSON");let c=bn[b.type];if(!c)throw RangeError(`No selection type ${b.type} defined`);return c.fromJSON(a,b)}static jsonID(a,b){if(a in bn)throw RangeError("Duplicate use of selection JSON ID "+a);return bn[a]=b,b.prototype.jsonID=a,b}getBookmark(){return bs.between(this.$anchor,this.$head).getBookmark()}}bo.prototype.visible=!0;class bp{constructor(a,b){this.$from=a,this.$to=b}}let bq=!1;function br(a){bq||a.parent.inlineContent||(bq=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+a.parent.type.name+")"))}class bs extends bo{constructor(a,b=a){br(a),br(b),super(a,b)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(a,b){let c=a.resolve(b.map(this.head));if(!c.parent.inlineContent)return bo.near(c);let d=a.resolve(b.map(this.anchor));return new bs(d.parent.inlineContent?d:c,c)}replace(a,b=Y.empty){if(super.replace(a,b),b==Y.empty){let b=this.$from.marksAcross(this.$to);b&&a.ensureMarks(b)}}eq(a){return a instanceof bs&&a.anchor==this.anchor&&a.head==this.head}getBookmark(){return new bt(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(a,b){if("number"!=typeof b.anchor||"number"!=typeof b.head)throw RangeError("Invalid input for TextSelection.fromJSON");return new bs(a.resolve(b.anchor),a.resolve(b.head))}static create(a,b,c=b){let d=a.resolve(b);return new this(d,c==b?d:a.resolve(c))}static between(a,b,c){let d=a.pos-b.pos;if((!c||d)&&(c=d>=0?1:-1),!b.parent.inlineContent){let a=bo.findFrom(b,c,!0)||bo.findFrom(b,-c,!0);if(!a)return bo.near(b,c);b=a.$head}return a.parent.inlineContent||(0==d?a=b:(a=(bo.findFrom(a,-c,!0)||bo.findFrom(a,c,!0)).$anchor).pos<b.pos!=d<0&&(a=b)),new bs(a,b)}}bo.jsonID("text",bs);class bt{constructor(a,b){this.anchor=a,this.head=b}map(a){return new bt(a.map(this.anchor),a.map(this.head))}resolve(a){return bs.between(a.resolve(this.anchor),a.resolve(this.head))}}class bu extends bo{constructor(a){let b=a.nodeAfter,c=a.node(0).resolve(a.pos+b.nodeSize);super(a,c),this.node=b}map(a,b){let{deleted:c,pos:d}=b.mapResult(this.anchor),e=a.resolve(d);return c?bo.near(e):new bu(e)}content(){return new Y(S.from(this.node),0,0)}eq(a){return a instanceof bu&&a.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new bv(this.anchor)}static fromJSON(a,b){if("number"!=typeof b.anchor)throw RangeError("Invalid input for NodeSelection.fromJSON");return new bu(a.resolve(b.anchor))}static create(a,b){return new bu(a.resolve(b))}static isSelectable(a){return!a.isText&&!1!==a.type.spec.selectable}}bu.prototype.visible=!1,bo.jsonID("node",bu);class bv{constructor(a){this.anchor=a}map(a){let{deleted:b,pos:c}=a.mapResult(this.anchor);return b?new bt(c,c):new bv(c)}resolve(a){let b=a.resolve(this.anchor),c=b.nodeAfter;return c&&bu.isSelectable(c)?new bu(b):bo.near(b)}}class bw extends bo{constructor(a){super(a.resolve(0),a.resolve(a.content.size))}replace(a,b=Y.empty){if(b==Y.empty){a.delete(0,a.doc.content.size);let b=bo.atStart(a.doc);b.eq(a.selection)||a.setSelection(b)}else super.replace(a,b)}toJSON(){return{type:"all"}}static fromJSON(a){return new bw(a)}map(a){return new bw(a)}eq(a){return a instanceof bw}getBookmark(){return bx}}bo.jsonID("all",bw);let bx={map(){return this},resolve:a=>new bw(a)};function by(a,b,c,d,e,f=!1){if(b.inlineContent)return bs.create(a,c);for(let g=d-(e>0?0:1);e>0?g<b.childCount:g>=0;g+=e){let d=b.child(g);if(d.isAtom){if(!f&&bu.isSelectable(d))return bu.create(a,c-(e<0?d.nodeSize:0))}else{let b=by(a,d,c+e,e<0?d.childCount:0,e,f);if(b)return b}c+=d.nodeSize*e}return null}function bz(a,b,c){let d,e=a.steps.length-1;if(e<b)return;let f=a.steps[e];(f instanceof aZ||f instanceof a$)&&(a.mapping.maps[e].forEach((a,b,c,e)=>{null==d&&(d=e)}),a.setSelection(bo.near(a.doc.resolve(d),c)))}class bA extends bm{constructor(a){super(a.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=a.selection,this.storedMarks=a.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(a){if(a.$from.doc!=this.doc)throw RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=a,this.curSelectionFor=this.steps.length,this.updated=(1|this.updated)&-3,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(a){return this.storedMarks=a,this.updated|=2,this}ensureMarks(a){return W.sameSet(this.storedMarks||this.selection.$from.marks(),a)||this.setStoredMarks(a),this}addStoredMark(a){return this.ensureMarks(a.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(a){return this.ensureMarks(a.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(a,b){super.addStep(a,b),this.updated=-3&this.updated,this.storedMarks=null}setTime(a){return this.time=a,this}replaceSelection(a){return this.selection.replace(this,a),this}replaceSelectionWith(a,b=!0){let c=this.selection;return b&&(a=a.mark(this.storedMarks||(c.empty?c.$from.marks():c.$from.marksAcross(c.$to)||W.none))),c.replaceWith(this,a),this}deleteSelection(){return this.selection.replace(this),this}insertText(a,b,c){let d=this.doc.type.schema;if(null==b)return a?this.replaceSelectionWith(d.text(a),!0):this.deleteSelection();{if(null==c&&(c=b),!a)return this.deleteRange(b,c);let e=this.storedMarks;if(!e){let a=this.doc.resolve(b);e=c==b?a.marks():a.marksAcross(this.doc.resolve(c))}return this.replaceRangeWith(b,c,d.text(a,e)),this.selection.empty||this.selection.to!=b+a.length||this.setSelection(bo.near(this.selection.$to)),this}}setMeta(a,b){return this.meta["string"==typeof a?a:a.key]=b,this}getMeta(a){return this.meta["string"==typeof a?a:a.key]}get isGeneric(){for(let a in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function bB(a,b){return b&&a?a.bind(b):a}class bC{constructor(a,b,c){this.name=a,this.init=bB(b.init,c),this.apply=bB(b.apply,c)}}let bD=[new bC("doc",{init:a=>a.doc||a.schema.topNodeType.createAndFill(),apply:a=>a.doc}),new bC("selection",{init:(a,b)=>a.selection||bo.atStart(b.doc),apply:a=>a.selection}),new bC("storedMarks",{init:a=>a.storedMarks||null,apply:(a,b,c,d)=>d.selection.$cursor?a.storedMarks:null}),new bC("scrollToSelection",{init:()=>0,apply:(a,b)=>a.scrolledIntoView?b+1:b})];class bE{constructor(a,b){this.schema=a,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=bD.slice(),b&&b.forEach(a=>{if(this.pluginsByKey[a.key])throw RangeError("Adding different instances of a keyed plugin ("+a.key+")");this.plugins.push(a),this.pluginsByKey[a.key]=a,a.spec.state&&this.fields.push(new bC(a.key,a.spec.state,a))})}}class bF{constructor(a){this.config=a}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(a){return this.applyTransaction(a).state}filterTransaction(a,b=-1){for(let c=0;c<this.config.plugins.length;c++)if(c!=b){let b=this.config.plugins[c];if(b.spec.filterTransaction&&!b.spec.filterTransaction.call(b,a,this))return!1}return!0}applyTransaction(a){if(!this.filterTransaction(a))return{state:this,transactions:[]};let b=[a],c=this.applyInner(a),d=null;for(;;){let e=!1;for(let f=0;f<this.config.plugins.length;f++){let g=this.config.plugins[f];if(g.spec.appendTransaction){let h=d?d[f].n:0,i=d?d[f].state:this,j=h<b.length&&g.spec.appendTransaction.call(g,h?b.slice(h):b,i,c);if(j&&c.filterTransaction(j,f)){if(j.setMeta("appendedTransaction",a),!d){d=[];for(let a=0;a<this.config.plugins.length;a++)d.push(a<f?{state:c,n:b.length}:{state:this,n:0})}b.push(j),c=c.applyInner(j),e=!0}d&&(d[f]={state:c,n:b.length})}}if(!e)return{state:c,transactions:b}}}applyInner(a){if(!a.before.eq(this.doc))throw RangeError("Applying a mismatched transaction");let b=new bF(this.config),c=this.config.fields;for(let d=0;d<c.length;d++){let e=c[d];b[e.name]=e.apply(a,this[e.name],this,b)}return b}get tr(){return new bA(this)}static create(a){let b=new bE(a.doc?a.doc.type.schema:a.schema,a.plugins),c=new bF(b);for(let d=0;d<b.fields.length;d++)c[b.fields[d].name]=b.fields[d].init(a,c);return c}reconfigure(a){let b=new bE(this.schema,a.plugins),c=b.fields,d=new bF(b);for(let b=0;b<c.length;b++){let e=c[b].name;d[e]=this.hasOwnProperty(e)?this[e]:c[b].init(a,d)}return d}toJSON(a){let b={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(b.storedMarks=this.storedMarks.map(a=>a.toJSON())),a&&"object"==typeof a)for(let c in a){if("doc"==c||"selection"==c)throw RangeError("The JSON fields `doc` and `selection` are reserved");let d=a[c],e=d.spec.state;e&&e.toJSON&&(b[c]=e.toJSON.call(d,this[d.key]))}return b}static fromJSON(a,b,c){if(!b)throw RangeError("Invalid input for EditorState.fromJSON");if(!a.schema)throw RangeError("Required config field 'schema' missing");let d=new bE(a.schema,a.plugins),e=new bF(d);return d.fields.forEach(d=>{if("doc"==d.name)e.doc=aj.fromJSON(a.schema,b.doc);else if("selection"==d.name)e.selection=bo.fromJSON(e.doc,b.selection);else if("storedMarks"==d.name)b.storedMarks&&(e.storedMarks=b.storedMarks.map(a.schema.markFromJSON));else{if(c)for(let f in c){let g=c[f],h=g.spec.state;if(g.key==d.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(b,f)){e[d.name]=h.fromJSON.call(g,a,b[f],e);return}}e[d.name]=d.init(a,e)}}),e}}class bG{constructor(a){this.spec=a,this.props={},a.props&&function a(b,c,d){for(let e in b){let f=b[e];f instanceof Function?f=f.bind(c):"handleDOMEvents"==e&&(f=a(f,c,{})),d[e]=f}return d}(a.props,this,this.props),this.key=a.key?a.key.key:bI("plugin")}getState(a){return a[this.key]}}let bH=Object.create(null);function bI(a){return a in bH?a+"$"+ ++bH[a]:(bH[a]=0,a+"$")}class bJ{constructor(a="key"){this.key=bI(a)}get(a){return a.config.pluginsByKey[this.key]}getState(a){return a[this.key]}}let bK=(a,b)=>!a.selection.empty&&(b&&b(a.tr.deleteSelection().scrollIntoView()),!0);function bL(a,b){let{$cursor:c}=a.selection;return c&&(b?b.endOfTextblock("backward",a):!(c.parentOffset>0))?c:null}let bM=(a,b,c)=>{let d=bL(a,c);if(!d)return!1;let e=bQ(d);if(!e){let c=d.blockRange(),e=c&&a1(c);return null!=e&&(b&&b(a.tr.lift(c,e).scrollIntoView()),!0)}let f=e.nodeBefore;if(b$(a,e,b,-1))return!0;if(0==d.parent.content.size&&(bO(f,"end")||bu.isSelectable(f)))for(let c=d.depth;;c--){let g=bb(a.doc,d.before(c),d.after(c),Y.empty);if(g&&g.slice.size<g.to-g.from){if(b){let c=a.tr.step(g);c.setSelection(bO(f,"end")?bo.findFrom(c.doc.resolve(c.mapping.map(e.pos,-1)),-1):bu.create(c.doc,e.pos-f.nodeSize)),b(c.scrollIntoView())}return!0}if(1==c||d.node(c-1).childCount>1)break}return!!f.isAtom&&e.depth==d.depth-1&&(b&&b(a.tr.delete(e.pos-f.nodeSize,e.pos).scrollIntoView()),!0)};function bN(a,b,c){let d=b.nodeBefore,e=b.pos-1;for(;!d.isTextblock;e--){if(d.type.spec.isolating)return!1;let a=d.lastChild;if(!a)return!1;d=a}let f=b.nodeAfter,g=b.pos+1;for(;!f.isTextblock;g++){if(f.type.spec.isolating)return!1;let a=f.firstChild;if(!a)return!1;f=a}let h=bb(a.doc,e,g,Y.empty);if(!h||h.from!=e||h instanceof aZ&&h.slice.size>=g-e)return!1;if(c){let b=a.tr.step(h);b.setSelection(bs.create(b.doc,e)),c(b.scrollIntoView())}return!0}function bO(a,b,c=!1){for(let d=a;d;d="start"==b?d.firstChild:d.lastChild){if(d.isTextblock)return!0;if(c&&1!=d.childCount)break}return!1}let bP=(a,b,c)=>{let{$head:d,empty:e}=a.selection,f=d;if(!e)return!1;if(d.parent.isTextblock){if(c?!c.endOfTextblock("backward",a):d.parentOffset>0)return!1;f=bQ(d)}let g=f&&f.nodeBefore;return!!g&&!!bu.isSelectable(g)&&(b&&b(a.tr.setSelection(bu.create(a.doc,f.pos-g.nodeSize)).scrollIntoView()),!0)};function bQ(a){if(!a.parent.type.spec.isolating)for(let b=a.depth-1;b>=0;b--){if(a.index(b)>0)return a.doc.resolve(a.before(b+1));if(a.node(b).type.spec.isolating)break}return null}function bR(a,b){let{$cursor:c}=a.selection;return c&&(b?b.endOfTextblock("forward",a):!(c.parentOffset<c.parent.content.size))?c:null}let bS=(a,b,c)=>{let d=bR(a,c);if(!d)return!1;let e=bU(d);if(!e)return!1;let f=e.nodeAfter;if(b$(a,e,b,1))return!0;if(0==d.parent.content.size&&(bO(f,"start")||bu.isSelectable(f))){let c=bb(a.doc,d.before(),d.after(),Y.empty);if(c&&c.slice.size<c.to-c.from){if(b){let d=a.tr.step(c);d.setSelection(bO(f,"start")?bo.findFrom(d.doc.resolve(d.mapping.map(e.pos)),1):bu.create(d.doc,d.mapping.map(e.pos))),b(d.scrollIntoView())}return!0}}return!!f.isAtom&&e.depth==d.depth-1&&(b&&b(a.tr.delete(e.pos,e.pos+f.nodeSize).scrollIntoView()),!0)},bT=(a,b,c)=>{let{$head:d,empty:e}=a.selection,f=d;if(!e)return!1;if(d.parent.isTextblock){if(c?!c.endOfTextblock("forward",a):d.parentOffset<d.parent.content.size)return!1;f=bU(d)}let g=f&&f.nodeAfter;return!!g&&!!bu.isSelectable(g)&&(b&&b(a.tr.setSelection(bu.create(a.doc,f.pos)).scrollIntoView()),!0)};function bU(a){if(!a.parent.type.spec.isolating)for(let b=a.depth-1;b>=0;b--){let c=a.node(b);if(a.index(b)+1<c.childCount)return a.doc.resolve(a.after(b+1));if(c.type.spec.isolating)break}return null}let bV=(a,b)=>{let{$head:c,$anchor:d}=a.selection;return!!c.parent.type.spec.code&&!!c.sameParent(d)&&(b&&b(a.tr.insertText("\n").scrollIntoView()),!0)};function bW(a){for(let b=0;b<a.edgeCount;b++){let{type:c}=a.edge(b);if(c.isTextblock&&!c.hasRequiredAttrs())return c}return null}let bX=(a,b)=>{let{$head:c,$anchor:d}=a.selection;if(!c.parent.type.spec.code||!c.sameParent(d))return!1;let e=c.node(-1),f=c.indexAfter(-1),g=bW(e.contentMatchAt(f));if(!g||!e.canReplaceWith(f,f,g))return!1;if(b){let d=c.after(),e=a.tr.replaceWith(d,d,g.createAndFill());e.setSelection(bo.near(e.doc.resolve(d),1)),b(e.scrollIntoView())}return!0},bY=(a,b)=>{let c=a.selection,{$from:d,$to:e}=c;if(c instanceof bw||d.parent.inlineContent||e.parent.inlineContent)return!1;let f=bW(e.parent.contentMatchAt(e.indexAfter()));if(!f||!f.isTextblock)return!1;if(b){let c=(!d.parentOffset&&e.index()<e.parent.childCount?d:e).pos,g=a.tr.insert(c,f.createAndFill());g.setSelection(bs.create(g.doc,c+1)),b(g.scrollIntoView())}return!0},bZ=(a,b)=>{let{$cursor:c}=a.selection;if(!c||c.parent.content.size)return!1;if(c.depth>1&&c.after()!=c.end(-1)){let d=c.before();if(a6(a.doc,d))return b&&b(a.tr.split(d).scrollIntoView()),!0}let d=c.blockRange(),e=d&&a1(d);return null!=e&&(b&&b(a.tr.lift(d,e).scrollIntoView()),!0)};function b$(a,b,c,d){let e,f,g,h=b.nodeBefore,i=b.nodeAfter,j,k,l=h.type.spec.isolating||i.type.spec.isolating;if(!l&&(e=b.nodeBefore,f=b.nodeAfter,g=b.index(),e&&f&&e.type.compatibleContent(f.type)&&(!e.content.size&&b.parent.canReplace(g-1,g)?(c&&c(a.tr.delete(b.pos-e.nodeSize,b.pos).scrollIntoView()),!0):!!b.parent.canReplace(g,g+1)&&!!(f.isTextblock||a7(a.doc,b.pos))&&(c&&c(a.tr.join(b.pos).scrollIntoView()),!0))))return!0;let m=!l&&b.parent.canReplace(b.index(),b.index()+1);if(m&&(j=(k=h.contentMatchAt(h.childCount)).findWrapping(i.type))&&k.matchType(j[0]||i.type).validEnd){if(c){let d=b.pos+i.nodeSize,e=S.empty;for(let a=j.length-1;a>=0;a--)e=S.from(j[a].create(null,e));e=S.from(h.copy(e));let f=a.tr.step(new a$(b.pos-1,d,b.pos,d,new Y(e,1,0),j.length,!0)),g=f.doc.resolve(d+2*j.length);g.nodeAfter&&g.nodeAfter.type==h.type&&a7(f.doc,g.pos)&&f.join(g.pos),c(f.scrollIntoView())}return!0}let n=i.type.spec.isolating||d>0&&l?null:bo.findFrom(b,1),o=n&&n.$from.blockRange(n.$to),p=o&&a1(o);if(null!=p&&p>=b.depth)return c&&c(a.tr.lift(o,p).scrollIntoView()),!0;if(m&&bO(i,"start",!0)&&bO(h,"end")){let d=h,e=[];for(;e.push(d),!d.isTextblock;)d=d.lastChild;let f=i,g=1;for(;!f.isTextblock;f=f.firstChild)g++;if(d.canReplace(d.childCount,d.childCount,f.content)){if(c){let d=S.empty;for(let a=e.length-1;a>=0;a--)d=S.from(e[a].copy(d));c(a.tr.step(new a$(b.pos-e.length,b.pos+i.nodeSize,b.pos+g,b.pos+i.nodeSize-g,new Y(d,e.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function b_(a){return function(b,c){let d=b.selection,e=a<0?d.$from:d.$to,f=e.depth;for(;e.node(f).isInline;){if(!f)return!1;f--}return!!e.node(f).isTextblock&&(c&&c(b.tr.setSelection(bs.create(b.doc,a<0?e.start(f):e.end(f)))),!0)}}let b0=b_(-1),b1=b_(1);function b2(a,b=null){return function(c,d){let e=!1;for(let d=0;d<c.selection.ranges.length&&!e;d++){let{$from:{pos:f},$to:{pos:g}}=c.selection.ranges[d];c.doc.nodesBetween(f,g,(d,f)=>{if(e)return!1;if(!(!d.isTextblock||d.hasMarkup(a,b)))if(d.type==a)e=!0;else{let b=c.doc.resolve(f),d=b.index();e=b.parent.canReplaceWith(d,d+1,a)}})}if(!e)return!1;if(d){let e=c.tr;for(let d=0;d<c.selection.ranges.length;d++){let{$from:{pos:f},$to:{pos:g}}=c.selection.ranges[d];e.setBlockType(f,g,a,b)}d(e.scrollIntoView())}return!0}}function b3(...a){return function(b,c,d){for(let e=0;e<a.length;e++)if(a[e](b,c,d))return!0;return!1}}let b4=b3(bK,bM,bP),b5=b3(bK,bS,bT),b6={Enter:b3(bV,bY,bZ,(a,b)=>{let{$from:c,$to:d}=a.selection;if(a.selection instanceof bu&&a.selection.node.isBlock)return!!c.parentOffset&&!!a6(a.doc,c.pos)&&(b&&b(a.tr.split(c.pos).scrollIntoView()),!0);if(!c.depth)return!1;let e=[],f,g,h=!1,i=!1;for(let a=c.depth;;a--){if(c.node(a).isBlock){let b;h=c.end(a)==c.pos+(c.depth-a),i=c.start(a)==c.pos-(c.depth-a),g=bW(c.node(a-1).contentMatchAt(c.indexAfter(a-1)));e.unshift(b||(h&&g?{type:g}:null)),f=a;break}if(1==a)return!1;e.unshift(null)}let j=a.tr;(a.selection instanceof bs||a.selection instanceof bw)&&j.deleteSelection();let k=j.mapping.map(c.pos),l=a6(j.doc,k,e.length,e);if(l||(e[0]=g?{type:g}:null,l=a6(j.doc,k,e.length,e)),!l)return!1;if(j.split(k,e.length,e),!h&&i&&c.node(f).type!=g){let a=j.mapping.map(c.before(f)),b=j.doc.resolve(a);g&&c.node(f-1).canReplaceWith(b.index(),b.index()+1,g)&&j.setNodeMarkup(j.mapping.map(c.before(f)),g)}return b&&b(j.scrollIntoView()),!0}),"Mod-Enter":bX,Backspace:b4,"Mod-Backspace":b4,"Shift-Backspace":b4,Delete:b5,"Mod-Delete":b5,"Mod-a":(a,b)=>(b&&b(a.tr.setSelection(new bw(a.doc))),!0)},b7={"Ctrl-h":b6.Backspace,"Alt-Backspace":b6["Mod-Backspace"],"Ctrl-d":b6.Delete,"Ctrl-Alt-Backspace":b6["Mod-Delete"],"Alt-Delete":b6["Mod-Delete"],"Alt-d":b6["Mod-Delete"],"Ctrl-a":b0,"Ctrl-e":b1};for(let a in b6)b7[a]=b6[a];"u">typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"u">typeof os&&os.platform&&os.platform();let b8=function(a){for(var b=0;;b++)if(!(a=a.previousSibling))return b},b9=function(a){let b=a.assignedSlot||a.parentNode;return b&&11==b.nodeType?b.host:b},ca=null,cb=function(a,b,c){let d=ca||(ca=document.createRange());return d.setEnd(a,null==c?a.nodeValue.length:c),d.setStart(a,b||0),d},cc=function(){ca=null},cd=function(a,b,c,d){return c&&(cf(a,b,c,d,-1)||cf(a,b,c,d,1))},ce=/^(img|br|input|textarea|hr)$/i;function cf(a,b,c,d,e){for(var f;;){if(a==c&&b==d)return!0;if(b==(e<0?0:cg(a))){let c=a.parentNode;if(!c||1!=c.nodeType||ch(a)||ce.test(a.nodeName)||"false"==a.contentEditable)return!1;b=b8(a)+(e<0?0:1),a=c}else{if(1!=a.nodeType)return!1;let c=a.childNodes[b+(e<0?-1:0)];if(1==c.nodeType&&"false"==c.contentEditable)if(null==(f=c.pmViewDesc)||!f.ignoreForSelection)return!1;else b+=e;else a=c,b=e<0?cg(a):0}}}function cg(a){return 3==a.nodeType?a.nodeValue.length:a.childNodes.length}function ch(a){let b;for(let c=a;c&&!(b=c.pmViewDesc);c=c.parentNode);return b&&b.node&&b.node.isBlock&&(b.dom==a||b.contentDOM==a)}let ci=function(a){return a.focusNode&&cd(a.focusNode,a.focusOffset,a.anchorNode,a.anchorOffset)};function cj(a,b){let c=document.createEvent("Event");return c.initEvent("keydown",!0,!0),c.keyCode=a,c.key=c.code=b,c}let ck="u">typeof navigator?navigator:null,cl="u">typeof document?document:null,cm=ck&&ck.userAgent||"",cn=/Edge\/(\d+)/.exec(cm),co=/MSIE \d/.exec(cm),cp=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(cm),cq=!!(co||cp||cn),cr=co?document.documentMode:cp?+cp[1]:cn?+cn[1]:0,cs=!cq&&/gecko\/(\d+)/i.test(cm);cs&&(/Firefox\/(\d+)/.exec(cm)||[0,0])[1];let ct=!cq&&/Chrome\/(\d+)/.exec(cm),cu=!!ct,cv=ct?+ct[1]:0,cw=!cq&&!!ck&&/Apple Computer/.test(ck.vendor),cx=cw&&(/Mobile\/\w+/.test(cm)||!!ck&&ck.maxTouchPoints>2),cy=cx||!!ck&&/Mac/.test(ck.platform),cz=!!ck&&/Win/.test(ck.platform),cA=/Android \d/.test(cm),cB=!!cl&&"webkitFontSmoothing"in cl.documentElement.style,cC=cB?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function cD(a,b){return"number"==typeof a?a:a[b]}function cE(a,b,c){let d=a.someProp("scrollThreshold")||0,e=a.someProp("scrollMargin")||5,f=a.dom.ownerDocument;for(let g=c||a.dom;g;){if(1!=g.nodeType){g=b9(g);continue}let a=g,c=a==f.body,h=c?function(a){let b=a.defaultView&&a.defaultView.visualViewport;return b?{left:0,right:b.width,top:0,bottom:b.height}:{left:0,right:a.documentElement.clientWidth,top:0,bottom:a.documentElement.clientHeight}}(f):function(a){let b=a.getBoundingClientRect(),c=b.width/a.offsetWidth||1,d=b.height/a.offsetHeight||1;return{left:b.left,right:b.left+a.clientWidth*c,top:b.top,bottom:b.top+a.clientHeight*d}}(a),i=0,j=0;if(b.top<h.top+cD(d,"top")?j=-(h.top-b.top+cD(e,"top")):b.bottom>h.bottom-cD(d,"bottom")&&(j=b.bottom-b.top>h.bottom-h.top?b.top+cD(e,"top")-h.top:b.bottom-h.bottom+cD(e,"bottom")),b.left<h.left+cD(d,"left")?i=-(h.left-b.left+cD(e,"left")):b.right>h.right-cD(d,"right")&&(i=b.right-h.right+cD(e,"right")),i||j)if(c)f.defaultView.scrollBy(i,j);else{let c=a.scrollLeft,d=a.scrollTop;j&&(a.scrollTop+=j),i&&(a.scrollLeft+=i);let e=a.scrollLeft-c,f=a.scrollTop-d;b={left:b.left-e,top:b.top-f,right:b.right-e,bottom:b.bottom-f}}let k=c?"fixed":getComputedStyle(g).position;if(/^(fixed|sticky)$/.test(k))break;g="absolute"==k?g.offsetParent:b9(g)}}function cF(a){let b=[],c=a.ownerDocument;for(let d=a;d&&(b.push({dom:d,top:d.scrollTop,left:d.scrollLeft}),a!=c);d=b9(d));return b}function cG(a,b){for(let c=0;c<a.length;c++){let{dom:d,top:e,left:f}=a[c];d.scrollTop!=e+b&&(d.scrollTop=e+b),d.scrollLeft!=f&&(d.scrollLeft=f)}}let cH=null;function cI(a,b){return a.left>=b.left-1&&a.left<=b.right+1&&a.top>=b.top-1&&a.top<=b.bottom+1}function cJ(a){return a.top<a.bottom||a.left<a.right}function cK(a,b){let c=a.getClientRects();if(c.length){let a=c[b<0?0:c.length-1];if(cJ(a))return a}return Array.prototype.find.call(c,cJ)||a.getBoundingClientRect()}let cL=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function cM(a,b,c){let{node:d,offset:e,atom:f}=a.docView.domFromPos(b,c<0?-1:1),g=cB||cs;if(3==d.nodeType)if(g&&(cL.test(d.nodeValue)||(c<0?!e:e==d.nodeValue.length))){let a=cK(cb(d,e,e),c);if(cs&&e&&/\s/.test(d.nodeValue[e-1])&&e<d.nodeValue.length){let b=cK(cb(d,e-1,e-1),-1);if(b.top==a.top){let c=cK(cb(d,e,e+1),-1);if(c.top!=a.top)return cN(c,c.left<b.left)}}return a}else{let a=e,b=e,f=c<0?1:-1;return c<0&&!e?(b++,f=-1):c>=0&&e==d.nodeValue.length?(a--,f=1):c<0?a--:b++,cN(cK(cb(d,a,b),f),f<0)}if(!a.state.doc.resolve(b-(f||0)).parent.inlineContent){if(null==f&&e&&(c<0||e==cg(d))){let a=d.childNodes[e-1];if(1==a.nodeType)return cO(a.getBoundingClientRect(),!1)}if(null==f&&e<cg(d)){let a=d.childNodes[e];if(1==a.nodeType)return cO(a.getBoundingClientRect(),!0)}return cO(d.getBoundingClientRect(),c>=0)}if(null==f&&e&&(c<0||e==cg(d))){let a=d.childNodes[e-1],b=3==a.nodeType?cb(a,cg(a)-!g):1!=a.nodeType||"BR"==a.nodeName&&a.nextSibling?null:a;if(b)return cN(cK(b,1),!1)}if(null==f&&e<cg(d)){let a=d.childNodes[e];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let b=a?3==a.nodeType?cb(a,0,+!g):1==a.nodeType?a:null:null;if(b)return cN(cK(b,-1),!0)}return cN(cK(3==d.nodeType?cb(d):d,-c),c>=0)}function cN(a,b){if(0==a.width)return a;let c=b?a.left:a.right;return{top:a.top,bottom:a.bottom,left:c,right:c}}function cO(a,b){if(0==a.height)return a;let c=b?a.top:a.bottom;return{top:c,bottom:c,left:a.left,right:a.right}}function cP(a,b,c){let d=a.state,e=a.root.activeElement;d!=b&&a.updateState(b),e!=a.dom&&a.focus();try{return c()}finally{d!=b&&a.updateState(d),e!=a.dom&&e&&e.focus()}}let cQ=/[\u0590-\u08ac]/,cR=null,cS=null,cT=!1;class cU{constructor(a,b,c,d){this.parent=a,this.children=b,this.dom=c,this.contentDOM=d,this.dirty=0,c.pmViewDesc=this}matchesWidget(a){return!1}matchesMark(a){return!1}matchesNode(a,b,c){return!1}matchesHack(a){return!1}parseRule(){return null}stopEvent(a){return!1}get size(){let a=0;for(let b=0;b<this.children.length;b++)a+=this.children[b].size;return a}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let a=0;a<this.children.length;a++)this.children[a].destroy()}posBeforeChild(a){for(let b=0,c=this.posAtStart;;b++){let d=this.children[b];if(d==a)return c;c+=d.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(a,b,c){let d;if(this.contentDOM&&this.contentDOM.contains(1==a.nodeType?a:a.parentNode))if(c<0){let c,d;if(a==this.contentDOM)c=a.childNodes[b-1];else{for(;a.parentNode!=this.contentDOM;)a=a.parentNode;c=a.previousSibling}for(;c&&!((d=c.pmViewDesc)&&d.parent==this);)c=c.previousSibling;return c?this.posBeforeChild(d)+d.size:this.posAtStart}else{let c,d;if(a==this.contentDOM)c=a.childNodes[b];else{for(;a.parentNode!=this.contentDOM;)a=a.parentNode;c=a.nextSibling}for(;c&&!((d=c.pmViewDesc)&&d.parent==this);)c=c.nextSibling;return c?this.posBeforeChild(d):this.posAtEnd}if(a==this.dom&&this.contentDOM)d=b>b8(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))d=2&a.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==b)for(let b=a;;b=b.parentNode){if(b==this.dom){d=!1;break}if(b.previousSibling)break}if(null==d&&b==a.childNodes.length)for(let b=a;;b=b.parentNode){if(b==this.dom){d=!0;break}if(b.nextSibling)break}}return(null==d?c>0:d)?this.posAtEnd:this.posAtStart}nearestDesc(a,b=!1){for(let c=!0,d=a;d;d=d.parentNode){let e=this.getDesc(d),f;if(e&&(!b||e.node))if(!c||!(f=e.nodeDOM)||(1==f.nodeType?f.contains(1==a.nodeType?a:a.parentNode):f==a))return e;else c=!1}}getDesc(a){let b=a.pmViewDesc;for(let a=b;a;a=a.parent)if(a==this)return b}posFromDOM(a,b,c){for(let d=a;d;d=d.parentNode){let e=this.getDesc(d);if(e)return e.localPosFromDOM(a,b,c)}return -1}descAt(a){for(let b=0,c=0;b<this.children.length;b++){let d=this.children[b],e=c+d.size;if(c==a&&e!=c){for(;!d.border&&d.children.length;)for(let a=0;a<d.children.length;a++){let b=d.children[a];if(b.size){d=b;break}}return d}if(a<e)return d.descAt(a-c-d.border);c=e}}domFromPos(a,b){if(!this.contentDOM)return{node:this.dom,offset:0,atom:a+1};let c=0,d=0;for(let b=0;c<this.children.length;c++){let e=this.children[c],f=b+e.size;if(f>a||e instanceof c_){d=a-b;break}b=f}if(d)return this.children[c].domFromPos(d-this.children[c].border,b);for(let a;c&&!(a=this.children[c-1]).size&&a instanceof cV&&a.side>=0;c--);if(b<=0){let a,d=!0;for(;(a=c?this.children[c-1]:null)&&a.dom.parentNode!=this.contentDOM;c--,d=!1);return a&&b&&d&&!a.border&&!a.domAtom?a.domFromPos(a.size,b):{node:this.contentDOM,offset:a?b8(a.dom)+1:0}}{let a,d=!0;for(;(a=c<this.children.length?this.children[c]:null)&&a.dom.parentNode!=this.contentDOM;c++,d=!1);return a&&d&&!a.border&&!a.domAtom?a.domFromPos(0,b):{node:this.contentDOM,offset:a?b8(a.dom):this.contentDOM.childNodes.length}}}parseRange(a,b,c=0){if(0==this.children.length)return{node:this.contentDOM,from:a,to:b,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let d=-1,e=-1;for(let f=c,g=0;;g++){let c=this.children[g],h=f+c.size;if(-1==d&&a<=h){let e=f+c.border;if(a>=e&&b<=h-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(a,b,e);a=f;for(let b=g;b>0;b--){let c=this.children[b-1];if(c.size&&c.dom.parentNode==this.contentDOM&&!c.emptyChildAt(1)){d=b8(c.dom)+1;break}a-=c.size}-1==d&&(d=0)}if(d>-1&&(h>b||g==this.children.length-1)){b=h;for(let a=g+1;a<this.children.length;a++){let c=this.children[a];if(c.size&&c.dom.parentNode==this.contentDOM&&!c.emptyChildAt(-1)){e=b8(c.dom);break}b+=c.size}-1==e&&(e=this.contentDOM.childNodes.length);break}f=h}return{node:this.contentDOM,from:a,to:b,fromOffset:d,toOffset:e}}emptyChildAt(a){if(this.border||!this.contentDOM||!this.children.length)return!1;let b=this.children[a<0?0:this.children.length-1];return 0==b.size||b.emptyChildAt(a)}domAfterPos(a){let{node:b,offset:c}=this.domFromPos(a,0);if(1!=b.nodeType||c==b.childNodes.length)throw RangeError("No node after pos "+a);return b.childNodes[c]}setSelection(a,b,c,d=!1){let e=Math.min(a,b),f=Math.max(a,b);for(let g=0,h=0;g<this.children.length;g++){let i=this.children[g],j=h+i.size;if(e>h&&f<j)return i.setSelection(a-h-i.border,b-h-i.border,c,d);h=j}let g=this.domFromPos(a,a?-1:1),h=b==a?g:this.domFromPos(b,b?-1:1),i=c.root.getSelection(),j=c.domSelectionRange(),k=!1;if((cs||cw)&&a==b){let{node:a,offset:b}=g;if(3==a.nodeType){if((k=!!(b&&"\n"==a.nodeValue[b-1]))&&b==a.nodeValue.length)for(let b=a,c;b;b=b.parentNode){if(c=b.nextSibling){"BR"==c.nodeName&&(g=h={node:c.parentNode,offset:b8(c)+1});break}let a=b.pmViewDesc;if(a&&a.node&&a.node.isBlock)break}}else{let c=a.childNodes[b-1];k=c&&("BR"==c.nodeName||"false"==c.contentEditable)}}if(cs&&j.focusNode&&j.focusNode!=h.node&&1==j.focusNode.nodeType){let a=j.focusNode.childNodes[j.focusOffset];a&&"false"==a.contentEditable&&(d=!0)}if(!(d||k&&cw)&&cd(g.node,g.offset,j.anchorNode,j.anchorOffset)&&cd(h.node,h.offset,j.focusNode,j.focusOffset))return;let l=!1;if((i.extend||a==b)&&!(k&&cs)){i.collapse(g.node,g.offset);try{a!=b&&i.extend(h.node,h.offset),l=!0}catch(a){}}if(!l){if(a>b){let a=g;g=h,h=a}let c=document.createRange();c.setEnd(h.node,h.offset),c.setStart(g.node,g.offset),i.removeAllRanges(),i.addRange(c)}}ignoreMutation(a){return!this.contentDOM&&"selection"!=a.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(a,b){for(let c=0,d=0;d<this.children.length;d++){let e=this.children[d],f=c+e.size;if(c==f?a<=f&&b>=c:a<f&&b>c){let d=c+e.border,g=f-e.border;if(a>=d&&b<=g){this.dirty=a==c||b==f?2:1,a==d&&b==g&&(e.contentLost||e.dom.parentNode!=this.contentDOM)?e.dirty=3:e.markDirty(a-d,b-d);return}e.dirty=e.dom!=e.contentDOM||e.dom.parentNode!=this.contentDOM||e.children.length?3:2}c=f}this.dirty=2}markParentsDirty(){let a=1;for(let b=this.parent;b;b=b.parent,a++){let c=1==a?2:1;b.dirty<c&&(b.dirty=c)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(a){return!1}}class cV extends cU{constructor(a,b,c,d){let e,f=b.type.toDOM;if("function"==typeof f&&(f=f(c,()=>e?e.parent?e.parent.posBeforeChild(e):void 0:d)),!b.type.spec.raw){if(1!=f.nodeType){let a=document.createElement("span");a.appendChild(f),f=a}f.contentEditable="false",f.classList.add("ProseMirror-widget")}super(a,[],f,null),this.widget=b,this.widget=b,e=this}matchesWidget(a){return 0==this.dirty&&a.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(a){let b=this.widget.spec.stopEvent;return!!b&&b(a)}ignoreMutation(a){return"selection"!=a.type||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}}class cW extends cU{constructor(a,b,c,d){super(a,[],b,null),this.textDOM=c,this.text=d}get size(){return this.text.length}localPosFromDOM(a,b){return a!=this.textDOM?this.posAtStart+(b?this.size:0):this.posAtStart+b}domFromPos(a){return{node:this.textDOM,offset:a}}ignoreMutation(a){return"characterData"===a.type&&a.target.nodeValue==a.oldValue}}class cX extends cU{constructor(a,b,c,d,e){super(a,[],c,d),this.mark=b,this.spec=e}static create(a,b,c,d){let e=d.nodeViews[b.type.name],f=e&&e(b,d,c);return f&&f.dom||(f=aJ.renderSpec(document,b.type.spec.toDOM(b,c),null,b.attrs)),new cX(a,b,f.dom,f.contentDOM||f.dom,f)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(a){return 3!=this.dirty&&this.mark.eq(a)}markDirty(a,b){if(super.markDirty(a,b),0!=this.dirty){let a=this.parent;for(;!a.node;)a=a.parent;a.dirty<this.dirty&&(a.dirty=this.dirty),this.dirty=0}}slice(a,b,c){let d=cX.create(this.parent,this.mark,!0,c),e=this.children,f=this.size;b<f&&(e=da(e,b,f,c)),a>0&&(e=da(e,0,a,c));for(let a=0;a<e.length;a++)e[a].parent=d;return d.children=e,d}ignoreMutation(a){return this.spec.ignoreMutation?this.spec.ignoreMutation(a):super.ignoreMutation(a)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class cY extends cU{constructor(a,b,c,d,e,f,g,h,i){super(a,[],e,f),this.node=b,this.outerDeco=c,this.innerDeco=d,this.nodeDOM=g}static create(a,b,c,d,e,f){let g=e.nodeViews[b.type.name],h,i=g&&g(b,e,()=>h?h.parent?h.parent.posBeforeChild(h):void 0:f,c,d),j=i&&i.dom,k=i&&i.contentDOM;if(b.isText)if(j){if(3!=j.nodeType)throw RangeError("Text must be rendered as a DOM text node")}else j=document.createTextNode(b.text);else if(!j){let a=aJ.renderSpec(document,b.type.spec.toDOM(b),null,b.attrs);({dom:j,contentDOM:k}=a)}k||b.isText||"BR"==j.nodeName||(j.hasAttribute("contenteditable")||(j.contentEditable="false"),b.type.spec.draggable&&(j.draggable=!0));let l=j;return(j=c5(j,c,b),i)?h=new c0(a,b,c,d,j,k||null,l,i,e,f+1):b.isText?new c$(a,b,c,d,j,l,e):new cY(a,b,c,d,j,k||null,l,e,f+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let a={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(a.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let b=this.children.length-1;b>=0;b--){let c=this.children[b];if(this.dom.contains(c.dom.parentNode)){a.contentElement=c.dom.parentNode;break}}a.contentElement||(a.getContent=()=>S.empty)}else a.contentElement=this.contentDOM;else a.getContent=()=>this.node.content;return a}matchesNode(a,b,c){return 0==this.dirty&&a.eq(this.node)&&c6(b,this.outerDeco)&&c.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(a,b){let c=this.node.inlineContent,d=b,e=a.composing?this.localCompositionInfo(a,b):null,f=e&&e.pos>-1?e:null,g=e&&e.pos<0,h=new c8(this,f&&f.node,a);(function(a,b,c,d){let e=b.locals(a),f=0;if(0==e.length){for(let c=0;c<a.childCount;c++){let g=a.child(c);d(g,e,b.forChild(f,g),c),f+=g.nodeSize}return}let g=0,h=[],i=null;for(let j=0;;){let k,l,m,n;for(;g<e.length&&e[g].to==f;){let a=e[g++];a.widget&&(k?(l||(l=[k])).push(a):k=a)}if(k)if(l){l.sort(c9);for(let a=0;a<l.length;a++)c(l[a],j,!!i)}else c(k,j,!!i);if(i)n=-1,m=i,i=null;else if(j<a.childCount)n=j,m=a.child(j++);else break;for(let a=0;a<h.length;a++)h[a].to<=f&&h.splice(a--,1);for(;g<e.length&&e[g].from<=f&&e[g].to>f;)h.push(e[g++]);let o=f+m.nodeSize;if(m.isText){let a=o;g<e.length&&e[g].from<a&&(a=e[g].from);for(let b=0;b<h.length;b++)h[b].to<a&&(a=h[b].to);a<o&&(i=m.cut(a-f),m=m.cut(0,a-f),o=a,n=-1)}else for(;g<e.length&&e[g].to<o;)g++;let p=m.isInline&&!m.isLeaf?h.filter(a=>!a.inline):h.slice();d(m,p,b.forChild(f,m),n),f=o}})(this.node,this.innerDeco,(b,e,f)=>{b.spec.marks?h.syncToMarks(b.spec.marks,c,a,e):b.type.side>=0&&!f&&h.syncToMarks(e==this.node.childCount?W.none:this.node.child(e).marks,c,a,e),h.placeWidget(b,a,d)},(b,f,i,j)=>{let k;h.syncToMarks(b.marks,c,a,j),h.findNodeMatch(b,f,i,j)||g&&a.state.selection.from>d&&a.state.selection.to<d+b.nodeSize&&(k=h.findIndexWithChild(e.node))>-1&&h.updateNodeAt(b,f,i,k,a)||h.updateNextNode(b,f,i,a,j,d)||h.addNode(b,f,i,a,d),d+=b.nodeSize}),h.syncToMarks([],c,a,0),this.node.isTextblock&&h.addTextblockHacks(),h.destroyRest(),(h.changed||2==this.dirty)&&(f&&this.protectLocalComposition(a,f),function a(b,c,d){let e=b.firstChild,f=!1;for(let g=0;g<c.length;g++){let h=c[g],i=h.dom;if(i.parentNode==b){for(;i!=e;)e=c7(e),f=!0;e=e.nextSibling}else f=!0,b.insertBefore(i,e);if(h instanceof cX){let c=e?e.previousSibling:b.lastChild;a(h.contentDOM,h.children,d),e=c?c.nextSibling:b.firstChild}}for(;e;)e=c7(e),f=!0;f&&d.trackWrites==b&&(d.trackWrites=null)}(this.contentDOM,this.children,a),cx&&function(a){if("UL"==a.nodeName||"OL"==a.nodeName){let b=a.style.cssText;a.style.cssText=b+"; list-style: square !important",window.getComputedStyle(a).listStyle,a.style.cssText=b}}(this.dom))}localCompositionInfo(a,b){let{from:c,to:d}=a.state.selection;if(!(a.state.selection instanceof bs)||c<b||d>b+this.node.content.size)return null;let e=a.input.compositionNode;if(!e||!this.dom.contains(e.parentNode))return null;if(!this.node.inlineContent)return{node:e,pos:-1,text:""};{let a=e.nodeValue,f=function(a,b,c,d){for(let e=0,f=0;e<a.childCount&&f<=d;){let g=a.child(e++),h=f;if(f+=g.nodeSize,!g.isText)continue;let i=g.text;for(;e<a.childCount;){let b=a.child(e++);if(f+=b.nodeSize,!b.isText)break;i+=b.text}if(f>=c){if(f>=d&&i.slice(d-b.length-h,d-h)==b)return d-b.length;let a=h<d?i.lastIndexOf(b,d-h-1):-1;if(a>=0&&a+b.length+h>=c)return h+a;if(c==d&&i.length>=d+b.length-h&&i.slice(d-h,d-h+b.length)==b)return d}}return -1}(this.node.content,a,c-b,d-b);return f<0?null:{node:e,pos:f,text:a}}}protectLocalComposition(a,{node:b,pos:c,text:d}){if(this.getDesc(b))return;let e=b;for(;e.parentNode!=this.contentDOM;e=e.parentNode){for(;e.previousSibling;)e.parentNode.removeChild(e.previousSibling);for(;e.nextSibling;)e.parentNode.removeChild(e.nextSibling);e.pmViewDesc&&(e.pmViewDesc=void 0)}let f=new cW(this,e,b,d);a.input.compositionNodes.push(f),this.children=da(this.children,c,c+d.length,a,f)}update(a,b,c,d){return 3!=this.dirty&&!!a.sameMarkup(this.node)&&(this.updateInner(a,b,c,d),!0)}updateInner(a,b,c,d){this.updateOuterDeco(b),this.node=a,this.innerDeco=c,this.contentDOM&&this.updateChildren(d,this.posAtStart),this.dirty=0}updateOuterDeco(a){if(c6(a,this.outerDeco))return;let b=1!=this.nodeDOM.nodeType,c=this.dom;this.dom=c4(this.dom,this.nodeDOM,c3(this.outerDeco,this.node,b),c3(a,this.node,b)),this.dom!=c&&(c.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=a}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function cZ(a,b,c,d,e){c5(d,b,a);let f=new cY(void 0,a,b,c,d,d,d,e,0);return f.contentDOM&&f.updateChildren(e,0),f}class c$ extends cY{constructor(a,b,c,d,e,f,g){super(a,b,c,d,e,null,f,g,0)}parseRule(){let a=this.nodeDOM.parentNode;for(;a&&a!=this.dom&&!a.pmIsDeco;)a=a.parentNode;return{skip:a||!0}}update(a,b,c,d){return 3!=this.dirty&&(0==this.dirty||!!this.inParent())&&!!a.sameMarkup(this.node)&&(this.updateOuterDeco(b),(0!=this.dirty||a.text!=this.node.text)&&a.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=a.text,d.trackWrites==this.nodeDOM&&(d.trackWrites=null)),this.node=a,this.dirty=0,!0)}inParent(){let a=this.parent.contentDOM;for(let b=this.nodeDOM;b;b=b.parentNode)if(b==a)return!0;return!1}domFromPos(a){return{node:this.nodeDOM,offset:a}}localPosFromDOM(a,b,c){return a==this.nodeDOM?this.posAtStart+Math.min(b,this.node.text.length):super.localPosFromDOM(a,b,c)}ignoreMutation(a){return"characterData"!=a.type&&"selection"!=a.type}slice(a,b,c){let d=this.node.cut(a,b),e=document.createTextNode(d.text);return new c$(this.parent,d,this.outerDeco,this.innerDeco,e,e,c)}markDirty(a,b){super.markDirty(a,b),this.dom!=this.nodeDOM&&(0==a||b==this.nodeDOM.nodeValue.length)&&(this.dirty=3)}get domAtom(){return!1}isText(a){return this.node.text==a}}class c_ extends cU{parseRule(){return{ignore:!0}}matchesHack(a){return 0==this.dirty&&this.dom.nodeName==a}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class c0 extends cY{constructor(a,b,c,d,e,f,g,h,i,j){super(a,b,c,d,e,f,g,i,j),this.spec=h}update(a,b,c,d){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==a.type||this.spec.multiType)){let e=this.spec.update(a,b,c);return e&&this.updateInner(a,b,c,d),e}return(!!this.contentDOM||!!a.isLeaf)&&super.update(a,b,c,d)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(a,b,c,d){this.spec.setSelection?this.spec.setSelection(a,b,c.root):super.setSelection(a,b,c,d)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(a){return!!this.spec.stopEvent&&this.spec.stopEvent(a)}ignoreMutation(a){return this.spec.ignoreMutation?this.spec.ignoreMutation(a):super.ignoreMutation(a)}}let c1=function(a){a&&(this.nodeName=a)};c1.prototype=Object.create(null);let c2=[new c1];function c3(a,b,c){if(0==a.length)return c2;let d=c?c2[0]:new c1,e=[d];for(let f=0;f<a.length;f++){let g=a[f].type.attrs;if(g)for(let a in g.nodeName&&e.push(d=new c1(g.nodeName)),g){let f=g[a];null!=f&&(c&&1==e.length&&e.push(d=new c1(b.isInline?"span":"div")),"class"==a?d.class=(d.class?d.class+" ":"")+f:"style"==a?d.style=(d.style?d.style+";":"")+f:"nodeName"!=a&&(d[a]=f))}}return e}function c4(a,b,c,d){if(c==c2&&d==c2)return b;let e=b;for(let b=0;b<d.length;b++){let f=d[b],g=c[b];if(b){let b;g&&g.nodeName==f.nodeName&&e!=a&&(b=e.parentNode)&&b.nodeName.toLowerCase()==f.nodeName||((b=document.createElement(f.nodeName)).pmIsDeco=!0,b.appendChild(e),g=c2[0]),e=b}!function(a,b,c){for(let d in b)"class"==d||"style"==d||"nodeName"==d||d in c||a.removeAttribute(d);for(let d in c)"class"!=d&&"style"!=d&&"nodeName"!=d&&c[d]!=b[d]&&a.setAttribute(d,c[d]);if(b.class!=c.class){let d=b.class?b.class.split(" ").filter(Boolean):[],e=c.class?c.class.split(" ").filter(Boolean):[];for(let b=0;b<d.length;b++)-1==e.indexOf(d[b])&&a.classList.remove(d[b]);for(let b=0;b<e.length;b++)-1==d.indexOf(e[b])&&a.classList.add(e[b]);0==a.classList.length&&a.removeAttribute("class")}if(b.style!=c.style){if(b.style){let c=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,d;for(;d=c.exec(b.style);)a.style.removeProperty(d[1])}c.style&&(a.style.cssText+=c.style)}}(e,g||c2[0],f)}return e}function c5(a,b,c){return c4(a,a,c2,c3(b,c,1!=a.nodeType))}function c6(a,b){if(a.length!=b.length)return!1;for(let c=0;c<a.length;c++)if(!a[c].type.eq(b[c].type))return!1;return!0}function c7(a){let b=a.nextSibling;return a.parentNode.removeChild(a),b}class c8{constructor(a,b,c){this.lock=b,this.view=c,this.index=0,this.stack=[],this.changed=!1,this.top=a,this.preMatch=function(a,b){let c=b,d=c.children.length,e=a.childCount,f=new Map,g=[];c:for(;e>0;){let h;for(;;)if(d){let a=c.children[d-1];if(a instanceof cX)c=a,d=a.children.length;else{h=a,d--;break}}else if(c==b)break c;else d=c.parent.children.indexOf(c),c=c.parent;let i=h.node;if(i){if(i!=a.child(e-1))break;--e,f.set(h,e),g.push(h)}}return{index:e,matched:f,matches:g.reverse()}}(a.node.content,a)}destroyBetween(a,b){if(a!=b){for(let c=a;c<b;c++)this.top.children[c].destroy();this.top.children.splice(a,b-a),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(a,b,c,d){let e=0,f=this.stack.length>>1,g=Math.min(f,a.length);for(;e<g&&(e==f-1?this.top:this.stack[e+1<<1]).matchesMark(a[e])&&!1!==a[e].type.spec.spanning;)e++;for(;e<f;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),f--;for(;f<a.length;){this.stack.push(this.top,this.index+1);let e=-1,g=this.top.children.length;d<this.preMatch.index&&(g=Math.min(this.index+3,g));for(let b=this.index;b<g;b++){let c=this.top.children[b];if(c.matchesMark(a[f])&&!this.isLocked(c.dom)){e=b;break}}if(e>-1)e>this.index&&(this.changed=!0,this.destroyBetween(this.index,e)),this.top=this.top.children[this.index];else{let d=cX.create(this.top,a[f],b,c);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,f++}}findNodeMatch(a,b,c,d){let e=-1,f;if(d>=this.preMatch.index&&(f=this.preMatch.matches[d-this.preMatch.index]).parent==this.top&&f.matchesNode(a,b,c))e=this.top.children.indexOf(f,this.index);else for(let d=this.index,f=Math.min(this.top.children.length,d+5);d<f;d++){let f=this.top.children[d];if(f.matchesNode(a,b,c)&&!this.preMatch.matched.has(f)){e=d;break}}return!(e<0)&&(this.destroyBetween(this.index,e),this.index++,!0)}updateNodeAt(a,b,c,d,e){let f=this.top.children[d];return 3==f.dirty&&f.dom==f.contentDOM&&(f.dirty=2),!!f.update(a,b,c,e)&&(this.destroyBetween(this.index,d),this.index++,!0)}findIndexWithChild(a){for(;;){let b=a.parentNode;if(!b)return -1;if(b==this.top.contentDOM){let b=a.pmViewDesc;if(b){for(let a=this.index;a<this.top.children.length;a++)if(this.top.children[a]==b)return a}return -1}a=b}}updateNextNode(a,b,c,d,e,f){for(let g=this.index;g<this.top.children.length;g++){let h=this.top.children[g];if(h instanceof cY){let i=this.preMatch.matched.get(h);if(null!=i&&i!=e)return!1;let j=h.dom,k,l=this.isLocked(j)&&!(a.isText&&h.node&&h.node.isText&&h.nodeDOM.nodeValue==a.text&&3!=h.dirty&&c6(b,h.outerDeco));if(!l&&h.update(a,b,c,d))return this.destroyBetween(this.index,g),h.dom!=j&&(this.changed=!0),this.index++,!0;if(!l&&(k=this.recreateWrapper(h,a,b,c,d,f)))return this.destroyBetween(this.index,g),this.top.children[this.index]=k,k.contentDOM&&(k.dirty=2,k.updateChildren(d,f+1),k.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(a,b,c,d,e,f){if(a.dirty||b.isAtom||!a.children.length||!a.node.content.eq(b.content)||!c6(c,a.outerDeco)||!d.eq(a.innerDeco))return null;let g=cY.create(this.top,b,c,d,e,f);if(g.contentDOM)for(let b of(g.children=a.children,a.children=[],g.children))b.parent=g;return a.destroy(),g}addNode(a,b,c,d,e){let f=cY.create(this.top,a,b,c,d,e);f.contentDOM&&f.updateChildren(d,e+1),this.top.children.splice(this.index++,0,f),this.changed=!0}placeWidget(a,b,c){let d=this.index<this.top.children.length?this.top.children[this.index]:null;if(d&&d.matchesWidget(a)&&(a==d.widget||!d.widget.type.toDOM.parentNode))this.index++;else{let d=new cV(this.top,a,b,c);this.top.children.splice(this.index++,0,d),this.changed=!0}}addTextblockHacks(){let a=this.top.children[this.index-1],b=this.top;for(;a instanceof cX;)a=(b=a).children[b.children.length-1];(!a||!(a instanceof c$)||/\n$/.test(a.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(a.node.text))&&((cw||cu)&&a&&"false"==a.dom.contentEditable&&this.addHackNode("IMG",b),this.addHackNode("BR",this.top))}addHackNode(a,b){if(b==this.top&&this.index<b.children.length&&b.children[this.index].matchesHack(a))this.index++;else{let c=document.createElement(a);"IMG"==a&&(c.className="ProseMirror-separator",c.alt=""),"BR"==a&&(c.className="ProseMirror-trailingBreak");let d=new c_(this.top,[],c,null);b!=this.top?b.children.push(d):b.children.splice(this.index++,0,d),this.changed=!0}}isLocked(a){return this.lock&&(a==this.lock||1==a.nodeType&&a.contains(this.lock.parentNode))}}function c9(a,b){return a.type.side-b.type.side}function da(a,b,c,d,e){let f=[];for(let g=0,h=0;g<a.length;g++){let i=a[g],j=h,k=h+=i.size;j>=c||k<=b?f.push(i):(j<b&&f.push(i.slice(0,b-j,d)),e&&(f.push(e),e=void 0),k>c&&f.push(i.slice(c-j,i.size,d)))}return f}function db(a,b=null){let c=a.domSelectionRange(),d=a.state.doc;if(!c.focusNode)return null;let e=a.docView.nearestDesc(c.focusNode),f=e&&0==e.size,g=a.docView.posFromDOM(c.focusNode,c.focusOffset,1);if(g<0)return null;let h=d.resolve(g),i,j;if(ci(c)){for(i=g;e&&!e.node;)e=e.parent;let a=e.node;if(e&&a.isAtom&&bu.isSelectable(a)&&e.parent&&!(a.isInline&&function(a,b,c){for(let d=0==b,e=b==cg(a);d||e;){if(a==c)return!0;let b=b8(a);if(!(a=a.parentNode))return!1;d=d&&0==b,e=e&&b==cg(a)}}(c.focusNode,c.focusOffset,e.dom))){let a=e.posBefore;j=new bu(g==a?h:d.resolve(a))}}else{if(c instanceof a.dom.ownerDocument.defaultView.Selection&&c.rangeCount>1){let b=g,e=g;for(let d=0;d<c.rangeCount;d++){let f=c.getRangeAt(d);b=Math.min(b,a.docView.posFromDOM(f.startContainer,f.startOffset,1)),e=Math.max(e,a.docView.posFromDOM(f.endContainer,f.endOffset,-1))}if(b<0)return null;[i,g]=e==a.state.selection.anchor?[e,b]:[b,e],h=d.resolve(g)}else i=a.docView.posFromDOM(c.anchorNode,c.anchorOffset,1);if(i<0)return null}let k=d.resolve(i);if(!j){let c="pointer"==b||a.state.selection.head<h.pos&&!f?1:-1;j=dk(a,k,h,c)}return j}function dc(a){return a.editable?a.hasFocus():dm(a)&&document.activeElement&&document.activeElement.contains(a.dom)}function dd(a,b=!1){let c=a.state.selection;if(di(a,c),dc(a)){if(!b&&a.input.mouseDown&&a.input.mouseDown.allowDefault&&cu){let b=a.domSelectionRange(),c=a.domObserver.currentSelection;if(b.anchorNode&&c.anchorNode&&cd(b.anchorNode,b.anchorOffset,c.anchorNode,c.anchorOffset)){a.input.mouseDown.delayedSelectionSync=!0,a.domObserver.setCurSelection();return}}if(a.domObserver.disconnectSelection(),a.cursorWrapper)!function(a){let b=a.domSelection();if(!b)return;let c=a.cursorWrapper.dom,d="IMG"==c.nodeName;d?b.collapse(c.parentNode,b8(c)+1):b.collapse(c,0),!d&&!a.state.selection.visible&&cq&&cr<=11&&(c.disabled=!0,c.disabled=!1)}(a);else{var d;let e,f,g,h,{anchor:i,head:j}=c,k,l;de&&!(c instanceof bs)&&(c.$from.parent.inlineContent||(k=df(a,c.from)),c.empty||c.$from.parent.inlineContent||(l=df(a,c.to))),a.docView.setSelection(i,j,a,b),de&&(k&&dh(k),l&&dh(l)),c.visible?a.dom.classList.remove("ProseMirror-hideselection"):(a.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&((e=(d=a).dom.ownerDocument).removeEventListener("selectionchange",d.input.hideSelectionGuard),g=(f=d.domSelectionRange()).anchorNode,h=f.anchorOffset,e.addEventListener("selectionchange",d.input.hideSelectionGuard=()=>{(f.anchorNode!=g||f.anchorOffset!=h)&&(e.removeEventListener("selectionchange",d.input.hideSelectionGuard),setTimeout(()=>{(!dc(d)||d.state.selection.visible)&&d.dom.classList.remove("ProseMirror-hideselection")},20))})))}a.domObserver.setCurSelection(),a.domObserver.connectSelection()}}let de=cw||cu&&cv<63;function df(a,b){let{node:c,offset:d}=a.docView.domFromPos(b,0),e=d<c.childNodes.length?c.childNodes[d]:null,f=d?c.childNodes[d-1]:null;if(cw&&e&&"false"==e.contentEditable)return dg(e);if((!e||"false"==e.contentEditable)&&(!f||"false"==f.contentEditable)){if(e)return dg(e);else if(f)return dg(f)}}function dg(a){return a.contentEditable="true",cw&&a.draggable&&(a.draggable=!1,a.wasDraggable=!0),a}function dh(a){a.contentEditable="false",a.wasDraggable&&(a.draggable=!0,a.wasDraggable=null)}function di(a,b){if(b instanceof bu){let c=a.docView.descAt(b.from);c!=a.lastSelectedViewDesc&&(dj(a),c&&c.selectNode(),a.lastSelectedViewDesc=c)}else dj(a)}function dj(a){a.lastSelectedViewDesc&&(a.lastSelectedViewDesc.parent&&a.lastSelectedViewDesc.deselectNode(),a.lastSelectedViewDesc=void 0)}function dk(a,b,c,d){return a.someProp("createSelectionBetween",d=>d(a,b,c))||bs.between(b,c,d)}function dl(a){return(!a.editable||!!a.hasFocus())&&dm(a)}function dm(a){let b=a.domSelectionRange();if(!b.anchorNode)return!1;try{return a.dom.contains(3==b.anchorNode.nodeType?b.anchorNode.parentNode:b.anchorNode)&&(a.editable||a.dom.contains(3==b.focusNode.nodeType?b.focusNode.parentNode:b.focusNode))}catch(a){return!1}}function dn(a,b){let{$anchor:c,$head:d}=a.selection,e=b>0?c.max(d):c.min(d),f=e.parent.inlineContent?e.depth?a.doc.resolve(b>0?e.after():e.before()):null:e;return f&&bo.findFrom(f,b)}function dp(a,b){return a.dispatch(a.state.tr.setSelection(b).scrollIntoView()),!0}function dq(a,b,c){let d=a.state.selection;if(d instanceof bs){if(c.indexOf("s")>-1){let{$head:c}=d,e=c.textOffset?null:b<0?c.nodeBefore:c.nodeAfter;if(!e||e.isText||!e.isLeaf)return!1;let f=a.state.doc.resolve(c.pos+e.nodeSize*(b<0?-1:1));return dp(a,new bs(d.$anchor,f))}else if(!d.empty)return!1;else if(a.endOfTextblock(b>0?"forward":"backward")){let c=dn(a.state,b);return!!c&&c instanceof bu&&dp(a,c)}else if(!(cy&&c.indexOf("m")>-1)){let c=d.$head,e=c.textOffset?null:b<0?c.nodeBefore:c.nodeAfter,f;if(!e||e.isText)return!1;let g=b<0?c.pos-e.nodeSize:c.pos;return!!(e.isAtom||(f=a.docView.descAt(g))&&!f.contentDOM)&&(bu.isSelectable(e)?dp(a,new bu(b<0?a.state.doc.resolve(c.pos-e.nodeSize):c)):!!cB&&dp(a,new bs(a.state.doc.resolve(b<0?g:g+e.nodeSize))))}}else{if(d instanceof bu&&d.node.isInline)return dp(a,new bs(b>0?d.$to:d.$from));let c=dn(a.state,b);return!!c&&dp(a,c)}}function dr(a){return 3==a.nodeType?a.nodeValue.length:a.childNodes.length}function ds(a,b){let c=a.pmViewDesc;return c&&0==c.size&&(b<0||a.nextSibling||"BR"!=a.nodeName)}function dt(a,b){return b<0?function(a){let b=a.domSelectionRange(),c=b.focusNode,d=b.focusOffset;if(!c)return;let e,f,g=!1;for(cs&&1==c.nodeType&&d<dr(c)&&ds(c.childNodes[d],-1)&&(g=!0);;)if(d>0)if(1!=c.nodeType)break;else{let a=c.childNodes[d-1];if(ds(a,-1))e=c,f=--d;else if(3==a.nodeType)d=(c=a).nodeValue.length;else break}else if(du(c))break;else{let b=c.previousSibling;for(;b&&ds(b,-1);)e=c.parentNode,f=b8(b),b=b.previousSibling;if(b)d=dr(c=b);else{if((c=c.parentNode)==a.dom)break;d=0}}g?dv(a,c,d):e&&dv(a,e,f)}(a):function(a){let b,c,d=a.domSelectionRange(),e=d.focusNode,f=d.focusOffset;if(!e)return;let g=dr(e);for(;;)if(f<g){if(1!=e.nodeType)break;if(ds(e.childNodes[f],1))b=e,c=++f;else break}else if(du(e))break;else{let d=e.nextSibling;for(;d&&ds(d,1);)b=d.parentNode,c=b8(d)+1,d=d.nextSibling;if(d)f=0,g=dr(e=d);else{if((e=e.parentNode)==a.dom)break;f=g=0}}b&&dv(a,b,c)}(a)}function du(a){let b=a.pmViewDesc;return b&&b.node&&b.node.isBlock}function dv(a,b,c){if(3!=b.nodeType){let a,d;(d=function(a,b){for(;a&&b==a.childNodes.length&&!ch(a);)b=b8(a)+1,a=a.parentNode;for(;a&&b<a.childNodes.length;){let c=a.childNodes[b];if(3==c.nodeType)return c;if(1==c.nodeType&&"false"==c.contentEditable)break;a=c,b=0}}(b,c))?(b=d,c=0):(a=function(a,b){for(;a&&!b&&!ch(a);)b=b8(a),a=a.parentNode;for(;a&&b;){let c=a.childNodes[b-1];if(3==c.nodeType)return c;if(1==c.nodeType&&"false"==c.contentEditable)break;b=(a=c).childNodes.length}}(b,c))&&(b=a,c=a.nodeValue.length)}let d=a.domSelection();if(!d)return;if(ci(d)){let a=document.createRange();a.setEnd(b,c),a.setStart(b,c),d.removeAllRanges(),d.addRange(a)}else d.extend&&d.extend(b,c);a.domObserver.setCurSelection();let{state:e}=a;setTimeout(()=>{a.state==e&&dd(a)},50)}function dw(a,b){let c=a.state.doc.resolve(b);if(!(cu||cz)&&c.parent.inlineContent){let d=a.coordsAtPos(b);if(b>c.start()){let c=a.coordsAtPos(b-1),e=(c.top+c.bottom)/2;if(e>d.top&&e<d.bottom&&Math.abs(c.left-d.left)>1)return c.left<d.left?"ltr":"rtl"}if(b<c.end()){let c=a.coordsAtPos(b+1),e=(c.top+c.bottom)/2;if(e>d.top&&e<d.bottom&&Math.abs(c.left-d.left)>1)return c.left>d.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(a.dom).direction?"rtl":"ltr"}function dx(a,b,c){let d=a.state.selection;if(d instanceof bs&&!d.empty||c.indexOf("s")>-1||cy&&c.indexOf("m")>-1)return!1;let{$from:e,$to:f}=d;if(!e.parent.inlineContent||a.endOfTextblock(b<0?"up":"down")){let c=dn(a.state,b);if(c&&c instanceof bu)return dp(a,c)}if(!e.parent.inlineContent){let c=b<0?e:f,g=d instanceof bw?bo.near(c,b):bo.findFrom(c,b);return!!g&&dp(a,g)}return!1}function dy(a,b){if(!(a.state.selection instanceof bs))return!0;let{$head:c,$anchor:d,empty:e}=a.state.selection;if(!c.sameParent(d))return!0;if(!e)return!1;if(a.endOfTextblock(b>0?"forward":"backward"))return!0;let f=!c.textOffset&&(b<0?c.nodeBefore:c.nodeAfter);if(f&&!f.isText){let d=a.state.tr;return b<0?d.delete(c.pos-f.nodeSize,c.pos):d.delete(c.pos,c.pos+f.nodeSize),a.dispatch(d),!0}return!1}function dz(a,b,c){a.domObserver.stop(),b.contentEditable=c,a.domObserver.start()}function dA(a,b){a.someProp("transformCopied",c=>{b=c(b,a)});let c=[],{content:d,openStart:e,openEnd:f}=b;for(;e>1&&f>1&&1==d.childCount&&1==d.firstChild.childCount;){e--,f--;let a=d.firstChild;c.push(a.type.name,a.attrs!=a.type.defaultAttrs?a.attrs:null),d=a.content}let g=a.someProp("clipboardSerializer")||aJ.fromSchema(a.state.schema),h=dI(),i=h.createElement("div");i.appendChild(g.serializeFragment(d,{document:h}));let j=i.firstChild,k,l=0;for(;j&&1==j.nodeType&&(k=dG[j.nodeName.toLowerCase()]);){for(let a=k.length-1;a>=0;a--){let b=h.createElement(k[a]);for(;i.firstChild;)b.appendChild(i.firstChild);i.appendChild(b),l++}j=i.firstChild}return j&&1==j.nodeType&&j.setAttribute("data-pm-slice",`${e} ${f}${l?` -${l}`:""} ${JSON.stringify(c)}`),{dom:i,text:a.someProp("clipboardTextSerializer",c=>c(b,a))||b.content.textBetween(0,b.content.size,"\n\n"),slice:b}}function dB(a,b,c,d,e){let f,g,h=e.parent.type.spec.code;if(!c&&!b)return null;let i=!!b&&(d||h||!c);if(i){if(a.someProp("transformPastedText",c=>{b=c(b,h||d,a)}),h)return g=new Y(S.from(a.state.schema.text(b.replace(/\r\n?/g,"\n"))),0,0),a.someProp("transformPasted",b=>{g=b(g,a,!0)}),g;let c=a.someProp("clipboardTextParser",c=>c(b,e,d,a));if(c)g=c;else{let c=e.marks(),{schema:d}=a.state,g=aJ.fromSchema(d);f=document.createElement("div"),b.split(/(?:\r\n?|\n)+/).forEach(a=>{let b=f.appendChild(document.createElement("p"));a&&b.appendChild(g.serializeNode(d.text(a,c)))})}}else a.someProp("transformPastedHTML",b=>{c=b(c,a)}),f=function(a){var b;let c,d=/^(\s*<meta [^>]*>)*/.exec(a);d&&(a=a.slice(d[0].length));let e=dI().createElement("div"),f=/<([a-z][^>\s]+)/i.exec(a),g;if((g=f&&dG[f[1].toLowerCase()])&&(a=g.map(a=>"<"+a+">").join("")+a+g.map(a=>"</"+a+">").reverse().join("")),e.innerHTML=(b=a,(c=window.trustedTypes)?(dJ||(dJ=c.defaultPolicy||c.createPolicy("ProseMirrorClipboard",{createHTML:a=>a})),dJ.createHTML(b)):b),g)for(let a=0;a<g.length;a++)e=e.querySelector(g[a])||e;return e}(c),cB&&function(a){let b=a.querySelectorAll(cu?"span:not([class]):not([style])":"span.Apple-converted-space");for(let c=0;c<b.length;c++){let d=b[c];1==d.childNodes.length&&"\xa0"==d.textContent&&d.parentNode&&d.parentNode.replaceChild(a.ownerDocument.createTextNode(" "),d)}}(f);let j=f&&f.querySelector("[data-pm-slice]"),k=j&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(j.getAttribute("data-pm-slice")||"");if(k&&k[3])for(let a=+k[3];a>0;a--){let a=f.firstChild;for(;a&&1!=a.nodeType;)a=a.nextSibling;if(!a)break;f=a}if(g||(g=(a.someProp("clipboardParser")||a.someProp("domParser")||aA.fromSchema(a.state.schema)).parseSlice(f,{preserveWhitespace:!!(i||k),context:e,ruleFromNode:a=>"BR"!=a.nodeName||a.nextSibling||!a.parentNode||dC.test(a.parentNode.nodeName)?null:{ignore:!0}})),k)g=function(a,b){if(!a.size)return a;let c=a.content.firstChild.type.schema,d;try{d=JSON.parse(b)}catch(b){return a}let{content:e,openStart:f,openEnd:g}=a;for(let a=d.length-2;a>=0;a-=2){let b=c.nodes[d[a]];if(!b||b.hasRequiredAttrs())break;e=S.from(b.create(d[a+1],e)),f++,g++}return new Y(e,f,g)}(dF(g,+k[1],+k[2]),k[4]);else if((g=Y.maxOpen(function(a,b){if(a.childCount<2)return a;for(let c=b.depth;c>=0;c--){let d=b.node(c).contentMatchAt(b.index(c)),e,f=[];if(a.forEach(a=>{if(!f)return;let b=d.findWrapping(a.type),c;if(!b)return f=null;if(c=f.length&&e.length&&function a(b,c,d,e,f){if(f<b.length&&f<c.length&&b[f]==c[f]){let g=a(b,c,d,e.lastChild,f+1);if(g)return e.copy(e.content.replaceChild(e.childCount-1,g));if(e.contentMatchAt(e.childCount).matchType(f==b.length-1?d.type:b[f+1]))return e.copy(e.content.append(S.from(dD(d,b,f+1))))}}(b,e,a,f[f.length-1],0))f[f.length-1]=c;else{f.length&&(f[f.length-1]=function a(b,c){if(0==c)return b;let d=b.content.replaceChild(b.childCount-1,a(b.lastChild,c-1)),e=b.contentMatchAt(b.childCount).fillBefore(S.empty,!0);return b.copy(d.append(e))}(f[f.length-1],e.length));let c=dD(a,b);f.push(c),d=d.matchType(c.type),e=b}}),f)return S.from(f)}return a}(g.content,e),!0)).openStart||g.openEnd){let a=0,b=0;for(let b=g.content.firstChild;a<g.openStart&&!b.type.spec.isolating;a++,b=b.firstChild);for(let a=g.content.lastChild;b<g.openEnd&&!a.type.spec.isolating;b++,a=a.lastChild);g=dF(g,a,b)}return a.someProp("transformPasted",b=>{g=b(g,a,i)}),g}let dC=/^(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 dD(a,b,c=0){for(let d=b.length-1;d>=c;d--)a=b[d].create(null,S.from(a));return a}function dE(a,b,c,d,e,f){let g=b<0?a.firstChild:a.lastChild,h=g.content;return a.childCount>1&&(f=0),e<d-1&&(h=dE(h,b,c,d,e+1,f)),e>=c&&(h=b<0?g.contentMatchAt(0).fillBefore(h,f<=e).append(h):h.append(g.contentMatchAt(g.childCount).fillBefore(S.empty,!0))),a.replaceChild(b<0?0:a.childCount-1,g.copy(h))}function dF(a,b,c){return b<a.openStart&&(a=new Y(dE(a.content,-1,b,a.openStart,0,a.openEnd),b,a.openEnd)),c<a.openEnd&&(a=new Y(dE(a.content,1,c,a.openEnd,0,0),a.openStart,c)),a}let dG={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},dH=null;function dI(){return dH||(dH=document.implementation.createHTMLDocument("title"))}let dJ=null,dK={},dL={},dM={touchstart:!0,touchmove:!0};class dN{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 dO(a,b){a.input.lastSelectionOrigin=b,a.input.lastSelectionTime=Date.now()}function dP(a){a.someProp("handleDOMEvents",b=>{for(let c in b)a.input.eventHandlers[c]||a.dom.addEventListener(c,a.input.eventHandlers[c]=b=>dQ(a,b))})}function dQ(a,b){return a.someProp("handleDOMEvents",c=>{let d=c[b.type];return!!d&&(d(a,b)||b.defaultPrevented)})}function dR(a){return{left:a.clientX,top:a.clientY}}function dS(a,b,c,d,e){if(-1==d)return!1;let f=a.state.doc.resolve(d);for(let d=f.depth+1;d>0;d--)if(a.someProp(b,b=>d>f.depth?b(a,c,f.nodeAfter,f.before(d),e,!0):b(a,c,f.node(d),f.before(d),e,!1)))return!0;return!1}function dT(a,b,c){if(a.focused||a.focus(),a.state.selection.eq(b))return;let d=a.state.tr.setSelection(b);"pointer"==c&&d.setMeta("pointer",!0),a.dispatch(d)}dL.keydown=(a,b)=>{if((a.input.shiftKey=16==b.keyCode||b.shiftKey,!dW(a,b))&&(a.input.lastKeyCode=b.keyCode,a.input.lastKeyCodeTime=Date.now(),!cA||!cu||13!=b.keyCode))if(229!=b.keyCode&&a.domObserver.forceFlush(),!cx||13!=b.keyCode||b.ctrlKey||b.altKey||b.metaKey)a.someProp("handleKeyDown",c=>c(a,b))||function(a,b){let c,d=b.keyCode,e=(c="",b.ctrlKey&&(c+="c"),b.metaKey&&(c+="m"),b.altKey&&(c+="a"),b.shiftKey&&(c+="s"),c);if(8==d||cy&&72==d&&"c"==e)return dy(a,-1)||dt(a,-1);if(46==d&&!b.shiftKey||cy&&68==d&&"c"==e)return dy(a,1)||dt(a,1);if(13==d||27==d)return!0;if(37==d||cy&&66==d&&"c"==e){let b=37==d?"ltr"==dw(a,a.state.selection.from)?-1:1:-1;return dq(a,b,e)||dt(a,b)}if(39==d||cy&&70==d&&"c"==e){let b=39==d?"ltr"==dw(a,a.state.selection.from)?1:-1:1;return dq(a,b,e)||dt(a,b)}else if(38==d||cy&&80==d&&"c"==e)return dx(a,-1,e)||dt(a,-1);else if(40==d||cy&&78==d&&"c"==e)return function(a){if(!cw||a.state.selection.$head.parentOffset>0)return!1;let{focusNode:b,focusOffset:c}=a.domSelectionRange();if(b&&1==b.nodeType&&0==c&&b.firstChild&&"false"==b.firstChild.contentEditable){let c=b.firstChild;dz(a,c,"true"),setTimeout(()=>dz(a,c,"false"),20)}return!1}(a)||dx(a,1,e)||dt(a,1);else if(e==(cy?"m":"c")&&(66==d||73==d||89==d||90==d))return!0;return!1}(a,b)?b.preventDefault():dO(a,"key");else{let b=Date.now();a.input.lastIOSEnter=b,a.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{a.input.lastIOSEnter==b&&(a.someProp("handleKeyDown",b=>b(a,cj(13,"Enter"))),a.input.lastIOSEnter=0)},200)}},dL.keyup=(a,b)=>{16==b.keyCode&&(a.input.shiftKey=!1)},dL.keypress=(a,b)=>{if(dW(a,b)||!b.charCode||b.ctrlKey&&!b.altKey||cy&&b.metaKey)return;if(a.someProp("handleKeyPress",c=>c(a,b)))return void b.preventDefault();let c=a.state.selection;if(!(c instanceof bs)||!c.$from.sameParent(c.$to)){let d=String.fromCharCode(b.charCode),e=()=>a.state.tr.insertText(d).scrollIntoView();/[\r\n]/.test(d)||a.someProp("handleTextInput",b=>b(a,c.$from.pos,c.$to.pos,d,e))||a.dispatch(e()),b.preventDefault()}};let dU=cy?"metaKey":"ctrlKey";dK.mousedown=(a,b)=>{var c;let d,e;a.input.shiftKey=b.shiftKey;let f=d$(a),g=Date.now(),h="singleClick";g-a.input.lastClick.time<500&&(d=(c=a.input.lastClick).x-b.clientX)*d+(e=c.y-b.clientY)*e<100&&!b[dU]&&a.input.lastClick.button==b.button&&("singleClick"==a.input.lastClick.type?h="doubleClick":"doubleClick"==a.input.lastClick.type&&(h="tripleClick")),a.input.lastClick={time:g,x:b.clientX,y:b.clientY,type:h,button:b.button};let i=a.posAtCoords(dR(b));i&&("singleClick"==h?(a.input.mouseDown&&a.input.mouseDown.done(),a.input.mouseDown=new dV(a,i,b,!!f)):("doubleClick"==h?function(a,b,c,d){return dS(a,"handleDoubleClickOn",b,c,d)||a.someProp("handleDoubleClick",c=>c(a,b,d))}:function(a,b,c,d){return dS(a,"handleTripleClickOn",b,c,d)||a.someProp("handleTripleClick",c=>c(a,b,d))||function(a,b,c){if(0!=c.button)return!1;let d=a.state.doc;if(-1==b)return!!d.inlineContent&&(dT(a,bs.create(d,0,d.content.size),"pointer"),!0);let e=d.resolve(b);for(let b=e.depth+1;b>0;b--){let c=b>e.depth?e.nodeAfter:e.node(b),f=e.before(b);if(c.inlineContent)dT(a,bs.create(d,f+1,f+1+c.content.size),"pointer");else{if(!bu.isSelectable(c))continue;dT(a,bu.create(d,f),"pointer")}return!0}}(a,c,d)})(a,i.pos,i.inside,b)?b.preventDefault():dO(a,"pointer"))};class dV{constructor(a,b,c,d){let e,f;if(this.view=a,this.pos=b,this.event=c,this.flushed=d,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=a.state.doc,this.selectNode=!!c[dU],this.allowDefault=c.shiftKey,b.inside>-1)e=a.state.doc.nodeAt(b.inside),f=b.inside;else{let c=a.state.doc.resolve(b.pos);e=c.parent,f=c.depth?c.before():0}const g=d?null:c.target,h=g?a.docView.nearestDesc(g,!0):null;this.target=h&&1==h.nodeDOM.nodeType?h.nodeDOM:null;let{selection:i}=a.state;(0==c.button&&e.type.spec.draggable&&!1!==e.type.spec.selectable||i instanceof bu&&i.from<=f&&i.to>f)&&(this.mightDrag={node:e,pos:f,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&cs&&!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()),a.root.addEventListener("mouseup",this.up=this.up.bind(this)),a.root.addEventListener("mousemove",this.move=this.move.bind(this)),dO(a,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),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(()=>dd(this.view)),this.view.input.mouseDown=null}up(a){if(this.done(),!this.view.dom.contains(a.target))return;let b=this.pos;if(this.view.state.doc!=this.startDoc&&(b=this.view.posAtCoords(dR(a))),this.updateAllowDefault(a),this.allowDefault||!b)dO(this.view,"pointer");else{var c,d,e,f;(c=this.view,d=b.pos,e=b.inside,f=this.selectNode,dS(c,"handleClickOn",d,e,a)||c.someProp("handleClick",b=>b(c,d,a))||(f?function(a,b){if(-1==b)return!1;let c=a.state.selection,d,e;c instanceof bu&&(d=c.node);let f=a.state.doc.resolve(b);for(let a=f.depth+1;a>0;a--){let b=a>f.depth?f.nodeAfter:f.node(a);if(bu.isSelectable(b)){e=d&&c.$from.depth>0&&a>=c.$from.depth&&f.before(c.$from.depth+1)==c.$from.pos?f.before(c.$from.depth):f.before(a);break}}return null!=e&&(dT(a,bu.create(a.state.doc,e),"pointer"),!0)}(c,e):function(a,b){if(-1==b)return!1;let c=a.state.doc.resolve(b),d=c.nodeAfter;return!!(d&&d.isAtom&&bu.isSelectable(d))&&(dT(a,new bu(c),"pointer"),!0)}(c,e)))?a.preventDefault():0==a.button&&(this.flushed||cw&&this.mightDrag&&!this.mightDrag.node.isAtom||cu&&!this.view.state.selection.visible&&2>=Math.min(Math.abs(b.pos-this.view.state.selection.from),Math.abs(b.pos-this.view.state.selection.to)))?(dT(this.view,bo.near(this.view.state.doc.resolve(b.pos)),"pointer"),a.preventDefault()):dO(this.view,"pointer")}}move(a){this.updateAllowDefault(a),dO(this.view,"pointer"),0==a.buttons&&this.done()}updateAllowDefault(a){!this.allowDefault&&(Math.abs(this.event.x-a.clientX)>4||Math.abs(this.event.y-a.clientY)>4)&&(this.allowDefault=!0)}}function dW(a,b){return!!a.composing||!!(cw&&500>Math.abs(b.timeStamp-a.input.compositionEndedAt))&&(a.input.compositionEndedAt=-2e8,!0)}dK.touchstart=a=>{a.input.lastTouch=Date.now(),d$(a),dO(a,"pointer")},dK.touchmove=a=>{a.input.lastTouch=Date.now(),dO(a,"pointer")},dK.contextmenu=a=>d$(a);let dX=cA?5e3:-1;function dY(a,b){clearTimeout(a.input.composingTimeout),b>-1&&(a.input.composingTimeout=setTimeout(()=>d$(a),b))}function dZ(a){let b;for(a.composing&&(a.input.composing=!1,a.input.compositionEndedAt=((b=document.createEvent("Event")).initEvent("event",!0,!0),b.timeStamp));a.input.compositionNodes.length>0;)a.input.compositionNodes.pop().markParentsDirty()}function d$(a,b=!1){if(!cA||!(a.domObserver.flushingSoon>=0)){if(a.domObserver.forceFlush(),dZ(a),b||a.docView&&a.docView.dirty){let c=db(a),d=a.state.selection;return c&&!c.eq(d)?a.dispatch(a.state.tr.setSelection(c)):(a.markCursor||b)&&!d.$from.node(d.$from.sharedDepth(d.to)).inlineContent?a.dispatch(a.state.tr.deleteSelection()):a.updateState(a.state),!0}return!1}}dL.compositionstart=dL.compositionupdate=a=>{if(!a.composing){a.domObserver.flush();let{state:b}=a,c=b.selection.$to;if(b.selection instanceof bs&&(b.storedMarks||!c.textOffset&&c.parentOffset&&c.nodeBefore.marks.some(a=>!1===a.type.spec.inclusive)||cu&&cz&&function(a){let{focusNode:b,focusOffset:c}=a.domSelectionRange();if(!b||1!=b.nodeType||c>=b.childNodes.length)return!1;let d=b.childNodes[c];return 1==d.nodeType&&"false"==d.contentEditable}(a)))a.markCursor=a.state.storedMarks||c.marks(),d$(a,!0),a.markCursor=null;else if(d$(a,!b.selection.empty),cs&&b.selection.empty&&c.parentOffset&&!c.textOffset&&c.nodeBefore.marks.length){let b=a.domSelectionRange();for(let c=b.focusNode,d=b.focusOffset;c&&1==c.nodeType&&0!=d;){let b=d<0?c.lastChild:c.childNodes[d-1];if(!b)break;if(3==b.nodeType){let c=a.domSelection();c&&c.collapse(b,b.nodeValue.length);break}c=b,d=-1}}a.input.composing=!0}dY(a,dX)},dL.compositionend=(a,b)=>{a.composing&&(a.input.composing=!1,a.input.compositionEndedAt=b.timeStamp,a.input.compositionPendingChanges=a.domObserver.pendingRecords().length?a.input.compositionID:0,a.input.compositionNode=null,a.input.badSafariComposition?a.domObserver.forceFlush():a.input.compositionPendingChanges&&Promise.resolve().then(()=>a.domObserver.flush()),a.input.compositionID++,dY(a,20))};let d_=cq&&cr<15||cx&&cC<604;function d0(a,b,c,d,e){let f=dB(a,b,c,d,a.state.selection.$from);if(a.someProp("handlePaste",b=>b(a,e,f||Y.empty)))return!0;if(!f)return!1;let g=0==f.openStart&&0==f.openEnd&&1==f.content.childCount?f.content.firstChild:null,h=g?a.state.tr.replaceSelectionWith(g,d):a.state.tr.replaceSelection(f);return a.dispatch(h.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function d1(a){let b=a.getData("text/plain")||a.getData("Text");if(b)return b;let c=a.getData("text/uri-list");return c?c.replace(/\r?\n/g," "):""}dK.copy=dL.cut=(a,b)=>{let c=a.state.selection,d="cut"==b.type;if(c.empty)return;let e=d_?null:b.clipboardData,{dom:f,text:g}=dA(a,c.content());e?(b.preventDefault(),e.clearData(),e.setData("text/html",f.innerHTML),e.setData("text/plain",g)):function(a,b){if(!a.dom.parentNode)return;let c=a.dom.parentNode.appendChild(document.createElement("div"));c.appendChild(b),c.style.cssText="position: fixed; left: -10000px; top: 10px";let d=getSelection(),e=document.createRange();e.selectNodeContents(b),a.dom.blur(),d.removeAllRanges(),d.addRange(e),setTimeout(()=>{c.parentNode&&c.parentNode.removeChild(c),a.focus()},50)}(a,f),d&&a.dispatch(a.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},dL.paste=(a,b)=>{if(a.composing&&!cA)return;let c=d_?null:b.clipboardData,d=a.input.shiftKey&&45!=a.input.lastKeyCode;c&&d0(a,d1(c),c.getData("text/html"),d,b)?b.preventDefault():function(a,b){if(!a.dom.parentNode)return;let c=a.input.shiftKey||a.state.selection.$from.parent.type.spec.code,d=a.dom.parentNode.appendChild(document.createElement(c?"textarea":"div"));c||(d.contentEditable="true"),d.style.cssText="position: fixed; left: -10000px; top: 10px",d.focus();let e=a.input.shiftKey&&45!=a.input.lastKeyCode;setTimeout(()=>{a.focus(),d.parentNode&&d.parentNode.removeChild(d),c?d0(a,d.value,null,e,b):d0(a,d.textContent,d.innerHTML,e,b)},50)}(a,b)};class d2{constructor(a,b,c){this.slice=a,this.move=b,this.node=c}}let d3=cy?"altKey":"ctrlKey";function d4(a,b){let c=a.someProp("dragCopies",a=>!a(b));return null!=c?c:!b[d3]}for(let a in dK.dragstart=(a,b)=>{let c,d=a.input.mouseDown;if(d&&d.done(),!b.dataTransfer)return;let e=a.state.selection,f=e.empty?null:a.posAtCoords(dR(b));if(f&&f.pos>=e.from&&f.pos<=(e instanceof bu?e.to-1:e.to));else if(d&&d.mightDrag)c=bu.create(a.state.doc,d.mightDrag.pos);else if(b.target&&1==b.target.nodeType){let d=a.docView.nearestDesc(b.target,!0);d&&d.node.type.spec.draggable&&d!=a.docView&&(c=bu.create(a.state.doc,d.posBefore))}let g=(c||a.state.selection).content(),{dom:h,text:i,slice:j}=dA(a,g);b.dataTransfer.files.length&&cu&&!(cv>120)||b.dataTransfer.clearData(),b.dataTransfer.setData(d_?"Text":"text/html",h.innerHTML),b.dataTransfer.effectAllowed="copyMove",d_||b.dataTransfer.setData("text/plain",i),a.dragging=new d2(j,d4(a,b),c)},dK.dragend=a=>{let b=a.dragging;window.setTimeout(()=>{a.dragging==b&&(a.dragging=null)},50)},dL.dragover=dL.dragenter=(a,b)=>b.preventDefault(),dL.drop=(a,b)=>{try{!function(a,b,c){if(!b.dataTransfer)return;let d=a.posAtCoords(dR(b));if(!d)return;let e=a.state.doc.resolve(d.pos),f=c&&c.slice;f?a.someProp("transformPasted",b=>{f=b(f,a,!1)}):f=dB(a,d1(b.dataTransfer),d_?null:b.dataTransfer.getData("text/html"),!1,e);let g=!!(c&&d4(a,b));if(a.someProp("handleDrop",c=>c(a,b,f||Y.empty,g)))return b.preventDefault();if(!f)return;b.preventDefault();let h=f?ba(a.state.doc,e.pos,f):e.pos;null==h&&(h=e.pos);let i=a.state.tr;if(g){let{node:a}=c;a?a.replace(i):i.deleteSelection()}let j=i.mapping.map(h),k=0==f.openStart&&0==f.openEnd&&1==f.content.childCount,l=i.doc;if(k?i.replaceRangeWith(j,j,f.content.firstChild):i.replaceRange(j,j,f),i.doc.eq(l))return;let m=i.doc.resolve(j);if(k&&bu.isSelectable(f.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(f.content.firstChild))i.setSelection(new bu(m));else{let b=i.mapping.map(h);i.mapping.maps[i.mapping.maps.length-1].forEach((a,c,d,e)=>b=e),i.setSelection(dk(a,m,i.doc.resolve(b)))}a.focus(),a.dispatch(i.setMeta("uiEvent","drop"))}(a,b,a.dragging)}finally{a.dragging=null}},dK.focus=a=>{a.input.lastFocus=Date.now(),a.focused||(a.domObserver.stop(),a.dom.classList.add("ProseMirror-focused"),a.domObserver.start(),a.focused=!0,setTimeout(()=>{a.docView&&a.hasFocus()&&!a.domObserver.currentSelection.eq(a.domSelectionRange())&&dd(a)},20))},dK.blur=(a,b)=>{a.focused&&(a.domObserver.stop(),a.dom.classList.remove("ProseMirror-focused"),a.domObserver.start(),b.relatedTarget&&a.dom.contains(b.relatedTarget)&&a.domObserver.currentSelection.clear(),a.focused=!1)},dK.beforeinput=(a,b)=>{if(cu&&cA&&"deleteContentBackward"==b.inputType){a.domObserver.flushSoon();let{domChangeCount:b}=a.input;setTimeout(()=>{if(a.input.domChangeCount!=b||(a.dom.blur(),a.focus(),a.someProp("handleKeyDown",b=>b(a,cj(8,"Backspace")))))return;let{$cursor:c}=a.state.selection;c&&c.pos>0&&a.dispatch(a.state.tr.delete(c.pos-1,c.pos).scrollIntoView())},50)}},dL)dK[a]=dL[a];function d5(a,b){if(a==b)return!0;for(let c in a)if(a[c]!==b[c])return!1;for(let c in b)if(!(c in a))return!1;return!0}class d6{constructor(a,b){this.toDOM=a,this.spec=b||eb,this.side=this.spec.side||0}map(a,b,c,d){let{pos:e,deleted:f}=a.mapResult(b.from+d,this.side<0?-1:1);return f?null:new d9(e-c,e-c,this)}valid(){return!0}eq(a){return this==a||a instanceof d6&&(this.spec.key&&this.spec.key==a.spec.key||this.toDOM==a.toDOM&&d5(this.spec,a.spec))}destroy(a){this.spec.destroy&&this.spec.destroy(a)}}class d7{constructor(a,b){this.attrs=a,this.spec=b||eb}map(a,b,c,d){let e=a.map(b.from+d,this.spec.inclusiveStart?-1:1)-c,f=a.map(b.to+d,this.spec.inclusiveEnd?1:-1)-c;return e>=f?null:new d9(e,f,this)}valid(a,b){return b.from<b.to}eq(a){return this==a||a instanceof d7&&d5(this.attrs,a.attrs)&&d5(this.spec,a.spec)}static is(a){return a.type instanceof d7}destroy(){}}class d8{constructor(a,b){this.attrs=a,this.spec=b||eb}map(a,b,c,d){let e=a.mapResult(b.from+d,1);if(e.deleted)return null;let f=a.mapResult(b.to+d,-1);return f.deleted||f.pos<=e.pos?null:new d9(e.pos-c,f.pos-c,this)}valid(a,b){let{index:c,offset:d}=a.content.findIndex(b.from),e;return d==b.from&&!(e=a.child(c)).isText&&d+e.nodeSize==b.to}eq(a){return this==a||a instanceof d8&&d5(this.attrs,a.attrs)&&d5(this.spec,a.spec)}destroy(){}}class d9{constructor(a,b,c){this.from=a,this.to=b,this.type=c}copy(a,b){return new d9(a,b,this.type)}eq(a,b=0){return this.type.eq(a.type)&&this.from+b==a.from&&this.to+b==a.to}map(a,b,c){return this.type.map(a,this,b,c)}static widget(a,b,c){return new d9(a,a,new d6(b,c))}static inline(a,b,c,d){return new d9(a,b,new d7(c,d))}static node(a,b,c,d){return new d9(a,b,new d8(c,d))}get spec(){return this.type.spec}get inline(){return this.type instanceof d7}get widget(){return this.type instanceof d6}}let ea=[],eb={};class ec{constructor(a,b){this.local=a.length?a:ea,this.children=b.length?b:ea}static create(a,b){return b.length?ei(b,a,0,eb):ed}find(a,b,c){let d=[];return this.findInner(null==a?0:a,null==b?1e9:b,d,0,c),d}findInner(a,b,c,d,e){for(let f=0;f<this.local.length;f++){let g=this.local[f];g.from<=b&&g.to>=a&&(!e||e(g.spec))&&c.push(g.copy(g.from+d,g.to+d))}for(let f=0;f<this.children.length;f+=3)if(this.children[f]<b&&this.children[f+1]>a){let g=this.children[f]+1;this.children[f+2].findInner(a-g,b-g,c,d+g,e)}}map(a,b,c){return this==ed||0==a.maps.length?this:this.mapInner(a,b,0,0,c||eb)}mapInner(a,b,c,d,e){let f;for(let g=0;g<this.local.length;g++){let h=this.local[g].map(a,c,d);h&&h.type.valid(b,h)?(f||(f=[])).push(h):e.onRemove&&e.onRemove(this.local[g].spec)}return this.children.length?function(a,b,c,d,e,f,g){let h=a.slice();for(let a=0,b=f;a<c.maps.length;a++){let d=0;c.maps[a].forEach((a,c,e,f)=>{let g=f-e-(c-a);for(let e=0;e<h.length;e+=3){let f=h[e+1];if(f<0||a>f+b-d)continue;let i=h[e]+b-d;c>=i?h[e+1]=a<=i?-2:-1:a>=b&&g&&(h[e]+=g,h[e+1]+=g)}d+=g}),b=c.maps[a].map(b,-1)}let i=!1;for(let b=0;b<h.length;b+=3)if(h[b+1]<0){if(-2==h[b+1]){i=!0,h[b+1]=-1;continue}let j=c.map(a[b]+f),k=j-e;if(k<0||k>=d.content.size){i=!0;continue}let l=c.map(a[b+1]+f,-1)-e,{index:m,offset:n}=d.content.findIndex(k),o=d.maybeChild(m);if(o&&n==k&&n+o.nodeSize==l){let d=h[b+2].mapInner(c,o,j+1,a[b]+f+1,g);d!=ed?(h[b]=k,h[b+1]=l,h[b+2]=d):(h[b+1]=-2,i=!0)}else i=!0}if(i){let i=ei(function(a,b,c,d,e,f,g){for(let h=0;h<a.length;h+=3)-1==a[h+1]&&function a(b,f){for(let a=0;a<b.local.length;a++){let h=b.local[a].map(d,e,f);h?c.push(h):g.onRemove&&g.onRemove(b.local[a].spec)}for(let c=0;c<b.children.length;c+=3)a(b.children[c+2],b.children[c]+f+1)}(a[h+2],b[h]+f+1);return c}(h,a,b,c,e,f,g),d,0,g);b=i.local;for(let a=0;a<h.length;a+=3)h[a+1]<0&&(h.splice(a,3),a-=3);for(let a=0,b=0;a<i.children.length;a+=3){let c=i.children[a];for(;b<h.length&&h[b]<c;)b+=3;h.splice(b,0,i.children[a],i.children[a+1],i.children[a+2])}}return new ec(b.sort(ej),h)}(this.children,f||[],a,b,c,d,e):f?new ec(f.sort(ej),ea):ed}add(a,b){return b.length?this==ed?ec.create(a,b):this.addInner(a,b,0):this}addInner(a,b,c){let d,e=0;a.forEach((a,f)=>{let g=f+c,h;if(h=eg(b,a,g)){for(d||(d=this.children.slice());e<d.length&&d[e]<f;)e+=3;d[e]==f?d[e+2]=d[e+2].addInner(a,h,g+1):d.splice(e,0,f,f+a.nodeSize,ei(h,a,g+1,eb)),e+=3}});let f=ef(e?eh(b):b,-c);for(let b=0;b<f.length;b++)f[b].type.valid(a,f[b])||f.splice(b--,1);return new ec(f.length?this.local.concat(f).sort(ej):this.local,d||this.children)}remove(a){return 0==a.length||this==ed?this:this.removeInner(a,0)}removeInner(a,b){let c=this.children,d=this.local;for(let d=0;d<c.length;d+=3){let e,f=c[d]+b,g=c[d+1]+b;for(let b=0,c;b<a.length;b++)(c=a[b])&&c.from>f&&c.to<g&&(a[b]=null,(e||(e=[])).push(c));if(!e)continue;c==this.children&&(c=this.children.slice());let h=c[d+2].removeInner(e,f+1);h!=ed?c[d+2]=h:(c.splice(d,3),d-=3)}if(d.length){for(let c=0,e;c<a.length;c++)if(e=a[c])for(let a=0;a<d.length;a++)d[a].eq(e,b)&&(d==this.local&&(d=this.local.slice()),d.splice(a--,1))}return c==this.children&&d==this.local?this:d.length||c.length?new ec(d,c):ed}forChild(a,b){let c,d;if(this==ed)return this;if(b.isLeaf)return ec.empty;for(let b=0;b<this.children.length;b+=3)if(this.children[b]>=a){this.children[b]==a&&(c=this.children[b+2]);break}let e=a+1,f=e+b.content.size;for(let a=0;a<this.local.length;a++){let b=this.local[a];if(b.from<f&&b.to>e&&b.type instanceof d7){let a=Math.max(e,b.from)-e,c=Math.min(f,b.to)-e;a<c&&(d||(d=[])).push(b.copy(a,c))}}if(d){let a=new ec(d.sort(ej),ea);return c?new ee([a,c]):a}return c||ed}eq(a){if(this==a)return!0;if(!(a instanceof ec)||this.local.length!=a.local.length||this.children.length!=a.children.length)return!1;for(let b=0;b<this.local.length;b++)if(!this.local[b].eq(a.local[b]))return!1;for(let b=0;b<this.children.length;b+=3)if(this.children[b]!=a.children[b]||this.children[b+1]!=a.children[b+1]||!this.children[b+2].eq(a.children[b+2]))return!1;return!0}locals(a){return ek(this.localsInner(a))}localsInner(a){if(this==ed)return ea;if(a.inlineContent||!this.local.some(d7.is))return this.local;let b=[];for(let a=0;a<this.local.length;a++)this.local[a].type instanceof d7||b.push(this.local[a]);return b}forEachSet(a){a(this)}}ec.empty=new ec([],[]),ec.removeOverlap=ek;let ed=ec.empty;class ee{constructor(a){this.members=a}map(a,b){let c=this.members.map(c=>c.map(a,b,eb));return ee.from(c)}forChild(a,b){if(b.isLeaf)return ec.empty;let c=[];for(let d=0;d<this.members.length;d++){let e=this.members[d].forChild(a,b);e!=ed&&(e instanceof ee?c=c.concat(e.members):c.push(e))}return ee.from(c)}eq(a){if(!(a instanceof ee)||a.members.length!=this.members.length)return!1;for(let b=0;b<this.members.length;b++)if(!this.members[b].eq(a.members[b]))return!1;return!0}locals(a){let b,c=!0;for(let d=0;d<this.members.length;d++){let e=this.members[d].localsInner(a);if(e.length)if(b){c&&(b=b.slice(),c=!1);for(let a=0;a<e.length;a++)b.push(e[a])}else b=e}return b?ek(c?b:b.sort(ej)):ea}static from(a){switch(a.length){case 0:return ed;case 1:return a[0];default:return new ee(a.every(a=>a instanceof ec)?a:a.reduce((a,b)=>a.concat(b instanceof ec?b:b.members),[]))}}forEachSet(a){for(let b=0;b<this.members.length;b++)this.members[b].forEachSet(a)}}function ef(a,b){if(!b||!a.length)return a;let c=[];for(let d=0;d<a.length;d++){let e=a[d];c.push(new d9(e.from+b,e.to+b,e.type))}return c}function eg(a,b,c){if(b.isLeaf)return null;let d=c+b.nodeSize,e=null;for(let b=0,f;b<a.length;b++)(f=a[b])&&f.from>c&&f.to<d&&((e||(e=[])).push(f),a[b]=null);return e}function eh(a){let b=[];for(let c=0;c<a.length;c++)null!=a[c]&&b.push(a[c]);return b}function ei(a,b,c,d){let e=[],f=!1;b.forEach((b,g)=>{let h=eg(a,b,g+c);if(h){f=!0;let a=ei(h,b,c+g+1,d);a!=ed&&e.push(g,g+b.nodeSize,a)}});let g=ef(f?eh(a):a,-c).sort(ej);for(let a=0;a<g.length;a++)g[a].type.valid(b,g[a])||(d.onRemove&&d.onRemove(g[a].spec),g.splice(a--,1));return g.length||e.length?new ec(g,e):ed}function ej(a,b){return a.from-b.from||a.to-b.to}function ek(a){let b=a;for(let c=0;c<b.length-1;c++){let d=b[c];if(d.from!=d.to)for(let e=c+1;e<b.length;e++){let f=b[e];if(f.from==d.from){f.to!=d.to&&(b==a&&(b=a.slice()),b[e]=f.copy(f.from,d.to),el(b,e+1,f.copy(d.to,f.to)));continue}f.from<d.to&&(b==a&&(b=a.slice()),b[c]=d.copy(d.from,f.from),el(b,e,d.copy(f.from,d.to)));break}}return b}function el(a,b,c){for(;b<a.length&&ej(c,a[b])>0;)b++;a.splice(b,0,c)}function em(a){let b=[];return a.someProp("decorations",c=>{let d=c(a.state);d&&d!=ed&&b.push(d)}),a.cursorWrapper&&b.push(ec.create(a.state.doc,[a.cursorWrapper.deco])),ee.from(b)}let en={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},eo=cq&&cr<=11;class ep{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(a){this.anchorNode=a.anchorNode,this.anchorOffset=a.anchorOffset,this.focusNode=a.focusNode,this.focusOffset=a.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(a){return a.anchorNode==this.anchorNode&&a.anchorOffset==this.anchorOffset&&a.focusNode==this.focusNode&&a.focusOffset==this.focusOffset}}class eq{constructor(a,b){this.view=a,this.handleDOMChange=b,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ep,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(b=>{for(let a=0;a<b.length;a++)this.queue.push(b[a]);cq&&cr<=11&&b.some(a=>"childList"==a.type&&a.removedNodes.length||"characterData"==a.type&&a.oldValue.length>a.target.nodeValue.length)?this.flushSoon():cw&&a.composing&&b.some(a=>"childList"==a.type&&"TR"==a.target.nodeName)?(a.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),eo&&(this.onCharData=a=>{this.queue.push({target:a.target,type:"characterData",oldValue:a.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,en)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let a=this.observer.takeRecords();if(a.length){for(let b=0;b<a.length;b++)this.queue.push(a[b]);window.setTimeout(()=>this.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(dl(this.view)){if(this.suppressingSelectionUpdates)return dd(this.view);if(cq&&cr<=11&&!this.view.state.selection.empty){let a=this.view.domSelectionRange();if(a.focusNode&&cd(a.focusNode,a.focusOffset,a.anchorNode,a.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(a){if(!a.focusNode)return!0;let b=new Set,c;for(let c=a.focusNode;c;c=b9(c))b.add(c);for(let d=a.anchorNode;d;d=b9(d))if(b.has(d)){c=d;break}let d=c&&this.view.docView.nearestDesc(c);if(d&&d.ignoreMutation({type:"selection",target:3==c.nodeType?c.parentNode:c}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let a of this.observer.takeRecords())this.queue.push(a);return this.queue}flush(){var a;let{view:b}=this;if(!b.docView||this.flushingSoon>-1)return;let c=this.pendingRecords();c.length&&(this.queue=[]);let d=b.domSelectionRange(),e=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(d)&&dl(b)&&!this.ignoreSelectionChange(d),f=-1,g=-1,h=!1,i=[];if(b.editable)for(let a=0;a<c.length;a++){let b=this.registerMutation(c[a],i);b&&(f=f<0?b.from:Math.min(b.from,f),g=g<0?b.to:Math.max(b.to,g),b.typeOver&&(h=!0))}if(i.some(a=>"BR"==a.nodeName)&&(8==b.input.lastKeyCode||46==b.input.lastKeyCode)){for(let a of i)if("BR"==a.nodeName&&a.parentNode){let b=a.nextSibling;b&&1==b.nodeType&&"false"==b.contentEditable&&a.parentNode.removeChild(a)}}else if(cs&&i.length){let a=i.filter(a=>"BR"==a.nodeName);if(2==a.length){let[b,c]=a;b.parentNode&&b.parentNode.parentNode==c.parentNode?c.remove():b.remove()}else{let{focusNode:c}=this.currentSelection;for(let d of a){let a=d.parentNode;a&&"LI"==a.nodeName&&(!c||function(a,b){for(let c=b.parentNode;c&&c!=a.dom;c=c.parentNode){let b=a.docView.nearestDesc(c,!0);if(b&&b.node.isBlock)return c}return null}(b,c)!=a)&&d.remove()}}}let j=null;f<0&&e&&b.input.lastFocus>Date.now()-200&&Math.max(b.input.lastTouch,b.input.lastClick.time)<Date.now()-300&&ci(d)&&(j=db(b))&&j.eq(bo.near(b.state.doc.resolve(0),1))?(b.input.lastFocus=0,dd(b),this.currentSelection.set(d),b.scrollToSelection()):(f>-1||e)&&(f>-1&&(b.docView.markDirty(f,g),a=b,!er.has(a)&&(er.set(a,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(a.dom).whiteSpace))&&(a.requiresGeckoHackNode=cs,es||(console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),es=!0))),b.input.badSafariComposition&&(b.input.badSafariComposition=!1,function(a,b){var c;let{focusNode:d,focusOffset:e}=a.domSelectionRange();for(let f of b)if((null==(c=f.parentNode)?void 0:c.nodeName)=="TR"){let b=f.nextSibling;for(;b&&"TD"!=b.nodeName&&"TH"!=b.nodeName;)b=b.nextSibling;if(b){let c=b;for(;;){let a=c.firstChild;if(!a||1!=a.nodeType||"false"==a.contentEditable||/^(BR|IMG)$/.test(a.nodeName))break;c=a}c.insertBefore(f,c.firstChild),d==f&&a.domSelection().collapse(f,e)}else f.parentNode.removeChild(f)}}(b,i)),this.handleDOMChange(f,g,h,i),b.docView&&b.docView.dirty?b.updateState(b.state):this.currentSelection.eq(d)||dd(b),this.currentSelection.set(d))}registerMutation(a,b){if(b.indexOf(a.target)>-1)return null;let c=this.view.docView.nearestDesc(a.target);if("attributes"==a.type&&(c==this.view.docView||"contenteditable"==a.attributeName||"style"==a.attributeName&&!a.oldValue&&!a.target.getAttribute("style"))||!c||c.ignoreMutation(a))return null;if("childList"==a.type){for(let c=0;c<a.addedNodes.length;c++){let d=a.addedNodes[c];b.push(d),3==d.nodeType&&(this.lastChangedTextNode=d)}if(c.contentDOM&&c.contentDOM!=c.dom&&!c.contentDOM.contains(a.target))return{from:c.posBefore,to:c.posAfter};let d=a.previousSibling,e=a.nextSibling;if(cq&&cr<=11&&a.addedNodes.length)for(let b=0;b<a.addedNodes.length;b++){let{previousSibling:c,nextSibling:f}=a.addedNodes[b];(!c||0>Array.prototype.indexOf.call(a.addedNodes,c))&&(d=c),(!f||0>Array.prototype.indexOf.call(a.addedNodes,f))&&(e=f)}let f=d&&d.parentNode==a.target?b8(d)+1:0,g=c.localPosFromDOM(a.target,f,-1),h=e&&e.parentNode==a.target?b8(e):a.target.childNodes.length;return{from:g,to:c.localPosFromDOM(a.target,h,1)}}return"attributes"==a.type?{from:c.posAtStart-c.border,to:c.posAtEnd+c.border}:(this.lastChangedTextNode=a.target,{from:c.posAtStart,to:c.posAtEnd,typeOver:a.target.nodeValue==a.oldValue})}}let er=new WeakMap,es=!1;function et(a,b){let c=b.startContainer,d=b.startOffset,e=b.endContainer,f=b.endOffset,g=a.domAtPos(a.state.selection.anchor);return cd(g.node,g.offset,e,f)&&([c,d,e,f]=[e,f,c,d]),{anchorNode:c,anchorOffset:d,focusNode:e,focusOffset:f}}function eu(a){let b=a.pmViewDesc;if(b)return b.parseRule();if("BR"==a.nodeName&&a.parentNode){if(cw&&/^(ul|ol)$/i.test(a.parentNode.nodeName)){let a=document.createElement("div");return a.appendChild(document.createElement("li")),{skip:a}}else if(a.parentNode.lastChild==a||cw&&/^(tr|table)$/i.test(a.parentNode.nodeName))return{ignore:!0}}else if("IMG"==a.nodeName&&a.getAttribute("mark-placeholder"))return{ignore:!0};return null}let ev=/^(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 ew(a,b,c){return Math.max(c.anchor,c.head)>b.content.size?null:dk(a,b.resolve(c.anchor),b.resolve(c.head))}function ex(a,b,c){let d=a.depth,e=b?a.end():a.pos;for(;d>0&&(b||a.indexAfter(d)==a.node(d).childCount);)d--,e++,b=!1;if(c){let b=a.node(d).maybeChild(a.indexAfter(d));for(;b&&!b.isLeaf;)b=b.firstChild,e++}return e}function ey(a){if(2!=a.length)return!1;let b=a.charCodeAt(0),c=a.charCodeAt(1);return b>=56320&&b<=57343&&c>=55296&&c<=56319}class ez{constructor(a,b){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 dN,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=b,this.state=b.state,this.directPlugins=b.plugins||[],this.directPlugins.forEach(eE),this.dispatch=this.dispatch.bind(this),this.dom=a&&a.mount||document.createElement("div"),a&&(a.appendChild?a.appendChild(this.dom):"function"==typeof a?a(this.dom):a.mount&&(this.mounted=!0)),this.editable=eC(this),eB(this),this.nodeViews=eD(this),this.docView=cZ(this.state.doc,eA(this),em(this),this.dom,this),this.domObserver=new eq(this,(a,b,c,d)=>(function(a,b,c,d,e){let f,g,h,i=a.input.compositionPendingChanges||(a.composing?a.input.compositionID:0);if(a.input.compositionPendingChanges=0,b<0){let b=a.input.lastSelectionTime>Date.now()-50?a.input.lastSelectionOrigin:null,c=db(a,b);if(c&&!a.state.selection.eq(c)){if(cu&&cA&&13===a.input.lastKeyCode&&Date.now()-100<a.input.lastKeyCodeTime&&a.someProp("handleKeyDown",b=>b(a,cj(13,"Enter"))))return;let d=a.state.tr.setSelection(c);"pointer"==b?d.setMeta("pointer",!0):"key"==b&&d.scrollIntoView(),i&&d.setMeta("composition",i),a.dispatch(d)}return}let j=a.state.doc.resolve(b),k=j.sharedDepth(c);b=j.before(k+1),c=a.state.doc.resolve(c).after(k+1);let l=a.state.selection,m=function(a,b,c){let d,{node:e,fromOffset:f,toOffset:g,from:h,to:i}=a.docView.parseRange(b,c),j=a.domSelectionRange(),k=j.anchorNode;if(k&&a.dom.contains(1==k.nodeType?k:k.parentNode)&&(d=[{node:k,offset:j.anchorOffset}],ci(j)||d.push({node:j.focusNode,offset:j.focusOffset})),cu&&8===a.input.lastKeyCode)for(let a=g;a>f;a--){let b=e.childNodes[a-1],c=b.pmViewDesc;if("BR"==b.nodeName&&!c){g=a;break}if(!c||c.size)break}let l=a.state.doc,m=a.someProp("domParser")||aA.fromSchema(a.state.schema),n=l.resolve(h),o=null,p=m.parse(e,{topNode:n.parent,topMatch:n.parent.contentMatchAt(n.index()),topOpen:!0,from:f,to:g,preserveWhitespace:"pre"!=n.parent.type.whitespace||"full",findPositions:d,ruleFromNode:eu,context:n});if(d&&null!=d[0].pos){let a=d[0].pos,b=d[1]&&d[1].pos;null==b&&(b=a),o={anchor:a+h,head:b+h}}return{doc:p,sel:o,from:h,to:i}}(a,b,c),n=a.state.doc,o=n.slice(m.from,m.to);8===a.input.lastKeyCode&&Date.now()-100<a.input.lastKeyCodeTime?(f=a.state.selection.to,g="end"):(f=a.state.selection.from,g="start"),a.input.lastKeyCode=null;let p=function(a,b,c,d,e){let f=a.findDiffStart(b,c);if(null==f)return null;let{a:g,b:h}=a.findDiffEnd(b,c+a.size,c+b.size);if("end"==e){let a=Math.max(0,f-Math.min(g,h));d-=g+a-f}if(g<f&&a.size<b.size){let a=d<=f&&d>=g?f-d:0;(f-=a)&&f<b.size&&ey(b.textBetween(f-1,f+1))&&(f+=a?1:-1),h=f+(h-g),g=f}else if(h<f){let b=d<=f&&d>=h?f-d:0;(f-=b)&&f<a.size&&ey(a.textBetween(f-1,f+1))&&(f+=b?1:-1),g=f+(g-h),h=f}return{start:f,endA:g,endB:h}}(o.content,m.doc.content,m.from,f,g);if(p&&a.input.domChangeCount++,(cx&&a.input.lastIOSEnter>Date.now()-225||cA)&&e.some(a=>1==a.nodeType&&!ev.test(a.nodeName))&&(!p||p.endA>=p.endB)&&a.someProp("handleKeyDown",b=>b(a,cj(13,"Enter")))){a.input.lastIOSEnter=0;return}if(!p)if(d&&l instanceof bs&&!l.empty&&l.$head.sameParent(l.$anchor)&&!a.composing&&!(m.sel&&m.sel.anchor!=m.sel.head))p={start:l.from,endA:l.to,endB:l.to};else{if(m.sel){let b=ew(a,a.state.doc,m.sel);if(b&&!b.eq(a.state.selection)){let c=a.state.tr.setSelection(b);i&&c.setMeta("composition",i),a.dispatch(c)}}return}a.state.selection.from<a.state.selection.to&&p.start==p.endB&&a.state.selection instanceof bs&&(p.start>a.state.selection.from&&p.start<=a.state.selection.from+2&&a.state.selection.from>=m.from?p.start=a.state.selection.from:p.endA<a.state.selection.to&&p.endA>=a.state.selection.to-2&&a.state.selection.to<=m.to&&(p.endB+=a.state.selection.to-p.endA,p.endA=a.state.selection.to)),cq&&cr<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>m.from&&" \xa0"==m.doc.textBetween(p.start-m.from-1,p.start-m.from+1)&&(p.start--,p.endA--,p.endB--);let q=m.doc.resolveNoCache(p.start-m.from),r=m.doc.resolveNoCache(p.endB-m.from),s=n.resolve(p.start),t=q.sameParent(r)&&q.parent.inlineContent&&s.end()>=p.endA;if((cx&&a.input.lastIOSEnter>Date.now()-225&&(!t||e.some(a=>"DIV"==a.nodeName||"P"==a.nodeName))||!t&&q.pos<m.doc.content.size&&(!q.sameParent(r)||!q.parent.inlineContent)&&q.pos<r.pos&&!/\S/.test(m.doc.textBetween(q.pos,r.pos,"","")))&&a.someProp("handleKeyDown",b=>b(a,cj(13,"Enter")))){a.input.lastIOSEnter=0;return}if(a.state.selection.anchor>p.start&&function(a,b,c,d,e){if(c-b<=e.pos-d.pos||ex(d,!0,!1)<e.pos)return!1;let f=a.resolve(b);if(!d.parent.isTextblock){let a=f.nodeAfter;return null!=a&&c==b+a.nodeSize}if(f.parentOffset<f.parent.content.size||!f.parent.isTextblock)return!1;let g=a.resolve(ex(f,!0,!0));return!(!g.parent.isTextblock||g.pos>c||ex(g,!0,!1)<c)&&d.parent.content.cut(d.parentOffset).eq(g.parent.content)}(n,p.start,p.endA,q,r)&&a.someProp("handleKeyDown",b=>b(a,cj(8,"Backspace")))){cA&&cu&&a.domObserver.suppressSelectionUpdates();return}cu&&p.endB==p.start&&(a.input.lastChromeDelete=Date.now()),cA&&!t&&q.start()!=r.start()&&0==r.parentOffset&&q.depth==r.depth&&m.sel&&m.sel.anchor==m.sel.head&&m.sel.head==p.endA&&(p.endB-=2,r=m.doc.resolveNoCache(p.endB-m.from),setTimeout(()=>{a.someProp("handleKeyDown",function(b){return b(a,cj(13,"Enter"))})},20));let u=p.start,v=p.endA,w=b=>{let c=b||a.state.tr.replace(u,v,m.doc.slice(p.start-m.from,p.endB-m.from));if(m.sel){let b=ew(a,c.doc,m.sel);b&&!(cu&&a.composing&&b.empty&&(p.start!=p.endB||a.input.lastChromeDelete<Date.now()-100)&&(b.head==u||b.head==c.mapping.map(v)-1)||cq&&b.empty&&b.head==u)&&c.setSelection(b)}return i&&c.setMeta("composition",i),c.scrollIntoView()};if(t)if(q.pos==r.pos){cq&&cr<=11&&0==q.parentOffset&&(a.domObserver.suppressSelectionUpdates(),setTimeout(()=>dd(a),20));let b=w(a.state.tr.delete(u,v)),c=n.resolve(p.start).marksAcross(n.resolve(p.endA));c&&b.ensureMarks(c),a.dispatch(b)}else if(p.endA==p.endB&&(h=function(a,b){let c=a.firstChild.marks,d=b.firstChild.marks,e=c,f=d,g,h,i;for(let a=0;a<d.length;a++)e=d[a].removeFromSet(e);for(let a=0;a<c.length;a++)f=c[a].removeFromSet(f);if(1==e.length&&0==f.length)h=e[0],g="add",i=a=>a.mark(h.addToSet(a.marks));else{if(0!=e.length||1!=f.length)return null;h=f[0],g="remove",i=a=>a.mark(h.removeFromSet(a.marks))}let j=[];for(let a=0;a<b.childCount;a++)j.push(i(b.child(a)));if(S.from(j).eq(a))return{mark:h,type:g}}(q.parent.content.cut(q.parentOffset,r.parentOffset),s.parent.content.cut(s.parentOffset,p.endA-s.start())))){let b=w(a.state.tr);"add"==h.type?b.addMark(u,v,h.mark):b.removeMark(u,v,h.mark),a.dispatch(b)}else if(q.parent.child(q.index()).isText&&q.index()==r.index()-!r.textOffset){let b=q.parent.textBetween(q.parentOffset,r.parentOffset),c=()=>w(a.state.tr.insertText(b,u,v));a.someProp("handleTextInput",d=>d(a,u,v,b,c))||a.dispatch(c())}else a.dispatch(w());else a.dispatch(w())})(this,a,b,c,d)),this.domObserver.start(),function(a){for(let b in dK){let c=dK[b];a.dom.addEventListener(b,a.input.eventHandlers[b]=b=>{!function(a,b){if(!b.bubbles)return!0;if(b.defaultPrevented)return!1;for(let c=b.target;c!=a.dom;c=c.parentNode)if(!c||11==c.nodeType||c.pmViewDesc&&c.pmViewDesc.stopEvent(b))return!1;return!0}(a,b)||dQ(a,b)||!a.editable&&b.type in dL||c(a,b)},dM[b]?{passive:!0}:void 0)}cw&&a.dom.addEventListener("input",()=>null),dP(a)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let a=this._props;for(let b in this._props={},a)this._props[b]=a[b];this._props.state=this.state}return this._props}update(a){a.handleDOMEvents!=this._props.handleDOMEvents&&dP(this);let b=this._props;this._props=a,a.plugins&&(a.plugins.forEach(eE),this.directPlugins=a.plugins),this.updateStateInner(a.state,b)}setProps(a){let b={};for(let a in this._props)b[a]=this._props[a];for(let c in b.state=this.state,a)b[c]=a[c];this.update(b)}updateState(a){this.updateStateInner(a,this._props)}updateStateInner(a,b){var c,d,e;let f=this.state,g=!1,h=!1;a.storedMarks&&this.composing&&(dZ(this),h=!0),this.state=a;let i=f.plugins!=a.plugins||this._props.plugins!=b.plugins;if(i||this._props.plugins!=b.plugins||this._props.nodeViews!=b.nodeViews){let a=eD(this);(function(a,b){let c=0,d=0;for(let d in a){if(a[d]!=b[d])return!0;c++}for(let a in b)d++;return c!=d})(a,this.nodeViews)&&(this.nodeViews=a,g=!0)}(i||b.handleDOMEvents!=this._props.handleDOMEvents)&&dP(this),this.editable=eC(this),eB(this);let j=em(this),k=eA(this),l=f.plugins==a.plugins||f.doc.eq(a.doc)?a.scrollToSelection>f.scrollToSelection?"to selection":"preserve":"reset",m=g||!this.docView.matchesNode(a.doc,k,j);(m||!a.selection.eq(f.selection))&&(h=!0);let n="preserve"==l&&h&&null==this.dom.style.overflowAnchor&&function(a){let b,c,d=a.dom.getBoundingClientRect(),e=Math.max(0,d.top);for(let f=(d.left+d.right)/2,g=e+1;g<Math.min(innerHeight,d.bottom);g+=5){let d=a.root.elementFromPoint(f,g);if(!d||d==a.dom||!a.dom.contains(d))continue;let h=d.getBoundingClientRect();if(h.top>=e-20){b=d,c=h.top;break}}return{refDOM:b,refTop:c,stack:cF(a.dom)}}(this);if(h){let b,c,h;this.domObserver.stop();let i=m&&(cq||cu)&&!this.composing&&!f.selection.empty&&!a.selection.empty&&(d=f.selection,e=a.selection,h=Math.min(d.$anchor.sharedDepth(d.head),e.$anchor.sharedDepth(e.head)),d.$anchor.start(h)!=e.$anchor.start(h));if(m){let b=cu?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(a){let b=a.domSelectionRange();if(!b.focusNode)return null;let c=function(a,b){for(;;){if(3==a.nodeType&&b)return a;if(1==a.nodeType&&b>0){if("false"==a.contentEditable)return null;b=cg(a=a.childNodes[b-1])}else{if(!a.parentNode||ch(a))return null;b=b8(a),a=a.parentNode}}}(b.focusNode,b.focusOffset),d=function(a,b){for(;;){if(3==a.nodeType&&b<a.nodeValue.length)return a;if(1==a.nodeType&&b<a.childNodes.length){if("false"==a.contentEditable)return null;a=a.childNodes[b],b=0}else{if(!a.parentNode||ch(a))return null;b=b8(a)+1,a=a.parentNode}}}(b.focusNode,b.focusOffset);if(c&&d&&c!=d){let b=d.pmViewDesc,e=a.domObserver.lastChangedTextNode;if(c==e||d==e)return e;if(!b||!b.isText(d.nodeValue))return d;if(a.input.compositionNode==d){let a=c.pmViewDesc;if(!(!a||!a.isText(c.nodeValue)))return d}}return c||d}(this)),(g||!this.docView.update(a.doc,k,j,this))&&(this.docView.updateOuterDeco(k),this.docView.destroy(),this.docView=cZ(a.doc,k,j,this.dom,this)),!b||this.trackWrites&&this.dom.contains(this.trackWrites)||(i=!0)}i||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&(b=this.docView.domFromPos(this.state.selection.anchor,0),c=this.domSelectionRange(),cd(b.node,b.offset,c.anchorNode,c.anchorOffset)))?dd(this,i):(di(this,a.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(f),(null==(c=this.dragging)?void 0:c.node)&&!f.doc.eq(a.doc)&&this.updateDraggedNode(this.dragging,f),"reset"==l?this.dom.scrollTop=0:"to selection"==l?this.scrollToSelection():n&&function({refDOM:a,refTop:b,stack:c}){let d=a?a.getBoundingClientRect().top:0;cG(c,0==d?0:d-b)}(n)}scrollToSelection(){let a=this.domSelectionRange().focusNode;if(a&&this.dom.contains(1==a.nodeType?a:a.parentNode))if(this.someProp("handleScrollToSelection",a=>a(this)));else if(this.state.selection instanceof bu){let b=this.docView.domAfterPos(this.state.selection.from);1==b.nodeType&&cE(this,b.getBoundingClientRect(),a)}else cE(this,this.coordsAtPos(this.state.selection.head,1),a)}destroyPluginViews(){let a;for(;a=this.pluginViews.pop();)a.destroy&&a.destroy()}updatePluginViews(a){if(a&&a.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let b=0;b<this.pluginViews.length;b++){let c=this.pluginViews[b];c.update&&c.update(this,a)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let a=0;a<this.directPlugins.length;a++){let b=this.directPlugins[a];b.spec.view&&this.pluginViews.push(b.spec.view(this))}for(let a=0;a<this.state.plugins.length;a++){let b=this.state.plugins[a];b.spec.view&&this.pluginViews.push(b.spec.view(this))}}}updateDraggedNode(a,b){let c=a.node,d=-1;if(this.state.doc.nodeAt(c.from)==c.node)d=c.from;else{let a=c.from+(this.state.doc.content.size-b.doc.content.size);(a>0&&this.state.doc.nodeAt(a))==c.node&&(d=a)}this.dragging=new d2(a.slice,a.move,d<0?void 0:bu.create(this.state.doc,d))}someProp(a,b){let c=this._props&&this._props[a],d;if(null!=c&&(d=b?b(c):c))return d;for(let c=0;c<this.directPlugins.length;c++){let e=this.directPlugins[c].props[a];if(null!=e&&(d=b?b(e):e))return d}let e=this.state.plugins;if(e)for(let c=0;c<e.length;c++){let f=e[c].props[a];if(null!=f&&(d=b?b(f):f))return d}}hasFocus(){if(cq){let a=this.root.activeElement;if(a==this.dom)return!0;if(!a||!this.dom.contains(a))return!1;for(;a&&this.dom!=a&&this.dom.contains(a);){if("false"==a.contentEditable)return!1;a=a.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(a){if(a.setActive)return a.setActive();if(cH)return a.focus(cH);let b=cF(a);a.focus(null==cH?{get preventScroll(){return cH={preventScroll:!0},!0}}:void 0),cH||(cH=!1,cG(b,0))}(this.dom),dd(this),this.domObserver.start()}get root(){let a=this._root;if(null==a){for(let a=this.dom.parentNode;a;a=a.parentNode)if(9==a.nodeType||11==a.nodeType&&a.host)return a.getSelection||(Object.getPrototypeOf(a).getSelection=()=>a.ownerDocument.getSelection()),this._root=a}return a||document}updateRoot(){this._root=null}posAtCoords(a){return function(a,b){var c;let d,e,f=a.dom.ownerDocument,g,h=0,i=function(a,b,c){if(a.caretPositionFromPoint)try{let d=a.caretPositionFromPoint(b,c);if(d)return{node:d.offsetNode,offset:Math.min(cg(d.offsetNode),d.offset)}}catch(a){}if(a.caretRangeFromPoint){let d=a.caretRangeFromPoint(b,c);if(d)return{node:d.startContainer,offset:Math.min(cg(d.startContainer),d.startOffset)}}}(f,b.left,b.top);i&&({node:g,offset:h}=i);let j=(a.root.elementFromPoint?a.root:f).elementFromPoint(b.left,b.top);if(!j||!a.dom.contains(1!=j.nodeType?j.parentNode:j)){let c=a.dom.getBoundingClientRect();if(!cI(b,c)||!(j=function a(b,c,d){let e=b.childNodes.length;if(e&&d.top<d.bottom)for(let f=Math.max(0,Math.min(e-1,Math.floor(e*(c.top-d.top)/(d.bottom-d.top))-2)),g=f;;){let d=b.childNodes[g];if(1==d.nodeType){let b=d.getClientRects();for(let e=0;e<b.length;e++){let f=b[e];if(cI(c,f))return a(d,c,f)}}if((g=(g+1)%e)==f)break}return b}(a.dom,b,c)))return null}if(cw)for(let a=j;g&&a;a=b9(a))a.draggable&&(g=void 0);if(j=(d=(c=j).parentNode)&&/^li$/i.test(d.nodeName)&&b.left<c.getBoundingClientRect().left?d:c,g){let c;if(cs&&1==g.nodeType&&(h=Math.min(h,g.childNodes.length))<g.childNodes.length){let a=g.childNodes[h],c;"IMG"==a.nodeName&&(c=a.getBoundingClientRect()).right<=b.left&&c.bottom>b.top&&h++}cB&&h&&1==g.nodeType&&1==(c=g.childNodes[h-1]).nodeType&&"false"==c.contentEditable&&c.getBoundingClientRect().top>=b.top&&h--,g==a.dom&&h==g.childNodes.length-1&&1==g.lastChild.nodeType&&b.top>g.lastChild.getBoundingClientRect().bottom?e=a.state.doc.content.size:(0==h||1!=g.nodeType||"BR"!=g.childNodes[h-1].nodeName)&&(e=function(a,b,c,d){let e=-1;for(let c=b,f=!1;c!=a.dom;){let b=a.docView.nearestDesc(c,!0),g;if(!b)return null;if(1==b.dom.nodeType&&(b.node.isBlock&&b.parent||!b.contentDOM)&&((g=b.dom.getBoundingClientRect()).width||g.height)&&(b.node.isBlock&&b.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(b.dom.nodeName)&&(!f&&g.left>d.left||g.top>d.top?e=b.posBefore:(!f&&g.right<d.left||g.bottom<d.top)&&(e=b.posAfter),f=!0),!b.contentDOM&&e<0&&!b.node.isText))return(b.node.isBlock?d.top<(g.top+g.bottom)/2:d.left<(g.left+g.right)/2)?b.posBefore:b.posAfter;c=b.dom.parentNode}return e>-1?e:a.docView.posFromDOM(b,c,-1)}(a,g,h,b))}null==e&&(e=function(a,b,c){let{node:d,offset:e}=function a(b,c){let d,e,f,g=2e8,h,i=0,j=c.top,k=c.top;for(let a=b.firstChild,l=0;a;a=a.nextSibling,l++){let b;if(1==a.nodeType)b=a.getClientRects();else{if(3!=a.nodeType)continue;b=cb(a).getClientRects()}for(let m=0;m<b.length;m++){let n=b[m];if(n.top<=j&&n.bottom>=k){j=Math.max(n.bottom,j),k=Math.min(n.top,k);let b=n.left>c.left?n.left-c.left:n.right<c.left?c.left-n.right:0;if(b<g){f=a,g=b,h=b&&3==f.nodeType?{left:n.right<c.left?n.right:n.left,top:c.top}:c,1==a.nodeType&&b&&(i=l+ +(c.left>=(n.left+n.right)/2));continue}}else n.top>c.top&&!d&&n.left<=c.left&&n.right>=c.left&&(d=a,e={left:Math.max(n.left,Math.min(n.right,c.left)),top:n.top});!f&&(c.left>=n.right&&c.top>=n.top||c.left>=n.left&&c.top>=n.bottom)&&(i=l+1)}}return(!f&&d&&(f=d,h=e,g=0),f&&3==f.nodeType)?function(a,b){let c=a.nodeValue.length,d=document.createRange(),e;for(let f=0;f<c;f++){d.setEnd(a,f+1),d.setStart(a,f);let c=cK(d,1);if(c.top!=c.bottom&&cI(b,c)){e={node:a,offset:f+ +(b.left>=(c.left+c.right)/2)};break}}return d.detach(),e||{node:a,offset:0}}(f,h):!f||g&&1==f.nodeType?{node:b,offset:i}:a(f,h)}(b,c),f=-1;if(1==d.nodeType&&!d.firstChild){let a=d.getBoundingClientRect();f=a.left!=a.right&&c.left>(a.left+a.right)/2?1:-1}return a.docView.posFromDOM(d,e,f)}(a,j,b));let k=a.docView.nearestDesc(j,!0);return{pos:e,inside:k?k.posAtStart-k.border:-1}}(this,a)}coordsAtPos(a,b=1){return cM(this,a,b)}domAtPos(a,b=0){return this.docView.domFromPos(a,b)}nodeDOM(a){let b=this.docView.descAt(a);return b?b.nodeDOM:null}posAtDOM(a,b,c=-1){let d=this.docView.posFromDOM(a,b,c);if(null==d)throw RangeError("DOM position not inside the editor");return d}endOfTextblock(a,b){return function(a,b,c){let d,e;return cR==b&&cS==c?cT:(cR=b,cS=c,cT="up"==c||"down"==c?(d=b.selection,e="up"==c?d.$from:d.$to,cP(a,b,()=>{let{node:b}=a.docView.domFromPos(e.pos,"up"==c?-1:1);for(;;){let c=a.docView.nearestDesc(b,!0);if(!c)break;if(c.node.isBlock){b=c.contentDOM||c.dom;break}b=c.dom.parentNode}let d=cM(a,e.pos,1);for(let a=b.firstChild;a;a=a.nextSibling){let b;if(1==a.nodeType)b=a.getClientRects();else{if(3!=a.nodeType)continue;b=cb(a,0,a.nodeValue.length).getClientRects()}for(let a=0;a<b.length;a++){let e=b[a];if(e.bottom>e.top+1&&("up"==c?d.top-e.top>(e.bottom-d.top)*2:e.bottom-d.bottom>(d.bottom-e.top)*2))return!1}}return!0})):function(a,b,c){let{$head:d}=b.selection;if(!d.parent.isTextblock)return!1;let e=d.parentOffset,f=e==d.parent.content.size,g=a.domSelection();return g?cQ.test(d.parent.textContent)&&g.modify?cP(a,b,()=>{let{focusNode:b,focusOffset:e,anchorNode:f,anchorOffset:h}=a.domSelectionRange(),i=g.caretBidiLevel;g.modify("move",c,"character");let j=d.depth?a.docView.domAfterPos(d.before()):a.dom,{focusNode:k,focusOffset:l}=a.domSelectionRange(),m=k&&!j.contains(1==k.nodeType?k:k.parentNode)||b==k&&e==l;try{g.collapse(f,h),b&&(b!=f||e!=h)&&g.extend&&g.extend(b,e)}catch(a){}return null!=i&&(g.caretBidiLevel=i),m}):"left"==c||"backward"==c?!e:f:d.pos==d.start()||d.pos==d.end()}(a,b,c))}(this,b||this.state,a)}pasteHTML(a,b){return d0(this,"",a,!1,b||new ClipboardEvent("paste"))}pasteText(a,b){return d0(this,a,null,!0,b||new ClipboardEvent("paste"))}serializeForClipboard(a){return dA(this,a)}destroy(){if(this.docView){for(let a in this.domObserver.stop(),this.input.eventHandlers)this.dom.removeEventListener(a,this.input.eventHandlers[a]);clearTimeout(this.input.composingTimeout),clearTimeout(this.input.lastIOSEnterFallbackTimeout),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],em(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,cc()}}get isDestroyed(){return null==this.docView}dispatchEvent(a){!dQ(this,a)&&dK[a.type]&&(this.editable||!(a.type in dL))&&dK[a.type](this,a)}domSelectionRange(){let a=this.domSelection();return a?cw&&11===this.root.nodeType&&function(a){let b=a.activeElement;for(;b&&b.shadowRoot;)b=b.shadowRoot.activeElement;return b}(this.dom.ownerDocument)==this.dom&&function(a,b){let c;if(b.getComposedRanges){let c=b.getComposedRanges(a.root)[0];if(c)return et(a,c)}function d(a){a.preventDefault(),a.stopImmediatePropagation(),c=a.getTargetRanges()[0]}return a.dom.addEventListener("beforeinput",d,!0),document.execCommand("indent"),a.dom.removeEventListener("beforeinput",d,!0),c?et(a,c):null}(this,a)||a:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function eA(a){let b=Object.create(null);return b.class="ProseMirror",b.contenteditable=String(a.editable),a.someProp("attributes",c=>{if("function"==typeof c&&(c=c(a.state)),c)for(let a in c)"class"==a?b.class+=" "+c[a]:"style"==a?b.style=(b.style?b.style+";":"")+c[a]:b[a]||"contenteditable"==a||"nodeName"==a||(b[a]=String(c[a]))}),b.translate||(b.translate="no"),[d9.node(0,a.state.doc.content.size,b)]}function eB(a){if(a.markCursor){let b=document.createElement("img");b.className="ProseMirror-separator",b.setAttribute("mark-placeholder","true"),b.setAttribute("alt",""),a.cursorWrapper={dom:b,deco:d9.widget(a.state.selection.from,b,{raw:!0,marks:a.markCursor})}}else a.cursorWrapper=null}function eC(a){return!a.someProp("editable",b=>!1===b(a.state))}function eD(a){let b=Object.create(null);function c(a){for(let c in a)Object.prototype.hasOwnProperty.call(b,c)||(b[c]=a[c])}return a.someProp("nodeViews",c),a.someProp("markViews",c),b}function eE(a){if(a.spec.state||a.spec.filterTransaction||a.spec.appendTransaction)throw RangeError("Plugins passed directly to the view must not have a state component")}ez.prototype.dispatch=function(a){let b=this._props.dispatchTransaction;b?b.call(this,a):this.updateState(this.state.apply(a))};for(var eF={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:"'"},eG={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},eH="u">typeof navigator&&/Mac/.test(navigator.platform),eI="u">typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),eJ=0;eJ<10;eJ++)eF[48+eJ]=eF[96+eJ]=String(eJ);for(var eJ=1;eJ<=24;eJ++)eF[eJ+111]="F"+eJ;for(var eJ=65;eJ<=90;eJ++)eF[eJ]=String.fromCharCode(eJ+32),eG[eJ]=String.fromCharCode(eJ);for(var eK in eF)eG.hasOwnProperty(eK)||(eG[eK]=eF[eK]);let eL="u">typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),eM="u">typeof navigator&&/Win/.test(navigator.platform);function eN(a,b,c=!0){return b.altKey&&(a="Alt-"+a),b.ctrlKey&&(a="Ctrl-"+a),b.metaKey&&(a="Meta-"+a),c&&b.shiftKey&&(a="Shift-"+a),a}function eO(a){let b=function(a){let b=Object.create(null);for(let c in a)b[function(a){let b,c,d,e,f=a.split(/-(?!$)/),g=f[f.length-1];"Space"==g&&(g=" ");for(let a=0;a<f.length-1;a++){let g=f[a];if(/^(cmd|meta|m)$/i.test(g))e=!0;else if(/^a(lt)?$/i.test(g))b=!0;else if(/^(c|ctrl|control)$/i.test(g))c=!0;else if(/^s(hift)?$/i.test(g))d=!0;else if(/^mod$/i.test(g))eL?e=!0:c=!0;else throw Error("Unrecognized modifier name: "+g)}return b&&(g="Alt-"+g),c&&(g="Ctrl-"+g),e&&(g="Meta-"+g),d&&(g="Shift-"+g),g}(c)]=a[c];return b}(a);return function(a,c){var d;let e=("Esc"==(d=!(eH&&c.metaKey&&c.shiftKey&&!c.ctrlKey&&!c.altKey||eI&&c.shiftKey&&c.key&&1==c.key.length||"Unidentified"==c.key)&&c.key||(c.shiftKey?eG:eF)[c.keyCode]||c.key||"Unidentified")&&(d="Escape"),"Del"==d&&(d="Delete"),"Left"==d&&(d="ArrowLeft"),"Up"==d&&(d="ArrowUp"),"Right"==d&&(d="ArrowRight"),"Down"==d&&(d="ArrowDown"),d),f,g=b[eN(e,c)];if(g&&g(a.state,a.dispatch,a))return!0;if(1==e.length&&" "!=e){if(c.shiftKey){let d=b[eN(e,c,!1)];if(d&&d(a.state,a.dispatch,a))return!0}if((c.altKey||c.metaKey||c.ctrlKey)&&!(eM&&c.ctrlKey&&c.altKey)&&(f=eF[c.keyCode])&&f!=e){let d=b[eN(f,c)];if(d&&d(a.state,a.dispatch,a))return!0}}return!1}}var eP=Object.defineProperty,eQ=(a,b)=>{for(var c in b)eP(a,c,{get:b[c],enumerable:!0})};function eR(a){let{state:b,transaction:c}=a,{selection:d}=c,{doc:e}=c,{storedMarks:f}=c;return{...b,apply:b.apply.bind(b),applyTransaction:b.applyTransaction.bind(b),plugins:b.plugins,schema:b.schema,reconfigure:b.reconfigure.bind(b),toJSON:b.toJSON.bind(b),get storedMarks(){return f},get selection(){return d},get doc(){return e},get tr(){return d=c.selection,e=c.doc,f=c.storedMarks,c}}}var eS=class{constructor(a){this.editor=a.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=a.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:a,editor:b,state:c}=this,{view:d}=b,{tr:e}=c,f=this.buildProps(e);return Object.fromEntries(Object.entries(a).map(([a,b])=>[a,(...a)=>{let c=b(...a)(f);return e.getMeta("preventDispatch")||this.hasCustomState||d.dispatch(e),c}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(a,b=!0){let{rawCommands:c,editor:d,state:e}=this,{view:f}=d,g=[],h=!!a,i=a||e.tr,j=()=>(h||!b||i.getMeta("preventDispatch")||this.hasCustomState||f.dispatch(i),g.every(a=>!0===a)),k={...Object.fromEntries(Object.entries(c).map(([a,c])=>[a,(...a)=>{let d=this.buildProps(i,b),e=c(...a)(d);return g.push(e),k}])),run:j};return k}createCan(a){let{rawCommands:b,state:c}=this,d=a||c.tr,e=this.buildProps(d,!1);return{...Object.fromEntries(Object.entries(b).map(([a,b])=>[a,(...a)=>b(...a)({...e,dispatch:void 0})])),chain:()=>this.createChain(d,!1)}}buildProps(a,b=!0){let{rawCommands:c,editor:d,state:e}=this,{view:f}=d,g={tr:a,editor:d,view:f,state:eR({state:e,transaction:a}),dispatch:b?()=>void 0:void 0,chain:()=>this.createChain(a,b),can:()=>this.createCan(a),get commands(){return Object.fromEntries(Object.entries(c).map(([a,b])=>[a,(...a)=>b(...a)(g)]))}};return g}},eT={};eQ(eT,{blur:()=>eU,clearContent:()=>eV,clearNodes:()=>eW,command:()=>eX,createParagraphNear:()=>eY,cut:()=>eZ,deleteCurrentNode:()=>e$,deleteNode:()=>e0,deleteRange:()=>e1,deleteSelection:()=>e2,enter:()=>e3,exitCode:()=>e4,extendMarkRange:()=>fb,first:()=>fc,focus:()=>fi,forEach:()=>fj,insertContent:()=>fk,insertContentAt:()=>fo,joinBackward:()=>fr,joinDown:()=>fq,joinForward:()=>fs,joinItemBackward:()=>ft,joinItemForward:()=>fu,joinTextblockBackward:()=>fv,joinTextblockForward:()=>fw,joinUp:()=>fp,keyboardShortcut:()=>fy,lift:()=>fA,liftEmptyBlock:()=>fB,liftListItem:()=>fC,newlineInCode:()=>fD,resetAttributes:()=>fG,scrollIntoView:()=>fH,selectAll:()=>fI,selectNodeBackward:()=>fJ,selectNodeForward:()=>fK,selectParentNode:()=>fL,selectTextblockEnd:()=>fM,selectTextblockStart:()=>fN,setContent:()=>fP,setMark:()=>gl,setMeta:()=>gm,setNode:()=>gn,setNodeSelection:()=>go,setTextDirection:()=>gp,setTextSelection:()=>gq,sinkListItem:()=>gr,splitBlock:()=>gt,splitListItem:()=>gu,toggleList:()=>gx,toggleMark:()=>gy,toggleNode:()=>gz,toggleWrap:()=>gA,undoInputRule:()=>gB,unsetAllMarks:()=>gC,unsetMark:()=>gD,unsetTextDirection:()=>gE,updateAttributes:()=>gF,wrapIn:()=>gG,wrapInList:()=>gH});var eU=()=>({editor:a,view:b})=>(requestAnimationFrame(()=>{var c;a.isDestroyed||(b.dom.blur(),null==(c=null==window?void 0:window.getSelection())||c.removeAllRanges())}),!0),eV=(a=!0)=>({commands:b})=>b.setContent("",{emitUpdate:a}),eW=()=>({state:a,tr:b,dispatch:c})=>{let{selection:d}=b,{ranges:e}=d;return!c||(e.forEach(({$from:c,$to:d})=>{a.doc.nodesBetween(c.pos,d.pos,(a,c)=>{if(a.type.isText)return;let{doc:d,mapping:e}=b,f=d.resolve(e.map(c)),g=d.resolve(e.map(c+a.nodeSize)),h=f.blockRange(g);if(!h)return;let i=a1(h);if(a.type.isTextblock){let{defaultType:a}=f.parent.contentMatchAt(f.index());b.setNodeMarkup(h.start,a)}(i||0===i)&&b.lift(h,i)})}),!0)},eX=a=>b=>a(b),eY=()=>({state:a,dispatch:b})=>bY(a,b),eZ=(a,b)=>({editor:c,tr:d})=>{let{state:e}=c,f=e.doc.slice(a.from,a.to);d.deleteRange(a.from,a.to);let g=d.mapping.map(b);return d.insert(g,f.content),d.setSelection(new bs(d.doc.resolve(Math.max(g-1,0)))),!0},e$=()=>({tr:a,dispatch:b})=>{let{selection:c}=a,d=c.$anchor.node();if(d.content.size>0)return!1;let e=a.selection.$anchor;for(let c=e.depth;c>0;c-=1)if(e.node(c).type===d.type){if(b){let b=e.before(c),d=e.after(c);a.delete(b,d).scrollIntoView()}return!0}return!1};function e_(a,b){if("string"==typeof a){if(!b.nodes[a])throw Error(`There is no node type named '${a}'. Maybe you forgot to add the extension?`);return b.nodes[a]}return a}var e0=a=>({tr:b,state:c,dispatch:d})=>{let e=e_(a,c.schema),f=b.selection.$anchor;for(let a=f.depth;a>0;a-=1)if(f.node(a).type===e){if(d){let c=f.before(a),d=f.after(a);b.delete(c,d).scrollIntoView()}return!0}return!1},e1=a=>({tr:b,dispatch:c})=>{let{from:d,to:e}=a;return c&&b.delete(d,e),!0},e2=()=>({state:a,dispatch:b})=>bK(a,b),e3=()=>({commands:a})=>a.keyboardShortcut("Enter"),e4=()=>({state:a,dispatch:b})=>bX(a,b);function e5(a){return"[object RegExp]"===Object.prototype.toString.call(a)}function e6(a,b,c={strict:!0}){let d=Object.keys(b);return!d.length||d.every(d=>c.strict?b[d]===a[d]:e5(b[d])?b[d].test(a[d]):b[d]===a[d])}function e7(a,b,c={}){return a.find(a=>a.type===b&&e6(Object.fromEntries(Object.keys(c).map(b=>[b,a.attrs[b]])),c))}function e8(a,b,c={}){return!!e7(a,b,c)}function e9(a,b,c){var d;if(!a||!b)return;let e=a.parent.childAfter(a.parentOffset);if(e.node&&e.node.marks.some(a=>a.type===b)||(e=a.parent.childBefore(a.parentOffset)),!e.node||!e.node.marks.some(a=>a.type===b)||(c=c||(null==(d=e.node.marks[0])?void 0:d.attrs),!e7([...e.node.marks],b,c)))return;let f=e.index,g=a.start()+e.offset,h=f+1,i=g+e.node.nodeSize;for(;f>0&&e8([...a.parent.child(f-1).marks],b,c);)f-=1,g-=a.parent.child(f).nodeSize;for(;h<a.parent.childCount&&e8([...a.parent.child(h).marks],b,c);)i+=a.parent.child(h).nodeSize,h+=1;return{from:g,to:i}}function fa(a,b){if("string"==typeof a){if(!b.marks[a])throw Error(`There is no mark type named '${a}'. Maybe you forgot to add the extension?`);return b.marks[a]}return a}var fb=(a,b={})=>({tr:c,state:d,dispatch:e})=>{let f=fa(a,d.schema),{doc:g,selection:h}=c,{$from:i,from:j,to:k}=h;if(e){let a=e9(i,f,b);if(a&&a.from<=j&&a.to>=k){let b=bs.create(g,a.from,a.to);c.setSelection(b)}}return!0},fc=a=>b=>{let c="function"==typeof a?a(b):a;for(let a=0;a<c.length;a+=1)if(c[a](b))return!0;return!1};function fd(a){return a instanceof bs}function fe(a=0,b=0,c=0){return Math.min(Math.max(a,b),c)}function ff(a,b=null){if(!b)return null;let c=bo.atStart(a),d=bo.atEnd(a);if("start"===b||!0===b)return c;if("end"===b)return d;let e=c.from,f=d.to;return"all"===b?bs.create(a,fe(0,e,f),fe(a.content.size,e,f)):bs.create(a,fe(b,e,f),fe(b,e,f))}function fg(){return"Android"===navigator.platform||/android/i.test(navigator.userAgent)}function fh(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var fi=(a=null,b={})=>({editor:c,view:d,tr:e,dispatch:f})=>{b={scrollIntoView:!0,...b};let g=()=>{(fh()||fg())&&d.dom.focus(),"u">typeof navigator&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&!fh()&&!fg()&&d.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{!c.isDestroyed&&(d.focus(),(null==b?void 0:b.scrollIntoView)&&c.commands.scrollIntoView())})};try{if(d.hasFocus()&&null===a||!1===a)return!0}catch{return!1}if(f&&null===a&&!fd(c.state.selection))return g(),!0;let h=ff(e.doc,a)||c.state.selection,i=c.state.selection.eq(h);return f&&(i||e.setSelection(h),i&&e.storedMarks&&e.setStoredMarks(e.storedMarks),g()),!0},fj=(a,b)=>c=>a.every((a,d)=>b(a,{...c,index:d})),fk=(a,b)=>({tr:c,commands:d})=>d.insertContentAt({from:c.selection.from,to:c.selection.to},a,b),fl=a=>{let b=a.childNodes;for(let c=b.length-1;c>=0;c-=1){let d=b[c];3===d.nodeType&&d.nodeValue&&/^(\n\s\s|\n)$/.test(d.nodeValue)?a.removeChild(d):1===d.nodeType&&fl(d)}return a};function fm(a){if("u"<typeof window)throw Error("[tiptap error]: there is no window object available, so this function cannot be used");let b=`<body>${a}</body>`;return fl(new window.DOMParser().parseFromString(b,"text/html").body)}function fn(a,b,c){if(a instanceof aj||a instanceof S)return a;c={slice:!0,parseOptions:{},...c};let d="object"==typeof a&&null!==a,e="string"==typeof a;if(d)try{if(Array.isArray(a)&&a.length>0)return S.fromArray(a.map(a=>b.nodeFromJSON(a)));let d=b.nodeFromJSON(a);return c.errorOnInvalidContent&&d.check(),d}catch(d){if(c.errorOnInvalidContent)throw Error("[tiptap error]: Invalid JSON content",{cause:d});return console.warn("[tiptap warn]: Invalid content.","Passed value:",a,"Error:",d),fn("",b,c)}if(e){if(c.errorOnInvalidContent){let d=!1,e="",f=new ay({topNode:b.spec.topNode,marks:b.spec.marks,nodes:b.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:a=>(d=!0,e="string"==typeof a?a:a.outerHTML,null)}]}})});if(c.slice?aA.fromSchema(f).parseSlice(fm(a),c.parseOptions):aA.fromSchema(f).parse(fm(a),c.parseOptions),c.errorOnInvalidContent&&d)throw Error("[tiptap error]: Invalid HTML content",{cause:Error(`Invalid element found: ${e}`)})}let d=aA.fromSchema(b);return c.slice?d.parseSlice(fm(a),c.parseOptions).content:d.parse(fm(a),c.parseOptions)}return fn("",b,c)}var fo=(a,b,c)=>({tr:d,dispatch:e,editor:f})=>{var g;if(e){let e,h;c={parseOptions:f.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...c};let i=a=>{f.emit("contentError",{editor:f,error:a,disableCollaboration:()=>{"collaboration"in f.storage&&"object"==typeof f.storage.collaboration&&f.storage.collaboration&&(f.storage.collaboration.isDisabled=!0)}})},j={preserveWhitespace:"full",...c.parseOptions};if(!c.errorOnInvalidContent&&!f.options.enableContentCheck&&f.options.emitContentError)try{fn(b,f.schema,{parseOptions:j,errorOnInvalidContent:!0})}catch(a){i(a)}try{e=fn(b,f.schema,{parseOptions:j,errorOnInvalidContent:null!=(g=c.errorOnInvalidContent)?g:f.options.enableContentCheck})}catch(a){return i(a),!1}let{from:k,to:l}="number"==typeof a?{from:a,to:a}:{from:a.from,to:a.to},m=!0,n=!0;if((!("type"in e)?e:[e]).forEach(a=>{a.check(),m=!!m&&a.isText&&0===a.marks.length,n=!!n&&a.isBlock}),k===l&&n){let{parent:a}=d.doc.resolve(k);!a.isTextblock||a.type.spec.code||a.childCount||(k-=1,l+=1)}if(m){if(Array.isArray(b))h=b.map(a=>a.text||"").join("");else if(b instanceof S){let a="";b.forEach(b=>{b.text&&(a+=b.text)}),h=a}else h="object"==typeof b&&b&&b.text?b.text:b;d.insertText(h,k,l)}else{h=e;let a=d.doc.resolve(k),b=a.node(),c=0===a.parentOffset,f=b.isText||b.isTextblock,g=b.content.size>0;c&&f&&g&&(k=Math.max(0,k-1)),d.replaceWith(k,l,h)}c.updateSelection&&function(a,b,c){let d=a.steps.length-1;if(d<b)return;let e=a.steps[d];if(!(e instanceof aZ||e instanceof a$))return;let f=a.mapping.maps[d],g=0;f.forEach((a,b,c,d)=>{0===g&&(g=d)}),a.setSelection(bo.near(a.doc.resolve(g),-1))}(d,d.steps.length-1,0),c.applyInputRules&&d.setMeta("applyInputRules",{from:k,text:h}),c.applyPasteRules&&d.setMeta("applyPasteRules",{from:k,text:h})}return!0},fp=()=>({state:a,dispatch:b})=>((a,b)=>{let c=a.selection,d=c instanceof bu,e;if(d){if(c.node.isTextblock||!a7(a.doc,c.from))return!1;e=c.from}else if(null==(e=a9(a.doc,c.from,-1)))return!1;if(b){let c=a.tr.join(e);d&&c.setSelection(bu.create(c.doc,e-a.doc.resolve(e).nodeBefore.nodeSize)),b(c.scrollIntoView())}return!0})(a,b),fq=()=>({state:a,dispatch:b})=>((a,b)=>{let c=a.selection,d;if(c instanceof bu){if(c.node.isTextblock||!a7(a.doc,c.to))return!1;d=c.to}else if(null==(d=a9(a.doc,c.to,1)))return!1;return b&&b(a.tr.join(d).scrollIntoView()),!0})(a,b),fr=()=>({state:a,dispatch:b})=>bM(a,b),fs=()=>({state:a,dispatch:b})=>bS(a,b),ft=()=>({state:a,dispatch:b,tr:c})=>{try{let d=a9(a.doc,a.selection.$from.pos,-1);if(null==d)return!1;return c.join(d,2),b&&b(c),!0}catch{return!1}},fu=()=>({state:a,dispatch:b,tr:c})=>{try{let d=a9(a.doc,a.selection.$from.pos,1);if(null==d)return!1;return c.join(d,2),b&&b(c),!0}catch{return!1}},fv=()=>({state:a,dispatch:b})=>((a,b,c)=>{let d=bL(a,c);if(!d)return!1;let e=bQ(d);return!!e&&bN(a,e,b)})(a,b),fw=()=>({state:a,dispatch:b})=>((a,b,c)=>{let d=bR(a,c);if(!d)return!1;let e=bU(d);return!!e&&bN(a,e,b)})(a,b);function fx(){return"u">typeof navigator&&/Mac/.test(navigator.platform)}var fy=a=>({editor:b,view:c,tr:d,dispatch:e})=>{let f=(function(a){let b,c,d,e,f=a.split(/-(?!$)/),g=f[f.length-1];"Space"===g&&(g=" ");for(let a=0;a<f.length-1;a+=1){let g=f[a];if(/^(cmd|meta|m)$/i.test(g))e=!0;else if(/^a(lt)?$/i.test(g))b=!0;else if(/^(c|ctrl|control)$/i.test(g))c=!0;else if(/^s(hift)?$/i.test(g))d=!0;else if(/^mod$/i.test(g))fh()||fx()?e=!0:c=!0;else throw Error(`Unrecognized modifier name: ${g}`)}return b&&(g=`Alt-${g}`),c&&(g=`Ctrl-${g}`),e&&(g=`Meta-${g}`),d&&(g=`Shift-${g}`),g})(a).split(/-(?!$)/),g=f.find(a=>!["Alt","Ctrl","Meta","Shift"].includes(a)),h=new KeyboardEvent("keydown",{key:"Space"===g?" ":g,altKey:f.includes("Alt"),ctrlKey:f.includes("Ctrl"),metaKey:f.includes("Meta"),shiftKey:f.includes("Shift"),bubbles:!0,cancelable:!0}),i=b.captureTransaction(()=>{c.someProp("handleKeyDown",a=>a(c,h))});return null==i||i.steps.forEach(a=>{let b=a.map(d.mapping);b&&e&&d.maybeStep(b)}),!0};function fz(a,b,c={}){let{from:d,to:e,empty:f}=a.selection,g=b?e_(b,a.schema):null,h=[];a.doc.nodesBetween(d,e,(a,b)=>{if(a.isText)return;let c=Math.max(d,b),f=Math.min(e,b+a.nodeSize);h.push({node:a,from:c,to:f})});let i=e-d,j=h.filter(a=>!g||g.name===a.node.type.name).filter(a=>e6(a.node.attrs,c,{strict:!1}));return f?!!j.length:j.reduce((a,b)=>a+b.to-b.from,0)>=i}var fA=(a,b={})=>({state:c,dispatch:d})=>{let e=e_(a,c.schema);return!!fz(c,e,b)&&((a,b)=>{let{$from:c,$to:d}=a.selection,e=c.blockRange(d),f=e&&a1(e);return null!=f&&(b&&b(a.tr.lift(e,f).scrollIntoView()),!0)})(c,d)},fB=()=>({state:a,dispatch:b})=>bZ(a,b),fC=a=>({state:b,dispatch:c})=>{var d;return(d=e_(a,b.schema),function(a,b){let{$from:c,$to:e}=a.selection,f=c.blockRange(e,a=>a.childCount>0&&a.firstChild.type==d);return!!f&&(!b||(c.node(f.depth-1).type==d?function(a,b,c,d){let e=a.tr,f=d.end,g=d.$to.end(d.depth);f<g&&(e.step(new a$(f-1,g,f,g,new Y(S.from(c.create(null,d.parent.copy())),1,0),1,!0)),d=new ah(e.doc.resolve(d.$from.pos),e.doc.resolve(g),d.depth));let h=a1(d);if(null==h)return!1;e.lift(d,h);let i=e.doc.resolve(e.mapping.map(f,-1)-1);return a7(e.doc,i.pos)&&i.nodeBefore.type==i.nodeAfter.type&&e.join(i.pos),b(e.scrollIntoView()),!0}(a,b,d,f):function(a,b,c){let d=a.tr,e=c.parent;for(let a=c.end,b=c.endIndex-1,f=c.startIndex;b>f;b--)a-=e.child(b).nodeSize,d.delete(a-1,a+1);let f=d.doc.resolve(c.start),g=f.nodeAfter;if(d.mapping.map(c.end)!=c.start+f.nodeAfter.nodeSize)return!1;let h=0==c.startIndex,i=c.endIndex==e.childCount,j=f.node(-1),k=f.index(-1);if(!j.canReplace(k+ +!h,k+1,g.content.append(i?S.empty:S.from(e))))return!1;let l=f.pos,m=l+g.nodeSize;return d.step(new a$(l-!!h,m+ +!!i,l+1,m-1,new Y((h?S.empty:S.from(e.copy(S.empty))).append(i?S.empty:S.from(e.copy(S.empty))),+!h,+!i),+!h)),b(d.scrollIntoView()),!0}(a,b,f)))})(b,c)},fD=()=>({state:a,dispatch:b})=>bV(a,b);function fE(a,b){return b.nodes[a]?"node":b.marks[a]?"mark":null}function fF(a,b){let c="string"==typeof b?[b]:b;return Object.keys(a).reduce((b,d)=>(c.includes(d)||(b[d]=a[d]),b),{})}var fG=(a,b)=>({tr:c,state:d,dispatch:e})=>{let f=null,g=null,h=fE("string"==typeof a?a:a.name,d.schema);if(!h)return!1;"node"===h&&(f=e_(a,d.schema)),"mark"===h&&(g=fa(a,d.schema));let i=!1;return c.selection.ranges.forEach(a=>{d.doc.nodesBetween(a.$from.pos,a.$to.pos,(a,d)=>{f&&f===a.type&&(i=!0,e&&c.setNodeMarkup(d,void 0,fF(a.attrs,b))),g&&a.marks.length&&a.marks.forEach(f=>{g===f.type&&(i=!0,e&&c.addMark(d,d+a.nodeSize,g.create(fF(f.attrs,b))))})})}),i},fH=()=>({tr:a,dispatch:b})=>(b&&a.scrollIntoView(),!0),fI=()=>({tr:a,dispatch:b})=>{if(b){let b=new bw(a.doc);a.setSelection(b)}return!0},fJ=()=>({state:a,dispatch:b})=>bP(a,b),fK=()=>({state:a,dispatch:b})=>bT(a,b),fL=()=>({state:a,dispatch:b})=>((a,b)=>{let{$from:c,to:d}=a.selection,e,f=c.sharedDepth(d);return 0!=f&&(e=c.before(f),b&&b(a.tr.setSelection(bu.create(a.doc,e))),!0)})(a,b),fM=()=>({state:a,dispatch:b})=>b1(a,b),fN=()=>({state:a,dispatch:b})=>b0(a,b);function fO(a,b,c={},d={}){return fn(a,b,{slice:!1,parseOptions:c,errorOnInvalidContent:d.errorOnInvalidContent})}var fP=(a,{errorOnInvalidContent:b,emitUpdate:c=!0,parseOptions:d={}}={})=>({editor:e,tr:f,dispatch:g,commands:h})=>{let{doc:i}=f;if("full"!==d.preserveWhitespace){let h=fO(a,e.schema,d,{errorOnInvalidContent:null!=b?b:e.options.enableContentCheck});return g&&f.replaceWith(0,i.content.size,h).setMeta("preventUpdate",!c),!0}return g&&f.setMeta("preventUpdate",!c),h.insertContentAt({from:0,to:i.content.size},a,{parseOptions:d,errorOnInvalidContent:null!=b?b:e.options.enableContentCheck})};function fQ(a,b){let c=fa(b,a.schema),{from:d,to:e,empty:f}=a.selection,g=[];f?(a.storedMarks&&g.push(...a.storedMarks),g.push(...a.selection.$head.marks())):a.doc.nodesBetween(d,e,a=>{g.push(...a.marks)});let h=g.find(a=>a.type.name===c.name);return h?{...h.attrs}:{}}function fR(a,b){let c=new bm(a);return b.forEach(a=>{a.steps.forEach(a=>{c.step(a)})}),c}function fS(a,b){for(let c=a.depth;c>0;c-=1){let d=a.node(c);if(b(d))return{pos:c>0?a.before(c):0,start:a.start(c),depth:c,node:d}}}function fT(a){return b=>fS(b.$from,a)}function fU(a,b,c){return void 0===a.config[b]&&a.parent?fU(a.parent,b,c):"function"==typeof a.config[b]?a.config[b].bind({...c,parent:a.parent?fU(a.parent,b,c):null}):a.config[b]}function fV(a){return a.map(a=>{let b={name:a.name,options:a.options,storage:a.storage},c=fU(a,"addExtensions",b);return c?[a,...fV(c())]:a}).flat(10)}function fW(a,b){let c=aJ.fromSchema(b).serializeFragment(a),d=document.implementation.createHTMLDocument().createElement("div");return d.appendChild(c),d.innerHTML}function fX(a){return"function"==typeof a}function fY(a,b,...c){return fX(a)?b?a.bind(b)(...c):a(...c):a}function fZ(a){let b=a.filter(a=>"extension"===a.type);return{baseExtensions:b,nodeExtensions:a.filter(a=>"node"===a.type),markExtensions:a.filter(a=>"mark"===a.type)}}function f$(a){let b=[],{nodeExtensions:c,markExtensions:d}=fZ(a),e=[...c,...d],f={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},g=c.filter(a=>"text"!==a.name).map(a=>a.name),h=d.map(a=>a.name),i=[...g,...h];return a.forEach(a=>{let c={name:a.name,options:a.options,storage:a.storage,extensions:e},d=fU(a,"addGlobalAttributes",c);d&&d().forEach(a=>{(Array.isArray(a.types)?a.types:"*"===a.types?i:"nodes"===a.types?g:"marks"===a.types?h:[]).forEach(c=>{Object.entries(a.attributes).forEach(([a,d])=>{b.push({type:c,name:a,attribute:{...f,...d}})})})})}),e.forEach(a=>{let c={name:a.name,options:a.options,storage:a.storage},d=fU(a,"addAttributes",c);d&&Object.entries(d()).forEach(([c,d])=>{let e={...f,...d};"function"==typeof(null==e?void 0:e.default)&&(e.default=e.default()),(null==e?void 0:e.isRequired)&&(null==e?void 0:e.default)===void 0&&delete e.default,b.push({type:a.name,name:c,attribute:e})})}),b}function f_(...a){return a.filter(a=>!!a).reduce((a,b)=>{let c={...a};return Object.entries(b).forEach(([a,b])=>{if(!c[a]){c[a]=b;return}if("class"===a){let d=b?String(b).split(" "):[],e=c[a]?c[a].split(" "):[],f=d.filter(a=>!e.includes(a));c[a]=[...e,...f].join(" ")}else if("style"===a){let d=b?b.split(";").map(a=>a.trim()).filter(Boolean):[],e=c[a]?c[a].split(";").map(a=>a.trim()).filter(Boolean):[],f=new Map;e.forEach(a=>{let[b,c]=a.split(":").map(a=>a.trim());f.set(b,c)}),d.forEach(a=>{let[b,c]=a.split(":").map(a=>a.trim());f.set(b,c)}),c[a]=Array.from(f.entries()).map(([a,b])=>`${a}: ${b}`).join("; ")}else c[a]=b}),c},{})}function f0(a,b){return b.filter(b=>b.type===a.type.name).filter(a=>a.attribute.rendered).map(b=>b.attribute.renderHTML?b.attribute.renderHTML(a.attrs)||{}:{[b.name]:a.attrs[b.name]}).reduce((a,b)=>f_(a,b),{})}function f1(a,b){return"style"in a?a:{...a,getAttrs:c=>{let d=a.getAttrs?a.getAttrs(c):a.attrs;if(!1===d)return!1;let e=b.reduce((a,b)=>{var d;let e=b.attribute.parseHTML?b.attribute.parseHTML(c):"string"!=typeof(d=c.getAttribute(b.name))?d:d.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(d):"true"===d||"false"!==d&&d;return null==e?a:{...a,[b.name]:e}},{});return{...d,...e}}}}function f2(a){return Object.fromEntries(Object.entries(a).filter(([a,b])=>!("attrs"===a&&function(a={}){return 0===Object.keys(a).length&&a.constructor===Object}(b))&&null!=b))}function f3(a){var b,c;let d={};return!(null==(b=null==a?void 0:a.attribute)?void 0:b.isRequired)&&"default"in((null==a?void 0:a.attribute)||{})&&(d.default=a.attribute.default),(null==(c=null==a?void 0:a.attribute)?void 0:c.validate)!==void 0&&(d.validate=a.attribute.validate),[a.name,d]}function f4(a){return a.sort((a,b)=>{let c=fU(a,"priority")||100,d=fU(b,"priority")||100;return c>d?-1:+(c<d)})}function f5(a){var b;let c=f4(fV(a)),d=Array.from(new Set((b=c.map(a=>a.name)).filter((a,c)=>b.indexOf(a)!==c)));return d.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${d.map(a=>`'${a}'`).join(", ")}]. This can lead to issues.`),c}function f6(a,b,c){let{from:d,to:e}=b,{blockSeparator:f="\n\n",textSerializers:g={}}=c||{},h="";return a.nodesBetween(d,e,(a,c,i,j)=>{var k;a.isBlock&&c>d&&(h+=f);let l=null==g?void 0:g[a.type.name];if(l)return i&&(h+=l({node:a,pos:c,parent:i,index:j,range:b})),!1;a.isText&&(h+=null==(k=null==a?void 0:a.text)?void 0:k.slice(Math.max(d,c)-c,e-c))}),h}function f7(a){return Object.fromEntries(Object.entries(a.nodes).filter(([,a])=>a.spec.toText).map(([a,b])=>[a,b.spec.toText]))}function f8(a,b){let c=fE("string"==typeof b?b:b.name,a.schema);return"node"===c?function(a,b){let c=e_(b,a.schema),{from:d,to:e}=a.selection,f=[];a.doc.nodesBetween(d,e,a=>{f.push(a)});let g=f.reverse().find(a=>a.type.name===c.name);return g?{...g.attrs}:{}}(a,b):"mark"===c?fQ(a,b):{}}function f9(a){let b,{mapping:c,steps:d}=a,e=[];return c.maps.forEach((a,b)=>{let f=[];if(a.ranges.length)a.forEach((a,b)=>{f.push({from:a,to:b})});else{let{from:a,to:c}=d[b];if(void 0===a||void 0===c)return;f.push({from:a,to:c})}f.forEach(({from:a,to:d})=>{let f=c.slice(b).map(a,-1),g=c.slice(b).map(d),h=c.invert().map(f,-1),i=c.invert().map(g);e.push({oldRange:{from:h,to:i},newRange:{from:f,to:g}})})}),1===(b=function(a,b=JSON.stringify){let c={};return a.filter(a=>{let d=b(a);return!Object.prototype.hasOwnProperty.call(c,d)&&(c[d]=!0)})}(e)).length?b:b.filter((a,c)=>!b.filter((a,b)=>b!==c).some(b=>a.oldRange.from>=b.oldRange.from&&a.oldRange.to<=b.oldRange.to&&a.newRange.from>=b.newRange.from&&a.newRange.to<=b.newRange.to))}function ga(a,b,c){let d=[];return a===b?c.resolve(a).marks().forEach(b=>{let e=e9(c.resolve(a),b.type);e&&d.push({mark:b,...e})}):c.nodesBetween(a,b,(a,b)=>{a&&(null==a?void 0:a.nodeSize)!==void 0&&d.push(...a.marks.map(c=>({from:b,to:b+a.nodeSize,mark:c})))}),d}function gb(a,b){return b.nodes[a]||b.marks[a]||null}function gc(a,b,c){return Object.fromEntries(Object.entries(c).filter(([c])=>{let d=a.find(a=>a.type===b&&a.name===c);return!!d&&d.attribute.keepOnSplit}))}function gd(a,b,c={}){let{empty:d,ranges:e}=a.selection,f=b?fa(b,a.schema):null;if(d)return!!(a.storedMarks||a.selection.$from.marks()).filter(a=>!f||f.name===a.type.name).find(a=>e6(a.attrs,c,{strict:!1}));let g=0,h=[];if(e.forEach(({$from:b,$to:c})=>{let d=b.pos,e=c.pos;a.doc.nodesBetween(d,e,(a,b)=>{if(f&&a.inlineContent&&!a.type.allowsMarkType(f))return!1;if(!a.isText&&!a.marks.length)return;let c=Math.max(d,b),i=Math.min(e,b+a.nodeSize);g+=i-c,h.push(...a.marks.map(a=>({mark:a,from:c,to:i})))})}),0===g)return!1;let i=h.filter(a=>!f||f.name===a.mark.type.name).filter(a=>e6(a.mark.attrs,c,{strict:!1})).reduce((a,b)=>a+b.to-b.from,0),j=h.filter(a=>!f||a.mark.type!==f&&a.mark.type.excludes(f)).reduce((a,b)=>a+b.to-b.from,0);return(i>0?i+j:i)>=g}function ge(a,b){return Array.isArray(b)?b.some(b=>("string"==typeof b?b:b.name)===a.name):b}function gf(a,b){let{nodeExtensions:c}=fZ(b),d=c.find(b=>b.name===a);if(!d)return!1;let e={name:d.name,options:d.options,storage:d.storage},f=fY(fU(d,"group",e));return"string"==typeof f&&f.split(" ").includes("list")}function gg(a,{checkChildren:b=!0,ignoreWhitespace:c=!1}={}){var d;if(c){if("hardBreak"===a.type.name)return!0;if(a.isText)return/^\s*$/m.test(null!=(d=a.text)?d:"")}if(a.isText)return!a.text;if(a.isAtom||a.isLeaf)return!1;if(0===a.content.childCount)return!0;if(b){let d=!0;return a.content.forEach(a=>{!1!==d&&(gg(a,{ignoreWhitespace:c,checkChildren:b})||(d=!1))}),d}return!1}function gh(a){return a instanceof bu}var gi=class a{constructor(a){this.position=a}static fromJSON(b){return new a(b.position)}toJSON(){return{position:this.position}}};function gj(a,b){let c=b.mapping.mapResult(a.position);return{position:new gi(c.pos),mapResult:c}}function gk(a){return new gi(a)}var gl=(a,b={})=>({tr:c,state:d,dispatch:e})=>{let{selection:f}=c,{empty:g,ranges:h}=f,i=fa(a,d.schema);if(e)if(g){let a=fQ(d,i);c.addStoredMark(i.create({...a,...b}))}else h.forEach(a=>{let e=a.$from.pos,f=a.$to.pos;d.doc.nodesBetween(e,f,(a,d)=>{let g=Math.max(d,e),h=Math.min(d+a.nodeSize,f);a.marks.find(a=>a.type===i)?a.marks.forEach(a=>{i===a.type&&c.addMark(g,h,i.create({...a.attrs,...b}))}):c.addMark(g,h,i.create(b))})});return function(a,b,c){var d;let{selection:e}=b,f=null;if(fd(e)&&(f=e.$cursor),f){let b=null!=(d=a.storedMarks)?d:f.marks();return f.parent.type.allowsMarkType(c)&&(!!c.isInSet(b)||!b.some(a=>a.type.excludes(c)))}let{ranges:g}=e;return g.some(({$from:b,$to:d})=>{let e=0===b.depth&&a.doc.inlineContent&&a.doc.type.allowsMarkType(c);return a.doc.nodesBetween(b.pos,d.pos,(a,b,d)=>{if(e)return!1;if(a.isInline){let b=!d||d.type.allowsMarkType(c),f=!!c.isInSet(a.marks)||!a.marks.some(a=>a.type.excludes(c));e=b&&f}return!e}),e})}(d,c,i)},gm=(a,b)=>({tr:c})=>(c.setMeta(a,b),!0),gn=(a,b={})=>({state:c,dispatch:d,chain:e})=>{let f,g=e_(a,c.schema);return(c.selection.$anchor.sameParent(c.selection.$head)&&(f=c.selection.$anchor.parent.attrs),g.isTextblock)?e().command(({commands:a})=>!!b2(g,{...f,...b})(c)||a.clearNodes()).command(({state:a})=>b2(g,{...f,...b})(a,d)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},go=a=>({tr:b,dispatch:c})=>{if(c){let{doc:c}=b,d=fe(a,0,c.content.size),e=bu.create(c,d);b.setSelection(e)}return!0},gp=(a,b)=>({tr:c,state:d,dispatch:e})=>{let f,g,{selection:h}=d;return"number"==typeof b?(f=b,g=b):b&&"from"in b&&"to"in b?(f=b.from,g=b.to):(f=h.from,g=h.to),e&&c.doc.nodesBetween(f,g,(b,d)=>{b.isText||c.setNodeMarkup(d,void 0,{...b.attrs,dir:a})}),!0},gq=a=>({tr:b,dispatch:c})=>{if(c){let{doc:c}=b,{from:d,to:e}="number"==typeof a?{from:a,to:a}:a,f=bs.atStart(c).from,g=bs.atEnd(c).to,h=fe(d,f,g),i=fe(e,f,g),j=bs.create(c,h,i);b.setSelection(j)}return!0},gr=a=>({state:b,dispatch:c})=>{var d;return(d=e_(a,b.schema),function(a,b){let{$from:c,$to:e}=a.selection,f=c.blockRange(e,a=>a.childCount>0&&a.firstChild.type==d);if(!f)return!1;let g=f.startIndex;if(0==g)return!1;let h=f.parent,i=h.child(g-1);if(i.type!=d)return!1;if(b){let c=i.lastChild&&i.lastChild.type==h.type,e=S.from(c?d.create():null),g=new Y(S.from(d.create(null,S.from(h.type.create(null,e)))),c?3:1,0),j=f.start,k=f.end;b(a.tr.step(new a$(j-(c?3:1),k,j,k,g,1,!0)).scrollIntoView())}return!0})(b,c)};function gs(a,b){let c=a.storedMarks||a.selection.$to.parentOffset&&a.selection.$from.marks();if(c){let d=c.filter(a=>null==b?void 0:b.includes(a.type.name));a.tr.ensureMarks(d)}}var gt=({keepMarks:a=!0}={})=>({tr:b,state:c,dispatch:d,editor:e})=>{let{selection:f,doc:g}=b,{$from:h,$to:i}=f,j=gc(e.extensionManager.attributes,h.node().type.name,h.node().attrs);if(f instanceof bu&&f.node.isBlock)return!!h.parentOffset&&!!a6(g,h.pos)&&(d&&(a&&gs(c,e.extensionManager.splittableMarks),b.split(h.pos).scrollIntoView()),!0);if(!h.parent.isBlock)return!1;let k=i.parentOffset===i.parent.content.size,l=0===h.depth?void 0:function(a){for(let b=0;b<a.edgeCount;b+=1){let{type:c}=a.edge(b);if(c.isTextblock&&!c.hasRequiredAttrs())return c}return null}(h.node(-1).contentMatchAt(h.indexAfter(-1))),m=k&&l?[{type:l,attrs:j}]:void 0,n=a6(b.doc,b.mapping.map(h.pos),1,m);if(!m&&!n&&a6(b.doc,b.mapping.map(h.pos),1,l?[{type:l}]:void 0)&&(n=!0,m=l?[{type:l,attrs:j}]:void 0),d){if(n&&(f instanceof bs&&b.deleteSelection(),b.split(b.mapping.map(h.pos),1,m),l&&!k&&!h.parentOffset&&h.parent.type!==l)){let a=b.mapping.map(h.before()),c=b.doc.resolve(a);h.node(-1).canReplaceWith(c.index(),c.index()+1,l)&&b.setNodeMarkup(b.mapping.map(h.before()),l)}a&&gs(c,e.extensionManager.splittableMarks),b.scrollIntoView()}return n},gu=(a,b={})=>({tr:c,state:d,dispatch:e,editor:f})=>{var g;let h=e_(a,d.schema),{$from:i,$to:j}=d.selection,k=d.selection.node;if(k&&k.isBlock||i.depth<2||!i.sameParent(j))return!1;let l=i.node(-1);if(l.type!==h)return!1;let m=f.extensionManager.attributes;if(0===i.parent.content.size&&i.node(-1).childCount===i.indexAfter(-1)){if(2===i.depth||i.node(-3).type!==h||i.index(-2)!==i.node(-2).childCount-1)return!1;if(e){let a=S.empty,d=i.index(-1)?1:i.index(-2)?2:3;for(let b=i.depth-d;b>=i.depth-3;b-=1)a=S.from(i.node(b).copy(a));let e=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3,f={...gc(m,i.node().type.name,i.node().attrs),...b},j=(null==(g=h.contentMatch.defaultType)?void 0:g.createAndFill(f))||void 0;a=a.append(S.from(h.createAndFill(null,j)||void 0));let k=i.before(i.depth-(d-1));c.replace(k,i.after(-e),new Y(a,4-d,0));let l=-1;c.doc.nodesBetween(k,c.doc.content.size,(a,b)=>{if(l>-1)return!1;a.isTextblock&&0===a.content.size&&(l=b+1)}),l>-1&&c.setSelection(bs.near(c.doc.resolve(l))),c.scrollIntoView()}return!0}let n=j.pos===i.end()?l.contentMatchAt(0).defaultType:null,o={...gc(m,l.type.name,l.attrs),...b},p={...gc(m,i.node().type.name,i.node().attrs),...b};c.delete(i.pos,j.pos);let q=n?[{type:h,attrs:o},{type:n,attrs:p}]:[{type:h,attrs:o}];if(!a6(c.doc,i.pos,2))return!1;if(e){let{selection:a,storedMarks:b}=d,{splittableMarks:g}=f.extensionManager,h=b||a.$to.parentOffset&&a.$from.marks();if(c.split(i.pos,2,q).scrollIntoView(),!h||!e)return!0;let j=h.filter(a=>g.includes(a.type.name));c.ensureMarks(j)}return!0},gv=(a,b)=>{let c=fT(a=>a.type===b)(a.selection);if(!c)return!0;let d=a.doc.resolve(Math.max(0,c.pos-1)).before(c.depth);if(void 0===d)return!0;let e=a.doc.nodeAt(d);return!(c.node.type===(null==e?void 0:e.type)&&a7(a.doc,c.pos))||(a.join(c.pos),!0)},gw=(a,b)=>{let c=fT(a=>a.type===b)(a.selection);if(!c)return!0;let d=a.doc.resolve(c.start).after(c.depth);if(void 0===d)return!0;let e=a.doc.nodeAt(d);return!(c.node.type===(null==e?void 0:e.type)&&a7(a.doc,d))||(a.join(d),!0)},gx=(a,b,c,d={})=>({editor:e,tr:f,state:g,dispatch:h,chain:i,commands:j,can:k})=>{let{extensions:l,splittableMarks:m}=e.extensionManager,n=e_(a,g.schema),o=e_(b,g.schema),{selection:p,storedMarks:q}=g,{$from:r,$to:s}=p,t=r.blockRange(s),u=q||p.$to.parentOffset&&p.$from.marks();if(!t)return!1;let v=fT(a=>gf(a.type.name,l))(p);if(t.depth>=1&&v&&t.depth-v.depth<=1){if(v.node.type===n)return j.liftListItem(o);if(gf(v.node.type.name,l)&&n.validContent(v.node.content)&&h)return i().command(()=>(f.setNodeMarkup(v.pos,n),!0)).command(()=>gv(f,n)).command(()=>gw(f,n)).run()}return c&&u&&h?i().command(()=>{let a=k().wrapInList(n,d),b=u.filter(a=>m.includes(a.type.name));return f.ensureMarks(b),!!a||j.clearNodes()}).wrapInList(n,d).command(()=>gv(f,n)).command(()=>gw(f,n)).run():i().command(()=>!!k().wrapInList(n,d)||j.clearNodes()).wrapInList(n,d).command(()=>gv(f,n)).command(()=>gw(f,n)).run()},gy=(a,b={},c={})=>({state:d,commands:e})=>{let{extendEmptyMarkRange:f=!1}=c,g=fa(a,d.schema);return gd(d,g,b)?e.unsetMark(g,{extendEmptyMarkRange:f}):e.setMark(g,b)},gz=(a,b,c={})=>({state:d,commands:e})=>{let f,g=e_(a,d.schema),h=e_(b,d.schema),i=fz(d,g,c);return(d.selection.$anchor.sameParent(d.selection.$head)&&(f=d.selection.$anchor.parent.attrs),i)?e.setNode(h,f):e.setNode(g,{...f,...c})},gA=(a,b={})=>({state:c,commands:d})=>{let e=e_(a,c.schema);return fz(c,e,b)?d.lift(e):d.wrapIn(e,b)},gB=()=>({state:a,dispatch:b})=>{let c=a.plugins;for(let d=0;d<c.length;d+=1){let e,f=c[d];if(f.spec.isInputRules&&(e=f.getState(a))){if(b){let b=a.tr,c=e.transform;for(let a=c.steps.length-1;a>=0;a-=1)b.step(c.steps[a].invert(c.docs[a]));if(e.text){let c=b.doc.resolve(e.from).marks();b.replaceWith(e.from,e.to,a.schema.text(e.text,c))}else b.delete(e.from,e.to)}return!0}}return!1},gC=()=>({tr:a,dispatch:b})=>{let{selection:c}=a,{empty:d,ranges:e}=c;return!!d||(b&&e.forEach(b=>{a.removeMark(b.$from.pos,b.$to.pos)}),!0)},gD=(a,b={})=>({tr:c,state:d,dispatch:e})=>{var f;let{extendEmptyMarkRange:g=!1}=b,{selection:h}=c,i=fa(a,d.schema),{$from:j,empty:k,ranges:l}=h;if(!e)return!0;if(k&&g){let{from:a,to:b}=h,d=null==(f=j.marks().find(a=>a.type===i))?void 0:f.attrs,e=e9(j,i,d);e&&(a=e.from,b=e.to),c.removeMark(a,b,i)}else l.forEach(a=>{c.removeMark(a.$from.pos,a.$to.pos,i)});return c.removeStoredMark(i),!0},gE=a=>({tr:b,state:c,dispatch:d})=>{let e,f,{selection:g}=c;return"number"==typeof a?(e=a,f=a):a&&"from"in a&&"to"in a?(e=a.from,f=a.to):(e=g.from,f=g.to),d&&b.doc.nodesBetween(e,f,(a,c)=>{if(a.isText)return;let d={...a.attrs};delete d.dir,b.setNodeMarkup(c,void 0,d)}),!0},gF=(a,b={})=>({tr:c,state:d,dispatch:e})=>{let f=null,g=null,h=fE("string"==typeof a?a:a.name,d.schema);if(!h)return!1;"node"===h&&(f=e_(a,d.schema)),"mark"===h&&(g=fa(a,d.schema));let i=!1;return c.selection.ranges.forEach(a=>{let h,j,k,l,m=a.$from.pos,n=a.$to.pos;c.selection.empty?d.doc.nodesBetween(m,n,(a,b)=>{f&&f===a.type&&(i=!0,k=Math.max(b,m),l=Math.min(b+a.nodeSize,n),h=b,j=a)}):d.doc.nodesBetween(m,n,(a,d)=>{d<m&&f&&f===a.type&&(i=!0,k=Math.max(d,m),l=Math.min(d+a.nodeSize,n),h=d,j=a),d>=m&&d<=n&&(f&&f===a.type&&(i=!0,e&&c.setNodeMarkup(d,void 0,{...a.attrs,...b})),g&&a.marks.length&&a.marks.forEach(f=>{if(g===f.type&&(i=!0,e)){let e=Math.max(d,m),h=Math.min(d+a.nodeSize,n);c.addMark(e,h,g.create({...f.attrs,...b}))}}))}),j&&(void 0!==h&&e&&c.setNodeMarkup(h,void 0,{...j.attrs,...b}),g&&j.marks.length&&j.marks.forEach(a=>{g===a.type&&e&&c.addMark(k,l,g.create({...a.attrs,...b}))}))}),i},gG=(a,b={})=>({state:c,dispatch:d})=>(function(a,b=null){return function(c,d){let{$from:e,$to:f}=c.selection,g=e.blockRange(f),h=g&&a2(g,a,b);return!!h&&(d&&d(c.tr.wrap(g,h).scrollIntoView()),!0)}})(e_(a,c.schema),b)(c,d),gH=(a,b={})=>({state:c,dispatch:d})=>(function(a,b=null){return function(c,d){let{$from:e,$to:f}=c.selection,g=e.blockRange(f);if(!g)return!1;let h=d?c.tr:null;return!!function(a,b,c,d=null){let e=!1,f=b,g=b.$from.doc;if(b.depth>=2&&b.$from.node(b.depth-1).type.compatibleContent(c)&&0==b.startIndex){if(0==b.$from.index(b.depth-1))return!1;let a=g.resolve(b.start-2);f=new ah(a,a,b.depth),b.endIndex<b.parent.childCount&&(b=new ah(b.$from,g.resolve(b.$to.end(b.depth)),b.depth)),e=!0}let h=a2(f,c,d,b);return!!h&&(a&&function(a,b,c,d,e){let f=S.empty;for(let a=c.length-1;a>=0;a--)f=S.from(c[a].type.create(c[a].attrs,f));a.step(new a$(b.start-2*!!d,b.end,b.start,b.end,new Y(f,0,0),c.length,!0));let g=0;for(let a=0;a<c.length;a++)c[a].type==e&&(g=a+1);let h=c.length-g,i=b.start+c.length-2*!!d,j=b.parent;for(let c=b.startIndex,d=b.endIndex,e=!0;c<d;c++,e=!1)!e&&a6(a.doc,i,h)&&(a.split(i,h),i+=2*h),i+=j.child(c).nodeSize}(a,b,h,e,c),!0)}(h,g,a,b)&&(d&&d(h.scrollIntoView()),!0)}})(e_(a,c.schema),b)(c,d),gI=class{constructor(){this.callbacks={}}on(a,b){return this.callbacks[a]||(this.callbacks[a]=[]),this.callbacks[a].push(b),this}emit(a,...b){let c=this.callbacks[a];return c&&c.forEach(a=>a.apply(this,b)),this}off(a,b){let c=this.callbacks[a];return c&&(b?this.callbacks[a]=c.filter(a=>a!==b):delete this.callbacks[a]),this}once(a,b){let c=(...d)=>{this.off(a,c),b.apply(this,d)};return this.on(a,c)}removeAllListeners(){this.callbacks={}}},gJ=class{constructor(a){var b;this.find=a.find,this.handler=a.handler,this.undoable=null==(b=a.undoable)||b}};function gK(a){var b;let{editor:c,from:d,to:e,text:f,rules:g,plugin:h}=a,{view:i}=c;if(i.composing)return!1;let j=i.state.doc.resolve(d);if(j.parent.type.spec.code||(null==(b=j.nodeBefore||j.nodeAfter)?void 0:b.marks.find(a=>a.type.spec.code)))return!1;let k=!1,l=((a,b=500)=>{let c="",d=a.parentOffset;return a.parent.nodesBetween(Math.max(0,d-b),d,(a,b,e,f)=>{var g,h;let i=(null==(h=(g=a.type.spec).toText)?void 0:h.call(g,{node:a,pos:b,parent:e,index:f}))||a.textContent||"%leaf%";c+=a.isAtom&&!a.isText?i:i.slice(0,Math.max(0,d-b))}),c})(j)+f;return g.forEach(a=>{if(k)return;let b=((a,b)=>{if(e5(b))return b.exec(a);let c=b(a);if(!c)return null;let d=[c.text];return d.index=c.index,d.input=a,d.data=c.data,c.replaceWith&&(c.text.includes(c.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),d.push(c.replaceWith)),d})(l,a.find);if(!b)return;let g=i.state.tr,j=eR({state:i.state,transaction:g}),m={from:d-(b[0].length-f.length),to:e},{commands:n,chain:o,can:p}=new eS({editor:c,state:j});null!==a.handler({state:j,range:m,match:b,commands:n,chain:o,can:p})&&g.steps.length&&(a.undoable&&g.setMeta(h,{transform:g,from:d,to:e,text:f}),i.dispatch(g),k=!0)}),k}function gL(a){return"Object"===Object.prototype.toString.call(a).slice(8,-1)&&a.constructor===Object&&Object.getPrototypeOf(a)===Object.prototype}var gM=class{constructor(a={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...a},this.name=this.config.name}get options(){return{...fY(fU(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...fY(fU(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(a={}){let b=this.extend({...this.config,addOptions:()=>(function a(b,c){let d={...b};return gL(b)&&gL(c)&&Object.keys(c).forEach(e=>{gL(c[e])&&gL(b[e])?d[e]=a(b[e],c[e]):d[e]=c[e]}),d})(this.options,a)});return b.name=this.name,b.parent=this.parent,b}extend(a={}){let b=new this.constructor({...this.config,...a});return b.parent=this,this.child=b,b.name="name"in a?a.name:b.parent.name,b}},gN=class a extends gM{constructor(){super(...arguments),this.type="mark"}static create(b={}){return new a("function"==typeof b?b():b)}static handleExit({editor:a,mark:b}){let{tr:c}=a.state,d=a.state.selection.$from;if(d.pos===d.end()){let e=d.marks();if(!e.find(a=>(null==a?void 0:a.type.name)===b.name))return!1;let f=e.find(a=>(null==a?void 0:a.type.name)===b.name);return f&&c.removeStoredMark(f),c.insertText(" ",d.pos),a.view.dispatch(c),!0}return!1}configure(a){return super.configure(a)}extend(a){let b="function"==typeof a?a():a;return super.extend(b)}},gO=class{constructor(a){this.find=a.find,this.handler=a.handler}},gP=null,gQ=class{constructor(a,b){this.splittableMarks=[],this.editor=b,this.baseExtensions=a,this.extensions=f5(a),this.schema=function(a,b){var c;let d=f$(a),{nodeExtensions:e,markExtensions:f}=fZ(a),g=null==(c=e.find(a=>fU(a,"topNode")))?void 0:c.name;return new ay({topNode:g,nodes:Object.fromEntries(e.map(c=>{let e=d.filter(a=>a.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:b},g=f2({...a.reduce((a,b)=>{let d=fU(b,"extendNodeSchema",f);return{...a,...d?d(c):{}}},{}),content:fY(fU(c,"content",f)),marks:fY(fU(c,"marks",f)),group:fY(fU(c,"group",f)),inline:fY(fU(c,"inline",f)),atom:fY(fU(c,"atom",f)),selectable:fY(fU(c,"selectable",f)),draggable:fY(fU(c,"draggable",f)),code:fY(fU(c,"code",f)),whitespace:fY(fU(c,"whitespace",f)),linebreakReplacement:fY(fU(c,"linebreakReplacement",f)),defining:fY(fU(c,"defining",f)),isolating:fY(fU(c,"isolating",f)),attrs:Object.fromEntries(e.map(f3))}),h=fY(fU(c,"parseHTML",f));h&&(g.parseDOM=h.map(a=>f1(a,e)));let i=fU(c,"renderHTML",f);i&&(g.toDOM=a=>i({node:a,HTMLAttributes:f0(a,e)}));let j=fU(c,"renderText",f);return j&&(g.toText=j),[c.name,g]})),marks:Object.fromEntries(f.map(c=>{let e=d.filter(a=>a.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:b},g=f2({...a.reduce((a,b)=>{let d=fU(b,"extendMarkSchema",f);return{...a,...d?d(c):{}}},{}),inclusive:fY(fU(c,"inclusive",f)),excludes:fY(fU(c,"excludes",f)),group:fY(fU(c,"group",f)),spanning:fY(fU(c,"spanning",f)),code:fY(fU(c,"code",f)),attrs:Object.fromEntries(e.map(f3))}),h=fY(fU(c,"parseHTML",f));h&&(g.parseDOM=h.map(a=>f1(a,e)));let i=fU(c,"renderHTML",f);return i&&(g.toDOM=a=>i({mark:a,HTMLAttributes:f0(a,e)})),[c.name,g]}))})}(this.extensions,b),this.setupExtensions()}get commands(){return this.extensions.reduce((a,b)=>{let c={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:this.editor,type:gb(b.name,this.schema)},d=fU(b,"addCommands",c);return d?{...a,...d()}:a},{})}get plugins(){let{editor:a}=this;return f4([...this.extensions].reverse()).flatMap(b=>{let c={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:a,type:gb(b.name,this.schema)},d=[],e=fU(b,"addKeyboardShortcuts",c),f={};if("mark"===b.type&&fU(b,"exitable",c)&&(f.ArrowRight=()=>gN.handleExit({editor:a,mark:b})),e){let b=Object.fromEntries(Object.entries(e()).map(([b,c])=>[b,()=>c({editor:a})]));f={...f,...b}}let g=new bG({props:{handleKeyDown:eO(f)}});d.push(g);let h=fU(b,"addInputRules",c);if(ge(b,a.options.enableInputRules)&&h){let b=h();if(b&&b.length){let c=function(a){let{editor:b,rules:c}=a,d=new bG({state:{init:()=>null,apply(a,e,f){let g=a.getMeta(d);if(g)return g;let h=a.getMeta("applyInputRules");return h&&setTimeout(()=>{let{text:a}=h;"string"==typeof a||(a=fW(S.from(a),f.schema));let{from:e}=h,g=e+a.length;gK({editor:b,from:e,to:g,text:a,rules:c,plugin:d})}),a.selectionSet||a.docChanged?null:e}},props:{handleTextInput:(a,e,f,g)=>gK({editor:b,from:e,to:f,text:g,rules:c,plugin:d}),handleDOMEvents:{compositionend:a=>(setTimeout(()=>{let{$cursor:e}=a.state.selection;e&&gK({editor:b,from:e.pos,to:e.pos,text:"",rules:c,plugin:d})}),!1)},handleKeyDown(a,e){if("Enter"!==e.key)return!1;let{$cursor:f}=a.state.selection;return!!f&&gK({editor:b,from:f.pos,to:f.pos,text:"\n",rules:c,plugin:d})}},isInputRules:!0});return d}({editor:a,rules:b}),e=Array.isArray(c)?c:[c];d.push(...e)}}let i=fU(b,"addPasteRules",c);if(ge(b,a.options.enablePasteRules)&&i){let b=i();if(b&&b.length){let c=function(a){let b,{editor:c,rules:d}=a,e=null,f=!1,g=!1,h="u">typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{b="u">typeof DragEvent?new DragEvent("drop"):null}catch{b=null}let i=({state:a,from:d,to:e,rule:f,pasteEvt:g})=>{let i=a.tr;if(function(a){let{editor:b,state:c,from:d,to:e,rule:f,pasteEvent:g,dropEvent:h}=a,{commands:i,chain:j,can:k}=new eS({editor:b,state:c}),l=[];return c.doc.nodesBetween(d,e,(a,b)=>{var m,n,o,p,q;if((null==(n=null==(m=a.type)?void 0:m.spec)?void 0:n.code)||!(a.isText||a.isTextblock||a.isInline))return;let r=null!=(q=null!=(p=null==(o=a.content)?void 0:o.size)?p:a.nodeSize)?q:0,s=Math.max(d,b),t=Math.min(e,b+r);s>=t||((a,b,c)=>{if(e5(b))return[...a.matchAll(b)];let d=b(a,c);return d?d.map(b=>{let c=[b.text];return c.index=b.index,c.input=a,c.data=b.data,b.replaceWith&&(b.text.includes(b.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),c.push(b.replaceWith)),c}):[]})(a.isText?a.text||"":a.textBetween(s-b,t-b,void 0,""),f.find,g).forEach(a=>{if(void 0===a.index)return;let b=s+a.index+1,d=b+a[0].length,e={from:c.tr.mapping.map(b),to:c.tr.mapping.map(d)},m=f.handler({state:c,range:e,match:a,commands:i,chain:j,can:k,pasteEvent:g,dropEvent:h});l.push(m)})}),l.every(a=>null!==a)}({editor:c,state:eR({state:a,transaction:i}),from:Math.max(d-1,0),to:e.b-1,rule:f,pasteEvent:g,dropEvent:b})&&i.steps.length){try{b="u">typeof DragEvent?new DragEvent("drop"):null}catch{b=null}return h="u">typeof ClipboardEvent?new ClipboardEvent("paste"):null,i}};return d.map(a=>new bG({view(a){let b=b=>{var d;(e=(null==(d=a.dom.parentElement)?void 0:d.contains(b.target))?a.dom.parentElement:null)&&(gP=c)},d=()=>{gP&&(gP=null)};return window.addEventListener("dragstart",b),window.addEventListener("dragend",d),{destroy(){window.removeEventListener("dragstart",b),window.removeEventListener("dragend",d)}}},props:{handleDOMEvents:{drop:(a,c)=>{if(g=e===a.dom.parentElement,b=c,!g){let a=gP;(null==a?void 0:a.isEditable)&&setTimeout(()=>{let b=a.state.selection;b&&a.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(a,b)=>{var c;let d=null==(c=b.clipboardData)?void 0:c.getData("text/html");return h=b,f=!!(null==d?void 0:d.includes("data-pm-slice")),!1}}},appendTransaction:(b,c,d)=>{let e=b[0],j="paste"===e.getMeta("uiEvent")&&!f,k="drop"===e.getMeta("uiEvent")&&!g,l=e.getMeta("applyPasteRules"),m=!!l;if(!j&&!k&&!m)return;if(m){var n,o;let b,{text:c}=l;"string"==typeof c||(c=fW(S.from(c),d.schema));let{from:e}=l,f=e+c.length;return i({rule:a,state:d,from:e,to:{b:f},pasteEvt:(n=c,null==(o=(b=new ClipboardEvent("paste",{clipboardData:new DataTransfer})).clipboardData)||o.setData("text/html",n),b)})}let p=c.doc.content.findDiffStart(d.doc.content),q=c.doc.content.findDiffEnd(d.doc.content);if("number"==typeof p&&q&&p!==q.b)return i({rule:a,state:d,from:p,to:q,pasteEvt:h})}}))}({editor:a,rules:b});d.push(...c)}}let j=fU(b,"addProseMirrorPlugins",c);if(j){let a=j();d.push(...a)}return d})}get attributes(){return f$(this.extensions)}get nodeViews(){let{editor:a}=this,{nodeExtensions:b}=fZ(this.extensions);return Object.fromEntries(b.filter(a=>!!fU(a,"addNodeView")).map(b=>{let c=this.attributes.filter(a=>a.type===b.name),d={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:a,type:e_(b.name,this.schema)},e=fU(b,"addNodeView",d);if(!e)return[];let f=e();return f?[b.name,(d,e,g,h,i)=>{let j=f0(d,c);return f({node:d,view:e,getPos:g,decorations:h,innerDecorations:i,editor:a,extension:b,HTMLAttributes:j})}]:[]}))}dispatchTransaction(a){let{editor:b}=this;return f4([...this.extensions].reverse()).reduceRight((a,c)=>{let d={name:c.name,options:c.options,storage:this.editor.extensionStorage[c.name],editor:b,type:gb(c.name,this.schema)},e=fU(c,"dispatchTransaction",d);return e?b=>{e.call(d,{transaction:b,next:a})}:a},a)}transformPastedHTML(a){let{editor:b}=this;return f4([...this.extensions]).reduce((a,c)=>{let d={name:c.name,options:c.options,storage:this.editor.extensionStorage[c.name],editor:b,type:gb(c.name,this.schema)},e=fU(c,"transformPastedHTML",d);return e?(b,c)=>{let f=a(b,c);return e.call(d,f)}:a},a||(a=>a))}get markViews(){let{editor:a}=this,{markExtensions:b}=fZ(this.extensions);return Object.fromEntries(b.filter(a=>!!fU(a,"addMarkView")).map(b=>{let c=this.attributes.filter(a=>a.type===b.name),d={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:a,type:fa(b.name,this.schema)},e=fU(b,"addMarkView",d);return e?[b.name,(d,f,g)=>{let h=f0(d,c);return e()({mark:d,view:f,inline:g,editor:a,extension:b,HTMLAttributes:h,updateAttributes:b=>{!function(a,b,c={}){let{state:d}=b,{doc:e,tr:f}=d;e.descendants((b,d)=>{let e=f.mapping.map(d),g=f.mapping.map(d)+b.nodeSize,h=null;if(b.marks.forEach(b=>{if(b!==a)return!1;h=b}),!h)return;let i=!1;if(Object.keys(c).forEach(a=>{c[a]!==h.attrs[a]&&(i=!0)}),i){let b=a.type.create({...a.attrs,...c});f.removeMark(e,g,a.type),f.addMark(e,g,b)}}),f.docChanged&&b.view.dispatch(f)}(d,a,b)}})}]:[]}))}setupExtensions(){let a=this.extensions;this.editor.extensionStorage=Object.fromEntries(a.map(a=>[a.name,a.storage])),a.forEach(a=>{var b;let c={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:this.editor,type:gb(a.name,this.schema)};"mark"===a.type&&(null==(b=fY(fU(a,"keepOnSplit",c)))||b)&&this.splittableMarks.push(a.name);let d=fU(a,"onBeforeCreate",c),e=fU(a,"onCreate",c),f=fU(a,"onUpdate",c),g=fU(a,"onSelectionUpdate",c),h=fU(a,"onTransaction",c),i=fU(a,"onFocus",c),j=fU(a,"onBlur",c),k=fU(a,"onDestroy",c);d&&this.editor.on("beforeCreate",d),e&&this.editor.on("create",e),f&&this.editor.on("update",f),g&&this.editor.on("selectionUpdate",g),h&&this.editor.on("transaction",h),i&&this.editor.on("focus",i),j&&this.editor.on("blur",j),k&&this.editor.on("destroy",k)})}};gQ.resolve=f5,gQ.sort=f4,gQ.flatten=fV;var gR={};eQ(gR,{ClipboardTextSerializer:()=>gT,Commands:()=>gU,Delete:()=>gV,Drop:()=>gW,Editable:()=>gX,FocusEvents:()=>gZ,Keymap:()=>g$,Paste:()=>g_,Tabindex:()=>g0,TextDirection:()=>g1,focusEventsPluginKey:()=>gY});var gS=class a extends gM{constructor(){super(...arguments),this.type="extension"}static create(b={}){return new a("function"==typeof b?b():b)}configure(a){return super.configure(a)}extend(a){let b="function"==typeof a?a():a;return super.extend(b)}},gT=gS.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new bG({key:new bJ("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:a}=this,{state:b,schema:c}=a,{doc:d,selection:e}=b,{ranges:f}=e,g=Math.min(...f.map(a=>a.$from.pos)),h=Math.max(...f.map(a=>a.$to.pos)),i=f7(c);return f6(d,{from:g,to:h},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:i})}}})]}}),gU=gS.create({name:"commands",addCommands:()=>({...eT})}),gV=gS.create({name:"delete",onUpdate({transaction:a,appendedTransactions:b}){var c,d,e;let f=()=>{var c,d,e,f;if(null!=(f=null==(e=null==(d=null==(c=this.editor.options.coreExtensionOptions)?void 0:c.delete)?void 0:d.filterTransaction)?void 0:e.call(d,a))?f:a.getMeta("y-sync$"))return;let g=fR(a.before,[a,...b]);f9(g).forEach(b=>{g.mapping.mapResult(b.oldRange.from).deletedAfter&&g.mapping.mapResult(b.oldRange.to).deletedBefore&&g.before.nodesBetween(b.oldRange.from,b.oldRange.to,(c,d)=>{let e=d+c.nodeSize-2,f=b.oldRange.from<=d&&e<=b.oldRange.to;this.editor.emit("delete",{type:"node",node:c,from:d,to:e,newFrom:g.mapping.map(d),newTo:g.mapping.map(e),deletedRange:b.oldRange,newRange:b.newRange,partial:!f,editor:this.editor,transaction:a,combinedTransform:g})})});let h=g.mapping;g.steps.forEach((b,c)=>{var d,e;if(b instanceof aW){let f=h.slice(c).map(b.from,-1),i=h.slice(c).map(b.to),j=h.invert().map(f,-1),k=h.invert().map(i),l=null==(d=g.doc.nodeAt(f-1))?void 0:d.marks.some(a=>a.eq(b.mark)),m=null==(e=g.doc.nodeAt(i))?void 0:e.marks.some(a=>a.eq(b.mark));this.editor.emit("delete",{type:"mark",mark:b.mark,from:b.from,to:b.to,deletedRange:{from:j,to:k},newRange:{from:f,to:i},partial:!!(m||l),editor:this.editor,transaction:a,combinedTransform:g})}})};null==(e=null==(d=null==(c=this.editor.options.coreExtensionOptions)?void 0:c.delete)?void 0:d.async)||e?setTimeout(f,0):f()}}),gW=gS.create({name:"drop",addProseMirrorPlugins(){return[new bG({key:new bJ("tiptapDrop"),props:{handleDrop:(a,b,c,d)=>{this.editor.emit("drop",{editor:this.editor,event:b,slice:c,moved:d})}}})]}}),gX=gS.create({name:"editable",addProseMirrorPlugins(){return[new bG({key:new bJ("editable"),props:{editable:()=>this.editor.options.editable}})]}}),gY=new bJ("focusEvents"),gZ=gS.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:a}=this;return[new bG({key:gY,props:{handleDOMEvents:{focus:(b,c)=>{a.isFocused=!0;let d=a.state.tr.setMeta("focus",{event:c}).setMeta("addToHistory",!1);return b.dispatch(d),!1},blur:(b,c)=>{a.isFocused=!1;let d=a.state.tr.setMeta("blur",{event:c}).setMeta("addToHistory",!1);return b.dispatch(d),!1}}}})]}}),g$=gS.create({name:"keymap",addKeyboardShortcuts(){let a=()=>this.editor.commands.first(({commands:a})=>[()=>a.undoInputRule(),()=>a.command(({tr:b})=>{let{selection:c,doc:d}=b,{empty:e,$anchor:f}=c,{pos:g,parent:h}=f,i=f.parent.isTextblock&&g>0?b.doc.resolve(g-1):f,j=i.parent.type.spec.isolating,k=f.pos-f.parentOffset,l=j&&1===i.parent.childCount?k===f.pos:bo.atStart(d).from===g;return!!e&&!!h.type.isTextblock&&!h.textContent.length&&!!l&&(!l||"paragraph"!==f.parent.type.name)&&a.clearNodes()}),()=>a.deleteSelection(),()=>a.joinBackward(),()=>a.selectNodeBackward()]),b=()=>this.editor.commands.first(({commands:a})=>[()=>a.deleteSelection(),()=>a.deleteCurrentNode(),()=>a.joinForward(),()=>a.selectNodeForward()]),c={Enter:()=>this.editor.commands.first(({commands:a})=>[()=>a.newlineInCode(),()=>a.createParagraphNear(),()=>a.liftEmptyBlock(),()=>a.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:a,"Mod-Backspace":a,"Shift-Backspace":a,Delete:b,"Mod-Delete":b,"Mod-a":()=>this.editor.commands.selectAll()},d={...c},e={...c,"Ctrl-h":a,"Alt-Backspace":a,"Ctrl-d":b,"Ctrl-Alt-Backspace":b,"Alt-Delete":b,"Alt-d":b,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return fh()||fx()?e:d},addProseMirrorPlugins(){return[new bG({key:new bJ("clearDocument"),appendTransaction:(a,b,c)=>{if(a.some(a=>a.getMeta("composition")))return;let d=a.some(a=>a.docChanged)&&!b.doc.eq(c.doc),e=a.some(a=>a.getMeta("preventClearDocument"));if(!d||e)return;let{empty:f,from:g,to:h}=b.selection,i=bo.atStart(b.doc).from,j=bo.atEnd(b.doc).to;if(f||g!==i||h!==j||!gg(c.doc))return;let k=c.tr,l=eR({state:c,transaction:k}),{commands:m}=new eS({editor:this.editor,state:l});if(m.clearNodes(),k.steps.length)return k}})]}}),g_=gS.create({name:"paste",addProseMirrorPlugins(){return[new bG({key:new bJ("tiptapPaste"),props:{handlePaste:(a,b,c)=>{this.editor.emit("paste",{editor:this.editor,event:b,slice:c})}}})]}}),g0=gS.create({name:"tabindex",addProseMirrorPlugins(){return[new bG({key:new bJ("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),g1=gS.create({name:"textDirection",addOptions:()=>({direction:void 0}),addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:a}=fZ(this.extensions);return[{types:a.filter(a=>"text"!==a.name).map(a=>a.name),attributes:{dir:{default:this.options.direction,parseHTML:a=>{let b=a.getAttribute("dir");return b&&("ltr"===b||"rtl"===b||"auto"===b)?b:this.options.direction},renderHTML:a=>a.dir?{dir:a.dir}:{}}}}]},addProseMirrorPlugins(){return[new bG({key:new bJ("textDirection"),props:{attributes:()=>{let a=this.options.direction;return a?{dir:a}:{}}}})]}}),g2=class a{constructor(a,b,c=!1,d=null){this.currentNode=null,this.actualDepth=null,this.isBlock=c,this.resolvedPos=a,this.editor=b,this.currentNode=d}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 a;return null!=(a=this.actualDepth)?a:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(a){let b=this.from,c=this.to;if(this.isBlock){if(0===this.content.size)return void console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);b=this.from+1,c=this.to-1}this.editor.commands.insertContentAt({from:b,to:c},a)}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}get parent(){if(0===this.depth)return null;let b=this.resolvedPos.start(this.resolvedPos.depth-1);return new a(this.resolvedPos.doc.resolve(b),this.editor)}get before(){let b=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return b.depth!==this.depth&&(b=this.resolvedPos.doc.resolve(this.from-3)),new a(b,this.editor)}get after(){let b=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return b.depth!==this.depth&&(b=this.resolvedPos.doc.resolve(this.to+3)),new a(b,this.editor)}get children(){let b=[];return this.node.content.forEach((c,d)=>{let e=c.isBlock&&!c.isTextblock,f=c.isAtom&&!c.isText,g=c.isInline,h=this.pos+d+ +!f;if(h<0||h>this.resolvedPos.doc.nodeSize-2)return;let i=this.resolvedPos.doc.resolve(h);if(!e&&!g&&i.depth<=this.depth)return;let j=new a(i,this.editor,e,e||g?c:null);e&&(j.actualDepth=this.depth+1),b.push(j)}),b}get firstChild(){return this.children[0]||null}get lastChild(){let a=this.children;return a[a.length-1]||null}closest(a,b={}){let c=null,d=this.parent;for(;d&&!c;){if(d.node.type.name===a)if(Object.keys(b).length>0){let a=d.node.attrs,c=Object.keys(b);for(let d=0;d<c.length;d+=1){let e=c[d];if(a[e]!==b[e])break}}else c=d;d=d.parent}return c}querySelector(a,b={}){return this.querySelectorAll(a,b,!0)[0]||null}querySelectorAll(a,b={},c=!1){let d=[];if(!this.children||0===this.children.length)return d;let e=Object.keys(b);return this.children.forEach(f=>{c&&d.length>0||(f.node.type.name===a&&e.every(a=>b[a]===f.node.attrs[a])&&d.push(f),c&&d.length>0||(d=d.concat(f.querySelectorAll(a,b,c))))}),d}setAttribute(a){let{tr:b}=this.editor.state;b.setNodeMarkup(this.from,void 0,{...this.node.attrs,...a}),this.editor.view.dispatch(b)}},g3=`.ProseMirror {
|
|
2
|
+
see more here https://nextjs.org/docs/messages/app-static-to-dynamic-error`),"__NEXT_ERROR_CODE",{value:"E132",enumerable:!1,configurable:!0});if(null==a?void 0:a.stack){let c=a.stack;b.stack=b.message+c.substring(c.indexOf("\n"))}throw b}return{value:{kind:u.CachedRouteKind.APP_PAGE,html:n,headers:q,rscData:o.flightData,postponed:o.postponed,status:o.statusCode,segmentData:o.segmentData},cacheControl:p}},p=async({hasResolved:c,previousCacheEntry:f,isRevalidating:g,span:i,forceStaticRender:j=!1})=>{let k,l=!1===L.isDev,q=c||b.writableEnded;if(ai&&ab&&!f&&!N)return(null==ac?void 0:ac.render404)?await ac.render404(a,b):(b.statusCode=404,b.end("This page could not be found")),null;if(aj&&(k=(0,v.parseFallbackField)(aj.fallback)),k===v.FallbackMode.PRERENDER&&(0,t.isBot)(al)&&(!as||an)&&(k=v.FallbackMode.BLOCKING_STATIC_RENDER),(null==f?void 0:f.isStale)===-1&&(ai=!0),ai&&(k!==v.FallbackMode.NOT_FOUND||f)&&(k=v.FallbackMode.BLOCKING_STATIC_RENDER),!N&&k!==v.FallbackMode.BLOCKING_STATIC_RENDER&&aE&&!q&&!_&&T&&(l||!ak)){if((l||aj)&&k===v.FallbackMode.NOT_FOUND){if(ad.experimental.adapterPath)return await aJ();throw new A.NoFallbackError}if(as&&(ad.cacheComponents?!aw:!ap)){let b=l&&"string"==typeof(null==aj?void 0:aj.fallback)?aj.fallback:ah,c=l&&(null==aj?void 0:aj.fallbackRouteParams)?(0,n.createOpaqueFallbackRouteParams)(aj.fallbackRouteParams):au?(0,n.getFallbackRouteParams)(ah,L):null,f=await L.handleResponse({cacheKey:b,req:a,nextConfig:ad,routeKind:e.RouteKind.APP_PAGE,isFallback:!0,prerenderManifest:$,isRoutePPREnabled:as,responseGenerator:async()=>o({span:i,postponed:void 0,fallbackRouteParams:c,forceStaticRender:!1}),waitUntil:d.waitUntil,isMinimalMode:N});if(null===f)return null;if(f)return delete f.cacheControl,f}}let r=ai||g||!av?void 0:av;if(aA&&!N&&m&&aw&&!j){let b=await m.get(aa,{kind:u.IncrementalCacheKind.APP_PAGE,isRoutePPREnabled:!0,isFallback:!1});b&&b.value&&b.value.kind===u.CachedRouteKind.APP_PAGE&&(r=b.value.postponed,b&&(-1===b.isStale||!0===b.isStale)&&(0,G.scheduleOnNextTick)(async()=>{let b=L.getResponseCache(a);try{await b.revalidate(aa,m,as,!1,a=>p({...a,forceStaticRender:!0}),null,c,d.waitUntil)}catch(a){console.error("Error revalidating the page in the background",a)}}))}if(at&&void 0!==r)return{cacheControl:{revalidate:1,expire:void 0},value:{kind:u.CachedRouteKind.PAGES,html:w.default.EMPTY,pageData:{},headers:void 0,status:void 0}};let s=l&&(null==aj?void 0:aj.fallbackRouteParams)&&(0,h.getRequestMeta)(a,"renderFallbackShell")?(0,n.createOpaqueFallbackRouteParams)(aj.fallbackRouteParams):au?(0,n.getFallbackRouteParams)(ah,L):null;return o({span:i,postponed:r,fallbackRouteParams:s,forceStaticRender:j})},q=async c=>{var f,g,i,j,k;let l,m=await L.handleResponse({cacheKey:aD,responseGenerator:a=>p({span:c,...a}),routeKind:e.RouteKind.APP_PAGE,isOnDemandRevalidate:ai,isRoutePPREnabled:as,req:a,nextConfig:ad,prerenderManifest:$,waitUntil:d.waitUntil,isMinimalMode:N});if(_&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate"),L.isDev&&b.setHeader("Cache-Control","no-store, must-revalidate"),!m){if(aD)throw Object.defineProperty(Error("invariant: cache entry required but not generated"),"__NEXT_ERROR_CODE",{value:"E62",enumerable:!1,configurable:!0});return null}if((null==(f=m.value)?void 0:f.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant app-page handler received invalid cache entry ${null==(i=m.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E707",enumerable:!1,configurable:!0});let n="string"==typeof m.value.postponed;az&&!aw&&(!n||ao)&&(N||b.setHeader("x-nextjs-cache",ai?"REVALIDATED":m.isMiss?"MISS":m.isStale?"STALE":"HIT"),b.setHeader(s.NEXT_IS_PRERENDER_HEADER,"1"));let{value:q}=m;if(av)l={revalidate:0,expire:void 0};else if(aw)l={revalidate:0,expire:void 0};else if(!L.isDev)if(_)l={revalidate:0,expire:void 0};else if(az){if(m.cacheControl)if("number"==typeof m.cacheControl.revalidate){if(m.cacheControl.revalidate<1)throw Object.defineProperty(Error(`Invalid revalidate configuration provided: ${m.cacheControl.revalidate} < 1`),"__NEXT_ERROR_CODE",{value:"E22",enumerable:!1,configurable:!0});l={revalidate:m.cacheControl.revalidate,expire:(null==(j=m.cacheControl)?void 0:j.expire)??ad.expireTime}}else l={revalidate:x.CACHE_ONE_YEAR,expire:void 0}}else b.getHeader("Cache-Control")||(l={revalidate:0,expire:void 0});if(m.cacheControl=l,"string"==typeof ax&&(null==q?void 0:q.kind)===u.CachedRouteKind.APP_PAGE&&q.segmentData){b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"2");let c=null==(k=q.headers)?void 0:k[x.NEXT_CACHE_TAGS_HEADER];N&&az&&c&&"string"==typeof c&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,c);let d=q.segmentData.get(ax);return void 0!==d?(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:w.default.fromStatic(d,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl}):(b.statusCode=204,(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl}))}let r=aA?(0,h.getRequestMeta)(a,"onCacheEntryV2")??(0,h.getRequestMeta)(a,"onCacheEntry"):(0,h.getRequestMeta)(a,"onCacheEntry");if(r&&await r(m,{url:(0,h.getRequestMeta)(a,"initURL")??a.url}))return null;if(q.headers){let a={...q.headers};for(let[c,d]of(N&&az||delete a[x.NEXT_CACHE_TAGS_HEADER],Object.entries(a)))if(void 0!==d)if(Array.isArray(d))for(let a of d)b.appendHeader(c,a);else"number"==typeof d&&(d=d.toString()),b.appendHeader(c,d)}let t=null==(g=q.headers)?void 0:g[x.NEXT_CACHE_TAGS_HEADER];if(N&&az&&t&&"string"==typeof t&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,t),!q.status||ap&&as||(b.statusCode=q.status),!N&&q.status&&E.RedirectStatusCode[q.status]&&ap&&(b.statusCode=200),n&&!aw&&b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"1"),ap&&!_){if(void 0===q.rscData){if(q.html.contentType!==s.RSC_CONTENT_TYPE_HEADER)if(ad.cacheComponents)return b.statusCode=404,(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl});else throw Object.defineProperty(new F.InvariantError(`Expected RSC response, got ${q.html.contentType}`),"__NEXT_ERROR_CODE",{value:"E789",enumerable:!1,configurable:!0});return(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:q.html,cacheControl:m.cacheControl})}return(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:w.default.fromStatic(q.rscData,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl})}let v=q.html;if(!n||N||ap)return(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:v,cacheControl:m.cacheControl});if(at)return v.push(new ReadableStream({start(a){a.enqueue(y.ENCODED_TAGS.CLOSED.BODY_AND_HTML),a.close()}})),(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}});let A=new TransformStream;return v.push(A.readable),o({span:c,postponed:q.postponed,fallbackRouteParams:null,forceStaticRender:!1}).then(async a=>{var b,c;if(!a)throw Object.defineProperty(Error("Invariant: expected a result to be returned"),"__NEXT_ERROR_CODE",{value:"E463",enumerable:!1,configurable:!0});if((null==(b=a.value)?void 0:b.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant: expected a page response, got ${null==(c=a.value)?void 0:c.kind}`),"__NEXT_ERROR_CODE",{value:"E305",enumerable:!1,configurable:!0});await a.value.html.pipeTo(A.writable)}).catch(a=>{A.writable.abort(a).catch(a=>{console.error("couldn't abort transformer",a)})}),(0,z.sendRenderResult)({req:a,res:b,generateEtags:ad.generateEtags,poweredByHeader:ad.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}})};if(!aI)return await aH.withPropagatedContext(a.headers,()=>aH.trace(i.BaseServerSpan.handleRequest,{spanName:`${aG} ${O}`,kind:g.SpanKind.SERVER,attributes:{"http.method":aG,"http.target":a.url}},q));await q(aI)}catch(b){throw b instanceof A.NoFallbackError||await L.onRequestError(a,b,{routerKind:"App Router",routePath:O,routeType:"render",revalidateReason:(0,f.c)({isStaticGeneration:az,isOnDemandRevalidate:ai})},!1,ac),b}}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},70722:a=>{"use strict";a.exports=require("next/dist/shared/lib/invariant-error")},77068:a=>{"use strict";a.exports=require("next/dist/shared/lib/size-limit")},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},89010:(a,b,c)=>{"use strict";let d,e;c.d(b,{Workspace:()=>oV});var f,g,h,i,j,k,l,m,n,o,p,q,r,s={};c.r(s),c.d(s,{decode:()=>lU,encode:()=>lX,format:()=>lY,parse:()=>l7});var t={};c.r(t),c.d(t,{Any:()=>ma,Cc:()=>mb,Cf:()=>mc,P:()=>l8,S:()=>l9,Z:()=>md});var u={};c.r(u),c.d(u,{arrayReplaceAt:()=>mt,assign:()=>ms,escapeHtml:()=>mF,escapeRE:()=>mH,fromCodePoint:()=>mv,has:()=>mr,isMdAsciiPunct:()=>mL,isPunctChar:()=>mK,isSpace:()=>mI,isString:()=>mp,isValidEntityCode:()=>mu,isWhiteSpace:()=>mJ,lib:()=>mN,normalizeReference:()=>mM,unescapeAll:()=>mA,unescapeMd:()=>mz});var v={};c.r(v),c.d(v,{parseLinkDestination:()=>mP,parseLinkLabel:()=>mO,parseLinkTitle:()=>mQ});var w=c(48249),x=c(67484),y=c(44384),z=c(14024),A=c(1482),B=c(64874),C=c(60306);let D={"claude-opus-4-6":{label:"Opus 4.6",input:5,output:25,cacheRead:.5,cacheWrite:6.25,color:"#f97316"},"claude-opus-4-5-20251101":{label:"Opus 4.5",input:5,output:25,cacheRead:.5,cacheWrite:6.25,color:"#fb923c"},"claude-sonnet-4-6":{label:"Sonnet 4.6",input:3,output:15,cacheRead:.3,cacheWrite:3.75,color:"#3b82f6"},"claude-sonnet-4-5-20250929":{label:"Sonnet 4.5",input:3,output:15,cacheRead:.3,cacheWrite:3.75,color:"#60a5fa"},"claude-haiku-4-5-20251001":{label:"Haiku 4.5",input:1,output:5,cacheRead:.1,cacheWrite:1.25,color:"#22c55e"}},E={label:"",input:3,output:15,cacheRead:.3,cacheWrite:3.75,color:"#94a3b8"};function F(a){if(D[a])return D[a];let b=a.toLowerCase();return b.includes("opus")?{...E,input:5,output:25,cacheRead:.5,cacheWrite:6.25,color:"#f97316"}:b.includes("haiku")?{...E,input:1,output:5,cacheRead:.1,cacheWrite:1.25,color:"#22c55e"}:E}function G(a){let b=D[a];return b?b.label:a.replace(/^claude-/,"").replace(/-\d{8}$/,"").replace(/-/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function H(a){return(D[a]??F(a)).color}function I(a){return a>=1e9?`${(a/1e9).toFixed(1)}B`:a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:String(a)}function J(a){return a>=1e3?`$${a.toFixed(0)}`:a>=100?`$${a.toFixed(1)}`:`$${a.toFixed(2)}`}function K({data:a,height:b=200,formatValue:c=I}){let d=(0,x.useRef)(null),e=(0,x.useRef)(null),[f,g]=(0,x.useState)(null),h=(0,x.useRef)([]);(0,x.useCallback)(()=>{let f=d.current,g=e.current;if(!f||!g)return;let i=window.devicePixelRatio||1,j=g.getBoundingClientRect().width;f.width=j*i,f.height=b*i,f.style.width=`${j}px`,f.style.height=`${b}px`;let k=f.getContext("2d");k.scale(i,i),k.clearRect(0,0,j,b);let{labels:l,datasets:m}=a;if(0===l.length)return;let n=j-50-12,o=b-8-28,p=function(a){if(a<=0)return 1;let b=Math.pow(10,Math.floor(Math.log10(a))),c=a/b;return c<=1?b:c<=2?2*b:c<=5?5*b:10*b}(Math.max(1,...l.map((a,b)=>m.reduce((a,c)=>a+c.data[b],0))));k.fillStyle=getComputedStyle(f).getPropertyValue("color")||"#888",k.font="10px ui-monospace, monospace",k.textAlign="right",k.textBaseline="middle";for(let a=0;a<=4;a++){var q;let b=p/4*a,d=8+o-b/p*o;k.fillText(c(b),44,d),k.strokeStyle=(q="--border",getComputedStyle(f).getPropertyValue(q).trim()||"#333"),k.lineWidth=.5,k.beginPath(),k.moveTo(50,d),k.lineTo(50+n,d),k.stroke()}let r=n/l.length,s=Math.max(4,Math.min(.6*r,32)),t=[];l.forEach((a,b)=>{let c=50+b*r+(r-s)/2,d=0;m.forEach(e=>{var f,g,h,i,j,l;let m=e.data[b];if(m<=0)return;let n=m/p*o,q=8+o-d-n;k.fillStyle=e.color,f=k,g=c,h=q,i=s,l=2,(j=n)<1||(l=Math.min(l,j/2,i/2),f.beginPath(),f.moveTo(g+l,h),f.lineTo(g+i-l,h),f.quadraticCurveTo(g+i,h,g+i,h+l),f.lineTo(g+i,h+j-l),f.quadraticCurveTo(g+i,h+j,g+i-l,h+j),f.lineTo(g+l,h+j),f.quadraticCurveTo(g,h+j,g,h+j-l),f.lineTo(g,h+l),f.quadraticCurveTo(g,h,g+l,h),f.fill()),t.push({x:c,y:q,w:s,h:n,label:a,value:m,dataset:e.label,color:e.color}),d+=n}),k.fillStyle=getComputedStyle(f).getPropertyValue("color")||"#888",k.font="9px ui-monospace, monospace",k.textAlign="center",k.textBaseline="top",b%(l.length>20?Math.ceil(l.length/15):1)==0&&k.fillText(a,c+s/2,8+o+6)}),h.current=t},[a,b,c]);let i=(0,x.useCallback)(a=>{let b=d.current?.getBoundingClientRect();if(!b)return;let e=a.clientX-b.left,f=a.clientY-b.top,i=h.current.find(a=>e>=a.x&&e<=a.x+a.w&&f>=a.y&&f<=a.y+a.h);i?g({x:a.clientX-b.left,y:i.y-4,content:`${i.dataset}: ${c(i.value)}`}):g(null)},[c]);return(0,w.jsxs)("div",{ref:e,className:"relative w-full text-muted-foreground",children:[(0,w.jsx)("canvas",{ref:d,className:"w-full",style:{height:b},onMouseMove:i,onMouseLeave:()=>g(null)}),f&&(0,w.jsx)("div",{className:"absolute pointer-events-none bg-popover text-popover-foreground text-[10px] px-2 py-1 rounded shadow-lg border border-border whitespace-nowrap z-10",style:{left:f.x,top:f.y,transform:"translate(-50%, -100%)"},children:f.content})]})}function L({hourCounts:a}){let{t:b}=(0,y.Bd)(),c=Math.max(1,...Object.values(a)),d=Array.from({length:24},(a,b)=>b);return(0,w.jsxs)("div",{children:[(0,w.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:b("tokenStats.activeHours")}),(0,w.jsx)("div",{className:"flex gap-[2px] items-end h-16",children:d.map(d=>{let e=a[String(d)]||0,f=e/c;return(0,w.jsxs)("div",{className:"flex-1 flex flex-col items-center gap-0.5",title:b("tokenStats.hourSessions",{h:d,count:e}),children:[(0,w.jsx)("div",{className:"w-full rounded-sm transition-all",style:{height:`${Math.max(2,48*f)}px`,backgroundColor:f>0?`rgba(59, 130, 246, ${.2+.8*f})`:"var(--muted)"}}),d%3==0&&(0,w.jsx)("span",{className:"text-[8px] text-muted-foreground",children:d})]},d)})})]})}function M({isOpen:a,onClose:b}){var c;let d,e,{t:f}=(0,y.Bd)(),[g,h]=(0,x.useState)(null),[i,j]=(0,x.useState)(!0),[k,l]=(0,x.useState)("day"),[m,n]=(0,x.useState)("tokens"),[o,p]=(0,x.useState)("claude"),q=(0,x.useMemo)(()=>g?.modelUsage?Object.entries(g.modelUsage).filter(([a])=>!a.startsWith("<")).map(([a,b])=>{let c;return{id:a,label:G(a),color:H(a),usage:b,cost:(c=F(a),b.inputTokens/1e6*c.input+b.outputTokens/1e6*c.output+b.cacheReadInputTokens/1e6*c.cacheRead+b.cacheCreationInputTokens/1e6*c.cacheWrite),totalTokens:b.inputTokens+b.outputTokens+b.cacheReadInputTokens+b.cacheCreationInputTokens}}).sort((a,b)=>b.cost-a.cost):[],[g]),r=(0,x.useMemo)(()=>q.reduce((a,b)=>a+b.cost,0),[q]),s=(0,x.useMemo)(()=>q.map(a=>a.id),[q]),t=(0,x.useMemo)(()=>{let a={};for(let b of q)a[b.id]=b.totalTokens>0?b.cost/b.totalTokens:0;return a},[q]),{activityChart:u,tokenChart:v,costChart:z}=(0,x.useMemo)(()=>{let a=g?.dailyActivity||[],b=g?.dailyModelTokens||[];if("day"===k){let c=a.slice(-60),d=b.slice(-60),e={labels:c.map(a=>a.date.slice(5)),datasets:[{label:f("tokenStats.messages"),data:c.map(a=>a.messageCount),color:"#3b82f6"},{label:f("tokenStats.toolCalls"),data:c.map(a=>a.toolCallCount),color:"#22c55e"}]},g=d.map(a=>a.date.slice(5));return{activityChart:e,tokenChart:{labels:g,datasets:s.map(a=>({label:G(a),data:d.map(b=>b.tokensByModel[a]||0),color:H(a)}))},costChart:{labels:g,datasets:s.map(a=>({label:G(a),data:d.map(b=>(b.tokensByModel[a]||0)*(t[a]||0)),color:H(a)}))}}}if("week"===k){let c=function(a,b){let c=new Map;for(let b of a){let a=new Date(b.date),d=new Date(a);d.setDate(a.getDate()-a.getDay());let e=d.toISOString().slice(0,10),f=e.slice(5);c.has(e)||c.set(e,{label:f,messages:0,sessions:0,tools:0,tokensByModel:{}});let g=c.get(e);g.messages+=b.messageCount,g.sessions+=b.sessionCount,g.tools+=b.toolCallCount}for(let a of b){let b=new Date(a.date),d=new Date(b);d.setDate(b.getDate()-b.getDay());let e=d.toISOString().slice(0,10);c.has(e)||c.set(e,{label:e.slice(5),messages:0,sessions:0,tools:0,tokensByModel:{}});let f=c.get(e);for(let[b,c]of Object.entries(a.tokensByModel))f.tokensByModel[b]=(f.tokensByModel[b]||0)+c}return Array.from(c.values()).sort((a,b)=>a.label.localeCompare(b.label))}(a,b),d=c.map(a=>a.label),e={labels:d,datasets:[{label:f("tokenStats.messages"),data:c.map(a=>a.messages),color:"#3b82f6"},{label:f("tokenStats.toolCalls"),data:c.map(a=>a.tools),color:"#22c55e"}]};return{activityChart:e,tokenChart:{labels:d,datasets:s.map(a=>({label:G(a),data:c.map(b=>b.tokensByModel[a]||0),color:H(a)}))},costChart:{labels:d,datasets:s.map(a=>({label:G(a),data:c.map(b=>(b.tokensByModel[a]||0)*(t[a]||0)),color:H(a)}))}}}let c=function(a,b){let c=new Map;for(let b of a){let a=b.date.slice(0,7);c.has(a)||c.set(a,{label:a,messages:0,sessions:0,tools:0,tokensByModel:{}});let d=c.get(a);d.messages+=b.messageCount,d.sessions+=b.sessionCount,d.tools+=b.toolCallCount}for(let a of b){let b=a.date.slice(0,7);c.has(b)||c.set(b,{label:b,messages:0,sessions:0,tools:0,tokensByModel:{}});let d=c.get(b);for(let[b,c]of Object.entries(a.tokensByModel))d.tokensByModel[b]=(d.tokensByModel[b]||0)+c}return Array.from(c.values()).sort((a,b)=>a.label.localeCompare(b.label))}(a,b),d=c.map(a=>a.label),e={labels:d,datasets:[{label:f("tokenStats.messages"),data:c.map(a=>a.messages),color:"#3b82f6"},{label:f("tokenStats.toolCalls"),data:c.map(a=>a.tools),color:"#22c55e"}]};return{activityChart:e,tokenChart:{labels:d,datasets:s.map(a=>({label:G(a),data:c.map(b=>b.tokensByModel[a]||0),color:H(a)}))},costChart:{labels:d,datasets:s.map(a=>({label:G(a),data:c.map(b=>(b.tokensByModel[a]||0)*(t[a]||0)),color:H(a)}))}}},[g,k,s,t,f]);if(!a)return null;let A=[{key:"day",label:f("tokenStats.day")},{key:"week",label:f("tokenStats.week")},{key:"month",label:f("tokenStats.month")}];return(0,w.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,w.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:b}),(0,w.jsxs)("div",{className:"relative bg-card rounded-xl shadow-xl w-full max-w-4xl mx-4 max-h-[90vh] flex flex-col overflow-hidden",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between px-6 py-3 border-b border-border flex-shrink-0",children:[(0,w.jsxs)("div",{className:"flex items-center gap-3",children:[(0,w.jsx)("h2",{className:"text-sm font-medium text-foreground",children:f("tokenStats.title")}),(0,w.jsx)("div",{className:"flex bg-muted rounded-md p-0.5",children:["claude","claude2"].map(a=>(0,w.jsx)("button",{className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${o===a?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>{h(null),p(a)},children:"claude"===a?"Claude":"Claude 2"},a))}),(0,w.jsx)("div",{className:"flex bg-muted rounded-md p-0.5",children:A.map(a=>(0,w.jsx)("button",{className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${k===a.key?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>l(a.key),children:a.label},a.key))})]}),(0,w.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,w.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,w.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,w.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-6",children:i?(0,w.jsx)("div",{className:"text-center text-muted-foreground py-12",children:f("common.loading")}):g?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)("div",{className:"grid grid-cols-5 gap-3",children:[(0,w.jsx)(N,{label:f("tokenStats.totalSessions"),value:String(g.totalSessions??0)}),(0,w.jsx)(N,{label:f("tokenStats.totalMessages"),value:I(g.totalMessages??0)}),(0,w.jsx)(N,{label:f("tokenStats.equivalentApiCost"),value:J(r),highlight:!0}),(0,w.jsx)(N,{label:f("tokenStats.longestSession"),value:g.longestSession?(d=Math.floor((c=g.longestSession.duration)/36e5),e=Math.floor(c%36e5/6e4),d>0?`${d}h ${e}m`:`${e}m`):"-"}),(0,w.jsx)(N,{label:f("tokenStats.firstUse"),value:g.firstSessionDate?g.firstSessionDate.slice(0,10):"-"})]}),(0,w.jsxs)("div",{children:[(0,w.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,w.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:f("tokenStats.activityTrend")}),(0,w.jsxs)("div",{className:"flex items-center gap-3 text-[10px]",children:[(0,w.jsxs)("span",{className:"flex items-center gap-1",children:[(0,w.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{backgroundColor:"#3b82f6"}}),f("tokenStats.messages")]}),(0,w.jsxs)("span",{className:"flex items-center gap-1",children:[(0,w.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{backgroundColor:"#22c55e"}}),f("tokenStats.toolCalls")]})]})]}),(0,w.jsx)("div",{className:"border border-border rounded-lg p-3 bg-muted/20",children:(0,w.jsx)(K,{data:u,height:180})})]}),(0,w.jsxs)("div",{children:[(0,w.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[(0,w.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:f("tokenStats.byModel")}),(0,w.jsxs)("div",{className:"flex bg-muted rounded-md p-0.5",children:[(0,w.jsx)("button",{className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${"tokens"===m?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>n("tokens"),children:f("tokenStats.tokenUsage")}),(0,w.jsx)("button",{className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${"cost"===m?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>n("cost"),children:f("tokenStats.equivalentCost")})]})]}),(0,w.jsx)("div",{className:"flex items-center gap-3 text-[10px] flex-wrap",children:q.map(a=>(0,w.jsxs)("span",{className:"flex items-center gap-1",children:[(0,w.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{backgroundColor:a.color}}),a.label]},a.id))})]}),(0,w.jsx)("div",{className:"border border-border rounded-lg p-3 bg-muted/20",children:(0,w.jsx)(K,{data:"tokens"===m?v:z,height:180,formatValue:"tokens"===m?I:J})})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:f("tokenStats.modelCostDetail")}),(0,w.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:(0,w.jsxs)("table",{className:"w-full text-xs",children:[(0,w.jsx)("thead",{children:(0,w.jsxs)("tr",{className:"bg-muted/50 text-muted-foreground",children:[(0,w.jsx)("th",{className:"text-left px-3 py-2 font-medium",children:f("tokenStats.model")}),(0,w.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Input"}),(0,w.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Output"}),(0,w.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Cache Read"}),(0,w.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Cache Write"}),(0,w.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:f("tokenStats.share")}),(0,w.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:f("tokenStats.equivalentCost")})]})}),(0,w.jsxs)("tbody",{children:[q.map(a=>(0,w.jsxs)("tr",{className:"border-t border-border",children:[(0,w.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:(0,w.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,w.jsx)("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:a.color}}),a.label]})}),(0,w.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:I(a.usage.inputTokens)}),(0,w.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:I(a.usage.outputTokens)}),(0,w.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:I(a.usage.cacheReadInputTokens)}),(0,w.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:I(a.usage.cacheCreationInputTokens)}),(0,w.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:r>0?`${(a.cost/r*100).toFixed(1)}%`:"-"}),(0,w.jsx)("td",{className:"px-3 py-2 text-right font-medium text-foreground",children:J(a.cost)})]},a.id)),(0,w.jsxs)("tr",{className:"border-t-2 border-border bg-muted/30",children:[(0,w.jsx)("td",{className:"px-3 py-2 font-medium text-foreground",children:f("tokenStats.total")}),(0,w.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:I(q.reduce((a,b)=>a+b.usage.inputTokens,0))}),(0,w.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:I(q.reduce((a,b)=>a+b.usage.outputTokens,0))}),(0,w.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:I(q.reduce((a,b)=>a+b.usage.cacheReadInputTokens,0))}),(0,w.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:I(q.reduce((a,b)=>a+b.usage.cacheCreationInputTokens,0))}),(0,w.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:"100%"}),(0,w.jsx)("td",{className:"px-3 py-2 text-right font-bold text-foreground",children:J(r)})]})]})]})})]}),g.hourCounts&&Object.keys(g.hourCounts).length>0&&(0,w.jsx)("div",{className:"border border-border rounded-lg p-3 bg-muted/20",children:(0,w.jsx)(L,{hourCounts:g.hourCounts})})]}):(0,w.jsx)("div",{className:"text-center text-muted-foreground py-12",children:f("tokenStats.notFound")})})]})]})}function N({label:a,value:b,highlight:c}){return(0,w.jsxs)("div",{className:"bg-muted/30 rounded-lg px-3 py-2.5",children:[(0,w.jsx)("div",{className:"text-[10px] text-muted-foreground",children:a}),(0,w.jsx)("div",{className:`text-sm font-semibold mt-0.5 ${c?"text-brand":"text-foreground"}`,children:b})]})}var O=c(41564),P=c(74429),Q=c(42237);function R(a){this.content=a}R.prototype={constructor:R,find:function(a){for(var b=0;b<this.content.length;b+=2)if(this.content[b]===a)return b;return -1},get:function(a){var b=this.find(a);return -1==b?void 0:this.content[b+1]},update:function(a,b,c){var d=c&&c!=a?this.remove(c):this,e=d.find(a),f=d.content.slice();return -1==e?f.push(c||a,b):(f[e+1]=b,c&&(f[e]=c)),new R(f)},remove:function(a){var b=this.find(a);if(-1==b)return this;var c=this.content.slice();return c.splice(b,2),new R(c)},addToStart:function(a,b){return new R([a,b].concat(this.remove(a).content))},addToEnd:function(a,b){var c=this.remove(a).content.slice();return c.push(a,b),new R(c)},addBefore:function(a,b,c){var d=this.remove(b),e=d.content.slice(),f=d.find(a);return e.splice(-1==f?e.length:f,0,b,c),new R(e)},forEach:function(a){for(var b=0;b<this.content.length;b+=2)a(this.content[b],this.content[b+1])},prepend:function(a){return(a=R.from(a)).size?new R(a.content.concat(this.subtract(a).content)):this},append:function(a){return(a=R.from(a)).size?new R(this.subtract(a).content.concat(a.content)):this},subtract:function(a){var b=this;a=R.from(a);for(var c=0;c<a.content.length;c+=2)b=b.remove(a.content[c]);return b},toObject:function(){var a={};return this.forEach(function(b,c){a[b]=c}),a},get size(){return this.content.length>>1}},R.from=function(a){if(a instanceof R)return a;var b=[];if(a)for(var c in a)b.push(c,a[c]);return new R(b)};class S{constructor(a,b){if(this.content=a,this.size=b||0,null==b)for(let b=0;b<a.length;b++)this.size+=a[b].nodeSize}nodesBetween(a,b,c,d=0,e){for(let f=0,g=0;g<b;f++){let h=this.content[f],i=g+h.nodeSize;if(i>a&&!1!==c(h,d+g,e||null,f)&&h.content.size){let e=g+1;h.nodesBetween(Math.max(0,a-e),Math.min(h.content.size,b-e),c,d+e)}g=i}}descendants(a){this.nodesBetween(0,this.size,a)}textBetween(a,b,c,d){let e="",f=!0;return this.nodesBetween(a,b,(g,h)=>{let i=g.isText?g.text.slice(Math.max(a,h)-h,b-h):g.isLeaf?d?"function"==typeof d?d(g):d:g.type.spec.leafText?g.type.spec.leafText(g):"":"";g.isBlock&&(g.isLeaf&&i||g.isTextblock)&&c&&(f?f=!1:e+=c),e+=i},0),e}append(a){if(!a.size)return this;if(!this.size)return a;let b=this.lastChild,c=a.firstChild,d=this.content.slice(),e=0;for(b.isText&&b.sameMarkup(c)&&(d[d.length-1]=b.withText(b.text+c.text),e=1);e<a.content.length;e++)d.push(a.content[e]);return new S(d,this.size+a.size)}cut(a,b=this.size){if(0==a&&b==this.size)return this;let c=[],d=0;if(b>a)for(let e=0,f=0;f<b;e++){let g=this.content[e],h=f+g.nodeSize;h>a&&((f<a||h>b)&&(g=g.isText?g.cut(Math.max(0,a-f),Math.min(g.text.length,b-f)):g.cut(Math.max(0,a-f-1),Math.min(g.content.size,b-f-1))),c.push(g),d+=g.nodeSize),f=h}return new S(c,d)}cutByIndex(a,b){return a==b?S.empty:0==a&&b==this.content.length?this:new S(this.content.slice(a,b))}replaceChild(a,b){let c=this.content[a];if(c==b)return this;let d=this.content.slice(),e=this.size+b.nodeSize-c.nodeSize;return d[a]=b,new S(d,e)}addToStart(a){return new S([a].concat(this.content),this.size+a.nodeSize)}addToEnd(a){return new S(this.content.concat(a),this.size+a.nodeSize)}eq(a){if(this.content.length!=a.content.length)return!1;for(let b=0;b<this.content.length;b++)if(!this.content[b].eq(a.content[b]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(a){let b=this.content[a];if(!b)throw RangeError("Index "+a+" out of range for "+this);return b}maybeChild(a){return this.content[a]||null}forEach(a){for(let b=0,c=0;b<this.content.length;b++){let d=this.content[b];a(d,c,b),c+=d.nodeSize}}findDiffStart(a,b=0){return function a(b,c,d){for(let e=0;;e++){if(e==b.childCount||e==c.childCount)return b.childCount==c.childCount?null:d;let f=b.child(e),g=c.child(e);if(f==g){d+=f.nodeSize;continue}if(!f.sameMarkup(g))return d;if(f.isText&&f.text!=g.text){for(let a=0;f.text[a]==g.text[a];a++)d++;return d}if(f.content.size||g.content.size){let b=a(f.content,g.content,d+1);if(null!=b)return b}d+=f.nodeSize}}(this,a,b)}findDiffEnd(a,b=this.size,c=a.size){return function a(b,c,d,e){for(let f=b.childCount,g=c.childCount;;){if(0==f||0==g)return f==g?null:{a:d,b:e};let h=b.child(--f),i=c.child(--g),j=h.nodeSize;if(h==i){d-=j,e-=j;continue}if(!h.sameMarkup(i))return{a:d,b:e};if(h.isText&&h.text!=i.text){let a=0,b=Math.min(h.text.length,i.text.length);for(;a<b&&h.text[h.text.length-a-1]==i.text[i.text.length-a-1];)a++,d--,e--;return{a:d,b:e}}if(h.content.size||i.content.size){let b=a(h.content,i.content,d-1,e-1);if(b)return b}d-=j,e-=j}}(this,a,b,c)}findIndex(a){if(0==a)return U(0,a);if(a==this.size)return U(this.content.length,a);if(a>this.size||a<0)throw RangeError(`Position ${a} outside of fragment (${this})`);for(let b=0,c=0;;b++){let d=c+this.child(b).nodeSize;if(d>=a){if(d==a)return U(b+1,d);return U(b,c)}c=d}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(a=>a.toJSON()):null}static fromJSON(a,b){if(!b)return S.empty;if(!Array.isArray(b))throw RangeError("Invalid input for Fragment.fromJSON");return new S(b.map(a.nodeFromJSON))}static fromArray(a){if(!a.length)return S.empty;let b,c=0;for(let d=0;d<a.length;d++){let e=a[d];c+=e.nodeSize,d&&e.isText&&a[d-1].sameMarkup(e)?(b||(b=a.slice(0,d)),b[b.length-1]=e.withText(b[b.length-1].text+e.text)):b&&b.push(e)}return new S(b||a,c)}static from(a){if(!a)return S.empty;if(a instanceof S)return a;if(Array.isArray(a))return this.fromArray(a);if(a.attrs)return new S([a],a.nodeSize);throw RangeError("Can not convert "+a+" to a Fragment"+(a.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}S.empty=new S([],0);let T={index:0,offset:0};function U(a,b){return T.index=a,T.offset=b,T}function V(a,b){if(a===b)return!0;if(!(a&&"object"==typeof a)||!(b&&"object"==typeof b))return!1;let c=Array.isArray(a);if(Array.isArray(b)!=c)return!1;if(c){if(a.length!=b.length)return!1;for(let c=0;c<a.length;c++)if(!V(a[c],b[c]))return!1}else{for(let c in a)if(!(c in b)||!V(a[c],b[c]))return!1;for(let c in b)if(!(c in a))return!1}return!0}class W{constructor(a,b){this.type=a,this.attrs=b}addToSet(a){let b,c=!1;for(let d=0;d<a.length;d++){let e=a[d];if(this.eq(e))return a;if(this.type.excludes(e.type))b||(b=a.slice(0,d));else{if(e.type.excludes(this.type))return a;!c&&e.type.rank>this.type.rank&&(b||(b=a.slice(0,d)),b.push(this),c=!0),b&&b.push(e)}}return b||(b=a.slice()),c||b.push(this),b}removeFromSet(a){for(let b=0;b<a.length;b++)if(this.eq(a[b]))return a.slice(0,b).concat(a.slice(b+1));return a}isInSet(a){for(let b=0;b<a.length;b++)if(this.eq(a[b]))return!0;return!1}eq(a){return this==a||this.type==a.type&&V(this.attrs,a.attrs)}toJSON(){let a={type:this.type.name};for(let b in this.attrs){a.attrs=this.attrs;break}return a}static fromJSON(a,b){if(!b)throw RangeError("Invalid input for Mark.fromJSON");let c=a.marks[b.type];if(!c)throw RangeError(`There is no mark type ${b.type} in this schema`);let d=c.create(b.attrs);return c.checkAttrs(d.attrs),d}static sameSet(a,b){if(a==b)return!0;if(a.length!=b.length)return!1;for(let c=0;c<a.length;c++)if(!a[c].eq(b[c]))return!1;return!0}static setFrom(a){if(!a||Array.isArray(a)&&0==a.length)return W.none;if(a instanceof W)return[a];let b=a.slice();return b.sort((a,b)=>a.type.rank-b.type.rank),b}}W.none=[];class X extends Error{}class Y{constructor(a,b,c){this.content=a,this.openStart=b,this.openEnd=c}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(a,b){let c=function a(b,c,d,e){let{index:f,offset:g}=b.findIndex(c),h=b.maybeChild(f);if(g==c||h.isText)return e&&!e.canReplace(f,f,d)?null:b.cut(0,c).append(d).append(b.cut(c));let i=a(h.content,c-g-1,d,h);return i&&b.replaceChild(f,h.copy(i))}(this.content,a+this.openStart,b);return c&&new Y(c,this.openStart,this.openEnd)}removeBetween(a,b){return new Y(function a(b,c,d){let{index:e,offset:f}=b.findIndex(c),g=b.maybeChild(e),{index:h,offset:i}=b.findIndex(d);if(f==c||g.isText){if(i!=d&&!b.child(h).isText)throw RangeError("Removing non-flat range");return b.cut(0,c).append(b.cut(d))}if(e!=h)throw RangeError("Removing non-flat range");return b.replaceChild(e,g.copy(a(g.content,c-f-1,d-f-1)))}(this.content,a+this.openStart,b+this.openStart),this.openStart,this.openEnd)}eq(a){return this.content.eq(a.content)&&this.openStart==a.openStart&&this.openEnd==a.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let a={content:this.content.toJSON()};return this.openStart>0&&(a.openStart=this.openStart),this.openEnd>0&&(a.openEnd=this.openEnd),a}static fromJSON(a,b){if(!b)return Y.empty;let c=b.openStart||0,d=b.openEnd||0;if("number"!=typeof c||"number"!=typeof d)throw RangeError("Invalid input for Slice.fromJSON");return new Y(S.fromJSON(a,b.content),c,d)}static maxOpen(a,b=!0){let c=0,d=0;for(let d=a.firstChild;d&&!d.isLeaf&&(b||!d.type.spec.isolating);d=d.firstChild)c++;for(let c=a.lastChild;c&&!c.isLeaf&&(b||!c.type.spec.isolating);c=c.lastChild)d++;return new Y(a,c,d)}}function Z(a,b){if(!b.type.compatibleContent(a.type))throw new X("Cannot join "+b.type.name+" onto "+a.type.name)}function $(a,b,c){let d=a.node(c);return Z(d,b.node(c)),d}function _(a,b){let c=b.length-1;c>=0&&a.isText&&a.sameMarkup(b[c])?b[c]=a.withText(b[c].text+a.text):b.push(a)}function aa(a,b,c,d){let e=(b||a).node(c),f=0,g=b?b.index(c):e.childCount;a&&(f=a.index(c),a.depth>c?f++:a.textOffset&&(_(a.nodeAfter,d),f++));for(let a=f;a<g;a++)_(e.child(a),d);b&&b.depth==c&&b.textOffset&&_(b.nodeBefore,d)}function ab(a,b){return a.type.checkContent(b),a.copy(b)}function ac(a,b,c){let d=[];return aa(null,a,c,d),a.depth>c&&_(ab($(a,b,c+1),ac(a,b,c+1)),d),aa(b,null,c,d),new S(d)}Y.empty=new Y(S.empty,0,0);class ad{constructor(a,b,c){this.pos=a,this.path=b,this.parentOffset=c,this.depth=b.length/3-1}resolveDepth(a){return null==a?this.depth:a<0?this.depth+a:a}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(a){return this.path[3*this.resolveDepth(a)]}index(a){return this.path[3*this.resolveDepth(a)+1]}indexAfter(a){return a=this.resolveDepth(a),this.index(a)+(a!=this.depth||this.textOffset?1:0)}start(a){return 0==(a=this.resolveDepth(a))?0:this.path[3*a-1]+1}end(a){return a=this.resolveDepth(a),this.start(a)+this.node(a).content.size}before(a){if(!(a=this.resolveDepth(a)))throw RangeError("There is no position before the top-level node");return a==this.depth+1?this.pos:this.path[3*a-1]}after(a){if(!(a=this.resolveDepth(a)))throw RangeError("There is no position after the top-level node");return a==this.depth+1?this.pos:this.path[3*a-1]+this.path[3*a].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let a=this.parent,b=this.index(this.depth);if(b==a.childCount)return null;let c=this.pos-this.path[this.path.length-1],d=a.child(b);return c?a.child(b).cut(c):d}get nodeBefore(){let a=this.index(this.depth),b=this.pos-this.path[this.path.length-1];return b?this.parent.child(a).cut(0,b):0==a?null:this.parent.child(a-1)}posAtIndex(a,b){b=this.resolveDepth(b);let c=this.path[3*b],d=0==b?0:this.path[3*b-1]+1;for(let b=0;b<a;b++)d+=c.child(b).nodeSize;return d}marks(){let a=this.parent,b=this.index();if(0==a.content.size)return W.none;if(this.textOffset)return a.child(b).marks;let c=a.maybeChild(b-1),d=a.maybeChild(b);if(!c){let a=c;c=d,d=a}let e=c.marks;for(var f=0;f<e.length;f++)!1!==e[f].type.spec.inclusive||d&&e[f].isInSet(d.marks)||(e=e[f--].removeFromSet(e));return e}marksAcross(a){let b=this.parent.maybeChild(this.index());if(!b||!b.isInline)return null;let c=b.marks,d=a.parent.maybeChild(a.index());for(var e=0;e<c.length;e++)!1!==c[e].type.spec.inclusive||d&&c[e].isInSet(d.marks)||(c=c[e--].removeFromSet(c));return c}sharedDepth(a){for(let b=this.depth;b>0;b--)if(this.start(b)<=a&&this.end(b)>=a)return b;return 0}blockRange(a=this,b){if(a.pos<this.pos)return a.blockRange(this);for(let c=this.depth-(this.parent.inlineContent||this.pos==a.pos?1:0);c>=0;c--)if(a.pos<=this.end(c)&&(!b||b(this.node(c))))return new ah(this,a,c);return null}sameParent(a){return this.pos-this.parentOffset==a.pos-a.parentOffset}max(a){return a.pos>this.pos?a:this}min(a){return a.pos<this.pos?a:this}toString(){let a="";for(let b=1;b<=this.depth;b++)a+=(a?"/":"")+this.node(b).type.name+"_"+this.index(b-1);return a+":"+this.parentOffset}static resolve(a,b){if(!(b>=0&&b<=a.content.size))throw RangeError("Position "+b+" out of range");let c=[],d=0,e=b;for(let b=a;;){let{index:a,offset:f}=b.content.findIndex(e),g=e-f;if(c.push(b,a,d+f),!g||(b=b.child(a)).isText)break;e=g-1,d+=f+1}return new ad(b,c,e)}static resolveCached(a,b){let c=ag.get(a);if(c)for(let a=0;a<c.elts.length;a++){let d=c.elts[a];if(d.pos==b)return d}else ag.set(a,c=new ae);let d=c.elts[c.i]=ad.resolve(a,b);return c.i=(c.i+1)%af,d}}class ae{constructor(){this.elts=[],this.i=0}}let af=12,ag=new WeakMap;class ah{constructor(a,b,c){this.$from=a,this.$to=b,this.depth=c}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}let ai=Object.create(null);class aj{constructor(a,b,c,d=W.none){this.type=a,this.attrs=b,this.marks=d,this.content=c||S.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(a){return this.content.child(a)}maybeChild(a){return this.content.maybeChild(a)}forEach(a){this.content.forEach(a)}nodesBetween(a,b,c,d=0){this.content.nodesBetween(a,b,c,d,this)}descendants(a){this.nodesBetween(0,this.content.size,a)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(a,b,c,d){return this.content.textBetween(a,b,c,d)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(a){return this==a||this.sameMarkup(a)&&this.content.eq(a.content)}sameMarkup(a){return this.hasMarkup(a.type,a.attrs,a.marks)}hasMarkup(a,b,c){return this.type==a&&V(this.attrs,b||a.defaultAttrs||ai)&&W.sameSet(this.marks,c||W.none)}copy(a=null){return a==this.content?this:new aj(this.type,this.attrs,a,this.marks)}mark(a){return a==this.marks?this:new aj(this.type,this.attrs,this.content,a)}cut(a,b=this.content.size){return 0==a&&b==this.content.size?this:this.copy(this.content.cut(a,b))}slice(a,b=this.content.size,c=!1){if(a==b)return Y.empty;let d=this.resolve(a),e=this.resolve(b),f=c?0:d.sharedDepth(b),g=d.start(f);return new Y(d.node(f).content.cut(d.pos-g,e.pos-g),d.depth-f,e.depth-f)}replace(a,b,c){var d=this.resolve(a),e=this.resolve(b);if(c.openStart>d.depth)throw new X("Inserted content deeper than insertion position");if(d.depth-c.openStart!=e.depth-c.openEnd)throw new X("Inconsistent open depths");return function a(b,c,d,e){let f=b.index(e),g=b.node(e);if(f==c.index(e)&&e<b.depth-d.openStart){let h=a(b,c,d,e+1);return g.copy(g.content.replaceChild(f,h))}if(!d.content.size)return ab(g,ac(b,c,e));if(d.openStart||d.openEnd||b.depth!=e||c.depth!=e){let{start:a,end:f}=function(a,b){let c=b.depth-a.openStart,d=b.node(c).copy(a.content);for(let a=c-1;a>=0;a--)d=b.node(a).copy(S.from(d));return{start:d.resolveNoCache(a.openStart+c),end:d.resolveNoCache(d.content.size-a.openEnd-c)}}(d,b);return ab(g,function a(b,c,d,e,f){let g=b.depth>f&&$(b,c,f+1),h=e.depth>f&&$(d,e,f+1),i=[];return aa(null,b,f,i),g&&h&&c.index(f)==d.index(f)?(Z(g,h),_(ab(g,a(b,c,d,e,f+1)),i)):(g&&_(ab(g,ac(b,c,f+1)),i),aa(c,d,f,i),h&&_(ab(h,ac(d,e,f+1)),i)),aa(e,null,f,i),new S(i)}(b,a,f,c,e))}{let a=b.parent,e=a.content;return ab(a,e.cut(0,b.parentOffset).append(d.content).append(e.cut(c.parentOffset)))}}(d,e,c,0)}nodeAt(a){for(let b=this;;){let{index:c,offset:d}=b.content.findIndex(a);if(!(b=b.maybeChild(c)))return null;if(d==a||b.isText)return b;a-=d+1}}childAfter(a){let{index:b,offset:c}=this.content.findIndex(a);return{node:this.content.maybeChild(b),index:b,offset:c}}childBefore(a){if(0==a)return{node:null,index:0,offset:0};let{index:b,offset:c}=this.content.findIndex(a);if(c<a)return{node:this.content.child(b),index:b,offset:c};let d=this.content.child(b-1);return{node:d,index:b-1,offset:c-d.nodeSize}}resolve(a){return ad.resolveCached(this,a)}resolveNoCache(a){return ad.resolve(this,a)}rangeHasMark(a,b,c){let d=!1;return b>a&&this.nodesBetween(a,b,a=>(c.isInSet(a.marks)&&(d=!0),!d)),d}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 a=this.type.name;return this.content.size&&(a+="("+this.content.toStringInner()+")"),al(this.marks,a)}contentMatchAt(a){let b=this.type.contentMatch.matchFragment(this.content,0,a);if(!b)throw Error("Called contentMatchAt on a node with invalid content");return b}canReplace(a,b,c=S.empty,d=0,e=c.childCount){let f=this.contentMatchAt(a).matchFragment(c,d,e),g=f&&f.matchFragment(this.content,b);if(!g||!g.validEnd)return!1;for(let a=d;a<e;a++)if(!this.type.allowsMarks(c.child(a).marks))return!1;return!0}canReplaceWith(a,b,c,d){if(d&&!this.type.allowsMarks(d))return!1;let e=this.contentMatchAt(a).matchType(c),f=e&&e.matchFragment(this.content,b);return!!f&&f.validEnd}canAppend(a){return a.content.size?this.canReplace(this.childCount,this.childCount,a.content):this.type.compatibleContent(a.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let a=W.none;for(let b=0;b<this.marks.length;b++){let c=this.marks[b];c.type.checkAttrs(c.attrs),a=c.addToSet(a)}if(!W.sameSet(a,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(a=>a.type.name)}`);this.content.forEach(a=>a.check())}toJSON(){let a={type:this.type.name};for(let b in this.attrs){a.attrs=this.attrs;break}return this.content.size&&(a.content=this.content.toJSON()),this.marks.length&&(a.marks=this.marks.map(a=>a.toJSON())),a}static fromJSON(a,b){let c;if(!b)throw RangeError("Invalid input for Node.fromJSON");if(b.marks){if(!Array.isArray(b.marks))throw RangeError("Invalid mark data for Node.fromJSON");c=b.marks.map(a.markFromJSON)}if("text"==b.type){if("string"!=typeof b.text)throw RangeError("Invalid text node in JSON");return a.text(b.text,c)}let d=S.fromJSON(a,b.content),e=a.nodeType(b.type).create(b.attrs,d,c);return e.type.checkAttrs(e.attrs),e}}aj.prototype.text=void 0;class ak extends aj{constructor(a,b,c,d){if(super(a,b,null,d),!c)throw RangeError("Empty text nodes are not allowed");this.text=c}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):al(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(a,b){return this.text.slice(a,b)}get nodeSize(){return this.text.length}mark(a){return a==this.marks?this:new ak(this.type,this.attrs,this.text,a)}withText(a){return a==this.text?this:new ak(this.type,this.attrs,a,this.marks)}cut(a=0,b=this.text.length){return 0==a&&b==this.text.length?this:this.withText(this.text.slice(a,b))}eq(a){return this.sameMarkup(a)&&this.text==a.text}toJSON(){let a=super.toJSON();return a.text=this.text,a}}function al(a,b){for(let c=a.length-1;c>=0;c--)b=a[c].type.name+"("+b+")";return b}class am{constructor(a){this.validEnd=a,this.next=[],this.wrapCache=[]}static parse(a,b){var c;let d,e=new an(a,b);if(null==e.next)return am.empty;let f=function a(b){let c=[];do c.push(function(b){let c=[];do c.push(function(b){let c=function(b){if(b.eat("(")){let c=a(b);return b.eat(")")||b.err("Missing closing paren"),c}if(/\W/.test(b.next))b.err("Unexpected token '"+b.next+"'");else{let a=(function(a,b){let c=a.nodeTypes,d=c[b];if(d)return[d];let e=[];for(let a in c){let d=c[a];d.isInGroup(b)&&e.push(d)}return 0==e.length&&a.err("No node type or group '"+b+"' found"),e})(b,b.next).map(a=>(null==b.inline?b.inline=a.isInline:b.inline!=a.isInline&&b.err("Mixing inline and block content"),{type:"name",value:a}));return b.pos++,1==a.length?a[0]:{type:"choice",exprs:a}}}(b);for(;;)if(b.eat("+"))c={type:"plus",expr:c};else if(b.eat("*"))c={type:"star",expr:c};else if(b.eat("?"))c={type:"opt",expr:c};else if(b.eat("{"))c=function(a,b){let c=ao(a),d=c;return a.eat(",")&&(d="}"!=a.next?ao(a):-1),a.eat("}")||a.err("Unclosed braced range"),{type:"range",min:c,max:d,expr:b}}(b,c);else break;return c}(b));while(b.next&&")"!=b.next&&"|"!=b.next);return 1==c.length?c[0]:{type:"seq",exprs:c}}(b));while(b.eat("|"));return 1==c.length?c[0]:{type:"choice",exprs:c}}(e);e.next&&e.err("Unexpected trailing text");let g=(c=function(a){let b=[[]];return e(function a(b,f){if("choice"==b.type)return b.exprs.reduce((b,c)=>b.concat(a(c,f)),[]);if("seq"==b.type)for(let d=0;;d++){let g=a(b.exprs[d],f);if(d==b.exprs.length-1)return g;e(g,f=c())}else if("star"==b.type){let g=c();return d(f,g),e(a(b.expr,g),g),[d(g)]}else if("plus"==b.type){let g=c();return e(a(b.expr,f),g),e(a(b.expr,g),g),[d(g)]}else if("opt"==b.type)return[d(f)].concat(a(b.expr,f));else if("range"==b.type){let g=f;for(let d=0;d<b.min;d++){let d=c();e(a(b.expr,g),d),g=d}if(-1==b.max)e(a(b.expr,g),g);else for(let f=b.min;f<b.max;f++){let f=c();d(g,f),e(a(b.expr,g),f),g=f}return[d(g)]}else if("name"==b.type)return[d(f,void 0,b.value)];else throw Error("Unknown expr type")}(a,0),c()),b;function c(){return b.push([])-1}function d(a,c,d){let e={term:d,to:c};return b[a].push(e),e}function e(a,b){a.forEach(a=>a.to=b)}}(f),d=Object.create(null),function a(b){let e=[];b.forEach(a=>{c[a].forEach(({term:a,to:b})=>{let d;if(a){for(let b=0;b<e.length;b++)e[b][0]==a&&(d=e[b][1]);aq(c,b).forEach(b=>{d||e.push([a,d=[]]),-1==d.indexOf(b)&&d.push(b)})}})});let f=d[b.join(",")]=new am(b.indexOf(c.length-1)>-1);for(let b=0;b<e.length;b++){let c=e[b][1].sort(ap);f.next.push({type:e[b][0],next:d[c.join(",")]||a(c)})}return f}(aq(c,0)));return function(a,b){for(let c=0,d=[a];c<d.length;c++){let a=d[c],e=!a.validEnd,f=[];for(let b=0;b<a.next.length;b++){let{type:c,next:g}=a.next[b];f.push(c.name),e&&!(c.isText||c.hasRequiredAttrs())&&(e=!1),-1==d.indexOf(g)&&d.push(g)}e&&b.err("Only non-generatable nodes ("+f.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(g,e),g}matchType(a){for(let b=0;b<this.next.length;b++)if(this.next[b].type==a)return this.next[b].next;return null}matchFragment(a,b=0,c=a.childCount){let d=this;for(let e=b;d&&e<c;e++)d=d.matchType(a.child(e).type);return d}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let a=0;a<this.next.length;a++){let{type:b}=this.next[a];if(!(b.isText||b.hasRequiredAttrs()))return b}return null}compatible(a){for(let b=0;b<this.next.length;b++)for(let c=0;c<a.next.length;c++)if(this.next[b].type==a.next[c].type)return!0;return!1}fillBefore(a,b=!1,c=0){let d=[this];return function e(f,g){let h=f.matchFragment(a,c);if(h&&(!b||h.validEnd))return S.from(g.map(a=>a.createAndFill()));for(let a=0;a<f.next.length;a++){let{type:b,next:c}=f.next[a];if(!(b.isText||b.hasRequiredAttrs())&&-1==d.indexOf(c)){d.push(c);let a=e(c,g.concat(b));if(a)return a}}return null}(this,[])}findWrapping(a){for(let b=0;b<this.wrapCache.length;b+=2)if(this.wrapCache[b]==a)return this.wrapCache[b+1];let b=this.computeWrapping(a);return this.wrapCache.push(a,b),b}computeWrapping(a){let b=Object.create(null),c=[{match:this,type:null,via:null}];for(;c.length;){let d=c.shift(),e=d.match;if(e.matchType(a)){let a=[];for(let b=d;b.type;b=b.via)a.push(b.type);return a.reverse()}for(let a=0;a<e.next.length;a++){let{type:f,next:g}=e.next[a];f.isLeaf||f.hasRequiredAttrs()||f.name in b||d.type&&!g.validEnd||(c.push({match:f.contentMatch,type:f,via:d}),b[f.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(a){if(a>=this.next.length)throw RangeError(`There's no ${a}th edge in this content match`);return this.next[a]}toString(){let a=[];return!function b(c){a.push(c);for(let d=0;d<c.next.length;d++)-1==a.indexOf(c.next[d].next)&&b(c.next[d].next)}(this),a.map((b,c)=>{let d=c+(b.validEnd?"*":" ")+" ";for(let c=0;c<b.next.length;c++)d+=(c?", ":"")+b.next[c].type.name+"->"+a.indexOf(b.next[c].next);return d}).join("\n")}}am.empty=new am(!0);class an{constructor(a,b){this.string=a,this.nodeTypes=b,this.inline=null,this.pos=0,this.tokens=a.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(a){return this.next==a&&(this.pos++||!0)}err(a){throw SyntaxError(a+" (in content expression '"+this.string+"')")}}function ao(a){/\D/.test(a.next)&&a.err("Expected number, got '"+a.next+"'");let b=Number(a.next);return a.pos++,b}function ap(a,b){return b-a}function aq(a,b){let c=[];return function b(d){let e=a[d];if(1==e.length&&!e[0].term)return b(e[0].to);c.push(d);for(let a=0;a<e.length;a++){let{term:d,to:f}=e[a];d||-1!=c.indexOf(f)||b(f)}}(b),c.sort(ap)}function ar(a){let b=Object.create(null);for(let c in a){let d=a[c];if(!d.hasDefault)return null;b[c]=d.default}return b}function as(a,b){let c=Object.create(null);for(let d in a){let e=b&&b[d];if(void 0===e){let b=a[d];if(b.hasDefault)e=b.default;else throw RangeError("No value supplied for attribute "+d)}c[d]=e}return c}function at(a,b,c,d){for(let d in b)if(!(d in a))throw RangeError(`Unsupported attribute ${d} for ${c} of type ${d}`);for(let c in a){let d=a[c];d.validate&&d.validate(b[c])}}function au(a,b){let c=Object.create(null);if(b)for(let d in b)c[d]=new aw(a,d,b[d]);return c}class av{constructor(a,b,c){this.name=a,this.schema=b,this.spec=c,this.markSet=null,this.groups=c.group?c.group.split(" "):[],this.attrs=au(a,c.attrs),this.defaultAttrs=ar(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(c.inline||"text"==a),this.isText="text"==a}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==am.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(a){return this.groups.indexOf(a)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let a in this.attrs)if(this.attrs[a].isRequired)return!0;return!1}compatibleContent(a){return this==a||this.contentMatch.compatible(a.contentMatch)}computeAttrs(a){return!a&&this.defaultAttrs?this.defaultAttrs:as(this.attrs,a)}create(a=null,b,c){if(this.isText)throw Error("NodeType.create can't construct text nodes");return new aj(this,this.computeAttrs(a),S.from(b),W.setFrom(c))}createChecked(a=null,b,c){return b=S.from(b),this.checkContent(b),new aj(this,this.computeAttrs(a),b,W.setFrom(c))}createAndFill(a=null,b,c){if(a=this.computeAttrs(a),(b=S.from(b)).size){let a=this.contentMatch.fillBefore(b);if(!a)return null;b=a.append(b)}let d=this.contentMatch.matchFragment(b),e=d&&d.fillBefore(S.empty,!0);return e?new aj(this,a,b.append(e),W.setFrom(c)):null}validContent(a){let b=this.contentMatch.matchFragment(a);if(!b||!b.validEnd)return!1;for(let b=0;b<a.childCount;b++)if(!this.allowsMarks(a.child(b).marks))return!1;return!0}checkContent(a){if(!this.validContent(a))throw RangeError(`Invalid content for node ${this.name}: ${a.toString().slice(0,50)}`)}checkAttrs(a){at(this.attrs,a,"node",this.name)}allowsMarkType(a){return null==this.markSet||this.markSet.indexOf(a)>-1}allowsMarks(a){if(null==this.markSet)return!0;for(let b=0;b<a.length;b++)if(!this.allowsMarkType(a[b].type))return!1;return!0}allowedMarks(a){let b;if(null==this.markSet)return a;for(let c=0;c<a.length;c++)this.allowsMarkType(a[c].type)?b&&b.push(a[c]):b||(b=a.slice(0,c));return b?b.length?b:W.none:a}static compile(a,b){let c=Object.create(null);a.forEach((a,d)=>c[a]=new av(a,b,d));let d=b.spec.topNode||"doc";if(!c[d])throw RangeError("Schema is missing its top node type ('"+d+"')");if(!c.text)throw RangeError("Every schema needs a 'text' type");for(let a in c.text.attrs)throw RangeError("The text node type should not have attributes");return c}}class aw{constructor(a,b,c){this.hasDefault=Object.prototype.hasOwnProperty.call(c,"default"),this.default=c.default,this.validate="string"==typeof c.validate?function(a,b,c){let d=c.split("|");return c=>{let e=null===c?"null":typeof c;if(0>d.indexOf(e))throw RangeError(`Expected value of type ${d} for attribute ${b} on type ${a}, got ${e}`)}}(a,b,c.validate):c.validate}get isRequired(){return!this.hasDefault}}class ax{constructor(a,b,c,d){this.name=a,this.rank=b,this.schema=c,this.spec=d,this.attrs=au(a,d.attrs),this.excluded=null;let e=ar(this.attrs);this.instance=e?new W(this,e):null}create(a=null){return!a&&this.instance?this.instance:new W(this,as(this.attrs,a))}static compile(a,b){let c=Object.create(null),d=0;return a.forEach((a,e)=>c[a]=new ax(a,d++,b,e)),c}removeFromSet(a){for(var b=0;b<a.length;b++)a[b].type==this&&(a=a.slice(0,b).concat(a.slice(b+1)),b--);return a}isInSet(a){for(let b=0;b<a.length;b++)if(a[b].type==this)return a[b]}checkAttrs(a){at(this.attrs,a,"mark",this.name)}excludes(a){return this.excluded.indexOf(a)>-1}}class ay{constructor(a){this.linebreakReplacement=null,this.cached=Object.create(null);let b=this.spec={};for(let c in a)b[c]=a[c];b.nodes=R.from(a.nodes),b.marks=R.from(a.marks||{}),this.nodes=av.compile(this.spec.nodes,this),this.marks=ax.compile(this.spec.marks,this);let c=Object.create(null);for(let a in this.nodes){if(a in this.marks)throw RangeError(a+" can not be both a node and a mark");let b=this.nodes[a],d=b.spec.content||"",e=b.spec.marks;if(b.contentMatch=c[d]||(c[d]=am.parse(d,this.nodes)),b.inlineContent=b.contentMatch.inlineContent,b.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError("Multiple linebreak nodes defined");if(!b.isInline||!b.isLeaf)throw RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=b}b.markSet="_"==e?null:e?az(this,e.split(" ")):""!=e&&b.inlineContent?null:[]}for(let a in this.marks){let b=this.marks[a],c=b.spec.excludes;b.excluded=null==c?[b]:""==c?[]:az(this,c.split(" "))}this.nodeFromJSON=a=>aj.fromJSON(this,a),this.markFromJSON=a=>W.fromJSON(this,a),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(a,b=null,c,d){if("string"==typeof a)a=this.nodeType(a);else if(a instanceof av){if(a.schema!=this)throw RangeError("Node type from different schema used ("+a.name+")")}else throw RangeError("Invalid node type: "+a);return a.createChecked(b,c,d)}text(a,b){let c=this.nodes.text;return new ak(c,c.defaultAttrs,a,W.setFrom(b))}mark(a,b){return"string"==typeof a&&(a=this.marks[a]),a.create(b)}nodeType(a){let b=this.nodes[a];if(!b)throw RangeError("Unknown node type: "+a);return b}}function az(a,b){let c=[];for(let d=0;d<b.length;d++){let e=b[d],f=a.marks[e],g=f;if(f)c.push(f);else for(let b in a.marks){let d=a.marks[b];("_"==e||d.spec.group&&d.spec.group.split(" ").indexOf(e)>-1)&&c.push(g=d)}if(!g)throw SyntaxError("Unknown mark type: '"+b[d]+"'")}return c}class aA{constructor(a,b){this.schema=a,this.rules=b,this.tags=[],this.styles=[];let c=this.matchedStyles=[];b.forEach(a=>{if(null!=a.tag)this.tags.push(a);else if(null!=a.style){let b=/[^=]*/.exec(a.style)[0];0>c.indexOf(b)&&c.push(b),this.styles.push(a)}}),this.normalizeLists=!this.tags.some(b=>{if(!/^(ul|ol)\b/.test(b.tag)||!b.node)return!1;let c=a.nodes[b.node];return c.contentMatch.matchType(c)})}parse(a,b={}){let c=new aG(this,b,!1);return c.addAll(a,W.none,b.from,b.to),c.finish()}parseSlice(a,b={}){let c=new aG(this,b,!0);return c.addAll(a,W.none,b.from,b.to),Y.maxOpen(c.finish())}matchTag(a,b,c){for(let f=c?this.tags.indexOf(c)+1:0;f<this.tags.length;f++){var d,e;let c=this.tags[f];if(d=a,e=c.tag,(d.matches||d.msMatchesSelector||d.webkitMatchesSelector||d.mozMatchesSelector).call(d,e)&&(void 0===c.namespace||a.namespaceURI==c.namespace)&&(!c.context||b.matchesContext(c.context))){if(c.getAttrs){let b=c.getAttrs(a);if(!1===b)continue;c.attrs=b||void 0}return c}}}matchStyle(a,b,c,d){for(let e=d?this.styles.indexOf(d)+1:0;e<this.styles.length;e++){let d=this.styles[e],f=d.style;if(0==f.indexOf(a)&&(!d.context||c.matchesContext(d.context))&&(!(f.length>a.length)||61==f.charCodeAt(a.length)&&f.slice(a.length+1)==b)){if(d.getAttrs){let a=d.getAttrs(b);if(!1===a)continue;d.attrs=a||void 0}return d}}}static schemaRules(a){let b=[];function c(a){let c=null==a.priority?50:a.priority,d=0;for(;d<b.length;d++){let a=b[d];if((null==a.priority?50:a.priority)<c)break}b.splice(d,0,a)}for(let b in a.marks){let d=a.marks[b].spec.parseDOM;d&&d.forEach(a=>{c(a=aH(a)),a.mark||a.ignore||a.clearMark||(a.mark=b)})}for(let b in a.nodes){let d=a.nodes[b].spec.parseDOM;d&&d.forEach(a=>{c(a=aH(a)),a.node||a.ignore||a.mark||(a.node=b)})}return b}static fromSchema(a){return a.cached.domParser||(a.cached.domParser=new aA(a,aA.schemaRules(a)))}}let aB={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},aC={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},aD={ol:!0,ul:!0};function aE(a,b,c){return null!=b?!!b|2*("full"===b):a&&"pre"==a.whitespace?3:-5&c}class aF{constructor(a,b,c,d,e,f){this.type=a,this.attrs=b,this.marks=c,this.solid=d,this.options=f,this.content=[],this.activeMarks=W.none,this.match=e||(4&f?null:a.contentMatch)}findWrapping(a){if(!this.match){if(!this.type)return[];let b=this.type.contentMatch.fillBefore(S.from(a));if(b)this.match=this.type.contentMatch.matchFragment(b);else{let b=this.type.contentMatch,c;return(c=b.findWrapping(a.type))?(this.match=b,c):null}}return this.match.findWrapping(a.type)}finish(a){if(!(1&this.options)){let a=this.content[this.content.length-1],b;a&&a.isText&&(b=/[ \t\r\n\u000c]+$/.exec(a.text))&&(a.text.length==b[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-b[0].length)))}let b=S.from(this.content);return!a&&this.match&&(b=b.append(this.match.fillBefore(S.empty,!0))),this.type?this.type.create(this.attrs,b,this.marks):b}inlineContext(a){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:a.parentNode&&!aB.hasOwnProperty(a.parentNode.nodeName.toLowerCase())}}class aG{constructor(a,b,c){this.parser=a,this.options=b,this.isOpen=c,this.open=0,this.localPreserveWS=!1;let d=b.topNode,e,f=aE(null,b.preserveWhitespace,0)|4*!!c;e=d?new aF(d.type,d.attrs,W.none,!0,b.topMatch||d.type.contentMatch,f):c?new aF(null,null,W.none,!0,null,f):new aF(a.schema.topNodeType,null,W.none,!0,null,f),this.nodes=[e],this.find=b.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(a,b){3==a.nodeType?this.addTextNode(a,b):1==a.nodeType&&this.addElement(a,b)}addTextNode(a,b){let c=a.nodeValue,d=this.top,e=2&d.options?"full":this.localPreserveWS||(1&d.options)>0,{schema:f}=this.parser;if("full"===e||d.inlineContext(a)||/[^ \t\r\n\u000c]/.test(c)){if(e)if("full"===e)c=c.replace(/\r\n?/g,"\n");else if(f.linebreakReplacement&&/[\r\n]/.test(c)&&this.top.findWrapping(f.linebreakReplacement.create())){let a=c.split(/\r?\n|\r/);for(let c=0;c<a.length;c++)c&&this.insertNode(f.linebreakReplacement.create(),b,!0),a[c]&&this.insertNode(f.text(a[c]),b,!/\S/.test(a[c]));c=""}else c=c.replace(/\r?\n|\r/g," ");else if(c=c.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(c)&&this.open==this.nodes.length-1){let b=d.content[d.content.length-1],e=a.previousSibling;(!b||e&&"BR"==e.nodeName||b.isText&&/[ \t\r\n\u000c]$/.test(b.text))&&(c=c.slice(1))}c&&this.insertNode(f.text(c),b,!/\S/.test(c)),this.findInText(a)}else this.findInside(a)}addElement(a,b,c){let d=this.localPreserveWS,e=this.top;("PRE"==a.tagName||/pre/.test(a.style&&a.style.whiteSpace))&&(this.localPreserveWS=!0);let f=a.nodeName.toLowerCase(),g;aD.hasOwnProperty(f)&&this.parser.normalizeLists&&function(a){for(let b=a.firstChild,c=null;b;b=b.nextSibling){let a=1==b.nodeType?b.nodeName.toLowerCase():null;a&&aD.hasOwnProperty(a)&&c?(c.appendChild(b),b=c):"li"==a?c=b:a&&(c=null)}}(a);let h=this.options.ruleFromNode&&this.options.ruleFromNode(a)||(g=this.parser.matchTag(a,this,c));a:if(h?h.ignore:aC.hasOwnProperty(f))this.findInside(a),this.ignoreFallback(a,b);else if(!h||h.skip||h.closeParent){h&&h.closeParent?this.open=Math.max(0,this.open-1):h&&h.skip.nodeType&&(a=h.skip);let c,d=this.needsBlock;if(aB.hasOwnProperty(f))e.content.length&&e.content[0].isInline&&this.open&&(this.open--,e=this.top),c=!0,e.type||(this.needsBlock=!0);else if(!a.firstChild){this.leafFallback(a,b);break a}let g=h&&h.skip?b:this.readStyles(a,b);g&&this.addAll(a,g),c&&this.sync(e),this.needsBlock=d}else{let c=this.readStyles(a,b);c&&this.addElementByRule(a,h,c,!1===h.consuming?g:void 0)}this.localPreserveWS=d}leafFallback(a,b){"BR"==a.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(a.ownerDocument.createTextNode("\n"),b)}ignoreFallback(a,b){"BR"!=a.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),b,!0)}readStyles(a,b){let c=a.style;if(c&&c.length)for(let a=0;a<this.parser.matchedStyles.length;a++){let d=this.parser.matchedStyles[a],e=c.getPropertyValue(d);if(e)for(let a;;){let c=this.parser.matchStyle(d,e,this,a);if(!c)break;if(c.ignore)return null;if(b=c.clearMark?b.filter(a=>!c.clearMark(a)):b.concat(this.parser.schema.marks[c.mark].create(c.attrs)),!1===c.consuming)a=c;else break}}return b}addElementByRule(a,b,c,d){let e,f;if(b.node)if((f=this.parser.schema.nodes[b.node]).isLeaf)this.insertNode(f.create(b.attrs),c,"BR"==a.nodeName)||this.leafFallback(a,c);else{let a=this.enter(f,b.attrs||null,c,b.preserveWhitespace);a&&(e=!0,c=a)}else{let a=this.parser.schema.marks[b.mark];c=c.concat(a.create(b.attrs))}let g=this.top;if(f&&f.isLeaf)this.findInside(a);else if(d)this.addElement(a,c,d);else if(b.getContent)this.findInside(a),b.getContent(a,this.parser.schema).forEach(a=>this.insertNode(a,c,!1));else{let d=a;"string"==typeof b.contentElement?d=a.querySelector(b.contentElement):"function"==typeof b.contentElement?d=b.contentElement(a):b.contentElement&&(d=b.contentElement),this.findAround(a,d,!0),this.addAll(d,c),this.findAround(a,d,!1)}e&&this.sync(g)&&this.open--}addAll(a,b,c,d){let e=c||0;for(let f=c?a.childNodes[c]:a.firstChild,g=null==d?null:a.childNodes[d];f!=g;f=f.nextSibling,++e)this.findAtPoint(a,e),this.addDOM(f,b);this.findAtPoint(a,e)}findPlace(a,b,c){let d,e;for(let b=this.open,f=0;b>=0;b--){let g=this.nodes[b],h=g.findWrapping(a);if(h&&(!d||d.length>h.length+f)&&(d=h,e=g,!h.length))break;if(g.solid){if(c)break;f+=2}}if(!d)return null;this.sync(e);for(let a=0;a<d.length;a++)b=this.enterInner(d[a],null,b,!1);return b}insertNode(a,b,c){if(a.isInline&&this.needsBlock&&!this.top.type){let a=this.textblockFromContext();a&&(b=this.enterInner(a,null,b))}let d=this.findPlace(a,b,c);if(d){this.closeExtra();let b=this.top;b.match&&(b.match=b.match.matchType(a.type));let c=W.none;for(let e of d.concat(a.marks))(b.type?b.type.allowsMarkType(e.type):aI(e.type,a.type))&&(c=e.addToSet(c));return b.content.push(a.mark(c)),!0}return!1}enter(a,b,c,d){let e=this.findPlace(a.create(b),c,!1);return e&&(e=this.enterInner(a,b,c,!0,d)),e}enterInner(a,b,c,d=!1,e){this.closeExtra();let f=this.top;f.match=f.match&&f.match.matchType(a);let g=aE(a,e,f.options);4&f.options&&0==f.content.length&&(g|=4);let h=W.none;return c=c.filter(b=>(f.type?!f.type.allowsMarkType(b.type):!aI(b.type,a))||(h=b.addToSet(h),!1)),this.nodes.push(new aF(a,b,h,d,null,g)),this.open++,c}closeExtra(a=!1){let b=this.nodes.length-1;if(b>this.open){for(;b>this.open;b--)this.nodes[b-1].content.push(this.nodes[b].finish(a));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(a){for(let b=this.open;b>=0;b--)if(this.nodes[b]==a)return this.open=b,!0;else this.localPreserveWS&&(this.nodes[b].options|=1);return!1}get currentPos(){this.closeExtra();let a=0;for(let b=this.open;b>=0;b--){let c=this.nodes[b].content;for(let b=c.length-1;b>=0;b--)a+=c[b].nodeSize;b&&a++}return a}findAtPoint(a,b){if(this.find)for(let c=0;c<this.find.length;c++)this.find[c].node==a&&this.find[c].offset==b&&(this.find[c].pos=this.currentPos)}findInside(a){if(this.find)for(let b=0;b<this.find.length;b++)null==this.find[b].pos&&1==a.nodeType&&a.contains(this.find[b].node)&&(this.find[b].pos=this.currentPos)}findAround(a,b,c){if(a!=b&&this.find)for(let d=0;d<this.find.length;d++)null==this.find[d].pos&&1==a.nodeType&&a.contains(this.find[d].node)&&b.compareDocumentPosition(this.find[d].node)&(c?2:4)&&(this.find[d].pos=this.currentPos)}findInText(a){if(this.find)for(let b=0;b<this.find.length;b++)this.find[b].node==a&&(this.find[b].pos=this.currentPos-(a.nodeValue.length-this.find[b].offset))}matchesContext(a){if(a.indexOf("|")>-1)return a.split(/\s*\|\s*/).some(this.matchesContext,this);let b=a.split("/"),c=this.options.context,d=!this.isOpen&&(!c||c.parent.type==this.nodes[0].type),e=-(c?c.depth+1:0)+ +!d,f=(a,g)=>{for(;a>=0;a--){let h=b[a];if(""==h){if(a==b.length-1||0==a)continue;for(;g>=e;g--)if(f(a-1,g))return!0;return!1}{let a=g>0||0==g&&d?this.nodes[g].type:c&&g>=e?c.node(g-e).type:null;if(!a||a.name!=h&&!a.isInGroup(h))return!1;g--}}return!0};return f(b.length-1,this.open)}textblockFromContext(){let a=this.options.context;if(a)for(let b=a.depth;b>=0;b--){let c=a.node(b).contentMatchAt(a.indexAfter(b)).defaultType;if(c&&c.isTextblock&&c.defaultAttrs)return c}for(let a in this.parser.schema.nodes){let b=this.parser.schema.nodes[a];if(b.isTextblock&&b.defaultAttrs)return b}}}function aH(a){let b={};for(let c in a)b[c]=a[c];return b}function aI(a,b){let c=b.schema.nodes;for(let d in c){let e=c[d];if(!e.allowsMarkType(a))continue;let f=[],g=a=>{f.push(a);for(let c=0;c<a.edgeCount;c++){let{type:d,next:e}=a.edge(c);if(d==b||0>f.indexOf(e)&&g(e))return!0}};if(g(e.contentMatch))return!0}}class aJ{constructor(a,b){this.nodes=a,this.marks=b}serializeFragment(a,b={},c){c||(c=aL(b).createDocumentFragment());let d=c,e=[];return a.forEach(a=>{if(e.length||a.marks.length){let c=0,f=0;for(;c<e.length&&f<a.marks.length;){let b=a.marks[f];if(!this.marks[b.type.name]){f++;continue}if(!b.eq(e[c][0])||!1===b.type.spec.spanning)break;c++,f++}for(;c<e.length;)d=e.pop()[1];for(;f<a.marks.length;){let c=a.marks[f++],g=this.serializeMark(c,a.isInline,b);g&&(e.push([c,d]),d.appendChild(g.dom),d=g.contentDOM||g.dom)}}d.appendChild(this.serializeNodeInner(a,b))}),c}serializeNodeInner(a,b){let{dom:c,contentDOM:d}=aN(aL(b),this.nodes[a.type.name](a),null,a.attrs);if(d){if(a.isLeaf)throw RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(a.content,b,d)}return c}serializeNode(a,b={}){let c=this.serializeNodeInner(a,b);for(let d=a.marks.length-1;d>=0;d--){let e=this.serializeMark(a.marks[d],a.isInline,b);e&&((e.contentDOM||e.dom).appendChild(c),c=e.dom)}return c}serializeMark(a,b,c={}){let d=this.marks[a.type.name];return d&&aN(aL(c),d(a,b),null,a.attrs)}static renderSpec(a,b,c=null,d){return aN(a,b,c,d)}static fromSchema(a){return a.cached.domSerializer||(a.cached.domSerializer=new aJ(this.nodesFromSchema(a),this.marksFromSchema(a)))}static nodesFromSchema(a){let b=aK(a.nodes);return b.text||(b.text=a=>a.text),b}static marksFromSchema(a){return aK(a.marks)}}function aK(a){let b={};for(let c in a){let d=a[c].spec.toDOM;d&&(b[c]=d)}return b}function aL(a){return a.document||window.document}let aM=new WeakMap;function aN(a,b,c,d){let e,f,g;if("string"==typeof b)return{dom:a.createTextNode(b)};if(null!=b.nodeType)return{dom:b};if(b.dom&&null!=b.dom.nodeType)return b;let h=b[0],i;if("string"!=typeof h)throw RangeError("Invalid array passed to renderSpec");if(d&&(void 0===(f=aM.get(d))&&aM.set(d,(g=null,!function a(b){if(b&&"object"==typeof b)if(Array.isArray(b))if("string"==typeof b[0])g||(g=[]),g.push(b);else for(let c=0;c<b.length;c++)a(b[c]);else for(let c in b)a(b[c])}(d),f=g)),i=f)&&i.indexOf(b)>-1)throw RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let j=h.indexOf(" ");j>0&&(c=h.slice(0,j),h=h.slice(j+1));let k=c?a.createElementNS(c,h):a.createElement(h),l=b[1],m=1;if(l&&"object"==typeof l&&null==l.nodeType&&!Array.isArray(l)){for(let a in m=2,l)if(null!=l[a]){let b=a.indexOf(" ");b>0?k.setAttributeNS(a.slice(0,b),a.slice(b+1),l[a]):"style"==a&&k.style?k.style.cssText=l[a]:k.setAttribute(a,l[a])}}for(let f=m;f<b.length;f++){let g=b[f];if(0===g){if(f<b.length-1||f>m)throw RangeError("Content hole must be the only child of its parent node");return{dom:k,contentDOM:k}}{let{dom:b,contentDOM:f}=aN(a,g,c,d);if(k.appendChild(b),f){if(e)throw RangeError("Multiple content holes");e=f}}}return{dom:k,contentDOM:e}}class aO{constructor(a,b,c){this.pos=a,this.delInfo=b,this.recover=c}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class aP{constructor(a,b=!1){if(this.ranges=a,this.inverted=b,!a.length&&aP.empty)return aP.empty}recover(a){let b=0,c=65535&a;if(!this.inverted)for(let a=0;a<c;a++)b+=this.ranges[3*a+2]-this.ranges[3*a+1];return this.ranges[3*c]+b+(a-(65535&a))/65536}mapResult(a,b=1){return this._map(a,b,!1)}map(a,b=1){return this._map(a,b,!0)}_map(a,b,c){let d=0,e=this.inverted?2:1,f=this.inverted?1:2;for(let g=0;g<this.ranges.length;g+=3){let h=this.ranges[g]-(this.inverted?d:0);if(h>a)break;let i=this.ranges[g+e],j=this.ranges[g+f],k=h+i;if(a<=k){let e=i?a==h?-1:a==k?1:b:b,f=h+d+(e<0?0:j);if(c)return f;let l=a==(b<0?h:k)?null:g/3+(a-h)*65536,m=a==h?2:a==k?1:4;return(b<0?a!=h:a!=k)&&(m|=8),new aO(f,m,l)}d+=j-i}return c?a+d:new aO(a+d,0,null)}touches(a,b){let c=0,d=65535&b,e=this.inverted?2:1,f=this.inverted?1:2;for(let b=0;b<this.ranges.length;b+=3){let g=this.ranges[b]-(this.inverted?c:0);if(g>a)break;let h=this.ranges[b+e];if(a<=g+h&&b==3*d)return!0;c+=this.ranges[b+f]-h}return!1}forEach(a){let b=this.inverted?2:1,c=this.inverted?1:2;for(let d=0,e=0;d<this.ranges.length;d+=3){let f=this.ranges[d],g=f-(this.inverted?e:0),h=f+(this.inverted?0:e),i=this.ranges[d+b],j=this.ranges[d+c];a(g,g+i,h,h+j),e+=j-i}}invert(){return new aP(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(a){return 0==a?aP.empty:new aP(a<0?[0,-a,0]:[0,0,a])}}aP.empty=new aP([]);class aQ{constructor(a,b,c=0,d=a?a.length:0){this.mirror=b,this.from=c,this.to=d,this._maps=a||[],this.ownData=!(a||b)}get maps(){return this._maps}slice(a=0,b=this.maps.length){return new aQ(this._maps,this.mirror,a,b)}appendMap(a,b){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(a),null!=b&&this.setMirror(this._maps.length-1,b)}appendMapping(a){for(let b=0,c=this._maps.length;b<a._maps.length;b++){let d=a.getMirror(b);this.appendMap(a._maps[b],null!=d&&d<b?c+d:void 0)}}getMirror(a){if(this.mirror){for(let b=0;b<this.mirror.length;b++)if(this.mirror[b]==a)return this.mirror[b+(b%2?-1:1)]}}setMirror(a,b){this.mirror||(this.mirror=[]),this.mirror.push(a,b)}appendMappingInverted(a){for(let b=a.maps.length-1,c=this._maps.length+a._maps.length;b>=0;b--){let d=a.getMirror(b);this.appendMap(a._maps[b].invert(),null!=d&&d>b?c-d-1:void 0)}}invert(){let a=new aQ;return a.appendMappingInverted(this),a}map(a,b=1){if(this.mirror)return this._map(a,b,!0);for(let c=this.from;c<this.to;c++)a=this._maps[c].map(a,b);return a}mapResult(a,b=1){return this._map(a,b,!1)}_map(a,b,c){let d=0;for(let c=this.from;c<this.to;c++){let e=this._maps[c].mapResult(a,b);if(null!=e.recover){let b=this.getMirror(c);if(null!=b&&b>c&&b<this.to){c=b,a=this._maps[b].recover(e.recover);continue}}d|=e.delInfo,a=e.pos}return c?a:new aO(a,d,null)}}let aR=Object.create(null);class aS{getMap(){return aP.empty}merge(a){return null}static fromJSON(a,b){if(!b||!b.stepType)throw RangeError("Invalid input for Step.fromJSON");let c=aR[b.stepType];if(!c)throw RangeError(`No step type ${b.stepType} defined`);return c.fromJSON(a,b)}static jsonID(a,b){if(a in aR)throw RangeError("Duplicate use of step JSON ID "+a);return aR[a]=b,b.prototype.jsonID=a,b}}class aT{constructor(a,b){this.doc=a,this.failed=b}static ok(a){return new aT(a,null)}static fail(a){return new aT(null,a)}static fromReplace(a,b,c,d){try{return aT.ok(a.replace(b,c,d))}catch(a){if(a instanceof X)return aT.fail(a.message);throw a}}}function aU(a,b,c){let d=[];for(let e=0;e<a.childCount;e++){let f=a.child(e);f.content.size&&(f=f.copy(aU(f.content,b,f))),f.isInline&&(f=b(f,c,e)),d.push(f)}return S.fromArray(d)}class aV extends aS{constructor(a,b,c){super(),this.from=a,this.to=b,this.mark=c}apply(a){let b=a.slice(this.from,this.to),c=a.resolve(this.from),d=c.node(c.sharedDepth(this.to)),e=new Y(aU(b.content,(a,b)=>a.isAtom&&b.type.allowsMarkType(this.mark.type)?a.mark(this.mark.addToSet(a.marks)):a,d),b.openStart,b.openEnd);return aT.fromReplace(a,this.from,this.to,e)}invert(){return new aW(this.from,this.to,this.mark)}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1);return b.deleted&&c.deleted||b.pos>=c.pos?null:new aV(b.pos,c.pos,this.mark)}merge(a){return a instanceof aV&&a.mark.eq(this.mark)&&this.from<=a.to&&this.to>=a.from?new aV(Math.min(this.from,a.from),Math.max(this.to,a.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to)throw RangeError("Invalid input for AddMarkStep.fromJSON");return new aV(b.from,b.to,a.markFromJSON(b.mark))}}aS.jsonID("addMark",aV);class aW extends aS{constructor(a,b,c){super(),this.from=a,this.to=b,this.mark=c}apply(a){let b=a.slice(this.from,this.to),c=new Y(aU(b.content,a=>a.mark(this.mark.removeFromSet(a.marks)),a),b.openStart,b.openEnd);return aT.fromReplace(a,this.from,this.to,c)}invert(){return new aV(this.from,this.to,this.mark)}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1);return b.deleted&&c.deleted||b.pos>=c.pos?null:new aW(b.pos,c.pos,this.mark)}merge(a){return a instanceof aW&&a.mark.eq(this.mark)&&this.from<=a.to&&this.to>=a.from?new aW(Math.min(this.from,a.from),Math.max(this.to,a.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to)throw RangeError("Invalid input for RemoveMarkStep.fromJSON");return new aW(b.from,b.to,a.markFromJSON(b.mark))}}aS.jsonID("removeMark",aW);class aX extends aS{constructor(a,b){super(),this.pos=a,this.mark=b}apply(a){let b=a.nodeAt(this.pos);if(!b)return aT.fail("No node at mark step's position");let c=b.type.create(b.attrs,null,this.mark.addToSet(b.marks));return aT.fromReplace(a,this.pos,this.pos+1,new Y(S.from(c),0,+!b.isLeaf))}invert(a){let b=a.nodeAt(this.pos);if(b){let a=this.mark.addToSet(b.marks);if(a.length==b.marks.length){for(let c=0;c<b.marks.length;c++)if(!b.marks[c].isInSet(a))return new aX(this.pos,b.marks[c]);return new aX(this.pos,this.mark)}}return new aY(this.pos,this.mark)}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new aX(b.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(a,b){if("number"!=typeof b.pos)throw RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new aX(b.pos,a.markFromJSON(b.mark))}}aS.jsonID("addNodeMark",aX);class aY extends aS{constructor(a,b){super(),this.pos=a,this.mark=b}apply(a){let b=a.nodeAt(this.pos);if(!b)return aT.fail("No node at mark step's position");let c=b.type.create(b.attrs,null,this.mark.removeFromSet(b.marks));return aT.fromReplace(a,this.pos,this.pos+1,new Y(S.from(c),0,+!b.isLeaf))}invert(a){let b=a.nodeAt(this.pos);return b&&this.mark.isInSet(b.marks)?new aX(this.pos,this.mark):this}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new aY(b.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(a,b){if("number"!=typeof b.pos)throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new aY(b.pos,a.markFromJSON(b.mark))}}aS.jsonID("removeNodeMark",aY);class aZ extends aS{constructor(a,b,c,d=!1){super(),this.from=a,this.to=b,this.slice=c,this.structure=d}apply(a){return this.structure&&a_(a,this.from,this.to)?aT.fail("Structure replace would overwrite content"):aT.fromReplace(a,this.from,this.to,this.slice)}getMap(){return new aP([this.from,this.to-this.from,this.slice.size])}invert(a){return new aZ(this.from,this.from+this.slice.size,a.slice(this.from,this.to))}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1);return b.deletedAcross&&c.deletedAcross?null:new aZ(b.pos,Math.max(b.pos,c.pos),this.slice,this.structure)}merge(a){if(!(a instanceof aZ)||a.structure||this.structure)return null;if(this.from+this.slice.size!=a.from||this.slice.openEnd||a.slice.openStart)if(a.to!=this.from||this.slice.openStart||a.slice.openEnd)return null;else{let b=this.slice.size+a.slice.size==0?Y.empty:new Y(a.slice.content.append(this.slice.content),a.slice.openStart,this.slice.openEnd);return new aZ(a.from,this.to,b,this.structure)}{let b=this.slice.size+a.slice.size==0?Y.empty:new Y(this.slice.content.append(a.slice.content),this.slice.openStart,a.slice.openEnd);return new aZ(this.from,this.to+(a.to-a.from),b,this.structure)}}toJSON(){let a={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(a.slice=this.slice.toJSON()),this.structure&&(a.structure=!0),a}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to)throw RangeError("Invalid input for ReplaceStep.fromJSON");return new aZ(b.from,b.to,Y.fromJSON(a,b.slice),!!b.structure)}}aS.jsonID("replace",aZ);class a$ extends aS{constructor(a,b,c,d,e,f,g=!1){super(),this.from=a,this.to=b,this.gapFrom=c,this.gapTo=d,this.slice=e,this.insert=f,this.structure=g}apply(a){if(this.structure&&(a_(a,this.from,this.gapFrom)||a_(a,this.gapTo,this.to)))return aT.fail("Structure gap-replace would overwrite content");let b=a.slice(this.gapFrom,this.gapTo);if(b.openStart||b.openEnd)return aT.fail("Gap is not a flat range");let c=this.slice.insertAt(this.insert,b.content);return c?aT.fromReplace(a,this.from,this.to,c):aT.fail("Content does not fit in gap")}getMap(){return new aP([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(a){let b=this.gapTo-this.gapFrom;return new a$(this.from,this.from+this.slice.size+b,this.from+this.insert,this.from+this.insert+b,a.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1),d=this.from==this.gapFrom?b.pos:a.map(this.gapFrom,-1),e=this.to==this.gapTo?c.pos:a.map(this.gapTo,1);return b.deletedAcross&&c.deletedAcross||d<b.pos||e>c.pos?null:new a$(b.pos,c.pos,d,e,this.slice,this.insert,this.structure)}toJSON(){let a={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(a.slice=this.slice.toJSON()),this.structure&&(a.structure=!0),a}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to||"number"!=typeof b.gapFrom||"number"!=typeof b.gapTo||"number"!=typeof b.insert)throw RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new a$(b.from,b.to,b.gapFrom,b.gapTo,Y.fromJSON(a,b.slice),b.insert,!!b.structure)}}function a_(a,b,c){let d=a.resolve(b),e=c-b,f=d.depth;for(;e>0&&f>0&&d.indexAfter(f)==d.node(f).childCount;)f--,e--;if(e>0){let a=d.node(f).maybeChild(d.indexAfter(f));for(;e>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,e--}}return!1}function a0(a,b,c,d=c.contentMatch,e=!0){let f=a.doc.nodeAt(b),g=[],h=b+1;for(let b=0;b<f.childCount;b++){let i=f.child(b),j=h+i.nodeSize,k=d.matchType(i.type);if(k){d=k;for(let b=0;b<i.marks.length;b++)c.allowsMarkType(i.marks[b].type)||a.step(new aW(h,j,i.marks[b]));if(e&&i.isText&&"pre"!=c.whitespace){let a,b=/\r?\n|\r/g,d;for(;a=b.exec(i.text);)d||(d=new Y(S.from(c.schema.text(" ",c.allowedMarks(i.marks))),0,0)),g.push(new aZ(h+a.index,h+a.index+a[0].length,d))}}else g.push(new aZ(h,j,Y.empty));h=j}if(!d.validEnd){let b=d.fillBefore(S.empty,!0);a.replace(h,h,new Y(b,0,0))}for(let b=g.length-1;b>=0;b--)a.step(g[b])}function a1(a){let b=a.parent.content.cutByIndex(a.startIndex,a.endIndex);for(let c=a.depth,d=0,e=0;;--c){let f=a.$from.node(c),g=a.$from.index(c)+d,h=a.$to.indexAfter(c)-e;if(c<a.depth&&f.canReplace(g,h,b))return c;if(0==c||f.type.spec.isolating||!((0==g||f.canReplace(g,f.childCount))&&(h==f.childCount||f.canReplace(0,h))))break;g&&(d=1),h<f.childCount&&(e=1)}return null}function a2(a,b,c=null,d=a){let e=function(a,b){let{parent:c,startIndex:d,endIndex:e}=a,f=c.contentMatchAt(d).findWrapping(b);if(!f)return null;let g=f.length?f[0]:b;return c.canReplaceWith(d,e,g)?f:null}(a,b),f=e&&function(a,b){let{parent:c,startIndex:d,endIndex:e}=a,f=c.child(d),g=b.contentMatch.findWrapping(f.type);if(!g)return null;let h=(g.length?g[g.length-1]:b).contentMatch;for(let a=d;h&&a<e;a++)h=h.matchType(c.child(a).type);return h&&h.validEnd?g:null}(d,b);return f?e.map(a3).concat({type:b,attrs:c}).concat(f.map(a3)):null}function a3(a){return{type:a,attrs:null}}function a4(a,b,c,d){b.forEach((e,f)=>{if(e.isText){let g,h=/\r?\n|\r/g;for(;g=h.exec(e.text);){let e=a.mapping.slice(d).map(c+1+f+g.index);a.replaceWith(e,e+1,b.type.schema.linebreakReplacement.create())}}})}function a5(a,b,c,d){b.forEach((e,f)=>{if(e.type==e.type.schema.linebreakReplacement){let e=a.mapping.slice(d).map(c+1+f);a.replaceWith(e,e+1,b.type.schema.text("\n"))}})}function a6(a,b,c=1,d){let e=a.resolve(b),f=e.depth-c,g=d&&d[d.length-1]||e.parent;if(f<0||e.parent.type.spec.isolating||!e.parent.canReplace(e.index(),e.parent.childCount)||!g.type.validContent(e.parent.content.cutByIndex(e.index(),e.parent.childCount)))return!1;for(let a=e.depth-1,b=c-2;a>f;a--,b--){let c=e.node(a),f=e.index(a);if(c.type.spec.isolating)return!1;let g=c.content.cutByIndex(f,c.childCount),h=d&&d[b+1];h&&(g=g.replaceChild(0,h.type.create(h.attrs)));let i=d&&d[b]||c;if(!c.canReplace(f+1,c.childCount)||!i.type.validContent(g))return!1}let h=e.indexAfter(f),i=d&&d[0];return e.node(f).canReplaceWith(h,h,i?i.type:e.node(f+1).type)}function a7(a,b){let c=a.resolve(b),d=c.index();return a8(c.nodeBefore,c.nodeAfter)&&c.parent.canReplace(d,d+1)}function a8(a,b){return!!(a&&b&&!a.isLeaf&&function(a,b){b.content.size||a.type.compatibleContent(b.type);let c=a.contentMatchAt(a.childCount),{linebreakReplacement:d}=a.type.schema;for(let e=0;e<b.childCount;e++){let f=b.child(e),g=f.type==d?a.type.schema.nodes.text:f.type;if(!(c=c.matchType(g))||!a.type.allowsMarks(f.marks))return!1}return c.validEnd}(a,b))}function a9(a,b,c=-1){let d=a.resolve(b);for(let a=d.depth;;a--){let e,f,g=d.index(a);if(a==d.depth?(e=d.nodeBefore,f=d.nodeAfter):c>0?(e=d.node(a+1),g++,f=d.node(a).maybeChild(g)):(e=d.node(a).maybeChild(g-1),f=d.node(a+1)),e&&!e.isTextblock&&a8(e,f)&&d.node(a).canReplace(g,g+1))return b;if(0==a)break;b=c<0?d.before(a):d.after(a)}}function ba(a,b,c){let d=a.resolve(b);if(!c.content.size)return b;let e=c.content;for(let a=0;a<c.openStart;a++)e=e.firstChild.content;for(let a=1;a<=(0==c.openStart&&c.size?2:1);a++)for(let b=d.depth;b>=0;b--){let c=b==d.depth?0:d.pos<=(d.start(b+1)+d.end(b+1))/2?-1:1,f=d.index(b)+ +(c>0),g=d.node(b),h=!1;if(1==a)h=g.canReplace(f,f,e);else{let a=g.contentMatchAt(f).findWrapping(e.firstChild.type);h=a&&g.canReplaceWith(f,f,a[0])}if(h)return 0==c?d.pos:c<0?d.before(b+1):d.after(b+1)}return null}function bb(a,b,c=b,d=Y.empty){if(b==c&&!d.size)return null;let e=a.resolve(b),f=a.resolve(c);return bc(e,f,d)?new aZ(b,c,d):new bd(e,f,d).fit()}function bc(a,b,c){return!c.openStart&&!c.openEnd&&a.start()==b.start()&&a.parent.canReplace(a.index(),b.index(),c.content)}aS.jsonID("replaceAround",a$);class bd{constructor(a,b,c){this.$from=a,this.$to=b,this.unplaced=c,this.frontier=[],this.placed=S.empty;for(let b=0;b<=a.depth;b++){let c=a.node(b);this.frontier.push({type:c.type,match:c.contentMatchAt(a.indexAfter(b))})}for(let b=a.depth;b>0;b--)this.placed=S.from(a.node(b).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let a=this.findFittable();a?this.placeNodes(a):this.openMore()||this.dropNode()}let a=this.mustMoveInline(),b=this.placed.size-this.depth-this.$from.depth,c=this.$from,d=this.close(a<0?this.$to:c.doc.resolve(a));if(!d)return null;let e=this.placed,f=c.depth,g=d.depth;for(;f&&g&&1==e.childCount;)e=e.firstChild.content,f--,g--;let h=new Y(e,f,g);return a>-1?new a$(c.pos,a,this.$to.pos,this.$to.end(),h,b):h.size||c.pos!=this.$to.pos?new aZ(c.pos,d.pos,h):null}findFittable(){let a=this.unplaced.openStart;for(let b=this.unplaced.content,c=0,d=this.unplaced.openEnd;c<a;c++){let e=b.firstChild;if(b.childCount>1&&(d=0),e.type.spec.isolating&&d<=c){a=c;break}b=e.content}for(let b=1;b<=2;b++)for(let c=1==b?a:this.unplaced.openStart;c>=0;c--){let a=null,d=(c?(a=bg(this.unplaced.content,c-1).firstChild).content:this.unplaced.content).firstChild;for(let e=this.depth;e>=0;e--){let{type:f,match:g}=this.frontier[e],h,i=null;if(1==b&&(d?g.matchType(d.type)||(i=g.fillBefore(S.from(d),!1)):a&&f.compatibleContent(a.type)))return{sliceDepth:c,frontierDepth:e,parent:a,inject:i};if(2==b&&d&&(h=g.findWrapping(d.type)))return{sliceDepth:c,frontierDepth:e,parent:a,wrap:h};if(a&&g.matchType(a.type))break}}}openMore(){let{content:a,openStart:b,openEnd:c}=this.unplaced,d=bg(a,b);return!!d.childCount&&!d.firstChild.isLeaf&&(this.unplaced=new Y(a,b+1,Math.max(c,d.size+b>=a.size-c?b+1:0)),!0)}dropNode(){let{content:a,openStart:b,openEnd:c}=this.unplaced,d=bg(a,b);if(d.childCount<=1&&b>0){let e=a.size-b<=b+d.size;this.unplaced=new Y(be(a,b-1,1),b-1,e?b-1:c)}else this.unplaced=new Y(be(a,b,1),b,c)}placeNodes({sliceDepth:a,frontierDepth:b,parent:c,inject:d,wrap:e}){for(;this.depth>b;)this.closeFrontierNode();if(e)for(let a=0;a<e.length;a++)this.openFrontierNode(e[a]);let f=this.unplaced,g=c?c.content:f.content,h=f.openStart-a,i=0,j=[],{match:k,type:l}=this.frontier[b];if(d){for(let a=0;a<d.childCount;a++)j.push(d.child(a));k=k.matchFragment(d)}let m=g.size+a-(f.content.size-f.openEnd);for(;i<g.childCount;){let a=g.child(i),b=k.matchType(a.type);if(!b)break;(++i>1||0==h||a.content.size)&&(k=b,j.push(function a(b,c,d){if(c<=0)return b;let e=b.content;return c>1&&(e=e.replaceChild(0,a(e.firstChild,c-1,1==e.childCount?d-1:0))),c>0&&(e=b.type.contentMatch.fillBefore(e).append(e),d<=0&&(e=e.append(b.type.contentMatch.matchFragment(e).fillBefore(S.empty,!0)))),b.copy(e)}(a.mark(l.allowedMarks(a.marks)),1==i?h:0,i==g.childCount?m:-1)))}let n=i==g.childCount;n||(m=-1),this.placed=bf(this.placed,b,S.from(j)),this.frontier[b].match=k,n&&m<0&&c&&c.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let a=0,b=g;a<m;a++){let a=b.lastChild;this.frontier.push({type:a.type,match:a.contentMatchAt(a.childCount)}),b=a.content}this.unplaced=n?0==a?Y.empty:new Y(be(f.content,a-1,1),a-1,m<0?f.openEnd:a-1):new Y(be(f.content,a,i),f.openStart,f.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return -1;let a=this.frontier[this.depth],b;if(!a.type.isTextblock||!bh(this.$to,this.$to.depth,a.type,a.match,!1)||this.$to.depth==this.depth&&(b=this.findCloseLevel(this.$to))&&b.depth==this.depth)return -1;let{depth:c}=this.$to,d=this.$to.after(c);for(;c>1&&d==this.$to.end(--c);)++d;return d}findCloseLevel(a){b:for(let b=Math.min(this.depth,a.depth);b>=0;b--){let{match:c,type:d}=this.frontier[b],e=b<a.depth&&a.end(b+1)==a.pos+(a.depth-(b+1)),f=bh(a,b,d,c,e);if(f){for(let c=b-1;c>=0;c--){let{match:b,type:d}=this.frontier[c],e=bh(a,c,d,b,!0);if(!e||e.childCount)continue b}return{depth:b,fit:f,move:e?a.doc.resolve(a.after(b+1)):a}}}}close(a){let b=this.findCloseLevel(a);if(!b)return null;for(;this.depth>b.depth;)this.closeFrontierNode();b.fit.childCount&&(this.placed=bf(this.placed,b.depth,b.fit)),a=b.move;for(let c=b.depth+1;c<=a.depth;c++){let b=a.node(c),d=b.type.contentMatch.fillBefore(b.content,!0,a.index(c));this.openFrontierNode(b.type,b.attrs,d)}return a}openFrontierNode(a,b=null,c){let d=this.frontier[this.depth];d.match=d.match.matchType(a),this.placed=bf(this.placed,this.depth,S.from(a.create(b,c))),this.frontier.push({type:a,match:a.contentMatch})}closeFrontierNode(){let a=this.frontier.pop().match.fillBefore(S.empty,!0);a.childCount&&(this.placed=bf(this.placed,this.frontier.length,a))}}function be(a,b,c){return 0==b?a.cutByIndex(c,a.childCount):a.replaceChild(0,a.firstChild.copy(be(a.firstChild.content,b-1,c)))}function bf(a,b,c){return 0==b?a.append(c):a.replaceChild(a.childCount-1,a.lastChild.copy(bf(a.lastChild.content,b-1,c)))}function bg(a,b){for(let c=0;c<b;c++)a=a.firstChild.content;return a}function bh(a,b,c,d,e){let f=a.node(b),g=e?a.indexAfter(b):a.index(b);if(g==f.childCount&&!c.compatibleContent(f.type))return null;let h=d.fillBefore(f.content,!0,g);return h&&!function(a,b,c){for(let d=c;d<b.childCount;d++)if(!a.allowsMarks(b.child(d).marks))return!0;return!1}(c,f.content,g)?h:null}function bi(a,b){let c=[],d=Math.min(a.depth,b.depth);for(let e=d;e>=0;e--){let d=a.start(e);if(d<a.pos-(a.depth-e)||b.end(e)>b.pos+(b.depth-e)||a.node(e).type.spec.isolating||b.node(e).type.spec.isolating)break;(d==b.start(e)||e==a.depth&&e==b.depth&&a.parent.inlineContent&&b.parent.inlineContent&&e&&b.start(e-1)==d-1)&&c.push(e)}return c}class bj extends aS{constructor(a,b,c){super(),this.pos=a,this.attr=b,this.value=c}apply(a){let b=a.nodeAt(this.pos);if(!b)return aT.fail("No node at attribute step's position");let c=Object.create(null);for(let a in b.attrs)c[a]=b.attrs[a];c[this.attr]=this.value;let d=b.type.create(c,null,b.marks);return aT.fromReplace(a,this.pos,this.pos+1,new Y(S.from(d),0,+!b.isLeaf))}getMap(){return aP.empty}invert(a){return new bj(this.pos,this.attr,a.nodeAt(this.pos).attrs[this.attr])}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new bj(b.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(a,b){if("number"!=typeof b.pos||"string"!=typeof b.attr)throw RangeError("Invalid input for AttrStep.fromJSON");return new bj(b.pos,b.attr,b.value)}}aS.jsonID("attr",bj);class bk extends aS{constructor(a,b){super(),this.attr=a,this.value=b}apply(a){let b=Object.create(null);for(let c in a.attrs)b[c]=a.attrs[c];b[this.attr]=this.value;let c=a.type.create(b,a.content,a.marks);return aT.ok(c)}getMap(){return aP.empty}invert(a){return new bk(this.attr,a.attrs[this.attr])}map(a){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(a,b){if("string"!=typeof b.attr)throw RangeError("Invalid input for DocAttrStep.fromJSON");return new bk(b.attr,b.value)}}aS.jsonID("docAttr",bk);let bl=class extends Error{};(bl=function a(b){let c=Error.call(this,b);return c.__proto__=a.prototype,c}).prototype=Object.create(Error.prototype),bl.prototype.constructor=bl,bl.prototype.name="TransformError";class bm{constructor(a){this.doc=a,this.steps=[],this.docs=[],this.mapping=new aQ}get before(){return this.docs.length?this.docs[0]:this.doc}step(a){let b=this.maybeStep(a);if(b.failed)throw new bl(b.failed);return this}maybeStep(a){let b=a.apply(this.doc);return b.failed||this.addStep(a,b.doc),b}get docChanged(){return this.steps.length>0}changedRange(){let a=1e9,b=-1e9;for(let c=0;c<this.mapping.maps.length;c++){let d=this.mapping.maps[c];c&&(a=d.map(a,1),b=d.map(b,-1)),d.forEach((c,d,e,f)=>{a=Math.min(a,e),b=Math.max(b,f)})}return 1e9==a?null:{from:a,to:b}}addStep(a,b){this.docs.push(this.doc),this.steps.push(a),this.mapping.appendMap(a.getMap()),this.doc=b}replace(a,b=a,c=Y.empty){let d=bb(this.doc,a,b,c);return d&&this.step(d),this}replaceWith(a,b,c){return this.replace(a,b,new Y(S.from(c),0,0))}delete(a,b){return this.replace(a,b,Y.empty)}insert(a,b){return this.replaceWith(a,a,b)}replaceRange(a,b,c){return!function(a,b,c,d){if(!d.size)return a.deleteRange(b,c);let e=a.doc.resolve(b),f=a.doc.resolve(c);if(bc(e,f,d))return a.step(new aZ(b,c,d));let g=bi(e,f);0==g[g.length-1]&&g.pop();let h=-(e.depth+1);g.unshift(h);for(let a=e.depth,b=e.pos-1;a>0;a--,b--){let c=e.node(a).type.spec;if(c.defining||c.definingAsContext||c.isolating)break;g.indexOf(a)>-1?h=a:e.before(a)==b&&g.splice(1,0,-a)}let i=g.indexOf(h),j=[],k=d.openStart;for(let a=d.content,b=0;;b++){let c=a.firstChild;if(j.push(c),b==d.openStart)break;a=c.content}for(let a=k-1;a>=0;a--){var l;let b=j[a],c=(l=b.type).spec.defining||l.spec.definingForContent;if(c&&!b.sameMarkup(e.node(Math.abs(h)-1)))k=a;else if(c||!b.type.isTextblock)break}for(let b=d.openStart;b>=0;b--){let h=(b+k+1)%(d.openStart+1),l=j[h];if(l)for(let b=0;b<g.length;b++){let j=g[(b+i)%g.length],k=!0;j<0&&(k=!1,j=-j);let m=e.node(j-1),n=e.index(j-1);if(m.canReplaceWith(n,n,l.type,l.marks))return a.replace(e.before(j),k?f.after(j):c,new Y(function a(b,c,d,e,f){if(c<d){let f=b.firstChild;b=b.replaceChild(0,f.copy(a(f.content,c+1,d,e,f)))}if(c>e){let a=f.contentMatchAt(0),c=a.fillBefore(b).append(b);b=c.append(a.matchFragment(c).fillBefore(S.empty,!0))}return b}(d.content,0,d.openStart,h),h,d.openEnd))}}let m=a.steps.length;for(let h=g.length-1;h>=0&&(a.replace(b,c,d),!(a.steps.length>m));h--){let a=g[h];a<0||(b=e.before(a),c=f.after(a))}}(this,a,b,c),this}replaceRangeWith(a,b,c){var d=a,e=b;if(!c.isInline&&d==e&&this.doc.resolve(d).parent.content.size){let a=function(a,b,c){let d=a.resolve(b);if(d.parent.canReplaceWith(d.index(),d.index(),c))return b;if(0==d.parentOffset)for(let a=d.depth-1;a>=0;a--){let b=d.index(a);if(d.node(a).canReplaceWith(b,b,c))return d.before(a+1);if(b>0)return null}if(d.parentOffset==d.parent.content.size)for(let a=d.depth-1;a>=0;a--){let b=d.indexAfter(a);if(d.node(a).canReplaceWith(b,b,c))return d.after(a+1);if(b<d.node(a).childCount)break}return null}(this.doc,d,c.type);null!=a&&(d=e=a)}return this.replaceRange(d,e,new Y(S.from(c),0,0)),this}deleteRange(a,b){return!function(a,b,c){let d=a.doc.resolve(b),e=a.doc.resolve(c),f=bi(d,e);for(let b=0;b<f.length;b++){let c=f[b],g=b==f.length-1;if(g&&0==c||d.node(c).type.contentMatch.validEnd)return a.delete(d.start(c),e.end(c));if(c>0&&(g||d.node(c-1).canReplace(d.index(c-1),e.indexAfter(c-1))))return a.delete(d.before(c),e.after(c))}for(let f=1;f<=d.depth&&f<=e.depth;f++)if(b-d.start(f)==d.depth-f&&c>d.end(f)&&e.end(f)-c!=e.depth-f&&d.start(f-1)==e.start(f-1)&&d.node(f-1).canReplace(d.index(f-1),e.index(f-1)))return a.delete(d.before(f),c);a.delete(b,c)}(this,a,b),this}lift(a,b){return!function(a,b,c){let{$from:d,$to:e,depth:f}=b,g=d.before(f+1),h=e.after(f+1),i=g,j=h,k=S.empty,l=0;for(let a=f,b=!1;a>c;a--)b||d.index(a)>0?(b=!0,k=S.from(d.node(a).copy(k)),l++):i--;let m=S.empty,n=0;for(let a=f,b=!1;a>c;a--)b||e.after(a+1)<e.end(a)?(b=!0,m=S.from(e.node(a).copy(m)),n++):j++;a.step(new a$(i,j,g,h,new Y(k.append(m),l,n),k.size-l,!0))}(this,a,b),this}join(a,b=1){return!function(a,b,c){let d=null,{linebreakReplacement:e}=a.doc.type.schema,f=a.doc.resolve(b-c),g=f.node().type;if(e&&g.inlineContent){let a="pre"==g.whitespace,b=!!g.contentMatch.matchType(e);a&&!b?d=!1:!a&&b&&(d=!0)}let h=a.steps.length;if(!1===d){let d=a.doc.resolve(b+c);a5(a,d.node(),d.before(),h)}g.inlineContent&&a0(a,b+c-1,g,f.node().contentMatchAt(f.index()),null==d);let i=a.mapping.slice(h),j=i.map(b-c);if(a.step(new aZ(j,i.map(b+c,-1),Y.empty,!0)),!0===d){let b=a.doc.resolve(j);a4(a,b.node(),b.before(),a.steps.length)}}(this,a,b),this}wrap(a,b){return!function(a,b,c){let d=S.empty;for(let a=c.length-1;a>=0;a--){if(d.size){let b=c[a].type.contentMatch.matchFragment(d);if(!b||!b.validEnd)throw RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}d=S.from(c[a].type.create(c[a].attrs,d))}let e=b.start,f=b.end;a.step(new a$(e,f,e,f,new Y(d,0,0),c.length,!0))}(this,a,b),this}setBlockType(a,b=a,c,d=null){var e=this;if(!c.isTextblock)throw RangeError("Type given to setBlockType should be a textblock");let f=e.steps.length;return e.doc.nodesBetween(a,b,(a,b)=>{var g,h,i;let j,k,l="function"==typeof d?d(a):d;if(a.isTextblock&&!a.hasMarkup(c,l)&&(g=e.doc,h=e.mapping.slice(f).map(b),i=c,k=(j=g.resolve(h)).index(),j.parent.canReplaceWith(k,k+1,i))){let d=null;if(c.schema.linebreakReplacement){let a="pre"==c.whitespace,b=!!c.contentMatch.matchType(c.schema.linebreakReplacement);a&&!b?d=!1:!a&&b&&(d=!0)}!1===d&&a5(e,a,b,f),a0(e,e.mapping.slice(f).map(b,1),c,void 0,null===d);let g=e.mapping.slice(f),h=g.map(b,1),i=g.map(b+a.nodeSize,1);return e.step(new a$(h,i,h+1,i-1,new Y(S.from(c.create(l,null,a.marks)),0,0),1,!0)),!0===d&&a4(e,a,b,f),!1}}),this}setNodeMarkup(a,b,c=null,d){return!function(a,b,c,d,e){let f=a.doc.nodeAt(b);if(!f)throw RangeError("No node at given position");c||(c=f.type);let g=c.create(d,null,e||f.marks);if(f.isLeaf)return a.replaceWith(b,b+f.nodeSize,g);if(!c.validContent(f.content))throw RangeError("Invalid content for node type "+c.name);a.step(new a$(b,b+f.nodeSize,b+1,b+f.nodeSize-1,new Y(S.from(g),0,0),1,!0))}(this,a,b,c,d),this}setNodeAttribute(a,b,c){return this.step(new bj(a,b,c)),this}setDocAttribute(a,b){return this.step(new bk(a,b)),this}addNodeMark(a,b){return this.step(new aX(a,b)),this}removeNodeMark(a,b){let c=this.doc.nodeAt(a);if(!c)throw RangeError("No node at position "+a);if(b instanceof W)b.isInSet(c.marks)&&this.step(new aY(a,b));else{let d=c.marks,e,f=[];for(;e=b.isInSet(d);)f.push(new aY(a,e)),d=e.removeFromSet(d);for(let a=f.length-1;a>=0;a--)this.step(f[a])}return this}split(a,b=1,c){return!function(a,b,c=1,d){let e=a.doc.resolve(b),f=S.empty,g=S.empty;for(let a=e.depth,b=e.depth-c,h=c-1;a>b;a--,h--){f=S.from(e.node(a).copy(f));let b=d&&d[h];g=S.from(b?b.type.create(b.attrs,g):e.node(a).copy(g))}a.step(new aZ(b,b,new Y(f.append(g),c,c),!0))}(this,a,b,c),this}addMark(a,b,c){var d;let e,f,g,h;return d=this,g=[],h=[],d.doc.nodesBetween(a,b,(d,i,j)=>{if(!d.isInline)return;let k=d.marks;if(!c.isInSet(k)&&j.type.allowsMarkType(c.type)){let j=Math.max(i,a),l=Math.min(i+d.nodeSize,b),m=c.addToSet(k);for(let a=0;a<k.length;a++)k[a].isInSet(m)||(e&&e.to==j&&e.mark.eq(k[a])?e.to=l:g.push(e=new aW(j,l,k[a])));f&&f.to==j?f.to=l:h.push(f=new aV(j,l,c))}}),g.forEach(a=>d.step(a)),h.forEach(a=>d.step(a)),this}removeMark(a,b,c){var d;let e,f;return d=this,e=[],f=0,d.doc.nodesBetween(a,b,(d,g)=>{if(!d.isInline)return;f++;let h=null;if(c instanceof ax){let a=d.marks,b;for(;b=c.isInSet(a);)(h||(h=[])).push(b),a=b.removeFromSet(a)}else c?c.isInSet(d.marks)&&(h=[c]):h=d.marks;if(h&&h.length){let c=Math.min(g+d.nodeSize,b);for(let b=0;b<h.length;b++){let d=h[b],i;for(let a=0;a<e.length;a++){let b=e[a];b.step==f-1&&d.eq(e[a].style)&&(i=b)}i?(i.to=c,i.step=f):e.push({style:d,from:Math.max(g,a),to:c,step:f})}}}),e.forEach(a=>d.step(new aW(a.from,a.to,a.style))),this}clearIncompatible(a,b,c){return a0(this,a,b,c),this}}let bn=Object.create(null);class bo{constructor(a,b,c){this.$anchor=a,this.$head=b,this.ranges=c||[new bp(a.min(b),a.max(b))]}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 a=this.ranges;for(let b=0;b<a.length;b++)if(a[b].$from.pos!=a[b].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(a,b=Y.empty){let c=b.content.lastChild,d=null;for(let a=0;a<b.openEnd;a++)d=c,c=c.lastChild;let e=a.steps.length,f=this.ranges;for(let g=0;g<f.length;g++){let{$from:h,$to:i}=f[g],j=a.mapping.slice(e);a.replaceRange(j.map(h.pos),j.map(i.pos),g?Y.empty:b),0==g&&bz(a,e,(c?c.isInline:d&&d.isTextblock)?-1:1)}}replaceWith(a,b){let c=a.steps.length,d=this.ranges;for(let e=0;e<d.length;e++){let{$from:f,$to:g}=d[e],h=a.mapping.slice(c),i=h.map(f.pos),j=h.map(g.pos);e?a.deleteRange(i,j):(a.replaceRangeWith(i,j,b),bz(a,c,b.isInline?-1:1))}}static findFrom(a,b,c=!1){let d=a.parent.inlineContent?new bs(a):by(a.node(0),a.parent,a.pos,a.index(),b,c);if(d)return d;for(let d=a.depth-1;d>=0;d--){let e=b<0?by(a.node(0),a.node(d),a.before(d+1),a.index(d),b,c):by(a.node(0),a.node(d),a.after(d+1),a.index(d)+1,b,c);if(e)return e}return null}static near(a,b=1){return this.findFrom(a,b)||this.findFrom(a,-b)||new bw(a.node(0))}static atStart(a){return by(a,a,0,0,1)||new bw(a)}static atEnd(a){return by(a,a,a.content.size,a.childCount,-1)||new bw(a)}static fromJSON(a,b){if(!b||!b.type)throw RangeError("Invalid input for Selection.fromJSON");let c=bn[b.type];if(!c)throw RangeError(`No selection type ${b.type} defined`);return c.fromJSON(a,b)}static jsonID(a,b){if(a in bn)throw RangeError("Duplicate use of selection JSON ID "+a);return bn[a]=b,b.prototype.jsonID=a,b}getBookmark(){return bs.between(this.$anchor,this.$head).getBookmark()}}bo.prototype.visible=!0;class bp{constructor(a,b){this.$from=a,this.$to=b}}let bq=!1;function br(a){bq||a.parent.inlineContent||(bq=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+a.parent.type.name+")"))}class bs extends bo{constructor(a,b=a){br(a),br(b),super(a,b)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(a,b){let c=a.resolve(b.map(this.head));if(!c.parent.inlineContent)return bo.near(c);let d=a.resolve(b.map(this.anchor));return new bs(d.parent.inlineContent?d:c,c)}replace(a,b=Y.empty){if(super.replace(a,b),b==Y.empty){let b=this.$from.marksAcross(this.$to);b&&a.ensureMarks(b)}}eq(a){return a instanceof bs&&a.anchor==this.anchor&&a.head==this.head}getBookmark(){return new bt(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(a,b){if("number"!=typeof b.anchor||"number"!=typeof b.head)throw RangeError("Invalid input for TextSelection.fromJSON");return new bs(a.resolve(b.anchor),a.resolve(b.head))}static create(a,b,c=b){let d=a.resolve(b);return new this(d,c==b?d:a.resolve(c))}static between(a,b,c){let d=a.pos-b.pos;if((!c||d)&&(c=d>=0?1:-1),!b.parent.inlineContent){let a=bo.findFrom(b,c,!0)||bo.findFrom(b,-c,!0);if(!a)return bo.near(b,c);b=a.$head}return a.parent.inlineContent||(0==d?a=b:(a=(bo.findFrom(a,-c,!0)||bo.findFrom(a,c,!0)).$anchor).pos<b.pos!=d<0&&(a=b)),new bs(a,b)}}bo.jsonID("text",bs);class bt{constructor(a,b){this.anchor=a,this.head=b}map(a){return new bt(a.map(this.anchor),a.map(this.head))}resolve(a){return bs.between(a.resolve(this.anchor),a.resolve(this.head))}}class bu extends bo{constructor(a){let b=a.nodeAfter,c=a.node(0).resolve(a.pos+b.nodeSize);super(a,c),this.node=b}map(a,b){let{deleted:c,pos:d}=b.mapResult(this.anchor),e=a.resolve(d);return c?bo.near(e):new bu(e)}content(){return new Y(S.from(this.node),0,0)}eq(a){return a instanceof bu&&a.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new bv(this.anchor)}static fromJSON(a,b){if("number"!=typeof b.anchor)throw RangeError("Invalid input for NodeSelection.fromJSON");return new bu(a.resolve(b.anchor))}static create(a,b){return new bu(a.resolve(b))}static isSelectable(a){return!a.isText&&!1!==a.type.spec.selectable}}bu.prototype.visible=!1,bo.jsonID("node",bu);class bv{constructor(a){this.anchor=a}map(a){let{deleted:b,pos:c}=a.mapResult(this.anchor);return b?new bt(c,c):new bv(c)}resolve(a){let b=a.resolve(this.anchor),c=b.nodeAfter;return c&&bu.isSelectable(c)?new bu(b):bo.near(b)}}class bw extends bo{constructor(a){super(a.resolve(0),a.resolve(a.content.size))}replace(a,b=Y.empty){if(b==Y.empty){a.delete(0,a.doc.content.size);let b=bo.atStart(a.doc);b.eq(a.selection)||a.setSelection(b)}else super.replace(a,b)}toJSON(){return{type:"all"}}static fromJSON(a){return new bw(a)}map(a){return new bw(a)}eq(a){return a instanceof bw}getBookmark(){return bx}}bo.jsonID("all",bw);let bx={map(){return this},resolve:a=>new bw(a)};function by(a,b,c,d,e,f=!1){if(b.inlineContent)return bs.create(a,c);for(let g=d-(e>0?0:1);e>0?g<b.childCount:g>=0;g+=e){let d=b.child(g);if(d.isAtom){if(!f&&bu.isSelectable(d))return bu.create(a,c-(e<0?d.nodeSize:0))}else{let b=by(a,d,c+e,e<0?d.childCount:0,e,f);if(b)return b}c+=d.nodeSize*e}return null}function bz(a,b,c){let d,e=a.steps.length-1;if(e<b)return;let f=a.steps[e];(f instanceof aZ||f instanceof a$)&&(a.mapping.maps[e].forEach((a,b,c,e)=>{null==d&&(d=e)}),a.setSelection(bo.near(a.doc.resolve(d),c)))}class bA extends bm{constructor(a){super(a.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=a.selection,this.storedMarks=a.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(a){if(a.$from.doc!=this.doc)throw RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=a,this.curSelectionFor=this.steps.length,this.updated=(1|this.updated)&-3,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(a){return this.storedMarks=a,this.updated|=2,this}ensureMarks(a){return W.sameSet(this.storedMarks||this.selection.$from.marks(),a)||this.setStoredMarks(a),this}addStoredMark(a){return this.ensureMarks(a.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(a){return this.ensureMarks(a.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(a,b){super.addStep(a,b),this.updated=-3&this.updated,this.storedMarks=null}setTime(a){return this.time=a,this}replaceSelection(a){return this.selection.replace(this,a),this}replaceSelectionWith(a,b=!0){let c=this.selection;return b&&(a=a.mark(this.storedMarks||(c.empty?c.$from.marks():c.$from.marksAcross(c.$to)||W.none))),c.replaceWith(this,a),this}deleteSelection(){return this.selection.replace(this),this}insertText(a,b,c){let d=this.doc.type.schema;if(null==b)return a?this.replaceSelectionWith(d.text(a),!0):this.deleteSelection();{if(null==c&&(c=b),!a)return this.deleteRange(b,c);let e=this.storedMarks;if(!e){let a=this.doc.resolve(b);e=c==b?a.marks():a.marksAcross(this.doc.resolve(c))}return this.replaceRangeWith(b,c,d.text(a,e)),this.selection.empty||this.selection.to!=b+a.length||this.setSelection(bo.near(this.selection.$to)),this}}setMeta(a,b){return this.meta["string"==typeof a?a:a.key]=b,this}getMeta(a){return this.meta["string"==typeof a?a:a.key]}get isGeneric(){for(let a in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function bB(a,b){return b&&a?a.bind(b):a}class bC{constructor(a,b,c){this.name=a,this.init=bB(b.init,c),this.apply=bB(b.apply,c)}}let bD=[new bC("doc",{init:a=>a.doc||a.schema.topNodeType.createAndFill(),apply:a=>a.doc}),new bC("selection",{init:(a,b)=>a.selection||bo.atStart(b.doc),apply:a=>a.selection}),new bC("storedMarks",{init:a=>a.storedMarks||null,apply:(a,b,c,d)=>d.selection.$cursor?a.storedMarks:null}),new bC("scrollToSelection",{init:()=>0,apply:(a,b)=>a.scrolledIntoView?b+1:b})];class bE{constructor(a,b){this.schema=a,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=bD.slice(),b&&b.forEach(a=>{if(this.pluginsByKey[a.key])throw RangeError("Adding different instances of a keyed plugin ("+a.key+")");this.plugins.push(a),this.pluginsByKey[a.key]=a,a.spec.state&&this.fields.push(new bC(a.key,a.spec.state,a))})}}class bF{constructor(a){this.config=a}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(a){return this.applyTransaction(a).state}filterTransaction(a,b=-1){for(let c=0;c<this.config.plugins.length;c++)if(c!=b){let b=this.config.plugins[c];if(b.spec.filterTransaction&&!b.spec.filterTransaction.call(b,a,this))return!1}return!0}applyTransaction(a){if(!this.filterTransaction(a))return{state:this,transactions:[]};let b=[a],c=this.applyInner(a),d=null;for(;;){let e=!1;for(let f=0;f<this.config.plugins.length;f++){let g=this.config.plugins[f];if(g.spec.appendTransaction){let h=d?d[f].n:0,i=d?d[f].state:this,j=h<b.length&&g.spec.appendTransaction.call(g,h?b.slice(h):b,i,c);if(j&&c.filterTransaction(j,f)){if(j.setMeta("appendedTransaction",a),!d){d=[];for(let a=0;a<this.config.plugins.length;a++)d.push(a<f?{state:c,n:b.length}:{state:this,n:0})}b.push(j),c=c.applyInner(j),e=!0}d&&(d[f]={state:c,n:b.length})}}if(!e)return{state:c,transactions:b}}}applyInner(a){if(!a.before.eq(this.doc))throw RangeError("Applying a mismatched transaction");let b=new bF(this.config),c=this.config.fields;for(let d=0;d<c.length;d++){let e=c[d];b[e.name]=e.apply(a,this[e.name],this,b)}return b}get tr(){return new bA(this)}static create(a){let b=new bE(a.doc?a.doc.type.schema:a.schema,a.plugins),c=new bF(b);for(let d=0;d<b.fields.length;d++)c[b.fields[d].name]=b.fields[d].init(a,c);return c}reconfigure(a){let b=new bE(this.schema,a.plugins),c=b.fields,d=new bF(b);for(let b=0;b<c.length;b++){let e=c[b].name;d[e]=this.hasOwnProperty(e)?this[e]:c[b].init(a,d)}return d}toJSON(a){let b={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(b.storedMarks=this.storedMarks.map(a=>a.toJSON())),a&&"object"==typeof a)for(let c in a){if("doc"==c||"selection"==c)throw RangeError("The JSON fields `doc` and `selection` are reserved");let d=a[c],e=d.spec.state;e&&e.toJSON&&(b[c]=e.toJSON.call(d,this[d.key]))}return b}static fromJSON(a,b,c){if(!b)throw RangeError("Invalid input for EditorState.fromJSON");if(!a.schema)throw RangeError("Required config field 'schema' missing");let d=new bE(a.schema,a.plugins),e=new bF(d);return d.fields.forEach(d=>{if("doc"==d.name)e.doc=aj.fromJSON(a.schema,b.doc);else if("selection"==d.name)e.selection=bo.fromJSON(e.doc,b.selection);else if("storedMarks"==d.name)b.storedMarks&&(e.storedMarks=b.storedMarks.map(a.schema.markFromJSON));else{if(c)for(let f in c){let g=c[f],h=g.spec.state;if(g.key==d.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(b,f)){e[d.name]=h.fromJSON.call(g,a,b[f],e);return}}e[d.name]=d.init(a,e)}}),e}}class bG{constructor(a){this.spec=a,this.props={},a.props&&function a(b,c,d){for(let e in b){let f=b[e];f instanceof Function?f=f.bind(c):"handleDOMEvents"==e&&(f=a(f,c,{})),d[e]=f}return d}(a.props,this,this.props),this.key=a.key?a.key.key:bI("plugin")}getState(a){return a[this.key]}}let bH=Object.create(null);function bI(a){return a in bH?a+"$"+ ++bH[a]:(bH[a]=0,a+"$")}class bJ{constructor(a="key"){this.key=bI(a)}get(a){return a.config.pluginsByKey[this.key]}getState(a){return a[this.key]}}let bK=(a,b)=>!a.selection.empty&&(b&&b(a.tr.deleteSelection().scrollIntoView()),!0);function bL(a,b){let{$cursor:c}=a.selection;return c&&(b?b.endOfTextblock("backward",a):!(c.parentOffset>0))?c:null}let bM=(a,b,c)=>{let d=bL(a,c);if(!d)return!1;let e=bQ(d);if(!e){let c=d.blockRange(),e=c&&a1(c);return null!=e&&(b&&b(a.tr.lift(c,e).scrollIntoView()),!0)}let f=e.nodeBefore;if(b$(a,e,b,-1))return!0;if(0==d.parent.content.size&&(bO(f,"end")||bu.isSelectable(f)))for(let c=d.depth;;c--){let g=bb(a.doc,d.before(c),d.after(c),Y.empty);if(g&&g.slice.size<g.to-g.from){if(b){let c=a.tr.step(g);c.setSelection(bO(f,"end")?bo.findFrom(c.doc.resolve(c.mapping.map(e.pos,-1)),-1):bu.create(c.doc,e.pos-f.nodeSize)),b(c.scrollIntoView())}return!0}if(1==c||d.node(c-1).childCount>1)break}return!!f.isAtom&&e.depth==d.depth-1&&(b&&b(a.tr.delete(e.pos-f.nodeSize,e.pos).scrollIntoView()),!0)};function bN(a,b,c){let d=b.nodeBefore,e=b.pos-1;for(;!d.isTextblock;e--){if(d.type.spec.isolating)return!1;let a=d.lastChild;if(!a)return!1;d=a}let f=b.nodeAfter,g=b.pos+1;for(;!f.isTextblock;g++){if(f.type.spec.isolating)return!1;let a=f.firstChild;if(!a)return!1;f=a}let h=bb(a.doc,e,g,Y.empty);if(!h||h.from!=e||h instanceof aZ&&h.slice.size>=g-e)return!1;if(c){let b=a.tr.step(h);b.setSelection(bs.create(b.doc,e)),c(b.scrollIntoView())}return!0}function bO(a,b,c=!1){for(let d=a;d;d="start"==b?d.firstChild:d.lastChild){if(d.isTextblock)return!0;if(c&&1!=d.childCount)break}return!1}let bP=(a,b,c)=>{let{$head:d,empty:e}=a.selection,f=d;if(!e)return!1;if(d.parent.isTextblock){if(c?!c.endOfTextblock("backward",a):d.parentOffset>0)return!1;f=bQ(d)}let g=f&&f.nodeBefore;return!!g&&!!bu.isSelectable(g)&&(b&&b(a.tr.setSelection(bu.create(a.doc,f.pos-g.nodeSize)).scrollIntoView()),!0)};function bQ(a){if(!a.parent.type.spec.isolating)for(let b=a.depth-1;b>=0;b--){if(a.index(b)>0)return a.doc.resolve(a.before(b+1));if(a.node(b).type.spec.isolating)break}return null}function bR(a,b){let{$cursor:c}=a.selection;return c&&(b?b.endOfTextblock("forward",a):!(c.parentOffset<c.parent.content.size))?c:null}let bS=(a,b,c)=>{let d=bR(a,c);if(!d)return!1;let e=bU(d);if(!e)return!1;let f=e.nodeAfter;if(b$(a,e,b,1))return!0;if(0==d.parent.content.size&&(bO(f,"start")||bu.isSelectable(f))){let c=bb(a.doc,d.before(),d.after(),Y.empty);if(c&&c.slice.size<c.to-c.from){if(b){let d=a.tr.step(c);d.setSelection(bO(f,"start")?bo.findFrom(d.doc.resolve(d.mapping.map(e.pos)),1):bu.create(d.doc,d.mapping.map(e.pos))),b(d.scrollIntoView())}return!0}}return!!f.isAtom&&e.depth==d.depth-1&&(b&&b(a.tr.delete(e.pos,e.pos+f.nodeSize).scrollIntoView()),!0)},bT=(a,b,c)=>{let{$head:d,empty:e}=a.selection,f=d;if(!e)return!1;if(d.parent.isTextblock){if(c?!c.endOfTextblock("forward",a):d.parentOffset<d.parent.content.size)return!1;f=bU(d)}let g=f&&f.nodeAfter;return!!g&&!!bu.isSelectable(g)&&(b&&b(a.tr.setSelection(bu.create(a.doc,f.pos)).scrollIntoView()),!0)};function bU(a){if(!a.parent.type.spec.isolating)for(let b=a.depth-1;b>=0;b--){let c=a.node(b);if(a.index(b)+1<c.childCount)return a.doc.resolve(a.after(b+1));if(c.type.spec.isolating)break}return null}let bV=(a,b)=>{let{$head:c,$anchor:d}=a.selection;return!!c.parent.type.spec.code&&!!c.sameParent(d)&&(b&&b(a.tr.insertText("\n").scrollIntoView()),!0)};function bW(a){for(let b=0;b<a.edgeCount;b++){let{type:c}=a.edge(b);if(c.isTextblock&&!c.hasRequiredAttrs())return c}return null}let bX=(a,b)=>{let{$head:c,$anchor:d}=a.selection;if(!c.parent.type.spec.code||!c.sameParent(d))return!1;let e=c.node(-1),f=c.indexAfter(-1),g=bW(e.contentMatchAt(f));if(!g||!e.canReplaceWith(f,f,g))return!1;if(b){let d=c.after(),e=a.tr.replaceWith(d,d,g.createAndFill());e.setSelection(bo.near(e.doc.resolve(d),1)),b(e.scrollIntoView())}return!0},bY=(a,b)=>{let c=a.selection,{$from:d,$to:e}=c;if(c instanceof bw||d.parent.inlineContent||e.parent.inlineContent)return!1;let f=bW(e.parent.contentMatchAt(e.indexAfter()));if(!f||!f.isTextblock)return!1;if(b){let c=(!d.parentOffset&&e.index()<e.parent.childCount?d:e).pos,g=a.tr.insert(c,f.createAndFill());g.setSelection(bs.create(g.doc,c+1)),b(g.scrollIntoView())}return!0},bZ=(a,b)=>{let{$cursor:c}=a.selection;if(!c||c.parent.content.size)return!1;if(c.depth>1&&c.after()!=c.end(-1)){let d=c.before();if(a6(a.doc,d))return b&&b(a.tr.split(d).scrollIntoView()),!0}let d=c.blockRange(),e=d&&a1(d);return null!=e&&(b&&b(a.tr.lift(d,e).scrollIntoView()),!0)};function b$(a,b,c,d){let e,f,g,h=b.nodeBefore,i=b.nodeAfter,j,k,l=h.type.spec.isolating||i.type.spec.isolating;if(!l&&(e=b.nodeBefore,f=b.nodeAfter,g=b.index(),e&&f&&e.type.compatibleContent(f.type)&&(!e.content.size&&b.parent.canReplace(g-1,g)?(c&&c(a.tr.delete(b.pos-e.nodeSize,b.pos).scrollIntoView()),!0):!!b.parent.canReplace(g,g+1)&&!!(f.isTextblock||a7(a.doc,b.pos))&&(c&&c(a.tr.join(b.pos).scrollIntoView()),!0))))return!0;let m=!l&&b.parent.canReplace(b.index(),b.index()+1);if(m&&(j=(k=h.contentMatchAt(h.childCount)).findWrapping(i.type))&&k.matchType(j[0]||i.type).validEnd){if(c){let d=b.pos+i.nodeSize,e=S.empty;for(let a=j.length-1;a>=0;a--)e=S.from(j[a].create(null,e));e=S.from(h.copy(e));let f=a.tr.step(new a$(b.pos-1,d,b.pos,d,new Y(e,1,0),j.length,!0)),g=f.doc.resolve(d+2*j.length);g.nodeAfter&&g.nodeAfter.type==h.type&&a7(f.doc,g.pos)&&f.join(g.pos),c(f.scrollIntoView())}return!0}let n=i.type.spec.isolating||d>0&&l?null:bo.findFrom(b,1),o=n&&n.$from.blockRange(n.$to),p=o&&a1(o);if(null!=p&&p>=b.depth)return c&&c(a.tr.lift(o,p).scrollIntoView()),!0;if(m&&bO(i,"start",!0)&&bO(h,"end")){let d=h,e=[];for(;e.push(d),!d.isTextblock;)d=d.lastChild;let f=i,g=1;for(;!f.isTextblock;f=f.firstChild)g++;if(d.canReplace(d.childCount,d.childCount,f.content)){if(c){let d=S.empty;for(let a=e.length-1;a>=0;a--)d=S.from(e[a].copy(d));c(a.tr.step(new a$(b.pos-e.length,b.pos+i.nodeSize,b.pos+g,b.pos+i.nodeSize-g,new Y(d,e.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function b_(a){return function(b,c){let d=b.selection,e=a<0?d.$from:d.$to,f=e.depth;for(;e.node(f).isInline;){if(!f)return!1;f--}return!!e.node(f).isTextblock&&(c&&c(b.tr.setSelection(bs.create(b.doc,a<0?e.start(f):e.end(f)))),!0)}}let b0=b_(-1),b1=b_(1);function b2(a,b=null){return function(c,d){let e=!1;for(let d=0;d<c.selection.ranges.length&&!e;d++){let{$from:{pos:f},$to:{pos:g}}=c.selection.ranges[d];c.doc.nodesBetween(f,g,(d,f)=>{if(e)return!1;if(!(!d.isTextblock||d.hasMarkup(a,b)))if(d.type==a)e=!0;else{let b=c.doc.resolve(f),d=b.index();e=b.parent.canReplaceWith(d,d+1,a)}})}if(!e)return!1;if(d){let e=c.tr;for(let d=0;d<c.selection.ranges.length;d++){let{$from:{pos:f},$to:{pos:g}}=c.selection.ranges[d];e.setBlockType(f,g,a,b)}d(e.scrollIntoView())}return!0}}function b3(...a){return function(b,c,d){for(let e=0;e<a.length;e++)if(a[e](b,c,d))return!0;return!1}}let b4=b3(bK,bM,bP),b5=b3(bK,bS,bT),b6={Enter:b3(bV,bY,bZ,(a,b)=>{let{$from:c,$to:d}=a.selection;if(a.selection instanceof bu&&a.selection.node.isBlock)return!!c.parentOffset&&!!a6(a.doc,c.pos)&&(b&&b(a.tr.split(c.pos).scrollIntoView()),!0);if(!c.depth)return!1;let e=[],f,g,h=!1,i=!1;for(let a=c.depth;;a--){if(c.node(a).isBlock){let b;h=c.end(a)==c.pos+(c.depth-a),i=c.start(a)==c.pos-(c.depth-a),g=bW(c.node(a-1).contentMatchAt(c.indexAfter(a-1)));e.unshift(b||(h&&g?{type:g}:null)),f=a;break}if(1==a)return!1;e.unshift(null)}let j=a.tr;(a.selection instanceof bs||a.selection instanceof bw)&&j.deleteSelection();let k=j.mapping.map(c.pos),l=a6(j.doc,k,e.length,e);if(l||(e[0]=g?{type:g}:null,l=a6(j.doc,k,e.length,e)),!l)return!1;if(j.split(k,e.length,e),!h&&i&&c.node(f).type!=g){let a=j.mapping.map(c.before(f)),b=j.doc.resolve(a);g&&c.node(f-1).canReplaceWith(b.index(),b.index()+1,g)&&j.setNodeMarkup(j.mapping.map(c.before(f)),g)}return b&&b(j.scrollIntoView()),!0}),"Mod-Enter":bX,Backspace:b4,"Mod-Backspace":b4,"Shift-Backspace":b4,Delete:b5,"Mod-Delete":b5,"Mod-a":(a,b)=>(b&&b(a.tr.setSelection(new bw(a.doc))),!0)},b7={"Ctrl-h":b6.Backspace,"Alt-Backspace":b6["Mod-Backspace"],"Ctrl-d":b6.Delete,"Ctrl-Alt-Backspace":b6["Mod-Delete"],"Alt-Delete":b6["Mod-Delete"],"Alt-d":b6["Mod-Delete"],"Ctrl-a":b0,"Ctrl-e":b1};for(let a in b6)b7[a]=b6[a];"u">typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"u">typeof os&&os.platform&&os.platform();let b8=function(a){for(var b=0;;b++)if(!(a=a.previousSibling))return b},b9=function(a){let b=a.assignedSlot||a.parentNode;return b&&11==b.nodeType?b.host:b},ca=null,cb=function(a,b,c){let d=ca||(ca=document.createRange());return d.setEnd(a,null==c?a.nodeValue.length:c),d.setStart(a,b||0),d},cc=function(){ca=null},cd=function(a,b,c,d){return c&&(cf(a,b,c,d,-1)||cf(a,b,c,d,1))},ce=/^(img|br|input|textarea|hr)$/i;function cf(a,b,c,d,e){for(var f;;){if(a==c&&b==d)return!0;if(b==(e<0?0:cg(a))){let c=a.parentNode;if(!c||1!=c.nodeType||ch(a)||ce.test(a.nodeName)||"false"==a.contentEditable)return!1;b=b8(a)+(e<0?0:1),a=c}else{if(1!=a.nodeType)return!1;let c=a.childNodes[b+(e<0?-1:0)];if(1==c.nodeType&&"false"==c.contentEditable)if(null==(f=c.pmViewDesc)||!f.ignoreForSelection)return!1;else b+=e;else a=c,b=e<0?cg(a):0}}}function cg(a){return 3==a.nodeType?a.nodeValue.length:a.childNodes.length}function ch(a){let b;for(let c=a;c&&!(b=c.pmViewDesc);c=c.parentNode);return b&&b.node&&b.node.isBlock&&(b.dom==a||b.contentDOM==a)}let ci=function(a){return a.focusNode&&cd(a.focusNode,a.focusOffset,a.anchorNode,a.anchorOffset)};function cj(a,b){let c=document.createEvent("Event");return c.initEvent("keydown",!0,!0),c.keyCode=a,c.key=c.code=b,c}let ck="u">typeof navigator?navigator:null,cl="u">typeof document?document:null,cm=ck&&ck.userAgent||"",cn=/Edge\/(\d+)/.exec(cm),co=/MSIE \d/.exec(cm),cp=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(cm),cq=!!(co||cp||cn),cr=co?document.documentMode:cp?+cp[1]:cn?+cn[1]:0,cs=!cq&&/gecko\/(\d+)/i.test(cm);cs&&(/Firefox\/(\d+)/.exec(cm)||[0,0])[1];let ct=!cq&&/Chrome\/(\d+)/.exec(cm),cu=!!ct,cv=ct?+ct[1]:0,cw=!cq&&!!ck&&/Apple Computer/.test(ck.vendor),cx=cw&&(/Mobile\/\w+/.test(cm)||!!ck&&ck.maxTouchPoints>2),cy=cx||!!ck&&/Mac/.test(ck.platform),cz=!!ck&&/Win/.test(ck.platform),cA=/Android \d/.test(cm),cB=!!cl&&"webkitFontSmoothing"in cl.documentElement.style,cC=cB?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function cD(a,b){return"number"==typeof a?a:a[b]}function cE(a,b,c){let d=a.someProp("scrollThreshold")||0,e=a.someProp("scrollMargin")||5,f=a.dom.ownerDocument;for(let g=c||a.dom;g;){if(1!=g.nodeType){g=b9(g);continue}let a=g,c=a==f.body,h=c?function(a){let b=a.defaultView&&a.defaultView.visualViewport;return b?{left:0,right:b.width,top:0,bottom:b.height}:{left:0,right:a.documentElement.clientWidth,top:0,bottom:a.documentElement.clientHeight}}(f):function(a){let b=a.getBoundingClientRect(),c=b.width/a.offsetWidth||1,d=b.height/a.offsetHeight||1;return{left:b.left,right:b.left+a.clientWidth*c,top:b.top,bottom:b.top+a.clientHeight*d}}(a),i=0,j=0;if(b.top<h.top+cD(d,"top")?j=-(h.top-b.top+cD(e,"top")):b.bottom>h.bottom-cD(d,"bottom")&&(j=b.bottom-b.top>h.bottom-h.top?b.top+cD(e,"top")-h.top:b.bottom-h.bottom+cD(e,"bottom")),b.left<h.left+cD(d,"left")?i=-(h.left-b.left+cD(e,"left")):b.right>h.right-cD(d,"right")&&(i=b.right-h.right+cD(e,"right")),i||j)if(c)f.defaultView.scrollBy(i,j);else{let c=a.scrollLeft,d=a.scrollTop;j&&(a.scrollTop+=j),i&&(a.scrollLeft+=i);let e=a.scrollLeft-c,f=a.scrollTop-d;b={left:b.left-e,top:b.top-f,right:b.right-e,bottom:b.bottom-f}}let k=c?"fixed":getComputedStyle(g).position;if(/^(fixed|sticky)$/.test(k))break;g="absolute"==k?g.offsetParent:b9(g)}}function cF(a){let b=[],c=a.ownerDocument;for(let d=a;d&&(b.push({dom:d,top:d.scrollTop,left:d.scrollLeft}),a!=c);d=b9(d));return b}function cG(a,b){for(let c=0;c<a.length;c++){let{dom:d,top:e,left:f}=a[c];d.scrollTop!=e+b&&(d.scrollTop=e+b),d.scrollLeft!=f&&(d.scrollLeft=f)}}let cH=null;function cI(a,b){return a.left>=b.left-1&&a.left<=b.right+1&&a.top>=b.top-1&&a.top<=b.bottom+1}function cJ(a){return a.top<a.bottom||a.left<a.right}function cK(a,b){let c=a.getClientRects();if(c.length){let a=c[b<0?0:c.length-1];if(cJ(a))return a}return Array.prototype.find.call(c,cJ)||a.getBoundingClientRect()}let cL=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function cM(a,b,c){let{node:d,offset:e,atom:f}=a.docView.domFromPos(b,c<0?-1:1),g=cB||cs;if(3==d.nodeType)if(g&&(cL.test(d.nodeValue)||(c<0?!e:e==d.nodeValue.length))){let a=cK(cb(d,e,e),c);if(cs&&e&&/\s/.test(d.nodeValue[e-1])&&e<d.nodeValue.length){let b=cK(cb(d,e-1,e-1),-1);if(b.top==a.top){let c=cK(cb(d,e,e+1),-1);if(c.top!=a.top)return cN(c,c.left<b.left)}}return a}else{let a=e,b=e,f=c<0?1:-1;return c<0&&!e?(b++,f=-1):c>=0&&e==d.nodeValue.length?(a--,f=1):c<0?a--:b++,cN(cK(cb(d,a,b),f),f<0)}if(!a.state.doc.resolve(b-(f||0)).parent.inlineContent){if(null==f&&e&&(c<0||e==cg(d))){let a=d.childNodes[e-1];if(1==a.nodeType)return cO(a.getBoundingClientRect(),!1)}if(null==f&&e<cg(d)){let a=d.childNodes[e];if(1==a.nodeType)return cO(a.getBoundingClientRect(),!0)}return cO(d.getBoundingClientRect(),c>=0)}if(null==f&&e&&(c<0||e==cg(d))){let a=d.childNodes[e-1],b=3==a.nodeType?cb(a,cg(a)-!g):1!=a.nodeType||"BR"==a.nodeName&&a.nextSibling?null:a;if(b)return cN(cK(b,1),!1)}if(null==f&&e<cg(d)){let a=d.childNodes[e];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let b=a?3==a.nodeType?cb(a,0,+!g):1==a.nodeType?a:null:null;if(b)return cN(cK(b,-1),!0)}return cN(cK(3==d.nodeType?cb(d):d,-c),c>=0)}function cN(a,b){if(0==a.width)return a;let c=b?a.left:a.right;return{top:a.top,bottom:a.bottom,left:c,right:c}}function cO(a,b){if(0==a.height)return a;let c=b?a.top:a.bottom;return{top:c,bottom:c,left:a.left,right:a.right}}function cP(a,b,c){let d=a.state,e=a.root.activeElement;d!=b&&a.updateState(b),e!=a.dom&&a.focus();try{return c()}finally{d!=b&&a.updateState(d),e!=a.dom&&e&&e.focus()}}let cQ=/[\u0590-\u08ac]/,cR=null,cS=null,cT=!1;class cU{constructor(a,b,c,d){this.parent=a,this.children=b,this.dom=c,this.contentDOM=d,this.dirty=0,c.pmViewDesc=this}matchesWidget(a){return!1}matchesMark(a){return!1}matchesNode(a,b,c){return!1}matchesHack(a){return!1}parseRule(){return null}stopEvent(a){return!1}get size(){let a=0;for(let b=0;b<this.children.length;b++)a+=this.children[b].size;return a}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let a=0;a<this.children.length;a++)this.children[a].destroy()}posBeforeChild(a){for(let b=0,c=this.posAtStart;;b++){let d=this.children[b];if(d==a)return c;c+=d.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(a,b,c){let d;if(this.contentDOM&&this.contentDOM.contains(1==a.nodeType?a:a.parentNode))if(c<0){let c,d;if(a==this.contentDOM)c=a.childNodes[b-1];else{for(;a.parentNode!=this.contentDOM;)a=a.parentNode;c=a.previousSibling}for(;c&&!((d=c.pmViewDesc)&&d.parent==this);)c=c.previousSibling;return c?this.posBeforeChild(d)+d.size:this.posAtStart}else{let c,d;if(a==this.contentDOM)c=a.childNodes[b];else{for(;a.parentNode!=this.contentDOM;)a=a.parentNode;c=a.nextSibling}for(;c&&!((d=c.pmViewDesc)&&d.parent==this);)c=c.nextSibling;return c?this.posBeforeChild(d):this.posAtEnd}if(a==this.dom&&this.contentDOM)d=b>b8(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))d=2&a.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==b)for(let b=a;;b=b.parentNode){if(b==this.dom){d=!1;break}if(b.previousSibling)break}if(null==d&&b==a.childNodes.length)for(let b=a;;b=b.parentNode){if(b==this.dom){d=!0;break}if(b.nextSibling)break}}return(null==d?c>0:d)?this.posAtEnd:this.posAtStart}nearestDesc(a,b=!1){for(let c=!0,d=a;d;d=d.parentNode){let e=this.getDesc(d),f;if(e&&(!b||e.node))if(!c||!(f=e.nodeDOM)||(1==f.nodeType?f.contains(1==a.nodeType?a:a.parentNode):f==a))return e;else c=!1}}getDesc(a){let b=a.pmViewDesc;for(let a=b;a;a=a.parent)if(a==this)return b}posFromDOM(a,b,c){for(let d=a;d;d=d.parentNode){let e=this.getDesc(d);if(e)return e.localPosFromDOM(a,b,c)}return -1}descAt(a){for(let b=0,c=0;b<this.children.length;b++){let d=this.children[b],e=c+d.size;if(c==a&&e!=c){for(;!d.border&&d.children.length;)for(let a=0;a<d.children.length;a++){let b=d.children[a];if(b.size){d=b;break}}return d}if(a<e)return d.descAt(a-c-d.border);c=e}}domFromPos(a,b){if(!this.contentDOM)return{node:this.dom,offset:0,atom:a+1};let c=0,d=0;for(let b=0;c<this.children.length;c++){let e=this.children[c],f=b+e.size;if(f>a||e instanceof c_){d=a-b;break}b=f}if(d)return this.children[c].domFromPos(d-this.children[c].border,b);for(let a;c&&!(a=this.children[c-1]).size&&a instanceof cV&&a.side>=0;c--);if(b<=0){let a,d=!0;for(;(a=c?this.children[c-1]:null)&&a.dom.parentNode!=this.contentDOM;c--,d=!1);return a&&b&&d&&!a.border&&!a.domAtom?a.domFromPos(a.size,b):{node:this.contentDOM,offset:a?b8(a.dom)+1:0}}{let a,d=!0;for(;(a=c<this.children.length?this.children[c]:null)&&a.dom.parentNode!=this.contentDOM;c++,d=!1);return a&&d&&!a.border&&!a.domAtom?a.domFromPos(0,b):{node:this.contentDOM,offset:a?b8(a.dom):this.contentDOM.childNodes.length}}}parseRange(a,b,c=0){if(0==this.children.length)return{node:this.contentDOM,from:a,to:b,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let d=-1,e=-1;for(let f=c,g=0;;g++){let c=this.children[g],h=f+c.size;if(-1==d&&a<=h){let e=f+c.border;if(a>=e&&b<=h-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(a,b,e);a=f;for(let b=g;b>0;b--){let c=this.children[b-1];if(c.size&&c.dom.parentNode==this.contentDOM&&!c.emptyChildAt(1)){d=b8(c.dom)+1;break}a-=c.size}-1==d&&(d=0)}if(d>-1&&(h>b||g==this.children.length-1)){b=h;for(let a=g+1;a<this.children.length;a++){let c=this.children[a];if(c.size&&c.dom.parentNode==this.contentDOM&&!c.emptyChildAt(-1)){e=b8(c.dom);break}b+=c.size}-1==e&&(e=this.contentDOM.childNodes.length);break}f=h}return{node:this.contentDOM,from:a,to:b,fromOffset:d,toOffset:e}}emptyChildAt(a){if(this.border||!this.contentDOM||!this.children.length)return!1;let b=this.children[a<0?0:this.children.length-1];return 0==b.size||b.emptyChildAt(a)}domAfterPos(a){let{node:b,offset:c}=this.domFromPos(a,0);if(1!=b.nodeType||c==b.childNodes.length)throw RangeError("No node after pos "+a);return b.childNodes[c]}setSelection(a,b,c,d=!1){let e=Math.min(a,b),f=Math.max(a,b);for(let g=0,h=0;g<this.children.length;g++){let i=this.children[g],j=h+i.size;if(e>h&&f<j)return i.setSelection(a-h-i.border,b-h-i.border,c,d);h=j}let g=this.domFromPos(a,a?-1:1),h=b==a?g:this.domFromPos(b,b?-1:1),i=c.root.getSelection(),j=c.domSelectionRange(),k=!1;if((cs||cw)&&a==b){let{node:a,offset:b}=g;if(3==a.nodeType){if((k=!!(b&&"\n"==a.nodeValue[b-1]))&&b==a.nodeValue.length)for(let b=a,c;b;b=b.parentNode){if(c=b.nextSibling){"BR"==c.nodeName&&(g=h={node:c.parentNode,offset:b8(c)+1});break}let a=b.pmViewDesc;if(a&&a.node&&a.node.isBlock)break}}else{let c=a.childNodes[b-1];k=c&&("BR"==c.nodeName||"false"==c.contentEditable)}}if(cs&&j.focusNode&&j.focusNode!=h.node&&1==j.focusNode.nodeType){let a=j.focusNode.childNodes[j.focusOffset];a&&"false"==a.contentEditable&&(d=!0)}if(!(d||k&&cw)&&cd(g.node,g.offset,j.anchorNode,j.anchorOffset)&&cd(h.node,h.offset,j.focusNode,j.focusOffset))return;let l=!1;if((i.extend||a==b)&&!(k&&cs)){i.collapse(g.node,g.offset);try{a!=b&&i.extend(h.node,h.offset),l=!0}catch(a){}}if(!l){if(a>b){let a=g;g=h,h=a}let c=document.createRange();c.setEnd(h.node,h.offset),c.setStart(g.node,g.offset),i.removeAllRanges(),i.addRange(c)}}ignoreMutation(a){return!this.contentDOM&&"selection"!=a.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(a,b){for(let c=0,d=0;d<this.children.length;d++){let e=this.children[d],f=c+e.size;if(c==f?a<=f&&b>=c:a<f&&b>c){let d=c+e.border,g=f-e.border;if(a>=d&&b<=g){this.dirty=a==c||b==f?2:1,a==d&&b==g&&(e.contentLost||e.dom.parentNode!=this.contentDOM)?e.dirty=3:e.markDirty(a-d,b-d);return}e.dirty=e.dom!=e.contentDOM||e.dom.parentNode!=this.contentDOM||e.children.length?3:2}c=f}this.dirty=2}markParentsDirty(){let a=1;for(let b=this.parent;b;b=b.parent,a++){let c=1==a?2:1;b.dirty<c&&(b.dirty=c)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(a){return!1}}class cV extends cU{constructor(a,b,c,d){let e,f=b.type.toDOM;if("function"==typeof f&&(f=f(c,()=>e?e.parent?e.parent.posBeforeChild(e):void 0:d)),!b.type.spec.raw){if(1!=f.nodeType){let a=document.createElement("span");a.appendChild(f),f=a}f.contentEditable="false",f.classList.add("ProseMirror-widget")}super(a,[],f,null),this.widget=b,this.widget=b,e=this}matchesWidget(a){return 0==this.dirty&&a.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(a){let b=this.widget.spec.stopEvent;return!!b&&b(a)}ignoreMutation(a){return"selection"!=a.type||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}}class cW extends cU{constructor(a,b,c,d){super(a,[],b,null),this.textDOM=c,this.text=d}get size(){return this.text.length}localPosFromDOM(a,b){return a!=this.textDOM?this.posAtStart+(b?this.size:0):this.posAtStart+b}domFromPos(a){return{node:this.textDOM,offset:a}}ignoreMutation(a){return"characterData"===a.type&&a.target.nodeValue==a.oldValue}}class cX extends cU{constructor(a,b,c,d,e){super(a,[],c,d),this.mark=b,this.spec=e}static create(a,b,c,d){let e=d.nodeViews[b.type.name],f=e&&e(b,d,c);return f&&f.dom||(f=aJ.renderSpec(document,b.type.spec.toDOM(b,c),null,b.attrs)),new cX(a,b,f.dom,f.contentDOM||f.dom,f)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(a){return 3!=this.dirty&&this.mark.eq(a)}markDirty(a,b){if(super.markDirty(a,b),0!=this.dirty){let a=this.parent;for(;!a.node;)a=a.parent;a.dirty<this.dirty&&(a.dirty=this.dirty),this.dirty=0}}slice(a,b,c){let d=cX.create(this.parent,this.mark,!0,c),e=this.children,f=this.size;b<f&&(e=da(e,b,f,c)),a>0&&(e=da(e,0,a,c));for(let a=0;a<e.length;a++)e[a].parent=d;return d.children=e,d}ignoreMutation(a){return this.spec.ignoreMutation?this.spec.ignoreMutation(a):super.ignoreMutation(a)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class cY extends cU{constructor(a,b,c,d,e,f,g,h,i){super(a,[],e,f),this.node=b,this.outerDeco=c,this.innerDeco=d,this.nodeDOM=g}static create(a,b,c,d,e,f){let g=e.nodeViews[b.type.name],h,i=g&&g(b,e,()=>h?h.parent?h.parent.posBeforeChild(h):void 0:f,c,d),j=i&&i.dom,k=i&&i.contentDOM;if(b.isText)if(j){if(3!=j.nodeType)throw RangeError("Text must be rendered as a DOM text node")}else j=document.createTextNode(b.text);else if(!j){let a=aJ.renderSpec(document,b.type.spec.toDOM(b),null,b.attrs);({dom:j,contentDOM:k}=a)}k||b.isText||"BR"==j.nodeName||(j.hasAttribute("contenteditable")||(j.contentEditable="false"),b.type.spec.draggable&&(j.draggable=!0));let l=j;return(j=c5(j,c,b),i)?h=new c0(a,b,c,d,j,k||null,l,i,e,f+1):b.isText?new c$(a,b,c,d,j,l,e):new cY(a,b,c,d,j,k||null,l,e,f+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let a={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(a.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let b=this.children.length-1;b>=0;b--){let c=this.children[b];if(this.dom.contains(c.dom.parentNode)){a.contentElement=c.dom.parentNode;break}}a.contentElement||(a.getContent=()=>S.empty)}else a.contentElement=this.contentDOM;else a.getContent=()=>this.node.content;return a}matchesNode(a,b,c){return 0==this.dirty&&a.eq(this.node)&&c6(b,this.outerDeco)&&c.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(a,b){let c=this.node.inlineContent,d=b,e=a.composing?this.localCompositionInfo(a,b):null,f=e&&e.pos>-1?e:null,g=e&&e.pos<0,h=new c8(this,f&&f.node,a);(function(a,b,c,d){let e=b.locals(a),f=0;if(0==e.length){for(let c=0;c<a.childCount;c++){let g=a.child(c);d(g,e,b.forChild(f,g),c),f+=g.nodeSize}return}let g=0,h=[],i=null;for(let j=0;;){let k,l,m,n;for(;g<e.length&&e[g].to==f;){let a=e[g++];a.widget&&(k?(l||(l=[k])).push(a):k=a)}if(k)if(l){l.sort(c9);for(let a=0;a<l.length;a++)c(l[a],j,!!i)}else c(k,j,!!i);if(i)n=-1,m=i,i=null;else if(j<a.childCount)n=j,m=a.child(j++);else break;for(let a=0;a<h.length;a++)h[a].to<=f&&h.splice(a--,1);for(;g<e.length&&e[g].from<=f&&e[g].to>f;)h.push(e[g++]);let o=f+m.nodeSize;if(m.isText){let a=o;g<e.length&&e[g].from<a&&(a=e[g].from);for(let b=0;b<h.length;b++)h[b].to<a&&(a=h[b].to);a<o&&(i=m.cut(a-f),m=m.cut(0,a-f),o=a,n=-1)}else for(;g<e.length&&e[g].to<o;)g++;let p=m.isInline&&!m.isLeaf?h.filter(a=>!a.inline):h.slice();d(m,p,b.forChild(f,m),n),f=o}})(this.node,this.innerDeco,(b,e,f)=>{b.spec.marks?h.syncToMarks(b.spec.marks,c,a,e):b.type.side>=0&&!f&&h.syncToMarks(e==this.node.childCount?W.none:this.node.child(e).marks,c,a,e),h.placeWidget(b,a,d)},(b,f,i,j)=>{let k;h.syncToMarks(b.marks,c,a,j),h.findNodeMatch(b,f,i,j)||g&&a.state.selection.from>d&&a.state.selection.to<d+b.nodeSize&&(k=h.findIndexWithChild(e.node))>-1&&h.updateNodeAt(b,f,i,k,a)||h.updateNextNode(b,f,i,a,j,d)||h.addNode(b,f,i,a,d),d+=b.nodeSize}),h.syncToMarks([],c,a,0),this.node.isTextblock&&h.addTextblockHacks(),h.destroyRest(),(h.changed||2==this.dirty)&&(f&&this.protectLocalComposition(a,f),function a(b,c,d){let e=b.firstChild,f=!1;for(let g=0;g<c.length;g++){let h=c[g],i=h.dom;if(i.parentNode==b){for(;i!=e;)e=c7(e),f=!0;e=e.nextSibling}else f=!0,b.insertBefore(i,e);if(h instanceof cX){let c=e?e.previousSibling:b.lastChild;a(h.contentDOM,h.children,d),e=c?c.nextSibling:b.firstChild}}for(;e;)e=c7(e),f=!0;f&&d.trackWrites==b&&(d.trackWrites=null)}(this.contentDOM,this.children,a),cx&&function(a){if("UL"==a.nodeName||"OL"==a.nodeName){let b=a.style.cssText;a.style.cssText=b+"; list-style: square !important",window.getComputedStyle(a).listStyle,a.style.cssText=b}}(this.dom))}localCompositionInfo(a,b){let{from:c,to:d}=a.state.selection;if(!(a.state.selection instanceof bs)||c<b||d>b+this.node.content.size)return null;let e=a.input.compositionNode;if(!e||!this.dom.contains(e.parentNode))return null;if(!this.node.inlineContent)return{node:e,pos:-1,text:""};{let a=e.nodeValue,f=function(a,b,c,d){for(let e=0,f=0;e<a.childCount&&f<=d;){let g=a.child(e++),h=f;if(f+=g.nodeSize,!g.isText)continue;let i=g.text;for(;e<a.childCount;){let b=a.child(e++);if(f+=b.nodeSize,!b.isText)break;i+=b.text}if(f>=c){if(f>=d&&i.slice(d-b.length-h,d-h)==b)return d-b.length;let a=h<d?i.lastIndexOf(b,d-h-1):-1;if(a>=0&&a+b.length+h>=c)return h+a;if(c==d&&i.length>=d+b.length-h&&i.slice(d-h,d-h+b.length)==b)return d}}return -1}(this.node.content,a,c-b,d-b);return f<0?null:{node:e,pos:f,text:a}}}protectLocalComposition(a,{node:b,pos:c,text:d}){if(this.getDesc(b))return;let e=b;for(;e.parentNode!=this.contentDOM;e=e.parentNode){for(;e.previousSibling;)e.parentNode.removeChild(e.previousSibling);for(;e.nextSibling;)e.parentNode.removeChild(e.nextSibling);e.pmViewDesc&&(e.pmViewDesc=void 0)}let f=new cW(this,e,b,d);a.input.compositionNodes.push(f),this.children=da(this.children,c,c+d.length,a,f)}update(a,b,c,d){return 3!=this.dirty&&!!a.sameMarkup(this.node)&&(this.updateInner(a,b,c,d),!0)}updateInner(a,b,c,d){this.updateOuterDeco(b),this.node=a,this.innerDeco=c,this.contentDOM&&this.updateChildren(d,this.posAtStart),this.dirty=0}updateOuterDeco(a){if(c6(a,this.outerDeco))return;let b=1!=this.nodeDOM.nodeType,c=this.dom;this.dom=c4(this.dom,this.nodeDOM,c3(this.outerDeco,this.node,b),c3(a,this.node,b)),this.dom!=c&&(c.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=a}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function cZ(a,b,c,d,e){c5(d,b,a);let f=new cY(void 0,a,b,c,d,d,d,e,0);return f.contentDOM&&f.updateChildren(e,0),f}class c$ extends cY{constructor(a,b,c,d,e,f,g){super(a,b,c,d,e,null,f,g,0)}parseRule(){let a=this.nodeDOM.parentNode;for(;a&&a!=this.dom&&!a.pmIsDeco;)a=a.parentNode;return{skip:a||!0}}update(a,b,c,d){return 3!=this.dirty&&(0==this.dirty||!!this.inParent())&&!!a.sameMarkup(this.node)&&(this.updateOuterDeco(b),(0!=this.dirty||a.text!=this.node.text)&&a.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=a.text,d.trackWrites==this.nodeDOM&&(d.trackWrites=null)),this.node=a,this.dirty=0,!0)}inParent(){let a=this.parent.contentDOM;for(let b=this.nodeDOM;b;b=b.parentNode)if(b==a)return!0;return!1}domFromPos(a){return{node:this.nodeDOM,offset:a}}localPosFromDOM(a,b,c){return a==this.nodeDOM?this.posAtStart+Math.min(b,this.node.text.length):super.localPosFromDOM(a,b,c)}ignoreMutation(a){return"characterData"!=a.type&&"selection"!=a.type}slice(a,b,c){let d=this.node.cut(a,b),e=document.createTextNode(d.text);return new c$(this.parent,d,this.outerDeco,this.innerDeco,e,e,c)}markDirty(a,b){super.markDirty(a,b),this.dom!=this.nodeDOM&&(0==a||b==this.nodeDOM.nodeValue.length)&&(this.dirty=3)}get domAtom(){return!1}isText(a){return this.node.text==a}}class c_ extends cU{parseRule(){return{ignore:!0}}matchesHack(a){return 0==this.dirty&&this.dom.nodeName==a}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class c0 extends cY{constructor(a,b,c,d,e,f,g,h,i,j){super(a,b,c,d,e,f,g,i,j),this.spec=h}update(a,b,c,d){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==a.type||this.spec.multiType)){let e=this.spec.update(a,b,c);return e&&this.updateInner(a,b,c,d),e}return(!!this.contentDOM||!!a.isLeaf)&&super.update(a,b,c,d)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(a,b,c,d){this.spec.setSelection?this.spec.setSelection(a,b,c.root):super.setSelection(a,b,c,d)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(a){return!!this.spec.stopEvent&&this.spec.stopEvent(a)}ignoreMutation(a){return this.spec.ignoreMutation?this.spec.ignoreMutation(a):super.ignoreMutation(a)}}let c1=function(a){a&&(this.nodeName=a)};c1.prototype=Object.create(null);let c2=[new c1];function c3(a,b,c){if(0==a.length)return c2;let d=c?c2[0]:new c1,e=[d];for(let f=0;f<a.length;f++){let g=a[f].type.attrs;if(g)for(let a in g.nodeName&&e.push(d=new c1(g.nodeName)),g){let f=g[a];null!=f&&(c&&1==e.length&&e.push(d=new c1(b.isInline?"span":"div")),"class"==a?d.class=(d.class?d.class+" ":"")+f:"style"==a?d.style=(d.style?d.style+";":"")+f:"nodeName"!=a&&(d[a]=f))}}return e}function c4(a,b,c,d){if(c==c2&&d==c2)return b;let e=b;for(let b=0;b<d.length;b++){let f=d[b],g=c[b];if(b){let b;g&&g.nodeName==f.nodeName&&e!=a&&(b=e.parentNode)&&b.nodeName.toLowerCase()==f.nodeName||((b=document.createElement(f.nodeName)).pmIsDeco=!0,b.appendChild(e),g=c2[0]),e=b}!function(a,b,c){for(let d in b)"class"==d||"style"==d||"nodeName"==d||d in c||a.removeAttribute(d);for(let d in c)"class"!=d&&"style"!=d&&"nodeName"!=d&&c[d]!=b[d]&&a.setAttribute(d,c[d]);if(b.class!=c.class){let d=b.class?b.class.split(" ").filter(Boolean):[],e=c.class?c.class.split(" ").filter(Boolean):[];for(let b=0;b<d.length;b++)-1==e.indexOf(d[b])&&a.classList.remove(d[b]);for(let b=0;b<e.length;b++)-1==d.indexOf(e[b])&&a.classList.add(e[b]);0==a.classList.length&&a.removeAttribute("class")}if(b.style!=c.style){if(b.style){let c=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,d;for(;d=c.exec(b.style);)a.style.removeProperty(d[1])}c.style&&(a.style.cssText+=c.style)}}(e,g||c2[0],f)}return e}function c5(a,b,c){return c4(a,a,c2,c3(b,c,1!=a.nodeType))}function c6(a,b){if(a.length!=b.length)return!1;for(let c=0;c<a.length;c++)if(!a[c].type.eq(b[c].type))return!1;return!0}function c7(a){let b=a.nextSibling;return a.parentNode.removeChild(a),b}class c8{constructor(a,b,c){this.lock=b,this.view=c,this.index=0,this.stack=[],this.changed=!1,this.top=a,this.preMatch=function(a,b){let c=b,d=c.children.length,e=a.childCount,f=new Map,g=[];c:for(;e>0;){let h;for(;;)if(d){let a=c.children[d-1];if(a instanceof cX)c=a,d=a.children.length;else{h=a,d--;break}}else if(c==b)break c;else d=c.parent.children.indexOf(c),c=c.parent;let i=h.node;if(i){if(i!=a.child(e-1))break;--e,f.set(h,e),g.push(h)}}return{index:e,matched:f,matches:g.reverse()}}(a.node.content,a)}destroyBetween(a,b){if(a!=b){for(let c=a;c<b;c++)this.top.children[c].destroy();this.top.children.splice(a,b-a),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(a,b,c,d){let e=0,f=this.stack.length>>1,g=Math.min(f,a.length);for(;e<g&&(e==f-1?this.top:this.stack[e+1<<1]).matchesMark(a[e])&&!1!==a[e].type.spec.spanning;)e++;for(;e<f;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),f--;for(;f<a.length;){this.stack.push(this.top,this.index+1);let e=-1,g=this.top.children.length;d<this.preMatch.index&&(g=Math.min(this.index+3,g));for(let b=this.index;b<g;b++){let c=this.top.children[b];if(c.matchesMark(a[f])&&!this.isLocked(c.dom)){e=b;break}}if(e>-1)e>this.index&&(this.changed=!0,this.destroyBetween(this.index,e)),this.top=this.top.children[this.index];else{let d=cX.create(this.top,a[f],b,c);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,f++}}findNodeMatch(a,b,c,d){let e=-1,f;if(d>=this.preMatch.index&&(f=this.preMatch.matches[d-this.preMatch.index]).parent==this.top&&f.matchesNode(a,b,c))e=this.top.children.indexOf(f,this.index);else for(let d=this.index,f=Math.min(this.top.children.length,d+5);d<f;d++){let f=this.top.children[d];if(f.matchesNode(a,b,c)&&!this.preMatch.matched.has(f)){e=d;break}}return!(e<0)&&(this.destroyBetween(this.index,e),this.index++,!0)}updateNodeAt(a,b,c,d,e){let f=this.top.children[d];return 3==f.dirty&&f.dom==f.contentDOM&&(f.dirty=2),!!f.update(a,b,c,e)&&(this.destroyBetween(this.index,d),this.index++,!0)}findIndexWithChild(a){for(;;){let b=a.parentNode;if(!b)return -1;if(b==this.top.contentDOM){let b=a.pmViewDesc;if(b){for(let a=this.index;a<this.top.children.length;a++)if(this.top.children[a]==b)return a}return -1}a=b}}updateNextNode(a,b,c,d,e,f){for(let g=this.index;g<this.top.children.length;g++){let h=this.top.children[g];if(h instanceof cY){let i=this.preMatch.matched.get(h);if(null!=i&&i!=e)return!1;let j=h.dom,k,l=this.isLocked(j)&&!(a.isText&&h.node&&h.node.isText&&h.nodeDOM.nodeValue==a.text&&3!=h.dirty&&c6(b,h.outerDeco));if(!l&&h.update(a,b,c,d))return this.destroyBetween(this.index,g),h.dom!=j&&(this.changed=!0),this.index++,!0;if(!l&&(k=this.recreateWrapper(h,a,b,c,d,f)))return this.destroyBetween(this.index,g),this.top.children[this.index]=k,k.contentDOM&&(k.dirty=2,k.updateChildren(d,f+1),k.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(a,b,c,d,e,f){if(a.dirty||b.isAtom||!a.children.length||!a.node.content.eq(b.content)||!c6(c,a.outerDeco)||!d.eq(a.innerDeco))return null;let g=cY.create(this.top,b,c,d,e,f);if(g.contentDOM)for(let b of(g.children=a.children,a.children=[],g.children))b.parent=g;return a.destroy(),g}addNode(a,b,c,d,e){let f=cY.create(this.top,a,b,c,d,e);f.contentDOM&&f.updateChildren(d,e+1),this.top.children.splice(this.index++,0,f),this.changed=!0}placeWidget(a,b,c){let d=this.index<this.top.children.length?this.top.children[this.index]:null;if(d&&d.matchesWidget(a)&&(a==d.widget||!d.widget.type.toDOM.parentNode))this.index++;else{let d=new cV(this.top,a,b,c);this.top.children.splice(this.index++,0,d),this.changed=!0}}addTextblockHacks(){let a=this.top.children[this.index-1],b=this.top;for(;a instanceof cX;)a=(b=a).children[b.children.length-1];(!a||!(a instanceof c$)||/\n$/.test(a.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(a.node.text))&&((cw||cu)&&a&&"false"==a.dom.contentEditable&&this.addHackNode("IMG",b),this.addHackNode("BR",this.top))}addHackNode(a,b){if(b==this.top&&this.index<b.children.length&&b.children[this.index].matchesHack(a))this.index++;else{let c=document.createElement(a);"IMG"==a&&(c.className="ProseMirror-separator",c.alt=""),"BR"==a&&(c.className="ProseMirror-trailingBreak");let d=new c_(this.top,[],c,null);b!=this.top?b.children.push(d):b.children.splice(this.index++,0,d),this.changed=!0}}isLocked(a){return this.lock&&(a==this.lock||1==a.nodeType&&a.contains(this.lock.parentNode))}}function c9(a,b){return a.type.side-b.type.side}function da(a,b,c,d,e){let f=[];for(let g=0,h=0;g<a.length;g++){let i=a[g],j=h,k=h+=i.size;j>=c||k<=b?f.push(i):(j<b&&f.push(i.slice(0,b-j,d)),e&&(f.push(e),e=void 0),k>c&&f.push(i.slice(c-j,i.size,d)))}return f}function db(a,b=null){let c=a.domSelectionRange(),d=a.state.doc;if(!c.focusNode)return null;let e=a.docView.nearestDesc(c.focusNode),f=e&&0==e.size,g=a.docView.posFromDOM(c.focusNode,c.focusOffset,1);if(g<0)return null;let h=d.resolve(g),i,j;if(ci(c)){for(i=g;e&&!e.node;)e=e.parent;let a=e.node;if(e&&a.isAtom&&bu.isSelectable(a)&&e.parent&&!(a.isInline&&function(a,b,c){for(let d=0==b,e=b==cg(a);d||e;){if(a==c)return!0;let b=b8(a);if(!(a=a.parentNode))return!1;d=d&&0==b,e=e&&b==cg(a)}}(c.focusNode,c.focusOffset,e.dom))){let a=e.posBefore;j=new bu(g==a?h:d.resolve(a))}}else{if(c instanceof a.dom.ownerDocument.defaultView.Selection&&c.rangeCount>1){let b=g,e=g;for(let d=0;d<c.rangeCount;d++){let f=c.getRangeAt(d);b=Math.min(b,a.docView.posFromDOM(f.startContainer,f.startOffset,1)),e=Math.max(e,a.docView.posFromDOM(f.endContainer,f.endOffset,-1))}if(b<0)return null;[i,g]=e==a.state.selection.anchor?[e,b]:[b,e],h=d.resolve(g)}else i=a.docView.posFromDOM(c.anchorNode,c.anchorOffset,1);if(i<0)return null}let k=d.resolve(i);if(!j){let c="pointer"==b||a.state.selection.head<h.pos&&!f?1:-1;j=dk(a,k,h,c)}return j}function dc(a){return a.editable?a.hasFocus():dm(a)&&document.activeElement&&document.activeElement.contains(a.dom)}function dd(a,b=!1){let c=a.state.selection;if(di(a,c),dc(a)){if(!b&&a.input.mouseDown&&a.input.mouseDown.allowDefault&&cu){let b=a.domSelectionRange(),c=a.domObserver.currentSelection;if(b.anchorNode&&c.anchorNode&&cd(b.anchorNode,b.anchorOffset,c.anchorNode,c.anchorOffset)){a.input.mouseDown.delayedSelectionSync=!0,a.domObserver.setCurSelection();return}}if(a.domObserver.disconnectSelection(),a.cursorWrapper)!function(a){let b=a.domSelection();if(!b)return;let c=a.cursorWrapper.dom,d="IMG"==c.nodeName;d?b.collapse(c.parentNode,b8(c)+1):b.collapse(c,0),!d&&!a.state.selection.visible&&cq&&cr<=11&&(c.disabled=!0,c.disabled=!1)}(a);else{var d;let e,f,g,h,{anchor:i,head:j}=c,k,l;de&&!(c instanceof bs)&&(c.$from.parent.inlineContent||(k=df(a,c.from)),c.empty||c.$from.parent.inlineContent||(l=df(a,c.to))),a.docView.setSelection(i,j,a,b),de&&(k&&dh(k),l&&dh(l)),c.visible?a.dom.classList.remove("ProseMirror-hideselection"):(a.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&((e=(d=a).dom.ownerDocument).removeEventListener("selectionchange",d.input.hideSelectionGuard),g=(f=d.domSelectionRange()).anchorNode,h=f.anchorOffset,e.addEventListener("selectionchange",d.input.hideSelectionGuard=()=>{(f.anchorNode!=g||f.anchorOffset!=h)&&(e.removeEventListener("selectionchange",d.input.hideSelectionGuard),setTimeout(()=>{(!dc(d)||d.state.selection.visible)&&d.dom.classList.remove("ProseMirror-hideselection")},20))})))}a.domObserver.setCurSelection(),a.domObserver.connectSelection()}}let de=cw||cu&&cv<63;function df(a,b){let{node:c,offset:d}=a.docView.domFromPos(b,0),e=d<c.childNodes.length?c.childNodes[d]:null,f=d?c.childNodes[d-1]:null;if(cw&&e&&"false"==e.contentEditable)return dg(e);if((!e||"false"==e.contentEditable)&&(!f||"false"==f.contentEditable)){if(e)return dg(e);else if(f)return dg(f)}}function dg(a){return a.contentEditable="true",cw&&a.draggable&&(a.draggable=!1,a.wasDraggable=!0),a}function dh(a){a.contentEditable="false",a.wasDraggable&&(a.draggable=!0,a.wasDraggable=null)}function di(a,b){if(b instanceof bu){let c=a.docView.descAt(b.from);c!=a.lastSelectedViewDesc&&(dj(a),c&&c.selectNode(),a.lastSelectedViewDesc=c)}else dj(a)}function dj(a){a.lastSelectedViewDesc&&(a.lastSelectedViewDesc.parent&&a.lastSelectedViewDesc.deselectNode(),a.lastSelectedViewDesc=void 0)}function dk(a,b,c,d){return a.someProp("createSelectionBetween",d=>d(a,b,c))||bs.between(b,c,d)}function dl(a){return(!a.editable||!!a.hasFocus())&&dm(a)}function dm(a){let b=a.domSelectionRange();if(!b.anchorNode)return!1;try{return a.dom.contains(3==b.anchorNode.nodeType?b.anchorNode.parentNode:b.anchorNode)&&(a.editable||a.dom.contains(3==b.focusNode.nodeType?b.focusNode.parentNode:b.focusNode))}catch(a){return!1}}function dn(a,b){let{$anchor:c,$head:d}=a.selection,e=b>0?c.max(d):c.min(d),f=e.parent.inlineContent?e.depth?a.doc.resolve(b>0?e.after():e.before()):null:e;return f&&bo.findFrom(f,b)}function dp(a,b){return a.dispatch(a.state.tr.setSelection(b).scrollIntoView()),!0}function dq(a,b,c){let d=a.state.selection;if(d instanceof bs){if(c.indexOf("s")>-1){let{$head:c}=d,e=c.textOffset?null:b<0?c.nodeBefore:c.nodeAfter;if(!e||e.isText||!e.isLeaf)return!1;let f=a.state.doc.resolve(c.pos+e.nodeSize*(b<0?-1:1));return dp(a,new bs(d.$anchor,f))}else if(!d.empty)return!1;else if(a.endOfTextblock(b>0?"forward":"backward")){let c=dn(a.state,b);return!!c&&c instanceof bu&&dp(a,c)}else if(!(cy&&c.indexOf("m")>-1)){let c=d.$head,e=c.textOffset?null:b<0?c.nodeBefore:c.nodeAfter,f;if(!e||e.isText)return!1;let g=b<0?c.pos-e.nodeSize:c.pos;return!!(e.isAtom||(f=a.docView.descAt(g))&&!f.contentDOM)&&(bu.isSelectable(e)?dp(a,new bu(b<0?a.state.doc.resolve(c.pos-e.nodeSize):c)):!!cB&&dp(a,new bs(a.state.doc.resolve(b<0?g:g+e.nodeSize))))}}else{if(d instanceof bu&&d.node.isInline)return dp(a,new bs(b>0?d.$to:d.$from));let c=dn(a.state,b);return!!c&&dp(a,c)}}function dr(a){return 3==a.nodeType?a.nodeValue.length:a.childNodes.length}function ds(a,b){let c=a.pmViewDesc;return c&&0==c.size&&(b<0||a.nextSibling||"BR"!=a.nodeName)}function dt(a,b){return b<0?function(a){let b=a.domSelectionRange(),c=b.focusNode,d=b.focusOffset;if(!c)return;let e,f,g=!1;for(cs&&1==c.nodeType&&d<dr(c)&&ds(c.childNodes[d],-1)&&(g=!0);;)if(d>0)if(1!=c.nodeType)break;else{let a=c.childNodes[d-1];if(ds(a,-1))e=c,f=--d;else if(3==a.nodeType)d=(c=a).nodeValue.length;else break}else if(du(c))break;else{let b=c.previousSibling;for(;b&&ds(b,-1);)e=c.parentNode,f=b8(b),b=b.previousSibling;if(b)d=dr(c=b);else{if((c=c.parentNode)==a.dom)break;d=0}}g?dv(a,c,d):e&&dv(a,e,f)}(a):function(a){let b,c,d=a.domSelectionRange(),e=d.focusNode,f=d.focusOffset;if(!e)return;let g=dr(e);for(;;)if(f<g){if(1!=e.nodeType)break;if(ds(e.childNodes[f],1))b=e,c=++f;else break}else if(du(e))break;else{let d=e.nextSibling;for(;d&&ds(d,1);)b=d.parentNode,c=b8(d)+1,d=d.nextSibling;if(d)f=0,g=dr(e=d);else{if((e=e.parentNode)==a.dom)break;f=g=0}}b&&dv(a,b,c)}(a)}function du(a){let b=a.pmViewDesc;return b&&b.node&&b.node.isBlock}function dv(a,b,c){if(3!=b.nodeType){let a,d;(d=function(a,b){for(;a&&b==a.childNodes.length&&!ch(a);)b=b8(a)+1,a=a.parentNode;for(;a&&b<a.childNodes.length;){let c=a.childNodes[b];if(3==c.nodeType)return c;if(1==c.nodeType&&"false"==c.contentEditable)break;a=c,b=0}}(b,c))?(b=d,c=0):(a=function(a,b){for(;a&&!b&&!ch(a);)b=b8(a),a=a.parentNode;for(;a&&b;){let c=a.childNodes[b-1];if(3==c.nodeType)return c;if(1==c.nodeType&&"false"==c.contentEditable)break;b=(a=c).childNodes.length}}(b,c))&&(b=a,c=a.nodeValue.length)}let d=a.domSelection();if(!d)return;if(ci(d)){let a=document.createRange();a.setEnd(b,c),a.setStart(b,c),d.removeAllRanges(),d.addRange(a)}else d.extend&&d.extend(b,c);a.domObserver.setCurSelection();let{state:e}=a;setTimeout(()=>{a.state==e&&dd(a)},50)}function dw(a,b){let c=a.state.doc.resolve(b);if(!(cu||cz)&&c.parent.inlineContent){let d=a.coordsAtPos(b);if(b>c.start()){let c=a.coordsAtPos(b-1),e=(c.top+c.bottom)/2;if(e>d.top&&e<d.bottom&&Math.abs(c.left-d.left)>1)return c.left<d.left?"ltr":"rtl"}if(b<c.end()){let c=a.coordsAtPos(b+1),e=(c.top+c.bottom)/2;if(e>d.top&&e<d.bottom&&Math.abs(c.left-d.left)>1)return c.left>d.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(a.dom).direction?"rtl":"ltr"}function dx(a,b,c){let d=a.state.selection;if(d instanceof bs&&!d.empty||c.indexOf("s")>-1||cy&&c.indexOf("m")>-1)return!1;let{$from:e,$to:f}=d;if(!e.parent.inlineContent||a.endOfTextblock(b<0?"up":"down")){let c=dn(a.state,b);if(c&&c instanceof bu)return dp(a,c)}if(!e.parent.inlineContent){let c=b<0?e:f,g=d instanceof bw?bo.near(c,b):bo.findFrom(c,b);return!!g&&dp(a,g)}return!1}function dy(a,b){if(!(a.state.selection instanceof bs))return!0;let{$head:c,$anchor:d,empty:e}=a.state.selection;if(!c.sameParent(d))return!0;if(!e)return!1;if(a.endOfTextblock(b>0?"forward":"backward"))return!0;let f=!c.textOffset&&(b<0?c.nodeBefore:c.nodeAfter);if(f&&!f.isText){let d=a.state.tr;return b<0?d.delete(c.pos-f.nodeSize,c.pos):d.delete(c.pos,c.pos+f.nodeSize),a.dispatch(d),!0}return!1}function dz(a,b,c){a.domObserver.stop(),b.contentEditable=c,a.domObserver.start()}function dA(a,b){a.someProp("transformCopied",c=>{b=c(b,a)});let c=[],{content:d,openStart:e,openEnd:f}=b;for(;e>1&&f>1&&1==d.childCount&&1==d.firstChild.childCount;){e--,f--;let a=d.firstChild;c.push(a.type.name,a.attrs!=a.type.defaultAttrs?a.attrs:null),d=a.content}let g=a.someProp("clipboardSerializer")||aJ.fromSchema(a.state.schema),h=dI(),i=h.createElement("div");i.appendChild(g.serializeFragment(d,{document:h}));let j=i.firstChild,k,l=0;for(;j&&1==j.nodeType&&(k=dG[j.nodeName.toLowerCase()]);){for(let a=k.length-1;a>=0;a--){let b=h.createElement(k[a]);for(;i.firstChild;)b.appendChild(i.firstChild);i.appendChild(b),l++}j=i.firstChild}return j&&1==j.nodeType&&j.setAttribute("data-pm-slice",`${e} ${f}${l?` -${l}`:""} ${JSON.stringify(c)}`),{dom:i,text:a.someProp("clipboardTextSerializer",c=>c(b,a))||b.content.textBetween(0,b.content.size,"\n\n"),slice:b}}function dB(a,b,c,d,e){let f,g,h=e.parent.type.spec.code;if(!c&&!b)return null;let i=!!b&&(d||h||!c);if(i){if(a.someProp("transformPastedText",c=>{b=c(b,h||d,a)}),h)return g=new Y(S.from(a.state.schema.text(b.replace(/\r\n?/g,"\n"))),0,0),a.someProp("transformPasted",b=>{g=b(g,a,!0)}),g;let c=a.someProp("clipboardTextParser",c=>c(b,e,d,a));if(c)g=c;else{let c=e.marks(),{schema:d}=a.state,g=aJ.fromSchema(d);f=document.createElement("div"),b.split(/(?:\r\n?|\n)+/).forEach(a=>{let b=f.appendChild(document.createElement("p"));a&&b.appendChild(g.serializeNode(d.text(a,c)))})}}else a.someProp("transformPastedHTML",b=>{c=b(c,a)}),f=function(a){var b;let c,d=/^(\s*<meta [^>]*>)*/.exec(a);d&&(a=a.slice(d[0].length));let e=dI().createElement("div"),f=/<([a-z][^>\s]+)/i.exec(a),g;if((g=f&&dG[f[1].toLowerCase()])&&(a=g.map(a=>"<"+a+">").join("")+a+g.map(a=>"</"+a+">").reverse().join("")),e.innerHTML=(b=a,(c=window.trustedTypes)?(dJ||(dJ=c.defaultPolicy||c.createPolicy("ProseMirrorClipboard",{createHTML:a=>a})),dJ.createHTML(b)):b),g)for(let a=0;a<g.length;a++)e=e.querySelector(g[a])||e;return e}(c),cB&&function(a){let b=a.querySelectorAll(cu?"span:not([class]):not([style])":"span.Apple-converted-space");for(let c=0;c<b.length;c++){let d=b[c];1==d.childNodes.length&&"\xa0"==d.textContent&&d.parentNode&&d.parentNode.replaceChild(a.ownerDocument.createTextNode(" "),d)}}(f);let j=f&&f.querySelector("[data-pm-slice]"),k=j&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(j.getAttribute("data-pm-slice")||"");if(k&&k[3])for(let a=+k[3];a>0;a--){let a=f.firstChild;for(;a&&1!=a.nodeType;)a=a.nextSibling;if(!a)break;f=a}if(g||(g=(a.someProp("clipboardParser")||a.someProp("domParser")||aA.fromSchema(a.state.schema)).parseSlice(f,{preserveWhitespace:!!(i||k),context:e,ruleFromNode:a=>"BR"!=a.nodeName||a.nextSibling||!a.parentNode||dC.test(a.parentNode.nodeName)?null:{ignore:!0}})),k)g=function(a,b){if(!a.size)return a;let c=a.content.firstChild.type.schema,d;try{d=JSON.parse(b)}catch(b){return a}let{content:e,openStart:f,openEnd:g}=a;for(let a=d.length-2;a>=0;a-=2){let b=c.nodes[d[a]];if(!b||b.hasRequiredAttrs())break;e=S.from(b.create(d[a+1],e)),f++,g++}return new Y(e,f,g)}(dF(g,+k[1],+k[2]),k[4]);else if((g=Y.maxOpen(function(a,b){if(a.childCount<2)return a;for(let c=b.depth;c>=0;c--){let d=b.node(c).contentMatchAt(b.index(c)),e,f=[];if(a.forEach(a=>{if(!f)return;let b=d.findWrapping(a.type),c;if(!b)return f=null;if(c=f.length&&e.length&&function a(b,c,d,e,f){if(f<b.length&&f<c.length&&b[f]==c[f]){let g=a(b,c,d,e.lastChild,f+1);if(g)return e.copy(e.content.replaceChild(e.childCount-1,g));if(e.contentMatchAt(e.childCount).matchType(f==b.length-1?d.type:b[f+1]))return e.copy(e.content.append(S.from(dD(d,b,f+1))))}}(b,e,a,f[f.length-1],0))f[f.length-1]=c;else{f.length&&(f[f.length-1]=function a(b,c){if(0==c)return b;let d=b.content.replaceChild(b.childCount-1,a(b.lastChild,c-1)),e=b.contentMatchAt(b.childCount).fillBefore(S.empty,!0);return b.copy(d.append(e))}(f[f.length-1],e.length));let c=dD(a,b);f.push(c),d=d.matchType(c.type),e=b}}),f)return S.from(f)}return a}(g.content,e),!0)).openStart||g.openEnd){let a=0,b=0;for(let b=g.content.firstChild;a<g.openStart&&!b.type.spec.isolating;a++,b=b.firstChild);for(let a=g.content.lastChild;b<g.openEnd&&!a.type.spec.isolating;b++,a=a.lastChild);g=dF(g,a,b)}return a.someProp("transformPasted",b=>{g=b(g,a,i)}),g}let dC=/^(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 dD(a,b,c=0){for(let d=b.length-1;d>=c;d--)a=b[d].create(null,S.from(a));return a}function dE(a,b,c,d,e,f){let g=b<0?a.firstChild:a.lastChild,h=g.content;return a.childCount>1&&(f=0),e<d-1&&(h=dE(h,b,c,d,e+1,f)),e>=c&&(h=b<0?g.contentMatchAt(0).fillBefore(h,f<=e).append(h):h.append(g.contentMatchAt(g.childCount).fillBefore(S.empty,!0))),a.replaceChild(b<0?0:a.childCount-1,g.copy(h))}function dF(a,b,c){return b<a.openStart&&(a=new Y(dE(a.content,-1,b,a.openStart,0,a.openEnd),b,a.openEnd)),c<a.openEnd&&(a=new Y(dE(a.content,1,c,a.openEnd,0,0),a.openStart,c)),a}let dG={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},dH=null;function dI(){return dH||(dH=document.implementation.createHTMLDocument("title"))}let dJ=null,dK={},dL={},dM={touchstart:!0,touchmove:!0};class dN{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 dO(a,b){a.input.lastSelectionOrigin=b,a.input.lastSelectionTime=Date.now()}function dP(a){a.someProp("handleDOMEvents",b=>{for(let c in b)a.input.eventHandlers[c]||a.dom.addEventListener(c,a.input.eventHandlers[c]=b=>dQ(a,b))})}function dQ(a,b){return a.someProp("handleDOMEvents",c=>{let d=c[b.type];return!!d&&(d(a,b)||b.defaultPrevented)})}function dR(a){return{left:a.clientX,top:a.clientY}}function dS(a,b,c,d,e){if(-1==d)return!1;let f=a.state.doc.resolve(d);for(let d=f.depth+1;d>0;d--)if(a.someProp(b,b=>d>f.depth?b(a,c,f.nodeAfter,f.before(d),e,!0):b(a,c,f.node(d),f.before(d),e,!1)))return!0;return!1}function dT(a,b,c){if(a.focused||a.focus(),a.state.selection.eq(b))return;let d=a.state.tr.setSelection(b);"pointer"==c&&d.setMeta("pointer",!0),a.dispatch(d)}dL.keydown=(a,b)=>{if((a.input.shiftKey=16==b.keyCode||b.shiftKey,!dW(a,b))&&(a.input.lastKeyCode=b.keyCode,a.input.lastKeyCodeTime=Date.now(),!cA||!cu||13!=b.keyCode))if(229!=b.keyCode&&a.domObserver.forceFlush(),!cx||13!=b.keyCode||b.ctrlKey||b.altKey||b.metaKey)a.someProp("handleKeyDown",c=>c(a,b))||function(a,b){let c,d=b.keyCode,e=(c="",b.ctrlKey&&(c+="c"),b.metaKey&&(c+="m"),b.altKey&&(c+="a"),b.shiftKey&&(c+="s"),c);if(8==d||cy&&72==d&&"c"==e)return dy(a,-1)||dt(a,-1);if(46==d&&!b.shiftKey||cy&&68==d&&"c"==e)return dy(a,1)||dt(a,1);if(13==d||27==d)return!0;if(37==d||cy&&66==d&&"c"==e){let b=37==d?"ltr"==dw(a,a.state.selection.from)?-1:1:-1;return dq(a,b,e)||dt(a,b)}if(39==d||cy&&70==d&&"c"==e){let b=39==d?"ltr"==dw(a,a.state.selection.from)?1:-1:1;return dq(a,b,e)||dt(a,b)}else if(38==d||cy&&80==d&&"c"==e)return dx(a,-1,e)||dt(a,-1);else if(40==d||cy&&78==d&&"c"==e)return function(a){if(!cw||a.state.selection.$head.parentOffset>0)return!1;let{focusNode:b,focusOffset:c}=a.domSelectionRange();if(b&&1==b.nodeType&&0==c&&b.firstChild&&"false"==b.firstChild.contentEditable){let c=b.firstChild;dz(a,c,"true"),setTimeout(()=>dz(a,c,"false"),20)}return!1}(a)||dx(a,1,e)||dt(a,1);else if(e==(cy?"m":"c")&&(66==d||73==d||89==d||90==d))return!0;return!1}(a,b)?b.preventDefault():dO(a,"key");else{let b=Date.now();a.input.lastIOSEnter=b,a.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{a.input.lastIOSEnter==b&&(a.someProp("handleKeyDown",b=>b(a,cj(13,"Enter"))),a.input.lastIOSEnter=0)},200)}},dL.keyup=(a,b)=>{16==b.keyCode&&(a.input.shiftKey=!1)},dL.keypress=(a,b)=>{if(dW(a,b)||!b.charCode||b.ctrlKey&&!b.altKey||cy&&b.metaKey)return;if(a.someProp("handleKeyPress",c=>c(a,b)))return void b.preventDefault();let c=a.state.selection;if(!(c instanceof bs)||!c.$from.sameParent(c.$to)){let d=String.fromCharCode(b.charCode),e=()=>a.state.tr.insertText(d).scrollIntoView();/[\r\n]/.test(d)||a.someProp("handleTextInput",b=>b(a,c.$from.pos,c.$to.pos,d,e))||a.dispatch(e()),b.preventDefault()}};let dU=cy?"metaKey":"ctrlKey";dK.mousedown=(a,b)=>{var c;let d,e;a.input.shiftKey=b.shiftKey;let f=d$(a),g=Date.now(),h="singleClick";g-a.input.lastClick.time<500&&(d=(c=a.input.lastClick).x-b.clientX)*d+(e=c.y-b.clientY)*e<100&&!b[dU]&&a.input.lastClick.button==b.button&&("singleClick"==a.input.lastClick.type?h="doubleClick":"doubleClick"==a.input.lastClick.type&&(h="tripleClick")),a.input.lastClick={time:g,x:b.clientX,y:b.clientY,type:h,button:b.button};let i=a.posAtCoords(dR(b));i&&("singleClick"==h?(a.input.mouseDown&&a.input.mouseDown.done(),a.input.mouseDown=new dV(a,i,b,!!f)):("doubleClick"==h?function(a,b,c,d){return dS(a,"handleDoubleClickOn",b,c,d)||a.someProp("handleDoubleClick",c=>c(a,b,d))}:function(a,b,c,d){return dS(a,"handleTripleClickOn",b,c,d)||a.someProp("handleTripleClick",c=>c(a,b,d))||function(a,b,c){if(0!=c.button)return!1;let d=a.state.doc;if(-1==b)return!!d.inlineContent&&(dT(a,bs.create(d,0,d.content.size),"pointer"),!0);let e=d.resolve(b);for(let b=e.depth+1;b>0;b--){let c=b>e.depth?e.nodeAfter:e.node(b),f=e.before(b);if(c.inlineContent)dT(a,bs.create(d,f+1,f+1+c.content.size),"pointer");else{if(!bu.isSelectable(c))continue;dT(a,bu.create(d,f),"pointer")}return!0}}(a,c,d)})(a,i.pos,i.inside,b)?b.preventDefault():dO(a,"pointer"))};class dV{constructor(a,b,c,d){let e,f;if(this.view=a,this.pos=b,this.event=c,this.flushed=d,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=a.state.doc,this.selectNode=!!c[dU],this.allowDefault=c.shiftKey,b.inside>-1)e=a.state.doc.nodeAt(b.inside),f=b.inside;else{let c=a.state.doc.resolve(b.pos);e=c.parent,f=c.depth?c.before():0}const g=d?null:c.target,h=g?a.docView.nearestDesc(g,!0):null;this.target=h&&1==h.nodeDOM.nodeType?h.nodeDOM:null;let{selection:i}=a.state;(0==c.button&&e.type.spec.draggable&&!1!==e.type.spec.selectable||i instanceof bu&&i.from<=f&&i.to>f)&&(this.mightDrag={node:e,pos:f,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&cs&&!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()),a.root.addEventListener("mouseup",this.up=this.up.bind(this)),a.root.addEventListener("mousemove",this.move=this.move.bind(this)),dO(a,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),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(()=>dd(this.view)),this.view.input.mouseDown=null}up(a){if(this.done(),!this.view.dom.contains(a.target))return;let b=this.pos;if(this.view.state.doc!=this.startDoc&&(b=this.view.posAtCoords(dR(a))),this.updateAllowDefault(a),this.allowDefault||!b)dO(this.view,"pointer");else{var c,d,e,f;(c=this.view,d=b.pos,e=b.inside,f=this.selectNode,dS(c,"handleClickOn",d,e,a)||c.someProp("handleClick",b=>b(c,d,a))||(f?function(a,b){if(-1==b)return!1;let c=a.state.selection,d,e;c instanceof bu&&(d=c.node);let f=a.state.doc.resolve(b);for(let a=f.depth+1;a>0;a--){let b=a>f.depth?f.nodeAfter:f.node(a);if(bu.isSelectable(b)){e=d&&c.$from.depth>0&&a>=c.$from.depth&&f.before(c.$from.depth+1)==c.$from.pos?f.before(c.$from.depth):f.before(a);break}}return null!=e&&(dT(a,bu.create(a.state.doc,e),"pointer"),!0)}(c,e):function(a,b){if(-1==b)return!1;let c=a.state.doc.resolve(b),d=c.nodeAfter;return!!(d&&d.isAtom&&bu.isSelectable(d))&&(dT(a,new bu(c),"pointer"),!0)}(c,e)))?a.preventDefault():0==a.button&&(this.flushed||cw&&this.mightDrag&&!this.mightDrag.node.isAtom||cu&&!this.view.state.selection.visible&&2>=Math.min(Math.abs(b.pos-this.view.state.selection.from),Math.abs(b.pos-this.view.state.selection.to)))?(dT(this.view,bo.near(this.view.state.doc.resolve(b.pos)),"pointer"),a.preventDefault()):dO(this.view,"pointer")}}move(a){this.updateAllowDefault(a),dO(this.view,"pointer"),0==a.buttons&&this.done()}updateAllowDefault(a){!this.allowDefault&&(Math.abs(this.event.x-a.clientX)>4||Math.abs(this.event.y-a.clientY)>4)&&(this.allowDefault=!0)}}function dW(a,b){return!!a.composing||!!(cw&&500>Math.abs(b.timeStamp-a.input.compositionEndedAt))&&(a.input.compositionEndedAt=-2e8,!0)}dK.touchstart=a=>{a.input.lastTouch=Date.now(),d$(a),dO(a,"pointer")},dK.touchmove=a=>{a.input.lastTouch=Date.now(),dO(a,"pointer")},dK.contextmenu=a=>d$(a);let dX=cA?5e3:-1;function dY(a,b){clearTimeout(a.input.composingTimeout),b>-1&&(a.input.composingTimeout=setTimeout(()=>d$(a),b))}function dZ(a){let b;for(a.composing&&(a.input.composing=!1,a.input.compositionEndedAt=((b=document.createEvent("Event")).initEvent("event",!0,!0),b.timeStamp));a.input.compositionNodes.length>0;)a.input.compositionNodes.pop().markParentsDirty()}function d$(a,b=!1){if(!cA||!(a.domObserver.flushingSoon>=0)){if(a.domObserver.forceFlush(),dZ(a),b||a.docView&&a.docView.dirty){let c=db(a),d=a.state.selection;return c&&!c.eq(d)?a.dispatch(a.state.tr.setSelection(c)):(a.markCursor||b)&&!d.$from.node(d.$from.sharedDepth(d.to)).inlineContent?a.dispatch(a.state.tr.deleteSelection()):a.updateState(a.state),!0}return!1}}dL.compositionstart=dL.compositionupdate=a=>{if(!a.composing){a.domObserver.flush();let{state:b}=a,c=b.selection.$to;if(b.selection instanceof bs&&(b.storedMarks||!c.textOffset&&c.parentOffset&&c.nodeBefore.marks.some(a=>!1===a.type.spec.inclusive)||cu&&cz&&function(a){let{focusNode:b,focusOffset:c}=a.domSelectionRange();if(!b||1!=b.nodeType||c>=b.childNodes.length)return!1;let d=b.childNodes[c];return 1==d.nodeType&&"false"==d.contentEditable}(a)))a.markCursor=a.state.storedMarks||c.marks(),d$(a,!0),a.markCursor=null;else if(d$(a,!b.selection.empty),cs&&b.selection.empty&&c.parentOffset&&!c.textOffset&&c.nodeBefore.marks.length){let b=a.domSelectionRange();for(let c=b.focusNode,d=b.focusOffset;c&&1==c.nodeType&&0!=d;){let b=d<0?c.lastChild:c.childNodes[d-1];if(!b)break;if(3==b.nodeType){let c=a.domSelection();c&&c.collapse(b,b.nodeValue.length);break}c=b,d=-1}}a.input.composing=!0}dY(a,dX)},dL.compositionend=(a,b)=>{a.composing&&(a.input.composing=!1,a.input.compositionEndedAt=b.timeStamp,a.input.compositionPendingChanges=a.domObserver.pendingRecords().length?a.input.compositionID:0,a.input.compositionNode=null,a.input.badSafariComposition?a.domObserver.forceFlush():a.input.compositionPendingChanges&&Promise.resolve().then(()=>a.domObserver.flush()),a.input.compositionID++,dY(a,20))};let d_=cq&&cr<15||cx&&cC<604;function d0(a,b,c,d,e){let f=dB(a,b,c,d,a.state.selection.$from);if(a.someProp("handlePaste",b=>b(a,e,f||Y.empty)))return!0;if(!f)return!1;let g=0==f.openStart&&0==f.openEnd&&1==f.content.childCount?f.content.firstChild:null,h=g?a.state.tr.replaceSelectionWith(g,d):a.state.tr.replaceSelection(f);return a.dispatch(h.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function d1(a){let b=a.getData("text/plain")||a.getData("Text");if(b)return b;let c=a.getData("text/uri-list");return c?c.replace(/\r?\n/g," "):""}dK.copy=dL.cut=(a,b)=>{let c=a.state.selection,d="cut"==b.type;if(c.empty)return;let e=d_?null:b.clipboardData,{dom:f,text:g}=dA(a,c.content());e?(b.preventDefault(),e.clearData(),e.setData("text/html",f.innerHTML),e.setData("text/plain",g)):function(a,b){if(!a.dom.parentNode)return;let c=a.dom.parentNode.appendChild(document.createElement("div"));c.appendChild(b),c.style.cssText="position: fixed; left: -10000px; top: 10px";let d=getSelection(),e=document.createRange();e.selectNodeContents(b),a.dom.blur(),d.removeAllRanges(),d.addRange(e),setTimeout(()=>{c.parentNode&&c.parentNode.removeChild(c),a.focus()},50)}(a,f),d&&a.dispatch(a.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},dL.paste=(a,b)=>{if(a.composing&&!cA)return;let c=d_?null:b.clipboardData,d=a.input.shiftKey&&45!=a.input.lastKeyCode;c&&d0(a,d1(c),c.getData("text/html"),d,b)?b.preventDefault():function(a,b){if(!a.dom.parentNode)return;let c=a.input.shiftKey||a.state.selection.$from.parent.type.spec.code,d=a.dom.parentNode.appendChild(document.createElement(c?"textarea":"div"));c||(d.contentEditable="true"),d.style.cssText="position: fixed; left: -10000px; top: 10px",d.focus();let e=a.input.shiftKey&&45!=a.input.lastKeyCode;setTimeout(()=>{a.focus(),d.parentNode&&d.parentNode.removeChild(d),c?d0(a,d.value,null,e,b):d0(a,d.textContent,d.innerHTML,e,b)},50)}(a,b)};class d2{constructor(a,b,c){this.slice=a,this.move=b,this.node=c}}let d3=cy?"altKey":"ctrlKey";function d4(a,b){let c=a.someProp("dragCopies",a=>!a(b));return null!=c?c:!b[d3]}for(let a in dK.dragstart=(a,b)=>{let c,d=a.input.mouseDown;if(d&&d.done(),!b.dataTransfer)return;let e=a.state.selection,f=e.empty?null:a.posAtCoords(dR(b));if(f&&f.pos>=e.from&&f.pos<=(e instanceof bu?e.to-1:e.to));else if(d&&d.mightDrag)c=bu.create(a.state.doc,d.mightDrag.pos);else if(b.target&&1==b.target.nodeType){let d=a.docView.nearestDesc(b.target,!0);d&&d.node.type.spec.draggable&&d!=a.docView&&(c=bu.create(a.state.doc,d.posBefore))}let g=(c||a.state.selection).content(),{dom:h,text:i,slice:j}=dA(a,g);b.dataTransfer.files.length&&cu&&!(cv>120)||b.dataTransfer.clearData(),b.dataTransfer.setData(d_?"Text":"text/html",h.innerHTML),b.dataTransfer.effectAllowed="copyMove",d_||b.dataTransfer.setData("text/plain",i),a.dragging=new d2(j,d4(a,b),c)},dK.dragend=a=>{let b=a.dragging;window.setTimeout(()=>{a.dragging==b&&(a.dragging=null)},50)},dL.dragover=dL.dragenter=(a,b)=>b.preventDefault(),dL.drop=(a,b)=>{try{!function(a,b,c){if(!b.dataTransfer)return;let d=a.posAtCoords(dR(b));if(!d)return;let e=a.state.doc.resolve(d.pos),f=c&&c.slice;f?a.someProp("transformPasted",b=>{f=b(f,a,!1)}):f=dB(a,d1(b.dataTransfer),d_?null:b.dataTransfer.getData("text/html"),!1,e);let g=!!(c&&d4(a,b));if(a.someProp("handleDrop",c=>c(a,b,f||Y.empty,g)))return b.preventDefault();if(!f)return;b.preventDefault();let h=f?ba(a.state.doc,e.pos,f):e.pos;null==h&&(h=e.pos);let i=a.state.tr;if(g){let{node:a}=c;a?a.replace(i):i.deleteSelection()}let j=i.mapping.map(h),k=0==f.openStart&&0==f.openEnd&&1==f.content.childCount,l=i.doc;if(k?i.replaceRangeWith(j,j,f.content.firstChild):i.replaceRange(j,j,f),i.doc.eq(l))return;let m=i.doc.resolve(j);if(k&&bu.isSelectable(f.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(f.content.firstChild))i.setSelection(new bu(m));else{let b=i.mapping.map(h);i.mapping.maps[i.mapping.maps.length-1].forEach((a,c,d,e)=>b=e),i.setSelection(dk(a,m,i.doc.resolve(b)))}a.focus(),a.dispatch(i.setMeta("uiEvent","drop"))}(a,b,a.dragging)}finally{a.dragging=null}},dK.focus=a=>{a.input.lastFocus=Date.now(),a.focused||(a.domObserver.stop(),a.dom.classList.add("ProseMirror-focused"),a.domObserver.start(),a.focused=!0,setTimeout(()=>{a.docView&&a.hasFocus()&&!a.domObserver.currentSelection.eq(a.domSelectionRange())&&dd(a)},20))},dK.blur=(a,b)=>{a.focused&&(a.domObserver.stop(),a.dom.classList.remove("ProseMirror-focused"),a.domObserver.start(),b.relatedTarget&&a.dom.contains(b.relatedTarget)&&a.domObserver.currentSelection.clear(),a.focused=!1)},dK.beforeinput=(a,b)=>{if(cu&&cA&&"deleteContentBackward"==b.inputType){a.domObserver.flushSoon();let{domChangeCount:b}=a.input;setTimeout(()=>{if(a.input.domChangeCount!=b||(a.dom.blur(),a.focus(),a.someProp("handleKeyDown",b=>b(a,cj(8,"Backspace")))))return;let{$cursor:c}=a.state.selection;c&&c.pos>0&&a.dispatch(a.state.tr.delete(c.pos-1,c.pos).scrollIntoView())},50)}},dL)dK[a]=dL[a];function d5(a,b){if(a==b)return!0;for(let c in a)if(a[c]!==b[c])return!1;for(let c in b)if(!(c in a))return!1;return!0}class d6{constructor(a,b){this.toDOM=a,this.spec=b||eb,this.side=this.spec.side||0}map(a,b,c,d){let{pos:e,deleted:f}=a.mapResult(b.from+d,this.side<0?-1:1);return f?null:new d9(e-c,e-c,this)}valid(){return!0}eq(a){return this==a||a instanceof d6&&(this.spec.key&&this.spec.key==a.spec.key||this.toDOM==a.toDOM&&d5(this.spec,a.spec))}destroy(a){this.spec.destroy&&this.spec.destroy(a)}}class d7{constructor(a,b){this.attrs=a,this.spec=b||eb}map(a,b,c,d){let e=a.map(b.from+d,this.spec.inclusiveStart?-1:1)-c,f=a.map(b.to+d,this.spec.inclusiveEnd?1:-1)-c;return e>=f?null:new d9(e,f,this)}valid(a,b){return b.from<b.to}eq(a){return this==a||a instanceof d7&&d5(this.attrs,a.attrs)&&d5(this.spec,a.spec)}static is(a){return a.type instanceof d7}destroy(){}}class d8{constructor(a,b){this.attrs=a,this.spec=b||eb}map(a,b,c,d){let e=a.mapResult(b.from+d,1);if(e.deleted)return null;let f=a.mapResult(b.to+d,-1);return f.deleted||f.pos<=e.pos?null:new d9(e.pos-c,f.pos-c,this)}valid(a,b){let{index:c,offset:d}=a.content.findIndex(b.from),e;return d==b.from&&!(e=a.child(c)).isText&&d+e.nodeSize==b.to}eq(a){return this==a||a instanceof d8&&d5(this.attrs,a.attrs)&&d5(this.spec,a.spec)}destroy(){}}class d9{constructor(a,b,c){this.from=a,this.to=b,this.type=c}copy(a,b){return new d9(a,b,this.type)}eq(a,b=0){return this.type.eq(a.type)&&this.from+b==a.from&&this.to+b==a.to}map(a,b,c){return this.type.map(a,this,b,c)}static widget(a,b,c){return new d9(a,a,new d6(b,c))}static inline(a,b,c,d){return new d9(a,b,new d7(c,d))}static node(a,b,c,d){return new d9(a,b,new d8(c,d))}get spec(){return this.type.spec}get inline(){return this.type instanceof d7}get widget(){return this.type instanceof d6}}let ea=[],eb={};class ec{constructor(a,b){this.local=a.length?a:ea,this.children=b.length?b:ea}static create(a,b){return b.length?ei(b,a,0,eb):ed}find(a,b,c){let d=[];return this.findInner(null==a?0:a,null==b?1e9:b,d,0,c),d}findInner(a,b,c,d,e){for(let f=0;f<this.local.length;f++){let g=this.local[f];g.from<=b&&g.to>=a&&(!e||e(g.spec))&&c.push(g.copy(g.from+d,g.to+d))}for(let f=0;f<this.children.length;f+=3)if(this.children[f]<b&&this.children[f+1]>a){let g=this.children[f]+1;this.children[f+2].findInner(a-g,b-g,c,d+g,e)}}map(a,b,c){return this==ed||0==a.maps.length?this:this.mapInner(a,b,0,0,c||eb)}mapInner(a,b,c,d,e){let f;for(let g=0;g<this.local.length;g++){let h=this.local[g].map(a,c,d);h&&h.type.valid(b,h)?(f||(f=[])).push(h):e.onRemove&&e.onRemove(this.local[g].spec)}return this.children.length?function(a,b,c,d,e,f,g){let h=a.slice();for(let a=0,b=f;a<c.maps.length;a++){let d=0;c.maps[a].forEach((a,c,e,f)=>{let g=f-e-(c-a);for(let e=0;e<h.length;e+=3){let f=h[e+1];if(f<0||a>f+b-d)continue;let i=h[e]+b-d;c>=i?h[e+1]=a<=i?-2:-1:a>=b&&g&&(h[e]+=g,h[e+1]+=g)}d+=g}),b=c.maps[a].map(b,-1)}let i=!1;for(let b=0;b<h.length;b+=3)if(h[b+1]<0){if(-2==h[b+1]){i=!0,h[b+1]=-1;continue}let j=c.map(a[b]+f),k=j-e;if(k<0||k>=d.content.size){i=!0;continue}let l=c.map(a[b+1]+f,-1)-e,{index:m,offset:n}=d.content.findIndex(k),o=d.maybeChild(m);if(o&&n==k&&n+o.nodeSize==l){let d=h[b+2].mapInner(c,o,j+1,a[b]+f+1,g);d!=ed?(h[b]=k,h[b+1]=l,h[b+2]=d):(h[b+1]=-2,i=!0)}else i=!0}if(i){let i=ei(function(a,b,c,d,e,f,g){for(let h=0;h<a.length;h+=3)-1==a[h+1]&&function a(b,f){for(let a=0;a<b.local.length;a++){let h=b.local[a].map(d,e,f);h?c.push(h):g.onRemove&&g.onRemove(b.local[a].spec)}for(let c=0;c<b.children.length;c+=3)a(b.children[c+2],b.children[c]+f+1)}(a[h+2],b[h]+f+1);return c}(h,a,b,c,e,f,g),d,0,g);b=i.local;for(let a=0;a<h.length;a+=3)h[a+1]<0&&(h.splice(a,3),a-=3);for(let a=0,b=0;a<i.children.length;a+=3){let c=i.children[a];for(;b<h.length&&h[b]<c;)b+=3;h.splice(b,0,i.children[a],i.children[a+1],i.children[a+2])}}return new ec(b.sort(ej),h)}(this.children,f||[],a,b,c,d,e):f?new ec(f.sort(ej),ea):ed}add(a,b){return b.length?this==ed?ec.create(a,b):this.addInner(a,b,0):this}addInner(a,b,c){let d,e=0;a.forEach((a,f)=>{let g=f+c,h;if(h=eg(b,a,g)){for(d||(d=this.children.slice());e<d.length&&d[e]<f;)e+=3;d[e]==f?d[e+2]=d[e+2].addInner(a,h,g+1):d.splice(e,0,f,f+a.nodeSize,ei(h,a,g+1,eb)),e+=3}});let f=ef(e?eh(b):b,-c);for(let b=0;b<f.length;b++)f[b].type.valid(a,f[b])||f.splice(b--,1);return new ec(f.length?this.local.concat(f).sort(ej):this.local,d||this.children)}remove(a){return 0==a.length||this==ed?this:this.removeInner(a,0)}removeInner(a,b){let c=this.children,d=this.local;for(let d=0;d<c.length;d+=3){let e,f=c[d]+b,g=c[d+1]+b;for(let b=0,c;b<a.length;b++)(c=a[b])&&c.from>f&&c.to<g&&(a[b]=null,(e||(e=[])).push(c));if(!e)continue;c==this.children&&(c=this.children.slice());let h=c[d+2].removeInner(e,f+1);h!=ed?c[d+2]=h:(c.splice(d,3),d-=3)}if(d.length){for(let c=0,e;c<a.length;c++)if(e=a[c])for(let a=0;a<d.length;a++)d[a].eq(e,b)&&(d==this.local&&(d=this.local.slice()),d.splice(a--,1))}return c==this.children&&d==this.local?this:d.length||c.length?new ec(d,c):ed}forChild(a,b){let c,d;if(this==ed)return this;if(b.isLeaf)return ec.empty;for(let b=0;b<this.children.length;b+=3)if(this.children[b]>=a){this.children[b]==a&&(c=this.children[b+2]);break}let e=a+1,f=e+b.content.size;for(let a=0;a<this.local.length;a++){let b=this.local[a];if(b.from<f&&b.to>e&&b.type instanceof d7){let a=Math.max(e,b.from)-e,c=Math.min(f,b.to)-e;a<c&&(d||(d=[])).push(b.copy(a,c))}}if(d){let a=new ec(d.sort(ej),ea);return c?new ee([a,c]):a}return c||ed}eq(a){if(this==a)return!0;if(!(a instanceof ec)||this.local.length!=a.local.length||this.children.length!=a.children.length)return!1;for(let b=0;b<this.local.length;b++)if(!this.local[b].eq(a.local[b]))return!1;for(let b=0;b<this.children.length;b+=3)if(this.children[b]!=a.children[b]||this.children[b+1]!=a.children[b+1]||!this.children[b+2].eq(a.children[b+2]))return!1;return!0}locals(a){return ek(this.localsInner(a))}localsInner(a){if(this==ed)return ea;if(a.inlineContent||!this.local.some(d7.is))return this.local;let b=[];for(let a=0;a<this.local.length;a++)this.local[a].type instanceof d7||b.push(this.local[a]);return b}forEachSet(a){a(this)}}ec.empty=new ec([],[]),ec.removeOverlap=ek;let ed=ec.empty;class ee{constructor(a){this.members=a}map(a,b){let c=this.members.map(c=>c.map(a,b,eb));return ee.from(c)}forChild(a,b){if(b.isLeaf)return ec.empty;let c=[];for(let d=0;d<this.members.length;d++){let e=this.members[d].forChild(a,b);e!=ed&&(e instanceof ee?c=c.concat(e.members):c.push(e))}return ee.from(c)}eq(a){if(!(a instanceof ee)||a.members.length!=this.members.length)return!1;for(let b=0;b<this.members.length;b++)if(!this.members[b].eq(a.members[b]))return!1;return!0}locals(a){let b,c=!0;for(let d=0;d<this.members.length;d++){let e=this.members[d].localsInner(a);if(e.length)if(b){c&&(b=b.slice(),c=!1);for(let a=0;a<e.length;a++)b.push(e[a])}else b=e}return b?ek(c?b:b.sort(ej)):ea}static from(a){switch(a.length){case 0:return ed;case 1:return a[0];default:return new ee(a.every(a=>a instanceof ec)?a:a.reduce((a,b)=>a.concat(b instanceof ec?b:b.members),[]))}}forEachSet(a){for(let b=0;b<this.members.length;b++)this.members[b].forEachSet(a)}}function ef(a,b){if(!b||!a.length)return a;let c=[];for(let d=0;d<a.length;d++){let e=a[d];c.push(new d9(e.from+b,e.to+b,e.type))}return c}function eg(a,b,c){if(b.isLeaf)return null;let d=c+b.nodeSize,e=null;for(let b=0,f;b<a.length;b++)(f=a[b])&&f.from>c&&f.to<d&&((e||(e=[])).push(f),a[b]=null);return e}function eh(a){let b=[];for(let c=0;c<a.length;c++)null!=a[c]&&b.push(a[c]);return b}function ei(a,b,c,d){let e=[],f=!1;b.forEach((b,g)=>{let h=eg(a,b,g+c);if(h){f=!0;let a=ei(h,b,c+g+1,d);a!=ed&&e.push(g,g+b.nodeSize,a)}});let g=ef(f?eh(a):a,-c).sort(ej);for(let a=0;a<g.length;a++)g[a].type.valid(b,g[a])||(d.onRemove&&d.onRemove(g[a].spec),g.splice(a--,1));return g.length||e.length?new ec(g,e):ed}function ej(a,b){return a.from-b.from||a.to-b.to}function ek(a){let b=a;for(let c=0;c<b.length-1;c++){let d=b[c];if(d.from!=d.to)for(let e=c+1;e<b.length;e++){let f=b[e];if(f.from==d.from){f.to!=d.to&&(b==a&&(b=a.slice()),b[e]=f.copy(f.from,d.to),el(b,e+1,f.copy(d.to,f.to)));continue}f.from<d.to&&(b==a&&(b=a.slice()),b[c]=d.copy(d.from,f.from),el(b,e,d.copy(f.from,d.to)));break}}return b}function el(a,b,c){for(;b<a.length&&ej(c,a[b])>0;)b++;a.splice(b,0,c)}function em(a){let b=[];return a.someProp("decorations",c=>{let d=c(a.state);d&&d!=ed&&b.push(d)}),a.cursorWrapper&&b.push(ec.create(a.state.doc,[a.cursorWrapper.deco])),ee.from(b)}let en={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},eo=cq&&cr<=11;class ep{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(a){this.anchorNode=a.anchorNode,this.anchorOffset=a.anchorOffset,this.focusNode=a.focusNode,this.focusOffset=a.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(a){return a.anchorNode==this.anchorNode&&a.anchorOffset==this.anchorOffset&&a.focusNode==this.focusNode&&a.focusOffset==this.focusOffset}}class eq{constructor(a,b){this.view=a,this.handleDOMChange=b,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ep,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(b=>{for(let a=0;a<b.length;a++)this.queue.push(b[a]);cq&&cr<=11&&b.some(a=>"childList"==a.type&&a.removedNodes.length||"characterData"==a.type&&a.oldValue.length>a.target.nodeValue.length)?this.flushSoon():cw&&a.composing&&b.some(a=>"childList"==a.type&&"TR"==a.target.nodeName)?(a.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),eo&&(this.onCharData=a=>{this.queue.push({target:a.target,type:"characterData",oldValue:a.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,en)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let a=this.observer.takeRecords();if(a.length){for(let b=0;b<a.length;b++)this.queue.push(a[b]);window.setTimeout(()=>this.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(dl(this.view)){if(this.suppressingSelectionUpdates)return dd(this.view);if(cq&&cr<=11&&!this.view.state.selection.empty){let a=this.view.domSelectionRange();if(a.focusNode&&cd(a.focusNode,a.focusOffset,a.anchorNode,a.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(a){if(!a.focusNode)return!0;let b=new Set,c;for(let c=a.focusNode;c;c=b9(c))b.add(c);for(let d=a.anchorNode;d;d=b9(d))if(b.has(d)){c=d;break}let d=c&&this.view.docView.nearestDesc(c);if(d&&d.ignoreMutation({type:"selection",target:3==c.nodeType?c.parentNode:c}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let a of this.observer.takeRecords())this.queue.push(a);return this.queue}flush(){var a;let{view:b}=this;if(!b.docView||this.flushingSoon>-1)return;let c=this.pendingRecords();c.length&&(this.queue=[]);let d=b.domSelectionRange(),e=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(d)&&dl(b)&&!this.ignoreSelectionChange(d),f=-1,g=-1,h=!1,i=[];if(b.editable)for(let a=0;a<c.length;a++){let b=this.registerMutation(c[a],i);b&&(f=f<0?b.from:Math.min(b.from,f),g=g<0?b.to:Math.max(b.to,g),b.typeOver&&(h=!0))}if(i.some(a=>"BR"==a.nodeName)&&(8==b.input.lastKeyCode||46==b.input.lastKeyCode)){for(let a of i)if("BR"==a.nodeName&&a.parentNode){let b=a.nextSibling;b&&1==b.nodeType&&"false"==b.contentEditable&&a.parentNode.removeChild(a)}}else if(cs&&i.length){let a=i.filter(a=>"BR"==a.nodeName);if(2==a.length){let[b,c]=a;b.parentNode&&b.parentNode.parentNode==c.parentNode?c.remove():b.remove()}else{let{focusNode:c}=this.currentSelection;for(let d of a){let a=d.parentNode;a&&"LI"==a.nodeName&&(!c||function(a,b){for(let c=b.parentNode;c&&c!=a.dom;c=c.parentNode){let b=a.docView.nearestDesc(c,!0);if(b&&b.node.isBlock)return c}return null}(b,c)!=a)&&d.remove()}}}let j=null;f<0&&e&&b.input.lastFocus>Date.now()-200&&Math.max(b.input.lastTouch,b.input.lastClick.time)<Date.now()-300&&ci(d)&&(j=db(b))&&j.eq(bo.near(b.state.doc.resolve(0),1))?(b.input.lastFocus=0,dd(b),this.currentSelection.set(d),b.scrollToSelection()):(f>-1||e)&&(f>-1&&(b.docView.markDirty(f,g),a=b,!er.has(a)&&(er.set(a,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(a.dom).whiteSpace))&&(a.requiresGeckoHackNode=cs,es||(console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),es=!0))),b.input.badSafariComposition&&(b.input.badSafariComposition=!1,function(a,b){var c;let{focusNode:d,focusOffset:e}=a.domSelectionRange();for(let f of b)if((null==(c=f.parentNode)?void 0:c.nodeName)=="TR"){let b=f.nextSibling;for(;b&&"TD"!=b.nodeName&&"TH"!=b.nodeName;)b=b.nextSibling;if(b){let c=b;for(;;){let a=c.firstChild;if(!a||1!=a.nodeType||"false"==a.contentEditable||/^(BR|IMG)$/.test(a.nodeName))break;c=a}c.insertBefore(f,c.firstChild),d==f&&a.domSelection().collapse(f,e)}else f.parentNode.removeChild(f)}}(b,i)),this.handleDOMChange(f,g,h,i),b.docView&&b.docView.dirty?b.updateState(b.state):this.currentSelection.eq(d)||dd(b),this.currentSelection.set(d))}registerMutation(a,b){if(b.indexOf(a.target)>-1)return null;let c=this.view.docView.nearestDesc(a.target);if("attributes"==a.type&&(c==this.view.docView||"contenteditable"==a.attributeName||"style"==a.attributeName&&!a.oldValue&&!a.target.getAttribute("style"))||!c||c.ignoreMutation(a))return null;if("childList"==a.type){for(let c=0;c<a.addedNodes.length;c++){let d=a.addedNodes[c];b.push(d),3==d.nodeType&&(this.lastChangedTextNode=d)}if(c.contentDOM&&c.contentDOM!=c.dom&&!c.contentDOM.contains(a.target))return{from:c.posBefore,to:c.posAfter};let d=a.previousSibling,e=a.nextSibling;if(cq&&cr<=11&&a.addedNodes.length)for(let b=0;b<a.addedNodes.length;b++){let{previousSibling:c,nextSibling:f}=a.addedNodes[b];(!c||0>Array.prototype.indexOf.call(a.addedNodes,c))&&(d=c),(!f||0>Array.prototype.indexOf.call(a.addedNodes,f))&&(e=f)}let f=d&&d.parentNode==a.target?b8(d)+1:0,g=c.localPosFromDOM(a.target,f,-1),h=e&&e.parentNode==a.target?b8(e):a.target.childNodes.length;return{from:g,to:c.localPosFromDOM(a.target,h,1)}}return"attributes"==a.type?{from:c.posAtStart-c.border,to:c.posAtEnd+c.border}:(this.lastChangedTextNode=a.target,{from:c.posAtStart,to:c.posAtEnd,typeOver:a.target.nodeValue==a.oldValue})}}let er=new WeakMap,es=!1;function et(a,b){let c=b.startContainer,d=b.startOffset,e=b.endContainer,f=b.endOffset,g=a.domAtPos(a.state.selection.anchor);return cd(g.node,g.offset,e,f)&&([c,d,e,f]=[e,f,c,d]),{anchorNode:c,anchorOffset:d,focusNode:e,focusOffset:f}}function eu(a){let b=a.pmViewDesc;if(b)return b.parseRule();if("BR"==a.nodeName&&a.parentNode){if(cw&&/^(ul|ol)$/i.test(a.parentNode.nodeName)){let a=document.createElement("div");return a.appendChild(document.createElement("li")),{skip:a}}else if(a.parentNode.lastChild==a||cw&&/^(tr|table)$/i.test(a.parentNode.nodeName))return{ignore:!0}}else if("IMG"==a.nodeName&&a.getAttribute("mark-placeholder"))return{ignore:!0};return null}let ev=/^(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 ew(a,b,c){return Math.max(c.anchor,c.head)>b.content.size?null:dk(a,b.resolve(c.anchor),b.resolve(c.head))}function ex(a,b,c){let d=a.depth,e=b?a.end():a.pos;for(;d>0&&(b||a.indexAfter(d)==a.node(d).childCount);)d--,e++,b=!1;if(c){let b=a.node(d).maybeChild(a.indexAfter(d));for(;b&&!b.isLeaf;)b=b.firstChild,e++}return e}function ey(a){if(2!=a.length)return!1;let b=a.charCodeAt(0),c=a.charCodeAt(1);return b>=56320&&b<=57343&&c>=55296&&c<=56319}class ez{constructor(a,b){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 dN,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=b,this.state=b.state,this.directPlugins=b.plugins||[],this.directPlugins.forEach(eE),this.dispatch=this.dispatch.bind(this),this.dom=a&&a.mount||document.createElement("div"),a&&(a.appendChild?a.appendChild(this.dom):"function"==typeof a?a(this.dom):a.mount&&(this.mounted=!0)),this.editable=eC(this),eB(this),this.nodeViews=eD(this),this.docView=cZ(this.state.doc,eA(this),em(this),this.dom,this),this.domObserver=new eq(this,(a,b,c,d)=>(function(a,b,c,d,e){let f,g,h,i=a.input.compositionPendingChanges||(a.composing?a.input.compositionID:0);if(a.input.compositionPendingChanges=0,b<0){let b=a.input.lastSelectionTime>Date.now()-50?a.input.lastSelectionOrigin:null,c=db(a,b);if(c&&!a.state.selection.eq(c)){if(cu&&cA&&13===a.input.lastKeyCode&&Date.now()-100<a.input.lastKeyCodeTime&&a.someProp("handleKeyDown",b=>b(a,cj(13,"Enter"))))return;let d=a.state.tr.setSelection(c);"pointer"==b?d.setMeta("pointer",!0):"key"==b&&d.scrollIntoView(),i&&d.setMeta("composition",i),a.dispatch(d)}return}let j=a.state.doc.resolve(b),k=j.sharedDepth(c);b=j.before(k+1),c=a.state.doc.resolve(c).after(k+1);let l=a.state.selection,m=function(a,b,c){let d,{node:e,fromOffset:f,toOffset:g,from:h,to:i}=a.docView.parseRange(b,c),j=a.domSelectionRange(),k=j.anchorNode;if(k&&a.dom.contains(1==k.nodeType?k:k.parentNode)&&(d=[{node:k,offset:j.anchorOffset}],ci(j)||d.push({node:j.focusNode,offset:j.focusOffset})),cu&&8===a.input.lastKeyCode)for(let a=g;a>f;a--){let b=e.childNodes[a-1],c=b.pmViewDesc;if("BR"==b.nodeName&&!c){g=a;break}if(!c||c.size)break}let l=a.state.doc,m=a.someProp("domParser")||aA.fromSchema(a.state.schema),n=l.resolve(h),o=null,p=m.parse(e,{topNode:n.parent,topMatch:n.parent.contentMatchAt(n.index()),topOpen:!0,from:f,to:g,preserveWhitespace:"pre"!=n.parent.type.whitespace||"full",findPositions:d,ruleFromNode:eu,context:n});if(d&&null!=d[0].pos){let a=d[0].pos,b=d[1]&&d[1].pos;null==b&&(b=a),o={anchor:a+h,head:b+h}}return{doc:p,sel:o,from:h,to:i}}(a,b,c),n=a.state.doc,o=n.slice(m.from,m.to);8===a.input.lastKeyCode&&Date.now()-100<a.input.lastKeyCodeTime?(f=a.state.selection.to,g="end"):(f=a.state.selection.from,g="start"),a.input.lastKeyCode=null;let p=function(a,b,c,d,e){let f=a.findDiffStart(b,c);if(null==f)return null;let{a:g,b:h}=a.findDiffEnd(b,c+a.size,c+b.size);if("end"==e){let a=Math.max(0,f-Math.min(g,h));d-=g+a-f}if(g<f&&a.size<b.size){let a=d<=f&&d>=g?f-d:0;(f-=a)&&f<b.size&&ey(b.textBetween(f-1,f+1))&&(f+=a?1:-1),h=f+(h-g),g=f}else if(h<f){let b=d<=f&&d>=h?f-d:0;(f-=b)&&f<a.size&&ey(a.textBetween(f-1,f+1))&&(f+=b?1:-1),g=f+(g-h),h=f}return{start:f,endA:g,endB:h}}(o.content,m.doc.content,m.from,f,g);if(p&&a.input.domChangeCount++,(cx&&a.input.lastIOSEnter>Date.now()-225||cA)&&e.some(a=>1==a.nodeType&&!ev.test(a.nodeName))&&(!p||p.endA>=p.endB)&&a.someProp("handleKeyDown",b=>b(a,cj(13,"Enter")))){a.input.lastIOSEnter=0;return}if(!p)if(d&&l instanceof bs&&!l.empty&&l.$head.sameParent(l.$anchor)&&!a.composing&&!(m.sel&&m.sel.anchor!=m.sel.head))p={start:l.from,endA:l.to,endB:l.to};else{if(m.sel){let b=ew(a,a.state.doc,m.sel);if(b&&!b.eq(a.state.selection)){let c=a.state.tr.setSelection(b);i&&c.setMeta("composition",i),a.dispatch(c)}}return}a.state.selection.from<a.state.selection.to&&p.start==p.endB&&a.state.selection instanceof bs&&(p.start>a.state.selection.from&&p.start<=a.state.selection.from+2&&a.state.selection.from>=m.from?p.start=a.state.selection.from:p.endA<a.state.selection.to&&p.endA>=a.state.selection.to-2&&a.state.selection.to<=m.to&&(p.endB+=a.state.selection.to-p.endA,p.endA=a.state.selection.to)),cq&&cr<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>m.from&&" \xa0"==m.doc.textBetween(p.start-m.from-1,p.start-m.from+1)&&(p.start--,p.endA--,p.endB--);let q=m.doc.resolveNoCache(p.start-m.from),r=m.doc.resolveNoCache(p.endB-m.from),s=n.resolve(p.start),t=q.sameParent(r)&&q.parent.inlineContent&&s.end()>=p.endA;if((cx&&a.input.lastIOSEnter>Date.now()-225&&(!t||e.some(a=>"DIV"==a.nodeName||"P"==a.nodeName))||!t&&q.pos<m.doc.content.size&&(!q.sameParent(r)||!q.parent.inlineContent)&&q.pos<r.pos&&!/\S/.test(m.doc.textBetween(q.pos,r.pos,"","")))&&a.someProp("handleKeyDown",b=>b(a,cj(13,"Enter")))){a.input.lastIOSEnter=0;return}if(a.state.selection.anchor>p.start&&function(a,b,c,d,e){if(c-b<=e.pos-d.pos||ex(d,!0,!1)<e.pos)return!1;let f=a.resolve(b);if(!d.parent.isTextblock){let a=f.nodeAfter;return null!=a&&c==b+a.nodeSize}if(f.parentOffset<f.parent.content.size||!f.parent.isTextblock)return!1;let g=a.resolve(ex(f,!0,!0));return!(!g.parent.isTextblock||g.pos>c||ex(g,!0,!1)<c)&&d.parent.content.cut(d.parentOffset).eq(g.parent.content)}(n,p.start,p.endA,q,r)&&a.someProp("handleKeyDown",b=>b(a,cj(8,"Backspace")))){cA&&cu&&a.domObserver.suppressSelectionUpdates();return}cu&&p.endB==p.start&&(a.input.lastChromeDelete=Date.now()),cA&&!t&&q.start()!=r.start()&&0==r.parentOffset&&q.depth==r.depth&&m.sel&&m.sel.anchor==m.sel.head&&m.sel.head==p.endA&&(p.endB-=2,r=m.doc.resolveNoCache(p.endB-m.from),setTimeout(()=>{a.someProp("handleKeyDown",function(b){return b(a,cj(13,"Enter"))})},20));let u=p.start,v=p.endA,w=b=>{let c=b||a.state.tr.replace(u,v,m.doc.slice(p.start-m.from,p.endB-m.from));if(m.sel){let b=ew(a,c.doc,m.sel);b&&!(cu&&a.composing&&b.empty&&(p.start!=p.endB||a.input.lastChromeDelete<Date.now()-100)&&(b.head==u||b.head==c.mapping.map(v)-1)||cq&&b.empty&&b.head==u)&&c.setSelection(b)}return i&&c.setMeta("composition",i),c.scrollIntoView()};if(t)if(q.pos==r.pos){cq&&cr<=11&&0==q.parentOffset&&(a.domObserver.suppressSelectionUpdates(),setTimeout(()=>dd(a),20));let b=w(a.state.tr.delete(u,v)),c=n.resolve(p.start).marksAcross(n.resolve(p.endA));c&&b.ensureMarks(c),a.dispatch(b)}else if(p.endA==p.endB&&(h=function(a,b){let c=a.firstChild.marks,d=b.firstChild.marks,e=c,f=d,g,h,i;for(let a=0;a<d.length;a++)e=d[a].removeFromSet(e);for(let a=0;a<c.length;a++)f=c[a].removeFromSet(f);if(1==e.length&&0==f.length)h=e[0],g="add",i=a=>a.mark(h.addToSet(a.marks));else{if(0!=e.length||1!=f.length)return null;h=f[0],g="remove",i=a=>a.mark(h.removeFromSet(a.marks))}let j=[];for(let a=0;a<b.childCount;a++)j.push(i(b.child(a)));if(S.from(j).eq(a))return{mark:h,type:g}}(q.parent.content.cut(q.parentOffset,r.parentOffset),s.parent.content.cut(s.parentOffset,p.endA-s.start())))){let b=w(a.state.tr);"add"==h.type?b.addMark(u,v,h.mark):b.removeMark(u,v,h.mark),a.dispatch(b)}else if(q.parent.child(q.index()).isText&&q.index()==r.index()-!r.textOffset){let b=q.parent.textBetween(q.parentOffset,r.parentOffset),c=()=>w(a.state.tr.insertText(b,u,v));a.someProp("handleTextInput",d=>d(a,u,v,b,c))||a.dispatch(c())}else a.dispatch(w());else a.dispatch(w())})(this,a,b,c,d)),this.domObserver.start(),function(a){for(let b in dK){let c=dK[b];a.dom.addEventListener(b,a.input.eventHandlers[b]=b=>{!function(a,b){if(!b.bubbles)return!0;if(b.defaultPrevented)return!1;for(let c=b.target;c!=a.dom;c=c.parentNode)if(!c||11==c.nodeType||c.pmViewDesc&&c.pmViewDesc.stopEvent(b))return!1;return!0}(a,b)||dQ(a,b)||!a.editable&&b.type in dL||c(a,b)},dM[b]?{passive:!0}:void 0)}cw&&a.dom.addEventListener("input",()=>null),dP(a)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let a=this._props;for(let b in this._props={},a)this._props[b]=a[b];this._props.state=this.state}return this._props}update(a){a.handleDOMEvents!=this._props.handleDOMEvents&&dP(this);let b=this._props;this._props=a,a.plugins&&(a.plugins.forEach(eE),this.directPlugins=a.plugins),this.updateStateInner(a.state,b)}setProps(a){let b={};for(let a in this._props)b[a]=this._props[a];for(let c in b.state=this.state,a)b[c]=a[c];this.update(b)}updateState(a){this.updateStateInner(a,this._props)}updateStateInner(a,b){var c,d,e;let f=this.state,g=!1,h=!1;a.storedMarks&&this.composing&&(dZ(this),h=!0),this.state=a;let i=f.plugins!=a.plugins||this._props.plugins!=b.plugins;if(i||this._props.plugins!=b.plugins||this._props.nodeViews!=b.nodeViews){let a=eD(this);(function(a,b){let c=0,d=0;for(let d in a){if(a[d]!=b[d])return!0;c++}for(let a in b)d++;return c!=d})(a,this.nodeViews)&&(this.nodeViews=a,g=!0)}(i||b.handleDOMEvents!=this._props.handleDOMEvents)&&dP(this),this.editable=eC(this),eB(this);let j=em(this),k=eA(this),l=f.plugins==a.plugins||f.doc.eq(a.doc)?a.scrollToSelection>f.scrollToSelection?"to selection":"preserve":"reset",m=g||!this.docView.matchesNode(a.doc,k,j);(m||!a.selection.eq(f.selection))&&(h=!0);let n="preserve"==l&&h&&null==this.dom.style.overflowAnchor&&function(a){let b,c,d=a.dom.getBoundingClientRect(),e=Math.max(0,d.top);for(let f=(d.left+d.right)/2,g=e+1;g<Math.min(innerHeight,d.bottom);g+=5){let d=a.root.elementFromPoint(f,g);if(!d||d==a.dom||!a.dom.contains(d))continue;let h=d.getBoundingClientRect();if(h.top>=e-20){b=d,c=h.top;break}}return{refDOM:b,refTop:c,stack:cF(a.dom)}}(this);if(h){let b,c,h;this.domObserver.stop();let i=m&&(cq||cu)&&!this.composing&&!f.selection.empty&&!a.selection.empty&&(d=f.selection,e=a.selection,h=Math.min(d.$anchor.sharedDepth(d.head),e.$anchor.sharedDepth(e.head)),d.$anchor.start(h)!=e.$anchor.start(h));if(m){let b=cu?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(a){let b=a.domSelectionRange();if(!b.focusNode)return null;let c=function(a,b){for(;;){if(3==a.nodeType&&b)return a;if(1==a.nodeType&&b>0){if("false"==a.contentEditable)return null;b=cg(a=a.childNodes[b-1])}else{if(!a.parentNode||ch(a))return null;b=b8(a),a=a.parentNode}}}(b.focusNode,b.focusOffset),d=function(a,b){for(;;){if(3==a.nodeType&&b<a.nodeValue.length)return a;if(1==a.nodeType&&b<a.childNodes.length){if("false"==a.contentEditable)return null;a=a.childNodes[b],b=0}else{if(!a.parentNode||ch(a))return null;b=b8(a)+1,a=a.parentNode}}}(b.focusNode,b.focusOffset);if(c&&d&&c!=d){let b=d.pmViewDesc,e=a.domObserver.lastChangedTextNode;if(c==e||d==e)return e;if(!b||!b.isText(d.nodeValue))return d;if(a.input.compositionNode==d){let a=c.pmViewDesc;if(!(!a||!a.isText(c.nodeValue)))return d}}return c||d}(this)),(g||!this.docView.update(a.doc,k,j,this))&&(this.docView.updateOuterDeco(k),this.docView.destroy(),this.docView=cZ(a.doc,k,j,this.dom,this)),!b||this.trackWrites&&this.dom.contains(this.trackWrites)||(i=!0)}i||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&(b=this.docView.domFromPos(this.state.selection.anchor,0),c=this.domSelectionRange(),cd(b.node,b.offset,c.anchorNode,c.anchorOffset)))?dd(this,i):(di(this,a.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(f),(null==(c=this.dragging)?void 0:c.node)&&!f.doc.eq(a.doc)&&this.updateDraggedNode(this.dragging,f),"reset"==l?this.dom.scrollTop=0:"to selection"==l?this.scrollToSelection():n&&function({refDOM:a,refTop:b,stack:c}){let d=a?a.getBoundingClientRect().top:0;cG(c,0==d?0:d-b)}(n)}scrollToSelection(){let a=this.domSelectionRange().focusNode;if(a&&this.dom.contains(1==a.nodeType?a:a.parentNode))if(this.someProp("handleScrollToSelection",a=>a(this)));else if(this.state.selection instanceof bu){let b=this.docView.domAfterPos(this.state.selection.from);1==b.nodeType&&cE(this,b.getBoundingClientRect(),a)}else cE(this,this.coordsAtPos(this.state.selection.head,1),a)}destroyPluginViews(){let a;for(;a=this.pluginViews.pop();)a.destroy&&a.destroy()}updatePluginViews(a){if(a&&a.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let b=0;b<this.pluginViews.length;b++){let c=this.pluginViews[b];c.update&&c.update(this,a)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let a=0;a<this.directPlugins.length;a++){let b=this.directPlugins[a];b.spec.view&&this.pluginViews.push(b.spec.view(this))}for(let a=0;a<this.state.plugins.length;a++){let b=this.state.plugins[a];b.spec.view&&this.pluginViews.push(b.spec.view(this))}}}updateDraggedNode(a,b){let c=a.node,d=-1;if(this.state.doc.nodeAt(c.from)==c.node)d=c.from;else{let a=c.from+(this.state.doc.content.size-b.doc.content.size);(a>0&&this.state.doc.nodeAt(a))==c.node&&(d=a)}this.dragging=new d2(a.slice,a.move,d<0?void 0:bu.create(this.state.doc,d))}someProp(a,b){let c=this._props&&this._props[a],d;if(null!=c&&(d=b?b(c):c))return d;for(let c=0;c<this.directPlugins.length;c++){let e=this.directPlugins[c].props[a];if(null!=e&&(d=b?b(e):e))return d}let e=this.state.plugins;if(e)for(let c=0;c<e.length;c++){let f=e[c].props[a];if(null!=f&&(d=b?b(f):f))return d}}hasFocus(){if(cq){let a=this.root.activeElement;if(a==this.dom)return!0;if(!a||!this.dom.contains(a))return!1;for(;a&&this.dom!=a&&this.dom.contains(a);){if("false"==a.contentEditable)return!1;a=a.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(a){if(a.setActive)return a.setActive();if(cH)return a.focus(cH);let b=cF(a);a.focus(null==cH?{get preventScroll(){return cH={preventScroll:!0},!0}}:void 0),cH||(cH=!1,cG(b,0))}(this.dom),dd(this),this.domObserver.start()}get root(){let a=this._root;if(null==a){for(let a=this.dom.parentNode;a;a=a.parentNode)if(9==a.nodeType||11==a.nodeType&&a.host)return a.getSelection||(Object.getPrototypeOf(a).getSelection=()=>a.ownerDocument.getSelection()),this._root=a}return a||document}updateRoot(){this._root=null}posAtCoords(a){return function(a,b){var c;let d,e,f=a.dom.ownerDocument,g,h=0,i=function(a,b,c){if(a.caretPositionFromPoint)try{let d=a.caretPositionFromPoint(b,c);if(d)return{node:d.offsetNode,offset:Math.min(cg(d.offsetNode),d.offset)}}catch(a){}if(a.caretRangeFromPoint){let d=a.caretRangeFromPoint(b,c);if(d)return{node:d.startContainer,offset:Math.min(cg(d.startContainer),d.startOffset)}}}(f,b.left,b.top);i&&({node:g,offset:h}=i);let j=(a.root.elementFromPoint?a.root:f).elementFromPoint(b.left,b.top);if(!j||!a.dom.contains(1!=j.nodeType?j.parentNode:j)){let c=a.dom.getBoundingClientRect();if(!cI(b,c)||!(j=function a(b,c,d){let e=b.childNodes.length;if(e&&d.top<d.bottom)for(let f=Math.max(0,Math.min(e-1,Math.floor(e*(c.top-d.top)/(d.bottom-d.top))-2)),g=f;;){let d=b.childNodes[g];if(1==d.nodeType){let b=d.getClientRects();for(let e=0;e<b.length;e++){let f=b[e];if(cI(c,f))return a(d,c,f)}}if((g=(g+1)%e)==f)break}return b}(a.dom,b,c)))return null}if(cw)for(let a=j;g&&a;a=b9(a))a.draggable&&(g=void 0);if(j=(d=(c=j).parentNode)&&/^li$/i.test(d.nodeName)&&b.left<c.getBoundingClientRect().left?d:c,g){let c;if(cs&&1==g.nodeType&&(h=Math.min(h,g.childNodes.length))<g.childNodes.length){let a=g.childNodes[h],c;"IMG"==a.nodeName&&(c=a.getBoundingClientRect()).right<=b.left&&c.bottom>b.top&&h++}cB&&h&&1==g.nodeType&&1==(c=g.childNodes[h-1]).nodeType&&"false"==c.contentEditable&&c.getBoundingClientRect().top>=b.top&&h--,g==a.dom&&h==g.childNodes.length-1&&1==g.lastChild.nodeType&&b.top>g.lastChild.getBoundingClientRect().bottom?e=a.state.doc.content.size:(0==h||1!=g.nodeType||"BR"!=g.childNodes[h-1].nodeName)&&(e=function(a,b,c,d){let e=-1;for(let c=b,f=!1;c!=a.dom;){let b=a.docView.nearestDesc(c,!0),g;if(!b)return null;if(1==b.dom.nodeType&&(b.node.isBlock&&b.parent||!b.contentDOM)&&((g=b.dom.getBoundingClientRect()).width||g.height)&&(b.node.isBlock&&b.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(b.dom.nodeName)&&(!f&&g.left>d.left||g.top>d.top?e=b.posBefore:(!f&&g.right<d.left||g.bottom<d.top)&&(e=b.posAfter),f=!0),!b.contentDOM&&e<0&&!b.node.isText))return(b.node.isBlock?d.top<(g.top+g.bottom)/2:d.left<(g.left+g.right)/2)?b.posBefore:b.posAfter;c=b.dom.parentNode}return e>-1?e:a.docView.posFromDOM(b,c,-1)}(a,g,h,b))}null==e&&(e=function(a,b,c){let{node:d,offset:e}=function a(b,c){let d,e,f,g=2e8,h,i=0,j=c.top,k=c.top;for(let a=b.firstChild,l=0;a;a=a.nextSibling,l++){let b;if(1==a.nodeType)b=a.getClientRects();else{if(3!=a.nodeType)continue;b=cb(a).getClientRects()}for(let m=0;m<b.length;m++){let n=b[m];if(n.top<=j&&n.bottom>=k){j=Math.max(n.bottom,j),k=Math.min(n.top,k);let b=n.left>c.left?n.left-c.left:n.right<c.left?c.left-n.right:0;if(b<g){f=a,g=b,h=b&&3==f.nodeType?{left:n.right<c.left?n.right:n.left,top:c.top}:c,1==a.nodeType&&b&&(i=l+ +(c.left>=(n.left+n.right)/2));continue}}else n.top>c.top&&!d&&n.left<=c.left&&n.right>=c.left&&(d=a,e={left:Math.max(n.left,Math.min(n.right,c.left)),top:n.top});!f&&(c.left>=n.right&&c.top>=n.top||c.left>=n.left&&c.top>=n.bottom)&&(i=l+1)}}return(!f&&d&&(f=d,h=e,g=0),f&&3==f.nodeType)?function(a,b){let c=a.nodeValue.length,d=document.createRange(),e;for(let f=0;f<c;f++){d.setEnd(a,f+1),d.setStart(a,f);let c=cK(d,1);if(c.top!=c.bottom&&cI(b,c)){e={node:a,offset:f+ +(b.left>=(c.left+c.right)/2)};break}}return d.detach(),e||{node:a,offset:0}}(f,h):!f||g&&1==f.nodeType?{node:b,offset:i}:a(f,h)}(b,c),f=-1;if(1==d.nodeType&&!d.firstChild){let a=d.getBoundingClientRect();f=a.left!=a.right&&c.left>(a.left+a.right)/2?1:-1}return a.docView.posFromDOM(d,e,f)}(a,j,b));let k=a.docView.nearestDesc(j,!0);return{pos:e,inside:k?k.posAtStart-k.border:-1}}(this,a)}coordsAtPos(a,b=1){return cM(this,a,b)}domAtPos(a,b=0){return this.docView.domFromPos(a,b)}nodeDOM(a){let b=this.docView.descAt(a);return b?b.nodeDOM:null}posAtDOM(a,b,c=-1){let d=this.docView.posFromDOM(a,b,c);if(null==d)throw RangeError("DOM position not inside the editor");return d}endOfTextblock(a,b){return function(a,b,c){let d,e;return cR==b&&cS==c?cT:(cR=b,cS=c,cT="up"==c||"down"==c?(d=b.selection,e="up"==c?d.$from:d.$to,cP(a,b,()=>{let{node:b}=a.docView.domFromPos(e.pos,"up"==c?-1:1);for(;;){let c=a.docView.nearestDesc(b,!0);if(!c)break;if(c.node.isBlock){b=c.contentDOM||c.dom;break}b=c.dom.parentNode}let d=cM(a,e.pos,1);for(let a=b.firstChild;a;a=a.nextSibling){let b;if(1==a.nodeType)b=a.getClientRects();else{if(3!=a.nodeType)continue;b=cb(a,0,a.nodeValue.length).getClientRects()}for(let a=0;a<b.length;a++){let e=b[a];if(e.bottom>e.top+1&&("up"==c?d.top-e.top>(e.bottom-d.top)*2:e.bottom-d.bottom>(d.bottom-e.top)*2))return!1}}return!0})):function(a,b,c){let{$head:d}=b.selection;if(!d.parent.isTextblock)return!1;let e=d.parentOffset,f=e==d.parent.content.size,g=a.domSelection();return g?cQ.test(d.parent.textContent)&&g.modify?cP(a,b,()=>{let{focusNode:b,focusOffset:e,anchorNode:f,anchorOffset:h}=a.domSelectionRange(),i=g.caretBidiLevel;g.modify("move",c,"character");let j=d.depth?a.docView.domAfterPos(d.before()):a.dom,{focusNode:k,focusOffset:l}=a.domSelectionRange(),m=k&&!j.contains(1==k.nodeType?k:k.parentNode)||b==k&&e==l;try{g.collapse(f,h),b&&(b!=f||e!=h)&&g.extend&&g.extend(b,e)}catch(a){}return null!=i&&(g.caretBidiLevel=i),m}):"left"==c||"backward"==c?!e:f:d.pos==d.start()||d.pos==d.end()}(a,b,c))}(this,b||this.state,a)}pasteHTML(a,b){return d0(this,"",a,!1,b||new ClipboardEvent("paste"))}pasteText(a,b){return d0(this,a,null,!0,b||new ClipboardEvent("paste"))}serializeForClipboard(a){return dA(this,a)}destroy(){if(this.docView){for(let a in this.domObserver.stop(),this.input.eventHandlers)this.dom.removeEventListener(a,this.input.eventHandlers[a]);clearTimeout(this.input.composingTimeout),clearTimeout(this.input.lastIOSEnterFallbackTimeout),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],em(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,cc()}}get isDestroyed(){return null==this.docView}dispatchEvent(a){!dQ(this,a)&&dK[a.type]&&(this.editable||!(a.type in dL))&&dK[a.type](this,a)}domSelectionRange(){let a=this.domSelection();return a?cw&&11===this.root.nodeType&&function(a){let b=a.activeElement;for(;b&&b.shadowRoot;)b=b.shadowRoot.activeElement;return b}(this.dom.ownerDocument)==this.dom&&function(a,b){let c;if(b.getComposedRanges){let c=b.getComposedRanges(a.root)[0];if(c)return et(a,c)}function d(a){a.preventDefault(),a.stopImmediatePropagation(),c=a.getTargetRanges()[0]}return a.dom.addEventListener("beforeinput",d,!0),document.execCommand("indent"),a.dom.removeEventListener("beforeinput",d,!0),c?et(a,c):null}(this,a)||a:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function eA(a){let b=Object.create(null);return b.class="ProseMirror",b.contenteditable=String(a.editable),a.someProp("attributes",c=>{if("function"==typeof c&&(c=c(a.state)),c)for(let a in c)"class"==a?b.class+=" "+c[a]:"style"==a?b.style=(b.style?b.style+";":"")+c[a]:b[a]||"contenteditable"==a||"nodeName"==a||(b[a]=String(c[a]))}),b.translate||(b.translate="no"),[d9.node(0,a.state.doc.content.size,b)]}function eB(a){if(a.markCursor){let b=document.createElement("img");b.className="ProseMirror-separator",b.setAttribute("mark-placeholder","true"),b.setAttribute("alt",""),a.cursorWrapper={dom:b,deco:d9.widget(a.state.selection.from,b,{raw:!0,marks:a.markCursor})}}else a.cursorWrapper=null}function eC(a){return!a.someProp("editable",b=>!1===b(a.state))}function eD(a){let b=Object.create(null);function c(a){for(let c in a)Object.prototype.hasOwnProperty.call(b,c)||(b[c]=a[c])}return a.someProp("nodeViews",c),a.someProp("markViews",c),b}function eE(a){if(a.spec.state||a.spec.filterTransaction||a.spec.appendTransaction)throw RangeError("Plugins passed directly to the view must not have a state component")}ez.prototype.dispatch=function(a){let b=this._props.dispatchTransaction;b?b.call(this,a):this.updateState(this.state.apply(a))};for(var eF={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:"'"},eG={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},eH="u">typeof navigator&&/Mac/.test(navigator.platform),eI="u">typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),eJ=0;eJ<10;eJ++)eF[48+eJ]=eF[96+eJ]=String(eJ);for(var eJ=1;eJ<=24;eJ++)eF[eJ+111]="F"+eJ;for(var eJ=65;eJ<=90;eJ++)eF[eJ]=String.fromCharCode(eJ+32),eG[eJ]=String.fromCharCode(eJ);for(var eK in eF)eG.hasOwnProperty(eK)||(eG[eK]=eF[eK]);let eL="u">typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),eM="u">typeof navigator&&/Win/.test(navigator.platform);function eN(a,b,c=!0){return b.altKey&&(a="Alt-"+a),b.ctrlKey&&(a="Ctrl-"+a),b.metaKey&&(a="Meta-"+a),c&&b.shiftKey&&(a="Shift-"+a),a}function eO(a){let b=function(a){let b=Object.create(null);for(let c in a)b[function(a){let b,c,d,e,f=a.split(/-(?!$)/),g=f[f.length-1];"Space"==g&&(g=" ");for(let a=0;a<f.length-1;a++){let g=f[a];if(/^(cmd|meta|m)$/i.test(g))e=!0;else if(/^a(lt)?$/i.test(g))b=!0;else if(/^(c|ctrl|control)$/i.test(g))c=!0;else if(/^s(hift)?$/i.test(g))d=!0;else if(/^mod$/i.test(g))eL?e=!0:c=!0;else throw Error("Unrecognized modifier name: "+g)}return b&&(g="Alt-"+g),c&&(g="Ctrl-"+g),e&&(g="Meta-"+g),d&&(g="Shift-"+g),g}(c)]=a[c];return b}(a);return function(a,c){var d;let e=("Esc"==(d=!(eH&&c.metaKey&&c.shiftKey&&!c.ctrlKey&&!c.altKey||eI&&c.shiftKey&&c.key&&1==c.key.length||"Unidentified"==c.key)&&c.key||(c.shiftKey?eG:eF)[c.keyCode]||c.key||"Unidentified")&&(d="Escape"),"Del"==d&&(d="Delete"),"Left"==d&&(d="ArrowLeft"),"Up"==d&&(d="ArrowUp"),"Right"==d&&(d="ArrowRight"),"Down"==d&&(d="ArrowDown"),d),f,g=b[eN(e,c)];if(g&&g(a.state,a.dispatch,a))return!0;if(1==e.length&&" "!=e){if(c.shiftKey){let d=b[eN(e,c,!1)];if(d&&d(a.state,a.dispatch,a))return!0}if((c.altKey||c.metaKey||c.ctrlKey)&&!(eM&&c.ctrlKey&&c.altKey)&&(f=eF[c.keyCode])&&f!=e){let d=b[eN(f,c)];if(d&&d(a.state,a.dispatch,a))return!0}}return!1}}var eP=Object.defineProperty,eQ=(a,b)=>{for(var c in b)eP(a,c,{get:b[c],enumerable:!0})};function eR(a){let{state:b,transaction:c}=a,{selection:d}=c,{doc:e}=c,{storedMarks:f}=c;return{...b,apply:b.apply.bind(b),applyTransaction:b.applyTransaction.bind(b),plugins:b.plugins,schema:b.schema,reconfigure:b.reconfigure.bind(b),toJSON:b.toJSON.bind(b),get storedMarks(){return f},get selection(){return d},get doc(){return e},get tr(){return d=c.selection,e=c.doc,f=c.storedMarks,c}}}var eS=class{constructor(a){this.editor=a.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=a.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:a,editor:b,state:c}=this,{view:d}=b,{tr:e}=c,f=this.buildProps(e);return Object.fromEntries(Object.entries(a).map(([a,b])=>[a,(...a)=>{let c=b(...a)(f);return e.getMeta("preventDispatch")||this.hasCustomState||d.dispatch(e),c}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(a,b=!0){let{rawCommands:c,editor:d,state:e}=this,{view:f}=d,g=[],h=!!a,i=a||e.tr,j=()=>(h||!b||i.getMeta("preventDispatch")||this.hasCustomState||f.dispatch(i),g.every(a=>!0===a)),k={...Object.fromEntries(Object.entries(c).map(([a,c])=>[a,(...a)=>{let d=this.buildProps(i,b),e=c(...a)(d);return g.push(e),k}])),run:j};return k}createCan(a){let{rawCommands:b,state:c}=this,d=a||c.tr,e=this.buildProps(d,!1);return{...Object.fromEntries(Object.entries(b).map(([a,b])=>[a,(...a)=>b(...a)({...e,dispatch:void 0})])),chain:()=>this.createChain(d,!1)}}buildProps(a,b=!0){let{rawCommands:c,editor:d,state:e}=this,{view:f}=d,g={tr:a,editor:d,view:f,state:eR({state:e,transaction:a}),dispatch:b?()=>void 0:void 0,chain:()=>this.createChain(a,b),can:()=>this.createCan(a),get commands(){return Object.fromEntries(Object.entries(c).map(([a,b])=>[a,(...a)=>b(...a)(g)]))}};return g}},eT={};eQ(eT,{blur:()=>eU,clearContent:()=>eV,clearNodes:()=>eW,command:()=>eX,createParagraphNear:()=>eY,cut:()=>eZ,deleteCurrentNode:()=>e$,deleteNode:()=>e0,deleteRange:()=>e1,deleteSelection:()=>e2,enter:()=>e3,exitCode:()=>e4,extendMarkRange:()=>fb,first:()=>fc,focus:()=>fi,forEach:()=>fj,insertContent:()=>fk,insertContentAt:()=>fo,joinBackward:()=>fr,joinDown:()=>fq,joinForward:()=>fs,joinItemBackward:()=>ft,joinItemForward:()=>fu,joinTextblockBackward:()=>fv,joinTextblockForward:()=>fw,joinUp:()=>fp,keyboardShortcut:()=>fy,lift:()=>fA,liftEmptyBlock:()=>fB,liftListItem:()=>fC,newlineInCode:()=>fD,resetAttributes:()=>fG,scrollIntoView:()=>fH,selectAll:()=>fI,selectNodeBackward:()=>fJ,selectNodeForward:()=>fK,selectParentNode:()=>fL,selectTextblockEnd:()=>fM,selectTextblockStart:()=>fN,setContent:()=>fP,setMark:()=>gl,setMeta:()=>gm,setNode:()=>gn,setNodeSelection:()=>go,setTextDirection:()=>gp,setTextSelection:()=>gq,sinkListItem:()=>gr,splitBlock:()=>gt,splitListItem:()=>gu,toggleList:()=>gx,toggleMark:()=>gy,toggleNode:()=>gz,toggleWrap:()=>gA,undoInputRule:()=>gB,unsetAllMarks:()=>gC,unsetMark:()=>gD,unsetTextDirection:()=>gE,updateAttributes:()=>gF,wrapIn:()=>gG,wrapInList:()=>gH});var eU=()=>({editor:a,view:b})=>(requestAnimationFrame(()=>{var c;a.isDestroyed||(b.dom.blur(),null==(c=null==window?void 0:window.getSelection())||c.removeAllRanges())}),!0),eV=(a=!0)=>({commands:b})=>b.setContent("",{emitUpdate:a}),eW=()=>({state:a,tr:b,dispatch:c})=>{let{selection:d}=b,{ranges:e}=d;return!c||(e.forEach(({$from:c,$to:d})=>{a.doc.nodesBetween(c.pos,d.pos,(a,c)=>{if(a.type.isText)return;let{doc:d,mapping:e}=b,f=d.resolve(e.map(c)),g=d.resolve(e.map(c+a.nodeSize)),h=f.blockRange(g);if(!h)return;let i=a1(h);if(a.type.isTextblock){let{defaultType:a}=f.parent.contentMatchAt(f.index());b.setNodeMarkup(h.start,a)}(i||0===i)&&b.lift(h,i)})}),!0)},eX=a=>b=>a(b),eY=()=>({state:a,dispatch:b})=>bY(a,b),eZ=(a,b)=>({editor:c,tr:d})=>{let{state:e}=c,f=e.doc.slice(a.from,a.to);d.deleteRange(a.from,a.to);let g=d.mapping.map(b);return d.insert(g,f.content),d.setSelection(new bs(d.doc.resolve(Math.max(g-1,0)))),!0},e$=()=>({tr:a,dispatch:b})=>{let{selection:c}=a,d=c.$anchor.node();if(d.content.size>0)return!1;let e=a.selection.$anchor;for(let c=e.depth;c>0;c-=1)if(e.node(c).type===d.type){if(b){let b=e.before(c),d=e.after(c);a.delete(b,d).scrollIntoView()}return!0}return!1};function e_(a,b){if("string"==typeof a){if(!b.nodes[a])throw Error(`There is no node type named '${a}'. Maybe you forgot to add the extension?`);return b.nodes[a]}return a}var e0=a=>({tr:b,state:c,dispatch:d})=>{let e=e_(a,c.schema),f=b.selection.$anchor;for(let a=f.depth;a>0;a-=1)if(f.node(a).type===e){if(d){let c=f.before(a),d=f.after(a);b.delete(c,d).scrollIntoView()}return!0}return!1},e1=a=>({tr:b,dispatch:c})=>{let{from:d,to:e}=a;return c&&b.delete(d,e),!0},e2=()=>({state:a,dispatch:b})=>bK(a,b),e3=()=>({commands:a})=>a.keyboardShortcut("Enter"),e4=()=>({state:a,dispatch:b})=>bX(a,b);function e5(a){return"[object RegExp]"===Object.prototype.toString.call(a)}function e6(a,b,c={strict:!0}){let d=Object.keys(b);return!d.length||d.every(d=>c.strict?b[d]===a[d]:e5(b[d])?b[d].test(a[d]):b[d]===a[d])}function e7(a,b,c={}){return a.find(a=>a.type===b&&e6(Object.fromEntries(Object.keys(c).map(b=>[b,a.attrs[b]])),c))}function e8(a,b,c={}){return!!e7(a,b,c)}function e9(a,b,c){var d;if(!a||!b)return;let e=a.parent.childAfter(a.parentOffset);if(e.node&&e.node.marks.some(a=>a.type===b)||(e=a.parent.childBefore(a.parentOffset)),!e.node||!e.node.marks.some(a=>a.type===b)||(c=c||(null==(d=e.node.marks[0])?void 0:d.attrs),!e7([...e.node.marks],b,c)))return;let f=e.index,g=a.start()+e.offset,h=f+1,i=g+e.node.nodeSize;for(;f>0&&e8([...a.parent.child(f-1).marks],b,c);)f-=1,g-=a.parent.child(f).nodeSize;for(;h<a.parent.childCount&&e8([...a.parent.child(h).marks],b,c);)i+=a.parent.child(h).nodeSize,h+=1;return{from:g,to:i}}function fa(a,b){if("string"==typeof a){if(!b.marks[a])throw Error(`There is no mark type named '${a}'. Maybe you forgot to add the extension?`);return b.marks[a]}return a}var fb=(a,b={})=>({tr:c,state:d,dispatch:e})=>{let f=fa(a,d.schema),{doc:g,selection:h}=c,{$from:i,from:j,to:k}=h;if(e){let a=e9(i,f,b);if(a&&a.from<=j&&a.to>=k){let b=bs.create(g,a.from,a.to);c.setSelection(b)}}return!0},fc=a=>b=>{let c="function"==typeof a?a(b):a;for(let a=0;a<c.length;a+=1)if(c[a](b))return!0;return!1};function fd(a){return a instanceof bs}function fe(a=0,b=0,c=0){return Math.min(Math.max(a,b),c)}function ff(a,b=null){if(!b)return null;let c=bo.atStart(a),d=bo.atEnd(a);if("start"===b||!0===b)return c;if("end"===b)return d;let e=c.from,f=d.to;return"all"===b?bs.create(a,fe(0,e,f),fe(a.content.size,e,f)):bs.create(a,fe(b,e,f),fe(b,e,f))}function fg(){return"Android"===navigator.platform||/android/i.test(navigator.userAgent)}function fh(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var fi=(a=null,b={})=>({editor:c,view:d,tr:e,dispatch:f})=>{b={scrollIntoView:!0,...b};let g=()=>{(fh()||fg())&&d.dom.focus(),"u">typeof navigator&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&!fh()&&!fg()&&d.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{!c.isDestroyed&&(d.focus(),(null==b?void 0:b.scrollIntoView)&&c.commands.scrollIntoView())})};try{if(d.hasFocus()&&null===a||!1===a)return!0}catch{return!1}if(f&&null===a&&!fd(c.state.selection))return g(),!0;let h=ff(e.doc,a)||c.state.selection,i=c.state.selection.eq(h);return f&&(i||e.setSelection(h),i&&e.storedMarks&&e.setStoredMarks(e.storedMarks),g()),!0},fj=(a,b)=>c=>a.every((a,d)=>b(a,{...c,index:d})),fk=(a,b)=>({tr:c,commands:d})=>d.insertContentAt({from:c.selection.from,to:c.selection.to},a,b),fl=a=>{let b=a.childNodes;for(let c=b.length-1;c>=0;c-=1){let d=b[c];3===d.nodeType&&d.nodeValue&&/^(\n\s\s|\n)$/.test(d.nodeValue)?a.removeChild(d):1===d.nodeType&&fl(d)}return a};function fm(a){if("u"<typeof window)throw Error("[tiptap error]: there is no window object available, so this function cannot be used");let b=`<body>${a}</body>`;return fl(new window.DOMParser().parseFromString(b,"text/html").body)}function fn(a,b,c){if(a instanceof aj||a instanceof S)return a;c={slice:!0,parseOptions:{},...c};let d="object"==typeof a&&null!==a,e="string"==typeof a;if(d)try{if(Array.isArray(a)&&a.length>0)return S.fromArray(a.map(a=>b.nodeFromJSON(a)));let d=b.nodeFromJSON(a);return c.errorOnInvalidContent&&d.check(),d}catch(d){if(c.errorOnInvalidContent)throw Error("[tiptap error]: Invalid JSON content",{cause:d});return console.warn("[tiptap warn]: Invalid content.","Passed value:",a,"Error:",d),fn("",b,c)}if(e){if(c.errorOnInvalidContent){let d=!1,e="",f=new ay({topNode:b.spec.topNode,marks:b.spec.marks,nodes:b.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:a=>(d=!0,e="string"==typeof a?a:a.outerHTML,null)}]}})});if(c.slice?aA.fromSchema(f).parseSlice(fm(a),c.parseOptions):aA.fromSchema(f).parse(fm(a),c.parseOptions),c.errorOnInvalidContent&&d)throw Error("[tiptap error]: Invalid HTML content",{cause:Error(`Invalid element found: ${e}`)})}let d=aA.fromSchema(b);return c.slice?d.parseSlice(fm(a),c.parseOptions).content:d.parse(fm(a),c.parseOptions)}return fn("",b,c)}var fo=(a,b,c)=>({tr:d,dispatch:e,editor:f})=>{var g;if(e){let e,h;c={parseOptions:f.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...c};let i=a=>{f.emit("contentError",{editor:f,error:a,disableCollaboration:()=>{"collaboration"in f.storage&&"object"==typeof f.storage.collaboration&&f.storage.collaboration&&(f.storage.collaboration.isDisabled=!0)}})},j={preserveWhitespace:"full",...c.parseOptions};if(!c.errorOnInvalidContent&&!f.options.enableContentCheck&&f.options.emitContentError)try{fn(b,f.schema,{parseOptions:j,errorOnInvalidContent:!0})}catch(a){i(a)}try{e=fn(b,f.schema,{parseOptions:j,errorOnInvalidContent:null!=(g=c.errorOnInvalidContent)?g:f.options.enableContentCheck})}catch(a){return i(a),!1}let{from:k,to:l}="number"==typeof a?{from:a,to:a}:{from:a.from,to:a.to},m=!0,n=!0;if((!("type"in e)?e:[e]).forEach(a=>{a.check(),m=!!m&&a.isText&&0===a.marks.length,n=!!n&&a.isBlock}),k===l&&n){let{parent:a}=d.doc.resolve(k);!a.isTextblock||a.type.spec.code||a.childCount||(k-=1,l+=1)}if(m){if(Array.isArray(b))h=b.map(a=>a.text||"").join("");else if(b instanceof S){let a="";b.forEach(b=>{b.text&&(a+=b.text)}),h=a}else h="object"==typeof b&&b&&b.text?b.text:b;d.insertText(h,k,l)}else{h=e;let a=d.doc.resolve(k),b=a.node(),c=0===a.parentOffset,f=b.isText||b.isTextblock,g=b.content.size>0;c&&f&&g&&(k=Math.max(0,k-1)),d.replaceWith(k,l,h)}c.updateSelection&&function(a,b,c){let d=a.steps.length-1;if(d<b)return;let e=a.steps[d];if(!(e instanceof aZ||e instanceof a$))return;let f=a.mapping.maps[d],g=0;f.forEach((a,b,c,d)=>{0===g&&(g=d)}),a.setSelection(bo.near(a.doc.resolve(g),-1))}(d,d.steps.length-1,0),c.applyInputRules&&d.setMeta("applyInputRules",{from:k,text:h}),c.applyPasteRules&&d.setMeta("applyPasteRules",{from:k,text:h})}return!0},fp=()=>({state:a,dispatch:b})=>((a,b)=>{let c=a.selection,d=c instanceof bu,e;if(d){if(c.node.isTextblock||!a7(a.doc,c.from))return!1;e=c.from}else if(null==(e=a9(a.doc,c.from,-1)))return!1;if(b){let c=a.tr.join(e);d&&c.setSelection(bu.create(c.doc,e-a.doc.resolve(e).nodeBefore.nodeSize)),b(c.scrollIntoView())}return!0})(a,b),fq=()=>({state:a,dispatch:b})=>((a,b)=>{let c=a.selection,d;if(c instanceof bu){if(c.node.isTextblock||!a7(a.doc,c.to))return!1;d=c.to}else if(null==(d=a9(a.doc,c.to,1)))return!1;return b&&b(a.tr.join(d).scrollIntoView()),!0})(a,b),fr=()=>({state:a,dispatch:b})=>bM(a,b),fs=()=>({state:a,dispatch:b})=>bS(a,b),ft=()=>({state:a,dispatch:b,tr:c})=>{try{let d=a9(a.doc,a.selection.$from.pos,-1);if(null==d)return!1;return c.join(d,2),b&&b(c),!0}catch{return!1}},fu=()=>({state:a,dispatch:b,tr:c})=>{try{let d=a9(a.doc,a.selection.$from.pos,1);if(null==d)return!1;return c.join(d,2),b&&b(c),!0}catch{return!1}},fv=()=>({state:a,dispatch:b})=>((a,b,c)=>{let d=bL(a,c);if(!d)return!1;let e=bQ(d);return!!e&&bN(a,e,b)})(a,b),fw=()=>({state:a,dispatch:b})=>((a,b,c)=>{let d=bR(a,c);if(!d)return!1;let e=bU(d);return!!e&&bN(a,e,b)})(a,b);function fx(){return"u">typeof navigator&&/Mac/.test(navigator.platform)}var fy=a=>({editor:b,view:c,tr:d,dispatch:e})=>{let f=(function(a){let b,c,d,e,f=a.split(/-(?!$)/),g=f[f.length-1];"Space"===g&&(g=" ");for(let a=0;a<f.length-1;a+=1){let g=f[a];if(/^(cmd|meta|m)$/i.test(g))e=!0;else if(/^a(lt)?$/i.test(g))b=!0;else if(/^(c|ctrl|control)$/i.test(g))c=!0;else if(/^s(hift)?$/i.test(g))d=!0;else if(/^mod$/i.test(g))fh()||fx()?e=!0:c=!0;else throw Error(`Unrecognized modifier name: ${g}`)}return b&&(g=`Alt-${g}`),c&&(g=`Ctrl-${g}`),e&&(g=`Meta-${g}`),d&&(g=`Shift-${g}`),g})(a).split(/-(?!$)/),g=f.find(a=>!["Alt","Ctrl","Meta","Shift"].includes(a)),h=new KeyboardEvent("keydown",{key:"Space"===g?" ":g,altKey:f.includes("Alt"),ctrlKey:f.includes("Ctrl"),metaKey:f.includes("Meta"),shiftKey:f.includes("Shift"),bubbles:!0,cancelable:!0}),i=b.captureTransaction(()=>{c.someProp("handleKeyDown",a=>a(c,h))});return null==i||i.steps.forEach(a=>{let b=a.map(d.mapping);b&&e&&d.maybeStep(b)}),!0};function fz(a,b,c={}){let{from:d,to:e,empty:f}=a.selection,g=b?e_(b,a.schema):null,h=[];a.doc.nodesBetween(d,e,(a,b)=>{if(a.isText)return;let c=Math.max(d,b),f=Math.min(e,b+a.nodeSize);h.push({node:a,from:c,to:f})});let i=e-d,j=h.filter(a=>!g||g.name===a.node.type.name).filter(a=>e6(a.node.attrs,c,{strict:!1}));return f?!!j.length:j.reduce((a,b)=>a+b.to-b.from,0)>=i}var fA=(a,b={})=>({state:c,dispatch:d})=>{let e=e_(a,c.schema);return!!fz(c,e,b)&&((a,b)=>{let{$from:c,$to:d}=a.selection,e=c.blockRange(d),f=e&&a1(e);return null!=f&&(b&&b(a.tr.lift(e,f).scrollIntoView()),!0)})(c,d)},fB=()=>({state:a,dispatch:b})=>bZ(a,b),fC=a=>({state:b,dispatch:c})=>{var d;return(d=e_(a,b.schema),function(a,b){let{$from:c,$to:e}=a.selection,f=c.blockRange(e,a=>a.childCount>0&&a.firstChild.type==d);return!!f&&(!b||(c.node(f.depth-1).type==d?function(a,b,c,d){let e=a.tr,f=d.end,g=d.$to.end(d.depth);f<g&&(e.step(new a$(f-1,g,f,g,new Y(S.from(c.create(null,d.parent.copy())),1,0),1,!0)),d=new ah(e.doc.resolve(d.$from.pos),e.doc.resolve(g),d.depth));let h=a1(d);if(null==h)return!1;e.lift(d,h);let i=e.doc.resolve(e.mapping.map(f,-1)-1);return a7(e.doc,i.pos)&&i.nodeBefore.type==i.nodeAfter.type&&e.join(i.pos),b(e.scrollIntoView()),!0}(a,b,d,f):function(a,b,c){let d=a.tr,e=c.parent;for(let a=c.end,b=c.endIndex-1,f=c.startIndex;b>f;b--)a-=e.child(b).nodeSize,d.delete(a-1,a+1);let f=d.doc.resolve(c.start),g=f.nodeAfter;if(d.mapping.map(c.end)!=c.start+f.nodeAfter.nodeSize)return!1;let h=0==c.startIndex,i=c.endIndex==e.childCount,j=f.node(-1),k=f.index(-1);if(!j.canReplace(k+ +!h,k+1,g.content.append(i?S.empty:S.from(e))))return!1;let l=f.pos,m=l+g.nodeSize;return d.step(new a$(l-!!h,m+ +!!i,l+1,m-1,new Y((h?S.empty:S.from(e.copy(S.empty))).append(i?S.empty:S.from(e.copy(S.empty))),+!h,+!i),+!h)),b(d.scrollIntoView()),!0}(a,b,f)))})(b,c)},fD=()=>({state:a,dispatch:b})=>bV(a,b);function fE(a,b){return b.nodes[a]?"node":b.marks[a]?"mark":null}function fF(a,b){let c="string"==typeof b?[b]:b;return Object.keys(a).reduce((b,d)=>(c.includes(d)||(b[d]=a[d]),b),{})}var fG=(a,b)=>({tr:c,state:d,dispatch:e})=>{let f=null,g=null,h=fE("string"==typeof a?a:a.name,d.schema);if(!h)return!1;"node"===h&&(f=e_(a,d.schema)),"mark"===h&&(g=fa(a,d.schema));let i=!1;return c.selection.ranges.forEach(a=>{d.doc.nodesBetween(a.$from.pos,a.$to.pos,(a,d)=>{f&&f===a.type&&(i=!0,e&&c.setNodeMarkup(d,void 0,fF(a.attrs,b))),g&&a.marks.length&&a.marks.forEach(f=>{g===f.type&&(i=!0,e&&c.addMark(d,d+a.nodeSize,g.create(fF(f.attrs,b))))})})}),i},fH=()=>({tr:a,dispatch:b})=>(b&&a.scrollIntoView(),!0),fI=()=>({tr:a,dispatch:b})=>{if(b){let b=new bw(a.doc);a.setSelection(b)}return!0},fJ=()=>({state:a,dispatch:b})=>bP(a,b),fK=()=>({state:a,dispatch:b})=>bT(a,b),fL=()=>({state:a,dispatch:b})=>((a,b)=>{let{$from:c,to:d}=a.selection,e,f=c.sharedDepth(d);return 0!=f&&(e=c.before(f),b&&b(a.tr.setSelection(bu.create(a.doc,e))),!0)})(a,b),fM=()=>({state:a,dispatch:b})=>b1(a,b),fN=()=>({state:a,dispatch:b})=>b0(a,b);function fO(a,b,c={},d={}){return fn(a,b,{slice:!1,parseOptions:c,errorOnInvalidContent:d.errorOnInvalidContent})}var fP=(a,{errorOnInvalidContent:b,emitUpdate:c=!0,parseOptions:d={}}={})=>({editor:e,tr:f,dispatch:g,commands:h})=>{let{doc:i}=f;if("full"!==d.preserveWhitespace){let h=fO(a,e.schema,d,{errorOnInvalidContent:null!=b?b:e.options.enableContentCheck});return g&&f.replaceWith(0,i.content.size,h).setMeta("preventUpdate",!c),!0}return g&&f.setMeta("preventUpdate",!c),h.insertContentAt({from:0,to:i.content.size},a,{parseOptions:d,errorOnInvalidContent:null!=b?b:e.options.enableContentCheck})};function fQ(a,b){let c=fa(b,a.schema),{from:d,to:e,empty:f}=a.selection,g=[];f?(a.storedMarks&&g.push(...a.storedMarks),g.push(...a.selection.$head.marks())):a.doc.nodesBetween(d,e,a=>{g.push(...a.marks)});let h=g.find(a=>a.type.name===c.name);return h?{...h.attrs}:{}}function fR(a,b){let c=new bm(a);return b.forEach(a=>{a.steps.forEach(a=>{c.step(a)})}),c}function fS(a,b){for(let c=a.depth;c>0;c-=1){let d=a.node(c);if(b(d))return{pos:c>0?a.before(c):0,start:a.start(c),depth:c,node:d}}}function fT(a){return b=>fS(b.$from,a)}function fU(a,b,c){return void 0===a.config[b]&&a.parent?fU(a.parent,b,c):"function"==typeof a.config[b]?a.config[b].bind({...c,parent:a.parent?fU(a.parent,b,c):null}):a.config[b]}function fV(a){return a.map(a=>{let b={name:a.name,options:a.options,storage:a.storage},c=fU(a,"addExtensions",b);return c?[a,...fV(c())]:a}).flat(10)}function fW(a,b){let c=aJ.fromSchema(b).serializeFragment(a),d=document.implementation.createHTMLDocument().createElement("div");return d.appendChild(c),d.innerHTML}function fX(a){return"function"==typeof a}function fY(a,b,...c){return fX(a)?b?a.bind(b)(...c):a(...c):a}function fZ(a){let b=a.filter(a=>"extension"===a.type);return{baseExtensions:b,nodeExtensions:a.filter(a=>"node"===a.type),markExtensions:a.filter(a=>"mark"===a.type)}}function f$(a){let b=[],{nodeExtensions:c,markExtensions:d}=fZ(a),e=[...c,...d],f={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},g=c.filter(a=>"text"!==a.name).map(a=>a.name),h=d.map(a=>a.name),i=[...g,...h];return a.forEach(a=>{let c={name:a.name,options:a.options,storage:a.storage,extensions:e},d=fU(a,"addGlobalAttributes",c);d&&d().forEach(a=>{(Array.isArray(a.types)?a.types:"*"===a.types?i:"nodes"===a.types?g:"marks"===a.types?h:[]).forEach(c=>{Object.entries(a.attributes).forEach(([a,d])=>{b.push({type:c,name:a,attribute:{...f,...d}})})})})}),e.forEach(a=>{let c={name:a.name,options:a.options,storage:a.storage},d=fU(a,"addAttributes",c);d&&Object.entries(d()).forEach(([c,d])=>{let e={...f,...d};"function"==typeof(null==e?void 0:e.default)&&(e.default=e.default()),(null==e?void 0:e.isRequired)&&(null==e?void 0:e.default)===void 0&&delete e.default,b.push({type:a.name,name:c,attribute:e})})}),b}function f_(...a){return a.filter(a=>!!a).reduce((a,b)=>{let c={...a};return Object.entries(b).forEach(([a,b])=>{if(!c[a]){c[a]=b;return}if("class"===a){let d=b?String(b).split(" "):[],e=c[a]?c[a].split(" "):[],f=d.filter(a=>!e.includes(a));c[a]=[...e,...f].join(" ")}else if("style"===a){let d=b?b.split(";").map(a=>a.trim()).filter(Boolean):[],e=c[a]?c[a].split(";").map(a=>a.trim()).filter(Boolean):[],f=new Map;e.forEach(a=>{let[b,c]=a.split(":").map(a=>a.trim());f.set(b,c)}),d.forEach(a=>{let[b,c]=a.split(":").map(a=>a.trim());f.set(b,c)}),c[a]=Array.from(f.entries()).map(([a,b])=>`${a}: ${b}`).join("; ")}else c[a]=b}),c},{})}function f0(a,b){return b.filter(b=>b.type===a.type.name).filter(a=>a.attribute.rendered).map(b=>b.attribute.renderHTML?b.attribute.renderHTML(a.attrs)||{}:{[b.name]:a.attrs[b.name]}).reduce((a,b)=>f_(a,b),{})}function f1(a,b){return"style"in a?a:{...a,getAttrs:c=>{let d=a.getAttrs?a.getAttrs(c):a.attrs;if(!1===d)return!1;let e=b.reduce((a,b)=>{var d;let e=b.attribute.parseHTML?b.attribute.parseHTML(c):"string"!=typeof(d=c.getAttribute(b.name))?d:d.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(d):"true"===d||"false"!==d&&d;return null==e?a:{...a,[b.name]:e}},{});return{...d,...e}}}}function f2(a){return Object.fromEntries(Object.entries(a).filter(([a,b])=>!("attrs"===a&&function(a={}){return 0===Object.keys(a).length&&a.constructor===Object}(b))&&null!=b))}function f3(a){var b,c;let d={};return!(null==(b=null==a?void 0:a.attribute)?void 0:b.isRequired)&&"default"in((null==a?void 0:a.attribute)||{})&&(d.default=a.attribute.default),(null==(c=null==a?void 0:a.attribute)?void 0:c.validate)!==void 0&&(d.validate=a.attribute.validate),[a.name,d]}function f4(a){return a.sort((a,b)=>{let c=fU(a,"priority")||100,d=fU(b,"priority")||100;return c>d?-1:+(c<d)})}function f5(a){var b;let c=f4(fV(a)),d=Array.from(new Set((b=c.map(a=>a.name)).filter((a,c)=>b.indexOf(a)!==c)));return d.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${d.map(a=>`'${a}'`).join(", ")}]. This can lead to issues.`),c}function f6(a,b,c){let{from:d,to:e}=b,{blockSeparator:f="\n\n",textSerializers:g={}}=c||{},h="";return a.nodesBetween(d,e,(a,c,i,j)=>{var k;a.isBlock&&c>d&&(h+=f);let l=null==g?void 0:g[a.type.name];if(l)return i&&(h+=l({node:a,pos:c,parent:i,index:j,range:b})),!1;a.isText&&(h+=null==(k=null==a?void 0:a.text)?void 0:k.slice(Math.max(d,c)-c,e-c))}),h}function f7(a){return Object.fromEntries(Object.entries(a.nodes).filter(([,a])=>a.spec.toText).map(([a,b])=>[a,b.spec.toText]))}function f8(a,b){let c=fE("string"==typeof b?b:b.name,a.schema);return"node"===c?function(a,b){let c=e_(b,a.schema),{from:d,to:e}=a.selection,f=[];a.doc.nodesBetween(d,e,a=>{f.push(a)});let g=f.reverse().find(a=>a.type.name===c.name);return g?{...g.attrs}:{}}(a,b):"mark"===c?fQ(a,b):{}}function f9(a){let b,{mapping:c,steps:d}=a,e=[];return c.maps.forEach((a,b)=>{let f=[];if(a.ranges.length)a.forEach((a,b)=>{f.push({from:a,to:b})});else{let{from:a,to:c}=d[b];if(void 0===a||void 0===c)return;f.push({from:a,to:c})}f.forEach(({from:a,to:d})=>{let f=c.slice(b).map(a,-1),g=c.slice(b).map(d),h=c.invert().map(f,-1),i=c.invert().map(g);e.push({oldRange:{from:h,to:i},newRange:{from:f,to:g}})})}),1===(b=function(a,b=JSON.stringify){let c={};return a.filter(a=>{let d=b(a);return!Object.prototype.hasOwnProperty.call(c,d)&&(c[d]=!0)})}(e)).length?b:b.filter((a,c)=>!b.filter((a,b)=>b!==c).some(b=>a.oldRange.from>=b.oldRange.from&&a.oldRange.to<=b.oldRange.to&&a.newRange.from>=b.newRange.from&&a.newRange.to<=b.newRange.to))}function ga(a,b,c){let d=[];return a===b?c.resolve(a).marks().forEach(b=>{let e=e9(c.resolve(a),b.type);e&&d.push({mark:b,...e})}):c.nodesBetween(a,b,(a,b)=>{a&&(null==a?void 0:a.nodeSize)!==void 0&&d.push(...a.marks.map(c=>({from:b,to:b+a.nodeSize,mark:c})))}),d}function gb(a,b){return b.nodes[a]||b.marks[a]||null}function gc(a,b,c){return Object.fromEntries(Object.entries(c).filter(([c])=>{let d=a.find(a=>a.type===b&&a.name===c);return!!d&&d.attribute.keepOnSplit}))}function gd(a,b,c={}){let{empty:d,ranges:e}=a.selection,f=b?fa(b,a.schema):null;if(d)return!!(a.storedMarks||a.selection.$from.marks()).filter(a=>!f||f.name===a.type.name).find(a=>e6(a.attrs,c,{strict:!1}));let g=0,h=[];if(e.forEach(({$from:b,$to:c})=>{let d=b.pos,e=c.pos;a.doc.nodesBetween(d,e,(a,b)=>{if(f&&a.inlineContent&&!a.type.allowsMarkType(f))return!1;if(!a.isText&&!a.marks.length)return;let c=Math.max(d,b),i=Math.min(e,b+a.nodeSize);g+=i-c,h.push(...a.marks.map(a=>({mark:a,from:c,to:i})))})}),0===g)return!1;let i=h.filter(a=>!f||f.name===a.mark.type.name).filter(a=>e6(a.mark.attrs,c,{strict:!1})).reduce((a,b)=>a+b.to-b.from,0),j=h.filter(a=>!f||a.mark.type!==f&&a.mark.type.excludes(f)).reduce((a,b)=>a+b.to-b.from,0);return(i>0?i+j:i)>=g}function ge(a,b){return Array.isArray(b)?b.some(b=>("string"==typeof b?b:b.name)===a.name):b}function gf(a,b){let{nodeExtensions:c}=fZ(b),d=c.find(b=>b.name===a);if(!d)return!1;let e={name:d.name,options:d.options,storage:d.storage},f=fY(fU(d,"group",e));return"string"==typeof f&&f.split(" ").includes("list")}function gg(a,{checkChildren:b=!0,ignoreWhitespace:c=!1}={}){var d;if(c){if("hardBreak"===a.type.name)return!0;if(a.isText)return/^\s*$/m.test(null!=(d=a.text)?d:"")}if(a.isText)return!a.text;if(a.isAtom||a.isLeaf)return!1;if(0===a.content.childCount)return!0;if(b){let d=!0;return a.content.forEach(a=>{!1!==d&&(gg(a,{ignoreWhitespace:c,checkChildren:b})||(d=!1))}),d}return!1}function gh(a){return a instanceof bu}var gi=class a{constructor(a){this.position=a}static fromJSON(b){return new a(b.position)}toJSON(){return{position:this.position}}};function gj(a,b){let c=b.mapping.mapResult(a.position);return{position:new gi(c.pos),mapResult:c}}function gk(a){return new gi(a)}var gl=(a,b={})=>({tr:c,state:d,dispatch:e})=>{let{selection:f}=c,{empty:g,ranges:h}=f,i=fa(a,d.schema);if(e)if(g){let a=fQ(d,i);c.addStoredMark(i.create({...a,...b}))}else h.forEach(a=>{let e=a.$from.pos,f=a.$to.pos;d.doc.nodesBetween(e,f,(a,d)=>{let g=Math.max(d,e),h=Math.min(d+a.nodeSize,f);a.marks.find(a=>a.type===i)?a.marks.forEach(a=>{i===a.type&&c.addMark(g,h,i.create({...a.attrs,...b}))}):c.addMark(g,h,i.create(b))})});return function(a,b,c){var d;let{selection:e}=b,f=null;if(fd(e)&&(f=e.$cursor),f){let b=null!=(d=a.storedMarks)?d:f.marks();return f.parent.type.allowsMarkType(c)&&(!!c.isInSet(b)||!b.some(a=>a.type.excludes(c)))}let{ranges:g}=e;return g.some(({$from:b,$to:d})=>{let e=0===b.depth&&a.doc.inlineContent&&a.doc.type.allowsMarkType(c);return a.doc.nodesBetween(b.pos,d.pos,(a,b,d)=>{if(e)return!1;if(a.isInline){let b=!d||d.type.allowsMarkType(c),f=!!c.isInSet(a.marks)||!a.marks.some(a=>a.type.excludes(c));e=b&&f}return!e}),e})}(d,c,i)},gm=(a,b)=>({tr:c})=>(c.setMeta(a,b),!0),gn=(a,b={})=>({state:c,dispatch:d,chain:e})=>{let f,g=e_(a,c.schema);return(c.selection.$anchor.sameParent(c.selection.$head)&&(f=c.selection.$anchor.parent.attrs),g.isTextblock)?e().command(({commands:a})=>!!b2(g,{...f,...b})(c)||a.clearNodes()).command(({state:a})=>b2(g,{...f,...b})(a,d)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},go=a=>({tr:b,dispatch:c})=>{if(c){let{doc:c}=b,d=fe(a,0,c.content.size),e=bu.create(c,d);b.setSelection(e)}return!0},gp=(a,b)=>({tr:c,state:d,dispatch:e})=>{let f,g,{selection:h}=d;return"number"==typeof b?(f=b,g=b):b&&"from"in b&&"to"in b?(f=b.from,g=b.to):(f=h.from,g=h.to),e&&c.doc.nodesBetween(f,g,(b,d)=>{b.isText||c.setNodeMarkup(d,void 0,{...b.attrs,dir:a})}),!0},gq=a=>({tr:b,dispatch:c})=>{if(c){let{doc:c}=b,{from:d,to:e}="number"==typeof a?{from:a,to:a}:a,f=bs.atStart(c).from,g=bs.atEnd(c).to,h=fe(d,f,g),i=fe(e,f,g),j=bs.create(c,h,i);b.setSelection(j)}return!0},gr=a=>({state:b,dispatch:c})=>{var d;return(d=e_(a,b.schema),function(a,b){let{$from:c,$to:e}=a.selection,f=c.blockRange(e,a=>a.childCount>0&&a.firstChild.type==d);if(!f)return!1;let g=f.startIndex;if(0==g)return!1;let h=f.parent,i=h.child(g-1);if(i.type!=d)return!1;if(b){let c=i.lastChild&&i.lastChild.type==h.type,e=S.from(c?d.create():null),g=new Y(S.from(d.create(null,S.from(h.type.create(null,e)))),c?3:1,0),j=f.start,k=f.end;b(a.tr.step(new a$(j-(c?3:1),k,j,k,g,1,!0)).scrollIntoView())}return!0})(b,c)};function gs(a,b){let c=a.storedMarks||a.selection.$to.parentOffset&&a.selection.$from.marks();if(c){let d=c.filter(a=>null==b?void 0:b.includes(a.type.name));a.tr.ensureMarks(d)}}var gt=({keepMarks:a=!0}={})=>({tr:b,state:c,dispatch:d,editor:e})=>{let{selection:f,doc:g}=b,{$from:h,$to:i}=f,j=gc(e.extensionManager.attributes,h.node().type.name,h.node().attrs);if(f instanceof bu&&f.node.isBlock)return!!h.parentOffset&&!!a6(g,h.pos)&&(d&&(a&&gs(c,e.extensionManager.splittableMarks),b.split(h.pos).scrollIntoView()),!0);if(!h.parent.isBlock)return!1;let k=i.parentOffset===i.parent.content.size,l=0===h.depth?void 0:function(a){for(let b=0;b<a.edgeCount;b+=1){let{type:c}=a.edge(b);if(c.isTextblock&&!c.hasRequiredAttrs())return c}return null}(h.node(-1).contentMatchAt(h.indexAfter(-1))),m=k&&l?[{type:l,attrs:j}]:void 0,n=a6(b.doc,b.mapping.map(h.pos),1,m);if(!m&&!n&&a6(b.doc,b.mapping.map(h.pos),1,l?[{type:l}]:void 0)&&(n=!0,m=l?[{type:l,attrs:j}]:void 0),d){if(n&&(f instanceof bs&&b.deleteSelection(),b.split(b.mapping.map(h.pos),1,m),l&&!k&&!h.parentOffset&&h.parent.type!==l)){let a=b.mapping.map(h.before()),c=b.doc.resolve(a);h.node(-1).canReplaceWith(c.index(),c.index()+1,l)&&b.setNodeMarkup(b.mapping.map(h.before()),l)}a&&gs(c,e.extensionManager.splittableMarks),b.scrollIntoView()}return n},gu=(a,b={})=>({tr:c,state:d,dispatch:e,editor:f})=>{var g;let h=e_(a,d.schema),{$from:i,$to:j}=d.selection,k=d.selection.node;if(k&&k.isBlock||i.depth<2||!i.sameParent(j))return!1;let l=i.node(-1);if(l.type!==h)return!1;let m=f.extensionManager.attributes;if(0===i.parent.content.size&&i.node(-1).childCount===i.indexAfter(-1)){if(2===i.depth||i.node(-3).type!==h||i.index(-2)!==i.node(-2).childCount-1)return!1;if(e){let a=S.empty,d=i.index(-1)?1:i.index(-2)?2:3;for(let b=i.depth-d;b>=i.depth-3;b-=1)a=S.from(i.node(b).copy(a));let e=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3,f={...gc(m,i.node().type.name,i.node().attrs),...b},j=(null==(g=h.contentMatch.defaultType)?void 0:g.createAndFill(f))||void 0;a=a.append(S.from(h.createAndFill(null,j)||void 0));let k=i.before(i.depth-(d-1));c.replace(k,i.after(-e),new Y(a,4-d,0));let l=-1;c.doc.nodesBetween(k,c.doc.content.size,(a,b)=>{if(l>-1)return!1;a.isTextblock&&0===a.content.size&&(l=b+1)}),l>-1&&c.setSelection(bs.near(c.doc.resolve(l))),c.scrollIntoView()}return!0}let n=j.pos===i.end()?l.contentMatchAt(0).defaultType:null,o={...gc(m,l.type.name,l.attrs),...b},p={...gc(m,i.node().type.name,i.node().attrs),...b};c.delete(i.pos,j.pos);let q=n?[{type:h,attrs:o},{type:n,attrs:p}]:[{type:h,attrs:o}];if(!a6(c.doc,i.pos,2))return!1;if(e){let{selection:a,storedMarks:b}=d,{splittableMarks:g}=f.extensionManager,h=b||a.$to.parentOffset&&a.$from.marks();if(c.split(i.pos,2,q).scrollIntoView(),!h||!e)return!0;let j=h.filter(a=>g.includes(a.type.name));c.ensureMarks(j)}return!0},gv=(a,b)=>{let c=fT(a=>a.type===b)(a.selection);if(!c)return!0;let d=a.doc.resolve(Math.max(0,c.pos-1)).before(c.depth);if(void 0===d)return!0;let e=a.doc.nodeAt(d);return!(c.node.type===(null==e?void 0:e.type)&&a7(a.doc,c.pos))||(a.join(c.pos),!0)},gw=(a,b)=>{let c=fT(a=>a.type===b)(a.selection);if(!c)return!0;let d=a.doc.resolve(c.start).after(c.depth);if(void 0===d)return!0;let e=a.doc.nodeAt(d);return!(c.node.type===(null==e?void 0:e.type)&&a7(a.doc,d))||(a.join(d),!0)},gx=(a,b,c,d={})=>({editor:e,tr:f,state:g,dispatch:h,chain:i,commands:j,can:k})=>{let{extensions:l,splittableMarks:m}=e.extensionManager,n=e_(a,g.schema),o=e_(b,g.schema),{selection:p,storedMarks:q}=g,{$from:r,$to:s}=p,t=r.blockRange(s),u=q||p.$to.parentOffset&&p.$from.marks();if(!t)return!1;let v=fT(a=>gf(a.type.name,l))(p);if(t.depth>=1&&v&&t.depth-v.depth<=1){if(v.node.type===n)return j.liftListItem(o);if(gf(v.node.type.name,l)&&n.validContent(v.node.content)&&h)return i().command(()=>(f.setNodeMarkup(v.pos,n),!0)).command(()=>gv(f,n)).command(()=>gw(f,n)).run()}return c&&u&&h?i().command(()=>{let a=k().wrapInList(n,d),b=u.filter(a=>m.includes(a.type.name));return f.ensureMarks(b),!!a||j.clearNodes()}).wrapInList(n,d).command(()=>gv(f,n)).command(()=>gw(f,n)).run():i().command(()=>!!k().wrapInList(n,d)||j.clearNodes()).wrapInList(n,d).command(()=>gv(f,n)).command(()=>gw(f,n)).run()},gy=(a,b={},c={})=>({state:d,commands:e})=>{let{extendEmptyMarkRange:f=!1}=c,g=fa(a,d.schema);return gd(d,g,b)?e.unsetMark(g,{extendEmptyMarkRange:f}):e.setMark(g,b)},gz=(a,b,c={})=>({state:d,commands:e})=>{let f,g=e_(a,d.schema),h=e_(b,d.schema),i=fz(d,g,c);return(d.selection.$anchor.sameParent(d.selection.$head)&&(f=d.selection.$anchor.parent.attrs),i)?e.setNode(h,f):e.setNode(g,{...f,...c})},gA=(a,b={})=>({state:c,commands:d})=>{let e=e_(a,c.schema);return fz(c,e,b)?d.lift(e):d.wrapIn(e,b)},gB=()=>({state:a,dispatch:b})=>{let c=a.plugins;for(let d=0;d<c.length;d+=1){let e,f=c[d];if(f.spec.isInputRules&&(e=f.getState(a))){if(b){let b=a.tr,c=e.transform;for(let a=c.steps.length-1;a>=0;a-=1)b.step(c.steps[a].invert(c.docs[a]));if(e.text){let c=b.doc.resolve(e.from).marks();b.replaceWith(e.from,e.to,a.schema.text(e.text,c))}else b.delete(e.from,e.to)}return!0}}return!1},gC=()=>({tr:a,dispatch:b})=>{let{selection:c}=a,{empty:d,ranges:e}=c;return!!d||(b&&e.forEach(b=>{a.removeMark(b.$from.pos,b.$to.pos)}),!0)},gD=(a,b={})=>({tr:c,state:d,dispatch:e})=>{var f;let{extendEmptyMarkRange:g=!1}=b,{selection:h}=c,i=fa(a,d.schema),{$from:j,empty:k,ranges:l}=h;if(!e)return!0;if(k&&g){let{from:a,to:b}=h,d=null==(f=j.marks().find(a=>a.type===i))?void 0:f.attrs,e=e9(j,i,d);e&&(a=e.from,b=e.to),c.removeMark(a,b,i)}else l.forEach(a=>{c.removeMark(a.$from.pos,a.$to.pos,i)});return c.removeStoredMark(i),!0},gE=a=>({tr:b,state:c,dispatch:d})=>{let e,f,{selection:g}=c;return"number"==typeof a?(e=a,f=a):a&&"from"in a&&"to"in a?(e=a.from,f=a.to):(e=g.from,f=g.to),d&&b.doc.nodesBetween(e,f,(a,c)=>{if(a.isText)return;let d={...a.attrs};delete d.dir,b.setNodeMarkup(c,void 0,d)}),!0},gF=(a,b={})=>({tr:c,state:d,dispatch:e})=>{let f=null,g=null,h=fE("string"==typeof a?a:a.name,d.schema);if(!h)return!1;"node"===h&&(f=e_(a,d.schema)),"mark"===h&&(g=fa(a,d.schema));let i=!1;return c.selection.ranges.forEach(a=>{let h,j,k,l,m=a.$from.pos,n=a.$to.pos;c.selection.empty?d.doc.nodesBetween(m,n,(a,b)=>{f&&f===a.type&&(i=!0,k=Math.max(b,m),l=Math.min(b+a.nodeSize,n),h=b,j=a)}):d.doc.nodesBetween(m,n,(a,d)=>{d<m&&f&&f===a.type&&(i=!0,k=Math.max(d,m),l=Math.min(d+a.nodeSize,n),h=d,j=a),d>=m&&d<=n&&(f&&f===a.type&&(i=!0,e&&c.setNodeMarkup(d,void 0,{...a.attrs,...b})),g&&a.marks.length&&a.marks.forEach(f=>{if(g===f.type&&(i=!0,e)){let e=Math.max(d,m),h=Math.min(d+a.nodeSize,n);c.addMark(e,h,g.create({...f.attrs,...b}))}}))}),j&&(void 0!==h&&e&&c.setNodeMarkup(h,void 0,{...j.attrs,...b}),g&&j.marks.length&&j.marks.forEach(a=>{g===a.type&&e&&c.addMark(k,l,g.create({...a.attrs,...b}))}))}),i},gG=(a,b={})=>({state:c,dispatch:d})=>(function(a,b=null){return function(c,d){let{$from:e,$to:f}=c.selection,g=e.blockRange(f),h=g&&a2(g,a,b);return!!h&&(d&&d(c.tr.wrap(g,h).scrollIntoView()),!0)}})(e_(a,c.schema),b)(c,d),gH=(a,b={})=>({state:c,dispatch:d})=>(function(a,b=null){return function(c,d){let{$from:e,$to:f}=c.selection,g=e.blockRange(f);if(!g)return!1;let h=d?c.tr:null;return!!function(a,b,c,d=null){let e=!1,f=b,g=b.$from.doc;if(b.depth>=2&&b.$from.node(b.depth-1).type.compatibleContent(c)&&0==b.startIndex){if(0==b.$from.index(b.depth-1))return!1;let a=g.resolve(b.start-2);f=new ah(a,a,b.depth),b.endIndex<b.parent.childCount&&(b=new ah(b.$from,g.resolve(b.$to.end(b.depth)),b.depth)),e=!0}let h=a2(f,c,d,b);return!!h&&(a&&function(a,b,c,d,e){let f=S.empty;for(let a=c.length-1;a>=0;a--)f=S.from(c[a].type.create(c[a].attrs,f));a.step(new a$(b.start-2*!!d,b.end,b.start,b.end,new Y(f,0,0),c.length,!0));let g=0;for(let a=0;a<c.length;a++)c[a].type==e&&(g=a+1);let h=c.length-g,i=b.start+c.length-2*!!d,j=b.parent;for(let c=b.startIndex,d=b.endIndex,e=!0;c<d;c++,e=!1)!e&&a6(a.doc,i,h)&&(a.split(i,h),i+=2*h),i+=j.child(c).nodeSize}(a,b,h,e,c),!0)}(h,g,a,b)&&(d&&d(h.scrollIntoView()),!0)}})(e_(a,c.schema),b)(c,d),gI=class{constructor(){this.callbacks={}}on(a,b){return this.callbacks[a]||(this.callbacks[a]=[]),this.callbacks[a].push(b),this}emit(a,...b){let c=this.callbacks[a];return c&&c.forEach(a=>a.apply(this,b)),this}off(a,b){let c=this.callbacks[a];return c&&(b?this.callbacks[a]=c.filter(a=>a!==b):delete this.callbacks[a]),this}once(a,b){let c=(...d)=>{this.off(a,c),b.apply(this,d)};return this.on(a,c)}removeAllListeners(){this.callbacks={}}},gJ=class{constructor(a){var b;this.find=a.find,this.handler=a.handler,this.undoable=null==(b=a.undoable)||b}};function gK(a){var b;let{editor:c,from:d,to:e,text:f,rules:g,plugin:h}=a,{view:i}=c;if(i.composing)return!1;let j=i.state.doc.resolve(d);if(j.parent.type.spec.code||(null==(b=j.nodeBefore||j.nodeAfter)?void 0:b.marks.find(a=>a.type.spec.code)))return!1;let k=!1,l=((a,b=500)=>{let c="",d=a.parentOffset;return a.parent.nodesBetween(Math.max(0,d-b),d,(a,b,e,f)=>{var g,h;let i=(null==(h=(g=a.type.spec).toText)?void 0:h.call(g,{node:a,pos:b,parent:e,index:f}))||a.textContent||"%leaf%";c+=a.isAtom&&!a.isText?i:i.slice(0,Math.max(0,d-b))}),c})(j)+f;return g.forEach(a=>{if(k)return;let b=((a,b)=>{if(e5(b))return b.exec(a);let c=b(a);if(!c)return null;let d=[c.text];return d.index=c.index,d.input=a,d.data=c.data,c.replaceWith&&(c.text.includes(c.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),d.push(c.replaceWith)),d})(l,a.find);if(!b)return;let g=i.state.tr,j=eR({state:i.state,transaction:g}),m={from:d-(b[0].length-f.length),to:e},{commands:n,chain:o,can:p}=new eS({editor:c,state:j});null!==a.handler({state:j,range:m,match:b,commands:n,chain:o,can:p})&&g.steps.length&&(a.undoable&&g.setMeta(h,{transform:g,from:d,to:e,text:f}),i.dispatch(g),k=!0)}),k}function gL(a){return"Object"===Object.prototype.toString.call(a).slice(8,-1)&&a.constructor===Object&&Object.getPrototypeOf(a)===Object.prototype}var gM=class{constructor(a={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...a},this.name=this.config.name}get options(){return{...fY(fU(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...fY(fU(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(a={}){let b=this.extend({...this.config,addOptions:()=>(function a(b,c){let d={...b};return gL(b)&&gL(c)&&Object.keys(c).forEach(e=>{gL(c[e])&&gL(b[e])?d[e]=a(b[e],c[e]):d[e]=c[e]}),d})(this.options,a)});return b.name=this.name,b.parent=this.parent,b}extend(a={}){let b=new this.constructor({...this.config,...a});return b.parent=this,this.child=b,b.name="name"in a?a.name:b.parent.name,b}},gN=class a extends gM{constructor(){super(...arguments),this.type="mark"}static create(b={}){return new a("function"==typeof b?b():b)}static handleExit({editor:a,mark:b}){let{tr:c}=a.state,d=a.state.selection.$from;if(d.pos===d.end()){let e=d.marks();if(!e.find(a=>(null==a?void 0:a.type.name)===b.name))return!1;let f=e.find(a=>(null==a?void 0:a.type.name)===b.name);return f&&c.removeStoredMark(f),c.insertText(" ",d.pos),a.view.dispatch(c),!0}return!1}configure(a){return super.configure(a)}extend(a){let b="function"==typeof a?a():a;return super.extend(b)}},gO=class{constructor(a){this.find=a.find,this.handler=a.handler}},gP=null,gQ=class{constructor(a,b){this.splittableMarks=[],this.editor=b,this.baseExtensions=a,this.extensions=f5(a),this.schema=function(a,b){var c;let d=f$(a),{nodeExtensions:e,markExtensions:f}=fZ(a),g=null==(c=e.find(a=>fU(a,"topNode")))?void 0:c.name;return new ay({topNode:g,nodes:Object.fromEntries(e.map(c=>{let e=d.filter(a=>a.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:b},g=f2({...a.reduce((a,b)=>{let d=fU(b,"extendNodeSchema",f);return{...a,...d?d(c):{}}},{}),content:fY(fU(c,"content",f)),marks:fY(fU(c,"marks",f)),group:fY(fU(c,"group",f)),inline:fY(fU(c,"inline",f)),atom:fY(fU(c,"atom",f)),selectable:fY(fU(c,"selectable",f)),draggable:fY(fU(c,"draggable",f)),code:fY(fU(c,"code",f)),whitespace:fY(fU(c,"whitespace",f)),linebreakReplacement:fY(fU(c,"linebreakReplacement",f)),defining:fY(fU(c,"defining",f)),isolating:fY(fU(c,"isolating",f)),attrs:Object.fromEntries(e.map(f3))}),h=fY(fU(c,"parseHTML",f));h&&(g.parseDOM=h.map(a=>f1(a,e)));let i=fU(c,"renderHTML",f);i&&(g.toDOM=a=>i({node:a,HTMLAttributes:f0(a,e)}));let j=fU(c,"renderText",f);return j&&(g.toText=j),[c.name,g]})),marks:Object.fromEntries(f.map(c=>{let e=d.filter(a=>a.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:b},g=f2({...a.reduce((a,b)=>{let d=fU(b,"extendMarkSchema",f);return{...a,...d?d(c):{}}},{}),inclusive:fY(fU(c,"inclusive",f)),excludes:fY(fU(c,"excludes",f)),group:fY(fU(c,"group",f)),spanning:fY(fU(c,"spanning",f)),code:fY(fU(c,"code",f)),attrs:Object.fromEntries(e.map(f3))}),h=fY(fU(c,"parseHTML",f));h&&(g.parseDOM=h.map(a=>f1(a,e)));let i=fU(c,"renderHTML",f);return i&&(g.toDOM=a=>i({mark:a,HTMLAttributes:f0(a,e)})),[c.name,g]}))})}(this.extensions,b),this.setupExtensions()}get commands(){return this.extensions.reduce((a,b)=>{let c={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:this.editor,type:gb(b.name,this.schema)},d=fU(b,"addCommands",c);return d?{...a,...d()}:a},{})}get plugins(){let{editor:a}=this;return f4([...this.extensions].reverse()).flatMap(b=>{let c={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:a,type:gb(b.name,this.schema)},d=[],e=fU(b,"addKeyboardShortcuts",c),f={};if("mark"===b.type&&fU(b,"exitable",c)&&(f.ArrowRight=()=>gN.handleExit({editor:a,mark:b})),e){let b=Object.fromEntries(Object.entries(e()).map(([b,c])=>[b,()=>c({editor:a})]));f={...f,...b}}let g=new bG({props:{handleKeyDown:eO(f)}});d.push(g);let h=fU(b,"addInputRules",c);if(ge(b,a.options.enableInputRules)&&h){let b=h();if(b&&b.length){let c=function(a){let{editor:b,rules:c}=a,d=new bG({state:{init:()=>null,apply(a,e,f){let g=a.getMeta(d);if(g)return g;let h=a.getMeta("applyInputRules");return h&&setTimeout(()=>{let{text:a}=h;"string"==typeof a||(a=fW(S.from(a),f.schema));let{from:e}=h,g=e+a.length;gK({editor:b,from:e,to:g,text:a,rules:c,plugin:d})}),a.selectionSet||a.docChanged?null:e}},props:{handleTextInput:(a,e,f,g)=>gK({editor:b,from:e,to:f,text:g,rules:c,plugin:d}),handleDOMEvents:{compositionend:a=>(setTimeout(()=>{let{$cursor:e}=a.state.selection;e&&gK({editor:b,from:e.pos,to:e.pos,text:"",rules:c,plugin:d})}),!1)},handleKeyDown(a,e){if("Enter"!==e.key)return!1;let{$cursor:f}=a.state.selection;return!!f&&gK({editor:b,from:f.pos,to:f.pos,text:"\n",rules:c,plugin:d})}},isInputRules:!0});return d}({editor:a,rules:b}),e=Array.isArray(c)?c:[c];d.push(...e)}}let i=fU(b,"addPasteRules",c);if(ge(b,a.options.enablePasteRules)&&i){let b=i();if(b&&b.length){let c=function(a){let b,{editor:c,rules:d}=a,e=null,f=!1,g=!1,h="u">typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{b="u">typeof DragEvent?new DragEvent("drop"):null}catch{b=null}let i=({state:a,from:d,to:e,rule:f,pasteEvt:g})=>{let i=a.tr;if(function(a){let{editor:b,state:c,from:d,to:e,rule:f,pasteEvent:g,dropEvent:h}=a,{commands:i,chain:j,can:k}=new eS({editor:b,state:c}),l=[];return c.doc.nodesBetween(d,e,(a,b)=>{var m,n,o,p,q;if((null==(n=null==(m=a.type)?void 0:m.spec)?void 0:n.code)||!(a.isText||a.isTextblock||a.isInline))return;let r=null!=(q=null!=(p=null==(o=a.content)?void 0:o.size)?p:a.nodeSize)?q:0,s=Math.max(d,b),t=Math.min(e,b+r);s>=t||((a,b,c)=>{if(e5(b))return[...a.matchAll(b)];let d=b(a,c);return d?d.map(b=>{let c=[b.text];return c.index=b.index,c.input=a,c.data=b.data,b.replaceWith&&(b.text.includes(b.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),c.push(b.replaceWith)),c}):[]})(a.isText?a.text||"":a.textBetween(s-b,t-b,void 0,""),f.find,g).forEach(a=>{if(void 0===a.index)return;let b=s+a.index+1,d=b+a[0].length,e={from:c.tr.mapping.map(b),to:c.tr.mapping.map(d)},m=f.handler({state:c,range:e,match:a,commands:i,chain:j,can:k,pasteEvent:g,dropEvent:h});l.push(m)})}),l.every(a=>null!==a)}({editor:c,state:eR({state:a,transaction:i}),from:Math.max(d-1,0),to:e.b-1,rule:f,pasteEvent:g,dropEvent:b})&&i.steps.length){try{b="u">typeof DragEvent?new DragEvent("drop"):null}catch{b=null}return h="u">typeof ClipboardEvent?new ClipboardEvent("paste"):null,i}};return d.map(a=>new bG({view(a){let b=b=>{var d;(e=(null==(d=a.dom.parentElement)?void 0:d.contains(b.target))?a.dom.parentElement:null)&&(gP=c)},d=()=>{gP&&(gP=null)};return window.addEventListener("dragstart",b),window.addEventListener("dragend",d),{destroy(){window.removeEventListener("dragstart",b),window.removeEventListener("dragend",d)}}},props:{handleDOMEvents:{drop:(a,c)=>{if(g=e===a.dom.parentElement,b=c,!g){let a=gP;(null==a?void 0:a.isEditable)&&setTimeout(()=>{let b=a.state.selection;b&&a.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(a,b)=>{var c;let d=null==(c=b.clipboardData)?void 0:c.getData("text/html");return h=b,f=!!(null==d?void 0:d.includes("data-pm-slice")),!1}}},appendTransaction:(b,c,d)=>{let e=b[0],j="paste"===e.getMeta("uiEvent")&&!f,k="drop"===e.getMeta("uiEvent")&&!g,l=e.getMeta("applyPasteRules"),m=!!l;if(!j&&!k&&!m)return;if(m){var n,o;let b,{text:c}=l;"string"==typeof c||(c=fW(S.from(c),d.schema));let{from:e}=l,f=e+c.length;return i({rule:a,state:d,from:e,to:{b:f},pasteEvt:(n=c,null==(o=(b=new ClipboardEvent("paste",{clipboardData:new DataTransfer})).clipboardData)||o.setData("text/html",n),b)})}let p=c.doc.content.findDiffStart(d.doc.content),q=c.doc.content.findDiffEnd(d.doc.content);if("number"==typeof p&&q&&p!==q.b)return i({rule:a,state:d,from:p,to:q,pasteEvt:h})}}))}({editor:a,rules:b});d.push(...c)}}let j=fU(b,"addProseMirrorPlugins",c);if(j){let a=j();d.push(...a)}return d})}get attributes(){return f$(this.extensions)}get nodeViews(){let{editor:a}=this,{nodeExtensions:b}=fZ(this.extensions);return Object.fromEntries(b.filter(a=>!!fU(a,"addNodeView")).map(b=>{let c=this.attributes.filter(a=>a.type===b.name),d={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:a,type:e_(b.name,this.schema)},e=fU(b,"addNodeView",d);if(!e)return[];let f=e();return f?[b.name,(d,e,g,h,i)=>{let j=f0(d,c);return f({node:d,view:e,getPos:g,decorations:h,innerDecorations:i,editor:a,extension:b,HTMLAttributes:j})}]:[]}))}dispatchTransaction(a){let{editor:b}=this;return f4([...this.extensions].reverse()).reduceRight((a,c)=>{let d={name:c.name,options:c.options,storage:this.editor.extensionStorage[c.name],editor:b,type:gb(c.name,this.schema)},e=fU(c,"dispatchTransaction",d);return e?b=>{e.call(d,{transaction:b,next:a})}:a},a)}transformPastedHTML(a){let{editor:b}=this;return f4([...this.extensions]).reduce((a,c)=>{let d={name:c.name,options:c.options,storage:this.editor.extensionStorage[c.name],editor:b,type:gb(c.name,this.schema)},e=fU(c,"transformPastedHTML",d);return e?(b,c)=>{let f=a(b,c);return e.call(d,f)}:a},a||(a=>a))}get markViews(){let{editor:a}=this,{markExtensions:b}=fZ(this.extensions);return Object.fromEntries(b.filter(a=>!!fU(a,"addMarkView")).map(b=>{let c=this.attributes.filter(a=>a.type===b.name),d={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:a,type:fa(b.name,this.schema)},e=fU(b,"addMarkView",d);return e?[b.name,(d,f,g)=>{let h=f0(d,c);return e()({mark:d,view:f,inline:g,editor:a,extension:b,HTMLAttributes:h,updateAttributes:b=>{!function(a,b,c={}){let{state:d}=b,{doc:e,tr:f}=d;e.descendants((b,d)=>{let e=f.mapping.map(d),g=f.mapping.map(d)+b.nodeSize,h=null;if(b.marks.forEach(b=>{if(b!==a)return!1;h=b}),!h)return;let i=!1;if(Object.keys(c).forEach(a=>{c[a]!==h.attrs[a]&&(i=!0)}),i){let b=a.type.create({...a.attrs,...c});f.removeMark(e,g,a.type),f.addMark(e,g,b)}}),f.docChanged&&b.view.dispatch(f)}(d,a,b)}})}]:[]}))}setupExtensions(){let a=this.extensions;this.editor.extensionStorage=Object.fromEntries(a.map(a=>[a.name,a.storage])),a.forEach(a=>{var b;let c={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:this.editor,type:gb(a.name,this.schema)};"mark"===a.type&&(null==(b=fY(fU(a,"keepOnSplit",c)))||b)&&this.splittableMarks.push(a.name);let d=fU(a,"onBeforeCreate",c),e=fU(a,"onCreate",c),f=fU(a,"onUpdate",c),g=fU(a,"onSelectionUpdate",c),h=fU(a,"onTransaction",c),i=fU(a,"onFocus",c),j=fU(a,"onBlur",c),k=fU(a,"onDestroy",c);d&&this.editor.on("beforeCreate",d),e&&this.editor.on("create",e),f&&this.editor.on("update",f),g&&this.editor.on("selectionUpdate",g),h&&this.editor.on("transaction",h),i&&this.editor.on("focus",i),j&&this.editor.on("blur",j),k&&this.editor.on("destroy",k)})}};gQ.resolve=f5,gQ.sort=f4,gQ.flatten=fV;var gR={};eQ(gR,{ClipboardTextSerializer:()=>gT,Commands:()=>gU,Delete:()=>gV,Drop:()=>gW,Editable:()=>gX,FocusEvents:()=>gZ,Keymap:()=>g$,Paste:()=>g_,Tabindex:()=>g0,TextDirection:()=>g1,focusEventsPluginKey:()=>gY});var gS=class a extends gM{constructor(){super(...arguments),this.type="extension"}static create(b={}){return new a("function"==typeof b?b():b)}configure(a){return super.configure(a)}extend(a){let b="function"==typeof a?a():a;return super.extend(b)}},gT=gS.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new bG({key:new bJ("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:a}=this,{state:b,schema:c}=a,{doc:d,selection:e}=b,{ranges:f}=e,g=Math.min(...f.map(a=>a.$from.pos)),h=Math.max(...f.map(a=>a.$to.pos)),i=f7(c);return f6(d,{from:g,to:h},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:i})}}})]}}),gU=gS.create({name:"commands",addCommands:()=>({...eT})}),gV=gS.create({name:"delete",onUpdate({transaction:a,appendedTransactions:b}){var c,d,e;let f=()=>{var c,d,e,f;if(null!=(f=null==(e=null==(d=null==(c=this.editor.options.coreExtensionOptions)?void 0:c.delete)?void 0:d.filterTransaction)?void 0:e.call(d,a))?f:a.getMeta("y-sync$"))return;let g=fR(a.before,[a,...b]);f9(g).forEach(b=>{g.mapping.mapResult(b.oldRange.from).deletedAfter&&g.mapping.mapResult(b.oldRange.to).deletedBefore&&g.before.nodesBetween(b.oldRange.from,b.oldRange.to,(c,d)=>{let e=d+c.nodeSize-2,f=b.oldRange.from<=d&&e<=b.oldRange.to;this.editor.emit("delete",{type:"node",node:c,from:d,to:e,newFrom:g.mapping.map(d),newTo:g.mapping.map(e),deletedRange:b.oldRange,newRange:b.newRange,partial:!f,editor:this.editor,transaction:a,combinedTransform:g})})});let h=g.mapping;g.steps.forEach((b,c)=>{var d,e;if(b instanceof aW){let f=h.slice(c).map(b.from,-1),i=h.slice(c).map(b.to),j=h.invert().map(f,-1),k=h.invert().map(i),l=null==(d=g.doc.nodeAt(f-1))?void 0:d.marks.some(a=>a.eq(b.mark)),m=null==(e=g.doc.nodeAt(i))?void 0:e.marks.some(a=>a.eq(b.mark));this.editor.emit("delete",{type:"mark",mark:b.mark,from:b.from,to:b.to,deletedRange:{from:j,to:k},newRange:{from:f,to:i},partial:!!(m||l),editor:this.editor,transaction:a,combinedTransform:g})}})};null==(e=null==(d=null==(c=this.editor.options.coreExtensionOptions)?void 0:c.delete)?void 0:d.async)||e?setTimeout(f,0):f()}}),gW=gS.create({name:"drop",addProseMirrorPlugins(){return[new bG({key:new bJ("tiptapDrop"),props:{handleDrop:(a,b,c,d)=>{this.editor.emit("drop",{editor:this.editor,event:b,slice:c,moved:d})}}})]}}),gX=gS.create({name:"editable",addProseMirrorPlugins(){return[new bG({key:new bJ("editable"),props:{editable:()=>this.editor.options.editable}})]}}),gY=new bJ("focusEvents"),gZ=gS.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:a}=this;return[new bG({key:gY,props:{handleDOMEvents:{focus:(b,c)=>{a.isFocused=!0;let d=a.state.tr.setMeta("focus",{event:c}).setMeta("addToHistory",!1);return b.dispatch(d),!1},blur:(b,c)=>{a.isFocused=!1;let d=a.state.tr.setMeta("blur",{event:c}).setMeta("addToHistory",!1);return b.dispatch(d),!1}}}})]}}),g$=gS.create({name:"keymap",addKeyboardShortcuts(){let a=()=>this.editor.commands.first(({commands:a})=>[()=>a.undoInputRule(),()=>a.command(({tr:b})=>{let{selection:c,doc:d}=b,{empty:e,$anchor:f}=c,{pos:g,parent:h}=f,i=f.parent.isTextblock&&g>0?b.doc.resolve(g-1):f,j=i.parent.type.spec.isolating,k=f.pos-f.parentOffset,l=j&&1===i.parent.childCount?k===f.pos:bo.atStart(d).from===g;return!!e&&!!h.type.isTextblock&&!h.textContent.length&&!!l&&(!l||"paragraph"!==f.parent.type.name)&&a.clearNodes()}),()=>a.deleteSelection(),()=>a.joinBackward(),()=>a.selectNodeBackward()]),b=()=>this.editor.commands.first(({commands:a})=>[()=>a.deleteSelection(),()=>a.deleteCurrentNode(),()=>a.joinForward(),()=>a.selectNodeForward()]),c={Enter:()=>this.editor.commands.first(({commands:a})=>[()=>a.newlineInCode(),()=>a.createParagraphNear(),()=>a.liftEmptyBlock(),()=>a.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:a,"Mod-Backspace":a,"Shift-Backspace":a,Delete:b,"Mod-Delete":b,"Mod-a":()=>this.editor.commands.selectAll()},d={...c},e={...c,"Ctrl-h":a,"Alt-Backspace":a,"Ctrl-d":b,"Ctrl-Alt-Backspace":b,"Alt-Delete":b,"Alt-d":b,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return fh()||fx()?e:d},addProseMirrorPlugins(){return[new bG({key:new bJ("clearDocument"),appendTransaction:(a,b,c)=>{if(a.some(a=>a.getMeta("composition")))return;let d=a.some(a=>a.docChanged)&&!b.doc.eq(c.doc),e=a.some(a=>a.getMeta("preventClearDocument"));if(!d||e)return;let{empty:f,from:g,to:h}=b.selection,i=bo.atStart(b.doc).from,j=bo.atEnd(b.doc).to;if(f||g!==i||h!==j||!gg(c.doc))return;let k=c.tr,l=eR({state:c,transaction:k}),{commands:m}=new eS({editor:this.editor,state:l});if(m.clearNodes(),k.steps.length)return k}})]}}),g_=gS.create({name:"paste",addProseMirrorPlugins(){return[new bG({key:new bJ("tiptapPaste"),props:{handlePaste:(a,b,c)=>{this.editor.emit("paste",{editor:this.editor,event:b,slice:c})}}})]}}),g0=gS.create({name:"tabindex",addProseMirrorPlugins(){return[new bG({key:new bJ("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),g1=gS.create({name:"textDirection",addOptions:()=>({direction:void 0}),addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:a}=fZ(this.extensions);return[{types:a.filter(a=>"text"!==a.name).map(a=>a.name),attributes:{dir:{default:this.options.direction,parseHTML:a=>{let b=a.getAttribute("dir");return b&&("ltr"===b||"rtl"===b||"auto"===b)?b:this.options.direction},renderHTML:a=>a.dir?{dir:a.dir}:{}}}}]},addProseMirrorPlugins(){return[new bG({key:new bJ("textDirection"),props:{attributes:()=>{let a=this.options.direction;return a?{dir:a}:{}}}})]}}),g2=class a{constructor(a,b,c=!1,d=null){this.currentNode=null,this.actualDepth=null,this.isBlock=c,this.resolvedPos=a,this.editor=b,this.currentNode=d}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 a;return null!=(a=this.actualDepth)?a:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(a){let b=this.from,c=this.to;if(this.isBlock){if(0===this.content.size)return void console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);b=this.from+1,c=this.to-1}this.editor.commands.insertContentAt({from:b,to:c},a)}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}get parent(){if(0===this.depth)return null;let b=this.resolvedPos.start(this.resolvedPos.depth-1);return new a(this.resolvedPos.doc.resolve(b),this.editor)}get before(){let b=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return b.depth!==this.depth&&(b=this.resolvedPos.doc.resolve(this.from-3)),new a(b,this.editor)}get after(){let b=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return b.depth!==this.depth&&(b=this.resolvedPos.doc.resolve(this.to+3)),new a(b,this.editor)}get children(){let b=[];return this.node.content.forEach((c,d)=>{let e=c.isBlock&&!c.isTextblock,f=c.isAtom&&!c.isText,g=c.isInline,h=this.pos+d+ +!f;if(h<0||h>this.resolvedPos.doc.nodeSize-2)return;let i=this.resolvedPos.doc.resolve(h);if(!e&&!g&&i.depth<=this.depth)return;let j=new a(i,this.editor,e,e||g?c:null);e&&(j.actualDepth=this.depth+1),b.push(j)}),b}get firstChild(){return this.children[0]||null}get lastChild(){let a=this.children;return a[a.length-1]||null}closest(a,b={}){let c=null,d=this.parent;for(;d&&!c;){if(d.node.type.name===a)if(Object.keys(b).length>0){let a=d.node.attrs,c=Object.keys(b);for(let d=0;d<c.length;d+=1){let e=c[d];if(a[e]!==b[e])break}}else c=d;d=d.parent}return c}querySelector(a,b={}){return this.querySelectorAll(a,b,!0)[0]||null}querySelectorAll(a,b={},c=!1){let d=[];if(!this.children||0===this.children.length)return d;let e=Object.keys(b);return this.children.forEach(f=>{c&&d.length>0||(f.node.type.name===a&&e.every(a=>b[a]===f.node.attrs[a])&&d.push(f),c&&d.length>0||(d=d.concat(f.querySelectorAll(a,b,c))))}),d}setAttribute(a){let{tr:b}=this.editor.state;b.setNodeMarkup(this.from,void 0,{...this.node.attrs,...a}),this.editor.view.dispatch(b)}},g3=`.ProseMirror {
|
|
3
3
|
position: relative;
|
|
4
4
|
}
|
|
5
5
|
|