wiki-viewer 2.11.3 → 2.11.5

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.
Files changed (73) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/build-manifest.json +3 -3
  3. package/.next/standalone/.next/prerender-manifest.json +3 -3
  4. package/.next/standalone/.next/required-server-files.json +1 -1
  5. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  6. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  7. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  11. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  12. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  13. package/.next/standalone/.next/server/app/api/agent/activity/route.js.nft.json +1 -1
  14. package/.next/standalone/.next/server/app/api/agent/events/[...path]/route.js.nft.json +1 -1
  15. package/.next/standalone/.next/server/app/api/agent/files/[...path]/route.js.nft.json +1 -1
  16. package/.next/standalone/.next/server/app/api/agent/fs/file/[...path]/route.js.nft.json +1 -1
  17. package/.next/standalone/.next/server/app/api/agent/fs/ls/[[...path]]/route.js.nft.json +1 -1
  18. package/.next/standalone/.next/server/app/api/agent/fs/move/route.js.nft.json +1 -1
  19. package/.next/standalone/.next/server/app/api/agent/fs/search/route.js.nft.json +1 -1
  20. package/.next/standalone/.next/server/app/api/agent/internal/span/route.js.nft.json +1 -1
  21. package/.next/standalone/.next/server/app/api/agent/settings/route.js.nft.json +1 -1
  22. package/.next/standalone/.next/server/app/api/agent/sidecar/[...path]/route.js.nft.json +1 -1
  23. package/.next/standalone/.next/server/app/api/app-proxy/[...path]/route.js.nft.json +1 -1
  24. package/.next/standalone/.next/server/app/api/assets/[...path]/route.js.nft.json +1 -1
  25. package/.next/standalone/.next/server/app/api/pdf/save/route.js.nft.json +1 -1
  26. package/.next/standalone/.next/server/app/api/share/[token]/asset/route.js.nft.json +1 -1
  27. package/.next/standalone/.next/server/app/api/share/[token]/route.js.nft.json +1 -1
  28. package/.next/standalone/.next/server/app/api/share/route.js.nft.json +1 -1
  29. package/.next/standalone/.next/server/app/api/system/reveal/route.js.nft.json +1 -1
  30. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/branch/route.js.nft.json +1 -1
  31. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/open/route.js.nft.json +1 -1
  32. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/refresh/route.js.nft.json +1 -1
  33. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/route.js.nft.json +1 -1
  34. package/.next/standalone/.next/server/app/api/system/workspaces/route.js.nft.json +1 -1
  35. package/.next/standalone/.next/server/app/api/upload/[...path]/route.js.nft.json +1 -1
  36. package/.next/standalone/.next/server/app/api/wiki/app/route.js.nft.json +1 -1
  37. package/.next/standalone/.next/server/app/api/wiki/backlinks/route.js.nft.json +1 -1
  38. package/.next/standalone/.next/server/app/api/wiki/content/route.js.nft.json +1 -1
  39. package/.next/standalone/.next/server/app/api/wiki/download/route.js.nft.json +1 -1
  40. package/.next/standalone/.next/server/app/api/wiki/folder/route.js.nft.json +1 -1
  41. package/.next/standalone/.next/server/app/api/wiki/git-branches/route.js.nft.json +1 -1
  42. package/.next/standalone/.next/server/app/api/wiki/git-checkout/route.js.nft.json +1 -1
  43. package/.next/standalone/.next/server/app/api/wiki/git-diff/route.js.nft.json +1 -1
  44. package/.next/standalone/.next/server/app/api/wiki/git-file-info/route.js.nft.json +1 -1
  45. package/.next/standalone/.next/server/app/api/wiki/git-history/route.js.nft.json +1 -1
  46. package/.next/standalone/.next/server/app/api/wiki/git-pull/route.js.nft.json +1 -1
  47. package/.next/standalone/.next/server/app/api/wiki/move/route.js.nft.json +1 -1
  48. package/.next/standalone/.next/server/app/api/wiki/new-file/route.js.nft.json +1 -1
  49. package/.next/standalone/.next/server/app/api/wiki/outlinks/route.js.nft.json +1 -1
  50. package/.next/standalone/.next/server/app/api/wiki/page/route.js.nft.json +1 -1
  51. package/.next/standalone/.next/server/app/api/wiki/presence/route.js.nft.json +1 -1
  52. package/.next/standalone/.next/server/app/api/wiki/route.js.nft.json +1 -1
  53. package/.next/standalone/.next/server/app/api/wiki/search/route.js.nft.json +1 -1
  54. package/.next/standalone/.next/server/app/api/wiki/slugs/route.js.nft.json +1 -1
  55. package/.next/standalone/.next/server/app/api/wiki/upload/route.js.nft.json +1 -1
  56. package/.next/standalone/.next/server/app/api/wiki/watch/route.js.nft.json +1 -1
  57. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  58. package/.next/standalone/.next/server/app/s/[token]/page_client-reference-manifest.js +1 -1
  59. package/.next/standalone/.next/server/app/signin/page_client-reference-manifest.js +1 -1
  60. package/.next/standalone/.next/server/chunks/ssr/_0oq8kwv._.js +4 -4
  61. package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
  62. package/.next/standalone/.next/server/pages/500.html +1 -1
  63. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  64. package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
  65. package/.next/standalone/.next/static/chunks/{16a.4k1u_jc2v.js → 0aztrjhb3uvoc.js} +4 -4
  66. package/.next/standalone/.next/static/chunks/{064kw6cpi-47..css → 0x_d6f24.04y4.css} +1 -1
  67. package/.next/standalone/.next/static/chunks/{06l3_t96g__d2.css → 138ap~9f.rqkh.css} +2 -2
  68. package/.next/standalone/package.json +1 -1
  69. package/.next/standalone/server.js +1 -1
  70. package/package.json +1 -1
  71. /package/.next/standalone/.next/static/{vlPEhXvukCQTNa1mne8yh → 5RQtk5maHbNoLCrZTBeMo}/_buildManifest.js +0 -0
  72. /package/.next/standalone/.next/static/{vlPEhXvukCQTNa1mne8yh → 5RQtk5maHbNoLCrZTBeMo}/_clientMiddlewareManifest.js +0 -0
  73. /package/.next/standalone/.next/static/{vlPEhXvukCQTNa1mne8yh → 5RQtk5maHbNoLCrZTBeMo}/_ssgManifest.js +0 -0
@@ -18,7 +18,7 @@ TOKEN=<paste token here>
18
18
  # 3. Read snapshot
19
19
  curl -s -H "Authorization: Bearer $TOKEN" \\
20
20
  -H "X-Agent-Id: ai:claude" \\
21
- ${b}/api/agent/files/${a??"<path/to/file.md>"}`;await navigator.clipboard.writeText(d),c(!0),setTimeout(()=>c(!1),1500)},[a])}}(a??null),[k,l]=(0,p.useState)(""),m=(0,p.useRef)(null),n="http://localhost:3000",q=(0,p.useCallback)(()=>b5,[]),s=(0,p.useCallback)(()=>k.replace(/\$WIKI_URL/g,n),[k,n]),t=(0,p.useCallback)(()=>`npx wiki-viewer-mcp register --url ${n} --id ai:myagent --name "My Agent"`,[n]),u=(0,p.useCallback)(()=>JSON.stringify({servers:{"wiki-viewer":{command:"npx",args:["wiki-viewer-mcp"],env:{WIKI_VIEWER_URL:n,WIKI_VIEWER_TOKEN:"<token from register>",WIKI_VIEWER_AGENT_ID:"ai:myagent"}}}},null,2),[n]),w=b6(q),x=b6(s),y=b6(t),z=b6(u);return((0,p.useEffect)(()=>{if(b)return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a);function a(a){"Escape"===a.key&&c()}},[b,c]),(0,p.useEffect)(()=>{b&&m.current?.focus()},[b]),(0,p.useEffect)(()=>{if(!b)return;f();let a=setInterval(()=>void f(),1e4);return()=>clearInterval(a)},[b,f]),(0,p.useEffect)(()=>{b&&fetch((0,av.apiUrl)("/api/agents/install")).then(a=>a.json()).then(a=>{a.bootstrapPrompt&&l(a.bootstrapPrompt)}).catch(()=>void 0)},[b]),b)?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px]",onClick:c,"aria-hidden":!0}),(0,g.jsxs)("aside",{ref:m,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":"AI Agent Panel",className:"fixed right-0 top-0 bottom-0 z-50 flex w-[90vw] max-w-sm md:w-80 flex-col border-l border-border bg-background shadow-xl outline-none",children:[(0,g.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsx)(i,{className:"h-4 w-4 text-muted-foreground"}),(0,g.jsx)("span",{className:"text-sm font-semibold",children:"AI Agent"})]}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:c,title:"Close panel (Esc)",children:(0,g.jsx)(o,{className:"h-3.5 w-3.5"})})]}),(0,g.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-5 px-4 py-4",children:[(0,g.jsxs)("section",{className:"rounded-md border border-border bg-muted/30 p-3",children:[(0,g.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Work with this wiki using AI"}),(0,g.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:["Connect Claude, Cursor, ChatGPT, and more. Pick by what you want — each option gives a copy-paste setup. You approve every assistant in ",(0,g.jsx)("span",{className:"font-medium text-foreground/80",children:"Agents"})," below before it gets access."]})]}),(0,g.jsxs)("section",{className:"space-y-3",children:[(0,g.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,g.jsx)("p",{className:"text-xs font-semibold text-foreground",children:"Co-write docs with you"}),(0,g.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Edits arrive as suggestions with comments you accept or revert. No MCP needed."}),(0,g.jsx)(v.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void x.copy(),disabled:!k,children:x.copied?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(bd.Copy,{className:"h-3.5 w-3.5"})," Paste into any chatbot"]})}),(0,g.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 pt-1",children:["Or install once so it sticks"," ",(0,g.jsx)("span",{className:"text-muted-foreground/40",children:"· Claude, OpenCode"}),":"]}),(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:b5}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void w.copy(),children:w.copied?(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,g.jsx)(bd.Copy,{className:"h-3.5 w-3.5"})})]})]}),(0,g.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,g.jsxs)("p",{className:"text-xs font-semibold text-foreground",children:["Edit files directly"," ",(0,g.jsx)("span",{className:"font-normal text-muted-foreground/60",children:"· Claude Code, Cursor, Codex"})]}),(0,g.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Native read / search / edit tools over MCP. Run to request access:"}),(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:t()}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void y.copy(),children:y.copied?(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,g.jsx)(bd.Copy,{className:"h-3.5 w-3.5"})})]}),(0,g.jsxs)("p",{className:"text-[10px] text-muted-foreground/50",children:["Approve in ",(0,g.jsx)("span",{className:"font-medium text-foreground/70",children:"Agents"}),", then add to your tool:"]}),(0,g.jsx)(v.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void z.copy(),children:z.copied?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(bd.Copy,{className:"h-3.5 w-3.5"})," Copy config (mcp.json)"]})})]}),(0,g.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,g.jsx)("span",{className:"text-[10px] text-muted-foreground/50",children:"For developers:"}),(0,g.jsxs)("button",{type:"button",onClick:()=>void j(),className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[h?(0,g.jsx)(r.Check,{className:"h-3 w-3 text-green-500"}):(0,g.jsx)(bd.Copy,{className:"h-3 w-3"})," curl example"]}),(0,g.jsxs)("a",{href:(0,av.apiUrl)("/api/agents/skill"),target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,g.jsx)(bE,{className:"h-3 w-3"})," skill"]}),(0,g.jsxs)("a",{href:(0,av.apiUrl)("/api/agents/install"),target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,g.jsx)(bE,{className:"h-3 w-3"})," install JSON"]})]})]}),(0,g.jsx)(bN,{}),(0,g.jsxs)("section",{className:"space-y-2",children:[(0,g.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:["Active Connections"," ",(0,g.jsx)("span",{className:"normal-case font-normal text-muted-foreground/50",children:"(last 5 min)"})]}),(0,g.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-3",children:0===e.length?(0,g.jsxs)("p",{className:"text-xs text-muted-foreground/60 flex items-center gap-1.5",children:[(0,g.jsx)(bD,{className:"h-3.5 w-3.5"}),"No recent activity"]}):(0,g.jsx)("ul",{className:"space-y-1.5",children:e.map(a=>(0,g.jsxs)("li",{className:"flex items-center justify-between text-xs",children:[(0,g.jsx)("span",{className:"font-mono text-foreground/80 truncate",children:a.by}),(0,g.jsxs)("span",{className:"text-muted-foreground shrink-0",children:[a.opCount," op",1!==a.opCount?"s":""]})]},a.by))})})]}),(0,g.jsxs)("section",{className:"space-y-2",children:[(0,g.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Recent Activity"}),(0,g.jsx)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 max-h-72 overflow-y-auto",children:(0,g.jsx)(b4,{activity:d})})]}),(0,g.jsx)("section",{children:(0,g.jsx)("a",{href:(0,av.apiUrl)("/docs/agent-collab-plan.md"),target:"_blank",rel:"noreferrer",className:"text-xs text-primary underline hover:no-underline",children:"Agent collaboration docs →"})})]})]})]}):null}var b8=a.i(765021);let b9=(0,h.default)("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]),ca=(0,h.default)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]),cb=(0,h.default)("file",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]),cc=(0,h.default)("file-plus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]),cd=(0,h.default)("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),ce=(0,h.default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),cf=(0,h.default)("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);function cg({pos:a,branches:b,loading:c,busyName:d,disabled:e,onPick:f,onClose:h}){let[i,j]=(0,p.useState)(""),k=(0,p.useRef)(null);if((0,p.useEffect)(()=>{let a=a=>{let b=a.target;k.current?.contains(b)||b?.closest?.("[data-branch-trigger]")||h()},b=a=>{"Escape"===a.key&&h()};return document.addEventListener("mousedown",a),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",b)}},[h]),"u"<typeof document)return null;let l=b.length>8,n=i.trim().toLowerCase(),o=n?b.filter(a=>a.name.toLowerCase().includes(n)):b;return(0,bu.createPortal)((0,g.jsx)("div",{ref:k,"data-branch-portal":!0,style:{position:"fixed",top:a.top,left:a.left},className:"pointer-events-auto z-[9999] flex max-h-72 w-52 flex-col overflow-hidden rounded-md border bg-popover p-1 shadow-md",children:c?(0,g.jsx)("div",{className:"flex justify-center py-2",children:(0,g.jsx)(m.Loader2,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"})}):0===b.length?(0,g.jsx)("p",{className:"px-2 py-1 text-[10px] text-muted-foreground",children:"No branches"}):(0,g.jsxs)(g.Fragment,{children:[l&&(0,g.jsx)("input",{autoFocus:!0,value:i,onChange:a=>j(a.target.value),placeholder:"Filter branches…",className:"mb-1 w-full shrink-0 rounded border bg-background px-1.5 py-1 text-[11px] outline-none focus:ring-1 focus:ring-ring"}),(0,g.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:0===o.length?(0,g.jsx)("p",{className:"px-2 py-1 text-[10px] text-muted-foreground",children:"No match"}):o.map(a=>(0,g.jsxs)("button",{type:"button",disabled:e||a.current,className:(0,ao.cn)("flex w-full items-center gap-1.5 rounded px-2 py-1 text-left text-[11px] hover:bg-muted",a.current?"font-semibold text-foreground":"text-muted-foreground"),onClick:b=>{b.stopPropagation(),a.current||f(a.name)},children:[a.current?(0,g.jsx)(r.Check,{className:"h-3 w-3 shrink-0"}):(0,g.jsx)("span",{className:"w-3 shrink-0"}),(0,g.jsx)("span",{className:"truncate",children:a.name}),d===a.name&&(0,g.jsx)(m.Loader2,{className:"ml-auto h-3 w-3 shrink-0 animate-spin"})]},a.name))})]})}),document.body)}var ch=a.i(280370),ci=a.i(385909),cj="ContextMenu",[ck,cl]=(0,y.createContextScope)(cj,[ch.createMenuScope]),cm=(0,ch.createMenuScope)(),[cn,co]=ck(cj),cp=a=>{let{__scopeContextMenu:b,children:c,onOpenChange:d,dir:e,modal:f=!0}=a,[h,i]=p.useState(!1),j=cm(b),k=(0,ci.useCallbackRef)(d),l=p.useCallback(a=>{i(a),k(a)},[k]);return(0,g.jsx)(cn,{scope:b,open:h,onOpenChange:l,modal:f,children:(0,g.jsx)(ch.Root,{...j,dir:e,open:h,onOpenChange:l,modal:f,children:c})})};cp.displayName=cj;var cq="ContextMenuTrigger",cr=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,disabled:d=!1,...e}=a,f=co(cq,c),h=cm(c),i=p.useRef({x:0,y:0}),j=p.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...i.current})}),k=p.useRef(0),l=p.useCallback(()=>window.clearTimeout(k.current),[]),m=a=>{i.current={x:a.clientX,y:a.clientY},f.onOpenChange(!0)};return p.useEffect(()=>l,[l]),p.useEffect(()=>void(d&&l()),[d,l]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ch.Anchor,{...h,virtualRef:j}),(0,g.jsx)(F.Primitive.span,{"data-state":f.open?"open":"closed","data-disabled":d?"":void 0,...e,ref:b,style:{WebkitTouchCallout:"none",...a.style},onContextMenu:d?a.onContextMenu:(0,w.composeEventHandlers)(a.onContextMenu,a=>{l(),m(a),a.preventDefault()}),onPointerDown:d?a.onPointerDown:(0,w.composeEventHandlers)(a.onPointerDown,cD(a=>{l(),k.current=window.setTimeout(()=>m(a),700)})),onPointerMove:d?a.onPointerMove:(0,w.composeEventHandlers)(a.onPointerMove,cD(l)),onPointerCancel:d?a.onPointerCancel:(0,w.composeEventHandlers)(a.onPointerCancel,cD(l)),onPointerUp:d?a.onPointerUp:(0,w.composeEventHandlers)(a.onPointerUp,cD(l))})]})});cr.displayName=cq;var cs=a=>{let{__scopeContextMenu:b,...c}=a,d=cm(b);return(0,g.jsx)(ch.Portal,{...d,...c})};cs.displayName="ContextMenuPortal";var ct="ContextMenuContent",cu=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=co(ct,c),f=cm(c),h=p.useRef(!1);return(0,g.jsx)(ch.Content,{...f,...d,ref:b,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:b=>{a.onCloseAutoFocus?.(b),!b.defaultPrevented&&h.current&&b.preventDefault(),h.current=!1},onInteractOutside:b=>{a.onInteractOutside?.(b),b.defaultPrevented||e.modal||(h.current=!0)},style:{...a.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});cu.displayName=ct,p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.Group,{...e,...d,ref:b})}).displayName="ContextMenuGroup";var cv=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.Label,{...e,...d,ref:b})});cv.displayName="ContextMenuLabel";var cw=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.Item,{...e,...d,ref:b})});cw.displayName="ContextMenuItem";var cx=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.CheckboxItem,{...e,...d,ref:b})});cx.displayName="ContextMenuCheckboxItem",p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.RadioGroup,{...e,...d,ref:b})}).displayName="ContextMenuRadioGroup";var cy=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.RadioItem,{...e,...d,ref:b})});cy.displayName="ContextMenuRadioItem";var cz=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.ItemIndicator,{...e,...d,ref:b})});cz.displayName="ContextMenuItemIndicator";var cA=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.Separator,{...e,...d,ref:b})});cA.displayName="ContextMenuSeparator",p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.Arrow,{...e,...d,ref:b})}).displayName="ContextMenuArrow";var cB=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.SubTrigger,{...e,...d,ref:b})});cB.displayName="ContextMenuSubTrigger";var cC=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.SubContent,{...e,...d,ref:b,style:{...a.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});function cD(a){return b=>"mouse"!==b.pointerType?a(b):void 0}cC.displayName="ContextMenuSubContent";var cE=a.i(694079);p.forwardRef(({className:a,inset:b,children:c,...d},e)=>(0,g.jsxs)(cB,{ref:e,className:(0,ao.cn)("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",b&&"pl-8",a),...d,children:[c,(0,g.jsx)(a3.ChevronRight,{className:"ml-auto h-4 w-4"})]})).displayName=cB.displayName,p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(cC,{ref:c,className:(0,ao.cn)("z-50 min-w-[8rem] overflow-hidden rounded-sm border bg-popover p-1 text-popover-foreground shadow-golden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...b})).displayName=cC.displayName;let cF=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(cs,{children:(0,g.jsx)(cu,{ref:c,className:(0,ao.cn)("z-50 min-w-[8rem] overflow-hidden rounded-sm border bg-popover p-1 text-popover-foreground shadow-golden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...b})}));cF.displayName=cu.displayName;let cG=p.forwardRef(({className:a,inset:b,...c},d)=>(0,g.jsx)(cw,{ref:d,className:(0,ao.cn)("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",b&&"pl-8",a),...c}));cG.displayName=cw.displayName,p.forwardRef(({className:a,children:b,checked:c,...d},e)=>(0,g.jsxs)(cx,{ref:e,className:(0,ao.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),checked:c,...d,children:[(0,g.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,g.jsx)(cz,{children:(0,g.jsx)(r.Check,{className:"h-4 w-4"})})}),b]})).displayName=cx.displayName,p.forwardRef(({className:a,children:b,...c},d)=>(0,g.jsxs)(cy,{ref:d,className:(0,ao.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...c,children:[(0,g.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,g.jsx)(cz,{children:(0,g.jsx)(cE.Circle,{className:"h-2 w-2 fill-current"})})}),b]})).displayName=cy.displayName,p.forwardRef(({className:a,inset:b,...c},d)=>(0,g.jsx)(cv,{ref:d,className:(0,ao.cn)("px-2 py-1.5 text-sm font-normal",b&&"pl-8",a),...c})).displayName=cv.displayName;let cH=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(cA,{ref:c,className:(0,ao.cn)("-mx-1 my-1 h-px bg-muted",a),...b}));cH.displayName=cA.displayName;let cI=(0,ay.create)((a,b)=>({humanize:!1,toggle:()=>{a({humanize:!b().humanize})}})),cJ=(0,ay.create)((a,b)=>({showHidden:!1,toggle:()=>{a({showHidden:!b().showHidden})}}));function cK(a){return a.split(".").pop()?.toLowerCase()??""}function cL(a,b){if("node-app"===b)return"node-app";if("app"===b)return"app";if("dir"===b)return"fallback";let c=a.split("/").pop()??a;if(c.startsWith(".")&&-1===c.indexOf(".",1))return"source";let d=cK(a);return d?["md","markdown"].includes(d)?"editor":"txt"===d?"text":["csv","tsv"].includes(d)?"csv":"pdf"===d?"pdf":["mmd","mermaid"].includes(d)?"mermaid":"ipynb"===d?"notebook":["png","jpg","jpeg","gif","webp","svg","avif","ico","bmp"].includes(d)?"image":["mp4","webm","mov","m4v","mp3","wav","ogg","m4a","aac"].includes(d)?"media":"docx"===d?"docx":["xlsx","xlsm"].includes(d)?"xlsx":"pptx"===d?"pptx":"html"===d?"html":(["py","js","ts","tsx","jsx","go","rs","java","c","cpp","h","sh","bash","zsh","rb","php","swift","kt","lua","sql","yaml","yml","toml","json","xml","css","scss"].includes(d),"source"):"source"}let cM=new Set(["txt","md","markdown","json","yaml","yml","toml","csv","tsv","xml","html","css","js","ts","tsx","jsx","sh","bash","zsh","rb","py","go","rs","java","c","cpp","h","php","swift","kt","lua","sql","scss","mmd","mermaid","ini","env","log","conf"]);function cN(a){let b=cL(a,"file");return"editor"===b||"text"===b||cM.has(cK(a))}function cO(a){return["md","markdown"].includes(cK(a))}function cP(a){return"image"===cL(a,"file")}function cQ(a){return"html"===cL(a,"file")}let cR={contentVisibility:"auto",containIntrinsicSize:"auto 32px"};function cS({node:a,ctx:b,isFavorited:c,activeWorkspaceId:d}){return(0,g.jsxs)(cF,{className:"w-48",children:[(0,g.jsxs)(cG,{onSelect:()=>b.copyPath(a.path),children:[(0,g.jsx)(bd.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),cO(a.name)&&(0,g.jsxs)(cG,{onSelect:()=>b.copyWikiLink(a.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,g.jsxs)(cG,{onSelect:()=>b.copyUrl(a.path),children:[(0,g.jsx)(b9,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===a.type&&cN(a.name)&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(cG,{onSelect:()=>b.copyRawContent(a.path),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,g.jsxs)(cG,{onSelect:()=>b.copyFormattedContent(a.path,a.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,g.jsx)(cH,{}),"dir"===a.type&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(cG,{onSelect:()=>{a.expanded||b.toggleFolder(a),b.setNewFileParent(a.path),b.setNewFileName(""),b.setFileCreateError(null)},children:[(0,g.jsx)(cc,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,g.jsxs)(cG,{onSelect:()=>b.triggerUpload(a.path),children:[(0,g.jsx)(cf,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,g.jsxs)(cG,{onSelect:()=>{b.setNewFolderParent(a.path),b.setNewFolderName(""),b.setFolderError(null)},children:[(0,g.jsx)(cd,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,g.jsx)(cH,{})]}),(0,g.jsxs)(cG,{onSelect:()=>b.handleDownload(a),children:[(0,g.jsx)(b8.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===a.type?"Download":"Download as zip"]}),(0,g.jsxs)(cG,{onSelect:()=>b.toggleFavorite(a,d),children:[(0,g.jsx)(ba,{className:(0,ao.cn)("mr-2 h-3.5 w-3.5",c&&"fill-current text-amber-400")}),c?"Remove from favorites":"Add to favorites"]}),(0,g.jsx)(cH,{}),(0,g.jsxs)(cG,{className:"text-destructive focus:text-destructive",onSelect:()=>{b.setDeletingPath(a.path),b.setDeletingIsDir("file"!==a.type)},children:[(0,g.jsx)(bf,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})}function cT({name:a,type:b}){let c="h-3.5 w-3.5 shrink-0";return"dir"===b?(0,g.jsx)(a4,{className:(0,ao.cn)(c,"text-foreground/70")}):"app"===b?(0,g.jsx)(k,{className:(0,ao.cn)(c,"text-foreground/70")}):"node-app"===b?(0,g.jsx)(ce,{className:(0,ao.cn)(c,"text-emerald-500")}):cQ(a)?(0,g.jsx)(k,{className:(0,ao.cn)(c,"text-foreground/60")}):cP(a)?(0,g.jsx)(l,{className:(0,ao.cn)(c,"text-sunshine-700")}):cN(a)?(0,g.jsx)(j.FileText,{className:(0,ao.cn)(c,"text-foreground/70")}):(0,g.jsx)(cb,{className:(0,ao.cn)(c,"text-foreground/60")})}let cU=(0,p.memo)(function({node:a,depth:b,ctx:c,isMobile:d,activeWorkspaceId:e,sidebarScrollRef:f,isActive:h,isDragOver:i,isFavorited:n,isAgentActive:o,isPulling:p,branchOpen:q,branchPos:r,branches:s,branchLoading:t,checkingOut:u,onHoverEnter:w,onHoverLeave:x}){var y;let z,A,B,C,D,E=cI(a=>a.humanize);return(0,g.jsxs)(cp,{children:[(0,g.jsx)(cr,{asChild:!0,children:(0,g.jsxs)("div",{role:"treeitem",tabIndex:0,draggable:!d,onKeyDown:d=>{if("Enter"===d.key||" "===d.key)d.preventDefault(),"dir"===a.type?c.toggleFolder(a):"app"===a.type||"node-app"===a.type?(c.openViewer(a),c.toggleFolder(a)):c.openViewer(a);else if("ArrowDown"===d.key){d.preventDefault();let a=f.current;if(!a)return;let b=Array.from(a.querySelectorAll('[role="treeitem"]')),c=b.indexOf(d.currentTarget);b[c+1]?.focus()}else if("ArrowUp"===d.key){d.preventDefault();let a=f.current;if(!a)return;let b=Array.from(a.querySelectorAll('[role="treeitem"]')),c=b.indexOf(d.currentTarget);b[c-1]?.focus()}else if("ArrowRight"===d.key){if(d.preventDefault(),"dir"===a.type||"app"===a.type||"node-app"===a.type)if(a.expanded){let a=f.current;if(!a)return;let b=Array.from(a.querySelectorAll('[role="treeitem"]')),c=b.indexOf(d.currentTarget);b[c+1]?.focus()}else c.toggleFolder(a)}else if("ArrowLeft"===d.key){if(d.preventDefault(),("dir"===a.type||"app"===a.type||"node-app"===a.type)&&a.expanded)c.toggleFolder(a);else if(b>0){let a=f.current;if(!a)return;let b=Array.from(a.querySelectorAll('[role="treeitem"]')),c=d.currentTarget,e=b.indexOf(c),g=Number.parseInt(c.style.paddingLeft??"0",10);for(let a=e-1;a>=0;a--)if(Number.parseInt(b[a].style.paddingLeft??"0",10)<g){b[a].focus();break}}}},onDragStart:b=>c.handleDragStart(b,a),onDragOver:b=>"dir"===a.type?c.handleDragOver(b,a.path,"dir"):b.preventDefault(),onDragLeave:()=>c.setDragOverPath(null),onDrop:b=>"dir"===a.type?c.handleDropOnFolder(b,a.path):b.preventDefault(),onMouseEnter:()=>w(a),onMouseLeave:x,className:(0,ao.cn)("tree-row-reveal flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer group transition-colors select-none touch-target",h?"bg-accent-soft text-foreground font-medium":"hover:bg-muted",i&&"ring-2 ring-primary bg-primary-soft",a.name.startsWith(".")&&"opacity-40"),style:{paddingLeft:`${14*b+8}px`,...cR},onClick:()=>{"dir"===a.type?c.toggleFolder(a):("app"===a.type||"node-app"===a.type?(c.openViewer(a),c.toggleFolder(a)):c.openViewer(a),d&&c.setSidebarCollapsed(!0))},children:["dir"===a.type||"app"===a.type||"node-app"===a.type?a.loading?(0,g.jsx)(m.Loader2,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}):(0,g.jsx)(a3.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform duration-200 ease-out",style:{transform:a.expanded?"rotate(90deg)":"rotate(0deg)"}}):(0,g.jsx)("span",{className:"w-3.5 shrink-0"}),(0,g.jsx)("span",{className:"",children:"dir"===a.type?a.expanded?(0,g.jsx)(a5,{className:(0,ao.cn)("h-4 w-4 shrink-0",!h&&"text-foreground/70")}):(0,g.jsx)(a4,{className:(0,ao.cn)("h-4 w-4 shrink-0",!h&&"text-foreground/70")}):"app"===a.type?(0,g.jsx)(k,{className:(0,ao.cn)("h-4 w-4 shrink-0",!h&&"text-foreground/70")}):"node-app"===a.type?(0,g.jsx)(ce,{className:(0,ao.cn)("h-4 w-4 shrink-0",!h&&"text-emerald-500")}):cQ(a.name)?(0,g.jsx)(k,{className:(0,ao.cn)("h-4 w-4 shrink-0",!h&&"text-foreground/60")}):cP(a.name)?(0,g.jsx)(l,{className:(0,ao.cn)("h-4 w-4 shrink-0",!h&&"text-sunshine-700")}):cN(a.name)?(0,g.jsx)(j.FileText,{className:(0,ao.cn)("h-4 w-4 shrink-0",!h&&"text-foreground/70")}):(0,g.jsx)(cb,{className:(0,ao.cn)("h-4 w-4 shrink-0",!h&&"text-foreground/60")})}),(0,g.jsx)("span",{className:"min-w-0 flex-1 truncate",title:E?a.name:void 0,children:E?(B=(A=(z=(y=a.name).lastIndexOf("."))>0&&z<y.length-1)?y.slice(0,z):y,C=A?y.slice(z):"",(D=B.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[\s_-]+/).filter(Boolean).map(a=>/^[A-Z0-9]+$/.test(a)?a:a[0].toUpperCase()+a.slice(1))).length?D.join(" ")+C:y):a.name}),a.git&&(0,g.jsxs)("span",{className:"relative flex shrink-0 items-center gap-0.5 rounded-sm bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:[(0,g.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"flex items-center gap-0.5 hover:text-foreground",title:"Switch branch",onClick:b=>{if(b.stopPropagation(),q){c.setBranchDropdownNode(null),c.setBranchDropdownPos(null);return}let d=b.currentTarget.getBoundingClientRect();c.setBranchDropdownPos({top:d.bottom+4,left:d.left}),c.setBranchDropdownNode(a.path),c.loadBranches(a.path)},children:[(0,g.jsx)(a6,{className:"h-2.5 w-2.5"}),a.git.branch,a.git.dirty&&(0,g.jsx)("span",{className:"ml-0.5 text-foreground/70",children:"*"})]}),p?(0,g.jsx)(m.Loader2,{className:"ml-0.5 h-2.5 w-2.5 animate-spin"}):(0,g.jsx)("button",{type:"button",onClick:b=>{b.stopPropagation();let d=a.path.includes("/")?a.path.substring(0,a.path.lastIndexOf("/")):"";c.handleGitPull(a.path,d)},className:"ml-0.5 text-muted-foreground hover:text-foreground",title:"Pull latest",children:(0,g.jsx)(bI,{className:"h-2.5 w-2.5"})}),q&&r&&(0,g.jsx)(cg,{pos:r,branches:s,loading:t,busyName:u,disabled:null!==u,onPick:b=>{let d=a.path.includes("/")?a.path.substring(0,a.path.lastIndexOf("/")):"";c.handleCheckout(a.path,b,d)},onClose:()=>{c.setBranchDropdownNode(null),c.setBranchDropdownPos(null)}})]}),o&&(0,g.jsx)("span",{className:"ml-0.5 h-1.5 w-1.5 rounded-full bg-emerald-400 shrink-0 animate-pulse",title:"Agent recently active"}),(0,g.jsx)("div",{className:"hover-reveal flex max-w-0 shrink-0 items-center overflow-hidden opacity-0 transition-all duration-150 group-hover:max-w-7 group-hover:opacity-100 focus-within:max-w-7 focus-within:opacity-100",onClick:a=>a.stopPropagation(),onKeyDown:a=>a.stopPropagation(),children:(0,g.jsxs)(ax.DropdownMenu,{children:[(0,g.jsx)(ax.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",title:"File actions",children:(0,g.jsx)(ca,{className:"h-3.5 w-3.5"})})}),(0,g.jsxs)(ax.DropdownMenuContent,{align:"end",className:"w-48",children:[(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>c.copyPath(a.path),children:[(0,g.jsx)(bd.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),cO(a.name)&&(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>c.copyWikiLink(a.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>c.copyUrl(a.path),children:[(0,g.jsx)(b9,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===a.type&&cN(a.name)&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>c.copyRawContent(a.path),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>c.copyFormattedContent(a.path,a.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,g.jsx)(ax.DropdownMenuSeparator,{}),"dir"===a.type&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ax.DropdownMenuItem,{onClick:async()=>{a.expanded||c.toggleFolder(a),c.setNewFileParent(a.path),c.setNewFileName(""),c.setFileCreateError(null)},children:[(0,g.jsx)(cc,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>c.triggerUpload(a.path),children:[(0,g.jsx)(cf,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>{c.setNewFolderParent(a.path),c.setNewFolderName(""),c.setFolderError(null)},children:[(0,g.jsx)(cd,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,g.jsx)(ax.DropdownMenuSeparator,{})]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>c.handleDownload(a),children:[(0,g.jsx)(b8.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===a.type?"Download":"Download as zip"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>c.toggleFavorite(a,e),children:[(0,g.jsx)(ba,{className:(0,ao.cn)("mr-2 h-3.5 w-3.5",n&&"fill-current text-amber-400")}),n?"Remove from favorites":"Add to favorites"]}),(0,g.jsx)(ax.DropdownMenuSeparator,{}),(0,g.jsxs)(ax.DropdownMenuItem,{className:"text-destructive focus:text-destructive",onClick:()=>{c.setDeletingPath(a.path),c.setDeletingIsDir("file"!==a.type)},children:[(0,g.jsx)(bf,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})]})})]})}),(0,g.jsx)(cS,{node:a,ctx:c,isFavorited:n,activeWorkspaceId:e})]})}),cV=(0,p.memo)(function(a){let{ctx:b,openPath:c,dragOverPath:d,branchDropdownNode:e,branchDropdownPos:f,nodeBranches:h,branchesLoading:i,checkingOutBranch:k,pullingRepo:l,activePaths:m,favorites:n,isMobile:q,activeWorkspaceId:s,newFileParent:t,newFileName:u,fileCreateError:w,newFolderParent:x,newFolderName:y,folderError:z,sidebarScrollRef:A}=a,B=cJ(a=>a.showHidden),C=(0,p.useRef)(null),D=(0,p.useCallback)(a=>{let c=("dir"===a.type||"app"===a.type||"node-app"===a.type)&&!a.expanded&&void 0===a.children;("file"===a.type||c)&&(C.current&&clearTimeout(C.current),C.current=setTimeout(()=>b.prefetch(a),120))},[b]),E=(0,p.useCallback)(()=>{C.current&&(clearTimeout(C.current),C.current=null)},[]),F=(0,p.useMemo)(()=>{let b=[],c=(a,d)=>{for(let e of a)!(!B&&e.name.startsWith("."))&&(b.push({kind:"row",node:e,depth:d}),"dir"===e.type&&(x===e.path&&b.push({kind:"newfolder",node:e,depth:d}),t===e.path&&b.push({kind:"newfile",node:e,depth:d})),("dir"===e.type||"app"===e.type||"node-app"===e.type)&&e.expanded&&(e.children&&e.children.length>0?c(e.children,d+1):e.children?.length===0&&b.push({kind:"empty",node:e,depth:d})))};return c(a.nodes,0),b},[a.nodes,t,x,B]);return(0,g.jsx)(g.Fragment,{children:F.map(a=>{let{node:p,depth:t}=a;if("row"===a.kind){let a=e===p.path;return(0,g.jsx)(cU,{node:p,depth:t,ctx:b,isMobile:q,activeWorkspaceId:s,sidebarScrollRef:A,isActive:c===p.path,isDragOver:d===p.path,isFavorited:n.some(a=>a.path===p.path),isAgentActive:m.has(p.path),isPulling:l===p.path,branchOpen:a,branchPos:a?f:null,branches:p.git?h[p.path]??[]:[],branchLoading:!!p.git&&!!i[p.path],checkingOut:a?k:null,onHoverEnter:D,onHoverLeave:E},p.path)}return"newfolder"===a.kind?(0,g.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(t+1)*14+8}px`,...cR},children:[(0,g.jsx)("span",{className:"w-3.5 shrink-0"}),(0,g.jsx)(a4,{className:"h-4 w-4 shrink-0 text-foreground/70"}),(0,g.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:y,onChange:a=>b.setNewFolderName(a.target.value),onKeyDown:a=>{"Enter"===a.key&&b.handleCreateFolder(),"Escape"===a.key&&(b.setNewFolderParent(null),b.setNewFolderName(""))}}),z&&(0,g.jsx)("span",{className:"text-xs text-destructive",children:z}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:b.handleCreateFolder,children:(0,g.jsx)(r.Check,{className:"h-3 w-3"})}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{b.setNewFolderParent(null),b.setNewFolderName("")},children:(0,g.jsx)(o,{className:"h-3 w-3"})})]},`nf-${p.path}`):"newfile"===a.kind?(0,g.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(t+1)*14+8}px`,...cR},children:[(0,g.jsx)("span",{className:"w-3.5 shrink-0"}),(0,g.jsx)(j.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,g.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:u,onChange:a=>b.setNewFileName(a.target.value),onKeyDown:a=>{"Enter"===a.key&&b.handleCreateFile(),"Escape"===a.key&&(b.setNewFileParent(null),b.setNewFileName(""))}}),w&&(0,g.jsx)("span",{className:"text-xs text-destructive",children:w}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:b.handleCreateFile,children:(0,g.jsx)(r.Check,{className:"h-3 w-3"})}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{b.setNewFileParent(null),b.setNewFileName("")},children:(0,g.jsx)(o,{className:"h-3 w-3"})})]},`ff-${p.path}`):(0,g.jsx)("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:`${(t+1)*14+8+14+6+16+6}px`,...cR},children:"Empty"},`empty-${p.path}`)})})}),cW=(0,ay.create)((a,b)=>({favorites:[],loadForWorkspace:b=>{a({favorites:[]})},toggle:(b,c)=>{let d=[];a({favorites:d.some(a=>a.path===b.path)?d.filter(a=>a.path!==b.path):[...d,b]})},isFavorited:a=>b().favorites.some(b=>b.path===a)}));function cX({doc:a,node:b,extraItems:c,activeWorkspaceId:d=null}){let e=cW(a=>a.isFavorited(b.path));return(0,g.jsxs)(ax.DropdownMenu,{children:[(0,g.jsx)(ax.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"File actions",children:(0,g.jsx)(ca,{className:"h-3.5 w-3.5"})})}),(0,g.jsxs)(ax.DropdownMenuContent,{align:"end",className:"w-52",children:[(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>{let a=(0,bB.withWs)(`/api/wiki/download?path=${encodeURIComponent(b.path)}`),c=document.createElement("a");c.href=a,c.download=b.name,document.body.appendChild(c),c.click(),c.remove()},children:[(0,g.jsx)(b8.Download,{className:"mr-2 h-3.5 w-3.5"}),"Download"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>{cW.getState().toggle({path:b.path,name:b.name},d)},children:[(0,g.jsx)(ba,{className:(0,ao.cn)("mr-2 h-3.5 w-3.5",e&&"fill-current text-amber-400")}),e?"Remove from favorites":"Add to favorites"]}),(0,g.jsx)(ax.DropdownMenuSeparator,{}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>a.copyPath(b.path),children:[(0,g.jsx)(bd.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),cO(b.name)&&(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>a.copyWikiLink(b.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,g.jsx)(ax.DropdownMenuSeparator,{}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>a.copyUrl(b.path),children:[(0,g.jsx)(b9,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),cN(b.name)&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ax.DropdownMenuSeparator,{}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>void a.copyRawContent(b.path),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>void a.copyFormattedContent(b.path,b.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),c&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ax.DropdownMenuSeparator,{}),c]})]})]})}let cY=(0,h.default)("align-center",[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);var cZ=a.i(796873);let c$=(0,h.default)("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);var c_=a.i(453590),c0=a.i(111939),c1=/[\\\/_+.#"@\[\(\{&]/,c2=/[\\\/_+.#"@\[\(\{&]/g,c3=/[\s-]/,c4=/[\s-]/g;function c5(a){return a.toLowerCase().replace(c4," ")}var c6='[cmdk-group=""]',c7='[cmdk-group-items=""]',c8='[cmdk-item=""]',c9=`${c8}:not([aria-disabled="true"])`,da="cmdk-item-select",db="data-value",dc=(a,b,c)=>{var d;return d=a,function a(b,c,d,e,f,g,h){if(g===c.length)return f===b.length?1:.99;var i=`${f},${g}`;if(void 0!==h[i])return h[i];for(var j,k,l,m,n=e.charAt(g),o=d.indexOf(n,f),p=0;o>=0;)(j=a(b,c,d,e,o+1,g+1,h))>p&&(o===f?j*=1:c1.test(b.charAt(o-1))?(j*=.8,(l=b.slice(f,o-1).match(c2))&&f>0&&(j*=Math.pow(.999,l.length))):c3.test(b.charAt(o-1))?(j*=.9,(m=b.slice(f,o-1).match(c4))&&f>0&&(j*=Math.pow(.999,m.length))):(j*=.17,f>0&&(j*=Math.pow(.999,o-f))),b.charAt(o)!==c.charAt(g)&&(j*=.9999)),(j<.1&&d.charAt(o-1)===e.charAt(g+1)||e.charAt(g+1)===e.charAt(g)&&d.charAt(o-1)!==e.charAt(g))&&.1*(k=a(b,c,d,e,o+1,g+2,h))>j&&(j=.1*k),j>p&&(p=j),o=d.indexOf(n,o+1);return h[i]=p,p}(d=c&&c.length>0?`${d+" "+c.join(" ")}`:d,b,c5(d),c5(b),0,0,{})},dd=p.createContext(void 0),de=p.createContext(void 0),df=p.createContext(void 0),dg=p.forwardRef((a,b)=>{let c=dr(()=>{var b,c;return{search:"",value:null!=(c=null!=(b=a.value)?b:a.defaultValue)?c:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),d=dr(()=>new Set),e=dr(()=>new Map),f=dr(()=>new Map),g=dr(()=>new Set),h=dp(a),{label:i,children:j,value:k,onValueChange:l,filter:m,shouldFilter:n,loop:o,disablePointerSelection:q=!1,vimBindings:r=!0,...s}=a,t=(0,z.useId)(),u=(0,z.useId)(),v=(0,z.useId)(),w=p.useRef(null),x=du();dq(()=>{if(void 0!==k){let a=k.trim();c.current.value=a,y.emit()}},[k]),dq(()=>{x(6,F)},[]);let y=p.useMemo(()=>({subscribe:a=>(g.current.add(a),()=>g.current.delete(a)),snapshot:()=>c.current,setState:(a,b,d)=>{var e,f,g,i;if(!Object.is(c.current[a],b)){if(c.current[a]=b,"search"===a)E(),C(),x(1,D);else if("value"===a){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let a=document.getElementById(v);a?a.focus():null==(e=document.getElementById(t))||e.focus()}if(x(7,()=>{var a;c.current.selectedItemId=null==(a=G())?void 0:a.id,y.emit()}),d||x(5,F),(null==(f=h.current)?void 0:f.value)!==void 0){null==(i=(g=h.current).onValueChange)||i.call(g,null!=b?b:"");return}}y.emit()}},emit:()=>{g.current.forEach(a=>a())}}),[]),A=p.useMemo(()=>({value:(a,b,d)=>{var e;b!==(null==(e=f.current.get(a))?void 0:e.value)&&(f.current.set(a,{value:b,keywords:d}),c.current.filtered.items.set(a,B(b,d)),x(2,()=>{C(),y.emit()}))},item:(a,b)=>(d.current.add(a),b&&(e.current.has(b)?e.current.get(b).add(a):e.current.set(b,new Set([a]))),x(3,()=>{E(),C(),c.current.value||D(),y.emit()}),()=>{f.current.delete(a),d.current.delete(a),c.current.filtered.items.delete(a);let b=G();x(4,()=>{E(),(null==b?void 0:b.getAttribute("id"))===a&&D(),y.emit()})}),group:a=>(e.current.has(a)||e.current.set(a,new Set),()=>{f.current.delete(a),e.current.delete(a)}),filter:()=>h.current.shouldFilter,label:i||a["aria-label"],getDisablePointerSelection:()=>h.current.disablePointerSelection,listId:t,inputId:v,labelId:u,listInnerRef:w}),[]);function B(a,b){var d,e;let f=null!=(e=null==(d=h.current)?void 0:d.filter)?e:dc;return a?f(a,c.current.search,b):0}function C(){if(!c.current.search||!1===h.current.shouldFilter)return;let a=c.current.filtered.items,b=[];c.current.filtered.groups.forEach(c=>{let d=e.current.get(c),f=0;d.forEach(b=>{f=Math.max(a.get(b),f)}),b.push([c,f])});let d=w.current;H().sort((b,c)=>{var d,e;let f=b.getAttribute("id"),g=c.getAttribute("id");return(null!=(d=a.get(g))?d:0)-(null!=(e=a.get(f))?e:0)}).forEach(a=>{let b=a.closest(c7);b?b.appendChild(a.parentElement===b?a:a.closest(`${c7} > *`)):d.appendChild(a.parentElement===d?a:a.closest(`${c7} > *`))}),b.sort((a,b)=>b[1]-a[1]).forEach(a=>{var b;let c=null==(b=w.current)?void 0:b.querySelector(`${c6}[${db}="${encodeURIComponent(a[0])}"]`);null==c||c.parentElement.appendChild(c)})}function D(){let a=H().find(a=>"true"!==a.getAttribute("aria-disabled")),b=null==a?void 0:a.getAttribute(db);y.setState("value",b||void 0)}function E(){var a,b,g,i;if(!c.current.search||!1===h.current.shouldFilter){c.current.filtered.count=d.current.size;return}c.current.filtered.groups=new Set;let j=0;for(let e of d.current){let d=B(null!=(b=null==(a=f.current.get(e))?void 0:a.value)?b:"",null!=(i=null==(g=f.current.get(e))?void 0:g.keywords)?i:[]);c.current.filtered.items.set(e,d),d>0&&j++}for(let[a,b]of e.current)for(let d of b)if(c.current.filtered.items.get(d)>0){c.current.filtered.groups.add(a);break}c.current.filtered.count=j}function F(){var a,b,c;let d=G();d&&((null==(a=d.parentElement)?void 0:a.firstChild)===d&&(null==(c=null==(b=d.closest(c6))?void 0:b.querySelector('[cmdk-group-heading=""]'))||c.scrollIntoView({block:"nearest"})),d.scrollIntoView({block:"nearest"}))}function G(){var a;return null==(a=w.current)?void 0:a.querySelector(`${c8}[aria-selected="true"]`)}function H(){var a;return Array.from((null==(a=w.current)?void 0:a.querySelectorAll(c9))||[])}function I(a){let b=H()[a];b&&y.setState("value",b.getAttribute(db))}function J(a){var b;let c=G(),d=H(),e=d.findIndex(a=>a===c),f=d[e+a];null!=(b=h.current)&&b.loop&&(f=e+a<0?d[d.length-1]:e+a===d.length?d[0]:d[e+a]),f&&y.setState("value",f.getAttribute(db))}function K(a){let b=G(),c=null==b?void 0:b.closest(c6),d;for(;c&&!d;)d=null==(c=a>0?function(a,b){let c=a.nextElementSibling;for(;c;){if(c.matches(b))return c;c=c.nextElementSibling}}(c,c6):function(a,b){let c=a.previousElementSibling;for(;c;){if(c.matches(b))return c;c=c.previousElementSibling}}(c,c6))?void 0:c.querySelector(c9);d?y.setState("value",d.getAttribute(db)):J(a)}let L=()=>I(H().length-1),M=a=>{a.preventDefault(),a.metaKey?L():a.altKey?K(1):J(1)},N=a=>{a.preventDefault(),a.metaKey?I(0):a.altKey?K(-1):J(-1)};return p.createElement(bw.div,{ref:b,tabIndex:-1,...s,"cmdk-root":"",onKeyDown:a=>{var b;null==(b=s.onKeyDown)||b.call(s,a);let c=a.nativeEvent.isComposing||229===a.keyCode;if(!(a.defaultPrevented||c))switch(a.key){case"n":case"j":r&&a.ctrlKey&&M(a);break;case"ArrowDown":M(a);break;case"p":case"k":r&&a.ctrlKey&&N(a);break;case"ArrowUp":N(a);break;case"Home":a.preventDefault(),I(0);break;case"End":a.preventDefault(),L();break;case"Enter":{a.preventDefault();let b=G();if(b){let a=new Event(da);b.dispatchEvent(a)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:dw},i),dv(a,a=>p.createElement(de.Provider,{value:y},p.createElement(dd.Provider,{value:A},a))))}),dh=p.forwardRef((a,b)=>{var c,d;let e=(0,z.useId)(),f=p.useRef(null),g=p.useContext(df),h=p.useContext(dd),i=dp(a),j=null!=(d=null==(c=i.current)?void 0:c.forceMount)?d:null==g?void 0:g.forceMount;dq(()=>{if(!j)return h.item(e,null==g?void 0:g.id)},[j]);let k=dt(e,f,[a.value,a.children,f],a.keywords),l=p.useContext(de),m=ds(a=>a.value&&a.value===k.current),n=ds(a=>!!j||!1===h.filter()||!a.search||a.filtered.items.get(e)>0);function o(){var a,b;q(),null==(b=(a=i.current).onSelect)||b.call(a,k.current)}function q(){l.setState("value",k.current,!0)}if(p.useEffect(()=>{let b=f.current;if(!(!b||a.disabled))return b.addEventListener(da,o),()=>b.removeEventListener(da,o)},[n,a.onSelect,a.disabled]),!n)return null;let{disabled:r,value:s,onSelect:t,forceMount:u,keywords:v,...w}=a;return p.createElement(bw.div,{ref:(0,x.composeRefs)(f,b),...w,id:e,"cmdk-item":"",role:"option","aria-disabled":!!r,"aria-selected":!!m,"data-disabled":!!r,"data-selected":!!m,onPointerMove:r||h.getDisablePointerSelection()?void 0:q,onClick:r?void 0:o},a.children)}),di=p.forwardRef((a,b)=>{let{heading:c,children:d,forceMount:e,...f}=a,g=(0,z.useId)(),h=p.useRef(null),i=p.useRef(null),j=(0,z.useId)(),k=p.useContext(dd),l=ds(a=>!!e||!1===k.filter()||!a.search||a.filtered.groups.has(g));dq(()=>k.group(g),[]),dt(g,h,[a.value,a.heading,i]);let m=p.useMemo(()=>({id:g,forceMount:e}),[e]);return p.createElement(bw.div,{ref:(0,x.composeRefs)(h,b),...f,"cmdk-group":"",role:"presentation",hidden:!l||void 0},c&&p.createElement("div",{ref:i,"cmdk-group-heading":"","aria-hidden":!0,id:j},c),dv(a,a=>p.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":c?j:void 0},p.createElement(df.Provider,{value:m},a))))}),dj=p.forwardRef((a,b)=>{let{alwaysRender:c,...d}=a,e=p.useRef(null),f=ds(a=>!a.search);return c||f?p.createElement(bw.div,{ref:(0,x.composeRefs)(e,b),...d,"cmdk-separator":"",role:"separator"}):null}),dk=p.forwardRef((a,b)=>{let{onValueChange:c,...d}=a,e=null!=a.value,f=p.useContext(de),g=ds(a=>a.search),h=ds(a=>a.selectedItemId),i=p.useContext(dd);return p.useEffect(()=>{null!=a.value&&f.setState("search",a.value)},[a.value]),p.createElement(bw.input,{ref:b,...d,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":i.listId,"aria-labelledby":i.labelId,"aria-activedescendant":h,id:i.inputId,type:"text",value:e?a.value:g,onChange:a=>{e||f.setState("search",a.target.value),null==c||c(a.target.value)}})}),dl=p.forwardRef((a,b)=>{let{children:c,label:d="Suggestions",...e}=a,f=p.useRef(null),g=p.useRef(null),h=ds(a=>a.selectedItemId),i=p.useContext(dd);return p.useEffect(()=>{if(g.current&&f.current){let a=g.current,b=f.current,c,d=new ResizeObserver(()=>{c=requestAnimationFrame(()=>{let c=a.offsetHeight;b.style.setProperty("--cmdk-list-height",c.toFixed(1)+"px")})});return d.observe(a),()=>{cancelAnimationFrame(c),d.unobserve(a)}}},[]),p.createElement(bw.div,{ref:(0,x.composeRefs)(f,b),...e,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":h,"aria-label":d,id:i.listId},dv(a,a=>p.createElement("div",{ref:(0,x.composeRefs)(g,i.listInnerRef),"cmdk-list-sizer":""},a)))}),dm=p.forwardRef((a,b)=>{let{open:c,onOpenChange:d,overlayClassName:e,contentClassName:f,container:g,...h}=a;return p.createElement(P,{open:c,onOpenChange:d},p.createElement(U,{container:g},p.createElement(W,{"cmdk-overlay":"",className:e}),p.createElement($,{"aria-label":a.label,"cmdk-dialog":"",className:f},p.createElement(dg,{ref:b,...h}))))}),dn=Object.assign(dg,{List:dl,Item:dh,Input:dk,Group:di,Separator:dj,Dialog:dm,Empty:p.forwardRef((a,b)=>ds(a=>0===a.filtered.count)?p.createElement(bw.div,{ref:b,...a,"cmdk-empty":"",role:"presentation"}):null),Loading:p.forwardRef((a,b)=>{let{progress:c,children:d,label:e="Loading...",...f}=a;return p.createElement(bw.div,{ref:b,...f,"cmdk-loading":"",role:"progressbar","aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,"aria-label":e},dv(a,a=>p.createElement("div",{"aria-hidden":!0},a)))})});function dp(a){let b=p.useRef(a);return dq(()=>{b.current=a}),b}var dq=p.useEffect;function dr(a){let b=p.useRef();return void 0===b.current&&(b.current=a()),b}function ds(a){let b=p.useContext(de),c=()=>a(b.snapshot());return p.useSyncExternalStore(b.subscribe,c,c)}function dt(a,b,c,d=[]){let e=p.useRef(),f=p.useContext(dd);return dq(()=>{var g;let h=(()=>{var a;for(let b of c){if("string"==typeof b)return b.trim();if("object"==typeof b&&"current"in b)return b.current?null==(a=b.current.textContent)?void 0:a.trim():e.current}})(),i=d.map(a=>a.trim());f.value(a,h,i),null==(g=b.current)||g.setAttribute(db,h),e.current=h}),e}var du=()=>{let[a,b]=p.useState(),c=dr(()=>new Map);return dq(()=>{c.current.forEach(a=>a()),c.current=new Map},[a]),(a,d)=>{c.current.set(a,d),b({})}};function dv({asChild:a,children:b},c){let d;return a&&p.isValidElement(b)?p.cloneElement("function"==typeof(d=b.type)?d(b.props):"render"in d?d.render(b.props):b,{ref:b.ref},c(b.props.children)):c(b)}var dw={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};let dx=(0,h.default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),dy=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(dn,{ref:c,className:(0,ao.cn)("flex h-full w-full flex-col overflow-hidden rounded-sm bg-popover text-popover-foreground",a),...b}));function dz({children:a,shouldFilter:b,...c}){return(0,g.jsx)(P,{...c,children:(0,g.jsxs)(aZ,{className:"overflow-hidden p-0 shadow-golden max-w-lg",children:[(0,g.jsx)(a0,{className:"sr-only",children:"Search"}),(0,g.jsx)(dy,{shouldFilter:b,className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:a})]})})}dy.displayName=dn.displayName;let dA=p.forwardRef(({className:a,...b},c)=>(0,g.jsxs)("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[(0,g.jsx)(dx,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),(0,g.jsx)(dn.Input,{ref:c,className:(0,ao.cn)("flex h-11 w-full rounded-sm bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",a),...b})]}));dA.displayName=dn.Input.displayName;let dB=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(dn.List,{ref:c,className:(0,ao.cn)("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...b}));dB.displayName=dn.List.displayName;let dC=p.forwardRef((a,b)=>(0,g.jsx)(dn.Empty,{ref:b,className:"py-6 text-center text-sm text-muted-foreground",...a}));dC.displayName=dn.Empty.displayName;let dD=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(dn.Group,{ref:c,className:(0,ao.cn)("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground",a),...b}));dD.displayName=dn.Group.displayName;let dE=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(dn.Separator,{ref:c,className:(0,ao.cn)("-mx-1 h-px bg-border",a),...b}));dE.displayName=dn.Separator.displayName;let dF=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(dn.Item,{ref:c,className:(0,ao.cn)("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",a),...b}));dF.displayName=dn.Item.displayName;let dG=null,dH=null,dI=(0,ay.create)(a=>({query:"",results:[],loading:!1,truncated:!1,open:!1,setQuery:b=>a({query:b}),setOpen:b=>a({open:b}),clear:()=>{dH&&clearTimeout(dH),dG?.abort(),a({query:"",results:[],loading:!1,truncated:!1})},search:b=>(dH&&clearTimeout(dH),b.trim())?(a({loading:!0}),new Promise(c=>{dH=setTimeout(()=>{dJ(a,b).finally(c)},150)})):(dG?.abort(),a({results:[],loading:!1,truncated:!1}),Promise.resolve())}));async function dJ(a,b){dG?.abort();let c=new AbortController;dG=c;try{let d=await (0,bB.wsFetch)("/api/wiki/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:b,limit:30}),signal:c.signal});if(!d.ok)return void a({results:[],loading:!1,truncated:!1});let e=await d.json();if(c.signal.aborted)return;a({results:e.matches??[],truncated:!!e.truncated,loading:!1})}catch(b){"AbortError"!==b.name&&a({loading:!1})}}var dK=a.i(713033);function dL({html:a}){let b=function(a){let b,c=[],d=/<mark>([\s\S]*?)<\/mark>/g,e=0;for(;null!==(b=d.exec(a));)b.index>e&&c.push({text:a.slice(e,b.index),mark:!1}),c.push({text:b[1]??"",mark:!0}),e=b.index+b[0].length;return e<a.length&&c.push({text:a.slice(e),mark:!1}),c}(a);return(0,g.jsx)(g.Fragment,{children:b.map((a,b)=>a.mark?(0,g.jsx)("mark",{className:"bg-yellow-200 dark:bg-yellow-700 rounded-[2px] px-[1px]",children:a.text},b):(0,g.jsx)("span",{children:a.text},b))})}function dM({onOpenFile:a,recents:b=[],onToggleSidebar:c=()=>void 0,onNewFile:d=()=>void 0,onCopyPath:e=()=>void 0}){let f=dI(a=>a.open),h=dI(a=>a.setOpen),j=dI(a=>a.query),k=dI(a=>a.setQuery),l=dI(a=>a.results),m=dI(a=>a.loading),n=dI(a=>a.truncated),o=dI(a=>a.search),{resolvedTheme:q,setTheme:r}=(0,c0.useTheme)(),s=bF(a=>a.toggle),t=(0,dK.useViewWidthStore)(a=>a.width),u=(0,dK.useViewWidthStore)(a=>a.cycle),v=j.trimStart(),w=""===v||v.startsWith(">"),x=""===v&&b.length>0,y=w?"":j;function z(a){a(),h(!1),k("")}(0,p.useEffect)(()=>{function a(a){(a.metaKey||a.ctrlKey)&&"k"===a.key.toLowerCase()&&(a.preventDefault(),h(!f))}return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[f,h]),(0,p.useEffect)(()=>{if(!f||w)return;let a=setTimeout(()=>{o(y)},120);return()=>clearTimeout(a)},[y,w,f,o]);let A=(dK.VIEW_WIDTH_ORDER.indexOf(t)+1)%dK.VIEW_WIDTH_ORDER.length,B=dK.VIEW_WIDTH_LABEL[dK.VIEW_WIDTH_ORDER[A]];return(0,g.jsxs)(dz,{open:f,onOpenChange:a=>{h(a),a||k("")},shouldFilter:!1,children:[(0,g.jsx)(dA,{placeholder:"Search files… ( > for actions )",value:j,onValueChange:k}),(0,g.jsxs)(dB,{children:[x&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(dD,{heading:"Recent",children:b.map(b=>(0,g.jsxs)(dF,{value:`recent:${b.path}`,onSelect:()=>{a(b.path),h(!1),k("")},children:[(0,g.jsx)(bg,{className:"mr-2 h-4 w-4"}),(0,g.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,g.jsx)("span",{className:"truncate font-medium",children:b.name}),(0,g.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:b.path})]})]},b.path))}),(0,g.jsx)(dE,{})]}),w&&(0,g.jsxs)(dD,{heading:"Actions",children:[(0,g.jsxs)(dF,{value:"toggle-dark-mode",onSelect:()=>z(()=>r("dark"===q?"light":"dark")),children:["dark"===q?(0,g.jsx)(c_.Sun,{className:"mr-2 h-4 w-4"}):(0,g.jsx)(cZ.Moon,{className:"mr-2 h-4 w-4"}),"dark"===q?"Switch to light mode":"Switch to dark mode"]}),(0,g.jsxs)(dF,{value:"toggle-ai-panel",onSelect:()=>z(s),children:[(0,g.jsx)(i,{className:"mr-2 h-4 w-4"}),"Toggle AI panel"]}),(0,g.jsxs)(dF,{value:"toggle-sidebar",onSelect:()=>z(c),children:[(0,g.jsx)(c$,{className:"mr-2 h-4 w-4"}),"Toggle sidebar"]}),(0,g.jsxs)(dF,{value:"new-file",onSelect:()=>z(d),children:[(0,g.jsx)(cc,{className:"mr-2 h-4 w-4"}),"New file"]}),(0,g.jsxs)(dF,{value:"copy-path",onSelect:()=>z(e),children:[(0,g.jsx)(bd.Copy,{className:"mr-2 h-4 w-4"}),"Copy current file path"]}),(0,g.jsxs)(dF,{value:"cycle-view-width",onSelect:()=>z(u),children:[(0,g.jsx)(cY,{className:"mr-2 h-4 w-4"}),(0,g.jsxs)("span",{children:["Change view width"," ",(0,g.jsxs)("span",{className:"text-muted-foreground",children:["(",dK.VIEW_WIDTH_LABEL[t]," → ",B,")"]})]})]})]}),!w&&(0,g.jsxs)(g.Fragment,{children:[m&&(0,g.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Searching…"}),!m&&""!==y.trim()&&0===l.length&&(0,g.jsx)(dC,{children:"No matches."}),l.length>0&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(dE,{}),(0,g.jsx)(dD,{heading:n?"Top results (refine query for more)":"Results",children:l.map(b=>(0,g.jsx)(dF,{value:b.path,onSelect:()=>{a(b.path),h(!1),k("")},children:(0,g.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,g.jsx)("span",{className:"truncate text-xs",children:b.path}),b.snippet&&(0,g.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:(0,g.jsx)(dL,{html:b.snippet})})]})},b.path))})]})]})]})]})}let dN=(0,h.default)("cloud-download",[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]]);var dO=a.i(410672);let dP=(0,h.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),dQ=(0,h.default)("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),dR=(0,h.default)("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]),dS=(0,h.default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),dT=(0,h.default)("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),dU=(0,h.default)("type",[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]]);function dV({onOpenFile:a}){let b=dI(a=>a.query),c=dI(a=>a.setQuery),d=dI(a=>a.results),e=dI(a=>a.loading),f=dI(a=>a.search),h=dI(a=>a.clear),[i,j]=(0,p.useState)(0),k=(0,p.useRef)(null);function l(b){let c=d[b];c&&(a(c.path),h())}return(0,p.useEffect)(()=>{j(0)},[d]),(0,p.useEffect)(()=>{let a=k.current?.querySelector(`[data-idx="${i}"]`);a?.scrollIntoView({block:"nearest"})},[i]),(0,g.jsxs)("div",{className:"flex flex-col gap-1 px-2 py-1.5",children:[(0,g.jsxs)("div",{className:"relative",children:[(0,g.jsx)(dx,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 opacity-50"}),(0,g.jsx)("input",{type:"text",className:"w-full rounded-sm bg-muted py-1 pl-7 pr-2 text-xs outline-none focus:ring-1 focus:ring-ring",placeholder:"Search… (⌘K)",value:b,onChange:a=>{c(a.target.value),f(a.target.value)},onKeyDown:a=>{"Escape"===a.key?h():0!==d.length&&("ArrowDown"===a.key?(a.preventDefault(),j(a=>(a+1)%d.length)):"ArrowUp"===a.key?(a.preventDefault(),j(a=>(a-1+d.length)%d.length)):"Enter"===a.key&&(a.preventDefault(),l(i)))}})]}),""!==b.trim()&&(0,g.jsxs)("div",{ref:k,className:"max-h-64 overflow-y-auto rounded-sm border bg-popover",children:[e&&(0,g.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"Searching…"}),!e&&0===d.length&&(0,g.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"No matches"}),d.map((a,b)=>(0,g.jsxs)("button",{type:"button","data-idx":b,onClick:()=>l(b),onMouseEnter:()=>j(b),className:`block w-full px-2 py-1 text-left ${b===i?"bg-accent":"hover:bg-accent"}`,children:[(0,g.jsx)("div",{className:"truncate text-xs",children:a.path}),a.snippet&&(0,g.jsx)("div",{className:"truncate text-[10px] text-muted-foreground",children:(0,g.jsx)(dL,{html:a.snippet})})]},a.path))]})]})}var dW=a.i(591119);function dX(a){let b=new Date(a).getTime();if(!Number.isFinite(b))return"";let c=Math.floor(Math.max(0,Date.now()-b)/1e3);if(c<60)return"just now";let d=Math.floor(c/60);if(d<60)return`${d}m ago`;let e=Math.floor(d/60);return e<24?`${e}h ago`:`${Math.floor(e/24)}d ago`}function dY({workspaces:a,activeWorkspaceId:b,rootPath:c,isWsAdmin:d,refreshingWsId:e,switchingBranch:f,switchingBranchName:h,wsBranches:i,branchPickerWsId:j,wsBranchPos:k,onSwitchWorkspace:l,onRefreshWorkspace:m,onPromptDeleteWorkspace:n,onAddWorkspace:o,setBranchPickerWsId:p,setWsBranchPos:q,loadWsBranches:t,handleSwitchBranch:u}){return(0,g.jsxs)("div",{className:"border-t px-2 py-2 bg-muted shrink-0",children:[(0,g.jsxs)(ax.DropdownMenu,{modal:!1,onOpenChange:a=>{a||(p(null),q(null))},children:[(0,g.jsx)(ax.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsxs)(v.Button,{size:"sm",variant:"ghost",className:"w-full h-auto justify-between gap-2 px-2 py-1.5 text-left",title:c??"",children:[(0,g.jsxs)("span",{className:"flex flex-col min-w-0",children:[(0,g.jsx)("span",{className:"truncate text-xs font-medium",children:a.find(a=>a.id===b)?.name??"Workspace"}),(0,g.jsx)("span",{className:"truncate text-[10px] text-muted-foreground",children:c??""})]}),(0,g.jsx)(s,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),(0,g.jsxs)(ax.DropdownMenuContent,{align:"start",className:"w-[var(--radix-dropdown-menu-trigger-width)]",onInteractOutside:a=>{a.target?.closest?.("[data-branch-portal]")&&a.preventDefault()},children:[a.map(a=>(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>void l(a.id),onPointerMove:a=>a.preventDefault(),onPointerLeave:a=>a.preventDefault(),className:(0,ao.cn)("gap-2",a.id===b&&"font-medium"),children:[a.id===b?(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 shrink-0"}):(0,g.jsx)("span",{className:"w-3.5 shrink-0"}),(0,g.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,g.jsxs)("span",{className:"flex items-center gap-1.5 truncate",children:[(0,g.jsx)("span",{className:"truncate",children:a.name}),a.git?d?(0,g.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0 hover:bg-accent",title:"Switch branch",disabled:f===a.id,onClick:b=>{if(b.stopPropagation(),b.preventDefault(),j===a.id){p(null),q(null);return}let c=b.currentTarget.getBoundingClientRect();q({top:c.bottom+4,left:c.left}),p(a.id),t(a.id)},children:[(0,g.jsx)(a6,{className:"h-2.5 w-2.5"})," ",a.git.branch??"branch"]}):(0,g.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,g.jsx)(a6,{className:"h-2.5 w-2.5"})," ",a.git.branch??"read-only"]}):a.ssh?(0,g.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,g.jsx)(a8,{className:"h-2.5 w-2.5"})," ",a.ssh.host]}):a.readOnly?(0,g.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,g.jsx)(a6,{className:"h-2.5 w-2.5"})," read-only"]}):null]}),(0,g.jsx)("span",{className:"truncate text-[10px] text-muted-foreground",children:a.rootDir}),a.git?.lastPulledAt&&dX(a.git.lastPulledAt)&&(0,g.jsxs)("span",{className:"text-[10px] text-muted-foreground/70",children:["synced ",dX(a.git.lastPulledAt)]})]}),d&&a.git&&(0,g.jsx)("button",{className:(0,ao.cn)("shrink-0 rounded p-0.5 hover:bg-accent transition-colors",a.git.lastError?"text-destructive":"text-muted-foreground hover:text-foreground"),title:a.git.lastError?`Last refresh failed: ${a.git.lastError}`:"Refresh",disabled:e===a.id,onClick:b=>{b.stopPropagation(),b.preventDefault(),m(a.id)},children:(0,g.jsx)(bI,{className:(0,ao.cn)("h-3.5 w-3.5",e===a.id&&"animate-spin")})}),d&&(0,g.jsx)("button",{className:"shrink-0 rounded p-0.5 text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",title:"Delete workspace (does not delete files)",onClick:b=>{b.stopPropagation(),n(a.id)},children:(0,g.jsx)(bf,{className:"h-3.5 w-3.5"})})]},a.id)),d&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ax.DropdownMenuSeparator,{}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:o,children:[(0,g.jsx)(cd,{className:"mr-2 h-3.5 w-3.5"}),"Add workspace…"]})]})]})]}),(()=>{if(!j||!k)return null;let b=a.find(a=>a.id===j);return b?(0,g.jsx)(cg,{pos:k,branches:(i[b.id]??[]).map(a=>({name:a,current:a===b.git?.branch})),loading:!i[b.id],busyName:f===b.id?h:null,disabled:f===b.id,onPick:a=>{u(b.id,a)},onClose:()=>{p(null),q(null)}}):null})()]})}let dZ=(0,ay.create)(a=>({width:288,setWidth:b=>{a({width:Number.isNaN(b)?288:Math.min(600,Math.max(200,Math.round(b)))})}}));function d$(a){return a.split("/").pop()??a}function d_({workspace:a,doc:b,fileTree:c,upload:d,isMobile:e,hideChrome:f,sidebarCollapsed:h,setSidebarCollapsed:k,sidebarResizing:l,setSidebarResizing:n,sidebarWidth:p,setSidebarWidth:t,collapsed:u,setCollapsed:w,createEntry:x,setCreateEntry:y,handleCreateFile:z,handleCreateFolder:A,dragOverPath:B,setDragOverPath:C,handleDragOver:D,handleDropOnFolder:E,sidebarScrollRef:F,treeCtx:G,favorites:H,recents:I,activePaths:J,setDialogs:K,handleRefreshWorkspace:L}){let{resolvedTheme:M,setTheme:N}=(0,c0.useTheme)(),O=cI(a=>a.humanize),P=cJ(a=>a.showHidden);return(0,g.jsxs)(g.Fragment,{children:[!f&&!h&&e&&(0,g.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px] md:hidden",onClick:()=>k(!0),"aria-hidden":!0}),!f&&!h&&(0,g.jsxs)(dW.Card,{style:e?void 0:{width:p},className:"fixed inset-y-0 left-0 z-50 w-[85vw] max-w-[20rem] md:relative md:z-auto md:w-auto md:max-w-none flex flex-col shrink-0 overflow-hidden rounded-none border-r border-l-0 border-t-0 border-b-0 bg-sidebar border-sidebar-border text-sidebar-foreground",children:[(0,g.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b bg-muted shrink-0",children:[(0,g.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",title:"Wiki Viewer v2.11.3",children:[(0,g.jsx)("img",{src:(0,av.apiUrl)("/logo.svg"),alt:"Wiki Viewer",className:"h-5 w-5 shrink-0"}),(0,g.jsx)("span",{className:"truncate text-xs font-semibold leading-5 tracking-tight translate-y-[0.5px]",children:"Wiki Viewer"})]}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 shrink-0",title:"Collapse sidebar",onClick:()=>k(!0),children:(0,g.jsx)(dR,{className:"h-3.5 w-3.5"})})]}),(0,g.jsxs)("div",{className:"flex items-center justify-between gap-1 px-3 py-1.5 border-b bg-muted/50 shrink-0",children:[(0,g.jsxs)(ax.DropdownMenu,{children:[(0,g.jsx)(ax.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsxs)(v.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1 px-2 text-xs",disabled:d.uploading,children:[d.uploading?(0,g.jsx)(m.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,g.jsx)(dS,{className:"h-3.5 w-3.5"}),"New",(0,g.jsx)(s,{className:"h-3 w-3 opacity-60"})]})}),(0,g.jsxs)(ax.DropdownMenuContent,{align:"start",className:"w-44",children:[(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>y(a=>({...a,file:{...a.file,parent:"",name:"",error:null}})),children:[(0,g.jsx)(cc,{className:"mr-2 h-3.5 w-3.5"}),"New file"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>y(a=>({...a,folder:{...a.folder,parent:"",name:"",error:null}})),children:[(0,g.jsx)(cd,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>d.triggerUpload(""),disabled:d.uploading,children:[(0,g.jsx)(cf,{className:"mr-2 h-3.5 w-3.5"}),"Upload"]})]})]}),(0,g.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh tree",onClick:()=>void c.refreshTree(),disabled:c.refreshingTree,children:c.refreshingTree?(0,g.jsx)(m.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,g.jsx)(bI,{className:"h-3.5 w-3.5"})}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"AI Agent panel",onClick:()=>{bF.getState().toggle(),e&&k(!0)},children:(0,g.jsx)(i,{className:"h-3.5 w-3.5"})}),(0,g.jsxs)(ax.DropdownMenu,{children:[(0,g.jsx)(ax.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"More actions",children:(0,g.jsx)(ca,{className:"h-3.5 w-3.5"})})}),(0,g.jsxs)(ax.DropdownMenuContent,{align:"end",className:"w-48",children:[a.isWsAdmin&&a.workspaces.find(b=>b.id===a.activeWorkspaceId)?.git&&(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>{a.activeWorkspaceId&&L(a.activeWorkspaceId)},disabled:a.refreshingWsId===a.activeWorkspaceId,children:[a.refreshingWsId===a.activeWorkspaceId?(0,g.jsx)(m.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,g.jsx)(dN,{className:"mr-2 h-3.5 w-3.5"}),"Pull latest"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>cJ.getState().toggle(),children:[P?(0,g.jsx)(dP,{className:"mr-2 h-3.5 w-3.5"}):(0,g.jsx)(dO.Eye,{className:"mr-2 h-3.5 w-3.5"}),P?"Hide hidden files":"Show hidden files"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>cI.getState().toggle(),children:[(0,g.jsx)(dU,{className:"mr-2 h-3.5 w-3.5"}),O?"Raw file names":"Humanize names"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>N("dark"===M?"light":"dark"),children:["dark"===M?(0,g.jsx)(c_.Sun,{className:"mr-2 h-3.5 w-3.5"}):(0,g.jsx)(cZ.Moon,{className:"mr-2 h-3.5 w-3.5"}),"dark"===M?"Light mode":"Dark mode"]}),(0,g.jsx)(ax.DropdownMenuSeparator,{}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>K(a=>({...a,settingsOpen:!0})),children:[(0,g.jsx)(dT,{className:"mr-2 h-3.5 w-3.5"}),"Settings"]})]})]})]})]}),d.uploadError&&(0,g.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0",children:[(0,g.jsx)(q.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),d.uploadError]}),""===x.folder.parent&&(0,g.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,g.jsx)(a4,{className:"h-4 w-4 shrink-0 text-warning"}),(0,g.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:x.folder.name,onChange:a=>y(b=>({...b,folder:{...b.folder,name:a.target.value}})),onKeyDown:a=>{"Enter"===a.key&&A(),"Escape"===a.key&&y(a=>({...a,folder:{...a.folder,parent:null,name:""}}))}}),x.folder.error&&(0,g.jsx)("span",{className:"text-xs text-destructive",children:x.folder.error}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:A,children:(0,g.jsx)(r.Check,{className:"h-3 w-3"})}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>y(a=>({...a,folder:{...a.folder,parent:null,name:""}})),children:(0,g.jsx)(o,{className:"h-3 w-3"})})]}),""===x.file.parent&&(0,g.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,g.jsx)(j.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,g.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:x.file.name,onChange:a=>y(b=>({...b,file:{...b.file,name:a.target.value}})),onKeyDown:a=>{"Enter"===a.key&&z(),"Escape"===a.key&&y(a=>({...a,file:{...a.file,parent:null,name:""}}))}}),x.file.error&&(0,g.jsx)("span",{className:"text-xs text-destructive",children:x.file.error}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:z,children:(0,g.jsx)(r.Check,{className:"h-3 w-3"})}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>y(a=>({...a,file:{...a.file,parent:null,name:""}})),children:(0,g.jsx)(o,{className:"h-3 w-3"})})]}),(0,g.jsx)("div",{className:"border-b",children:(0,g.jsx)(dV,{onOpenFile:b.openFromSearch})}),(0,g.jsxs)("div",{ref:F,className:(0,ao.cn)("flex-1 overflow-auto py-1 ",""===B&&"ring-2 ring-inset ring-primary bg-primary/5"),onDragOver:a=>D(a,"","root"),onDragLeave:a=>{a.currentTarget.contains(a.relatedTarget)||C(null)},onDrop:a=>E(a,""),children:[H.length>0&&(0,g.jsxs)("div",{className:"border-b mb-1",children:[(0,g.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>w(a=>({...a,favorites:!a.favorites})),children:[u.favorites?(0,g.jsx)(a3.ChevronRight,{className:"h-3 w-3"}):(0,g.jsx)(s,{className:"h-3 w-3"}),(0,g.jsx)(ba,{className:"h-3 w-3"}),"Favorites",(0,g.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:H.length})]}),!u.favorites&&H.map(c=>(0,g.jsxs)(cp,{children:[(0,g.jsx)(cr,{asChild:!0,children:(0,g.jsxs)("div",{role:"button",tabIndex:0,className:(0,ao.cn)("group flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",b.openFile?.path===c.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{b.openFavoriteEntry(c)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.preventDefault(),b.openFavoriteEntry(c))},children:[(0,g.jsx)(cT,{name:c.name,type:c.type??"file"}),(0,g.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs",title:O?c.name:void 0,children:O?d$(c.name):c.name}),(0,g.jsx)("span",{className:"max-w-[80px] truncate text-[10px] text-muted-foreground/60",children:c.path.split("/").slice(0,-1).join("/")}),(0,g.jsx)("button",{type:"button",className:"hover-reveal shrink-0 rounded p-0.5 text-muted-foreground/50 opacity-0 transition-colors hover:bg-muted hover:text-amber-400 group-hover:opacity-100 focus:opacity-100",title:"Remove from favorites",onClick:b=>{b.stopPropagation(),cW.getState().toggle({path:c.path,name:c.name},a.activeWorkspaceId)},children:(0,g.jsx)(o,{className:"h-3 w-3"})})]})}),(0,g.jsx)(cS,{node:{path:c.path,name:c.name,type:c.type??"file"},ctx:G,isFavorited:!0,activeWorkspaceId:a.activeWorkspaceId})]},c.path))]}),I.length>0&&(0,g.jsxs)("div",{className:"border-b mb-1",children:[(0,g.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>w(a=>({...a,recent:!a.recent})),children:[u.recent?(0,g.jsx)(a3.ChevronRight,{className:"h-3 w-3"}):(0,g.jsx)(s,{className:"h-3 w-3"}),(0,g.jsx)(dQ,{className:"h-3 w-3"}),"Recent",(0,g.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:I.length})]}),!u.recent&&I.slice(0,8).map(c=>(0,g.jsxs)(cp,{children:[(0,g.jsx)(cr,{asChild:!0,children:(0,g.jsxs)("div",{role:"button",tabIndex:0,className:(0,ao.cn)("flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",b.openFile?.path===c.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{b.openViewer({path:c.path,name:c.name,type:c.type??"file",modifiedAt:""}),e&&k(!0)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.preventDefault(),b.openViewer({path:c.path,name:c.name,type:c.type??"file",modifiedAt:""}))},children:[(0,g.jsx)(cT,{name:c.name,type:c.type??"file"}),(0,g.jsx)("span",{className:"flex-1 truncate text-xs",title:O?c.name:void 0,children:O?d$(c.name):c.name}),(0,g.jsx)("span",{className:"text-[10px] text-muted-foreground/60 truncate max-w-[80px]",children:c.path.split("/").slice(0,-1).join("/")})]})}),(0,g.jsx)(cS,{node:{path:c.path,name:c.name,type:c.type??"file"},ctx:G,isFavorited:H.some(a=>a.path===c.path),activeWorkspaceId:a.activeWorkspaceId})]},c.path))]}),c.rootLoading?(0,g.jsx)("div",{className:"flex justify-center py-6",children:(0,g.jsx)(m.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):0===c.roots.length?(0,g.jsxs)("div",{className:"flex flex-col items-center gap-3 px-4 py-8 text-center",children:[(0,g.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,g.jsx)(j.FileText,{className:"h-6 w-6 text-muted-foreground"})}),(0,g.jsxs)("div",{className:"space-y-1",children:[(0,g.jsx)("p",{className:"text-sm font-medium",children:"No files yet"}),(0,g.jsx)("p",{className:"text-xs text-muted-foreground",children:"Upload files or add them to the configured directory"})]}),(0,g.jsxs)(v.Button,{size:"sm",variant:"outline",className:"w-full gap-1.5 max-w-[180px]",onClick:()=>d.triggerUpload(""),disabled:d.uploading,children:[d.uploading?(0,g.jsx)(m.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,g.jsx)(cf,{className:"h-3.5 w-3.5"}),"Upload Files"]})]}):(0,g.jsx)(cV,{ctx:G,nodes:c.roots,openPath:b.openFile?.path??null,dragOverPath:B,branchDropdownNode:c.branchDropdownNode,branchDropdownPos:c.branchDropdownPos,nodeBranches:c.nodeBranches,branchesLoading:c.branchesLoading,checkingOutBranch:c.checkingOutBranch,pullingRepo:c.pullingRepo,activePaths:J,favorites:H,isMobile:e,activeWorkspaceId:a.activeWorkspaceId,newFileParent:x.file.parent,newFileName:x.file.name,fileCreateError:x.file.error,newFolderParent:x.folder.parent,newFolderName:x.folder.name,folderError:x.folder.error,sidebarScrollRef:F})]}),(0,g.jsx)(dY,{workspaces:a.workspaces,activeWorkspaceId:a.activeWorkspaceId,rootPath:a.rootPath,isWsAdmin:a.isWsAdmin,refreshingWsId:a.refreshingWsId,switchingBranch:a.switchingBranch,switchingBranchName:a.switchingBranchName,wsBranches:a.wsBranches,branchPickerWsId:a.branchPickerWsId,wsBranchPos:a.wsBranchPos,onSwitchWorkspace:b=>void a.switchWorkspace(b),onRefreshWorkspace:a.handleRefreshWorkspace,onPromptDeleteWorkspace:b=>a.setDeletingWorkspaceId(b),onAddWorkspace:()=>a.setAddingWorkspace(!0),setBranchPickerWsId:a.setBranchPickerWsId,setWsBranchPos:a.setWsBranchPos,loadWsBranches:a.loadWsBranches,handleSwitchBranch:a.handleSwitchBranch}),(0,g.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize",onMouseDown:a=>{a.preventDefault();let b=a.clientX;n(!0);let c=document.body.style.cursor,d=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let e=a=>{t(p+(a.clientX-b))},f=()=>{n(!1),document.body.style.cursor=c,document.body.style.userSelect=d,window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",f)};window.addEventListener("mousemove",e),window.addEventListener("mouseup",f)},onDoubleClick:()=>t(288),onKeyDown:a=>{"ArrowLeft"===a.key?(a.preventDefault(),t(p-16)):"ArrowRight"===a.key&&(a.preventDefault(),t(p+16))},tabIndex:0,"aria-valuemin":200,"aria-valuemax":600,"aria-valuenow":p,className:(0,ao.cn)("absolute right-0 top-0 z-20 h-full w-1.5 cursor-col-resize -mr-px transition-colors hover:bg-primary/40 focus:bg-primary/40 focus:outline-none hidden md:block",l&&"bg-primary/60")})]})]})}function d0({workspace:a,doc:b,fileTree:c,upload:d,isMobile:e,hideChrome:f,sidebarCollapsed:h,setSidebarCollapsed:i,favorites:j,recents:k,activePaths:l,setDeleting:m,setDialogs:n}){let[o,q]=(0,p.useState)(!1),[r,s]=(0,p.useState)(null),[t,u]=(0,p.useState)({favorites:!1,recent:!0}),[v,w]=(0,p.useState)({file:{parent:null,name:"",error:null},folder:{parent:null,name:"",error:null}}),x=(0,p.useRef)(null),y=(0,p.useRef)(null),z=dZ(a=>a.width),A=dZ(a=>a.setWidth),B=(0,p.useCallback)(async()=>{let a=v.file.name.trim();if(!a||null===v.file.parent)return;w(a=>({...a,file:{...a.file,error:null}}));let d=a.includes(".")?a:`${a}.md`,e=v.file.parent?`${v.file.parent}/${d}`:d,f=await fetch((0,bB.withWs)("/api/wiki/new-file"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})});if(f.ok){let a=v.file.parent;w(a=>({...a,file:{parent:null,name:"",error:null}})),await c.reloadDir(a),b.openViewer({path:e,name:d,type:"file",modifiedAt:new Date().toISOString()})}else{let a=await f.json();w(b=>({...b,file:{...b.file,error:a.error??"Failed"}}))}},[v.file.parent,v.file.name,c,b]),C=(0,p.useCallback)(async()=>{let a=v.folder.name.trim();if(!a||null===v.folder.parent)return;w(a=>({...a,folder:{...a.folder,error:null}}));let b=v.folder.parent?`${v.folder.parent}/${a}`:a,d=await fetch((0,bB.withWs)("/api/wiki/folder"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:b})});if(d.ok){let a=v.folder.parent;w(a=>({...a,folder:{parent:null,name:"",error:null}})),await c.reloadDir(a)}else{let a=await d.json();w(b=>({...b,folder:{...b.folder,error:a.error??"Failed"}}))}},[v.folder.parent,v.folder.name,c]);function D(a,b,c){a.preventDefault(),a.stopPropagation();let d=y.current;if(!d){Array.from(a.dataTransfer.types).includes("Files")&&(a.dataTransfer.dropEffect="copy",s("root"===c?"":b));return}d.path===b||b.startsWith(`${d.path}/`)||(a.dataTransfer.dropEffect="move",s("root"===c?"":b))}async function E(a,e){a.preventDefault(),a.stopPropagation(),s(null);let f=y.current;if(y.current=null,!f){a.dataTransfer.files.length>0&&await d.doUpload(a.dataTransfer.files,e);return}if(f.path===e||e.startsWith(`${f.path}/`))return;let g=e?`${e}/${f.name}`:f.name;if(g!==f.path&&(await fetch((0,bB.withWs)("/api/wiki/move"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:f.path,to:g})})).ok){let a=f.path.includes("/")?f.path.split("/").slice(0,-1).join("/"):"";await c.reloadDir(a),e!==a&&await c.reloadDir(e),b.openFile?.path===f.path&&b.openViewer({path:g,name:f.name,type:f.type,modifiedAt:f.modifiedAt})}}let F=(0,p.useRef)(null);F.current={toggleFolder:a=>void c.toggleFolder(a),openViewer:a=>void b.openViewer(a),copyPath:a=>b.copyPath(a),copyWikiLink:a=>b.copyWikiLink(a),copyUrl:a=>b.copyUrl(a),copyRawContent:a=>void b.copyRawContent(a),copyFormattedContent:(a,c)=>void b.copyFormattedContent(a,c),handleDownload:function(a){let b=(0,bB.withWs)(`/api/wiki/download?path=${encodeURIComponent(a.path)}`),c=document.createElement("a");c.href=b,c.download="file"===a.type?a.name:`${a.name}.zip`,document.body.appendChild(c),c.click(),c.remove()},triggerUpload:a=>d.triggerUpload(a),handleCreateFile:B,handleCreateFolder:C,handleDragStart:function(a,b){y.current=b,a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",b.path)},handleDragOver:D,handleDropOnFolder:(a,b)=>void E(a,b),handleGitPull:(a,b)=>void c.handleGitPull(a,b),handleCheckout:(a,b,d)=>void c.handleCheckout(a,b,d),loadBranches:a=>void c.loadBranches(a),prefetch:a=>void c.prefetch(a),toggleFavorite:(a,b)=>cW.getState().toggle({path:a.path,name:a.name,type:a.type},b),setDragOverPath:s,setSidebarCollapsed:i,setBranchDropdownNode:a=>c.setBranchDropdownNode(a),setBranchDropdownPos:a=>c.setBranchDropdownPos(a),setNewFileParent:a=>w(b=>({...b,file:{...b.file,parent:a,error:null}})),setNewFileName:a=>w(b=>({...b,file:{...b.file,name:a}})),setFileCreateError:a=>w(b=>({...b,file:{...b.file,error:a}})),setNewFolderParent:a=>w(b=>({...b,folder:{...b.folder,parent:a,error:null}})),setNewFolderName:a=>w(b=>({...b,folder:{...b.folder,name:a}})),setFolderError:a=>w(b=>({...b,folder:{...b.folder,error:a}})),setDeletingPath:a=>m(b=>({...b,path:a})),setDeletingIsDir:a=>m(b=>({...b,isDir:a}))};let G=(0,p.useMemo)(()=>({toggleFolder:a=>F.current.toggleFolder(a),openViewer:a=>F.current.openViewer(a),copyPath:a=>F.current.copyPath(a),copyWikiLink:a=>F.current.copyWikiLink(a),copyUrl:a=>F.current.copyUrl(a),copyRawContent:a=>F.current.copyRawContent(a),copyFormattedContent:(a,b)=>F.current.copyFormattedContent(a,b),handleDownload:a=>F.current.handleDownload(a),triggerUpload:a=>F.current.triggerUpload(a),handleCreateFile:()=>F.current.handleCreateFile(),handleCreateFolder:()=>F.current.handleCreateFolder(),handleDragStart:(a,b)=>F.current.handleDragStart(a,b),handleDragOver:(a,b,c)=>F.current.handleDragOver(a,b,c),handleDropOnFolder:(a,b)=>F.current.handleDropOnFolder(a,b),handleGitPull:(a,b)=>F.current.handleGitPull(a,b),handleCheckout:(a,b,c)=>F.current.handleCheckout(a,b,c),loadBranches:a=>F.current.loadBranches(a),prefetch:a=>F.current.prefetch(a),toggleFavorite:(a,b)=>F.current.toggleFavorite(a,b),setDragOverPath:a=>F.current.setDragOverPath(a),setSidebarCollapsed:a=>F.current.setSidebarCollapsed(a),setBranchDropdownNode:a=>F.current.setBranchDropdownNode(a),setBranchDropdownPos:a=>F.current.setBranchDropdownPos(a),setNewFileParent:a=>F.current.setNewFileParent(a),setNewFileName:a=>F.current.setNewFileName(a),setFileCreateError:a=>F.current.setFileCreateError(a),setNewFolderParent:a=>F.current.setNewFolderParent(a),setNewFolderName:a=>F.current.setNewFolderName(a),setFolderError:a=>F.current.setFolderError(a),setDeletingPath:a=>F.current.setDeletingPath(a),setDeletingIsDir:a=>F.current.setDeletingIsDir(a)}),[]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(dM,{onOpenFile:b.openFromSearch,recents:k,onToggleSidebar:()=>i(a=>{let b=!a;return e&&!1===b&&bF.getState().close(),b}),onNewFile:()=>w(a=>({...a,file:{...a.file,parent:""}})),onCopyPath:()=>{b.openFile&&b.copyPath(b.openFile.path)}}),(0,g.jsx)(d_,{workspace:a,doc:b,fileTree:c,upload:d,isMobile:e,hideChrome:f,sidebarCollapsed:h,setSidebarCollapsed:i,sidebarResizing:o,setSidebarResizing:q,sidebarWidth:z,setSidebarWidth:A,collapsed:t,setCollapsed:u,createEntry:v,setCreateEntry:w,handleCreateFile:B,handleCreateFolder:C,dragOverPath:r,setDragOverPath:s,handleDragOver:D,handleDropOnFolder:E,sidebarScrollRef:x,treeCtx:G,favorites:j,recents:k,activePaths:l,setDialogs:n,handleRefreshWorkspace:a.handleRefreshWorkspace})]})}let d1=(0,h.default)("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]),d2=(0,h.default)("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]),d3=(0,h.default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),d4=(0,h.default)("share",[["path",{d:"M12 2v13",key:"1km8f5"}],["path",{d:"m16 6-4-4-4 4",key:"13yo43"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}]]),d5=(0,h.default)("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);var d6=a.i(441218);let d7=(0,h.default)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),d8=(0,p.createContext)(null),d9=(0,p.createContext)(null);function ea({path:a,badge:b,sublabel:c,showBreadcrumb:d=!0,leading:e,children:f,className:h}){let i=(0,p.useContext)(d8),j=(0,p.useContext)(d9);return i?(0,g.jsxs)(g.Fragment,{children:[b&&(j?(0,bu.createPortal)((0,g.jsx)("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground/50",children:b}),j):(0,bu.createPortal)((0,g.jsx)("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground/50",children:b}),i)),(0,bu.createPortal)((0,g.jsxs)(g.Fragment,{children:[c&&(0,g.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground/40",children:c}),f]}),i)]}):(0,g.jsxs)("div",{className:(0,ao.cn)("flex shrink-0 items-center justify-between gap-3 border-b border-border bg-background px-4 py-2",h),children:[(0,g.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e,a&&(0,g.jsx)("span",{className:"text-xs text-muted-foreground truncate",title:a,children:a.split("/").pop()??a}),b&&(0,g.jsx)("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground/50",children:b}),c&&(0,g.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground/40",children:c})]}),(0,g.jsx)("div",{className:"flex shrink-0 items-center gap-1",children:f})]})}function eb(a){let b=[],c="",d=!1,e=[];for(let f=0;f<a.length;f++){let g=a[f],h=a[f+1];d?'"'===g&&'"'===h?(c+='"',f++):'"'===g?d=!1:c+=g:'"'===g?d=!0:","===g?(e.push(c),c=""):"\n"===g||"\r"===g&&"\n"===h?(e.push(c),c="",e.length>0&&b.push(e),e=[],"\r"===g&&f++):c+=g}return e.push(c),e.some(a=>""!==a)&&b.push(e),b}function ec(a){return a.map(a=>a.map(a=>a.includes(",")||a.includes('"')||a.includes("\n")?`"${a.replace(/"/g,'""')}"`:a).join(",")).join("\n")}function ed({path:a}){let[b,c]=(0,p.useState)([]),[d,e]=(0,p.useState)(""),[f,h]=(0,p.useState)(!1),[i,j]=(0,p.useState)(!1),[k,l]=(0,p.useState)(!1),[m,n]=(0,p.useState)(null),[o,q]=(0,p.useState)(!1),[r,s]=(0,p.useState)(1e3),t=(0,bB.withWs)(`/api/assets/${a}`);(0,p.useEffect)(()=>{fetch(t).then(a=>a.text()).then(a=>{let b=eb(a),d=a.length>2097152||b.length>2e3;e(a),c(b),q(d),h(d),j(!1)})},[t]);let u=(0,p.useCallback)((a,b,d)=>{c(c=>{let e=c.map(a=>[...a]);for(;e.length<=a;)e.push([]);for(;e[a].length<=b;)e[a].push("");return e[a][b]=d,e}),j(!0)},[]),w=async()=>{l(!0);let g=f?d:ec(b);try{await (0,bB.wsFetch)(`/api/assets/${a}`,{method:"PUT",headers:{"Content-Type":"text/plain"},body:g}),f?c(eb(d)):e(g),j(!1)}catch(a){console.error("Failed to save CSV:",a)}l(!1)},x=b[0]||[],y=b.slice(1),z=o?y.slice(0,r):y,A=o&&r<y.length;return(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsxs)(ea,{path:a,badge:`CSV${b.length>0?` (${b.length-1} rows)`:""}`,children:[i&&(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:w,disabled:k,children:[(0,g.jsx)(d7,{className:"h-3.5 w-3.5"}),k?"Saving...":"Save"]}),o&&(0,g.jsxs)("span",{className:"text-[11px] text-amber-600 dark:text-amber-400 px-1",children:["Large file (",(d.length/1048576).toFixed(1)," MB,"," ",b.length.toLocaleString()," rows)"]}),(0,g.jsxs)("button",{onClick:()=>{f?c(eb(d)):e(ec(b)),h(!f)},className:`flex items-center gap-1.5 px-2.5 py-1 text-[11px] rounded-md transition-colors border border-border ${f?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"}`,children:[(0,g.jsx)(d1,{className:"h-3 w-3"}),f?"Table":"Source"]}),(0,g.jsx)("button",{onClick:()=>window.open(t,"_blank"),className:"inline-flex items-center justify-center rounded-md h-8 w-8 hover:bg-accent hover:text-accent-foreground transition-colors cursor-pointer",title:"Download CSV",children:(0,g.jsx)(b8.Download,{className:"h-4 w-4"})})]}),f?(0,g.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:(0,g.jsx)("textarea",{value:d,onChange:a=>{e(a.target.value),j(!0)},className:"w-full h-full min-h-[calc(100vh-12rem)] bg-transparent font-mono text-[13px] leading-relaxed resize-none focus:outline-none",spellCheck:!1})}):(0,g.jsxs)("div",{className:"flex-1 overflow-auto",children:[(0,g.jsxs)("table",{className:"w-full border-collapse text-[13px]",children:[(0,g.jsx)("thead",{className:"sticky top-0 z-10",children:(0,g.jsxs)("tr",{className:"bg-muted/80 backdrop-blur-sm",children:[(0,g.jsx)("th",{className:"border border-border px-1 py-1 text-center text-[10px] text-muted-foreground w-8",children:"#"}),x.map((a,b)=>(0,g.jsx)("th",{className:"border border-border px-3 py-1.5 text-left font-medium text-foreground min-w-[100px]",children:m?.r===0&&m?.c===b?(0,g.jsx)("input",{autoFocus:!0,className:"w-full bg-transparent outline-none",value:a,onChange:a=>u(0,b,a.target.value),onBlur:()=>n(null),onKeyDown:a=>{("Enter"===a.key||"Escape"===a.key)&&n(null),"Tab"===a.key&&(a.preventDefault(),n({r:0,c:b+1<x.length?b+1:0}))}}):(0,g.jsx)("span",{className:"cursor-text",onDoubleClick:()=>n({r:0,c:b}),children:a||" "})},b))]})}),(0,g.jsx)("tbody",{children:z.map((a,b)=>{let d=b+1;return(0,g.jsxs)("tr",{className:"hover:bg-accent/30 transition-colors group",children:[(0,g.jsxs)("td",{className:"border border-border px-1 py-1 text-center text-[10px] text-muted-foreground/50",children:[(0,g.jsx)("span",{className:"group-hover:hidden",children:b+1}),(0,g.jsx)("button",{className:"hidden group-hover:inline text-destructive hover:text-destructive/80 text-[10px]",onClick:()=>{c(a=>a.filter((a,b)=>b!==d)),j(!0)},title:"Delete row",children:"×"})]}),x.map((b,c)=>{let e=a[c]??"",f=m?.r===d&&m?.c===c;return(0,g.jsx)("td",{className:"border border-border px-3 py-1.5",children:f?(0,g.jsx)("input",{autoFocus:!0,className:"w-full bg-transparent outline-none",value:e,onChange:a=>u(d,c,a.target.value),onBlur:()=>n(null),onKeyDown:a=>{"Escape"===a.key&&n(null),"Enter"===a.key&&n({r:d+1,c}),"Tab"===a.key&&(a.preventDefault(),a.shiftKey?n({r:d,c:Math.max(0,c-1)}):n({r:c+1>=x.length?d+1:d,c:c+1>=x.length?0:c+1}))}}):(0,g.jsx)("span",{className:"cursor-text",onDoubleClick:()=>n({r:d,c}),children:e||" "})},c)})]},b)})})]}),A&&(0,g.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border",children:[(0,g.jsxs)("button",{onClick:()=>s(a=>a+1e3),className:"text-[11px] text-foreground hover:bg-accent transition-colors px-2.5 py-1 rounded border border-border",children:["Show"," ",Math.min(1e3,y.length-r).toLocaleString()," ","more rows"]}),(0,g.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[r.toLocaleString()," /"," ",y.length.toLocaleString()," rows"]})]}),(0,g.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 border-t border-border",children:[(0,g.jsx)("button",{onClick:()=>{let a=b[0]?.length||1;c(b=>[...b,Array(a).fill("")]),j(!0)},className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors px-2 py-1 rounded hover:bg-accent",children:"+ Add row"}),(0,g.jsx)("button",{onClick:()=>{c(a=>a.map(a=>[...a,""])),j(!0)},className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors px-2 py-1 rounded hover:bg-accent",children:"+ Add column"})]})]})]})}function ee(a){this.content=a}ee.prototype={constructor:ee,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 ee(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 ee(c)},addToStart:function(a,b){return new ee([a,b].concat(this.remove(a).content))},addToEnd:function(a,b){var c=this.remove(a).content.slice();return c.push(a,b),new ee(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 ee(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=ee.from(a)).size?new ee(a.content.concat(this.subtract(a).content)):this},append:function(a){return(a=ee.from(a)).size?new ee(this.subtract(a).content.concat(a.content)):this},subtract:function(a){var b=this;a=ee.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}},ee.from=function(a){if(a instanceof ee)return a;var b=[];if(a)for(var c in a)b.push(c,a[c]);return new ee(b)};class ef{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 ef(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 ef(c,d)}cutByIndex(a,b){return a==b?ef.empty:0==a&&b==this.content.length?this:new ef(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 ef(d,e)}addToStart(a){return new ef([a].concat(this.content),this.size+a.nodeSize)}addToEnd(a){return new ef(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 eh(0,a);if(a==this.size)return eh(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 eh(b+1,d);return eh(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 ef.empty;if(!Array.isArray(b))throw RangeError("Invalid input for Fragment.fromJSON");return ef.fromArray(b.map(a.nodeFromJSON))}static fromArray(a){if(!a.length)return ef.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 ef(b||a,c)}static from(a){if(!a)return ef.empty;if(a instanceof ef)return a;if(Array.isArray(a))return this.fromArray(a);if(a.attrs)return new ef([a],a.nodeSize);throw RangeError("Can not convert "+a+" to a Fragment"+(a.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}ef.empty=new ef([],0);let eg={index:0,offset:0};function eh(a,b){return eg.index=a,eg.offset=b,eg}function ei(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(!ei(a[c],b[c]))return!1}else{for(let c in a)if(!(c in b)||!ei(a[c],b[c]))return!1;for(let c in b)if(!(c in a))return!1}return!0}class ej{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&&ei(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 ej.none;if(a instanceof ej)return[a];let b=a.slice();return b.sort((a,b)=>a.type.rank-b.type.rank),b}}ej.none=[];class ek extends Error{}class el{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,f,g){let{index:h,offset:i}=b.findIndex(c),j=b.maybeChild(h);if(i==c||j.isText)return g&&e<=0&&f<=0&&!g.canReplace(h,h,d)?null:b.cut(0,c).append(d).append(b.cut(c));let k=a(j.content,c-i-1,d,0==h?e-1:0,h==b.childCount-1?f-1:0,j);return k&&b.replaceChild(h,j.copy(k))}(this.content,a+this.openStart,b,this.openStart+1,this.openEnd+1);return c&&new el(c,this.openStart,this.openEnd)}removeBetween(a,b){return new el(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 el.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 el(ef.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 el(a,c,d)}}function em(a,b){if(!b.type.compatibleContent(a.type))throw new ek("Cannot join "+b.type.name+" onto "+a.type.name)}function en(a,b,c){let d=a.node(c);return em(d,b.node(c)),d}function eo(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 ep(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&&(eo(a.nodeAfter,d),f++));for(let a=f;a<g;a++)eo(e.child(a),d);b&&b.depth==c&&b.textOffset&&eo(b.nodeBefore,d)}function eq(a,b){return a.type.checkContent(b),a.copy(b)}function er(a,b,c){let d=[];return ep(null,a,c,d),a.depth>c&&eo(eq(en(a,b,c+1),er(a,b,c+1)),d),ep(b,null,c,d),new ef(d)}el.empty=new el(ef.empty,0,0);class es{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 ej.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 ew(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 es(b,c,e)}static resolveCached(a,b){let c=ev.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 ev.set(a,c=new et);let d=c.elts[c.i]=es.resolve(a,b);return c.i=(c.i+1)%eu,d}}class et{constructor(){this.elts=[],this.i=0}}let eu=12,ev=new WeakMap;class ew{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 ex=Object.create(null);class ey{constructor(a,b,c,d=ej.none){this.type=a,this.attrs=b,this.marks=d,this.content=c||ef.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&&ei(this.attrs,b||a.defaultAttrs||ex)&&ej.sameSet(this.marks,c||ej.none)}copy(a=null){return a==this.content?this:new ey(this.type,this.attrs,a,this.marks)}mark(a){return a==this.marks?this:new ey(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 el.empty;let d=this.resolve(a),e=this.resolve(b),f=c?0:d.sharedDepth(b),g=d.start(f);return new el(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 ek("Inserted content deeper than insertion position");if(d.depth-c.openStart!=e.depth-c.openEnd)throw new ek("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 eq(g,er(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(ef.from(d));return{start:d.resolveNoCache(a.openStart+c),end:d.resolveNoCache(d.content.size-a.openEnd-c)}}(d,b);return eq(g,function a(b,c,d,e,f){let g=b.depth>f&&en(b,c,f+1),h=e.depth>f&&en(d,e,f+1),i=[];return ep(null,b,f,i),g&&h&&c.index(f)==d.index(f)?(em(g,h),eo(eq(g,a(b,c,d,e,f+1)),i)):(g&&eo(eq(g,er(b,c,f+1)),i),ep(c,d,f,i),h&&eo(eq(h,er(d,e,f+1)),i)),ep(e,null,f,i),new ef(i)}(b,a,f,c,e))}{let a=b.parent,e=a.content;return eq(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 es.resolveCached(this,a)}resolveNoCache(a){return es.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()+")"),eA(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=ef.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=ej.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(!ej.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=ef.fromJSON(a,b.content),e=a.nodeType(b.type).create(b.attrs,d,c);return e.type.checkAttrs(e.attrs),e}}ey.prototype.text=void 0;class ez extends ey{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):eA(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 ez(this.type,this.attrs,this.text,a)}withText(a){return a==this.text?this:new ez(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 eA(a,b){for(let c=a.length-1;c>=0;c--)b=a[c].type.name+"("+b+")";return b}class eB{constructor(a){this.validEnd=a,this.next=[],this.wrapCache=[]}static parse(a,b){var c;let d,e=new eC(a,b);if(null==e.next)return eB.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=eD(a),d=c;return a.eat(",")&&(d="}"!=a.next?eD(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]);eF(c,b).forEach(b=>{d||e.push([a,d=[]]),-1==d.indexOf(b)&&d.push(b)})}})});let f=d[b.join(",")]=new eB(b.indexOf(c.length-1)>-1);for(let b=0;b<e.length;b++){let c=e[b][1].sort(eE);f.next.push({type:e[b][0],next:d[c.join(",")]||a(c)})}return f}(eF(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 ef.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")}}eB.empty=new eB(!0);class eC{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 eD(a){/\D/.test(a.next)&&a.err("Expected number, got '"+a.next+"'");let b=Number(a.next);return a.pos++,b}function eE(a,b){return b-a}function eF(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(eE)}function eG(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 eH(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 eI(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 eJ(a,b){let c=Object.create(null);if(b)for(let d in b)c[d]=new eL(a,d,b[d]);return c}class eK{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=eJ(a,c.attrs),this.defaultAttrs=eG(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==eB.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:eH(this.attrs,a)}create(a=null,b,c){if(this.isText)throw Error("NodeType.create can't construct text nodes");return new ey(this,this.computeAttrs(a),ef.from(b),ej.setFrom(c))}createChecked(a=null,b,c){return b=ef.from(b),this.checkContent(b),new ey(this,this.computeAttrs(a),b,ej.setFrom(c))}createAndFill(a=null,b,c){if(a=this.computeAttrs(a),(b=ef.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(ef.empty,!0);return e?new ey(this,a,b.append(e),ej.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){eI(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:ej.none:a}static compile(a,b){let c=Object.create(null);a.forEach((a,d)=>c[a]=new eK(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 eL{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 eM{constructor(a,b,c,d){this.name=a,this.rank=b,this.schema=c,this.spec=d,this.attrs=eJ(a,d.attrs),this.excluded=null;let e=eG(this.attrs);this.instance=e?new ej(this,e):null}create(a=null){return!a&&this.instance?this.instance:new ej(this,eH(this.attrs,a))}static compile(a,b){let c=Object.create(null),d=0;return a.forEach((a,e)=>c[a]=new eM(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){eI(this.attrs,a,"mark",this.name)}excludes(a){return this.excluded.indexOf(a)>-1}}class eN{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=ee.from(a.nodes),b.marks=ee.from(a.marks||{}),this.nodes=eK.compile(this.spec.nodes,this),this.marks=eM.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]=eB.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?eO(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?[]:eO(this,c.split(" "))}this.nodeFromJSON=a=>ey.fromJSON(this,a),this.markFromJSON=a=>ej.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 eK){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 ez(c,c.defaultAttrs,a,ej.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 eO(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 eP{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 eV(this,b,!1);return c.addAll(a,ej.none,b.from,b.to),c.finish()}parseSlice(a,b={}){let c=new eV(this,b,!0);return c.addAll(a,ej.none,b.from,b.to),el.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=eW(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=eW(a)),a.node||a.ignore||a.mark||(a.node=b)})}return b}static fromSchema(a){return a.cached.domParser||(a.cached.domParser=new eP(a,eP.schemaRules(a)))}}let eQ={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},eR={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},eS={ol:!0,ul:!0};function eT(a,b,c){return null!=b?!!b|2*("full"===b):a&&"pre"==a.whitespace?3:-5&c}class eU{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=ej.none,this.match=e||(4&f?null:a.contentMatch)}findWrapping(a){if(!this.match){if(!this.type)return[];let b=this.type.contentMatch.fillBefore(ef.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=ef.from(this.content);return!a&&this.match&&(b=b.append(this.match.fillBefore(ef.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&&!eQ.hasOwnProperty(a.parentNode.nodeName.toLowerCase())}}class eV{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=eT(null,b.preserveWhitespace,0)|4*!!c;e=d?new eU(d.type,d.attrs,ej.none,!0,b.topMatch||d.type.contentMatch,f):c?new eU(null,null,ej.none,!0,null,f):new eU(a.schema.topNodeType,null,ej.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;eS.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&&eS.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));b:if(h?h.ignore:eR.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(eQ.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 b}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=ej.none;for(let e of d.concat(a.marks))(b.type?b.type.allowsMarkType(e.type):eX(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=eT(a,e,f.options);4&f.options&&0==f.content.length&&(g|=4);let h=ej.none;return c=c.filter(b=>(f.type?!f.type.allowsMarkType(b.type):!eX(b.type,a))||(h=b.addToSet(h),!1)),this.nodes.push(new eU(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 eW(a){let b={};for(let c in a)b[c]=a[c];return b}function eX(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 eY{constructor(a,b){this.nodes=a,this.marks=b}serializeFragment(a,b={},c){c||(c=e$(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){if(a.isText)return e$(b).createTextNode(a.text);let{dom:c,contentDOM:d}=e0(e$(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&&e0(e$(c),d(a,b),null,a.attrs)}static renderSpec(a,b,c=null,d){return"string"==typeof b?{dom:a.createTextNode(b)}:e0(a,b,c,d)}static fromSchema(a){return a.cached.domSerializer||(a.cached.domSerializer=new eY(this.nodesFromSchema(a),this.marksFromSchema(a)))}static nodesFromSchema(a){let b=eZ(a.nodes);return b.text||(b.text=a=>a.text),b}static marksFromSchema(a){return eZ(a.marks)}}function eZ(a){let b={};for(let c in a){let d=a[c].spec.toDOM;d&&(b[c]=d)}return b}function e$(a){return a.document||window.document}let e_=new WeakMap;function e0(a,b,c,d){let e,f,g;if(1==b.nodeType)return{dom:b};if(b.dom&&1==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=e_.get(d))&&e_.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}}if("string"==typeof g)k.appendChild(a.createTextNode(g));else{let{dom:b,contentDOM:f}=e0(a,g,c,d);if(k.appendChild(b),f){if(e)throw RangeError("Multiple content holes");e=f}}}return{dom:k,contentDOM:e}}class e1{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 e2{constructor(a,b=!1){if(this.ranges=a,this.inverted=b,!a.length&&e2.empty)return e2.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 e1(f,m,l)}d+=j-i}return c?a+d:new e1(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 e2(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(a){return 0==a?e2.empty:new e2(a<0?[0,-a,0]:[0,0,a])}}e2.empty=new e2([]);class e3{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 e3(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 e3;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 e1(a,d,null)}}let e4=Object.create(null);class e5{getMap(){return e2.empty}merge(a){return null}static fromJSON(a,b){if(!b||!b.stepType)throw RangeError("Invalid input for Step.fromJSON");let c=e4[b.stepType];if(!c)throw RangeError(`No step type ${b.stepType} defined`);return c.fromJSON(a,b)}static jsonID(a,b){if(a in e4)throw RangeError("Duplicate use of step JSON ID "+a);return e4[a]=b,b.prototype.jsonID=a,b}}class e6{constructor(a,b){this.doc=a,this.failed=b}static ok(a){return new e6(a,null)}static fail(a){return new e6(null,a)}static fromReplace(a,b,c,d){try{return e6.ok(a.replace(b,c,d))}catch(a){if(a instanceof ek)return e6.fail(a.message);throw a}}}function e7(a,b,c){let d=[];for(let e=0;e<a.childCount;e++){let f=a.child(e);f.content.size&&(f=f.copy(e7(f.content,b,f))),f.isInline&&(f=b(f,c,e)),d.push(f)}return ef.fromArray(d)}class e8 extends e5{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 el(e7(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 e6.fromReplace(a,this.from,this.to,e)}invert(){return new e9(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 e8(b.pos,c.pos,this.mark)}merge(a){return a instanceof e8&&a.mark.eq(this.mark)&&this.from<=a.to&&this.to>=a.from?new e8(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 e8(b.from,b.to,a.markFromJSON(b.mark))}}e5.jsonID("addMark",e8);class e9 extends e5{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 el(e7(b.content,a=>a.mark(this.mark.removeFromSet(a.marks)),a),b.openStart,b.openEnd);return e6.fromReplace(a,this.from,this.to,c)}invert(){return new e8(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 e9(b.pos,c.pos,this.mark)}merge(a){return a instanceof e9&&a.mark.eq(this.mark)&&this.from<=a.to&&this.to>=a.from?new e9(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 e9(b.from,b.to,a.markFromJSON(b.mark))}}e5.jsonID("removeMark",e9);class fa extends e5{constructor(a,b){super(),this.pos=a,this.mark=b}apply(a){let b=a.nodeAt(this.pos);if(!b)return e6.fail("No node at mark step's position");let c=b.type.create(b.attrs,null,this.mark.addToSet(b.marks));return e6.fromReplace(a,this.pos,this.pos+1,new el(ef.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 fa(this.pos,b.marks[c]);return new fa(this.pos,this.mark)}}return new fb(this.pos,this.mark)}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new fa(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 fa(b.pos,a.markFromJSON(b.mark))}}e5.jsonID("addNodeMark",fa);class fb extends e5{constructor(a,b){super(),this.pos=a,this.mark=b}apply(a){let b=a.nodeAt(this.pos);if(!b)return e6.fail("No node at mark step's position");let c=b.type.create(b.attrs,null,this.mark.removeFromSet(b.marks));return e6.fromReplace(a,this.pos,this.pos+1,new el(ef.from(c),0,+!b.isLeaf))}invert(a){let b=a.nodeAt(this.pos);return b&&this.mark.isInSet(b.marks)?new fa(this.pos,this.mark):this}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new fb(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 fb(b.pos,a.markFromJSON(b.mark))}}e5.jsonID("removeNodeMark",fb);class fc extends e5{constructor(a,b,c,d=!1){super(),this.from=a,this.to=b,this.slice=c,this.structure=d}apply(a){return this.structure&&fe(a,this.from,this.to)?e6.fail("Structure replace would overwrite content"):e6.fromReplace(a,this.from,this.to,this.slice)}getMap(){return new e2([this.from,this.to-this.from,this.slice.size])}invert(a){return new fc(this.from,this.from+this.slice.size,a.slice(this.from,this.to))}map(a){let b=a.mapResult(this.to,-1),c=this.from==this.to&&fc.MAP_BIAS<0?b:a.mapResult(this.from,1);return c.deletedAcross&&b.deletedAcross?null:new fc(c.pos,Math.max(c.pos,b.pos),this.slice,this.structure)}merge(a){if(!(a instanceof fc)||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?el.empty:new el(a.slice.content.append(this.slice.content),a.slice.openStart,this.slice.openEnd);return new fc(a.from,this.to,b,this.structure)}{let b=this.slice.size+a.slice.size==0?el.empty:new el(this.slice.content.append(a.slice.content),this.slice.openStart,a.slice.openEnd);return new fc(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 fc(b.from,b.to,el.fromJSON(a,b.slice),!!b.structure)}}fc.MAP_BIAS=1,e5.jsonID("replace",fc);class fd extends e5{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&&(fe(a,this.from,this.gapFrom)||fe(a,this.gapTo,this.to)))return e6.fail("Structure gap-replace would overwrite content");let b=a.slice(this.gapFrom,this.gapTo);if(b.openStart||b.openEnd)return e6.fail("Gap is not a flat range");let c=this.slice.insertAt(this.insert,b.content);return c?e6.fromReplace(a,this.from,this.to,c):e6.fail("Content does not fit in gap")}getMap(){return new e2([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 fd(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 fd(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 fd(b.from,b.to,b.gapFrom,b.gapTo,el.fromJSON(a,b.slice),b.insert,!!b.structure)}}function fe(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 ff(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 e9(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 el(ef.from(c.schema.text(" ",c.allowedMarks(i.marks))),0,0)),g.push(new fc(h+a.index,h+a.index+a[0].length,d))}}else g.push(new fc(h,j,el.empty));h=j}if(!d.validEnd){let b=d.fillBefore(ef.empty,!0);a.replace(h,h,new el(b,0,0))}for(let b=g.length-1;b>=0;b--)a.step(g[b])}function fg(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 fh(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(fi).concat({type:b,attrs:c}).concat(f.map(fi)):null}function fi(a){return{type:a,attrs:null}}function fj(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 fk(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 fl(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 fm(a,b){let c=a.resolve(b),d=c.index();return fn(c.nodeBefore,c.nodeAfter)&&c.parent.canReplace(d,d+1)}function fn(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 fo(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&&fn(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 fp(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 fq(a,b,c=b,d=el.empty){if(b==c&&!d.size)return null;let e=a.resolve(b),f=a.resolve(c);return fr(e,f,d)?new fc(b,c,d):new fs(e,f,d).fit()}function fr(a,b,c){return!c.openStart&&!c.openEnd&&a.start()==b.start()&&a.parent.canReplace(a.index(),b.index(),c.content)}e5.jsonID("replaceAround",fd);class fs{constructor(a,b,c){this.$from=a,this.$to=b,this.unplaced=c,this.frontier=[],this.placed=ef.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=ef.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 el(e,f,g);return a>-1?new fd(c.pos,a,this.$to.pos,this.$to.end(),h,b):h.size||c.pos!=this.$to.pos?new fc(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=fv(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(ef.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=fv(a,b);return!!d.childCount&&!d.firstChild.isLeaf&&(this.unplaced=new el(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=fv(a,b);if(d.childCount<=1&&b>0){let e=a.size-b<=b+d.size;this.unplaced=new el(ft(a,b-1,1),b-1,e?b-1:c)}else this.unplaced=new el(ft(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(ef.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=fu(this.placed,b,ef.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?el.empty:new el(ft(f.content,a-1,1),a-1,m<0?f.openEnd:a-1):new el(ft(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||!fw(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){c: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=fw(a,b,d,c,e);if(f){for(let c=b-1;c>=0;c--){let{match:b,type:d}=this.frontier[c],e=fw(a,c,d,b,!0);if(!e||e.childCount)continue c}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=fu(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=fu(this.placed,this.depth,ef.from(a.create(b,c))),this.frontier.push({type:a,match:a.contentMatch})}closeFrontierNode(){let a=this.frontier.pop().match.fillBefore(ef.empty,!0);a.childCount&&(this.placed=fu(this.placed,this.frontier.length,a))}}function ft(a,b,c){return 0==b?a.cutByIndex(c,a.childCount):a.replaceChild(0,a.firstChild.copy(ft(a.firstChild.content,b-1,c)))}function fu(a,b,c){return 0==b?a.append(c):a.replaceChild(a.childCount-1,a.lastChild.copy(fu(a.lastChild.content,b-1,c)))}function fv(a,b){for(let c=0;c<b;c++)a=a.firstChild.content;return a}function fw(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 fx(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 fy extends e5{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 e6.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 e6.fromReplace(a,this.pos,this.pos+1,new el(ef.from(d),0,+!b.isLeaf))}getMap(){return e2.empty}invert(a){return new fy(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 fy(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 fy(b.pos,b.attr,b.value)}}e5.jsonID("attr",fy);class fz extends e5{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 e6.ok(c)}getMap(){return e2.empty}invert(a){return new fz(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 fz(b.attr,b.value)}}e5.jsonID("docAttr",fz);let fA=class extends Error{};(fA=function a(b){let c=Error.call(this,b);return c.__proto__=a.prototype,c}).prototype=Object.create(Error.prototype),fA.prototype.constructor=fA,fA.prototype.name="TransformError";class fB{constructor(a){this.doc=a,this.steps=[],this.docs=[],this.mapping=new e3}get before(){return this.docs.length?this.docs[0]:this.doc}step(a){let b=this.maybeStep(a);if(b.failed)throw new fA(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=el.empty){let d=fq(this.doc,a,b,c);return d&&this.step(d),this}replaceWith(a,b,c){return this.replace(a,b,new el(ef.from(c),0,0))}delete(a,b){return this.replace(a,b,el.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(fr(e,f,d))return a.step(new fc(b,c,d));let g=fx(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 el(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(ef.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 el(ef.from(c),0,0)),this}deleteRange(a,b){return!function(a,b,c){let d=a.doc.resolve(b),e=a.doc.resolve(c);if(d.parent.isTextblock&&e.parent.isTextblock&&d.start()!=e.start()&&0==d.parentOffset&&0==e.parentOffset){let f=d.sharedDepth(c),g=!1;for(let a=d.depth;a>f;a--)d.node(a).type.spec.isolating&&(g=!0);for(let a=e.depth;a>f;a--)e.node(a).type.spec.isolating&&(g=!0);if(!g){for(let a=d.depth;a>0&&b==d.start(a);a--)b=d.before(a);for(let a=e.depth;a>0&&c==e.start(a);a--)c=e.before(a);d=a.doc.resolve(b),e=a.doc.resolve(c)}}let f=fx(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=ef.empty,l=0;for(let a=f,b=!1;a>c;a--)b||d.index(a)>0?(b=!0,k=ef.from(d.node(a).copy(k)),l++):i--;let m=ef.empty,n=0;for(let a=f,b=!1;a>c;a--)b||e.after(a+1)<e.end(a)?(b=!0,m=ef.from(e.node(a).copy(m)),n++):j++;a.step(new fd(i,j,g,h,new el(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);fk(a,d.node(),d.before(),h)}g.inlineContent&&ff(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 fc(j,i.map(b+c,-1),el.empty,!0)),!0===d){let b=a.doc.resolve(j);fj(a,b.node(),b.before(),a.steps.length)}}(this,a,b),this}wrap(a,b){return!function(a,b,c){let d=ef.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=ef.from(c[a].type.create(c[a].attrs,d))}let e=b.start,f=b.end;a.step(new fd(e,f,e,f,new el(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&&fk(e,a,b,f),ff(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 fd(h,i,h+1,i-1,new el(ef.from(c.create(l,null,a.marks)),0,0),1,!0)),!0===d&&fj(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 fd(b,b+f.nodeSize,b+1,b+f.nodeSize-1,new el(ef.from(g),0,0),1,!0))}(this,a,b,c,d),this}setNodeAttribute(a,b,c){return this.step(new fy(a,b,c)),this}setDocAttribute(a,b){return this.step(new fz(a,b)),this}addNodeMark(a,b){return this.step(new fa(a,b)),this}removeNodeMark(a,b){let c=this.doc.nodeAt(a);if(!c)throw RangeError("No node at position "+a);if(b instanceof ej)b.isInSet(c.marks)&&this.step(new fb(a,b));else{let d=c.marks,e,f=[];for(;e=b.isInSet(d);)f.push(new fb(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=ef.empty,g=ef.empty;for(let a=e.depth,b=e.depth-c,h=c-1;a>b;a--,h--){f=ef.from(e.node(a).copy(f));let b=d&&d[h];g=ef.from(b?b.type.create(b.attrs,g):e.node(a).copy(g))}a.step(new fc(b,b,new el(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 e9(j,l,k[a])));f&&f.to==j?f.to=l:h.push(f=new e8(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 eM){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 e9(a.from,a.to,a.style))),this}clearIncompatible(a,b,c){return ff(this,a,b,c),this}}let fC=Object.create(null);class fD{constructor(a,b,c){this.$anchor=a,this.$head=b,this.ranges=c||[new fE(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=el.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?el.empty:b),0==g&&fO(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),fO(a,c,b.isInline?-1:1))}}static findFrom(a,b,c=!1){let d=a.parent.inlineContent?new fH(a):fN(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?fN(a.node(0),a.node(d),a.before(d+1),a.index(d),b,c):fN(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 fL(a.node(0))}static atStart(a){return fN(a,a,0,0,1)||new fL(a)}static atEnd(a){return fN(a,a,a.content.size,a.childCount,-1)||new fL(a)}static fromJSON(a,b){if(!b||!b.type)throw RangeError("Invalid input for Selection.fromJSON");let c=fC[b.type];if(!c)throw RangeError(`No selection type ${b.type} defined`);return c.fromJSON(a,b)}static jsonID(a,b){if(a in fC)throw RangeError("Duplicate use of selection JSON ID "+a);return fC[a]=b,b.prototype.jsonID=a,b}getBookmark(){return fH.between(this.$anchor,this.$head).getBookmark()}}fD.prototype.visible=!0;class fE{constructor(a,b){this.$from=a,this.$to=b}}let fF=!1;function fG(a){fF||a.parent.inlineContent||(fF=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+a.parent.type.name+")"))}class fH extends fD{constructor(a,b=a){fG(a),fG(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 fD.near(c);let d=a.resolve(b.map(this.anchor));return new fH(d.parent.inlineContent?d:c,c)}replace(a,b=el.empty){if(super.replace(a,b),b==el.empty){let b=this.$from.marksAcross(this.$to);b&&a.ensureMarks(b)}}eq(a){return a instanceof fH&&a.anchor==this.anchor&&a.head==this.head}getBookmark(){return new fI(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 fH(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=fD.findFrom(b,c,!0)||fD.findFrom(b,-c,!0);if(!a)return fD.near(b,c);b=a.$head}return a.parent.inlineContent||(0==d?a=b:(a=(fD.findFrom(a,-c,!0)||fD.findFrom(a,c,!0)).$anchor).pos<b.pos!=d<0&&(a=b)),new fH(a,b)}}fD.jsonID("text",fH);class fI{constructor(a,b){this.anchor=a,this.head=b}map(a){return new fI(a.map(this.anchor),a.map(this.head))}resolve(a){return fH.between(a.resolve(this.anchor),a.resolve(this.head))}}class fJ extends fD{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?fD.near(e):new fJ(e)}content(){return new el(ef.from(this.node),0,0)}eq(a){return a instanceof fJ&&a.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new fK(this.anchor)}static fromJSON(a,b){if("number"!=typeof b.anchor)throw RangeError("Invalid input for NodeSelection.fromJSON");return new fJ(a.resolve(b.anchor))}static create(a,b){return new fJ(a.resolve(b))}static isSelectable(a){return!a.isText&&!1!==a.type.spec.selectable}}fJ.prototype.visible=!1,fD.jsonID("node",fJ);class fK{constructor(a){this.anchor=a}map(a){let{deleted:b,pos:c}=a.mapResult(this.anchor);return b?new fI(c,c):new fK(c)}resolve(a){let b=a.resolve(this.anchor),c=b.nodeAfter;return c&&fJ.isSelectable(c)?new fJ(b):fD.near(b)}}class fL extends fD{constructor(a){super(a.resolve(0),a.resolve(a.content.size))}replace(a,b=el.empty){if(b==el.empty){a.delete(0,a.doc.content.size);let b=fD.atStart(a.doc);b.eq(a.selection)||a.setSelection(b)}else super.replace(a,b)}toJSON(){return{type:"all"}}static fromJSON(a){return new fL(a)}map(a){return new fL(a)}eq(a){return a instanceof fL}getBookmark(){return fM}}fD.jsonID("all",fL);let fM={map(){return this},resolve:a=>new fL(a)};function fN(a,b,c,d,e,f=!1){if(b.inlineContent)return fH.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&&fJ.isSelectable(d))return fJ.create(a,c-(e<0?d.nodeSize:0))}else{let b=fN(a,d,c+e,e<0?d.childCount:0,e,f);if(b)return b}c+=d.nodeSize*e}return null}function fO(a,b,c){let d,e=a.steps.length-1;if(e<b)return;let f=a.steps[e];(f instanceof fc||f instanceof fd)&&(a.mapping.maps[e].forEach((a,b,c,e)=>{null==d&&(d=e)}),a.setSelection(fD.near(a.doc.resolve(d),c)))}class fP extends fB{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 ej.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)||ej.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(fD.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 fQ(a,b){return b&&a?a.bind(b):a}class fR{constructor(a,b,c){this.name=a,this.init=fQ(b.init,c),this.apply=fQ(b.apply,c)}}let fS=[new fR("doc",{init:a=>a.doc||a.schema.topNodeType.createAndFill(),apply:a=>a.doc}),new fR("selection",{init:(a,b)=>a.selection||fD.atStart(b.doc),apply:a=>a.selection}),new fR("storedMarks",{init:a=>a.storedMarks||null,apply:(a,b,c,d)=>d.selection.$cursor?a.storedMarks:null}),new fR("scrollToSelection",{init:()=>0,apply:(a,b)=>a.scrolledIntoView?b+1:b})];class fT{constructor(a,b){this.schema=a,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=fS.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 fR(a.key,a.spec.state,a))})}}class fU{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 fU(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 fP(this)}static create(a){let b=new fT(a.doc?a.doc.type.schema:a.schema,a.plugins),c=new fU(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 fT(this.schema,a.plugins),c=b.fields,d=new fU(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 fT(a.schema,a.plugins),e=new fU(d);return d.fields.forEach(d=>{if("doc"==d.name)e.doc=ey.fromJSON(a.schema,b.doc);else if("selection"==d.name)e.selection=fD.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 fV{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:fX("plugin")}getState(a){return a[this.key]}}let fW=Object.create(null);function fX(a){return a in fW?a+"$"+ ++fW[a]:(fW[a]=0,a+"$")}class fY{constructor(a="key"){this.key=fX(a)}get(a){return a.config.pluginsByKey[this.key]}getState(a){return a[this.key]}}let fZ=function(a){for(var b=0;;b++)if(!(a=a.previousSibling))return b},f$=function(a){let b=a.assignedSlot||a.parentNode;return b&&11==b.nodeType?b.host:b},f_=null,f0=function(a,b,c){let d=f_||(f_=document.createRange());return d.setEnd(a,null==c?a.nodeValue.length:c),d.setStart(a,b||0),d},f1=function(){f_=null},f2=function(a,b,c,d){return c&&(f4(a,b,c,d,-1)||f4(a,b,c,d,1))},f3=/^(img|br|input|textarea|hr)$/i;function f4(a,b,c,d,e){for(var f;;){if(a==c&&b==d)return!0;if(b==(e<0?0:f5(a))){let c=a.parentNode;if(!c||1!=c.nodeType||f6(a)||f3.test(a.nodeName)||"false"==a.contentEditable)return!1;b=fZ(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?f5(a):0}}}function f5(a){return 3==a.nodeType?a.nodeValue.length:a.childNodes.length}function f6(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 f7=function(a){return a.focusNode&&f2(a.focusNode,a.focusOffset,a.anchorNode,a.anchorOffset)};function f8(a,b){let c=document.createEvent("Event");return c.initEvent("keydown",!0,!0),c.keyCode=a,c.key=c.code=b,c}let f9="u">typeof navigator?navigator:null,ga="u">typeof document?document:null,gb=f9&&f9.userAgent||"",gc=/Edge\/(\d+)/.exec(gb),gd=/MSIE \d/.exec(gb),ge=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(gb),gf=!!(gd||ge||gc),gg=gd?document.documentMode:ge?+ge[1]:gc?+gc[1]:0,gh=!gf&&/gecko\/(\d+)/i.test(gb);gh&&(/Firefox\/(\d+)/.exec(gb)||[0,0])[1];let gi=!gf&&/Chrome\/(\d+)/.exec(gb),gj=!!gi,gk=gi?+gi[1]:0,gl=!gf&&!!f9&&/Apple Computer/.test(f9.vendor),gm=gl&&(/Mobile\/\w+/.test(gb)||!!f9&&f9.maxTouchPoints>2),gn=gm||!!f9&&/Mac/.test(f9.platform),go=!!f9&&/Win/.test(f9.platform),gp=/Android \d/.test(gb),gq=!!ga&&"webkitFontSmoothing"in ga.documentElement.style,gr=gq?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function gs(a,b){return"number"==typeof a?a:a[b]}function gt(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=f$(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+gs(d,"top")?j=-(h.top-b.top+gs(e,"top")):b.bottom>h.bottom-gs(d,"bottom")&&(j=b.bottom-b.top>h.bottom-h.top?b.top+gs(e,"top")-h.top:b.bottom-h.bottom+gs(e,"bottom")),b.left<h.left+gs(d,"left")?i=-(h.left-b.left+gs(e,"left")):b.right>h.right-gs(d,"right")&&(i=b.right-h.right+gs(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:f$(g)}}function gu(a){let b=[],c=a.ownerDocument;for(let d=a;d&&(b.push({dom:d,top:d.scrollTop,left:d.scrollLeft}),a!=c);d=f$(d));return b}function gv(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 gw=null;function gx(a,b){return a.left>=b.left-1&&a.left<=b.right+1&&a.top>=b.top-1&&a.top<=b.bottom+1}function gy(a){return a.top<a.bottom||a.left<a.right}function gz(a,b){let c=a.getClientRects();if(c.length){let a=c[b<0?0:c.length-1];if(gy(a))return a}return Array.prototype.find.call(c,gy)||a.getBoundingClientRect()}let gA=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function gB(a,b,c){let{node:d,offset:e,atom:f}=a.docView.domFromPos(b,c<0?-1:1),g=gq||gh;if(3==d.nodeType)if(g&&(gA.test(d.nodeValue)||(c<0?!e:e==d.nodeValue.length))){let a=gz(f0(d,e,e),c);if(gh&&e&&/\s/.test(d.nodeValue[e-1])&&e<d.nodeValue.length){let b=gz(f0(d,e-1,e-1),-1);if(b.top==a.top){let c=gz(f0(d,e,e+1),-1);if(c.top!=a.top)return gC(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++,gC(gz(f0(d,a,b),f),f<0)}if(!a.state.doc.resolve(b-(f||0)).parent.inlineContent){if(null==f&&e&&(c<0||e==f5(d))){let a=d.childNodes[e-1];if(1==a.nodeType)return gD(a.getBoundingClientRect(),!1)}if(null==f&&e<f5(d)){let a=d.childNodes[e];if(1==a.nodeType)return gD(a.getBoundingClientRect(),!0)}return gD(d.getBoundingClientRect(),c>=0)}if(null==f&&e&&(c<0||e==f5(d))){let a=d.childNodes[e-1],b=3==a.nodeType?f0(a,f5(a)-!g):1!=a.nodeType||"BR"==a.nodeName&&a.nextSibling?null:a;if(b)return gC(gz(b,1),!1)}if(null==f&&e<f5(d)){let a=d.childNodes[e];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let b=a?3==a.nodeType?f0(a,0,+!g):1==a.nodeType?a:null:null;if(b)return gC(gz(b,-1),!0)}return gC(gz(3==d.nodeType?f0(d):d,-c),c>=0)}function gC(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 gD(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 gE(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 gF=/[\u0590-\u08ac]/,gG=null,gH=null,gI=!1;class gJ{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>fZ(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 gQ){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 gK&&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?fZ(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?fZ(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=fZ(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=fZ(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((gh||gl)&&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:fZ(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(gh&&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&&gl)&&f2(g.node,g.offset,j.anchorNode,j.anchorOffset)&&f2(h.node,h.offset,j.focusNode,j.focusOffset))return;let l=!1;if((i.extend||a==b)&&!(k&&gh)){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 gK extends gJ{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 gL extends gJ{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 gM extends gJ{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=eY.renderSpec(document,b.type.spec.toDOM(b,c),null,b.attrs)),new gM(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=gM.create(this.parent,this.mark,!0,c),e=this.children,f=this.size;b<f&&(e=g_(e,b,f,c)),a>0&&(e=g_(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 gN extends gJ{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=eY.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=gW(j,c,b),i)?h=new gR(a,b,c,d,j,k||null,l,i,e,f+1):b.isText?new gP(a,b,c,d,j,l,e):new gN(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=()=>ef.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)&&gX(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 gZ(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(g$);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?ej.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=gY(e),f=!0;e=e.nextSibling}else f=!0,b.insertBefore(i,e);if(h instanceof gM){let c=e?e.previousSibling:b.lastChild;a(h.contentDOM,h.children,d),e=c?c.nextSibling:b.firstChild}}for(;e;)e=gY(e),f=!0;f&&d.trackWrites==b&&(d.trackWrites=null)}(this.contentDOM,this.children,a),gm&&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 fH)||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 gL(this,e,b,d);a.input.compositionNodes.push(f),this.children=g_(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(gX(a,this.outerDeco))return;let b=1!=this.nodeDOM.nodeType,c=this.dom;this.dom=gV(this.dom,this.nodeDOM,gU(this.outerDeco,this.node,b),gU(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 gO(a,b,c,d,e){gW(d,b,a);let f=new gN(void 0,a,b,c,d,d,d,e,0);return f.contentDOM&&f.updateChildren(e,0),f}class gP extends gN{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 gP(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 gQ extends gJ{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 gR extends gN{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 gS=function(a){a&&(this.nodeName=a)};gS.prototype=Object.create(null);let gT=[new gS];function gU(a,b,c){if(0==a.length)return gT;let d=c?gT[0]:new gS,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 gS(g.nodeName)),g){let f=g[a];null!=f&&(c&&1==e.length&&e.push(d=new gS(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 gV(a,b,c,d){if(c==gT&&d==gT)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=gT[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||gT[0],f)}return e}function gW(a,b,c){return gV(a,a,gT,gU(b,c,1!=a.nodeType))}function gX(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 gY(a){let b=a.nextSibling;return a.parentNode.removeChild(a),b}class gZ{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=[];d:for(;e>0;){let h;for(;;)if(d){let a=c.children[d-1];if(a instanceof gM)c=a,d=a.children.length;else{h=a,d--;break}}else if(c==b)break d;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=gM.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 gN){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&&gX(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)||!gX(c,a.outerDeco)||!d.eq(a.innerDeco))return null;let g=gN.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=gN.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 gK(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 gM;)a=(b=a).children[b.children.length-1];(!a||!(a instanceof gP)||/\n$/.test(a.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(a.node.text))&&((gl||gj)&&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 gQ(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 g$(a,b){return a.type.side-b.type.side}function g_(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 g0(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(f7(c)){for(i=g;e&&!e.node;)e=e.parent;let a=e.node;if(e&&a.isAtom&&fJ.isSelectable(a)&&e.parent&&!(a.isInline&&function(a,b,c){for(let d=0==b,e=b==f5(a);d||e;){if(a==c)return!0;let b=fZ(a);if(!(a=a.parentNode))return!1;d=d&&0==b,e=e&&b==f5(a)}}(c.focusNode,c.focusOffset,e.dom))){let a=e.posBefore;j=new fJ(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=g9(a,k,h,c)}return j}function g1(a){return a.editable?a.hasFocus():hb(a)&&document.activeElement&&document.activeElement.contains(a.dom)}function g2(a,b=!1){let c=a.state.selection;if(g7(a,c),g1(a)){if(!b&&a.input.mouseDown&&a.input.mouseDown.allowDefault&&gj){let b=a.domSelectionRange(),c=a.domObserver.currentSelection;if(b.anchorNode&&c.anchorNode&&f2(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,fZ(c)+1):b.collapse(c,0),!d&&!a.state.selection.visible&&gf&&gg<=11&&(c.disabled=!0,c.disabled=!1)}(a);else{var d;let e,f,g,h,{anchor:i,head:j}=c,k,l;g3&&!(c instanceof fH)&&(c.$from.parent.inlineContent||(k=g4(a,c.from)),c.empty||c.$from.parent.inlineContent||(l=g4(a,c.to))),a.docView.setSelection(i,j,a,b),g3&&(k&&g6(k),l&&g6(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(()=>{(!g1(d)||d.state.selection.visible)&&d.dom.classList.remove("ProseMirror-hideselection")},20))})))}a.domObserver.setCurSelection(),a.domObserver.connectSelection()}}let g3=gl||gj&&gk<63;function g4(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(gl&&e&&"false"==e.contentEditable)return g5(e);if((!e||"false"==e.contentEditable)&&(!f||"false"==f.contentEditable)){if(e)return g5(e);else if(f)return g5(f)}}function g5(a){return a.contentEditable="true",gl&&a.draggable&&(a.draggable=!1,a.wasDraggable=!0),a}function g6(a){a.contentEditable="false",a.wasDraggable&&(a.draggable=!0,a.wasDraggable=null)}function g7(a,b){if(b instanceof fJ){let c=a.docView.descAt(b.from);c!=a.lastSelectedViewDesc&&(g8(a),c&&c.selectNode(),a.lastSelectedViewDesc=c)}else g8(a)}function g8(a){a.lastSelectedViewDesc&&(a.lastSelectedViewDesc.parent&&a.lastSelectedViewDesc.deselectNode(),a.lastSelectedViewDesc=void 0)}function g9(a,b,c,d){return a.someProp("createSelectionBetween",d=>d(a,b,c))||fH.between(b,c,d)}function ha(a){return(!a.editable||!!a.hasFocus())&&hb(a)}function hb(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 hc(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&&fD.findFrom(f,b)}function hd(a,b){return a.dispatch(a.state.tr.setSelection(b).scrollIntoView()),!0}function he(a,b,c){let d=a.state.selection;if(d instanceof fH){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 hd(a,new fH(d.$anchor,f))}else if(!d.empty)return!1;else if(a.endOfTextblock(b>0?"forward":"backward")){let c=hc(a.state,b);return!!c&&c instanceof fJ&&hd(a,c)}else if(!(gn&&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)&&(fJ.isSelectable(e)?hd(a,new fJ(b<0?a.state.doc.resolve(c.pos-e.nodeSize):c)):!!gq&&hd(a,new fH(a.state.doc.resolve(b<0?g:g+e.nodeSize))))}}else{if(d instanceof fJ&&d.node.isInline)return hd(a,new fH(b>0?d.$to:d.$from));let c=hc(a.state,b);return!!c&&hd(a,c)}}function hf(a){return 3==a.nodeType?a.nodeValue.length:a.childNodes.length}function hg(a,b){let c=a.pmViewDesc;return c&&0==c.size&&(b<0||a.nextSibling||"BR"!=a.nodeName)}function hh(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(gh&&1==c.nodeType&&d<hf(c)&&hg(c.childNodes[d],-1)&&(g=!0);;)if(d>0)if(1!=c.nodeType)break;else{let a=c.childNodes[d-1];if(hg(a,-1))e=c,f=--d;else if(3==a.nodeType)d=(c=a).nodeValue.length;else break}else if(hi(c))break;else{let b=c.previousSibling;for(;b&&hg(b,-1);)e=c.parentNode,f=fZ(b),b=b.previousSibling;if(b)d=hf(c=b);else{if((c=c.parentNode)==a.dom)break;d=0}}g?hj(a,c,d):e&&hj(a,e,f)}(a):function(a){let b,c,d=a.domSelectionRange(),e=d.focusNode,f=d.focusOffset;if(!e)return;let g=hf(e);for(;;)if(f<g){if(1!=e.nodeType)break;if(hg(e.childNodes[f],1))b=e,c=++f;else break}else if(hi(e))break;else{let d=e.nextSibling;for(;d&&hg(d,1);)b=d.parentNode,c=fZ(d)+1,d=d.nextSibling;if(d)f=0,g=hf(e=d);else{if((e=e.parentNode)==a.dom)break;f=g=0}}b&&hj(a,b,c)}(a)}function hi(a){let b=a.pmViewDesc;return b&&b.node&&b.node.isBlock}function hj(a,b,c){if(3!=b.nodeType){let a,d;(d=function(a,b){for(;a&&b==a.childNodes.length&&!f6(a);)b=fZ(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&&!f6(a);)b=fZ(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(f7(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&&g2(a)},50)}function hk(a,b){let c=a.state.doc.resolve(b);if(!(gj||go)&&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 hl(a,b,c){let d=a.state.selection;if(d instanceof fH&&!d.empty||c.indexOf("s")>-1||gn&&c.indexOf("m")>-1)return!1;let{$from:e,$to:f}=d;if(!e.parent.inlineContent||a.endOfTextblock(b<0?"up":"down")){let c=hc(a.state,b);if(c&&c instanceof fJ)return hd(a,c)}if(!e.parent.inlineContent){let c=b<0?e:f,g=d instanceof fL?fD.near(c,b):fD.findFrom(c,b);return!!g&&hd(a,g)}return!1}function hm(a,b){if(!(a.state.selection instanceof fH))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 hn(a,b,c){a.domObserver.stop(),b.contentEditable=c,a.domObserver.start()}function ho(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")||eY.fromSchema(a.state.schema),h=hw(),i=h.createElement("div");i.appendChild(g.serializeFragment(d,{document:h}));let j=i.firstChild,k,l=0;for(;j&&1==j.nodeType&&(k=hu[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 hp(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 el(ef.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=eY.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=hw().createElement("div"),f=/<([a-z][^>\s]+)/i.exec(a),g;if((g=f&&hu[f[1].toLowerCase()])&&(a=g.map(a=>"<"+a+">").join("")+a+g.map(a=>"</"+a+">").reverse().join("")),e.innerHTML=(b=a,(c=window.trustedTypes)?(hx||(hx=c.defaultPolicy||c.createPolicy("ProseMirrorClipboard",{createHTML:a=>a})),hx.createHTML(b)):b),g)for(let a=0;a<g.length;a++)e=e.querySelector(g[a])||e;return e}(c),gq&&function(a){let b=a.querySelectorAll(gj?"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&&" "==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")||eP.fromSchema(a.state.schema)).parseSlice(f,{preserveWhitespace:!!(i||k),context:e,ruleFromNode:a=>"BR"!=a.nodeName||a.nextSibling||!a.parentNode||hq.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=ef.from(b.create(d[a+1],e)),f++,g++}return new el(e,f,g)}(ht(g,+k[1],+k[2]),k[4]);else if((g=el.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(ef.from(hr(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(ef.empty,!0);return b.copy(d.append(e))}(f[f.length-1],e.length));let c=hr(a,b);f.push(c),d=d.matchType(c.type),e=b}}),f)return ef.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=ht(g,a,b)}return a.someProp("transformPasted",b=>{g=b(g,a,i)}),g}let hq=/^(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 hr(a,b,c=0){for(let d=b.length-1;d>=c;d--)a=b[d].create(null,ef.from(a));return a}function hs(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=hs(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(ef.empty,!0))),a.replaceChild(b<0?0:a.childCount-1,g.copy(h))}function ht(a,b,c){return b<a.openStart&&(a=new el(hs(a.content,-1,b,a.openStart,0,a.openEnd),b,a.openEnd)),c<a.openEnd&&(a=new el(hs(a.content,1,c,a.openEnd,0,0),a.openStart,c)),a}let hu={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},hv=null;function hw(){return hv||(hv=document.implementation.createHTMLDocument("title"))}let hx=null,hy={},hz={},hA={touchstart:!0,touchmove:!0};class hB{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 hC(a,b){a.input.lastSelectionOrigin=b,a.input.lastSelectionTime=Date.now()}function hD(a){a.someProp("handleDOMEvents",b=>{for(let c in b)a.input.eventHandlers[c]||a.dom.addEventListener(c,a.input.eventHandlers[c]=b=>hE(a,b))})}function hE(a,b){return a.someProp("handleDOMEvents",c=>{let d=c[b.type];return!!d&&(d(a,b)||b.defaultPrevented)})}function hF(a){return{left:a.clientX,top:a.clientY}}function hG(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 hH(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)}hz.keydown=(a,b)=>{if((a.input.shiftKey=16==b.keyCode||b.shiftKey,!hK(a,b))&&(a.input.lastKeyCode=b.keyCode,a.input.lastKeyCodeTime=Date.now(),!gp||!gj||13!=b.keyCode))if(229!=b.keyCode&&a.domObserver.forceFlush(),!gm||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||gn&&72==d&&"c"==e)return hm(a,-1)||hh(a,-1);if(46==d&&!b.shiftKey||gn&&68==d&&"c"==e)return hm(a,1)||hh(a,1);if(13==d||27==d)return!0;if(37==d||gn&&66==d&&"c"==e){let b=37==d?"ltr"==hk(a,a.state.selection.from)?-1:1:-1;return he(a,b,e)||hh(a,b)}if(39==d||gn&&70==d&&"c"==e){let b=39==d?"ltr"==hk(a,a.state.selection.from)?1:-1:1;return he(a,b,e)||hh(a,b)}else if(38==d||gn&&80==d&&"c"==e)return hl(a,-1,e)||hh(a,-1);else if(40==d||gn&&78==d&&"c"==e)return function(a){if(!gl||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;hn(a,c,"true"),setTimeout(()=>hn(a,c,"false"),20)}return!1}(a)||hl(a,1,e)||hh(a,1);else if(e==(gn?"m":"c")&&(66==d||73==d||89==d||90==d))return!0;return!1}(a,b)?b.preventDefault():hC(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,f8(13,"Enter"))),a.input.lastIOSEnter=0)},200)}},hz.keyup=(a,b)=>{16==b.keyCode&&(a.input.shiftKey=!1)},hz.keypress=(a,b)=>{if(hK(a,b)||!b.charCode||b.ctrlKey&&!b.altKey||gn&&b.metaKey)return;if(a.someProp("handleKeyPress",c=>c(a,b)))return void b.preventDefault();let c=a.state.selection;if(!(c instanceof fH)||!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 hI=gn?"metaKey":"ctrlKey";hy.mousedown=(a,b)=>{var c;let d,e;a.input.shiftKey=b.shiftKey;let f=hO(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[hI]&&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(hF(b));i&&("singleClick"==h?(a.input.mouseDown&&a.input.mouseDown.done(),a.input.mouseDown=new hJ(a,i,b,!!f)):("doubleClick"==h?function(a,b,c,d){return hG(a,"handleDoubleClickOn",b,c,d)||a.someProp("handleDoubleClick",c=>c(a,b,d))}:function(a,b,c,d){return hG(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&&(hH(a,fH.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)hH(a,fH.create(d,f+1,f+1+c.content.size),"pointer");else{if(!fJ.isSelectable(c))continue;hH(a,fJ.create(d,f),"pointer")}return!0}}(a,c,d)})(a,i.pos,i.inside,b)?b.preventDefault():hC(a,"pointer"))};class hJ{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[hI],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 fJ&&i.from<=f&&i.to>f)&&(this.mightDrag={node:e,pos:f,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&gh&&!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)),hC(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(()=>g2(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(hF(a))),this.updateAllowDefault(a),this.allowDefault||!b)hC(this.view,"pointer");else{var c,d,e,f;(c=this.view,d=b.pos,e=b.inside,f=this.selectNode,hG(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 fJ&&(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(fJ.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&&(hH(a,fJ.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&&fJ.isSelectable(d))&&(hH(a,new fJ(c),"pointer"),!0)}(c,e)))?a.preventDefault():0==a.button&&(this.flushed||gl&&this.mightDrag&&!this.mightDrag.node.isAtom||gj&&!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)))?(hH(this.view,fD.near(this.view.state.doc.resolve(b.pos)),"pointer"),a.preventDefault()):hC(this.view,"pointer")}}move(a){this.updateAllowDefault(a),hC(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 hK(a,b){return!!a.composing||!!(gl&&500>Math.abs(b.timeStamp-a.input.compositionEndedAt))&&(a.input.compositionEndedAt=-2e8,!0)}hy.touchstart=a=>{a.input.lastTouch=Date.now(),hO(a),hC(a,"pointer")},hy.touchmove=a=>{a.input.lastTouch=Date.now(),hC(a,"pointer")},hy.contextmenu=a=>hO(a);let hL=gp?5e3:-1;function hM(a,b){clearTimeout(a.input.composingTimeout),b>-1&&(a.input.composingTimeout=setTimeout(()=>hO(a),b))}function hN(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 hO(a,b=!1){if(!gp||!(a.domObserver.flushingSoon>=0)){if(a.domObserver.forceFlush(),hN(a),b||a.docView&&a.docView.dirty){let c=g0(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}}hz.compositionstart=hz.compositionupdate=a=>{if(!a.composing){a.domObserver.flush();let{state:b}=a,c=b.selection.$to;if(b.selection instanceof fH&&(b.storedMarks||!c.textOffset&&c.parentOffset&&c.nodeBefore.marks.some(a=>!1===a.type.spec.inclusive)||gj&&go&&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(),hO(a,!0),a.markCursor=null;else if(hO(a,!b.selection.empty),gh&&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}hM(a,hL)},hz.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++,hM(a,20))};let hP=gf&&gg<15||gm&&gr<604;function hQ(a,b,c,d,e){let f=hp(a,b,c,d,a.state.selection.$from);if(a.someProp("handlePaste",b=>b(a,e,f||el.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 hR(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," "):""}hy.copy=hz.cut=(a,b)=>{let c=a.state.selection,d="cut"==b.type;if(c.empty)return;let e=hP?null:b.clipboardData,{dom:f,text:g}=ho(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"))},hz.paste=(a,b)=>{if(a.composing&&!gp)return;let c=hP?null:b.clipboardData,d=a.input.shiftKey&&45!=a.input.lastKeyCode;c&&hQ(a,hR(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?hQ(a,d.value,null,e,b):hQ(a,d.textContent,d.innerHTML,e,b)},50)}(a,b)};class hS{constructor(a,b,c){this.slice=a,this.move=b,this.node=c}}let hT=gn?"altKey":"ctrlKey";function hU(a,b){let c;return a.someProp("dragCopies",a=>{c=c||a(b)}),null!=c?!c:!b[hT]}for(let a in hy.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(hF(b));if(f&&f.pos>=e.from&&f.pos<=(e instanceof fJ?e.to-1:e.to));else if(d&&d.mightDrag)c=fJ.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=fJ.create(a.state.doc,d.posBefore))}let g=(c||a.state.selection).content(),{dom:h,text:i,slice:j}=ho(a,g);b.dataTransfer.files.length&&gj&&!(gk>120)||b.dataTransfer.clearData(),b.dataTransfer.setData(hP?"Text":"text/html",h.innerHTML),b.dataTransfer.effectAllowed="copyMove",hP||b.dataTransfer.setData("text/plain",i),a.dragging=new hS(j,hU(a,b),c)},hy.dragend=a=>{let b=a.dragging;window.setTimeout(()=>{a.dragging==b&&(a.dragging=null)},50)},hz.dragover=hz.dragenter=(a,b)=>b.preventDefault(),hz.drop=(a,b)=>{try{!function(a,b,c){if(!b.dataTransfer)return;let d=a.posAtCoords(hF(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=hp(a,hR(b.dataTransfer),hP?null:b.dataTransfer.getData("text/html"),!1,e);let g=!!(c&&hU(a,b));if(a.someProp("handleDrop",c=>c(a,b,f||el.empty,g)))return b.preventDefault();if(!f)return;b.preventDefault();let h=f?fp(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&&fJ.isSelectable(f.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(f.content.firstChild))i.setSelection(new fJ(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(g9(a,m,i.doc.resolve(b)))}a.focus(),a.dispatch(i.setMeta("uiEvent","drop"))}(a,b,a.dragging)}finally{a.dragging=null}},hy.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())&&g2(a)},20))},hy.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)},hy.beforeinput=(a,b)=>{if(gj&&gp&&"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,f8(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)}},hz)hy[a]=hz[a];function hV(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 hW{constructor(a,b){this.toDOM=a,this.spec=b||h_,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 hZ(e-c,e-c,this)}valid(){return!0}eq(a){return this==a||a instanceof hW&&(this.spec.key&&this.spec.key==a.spec.key||this.toDOM==a.toDOM&&hV(this.spec,a.spec))}destroy(a){this.spec.destroy&&this.spec.destroy(a)}}class hX{constructor(a,b){this.attrs=a,this.spec=b||h_}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 hZ(e,f,this)}valid(a,b){return b.from<b.to}eq(a){return this==a||a instanceof hX&&hV(this.attrs,a.attrs)&&hV(this.spec,a.spec)}static is(a){return a.type instanceof hX}destroy(){}}class hY{constructor(a,b){this.attrs=a,this.spec=b||h_}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 hZ(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 hY&&hV(this.attrs,a.attrs)&&hV(this.spec,a.spec)}destroy(){}}class hZ{constructor(a,b,c){this.from=a,this.to=b,this.type=c}copy(a,b){return new hZ(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 hZ(a,a,new hW(b,c))}static inline(a,b,c,d){return new hZ(a,b,new hX(c,d))}static node(a,b,c,d){return new hZ(a,b,new hY(c,d))}get spec(){return this.type.spec}get inline(){return this.type instanceof hX}get widget(){return this.type instanceof hW}}let h$=[],h_={};class h0{constructor(a,b){this.local=a.length?a:h$,this.children=b.length?b:h$}static create(a,b){return b.length?h6(b,a,0,h_):h1}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==h1||0==a.maps.length?this:this.mapInner(a,b,0,0,c||h_)}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!=h1?(h[b]=k,h[b+1]=l,h[b+2]=d):(h[b+1]=-2,i=!0)}else i=!0}if(i){let i=h6(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 h0(b.sort(h7),h)}(this.children,f||[],a,b,c,d,e):f?new h0(f.sort(h7),h$):h1}add(a,b){return b.length?this==h1?h0.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=h4(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,h6(h,a,g+1,h_)),e+=3}});let f=h3(e?h5(b):b,-c);for(let b=0;b<f.length;b++)f[b].type.valid(a,f[b])||f.splice(b--,1);return new h0(f.length?this.local.concat(f).sort(h7):this.local,d||this.children)}remove(a){return 0==a.length||this==h1?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!=h1?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 h0(d,c):h1}forChild(a,b){let c,d;if(this==h1)return this;if(b.isLeaf)return h0.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 hX){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 h0(d.sort(h7),h$);return c?new h2([a,c]):a}return c||h1}eq(a){if(this==a)return!0;if(!(a instanceof h0)||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 h8(this.localsInner(a))}localsInner(a){if(this==h1)return h$;if(a.inlineContent||!this.local.some(hX.is))return this.local;let b=[];for(let a=0;a<this.local.length;a++)this.local[a].type instanceof hX||b.push(this.local[a]);return b}forEachSet(a){a(this)}}h0.empty=new h0([],[]),h0.removeOverlap=h8;let h1=h0.empty;class h2{constructor(a){this.members=a}map(a,b){let c=this.members.map(c=>c.map(a,b,h_));return h2.from(c)}forChild(a,b){if(b.isLeaf)return h0.empty;let c=[];for(let d=0;d<this.members.length;d++){let e=this.members[d].forChild(a,b);e!=h1&&(e instanceof h2?c=c.concat(e.members):c.push(e))}return h2.from(c)}eq(a){if(!(a instanceof h2)||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?h8(c?b:b.sort(h7)):h$}static from(a){switch(a.length){case 0:return h1;case 1:return a[0];default:return new h2(a.every(a=>a instanceof h0)?a:a.reduce((a,b)=>a.concat(b instanceof h0?b:b.members),[]))}}forEachSet(a){for(let b=0;b<this.members.length;b++)this.members[b].forEachSet(a)}}function h3(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 hZ(e.from+b,e.to+b,e.type))}return c}function h4(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 h5(a){let b=[];for(let c=0;c<a.length;c++)null!=a[c]&&b.push(a[c]);return b}function h6(a,b,c,d){let e=[],f=!1;b.forEach((b,g)=>{let h=h4(a,b,g+c);if(h){f=!0;let a=h6(h,b,c+g+1,d);a!=h1&&e.push(g,g+b.nodeSize,a)}});let g=h3(f?h5(a):a,-c).sort(h7);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 h0(g,e):h1}function h7(a,b){return a.from-b.from||a.to-b.to}function h8(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),h9(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),h9(b,e,d.copy(f.from,d.to)));break}}return b}function h9(a,b,c){for(;b<a.length&&h7(c,a[b])>0;)b++;a.splice(b,0,c)}function ia(a){let b=[];return a.someProp("decorations",c=>{let d=c(a.state);d&&d!=h1&&b.push(d)}),a.cursorWrapper&&b.push(h0.create(a.state.doc,[a.cursorWrapper.deco])),h2.from(b)}let ib={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ic=gf&&gg<=11;class id{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 ie{constructor(a,b){this.view=a,this.handleDOMChange=b,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new id,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]);gf&&gg<=11&&b.some(a=>"childList"==a.type&&a.removedNodes.length||"characterData"==a.type&&a.oldValue.length>a.target.nodeValue.length)?this.flushSoon():gl&&a.composing&&b.some(a=>"childList"==a.type&&"TR"==a.target.nodeName)?(a.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),ic&&(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,ib)),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(ha(this.view)){if(this.suppressingSelectionUpdates)return g2(this.view);if(gf&&gg<=11&&!this.view.state.selection.empty){let a=this.view.domSelectionRange();if(a.focusNode&&f2(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=f$(c))b.add(c);for(let d=a.anchorNode;d;d=f$(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)&&ha(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;for(;b&&1==b.nodeType;){if("false"==b.contentEditable){a.parentNode.removeChild(a);break}b=b.firstChild}}}else if(gh&&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&&f7(d)&&(j=g0(b))&&j.eq(fD.near(b.state.doc.resolve(0),1))?(b.input.lastFocus=0,g2(b),this.currentSelection.set(d),b.scrollToSelection()):(f>-1||e)&&(f>-1&&(b.docView.markDirty(f,g),a=b,!ig.has(a)&&(ig.set(a,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(a.dom).whiteSpace))&&(a.requiresGeckoHackNode=gh,ih||(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."),ih=!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)||g2(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(gf&&gg<=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?fZ(d)+1:0,g=c.localPosFromDOM(a.target,f,-1),h=e&&e.parentNode==a.target?fZ(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 ig=new WeakMap,ih=!1;function ii(a,b){let c=b.startContainer,d=b.startOffset,e=b.endContainer,f=b.endOffset,g=a.domAtPos(a.state.selection.anchor);return f2(g.node,g.offset,e,f)&&([c,d,e,f]=[e,f,c,d]),{anchorNode:c,anchorOffset:d,focusNode:e,focusOffset:f}}function ij(a){let b=a.pmViewDesc;if(b)return b.parseRule();if("BR"==a.nodeName&&a.parentNode){if(gl&&/^(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||gl&&/^(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 ik=/^(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 il(a,b,c){return Math.max(c.anchor,c.head)>b.content.size?null:g9(a,b.resolve(c.anchor),b.resolve(c.head))}function im(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 io(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 ip{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 hB,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=b,this.state=b.state,this.directPlugins=b.plugins||[],this.directPlugins.forEach(iu),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=is(this),ir(this),this.nodeViews=it(this),this.docView=gO(this.state.doc,iq(this),ia(this),this.dom,this),this.domObserver=new ie(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=g0(a,b);if(c&&!a.state.selection.eq(c)){if(gj&&gp&&13===a.input.lastKeyCode&&Date.now()-100<a.input.lastKeyCodeTime&&a.someProp("handleKeyDown",b=>b(a,f8(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}],f7(j)||d.push({node:j.focusNode,offset:j.focusOffset})),gj&&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")||eP.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:ij,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&&io(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&&io(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++,(gm&&a.input.lastIOSEnter>Date.now()-225||gp)&&e.some(a=>1==a.nodeType&&!ik.test(a.nodeName))&&(!p||p.endA>=p.endB)&&a.someProp("handleKeyDown",b=>b(a,f8(13,"Enter")))){a.input.lastIOSEnter=0;return}if(!p)if(d&&l instanceof fH&&!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=il(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 fH&&(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)),gf&&gg<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>m.from&&"  "==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((gm&&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,f8(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||im(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(im(f,!0,!0));return!(!g.parent.isTextblock||g.pos>c||im(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,f8(8,"Backspace")))){gp&&gj&&a.domObserver.suppressSelectionUpdates();return}gj&&p.endB==p.start&&(a.input.lastChromeDelete=Date.now()),gp&&!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,f8(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=il(a,c.doc,m.sel);b&&!(gj&&a.composing&&b.empty&&(p.start!=p.endB||a.input.lastChromeDelete<Date.now()-100)&&(b.head==u||b.head==c.mapping.map(v)-1)||gf&&b.empty&&b.head==u)&&c.setSelection(b)}return i&&c.setMeta("composition",i),c.scrollIntoView()};if(t)if(q.pos==r.pos){gf&&gg<=11&&0==q.parentOffset&&(a.domObserver.suppressSelectionUpdates(),setTimeout(()=>g2(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(ef.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 hy){let c=hy[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)||hE(a,b)||!a.editable&&b.type in hz||c(a,b)},hA[b]?{passive:!0}:void 0)}gl&&a.dom.addEventListener("input",()=>null),hD(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&&hD(this);let b=this._props;this._props=a,a.plugins&&(a.plugins.forEach(iu),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&&(hN(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=it(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)&&hD(this),this.editable=is(this),ir(this);let j=ia(this),k=iq(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:gu(a.dom)}}(this);if(h){let b,c,h;this.domObserver.stop();let i=m&&(gf||gj)&&!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=gj?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=f5(a=a.childNodes[b-1])}else{if(!a.parentNode||f6(a))return null;b=fZ(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||f6(a))return null;b=fZ(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=gO(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(),f2(b.node,b.offset,c.anchorNode,c.anchorOffset)))?g2(this,i):(g7(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;gv(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 fJ){let b=this.docView.domAfterPos(this.state.selection.from);1==b.nodeType&&gt(this,b.getBoundingClientRect(),a)}else gt(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(c.from<this.state.doc.content.size&&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&&a<this.state.doc.content.size&&this.state.doc.nodeAt(a))==c.node&&(d=a)}this.dragging=new hS(a.slice,a.move,d<0?void 0:fJ.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(gf){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(gw)return a.focus(gw);let b=gu(a);a.focus(null==gw?{get preventScroll(){return gw={preventScroll:!0},!0}}:void 0),gw||(gw=!1,gv(b,0))}(this.dom),g2(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(f5(d.offsetNode),d.offset)}}catch(a){}if(a.caretRangeFromPoint){let d=a.caretRangeFromPoint(b,c);if(d)return{node:d.startContainer,offset:Math.min(f5(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(!gx(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(gx(c,f))return a(d,c,f)}}if((g=(g+1)%e)==f)break}return b}(a.dom,b,c)))return null}if(gl)for(let a=j;g&&a;a=f$(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(gh&&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++}gq&&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=f0(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=gz(d,1);if(c.top!=c.bottom&&gx(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 gB(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 gG==b&&gH==c?gI:(gG=b,gH=c,gI="up"==c||"down"==c?(d=b.selection,e="up"==c?d.$from:d.$to,gE(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=gB(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=f0(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?gF.test(d.parent.textContent)&&g.modify?gE(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 hQ(this,"",a,!1,b||new ClipboardEvent("paste"))}pasteText(a,b){return hQ(this,a,null,!0,b||new ClipboardEvent("paste"))}serializeForClipboard(a){return ho(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,[],ia(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,f1()}}get isDestroyed(){return null==this.docView}dispatchEvent(a){!hE(this,a)&&hy[a.type]&&(this.editable||!(a.type in hz))&&hy[a.type](this,a)}domSelectionRange(){let a=this.domSelection();return a?gl&&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 ii(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?ii(a,c):null}(this,a)||a:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function iq(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"),[hZ.node(0,a.state.doc.content.size,b)]}function ir(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:hZ.widget(a.state.selection.from,b,{raw:!0,marks:a.markCursor})}}else a.cursorWrapper=null}function is(a){return!a.someProp("editable",b=>!1===b(a.state))}function it(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 iu(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")}ip.prototype.dispatch=function(a){let b=this._props.dispatchTransaction;b?b.call(this,a):this.updateState(this.state.apply(a))};for(var iv={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:"'"},iw={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ix="u">typeof navigator&&/Mac/.test(navigator.platform),iy="u">typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),iz=0;iz<10;iz++)iv[48+iz]=iv[96+iz]=String(iz);for(var iz=1;iz<=24;iz++)iv[iz+111]="F"+iz;for(var iz=65;iz<=90;iz++)iv[iz]=String.fromCharCode(iz+32),iw[iz]=String.fromCharCode(iz);for(var iA in iv)iw.hasOwnProperty(iA)||(iw[iA]=iv[iA]);let iB="u">typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),iC="u">typeof navigator&&/Win/.test(navigator.platform);function iD(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 iE(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))iB?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=!(ix&&c.metaKey&&c.shiftKey&&!c.ctrlKey&&!c.altKey||iy&&c.shiftKey&&c.key&&1==c.key.length||"Unidentified"==c.key)&&c.key||(c.shiftKey?iw:iv)[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[iD(e,c)];if(g&&g(a.state,a.dispatch,a))return!0;if(1==e.length&&" "!=e){if(c.shiftKey){let d=b[iD(e,c,!1)];if(d&&d(a.state,a.dispatch,a))return!0}if((c.altKey||c.metaKey||c.ctrlKey)&&!(iC&&c.ctrlKey&&c.altKey)&&(f=iv[c.keyCode])&&f!=e){let d=b[iD(f,c)];if(d&&d(a.state,a.dispatch,a))return!0}}return!1}}if("u">typeof WeakMap){let a=new WeakMap;b=b=>a.get(b),c=(b,c)=>(a.set(b,c),c)}else{let a=[],d=0;b=b=>{for(let c=0;c<a.length;c+=2)if(a[c]==b)return a[c+1]},c=(b,c)=>(10==d&&(d=0),a[d++]=b,a[d++]=c)}var iF=class{constructor(a,b,c,d){this.width=a,this.height=b,this.map=c,this.problems=d}findCell(a){for(let b=0;b<this.map.length;b++){let c=this.map[b];if(c!=a)continue;let d=b%this.width,e=b/this.width|0,f=d+1,g=e+1;for(let a=1;f<this.width&&this.map[b+a]==c;a++)f++;for(let a=1;g<this.height&&this.map[b+this.width*a]==c;a++)g++;return{left:d,top:e,right:f,bottom:g}}throw RangeError(`No cell with offset ${a} found`)}colCount(a){for(let b=0;b<this.map.length;b++)if(this.map[b]==a)return b%this.width;throw RangeError(`No cell with offset ${a} found`)}nextCell(a,b,c){let{left:d,right:e,top:f,bottom:g}=this.findCell(a);return"horiz"==b?(c<0?0==d:e==this.width)?null:this.map[f*this.width+(c<0?d-1:e)]:(c<0?0==f:g==this.height)?null:this.map[d+this.width*(c<0?f-1:g)]}rectBetween(a,b){let{left:c,right:d,top:e,bottom:f}=this.findCell(a),{left:g,right:h,top:i,bottom:j}=this.findCell(b);return{left:Math.min(c,g),top:Math.min(e,i),right:Math.max(d,h),bottom:Math.max(f,j)}}cellsInRect(a){let b=[],c={};for(let d=a.top;d<a.bottom;d++)for(let e=a.left;e<a.right;e++){let f=d*this.width+e,g=this.map[f];!c[g]&&(c[g]=!0,e==a.left&&e&&this.map[f-1]==g||d==a.top&&d&&this.map[f-this.width]==g||b.push(g))}return b}positionAt(a,b,c){for(let d=0,e=0;;d++){let f=e+c.child(d).nodeSize;if(d==a){let c=b+a*this.width,d=(a+1)*this.width;for(;c<d&&this.map[c]<e;)c++;return c==d?f-1:this.map[c]}e=f}}static get(a){return b(a)||c(a,function(a){if("table"!=a.type.spec.tableRole)throw RangeError("Not a table node: "+a.type.name);let b=function(a){let b=-1,c=!1;for(let d=0;d<a.childCount;d++){let e=a.child(d),f=0;if(c)for(let b=0;b<d;b++){let c=a.child(b);for(let a=0;a<c.childCount;a++){let e=c.child(a);b+e.attrs.rowspan>d&&(f+=e.attrs.colspan)}}for(let a=0;a<e.childCount;a++){let b=e.child(a);f+=b.attrs.colspan,b.attrs.rowspan>1&&(c=!0)}-1==b?b=f:b!=f&&(b=Math.max(b,f))}return b}(a),c=a.childCount,d=[],e=0,f=null,g=[];for(let a=0,e=b*c;a<e;a++)d[a]=0;for(let h=0,i=0;h<c;h++){let j=a.child(h);i++;for(let a=0;;a++){for(;e<d.length&&0!=d[e];)e++;if(a==j.childCount)break;let k=j.child(a),{colspan:l,rowspan:m,colwidth:n}=k.attrs;for(let a=0;a<m;a++){if(a+h>=c){(f||(f=[])).push({type:"overlong_rowspan",pos:i,n:m-a});break}let j=e+a*b;for(let a=0;a<l;a++){0==d[j+a]?d[j+a]=i:(f||(f=[])).push({type:"collision",row:h,pos:i,n:l-a});let c=n&&n[a];if(c){let d=(j+a)%b*2,e=g[d];null==e||e!=c&&1==g[d+1]?(g[d]=c,g[d+1]=1):e==c&&g[d+1]++}}}e+=l,i+=k.nodeSize}let k=(h+1)*b,l=0;for(;e<k;)0==d[e++]&&l++;l&&(f||(f=[])).push({type:"missing",row:h,n:l}),i++}(0===b||0===c)&&(f||(f=[])).push({type:"zero_sized"});let h=new iF(b,c,d,f),i=!1;for(let a=0;!i&&a<g.length;a+=2)null!=g[a]&&g[a+1]<c&&(i=!0);return i&&function(a,b,c){a.problems||(a.problems=[]);let d={};for(let e=0;e<a.map.length;e++){let f=a.map[e];if(d[f])continue;d[f]=!0;let g=c.nodeAt(f);if(!g)throw RangeError(`No cell with offset ${f} found`);let h=null,i=g.attrs;for(let c=0;c<i.colspan;c++){let d=b[(e+c)%a.width*2];null==d||i.colwidth&&i.colwidth[c]==d||((h||(h=function(a){if(a.colwidth)return a.colwidth.slice();let b=[];for(let c=0;c<a.colspan;c++)b.push(0);return b}(i)))[c]=d)}h&&a.problems.unshift({type:"colwidth mismatch",pos:f,colwidth:h})}}(h,g,a),h}(a))}};function iG(a){let b=a.cached.tableNodeTypes;if(!b)for(let c in b=a.cached.tableNodeTypes={},a.nodes){let d=a.nodes[c],e=d.spec.tableRole;e&&(b[e]=d)}return b}let iH=new fY("selectingCells");function iI(a){for(let b=a.depth-1;b>0;b--)if("row"==a.node(b).type.spec.tableRole)return a.node(0).resolve(a.before(b+1));return null}function iJ(a){let b=a.selection.$head;for(let a=b.depth;a>0;a--)if("row"==b.node(a).type.spec.tableRole)return!0;return!1}function iK(a){let b=a.selection;if("$anchorCell"in b&&b.$anchorCell)return b.$anchorCell.pos>b.$headCell.pos?b.$anchorCell:b.$headCell;if("node"in b&&b.node&&"cell"==b.node.type.spec.tableRole)return b.$anchor;let c=iI(b.$head)||function(a){for(let b=a.nodeAfter,c=a.pos;b;b=b.firstChild,c++){let d=b.type.spec.tableRole;if("cell"==d||"header_cell"==d)return a.doc.resolve(c)}for(let b=a.nodeBefore,c=a.pos;b;b=b.lastChild,c--){let d=b.type.spec.tableRole;if("cell"==d||"header_cell"==d)return a.doc.resolve(c-b.nodeSize)}}(b.$head);if(c)return c;throw RangeError(`No cell found around position ${b.head}`)}function iL(a){return"row"==a.parent.type.spec.tableRole&&!!a.nodeAfter}function iM(a,b){return a.depth==b.depth&&a.pos>=b.start(-1)&&a.pos<=b.end(-1)}function iN(a,b,c){let d=a.node(-1),e=iF.get(d),f=a.start(-1),g=e.nextCell(a.pos-f,b,c);return null==g?null:a.node(0).resolve(f+g)}function iO(a,b,c=1){let d={...a,colspan:a.colspan-c};return d.colwidth&&(d.colwidth=d.colwidth.slice(),d.colwidth.splice(b,c),d.colwidth.some(a=>a>0)||(d.colwidth=null)),d}function iP(a,b,c=1){let d={...a,colspan:a.colspan+c};if(d.colwidth){d.colwidth=d.colwidth.slice();for(let a=0;a<c;a++)d.colwidth.splice(b,0,0)}return d}var iQ=class a extends fD{constructor(a,b=a){const c=a.node(-1),d=iF.get(c),e=a.start(-1),f=d.rectBetween(a.pos-e,b.pos-e),g=a.node(0),h=d.cellsInRect(f).filter(a=>a!=b.pos-e);h.unshift(b.pos-e);const i=h.map(a=>{let b=c.nodeAt(a);if(!b)throw RangeError(`No cell with offset ${a} found`);let d=e+a+1;return new fE(g.resolve(d),g.resolve(d+b.content.size))});super(i[0].$from,i[0].$to,i),this.$anchorCell=a,this.$headCell=b}map(b,c){let d=b.resolve(c.map(this.$anchorCell.pos)),e=b.resolve(c.map(this.$headCell.pos));if(iL(d)&&iL(e)&&iM(d,e)){let b=this.$anchorCell.node(-1)!=d.node(-1);return b&&this.isRowSelection()?a.rowSelection(d,e):b&&this.isColSelection()?a.colSelection(d,e):new a(d,e)}return fH.between(d,e)}content(){let a=this.$anchorCell.node(-1),b=iF.get(a),c=this.$anchorCell.start(-1),d=b.rectBetween(this.$anchorCell.pos-c,this.$headCell.pos-c),e={},f=[];for(let c=d.top;c<d.bottom;c++){let g=[];for(let f=c*b.width+d.left,h=d.left;h<d.right;h++,f++){let c=b.map[f];if(e[c])continue;e[c]=!0;let h=b.findCell(c),i=a.nodeAt(c);if(!i)throw RangeError(`No cell with offset ${c} found`);let j=d.left-h.left,k=h.right-d.right;if(j>0||k>0){let a=i.attrs;if(j>0&&(a=iO(a,0,j)),k>0&&(a=iO(a,a.colspan-k,k)),h.left<d.left){if(!(i=i.type.createAndFill(a)))throw RangeError(`Could not create cell with attrs ${JSON.stringify(a)}`)}else i=i.type.create(a,i.content)}if(h.top<d.top||h.bottom>d.bottom){let a={...i.attrs,rowspan:Math.min(h.bottom,d.bottom)-Math.max(h.top,d.top)};i=h.top<d.top?i.type.createAndFill(a):i.type.create(a,i.content)}g.push(i)}f.push(a.child(c).copy(ef.from(g)))}let g=this.isColSelection()&&this.isRowSelection()?a:f;return new el(ef.from(g),1,1)}replace(a,b=el.empty){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);a.replace(h.map(f.pos),h.map(g.pos),e?el.empty:b)}let e=fD.findFrom(a.doc.resolve(a.mapping.slice(c).map(this.to)),-1);e&&a.setSelection(e)}replaceWith(a,b){this.replace(a,new el(ef.from(b),0,0))}forEachCell(a){let b=this.$anchorCell.node(-1),c=iF.get(b),d=this.$anchorCell.start(-1),e=c.cellsInRect(c.rectBetween(this.$anchorCell.pos-d,this.$headCell.pos-d));for(let c=0;c<e.length;c++)a(b.nodeAt(e[c]),d+e[c])}isColSelection(){let a=this.$anchorCell.index(-1),b=this.$headCell.index(-1);return!(Math.min(a,b)>0)&&Math.max(a+this.$anchorCell.nodeAfter.attrs.rowspan,b+this.$headCell.nodeAfter.attrs.rowspan)==this.$headCell.node(-1).childCount}static colSelection(b,c=b){let d=b.node(-1),e=iF.get(d),f=b.start(-1),g=e.findCell(b.pos-f),h=e.findCell(c.pos-f),i=b.node(0);return g.top<=h.top?(g.top>0&&(b=i.resolve(f+e.map[g.left])),h.bottom<e.height&&(c=i.resolve(f+e.map[e.width*(e.height-1)+h.right-1]))):(h.top>0&&(c=i.resolve(f+e.map[h.left])),g.bottom<e.height&&(b=i.resolve(f+e.map[e.width*(e.height-1)+g.right-1]))),new a(b,c)}isRowSelection(){let a=this.$anchorCell.node(-1),b=iF.get(a),c=this.$anchorCell.start(-1),d=b.colCount(this.$anchorCell.pos-c),e=b.colCount(this.$headCell.pos-c);return!(Math.min(d,e)>0)&&Math.max(d+this.$anchorCell.nodeAfter.attrs.colspan,e+this.$headCell.nodeAfter.attrs.colspan)==b.width}eq(b){return b instanceof a&&b.$anchorCell.pos==this.$anchorCell.pos&&b.$headCell.pos==this.$headCell.pos}static rowSelection(b,c=b){let d=b.node(-1),e=iF.get(d),f=b.start(-1),g=e.findCell(b.pos-f),h=e.findCell(c.pos-f),i=b.node(0);return g.left<=h.left?(g.left>0&&(b=i.resolve(f+e.map[g.top*e.width])),h.right<e.width&&(c=i.resolve(f+e.map[e.width*(h.top+1)-1]))):(h.left>0&&(c=i.resolve(f+e.map[h.top*e.width])),g.right<e.width&&(b=i.resolve(f+e.map[e.width*(g.top+1)-1]))),new a(b,c)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(b,c){return new a(b.resolve(c.anchor),b.resolve(c.head))}static create(b,c,d=c){return new a(b.resolve(c),b.resolve(d))}getBookmark(){return new iR(this.$anchorCell.pos,this.$headCell.pos)}};iQ.prototype.visible=!1,fD.jsonID("cell",iQ);var iR=class a{constructor(a,b){this.anchor=a,this.head=b}map(b){return new a(b.map(this.anchor),b.map(this.head))}resolve(a){let b=a.resolve(this.anchor),c=a.resolve(this.head);return"row"==b.parent.type.spec.tableRole&&"row"==c.parent.type.spec.tableRole&&b.index()<b.parent.childCount&&c.index()<c.parent.childCount&&iM(b,c)?new iQ(b,c):fD.near(c,1)}};function iS(a){if(!(a.selection instanceof iQ))return null;let b=[];return a.selection.forEachCell((a,c)=>{b.push(hZ.node(c,c+a.nodeSize,{class:"selectedCell"}))}),h0.create(a.doc,b)}let iT=new fY("fix-tables");function iU(a,b){let c,d=(b,d)=>{"table"==b.type.spec.tableRole&&(c=function(a,b,c,d){let e,f,g=iF.get(b);if(!g.problems)return d;d||(d=a.tr);let h=[];for(let a=0;a<g.height;a++)h.push(0);for(let a=0;a<g.problems.length;a++){let e=g.problems[a];if("collision"==e.type){let a=b.nodeAt(e.pos);if(!a)continue;let f=a.attrs;for(let a=0;a<f.rowspan;a++)h[e.row+a]+=e.n;d.setNodeMarkup(d.mapping.map(c+1+e.pos),null,iO(f,f.colspan-e.n,e.n))}else if("missing"==e.type)h[e.row]+=e.n;else if("overlong_rowspan"==e.type){let a=b.nodeAt(e.pos);if(!a)continue;d.setNodeMarkup(d.mapping.map(c+1+e.pos),null,{...a.attrs,rowspan:a.attrs.rowspan-e.n})}else if("colwidth mismatch"==e.type){let a=b.nodeAt(e.pos);if(!a)continue;d.setNodeMarkup(d.mapping.map(c+1+e.pos),null,{...a.attrs,colwidth:e.colwidth})}else if("zero_sized"==e.type){let a=d.mapping.map(c);d.delete(a,a+b.nodeSize)}}for(let a=0;a<h.length;a++)h[a]&&(null==e&&(e=a),f=a);for(let i=0,j=c+1;i<g.height;i++){let c=b.child(i),g=j+c.nodeSize,k=h[i];if(k>0){let b="cell";c.firstChild&&(b=c.firstChild.type.spec.tableRole);let h=[];for(let c=0;c<k;c++){let c=iG(a.schema)[b].createAndFill();c&&h.push(c)}let l=(0==i||e==i-1)&&f==i?j+1:g-1;d.insert(d.mapping.map(l),h)}j=g}return d.setMeta(iT,{fixTables:!0})}(a,b,d,c))};return b?b.doc!=a.doc&&function a(b,c,d,e){let f=b.childCount,g=c.childCount;d:for(let h=0,i=0;h<g;h++){let g=c.child(h);for(let a=i,c=Math.min(f,h+3);a<c;a++)if(b.child(a)==g){i=a+1,d+=g.nodeSize;continue d}e(g,d),i<f&&b.child(i).sameMarkup(g)?a(b.child(i),g,d+1,e):g.nodesBetween(0,g.content.size,e,d+1),d+=g.nodeSize}}(b.doc,a.doc,0,d):a.doc.descendants(d),c}function iV(a){let b=iF.get(a),c=[],d=b.height,e=b.width;for(let f=0;f<d;f++){let d=[];for(let c=0;c<e;c++){let g=f*e+c,h=b.map[g];if(f>0){let a=g-e;if(h===b.map[a]){d.push(null);continue}}if(c>0){let a=g-1;if(h===b.map[a]){d.push(null);continue}}d.push(a.nodeAt(h))}c.push(d)}return c}function iW(a,b){let c=[],d=iF.get(a),e=d.height,f=d.width;for(let g=0;g<e;g++){let e=a.child(g),h=[];for(let c=0;c<f;c++){let e=b[g][c];if(!e)continue;let f=d.map[g*d.width+c],i=a.nodeAt(f);if(!i)continue;let j=i.type.createChecked(e.attrs,e.content,e.marks);h.push(j)}let i=e.type.createChecked(e.attrs,h,e.marks);c.push(i)}return a.type.createChecked(a.attrs,c,a.marks)}function iX(a,b,c,d){let e,f=b[0]>c[0]?-1:1,g=a.splice(b[0],b.length),h=+(g.length%2==0);return e=-1===d&&1===f?c[0]-1:1===d&&-1===f?c[c.length-1]-h+1:-1===f?c[0]:c[c.length-1]-h,a.splice(e,0,...g),a}function iY(a){var b=a;for(let a=b.depth;a>=0;a-=1){let c=b.node(a);if((a=>"table"===a.type.spec.tableRole)(c))return{node:c,pos:0===a?0:b.before(a),start:b.start(a),depth:a}}return null}function iZ(a,b){let c=iY(b.$from);if(!c)return;let d=iF.get(c.node);if(!(a<0)&&!(a>d.width-1))return d.cellsInRect({left:a,right:a+1,top:0,bottom:d.height}).map(a=>{let b=c.node.nodeAt(a),d=a+c.start;return{pos:d,start:d+1,node:b,depth:c.depth+2}})}function i$(a,b){let c=iY(b.$from);if(!c)return;let d=iF.get(c.node);if(!(a<0)&&!(a>d.height-1))return d.cellsInRect({left:0,right:d.width,top:a,bottom:a+1}).map(a=>{let b=c.node.nodeAt(a),d=a+c.start;return{pos:d,start:d+1,node:b,depth:c.depth+2}})}function i_(a,b,c=b){let d,e=b,f=c;for(let c=b;c>=0;c--){let b=iZ(c,a.selection);b&&b.forEach(a=>{let b=a.node.attrs.colspan+c-1;b>=e&&(e=c),b>f&&(f=b)})}for(let c=b;c<=f;c++){let b=iZ(c,a.selection);b&&b.forEach(a=>{let b=a.node.attrs.colspan+c-1;a.node.attrs.colspan>1&&b>f&&(f=b)})}let g=[];for(let b=e;b<=f;b++){let c=iZ(b,a.selection);c&&c.length>0&&g.push(b)}e=g[0],f=g[g.length-1];let h=iZ(e,a.selection),i=i$(0,a.selection);if(!h||!i)return;let j=a.doc.resolve(h[h.length-1].pos);for(let b=f;b>=e;b--){let c=iZ(b,a.selection);if(c&&c.length>0){for(let a=i.length-1;a>=0;a--)if(i[a].pos===c[0].pos){d=c[0];break}if(d)break}}if(d)return{$anchor:j,$head:a.doc.resolve(d.pos),indexes:g}}function i0(a,b,c=b){let d,e=b,f=c;for(let c=b;c>=0;c--){let b=i$(c,a.selection);b&&b.forEach(a=>{let b=a.node.attrs.rowspan+c-1;b>=e&&(e=c),b>f&&(f=b)})}for(let c=b;c<=f;c++){let b=i$(c,a.selection);b&&b.forEach(a=>{let b=a.node.attrs.rowspan+c-1;a.node.attrs.rowspan>1&&b>f&&(f=b)})}let g=[];for(let b=e;b<=f;b++){let c=i$(b,a.selection);c&&c.length>0&&g.push(b)}e=g[0],f=g[g.length-1];let h=i$(e,a.selection),i=iZ(0,a.selection);if(!h||!i)return;let j=a.doc.resolve(h[h.length-1].pos);for(let b=f;b>=e;b--){let c=i$(b,a.selection);if(c&&c.length>0){for(let a=i.length-1;a>=0;a--)if(i[a].pos===c[0].pos){d=c[0];break}if(d)break}}if(d)return{$anchor:j,$head:a.doc.resolve(d.pos),indexes:g}}function i1(a){return a[0].map((b,c)=>a.map(a=>a[c]))}function i2(a){let b=a.selection,c=iK(a),d=c.node(-1),e=c.start(-1),f=iF.get(d);return{...b instanceof iQ?f.rectBetween(b.$anchorCell.pos-e,b.$headCell.pos-e):f.findCell(c.pos-e),tableStart:e,map:f,table:d}}function i3(a,{map:b,tableStart:c,table:d},e){let f=e>0?-1:0;(function(a,b,c){let d=iG(b.type.schema).header_cell;for(let e=0;e<a.height;e++)if(b.nodeAt(a.map[c+e*a.width]).type!=d)return!1;return!0})(b,d,e+f)&&(f=0==e||e==b.width?null:0);for(let g=0;g<b.height;g++){let h=g*b.width+e;if(e>0&&e<b.width&&b.map[h-1]==b.map[h]){let f=b.map[h],i=d.nodeAt(f);a.setNodeMarkup(a.mapping.map(c+f),null,iP(i.attrs,e-b.colCount(f))),g+=i.attrs.rowspan-1}else{let i=null==f?iG(d.type.schema).cell:d.nodeAt(b.map[h+f]).type,j=b.positionAt(g,e,d);a.insert(a.mapping.map(c+j),i.createAndFill())}}return a}function i4(a,{map:b,tableStart:c,table:d},e){let f=c;for(let a=0;a<e;a++)f+=d.child(a).nodeSize;let g=[],h=e>0?-1:0;(function(a,b,c){var d;let e=iG(b.type.schema).header_cell;for(let f=0;f<a.width;f++)if((null==(d=b.nodeAt(a.map[f+c*a.width]))?void 0:d.type)!=e)return!1;return!0})(b,d,e+h)&&(h=0==e||e==b.height?null:0);for(let f=0,j=b.width*e;f<b.width;f++,j++)if(e>0&&e<b.height&&b.map[j]==b.map[j-b.width]){let e=b.map[j],g=d.nodeAt(e).attrs;a.setNodeMarkup(c+e,null,{...g,rowspan:g.rowspan+1}),f+=g.colspan-1}else{var i;let a=null==h?iG(d.type.schema).cell:null==(i=d.nodeAt(b.map[j+h*b.width]))?void 0:i.type,c=null==a?void 0:a.createAndFill();c&&g.push(c)}return a.insert(f,iG(d.type.schema).row.create(null,g)),a}function i5(a){let b=a.content;return 1==b.childCount&&b.child(0).isTextblock&&0==b.child(0).childCount}function i6(a,b){let c=a.selection;if(!(c instanceof iQ)||c.$anchorCell.pos==c.$headCell.pos)return!1;let d=i2(a),{map:e}=d;if(function({width:a,height:b,map:c},d){let e=d.top*a+d.left,f=e,g=(d.bottom-1)*a+d.left,h=e+(d.right-d.left-1);for(let b=d.top;b<d.bottom;b++){if(d.left>0&&c[f]==c[f-1]||d.right<a&&c[h]==c[h+1])return!0;f+=a,h+=a}for(let f=d.left;f<d.right;f++){if(d.top>0&&c[e]==c[e-a]||d.bottom<b&&c[g]==c[g+a])return!0;e++,g++}return!1}(e,d))return!1;if(b){let c,f,g=a.tr,h={},i=ef.empty;for(let a=d.top;a<d.bottom;a++)for(let b=d.left;b<d.right;b++){let j=e.map[a*e.width+b],k=d.table.nodeAt(j);if(!h[j]&&k)if(h[j]=!0,null==c)c=j,f=k;else{i5(k)||(i=i.append(k.content));let a=g.mapping.map(j+d.tableStart);g.delete(a,a+k.nodeSize)}}if(null==c||null==f)return!0;if(g.setNodeMarkup(c+d.tableStart,null,{...iP(f.attrs,f.attrs.colspan,d.right-d.left-f.attrs.colspan),rowspan:d.bottom-d.top}),i.size>0){let a=c+1+f.content.size,b=i5(f)?c+1:a;g.replaceWith(b+d.tableStart,a+d.tableStart,i)}g.setSelection(new iQ(g.doc.resolve(c+d.tableStart))),b(g)}return!0}function i7(a,b){var c;let d=iG(a.schema);return(c=({node:a})=>d[a.type.spec.tableRole],(a,b)=>{let d,e,f=a.selection;if(f instanceof iQ){if(f.$anchorCell.pos!=f.$headCell.pos)return!1;d=f.$anchorCell.nodeAfter,e=f.$anchorCell.pos}else{var g;if(!(d=function(a){for(let b=a.depth;b>0;b--){let c=a.node(b).type.spec.tableRole;if("cell"===c||"header_cell"===c)return a.node(b)}return null}(f.$from)))return!1;e=null==(g=iI(f.$from))?void 0:g.pos}if(null==d||null==e||1==d.attrs.colspan&&1==d.attrs.rowspan)return!1;if(b){let g,h=d.attrs,i=[],j=h.colwidth;h.rowspan>1&&(h={...h,rowspan:1}),h.colspan>1&&(h={...h,colspan:1});let k=i2(a),l=a.tr;for(let a=0;a<k.right-k.left;a++)i.push(j?{...h,colwidth:j&&j[a]?[j[a]]:null}:h);for(let a=k.top;a<k.bottom;a++){let b=k.map.positionAt(a,k.left,k.table);a==k.top&&(b+=d.nodeSize);for(let e=k.left,f=0;e<k.right;e++,f++)(e!=k.left||a!=k.top)&&l.insert(g=l.mapping.map(b+k.tableStart,1),c({node:d,row:a,col:e}).createAndFill(i[f]))}l.setNodeMarkup(e,c({node:d,row:k.top,col:k.left}),i[0]),f instanceof iQ&&l.setSelection(new iQ(l.doc.resolve(f.$anchorCell.pos),g?l.doc.resolve(g):void 0)),b(l)}return!0})(a,b)}function i8(a,b,c){let d=b.map.cellsInRect({left:0,top:0,right:"row"==a?b.map.width:1,bottom:"column"==a?b.map.height:1});for(let a=0;a<d.length;a++){let e=b.table.nodeAt(d[a]);if(e&&e.type!==c.header_cell)return!1}return!0}function i9(a,b){if((b=b||{useDeprecatedLogic:!1}).useDeprecatedLogic)return function(b,c){if(!iJ(b))return!1;if(c){let d=iG(b.schema),e=i2(b),f=b.tr,g=e.map.cellsInRect("column"==a?{left:e.left,top:0,right:e.right,bottom:e.map.height}:"row"==a?{left:0,top:e.top,right:e.map.width,bottom:e.bottom}:e),h=g.map(a=>e.table.nodeAt(a));for(let a=0;a<g.length;a++)h[a].type==d.header_cell&&f.setNodeMarkup(e.tableStart+g[a],d.cell,h[a].attrs);if(0===f.steps.length)for(let a=0;a<g.length;a++)f.setNodeMarkup(e.tableStart+g[a],d.header_cell,h[a].attrs);c(f)}return!0};return function(b,c){if(!iJ(b))return!1;if(c){let d=iG(b.schema),e=i2(b),f=b.tr,g=i8("row",e,d),h=i8("column",e,d),i=+("column"===a?!!g:"row"===a&&!!h),j="column"==a?{left:0,top:i,right:1,bottom:e.map.height}:"row"==a?{left:i,top:0,right:e.map.width,bottom:1}:e,k="column"==a?h?d.cell:d.header_cell:"row"==a?g?d.cell:d.header_cell:d.cell;e.map.cellsInRect(j).forEach(a=>{let b=a+e.tableStart,c=f.doc.nodeAt(b);c&&f.setNodeMarkup(b,k,c.attrs)}),c(f)}return!0}}i9("row",{useDeprecatedLogic:!0}),i9("column",{useDeprecatedLogic:!0});let ja=i9("cell",{useDeprecatedLogic:!0});function jb(a){return function(b,c){if(!iJ(b))return!1;let d=function(a,b){if(b<0){let b=a.nodeBefore;if(b)return a.pos-b.nodeSize;for(let b=a.index(-1)-1,c=a.before();b>=0;b--){let d=a.node(-1).child(b),e=d.lastChild;if(e)return c-1-e.nodeSize;c-=d.nodeSize}}else{if(a.index()<a.parent.childCount-1)return a.pos+a.nodeAfter.nodeSize;let b=a.node(-1);for(let c=a.indexAfter(-1),d=a.after();c<b.childCount;c++){let a=b.child(c);if(a.childCount)return d+1;d+=a.nodeSize}}return null}(iK(b),a);if(null==d)return!1;if(c){let a=b.doc.resolve(d);c(b.tr.setSelection(fH.between(a,a.node(0).resolve(a.pos+a.nodeAfter.nodeSize))).scrollIntoView())}return!0}}function jc(a,b){let c=a.selection;if(!(c instanceof iQ))return!1;if(b){let d=a.tr,e=iG(a.schema).cell.createAndFill().content;c.forEachCell((a,b)=>{a.content.eq(e)||d.replace(d.mapping.map(b+1),d.mapping.map(b+a.nodeSize-1),new el(e,0,0))}),d.docChanged&&b(d)}return!0}function jd(a,b){let c=a.createAndFill();return new fB(c).replace(0,c.content.size,b).doc}function je(a,b,c,d,e,f,g,h){if(0==g||g==b.height)return!1;let i=!1;for(let j=e;j<f;j++){let e=g*b.width+j,f=b.map[e];if(b.map[e-b.width]==f){i=!0;let e=c.nodeAt(f),{top:k,left:l}=b.findCell(f);a.setNodeMarkup(a.mapping.slice(h).map(f+d),null,{...e.attrs,rowspan:g-k}),a.insert(a.mapping.slice(h).map(b.positionAt(g,l,c)),e.type.createAndFill({...e.attrs,rowspan:k+e.attrs.rowspan-g})),j+=e.attrs.colspan-1}}return i}function jf(a,b,c,d,e,f,g,h){if(0==g||g==b.width)return!1;let i=!1;for(let j=e;j<f;j++){let e=j*b.width+g,f=b.map[e];if(b.map[e-1]==f){i=!0;let e=c.nodeAt(f),k=b.colCount(f),l=a.mapping.slice(h).map(f+d);a.setNodeMarkup(l,null,iO(e.attrs,g-k,e.attrs.colspan-(g-k))),a.insert(l+e.nodeSize,e.type.createAndFill(iO(e.attrs,0,g-k))),j+=e.attrs.rowspan-1}}return i}function jg(a,b,c,d,e){let f=c?a.doc.nodeAt(c-1):a.doc;if(!f)throw Error("No table found");let g=iF.get(f),{top:h,left:i}=d,j=i+e.width,k=h+e.height,l=a.tr,m=0;function n(){if(!(f=c?l.doc.nodeAt(c-1):l.doc))throw Error("No table found");g=iF.get(f),m=l.mapping.maps.length}(function(a,b,c,d,e,f){let g,h,i=iG(a.doc.type.schema);if(e>b.width)for(let f=0,j=0;f<b.height;f++){let k,l=c.child(f);j+=l.nodeSize;let m=[];k=null==l.lastChild||l.lastChild.type==i.cell?g||(g=i.cell.createAndFill()):h||(h=i.header_cell.createAndFill());for(let a=b.width;a<e;a++)m.push(k);a.insert(a.mapping.slice(0).map(j-1+d),m)}if(f>b.height){let j=[];for(let a=0,d=(b.height-1)*b.width;a<Math.max(b.width,e);a++){let e=!(a>=b.width)&&c.nodeAt(b.map[d+a]).type==i.header_cell;j.push(e?h||(h=i.header_cell.createAndFill()):g||(g=i.cell.createAndFill()))}let k=i.row.create(null,ef.from(j)),l=[];for(let a=b.height;a<f;a++)l.push(k);a.insert(a.mapping.slice(0).map(d+c.nodeSize-2),l)}return!!(g||h)})(l,g,f,c,j,k)&&n(),je(l,g,f,c,i,j,h,m)&&n(),je(l,g,f,c,i,j,k,m)&&n(),jf(l,g,f,c,h,k,i,m)&&n(),jf(l,g,f,c,h,k,j,m)&&n();for(let a=h;a<k;a++){let b=g.positionAt(a,i,f),d=g.positionAt(a,j,f);l.replace(l.mapping.slice(m).map(b+c),l.mapping.slice(m).map(d+c),new el(e.rows[a-h],0,0))}n(),l.setSelection(new iQ(l.doc.resolve(c+g.positionAt(h,i,f)),l.doc.resolve(c+g.positionAt(k-1,j-1,f)))),b(l)}let jh=iE({ArrowLeft:jj("horiz",-1),ArrowRight:jj("horiz",1),ArrowUp:jj("vert",-1),ArrowDown:jj("vert",1),"Shift-ArrowLeft":jk("horiz",-1),"Shift-ArrowRight":jk("horiz",1),"Shift-ArrowUp":jk("vert",-1),"Shift-ArrowDown":jk("vert",1),Backspace:jc,"Mod-Backspace":jc,Delete:jc,"Mod-Delete":jc});function ji(a,b,c){return!c.eq(a.selection)&&(b&&b(a.tr.setSelection(c).scrollIntoView()),!0)}function jj(a,b){return(c,d,e)=>{if(!e)return!1;let f=c.selection;if(f instanceof iQ)return ji(c,d,fD.near(f.$headCell,b));if("horiz"!=a&&!f.empty)return!1;let g=jo(e,a,b);if(null==g)return!1;if("horiz"==a)return ji(c,d,fD.near(c.doc.resolve(f.head+b),b));{let e,f=c.doc.resolve(g),h=iN(f,a,b);return e=h?fD.near(h,1):b<0?fD.near(c.doc.resolve(f.before(-1)),-1):fD.near(c.doc.resolve(f.after(-1)),1),ji(c,d,e)}}}function jk(a,b){return(c,d,e)=>{let f;if(!e)return!1;let g=c.selection;if(g instanceof iQ)f=g;else{let d=jo(e,a,b);if(null==d)return!1;f=new iQ(c.doc.resolve(d))}let h=iN(f.$headCell,a,b);return!!h&&ji(c,d,new iQ(f.$anchorCell,h))}}function jl(a,b){let c=iI(a.state.doc.resolve(b));return!!c&&(a.dispatch(a.state.tr.setSelection(new iQ(c))),!0)}function jm(a,b,c){if(!iJ(a.state))return!1;let d=function(a){if(0===a.size)return null;let{content:b,openStart:c,openEnd:d}=a;for(;1==b.childCount&&(c>0&&d>0||"table"==b.child(0).type.spec.tableRole);)c--,d--,b=b.child(0).content;let e=b.child(0),f=e.type.spec.tableRole,g=e.type.schema,h=[];if("row"==f)for(let a=0;a<b.childCount;a++){let e=b.child(a).content,f=a?0:Math.max(0,c-1),i=a<b.childCount-1?0:Math.max(0,d-1);(f||i)&&(e=jd(iG(g).row,new el(e,f,i)).content),h.push(e)}else{if("cell"!=f&&"header_cell"!=f)return null;h.push(c||d?jd(iG(g).row,new el(b,c,d)).content:b)}return function(a,b){let c=[];for(let a=0;a<b.length;a++){let d=b[a];for(let b=d.childCount-1;b>=0;b--){let{rowspan:e,colspan:f}=d.child(b).attrs;for(let b=a;b<a+e;b++)c[b]=(c[b]||0)+f}}let d=0;for(let a=0;a<c.length;a++)d=Math.max(d,c[a]);for(let e=0;e<c.length;e++)if(e>=b.length&&b.push(ef.empty),c[e]<d){let f=iG(a).cell.createAndFill(),g=[];for(let a=c[e];a<d;a++)g.push(f);b[e]=b[e].append(ef.from(g))}return{height:b.length,width:d,rows:b}}(g,h)}(c),e=a.state.selection;if(e instanceof iQ){d||(d={width:1,height:1,rows:[ef.from(jd(iG(a.state.schema).cell,c))]});let b=e.$anchorCell.node(-1),f=e.$anchorCell.start(-1),g=iF.get(b).rectBetween(e.$anchorCell.pos-f,e.$headCell.pos-f);return d=function({width:a,height:b,rows:c},d,e){if(a!=d){let b=[],e=[];for(let a=0;a<c.length;a++){let f=c[a],g=[];for(let c=b[a]||0,e=0;c<d;e++){let h=f.child(e%f.childCount);c+h.attrs.colspan>d&&(h=h.type.createChecked(iO(h.attrs,h.attrs.colspan,c+h.attrs.colspan-d),h.content)),g.push(h),c+=h.attrs.colspan;for(let c=1;c<h.attrs.rowspan;c++)b[a+c]=(b[a+c]||0)+h.attrs.colspan}e.push(ef.from(g))}c=e,a=d}if(b!=e){let a=[];for(let d=0,f=0;d<e;d++,f++){let g=[],h=c[f%b];for(let a=0;a<h.childCount;a++){let b=h.child(a);d+b.attrs.rowspan>e&&(b=b.type.create({...b.attrs,rowspan:Math.max(1,e-b.attrs.rowspan)},b.content)),g.push(b)}a.push(ef.from(g))}c=a,b=e}return{width:a,height:b,rows:c}}(d,g.right-g.left,g.bottom-g.top),jg(a.state,a.dispatch,f,g,d),!0}if(!d)return!1;{let b=iK(a.state),c=b.start(-1);return jg(a.state,a.dispatch,c,iF.get(b.node(-1)).findCell(b.pos-c),d),!0}}function jn(a,b){var c;let d;if(0!=b.button||b.ctrlKey||b.metaKey)return;let e=jp(a,b.target);if(b.shiftKey&&a.state.selection instanceof iQ)f(a.state.selection.$anchorCell,b),b.preventDefault();else if(b.shiftKey&&e&&null!=(d=iI(a.state.selection.$anchor))&&(null==(c=jq(a,b))?void 0:c.pos)!=d.pos)f(d,b),b.preventDefault();else if(!e)return;function f(b,c){let d=jq(a,c),e=null==iH.getState(a.state);if(!d||!iM(b,d))if(!e)return;else d=b;let f=new iQ(b,d);if(e||!a.state.selection.eq(f)){let c=a.state.tr.setSelection(f);e&&c.setMeta(iH,b.pos),a.dispatch(c)}}function g(){a.root.removeEventListener("mouseup",g),a.root.removeEventListener("dragstart",g),a.root.removeEventListener("mousemove",h),null!=iH.getState(a.state)&&a.dispatch(a.state.tr.setMeta(iH,-1))}function h(c){let d,h=iH.getState(a.state);if(null!=h)d=a.state.doc.resolve(h);else if(jp(a,c.target)!=e&&!(d=jq(a,b)))return g();d&&f(d,c)}a.root.addEventListener("mouseup",g),a.root.addEventListener("dragstart",g),a.root.addEventListener("mousemove",h)}function jo(a,b,c){if(!(a.state.selection instanceof fH))return null;let{$head:d}=a.state.selection;for(let e=d.depth-1;e>=0;e--){let f=d.node(e);if((c<0?d.index(e):d.indexAfter(e))!=(c<0?0:f.childCount))break;if("cell"==f.type.spec.tableRole||"header_cell"==f.type.spec.tableRole){let f=d.before(e),g="vert"==b?c>0?"down":"up":c>0?"right":"left";return a.endOfTextblock(g)?f:null}}return null}function jp(a,b){for(;b&&b!=a.dom;b=b.parentNode)if("TD"==b.nodeName||"TH"==b.nodeName)return b;return null}function jq(a,b){let c=a.posAtCoords({left:b.clientX,top:b.clientY});if(!c)return null;let{inside:d,pos:e}=c;return d>=0&&iI(a.state.doc.resolve(d))||iI(a.state.doc.resolve(e))}var jr=class{constructor(a,b){this.node=a,this.defaultCellMinWidth=b,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${b}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),js(a,this.colgroup,this.table,b),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(a){return a.type==this.node.type&&(this.node=a,js(a,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(a){return"attributes"==a.type&&(a.target==this.table||this.colgroup.contains(a.target))}};function js(a,b,c,d,e,f){let g=0,h=!0,i=b.firstChild,j=a.firstChild;if(j){for(let a=0,c=0;a<j.childCount;a++){let{colspan:k,colwidth:l}=j.child(a).attrs;for(let a=0;a<k;a++,c++){let j=e==c?f:l&&l[a],k=j?j+"px":"";if(g+=j||d,j||(h=!1),i)i.style.width!=k&&(i.style.width=k),i=i.nextSibling;else{let a=document.createElement("col");a.style.width=k,b.appendChild(a)}}}for(;i;){var k;let a=i.nextSibling;null==(k=i.parentNode)||k.removeChild(i),i=a}h?(c.style.width=g+"px",c.style.minWidth=""):(c.style.width="",c.style.minWidth=g+"px")}}let jt=new fY("tableColumnResizing");var ju=class a{constructor(a,b){this.activeHandle=a,this.dragging=b}apply(b){let c=b.getMeta(jt);if(c&&null!=c.setHandle)return new a(c.setHandle,!1);if(c&&void 0!==c.setDragging)return new a(this.activeHandle,c.setDragging);if(this.activeHandle>-1&&b.docChanged){let c=b.mapping.map(this.activeHandle,-1);return iL(b.doc.resolve(c))||(c=-1),new a(c,this.dragging)}return this}};function jv(a,b,c,d){let e=a.posAtCoords({left:b.clientX+("right"==c?-d:d),top:b.clientY});if(!e)return -1;let{pos:f}=e,g=iI(a.state.doc.resolve(f));if(!g)return -1;if("right"==c)return g.pos;let h=iF.get(g.node(-1)),i=g.start(-1),j=h.map.indexOf(g.pos-i);return j%h.width==0?-1:i+h.map[j-1]}function jw(a,b,c){let d=b.clientX-a.startX;return Math.max(c,a.startWidth+d)}function jx(a,b){a.dispatch(a.state.tr.setMeta(jt,{setHandle:b}))}function jy(a,b,c,d){let e=a.state.doc.resolve(b),f=e.node(-1),g=e.start(-1),h=iF.get(f).colCount(e.pos-g)+e.nodeAfter.attrs.colspan-1,i=a.domAtPos(e.start(-1)).node;for(;i&&"TABLE"!=i.nodeName;)i=i.parentNode;i&&js(f,i.firstChild,i,d,h,c)}var jz=p,jA=a.i(985209);let jB=(a,b)=>!a.selection.empty&&(b&&b(a.tr.deleteSelection().scrollIntoView()),!0);function jC(a,b){let{$cursor:c}=a.selection;return c&&(b?b.endOfTextblock("backward",a):!(c.parentOffset>0))?c:null}let jD=(a,b,c)=>{let d=jC(a,c);if(!d)return!1;let e=jH(d);if(!e){let c=d.blockRange(),e=c&&fg(c);return null!=e&&(b&&b(a.tr.lift(c,e).scrollIntoView()),!0)}let f=e.nodeBefore;if(jR(a,e,b,-1))return!0;if(0==d.parent.content.size&&(jF(f,"end")||fJ.isSelectable(f)))for(let c=d.depth;;c--){let g=fq(a.doc,d.before(c),d.after(c),el.empty);if(g&&g.slice.size<g.to-g.from){if(b){let c=a.tr.step(g);c.setSelection(jF(f,"end")?fD.findFrom(c.doc.resolve(c.mapping.map(e.pos,-1)),-1):fJ.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 jE(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=fq(a.doc,e,g,el.empty);if(!h||h.from!=e||h instanceof fc&&h.slice.size>=g-e)return!1;if(c){let b=a.tr.step(h);b.setSelection(fH.create(b.doc,e)),c(b.scrollIntoView())}return!0}function jF(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 jG=(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=jH(d)}let g=f&&f.nodeBefore;return!!g&&!!fJ.isSelectable(g)&&(b&&b(a.tr.setSelection(fJ.create(a.doc,f.pos-g.nodeSize)).scrollIntoView()),!0)};function jH(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 jI(a,b){let{$cursor:c}=a.selection;return c&&(b?b.endOfTextblock("forward",a):!(c.parentOffset<c.parent.content.size))?c:null}let jJ=(a,b,c)=>{let d=jI(a,c);if(!d)return!1;let e=jL(d);if(!e)return!1;let f=e.nodeAfter;if(jR(a,e,b,1))return!0;if(0==d.parent.content.size&&(jF(f,"start")||fJ.isSelectable(f))){let c=fq(a.doc,d.before(),d.after(),el.empty);if(c&&c.slice.size<c.to-c.from){if(b){let d=a.tr.step(c);d.setSelection(jF(f,"start")?fD.findFrom(d.doc.resolve(d.mapping.map(e.pos)),1):fJ.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)},jK=(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=jL(d)}let g=f&&f.nodeAfter;return!!g&&!!fJ.isSelectable(g)&&(b&&b(a.tr.setSelection(fJ.create(a.doc,f.pos)).scrollIntoView()),!0)};function jL(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 jM=(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 jN(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 jO=(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=jN(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(fD.near(e.doc.resolve(d),1)),b(e.scrollIntoView())}return!0},jP=(a,b)=>{let c=a.selection,{$from:d,$to:e}=c;if(c instanceof fL||d.parent.inlineContent||e.parent.inlineContent)return!1;let f=jN(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(fH.create(g.doc,c+1)),b(g.scrollIntoView())}return!0},jQ=(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(fl(a.doc,d))return b&&b(a.tr.split(d).scrollIntoView()),!0}let d=c.blockRange(),e=d&&fg(d);return null!=e&&(b&&b(a.tr.lift(d,e).scrollIntoView()),!0)};function jR(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||fm(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=ef.empty;for(let a=j.length-1;a>=0;a--)e=ef.from(j[a].create(null,e));e=ef.from(h.copy(e));let f=a.tr.step(new fd(b.pos-1,d,b.pos,d,new el(e,1,0),j.length,!0)),g=f.doc.resolve(d+2*j.length);g.nodeAfter&&g.nodeAfter.type==h.type&&fm(f.doc,g.pos)&&f.join(g.pos),c(f.scrollIntoView())}return!0}let n=i.type.spec.isolating||d>0&&l?null:fD.findFrom(b,1),o=n&&n.$from.blockRange(n.$to),p=o&&fg(o);if(null!=p&&p>=b.depth)return c&&c(a.tr.lift(o,p).scrollIntoView()),!0;if(m&&jF(i,"start",!0)&&jF(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=ef.empty;for(let a=e.length-1;a>=0;a--)d=ef.from(e[a].copy(d));c(a.tr.step(new fd(b.pos-e.length,b.pos+i.nodeSize,b.pos+g,b.pos+i.nodeSize-g,new el(d,e.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function jS(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(fH.create(b.doc,a<0?e.start(f):e.end(f)))),!0)}}let jT=jS(-1),jU=jS(1);function jV(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 jW(...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 jX=jW(jB,jD,jG),jY=jW(jB,jJ,jK),jZ={Enter:jW(jM,jP,jQ,(a,b)=>{let{$from:c,$to:d}=a.selection;if(a.selection instanceof fJ&&a.selection.node.isBlock)return!!c.parentOffset&&!!fl(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=jN(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 fH||a.selection instanceof fL)&&j.deleteSelection();let k=j.mapping.map(c.pos),l=fl(j.doc,k,e.length,e);if(l||(e[0]=g?{type:g}:null,l=fl(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":jO,Backspace:jX,"Mod-Backspace":jX,"Shift-Backspace":jX,Delete:jY,"Mod-Delete":jY,"Mod-a":(a,b)=>(b&&b(a.tr.setSelection(new fL(a.doc))),!0)},j$={"Ctrl-h":jZ.Backspace,"Alt-Backspace":jZ["Mod-Backspace"],"Ctrl-d":jZ.Delete,"Ctrl-Alt-Backspace":jZ["Mod-Delete"],"Alt-Delete":jZ["Mod-Delete"],"Alt-d":jZ["Mod-Delete"],"Ctrl-a":jT,"Ctrl-e":jU};for(let a in jZ)j$[a]=jZ[a];"u">typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"u">typeof os&&os.platform&&os.platform();var j_=Object.defineProperty,j0=(a,b)=>{for(var c in b)j_(a,c,{get:b[c],enumerable:!0})};function j1(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 j2=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:j1({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}},j3={};j0(j3,{blur:()=>j4,clearContent:()=>j5,clearNodes:()=>j6,command:()=>j7,createParagraphNear:()=>j8,cut:()=>j9,deleteCurrentNode:()=>ka,deleteNode:()=>kc,deleteRange:()=>kd,deleteSelection:()=>kf,enter:()=>kg,exitCode:()=>kh,extendMarkRange:()=>ko,first:()=>kp,focus:()=>kv,forEach:()=>kw,insertContent:()=>kx,insertContentAt:()=>kA,joinBackward:()=>kD,joinDown:()=>kC,joinForward:()=>kE,joinItemBackward:()=>kF,joinItemForward:()=>kG,joinTextblockBackward:()=>kH,joinTextblockForward:()=>kI,joinUp:()=>kB,keyboardShortcut:()=>kK,lift:()=>kM,liftEmptyBlock:()=>kN,liftListItem:()=>kO,newlineInCode:()=>kP,resetAttributes:()=>kS,scrollIntoView:()=>kT,selectAll:()=>kU,selectNodeBackward:()=>kV,selectNodeForward:()=>kW,selectParentNode:()=>kX,selectTextblockEnd:()=>kY,selectTextblockStart:()=>kZ,setContent:()=>k_,setMark:()=>lB,setMeta:()=>lC,setNode:()=>lD,setNodeSelection:()=>lE,setTextDirection:()=>lF,setTextSelection:()=>lG,sinkListItem:()=>lH,splitBlock:()=>lJ,splitListItem:()=>lK,toggleList:()=>lN,toggleMark:()=>lO,toggleNode:()=>lP,toggleWrap:()=>lQ,undoInputRule:()=>lR,unsetAllMarks:()=>lS,unsetMark:()=>lT,unsetTextDirection:()=>lU,updateAttributes:()=>lV,wrapIn:()=>lW,wrapInList:()=>lX});var j4=()=>({editor:a,view:b})=>(requestAnimationFrame(()=>{var c;a.isDestroyed||(b.dom.blur(),null==(c=null==window?void 0:window.getSelection())||c.removeAllRanges())}),!0),j5=(a=!0)=>({commands:b})=>b.setContent("",{emitUpdate:a}),j6=()=>({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=fg(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)},j7=a=>b=>a(b),j8=()=>({state:a,dispatch:b})=>jP(a,b),j9=(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 fH(d.doc.resolve(Math.max(g-1,0)))),!0},ka=()=>({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 kb(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 kc=a=>({tr:b,state:c,dispatch:d})=>{let e=kb(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},kd=a=>({tr:b,dispatch:c})=>{let{from:d,to:e}=a;return c&&b.delete(d,e),!0},ke=(a,b,c)=>{var d;return!a.parent.isInline||"left"===c&&a.pos>a.start()||"right"===c&&a.pos<a.end()?a.pos:(d=b.nodes[a.parent.type.name].spec).content&&/^text(\*|\+)/.test(d.content)?"left"===c?a.start()-1:a.end()+1:a.pos},kf=()=>({state:a,dispatch:b})=>{var c;let{$from:d,$to:e}=a.selection;if(a.selection.empty)return!1;let{from:f,to:g}={from:ke(d,c=a.schema,"left"),to:ke(e,c,"right")};return b&&(a.tr.deleteRange(f,g).scrollIntoView(),b(a.tr)),!0},kg=()=>({commands:a})=>a.keyboardShortcut("Enter"),kh=()=>({state:a,dispatch:b})=>jO(a,b);function ki(a){return"[object RegExp]"===Object.prototype.toString.call(a)}function kj(a,b,c={strict:!0}){let d=Object.keys(b);return!d.length||d.every(d=>c.strict?b[d]===a[d]:ki(b[d])?b[d].test(a[d]):b[d]===a[d])}function kk(a,b,c={}){return a.find(a=>a.type===b&&kj(Object.fromEntries(Object.keys(c).map(b=>[b,a.attrs[b]])),c))}function kl(a,b,c={}){return!!kk(a,b,c)}function km(a,b,c){if(!a||!b)return;let d=a.parent.childAfter(a.parentOffset);if(d.node&&d.node.marks.some(a=>a.type===b)||(d=a.parent.childBefore(a.parentOffset)),!d.node||!d.node.marks.some(a=>a.type===b))return;if(!c){let a=d.node.marks.find(a=>a.type===b);a&&(c=a.attrs)}if(!kk([...d.node.marks],b,c))return;let e=d.index,f=a.start()+d.offset,g=e+1,h=f+d.node.nodeSize;for(;e>0&&kl([...a.parent.child(e-1).marks],b,c);)e-=1,f-=a.parent.child(e).nodeSize;for(;g<a.parent.childCount&&kl([...a.parent.child(g).marks],b,c);)h+=a.parent.child(g).nodeSize,g+=1;return{from:f,to:h}}function kn(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 ko=(a,b)=>({tr:c,state:d,dispatch:e})=>{let f=kn(a,d.schema),{doc:g,selection:h}=c,{$from:i,from:j,to:k}=h;if(e){let a=km(i,f,b);if(a&&a.from<=j&&a.to>=k){let b=fH.create(g,a.from,a.to);c.setSelection(b)}}return!0},kp=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 kq(a){return a instanceof fH}function kr(a=0,b=0,c=0){return Math.min(Math.max(a,b),c)}function ks(a,b=null){if(!b)return null;let c=fD.atStart(a),d=fD.atEnd(a);if("start"===b||!0===b)return c;if("end"===b)return d;let e=c.from,f=d.to;return"all"===b?fH.create(a,kr(0,e,f),kr(a.content.size,e,f)):fH.create(a,kr(b,e,f),kr(b,e,f))}function kt(){return"Android"===navigator.platform||/android/i.test(navigator.userAgent)}function ku(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var kv=(a=null,b={})=>({editor:c,view:d,tr:e,dispatch:f})=>{b={scrollIntoView:!0,...b};let g=()=>{(ku()||kt())&&d.dom.focus(),"u">typeof navigator&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&!ku()&&!kt()&&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&&!kq(c.state.selection))return g(),!0;let h=ks(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},kw=(a,b)=>c=>a.every((a,d)=>b(a,{...c,index:d})),kx=(a,b)=>({tr:c,commands:d})=>d.insertContentAt({from:c.selection.from,to:c.selection.to},a,b);function ky(a){throw Error("[tiptap error]: there is no window object available, so this function cannot be used")}function kz(a,b,c){if(a instanceof ey||a instanceof ef)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 ef.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),kz("",b,c)}if(e){if(c.errorOnInvalidContent){let d=!1,e="",f=new eN({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?eP.fromSchema(f).parseSlice(ky(a),c.parseOptions):eP.fromSchema(f).parse(ky(a),c.parseOptions),c.errorOnInvalidContent&&d)throw Error("[tiptap error]: Invalid HTML content",{cause:Error(`Invalid element found: ${e}`)})}let d=eP.fromSchema(b);return c.slice?d.parseSlice(ky(a),c.parseOptions).content:d.parse(ky(a),c.parseOptions)}return kz("",b,c)}var kA=(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{kz(b,f.schema,{parseOptions:j,errorOnInvalidContent:!0})}catch(a){i(a)}try{e=kz(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 ef){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&&n&&(k=Math.max(0,k-1)),d.replaceWith(k,l,h)}c.updateSelection&&function(a,b){let c=a.steps.length-1;if(c<b)return;let d=a.steps[c];if(!(d instanceof fc||d instanceof fd))return;let e=a.mapping.maps[c],f=0;e.forEach((a,b,c,d)=>{0===f&&(f=d)}),a.setSelection(fD.near(a.doc.resolve(f),-1))}(d,d.steps.length-1),c.applyInputRules&&d.setMeta("applyInputRules",{from:k,text:h}),c.applyPasteRules&&d.setMeta("applyPasteRules",{from:k,text:h})}return!0},kB=()=>({state:a,dispatch:b})=>((a,b)=>{let c=a.selection,d=c instanceof fJ,e;if(d){if(c.node.isTextblock||!fm(a.doc,c.from))return!1;e=c.from}else if(null==(e=fo(a.doc,c.from,-1)))return!1;if(b){let c=a.tr.join(e);d&&c.setSelection(fJ.create(c.doc,e-a.doc.resolve(e).nodeBefore.nodeSize)),b(c.scrollIntoView())}return!0})(a,b),kC=()=>({state:a,dispatch:b})=>((a,b)=>{let c=a.selection,d;if(c instanceof fJ){if(c.node.isTextblock||!fm(a.doc,c.to))return!1;d=c.to}else if(null==(d=fo(a.doc,c.to,1)))return!1;return b&&b(a.tr.join(d).scrollIntoView()),!0})(a,b),kD=()=>({state:a,dispatch:b})=>jD(a,b),kE=()=>({state:a,dispatch:b})=>jJ(a,b),kF=()=>({state:a,dispatch:b,tr:c})=>{try{let d=fo(a.doc,a.selection.$from.pos,-1);if(null==d)return!1;return c.join(d,2),b&&b(c),!0}catch{return!1}},kG=()=>({state:a,dispatch:b,tr:c})=>{try{let d=fo(a.doc,a.selection.$from.pos,1);if(null==d)return!1;return c.join(d,2),b&&b(c),!0}catch{return!1}},kH=()=>({state:a,dispatch:b})=>((a,b,c)=>{let d=jC(a,c);if(!d)return!1;let e=jH(d);return!!e&&jE(a,e,b)})(a,b),kI=()=>({state:a,dispatch:b})=>((a,b,c)=>{let d=jI(a,c);if(!d)return!1;let e=jL(d);return!!e&&jE(a,e,b)})(a,b);function kJ(){return"u">typeof navigator&&/Mac/.test(navigator.platform)}var kK=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))ku()||kJ()?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 kL(a,b,c={}){let{from:d,to:e,empty:f}=a.selection,g=b?kb(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=>kj(a.node.attrs,c,{strict:!1}));return f?!!j.length:j.reduce((a,b)=>a+b.to-b.from,0)>=i}var kM=(a,b={})=>({state:c,dispatch:d})=>{let e=kb(a,c.schema);return!!kL(c,e,b)&&((a,b)=>{let{$from:c,$to:d}=a.selection,e=c.blockRange(d),f=e&&fg(e);return null!=f&&(b&&b(a.tr.lift(e,f).scrollIntoView()),!0)})(c,d)},kN=()=>({state:a,dispatch:b})=>jQ(a,b),kO=a=>({state:b,dispatch:c})=>{var d;return(d=kb(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 fd(f-1,g,f,g,new el(ef.from(c.create(null,d.parent.copy())),1,0),1,!0)),d=new ew(e.doc.resolve(d.$from.pos),e.doc.resolve(g),d.depth));let h=fg(d);if(null==h)return!1;e.lift(d,h);let i=e.doc.resolve(e.mapping.map(f,-1)-1);return fm(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?ef.empty:ef.from(e))))return!1;let l=f.pos,m=l+g.nodeSize;return d.step(new fd(l-!!h,m+ +!!i,l+1,m-1,new el((h?ef.empty:ef.from(e.copy(ef.empty))).append(i?ef.empty:ef.from(e.copy(ef.empty))),+!h,+!i),+!h)),b(d.scrollIntoView()),!0}(a,b,f)))})(b,c)},kP=()=>({state:a,dispatch:b})=>jM(a,b);function kQ(a,b){return b.nodes[a]?"node":b.marks[a]?"mark":null}function kR(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 kS=(a,b)=>({tr:c,state:d,dispatch:e})=>{let f=null,g=null,h=kQ("string"==typeof a?a:a.name,d.schema);if(!h)return!1;"node"===h&&(f=kb(a,d.schema)),"mark"===h&&(g=kn(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,kR(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(kR(f.attrs,b))))})})}),i},kT=()=>({tr:a,dispatch:b})=>(b&&a.scrollIntoView(),!0),kU=()=>({tr:a,dispatch:b})=>{if(b){let b=new fL(a.doc);a.setSelection(b)}return!0},kV=()=>({state:a,dispatch:b})=>jG(a,b),kW=()=>({state:a,dispatch:b})=>jK(a,b),kX=()=>({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(fJ.create(a.doc,e))),!0)})(a,b),kY=()=>({state:a,dispatch:b})=>jU(a,b),kZ=()=>({state:a,dispatch:b})=>jT(a,b);function k$(a,b,c={},d={}){return kz(a,b,{slice:!1,parseOptions:c,errorOnInvalidContent:d.errorOnInvalidContent})}var k_=(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=k$(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 k0(a,b){let c=kn(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 k1(a,b){let c=new fB(a);return b.forEach(a=>{a.steps.forEach(a=>{c.step(a)})}),c}function k2(a,b){let c=[];return a.descendants((a,d)=>{b(a)&&c.push({node:a,pos:d})}),c}function k3(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 k4(a){return b=>k3(b.$from,a)}function k5(a,b,c){return void 0===a.config[b]&&a.parent?k5(a.parent,b,c):"function"==typeof a.config[b]?a.config[b].bind({...c,parent:a.parent?k5(a.parent,b,c):null}):a.config[b]}function k6(a){return a.map(a=>{let b={name:a.name,options:a.options,storage:a.storage},c=k5(a,"addExtensions",b);return c?[a,...k6(c())]:a}).flat(10)}function k7(a,b){let c=eY.fromSchema(b).serializeFragment(a),d=document.implementation.createHTMLDocument().createElement("div");return d.appendChild(c),d.innerHTML}function k8(a){return"function"==typeof a}function k9(a,b,...c){return k8(a)?b?a.bind(b)(...c):a(...c):a}function la(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 lb(a){let b=[],{nodeExtensions:c,markExtensions:d}=la(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=k5(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=k5(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 lc(a){let b=[],c=function(a){let b=[],c="",d=!1,e=!1,f=0,g=a.length;for(let h=0;h<g;h+=1){let g=a[h];if("'"===g&&!e){d=!d,c+=g;continue}if('"'===g&&!d){e=!e,c+=g;continue}if(!d&&!e){if("("===g){f+=1,c+=g;continue}if(")"===g&&f>0){f-=1,c+=g;continue}if(";"===g&&0===f){b.push(c),c="";continue}}c+=g}return c&&b.push(c),b}(a||""),d=c.length;for(let a=0;a<d;a+=1){let d=c[a],e=d.indexOf(":");if(-1===e)continue;let f=d.slice(0,e).trim(),g=d.slice(e+1).trim();f&&g&&b.push([f,g])}return b}function ld(...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=new Map([...lc(c[a]),...lc(b)]);c[a]=Array.from(d.entries()).map(([a,b])=>`${a}: ${b}`).join("; ")}else c[a]=b}),c},{})}function le(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)=>ld(a,b),{})}function lf(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 lg(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 lh(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 li(a){return a.sort((a,b)=>{let c=k5(a,"priority")||100,d=k5(b,"priority")||100;return c>d?-1:+(c<d)})}function lj(a){var b;let c=li(k6(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 lk(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 ll(a,b){let c={from:0,to:a.content.size};return lk(a,c,b)}function lm(a){return Object.fromEntries(Object.entries(a.nodes).filter(([,a])=>a.spec.toText).map(([a,b])=>[a,b.spec.toText]))}function ln(a,b){let c=kQ("string"==typeof b?b:b.name,a.schema);return"node"===c?function(a,b){let c=kb(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?k0(a,b):{}}function lo(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 lp(a,b,c){let d=[];return a===b?c.resolve(a).marks().forEach(b=>{let e=km(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 lq(a,b){return b.nodes[a]||b.marks[a]||null}function lr(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 ls(a,b,c={}){let{empty:d,ranges:e}=a.selection,f=b?kn(b,a.schema):null;if(d)return!!(a.storedMarks||a.selection.$from.marks()).filter(a=>!f||f.name===a.type.name).find(a=>kj(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=>kj(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 lt(a,b){return Array.isArray(b)?b.some(b=>("string"==typeof b?b:b.name)===a.name):b}function lu(a,b){let{nodeExtensions:c}=la(b),d=c.find(b=>b.name===a);if(!d)return!1;let e={name:d.name,options:d.options,storage:d.storage},f=k9(k5(d,"group",e));return"string"==typeof f&&f.split(" ").includes("list")}function lv(a,{checkChildren:b=!0,ignoreWhitespace:c=!1}={}){var d;if(c){if("hardBreak"===a.type.name)return!0;if(a.isText)return!/\S/.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&&(lv(a,{ignoreWhitespace:c,checkChildren:b})||(d=!1))}),d}return!1}function lw(a){return a instanceof fJ}var lx=class a{constructor(a){this.position=a}static fromJSON(b){return new a(b.position)}toJSON(){return{position:this.position}}};function ly(a,b){let c=b.mapping.mapResult(a.position);return{position:new lx(c.pos),mapResult:c}}function lz(a){return new lx(a)}function lA(a,b,c){let d=a.state.doc.content.size,e=kr(b,0,d),f=kr(c,0,d),g=a.coordsAtPos(e),h=a.coordsAtPos(f,-1),i=Math.min(g.top,h.top),j=Math.max(g.bottom,h.bottom),k=Math.min(g.left,h.left),l=Math.max(g.right,h.right),m={top:i,bottom:j,left:k,right:l,width:l-k,height:j-i,x:k,y:i};return{...m,toJSON:()=>m}}var lB=(a,b={})=>({tr:c,state:d,dispatch:e})=>{let{selection:f}=c,{empty:g,ranges:h}=f,i=kn(a,d.schema);if(e)if(g){let a=k0(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(kq(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)},lC=(a,b)=>({tr:c})=>(c.setMeta(a,b),!0),lD=(a,b={})=>({state:c,dispatch:d,chain:e})=>{let f,g=kb(a,c.schema);return(c.selection.$anchor.sameParent(c.selection.$head)&&(f=c.selection.$anchor.parent.attrs),g.isTextblock)?e().command(({commands:a})=>!!jV(g,{...f,...b})(c)||a.clearNodes()).command(({state:a})=>jV(g,{...f,...b})(a,d)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},lE=a=>({tr:b,dispatch:c})=>{if(c){let{doc:c}=b,d=kr(a,0,c.content.size),e=fJ.create(c,d);b.setSelection(e)}return!0},lF=(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},lG=a=>({tr:b,dispatch:c})=>{if(c){let{doc:c}=b,{from:d,to:e}="number"==typeof a?{from:a,to:a}:a,f=fH.atStart(c).from,g=fH.atEnd(c).to,h=kr(d,f,g),i=kr(e,f,g),j=fH.create(c,h,i);b.setSelection(j)}return!0},lH=a=>({state:b,dispatch:c})=>{var d;return(d=kb(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=ef.from(c?d.create():null),g=new el(ef.from(d.create(null,ef.from(h.type.create(null,e)))),c?3:1,0),j=f.start,k=f.end;b(a.tr.step(new fd(j-(c?3:1),k,j,k,g,1,!0)).scrollIntoView())}return!0})(b,c)};function lI(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 lJ=({keepMarks:a=!0}={})=>({tr:b,state:c,dispatch:d,editor:e})=>{let{selection:f,doc:g}=b,{$from:h,$to:i}=f,j=lr(e.extensionManager.attributes,h.node().type.name,h.node().attrs);if(f instanceof fJ&&f.node.isBlock)return!!h.parentOffset&&!!fl(g,h.pos)&&(d&&(a&&lI(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=fl(b.doc,b.mapping.map(h.pos),1,m);if(!m&&!n&&fl(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 fH&&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&&lI(c,e.extensionManager.splittableMarks),b.scrollIntoView()}return n},lK=(a,b={})=>({tr:c,state:d,dispatch:e,editor:f})=>{var g;let h=kb(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=ef.empty,d=i.index(-1)?1:i.index(-2)?2:3;for(let b=i.depth-d;b>=i.depth-3;b-=1)a=ef.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={...lr(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(ef.from(h.createAndFill(null,j)||void 0));let k=i.before(i.depth-(d-1));c.replace(k,i.after(-e),new el(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(fH.near(c.doc.resolve(l))),c.scrollIntoView()}return!0}let n=j.pos===i.end()?l.contentMatchAt(0).defaultType:null,o={...lr(m,l.type.name,l.attrs),...b},p={...lr(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(!fl(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},lL=(a,b)=>{let c=k4(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)&&fm(a.doc,c.pos))||(a.join(c.pos),!0)},lM=(a,b)=>{let c=k4(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)&&fm(a.doc,d))||(a.join(d),!0)},lN=(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=kb(a,g.schema),o=kb(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=k4(a=>lu(a.type.name,l))(p),w=0===p.from&&p.to===g.doc.content.size,x=g.doc.content.content,y=1===x.length?x[0]:null,z=w&&y&&lu(y.type.name,l)?{node:y,pos:0,depth:0}:null,A=null!=v?v:z,B=!!v&&t.depth>=1&&t.depth-v.depth<=1,C=!!z;if((B||C)&&A){if(A.node.type===n)return w&&C?i().command(({tr:a,dispatch:b})=>{let c=function(a){let b=a.doc,c=b.firstChild;if(!c)return null;let d=b.resolve(1),e=b.resolve(c.nodeSize-1);return fH.between(d,e)}(a);return!!c&&(a.setSelection(c),b&&b(a),!0)}).liftListItem(o).run():j.liftListItem(o);if(lu(A.node.type.name,l)&&n.validContent(A.node.content))return i().command(()=>(f.setNodeMarkup(A.pos,n),!0)).command(()=>lL(f,n)).command(()=>lM(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(()=>lL(f,n)).command(()=>lM(f,n)).run():i().command(()=>!!k().wrapInList(n,d)||j.clearNodes()).wrapInList(n,d).command(()=>lL(f,n)).command(()=>lM(f,n)).run()},lO=(a,b={},c={})=>({state:d,commands:e})=>{let{extendEmptyMarkRange:f=!1}=c,g=kn(a,d.schema);return ls(d,g,b)?e.unsetMark(g,{extendEmptyMarkRange:f}):e.setMark(g,b)},lP=(a,b,c={})=>({state:d,commands:e})=>{let f,g=kb(a,d.schema),h=kb(b,d.schema),i=kL(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})},lQ=(a,b={})=>({state:c,commands:d})=>{let e=kb(a,c.schema);return kL(c,e,b)?d.lift(e):d.wrapIn(e,b)},lR=()=>({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},lS=()=>({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)},lT=(a,b={})=>({tr:c,state:d,dispatch:e})=>{var f;let{extendEmptyMarkRange:g=!1}=b,{selection:h}=c,i=kn(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=km(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},lU=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},lV=(a,b={})=>({tr:c,state:d,dispatch:e})=>{let f=null,g=null,h=kQ("string"==typeof a?a:a.name,d.schema);if(!h)return!1;"node"===h&&(f=kb(a,d.schema)),"mark"===h&&(g=kn(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},lW=(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&&fh(g,a,b);return!!h&&(d&&d(c.tr.wrap(g,h).scrollIntoView()),!0)}})(kb(a,c.schema),b)(c,d),lX=(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 ew(a,a,b.depth),b.endIndex<b.parent.childCount&&(b=new ew(b.$from,g.resolve(b.$to.end(b.depth)),b.depth)),e=!0}let h=fh(f,c,d,b);return!!h&&(a&&function(a,b,c,d,e){let f=ef.empty;for(let a=c.length-1;a>=0;a--)f=ef.from(c[a].type.create(c[a].attrs,f));a.step(new fd(b.start-2*!!d,b.end,b.start,b.end,new el(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&&fl(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)}})(kb(a,c.schema),b)(c,d),lY=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={}}},lZ=class{constructor(a){var b;this.find=a.find,this.handler=a.handler,this.undoable=null==(b=a.undoable)||b}};function l$(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(ki(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=j1({state:i.state,transaction:g}),m={from:d-(b[0].length-f.length),to:e},{commands:n,chain:o,can:p}=new j2({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 l_(a){return"Object"===Object.prototype.toString.call(a).slice(8,-1)&&a.constructor===Object&&Object.getPrototypeOf(a)===Object.prototype}var l0=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{...k9(k5(this,"addOptions",{name:this.name}))}}get storage(){return{...k9(k5(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 l_(b)&&l_(c)&&Object.keys(c).forEach(e=>{l_(c[e])&&l_(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,this.child=null,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}},l1=class a extends l0{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)}},l2=class{constructor(a){this.find=a.find,this.handler=a.handler}},l3=null,l4=class{constructor(a,b){this.splittableMarks=[],this.editor=b,this.baseExtensions=a,this.extensions=lj(a),this.schema=function(a,b){var c;let d=lb(a),{nodeExtensions:e,markExtensions:f}=la(a),g=null==(c=e.find(a=>k5(a,"topNode")))?void 0:c.name;return new eN({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=lg({...a.reduce((a,b)=>{let d=k5(b,"extendNodeSchema",f);return{...a,...d?d(c):{}}},{}),content:k9(k5(c,"content",f)),marks:k9(k5(c,"marks",f)),group:k9(k5(c,"group",f)),inline:k9(k5(c,"inline",f)),atom:k9(k5(c,"atom",f)),selectable:k9(k5(c,"selectable",f)),draggable:k9(k5(c,"draggable",f)),code:k9(k5(c,"code",f)),whitespace:k9(k5(c,"whitespace",f)),linebreakReplacement:k9(k5(c,"linebreakReplacement",f)),defining:k9(k5(c,"defining",f)),isolating:k9(k5(c,"isolating",f)),attrs:Object.fromEntries(e.map(lh))}),h=k9(k5(c,"parseHTML",f));h&&(g.parseDOM=h.map(a=>lf(a,e)));let i=k5(c,"renderHTML",f);i&&(g.toDOM=a=>i({node:a,HTMLAttributes:le(a,e)}));let j=k5(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=lg({...a.reduce((a,b)=>{let d=k5(b,"extendMarkSchema",f);return{...a,...d?d(c):{}}},{}),inclusive:k9(k5(c,"inclusive",f)),excludes:k9(k5(c,"excludes",f)),group:k9(k5(c,"group",f)),spanning:k9(k5(c,"spanning",f)),code:k9(k5(c,"code",f)),attrs:Object.fromEntries(e.map(lh))}),h=k9(k5(c,"parseHTML",f));h&&(g.parseDOM=h.map(a=>lf(a,e)));let i=k5(c,"renderHTML",f);return i&&(g.toDOM=a=>i({mark:a,HTMLAttributes:le(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:lq(b.name,this.schema)},d=k5(b,"addCommands",c);return d?{...a,...d()}:a},{})}get plugins(){let{editor:a}=this;return li([...this.extensions].reverse()).flatMap(b=>{let c={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:a,type:lq(b.name,this.schema)},d=[],e=k5(b,"addKeyboardShortcuts",c),f={};if("mark"===b.type&&k5(b,"exitable",c)&&(f.ArrowRight=()=>l1.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 fV({props:{handleKeyDown:iE(f)}});d.push(g);let h=k5(b,"addInputRules",c);if(lt(b,a.options.enableInputRules)&&h){let b=h();if(b&&b.length){let c=function(a){let{editor:b,rules:c}=a,d=new fV({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=k7(ef.from(a),f.schema));let{from:e}=h,g=e+a.length;l$({editor:b,from:e,to:g,text:a,rules:c,plugin:d})}),a.selectionSet||a.docChanged?null:e}},props:{handleTextInput:(a,e,f,g)=>l$({editor:b,from:e,to:f,text:g,rules:c,plugin:d}),handleDOMEvents:{compositionend:a=>(setTimeout(()=>{let{$cursor:e}=a.state.selection;e&&l$({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&&l$({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=k5(b,"addPasteRules",c);if(lt(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 j2({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(ki(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:j1({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 fV({view(a){let b=b=>{var d;(e=(null==(d=a.dom.parentElement)?void 0:d.contains(b.target))?a.dom.parentElement:null)&&(l3=c)},d=()=>{l3&&(l3=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=l3;(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=k7(ef.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=k5(b,"addProseMirrorPlugins",c);if(j){let a=j();d.push(...a)}return d})}get attributes(){return lb(this.extensions)}get nodeViews(){let{editor:a}=this,{nodeExtensions:b}=la(this.extensions);return Object.fromEntries(b.filter(a=>!!k5(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:kb(b.name,this.schema)},e=k5(b,"addNodeView",d);if(!e)return[];let f=e();return f?[b.name,(d,e,g,h,i)=>{let j=le(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 li([...this.extensions].reverse()).reduceRight((a,c)=>{let d={name:c.name,options:c.options,storage:this.editor.extensionStorage[c.name],editor:b,type:lq(c.name,this.schema)},e=k5(c,"dispatchTransaction",d);return e?b=>{e.call(d,{transaction:b,next:a})}:a},a)}transformPastedHTML(a){let{editor:b}=this;return li([...this.extensions]).reduce((a,c)=>{let d={name:c.name,options:c.options,storage:this.editor.extensionStorage[c.name],editor:b,type:lq(c.name,this.schema)},e=k5(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}=la(this.extensions);return Object.fromEntries(b.filter(a=>!!k5(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:kn(b.name,this.schema)},e=k5(b,"addMarkView",d);return e?[b.name,(d,f,g)=>{let h=le(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)}})}]:[]}))}destroy(){this.extensions.forEach(a=>{let b=a;for(;b.parent;){let a=b.parent;a.child===b&&(a.child=null),b=a}}),this.extensions=[],this.baseExtensions=[],this.schema=null,this.editor=null}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:lq(a.name,this.schema)};"mark"===a.type&&(null==(b=k9(k5(a,"keepOnSplit",c)))||b)&&this.splittableMarks.push(a.name);let d=k5(a,"onBeforeCreate",c),e=k5(a,"onCreate",c),f=k5(a,"onUpdate",c),g=k5(a,"onSelectionUpdate",c),h=k5(a,"onTransaction",c),i=k5(a,"onFocus",c),j=k5(a,"onBlur",c),k=k5(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)})}};l4.resolve=lj,l4.sort=li,l4.flatten=k6,j0({},{ClipboardTextSerializer:()=>l6,Commands:()=>l7,Delete:()=>l8,Drop:()=>l9,Editable:()=>ma,FocusEvents:()=>mc,Keymap:()=>md,Paste:()=>me,Tabindex:()=>mf,TextDirection:()=>mg,focusEventsPluginKey:()=>mb});var l5=class a extends l0{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)}},l6=l5.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new fV({key:new fY("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=lm(c);return lk(d,{from:g,to:h},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:i})}}})]}}),l7=l5.create({name:"commands",addCommands:()=>({...j3})}),l8=l5.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=k1(a.before,[a,...b]);lo(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 e9){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=f>0&&(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()}}),l9=l5.create({name:"drop",addProseMirrorPlugins(){return[new fV({key:new fY("tiptapDrop"),props:{handleDrop:(a,b,c,d)=>{this.editor.emit("drop",{editor:this.editor,event:b,slice:c,moved:d})}}})]}}),ma=l5.create({name:"editable",addProseMirrorPlugins(){return[new fV({key:new fY("editable"),props:{editable:()=>this.editor.options.editable}})]}}),mb=new fY("focusEvents"),mc=l5.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:a}=this;return[new fV({key:mb,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}}}})]}}),md=l5.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:fD.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 ku()||kJ()?e:d},addProseMirrorPlugins(){return[new fV({key:new fY("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=fD.atStart(b.doc).from,j=fD.atEnd(b.doc).to;if(f||g!==i||h!==j||!lv(c.doc))return;let k=c.tr,l=j1({state:c,transaction:k}),{commands:m}=new j2({editor:this.editor,state:l});if(m.clearNodes(),k.steps.length)return k}})]}}),me=l5.create({name:"paste",addProseMirrorPlugins(){return[new fV({key:new fY("tiptapPaste"),props:{handlePaste:(a,b,c)=>{this.editor.emit("paste",{editor:this.editor,event:b,slice:c})}}})]}}),mf=l5.create({name:"tabindex",addOptions:()=>({value:void 0}),addProseMirrorPlugins(){return[new fV({key:new fY("tabindex"),props:{attributes:()=>{var a;return this.editor.isEditable||void 0!==this.options.value?{tabindex:null!=(a=this.options.value)?a:"0"}:{}}}})]}}),mg=l5.create({name:"textDirection",addOptions:()=>({direction:void 0}),addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:a}=la(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 fV({key:new fY("textDirection"),props:{attributes:()=>{let a=this.options.direction;return a?{dir:a}:{}}}})]}}),mh=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)}},mi=`.ProseMirror {
21
+ ${b}/api/agent/files/${a??"<path/to/file.md>"}`;await navigator.clipboard.writeText(d),c(!0),setTimeout(()=>c(!1),1500)},[a])}}(a??null),[k,l]=(0,p.useState)(""),m=(0,p.useRef)(null),n="http://localhost:3000",q=(0,p.useCallback)(()=>b5,[]),s=(0,p.useCallback)(()=>k.replace(/\$WIKI_URL/g,n),[k,n]),t=(0,p.useCallback)(()=>`npx wiki-viewer-mcp register --url ${n} --id ai:myagent --name "My Agent"`,[n]),u=(0,p.useCallback)(()=>JSON.stringify({servers:{"wiki-viewer":{command:"npx",args:["wiki-viewer-mcp"],env:{WIKI_VIEWER_URL:n,WIKI_VIEWER_TOKEN:"<token from register>",WIKI_VIEWER_AGENT_ID:"ai:myagent"}}}},null,2),[n]),w=b6(q),x=b6(s),y=b6(t),z=b6(u);return((0,p.useEffect)(()=>{if(b)return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a);function a(a){"Escape"===a.key&&c()}},[b,c]),(0,p.useEffect)(()=>{b&&m.current?.focus()},[b]),(0,p.useEffect)(()=>{if(!b)return;f();let a=setInterval(()=>void f(),1e4);return()=>clearInterval(a)},[b,f]),(0,p.useEffect)(()=>{b&&fetch((0,av.apiUrl)("/api/agents/install")).then(a=>a.json()).then(a=>{a.bootstrapPrompt&&l(a.bootstrapPrompt)}).catch(()=>void 0)},[b]),b)?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px]",onClick:c,"aria-hidden":!0}),(0,g.jsxs)("aside",{ref:m,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":"AI Agent Panel",className:"fixed right-0 top-0 bottom-0 z-50 flex w-[90vw] max-w-sm md:w-80 flex-col border-l border-border bg-background shadow-xl outline-none",children:[(0,g.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsx)(i,{className:"h-4 w-4 text-muted-foreground"}),(0,g.jsx)("span",{className:"text-sm font-semibold",children:"AI Agent"})]}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:c,title:"Close panel (Esc)",children:(0,g.jsx)(o,{className:"h-3.5 w-3.5"})})]}),(0,g.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-5 px-4 py-4",children:[(0,g.jsxs)("section",{className:"rounded-md border border-border bg-muted/30 p-3",children:[(0,g.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Work with this wiki using AI"}),(0,g.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:["Connect Claude, Cursor, ChatGPT, and more. Pick by what you want — each option gives a copy-paste setup. You approve every assistant in ",(0,g.jsx)("span",{className:"font-medium text-foreground/80",children:"Agents"})," below before it gets access."]})]}),(0,g.jsxs)("section",{className:"space-y-3",children:[(0,g.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,g.jsx)("p",{className:"text-xs font-semibold text-foreground",children:"Co-write docs with you"}),(0,g.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Edits arrive as suggestions with comments you accept or revert. No MCP needed."}),(0,g.jsx)(v.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void x.copy(),disabled:!k,children:x.copied?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(bd.Copy,{className:"h-3.5 w-3.5"})," Paste into any chatbot"]})}),(0,g.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 pt-1",children:["Or install once so it sticks"," ",(0,g.jsx)("span",{className:"text-muted-foreground/40",children:"· Claude, OpenCode"}),":"]}),(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:b5}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void w.copy(),children:w.copied?(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,g.jsx)(bd.Copy,{className:"h-3.5 w-3.5"})})]})]}),(0,g.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,g.jsxs)("p",{className:"text-xs font-semibold text-foreground",children:["Edit files directly"," ",(0,g.jsx)("span",{className:"font-normal text-muted-foreground/60",children:"· Claude Code, Cursor, Codex"})]}),(0,g.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Native read / search / edit tools over MCP. Run to request access:"}),(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:t()}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void y.copy(),children:y.copied?(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,g.jsx)(bd.Copy,{className:"h-3.5 w-3.5"})})]}),(0,g.jsxs)("p",{className:"text-[10px] text-muted-foreground/50",children:["Approve in ",(0,g.jsx)("span",{className:"font-medium text-foreground/70",children:"Agents"}),", then add to your tool:"]}),(0,g.jsx)(v.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void z.copy(),children:z.copied?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(bd.Copy,{className:"h-3.5 w-3.5"})," Copy config (mcp.json)"]})})]}),(0,g.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,g.jsx)("span",{className:"text-[10px] text-muted-foreground/50",children:"For developers:"}),(0,g.jsxs)("button",{type:"button",onClick:()=>void j(),className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[h?(0,g.jsx)(r.Check,{className:"h-3 w-3 text-green-500"}):(0,g.jsx)(bd.Copy,{className:"h-3 w-3"})," curl example"]}),(0,g.jsxs)("a",{href:(0,av.apiUrl)("/api/agents/skill"),target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,g.jsx)(bE,{className:"h-3 w-3"})," skill"]}),(0,g.jsxs)("a",{href:(0,av.apiUrl)("/api/agents/install"),target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,g.jsx)(bE,{className:"h-3 w-3"})," install JSON"]})]})]}),(0,g.jsx)(bN,{}),(0,g.jsxs)("section",{className:"space-y-2",children:[(0,g.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:["Active Connections"," ",(0,g.jsx)("span",{className:"normal-case font-normal text-muted-foreground/50",children:"(last 5 min)"})]}),(0,g.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-3",children:0===e.length?(0,g.jsxs)("p",{className:"text-xs text-muted-foreground/60 flex items-center gap-1.5",children:[(0,g.jsx)(bD,{className:"h-3.5 w-3.5"}),"No recent activity"]}):(0,g.jsx)("ul",{className:"space-y-1.5",children:e.map(a=>(0,g.jsxs)("li",{className:"flex items-center justify-between text-xs",children:[(0,g.jsx)("span",{className:"font-mono text-foreground/80 truncate",children:a.by}),(0,g.jsxs)("span",{className:"text-muted-foreground shrink-0",children:[a.opCount," op",1!==a.opCount?"s":""]})]},a.by))})})]}),(0,g.jsxs)("section",{className:"space-y-2",children:[(0,g.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Recent Activity"}),(0,g.jsx)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 max-h-72 overflow-y-auto",children:(0,g.jsx)(b4,{activity:d})})]}),(0,g.jsx)("section",{children:(0,g.jsx)("a",{href:(0,av.apiUrl)("/docs/agent-collab-plan.md"),target:"_blank",rel:"noreferrer",className:"text-xs text-primary underline hover:no-underline",children:"Agent collaboration docs →"})})]})]})]}):null}var b8=a.i(765021);let b9=(0,h.default)("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]),ca=(0,h.default)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]),cb=(0,h.default)("file",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]),cc=(0,h.default)("file-plus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]),cd=(0,h.default)("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),ce=(0,h.default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),cf=(0,h.default)("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);function cg({pos:a,branches:b,loading:c,busyName:d,disabled:e,onPick:f,onClose:h}){let[i,j]=(0,p.useState)(""),k=(0,p.useRef)(null);if((0,p.useEffect)(()=>{let a=a=>{let b=a.target;k.current?.contains(b)||b?.closest?.("[data-branch-trigger]")||h()},b=a=>{"Escape"===a.key&&h()};return document.addEventListener("mousedown",a),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",b)}},[h]),"u"<typeof document)return null;let l=b.length>8,n=i.trim().toLowerCase(),o=n?b.filter(a=>a.name.toLowerCase().includes(n)):b;return(0,bu.createPortal)((0,g.jsx)("div",{ref:k,"data-branch-portal":!0,style:{position:"fixed",top:a.top,left:a.left},className:"pointer-events-auto z-[9999] flex max-h-72 w-52 flex-col overflow-hidden rounded-md border bg-popover p-1 shadow-md",children:c?(0,g.jsx)("div",{className:"flex justify-center py-2",children:(0,g.jsx)(m.Loader2,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"})}):0===b.length?(0,g.jsx)("p",{className:"px-2 py-1 text-[10px] text-muted-foreground",children:"No branches"}):(0,g.jsxs)(g.Fragment,{children:[l&&(0,g.jsx)("input",{autoFocus:!0,value:i,onChange:a=>j(a.target.value),placeholder:"Filter branches…",className:"mb-1 w-full shrink-0 rounded border bg-background px-1.5 py-1 text-[11px] outline-none focus:ring-1 focus:ring-ring"}),(0,g.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:0===o.length?(0,g.jsx)("p",{className:"px-2 py-1 text-[10px] text-muted-foreground",children:"No match"}):o.map(a=>(0,g.jsxs)("button",{type:"button",disabled:e||a.current,className:(0,ao.cn)("flex w-full items-center gap-1.5 rounded px-2 py-1 text-left text-[11px] hover:bg-muted",a.current?"font-semibold text-foreground":"text-muted-foreground"),onClick:b=>{b.stopPropagation(),a.current||f(a.name)},children:[a.current?(0,g.jsx)(r.Check,{className:"h-3 w-3 shrink-0"}):(0,g.jsx)("span",{className:"w-3 shrink-0"}),(0,g.jsx)("span",{className:"truncate",children:a.name}),d===a.name&&(0,g.jsx)(m.Loader2,{className:"ml-auto h-3 w-3 shrink-0 animate-spin"})]},a.name))})]})}),document.body)}var ch=a.i(280370),ci=a.i(385909),cj="ContextMenu",[ck,cl]=(0,y.createContextScope)(cj,[ch.createMenuScope]),cm=(0,ch.createMenuScope)(),[cn,co]=ck(cj),cp=a=>{let{__scopeContextMenu:b,children:c,onOpenChange:d,dir:e,modal:f=!0}=a,[h,i]=p.useState(!1),j=cm(b),k=(0,ci.useCallbackRef)(d),l=p.useCallback(a=>{i(a),k(a)},[k]);return(0,g.jsx)(cn,{scope:b,open:h,onOpenChange:l,modal:f,children:(0,g.jsx)(ch.Root,{...j,dir:e,open:h,onOpenChange:l,modal:f,children:c})})};cp.displayName=cj;var cq="ContextMenuTrigger",cr=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,disabled:d=!1,...e}=a,f=co(cq,c),h=cm(c),i=p.useRef({x:0,y:0}),j=p.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...i.current})}),k=p.useRef(0),l=p.useCallback(()=>window.clearTimeout(k.current),[]),m=a=>{i.current={x:a.clientX,y:a.clientY},f.onOpenChange(!0)};return p.useEffect(()=>l,[l]),p.useEffect(()=>void(d&&l()),[d,l]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ch.Anchor,{...h,virtualRef:j}),(0,g.jsx)(F.Primitive.span,{"data-state":f.open?"open":"closed","data-disabled":d?"":void 0,...e,ref:b,style:{WebkitTouchCallout:"none",...a.style},onContextMenu:d?a.onContextMenu:(0,w.composeEventHandlers)(a.onContextMenu,a=>{l(),m(a),a.preventDefault()}),onPointerDown:d?a.onPointerDown:(0,w.composeEventHandlers)(a.onPointerDown,cD(a=>{l(),k.current=window.setTimeout(()=>m(a),700)})),onPointerMove:d?a.onPointerMove:(0,w.composeEventHandlers)(a.onPointerMove,cD(l)),onPointerCancel:d?a.onPointerCancel:(0,w.composeEventHandlers)(a.onPointerCancel,cD(l)),onPointerUp:d?a.onPointerUp:(0,w.composeEventHandlers)(a.onPointerUp,cD(l))})]})});cr.displayName=cq;var cs=a=>{let{__scopeContextMenu:b,...c}=a,d=cm(b);return(0,g.jsx)(ch.Portal,{...d,...c})};cs.displayName="ContextMenuPortal";var ct="ContextMenuContent",cu=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=co(ct,c),f=cm(c),h=p.useRef(!1);return(0,g.jsx)(ch.Content,{...f,...d,ref:b,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:b=>{a.onCloseAutoFocus?.(b),!b.defaultPrevented&&h.current&&b.preventDefault(),h.current=!1},onInteractOutside:b=>{a.onInteractOutside?.(b),b.defaultPrevented||e.modal||(h.current=!0)},style:{...a.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});cu.displayName=ct,p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.Group,{...e,...d,ref:b})}).displayName="ContextMenuGroup";var cv=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.Label,{...e,...d,ref:b})});cv.displayName="ContextMenuLabel";var cw=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.Item,{...e,...d,ref:b})});cw.displayName="ContextMenuItem";var cx=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.CheckboxItem,{...e,...d,ref:b})});cx.displayName="ContextMenuCheckboxItem",p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.RadioGroup,{...e,...d,ref:b})}).displayName="ContextMenuRadioGroup";var cy=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.RadioItem,{...e,...d,ref:b})});cy.displayName="ContextMenuRadioItem";var cz=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.ItemIndicator,{...e,...d,ref:b})});cz.displayName="ContextMenuItemIndicator";var cA=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.Separator,{...e,...d,ref:b})});cA.displayName="ContextMenuSeparator",p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.Arrow,{...e,...d,ref:b})}).displayName="ContextMenuArrow";var cB=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.SubTrigger,{...e,...d,ref:b})});cB.displayName="ContextMenuSubTrigger";var cC=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=cm(c);return(0,g.jsx)(ch.SubContent,{...e,...d,ref:b,style:{...a.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});function cD(a){return b=>"mouse"!==b.pointerType?a(b):void 0}cC.displayName="ContextMenuSubContent";var cE=a.i(694079);p.forwardRef(({className:a,inset:b,children:c,...d},e)=>(0,g.jsxs)(cB,{ref:e,className:(0,ao.cn)("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",b&&"pl-8",a),...d,children:[c,(0,g.jsx)(a3.ChevronRight,{className:"ml-auto h-4 w-4"})]})).displayName=cB.displayName,p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(cC,{ref:c,className:(0,ao.cn)("z-50 min-w-[8rem] overflow-hidden rounded-sm border bg-popover p-1 text-popover-foreground shadow-golden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...b})).displayName=cC.displayName;let cF=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(cs,{children:(0,g.jsx)(cu,{ref:c,className:(0,ao.cn)("z-50 min-w-[8rem] overflow-hidden rounded-sm border bg-popover p-1 text-popover-foreground shadow-golden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...b})}));cF.displayName=cu.displayName;let cG=p.forwardRef(({className:a,inset:b,...c},d)=>(0,g.jsx)(cw,{ref:d,className:(0,ao.cn)("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",b&&"pl-8",a),...c}));cG.displayName=cw.displayName,p.forwardRef(({className:a,children:b,checked:c,...d},e)=>(0,g.jsxs)(cx,{ref:e,className:(0,ao.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),checked:c,...d,children:[(0,g.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,g.jsx)(cz,{children:(0,g.jsx)(r.Check,{className:"h-4 w-4"})})}),b]})).displayName=cx.displayName,p.forwardRef(({className:a,children:b,...c},d)=>(0,g.jsxs)(cy,{ref:d,className:(0,ao.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...c,children:[(0,g.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,g.jsx)(cz,{children:(0,g.jsx)(cE.Circle,{className:"h-2 w-2 fill-current"})})}),b]})).displayName=cy.displayName,p.forwardRef(({className:a,inset:b,...c},d)=>(0,g.jsx)(cv,{ref:d,className:(0,ao.cn)("px-2 py-1.5 text-sm font-normal",b&&"pl-8",a),...c})).displayName=cv.displayName;let cH=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(cA,{ref:c,className:(0,ao.cn)("-mx-1 my-1 h-px bg-muted",a),...b}));cH.displayName=cA.displayName;let cI=(0,ay.create)((a,b)=>({humanize:!1,toggle:()=>{a({humanize:!b().humanize})}})),cJ=(0,ay.create)((a,b)=>({showHidden:!1,toggle:()=>{a({showHidden:!b().showHidden})}}));function cK(a){return a.split(".").pop()?.toLowerCase()??""}function cL(a,b){if("node-app"===b)return"node-app";if("app"===b)return"app";if("dir"===b)return"fallback";let c=a.split("/").pop()??a;if(c.startsWith(".")&&-1===c.indexOf(".",1))return"source";let d=cK(a);return d?["md","markdown"].includes(d)?"editor":"txt"===d?"text":["csv","tsv"].includes(d)?"csv":"pdf"===d?"pdf":["mmd","mermaid"].includes(d)?"mermaid":"ipynb"===d?"notebook":["png","jpg","jpeg","gif","webp","svg","avif","ico","bmp"].includes(d)?"image":["mp4","webm","mov","m4v","mp3","wav","ogg","m4a","aac"].includes(d)?"media":"docx"===d?"docx":["xlsx","xlsm"].includes(d)?"xlsx":"pptx"===d?"pptx":"html"===d?"html":(["py","js","ts","tsx","jsx","go","rs","java","c","cpp","h","sh","bash","zsh","rb","php","swift","kt","lua","sql","yaml","yml","toml","json","xml","css","scss"].includes(d),"source"):"source"}let cM=new Set(["txt","md","markdown","json","yaml","yml","toml","csv","tsv","xml","html","css","js","ts","tsx","jsx","sh","bash","zsh","rb","py","go","rs","java","c","cpp","h","php","swift","kt","lua","sql","scss","mmd","mermaid","ini","env","log","conf"]);function cN(a){let b=cL(a,"file");return"editor"===b||"text"===b||cM.has(cK(a))}function cO(a){return["md","markdown"].includes(cK(a))}function cP(a){return"image"===cL(a,"file")}function cQ(a){return"html"===cL(a,"file")}let cR={contentVisibility:"auto",containIntrinsicSize:"auto 32px"};function cS({node:a,ctx:b,isFavorited:c,activeWorkspaceId:d}){return(0,g.jsxs)(cF,{className:"w-48",children:[(0,g.jsxs)(cG,{onSelect:()=>b.copyPath(a.path),children:[(0,g.jsx)(bd.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),cO(a.name)&&(0,g.jsxs)(cG,{onSelect:()=>b.copyWikiLink(a.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,g.jsxs)(cG,{onSelect:()=>b.copyUrl(a.path),children:[(0,g.jsx)(b9,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===a.type&&cN(a.name)&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(cG,{onSelect:()=>b.copyRawContent(a.path),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,g.jsxs)(cG,{onSelect:()=>b.copyFormattedContent(a.path,a.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,g.jsx)(cH,{}),"dir"===a.type&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(cG,{onSelect:()=>{a.expanded||b.toggleFolder(a),b.setNewFileParent(a.path),b.setNewFileName(""),b.setFileCreateError(null)},children:[(0,g.jsx)(cc,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,g.jsxs)(cG,{onSelect:()=>b.triggerUpload(a.path),children:[(0,g.jsx)(cf,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,g.jsxs)(cG,{onSelect:()=>{b.setNewFolderParent(a.path),b.setNewFolderName(""),b.setFolderError(null)},children:[(0,g.jsx)(cd,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,g.jsx)(cH,{})]}),(0,g.jsxs)(cG,{onSelect:()=>b.handleDownload(a),children:[(0,g.jsx)(b8.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===a.type?"Download":"Download as zip"]}),(0,g.jsxs)(cG,{onSelect:()=>b.toggleFavorite(a,d),children:[(0,g.jsx)(ba,{className:(0,ao.cn)("mr-2 h-3.5 w-3.5",c&&"fill-current text-amber-400")}),c?"Remove from favorites":"Add to favorites"]}),(0,g.jsx)(cH,{}),(0,g.jsxs)(cG,{className:"text-destructive focus:text-destructive",onSelect:()=>{b.setDeletingPath(a.path),b.setDeletingIsDir("file"!==a.type)},children:[(0,g.jsx)(bf,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})}function cT({name:a,type:b}){let c="h-3.5 w-3.5 shrink-0";return"dir"===b?(0,g.jsx)(a4,{className:(0,ao.cn)(c,"text-foreground/70")}):"app"===b?(0,g.jsx)(k,{className:(0,ao.cn)(c,"text-foreground/70")}):"node-app"===b?(0,g.jsx)(ce,{className:(0,ao.cn)(c,"text-emerald-500")}):cQ(a)?(0,g.jsx)(k,{className:(0,ao.cn)(c,"text-foreground/60")}):cP(a)?(0,g.jsx)(l,{className:(0,ao.cn)(c,"text-sunshine-700")}):cN(a)?(0,g.jsx)(j.FileText,{className:(0,ao.cn)(c,"text-foreground/70")}):(0,g.jsx)(cb,{className:(0,ao.cn)(c,"text-foreground/60")})}let cU=(0,p.memo)(function({node:a,depth:b,ctx:c,isMobile:d,activeWorkspaceId:e,sidebarScrollRef:f,isActive:h,isDragOver:i,isFavorited:n,isAgentActive:o,isPulling:p,branchOpen:q,branchPos:r,branches:s,branchLoading:t,checkingOut:u,onHoverEnter:w,onHoverLeave:x}){var y;let z,A,B,C,D,E=cI(a=>a.humanize);return(0,g.jsxs)(cp,{children:[(0,g.jsx)(cr,{asChild:!0,children:(0,g.jsxs)("div",{role:"treeitem",tabIndex:0,draggable:!d,onKeyDown:d=>{if("Enter"===d.key||" "===d.key)d.preventDefault(),"dir"===a.type?c.toggleFolder(a):"app"===a.type||"node-app"===a.type?(c.openViewer(a),c.toggleFolder(a)):c.openViewer(a);else if("ArrowDown"===d.key){d.preventDefault();let a=f.current;if(!a)return;let b=Array.from(a.querySelectorAll('[role="treeitem"]')),c=b.indexOf(d.currentTarget);b[c+1]?.focus()}else if("ArrowUp"===d.key){d.preventDefault();let a=f.current;if(!a)return;let b=Array.from(a.querySelectorAll('[role="treeitem"]')),c=b.indexOf(d.currentTarget);b[c-1]?.focus()}else if("ArrowRight"===d.key){if(d.preventDefault(),"dir"===a.type||"app"===a.type||"node-app"===a.type)if(a.expanded){let a=f.current;if(!a)return;let b=Array.from(a.querySelectorAll('[role="treeitem"]')),c=b.indexOf(d.currentTarget);b[c+1]?.focus()}else c.toggleFolder(a)}else if("ArrowLeft"===d.key){if(d.preventDefault(),("dir"===a.type||"app"===a.type||"node-app"===a.type)&&a.expanded)c.toggleFolder(a);else if(b>0){let a=f.current;if(!a)return;let b=Array.from(a.querySelectorAll('[role="treeitem"]')),c=d.currentTarget,e=b.indexOf(c),g=Number.parseInt(c.style.paddingLeft??"0",10);for(let a=e-1;a>=0;a--)if(Number.parseInt(b[a].style.paddingLeft??"0",10)<g){b[a].focus();break}}}},onDragStart:b=>c.handleDragStart(b,a),onDragOver:b=>"dir"===a.type?c.handleDragOver(b,a.path,"dir"):b.preventDefault(),onDragLeave:()=>c.setDragOverPath(null),onDrop:b=>"dir"===a.type?c.handleDropOnFolder(b,a.path):b.preventDefault(),onMouseEnter:()=>w(a),onMouseLeave:x,className:(0,ao.cn)("tree-row-reveal flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer group transition-colors select-none touch-target",h?"bg-accent-soft text-foreground font-medium":"hover:bg-muted",i&&"ring-2 ring-primary bg-primary-soft",a.name.startsWith(".")&&"opacity-40"),style:{paddingLeft:`${14*b+8}px`,...cR},onClick:()=>{"dir"===a.type?c.toggleFolder(a):("app"===a.type||"node-app"===a.type?(c.openViewer(a),c.toggleFolder(a)):c.openViewer(a),d&&c.setSidebarCollapsed(!0))},children:["dir"===a.type||"app"===a.type||"node-app"===a.type?a.loading?(0,g.jsx)(m.Loader2,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}):(0,g.jsx)(a3.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform duration-200 ease-out",style:{transform:a.expanded?"rotate(90deg)":"rotate(0deg)"}}):(0,g.jsx)("span",{className:"w-3.5 shrink-0"}),(0,g.jsx)("span",{className:"",children:"dir"===a.type?a.expanded?(0,g.jsx)(a5,{className:(0,ao.cn)("h-4 w-4 shrink-0",!h&&"text-foreground/70")}):(0,g.jsx)(a4,{className:(0,ao.cn)("h-4 w-4 shrink-0",!h&&"text-foreground/70")}):"app"===a.type?(0,g.jsx)(k,{className:(0,ao.cn)("h-4 w-4 shrink-0",!h&&"text-foreground/70")}):"node-app"===a.type?(0,g.jsx)(ce,{className:(0,ao.cn)("h-4 w-4 shrink-0",!h&&"text-emerald-500")}):cQ(a.name)?(0,g.jsx)(k,{className:(0,ao.cn)("h-4 w-4 shrink-0",!h&&"text-foreground/60")}):cP(a.name)?(0,g.jsx)(l,{className:(0,ao.cn)("h-4 w-4 shrink-0",!h&&"text-sunshine-700")}):cN(a.name)?(0,g.jsx)(j.FileText,{className:(0,ao.cn)("h-4 w-4 shrink-0",!h&&"text-foreground/70")}):(0,g.jsx)(cb,{className:(0,ao.cn)("h-4 w-4 shrink-0",!h&&"text-foreground/60")})}),(0,g.jsx)("span",{className:"min-w-0 flex-1 truncate",title:E?a.name:void 0,children:E?(B=(A=(z=(y=a.name).lastIndexOf("."))>0&&z<y.length-1)?y.slice(0,z):y,C=A?y.slice(z):"",(D=B.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[\s_-]+/).filter(Boolean).map(a=>/^[A-Z0-9]+$/.test(a)?a:a[0].toUpperCase()+a.slice(1))).length?D.join(" ")+C:y):a.name}),a.git&&(0,g.jsxs)("span",{className:"relative flex shrink-0 items-center gap-0.5 rounded-sm bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:[(0,g.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"flex items-center gap-0.5 hover:text-foreground",title:"Switch branch",onClick:b=>{if(b.stopPropagation(),q){c.setBranchDropdownNode(null),c.setBranchDropdownPos(null);return}let d=b.currentTarget.getBoundingClientRect();c.setBranchDropdownPos({top:d.bottom+4,left:d.left}),c.setBranchDropdownNode(a.path),c.loadBranches(a.path)},children:[(0,g.jsx)(a6,{className:"h-2.5 w-2.5"}),a.git.branch,a.git.dirty&&(0,g.jsx)("span",{className:"ml-0.5 text-foreground/70",children:"*"})]}),p?(0,g.jsx)(m.Loader2,{className:"ml-0.5 h-2.5 w-2.5 animate-spin"}):(0,g.jsx)("button",{type:"button",onClick:b=>{b.stopPropagation();let d=a.path.includes("/")?a.path.substring(0,a.path.lastIndexOf("/")):"";c.handleGitPull(a.path,d)},className:"ml-0.5 text-muted-foreground hover:text-foreground",title:"Pull latest",children:(0,g.jsx)(bI,{className:"h-2.5 w-2.5"})}),q&&r&&(0,g.jsx)(cg,{pos:r,branches:s,loading:t,busyName:u,disabled:null!==u,onPick:b=>{let d=a.path.includes("/")?a.path.substring(0,a.path.lastIndexOf("/")):"";c.handleCheckout(a.path,b,d)},onClose:()=>{c.setBranchDropdownNode(null),c.setBranchDropdownPos(null)}})]}),o&&(0,g.jsx)("span",{className:"ml-0.5 h-1.5 w-1.5 rounded-full bg-emerald-400 shrink-0 animate-pulse",title:"Agent recently active"}),(0,g.jsx)("div",{className:"hover-reveal flex max-w-0 shrink-0 items-center overflow-hidden opacity-0 transition-all duration-150 group-hover:max-w-7 group-hover:opacity-100 focus-within:max-w-7 focus-within:opacity-100",onClick:a=>a.stopPropagation(),onKeyDown:a=>a.stopPropagation(),children:(0,g.jsxs)(ax.DropdownMenu,{children:[(0,g.jsx)(ax.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",title:"File actions",children:(0,g.jsx)(ca,{className:"h-3.5 w-3.5"})})}),(0,g.jsxs)(ax.DropdownMenuContent,{align:"end",className:"w-48",children:[(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>c.copyPath(a.path),children:[(0,g.jsx)(bd.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),cO(a.name)&&(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>c.copyWikiLink(a.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>c.copyUrl(a.path),children:[(0,g.jsx)(b9,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===a.type&&cN(a.name)&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>c.copyRawContent(a.path),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>c.copyFormattedContent(a.path,a.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,g.jsx)(ax.DropdownMenuSeparator,{}),"dir"===a.type&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ax.DropdownMenuItem,{onClick:async()=>{a.expanded||c.toggleFolder(a),c.setNewFileParent(a.path),c.setNewFileName(""),c.setFileCreateError(null)},children:[(0,g.jsx)(cc,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>c.triggerUpload(a.path),children:[(0,g.jsx)(cf,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>{c.setNewFolderParent(a.path),c.setNewFolderName(""),c.setFolderError(null)},children:[(0,g.jsx)(cd,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,g.jsx)(ax.DropdownMenuSeparator,{})]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>c.handleDownload(a),children:[(0,g.jsx)(b8.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===a.type?"Download":"Download as zip"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>c.toggleFavorite(a,e),children:[(0,g.jsx)(ba,{className:(0,ao.cn)("mr-2 h-3.5 w-3.5",n&&"fill-current text-amber-400")}),n?"Remove from favorites":"Add to favorites"]}),(0,g.jsx)(ax.DropdownMenuSeparator,{}),(0,g.jsxs)(ax.DropdownMenuItem,{className:"text-destructive focus:text-destructive",onClick:()=>{c.setDeletingPath(a.path),c.setDeletingIsDir("file"!==a.type)},children:[(0,g.jsx)(bf,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})]})})]})}),(0,g.jsx)(cS,{node:a,ctx:c,isFavorited:n,activeWorkspaceId:e})]})}),cV=(0,p.memo)(function(a){let{ctx:b,openPath:c,dragOverPath:d,branchDropdownNode:e,branchDropdownPos:f,nodeBranches:h,branchesLoading:i,checkingOutBranch:k,pullingRepo:l,activePaths:m,favorites:n,isMobile:q,activeWorkspaceId:s,newFileParent:t,newFileName:u,fileCreateError:w,newFolderParent:x,newFolderName:y,folderError:z,sidebarScrollRef:A}=a,B=cJ(a=>a.showHidden),C=(0,p.useRef)(null),D=(0,p.useCallback)(a=>{let c=("dir"===a.type||"app"===a.type||"node-app"===a.type)&&!a.expanded&&void 0===a.children;("file"===a.type||c)&&(C.current&&clearTimeout(C.current),C.current=setTimeout(()=>b.prefetch(a),120))},[b]),E=(0,p.useCallback)(()=>{C.current&&(clearTimeout(C.current),C.current=null)},[]),F=(0,p.useMemo)(()=>{let b=[],c=(a,d)=>{for(let e of a)!(!B&&e.name.startsWith("."))&&(b.push({kind:"row",node:e,depth:d}),"dir"===e.type&&(x===e.path&&b.push({kind:"newfolder",node:e,depth:d}),t===e.path&&b.push({kind:"newfile",node:e,depth:d})),("dir"===e.type||"app"===e.type||"node-app"===e.type)&&e.expanded&&(e.children&&e.children.length>0?c(e.children,d+1):e.children?.length===0&&b.push({kind:"empty",node:e,depth:d})))};return c(a.nodes,0),b},[a.nodes,t,x,B]);return(0,g.jsx)(g.Fragment,{children:F.map(a=>{let{node:p,depth:t}=a;if("row"===a.kind){let a=e===p.path;return(0,g.jsx)(cU,{node:p,depth:t,ctx:b,isMobile:q,activeWorkspaceId:s,sidebarScrollRef:A,isActive:c===p.path,isDragOver:d===p.path,isFavorited:n.some(a=>a.path===p.path),isAgentActive:m.has(p.path),isPulling:l===p.path,branchOpen:a,branchPos:a?f:null,branches:p.git?h[p.path]??[]:[],branchLoading:!!p.git&&!!i[p.path],checkingOut:a?k:null,onHoverEnter:D,onHoverLeave:E},p.path)}return"newfolder"===a.kind?(0,g.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(t+1)*14+8}px`,...cR},children:[(0,g.jsx)("span",{className:"w-3.5 shrink-0"}),(0,g.jsx)(a4,{className:"h-4 w-4 shrink-0 text-foreground/70"}),(0,g.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:y,onChange:a=>b.setNewFolderName(a.target.value),onKeyDown:a=>{"Enter"===a.key&&b.handleCreateFolder(),"Escape"===a.key&&(b.setNewFolderParent(null),b.setNewFolderName(""))}}),z&&(0,g.jsx)("span",{className:"text-xs text-destructive",children:z}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:b.handleCreateFolder,children:(0,g.jsx)(r.Check,{className:"h-3 w-3"})}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{b.setNewFolderParent(null),b.setNewFolderName("")},children:(0,g.jsx)(o,{className:"h-3 w-3"})})]},`nf-${p.path}`):"newfile"===a.kind?(0,g.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(t+1)*14+8}px`,...cR},children:[(0,g.jsx)("span",{className:"w-3.5 shrink-0"}),(0,g.jsx)(j.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,g.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:u,onChange:a=>b.setNewFileName(a.target.value),onKeyDown:a=>{"Enter"===a.key&&b.handleCreateFile(),"Escape"===a.key&&(b.setNewFileParent(null),b.setNewFileName(""))}}),w&&(0,g.jsx)("span",{className:"text-xs text-destructive",children:w}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:b.handleCreateFile,children:(0,g.jsx)(r.Check,{className:"h-3 w-3"})}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{b.setNewFileParent(null),b.setNewFileName("")},children:(0,g.jsx)(o,{className:"h-3 w-3"})})]},`ff-${p.path}`):(0,g.jsx)("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:`${(t+1)*14+8+14+6+16+6}px`,...cR},children:"Empty"},`empty-${p.path}`)})})}),cW=(0,ay.create)((a,b)=>({favorites:[],loadForWorkspace:b=>{a({favorites:[]})},toggle:(b,c)=>{let d=[];a({favorites:d.some(a=>a.path===b.path)?d.filter(a=>a.path!==b.path):[...d,b]})},isFavorited:a=>b().favorites.some(b=>b.path===a)}));function cX({doc:a,node:b,extraItems:c,activeWorkspaceId:d=null}){let e=cW(a=>a.isFavorited(b.path));return(0,g.jsxs)(ax.DropdownMenu,{children:[(0,g.jsx)(ax.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"File actions",children:(0,g.jsx)(ca,{className:"h-3.5 w-3.5"})})}),(0,g.jsxs)(ax.DropdownMenuContent,{align:"end",className:"w-52",children:[(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>{let a=(0,bB.withWs)(`/api/wiki/download?path=${encodeURIComponent(b.path)}`),c=document.createElement("a");c.href=a,c.download=b.name,document.body.appendChild(c),c.click(),c.remove()},children:[(0,g.jsx)(b8.Download,{className:"mr-2 h-3.5 w-3.5"}),"Download"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>{cW.getState().toggle({path:b.path,name:b.name},d)},children:[(0,g.jsx)(ba,{className:(0,ao.cn)("mr-2 h-3.5 w-3.5",e&&"fill-current text-amber-400")}),e?"Remove from favorites":"Add to favorites"]}),(0,g.jsx)(ax.DropdownMenuSeparator,{}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>a.copyPath(b.path),children:[(0,g.jsx)(bd.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),cO(b.name)&&(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>a.copyWikiLink(b.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,g.jsx)(ax.DropdownMenuSeparator,{}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>a.copyUrl(b.path),children:[(0,g.jsx)(b9,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),cN(b.name)&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ax.DropdownMenuSeparator,{}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>void a.copyRawContent(b.path),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>void a.copyFormattedContent(b.path,b.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),c&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ax.DropdownMenuSeparator,{}),c]})]})]})}let cY=(0,h.default)("align-center",[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);var cZ=a.i(796873);let c$=(0,h.default)("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);var c_=a.i(453590),c0=a.i(111939),c1=/[\\\/_+.#"@\[\(\{&]/,c2=/[\\\/_+.#"@\[\(\{&]/g,c3=/[\s-]/,c4=/[\s-]/g;function c5(a){return a.toLowerCase().replace(c4," ")}var c6='[cmdk-group=""]',c7='[cmdk-group-items=""]',c8='[cmdk-item=""]',c9=`${c8}:not([aria-disabled="true"])`,da="cmdk-item-select",db="data-value",dc=(a,b,c)=>{var d;return d=a,function a(b,c,d,e,f,g,h){if(g===c.length)return f===b.length?1:.99;var i=`${f},${g}`;if(void 0!==h[i])return h[i];for(var j,k,l,m,n=e.charAt(g),o=d.indexOf(n,f),p=0;o>=0;)(j=a(b,c,d,e,o+1,g+1,h))>p&&(o===f?j*=1:c1.test(b.charAt(o-1))?(j*=.8,(l=b.slice(f,o-1).match(c2))&&f>0&&(j*=Math.pow(.999,l.length))):c3.test(b.charAt(o-1))?(j*=.9,(m=b.slice(f,o-1).match(c4))&&f>0&&(j*=Math.pow(.999,m.length))):(j*=.17,f>0&&(j*=Math.pow(.999,o-f))),b.charAt(o)!==c.charAt(g)&&(j*=.9999)),(j<.1&&d.charAt(o-1)===e.charAt(g+1)||e.charAt(g+1)===e.charAt(g)&&d.charAt(o-1)!==e.charAt(g))&&.1*(k=a(b,c,d,e,o+1,g+2,h))>j&&(j=.1*k),j>p&&(p=j),o=d.indexOf(n,o+1);return h[i]=p,p}(d=c&&c.length>0?`${d+" "+c.join(" ")}`:d,b,c5(d),c5(b),0,0,{})},dd=p.createContext(void 0),de=p.createContext(void 0),df=p.createContext(void 0),dg=p.forwardRef((a,b)=>{let c=dr(()=>{var b,c;return{search:"",value:null!=(c=null!=(b=a.value)?b:a.defaultValue)?c:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),d=dr(()=>new Set),e=dr(()=>new Map),f=dr(()=>new Map),g=dr(()=>new Set),h=dp(a),{label:i,children:j,value:k,onValueChange:l,filter:m,shouldFilter:n,loop:o,disablePointerSelection:q=!1,vimBindings:r=!0,...s}=a,t=(0,z.useId)(),u=(0,z.useId)(),v=(0,z.useId)(),w=p.useRef(null),x=du();dq(()=>{if(void 0!==k){let a=k.trim();c.current.value=a,y.emit()}},[k]),dq(()=>{x(6,F)},[]);let y=p.useMemo(()=>({subscribe:a=>(g.current.add(a),()=>g.current.delete(a)),snapshot:()=>c.current,setState:(a,b,d)=>{var e,f,g,i;if(!Object.is(c.current[a],b)){if(c.current[a]=b,"search"===a)E(),C(),x(1,D);else if("value"===a){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let a=document.getElementById(v);a?a.focus():null==(e=document.getElementById(t))||e.focus()}if(x(7,()=>{var a;c.current.selectedItemId=null==(a=G())?void 0:a.id,y.emit()}),d||x(5,F),(null==(f=h.current)?void 0:f.value)!==void 0){null==(i=(g=h.current).onValueChange)||i.call(g,null!=b?b:"");return}}y.emit()}},emit:()=>{g.current.forEach(a=>a())}}),[]),A=p.useMemo(()=>({value:(a,b,d)=>{var e;b!==(null==(e=f.current.get(a))?void 0:e.value)&&(f.current.set(a,{value:b,keywords:d}),c.current.filtered.items.set(a,B(b,d)),x(2,()=>{C(),y.emit()}))},item:(a,b)=>(d.current.add(a),b&&(e.current.has(b)?e.current.get(b).add(a):e.current.set(b,new Set([a]))),x(3,()=>{E(),C(),c.current.value||D(),y.emit()}),()=>{f.current.delete(a),d.current.delete(a),c.current.filtered.items.delete(a);let b=G();x(4,()=>{E(),(null==b?void 0:b.getAttribute("id"))===a&&D(),y.emit()})}),group:a=>(e.current.has(a)||e.current.set(a,new Set),()=>{f.current.delete(a),e.current.delete(a)}),filter:()=>h.current.shouldFilter,label:i||a["aria-label"],getDisablePointerSelection:()=>h.current.disablePointerSelection,listId:t,inputId:v,labelId:u,listInnerRef:w}),[]);function B(a,b){var d,e;let f=null!=(e=null==(d=h.current)?void 0:d.filter)?e:dc;return a?f(a,c.current.search,b):0}function C(){if(!c.current.search||!1===h.current.shouldFilter)return;let a=c.current.filtered.items,b=[];c.current.filtered.groups.forEach(c=>{let d=e.current.get(c),f=0;d.forEach(b=>{f=Math.max(a.get(b),f)}),b.push([c,f])});let d=w.current;H().sort((b,c)=>{var d,e;let f=b.getAttribute("id"),g=c.getAttribute("id");return(null!=(d=a.get(g))?d:0)-(null!=(e=a.get(f))?e:0)}).forEach(a=>{let b=a.closest(c7);b?b.appendChild(a.parentElement===b?a:a.closest(`${c7} > *`)):d.appendChild(a.parentElement===d?a:a.closest(`${c7} > *`))}),b.sort((a,b)=>b[1]-a[1]).forEach(a=>{var b;let c=null==(b=w.current)?void 0:b.querySelector(`${c6}[${db}="${encodeURIComponent(a[0])}"]`);null==c||c.parentElement.appendChild(c)})}function D(){let a=H().find(a=>"true"!==a.getAttribute("aria-disabled")),b=null==a?void 0:a.getAttribute(db);y.setState("value",b||void 0)}function E(){var a,b,g,i;if(!c.current.search||!1===h.current.shouldFilter){c.current.filtered.count=d.current.size;return}c.current.filtered.groups=new Set;let j=0;for(let e of d.current){let d=B(null!=(b=null==(a=f.current.get(e))?void 0:a.value)?b:"",null!=(i=null==(g=f.current.get(e))?void 0:g.keywords)?i:[]);c.current.filtered.items.set(e,d),d>0&&j++}for(let[a,b]of e.current)for(let d of b)if(c.current.filtered.items.get(d)>0){c.current.filtered.groups.add(a);break}c.current.filtered.count=j}function F(){var a,b,c;let d=G();d&&((null==(a=d.parentElement)?void 0:a.firstChild)===d&&(null==(c=null==(b=d.closest(c6))?void 0:b.querySelector('[cmdk-group-heading=""]'))||c.scrollIntoView({block:"nearest"})),d.scrollIntoView({block:"nearest"}))}function G(){var a;return null==(a=w.current)?void 0:a.querySelector(`${c8}[aria-selected="true"]`)}function H(){var a;return Array.from((null==(a=w.current)?void 0:a.querySelectorAll(c9))||[])}function I(a){let b=H()[a];b&&y.setState("value",b.getAttribute(db))}function J(a){var b;let c=G(),d=H(),e=d.findIndex(a=>a===c),f=d[e+a];null!=(b=h.current)&&b.loop&&(f=e+a<0?d[d.length-1]:e+a===d.length?d[0]:d[e+a]),f&&y.setState("value",f.getAttribute(db))}function K(a){let b=G(),c=null==b?void 0:b.closest(c6),d;for(;c&&!d;)d=null==(c=a>0?function(a,b){let c=a.nextElementSibling;for(;c;){if(c.matches(b))return c;c=c.nextElementSibling}}(c,c6):function(a,b){let c=a.previousElementSibling;for(;c;){if(c.matches(b))return c;c=c.previousElementSibling}}(c,c6))?void 0:c.querySelector(c9);d?y.setState("value",d.getAttribute(db)):J(a)}let L=()=>I(H().length-1),M=a=>{a.preventDefault(),a.metaKey?L():a.altKey?K(1):J(1)},N=a=>{a.preventDefault(),a.metaKey?I(0):a.altKey?K(-1):J(-1)};return p.createElement(bw.div,{ref:b,tabIndex:-1,...s,"cmdk-root":"",onKeyDown:a=>{var b;null==(b=s.onKeyDown)||b.call(s,a);let c=a.nativeEvent.isComposing||229===a.keyCode;if(!(a.defaultPrevented||c))switch(a.key){case"n":case"j":r&&a.ctrlKey&&M(a);break;case"ArrowDown":M(a);break;case"p":case"k":r&&a.ctrlKey&&N(a);break;case"ArrowUp":N(a);break;case"Home":a.preventDefault(),I(0);break;case"End":a.preventDefault(),L();break;case"Enter":{a.preventDefault();let b=G();if(b){let a=new Event(da);b.dispatchEvent(a)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:dw},i),dv(a,a=>p.createElement(de.Provider,{value:y},p.createElement(dd.Provider,{value:A},a))))}),dh=p.forwardRef((a,b)=>{var c,d;let e=(0,z.useId)(),f=p.useRef(null),g=p.useContext(df),h=p.useContext(dd),i=dp(a),j=null!=(d=null==(c=i.current)?void 0:c.forceMount)?d:null==g?void 0:g.forceMount;dq(()=>{if(!j)return h.item(e,null==g?void 0:g.id)},[j]);let k=dt(e,f,[a.value,a.children,f],a.keywords),l=p.useContext(de),m=ds(a=>a.value&&a.value===k.current),n=ds(a=>!!j||!1===h.filter()||!a.search||a.filtered.items.get(e)>0);function o(){var a,b;q(),null==(b=(a=i.current).onSelect)||b.call(a,k.current)}function q(){l.setState("value",k.current,!0)}if(p.useEffect(()=>{let b=f.current;if(!(!b||a.disabled))return b.addEventListener(da,o),()=>b.removeEventListener(da,o)},[n,a.onSelect,a.disabled]),!n)return null;let{disabled:r,value:s,onSelect:t,forceMount:u,keywords:v,...w}=a;return p.createElement(bw.div,{ref:(0,x.composeRefs)(f,b),...w,id:e,"cmdk-item":"",role:"option","aria-disabled":!!r,"aria-selected":!!m,"data-disabled":!!r,"data-selected":!!m,onPointerMove:r||h.getDisablePointerSelection()?void 0:q,onClick:r?void 0:o},a.children)}),di=p.forwardRef((a,b)=>{let{heading:c,children:d,forceMount:e,...f}=a,g=(0,z.useId)(),h=p.useRef(null),i=p.useRef(null),j=(0,z.useId)(),k=p.useContext(dd),l=ds(a=>!!e||!1===k.filter()||!a.search||a.filtered.groups.has(g));dq(()=>k.group(g),[]),dt(g,h,[a.value,a.heading,i]);let m=p.useMemo(()=>({id:g,forceMount:e}),[e]);return p.createElement(bw.div,{ref:(0,x.composeRefs)(h,b),...f,"cmdk-group":"",role:"presentation",hidden:!l||void 0},c&&p.createElement("div",{ref:i,"cmdk-group-heading":"","aria-hidden":!0,id:j},c),dv(a,a=>p.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":c?j:void 0},p.createElement(df.Provider,{value:m},a))))}),dj=p.forwardRef((a,b)=>{let{alwaysRender:c,...d}=a,e=p.useRef(null),f=ds(a=>!a.search);return c||f?p.createElement(bw.div,{ref:(0,x.composeRefs)(e,b),...d,"cmdk-separator":"",role:"separator"}):null}),dk=p.forwardRef((a,b)=>{let{onValueChange:c,...d}=a,e=null!=a.value,f=p.useContext(de),g=ds(a=>a.search),h=ds(a=>a.selectedItemId),i=p.useContext(dd);return p.useEffect(()=>{null!=a.value&&f.setState("search",a.value)},[a.value]),p.createElement(bw.input,{ref:b,...d,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":i.listId,"aria-labelledby":i.labelId,"aria-activedescendant":h,id:i.inputId,type:"text",value:e?a.value:g,onChange:a=>{e||f.setState("search",a.target.value),null==c||c(a.target.value)}})}),dl=p.forwardRef((a,b)=>{let{children:c,label:d="Suggestions",...e}=a,f=p.useRef(null),g=p.useRef(null),h=ds(a=>a.selectedItemId),i=p.useContext(dd);return p.useEffect(()=>{if(g.current&&f.current){let a=g.current,b=f.current,c,d=new ResizeObserver(()=>{c=requestAnimationFrame(()=>{let c=a.offsetHeight;b.style.setProperty("--cmdk-list-height",c.toFixed(1)+"px")})});return d.observe(a),()=>{cancelAnimationFrame(c),d.unobserve(a)}}},[]),p.createElement(bw.div,{ref:(0,x.composeRefs)(f,b),...e,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":h,"aria-label":d,id:i.listId},dv(a,a=>p.createElement("div",{ref:(0,x.composeRefs)(g,i.listInnerRef),"cmdk-list-sizer":""},a)))}),dm=p.forwardRef((a,b)=>{let{open:c,onOpenChange:d,overlayClassName:e,contentClassName:f,container:g,...h}=a;return p.createElement(P,{open:c,onOpenChange:d},p.createElement(U,{container:g},p.createElement(W,{"cmdk-overlay":"",className:e}),p.createElement($,{"aria-label":a.label,"cmdk-dialog":"",className:f},p.createElement(dg,{ref:b,...h}))))}),dn=Object.assign(dg,{List:dl,Item:dh,Input:dk,Group:di,Separator:dj,Dialog:dm,Empty:p.forwardRef((a,b)=>ds(a=>0===a.filtered.count)?p.createElement(bw.div,{ref:b,...a,"cmdk-empty":"",role:"presentation"}):null),Loading:p.forwardRef((a,b)=>{let{progress:c,children:d,label:e="Loading...",...f}=a;return p.createElement(bw.div,{ref:b,...f,"cmdk-loading":"",role:"progressbar","aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,"aria-label":e},dv(a,a=>p.createElement("div",{"aria-hidden":!0},a)))})});function dp(a){let b=p.useRef(a);return dq(()=>{b.current=a}),b}var dq=p.useEffect;function dr(a){let b=p.useRef();return void 0===b.current&&(b.current=a()),b}function ds(a){let b=p.useContext(de),c=()=>a(b.snapshot());return p.useSyncExternalStore(b.subscribe,c,c)}function dt(a,b,c,d=[]){let e=p.useRef(),f=p.useContext(dd);return dq(()=>{var g;let h=(()=>{var a;for(let b of c){if("string"==typeof b)return b.trim();if("object"==typeof b&&"current"in b)return b.current?null==(a=b.current.textContent)?void 0:a.trim():e.current}})(),i=d.map(a=>a.trim());f.value(a,h,i),null==(g=b.current)||g.setAttribute(db,h),e.current=h}),e}var du=()=>{let[a,b]=p.useState(),c=dr(()=>new Map);return dq(()=>{c.current.forEach(a=>a()),c.current=new Map},[a]),(a,d)=>{c.current.set(a,d),b({})}};function dv({asChild:a,children:b},c){let d;return a&&p.isValidElement(b)?p.cloneElement("function"==typeof(d=b.type)?d(b.props):"render"in d?d.render(b.props):b,{ref:b.ref},c(b.props.children)):c(b)}var dw={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};let dx=(0,h.default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),dy=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(dn,{ref:c,className:(0,ao.cn)("flex h-full w-full flex-col overflow-hidden rounded-sm bg-popover text-popover-foreground",a),...b}));function dz({children:a,shouldFilter:b,...c}){return(0,g.jsx)(P,{...c,children:(0,g.jsxs)(aZ,{className:"overflow-hidden p-0 shadow-golden max-w-lg",children:[(0,g.jsx)(a0,{className:"sr-only",children:"Search"}),(0,g.jsx)(dy,{shouldFilter:b,className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:a})]})})}dy.displayName=dn.displayName;let dA=p.forwardRef(({className:a,...b},c)=>(0,g.jsxs)("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[(0,g.jsx)(dx,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),(0,g.jsx)(dn.Input,{ref:c,className:(0,ao.cn)("flex h-11 w-full rounded-sm bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",a),...b})]}));dA.displayName=dn.Input.displayName;let dB=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(dn.List,{ref:c,className:(0,ao.cn)("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...b}));dB.displayName=dn.List.displayName;let dC=p.forwardRef((a,b)=>(0,g.jsx)(dn.Empty,{ref:b,className:"py-6 text-center text-sm text-muted-foreground",...a}));dC.displayName=dn.Empty.displayName;let dD=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(dn.Group,{ref:c,className:(0,ao.cn)("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground",a),...b}));dD.displayName=dn.Group.displayName;let dE=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(dn.Separator,{ref:c,className:(0,ao.cn)("-mx-1 h-px bg-border",a),...b}));dE.displayName=dn.Separator.displayName;let dF=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(dn.Item,{ref:c,className:(0,ao.cn)("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",a),...b}));dF.displayName=dn.Item.displayName;let dG=null,dH=null,dI=(0,ay.create)(a=>({query:"",results:[],loading:!1,truncated:!1,open:!1,setQuery:b=>a({query:b}),setOpen:b=>a({open:b}),clear:()=>{dH&&clearTimeout(dH),dG?.abort(),a({query:"",results:[],loading:!1,truncated:!1})},search:b=>(dH&&clearTimeout(dH),b.trim())?(a({loading:!0}),new Promise(c=>{dH=setTimeout(()=>{dJ(a,b).finally(c)},150)})):(dG?.abort(),a({results:[],loading:!1,truncated:!1}),Promise.resolve())}));async function dJ(a,b){dG?.abort();let c=new AbortController;dG=c;try{let d=await (0,bB.wsFetch)("/api/wiki/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:b,limit:30}),signal:c.signal});if(!d.ok)return void a({results:[],loading:!1,truncated:!1});let e=await d.json();if(c.signal.aborted)return;a({results:e.matches??[],truncated:!!e.truncated,loading:!1})}catch(b){"AbortError"!==b.name&&a({loading:!1})}}var dK=a.i(713033);function dL({html:a}){let b=function(a){let b,c=[],d=/<mark>([\s\S]*?)<\/mark>/g,e=0;for(;null!==(b=d.exec(a));)b.index>e&&c.push({text:a.slice(e,b.index),mark:!1}),c.push({text:b[1]??"",mark:!0}),e=b.index+b[0].length;return e<a.length&&c.push({text:a.slice(e),mark:!1}),c}(a);return(0,g.jsx)(g.Fragment,{children:b.map((a,b)=>a.mark?(0,g.jsx)("mark",{className:"bg-yellow-200 dark:bg-yellow-700 rounded-[2px] px-[1px]",children:a.text},b):(0,g.jsx)("span",{children:a.text},b))})}function dM({onOpenFile:a,recents:b=[],onToggleSidebar:c=()=>void 0,onNewFile:d=()=>void 0,onCopyPath:e=()=>void 0}){let f=dI(a=>a.open),h=dI(a=>a.setOpen),j=dI(a=>a.query),k=dI(a=>a.setQuery),l=dI(a=>a.results),m=dI(a=>a.loading),n=dI(a=>a.truncated),o=dI(a=>a.search),{resolvedTheme:q,setTheme:r}=(0,c0.useTheme)(),s=bF(a=>a.toggle),t=(0,dK.useViewWidthStore)(a=>a.width),u=(0,dK.useViewWidthStore)(a=>a.cycle),v=j.trimStart(),w=""===v||v.startsWith(">"),x=""===v&&b.length>0,y=w?"":j;function z(a){a(),h(!1),k("")}(0,p.useEffect)(()=>{function a(a){(a.metaKey||a.ctrlKey)&&"k"===a.key.toLowerCase()&&(a.preventDefault(),h(!f))}return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[f,h]),(0,p.useEffect)(()=>{if(!f||w)return;let a=setTimeout(()=>{o(y)},120);return()=>clearTimeout(a)},[y,w,f,o]);let A=(dK.VIEW_WIDTH_ORDER.indexOf(t)+1)%dK.VIEW_WIDTH_ORDER.length,B=dK.VIEW_WIDTH_LABEL[dK.VIEW_WIDTH_ORDER[A]];return(0,g.jsxs)(dz,{open:f,onOpenChange:a=>{h(a),a||k("")},shouldFilter:!1,children:[(0,g.jsx)(dA,{placeholder:"Search files… ( > for actions )",value:j,onValueChange:k}),(0,g.jsxs)(dB,{children:[x&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(dD,{heading:"Recent",children:b.map(b=>(0,g.jsxs)(dF,{value:`recent:${b.path}`,onSelect:()=>{a(b.path),h(!1),k("")},children:[(0,g.jsx)(bg,{className:"mr-2 h-4 w-4"}),(0,g.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,g.jsx)("span",{className:"truncate font-medium",children:b.name}),(0,g.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:b.path})]})]},b.path))}),(0,g.jsx)(dE,{})]}),w&&(0,g.jsxs)(dD,{heading:"Actions",children:[(0,g.jsxs)(dF,{value:"toggle-dark-mode",onSelect:()=>z(()=>r("dark"===q?"light":"dark")),children:["dark"===q?(0,g.jsx)(c_.Sun,{className:"mr-2 h-4 w-4"}):(0,g.jsx)(cZ.Moon,{className:"mr-2 h-4 w-4"}),"dark"===q?"Switch to light mode":"Switch to dark mode"]}),(0,g.jsxs)(dF,{value:"toggle-ai-panel",onSelect:()=>z(s),children:[(0,g.jsx)(i,{className:"mr-2 h-4 w-4"}),"Toggle AI panel"]}),(0,g.jsxs)(dF,{value:"toggle-sidebar",onSelect:()=>z(c),children:[(0,g.jsx)(c$,{className:"mr-2 h-4 w-4"}),"Toggle sidebar"]}),(0,g.jsxs)(dF,{value:"new-file",onSelect:()=>z(d),children:[(0,g.jsx)(cc,{className:"mr-2 h-4 w-4"}),"New file"]}),(0,g.jsxs)(dF,{value:"copy-path",onSelect:()=>z(e),children:[(0,g.jsx)(bd.Copy,{className:"mr-2 h-4 w-4"}),"Copy current file path"]}),(0,g.jsxs)(dF,{value:"cycle-view-width",onSelect:()=>z(u),children:[(0,g.jsx)(cY,{className:"mr-2 h-4 w-4"}),(0,g.jsxs)("span",{children:["Change view width"," ",(0,g.jsxs)("span",{className:"text-muted-foreground",children:["(",dK.VIEW_WIDTH_LABEL[t]," → ",B,")"]})]})]})]}),!w&&(0,g.jsxs)(g.Fragment,{children:[m&&(0,g.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Searching…"}),!m&&""!==y.trim()&&0===l.length&&(0,g.jsx)(dC,{children:"No matches."}),l.length>0&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(dE,{}),(0,g.jsx)(dD,{heading:n?"Top results (refine query for more)":"Results",children:l.map(b=>(0,g.jsx)(dF,{value:b.path,onSelect:()=>{a(b.path),h(!1),k("")},children:(0,g.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,g.jsx)("span",{className:"truncate text-xs",children:b.path}),b.snippet&&(0,g.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:(0,g.jsx)(dL,{html:b.snippet})})]})},b.path))})]})]})]})]})}let dN=(0,h.default)("cloud-download",[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]]);var dO=a.i(410672);let dP=(0,h.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),dQ=(0,h.default)("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),dR=(0,h.default)("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]),dS=(0,h.default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),dT=(0,h.default)("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),dU=(0,h.default)("type",[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]]);function dV({onOpenFile:a}){let b=dI(a=>a.query),c=dI(a=>a.setQuery),d=dI(a=>a.results),e=dI(a=>a.loading),f=dI(a=>a.search),h=dI(a=>a.clear),[i,j]=(0,p.useState)(0),k=(0,p.useRef)(null);function l(b){let c=d[b];c&&(a(c.path),h())}return(0,p.useEffect)(()=>{j(0)},[d]),(0,p.useEffect)(()=>{let a=k.current?.querySelector(`[data-idx="${i}"]`);a?.scrollIntoView({block:"nearest"})},[i]),(0,g.jsxs)("div",{className:"flex flex-col gap-1 px-2 py-1.5",children:[(0,g.jsxs)("div",{className:"relative",children:[(0,g.jsx)(dx,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 opacity-50"}),(0,g.jsx)("input",{type:"text",className:"w-full rounded-sm bg-muted py-1 pl-7 pr-2 text-xs outline-none focus:ring-1 focus:ring-ring",placeholder:"Search… (⌘K)",value:b,onChange:a=>{c(a.target.value),f(a.target.value)},onKeyDown:a=>{"Escape"===a.key?h():0!==d.length&&("ArrowDown"===a.key?(a.preventDefault(),j(a=>(a+1)%d.length)):"ArrowUp"===a.key?(a.preventDefault(),j(a=>(a-1+d.length)%d.length)):"Enter"===a.key&&(a.preventDefault(),l(i)))}})]}),""!==b.trim()&&(0,g.jsxs)("div",{ref:k,className:"max-h-64 overflow-y-auto rounded-sm border bg-popover",children:[e&&(0,g.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"Searching…"}),!e&&0===d.length&&(0,g.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"No matches"}),d.map((a,b)=>(0,g.jsxs)("button",{type:"button","data-idx":b,onClick:()=>l(b),onMouseEnter:()=>j(b),className:`block w-full px-2 py-1 text-left ${b===i?"bg-accent":"hover:bg-accent"}`,children:[(0,g.jsx)("div",{className:"truncate text-xs",children:a.path}),a.snippet&&(0,g.jsx)("div",{className:"truncate text-[10px] text-muted-foreground",children:(0,g.jsx)(dL,{html:a.snippet})})]},a.path))]})]})}var dW=a.i(591119);function dX(a){let b=new Date(a).getTime();if(!Number.isFinite(b))return"";let c=Math.floor(Math.max(0,Date.now()-b)/1e3);if(c<60)return"just now";let d=Math.floor(c/60);if(d<60)return`${d}m ago`;let e=Math.floor(d/60);return e<24?`${e}h ago`:`${Math.floor(e/24)}d ago`}function dY({workspaces:a,activeWorkspaceId:b,rootPath:c,isWsAdmin:d,refreshingWsId:e,switchingBranch:f,switchingBranchName:h,wsBranches:i,branchPickerWsId:j,wsBranchPos:k,onSwitchWorkspace:l,onRefreshWorkspace:m,onPromptDeleteWorkspace:n,onAddWorkspace:o,setBranchPickerWsId:p,setWsBranchPos:q,loadWsBranches:t,handleSwitchBranch:u}){return(0,g.jsxs)("div",{className:"border-t px-2 py-2 bg-muted shrink-0",children:[(0,g.jsxs)(ax.DropdownMenu,{modal:!1,onOpenChange:a=>{a||(p(null),q(null))},children:[(0,g.jsx)(ax.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsxs)(v.Button,{size:"sm",variant:"ghost",className:"w-full h-auto justify-between gap-2 px-2 py-1.5 text-left",title:c??"",children:[(0,g.jsxs)("span",{className:"flex flex-col min-w-0",children:[(0,g.jsx)("span",{className:"truncate text-xs font-medium",children:a.find(a=>a.id===b)?.name??"Workspace"}),(0,g.jsx)("span",{className:"truncate text-[10px] text-muted-foreground",children:c??""})]}),(0,g.jsx)(s,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),(0,g.jsxs)(ax.DropdownMenuContent,{align:"start",className:"w-[var(--radix-dropdown-menu-trigger-width)]",onInteractOutside:a=>{a.target?.closest?.("[data-branch-portal]")&&a.preventDefault()},children:[a.map(a=>(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>void l(a.id),onPointerMove:a=>a.preventDefault(),onPointerLeave:a=>a.preventDefault(),className:(0,ao.cn)("gap-2",a.id===b&&"font-medium"),children:[a.id===b?(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 shrink-0"}):(0,g.jsx)("span",{className:"w-3.5 shrink-0"}),(0,g.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,g.jsxs)("span",{className:"flex items-center gap-1.5 truncate",children:[(0,g.jsx)("span",{className:"truncate",children:a.name}),a.git?d?(0,g.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0 hover:bg-accent",title:"Switch branch",disabled:f===a.id,onClick:b=>{if(b.stopPropagation(),b.preventDefault(),j===a.id){p(null),q(null);return}let c=b.currentTarget.getBoundingClientRect();q({top:c.bottom+4,left:c.left}),p(a.id),t(a.id)},children:[(0,g.jsx)(a6,{className:"h-2.5 w-2.5"})," ",a.git.branch??"branch"]}):(0,g.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,g.jsx)(a6,{className:"h-2.5 w-2.5"})," ",a.git.branch??"read-only"]}):a.ssh?(0,g.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,g.jsx)(a8,{className:"h-2.5 w-2.5"})," ",a.ssh.host]}):a.readOnly?(0,g.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,g.jsx)(a6,{className:"h-2.5 w-2.5"})," read-only"]}):null]}),(0,g.jsx)("span",{className:"truncate text-[10px] text-muted-foreground",children:a.rootDir}),a.git?.lastPulledAt&&dX(a.git.lastPulledAt)&&(0,g.jsxs)("span",{className:"text-[10px] text-muted-foreground/70",children:["synced ",dX(a.git.lastPulledAt)]})]}),d&&a.git&&(0,g.jsx)("button",{className:(0,ao.cn)("shrink-0 rounded p-0.5 hover:bg-accent transition-colors",a.git.lastError?"text-destructive":"text-muted-foreground hover:text-foreground"),title:a.git.lastError?`Last refresh failed: ${a.git.lastError}`:"Refresh",disabled:e===a.id,onClick:b=>{b.stopPropagation(),b.preventDefault(),m(a.id)},children:(0,g.jsx)(bI,{className:(0,ao.cn)("h-3.5 w-3.5",e===a.id&&"animate-spin")})}),d&&(0,g.jsx)("button",{className:"shrink-0 rounded p-0.5 text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",title:"Delete workspace (does not delete files)",onClick:b=>{b.stopPropagation(),n(a.id)},children:(0,g.jsx)(bf,{className:"h-3.5 w-3.5"})})]},a.id)),d&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ax.DropdownMenuSeparator,{}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:o,children:[(0,g.jsx)(cd,{className:"mr-2 h-3.5 w-3.5"}),"Add workspace…"]})]})]})]}),(()=>{if(!j||!k)return null;let b=a.find(a=>a.id===j);return b?(0,g.jsx)(cg,{pos:k,branches:(i[b.id]??[]).map(a=>({name:a,current:a===b.git?.branch})),loading:!i[b.id],busyName:f===b.id?h:null,disabled:f===b.id,onPick:a=>{u(b.id,a)},onClose:()=>{p(null),q(null)}}):null})()]})}let dZ=(0,ay.create)(a=>({width:288,setWidth:b=>{a({width:Number.isNaN(b)?288:Math.min(600,Math.max(200,Math.round(b)))})}}));function d$(a){return a.split("/").pop()??a}function d_({workspace:a,doc:b,fileTree:c,upload:d,isMobile:e,hideChrome:f,sidebarCollapsed:h,setSidebarCollapsed:k,sidebarResizing:l,setSidebarResizing:n,sidebarWidth:p,setSidebarWidth:t,collapsed:u,setCollapsed:w,createEntry:x,setCreateEntry:y,handleCreateFile:z,handleCreateFolder:A,dragOverPath:B,setDragOverPath:C,handleDragOver:D,handleDropOnFolder:E,sidebarScrollRef:F,treeCtx:G,favorites:H,recents:I,activePaths:J,setDialogs:K,handleRefreshWorkspace:L}){let{resolvedTheme:M,setTheme:N}=(0,c0.useTheme)(),O=cI(a=>a.humanize),P=cJ(a=>a.showHidden);return(0,g.jsxs)(g.Fragment,{children:[!f&&!h&&e&&(0,g.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px] md:hidden",onClick:()=>k(!0),"aria-hidden":!0}),!f&&!h&&(0,g.jsxs)(dW.Card,{style:e?void 0:{width:p},className:"fixed inset-y-0 left-0 z-50 w-[85vw] max-w-[20rem] md:relative md:z-auto md:w-auto md:max-w-none flex flex-col shrink-0 overflow-hidden rounded-none border-r border-l-0 border-t-0 border-b-0 bg-sidebar border-sidebar-border text-sidebar-foreground",children:[(0,g.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b bg-muted shrink-0",children:[(0,g.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",title:"Wiki Viewer v2.11.5",children:[(0,g.jsx)("img",{src:(0,av.apiUrl)("/logo.svg"),alt:"Wiki Viewer",className:"h-5 w-5 shrink-0"}),(0,g.jsx)("span",{className:"truncate text-xs font-semibold leading-5 tracking-tight translate-y-[0.5px]",children:"Wiki Viewer"})]}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 shrink-0",title:"Collapse sidebar",onClick:()=>k(!0),children:(0,g.jsx)(dR,{className:"h-3.5 w-3.5"})})]}),(0,g.jsxs)("div",{className:"flex items-center justify-between gap-1 px-3 py-1.5 border-b bg-muted/50 shrink-0",children:[(0,g.jsxs)(ax.DropdownMenu,{children:[(0,g.jsx)(ax.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsxs)(v.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1 px-2 text-xs",disabled:d.uploading,children:[d.uploading?(0,g.jsx)(m.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,g.jsx)(dS,{className:"h-3.5 w-3.5"}),"New",(0,g.jsx)(s,{className:"h-3 w-3 opacity-60"})]})}),(0,g.jsxs)(ax.DropdownMenuContent,{align:"start",className:"w-44",children:[(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>y(a=>({...a,file:{...a.file,parent:"",name:"",error:null}})),children:[(0,g.jsx)(cc,{className:"mr-2 h-3.5 w-3.5"}),"New file"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>y(a=>({...a,folder:{...a.folder,parent:"",name:"",error:null}})),children:[(0,g.jsx)(cd,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>d.triggerUpload(""),disabled:d.uploading,children:[(0,g.jsx)(cf,{className:"mr-2 h-3.5 w-3.5"}),"Upload"]})]})]}),(0,g.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh tree",onClick:()=>void c.refreshTree(),disabled:c.refreshingTree,children:c.refreshingTree?(0,g.jsx)(m.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,g.jsx)(bI,{className:"h-3.5 w-3.5"})}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"AI Agent panel",onClick:()=>{bF.getState().toggle(),e&&k(!0)},children:(0,g.jsx)(i,{className:"h-3.5 w-3.5"})}),(0,g.jsxs)(ax.DropdownMenu,{children:[(0,g.jsx)(ax.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"More actions",children:(0,g.jsx)(ca,{className:"h-3.5 w-3.5"})})}),(0,g.jsxs)(ax.DropdownMenuContent,{align:"end",className:"w-48",children:[a.isWsAdmin&&a.workspaces.find(b=>b.id===a.activeWorkspaceId)?.git&&(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>{a.activeWorkspaceId&&L(a.activeWorkspaceId)},disabled:a.refreshingWsId===a.activeWorkspaceId,children:[a.refreshingWsId===a.activeWorkspaceId?(0,g.jsx)(m.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,g.jsx)(dN,{className:"mr-2 h-3.5 w-3.5"}),"Pull latest"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>cJ.getState().toggle(),children:[P?(0,g.jsx)(dP,{className:"mr-2 h-3.5 w-3.5"}):(0,g.jsx)(dO.Eye,{className:"mr-2 h-3.5 w-3.5"}),P?"Hide hidden files":"Show hidden files"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>cI.getState().toggle(),children:[(0,g.jsx)(dU,{className:"mr-2 h-3.5 w-3.5"}),O?"Raw file names":"Humanize names"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>N("dark"===M?"light":"dark"),children:["dark"===M?(0,g.jsx)(c_.Sun,{className:"mr-2 h-3.5 w-3.5"}):(0,g.jsx)(cZ.Moon,{className:"mr-2 h-3.5 w-3.5"}),"dark"===M?"Light mode":"Dark mode"]}),(0,g.jsx)(ax.DropdownMenuSeparator,{}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>K(a=>({...a,settingsOpen:!0})),children:[(0,g.jsx)(dT,{className:"mr-2 h-3.5 w-3.5"}),"Settings"]})]})]})]})]}),d.uploadError&&(0,g.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0",children:[(0,g.jsx)(q.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),d.uploadError]}),""===x.folder.parent&&(0,g.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,g.jsx)(a4,{className:"h-4 w-4 shrink-0 text-warning"}),(0,g.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:x.folder.name,onChange:a=>y(b=>({...b,folder:{...b.folder,name:a.target.value}})),onKeyDown:a=>{"Enter"===a.key&&A(),"Escape"===a.key&&y(a=>({...a,folder:{...a.folder,parent:null,name:""}}))}}),x.folder.error&&(0,g.jsx)("span",{className:"text-xs text-destructive",children:x.folder.error}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:A,children:(0,g.jsx)(r.Check,{className:"h-3 w-3"})}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>y(a=>({...a,folder:{...a.folder,parent:null,name:""}})),children:(0,g.jsx)(o,{className:"h-3 w-3"})})]}),""===x.file.parent&&(0,g.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,g.jsx)(j.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,g.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:x.file.name,onChange:a=>y(b=>({...b,file:{...b.file,name:a.target.value}})),onKeyDown:a=>{"Enter"===a.key&&z(),"Escape"===a.key&&y(a=>({...a,file:{...a.file,parent:null,name:""}}))}}),x.file.error&&(0,g.jsx)("span",{className:"text-xs text-destructive",children:x.file.error}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:z,children:(0,g.jsx)(r.Check,{className:"h-3 w-3"})}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>y(a=>({...a,file:{...a.file,parent:null,name:""}})),children:(0,g.jsx)(o,{className:"h-3 w-3"})})]}),(0,g.jsx)("div",{className:"border-b",children:(0,g.jsx)(dV,{onOpenFile:b.openFromSearch})}),(0,g.jsxs)("div",{ref:F,className:(0,ao.cn)("flex-1 overflow-auto py-1 ",""===B&&"ring-2 ring-inset ring-primary bg-primary/5"),onDragOver:a=>D(a,"","root"),onDragLeave:a=>{a.currentTarget.contains(a.relatedTarget)||C(null)},onDrop:a=>E(a,""),children:[H.length>0&&(0,g.jsxs)("div",{className:"border-b mb-1",children:[(0,g.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>w(a=>({...a,favorites:!a.favorites})),children:[u.favorites?(0,g.jsx)(a3.ChevronRight,{className:"h-3 w-3"}):(0,g.jsx)(s,{className:"h-3 w-3"}),(0,g.jsx)(ba,{className:"h-3 w-3"}),"Favorites",(0,g.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:H.length})]}),!u.favorites&&H.map(c=>(0,g.jsxs)(cp,{children:[(0,g.jsx)(cr,{asChild:!0,children:(0,g.jsxs)("div",{role:"button",tabIndex:0,className:(0,ao.cn)("group flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",b.openFile?.path===c.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{b.openFavoriteEntry(c)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.preventDefault(),b.openFavoriteEntry(c))},children:[(0,g.jsx)(cT,{name:c.name,type:c.type??"file"}),(0,g.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs",title:O?c.name:void 0,children:O?d$(c.name):c.name}),(0,g.jsx)("span",{className:"max-w-[80px] truncate text-[10px] text-muted-foreground/60",children:c.path.split("/").slice(0,-1).join("/")}),(0,g.jsx)("button",{type:"button",className:"hover-reveal shrink-0 rounded p-0.5 text-muted-foreground/50 opacity-0 transition-colors hover:bg-muted hover:text-amber-400 group-hover:opacity-100 focus:opacity-100",title:"Remove from favorites",onClick:b=>{b.stopPropagation(),cW.getState().toggle({path:c.path,name:c.name},a.activeWorkspaceId)},children:(0,g.jsx)(o,{className:"h-3 w-3"})})]})}),(0,g.jsx)(cS,{node:{path:c.path,name:c.name,type:c.type??"file"},ctx:G,isFavorited:!0,activeWorkspaceId:a.activeWorkspaceId})]},c.path))]}),I.length>0&&(0,g.jsxs)("div",{className:"border-b mb-1",children:[(0,g.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>w(a=>({...a,recent:!a.recent})),children:[u.recent?(0,g.jsx)(a3.ChevronRight,{className:"h-3 w-3"}):(0,g.jsx)(s,{className:"h-3 w-3"}),(0,g.jsx)(dQ,{className:"h-3 w-3"}),"Recent",(0,g.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:I.length})]}),!u.recent&&I.slice(0,8).map(c=>(0,g.jsxs)(cp,{children:[(0,g.jsx)(cr,{asChild:!0,children:(0,g.jsxs)("div",{role:"button",tabIndex:0,className:(0,ao.cn)("flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",b.openFile?.path===c.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{b.openViewer({path:c.path,name:c.name,type:c.type??"file",modifiedAt:""}),e&&k(!0)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.preventDefault(),b.openViewer({path:c.path,name:c.name,type:c.type??"file",modifiedAt:""}))},children:[(0,g.jsx)(cT,{name:c.name,type:c.type??"file"}),(0,g.jsx)("span",{className:"flex-1 truncate text-xs",title:O?c.name:void 0,children:O?d$(c.name):c.name}),(0,g.jsx)("span",{className:"text-[10px] text-muted-foreground/60 truncate max-w-[80px]",children:c.path.split("/").slice(0,-1).join("/")})]})}),(0,g.jsx)(cS,{node:{path:c.path,name:c.name,type:c.type??"file"},ctx:G,isFavorited:H.some(a=>a.path===c.path),activeWorkspaceId:a.activeWorkspaceId})]},c.path))]}),c.rootLoading?(0,g.jsx)("div",{className:"flex justify-center py-6",children:(0,g.jsx)(m.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):0===c.roots.length?(0,g.jsxs)("div",{className:"flex flex-col items-center gap-3 px-4 py-8 text-center",children:[(0,g.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,g.jsx)(j.FileText,{className:"h-6 w-6 text-muted-foreground"})}),(0,g.jsxs)("div",{className:"space-y-1",children:[(0,g.jsx)("p",{className:"text-sm font-medium",children:"No files yet"}),(0,g.jsx)("p",{className:"text-xs text-muted-foreground",children:"Upload files or add them to the configured directory"})]}),(0,g.jsxs)(v.Button,{size:"sm",variant:"outline",className:"w-full gap-1.5 max-w-[180px]",onClick:()=>d.triggerUpload(""),disabled:d.uploading,children:[d.uploading?(0,g.jsx)(m.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,g.jsx)(cf,{className:"h-3.5 w-3.5"}),"Upload Files"]})]}):(0,g.jsx)(cV,{ctx:G,nodes:c.roots,openPath:b.openFile?.path??null,dragOverPath:B,branchDropdownNode:c.branchDropdownNode,branchDropdownPos:c.branchDropdownPos,nodeBranches:c.nodeBranches,branchesLoading:c.branchesLoading,checkingOutBranch:c.checkingOutBranch,pullingRepo:c.pullingRepo,activePaths:J,favorites:H,isMobile:e,activeWorkspaceId:a.activeWorkspaceId,newFileParent:x.file.parent,newFileName:x.file.name,fileCreateError:x.file.error,newFolderParent:x.folder.parent,newFolderName:x.folder.name,folderError:x.folder.error,sidebarScrollRef:F})]}),(0,g.jsx)(dY,{workspaces:a.workspaces,activeWorkspaceId:a.activeWorkspaceId,rootPath:a.rootPath,isWsAdmin:a.isWsAdmin,refreshingWsId:a.refreshingWsId,switchingBranch:a.switchingBranch,switchingBranchName:a.switchingBranchName,wsBranches:a.wsBranches,branchPickerWsId:a.branchPickerWsId,wsBranchPos:a.wsBranchPos,onSwitchWorkspace:b=>void a.switchWorkspace(b),onRefreshWorkspace:a.handleRefreshWorkspace,onPromptDeleteWorkspace:b=>a.setDeletingWorkspaceId(b),onAddWorkspace:()=>a.setAddingWorkspace(!0),setBranchPickerWsId:a.setBranchPickerWsId,setWsBranchPos:a.setWsBranchPos,loadWsBranches:a.loadWsBranches,handleSwitchBranch:a.handleSwitchBranch}),(0,g.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize",onMouseDown:a=>{a.preventDefault();let b=a.clientX;n(!0);let c=document.body.style.cursor,d=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let e=a=>{t(p+(a.clientX-b))},f=()=>{n(!1),document.body.style.cursor=c,document.body.style.userSelect=d,window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",f)};window.addEventListener("mousemove",e),window.addEventListener("mouseup",f)},onDoubleClick:()=>t(288),onKeyDown:a=>{"ArrowLeft"===a.key?(a.preventDefault(),t(p-16)):"ArrowRight"===a.key&&(a.preventDefault(),t(p+16))},tabIndex:0,"aria-valuemin":200,"aria-valuemax":600,"aria-valuenow":p,className:(0,ao.cn)("absolute right-0 top-0 z-20 h-full w-1.5 cursor-col-resize -mr-px transition-colors hover:bg-primary/40 focus:bg-primary/40 focus:outline-none hidden md:block",l&&"bg-primary/60")})]})]})}function d0({workspace:a,doc:b,fileTree:c,upload:d,isMobile:e,hideChrome:f,sidebarCollapsed:h,setSidebarCollapsed:i,favorites:j,recents:k,activePaths:l,setDeleting:m,setDialogs:n}){let[o,q]=(0,p.useState)(!1),[r,s]=(0,p.useState)(null),[t,u]=(0,p.useState)({favorites:!1,recent:!0}),[v,w]=(0,p.useState)({file:{parent:null,name:"",error:null},folder:{parent:null,name:"",error:null}}),x=(0,p.useRef)(null),y=(0,p.useRef)(null),z=dZ(a=>a.width),A=dZ(a=>a.setWidth),B=(0,p.useCallback)(async()=>{let a=v.file.name.trim();if(!a||null===v.file.parent)return;w(a=>({...a,file:{...a.file,error:null}}));let d=a.includes(".")?a:`${a}.md`,e=v.file.parent?`${v.file.parent}/${d}`:d,f=await fetch((0,bB.withWs)("/api/wiki/new-file"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})});if(f.ok){let a=v.file.parent;w(a=>({...a,file:{parent:null,name:"",error:null}})),await c.reloadDir(a),b.openViewer({path:e,name:d,type:"file",modifiedAt:new Date().toISOString()})}else{let a=await f.json();w(b=>({...b,file:{...b.file,error:a.error??"Failed"}}))}},[v.file.parent,v.file.name,c,b]),C=(0,p.useCallback)(async()=>{let a=v.folder.name.trim();if(!a||null===v.folder.parent)return;w(a=>({...a,folder:{...a.folder,error:null}}));let b=v.folder.parent?`${v.folder.parent}/${a}`:a,d=await fetch((0,bB.withWs)("/api/wiki/folder"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:b})});if(d.ok){let a=v.folder.parent;w(a=>({...a,folder:{parent:null,name:"",error:null}})),await c.reloadDir(a)}else{let a=await d.json();w(b=>({...b,folder:{...b.folder,error:a.error??"Failed"}}))}},[v.folder.parent,v.folder.name,c]);function D(a,b,c){a.preventDefault(),a.stopPropagation();let d=y.current;if(!d){Array.from(a.dataTransfer.types).includes("Files")&&(a.dataTransfer.dropEffect="copy",s("root"===c?"":b));return}d.path===b||b.startsWith(`${d.path}/`)||(a.dataTransfer.dropEffect="move",s("root"===c?"":b))}async function E(a,e){a.preventDefault(),a.stopPropagation(),s(null);let f=y.current;if(y.current=null,!f){a.dataTransfer.files.length>0&&await d.doUpload(a.dataTransfer.files,e);return}if(f.path===e||e.startsWith(`${f.path}/`))return;let g=e?`${e}/${f.name}`:f.name;if(g!==f.path&&(await fetch((0,bB.withWs)("/api/wiki/move"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:f.path,to:g})})).ok){let a=f.path.includes("/")?f.path.split("/").slice(0,-1).join("/"):"";await c.reloadDir(a),e!==a&&await c.reloadDir(e),b.openFile?.path===f.path&&b.openViewer({path:g,name:f.name,type:f.type,modifiedAt:f.modifiedAt})}}let F=(0,p.useRef)(null);F.current={toggleFolder:a=>void c.toggleFolder(a),openViewer:a=>void b.openViewer(a),copyPath:a=>b.copyPath(a),copyWikiLink:a=>b.copyWikiLink(a),copyUrl:a=>b.copyUrl(a),copyRawContent:a=>void b.copyRawContent(a),copyFormattedContent:(a,c)=>void b.copyFormattedContent(a,c),handleDownload:function(a){let b=(0,bB.withWs)(`/api/wiki/download?path=${encodeURIComponent(a.path)}`),c=document.createElement("a");c.href=b,c.download="file"===a.type?a.name:`${a.name}.zip`,document.body.appendChild(c),c.click(),c.remove()},triggerUpload:a=>d.triggerUpload(a),handleCreateFile:B,handleCreateFolder:C,handleDragStart:function(a,b){y.current=b,a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",b.path)},handleDragOver:D,handleDropOnFolder:(a,b)=>void E(a,b),handleGitPull:(a,b)=>void c.handleGitPull(a,b),handleCheckout:(a,b,d)=>void c.handleCheckout(a,b,d),loadBranches:a=>void c.loadBranches(a),prefetch:a=>void c.prefetch(a),toggleFavorite:(a,b)=>cW.getState().toggle({path:a.path,name:a.name,type:a.type},b),setDragOverPath:s,setSidebarCollapsed:i,setBranchDropdownNode:a=>c.setBranchDropdownNode(a),setBranchDropdownPos:a=>c.setBranchDropdownPos(a),setNewFileParent:a=>w(b=>({...b,file:{...b.file,parent:a,error:null}})),setNewFileName:a=>w(b=>({...b,file:{...b.file,name:a}})),setFileCreateError:a=>w(b=>({...b,file:{...b.file,error:a}})),setNewFolderParent:a=>w(b=>({...b,folder:{...b.folder,parent:a,error:null}})),setNewFolderName:a=>w(b=>({...b,folder:{...b.folder,name:a}})),setFolderError:a=>w(b=>({...b,folder:{...b.folder,error:a}})),setDeletingPath:a=>m(b=>({...b,path:a})),setDeletingIsDir:a=>m(b=>({...b,isDir:a}))};let G=(0,p.useMemo)(()=>({toggleFolder:a=>F.current.toggleFolder(a),openViewer:a=>F.current.openViewer(a),copyPath:a=>F.current.copyPath(a),copyWikiLink:a=>F.current.copyWikiLink(a),copyUrl:a=>F.current.copyUrl(a),copyRawContent:a=>F.current.copyRawContent(a),copyFormattedContent:(a,b)=>F.current.copyFormattedContent(a,b),handleDownload:a=>F.current.handleDownload(a),triggerUpload:a=>F.current.triggerUpload(a),handleCreateFile:()=>F.current.handleCreateFile(),handleCreateFolder:()=>F.current.handleCreateFolder(),handleDragStart:(a,b)=>F.current.handleDragStart(a,b),handleDragOver:(a,b,c)=>F.current.handleDragOver(a,b,c),handleDropOnFolder:(a,b)=>F.current.handleDropOnFolder(a,b),handleGitPull:(a,b)=>F.current.handleGitPull(a,b),handleCheckout:(a,b,c)=>F.current.handleCheckout(a,b,c),loadBranches:a=>F.current.loadBranches(a),prefetch:a=>F.current.prefetch(a),toggleFavorite:(a,b)=>F.current.toggleFavorite(a,b),setDragOverPath:a=>F.current.setDragOverPath(a),setSidebarCollapsed:a=>F.current.setSidebarCollapsed(a),setBranchDropdownNode:a=>F.current.setBranchDropdownNode(a),setBranchDropdownPos:a=>F.current.setBranchDropdownPos(a),setNewFileParent:a=>F.current.setNewFileParent(a),setNewFileName:a=>F.current.setNewFileName(a),setFileCreateError:a=>F.current.setFileCreateError(a),setNewFolderParent:a=>F.current.setNewFolderParent(a),setNewFolderName:a=>F.current.setNewFolderName(a),setFolderError:a=>F.current.setFolderError(a),setDeletingPath:a=>F.current.setDeletingPath(a),setDeletingIsDir:a=>F.current.setDeletingIsDir(a)}),[]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(dM,{onOpenFile:b.openFromSearch,recents:k,onToggleSidebar:()=>i(a=>{let b=!a;return e&&!1===b&&bF.getState().close(),b}),onNewFile:()=>w(a=>({...a,file:{...a.file,parent:""}})),onCopyPath:()=>{b.openFile&&b.copyPath(b.openFile.path)}}),(0,g.jsx)(d_,{workspace:a,doc:b,fileTree:c,upload:d,isMobile:e,hideChrome:f,sidebarCollapsed:h,setSidebarCollapsed:i,sidebarResizing:o,setSidebarResizing:q,sidebarWidth:z,setSidebarWidth:A,collapsed:t,setCollapsed:u,createEntry:v,setCreateEntry:w,handleCreateFile:B,handleCreateFolder:C,dragOverPath:r,setDragOverPath:s,handleDragOver:D,handleDropOnFolder:E,sidebarScrollRef:x,treeCtx:G,favorites:j,recents:k,activePaths:l,setDialogs:n,handleRefreshWorkspace:a.handleRefreshWorkspace})]})}let d1=(0,h.default)("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]),d2=(0,h.default)("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]),d3=(0,h.default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),d4=(0,h.default)("share",[["path",{d:"M12 2v13",key:"1km8f5"}],["path",{d:"m16 6-4-4-4 4",key:"13yo43"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}]]),d5=(0,h.default)("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);var d6=a.i(441218);let d7=(0,h.default)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),d8=(0,p.createContext)(null),d9=(0,p.createContext)(null);function ea({path:a,badge:b,sublabel:c,showBreadcrumb:d=!0,leading:e,children:f,className:h}){let i=(0,p.useContext)(d8),j=(0,p.useContext)(d9);return i?(0,g.jsxs)(g.Fragment,{children:[b&&(j?(0,bu.createPortal)((0,g.jsx)("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground/50",children:b}),j):(0,bu.createPortal)((0,g.jsx)("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground/50",children:b}),i)),(0,bu.createPortal)((0,g.jsxs)(g.Fragment,{children:[c&&(0,g.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground/40",children:c}),f]}),i)]}):(0,g.jsxs)("div",{className:(0,ao.cn)("flex shrink-0 items-center justify-between gap-3 border-b border-border bg-background px-4 py-2",h),children:[(0,g.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e,a&&(0,g.jsx)("span",{className:"text-xs text-muted-foreground truncate",title:a,children:a.split("/").pop()??a}),b&&(0,g.jsx)("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground/50",children:b}),c&&(0,g.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground/40",children:c})]}),(0,g.jsx)("div",{className:"flex shrink-0 items-center gap-1",children:f})]})}function eb(a){let b=[],c="",d=!1,e=[];for(let f=0;f<a.length;f++){let g=a[f],h=a[f+1];d?'"'===g&&'"'===h?(c+='"',f++):'"'===g?d=!1:c+=g:'"'===g?d=!0:","===g?(e.push(c),c=""):"\n"===g||"\r"===g&&"\n"===h?(e.push(c),c="",e.length>0&&b.push(e),e=[],"\r"===g&&f++):c+=g}return e.push(c),e.some(a=>""!==a)&&b.push(e),b}function ec(a){return a.map(a=>a.map(a=>a.includes(",")||a.includes('"')||a.includes("\n")?`"${a.replace(/"/g,'""')}"`:a).join(",")).join("\n")}function ed({path:a}){let[b,c]=(0,p.useState)([]),[d,e]=(0,p.useState)(""),[f,h]=(0,p.useState)(!1),[i,j]=(0,p.useState)(!1),[k,l]=(0,p.useState)(!1),[m,n]=(0,p.useState)(null),[o,q]=(0,p.useState)(!1),[r,s]=(0,p.useState)(1e3),t=(0,bB.withWs)(`/api/assets/${a}`);(0,p.useEffect)(()=>{fetch(t).then(a=>a.text()).then(a=>{let b=eb(a),d=a.length>2097152||b.length>2e3;e(a),c(b),q(d),h(d),j(!1)})},[t]);let u=(0,p.useCallback)((a,b,d)=>{c(c=>{let e=c.map(a=>[...a]);for(;e.length<=a;)e.push([]);for(;e[a].length<=b;)e[a].push("");return e[a][b]=d,e}),j(!0)},[]),w=async()=>{l(!0);let g=f?d:ec(b);try{await (0,bB.wsFetch)(`/api/assets/${a}`,{method:"PUT",headers:{"Content-Type":"text/plain"},body:g}),f?c(eb(d)):e(g),j(!1)}catch(a){console.error("Failed to save CSV:",a)}l(!1)},x=b[0]||[],y=b.slice(1),z=o?y.slice(0,r):y,A=o&&r<y.length;return(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsxs)(ea,{path:a,badge:`CSV${b.length>0?` (${b.length-1} rows)`:""}`,children:[i&&(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:w,disabled:k,children:[(0,g.jsx)(d7,{className:"h-3.5 w-3.5"}),k?"Saving...":"Save"]}),o&&(0,g.jsxs)("span",{className:"text-[11px] text-amber-600 dark:text-amber-400 px-1",children:["Large file (",(d.length/1048576).toFixed(1)," MB,"," ",b.length.toLocaleString()," rows)"]}),(0,g.jsxs)("button",{onClick:()=>{f?c(eb(d)):e(ec(b)),h(!f)},className:`flex items-center gap-1.5 px-2.5 py-1 text-[11px] rounded-md transition-colors border border-border ${f?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"}`,children:[(0,g.jsx)(d1,{className:"h-3 w-3"}),f?"Table":"Source"]}),(0,g.jsx)("button",{onClick:()=>window.open(t,"_blank"),className:"inline-flex items-center justify-center rounded-md h-8 w-8 hover:bg-accent hover:text-accent-foreground transition-colors cursor-pointer",title:"Download CSV",children:(0,g.jsx)(b8.Download,{className:"h-4 w-4"})})]}),f?(0,g.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:(0,g.jsx)("textarea",{value:d,onChange:a=>{e(a.target.value),j(!0)},className:"w-full h-full min-h-[calc(100vh-12rem)] bg-transparent font-mono text-[13px] leading-relaxed resize-none focus:outline-none",spellCheck:!1})}):(0,g.jsxs)("div",{className:"flex-1 overflow-auto",children:[(0,g.jsxs)("table",{className:"w-full border-collapse text-[13px]",children:[(0,g.jsx)("thead",{className:"sticky top-0 z-10",children:(0,g.jsxs)("tr",{className:"bg-muted/80 backdrop-blur-sm",children:[(0,g.jsx)("th",{className:"border border-border px-1 py-1 text-center text-[10px] text-muted-foreground w-8",children:"#"}),x.map((a,b)=>(0,g.jsx)("th",{className:"border border-border px-3 py-1.5 text-left font-medium text-foreground min-w-[100px]",children:m?.r===0&&m?.c===b?(0,g.jsx)("input",{autoFocus:!0,className:"w-full bg-transparent outline-none",value:a,onChange:a=>u(0,b,a.target.value),onBlur:()=>n(null),onKeyDown:a=>{("Enter"===a.key||"Escape"===a.key)&&n(null),"Tab"===a.key&&(a.preventDefault(),n({r:0,c:b+1<x.length?b+1:0}))}}):(0,g.jsx)("span",{className:"cursor-text",onDoubleClick:()=>n({r:0,c:b}),children:a||" "})},b))]})}),(0,g.jsx)("tbody",{children:z.map((a,b)=>{let d=b+1;return(0,g.jsxs)("tr",{className:"hover:bg-accent/30 transition-colors group",children:[(0,g.jsxs)("td",{className:"border border-border px-1 py-1 text-center text-[10px] text-muted-foreground/50",children:[(0,g.jsx)("span",{className:"group-hover:hidden",children:b+1}),(0,g.jsx)("button",{className:"hidden group-hover:inline text-destructive hover:text-destructive/80 text-[10px]",onClick:()=>{c(a=>a.filter((a,b)=>b!==d)),j(!0)},title:"Delete row",children:"×"})]}),x.map((b,c)=>{let e=a[c]??"",f=m?.r===d&&m?.c===c;return(0,g.jsx)("td",{className:"border border-border px-3 py-1.5",children:f?(0,g.jsx)("input",{autoFocus:!0,className:"w-full bg-transparent outline-none",value:e,onChange:a=>u(d,c,a.target.value),onBlur:()=>n(null),onKeyDown:a=>{"Escape"===a.key&&n(null),"Enter"===a.key&&n({r:d+1,c}),"Tab"===a.key&&(a.preventDefault(),a.shiftKey?n({r:d,c:Math.max(0,c-1)}):n({r:c+1>=x.length?d+1:d,c:c+1>=x.length?0:c+1}))}}):(0,g.jsx)("span",{className:"cursor-text",onDoubleClick:()=>n({r:d,c}),children:e||" "})},c)})]},b)})})]}),A&&(0,g.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border",children:[(0,g.jsxs)("button",{onClick:()=>s(a=>a+1e3),className:"text-[11px] text-foreground hover:bg-accent transition-colors px-2.5 py-1 rounded border border-border",children:["Show"," ",Math.min(1e3,y.length-r).toLocaleString()," ","more rows"]}),(0,g.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[r.toLocaleString()," /"," ",y.length.toLocaleString()," rows"]})]}),(0,g.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 border-t border-border",children:[(0,g.jsx)("button",{onClick:()=>{let a=b[0]?.length||1;c(b=>[...b,Array(a).fill("")]),j(!0)},className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors px-2 py-1 rounded hover:bg-accent",children:"+ Add row"}),(0,g.jsx)("button",{onClick:()=>{c(a=>a.map(a=>[...a,""])),j(!0)},className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors px-2 py-1 rounded hover:bg-accent",children:"+ Add column"})]})]})]})}function ee(a){this.content=a}ee.prototype={constructor:ee,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 ee(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 ee(c)},addToStart:function(a,b){return new ee([a,b].concat(this.remove(a).content))},addToEnd:function(a,b){var c=this.remove(a).content.slice();return c.push(a,b),new ee(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 ee(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=ee.from(a)).size?new ee(a.content.concat(this.subtract(a).content)):this},append:function(a){return(a=ee.from(a)).size?new ee(this.subtract(a).content.concat(a.content)):this},subtract:function(a){var b=this;a=ee.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}},ee.from=function(a){if(a instanceof ee)return a;var b=[];if(a)for(var c in a)b.push(c,a[c]);return new ee(b)};class ef{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 ef(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 ef(c,d)}cutByIndex(a,b){return a==b?ef.empty:0==a&&b==this.content.length?this:new ef(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 ef(d,e)}addToStart(a){return new ef([a].concat(this.content),this.size+a.nodeSize)}addToEnd(a){return new ef(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 eh(0,a);if(a==this.size)return eh(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 eh(b+1,d);return eh(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 ef.empty;if(!Array.isArray(b))throw RangeError("Invalid input for Fragment.fromJSON");return ef.fromArray(b.map(a.nodeFromJSON))}static fromArray(a){if(!a.length)return ef.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 ef(b||a,c)}static from(a){if(!a)return ef.empty;if(a instanceof ef)return a;if(Array.isArray(a))return this.fromArray(a);if(a.attrs)return new ef([a],a.nodeSize);throw RangeError("Can not convert "+a+" to a Fragment"+(a.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}ef.empty=new ef([],0);let eg={index:0,offset:0};function eh(a,b){return eg.index=a,eg.offset=b,eg}function ei(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(!ei(a[c],b[c]))return!1}else{for(let c in a)if(!(c in b)||!ei(a[c],b[c]))return!1;for(let c in b)if(!(c in a))return!1}return!0}class ej{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&&ei(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 ej.none;if(a instanceof ej)return[a];let b=a.slice();return b.sort((a,b)=>a.type.rank-b.type.rank),b}}ej.none=[];class ek extends Error{}class el{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,f,g){let{index:h,offset:i}=b.findIndex(c),j=b.maybeChild(h);if(i==c||j.isText)return g&&e<=0&&f<=0&&!g.canReplace(h,h,d)?null:b.cut(0,c).append(d).append(b.cut(c));let k=a(j.content,c-i-1,d,0==h?e-1:0,h==b.childCount-1?f-1:0,j);return k&&b.replaceChild(h,j.copy(k))}(this.content,a+this.openStart,b,this.openStart+1,this.openEnd+1);return c&&new el(c,this.openStart,this.openEnd)}removeBetween(a,b){return new el(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 el.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 el(ef.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 el(a,c,d)}}function em(a,b){if(!b.type.compatibleContent(a.type))throw new ek("Cannot join "+b.type.name+" onto "+a.type.name)}function en(a,b,c){let d=a.node(c);return em(d,b.node(c)),d}function eo(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 ep(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&&(eo(a.nodeAfter,d),f++));for(let a=f;a<g;a++)eo(e.child(a),d);b&&b.depth==c&&b.textOffset&&eo(b.nodeBefore,d)}function eq(a,b){return a.type.checkContent(b),a.copy(b)}function er(a,b,c){let d=[];return ep(null,a,c,d),a.depth>c&&eo(eq(en(a,b,c+1),er(a,b,c+1)),d),ep(b,null,c,d),new ef(d)}el.empty=new el(ef.empty,0,0);class es{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 ej.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 ew(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 es(b,c,e)}static resolveCached(a,b){let c=ev.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 ev.set(a,c=new et);let d=c.elts[c.i]=es.resolve(a,b);return c.i=(c.i+1)%eu,d}}class et{constructor(){this.elts=[],this.i=0}}let eu=12,ev=new WeakMap;class ew{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 ex=Object.create(null);class ey{constructor(a,b,c,d=ej.none){this.type=a,this.attrs=b,this.marks=d,this.content=c||ef.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&&ei(this.attrs,b||a.defaultAttrs||ex)&&ej.sameSet(this.marks,c||ej.none)}copy(a=null){return a==this.content?this:new ey(this.type,this.attrs,a,this.marks)}mark(a){return a==this.marks?this:new ey(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 el.empty;let d=this.resolve(a),e=this.resolve(b),f=c?0:d.sharedDepth(b),g=d.start(f);return new el(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 ek("Inserted content deeper than insertion position");if(d.depth-c.openStart!=e.depth-c.openEnd)throw new ek("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 eq(g,er(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(ef.from(d));return{start:d.resolveNoCache(a.openStart+c),end:d.resolveNoCache(d.content.size-a.openEnd-c)}}(d,b);return eq(g,function a(b,c,d,e,f){let g=b.depth>f&&en(b,c,f+1),h=e.depth>f&&en(d,e,f+1),i=[];return ep(null,b,f,i),g&&h&&c.index(f)==d.index(f)?(em(g,h),eo(eq(g,a(b,c,d,e,f+1)),i)):(g&&eo(eq(g,er(b,c,f+1)),i),ep(c,d,f,i),h&&eo(eq(h,er(d,e,f+1)),i)),ep(e,null,f,i),new ef(i)}(b,a,f,c,e))}{let a=b.parent,e=a.content;return eq(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 es.resolveCached(this,a)}resolveNoCache(a){return es.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()+")"),eA(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=ef.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=ej.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(!ej.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=ef.fromJSON(a,b.content),e=a.nodeType(b.type).create(b.attrs,d,c);return e.type.checkAttrs(e.attrs),e}}ey.prototype.text=void 0;class ez extends ey{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):eA(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 ez(this.type,this.attrs,this.text,a)}withText(a){return a==this.text?this:new ez(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 eA(a,b){for(let c=a.length-1;c>=0;c--)b=a[c].type.name+"("+b+")";return b}class eB{constructor(a){this.validEnd=a,this.next=[],this.wrapCache=[]}static parse(a,b){var c;let d,e=new eC(a,b);if(null==e.next)return eB.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=eD(a),d=c;return a.eat(",")&&(d="}"!=a.next?eD(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]);eF(c,b).forEach(b=>{d||e.push([a,d=[]]),-1==d.indexOf(b)&&d.push(b)})}})});let f=d[b.join(",")]=new eB(b.indexOf(c.length-1)>-1);for(let b=0;b<e.length;b++){let c=e[b][1].sort(eE);f.next.push({type:e[b][0],next:d[c.join(",")]||a(c)})}return f}(eF(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 ef.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")}}eB.empty=new eB(!0);class eC{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 eD(a){/\D/.test(a.next)&&a.err("Expected number, got '"+a.next+"'");let b=Number(a.next);return a.pos++,b}function eE(a,b){return b-a}function eF(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(eE)}function eG(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 eH(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 eI(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 eJ(a,b){let c=Object.create(null);if(b)for(let d in b)c[d]=new eL(a,d,b[d]);return c}class eK{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=eJ(a,c.attrs),this.defaultAttrs=eG(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==eB.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:eH(this.attrs,a)}create(a=null,b,c){if(this.isText)throw Error("NodeType.create can't construct text nodes");return new ey(this,this.computeAttrs(a),ef.from(b),ej.setFrom(c))}createChecked(a=null,b,c){return b=ef.from(b),this.checkContent(b),new ey(this,this.computeAttrs(a),b,ej.setFrom(c))}createAndFill(a=null,b,c){if(a=this.computeAttrs(a),(b=ef.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(ef.empty,!0);return e?new ey(this,a,b.append(e),ej.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){eI(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:ej.none:a}static compile(a,b){let c=Object.create(null);a.forEach((a,d)=>c[a]=new eK(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 eL{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 eM{constructor(a,b,c,d){this.name=a,this.rank=b,this.schema=c,this.spec=d,this.attrs=eJ(a,d.attrs),this.excluded=null;let e=eG(this.attrs);this.instance=e?new ej(this,e):null}create(a=null){return!a&&this.instance?this.instance:new ej(this,eH(this.attrs,a))}static compile(a,b){let c=Object.create(null),d=0;return a.forEach((a,e)=>c[a]=new eM(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){eI(this.attrs,a,"mark",this.name)}excludes(a){return this.excluded.indexOf(a)>-1}}class eN{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=ee.from(a.nodes),b.marks=ee.from(a.marks||{}),this.nodes=eK.compile(this.spec.nodes,this),this.marks=eM.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]=eB.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?eO(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?[]:eO(this,c.split(" "))}this.nodeFromJSON=a=>ey.fromJSON(this,a),this.markFromJSON=a=>ej.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 eK){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 ez(c,c.defaultAttrs,a,ej.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 eO(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 eP{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 eV(this,b,!1);return c.addAll(a,ej.none,b.from,b.to),c.finish()}parseSlice(a,b={}){let c=new eV(this,b,!0);return c.addAll(a,ej.none,b.from,b.to),el.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=eW(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=eW(a)),a.node||a.ignore||a.mark||(a.node=b)})}return b}static fromSchema(a){return a.cached.domParser||(a.cached.domParser=new eP(a,eP.schemaRules(a)))}}let eQ={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},eR={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},eS={ol:!0,ul:!0};function eT(a,b,c){return null!=b?!!b|2*("full"===b):a&&"pre"==a.whitespace?3:-5&c}class eU{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=ej.none,this.match=e||(4&f?null:a.contentMatch)}findWrapping(a){if(!this.match){if(!this.type)return[];let b=this.type.contentMatch.fillBefore(ef.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=ef.from(this.content);return!a&&this.match&&(b=b.append(this.match.fillBefore(ef.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&&!eQ.hasOwnProperty(a.parentNode.nodeName.toLowerCase())}}class eV{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=eT(null,b.preserveWhitespace,0)|4*!!c;e=d?new eU(d.type,d.attrs,ej.none,!0,b.topMatch||d.type.contentMatch,f):c?new eU(null,null,ej.none,!0,null,f):new eU(a.schema.topNodeType,null,ej.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;eS.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&&eS.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));b:if(h?h.ignore:eR.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(eQ.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 b}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=ej.none;for(let e of d.concat(a.marks))(b.type?b.type.allowsMarkType(e.type):eX(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=eT(a,e,f.options);4&f.options&&0==f.content.length&&(g|=4);let h=ej.none;return c=c.filter(b=>(f.type?!f.type.allowsMarkType(b.type):!eX(b.type,a))||(h=b.addToSet(h),!1)),this.nodes.push(new eU(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 eW(a){let b={};for(let c in a)b[c]=a[c];return b}function eX(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 eY{constructor(a,b){this.nodes=a,this.marks=b}serializeFragment(a,b={},c){c||(c=e$(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){if(a.isText)return e$(b).createTextNode(a.text);let{dom:c,contentDOM:d}=e0(e$(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&&e0(e$(c),d(a,b),null,a.attrs)}static renderSpec(a,b,c=null,d){return"string"==typeof b?{dom:a.createTextNode(b)}:e0(a,b,c,d)}static fromSchema(a){return a.cached.domSerializer||(a.cached.domSerializer=new eY(this.nodesFromSchema(a),this.marksFromSchema(a)))}static nodesFromSchema(a){let b=eZ(a.nodes);return b.text||(b.text=a=>a.text),b}static marksFromSchema(a){return eZ(a.marks)}}function eZ(a){let b={};for(let c in a){let d=a[c].spec.toDOM;d&&(b[c]=d)}return b}function e$(a){return a.document||window.document}let e_=new WeakMap;function e0(a,b,c,d){let e,f,g;if(1==b.nodeType)return{dom:b};if(b.dom&&1==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=e_.get(d))&&e_.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}}if("string"==typeof g)k.appendChild(a.createTextNode(g));else{let{dom:b,contentDOM:f}=e0(a,g,c,d);if(k.appendChild(b),f){if(e)throw RangeError("Multiple content holes");e=f}}}return{dom:k,contentDOM:e}}class e1{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 e2{constructor(a,b=!1){if(this.ranges=a,this.inverted=b,!a.length&&e2.empty)return e2.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 e1(f,m,l)}d+=j-i}return c?a+d:new e1(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 e2(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(a){return 0==a?e2.empty:new e2(a<0?[0,-a,0]:[0,0,a])}}e2.empty=new e2([]);class e3{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 e3(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 e3;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 e1(a,d,null)}}let e4=Object.create(null);class e5{getMap(){return e2.empty}merge(a){return null}static fromJSON(a,b){if(!b||!b.stepType)throw RangeError("Invalid input for Step.fromJSON");let c=e4[b.stepType];if(!c)throw RangeError(`No step type ${b.stepType} defined`);return c.fromJSON(a,b)}static jsonID(a,b){if(a in e4)throw RangeError("Duplicate use of step JSON ID "+a);return e4[a]=b,b.prototype.jsonID=a,b}}class e6{constructor(a,b){this.doc=a,this.failed=b}static ok(a){return new e6(a,null)}static fail(a){return new e6(null,a)}static fromReplace(a,b,c,d){try{return e6.ok(a.replace(b,c,d))}catch(a){if(a instanceof ek)return e6.fail(a.message);throw a}}}function e7(a,b,c){let d=[];for(let e=0;e<a.childCount;e++){let f=a.child(e);f.content.size&&(f=f.copy(e7(f.content,b,f))),f.isInline&&(f=b(f,c,e)),d.push(f)}return ef.fromArray(d)}class e8 extends e5{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 el(e7(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 e6.fromReplace(a,this.from,this.to,e)}invert(){return new e9(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 e8(b.pos,c.pos,this.mark)}merge(a){return a instanceof e8&&a.mark.eq(this.mark)&&this.from<=a.to&&this.to>=a.from?new e8(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 e8(b.from,b.to,a.markFromJSON(b.mark))}}e5.jsonID("addMark",e8);class e9 extends e5{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 el(e7(b.content,a=>a.mark(this.mark.removeFromSet(a.marks)),a),b.openStart,b.openEnd);return e6.fromReplace(a,this.from,this.to,c)}invert(){return new e8(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 e9(b.pos,c.pos,this.mark)}merge(a){return a instanceof e9&&a.mark.eq(this.mark)&&this.from<=a.to&&this.to>=a.from?new e9(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 e9(b.from,b.to,a.markFromJSON(b.mark))}}e5.jsonID("removeMark",e9);class fa extends e5{constructor(a,b){super(),this.pos=a,this.mark=b}apply(a){let b=a.nodeAt(this.pos);if(!b)return e6.fail("No node at mark step's position");let c=b.type.create(b.attrs,null,this.mark.addToSet(b.marks));return e6.fromReplace(a,this.pos,this.pos+1,new el(ef.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 fa(this.pos,b.marks[c]);return new fa(this.pos,this.mark)}}return new fb(this.pos,this.mark)}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new fa(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 fa(b.pos,a.markFromJSON(b.mark))}}e5.jsonID("addNodeMark",fa);class fb extends e5{constructor(a,b){super(),this.pos=a,this.mark=b}apply(a){let b=a.nodeAt(this.pos);if(!b)return e6.fail("No node at mark step's position");let c=b.type.create(b.attrs,null,this.mark.removeFromSet(b.marks));return e6.fromReplace(a,this.pos,this.pos+1,new el(ef.from(c),0,+!b.isLeaf))}invert(a){let b=a.nodeAt(this.pos);return b&&this.mark.isInSet(b.marks)?new fa(this.pos,this.mark):this}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new fb(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 fb(b.pos,a.markFromJSON(b.mark))}}e5.jsonID("removeNodeMark",fb);class fc extends e5{constructor(a,b,c,d=!1){super(),this.from=a,this.to=b,this.slice=c,this.structure=d}apply(a){return this.structure&&fe(a,this.from,this.to)?e6.fail("Structure replace would overwrite content"):e6.fromReplace(a,this.from,this.to,this.slice)}getMap(){return new e2([this.from,this.to-this.from,this.slice.size])}invert(a){return new fc(this.from,this.from+this.slice.size,a.slice(this.from,this.to))}map(a){let b=a.mapResult(this.to,-1),c=this.from==this.to&&fc.MAP_BIAS<0?b:a.mapResult(this.from,1);return c.deletedAcross&&b.deletedAcross?null:new fc(c.pos,Math.max(c.pos,b.pos),this.slice,this.structure)}merge(a){if(!(a instanceof fc)||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?el.empty:new el(a.slice.content.append(this.slice.content),a.slice.openStart,this.slice.openEnd);return new fc(a.from,this.to,b,this.structure)}{let b=this.slice.size+a.slice.size==0?el.empty:new el(this.slice.content.append(a.slice.content),this.slice.openStart,a.slice.openEnd);return new fc(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 fc(b.from,b.to,el.fromJSON(a,b.slice),!!b.structure)}}fc.MAP_BIAS=1,e5.jsonID("replace",fc);class fd extends e5{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&&(fe(a,this.from,this.gapFrom)||fe(a,this.gapTo,this.to)))return e6.fail("Structure gap-replace would overwrite content");let b=a.slice(this.gapFrom,this.gapTo);if(b.openStart||b.openEnd)return e6.fail("Gap is not a flat range");let c=this.slice.insertAt(this.insert,b.content);return c?e6.fromReplace(a,this.from,this.to,c):e6.fail("Content does not fit in gap")}getMap(){return new e2([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 fd(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 fd(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 fd(b.from,b.to,b.gapFrom,b.gapTo,el.fromJSON(a,b.slice),b.insert,!!b.structure)}}function fe(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 ff(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 e9(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 el(ef.from(c.schema.text(" ",c.allowedMarks(i.marks))),0,0)),g.push(new fc(h+a.index,h+a.index+a[0].length,d))}}else g.push(new fc(h,j,el.empty));h=j}if(!d.validEnd){let b=d.fillBefore(ef.empty,!0);a.replace(h,h,new el(b,0,0))}for(let b=g.length-1;b>=0;b--)a.step(g[b])}function fg(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 fh(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(fi).concat({type:b,attrs:c}).concat(f.map(fi)):null}function fi(a){return{type:a,attrs:null}}function fj(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 fk(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 fl(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 fm(a,b){let c=a.resolve(b),d=c.index();return fn(c.nodeBefore,c.nodeAfter)&&c.parent.canReplace(d,d+1)}function fn(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 fo(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&&fn(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 fp(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 fq(a,b,c=b,d=el.empty){if(b==c&&!d.size)return null;let e=a.resolve(b),f=a.resolve(c);return fr(e,f,d)?new fc(b,c,d):new fs(e,f,d).fit()}function fr(a,b,c){return!c.openStart&&!c.openEnd&&a.start()==b.start()&&a.parent.canReplace(a.index(),b.index(),c.content)}e5.jsonID("replaceAround",fd);class fs{constructor(a,b,c){this.$from=a,this.$to=b,this.unplaced=c,this.frontier=[],this.placed=ef.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=ef.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 el(e,f,g);return a>-1?new fd(c.pos,a,this.$to.pos,this.$to.end(),h,b):h.size||c.pos!=this.$to.pos?new fc(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=fv(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(ef.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=fv(a,b);return!!d.childCount&&!d.firstChild.isLeaf&&(this.unplaced=new el(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=fv(a,b);if(d.childCount<=1&&b>0){let e=a.size-b<=b+d.size;this.unplaced=new el(ft(a,b-1,1),b-1,e?b-1:c)}else this.unplaced=new el(ft(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(ef.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=fu(this.placed,b,ef.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?el.empty:new el(ft(f.content,a-1,1),a-1,m<0?f.openEnd:a-1):new el(ft(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||!fw(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){c: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=fw(a,b,d,c,e);if(f){for(let c=b-1;c>=0;c--){let{match:b,type:d}=this.frontier[c],e=fw(a,c,d,b,!0);if(!e||e.childCount)continue c}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=fu(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=fu(this.placed,this.depth,ef.from(a.create(b,c))),this.frontier.push({type:a,match:a.contentMatch})}closeFrontierNode(){let a=this.frontier.pop().match.fillBefore(ef.empty,!0);a.childCount&&(this.placed=fu(this.placed,this.frontier.length,a))}}function ft(a,b,c){return 0==b?a.cutByIndex(c,a.childCount):a.replaceChild(0,a.firstChild.copy(ft(a.firstChild.content,b-1,c)))}function fu(a,b,c){return 0==b?a.append(c):a.replaceChild(a.childCount-1,a.lastChild.copy(fu(a.lastChild.content,b-1,c)))}function fv(a,b){for(let c=0;c<b;c++)a=a.firstChild.content;return a}function fw(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 fx(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 fy extends e5{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 e6.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 e6.fromReplace(a,this.pos,this.pos+1,new el(ef.from(d),0,+!b.isLeaf))}getMap(){return e2.empty}invert(a){return new fy(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 fy(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 fy(b.pos,b.attr,b.value)}}e5.jsonID("attr",fy);class fz extends e5{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 e6.ok(c)}getMap(){return e2.empty}invert(a){return new fz(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 fz(b.attr,b.value)}}e5.jsonID("docAttr",fz);let fA=class extends Error{};(fA=function a(b){let c=Error.call(this,b);return c.__proto__=a.prototype,c}).prototype=Object.create(Error.prototype),fA.prototype.constructor=fA,fA.prototype.name="TransformError";class fB{constructor(a){this.doc=a,this.steps=[],this.docs=[],this.mapping=new e3}get before(){return this.docs.length?this.docs[0]:this.doc}step(a){let b=this.maybeStep(a);if(b.failed)throw new fA(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=el.empty){let d=fq(this.doc,a,b,c);return d&&this.step(d),this}replaceWith(a,b,c){return this.replace(a,b,new el(ef.from(c),0,0))}delete(a,b){return this.replace(a,b,el.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(fr(e,f,d))return a.step(new fc(b,c,d));let g=fx(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 el(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(ef.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 el(ef.from(c),0,0)),this}deleteRange(a,b){return!function(a,b,c){let d=a.doc.resolve(b),e=a.doc.resolve(c);if(d.parent.isTextblock&&e.parent.isTextblock&&d.start()!=e.start()&&0==d.parentOffset&&0==e.parentOffset){let f=d.sharedDepth(c),g=!1;for(let a=d.depth;a>f;a--)d.node(a).type.spec.isolating&&(g=!0);for(let a=e.depth;a>f;a--)e.node(a).type.spec.isolating&&(g=!0);if(!g){for(let a=d.depth;a>0&&b==d.start(a);a--)b=d.before(a);for(let a=e.depth;a>0&&c==e.start(a);a--)c=e.before(a);d=a.doc.resolve(b),e=a.doc.resolve(c)}}let f=fx(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=ef.empty,l=0;for(let a=f,b=!1;a>c;a--)b||d.index(a)>0?(b=!0,k=ef.from(d.node(a).copy(k)),l++):i--;let m=ef.empty,n=0;for(let a=f,b=!1;a>c;a--)b||e.after(a+1)<e.end(a)?(b=!0,m=ef.from(e.node(a).copy(m)),n++):j++;a.step(new fd(i,j,g,h,new el(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);fk(a,d.node(),d.before(),h)}g.inlineContent&&ff(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 fc(j,i.map(b+c,-1),el.empty,!0)),!0===d){let b=a.doc.resolve(j);fj(a,b.node(),b.before(),a.steps.length)}}(this,a,b),this}wrap(a,b){return!function(a,b,c){let d=ef.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=ef.from(c[a].type.create(c[a].attrs,d))}let e=b.start,f=b.end;a.step(new fd(e,f,e,f,new el(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&&fk(e,a,b,f),ff(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 fd(h,i,h+1,i-1,new el(ef.from(c.create(l,null,a.marks)),0,0),1,!0)),!0===d&&fj(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 fd(b,b+f.nodeSize,b+1,b+f.nodeSize-1,new el(ef.from(g),0,0),1,!0))}(this,a,b,c,d),this}setNodeAttribute(a,b,c){return this.step(new fy(a,b,c)),this}setDocAttribute(a,b){return this.step(new fz(a,b)),this}addNodeMark(a,b){return this.step(new fa(a,b)),this}removeNodeMark(a,b){let c=this.doc.nodeAt(a);if(!c)throw RangeError("No node at position "+a);if(b instanceof ej)b.isInSet(c.marks)&&this.step(new fb(a,b));else{let d=c.marks,e,f=[];for(;e=b.isInSet(d);)f.push(new fb(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=ef.empty,g=ef.empty;for(let a=e.depth,b=e.depth-c,h=c-1;a>b;a--,h--){f=ef.from(e.node(a).copy(f));let b=d&&d[h];g=ef.from(b?b.type.create(b.attrs,g):e.node(a).copy(g))}a.step(new fc(b,b,new el(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 e9(j,l,k[a])));f&&f.to==j?f.to=l:h.push(f=new e8(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 eM){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 e9(a.from,a.to,a.style))),this}clearIncompatible(a,b,c){return ff(this,a,b,c),this}}let fC=Object.create(null);class fD{constructor(a,b,c){this.$anchor=a,this.$head=b,this.ranges=c||[new fE(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=el.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?el.empty:b),0==g&&fO(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),fO(a,c,b.isInline?-1:1))}}static findFrom(a,b,c=!1){let d=a.parent.inlineContent?new fH(a):fN(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?fN(a.node(0),a.node(d),a.before(d+1),a.index(d),b,c):fN(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 fL(a.node(0))}static atStart(a){return fN(a,a,0,0,1)||new fL(a)}static atEnd(a){return fN(a,a,a.content.size,a.childCount,-1)||new fL(a)}static fromJSON(a,b){if(!b||!b.type)throw RangeError("Invalid input for Selection.fromJSON");let c=fC[b.type];if(!c)throw RangeError(`No selection type ${b.type} defined`);return c.fromJSON(a,b)}static jsonID(a,b){if(a in fC)throw RangeError("Duplicate use of selection JSON ID "+a);return fC[a]=b,b.prototype.jsonID=a,b}getBookmark(){return fH.between(this.$anchor,this.$head).getBookmark()}}fD.prototype.visible=!0;class fE{constructor(a,b){this.$from=a,this.$to=b}}let fF=!1;function fG(a){fF||a.parent.inlineContent||(fF=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+a.parent.type.name+")"))}class fH extends fD{constructor(a,b=a){fG(a),fG(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 fD.near(c);let d=a.resolve(b.map(this.anchor));return new fH(d.parent.inlineContent?d:c,c)}replace(a,b=el.empty){if(super.replace(a,b),b==el.empty){let b=this.$from.marksAcross(this.$to);b&&a.ensureMarks(b)}}eq(a){return a instanceof fH&&a.anchor==this.anchor&&a.head==this.head}getBookmark(){return new fI(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 fH(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=fD.findFrom(b,c,!0)||fD.findFrom(b,-c,!0);if(!a)return fD.near(b,c);b=a.$head}return a.parent.inlineContent||(0==d?a=b:(a=(fD.findFrom(a,-c,!0)||fD.findFrom(a,c,!0)).$anchor).pos<b.pos!=d<0&&(a=b)),new fH(a,b)}}fD.jsonID("text",fH);class fI{constructor(a,b){this.anchor=a,this.head=b}map(a){return new fI(a.map(this.anchor),a.map(this.head))}resolve(a){return fH.between(a.resolve(this.anchor),a.resolve(this.head))}}class fJ extends fD{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?fD.near(e):new fJ(e)}content(){return new el(ef.from(this.node),0,0)}eq(a){return a instanceof fJ&&a.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new fK(this.anchor)}static fromJSON(a,b){if("number"!=typeof b.anchor)throw RangeError("Invalid input for NodeSelection.fromJSON");return new fJ(a.resolve(b.anchor))}static create(a,b){return new fJ(a.resolve(b))}static isSelectable(a){return!a.isText&&!1!==a.type.spec.selectable}}fJ.prototype.visible=!1,fD.jsonID("node",fJ);class fK{constructor(a){this.anchor=a}map(a){let{deleted:b,pos:c}=a.mapResult(this.anchor);return b?new fI(c,c):new fK(c)}resolve(a){let b=a.resolve(this.anchor),c=b.nodeAfter;return c&&fJ.isSelectable(c)?new fJ(b):fD.near(b)}}class fL extends fD{constructor(a){super(a.resolve(0),a.resolve(a.content.size))}replace(a,b=el.empty){if(b==el.empty){a.delete(0,a.doc.content.size);let b=fD.atStart(a.doc);b.eq(a.selection)||a.setSelection(b)}else super.replace(a,b)}toJSON(){return{type:"all"}}static fromJSON(a){return new fL(a)}map(a){return new fL(a)}eq(a){return a instanceof fL}getBookmark(){return fM}}fD.jsonID("all",fL);let fM={map(){return this},resolve:a=>new fL(a)};function fN(a,b,c,d,e,f=!1){if(b.inlineContent)return fH.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&&fJ.isSelectable(d))return fJ.create(a,c-(e<0?d.nodeSize:0))}else{let b=fN(a,d,c+e,e<0?d.childCount:0,e,f);if(b)return b}c+=d.nodeSize*e}return null}function fO(a,b,c){let d,e=a.steps.length-1;if(e<b)return;let f=a.steps[e];(f instanceof fc||f instanceof fd)&&(a.mapping.maps[e].forEach((a,b,c,e)=>{null==d&&(d=e)}),a.setSelection(fD.near(a.doc.resolve(d),c)))}class fP extends fB{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 ej.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)||ej.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(fD.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 fQ(a,b){return b&&a?a.bind(b):a}class fR{constructor(a,b,c){this.name=a,this.init=fQ(b.init,c),this.apply=fQ(b.apply,c)}}let fS=[new fR("doc",{init:a=>a.doc||a.schema.topNodeType.createAndFill(),apply:a=>a.doc}),new fR("selection",{init:(a,b)=>a.selection||fD.atStart(b.doc),apply:a=>a.selection}),new fR("storedMarks",{init:a=>a.storedMarks||null,apply:(a,b,c,d)=>d.selection.$cursor?a.storedMarks:null}),new fR("scrollToSelection",{init:()=>0,apply:(a,b)=>a.scrolledIntoView?b+1:b})];class fT{constructor(a,b){this.schema=a,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=fS.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 fR(a.key,a.spec.state,a))})}}class fU{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 fU(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 fP(this)}static create(a){let b=new fT(a.doc?a.doc.type.schema:a.schema,a.plugins),c=new fU(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 fT(this.schema,a.plugins),c=b.fields,d=new fU(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 fT(a.schema,a.plugins),e=new fU(d);return d.fields.forEach(d=>{if("doc"==d.name)e.doc=ey.fromJSON(a.schema,b.doc);else if("selection"==d.name)e.selection=fD.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 fV{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:fX("plugin")}getState(a){return a[this.key]}}let fW=Object.create(null);function fX(a){return a in fW?a+"$"+ ++fW[a]:(fW[a]=0,a+"$")}class fY{constructor(a="key"){this.key=fX(a)}get(a){return a.config.pluginsByKey[this.key]}getState(a){return a[this.key]}}let fZ=function(a){for(var b=0;;b++)if(!(a=a.previousSibling))return b},f$=function(a){let b=a.assignedSlot||a.parentNode;return b&&11==b.nodeType?b.host:b},f_=null,f0=function(a,b,c){let d=f_||(f_=document.createRange());return d.setEnd(a,null==c?a.nodeValue.length:c),d.setStart(a,b||0),d},f1=function(){f_=null},f2=function(a,b,c,d){return c&&(f4(a,b,c,d,-1)||f4(a,b,c,d,1))},f3=/^(img|br|input|textarea|hr)$/i;function f4(a,b,c,d,e){for(var f;;){if(a==c&&b==d)return!0;if(b==(e<0?0:f5(a))){let c=a.parentNode;if(!c||1!=c.nodeType||f6(a)||f3.test(a.nodeName)||"false"==a.contentEditable)return!1;b=fZ(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?f5(a):0}}}function f5(a){return 3==a.nodeType?a.nodeValue.length:a.childNodes.length}function f6(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 f7=function(a){return a.focusNode&&f2(a.focusNode,a.focusOffset,a.anchorNode,a.anchorOffset)};function f8(a,b){let c=document.createEvent("Event");return c.initEvent("keydown",!0,!0),c.keyCode=a,c.key=c.code=b,c}let f9="u">typeof navigator?navigator:null,ga="u">typeof document?document:null,gb=f9&&f9.userAgent||"",gc=/Edge\/(\d+)/.exec(gb),gd=/MSIE \d/.exec(gb),ge=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(gb),gf=!!(gd||ge||gc),gg=gd?document.documentMode:ge?+ge[1]:gc?+gc[1]:0,gh=!gf&&/gecko\/(\d+)/i.test(gb);gh&&(/Firefox\/(\d+)/.exec(gb)||[0,0])[1];let gi=!gf&&/Chrome\/(\d+)/.exec(gb),gj=!!gi,gk=gi?+gi[1]:0,gl=!gf&&!!f9&&/Apple Computer/.test(f9.vendor),gm=gl&&(/Mobile\/\w+/.test(gb)||!!f9&&f9.maxTouchPoints>2),gn=gm||!!f9&&/Mac/.test(f9.platform),go=!!f9&&/Win/.test(f9.platform),gp=/Android \d/.test(gb),gq=!!ga&&"webkitFontSmoothing"in ga.documentElement.style,gr=gq?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function gs(a,b){return"number"==typeof a?a:a[b]}function gt(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=f$(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+gs(d,"top")?j=-(h.top-b.top+gs(e,"top")):b.bottom>h.bottom-gs(d,"bottom")&&(j=b.bottom-b.top>h.bottom-h.top?b.top+gs(e,"top")-h.top:b.bottom-h.bottom+gs(e,"bottom")),b.left<h.left+gs(d,"left")?i=-(h.left-b.left+gs(e,"left")):b.right>h.right-gs(d,"right")&&(i=b.right-h.right+gs(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:f$(g)}}function gu(a){let b=[],c=a.ownerDocument;for(let d=a;d&&(b.push({dom:d,top:d.scrollTop,left:d.scrollLeft}),a!=c);d=f$(d));return b}function gv(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 gw=null;function gx(a,b){return a.left>=b.left-1&&a.left<=b.right+1&&a.top>=b.top-1&&a.top<=b.bottom+1}function gy(a){return a.top<a.bottom||a.left<a.right}function gz(a,b){let c=a.getClientRects();if(c.length){let a=c[b<0?0:c.length-1];if(gy(a))return a}return Array.prototype.find.call(c,gy)||a.getBoundingClientRect()}let gA=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function gB(a,b,c){let{node:d,offset:e,atom:f}=a.docView.domFromPos(b,c<0?-1:1),g=gq||gh;if(3==d.nodeType)if(g&&(gA.test(d.nodeValue)||(c<0?!e:e==d.nodeValue.length))){let a=gz(f0(d,e,e),c);if(gh&&e&&/\s/.test(d.nodeValue[e-1])&&e<d.nodeValue.length){let b=gz(f0(d,e-1,e-1),-1);if(b.top==a.top){let c=gz(f0(d,e,e+1),-1);if(c.top!=a.top)return gC(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++,gC(gz(f0(d,a,b),f),f<0)}if(!a.state.doc.resolve(b-(f||0)).parent.inlineContent){if(null==f&&e&&(c<0||e==f5(d))){let a=d.childNodes[e-1];if(1==a.nodeType)return gD(a.getBoundingClientRect(),!1)}if(null==f&&e<f5(d)){let a=d.childNodes[e];if(1==a.nodeType)return gD(a.getBoundingClientRect(),!0)}return gD(d.getBoundingClientRect(),c>=0)}if(null==f&&e&&(c<0||e==f5(d))){let a=d.childNodes[e-1],b=3==a.nodeType?f0(a,f5(a)-!g):1!=a.nodeType||"BR"==a.nodeName&&a.nextSibling?null:a;if(b)return gC(gz(b,1),!1)}if(null==f&&e<f5(d)){let a=d.childNodes[e];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let b=a?3==a.nodeType?f0(a,0,+!g):1==a.nodeType?a:null:null;if(b)return gC(gz(b,-1),!0)}return gC(gz(3==d.nodeType?f0(d):d,-c),c>=0)}function gC(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 gD(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 gE(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 gF=/[\u0590-\u08ac]/,gG=null,gH=null,gI=!1;class gJ{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>fZ(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 gQ){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 gK&&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?fZ(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?fZ(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=fZ(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=fZ(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((gh||gl)&&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:fZ(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(gh&&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&&gl)&&f2(g.node,g.offset,j.anchorNode,j.anchorOffset)&&f2(h.node,h.offset,j.focusNode,j.focusOffset))return;let l=!1;if((i.extend||a==b)&&!(k&&gh)){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 gK extends gJ{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 gL extends gJ{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 gM extends gJ{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=eY.renderSpec(document,b.type.spec.toDOM(b,c),null,b.attrs)),new gM(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=gM.create(this.parent,this.mark,!0,c),e=this.children,f=this.size;b<f&&(e=g_(e,b,f,c)),a>0&&(e=g_(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 gN extends gJ{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=eY.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=gW(j,c,b),i)?h=new gR(a,b,c,d,j,k||null,l,i,e,f+1):b.isText?new gP(a,b,c,d,j,l,e):new gN(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=()=>ef.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)&&gX(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 gZ(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(g$);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?ej.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=gY(e),f=!0;e=e.nextSibling}else f=!0,b.insertBefore(i,e);if(h instanceof gM){let c=e?e.previousSibling:b.lastChild;a(h.contentDOM,h.children,d),e=c?c.nextSibling:b.firstChild}}for(;e;)e=gY(e),f=!0;f&&d.trackWrites==b&&(d.trackWrites=null)}(this.contentDOM,this.children,a),gm&&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 fH)||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 gL(this,e,b,d);a.input.compositionNodes.push(f),this.children=g_(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(gX(a,this.outerDeco))return;let b=1!=this.nodeDOM.nodeType,c=this.dom;this.dom=gV(this.dom,this.nodeDOM,gU(this.outerDeco,this.node,b),gU(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 gO(a,b,c,d,e){gW(d,b,a);let f=new gN(void 0,a,b,c,d,d,d,e,0);return f.contentDOM&&f.updateChildren(e,0),f}class gP extends gN{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 gP(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 gQ extends gJ{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 gR extends gN{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 gS=function(a){a&&(this.nodeName=a)};gS.prototype=Object.create(null);let gT=[new gS];function gU(a,b,c){if(0==a.length)return gT;let d=c?gT[0]:new gS,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 gS(g.nodeName)),g){let f=g[a];null!=f&&(c&&1==e.length&&e.push(d=new gS(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 gV(a,b,c,d){if(c==gT&&d==gT)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=gT[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||gT[0],f)}return e}function gW(a,b,c){return gV(a,a,gT,gU(b,c,1!=a.nodeType))}function gX(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 gY(a){let b=a.nextSibling;return a.parentNode.removeChild(a),b}class gZ{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=[];d:for(;e>0;){let h;for(;;)if(d){let a=c.children[d-1];if(a instanceof gM)c=a,d=a.children.length;else{h=a,d--;break}}else if(c==b)break d;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=gM.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 gN){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&&gX(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)||!gX(c,a.outerDeco)||!d.eq(a.innerDeco))return null;let g=gN.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=gN.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 gK(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 gM;)a=(b=a).children[b.children.length-1];(!a||!(a instanceof gP)||/\n$/.test(a.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(a.node.text))&&((gl||gj)&&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 gQ(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 g$(a,b){return a.type.side-b.type.side}function g_(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 g0(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(f7(c)){for(i=g;e&&!e.node;)e=e.parent;let a=e.node;if(e&&a.isAtom&&fJ.isSelectable(a)&&e.parent&&!(a.isInline&&function(a,b,c){for(let d=0==b,e=b==f5(a);d||e;){if(a==c)return!0;let b=fZ(a);if(!(a=a.parentNode))return!1;d=d&&0==b,e=e&&b==f5(a)}}(c.focusNode,c.focusOffset,e.dom))){let a=e.posBefore;j=new fJ(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=g9(a,k,h,c)}return j}function g1(a){return a.editable?a.hasFocus():hb(a)&&document.activeElement&&document.activeElement.contains(a.dom)}function g2(a,b=!1){let c=a.state.selection;if(g7(a,c),g1(a)){if(!b&&a.input.mouseDown&&a.input.mouseDown.allowDefault&&gj){let b=a.domSelectionRange(),c=a.domObserver.currentSelection;if(b.anchorNode&&c.anchorNode&&f2(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,fZ(c)+1):b.collapse(c,0),!d&&!a.state.selection.visible&&gf&&gg<=11&&(c.disabled=!0,c.disabled=!1)}(a);else{var d;let e,f,g,h,{anchor:i,head:j}=c,k,l;g3&&!(c instanceof fH)&&(c.$from.parent.inlineContent||(k=g4(a,c.from)),c.empty||c.$from.parent.inlineContent||(l=g4(a,c.to))),a.docView.setSelection(i,j,a,b),g3&&(k&&g6(k),l&&g6(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(()=>{(!g1(d)||d.state.selection.visible)&&d.dom.classList.remove("ProseMirror-hideselection")},20))})))}a.domObserver.setCurSelection(),a.domObserver.connectSelection()}}let g3=gl||gj&&gk<63;function g4(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(gl&&e&&"false"==e.contentEditable)return g5(e);if((!e||"false"==e.contentEditable)&&(!f||"false"==f.contentEditable)){if(e)return g5(e);else if(f)return g5(f)}}function g5(a){return a.contentEditable="true",gl&&a.draggable&&(a.draggable=!1,a.wasDraggable=!0),a}function g6(a){a.contentEditable="false",a.wasDraggable&&(a.draggable=!0,a.wasDraggable=null)}function g7(a,b){if(b instanceof fJ){let c=a.docView.descAt(b.from);c!=a.lastSelectedViewDesc&&(g8(a),c&&c.selectNode(),a.lastSelectedViewDesc=c)}else g8(a)}function g8(a){a.lastSelectedViewDesc&&(a.lastSelectedViewDesc.parent&&a.lastSelectedViewDesc.deselectNode(),a.lastSelectedViewDesc=void 0)}function g9(a,b,c,d){return a.someProp("createSelectionBetween",d=>d(a,b,c))||fH.between(b,c,d)}function ha(a){return(!a.editable||!!a.hasFocus())&&hb(a)}function hb(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 hc(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&&fD.findFrom(f,b)}function hd(a,b){return a.dispatch(a.state.tr.setSelection(b).scrollIntoView()),!0}function he(a,b,c){let d=a.state.selection;if(d instanceof fH){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 hd(a,new fH(d.$anchor,f))}else if(!d.empty)return!1;else if(a.endOfTextblock(b>0?"forward":"backward")){let c=hc(a.state,b);return!!c&&c instanceof fJ&&hd(a,c)}else if(!(gn&&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)&&(fJ.isSelectable(e)?hd(a,new fJ(b<0?a.state.doc.resolve(c.pos-e.nodeSize):c)):!!gq&&hd(a,new fH(a.state.doc.resolve(b<0?g:g+e.nodeSize))))}}else{if(d instanceof fJ&&d.node.isInline)return hd(a,new fH(b>0?d.$to:d.$from));let c=hc(a.state,b);return!!c&&hd(a,c)}}function hf(a){return 3==a.nodeType?a.nodeValue.length:a.childNodes.length}function hg(a,b){let c=a.pmViewDesc;return c&&0==c.size&&(b<0||a.nextSibling||"BR"!=a.nodeName)}function hh(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(gh&&1==c.nodeType&&d<hf(c)&&hg(c.childNodes[d],-1)&&(g=!0);;)if(d>0)if(1!=c.nodeType)break;else{let a=c.childNodes[d-1];if(hg(a,-1))e=c,f=--d;else if(3==a.nodeType)d=(c=a).nodeValue.length;else break}else if(hi(c))break;else{let b=c.previousSibling;for(;b&&hg(b,-1);)e=c.parentNode,f=fZ(b),b=b.previousSibling;if(b)d=hf(c=b);else{if((c=c.parentNode)==a.dom)break;d=0}}g?hj(a,c,d):e&&hj(a,e,f)}(a):function(a){let b,c,d=a.domSelectionRange(),e=d.focusNode,f=d.focusOffset;if(!e)return;let g=hf(e);for(;;)if(f<g){if(1!=e.nodeType)break;if(hg(e.childNodes[f],1))b=e,c=++f;else break}else if(hi(e))break;else{let d=e.nextSibling;for(;d&&hg(d,1);)b=d.parentNode,c=fZ(d)+1,d=d.nextSibling;if(d)f=0,g=hf(e=d);else{if((e=e.parentNode)==a.dom)break;f=g=0}}b&&hj(a,b,c)}(a)}function hi(a){let b=a.pmViewDesc;return b&&b.node&&b.node.isBlock}function hj(a,b,c){if(3!=b.nodeType){let a,d;(d=function(a,b){for(;a&&b==a.childNodes.length&&!f6(a);)b=fZ(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&&!f6(a);)b=fZ(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(f7(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&&g2(a)},50)}function hk(a,b){let c=a.state.doc.resolve(b);if(!(gj||go)&&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 hl(a,b,c){let d=a.state.selection;if(d instanceof fH&&!d.empty||c.indexOf("s")>-1||gn&&c.indexOf("m")>-1)return!1;let{$from:e,$to:f}=d;if(!e.parent.inlineContent||a.endOfTextblock(b<0?"up":"down")){let c=hc(a.state,b);if(c&&c instanceof fJ)return hd(a,c)}if(!e.parent.inlineContent){let c=b<0?e:f,g=d instanceof fL?fD.near(c,b):fD.findFrom(c,b);return!!g&&hd(a,g)}return!1}function hm(a,b){if(!(a.state.selection instanceof fH))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 hn(a,b,c){a.domObserver.stop(),b.contentEditable=c,a.domObserver.start()}function ho(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")||eY.fromSchema(a.state.schema),h=hw(),i=h.createElement("div");i.appendChild(g.serializeFragment(d,{document:h}));let j=i.firstChild,k,l=0;for(;j&&1==j.nodeType&&(k=hu[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 hp(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 el(ef.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=eY.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=hw().createElement("div"),f=/<([a-z][^>\s]+)/i.exec(a),g;if((g=f&&hu[f[1].toLowerCase()])&&(a=g.map(a=>"<"+a+">").join("")+a+g.map(a=>"</"+a+">").reverse().join("")),e.innerHTML=(b=a,(c=window.trustedTypes)?(hx||(hx=c.defaultPolicy||c.createPolicy("ProseMirrorClipboard",{createHTML:a=>a})),hx.createHTML(b)):b),g)for(let a=0;a<g.length;a++)e=e.querySelector(g[a])||e;return e}(c),gq&&function(a){let b=a.querySelectorAll(gj?"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&&" "==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")||eP.fromSchema(a.state.schema)).parseSlice(f,{preserveWhitespace:!!(i||k),context:e,ruleFromNode:a=>"BR"!=a.nodeName||a.nextSibling||!a.parentNode||hq.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=ef.from(b.create(d[a+1],e)),f++,g++}return new el(e,f,g)}(ht(g,+k[1],+k[2]),k[4]);else if((g=el.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(ef.from(hr(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(ef.empty,!0);return b.copy(d.append(e))}(f[f.length-1],e.length));let c=hr(a,b);f.push(c),d=d.matchType(c.type),e=b}}),f)return ef.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=ht(g,a,b)}return a.someProp("transformPasted",b=>{g=b(g,a,i)}),g}let hq=/^(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 hr(a,b,c=0){for(let d=b.length-1;d>=c;d--)a=b[d].create(null,ef.from(a));return a}function hs(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=hs(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(ef.empty,!0))),a.replaceChild(b<0?0:a.childCount-1,g.copy(h))}function ht(a,b,c){return b<a.openStart&&(a=new el(hs(a.content,-1,b,a.openStart,0,a.openEnd),b,a.openEnd)),c<a.openEnd&&(a=new el(hs(a.content,1,c,a.openEnd,0,0),a.openStart,c)),a}let hu={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},hv=null;function hw(){return hv||(hv=document.implementation.createHTMLDocument("title"))}let hx=null,hy={},hz={},hA={touchstart:!0,touchmove:!0};class hB{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 hC(a,b){a.input.lastSelectionOrigin=b,a.input.lastSelectionTime=Date.now()}function hD(a){a.someProp("handleDOMEvents",b=>{for(let c in b)a.input.eventHandlers[c]||a.dom.addEventListener(c,a.input.eventHandlers[c]=b=>hE(a,b))})}function hE(a,b){return a.someProp("handleDOMEvents",c=>{let d=c[b.type];return!!d&&(d(a,b)||b.defaultPrevented)})}function hF(a){return{left:a.clientX,top:a.clientY}}function hG(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 hH(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)}hz.keydown=(a,b)=>{if((a.input.shiftKey=16==b.keyCode||b.shiftKey,!hK(a,b))&&(a.input.lastKeyCode=b.keyCode,a.input.lastKeyCodeTime=Date.now(),!gp||!gj||13!=b.keyCode))if(229!=b.keyCode&&a.domObserver.forceFlush(),!gm||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||gn&&72==d&&"c"==e)return hm(a,-1)||hh(a,-1);if(46==d&&!b.shiftKey||gn&&68==d&&"c"==e)return hm(a,1)||hh(a,1);if(13==d||27==d)return!0;if(37==d||gn&&66==d&&"c"==e){let b=37==d?"ltr"==hk(a,a.state.selection.from)?-1:1:-1;return he(a,b,e)||hh(a,b)}if(39==d||gn&&70==d&&"c"==e){let b=39==d?"ltr"==hk(a,a.state.selection.from)?1:-1:1;return he(a,b,e)||hh(a,b)}else if(38==d||gn&&80==d&&"c"==e)return hl(a,-1,e)||hh(a,-1);else if(40==d||gn&&78==d&&"c"==e)return function(a){if(!gl||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;hn(a,c,"true"),setTimeout(()=>hn(a,c,"false"),20)}return!1}(a)||hl(a,1,e)||hh(a,1);else if(e==(gn?"m":"c")&&(66==d||73==d||89==d||90==d))return!0;return!1}(a,b)?b.preventDefault():hC(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,f8(13,"Enter"))),a.input.lastIOSEnter=0)},200)}},hz.keyup=(a,b)=>{16==b.keyCode&&(a.input.shiftKey=!1)},hz.keypress=(a,b)=>{if(hK(a,b)||!b.charCode||b.ctrlKey&&!b.altKey||gn&&b.metaKey)return;if(a.someProp("handleKeyPress",c=>c(a,b)))return void b.preventDefault();let c=a.state.selection;if(!(c instanceof fH)||!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 hI=gn?"metaKey":"ctrlKey";hy.mousedown=(a,b)=>{var c;let d,e;a.input.shiftKey=b.shiftKey;let f=hO(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[hI]&&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(hF(b));i&&("singleClick"==h?(a.input.mouseDown&&a.input.mouseDown.done(),a.input.mouseDown=new hJ(a,i,b,!!f)):("doubleClick"==h?function(a,b,c,d){return hG(a,"handleDoubleClickOn",b,c,d)||a.someProp("handleDoubleClick",c=>c(a,b,d))}:function(a,b,c,d){return hG(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&&(hH(a,fH.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)hH(a,fH.create(d,f+1,f+1+c.content.size),"pointer");else{if(!fJ.isSelectable(c))continue;hH(a,fJ.create(d,f),"pointer")}return!0}}(a,c,d)})(a,i.pos,i.inside,b)?b.preventDefault():hC(a,"pointer"))};class hJ{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[hI],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 fJ&&i.from<=f&&i.to>f)&&(this.mightDrag={node:e,pos:f,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&gh&&!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)),hC(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(()=>g2(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(hF(a))),this.updateAllowDefault(a),this.allowDefault||!b)hC(this.view,"pointer");else{var c,d,e,f;(c=this.view,d=b.pos,e=b.inside,f=this.selectNode,hG(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 fJ&&(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(fJ.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&&(hH(a,fJ.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&&fJ.isSelectable(d))&&(hH(a,new fJ(c),"pointer"),!0)}(c,e)))?a.preventDefault():0==a.button&&(this.flushed||gl&&this.mightDrag&&!this.mightDrag.node.isAtom||gj&&!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)))?(hH(this.view,fD.near(this.view.state.doc.resolve(b.pos)),"pointer"),a.preventDefault()):hC(this.view,"pointer")}}move(a){this.updateAllowDefault(a),hC(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 hK(a,b){return!!a.composing||!!(gl&&500>Math.abs(b.timeStamp-a.input.compositionEndedAt))&&(a.input.compositionEndedAt=-2e8,!0)}hy.touchstart=a=>{a.input.lastTouch=Date.now(),hO(a),hC(a,"pointer")},hy.touchmove=a=>{a.input.lastTouch=Date.now(),hC(a,"pointer")},hy.contextmenu=a=>hO(a);let hL=gp?5e3:-1;function hM(a,b){clearTimeout(a.input.composingTimeout),b>-1&&(a.input.composingTimeout=setTimeout(()=>hO(a),b))}function hN(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 hO(a,b=!1){if(!gp||!(a.domObserver.flushingSoon>=0)){if(a.domObserver.forceFlush(),hN(a),b||a.docView&&a.docView.dirty){let c=g0(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}}hz.compositionstart=hz.compositionupdate=a=>{if(!a.composing){a.domObserver.flush();let{state:b}=a,c=b.selection.$to;if(b.selection instanceof fH&&(b.storedMarks||!c.textOffset&&c.parentOffset&&c.nodeBefore.marks.some(a=>!1===a.type.spec.inclusive)||gj&&go&&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(),hO(a,!0),a.markCursor=null;else if(hO(a,!b.selection.empty),gh&&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}hM(a,hL)},hz.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++,hM(a,20))};let hP=gf&&gg<15||gm&&gr<604;function hQ(a,b,c,d,e){let f=hp(a,b,c,d,a.state.selection.$from);if(a.someProp("handlePaste",b=>b(a,e,f||el.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 hR(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," "):""}hy.copy=hz.cut=(a,b)=>{let c=a.state.selection,d="cut"==b.type;if(c.empty)return;let e=hP?null:b.clipboardData,{dom:f,text:g}=ho(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"))},hz.paste=(a,b)=>{if(a.composing&&!gp)return;let c=hP?null:b.clipboardData,d=a.input.shiftKey&&45!=a.input.lastKeyCode;c&&hQ(a,hR(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?hQ(a,d.value,null,e,b):hQ(a,d.textContent,d.innerHTML,e,b)},50)}(a,b)};class hS{constructor(a,b,c){this.slice=a,this.move=b,this.node=c}}let hT=gn?"altKey":"ctrlKey";function hU(a,b){let c;return a.someProp("dragCopies",a=>{c=c||a(b)}),null!=c?!c:!b[hT]}for(let a in hy.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(hF(b));if(f&&f.pos>=e.from&&f.pos<=(e instanceof fJ?e.to-1:e.to));else if(d&&d.mightDrag)c=fJ.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=fJ.create(a.state.doc,d.posBefore))}let g=(c||a.state.selection).content(),{dom:h,text:i,slice:j}=ho(a,g);b.dataTransfer.files.length&&gj&&!(gk>120)||b.dataTransfer.clearData(),b.dataTransfer.setData(hP?"Text":"text/html",h.innerHTML),b.dataTransfer.effectAllowed="copyMove",hP||b.dataTransfer.setData("text/plain",i),a.dragging=new hS(j,hU(a,b),c)},hy.dragend=a=>{let b=a.dragging;window.setTimeout(()=>{a.dragging==b&&(a.dragging=null)},50)},hz.dragover=hz.dragenter=(a,b)=>b.preventDefault(),hz.drop=(a,b)=>{try{!function(a,b,c){if(!b.dataTransfer)return;let d=a.posAtCoords(hF(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=hp(a,hR(b.dataTransfer),hP?null:b.dataTransfer.getData("text/html"),!1,e);let g=!!(c&&hU(a,b));if(a.someProp("handleDrop",c=>c(a,b,f||el.empty,g)))return b.preventDefault();if(!f)return;b.preventDefault();let h=f?fp(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&&fJ.isSelectable(f.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(f.content.firstChild))i.setSelection(new fJ(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(g9(a,m,i.doc.resolve(b)))}a.focus(),a.dispatch(i.setMeta("uiEvent","drop"))}(a,b,a.dragging)}finally{a.dragging=null}},hy.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())&&g2(a)},20))},hy.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)},hy.beforeinput=(a,b)=>{if(gj&&gp&&"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,f8(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)}},hz)hy[a]=hz[a];function hV(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 hW{constructor(a,b){this.toDOM=a,this.spec=b||h_,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 hZ(e-c,e-c,this)}valid(){return!0}eq(a){return this==a||a instanceof hW&&(this.spec.key&&this.spec.key==a.spec.key||this.toDOM==a.toDOM&&hV(this.spec,a.spec))}destroy(a){this.spec.destroy&&this.spec.destroy(a)}}class hX{constructor(a,b){this.attrs=a,this.spec=b||h_}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 hZ(e,f,this)}valid(a,b){return b.from<b.to}eq(a){return this==a||a instanceof hX&&hV(this.attrs,a.attrs)&&hV(this.spec,a.spec)}static is(a){return a.type instanceof hX}destroy(){}}class hY{constructor(a,b){this.attrs=a,this.spec=b||h_}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 hZ(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 hY&&hV(this.attrs,a.attrs)&&hV(this.spec,a.spec)}destroy(){}}class hZ{constructor(a,b,c){this.from=a,this.to=b,this.type=c}copy(a,b){return new hZ(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 hZ(a,a,new hW(b,c))}static inline(a,b,c,d){return new hZ(a,b,new hX(c,d))}static node(a,b,c,d){return new hZ(a,b,new hY(c,d))}get spec(){return this.type.spec}get inline(){return this.type instanceof hX}get widget(){return this.type instanceof hW}}let h$=[],h_={};class h0{constructor(a,b){this.local=a.length?a:h$,this.children=b.length?b:h$}static create(a,b){return b.length?h6(b,a,0,h_):h1}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==h1||0==a.maps.length?this:this.mapInner(a,b,0,0,c||h_)}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!=h1?(h[b]=k,h[b+1]=l,h[b+2]=d):(h[b+1]=-2,i=!0)}else i=!0}if(i){let i=h6(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 h0(b.sort(h7),h)}(this.children,f||[],a,b,c,d,e):f?new h0(f.sort(h7),h$):h1}add(a,b){return b.length?this==h1?h0.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=h4(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,h6(h,a,g+1,h_)),e+=3}});let f=h3(e?h5(b):b,-c);for(let b=0;b<f.length;b++)f[b].type.valid(a,f[b])||f.splice(b--,1);return new h0(f.length?this.local.concat(f).sort(h7):this.local,d||this.children)}remove(a){return 0==a.length||this==h1?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!=h1?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 h0(d,c):h1}forChild(a,b){let c,d;if(this==h1)return this;if(b.isLeaf)return h0.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 hX){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 h0(d.sort(h7),h$);return c?new h2([a,c]):a}return c||h1}eq(a){if(this==a)return!0;if(!(a instanceof h0)||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 h8(this.localsInner(a))}localsInner(a){if(this==h1)return h$;if(a.inlineContent||!this.local.some(hX.is))return this.local;let b=[];for(let a=0;a<this.local.length;a++)this.local[a].type instanceof hX||b.push(this.local[a]);return b}forEachSet(a){a(this)}}h0.empty=new h0([],[]),h0.removeOverlap=h8;let h1=h0.empty;class h2{constructor(a){this.members=a}map(a,b){let c=this.members.map(c=>c.map(a,b,h_));return h2.from(c)}forChild(a,b){if(b.isLeaf)return h0.empty;let c=[];for(let d=0;d<this.members.length;d++){let e=this.members[d].forChild(a,b);e!=h1&&(e instanceof h2?c=c.concat(e.members):c.push(e))}return h2.from(c)}eq(a){if(!(a instanceof h2)||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?h8(c?b:b.sort(h7)):h$}static from(a){switch(a.length){case 0:return h1;case 1:return a[0];default:return new h2(a.every(a=>a instanceof h0)?a:a.reduce((a,b)=>a.concat(b instanceof h0?b:b.members),[]))}}forEachSet(a){for(let b=0;b<this.members.length;b++)this.members[b].forEachSet(a)}}function h3(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 hZ(e.from+b,e.to+b,e.type))}return c}function h4(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 h5(a){let b=[];for(let c=0;c<a.length;c++)null!=a[c]&&b.push(a[c]);return b}function h6(a,b,c,d){let e=[],f=!1;b.forEach((b,g)=>{let h=h4(a,b,g+c);if(h){f=!0;let a=h6(h,b,c+g+1,d);a!=h1&&e.push(g,g+b.nodeSize,a)}});let g=h3(f?h5(a):a,-c).sort(h7);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 h0(g,e):h1}function h7(a,b){return a.from-b.from||a.to-b.to}function h8(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),h9(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),h9(b,e,d.copy(f.from,d.to)));break}}return b}function h9(a,b,c){for(;b<a.length&&h7(c,a[b])>0;)b++;a.splice(b,0,c)}function ia(a){let b=[];return a.someProp("decorations",c=>{let d=c(a.state);d&&d!=h1&&b.push(d)}),a.cursorWrapper&&b.push(h0.create(a.state.doc,[a.cursorWrapper.deco])),h2.from(b)}let ib={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ic=gf&&gg<=11;class id{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 ie{constructor(a,b){this.view=a,this.handleDOMChange=b,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new id,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]);gf&&gg<=11&&b.some(a=>"childList"==a.type&&a.removedNodes.length||"characterData"==a.type&&a.oldValue.length>a.target.nodeValue.length)?this.flushSoon():gl&&a.composing&&b.some(a=>"childList"==a.type&&"TR"==a.target.nodeName)?(a.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),ic&&(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,ib)),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(ha(this.view)){if(this.suppressingSelectionUpdates)return g2(this.view);if(gf&&gg<=11&&!this.view.state.selection.empty){let a=this.view.domSelectionRange();if(a.focusNode&&f2(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=f$(c))b.add(c);for(let d=a.anchorNode;d;d=f$(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)&&ha(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;for(;b&&1==b.nodeType;){if("false"==b.contentEditable){a.parentNode.removeChild(a);break}b=b.firstChild}}}else if(gh&&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&&f7(d)&&(j=g0(b))&&j.eq(fD.near(b.state.doc.resolve(0),1))?(b.input.lastFocus=0,g2(b),this.currentSelection.set(d),b.scrollToSelection()):(f>-1||e)&&(f>-1&&(b.docView.markDirty(f,g),a=b,!ig.has(a)&&(ig.set(a,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(a.dom).whiteSpace))&&(a.requiresGeckoHackNode=gh,ih||(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."),ih=!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)||g2(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(gf&&gg<=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?fZ(d)+1:0,g=c.localPosFromDOM(a.target,f,-1),h=e&&e.parentNode==a.target?fZ(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 ig=new WeakMap,ih=!1;function ii(a,b){let c=b.startContainer,d=b.startOffset,e=b.endContainer,f=b.endOffset,g=a.domAtPos(a.state.selection.anchor);return f2(g.node,g.offset,e,f)&&([c,d,e,f]=[e,f,c,d]),{anchorNode:c,anchorOffset:d,focusNode:e,focusOffset:f}}function ij(a){let b=a.pmViewDesc;if(b)return b.parseRule();if("BR"==a.nodeName&&a.parentNode){if(gl&&/^(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||gl&&/^(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 ik=/^(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 il(a,b,c){return Math.max(c.anchor,c.head)>b.content.size?null:g9(a,b.resolve(c.anchor),b.resolve(c.head))}function im(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 io(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 ip{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 hB,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=b,this.state=b.state,this.directPlugins=b.plugins||[],this.directPlugins.forEach(iu),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=is(this),ir(this),this.nodeViews=it(this),this.docView=gO(this.state.doc,iq(this),ia(this),this.dom,this),this.domObserver=new ie(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=g0(a,b);if(c&&!a.state.selection.eq(c)){if(gj&&gp&&13===a.input.lastKeyCode&&Date.now()-100<a.input.lastKeyCodeTime&&a.someProp("handleKeyDown",b=>b(a,f8(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}],f7(j)||d.push({node:j.focusNode,offset:j.focusOffset})),gj&&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")||eP.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:ij,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&&io(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&&io(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++,(gm&&a.input.lastIOSEnter>Date.now()-225||gp)&&e.some(a=>1==a.nodeType&&!ik.test(a.nodeName))&&(!p||p.endA>=p.endB)&&a.someProp("handleKeyDown",b=>b(a,f8(13,"Enter")))){a.input.lastIOSEnter=0;return}if(!p)if(d&&l instanceof fH&&!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=il(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 fH&&(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)),gf&&gg<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>m.from&&"  "==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((gm&&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,f8(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||im(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(im(f,!0,!0));return!(!g.parent.isTextblock||g.pos>c||im(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,f8(8,"Backspace")))){gp&&gj&&a.domObserver.suppressSelectionUpdates();return}gj&&p.endB==p.start&&(a.input.lastChromeDelete=Date.now()),gp&&!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,f8(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=il(a,c.doc,m.sel);b&&!(gj&&a.composing&&b.empty&&(p.start!=p.endB||a.input.lastChromeDelete<Date.now()-100)&&(b.head==u||b.head==c.mapping.map(v)-1)||gf&&b.empty&&b.head==u)&&c.setSelection(b)}return i&&c.setMeta("composition",i),c.scrollIntoView()};if(t)if(q.pos==r.pos){gf&&gg<=11&&0==q.parentOffset&&(a.domObserver.suppressSelectionUpdates(),setTimeout(()=>g2(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(ef.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 hy){let c=hy[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)||hE(a,b)||!a.editable&&b.type in hz||c(a,b)},hA[b]?{passive:!0}:void 0)}gl&&a.dom.addEventListener("input",()=>null),hD(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&&hD(this);let b=this._props;this._props=a,a.plugins&&(a.plugins.forEach(iu),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&&(hN(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=it(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)&&hD(this),this.editable=is(this),ir(this);let j=ia(this),k=iq(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:gu(a.dom)}}(this);if(h){let b,c,h;this.domObserver.stop();let i=m&&(gf||gj)&&!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=gj?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=f5(a=a.childNodes[b-1])}else{if(!a.parentNode||f6(a))return null;b=fZ(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||f6(a))return null;b=fZ(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=gO(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(),f2(b.node,b.offset,c.anchorNode,c.anchorOffset)))?g2(this,i):(g7(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;gv(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 fJ){let b=this.docView.domAfterPos(this.state.selection.from);1==b.nodeType&&gt(this,b.getBoundingClientRect(),a)}else gt(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(c.from<this.state.doc.content.size&&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&&a<this.state.doc.content.size&&this.state.doc.nodeAt(a))==c.node&&(d=a)}this.dragging=new hS(a.slice,a.move,d<0?void 0:fJ.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(gf){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(gw)return a.focus(gw);let b=gu(a);a.focus(null==gw?{get preventScroll(){return gw={preventScroll:!0},!0}}:void 0),gw||(gw=!1,gv(b,0))}(this.dom),g2(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(f5(d.offsetNode),d.offset)}}catch(a){}if(a.caretRangeFromPoint){let d=a.caretRangeFromPoint(b,c);if(d)return{node:d.startContainer,offset:Math.min(f5(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(!gx(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(gx(c,f))return a(d,c,f)}}if((g=(g+1)%e)==f)break}return b}(a.dom,b,c)))return null}if(gl)for(let a=j;g&&a;a=f$(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(gh&&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++}gq&&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=f0(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=gz(d,1);if(c.top!=c.bottom&&gx(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 gB(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 gG==b&&gH==c?gI:(gG=b,gH=c,gI="up"==c||"down"==c?(d=b.selection,e="up"==c?d.$from:d.$to,gE(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=gB(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=f0(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?gF.test(d.parent.textContent)&&g.modify?gE(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 hQ(this,"",a,!1,b||new ClipboardEvent("paste"))}pasteText(a,b){return hQ(this,a,null,!0,b||new ClipboardEvent("paste"))}serializeForClipboard(a){return ho(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,[],ia(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,f1()}}get isDestroyed(){return null==this.docView}dispatchEvent(a){!hE(this,a)&&hy[a.type]&&(this.editable||!(a.type in hz))&&hy[a.type](this,a)}domSelectionRange(){let a=this.domSelection();return a?gl&&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 ii(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?ii(a,c):null}(this,a)||a:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function iq(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"),[hZ.node(0,a.state.doc.content.size,b)]}function ir(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:hZ.widget(a.state.selection.from,b,{raw:!0,marks:a.markCursor})}}else a.cursorWrapper=null}function is(a){return!a.someProp("editable",b=>!1===b(a.state))}function it(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 iu(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")}ip.prototype.dispatch=function(a){let b=this._props.dispatchTransaction;b?b.call(this,a):this.updateState(this.state.apply(a))};for(var iv={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:"'"},iw={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ix="u">typeof navigator&&/Mac/.test(navigator.platform),iy="u">typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),iz=0;iz<10;iz++)iv[48+iz]=iv[96+iz]=String(iz);for(var iz=1;iz<=24;iz++)iv[iz+111]="F"+iz;for(var iz=65;iz<=90;iz++)iv[iz]=String.fromCharCode(iz+32),iw[iz]=String.fromCharCode(iz);for(var iA in iv)iw.hasOwnProperty(iA)||(iw[iA]=iv[iA]);let iB="u">typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),iC="u">typeof navigator&&/Win/.test(navigator.platform);function iD(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 iE(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))iB?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=!(ix&&c.metaKey&&c.shiftKey&&!c.ctrlKey&&!c.altKey||iy&&c.shiftKey&&c.key&&1==c.key.length||"Unidentified"==c.key)&&c.key||(c.shiftKey?iw:iv)[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[iD(e,c)];if(g&&g(a.state,a.dispatch,a))return!0;if(1==e.length&&" "!=e){if(c.shiftKey){let d=b[iD(e,c,!1)];if(d&&d(a.state,a.dispatch,a))return!0}if((c.altKey||c.metaKey||c.ctrlKey)&&!(iC&&c.ctrlKey&&c.altKey)&&(f=iv[c.keyCode])&&f!=e){let d=b[iD(f,c)];if(d&&d(a.state,a.dispatch,a))return!0}}return!1}}if("u">typeof WeakMap){let a=new WeakMap;b=b=>a.get(b),c=(b,c)=>(a.set(b,c),c)}else{let a=[],d=0;b=b=>{for(let c=0;c<a.length;c+=2)if(a[c]==b)return a[c+1]},c=(b,c)=>(10==d&&(d=0),a[d++]=b,a[d++]=c)}var iF=class{constructor(a,b,c,d){this.width=a,this.height=b,this.map=c,this.problems=d}findCell(a){for(let b=0;b<this.map.length;b++){let c=this.map[b];if(c!=a)continue;let d=b%this.width,e=b/this.width|0,f=d+1,g=e+1;for(let a=1;f<this.width&&this.map[b+a]==c;a++)f++;for(let a=1;g<this.height&&this.map[b+this.width*a]==c;a++)g++;return{left:d,top:e,right:f,bottom:g}}throw RangeError(`No cell with offset ${a} found`)}colCount(a){for(let b=0;b<this.map.length;b++)if(this.map[b]==a)return b%this.width;throw RangeError(`No cell with offset ${a} found`)}nextCell(a,b,c){let{left:d,right:e,top:f,bottom:g}=this.findCell(a);return"horiz"==b?(c<0?0==d:e==this.width)?null:this.map[f*this.width+(c<0?d-1:e)]:(c<0?0==f:g==this.height)?null:this.map[d+this.width*(c<0?f-1:g)]}rectBetween(a,b){let{left:c,right:d,top:e,bottom:f}=this.findCell(a),{left:g,right:h,top:i,bottom:j}=this.findCell(b);return{left:Math.min(c,g),top:Math.min(e,i),right:Math.max(d,h),bottom:Math.max(f,j)}}cellsInRect(a){let b=[],c={};for(let d=a.top;d<a.bottom;d++)for(let e=a.left;e<a.right;e++){let f=d*this.width+e,g=this.map[f];!c[g]&&(c[g]=!0,e==a.left&&e&&this.map[f-1]==g||d==a.top&&d&&this.map[f-this.width]==g||b.push(g))}return b}positionAt(a,b,c){for(let d=0,e=0;;d++){let f=e+c.child(d).nodeSize;if(d==a){let c=b+a*this.width,d=(a+1)*this.width;for(;c<d&&this.map[c]<e;)c++;return c==d?f-1:this.map[c]}e=f}}static get(a){return b(a)||c(a,function(a){if("table"!=a.type.spec.tableRole)throw RangeError("Not a table node: "+a.type.name);let b=function(a){let b=-1,c=!1;for(let d=0;d<a.childCount;d++){let e=a.child(d),f=0;if(c)for(let b=0;b<d;b++){let c=a.child(b);for(let a=0;a<c.childCount;a++){let e=c.child(a);b+e.attrs.rowspan>d&&(f+=e.attrs.colspan)}}for(let a=0;a<e.childCount;a++){let b=e.child(a);f+=b.attrs.colspan,b.attrs.rowspan>1&&(c=!0)}-1==b?b=f:b!=f&&(b=Math.max(b,f))}return b}(a),c=a.childCount,d=[],e=0,f=null,g=[];for(let a=0,e=b*c;a<e;a++)d[a]=0;for(let h=0,i=0;h<c;h++){let j=a.child(h);i++;for(let a=0;;a++){for(;e<d.length&&0!=d[e];)e++;if(a==j.childCount)break;let k=j.child(a),{colspan:l,rowspan:m,colwidth:n}=k.attrs;for(let a=0;a<m;a++){if(a+h>=c){(f||(f=[])).push({type:"overlong_rowspan",pos:i,n:m-a});break}let j=e+a*b;for(let a=0;a<l;a++){0==d[j+a]?d[j+a]=i:(f||(f=[])).push({type:"collision",row:h,pos:i,n:l-a});let c=n&&n[a];if(c){let d=(j+a)%b*2,e=g[d];null==e||e!=c&&1==g[d+1]?(g[d]=c,g[d+1]=1):e==c&&g[d+1]++}}}e+=l,i+=k.nodeSize}let k=(h+1)*b,l=0;for(;e<k;)0==d[e++]&&l++;l&&(f||(f=[])).push({type:"missing",row:h,n:l}),i++}(0===b||0===c)&&(f||(f=[])).push({type:"zero_sized"});let h=new iF(b,c,d,f),i=!1;for(let a=0;!i&&a<g.length;a+=2)null!=g[a]&&g[a+1]<c&&(i=!0);return i&&function(a,b,c){a.problems||(a.problems=[]);let d={};for(let e=0;e<a.map.length;e++){let f=a.map[e];if(d[f])continue;d[f]=!0;let g=c.nodeAt(f);if(!g)throw RangeError(`No cell with offset ${f} found`);let h=null,i=g.attrs;for(let c=0;c<i.colspan;c++){let d=b[(e+c)%a.width*2];null==d||i.colwidth&&i.colwidth[c]==d||((h||(h=function(a){if(a.colwidth)return a.colwidth.slice();let b=[];for(let c=0;c<a.colspan;c++)b.push(0);return b}(i)))[c]=d)}h&&a.problems.unshift({type:"colwidth mismatch",pos:f,colwidth:h})}}(h,g,a),h}(a))}};function iG(a){let b=a.cached.tableNodeTypes;if(!b)for(let c in b=a.cached.tableNodeTypes={},a.nodes){let d=a.nodes[c],e=d.spec.tableRole;e&&(b[e]=d)}return b}let iH=new fY("selectingCells");function iI(a){for(let b=a.depth-1;b>0;b--)if("row"==a.node(b).type.spec.tableRole)return a.node(0).resolve(a.before(b+1));return null}function iJ(a){let b=a.selection.$head;for(let a=b.depth;a>0;a--)if("row"==b.node(a).type.spec.tableRole)return!0;return!1}function iK(a){let b=a.selection;if("$anchorCell"in b&&b.$anchorCell)return b.$anchorCell.pos>b.$headCell.pos?b.$anchorCell:b.$headCell;if("node"in b&&b.node&&"cell"==b.node.type.spec.tableRole)return b.$anchor;let c=iI(b.$head)||function(a){for(let b=a.nodeAfter,c=a.pos;b;b=b.firstChild,c++){let d=b.type.spec.tableRole;if("cell"==d||"header_cell"==d)return a.doc.resolve(c)}for(let b=a.nodeBefore,c=a.pos;b;b=b.lastChild,c--){let d=b.type.spec.tableRole;if("cell"==d||"header_cell"==d)return a.doc.resolve(c-b.nodeSize)}}(b.$head);if(c)return c;throw RangeError(`No cell found around position ${b.head}`)}function iL(a){return"row"==a.parent.type.spec.tableRole&&!!a.nodeAfter}function iM(a,b){return a.depth==b.depth&&a.pos>=b.start(-1)&&a.pos<=b.end(-1)}function iN(a,b,c){let d=a.node(-1),e=iF.get(d),f=a.start(-1),g=e.nextCell(a.pos-f,b,c);return null==g?null:a.node(0).resolve(f+g)}function iO(a,b,c=1){let d={...a,colspan:a.colspan-c};return d.colwidth&&(d.colwidth=d.colwidth.slice(),d.colwidth.splice(b,c),d.colwidth.some(a=>a>0)||(d.colwidth=null)),d}function iP(a,b,c=1){let d={...a,colspan:a.colspan+c};if(d.colwidth){d.colwidth=d.colwidth.slice();for(let a=0;a<c;a++)d.colwidth.splice(b,0,0)}return d}var iQ=class a extends fD{constructor(a,b=a){const c=a.node(-1),d=iF.get(c),e=a.start(-1),f=d.rectBetween(a.pos-e,b.pos-e),g=a.node(0),h=d.cellsInRect(f).filter(a=>a!=b.pos-e);h.unshift(b.pos-e);const i=h.map(a=>{let b=c.nodeAt(a);if(!b)throw RangeError(`No cell with offset ${a} found`);let d=e+a+1;return new fE(g.resolve(d),g.resolve(d+b.content.size))});super(i[0].$from,i[0].$to,i),this.$anchorCell=a,this.$headCell=b}map(b,c){let d=b.resolve(c.map(this.$anchorCell.pos)),e=b.resolve(c.map(this.$headCell.pos));if(iL(d)&&iL(e)&&iM(d,e)){let b=this.$anchorCell.node(-1)!=d.node(-1);return b&&this.isRowSelection()?a.rowSelection(d,e):b&&this.isColSelection()?a.colSelection(d,e):new a(d,e)}return fH.between(d,e)}content(){let a=this.$anchorCell.node(-1),b=iF.get(a),c=this.$anchorCell.start(-1),d=b.rectBetween(this.$anchorCell.pos-c,this.$headCell.pos-c),e={},f=[];for(let c=d.top;c<d.bottom;c++){let g=[];for(let f=c*b.width+d.left,h=d.left;h<d.right;h++,f++){let c=b.map[f];if(e[c])continue;e[c]=!0;let h=b.findCell(c),i=a.nodeAt(c);if(!i)throw RangeError(`No cell with offset ${c} found`);let j=d.left-h.left,k=h.right-d.right;if(j>0||k>0){let a=i.attrs;if(j>0&&(a=iO(a,0,j)),k>0&&(a=iO(a,a.colspan-k,k)),h.left<d.left){if(!(i=i.type.createAndFill(a)))throw RangeError(`Could not create cell with attrs ${JSON.stringify(a)}`)}else i=i.type.create(a,i.content)}if(h.top<d.top||h.bottom>d.bottom){let a={...i.attrs,rowspan:Math.min(h.bottom,d.bottom)-Math.max(h.top,d.top)};i=h.top<d.top?i.type.createAndFill(a):i.type.create(a,i.content)}g.push(i)}f.push(a.child(c).copy(ef.from(g)))}let g=this.isColSelection()&&this.isRowSelection()?a:f;return new el(ef.from(g),1,1)}replace(a,b=el.empty){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);a.replace(h.map(f.pos),h.map(g.pos),e?el.empty:b)}let e=fD.findFrom(a.doc.resolve(a.mapping.slice(c).map(this.to)),-1);e&&a.setSelection(e)}replaceWith(a,b){this.replace(a,new el(ef.from(b),0,0))}forEachCell(a){let b=this.$anchorCell.node(-1),c=iF.get(b),d=this.$anchorCell.start(-1),e=c.cellsInRect(c.rectBetween(this.$anchorCell.pos-d,this.$headCell.pos-d));for(let c=0;c<e.length;c++)a(b.nodeAt(e[c]),d+e[c])}isColSelection(){let a=this.$anchorCell.index(-1),b=this.$headCell.index(-1);return!(Math.min(a,b)>0)&&Math.max(a+this.$anchorCell.nodeAfter.attrs.rowspan,b+this.$headCell.nodeAfter.attrs.rowspan)==this.$headCell.node(-1).childCount}static colSelection(b,c=b){let d=b.node(-1),e=iF.get(d),f=b.start(-1),g=e.findCell(b.pos-f),h=e.findCell(c.pos-f),i=b.node(0);return g.top<=h.top?(g.top>0&&(b=i.resolve(f+e.map[g.left])),h.bottom<e.height&&(c=i.resolve(f+e.map[e.width*(e.height-1)+h.right-1]))):(h.top>0&&(c=i.resolve(f+e.map[h.left])),g.bottom<e.height&&(b=i.resolve(f+e.map[e.width*(e.height-1)+g.right-1]))),new a(b,c)}isRowSelection(){let a=this.$anchorCell.node(-1),b=iF.get(a),c=this.$anchorCell.start(-1),d=b.colCount(this.$anchorCell.pos-c),e=b.colCount(this.$headCell.pos-c);return!(Math.min(d,e)>0)&&Math.max(d+this.$anchorCell.nodeAfter.attrs.colspan,e+this.$headCell.nodeAfter.attrs.colspan)==b.width}eq(b){return b instanceof a&&b.$anchorCell.pos==this.$anchorCell.pos&&b.$headCell.pos==this.$headCell.pos}static rowSelection(b,c=b){let d=b.node(-1),e=iF.get(d),f=b.start(-1),g=e.findCell(b.pos-f),h=e.findCell(c.pos-f),i=b.node(0);return g.left<=h.left?(g.left>0&&(b=i.resolve(f+e.map[g.top*e.width])),h.right<e.width&&(c=i.resolve(f+e.map[e.width*(h.top+1)-1]))):(h.left>0&&(c=i.resolve(f+e.map[h.top*e.width])),g.right<e.width&&(b=i.resolve(f+e.map[e.width*(g.top+1)-1]))),new a(b,c)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(b,c){return new a(b.resolve(c.anchor),b.resolve(c.head))}static create(b,c,d=c){return new a(b.resolve(c),b.resolve(d))}getBookmark(){return new iR(this.$anchorCell.pos,this.$headCell.pos)}};iQ.prototype.visible=!1,fD.jsonID("cell",iQ);var iR=class a{constructor(a,b){this.anchor=a,this.head=b}map(b){return new a(b.map(this.anchor),b.map(this.head))}resolve(a){let b=a.resolve(this.anchor),c=a.resolve(this.head);return"row"==b.parent.type.spec.tableRole&&"row"==c.parent.type.spec.tableRole&&b.index()<b.parent.childCount&&c.index()<c.parent.childCount&&iM(b,c)?new iQ(b,c):fD.near(c,1)}};function iS(a){if(!(a.selection instanceof iQ))return null;let b=[];return a.selection.forEachCell((a,c)=>{b.push(hZ.node(c,c+a.nodeSize,{class:"selectedCell"}))}),h0.create(a.doc,b)}let iT=new fY("fix-tables");function iU(a,b){let c,d=(b,d)=>{"table"==b.type.spec.tableRole&&(c=function(a,b,c,d){let e,f,g=iF.get(b);if(!g.problems)return d;d||(d=a.tr);let h=[];for(let a=0;a<g.height;a++)h.push(0);for(let a=0;a<g.problems.length;a++){let e=g.problems[a];if("collision"==e.type){let a=b.nodeAt(e.pos);if(!a)continue;let f=a.attrs;for(let a=0;a<f.rowspan;a++)h[e.row+a]+=e.n;d.setNodeMarkup(d.mapping.map(c+1+e.pos),null,iO(f,f.colspan-e.n,e.n))}else if("missing"==e.type)h[e.row]+=e.n;else if("overlong_rowspan"==e.type){let a=b.nodeAt(e.pos);if(!a)continue;d.setNodeMarkup(d.mapping.map(c+1+e.pos),null,{...a.attrs,rowspan:a.attrs.rowspan-e.n})}else if("colwidth mismatch"==e.type){let a=b.nodeAt(e.pos);if(!a)continue;d.setNodeMarkup(d.mapping.map(c+1+e.pos),null,{...a.attrs,colwidth:e.colwidth})}else if("zero_sized"==e.type){let a=d.mapping.map(c);d.delete(a,a+b.nodeSize)}}for(let a=0;a<h.length;a++)h[a]&&(null==e&&(e=a),f=a);for(let i=0,j=c+1;i<g.height;i++){let c=b.child(i),g=j+c.nodeSize,k=h[i];if(k>0){let b="cell";c.firstChild&&(b=c.firstChild.type.spec.tableRole);let h=[];for(let c=0;c<k;c++){let c=iG(a.schema)[b].createAndFill();c&&h.push(c)}let l=(0==i||e==i-1)&&f==i?j+1:g-1;d.insert(d.mapping.map(l),h)}j=g}return d.setMeta(iT,{fixTables:!0})}(a,b,d,c))};return b?b.doc!=a.doc&&function a(b,c,d,e){let f=b.childCount,g=c.childCount;d:for(let h=0,i=0;h<g;h++){let g=c.child(h);for(let a=i,c=Math.min(f,h+3);a<c;a++)if(b.child(a)==g){i=a+1,d+=g.nodeSize;continue d}e(g,d),i<f&&b.child(i).sameMarkup(g)?a(b.child(i),g,d+1,e):g.nodesBetween(0,g.content.size,e,d+1),d+=g.nodeSize}}(b.doc,a.doc,0,d):a.doc.descendants(d),c}function iV(a){let b=iF.get(a),c=[],d=b.height,e=b.width;for(let f=0;f<d;f++){let d=[];for(let c=0;c<e;c++){let g=f*e+c,h=b.map[g];if(f>0){let a=g-e;if(h===b.map[a]){d.push(null);continue}}if(c>0){let a=g-1;if(h===b.map[a]){d.push(null);continue}}d.push(a.nodeAt(h))}c.push(d)}return c}function iW(a,b){let c=[],d=iF.get(a),e=d.height,f=d.width;for(let g=0;g<e;g++){let e=a.child(g),h=[];for(let c=0;c<f;c++){let e=b[g][c];if(!e)continue;let f=d.map[g*d.width+c],i=a.nodeAt(f);if(!i)continue;let j=i.type.createChecked(e.attrs,e.content,e.marks);h.push(j)}let i=e.type.createChecked(e.attrs,h,e.marks);c.push(i)}return a.type.createChecked(a.attrs,c,a.marks)}function iX(a,b,c,d){let e,f=b[0]>c[0]?-1:1,g=a.splice(b[0],b.length),h=+(g.length%2==0);return e=-1===d&&1===f?c[0]-1:1===d&&-1===f?c[c.length-1]-h+1:-1===f?c[0]:c[c.length-1]-h,a.splice(e,0,...g),a}function iY(a){var b=a;for(let a=b.depth;a>=0;a-=1){let c=b.node(a);if((a=>"table"===a.type.spec.tableRole)(c))return{node:c,pos:0===a?0:b.before(a),start:b.start(a),depth:a}}return null}function iZ(a,b){let c=iY(b.$from);if(!c)return;let d=iF.get(c.node);if(!(a<0)&&!(a>d.width-1))return d.cellsInRect({left:a,right:a+1,top:0,bottom:d.height}).map(a=>{let b=c.node.nodeAt(a),d=a+c.start;return{pos:d,start:d+1,node:b,depth:c.depth+2}})}function i$(a,b){let c=iY(b.$from);if(!c)return;let d=iF.get(c.node);if(!(a<0)&&!(a>d.height-1))return d.cellsInRect({left:0,right:d.width,top:a,bottom:a+1}).map(a=>{let b=c.node.nodeAt(a),d=a+c.start;return{pos:d,start:d+1,node:b,depth:c.depth+2}})}function i_(a,b,c=b){let d,e=b,f=c;for(let c=b;c>=0;c--){let b=iZ(c,a.selection);b&&b.forEach(a=>{let b=a.node.attrs.colspan+c-1;b>=e&&(e=c),b>f&&(f=b)})}for(let c=b;c<=f;c++){let b=iZ(c,a.selection);b&&b.forEach(a=>{let b=a.node.attrs.colspan+c-1;a.node.attrs.colspan>1&&b>f&&(f=b)})}let g=[];for(let b=e;b<=f;b++){let c=iZ(b,a.selection);c&&c.length>0&&g.push(b)}e=g[0],f=g[g.length-1];let h=iZ(e,a.selection),i=i$(0,a.selection);if(!h||!i)return;let j=a.doc.resolve(h[h.length-1].pos);for(let b=f;b>=e;b--){let c=iZ(b,a.selection);if(c&&c.length>0){for(let a=i.length-1;a>=0;a--)if(i[a].pos===c[0].pos){d=c[0];break}if(d)break}}if(d)return{$anchor:j,$head:a.doc.resolve(d.pos),indexes:g}}function i0(a,b,c=b){let d,e=b,f=c;for(let c=b;c>=0;c--){let b=i$(c,a.selection);b&&b.forEach(a=>{let b=a.node.attrs.rowspan+c-1;b>=e&&(e=c),b>f&&(f=b)})}for(let c=b;c<=f;c++){let b=i$(c,a.selection);b&&b.forEach(a=>{let b=a.node.attrs.rowspan+c-1;a.node.attrs.rowspan>1&&b>f&&(f=b)})}let g=[];for(let b=e;b<=f;b++){let c=i$(b,a.selection);c&&c.length>0&&g.push(b)}e=g[0],f=g[g.length-1];let h=i$(e,a.selection),i=iZ(0,a.selection);if(!h||!i)return;let j=a.doc.resolve(h[h.length-1].pos);for(let b=f;b>=e;b--){let c=i$(b,a.selection);if(c&&c.length>0){for(let a=i.length-1;a>=0;a--)if(i[a].pos===c[0].pos){d=c[0];break}if(d)break}}if(d)return{$anchor:j,$head:a.doc.resolve(d.pos),indexes:g}}function i1(a){return a[0].map((b,c)=>a.map(a=>a[c]))}function i2(a){let b=a.selection,c=iK(a),d=c.node(-1),e=c.start(-1),f=iF.get(d);return{...b instanceof iQ?f.rectBetween(b.$anchorCell.pos-e,b.$headCell.pos-e):f.findCell(c.pos-e),tableStart:e,map:f,table:d}}function i3(a,{map:b,tableStart:c,table:d},e){let f=e>0?-1:0;(function(a,b,c){let d=iG(b.type.schema).header_cell;for(let e=0;e<a.height;e++)if(b.nodeAt(a.map[c+e*a.width]).type!=d)return!1;return!0})(b,d,e+f)&&(f=0==e||e==b.width?null:0);for(let g=0;g<b.height;g++){let h=g*b.width+e;if(e>0&&e<b.width&&b.map[h-1]==b.map[h]){let f=b.map[h],i=d.nodeAt(f);a.setNodeMarkup(a.mapping.map(c+f),null,iP(i.attrs,e-b.colCount(f))),g+=i.attrs.rowspan-1}else{let i=null==f?iG(d.type.schema).cell:d.nodeAt(b.map[h+f]).type,j=b.positionAt(g,e,d);a.insert(a.mapping.map(c+j),i.createAndFill())}}return a}function i4(a,{map:b,tableStart:c,table:d},e){let f=c;for(let a=0;a<e;a++)f+=d.child(a).nodeSize;let g=[],h=e>0?-1:0;(function(a,b,c){var d;let e=iG(b.type.schema).header_cell;for(let f=0;f<a.width;f++)if((null==(d=b.nodeAt(a.map[f+c*a.width]))?void 0:d.type)!=e)return!1;return!0})(b,d,e+h)&&(h=0==e||e==b.height?null:0);for(let f=0,j=b.width*e;f<b.width;f++,j++)if(e>0&&e<b.height&&b.map[j]==b.map[j-b.width]){let e=b.map[j],g=d.nodeAt(e).attrs;a.setNodeMarkup(c+e,null,{...g,rowspan:g.rowspan+1}),f+=g.colspan-1}else{var i;let a=null==h?iG(d.type.schema).cell:null==(i=d.nodeAt(b.map[j+h*b.width]))?void 0:i.type,c=null==a?void 0:a.createAndFill();c&&g.push(c)}return a.insert(f,iG(d.type.schema).row.create(null,g)),a}function i5(a){let b=a.content;return 1==b.childCount&&b.child(0).isTextblock&&0==b.child(0).childCount}function i6(a,b){let c=a.selection;if(!(c instanceof iQ)||c.$anchorCell.pos==c.$headCell.pos)return!1;let d=i2(a),{map:e}=d;if(function({width:a,height:b,map:c},d){let e=d.top*a+d.left,f=e,g=(d.bottom-1)*a+d.left,h=e+(d.right-d.left-1);for(let b=d.top;b<d.bottom;b++){if(d.left>0&&c[f]==c[f-1]||d.right<a&&c[h]==c[h+1])return!0;f+=a,h+=a}for(let f=d.left;f<d.right;f++){if(d.top>0&&c[e]==c[e-a]||d.bottom<b&&c[g]==c[g+a])return!0;e++,g++}return!1}(e,d))return!1;if(b){let c,f,g=a.tr,h={},i=ef.empty;for(let a=d.top;a<d.bottom;a++)for(let b=d.left;b<d.right;b++){let j=e.map[a*e.width+b],k=d.table.nodeAt(j);if(!h[j]&&k)if(h[j]=!0,null==c)c=j,f=k;else{i5(k)||(i=i.append(k.content));let a=g.mapping.map(j+d.tableStart);g.delete(a,a+k.nodeSize)}}if(null==c||null==f)return!0;if(g.setNodeMarkup(c+d.tableStart,null,{...iP(f.attrs,f.attrs.colspan,d.right-d.left-f.attrs.colspan),rowspan:d.bottom-d.top}),i.size>0){let a=c+1+f.content.size,b=i5(f)?c+1:a;g.replaceWith(b+d.tableStart,a+d.tableStart,i)}g.setSelection(new iQ(g.doc.resolve(c+d.tableStart))),b(g)}return!0}function i7(a,b){var c;let d=iG(a.schema);return(c=({node:a})=>d[a.type.spec.tableRole],(a,b)=>{let d,e,f=a.selection;if(f instanceof iQ){if(f.$anchorCell.pos!=f.$headCell.pos)return!1;d=f.$anchorCell.nodeAfter,e=f.$anchorCell.pos}else{var g;if(!(d=function(a){for(let b=a.depth;b>0;b--){let c=a.node(b).type.spec.tableRole;if("cell"===c||"header_cell"===c)return a.node(b)}return null}(f.$from)))return!1;e=null==(g=iI(f.$from))?void 0:g.pos}if(null==d||null==e||1==d.attrs.colspan&&1==d.attrs.rowspan)return!1;if(b){let g,h=d.attrs,i=[],j=h.colwidth;h.rowspan>1&&(h={...h,rowspan:1}),h.colspan>1&&(h={...h,colspan:1});let k=i2(a),l=a.tr;for(let a=0;a<k.right-k.left;a++)i.push(j?{...h,colwidth:j&&j[a]?[j[a]]:null}:h);for(let a=k.top;a<k.bottom;a++){let b=k.map.positionAt(a,k.left,k.table);a==k.top&&(b+=d.nodeSize);for(let e=k.left,f=0;e<k.right;e++,f++)(e!=k.left||a!=k.top)&&l.insert(g=l.mapping.map(b+k.tableStart,1),c({node:d,row:a,col:e}).createAndFill(i[f]))}l.setNodeMarkup(e,c({node:d,row:k.top,col:k.left}),i[0]),f instanceof iQ&&l.setSelection(new iQ(l.doc.resolve(f.$anchorCell.pos),g?l.doc.resolve(g):void 0)),b(l)}return!0})(a,b)}function i8(a,b,c){let d=b.map.cellsInRect({left:0,top:0,right:"row"==a?b.map.width:1,bottom:"column"==a?b.map.height:1});for(let a=0;a<d.length;a++){let e=b.table.nodeAt(d[a]);if(e&&e.type!==c.header_cell)return!1}return!0}function i9(a,b){if((b=b||{useDeprecatedLogic:!1}).useDeprecatedLogic)return function(b,c){if(!iJ(b))return!1;if(c){let d=iG(b.schema),e=i2(b),f=b.tr,g=e.map.cellsInRect("column"==a?{left:e.left,top:0,right:e.right,bottom:e.map.height}:"row"==a?{left:0,top:e.top,right:e.map.width,bottom:e.bottom}:e),h=g.map(a=>e.table.nodeAt(a));for(let a=0;a<g.length;a++)h[a].type==d.header_cell&&f.setNodeMarkup(e.tableStart+g[a],d.cell,h[a].attrs);if(0===f.steps.length)for(let a=0;a<g.length;a++)f.setNodeMarkup(e.tableStart+g[a],d.header_cell,h[a].attrs);c(f)}return!0};return function(b,c){if(!iJ(b))return!1;if(c){let d=iG(b.schema),e=i2(b),f=b.tr,g=i8("row",e,d),h=i8("column",e,d),i=+("column"===a?!!g:"row"===a&&!!h),j="column"==a?{left:0,top:i,right:1,bottom:e.map.height}:"row"==a?{left:i,top:0,right:e.map.width,bottom:1}:e,k="column"==a?h?d.cell:d.header_cell:"row"==a?g?d.cell:d.header_cell:d.cell;e.map.cellsInRect(j).forEach(a=>{let b=a+e.tableStart,c=f.doc.nodeAt(b);c&&f.setNodeMarkup(b,k,c.attrs)}),c(f)}return!0}}i9("row",{useDeprecatedLogic:!0}),i9("column",{useDeprecatedLogic:!0});let ja=i9("cell",{useDeprecatedLogic:!0});function jb(a){return function(b,c){if(!iJ(b))return!1;let d=function(a,b){if(b<0){let b=a.nodeBefore;if(b)return a.pos-b.nodeSize;for(let b=a.index(-1)-1,c=a.before();b>=0;b--){let d=a.node(-1).child(b),e=d.lastChild;if(e)return c-1-e.nodeSize;c-=d.nodeSize}}else{if(a.index()<a.parent.childCount-1)return a.pos+a.nodeAfter.nodeSize;let b=a.node(-1);for(let c=a.indexAfter(-1),d=a.after();c<b.childCount;c++){let a=b.child(c);if(a.childCount)return d+1;d+=a.nodeSize}}return null}(iK(b),a);if(null==d)return!1;if(c){let a=b.doc.resolve(d);c(b.tr.setSelection(fH.between(a,a.node(0).resolve(a.pos+a.nodeAfter.nodeSize))).scrollIntoView())}return!0}}function jc(a,b){let c=a.selection;if(!(c instanceof iQ))return!1;if(b){let d=a.tr,e=iG(a.schema).cell.createAndFill().content;c.forEachCell((a,b)=>{a.content.eq(e)||d.replace(d.mapping.map(b+1),d.mapping.map(b+a.nodeSize-1),new el(e,0,0))}),d.docChanged&&b(d)}return!0}function jd(a,b){let c=a.createAndFill();return new fB(c).replace(0,c.content.size,b).doc}function je(a,b,c,d,e,f,g,h){if(0==g||g==b.height)return!1;let i=!1;for(let j=e;j<f;j++){let e=g*b.width+j,f=b.map[e];if(b.map[e-b.width]==f){i=!0;let e=c.nodeAt(f),{top:k,left:l}=b.findCell(f);a.setNodeMarkup(a.mapping.slice(h).map(f+d),null,{...e.attrs,rowspan:g-k}),a.insert(a.mapping.slice(h).map(b.positionAt(g,l,c)),e.type.createAndFill({...e.attrs,rowspan:k+e.attrs.rowspan-g})),j+=e.attrs.colspan-1}}return i}function jf(a,b,c,d,e,f,g,h){if(0==g||g==b.width)return!1;let i=!1;for(let j=e;j<f;j++){let e=j*b.width+g,f=b.map[e];if(b.map[e-1]==f){i=!0;let e=c.nodeAt(f),k=b.colCount(f),l=a.mapping.slice(h).map(f+d);a.setNodeMarkup(l,null,iO(e.attrs,g-k,e.attrs.colspan-(g-k))),a.insert(l+e.nodeSize,e.type.createAndFill(iO(e.attrs,0,g-k))),j+=e.attrs.rowspan-1}}return i}function jg(a,b,c,d,e){let f=c?a.doc.nodeAt(c-1):a.doc;if(!f)throw Error("No table found");let g=iF.get(f),{top:h,left:i}=d,j=i+e.width,k=h+e.height,l=a.tr,m=0;function n(){if(!(f=c?l.doc.nodeAt(c-1):l.doc))throw Error("No table found");g=iF.get(f),m=l.mapping.maps.length}(function(a,b,c,d,e,f){let g,h,i=iG(a.doc.type.schema);if(e>b.width)for(let f=0,j=0;f<b.height;f++){let k,l=c.child(f);j+=l.nodeSize;let m=[];k=null==l.lastChild||l.lastChild.type==i.cell?g||(g=i.cell.createAndFill()):h||(h=i.header_cell.createAndFill());for(let a=b.width;a<e;a++)m.push(k);a.insert(a.mapping.slice(0).map(j-1+d),m)}if(f>b.height){let j=[];for(let a=0,d=(b.height-1)*b.width;a<Math.max(b.width,e);a++){let e=!(a>=b.width)&&c.nodeAt(b.map[d+a]).type==i.header_cell;j.push(e?h||(h=i.header_cell.createAndFill()):g||(g=i.cell.createAndFill()))}let k=i.row.create(null,ef.from(j)),l=[];for(let a=b.height;a<f;a++)l.push(k);a.insert(a.mapping.slice(0).map(d+c.nodeSize-2),l)}return!!(g||h)})(l,g,f,c,j,k)&&n(),je(l,g,f,c,i,j,h,m)&&n(),je(l,g,f,c,i,j,k,m)&&n(),jf(l,g,f,c,h,k,i,m)&&n(),jf(l,g,f,c,h,k,j,m)&&n();for(let a=h;a<k;a++){let b=g.positionAt(a,i,f),d=g.positionAt(a,j,f);l.replace(l.mapping.slice(m).map(b+c),l.mapping.slice(m).map(d+c),new el(e.rows[a-h],0,0))}n(),l.setSelection(new iQ(l.doc.resolve(c+g.positionAt(h,i,f)),l.doc.resolve(c+g.positionAt(k-1,j-1,f)))),b(l)}let jh=iE({ArrowLeft:jj("horiz",-1),ArrowRight:jj("horiz",1),ArrowUp:jj("vert",-1),ArrowDown:jj("vert",1),"Shift-ArrowLeft":jk("horiz",-1),"Shift-ArrowRight":jk("horiz",1),"Shift-ArrowUp":jk("vert",-1),"Shift-ArrowDown":jk("vert",1),Backspace:jc,"Mod-Backspace":jc,Delete:jc,"Mod-Delete":jc});function ji(a,b,c){return!c.eq(a.selection)&&(b&&b(a.tr.setSelection(c).scrollIntoView()),!0)}function jj(a,b){return(c,d,e)=>{if(!e)return!1;let f=c.selection;if(f instanceof iQ)return ji(c,d,fD.near(f.$headCell,b));if("horiz"!=a&&!f.empty)return!1;let g=jo(e,a,b);if(null==g)return!1;if("horiz"==a)return ji(c,d,fD.near(c.doc.resolve(f.head+b),b));{let e,f=c.doc.resolve(g),h=iN(f,a,b);return e=h?fD.near(h,1):b<0?fD.near(c.doc.resolve(f.before(-1)),-1):fD.near(c.doc.resolve(f.after(-1)),1),ji(c,d,e)}}}function jk(a,b){return(c,d,e)=>{let f;if(!e)return!1;let g=c.selection;if(g instanceof iQ)f=g;else{let d=jo(e,a,b);if(null==d)return!1;f=new iQ(c.doc.resolve(d))}let h=iN(f.$headCell,a,b);return!!h&&ji(c,d,new iQ(f.$anchorCell,h))}}function jl(a,b){let c=iI(a.state.doc.resolve(b));return!!c&&(a.dispatch(a.state.tr.setSelection(new iQ(c))),!0)}function jm(a,b,c){if(!iJ(a.state))return!1;let d=function(a){if(0===a.size)return null;let{content:b,openStart:c,openEnd:d}=a;for(;1==b.childCount&&(c>0&&d>0||"table"==b.child(0).type.spec.tableRole);)c--,d--,b=b.child(0).content;let e=b.child(0),f=e.type.spec.tableRole,g=e.type.schema,h=[];if("row"==f)for(let a=0;a<b.childCount;a++){let e=b.child(a).content,f=a?0:Math.max(0,c-1),i=a<b.childCount-1?0:Math.max(0,d-1);(f||i)&&(e=jd(iG(g).row,new el(e,f,i)).content),h.push(e)}else{if("cell"!=f&&"header_cell"!=f)return null;h.push(c||d?jd(iG(g).row,new el(b,c,d)).content:b)}return function(a,b){let c=[];for(let a=0;a<b.length;a++){let d=b[a];for(let b=d.childCount-1;b>=0;b--){let{rowspan:e,colspan:f}=d.child(b).attrs;for(let b=a;b<a+e;b++)c[b]=(c[b]||0)+f}}let d=0;for(let a=0;a<c.length;a++)d=Math.max(d,c[a]);for(let e=0;e<c.length;e++)if(e>=b.length&&b.push(ef.empty),c[e]<d){let f=iG(a).cell.createAndFill(),g=[];for(let a=c[e];a<d;a++)g.push(f);b[e]=b[e].append(ef.from(g))}return{height:b.length,width:d,rows:b}}(g,h)}(c),e=a.state.selection;if(e instanceof iQ){d||(d={width:1,height:1,rows:[ef.from(jd(iG(a.state.schema).cell,c))]});let b=e.$anchorCell.node(-1),f=e.$anchorCell.start(-1),g=iF.get(b).rectBetween(e.$anchorCell.pos-f,e.$headCell.pos-f);return d=function({width:a,height:b,rows:c},d,e){if(a!=d){let b=[],e=[];for(let a=0;a<c.length;a++){let f=c[a],g=[];for(let c=b[a]||0,e=0;c<d;e++){let h=f.child(e%f.childCount);c+h.attrs.colspan>d&&(h=h.type.createChecked(iO(h.attrs,h.attrs.colspan,c+h.attrs.colspan-d),h.content)),g.push(h),c+=h.attrs.colspan;for(let c=1;c<h.attrs.rowspan;c++)b[a+c]=(b[a+c]||0)+h.attrs.colspan}e.push(ef.from(g))}c=e,a=d}if(b!=e){let a=[];for(let d=0,f=0;d<e;d++,f++){let g=[],h=c[f%b];for(let a=0;a<h.childCount;a++){let b=h.child(a);d+b.attrs.rowspan>e&&(b=b.type.create({...b.attrs,rowspan:Math.max(1,e-b.attrs.rowspan)},b.content)),g.push(b)}a.push(ef.from(g))}c=a,b=e}return{width:a,height:b,rows:c}}(d,g.right-g.left,g.bottom-g.top),jg(a.state,a.dispatch,f,g,d),!0}if(!d)return!1;{let b=iK(a.state),c=b.start(-1);return jg(a.state,a.dispatch,c,iF.get(b.node(-1)).findCell(b.pos-c),d),!0}}function jn(a,b){var c;let d;if(0!=b.button||b.ctrlKey||b.metaKey)return;let e=jp(a,b.target);if(b.shiftKey&&a.state.selection instanceof iQ)f(a.state.selection.$anchorCell,b),b.preventDefault();else if(b.shiftKey&&e&&null!=(d=iI(a.state.selection.$anchor))&&(null==(c=jq(a,b))?void 0:c.pos)!=d.pos)f(d,b),b.preventDefault();else if(!e)return;function f(b,c){let d=jq(a,c),e=null==iH.getState(a.state);if(!d||!iM(b,d))if(!e)return;else d=b;let f=new iQ(b,d);if(e||!a.state.selection.eq(f)){let c=a.state.tr.setSelection(f);e&&c.setMeta(iH,b.pos),a.dispatch(c)}}function g(){a.root.removeEventListener("mouseup",g),a.root.removeEventListener("dragstart",g),a.root.removeEventListener("mousemove",h),null!=iH.getState(a.state)&&a.dispatch(a.state.tr.setMeta(iH,-1))}function h(c){let d,h=iH.getState(a.state);if(null!=h)d=a.state.doc.resolve(h);else if(jp(a,c.target)!=e&&!(d=jq(a,b)))return g();d&&f(d,c)}a.root.addEventListener("mouseup",g),a.root.addEventListener("dragstart",g),a.root.addEventListener("mousemove",h)}function jo(a,b,c){if(!(a.state.selection instanceof fH))return null;let{$head:d}=a.state.selection;for(let e=d.depth-1;e>=0;e--){let f=d.node(e);if((c<0?d.index(e):d.indexAfter(e))!=(c<0?0:f.childCount))break;if("cell"==f.type.spec.tableRole||"header_cell"==f.type.spec.tableRole){let f=d.before(e),g="vert"==b?c>0?"down":"up":c>0?"right":"left";return a.endOfTextblock(g)?f:null}}return null}function jp(a,b){for(;b&&b!=a.dom;b=b.parentNode)if("TD"==b.nodeName||"TH"==b.nodeName)return b;return null}function jq(a,b){let c=a.posAtCoords({left:b.clientX,top:b.clientY});if(!c)return null;let{inside:d,pos:e}=c;return d>=0&&iI(a.state.doc.resolve(d))||iI(a.state.doc.resolve(e))}var jr=class{constructor(a,b){this.node=a,this.defaultCellMinWidth=b,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${b}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),js(a,this.colgroup,this.table,b),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(a){return a.type==this.node.type&&(this.node=a,js(a,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(a){return"attributes"==a.type&&(a.target==this.table||this.colgroup.contains(a.target))}};function js(a,b,c,d,e,f){let g=0,h=!0,i=b.firstChild,j=a.firstChild;if(j){for(let a=0,c=0;a<j.childCount;a++){let{colspan:k,colwidth:l}=j.child(a).attrs;for(let a=0;a<k;a++,c++){let j=e==c?f:l&&l[a],k=j?j+"px":"";if(g+=j||d,j||(h=!1),i)i.style.width!=k&&(i.style.width=k),i=i.nextSibling;else{let a=document.createElement("col");a.style.width=k,b.appendChild(a)}}}for(;i;){var k;let a=i.nextSibling;null==(k=i.parentNode)||k.removeChild(i),i=a}h?(c.style.width=g+"px",c.style.minWidth=""):(c.style.width="",c.style.minWidth=g+"px")}}let jt=new fY("tableColumnResizing");var ju=class a{constructor(a,b){this.activeHandle=a,this.dragging=b}apply(b){let c=b.getMeta(jt);if(c&&null!=c.setHandle)return new a(c.setHandle,!1);if(c&&void 0!==c.setDragging)return new a(this.activeHandle,c.setDragging);if(this.activeHandle>-1&&b.docChanged){let c=b.mapping.map(this.activeHandle,-1);return iL(b.doc.resolve(c))||(c=-1),new a(c,this.dragging)}return this}};function jv(a,b,c,d){let e=a.posAtCoords({left:b.clientX+("right"==c?-d:d),top:b.clientY});if(!e)return -1;let{pos:f}=e,g=iI(a.state.doc.resolve(f));if(!g)return -1;if("right"==c)return g.pos;let h=iF.get(g.node(-1)),i=g.start(-1),j=h.map.indexOf(g.pos-i);return j%h.width==0?-1:i+h.map[j-1]}function jw(a,b,c){let d=b.clientX-a.startX;return Math.max(c,a.startWidth+d)}function jx(a,b){a.dispatch(a.state.tr.setMeta(jt,{setHandle:b}))}function jy(a,b,c,d){let e=a.state.doc.resolve(b),f=e.node(-1),g=e.start(-1),h=iF.get(f).colCount(e.pos-g)+e.nodeAfter.attrs.colspan-1,i=a.domAtPos(e.start(-1)).node;for(;i&&"TABLE"!=i.nodeName;)i=i.parentNode;i&&js(f,i.firstChild,i,d,h,c)}var jz=p,jA=a.i(985209);let jB=(a,b)=>!a.selection.empty&&(b&&b(a.tr.deleteSelection().scrollIntoView()),!0);function jC(a,b){let{$cursor:c}=a.selection;return c&&(b?b.endOfTextblock("backward",a):!(c.parentOffset>0))?c:null}let jD=(a,b,c)=>{let d=jC(a,c);if(!d)return!1;let e=jH(d);if(!e){let c=d.blockRange(),e=c&&fg(c);return null!=e&&(b&&b(a.tr.lift(c,e).scrollIntoView()),!0)}let f=e.nodeBefore;if(jR(a,e,b,-1))return!0;if(0==d.parent.content.size&&(jF(f,"end")||fJ.isSelectable(f)))for(let c=d.depth;;c--){let g=fq(a.doc,d.before(c),d.after(c),el.empty);if(g&&g.slice.size<g.to-g.from){if(b){let c=a.tr.step(g);c.setSelection(jF(f,"end")?fD.findFrom(c.doc.resolve(c.mapping.map(e.pos,-1)),-1):fJ.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 jE(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=fq(a.doc,e,g,el.empty);if(!h||h.from!=e||h instanceof fc&&h.slice.size>=g-e)return!1;if(c){let b=a.tr.step(h);b.setSelection(fH.create(b.doc,e)),c(b.scrollIntoView())}return!0}function jF(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 jG=(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=jH(d)}let g=f&&f.nodeBefore;return!!g&&!!fJ.isSelectable(g)&&(b&&b(a.tr.setSelection(fJ.create(a.doc,f.pos-g.nodeSize)).scrollIntoView()),!0)};function jH(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 jI(a,b){let{$cursor:c}=a.selection;return c&&(b?b.endOfTextblock("forward",a):!(c.parentOffset<c.parent.content.size))?c:null}let jJ=(a,b,c)=>{let d=jI(a,c);if(!d)return!1;let e=jL(d);if(!e)return!1;let f=e.nodeAfter;if(jR(a,e,b,1))return!0;if(0==d.parent.content.size&&(jF(f,"start")||fJ.isSelectable(f))){let c=fq(a.doc,d.before(),d.after(),el.empty);if(c&&c.slice.size<c.to-c.from){if(b){let d=a.tr.step(c);d.setSelection(jF(f,"start")?fD.findFrom(d.doc.resolve(d.mapping.map(e.pos)),1):fJ.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)},jK=(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=jL(d)}let g=f&&f.nodeAfter;return!!g&&!!fJ.isSelectable(g)&&(b&&b(a.tr.setSelection(fJ.create(a.doc,f.pos)).scrollIntoView()),!0)};function jL(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 jM=(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 jN(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 jO=(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=jN(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(fD.near(e.doc.resolve(d),1)),b(e.scrollIntoView())}return!0},jP=(a,b)=>{let c=a.selection,{$from:d,$to:e}=c;if(c instanceof fL||d.parent.inlineContent||e.parent.inlineContent)return!1;let f=jN(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(fH.create(g.doc,c+1)),b(g.scrollIntoView())}return!0},jQ=(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(fl(a.doc,d))return b&&b(a.tr.split(d).scrollIntoView()),!0}let d=c.blockRange(),e=d&&fg(d);return null!=e&&(b&&b(a.tr.lift(d,e).scrollIntoView()),!0)};function jR(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||fm(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=ef.empty;for(let a=j.length-1;a>=0;a--)e=ef.from(j[a].create(null,e));e=ef.from(h.copy(e));let f=a.tr.step(new fd(b.pos-1,d,b.pos,d,new el(e,1,0),j.length,!0)),g=f.doc.resolve(d+2*j.length);g.nodeAfter&&g.nodeAfter.type==h.type&&fm(f.doc,g.pos)&&f.join(g.pos),c(f.scrollIntoView())}return!0}let n=i.type.spec.isolating||d>0&&l?null:fD.findFrom(b,1),o=n&&n.$from.blockRange(n.$to),p=o&&fg(o);if(null!=p&&p>=b.depth)return c&&c(a.tr.lift(o,p).scrollIntoView()),!0;if(m&&jF(i,"start",!0)&&jF(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=ef.empty;for(let a=e.length-1;a>=0;a--)d=ef.from(e[a].copy(d));c(a.tr.step(new fd(b.pos-e.length,b.pos+i.nodeSize,b.pos+g,b.pos+i.nodeSize-g,new el(d,e.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function jS(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(fH.create(b.doc,a<0?e.start(f):e.end(f)))),!0)}}let jT=jS(-1),jU=jS(1);function jV(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 jW(...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 jX=jW(jB,jD,jG),jY=jW(jB,jJ,jK),jZ={Enter:jW(jM,jP,jQ,(a,b)=>{let{$from:c,$to:d}=a.selection;if(a.selection instanceof fJ&&a.selection.node.isBlock)return!!c.parentOffset&&!!fl(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=jN(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 fH||a.selection instanceof fL)&&j.deleteSelection();let k=j.mapping.map(c.pos),l=fl(j.doc,k,e.length,e);if(l||(e[0]=g?{type:g}:null,l=fl(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":jO,Backspace:jX,"Mod-Backspace":jX,"Shift-Backspace":jX,Delete:jY,"Mod-Delete":jY,"Mod-a":(a,b)=>(b&&b(a.tr.setSelection(new fL(a.doc))),!0)},j$={"Ctrl-h":jZ.Backspace,"Alt-Backspace":jZ["Mod-Backspace"],"Ctrl-d":jZ.Delete,"Ctrl-Alt-Backspace":jZ["Mod-Delete"],"Alt-Delete":jZ["Mod-Delete"],"Alt-d":jZ["Mod-Delete"],"Ctrl-a":jT,"Ctrl-e":jU};for(let a in jZ)j$[a]=jZ[a];"u">typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"u">typeof os&&os.platform&&os.platform();var j_=Object.defineProperty,j0=(a,b)=>{for(var c in b)j_(a,c,{get:b[c],enumerable:!0})};function j1(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 j2=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:j1({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}},j3={};j0(j3,{blur:()=>j4,clearContent:()=>j5,clearNodes:()=>j6,command:()=>j7,createParagraphNear:()=>j8,cut:()=>j9,deleteCurrentNode:()=>ka,deleteNode:()=>kc,deleteRange:()=>kd,deleteSelection:()=>kf,enter:()=>kg,exitCode:()=>kh,extendMarkRange:()=>ko,first:()=>kp,focus:()=>kv,forEach:()=>kw,insertContent:()=>kx,insertContentAt:()=>kA,joinBackward:()=>kD,joinDown:()=>kC,joinForward:()=>kE,joinItemBackward:()=>kF,joinItemForward:()=>kG,joinTextblockBackward:()=>kH,joinTextblockForward:()=>kI,joinUp:()=>kB,keyboardShortcut:()=>kK,lift:()=>kM,liftEmptyBlock:()=>kN,liftListItem:()=>kO,newlineInCode:()=>kP,resetAttributes:()=>kS,scrollIntoView:()=>kT,selectAll:()=>kU,selectNodeBackward:()=>kV,selectNodeForward:()=>kW,selectParentNode:()=>kX,selectTextblockEnd:()=>kY,selectTextblockStart:()=>kZ,setContent:()=>k_,setMark:()=>lB,setMeta:()=>lC,setNode:()=>lD,setNodeSelection:()=>lE,setTextDirection:()=>lF,setTextSelection:()=>lG,sinkListItem:()=>lH,splitBlock:()=>lJ,splitListItem:()=>lK,toggleList:()=>lN,toggleMark:()=>lO,toggleNode:()=>lP,toggleWrap:()=>lQ,undoInputRule:()=>lR,unsetAllMarks:()=>lS,unsetMark:()=>lT,unsetTextDirection:()=>lU,updateAttributes:()=>lV,wrapIn:()=>lW,wrapInList:()=>lX});var j4=()=>({editor:a,view:b})=>(requestAnimationFrame(()=>{var c;a.isDestroyed||(b.dom.blur(),null==(c=null==window?void 0:window.getSelection())||c.removeAllRanges())}),!0),j5=(a=!0)=>({commands:b})=>b.setContent("",{emitUpdate:a}),j6=()=>({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=fg(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)},j7=a=>b=>a(b),j8=()=>({state:a,dispatch:b})=>jP(a,b),j9=(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 fH(d.doc.resolve(Math.max(g-1,0)))),!0},ka=()=>({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 kb(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 kc=a=>({tr:b,state:c,dispatch:d})=>{let e=kb(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},kd=a=>({tr:b,dispatch:c})=>{let{from:d,to:e}=a;return c&&b.delete(d,e),!0},ke=(a,b,c)=>{var d;return!a.parent.isInline||"left"===c&&a.pos>a.start()||"right"===c&&a.pos<a.end()?a.pos:(d=b.nodes[a.parent.type.name].spec).content&&/^text(\*|\+)/.test(d.content)?"left"===c?a.start()-1:a.end()+1:a.pos},kf=()=>({state:a,dispatch:b})=>{var c;let{$from:d,$to:e}=a.selection;if(a.selection.empty)return!1;let{from:f,to:g}={from:ke(d,c=a.schema,"left"),to:ke(e,c,"right")};return b&&(a.tr.deleteRange(f,g).scrollIntoView(),b(a.tr)),!0},kg=()=>({commands:a})=>a.keyboardShortcut("Enter"),kh=()=>({state:a,dispatch:b})=>jO(a,b);function ki(a){return"[object RegExp]"===Object.prototype.toString.call(a)}function kj(a,b,c={strict:!0}){let d=Object.keys(b);return!d.length||d.every(d=>c.strict?b[d]===a[d]:ki(b[d])?b[d].test(a[d]):b[d]===a[d])}function kk(a,b,c={}){return a.find(a=>a.type===b&&kj(Object.fromEntries(Object.keys(c).map(b=>[b,a.attrs[b]])),c))}function kl(a,b,c={}){return!!kk(a,b,c)}function km(a,b,c){if(!a||!b)return;let d=a.parent.childAfter(a.parentOffset);if(d.node&&d.node.marks.some(a=>a.type===b)||(d=a.parent.childBefore(a.parentOffset)),!d.node||!d.node.marks.some(a=>a.type===b))return;if(!c){let a=d.node.marks.find(a=>a.type===b);a&&(c=a.attrs)}if(!kk([...d.node.marks],b,c))return;let e=d.index,f=a.start()+d.offset,g=e+1,h=f+d.node.nodeSize;for(;e>0&&kl([...a.parent.child(e-1).marks],b,c);)e-=1,f-=a.parent.child(e).nodeSize;for(;g<a.parent.childCount&&kl([...a.parent.child(g).marks],b,c);)h+=a.parent.child(g).nodeSize,g+=1;return{from:f,to:h}}function kn(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 ko=(a,b)=>({tr:c,state:d,dispatch:e})=>{let f=kn(a,d.schema),{doc:g,selection:h}=c,{$from:i,from:j,to:k}=h;if(e){let a=km(i,f,b);if(a&&a.from<=j&&a.to>=k){let b=fH.create(g,a.from,a.to);c.setSelection(b)}}return!0},kp=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 kq(a){return a instanceof fH}function kr(a=0,b=0,c=0){return Math.min(Math.max(a,b),c)}function ks(a,b=null){if(!b)return null;let c=fD.atStart(a),d=fD.atEnd(a);if("start"===b||!0===b)return c;if("end"===b)return d;let e=c.from,f=d.to;return"all"===b?fH.create(a,kr(0,e,f),kr(a.content.size,e,f)):fH.create(a,kr(b,e,f),kr(b,e,f))}function kt(){return"Android"===navigator.platform||/android/i.test(navigator.userAgent)}function ku(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var kv=(a=null,b={})=>({editor:c,view:d,tr:e,dispatch:f})=>{b={scrollIntoView:!0,...b};let g=()=>{(ku()||kt())&&d.dom.focus(),"u">typeof navigator&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&!ku()&&!kt()&&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&&!kq(c.state.selection))return g(),!0;let h=ks(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},kw=(a,b)=>c=>a.every((a,d)=>b(a,{...c,index:d})),kx=(a,b)=>({tr:c,commands:d})=>d.insertContentAt({from:c.selection.from,to:c.selection.to},a,b);function ky(a){throw Error("[tiptap error]: there is no window object available, so this function cannot be used")}function kz(a,b,c){if(a instanceof ey||a instanceof ef)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 ef.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),kz("",b,c)}if(e){if(c.errorOnInvalidContent){let d=!1,e="",f=new eN({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?eP.fromSchema(f).parseSlice(ky(a),c.parseOptions):eP.fromSchema(f).parse(ky(a),c.parseOptions),c.errorOnInvalidContent&&d)throw Error("[tiptap error]: Invalid HTML content",{cause:Error(`Invalid element found: ${e}`)})}let d=eP.fromSchema(b);return c.slice?d.parseSlice(ky(a),c.parseOptions).content:d.parse(ky(a),c.parseOptions)}return kz("",b,c)}var kA=(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{kz(b,f.schema,{parseOptions:j,errorOnInvalidContent:!0})}catch(a){i(a)}try{e=kz(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 ef){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&&n&&(k=Math.max(0,k-1)),d.replaceWith(k,l,h)}c.updateSelection&&function(a,b){let c=a.steps.length-1;if(c<b)return;let d=a.steps[c];if(!(d instanceof fc||d instanceof fd))return;let e=a.mapping.maps[c],f=0;e.forEach((a,b,c,d)=>{0===f&&(f=d)}),a.setSelection(fD.near(a.doc.resolve(f),-1))}(d,d.steps.length-1),c.applyInputRules&&d.setMeta("applyInputRules",{from:k,text:h}),c.applyPasteRules&&d.setMeta("applyPasteRules",{from:k,text:h})}return!0},kB=()=>({state:a,dispatch:b})=>((a,b)=>{let c=a.selection,d=c instanceof fJ,e;if(d){if(c.node.isTextblock||!fm(a.doc,c.from))return!1;e=c.from}else if(null==(e=fo(a.doc,c.from,-1)))return!1;if(b){let c=a.tr.join(e);d&&c.setSelection(fJ.create(c.doc,e-a.doc.resolve(e).nodeBefore.nodeSize)),b(c.scrollIntoView())}return!0})(a,b),kC=()=>({state:a,dispatch:b})=>((a,b)=>{let c=a.selection,d;if(c instanceof fJ){if(c.node.isTextblock||!fm(a.doc,c.to))return!1;d=c.to}else if(null==(d=fo(a.doc,c.to,1)))return!1;return b&&b(a.tr.join(d).scrollIntoView()),!0})(a,b),kD=()=>({state:a,dispatch:b})=>jD(a,b),kE=()=>({state:a,dispatch:b})=>jJ(a,b),kF=()=>({state:a,dispatch:b,tr:c})=>{try{let d=fo(a.doc,a.selection.$from.pos,-1);if(null==d)return!1;return c.join(d,2),b&&b(c),!0}catch{return!1}},kG=()=>({state:a,dispatch:b,tr:c})=>{try{let d=fo(a.doc,a.selection.$from.pos,1);if(null==d)return!1;return c.join(d,2),b&&b(c),!0}catch{return!1}},kH=()=>({state:a,dispatch:b})=>((a,b,c)=>{let d=jC(a,c);if(!d)return!1;let e=jH(d);return!!e&&jE(a,e,b)})(a,b),kI=()=>({state:a,dispatch:b})=>((a,b,c)=>{let d=jI(a,c);if(!d)return!1;let e=jL(d);return!!e&&jE(a,e,b)})(a,b);function kJ(){return"u">typeof navigator&&/Mac/.test(navigator.platform)}var kK=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))ku()||kJ()?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 kL(a,b,c={}){let{from:d,to:e,empty:f}=a.selection,g=b?kb(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=>kj(a.node.attrs,c,{strict:!1}));return f?!!j.length:j.reduce((a,b)=>a+b.to-b.from,0)>=i}var kM=(a,b={})=>({state:c,dispatch:d})=>{let e=kb(a,c.schema);return!!kL(c,e,b)&&((a,b)=>{let{$from:c,$to:d}=a.selection,e=c.blockRange(d),f=e&&fg(e);return null!=f&&(b&&b(a.tr.lift(e,f).scrollIntoView()),!0)})(c,d)},kN=()=>({state:a,dispatch:b})=>jQ(a,b),kO=a=>({state:b,dispatch:c})=>{var d;return(d=kb(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 fd(f-1,g,f,g,new el(ef.from(c.create(null,d.parent.copy())),1,0),1,!0)),d=new ew(e.doc.resolve(d.$from.pos),e.doc.resolve(g),d.depth));let h=fg(d);if(null==h)return!1;e.lift(d,h);let i=e.doc.resolve(e.mapping.map(f,-1)-1);return fm(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?ef.empty:ef.from(e))))return!1;let l=f.pos,m=l+g.nodeSize;return d.step(new fd(l-!!h,m+ +!!i,l+1,m-1,new el((h?ef.empty:ef.from(e.copy(ef.empty))).append(i?ef.empty:ef.from(e.copy(ef.empty))),+!h,+!i),+!h)),b(d.scrollIntoView()),!0}(a,b,f)))})(b,c)},kP=()=>({state:a,dispatch:b})=>jM(a,b);function kQ(a,b){return b.nodes[a]?"node":b.marks[a]?"mark":null}function kR(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 kS=(a,b)=>({tr:c,state:d,dispatch:e})=>{let f=null,g=null,h=kQ("string"==typeof a?a:a.name,d.schema);if(!h)return!1;"node"===h&&(f=kb(a,d.schema)),"mark"===h&&(g=kn(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,kR(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(kR(f.attrs,b))))})})}),i},kT=()=>({tr:a,dispatch:b})=>(b&&a.scrollIntoView(),!0),kU=()=>({tr:a,dispatch:b})=>{if(b){let b=new fL(a.doc);a.setSelection(b)}return!0},kV=()=>({state:a,dispatch:b})=>jG(a,b),kW=()=>({state:a,dispatch:b})=>jK(a,b),kX=()=>({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(fJ.create(a.doc,e))),!0)})(a,b),kY=()=>({state:a,dispatch:b})=>jU(a,b),kZ=()=>({state:a,dispatch:b})=>jT(a,b);function k$(a,b,c={},d={}){return kz(a,b,{slice:!1,parseOptions:c,errorOnInvalidContent:d.errorOnInvalidContent})}var k_=(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=k$(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 k0(a,b){let c=kn(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 k1(a,b){let c=new fB(a);return b.forEach(a=>{a.steps.forEach(a=>{c.step(a)})}),c}function k2(a,b){let c=[];return a.descendants((a,d)=>{b(a)&&c.push({node:a,pos:d})}),c}function k3(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 k4(a){return b=>k3(b.$from,a)}function k5(a,b,c){return void 0===a.config[b]&&a.parent?k5(a.parent,b,c):"function"==typeof a.config[b]?a.config[b].bind({...c,parent:a.parent?k5(a.parent,b,c):null}):a.config[b]}function k6(a){return a.map(a=>{let b={name:a.name,options:a.options,storage:a.storage},c=k5(a,"addExtensions",b);return c?[a,...k6(c())]:a}).flat(10)}function k7(a,b){let c=eY.fromSchema(b).serializeFragment(a),d=document.implementation.createHTMLDocument().createElement("div");return d.appendChild(c),d.innerHTML}function k8(a){return"function"==typeof a}function k9(a,b,...c){return k8(a)?b?a.bind(b)(...c):a(...c):a}function la(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 lb(a){let b=[],{nodeExtensions:c,markExtensions:d}=la(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=k5(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=k5(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 lc(a){let b=[],c=function(a){let b=[],c="",d=!1,e=!1,f=0,g=a.length;for(let h=0;h<g;h+=1){let g=a[h];if("'"===g&&!e){d=!d,c+=g;continue}if('"'===g&&!d){e=!e,c+=g;continue}if(!d&&!e){if("("===g){f+=1,c+=g;continue}if(")"===g&&f>0){f-=1,c+=g;continue}if(";"===g&&0===f){b.push(c),c="";continue}}c+=g}return c&&b.push(c),b}(a||""),d=c.length;for(let a=0;a<d;a+=1){let d=c[a],e=d.indexOf(":");if(-1===e)continue;let f=d.slice(0,e).trim(),g=d.slice(e+1).trim();f&&g&&b.push([f,g])}return b}function ld(...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=new Map([...lc(c[a]),...lc(b)]);c[a]=Array.from(d.entries()).map(([a,b])=>`${a}: ${b}`).join("; ")}else c[a]=b}),c},{})}function le(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)=>ld(a,b),{})}function lf(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 lg(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 lh(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 li(a){return a.sort((a,b)=>{let c=k5(a,"priority")||100,d=k5(b,"priority")||100;return c>d?-1:+(c<d)})}function lj(a){var b;let c=li(k6(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 lk(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 ll(a,b){let c={from:0,to:a.content.size};return lk(a,c,b)}function lm(a){return Object.fromEntries(Object.entries(a.nodes).filter(([,a])=>a.spec.toText).map(([a,b])=>[a,b.spec.toText]))}function ln(a,b){let c=kQ("string"==typeof b?b:b.name,a.schema);return"node"===c?function(a,b){let c=kb(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?k0(a,b):{}}function lo(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 lp(a,b,c){let d=[];return a===b?c.resolve(a).marks().forEach(b=>{let e=km(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 lq(a,b){return b.nodes[a]||b.marks[a]||null}function lr(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 ls(a,b,c={}){let{empty:d,ranges:e}=a.selection,f=b?kn(b,a.schema):null;if(d)return!!(a.storedMarks||a.selection.$from.marks()).filter(a=>!f||f.name===a.type.name).find(a=>kj(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=>kj(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 lt(a,b){return Array.isArray(b)?b.some(b=>("string"==typeof b?b:b.name)===a.name):b}function lu(a,b){let{nodeExtensions:c}=la(b),d=c.find(b=>b.name===a);if(!d)return!1;let e={name:d.name,options:d.options,storage:d.storage},f=k9(k5(d,"group",e));return"string"==typeof f&&f.split(" ").includes("list")}function lv(a,{checkChildren:b=!0,ignoreWhitespace:c=!1}={}){var d;if(c){if("hardBreak"===a.type.name)return!0;if(a.isText)return!/\S/.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&&(lv(a,{ignoreWhitespace:c,checkChildren:b})||(d=!1))}),d}return!1}function lw(a){return a instanceof fJ}var lx=class a{constructor(a){this.position=a}static fromJSON(b){return new a(b.position)}toJSON(){return{position:this.position}}};function ly(a,b){let c=b.mapping.mapResult(a.position);return{position:new lx(c.pos),mapResult:c}}function lz(a){return new lx(a)}function lA(a,b,c){let d=a.state.doc.content.size,e=kr(b,0,d),f=kr(c,0,d),g=a.coordsAtPos(e),h=a.coordsAtPos(f,-1),i=Math.min(g.top,h.top),j=Math.max(g.bottom,h.bottom),k=Math.min(g.left,h.left),l=Math.max(g.right,h.right),m={top:i,bottom:j,left:k,right:l,width:l-k,height:j-i,x:k,y:i};return{...m,toJSON:()=>m}}var lB=(a,b={})=>({tr:c,state:d,dispatch:e})=>{let{selection:f}=c,{empty:g,ranges:h}=f,i=kn(a,d.schema);if(e)if(g){let a=k0(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(kq(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)},lC=(a,b)=>({tr:c})=>(c.setMeta(a,b),!0),lD=(a,b={})=>({state:c,dispatch:d,chain:e})=>{let f,g=kb(a,c.schema);return(c.selection.$anchor.sameParent(c.selection.$head)&&(f=c.selection.$anchor.parent.attrs),g.isTextblock)?e().command(({commands:a})=>!!jV(g,{...f,...b})(c)||a.clearNodes()).command(({state:a})=>jV(g,{...f,...b})(a,d)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},lE=a=>({tr:b,dispatch:c})=>{if(c){let{doc:c}=b,d=kr(a,0,c.content.size),e=fJ.create(c,d);b.setSelection(e)}return!0},lF=(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},lG=a=>({tr:b,dispatch:c})=>{if(c){let{doc:c}=b,{from:d,to:e}="number"==typeof a?{from:a,to:a}:a,f=fH.atStart(c).from,g=fH.atEnd(c).to,h=kr(d,f,g),i=kr(e,f,g),j=fH.create(c,h,i);b.setSelection(j)}return!0},lH=a=>({state:b,dispatch:c})=>{var d;return(d=kb(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=ef.from(c?d.create():null),g=new el(ef.from(d.create(null,ef.from(h.type.create(null,e)))),c?3:1,0),j=f.start,k=f.end;b(a.tr.step(new fd(j-(c?3:1),k,j,k,g,1,!0)).scrollIntoView())}return!0})(b,c)};function lI(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 lJ=({keepMarks:a=!0}={})=>({tr:b,state:c,dispatch:d,editor:e})=>{let{selection:f,doc:g}=b,{$from:h,$to:i}=f,j=lr(e.extensionManager.attributes,h.node().type.name,h.node().attrs);if(f instanceof fJ&&f.node.isBlock)return!!h.parentOffset&&!!fl(g,h.pos)&&(d&&(a&&lI(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=fl(b.doc,b.mapping.map(h.pos),1,m);if(!m&&!n&&fl(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 fH&&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&&lI(c,e.extensionManager.splittableMarks),b.scrollIntoView()}return n},lK=(a,b={})=>({tr:c,state:d,dispatch:e,editor:f})=>{var g;let h=kb(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=ef.empty,d=i.index(-1)?1:i.index(-2)?2:3;for(let b=i.depth-d;b>=i.depth-3;b-=1)a=ef.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={...lr(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(ef.from(h.createAndFill(null,j)||void 0));let k=i.before(i.depth-(d-1));c.replace(k,i.after(-e),new el(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(fH.near(c.doc.resolve(l))),c.scrollIntoView()}return!0}let n=j.pos===i.end()?l.contentMatchAt(0).defaultType:null,o={...lr(m,l.type.name,l.attrs),...b},p={...lr(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(!fl(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},lL=(a,b)=>{let c=k4(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)&&fm(a.doc,c.pos))||(a.join(c.pos),!0)},lM=(a,b)=>{let c=k4(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)&&fm(a.doc,d))||(a.join(d),!0)},lN=(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=kb(a,g.schema),o=kb(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=k4(a=>lu(a.type.name,l))(p),w=0===p.from&&p.to===g.doc.content.size,x=g.doc.content.content,y=1===x.length?x[0]:null,z=w&&y&&lu(y.type.name,l)?{node:y,pos:0,depth:0}:null,A=null!=v?v:z,B=!!v&&t.depth>=1&&t.depth-v.depth<=1,C=!!z;if((B||C)&&A){if(A.node.type===n)return w&&C?i().command(({tr:a,dispatch:b})=>{let c=function(a){let b=a.doc,c=b.firstChild;if(!c)return null;let d=b.resolve(1),e=b.resolve(c.nodeSize-1);return fH.between(d,e)}(a);return!!c&&(a.setSelection(c),b&&b(a),!0)}).liftListItem(o).run():j.liftListItem(o);if(lu(A.node.type.name,l)&&n.validContent(A.node.content))return i().command(()=>(f.setNodeMarkup(A.pos,n),!0)).command(()=>lL(f,n)).command(()=>lM(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(()=>lL(f,n)).command(()=>lM(f,n)).run():i().command(()=>!!k().wrapInList(n,d)||j.clearNodes()).wrapInList(n,d).command(()=>lL(f,n)).command(()=>lM(f,n)).run()},lO=(a,b={},c={})=>({state:d,commands:e})=>{let{extendEmptyMarkRange:f=!1}=c,g=kn(a,d.schema);return ls(d,g,b)?e.unsetMark(g,{extendEmptyMarkRange:f}):e.setMark(g,b)},lP=(a,b,c={})=>({state:d,commands:e})=>{let f,g=kb(a,d.schema),h=kb(b,d.schema),i=kL(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})},lQ=(a,b={})=>({state:c,commands:d})=>{let e=kb(a,c.schema);return kL(c,e,b)?d.lift(e):d.wrapIn(e,b)},lR=()=>({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},lS=()=>({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)},lT=(a,b={})=>({tr:c,state:d,dispatch:e})=>{var f;let{extendEmptyMarkRange:g=!1}=b,{selection:h}=c,i=kn(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=km(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},lU=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},lV=(a,b={})=>({tr:c,state:d,dispatch:e})=>{let f=null,g=null,h=kQ("string"==typeof a?a:a.name,d.schema);if(!h)return!1;"node"===h&&(f=kb(a,d.schema)),"mark"===h&&(g=kn(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},lW=(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&&fh(g,a,b);return!!h&&(d&&d(c.tr.wrap(g,h).scrollIntoView()),!0)}})(kb(a,c.schema),b)(c,d),lX=(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 ew(a,a,b.depth),b.endIndex<b.parent.childCount&&(b=new ew(b.$from,g.resolve(b.$to.end(b.depth)),b.depth)),e=!0}let h=fh(f,c,d,b);return!!h&&(a&&function(a,b,c,d,e){let f=ef.empty;for(let a=c.length-1;a>=0;a--)f=ef.from(c[a].type.create(c[a].attrs,f));a.step(new fd(b.start-2*!!d,b.end,b.start,b.end,new el(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&&fl(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)}})(kb(a,c.schema),b)(c,d),lY=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={}}},lZ=class{constructor(a){var b;this.find=a.find,this.handler=a.handler,this.undoable=null==(b=a.undoable)||b}};function l$(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(ki(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=j1({state:i.state,transaction:g}),m={from:d-(b[0].length-f.length),to:e},{commands:n,chain:o,can:p}=new j2({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 l_(a){return"Object"===Object.prototype.toString.call(a).slice(8,-1)&&a.constructor===Object&&Object.getPrototypeOf(a)===Object.prototype}var l0=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{...k9(k5(this,"addOptions",{name:this.name}))}}get storage(){return{...k9(k5(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 l_(b)&&l_(c)&&Object.keys(c).forEach(e=>{l_(c[e])&&l_(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,this.child=null,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}},l1=class a extends l0{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)}},l2=class{constructor(a){this.find=a.find,this.handler=a.handler}},l3=null,l4=class{constructor(a,b){this.splittableMarks=[],this.editor=b,this.baseExtensions=a,this.extensions=lj(a),this.schema=function(a,b){var c;let d=lb(a),{nodeExtensions:e,markExtensions:f}=la(a),g=null==(c=e.find(a=>k5(a,"topNode")))?void 0:c.name;return new eN({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=lg({...a.reduce((a,b)=>{let d=k5(b,"extendNodeSchema",f);return{...a,...d?d(c):{}}},{}),content:k9(k5(c,"content",f)),marks:k9(k5(c,"marks",f)),group:k9(k5(c,"group",f)),inline:k9(k5(c,"inline",f)),atom:k9(k5(c,"atom",f)),selectable:k9(k5(c,"selectable",f)),draggable:k9(k5(c,"draggable",f)),code:k9(k5(c,"code",f)),whitespace:k9(k5(c,"whitespace",f)),linebreakReplacement:k9(k5(c,"linebreakReplacement",f)),defining:k9(k5(c,"defining",f)),isolating:k9(k5(c,"isolating",f)),attrs:Object.fromEntries(e.map(lh))}),h=k9(k5(c,"parseHTML",f));h&&(g.parseDOM=h.map(a=>lf(a,e)));let i=k5(c,"renderHTML",f);i&&(g.toDOM=a=>i({node:a,HTMLAttributes:le(a,e)}));let j=k5(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=lg({...a.reduce((a,b)=>{let d=k5(b,"extendMarkSchema",f);return{...a,...d?d(c):{}}},{}),inclusive:k9(k5(c,"inclusive",f)),excludes:k9(k5(c,"excludes",f)),group:k9(k5(c,"group",f)),spanning:k9(k5(c,"spanning",f)),code:k9(k5(c,"code",f)),attrs:Object.fromEntries(e.map(lh))}),h=k9(k5(c,"parseHTML",f));h&&(g.parseDOM=h.map(a=>lf(a,e)));let i=k5(c,"renderHTML",f);return i&&(g.toDOM=a=>i({mark:a,HTMLAttributes:le(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:lq(b.name,this.schema)},d=k5(b,"addCommands",c);return d?{...a,...d()}:a},{})}get plugins(){let{editor:a}=this;return li([...this.extensions].reverse()).flatMap(b=>{let c={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:a,type:lq(b.name,this.schema)},d=[],e=k5(b,"addKeyboardShortcuts",c),f={};if("mark"===b.type&&k5(b,"exitable",c)&&(f.ArrowRight=()=>l1.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 fV({props:{handleKeyDown:iE(f)}});d.push(g);let h=k5(b,"addInputRules",c);if(lt(b,a.options.enableInputRules)&&h){let b=h();if(b&&b.length){let c=function(a){let{editor:b,rules:c}=a,d=new fV({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=k7(ef.from(a),f.schema));let{from:e}=h,g=e+a.length;l$({editor:b,from:e,to:g,text:a,rules:c,plugin:d})}),a.selectionSet||a.docChanged?null:e}},props:{handleTextInput:(a,e,f,g)=>l$({editor:b,from:e,to:f,text:g,rules:c,plugin:d}),handleDOMEvents:{compositionend:a=>(setTimeout(()=>{let{$cursor:e}=a.state.selection;e&&l$({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&&l$({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=k5(b,"addPasteRules",c);if(lt(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 j2({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(ki(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:j1({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 fV({view(a){let b=b=>{var d;(e=(null==(d=a.dom.parentElement)?void 0:d.contains(b.target))?a.dom.parentElement:null)&&(l3=c)},d=()=>{l3&&(l3=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=l3;(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=k7(ef.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=k5(b,"addProseMirrorPlugins",c);if(j){let a=j();d.push(...a)}return d})}get attributes(){return lb(this.extensions)}get nodeViews(){let{editor:a}=this,{nodeExtensions:b}=la(this.extensions);return Object.fromEntries(b.filter(a=>!!k5(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:kb(b.name,this.schema)},e=k5(b,"addNodeView",d);if(!e)return[];let f=e();return f?[b.name,(d,e,g,h,i)=>{let j=le(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 li([...this.extensions].reverse()).reduceRight((a,c)=>{let d={name:c.name,options:c.options,storage:this.editor.extensionStorage[c.name],editor:b,type:lq(c.name,this.schema)},e=k5(c,"dispatchTransaction",d);return e?b=>{e.call(d,{transaction:b,next:a})}:a},a)}transformPastedHTML(a){let{editor:b}=this;return li([...this.extensions]).reduce((a,c)=>{let d={name:c.name,options:c.options,storage:this.editor.extensionStorage[c.name],editor:b,type:lq(c.name,this.schema)},e=k5(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}=la(this.extensions);return Object.fromEntries(b.filter(a=>!!k5(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:kn(b.name,this.schema)},e=k5(b,"addMarkView",d);return e?[b.name,(d,f,g)=>{let h=le(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)}})}]:[]}))}destroy(){this.extensions.forEach(a=>{let b=a;for(;b.parent;){let a=b.parent;a.child===b&&(a.child=null),b=a}}),this.extensions=[],this.baseExtensions=[],this.schema=null,this.editor=null}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:lq(a.name,this.schema)};"mark"===a.type&&(null==(b=k9(k5(a,"keepOnSplit",c)))||b)&&this.splittableMarks.push(a.name);let d=k5(a,"onBeforeCreate",c),e=k5(a,"onCreate",c),f=k5(a,"onUpdate",c),g=k5(a,"onSelectionUpdate",c),h=k5(a,"onTransaction",c),i=k5(a,"onFocus",c),j=k5(a,"onBlur",c),k=k5(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)})}};l4.resolve=lj,l4.sort=li,l4.flatten=k6,j0({},{ClipboardTextSerializer:()=>l6,Commands:()=>l7,Delete:()=>l8,Drop:()=>l9,Editable:()=>ma,FocusEvents:()=>mc,Keymap:()=>md,Paste:()=>me,Tabindex:()=>mf,TextDirection:()=>mg,focusEventsPluginKey:()=>mb});var l5=class a extends l0{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)}},l6=l5.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new fV({key:new fY("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=lm(c);return lk(d,{from:g,to:h},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:i})}}})]}}),l7=l5.create({name:"commands",addCommands:()=>({...j3})}),l8=l5.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=k1(a.before,[a,...b]);lo(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 e9){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=f>0&&(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()}}),l9=l5.create({name:"drop",addProseMirrorPlugins(){return[new fV({key:new fY("tiptapDrop"),props:{handleDrop:(a,b,c,d)=>{this.editor.emit("drop",{editor:this.editor,event:b,slice:c,moved:d})}}})]}}),ma=l5.create({name:"editable",addProseMirrorPlugins(){return[new fV({key:new fY("editable"),props:{editable:()=>this.editor.options.editable}})]}}),mb=new fY("focusEvents"),mc=l5.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:a}=this;return[new fV({key:mb,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}}}})]}}),md=l5.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:fD.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 ku()||kJ()?e:d},addProseMirrorPlugins(){return[new fV({key:new fY("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=fD.atStart(b.doc).from,j=fD.atEnd(b.doc).to;if(f||g!==i||h!==j||!lv(c.doc))return;let k=c.tr,l=j1({state:c,transaction:k}),{commands:m}=new j2({editor:this.editor,state:l});if(m.clearNodes(),k.steps.length)return k}})]}}),me=l5.create({name:"paste",addProseMirrorPlugins(){return[new fV({key:new fY("tiptapPaste"),props:{handlePaste:(a,b,c)=>{this.editor.emit("paste",{editor:this.editor,event:b,slice:c})}}})]}}),mf=l5.create({name:"tabindex",addOptions:()=>({value:void 0}),addProseMirrorPlugins(){return[new fV({key:new fY("tabindex"),props:{attributes:()=>{var a;return this.editor.isEditable||void 0!==this.options.value?{tabindex:null!=(a=this.options.value)?a:"0"}:{}}}})]}}),mg=l5.create({name:"textDirection",addOptions:()=>({direction:void 0}),addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:a}=la(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 fV({key:new fY("textDirection"),props:{attributes:()=>{let a=this.options.direction;return a?{dir:a}:{}}}})]}}),mh=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)}},mi=`.ProseMirror {
22
22
  position: relative;
23
23
  }
24
24
 
@@ -124,7 +124,7 @@ ${e}
124
124
  `)},addCommands(){return{setBlockquote:()=>({commands:a})=>a.wrapIn(this.name),toggleBlockquote:()=>({commands:a})=>a.toggleWrap(this.name),unsetBlockquote:()=>({commands:a})=>a.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[mn({find:rS,type:this.type})]}}),rU=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,rV=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,rW=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,rX=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,rY=l1.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:a=>"normal"!==a.style.fontWeight&&null},{style:"font-weight=400",clearMark:a=>a.type.name===this.name},{style:"font-weight",getAttrs:a=>/^(bold(er)?|[5-9]\d{2,})$/.test(a)&&null}]},renderHTML({HTMLAttributes:a}){return rR("strong",{...ld(this.options.HTMLAttributes,a),children:rR("slot",{})})},markdownTokenName:"strong",parseMarkdown:(a,b)=>b.applyMark("bold",b.parseInline(a.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(a,b)=>`**${b.renderChildren(a)}**`,addCommands(){return{setBold:()=>({commands:a})=>a.setMark(this.name),toggleBold:()=>({commands:a})=>a.toggleMark(this.name),unsetBold:()=>({commands:a})=>a.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[mk({find:rU,type:this.type}),mk({find:rW,type:this.type})]},addPasteRules(){return[mA({find:rV,type:this.type}),mA({find:rX,type:this.type})]}}),rZ=/(^|[^`])`([^`]+)`(?!`)$/,r$=/(^|[^`])`([^`]+)`(?!`)/g,r_=l1.create({name:"code",addOptions:()=>({HTMLAttributes:{}}),excludes:"_",code:!0,exitable:!0,parseHTML:()=>[{tag:"code"}],renderHTML({HTMLAttributes:a}){return["code",ld(this.options.HTMLAttributes,a),0]},markdownTokenName:"codespan",parseMarkdown:(a,b)=>b.applyMark("code",[{type:"text",text:a.text||""}]),renderMarkdown:(a,b)=>a.content?`\`${b.renderChildren(a.content)}\``:"",addCommands(){return{setCode:()=>({commands:a})=>a.setMark(this.name),toggleCode:()=>({commands:a})=>a.toggleMark(this.name),unsetCode:()=>({commands:a})=>a.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[mk({find:rZ,type:this.type})]},addPasteRules(){return[mA({find:r$,type:this.type})]}}),r0=/^```([a-z]+)?[\s\n]$/,r1=/^~~~([a-z]+)?[\s\n]$/,r2=my.create({name:"codeBlock",addOptions:()=>({languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}),content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:a=>{var b;let{languageClassPrefix:c}=this.options;if(!c)return null;let d=[...(null==(b=a.firstElementChild)?void 0:b.classList)||[]].filter(a=>a.startsWith(c)).map(a=>a.replace(c,""))[0];return d||null},rendered:!1}}},parseHTML:()=>[{tag:"pre",preserveWhitespace:"full"}],renderHTML({node:a,HTMLAttributes:b}){return["pre",ld(this.options.HTMLAttributes,b),["code",{class:a.attrs.language?this.options.languageClassPrefix+a.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(a,b)=>{var c,d;return(null==(c=a.raw)?void 0:c.startsWith("```"))===!1&&(null==(d=a.raw)?void 0:d.startsWith("~~~"))===!1&&"indented"!==a.codeBlockStyle?[]:b.createNode("codeBlock",{language:a.lang||null},a.text?[b.createTextNode(a.text)]:[])},renderMarkdown:(a,b)=>{var c;let d=(null==(c=a.attrs)?void 0:c.language)||"";return a.content?[`\`\`\`${d}`,b.renderChildren(a.content),"```"].join("\n"):`\`\`\`${d}
125
125
 
126
126
  \`\`\``},addCommands(){return{setCodeBlock:a=>({commands:b})=>b.setNode(this.name,a),toggleCodeBlock:a=>({commands:b})=>b.toggleNode(this.name,"paragraph",a)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:a,$anchor:b}=this.editor.state.selection,c=1===b.pos;return!!a&&b.parent.type.name===this.name&&(!!c||!b.parent.textContent.length)&&this.editor.commands.clearNodes()},Tab:({editor:a})=>{var b;if(!this.options.enableTabIndentation)return!1;let c=null!=(b=this.options.tabSize)?b:4,{state:d}=a,{selection:e}=d,{$from:f,empty:g}=e;if(f.parent.type!==this.type)return!1;let h=" ".repeat(c);return g?a.commands.insertContent(h):a.commands.command(({tr:a})=>{let{from:b,to:c}=e,f=d.doc.textBetween(b,c,"\n","\n").split("\n").map(a=>h+a).join("\n");return a.replaceWith(b,c,d.schema.text(f)),!0})},"Shift-Tab":({editor:a})=>{var b;if(!this.options.enableTabIndentation)return!1;let c=null!=(b=this.options.tabSize)?b:4,{state:d}=a,{selection:e}=d,{$from:f,empty:g}=e;return f.parent.type===this.type&&(g?a.commands.command(({tr:a})=>{var b;let{pos:e}=f,g=f.start(),h=f.end(),i=d.doc.textBetween(g,h,"\n","\n").split("\n"),j=0,k=0,l=e-g;for(let a=0;a<i.length;a+=1){if(k+i[a].length>=l){j=a;break}k+=i[a].length+1}let m=Math.min(((null==(b=i[j].match(/^ */))?void 0:b[0])||"").length,c);if(0===m)return!0;let n=g;for(let a=0;a<j;a+=1)n+=i[a].length+1;return a.delete(n,n+m),e-n<=m&&a.setSelection(fH.create(a.doc,n)),!0}):a.commands.command(({tr:a})=>{let{from:b,to:f}=e,g=d.doc.textBetween(b,f,"\n","\n").split("\n").map(a=>{var b;let d=Math.min(((null==(b=a.match(/^ */))?void 0:b[0])||"").length,c);return a.slice(d)}).join("\n");return a.replaceWith(b,f,d.schema.text(g)),!0}))},Enter:({editor:a})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:b}=a,{selection:c}=b,{$from:d,empty:e}=c;if(!e||d.parent.type!==this.type)return!1;let f=d.parentOffset===d.parent.nodeSize-2,g=d.parent.textContent.endsWith("\n\n");return!!f&&!!g&&a.chain().command(({tr:a})=>(a.delete(d.pos-2,d.pos),!0)).exitCode().run()},ArrowDown:({editor:a})=>{if(!this.options.exitOnArrowDown)return!1;let{state:b}=a,{selection:c,doc:d}=b,{$from:e,empty:f}=c;if(!f||e.parent.type!==this.type||e.parentOffset!==e.parent.nodeSize-2)return!1;let g=e.after();return void 0!==g&&(d.nodeAt(g)?a.commands.command(({tr:a})=>(a.setSelection(fD.near(d.resolve(g))),!0)):a.commands.exitCode())}}},addInputRules(){return[mm({find:r0,type:this.type,getAttributes:a=>({language:a[1]})}),mm({find:r1,type:this.type,getAttributes:a=>({language:a[1]})})]},addProseMirrorPlugins(){return[new fV({key:new fY("codeBlockVSCodeHandler"),props:{handlePaste:(a,b)=>{if(!b.clipboardData||this.editor.isActive(this.type.name))return!1;let c=b.clipboardData.getData("text/plain"),d=b.clipboardData.getData("vscode-editor-data"),e=d?JSON.parse(d):void 0,f=null==e?void 0:e.mode;if(!c||!f)return!1;let{tr:g,schema:h}=a.state,i=h.text(c.replace(/\r\n?/g,"\n"));return g.replaceSelectionWith(this.type.create({language:f},i)),g.selection.$from.parent.type!==this.type&&g.setSelection(fH.near(g.doc.resolve(Math.max(0,g.selection.from-2)))),g.setMeta("paste",!0),a.dispatch(g),!0}}})]}}),r3=my.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(a,b)=>a.content?b.renderChildren(a.content,"\n\n"):""}),r4=my.create({name:"hardBreak",markdownTokenName:"br",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:a}){return["br",ld(this.options.HTMLAttributes,a)]},renderText:()=>"\n",renderMarkdown:()=>`
127
- `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:a,chain:b,state:c,editor:d})=>a.first([()=>a.exitCode(),()=>a.command(()=>{let{selection:a,storedMarks:e}=c;if(a.$from.parent.type.spec.isolating)return!1;let{keepMarks:f}=this.options,{splittableMarks:g}=d.extensionManager,h=e||a.$to.parentOffset&&a.$from.marks();return b().insertContent({type:this.name}).command(({tr:a,dispatch:b})=>{if(b&&h&&f){let b=h.filter(a=>g.includes(a.type.name));a.ensureMarks(b)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),r5=my.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map(a=>({tag:`h${a}`,attrs:{level:a}}))},renderHTML({node:a,HTMLAttributes:b}){let c=this.options.levels.includes(a.attrs.level)?a.attrs.level:this.options.levels[0];return[`h${c}`,ld(this.options.HTMLAttributes,b),0]},parseMarkdown:(a,b)=>b.createNode("heading",{level:a.depth||1},b.parseInline(a.tokens||[])),renderMarkdown:(a,b)=>{var c;let d=(null==(c=a.attrs)?void 0:c.level)?parseInt(a.attrs.level,10):1,e="#".repeat(d);return a.content?`${e} ${b.renderChildren(a.content)}`:""},addCommands(){return{setHeading:a=>({commands:b})=>!!this.options.levels.includes(a.level)&&b.setNode(this.name,a),toggleHeading:a=>({commands:b})=>!!this.options.levels.includes(a.level)&&b.toggleNode(this.name,"paragraph",a)}},addKeyboardShortcuts(){return this.options.levels.reduce((a,b)=>({...a,[`Mod-Alt-${b}`]:()=>this.editor.commands.toggleHeading({level:b})}),{})},addInputRules(){return this.options.levels.map(a=>mm({find:RegExp(`^(#{${Math.min(...this.options.levels)},${a}})\\s$`),type:this.type,getAttributes:{level:a}}))}}),r6=my.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{},nextNodeType:"paragraph"}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:a}){return["hr",ld(this.options.HTMLAttributes,a)]},markdownTokenName:"hr",parseMarkdown:(a,b)=>b.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:a,state:b})=>{if(!function(a,b){let{selection:c}=a,{$from:d}=c;if(c instanceof fJ){let a=d.index();return d.parent.canReplaceWith(a,a+1,b)}let e=d.depth;for(;e>=0;){let a=d.index(e);if(d.node(e).contentMatchAt(a).matchType(b))return!0;e-=1}return!1}(b,b.schema.nodes[this.name]))return!1;let{selection:c}=b,{$to:d}=c,e=a();return lw(c)?e.insertContentAt(d.pos,{type:this.name}):e.insertContent({type:this.name}),e.command(({state:a,tr:b,dispatch:c})=>{if(c){let{$to:c}=b.selection,d=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?b.setSelection(fH.create(b.doc,c.pos+1)):c.nodeAfter.isBlock?b.setSelection(fJ.create(b.doc,c.pos)):b.setSelection(fH.create(b.doc,c.pos));else{let e=a.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,f=null==e?void 0:e.create();f&&(b.insert(d,f),b.setSelection(fH.create(b.doc,d+1)))}b.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ml({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),r7=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,r8=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,r9=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,sa=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,sb=l1.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:a=>"normal"!==a.style.fontStyle&&null},{style:"font-style=normal",clearMark:a=>a.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:a}){return["em",ld(this.options.HTMLAttributes,a),0]},addCommands(){return{setItalic:()=>({commands:a})=>a.setMark(this.name),toggleItalic:()=>({commands:a})=>a.toggleMark(this.name),unsetItalic:()=>({commands:a})=>a.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(a,b)=>b.applyMark("italic",b.parseInline(a.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(a,b)=>`*${b.renderChildren(a)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[mk({find:r7,type:this.type}),mk({find:r9,type:this.type})]},addPasteRules(){return[mA({find:r8,type:this.type}),mA({find:sa,type:this.type})]}}),sc="&nbsp;",sd=my.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:a}){return["p",ld(this.options.HTMLAttributes,a),0]},parseMarkdown:(a,b)=>{let c=a.tokens||[];if(1===c.length&&"image"===c[0].type)return b.parseChildren([c[0]]);let d=b.parseInline(c);return 1===c.length&&"text"===c[0].type&&(c[0].raw===sc||c[0].text===sc||" "===c[0].raw||" "===c[0].text)&&1===d.length&&"text"===d[0].type&&(d[0].text===sc||" "===d[0].text)?b.createNode("paragraph",void 0,[]):b.createNode("paragraph",void 0,d)},renderMarkdown:(a,b,c)=>{var d,e;if(!a)return"";let f=Array.isArray(a.content)?a.content:[];if(0===f.length){let a=Array.isArray(null==(d=null==c?void 0:c.previousNode)?void 0:d.content)?c.previousNode.content:[];return(null==(e=null==c?void 0:c.previousNode)?void 0:e.type)==="paragraph"&&0===a.length?sc:""}return b.renderChildren(f)},addCommands(){return{setParagraph:()=>({commands:a})=>a.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),se=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,sf=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,sg=l1.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:a=>!!a.includes("line-through")&&{}}],renderHTML({HTMLAttributes:a}){return["s",ld(this.options.HTMLAttributes,a),0]},markdownTokenName:"del",parseMarkdown:(a,b)=>b.applyMark("strike",b.parseInline(a.tokens||[])),renderMarkdown:(a,b)=>`~~${b.renderChildren(a)}~~`,addCommands(){return{setStrike:()=>({commands:a})=>a.setMark(this.name),toggleStrike:()=>({commands:a})=>a.toggleMark(this.name),unsetStrike:()=>({commands:a})=>a.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[mk({find:se,type:this.type})]},addPasteRules(){return[mA({find:sf,type:this.type})]}}),sh=my.create({name:"text",group:"inline",parseMarkdown:a=>({type:"text",text:a.text||""}),renderMarkdown:a=>a.text||""}),si=l1.create({name:"underline",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:a=>!!a.includes("underline")&&{}}],renderHTML({HTMLAttributes:a}){return["u",ld(this.options.HTMLAttributes,a),0]},parseMarkdown(a,b){return b.applyMark(this.name||"underline",b.parseInline(a.tokens||[]))},renderMarkdown:(a,b)=>`++${b.renderChildren(a)}++`,markdownTokenizer:{name:"underline",level:"inline",start:a=>a.indexOf("++"),tokenize(a,b,c){let d=/^(\+\+)([\s\S]+?)(\+\+)/.exec(a);if(!d)return;let e=d[2].trim();return{type:"underline",raw:d[0],text:e,tokens:c.inlineTokens(e)}}},addCommands(){return{setUnderline:()=>({commands:a})=>a.setMark(this.name),toggleUnderline:()=>({commands:a})=>a.toggleMark(this.name),unsetUnderline:()=>({commands:a})=>a.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),sj=l5.create({name:"starterKit",addExtensions(){var a,b,c,d;let e=[];return!1!==this.options.bold&&e.push(rY.configure(this.options.bold)),!1!==this.options.blockquote&&e.push(rT.configure(this.options.blockquote)),!1!==this.options.bulletList&&e.push(rs.configure(this.options.bulletList)),!1!==this.options.code&&e.push(r_.configure(this.options.code)),!1!==this.options.codeBlock&&e.push(r2.configure(this.options.codeBlock)),!1!==this.options.document&&e.push(r3.configure(this.options.document)),!1!==this.options.dropcursor&&e.push(q0.configure(this.options.dropcursor)),!1!==this.options.gapcursor&&e.push(q1.configure(this.options.gapcursor)),!1!==this.options.hardBreak&&e.push(r4.configure(this.options.hardBreak)),!1!==this.options.heading&&e.push(r5.configure(this.options.heading)),!1!==this.options.undoRedo&&e.push(ra.configure(this.options.undoRedo)),!1!==this.options.horizontalRule&&e.push(r6.configure(this.options.horizontalRule)),!1!==this.options.italic&&e.push(sb.configure(this.options.italic)),!1!==this.options.listItem&&e.push(rt.configure(this.options.listItem)),!1!==this.options.listKeymap&&e.push(rH.configure(null==(a=this.options)?void 0:a.listKeymap)),!1!==this.options.link&&e.push(qB.configure(null==(b=this.options)?void 0:b.link)),!1!==this.options.orderedList&&e.push(rM.configure(this.options.orderedList)),!1!==this.options.paragraph&&e.push(sd.configure(this.options.paragraph)),!1!==this.options.strike&&e.push(sg.configure(this.options.strike)),!1!==this.options.text&&e.push(sh.configure(this.options.text)),!1!==this.options.underline&&e.push(si.configure(null==(c=this.options)?void 0:c.underline)),!1!==this.options.trailingNode&&e.push(q9.configure(null==(d=this.options)?void 0:d.trailingNode)),e}});function sk(a){let b=a.regex,c={};Object.assign(c,{className:"variable",variants:[{begin:b.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},{begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[c]}]}]});let d={className:"subst",begin:/\$\(/,end:/\)/,contains:[a.BACKSLASH_ESCAPE]},e=a.inherit(a.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),f={begin:/<<-?\s*(?=\w+)/,starts:{contains:[a.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},g={className:"string",begin:/"/,end:/"/,contains:[a.BACKSLASH_ESCAPE,c,d]};d.contains.push(g);let h={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},a.NUMBER_MODE,c]},i=a.SHEBANG({binary:"(fish|bash|zsh|sh|csh|ksh|tcsh|dash|scsh)",relevance:10}),j={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[a.inherit(a.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0};return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],literal:["true","false"],built_in:["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset","alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias","set","shopt","autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp","chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"]},contains:[i,a.SHEBANG(),j,h,e,f,{match:/(\/[a-z._-]+)+/},g,{match:/\\"/},{className:"string",begin:/'/,end:/'/},{match:/\\'/},c]}}let sl=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video","defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],sm=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),sn=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),so=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),sp=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function sq(a){let b=a.regex,c={IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:a.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[a.APOS_STRING_MODE,a.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:a.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}},d=[a.APOS_STRING_MODE,a.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[c.BLOCK_COMMENT,{begin:/-(webkit|moz|ms|o)-(?=[a-z])/},c.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\.[a-zA-Z-][a-zA-Z0-9_-]*",relevance:0},c.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+sn.join("|")+")"},{begin:":(:)?("+so.join("|")+")"}]},c.CSS_VARIABLE,{className:"attribute",begin:"\\b("+sp.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[c.BLOCK_COMMENT,c.HEXCOLOR,c.IMPORTANT,c.CSS_NUMBER_MODE,...d,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...d,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},c.FUNCTION_DISPATCH]},{begin:b.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:/@-?\w[\w]*(-\w+)*/},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:"and or not only",attribute:sm.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...d,c.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+sl.join("|")+")\\b"}]}}function sr(a){let b={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:b,illegal:"</",contains:[a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,{className:"string",variants:[a.QUOTE_STRING_MODE,a.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[a.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:b,illegal:/["']/}]}]}}let ss="[A-Za-z$_][0-9A-Za-z$_]*",st=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],su=["true","false","null","undefined","NaN","Infinity"],sv=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],sw=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],sx=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],sy=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],sz=[].concat(sx,sv,sw);function sA(a){var b;let c=a.regex,d=/<[A-Za-z0-9\\._:-]+/,e=/\/[A-Za-z0-9\\._:-]+>|\/>/,f={$pattern:ss,keyword:st,literal:su,built_in:sz,"variable.language":sy},g="[0-9](_?[0-9])*",h=`\\.(${g})`,i="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",j={className:"number",variants:[{begin:`(\\b(${i})((${h})|\\.)?|(${h}))[eE][+-]?(${g})\\b`},{begin:`\\b(${i})\\b((${h})\\b|\\.)?|(${h})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},k={className:"subst",begin:"\\$\\{",end:"\\}",keywords:f,contains:[]},l={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[a.BACKSLASH_ESCAPE,k],subLanguage:"xml"}},m={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[a.BACKSLASH_ESCAPE,k],subLanguage:"css"}},n={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[a.BACKSLASH_ESCAPE,k],subLanguage:"graphql"}},o={className:"string",begin:"`",end:"`",contains:[a.BACKSLASH_ESCAPE,k]},p={className:"comment",variants:[a.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:ss+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),a.C_BLOCK_COMMENT_MODE,a.C_LINE_COMMENT_MODE]},q=[a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,l,m,n,o,{match:/\$\d+/},j];k.contains=q.concat({begin:/\{/,end:/\}/,keywords:f,contains:["self"].concat(q)});let r=[].concat(p,k.contains),s=r.concat([{begin:/(\s*)\(/,end:/\)/,keywords:f,contains:["self"].concat(r)}]),t={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:f,contains:s},u={variants:[{match:[/class/,/\s+/,ss,/\s+/,/extends/,/\s+/,c.concat(ss,"(",c.concat(/\./,ss),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,ss],scope:{1:"keyword",3:"title.class"}}]},v={relevance:0,match:c.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...sv,...sw]}},w={match:c.concat(/\b/,(b=[...sx,"super","import"].map(a=>`${a}\\s*\\(`),c.concat("(?!",b.join("|"),")")),ss,c.lookahead(/\s*\(/)),className:"title.function",relevance:0},x={begin:c.concat(/\./,c.lookahead(c.concat(ss,/(?![0-9A-Za-z$_(])/))),end:ss,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},y="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+a.UNDERSCORE_IDENT_RE+")\\s*=>",z={match:[/const|var|let/,/\s+/,ss,/\s*/,/=\s*/,/(async\s*)?/,c.lookahead(y)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[t]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:f,exports:{PARAMS_CONTAINS:s,CLASS_REFERENCE:v},illegal:/#(?![$_A-z])/,contains:[a.SHEBANG({label:"shebang",binary:"node",relevance:5}),{label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,l,m,n,o,p,{match:/\$\d+/},j,v,{scope:"attr",match:ss+c.lookahead(":"),relevance:0},z,{begin:"("+a.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[p,a.REGEXP_MODE,{className:"function",begin:y,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:a.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:f,contains:s}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:"<>",end:"</>"},{match:/<[A-Za-z0-9\\._:-]+\s*\/>/},{begin:d,"on:begin":(a,b)=>{let c,d=a[0].length+a.index,e=a.input[d];if("<"===e||","===e)return void b.ignoreMatch();">"!==e||((a,{after:b})=>{let c="</"+a[0].slice(1);return -1!==a.input.indexOf(c,b)})(a,{after:d})||b.ignoreMatch();let f=a.input.substring(d);if((c=f.match(/^\s*=/))||(c=f.match(/^\s+extends\s+/))&&0===c.index)return void b.ignoreMatch()},end:e}],subLanguage:"xml",contains:[{begin:d,end:e,skip:!0,contains:["self"]}]}]},{variants:[{match:[/function/,/\s+/,ss,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[t],illegal:/%/},{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+a.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[t,a.inherit(a.TITLE_MODE,{begin:ss,className:"title.function"})]},{match:/\.\.\./,relevance:0},x,{match:"\\$"+ss,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[t]},w,{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},u,{match:[/get|set/,/\s+/,ss,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},t]},{match:/\$[(.]/}]}}function sB(a){let b=["true","false","null"],c={scope:"literal",beginKeywords:b.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:b},contains:[{className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},{match:/[{}[\],:]/,className:"punctuation",relevance:0},a.QUOTE_STRING_MODE,c,a.C_NUMBER_MODE,a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function sC(a){let b=a.regex,c={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},d={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:b.concat(/\[.+?\]\(/,/[A-Za-z][A-Za-z0-9+.-]*/,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},e={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},f={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},g=a.inherit(e,{contains:[]}),h=a.inherit(f,{contains:[]});e.contains.push(h),f.contains.push(g);let i=[c,d];return[e,f,g,h].forEach(a=>{a.contains=a.contains.concat(i)}),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:i=i.concat(e,f)},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:i}]}]},c,{className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},e,f,{className:"quote",begin:"^>\\s+",contains:i,end:"$"},{className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},{begin:"^[-\\*]{3,}",end:"$"},d,{begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function sD(a){let b=a.regex,c=/[\p{XID_Start}_]\p{XID_Continue}*/u,d=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],e={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:d,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},f={className:"meta",begin:/^(>>>|\.\.\.) /},g={className:"subst",begin:/\{/,end:/\}/,keywords:e,illegal:/#/},h={begin:/\{\{/,relevance:0},i={className:"string",contains:[a.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[a.BACKSLASH_ESCAPE,f],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[a.BACKSLASH_ESCAPE,f],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[a.BACKSLASH_ESCAPE,f,h,g]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[a.BACKSLASH_ESCAPE,f,h,g]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[a.BACKSLASH_ESCAPE,h,g]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[a.BACKSLASH_ESCAPE,h,g]},a.APOS_STRING_MODE,a.QUOTE_STRING_MODE]},j="[0-9](_?[0-9])*",k=`(\\b(${j}))?\\.(${j})|\\b(${j})\\.`,l=`\\b|${d.join("|")}`,m={className:"number",relevance:0,variants:[{begin:`(\\b(${j})|(${k}))[eE][+-]?(${j})[jJ]?(?=${l})`},{begin:`(${k})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${l})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${l})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${l})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${l})`},{begin:`\\b(${j})[jJ](?=${l})`}]},n={className:"comment",begin:b.lookahead(/# type:/),end:/$/,keywords:e,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},o={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:e,contains:["self",f,m,i,a.HASH_COMMENT_MODE]}]};return g.contains=[i,m,f],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:e,illegal:/(<\/|\?)|=>/,contains:[f,m,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},i,n,a.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,c],scope:{1:"keyword",3:"title.function"},contains:[o]},{variants:[{match:[/\bclass/,/\s+/,c,/\s*/,/\(\s*/,c,/\s*\)/]},{match:[/\bclass/,/\s+/,c]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[m,o,i]}]}}function sE(a){let b=a.regex,c=/(r#)?/,d=b.concat(c,a.UNDERSCORE_IDENT_RE),e=b.concat(c,a.IDENT_RE),f={className:"title.function.invoke",relevance:0,begin:b.concat(/\b/,/(?!let|for|while|if|else|match\b)/,e,b.lookahead(/\s*\(/))},g="([ui](8|16|32|64|128|size)|f(32|64))?",h=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],i=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:a.IDENT_RE+"!?",type:i,keyword:["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],literal:["true","false","Some","None","Ok","Err"],built_in:h},illegal:"</",contains:[a.C_LINE_COMMENT_MODE,a.COMMENT("/\\*","\\*/",{contains:["self"]}),a.inherit(a.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+g},{begin:"\\b0o([0-7_]+)"+g},{begin:"\\b0x([A-Fa-f0-9_]+)"+g},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+g}],relevance:0},{begin:[/fn/,/\s+/,d],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[a.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,d],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,d,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,d],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,d],className:{1:"keyword",3:"title.class"}},{begin:a.IDENT_RE+"::",keywords:{keyword:"Self",built_in:h,type:i}},{className:"punctuation",begin:"->"},f]}}function sF(a){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function sG(a){let b=a.regex,c=a.COMMENT("--","$"),d=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],e=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year","add","asc","collation","desc","final","first","last","view"].filter(a=>!d.includes(a)),f={match:b.concat(/\b/,b.either(...d),/\s*\(/),relevance:0,keywords:{built_in:d}};function g(a){return b.concat(/\b/,b.either(...a.map(a=>a.replace(/\s+/,"\\s+"))),/\b/)}let h={scope:"keyword",match:g(["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"]),relevance:0};return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:function(a,{exceptions:b,when:c}={}){return b=b||[],a.map(a=>a.match(/\|\d+$/)||b.includes(a)?a:c(a)?`${a}|0`:a)}(e,{when:a=>a.length<3}),literal:["true","false","unknown"],type:["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],built_in:["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"]},contains:[{scope:"type",match:g(["double precision","large object","with timezone","without timezone"])},h,f,{scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},{scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},{begin:/"/,end:/"/,contains:[{match:/""/}]},a.C_NUMBER_MODE,a.C_BLOCK_COMMENT_MODE,c,{scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0}]}}let sH="[A-Za-z$_][0-9A-Za-z$_]*",sI=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],sJ=["true","false","null","undefined","NaN","Infinity"],sK=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],sL=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],sM=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],sN=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],sO=[].concat(sM,sK,sL);function sP(a){var b;let c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B=a.regex,C=(c=a.regex,d=/<[A-Za-z0-9\\._:-]+/,e=/\/[A-Za-z0-9\\._:-]+>|\/>/,f=(a,b)=>{let c,d=a[0].length+a.index,e=a.input[d];if("<"===e||","===e)return void b.ignoreMatch();">"!==e||((a,{after:b})=>{let c="</"+a[0].slice(1);return -1!==a.input.indexOf(c,b)})(a,{after:d})||b.ignoreMatch();let f=a.input.substring(d);if((c=f.match(/^\s*=/))||(c=f.match(/^\s+extends\s+/))&&0===c.index)return void b.ignoreMatch()},g={$pattern:sH,keyword:sI,literal:sJ,built_in:sO,"variable.language":sN},h="[0-9](_?[0-9])*",i=`\\.(${h})`,j="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",k={className:"number",variants:[{begin:`(\\b(${j})((${i})|\\.)?|(${i}))[eE][+-]?(${h})\\b`},{begin:`\\b(${j})\\b((${i})\\b|\\.)?|(${i})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},l={className:"subst",begin:"\\$\\{",end:"\\}",keywords:g,contains:[]},m={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[a.BACKSLASH_ESCAPE,l],subLanguage:"xml"}},n={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[a.BACKSLASH_ESCAPE,l],subLanguage:"css"}},o={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[a.BACKSLASH_ESCAPE,l],subLanguage:"graphql"}},p={className:"string",begin:"`",end:"`",contains:[a.BACKSLASH_ESCAPE,l]},q={className:"comment",variants:[a.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:sH+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),a.C_BLOCK_COMMENT_MODE,a.C_LINE_COMMENT_MODE]},l.contains=(r=[a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,m,n,o,p,{match:/\$\d+/},k]).concat({begin:/\{/,end:/\}/,keywords:g,contains:["self"].concat(r)}),t=(s=[].concat(q,l.contains)).concat([{begin:/(\s*)\(/,end:/\)/,keywords:g,contains:["self"].concat(s)}]),u={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:g,contains:t},v={variants:[{match:[/class/,/\s+/,sH,/\s+/,/extends/,/\s+/,c.concat(sH,"(",c.concat(/\./,sH),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,sH],scope:{1:"keyword",3:"title.class"}}]},w={relevance:0,match:c.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...sK,...sL]}},x={match:c.concat(/\b/,(b=[...sM,"super","import"].map(a=>`${a}\\s*\\(`),c.concat("(?!",b.join("|"),")")),sH,c.lookahead(/\s*\(/)),className:"title.function",relevance:0},y={begin:c.concat(/\./,c.lookahead(c.concat(sH,/(?![0-9A-Za-z$_(])/))),end:sH,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},z="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+a.UNDERSCORE_IDENT_RE+")\\s*=>",A={match:[/const|var|let/,/\s+/,sH,/\s*/,/=\s*/,/(async\s*)?/,c.lookahead(z)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[u]},{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:g,exports:{PARAMS_CONTAINS:t,CLASS_REFERENCE:w},illegal:/#(?![$_A-z])/,contains:[a.SHEBANG({label:"shebang",binary:"node",relevance:5}),{label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,m,n,o,p,q,{match:/\$\d+/},k,w,{scope:"attr",match:sH+c.lookahead(":"),relevance:0},A,{begin:"("+a.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[q,a.REGEXP_MODE,{className:"function",begin:z,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:a.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:g,contains:t}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:"<>",end:"</>"},{match:/<[A-Za-z0-9\\._:-]+\s*\/>/},{begin:d,"on:begin":f,end:e}],subLanguage:"xml",contains:[{begin:d,end:e,skip:!0,contains:["self"]}]}]},{variants:[{match:[/function/,/\s+/,sH,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[u],illegal:/%/},{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+a.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[u,a.inherit(a.TITLE_MODE,{begin:sH,className:"title.function"})]},{match:/\.\.\./,relevance:0},y,{match:"\\$"+sH,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[u]},x,{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},v,{match:[/get|set/,/\s+/,sH,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},u]},{match:/\$[(.]/}]}),D=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],E={begin:[/namespace/,/\s+/,a.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},F={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:D},contains:[C.exports.CLASS_REFERENCE]},G={$pattern:sH,keyword:sI.concat(["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"]),literal:sJ,built_in:sO.concat(D),"variable.language":sN},H={className:"meta",begin:"@"+sH},I=(a,b,c)=>{let d=a.contains.findIndex(a=>a.label===b);if(-1===d)throw Error("can not find mode to replace");a.contains.splice(d,1,c)};Object.assign(C.keywords,G),C.exports.PARAMS_CONTAINS.push(H);let J=C.contains.find(a=>"attr"===a.scope),K=Object.assign({},J,{match:B.concat(sH,B.lookahead(/\s*\?:/))});return C.exports.PARAMS_CONTAINS.push([C.exports.CLASS_REFERENCE,J,K]),C.contains=C.contains.concat([H,E,F,K]),I(C,"shebang",a.SHEBANG()),I(C,"use_strict",{className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/}),C.contains.find(a=>"func.def"===a.label).relevance=0,Object.assign(C,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),C}function sQ(a){let b=a.regex,c=b.concat(/[\p{L}_]/u,b.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),d={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},e={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},f=a.inherit(e,{begin:/\(/,end:/\)/}),g=a.inherit(a.APOS_STRING_MODE,{className:"string"}),h=a.inherit(a.QUOTE_STRING_MODE,{className:"string"}),i={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:/[\p{L}0-9._:-]+/u,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[d]},{begin:/'/,end:/'/,contains:[d]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[e,h,g,f,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[e,f,h,g]}]}]},a.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},d,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[h]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[i],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[i],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:b.concat(/</,b.lookahead(b.concat(c,b.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:c,relevance:0,starts:i}]},{className:"tag",begin:b.concat(/<\//,b.lookahead(b.concat(c,/>/))),contains:[{className:"name",begin:c,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function sR(a){let b="true false yes no null",c="[\\w#;/?:@&=+$,.~*'()[\\]]+",d={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[a.BACKSLASH_ESCAPE,{className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]}]},e=a.inherit(d,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),f={end:",",endsWithParent:!0,excludeEnd:!0,keywords:b,relevance:0},g=[{className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+c},{className:"type",begin:"!<"+c+">"},{className:"type",begin:"!"+c},{className:"type",begin:"!!"+c},{className:"meta",begin:"&"+a.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+a.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},a.HASH_COMMENT_MODE,{beginKeywords:b,keywords:{literal:b}},{className:"number",begin:"\\b[0-9]{4}(-[0-9][0-9]){0,2}([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?(\\.[0-9]*)?([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?\\b"},{className:"number",begin:a.C_NUMBER_RE+"\\b",relevance:0},{begin:/\{/,end:/\}/,contains:[f],illegal:"\\n",relevance:0},{begin:"\\[",end:"\\]",contains:[f],illegal:"\\n",relevance:0},{className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},d],h=[...g];return h.pop(),h.push(e),f.contains=h,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:g}}var sS=a.i(451949);let sT=a.i(752344).default,sU={};function sV(a){let b=sT.newInstance();return a&&e(a),{highlight:c,highlightAuto:function(a,e){let f;(0,sS.ok)("string"==typeof a,"expected `string` as `value`");let g=(e||sU).subset||d(),h=-1,i=0;for(;++h<g.length;){let d=g[h];if(!b.getLanguage(d))continue;let j=c(d,a,e);j.data&&void 0!==j.data.relevance&&j.data.relevance>i&&(i=j.data.relevance,f=j)}return f||{type:"root",children:[],data:{language:void 0,relevance:i}}},listLanguages:d,register:e,registerAlias:function(a,c){if("string"==typeof a)(0,sS.ok)(void 0!==c),b.registerAliases("string"==typeof c?c:[...c],{languageName:a});else{let c;for(c in a)if(Object.hasOwn(a,c)){let d=a[c];b.registerAliases("string"==typeof d?d:[...d],{languageName:c})}}},registered:function(a){return!!b.getLanguage(a)}};function c(a,c,d){(0,sS.ok)("string"==typeof a,"expected `string` as `name`"),(0,sS.ok)("string"==typeof c,"expected `string` as `value`");let e=d||sU,f="string"==typeof e.prefix?e.prefix:"hljs-";if(!b.getLanguage(a))throw Error("Unknown language: `"+a+"` is not registered");b.configure({__emitter:sW,classPrefix:f});let g=b.highlight(c,{ignoreIllegals:!0,language:a});if(g.errorRaised)throw Error("Could not highlight with `Highlight.js`",{cause:g.errorRaised});let h=g._emitter.root,i=h.data;return i.language=g.language,i.relevance=g.relevance,h}function d(){return b.listLanguages()}function e(a,c){if("string"==typeof a)(0,sS.ok)(void 0!==c,"expected `grammar`"),b.registerLanguage(a,c);else{let c;for(c in a)Object.hasOwn(a,c)&&b.registerLanguage(c,a[c])}}}class sW{constructor(a){this.options=a,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(a){if(""===a)return;let b=this.stack[this.stack.length-1],c=b.children[b.children.length-1];c&&"text"===c.type?c.value+=a:b.children.push({type:"text",value:a})}startScope(a){this.openNode(String(a))}endScope(){this.closeNode()}__addSublanguage(a,b){let c=this.stack[this.stack.length-1],d=a.root.children;b?c.children.push({type:"element",tagName:"span",properties:{className:[b]},children:d}):c.children.push(...d)}openNode(a){let b=this,c=a.split(".").map(function(a,c){return c?a+"_".repeat(c):b.options.classPrefix+a}),d=this.stack[this.stack.length-1],e={type:"element",tagName:"span",properties:{className:c},children:[]};d.children.push(e),this.stack.push(e)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}let sX=my.create({name:"callout",group:"block",content:"block+",defining:!0,addAttributes:()=>({type:{default:"info",parseHTML:a=>a.getAttribute("data-callout-type")||"info",renderHTML:a=>({"data-callout-type":a.type})}}),parseHTML:()=>[{tag:'div[data-callout="true"]'}],renderHTML:({HTMLAttributes:a})=>["div",ld(a,{"data-callout":"true",class:`callout callout-${a["data-callout-type"]||"info"}`}),0]});function sY(a,b,c){let{selection:d,doc:e}=a,f=e.resolve(d.from);for(;f.depth>1;)f=e.resolve(f.before(f.depth));if(0===f.depth)return!1;let g=f.before(1),h=e.nodeAt(g);if(!h)return!1;let i=f.index(0),j="up"===c?i-1:i+1;if(j<0||j>=e.childCount)return!1;let k=e.child(j),l=a.tr,m=g+h.nodeSize,n="up"===c?g-k.nodeSize:m,o="up"===c?g:m+k.nodeSize;if("up"===c)l=(l=(l=l.delete(g,m)).insert(n,h)).setSelection(fJ.create(l.doc,n));else{l=l.delete(g,m);let a=o-h.nodeSize;l=(l=l.insert(a,h)).setSelection(fJ.create(l.doc,a))}return b&&b(l.scrollIntoView()),!0}let sZ="cabinet-drag-handle",s$="cabinet-gutter-add",s_=l5.create({name:"dragHandle",addKeyboardShortcuts:()=>({"Mod-Alt-ArrowUp":({editor:a})=>sY(a.state,a.view.dispatch,"up"),"Mod-Alt-ArrowDown":({editor:a})=>sY(a.state,a.view.dispatch,"down"),"Alt-Shift-ArrowUp":({editor:a})=>sY(a.state,a.view.dispatch,"up"),"Alt-Shift-ArrowDown":({editor:a})=>sY(a.state,a.view.dispatch,"down")}),addProseMirrorPlugins(){let a,b,c=null,d="u">typeof document?((a=document.getElementById(sZ))||((a=document.createElement("div")).id=sZ,a.setAttribute("data-drag-handle","true"),a.draggable=!0,a.innerHTML='<svg width="10" height="16" viewBox="0 0 10 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><circle cx="2.5" cy="3" r="1.2"/><circle cx="2.5" cy="8" r="1.2"/><circle cx="2.5" cy="13" r="1.2"/><circle cx="7.5" cy="3" r="1.2"/><circle cx="7.5" cy="8" r="1.2"/><circle cx="7.5" cy="13" r="1.2"/></svg>',Object.assign(a.style,{position:"absolute",display:"none",cursor:"grab",padding:"2px 4px",borderRadius:"4px",color:"var(--muted-foreground)",opacity:"0.55",zIndex:"40",userSelect:"none",transition:"opacity 120ms ease"}),a.addEventListener("mouseenter",()=>{a&&(a.style.opacity="1")}),a.addEventListener("mouseleave",()=>{a&&(a.style.opacity="0.55")}),document.body.appendChild(a)),a):null,e="u">typeof document?((b=document.getElementById(s$))||((b=document.createElement("button")).id=s$,b.type="button",b.setAttribute("aria-label","Add block"),b.title="Add block",b.innerHTML='<svg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5 1V9M1 5H9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>',Object.assign(b.style,{position:"absolute",display:"none",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",cursor:"pointer",borderRadius:"4px",color:"var(--muted-foreground)",opacity:"0.55",zIndex:"40",transition:"opacity 120ms ease, background 120ms ease",background:"transparent",border:"none",padding:"0"}),b.addEventListener("mouseenter",()=>{b&&(b.style.opacity="1",b.style.background="var(--muted)")}),b.addEventListener("mouseleave",()=>{b&&(b.style.opacity="0.55",b.style.background="transparent")}),document.body.appendChild(b)),b):null,f=()=>{d&&(d.style.display="none"),e&&(e.style.display="none"),c=null};return[new fV({key:new fY("cabinetDragHandle"),view:a=>{if(!d)return{destroy:()=>{}};let b=b=>{if(!a.editable)return;let g=a.dom.getBoundingClientRect();if(b.clientX<g.left-60||b.clientX>g.right+60||b.clientY<g.top||b.clientY>g.bottom)return void f();let h=function(a,b){let c=a.posAtCoords(b);if(!c)return null;let d=a.state.doc.resolve(c.inside>=0?c.inside:c.pos);for(;d.depth>0&&!d.parent.type.isBlock;)d=a.state.doc.resolve(d.before());let e=d.depth;for(;e>1&&"doc"!==a.state.doc.resolve(d.before(e)).parent.type.name;)e-=1;let f=0===e?0:d.before(Math.max(e,1)),g=a.state.doc.nodeAt(f);if(!g)return null;let h=a.nodeDOM(f);return{pos:f,node:g,dom:h}}(a,{left:Math.max(g.left+20,Math.min(g.right-20,b.clientX)),top:b.clientY});if(!h?.dom||!(h.dom instanceof HTMLElement))return void f();c=h;let i=h.dom.getBoundingClientRect();d.style.display="flex",d.style.top=`${window.scrollY+i.top+4}px`,d.style.left=`${window.scrollX+i.left-22}px`,e&&(e.style.display="flex",e.style.top=`${window.scrollY+i.top+4}px`,e.style.left=`${window.scrollX+i.left-44}px`)},g=()=>f(),h=()=>{if(!c)return;let b=c.pos+c.node.nodeSize,d=b<=a.state.doc.content.size,e=a.state.tr;if(d){let c=fH.create(a.state.doc,Math.min(b-1,a.state.doc.content.size));a.dispatch(e.setSelection(c))}a.focus();let f=a.state.tr.split(a.state.selection.from);a.dispatch(f),a.dom.dispatchEvent(new KeyboardEvent("keydown",{key:"/",bubbles:!0,cancelable:!0}))},i=b=>{if(!c||!b.dataTransfer)return;let{pos:d,dom:e}=c,f=a.state.tr.setSelection(fJ.create(a.state.doc,d));a.dispatch(f);let g=a.state.selection.content(),h=document.createElement("div");h.appendChild(a.someProp("clipboardSerializer")?.serializeFragment(g.content)??document.createElement("div")),b.dataTransfer.clearData(),b.dataTransfer.setData("text/html",h.innerHTML),b.dataTransfer.setData("text/plain",e.textContent??""),b.dataTransfer.effectAllowed="copyMove",b.dataTransfer.setDragImage(e,0,0),a.dragging={slice:g,move:!0}};return window.addEventListener("mousemove",b),a.dom.addEventListener("mouseleave",g),d.addEventListener("dragstart",i),e&&e.addEventListener("click",h),{destroy(){window.removeEventListener("mousemove",b),a.dom.removeEventListener("mouseleave",g),d.removeEventListener("dragstart",i),e&&e.removeEventListener("click",h),f()}}}})]}}),s0=new fY("headingAnchors");function s1(a){let b=[],c=new Map;return a.descendants((a,d)=>{if("heading"!==a.type.name)return;let e=a.textContent.toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-");if(!e)return;let f=c.get(e)??0;c.set(e,f+1);let g=0===f?e:`${e}-${f}`;b.push(hZ.node(d,d+a.nodeSize,{id:g}))}),h0.create(a,b)}let s2=l5.create({name:"headingAnchors",addProseMirrorPlugins:()=>[new fV({key:s0,state:{init:(a,{doc:b})=>s1(b),apply:(a,b)=>a.docChanged?s1(a.doc):b},props:{decorations:a=>s0.getState(a)}})]});function s3(a){return a.value||a.children||[]}function s4({doc:a,name:b,lowlight:c,defaultLanguage:d}){let e=[];return k2(a,a=>a.type.name===b).forEach(a=>{var b;let f=a.pos+1,g=a.node.attrs.language||d,h=c.listLanguages();(function a(b,c=[]){return b.flatMap(b=>{let d=[...c,...b.properties?b.properties.className:[]];return b.children?a(b.children,d):{text:b.value,classes:d}})})(g&&(h.includes(g)||sT.getLanguage(g)||(null==(b=c.registered)?void 0:b.call(c,g)))?s3(c.highlight(g,a.node.textContent)):s3(c.highlightAuto(a.node.textContent))).forEach(a=>{let b=f+a.text.length;if(a.classes.length){let c=hZ.inline(f,b,{class:a.classes.join(" ")});e.push(c)}f=b})}),h0.create(a,e)}var s5=r2.extend({addOptions(){var a;return{...null==(a=this.parent)?void 0:a.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},addProseMirrorPlugins(){var a;return[...(null==(a=this.parent)?void 0:a.call(this))||[],function({name:a,lowlight:b,defaultLanguage:c}){if(!["highlight","highlightAuto","listLanguages"].every(a=>"function"==typeof b[a]))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");let d=new fV({key:new fY("lowlight"),state:{init:(d,{doc:e})=>s4({doc:e,name:a,lowlight:b,defaultLanguage:c}),apply:(d,e,f,g)=>{let h=f.selection.$head.parent.type.name,i=g.selection.$head.parent.type.name,j=k2(f.doc,b=>b.type.name===a),k=k2(g.doc,b=>b.type.name===a);return d.docChanged&&([h,i].includes(a)||k.length!==j.length||d.steps.some(a=>void 0!==a.from&&void 0!==a.to&&j.some(b=>b.pos>=a.from&&b.pos+b.node.nodeSize<=a.to)))?s4({doc:d.doc,name:a,lowlight:b,defaultLanguage:c}):e.map(d.mapping,d.doc)}},props:{decorations:a=>d.getState(a)}});return d}({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}});let s6=(0,h.default)("maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]),s7=(0,h.default)("minimize-2",[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]]),s8=(0,h.default)("zoom-in",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),s9=(0,h.default)("zoom-out",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);function ta({svg:a,className:b,allowPlainWheel:c,maxHeight:d,onExpand:e,onClose:f}){let[h,i]=(0,p.useState)(1),[j,k]=(0,p.useState)({x:0,y:0}),[l,m]=(0,p.useState)(!1),[n,o]=(0,p.useState)(d),q=(0,p.useRef)({x:0,y:0,panX:0,panY:0}),r=(0,p.useRef)(null);(0,p.useLayoutEffect)(()=>{if(null==d)return;let a=r.current?.querySelector("svg");if(!a)return;let b=a.getBoundingClientRect().height;b&&o(Math.min(Math.round(b)+32,d))},[a,d]);let s=(0,p.useCallback)(a=>{if(!(c||a.ctrlKey||a.metaKey))return;a.preventDefault();let b=a.deltaY>0?-.25:.25;i(a=>Math.min(Math.max(a+b,.25),5))},[c]),t=(0,p.useCallback)(a=>{0===a.button&&(m(!0),q.current={x:a.clientX,y:a.clientY,panX:j.x,panY:j.y},a.target.setPointerCapture(a.pointerId))},[j]),u=(0,p.useCallback)(a=>{l&&k({x:q.current.panX+(a.clientX-q.current.x),y:q.current.panY+(a.clientY-q.current.y)})},[l]),w=(0,p.useCallback)(()=>m(!1),[]);return(0,g.jsxs)("div",{className:`relative overflow-hidden ${b??""}`,style:{cursor:l?"grabbing":"grab",height:null!=d?n:void 0},onWheel:s,onPointerDown:t,onPointerMove:u,onPointerUp:w,children:[(0,g.jsx)("div",{ref:r,className:"flex items-center justify-center w-full h-full min-h-full p-4 [&_svg]:max-w-full origin-center select-none",style:{transform:`translate(${j.x}px, ${j.y}px) scale(${h})`},dangerouslySetInnerHTML:{__html:a}}),(0,g.jsxs)("div",{className:"absolute top-2 right-2 flex items-center gap-0.5 rounded-md border border-border bg-card/90 backdrop-blur px-1 py-0.5 shadow-sm",contentEditable:!1,children:[(0,g.jsx)(v.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>i(a=>Math.max(a-.25,.25)),title:"Zoom out",children:(0,g.jsx)(s9,{className:"h-3.5 w-3.5"})}),(0,g.jsxs)("button",{type:"button",onClick:()=>{i(1),k({x:0,y:0})},title:"Reset view",className:"text-[11px] text-muted-foreground tabular-nums w-9 text-center select-none hover:text-foreground",children:[Math.round(100*h),"%"]}),(0,g.jsx)(v.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>i(a=>Math.min(a+.25,5)),title:"Zoom in",children:(0,g.jsx)(s8,{className:"h-3.5 w-3.5"})}),e&&(0,g.jsx)(v.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:e,title:"Pop out",children:(0,g.jsx)(s6,{className:"h-3.5 w-3.5"})}),f&&(0,g.jsx)(v.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:f,title:"Close",children:(0,g.jsx)(s7,{className:"h-3.5 w-3.5"})})]})]})}function tb({svg:a,className:b,maxHeight:c}){let[d,e]=(0,p.useState)(!1);return(0,p.useEffect)(()=>{if(!d)return;let a=a=>"Escape"===a.key&&e(!1);return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[d]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ta,{svg:a,className:b,maxHeight:c,onExpand:()=>e(!0)}),d&&"u">typeof document&&(0,bu.createPortal)((0,g.jsx)("div",{className:"fixed inset-0 z-50 bg-background/95 backdrop-blur",children:(0,g.jsx)(ta,{svg:a,className:"w-full h-full",allowPlainWheel:!0,onClose:()=>e(!1)})}),document.body)]})}let tc="rounded-md bg-muted p-4 font-mono text-sm",td=0;function te(b){let{node:c,editor:d}=b,e="mermaid"===(c.attrs.language??""),f=c.textContent,[h,i]=(0,p.useState)(""),[j,k]=(0,p.useState)(""),l=(0,p.useRef)(null);if((0,p.useEffect)(()=>{if(!e)return;let b=f.trim();if(!b){i(""),k("");return}return l.current&&clearTimeout(l.current),l.current=setTimeout(async()=>{try{let c=(await a.A(334743)).default;c.initialize({startOnLoad:!1,theme:document.documentElement.classList.contains("dark")?"dark":"default",securityLevel:"loose",suppressErrorRendering:!0}),await c.parse(b);let{svg:d}=await c.render(`mermaid-cb-${++td}`,b);i(d),k("")}catch(a){document.querySelectorAll('[id^="dmermaid-cb-"]').forEach(a=>a.remove()),k(a instanceof Error?a.message:"Failed to render")}},300),()=>{l.current&&clearTimeout(l.current)}},[e,f]),!e)return(0,g.jsx)(nf,{as:"pre",className:tc,children:(0,g.jsx)(ne,{as:"code"})});let m=d.isEditable,n=h&&(!m||!j);return(0,g.jsxs)(nf,{className:"my-3",children:[(0,g.jsx)("pre",{className:tc,style:{display:!m&&n?"none":void 0},children:(0,g.jsx)(ne,{as:"code"})}),n&&(0,g.jsx)("div",{className:"mermaid-preview rounded-md border border-border bg-card",contentEditable:!1,children:(0,g.jsx)(tb,{svg:h,className:"w-full",maxHeight:600})}),m&&j&&(0,g.jsxs)("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-2 text-xs text-red-500",contentEditable:!1,children:["Mermaid error: ",j]})]})}let tf=l1.create({name:"proofSpan",priority:900,inclusive:!1,keepOnSplit:!1,addAttributes:()=>({spanId:{default:null,parseHTML:a=>a.getAttribute("id"),renderHTML:a=>({id:a.spanId})},origin:{default:"ai",parseHTML:a=>a.getAttribute("origin"),renderHTML:a=>({origin:a.origin})},basis:{default:null,parseHTML:a=>a.getAttribute("basis"),renderHTML:a=>({basis:a.basis})},basisDetail:{default:null,parseHTML:a=>a.getAttribute("basis-detail"),renderHTML:a=>({"basis-detail":a.basisDetail})},by:{default:null,parseHTML:a=>a.getAttribute("by"),renderHTML:a=>({by:a.by})},at:{default:null,parseHTML:a=>a.getAttribute("at"),renderHTML:a=>({at:a.at})},inResponseTo:{default:null,parseHTML:a=>a.getAttribute("in-response-to"),renderHTML:a=>({"in-response-to":a.inResponseTo})}}),parseHTML:()=>[{tag:"proof-span"}],renderHTML:({HTMLAttributes:a})=>["proof-span",ld(a,{class:"proof-span"}),0]});var tg=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;function th(a){let{node:b,updateAttributes:c,selected:d,editor:e}=a,f=b.attrs,h=(0,p.useRef)(null),i=(0,p.useRef)(null),[j,k]=(0,p.useState)(null),l=f.align??"center",m=(0,p.useCallback)((a,b)=>{if(!e.isEditable)return;a.preventDefault(),a.stopPropagation();let d=h.current,f=i.current;if(!d||!f)return;let g=a.clientX,j=d.getBoundingClientRect().width,l=f.parentElement?.getBoundingClientRect().width??800,m=a=>{k(Math.max(80,Math.min(l,j+("right"===b?a.clientX-g:g-a.clientX))))},n=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",n),k(a=>(null!=a&&c({width:Math.round(a)}),null))};window.addEventListener("pointermove",m),window.addEventListener("pointerup",n)},[e.isEditable,c]),n=null!=j?`${Math.round(j)}px`:"number"==typeof f.width?`${f.width}px`:"string"==typeof f.width&&f.width?f.width:void 0,o="left"===l?"mr-auto":"right"===l?"ml-auto":"mx-auto";return(0,g.jsx)(nf,{as:"div",className:`resizable-image my-3 ${o}`,"data-align":l,style:{width:n??"fit-content",maxWidth:"100%"},children:(0,g.jsxs)("div",{ref:i,className:`relative group inline-block max-w-full ${d?"ring-2 ring-primary rounded-md":""}`,contentEditable:!1,children:[(0,g.jsx)("img",{ref:h,src:f.src,alt:f.alt??"",title:f.title??void 0,className:"block rounded-md max-w-full h-auto",style:{width:n},draggable:!1}),e.isEditable&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{"aria-label":"Resize from left",onPointerDown:a=>m(a,"left"),className:"hover-reveal resize-hit absolute left-0 top-0 bottom-0 w-2 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:(0,g.jsx)("div",{className:"w-1 h-8 bg-card border border-border rounded-full shadow"})}),(0,g.jsx)("div",{"aria-label":"Resize from right",onPointerDown:a=>m(a,"right"),className:"hover-reveal resize-hit absolute right-0 top-0 bottom-0 w-2 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:(0,g.jsx)("div",{className:"w-1 h-8 bg-card border border-border rounded-full shadow"})}),null!=j&&(0,g.jsxs)("div",{className:"absolute top-1 right-1 text-[10px] px-1.5 py-0.5 rounded bg-primary/80 text-primary-foreground font-mono",children:[Math.round(j),"px"]})]})]})})}let ti=my.create({name:"image",addOptions:()=>({inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}),inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes:()=>({src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}),parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:a}){return["img",ld(this.options.HTMLAttributes,a)]},parseMarkdown:(a,b)=>b.createNode("image",{src:a.href,title:a.title,alt:a.text}),renderMarkdown:a=>{var b,c,d,e,f,g;let h=null!=(c=null==(b=a.attrs)?void 0:b.src)?c:"",i=null!=(e=null==(d=a.attrs)?void 0:d.alt)?e:"",j=null!=(g=null==(f=a.attrs)?void 0:f.title)?g:"";return j?`![${i}](${h} "${j}")`:`![${i}](${h})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||"u"<typeof document)return null;let{directions:a,minWidth:b,minHeight:c,alwaysPreserveAspectRatio:d}=this.options.resize;return({node:e,getPos:f,HTMLAttributes:g,editor:h})=>{let i=document.createElement("img");Object.entries(g).forEach(([a,b])=>{if(null!=b)switch(a){case"width":case"height":break;default:i.setAttribute(a,b)}}),i.src=g.src;let j=new mo({element:i,editor:h,node:e,getPos:f,onResize:(a,b)=>{i.style.width=`${a}px`,i.style.height=`${b}px`},onCommit:(a,b)=>{let c=f();void 0!==c&&this.editor.chain().setNodeSelection(c).updateAttributes(this.name,{width:a,height:b}).run()},onUpdate:(a,b,c)=>a.type===e.type,options:{directions:a,min:{width:b,height:c},preserveAspectRatio:!0===d}}),k=j.dom;return k.style.visibility="hidden",k.style.pointerEvents="none",i.onload=()=>{k.style.visibility="",k.style.pointerEvents=""},j}},addCommands(){return{setImage:a=>({commands:b})=>b.insertContent({type:this.name,attrs:a})}},addInputRules(){return[ml({find:tg,type:this.type,getAttributes:a=>{let[,,b,c,d]=a;return{src:c,alt:b,title:d}}})]}}).extend({name:"image",draggable:!0,addAttributes(){return{...this.parent?.(),width:{default:null,parseHTML:a=>{let b=a.getAttribute("width")??a.style.width;if(!b)return null;let c=/^(\d+)(px)?$/.exec(b);return c?Number(c[1]):b},renderHTML:a=>{if(!a.width)return{};let b="number"==typeof a.width?`${a.width}px`:a.width;return{style:`width: ${b}`}}},align:{default:null,parseHTML:a=>a.getAttribute("data-align"),renderHTML:a=>a.align?{"data-align":a.align}:{}}}},addNodeView:()=>nk(th)}),tj=new fY("wikiLinkDecorator"),tk="wikiLinkDecorator:refresh";function tl(a){let{has:b}=oa.getState(),c=a.schema.marks.wikiLink;if(!c)return h0.empty;let d=[];return a.doc.descendants((a,e)=>{if(!a.isText)return;let f=a.marks.find(a=>a.type===c);if(!f)return;let g=f.attrs.slug;!g||b(g)||d.push(hZ.inline(e,e+a.nodeSize,{"data-broken":"true"}))}),h0.create(a.doc,d)}let tm=/\[\[([a-z0-9-]+)(?:\|([^\]#|]+)|#([a-z0-9-]+))?\]\]$/,tn=l1.create({name:"wikiLink",priority:1e3,keepOnSplit:!1,inclusive:!1,addAttributes:()=>({slug:{default:null,parseHTML:a=>a.getAttribute("data-slug"),renderHTML:a=>({"data-slug":a.slug})},alias:{default:null,parseHTML:a=>a.getAttribute("data-alias"),renderHTML:a=>null!=a.alias?{"data-alias":a.alias}:{}},anchor:{default:null,parseHTML:a=>a.getAttribute("data-anchor"),renderHTML:a=>null!=a.anchor?{"data-anchor":a.anchor}:{}}}),parseHTML:()=>[{tag:'a[data-wiki-link="true"]'}],renderHTML({HTMLAttributes:a}){let b=String(a["data-slug"]??""),c=null!=a["data-anchor"]?String(a["data-anchor"]):null;return["a",ld(a,{"data-wiki-link":"true",href:c?`#wiki:${b}#${c}`:`#wiki:${b}`,class:"wiki-link"}),0]},addInputRules(){return[new lZ({find:tm,handler:({state:a,range:b,match:c})=>{let d=c[1]??"",e=c[2]??null,f=c[3]??null,g=e??(f?`${d}#${f}`:d),{tr:h}=a;h.replaceWith(b.from,b.to,a.schema.text(g,[this.type.create({slug:d,alias:e,anchor:f})]))}})]},addProseMirrorPlugins:()=>[new fV({key:tj,state:{init:(a,b)=>tl(b),apply:(a,b,c,d)=>a.getMeta(tk)||a.docChanged?tl(d):b.map(a.mapping,a.doc)},props:{decorations:a=>tj.getState(a)??h0.empty},view(a){let b=oa.subscribe(()=>{let b=a.state.tr.setMeta(tk,!0);a.dispatch(b)});return{destroy(){b()}}}})],addCommands(){return{setWikiLink:a=>({commands:b})=>b.setMark(this.name,{slug:a.slug,alias:a.alias??null,anchor:a.anchor??null}),unsetWikiLink:()=>({commands:a})=>a.unsetMark(this.name)}}}),to=sV({bash:sk,css:sq,go:sr,javascript:sA,json:sB,markdown:sC,python:sD,rust:sE,shell:sF,sql:sG,typescript:sP,xml:sQ,yaml:sR}),tp=[sj.configure({heading:{levels:[1,2,3,4]},codeBlock:!1,link:!1,underline:!1}),s5.configure({lowlight:to,HTMLAttributes:{class:tc}}).extend({addNodeView:()=>nk(te)}),q7.configure({placeholder:"Start writing, or press '/' for commands..."}),ti.configure({HTMLAttributes:{class:"rounded-lg max-w-full"},allowBase64:!1}),ro.configure({resizable:!0,lastColumnResizable:!1,HTMLAttributes:{class:"border-collapse w-full"}}),rh,rf,rg,rP.configure({HTMLAttributes:{class:"task-list"}}),rO.configure({nested:!0}),qB.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}}).extend({parseHTML:()=>[{tag:'a[href]:not([data-wiki-link="true"])'}],addKeyboardShortcuts(){return{"Mod-e":()=>{let{state:a}=this.editor,{from:b,to:c}=a.selection;return b!==c&&(this.editor.getAttributes("link").href,!1)}}}}),sX,tf,rQ.configure({types:["heading","paragraph"]}),rb,rc,s_,s2,tn],tq=/\.(md|markdown)$/i;function tr(a){try{return decodeURIComponent(a)}catch{return a}}async function ts(a,b,c){let d=encodeURIComponent(a).replace(/%2F/g,"/"),e=await fetch((0,av.apiUrl)(`/api/agent/files/${d}`),{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":crypto.randomUUID(),...{}},body:JSON.stringify({baseRevision:b,by:"human",ops:[c]})});if(409===e.status){let a=await e.json();return"STALE_REVISION"===a.code&&a.snapshot?.revision!==void 0?{ok:!1,stale:!0,newRevision:a.snapshot.revision}:{ok:!1,stale:!1}}return{ok:e.ok,stale:!1}}async function tt(a){let{path:b,ref:c,kind:d,markdown:e,basisDetail:f,getRevision:g,refresh:h}=a,i={type:"suggestion.add",ref:c,kind:d,basis:"suggested"};"delete"!==d&&(i.markdown=e??""),f&&(i.basisDetail=f);let j=await ts(b,g(),i);return!j.ok&&j.stale&&void 0!==j.newRevision&&(await h(),j=await ts(b,j.newRevision,i)),j.ok}let tu=a=>a.replace(/\s+$/g,"").trimStart(),tv=(0,h.default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);function tw({anchorKey:a,anchorLabel:b,comments:c,top:d,left:e,onClick:f}){let h;if(0===c.length)return null;let i=c.filter(a=>!a.resolved);if(0===i.length)h="check";else{let a=i[0].turns.at(-1);h=a?.by.startsWith("ai:")?"dot-ai":"ring-human"}return(0,g.jsxs)("button",{type:"button",onClick:f,style:{position:"absolute",top:d,left:e,transform:"translateY(2px)"},className:"z-10 p-2 sm:p-0.5 -m-1.5 sm:m-0 rounded transition-colors hover:bg-accent focus:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-label":`Comment thread for ${b??a}`,children:["check"===h&&(0,g.jsx)(tv,{className:"h-3.5 w-3.5 text-muted-foreground/30"}),"dot-ai"===h&&(0,g.jsx)(oC,{className:"h-3.5 w-3.5 fill-primary text-primary"}),"ring-human"===h&&(0,g.jsx)(oC,{className:"h-3.5 w-3.5 text-muted-foreground/70"})]})}var tx=a.i(735452),ty="Popover",[tz,tA]=(0,y.createContextScope)(ty,[tx.createPopperScope]),tB=(0,tx.createPopperScope)(),[tC,tD]=tz(ty),tE=a=>{let{__scopePopover:b,children:c,open:d,defaultOpen:e,onOpenChange:f,modal:h=!1}=a,i=tB(b),j=p.useRef(null),[k,l]=p.useState(!1),[m,n]=(0,A.useControllableState)({prop:d,defaultProp:e??!1,onChange:f,caller:ty});return(0,g.jsx)(tx.Root,{...i,children:(0,g.jsx)(tC,{scope:b,contentId:(0,z.useId)(),triggerRef:j,open:m,onOpenChange:n,onOpenToggle:p.useCallback(()=>n(a=>!a),[n]),hasCustomAnchor:k,onCustomAnchorAdd:p.useCallback(()=>l(!0),[]),onCustomAnchorRemove:p.useCallback(()=>l(!1),[]),modal:h,children:c})})};tE.displayName=ty;var tF="PopoverAnchor",tG=p.forwardRef((a,b)=>{let{__scopePopover:c,...d}=a,e=tD(tF,c),f=tB(c),{onCustomAnchorAdd:h,onCustomAnchorRemove:i}=e;return p.useEffect(()=>(h(),()=>i()),[h,i]),(0,g.jsx)(tx.Anchor,{...f,...d,ref:b})});tG.displayName=tF;var tH="PopoverTrigger";p.forwardRef((a,b)=>{let{__scopePopover:c,...d}=a,e=tD(tH,c),f=tB(c),h=(0,x.useComposedRefs)(b,e.triggerRef),i=(0,g.jsx)(F.Primitive.button,{type:"button","aria-haspopup":"dialog","aria-expanded":e.open,"aria-controls":e.contentId,"data-state":tU(e.open),...d,ref:h,onClick:(0,w.composeEventHandlers)(a.onClick,e.onOpenToggle)});return e.hasCustomAnchor?i:(0,g.jsx)(tx.Anchor,{asChild:!0,...f,children:i})}).displayName=tH;var tI="PopoverPortal",[tJ,tK]=tz(tI,{forceMount:void 0}),tL=a=>{let{__scopePopover:b,forceMount:c,children:d,container:e}=a,f=tD(tI,b);return(0,g.jsx)(tJ,{scope:b,forceMount:c,children:(0,g.jsx)(E.Presence,{present:c||f.open,children:(0,g.jsx)(D.Portal,{asChild:!0,container:e,children:d})})})};tL.displayName=tI;var tM="PopoverContent",tN=p.forwardRef((a,b)=>{let c=tK(tM,a.__scopePopover),{forceMount:d=c.forceMount,...e}=a,f=tD(tM,a.__scopePopover);return(0,g.jsx)(E.Presence,{present:d||f.open,children:f.modal?(0,g.jsx)(tP,{...e,ref:b}):(0,g.jsx)(tQ,{...e,ref:b})})});tN.displayName=tM;var tO=(0,J.createSlot)("PopoverContent.RemoveScroll"),tP=p.forwardRef((a,b)=>{let c=tD(tM,a.__scopePopover),d=p.useRef(null),e=(0,x.useComposedRefs)(b,d),f=p.useRef(!1);return p.useEffect(()=>{let a=d.current;if(a)return(0,I.hideOthers)(a)},[]),(0,g.jsx)(H.RemoveScroll,{as:tO,allowPinchZoom:!0,children:(0,g.jsx)(tR,{...a,ref:e,trapFocus:c.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:(0,w.composeEventHandlers)(a.onCloseAutoFocus,a=>{a.preventDefault(),f.current||c.triggerRef.current?.focus()}),onPointerDownOutside:(0,w.composeEventHandlers)(a.onPointerDownOutside,a=>{let b=a.detail.originalEvent,c=0===b.button&&!0===b.ctrlKey;f.current=2===b.button||c},{checkForDefaultPrevented:!1}),onFocusOutside:(0,w.composeEventHandlers)(a.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),tQ=p.forwardRef((a,b)=>{let c=tD(tM,a.__scopePopover),d=p.useRef(!1),e=p.useRef(!1);return(0,g.jsx)(tR,{...a,ref:b,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:b=>{a.onCloseAutoFocus?.(b),b.defaultPrevented||(d.current||c.triggerRef.current?.focus(),b.preventDefault()),d.current=!1,e.current=!1},onInteractOutside:b=>{a.onInteractOutside?.(b),b.defaultPrevented||(d.current=!0,"pointerdown"===b.detail.originalEvent.type&&(e.current=!0));let f=b.target;c.triggerRef.current?.contains(f)&&b.preventDefault(),"focusin"===b.detail.originalEvent.type&&e.current&&b.preventDefault()}})}),tR=p.forwardRef((a,b)=>{let{__scopePopover:c,trapFocus:d,onOpenAutoFocus:e,onCloseAutoFocus:f,disableOutsidePointerEvents:h,onEscapeKeyDown:i,onPointerDownOutside:j,onFocusOutside:k,onInteractOutside:l,...m}=a,n=tD(tM,c),o=tB(c);return(0,G.useFocusGuards)(),(0,g.jsx)(C.FocusScope,{asChild:!0,loop:!0,trapped:d,onMountAutoFocus:e,onUnmountAutoFocus:f,children:(0,g.jsx)(B.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:h,onInteractOutside:l,onEscapeKeyDown:i,onPointerDownOutside:j,onFocusOutside:k,onDismiss:()=>n.onOpenChange(!1),children:(0,g.jsx)(tx.Content,{"data-state":tU(n.open),role:"dialog",id:n.contentId,...o,...m,ref:b,style:{...m.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),tS="PopoverClose";p.forwardRef((a,b)=>{let{__scopePopover:c,...d}=a,e=tD(tS,c);return(0,g.jsx)(F.Primitive.button,{type:"button",...d,ref:b,onClick:(0,w.composeEventHandlers)(a.onClick,()=>e.onOpenChange(!1))})}).displayName=tS;var tT=p.forwardRef((a,b)=>{let{__scopePopover:c,...d}=a,e=tB(c);return(0,g.jsx)(tx.Arrow,{...e,...d,ref:b})});function tU(a){return a?"open":"closed"}tT.displayName="PopoverArrow";let tV=new Intl.RelativeTimeFormat("en",{numeric:"auto"});async function tW(a,b,c,d){let e=encodeURIComponent(a).replace(/%2F/g,"/"),f=await (0,bB.wsFetch)(`/api/agent/files/${e}`,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":crypto.randomUUID(),...{}},body:JSON.stringify({baseRevision:b,by:c,ops:d})});if(409===f.status){let a=await f.json();return"STALE_REVISION"===a.code&&a.snapshot?.revision!==void 0?{ok:!1,stale:!0,newRevision:a.snapshot.revision}:{ok:!1,stale:!1}}return f.ok?{ok:!0,stale:!1}:{ok:!1,stale:!1}}function tX({path:a,anchorKey:b,anchorLabel:c,anchorRef:d,lineAnchor:e,comments:f,anchorEl:h,onClose:i,readOnly:j}){let[k,l]=(0,p.useState)(null),[m,n]=(0,p.useState)(""),[o,q]=(0,p.useState)(!1),r=(0,p.useRef)(null),s=f.filter(a=>!a.resolved),t=s.length>0,u=s[0]??f[0]??null;if((0,p.useEffect)(()=>{if(!h)return void l(null);let a=h.getBoundingClientRect();l({top:a.bottom+4,left:a.left})},[h]),(0,p.useEffect)(()=>{if(!h)return;let a=a=>{"Escape"===a.key&&i()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[h,i]),(0,p.useEffect)(()=>{k&&setTimeout(()=>r.current?.focus(),50)},[k]),!h||!k)return null;function v(){let b=oc.getState().byPath[a];return b?.snapshotRevision??0}async function w(){if(m.trim()&&!o){q(!0);try{let c=u?{type:"comment.reply",commentId:u.id,text:m.trim()}:e?{type:"comment.add",lineAnchor:e,text:m.trim()}:{type:"comment.add",ref:d??b,text:m.trim()},f=v(),g=await tW(a,f,"human",[c]);!g.ok&&g.stale&&void 0!==g.newRevision&&(await oc.getState().loadSidecar(a),f=g.newRevision,g=await tW(a,f,"human",[c])),g.ok&&(await oc.getState().loadSidecar(a),n(""),i())}finally{q(!1)}}}async function x(){if(u&&!o){q(!0);try{let b=u.resolved?"comment.reopen":"comment.resolve",c=v(),d=await tW(a,c,"human",[{type:b,commentId:u.id}]);!d.ok&&d.stale&&void 0!==d.newRevision&&(await oc.getState().loadSidecar(a),c=d.newRevision,d=await tW(a,c,"human",[{type:b,commentId:u.id}])),d.ok&&(await oc.getState().loadSidecar(a),i())}finally{q(!1)}}}let y=f.flatMap(a=>a.turns.map(b=>({...b,resolved:a.resolved,commentId:a.id})));return(0,g.jsxs)(tE,{open:!0,children:[(0,g.jsx)(tG,{asChild:!0,children:(0,g.jsx)("span",{"aria-hidden":"true",style:{position:"fixed",top:k.top,left:k.left,width:0,height:0,pointerEvents:"none"}})}),(0,g.jsx)(tL,{children:(0,g.jsxs)(tN,{side:"bottom",align:"start",sideOffset:4,collisionPadding:8,onInteractOutside:i,className:"z-50 w-[min(18rem,calc(100vw-1rem))] bg-popover border border-border rounded-lg shadow-xl p-3 space-y-2 text-[12px] focus:outline-none",children:[(0,g.jsxs)("div",{className:"flex items-center justify-between",children:[(0,g.jsx)("span",{className:"text-[11px] font-mono text-muted-foreground/60 truncate",children:c??b}),u&&!j&&(0,g.jsx)("button",{type:"button",disabled:o,onClick:()=>void x(),className:"ml-2 shrink-0 text-[10px] px-1.5 py-0.5 rounded border border-border hover:bg-accent disabled:opacity-50 transition-colors",children:u.resolved?"Reopen":"Resolve"})]}),y.length>0&&(0,g.jsx)("div",{className:"space-y-2 max-h-48 overflow-y-auto pr-1",children:y.map((a,b)=>(0,g.jsxs)("div",{className:"space-y-0.5",children:[(0,g.jsxs)("p",{className:"text-[10px] text-muted-foreground/60",children:[a.by," · ",function(a){let b=Math.round((Date.now()-new Date(a).getTime())/1e3);if(60>Math.abs(b))return tV.format(-b,"second");let c=Math.round(b/60);if(60>Math.abs(c))return tV.format(-c,"minute");let d=Math.round(c/60);return 24>Math.abs(d)?tV.format(-d,"hour"):tV.format(-Math.round(d/24),"day")}(a.at)]}),(0,g.jsx)("p",{className:"text-foreground leading-snug whitespace-pre-wrap",children:a.text})]},b))}),(!u?.resolved||0===f.length)&&(0,g.jsxs)("div",{className:"space-y-1.5 pt-1",children:[(0,g.jsx)("textarea",{ref:r,value:m,onChange:a=>n(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.metaKey||a.ctrlKey)&&w()},placeholder:t?"Reply…":"Add a comment…",rows:2,className:"w-full resize-none rounded-md border border-border bg-background px-2 py-1.5 text-[12px] focus:outline-none focus-visible:ring-1 focus-visible:ring-ring placeholder:text-muted-foreground/40"}),(0,g.jsxs)("div",{className:"flex items-center justify-between",children:[(0,g.jsx)("span",{className:"text-[10px] text-muted-foreground/40",children:"⌘↵ send"}),(0,g.jsx)("button",{type:"button",disabled:o||!m.trim(),onClick:()=>void w(),className:"px-2.5 py-1 rounded-md bg-primary text-primary-foreground text-[11px] font-medium hover:bg-primary/90 disabled:opacity-50 transition-colors",children:"Send"})]})]}),(0,g.jsx)(tT,{className:"fill-border"})]})})]})}function tY({targetEl:a,path:b,onClose:c,onComment:d}){let[e,f]=(0,p.useState)(null),[h,i]=(0,p.useState)(null),[j,k]=(0,p.useState)(!1);if((0,p.useEffect)(()=>{if(!a){f(null),i(null);return}let b=a.getBoundingClientRect();f({top:b.bottom+window.scrollY+4,left:b.left+window.scrollX}),i({spanId:a.getAttribute("id")??"",origin:a.getAttribute("origin"),basis:a.getAttribute("basis"),basisDetail:a.getAttribute("basis-detail"),by:a.getAttribute("by"),at:a.getAttribute("at")})},[a]),(0,p.useEffect)(()=>{if(!a)return;let b=a=>{"Escape"===a.key&&c()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[a,c]),!a||!e||!h)return null;async function l(a){if(!j&&h){k(!0);try{await (0,bB.wsFetch)("/api/agent/internal/span",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:b,spanId:h.spanId,action:a,idempotencyKey:crypto.randomUUID()})})}finally{k(!1),c()}}}return(0,g.jsxs)(tE,{open:!0,children:[(0,g.jsx)(tG,{asChild:!0,children:(0,g.jsx)("span",{"aria-hidden":"true",style:{position:"fixed",top:e.top,left:e.left,width:0,height:0,pointerEvents:"none"}})}),(0,g.jsx)(tL,{children:(0,g.jsxs)(tN,{side:"bottom",align:"start",sideOffset:4,collisionPadding:8,onInteractOutside:c,className:"z-50 w-[min(16rem,calc(100vw-1rem))] bg-popover border border-border rounded-lg shadow-xl p-3 space-y-2 text-[12px] focus:outline-none",children:[(0,g.jsxs)("div",{className:"space-y-0.5",children:[(0,g.jsxs)("p",{className:"font-medium text-foreground truncate",children:[h.by??"unknown"," · ",h.basis??"—"," · ",function(a){if(!a)return"";let b=Math.floor((Date.now()-new Date(a).getTime())/1e3);if(b<60)return`${b}s ago`;let c=Math.floor(b/60);if(c<60)return`${c}m ago`;let d=Math.floor(c/60);return d<24?`${d}h ago`:`${Math.floor(d/24)}d ago`}(h.at)]}),h.basisDetail&&(0,g.jsxs)("p",{className:"text-muted-foreground italic truncate",children:["“",h.basisDetail,"”"]}),h.origin&&(0,g.jsxs)("p",{className:"text-muted-foreground/60",children:["origin: ",h.origin]})]}),(0,g.jsxs)("div",{className:"flex items-center gap-1.5 pt-1",children:[(0,g.jsx)("button",{type:"button",disabled:j,onClick:()=>void l("accept"),className:"flex-1 py-1 rounded-md bg-primary text-primary-foreground text-[11px] font-medium hover:bg-primary/90 disabled:opacity-50 transition-colors",children:"Accept"}),(0,g.jsx)("button",{type:"button",disabled:j,onClick:()=>void l("revert"),className:"flex-1 py-1 rounded-md border border-border text-[11px] font-medium hover:bg-accent disabled:opacity-50 transition-colors",children:"Revert"}),(0,g.jsx)("button",{type:"button",disabled:j,onClick:()=>{d?.(),c()},className:"flex-1 py-1 rounded-md border border-border text-[11px] font-medium hover:bg-accent disabled:opacity-50 transition-colors",children:"Comment"})]}),(0,g.jsx)(tT,{className:"fill-border"})]})})]})}async function tZ(a,b,c,d){let e=encodeURIComponent(a).replace(/%2F/g,"/"),f=await (0,bB.wsFetch)(`/api/agent/files/${e}`,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":crypto.randomUUID(),...{}},body:JSON.stringify({baseRevision:b,by:"human",ops:[{type:c,suggestionId:d}]})});return{ok:f.ok,status:f.status}}function t$({suggestion:a,currentMarkdown:b,path:c,baseRevision:d,getLatestRevision:e,top:f,left:h,width:i,onSettled:j,readOnly:k}){let[l,m]=(0,p.useState)(!1);async function n(){if(!l){m(!0);try{let b=await tZ(c,d,"suggestion.accept",a.id);b.ok||409!==b.status||(b=await tZ(c,e(),"suggestion.accept",a.id))}finally{m(!1),j()}}}async function o(){if(!l){m(!0);try{await tZ(c,d,"suggestion.reject",a.id)}finally{m(!1),j()}}}let q="delete"===a.kind,r="insertAfter"===a.kind||"insertBefore"===a.kind;return(0,g.jsxs)("div",{style:{position:"absolute",top:f,left:h,width:i>0?i:void 0,zIndex:30},className:"my-1 rounded-lg border border-border bg-card shadow-md text-[12px] overflow-hidden",role:"region","aria-label":`Suggestion by ${a.by}`,children:[(0,g.jsx)("div",{className:"flex items-center justify-between px-3 py-2 bg-muted/50 border-b border-border",children:(0,g.jsxs)("span",{className:"font-medium text-foreground",children:[(0,g.jsx)("span",{className:"text-primary",children:a.by})," suggests ",(0,g.jsx)("span",{className:"text-muted-foreground",children:function(a){switch(a){case"replace":return"replacing this block";case"insertAfter":return"inserting content after this block";case"insertBefore":return"inserting content before this block";case"delete":return"deleting this block"}}(a.kind)})]})}),(0,g.jsxs)("div",{className:"p-3 space-y-2",children:["replace"===a.kind&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/60 mb-1",children:"─ current ─"}),(0,g.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-muted-foreground bg-destructive/5 rounded px-2 py-1",children:b||"(empty)"})]}),(0,g.jsxs)("div",{children:[(0,g.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/60 mb-1",children:"─ proposed ─"}),(0,g.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-foreground bg-primary/5 rounded px-2 py-1",children:a.markdown??"(empty)"})]})]}),r&&(0,g.jsxs)("div",{children:[(0,g.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/60 mb-1",children:"─ will be inserted ─"}),(0,g.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-foreground bg-primary/5 rounded px-2 py-1",children:a.markdown??"(empty)"})]}),q&&(0,g.jsxs)("div",{children:[(0,g.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/60 mb-1",children:"─ will be deleted ─"}),(0,g.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-muted-foreground line-through bg-destructive/5 rounded px-2 py-1",children:b||"(empty)"})]}),a.basisDetail&&(0,g.jsxs)("p",{className:"italic text-muted-foreground/70 text-[11px]",children:["Reason: ",a.basisDetail]})]}),!k&&(0,g.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-t border-border bg-muted/30",children:[(0,g.jsx)("button",{type:"button",disabled:l,onClick:()=>void n(),className:"flex-1 py-1 rounded-md bg-primary text-primary-foreground text-[11px] font-medium hover:bg-primary/90 disabled:opacity-50 transition-colors",children:"Accept"}),(0,g.jsx)("button",{type:"button",disabled:l,onClick:()=>void o(),className:"flex-1 py-1 rounded-md border border-border text-[11px] font-medium hover:bg-accent disabled:opacity-50 transition-colors",children:"Reject"})]})]})}async function t_(a,b,c){let d=encodeURIComponent(a).replace(/%2F/g,"/"),e=await (0,bB.wsFetch)(`/api/agent/files/${d}`,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":crypto.randomUUID(),...{}},body:JSON.stringify({baseRevision:b,by:"human",ops:c})});if(409===e.status){let a=await e.json();return"STALE_REVISION"===a.code&&a.snapshot?.revision!==void 0?{ok:!1,stale:!0,newRevision:a.snapshot.revision}:{ok:!1,stale:!1}}return e.ok?{ok:!0,stale:!1}:{ok:!1,stale:!1}}let t0={replace:"Replace block",insertAfter:"Insert after",insertBefore:"Insert before",delete:"Delete block"};function t1({path:a,blockRef:b,currentMarkdown:c,anchor:d,onClose:e}){let[f,h]=(0,p.useState)("replace"),[i,j]=(0,p.useState)(c),[k,l]=(0,p.useState)(""),[m,n]=(0,p.useState)(!1),o=(0,p.useRef)(null);(0,p.useEffect)(()=>{"replace"===f?j(c):j("")},[f,c]),(0,p.useEffect)(()=>{let a=a=>{"Escape"===a.key&&e()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e]),(0,p.useEffect)(()=>{setTimeout(()=>o.current?.focus(),50)},[]);let q="delete"!==f,r=!m&&(!q||i.trim().length>0);async function s(){if(r){n(!0);try{let c={type:"suggestion.add",ref:b,kind:f,basis:"suggested"};q&&(c.markdown=i),k.trim()&&(c.basisDetail=k.trim());let d=oc.getState().byPath[a]?.snapshotRevision??0,g=await t_(a,d,[c]);!g.ok&&g.stale&&void 0!==g.newRevision&&(await oc.getState().loadSidecar(a),d=g.newRevision,g=await t_(a,d,[c])),g.ok&&(await oc.getState().loadSidecar(a),await oc.getState().loadSnapshot(a),e())}finally{n(!1)}}}return(0,g.jsxs)(tE,{open:!0,children:[(0,g.jsx)(tG,{asChild:!0,children:(0,g.jsx)("span",{"aria-hidden":"true",style:{position:"fixed",top:d.top,left:d.left,width:0,height:0,pointerEvents:"none"}})}),(0,g.jsx)(tL,{children:(0,g.jsxs)(tN,{side:"bottom",align:"start",sideOffset:4,collisionPadding:8,onInteractOutside:e,className:"z-50 w-[min(20rem,calc(100vw-1rem))] bg-popover border border-border rounded-lg shadow-xl p-3 space-y-2.5 text-[12px] focus:outline-none",children:[(0,g.jsxs)("div",{className:"flex items-center justify-between",children:[(0,g.jsx)("span",{className:"font-medium text-foreground",children:"Suggest an edit"}),(0,g.jsx)("span",{className:"text-[11px] font-mono text-muted-foreground/60 truncate ml-2",children:b})]}),(0,g.jsx)("div",{className:"flex flex-wrap gap-1",children:Object.keys(t0).map(a=>(0,g.jsx)("button",{type:"button",onClick:()=>h(a),className:`px-2 py-0.5 rounded-md text-[10.5px] border transition-colors ${f===a?"bg-primary text-primary-foreground border-primary":"border-border text-muted-foreground hover:bg-accent"}`,children:t0[a]},a))}),"delete"===f&&(0,g.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-muted-foreground line-through bg-destructive/5 rounded px-2 py-1 max-h-32 overflow-y-auto",children:c||"(empty)"}),q&&(0,g.jsxs)("div",{className:"space-y-1",children:[(0,g.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/60",children:"replace"===f?"proposed content":"content to insert"}),(0,g.jsx)("textarea",{ref:o,value:i,onChange:a=>j(a.target.value),rows:4,placeholder:"Markdown…",className:"w-full resize-y rounded-md border border-border bg-background px-2 py-1.5 font-mono text-[11px] focus:outline-none focus-visible:ring-1 focus-visible:ring-ring placeholder:text-muted-foreground/40"})]}),(0,g.jsx)("input",{type:"text",value:k,onChange:a=>l(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.metaKey||a.ctrlKey)&&s()},placeholder:"Reason (optional)",className:"w-full rounded-md border border-border bg-background px-2 py-1.5 text-[12px] focus:outline-none focus-visible:ring-1 focus-visible:ring-ring placeholder:text-muted-foreground/40"}),(0,g.jsxs)("div",{className:"flex items-center justify-between pt-0.5",children:[(0,g.jsx)("span",{className:"text-[10px] text-muted-foreground/40",children:"⌘↵ submit"}),(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsx)("button",{type:"button",disabled:m,onClick:e,className:"px-2.5 py-1 rounded-md border border-border text-[11px] font-medium hover:bg-accent disabled:opacity-50 transition-colors",children:"Cancel"}),(0,g.jsx)("button",{type:"button",disabled:!r,onClick:()=>void s(),className:"px-2.5 py-1 rounded-md bg-primary text-primary-foreground text-[11px] font-medium hover:bg-primary/90 disabled:opacity-50 transition-colors",children:"Suggest"})]})]}),(0,g.jsx)(tT,{className:"fill-border"})]})})]})}let t2=(0,h.default)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),t3=(0,h.default)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),t4=(0,h.default)("sigma",[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]]),t5=(0,h.default)("table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]),t6=[{label:"Text",icon:dU,description:"Start writing plain text",category:"basic",action:{type:"direct",run:a=>a.chain().focus().setParagraph().run()}},{label:"Heading 1",icon:oN,description:"Large section heading",category:"basic",action:{type:"direct",run:a=>a.chain().focus().toggleHeading({level:1}).run()}},{label:"Heading 2",icon:oO,description:"Medium section heading",category:"basic",action:{type:"direct",run:a=>a.chain().focus().toggleHeading({level:2}).run()}},{label:"Heading 3",icon:oP,description:"Small section heading",category:"basic",action:{type:"direct",run:a=>a.chain().focus().toggleHeading({level:3}).run()}},{label:"Bullet List",icon:oQ,description:"Create a bullet list",category:"basic",action:{type:"direct",run:a=>a.chain().focus().toggleBulletList().run()}},{label:"Numbered List",icon:oR,description:"Create a numbered list",category:"basic",action:{type:"direct",run:a=>a.chain().focus().toggleOrderedList().run()}},{label:"Checklist",icon:oK,description:"Create a task checklist",category:"basic",action:{type:"direct",run:a=>a.chain().focus().toggleTaskList().run()}},{label:"Code Block",icon:oA,description:"Insert a code block",category:"basic",action:{type:"direct",run:a=>a.chain().focus().toggleCodeBlock().run()}},{label:"Blockquote",icon:oV,description:"Insert a blockquote",category:"basic",action:{type:"direct",run:a=>a.chain().focus().toggleBlockquote().run()}},{label:"Divider",icon:oS,description:"Insert a horizontal rule",category:"basic",action:{type:"direct",run:a=>a.chain().focus().setHorizontalRule().run()}},{label:"Table",icon:t5,description:"Insert a 3x3 table",category:"basic",action:{type:"direct",run:a=>a.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},{label:"Image",icon:l,description:"Upload, paste URL, or drop an image",category:"media",action:{type:"popover",kind:{type:"media",kind:"image"}}},{label:"Video",icon:oY,description:"Upload or paste a video URL",category:"media",action:{type:"popover",kind:{type:"media",kind:"video"}}},{label:"File",icon:cb,description:"Attach any file to this page",category:"media",action:{type:"popover",kind:{type:"media",kind:"file"}}},{label:"Callout",icon:t3,description:"Insert an info callout",category:"advanced",action:{type:"direct",run:a=>a.chain().focus().wrapIn("callout",{type:"info"}).run()}},{label:"Warning",icon:t2,description:"Insert a warning callout",category:"advanced",action:{type:"direct",run:a=>a.chain().focus().wrapIn("callout",{type:"warning"}).run()}},{label:"Math",icon:t4,description:"Insert a LaTeX math expression",category:"advanced",action:{type:"direct",run:a=>a.chain().focus().insertContent("$x=y$").run()}}];function t7({cmd:a}){switch(a.label){case"Heading 1":return(0,g.jsx)("p",{className:"font-bold text-[18px] leading-tight text-foreground/80 truncate",children:"Heading 1"});case"Heading 2":return(0,g.jsx)("p",{className:"font-semibold text-[14px] leading-tight text-foreground/80 truncate",children:"Heading 2"});case"Heading 3":return(0,g.jsx)("p",{className:"font-medium text-[12px] leading-tight text-foreground/80 truncate",children:"Heading 3"});case"Text":return(0,g.jsx)("p",{className:"text-[11px] text-foreground/60 leading-snug",children:"The quick brown fox jumps over the lazy dog."});case"Bullet List":return(0,g.jsxs)("ul",{className:"list-disc pl-4 text-[10px] text-foreground/60 space-y-0.5",children:[(0,g.jsx)("li",{children:"First item"}),(0,g.jsx)("li",{children:"Second item"}),(0,g.jsx)("li",{children:"Third item"})]});case"Numbered List":return(0,g.jsxs)("ol",{className:"list-decimal pl-4 text-[10px] text-foreground/60 space-y-0.5",children:[(0,g.jsx)("li",{children:"First item"}),(0,g.jsx)("li",{children:"Second item"}),(0,g.jsx)("li",{children:"Third item"})]});case"Checklist":return(0,g.jsxs)("div",{className:"space-y-0.5 text-[10px] text-foreground/60",children:[(0,g.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,g.jsx)("span",{className:"w-3 h-3 border border-foreground/30 rounded-sm inline-block shrink-0"}),"Pending task"]}),(0,g.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,g.jsx)("span",{className:"w-3 h-3 border border-foreground/30 rounded-sm bg-foreground/20 inline-block shrink-0"}),"Done task"]})]});case"Code Block":return(0,g.jsx)("pre",{className:"bg-muted rounded px-2 py-1 text-[10px] font-mono text-foreground/70 leading-snug",children:(0,g.jsx)("code",{children:"const x = 42;"})});case"Blockquote":return(0,g.jsx)("div",{className:"border-l-2 border-foreground/30 pl-2 text-[10px] text-foreground/60 italic",children:"A thought worth quoting."});case"Divider":return(0,g.jsx)("hr",{className:"border-foreground/20 w-full"});case"Table":return(0,g.jsxs)("table",{className:"text-[9px] border-collapse w-full",children:[(0,g.jsx)("thead",{children:(0,g.jsx)("tr",{children:["Col A","Col B","Col C"].map(a=>(0,g.jsx)("th",{className:"border border-foreground/20 px-1.5 py-0.5 text-left font-semibold bg-muted/50 text-foreground/70",children:a},a))})}),(0,g.jsx)("tbody",{children:[["1","2","3"],["4","5","6"]].map((a,b)=>(0,g.jsx)("tr",{children:a.map((a,b)=>(0,g.jsx)("td",{className:"border border-foreground/20 px-1.5 py-0.5 text-foreground/50",children:a},b))},b))})]});case"Image":return(0,g.jsxs)("div",{className:"flex items-center gap-2 text-foreground/50",children:[(0,g.jsx)(l,{className:"h-8 w-8 text-foreground/20"}),(0,g.jsx)("span",{className:"text-[10px]",children:"image.png"})]});case"Video":return(0,g.jsxs)("div",{className:"flex items-center gap-2 text-foreground/50",children:[(0,g.jsx)(oY,{className:"h-8 w-8 text-foreground/20"}),(0,g.jsx)("span",{className:"text-[10px]",children:"video.mp4"})]});case"File":return(0,g.jsxs)("div",{className:"flex items-center gap-2 text-foreground/50",children:[(0,g.jsx)(cb,{className:"h-8 w-8 text-foreground/20"}),(0,g.jsx)("span",{className:"text-[10px]",children:"attachment.pdf"})]});case"Callout":return(0,g.jsxs)("div",{className:"flex items-start gap-1.5 bg-blue-500/10 border border-blue-500/20 rounded px-2 py-1",children:[(0,g.jsx)(t3,{className:"h-3 w-3 text-blue-500 shrink-0 mt-0.5"}),(0,g.jsx)("span",{className:"text-[10px] text-foreground/60",children:"Info callout"})]});case"Warning":return(0,g.jsxs)("div",{className:"flex items-start gap-1.5 bg-warning/10 border border-warning/20 rounded px-2 py-1",children:[(0,g.jsx)(t2,{className:"h-3 w-3 text-warning shrink-0 mt-0.5"}),(0,g.jsx)("span",{className:"text-[10px] text-foreground/60",children:"Warning callout"})]});case"Math":return(0,g.jsx)("p",{className:"font-mono text-[13px] text-foreground/70",children:"E = mc²"});default:return(0,g.jsx)("p",{className:"text-[10px] text-muted-foreground",children:a.description})}}function t8({editor:a}){let[b,c]=(0,p.useState)(!1),[d,e]=(0,p.useState)(""),[f,h]=(0,p.useState)(0),[i,j]=(0,p.useState)({top:0,left:0}),[k,l]=(0,p.useState)(null),m=(0,p.useRef)(null),n=b_(a=>a.currentPath),o=t6.filter(a=>a.label.toLowerCase().includes(d.toLowerCase())||a.description.toLowerCase().includes(d.toLowerCase())),q=(0,p.useCallback)(()=>{c(!1),e(""),h(0)},[]),r=(0,p.useCallback)(b=>{if(!a)return;let{from:f}=a.state.selection,g=f-d.length-1;a.chain().focus().deleteRange({from:g,to:f}).run(),"direct"===b.action.type?(b.action.run(a),q()):(l(b.action.kind),c(!1),e(""))},[a,d,q]);if((0,p.useEffect)(()=>{if(!a)return;let g=g=>{if(!b){if("/"===g.key){let{from:b}=a.state.selection,d=a.state.doc.textBetween(Math.max(0,b-1),b);if(1===b||""===d||"\n"===d||" "===d){let d=a.view.coordsAtPos(b),f=a.view.dom.getBoundingClientRect();j({top:d.bottom-f.top+4,left:d.left-f.left}),c(!0),e(""),h(0)}}return}"Escape"===g.key?(g.preventDefault(),q()):"ArrowDown"===g.key?(g.preventDefault(),h(a=>Math.min(a+1,o.length-1))):"ArrowUp"===g.key?(g.preventDefault(),h(a=>Math.max(a-1,0))):"Enter"===g.key?(g.preventDefault(),o[f]&&r(o[f])):"Backspace"===g.key?0===d.length?q():(e(a=>a.slice(0,-1)),h(0)):" "===g.key?q():1!==g.key.length||g.metaKey||g.ctrlKey||(e(a=>a+g.key),h(0))};return window.addEventListener("keydown",g,!0),()=>window.removeEventListener("keydown",g,!0)},[a,b,d,f,o,q,r]),(0,p.useEffect)(()=>{if(!b)return;let a=a=>{m.current&&!m.current.contains(a.target)&&q()};return window.addEventListener("mousedown",a),()=>window.removeEventListener("mousedown",a)},[b,q]),(!b||0===o.length)&&!k)return null;let s=new Map;for(let a of o){let b=s.get(a.category)??[];b.push(a),s.set(a.category,b)}let t=o[f]??null;return(0,g.jsxs)(g.Fragment,{children:[b&&o.length>0&&(0,g.jsxs)("div",{ref:m,className:"absolute z-50 w-[280px] bg-popover border border-border rounded-lg shadow-lg overflow-hidden",style:{top:i.top,left:i.left},children:[(0,g.jsx)("div",{className:"max-h-[300px] overflow-y-auto py-1",children:[{key:"basic",title:"Basic"},{key:"media",title:"Media"},{key:"advanced",title:"Advanced"}].map(a=>{let b=s.get(a.key);return b&&0!==b.length?(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"text-[9px] uppercase tracking-wider text-muted-foreground px-3 pt-2 pb-1",children:a.title}),b.map(a=>{let b=o.indexOf(a),c=a.icon,d=b===f;return(0,g.jsxs)("button",{onMouseDown:b=>{b.preventDefault(),r(a)},onMouseEnter:()=>h(b),className:(0,ao.cn)("flex items-center gap-3 w-full px-3 py-1.5 text-left transition-colors",d?"bg-accent text-accent-foreground ring-1 ring-inset ring-accent-foreground/10":"hover:bg-accent/50"),children:[(0,g.jsx)(c,{className:(0,ao.cn)("h-4 w-4 shrink-0 transition-colors",d?"text-accent-foreground":"text-muted-foreground")}),(0,g.jsxs)("div",{className:"min-w-0",children:[(0,g.jsx)("p",{className:"text-[12px] font-medium truncate",children:a.label}),(0,g.jsx)("p",{className:(0,ao.cn)("text-[10px] truncate transition-colors",d?"text-accent-foreground/70":"text-muted-foreground"),children:a.description})]})]},a.label)})]},a.key):null})}),t&&(0,g.jsx)("div",{className:"border-t border-border bg-muted/30 px-3 py-2 min-h-[52px] flex items-center",children:(0,g.jsx)(t7,{cmd:t})})]}),k&&a?"media"===k.type?n?(0,g.jsx)(o3,{kind:k.kind,pagePath:n,anchor:i,onCancel:()=>l(null),onInsert:b=>((b,c)=>{if(!a)return;let{url:d,alt:e,mimeType:f}=c;"image"===b||(f??"").startsWith("image/")||/\.(png|jpe?g|gif|webp|svg|avif)(\?|$)/i.test(d)?a.chain().focus().setImage({src:d,alt:e??""}).run():a.chain().focus().insertContent(`<a href="${d}">${e??d}</a>`).run(),l(null)})(k.kind,b)}):null:null:null]})}function t9(a){let b=[],c=new Map;return a.state.doc.forEach((a,d)=>{if("heading"===a.type.name){let e=a.textContent,f=a.attrs.level,g=e.toLowerCase().replace(/\s+/g,"-").replace(/[^\w-]/g,"")||"heading",h=(c.get(g)??0)+1;c.set(g,h);let i=1===h?g:`${g}-${h}`;b.push({level:f,text:e,pos:d,uid:i})}}),b}function ua(a,b){try{let{node:c}=a.view.domAtPos(b.pos+1);return c.nodeType===Node.ELEMENT_NODE?c.closest("h1,h2,h3,h4,h5,h6")??c:c.parentElement?.closest("h1,h2,h3,h4,h5,h6")??null}catch{return null}}function ub({editor:a,scrollContainerRef:b}){let[c,d]=(0,p.useState)([]),[e,f]=(0,p.useState)(null),[h,i]=(0,p.useState)(!1),[j,k]=(0,p.useState)(0),[l,m]=(0,p.useState)(0),n=(0,p.useRef)([]),o=(0,p.useRef)(null),q=(0,p.useRef)(null);(0,p.useEffect)(()=>{n.current=c},[c]),(0,p.useEffect)(()=>{o.current=e},[e]),(0,p.useEffect)(()=>{if(!a)return;let b=null,c=()=>{b&&clearTimeout(b),b=setTimeout(()=>d(t9(a)),250)};return a.on("update",c),d(t9(a)),()=>{b&&clearTimeout(b),a.off("update",c)}},[a]),(0,p.useEffect)(()=>{let c=b.current;if(!c)return;let d=0,e=()=>{cancelAnimationFrame(d),d=requestAnimationFrame(()=>{let b=c.scrollHeight-c.clientHeight;k(b>0?Math.min(1,c.scrollTop/b):0);let d=n.current,e=o.current;if(!a||!e||0===d.length)return void m(0);let f=d.findIndex(a=>a.uid===e);if(f<0)return void m(0);let g=d[f],h=d[f+1],i=ua(a,g);if(!i)return void m(0);let j=i.offsetTop,l=Math.max(1,(h?ua(a,h)?.offsetTop??c.scrollHeight:c.scrollHeight)-j);m(Math.max(0,Math.min(1,(c.scrollTop+Math.min(96,.25*c.clientHeight)-j)/l)))})};return c.addEventListener("scroll",e,{passive:!0}),()=>{c.removeEventListener("scroll",e),cancelAnimationFrame(d)}},[a,b]),(0,p.useEffect)(()=>{q.current?.disconnect();let d=b.current;if(!d||!a||0===c.length)return;let e=new IntersectionObserver(a=>{for(let b of a)if(b.isIntersecting){let a=b.target.dataset.outlineId;a&&f(a)}},{root:d,rootMargin:"-8% 0px -72% 0px",threshold:0});for(let b of c)try{let c=ua(a,b);c&&(c.dataset.outlineId=b.uid,e.observe(c))}catch{}return q.current=e,()=>{e.disconnect()}},[c,a,b]);let r=(0,p.useCallback)(b=>{if(!a)return;let c=ua(a,b);c?.scrollIntoView({behavior:"smooth",block:"start"})},[a]),s=c.length>=2,[t,u]=(0,p.useState)(!1),v=(0,g.jsx)(g.Fragment,{children:c.map((a,b)=>(0,g.jsxs)("button",{onClick:()=>{r(a),u(!1)},title:a.text,className:(0,ao.cn)("text-left text-[10.5px] leading-snug py-0.5 rounded truncate transition-colors shrink-0",e===a.uid?"text-primary bg-primary/10 font-medium":"text-muted-foreground/60 hover:text-foreground hover:bg-accent",e===a.uid&&"relative overflow-hidden"),style:{paddingLeft:`${(a.level-1)*8+4}px`},children:[e===a.uid&&(0,g.jsx)("span",{"aria-hidden":!0,className:"absolute left-0 top-0 bottom-0 w-0.5 bg-primary/15",children:(0,g.jsx)("span",{className:"absolute bottom-0 left-0 w-full bg-primary transition-[height] duration-100 ease-out",style:{height:`${100*l}%`}})}),e===a.uid?(0,g.jsx)("span",{className:"relative z-10",children:a.text}):a.text]},`${a.uid}-${b}`))});return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{"aria-hidden":!0,className:"absolute top-0 left-0 right-0 h-0.5 z-30 pointer-events-none",children:(0,g.jsx)("div",{className:"h-full bg-primary/35 transition-[width] duration-100 ease-out",style:{width:`${100*j}%`}})}),s&&(0,g.jsxs)("div",{className:"absolute right-1 top-4 z-20 hidden xl:block w-40",children:[(0,g.jsxs)("button",{onClick:()=>i(a=>!a),className:"flex items-center gap-1 mb-1.5 px-1 py-0.5 rounded text-muted-foreground/40 hover:text-muted-foreground hover:bg-accent transition-colors text-[10px]","aria-label":h?"Expand outline":"Collapse outline",children:[(0,g.jsx)(oQ,{className:"h-3 w-3"}),!h&&(0,g.jsx)("span",{children:"Outline"})]}),!h&&(0,g.jsx)("nav",{"aria-label":"Document outline",className:"flex flex-col gap-px max-h-[50vh] overflow-y-auto pr-1",children:v})]}),s&&(0,g.jsxs)("div",{className:"absolute right-2 top-2 z-30 xl:hidden",children:[(0,g.jsx)("button",{onClick:()=>u(a=>!a),className:"flex items-center gap-1 px-1.5 py-1 rounded bg-background/80 backdrop-blur border border-border/60 text-muted-foreground/60 hover:text-foreground hover:bg-accent transition-colors text-[10px] shadow-sm","aria-label":"Document outline","aria-expanded":t,children:(0,g.jsx)(oQ,{className:"h-3.5 w-3.5"})}),t&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("button",{"aria-hidden":!0,tabIndex:-1,className:"fixed inset-0 z-0 cursor-default",onClick:()=>u(!1)}),(0,g.jsx)("nav",{"aria-label":"Document outline",className:"absolute right-0 top-9 z-10 w-52 max-h-[60vh] overflow-y-auto flex flex-col gap-px rounded-lg border border-border bg-popover p-2 shadow-lg",children:v})]})]})]})}let uc=`
127
+ `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:a,chain:b,state:c,editor:d})=>a.first([()=>a.exitCode(),()=>a.command(()=>{let{selection:a,storedMarks:e}=c;if(a.$from.parent.type.spec.isolating)return!1;let{keepMarks:f}=this.options,{splittableMarks:g}=d.extensionManager,h=e||a.$to.parentOffset&&a.$from.marks();return b().insertContent({type:this.name}).command(({tr:a,dispatch:b})=>{if(b&&h&&f){let b=h.filter(a=>g.includes(a.type.name));a.ensureMarks(b)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),r5=my.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map(a=>({tag:`h${a}`,attrs:{level:a}}))},renderHTML({node:a,HTMLAttributes:b}){let c=this.options.levels.includes(a.attrs.level)?a.attrs.level:this.options.levels[0];return[`h${c}`,ld(this.options.HTMLAttributes,b),0]},parseMarkdown:(a,b)=>b.createNode("heading",{level:a.depth||1},b.parseInline(a.tokens||[])),renderMarkdown:(a,b)=>{var c;let d=(null==(c=a.attrs)?void 0:c.level)?parseInt(a.attrs.level,10):1,e="#".repeat(d);return a.content?`${e} ${b.renderChildren(a.content)}`:""},addCommands(){return{setHeading:a=>({commands:b})=>!!this.options.levels.includes(a.level)&&b.setNode(this.name,a),toggleHeading:a=>({commands:b})=>!!this.options.levels.includes(a.level)&&b.toggleNode(this.name,"paragraph",a)}},addKeyboardShortcuts(){return this.options.levels.reduce((a,b)=>({...a,[`Mod-Alt-${b}`]:()=>this.editor.commands.toggleHeading({level:b})}),{})},addInputRules(){return this.options.levels.map(a=>mm({find:RegExp(`^(#{${Math.min(...this.options.levels)},${a}})\\s$`),type:this.type,getAttributes:{level:a}}))}}),r6=my.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{},nextNodeType:"paragraph"}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:a}){return["hr",ld(this.options.HTMLAttributes,a)]},markdownTokenName:"hr",parseMarkdown:(a,b)=>b.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:a,state:b})=>{if(!function(a,b){let{selection:c}=a,{$from:d}=c;if(c instanceof fJ){let a=d.index();return d.parent.canReplaceWith(a,a+1,b)}let e=d.depth;for(;e>=0;){let a=d.index(e);if(d.node(e).contentMatchAt(a).matchType(b))return!0;e-=1}return!1}(b,b.schema.nodes[this.name]))return!1;let{selection:c}=b,{$to:d}=c,e=a();return lw(c)?e.insertContentAt(d.pos,{type:this.name}):e.insertContent({type:this.name}),e.command(({state:a,tr:b,dispatch:c})=>{if(c){let{$to:c}=b.selection,d=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?b.setSelection(fH.create(b.doc,c.pos+1)):c.nodeAfter.isBlock?b.setSelection(fJ.create(b.doc,c.pos)):b.setSelection(fH.create(b.doc,c.pos));else{let e=a.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,f=null==e?void 0:e.create();f&&(b.insert(d,f),b.setSelection(fH.create(b.doc,d+1)))}b.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ml({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),r7=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,r8=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,r9=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,sa=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,sb=l1.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:a=>"normal"!==a.style.fontStyle&&null},{style:"font-style=normal",clearMark:a=>a.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:a}){return["em",ld(this.options.HTMLAttributes,a),0]},addCommands(){return{setItalic:()=>({commands:a})=>a.setMark(this.name),toggleItalic:()=>({commands:a})=>a.toggleMark(this.name),unsetItalic:()=>({commands:a})=>a.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(a,b)=>b.applyMark("italic",b.parseInline(a.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(a,b)=>`*${b.renderChildren(a)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[mk({find:r7,type:this.type}),mk({find:r9,type:this.type})]},addPasteRules(){return[mA({find:r8,type:this.type}),mA({find:sa,type:this.type})]}}),sc="&nbsp;",sd=my.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:a}){return["p",ld(this.options.HTMLAttributes,a),0]},parseMarkdown:(a,b)=>{let c=a.tokens||[];if(1===c.length&&"image"===c[0].type)return b.parseChildren([c[0]]);let d=b.parseInline(c);return 1===c.length&&"text"===c[0].type&&(c[0].raw===sc||c[0].text===sc||" "===c[0].raw||" "===c[0].text)&&1===d.length&&"text"===d[0].type&&(d[0].text===sc||" "===d[0].text)?b.createNode("paragraph",void 0,[]):b.createNode("paragraph",void 0,d)},renderMarkdown:(a,b,c)=>{var d,e;if(!a)return"";let f=Array.isArray(a.content)?a.content:[];if(0===f.length){let a=Array.isArray(null==(d=null==c?void 0:c.previousNode)?void 0:d.content)?c.previousNode.content:[];return(null==(e=null==c?void 0:c.previousNode)?void 0:e.type)==="paragraph"&&0===a.length?sc:""}return b.renderChildren(f)},addCommands(){return{setParagraph:()=>({commands:a})=>a.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),se=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,sf=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,sg=l1.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:a=>!!a.includes("line-through")&&{}}],renderHTML({HTMLAttributes:a}){return["s",ld(this.options.HTMLAttributes,a),0]},markdownTokenName:"del",parseMarkdown:(a,b)=>b.applyMark("strike",b.parseInline(a.tokens||[])),renderMarkdown:(a,b)=>`~~${b.renderChildren(a)}~~`,addCommands(){return{setStrike:()=>({commands:a})=>a.setMark(this.name),toggleStrike:()=>({commands:a})=>a.toggleMark(this.name),unsetStrike:()=>({commands:a})=>a.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[mk({find:se,type:this.type})]},addPasteRules(){return[mA({find:sf,type:this.type})]}}),sh=my.create({name:"text",group:"inline",parseMarkdown:a=>({type:"text",text:a.text||""}),renderMarkdown:a=>a.text||""}),si=l1.create({name:"underline",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:a=>!!a.includes("underline")&&{}}],renderHTML({HTMLAttributes:a}){return["u",ld(this.options.HTMLAttributes,a),0]},parseMarkdown(a,b){return b.applyMark(this.name||"underline",b.parseInline(a.tokens||[]))},renderMarkdown:(a,b)=>`++${b.renderChildren(a)}++`,markdownTokenizer:{name:"underline",level:"inline",start:a=>a.indexOf("++"),tokenize(a,b,c){let d=/^(\+\+)([\s\S]+?)(\+\+)/.exec(a);if(!d)return;let e=d[2].trim();return{type:"underline",raw:d[0],text:e,tokens:c.inlineTokens(e)}}},addCommands(){return{setUnderline:()=>({commands:a})=>a.setMark(this.name),toggleUnderline:()=>({commands:a})=>a.toggleMark(this.name),unsetUnderline:()=>({commands:a})=>a.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),sj=l5.create({name:"starterKit",addExtensions(){var a,b,c,d;let e=[];return!1!==this.options.bold&&e.push(rY.configure(this.options.bold)),!1!==this.options.blockquote&&e.push(rT.configure(this.options.blockquote)),!1!==this.options.bulletList&&e.push(rs.configure(this.options.bulletList)),!1!==this.options.code&&e.push(r_.configure(this.options.code)),!1!==this.options.codeBlock&&e.push(r2.configure(this.options.codeBlock)),!1!==this.options.document&&e.push(r3.configure(this.options.document)),!1!==this.options.dropcursor&&e.push(q0.configure(this.options.dropcursor)),!1!==this.options.gapcursor&&e.push(q1.configure(this.options.gapcursor)),!1!==this.options.hardBreak&&e.push(r4.configure(this.options.hardBreak)),!1!==this.options.heading&&e.push(r5.configure(this.options.heading)),!1!==this.options.undoRedo&&e.push(ra.configure(this.options.undoRedo)),!1!==this.options.horizontalRule&&e.push(r6.configure(this.options.horizontalRule)),!1!==this.options.italic&&e.push(sb.configure(this.options.italic)),!1!==this.options.listItem&&e.push(rt.configure(this.options.listItem)),!1!==this.options.listKeymap&&e.push(rH.configure(null==(a=this.options)?void 0:a.listKeymap)),!1!==this.options.link&&e.push(qB.configure(null==(b=this.options)?void 0:b.link)),!1!==this.options.orderedList&&e.push(rM.configure(this.options.orderedList)),!1!==this.options.paragraph&&e.push(sd.configure(this.options.paragraph)),!1!==this.options.strike&&e.push(sg.configure(this.options.strike)),!1!==this.options.text&&e.push(sh.configure(this.options.text)),!1!==this.options.underline&&e.push(si.configure(null==(c=this.options)?void 0:c.underline)),!1!==this.options.trailingNode&&e.push(q9.configure(null==(d=this.options)?void 0:d.trailingNode)),e}});function sk(a){let b=a.regex,c={};Object.assign(c,{className:"variable",variants:[{begin:b.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},{begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[c]}]}]});let d={className:"subst",begin:/\$\(/,end:/\)/,contains:[a.BACKSLASH_ESCAPE]},e=a.inherit(a.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),f={begin:/<<-?\s*(?=\w+)/,starts:{contains:[a.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},g={className:"string",begin:/"/,end:/"/,contains:[a.BACKSLASH_ESCAPE,c,d]};d.contains.push(g);let h={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},a.NUMBER_MODE,c]},i=a.SHEBANG({binary:"(fish|bash|zsh|sh|csh|ksh|tcsh|dash|scsh)",relevance:10}),j={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[a.inherit(a.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0};return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],literal:["true","false"],built_in:["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset","alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias","set","shopt","autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp","chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"]},contains:[i,a.SHEBANG(),j,h,e,f,{match:/(\/[a-z._-]+)+/},g,{match:/\\"/},{className:"string",begin:/'/,end:/'/},{match:/\\'/},c]}}let sl=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video","defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],sm=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),sn=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),so=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),sp=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function sq(a){let b=a.regex,c={IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:a.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[a.APOS_STRING_MODE,a.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:a.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}},d=[a.APOS_STRING_MODE,a.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[c.BLOCK_COMMENT,{begin:/-(webkit|moz|ms|o)-(?=[a-z])/},c.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\.[a-zA-Z-][a-zA-Z0-9_-]*",relevance:0},c.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+sn.join("|")+")"},{begin:":(:)?("+so.join("|")+")"}]},c.CSS_VARIABLE,{className:"attribute",begin:"\\b("+sp.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[c.BLOCK_COMMENT,c.HEXCOLOR,c.IMPORTANT,c.CSS_NUMBER_MODE,...d,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...d,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},c.FUNCTION_DISPATCH]},{begin:b.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:/@-?\w[\w]*(-\w+)*/},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:"and or not only",attribute:sm.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...d,c.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+sl.join("|")+")\\b"}]}}function sr(a){let b={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:b,illegal:"</",contains:[a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,{className:"string",variants:[a.QUOTE_STRING_MODE,a.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[a.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:b,illegal:/["']/}]}]}}let ss="[A-Za-z$_][0-9A-Za-z$_]*",st=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],su=["true","false","null","undefined","NaN","Infinity"],sv=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],sw=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],sx=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],sy=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],sz=[].concat(sx,sv,sw);function sA(a){var b;let c=a.regex,d=/<[A-Za-z0-9\\._:-]+/,e=/\/[A-Za-z0-9\\._:-]+>|\/>/,f={$pattern:ss,keyword:st,literal:su,built_in:sz,"variable.language":sy},g="[0-9](_?[0-9])*",h=`\\.(${g})`,i="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",j={className:"number",variants:[{begin:`(\\b(${i})((${h})|\\.)?|(${h}))[eE][+-]?(${g})\\b`},{begin:`\\b(${i})\\b((${h})\\b|\\.)?|(${h})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},k={className:"subst",begin:"\\$\\{",end:"\\}",keywords:f,contains:[]},l={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[a.BACKSLASH_ESCAPE,k],subLanguage:"xml"}},m={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[a.BACKSLASH_ESCAPE,k],subLanguage:"css"}},n={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[a.BACKSLASH_ESCAPE,k],subLanguage:"graphql"}},o={className:"string",begin:"`",end:"`",contains:[a.BACKSLASH_ESCAPE,k]},p={className:"comment",variants:[a.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:ss+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),a.C_BLOCK_COMMENT_MODE,a.C_LINE_COMMENT_MODE]},q=[a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,l,m,n,o,{match:/\$\d+/},j];k.contains=q.concat({begin:/\{/,end:/\}/,keywords:f,contains:["self"].concat(q)});let r=[].concat(p,k.contains),s=r.concat([{begin:/(\s*)\(/,end:/\)/,keywords:f,contains:["self"].concat(r)}]),t={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:f,contains:s},u={variants:[{match:[/class/,/\s+/,ss,/\s+/,/extends/,/\s+/,c.concat(ss,"(",c.concat(/\./,ss),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,ss],scope:{1:"keyword",3:"title.class"}}]},v={relevance:0,match:c.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...sv,...sw]}},w={match:c.concat(/\b/,(b=[...sx,"super","import"].map(a=>`${a}\\s*\\(`),c.concat("(?!",b.join("|"),")")),ss,c.lookahead(/\s*\(/)),className:"title.function",relevance:0},x={begin:c.concat(/\./,c.lookahead(c.concat(ss,/(?![0-9A-Za-z$_(])/))),end:ss,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},y="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+a.UNDERSCORE_IDENT_RE+")\\s*=>",z={match:[/const|var|let/,/\s+/,ss,/\s*/,/=\s*/,/(async\s*)?/,c.lookahead(y)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[t]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:f,exports:{PARAMS_CONTAINS:s,CLASS_REFERENCE:v},illegal:/#(?![$_A-z])/,contains:[a.SHEBANG({label:"shebang",binary:"node",relevance:5}),{label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,l,m,n,o,p,{match:/\$\d+/},j,v,{scope:"attr",match:ss+c.lookahead(":"),relevance:0},z,{begin:"("+a.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[p,a.REGEXP_MODE,{className:"function",begin:y,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:a.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:f,contains:s}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:"<>",end:"</>"},{match:/<[A-Za-z0-9\\._:-]+\s*\/>/},{begin:d,"on:begin":(a,b)=>{let c,d=a[0].length+a.index,e=a.input[d];if("<"===e||","===e)return void b.ignoreMatch();">"!==e||((a,{after:b})=>{let c="</"+a[0].slice(1);return -1!==a.input.indexOf(c,b)})(a,{after:d})||b.ignoreMatch();let f=a.input.substring(d);if((c=f.match(/^\s*=/))||(c=f.match(/^\s+extends\s+/))&&0===c.index)return void b.ignoreMatch()},end:e}],subLanguage:"xml",contains:[{begin:d,end:e,skip:!0,contains:["self"]}]}]},{variants:[{match:[/function/,/\s+/,ss,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[t],illegal:/%/},{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+a.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[t,a.inherit(a.TITLE_MODE,{begin:ss,className:"title.function"})]},{match:/\.\.\./,relevance:0},x,{match:"\\$"+ss,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[t]},w,{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},u,{match:[/get|set/,/\s+/,ss,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},t]},{match:/\$[(.]/}]}}function sB(a){let b=["true","false","null"],c={scope:"literal",beginKeywords:b.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:b},contains:[{className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},{match:/[{}[\],:]/,className:"punctuation",relevance:0},a.QUOTE_STRING_MODE,c,a.C_NUMBER_MODE,a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function sC(a){let b=a.regex,c={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},d={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:b.concat(/\[.+?\]\(/,/[A-Za-z][A-Za-z0-9+.-]*/,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},e={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},f={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},g=a.inherit(e,{contains:[]}),h=a.inherit(f,{contains:[]});e.contains.push(h),f.contains.push(g);let i=[c,d];return[e,f,g,h].forEach(a=>{a.contains=a.contains.concat(i)}),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:i=i.concat(e,f)},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:i}]}]},c,{className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},e,f,{className:"quote",begin:"^>\\s+",contains:i,end:"$"},{className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},{begin:"^[-\\*]{3,}",end:"$"},d,{begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function sD(a){let b=a.regex,c=/[\p{XID_Start}_]\p{XID_Continue}*/u,d=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],e={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:d,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},f={className:"meta",begin:/^(>>>|\.\.\.) /},g={className:"subst",begin:/\{/,end:/\}/,keywords:e,illegal:/#/},h={begin:/\{\{/,relevance:0},i={className:"string",contains:[a.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[a.BACKSLASH_ESCAPE,f],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[a.BACKSLASH_ESCAPE,f],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[a.BACKSLASH_ESCAPE,f,h,g]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[a.BACKSLASH_ESCAPE,f,h,g]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[a.BACKSLASH_ESCAPE,h,g]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[a.BACKSLASH_ESCAPE,h,g]},a.APOS_STRING_MODE,a.QUOTE_STRING_MODE]},j="[0-9](_?[0-9])*",k=`(\\b(${j}))?\\.(${j})|\\b(${j})\\.`,l=`\\b|${d.join("|")}`,m={className:"number",relevance:0,variants:[{begin:`(\\b(${j})|(${k}))[eE][+-]?(${j})[jJ]?(?=${l})`},{begin:`(${k})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${l})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${l})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${l})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${l})`},{begin:`\\b(${j})[jJ](?=${l})`}]},n={className:"comment",begin:b.lookahead(/# type:/),end:/$/,keywords:e,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},o={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:e,contains:["self",f,m,i,a.HASH_COMMENT_MODE]}]};return g.contains=[i,m,f],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:e,illegal:/(<\/|\?)|=>/,contains:[f,m,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},i,n,a.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,c],scope:{1:"keyword",3:"title.function"},contains:[o]},{variants:[{match:[/\bclass/,/\s+/,c,/\s*/,/\(\s*/,c,/\s*\)/]},{match:[/\bclass/,/\s+/,c]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[m,o,i]}]}}function sE(a){let b=a.regex,c=/(r#)?/,d=b.concat(c,a.UNDERSCORE_IDENT_RE),e=b.concat(c,a.IDENT_RE),f={className:"title.function.invoke",relevance:0,begin:b.concat(/\b/,/(?!let|for|while|if|else|match\b)/,e,b.lookahead(/\s*\(/))},g="([ui](8|16|32|64|128|size)|f(32|64))?",h=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],i=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:a.IDENT_RE+"!?",type:i,keyword:["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],literal:["true","false","Some","None","Ok","Err"],built_in:h},illegal:"</",contains:[a.C_LINE_COMMENT_MODE,a.COMMENT("/\\*","\\*/",{contains:["self"]}),a.inherit(a.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+g},{begin:"\\b0o([0-7_]+)"+g},{begin:"\\b0x([A-Fa-f0-9_]+)"+g},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+g}],relevance:0},{begin:[/fn/,/\s+/,d],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[a.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,d],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,d,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,d],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,d],className:{1:"keyword",3:"title.class"}},{begin:a.IDENT_RE+"::",keywords:{keyword:"Self",built_in:h,type:i}},{className:"punctuation",begin:"->"},f]}}function sF(a){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function sG(a){let b=a.regex,c=a.COMMENT("--","$"),d=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],e=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year","add","asc","collation","desc","final","first","last","view"].filter(a=>!d.includes(a)),f={match:b.concat(/\b/,b.either(...d),/\s*\(/),relevance:0,keywords:{built_in:d}};function g(a){return b.concat(/\b/,b.either(...a.map(a=>a.replace(/\s+/,"\\s+"))),/\b/)}let h={scope:"keyword",match:g(["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"]),relevance:0};return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:function(a,{exceptions:b,when:c}={}){return b=b||[],a.map(a=>a.match(/\|\d+$/)||b.includes(a)?a:c(a)?`${a}|0`:a)}(e,{when:a=>a.length<3}),literal:["true","false","unknown"],type:["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],built_in:["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"]},contains:[{scope:"type",match:g(["double precision","large object","with timezone","without timezone"])},h,f,{scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},{scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},{begin:/"/,end:/"/,contains:[{match:/""/}]},a.C_NUMBER_MODE,a.C_BLOCK_COMMENT_MODE,c,{scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0}]}}let sH="[A-Za-z$_][0-9A-Za-z$_]*",sI=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],sJ=["true","false","null","undefined","NaN","Infinity"],sK=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],sL=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],sM=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],sN=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],sO=[].concat(sM,sK,sL);function sP(a){var b;let c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B=a.regex,C=(c=a.regex,d=/<[A-Za-z0-9\\._:-]+/,e=/\/[A-Za-z0-9\\._:-]+>|\/>/,f=(a,b)=>{let c,d=a[0].length+a.index,e=a.input[d];if("<"===e||","===e)return void b.ignoreMatch();">"!==e||((a,{after:b})=>{let c="</"+a[0].slice(1);return -1!==a.input.indexOf(c,b)})(a,{after:d})||b.ignoreMatch();let f=a.input.substring(d);if((c=f.match(/^\s*=/))||(c=f.match(/^\s+extends\s+/))&&0===c.index)return void b.ignoreMatch()},g={$pattern:sH,keyword:sI,literal:sJ,built_in:sO,"variable.language":sN},h="[0-9](_?[0-9])*",i=`\\.(${h})`,j="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",k={className:"number",variants:[{begin:`(\\b(${j})((${i})|\\.)?|(${i}))[eE][+-]?(${h})\\b`},{begin:`\\b(${j})\\b((${i})\\b|\\.)?|(${i})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},l={className:"subst",begin:"\\$\\{",end:"\\}",keywords:g,contains:[]},m={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[a.BACKSLASH_ESCAPE,l],subLanguage:"xml"}},n={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[a.BACKSLASH_ESCAPE,l],subLanguage:"css"}},o={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[a.BACKSLASH_ESCAPE,l],subLanguage:"graphql"}},p={className:"string",begin:"`",end:"`",contains:[a.BACKSLASH_ESCAPE,l]},q={className:"comment",variants:[a.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:sH+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),a.C_BLOCK_COMMENT_MODE,a.C_LINE_COMMENT_MODE]},l.contains=(r=[a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,m,n,o,p,{match:/\$\d+/},k]).concat({begin:/\{/,end:/\}/,keywords:g,contains:["self"].concat(r)}),t=(s=[].concat(q,l.contains)).concat([{begin:/(\s*)\(/,end:/\)/,keywords:g,contains:["self"].concat(s)}]),u={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:g,contains:t},v={variants:[{match:[/class/,/\s+/,sH,/\s+/,/extends/,/\s+/,c.concat(sH,"(",c.concat(/\./,sH),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,sH],scope:{1:"keyword",3:"title.class"}}]},w={relevance:0,match:c.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...sK,...sL]}},x={match:c.concat(/\b/,(b=[...sM,"super","import"].map(a=>`${a}\\s*\\(`),c.concat("(?!",b.join("|"),")")),sH,c.lookahead(/\s*\(/)),className:"title.function",relevance:0},y={begin:c.concat(/\./,c.lookahead(c.concat(sH,/(?![0-9A-Za-z$_(])/))),end:sH,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},z="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+a.UNDERSCORE_IDENT_RE+")\\s*=>",A={match:[/const|var|let/,/\s+/,sH,/\s*/,/=\s*/,/(async\s*)?/,c.lookahead(z)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[u]},{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:g,exports:{PARAMS_CONTAINS:t,CLASS_REFERENCE:w},illegal:/#(?![$_A-z])/,contains:[a.SHEBANG({label:"shebang",binary:"node",relevance:5}),{label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,m,n,o,p,q,{match:/\$\d+/},k,w,{scope:"attr",match:sH+c.lookahead(":"),relevance:0},A,{begin:"("+a.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[q,a.REGEXP_MODE,{className:"function",begin:z,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:a.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:g,contains:t}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:"<>",end:"</>"},{match:/<[A-Za-z0-9\\._:-]+\s*\/>/},{begin:d,"on:begin":f,end:e}],subLanguage:"xml",contains:[{begin:d,end:e,skip:!0,contains:["self"]}]}]},{variants:[{match:[/function/,/\s+/,sH,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[u],illegal:/%/},{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+a.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[u,a.inherit(a.TITLE_MODE,{begin:sH,className:"title.function"})]},{match:/\.\.\./,relevance:0},y,{match:"\\$"+sH,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[u]},x,{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},v,{match:[/get|set/,/\s+/,sH,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},u]},{match:/\$[(.]/}]}),D=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],E={begin:[/namespace/,/\s+/,a.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},F={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:D},contains:[C.exports.CLASS_REFERENCE]},G={$pattern:sH,keyword:sI.concat(["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"]),literal:sJ,built_in:sO.concat(D),"variable.language":sN},H={className:"meta",begin:"@"+sH},I=(a,b,c)=>{let d=a.contains.findIndex(a=>a.label===b);if(-1===d)throw Error("can not find mode to replace");a.contains.splice(d,1,c)};Object.assign(C.keywords,G),C.exports.PARAMS_CONTAINS.push(H);let J=C.contains.find(a=>"attr"===a.scope),K=Object.assign({},J,{match:B.concat(sH,B.lookahead(/\s*\?:/))});return C.exports.PARAMS_CONTAINS.push([C.exports.CLASS_REFERENCE,J,K]),C.contains=C.contains.concat([H,E,F,K]),I(C,"shebang",a.SHEBANG()),I(C,"use_strict",{className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/}),C.contains.find(a=>"func.def"===a.label).relevance=0,Object.assign(C,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),C}function sQ(a){let b=a.regex,c=b.concat(/[\p{L}_]/u,b.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),d={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},e={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},f=a.inherit(e,{begin:/\(/,end:/\)/}),g=a.inherit(a.APOS_STRING_MODE,{className:"string"}),h=a.inherit(a.QUOTE_STRING_MODE,{className:"string"}),i={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:/[\p{L}0-9._:-]+/u,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[d]},{begin:/'/,end:/'/,contains:[d]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[e,h,g,f,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[e,f,h,g]}]}]},a.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},d,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[h]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[i],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[i],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:b.concat(/</,b.lookahead(b.concat(c,b.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:c,relevance:0,starts:i}]},{className:"tag",begin:b.concat(/<\//,b.lookahead(b.concat(c,/>/))),contains:[{className:"name",begin:c,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function sR(a){let b="true false yes no null",c="[\\w#;/?:@&=+$,.~*'()[\\]]+",d={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[a.BACKSLASH_ESCAPE,{className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]}]},e=a.inherit(d,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),f={end:",",endsWithParent:!0,excludeEnd:!0,keywords:b,relevance:0},g=[{className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+c},{className:"type",begin:"!<"+c+">"},{className:"type",begin:"!"+c},{className:"type",begin:"!!"+c},{className:"meta",begin:"&"+a.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+a.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},a.HASH_COMMENT_MODE,{beginKeywords:b,keywords:{literal:b}},{className:"number",begin:"\\b[0-9]{4}(-[0-9][0-9]){0,2}([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?(\\.[0-9]*)?([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?\\b"},{className:"number",begin:a.C_NUMBER_RE+"\\b",relevance:0},{begin:/\{/,end:/\}/,contains:[f],illegal:"\\n",relevance:0},{begin:"\\[",end:"\\]",contains:[f],illegal:"\\n",relevance:0},{className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},d],h=[...g];return h.pop(),h.push(e),f.contains=h,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:g}}var sS=a.i(451949);let sT=a.i(752344).default,sU={};function sV(a){let b=sT.newInstance();return a&&e(a),{highlight:c,highlightAuto:function(a,e){let f;(0,sS.ok)("string"==typeof a,"expected `string` as `value`");let g=(e||sU).subset||d(),h=-1,i=0;for(;++h<g.length;){let d=g[h];if(!b.getLanguage(d))continue;let j=c(d,a,e);j.data&&void 0!==j.data.relevance&&j.data.relevance>i&&(i=j.data.relevance,f=j)}return f||{type:"root",children:[],data:{language:void 0,relevance:i}}},listLanguages:d,register:e,registerAlias:function(a,c){if("string"==typeof a)(0,sS.ok)(void 0!==c),b.registerAliases("string"==typeof c?c:[...c],{languageName:a});else{let c;for(c in a)if(Object.hasOwn(a,c)){let d=a[c];b.registerAliases("string"==typeof d?d:[...d],{languageName:c})}}},registered:function(a){return!!b.getLanguage(a)}};function c(a,c,d){(0,sS.ok)("string"==typeof a,"expected `string` as `name`"),(0,sS.ok)("string"==typeof c,"expected `string` as `value`");let e=d||sU,f="string"==typeof e.prefix?e.prefix:"hljs-";if(!b.getLanguage(a))throw Error("Unknown language: `"+a+"` is not registered");b.configure({__emitter:sW,classPrefix:f});let g=b.highlight(c,{ignoreIllegals:!0,language:a});if(g.errorRaised)throw Error("Could not highlight with `Highlight.js`",{cause:g.errorRaised});let h=g._emitter.root,i=h.data;return i.language=g.language,i.relevance=g.relevance,h}function d(){return b.listLanguages()}function e(a,c){if("string"==typeof a)(0,sS.ok)(void 0!==c,"expected `grammar`"),b.registerLanguage(a,c);else{let c;for(c in a)Object.hasOwn(a,c)&&b.registerLanguage(c,a[c])}}}class sW{constructor(a){this.options=a,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(a){if(""===a)return;let b=this.stack[this.stack.length-1],c=b.children[b.children.length-1];c&&"text"===c.type?c.value+=a:b.children.push({type:"text",value:a})}startScope(a){this.openNode(String(a))}endScope(){this.closeNode()}__addSublanguage(a,b){let c=this.stack[this.stack.length-1],d=a.root.children;b?c.children.push({type:"element",tagName:"span",properties:{className:[b]},children:d}):c.children.push(...d)}openNode(a){let b=this,c=a.split(".").map(function(a,c){return c?a+"_".repeat(c):b.options.classPrefix+a}),d=this.stack[this.stack.length-1],e={type:"element",tagName:"span",properties:{className:c},children:[]};d.children.push(e),this.stack.push(e)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}let sX=my.create({name:"callout",group:"block",content:"block+",defining:!0,addAttributes:()=>({type:{default:"info",parseHTML:a=>a.getAttribute("data-callout-type")||"info",renderHTML:a=>({"data-callout-type":a.type})}}),parseHTML:()=>[{tag:'div[data-callout="true"]'}],renderHTML:({HTMLAttributes:a})=>["div",ld(a,{"data-callout":"true",class:`callout callout-${a["data-callout-type"]||"info"}`}),0]});function sY(a,b,c){let{selection:d,doc:e}=a,f=e.resolve(d.from);for(;f.depth>1;)f=e.resolve(f.before(f.depth));if(0===f.depth)return!1;let g=f.before(1),h=e.nodeAt(g);if(!h)return!1;let i=f.index(0),j="up"===c?i-1:i+1;if(j<0||j>=e.childCount)return!1;let k=e.child(j),l=a.tr,m=g+h.nodeSize,n="up"===c?g-k.nodeSize:m,o="up"===c?g:m+k.nodeSize;if("up"===c)l=(l=(l=l.delete(g,m)).insert(n,h)).setSelection(fJ.create(l.doc,n));else{l=l.delete(g,m);let a=o-h.nodeSize;l=(l=l.insert(a,h)).setSelection(fJ.create(l.doc,a))}return b&&b(l.scrollIntoView()),!0}let sZ="cabinet-drag-handle",s$="cabinet-gutter-add",s_=l5.create({name:"dragHandle",addKeyboardShortcuts:()=>({"Mod-Alt-ArrowUp":({editor:a})=>sY(a.state,a.view.dispatch,"up"),"Mod-Alt-ArrowDown":({editor:a})=>sY(a.state,a.view.dispatch,"down"),"Alt-Shift-ArrowUp":({editor:a})=>sY(a.state,a.view.dispatch,"up"),"Alt-Shift-ArrowDown":({editor:a})=>sY(a.state,a.view.dispatch,"down")}),addProseMirrorPlugins(){let a,b,c=null,d="u">typeof document?((a=document.getElementById(sZ))||((a=document.createElement("div")).id=sZ,a.setAttribute("data-drag-handle","true"),a.draggable=!0,a.innerHTML='<svg width="10" height="16" viewBox="0 0 10 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><circle cx="2.5" cy="3" r="1.2"/><circle cx="2.5" cy="8" r="1.2"/><circle cx="2.5" cy="13" r="1.2"/><circle cx="7.5" cy="3" r="1.2"/><circle cx="7.5" cy="8" r="1.2"/><circle cx="7.5" cy="13" r="1.2"/></svg>',Object.assign(a.style,{position:"absolute",display:"none",cursor:"grab",padding:"2px 4px",borderRadius:"4px",color:"var(--muted-foreground)",opacity:"0.55",zIndex:"40",userSelect:"none",transition:"opacity 120ms ease"}),a.addEventListener("mouseenter",()=>{a&&(a.style.opacity="1")}),a.addEventListener("mouseleave",()=>{a&&(a.style.opacity="0.55")}),document.body.appendChild(a)),a):null,e="u">typeof document?((b=document.getElementById(s$))||((b=document.createElement("button")).id=s$,b.type="button",b.setAttribute("aria-label","Add block"),b.title="Add block",b.innerHTML='<svg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5 1V9M1 5H9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>',Object.assign(b.style,{position:"absolute",display:"none",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",cursor:"pointer",borderRadius:"4px",color:"var(--muted-foreground)",opacity:"0.55",zIndex:"40",transition:"opacity 120ms ease, background 120ms ease",background:"transparent",border:"none",padding:"0"}),b.addEventListener("mouseenter",()=>{b&&(b.style.opacity="1",b.style.background="var(--muted)")}),b.addEventListener("mouseleave",()=>{b&&(b.style.opacity="0.55",b.style.background="transparent")}),document.body.appendChild(b)),b):null,f=()=>{d&&(d.style.display="none"),e&&(e.style.display="none"),c=null};return[new fV({key:new fY("cabinetDragHandle"),view:a=>{if(!d)return{destroy:()=>{}};let b=b=>{if(!a.editable)return;let g=a.dom.getBoundingClientRect();if(b.clientX<g.left-60||b.clientX>g.right+60||b.clientY<g.top||b.clientY>g.bottom)return void f();let h=function(a,b){let c=a.posAtCoords(b);if(!c)return null;let d=a.state.doc.resolve(c.inside>=0?c.inside:c.pos);for(;d.depth>0&&!d.parent.type.isBlock;)d=a.state.doc.resolve(d.before());let e=d.depth;for(;e>1&&"doc"!==a.state.doc.resolve(d.before(e)).parent.type.name;)e-=1;let f=0===e?0:d.before(Math.max(e,1)),g=a.state.doc.nodeAt(f);if(!g)return null;let h=a.nodeDOM(f);return{pos:f,node:g,dom:h}}(a,{left:Math.max(g.left+20,Math.min(g.right-20,b.clientX)),top:b.clientY});if(!h?.dom||!(h.dom instanceof HTMLElement))return void f();c=h;let i=h.dom.getBoundingClientRect();d.style.display="flex",d.style.top=`${window.scrollY+i.top+4}px`,d.style.left=`${window.scrollX+i.left-22}px`,e&&(e.style.display="flex",e.style.top=`${window.scrollY+i.top+4}px`,e.style.left=`${window.scrollX+i.left-44}px`)},g=()=>f(),h=()=>{if(!c)return;let b=c.pos+c.node.nodeSize,d=b<=a.state.doc.content.size,e=a.state.tr;if(d){let c=fH.create(a.state.doc,Math.min(b-1,a.state.doc.content.size));a.dispatch(e.setSelection(c))}a.focus();let f=a.state.tr.split(a.state.selection.from);a.dispatch(f),a.dom.dispatchEvent(new KeyboardEvent("keydown",{key:"/",bubbles:!0,cancelable:!0}))},i=b=>{if(!c||!b.dataTransfer)return;let{pos:d,dom:e}=c,f=a.state.tr.setSelection(fJ.create(a.state.doc,d));a.dispatch(f);let g=a.state.selection.content(),h=document.createElement("div");h.appendChild(a.someProp("clipboardSerializer")?.serializeFragment(g.content)??document.createElement("div")),b.dataTransfer.clearData(),b.dataTransfer.setData("text/html",h.innerHTML),b.dataTransfer.setData("text/plain",e.textContent??""),b.dataTransfer.effectAllowed="copyMove",b.dataTransfer.setDragImage(e,0,0),a.dragging={slice:g,move:!0}};return window.addEventListener("mousemove",b),a.dom.addEventListener("mouseleave",g),d.addEventListener("dragstart",i),e&&e.addEventListener("click",h),{destroy(){window.removeEventListener("mousemove",b),a.dom.removeEventListener("mouseleave",g),d.removeEventListener("dragstart",i),e&&e.removeEventListener("click",h),f()}}}})]}}),s0=new fY("headingAnchors");function s1(a){let b=[],c=new Map;return a.descendants((a,d)=>{if("heading"!==a.type.name)return;let e=a.textContent.toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-");if(!e)return;let f=c.get(e)??0;c.set(e,f+1);let g=0===f?e:`${e}-${f}`;b.push(hZ.node(d,d+a.nodeSize,{id:g}))}),h0.create(a,b)}let s2=l5.create({name:"headingAnchors",addProseMirrorPlugins:()=>[new fV({key:s0,state:{init:(a,{doc:b})=>s1(b),apply:(a,b)=>a.docChanged?s1(a.doc):b},props:{decorations:a=>s0.getState(a)}})]});function s3(a){return a.value||a.children||[]}function s4({doc:a,name:b,lowlight:c,defaultLanguage:d}){let e=[];return k2(a,a=>a.type.name===b).forEach(a=>{var b;let f=a.pos+1,g=a.node.attrs.language||d,h=c.listLanguages();(function a(b,c=[]){return b.flatMap(b=>{let d=[...c,...b.properties?b.properties.className:[]];return b.children?a(b.children,d):{text:b.value,classes:d}})})(g&&(h.includes(g)||sT.getLanguage(g)||(null==(b=c.registered)?void 0:b.call(c,g)))?s3(c.highlight(g,a.node.textContent)):s3(c.highlightAuto(a.node.textContent))).forEach(a=>{let b=f+a.text.length;if(a.classes.length){let c=hZ.inline(f,b,{class:a.classes.join(" ")});e.push(c)}f=b})}),h0.create(a,e)}var s5=r2.extend({addOptions(){var a;return{...null==(a=this.parent)?void 0:a.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},addProseMirrorPlugins(){var a;return[...(null==(a=this.parent)?void 0:a.call(this))||[],function({name:a,lowlight:b,defaultLanguage:c}){if(!["highlight","highlightAuto","listLanguages"].every(a=>"function"==typeof b[a]))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");let d=new fV({key:new fY("lowlight"),state:{init:(d,{doc:e})=>s4({doc:e,name:a,lowlight:b,defaultLanguage:c}),apply:(d,e,f,g)=>{let h=f.selection.$head.parent.type.name,i=g.selection.$head.parent.type.name,j=k2(f.doc,b=>b.type.name===a),k=k2(g.doc,b=>b.type.name===a);return d.docChanged&&([h,i].includes(a)||k.length!==j.length||d.steps.some(a=>void 0!==a.from&&void 0!==a.to&&j.some(b=>b.pos>=a.from&&b.pos+b.node.nodeSize<=a.to)))?s4({doc:d.doc,name:a,lowlight:b,defaultLanguage:c}):e.map(d.mapping,d.doc)}},props:{decorations:a=>d.getState(a)}});return d}({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}});let s6=(0,h.default)("maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]),s7=(0,h.default)("minimize-2",[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]]),s8=(0,h.default)("zoom-in",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),s9=(0,h.default)("zoom-out",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);function ta({svg:a,className:b,allowPlainWheel:c,maxHeight:d,onExpand:e,onClose:f}){let[h,i]=(0,p.useState)(1),[j,k]=(0,p.useState)({x:0,y:0}),[l,m]=(0,p.useState)(!1),[n,o]=(0,p.useState)(d),q=(0,p.useRef)({x:0,y:0,panX:0,panY:0}),r=(0,p.useRef)(null);(0,p.useLayoutEffect)(()=>{if(null==d)return;let a=r.current?.querySelector("svg");if(!a)return;let b=a.getBoundingClientRect().height;b&&o(Math.min(Math.round(b)+32,d))},[a,d]);let s=(0,p.useCallback)(a=>{if(!(c||a.ctrlKey||a.metaKey))return;a.preventDefault();let b=a.deltaY>0?-.25:.25;i(a=>Math.min(Math.max(a+b,.25),5))},[c]),t=(0,p.useCallback)(a=>{0===a.button&&(m(!0),q.current={x:a.clientX,y:a.clientY,panX:j.x,panY:j.y},a.target.setPointerCapture(a.pointerId))},[j]),u=(0,p.useCallback)(a=>{l&&k({x:q.current.panX+(a.clientX-q.current.x),y:q.current.panY+(a.clientY-q.current.y)})},[l]),w=(0,p.useCallback)(()=>m(!1),[]);return(0,g.jsxs)("div",{className:`relative overflow-hidden ${b??""}`,style:{cursor:l?"grabbing":"grab",height:null!=d?n:void 0},onWheel:s,onPointerDown:t,onPointerMove:u,onPointerUp:w,children:[(0,g.jsx)("div",{ref:r,className:"flex items-center justify-center w-full h-full min-h-full p-4 [&_svg]:max-w-full origin-center select-none",style:{transform:`translate(${j.x}px, ${j.y}px) scale(${h})`},dangerouslySetInnerHTML:{__html:a}}),(0,g.jsxs)("div",{className:"absolute top-2 right-2 flex items-center gap-0.5 rounded-md border border-border bg-card/90 backdrop-blur px-1 py-0.5 shadow-sm",contentEditable:!1,children:[(0,g.jsx)(v.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>i(a=>Math.max(a-.25,.25)),title:"Zoom out",children:(0,g.jsx)(s9,{className:"h-3.5 w-3.5"})}),(0,g.jsxs)("button",{type:"button",onClick:()=>{i(1),k({x:0,y:0})},title:"Reset view",className:"text-[11px] text-muted-foreground tabular-nums w-9 text-center select-none hover:text-foreground",children:[Math.round(100*h),"%"]}),(0,g.jsx)(v.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>i(a=>Math.min(a+.25,5)),title:"Zoom in",children:(0,g.jsx)(s8,{className:"h-3.5 w-3.5"})}),e&&(0,g.jsx)(v.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:e,title:"Pop out",children:(0,g.jsx)(s6,{className:"h-3.5 w-3.5"})}),f&&(0,g.jsx)(v.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:f,title:"Close",children:(0,g.jsx)(s7,{className:"h-3.5 w-3.5"})})]})]})}function tb({svg:a,className:b,maxHeight:c}){let[d,e]=(0,p.useState)(!1);return(0,p.useEffect)(()=>{if(!d)return;let a=a=>"Escape"===a.key&&e(!1);return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[d]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ta,{svg:a,className:b,maxHeight:c,onExpand:()=>e(!0)}),d&&"u">typeof document&&(0,bu.createPortal)((0,g.jsx)("div",{className:"fixed inset-0 z-50 bg-background/95 backdrop-blur",children:(0,g.jsx)(ta,{svg:a,className:"w-full h-full",allowPlainWheel:!0,onClose:()=>e(!1)})}),document.body)]})}let tc="rounded-md bg-muted p-4 font-mono text-sm",td=0;function te(b){let{node:c,editor:d}=b,e="mermaid"===(c.attrs.language??""),f=c.textContent,[h,i]=(0,p.useState)(""),[j,k]=(0,p.useState)(""),l=(0,p.useRef)(null);if((0,p.useEffect)(()=>{if(!e)return;let b=f.trim();if(!b){i(""),k("");return}return l.current&&clearTimeout(l.current),l.current=setTimeout(async()=>{try{let c=(await a.A(334743)).default;c.initialize({startOnLoad:!1,theme:document.documentElement.classList.contains("dark")?"dark":"default",securityLevel:"loose",suppressErrorRendering:!0}),await c.parse(b);let{svg:d}=await c.render(`mermaid-cb-${++td}`,b);i(d),k("")}catch(a){document.querySelectorAll('[id^="dmermaid-cb-"]').forEach(a=>a.remove()),k(a instanceof Error?a.message:"Failed to render")}},300),()=>{l.current&&clearTimeout(l.current)}},[e,f]),!e)return(0,g.jsx)(nf,{as:"pre",className:tc,children:(0,g.jsx)(ne,{as:"code"})});let m=d.isEditable,n=h&&(!m||!j);return(0,g.jsxs)(nf,{className:"my-3",children:[(0,g.jsx)("pre",{className:tc,style:{display:!m&&n?"none":void 0},children:(0,g.jsx)(ne,{as:"code"})}),n&&(0,g.jsx)("div",{className:"mermaid-preview rounded-md border border-border bg-card",contentEditable:!1,children:(0,g.jsx)(tb,{svg:h,className:"w-full",maxHeight:600})}),m&&j&&(0,g.jsxs)("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-2 text-xs text-red-500",contentEditable:!1,children:["Mermaid error: ",j]})]})}let tf=l1.create({name:"proofSpan",priority:900,inclusive:!1,keepOnSplit:!1,addAttributes:()=>({spanId:{default:null,parseHTML:a=>a.getAttribute("id"),renderHTML:a=>({id:a.spanId})},origin:{default:"ai",parseHTML:a=>a.getAttribute("origin"),renderHTML:a=>({origin:a.origin})},basis:{default:null,parseHTML:a=>a.getAttribute("basis"),renderHTML:a=>({basis:a.basis})},basisDetail:{default:null,parseHTML:a=>a.getAttribute("basis-detail"),renderHTML:a=>({"basis-detail":a.basisDetail})},by:{default:null,parseHTML:a=>a.getAttribute("by"),renderHTML:a=>({by:a.by})},at:{default:null,parseHTML:a=>a.getAttribute("at"),renderHTML:a=>({at:a.at})},inResponseTo:{default:null,parseHTML:a=>a.getAttribute("in-response-to"),renderHTML:a=>({"in-response-to":a.inResponseTo})}}),parseHTML:()=>[{tag:"proof-span"}],renderHTML:({HTMLAttributes:a})=>["proof-span",ld(a,{class:"proof-span"}),0]});var tg=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;function th(a){let{node:b,updateAttributes:c,selected:d,editor:e}=a,f=b.attrs,h=(0,p.useRef)(null),i=(0,p.useRef)(null),[j,k]=(0,p.useState)(null),l=f.align??"center",m=(0,p.useCallback)((a,b)=>{if(!e.isEditable)return;a.preventDefault(),a.stopPropagation();let d=h.current,f=i.current;if(!d||!f)return;let g=a.clientX,j=d.getBoundingClientRect().width,l=f.parentElement?.getBoundingClientRect().width??800,m=a=>{k(Math.max(80,Math.min(l,j+("right"===b?a.clientX-g:g-a.clientX))))},n=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",n),k(a=>(null!=a&&c({width:Math.round(a)}),null))};window.addEventListener("pointermove",m),window.addEventListener("pointerup",n)},[e.isEditable,c]),n=null!=j?`${Math.round(j)}px`:"number"==typeof f.width?`${f.width}px`:"string"==typeof f.width&&f.width?f.width:void 0,o="left"===l?"mr-auto":"right"===l?"ml-auto":"mx-auto";return(0,g.jsx)(nf,{as:"div",className:`resizable-image my-3 ${o}`,"data-align":l,style:{width:n??"fit-content",maxWidth:"100%"},children:(0,g.jsxs)("div",{ref:i,className:`relative group inline-block max-w-full ${d?"ring-2 ring-primary rounded-md":""}`,contentEditable:!1,children:[(0,g.jsx)("img",{ref:h,src:f.src,alt:f.alt??"",title:f.title??void 0,className:"block rounded-md max-w-full h-auto",style:{width:n},draggable:!1}),e.isEditable&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{"aria-label":"Resize from left",onPointerDown:a=>m(a,"left"),className:"hover-reveal resize-hit absolute left-0 top-0 bottom-0 w-2 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:(0,g.jsx)("div",{className:"w-1 h-8 bg-card border border-border rounded-full shadow"})}),(0,g.jsx)("div",{"aria-label":"Resize from right",onPointerDown:a=>m(a,"right"),className:"hover-reveal resize-hit absolute right-0 top-0 bottom-0 w-2 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:(0,g.jsx)("div",{className:"w-1 h-8 bg-card border border-border rounded-full shadow"})}),null!=j&&(0,g.jsxs)("div",{className:"absolute top-1 right-1 text-[10px] px-1.5 py-0.5 rounded bg-primary/80 text-primary-foreground font-mono",children:[Math.round(j),"px"]})]})]})})}let ti=my.create({name:"image",addOptions:()=>({inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}),inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes:()=>({src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}),parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:a}){return["img",ld(this.options.HTMLAttributes,a)]},parseMarkdown:(a,b)=>b.createNode("image",{src:a.href,title:a.title,alt:a.text}),renderMarkdown:a=>{var b,c,d,e,f,g;let h=null!=(c=null==(b=a.attrs)?void 0:b.src)?c:"",i=null!=(e=null==(d=a.attrs)?void 0:d.alt)?e:"",j=null!=(g=null==(f=a.attrs)?void 0:f.title)?g:"";return j?`![${i}](${h} "${j}")`:`![${i}](${h})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||"u"<typeof document)return null;let{directions:a,minWidth:b,minHeight:c,alwaysPreserveAspectRatio:d}=this.options.resize;return({node:e,getPos:f,HTMLAttributes:g,editor:h})=>{let i=document.createElement("img");Object.entries(g).forEach(([a,b])=>{if(null!=b)switch(a){case"width":case"height":break;default:i.setAttribute(a,b)}}),i.src=g.src;let j=new mo({element:i,editor:h,node:e,getPos:f,onResize:(a,b)=>{i.style.width=`${a}px`,i.style.height=`${b}px`},onCommit:(a,b)=>{let c=f();void 0!==c&&this.editor.chain().setNodeSelection(c).updateAttributes(this.name,{width:a,height:b}).run()},onUpdate:(a,b,c)=>a.type===e.type,options:{directions:a,min:{width:b,height:c},preserveAspectRatio:!0===d}}),k=j.dom;return k.style.visibility="hidden",k.style.pointerEvents="none",i.onload=()=>{k.style.visibility="",k.style.pointerEvents=""},j}},addCommands(){return{setImage:a=>({commands:b})=>b.insertContent({type:this.name,attrs:a})}},addInputRules(){return[ml({find:tg,type:this.type,getAttributes:a=>{let[,,b,c,d]=a;return{src:c,alt:b,title:d}}})]}}).extend({name:"image",draggable:!0,addAttributes(){return{...this.parent?.(),width:{default:null,parseHTML:a=>{let b=a.getAttribute("width")??a.style.width;if(!b)return null;let c=/^(\d+)(px)?$/.exec(b);return c?Number(c[1]):b},renderHTML:a=>{if(!a.width)return{};let b="number"==typeof a.width?`${a.width}px`:a.width;return{style:`width: ${b}`}}},align:{default:null,parseHTML:a=>a.getAttribute("data-align"),renderHTML:a=>a.align?{"data-align":a.align}:{}}}},addNodeView:()=>nk(th)}),tj=new fY("wikiLinkDecorator"),tk="wikiLinkDecorator:refresh";function tl(a){let{has:b}=oa.getState(),c=a.schema.marks.wikiLink;if(!c)return h0.empty;let d=[];return a.doc.descendants((a,e)=>{if(!a.isText)return;let f=a.marks.find(a=>a.type===c);if(!f)return;let g=f.attrs.slug;!g||b(g)||d.push(hZ.inline(e,e+a.nodeSize,{"data-broken":"true"}))}),h0.create(a.doc,d)}let tm=/\[\[([a-z0-9-]+)(?:\|([^\]#|]+)|#([a-z0-9-]+))?\]\]$/,tn=l1.create({name:"wikiLink",priority:1e3,keepOnSplit:!1,inclusive:!1,addAttributes:()=>({slug:{default:null,parseHTML:a=>a.getAttribute("data-slug"),renderHTML:a=>({"data-slug":a.slug})},alias:{default:null,parseHTML:a=>a.getAttribute("data-alias"),renderHTML:a=>null!=a.alias?{"data-alias":a.alias}:{}},anchor:{default:null,parseHTML:a=>a.getAttribute("data-anchor"),renderHTML:a=>null!=a.anchor?{"data-anchor":a.anchor}:{}}}),parseHTML:()=>[{tag:'a[data-wiki-link="true"]'}],renderHTML({HTMLAttributes:a}){let b=String(a["data-slug"]??""),c=null!=a["data-anchor"]?String(a["data-anchor"]):null;return["a",ld(a,{"data-wiki-link":"true",href:c?`#wiki:${b}#${c}`:`#wiki:${b}`,class:"wiki-link"}),0]},addInputRules(){return[new lZ({find:tm,handler:({state:a,range:b,match:c})=>{let d=c[1]??"",e=c[2]??null,f=c[3]??null,g=e??(f?`${d}#${f}`:d),{tr:h}=a;h.replaceWith(b.from,b.to,a.schema.text(g,[this.type.create({slug:d,alias:e,anchor:f})]))}})]},addProseMirrorPlugins:()=>[new fV({key:tj,state:{init:(a,b)=>tl(b),apply:(a,b,c,d)=>a.getMeta(tk)||a.docChanged?tl(d):b.map(a.mapping,a.doc)},props:{decorations:a=>tj.getState(a)??h0.empty},view(a){let b=oa.subscribe(()=>{let b=a.state.tr.setMeta(tk,!0);a.dispatch(b)});return{destroy(){b()}}}})],addCommands(){return{setWikiLink:a=>({commands:b})=>b.setMark(this.name,{slug:a.slug,alias:a.alias??null,anchor:a.anchor??null}),unsetWikiLink:()=>({commands:a})=>a.unsetMark(this.name)}}}),to=sV({bash:sk,css:sq,go:sr,javascript:sA,json:sB,markdown:sC,python:sD,rust:sE,shell:sF,sql:sG,typescript:sP,xml:sQ,yaml:sR}),tp=[sj.configure({heading:{levels:[1,2,3,4]},codeBlock:!1,link:!1,underline:!1}),s5.configure({lowlight:to,HTMLAttributes:{class:tc}}).extend({addNodeView:()=>nk(te)}),q7.configure({placeholder:"Start writing, or press '/' for commands..."}),ti.configure({HTMLAttributes:{class:"rounded-lg max-w-full"},allowBase64:!1}),ro.configure({resizable:!0,lastColumnResizable:!1,HTMLAttributes:{class:"border-collapse w-full"}}),rh,rf,rg,rP.configure({HTMLAttributes:{class:"task-list"}}),rO.configure({nested:!0}),qB.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}}).extend({parseHTML:()=>[{tag:'a[href]:not([data-wiki-link="true"])'}],addKeyboardShortcuts(){return{"Mod-e":()=>{let{state:a}=this.editor,{from:b,to:c}=a.selection;return b!==c&&(this.editor.getAttributes("link").href,!1)}}}}),sX,tf,rQ.configure({types:["heading","paragraph"]}),rb,rc,s_,s2,tn],tq=/\.(md|markdown)$/i;function tr(a){try{return decodeURIComponent(a)}catch{return a}}async function ts(a,b,c){let d=encodeURIComponent(a).replace(/%2F/g,"/"),e=await fetch((0,av.apiUrl)(`/api/agent/files/${d}`),{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":crypto.randomUUID(),...{}},body:JSON.stringify({baseRevision:b,by:"human",ops:[c]})});if(409===e.status){let a=await e.json();return"STALE_REVISION"===a.code&&a.snapshot?.revision!==void 0?{ok:!1,stale:!0,newRevision:a.snapshot.revision}:{ok:!1,stale:!1}}return{ok:e.ok,stale:!1}}async function tt(a){let{path:b,ref:c,kind:d,markdown:e,basisDetail:f,getRevision:g,refresh:h}=a,i={type:"suggestion.add",ref:c,kind:d,basis:"suggested"};"delete"!==d&&(i.markdown=e??""),f&&(i.basisDetail=f);let j=await ts(b,g(),i);return!j.ok&&j.stale&&void 0!==j.newRevision&&(await h(),j=await ts(b,j.newRevision,i)),j.ok}let tu=a=>a.replace(/\s+$/g,"").trimStart(),tv=(0,h.default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);function tw({anchorKey:a,anchorLabel:b,comments:c,top:d,left:e,onClick:f}){let h;if(0===c.length)return null;let i=c.filter(a=>!a.resolved);if(0===i.length)h="check";else{let a=i[0].turns.at(-1);h=a?.by.startsWith("ai:")?"dot-ai":"ring-human"}return(0,g.jsxs)("button",{type:"button",onClick:f,style:{position:"absolute",top:d,left:e,transform:"translateY(2px)"},className:"z-10 p-2 sm:p-0.5 -m-1.5 sm:m-0 rounded transition-colors hover:bg-accent focus:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-label":`Comment thread for ${b??a}`,children:["check"===h&&(0,g.jsx)(tv,{className:"h-3.5 w-3.5 text-muted-foreground/30"}),"dot-ai"===h&&(0,g.jsx)(oC,{className:"h-3.5 w-3.5 fill-primary text-primary"}),"ring-human"===h&&(0,g.jsx)(oC,{className:"h-3.5 w-3.5 text-muted-foreground/70"})]})}var tx=a.i(735452),ty="Popover",[tz,tA]=(0,y.createContextScope)(ty,[tx.createPopperScope]),tB=(0,tx.createPopperScope)(),[tC,tD]=tz(ty),tE=a=>{let{__scopePopover:b,children:c,open:d,defaultOpen:e,onOpenChange:f,modal:h=!1}=a,i=tB(b),j=p.useRef(null),[k,l]=p.useState(!1),[m,n]=(0,A.useControllableState)({prop:d,defaultProp:e??!1,onChange:f,caller:ty});return(0,g.jsx)(tx.Root,{...i,children:(0,g.jsx)(tC,{scope:b,contentId:(0,z.useId)(),triggerRef:j,open:m,onOpenChange:n,onOpenToggle:p.useCallback(()=>n(a=>!a),[n]),hasCustomAnchor:k,onCustomAnchorAdd:p.useCallback(()=>l(!0),[]),onCustomAnchorRemove:p.useCallback(()=>l(!1),[]),modal:h,children:c})})};tE.displayName=ty;var tF="PopoverAnchor",tG=p.forwardRef((a,b)=>{let{__scopePopover:c,...d}=a,e=tD(tF,c),f=tB(c),{onCustomAnchorAdd:h,onCustomAnchorRemove:i}=e;return p.useEffect(()=>(h(),()=>i()),[h,i]),(0,g.jsx)(tx.Anchor,{...f,...d,ref:b})});tG.displayName=tF;var tH="PopoverTrigger";p.forwardRef((a,b)=>{let{__scopePopover:c,...d}=a,e=tD(tH,c),f=tB(c),h=(0,x.useComposedRefs)(b,e.triggerRef),i=(0,g.jsx)(F.Primitive.button,{type:"button","aria-haspopup":"dialog","aria-expanded":e.open,"aria-controls":e.contentId,"data-state":tU(e.open),...d,ref:h,onClick:(0,w.composeEventHandlers)(a.onClick,e.onOpenToggle)});return e.hasCustomAnchor?i:(0,g.jsx)(tx.Anchor,{asChild:!0,...f,children:i})}).displayName=tH;var tI="PopoverPortal",[tJ,tK]=tz(tI,{forceMount:void 0}),tL=a=>{let{__scopePopover:b,forceMount:c,children:d,container:e}=a,f=tD(tI,b);return(0,g.jsx)(tJ,{scope:b,forceMount:c,children:(0,g.jsx)(E.Presence,{present:c||f.open,children:(0,g.jsx)(D.Portal,{asChild:!0,container:e,children:d})})})};tL.displayName=tI;var tM="PopoverContent",tN=p.forwardRef((a,b)=>{let c=tK(tM,a.__scopePopover),{forceMount:d=c.forceMount,...e}=a,f=tD(tM,a.__scopePopover);return(0,g.jsx)(E.Presence,{present:d||f.open,children:f.modal?(0,g.jsx)(tP,{...e,ref:b}):(0,g.jsx)(tQ,{...e,ref:b})})});tN.displayName=tM;var tO=(0,J.createSlot)("PopoverContent.RemoveScroll"),tP=p.forwardRef((a,b)=>{let c=tD(tM,a.__scopePopover),d=p.useRef(null),e=(0,x.useComposedRefs)(b,d),f=p.useRef(!1);return p.useEffect(()=>{let a=d.current;if(a)return(0,I.hideOthers)(a)},[]),(0,g.jsx)(H.RemoveScroll,{as:tO,allowPinchZoom:!0,children:(0,g.jsx)(tR,{...a,ref:e,trapFocus:c.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:(0,w.composeEventHandlers)(a.onCloseAutoFocus,a=>{a.preventDefault(),f.current||c.triggerRef.current?.focus()}),onPointerDownOutside:(0,w.composeEventHandlers)(a.onPointerDownOutside,a=>{let b=a.detail.originalEvent,c=0===b.button&&!0===b.ctrlKey;f.current=2===b.button||c},{checkForDefaultPrevented:!1}),onFocusOutside:(0,w.composeEventHandlers)(a.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),tQ=p.forwardRef((a,b)=>{let c=tD(tM,a.__scopePopover),d=p.useRef(!1),e=p.useRef(!1);return(0,g.jsx)(tR,{...a,ref:b,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:b=>{a.onCloseAutoFocus?.(b),b.defaultPrevented||(d.current||c.triggerRef.current?.focus(),b.preventDefault()),d.current=!1,e.current=!1},onInteractOutside:b=>{a.onInteractOutside?.(b),b.defaultPrevented||(d.current=!0,"pointerdown"===b.detail.originalEvent.type&&(e.current=!0));let f=b.target;c.triggerRef.current?.contains(f)&&b.preventDefault(),"focusin"===b.detail.originalEvent.type&&e.current&&b.preventDefault()}})}),tR=p.forwardRef((a,b)=>{let{__scopePopover:c,trapFocus:d,onOpenAutoFocus:e,onCloseAutoFocus:f,disableOutsidePointerEvents:h,onEscapeKeyDown:i,onPointerDownOutside:j,onFocusOutside:k,onInteractOutside:l,...m}=a,n=tD(tM,c),o=tB(c);return(0,G.useFocusGuards)(),(0,g.jsx)(C.FocusScope,{asChild:!0,loop:!0,trapped:d,onMountAutoFocus:e,onUnmountAutoFocus:f,children:(0,g.jsx)(B.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:h,onInteractOutside:l,onEscapeKeyDown:i,onPointerDownOutside:j,onFocusOutside:k,onDismiss:()=>n.onOpenChange(!1),children:(0,g.jsx)(tx.Content,{"data-state":tU(n.open),role:"dialog",id:n.contentId,...o,...m,ref:b,style:{...m.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),tS="PopoverClose";p.forwardRef((a,b)=>{let{__scopePopover:c,...d}=a,e=tD(tS,c);return(0,g.jsx)(F.Primitive.button,{type:"button",...d,ref:b,onClick:(0,w.composeEventHandlers)(a.onClick,()=>e.onOpenChange(!1))})}).displayName=tS;var tT=p.forwardRef((a,b)=>{let{__scopePopover:c,...d}=a,e=tB(c);return(0,g.jsx)(tx.Arrow,{...e,...d,ref:b})});function tU(a){return a?"open":"closed"}tT.displayName="PopoverArrow";let tV=new Intl.RelativeTimeFormat("en",{numeric:"auto"});async function tW(a,b,c,d){let e=encodeURIComponent(a).replace(/%2F/g,"/"),f=await (0,bB.wsFetch)(`/api/agent/files/${e}`,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":crypto.randomUUID(),...{}},body:JSON.stringify({baseRevision:b,by:c,ops:d})});if(409===f.status){let a=await f.json();return"STALE_REVISION"===a.code&&a.snapshot?.revision!==void 0?{ok:!1,stale:!0,newRevision:a.snapshot.revision}:{ok:!1,stale:!1}}return f.ok?{ok:!0,stale:!1}:{ok:!1,stale:!1}}function tX({path:a,anchorKey:b,anchorLabel:c,anchorRef:d,lineAnchor:e,comments:f,anchorEl:h,onClose:i,readOnly:j}){let[k,l]=(0,p.useState)(null),[m,n]=(0,p.useState)(""),[o,q]=(0,p.useState)(!1),r=(0,p.useRef)(null),s=f.filter(a=>!a.resolved),t=s.length>0,u=s[0]??f[0]??null;if((0,p.useEffect)(()=>{if(!h)return void l(null);let a=h.getBoundingClientRect();l({top:a.bottom+4,left:a.left})},[h]),(0,p.useEffect)(()=>{if(!h)return;let a=a=>{"Escape"===a.key&&i()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[h,i]),(0,p.useEffect)(()=>{k&&setTimeout(()=>r.current?.focus(),50)},[k]),!h||!k)return null;function v(){let b=oc.getState().byPath[a];return b?.snapshotRevision??0}async function w(){if(m.trim()&&!o){q(!0);try{let c=u?{type:"comment.reply",commentId:u.id,text:m.trim()}:e?{type:"comment.add",lineAnchor:e,text:m.trim()}:{type:"comment.add",ref:d??b,text:m.trim()},f=v(),g=await tW(a,f,"human",[c]);!g.ok&&g.stale&&void 0!==g.newRevision&&(await oc.getState().loadSidecar(a),f=g.newRevision,g=await tW(a,f,"human",[c])),g.ok&&(await oc.getState().loadSidecar(a),n(""),i())}finally{q(!1)}}}async function x(){if(u&&!o){q(!0);try{let b=u.resolved?"comment.reopen":"comment.resolve",c=v(),d=await tW(a,c,"human",[{type:b,commentId:u.id}]);!d.ok&&d.stale&&void 0!==d.newRevision&&(await oc.getState().loadSidecar(a),c=d.newRevision,d=await tW(a,c,"human",[{type:b,commentId:u.id}])),d.ok&&(await oc.getState().loadSidecar(a),i())}finally{q(!1)}}}let y=f.flatMap(a=>a.turns.map(b=>({...b,resolved:a.resolved,commentId:a.id})));return(0,g.jsxs)(tE,{open:!0,children:[(0,g.jsx)(tG,{asChild:!0,children:(0,g.jsx)("span",{"aria-hidden":"true",style:{position:"fixed",top:k.top,left:k.left,width:0,height:0,pointerEvents:"none"}})}),(0,g.jsx)(tL,{children:(0,g.jsxs)(tN,{side:"bottom",align:"start",sideOffset:4,collisionPadding:8,onInteractOutside:i,className:"z-50 w-[min(18rem,calc(100vw-1rem))] bg-popover border border-border rounded-lg shadow-xl p-3 space-y-2 text-[12px] focus:outline-none",children:[(0,g.jsxs)("div",{className:"flex items-center justify-between",children:[(0,g.jsx)("span",{className:"text-[11px] font-mono text-muted-foreground/60 truncate",children:c??b}),u&&!j&&(0,g.jsx)("button",{type:"button",disabled:o,onClick:()=>void x(),className:"ml-2 shrink-0 text-[10px] px-1.5 py-0.5 rounded border border-border hover:bg-accent disabled:opacity-50 transition-colors",children:u.resolved?"Reopen":"Resolve"})]}),y.length>0&&(0,g.jsx)("div",{className:"space-y-2 max-h-48 overflow-y-auto pr-1",children:y.map((a,b)=>(0,g.jsxs)("div",{className:"space-y-0.5",children:[(0,g.jsxs)("p",{className:"text-[10px] text-muted-foreground/60",children:[a.by," · ",function(a){let b=Math.round((Date.now()-new Date(a).getTime())/1e3);if(60>Math.abs(b))return tV.format(-b,"second");let c=Math.round(b/60);if(60>Math.abs(c))return tV.format(-c,"minute");let d=Math.round(c/60);return 24>Math.abs(d)?tV.format(-d,"hour"):tV.format(-Math.round(d/24),"day")}(a.at)]}),(0,g.jsx)("p",{className:"text-foreground leading-snug whitespace-pre-wrap",children:a.text})]},b))}),(!u?.resolved||0===f.length)&&(0,g.jsxs)("div",{className:"space-y-1.5 pt-1",children:[(0,g.jsx)("textarea",{ref:r,value:m,onChange:a=>n(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.metaKey||a.ctrlKey)&&w()},placeholder:t?"Reply…":"Add a comment…",rows:2,className:"w-full resize-none rounded-md border border-border bg-background px-2 py-1.5 text-[12px] focus:outline-none focus-visible:ring-1 focus-visible:ring-ring placeholder:text-muted-foreground/40"}),(0,g.jsxs)("div",{className:"flex items-center justify-between",children:[(0,g.jsx)("span",{className:"text-[10px] text-muted-foreground/40",children:"⌘↵ send"}),(0,g.jsx)("button",{type:"button",disabled:o||!m.trim(),onClick:()=>void w(),className:"px-2.5 py-1 rounded-md bg-primary text-primary-foreground text-[11px] font-medium hover:bg-primary/90 disabled:opacity-50 transition-colors",children:"Send"})]})]}),(0,g.jsx)(tT,{className:"fill-border"})]})})]})}function tY({targetEl:a,path:b,onClose:c,onComment:d}){let[e,f]=(0,p.useState)(null),[h,i]=(0,p.useState)(null),[j,k]=(0,p.useState)(!1);if((0,p.useEffect)(()=>{if(!a){f(null),i(null);return}let b=a.getBoundingClientRect();f({top:b.bottom+window.scrollY+4,left:b.left+window.scrollX}),i({spanId:a.getAttribute("id")??"",origin:a.getAttribute("origin"),basis:a.getAttribute("basis"),basisDetail:a.getAttribute("basis-detail"),by:a.getAttribute("by"),at:a.getAttribute("at")})},[a]),(0,p.useEffect)(()=>{if(!a)return;let b=a=>{"Escape"===a.key&&c()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[a,c]),!a||!e||!h)return null;async function l(a){if(!j&&h){k(!0);try{await (0,bB.wsFetch)("/api/agent/internal/span",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:b,spanId:h.spanId,action:a,idempotencyKey:crypto.randomUUID()})})}finally{k(!1),c()}}}return(0,g.jsxs)(tE,{open:!0,children:[(0,g.jsx)(tG,{asChild:!0,children:(0,g.jsx)("span",{"aria-hidden":"true",style:{position:"fixed",top:e.top,left:e.left,width:0,height:0,pointerEvents:"none"}})}),(0,g.jsx)(tL,{children:(0,g.jsxs)(tN,{side:"bottom",align:"start",sideOffset:4,collisionPadding:8,onInteractOutside:c,className:"z-50 w-[min(16rem,calc(100vw-1rem))] bg-popover border border-border rounded-lg shadow-xl p-3 space-y-2 text-[12px] focus:outline-none",children:[(0,g.jsxs)("div",{className:"space-y-0.5",children:[(0,g.jsxs)("p",{className:"font-medium text-foreground truncate",children:[h.by??"unknown"," · ",h.basis??"—"," · ",function(a){if(!a)return"";let b=Math.floor((Date.now()-new Date(a).getTime())/1e3);if(b<60)return`${b}s ago`;let c=Math.floor(b/60);if(c<60)return`${c}m ago`;let d=Math.floor(c/60);return d<24?`${d}h ago`:`${Math.floor(d/24)}d ago`}(h.at)]}),h.basisDetail&&(0,g.jsxs)("p",{className:"text-muted-foreground italic truncate",children:["“",h.basisDetail,"”"]}),h.origin&&(0,g.jsxs)("p",{className:"text-muted-foreground/60",children:["origin: ",h.origin]})]}),(0,g.jsxs)("div",{className:"flex items-center gap-1.5 pt-1",children:[(0,g.jsx)("button",{type:"button",disabled:j,onClick:()=>void l("accept"),className:"flex-1 py-1 rounded-md bg-primary text-primary-foreground text-[11px] font-medium hover:bg-primary/90 disabled:opacity-50 transition-colors",children:"Accept"}),(0,g.jsx)("button",{type:"button",disabled:j,onClick:()=>void l("revert"),className:"flex-1 py-1 rounded-md border border-border text-[11px] font-medium hover:bg-accent disabled:opacity-50 transition-colors",children:"Revert"}),(0,g.jsx)("button",{type:"button",disabled:j,onClick:()=>{d?.(),c()},className:"flex-1 py-1 rounded-md border border-border text-[11px] font-medium hover:bg-accent disabled:opacity-50 transition-colors",children:"Comment"})]}),(0,g.jsx)(tT,{className:"fill-border"})]})})]})}async function tZ(a,b,c,d){let e=encodeURIComponent(a).replace(/%2F/g,"/"),f=await (0,bB.wsFetch)(`/api/agent/files/${e}`,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":crypto.randomUUID(),...{}},body:JSON.stringify({baseRevision:b,by:"human",ops:[{type:c,suggestionId:d}]})});return{ok:f.ok,status:f.status}}function t$({suggestion:a,currentMarkdown:b,path:c,baseRevision:d,getLatestRevision:e,top:f,left:h,width:i,onSettled:j,readOnly:k}){let[l,m]=(0,p.useState)(!1);async function n(){if(!l){m(!0);try{let b=await tZ(c,d,"suggestion.accept",a.id);b.ok||409!==b.status||(b=await tZ(c,e(),"suggestion.accept",a.id))}finally{m(!1),j()}}}async function o(){if(!l){m(!0);try{await tZ(c,d,"suggestion.reject",a.id)}finally{m(!1),j()}}}let q="delete"===a.kind,r="insertAfter"===a.kind||"insertBefore"===a.kind;return(0,g.jsxs)("div",{style:{position:"absolute",top:f,left:h,width:i>0?i:void 0,zIndex:30},className:"my-1 rounded-lg border border-border bg-card shadow-md text-[12px] overflow-hidden",role:"region","aria-label":`Suggestion by ${a.by}`,children:[(0,g.jsx)("div",{className:"flex items-center justify-between px-3 py-2 bg-muted/50 border-b border-border",children:(0,g.jsxs)("span",{className:"font-medium text-foreground",children:[(0,g.jsx)("span",{className:"text-primary",children:a.by})," suggests ",(0,g.jsx)("span",{className:"text-muted-foreground",children:function(a){switch(a){case"replace":return"replacing this block";case"insertAfter":return"inserting content after this block";case"insertBefore":return"inserting content before this block";case"delete":return"deleting this block"}}(a.kind)})]})}),(0,g.jsxs)("div",{className:"p-3 space-y-2",children:["replace"===a.kind&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/60 mb-1",children:"─ current ─"}),(0,g.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-muted-foreground bg-destructive/5 rounded px-2 py-1",children:b||"(empty)"})]}),(0,g.jsxs)("div",{children:[(0,g.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/60 mb-1",children:"─ proposed ─"}),(0,g.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-foreground bg-primary/5 rounded px-2 py-1",children:a.markdown??"(empty)"})]})]}),r&&(0,g.jsxs)("div",{children:[(0,g.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/60 mb-1",children:"─ will be inserted ─"}),(0,g.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-foreground bg-primary/5 rounded px-2 py-1",children:a.markdown??"(empty)"})]}),q&&(0,g.jsxs)("div",{children:[(0,g.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/60 mb-1",children:"─ will be deleted ─"}),(0,g.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-muted-foreground line-through bg-destructive/5 rounded px-2 py-1",children:b||"(empty)"})]}),a.basisDetail&&(0,g.jsxs)("p",{className:"italic text-muted-foreground/70 text-[11px]",children:["Reason: ",a.basisDetail]})]}),!k&&(0,g.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-t border-border bg-muted/30",children:[(0,g.jsx)("button",{type:"button",disabled:l,onClick:()=>void n(),className:"flex-1 py-1 rounded-md bg-primary text-primary-foreground text-[11px] font-medium hover:bg-primary/90 disabled:opacity-50 transition-colors",children:"Accept"}),(0,g.jsx)("button",{type:"button",disabled:l,onClick:()=>void o(),className:"flex-1 py-1 rounded-md border border-border text-[11px] font-medium hover:bg-accent disabled:opacity-50 transition-colors",children:"Reject"})]})]})}async function t_(a,b,c){let d=encodeURIComponent(a).replace(/%2F/g,"/"),e=await (0,bB.wsFetch)(`/api/agent/files/${d}`,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":crypto.randomUUID(),...{}},body:JSON.stringify({baseRevision:b,by:"human",ops:c})});if(409===e.status){let a=await e.json();return"STALE_REVISION"===a.code&&a.snapshot?.revision!==void 0?{ok:!1,stale:!0,newRevision:a.snapshot.revision}:{ok:!1,stale:!1}}return e.ok?{ok:!0,stale:!1}:{ok:!1,stale:!1}}let t0={replace:"Replace block",insertAfter:"Insert after",insertBefore:"Insert before",delete:"Delete block"};function t1({path:a,blockRef:b,currentMarkdown:c,anchor:d,onClose:e}){let[f,h]=(0,p.useState)("replace"),[i,j]=(0,p.useState)(c),[k,l]=(0,p.useState)(""),[m,n]=(0,p.useState)(!1),o=(0,p.useRef)(null);(0,p.useEffect)(()=>{"replace"===f?j(c):j("")},[f,c]),(0,p.useEffect)(()=>{let a=a=>{"Escape"===a.key&&e()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e]),(0,p.useEffect)(()=>{setTimeout(()=>o.current?.focus(),50)},[]);let q="delete"!==f,r=!m&&(!q||i.trim().length>0);async function s(){if(r){n(!0);try{let c={type:"suggestion.add",ref:b,kind:f,basis:"suggested"};q&&(c.markdown=i),k.trim()&&(c.basisDetail=k.trim());let d=oc.getState().byPath[a]?.snapshotRevision??0,g=await t_(a,d,[c]);!g.ok&&g.stale&&void 0!==g.newRevision&&(await oc.getState().loadSidecar(a),d=g.newRevision,g=await t_(a,d,[c])),g.ok&&(await oc.getState().loadSidecar(a),await oc.getState().loadSnapshot(a),e())}finally{n(!1)}}}return(0,g.jsxs)(tE,{open:!0,children:[(0,g.jsx)(tG,{asChild:!0,children:(0,g.jsx)("span",{"aria-hidden":"true",style:{position:"fixed",top:d.top,left:d.left,width:0,height:0,pointerEvents:"none"}})}),(0,g.jsx)(tL,{children:(0,g.jsxs)(tN,{side:"bottom",align:"start",sideOffset:4,collisionPadding:8,onInteractOutside:e,className:"z-50 w-[min(20rem,calc(100vw-1rem))] bg-popover border border-border rounded-lg shadow-xl p-3 space-y-2.5 text-[12px] focus:outline-none",children:[(0,g.jsxs)("div",{className:"flex items-center justify-between",children:[(0,g.jsx)("span",{className:"font-medium text-foreground",children:"Suggest an edit"}),(0,g.jsx)("span",{className:"text-[11px] font-mono text-muted-foreground/60 truncate ml-2",children:b})]}),(0,g.jsx)("div",{className:"flex flex-wrap gap-1",children:Object.keys(t0).map(a=>(0,g.jsx)("button",{type:"button",onClick:()=>h(a),className:`px-2 py-0.5 rounded-md text-[10.5px] border transition-colors ${f===a?"bg-primary text-primary-foreground border-primary":"border-border text-muted-foreground hover:bg-accent"}`,children:t0[a]},a))}),"delete"===f&&(0,g.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-muted-foreground line-through bg-destructive/5 rounded px-2 py-1 max-h-32 overflow-y-auto",children:c||"(empty)"}),q&&(0,g.jsxs)("div",{className:"space-y-1",children:[(0,g.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/60",children:"replace"===f?"proposed content":"content to insert"}),(0,g.jsx)("textarea",{ref:o,value:i,onChange:a=>j(a.target.value),rows:4,placeholder:"Markdown…",className:"w-full resize-y rounded-md border border-border bg-background px-2 py-1.5 font-mono text-[11px] focus:outline-none focus-visible:ring-1 focus-visible:ring-ring placeholder:text-muted-foreground/40"})]}),(0,g.jsx)("input",{type:"text",value:k,onChange:a=>l(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.metaKey||a.ctrlKey)&&s()},placeholder:"Reason (optional)",className:"w-full rounded-md border border-border bg-background px-2 py-1.5 text-[12px] focus:outline-none focus-visible:ring-1 focus-visible:ring-ring placeholder:text-muted-foreground/40"}),(0,g.jsxs)("div",{className:"flex items-center justify-between pt-0.5",children:[(0,g.jsx)("span",{className:"text-[10px] text-muted-foreground/40",children:"⌘↵ submit"}),(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsx)("button",{type:"button",disabled:m,onClick:e,className:"px-2.5 py-1 rounded-md border border-border text-[11px] font-medium hover:bg-accent disabled:opacity-50 transition-colors",children:"Cancel"}),(0,g.jsx)("button",{type:"button",disabled:!r,onClick:()=>void s(),className:"px-2.5 py-1 rounded-md bg-primary text-primary-foreground text-[11px] font-medium hover:bg-primary/90 disabled:opacity-50 transition-colors",children:"Suggest"})]})]}),(0,g.jsx)(tT,{className:"fill-border"})]})})]})}let t2=(0,h.default)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),t3=(0,h.default)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),t4=(0,h.default)("sigma",[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]]),t5=(0,h.default)("table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]),t6=[{label:"Text",icon:dU,description:"Start writing plain text",category:"basic",action:{type:"direct",run:a=>a.chain().focus().setParagraph().run()}},{label:"Heading 1",icon:oN,description:"Large section heading",category:"basic",action:{type:"direct",run:a=>a.chain().focus().toggleHeading({level:1}).run()}},{label:"Heading 2",icon:oO,description:"Medium section heading",category:"basic",action:{type:"direct",run:a=>a.chain().focus().toggleHeading({level:2}).run()}},{label:"Heading 3",icon:oP,description:"Small section heading",category:"basic",action:{type:"direct",run:a=>a.chain().focus().toggleHeading({level:3}).run()}},{label:"Bullet List",icon:oQ,description:"Create a bullet list",category:"basic",action:{type:"direct",run:a=>a.chain().focus().toggleBulletList().run()}},{label:"Numbered List",icon:oR,description:"Create a numbered list",category:"basic",action:{type:"direct",run:a=>a.chain().focus().toggleOrderedList().run()}},{label:"Checklist",icon:oK,description:"Create a task checklist",category:"basic",action:{type:"direct",run:a=>a.chain().focus().toggleTaskList().run()}},{label:"Code Block",icon:oA,description:"Insert a code block",category:"basic",action:{type:"direct",run:a=>a.chain().focus().toggleCodeBlock().run()}},{label:"Blockquote",icon:oV,description:"Insert a blockquote",category:"basic",action:{type:"direct",run:a=>a.chain().focus().toggleBlockquote().run()}},{label:"Divider",icon:oS,description:"Insert a horizontal rule",category:"basic",action:{type:"direct",run:a=>a.chain().focus().setHorizontalRule().run()}},{label:"Table",icon:t5,description:"Insert a 3x3 table",category:"basic",action:{type:"direct",run:a=>a.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},{label:"Image",icon:l,description:"Upload, paste URL, or drop an image",category:"media",action:{type:"popover",kind:{type:"media",kind:"image"}}},{label:"Video",icon:oY,description:"Upload or paste a video URL",category:"media",action:{type:"popover",kind:{type:"media",kind:"video"}}},{label:"File",icon:cb,description:"Attach any file to this page",category:"media",action:{type:"popover",kind:{type:"media",kind:"file"}}},{label:"Callout",icon:t3,description:"Insert an info callout",category:"advanced",action:{type:"direct",run:a=>a.chain().focus().wrapIn("callout",{type:"info"}).run()}},{label:"Warning",icon:t2,description:"Insert a warning callout",category:"advanced",action:{type:"direct",run:a=>a.chain().focus().wrapIn("callout",{type:"warning"}).run()}},{label:"Math",icon:t4,description:"Insert a LaTeX math expression",category:"advanced",action:{type:"direct",run:a=>a.chain().focus().insertContent("$x=y$").run()}}];function t7({cmd:a}){switch(a.label){case"Heading 1":return(0,g.jsx)("p",{className:"font-bold text-[18px] leading-tight text-foreground/80 truncate",children:"Heading 1"});case"Heading 2":return(0,g.jsx)("p",{className:"font-semibold text-[14px] leading-tight text-foreground/80 truncate",children:"Heading 2"});case"Heading 3":return(0,g.jsx)("p",{className:"font-medium text-[12px] leading-tight text-foreground/80 truncate",children:"Heading 3"});case"Text":return(0,g.jsx)("p",{className:"text-[11px] text-foreground/60 leading-snug",children:"The quick brown fox jumps over the lazy dog."});case"Bullet List":return(0,g.jsxs)("ul",{className:"list-disc pl-4 text-[10px] text-foreground/60 space-y-0.5",children:[(0,g.jsx)("li",{children:"First item"}),(0,g.jsx)("li",{children:"Second item"}),(0,g.jsx)("li",{children:"Third item"})]});case"Numbered List":return(0,g.jsxs)("ol",{className:"list-decimal pl-4 text-[10px] text-foreground/60 space-y-0.5",children:[(0,g.jsx)("li",{children:"First item"}),(0,g.jsx)("li",{children:"Second item"}),(0,g.jsx)("li",{children:"Third item"})]});case"Checklist":return(0,g.jsxs)("div",{className:"space-y-0.5 text-[10px] text-foreground/60",children:[(0,g.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,g.jsx)("span",{className:"w-3 h-3 border border-foreground/30 rounded-sm inline-block shrink-0"}),"Pending task"]}),(0,g.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,g.jsx)("span",{className:"w-3 h-3 border border-foreground/30 rounded-sm bg-foreground/20 inline-block shrink-0"}),"Done task"]})]});case"Code Block":return(0,g.jsx)("pre",{className:"bg-muted rounded px-2 py-1 text-[10px] font-mono text-foreground/70 leading-snug",children:(0,g.jsx)("code",{children:"const x = 42;"})});case"Blockquote":return(0,g.jsx)("div",{className:"border-l-2 border-foreground/30 pl-2 text-[10px] text-foreground/60 italic",children:"A thought worth quoting."});case"Divider":return(0,g.jsx)("hr",{className:"border-foreground/20 w-full"});case"Table":return(0,g.jsxs)("table",{className:"text-[9px] border-collapse w-full",children:[(0,g.jsx)("thead",{children:(0,g.jsx)("tr",{children:["Col A","Col B","Col C"].map(a=>(0,g.jsx)("th",{className:"border border-foreground/20 px-1.5 py-0.5 text-left font-semibold bg-muted/50 text-foreground/70",children:a},a))})}),(0,g.jsx)("tbody",{children:[["1","2","3"],["4","5","6"]].map((a,b)=>(0,g.jsx)("tr",{children:a.map((a,b)=>(0,g.jsx)("td",{className:"border border-foreground/20 px-1.5 py-0.5 text-foreground/50",children:a},b))},b))})]});case"Image":return(0,g.jsxs)("div",{className:"flex items-center gap-2 text-foreground/50",children:[(0,g.jsx)(l,{className:"h-8 w-8 text-foreground/20"}),(0,g.jsx)("span",{className:"text-[10px]",children:"image.png"})]});case"Video":return(0,g.jsxs)("div",{className:"flex items-center gap-2 text-foreground/50",children:[(0,g.jsx)(oY,{className:"h-8 w-8 text-foreground/20"}),(0,g.jsx)("span",{className:"text-[10px]",children:"video.mp4"})]});case"File":return(0,g.jsxs)("div",{className:"flex items-center gap-2 text-foreground/50",children:[(0,g.jsx)(cb,{className:"h-8 w-8 text-foreground/20"}),(0,g.jsx)("span",{className:"text-[10px]",children:"attachment.pdf"})]});case"Callout":return(0,g.jsxs)("div",{className:"flex items-start gap-1.5 bg-blue-500/10 border border-blue-500/20 rounded px-2 py-1",children:[(0,g.jsx)(t3,{className:"h-3 w-3 text-blue-500 shrink-0 mt-0.5"}),(0,g.jsx)("span",{className:"text-[10px] text-foreground/60",children:"Info callout"})]});case"Warning":return(0,g.jsxs)("div",{className:"flex items-start gap-1.5 bg-warning/10 border border-warning/20 rounded px-2 py-1",children:[(0,g.jsx)(t2,{className:"h-3 w-3 text-warning shrink-0 mt-0.5"}),(0,g.jsx)("span",{className:"text-[10px] text-foreground/60",children:"Warning callout"})]});case"Math":return(0,g.jsx)("p",{className:"font-mono text-[13px] text-foreground/70",children:"E = mc²"});default:return(0,g.jsx)("p",{className:"text-[10px] text-muted-foreground",children:a.description})}}function t8({editor:a}){let[b,c]=(0,p.useState)(!1),[d,e]=(0,p.useState)(""),[f,h]=(0,p.useState)(0),[i,j]=(0,p.useState)({top:0,left:0}),[k,l]=(0,p.useState)(null),m=(0,p.useRef)(null),n=b_(a=>a.currentPath),o=t6.filter(a=>a.label.toLowerCase().includes(d.toLowerCase())||a.description.toLowerCase().includes(d.toLowerCase())),q=(0,p.useCallback)(()=>{c(!1),e(""),h(0)},[]),r=(0,p.useCallback)(b=>{if(!a)return;let{from:f}=a.state.selection,g=f-d.length-1;a.chain().focus().deleteRange({from:g,to:f}).run(),"direct"===b.action.type?(b.action.run(a),q()):(l(b.action.kind),c(!1),e(""))},[a,d,q]);if((0,p.useEffect)(()=>{if(!a)return;let g=g=>{if(!b){if("/"===g.key){let{from:b}=a.state.selection,d=a.state.doc.textBetween(Math.max(0,b-1),b);if(1===b||""===d||"\n"===d||" "===d){let d=a.view.coordsAtPos(b),f=a.view.dom.getBoundingClientRect();j({top:d.bottom-f.top+4,left:d.left-f.left}),c(!0),e(""),h(0)}}return}"Escape"===g.key?(g.preventDefault(),q()):"ArrowDown"===g.key?(g.preventDefault(),h(a=>Math.min(a+1,o.length-1))):"ArrowUp"===g.key?(g.preventDefault(),h(a=>Math.max(a-1,0))):"Enter"===g.key?(g.preventDefault(),o[f]&&r(o[f])):"Backspace"===g.key?0===d.length?q():(e(a=>a.slice(0,-1)),h(0)):" "===g.key?q():1!==g.key.length||g.metaKey||g.ctrlKey||(e(a=>a+g.key),h(0))};return window.addEventListener("keydown",g,!0),()=>window.removeEventListener("keydown",g,!0)},[a,b,d,f,o,q,r]),(0,p.useEffect)(()=>{if(!b)return;let a=a=>{m.current&&!m.current.contains(a.target)&&q()};return window.addEventListener("mousedown",a),()=>window.removeEventListener("mousedown",a)},[b,q]),(!b||0===o.length)&&!k)return null;let s=new Map;for(let a of o){let b=s.get(a.category)??[];b.push(a),s.set(a.category,b)}let t=o[f]??null;return(0,g.jsxs)(g.Fragment,{children:[b&&o.length>0&&(0,g.jsxs)("div",{ref:m,className:"absolute z-50 w-[280px] bg-popover border border-border rounded-lg shadow-lg overflow-hidden",style:{top:i.top,left:i.left},children:[(0,g.jsx)("div",{className:"max-h-[300px] overflow-y-auto py-1",children:[{key:"basic",title:"Basic"},{key:"media",title:"Media"},{key:"advanced",title:"Advanced"}].map(a=>{let b=s.get(a.key);return b&&0!==b.length?(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"text-[9px] uppercase tracking-wider text-muted-foreground px-3 pt-2 pb-1",children:a.title}),b.map(a=>{let b=o.indexOf(a),c=a.icon,d=b===f;return(0,g.jsxs)("button",{onMouseDown:b=>{b.preventDefault(),r(a)},onMouseEnter:()=>h(b),className:(0,ao.cn)("flex items-center gap-3 w-full px-3 py-1.5 text-left transition-colors",d?"bg-accent text-accent-foreground ring-1 ring-inset ring-accent-foreground/10":"hover:bg-accent/50"),children:[(0,g.jsx)(c,{className:(0,ao.cn)("h-4 w-4 shrink-0 transition-colors",d?"text-accent-foreground":"text-muted-foreground")}),(0,g.jsxs)("div",{className:"min-w-0",children:[(0,g.jsx)("p",{className:"text-[12px] font-medium truncate",children:a.label}),(0,g.jsx)("p",{className:(0,ao.cn)("text-[10px] truncate transition-colors",d?"text-accent-foreground/70":"text-muted-foreground"),children:a.description})]})]},a.label)})]},a.key):null})}),t&&(0,g.jsx)("div",{className:"border-t border-border bg-muted/30 px-3 py-2 min-h-[52px] flex items-center",children:(0,g.jsx)(t7,{cmd:t})})]}),k&&a?"media"===k.type?n?(0,g.jsx)(o3,{kind:k.kind,pagePath:n,anchor:i,onCancel:()=>l(null),onInsert:b=>((b,c)=>{if(!a)return;let{url:d,alt:e,mimeType:f}=c;"image"===b||(f??"").startsWith("image/")||/\.(png|jpe?g|gif|webp|svg|avif)(\?|$)/i.test(d)?a.chain().focus().setImage({src:d,alt:e??""}).run():a.chain().focus().insertContent(`<a href="${d}">${e??d}</a>`).run(),l(null)})(k.kind,b)}):null:null:null]})}function t9(a){let b=[],c=new Map;return a.state.doc.forEach((a,d)=>{if("heading"===a.type.name){let e=a.textContent,f=a.attrs.level,g=e.toLowerCase().replace(/\s+/g,"-").replace(/[^\w-]/g,"")||"heading",h=(c.get(g)??0)+1;c.set(g,h);let i=1===h?g:`${g}-${h}`;b.push({level:f,text:e,pos:d,uid:i})}}),b}function ua(a,b){try{let{node:c}=a.view.domAtPos(b.pos+1);return c.nodeType===Node.ELEMENT_NODE?c.closest("h1,h2,h3,h4,h5,h6")??c:c.parentElement?.closest("h1,h2,h3,h4,h5,h6")??null}catch{return null}}function ub({editor:a,scrollContainerRef:b}){let[c,d]=(0,p.useState)([]),[e,f]=(0,p.useState)(null),[h,i]=(0,p.useState)(!1),[j,k]=(0,p.useState)(0),[l,m]=(0,p.useState)(0),n=(0,p.useRef)([]),o=(0,p.useRef)(null),q=(0,p.useRef)(null);(0,p.useEffect)(()=>{n.current=c},[c]),(0,p.useEffect)(()=>{o.current=e},[e]),(0,p.useEffect)(()=>{if(!a)return;let b=null,c=()=>{b&&clearTimeout(b),b=setTimeout(()=>d(t9(a)),250)};return a.on("update",c),d(t9(a)),()=>{b&&clearTimeout(b),a.off("update",c)}},[a]),(0,p.useEffect)(()=>{let c=b.current;if(!c)return;let d=0,e=()=>{cancelAnimationFrame(d),d=requestAnimationFrame(()=>{let b=c.scrollHeight-c.clientHeight;k(b>0?Math.min(1,c.scrollTop/b):0);let d=n.current,e=o.current;if(!a||!e||0===d.length)return void m(0);let f=d.findIndex(a=>a.uid===e);if(f<0)return void m(0);let g=d[f],h=d[f+1],i=ua(a,g);if(!i)return void m(0);let j=i.offsetTop,l=Math.max(1,(h?ua(a,h)?.offsetTop??c.scrollHeight:c.scrollHeight)-j);m(Math.max(0,Math.min(1,(c.scrollTop+Math.min(96,.25*c.clientHeight)-j)/l)))})};return c.addEventListener("scroll",e,{passive:!0}),()=>{c.removeEventListener("scroll",e),cancelAnimationFrame(d)}},[a,b]),(0,p.useEffect)(()=>{q.current?.disconnect();let d=b.current;if(!d||!a||0===c.length)return;let e=new IntersectionObserver(a=>{for(let b of a)if(b.isIntersecting){let a=b.target.dataset.outlineId;a&&f(a)}},{root:d,rootMargin:"-8% 0px -72% 0px",threshold:0});for(let b of c)try{let c=ua(a,b);c&&(c.dataset.outlineId=b.uid,e.observe(c))}catch{}return q.current=e,()=>{e.disconnect()}},[c,a,b]);let r=(0,p.useCallback)(b=>{if(!a)return;let c=ua(a,b);c&&(c.scrollIntoView({behavior:"smooth",block:"start"}),document.dispatchEvent(new CustomEvent("anchor-navigation",{detail:{element:c}})))},[a]),s=c.length>=2,[t,u]=(0,p.useState)(!1),v=(0,g.jsx)(g.Fragment,{children:c.map((a,b)=>(0,g.jsxs)("button",{onClick:()=>{r(a),u(!1)},title:a.text,className:(0,ao.cn)("text-left text-[10.5px] leading-snug py-0.5 rounded truncate transition-colors shrink-0",e===a.uid?"text-primary bg-primary/10 font-medium":"text-muted-foreground/60 hover:text-foreground hover:bg-accent",e===a.uid&&"relative overflow-hidden"),style:{paddingLeft:`${(a.level-1)*8+4}px`},children:[e===a.uid&&(0,g.jsx)("span",{"aria-hidden":!0,className:"absolute left-0 top-0 bottom-0 w-0.5 bg-primary/15",children:(0,g.jsx)("span",{className:"absolute bottom-0 left-0 w-full bg-primary transition-[height] duration-100 ease-out",style:{height:`${100*l}%`}})}),e===a.uid?(0,g.jsx)("span",{className:"relative z-10",children:a.text}):a.text]},`${a.uid}-${b}`))});return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{"aria-hidden":!0,className:"absolute top-0 left-0 right-0 h-0.5 z-30 pointer-events-none",children:(0,g.jsx)("div",{className:"h-full bg-primary/35 transition-[width] duration-100 ease-out",style:{width:`${100*j}%`}})}),s&&(0,g.jsxs)("div",{className:"absolute right-1 top-4 z-20 hidden xl:block w-40",children:[(0,g.jsxs)("button",{onClick:()=>i(a=>!a),className:"flex items-center gap-1 mb-1.5 px-1 py-0.5 rounded text-muted-foreground/40 hover:text-muted-foreground hover:bg-accent transition-colors text-[10px]","aria-label":h?"Expand outline":"Collapse outline",children:[(0,g.jsx)(oQ,{className:"h-3 w-3"}),!h&&(0,g.jsx)("span",{children:"Outline"})]}),!h&&(0,g.jsx)("nav",{"aria-label":"Document outline",className:"flex flex-col gap-px max-h-[50vh] overflow-y-auto pr-1",children:v})]}),s&&(0,g.jsxs)("div",{className:"absolute right-2 top-2 z-30 xl:hidden",children:[(0,g.jsx)("button",{onClick:()=>u(a=>!a),className:"flex items-center gap-1 px-1.5 py-1 rounded bg-background/80 backdrop-blur border border-border/60 text-muted-foreground/60 hover:text-foreground hover:bg-accent transition-colors text-[10px] shadow-sm","aria-label":"Document outline","aria-expanded":t,children:(0,g.jsx)(oQ,{className:"h-3.5 w-3.5"})}),t&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("button",{"aria-hidden":!0,tabIndex:-1,className:"fixed inset-0 z-0 cursor-default",onClick:()=>u(!1)}),(0,g.jsx)("nav",{"aria-label":"Document outline",className:"absolute right-0 top-9 z-10 w-52 max-h-[60vh] overflow-y-auto flex flex-col gap-px rounded-lg border border-border bg-popover p-2 shadow-lg",children:v})]})]})]})}let uc=`
128
128
  .tiptap > * {
129
129
  transition: opacity .35s ease;
130
130
  }
@@ -165,8 +165,8 @@ body.exp-focus-cocoon button[aria-label="Expand outline"] {
165
165
  animation: exp-anchor-flash 2s ease-out;
166
166
  border-radius: 6px;
167
167
  }
168
- `;function uj({scrollContainerRef:a}){return(0,p.useEffect)(()=>{let b=a.current;if(!b)return;let c=new Set,d=new WeakMap,e=null,f=0,g=a=>{a.classList.remove("exp-anchor-flash");let b=d.get(a);b&&(a.removeEventListener("animationend",b),d.delete(a)),c.delete(a)},h=()=>{let a,f;e=null;let h=(()=>{let a=b.getBoundingClientRect().top,c=null,d=1/0;for(let e of b.querySelectorAll(".tiptap > :is(h1,h2,h3,h4,h5,h6)")){let b=Math.abs(e.getBoundingClientRect().top-a-48);b<=14&&b<d&&(c=e,d=b)}return c})();h&&((a=d.get(h))&&(h.removeEventListener("animationend",a),d.delete(h)),h.classList.remove("exp-anchor-flash"),h.offsetWidth,h.classList.add("exp-anchor-flash"),c.add(h),f=()=>g(h),d.set(h,f),h.addEventListener("animationend",f,{once:!0}))},i=()=>{f||(f=requestAnimationFrame(()=>{f=0,e&&clearTimeout(e),e=setTimeout(h,140)}))};return b.addEventListener("scroll",i,{passive:!0}),()=>{for(let a of(b.removeEventListener("scroll",i),f&&cancelAnimationFrame(f),e&&clearTimeout(e),c))g(a)}},[a]),(0,g.jsx)("style",{children:ui})}function uk(a,b){try{let{node:c}=a.view.domAtPos(b+1);if(c.nodeType===Node.ELEMENT_NODE)return c.closest("h1,h2,h3,h4,h5,h6")??c;return c.parentElement?.closest("h1,h2,h3,h4,h5,h6")??null}catch{return null}}function ul(a){let b=a?.querySelector(".tiptap");if(b)for(let a of Array.from(b.children))a.style.display=""}function um({editor:a,scrollContainerRef:b}){let c=b_(a=>a.currentPath),[d,e]=(0,p.useState)(!1),[f,h]=(0,p.useState)(new Set),[i,j]=(0,p.useState)(null),[k,l]=(0,p.useState)([]),m=c?`wiki-collapsed:${c}`:"wiki-collapsed:shared",n=b.current;return((0,p.useEffect)(()=>{e(!0)},[]),(0,p.useEffect)(()=>{},[m]),(0,p.useEffect)(()=>{},[f,i,m]),(0,p.useEffect)(()=>{if(!a||!d||!n||i!==m){ul(n??null),l([]);return}let b=null,c=0,e=null,g=()=>{let b,c,d,e,g,h,i=(b=[],c=new Map,d=n.getBoundingClientRect(),e=n.querySelector(".tiptap"),h=(g=e?.getBoundingClientRect())?g.right-d.left+n.scrollLeft:d.width,a.state.doc.forEach((e,f)=>{if("heading"!==e.type.name)return;let g=e.textContent,i=e.attrs.level,j=g.toLowerCase().replace(/\s+/g,"-").replace(/[^\w-]/g,"")||"heading",k=(c.get(j)??0)+1;c.set(j,k);let l=1===k?j:`${j}-${k}`,m=uk(a,f);if(!(m instanceof HTMLElement))return;let o=m.offsetTop+m.offsetHeight/2,p=m.offsetLeft;try{let a=document.createRange();a.selectNodeContents(m);let b=a.getBoundingClientRect(),c=m.getBoundingClientRect(),e=0===b.width&&0===b.height?c:b;o=e.top-d.top+n.scrollTop+.6*e.height,p=e.right-d.left+n.scrollLeft+8}catch{let a=m.getBoundingClientRect();o=a.top-d.top+n.scrollTop+a.height/2,p=a.right-d.left+n.scrollLeft+8}b.push({level:i,text:g,pos:f,uid:l,centerY:o,endLeft:p,rootRight:h})}),b);l(i);let j=n.querySelector(".tiptap");if(j)for(let b of(ul(n),i)){if(!f.has(b.uid))continue;let c=uk(a,b.pos);if(!c||!j.contains(c))continue;let d=c.nextElementSibling;for(;d&&d.parentElement===j;){let a=function(a){if(!a)return null;let b=a.tagName.match(/^H([1-6])$/);return b?Number(b[1]):null}(d);if(null!==a&&a<=b.level)break;d.style.display="none",d=d.nextElementSibling}}},h=()=>{b&&clearTimeout(b),b=setTimeout(g,250)};return g(),c=requestAnimationFrame(g),a.on("update",h),"u">typeof ResizeObserver?(e=new ResizeObserver(g)).observe(n):window.addEventListener("resize",g,{passive:!0}),()=>{b&&clearTimeout(b),cancelAnimationFrame(c),a.off("update",h),window.removeEventListener("resize",g),e?.disconnect(),ul(n)}},[f,a,n,i,d,m]),d&&n)?(0,bu.createPortal)((0,g.jsx)("div",{"aria-hidden":!0,className:"absolute inset-0 h-0 pointer-events-none z-20",children:k.map(a=>{let b=f.has(a.uid),c=a.endLeft+20;return(0,g.jsxs)("div",{children:[(0,g.jsx)("button",{type:"button","aria-label":`${b?"Expand":"Collapse"} section: ${a.text}`,"aria-pressed":b,title:a.text,onClick:()=>{h(b=>{let c=new Set(b);return c.has(a.uid)?c.delete(a.uid):c.add(a.uid),c})},className:"pointer-events-auto absolute flex h-4 w-4 -translate-y-1/2 items-center justify-center rounded border border-border/70 bg-background/90 text-muted-foreground shadow-sm backdrop-blur transition-colors hover:bg-accent hover:text-foreground",style:{top:a.centerY,left:a.endLeft},children:b?(0,g.jsx)(a3.ChevronRight,{className:"h-3 w-3"}):(0,g.jsx)(s,{className:"h-3 w-3"})}),b&&a.rootRight-c>8?(0,g.jsx)("span",{"aria-hidden":!0,className:"absolute -translate-y-1/2 border-t border-dashed border-border/70",style:{top:a.centerY,left:c,width:a.rootRight-c}}):null]},a.uid)})}),n):null}function un(a){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ue,{...a}),(0,g.jsx)(uf,{...a}),(0,g.jsx)(uh,{...a}),(0,g.jsx)(uj,{...a}),(0,g.jsx)(um,{...a})]})}let uo=(0,h.default)("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]),up=(0,h.default)("unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]),uq=new Map,ur=new Map,us=(0,ay.create)((a,b)=>({path:null,backlinks:[],loading:!1,cacheVersion:0,fetch:async c=>{let d;if(!c)return;let e=(d=uq.get(c))?Date.now()-d.loadedAt>6e4?(uq.delete(c),null):d.data:null;if(e)return void a({path:c,backlinks:e,loading:!1});a({path:c,backlinks:[],loading:!0});let f=ur.get(c);if(f){try{let d=await f.promise;if(b().path!==c)return;a({backlinks:d,loading:!1})}catch{b().path===c&&a({loading:!1})}return}let g=new AbortController,h=(async()=>{let a=await (0,bB.wsFetch)(`/api/wiki/backlinks?path=${encodeURIComponent(c)}`,{signal:g.signal});return a.ok?(await a.json()).backlinks??[]:[]})().finally(()=>{ur.delete(c)});ur.set(c,{promise:h,controller:g});try{let d=await h;if(g.signal.aborted)return;if(uq.delete(c),uq.set(c,{data:d,loadedAt:Date.now()}),uq.size>30){let a=uq.keys().next().value;void 0!==a&&uq.delete(a)}if(b().path!==c)return;a({backlinks:d,loading:!1})}catch(d){if("AbortError"===d.name||b().path!==c)return;a({backlinks:[],loading:!1})}},cancel:()=>{let{path:c}=b();c&&ur.get(c)?.controller.abort(),b().loading&&a({loading:!1})},invalidateAll:()=>{uq.clear(),a({cacheVersion:b().cacheVersion+1})}})),ut="kb-backlinks-collapsed";function uu({currentPath:a}){let[b,c]=(0,p.useState)(!1),d=oa(a=>a.has),e=us(a=>a.path),f=us(a=>a.backlinks),h=us(a=>a.loading),i=us(a=>a.cacheVersion),j=e===a?f:[];return((0,p.useEffect)(()=>{"1"===localStorage.getItem(ut)&&c(!0)},[]),(0,p.useEffect)(()=>{if(b||!a)return;let c=setTimeout(()=>{us.getState().fetch(a)},200);return()=>{clearTimeout(c),us.getState().cancel()}},[a,b,i]),b||h||0!==j.length)?(0,g.jsx)("div",{className:"max-w-[var(--editor-max-w,48rem)] mx-auto px-4 sm:px-8 pb-8 pt-1",children:(0,g.jsxs)("div",{className:"border-t border-border/60 pt-4",children:[(0,g.jsxs)("button",{onClick:()=>{let a=!b;c(a);try{localStorage.setItem(ut,a?"1":"0")}catch{}},className:"flex items-center gap-1.5 text-[11px] text-muted-foreground/60 hover:text-muted-foreground transition-colors mb-2","aria-expanded":!b,children:[b?(0,g.jsx)(a3.ChevronRight,{className:"h-3 w-3 shrink-0"}):(0,g.jsx)(s,{className:"h-3 w-3 shrink-0"}),(0,g.jsx)(uo,{className:"h-3 w-3 shrink-0"}),(0,g.jsx)("span",{className:"font-medium",children:"Linked from"}),j.length>0&&(0,g.jsxs)("span",{className:"opacity-50 tabular-nums",children:["(",j.length,")"]}),h&&(0,g.jsx)("span",{className:"opacity-40 ml-1",children:"…"})]}),!b&&j.length>0&&(0,g.jsx)("ul",{className:"flex flex-col gap-1.5",children:j.map(a=>{var b,c;let e,f=d(((b=a.path).split("/").pop()??b).replace(/\.md$/i,""));return(0,g.jsxs)("li",{className:"flex flex-col",children:[(0,g.jsxs)("button",{onClick:()=>f&&b_.getState().loadPage(a.path),className:f?"text-left text-[12px] text-primary/70 hover:text-primary hover:underline underline-offset-2 truncate transition-colors flex items-center gap-1":"text-left text-[12px] text-muted-foreground/40 truncate cursor-default flex items-center gap-1",title:f?a.path:`${a.path} (file not found)`,children:[!f&&(0,g.jsx)(up,{className:"h-2.5 w-2.5 shrink-0 text-muted-foreground/30"}),(e=(c=a.path).replace(/\.md$/i,"").split("/")).length>1?e.slice(-2).join(" / "):e[0]??c]}),a.snippet&&(0,g.jsx)("p",{className:f?"text-[10.5px] text-muted-foreground/50 line-clamp-1 mt-0.5":"text-[10.5px] text-muted-foreground/25 line-clamp-1 mt-0.5",children:a.snippet})]},a.path)})})]})}):null}let uv=(0,h.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),uw=(0,h.default)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),ux=(0,h.default)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),uy=(0,h.default)("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),uz=(0,h.default)("columns-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),uA=(0,h.default)("panel-top",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]]),uB=(0,h.default)("rows-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);function uC({label:a,icon:b,disabled:c,active:d,danger:e,onAction:f}){return(0,g.jsx)("button",{type:"button","aria-label":a,title:a,disabled:c,onMouseDown:a=>a.preventDefault(),onClick:a=>{a.preventDefault(),f()},className:(0,ao.cn)("h-7 w-7 inline-flex items-center justify-center rounded text-foreground/80 hover:bg-accent transition-colors disabled:pointer-events-none disabled:opacity-35",d&&"bg-accent text-foreground",e&&"text-destructive hover:bg-destructive/10"),children:(0,g.jsx)(b,{className:"h-3.5 w-3.5"})})}function uD(){return(0,g.jsx)("div",{className:"mx-1 h-5 w-px bg-border"})}function uE({editor:a}){if(!a)return null;let b=()=>{if(!iJ(a.state))return null;try{return i2(a.state)}catch{return null}},c=b=>{b()&&(a.commands.focus(),a.commands.fixTables())},d=c=>{let d=b();if(!d)return;let e=d.top,f=e+c;if(!(f<0)&&!(f>=d.map.height)){var g;(g={from:e,to:f},(a,b)=>{let{from:c,to:d,select:e=!0,pos:f=a.selection.from}=g,h=a.tr;return!!function(a){var b,c,d,e,f;let g,{tr:h,originIndex:i,targetIndex:j,select:k,pos:l}=a,m=iY(h.doc.resolve(l));if(!m)return!1;let n=null==(b=i0(h,i))?void 0:b.indexes,o=null==(c=i0(h,j))?void 0:c.indexes;if(!n||!o||n.includes(j))return!1;let p=(d=m.node,e=n,f=o,g=iV(d),iW(d,g=iX(g,e,f,0)));if(h.replaceWith(m.pos,m.pos+m.node.nodeSize,p),!k)return!0;let q=iF.get(p),r=m.start,s=q.positionAt(j,q.width-1,p),t=h.doc.resolve(r+s),u=q.positionAt(j,0,p),v=h.doc.resolve(r+u);return h.setSelection(iQ.rowSelection(t,v)),!0}({tr:h,originIndex:c,targetIndex:d,select:e,pos:f})&&(null==b||b(h),!0)})(a.state,a.view.dispatch),a.commands.focus()}},e=c=>{let d=b();if(!d)return;let e=d.left,f=e+c;if(!(f<0)&&!(f>=d.map.width)){var g;(g={from:e,to:f},(a,b)=>{let{from:c,to:d,select:e=!0,pos:f=a.selection.from}=g,h=a.tr;return!!function(a){var b,c,d,e,f;let g,{tr:h,originIndex:i,targetIndex:j,select:k,pos:l}=a,m=iY(h.doc.resolve(l));if(!m)return!1;let n=null==(b=i_(h,i))?void 0:b.indexes,o=null==(c=i_(h,j))?void 0:c.indexes;if(!n||!o||n.includes(j))return!1;let p=(d=m.node,e=n,f=o,g=i1(iV(d)),iW(d,g=i1(g=iX(g,e,f,0))));if(h.replaceWith(m.pos,m.pos+m.node.nodeSize,p),!k)return!0;let q=iF.get(p),r=m.start,s=q.positionAt(q.height-1,j,p),t=h.doc.resolve(r+s),u=q.positionAt(0,j,p),v=h.doc.resolve(r+u);return h.setSelection(iQ.colSelection(t,v)),!0}({tr:h,originIndex:c,targetIndex:d,select:e,pos:f})&&(null==b||b(h),!0)})(a.state,a.view.dispatch),a.commands.focus()}},f=b(),h=!!f&&f.top>0,i=!!f&&f.top<f.map.height-1,j=!!f&&f.left>0,k=!!f&&f.left<f.map.width-1;return(0,g.jsxs)(ov,{editor:a,pluginKey:"tableMenu",options:{placement:"top",offset:10},shouldShow:({editor:a})=>a.isActive("table"),className:"flex items-center gap-0.5 rounded-md border border-border bg-popover px-1 py-1 shadow-lg",children:[(0,g.jsx)(uC,{label:"Select cell text",icon:t5,onAction:()=>{let b=iI(a.state.selection.$from),c=b?.nodeAfter;b&&c&&a.chain().focus().setTextSelection({from:b.pos+1,to:b.pos+c.nodeSize-1}).run()}}),(0,g.jsx)(uD,{}),(0,g.jsx)(uC,{label:"Add row above",icon:uB,onAction:()=>c(()=>a.chain().focus().addRowBefore().run())}),(0,g.jsx)(uC,{label:"Add row below",icon:uv,onAction:()=>c(()=>a.chain().focus().addRowAfter().run())}),(0,g.jsx)(uC,{label:"Move row up",icon:uy,disabled:!h,onAction:()=>d(-1)}),(0,g.jsx)(uC,{label:"Move row down",icon:uv,disabled:!i,onAction:()=>d(1)}),(0,g.jsx)(uC,{label:"Delete row",icon:bf,danger:!0,onAction:()=>c(()=>a.chain().focus().deleteRow().run())}),(0,g.jsx)(uD,{}),(0,g.jsx)(uC,{label:"Add column before",icon:uz,onAction:()=>c(()=>a.chain().focus().addColumnBefore().run())}),(0,g.jsx)(uC,{label:"Add column after",icon:ux,onAction:()=>c(()=>a.chain().focus().addColumnAfter().run())}),(0,g.jsx)(uC,{label:"Move column left",icon:uw,disabled:!j,onAction:()=>e(-1)}),(0,g.jsx)(uC,{label:"Move column right",icon:ux,disabled:!k,onAction:()=>e(1)}),(0,g.jsx)(uC,{label:"Delete column",icon:bf,danger:!0,onAction:()=>c(()=>a.chain().focus().deleteColumn().run())}),(0,g.jsx)(uD,{}),(0,g.jsx)(uC,{label:"Toggle header row",icon:uA,onAction:()=>c(()=>a.chain().focus().toggleHeaderRow().run())}),(0,g.jsx)(uC,{label:"Toggle header column",icon:c$,onAction:()=>c(()=>a.chain().focus().toggleHeaderColumn().run())}),(0,g.jsx)(uD,{}),(0,g.jsx)(uC,{label:"Delete table",icon:bf,danger:!0,onAction:()=>a.chain().focus().deleteTable().run()})]})}let uF=["entities","concepts","comparisons"],uG=/^[a-z0-9-]+$/;function uH({editor:a,onCreateRequest:b}){let[c,d]=(0,p.useState)(!1),[e,f]=(0,p.useState)(""),[h,i]=(0,p.useState)(0),[j,k]=(0,p.useState)({top:0,left:0}),l=(0,p.useRef)(null),m=(0,p.useRef)(0),n=oa(a=>a.slugs),o=oa(a=>a.slugDir),q=oa(a=>a.has),r=Array.from(n).sort().filter(a=>!e||a.includes(e.toLowerCase())).slice(0,20),s=e.length>0&&uG.test(e)&&!q(e),t=r.length+ +!!s,u=(0,p.useCallback)(()=>{d(!1),f(""),i(0)},[]),v=(0,p.useCallback)(b=>{if(!a)return;let{from:c}=a.state.selection,d=m.current-2,e=a.state.schema.marks.wikiLink;if(!e)return;let f=e.create({slug:b,alias:null,anchor:null}),g=a.state.schema.text(b,[f]),h=a.state.tr.replaceWith(d,c,g);a.view.dispatch(h),a.commands.focus(),u()},[a,u]),w=(0,p.useCallback)(async c=>{if(a){if(c<r.length)v(r[c]??"");else if(s){let a=await b(e);a.ok?v(a.slug):u()}}},[a,r,s,e,v,b,u]);return((0,p.useEffect)(()=>{if(!a)return;let b=b=>{if(!c){if("["===b.key){let{from:b}=a.state.selection;if("["!==a.state.doc.textBetween(Math.max(0,b-1),b)||a.state.doc.resolve(b).marks().some(a=>"wikiLink"===a.type.name))return;let c=a.view.coordsAtPos(b),e=a.view.dom.getBoundingClientRect();k({top:c.bottom-e.top+4,left:c.left-e.left}),m.current=b+1,d(!0),f(""),i(0)}return}"ArrowDown"===b.key?(b.preventDefault(),i(a=>t>0?(a+1)%t:0)):"ArrowUp"===b.key?(b.preventDefault(),i(a=>t>0?(a-1+t)%t:0)):"Enter"===b.key?(b.preventDefault(),b.stopPropagation(),t>0&&w(h)):"Escape"===b.key||"]"===b.key?u():"Backspace"===b.key?0===e.length?u():(f(a=>a.slice(0,-1)),i(0)):1!==b.key.length||b.metaKey||b.ctrlKey||(f(a=>a+b.key),i(0))};return window.addEventListener("keydown",b,!0),()=>window.removeEventListener("keydown",b,!0)},[a,c,e,h,t,u,w]),(0,p.useEffect)(()=>{if(!c)return;let a=a=>{l.current&&!l.current.contains(a.target)&&u()};return window.addEventListener("mousedown",a),()=>window.removeEventListener("mousedown",a)},[c,u]),c&&0!==t)?(0,g.jsxs)("div",{ref:l,className:"absolute z-50 w-[280px] bg-popover border border-border rounded-lg shadow-lg py-1 overflow-hidden max-h-[300px] overflow-y-auto",style:{top:j.top,left:j.left},children:[r.map((a,b)=>{let c=o.get(a);return(0,g.jsxs)("button",{type:"button",onMouseDown:a=>{a.preventDefault(),w(b)},onMouseEnter:()=>i(b),className:(0,ao.cn)("flex items-center justify-between w-full px-3 py-1.5 text-left text-sm transition-colors",b===h?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:[(0,g.jsx)("span",{className:"truncate",children:a}),c&&(0,g.jsx)("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground bg-muted px-1.5 py-0.5 rounded",children:c})]},a)}),s&&(0,g.jsx)("button",{type:"button",onMouseDown:a=>{a.preventDefault(),w(r.length)},onMouseEnter:()=>i(r.length),className:(0,ao.cn)("flex items-center w-full px-3 py-1.5 text-left text-sm transition-colors",r.length===h?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:(0,g.jsxs)("span",{className:"text-muted-foreground",children:["+ Create new “",e,"”"]})})]}):null}let uI=(0,by.cva)("inline-flex items-center rounded-sm border px-2.5 py-0.5 text-xs font-normal transition-colors focus:outline-none focus:ring-2 focus:ring-ring",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow-e-1",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground shadow-e-1",outline:"text-foreground",accent:"border-transparent bg-accent text-accent-foreground"}},defaultVariants:{variant:"default"}});function uJ({className:a,variant:b,...c}){return(0,g.jsx)("div",{className:(0,ao.cn)(uI({variant:b}),a),...c})}let uK=new Set(["title","type","status","created","updated","date","tags","sources","private","supersedes","superseded_by"]);function uL({data:a}){let[b,c]=(0,p.useState)(!1),d=Object.keys(a);if(0===d.length)return null;let e="string"==typeof a.title?a.title:null,f="string"==typeof a.type?a.type:null,h="string"==typeof a.status?a.status:null,i="string"==typeof a.created?a.created:null,j="string"==typeof a.updated?a.updated:null,k=!0===a.private,l=Array.isArray(a.tags)?a.tags:[],m=Array.isArray(a.sources)?a.sources:[],n="string"==typeof a.superseded_by?a.superseded_by:null,o=d.filter(a=>!uK.has(a));return(0,g.jsxs)("div",{className:"mb-6 rounded-sm border bg-card/40 px-4 py-3 text-xs",children:[e&&(0,g.jsx)("div",{className:"mb-2 text-base font-normal text-foreground",children:e}),(0,g.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5 text-muted-foreground",children:[f&&(0,g.jsx)(uJ,{variant:"outline",className:"font-normal",children:f}),h&&(0,g.jsx)(uJ,{variant:"outline",className:"font-normal",children:h}),k&&(0,g.jsx)(uJ,{variant:"outline",className:"border-warning-ink/40 font-normal text-warning-ink",children:"private"}),n&&(0,g.jsxs)(uJ,{variant:"outline",className:"border-destructive/40 font-normal text-destructive",children:["superseded → ",n]}),i&&(0,g.jsxs)("span",{children:[(0,g.jsx)("span",{className:"opacity-60",children:"created"})," ",(0,g.jsx)("span",{className:"text-foreground/80",children:i})]}),j&&j!==i&&(0,g.jsxs)("span",{children:[(0,g.jsx)("span",{className:"opacity-60",children:"updated"})," ",(0,g.jsx)("span",{className:"text-foreground/80",children:j})]})]}),l.length>0&&(0,g.jsx)("div",{className:"mt-2 flex flex-wrap gap-1",children:l.map(a=>(0,g.jsxs)(uJ,{variant:"secondary",className:"font-normal text-[11px]",children:["#",a]},a))}),m.length>0&&(0,g.jsxs)("div",{className:"mt-2",children:[(0,g.jsx)("span",{className:"opacity-60",children:"sources:"})," ",(0,g.jsx)("span",{className:"text-foreground/80",children:m.join(", ")})]}),o.length>0&&(0,g.jsxs)("div",{className:"mt-2 border-t pt-2",children:[(0,g.jsxs)("button",{type:"button",onClick:()=>c(a=>!a),className:"flex items-center gap-1 text-muted-foreground hover:text-foreground",children:[b?(0,g.jsx)(s,{className:"h-3 w-3"}):(0,g.jsx)(a3.ChevronRight,{className:"h-3 w-3"}),(0,g.jsxs)("span",{children:[o.length," more field",1===o.length?"":"s"]})]}),b&&(0,g.jsx)("dl",{className:"mt-1.5 grid grid-cols-[max-content_1fr] gap-x-3 gap-y-0.5",children:o.map(b=>(0,g.jsxs)(p.Fragment,{children:[(0,g.jsx)("dt",{className:"opacity-60",children:b}),(0,g.jsx)("dd",{className:"text-foreground/80 break-words",children:function a(b){if(null==b)return"";if("string"==typeof b)return b;if("number"==typeof b||"boolean"==typeof b)return String(b);if(Array.isArray(b))return b.map(a).join(", ");try{return JSON.stringify(b)}catch{return String(b)}}(a[b])})]},b))})]})]})}function uM({containerRef:a,onComment:b,align:c="center"}){let[d,e]=(0,p.useState)(null);return((0,p.useEffect)(()=>{function b(){let b=window.getSelection();if(!b||b.isCollapsed||0===b.rangeCount)return void e(null);let d=b.getRangeAt(0),f=a.current;if(!f||!f.contains(d.commonAncestorContainer))return void e(null);let g=d.getBoundingClientRect();if(0===g.width&&0===g.height)return void e(null);if("left"===c){let a=f.getBoundingClientRect();e({top:g.top,left:a.left+8})}else e({top:g.top-38,left:g.left+g.width/2})}return document.addEventListener("selectionchange",b),()=>document.removeEventListener("selectionchange",b)},[a,c]),d)?(0,g.jsxs)("button",{type:"button",style:{position:"fixed",top:d.top,left:d.left,transform:"left"===c?void 0:"translateX(-50%)",zIndex:50},className:"flex items-center gap-1 px-2 py-1 bg-popover border border-border rounded-sm shadow-lg text-[12px] text-foreground/80 hover:text-foreground hover:bg-accent transition-colors",onMouseDown:a=>a.preventDefault(),onClick:()=>{b(),e(null)},"aria-label":"Add comment",title:"Add comment",children:[(0,g.jsx)(oC,{className:"w-3.5 h-3.5"}),(0,g.jsx)("span",{children:"Comment"})]}):null}async function uN(a,b){let c=new FormData;c.append("file",b);try{let d=await (0,bB.wsFetch)(`/api/upload/${a}`,{method:"POST",body:c});if(!d.ok)return au(`Upload failed: ${b.name}`),null;let e=await d.json();return e.url?(0,bB.withWs)(e.url):e.url}catch{return au(`Upload failed: ${b.name}`),null}}function uO({mode:a}={}){let{currentPath:b,content:c,saveStatus:d,frontmatter:e,isLoading:f,loadStatus:h,createMissingPage:i,editMode:j,setEditMode:k}=b_(),l=a??j,n="viewing"===l,o="suggesting"===l,s=(0,p.useMemo)(()=>n?function(a){let b=n8.exec(a);if(!b)return{data:{},body:a};let c=b[1],d=a.slice(b[0].length),e=c.split(/\r?\n/).find(a=>""!==a.trim())??"";if(/^\s*(#{1,6}\s|<|>|-\s|\*\s|\d+\.\s)/.test(e))return{data:{},body:a};let f={},g=c.split(/\r?\n/),h=0;for(;h<g.length;){let a=g[h];if(!a||/^\s*#/.test(a)){h+=1;continue}let b=/^([A-Za-z_][\w-]*)\s*:\s*(.*)$/.exec(a);if(!b){h+=1;continue}let c=b[1],d=b[2];if(""===d.trim()){let a=[],b=h+1;for(;b<g.length&&/^\s+-\s+/.test(g[b]);){let c=/^\s+-\s+(.*)$/.exec(g[b]);c&&a.push(n9(c[1])),b+=1}if(a.length>0){f[c]=a,h=b;continue}f[c]="",h+=1;continue}f[c]=n9(d),h+=1}return 0===Object.keys(f).length?{data:{},body:a}:{data:f,body:d}}(c):{data:{},body:c},[c,n]),t=(0,dK.useViewWidthStore)(a=>dK.VIEW_WIDTH_CSS[a.width]),u=(0,dK.useViewWidthStore)(a=>dK.VIEW_ALIGN_ML[a.align]),w=n?"rtl"===s.data.dir:e?.dir==="rtl",{open:x,clearMessages:y}=bF(),{open:z,Dialog:A}=function(){let[a,b]=(0,p.useState)(!1),[c,d]=(0,p.useState)({slug:"",dir:"entities",title:""}),[e,f]=(0,p.useState)(!1),h=(0,p.useRef)(null),i=(0,p.useCallback)(a=>(d({slug:a,dir:"entities",title:a.split("-").filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}),b(!0),new Promise(a=>{h.current=a})),[]),j=(0,p.useCallback)(()=>{b(!1),h.current?.({ok:!1,slug:c.slug}),h.current=null},[c.slug]),k=(0,p.useCallback)(async()=>{let{slug:a,dir:d,title:e}=c;f(!0);try{let c=await (0,bB.wsFetch)("/api/wiki/page",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:a,dir:d,title:e.trim()||void 0})});if(c.ok||409===c.status){let c=oa.getState();c.invalidate(),c.load(),b(!1),h.current?.({ok:!0,slug:a,dir:d}),h.current=null}else{let a=await c.json().catch(()=>({})),b=null!==a&&"object"==typeof a&&"error"in a&&"string"==typeof a.error?a.error:"Failed to create page";au(b)}}catch{au("Failed to create page")}finally{f(!1)}},[c]);return{open:i,Dialog:(0,g.jsx)(P,{open:a,onOpenChange:a=>{a||j()},children:(0,g.jsxs)(aZ,{children:[(0,g.jsx)(a$,{children:(0,g.jsx)(a0,{children:"Create wiki page"})}),(0,g.jsxs)("div",{className:"space-y-4 py-2",children:[(0,g.jsxs)("div",{className:"space-y-1.5",children:[(0,g.jsx)(bA,{htmlFor:"wiki-create-slug",children:"Slug"}),(0,g.jsx)(bh.Input,{id:"wiki-create-slug",value:c.slug,readOnly:!0,className:"bg-muted cursor-default select-all"})]}),(0,g.jsxs)("div",{className:"space-y-1.5",children:[(0,g.jsx)(bA,{children:"Directory"}),(0,g.jsx)("div",{className:"flex gap-4",children:uF.map(a=>(0,g.jsxs)("label",{className:"flex items-center gap-1.5 text-sm cursor-pointer",children:[(0,g.jsx)("input",{type:"radio",name:"wiki-create-dir",value:a,checked:c.dir===a,onChange:()=>d(b=>({...b,dir:a})),className:"accent-primary"}),a]},a))})]}),(0,g.jsxs)("div",{className:"space-y-1.5",children:[(0,g.jsx)(bA,{htmlFor:"wiki-create-title",children:"Title (optional)"}),(0,g.jsx)(bh.Input,{id:"wiki-create-title",value:c.title,onChange:a=>d(b=>({...b,title:a.target.value})),placeholder:"Humanized title..."})]})]}),(0,g.jsxs)(a_,{children:[(0,g.jsx)(v.Button,{variant:"outline",onClick:j,disabled:e,children:"Cancel"}),(0,g.jsx)(v.Button,{onClick:()=>void k(),disabled:e,children:e?"Creating...":"Create"})]})]})})}}(),B=(0,p.useRef)(z);B.current=z;let C=(0,p.useRef)(!1),D=(0,p.useRef)(n);D.current=n;let E=(0,p.useRef)(null),[F,G]=(0,p.useState)(!1),[H,I]=(0,p.useState)("");(0,p.useEffect)(()=>{oa.getState().load()},[]),(0,p.useEffect)(()=>{if(!b)return;let a=setTimeout(()=>{oc.getState().loadSidecar(b)},200);return()=>clearTimeout(a)},[b]),function({path:a,mode:b,enabled:c=!0}){(0,p.useEffect)(()=>{},[c,a,"viewing"===b])}({path:b,mode:l,enabled:!0}),function({path:a,isViewingRef:b,enabled:c=!0}){let d=(0,p.useMemo)(()=>{if(!a)return"";let b=a.lastIndexOf("/");return -1===b?"":a.slice(0,b)},[a]),e=(0,bB.getActiveWorkspaceId)(),f=(0,bB.getEphemeralRoot)();(0,p.useEffect)(()=>{},[a,d,c,e,f,b])}({path:b,isViewingRef:D});let[J,K]=(0,p.useState)(null),L=(0,p.useRef)(null),[M,N]=(0,p.useState)(new Map),O=oc(a=>b?a.byPath[b]?.snapshotBlocks:void 0),Q=oc(a=>b?a.byPath[b]?.sidecar?.suggestions:void 0),R=oc(a=>b?a.byPath[b]?.snapshotRevision??0:0),S=oc(a=>b?a.byPath[b]?.sidecar?.comments:void 0),T=(0,p.useMemo)(()=>O??[],[O]),U=(0,p.useMemo)(()=>S??[],[S]),V=(0,p.useMemo)(()=>Q?.filter(a=>"pending"===a.status)??[],[Q]),W=(0,p.useMemo)(()=>{let a={};for(let b of U)b.ref&&(a[b.ref]??=[]).push(b);return a},[U]),[X,Y]=(0,p.useState)(null),[Z,$]=(0,p.useState)(null),_=(0,p.useCallback)(()=>{if(!E.current)return null;let a=E.current.view,{from:b}=a.state.selection,c=b_.getState().currentPath??"",d=oc.getState().byPath[c]?.snapshotBlocks??[],e=a.state.doc.resolve(b),f=e.depth>0?e.index(0):0,g=L.current?.querySelector(".ProseMirror"),h=(g?Array.from(g.children):[])[f]??null,i=d[f],j=i?.ref??h?.getAttribute("data-block-ref")??null,k=i?.markdown??"";if(!j&&h){let c=a.domAtPos(b),d=c.node.nodeType===Node.ELEMENT_NODE?c.node:c.node.parentElement,e=d?.closest("[data-block-ref]")??null;j=e?.getAttribute("data-block-ref")??null}return j&&h?{blockRef:j,blockEl:h,markdown:k}:null},[]),aa=(0,p.useCallback)(()=>{let a=_();if(!a)return;let b=a.blockEl.getBoundingClientRect();$({blockRef:a.blockRef,markdown:a.markdown,anchor:{top:b.bottom+4,left:b.left}})},[_]),ab=(0,p.useCallback)(()=>{let a=_();a&&Y({blockRef:a.blockRef,el:a.blockEl})},[_]),{markDirty:ac,flush:ad,onSelectionUpdate:ae}=function({path:a,editorRef:b,scrollContainerRef:c,isLoadingRef:d,isViewingRef:e,enabled:f=!0}){let g=(0,p.useRef)(!1),h=(0,p.useRef)(!1),i=(0,p.useRef)(null),j=(0,p.useCallback)(async()=>{if(h.current||!f||e.current||"suggesting"!==b_.getState().editMode||!g.current)return;let i=b.current,j=a??b_.getState().currentPath;if(!i||!j)return;let k=c.current?.querySelector(".ProseMirror");if(!k)return;let l=Array.from(k.children),m=oc.getState().byPath[j]?.snapshotBlocks??[];if(0!==m.length){h.current=!0,g.current=!1;try{let a=()=>oc.getState().byPath[j]?.snapshotRevision??0,b=async()=>{await oc.getState().loadSnapshot(j),await oc.getState().loadSidecar(j)},c=Math.max(l.length,m.length),e=!1;for(let d=0;d<c;d++){let c=l[d],f=m[d],g=c?n7(c.outerHTML,j).trim():null;if(f&&null!==g){if(tu(g)!==tu(f.markdown)){let c=await tt({path:j,ref:f.ref,kind:"replace",markdown:g,getRevision:a,refresh:b});e=e||c}}else if(f&&null===g){let c=await tt({path:j,ref:f.ref,kind:"delete",getRevision:a,refresh:b});e=e||c}else if(!f&&null!==g&&g.length>0){let c=m[m.length-1]?.ref;if(c){let d=await tt({path:j,ref:c,kind:"insertAfter",markdown:g,getRevision:a,refresh:b});e=e||d}}}if(e){await b();let a=(oc.getState().byPath[j]?.snapshotBlocks??m).map(a=>a.markdown).join("\n\n");d.current=!0;let c=await (0,np.markdownToHtml)(a,j);i.commands.setContent(c),setTimeout(()=>{d.current=!1},50)}}finally{h.current=!1}}},[f,a,b,c,d,e]),k=(0,p.useCallback)(()=>{!f||e.current||"suggesting"===b_.getState().editMode&&(g.current=!0)},[f,e]),l=(0,p.useCallback)(a=>{if("suggesting"!==b_.getState().editMode)return;let{from:b}=a.state.selection,c=a.state.doc.resolve(b),d=c.depth>0?c.index(0):0,e=i.current;i.current=d,null!==e&&e!==d&&g.current&&j()},[j]);return{markDirty:k,flush:j,onSelectionUpdate:l}}({path:b,editorRef:E,scrollContainerRef:L,isLoadingRef:C,isViewingRef:D});(0,p.useEffect)(()=>{if(!b)return;let a=setTimeout(()=>{oc.getState().loadSnapshot(b)},200);return()=>clearTimeout(a)},[b]),(0,p.useEffect)(()=>{if(!b||0===T.length||!L.current)return;let a=L.current,c=a.querySelector(".ProseMirror");if(!c)return;let d=Array.from(c.children),e=a.getBoundingClientRect(),f=new Map;for(let b=0;b<Math.min(d.length,T.length);b++){let c=d[b],g=T[b];c.setAttribute("data-block-ref",g.ref);let h=c.getBoundingClientRect();f.set(g.ref,{top:h.top-e.top+a.scrollTop,left:h.left-e.left,width:h.width,bottom:h.bottom-e.top+a.scrollTop})}N(f)},[b,T]);let af=function(a={},b=[]){let c=(0,jz.useRef)(a);c.current=a;let[d]=(0,jz.useState)(()=>new m9(c)),e=(0,jA.useSyncExternalStore)(d.subscribe,d.getEditor,d.getServerSnapshot);return(0,jz.useDebugValue)(e),(0,jz.useEffect)(d.onRender(b)),!function(a){var b;let[c]=(0,jz.useState)(()=>new m8(a.editor)),d=(0,m2.useSyncExternalStoreWithSelector)(c.subscribe,c.getSnapshot,c.getServerSnapshot,a.selector,null!=(b=a.equalityFn)?b:m0);m7(()=>c.watch(a.editor),[a.editor,c]),(0,jz.useDebugValue)(d)}({editor:e,selector:({transactionNumber:b})=>!1===a.shouldRerenderOnTransaction||void 0===a.shouldRerenderOnTransaction?null:a.immediatelyRender&&0===b?0:b+1}),e}({extensions:tp,content:"",editable:!n,onUpdate:(0,p.useCallback)(({editor:a})=>{if(C.current||D.current||!a)return;ac();let b=n7(a.getHTML(),b_.getState().currentPath??void 0);b_.getState().updateContent(b)},[]),onBlur:()=>{ad()},onSelectionUpdate:({editor:a})=>{ae(a)},editorProps:{attributes:{class:"focus:outline-none min-h-[calc(100vh-12rem)] px-4 sm:px-8 py-6 max-w-[var(--editor-max-w,48rem)] ml-[var(--editor-ml,auto)] mr-auto"},handleKeyDown:(a,b)=>{if((b.metaKey||b.ctrlKey)&&"a"===b.key.toLowerCase()&&iJ(a.state)){let c=iI(a.state.selection.$from),d=c?.nodeAfter;if(!c||!d)return!1;let e=c.pos+1,f=c.pos+d.nodeSize-1;return(a.state.selection.from!==e||a.state.selection.to!==f)&&(b.preventDefault(),af?.chain().focus().setTextSelection({from:e,to:f}).run(),!0)}return!1},handleClick:(a,b,c)=>{let d=c.target.closest("a");if(!d)return!1;let e=d.getAttribute("href");if(!e)return!1;if("true"===d.dataset.wikiLink){c.preventDefault(),c.stopPropagation();let a=d.dataset.slug??"",b=d.dataset.anchor??null;if(!a)return!0;let e=oa.getState();if(e.has(a)){let c=e.getDir(a),d=null===c||"root"===c?`${a}.md`:`${c}/${a}.md`;b_.getState().loadPage(d),b&&setTimeout(()=>{document.querySelector(`[id="${b}"]`)?.scrollIntoView({behavior:"smooth"})},200)}else{if(D.current)return!0;B.current(a).then(a=>{if(a.ok){let b=a.dir??"entities",c=`${b}/${a.slug}.md`;b_.getState().loadPage(c)}})}return!0}if(/^https?:\/\//.test(e)||e.startsWith("/api/")||e.startsWith("mailto:")||e.startsWith("tel:"))return!1;c.preventDefault(),c.stopPropagation();let f=function(a,b,c){var d;let e;if(!a||/^[a-z][a-z0-9+.-]*:/i.test(a)||a.startsWith("/api/"))return null;let f=a.indexOf("#"),g=f>=0?tr(a.slice(0,f)):tr(a);if(!g)return null;tq.test(g);let h=g.replace(tq,""),i=h.startsWith("/"),j=h.startsWith("./")||h.startsWith("../");if(!i&&!j&&!g.includes("/")&&!g.includes(".")&&c?.has(h)){let a=c.getDir(h);return null===a||"root"===a?`${h}.md`:`${a}/${h}.md`}if(i)e=h.replace(/^\/+/,"");else{let a=b?.includes("/")?b.slice(0,b.lastIndexOf("/")):"";e=a?`${a}/${h.replace(/^\.\/+/,"")}`:h.replace(/^\.\/+/,"")}let k=function(a){let b=a.split("/").filter(a=>a.length>0&&"."!==a),c=[];for(let a of b)if(".."===a){if(0===c.length)return null;c.pop()}else c.push(a);return c.join("/")}(e);return null===k||""===k?null:(d=k.split("/").pop()??k,/\.[^./]+$/.test(d))?k:`${k}.md`}(e,b_.getState().currentPath,oa.getState());if(f){b_.getState().loadPage(f);let a=e.includes("#")?e.slice(e.indexOf("#")+1):"";a&&setTimeout(()=>{document.querySelector(`[id="${a}"]`)?.scrollIntoView({behavior:"smooth"})},200)}return!0},handlePaste:(a,b)=>{if(D.current)return!1;let c=b.clipboardData?.files,d=b_.getState().currentPath;if(c&&c.length>0&&d){for(let a of Array.from(c))uN(d,a).then(b=>{b&&af&&(a.type.startsWith("image/")?af.chain().focus().setImage({src:b,alt:a.name}).run():af.chain().focus().insertContent(`<a href="${b}">${a.name}</a>`).run())});return!0}return!1},handleDrop:(a,b)=>{if(D.current)return!1;let c=b.dataTransfer?.files;if(!c||0===c.length)return!1;let d=b_.getState().currentPath;if(!d)return!1;for(let a of(b.preventDefault(),Array.from(c)))uN(d,a).then(b=>{b&&af&&(a.type.startsWith("image/")?af.chain().focus().setImage({src:b,alt:a.name}).run():af.chain().focus().insertContent(`<a href="${b}">${a.name}</a>`).run())});return!0}},immediatelyRender:!1});E.current=af,(0,p.useEffect)(()=>{af?.setEditable(!n),n&&G(!1)},[af,n]);let ag=(0,p.useRef)(null),ah=(0,p.useRef)(null),[ai,aj]=(0,p.useState)(null);(0,p.useEffect)(()=>{if(!af||null===b||b_.getState().isDirty&&b===ag.current||f&&""===c)return;let a=s.body,d=`${b} ${a}`;if(ah.current===d){ai!==b&&aj(b);return}ag.current=b;let e=!1;return(async()=>{C.current=!0;let c=await (0,np.markdownToHtml)(a,n?{pagePath:b,sanitize:!0}:b);if(e||b_.getState().currentPath!==b){C.current=!1;return}af.commands.setContent(c),ah.current=d,aj(b),setTimeout(()=>{C.current=!1},50)})(),()=>{e=!0}},[af,c,b,f,ai,s.body,n]),(0,p.useEffect)(()=>{if(!n||!ai)return;let a=L.current;a&&a.querySelectorAll('input[type="checkbox"]').forEach(a=>{a.disabled=!0})},[n,ai,s.body]);let ak=null!==b&&(f||ai!==b),[al,am]=(0,p.useState)(!1);if((0,p.useEffect)(()=>{if(!ak)return void am(!1);let a=setTimeout(()=>am(!0),150);return()=>clearTimeout(a)},[ak]),null===b)return(0,g.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,g.jsxs)("div",{className:"text-center space-y-3",children:[(0,g.jsx)("p",{className:"text-lg font-medium tracking-[-0.02em]",children:"No page selected"}),(0,g.jsx)("p",{className:"text-sm text-muted-foreground/70",children:"Select a page from the sidebar or create a new one"})]})});if("missing"===h){let a=(b.split("/").pop()||b).replace(/[-_]+/g," ").replace(/\b\w/g,a=>a.toUpperCase());return(0,g.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,g.jsx)("div",{className:"max-w-3xl mx-auto px-6 py-10 space-y-6",children:(0,g.jsxs)("div",{className:"space-y-3",children:[(0,g.jsx)("p",{className:"text-lg font-medium tracking-[-0.02em] text-foreground",children:a}),(0,g.jsx)("p",{className:"text-sm text-muted-foreground/80",children:"This page doesn't exist yet."}),(0,g.jsxs)("button",{onClick:()=>void i(a),className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-[13px] font-medium text-primary-foreground hover:bg-primary/90 transition-colors",children:[(0,g.jsx)(cc,{className:"h-3.5 w-3.5"}),"Create page"]})]})})})}let an=async()=>{if(F){if(b_.getState().updateContent(H),af){C.current=!0;let a=await (0,np.markdownToHtml)(H,b??void 0);af.commands.setContent(a),setTimeout(()=>{C.current=!1},50)}G(!1)}else I(b_.getState().content),G(!0)};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[!n&&(0,g.jsxs)("div",{className:"flex items-center min-w-0",children:[(0,g.jsx)("div",{className:"flex-1 min-w-0",children:!F&&(0,g.jsx)(o5,{editor:af})}),(0,g.jsxs)("button",{onClick:an,className:`flex items-center gap-1.5 px-3 py-1 mr-2 text-[11px] rounded-md transition-colors border border-border ${F?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"}`,children:[(0,g.jsx)(d1,{className:"h-3 w-3"}),F?"Preview":"Markdown"]})]}),F?(0,g.jsx)("div",{className:"flex-1 overflow-y-auto p-4",dir:w?"rtl":void 0,children:(0,g.jsx)("textarea",{value:H,onChange:a=>I(a.target.value),className:"w-full h-full min-h-[calc(100vh-12rem)] bg-transparent font-mono text-[13px] leading-relaxed resize-none focus:outline-none",spellCheck:!1})}):(0,g.jsxs)("div",{className:"flex-1 relative",dir:w?"rtl":void 0,children:[o&&(0,g.jsx)("div",{className:"absolute top-0 inset-x-0 z-20 flex items-center justify-center gap-2 px-3 py-1 bg-primary/10 border-b border-primary/20 text-[11px] text-primary pointer-events-none",children:"Suggesting mode · your edits become suggestions for review"}),(0,g.jsx)(ub,{editor:af,scrollContainerRef:L}),(0,g.jsx)(un,{editor:af,scrollContainerRef:L}),(0,g.jsxs)("div",{ref:L,className:`absolute inset-0 overflow-y-auto ${o?"pt-7":""}`,style:{"--editor-max-w":t,"--editor-ml":u},"data-editor-scroll":!0,children:[(0,g.jsxs)("div",{"aria-hidden":"true",className:"relative pointer-events-none",style:{height:0},children:[Object.entries(W).map(([a,b])=>{let c=M.get(a);return c?(0,g.jsx)("div",{style:{pointerEvents:"auto"},children:(0,g.jsx)(tw,{anchorKey:a,anchorLabel:a,comments:b,top:c.top+4,left:Math.max(0,c.left-20),onClick:()=>{let b=L.current?.querySelector(`[data-block-ref="${a}"]`);b&&Y({blockRef:a,el:b})}})},`pip-${a}`):null}),b&&V.map(a=>{let c=M.get(a.ref),d=T.find(b=>b.ref===a.ref);if(!c||!d)return null;let e="insertAfter"===a.kind?c.bottom+4:"insertBefore"===a.kind?Math.max(0,c.top-80):c.top;return(0,g.jsx)("div",{style:{pointerEvents:"auto"},children:(0,g.jsx)(t$,{path:b,suggestion:a,currentMarkdown:d.markdown,baseRevision:R,getLatestRevision:()=>oc.getState().byPath[b]?.snapshotRevision??0,top:e,left:c.left,width:c.width,onSettled:()=>{oc.getState().loadSidecar(b),oc.getState().loadSnapshot(b)},readOnly:n})},`sug-${a.id}`)})]}),X&&b&&(0,g.jsx)(tX,{path:b,anchorKey:X.blockRef,anchorRef:X.blockRef,anchorLabel:X.blockRef,comments:W[X.blockRef]??[],anchorEl:X.el,onClose:()=>Y(null),readOnly:n}),Z&&b&&(0,g.jsx)(t1,{path:b,blockRef:Z.blockRef,currentMarkdown:Z.markdown,anchor:Z.anchor,onClose:()=>$(null)}),n&&Object.keys(s.data).length>0&&(0,g.jsx)("div",{className:"max-w-[var(--editor-max-w,48rem)] ml-[var(--editor-ml,auto)] mr-auto px-4 sm:px-8 pt-6",children:(0,g.jsx)(uL,{data:s.data})}),(0,g.jsx)(m6,{editor:af}),b&&/\.(md|markdown)$/i.test(b)&&(0,g.jsx)(uu,{currentPath:b}),(0,g.jsx)("div",{"aria-hidden":"true",className:"contents",onMouseOver:a=>{let b=a.target.closest(".proof-span");b&&b!==J&&K(b)},onMouseOut:a=>{let b=a.relatedTarget;b?.closest(".proof-span")||K(null)}}),b&&(0,g.jsx)(tY,{targetEl:J,path:b,onClose:()=>K(null),onComment:()=>{if(!J)return;let a=J.closest("[data-block-ref]");if(!a)return;let b=a.getAttribute("data-block-ref");b&&Y({blockRef:b,el:a})}}),!n&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(oJ,{editor:af,onSuggestEdit:aa,onComment:ab}),(0,g.jsx)(uE,{editor:af}),(0,g.jsx)(t8,{editor:af}),(0,g.jsx)(uH,{editor:af,onCreateRequest:B.current})]}),n&&(0,g.jsx)(uM,{containerRef:L,onComment:ab}),(0,g.jsxs)("div",{className:"max-w-[var(--editor-max-w,48rem)] ml-[var(--editor-ml,auto)] mr-auto px-8 pb-8 flex items-center gap-4",children:[(0,g.jsxs)("button",{onClick:()=>{y(),x()},className:"group flex items-center gap-2 text-[13px] text-muted-foreground/50 hover:text-muted-foreground transition-colors cursor-pointer",children:[(0,g.jsx)(no,{className:"h-3.5 w-3.5 group-hover:text-primary transition-colors"}),(0,g.jsx)("span",{children:"Edit with AI"})]}),!n&&(0,g.jsxs)("span",{className:"text-[11px] text-muted-foreground/30 select-none",children:[(0,g.jsx)("kbd",{className:"rounded px-1 py-0.5 font-mono text-[10px] ring-1 ring-foreground/10",children:"/"})," ","for commands"]})]})]}),al&&(0,g.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 backdrop-blur-md z-20 pointer-events-none","aria-hidden":"true",children:(0,g.jsx)(m.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground/70"})})]}),!n&&(0,g.jsxs)("div",{className:"flex items-center justify-between px-4 py-1 border-t border-border text-xs text-muted-foreground/60",children:[(0,g.jsxs)("span",{className:"text-[10.5px] text-muted-foreground/30 select-none hidden sm:block",children:[(0,g.jsx)("kbd",{className:"rounded px-1 font-mono text-[9.5px] ring-1 ring-foreground/10",children:"⌘S"})," ","save",(0,g.jsx)("span",{className:"mx-1.5 opacity-40",children:"·"}),(0,g.jsx)("kbd",{className:"rounded px-1 font-mono text-[9.5px] ring-1 ring-foreground/10",children:"/"})," ","commands"]}),(0,g.jsxs)("div",{className:"flex items-center gap-3",children:[(0,g.jsxs)("div",{className:"flex items-center rounded-md border border-border overflow-hidden text-[10.5px]",role:"radiogroup","aria-label":"Edit mode",children:[(0,g.jsx)("button",{type:"button",role:"radio","aria-checked":"editing"===j,onClick:()=>k("editing"),className:`px-2 py-0.5 transition-colors ${"editing"===j?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"}`,children:"Editing"}),(0,g.jsx)("button",{type:"button",role:"radio","aria-checked":"suggesting"===j,onClick:()=>k("suggesting"),className:`px-2 py-0.5 transition-colors ${"suggesting"===j?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"}`,children:"Suggesting"})]}),(0,g.jsxs)("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10.5px] transition-all duration-300 ${"idle"===d?"opacity-0 pointer-events-none":"opacity-100"} ${"saving"===d?"bg-muted text-muted-foreground":"saved"===d?"bg-success/10 text-success":"error"===d?"bg-destructive/10 text-destructive":""}`,children:["saving"===d&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(m.Loader2,{className:"h-2.5 w-2.5 animate-spin"}),"Saving…"]}),"saved"===d&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(r.Check,{className:"h-2.5 w-2.5"}),"Saved"]}),"error"===d&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(q.AlertCircle,{className:"h-2.5 w-2.5"}),"Save failed"]})]})]})]})]}),A]})}function uP({path:a}){let b=(0,bB.withWs)(`/api/assets/${a}`),c=a.split("/").pop()||a,d=c.includes(".")?c.split(".").pop()?.toUpperCase():"",e=async()=>{try{await (0,bB.wsFetch)("/api/system/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})}catch{}};return(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsx)(ea,{path:a,badge:d||void 0}),(0,g.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,g.jsxs)("div",{className:"flex flex-col items-center gap-4 text-center max-w-sm",children:[(0,g.jsx)("div",{className:"flex size-16 items-center justify-center rounded-2xl bg-muted",children:(0,g.jsx)(cb,{className:"size-8 text-muted-foreground/50"})}),(0,g.jsxs)("div",{className:"space-y-1",children:[(0,g.jsx)("p",{className:"text-sm font-medium",children:c}),(0,g.jsx)("p",{className:"text-xs text-muted-foreground",children:"This file type can't be previewed in Cabinet."})]}),(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsxs)(v.Button,{variant:"outline",size:"sm",className:"gap-2",onClick:e,children:[(0,g.jsx)(a5,{className:"h-4 w-4"}),"Open in Finder"]}),(0,g.jsxs)(v.Button,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>{let a=document.createElement("a");a.href=b,a.download=c,a.click()},children:[(0,g.jsx)(b8.Download,{className:"h-4 w-4"}),"Download"]})]})]})})]})}let uQ=(0,h.default)("file-warning",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);function uR({path:a,size:b,onOpen:c}){let d=(0,bB.withWs)(`/api/assets/${a}`),e=a.split("/").pop()||a,f=e.includes(".")?e.split(".").pop()?.toUpperCase():"",h=async()=>{try{await (0,bB.wsFetch)("/api/system/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})}catch{}};return(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsx)(ea,{path:a,badge:f||void 0}),(0,g.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,g.jsxs)("div",{className:"flex flex-col items-center gap-4 text-center max-w-sm",children:[(0,g.jsx)("div",{className:"flex size-16 items-center justify-center rounded-2xl bg-amber-500/10",children:(0,g.jsx)(uQ,{className:"size-8 text-amber-500"})}),(0,g.jsxs)("div",{className:"space-y-1",children:[(0,g.jsx)("p",{className:"text-sm font-medium",children:e}),(0,g.jsxs)("p",{className:"text-xs text-muted-foreground",children:["This file is ",b>=0x40000000?`${(b/0x40000000).toFixed(1)} GB`:b>=1048576?`${(b/1048576).toFixed(1)} MB`:b>=1024?`${Math.round(b/1024)} KB`:`${b} B`,". Opening it in the viewer may freeze the tab while it loads and renders."]})]}),(0,g.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[(0,g.jsx)(v.Button,{variant:"default",size:"sm",className:"gap-2",onClick:c,children:"Open anyway"}),(0,g.jsxs)(v.Button,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>window.open(d,"_blank"),children:[(0,g.jsx)(bE,{className:"h-4 w-4"}),"Raw"]}),(0,g.jsxs)(v.Button,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>{let a=document.createElement("a");a.href=d,a.download=e,a.click()},children:[(0,g.jsx)(b8.Download,{className:"h-4 w-4"}),"Download"]}),(0,g.jsxs)(v.Button,{variant:"outline",size:"sm",className:"gap-2",onClick:h,children:[(0,g.jsx)(a5,{className:"h-4 w-4"}),"Open in Finder"]})]})]})})]})}function uS({path:a,title:b}){let c=(0,bB.withWs)(`/api/assets/${a}`),d=a.split("/").pop()||a,e=d.includes(".")?d.split(".").pop()?.toUpperCase():"IMG";return(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsxs)(ea,{path:a,badge:e,children:[(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let a=document.createElement("a");a.href=c,a.download=d,a.click()},children:[(0,g.jsx)(b8.Download,{className:"h-3.5 w-3.5"}),"Download"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(c,"_blank"),children:[(0,g.jsx)(bE,{className:"h-3.5 w-3.5"}),"Open in new tab"]})]}),(0,g.jsx)("div",{className:"flex-1 overflow-auto flex items-center justify-center bg-[#1a1a1a] p-8",children:(0,g.jsx)("img",{src:c,alt:b,className:"max-w-full max-h-full object-contain rounded-md shadow-lg",style:{imageRendering:"auto"}})})]})}function uT({path:a,type:b}){let c=(0,bB.withWs)(`/api/assets/${a}`),d=a.split("/").pop()||a,e=d.includes(".")?d.split(".").pop()?.toUpperCase():b.toUpperCase();return(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsxs)(ea,{path:a,badge:e,children:[(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let a=document.createElement("a");a.href=c,a.download=d,a.click()},children:[(0,g.jsx)(b8.Download,{className:"h-3.5 w-3.5"}),"Download"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(c,"_blank"),children:[(0,g.jsx)(bE,{className:"h-3.5 w-3.5"}),"Open in new tab"]})]}),(0,g.jsx)("div",{className:"flex-1 overflow-auto flex items-center justify-center bg-[#1a1a1a] p-8",children:"video"===b?(0,g.jsx)("video",{src:c,controls:!0,className:"max-w-full max-h-full rounded-md shadow-lg",children:"Your browser does not support the video element."}):(0,g.jsxs)("div",{className:"w-full max-w-lg space-y-4",children:[(0,g.jsx)("div",{className:"text-center text-muted-foreground text-sm",children:d}),(0,g.jsx)("audio",{src:c,controls:!0,className:"w-full",children:"Your browser does not support the audio element."})]})})]})}function uU({path:b,title:c}){let[d,e]=(0,p.useState)(""),[f,h]=(0,p.useState)(""),[i,j]=(0,p.useState)(""),[k,l]=(0,p.useState)(!0),[m,n]=(0,p.useState)(!1),[o,q]=(0,p.useState)(!1),s=(0,p.useRef)(0),t=(0,bB.withWs)(`/api/assets/${b}`);b.split("/").pop();let u=(0,p.useCallback)(async()=>{l(!0),j("");try{let b=await (0,bB.wsFetch)(t);if(!b.ok)throw Error("Failed to fetch file");let c=await b.text();e(c);let d=(await a.A(334743)).default;d.initialize({startOnLoad:!1,theme:document.documentElement.classList.contains("dark")?"dark":"default",securityLevel:"loose",suppressErrorRendering:!0}),await d.parse(c.trim());let f=`mermaid-${++s.current}`,{svg:g}=await d.render(f,c.trim());h(g)}catch(a){document.querySelectorAll('[id^="dmermaid-"], [id^="d"]:has(> .error-icon)').forEach(a=>a.remove()),j(a instanceof Error?a.message:"Failed to render diagram")}finally{l(!1)}},[t]);return(0,p.useEffect)(()=>{u()},[u]),(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsxs)(ea,{path:b,badge:"MERMAID",children:[(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:`h-7 gap-1.5 text-xs ${m?"bg-muted":""}`,onClick:()=>n(a=>!a),children:[m?(0,g.jsx)(dO.Eye,{className:"h-3.5 w-3.5"}):(0,g.jsx)(d1,{className:"h-3.5 w-3.5"}),m?"Diagram":"Code"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{navigator.clipboard.writeText(d),q(!0),setTimeout(()=>q(!1),2e3)},children:[o?(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,g.jsx)(bd.Copy,{className:"h-3.5 w-3.5"}),o?"Copied":"Copy"]}),f&&(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{if(!f)return;let a=new Blob([f],{type:"image/svg+xml"}),b=URL.createObjectURL(a),d=document.createElement("a");d.href=b,d.download=`${c}.svg`,d.click(),URL.revokeObjectURL(b)},children:[(0,g.jsx)(b8.Download,{className:"h-3.5 w-3.5"}),"SVG"]})]}),(0,g.jsx)("div",{className:"flex-1 overflow-auto",children:k?(0,g.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Rendering diagram..."}):m?(0,g.jsx)("pre",{className:"p-4 text-[13px] leading-relaxed font-mono bg-[#1e1e1e]",children:(0,g.jsx)("code",{children:d.split("\n").map((a,b)=>(0,g.jsxs)("div",{className:"flex",children:[(0,g.jsx)("span",{className:"inline-block w-12 pr-4 text-right text-[#858585] select-none shrink-0",children:b+1}),(0,g.jsx)("span",{className:"text-[#d4d4d4] flex-1",children:a||"\n"})]},b))})}):i?(0,g.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-sm p-8",children:[(0,g.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,g.jsx)("div",{className:"h-10 w-10 rounded-full bg-red-500/10 flex items-center justify-center",children:(0,g.jsx)(d1,{className:"h-5 w-5 text-red-500"})}),(0,g.jsx)("p",{className:"text-red-500 font-medium",children:"Diagram syntax error"})]}),(0,g.jsx)("pre",{className:"text-muted-foreground text-xs max-w-lg text-left bg-muted rounded-md p-3 overflow-auto whitespace-pre-wrap",children:i}),(0,g.jsx)(v.Button,{variant:"outline",size:"sm",onClick:()=>n(!0),children:"View source to fix"})]}):(0,g.jsx)(tb,{svg:f,className:"w-full h-full"})})]})}var uV=a.i(855814),uW="[0-9](_*[0-9])*",uX=`\\.(${uW})`,uY="[0-9a-fA-F](_*[0-9a-fA-F])*",uZ={className:"number",variants:[{begin:`(\\b(${uW})((${uX})|\\.)?|(${uX}))[eE][+-]?(${uW})[fFdD]?\\b`},{begin:`\\b(${uW})((${uX})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${uX})[fFdD]?\\b`},{begin:`\\b(${uW})[fFdD]\\b`},{begin:`\\b0[xX]((${uY})\\.?|(${uY})?\\.(${uY}))[pP][+-]?(${uW})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${uY})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0},u$="[0-9](_*[0-9])*",u_=`\\.(${u$})`,u0="[0-9a-fA-F](_*[0-9a-fA-F])*",u1={className:"number",variants:[{begin:`(\\b(${u$})((${u_})|\\.)?|(${u_}))[eE][+-]?(${u$})[fFdD]?\\b`},{begin:`\\b(${u$})((${u_})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${u_})[fFdD]?\\b`},{begin:`\\b(${u$})[fFdD]\\b`},{begin:`\\b0[xX]((${u0})\\.?|(${u0})?\\.(${u0}))[pP][+-]?(${u$})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${u0})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};let u2=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video","defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],u3=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),u4=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),u5=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),u6=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse(),u7=u4.concat(u5).sort().reverse(),u8=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video","defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],u9=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),va=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),vb=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),vc=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function vd(a){return a?"string"==typeof a?a:a.source:null}function ve(a){return vf("(?=",a,")")}function vf(...a){return a.map(a=>vd(a)).join("")}function vg(...a){let b;return"("+(("object"==typeof(b=a[a.length-1])&&b.constructor===Object?(a.splice(a.length-1,1),b):{}).capture?"":"?:")+a.map(a=>vd(a)).join("|")+")"}let vh=a=>vf(/\b/,a,/\w$/.test(a)?/\b/:/\B/),vi=["Protocol","Type"].map(vh),vj=["init","self"].map(vh),vk=["Any","Self"],vl=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],vm=["false","nil","true"],vn=["assignment","associativity","higherThan","left","lowerThan","none","right"],vo=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],vp=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],vq=vg(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),vr=vg(vq,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),vs=vf(vq,vr,"*"),vt=vg(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),vu=vg(vt,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),vv=vf(vt,vu,"*"),vw=vf(/[A-Z]/,vu,"*"),vx=["attached","autoclosure",vf(/convention\(/,vg("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",vf(/objc\(/,vv,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],vy=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"],vz={arduino:function(a){let b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r=(b=a.regex,c=a.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),e="[a-zA-Z_]\\w*::",f="(?!struct)("+(d="decltype\\(auto\\)")+"|"+b.optional(e)+"[a-zA-Z_]\\w*"+b.optional("<[^<>]+>")+")",g={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},h={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[a.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},a.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},i={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},j={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},a.inherit(h,{className:"string"}),{className:"string",begin:/<.*?>/},c,a.C_BLOCK_COMMENT_MODE]},k={className:"title",begin:b.optional(e)+a.IDENT_RE,relevance:0},l=b.optional(e)+a.IDENT_RE+"\\s*\\(",p={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:m={type:["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],keyword:["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"]},contains:(o=[n={className:"function.dispatch",relevance:0,keywords:{_hint:["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"]},begin:b.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,a.IDENT_RE,b.lookahead(/(<[^<>]+>|)\s*\(/))},j,g,c,a.C_BLOCK_COMMENT_MODE,i,h]).concat([{begin:/\(/,end:/\)/,keywords:m,contains:o.concat(["self"]),relevance:0}]),relevance:0},q={className:"function",begin:"("+f+"[\\*&\\s]+)+"+l,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:m,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:d,keywords:m,relevance:0},{begin:l,returnBegin:!0,contains:[k],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[h,i]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:[c,a.C_BLOCK_COMMENT_MODE,h,i,g,{begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:["self",c,a.C_BLOCK_COMMENT_MODE,h,i,g]}]},g,c,a.C_BLOCK_COMMENT_MODE,j]},{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:m,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(p,q,n,o,[j,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:m,contains:["self",g]},{begin:a.IDENT_RE+"::",keywords:m},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}),s=r.keywords;return s.type=[...s.type,"boolean","byte","word","String"],s.literal=[...s.literal,"DIGITAL_MESSAGE","FIRMATA_STRING","ANALOG_MESSAGE","REPORT_DIGITAL","REPORT_ANALOG","INPUT_PULLUP","SET_PIN_MODE","INTERNAL2V56","SYSTEM_RESET","LED_BUILTIN","INTERNAL1V1","SYSEX_START","INTERNAL","EXTERNAL","DEFAULT","OUTPUT","INPUT","HIGH","LOW"],s.built_in=[...s.built_in,"KeyboardController","MouseController","SoftwareSerial","EthernetServer","EthernetClient","LiquidCrystal","RobotControl","GSMVoiceCall","EthernetUDP","EsploraTFT","HttpClient","RobotMotor","WiFiClient","GSMScanner","FileSystem","Scheduler","GSMServer","YunClient","YunServer","IPAddress","GSMClient","GSMModem","Keyboard","Ethernet","Console","GSMBand","Esplora","Stepper","Process","WiFiUDP","GSM_SMS","Mailbox","USBHost","Firmata","PImage","Client","Server","GSMPIN","FileIO","Bridge","Serial","EEPROM","Stream","Mouse","Audio","Servo","File","Task","GPRS","WiFi","Wire","TFT","GSM","SPI","SD"],s._hints=["setup","loop","runShellCommandAsynchronously","analogWriteResolution","retrieveCallingNumber","printFirmwareVersion","analogReadResolution","sendDigitalPortPair","noListenOnLocalhost","readJoystickButton","setFirmwareVersion","readJoystickSwitch","scrollDisplayRight","getVoiceCallStatus","scrollDisplayLeft","writeMicroseconds","delayMicroseconds","beginTransmission","getSignalStrength","runAsynchronously","getAsynchronously","listenOnLocalhost","getCurrentCarrier","readAccelerometer","messageAvailable","sendDigitalPorts","lineFollowConfig","countryNameWrite","runShellCommand","readStringUntil","rewindDirectory","readTemperature","setClockDivider","readLightSensor","endTransmission","analogReference","detachInterrupt","countryNameRead","attachInterrupt","encryptionType","readBytesUntil","robotNameWrite","readMicrophone","robotNameRead","cityNameWrite","userNameWrite","readJoystickY","readJoystickX","mouseReleased","openNextFile","scanNetworks","noInterrupts","digitalWrite","beginSpeaker","mousePressed","isActionDone","mouseDragged","displayLogos","noAutoscroll","addParameter","remoteNumber","getModifiers","keyboardRead","userNameRead","waitContinue","processInput","parseCommand","printVersion","readNetworks","writeMessage","blinkVersion","cityNameRead","readMessage","setDataMode","parsePacket","isListening","setBitOrder","beginPacket","isDirectory","motorsWrite","drawCompass","digitalRead","clearScreen","serialEvent","rightToLeft","setTextSize","leftToRight","requestFrom","keyReleased","compassRead","analogWrite","interrupts","WiFiServer","disconnect","playMelody","parseFloat","autoscroll","getPINUsed","setPINUsed","setTimeout","sendAnalog","readSlider","analogRead","beginWrite","createChar","motorsStop","keyPressed","tempoWrite","readButton","subnetMask","debugPrint","macAddress","writeGreen","randomSeed","attachGPRS","readString","sendString","remotePort","releaseAll","mouseMoved","background","getXChange","getYChange","answerCall","getResult","voiceCall","endPacket","constrain","getSocket","writeJSON","getButton","available","connected","findUntil","readBytes","exitValue","readGreen","writeBlue","startLoop","IPAddress","isPressed","sendSysex","pauseMode","gatewayIP","setCursor","getOemKey","tuneWrite","noDisplay","loadImage","switchPIN","onRequest","onReceive","changePIN","playFile","noBuffer","parseInt","overflow","checkPIN","knobRead","beginTFT","bitClear","updateIR","bitWrite","position","writeRGB","highByte","writeRed","setSpeed","readBlue","noStroke","remoteIP","transfer","shutdown","hangCall","beginSMS","endWrite","attached","maintain","noCursor","checkReg","checkPUK","shiftOut","isValid","shiftIn","pulseIn","connect","println","localIP","pinMode","getIMEI","display","noBlink","process","getBand","running","beginSD","drawBMP","lowByte","setBand","release","bitRead","prepare","pointTo","readRed","setMode","noFill","remove","listen","stroke","detach","attach","noTone","exists","buffer","height","bitSet","circle","config","cursor","random","IRread","setDNS","endSMS","getKey","micros","millis","begin","print","write","ready","flush","width","isPIN","blink","clear","press","mkdir","rmdir","close","point","yield","image","BSSID","click","delay","read","text","move","peek","beep","rect","line","open","seek","fill","size","turn","stop","home","find","step","tone","sqrt","RSSI","SSID","end","bit","tan","cos","sin","pow","map","abs","max","min","get","run","put"],r.name="Arduino",r.aliases=["ino"],r.supersetOf="cpp",r},bash:sk,c:function(a){let b=a.regex,c=a.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),d="decltype\\(auto\\)",e="[a-zA-Z_]\\w*::",f="("+d+"|"+b.optional(e)+"[a-zA-Z_]\\w*"+b.optional("<[^<>]+>")+")",g={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},h={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[a.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},a.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},i={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},j={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},a.inherit(h,{className:"string"}),{className:"string",begin:/<.*?>/},c,a.C_BLOCK_COMMENT_MODE]},k={className:"title",begin:b.optional(e)+a.IDENT_RE,relevance:0},l=b.optional(e)+a.IDENT_RE+"\\s*\\(",m={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},n=[j,g,c,a.C_BLOCK_COMMENT_MODE,i,h],o={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:m,contains:n.concat([{begin:/\(/,end:/\)/,keywords:m,contains:n.concat(["self"]),relevance:0}]),relevance:0},p={begin:"("+f+"[\\*&\\s]+)+"+l,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:m,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:d,keywords:m,relevance:0},{begin:l,returnBegin:!0,contains:[a.inherit(k,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:[c,a.C_BLOCK_COMMENT_MODE,h,i,g,{begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:["self",c,a.C_BLOCK_COMMENT_MODE,h,i,g]}]},g,c,a.C_BLOCK_COMMENT_MODE,j]};return{name:"C",aliases:["h"],keywords:m,disableAutodetect:!0,illegal:"</",contains:[].concat(o,p,n,[j,{begin:a.IDENT_RE+"::",keywords:m},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},a.TITLE_MODE]}]),exports:{preprocessor:j,strings:h,keywords:m}}},cpp:function(a){let b=a.regex,c=a.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),d="decltype\\(auto\\)",e="[a-zA-Z_]\\w*::",f="(?!struct)("+d+"|"+b.optional(e)+"[a-zA-Z_]\\w*"+b.optional("<[^<>]+>")+")",g={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},h={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[a.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},a.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},i={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},j={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},a.inherit(h,{className:"string"}),{className:"string",begin:/<.*?>/},c,a.C_BLOCK_COMMENT_MODE]},k={className:"title",begin:b.optional(e)+a.IDENT_RE,relevance:0},l=b.optional(e)+a.IDENT_RE+"\\s*\\(",m={type:["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],keyword:["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"]},n={className:"function.dispatch",relevance:0,keywords:{_hint:["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"]},begin:b.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,a.IDENT_RE,b.lookahead(/(<[^<>]+>|)\s*\(/))},o=[n,j,g,c,a.C_BLOCK_COMMENT_MODE,i,h],p={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:m,contains:o.concat([{begin:/\(/,end:/\)/,keywords:m,contains:o.concat(["self"]),relevance:0}]),relevance:0},q={className:"function",begin:"("+f+"[\\*&\\s]+)+"+l,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:m,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:d,keywords:m,relevance:0},{begin:l,returnBegin:!0,contains:[k],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[h,i]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:[c,a.C_BLOCK_COMMENT_MODE,h,i,g,{begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:["self",c,a.C_BLOCK_COMMENT_MODE,h,i,g]}]},g,c,a.C_BLOCK_COMMENT_MODE,j]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:m,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(p,q,n,o,[j,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:m,contains:["self",g]},{begin:a.IDENT_RE+"::",keywords:m},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}},csharp:function(a){let b={keyword:["abstract","as","base","break","case","catch","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","scoped","sealed","sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"].concat(["add","alias","and","ascending","args","async","await","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value|0","var","when","where","with","yield"]),built_in:["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],literal:["default","false","null","true"]},c=a.inherit(a.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),d={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},e={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},f=a.inherit(e,{illegal:/\n/}),g={className:"subst",begin:/\{/,end:/\}/,keywords:b},h=a.inherit(g,{illegal:/\n/}),i={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},a.BACKSLASH_ESCAPE,h]},j={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},g]},k=a.inherit(j,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},h]});g.contains=[j,i,e,a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,d,a.C_BLOCK_COMMENT_MODE],h.contains=[k,i,f,a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,d,a.inherit(a.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];let l={variants:[{className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},j,i,e,a.APOS_STRING_MODE,a.QUOTE_STRING_MODE]},m={begin:"<",end:">",contains:[{beginKeywords:"in out"},c]},n=a.IDENT_RE+"(<"+a.IDENT_RE+"(\\s*,\\s*"+a.IDENT_RE+")*>)?(\\[\\])?",o={begin:"@"+a.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:b,illegal:/::/,contains:[a.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:"<!--|-->"},{begin:"</?",end:">"}]}]}),a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},l,d,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},c,m,a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[c,a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[c,m,a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+n+"\\s+)+"+a.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:b,contains:[{beginKeywords:"public private protected static internal protected abstract async extern override unsafe virtual new sealed partial",relevance:0},{begin:a.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[a.TITLE_MODE,m],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:b,relevance:0,contains:[l,d,a.C_BLOCK_COMMENT_MODE]},a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE]},o]}},css:sq,diff:function(a){let b=a.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:b.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:b.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}},go:sr,graphql:function(a){let b=a.regex;return{name:"GraphQL",aliases:["gql"],case_insensitive:!0,disableAutodetect:!1,keywords:{keyword:["query","mutation","subscription","type","input","schema","directive","interface","union","scalar","fragment","enum","on"],literal:["true","false","null"]},contains:[a.HASH_COMMENT_MODE,a.QUOTE_STRING_MODE,a.NUMBER_MODE,{scope:"punctuation",match:/[.]{3}/,relevance:0},{scope:"punctuation",begin:/[\!\(\)\:\=\[\]\{\|\}]{1}/,relevance:0},{scope:"variable",begin:/\$/,end:/\W/,excludeEnd:!0,relevance:0},{scope:"meta",match:/@\w+/,excludeEnd:!0},{scope:"symbol",begin:b.concat(/[_A-Za-z][_0-9A-Za-z]*/,b.lookahead(/\s*:/)),relevance:0}],illegal:[/[;<']/,/BEGIN/]}},ini:function(a){let b=a.regex,c={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:a.NUMBER_RE}]},d=a.COMMENT();d.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];let e={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},f={className:"literal",begin:/\bon|off|true|false|yes|no\b/},g={className:"string",contains:[a.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},h=b.either(/[A-Za-z0-9_-]+/,/"(\\"|[^"])*"/,/'[^']*'/);return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[d,{className:"section",begin:/\[+/,end:/\]+/},{begin:b.concat(h,"(\\s*\\.\\s*",h,")*",b.lookahead(/\s*=\s*[^#\s]/)),className:"attr",starts:{end:/$/,contains:[d,{begin:/\[/,end:/\]/,contains:[d,f,e,g,c,"self"],relevance:0},f,e,g,c]}}]}},java:function(a){let b=a.regex,c="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",d=c+function a(b,c,d){return -1===d?"":b.replace(c,e=>a(b,c,d-1))}("(?:<"+c+"~~~(?:\\s*,\\s*"+c+"~~~)*>)?",/~~~/g,2),e={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},f={className:"meta",begin:"@"+c,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},g={className:"params",begin:/\(/,end:/\)/,keywords:e,relevance:0,contains:[a.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:e,illegal:/<\/|#/,contains:[a.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[a.BACKSLASH_ESCAPE]},a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,c],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[b.concat(/(?!else)/,c),/\s+/,c,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,c],className:{1:"keyword",3:"title.class"},contains:[g,a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+d+"\\s+)",a.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:e,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:e,relevance:0,contains:[f,a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,uZ,a.C_BLOCK_COMMENT_MODE]},a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE]},uZ,f]}},javascript:sA,json:sB,kotlin:function(a){let b={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},c={className:"symbol",begin:a.UNDERSCORE_IDENT_RE+"@"},d={className:"subst",begin:/\$\{/,end:/\}/,contains:[a.C_NUMBER_MODE]},e={className:"variable",begin:"\\$"+a.UNDERSCORE_IDENT_RE},f={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[e,d]},{begin:"'",end:"'",illegal:/\n/,contains:[a.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[a.BACKSLASH_ESCAPE,e,d]}]};d.contains.push(f);let g={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+a.UNDERSCORE_IDENT_RE+")?"},h={className:"meta",begin:"@"+a.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[a.inherit(f,{className:"string"}),"self"]}]},i=a.COMMENT("/\\*","\\*/",{contains:[a.C_BLOCK_COMMENT_MODE]}),j={variants:[{className:"type",begin:a.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]};return j.variants[1].contains=[j],j.variants[1].contains=[j],{name:"Kotlin",aliases:["kt","kts"],keywords:b,contains:[a.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),a.C_LINE_COMMENT_MODE,i,{className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},c,g,h,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:b,relevance:5,contains:[{begin:a.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[a.UNDERSCORE_TITLE_MODE]},{className:"type",begin:/</,end:/>/,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:b,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[j,a.C_LINE_COMMENT_MODE,i],relevance:0},a.C_LINE_COMMENT_MODE,i,g,h,f,a.C_NUMBER_MODE]},i]},{begin:[/class|interface|trait/,/\s+/,a.UNDERSCORE_IDENT_RE],beginScope:{3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},a.UNDERSCORE_TITLE_MODE,{className:"type",begin:/</,end:/>/,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},g,h]},f,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:"\n"},u1]}},less:function(a){let b={IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:a.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[a.APOS_STRING_MODE,a.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:a.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}},c="[\\w-]+",d="("+c+"|@\\{"+c+"\\})",e=[],f=[],g=function(a){return{className:"string",begin:"~?"+a+".*?"+a}},h=function(a,b,c){return{className:a,begin:b,relevance:c}},i={$pattern:/[a-z-]+/,keyword:"and or not only",attribute:u3.join(" ")};f.push(a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,g("'"),g('"'),b.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},b.HEXCOLOR,{begin:"\\(",end:"\\)",contains:f,keywords:i,relevance:0},h("variable","@@?"+c,10),h("variable","@\\{"+c+"\\}"),h("built_in","~?`[^`]*?`"),{className:"attribute",begin:c+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},b.IMPORTANT,{beginKeywords:"and not"},b.FUNCTION_DISPATCH);let j=f.concat({begin:/\{/,end:/\}/,contains:e}),k={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(f)},l={begin:d+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},b.CSS_VARIABLE,{className:"attribute",begin:"\\b("+u6.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:f}}]},m={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:d,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:"[<='$\"]",relevance:0,contains:[a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,k,h("keyword","all\\b"),h("variable","@\\{"+c+"\\}"),{begin:"\\b("+u2.join("|")+")\\b",className:"selector-tag"},b.CSS_NUMBER_MODE,h("selector-tag",d,0),h("selector-id","#"+d),h("selector-class","\\."+d,0),h("selector-tag","&",0),b.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+u4.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+u5.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:j},{begin:"!important"},b.FUNCTION_DISPATCH]},n={begin:c+":(:)?"+`(${u7.join("|")})`,returnBegin:!0,contains:[m]};return e.push(a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,{className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:i,returnEnd:!0,contains:f,relevance:0}},{className:"variable",variants:[{begin:"@"+c+"\\s*:",relevance:15},{begin:"@"+c}],starts:{end:"[;}]",returnEnd:!0,contains:j}},n,l,m,k,b.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:"[=>'/<($\"]",contains:e}},lua:function(a){let b="\\[=*\\[",c="\\]=*\\]",d={begin:b,end:c,contains:["self"]},e=[a.COMMENT("--(?!"+b+")","$"),a.COMMENT("--"+b,c,{contains:[d],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:a.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:e.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[a.inherit(a.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:e}].concat(e)},a.C_NUMBER_MODE,a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,{className:"string",begin:b,end:c,contains:[d],relevance:5}])}},makefile:function(a){let b={className:"variable",variants:[{begin:"\\$\\("+a.UNDERSCORE_IDENT_RE+"\\)",contains:[a.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},c={className:"string",begin:/"/,end:/"/,contains:[a.BACKSLASH_ESCAPE,b]},d={begin:"^"+a.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"};return{name:"Makefile",aliases:["mk","mak","make"],keywords:{$pattern:/[\w-]+/,keyword:"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath"},contains:[a.HASH_COMMENT_MODE,b,c,{className:"variable",begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value"},contains:[b,c]},d,{className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},{className:"section",begin:/^[^\s]+:/,end:/$/,contains:[b]}]}},markdown:sC,objectivec:function(a){let b=/[a-zA-Z@][a-zA-Z0-9_]*/,c={$pattern:b,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:{"variable.language":["this","super"],$pattern:b,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},illegal:"</",contains:[{className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,a.C_NUMBER_MODE,a.QUOTE_STRING_MODE,a.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[a.BACKSLASH_ESCAPE]}]},{className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},a.inherit(a.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+c.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:c,contains:[a.UNDERSCORE_TITLE_MODE]},{begin:"\\."+a.UNDERSCORE_IDENT_RE,relevance:0}]}},perl:function(a){let b=a.regex,c=/[dualxmsipngr]{0,12}/,d={$pattern:/[\w.]+/,keyword:"abs accept alarm and atan2 bind binmode bless break caller chdir chmod chomp chop chown chr chroot class close closedir connect continue cos crypt dbmclose dbmopen defined delete die do dump each else elsif endgrent endhostent endnetent endprotoent endpwent endservent eof eval exec exists exit exp fcntl field fileno flock for foreach fork format formline getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr getnetbyname getnetent getpeername getpgrp getpriority getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport getservent getsockname getsockopt given glob gmtime goto grep gt hex if index int ioctl join keys kill last lc lcfirst length link listen local localtime log lstat lt ma map method mkdir msgctl msgget msgrcv msgsnd my ne next no not oct open opendir or ord our pack package pipe pop pos print printf prototype push q|0 qq quotemeta qw qx rand read readdir readline readlink readpipe recv redo ref rename require reset return reverse rewinddir rindex rmdir say scalar seek seekdir select semctl semget semop send setgrent sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split sprintf sqrt srand stat state study sub substr symlink syscall sysopen sysread sysseek system syswrite tell telldir tie tied time times tr truncate uc ucfirst umask undef unless unlink unpack unshift untie until use utime values vec wait waitpid wantarray warn when while write x|0 xor y|0"},e={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:d},f={begin:/->\{/,end:/\}/},g={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},h={scope:"variable",variants:[{begin:/\$\d/},{begin:b.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[g]},i={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},j=[a.BACKSLASH_ESCAPE,e,h],k=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],l=(a,d,e="\\1")=>{let f="\\1"===e?e:b.concat(e,d);return b.concat(b.concat("(?:",a,")"),d,/(?:\\.|[^\\\/])*?/,f,/(?:\\.|[^\\\/])*?/,e,c)},m=(a,d,e)=>b.concat(b.concat("(?:",a,")"),d,/(?:\\.|[^\\\/])*?/,e,c),n=[h,a.HASH_COMMENT_MODE,a.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),f,{className:"string",contains:j,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[a.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[a.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},i,{begin:"(\\/\\/|"+a.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[a.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:l("s|tr|y",b.either(...k,{capture:!0}))},{begin:l("s|tr|y","\\(","\\)")},{begin:l("s|tr|y","\\[","\\]")},{begin:l("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:m("(?:m|qr)?",/\//,/\//)},{begin:m("m|qr",b.either(...k,{capture:!0}),/\1/)},{begin:m("m|qr",/\(/,/\)/)},{begin:m("m|qr",/\[/,/\]/)},{begin:m("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[a.TITLE_MODE,g]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[a.TITLE_MODE,g,i]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return e.contains=n,f.contains=n,{name:"Perl",aliases:["pl","pm"],keywords:d,contains:n}},php:function(a){let b,c=a.regex,d=/(?![A-Za-z0-9])(?![$])/,e=c.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,d),f=c.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,d),g=c.concat(/[A-Z]+/,d),h={scope:"variable",match:"\\$+"+e},i={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},j=a.inherit(a.APOS_STRING_MODE,{illegal:null}),k=a.inherit(a.QUOTE_STRING_MODE,{illegal:null,contains:a.QUOTE_STRING_MODE.contains.concat(i)}),l={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:a.QUOTE_STRING_MODE.contains.concat(i),"on:begin":(a,b)=>{b.data._beginMatch=a[1]||a[2]},"on:end":(a,b)=>{b.data._beginMatch!==a[1]&&b.ignoreMatch()}},m=a.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),n="[ \n]",o={scope:"string",variants:[k,j,l,m]},p={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},q=["false","null","true"],r=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],s=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],t={keyword:r,literal:(b=[],q.forEach(a=>{b.push(a),a.toLowerCase()===a?b.push(a.toUpperCase()):b.push(a.toLowerCase())}),b),built_in:s},u=a=>a.map(a=>a.replace(/\|\d+$/,"")),v={variants:[{match:[/new/,c.concat(n,"+"),c.concat("(?!",u(s).join("\\b|"),"\\b)"),f],scope:{1:"keyword",4:"title.class"}}]},w=c.concat(e,"\\b(?!\\()"),x={variants:[{match:[c.concat(/::/,c.lookahead(/(?!class\b)/)),w],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[f,c.concat(/::/,c.lookahead(/(?!class\b)/)),w],scope:{1:"title.class",3:"variable.constant"}},{match:[f,c.concat("::",c.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[f,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},y={scope:"attr",match:c.concat(e,c.lookahead(":"),c.lookahead(/(?!::)/))},z={relevance:0,begin:/\(/,end:/\)/,keywords:t,contains:[y,h,x,a.C_BLOCK_COMMENT_MODE,o,p,v]},A={relevance:0,match:[/\b/,c.concat("(?!fn\\b|function\\b|",u(r).join("\\b|"),"|",u(s).join("\\b|"),"\\b)"),e,c.concat(n,"*"),c.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[z]};z.contains.push(A);let B=[y,x,a.C_BLOCK_COMMENT_MODE,o,p,v],C={begin:c.concat(/#\[\s*\\?/,c.either(f,g)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:q,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:q,keyword:["new","array"]},contains:["self",...B]},...B,{scope:"meta",variants:[{match:f},{match:g}]}]};return{case_insensitive:!1,keywords:t,contains:[C,a.HASH_COMMENT_MODE,a.COMMENT("//","$"),a.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:a.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},{scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},{scope:"variable.language",match:/\$this\b/},h,A,x,{match:[/const/,/\s/,e],scope:{1:"keyword",3:"variable.constant"}},v,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},a.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:t,contains:["self",C,h,x,a.C_BLOCK_COMMENT_MODE,o,p]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},a.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[a.inherit(a.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},a.UNDERSCORE_TITLE_MODE]},o,p]}},"php-template":function(a){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},a.inherit(a.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),a.inherit(a.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}},plaintext:function(a){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}},python:sD,"python-repl":function(a){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}},r:function(a){let b=a.regex,c=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,d=b.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),e=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,f=b.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:c,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[a.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:b.lookahead(b.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:c},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),a.HASH_COMMENT_MODE,{scope:"string",contains:[a.BACKSLASH_ESCAPE],variants:[a.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),a.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),a.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),a.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),a.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),a.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[e,d]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,d]},{scope:{1:"punctuation",2:"number"},match:[f,d]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,d]}]},{scope:{3:"operator"},match:[c,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:e},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:f},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}},ruby:function(a){let b=a.regex,c="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",d=b.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),e=b.concat(d,/(::\w+)*/),f={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield","include","extend","prepend","public","private","protected","raise","throw"],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},g={className:"doctag",begin:"@[A-Za-z]+"},h={begin:"#<",end:">"},i=[a.COMMENT("#","$",{contains:[g]}),a.COMMENT("^=begin","^=end",{contains:[g],relevance:10}),a.COMMENT("^__END__",a.MATCH_NOTHING_RE)],j={className:"subst",begin:/#\{/,end:/\}/,keywords:f},k={className:"string",contains:[a.BACKSLASH_ESCAPE,j],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:b.concat(/<<[-~]?'?/,b.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[a.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[a.BACKSLASH_ESCAPE,j]})]}]},l="[0-9](_?[0-9])*",m={className:"number",relevance:0,variants:[{begin:`\\b([1-9](_?[0-9])*|0)(\\.(${l}))?([eE][+-]?(${l})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},n={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:f}]},o=[k,{variants:[{match:[/class\s+/,e,/\s+<\s+/,e]},{match:[/\b(class|module)\s+/,e]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:f},{match:[/(include|extend)\s+/,e],scope:{2:"title.class"},keywords:f},{relevance:0,match:[e,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:d,scope:"title.class"},{match:[/def/,/\s+/,c],scope:{1:"keyword",3:"title.function"},contains:[n]},{begin:a.IDENT_RE+"::"},{className:"symbol",begin:a.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[k,{begin:c}],relevance:0},m,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:f},{begin:"("+a.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[a.BACKSLASH_ESCAPE,j],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(h,i),relevance:0}].concat(h,i);j.contains=o,n.contains=o;let p=[{begin:/^\s*=>/,starts:{end:"$",contains:o}},{className:"meta.prompt",begin:"^([>?]>|[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]|(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>)(?=[ ])",starts:{end:"$",keywords:f,contains:o}}];return i.unshift(h),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:f,illegal:/\/\*/,contains:[a.SHEBANG({binary:"ruby"})].concat(p).concat(i).concat(o)}},rust:sE,scss:function(a){let b={IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:a.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[a.APOS_STRING_MODE,a.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:a.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}},c="@[a-z-]+",d={className:"variable",begin:"(\\$[a-zA-Z-][a-zA-Z0-9_-]*)\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,b.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},b.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+u8.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+va.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+vb.join("|")+")"},d,{begin:/\(/,end:/\)/,contains:[b.CSS_NUMBER_MODE]},b.CSS_VARIABLE,{className:"attribute",begin:"\\b("+vc.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[b.BLOCK_COMMENT,d,b.HEXCOLOR,b.CSS_NUMBER_MODE,a.QUOTE_STRING_MODE,a.APOS_STRING_MODE,b.IMPORTANT,b.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:c,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:"and or not only",attribute:u9.join(" ")},contains:[{begin:c,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},d,a.QUOTE_STRING_MODE,a.APOS_STRING_MODE,b.HEXCOLOR,b.CSS_NUMBER_MODE]},b.FUNCTION_DISPATCH]}},shell:sF,sql:sG,swift:function(a){let b={match:/\s+/,relevance:0},c=a.COMMENT("/\\*","\\*/",{contains:["self"]}),d=[a.C_LINE_COMMENT_MODE,c],e={match:[/\./,vg(...vi,...vj)],className:{2:"keyword"}},f={match:vf(/\./,vg(...vl)),relevance:0},g=vl.filter(a=>"string"==typeof a).concat(["_|0"]),h={variants:[{className:"keyword",match:vg(...vl.filter(a=>"string"!=typeof a).concat(vk).map(vh),...vj)}]},i={$pattern:vg(/\b\w+/,/#\w+/),keyword:g.concat(vo),literal:vm},j=[e,f,h],k=[{match:vf(/\./,vg(...vp)),relevance:0},{className:"built_in",match:vf(/\b/,vg(...vp),/(?=\()/)}],l={match:/->/,relevance:0},m=[l,{className:"operator",relevance:0,variants:[{match:vs},{match:`\\.(\\.|${vr})+`}]}],n="([0-9]_*)+",o="([0-9a-fA-F]_*)+",p={className:"number",relevance:0,variants:[{match:`\\b(${n})(\\.(${n}))?([eE][+-]?(${n}))?\\b`},{match:`\\b0x(${o})(\\.(${o}))?([pP][+-]?(${n}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},q=(a="")=>({className:"subst",variants:[{match:vf(/\\/,a,/[0\\tnr"']/)},{match:vf(/\\/,a,/u\{[0-9a-fA-F]{1,8}\}/)}]}),r=(a="")=>({className:"subst",label:"interpol",begin:vf(/\\/,a,/\(/),end:/\)/}),s=(a="")=>({begin:vf(a,/"""/),end:vf(/"""/,a),contains:[q(a),((a="")=>({className:"subst",match:vf(/\\/,a,/[\t ]*(?:[\r\n]|\r\n)/)}))(a),r(a)]}),t=(a="")=>({begin:vf(a,/"/),end:vf(/"/,a),contains:[q(a),r(a)]}),u={className:"string",variants:[s(),s("#"),s("##"),s("###"),t(),t("#"),t("##"),t("###")]},v=[a.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[a.BACKSLASH_ESCAPE]}],w=a=>{let b=vf(a,/\//),c=vf(/\//,a);return{begin:b,end:c,contains:[...v,{scope:"comment",begin:`#(?!.*${c})`,end:/$/}]}},x={scope:"regexp",variants:[w("###"),w("##"),w("#"),{begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:v}]},y={match:vf(/`/,vv,/`/)},z=[y,{className:"variable",match:/\$\d+/},{className:"variable",match:`\\$${vu}+`}],A=[{match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:vy,contains:[...m,p,u]}]}},{scope:"keyword",match:vf(/@/,vg(...vx),ve(vg(/\(/,/\s+/)))},{scope:"meta",match:vf(/@/,vv)}],B={match:ve(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:vf(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,vu,"+")},{className:"type",match:vw,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:vf(/\s+&\s+/,ve(vw)),relevance:0}]},C={begin:/</,end:/>/,keywords:i,contains:[...d,...j,...A,l,B]};B.contains.push(C);let D={begin:/\(/,end:/\)/,relevance:0,keywords:i,contains:["self",{match:vf(vv,/\s*:/),keywords:"_|0",relevance:0},...d,x,...j,...k,...m,p,u,...z,...A,B]},E={begin:/</,end:/>/,keywords:"repeat each",contains:[...d,B]},F={begin:/\(/,end:/\)/,keywords:i,contains:[{begin:vg(ve(vf(vv,/\s*:/)),ve(vf(vv,/\s+/,vv,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:vv}]},...d,...j,...m,p,u,...A,B,D],endsParent:!0,illegal:/["']/},G={match:[/(func|macro)/,/\s+/,vg(y.match,vv,vs)],className:{1:"keyword",3:"title.function"},contains:[E,F,b],illegal:[/\[/,/%/]},H={begin:[/precedencegroup/,/\s+/,vw],className:{1:"keyword",3:"title"},contains:[B],keywords:[...vn,...vm],end:/}/},I={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,vv,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:i,contains:[E,...j,{begin:/:/,end:/\{/,keywords:i,contains:[{scope:"title.class.inherited",match:vw},...j],relevance:0}]};for(let a of u.variants){let b=a.contains.find(a=>"interpol"===a.label);b.keywords=i;let c=[...j,...k,...m,p,u,...z];b.contains=[...c,{begin:/\(/,end:/\)/,contains:["self",...c]}]}return{name:"Swift",keywords:i,contains:[...d,G,{match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[E,F,b],illegal:/\[|%/},{match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},{match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},I,{match:[/operator/,/\s+/,vs],className:{1:"keyword",3:"title"}},H,{beginKeywords:"import",end:/$/,contains:[...d],relevance:0},x,...j,...k,...m,p,u,...z,...A,B,D]}},typescript:sP,vbnet:function(a){let b=a.regex,c=/\d{1,2}\/\d{1,2}\/\d{4}/,d=/\d{4}-\d{1,2}-\d{1,2}/,e=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,f=/\d{1,2}(:\d{1,2}){1,2}/,g={className:"literal",variants:[{begin:b.concat(/# */,b.either(d,c),/ *#/)},{begin:b.concat(/# */,f,/ *#/)},{begin:b.concat(/# */,e,/ *#/)},{begin:b.concat(/# */,b.either(d,c),/ +/,b.either(e,f),/ *#/)}]},h=a.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),i=a.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[{className:"string",begin:/"(""|[^/n])"C\b/},{className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},g,{className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},{className:"label",begin:/^\w+:/},h,i,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[i]}]}},wasm:function(a){a.regex;let b=a.COMMENT(/\(;/,/;\)/);return b.contains.push("self"),{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"]},contains:[a.COMMENT(/;;/,/$/),b,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},{className:"variable",begin:/\$[\w_]+/},{match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},{begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},a.QUOTE_STRING_MODE,{match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},{className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/},{className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/}]}},xml:sQ,yaml:sR},vA=sV(vz);function vB(a){return Array.isArray(a)?a.join(""):a??""}let vC=/\x1b\[[0-9;]*[A-Za-z]/g;function vD(a){return a.replace(vC,"")}function vE({output:a}){if("stream"===a.output_type){let b=vD(vB(a.text)),c="stderr"===a.name;return(0,g.jsx)("pre",{className:`whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md ${c?"bg-[rgba(139,46,62,0.06)] text-[#8B2E3E]":"bg-[#F5EEDC] text-[#2A221B]"}`,children:b})}if("error"===a.output_type){let b=a.traceback.map(vD).join("\n");return(0,g.jsxs)("pre",{className:"whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md bg-[rgba(139,46,62,0.08)] text-[#8B2E3E] border border-[rgba(139,46,62,0.18)]",children:[(0,g.jsxs)("span",{className:"font-semibold",children:[a.ename,": ",a.evalue]}),b?`
168
+ `;function uj({scrollContainerRef:a}){return(0,p.useEffect)(()=>{let b=a.current;if(!b)return;let c=new Set,d=new WeakMap,e=a=>{a.classList.remove("exp-anchor-flash");let b=d.get(a);b&&(a.removeEventListener("animationend",b),d.delete(a)),c.delete(a)},f=a=>{let b=d.get(a);b&&(a.removeEventListener("animationend",b),d.delete(a)),a.classList.remove("exp-anchor-flash"),a.offsetWidth,a.classList.add("exp-anchor-flash"),c.add(a);let f=()=>e(a);d.set(a,f),a.addEventListener("animationend",f,{once:!0})},g=()=>{let a=window.location.hash.slice(1);if(a){let c=(a=>{let c=a;try{c=decodeURIComponent(a)}catch{}for(let a of b.querySelectorAll("h1, h2, h3, h4, h5, h6"))if(a.id===c)return a;let d=document.getElementById(c);return d&&b.contains(d)?d:null})(a);c&&f(c)}},h=a=>{a instanceof CustomEvent&&a.detail?.element instanceof HTMLElement&&f(a.detail.element)};return window.addEventListener("hashchange",g),document.addEventListener("anchor-navigation",h),()=>{for(let a of(window.removeEventListener("hashchange",g),document.removeEventListener("anchor-navigation",h),c))e(a)}},[a]),(0,g.jsx)("style",{children:ui})}function uk(a,b){try{let{node:c}=a.view.domAtPos(b+1);if(c.nodeType===Node.ELEMENT_NODE)return c.closest("h1,h2,h3,h4,h5,h6")??c;return c.parentElement?.closest("h1,h2,h3,h4,h5,h6")??null}catch{return null}}function ul(a){let b=a?.querySelector(".tiptap");if(b)for(let a of Array.from(b.children))a.style.display=""}function um({editor:a,scrollContainerRef:b}){let c=b_(a=>a.currentPath),[d,e]=(0,p.useState)(!1),[f,h]=(0,p.useState)(new Set),[i,j]=(0,p.useState)(null),[k,l]=(0,p.useState)([]),m=c?`wiki-collapsed:${c}`:"wiki-collapsed:shared",n=b.current;return((0,p.useEffect)(()=>{e(!0)},[]),(0,p.useEffect)(()=>{},[m]),(0,p.useEffect)(()=>{},[f,i,m]),(0,p.useEffect)(()=>{if(!a||!d||!n||i!==m){ul(n??null),l([]);return}let b=null,c=0,e=null,g=()=>{let b,c,d,e,g,h,i=(b=[],c=new Map,d=n.getBoundingClientRect(),e=n.querySelector(".tiptap"),h=(g=e?.getBoundingClientRect())?g.right-d.left+n.scrollLeft:d.width,a.state.doc.forEach((e,f)=>{if("heading"!==e.type.name)return;let g=e.textContent,i=e.attrs.level,j=g.toLowerCase().replace(/\s+/g,"-").replace(/[^\w-]/g,"")||"heading",k=(c.get(j)??0)+1;c.set(j,k);let l=1===k?j:`${j}-${k}`,m=uk(a,f);if(!(m instanceof HTMLElement))return;let o=m.offsetTop+m.offsetHeight/2,p=m.offsetLeft;try{let a=document.createRange();a.selectNodeContents(m);let b=a.getBoundingClientRect(),c=m.getBoundingClientRect(),e=0===b.width&&0===b.height?c:b;o=e.top-d.top+n.scrollTop+.6*e.height,p=e.right-d.left+n.scrollLeft+8}catch{let a=m.getBoundingClientRect();o=a.top-d.top+n.scrollTop+a.height/2,p=a.right-d.left+n.scrollLeft+8}b.push({level:i,text:g,pos:f,uid:l,centerY:o,endLeft:p,rootRight:h})}),b);l(i);let j=n.querySelector(".tiptap");if(j)for(let b of(ul(n),i)){if(!f.has(b.uid))continue;let c=uk(a,b.pos);if(!c||!j.contains(c))continue;let d=c.nextElementSibling;for(;d&&d.parentElement===j;){let a=function(a){if(!a)return null;let b=a.tagName.match(/^H([1-6])$/);return b?Number(b[1]):null}(d);if(null!==a&&a<=b.level)break;d.style.display="none",d=d.nextElementSibling}}},h=()=>{b&&clearTimeout(b),b=setTimeout(g,250)};return g(),c=requestAnimationFrame(g),a.on("update",h),"u">typeof ResizeObserver?(e=new ResizeObserver(g)).observe(n):window.addEventListener("resize",g,{passive:!0}),()=>{b&&clearTimeout(b),cancelAnimationFrame(c),a.off("update",h),window.removeEventListener("resize",g),e?.disconnect(),ul(n)}},[f,a,n,i,d,m]),d&&n)?(0,bu.createPortal)((0,g.jsx)("div",{"aria-hidden":!0,className:"absolute inset-0 h-0 pointer-events-none z-20",children:k.map(a=>{let b=f.has(a.uid),c=a.endLeft+20;return(0,g.jsxs)("div",{children:[(0,g.jsx)("button",{type:"button","aria-label":`${b?"Expand":"Collapse"} section: ${a.text}`,"aria-pressed":b,title:a.text,onClick:()=>{h(b=>{let c=new Set(b);return c.has(a.uid)?c.delete(a.uid):c.add(a.uid),c})},className:"pointer-events-auto absolute flex h-4 w-4 -translate-y-1/2 items-center justify-center rounded border border-border/70 bg-background/90 text-muted-foreground shadow-sm backdrop-blur transition-colors hover:bg-accent hover:text-foreground",style:{top:a.centerY,left:a.endLeft},children:b?(0,g.jsx)(a3.ChevronRight,{className:"h-3 w-3"}):(0,g.jsx)(s,{className:"h-3 w-3"})}),b&&a.rootRight-c>8?(0,g.jsx)("span",{"aria-hidden":!0,className:"absolute -translate-y-1/2 border-t border-dashed border-border/70",style:{top:a.centerY,left:c,width:a.rootRight-c}}):null]},a.uid)})}),n):null}function un(a){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ue,{...a}),(0,g.jsx)(uf,{...a}),(0,g.jsx)(uh,{...a}),(0,g.jsx)(uj,{...a}),(0,g.jsx)(um,{...a})]})}let uo=(0,h.default)("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]),up=(0,h.default)("unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]),uq=new Map,ur=new Map,us=(0,ay.create)((a,b)=>({path:null,backlinks:[],loading:!1,cacheVersion:0,fetch:async c=>{let d;if(!c)return;let e=(d=uq.get(c))?Date.now()-d.loadedAt>6e4?(uq.delete(c),null):d.data:null;if(e)return void a({path:c,backlinks:e,loading:!1});a({path:c,backlinks:[],loading:!0});let f=ur.get(c);if(f){try{let d=await f.promise;if(b().path!==c)return;a({backlinks:d,loading:!1})}catch{b().path===c&&a({loading:!1})}return}let g=new AbortController,h=(async()=>{let a=await (0,bB.wsFetch)(`/api/wiki/backlinks?path=${encodeURIComponent(c)}`,{signal:g.signal});return a.ok?(await a.json()).backlinks??[]:[]})().finally(()=>{ur.delete(c)});ur.set(c,{promise:h,controller:g});try{let d=await h;if(g.signal.aborted)return;if(uq.delete(c),uq.set(c,{data:d,loadedAt:Date.now()}),uq.size>30){let a=uq.keys().next().value;void 0!==a&&uq.delete(a)}if(b().path!==c)return;a({backlinks:d,loading:!1})}catch(d){if("AbortError"===d.name||b().path!==c)return;a({backlinks:[],loading:!1})}},cancel:()=>{let{path:c}=b();c&&ur.get(c)?.controller.abort(),b().loading&&a({loading:!1})},invalidateAll:()=>{uq.clear(),a({cacheVersion:b().cacheVersion+1})}})),ut="kb-backlinks-collapsed";function uu({currentPath:a}){let[b,c]=(0,p.useState)(!1),d=oa(a=>a.has),e=us(a=>a.path),f=us(a=>a.backlinks),h=us(a=>a.loading),i=us(a=>a.cacheVersion),j=e===a?f:[];return((0,p.useEffect)(()=>{"1"===localStorage.getItem(ut)&&c(!0)},[]),(0,p.useEffect)(()=>{if(b||!a)return;let c=setTimeout(()=>{us.getState().fetch(a)},200);return()=>{clearTimeout(c),us.getState().cancel()}},[a,b,i]),b||h||0!==j.length)?(0,g.jsx)("div",{className:"max-w-[var(--editor-max-w,48rem)] mx-auto px-4 sm:px-8 pb-8 pt-1",children:(0,g.jsxs)("div",{className:"border-t border-border/60 pt-4",children:[(0,g.jsxs)("button",{onClick:()=>{let a=!b;c(a);try{localStorage.setItem(ut,a?"1":"0")}catch{}},className:"flex items-center gap-1.5 text-[11px] text-muted-foreground/60 hover:text-muted-foreground transition-colors mb-2","aria-expanded":!b,children:[b?(0,g.jsx)(a3.ChevronRight,{className:"h-3 w-3 shrink-0"}):(0,g.jsx)(s,{className:"h-3 w-3 shrink-0"}),(0,g.jsx)(uo,{className:"h-3 w-3 shrink-0"}),(0,g.jsx)("span",{className:"font-medium",children:"Linked from"}),j.length>0&&(0,g.jsxs)("span",{className:"opacity-50 tabular-nums",children:["(",j.length,")"]}),h&&(0,g.jsx)("span",{className:"opacity-40 ml-1",children:"…"})]}),!b&&j.length>0&&(0,g.jsx)("ul",{className:"flex flex-col gap-1.5",children:j.map(a=>{var b,c;let e,f=d(((b=a.path).split("/").pop()??b).replace(/\.md$/i,""));return(0,g.jsxs)("li",{className:"flex flex-col",children:[(0,g.jsxs)("button",{onClick:()=>f&&b_.getState().loadPage(a.path),className:f?"text-left text-[12px] text-primary/70 hover:text-primary hover:underline underline-offset-2 truncate transition-colors flex items-center gap-1":"text-left text-[12px] text-muted-foreground/40 truncate cursor-default flex items-center gap-1",title:f?a.path:`${a.path} (file not found)`,children:[!f&&(0,g.jsx)(up,{className:"h-2.5 w-2.5 shrink-0 text-muted-foreground/30"}),(e=(c=a.path).replace(/\.md$/i,"").split("/")).length>1?e.slice(-2).join(" / "):e[0]??c]}),a.snippet&&(0,g.jsx)("p",{className:f?"text-[10.5px] text-muted-foreground/50 line-clamp-1 mt-0.5":"text-[10.5px] text-muted-foreground/25 line-clamp-1 mt-0.5",children:a.snippet})]},a.path)})})]})}):null}let uv=(0,h.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),uw=(0,h.default)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),ux=(0,h.default)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),uy=(0,h.default)("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),uz=(0,h.default)("columns-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),uA=(0,h.default)("panel-top",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]]),uB=(0,h.default)("rows-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);function uC({label:a,icon:b,disabled:c,active:d,danger:e,onAction:f}){return(0,g.jsx)("button",{type:"button","aria-label":a,title:a,disabled:c,onMouseDown:a=>a.preventDefault(),onClick:a=>{a.preventDefault(),f()},className:(0,ao.cn)("h-7 w-7 inline-flex items-center justify-center rounded text-foreground/80 hover:bg-accent transition-colors disabled:pointer-events-none disabled:opacity-35",d&&"bg-accent text-foreground",e&&"text-destructive hover:bg-destructive/10"),children:(0,g.jsx)(b,{className:"h-3.5 w-3.5"})})}function uD(){return(0,g.jsx)("div",{className:"mx-1 h-5 w-px bg-border"})}function uE({editor:a}){if(!a)return null;let b=()=>{if(!iJ(a.state))return null;try{return i2(a.state)}catch{return null}},c=b=>{b()&&(a.commands.focus(),a.commands.fixTables())},d=c=>{let d=b();if(!d)return;let e=d.top,f=e+c;if(!(f<0)&&!(f>=d.map.height)){var g;(g={from:e,to:f},(a,b)=>{let{from:c,to:d,select:e=!0,pos:f=a.selection.from}=g,h=a.tr;return!!function(a){var b,c,d,e,f;let g,{tr:h,originIndex:i,targetIndex:j,select:k,pos:l}=a,m=iY(h.doc.resolve(l));if(!m)return!1;let n=null==(b=i0(h,i))?void 0:b.indexes,o=null==(c=i0(h,j))?void 0:c.indexes;if(!n||!o||n.includes(j))return!1;let p=(d=m.node,e=n,f=o,g=iV(d),iW(d,g=iX(g,e,f,0)));if(h.replaceWith(m.pos,m.pos+m.node.nodeSize,p),!k)return!0;let q=iF.get(p),r=m.start,s=q.positionAt(j,q.width-1,p),t=h.doc.resolve(r+s),u=q.positionAt(j,0,p),v=h.doc.resolve(r+u);return h.setSelection(iQ.rowSelection(t,v)),!0}({tr:h,originIndex:c,targetIndex:d,select:e,pos:f})&&(null==b||b(h),!0)})(a.state,a.view.dispatch),a.commands.focus()}},e=c=>{let d=b();if(!d)return;let e=d.left,f=e+c;if(!(f<0)&&!(f>=d.map.width)){var g;(g={from:e,to:f},(a,b)=>{let{from:c,to:d,select:e=!0,pos:f=a.selection.from}=g,h=a.tr;return!!function(a){var b,c,d,e,f;let g,{tr:h,originIndex:i,targetIndex:j,select:k,pos:l}=a,m=iY(h.doc.resolve(l));if(!m)return!1;let n=null==(b=i_(h,i))?void 0:b.indexes,o=null==(c=i_(h,j))?void 0:c.indexes;if(!n||!o||n.includes(j))return!1;let p=(d=m.node,e=n,f=o,g=i1(iV(d)),iW(d,g=i1(g=iX(g,e,f,0))));if(h.replaceWith(m.pos,m.pos+m.node.nodeSize,p),!k)return!0;let q=iF.get(p),r=m.start,s=q.positionAt(q.height-1,j,p),t=h.doc.resolve(r+s),u=q.positionAt(0,j,p),v=h.doc.resolve(r+u);return h.setSelection(iQ.colSelection(t,v)),!0}({tr:h,originIndex:c,targetIndex:d,select:e,pos:f})&&(null==b||b(h),!0)})(a.state,a.view.dispatch),a.commands.focus()}},f=b(),h=!!f&&f.top>0,i=!!f&&f.top<f.map.height-1,j=!!f&&f.left>0,k=!!f&&f.left<f.map.width-1;return(0,g.jsxs)(ov,{editor:a,pluginKey:"tableMenu",options:{placement:"top",offset:10},shouldShow:({editor:a})=>a.isActive("table"),className:"flex items-center gap-0.5 rounded-md border border-border bg-popover px-1 py-1 shadow-lg",children:[(0,g.jsx)(uC,{label:"Select cell text",icon:t5,onAction:()=>{let b=iI(a.state.selection.$from),c=b?.nodeAfter;b&&c&&a.chain().focus().setTextSelection({from:b.pos+1,to:b.pos+c.nodeSize-1}).run()}}),(0,g.jsx)(uD,{}),(0,g.jsx)(uC,{label:"Add row above",icon:uB,onAction:()=>c(()=>a.chain().focus().addRowBefore().run())}),(0,g.jsx)(uC,{label:"Add row below",icon:uv,onAction:()=>c(()=>a.chain().focus().addRowAfter().run())}),(0,g.jsx)(uC,{label:"Move row up",icon:uy,disabled:!h,onAction:()=>d(-1)}),(0,g.jsx)(uC,{label:"Move row down",icon:uv,disabled:!i,onAction:()=>d(1)}),(0,g.jsx)(uC,{label:"Delete row",icon:bf,danger:!0,onAction:()=>c(()=>a.chain().focus().deleteRow().run())}),(0,g.jsx)(uD,{}),(0,g.jsx)(uC,{label:"Add column before",icon:uz,onAction:()=>c(()=>a.chain().focus().addColumnBefore().run())}),(0,g.jsx)(uC,{label:"Add column after",icon:ux,onAction:()=>c(()=>a.chain().focus().addColumnAfter().run())}),(0,g.jsx)(uC,{label:"Move column left",icon:uw,disabled:!j,onAction:()=>e(-1)}),(0,g.jsx)(uC,{label:"Move column right",icon:ux,disabled:!k,onAction:()=>e(1)}),(0,g.jsx)(uC,{label:"Delete column",icon:bf,danger:!0,onAction:()=>c(()=>a.chain().focus().deleteColumn().run())}),(0,g.jsx)(uD,{}),(0,g.jsx)(uC,{label:"Toggle header row",icon:uA,onAction:()=>c(()=>a.chain().focus().toggleHeaderRow().run())}),(0,g.jsx)(uC,{label:"Toggle header column",icon:c$,onAction:()=>c(()=>a.chain().focus().toggleHeaderColumn().run())}),(0,g.jsx)(uD,{}),(0,g.jsx)(uC,{label:"Delete table",icon:bf,danger:!0,onAction:()=>a.chain().focus().deleteTable().run()})]})}let uF=["entities","concepts","comparisons"],uG=/^[a-z0-9-]+$/;function uH({editor:a,onCreateRequest:b}){let[c,d]=(0,p.useState)(!1),[e,f]=(0,p.useState)(""),[h,i]=(0,p.useState)(0),[j,k]=(0,p.useState)({top:0,left:0}),l=(0,p.useRef)(null),m=(0,p.useRef)(0),n=oa(a=>a.slugs),o=oa(a=>a.slugDir),q=oa(a=>a.has),r=Array.from(n).sort().filter(a=>!e||a.includes(e.toLowerCase())).slice(0,20),s=e.length>0&&uG.test(e)&&!q(e),t=r.length+ +!!s,u=(0,p.useCallback)(()=>{d(!1),f(""),i(0)},[]),v=(0,p.useCallback)(b=>{if(!a)return;let{from:c}=a.state.selection,d=m.current-2,e=a.state.schema.marks.wikiLink;if(!e)return;let f=e.create({slug:b,alias:null,anchor:null}),g=a.state.schema.text(b,[f]),h=a.state.tr.replaceWith(d,c,g);a.view.dispatch(h),a.commands.focus(),u()},[a,u]),w=(0,p.useCallback)(async c=>{if(a){if(c<r.length)v(r[c]??"");else if(s){let a=await b(e);a.ok?v(a.slug):u()}}},[a,r,s,e,v,b,u]);return((0,p.useEffect)(()=>{if(!a)return;let b=b=>{if(!c){if("["===b.key){let{from:b}=a.state.selection;if("["!==a.state.doc.textBetween(Math.max(0,b-1),b)||a.state.doc.resolve(b).marks().some(a=>"wikiLink"===a.type.name))return;let c=a.view.coordsAtPos(b),e=a.view.dom.getBoundingClientRect();k({top:c.bottom-e.top+4,left:c.left-e.left}),m.current=b+1,d(!0),f(""),i(0)}return}"ArrowDown"===b.key?(b.preventDefault(),i(a=>t>0?(a+1)%t:0)):"ArrowUp"===b.key?(b.preventDefault(),i(a=>t>0?(a-1+t)%t:0)):"Enter"===b.key?(b.preventDefault(),b.stopPropagation(),t>0&&w(h)):"Escape"===b.key||"]"===b.key?u():"Backspace"===b.key?0===e.length?u():(f(a=>a.slice(0,-1)),i(0)):1!==b.key.length||b.metaKey||b.ctrlKey||(f(a=>a+b.key),i(0))};return window.addEventListener("keydown",b,!0),()=>window.removeEventListener("keydown",b,!0)},[a,c,e,h,t,u,w]),(0,p.useEffect)(()=>{if(!c)return;let a=a=>{l.current&&!l.current.contains(a.target)&&u()};return window.addEventListener("mousedown",a),()=>window.removeEventListener("mousedown",a)},[c,u]),c&&0!==t)?(0,g.jsxs)("div",{ref:l,className:"absolute z-50 w-[280px] bg-popover border border-border rounded-lg shadow-lg py-1 overflow-hidden max-h-[300px] overflow-y-auto",style:{top:j.top,left:j.left},children:[r.map((a,b)=>{let c=o.get(a);return(0,g.jsxs)("button",{type:"button",onMouseDown:a=>{a.preventDefault(),w(b)},onMouseEnter:()=>i(b),className:(0,ao.cn)("flex items-center justify-between w-full px-3 py-1.5 text-left text-sm transition-colors",b===h?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:[(0,g.jsx)("span",{className:"truncate",children:a}),c&&(0,g.jsx)("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground bg-muted px-1.5 py-0.5 rounded",children:c})]},a)}),s&&(0,g.jsx)("button",{type:"button",onMouseDown:a=>{a.preventDefault(),w(r.length)},onMouseEnter:()=>i(r.length),className:(0,ao.cn)("flex items-center w-full px-3 py-1.5 text-left text-sm transition-colors",r.length===h?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:(0,g.jsxs)("span",{className:"text-muted-foreground",children:["+ Create new “",e,"”"]})})]}):null}let uI=(0,by.cva)("inline-flex items-center rounded-sm border px-2.5 py-0.5 text-xs font-normal transition-colors focus:outline-none focus:ring-2 focus:ring-ring",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow-e-1",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground shadow-e-1",outline:"text-foreground",accent:"border-transparent bg-accent text-accent-foreground"}},defaultVariants:{variant:"default"}});function uJ({className:a,variant:b,...c}){return(0,g.jsx)("div",{className:(0,ao.cn)(uI({variant:b}),a),...c})}let uK=new Set(["title","type","status","created","updated","date","tags","sources","private","supersedes","superseded_by"]);function uL({data:a}){let[b,c]=(0,p.useState)(!1),d=Object.keys(a);if(0===d.length)return null;let e="string"==typeof a.title?a.title:null,f="string"==typeof a.type?a.type:null,h="string"==typeof a.status?a.status:null,i="string"==typeof a.created?a.created:null,j="string"==typeof a.updated?a.updated:null,k=!0===a.private,l=Array.isArray(a.tags)?a.tags:[],m=Array.isArray(a.sources)?a.sources:[],n="string"==typeof a.superseded_by?a.superseded_by:null,o=d.filter(a=>!uK.has(a));return(0,g.jsxs)("div",{className:"mb-6 rounded-sm border bg-card/40 px-4 py-3 text-xs",children:[e&&(0,g.jsx)("div",{className:"mb-2 text-base font-normal text-foreground",children:e}),(0,g.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5 text-muted-foreground",children:[f&&(0,g.jsx)(uJ,{variant:"outline",className:"font-normal",children:f}),h&&(0,g.jsx)(uJ,{variant:"outline",className:"font-normal",children:h}),k&&(0,g.jsx)(uJ,{variant:"outline",className:"border-warning-ink/40 font-normal text-warning-ink",children:"private"}),n&&(0,g.jsxs)(uJ,{variant:"outline",className:"border-destructive/40 font-normal text-destructive",children:["superseded → ",n]}),i&&(0,g.jsxs)("span",{children:[(0,g.jsx)("span",{className:"opacity-60",children:"created"})," ",(0,g.jsx)("span",{className:"text-foreground/80",children:i})]}),j&&j!==i&&(0,g.jsxs)("span",{children:[(0,g.jsx)("span",{className:"opacity-60",children:"updated"})," ",(0,g.jsx)("span",{className:"text-foreground/80",children:j})]})]}),l.length>0&&(0,g.jsx)("div",{className:"mt-2 flex flex-wrap gap-1",children:l.map(a=>(0,g.jsxs)(uJ,{variant:"secondary",className:"font-normal text-[11px]",children:["#",a]},a))}),m.length>0&&(0,g.jsxs)("div",{className:"mt-2",children:[(0,g.jsx)("span",{className:"opacity-60",children:"sources:"})," ",(0,g.jsx)("span",{className:"text-foreground/80",children:m.join(", ")})]}),o.length>0&&(0,g.jsxs)("div",{className:"mt-2 border-t pt-2",children:[(0,g.jsxs)("button",{type:"button",onClick:()=>c(a=>!a),className:"flex items-center gap-1 text-muted-foreground hover:text-foreground",children:[b?(0,g.jsx)(s,{className:"h-3 w-3"}):(0,g.jsx)(a3.ChevronRight,{className:"h-3 w-3"}),(0,g.jsxs)("span",{children:[o.length," more field",1===o.length?"":"s"]})]}),b&&(0,g.jsx)("dl",{className:"mt-1.5 grid grid-cols-[max-content_1fr] gap-x-3 gap-y-0.5",children:o.map(b=>(0,g.jsxs)(p.Fragment,{children:[(0,g.jsx)("dt",{className:"opacity-60",children:b}),(0,g.jsx)("dd",{className:"text-foreground/80 break-words",children:function a(b){if(null==b)return"";if("string"==typeof b)return b;if("number"==typeof b||"boolean"==typeof b)return String(b);if(Array.isArray(b))return b.map(a).join(", ");try{return JSON.stringify(b)}catch{return String(b)}}(a[b])})]},b))})]})]})}function uM({containerRef:a,onComment:b,align:c="center"}){let[d,e]=(0,p.useState)(null);return((0,p.useEffect)(()=>{function b(){let b=window.getSelection();if(!b||b.isCollapsed||0===b.rangeCount)return void e(null);let d=b.getRangeAt(0),f=a.current;if(!f||!f.contains(d.commonAncestorContainer))return void e(null);let g=d.getBoundingClientRect();if(0===g.width&&0===g.height)return void e(null);if("left"===c){let a=f.getBoundingClientRect();e({top:g.top,left:a.left+8})}else e({top:g.top-38,left:g.left+g.width/2})}return document.addEventListener("selectionchange",b),()=>document.removeEventListener("selectionchange",b)},[a,c]),d)?(0,g.jsxs)("button",{type:"button",style:{position:"fixed",top:d.top,left:d.left,transform:"left"===c?void 0:"translateX(-50%)",zIndex:50},className:"flex items-center gap-1 px-2 py-1 bg-popover border border-border rounded-sm shadow-lg text-[12px] text-foreground/80 hover:text-foreground hover:bg-accent transition-colors",onMouseDown:a=>a.preventDefault(),onClick:()=>{b(),e(null)},"aria-label":"Add comment",title:"Add comment",children:[(0,g.jsx)(oC,{className:"w-3.5 h-3.5"}),(0,g.jsx)("span",{children:"Comment"})]}):null}async function uN(a,b){let c=new FormData;c.append("file",b);try{let d=await (0,bB.wsFetch)(`/api/upload/${a}`,{method:"POST",body:c});if(!d.ok)return au(`Upload failed: ${b.name}`),null;let e=await d.json();return e.url?(0,bB.withWs)(e.url):e.url}catch{return au(`Upload failed: ${b.name}`),null}}function uO(a,b=document){let c=a;try{c=decodeURIComponent(a)}catch{}let d=document.getElementById(c);if(d)return d;for(let a of b.querySelectorAll("h1, h2, h3, h4, h5, h6"))if(a.id===c)return a;return null}function uP({mode:a}={}){let{currentPath:b,content:c,saveStatus:d,frontmatter:e,isLoading:f,loadStatus:h,createMissingPage:i,editMode:j,setEditMode:k}=b_(),l=a??j,n="viewing"===l,o="suggesting"===l,s=(0,p.useMemo)(()=>n?function(a){let b=n8.exec(a);if(!b)return{data:{},body:a};let c=b[1],d=a.slice(b[0].length),e=c.split(/\r?\n/).find(a=>""!==a.trim())??"";if(/^\s*(#{1,6}\s|<|>|-\s|\*\s|\d+\.\s)/.test(e))return{data:{},body:a};let f={},g=c.split(/\r?\n/),h=0;for(;h<g.length;){let a=g[h];if(!a||/^\s*#/.test(a)){h+=1;continue}let b=/^([A-Za-z_][\w-]*)\s*:\s*(.*)$/.exec(a);if(!b){h+=1;continue}let c=b[1],d=b[2];if(""===d.trim()){let a=[],b=h+1;for(;b<g.length&&/^\s+-\s+/.test(g[b]);){let c=/^\s+-\s+(.*)$/.exec(g[b]);c&&a.push(n9(c[1])),b+=1}if(a.length>0){f[c]=a,h=b;continue}f[c]="",h+=1;continue}f[c]=n9(d),h+=1}return 0===Object.keys(f).length?{data:{},body:a}:{data:f,body:d}}(c):{data:{},body:c},[c,n]),t=(0,dK.useViewWidthStore)(a=>dK.VIEW_WIDTH_CSS[a.width]),u=(0,dK.useViewWidthStore)(a=>dK.VIEW_ALIGN_ML[a.align]),w=n?"rtl"===s.data.dir:e?.dir==="rtl",{open:x,clearMessages:y}=bF(),{open:z,Dialog:A}=function(){let[a,b]=(0,p.useState)(!1),[c,d]=(0,p.useState)({slug:"",dir:"entities",title:""}),[e,f]=(0,p.useState)(!1),h=(0,p.useRef)(null),i=(0,p.useCallback)(a=>(d({slug:a,dir:"entities",title:a.split("-").filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}),b(!0),new Promise(a=>{h.current=a})),[]),j=(0,p.useCallback)(()=>{b(!1),h.current?.({ok:!1,slug:c.slug}),h.current=null},[c.slug]),k=(0,p.useCallback)(async()=>{let{slug:a,dir:d,title:e}=c;f(!0);try{let c=await (0,bB.wsFetch)("/api/wiki/page",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:a,dir:d,title:e.trim()||void 0})});if(c.ok||409===c.status){let c=oa.getState();c.invalidate(),c.load(),b(!1),h.current?.({ok:!0,slug:a,dir:d}),h.current=null}else{let a=await c.json().catch(()=>({})),b=null!==a&&"object"==typeof a&&"error"in a&&"string"==typeof a.error?a.error:"Failed to create page";au(b)}}catch{au("Failed to create page")}finally{f(!1)}},[c]);return{open:i,Dialog:(0,g.jsx)(P,{open:a,onOpenChange:a=>{a||j()},children:(0,g.jsxs)(aZ,{children:[(0,g.jsx)(a$,{children:(0,g.jsx)(a0,{children:"Create wiki page"})}),(0,g.jsxs)("div",{className:"space-y-4 py-2",children:[(0,g.jsxs)("div",{className:"space-y-1.5",children:[(0,g.jsx)(bA,{htmlFor:"wiki-create-slug",children:"Slug"}),(0,g.jsx)(bh.Input,{id:"wiki-create-slug",value:c.slug,readOnly:!0,className:"bg-muted cursor-default select-all"})]}),(0,g.jsxs)("div",{className:"space-y-1.5",children:[(0,g.jsx)(bA,{children:"Directory"}),(0,g.jsx)("div",{className:"flex gap-4",children:uF.map(a=>(0,g.jsxs)("label",{className:"flex items-center gap-1.5 text-sm cursor-pointer",children:[(0,g.jsx)("input",{type:"radio",name:"wiki-create-dir",value:a,checked:c.dir===a,onChange:()=>d(b=>({...b,dir:a})),className:"accent-primary"}),a]},a))})]}),(0,g.jsxs)("div",{className:"space-y-1.5",children:[(0,g.jsx)(bA,{htmlFor:"wiki-create-title",children:"Title (optional)"}),(0,g.jsx)(bh.Input,{id:"wiki-create-title",value:c.title,onChange:a=>d(b=>({...b,title:a.target.value})),placeholder:"Humanized title..."})]})]}),(0,g.jsxs)(a_,{children:[(0,g.jsx)(v.Button,{variant:"outline",onClick:j,disabled:e,children:"Cancel"}),(0,g.jsx)(v.Button,{onClick:()=>void k(),disabled:e,children:e?"Creating...":"Create"})]})]})})}}(),B=(0,p.useRef)(z);B.current=z;let C=(0,p.useRef)(!1),D=(0,p.useRef)(n);D.current=n;let E=(0,p.useRef)(null),[F,G]=(0,p.useState)(!1),[H,I]=(0,p.useState)("");(0,p.useEffect)(()=>{oa.getState().load()},[]),(0,p.useEffect)(()=>{if(!b)return;let a=setTimeout(()=>{oc.getState().loadSidecar(b)},200);return()=>clearTimeout(a)},[b]),function({path:a,mode:b,enabled:c=!0}){(0,p.useEffect)(()=>{},[c,a,"viewing"===b])}({path:b,mode:l,enabled:!0}),function({path:a,isViewingRef:b,enabled:c=!0}){let d=(0,p.useMemo)(()=>{if(!a)return"";let b=a.lastIndexOf("/");return -1===b?"":a.slice(0,b)},[a]),e=(0,bB.getActiveWorkspaceId)(),f=(0,bB.getEphemeralRoot)();(0,p.useEffect)(()=>{},[a,d,c,e,f,b])}({path:b,isViewingRef:D});let[J,K]=(0,p.useState)(null),L=(0,p.useRef)(null),[M,N]=(0,p.useState)(new Map),O=oc(a=>b?a.byPath[b]?.snapshotBlocks:void 0),Q=oc(a=>b?a.byPath[b]?.sidecar?.suggestions:void 0),R=oc(a=>b?a.byPath[b]?.snapshotRevision??0:0),S=oc(a=>b?a.byPath[b]?.sidecar?.comments:void 0),T=(0,p.useMemo)(()=>O??[],[O]),U=(0,p.useMemo)(()=>S??[],[S]),V=(0,p.useMemo)(()=>Q?.filter(a=>"pending"===a.status)??[],[Q]),W=(0,p.useMemo)(()=>{let a={};for(let b of U)b.ref&&(a[b.ref]??=[]).push(b);return a},[U]),[X,Y]=(0,p.useState)(null),[Z,$]=(0,p.useState)(null),_=(0,p.useCallback)(()=>{if(!E.current)return null;let a=E.current.view,{from:b}=a.state.selection,c=b_.getState().currentPath??"",d=oc.getState().byPath[c]?.snapshotBlocks??[],e=a.state.doc.resolve(b),f=e.depth>0?e.index(0):0,g=L.current?.querySelector(".ProseMirror"),h=(g?Array.from(g.children):[])[f]??null,i=d[f],j=i?.ref??h?.getAttribute("data-block-ref")??null,k=i?.markdown??"";if(!j&&h){let c=a.domAtPos(b),d=c.node.nodeType===Node.ELEMENT_NODE?c.node:c.node.parentElement,e=d?.closest("[data-block-ref]")??null;j=e?.getAttribute("data-block-ref")??null}return j&&h?{blockRef:j,blockEl:h,markdown:k}:null},[]),aa=(0,p.useCallback)(()=>{let a=_();if(!a)return;let b=a.blockEl.getBoundingClientRect();$({blockRef:a.blockRef,markdown:a.markdown,anchor:{top:b.bottom+4,left:b.left}})},[_]),ab=(0,p.useCallback)(()=>{let a=_();a&&Y({blockRef:a.blockRef,el:a.blockEl})},[_]),{markDirty:ac,flush:ad,onSelectionUpdate:ae}=function({path:a,editorRef:b,scrollContainerRef:c,isLoadingRef:d,isViewingRef:e,enabled:f=!0}){let g=(0,p.useRef)(!1),h=(0,p.useRef)(!1),i=(0,p.useRef)(null),j=(0,p.useCallback)(async()=>{if(h.current||!f||e.current||"suggesting"!==b_.getState().editMode||!g.current)return;let i=b.current,j=a??b_.getState().currentPath;if(!i||!j)return;let k=c.current?.querySelector(".ProseMirror");if(!k)return;let l=Array.from(k.children),m=oc.getState().byPath[j]?.snapshotBlocks??[];if(0!==m.length){h.current=!0,g.current=!1;try{let a=()=>oc.getState().byPath[j]?.snapshotRevision??0,b=async()=>{await oc.getState().loadSnapshot(j),await oc.getState().loadSidecar(j)},c=Math.max(l.length,m.length),e=!1;for(let d=0;d<c;d++){let c=l[d],f=m[d],g=c?n7(c.outerHTML,j).trim():null;if(f&&null!==g){if(tu(g)!==tu(f.markdown)){let c=await tt({path:j,ref:f.ref,kind:"replace",markdown:g,getRevision:a,refresh:b});e=e||c}}else if(f&&null===g){let c=await tt({path:j,ref:f.ref,kind:"delete",getRevision:a,refresh:b});e=e||c}else if(!f&&null!==g&&g.length>0){let c=m[m.length-1]?.ref;if(c){let d=await tt({path:j,ref:c,kind:"insertAfter",markdown:g,getRevision:a,refresh:b});e=e||d}}}if(e){await b();let a=(oc.getState().byPath[j]?.snapshotBlocks??m).map(a=>a.markdown).join("\n\n");d.current=!0;let c=await (0,np.markdownToHtml)(a,j);i.commands.setContent(c),setTimeout(()=>{d.current=!1},50)}}finally{h.current=!1}}},[f,a,b,c,d,e]),k=(0,p.useCallback)(()=>{!f||e.current||"suggesting"===b_.getState().editMode&&(g.current=!0)},[f,e]),l=(0,p.useCallback)(a=>{if("suggesting"!==b_.getState().editMode)return;let{from:b}=a.state.selection,c=a.state.doc.resolve(b),d=c.depth>0?c.index(0):0,e=i.current;i.current=d,null!==e&&e!==d&&g.current&&j()},[j]);return{markDirty:k,flush:j,onSelectionUpdate:l}}({path:b,editorRef:E,scrollContainerRef:L,isLoadingRef:C,isViewingRef:D});(0,p.useEffect)(()=>{if(!b)return;let a=setTimeout(()=>{oc.getState().loadSnapshot(b)},200);return()=>clearTimeout(a)},[b]),(0,p.useEffect)(()=>{if(!b||0===T.length||!L.current)return;let a=L.current,c=a.querySelector(".ProseMirror");if(!c)return;let d=Array.from(c.children),e=a.getBoundingClientRect(),f=new Map;for(let b=0;b<Math.min(d.length,T.length);b++){let c=d[b],g=T[b];c.setAttribute("data-block-ref",g.ref);let h=c.getBoundingClientRect();f.set(g.ref,{top:h.top-e.top+a.scrollTop,left:h.left-e.left,width:h.width,bottom:h.bottom-e.top+a.scrollTop})}N(f)},[b,T]);let af=function(a={},b=[]){let c=(0,jz.useRef)(a);c.current=a;let[d]=(0,jz.useState)(()=>new m9(c)),e=(0,jA.useSyncExternalStore)(d.subscribe,d.getEditor,d.getServerSnapshot);return(0,jz.useDebugValue)(e),(0,jz.useEffect)(d.onRender(b)),!function(a){var b;let[c]=(0,jz.useState)(()=>new m8(a.editor)),d=(0,m2.useSyncExternalStoreWithSelector)(c.subscribe,c.getSnapshot,c.getServerSnapshot,a.selector,null!=(b=a.equalityFn)?b:m0);m7(()=>c.watch(a.editor),[a.editor,c]),(0,jz.useDebugValue)(d)}({editor:e,selector:({transactionNumber:b})=>!1===a.shouldRerenderOnTransaction||void 0===a.shouldRerenderOnTransaction?null:a.immediatelyRender&&0===b?0:b+1}),e}({extensions:tp,content:"",editable:!n,onUpdate:(0,p.useCallback)(({editor:a})=>{if(C.current||D.current||!a)return;ac();let b=n7(a.getHTML(),b_.getState().currentPath??void 0);b_.getState().updateContent(b)},[]),onBlur:()=>{ad()},onSelectionUpdate:({editor:a})=>{ae(a)},editorProps:{attributes:{class:"focus:outline-none min-h-[calc(100vh-12rem)] px-4 sm:px-8 py-6 max-w-[var(--editor-max-w,48rem)] ml-[var(--editor-ml,auto)] mr-auto"},handleKeyDown:(a,b)=>{if((b.metaKey||b.ctrlKey)&&"a"===b.key.toLowerCase()&&iJ(a.state)){let c=iI(a.state.selection.$from),d=c?.nodeAfter;if(!c||!d)return!1;let e=c.pos+1,f=c.pos+d.nodeSize-1;return(a.state.selection.from!==e||a.state.selection.to!==f)&&(b.preventDefault(),af?.chain().focus().setTextSelection({from:e,to:f}).run(),!0)}return!1},handleClick:(a,b,c)=>{let d=c.target.closest("a");if(!d)return!1;let e=d.getAttribute("href");if(!e)return!1;if("true"===d.dataset.wikiLink){c.preventDefault(),c.stopPropagation();let a=d.dataset.slug??"",b=d.dataset.anchor??null;if(!a)return!0;let e=oa.getState();if(e.has(a)){let c=e.getDir(a),d=null===c||"root"===c?`${a}.md`:`${c}/${a}.md`;b_.getState().loadPage(d),b&&setTimeout(()=>{let a=uO(b);a&&(a.scrollIntoView({behavior:"smooth"}),document.dispatchEvent(new CustomEvent("anchor-navigation",{detail:{element:a}})))},200)}else{if(D.current)return!0;B.current(a).then(a=>{if(a.ok){let b=a.dir??"entities",c=`${b}/${a.slug}.md`;b_.getState().loadPage(c)}})}return!0}if(/^https?:\/\//.test(e)||e.startsWith("/api/")||e.startsWith("mailto:")||e.startsWith("tel:"))return!1;if(c.preventDefault(),c.stopPropagation(),e.startsWith("#")){let a=uO(e.slice(1));return a&&(a.scrollIntoView({behavior:"smooth"}),document.dispatchEvent(new CustomEvent("anchor-navigation",{detail:{element:a}}))),!0}let f=function(a,b,c){var d;let e;if(!a||/^[a-z][a-z0-9+.-]*:/i.test(a)||a.startsWith("/api/"))return null;let f=a.indexOf("#"),g=f>=0?tr(a.slice(0,f)):tr(a);if(!g)return null;tq.test(g);let h=g.replace(tq,""),i=h.startsWith("/"),j=h.startsWith("./")||h.startsWith("../");if(!i&&!j&&!g.includes("/")&&!g.includes(".")&&c?.has(h)){let a=c.getDir(h);return null===a||"root"===a?`${h}.md`:`${a}/${h}.md`}if(i)e=h.replace(/^\/+/,"");else{let a=b?.includes("/")?b.slice(0,b.lastIndexOf("/")):"";e=a?`${a}/${h.replace(/^\.\/+/,"")}`:h.replace(/^\.\/+/,"")}let k=function(a){let b=a.split("/").filter(a=>a.length>0&&"."!==a),c=[];for(let a of b)if(".."===a){if(0===c.length)return null;c.pop()}else c.push(a);return c.join("/")}(e);return null===k||""===k?null:(d=k.split("/").pop()??k,/\.[^./]+$/.test(d))?k:`${k}.md`}(e,b_.getState().currentPath,oa.getState());if(f){b_.getState().loadPage(f);let a=e.includes("#")?e.slice(e.indexOf("#")+1):"";a&&setTimeout(()=>{let b=uO(a);b&&(b.scrollIntoView({behavior:"smooth"}),document.dispatchEvent(new CustomEvent("anchor-navigation",{detail:{element:b}})))},200)}return!0},handlePaste:(a,b)=>{if(D.current)return!1;let c=b.clipboardData?.files,d=b_.getState().currentPath;if(c&&c.length>0&&d){for(let a of Array.from(c))uN(d,a).then(b=>{b&&af&&(a.type.startsWith("image/")?af.chain().focus().setImage({src:b,alt:a.name}).run():af.chain().focus().insertContent(`<a href="${b}">${a.name}</a>`).run())});return!0}return!1},handleDrop:(a,b)=>{if(D.current)return!1;let c=b.dataTransfer?.files;if(!c||0===c.length)return!1;let d=b_.getState().currentPath;if(!d)return!1;for(let a of(b.preventDefault(),Array.from(c)))uN(d,a).then(b=>{b&&af&&(a.type.startsWith("image/")?af.chain().focus().setImage({src:b,alt:a.name}).run():af.chain().focus().insertContent(`<a href="${b}">${a.name}</a>`).run())});return!0}},immediatelyRender:!1});E.current=af,(0,p.useEffect)(()=>{af?.setEditable(!n),n&&G(!1)},[af,n]);let ag=(0,p.useRef)(null),ah=(0,p.useRef)(null),[ai,aj]=(0,p.useState)(null);(0,p.useEffect)(()=>{if(!af||null===b||b_.getState().isDirty&&b===ag.current||f&&""===c)return;let a=s.body,d=`${b} ${a}`;if(ah.current===d){ai!==b&&aj(b);return}ag.current=b;let e=!1;return(async()=>{C.current=!0;let c=await (0,np.markdownToHtml)(a,n?{pagePath:b,sanitize:!0}:b);if(e||b_.getState().currentPath!==b){C.current=!1;return}af.commands.setContent(c),ah.current=d,aj(b),setTimeout(()=>{C.current=!1},50)})(),()=>{e=!0}},[af,c,b,f,ai,s.body,n]),(0,p.useEffect)(()=>{if(!n||!ai)return;let a=L.current;a&&a.querySelectorAll('input[type="checkbox"]').forEach(a=>{a.disabled=!0})},[n,ai,s.body]);let ak=null!==b&&(f||ai!==b),[al,am]=(0,p.useState)(!1);if((0,p.useEffect)(()=>{if(!ak)return void am(!1);let a=setTimeout(()=>am(!0),150);return()=>clearTimeout(a)},[ak]),null===b)return(0,g.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,g.jsxs)("div",{className:"text-center space-y-3",children:[(0,g.jsx)("p",{className:"text-lg font-medium tracking-[-0.02em]",children:"No page selected"}),(0,g.jsx)("p",{className:"text-sm text-muted-foreground/70",children:"Select a page from the sidebar or create a new one"})]})});if("missing"===h){let a=(b.split("/").pop()||b).replace(/[-_]+/g," ").replace(/\b\w/g,a=>a.toUpperCase());return(0,g.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,g.jsx)("div",{className:"max-w-3xl mx-auto px-6 py-10 space-y-6",children:(0,g.jsxs)("div",{className:"space-y-3",children:[(0,g.jsx)("p",{className:"text-lg font-medium tracking-[-0.02em] text-foreground",children:a}),(0,g.jsx)("p",{className:"text-sm text-muted-foreground/80",children:"This page doesn't exist yet."}),(0,g.jsxs)("button",{onClick:()=>void i(a),className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-[13px] font-medium text-primary-foreground hover:bg-primary/90 transition-colors",children:[(0,g.jsx)(cc,{className:"h-3.5 w-3.5"}),"Create page"]})]})})})}let an=async()=>{if(F){if(b_.getState().updateContent(H),af){C.current=!0;let a=await (0,np.markdownToHtml)(H,b??void 0);af.commands.setContent(a),setTimeout(()=>{C.current=!1},50)}G(!1)}else I(b_.getState().content),G(!0)};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[!n&&(0,g.jsxs)("div",{className:"flex items-center min-w-0",children:[(0,g.jsx)("div",{className:"flex-1 min-w-0",children:!F&&(0,g.jsx)(o5,{editor:af})}),(0,g.jsxs)("button",{onClick:an,className:`flex items-center gap-1.5 px-3 py-1 mr-2 text-[11px] rounded-md transition-colors border border-border ${F?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"}`,children:[(0,g.jsx)(d1,{className:"h-3 w-3"}),F?"Preview":"Markdown"]})]}),F?(0,g.jsx)("div",{className:"flex-1 overflow-y-auto p-4",dir:w?"rtl":void 0,children:(0,g.jsx)("textarea",{value:H,onChange:a=>I(a.target.value),className:"w-full h-full min-h-[calc(100vh-12rem)] bg-transparent font-mono text-[13px] leading-relaxed resize-none focus:outline-none",spellCheck:!1})}):(0,g.jsxs)("div",{className:"flex-1 relative",dir:w?"rtl":void 0,children:[o&&(0,g.jsx)("div",{className:"absolute top-0 inset-x-0 z-20 flex items-center justify-center gap-2 px-3 py-1 bg-primary/10 border-b border-primary/20 text-[11px] text-primary pointer-events-none",children:"Suggesting mode · your edits become suggestions for review"}),(0,g.jsx)(ub,{editor:af,scrollContainerRef:L}),(0,g.jsx)(un,{editor:af,scrollContainerRef:L}),(0,g.jsxs)("div",{ref:L,className:`absolute inset-0 overflow-y-auto ${o?"pt-7":""}`,style:{"--editor-max-w":t,"--editor-ml":u},"data-editor-scroll":!0,children:[(0,g.jsxs)("div",{"aria-hidden":"true",className:"relative pointer-events-none",style:{height:0},children:[Object.entries(W).map(([a,b])=>{let c=M.get(a);return c?(0,g.jsx)("div",{style:{pointerEvents:"auto"},children:(0,g.jsx)(tw,{anchorKey:a,anchorLabel:a,comments:b,top:c.top+4,left:Math.max(0,c.left-20),onClick:()=>{let b=L.current?.querySelector(`[data-block-ref="${a}"]`);b&&Y({blockRef:a,el:b})}})},`pip-${a}`):null}),b&&V.map(a=>{let c=M.get(a.ref),d=T.find(b=>b.ref===a.ref);if(!c||!d)return null;let e="insertAfter"===a.kind?c.bottom+4:"insertBefore"===a.kind?Math.max(0,c.top-80):c.top;return(0,g.jsx)("div",{style:{pointerEvents:"auto"},children:(0,g.jsx)(t$,{path:b,suggestion:a,currentMarkdown:d.markdown,baseRevision:R,getLatestRevision:()=>oc.getState().byPath[b]?.snapshotRevision??0,top:e,left:c.left,width:c.width,onSettled:()=>{oc.getState().loadSidecar(b),oc.getState().loadSnapshot(b)},readOnly:n})},`sug-${a.id}`)})]}),X&&b&&(0,g.jsx)(tX,{path:b,anchorKey:X.blockRef,anchorRef:X.blockRef,anchorLabel:X.blockRef,comments:W[X.blockRef]??[],anchorEl:X.el,onClose:()=>Y(null),readOnly:n}),Z&&b&&(0,g.jsx)(t1,{path:b,blockRef:Z.blockRef,currentMarkdown:Z.markdown,anchor:Z.anchor,onClose:()=>$(null)}),n&&Object.keys(s.data).length>0&&(0,g.jsx)("div",{className:"max-w-[var(--editor-max-w,48rem)] ml-[var(--editor-ml,auto)] mr-auto px-4 sm:px-8 pt-3",children:(0,g.jsx)(uL,{data:s.data})}),(0,g.jsx)(m6,{editor:af}),b&&/\.(md|markdown)$/i.test(b)&&(0,g.jsx)(uu,{currentPath:b}),(0,g.jsx)("div",{"aria-hidden":"true",className:"contents",onMouseOver:a=>{let b=a.target.closest(".proof-span");b&&b!==J&&K(b)},onMouseOut:a=>{let b=a.relatedTarget;b?.closest(".proof-span")||K(null)}}),b&&(0,g.jsx)(tY,{targetEl:J,path:b,onClose:()=>K(null),onComment:()=>{if(!J)return;let a=J.closest("[data-block-ref]");if(!a)return;let b=a.getAttribute("data-block-ref");b&&Y({blockRef:b,el:a})}}),!n&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(oJ,{editor:af,onSuggestEdit:aa,onComment:ab}),(0,g.jsx)(uE,{editor:af}),(0,g.jsx)(t8,{editor:af}),(0,g.jsx)(uH,{editor:af,onCreateRequest:B.current})]}),n&&(0,g.jsx)(uM,{containerRef:L,onComment:ab}),(0,g.jsxs)("div",{className:"max-w-[var(--editor-max-w,48rem)] ml-[var(--editor-ml,auto)] mr-auto px-8 pb-8 flex items-center gap-4",children:[(0,g.jsxs)("button",{onClick:()=>{y(),x()},className:"group flex items-center gap-2 text-[13px] text-muted-foreground/50 hover:text-muted-foreground transition-colors cursor-pointer",children:[(0,g.jsx)(no,{className:"h-3.5 w-3.5 group-hover:text-primary transition-colors"}),(0,g.jsx)("span",{children:"Edit with AI"})]}),!n&&(0,g.jsxs)("span",{className:"text-[11px] text-muted-foreground/30 select-none",children:[(0,g.jsx)("kbd",{className:"rounded px-1 py-0.5 font-mono text-[10px] ring-1 ring-foreground/10",children:"/"})," ","for commands"]})]})]}),al&&(0,g.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 backdrop-blur-md z-20 pointer-events-none","aria-hidden":"true",children:(0,g.jsx)(m.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground/70"})})]}),!n&&(0,g.jsxs)("div",{className:"flex items-center justify-between px-4 py-1 border-t border-border text-xs text-muted-foreground/60",children:[(0,g.jsxs)("span",{className:"text-[10.5px] text-muted-foreground/30 select-none hidden sm:block",children:[(0,g.jsx)("kbd",{className:"rounded px-1 font-mono text-[9.5px] ring-1 ring-foreground/10",children:"⌘S"})," ","save",(0,g.jsx)("span",{className:"mx-1.5 opacity-40",children:"·"}),(0,g.jsx)("kbd",{className:"rounded px-1 font-mono text-[9.5px] ring-1 ring-foreground/10",children:"/"})," ","commands"]}),(0,g.jsxs)("div",{className:"flex items-center gap-3",children:[(0,g.jsxs)("div",{className:"flex items-center rounded-md border border-border overflow-hidden text-[10.5px]",role:"radiogroup","aria-label":"Edit mode",children:[(0,g.jsx)("button",{type:"button",role:"radio","aria-checked":"editing"===j,onClick:()=>k("editing"),className:`px-2 py-0.5 transition-colors ${"editing"===j?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"}`,children:"Editing"}),(0,g.jsx)("button",{type:"button",role:"radio","aria-checked":"suggesting"===j,onClick:()=>k("suggesting"),className:`px-2 py-0.5 transition-colors ${"suggesting"===j?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"}`,children:"Suggesting"})]}),(0,g.jsxs)("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10.5px] transition-all duration-300 ${"idle"===d?"opacity-0 pointer-events-none":"opacity-100"} ${"saving"===d?"bg-muted text-muted-foreground":"saved"===d?"bg-success/10 text-success":"error"===d?"bg-destructive/10 text-destructive":""}`,children:["saving"===d&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(m.Loader2,{className:"h-2.5 w-2.5 animate-spin"}),"Saving…"]}),"saved"===d&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(r.Check,{className:"h-2.5 w-2.5"}),"Saved"]}),"error"===d&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(q.AlertCircle,{className:"h-2.5 w-2.5"}),"Save failed"]})]})]})]})]}),A]})}function uQ({path:a}){let b=(0,bB.withWs)(`/api/assets/${a}`),c=a.split("/").pop()||a,d=c.includes(".")?c.split(".").pop()?.toUpperCase():"",e=async()=>{try{await (0,bB.wsFetch)("/api/system/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})}catch{}};return(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsx)(ea,{path:a,badge:d||void 0}),(0,g.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,g.jsxs)("div",{className:"flex flex-col items-center gap-4 text-center max-w-sm",children:[(0,g.jsx)("div",{className:"flex size-16 items-center justify-center rounded-2xl bg-muted",children:(0,g.jsx)(cb,{className:"size-8 text-muted-foreground/50"})}),(0,g.jsxs)("div",{className:"space-y-1",children:[(0,g.jsx)("p",{className:"text-sm font-medium",children:c}),(0,g.jsx)("p",{className:"text-xs text-muted-foreground",children:"This file type can't be previewed in Cabinet."})]}),(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsxs)(v.Button,{variant:"outline",size:"sm",className:"gap-2",onClick:e,children:[(0,g.jsx)(a5,{className:"h-4 w-4"}),"Open in Finder"]}),(0,g.jsxs)(v.Button,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>{let a=document.createElement("a");a.href=b,a.download=c,a.click()},children:[(0,g.jsx)(b8.Download,{className:"h-4 w-4"}),"Download"]})]})]})})]})}let uR=(0,h.default)("file-warning",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);function uS({path:a,size:b,onOpen:c}){let d=(0,bB.withWs)(`/api/assets/${a}`),e=a.split("/").pop()||a,f=e.includes(".")?e.split(".").pop()?.toUpperCase():"",h=async()=>{try{await (0,bB.wsFetch)("/api/system/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})}catch{}};return(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsx)(ea,{path:a,badge:f||void 0}),(0,g.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,g.jsxs)("div",{className:"flex flex-col items-center gap-4 text-center max-w-sm",children:[(0,g.jsx)("div",{className:"flex size-16 items-center justify-center rounded-2xl bg-amber-500/10",children:(0,g.jsx)(uR,{className:"size-8 text-amber-500"})}),(0,g.jsxs)("div",{className:"space-y-1",children:[(0,g.jsx)("p",{className:"text-sm font-medium",children:e}),(0,g.jsxs)("p",{className:"text-xs text-muted-foreground",children:["This file is ",b>=0x40000000?`${(b/0x40000000).toFixed(1)} GB`:b>=1048576?`${(b/1048576).toFixed(1)} MB`:b>=1024?`${Math.round(b/1024)} KB`:`${b} B`,". Opening it in the viewer may freeze the tab while it loads and renders."]})]}),(0,g.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[(0,g.jsx)(v.Button,{variant:"default",size:"sm",className:"gap-2",onClick:c,children:"Open anyway"}),(0,g.jsxs)(v.Button,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>window.open(d,"_blank"),children:[(0,g.jsx)(bE,{className:"h-4 w-4"}),"Raw"]}),(0,g.jsxs)(v.Button,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>{let a=document.createElement("a");a.href=d,a.download=e,a.click()},children:[(0,g.jsx)(b8.Download,{className:"h-4 w-4"}),"Download"]}),(0,g.jsxs)(v.Button,{variant:"outline",size:"sm",className:"gap-2",onClick:h,children:[(0,g.jsx)(a5,{className:"h-4 w-4"}),"Open in Finder"]})]})]})})]})}function uT({path:a,title:b}){let c=(0,bB.withWs)(`/api/assets/${a}`),d=a.split("/").pop()||a,e=d.includes(".")?d.split(".").pop()?.toUpperCase():"IMG";return(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsxs)(ea,{path:a,badge:e,children:[(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let a=document.createElement("a");a.href=c,a.download=d,a.click()},children:[(0,g.jsx)(b8.Download,{className:"h-3.5 w-3.5"}),"Download"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(c,"_blank"),children:[(0,g.jsx)(bE,{className:"h-3.5 w-3.5"}),"Open in new tab"]})]}),(0,g.jsx)("div",{className:"flex-1 overflow-auto flex items-center justify-center bg-[#1a1a1a] p-8",children:(0,g.jsx)("img",{src:c,alt:b,className:"max-w-full max-h-full object-contain rounded-md shadow-lg",style:{imageRendering:"auto"}})})]})}function uU({path:a,type:b}){let c=(0,bB.withWs)(`/api/assets/${a}`),d=a.split("/").pop()||a,e=d.includes(".")?d.split(".").pop()?.toUpperCase():b.toUpperCase();return(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsxs)(ea,{path:a,badge:e,children:[(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let a=document.createElement("a");a.href=c,a.download=d,a.click()},children:[(0,g.jsx)(b8.Download,{className:"h-3.5 w-3.5"}),"Download"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(c,"_blank"),children:[(0,g.jsx)(bE,{className:"h-3.5 w-3.5"}),"Open in new tab"]})]}),(0,g.jsx)("div",{className:"flex-1 overflow-auto flex items-center justify-center bg-[#1a1a1a] p-8",children:"video"===b?(0,g.jsx)("video",{src:c,controls:!0,className:"max-w-full max-h-full rounded-md shadow-lg",children:"Your browser does not support the video element."}):(0,g.jsxs)("div",{className:"w-full max-w-lg space-y-4",children:[(0,g.jsx)("div",{className:"text-center text-muted-foreground text-sm",children:d}),(0,g.jsx)("audio",{src:c,controls:!0,className:"w-full",children:"Your browser does not support the audio element."})]})})]})}function uV({path:b,title:c}){let[d,e]=(0,p.useState)(""),[f,h]=(0,p.useState)(""),[i,j]=(0,p.useState)(""),[k,l]=(0,p.useState)(!0),[m,n]=(0,p.useState)(!1),[o,q]=(0,p.useState)(!1),s=(0,p.useRef)(0),t=(0,bB.withWs)(`/api/assets/${b}`);b.split("/").pop();let u=(0,p.useCallback)(async()=>{l(!0),j("");try{let b=await (0,bB.wsFetch)(t);if(!b.ok)throw Error("Failed to fetch file");let c=await b.text();e(c);let d=(await a.A(334743)).default;d.initialize({startOnLoad:!1,theme:document.documentElement.classList.contains("dark")?"dark":"default",securityLevel:"loose",suppressErrorRendering:!0}),await d.parse(c.trim());let f=`mermaid-${++s.current}`,{svg:g}=await d.render(f,c.trim());h(g)}catch(a){document.querySelectorAll('[id^="dmermaid-"], [id^="d"]:has(> .error-icon)').forEach(a=>a.remove()),j(a instanceof Error?a.message:"Failed to render diagram")}finally{l(!1)}},[t]);return(0,p.useEffect)(()=>{u()},[u]),(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsxs)(ea,{path:b,badge:"MERMAID",children:[(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:`h-7 gap-1.5 text-xs ${m?"bg-muted":""}`,onClick:()=>n(a=>!a),children:[m?(0,g.jsx)(dO.Eye,{className:"h-3.5 w-3.5"}):(0,g.jsx)(d1,{className:"h-3.5 w-3.5"}),m?"Diagram":"Code"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{navigator.clipboard.writeText(d),q(!0),setTimeout(()=>q(!1),2e3)},children:[o?(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,g.jsx)(bd.Copy,{className:"h-3.5 w-3.5"}),o?"Copied":"Copy"]}),f&&(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{if(!f)return;let a=new Blob([f],{type:"image/svg+xml"}),b=URL.createObjectURL(a),d=document.createElement("a");d.href=b,d.download=`${c}.svg`,d.click(),URL.revokeObjectURL(b)},children:[(0,g.jsx)(b8.Download,{className:"h-3.5 w-3.5"}),"SVG"]})]}),(0,g.jsx)("div",{className:"flex-1 overflow-auto",children:k?(0,g.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Rendering diagram..."}):m?(0,g.jsx)("pre",{className:"p-4 text-[13px] leading-relaxed font-mono bg-[#1e1e1e]",children:(0,g.jsx)("code",{children:d.split("\n").map((a,b)=>(0,g.jsxs)("div",{className:"flex",children:[(0,g.jsx)("span",{className:"inline-block w-12 pr-4 text-right text-[#858585] select-none shrink-0",children:b+1}),(0,g.jsx)("span",{className:"text-[#d4d4d4] flex-1",children:a||"\n"})]},b))})}):i?(0,g.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-sm p-8",children:[(0,g.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,g.jsx)("div",{className:"h-10 w-10 rounded-full bg-red-500/10 flex items-center justify-center",children:(0,g.jsx)(d1,{className:"h-5 w-5 text-red-500"})}),(0,g.jsx)("p",{className:"text-red-500 font-medium",children:"Diagram syntax error"})]}),(0,g.jsx)("pre",{className:"text-muted-foreground text-xs max-w-lg text-left bg-muted rounded-md p-3 overflow-auto whitespace-pre-wrap",children:i}),(0,g.jsx)(v.Button,{variant:"outline",size:"sm",onClick:()=>n(!0),children:"View source to fix"})]}):(0,g.jsx)(tb,{svg:f,className:"w-full h-full"})})]})}var uW=a.i(855814),uX="[0-9](_*[0-9])*",uY=`\\.(${uX})`,uZ="[0-9a-fA-F](_*[0-9a-fA-F])*",u$={className:"number",variants:[{begin:`(\\b(${uX})((${uY})|\\.)?|(${uY}))[eE][+-]?(${uX})[fFdD]?\\b`},{begin:`\\b(${uX})((${uY})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${uY})[fFdD]?\\b`},{begin:`\\b(${uX})[fFdD]\\b`},{begin:`\\b0[xX]((${uZ})\\.?|(${uZ})?\\.(${uZ}))[pP][+-]?(${uX})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${uZ})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0},u_="[0-9](_*[0-9])*",u0=`\\.(${u_})`,u1="[0-9a-fA-F](_*[0-9a-fA-F])*",u2={className:"number",variants:[{begin:`(\\b(${u_})((${u0})|\\.)?|(${u0}))[eE][+-]?(${u_})[fFdD]?\\b`},{begin:`\\b(${u_})((${u0})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${u0})[fFdD]?\\b`},{begin:`\\b(${u_})[fFdD]\\b`},{begin:`\\b0[xX]((${u1})\\.?|(${u1})?\\.(${u1}))[pP][+-]?(${u_})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${u1})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};let u3=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video","defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],u4=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),u5=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),u6=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),u7=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse(),u8=u5.concat(u6).sort().reverse(),u9=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video","defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],va=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),vb=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),vc=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),vd=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function ve(a){return a?"string"==typeof a?a:a.source:null}function vf(a){return vg("(?=",a,")")}function vg(...a){return a.map(a=>ve(a)).join("")}function vh(...a){let b;return"("+(("object"==typeof(b=a[a.length-1])&&b.constructor===Object?(a.splice(a.length-1,1),b):{}).capture?"":"?:")+a.map(a=>ve(a)).join("|")+")"}let vi=a=>vg(/\b/,a,/\w$/.test(a)?/\b/:/\B/),vj=["Protocol","Type"].map(vi),vk=["init","self"].map(vi),vl=["Any","Self"],vm=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],vn=["false","nil","true"],vo=["assignment","associativity","higherThan","left","lowerThan","none","right"],vp=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],vq=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],vr=vh(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),vs=vh(vr,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),vt=vg(vr,vs,"*"),vu=vh(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),vv=vh(vu,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),vw=vg(vu,vv,"*"),vx=vg(/[A-Z]/,vv,"*"),vy=["attached","autoclosure",vg(/convention\(/,vh("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",vg(/objc\(/,vw,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],vz=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"],vA={arduino:function(a){let b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r=(b=a.regex,c=a.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),e="[a-zA-Z_]\\w*::",f="(?!struct)("+(d="decltype\\(auto\\)")+"|"+b.optional(e)+"[a-zA-Z_]\\w*"+b.optional("<[^<>]+>")+")",g={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},h={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[a.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},a.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},i={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},j={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},a.inherit(h,{className:"string"}),{className:"string",begin:/<.*?>/},c,a.C_BLOCK_COMMENT_MODE]},k={className:"title",begin:b.optional(e)+a.IDENT_RE,relevance:0},l=b.optional(e)+a.IDENT_RE+"\\s*\\(",p={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:m={type:["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],keyword:["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"]},contains:(o=[n={className:"function.dispatch",relevance:0,keywords:{_hint:["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"]},begin:b.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,a.IDENT_RE,b.lookahead(/(<[^<>]+>|)\s*\(/))},j,g,c,a.C_BLOCK_COMMENT_MODE,i,h]).concat([{begin:/\(/,end:/\)/,keywords:m,contains:o.concat(["self"]),relevance:0}]),relevance:0},q={className:"function",begin:"("+f+"[\\*&\\s]+)+"+l,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:m,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:d,keywords:m,relevance:0},{begin:l,returnBegin:!0,contains:[k],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[h,i]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:[c,a.C_BLOCK_COMMENT_MODE,h,i,g,{begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:["self",c,a.C_BLOCK_COMMENT_MODE,h,i,g]}]},g,c,a.C_BLOCK_COMMENT_MODE,j]},{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:m,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(p,q,n,o,[j,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:m,contains:["self",g]},{begin:a.IDENT_RE+"::",keywords:m},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}),s=r.keywords;return s.type=[...s.type,"boolean","byte","word","String"],s.literal=[...s.literal,"DIGITAL_MESSAGE","FIRMATA_STRING","ANALOG_MESSAGE","REPORT_DIGITAL","REPORT_ANALOG","INPUT_PULLUP","SET_PIN_MODE","INTERNAL2V56","SYSTEM_RESET","LED_BUILTIN","INTERNAL1V1","SYSEX_START","INTERNAL","EXTERNAL","DEFAULT","OUTPUT","INPUT","HIGH","LOW"],s.built_in=[...s.built_in,"KeyboardController","MouseController","SoftwareSerial","EthernetServer","EthernetClient","LiquidCrystal","RobotControl","GSMVoiceCall","EthernetUDP","EsploraTFT","HttpClient","RobotMotor","WiFiClient","GSMScanner","FileSystem","Scheduler","GSMServer","YunClient","YunServer","IPAddress","GSMClient","GSMModem","Keyboard","Ethernet","Console","GSMBand","Esplora","Stepper","Process","WiFiUDP","GSM_SMS","Mailbox","USBHost","Firmata","PImage","Client","Server","GSMPIN","FileIO","Bridge","Serial","EEPROM","Stream","Mouse","Audio","Servo","File","Task","GPRS","WiFi","Wire","TFT","GSM","SPI","SD"],s._hints=["setup","loop","runShellCommandAsynchronously","analogWriteResolution","retrieveCallingNumber","printFirmwareVersion","analogReadResolution","sendDigitalPortPair","noListenOnLocalhost","readJoystickButton","setFirmwareVersion","readJoystickSwitch","scrollDisplayRight","getVoiceCallStatus","scrollDisplayLeft","writeMicroseconds","delayMicroseconds","beginTransmission","getSignalStrength","runAsynchronously","getAsynchronously","listenOnLocalhost","getCurrentCarrier","readAccelerometer","messageAvailable","sendDigitalPorts","lineFollowConfig","countryNameWrite","runShellCommand","readStringUntil","rewindDirectory","readTemperature","setClockDivider","readLightSensor","endTransmission","analogReference","detachInterrupt","countryNameRead","attachInterrupt","encryptionType","readBytesUntil","robotNameWrite","readMicrophone","robotNameRead","cityNameWrite","userNameWrite","readJoystickY","readJoystickX","mouseReleased","openNextFile","scanNetworks","noInterrupts","digitalWrite","beginSpeaker","mousePressed","isActionDone","mouseDragged","displayLogos","noAutoscroll","addParameter","remoteNumber","getModifiers","keyboardRead","userNameRead","waitContinue","processInput","parseCommand","printVersion","readNetworks","writeMessage","blinkVersion","cityNameRead","readMessage","setDataMode","parsePacket","isListening","setBitOrder","beginPacket","isDirectory","motorsWrite","drawCompass","digitalRead","clearScreen","serialEvent","rightToLeft","setTextSize","leftToRight","requestFrom","keyReleased","compassRead","analogWrite","interrupts","WiFiServer","disconnect","playMelody","parseFloat","autoscroll","getPINUsed","setPINUsed","setTimeout","sendAnalog","readSlider","analogRead","beginWrite","createChar","motorsStop","keyPressed","tempoWrite","readButton","subnetMask","debugPrint","macAddress","writeGreen","randomSeed","attachGPRS","readString","sendString","remotePort","releaseAll","mouseMoved","background","getXChange","getYChange","answerCall","getResult","voiceCall","endPacket","constrain","getSocket","writeJSON","getButton","available","connected","findUntil","readBytes","exitValue","readGreen","writeBlue","startLoop","IPAddress","isPressed","sendSysex","pauseMode","gatewayIP","setCursor","getOemKey","tuneWrite","noDisplay","loadImage","switchPIN","onRequest","onReceive","changePIN","playFile","noBuffer","parseInt","overflow","checkPIN","knobRead","beginTFT","bitClear","updateIR","bitWrite","position","writeRGB","highByte","writeRed","setSpeed","readBlue","noStroke","remoteIP","transfer","shutdown","hangCall","beginSMS","endWrite","attached","maintain","noCursor","checkReg","checkPUK","shiftOut","isValid","shiftIn","pulseIn","connect","println","localIP","pinMode","getIMEI","display","noBlink","process","getBand","running","beginSD","drawBMP","lowByte","setBand","release","bitRead","prepare","pointTo","readRed","setMode","noFill","remove","listen","stroke","detach","attach","noTone","exists","buffer","height","bitSet","circle","config","cursor","random","IRread","setDNS","endSMS","getKey","micros","millis","begin","print","write","ready","flush","width","isPIN","blink","clear","press","mkdir","rmdir","close","point","yield","image","BSSID","click","delay","read","text","move","peek","beep","rect","line","open","seek","fill","size","turn","stop","home","find","step","tone","sqrt","RSSI","SSID","end","bit","tan","cos","sin","pow","map","abs","max","min","get","run","put"],r.name="Arduino",r.aliases=["ino"],r.supersetOf="cpp",r},bash:sk,c:function(a){let b=a.regex,c=a.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),d="decltype\\(auto\\)",e="[a-zA-Z_]\\w*::",f="("+d+"|"+b.optional(e)+"[a-zA-Z_]\\w*"+b.optional("<[^<>]+>")+")",g={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},h={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[a.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},a.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},i={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},j={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},a.inherit(h,{className:"string"}),{className:"string",begin:/<.*?>/},c,a.C_BLOCK_COMMENT_MODE]},k={className:"title",begin:b.optional(e)+a.IDENT_RE,relevance:0},l=b.optional(e)+a.IDENT_RE+"\\s*\\(",m={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},n=[j,g,c,a.C_BLOCK_COMMENT_MODE,i,h],o={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:m,contains:n.concat([{begin:/\(/,end:/\)/,keywords:m,contains:n.concat(["self"]),relevance:0}]),relevance:0},p={begin:"("+f+"[\\*&\\s]+)+"+l,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:m,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:d,keywords:m,relevance:0},{begin:l,returnBegin:!0,contains:[a.inherit(k,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:[c,a.C_BLOCK_COMMENT_MODE,h,i,g,{begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:["self",c,a.C_BLOCK_COMMENT_MODE,h,i,g]}]},g,c,a.C_BLOCK_COMMENT_MODE,j]};return{name:"C",aliases:["h"],keywords:m,disableAutodetect:!0,illegal:"</",contains:[].concat(o,p,n,[j,{begin:a.IDENT_RE+"::",keywords:m},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},a.TITLE_MODE]}]),exports:{preprocessor:j,strings:h,keywords:m}}},cpp:function(a){let b=a.regex,c=a.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),d="decltype\\(auto\\)",e="[a-zA-Z_]\\w*::",f="(?!struct)("+d+"|"+b.optional(e)+"[a-zA-Z_]\\w*"+b.optional("<[^<>]+>")+")",g={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},h={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[a.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},a.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},i={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},j={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},a.inherit(h,{className:"string"}),{className:"string",begin:/<.*?>/},c,a.C_BLOCK_COMMENT_MODE]},k={className:"title",begin:b.optional(e)+a.IDENT_RE,relevance:0},l=b.optional(e)+a.IDENT_RE+"\\s*\\(",m={type:["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],keyword:["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"]},n={className:"function.dispatch",relevance:0,keywords:{_hint:["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"]},begin:b.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,a.IDENT_RE,b.lookahead(/(<[^<>]+>|)\s*\(/))},o=[n,j,g,c,a.C_BLOCK_COMMENT_MODE,i,h],p={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:m,contains:o.concat([{begin:/\(/,end:/\)/,keywords:m,contains:o.concat(["self"]),relevance:0}]),relevance:0},q={className:"function",begin:"("+f+"[\\*&\\s]+)+"+l,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:m,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:d,keywords:m,relevance:0},{begin:l,returnBegin:!0,contains:[k],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[h,i]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:[c,a.C_BLOCK_COMMENT_MODE,h,i,g,{begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:["self",c,a.C_BLOCK_COMMENT_MODE,h,i,g]}]},g,c,a.C_BLOCK_COMMENT_MODE,j]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:m,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(p,q,n,o,[j,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:m,contains:["self",g]},{begin:a.IDENT_RE+"::",keywords:m},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}},csharp:function(a){let b={keyword:["abstract","as","base","break","case","catch","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","scoped","sealed","sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"].concat(["add","alias","and","ascending","args","async","await","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value|0","var","when","where","with","yield"]),built_in:["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],literal:["default","false","null","true"]},c=a.inherit(a.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),d={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},e={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},f=a.inherit(e,{illegal:/\n/}),g={className:"subst",begin:/\{/,end:/\}/,keywords:b},h=a.inherit(g,{illegal:/\n/}),i={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},a.BACKSLASH_ESCAPE,h]},j={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},g]},k=a.inherit(j,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},h]});g.contains=[j,i,e,a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,d,a.C_BLOCK_COMMENT_MODE],h.contains=[k,i,f,a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,d,a.inherit(a.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];let l={variants:[{className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},j,i,e,a.APOS_STRING_MODE,a.QUOTE_STRING_MODE]},m={begin:"<",end:">",contains:[{beginKeywords:"in out"},c]},n=a.IDENT_RE+"(<"+a.IDENT_RE+"(\\s*,\\s*"+a.IDENT_RE+")*>)?(\\[\\])?",o={begin:"@"+a.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:b,illegal:/::/,contains:[a.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:"<!--|-->"},{begin:"</?",end:">"}]}]}),a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},l,d,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},c,m,a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[c,a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[c,m,a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+n+"\\s+)+"+a.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:b,contains:[{beginKeywords:"public private protected static internal protected abstract async extern override unsafe virtual new sealed partial",relevance:0},{begin:a.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[a.TITLE_MODE,m],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:b,relevance:0,contains:[l,d,a.C_BLOCK_COMMENT_MODE]},a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE]},o]}},css:sq,diff:function(a){let b=a.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:b.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:b.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}},go:sr,graphql:function(a){let b=a.regex;return{name:"GraphQL",aliases:["gql"],case_insensitive:!0,disableAutodetect:!1,keywords:{keyword:["query","mutation","subscription","type","input","schema","directive","interface","union","scalar","fragment","enum","on"],literal:["true","false","null"]},contains:[a.HASH_COMMENT_MODE,a.QUOTE_STRING_MODE,a.NUMBER_MODE,{scope:"punctuation",match:/[.]{3}/,relevance:0},{scope:"punctuation",begin:/[\!\(\)\:\=\[\]\{\|\}]{1}/,relevance:0},{scope:"variable",begin:/\$/,end:/\W/,excludeEnd:!0,relevance:0},{scope:"meta",match:/@\w+/,excludeEnd:!0},{scope:"symbol",begin:b.concat(/[_A-Za-z][_0-9A-Za-z]*/,b.lookahead(/\s*:/)),relevance:0}],illegal:[/[;<']/,/BEGIN/]}},ini:function(a){let b=a.regex,c={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:a.NUMBER_RE}]},d=a.COMMENT();d.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];let e={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},f={className:"literal",begin:/\bon|off|true|false|yes|no\b/},g={className:"string",contains:[a.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},h=b.either(/[A-Za-z0-9_-]+/,/"(\\"|[^"])*"/,/'[^']*'/);return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[d,{className:"section",begin:/\[+/,end:/\]+/},{begin:b.concat(h,"(\\s*\\.\\s*",h,")*",b.lookahead(/\s*=\s*[^#\s]/)),className:"attr",starts:{end:/$/,contains:[d,{begin:/\[/,end:/\]/,contains:[d,f,e,g,c,"self"],relevance:0},f,e,g,c]}}]}},java:function(a){let b=a.regex,c="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",d=c+function a(b,c,d){return -1===d?"":b.replace(c,e=>a(b,c,d-1))}("(?:<"+c+"~~~(?:\\s*,\\s*"+c+"~~~)*>)?",/~~~/g,2),e={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},f={className:"meta",begin:"@"+c,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},g={className:"params",begin:/\(/,end:/\)/,keywords:e,relevance:0,contains:[a.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:e,illegal:/<\/|#/,contains:[a.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[a.BACKSLASH_ESCAPE]},a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,c],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[b.concat(/(?!else)/,c),/\s+/,c,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,c],className:{1:"keyword",3:"title.class"},contains:[g,a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+d+"\\s+)",a.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:e,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:e,relevance:0,contains:[f,a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,u$,a.C_BLOCK_COMMENT_MODE]},a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE]},u$,f]}},javascript:sA,json:sB,kotlin:function(a){let b={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},c={className:"symbol",begin:a.UNDERSCORE_IDENT_RE+"@"},d={className:"subst",begin:/\$\{/,end:/\}/,contains:[a.C_NUMBER_MODE]},e={className:"variable",begin:"\\$"+a.UNDERSCORE_IDENT_RE},f={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[e,d]},{begin:"'",end:"'",illegal:/\n/,contains:[a.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[a.BACKSLASH_ESCAPE,e,d]}]};d.contains.push(f);let g={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+a.UNDERSCORE_IDENT_RE+")?"},h={className:"meta",begin:"@"+a.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[a.inherit(f,{className:"string"}),"self"]}]},i=a.COMMENT("/\\*","\\*/",{contains:[a.C_BLOCK_COMMENT_MODE]}),j={variants:[{className:"type",begin:a.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]};return j.variants[1].contains=[j],j.variants[1].contains=[j],{name:"Kotlin",aliases:["kt","kts"],keywords:b,contains:[a.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),a.C_LINE_COMMENT_MODE,i,{className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},c,g,h,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:b,relevance:5,contains:[{begin:a.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[a.UNDERSCORE_TITLE_MODE]},{className:"type",begin:/</,end:/>/,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:b,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[j,a.C_LINE_COMMENT_MODE,i],relevance:0},a.C_LINE_COMMENT_MODE,i,g,h,f,a.C_NUMBER_MODE]},i]},{begin:[/class|interface|trait/,/\s+/,a.UNDERSCORE_IDENT_RE],beginScope:{3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},a.UNDERSCORE_TITLE_MODE,{className:"type",begin:/</,end:/>/,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},g,h]},f,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:"\n"},u2]}},less:function(a){let b={IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:a.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[a.APOS_STRING_MODE,a.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:a.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}},c="[\\w-]+",d="("+c+"|@\\{"+c+"\\})",e=[],f=[],g=function(a){return{className:"string",begin:"~?"+a+".*?"+a}},h=function(a,b,c){return{className:a,begin:b,relevance:c}},i={$pattern:/[a-z-]+/,keyword:"and or not only",attribute:u4.join(" ")};f.push(a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,g("'"),g('"'),b.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},b.HEXCOLOR,{begin:"\\(",end:"\\)",contains:f,keywords:i,relevance:0},h("variable","@@?"+c,10),h("variable","@\\{"+c+"\\}"),h("built_in","~?`[^`]*?`"),{className:"attribute",begin:c+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},b.IMPORTANT,{beginKeywords:"and not"},b.FUNCTION_DISPATCH);let j=f.concat({begin:/\{/,end:/\}/,contains:e}),k={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(f)},l={begin:d+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},b.CSS_VARIABLE,{className:"attribute",begin:"\\b("+u7.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:f}}]},m={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:d,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:"[<='$\"]",relevance:0,contains:[a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,k,h("keyword","all\\b"),h("variable","@\\{"+c+"\\}"),{begin:"\\b("+u3.join("|")+")\\b",className:"selector-tag"},b.CSS_NUMBER_MODE,h("selector-tag",d,0),h("selector-id","#"+d),h("selector-class","\\."+d,0),h("selector-tag","&",0),b.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+u5.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+u6.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:j},{begin:"!important"},b.FUNCTION_DISPATCH]},n={begin:c+":(:)?"+`(${u8.join("|")})`,returnBegin:!0,contains:[m]};return e.push(a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,{className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:i,returnEnd:!0,contains:f,relevance:0}},{className:"variable",variants:[{begin:"@"+c+"\\s*:",relevance:15},{begin:"@"+c}],starts:{end:"[;}]",returnEnd:!0,contains:j}},n,l,m,k,b.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:"[=>'/<($\"]",contains:e}},lua:function(a){let b="\\[=*\\[",c="\\]=*\\]",d={begin:b,end:c,contains:["self"]},e=[a.COMMENT("--(?!"+b+")","$"),a.COMMENT("--"+b,c,{contains:[d],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:a.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:e.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[a.inherit(a.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:e}].concat(e)},a.C_NUMBER_MODE,a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,{className:"string",begin:b,end:c,contains:[d],relevance:5}])}},makefile:function(a){let b={className:"variable",variants:[{begin:"\\$\\("+a.UNDERSCORE_IDENT_RE+"\\)",contains:[a.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},c={className:"string",begin:/"/,end:/"/,contains:[a.BACKSLASH_ESCAPE,b]},d={begin:"^"+a.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"};return{name:"Makefile",aliases:["mk","mak","make"],keywords:{$pattern:/[\w-]+/,keyword:"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath"},contains:[a.HASH_COMMENT_MODE,b,c,{className:"variable",begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value"},contains:[b,c]},d,{className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},{className:"section",begin:/^[^\s]+:/,end:/$/,contains:[b]}]}},markdown:sC,objectivec:function(a){let b=/[a-zA-Z@][a-zA-Z0-9_]*/,c={$pattern:b,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:{"variable.language":["this","super"],$pattern:b,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},illegal:"</",contains:[{className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,a.C_NUMBER_MODE,a.QUOTE_STRING_MODE,a.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[a.BACKSLASH_ESCAPE]}]},{className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},a.inherit(a.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+c.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:c,contains:[a.UNDERSCORE_TITLE_MODE]},{begin:"\\."+a.UNDERSCORE_IDENT_RE,relevance:0}]}},perl:function(a){let b=a.regex,c=/[dualxmsipngr]{0,12}/,d={$pattern:/[\w.]+/,keyword:"abs accept alarm and atan2 bind binmode bless break caller chdir chmod chomp chop chown chr chroot class close closedir connect continue cos crypt dbmclose dbmopen defined delete die do dump each else elsif endgrent endhostent endnetent endprotoent endpwent endservent eof eval exec exists exit exp fcntl field fileno flock for foreach fork format formline getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr getnetbyname getnetent getpeername getpgrp getpriority getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport getservent getsockname getsockopt given glob gmtime goto grep gt hex if index int ioctl join keys kill last lc lcfirst length link listen local localtime log lstat lt ma map method mkdir msgctl msgget msgrcv msgsnd my ne next no not oct open opendir or ord our pack package pipe pop pos print printf prototype push q|0 qq quotemeta qw qx rand read readdir readline readlink readpipe recv redo ref rename require reset return reverse rewinddir rindex rmdir say scalar seek seekdir select semctl semget semop send setgrent sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split sprintf sqrt srand stat state study sub substr symlink syscall sysopen sysread sysseek system syswrite tell telldir tie tied time times tr truncate uc ucfirst umask undef unless unlink unpack unshift untie until use utime values vec wait waitpid wantarray warn when while write x|0 xor y|0"},e={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:d},f={begin:/->\{/,end:/\}/},g={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},h={scope:"variable",variants:[{begin:/\$\d/},{begin:b.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[g]},i={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},j=[a.BACKSLASH_ESCAPE,e,h],k=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],l=(a,d,e="\\1")=>{let f="\\1"===e?e:b.concat(e,d);return b.concat(b.concat("(?:",a,")"),d,/(?:\\.|[^\\\/])*?/,f,/(?:\\.|[^\\\/])*?/,e,c)},m=(a,d,e)=>b.concat(b.concat("(?:",a,")"),d,/(?:\\.|[^\\\/])*?/,e,c),n=[h,a.HASH_COMMENT_MODE,a.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),f,{className:"string",contains:j,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[a.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[a.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},i,{begin:"(\\/\\/|"+a.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[a.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:l("s|tr|y",b.either(...k,{capture:!0}))},{begin:l("s|tr|y","\\(","\\)")},{begin:l("s|tr|y","\\[","\\]")},{begin:l("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:m("(?:m|qr)?",/\//,/\//)},{begin:m("m|qr",b.either(...k,{capture:!0}),/\1/)},{begin:m("m|qr",/\(/,/\)/)},{begin:m("m|qr",/\[/,/\]/)},{begin:m("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[a.TITLE_MODE,g]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[a.TITLE_MODE,g,i]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return e.contains=n,f.contains=n,{name:"Perl",aliases:["pl","pm"],keywords:d,contains:n}},php:function(a){let b,c=a.regex,d=/(?![A-Za-z0-9])(?![$])/,e=c.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,d),f=c.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,d),g=c.concat(/[A-Z]+/,d),h={scope:"variable",match:"\\$+"+e},i={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},j=a.inherit(a.APOS_STRING_MODE,{illegal:null}),k=a.inherit(a.QUOTE_STRING_MODE,{illegal:null,contains:a.QUOTE_STRING_MODE.contains.concat(i)}),l={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:a.QUOTE_STRING_MODE.contains.concat(i),"on:begin":(a,b)=>{b.data._beginMatch=a[1]||a[2]},"on:end":(a,b)=>{b.data._beginMatch!==a[1]&&b.ignoreMatch()}},m=a.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),n="[ \n]",o={scope:"string",variants:[k,j,l,m]},p={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},q=["false","null","true"],r=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],s=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],t={keyword:r,literal:(b=[],q.forEach(a=>{b.push(a),a.toLowerCase()===a?b.push(a.toUpperCase()):b.push(a.toLowerCase())}),b),built_in:s},u=a=>a.map(a=>a.replace(/\|\d+$/,"")),v={variants:[{match:[/new/,c.concat(n,"+"),c.concat("(?!",u(s).join("\\b|"),"\\b)"),f],scope:{1:"keyword",4:"title.class"}}]},w=c.concat(e,"\\b(?!\\()"),x={variants:[{match:[c.concat(/::/,c.lookahead(/(?!class\b)/)),w],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[f,c.concat(/::/,c.lookahead(/(?!class\b)/)),w],scope:{1:"title.class",3:"variable.constant"}},{match:[f,c.concat("::",c.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[f,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},y={scope:"attr",match:c.concat(e,c.lookahead(":"),c.lookahead(/(?!::)/))},z={relevance:0,begin:/\(/,end:/\)/,keywords:t,contains:[y,h,x,a.C_BLOCK_COMMENT_MODE,o,p,v]},A={relevance:0,match:[/\b/,c.concat("(?!fn\\b|function\\b|",u(r).join("\\b|"),"|",u(s).join("\\b|"),"\\b)"),e,c.concat(n,"*"),c.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[z]};z.contains.push(A);let B=[y,x,a.C_BLOCK_COMMENT_MODE,o,p,v],C={begin:c.concat(/#\[\s*\\?/,c.either(f,g)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:q,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:q,keyword:["new","array"]},contains:["self",...B]},...B,{scope:"meta",variants:[{match:f},{match:g}]}]};return{case_insensitive:!1,keywords:t,contains:[C,a.HASH_COMMENT_MODE,a.COMMENT("//","$"),a.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:a.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},{scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},{scope:"variable.language",match:/\$this\b/},h,A,x,{match:[/const/,/\s/,e],scope:{1:"keyword",3:"variable.constant"}},v,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},a.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:t,contains:["self",C,h,x,a.C_BLOCK_COMMENT_MODE,o,p]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},a.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[a.inherit(a.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},a.UNDERSCORE_TITLE_MODE]},o,p]}},"php-template":function(a){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},a.inherit(a.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),a.inherit(a.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}},plaintext:function(a){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}},python:sD,"python-repl":function(a){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}},r:function(a){let b=a.regex,c=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,d=b.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),e=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,f=b.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:c,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[a.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:b.lookahead(b.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:c},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),a.HASH_COMMENT_MODE,{scope:"string",contains:[a.BACKSLASH_ESCAPE],variants:[a.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),a.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),a.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),a.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),a.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),a.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[e,d]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,d]},{scope:{1:"punctuation",2:"number"},match:[f,d]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,d]}]},{scope:{3:"operator"},match:[c,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:e},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:f},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}},ruby:function(a){let b=a.regex,c="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",d=b.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),e=b.concat(d,/(::\w+)*/),f={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield","include","extend","prepend","public","private","protected","raise","throw"],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},g={className:"doctag",begin:"@[A-Za-z]+"},h={begin:"#<",end:">"},i=[a.COMMENT("#","$",{contains:[g]}),a.COMMENT("^=begin","^=end",{contains:[g],relevance:10}),a.COMMENT("^__END__",a.MATCH_NOTHING_RE)],j={className:"subst",begin:/#\{/,end:/\}/,keywords:f},k={className:"string",contains:[a.BACKSLASH_ESCAPE,j],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:b.concat(/<<[-~]?'?/,b.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[a.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[a.BACKSLASH_ESCAPE,j]})]}]},l="[0-9](_?[0-9])*",m={className:"number",relevance:0,variants:[{begin:`\\b([1-9](_?[0-9])*|0)(\\.(${l}))?([eE][+-]?(${l})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},n={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:f}]},o=[k,{variants:[{match:[/class\s+/,e,/\s+<\s+/,e]},{match:[/\b(class|module)\s+/,e]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:f},{match:[/(include|extend)\s+/,e],scope:{2:"title.class"},keywords:f},{relevance:0,match:[e,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:d,scope:"title.class"},{match:[/def/,/\s+/,c],scope:{1:"keyword",3:"title.function"},contains:[n]},{begin:a.IDENT_RE+"::"},{className:"symbol",begin:a.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[k,{begin:c}],relevance:0},m,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:f},{begin:"("+a.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[a.BACKSLASH_ESCAPE,j],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(h,i),relevance:0}].concat(h,i);j.contains=o,n.contains=o;let p=[{begin:/^\s*=>/,starts:{end:"$",contains:o}},{className:"meta.prompt",begin:"^([>?]>|[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]|(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>)(?=[ ])",starts:{end:"$",keywords:f,contains:o}}];return i.unshift(h),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:f,illegal:/\/\*/,contains:[a.SHEBANG({binary:"ruby"})].concat(p).concat(i).concat(o)}},rust:sE,scss:function(a){let b={IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:a.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[a.APOS_STRING_MODE,a.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:a.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}},c="@[a-z-]+",d={className:"variable",begin:"(\\$[a-zA-Z-][a-zA-Z0-9_-]*)\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,b.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},b.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+u9.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+vb.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+vc.join("|")+")"},d,{begin:/\(/,end:/\)/,contains:[b.CSS_NUMBER_MODE]},b.CSS_VARIABLE,{className:"attribute",begin:"\\b("+vd.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[b.BLOCK_COMMENT,d,b.HEXCOLOR,b.CSS_NUMBER_MODE,a.QUOTE_STRING_MODE,a.APOS_STRING_MODE,b.IMPORTANT,b.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:c,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:"and or not only",attribute:va.join(" ")},contains:[{begin:c,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},d,a.QUOTE_STRING_MODE,a.APOS_STRING_MODE,b.HEXCOLOR,b.CSS_NUMBER_MODE]},b.FUNCTION_DISPATCH]}},shell:sF,sql:sG,swift:function(a){let b={match:/\s+/,relevance:0},c=a.COMMENT("/\\*","\\*/",{contains:["self"]}),d=[a.C_LINE_COMMENT_MODE,c],e={match:[/\./,vh(...vj,...vk)],className:{2:"keyword"}},f={match:vg(/\./,vh(...vm)),relevance:0},g=vm.filter(a=>"string"==typeof a).concat(["_|0"]),h={variants:[{className:"keyword",match:vh(...vm.filter(a=>"string"!=typeof a).concat(vl).map(vi),...vk)}]},i={$pattern:vh(/\b\w+/,/#\w+/),keyword:g.concat(vp),literal:vn},j=[e,f,h],k=[{match:vg(/\./,vh(...vq)),relevance:0},{className:"built_in",match:vg(/\b/,vh(...vq),/(?=\()/)}],l={match:/->/,relevance:0},m=[l,{className:"operator",relevance:0,variants:[{match:vt},{match:`\\.(\\.|${vs})+`}]}],n="([0-9]_*)+",o="([0-9a-fA-F]_*)+",p={className:"number",relevance:0,variants:[{match:`\\b(${n})(\\.(${n}))?([eE][+-]?(${n}))?\\b`},{match:`\\b0x(${o})(\\.(${o}))?([pP][+-]?(${n}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},q=(a="")=>({className:"subst",variants:[{match:vg(/\\/,a,/[0\\tnr"']/)},{match:vg(/\\/,a,/u\{[0-9a-fA-F]{1,8}\}/)}]}),r=(a="")=>({className:"subst",label:"interpol",begin:vg(/\\/,a,/\(/),end:/\)/}),s=(a="")=>({begin:vg(a,/"""/),end:vg(/"""/,a),contains:[q(a),((a="")=>({className:"subst",match:vg(/\\/,a,/[\t ]*(?:[\r\n]|\r\n)/)}))(a),r(a)]}),t=(a="")=>({begin:vg(a,/"/),end:vg(/"/,a),contains:[q(a),r(a)]}),u={className:"string",variants:[s(),s("#"),s("##"),s("###"),t(),t("#"),t("##"),t("###")]},v=[a.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[a.BACKSLASH_ESCAPE]}],w=a=>{let b=vg(a,/\//),c=vg(/\//,a);return{begin:b,end:c,contains:[...v,{scope:"comment",begin:`#(?!.*${c})`,end:/$/}]}},x={scope:"regexp",variants:[w("###"),w("##"),w("#"),{begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:v}]},y={match:vg(/`/,vw,/`/)},z=[y,{className:"variable",match:/\$\d+/},{className:"variable",match:`\\$${vv}+`}],A=[{match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:vz,contains:[...m,p,u]}]}},{scope:"keyword",match:vg(/@/,vh(...vy),vf(vh(/\(/,/\s+/)))},{scope:"meta",match:vg(/@/,vw)}],B={match:vf(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:vg(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,vv,"+")},{className:"type",match:vx,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:vg(/\s+&\s+/,vf(vx)),relevance:0}]},C={begin:/</,end:/>/,keywords:i,contains:[...d,...j,...A,l,B]};B.contains.push(C);let D={begin:/\(/,end:/\)/,relevance:0,keywords:i,contains:["self",{match:vg(vw,/\s*:/),keywords:"_|0",relevance:0},...d,x,...j,...k,...m,p,u,...z,...A,B]},E={begin:/</,end:/>/,keywords:"repeat each",contains:[...d,B]},F={begin:/\(/,end:/\)/,keywords:i,contains:[{begin:vh(vf(vg(vw,/\s*:/)),vf(vg(vw,/\s+/,vw,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:vw}]},...d,...j,...m,p,u,...A,B,D],endsParent:!0,illegal:/["']/},G={match:[/(func|macro)/,/\s+/,vh(y.match,vw,vt)],className:{1:"keyword",3:"title.function"},contains:[E,F,b],illegal:[/\[/,/%/]},H={begin:[/precedencegroup/,/\s+/,vx],className:{1:"keyword",3:"title"},contains:[B],keywords:[...vo,...vn],end:/}/},I={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,vw,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:i,contains:[E,...j,{begin:/:/,end:/\{/,keywords:i,contains:[{scope:"title.class.inherited",match:vx},...j],relevance:0}]};for(let a of u.variants){let b=a.contains.find(a=>"interpol"===a.label);b.keywords=i;let c=[...j,...k,...m,p,u,...z];b.contains=[...c,{begin:/\(/,end:/\)/,contains:["self",...c]}]}return{name:"Swift",keywords:i,contains:[...d,G,{match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[E,F,b],illegal:/\[|%/},{match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},{match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},I,{match:[/operator/,/\s+/,vt],className:{1:"keyword",3:"title"}},H,{beginKeywords:"import",end:/$/,contains:[...d],relevance:0},x,...j,...k,...m,p,u,...z,...A,B,D]}},typescript:sP,vbnet:function(a){let b=a.regex,c=/\d{1,2}\/\d{1,2}\/\d{4}/,d=/\d{4}-\d{1,2}-\d{1,2}/,e=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,f=/\d{1,2}(:\d{1,2}){1,2}/,g={className:"literal",variants:[{begin:b.concat(/# */,b.either(d,c),/ *#/)},{begin:b.concat(/# */,f,/ *#/)},{begin:b.concat(/# */,e,/ *#/)},{begin:b.concat(/# */,b.either(d,c),/ +/,b.either(e,f),/ *#/)}]},h=a.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),i=a.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[{className:"string",begin:/"(""|[^/n])"C\b/},{className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},g,{className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},{className:"label",begin:/^\w+:/},h,i,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[i]}]}},wasm:function(a){a.regex;let b=a.COMMENT(/\(;/,/;\)/);return b.contains.push("self"),{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"]},contains:[a.COMMENT(/;;/,/$/),b,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},{className:"variable",begin:/\$[\w_]+/},{match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},{begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},a.QUOTE_STRING_MODE,{match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},{className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/},{className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/}]}},xml:sQ,yaml:sR},vB=sV(vA);function vC(a){return Array.isArray(a)?a.join(""):a??""}let vD=/\x1b\[[0-9;]*[A-Za-z]/g;function vE(a){return a.replace(vD,"")}function vF({output:a}){if("stream"===a.output_type){let b=vE(vC(a.text)),c="stderr"===a.name;return(0,g.jsx)("pre",{className:`whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md ${c?"bg-[rgba(139,46,62,0.06)] text-[#8B2E3E]":"bg-[#F5EEDC] text-[#2A221B]"}`,children:b})}if("error"===a.output_type){let b=a.traceback.map(vE).join("\n");return(0,g.jsxs)("pre",{className:"whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md bg-[rgba(139,46,62,0.08)] text-[#8B2E3E] border border-[rgba(139,46,62,0.18)]",children:[(0,g.jsxs)("span",{className:"font-semibold",children:[a.ename,": ",a.evalue]}),b?`
169
169
 
170
- ${b}`:""]})}let b=a.data||{};if(b["image/png"]){let a=`data:image/png;base64,${vB(b["image/png"]).replace(/\s/g,"")}`;return(0,g.jsx)("img",{src:a,alt:"output",className:"max-w-full rounded-md bg-card p-2"})}if(b["image/jpeg"]){let a=`data:image/jpeg;base64,${vB(b["image/jpeg"]).replace(/\s/g,"")}`;return(0,g.jsx)("img",{src:a,alt:"output",className:"max-w-full rounded-md bg-card p-2"})}if(b["image/svg+xml"]){let a=vB(b["image/svg+xml"]);return(0,g.jsx)("div",{className:"max-w-full rounded-md bg-card p-2 overflow-auto",dangerouslySetInnerHTML:{__html:a}})}if(b["text/html"]){let a=vB(b["text/html"]);return(0,g.jsx)("iframe",{srcDoc:`<!doctype html><html><head><base target="_blank"><style>body{margin:0;padding:8px;font-family:-apple-system,BlinkMacSystemFont,Inter,system-ui,sans-serif;background:#FFF9E9;color:#2A221B;font-size:13px}table{border-collapse:collapse}th,td{border:1px solid #D4C4B0;padding:4px 8px;text-align:left}thead{background:#EFE5CC}</style></head><body>${a}</body></html>`,sandbox:"allow-scripts",className:"w-full bg-[#FFF9E9] rounded-md border border-[#E8DDC5]",style:{height:360}})}return b["text/plain"]?(0,g.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md bg-[#F5EEDC] text-[#2A221B]",children:vD(vB(b["text/plain"]))}):null}function vF({cell:a,language:b}){let c=vB(a.source),d=(0,p.useMemo)(()=>(function(a,b){try{let c=b?vA.highlight(b,a):vA.highlightAuto(a);return(0,uV.toHtml)(c)}catch{return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}})(c,b),[c,b]),e=a.execution_count??" ",f=(a.outputs?.length??0)>0;return(0,g.jsxs)("div",{className:"grid grid-cols-[60px_1fr] gap-3 mb-5",children:[(0,g.jsxs)("div",{className:"text-right pt-3 select-none font-mono text-[11px] text-[#8B5E3C]",children:["In [",e,"]:"]}),(0,g.jsxs)("div",{children:[(0,g.jsx)("pre",{className:"whitespace-pre overflow-x-auto font-mono text-[13px] leading-relaxed px-4 py-3 rounded-md bg-[#FFF9E9] border border-[#E8DDC5] text-[#2A221B]",children:(0,g.jsx)("code",{dangerouslySetInnerHTML:{__html:d}})}),f&&(0,g.jsxs)("div",{className:"mt-2 grid grid-cols-[60px_1fr] gap-3",children:[(0,g.jsxs)("div",{className:"text-right pt-3 select-none font-mono text-[11px] text-[#8B2E3E]",children:["Out[",e,"]:"]}),(0,g.jsx)("div",{className:"space-y-2",children:a.outputs?.map((a,b)=>(0,g.jsx)(vE,{output:a},b))})]})]})]})}function vG({cell:a}){let[b,c]=(0,p.useState)("");return(0,p.useEffect)(()=>{let b=!1;return(0,np.markdownToHtml)(vB(a.source)).then(a=>{b||c(a)}),()=>{b=!0}},[a.source]),(0,g.jsx)("div",{className:"prose prose-sm max-w-none mb-5 px-1 [&_h1]:font-serif [&_h2]:font-serif [&_h3]:font-serif [&_a]:text-[#8B5E3C] [&_a:hover]:underline [&_code]:bg-[#F5EEDC] [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:rounded [&_code]:text-[#8B2E3E]",dangerouslySetInnerHTML:{__html:b}})}function vH({cell:a}){return(0,g.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md bg-[#F5EEDC] text-[#2A221B] mb-5",children:vB(a.source)})}function vI({path:a}){let[b,c]=(0,p.useState)(null),[d,e]=(0,p.useState)(!0),[f,h]=(0,p.useState)(null),[i,j]=(0,p.useState)(!1),k=(0,bB.withWs)(`/api/assets/${a}`),l=a.split("/").pop()||a,m=(0,p.useCallback)(async()=>{e(!0),h(null);try{let a=await (0,bB.wsFetch)(k);if(!a.ok)throw Error(`HTTP ${a.status}`);let b=await a.json();c(b)}catch(a){h(a instanceof Error?a.message:"Failed to load notebook")}finally{e(!1)}},[k]);(0,p.useEffect)(()=>{m()},[m]);let n=b?.metadata?.language_info?.name||b?.metadata?.kernelspec?.name||"python",o=b?.cells?.length??0,s=b?.cells?.filter(a=>"code"===a.cell_type).length??0,t=b?.cells?.some(a=>"code"===a.cell_type&&(a.outputs?.length??0)>0)??!1;return(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsxs)(ea,{path:a,badge:"IPYNB",sublabel:`${o} cells \xb7 ${s} code \xb7 ${n}`,children:[(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{navigator.clipboard.writeText(`jupyter lab ${a}`),j(!0),setTimeout(()=>j(!1),2e3)},title:"Copy: jupyter lab <path>",children:[i?(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,g.jsx)(bd.Copy,{className:"h-3.5 w-3.5"}),i?"Copied":"Copy run cmd"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let a=document.createElement("a");a.href=k,a.download=l,a.click()},children:[(0,g.jsx)(b8.Download,{className:"h-3.5 w-3.5"}),"Download"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(k,"_blank"),children:[(0,g.jsx)(bE,{className:"h-3.5 w-3.5"}),"Raw JSON"]})]}),(0,g.jsx)("div",{className:"flex-1 overflow-auto bg-[#F5EEDC]",children:d?(0,g.jsx)("div",{className:"flex items-center justify-center h-full text-[#7A6B5D] text-sm",children:"Loading notebook…"}):f?(0,g.jsxs)("div",{className:"flex items-center justify-center h-full text-[#8B2E3E] text-sm gap-2",children:[(0,g.jsx)(q.AlertCircle,{className:"h-4 w-4"})," ",f]}):b?(0,g.jsxs)("div",{className:"max-w-[1100px] mx-auto py-8 px-6",children:[!t&&s>0&&(0,g.jsxs)("div",{className:"mb-6 rounded-md border border-[#E8DDC5] bg-[#FFF9E9] px-4 py-3 text-[13px] text-[#7A6B5D]",children:[(0,g.jsx)("span",{className:"font-semibold text-[#0c0a09]",children:"This notebook hasn't been run yet."})," ","Code and markdown cells display below; outputs appear once the author runs the notebook in Jupyter (or you do, then re-save)."]}),b.cells?.map((a,b)=>"markdown"===a.cell_type?(0,g.jsx)(vG,{cell:a},b):"raw"===a.cell_type?(0,g.jsx)(vH,{cell:a},b):(0,g.jsx)(vF,{cell:a,language:n},b))]}):null})]})}function vJ({path:a,extLabel:b,external:c,hideFinder:d}){let e=(0,bB.withWs)(`/api/assets/${a}`),f=a.split("/").pop()||a,h=async()=>{try{await (0,bB.wsFetch)("/api/system/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})}catch{}};return(0,g.jsxs)(ea,{path:a,badge:b||void 0,children:[c&&(0,g.jsxs)("a",{href:c.href,target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-center gap-1.5 text-[11px] h-7 px-2.5 rounded-md border border-border hover:bg-accent transition-colors",children:[(0,g.jsx)(bE,{className:"h-3.5 w-3.5"}),c.label]}),!d&&(0,g.jsxs)(v.Button,{variant:"outline",size:"sm",className:"gap-1.5 text-[11px] h-7",onClick:h,title:"Open in Finder",children:[(0,g.jsx)(a5,{className:"h-3.5 w-3.5"}),"Reveal"]}),!d&&(0,g.jsxs)(v.Button,{variant:"outline",size:"sm",className:"gap-1.5 text-[11px] h-7",onClick:()=>{let a=document.createElement("a");a.href=e,a.download=f,a.click()},title:"Download original",children:[(0,g.jsx)(b8.Download,{className:"h-3.5 w-3.5"}),"Download"]})]})}function vK({path:b,title:c}){let d=(0,p.useRef)(null),[e,f]=(0,p.useState)(!0),[h,i]=(0,p.useState)(null);return(0,p.useEffect)(()=>{let c=!1,e=d.current;if(e)return e.innerHTML="",(async()=>{f(!0),i(null);try{let[{renderAsync:d},g]=await Promise.all([a.A(458647),(0,bB.wsFetch)(`/api/assets/${b}`)]);if(c)return;if(!g.ok)throw Error(`Failed to load file (${g.status})`);let h=await g.blob();if(c)return;await d(h,e,void 0,{className:"docx-rendered",inWrapper:!0,ignoreWidth:!1,ignoreHeight:!1,breakPages:!0,renderHeaders:!0,renderFooters:!0,renderFootnotes:!0,experimental:!0,useBase64URL:!0}),c||f(!1)}catch(a){c||(i(a instanceof Error?a.message:"Failed to render document"),f(!1))}})(),()=>{c=!0}},[b]),(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsx)(vJ,{path:b,title:c,extLabel:"DOCX"}),(0,g.jsxs)("div",{className:"flex-1 overflow-y-auto bg-muted/30",children:[e&&!h&&(0,g.jsxs)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:[(0,g.jsx)(m.Loader2,{className:"h-5 w-5 animate-spin mr-2"}),"Rendering document…"]}),h&&(0,g.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,g.jsxs)("div",{className:"text-center space-y-2",children:[(0,g.jsx)("p",{className:"text-sm text-destructive",children:h}),(0,g.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try downloading the file and opening it externally."})]})}),(0,g.jsx)("div",{ref:d,className:"docx-viewer-body mx-auto max-w-5xl py-6 px-4"})]})]})}function vL({path:b,title:c}){let d=(0,p.useRef)(null),[e,f]=(0,p.useState)(!0),[h,i]=(0,p.useState)(null);return(0,p.useEffect)(()=>{let c=!1,e=d.current;if(!e)return;e.innerHTML="";let g=null;return(async()=>{f(!0),i(null);try{let[{init:d},h]=await Promise.all([a.A(287443),(0,bB.wsFetch)(`/api/assets/${b}`)]);if(c)return;if(!h.ok)throw Error(`Failed to load file (${h.status})`);let i=await h.arrayBuffer();if(c)return;let j=e.clientWidth||960,k=Math.round(9*j/16);g=d(e,{width:j,height:k,mode:"list"}),await g.preview(i),c||f(!1)}catch(a){c||(i(a instanceof Error?a.message:"Failed to render presentation"),f(!1))}})(),()=>{c=!0;try{g?.destroy?.()}catch{}}},[b]),(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsx)(vJ,{path:b,title:c,extLabel:"PPTX"}),(0,g.jsxs)("div",{className:"flex-1 overflow-auto bg-muted/30 py-4",children:[e&&!h&&(0,g.jsxs)("div",{className:"h-[60vh] flex items-center justify-center text-muted-foreground",children:[(0,g.jsx)(m.Loader2,{className:"h-5 w-5 animate-spin mr-2"}),"Rendering slides…"]}),h&&(0,g.jsx)("div",{className:"h-[60vh] flex items-center justify-center",children:(0,g.jsxs)("div",{className:"text-center space-y-2",children:[(0,g.jsx)("p",{className:"text-sm text-destructive",children:h}),(0,g.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try downloading the file and opening it externally."})]})}),(0,g.jsx)("div",{ref:d,className:"pptx-viewer-body mx-auto max-w-5xl px-4"})]})]})}function vM({path:b,title:c}){let[d,e]=(0,p.useState)(null),[f,h]=(0,p.useState)(0),[i,j]=(0,p.useState)(!0),[k,l]=(0,p.useState)(null),n=(0,p.useRef)(null);(0,p.useEffect)(()=>{if(!d||!n.current)return;let a=d[f];if(!a||null!==a.html)return;let{wb:b,toHtml:c}=n.current,g=c(b.Sheets[a.name]);e(a=>{if(!a)return a;let b=[...a];return b[f]={...b[f],html:g.html,rows:g.rows,truncated:g.truncated},b})},[d,f]),(0,p.useEffect)(()=>{let c=!1;return j(!0),l(null),e(null),(async()=>{try{let[d,f]=await Promise.all([a.A(57386),(0,bB.wsFetch)(`/api/assets/${b}`)]);if(c)return;if(!f.ok)throw Error(`Failed to load file (${f.status})`);let g=await f.arrayBuffer();if(c)return;let i=d.read(g,{type:"array",cellDates:!0,cellStyles:!0});if(c)return;n.current={wb:i,toHtml:a=>{let b=a["!ref"],c=b?d.utils.decode_range(b):null,e=c?c.e.r-c.s.r+1:0;if(!c||e<=2e3)return{html:d.utils.sheet_to_html(a,{editable:!1}),rows:e,truncated:!1};let f={...a,"!ref":d.utils.encode_range({s:c.s,e:{r:c.s.r+2e3-1,c:c.e.c}})};return{html:d.utils.sheet_to_html(f,{editable:!1}),rows:e,truncated:!0}}},e(i.SheetNames.map(a=>({name:a,html:null,rows:0,truncated:!1}))),h(0),j(!1)}catch(a){c||(l(a instanceof Error?a.message:"Failed to parse spreadsheet"),j(!1))}})(),()=>{c=!0}},[b]);let o=(0,p.useMemo)(()=>d?.[f]??null,[d,f]);return(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsx)(vJ,{path:b,title:c,extLabel:"XLSX"}),d&&d.length>1&&(0,g.jsx)("div",{className:"flex items-center gap-0.5 border-b border-border bg-muted/40 px-2 overflow-x-auto scrollbar-none",children:d.map((a,b)=>(0,g.jsx)("button",{type:"button",onClick:()=>h(b),className:(0,ao.cn)("px-3 py-1.5 text-[12px] rounded-t whitespace-nowrap transition-colors",b===f?"bg-background text-foreground font-medium border-t border-x border-border -mb-px":"text-muted-foreground hover:text-foreground"),children:a.name},a.name+b))}),(0,g.jsxs)("div",{className:"flex-1 overflow-auto",children:[i&&!k&&(0,g.jsxs)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:[(0,g.jsx)(m.Loader2,{className:"h-5 w-5 animate-spin mr-2"}),"Parsing spreadsheet…"]}),k&&(0,g.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,g.jsxs)("div",{className:"text-center space-y-2",children:[(0,g.jsx)("p",{className:"text-sm text-destructive",children:k}),(0,g.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try downloading the file and opening it externally."})]})}),o?.truncated&&(0,g.jsxs)("div",{className:"px-3 py-2 text-[11px] text-amber-600 dark:text-amber-400 border-b border-border",children:["Large sheet (",o.rows.toLocaleString()," rows). Showing first"," ",2e3.toLocaleString()," for performance. Download the file to see everything."]}),o?.html!=null&&(0,g.jsx)("div",{className:"xlsx-sheet p-3 text-[12px]",dangerouslySetInnerHTML:{__html:o.html}})]})]})}let vN=(0,h.default)("wrap-text",[["path",{d:"m16 16-2 2 2 2",key:"kkc6pm"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["path",{d:"M3 18h7",key:"sq21v6"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]),vO=sV(vz);function vP(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function vQ(a){return`${a.lineStart}:${a.lineEnd}:${a.textHash}`}function vR(a){return`L${a.lineStart}-${a.lineEnd}`}async function vS(a){return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(a)))).map(a=>a.toString(16).padStart(2,"0")).join("").slice(0,12)}let vT={".js":"javascript",".cjs":"javascript",".mjs":"javascript",".ts":"typescript",".tsx":"typescript",".jsx":"javascript",".py":"python",".rb":"ruby",".php":"php",".sh":"bash",".bash":"bash",".zsh":"bash",".ps1":"powershell",".css":"css",".scss":"scss",".html":"xml",".json":"json",".jsonc":"json",".yaml":"yaml",".yml":"yaml",".toml":"ini",".ini":"ini",".xml":"xml",".sql":"sql",".graphql":"graphql",".gql":"graphql",".go":"go",".rs":"rust",".swift":"swift",".java":"java",".kt":"kotlin",".kts":"kotlin",".c":"c",".cpp":"cpp",".h":"c",".env":"bash",".txt":"",".text":"",".log":"",".rst":"",".mdx":"markdown"};function vU({path:a}){let[b,c]=(0,p.useState)(null),[d,e]=(0,p.useState)(0),[f,h]=(0,p.useState)(!1),[i,j]=(0,p.useState)(!0),[k,l]=(0,p.useState)(!1),[m,n]=(0,p.useState)(!1),[o,q]=(0,p.useState)(2e3),[s,t]=(0,p.useState)(new Map),[u,w]=(0,p.useState)(null),x=(0,p.useRef)(null),y=(0,bB.withWs)(`/api/assets/${a}`),z=a.split("/").pop()||a,A=vT[z.includes(".")?`.${z.split(".").pop()?.toLowerCase()}`:""]??"",B=oc(b=>b.byPath[a]?.sidecar??null),C=B?.comments??[],D=(0,p.useMemo)(()=>b?b.replace(/\r\n/g,"\n").split("\n"):[],[b]),E=(0,p.useCallback)(async()=>{j(!0),h(!1),c(null),e(0);try{let a=await (0,bB.wsFetch)(y);if(a.ok){let b=new Uint8Array(await a.arrayBuffer());!function(a){let b=Math.min(a.length,8192);if(0===b)return!1;let c=0;for(let d=0;d<b;d++){let b=a[d];if(0===b)return!0;(b<9||b>13&&b<32)&&c++}return c/b>.3}(b)?(e(b.length),c(new TextDecoder("utf-8").decode(b))):h(!0)}}catch{}finally{j(!1)}},[y]);(0,p.useEffect)(()=>{E(),oc.getState().loadSidecar(a),q(2e3),w(null)},[E,a]);let F=(0,p.useMemo)(()=>D.length,[D]),G=d>2097152||F>5e3,H=(0,p.useMemo)(()=>{if(!b)return[];if(G)return D.map(vP);try{let a=A?vO.highlight(A,b):vO.highlightAuto(b);return(0,uV.toHtml)(a).split("\n")}catch{return D.map(vP)}},[b,A,G,D]),I=G?H.slice(0,o):H,J=G&&o<H.length,K=(0,p.useMemo)(()=>{let a={};for(let b of C){if(!b.lineAnchor)continue;let c=vQ(b.lineAnchor);(a[c]??=[]).push(b)}return a},[C]);(0,p.useEffect)(()=>{if(!b||f||i||!x.current)return void t(new Map);let a=x.current,c=a.getBoundingClientRect(),d=Array.from(a.querySelectorAll("[data-line]")),e=new Map;for(let b of d){let d=Number(b.dataset.line);if(!Number.isFinite(d))continue;let f=b.getBoundingClientRect();e.set(d,{top:f.top-c.top+a.scrollTop,left:f.left-c.left,width:f.width,bottom:f.bottom-c.top+a.scrollTop})}t(e)},[b,f,i,o,k,H]);let L=(0,p.useCallback)(()=>{let a=x.current,b=window.getSelection();if(!a||!b||b.isCollapsed||0===b.rangeCount)return;let c=b.getRangeAt(0);if(!a.contains(c.commonAncestorContainer))return;let d=a=>{let b=a?a.nodeType===Node.ELEMENT_NODE?a:a.parentElement:null;return b?.closest("[data-line]")??null},e=d(c.startContainer),f=d(c.endContainer);if(!e||!f)return;let g=Number(e.dataset.line),h=Number(f.dataset.line);if(!Number.isFinite(g)||!Number.isFinite(h))return;let i=Math.min(g,h),j=Math.max(g,h),k=D.slice(i-1,j).join("\n");(async()=>{let a={lineStart:i,lineEnd:j,textHash:await vS(k)};w({anchorKey:vQ(a),anchorLabel:vR(a),lineAnchor:a,anchorEl:e})})()},[D]),M=(0,p.useCallback)((a,b)=>{w({anchorKey:vQ(a),anchorLabel:vR(a),lineAnchor:a,anchorEl:b})},[]);return f?(0,g.jsx)(uP,{path:a,title:z}):(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsxs)(ea,{path:a,badge:z.includes(".")?z.split(".").pop()?.toUpperCase()??"TEXT":"TEXT",children:[(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:`h-7 gap-1.5 text-xs ${k?"bg-muted":""}`,onClick:()=>l(a=>!a),title:k?"Disable line wrap":"Enable line wrap",children:[(0,g.jsx)(vN,{className:"h-3.5 w-3.5"}),"Wrap"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{b&&(navigator.clipboard.writeText(b),n(!0),setTimeout(()=>n(!1),2e3))},title:"Copy file contents",children:[m?(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,g.jsx)(bd.Copy,{className:"h-3.5 w-3.5"}),m?"Copied":"Copy"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let a=document.createElement("a");a.href=y,a.download=z,a.click()},title:"Download file",children:[(0,g.jsx)(b8.Download,{className:"h-3.5 w-3.5"}),"Download"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(y,"_blank"),children:[(0,g.jsx)(bE,{className:"h-3.5 w-3.5"}),"Raw"]})]}),(0,g.jsxs)("div",{ref:x,className:"relative flex-1 overflow-auto source-viewer-code bg-background",children:[!i&&b&&!f&&(0,g.jsx)(uM,{containerRef:x,onComment:L,align:"left"}),(0,g.jsx)("div",{className:"relative pointer-events-none",style:{height:0},children:Object.entries(K).map(([a,b])=>{let c=b[0]?.lineAnchor;if(!c)return null;let d=s.get(c.lineStart);return d?(0,g.jsx)("div",{style:{pointerEvents:"auto"},children:(0,g.jsx)(tw,{anchorKey:a,anchorLabel:vR(c),comments:b,top:d.top+4,left:Math.max(0,d.left-20),onClick:()=>{let a=x.current?.querySelector(`[data-line="${c.lineStart}"]`);a&&M(c,a)}})},`pip-${a}`):null})}),i?(0,g.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading..."}):(0,g.jsxs)(g.Fragment,{children:[G&&(0,g.jsxs)("div",{className:"px-4 py-2 text-[11px] text-amber-700 dark:text-amber-300 bg-amber-500/15 border-b border-amber-500/30 font-sans",children:["Large file (",(d/1048576).toFixed(1)," MB, ",H.length.toLocaleString()," lines). Syntax highlighting disabled for performance. Use Raw or Download for the full file."]}),(0,g.jsx)("div",{className:"leading-relaxed font-mono min-w-max",style:{fontSize:"calc(13px * var(--font-scale-code, 1))"},children:I.map((a,b)=>{let c=u?.lineAnchor,d=c&&b+1>=c.lineStart&&b+1<=c.lineEnd;return(0,g.jsxs)("div",{"data-line":b+1,className:`flex ${d?"bg-amber-400/25":"hover:bg-foreground/5"}`,children:[(0,g.jsx)("span",{className:"w-12 shrink-0 pr-4 text-right text-muted-foreground select-none sticky left-0 bg-muted",children:b+1}),(0,g.jsx)("span",{className:`text-foreground pl-2 ${k?"whitespace-pre-wrap break-all":"whitespace-pre"}`,dangerouslySetInnerHTML:{__html:a||" "}})]},b)})}),J&&(0,g.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-t border-border font-sans",children:[(0,g.jsxs)("button",{onClick:()=>q(a=>a+2e3),className:"text-[11px] text-foreground hover:text-foreground px-2.5 py-1 rounded bg-foreground/10 hover:bg-foreground/20 transition-colors",children:["Show ",Math.min(2e3,H.length-o).toLocaleString()," more"]}),(0,g.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[o.toLocaleString()," / ",H.length.toLocaleString()," lines"]})]})]}),u&&(0,g.jsx)(tX,{path:a,anchorKey:u.anchorKey,anchorLabel:u.anchorLabel,lineAnchor:u.lineAnchor,comments:K[u.anchorKey]??[],anchorEl:u.anchorEl,onClose:()=>w(null)})]})]})}var vV=a.i(360878),vW=a.i(211789);function vX({path:a,title:b,src:c,fullscreen:d,onExit:e,scriptsEnabled:f,onToggleScripts:h}){let[i,j]=(0,p.useState)(!1),k=f??i,l=(0,bB.withWs)(c??`/api/assets/${a}/index.html`),m=d&&e?(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:e,title:"Exit app",children:[(0,g.jsx)(uw,{className:"h-3.5 w-3.5"}),"Exit app"]}):null;return(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsxs)(ea,{path:a,badge:d?"App":void 0,showBreadcrumb:!d,leading:d?(0,g.jsxs)(g.Fragment,{children:[m,(0,g.jsx)("span",{className:"truncate text-[13px] font-medium text-foreground",children:b})]}):null,children:[(0,g.jsx)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:h??(()=>j(a=>!a)),title:k?"Disable scripts (recommended for untrusted content)":"Enable scripts",children:k?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(vW.Ban,{className:"h-3.5 w-3.5"}),"Disable scripts"]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(vV.Play,{className:"h-3.5 w-3.5"}),"Enable scripts"]})}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(l,"_blank"),children:[(0,g.jsx)(bE,{className:"h-3.5 w-3.5"}),"Open in new tab"]})]}),(0,g.jsx)("iframe",{src:l,className:"flex-1 w-full border-0 bg-card",title:b,sandbox:k?"allow-scripts allow-forms allow-popups allow-top-navigation-by-user-activation":"allow-forms allow-popups allow-top-navigation-by-user-activation"})]})}let vY=(0,h.default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),vZ={stopped:"Stopped",installing:"Installing dependencies…",starting:"Starting…",running:"Running",error:"Error"};function v$({path:a,title:b}){let[c,d]=(0,p.useState)("stopped"),[e,f]=(0,p.useState)(null),[h,i]=(0,p.useState)([]),[j,k]=(0,p.useState)(null),[l,n]=(0,p.useState)(!1),[o,r]=(0,p.useState)(0),[t,u]=(0,p.useState)([]),[w,x]=(0,p.useState)(null),y=(0,p.useRef)(null),z=(0,p.useRef)(null),A=(0,bB.withWs)(`/api/app-proxy/${a}/`),B=()=>{y.current&&(clearInterval(y.current),y.current=null)},C=(0,p.useCallback)(async()=>{try{let b=await (0,bB.wsFetch)(`/api/wiki/app?path=${encodeURIComponent(a)}`);if(!b.ok)return;let c=await b.json();d(c.status),i(c.logs??[]),c.scripts&&u(c.scripts),void 0!==c.defaultScript&&x(c.defaultScript),c.port&&f(c.port),c.error&&k(c.error),("running"===c.status||"stopped"===c.status||"error"===c.status)&&B()}catch{}},[a]);(0,p.useEffect)(()=>("installing"===c||"starting"===c?y.current||(y.current=setInterval(C,800)):B(),B),[c,C]),(0,p.useEffect)(()=>{z.current?.scrollIntoView({behavior:"smooth"})},[h]),(0,p.useEffect)(()=>{C()},[C]);let D=async b=>{k(null),i([]),d("starting");try{let c=await (0,bB.wsFetch)("/api/wiki/app",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a,script:b})}),e=await c.json();if(!c.ok||e.error){d("error"),k(e.error??"Failed to start");return}e.port&&f(e.port),await C()}catch(a){d("error"),k(String(a))}},E=async()=>{await (0,bB.wsFetch)("/api/wiki/app",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})}),d("stopped"),f(null)},F=async()=>{await E(),await D(),r(a=>a+1)},G=t.filter(a=>a!==w);return(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsxs)(ea,{path:a,badge:"Node app",children:["running"===c&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>r(a=>a+1),children:[(0,g.jsx)(bI,{className:"h-3.5 w-3.5"}),"Refresh"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(A,"_blank"),children:[(0,g.jsx)(bE,{className:"h-3.5 w-3.5"}),"Open in new tab"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:F,children:[(0,g.jsx)(bI,{className:"h-3.5 w-3.5"}),"Restart"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs text-destructive hover:text-destructive",onClick:E,children:[(0,g.jsx)(vY,{className:"h-3.5 w-3.5"}),"Stop"]})]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>n(a=>!a),children:[(0,g.jsx)(ce,{className:"h-3.5 w-3.5"}),"Logs"]})]}),l&&(0,g.jsxs)("div",{className:"border-b bg-black/90 text-green-400 font-mono text-xs h-40 overflow-auto p-2 shrink-0",children:[0===h.length?(0,g.jsx)("span",{className:"text-muted-foreground",children:"No output yet."}):h.map((a,b)=>(0,g.jsx)("div",{className:"whitespace-pre-wrap leading-5",children:a},b)),(0,g.jsx)("div",{ref:z})]}),(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:["stopped"===c&&(0,g.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-4",children:[(0,g.jsxs)("div",{className:"text-center space-y-1",children:[(0,g.jsx)("p",{className:"text-sm font-medium",children:b}),(0,g.jsx)("p",{className:"text-xs text-muted-foreground",children:"Node.js app — will be started on a local port"})]}),(0,g.jsxs)("div",{className:"inline-flex items-stretch overflow-hidden rounded-full bg-primary text-primary-foreground shadow-e-1",children:[(0,g.jsxs)("button",{type:"button",onClick:()=>D(),className:"inline-flex items-center gap-2 px-4 py-2.5 text-sm font-medium transition-colors hover:bg-primary-foreground/10 focus-visible:outline-none",children:[(0,g.jsx)(vV.Play,{className:"h-4 w-4"}),"Launch app",w&&(0,g.jsxs)("span",{className:"opacity-70",children:["(",w,")"]})]}),G.length>0&&(0,g.jsxs)(ax.DropdownMenu,{children:[(0,g.jsx)(ax.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsx)("button",{type:"button",className:"inline-flex items-center justify-center border-l border-l-primary-foreground/20 px-2 transition-colors hover:bg-primary-foreground/10 focus-visible:outline-none","aria-label":"Choose script to launch",children:(0,g.jsx)(s,{className:"h-4 w-4"})})}),(0,g.jsxs)(ax.DropdownMenuContent,{align:"end",children:[(0,g.jsx)(ax.DropdownMenuLabel,{children:"Run script"}),(0,g.jsx)(ax.DropdownMenuSeparator,{}),t.map(a=>(0,g.jsxs)(ax.DropdownMenuItem,{onSelect:()=>D(a),className:"gap-2 font-mono text-xs",children:[(0,g.jsx)(vV.Play,{className:"h-3.5 w-3.5"}),a,a===w&&(0,g.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"default"})]},a))]})]})]})]}),("installing"===c||"starting"===c)&&(0,g.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3",children:[(0,g.jsx)(m.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"}),(0,g.jsx)("p",{className:"text-sm text-muted-foreground",children:vZ[c]}),e&&(0,g.jsxs)("p",{className:"text-xs text-muted-foreground/60",children:["port ",e]}),(0,g.jsxs)(v.Button,{onClick:E,variant:"outline",size:"sm",className:"gap-2",children:[(0,g.jsx)(vY,{className:"h-3.5 w-3.5"}),"Cancel"]})]}),"error"===c&&(0,g.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-6",children:[(0,g.jsx)(q.AlertCircle,{className:"h-8 w-8 text-destructive"}),(0,g.jsxs)("div",{className:"text-center space-y-1 max-w-md",children:[(0,g.jsx)("p",{className:"text-sm font-medium text-destructive",children:"Failed to start app"}),(0,g.jsx)("p",{className:"text-xs text-muted-foreground break-words",children:j??"Unknown error"})]}),(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsx)(v.Button,{onClick:E,variant:"ghost",className:"gap-2",children:"Back"}),(0,g.jsxs)(v.Button,{onClick:F,variant:"outline",className:"gap-2",children:[(0,g.jsx)(bI,{className:"h-4 w-4"}),"Try again"]})]})]}),"running"===c&&(0,g.jsx)("iframe",{src:A,className:"flex-1 w-full border-0 bg-card",title:b,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-top-navigation-by-user-activation"},o)]})]})}let v_=(0,d6.default)(async()=>{},{loadableGenerated:{modules:[904378]},ssr:!1});function v0(a){let b=new Date(a).getTime();if(!Number.isFinite(b))return"";let c=Math.floor(Math.max(0,Date.now()-b)/1e3);if(c<60)return"just now";let d=Math.floor(c/60);if(d<60)return`${d}m ago`;let e=Math.floor(d/60);return e<24?`${e}h ago`:`${Math.floor(e/24)}d ago`}let v1=new Set(["image","media","pdf","fallback","app","node-app","html"]);function v2({openFile:a,fileContent:b,fileLoading:c,editing:d,setEditing:e,editContent:f,setEditContent:h,saving:i,saveError:n,onSave:q,gitFileInfo:s,showHistory:t,historyLoading:u,historyCommits:w,selectedDiffSha:x,diffContent:y,diffLoading:z,onToggleHistory:A,onSelectDiff:B,gateBypassPath:C,onBypassGate:D,onRefresh:E,onShare:F,onClose:G,renderCopyMenu:H,appKey:I,setAppKey:J,appFullscreen:K,setAppFullscreen:L,viewerKey:M,setViewerKey:N,htmlSourceMode:O,setHtmlSourceMode:P,widthAwareViewer:Q,viewWidth:R,viewAlign:S,setViewWidth:T,setViewAlign:U,contentWidthClass:V,contentAlignClass:W,isMobile:X,sidebarCollapsed:Y}){let[Z,$]=(0,p.useState)(null),[_,aa]=(0,p.useState)(null),[ab,ac]=(0,p.useState)(!1);(0,p.useEffect)(()=>{ac(!1)},[a.path]);let ad=cL(a.name,a.nodeType),ae=!v1.has(ad)&&(a.size??0)>5242880&&C!==a.path;if("node-app"===ad)return(0,g.jsx)(v$,{path:a.path,title:a.name});let af="html"===ad?(0,bB.withWs)(`/api/assets/${a.path}`):void 0;return"app"===ad||"html"===ad?K?(0,g.jsx)(vX,{scriptsEnabled:ab,onToggleScripts:()=>ac(a=>!a),path:a.path,title:a.name,src:af,fullscreen:!0,onExit:()=>L(!1)}):(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,g.jsxs)("div",{className:(0,ao.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 ",!X&&Y&&"pl-11"),children:[(0,g.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,g.jsx)("span",{className:"hidden md:inline-flex",children:(0,g.jsx)("span",{className:"",children:(0,g.jsx)(k,{className:"h-4 w-4 shrink-0 text-foreground/70"})})}),(0,g.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:a.path,children:a.path}),(0,g.jsx)("div",{ref:a=>{a&&aa(a)},className:"flex items-center gap-1 shrink-0"})]}),(0,g.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,g.jsx)("div",{ref:a=>{a&&$(a)},className:"flex items-center gap-1 shrink-0"}),H(a,(0,g.jsxs)(g.Fragment,{children:["html"===ad&&!d&&(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>P(!O),children:[O?(0,g.jsx)(k,{className:"mr-2 h-3.5 w-3.5"}):(0,g.jsx)(d1,{className:"mr-2 h-3.5 w-3.5"}),O?"Show preview":"Show source"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>J(a=>a+1),children:[(0,g.jsx)(bI,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>L(!0),children:[(0,g.jsx)(d2,{className:"mr-2 h-3.5 w-3.5"}),"Open fullscreen"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:F,children:[(0,g.jsx)(d4,{className:"mr-2 h-3.5 w-3.5"}),"Share"]})]})),"html"===ad&&!d&&null!==b&&(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Edit source",onClick:()=>{e(!0),h(b)},children:(0,g.jsx)(d3,{className:"h-3.5 w-3.5"})}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:G,children:(0,g.jsx)(o,{className:"h-3.5 w-3.5"})})]})]}),d&&"html"===ad?(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[(0,g.jsx)("textarea",{value:f,onChange:a=>h(a.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"}),(0,g.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[n&&(0,g.jsx)("span",{className:"text-xs text-destructive mr-auto",children:n}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",onClick:()=>e(!1),children:"Cancel"}),(0,g.jsxs)(v.Button,{size:"sm",className:"gap-1",onClick:q,disabled:i,children:[i&&(0,g.jsx)(m.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):O&&"html"===ad?(0,g.jsx)(d9.Provider,{value:_,children:(0,g.jsx)(d8.Provider,{value:Z,children:(0,g.jsx)(vU,{path:a.path,title:a.name})})}):(0,g.jsx)(d9.Provider,{value:_,children:(0,g.jsx)(d8.Provider,{value:Z,children:(0,g.jsx)(vX,{scriptsEnabled:ab,onToggleScripts:()=>ac(a=>!a),path:a.path,title:a.name,src:af},I)})})]}):(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,g.jsxs)("div",{className:(0,ao.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 ",!X&&Y&&"pl-11"),children:[(0,g.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,g.jsx)("span",{className:"hidden md:inline-flex",children:(0,g.jsx)("span",{className:"",children:cP(a.name)?(0,g.jsx)(l,{className:"h-4 w-4 shrink-0 text-sunshine-700"}):cN(a.name)?(0,g.jsx)(j.FileText,{className:"h-4 w-4 shrink-0 text-foreground/70"}):(0,g.jsx)(cb,{className:"h-4 w-4 shrink-0 text-foreground/60"})})}),(0,g.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:a.path,children:a.path}),(0,g.jsx)("div",{ref:a=>{a&&aa(a)},className:"flex items-center gap-1 shrink-0"}),s&&(0,g.jsxs)("span",{className:"hidden md:flex items-center gap-1 text-[11px] text-muted-foreground shrink-0 ml-1",children:[(0,g.jsx)(d5,{className:"h-3 w-3 shrink-0"}),(0,g.jsx)("span",{className:"truncate max-w-[100px]",children:s.author}),(0,g.jsx)("span",{title:new Date(s.date).toLocaleString(),className:"shrink-0",children:v0(s.date)})]})]}),(0,g.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,g.jsx)("div",{ref:a=>{a&&$(a)},className:"flex items-center gap-1 shrink-0"}),H(a,(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ax.DropdownMenuItem,{onClick:A,children:[(0,g.jsx)(dQ,{className:"mr-2 h-3.5 w-3.5"}),t?"Hide history":"File history"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:F,children:[(0,g.jsx)(d4,{className:"mr-2 h-3.5 w-3.5"}),"Share"]}),!d&&(0,g.jsxs)(ax.DropdownMenuItem,{onClick:E,disabled:c,children:[c?(0,g.jsx)(m.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,g.jsx)(bI,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),Q&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ax.DropdownMenuSeparator,{}),(0,g.jsx)(ax.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Width"}),dK.VIEW_WIDTH_ORDER.map(a=>(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>T(a),className:"flex items-center justify-between text-xs",children:[dK.VIEW_WIDTH_LABEL[a],a===R&&(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5"})]},a)),(0,g.jsx)(ax.DropdownMenuSeparator,{}),(0,g.jsx)(ax.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Alignment"}),dK.VIEW_ALIGN_ORDER.map(a=>(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>U(a),className:"flex items-center justify-between text-xs",children:[dK.VIEW_ALIGN_LABEL[a],a===S&&(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5"})]},a))]})]})),cN(a.name)&&!d&&(null!==b||cO(a.name))&&(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{e(!0),h(b??"")},children:(0,g.jsx)(d3,{className:"h-3.5 w-3.5"})}),cN(a.name)&&d&&cO(a.name)&&(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Done editing",onClick:()=>e(!1),children:(0,g.jsx)(dO.Eye,{className:"h-3.5 w-3.5"})}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:G,children:(0,g.jsx)(o,{className:"h-3.5 w-3.5"})})]})]}),t&&(0,g.jsxs)("div",{className:"border-b bg-muted/30 shrink-0 max-h-[40vh] overflow-auto",children:[(0,g.jsxs)("div",{className:"flex items-center justify-between px-4 py-1.5 border-b",children:[(0,g.jsx)("span",{className:"text-xs font-semibold text-muted-foreground",children:"History"}),(0,g.jsx)("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:A,children:(0,g.jsx)(o,{className:"h-3.5 w-3.5"})})]}),u?(0,g.jsx)("div",{className:"flex justify-center py-4",children:(0,g.jsx)(m.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):0===w.length?(0,g.jsx)("p",{className:"px-4 py-3 text-xs text-muted-foreground",children:"No history found."}):(0,g.jsx)("div",{children:w.map(a=>(0,g.jsxs)("div",{children:[(0,g.jsx)("button",{type:"button",className:(0,ao.cn)("w-full text-left px-4 py-2 hover:bg-muted transition-colors",x===a.sha&&"bg-muted"),onClick:()=>B(a.sha),children:(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsx)("code",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:a.shortSha}),(0,g.jsx)("span",{className:"flex-1 truncate text-xs",children:a.message}),(0,g.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:a.author}),(0,g.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",title:new Date(a.date).toLocaleString(),children:v0(a.date)})]})}),x===a.sha&&(0,g.jsx)("div",{className:"border-t",children:z?(0,g.jsx)("div",{className:"flex justify-center py-3",children:(0,g.jsx)(m.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):null!==y?(0,g.jsx)("pre",{className:"overflow-auto px-4 py-2 text-[11px] font-mono leading-relaxed whitespace-pre text-foreground/80 max-h-60",children:y}):null})]},a.sha))})]}),ae?(0,g.jsx)(uR,{path:a.path,size:a.size??0,onOpen:D}):d?(0,g.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:cO(a.name)?(0,g.jsx)(uO,{}):(0,g.jsx)("textarea",{value:f,onChange:a=>h(a.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"})}):cO(a.name)?(0,g.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:c?(0,g.jsx)("div",{className:"flex justify-center py-8",children:(0,g.jsx)(m.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,g.jsx)(uO,{mode:"viewing"})}):"csv"===ad||"pdf"===ad||"mermaid"===ad||"notebook"===ad||"image"===ad||"media"===ad||"docx"===ad||"xlsx"===ad||"pptx"===ad||"source"===ad||"fallback"===ad?(0,g.jsx)(d9.Provider,{value:_,children:(0,g.jsx)(d8.Provider,{value:Z,children:(0,g.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:c?(0,g.jsx)("div",{className:"flex justify-center py-8",children:(0,g.jsx)(m.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):"csv"===ad?(0,g.jsx)(ed,{path:a.path,title:a.name}):"pdf"===ad?(0,g.jsx)(v_,{path:a.path,title:a.name}):"mermaid"===ad?(0,g.jsx)(uU,{path:a.path,title:a.name}):"notebook"===ad?(0,g.jsx)(vI,{path:a.path,title:a.name}):"image"===ad?(0,g.jsx)(uS,{path:a.path,title:a.name}):"media"===ad?(0,g.jsx)(uT,{path:a.path,title:a.name,type:["mp4","webm","mov","m4v"].includes(cK(a.name))?"video":"audio"}):"docx"===ad?(0,g.jsx)(vK,{path:a.path,title:a.name}):"xlsx"===ad?(0,g.jsx)(vM,{path:a.path,title:a.name}):"pptx"===ad?(0,g.jsx)(vL,{path:a.path,title:a.name}):"source"===ad?(0,g.jsx)(vU,{path:a.path,title:a.name}):(0,g.jsx)(uP,{path:a.path,title:a.name})},M)})}):(0,g.jsx)("div",{className:"flex-1 overflow-auto p-4 min-h-0",children:(0,g.jsx)("div",{className:(0,ao.cn)("w-full",W,V),children:c?(0,g.jsx)("div",{className:"flex justify-center py-8",children:(0,g.jsx)(m.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):null!==b?(0,g.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words leading-relaxed",children:b}):cN(a.name)?(0,g.jsx)("p",{className:"text-sm text-muted-foreground",children:"Could not load file."}):(0,g.jsx)("p",{className:"text-sm text-muted-foreground",children:"Preview not available for this file type."})})}),d&&!cO(a.name)&&(0,g.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[n&&(0,g.jsx)("span",{className:"text-xs text-destructive mr-auto",children:n}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",onClick:()=>e(!1),children:"Cancel"}),(0,g.jsxs)(v.Button,{size:"sm",className:"gap-1",onClick:q,disabled:i,children:[i&&(0,g.jsx)(m.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]})}function v3(a="(max-width: 767px)"){let[b,c]=(0,p.useState)(!1);return(0,p.useEffect)(()=>{let b=window.matchMedia(a),d=()=>c(b.matches);return d(),b.addEventListener("change",d),()=>b.removeEventListener("change",d)},[a]),b}let v4=(0,ay.create)(a=>({recents:[],loadForWorkspace:b=>{a({recents:[]})},push:(b,c)=>{let d=[].filter(a=>a.path!==b.path);a({recents:[b,...d].slice(0,15)})}})),v5=new Map,v6=new Map;async function v7(a){let b=await (0,bB.wsFetch)(`/api/wiki?dir=${encodeURIComponent(a)}`);return b.ok?(await b.json()).entries.map(b=>({name:b.name,path:a?`${a}/${b.name}`:b.name,type:b.type,size:b.size,modifiedAt:b.modifiedAt,expanded:!1,git:b.git})):[]}async function v8(a){let b=v5.get(a);if(b)return v5.delete(a),b;let c=v6.get(a);if(c){let b=await c;return v5.delete(a),b}return null}function v9(a,b,c){return a.map(a=>a.path===b?c(a):a.children?{...a,children:v9(a.children,b,c)}:a)}function wa(a){let b=[];for(let c of a)("dir"===c.type||"app"===c.type||"node-app"===c.type)&&c.expanded&&c.children&&(b.push(c.path),b.push(...wa(c.children)));return b}function wb(a){return a.split("/").pop()??a}a.s(["default",0,function(){let a=function(){let[a,b]=(0,p.useState)(null),[c,d]=(0,p.useState)(null),[e,f]=(0,p.useState)(()=>null),[g,h]=(0,p.useState)([]),[i,j]=(0,p.useState)(!1),[k,l]=(0,p.useState)(!1),[m,n]=(0,p.useState)(null),[o,q]=(0,p.useState)(null),[r,s]=(0,p.useState)({}),[t,u]=(0,p.useState)(null),[v,w]=(0,p.useState)(null),[x,y]=(0,p.useState)(null),[z,A]=(0,p.useState)(null),B=(0,p.useCallback)(async()=>{let a=(0,bB.getEphemeralRoot)();if(a){h([]),j(!1),b(!0),d(a),f(`root:${a}`);return}try{let a=await fetch((0,av.apiUrl)("/api/system/workspaces"));if(!a.ok)throw Error("Failed");let c=await a.json();if(h(c.workspaces),j(c.isAdmin),c.workspaces.length>0){b(!0);let a=new URLSearchParams(window.location.search).get("ws"),e=a?c.workspaces.find(b=>b.id===a):null,g=e??[...c.workspaces].sort((a,b)=>(b.lastOpenedAt??b.createdAt).localeCompare(a.lastOpenedAt??a.createdAt))[0];if(f(g.id),d(g.rootDir),!e){let a=new URL(location.href);a.searchParams.set("ws",g.id),history.replaceState(null,"",a.toString())}}else b(!1)}catch{b(!1)}},[]);(0,p.useEffect)(()=>{B()},[B]);let C=(0,p.useCallback)(async a=>{if(a===e)return;try{await fetch((0,av.apiUrl)(`/api/system/workspaces/${a}/open`),{method:"POST"})}catch{}let b=new URL(location.href);b.searchParams.set("ws",a),b.searchParams.delete("path"),history.pushState(null,"",b.toString()),oa.getState().invalidate(),us.getState().invalidateAll();let c=g.find(b=>b.id===a);c&&d(c.rootDir),f(a)},[e,g]),D=(0,p.useCallback)(async a=>{if(m)try{if(!(await fetch((0,av.apiUrl)(`/api/system/workspaces/${m}`),{method:"DELETE"})).ok)throw Error("Failed");if(m===e){let c=g.filter(a=>a.id!==m);if(c.length>0){let b=[...c].sort((a,b)=>(b.lastOpenedAt??b.createdAt).localeCompare(a.lastOpenedAt??a.createdAt))[0];await a(b.id)}else b(!1)}await B()}catch{}finally{n(null)}},[m,e,g,B]),E=(0,p.useCallback)(async a=>{if(!o){q(a);try{let b=await fetch((0,av.apiUrl)(`/api/system/workspaces/${a}/refresh`),{method:"POST"});if(!b.ok){let a=await b.json();au(a.error??"Refresh failed");return}await B()}catch{au("Refresh failed")}finally{q(null)}}},[o,B]),F=(0,p.useCallback)(async a=>{if(!r[a])try{let b=await fetch((0,av.apiUrl)(`/api/system/workspaces/${a}/branch`));if(!b.ok)return;let c=await b.json();s(b=>({...b,[a]:c.branches??[]}))}catch{}},[r]),G=(0,p.useCallback)(async(a,b)=>{if(!t){u(a),w(b);try{let c=await fetch((0,av.apiUrl)(`/api/system/workspaces/${a}/branch`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:b})});if(!c.ok){let a=await c.json();au(a.error??"Branch switch failed");return}at(`Switched to ${b}`),y(null),A(null),await B()}catch{au("Branch switch failed")}finally{u(null),w(null)}}},[t,B]);return{rootConfigured:a,rootPath:c,activeWorkspaceId:e,workspaces:g,isWsAdmin:i,addingWorkspace:k,setAddingWorkspace:l,setRootConfigured:b,setActiveWorkspaceId:f,deletingWorkspaceId:m,setDeletingWorkspaceId:n,refreshingWsId:o,wsBranches:r,switchingBranch:t,switchingBranchName:v,branchPickerWsId:x,setBranchPickerWsId:y,wsBranchPos:z,setWsBranchPos:A,loadWorkspaces:B,switchWorkspace:C,handleDeleteWorkspace:D,handleRefreshWorkspace:E,loadWsBranches:F,handleSwitchBranch:G}}(),b=(0,p.useRef)(()=>{}),c=function({activeWorkspaceId:a,rootConfigured:b,onExternalChange:c}){let[d,e]=(0,p.useState)([]),[f,g]=(0,p.useState)(!1),[h,i]=(0,p.useState)(!1),j=(0,p.useRef)(!1),[k,l]=(0,p.useState)(!1),[m,n]=(0,p.useState)({}),[o,q]=(0,p.useState)({}),[r,s]=(0,p.useState)(null),[t,u]=(0,p.useState)(null),[v,w]=(0,p.useState)(null),[x,y]=(0,p.useState)(null);(0,p.useEffect)(()=>{e([]),g(!1),j.current=!1,n({}),q({}),s(null),u(null),w(null),y(null)},[a]),(0,p.useEffect)(()=>{!a||f||j.current||(j.current=!0,i(!0),v7("").then(a=>{e(a),g(!0),i(!1)}).catch(()=>{j.current=!1,i(!1)}))},[f,a]);let z=(0,p.useCallback)(async a=>{let b=await v7(a);""===a?e(a=>{let c=new Map(a.map(a=>[a.path,a]));return b.map(a=>{let b=c.get(a.path);return b&&("dir"===b.type||"app"===b.type)?{...a,expanded:b.expanded,children:b.children}:a})}):e(c=>v9(c,a,a=>({...a,children:b,expanded:!0})))},[]),A=(0,p.useCallback)(async a=>{let b=a.split("/");if(b.length<=1)return;let c=[],d="";for(let a=0;a<b.length-1;a++)d=d?`${d}/${b[a]}`:b[a],c.push({prefix:d,children:await v7(d)});e(a=>{let b=a;for(let{prefix:a,children:d}of c)b=v9(b,a,a=>({...a,children:d,expanded:!0}));return b})},[]),B=(0,p.useCallback)(async()=>{l(!0);try{let a=wa(d),b=await v7("");for(let c of(e(b),a)){let a=await v7(c);e(b=>v9(b,c,b=>({...b,children:a,expanded:!0})))}}finally{l(!1)}},[d]),C=(0,p.useCallback)(async a=>{if("dir"===a.type||"app"===a.type||"node-app"===a.type)if(a.expanded)e(b=>v9(b,a.path,a=>({...a,expanded:!1})));else if(void 0===a.children){let b=await v8(a.path);if(b)return void e(c=>v9(c,a.path,a=>({...a,loading:!1,children:b,expanded:!0})));e(b=>v9(b,a.path,a=>({...a,loading:!0})));let c=await v7(a.path);e(b=>v9(b,a.path,a=>({...a,loading:!1,children:c,expanded:!0})))}else e(b=>v9(b,a.path,a=>({...a,expanded:!0})))},[]),D=(0,p.useCallback)(a=>{"file"===a.type?(a.name.endsWith(".md")||a.name.endsWith(".markdown"))&&bW(a.path):function(a){if(v5.has(a)||v6.has(a))return;let b=v7(a).then(b=>(v5.set(a,b),b)).finally(()=>v6.delete(a));v6.set(a,b),b.catch(()=>{})}(a.path)},[]),E=(0,p.useRef)([]);(0,p.useEffect)(()=>{E.current=wa(d)},[d]);let F=(0,p.useMemo)(()=>wa(d).filter(a=>""!==a).slice(0,24).join("\n"),[d]),[G,H]=(0,p.useState)("");(0,p.useEffect)(()=>{let a=setTimeout(()=>H(F),300);return()=>clearTimeout(a)},[F]);let I=(0,p.useRef)(c);(0,p.useEffect)(()=>{I.current=c},[c]),(0,p.useEffect)(()=>{if(!b||(0,av.isLite)()||!a)return;let c=new Map;function d(a){c.has(a)&&clearTimeout(c.get(a)),c.set(a,setTimeout(()=>{c.delete(a),z(a)},300))}let e=(G?G.split("\n"):[]).map(a=>`dir=${encodeURIComponent(a)}`).join("&"),f=new EventSource((0,bB.withWs)(e?`/api/wiki/watch?${e}`:"/api/wiki/watch"));return f.onmessage=a=>{let b;try{b=JSON.parse(a.data)}catch{return}let{type:e,path:f}=b;if("rescan"===e){for(let a of(us.getState().invalidateAll(),d(""),E.current))d(a);return}("add"===e||"change"===e||"unlink"===e)&&us.getState().invalidateAll();let g=f.split("/");if(d(g.length>1?g.slice(0,-1).join("/"):""),"change"===e){let a=`__file__${f}`;c.has(a)&&clearTimeout(c.get(a)),c.set(a,setTimeout(()=>{c.delete(a),I.current?.(f)},400))}},()=>{for(let a of(f.close(),c.values()))clearTimeout(a)}},[b,z,a,G]);let J=(0,p.useCallback)(async a=>{if(!m[a]&&!o[a]){q(b=>({...b,[a]:!0}));try{let b=await (0,bB.wsFetch)(`/api/wiki/git-branches?path=${encodeURIComponent(a)}`);if(!b.ok)return void au("Could not load branches");let c=await b.json();n(b=>({...b,[a]:c.branches}))}catch{au("Could not load branches")}finally{q(b=>({...b,[a]:!1}))}}},[m,o]),K=(0,p.useCallback)(async(a,b,c)=>{if(!r){s(b);try{let d=await (0,bB.wsFetch)("/api/wiki/git-checkout",{method:"POST",body:JSON.stringify({path:a,branch:b})});if(409===d.status)return void au("Repository has uncommitted changes");if(!d.ok){let a=await d.json();au(a.error??"Checkout failed");return}let e=await d.json();at(`Switched to ${e.branch}`),w(null),y(null),n(b=>{let c={...b};return delete c[a],c}),await z(c)}catch{au("Checkout failed")}finally{s(null)}}},[r,z]),L=(0,p.useCallback)(async(a,b)=>{if(!t){u(a);try{let c=await (0,bB.wsFetch)("/api/wiki/git-pull",{method:"POST",body:JSON.stringify({path:a})});if(!c.ok){let a=await c.json();au(a.message??a.error??"Pull failed");return}let d=await c.json();at(`Pulled ${a} (${d.branch} @ ${d.sha.slice(0,7)})`),await z(b)}catch{au("Pull failed")}finally{u(null)}}},[t,z]);return{roots:d,rootLoaded:f,rootLoading:h,refreshingTree:k,refreshTree:B,reloadDir:z,revealPath:A,toggleFolder:C,prefetch:D,nodeBranches:m,branchesLoading:o,checkingOutBranch:r,pullingRepo:t,branchDropdownNode:v,setBranchDropdownNode:w,branchDropdownPos:x,setBranchDropdownPos:y,loadBranches:J,handleCheckout:K,handleGitPull:L}}({activeWorkspaceId:a.activeWorkspaceId,rootConfigured:a.rootConfigured,onExternalChange:(0,p.useCallback)(a=>b.current(a),[])}),d=function({activeWorkspaceId:a,rootPath:b,isMobile:c,setSidebarCollapsed:d,treeApi:e}){let[f,g]=(0,p.useState)(null),[h,i]=(0,p.useState)(null),[j,k]=(0,p.useState)(!1),[l,m]=(0,p.useState)(0),[n,o]=(0,p.useState)(0),[q,r]=(0,p.useState)(null),[s,t]=(0,p.useState)(0),[u,v]=(0,p.useState)(!1),[w,x]=(0,p.useState)(!1),[y,z]=(0,p.useState)(""),[A,B]=(0,p.useState)(!1),[C,D]=(0,p.useState)(!1),[E,F]=(0,p.useState)(null),G=(0,p.useRef)(null),H=(0,p.useRef)(!1);(0,p.useEffect)(()=>{G.current=f},[f]),(0,p.useEffect)(()=>{H.current=w},[w]);let I=(0,p.useMemo)(()=>f?cL(f.name,f.nodeType):null,[f]),J=(0,p.useCallback)(()=>{x(!1),B(!1),F(null),r(null),t(0),i(null)},[]),K=(0,p.useCallback)(async(a,b)=>{var c;if(["editor","text"].includes(b)||cN((c=a).split("/").pop()??c)){v(!0);try{let b=await (0,bB.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(a)}`);if(b.ok){let a=await b.json();r(a.content),t(Number(b.headers.get("X-Wiki-Revision")??0))}}catch{}v(!1)}},[]),L=(0,p.useCallback)(async b=>{if("file"===b.type&&v4.getState().push({path:b.path,name:b.name},a),g({path:b.path,name:b.name,size:b.size,nodeType:"app"===b.type?"app":"node-app"===b.type?"node-app":"file"}),J(),"file"===b.type&&cO(b.name)){v(!0);try{await b_.getState().loadPage(b.path)}finally{v(!1)}return}let c=cL(b.name,b.type);await K(b.path,c)},[a,J,K]),M=(0,p.useCallback)(()=>{g(null),r(null),x(!1),B(!1),F(null)},[]),N=(0,p.useCallback)(()=>{g(null),r(null),x(!1),B(!1),F(null),t(0)},[]),O=(0,p.useCallback)(a=>{let b=a.split("/").pop()??a;e.revealPath(a),L({path:a,name:b,type:"file",modifiedAt:""})},[L,e]),P=(0,p.useCallback)(async a=>{let b=a.path.split("/").slice(0,-1).join("/"),f=(await v7(b)).find(b=>b.path===a.path);if(f){if("dir"===f.type){await e.revealPath(a.path),await e.toggleFolder(f);return}if("app"===f.type||"node-app"===f.type){await e.revealPath(f.path),L({path:f.path,name:f.name,type:f.type,modifiedAt:f.modifiedAt}),await e.toggleFolder(f),c&&d(!0);return}L({path:f.path,name:f.name,type:f.type,modifiedAt:f.modifiedAt}),c&&d(!0)}},[c,L,d,e]),Q=(0,p.useCallback)(async a=>{if(!a)return void g(null);let c=(0,bB.toRootRelative)(a,(0,bB.getEphemeralRoot)()??b);if(null===c||!(a=c))return;let d=a.split("/"),f=d[d.length-1],h=d.slice(0,-1).join("/"),i=(await v7(h)).find(b=>b.path===a);i&&(await e.revealPath(a),L({path:a,name:f,type:i.type,modifiedAt:i.modifiedAt}))},[L,b,e]);(0,p.useEffect)(()=>{},[f]),(0,p.useEffect)(()=>{},[Q]);let[R,S]=(0,p.useState)(!1);(0,p.useEffect)(()=>{S("1"===new URLSearchParams(window.location.search).get("embed"))},[]),(0,p.useEffect)(()=>{if(!R)return;let a=a=>{a.origin!==window.location.origin?console.warn(`[wiki-viewer] ignored postMessage from untrusted parent origin ${a.origin}.`):a.data&&"open-file"===a.data.type&&"string"==typeof a.data.path&&Q(a.data.path)};return window.addEventListener("message",a),()=>window.removeEventListener("message",a)},[R,Q]);let T=(0,p.useRef)(null),U=(0,p.useRef)(!1),[V,W]=(0,p.useState)(!1),X=(0,p.useCallback)(()=>W(!0),[]);(0,p.useEffect)(()=>{U.current||V&&(U.current=!0,Q(T.current))},[V,Q]),(0,p.useEffect)(()=>{f&&cO(f.name)&&b_.getState().currentPath!==f.path&&b_.getState().loadPage(f.path)},[f]);let Y=(0,p.useCallback)(async()=>{let a=G.current;if(a){if(cO(a.name)){v(!0);try{await b_.getState().loadPage(a.path)}finally{v(!1)}return}if(["editor","text"].includes(cL(a.name,a.nodeType))||cN(a.name)){v(!0);try{let b=await (0,bB.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(a.path)}`);if(b.ok){let a=await b.json();r(a.content),t(Number(b.headers.get("X-Wiki-Revision")??0))}}catch{}v(!1)}}},[]),Z=(0,p.useCallback)(()=>{o(a=>a+1),Y()},[Y]),$=(0,p.useCallback)(a=>{let b=G.current;b&&b.path===a&&!H.current&&Y()},[Y]),_=(0,p.useCallback)(async()=>{let a=G.current;if(!a)return;D(!0),F(null);let b=await (0,bB.wsFetch)("/api/wiki/content",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a.path,content:y,baseRevision:s})});if(b.ok){let a=await b.json();"number"==typeof a.revision&&t(a.revision),r(y),x(!1)}else F((await b.json()).error??"Save failed");D(!1)},[y,s]);async function aa(a){let b=G.current;if(b?.path===a&&null!==q)return q;if(b_.getState().currentPath===a)return b_.getState().content;let c=await (0,bB.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(a)}`);if(!c.ok)throw Error("Cannot copy content");return(await c.json()).content}return{openFile:f,openFileViewerKind:I,fileContent:q,fileRevision:s,fileLoading:u,editing:w,setEditing:x,editContent:y,setEditContent:z,htmlSourceMode:A,setHtmlSourceMode:B,saving:C,saveError:E,appFullscreen:j,setAppFullscreen:k,appKey:l,setAppKey:m,viewerKey:n,setViewerKey:o,gateBypassPath:h,bypassGate:()=>i(G.current?.path??null),openViewer:L,openFromSearch:O,openFavoriteEntry:P,navigateToPath:Q,handleSave:_,refreshViewer:Y,handleRefresh:Z,closeFile:M,clearFile:N,onExternalChange:$,markRootLoaded:X,copyPath:a=>{navigator.clipboard.writeText(a),at("Path copied")},copyWikiLink:a=>{let b=a.replace(/\.(md|markdown)$/i,"");navigator.clipboard.writeText(`[[${b}]]`),at("Wiki link copied")},copyUrl:b=>{let c=new URL(location.href);c.searchParams.set("path",b),a&&c.searchParams.set("ws",a),navigator.clipboard.writeText(c.toString()),at("URL copied")},copyRawContent:async function(a){try{let b=await aa(a);await navigator.clipboard.writeText(b),at("Raw content copied")}catch{au("Could not copy file content")}},copyFormattedContent:async function(a,b){try{let c=await aa(a);if(!cO(b)){await navigator.clipboard.writeText(c),at("Content copied");return}let d=await (0,np.markdownToHtml)(c,{pagePath:a,sanitize:!0});"ClipboardItem"in window&&navigator.clipboard.write?await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([d],{type:"text/html"}),"text/plain":new Blob([c],{type:"text/plain"})})]):await navigator.clipboard.writeText(c),at("Formatted content copied")}catch{au("Could not copy formatted content")}}}}({activeWorkspaceId:a.activeWorkspaceId,rootPath:a.rootPath,isMobile:v3(),setSidebarCollapsed:a=>q.current(a),treeApi:{revealPath:c.revealPath,toggleFolder:c.toggleFolder}});(0,p.useEffect)(()=>{b.current=d.onExternalChange},[d.onExternalChange]);let e=v3(),[f,h]=(0,p.useState)(!1),q=(0,p.useRef)(()=>{});q.current=h;let[r,s]=(0,p.useState)({settingsOpen:!1,shareDialogOpen:!1}),[t,u]=(0,p.useState)(!1),[w,x]=(0,p.useState)({path:null,isDir:!1}),y=function({reloadDir:a}){let[b,c]=(0,p.useState)(!1),[d,e]=(0,p.useState)(null),f=(0,p.useRef)(null),g=(0,p.useRef)(""),h=(0,p.useCallback)(async(b,d)=>{void 0!==d&&(g.current=d);let h=Array.from(b);if(h.length){c(!0),e(null);try{for(let a of h){let b=new FormData;b.append("file",a),b.append("dir",g.current);let c=await (0,bB.wsFetch)("/api/wiki/upload",{method:"POST",body:b});if(!c.ok){let a=await c.json();e(a.error??"Upload failed"),au(a.error??"Upload failed");break}}await a(g.current)}catch{e("Upload failed.")}finally{c(!1),f.current&&(f.current.value="")}}},[a]);return{uploading:b,uploadError:d,fileInputRef:f,triggerUpload:function(a){g.current=a,f.current?.click()},doUpload:h}}({reloadDir:c.reloadDir}),z=function(a){let[b,c]=(0,p.useState)(null),[d,e]=(0,p.useState)(!1),[f,g]=(0,p.useState)([]),[h,i]=(0,p.useState)(!1),[j,k]=(0,p.useState)(null),[l,m]=(0,p.useState)(null),[n,o]=(0,p.useState)(!1),q=a?.path;(0,p.useEffect)(()=>{e(!1),g([]),k(null),m(null)},[q]),(0,p.useEffect)(()=>{if(!q)return void c(null);let a=!1,b=setTimeout(()=>{(async()=>{try{let b=await (0,bB.wsFetch)(`/api/wiki/git-file-info?path=${encodeURIComponent(q)}`);if(a)return;if(!b.ok)return void c(null);let d=await b.json();a||c(d.info)}catch{a||c(null)}})()},200);return()=>{a=!0,clearTimeout(b)}},[q]);let r=(0,p.useCallback)(async()=>{if(!a)return;let b=a.path;e(!0),i(!0),g([]),k(null),m(null);try{let c=await (0,bB.wsFetch)(`/api/wiki/git-history?path=${encodeURIComponent(b)}`);if(!c.ok)return void au("Could not load history");let d=await c.json();a.path===b&&g(d.commits)}catch{au("Could not load history")}finally{i(!1)}},[a]),s=(0,p.useCallback)(async b=>{if(!a)return;if(j===b){k(null),m(null);return}let c=a.path;k(b),o(!0),m(null);try{let d=await (0,bB.wsFetch)(`/api/wiki/git-diff?path=${encodeURIComponent(c)}&sha=${encodeURIComponent(b)}`);if(!d.ok)return void au("Could not load diff");let e=await d.json();a.path===c&&j===b&&m(e.diff)}catch{au("Could not load diff")}finally{o(!1)}},[a,j]);return{gitFileInfo:b,showHistory:d,setShowHistory:e,historyLoading:h,historyCommits:f,selectedDiffSha:j,setSelectedDiffSha:k,loadHistory:r,diffContent:l,diffLoading:n,selectDiff:s}}(d.openFile),A=cW(a=>a.favorites),B=v4(a=>a.recents),C=bF(a=>a.activity),D=(0,p.useMemo)(()=>{let a=new Date(Date.now()-6e4).toISOString(),b=new Set;for(let c of C)c.at>=a&&c.path&&c.by?.startsWith("ai:")&&b.add(c.path);return b},[C]);async function E(){if(!w.path)return;await fetch((0,bB.withWs)("/api/wiki"),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:w.path})}),(d.openFile?.path===w.path||d.openFile?.path.startsWith(`${w.path}/`))&&d.closeFile();let a=wb(w.path).includes("/")?w.path.split("/").slice(0,-1).join("/"):"";await c.reloadDir(a),x({path:null,isDir:!1})}(0,p.useEffect)(()=>{let a=new URLSearchParams(window.location.search);u("1"===a.get("embed")&&"1"!==a.get("chrome"))},[]),(0,p.useEffect)(()=>{e&&h(!0)},[e]),(0,p.useEffect)(()=>{oa.getState().load()},[]),(0,p.useEffect)(()=>{let a=()=>{bF.getState().loadActivity()};a();let b=setInterval(a,1e4);return()=>clearInterval(b)},[]),(0,p.useEffect)(()=>{v4.getState().loadForWorkspace(a.activeWorkspaceId),cW.getState().loadForWorkspace(a.activeWorkspaceId)},[a.activeWorkspaceId]),(0,p.useEffect)(()=>{let a,b=[...A.map(a=>a.path),...B.slice(0,8).map(a=>a.path)].filter((a,b,c)=>cO(a)&&c.indexOf(a)===b).slice(0,12);if(0===b.length)return;let c=(a=()=>{for(let a of b)bW(a)},window.setTimeout(a,400));return()=>{clearTimeout(c)}},[A,B]),(0,p.useEffect)(()=>{d.clearFile()},[a.activeWorkspaceId,d.clearFile]),(0,p.useEffect)(()=>{c.rootLoaded&&d.markRootLoaded()},[c.rootLoaded,d.markRootLoaded]);let F=(0,dK.useViewWidthStore)(a=>a.width),G=(0,dK.useViewWidthStore)(a=>a.align),H=(0,dK.useViewWidthStore)(a=>a.setWidth),I=(0,dK.useViewWidthStore)(a=>a.setAlign),J=null===d.openFileViewerKind||"editor"===d.openFileViewerKind||"text"===d.openFileViewerKind||"source"===d.openFileViewerKind||"notebook"===d.openFileViewerKind||"fallback"===d.openFileViewerKind,K=J?dK.VIEW_WIDTH_CLASS[F]:"",L=J?dK.VIEW_ALIGN_CLASS[G]:"",M=(0,p.useCallback)((b,c)=>(0,g.jsx)(cX,{doc:d,node:b,extraItems:c,activeWorkspaceId:a.activeWorkspaceId}),[d,a.activeWorkspaceId]);return(0,g.jsxs)("div",{className:"flex h-screen gap-0 overflow-hidden bg-background",children:[null===a.rootConfigured&&(0,g.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,g.jsx)(m.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),!1===a.rootConfigured&&(0,g.jsx)(bc,{onSelect:b=>{let c=new URL(location.href);c.searchParams.set("ws",b),c.searchParams.delete("path"),history.replaceState(null,"",c.toString()),a.setRootConfigured(!0),a.setActiveWorkspaceId(b),a.loadWorkspaces()}}),!0===a.rootConfigured&&a.addingWorkspace&&(0,g.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,g.jsx)("div",{className:"flex items-center justify-end border-b px-3 py-2 bg-muted shrink-0",children:(0,g.jsxs)(v.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1.5 text-xs",onClick:()=>a.setAddingWorkspace(!1),children:[(0,g.jsx)(o,{className:"h-3.5 w-3.5"})," Cancel"]})}),(0,g.jsx)(bc,{onSelect:b=>{a.setAddingWorkspace(!1),a.loadWorkspaces(),a.switchWorkspace(b)}})]}),!0===a.rootConfigured&&!a.addingWorkspace&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d0,{workspace:a,doc:d,fileTree:c,upload:y,isMobile:e,hideChrome:t,sidebarCollapsed:f,setSidebarCollapsed:h,favorites:A,recents:B,activePaths:D,setDeleting:x,setDialogs:s}),(0,g.jsxs)("div",{className:"flex-1 flex flex-col min-w-0 relative",children:[!t&&f&&(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"hidden md:flex absolute left-2 top-2 z-10 h-7 w-7 p-0",title:"Show sidebar",onClick:()=>h(!1),children:(0,g.jsx)(n,{className:"h-3.5 w-3.5"})}),!t&&(0,g.jsxs)("div",{className:"md:hidden flex h-11 shrink-0 items-center justify-between gap-2 border-b bg-muted px-1",children:[(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"Show sidebar",onClick:()=>{h(!1),bF.getState().close()},children:(0,g.jsx)(n,{className:"h-4 w-4"})}),(0,g.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5 text-xs font-semibold tracking-tight text-muted-foreground",title:d.openFile?.path,children:[d.openFile&&(0,g.jsx)("span",{className:"shrink-0",children:"app"===d.openFileViewerKind||"html"===d.openFileViewerKind?(0,g.jsx)(k,{className:"h-4 w-4 text-foreground/70"}):cP(d.openFile.name)?(0,g.jsx)(l,{className:"h-4 w-4 text-sunshine-700"}):cN(d.openFile.name)?(0,g.jsx)(j.FileText,{className:"h-4 w-4 text-foreground/70"}):(0,g.jsx)(j.FileText,{className:"h-4 w-4 text-foreground/60"})}),(0,g.jsx)("span",{className:"truncate",children:d.openFile?d.openFile.name:"Wiki Viewer"})]}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"AI Agent panel",onClick:()=>{bF.getState().open(),h(!0)},children:(0,g.jsx)(i,{className:"h-4 w-4"})})]}),d.openFile?(0,g.jsx)(v2,{openFile:d.openFile,fileContent:d.fileContent,fileRevision:d.fileRevision,fileLoading:d.fileLoading,editing:d.editing,setEditing:d.setEditing,editContent:d.editContent,setEditContent:d.setEditContent,saving:d.saving,saveError:d.saveError,onSave:d.handleSave,gitFileInfo:z.gitFileInfo,showHistory:z.showHistory,historyLoading:z.historyLoading,historyCommits:z.historyCommits,selectedDiffSha:z.selectedDiffSha,diffContent:z.diffContent,diffLoading:z.diffLoading,onToggleHistory:()=>z.setShowHistory(a=>!a),onSelectDiff:z.selectDiff,gateBypassPath:d.gateBypassPath,onBypassGate:d.bypassGate,onRefresh:d.handleRefresh,onShare:()=>s(a=>({...a,shareDialogOpen:!0})),onClose:()=>{d.closeFile()},renderCopyMenu:M,appKey:d.appKey,setAppKey:d.setAppKey,appFullscreen:d.appFullscreen,setAppFullscreen:d.setAppFullscreen,viewerKey:d.viewerKey,setViewerKey:d.setViewerKey,htmlSourceMode:d.htmlSourceMode,setHtmlSourceMode:d.setHtmlSourceMode,widthAwareViewer:J,viewWidth:F,viewAlign:G,setViewWidth:H,setViewAlign:I,contentWidthClass:K,contentAlignClass:L,isMobile:e,sidebarCollapsed:f}):(0,g.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center",children:(0,g.jsxs)("div",{className:"flex flex-col items-center gap-2 text-center px-4",children:[(0,g.jsx)(j.FileText,{className:"h-8 w-8 text-muted-foreground"}),(0,g.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a file to view or edit"})]})})]}),(0,g.jsx)(bC,{open:r.shareDialogOpen,onOpenChange:a=>s(b=>({...b,shareDialogOpen:a})),filePath:d.openFile?.path??""}),!(0,av.isLite)()&&(0,g.jsx)(aX,{open:r.settingsOpen,onOpenChange:a=>s(b=>({...b,settingsOpen:a}))}),(0,g.jsx)(b7,{currentPath:d.openFile?.path}),(0,g.jsx)("input",{ref:y.fileInputRef,type:"file",multiple:!0,className:"hidden",onChange:a=>{a.target.files&&y.doUpload(a.target.files)}}),(0,g.jsx)(a2,{open:!!w.path,onOpenChange:a=>{a||x({path:null,isDir:!1})},title:w.isDir?"Delete folder?":"Delete file?",description:w.isDir?`"${wb(w.path??"")}" and all its contents will be permanently deleted.`:`"${wb(w.path??"")}" will be permanently removed.`,onConfirm:E}),(0,g.jsx)(a2,{open:!!a.deletingWorkspaceId,onOpenChange:b=>{b||a.setDeletingWorkspaceId(null)},title:"Delete workspace?",description:`"${a.workspaces.find(b=>b.id===a.deletingWorkspaceId)?.name??""}" will be removed from the workspace list. Files on disk are NOT deleted.`,onConfirm:()=>void a.handleDeleteWorkspace(async b=>{await a.switchWorkspace(b),d.clearFile()})})]})]},a.activeWorkspaceId??"none")}],240777)}];
170
+ ${b}`:""]})}let b=a.data||{};if(b["image/png"]){let a=`data:image/png;base64,${vC(b["image/png"]).replace(/\s/g,"")}`;return(0,g.jsx)("img",{src:a,alt:"output",className:"max-w-full rounded-md bg-card p-2"})}if(b["image/jpeg"]){let a=`data:image/jpeg;base64,${vC(b["image/jpeg"]).replace(/\s/g,"")}`;return(0,g.jsx)("img",{src:a,alt:"output",className:"max-w-full rounded-md bg-card p-2"})}if(b["image/svg+xml"]){let a=vC(b["image/svg+xml"]);return(0,g.jsx)("div",{className:"max-w-full rounded-md bg-card p-2 overflow-auto",dangerouslySetInnerHTML:{__html:a}})}if(b["text/html"]){let a=vC(b["text/html"]);return(0,g.jsx)("iframe",{srcDoc:`<!doctype html><html><head><base target="_blank"><style>body{margin:0;padding:8px;font-family:-apple-system,BlinkMacSystemFont,Inter,system-ui,sans-serif;background:#FFF9E9;color:#2A221B;font-size:13px}table{border-collapse:collapse}th,td{border:1px solid #D4C4B0;padding:4px 8px;text-align:left}thead{background:#EFE5CC}</style></head><body>${a}</body></html>`,sandbox:"allow-scripts",className:"w-full bg-[#FFF9E9] rounded-md border border-[#E8DDC5]",style:{height:360}})}return b["text/plain"]?(0,g.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md bg-[#F5EEDC] text-[#2A221B]",children:vE(vC(b["text/plain"]))}):null}function vG({cell:a,language:b}){let c=vC(a.source),d=(0,p.useMemo)(()=>(function(a,b){try{let c=b?vB.highlight(b,a):vB.highlightAuto(a);return(0,uW.toHtml)(c)}catch{return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}})(c,b),[c,b]),e=a.execution_count??" ",f=(a.outputs?.length??0)>0;return(0,g.jsxs)("div",{className:"grid grid-cols-[60px_1fr] gap-3 mb-5",children:[(0,g.jsxs)("div",{className:"text-right pt-3 select-none font-mono text-[11px] text-[#8B5E3C]",children:["In [",e,"]:"]}),(0,g.jsxs)("div",{children:[(0,g.jsx)("pre",{className:"whitespace-pre overflow-x-auto font-mono text-[13px] leading-relaxed px-4 py-3 rounded-md bg-[#FFF9E9] border border-[#E8DDC5] text-[#2A221B]",children:(0,g.jsx)("code",{dangerouslySetInnerHTML:{__html:d}})}),f&&(0,g.jsxs)("div",{className:"mt-2 grid grid-cols-[60px_1fr] gap-3",children:[(0,g.jsxs)("div",{className:"text-right pt-3 select-none font-mono text-[11px] text-[#8B2E3E]",children:["Out[",e,"]:"]}),(0,g.jsx)("div",{className:"space-y-2",children:a.outputs?.map((a,b)=>(0,g.jsx)(vF,{output:a},b))})]})]})]})}function vH({cell:a}){let[b,c]=(0,p.useState)("");return(0,p.useEffect)(()=>{let b=!1;return(0,np.markdownToHtml)(vC(a.source)).then(a=>{b||c(a)}),()=>{b=!0}},[a.source]),(0,g.jsx)("div",{className:"prose prose-sm max-w-none mb-5 px-1 [&_h1]:font-serif [&_h2]:font-serif [&_h3]:font-serif [&_a]:text-[#8B5E3C] [&_a:hover]:underline [&_code]:bg-[#F5EEDC] [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:rounded [&_code]:text-[#8B2E3E]",dangerouslySetInnerHTML:{__html:b}})}function vI({cell:a}){return(0,g.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md bg-[#F5EEDC] text-[#2A221B] mb-5",children:vC(a.source)})}function vJ({path:a}){let[b,c]=(0,p.useState)(null),[d,e]=(0,p.useState)(!0),[f,h]=(0,p.useState)(null),[i,j]=(0,p.useState)(!1),k=(0,bB.withWs)(`/api/assets/${a}`),l=a.split("/").pop()||a,m=(0,p.useCallback)(async()=>{e(!0),h(null);try{let a=await (0,bB.wsFetch)(k);if(!a.ok)throw Error(`HTTP ${a.status}`);let b=await a.json();c(b)}catch(a){h(a instanceof Error?a.message:"Failed to load notebook")}finally{e(!1)}},[k]);(0,p.useEffect)(()=>{m()},[m]);let n=b?.metadata?.language_info?.name||b?.metadata?.kernelspec?.name||"python",o=b?.cells?.length??0,s=b?.cells?.filter(a=>"code"===a.cell_type).length??0,t=b?.cells?.some(a=>"code"===a.cell_type&&(a.outputs?.length??0)>0)??!1;return(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsxs)(ea,{path:a,badge:"IPYNB",sublabel:`${o} cells \xb7 ${s} code \xb7 ${n}`,children:[(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{navigator.clipboard.writeText(`jupyter lab ${a}`),j(!0),setTimeout(()=>j(!1),2e3)},title:"Copy: jupyter lab <path>",children:[i?(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,g.jsx)(bd.Copy,{className:"h-3.5 w-3.5"}),i?"Copied":"Copy run cmd"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let a=document.createElement("a");a.href=k,a.download=l,a.click()},children:[(0,g.jsx)(b8.Download,{className:"h-3.5 w-3.5"}),"Download"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(k,"_blank"),children:[(0,g.jsx)(bE,{className:"h-3.5 w-3.5"}),"Raw JSON"]})]}),(0,g.jsx)("div",{className:"flex-1 overflow-auto bg-[#F5EEDC]",children:d?(0,g.jsx)("div",{className:"flex items-center justify-center h-full text-[#7A6B5D] text-sm",children:"Loading notebook…"}):f?(0,g.jsxs)("div",{className:"flex items-center justify-center h-full text-[#8B2E3E] text-sm gap-2",children:[(0,g.jsx)(q.AlertCircle,{className:"h-4 w-4"})," ",f]}):b?(0,g.jsxs)("div",{className:"max-w-[1100px] mx-auto py-8 px-6",children:[!t&&s>0&&(0,g.jsxs)("div",{className:"mb-6 rounded-md border border-[#E8DDC5] bg-[#FFF9E9] px-4 py-3 text-[13px] text-[#7A6B5D]",children:[(0,g.jsx)("span",{className:"font-semibold text-[#0c0a09]",children:"This notebook hasn't been run yet."})," ","Code and markdown cells display below; outputs appear once the author runs the notebook in Jupyter (or you do, then re-save)."]}),b.cells?.map((a,b)=>"markdown"===a.cell_type?(0,g.jsx)(vH,{cell:a},b):"raw"===a.cell_type?(0,g.jsx)(vI,{cell:a},b):(0,g.jsx)(vG,{cell:a,language:n},b))]}):null})]})}function vK({path:a,extLabel:b,external:c,hideFinder:d}){let e=(0,bB.withWs)(`/api/assets/${a}`),f=a.split("/").pop()||a,h=async()=>{try{await (0,bB.wsFetch)("/api/system/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})}catch{}};return(0,g.jsxs)(ea,{path:a,badge:b||void 0,children:[c&&(0,g.jsxs)("a",{href:c.href,target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-center gap-1.5 text-[11px] h-7 px-2.5 rounded-md border border-border hover:bg-accent transition-colors",children:[(0,g.jsx)(bE,{className:"h-3.5 w-3.5"}),c.label]}),!d&&(0,g.jsxs)(v.Button,{variant:"outline",size:"sm",className:"gap-1.5 text-[11px] h-7",onClick:h,title:"Open in Finder",children:[(0,g.jsx)(a5,{className:"h-3.5 w-3.5"}),"Reveal"]}),!d&&(0,g.jsxs)(v.Button,{variant:"outline",size:"sm",className:"gap-1.5 text-[11px] h-7",onClick:()=>{let a=document.createElement("a");a.href=e,a.download=f,a.click()},title:"Download original",children:[(0,g.jsx)(b8.Download,{className:"h-3.5 w-3.5"}),"Download"]})]})}function vL({path:b,title:c}){let d=(0,p.useRef)(null),[e,f]=(0,p.useState)(!0),[h,i]=(0,p.useState)(null);return(0,p.useEffect)(()=>{let c=!1,e=d.current;if(e)return e.innerHTML="",(async()=>{f(!0),i(null);try{let[{renderAsync:d},g]=await Promise.all([a.A(458647),(0,bB.wsFetch)(`/api/assets/${b}`)]);if(c)return;if(!g.ok)throw Error(`Failed to load file (${g.status})`);let h=await g.blob();if(c)return;await d(h,e,void 0,{className:"docx-rendered",inWrapper:!0,ignoreWidth:!1,ignoreHeight:!1,breakPages:!0,renderHeaders:!0,renderFooters:!0,renderFootnotes:!0,experimental:!0,useBase64URL:!0}),c||f(!1)}catch(a){c||(i(a instanceof Error?a.message:"Failed to render document"),f(!1))}})(),()=>{c=!0}},[b]),(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsx)(vK,{path:b,title:c,extLabel:"DOCX"}),(0,g.jsxs)("div",{className:"flex-1 overflow-y-auto bg-muted/30",children:[e&&!h&&(0,g.jsxs)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:[(0,g.jsx)(m.Loader2,{className:"h-5 w-5 animate-spin mr-2"}),"Rendering document…"]}),h&&(0,g.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,g.jsxs)("div",{className:"text-center space-y-2",children:[(0,g.jsx)("p",{className:"text-sm text-destructive",children:h}),(0,g.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try downloading the file and opening it externally."})]})}),(0,g.jsx)("div",{ref:d,className:"docx-viewer-body mx-auto max-w-5xl py-6 px-4"})]})]})}function vM({path:b,title:c}){let d=(0,p.useRef)(null),[e,f]=(0,p.useState)(!0),[h,i]=(0,p.useState)(null);return(0,p.useEffect)(()=>{let c=!1,e=d.current;if(!e)return;e.innerHTML="";let g=null;return(async()=>{f(!0),i(null);try{let[{init:d},h]=await Promise.all([a.A(287443),(0,bB.wsFetch)(`/api/assets/${b}`)]);if(c)return;if(!h.ok)throw Error(`Failed to load file (${h.status})`);let i=await h.arrayBuffer();if(c)return;let j=e.clientWidth||960,k=Math.round(9*j/16);g=d(e,{width:j,height:k,mode:"list"}),await g.preview(i),c||f(!1)}catch(a){c||(i(a instanceof Error?a.message:"Failed to render presentation"),f(!1))}})(),()=>{c=!0;try{g?.destroy?.()}catch{}}},[b]),(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsx)(vK,{path:b,title:c,extLabel:"PPTX"}),(0,g.jsxs)("div",{className:"flex-1 overflow-auto bg-muted/30 py-4",children:[e&&!h&&(0,g.jsxs)("div",{className:"h-[60vh] flex items-center justify-center text-muted-foreground",children:[(0,g.jsx)(m.Loader2,{className:"h-5 w-5 animate-spin mr-2"}),"Rendering slides…"]}),h&&(0,g.jsx)("div",{className:"h-[60vh] flex items-center justify-center",children:(0,g.jsxs)("div",{className:"text-center space-y-2",children:[(0,g.jsx)("p",{className:"text-sm text-destructive",children:h}),(0,g.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try downloading the file and opening it externally."})]})}),(0,g.jsx)("div",{ref:d,className:"pptx-viewer-body mx-auto max-w-5xl px-4"})]})]})}function vN({path:b,title:c}){let[d,e]=(0,p.useState)(null),[f,h]=(0,p.useState)(0),[i,j]=(0,p.useState)(!0),[k,l]=(0,p.useState)(null),n=(0,p.useRef)(null);(0,p.useEffect)(()=>{if(!d||!n.current)return;let a=d[f];if(!a||null!==a.html)return;let{wb:b,toHtml:c}=n.current,g=c(b.Sheets[a.name]);e(a=>{if(!a)return a;let b=[...a];return b[f]={...b[f],html:g.html,rows:g.rows,truncated:g.truncated},b})},[d,f]),(0,p.useEffect)(()=>{let c=!1;return j(!0),l(null),e(null),(async()=>{try{let[d,f]=await Promise.all([a.A(57386),(0,bB.wsFetch)(`/api/assets/${b}`)]);if(c)return;if(!f.ok)throw Error(`Failed to load file (${f.status})`);let g=await f.arrayBuffer();if(c)return;let i=d.read(g,{type:"array",cellDates:!0,cellStyles:!0});if(c)return;n.current={wb:i,toHtml:a=>{let b=a["!ref"],c=b?d.utils.decode_range(b):null,e=c?c.e.r-c.s.r+1:0;if(!c||e<=2e3)return{html:d.utils.sheet_to_html(a,{editable:!1}),rows:e,truncated:!1};let f={...a,"!ref":d.utils.encode_range({s:c.s,e:{r:c.s.r+2e3-1,c:c.e.c}})};return{html:d.utils.sheet_to_html(f,{editable:!1}),rows:e,truncated:!0}}},e(i.SheetNames.map(a=>({name:a,html:null,rows:0,truncated:!1}))),h(0),j(!1)}catch(a){c||(l(a instanceof Error?a.message:"Failed to parse spreadsheet"),j(!1))}})(),()=>{c=!0}},[b]);let o=(0,p.useMemo)(()=>d?.[f]??null,[d,f]);return(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsx)(vK,{path:b,title:c,extLabel:"XLSX"}),d&&d.length>1&&(0,g.jsx)("div",{className:"flex items-center gap-0.5 border-b border-border bg-muted/40 px-2 overflow-x-auto scrollbar-none",children:d.map((a,b)=>(0,g.jsx)("button",{type:"button",onClick:()=>h(b),className:(0,ao.cn)("px-3 py-1.5 text-[12px] rounded-t whitespace-nowrap transition-colors",b===f?"bg-background text-foreground font-medium border-t border-x border-border -mb-px":"text-muted-foreground hover:text-foreground"),children:a.name},a.name+b))}),(0,g.jsxs)("div",{className:"flex-1 overflow-auto",children:[i&&!k&&(0,g.jsxs)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:[(0,g.jsx)(m.Loader2,{className:"h-5 w-5 animate-spin mr-2"}),"Parsing spreadsheet…"]}),k&&(0,g.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,g.jsxs)("div",{className:"text-center space-y-2",children:[(0,g.jsx)("p",{className:"text-sm text-destructive",children:k}),(0,g.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try downloading the file and opening it externally."})]})}),o?.truncated&&(0,g.jsxs)("div",{className:"px-3 py-2 text-[11px] text-amber-600 dark:text-amber-400 border-b border-border",children:["Large sheet (",o.rows.toLocaleString()," rows). Showing first"," ",2e3.toLocaleString()," for performance. Download the file to see everything."]}),o?.html!=null&&(0,g.jsx)("div",{className:"xlsx-sheet p-3 text-[12px]",dangerouslySetInnerHTML:{__html:o.html}})]})]})}let vO=(0,h.default)("wrap-text",[["path",{d:"m16 16-2 2 2 2",key:"kkc6pm"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["path",{d:"M3 18h7",key:"sq21v6"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]),vP=sV(vA);function vQ(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function vR(a){return`${a.lineStart}:${a.lineEnd}:${a.textHash}`}function vS(a){return`L${a.lineStart}-${a.lineEnd}`}async function vT(a){return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(a)))).map(a=>a.toString(16).padStart(2,"0")).join("").slice(0,12)}let vU={".js":"javascript",".cjs":"javascript",".mjs":"javascript",".ts":"typescript",".tsx":"typescript",".jsx":"javascript",".py":"python",".rb":"ruby",".php":"php",".sh":"bash",".bash":"bash",".zsh":"bash",".ps1":"powershell",".css":"css",".scss":"scss",".html":"xml",".json":"json",".jsonc":"json",".yaml":"yaml",".yml":"yaml",".toml":"ini",".ini":"ini",".xml":"xml",".sql":"sql",".graphql":"graphql",".gql":"graphql",".go":"go",".rs":"rust",".swift":"swift",".java":"java",".kt":"kotlin",".kts":"kotlin",".c":"c",".cpp":"cpp",".h":"c",".env":"bash",".txt":"",".text":"",".log":"",".rst":"",".mdx":"markdown"};function vV({path:a}){let[b,c]=(0,p.useState)(null),[d,e]=(0,p.useState)(0),[f,h]=(0,p.useState)(!1),[i,j]=(0,p.useState)(!0),[k,l]=(0,p.useState)(!1),[m,n]=(0,p.useState)(!1),[o,q]=(0,p.useState)(2e3),[s,t]=(0,p.useState)(new Map),[u,w]=(0,p.useState)(null),x=(0,p.useRef)(null),y=(0,bB.withWs)(`/api/assets/${a}`),z=a.split("/").pop()||a,A=vU[z.includes(".")?`.${z.split(".").pop()?.toLowerCase()}`:""]??"",B=oc(b=>b.byPath[a]?.sidecar??null),C=B?.comments??[],D=(0,p.useMemo)(()=>b?b.replace(/\r\n/g,"\n").split("\n"):[],[b]),E=(0,p.useCallback)(async()=>{j(!0),h(!1),c(null),e(0);try{let a=await (0,bB.wsFetch)(y);if(a.ok){let b=new Uint8Array(await a.arrayBuffer());!function(a){let b=Math.min(a.length,8192);if(0===b)return!1;let c=0;for(let d=0;d<b;d++){let b=a[d];if(0===b)return!0;(b<9||b>13&&b<32)&&c++}return c/b>.3}(b)?(e(b.length),c(new TextDecoder("utf-8").decode(b))):h(!0)}}catch{}finally{j(!1)}},[y]);(0,p.useEffect)(()=>{E(),oc.getState().loadSidecar(a),q(2e3),w(null)},[E,a]);let F=(0,p.useMemo)(()=>D.length,[D]),G=d>2097152||F>5e3,H=(0,p.useMemo)(()=>{if(!b)return[];if(G)return D.map(vQ);try{let a=A?vP.highlight(A,b):vP.highlightAuto(b);return(0,uW.toHtml)(a).split("\n")}catch{return D.map(vQ)}},[b,A,G,D]),I=G?H.slice(0,o):H,J=G&&o<H.length,K=(0,p.useMemo)(()=>{let a={};for(let b of C){if(!b.lineAnchor)continue;let c=vR(b.lineAnchor);(a[c]??=[]).push(b)}return a},[C]);(0,p.useEffect)(()=>{if(!b||f||i||!x.current)return void t(new Map);let a=x.current,c=a.getBoundingClientRect(),d=Array.from(a.querySelectorAll("[data-line]")),e=new Map;for(let b of d){let d=Number(b.dataset.line);if(!Number.isFinite(d))continue;let f=b.getBoundingClientRect();e.set(d,{top:f.top-c.top+a.scrollTop,left:f.left-c.left,width:f.width,bottom:f.bottom-c.top+a.scrollTop})}t(e)},[b,f,i,o,k,H]);let L=(0,p.useCallback)(()=>{let a=x.current,b=window.getSelection();if(!a||!b||b.isCollapsed||0===b.rangeCount)return;let c=b.getRangeAt(0);if(!a.contains(c.commonAncestorContainer))return;let d=a=>{let b=a?a.nodeType===Node.ELEMENT_NODE?a:a.parentElement:null;return b?.closest("[data-line]")??null},e=d(c.startContainer),f=d(c.endContainer);if(!e||!f)return;let g=Number(e.dataset.line),h=Number(f.dataset.line);if(!Number.isFinite(g)||!Number.isFinite(h))return;let i=Math.min(g,h),j=Math.max(g,h),k=D.slice(i-1,j).join("\n");(async()=>{let a={lineStart:i,lineEnd:j,textHash:await vT(k)};w({anchorKey:vR(a),anchorLabel:vS(a),lineAnchor:a,anchorEl:e})})()},[D]),M=(0,p.useCallback)((a,b)=>{w({anchorKey:vR(a),anchorLabel:vS(a),lineAnchor:a,anchorEl:b})},[]);return f?(0,g.jsx)(uQ,{path:a,title:z}):(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsxs)(ea,{path:a,badge:z.includes(".")?z.split(".").pop()?.toUpperCase()??"TEXT":"TEXT",children:[(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:`h-7 gap-1.5 text-xs ${k?"bg-muted":""}`,onClick:()=>l(a=>!a),title:k?"Disable line wrap":"Enable line wrap",children:[(0,g.jsx)(vO,{className:"h-3.5 w-3.5"}),"Wrap"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{b&&(navigator.clipboard.writeText(b),n(!0),setTimeout(()=>n(!1),2e3))},title:"Copy file contents",children:[m?(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,g.jsx)(bd.Copy,{className:"h-3.5 w-3.5"}),m?"Copied":"Copy"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let a=document.createElement("a");a.href=y,a.download=z,a.click()},title:"Download file",children:[(0,g.jsx)(b8.Download,{className:"h-3.5 w-3.5"}),"Download"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(y,"_blank"),children:[(0,g.jsx)(bE,{className:"h-3.5 w-3.5"}),"Raw"]})]}),(0,g.jsxs)("div",{ref:x,className:"relative flex-1 overflow-auto source-viewer-code bg-background",children:[!i&&b&&!f&&(0,g.jsx)(uM,{containerRef:x,onComment:L,align:"left"}),(0,g.jsx)("div",{className:"relative pointer-events-none",style:{height:0},children:Object.entries(K).map(([a,b])=>{let c=b[0]?.lineAnchor;if(!c)return null;let d=s.get(c.lineStart);return d?(0,g.jsx)("div",{style:{pointerEvents:"auto"},children:(0,g.jsx)(tw,{anchorKey:a,anchorLabel:vS(c),comments:b,top:d.top+4,left:Math.max(0,d.left-20),onClick:()=>{let a=x.current?.querySelector(`[data-line="${c.lineStart}"]`);a&&M(c,a)}})},`pip-${a}`):null})}),i?(0,g.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading..."}):(0,g.jsxs)(g.Fragment,{children:[G&&(0,g.jsxs)("div",{className:"px-4 py-2 text-[11px] text-amber-700 dark:text-amber-300 bg-amber-500/15 border-b border-amber-500/30 font-sans",children:["Large file (",(d/1048576).toFixed(1)," MB, ",H.length.toLocaleString()," lines). Syntax highlighting disabled for performance. Use Raw or Download for the full file."]}),(0,g.jsx)("div",{className:"leading-relaxed font-mono min-w-max",style:{fontSize:"calc(13px * var(--font-scale-code, 1))"},children:I.map((a,b)=>{let c=u?.lineAnchor,d=c&&b+1>=c.lineStart&&b+1<=c.lineEnd;return(0,g.jsxs)("div",{"data-line":b+1,className:`flex ${d?"bg-amber-400/25":"hover:bg-foreground/5"}`,children:[(0,g.jsx)("span",{className:"w-12 shrink-0 pr-4 text-right text-muted-foreground select-none sticky left-0 bg-muted",children:b+1}),(0,g.jsx)("span",{className:`text-foreground pl-2 ${k?"whitespace-pre-wrap break-all":"whitespace-pre"}`,dangerouslySetInnerHTML:{__html:a||" "}})]},b)})}),J&&(0,g.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-t border-border font-sans",children:[(0,g.jsxs)("button",{onClick:()=>q(a=>a+2e3),className:"text-[11px] text-foreground hover:text-foreground px-2.5 py-1 rounded bg-foreground/10 hover:bg-foreground/20 transition-colors",children:["Show ",Math.min(2e3,H.length-o).toLocaleString()," more"]}),(0,g.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[o.toLocaleString()," / ",H.length.toLocaleString()," lines"]})]})]}),u&&(0,g.jsx)(tX,{path:a,anchorKey:u.anchorKey,anchorLabel:u.anchorLabel,lineAnchor:u.lineAnchor,comments:K[u.anchorKey]??[],anchorEl:u.anchorEl,onClose:()=>w(null)})]})]})}var vW=a.i(360878),vX=a.i(211789);function vY({path:a,title:b,src:c,fullscreen:d,onExit:e,scriptsEnabled:f,onToggleScripts:h}){let[i,j]=(0,p.useState)(!1),k=f??i,l=(0,bB.withWs)(c??`/api/assets/${a}/index.html`),m=d&&e?(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:e,title:"Exit app",children:[(0,g.jsx)(uw,{className:"h-3.5 w-3.5"}),"Exit app"]}):null;return(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsxs)(ea,{path:a,badge:d?"App":void 0,showBreadcrumb:!d,leading:d?(0,g.jsxs)(g.Fragment,{children:[m,(0,g.jsx)("span",{className:"truncate text-[13px] font-medium text-foreground",children:b})]}):null,children:[(0,g.jsx)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:h??(()=>j(a=>!a)),title:k?"Disable scripts (recommended for untrusted content)":"Enable scripts",children:k?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(vX.Ban,{className:"h-3.5 w-3.5"}),"Disable scripts"]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(vW.Play,{className:"h-3.5 w-3.5"}),"Enable scripts"]})}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(l,"_blank"),children:[(0,g.jsx)(bE,{className:"h-3.5 w-3.5"}),"Open in new tab"]})]}),(0,g.jsx)("iframe",{src:l,className:"flex-1 w-full border-0 bg-card",title:b,sandbox:k?"allow-scripts allow-forms allow-popups allow-top-navigation-by-user-activation":"allow-forms allow-popups allow-top-navigation-by-user-activation"})]})}let vZ=(0,h.default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),v$={stopped:"Stopped",installing:"Installing dependencies…",starting:"Starting…",running:"Running",error:"Error"};function v_({path:a,title:b}){let[c,d]=(0,p.useState)("stopped"),[e,f]=(0,p.useState)(null),[h,i]=(0,p.useState)([]),[j,k]=(0,p.useState)(null),[l,n]=(0,p.useState)(!1),[o,r]=(0,p.useState)(0),[t,u]=(0,p.useState)([]),[w,x]=(0,p.useState)(null),y=(0,p.useRef)(null),z=(0,p.useRef)(null),A=(0,bB.withWs)(`/api/app-proxy/${a}/`),B=()=>{y.current&&(clearInterval(y.current),y.current=null)},C=(0,p.useCallback)(async()=>{try{let b=await (0,bB.wsFetch)(`/api/wiki/app?path=${encodeURIComponent(a)}`);if(!b.ok)return;let c=await b.json();d(c.status),i(c.logs??[]),c.scripts&&u(c.scripts),void 0!==c.defaultScript&&x(c.defaultScript),c.port&&f(c.port),c.error&&k(c.error),("running"===c.status||"stopped"===c.status||"error"===c.status)&&B()}catch{}},[a]);(0,p.useEffect)(()=>("installing"===c||"starting"===c?y.current||(y.current=setInterval(C,800)):B(),B),[c,C]),(0,p.useEffect)(()=>{z.current?.scrollIntoView({behavior:"smooth"})},[h]),(0,p.useEffect)(()=>{C()},[C]);let D=async b=>{k(null),i([]),d("starting");try{let c=await (0,bB.wsFetch)("/api/wiki/app",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a,script:b})}),e=await c.json();if(!c.ok||e.error){d("error"),k(e.error??"Failed to start");return}e.port&&f(e.port),await C()}catch(a){d("error"),k(String(a))}},E=async()=>{await (0,bB.wsFetch)("/api/wiki/app",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})}),d("stopped"),f(null)},F=async()=>{await E(),await D(),r(a=>a+1)},G=t.filter(a=>a!==w);return(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsxs)(ea,{path:a,badge:"Node app",children:["running"===c&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>r(a=>a+1),children:[(0,g.jsx)(bI,{className:"h-3.5 w-3.5"}),"Refresh"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(A,"_blank"),children:[(0,g.jsx)(bE,{className:"h-3.5 w-3.5"}),"Open in new tab"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:F,children:[(0,g.jsx)(bI,{className:"h-3.5 w-3.5"}),"Restart"]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs text-destructive hover:text-destructive",onClick:E,children:[(0,g.jsx)(vZ,{className:"h-3.5 w-3.5"}),"Stop"]})]}),(0,g.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>n(a=>!a),children:[(0,g.jsx)(ce,{className:"h-3.5 w-3.5"}),"Logs"]})]}),l&&(0,g.jsxs)("div",{className:"border-b bg-black/90 text-green-400 font-mono text-xs h-40 overflow-auto p-2 shrink-0",children:[0===h.length?(0,g.jsx)("span",{className:"text-muted-foreground",children:"No output yet."}):h.map((a,b)=>(0,g.jsx)("div",{className:"whitespace-pre-wrap leading-5",children:a},b)),(0,g.jsx)("div",{ref:z})]}),(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:["stopped"===c&&(0,g.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-4",children:[(0,g.jsxs)("div",{className:"text-center space-y-1",children:[(0,g.jsx)("p",{className:"text-sm font-medium",children:b}),(0,g.jsx)("p",{className:"text-xs text-muted-foreground",children:"Node.js app — will be started on a local port"})]}),(0,g.jsxs)("div",{className:"inline-flex items-stretch overflow-hidden rounded-full bg-primary text-primary-foreground shadow-e-1",children:[(0,g.jsxs)("button",{type:"button",onClick:()=>D(),className:"inline-flex items-center gap-2 px-4 py-2.5 text-sm font-medium transition-colors hover:bg-primary-foreground/10 focus-visible:outline-none",children:[(0,g.jsx)(vW.Play,{className:"h-4 w-4"}),"Launch app",w&&(0,g.jsxs)("span",{className:"opacity-70",children:["(",w,")"]})]}),G.length>0&&(0,g.jsxs)(ax.DropdownMenu,{children:[(0,g.jsx)(ax.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsx)("button",{type:"button",className:"inline-flex items-center justify-center border-l border-l-primary-foreground/20 px-2 transition-colors hover:bg-primary-foreground/10 focus-visible:outline-none","aria-label":"Choose script to launch",children:(0,g.jsx)(s,{className:"h-4 w-4"})})}),(0,g.jsxs)(ax.DropdownMenuContent,{align:"end",children:[(0,g.jsx)(ax.DropdownMenuLabel,{children:"Run script"}),(0,g.jsx)(ax.DropdownMenuSeparator,{}),t.map(a=>(0,g.jsxs)(ax.DropdownMenuItem,{onSelect:()=>D(a),className:"gap-2 font-mono text-xs",children:[(0,g.jsx)(vW.Play,{className:"h-3.5 w-3.5"}),a,a===w&&(0,g.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"default"})]},a))]})]})]})]}),("installing"===c||"starting"===c)&&(0,g.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3",children:[(0,g.jsx)(m.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"}),(0,g.jsx)("p",{className:"text-sm text-muted-foreground",children:v$[c]}),e&&(0,g.jsxs)("p",{className:"text-xs text-muted-foreground/60",children:["port ",e]}),(0,g.jsxs)(v.Button,{onClick:E,variant:"outline",size:"sm",className:"gap-2",children:[(0,g.jsx)(vZ,{className:"h-3.5 w-3.5"}),"Cancel"]})]}),"error"===c&&(0,g.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-6",children:[(0,g.jsx)(q.AlertCircle,{className:"h-8 w-8 text-destructive"}),(0,g.jsxs)("div",{className:"text-center space-y-1 max-w-md",children:[(0,g.jsx)("p",{className:"text-sm font-medium text-destructive",children:"Failed to start app"}),(0,g.jsx)("p",{className:"text-xs text-muted-foreground break-words",children:j??"Unknown error"})]}),(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsx)(v.Button,{onClick:E,variant:"ghost",className:"gap-2",children:"Back"}),(0,g.jsxs)(v.Button,{onClick:F,variant:"outline",className:"gap-2",children:[(0,g.jsx)(bI,{className:"h-4 w-4"}),"Try again"]})]})]}),"running"===c&&(0,g.jsx)("iframe",{src:A,className:"flex-1 w-full border-0 bg-card",title:b,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-top-navigation-by-user-activation"},o)]})]})}let v0=(0,d6.default)(async()=>{},{loadableGenerated:{modules:[904378]},ssr:!1});function v1(a){let b=new Date(a).getTime();if(!Number.isFinite(b))return"";let c=Math.floor(Math.max(0,Date.now()-b)/1e3);if(c<60)return"just now";let d=Math.floor(c/60);if(d<60)return`${d}m ago`;let e=Math.floor(d/60);return e<24?`${e}h ago`:`${Math.floor(e/24)}d ago`}let v2=new Set(["image","media","pdf","fallback","app","node-app","html"]);function v3({openFile:a,fileContent:b,fileLoading:c,editing:d,setEditing:e,editContent:f,setEditContent:h,saving:i,saveError:n,onSave:q,gitFileInfo:s,showHistory:t,historyLoading:u,historyCommits:w,selectedDiffSha:x,diffContent:y,diffLoading:z,onToggleHistory:A,onSelectDiff:B,gateBypassPath:C,onBypassGate:D,onRefresh:E,onShare:F,onClose:G,renderCopyMenu:H,appKey:I,setAppKey:J,appFullscreen:K,setAppFullscreen:L,viewerKey:M,setViewerKey:N,htmlSourceMode:O,setHtmlSourceMode:P,widthAwareViewer:Q,viewWidth:R,viewAlign:S,setViewWidth:T,setViewAlign:U,contentWidthClass:V,contentAlignClass:W,isMobile:X,sidebarCollapsed:Y}){let[Z,$]=(0,p.useState)(null),[_,aa]=(0,p.useState)(null),[ab,ac]=(0,p.useState)(!1);(0,p.useEffect)(()=>{ac(!1)},[a.path]);let ad=cL(a.name,a.nodeType),ae=!v2.has(ad)&&(a.size??0)>5242880&&C!==a.path;if("node-app"===ad)return(0,g.jsx)(v_,{path:a.path,title:a.name});let af="html"===ad?(0,bB.withWs)(`/api/assets/${a.path}`):void 0;return"app"===ad||"html"===ad?K?(0,g.jsx)(vY,{scriptsEnabled:ab,onToggleScripts:()=>ac(a=>!a),path:a.path,title:a.name,src:af,fullscreen:!0,onExit:()=>L(!1)}):(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,g.jsxs)("div",{className:(0,ao.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 ",!X&&Y&&"pl-11"),children:[(0,g.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,g.jsx)("span",{className:"hidden md:inline-flex",children:(0,g.jsx)("span",{className:"",children:(0,g.jsx)(k,{className:"h-4 w-4 shrink-0 text-foreground/70"})})}),(0,g.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:a.path,children:a.path}),(0,g.jsx)("div",{ref:a=>{a&&aa(a)},className:"flex items-center gap-1 shrink-0"})]}),(0,g.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,g.jsx)("div",{ref:a=>{a&&$(a)},className:"flex items-center gap-1 shrink-0"}),H(a,(0,g.jsxs)(g.Fragment,{children:["html"===ad&&!d&&(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>P(!O),children:[O?(0,g.jsx)(k,{className:"mr-2 h-3.5 w-3.5"}):(0,g.jsx)(d1,{className:"mr-2 h-3.5 w-3.5"}),O?"Show preview":"Show source"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>J(a=>a+1),children:[(0,g.jsx)(bI,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>L(!0),children:[(0,g.jsx)(d2,{className:"mr-2 h-3.5 w-3.5"}),"Open fullscreen"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:F,children:[(0,g.jsx)(d4,{className:"mr-2 h-3.5 w-3.5"}),"Share"]})]})),"html"===ad&&!d&&null!==b&&(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Edit source",onClick:()=>{e(!0),h(b)},children:(0,g.jsx)(d3,{className:"h-3.5 w-3.5"})}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:G,children:(0,g.jsx)(o,{className:"h-3.5 w-3.5"})})]})]}),d&&"html"===ad?(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[(0,g.jsx)("textarea",{value:f,onChange:a=>h(a.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"}),(0,g.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[n&&(0,g.jsx)("span",{className:"text-xs text-destructive mr-auto",children:n}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",onClick:()=>e(!1),children:"Cancel"}),(0,g.jsxs)(v.Button,{size:"sm",className:"gap-1",onClick:q,disabled:i,children:[i&&(0,g.jsx)(m.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):O&&"html"===ad?(0,g.jsx)(d9.Provider,{value:_,children:(0,g.jsx)(d8.Provider,{value:Z,children:(0,g.jsx)(vV,{path:a.path,title:a.name})})}):(0,g.jsx)(d9.Provider,{value:_,children:(0,g.jsx)(d8.Provider,{value:Z,children:(0,g.jsx)(vY,{scriptsEnabled:ab,onToggleScripts:()=>ac(a=>!a),path:a.path,title:a.name,src:af},I)})})]}):(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,g.jsxs)("div",{className:(0,ao.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 ",!X&&Y&&"pl-11"),children:[(0,g.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,g.jsx)("span",{className:"hidden md:inline-flex",children:(0,g.jsx)("span",{className:"",children:cP(a.name)?(0,g.jsx)(l,{className:"h-4 w-4 shrink-0 text-sunshine-700"}):cN(a.name)?(0,g.jsx)(j.FileText,{className:"h-4 w-4 shrink-0 text-foreground/70"}):(0,g.jsx)(cb,{className:"h-4 w-4 shrink-0 text-foreground/60"})})}),(0,g.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:a.path,children:a.path}),(0,g.jsx)("div",{ref:a=>{a&&aa(a)},className:"flex items-center gap-1 shrink-0"}),s&&(0,g.jsxs)("span",{className:"hidden md:flex items-center gap-1 text-[11px] text-muted-foreground shrink-0 ml-1",children:[(0,g.jsx)(d5,{className:"h-3 w-3 shrink-0"}),(0,g.jsx)("span",{className:"truncate max-w-[100px]",children:s.author}),(0,g.jsx)("span",{title:new Date(s.date).toLocaleString(),className:"shrink-0",children:v1(s.date)})]})]}),(0,g.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,g.jsx)("div",{ref:a=>{a&&$(a)},className:"flex items-center gap-1 shrink-0"}),H(a,(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(ax.DropdownMenuItem,{onClick:A,children:[(0,g.jsx)(dQ,{className:"mr-2 h-3.5 w-3.5"}),t?"Hide history":"File history"]}),(0,g.jsxs)(ax.DropdownMenuItem,{onClick:F,children:[(0,g.jsx)(d4,{className:"mr-2 h-3.5 w-3.5"}),"Share"]}),!d&&(0,g.jsxs)(ax.DropdownMenuItem,{onClick:E,disabled:c,children:[c?(0,g.jsx)(m.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,g.jsx)(bI,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),Q&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ax.DropdownMenuSeparator,{}),(0,g.jsx)(ax.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Width"}),dK.VIEW_WIDTH_ORDER.map(a=>(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>T(a),className:"flex items-center justify-between text-xs",children:[dK.VIEW_WIDTH_LABEL[a],a===R&&(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5"})]},a)),(0,g.jsx)(ax.DropdownMenuSeparator,{}),(0,g.jsx)(ax.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Alignment"}),dK.VIEW_ALIGN_ORDER.map(a=>(0,g.jsxs)(ax.DropdownMenuItem,{onClick:()=>U(a),className:"flex items-center justify-between text-xs",children:[dK.VIEW_ALIGN_LABEL[a],a===S&&(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5"})]},a))]})]})),cN(a.name)&&!d&&(null!==b||cO(a.name))&&(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{e(!0),h(b??"")},children:(0,g.jsx)(d3,{className:"h-3.5 w-3.5"})}),cN(a.name)&&d&&cO(a.name)&&(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Done editing",onClick:()=>e(!1),children:(0,g.jsx)(dO.Eye,{className:"h-3.5 w-3.5"})}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:G,children:(0,g.jsx)(o,{className:"h-3.5 w-3.5"})})]})]}),t&&(0,g.jsxs)("div",{className:"border-b bg-muted/30 shrink-0 max-h-[40vh] overflow-auto",children:[(0,g.jsxs)("div",{className:"flex items-center justify-between px-4 py-1.5 border-b",children:[(0,g.jsx)("span",{className:"text-xs font-semibold text-muted-foreground",children:"History"}),(0,g.jsx)("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:A,children:(0,g.jsx)(o,{className:"h-3.5 w-3.5"})})]}),u?(0,g.jsx)("div",{className:"flex justify-center py-4",children:(0,g.jsx)(m.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):0===w.length?(0,g.jsx)("p",{className:"px-4 py-3 text-xs text-muted-foreground",children:"No history found."}):(0,g.jsx)("div",{children:w.map(a=>(0,g.jsxs)("div",{children:[(0,g.jsx)("button",{type:"button",className:(0,ao.cn)("w-full text-left px-4 py-2 hover:bg-muted transition-colors",x===a.sha&&"bg-muted"),onClick:()=>B(a.sha),children:(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsx)("code",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:a.shortSha}),(0,g.jsx)("span",{className:"flex-1 truncate text-xs",children:a.message}),(0,g.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:a.author}),(0,g.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",title:new Date(a.date).toLocaleString(),children:v1(a.date)})]})}),x===a.sha&&(0,g.jsx)("div",{className:"border-t",children:z?(0,g.jsx)("div",{className:"flex justify-center py-3",children:(0,g.jsx)(m.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):null!==y?(0,g.jsx)("pre",{className:"overflow-auto px-4 py-2 text-[11px] font-mono leading-relaxed whitespace-pre text-foreground/80 max-h-60",children:y}):null})]},a.sha))})]}),ae?(0,g.jsx)(uS,{path:a.path,size:a.size??0,onOpen:D}):d?(0,g.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:cO(a.name)?(0,g.jsx)(uP,{}):(0,g.jsx)("textarea",{value:f,onChange:a=>h(a.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"})}):cO(a.name)?(0,g.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:c?(0,g.jsx)("div",{className:"flex justify-center py-8",children:(0,g.jsx)(m.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,g.jsx)(uP,{mode:"viewing"})}):"csv"===ad||"pdf"===ad||"mermaid"===ad||"notebook"===ad||"image"===ad||"media"===ad||"docx"===ad||"xlsx"===ad||"pptx"===ad||"source"===ad||"fallback"===ad?(0,g.jsx)(d9.Provider,{value:_,children:(0,g.jsx)(d8.Provider,{value:Z,children:(0,g.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:c?(0,g.jsx)("div",{className:"flex justify-center py-8",children:(0,g.jsx)(m.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):"csv"===ad?(0,g.jsx)(ed,{path:a.path,title:a.name}):"pdf"===ad?(0,g.jsx)(v0,{path:a.path,title:a.name}):"mermaid"===ad?(0,g.jsx)(uV,{path:a.path,title:a.name}):"notebook"===ad?(0,g.jsx)(vJ,{path:a.path,title:a.name}):"image"===ad?(0,g.jsx)(uT,{path:a.path,title:a.name}):"media"===ad?(0,g.jsx)(uU,{path:a.path,title:a.name,type:["mp4","webm","mov","m4v"].includes(cK(a.name))?"video":"audio"}):"docx"===ad?(0,g.jsx)(vL,{path:a.path,title:a.name}):"xlsx"===ad?(0,g.jsx)(vN,{path:a.path,title:a.name}):"pptx"===ad?(0,g.jsx)(vM,{path:a.path,title:a.name}):"source"===ad?(0,g.jsx)(vV,{path:a.path,title:a.name}):(0,g.jsx)(uQ,{path:a.path,title:a.name})},M)})}):(0,g.jsx)("div",{className:"flex-1 overflow-auto p-4 min-h-0",children:(0,g.jsx)("div",{className:(0,ao.cn)("w-full",W,V),children:c?(0,g.jsx)("div",{className:"flex justify-center py-8",children:(0,g.jsx)(m.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):null!==b?(0,g.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words leading-relaxed",children:b}):cN(a.name)?(0,g.jsx)("p",{className:"text-sm text-muted-foreground",children:"Could not load file."}):(0,g.jsx)("p",{className:"text-sm text-muted-foreground",children:"Preview not available for this file type."})})}),d&&!cO(a.name)&&(0,g.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[n&&(0,g.jsx)("span",{className:"text-xs text-destructive mr-auto",children:n}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",onClick:()=>e(!1),children:"Cancel"}),(0,g.jsxs)(v.Button,{size:"sm",className:"gap-1",onClick:q,disabled:i,children:[i&&(0,g.jsx)(m.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]})}function v4(a="(max-width: 767px)"){let[b,c]=(0,p.useState)(!1);return(0,p.useEffect)(()=>{let b=window.matchMedia(a),d=()=>c(b.matches);return d(),b.addEventListener("change",d),()=>b.removeEventListener("change",d)},[a]),b}let v5=(0,ay.create)(a=>({recents:[],loadForWorkspace:b=>{a({recents:[]})},push:(b,c)=>{let d=[].filter(a=>a.path!==b.path);a({recents:[b,...d].slice(0,15)})}})),v6=new Map,v7=new Map;async function v8(a){let b=await (0,bB.wsFetch)(`/api/wiki?dir=${encodeURIComponent(a)}`);return b.ok?(await b.json()).entries.map(b=>({name:b.name,path:a?`${a}/${b.name}`:b.name,type:b.type,size:b.size,modifiedAt:b.modifiedAt,expanded:!1,git:b.git})):[]}async function v9(a){let b=v6.get(a);if(b)return v6.delete(a),b;let c=v7.get(a);if(c){let b=await c;return v6.delete(a),b}return null}function wa(a,b,c){return a.map(a=>a.path===b?c(a):a.children?{...a,children:wa(a.children,b,c)}:a)}function wb(a){let b=[];for(let c of a)("dir"===c.type||"app"===c.type||"node-app"===c.type)&&c.expanded&&c.children&&(b.push(c.path),b.push(...wb(c.children)));return b}function wc(a){return a.split("/").pop()??a}a.s(["default",0,function(){let a=function(){let[a,b]=(0,p.useState)(null),[c,d]=(0,p.useState)(null),[e,f]=(0,p.useState)(()=>null),[g,h]=(0,p.useState)([]),[i,j]=(0,p.useState)(!1),[k,l]=(0,p.useState)(!1),[m,n]=(0,p.useState)(null),[o,q]=(0,p.useState)(null),[r,s]=(0,p.useState)({}),[t,u]=(0,p.useState)(null),[v,w]=(0,p.useState)(null),[x,y]=(0,p.useState)(null),[z,A]=(0,p.useState)(null),B=(0,p.useCallback)(async()=>{let a=(0,bB.getEphemeralRoot)();if(a){h([]),j(!1),b(!0),d(a),f(`root:${a}`);return}try{let a=await fetch((0,av.apiUrl)("/api/system/workspaces"));if(!a.ok)throw Error("Failed");let c=await a.json();if(h(c.workspaces),j(c.isAdmin),c.workspaces.length>0){b(!0);let a=new URLSearchParams(window.location.search).get("ws"),e=a?c.workspaces.find(b=>b.id===a):null,g=e??[...c.workspaces].sort((a,b)=>(b.lastOpenedAt??b.createdAt).localeCompare(a.lastOpenedAt??a.createdAt))[0];if(f(g.id),d(g.rootDir),!e){let a=new URL(location.href);a.searchParams.set("ws",g.id),history.replaceState(null,"",a.toString())}}else b(!1)}catch{b(!1)}},[]);(0,p.useEffect)(()=>{B()},[B]);let C=(0,p.useCallback)(async a=>{if(a===e)return;try{await fetch((0,av.apiUrl)(`/api/system/workspaces/${a}/open`),{method:"POST"})}catch{}let b=new URL(location.href);b.searchParams.set("ws",a),b.searchParams.delete("path"),history.pushState(null,"",b.toString()),oa.getState().invalidate(),us.getState().invalidateAll();let c=g.find(b=>b.id===a);c&&d(c.rootDir),f(a)},[e,g]),D=(0,p.useCallback)(async a=>{if(m)try{if(!(await fetch((0,av.apiUrl)(`/api/system/workspaces/${m}`),{method:"DELETE"})).ok)throw Error("Failed");if(m===e){let c=g.filter(a=>a.id!==m);if(c.length>0){let b=[...c].sort((a,b)=>(b.lastOpenedAt??b.createdAt).localeCompare(a.lastOpenedAt??a.createdAt))[0];await a(b.id)}else b(!1)}await B()}catch{}finally{n(null)}},[m,e,g,B]),E=(0,p.useCallback)(async a=>{if(!o){q(a);try{let b=await fetch((0,av.apiUrl)(`/api/system/workspaces/${a}/refresh`),{method:"POST"});if(!b.ok){let a=await b.json();au(a.error??"Refresh failed");return}await B()}catch{au("Refresh failed")}finally{q(null)}}},[o,B]),F=(0,p.useCallback)(async a=>{if(!r[a])try{let b=await fetch((0,av.apiUrl)(`/api/system/workspaces/${a}/branch`));if(!b.ok)return;let c=await b.json();s(b=>({...b,[a]:c.branches??[]}))}catch{}},[r]),G=(0,p.useCallback)(async(a,b)=>{if(!t){u(a),w(b);try{let c=await fetch((0,av.apiUrl)(`/api/system/workspaces/${a}/branch`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:b})});if(!c.ok){let a=await c.json();au(a.error??"Branch switch failed");return}at(`Switched to ${b}`),y(null),A(null),await B()}catch{au("Branch switch failed")}finally{u(null),w(null)}}},[t,B]);return{rootConfigured:a,rootPath:c,activeWorkspaceId:e,workspaces:g,isWsAdmin:i,addingWorkspace:k,setAddingWorkspace:l,setRootConfigured:b,setActiveWorkspaceId:f,deletingWorkspaceId:m,setDeletingWorkspaceId:n,refreshingWsId:o,wsBranches:r,switchingBranch:t,switchingBranchName:v,branchPickerWsId:x,setBranchPickerWsId:y,wsBranchPos:z,setWsBranchPos:A,loadWorkspaces:B,switchWorkspace:C,handleDeleteWorkspace:D,handleRefreshWorkspace:E,loadWsBranches:F,handleSwitchBranch:G}}(),b=(0,p.useRef)(()=>{}),c=function({activeWorkspaceId:a,rootConfigured:b,onExternalChange:c}){let[d,e]=(0,p.useState)([]),[f,g]=(0,p.useState)(!1),[h,i]=(0,p.useState)(!1),j=(0,p.useRef)(!1),[k,l]=(0,p.useState)(!1),[m,n]=(0,p.useState)({}),[o,q]=(0,p.useState)({}),[r,s]=(0,p.useState)(null),[t,u]=(0,p.useState)(null),[v,w]=(0,p.useState)(null),[x,y]=(0,p.useState)(null);(0,p.useEffect)(()=>{e([]),g(!1),j.current=!1,n({}),q({}),s(null),u(null),w(null),y(null)},[a]),(0,p.useEffect)(()=>{!a||f||j.current||(j.current=!0,i(!0),v8("").then(a=>{e(a),g(!0),i(!1)}).catch(()=>{j.current=!1,i(!1)}))},[f,a]);let z=(0,p.useCallback)(async a=>{let b=await v8(a);""===a?e(a=>{let c=new Map(a.map(a=>[a.path,a]));return b.map(a=>{let b=c.get(a.path);return b&&("dir"===b.type||"app"===b.type)?{...a,expanded:b.expanded,children:b.children}:a})}):e(c=>wa(c,a,a=>({...a,children:b,expanded:!0})))},[]),A=(0,p.useCallback)(async a=>{let b=a.split("/");if(b.length<=1)return;let c=[],d="";for(let a=0;a<b.length-1;a++)d=d?`${d}/${b[a]}`:b[a],c.push({prefix:d,children:await v8(d)});e(a=>{let b=a;for(let{prefix:a,children:d}of c)b=wa(b,a,a=>({...a,children:d,expanded:!0}));return b})},[]),B=(0,p.useCallback)(async()=>{l(!0);try{let a=wb(d),b=await v8("");for(let c of(e(b),a)){let a=await v8(c);e(b=>wa(b,c,b=>({...b,children:a,expanded:!0})))}}finally{l(!1)}},[d]),C=(0,p.useCallback)(async a=>{if("dir"===a.type||"app"===a.type||"node-app"===a.type)if(a.expanded)e(b=>wa(b,a.path,a=>({...a,expanded:!1})));else if(void 0===a.children){let b=await v9(a.path);if(b)return void e(c=>wa(c,a.path,a=>({...a,loading:!1,children:b,expanded:!0})));e(b=>wa(b,a.path,a=>({...a,loading:!0})));let c=await v8(a.path);e(b=>wa(b,a.path,a=>({...a,loading:!1,children:c,expanded:!0})))}else e(b=>wa(b,a.path,a=>({...a,expanded:!0})))},[]),D=(0,p.useCallback)(a=>{"file"===a.type?(a.name.endsWith(".md")||a.name.endsWith(".markdown"))&&bW(a.path):function(a){if(v6.has(a)||v7.has(a))return;let b=v8(a).then(b=>(v6.set(a,b),b)).finally(()=>v7.delete(a));v7.set(a,b),b.catch(()=>{})}(a.path)},[]),E=(0,p.useRef)([]);(0,p.useEffect)(()=>{E.current=wb(d)},[d]);let F=(0,p.useMemo)(()=>wb(d).filter(a=>""!==a).slice(0,24).join("\n"),[d]),[G,H]=(0,p.useState)("");(0,p.useEffect)(()=>{let a=setTimeout(()=>H(F),300);return()=>clearTimeout(a)},[F]);let I=(0,p.useRef)(c);(0,p.useEffect)(()=>{I.current=c},[c]),(0,p.useEffect)(()=>{if(!b||(0,av.isLite)()||!a)return;let c=new Map;function d(a){c.has(a)&&clearTimeout(c.get(a)),c.set(a,setTimeout(()=>{c.delete(a),z(a)},300))}let e=(G?G.split("\n"):[]).map(a=>`dir=${encodeURIComponent(a)}`).join("&"),f=new EventSource((0,bB.withWs)(e?`/api/wiki/watch?${e}`:"/api/wiki/watch"));return f.onmessage=a=>{let b;try{b=JSON.parse(a.data)}catch{return}let{type:e,path:f}=b;if("rescan"===e){for(let a of(us.getState().invalidateAll(),d(""),E.current))d(a);return}("add"===e||"change"===e||"unlink"===e)&&us.getState().invalidateAll();let g=f.split("/");if(d(g.length>1?g.slice(0,-1).join("/"):""),"change"===e){let a=`__file__${f}`;c.has(a)&&clearTimeout(c.get(a)),c.set(a,setTimeout(()=>{c.delete(a),I.current?.(f)},400))}},()=>{for(let a of(f.close(),c.values()))clearTimeout(a)}},[b,z,a,G]);let J=(0,p.useCallback)(async a=>{if(!m[a]&&!o[a]){q(b=>({...b,[a]:!0}));try{let b=await (0,bB.wsFetch)(`/api/wiki/git-branches?path=${encodeURIComponent(a)}`);if(!b.ok)return void au("Could not load branches");let c=await b.json();n(b=>({...b,[a]:c.branches}))}catch{au("Could not load branches")}finally{q(b=>({...b,[a]:!1}))}}},[m,o]),K=(0,p.useCallback)(async(a,b,c)=>{if(!r){s(b);try{let d=await (0,bB.wsFetch)("/api/wiki/git-checkout",{method:"POST",body:JSON.stringify({path:a,branch:b})});if(409===d.status)return void au("Repository has uncommitted changes");if(!d.ok){let a=await d.json();au(a.error??"Checkout failed");return}let e=await d.json();at(`Switched to ${e.branch}`),w(null),y(null),n(b=>{let c={...b};return delete c[a],c}),await z(c)}catch{au("Checkout failed")}finally{s(null)}}},[r,z]),L=(0,p.useCallback)(async(a,b)=>{if(!t){u(a);try{let c=await (0,bB.wsFetch)("/api/wiki/git-pull",{method:"POST",body:JSON.stringify({path:a})});if(!c.ok){let a=await c.json();au(a.message??a.error??"Pull failed");return}let d=await c.json();at(`Pulled ${a} (${d.branch} @ ${d.sha.slice(0,7)})`),await z(b)}catch{au("Pull failed")}finally{u(null)}}},[t,z]);return{roots:d,rootLoaded:f,rootLoading:h,refreshingTree:k,refreshTree:B,reloadDir:z,revealPath:A,toggleFolder:C,prefetch:D,nodeBranches:m,branchesLoading:o,checkingOutBranch:r,pullingRepo:t,branchDropdownNode:v,setBranchDropdownNode:w,branchDropdownPos:x,setBranchDropdownPos:y,loadBranches:J,handleCheckout:K,handleGitPull:L}}({activeWorkspaceId:a.activeWorkspaceId,rootConfigured:a.rootConfigured,onExternalChange:(0,p.useCallback)(a=>b.current(a),[])}),d=function({activeWorkspaceId:a,rootPath:b,isMobile:c,setSidebarCollapsed:d,treeApi:e}){let[f,g]=(0,p.useState)(null),[h,i]=(0,p.useState)(null),[j,k]=(0,p.useState)(!1),[l,m]=(0,p.useState)(0),[n,o]=(0,p.useState)(0),[q,r]=(0,p.useState)(null),[s,t]=(0,p.useState)(0),[u,v]=(0,p.useState)(!1),[w,x]=(0,p.useState)(!1),[y,z]=(0,p.useState)(""),[A,B]=(0,p.useState)(!1),[C,D]=(0,p.useState)(!1),[E,F]=(0,p.useState)(null),G=(0,p.useRef)(null),H=(0,p.useRef)(!1);(0,p.useEffect)(()=>{G.current=f},[f]),(0,p.useEffect)(()=>{H.current=w},[w]);let I=(0,p.useMemo)(()=>f?cL(f.name,f.nodeType):null,[f]),J=(0,p.useCallback)(()=>{x(!1),B(!1),F(null),r(null),t(0),i(null)},[]),K=(0,p.useCallback)(async(a,b)=>{var c;if(["editor","text"].includes(b)||cN((c=a).split("/").pop()??c)){v(!0);try{let b=await (0,bB.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(a)}`);if(b.ok){let a=await b.json();r(a.content),t(Number(b.headers.get("X-Wiki-Revision")??0))}}catch{}v(!1)}},[]),L=(0,p.useCallback)(async b=>{if("file"===b.type&&v5.getState().push({path:b.path,name:b.name},a),g({path:b.path,name:b.name,size:b.size,nodeType:"app"===b.type?"app":"node-app"===b.type?"node-app":"file"}),J(),"file"===b.type&&cO(b.name)){v(!0);try{await b_.getState().loadPage(b.path)}finally{v(!1)}return}let c=cL(b.name,b.type);await K(b.path,c)},[a,J,K]),M=(0,p.useCallback)(()=>{g(null),r(null),x(!1),B(!1),F(null)},[]),N=(0,p.useCallback)(()=>{g(null),r(null),x(!1),B(!1),F(null),t(0)},[]),O=(0,p.useCallback)(a=>{let b=a.split("/").pop()??a;e.revealPath(a),L({path:a,name:b,type:"file",modifiedAt:""})},[L,e]),P=(0,p.useCallback)(async a=>{let b=a.path.split("/").slice(0,-1).join("/"),f=(await v8(b)).find(b=>b.path===a.path);if(f){if("dir"===f.type){await e.revealPath(a.path),await e.toggleFolder(f);return}if("app"===f.type||"node-app"===f.type){await e.revealPath(f.path),L({path:f.path,name:f.name,type:f.type,modifiedAt:f.modifiedAt}),await e.toggleFolder(f),c&&d(!0);return}L({path:f.path,name:f.name,type:f.type,modifiedAt:f.modifiedAt}),c&&d(!0)}},[c,L,d,e]),Q=(0,p.useCallback)(async a=>{if(!a)return void g(null);let c=(0,bB.toRootRelative)(a,(0,bB.getEphemeralRoot)()??b);if(null===c||!(a=c))return;let d=a.split("/"),f=d[d.length-1],h=d.slice(0,-1).join("/"),i=(await v8(h)).find(b=>b.path===a);i&&(await e.revealPath(a),L({path:a,name:f,type:i.type,modifiedAt:i.modifiedAt}))},[L,b,e]);(0,p.useEffect)(()=>{},[f]),(0,p.useEffect)(()=>{},[Q]);let[R,S]=(0,p.useState)(!1);(0,p.useEffect)(()=>{S("1"===new URLSearchParams(window.location.search).get("embed"))},[]),(0,p.useEffect)(()=>{if(!R)return;let a=a=>{a.origin!==window.location.origin?console.warn(`[wiki-viewer] ignored postMessage from untrusted parent origin ${a.origin}.`):a.data&&"open-file"===a.data.type&&"string"==typeof a.data.path&&Q(a.data.path)};return window.addEventListener("message",a),()=>window.removeEventListener("message",a)},[R,Q]);let T=(0,p.useRef)(null),U=(0,p.useRef)(!1),[V,W]=(0,p.useState)(!1),X=(0,p.useCallback)(()=>W(!0),[]);(0,p.useEffect)(()=>{U.current||V&&(U.current=!0,Q(T.current))},[V,Q]),(0,p.useEffect)(()=>{f&&cO(f.name)&&b_.getState().currentPath!==f.path&&b_.getState().loadPage(f.path)},[f]);let Y=(0,p.useCallback)(async()=>{let a=G.current;if(a){if(cO(a.name)){v(!0);try{await b_.getState().loadPage(a.path)}finally{v(!1)}return}if(["editor","text"].includes(cL(a.name,a.nodeType))||cN(a.name)){v(!0);try{let b=await (0,bB.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(a.path)}`);if(b.ok){let a=await b.json();r(a.content),t(Number(b.headers.get("X-Wiki-Revision")??0))}}catch{}v(!1)}}},[]),Z=(0,p.useCallback)(()=>{o(a=>a+1),Y()},[Y]),$=(0,p.useCallback)(a=>{let b=G.current;b&&b.path===a&&!H.current&&Y()},[Y]),_=(0,p.useCallback)(async()=>{let a=G.current;if(!a)return;D(!0),F(null);let b=await (0,bB.wsFetch)("/api/wiki/content",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a.path,content:y,baseRevision:s})});if(b.ok){let a=await b.json();"number"==typeof a.revision&&t(a.revision),r(y),x(!1)}else F((await b.json()).error??"Save failed");D(!1)},[y,s]);async function aa(a){let b=G.current;if(b?.path===a&&null!==q)return q;if(b_.getState().currentPath===a)return b_.getState().content;let c=await (0,bB.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(a)}`);if(!c.ok)throw Error("Cannot copy content");return(await c.json()).content}return{openFile:f,openFileViewerKind:I,fileContent:q,fileRevision:s,fileLoading:u,editing:w,setEditing:x,editContent:y,setEditContent:z,htmlSourceMode:A,setHtmlSourceMode:B,saving:C,saveError:E,appFullscreen:j,setAppFullscreen:k,appKey:l,setAppKey:m,viewerKey:n,setViewerKey:o,gateBypassPath:h,bypassGate:()=>i(G.current?.path??null),openViewer:L,openFromSearch:O,openFavoriteEntry:P,navigateToPath:Q,handleSave:_,refreshViewer:Y,handleRefresh:Z,closeFile:M,clearFile:N,onExternalChange:$,markRootLoaded:X,copyPath:a=>{navigator.clipboard.writeText(a),at("Path copied")},copyWikiLink:a=>{let b=a.replace(/\.(md|markdown)$/i,"");navigator.clipboard.writeText(`[[${b}]]`),at("Wiki link copied")},copyUrl:b=>{let c=new URL(location.href);c.searchParams.set("path",b),a&&c.searchParams.set("ws",a),navigator.clipboard.writeText(c.toString()),at("URL copied")},copyRawContent:async function(a){try{let b=await aa(a);await navigator.clipboard.writeText(b),at("Raw content copied")}catch{au("Could not copy file content")}},copyFormattedContent:async function(a,b){try{let c=await aa(a);if(!cO(b)){await navigator.clipboard.writeText(c),at("Content copied");return}let d=await (0,np.markdownToHtml)(c,{pagePath:a,sanitize:!0});"ClipboardItem"in window&&navigator.clipboard.write?await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([d],{type:"text/html"}),"text/plain":new Blob([c],{type:"text/plain"})})]):await navigator.clipboard.writeText(c),at("Formatted content copied")}catch{au("Could not copy formatted content")}}}}({activeWorkspaceId:a.activeWorkspaceId,rootPath:a.rootPath,isMobile:v4(),setSidebarCollapsed:a=>q.current(a),treeApi:{revealPath:c.revealPath,toggleFolder:c.toggleFolder}});(0,p.useEffect)(()=>{b.current=d.onExternalChange},[d.onExternalChange]);let e=v4(),[f,h]=(0,p.useState)(!1),q=(0,p.useRef)(()=>{});q.current=h;let[r,s]=(0,p.useState)({settingsOpen:!1,shareDialogOpen:!1}),[t,u]=(0,p.useState)(!1),[w,x]=(0,p.useState)({path:null,isDir:!1}),y=function({reloadDir:a}){let[b,c]=(0,p.useState)(!1),[d,e]=(0,p.useState)(null),f=(0,p.useRef)(null),g=(0,p.useRef)(""),h=(0,p.useCallback)(async(b,d)=>{void 0!==d&&(g.current=d);let h=Array.from(b);if(h.length){c(!0),e(null);try{for(let a of h){let b=new FormData;b.append("file",a),b.append("dir",g.current);let c=await (0,bB.wsFetch)("/api/wiki/upload",{method:"POST",body:b});if(!c.ok){let a=await c.json();e(a.error??"Upload failed"),au(a.error??"Upload failed");break}}await a(g.current)}catch{e("Upload failed.")}finally{c(!1),f.current&&(f.current.value="")}}},[a]);return{uploading:b,uploadError:d,fileInputRef:f,triggerUpload:function(a){g.current=a,f.current?.click()},doUpload:h}}({reloadDir:c.reloadDir}),z=function(a){let[b,c]=(0,p.useState)(null),[d,e]=(0,p.useState)(!1),[f,g]=(0,p.useState)([]),[h,i]=(0,p.useState)(!1),[j,k]=(0,p.useState)(null),[l,m]=(0,p.useState)(null),[n,o]=(0,p.useState)(!1),q=a?.path;(0,p.useEffect)(()=>{e(!1),g([]),k(null),m(null)},[q]),(0,p.useEffect)(()=>{if(!q)return void c(null);let a=!1,b=setTimeout(()=>{(async()=>{try{let b=await (0,bB.wsFetch)(`/api/wiki/git-file-info?path=${encodeURIComponent(q)}`);if(a)return;if(!b.ok)return void c(null);let d=await b.json();a||c(d.info)}catch{a||c(null)}})()},200);return()=>{a=!0,clearTimeout(b)}},[q]);let r=(0,p.useCallback)(async()=>{if(!a)return;let b=a.path;e(!0),i(!0),g([]),k(null),m(null);try{let c=await (0,bB.wsFetch)(`/api/wiki/git-history?path=${encodeURIComponent(b)}`);if(!c.ok)return void au("Could not load history");let d=await c.json();a.path===b&&g(d.commits)}catch{au("Could not load history")}finally{i(!1)}},[a]),s=(0,p.useCallback)(async b=>{if(!a)return;if(j===b){k(null),m(null);return}let c=a.path;k(b),o(!0),m(null);try{let d=await (0,bB.wsFetch)(`/api/wiki/git-diff?path=${encodeURIComponent(c)}&sha=${encodeURIComponent(b)}`);if(!d.ok)return void au("Could not load diff");let e=await d.json();a.path===c&&j===b&&m(e.diff)}catch{au("Could not load diff")}finally{o(!1)}},[a,j]);return{gitFileInfo:b,showHistory:d,setShowHistory:e,historyLoading:h,historyCommits:f,selectedDiffSha:j,setSelectedDiffSha:k,loadHistory:r,diffContent:l,diffLoading:n,selectDiff:s}}(d.openFile),A=cW(a=>a.favorites),B=v5(a=>a.recents),C=bF(a=>a.activity),D=(0,p.useMemo)(()=>{let a=new Date(Date.now()-6e4).toISOString(),b=new Set;for(let c of C)c.at>=a&&c.path&&c.by?.startsWith("ai:")&&b.add(c.path);return b},[C]);async function E(){if(!w.path)return;await fetch((0,bB.withWs)("/api/wiki"),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:w.path})}),(d.openFile?.path===w.path||d.openFile?.path.startsWith(`${w.path}/`))&&d.closeFile();let a=wc(w.path).includes("/")?w.path.split("/").slice(0,-1).join("/"):"";await c.reloadDir(a),x({path:null,isDir:!1})}(0,p.useEffect)(()=>{let a=new URLSearchParams(window.location.search);u("1"===a.get("embed")&&"1"!==a.get("chrome"))},[]),(0,p.useEffect)(()=>{e&&h(!0)},[e]),(0,p.useEffect)(()=>{oa.getState().load()},[]),(0,p.useEffect)(()=>{let a=()=>{bF.getState().loadActivity()};a();let b=setInterval(a,1e4);return()=>clearInterval(b)},[]),(0,p.useEffect)(()=>{v5.getState().loadForWorkspace(a.activeWorkspaceId),cW.getState().loadForWorkspace(a.activeWorkspaceId)},[a.activeWorkspaceId]),(0,p.useEffect)(()=>{let a,b=[...A.map(a=>a.path),...B.slice(0,8).map(a=>a.path)].filter((a,b,c)=>cO(a)&&c.indexOf(a)===b).slice(0,12);if(0===b.length)return;let c=(a=()=>{for(let a of b)bW(a)},window.setTimeout(a,400));return()=>{clearTimeout(c)}},[A,B]),(0,p.useEffect)(()=>{d.clearFile()},[a.activeWorkspaceId,d.clearFile]),(0,p.useEffect)(()=>{c.rootLoaded&&d.markRootLoaded()},[c.rootLoaded,d.markRootLoaded]);let F=(0,dK.useViewWidthStore)(a=>a.width),G=(0,dK.useViewWidthStore)(a=>a.align),H=(0,dK.useViewWidthStore)(a=>a.setWidth),I=(0,dK.useViewWidthStore)(a=>a.setAlign),J=null===d.openFileViewerKind||"editor"===d.openFileViewerKind||"text"===d.openFileViewerKind||"source"===d.openFileViewerKind||"notebook"===d.openFileViewerKind||"fallback"===d.openFileViewerKind,K=J?dK.VIEW_WIDTH_CLASS[F]:"",L=J?dK.VIEW_ALIGN_CLASS[G]:"",M=(0,p.useCallback)((b,c)=>(0,g.jsx)(cX,{doc:d,node:b,extraItems:c,activeWorkspaceId:a.activeWorkspaceId}),[d,a.activeWorkspaceId]);return(0,g.jsxs)("div",{className:"flex h-screen gap-0 overflow-hidden bg-background",children:[null===a.rootConfigured&&(0,g.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,g.jsx)(m.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),!1===a.rootConfigured&&(0,g.jsx)(bc,{onSelect:b=>{let c=new URL(location.href);c.searchParams.set("ws",b),c.searchParams.delete("path"),history.replaceState(null,"",c.toString()),a.setRootConfigured(!0),a.setActiveWorkspaceId(b),a.loadWorkspaces()}}),!0===a.rootConfigured&&a.addingWorkspace&&(0,g.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,g.jsx)("div",{className:"flex items-center justify-end border-b px-3 py-2 bg-muted shrink-0",children:(0,g.jsxs)(v.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1.5 text-xs",onClick:()=>a.setAddingWorkspace(!1),children:[(0,g.jsx)(o,{className:"h-3.5 w-3.5"})," Cancel"]})}),(0,g.jsx)(bc,{onSelect:b=>{a.setAddingWorkspace(!1),a.loadWorkspaces(),a.switchWorkspace(b)}})]}),!0===a.rootConfigured&&!a.addingWorkspace&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d0,{workspace:a,doc:d,fileTree:c,upload:y,isMobile:e,hideChrome:t,sidebarCollapsed:f,setSidebarCollapsed:h,favorites:A,recents:B,activePaths:D,setDeleting:x,setDialogs:s}),(0,g.jsxs)("div",{className:"flex-1 flex flex-col min-w-0 relative",children:[!t&&f&&(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"hidden md:flex absolute left-2 top-2 z-10 h-7 w-7 p-0",title:"Show sidebar",onClick:()=>h(!1),children:(0,g.jsx)(n,{className:"h-3.5 w-3.5"})}),!t&&(0,g.jsxs)("div",{className:"md:hidden flex h-11 shrink-0 items-center justify-between gap-2 border-b bg-muted px-1",children:[(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"Show sidebar",onClick:()=>{h(!1),bF.getState().close()},children:(0,g.jsx)(n,{className:"h-4 w-4"})}),(0,g.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5 text-xs font-semibold tracking-tight text-muted-foreground",title:d.openFile?.path,children:[d.openFile&&(0,g.jsx)("span",{className:"shrink-0",children:"app"===d.openFileViewerKind||"html"===d.openFileViewerKind?(0,g.jsx)(k,{className:"h-4 w-4 text-foreground/70"}):cP(d.openFile.name)?(0,g.jsx)(l,{className:"h-4 w-4 text-sunshine-700"}):cN(d.openFile.name)?(0,g.jsx)(j.FileText,{className:"h-4 w-4 text-foreground/70"}):(0,g.jsx)(j.FileText,{className:"h-4 w-4 text-foreground/60"})}),(0,g.jsx)("span",{className:"truncate",children:d.openFile?d.openFile.name:"Wiki Viewer"})]}),(0,g.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"AI Agent panel",onClick:()=>{bF.getState().open(),h(!0)},children:(0,g.jsx)(i,{className:"h-4 w-4"})})]}),d.openFile?(0,g.jsx)(v3,{openFile:d.openFile,fileContent:d.fileContent,fileRevision:d.fileRevision,fileLoading:d.fileLoading,editing:d.editing,setEditing:d.setEditing,editContent:d.editContent,setEditContent:d.setEditContent,saving:d.saving,saveError:d.saveError,onSave:d.handleSave,gitFileInfo:z.gitFileInfo,showHistory:z.showHistory,historyLoading:z.historyLoading,historyCommits:z.historyCommits,selectedDiffSha:z.selectedDiffSha,diffContent:z.diffContent,diffLoading:z.diffLoading,onToggleHistory:()=>z.setShowHistory(a=>!a),onSelectDiff:z.selectDiff,gateBypassPath:d.gateBypassPath,onBypassGate:d.bypassGate,onRefresh:d.handleRefresh,onShare:()=>s(a=>({...a,shareDialogOpen:!0})),onClose:()=>{d.closeFile()},renderCopyMenu:M,appKey:d.appKey,setAppKey:d.setAppKey,appFullscreen:d.appFullscreen,setAppFullscreen:d.setAppFullscreen,viewerKey:d.viewerKey,setViewerKey:d.setViewerKey,htmlSourceMode:d.htmlSourceMode,setHtmlSourceMode:d.setHtmlSourceMode,widthAwareViewer:J,viewWidth:F,viewAlign:G,setViewWidth:H,setViewAlign:I,contentWidthClass:K,contentAlignClass:L,isMobile:e,sidebarCollapsed:f}):(0,g.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center",children:(0,g.jsxs)("div",{className:"flex flex-col items-center gap-2 text-center px-4",children:[(0,g.jsx)(j.FileText,{className:"h-8 w-8 text-muted-foreground"}),(0,g.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a file to view or edit"})]})})]}),(0,g.jsx)(bC,{open:r.shareDialogOpen,onOpenChange:a=>s(b=>({...b,shareDialogOpen:a})),filePath:d.openFile?.path??""}),!(0,av.isLite)()&&(0,g.jsx)(aX,{open:r.settingsOpen,onOpenChange:a=>s(b=>({...b,settingsOpen:a}))}),(0,g.jsx)(b7,{currentPath:d.openFile?.path}),(0,g.jsx)("input",{ref:y.fileInputRef,type:"file",multiple:!0,className:"hidden",onChange:a=>{a.target.files&&y.doUpload(a.target.files)}}),(0,g.jsx)(a2,{open:!!w.path,onOpenChange:a=>{a||x({path:null,isDir:!1})},title:w.isDir?"Delete folder?":"Delete file?",description:w.isDir?`"${wc(w.path??"")}" and all its contents will be permanently deleted.`:`"${wc(w.path??"")}" will be permanently removed.`,onConfirm:E}),(0,g.jsx)(a2,{open:!!a.deletingWorkspaceId,onOpenChange:b=>{b||a.setDeletingWorkspaceId(null)},title:"Delete workspace?",description:`"${a.workspaces.find(b=>b.id===a.deletingWorkspaceId)?.name??""}" will be removed from the workspace list. Files on disk are NOT deleted.`,onConfirm:()=>void a.handleDeleteWorkspace(async b=>{await a.switchWorkspace(b),d.clearFile()})})]})]},a.activeWorkspaceId??"none")}],240777)}];
171
171
 
172
172
  //# sourceMappingURL=_0oq8kwv._.js.map