wiki-viewer 2.0.1 → 2.1.1

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 (94) 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/server/app/_global-error.html +1 -1
  4. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  5. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  6. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  7. package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  11. package/.next/standalone/.next/server/app/_not-found.rsc +1 -1
  12. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  13. package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  14. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  15. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  16. package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  17. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  18. package/.next/standalone/.next/server/app/api/agent/activity/route.js.nft.json +1 -1
  19. package/.next/standalone/.next/server/app/api/agent/events/[...path]/route.js.nft.json +1 -1
  20. package/.next/standalone/.next/server/app/api/agent/files/[...path]/route.js.nft.json +1 -1
  21. package/.next/standalone/.next/server/app/api/agent/fs/file/[...path]/route.js.nft.json +1 -1
  22. package/.next/standalone/.next/server/app/api/agent/fs/ls/[[...path]]/route.js.nft.json +1 -1
  23. package/.next/standalone/.next/server/app/api/agent/fs/move/route.js.nft.json +1 -1
  24. package/.next/standalone/.next/server/app/api/agent/fs/search/route.js.nft.json +1 -1
  25. package/.next/standalone/.next/server/app/api/agent/internal/span/route.js.nft.json +1 -1
  26. package/.next/standalone/.next/server/app/api/agent/settings/route.js.nft.json +1 -1
  27. package/.next/standalone/.next/server/app/api/agent/sidecar/[...path]/route.js.nft.json +1 -1
  28. package/.next/standalone/.next/server/app/api/assets/[...path]/route.js.nft.json +1 -1
  29. package/.next/standalone/.next/server/app/api/share/[token]/route.js.nft.json +1 -1
  30. package/.next/standalone/.next/server/app/api/share/route.js.nft.json +1 -1
  31. package/.next/standalone/.next/server/app/api/system/reveal/route.js.nft.json +1 -1
  32. package/.next/standalone/.next/server/app/api/system/set-root/route.js.nft.json +1 -1
  33. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/open/route.js.nft.json +1 -1
  34. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/refresh/route.js.nft.json +1 -1
  35. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/route.js.nft.json +1 -1
  36. package/.next/standalone/.next/server/app/api/system/workspaces/route.js.nft.json +1 -1
  37. package/.next/standalone/.next/server/app/api/upload/[...path]/route.js.nft.json +1 -1
  38. package/.next/standalone/.next/server/app/api/wiki/app/route.js.nft.json +1 -1
  39. package/.next/standalone/.next/server/app/api/wiki/backlinks/route.js.nft.json +1 -1
  40. package/.next/standalone/.next/server/app/api/wiki/content/route.js.nft.json +1 -1
  41. package/.next/standalone/.next/server/app/api/wiki/download/route.js.nft.json +1 -1
  42. package/.next/standalone/.next/server/app/api/wiki/file/route.js.nft.json +1 -1
  43. package/.next/standalone/.next/server/app/api/wiki/folder/route.js.nft.json +1 -1
  44. package/.next/standalone/.next/server/app/api/wiki/git-branches/route.js.nft.json +1 -1
  45. package/.next/standalone/.next/server/app/api/wiki/git-checkout/route.js.nft.json +1 -1
  46. package/.next/standalone/.next/server/app/api/wiki/git-diff/route.js.nft.json +1 -1
  47. package/.next/standalone/.next/server/app/api/wiki/git-file-info/route.js.nft.json +1 -1
  48. package/.next/standalone/.next/server/app/api/wiki/git-history/route.js.nft.json +1 -1
  49. package/.next/standalone/.next/server/app/api/wiki/git-pull/route.js.nft.json +1 -1
  50. package/.next/standalone/.next/server/app/api/wiki/move/route.js.nft.json +1 -1
  51. package/.next/standalone/.next/server/app/api/wiki/new-file/route.js.nft.json +1 -1
  52. package/.next/standalone/.next/server/app/api/wiki/outlinks/route.js.nft.json +1 -1
  53. package/.next/standalone/.next/server/app/api/wiki/page/route.js.nft.json +1 -1
  54. package/.next/standalone/.next/server/app/api/wiki/presence/route.js.nft.json +1 -1
  55. package/.next/standalone/.next/server/app/api/wiki/route.js.nft.json +1 -1
  56. package/.next/standalone/.next/server/app/api/wiki/search/route.js.nft.json +1 -1
  57. package/.next/standalone/.next/server/app/api/wiki/slugs/route.js.nft.json +1 -1
  58. package/.next/standalone/.next/server/app/api/wiki/upload/route.js.nft.json +1 -1
  59. package/.next/standalone/.next/server/app/api/wiki/watch/route.js.nft.json +1 -1
  60. package/.next/standalone/.next/server/app/index.html +1 -1
  61. package/.next/standalone/.next/server/app/index.rsc +2 -2
  62. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  63. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +2 -2
  64. package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  65. package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  66. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  67. package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  68. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  69. package/.next/standalone/.next/server/app/s/[token]/page.js.nft.json +1 -1
  70. package/.next/standalone/.next/server/app/s/[token]/page_client-reference-manifest.js +1 -1
  71. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0w~__xz._.js +1 -1
  72. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__10m6c40._.js → [root-of-the-server]__0g2q.m9._.js} +1 -1
  73. package/.next/standalone/.next/server/chunks/ssr/{_0yevh-d._.js → _026lnd.._.js} +7 -7
  74. package/.next/standalone/.next/server/chunks/ssr/_06rf50_._.js +3 -0
  75. package/.next/standalone/.next/server/chunks/ssr/{_0~a9dyk._.js → _0hpi._s._.js} +6 -6
  76. package/.next/standalone/.next/server/chunks/ssr/_0jdop6l._.js +3 -0
  77. package/.next/standalone/.next/server/chunks/ssr/src_app_page_tsx_0ss2.w7._.js +1 -1
  78. package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
  79. package/.next/standalone/.next/server/middleware-manifest.json +1 -1
  80. package/.next/standalone/.next/server/pages/404.html +1 -1
  81. package/.next/standalone/.next/server/pages/500.html +1 -1
  82. package/.next/standalone/.next/static/chunks/0_p-~rp2hak3c.js +113 -0
  83. package/.next/standalone/.next/static/chunks/0lrkdb9w.6kl1.js +1 -0
  84. package/.next/standalone/.next/static/chunks/{0ey6h_rkpuzxs.js → 0oy4xayqkedl5.js} +5 -5
  85. package/.next/standalone/.next/static/chunks/{0.69aou29w6ma.js → 0r0fa52s8puxv.js} +1 -1
  86. package/.next/standalone/.next/static/chunks/14_efa7172tp-.js +1 -0
  87. package/.next/standalone/package.json +1 -1
  88. package/package.json +1 -1
  89. package/.next/standalone/.next/server/chunks/ssr/_0wmhtx3._.js +0 -3
  90. package/.next/standalone/.next/static/chunks/0jt1z17mjmjde.js +0 -113
  91. package/.next/standalone/.next/static/chunks/0wxju9pxda4c2.js +0 -1
  92. /package/.next/standalone/.next/static/{nbWvTsOgKt53BB3Gl0swc → XIglKqX0BlS2ovM_Stm9Z}/_buildManifest.js +0 -0
  93. /package/.next/standalone/.next/static/{nbWvTsOgKt53BB3Gl0swc → XIglKqX0BlS2ovM_Stm9Z}/_clientMiddlewareManifest.js +0 -0
  94. /package/.next/standalone/.next/static/{nbWvTsOgKt53BB3Gl0swc → XIglKqX0BlS2ovM_Stm9Z}/_ssgManifest.js +0 -0
@@ -79,11 +79,11 @@ ${i}
79
79
  `,d+=1;else break}let b=y.slice(1);if(b.length>0){let r=b.map(e=>e.slice(m+u)).join("\n");r.trim()&&(e=t.customNestedParser?t.customNestedParser(r):n.blockTokens(r))}let v=t.createToken(f,e);l.push(v)}if(0!==l.length)return{items:l,raw:c}}function aA(e,t,n,r){if(!e||!Array.isArray(e.content))return"";let i="function"==typeof n?n(r):n,[o,...s]=e.content,a=t.renderChildren([o]),l=`${i}${a}`;return s&&s.length>0&&s.forEach((e,n)=>{var r,i;let o=null!=(i=null==(r=t.renderChild)?void 0:r.call(t,e,n+1))?i:t.renderChildren([e]);if(null!=o){let n=o.split("\n").map(e=>e?t.indent(e):t.indent("")).join("\n");l+="paragraph"===e.type?`
80
80
 
81
81
  ${n}`:`
82
- ${n}`}}),l}function aT(e,t,n={}){let{state:r}=t,{doc:i,tr:o}=r;i.descendants((t,r)=>{let i=o.mapping.map(r),s=o.mapping.map(r)+t.nodeSize,a=null;if(t.marks.forEach(t=>{if(t!==e)return!1;a=t}),!a)return;let l=!1;if(Object.keys(n).forEach(e=>{n[e]!==a.attrs[e]&&(l=!0)}),l){let t=e.type.create({...e.attrs,...n});o.removeMark(i,s,e.type),o.addMark(i,s,t)}}),o.docChanged&&t.view.dispatch(o)}i8({},{createAtomBlockMarkdownSpec:()=>ak,createBlockMarkdownSpec:()=>aS,createInlineMarkdownSpec:()=>aM,parseAttributes:()=>aw,parseIndentedBlocks:()=>aN,renderNestedMarkdownContent:()=>aA,serializeAttributes:()=>ax});var aR=class{constructor(e,t,n){this.component=e,this.editor=t.editor,this.options={...n},this.mark=t.mark,this.HTMLAttributes=t.HTMLAttributes}get dom(){return this.editor.view.dom}get contentDOM(){return null}updateAttributes(e,t){aT(t||this.mark,this.editor,e)}ignoreMutation(e){return!this.dom||!this.contentDOM||("function"==typeof this.options.ignoreMutation?this.options.ignoreMutation({mutation:e}):!("selection"===e.type||this.dom.contains(e.target)&&"childList"===e.type&&(oR()||oT())&&this.editor.isFocused&&[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(e=>e.isContentEditable))&&(this.contentDOM===e.target&&"attributes"===e.type||!this.contentDOM.contains(e.target)))}},aO=class e extends s8{constructor(){super(...arguments),this.type="node"}static create(t={}){return new e("function"==typeof t?t():t)}configure(e){return super.configure(e)}extend(e){let t="function"==typeof e?e():e;return super.extend(t)}},aD=class{constructor(e,t,n){this.isDragging=!1,this.component=e,this.editor=t.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=t.extension,this.node=t.node,this.decorations=t.decorations,this.innerDecorations=t.innerDecorations,this.view=t.view,this.HTMLAttributes=t.HTMLAttributes,this.getPos=t.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var t,n,r,i,o,s,a;let{view:l}=this.editor,c=e.target,d=3===c.nodeType?null==(t=c.parentElement)?void 0:t.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(null==(n=this.contentDOM)?void 0:n.contains(c))||!d)return;let u=0,h=0;if(this.dom!==d){let t=this.dom.getBoundingClientRect(),n=d.getBoundingClientRect(),a=null!=(i=e.offsetX)?i:null==(r=e.nativeEvent)?void 0:r.offsetX,l=null!=(s=e.offsetY)?s:null==(o=e.nativeEvent)?void 0:o.offsetY;u=n.x-t.x+a,h=n.y-t.y+l}let p=this.dom.cloneNode(!0);try{let e=this.dom.getBoundingClientRect();p.style.width=`${Math.round(e.width)}px`,p.style.height=`${Math.round(e.height)}px`,p.style.boxSizing="border-box",p.style.pointerEvents="none"}catch{}let f=null;try{(f=document.createElement("div")).style.position="absolute",f.style.top="-9999px",f.style.left="-9999px",f.style.pointerEvents="none",f.appendChild(p),document.body.appendChild(f),null==(a=e.dataTransfer)||a.setDragImage(p,u,h)}finally{f&&setTimeout(()=>{try{null==f||f.remove()}catch{}},0)}let m=this.getPos();if("number"!=typeof m)return;let g=eU.create(l.state.doc,m),y=l.state.tr.setSelection(g);l.dispatch(y)}stopEvent(e){var t;if(!this.dom)return!1;if("function"==typeof this.options.stopEvent)return this.options.stopEvent({event:e});let n=e.target;if(!(this.dom.contains(n)&&!(null==(t=this.contentDOM)?void 0:t.contains(n))))return!1;let r=e.type.startsWith("drag"),i="dragover"===e.type||"dragenter"===e.type,o="drop"===e.type;if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!o&&!r)return!0;let{isEditable:s}=this.editor,{isDragging:a}=this,l=!!this.node.type.spec.draggable,c=eU.isSelectable(this.node),d="copy"===e.type,u="paste"===e.type,h="cut"===e.type,p="mousedown"===e.type;if(!l&&c&&r&&e.target===this.dom&&e.preventDefault(),l&&r&&!a&&e.target===this.dom)return e.preventDefault(),!1;if(l&&s&&!a&&p){let e=n.closest("[data-drag-handle]");e&&(this.dom===e||this.dom.contains(e))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!a&&!i&&!o&&!d&&!u&&!h&&(!p||!c)&&!0}ignoreMutation(e){return!this.dom||!this.contentDOM||("function"==typeof this.options.ignoreMutation?this.options.ignoreMutation({mutation:e}):!!this.node.isLeaf||!!this.node.isAtom||!("selection"===e.type||this.dom.contains(e.target)&&"childList"===e.type&&(oR()||oT())&&this.editor.isFocused&&[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(e=>e.isContentEditable))&&(this.contentDOM===e.target&&"attributes"===e.type||!this.contentDOM.contains(e.target)))}updateAttributes(e){this.editor.commands.command(({tr:t})=>{let n=this.getPos();return"number"==typeof n&&(t.setNodeMarkup(n,void 0,{...this.node.attrs,...e}),!0)})}deleteNode(){let e=this.getPos();if("number"!=typeof e)return;let t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}};e.s(["Editor",0,ab,"Extension",0,ai,"InputRule",0,s6,"Mark",0,ae,"MarkView",0,aR,"Node",0,aO,"NodeView",0,aD,"ResizableNodeView",0,av,"callOrReturn",0,sc,"canInsertNode",0,function(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof eU){let e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let i=r.depth;for(;i>=0;){let e=r.index(i);if(r.node(i).contentMatchAt(e).matchType(t))return!0;i-=1}return!1},"combineTransactionSteps",0,sn,"findChildren",0,function(e,t){let n=[];return e.descendants((e,r)=>{t(e)&&n.push({node:e,pos:r})}),n},"findChildrenInRange",0,function(e,t,n){let r=[];return e.nodesBetween(t.from,t.to,(e,t)=>{n(e)&&r.push({node:e,pos:t})}),r},"findParentNodeClosestToPos",0,sr,"getAttributes",0,sS,"getChangedRanges",0,sC,"getExtensionField",0,so,"getMarksBetween",0,sE,"getNodeAtPosition",0,(e,t,n,r=20)=>{let i=e.doc.resolve(n),o=r,s=null;for(;o>0&&null===s;){let e=i.node(o);(null==e?void 0:e.type.name)===t?s=e:o-=1}return[s,o]},"getNodeType",0,ou,"getRenderedAttributes",0,sf,"getText",0,sx,"getTextSerializersFromSchema",0,sk,"isAtEndOfNode",0,(e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=si(e=>e.type.name===t)(e.selection);if(!n)return!1;let r=e.doc.resolve(n.pos+1);return i.pos+1===r.end()}return!(r.parentOffset<r.parent.nodeSize-2)&&n.pos===r.pos},"isAtStartOfNode",0,e=>{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0)&&t.pos===n.pos},"isNodeActive",0,oJ,"isNodeEmpty",0,sO,"isNodeSelection",0,function(e){return e instanceof eU},"isNodeViewSelected",0,sD,"isTextSelection",0,oM,"markInputRule",0,function(e){return new s6({find:e.find,handler:({state:t,range:n,match:r})=>{let i=sc(e.getAttributes,void 0,r);if(!1===i||null===i)return null;let{tr:o}=t,s=r[r.length-1],a=r[0];if(s){let r=a.search(/\S/),l=n.from+a.indexOf(s),c=l+s.length;if(sE(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>l).length)return null;c<n.to&&o.delete(c,n.to),l>n.from&&o.delete(n.from+r,l);let d=n.from+r+s.length;o.addMark(n.from+r,d,e.type.create(i||{})),o.removeStoredMark(e.type)}},undoable:e.undoable})},"markPasteRule",0,function(e){return new at({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let o=sc(e.getAttributes,void 0,r,i);if(!1===o||null===o)return null;let{tr:s}=t,a=r[r.length-1],l=r[0],c=n.to;if(a){let i=l.search(/\S/),d=n.from+l.indexOf(a),u=d+a.length;if(sE(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>d).length)return null;u<n.to&&s.delete(u,n.to),d>n.from&&s.delete(n.from+i,d),c=n.from+i+a.length,s.addMark(n.from+i,c,e.type.create(o||{})),void 0!==r.index&&void 0!==r.input&&r.index+r[0].length>=r.input.length||s.removeStoredMark(e.type)}}})},"mergeAttributes",0,sp,"nodeInputRule",0,function(e){return new s6({find:e.find,handler:({state:t,range:n,match:r})=>{let i=sc(e.getAttributes,void 0,r)||{},{tr:o}=t,s=n.from,a=n.to,l=e.type.create(i);if(r[1]){let e=s+r[0].lastIndexOf(r[1]);e>a?e=a:a=e+r[1].length;let t=r[0][r[0].length-1];o.insertText(t,s+r[0].length-1),o.replaceWith(e,a,l)}else if(r[0]){let t=e.type.isInline?s:s-1;o.insert(t,e.type.create(i)).delete(o.mapping.map(s),o.mapping.map(a))}o.scrollIntoView()},undoable:e.undoable})},"parseIndentedBlocks",0,aN,"posToDOMRect",0,function(e,t,n){let r=e.state.doc.content.size,i=oN(t,0,r),o=oN(n,0,r),s=e.coordsAtPos(i),a=e.coordsAtPos(o,-1),l=Math.min(s.top,a.top),c=Math.max(s.bottom,a.bottom),d=Math.min(s.left,a.left),u=Math.max(s.right,a.right),h={top:l,bottom:c,left:d,right:u,width:u-d,height:c-l,x:d,y:l};return{...h,toJSON:()=>h}},"renderNestedMarkdownContent",0,aA,"textblockTypeInputRule",0,function(e){return new s6({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),o=sc(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,o)},undoable:e.undoable})},"wrappingInputRule",0,function(e){return new s6({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let o=sc(e.getAttributes,void 0,r)||{},s=t.tr.delete(n.from,n.to),a=s.doc.resolve(n.from).blockRange(),l=a&&eg(a,e.type,o);if(!l)return null;if(s.wrap(a,l),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,o=r||n.$to.parentOffset&&n.$from.marks();if(o){let e=o.filter(e=>i.includes(e.type.name));s.ensureMarks(e)}}if(e.keepAttributes){let t="bulletList"===e.type.name||"orderedList"===e.type.name?"listItem":"taskList";i().updateAttributes(t,o).run()}let c=s.doc.resolve(n.from-1).nodeBefore;c&&c.type===e.type&&ex(s.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,c))&&s.join(n.from-1)},undoable:e.undoable})}],343603);let{getOwnPropertyNames:aj,getOwnPropertySymbols:aI}=Object,{hasOwnProperty:aP}=Object.prototype;function aL(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function az(e){return function(t,n,r){if(!t||!n||"object"!=typeof t||"object"!=typeof n)return e(t,n,r);let{cache:i}=r,o=i.get(t),s=i.get(n);if(o&&s)return o===n&&s===t;i.set(t,n),i.set(n,t);let a=e(t,n,r);return i.delete(t),i.delete(n),a}}function a_(e){return aj(e).concat(aI(e))}let a$=Object.hasOwn||((e,t)=>aP.call(e,t));function aH(e,t){return e===t||!e&&!t&&e!=e&&t!=t}let{getOwnPropertyDescriptor:aB,keys:aF}=Object;function aV(e,t){return e.byteLength===t.byteLength&&a1(new Uint8Array(e),new Uint8Array(t))}function aU(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function aW(e,t){return e.byteLength===t.byteLength&&a1(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function aK(e,t){return aH(e.getTime(),t.getTime())}function aq(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function aJ(e,t){return e===t}function aG(e,t,n){let r,i,o=e.size;if(o!==t.size)return!1;if(!o)return!0;let s=Array(o),a=e.entries(),l=0;for(;(r=a.next())&&!r.done;){let o=t.entries(),a=!1,c=0;for(;(i=o.next())&&!i.done;){if(s[c]){c++;continue}let o=r.value,d=i.value;if(n.equals(o[0],d[0],l,c,e,t,n)&&n.equals(o[1],d[1],o[0],d[0],e,t,n)){a=s[c]=!0;break}c++}if(!a)return!1;l++}return!0}function aX(e,t,n){let r=aF(e),i=r.length;if(aF(t).length!==i)return!1;for(;i-- >0;)if(!a5(e,t,n,r[i]))return!1;return!0}function aZ(e,t,n){let r,i,o,s=a_(e),a=s.length;if(a_(t).length!==a)return!1;for(;a-- >0;)if(!a5(e,t,n,r=s[a])||(i=aB(e,r),o=aB(t,r),(i||o)&&(!i||!o||i.configurable!==o.configurable||i.enumerable!==o.enumerable||i.writable!==o.writable)))return!1;return!0}function aY(e,t){return aH(e.valueOf(),t.valueOf())}function aQ(e,t){return e.source===t.source&&e.flags===t.flags}function a0(e,t,n){let r,i,o=e.size;if(o!==t.size)return!1;if(!o)return!0;let s=Array(o),a=e.values();for(;(r=a.next())&&!r.done;){let o=t.values(),a=!1,l=0;for(;(i=o.next())&&!i.done;){if(!s[l]&&n.equals(r.value,i.value,r.value,i.value,e,t,n)){a=s[l]=!0;break}l++}if(!a)return!1}return!0}function a1(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function a2(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function a5(e,t,n,r){return("_owner"===r||"__o"===r||"__v"===r)&&(!!e.$$typeof||!!t.$$typeof)||a$(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}let a3={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},a4=Object.prototype.toString,a6=a9();function a9(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,o=function({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:o,areMapsEqual:s,areNumbersEqual:a,areObjectsEqual:l,arePrimitiveWrappersEqual:c,areRegExpsEqual:d,areSetsEqual:u,areTypedArraysEqual:h,areUrlsEqual:p,unknownTagComparators:f}){return function(m,g,y){if(m===g)return!0;if(null==m||null==g)return!1;let b=typeof m;if(b!==typeof g)return!1;if("object"!==b)return"number"===b?a(m,g,y):"function"===b&&o(m,g,y);let v=m.constructor;if(v!==g.constructor)return!1;if(v===Object)return l(m,g,y);if(Array.isArray(m))return t(m,g,y);if(v===Date)return r(m,g,y);if(v===RegExp)return d(m,g,y);if(v===Map)return s(m,g,y);if(v===Set)return u(m,g,y);let w=a4.call(m);if("[object Date]"===w)return r(m,g,y);if("[object RegExp]"===w)return d(m,g,y);if("[object Map]"===w)return s(m,g,y);if("[object Set]"===w)return u(m,g,y);if("[object Object]"===w)return"function"!=typeof m.then&&"function"!=typeof g.then&&l(m,g,y);if("[object URL]"===w)return p(m,g,y);if("[object Error]"===w)return i(m,g,y);if("[object Arguments]"===w)return l(m,g,y);if(a3[w])return h(m,g,y);if("[object ArrayBuffer]"===w)return e(m,g,y);if("[object DataView]"===w)return n(m,g,y);if("[object Boolean]"===w||"[object Number]"===w||"[object String]"===w)return c(m,g,y);if(f){let e=f[w];if(!e){let t=null!=m?m[Symbol.toStringTag]:void 0;t&&(e=f[t])}if(e)return e(m,g,y)}return!1}}(function({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:aV,areArraysEqual:n?aZ:aU,areDataViewsEqual:aW,areDatesEqual:aK,areErrorsEqual:aq,areFunctionsEqual:aJ,areMapsEqual:n?aL(aG,aZ):aG,areNumbersEqual:aH,areObjectsEqual:n?aZ:aX,arePrimitiveWrappersEqual:aY,areRegExpsEqual:aQ,areSetsEqual:n?aL(a0,aZ):a0,areTypedArraysEqual:n?aL(a1,aZ):a1,areUrlsEqual:a2,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=az(r.areArraysEqual),t=az(r.areMapsEqual),n=az(r.areObjectsEqual),i=az(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}(e)),s=n?n(o):function(e,t,n,r,i,s,a){return o(e,t,a)};return function({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(o,s){let{cache:a=e?new WeakMap:void 0,meta:l}=n();return t(o,s,{cache:a,equals:r,meta:l,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let o={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,o)}}({circular:t,comparator:o,createState:r,equals:s,strict:i})}a9({strict:!0}),a9({circular:!0}),a9({circular:!0,strict:!0}),a9({createInternalComparator:()=>aH}),a9({strict:!0,createInternalComparator:()=>aH}),a9({circular:!0,createInternalComparator:()=>aH}),a9({circular:!0,createInternalComparator:()=>aH,strict:!0});var a7=e.i(383835),a8=({contentComponent:e})=>{let t=(0,iI.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,iP.jsx)(iP.Fragment,{children:Object.values(t)})},le=class extends iD.default.Component{constructor(e){super(e),this.editorContentRef=iD.default.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var e;let t=this.props.editor;if(t&&!t.isDestroyed&&(null==(e=t.view.dom)?void 0:e.parentNode)){let e,n;if(t.contentComponent)return;let r=this.editorContentRef.current;r.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:r}),e=new Set,n={},t.contentComponent={subscribe:t=>(e.add(t),()=>{e.delete(t)}),getSnapshot:()=>n,getServerSnapshot:()=>n,setRenderer(t,r){n={...n,[t]:ij.default.createPortal(r.reactElement,r.element,t)},e.forEach(e=>e())},removeRenderer(t){let r={...n};delete r[t],n=r,e.forEach(e=>e())}},t.createNodeViews(),t.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){var e;let t=this.props.editor;if(t){t.isEditorContentInitialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),t.contentComponent=null;try{if(!(null==(e=t.view.dom)?void 0:e.parentNode))return;let n=document.createElement("div");n.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:n})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,iP.jsxs)(iP.Fragment,{children:[(0,iP.jsx)("div",{ref:((...e)=>t=>{e.forEach(e=>{"function"==typeof e?e(t):e&&(e.current=t)})})(t,this.editorContentRef),...n}),(null==e?void 0:e.contentComponent)&&(0,iP.jsx)(a8,{contentComponent:e.contentComponent})]})}},lt=(0,iD.forwardRef)((e,t)=>{let n=iD.default.useMemo(()=>Math.floor(0xffffffff*Math.random()).toString(),[e.editor]);return iD.default.createElement(le,{key:n,innerRef:t,...e})}),ln=iD.default.memo(lt),lr="u">typeof window?iD.useLayoutEffect:iD.useEffect,li=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}},lo="u"<typeof window,ls=lo||!!("u">typeof window&&window.next),la=class e{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(e=>e())}getInitialEditor(){let e=this.options.current.immediatelyRender,t=null==e||e;return lo?t=!1:ls&&void 0===e&&(t=!1),t?this.createEditor():null}createEditor(){return new ab({...this.options.current,onBeforeCreate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onBeforeCreate)?void 0:n.call(t,...e)},onBlur:(...e)=>{var t,n;return null==(n=(t=this.options.current).onBlur)?void 0:n.call(t,...e)},onCreate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onCreate)?void 0:n.call(t,...e)},onDestroy:(...e)=>{var t,n;return null==(n=(t=this.options.current).onDestroy)?void 0:n.call(t,...e)},onFocus:(...e)=>{var t,n;return null==(n=(t=this.options.current).onFocus)?void 0:n.call(t,...e)},onSelectionUpdate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onSelectionUpdate)?void 0:n.call(t,...e)},onTransaction:(...e)=>{var t,n;return null==(n=(t=this.options.current).onTransaction)?void 0:n.call(t,...e)},onUpdate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onUpdate)?void 0:n.call(t,...e)},onContentError:(...e)=>{var t,n;return null==(n=(t=this.options.current).onContentError)?void 0:n.call(t,...e)},onDrop:(...e)=>{var t,n;return null==(n=(t=this.options.current).onDrop)?void 0:n.call(t,...e)},onPaste:(...e)=>{var t,n;return null==(n=(t=this.options.current).onPaste)?void 0:n.call(t,...e)},onDelete:(...e)=>{var t,n;return null==(n=(t=this.options.current).onDelete)?void 0:n.call(t,...e)}})}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(n=>!!["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(n)||("extensions"===n&&e.extensions&&t.extensions?e.extensions.length===t.extensions.length&&e.extensions.every((e,n)=>{var r;return e===(null==(r=t.extensions)?void 0:r[n])}):e[n]===t[n]))}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===t.length?e.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(null===this.previousDeps){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((t,n)=>t===e[n]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){let e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}},ll=(0,iD.createContext)({editor:null});ll.Consumer;var lc=(0,iD.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),ld=iD.default.forwardRef((e,t)=>{let{onDragStart:n}=(0,iD.useContext)(lc),r=e.as||"div";return(0,iP.jsx)(r,{...e,ref:t,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...e.style}})});function lu(e){return!!("function"==typeof e&&e.prototype&&e.prototype.isReactComponent)}function lh(e){return!!("object"==typeof e&&e.$$typeof&&("Symbol(react.forward_ref)"===e.$$typeof.toString()||"react.forward_ref"===e.$$typeof.description))}var lp=class{constructor(e,{editor:t,props:n={},as:r="div",className:i=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(0xffffffff*Math.random()).toString(),this.component=e,this.editor=t,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),i&&this.element.classList.add(...i.split(" ")),this.editor.isEditorContentInitialized?(0,ij.flushSync)(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var e;if(this.destroyed)return;let t=this.component,n=this.props,r=this.editor,i=function(){try{if(iD.version)return parseInt(iD.version.split(".")[0],10)>=19}catch{}return!1}(),o=function(e){if(lu(e)||lh(e))return!0;if("object"==typeof e&&e.$$typeof&&("Symbol(react.memo)"===e.$$typeof.toString()||"react.memo"===e.$$typeof.description)){let t=e.type;if(t)return lu(t)||lh(t)}return!1}(t),s={...n};s.ref&&!(i||o)&&delete s.ref,!s.ref&&(i||o)&&(s.ref=e=>{this.ref=e}),this.reactElement=(0,iP.jsx)(t,{...s}),null==(e=null==r?void 0:r.contentComponent)||e.setRenderer(this.id,this)}updateProps(e={}){if(this.destroyed)return;let t=!1,n=Object.keys(e);for(let r=0;r<n.length;r+=1){let i=n[r];if(e[i]!==this.props[i]){t=!0;break}}t&&(this.props={...this.props,...e},this.render())}destroy(){var e;this.destroyed=!0;let t=this.editor;null==(e=null==t?void 0:t.contentComponent)||e.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(e){Object.keys(e).forEach(t=>{this.element.setAttribute(t,e[t])})}};iD.default.createContext({markViewContentRef:()=>{}});var lf=class extends aD{constructor(e,t,n){if(super(e,t,n),this.selectionRafId=null,this.handlePositionUpdate=()=>{let e=this.getPos();"number"==typeof e&&e!==this.currentPos&&(this.currentPos=e,this.renderer.updateProps({getPos:()=>this.getPos()}),"function"==typeof this.options.attrs&&this.updateElementAttributes())},this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const e=this.dom.querySelector("[data-node-view-content]");if(!e)return;e.appendChild(this.contentDOMElement)}this.options.trackNodeViewPosition&&this.editor.on("update",this.handlePositionUpdate)}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){let e=this.editor,t=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(t,{get(n,r,i){var o;return"storage"===r?null!=(o=e.storage[t.name])?o:{}:Reflect.get(n,r,i)}})}return this.cachedExtensionWithSyncedStorage}mount(){let e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode(),ref:(0,iD.createRef)()};if(!this.component.displayName){let e;this.component.displayName=(e=this.extension.name).charAt(0).toUpperCase()+e.substring(1)}let t={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:e=>{e&&this.contentDOMElement&&e.firstChild!==this.contentDOMElement&&(e.hasAttribute("data-node-view-wrapper")&&e.removeAttribute("data-node-view-wrapper"),e.appendChild(this.contentDOMElement))}},n=this.component,r=(0,iD.memo)(e=>(0,iP.jsx)(lc.Provider,{value:t,children:(0,iD.createElement)(n,e)}));r.displayName="ReactNodeView";let i=this.node.isInline?"span":"div";this.options.as&&(i=this.options.as);let{className:o=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new lp(r,{editor:this.editor,props:e,as:i,className:`node-${this.node.type.name} ${o}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes(),this.currentPos=this.getPos()}get dom(){var e;if(this.renderer.element.firstElementChild&&!(null==(e=this.renderer.element.firstElementChild)?void 0:e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;let e=this.currentPos;if("number"==typeof e)if(sD({selection:this.editor.state.selection,pos:e,nodeSize:this.node.nodeSize,selectedOnTextSelection:this.options.selectedOnTextSelection})){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(e,t,n){let r=e=>{this.renderer.updateProps(e),"function"==typeof this.options.attrs&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if("function"==typeof this.options.update){let i=this.node,o=this.decorations,s=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=this.getPos(),this.options.update({oldNode:i,oldDecorations:o,newNode:e,newDecorations:t,oldInnerDecorations:s,innerDecorations:n,updateProps:()=>r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}if(e===this.node)return this.node=e,this.decorations=t,this.innerDecorations=n,!0;let i=this.getPos();this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=i;let o={node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage};return this.options.trackNodeViewPosition&&(o.getPos=()=>this.getPos()),r(o),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.options.trackNodeViewPosition&&this.editor.off("update",this.handlePositionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let e={};if("function"==typeof this.options.attrs){let t=this.editor.extensionManager.attributes,n=sf(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}},lm=(0,iD.createContext)({get editor(){throw Error("useTiptap must be used within a <Tiptap> provider")}});function lg({editor:e,instance:t,children:n}){let r=null!=e?e:t;if(!r)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let i=(0,iD.useMemo)(()=>({editor:r}),[r]),o=(0,iD.useMemo)(()=>({editor:r}),[r]);return(0,iP.jsx)(ll.Provider,{value:o,children:(0,iP.jsx)(lm.Provider,{value:i,children:n})})}function ly({...e}){let{editor:t}=(0,iD.useContext)(lm);return(0,iP.jsx)(ln,{editor:t,...e})}lm.displayName="TiptapContext",lg.displayName="Tiptap",ly.displayName="Tiptap.Content",Object.assign(lg,{Content:ly}),e.s(["EditorContent",0,ln,"NodeViewWrapper",0,ld,"ReactNodeViewRenderer",0,function(e,t){return n=>n.editor.contentComponent?new lf(e,n,t):{}},"useCurrentEditor",0,()=>(0,iD.useContext)(ll),"useEditor",0,function(e={},t=[]){let n=(0,iD.useRef)(e);n.current=e;let[r]=(0,iD.useState)(()=>new la(n)),i=(0,iI.useSyncExternalStore)(r.subscribe,r.getEditor,r.getServerSnapshot);return(0,iD.useDebugValue)(i),(0,iD.useEffect)(r.onRender(t)),!function(e){var t;let[n]=(0,iD.useState)(()=>new li(e.editor)),r=(0,a7.useSyncExternalStoreWithSelector)(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,null!=(t=e.equalityFn)?t:a6);lr(()=>n.watch(e.editor),[e.editor,n]),(0,iD.useDebugValue)(r)}({editor:i,selector:({transactionNumber:t})=>!1===e.shouldRerenderOnTransaction||void 0===e.shouldRerenderOnTransaction?null:e.immediatelyRender&&0===t?0:t+1}),i}],885047)},313393,e=>{"use strict";let t=(0,e.i(605993).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"}]]);e.s(["Code2",0,t],313393)},530229,e=>{"use strict";let t=(0,e.i(605993).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"}]]);e.s(["FilePlus",0,t],530229)},231597,417068,660885,490275,534537,e=>{"use strict";let t=(0,e.i(605993).default)("sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);function n(e,t){return Array(t+1).join(e)}function r(e){return e.replace(/^\n*/,"")}function i(e){for(var t=e.length;t>0&&"\n"===e[t-1];)t--;return e.substring(0,t)}e.s(["Sparkles",0,t],231597),e.s(["findNodeByPath",0,function e(t,n){for(let r of t){if(r.path===n)return r;if(r.children){let t=e(r.children,n);if(t)return t}}return null}],417068);var o,s,a=["ADDRESS","ARTICLE","ASIDE","AUDIO","BLOCKQUOTE","BODY","CANVAS","CENTER","DD","DIR","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","FRAMESET","H1","H2","H3","H4","H5","H6","HEADER","HGROUP","HR","HTML","ISINDEX","LI","MAIN","MENU","NAV","NOFRAMES","NOSCRIPT","OL","OUTPUT","P","PRE","SECTION","TABLE","TBODY","TD","TFOOT","TH","THEAD","TR","UL"];function l(e){return h(e,a)}var c=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"];function d(e){return h(e,c)}var u=["A","TABLE","THEAD","TBODY","TFOOT","TH","TD","IFRAME","SCRIPT","AUDIO","VIDEO"];function h(e,t){return t.indexOf(e.nodeName)>=0}function p(e,t){return e.getElementsByTagName&&t.some(function(t){return e.getElementsByTagName(t).length})}var f=[[/\\/g,"\\\\"],[/\*/g,"\\*"],[/^-/g,"\\-"],[/^\+ /g,"\\+ "],[/^(=+)/g,"\\$1"],[/^(#{1,6}) /g,"\\$1 "],[/`/g,"\\`"],[/^~~~/g,"\\~~~"],[/\[/g,"\\["],[/\]/g,"\\]"],[/^>/g,"\\>"],[/_/g,"\\_"],[/^(\d+)\. /g,"$1\\. "]];function m(e){return f.reduce(function(e,t){return e.replace(t[0],t[1])},e)}var g={};function y(e){return e?e.replace(/(\n+\s*)+/g,"\n"):""}function b(e){var t=e.replace(/([<>()])/g,"\\$1");return t.indexOf(" ")>=0?"<"+t+">":t}function v(e){return e.replace(/"/g,'\\"')}function w(e){for(var t in this.options=e,this._keep=[],this._remove=[],this.blankRule={replacement:e.blankReplacement},this.keepReplacement=e.keepReplacement,this.defaultRule={replacement:e.defaultReplacement},this.array=[],e.rules)this.array.push(e.rules[t])}function x(e,t,n){for(var r=0;r<e.length;r++){var i=e[r];if(function(e,t,n){var r=e.filter;if("string"==typeof r){if(r===t.nodeName.toLowerCase())return!0}else if(Array.isArray(r)){if(r.indexOf(t.nodeName.toLowerCase())>-1)return!0}else if("function"==typeof r){if(r.call(e,t,n))return!0}else throw TypeError("`filter` needs to be a string, array, or function")}(i,t,n))return i}}function k(e){var t=e.nextSibling||e.parentNode;return e.parentNode.removeChild(e),t}function S(e,t,n){return e&&e.parentNode===t||n(t)?t.nextSibling||t.parentNode:t.firstChild||t.nextSibling||t.parentNode}g.paragraph={filter:"p",replacement:function(e){return"\n\n"+e+"\n\n"}},g.lineBreak={filter:"br",replacement:function(e,t,n){return n.br+"\n"}},g.heading={filter:["h1","h2","h3","h4","h5","h6"],replacement:function(e,t,r){var i=Number(t.nodeName.charAt(1));if("setext"!==r.headingStyle||!(i<3))return"\n\n"+n("#",i)+" "+e+"\n\n";var o=n(1===i?"=":"-",e.length);return"\n\n"+e+"\n"+o+"\n\n"}},g.blockquote={filter:"blockquote",replacement:function(e){return"\n\n"+(e=i(r(e)).replace(/^/gm,"> "))+"\n\n"}},g.list={filter:["ul","ol"],replacement:function(e,t){var n=t.parentNode;return"LI"===n.nodeName&&n.lastElementChild===t?"\n"+e:"\n\n"+e+"\n\n"}},g.listItem={filter:"li",replacement:function(e,t,n){var o=n.bulletListMarker+" ",s=t.parentNode;if("OL"===s.nodeName){var a=s.getAttribute("start"),l=Array.prototype.indexOf.call(s.children,t);o=(a?Number(a)+l:l+1)+". "}var c=/\n$/.test(e);return e=(e=i(r(e))+(c?"\n":"")).replace(/\n/gm,"\n"+" ".repeat(o.length)),o+e+(t.nextSibling?"\n":"")}},g.indentedCodeBlock={filter:function(e,t){return"indented"===t.codeBlockStyle&&"PRE"===e.nodeName&&e.firstChild&&"CODE"===e.firstChild.nodeName},replacement:function(e,t,n){return"\n\n "+t.firstChild.textContent.replace(/\n/g,"\n ")+"\n\n"}},g.fencedCodeBlock={filter:function(e,t){return"fenced"===t.codeBlockStyle&&"PRE"===e.nodeName&&e.firstChild&&"CODE"===e.firstChild.nodeName},replacement:function(e,t,r){for(var i,o=((t.firstChild.getAttribute("class")||"").match(/language-(\S+)/)||[null,""])[1],s=t.firstChild.textContent,a=r.fence.charAt(0),l=3,c=RegExp("^"+a+"{3,}","gm");i=c.exec(s);)i[0].length>=l&&(l=i[0].length+1);var d=n(a,l);return"\n\n"+d+o+"\n"+s.replace(/\n$/,"")+"\n"+d+"\n\n"}},g.horizontalRule={filter:"hr",replacement:function(e,t,n){return"\n\n"+n.hr+"\n\n"}},g.inlineLink={filter:function(e,t){return"inlined"===t.linkStyle&&"A"===e.nodeName&&e.getAttribute("href")},replacement:function(e,t){var n=b(t.getAttribute("href")),r=v(y(t.getAttribute("title")));return"["+e+"]("+n+(r?' "'+r+'"':"")+")"}},g.referenceLink={filter:function(e,t){return"referenced"===t.linkStyle&&"A"===e.nodeName&&e.getAttribute("href")},replacement:function(e,t,n){var r,i,o=b(t.getAttribute("href")),s=y(t.getAttribute("title"));switch(s&&(s=' "'+v(s)+'"'),n.linkReferenceStyle){case"collapsed":r="["+e+"][]",i="["+e+"]: "+o+s;break;case"shortcut":r="["+e+"]",i="["+e+"]: "+o+s;break;default:var a=this.references.length+1;r="["+e+"]["+a+"]",i="["+a+"]: "+o+s}return this.references.push(i),r},references:[],append:function(e){var t="";return this.references.length&&(t="\n\n"+this.references.join("\n")+"\n\n",this.references=[]),t}},g.emphasis={filter:["em","i"],replacement:function(e,t,n){return e.trim()?n.emDelimiter+e+n.emDelimiter:""}},g.strong={filter:["strong","b"],replacement:function(e,t,n){return e.trim()?n.strongDelimiter+e+n.strongDelimiter:""}},g.code={filter:function(e){var t=e.previousSibling||e.nextSibling,n="PRE"===e.parentNode.nodeName&&!t;return"CODE"===e.nodeName&&!n},replacement:function(e){if(!e)return"";e=e.replace(/\r?\n|\r/g," ");for(var t=/^`|^ .*?[^ ].* $|`$/.test(e)?" ":"",n="`",r=e.match(/`+/gm)||[];-1!==r.indexOf(n);)n+="`";return n+t+e+t+n}},g.image={filter:"img",replacement:function(e,t){var n=m(y(t.getAttribute("alt"))),r=b(t.getAttribute("src")||""),i=y(t.getAttribute("title")),o=i?' "'+v(i)+'"':"";return r?"!["+n+"]("+r+o+")":""}},w.prototype={add:function(e,t){this.array.unshift(t)},keep:function(e){this._keep.unshift({filter:e,replacement:this.keepReplacement})},remove:function(e){this._remove.unshift({filter:e,replacement:function(){return""}})},forNode:function(e){var t;return e.isBlank?this.blankRule:(t=x(this.array,e,this.options))||(t=x(this._keep,e,this.options))||(t=x(this._remove,e,this.options))?t:this.defaultRule},forEach:function(e){for(var t=0;t<this.array.length;t++)e(this.array[t],t)}};var C="u">typeof window?window:{},E=!function(){var e=C.DOMParser,t=!1;try{new e().parseFromString("","text/html")&&(t=!0)}catch(e){}return t}()?(o=function(){},!function(){var e=!1;try{document.implementation.createHTMLDocument("").open()}catch(t){C.ActiveXObject&&(e=!0)}return e}()?o.prototype.parseFromString=function(e){var t=document.implementation.createHTMLDocument("");return t.open(),t.write(e),t.close(),t}:o.prototype.parseFromString=function(e){var t=new window.ActiveXObject("htmlfile");return t.designMode="on",t.open(),t.write(e),t.close(),t},o):C.DOMParser;function M(e,t){var n;return!function(e){var t=e.element,n=e.isBlock,r=e.isVoid,i=e.isPre||function(e){return"PRE"===e.nodeName};if(!(!t.firstChild||i(t))){for(var o=null,s=!1,a=null,l=S(null,t,i);l!==t;){if(3===l.nodeType||4===l.nodeType){var c=l.data.replace(/[ \r\n\t]+/g," ");if((!o||/ $/.test(o.data))&&!s&&" "===c[0]&&(c=c.substr(1)),!c){l=k(l);continue}l.data=c,o=l}else if(1===l.nodeType)n(l)||"BR"===l.nodeName?(o&&(o.data=o.data.replace(/ $/,"")),o=null,s=!1):r(l)||i(l)?(o=null,s=!0):o&&(s=!1);else{l=k(l);continue}var d=S(a,l,i);a=l,l=d}o&&(o.data=o.data.replace(/ $/,""),o.data||k(o))}}({element:n="string"==typeof e?(s=s||new E).parseFromString('<x-turndown id="turndown-root">'+e+"</x-turndown>","text/html").getElementById("turndown-root"):e.cloneNode(!0),isBlock:l,isVoid:d,isPre:t.preformattedCode?N:null}),n}function N(e){return"PRE"===e.nodeName||"CODE"===e.nodeName}function A(e,t){var n;return e.isBlock=l(e),e.isCode="CODE"===e.nodeName||e.parentNode.isCode,e.isBlank=!d(n=e)&&!h(n,u)&&/^\s*$/i.test(n.textContent)&&!p(n,c)&&!p(n,u),e.flankingWhitespace=function(e,t){if(e.isBlock||t.preformattedCode&&e.isCode)return{leading:"",trailing:""};var n,r={leading:(n=e.textContent.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/))[1],leadingAscii:n[2],leadingNonAscii:n[3],trailing:n[4],trailingNonAscii:n[5],trailingAscii:n[6]};return r.leadingAscii&&T("left",e,t)&&(r.leading=r.leadingNonAscii),r.trailingAscii&&T("right",e,t)&&(r.trailing=r.trailingNonAscii),{leading:r.leading,trailing:r.trailing}}(e,t),e}function T(e,t,n){var r,i,o;return"left"===e?(r=t.previousSibling,i=/ $/):(r=t.nextSibling,i=/^ /),r&&(3===r.nodeType?o=i.test(r.nodeValue):n.preformattedCode&&"CODE"===r.nodeName?o=!1:1!==r.nodeType||l(r)||(o=i.test(r.textContent))),o}var R=Array.prototype.reduce;function O(e){if(!(this instanceof O))return new O(e);this.options=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}({},{rules:g,headingStyle:"setext",hr:"* * *",bulletListMarker:"*",codeBlockStyle:"indented",fence:"```",emDelimiter:"_",strongDelimiter:"**",linkStyle:"inlined",linkReferenceStyle:"full",br:" ",preformattedCode:!1,blankReplacement:function(e,t){return t.isBlock?"\n\n":""},keepReplacement:function(e,t){return t.isBlock?"\n\n"+t.outerHTML+"\n\n":t.outerHTML},defaultReplacement:function(e,t){return t.isBlock?"\n\n"+e+"\n\n":e}},e),this.rules=new w(this.options)}function D(e){var t=this;return R.call(e.childNodes,function(e,n){n=new A(n,t.options);var r="";return 3===n.nodeType?r=n.isCode?n.nodeValue:t.escape(n.nodeValue):1===n.nodeType&&(r=I.call(t,n)),P(e,r)},"")}function j(e){var t=this;return this.rules.forEach(function(n){"function"==typeof n.append&&(e=P(e,n.append(t.options)))}),e.replace(/^[\t\r\n]+/,"").replace(/[\t\r\n\s]+$/,"")}function I(e){var t=this.rules.forNode(e),n=D.call(this,e),r=e.flankingWhitespace;return(r.leading||r.trailing)&&(n=n.trim()),r.leading+t.replacement(n,e,this.options)+r.trailing}function P(e,t){var n=i(e),o=r(t),s=Math.max(e.length-n.length,t.length-o.length);return n+"\n\n".substring(0,s)+o}O.prototype={turndown:function(e){var t;if(!(null!=(t=e)&&("string"==typeof t||t.nodeType&&(1===t.nodeType||9===t.nodeType||11===t.nodeType))))throw TypeError(e+" is not a string, or an element/document/fragment node.");return""===e?"":j.call(this,D.call(this,new M(e,this.options)))},use:function(e){if(Array.isArray(e))for(var t=0;t<e.length;t++)this.use(e[t]);else if("function"==typeof e)e(this);else throw TypeError("plugin must be a Function or an Array of Functions");return this},addRule:function(e,t){return this.rules.add(e,t),this},keep:function(e){return this.rules.keep(e),this},remove:function(e){return this.rules.remove(e),this},escape:function(e){return m(e)}};var L=/highlight-(?:text|source)-([a-z0-9]+)/;function z(e){e.addRule("highlightedCodeBlock",{filter:function(e){var t=e.firstChild;return"DIV"===e.nodeName&&L.test(e.className)&&t&&"PRE"===t.nodeName},replacement:function(e,t,n){var r=((t.className||"").match(L)||[null,""])[1];return"\n\n"+n.fence+r+"\n"+t.firstChild.textContent+"\n"+n.fence+"\n\n"}})}function _(e){e.addRule("strikethrough",{filter:["del","s","strike"],replacement:function(e){return"~"+e+"~"}})}var $=Array.prototype.indexOf,H=Array.prototype.every,B={};function F(e){var t,n,r=e.parentNode;return"THEAD"===r.nodeName||r.firstChild===e&&("TABLE"===r.nodeName||(n=(t=r).previousSibling,"TBODY"===t.nodeName&&(!n||"THEAD"===n.nodeName&&/^\s*$/i.test(n.textContent))))&&H.call(e.childNodes,function(e){return"TH"===e.nodeName})}function V(e,t){var n=$.call(t.parentNode.childNodes,t),r=" ";return 0===n&&(r="| "),r+e+" |"}function U(e){for(var t in e.keep(function(e){return"TABLE"===e.nodeName&&!F(e.rows[0])}),B)e.addRule(t,B[t])}function W(e){e.addRule("taskListItems",{filter:function(e){return"checkbox"===e.type&&"LI"===e.parentNode.nodeName},replacement:function(e,t){return(t.checked?"[x]":"[ ]")+" "}})}B.tableCell={filter:["th","td"],replacement:function(e,t){return V(e,t)}},B.tableRow={filter:"tr",replacement:function(e,t){var n="",r={left:":--",right:"--:",center:":-:"};if(F(t))for(var i=0;i<t.childNodes.length;i++){var o="---",s=(t.childNodes[i].getAttribute("align")||"").toLowerCase();s&&(o=r[s]||o),n+=V(o,t.childNodes[i])}return"\n"+e+(n?"\n"+n:"")}},B.table={filter:function(e){return"TABLE"===e.nodeName&&F(e.rows[0])},replacement:function(e){return"\n\n"+(e=e.replace("\n\n","\n"))+"\n\n"}},B.tableSection={filter:["thead","tbody","tfoot"],replacement:function(e){return e}};var K=e.i(319814);let q=new O({headingStyle:"atx",hr:"---",bulletListMarker:"-",codeBlockStyle:"fenced",fence:"```",emDelimiter:"*",strongDelimiter:"**"});for(let e of(q.use(function(e){e.use([z,_,U,W])}),q.addRule("codeBlock",{filter:e=>"PRE"===e.nodeName&&null!==e.firstChild&&"CODE"===e.firstChild.nodeName,replacement:(e,t)=>{let n=t.firstChild,r=n.getAttribute("class")?.replace("language-","")||"",i=n.textContent||"";return`
82
+ ${n}`}}),l}function aT(e,t,n={}){let{state:r}=t,{doc:i,tr:o}=r;i.descendants((t,r)=>{let i=o.mapping.map(r),s=o.mapping.map(r)+t.nodeSize,a=null;if(t.marks.forEach(t=>{if(t!==e)return!1;a=t}),!a)return;let l=!1;if(Object.keys(n).forEach(e=>{n[e]!==a.attrs[e]&&(l=!0)}),l){let t=e.type.create({...e.attrs,...n});o.removeMark(i,s,e.type),o.addMark(i,s,t)}}),o.docChanged&&t.view.dispatch(o)}i8({},{createAtomBlockMarkdownSpec:()=>ak,createBlockMarkdownSpec:()=>aS,createInlineMarkdownSpec:()=>aM,parseAttributes:()=>aw,parseIndentedBlocks:()=>aN,renderNestedMarkdownContent:()=>aA,serializeAttributes:()=>ax});var aR=class{constructor(e,t,n){this.component=e,this.editor=t.editor,this.options={...n},this.mark=t.mark,this.HTMLAttributes=t.HTMLAttributes}get dom(){return this.editor.view.dom}get contentDOM(){return null}updateAttributes(e,t){aT(t||this.mark,this.editor,e)}ignoreMutation(e){return!this.dom||!this.contentDOM||("function"==typeof this.options.ignoreMutation?this.options.ignoreMutation({mutation:e}):!("selection"===e.type||this.dom.contains(e.target)&&"childList"===e.type&&(oR()||oT())&&this.editor.isFocused&&[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(e=>e.isContentEditable))&&(this.contentDOM===e.target&&"attributes"===e.type||!this.contentDOM.contains(e.target)))}},aO=class e extends s8{constructor(){super(...arguments),this.type="node"}static create(t={}){return new e("function"==typeof t?t():t)}configure(e){return super.configure(e)}extend(e){let t="function"==typeof e?e():e;return super.extend(t)}},aD=class{constructor(e,t,n){this.isDragging=!1,this.component=e,this.editor=t.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=t.extension,this.node=t.node,this.decorations=t.decorations,this.innerDecorations=t.innerDecorations,this.view=t.view,this.HTMLAttributes=t.HTMLAttributes,this.getPos=t.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var t,n,r,i,o,s,a;let{view:l}=this.editor,c=e.target,d=3===c.nodeType?null==(t=c.parentElement)?void 0:t.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(null==(n=this.contentDOM)?void 0:n.contains(c))||!d)return;let u=0,h=0;if(this.dom!==d){let t=this.dom.getBoundingClientRect(),n=d.getBoundingClientRect(),a=null!=(i=e.offsetX)?i:null==(r=e.nativeEvent)?void 0:r.offsetX,l=null!=(s=e.offsetY)?s:null==(o=e.nativeEvent)?void 0:o.offsetY;u=n.x-t.x+a,h=n.y-t.y+l}let p=this.dom.cloneNode(!0);try{let e=this.dom.getBoundingClientRect();p.style.width=`${Math.round(e.width)}px`,p.style.height=`${Math.round(e.height)}px`,p.style.boxSizing="border-box",p.style.pointerEvents="none"}catch{}let f=null;try{(f=document.createElement("div")).style.position="absolute",f.style.top="-9999px",f.style.left="-9999px",f.style.pointerEvents="none",f.appendChild(p),document.body.appendChild(f),null==(a=e.dataTransfer)||a.setDragImage(p,u,h)}finally{f&&setTimeout(()=>{try{null==f||f.remove()}catch{}},0)}let m=this.getPos();if("number"!=typeof m)return;let g=eU.create(l.state.doc,m),y=l.state.tr.setSelection(g);l.dispatch(y)}stopEvent(e){var t;if(!this.dom)return!1;if("function"==typeof this.options.stopEvent)return this.options.stopEvent({event:e});let n=e.target;if(!(this.dom.contains(n)&&!(null==(t=this.contentDOM)?void 0:t.contains(n))))return!1;let r=e.type.startsWith("drag"),i="dragover"===e.type||"dragenter"===e.type,o="drop"===e.type;if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!o&&!r)return!0;let{isEditable:s}=this.editor,{isDragging:a}=this,l=!!this.node.type.spec.draggable,c=eU.isSelectable(this.node),d="copy"===e.type,u="paste"===e.type,h="cut"===e.type,p="mousedown"===e.type;if(!l&&c&&r&&e.target===this.dom&&e.preventDefault(),l&&r&&!a&&e.target===this.dom)return e.preventDefault(),!1;if(l&&s&&!a&&p){let e=n.closest("[data-drag-handle]");e&&(this.dom===e||this.dom.contains(e))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!a&&!i&&!o&&!d&&!u&&!h&&(!p||!c)&&!0}ignoreMutation(e){return!this.dom||!this.contentDOM||("function"==typeof this.options.ignoreMutation?this.options.ignoreMutation({mutation:e}):!!this.node.isLeaf||!!this.node.isAtom||!("selection"===e.type||this.dom.contains(e.target)&&"childList"===e.type&&(oR()||oT())&&this.editor.isFocused&&[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(e=>e.isContentEditable))&&(this.contentDOM===e.target&&"attributes"===e.type||!this.contentDOM.contains(e.target)))}updateAttributes(e){this.editor.commands.command(({tr:t})=>{let n=this.getPos();return"number"==typeof n&&(t.setNodeMarkup(n,void 0,{...this.node.attrs,...e}),!0)})}deleteNode(){let e=this.getPos();if("number"!=typeof e)return;let t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}};e.s(["Editor",0,ab,"Extension",0,ai,"InputRule",0,s6,"Mark",0,ae,"MarkView",0,aR,"Node",0,aO,"NodeView",0,aD,"ResizableNodeView",0,av,"callOrReturn",0,sc,"canInsertNode",0,function(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof eU){let e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let i=r.depth;for(;i>=0;){let e=r.index(i);if(r.node(i).contentMatchAt(e).matchType(t))return!0;i-=1}return!1},"combineTransactionSteps",0,sn,"findChildren",0,function(e,t){let n=[];return e.descendants((e,r)=>{t(e)&&n.push({node:e,pos:r})}),n},"findChildrenInRange",0,function(e,t,n){let r=[];return e.nodesBetween(t.from,t.to,(e,t)=>{n(e)&&r.push({node:e,pos:t})}),r},"findParentNodeClosestToPos",0,sr,"getAttributes",0,sS,"getChangedRanges",0,sC,"getExtensionField",0,so,"getMarksBetween",0,sE,"getNodeAtPosition",0,(e,t,n,r=20)=>{let i=e.doc.resolve(n),o=r,s=null;for(;o>0&&null===s;){let e=i.node(o);(null==e?void 0:e.type.name)===t?s=e:o-=1}return[s,o]},"getNodeType",0,ou,"getRenderedAttributes",0,sf,"getText",0,sx,"getTextSerializersFromSchema",0,sk,"isAtEndOfNode",0,(e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=si(e=>e.type.name===t)(e.selection);if(!n)return!1;let r=e.doc.resolve(n.pos+1);return i.pos+1===r.end()}return!(r.parentOffset<r.parent.nodeSize-2)&&n.pos===r.pos},"isAtStartOfNode",0,e=>{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0)&&t.pos===n.pos},"isNodeActive",0,oJ,"isNodeEmpty",0,sO,"isNodeSelection",0,function(e){return e instanceof eU},"isNodeViewSelected",0,sD,"isTextSelection",0,oM,"markInputRule",0,function(e){return new s6({find:e.find,handler:({state:t,range:n,match:r})=>{let i=sc(e.getAttributes,void 0,r);if(!1===i||null===i)return null;let{tr:o}=t,s=r[r.length-1],a=r[0];if(s){let r=a.search(/\S/),l=n.from+a.indexOf(s),c=l+s.length;if(sE(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>l).length)return null;c<n.to&&o.delete(c,n.to),l>n.from&&o.delete(n.from+r,l);let d=n.from+r+s.length;o.addMark(n.from+r,d,e.type.create(i||{})),o.removeStoredMark(e.type)}},undoable:e.undoable})},"markPasteRule",0,function(e){return new at({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let o=sc(e.getAttributes,void 0,r,i);if(!1===o||null===o)return null;let{tr:s}=t,a=r[r.length-1],l=r[0],c=n.to;if(a){let i=l.search(/\S/),d=n.from+l.indexOf(a),u=d+a.length;if(sE(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>d).length)return null;u<n.to&&s.delete(u,n.to),d>n.from&&s.delete(n.from+i,d),c=n.from+i+a.length,s.addMark(n.from+i,c,e.type.create(o||{})),void 0!==r.index&&void 0!==r.input&&r.index+r[0].length>=r.input.length||s.removeStoredMark(e.type)}}})},"mergeAttributes",0,sp,"nodeInputRule",0,function(e){return new s6({find:e.find,handler:({state:t,range:n,match:r})=>{let i=sc(e.getAttributes,void 0,r)||{},{tr:o}=t,s=n.from,a=n.to,l=e.type.create(i);if(r[1]){let e=s+r[0].lastIndexOf(r[1]);e>a?e=a:a=e+r[1].length;let t=r[0][r[0].length-1];o.insertText(t,s+r[0].length-1),o.replaceWith(e,a,l)}else if(r[0]){let t=e.type.isInline?s:s-1;o.insert(t,e.type.create(i)).delete(o.mapping.map(s),o.mapping.map(a))}o.scrollIntoView()},undoable:e.undoable})},"parseIndentedBlocks",0,aN,"posToDOMRect",0,function(e,t,n){let r=e.state.doc.content.size,i=oN(t,0,r),o=oN(n,0,r),s=e.coordsAtPos(i),a=e.coordsAtPos(o,-1),l=Math.min(s.top,a.top),c=Math.max(s.bottom,a.bottom),d=Math.min(s.left,a.left),u=Math.max(s.right,a.right),h={top:l,bottom:c,left:d,right:u,width:u-d,height:c-l,x:d,y:l};return{...h,toJSON:()=>h}},"renderNestedMarkdownContent",0,aA,"textblockTypeInputRule",0,function(e){return new s6({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),o=sc(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,o)},undoable:e.undoable})},"wrappingInputRule",0,function(e){return new s6({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let o=sc(e.getAttributes,void 0,r)||{},s=t.tr.delete(n.from,n.to),a=s.doc.resolve(n.from).blockRange(),l=a&&eg(a,e.type,o);if(!l)return null;if(s.wrap(a,l),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,o=r||n.$to.parentOffset&&n.$from.marks();if(o){let e=o.filter(e=>i.includes(e.type.name));s.ensureMarks(e)}}if(e.keepAttributes){let t="bulletList"===e.type.name||"orderedList"===e.type.name?"listItem":"taskList";i().updateAttributes(t,o).run()}let c=s.doc.resolve(n.from-1).nodeBefore;c&&c.type===e.type&&ex(s.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,c))&&s.join(n.from-1)},undoable:e.undoable})}],343603);let{getOwnPropertyNames:aj,getOwnPropertySymbols:aI}=Object,{hasOwnProperty:aP}=Object.prototype;function aL(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function az(e){return function(t,n,r){if(!t||!n||"object"!=typeof t||"object"!=typeof n)return e(t,n,r);let{cache:i}=r,o=i.get(t),s=i.get(n);if(o&&s)return o===n&&s===t;i.set(t,n),i.set(n,t);let a=e(t,n,r);return i.delete(t),i.delete(n),a}}function a_(e){return aj(e).concat(aI(e))}let a$=Object.hasOwn||((e,t)=>aP.call(e,t));function aH(e,t){return e===t||!e&&!t&&e!=e&&t!=t}let{getOwnPropertyDescriptor:aB,keys:aF}=Object;function aV(e,t){return e.byteLength===t.byteLength&&a1(new Uint8Array(e),new Uint8Array(t))}function aU(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function aW(e,t){return e.byteLength===t.byteLength&&a1(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function aK(e,t){return aH(e.getTime(),t.getTime())}function aq(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function aJ(e,t){return e===t}function aG(e,t,n){let r,i,o=e.size;if(o!==t.size)return!1;if(!o)return!0;let s=Array(o),a=e.entries(),l=0;for(;(r=a.next())&&!r.done;){let o=t.entries(),a=!1,c=0;for(;(i=o.next())&&!i.done;){if(s[c]){c++;continue}let o=r.value,d=i.value;if(n.equals(o[0],d[0],l,c,e,t,n)&&n.equals(o[1],d[1],o[0],d[0],e,t,n)){a=s[c]=!0;break}c++}if(!a)return!1;l++}return!0}function aX(e,t,n){let r=aF(e),i=r.length;if(aF(t).length!==i)return!1;for(;i-- >0;)if(!a5(e,t,n,r[i]))return!1;return!0}function aZ(e,t,n){let r,i,o,s=a_(e),a=s.length;if(a_(t).length!==a)return!1;for(;a-- >0;)if(!a5(e,t,n,r=s[a])||(i=aB(e,r),o=aB(t,r),(i||o)&&(!i||!o||i.configurable!==o.configurable||i.enumerable!==o.enumerable||i.writable!==o.writable)))return!1;return!0}function aY(e,t){return aH(e.valueOf(),t.valueOf())}function aQ(e,t){return e.source===t.source&&e.flags===t.flags}function a0(e,t,n){let r,i,o=e.size;if(o!==t.size)return!1;if(!o)return!0;let s=Array(o),a=e.values();for(;(r=a.next())&&!r.done;){let o=t.values(),a=!1,l=0;for(;(i=o.next())&&!i.done;){if(!s[l]&&n.equals(r.value,i.value,r.value,i.value,e,t,n)){a=s[l]=!0;break}l++}if(!a)return!1}return!0}function a1(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function a2(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function a5(e,t,n,r){return("_owner"===r||"__o"===r||"__v"===r)&&(!!e.$$typeof||!!t.$$typeof)||a$(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}let a3={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},a4=Object.prototype.toString,a6=a9();function a9(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,o=function({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:o,areMapsEqual:s,areNumbersEqual:a,areObjectsEqual:l,arePrimitiveWrappersEqual:c,areRegExpsEqual:d,areSetsEqual:u,areTypedArraysEqual:h,areUrlsEqual:p,unknownTagComparators:f}){return function(m,g,y){if(m===g)return!0;if(null==m||null==g)return!1;let b=typeof m;if(b!==typeof g)return!1;if("object"!==b)return"number"===b?a(m,g,y):"function"===b&&o(m,g,y);let v=m.constructor;if(v!==g.constructor)return!1;if(v===Object)return l(m,g,y);if(Array.isArray(m))return t(m,g,y);if(v===Date)return r(m,g,y);if(v===RegExp)return d(m,g,y);if(v===Map)return s(m,g,y);if(v===Set)return u(m,g,y);let w=a4.call(m);if("[object Date]"===w)return r(m,g,y);if("[object RegExp]"===w)return d(m,g,y);if("[object Map]"===w)return s(m,g,y);if("[object Set]"===w)return u(m,g,y);if("[object Object]"===w)return"function"!=typeof m.then&&"function"!=typeof g.then&&l(m,g,y);if("[object URL]"===w)return p(m,g,y);if("[object Error]"===w)return i(m,g,y);if("[object Arguments]"===w)return l(m,g,y);if(a3[w])return h(m,g,y);if("[object ArrayBuffer]"===w)return e(m,g,y);if("[object DataView]"===w)return n(m,g,y);if("[object Boolean]"===w||"[object Number]"===w||"[object String]"===w)return c(m,g,y);if(f){let e=f[w];if(!e){let t=null!=m?m[Symbol.toStringTag]:void 0;t&&(e=f[t])}if(e)return e(m,g,y)}return!1}}(function({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:aV,areArraysEqual:n?aZ:aU,areDataViewsEqual:aW,areDatesEqual:aK,areErrorsEqual:aq,areFunctionsEqual:aJ,areMapsEqual:n?aL(aG,aZ):aG,areNumbersEqual:aH,areObjectsEqual:n?aZ:aX,arePrimitiveWrappersEqual:aY,areRegExpsEqual:aQ,areSetsEqual:n?aL(a0,aZ):a0,areTypedArraysEqual:n?aL(a1,aZ):a1,areUrlsEqual:a2,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=az(r.areArraysEqual),t=az(r.areMapsEqual),n=az(r.areObjectsEqual),i=az(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}(e)),s=n?n(o):function(e,t,n,r,i,s,a){return o(e,t,a)};return function({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(o,s){let{cache:a=e?new WeakMap:void 0,meta:l}=n();return t(o,s,{cache:a,equals:r,meta:l,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let o={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,o)}}({circular:t,comparator:o,createState:r,equals:s,strict:i})}a9({strict:!0}),a9({circular:!0}),a9({circular:!0,strict:!0}),a9({createInternalComparator:()=>aH}),a9({strict:!0,createInternalComparator:()=>aH}),a9({circular:!0,createInternalComparator:()=>aH}),a9({circular:!0,createInternalComparator:()=>aH,strict:!0});var a7=e.i(383835),a8=({contentComponent:e})=>{let t=(0,iI.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,iP.jsx)(iP.Fragment,{children:Object.values(t)})},le=class extends iD.default.Component{constructor(e){super(e),this.editorContentRef=iD.default.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var e;let t=this.props.editor;if(t&&!t.isDestroyed&&(null==(e=t.view.dom)?void 0:e.parentNode)){let e,n;if(t.contentComponent)return;let r=this.editorContentRef.current;r.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:r}),e=new Set,n={},t.contentComponent={subscribe:t=>(e.add(t),()=>{e.delete(t)}),getSnapshot:()=>n,getServerSnapshot:()=>n,setRenderer(t,r){n={...n,[t]:ij.default.createPortal(r.reactElement,r.element,t)},e.forEach(e=>e())},removeRenderer(t){let r={...n};delete r[t],n=r,e.forEach(e=>e())}},t.createNodeViews(),t.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){var e;let t=this.props.editor;if(t){t.isEditorContentInitialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),t.contentComponent=null;try{if(!(null==(e=t.view.dom)?void 0:e.parentNode))return;let n=document.createElement("div");n.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:n})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,iP.jsxs)(iP.Fragment,{children:[(0,iP.jsx)("div",{ref:((...e)=>t=>{e.forEach(e=>{"function"==typeof e?e(t):e&&(e.current=t)})})(t,this.editorContentRef),...n}),(null==e?void 0:e.contentComponent)&&(0,iP.jsx)(a8,{contentComponent:e.contentComponent})]})}},lt=(0,iD.forwardRef)((e,t)=>{let n=iD.default.useMemo(()=>Math.floor(0xffffffff*Math.random()).toString(),[e.editor]);return iD.default.createElement(le,{key:n,innerRef:t,...e})}),ln=iD.default.memo(lt),lr="u">typeof window?iD.useLayoutEffect:iD.useEffect,li=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}},lo="u"<typeof window,ls=lo||!!("u">typeof window&&window.next),la=class e{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(e=>e())}getInitialEditor(){let e=this.options.current.immediatelyRender,t=null==e||e;return lo?t=!1:ls&&void 0===e&&(t=!1),t?this.createEditor():null}createEditor(){return new ab({...this.options.current,onBeforeCreate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onBeforeCreate)?void 0:n.call(t,...e)},onBlur:(...e)=>{var t,n;return null==(n=(t=this.options.current).onBlur)?void 0:n.call(t,...e)},onCreate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onCreate)?void 0:n.call(t,...e)},onDestroy:(...e)=>{var t,n;return null==(n=(t=this.options.current).onDestroy)?void 0:n.call(t,...e)},onFocus:(...e)=>{var t,n;return null==(n=(t=this.options.current).onFocus)?void 0:n.call(t,...e)},onSelectionUpdate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onSelectionUpdate)?void 0:n.call(t,...e)},onTransaction:(...e)=>{var t,n;return null==(n=(t=this.options.current).onTransaction)?void 0:n.call(t,...e)},onUpdate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onUpdate)?void 0:n.call(t,...e)},onContentError:(...e)=>{var t,n;return null==(n=(t=this.options.current).onContentError)?void 0:n.call(t,...e)},onDrop:(...e)=>{var t,n;return null==(n=(t=this.options.current).onDrop)?void 0:n.call(t,...e)},onPaste:(...e)=>{var t,n;return null==(n=(t=this.options.current).onPaste)?void 0:n.call(t,...e)},onDelete:(...e)=>{var t,n;return null==(n=(t=this.options.current).onDelete)?void 0:n.call(t,...e)}})}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(n=>!!["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(n)||("extensions"===n&&e.extensions&&t.extensions?e.extensions.length===t.extensions.length&&e.extensions.every((e,n)=>{var r;return e===(null==(r=t.extensions)?void 0:r[n])}):e[n]===t[n]))}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===t.length?e.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(null===this.previousDeps){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((t,n)=>t===e[n]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){let e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}},ll=(0,iD.createContext)({editor:null});ll.Consumer;var lc=(0,iD.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),ld=iD.default.forwardRef((e,t)=>{let{onDragStart:n}=(0,iD.useContext)(lc),r=e.as||"div";return(0,iP.jsx)(r,{...e,ref:t,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...e.style}})});function lu(e){return!!("function"==typeof e&&e.prototype&&e.prototype.isReactComponent)}function lh(e){return!!("object"==typeof e&&e.$$typeof&&("Symbol(react.forward_ref)"===e.$$typeof.toString()||"react.forward_ref"===e.$$typeof.description))}var lp=class{constructor(e,{editor:t,props:n={},as:r="div",className:i=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(0xffffffff*Math.random()).toString(),this.component=e,this.editor=t,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),i&&this.element.classList.add(...i.split(" ")),this.editor.isEditorContentInitialized?(0,ij.flushSync)(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var e;if(this.destroyed)return;let t=this.component,n=this.props,r=this.editor,i=function(){try{if(iD.version)return parseInt(iD.version.split(".")[0],10)>=19}catch{}return!1}(),o=function(e){if(lu(e)||lh(e))return!0;if("object"==typeof e&&e.$$typeof&&("Symbol(react.memo)"===e.$$typeof.toString()||"react.memo"===e.$$typeof.description)){let t=e.type;if(t)return lu(t)||lh(t)}return!1}(t),s={...n};s.ref&&!(i||o)&&delete s.ref,!s.ref&&(i||o)&&(s.ref=e=>{this.ref=e}),this.reactElement=(0,iP.jsx)(t,{...s}),null==(e=null==r?void 0:r.contentComponent)||e.setRenderer(this.id,this)}updateProps(e={}){if(this.destroyed)return;let t=!1,n=Object.keys(e);for(let r=0;r<n.length;r+=1){let i=n[r];if(e[i]!==this.props[i]){t=!0;break}}t&&(this.props={...this.props,...e},this.render())}destroy(){var e;this.destroyed=!0;let t=this.editor;null==(e=null==t?void 0:t.contentComponent)||e.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(e){Object.keys(e).forEach(t=>{this.element.setAttribute(t,e[t])})}};iD.default.createContext({markViewContentRef:()=>{}});var lf=class extends aD{constructor(e,t,n){if(super(e,t,n),this.selectionRafId=null,this.handlePositionUpdate=()=>{let e=this.getPos();"number"==typeof e&&e!==this.currentPos&&(this.currentPos=e,this.renderer.updateProps({getPos:()=>this.getPos()}),"function"==typeof this.options.attrs&&this.updateElementAttributes())},this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const e=this.dom.querySelector("[data-node-view-content]");if(!e)return;e.appendChild(this.contentDOMElement)}this.options.trackNodeViewPosition&&this.editor.on("update",this.handlePositionUpdate)}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){let e=this.editor,t=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(t,{get(n,r,i){var o;return"storage"===r?null!=(o=e.storage[t.name])?o:{}:Reflect.get(n,r,i)}})}return this.cachedExtensionWithSyncedStorage}mount(){let e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode(),ref:(0,iD.createRef)()};if(!this.component.displayName){let e;this.component.displayName=(e=this.extension.name).charAt(0).toUpperCase()+e.substring(1)}let t={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:e=>{e&&this.contentDOMElement&&e.firstChild!==this.contentDOMElement&&(e.hasAttribute("data-node-view-wrapper")&&e.removeAttribute("data-node-view-wrapper"),e.appendChild(this.contentDOMElement))}},n=this.component,r=(0,iD.memo)(e=>(0,iP.jsx)(lc.Provider,{value:t,children:(0,iD.createElement)(n,e)}));r.displayName="ReactNodeView";let i=this.node.isInline?"span":"div";this.options.as&&(i=this.options.as);let{className:o=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new lp(r,{editor:this.editor,props:e,as:i,className:`node-${this.node.type.name} ${o}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes(),this.currentPos=this.getPos()}get dom(){var e;if(this.renderer.element.firstElementChild&&!(null==(e=this.renderer.element.firstElementChild)?void 0:e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;let e=this.currentPos;if("number"==typeof e)if(sD({selection:this.editor.state.selection,pos:e,nodeSize:this.node.nodeSize,selectedOnTextSelection:this.options.selectedOnTextSelection})){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(e,t,n){let r=e=>{this.renderer.updateProps(e),"function"==typeof this.options.attrs&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if("function"==typeof this.options.update){let i=this.node,o=this.decorations,s=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=this.getPos(),this.options.update({oldNode:i,oldDecorations:o,newNode:e,newDecorations:t,oldInnerDecorations:s,innerDecorations:n,updateProps:()=>r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}if(e===this.node)return this.node=e,this.decorations=t,this.innerDecorations=n,!0;let i=this.getPos();this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=i;let o={node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage};return this.options.trackNodeViewPosition&&(o.getPos=()=>this.getPos()),r(o),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.options.trackNodeViewPosition&&this.editor.off("update",this.handlePositionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let e={};if("function"==typeof this.options.attrs){let t=this.editor.extensionManager.attributes,n=sf(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}},lm=(0,iD.createContext)({get editor(){throw Error("useTiptap must be used within a <Tiptap> provider")}});function lg({editor:e,instance:t,children:n}){let r=null!=e?e:t;if(!r)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let i=(0,iD.useMemo)(()=>({editor:r}),[r]),o=(0,iD.useMemo)(()=>({editor:r}),[r]);return(0,iP.jsx)(ll.Provider,{value:o,children:(0,iP.jsx)(lm.Provider,{value:i,children:n})})}function ly({...e}){let{editor:t}=(0,iD.useContext)(lm);return(0,iP.jsx)(ln,{editor:t,...e})}lm.displayName="TiptapContext",lg.displayName="Tiptap",ly.displayName="Tiptap.Content",Object.assign(lg,{Content:ly}),e.s(["EditorContent",0,ln,"NodeViewWrapper",0,ld,"ReactNodeViewRenderer",0,function(e,t){return n=>n.editor.contentComponent?new lf(e,n,t):{}},"useCurrentEditor",0,()=>(0,iD.useContext)(ll),"useEditor",0,function(e={},t=[]){let n=(0,iD.useRef)(e);n.current=e;let[r]=(0,iD.useState)(()=>new la(n)),i=(0,iI.useSyncExternalStore)(r.subscribe,r.getEditor,r.getServerSnapshot);return(0,iD.useDebugValue)(i),(0,iD.useEffect)(r.onRender(t)),!function(e){var t;let[n]=(0,iD.useState)(()=>new li(e.editor)),r=(0,a7.useSyncExternalStoreWithSelector)(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,null!=(t=e.equalityFn)?t:a6);lr(()=>n.watch(e.editor),[e.editor,n]),(0,iD.useDebugValue)(r)}({editor:i,selector:({transactionNumber:t})=>!1===e.shouldRerenderOnTransaction||void 0===e.shouldRerenderOnTransaction?null:e.immediatelyRender&&0===t?0:t+1}),i}],885047)},313393,e=>{"use strict";let t=(0,e.i(605993).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"}]]);e.s(["Code2",0,t],313393)},530229,e=>{"use strict";let t=(0,e.i(605993).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"}]]);e.s(["FilePlus",0,t],530229)},231597,417068,660885,490275,534537,562199,24800,96701,990791,395624,246542,592185,926732,417385,e=>{"use strict";let t=(0,e.i(605993).default)("sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);function n(e,t){return Array(t+1).join(e)}function r(e){return e.replace(/^\n*/,"")}function i(e){for(var t=e.length;t>0&&"\n"===e[t-1];)t--;return e.substring(0,t)}e.s(["Sparkles",0,t],231597),e.s(["findNodeByPath",0,function e(t,n){for(let r of t){if(r.path===n)return r;if(r.children){let t=e(r.children,n);if(t)return t}}return null}],417068);var o,s,a=["ADDRESS","ARTICLE","ASIDE","AUDIO","BLOCKQUOTE","BODY","CANVAS","CENTER","DD","DIR","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","FRAMESET","H1","H2","H3","H4","H5","H6","HEADER","HGROUP","HR","HTML","ISINDEX","LI","MAIN","MENU","NAV","NOFRAMES","NOSCRIPT","OL","OUTPUT","P","PRE","SECTION","TABLE","TBODY","TD","TFOOT","TH","THEAD","TR","UL"];function l(e){return h(e,a)}var c=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"];function d(e){return h(e,c)}var u=["A","TABLE","THEAD","TBODY","TFOOT","TH","TD","IFRAME","SCRIPT","AUDIO","VIDEO"];function h(e,t){return t.indexOf(e.nodeName)>=0}function p(e,t){return e.getElementsByTagName&&t.some(function(t){return e.getElementsByTagName(t).length})}var f=[[/\\/g,"\\\\"],[/\*/g,"\\*"],[/^-/g,"\\-"],[/^\+ /g,"\\+ "],[/^(=+)/g,"\\$1"],[/^(#{1,6}) /g,"\\$1 "],[/`/g,"\\`"],[/^~~~/g,"\\~~~"],[/\[/g,"\\["],[/\]/g,"\\]"],[/^>/g,"\\>"],[/_/g,"\\_"],[/^(\d+)\. /g,"$1\\. "]];function m(e){return f.reduce(function(e,t){return e.replace(t[0],t[1])},e)}var g={};function y(e){return e?e.replace(/(\n+\s*)+/g,"\n"):""}function b(e){var t=e.replace(/([<>()])/g,"\\$1");return t.indexOf(" ")>=0?"<"+t+">":t}function v(e){return e.replace(/"/g,'\\"')}function w(e){for(var t in this.options=e,this._keep=[],this._remove=[],this.blankRule={replacement:e.blankReplacement},this.keepReplacement=e.keepReplacement,this.defaultRule={replacement:e.defaultReplacement},this.array=[],e.rules)this.array.push(e.rules[t])}function x(e,t,n){for(var r=0;r<e.length;r++){var i=e[r];if(function(e,t,n){var r=e.filter;if("string"==typeof r){if(r===t.nodeName.toLowerCase())return!0}else if(Array.isArray(r)){if(r.indexOf(t.nodeName.toLowerCase())>-1)return!0}else if("function"==typeof r){if(r.call(e,t,n))return!0}else throw TypeError("`filter` needs to be a string, array, or function")}(i,t,n))return i}}function k(e){var t=e.nextSibling||e.parentNode;return e.parentNode.removeChild(e),t}function S(e,t,n){return e&&e.parentNode===t||n(t)?t.nextSibling||t.parentNode:t.firstChild||t.nextSibling||t.parentNode}g.paragraph={filter:"p",replacement:function(e){return"\n\n"+e+"\n\n"}},g.lineBreak={filter:"br",replacement:function(e,t,n){return n.br+"\n"}},g.heading={filter:["h1","h2","h3","h4","h5","h6"],replacement:function(e,t,r){var i=Number(t.nodeName.charAt(1));if("setext"!==r.headingStyle||!(i<3))return"\n\n"+n("#",i)+" "+e+"\n\n";var o=n(1===i?"=":"-",e.length);return"\n\n"+e+"\n"+o+"\n\n"}},g.blockquote={filter:"blockquote",replacement:function(e){return"\n\n"+(e=i(r(e)).replace(/^/gm,"> "))+"\n\n"}},g.list={filter:["ul","ol"],replacement:function(e,t){var n=t.parentNode;return"LI"===n.nodeName&&n.lastElementChild===t?"\n"+e:"\n\n"+e+"\n\n"}},g.listItem={filter:"li",replacement:function(e,t,n){var o=n.bulletListMarker+" ",s=t.parentNode;if("OL"===s.nodeName){var a=s.getAttribute("start"),l=Array.prototype.indexOf.call(s.children,t);o=(a?Number(a)+l:l+1)+". "}var c=/\n$/.test(e);return e=(e=i(r(e))+(c?"\n":"")).replace(/\n/gm,"\n"+" ".repeat(o.length)),o+e+(t.nextSibling?"\n":"")}},g.indentedCodeBlock={filter:function(e,t){return"indented"===t.codeBlockStyle&&"PRE"===e.nodeName&&e.firstChild&&"CODE"===e.firstChild.nodeName},replacement:function(e,t,n){return"\n\n "+t.firstChild.textContent.replace(/\n/g,"\n ")+"\n\n"}},g.fencedCodeBlock={filter:function(e,t){return"fenced"===t.codeBlockStyle&&"PRE"===e.nodeName&&e.firstChild&&"CODE"===e.firstChild.nodeName},replacement:function(e,t,r){for(var i,o=((t.firstChild.getAttribute("class")||"").match(/language-(\S+)/)||[null,""])[1],s=t.firstChild.textContent,a=r.fence.charAt(0),l=3,c=RegExp("^"+a+"{3,}","gm");i=c.exec(s);)i[0].length>=l&&(l=i[0].length+1);var d=n(a,l);return"\n\n"+d+o+"\n"+s.replace(/\n$/,"")+"\n"+d+"\n\n"}},g.horizontalRule={filter:"hr",replacement:function(e,t,n){return"\n\n"+n.hr+"\n\n"}},g.inlineLink={filter:function(e,t){return"inlined"===t.linkStyle&&"A"===e.nodeName&&e.getAttribute("href")},replacement:function(e,t){var n=b(t.getAttribute("href")),r=v(y(t.getAttribute("title")));return"["+e+"]("+n+(r?' "'+r+'"':"")+")"}},g.referenceLink={filter:function(e,t){return"referenced"===t.linkStyle&&"A"===e.nodeName&&e.getAttribute("href")},replacement:function(e,t,n){var r,i,o=b(t.getAttribute("href")),s=y(t.getAttribute("title"));switch(s&&(s=' "'+v(s)+'"'),n.linkReferenceStyle){case"collapsed":r="["+e+"][]",i="["+e+"]: "+o+s;break;case"shortcut":r="["+e+"]",i="["+e+"]: "+o+s;break;default:var a=this.references.length+1;r="["+e+"]["+a+"]",i="["+a+"]: "+o+s}return this.references.push(i),r},references:[],append:function(e){var t="";return this.references.length&&(t="\n\n"+this.references.join("\n")+"\n\n",this.references=[]),t}},g.emphasis={filter:["em","i"],replacement:function(e,t,n){return e.trim()?n.emDelimiter+e+n.emDelimiter:""}},g.strong={filter:["strong","b"],replacement:function(e,t,n){return e.trim()?n.strongDelimiter+e+n.strongDelimiter:""}},g.code={filter:function(e){var t=e.previousSibling||e.nextSibling,n="PRE"===e.parentNode.nodeName&&!t;return"CODE"===e.nodeName&&!n},replacement:function(e){if(!e)return"";e=e.replace(/\r?\n|\r/g," ");for(var t=/^`|^ .*?[^ ].* $|`$/.test(e)?" ":"",n="`",r=e.match(/`+/gm)||[];-1!==r.indexOf(n);)n+="`";return n+t+e+t+n}},g.image={filter:"img",replacement:function(e,t){var n=m(y(t.getAttribute("alt"))),r=b(t.getAttribute("src")||""),i=y(t.getAttribute("title")),o=i?' "'+v(i)+'"':"";return r?"!["+n+"]("+r+o+")":""}},w.prototype={add:function(e,t){this.array.unshift(t)},keep:function(e){this._keep.unshift({filter:e,replacement:this.keepReplacement})},remove:function(e){this._remove.unshift({filter:e,replacement:function(){return""}})},forNode:function(e){var t;return e.isBlank?this.blankRule:(t=x(this.array,e,this.options))||(t=x(this._keep,e,this.options))||(t=x(this._remove,e,this.options))?t:this.defaultRule},forEach:function(e){for(var t=0;t<this.array.length;t++)e(this.array[t],t)}};var C="u">typeof window?window:{},E=!function(){var e=C.DOMParser,t=!1;try{new e().parseFromString("","text/html")&&(t=!0)}catch(e){}return t}()?(o=function(){},!function(){var e=!1;try{document.implementation.createHTMLDocument("").open()}catch(t){C.ActiveXObject&&(e=!0)}return e}()?o.prototype.parseFromString=function(e){var t=document.implementation.createHTMLDocument("");return t.open(),t.write(e),t.close(),t}:o.prototype.parseFromString=function(e){var t=new window.ActiveXObject("htmlfile");return t.designMode="on",t.open(),t.write(e),t.close(),t},o):C.DOMParser;function M(e,t){var n;return!function(e){var t=e.element,n=e.isBlock,r=e.isVoid,i=e.isPre||function(e){return"PRE"===e.nodeName};if(!(!t.firstChild||i(t))){for(var o=null,s=!1,a=null,l=S(null,t,i);l!==t;){if(3===l.nodeType||4===l.nodeType){var c=l.data.replace(/[ \r\n\t]+/g," ");if((!o||/ $/.test(o.data))&&!s&&" "===c[0]&&(c=c.substr(1)),!c){l=k(l);continue}l.data=c,o=l}else if(1===l.nodeType)n(l)||"BR"===l.nodeName?(o&&(o.data=o.data.replace(/ $/,"")),o=null,s=!1):r(l)||i(l)?(o=null,s=!0):o&&(s=!1);else{l=k(l);continue}var d=S(a,l,i);a=l,l=d}o&&(o.data=o.data.replace(/ $/,""),o.data||k(o))}}({element:n="string"==typeof e?(s=s||new E).parseFromString('<x-turndown id="turndown-root">'+e+"</x-turndown>","text/html").getElementById("turndown-root"):e.cloneNode(!0),isBlock:l,isVoid:d,isPre:t.preformattedCode?N:null}),n}function N(e){return"PRE"===e.nodeName||"CODE"===e.nodeName}function A(e,t){var n;return e.isBlock=l(e),e.isCode="CODE"===e.nodeName||e.parentNode.isCode,e.isBlank=!d(n=e)&&!h(n,u)&&/^\s*$/i.test(n.textContent)&&!p(n,c)&&!p(n,u),e.flankingWhitespace=function(e,t){if(e.isBlock||t.preformattedCode&&e.isCode)return{leading:"",trailing:""};var n,r={leading:(n=e.textContent.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/))[1],leadingAscii:n[2],leadingNonAscii:n[3],trailing:n[4],trailingNonAscii:n[5],trailingAscii:n[6]};return r.leadingAscii&&T("left",e,t)&&(r.leading=r.leadingNonAscii),r.trailingAscii&&T("right",e,t)&&(r.trailing=r.trailingNonAscii),{leading:r.leading,trailing:r.trailing}}(e,t),e}function T(e,t,n){var r,i,o;return"left"===e?(r=t.previousSibling,i=/ $/):(r=t.nextSibling,i=/^ /),r&&(3===r.nodeType?o=i.test(r.nodeValue):n.preformattedCode&&"CODE"===r.nodeName?o=!1:1!==r.nodeType||l(r)||(o=i.test(r.textContent))),o}var R=Array.prototype.reduce;function O(e){if(!(this instanceof O))return new O(e);this.options=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}({},{rules:g,headingStyle:"setext",hr:"* * *",bulletListMarker:"*",codeBlockStyle:"indented",fence:"```",emDelimiter:"_",strongDelimiter:"**",linkStyle:"inlined",linkReferenceStyle:"full",br:" ",preformattedCode:!1,blankReplacement:function(e,t){return t.isBlock?"\n\n":""},keepReplacement:function(e,t){return t.isBlock?"\n\n"+t.outerHTML+"\n\n":t.outerHTML},defaultReplacement:function(e,t){return t.isBlock?"\n\n"+e+"\n\n":e}},e),this.rules=new w(this.options)}function D(e){var t=this;return R.call(e.childNodes,function(e,n){n=new A(n,t.options);var r="";return 3===n.nodeType?r=n.isCode?n.nodeValue:t.escape(n.nodeValue):1===n.nodeType&&(r=I.call(t,n)),P(e,r)},"")}function j(e){var t=this;return this.rules.forEach(function(n){"function"==typeof n.append&&(e=P(e,n.append(t.options)))}),e.replace(/^[\t\r\n]+/,"").replace(/[\t\r\n\s]+$/,"")}function I(e){var t=this.rules.forNode(e),n=D.call(this,e),r=e.flankingWhitespace;return(r.leading||r.trailing)&&(n=n.trim()),r.leading+t.replacement(n,e,this.options)+r.trailing}function P(e,t){var n=i(e),o=r(t),s=Math.max(e.length-n.length,t.length-o.length);return n+"\n\n".substring(0,s)+o}O.prototype={turndown:function(e){var t;if(!(null!=(t=e)&&("string"==typeof t||t.nodeType&&(1===t.nodeType||9===t.nodeType||11===t.nodeType))))throw TypeError(e+" is not a string, or an element/document/fragment node.");return""===e?"":j.call(this,D.call(this,new M(e,this.options)))},use:function(e){if(Array.isArray(e))for(var t=0;t<e.length;t++)this.use(e[t]);else if("function"==typeof e)e(this);else throw TypeError("plugin must be a Function or an Array of Functions");return this},addRule:function(e,t){return this.rules.add(e,t),this},keep:function(e){return this.rules.keep(e),this},remove:function(e){return this.rules.remove(e),this},escape:function(e){return m(e)}};var L=/highlight-(?:text|source)-([a-z0-9]+)/;function z(e){e.addRule("highlightedCodeBlock",{filter:function(e){var t=e.firstChild;return"DIV"===e.nodeName&&L.test(e.className)&&t&&"PRE"===t.nodeName},replacement:function(e,t,n){var r=((t.className||"").match(L)||[null,""])[1];return"\n\n"+n.fence+r+"\n"+t.firstChild.textContent+"\n"+n.fence+"\n\n"}})}function _(e){e.addRule("strikethrough",{filter:["del","s","strike"],replacement:function(e){return"~"+e+"~"}})}var $=Array.prototype.indexOf,H=Array.prototype.every,B={};function F(e){var t,n,r=e.parentNode;return"THEAD"===r.nodeName||r.firstChild===e&&("TABLE"===r.nodeName||(n=(t=r).previousSibling,"TBODY"===t.nodeName&&(!n||"THEAD"===n.nodeName&&/^\s*$/i.test(n.textContent))))&&H.call(e.childNodes,function(e){return"TH"===e.nodeName})}function V(e,t){var n=$.call(t.parentNode.childNodes,t),r=" ";return 0===n&&(r="| "),r+e+" |"}function U(e){for(var t in e.keep(function(e){return"TABLE"===e.nodeName&&!F(e.rows[0])}),B)e.addRule(t,B[t])}function W(e){e.addRule("taskListItems",{filter:function(e){return"checkbox"===e.type&&"LI"===e.parentNode.nodeName},replacement:function(e,t){return(t.checked?"[x]":"[ ]")+" "}})}B.tableCell={filter:["th","td"],replacement:function(e,t){return V(e,t)}},B.tableRow={filter:"tr",replacement:function(e,t){var n="",r={left:":--",right:"--:",center:":-:"};if(F(t))for(var i=0;i<t.childNodes.length;i++){var o="---",s=(t.childNodes[i].getAttribute("align")||"").toLowerCase();s&&(o=r[s]||o),n+=V(o,t.childNodes[i])}return"\n"+e+(n?"\n"+n:"")}},B.table={filter:function(e){return"TABLE"===e.nodeName&&F(e.rows[0])},replacement:function(e){return"\n\n"+(e=e.replace("\n\n","\n"))+"\n\n"}},B.tableSection={filter:["thead","tbody","tfoot"],replacement:function(e){return e}};var K=e.i(319814);let q=new O({headingStyle:"atx",hr:"---",bulletListMarker:"-",codeBlockStyle:"fenced",fence:"```",emDelimiter:"*",strongDelimiter:"**"});for(let e of(q.use(function(e){e.use([z,_,U,W])}),q.addRule("codeBlock",{filter:e=>"PRE"===e.nodeName&&null!==e.firstChild&&"CODE"===e.firstChild.nodeName,replacement:(e,t)=>{let n=t.firstChild,r=n.getAttribute("class")?.replace("language-","")||"",i=n.textContent||"";return`
83
83
  \`\`\`${r}
84
84
  ${i}
85
85
  \`\`\`
86
- `}}),q.addRule("wikiLink",{filter:e=>"A"===e.nodeName&&"true"===e.getAttribute("data-wiki-link"),replacement:(e,t)=>{let n=t.getAttribute("data-slug")??"",r=t.getAttribute("data-alias"),i=t.getAttribute("data-anchor");return r?`[[${n}|${r}]]`:i?`[[${n}#${i}]]`:`[[${n}]]`}}),q.addRule("proofSpan",{filter:e=>"PROOF-SPAN"===e.nodeName,replacement:(e,t)=>{let n=[];for(let e of Array.from(t.attributes))n.push(`${e.name}="${e.value.replace(/"/g,"&quot;")}"`);return`<proof-span${n.length?" "+n.join(" "):""}>${e}</proof-span>`}}),q.addRule("styledSpan",{filter:e=>"SPAN"===e.nodeName&&!!e.getAttribute("style"),replacement:(e,t)=>{let n=t.getAttribute("style")??"";return`<span style="${n}">${e}</span>`}}),q.addRule("lucideIcon",{filter:e=>"SPAN"===e.nodeName&&e.hasAttribute("data-lucide"),replacement:(e,t)=>{let n=t.getAttribute("data-lucide")??"file",r=t.getAttribute("data-color")??"gray";return`<span data-lucide="${n}" data-color="${r}">&nbsp;</span>`}}),q.addRule("mark",{filter:"mark",replacement:(e,t)=>{let n=[];for(let e of Array.from(t.attributes))n.push(`${e.name}="${e.value.replace(/"/g,"&quot;")}"`);return`<mark${n.length?` ${n.join(" ")}`:""}>${e}</mark>`}}),["u","sub","sup"]))q.addRule(e,{filter:e,replacement:t=>`<${e}>${t}</${e}>`});q.addRule("video",{filter:"video",replacement:(e,t)=>{let n=t.getAttribute("src")??"",r=n?(0,K.detectEmbed)(n):null;if(r&&"video"!==r.provider){let e=r.aspectRatio?` data-aspect-ratio="${r.aspectRatio}"`:"";return`
86
+ `}}),q.addRule("wikiLink",{filter:e=>"A"===e.nodeName&&"true"===e.getAttribute("data-wiki-link"),replacement:(e,t)=>{let n=t.getAttribute("data-slug")??"",r=t.getAttribute("data-alias"),i=t.getAttribute("data-anchor");return r?`[[${n}|${r}]]`:i?`[[${n}#${i}]]`:`[[${n}]]`}}),q.addRule("proofSpan",{filter:e=>"PROOF-SPAN"===e.nodeName,replacement:(e,t)=>{let n=[];for(let e of Array.from(t.attributes))n.push(`${e.name}="${e.value.replace(/"/g,"&quot;")}"`);return`<proof-span${n.length?" "+n.join(" "):""}>${e}</proof-span>`}}),q.addRule("styledSpan",{filter:e=>"SPAN"===e.nodeName&&!!e.getAttribute("style"),replacement:(e,t)=>{let n=t.getAttribute("style")??"";return`<span style="${n}">${e}</span>`}}),q.addRule("lucideIcon",{filter:e=>"SPAN"===e.nodeName&&e.hasAttribute("data-lucide"),replacement:(e,t)=>{let n=t.getAttribute("data-lucide")??"file",r=t.getAttribute("data-color")??"gray";return`<span data-lucide="${n}" data-color="${r}">&nbsp;</span>`}}),q.addRule("mark",{filter:"mark",replacement:(e,t)=>{let n=[];for(let e of Array.from(t.attributes))n.push(`${e.name}="${e.value.replace(/"/g,"&quot;")}"`);return`<mark${n.length?` ${n.join(" ")}`:""}>${e}</mark>`}}),["u","sub","sup"]))q.addRule(e,{filter:e,replacement:t=>`<${e}>${t}</${e}>`});function J(e,t){let n=e.match(/^\/api\/assets\/(.+)$/);if(!n)return e;let r=n[1].replace(/[?#].*$/,"").split("/").map(e=>{try{return decodeURIComponent(e)}catch{return e}}),i=t.lastIndexOf("/"),o=-1===i?[]:t.slice(0,i).split("/"),s=0;for(;s<o.length&&s<r.length&&o[s]===r[s];)s++;let a=o.slice(s).map(()=>"..").concat(r.slice(s)).join("/");return a?a.startsWith(".")?a:`./${a}`:"./"}q.addRule("video",{filter:"video",replacement:(e,t)=>{let n=t.getAttribute("src")??"",r=n?(0,K.detectEmbed)(n):null;if(r&&"video"!==r.provider){let e=r.aspectRatio?` data-aspect-ratio="${r.aspectRatio}"`:"";return`
87
87
  <div data-embed="true" data-provider="${r.provider}" data-src="${r.embedUrl}" data-original-url="${r.originalUrl}"${e}><iframe src="${r.embedUrl}" data-embed-provider="${r.provider}" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen" allowfullscreen loading="lazy" frameborder="0"></iframe></div>
88
88
  `}let i=[];for(let e of Array.from(t.attributes))i.push(`${e.name}="${e.value.replace(/"/g,"&quot;")}"`);return`<video${i.length?` ${i.join(" ")}`:""}></video>`}}),q.addRule("embedBlock",{filter:e=>"DIV"===e.nodeName&&"true"===e.getAttribute("data-embed"),replacement:(e,t)=>{let n=t.getAttribute("data-provider")??"iframe",r=t.getAttribute("data-src")??"",i=t.getAttribute("data-original-url")??"",o=t.getAttribute("data-aspect-ratio")??"";if("video"===n)return`
89
89
  <video src="${r}" controls></video>
@@ -93,9 +93,9 @@ ${i}
93
93
  <blockquote class="twitter-tweet" data-theme="auto"><a href="${r}">${r}</a></blockquote>
94
94
  `}}),q.addRule("sizedImage",{filter:e=>{if("IMG"!==e.nodeName)return!1;let t=e.getAttribute("width")??e.style.width,n=e.getAttribute("data-align");return!!(t||n)},replacement:(e,t)=>{let n=[];for(let e of Array.from(t.attributes))n.push(`${e.name}="${e.value.replace(/"/g,"&quot;")}"`);return`<img ${n.join(" ")} />`}}),q.addRule("resizableImageWrapper",{filter:e=>"DIV"===e.nodeName&&e.classList.contains("resizable-image"),replacement:e=>e}),q.addRule("inlineMath",{filter:e=>{if("SPAN"!==e.nodeName)return!1;let t=e.getAttribute("data-type");return"inline-math"===t||"inlineMath"===t},replacement:(e,t)=>{let n=t.getAttribute("data-latex")??"";return`$${n}$`}}),q.addRule("alignedBlock",{filter:e=>{if(!["P","H1","H2","H3","H4","H5","H6"].includes(e.nodeName))return!1;let t=e.getAttribute("style")??"";return/text-align:\s*(center|right|justify)/.test(t)},replacement:(e,t)=>{let n=t.nodeName.toLowerCase(),r=t.getAttribute("style")??"";return`
95
95
  <${n} style="${r}">${e}</${n}>
96
- `}}),e.s(["htmlToMarkdown",0,function(e){return q.turndown(e)}],660885);let J=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/;function G(e){let t=e.trim();if(""===t)return"";if("true"===t)return!0;if("false"===t)return!1;if("null"===t||"~"===t)return null;if(/^-?\d+$/.test(t)||/^-?\d*\.\d+$/.test(t))return Number(t);if(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t.startsWith("[")&&t.endsWith("]")){let e=t.slice(1,-1).trim();return""===e?[]:e.split(",").map(e=>G(e))}return t}e.s(["parseFrontmatter",0,function(e){let t=J.exec(e);if(!t)return{data:{},body:e};let n=t[1],r=e.slice(t[0].length),i=n.split(/\r?\n/).find(e=>""!==e.trim())??"";if(/^\s*(#{1,6}\s|<|>|-\s|\*\s|\d+\.\s)/.test(i))return{data:{},body:e};let o={},s=n.split(/\r?\n/),a=0;for(;a<s.length;){let e=s[a];if(!e||/^\s*#/.test(e)){a+=1;continue}let t=/^([A-Za-z_][\w-]*)\s*:\s*(.*)$/.exec(e);if(!t){a+=1;continue}let n=t[1],r=t[2];if(""===r.trim()){let e=[],t=a+1;for(;t<s.length&&/^\s+-\s+/.test(s[t]);){let n=/^\s+-\s+(.*)$/.exec(s[t]);n&&e.push(G(n[1])),t+=1}if(e.length>0){o[n]=e,a=t;continue}o[n]="",a+=1;continue}o[n]=G(r),a+=1}return 0===Object.keys(o).length?{data:{},body:e}:{data:o,body:r}}],490275);var X=e.i(101685);let Z=e=>{let t,n=new Set,r=(e,r)=>{let i="function"==typeof e?e(t):e;if(!Object.is(i,t)){let e=t;t=(null!=r?r:"object"!=typeof i||null===i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,o={setState:r,getState:i,getInitialState:()=>s,subscribe:e=>(n.add(e),()=>n.delete(e))},s=t=e(r,i,o);return o},Y=e=>{let t=e?Z(e):Z,n=e=>(function(e,t=e=>e){let n=X.default.useSyncExternalStore(e.subscribe,X.default.useCallback(()=>t(e.getState()),[e,t]),X.default.useCallback(()=>t(e.getInitialState()),[e,t]));return X.default.useDebugValue(n),n})(t,e);return Object.assign(n,t),n};e.s(["create",0,e=>e?Y(e):Y],534537)},671485,e=>{"use strict";let t=["/api/wiki","/api/assets/","/api/upload/","/api/system/reveal"],n=["/api/agent/admin","/api/agent/register","/api/agents"];function r(){return new URLSearchParams(window.location.search).get("ws")}function i(e){let i=r();if(!i)return e;let o=e.indexOf("?"),s=-1===o?e:e.slice(0,o),a=-1===o?"":e.slice(o+1);if(!function(e){for(let t of n)if(e===t||e.startsWith(t+"/"))return!1;if(e.startsWith("/api/agent/"))return!0;for(let n of t)if(e.startsWith(n))return!0;return!1}(s))return e;let l=new URLSearchParams(a);return l.has("ws")?e:(l.set("ws",i),`${s}?${l.toString()}`)}e.s(["getActiveWorkspaceId",0,r,"withWs",0,i,"wsFetch",0,function(e,t){return fetch(i(e),t)}])},24800,562199,96701,990791,395624,246542,592185,926732,417385,e=>{"use strict";var t=e.i(534537),n=e.i(671485);function r(){return{}}e.s(["authHeaders",0,r],562199);let i=(0,t.create)(e=>({isOpen:!1,open:()=>e({isOpen:!0}),close:()=>e({isOpen:!1}),toggle:()=>e(e=>({isOpen:!e.isOpen})),clearMessages:()=>{},activity:[],connections:[],hasToken:!1,pollIntervalMs:1e4,rateLimit:null,loadActivity:async()=>{let t=localStorage.getItem("wiki-agent-token")??null,i=!!(t&&t.trim());try{let t=await (0,n.wsFetch)("/api/agent/activity?limit=50",{headers:r()});if(!t.ok)return void e({hasToken:i});let o=(await t.json()).events??[],s=function(e){let t=new Date(Date.now()-3e5).toISOString(),n=new Map;for(let r of e){if(r.at<t)continue;let e=n.get(r.by);e?n.set(r.by,{opCount:e.opCount+1,lastSeen:r.at>e.lastSeen?r.at:e.lastSeen}):n.set(r.by,{opCount:1,lastSeen:r.at})}return Array.from(n.entries()).map(([e,t])=>({by:e,...t})).sort((e,t)=>e.lastSeen<t.lastSeen?1:-1)}(o),a=null;try{let e=await (0,n.wsFetch)("/api/agent/settings",{headers:r()});e.ok&&(a=(await e.json()).rateLimit??null)}catch{}e({activity:o,connections:s,hasToken:i,rateLimit:a})}catch{e({hasToken:i})}}}));e.s(["useAIPanelStore",0,i],24800);class o extends Error{status;constructor(e,t){super(e),this.status=t,this.name="FetchPageError"}}async function s(e,t){let r=await (0,n.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(e)}`,{signal:t});if(!r.ok)throw new o(`Failed to fetch page: ${e}`,r.status);let i=await r.json(),s=r.headers.get("X-Wiki-Revision"),a=null!==s?Number(s):null;return{path:e,content:i.content,frontmatter:null,revision:a}}class a extends Error{currentRevision;serverContent;constructor(e,t){super("File was modified externally. Reloaded with latest content."),this.currentRevision=e,this.serverContent=t,this.name="StaleRevisionError"}}async function l(e,t,r){let i={path:e,content:t};null!==r&&(i.baseRevision=r);let o=await (0,n.wsFetch)("/api/wiki/content",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(409===o.status){let r=await o.json(),i=await (0,n.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(e)}`),s=i.ok?(await i.json()).content:t;throw new a(r.currentRevision??0,s)}if(!o.ok)throw Error("Failed to save page");return{revision:(await o.json()).revision??null}}async function c(e,t=""){await l(e,t,null)}let d="kb-page-cache",u=new Map,h=new Map;function p(e){if(u.delete(e.path),u.set(e.path,e),u.size>30){let e=u.keys().next().value;void 0!==e&&u.delete(e)}}function f(e){try{localStorage.setItem(d,JSON.stringify(e))}catch{}}let m="kb-edit-mode",g=null,y=null,b=null,v=(0,t.create)((e,t)=>({currentPath:null,content:"",frontmatter:null,saveStatus:"idle",loadStatus:"idle",isDirty:!1,isLoading:!1,lastSavedAt:null,currentRevision:null,editMode:"suggesting"===localStorage.getItem(m)?"suggesting":"editing",setEditMode:t=>{localStorage.setItem(m,t),e({editMode:t})},loadPage:async n=>{let r,i=t();i.isDirty&&i.currentPath&&i.currentPath!==n&&await t().save(),e({currentPath:n,isLoading:!0,loadStatus:"loading",isDirty:!1,content:"",currentRevision:null});let a=(r=u.get(n))?(u.delete(n),u.set(n,r),r):null,l=a??function(e){try{let t=localStorage.getItem(d);if(!t)return null;let n=JSON.parse(t);if(n.path!==e)return null;return n}catch{return null}}(n);l&&e({content:l.content,frontmatter:l.frontmatter,isLoading:!1,loadStatus:"ok",...a?{currentRevision:a.revision}:{}});let c=h.get(n);if(c)try{let r=await c;if(t().currentPath!==n)return;e({content:r.content,frontmatter:r.frontmatter,isLoading:!1,loadStatus:"ok",currentRevision:r.revision}),f({path:n,content:r.content,frontmatter:r.frontmatter});return}catch{}b?.abort();let m=new AbortController;b=m;try{let r=await s(n,m.signal);if(p(r),t().currentPath!==n)return;e({content:r.content,frontmatter:r.frontmatter,isLoading:!1,loadStatus:"ok",currentRevision:r.revision}),f({path:n,content:r.content,frontmatter:r.frontmatter})}catch(r){if(r instanceof DOMException&&"AbortError"===r.name||t().currentPath!==n)return;r instanceof o&&404===r.status?e({isLoading:!1,loadStatus:"missing",content:""}):e({isLoading:!1,loadStatus:"error"})}},updateContent:n=>{"suggesting"===t().editMode?e({content:n}):(e({content:n,isDirty:!0}),g&&clearTimeout(g),g=setTimeout(()=>{t().save()},500))},updateFrontmatter:n=>{e({frontmatter:{...t().frontmatter,...n},isDirty:!0}),g&&clearTimeout(g),g=setTimeout(()=>{t().save()},500)},save:async()=>{let{currentPath:n,content:r,isDirty:i,currentRevision:o,editMode:s}=t();if(n&&i&&"suggesting"!==s){e({saveStatus:"saving"});try{let i=await l(n,r,o);e({saveStatus:"saved",isDirty:!1,lastSavedAt:Date.now(),currentRevision:i.revision??o}),f({path:n,content:r,frontmatter:t().frontmatter}),p({path:n,content:r,frontmatter:t().frontmatter,revision:i.revision??o}),y&&clearTimeout(y),y=setTimeout(()=>{"saved"===t().saveStatus&&e({saveStatus:"idle"})},2e3)}catch(r){r instanceof a?(e({content:r.serverContent,isDirty:!1,saveStatus:"error",currentRevision:r.currentRevision}),f({path:n,content:r.serverContent,frontmatter:t().frontmatter})):e({saveStatus:"error"})}}},createMissingPage:async n=>{let{currentPath:r}=t();if(!r)return;let i=`# ${n}
96
+ `}}),e.s(["htmlToMarkdown",0,function(e,t){var n;let r=q.turndown(e);return t?(n=r,t?n=(n=n.replace(/\]\((\/api\/assets\/[^)\s]+)\)/g,(e,n)=>`](${J(n,t)})`)).replace(/(src|href)="(\/api\/assets\/[^"]+)"/g,(e,n,r)=>`${n}="${J(r,t)}"`):n):r}],660885);let G=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/;function X(e){let t=e.trim();if(""===t)return"";if("true"===t)return!0;if("false"===t)return!1;if("null"===t||"~"===t)return null;if(/^-?\d+$/.test(t)||/^-?\d*\.\d+$/.test(t))return Number(t);if(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t.startsWith("[")&&t.endsWith("]")){let e=t.slice(1,-1).trim();return""===e?[]:e.split(",").map(e=>X(e))}return t}e.s(["parseFrontmatter",0,function(e){let t=G.exec(e);if(!t)return{data:{},body:e};let n=t[1],r=e.slice(t[0].length),i=n.split(/\r?\n/).find(e=>""!==e.trim())??"";if(/^\s*(#{1,6}\s|<|>|-\s|\*\s|\d+\.\s)/.test(i))return{data:{},body:e};let o={},s=n.split(/\r?\n/),a=0;for(;a<s.length;){let e=s[a];if(!e||/^\s*#/.test(e)){a+=1;continue}let t=/^([A-Za-z_][\w-]*)\s*:\s*(.*)$/.exec(e);if(!t){a+=1;continue}let n=t[1],r=t[2];if(""===r.trim()){let e=[],t=a+1;for(;t<s.length&&/^\s+-\s+/.test(s[t]);){let n=/^\s+-\s+(.*)$/.exec(s[t]);n&&e.push(X(n[1])),t+=1}if(e.length>0){o[n]=e,a=t;continue}o[n]="",a+=1;continue}o[n]=X(r),a+=1}return 0===Object.keys(o).length?{data:{},body:e}:{data:o,body:r}}],490275);var Z=e.i(101685);let Y=e=>{let t,n=new Set,r=(e,r)=>{let i="function"==typeof e?e(t):e;if(!Object.is(i,t)){let e=t;t=(null!=r?r:"object"!=typeof i||null===i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,o={setState:r,getState:i,getInitialState:()=>s,subscribe:e=>(n.add(e),()=>n.delete(e))},s=t=e(r,i,o);return o},Q=e=>{let t=e?Y(e):Y,n=e=>(function(e,t=e=>e){let n=Z.default.useSyncExternalStore(e.subscribe,Z.default.useCallback(()=>t(e.getState()),[e,t]),Z.default.useCallback(()=>t(e.getInitialState()),[e,t]));return Z.default.useDebugValue(n),n})(t,e);return Object.assign(n,t),n},ee=e=>e?Q(e):Q;e.s(["create",0,ee],534537);var et=e.i(671485);function en(){return{}}e.s(["authHeaders",0,en],562199);let er=ee(e=>({isOpen:!1,open:()=>e({isOpen:!0}),close:()=>e({isOpen:!1}),toggle:()=>e(e=>({isOpen:!e.isOpen})),clearMessages:()=>{},activity:[],connections:[],hasToken:!1,pollIntervalMs:1e4,rateLimit:null,loadActivity:async()=>{let t=localStorage.getItem("wiki-agent-token")??null,n=!!(t&&t.trim());try{let t=await (0,et.wsFetch)("/api/agent/activity?limit=50",{headers:en()});if(!t.ok)return void e({hasToken:n});let r=(await t.json()).events??[],i=function(e){let t=new Date(Date.now()-3e5).toISOString(),n=new Map;for(let r of e){if(r.at<t)continue;let e=n.get(r.by);e?n.set(r.by,{opCount:e.opCount+1,lastSeen:r.at>e.lastSeen?r.at:e.lastSeen}):n.set(r.by,{opCount:1,lastSeen:r.at})}return Array.from(n.entries()).map(([e,t])=>({by:e,...t})).sort((e,t)=>e.lastSeen<t.lastSeen?1:-1)}(r),o=null;try{let e=await (0,et.wsFetch)("/api/agent/settings",{headers:en()});e.ok&&(o=(await e.json()).rateLimit??null)}catch{}e({activity:r,connections:i,hasToken:n,rateLimit:o})}catch{e({hasToken:n})}}}));e.s(["useAIPanelStore",0,er],24800);class ei extends Error{status;constructor(e,t){super(e),this.status=t,this.name="FetchPageError"}}async function eo(e,t){let n=await (0,et.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(e)}`,{signal:t});if(!n.ok)throw new ei(`Failed to fetch page: ${e}`,n.status);let r=await n.json(),i=n.headers.get("X-Wiki-Revision"),o=null!==i?Number(i):null;return{path:e,content:r.content,frontmatter:null,revision:o}}class es extends Error{currentRevision;serverContent;constructor(e,t){super("File was modified externally. Reloaded with latest content."),this.currentRevision=e,this.serverContent=t,this.name="StaleRevisionError"}}async function ea(e,t,n){let r={path:e,content:t};null!==n&&(r.baseRevision=n);let i=await (0,et.wsFetch)("/api/wiki/content",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(409===i.status){let n=await i.json(),r=await (0,et.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(e)}`),o=r.ok?(await r.json()).content:t;throw new es(n.currentRevision??0,o)}if(!i.ok)throw Error("Failed to save page");return{revision:(await i.json()).revision??null}}async function el(e,t=""){await ea(e,t,null)}let ec="kb-page-cache",ed=new Map,eu=new Map;function eh(e){if(ed.delete(e.path),ed.set(e.path,e),ed.size>30){let e=ed.keys().next().value;void 0!==e&&ed.delete(e)}}function ep(e){try{localStorage.setItem(ec,JSON.stringify(e))}catch{}}let ef="kb-edit-mode",em=null,eg=null,ey=null,eb=ee((e,t)=>({currentPath:null,content:"",frontmatter:null,saveStatus:"idle",loadStatus:"idle",isDirty:!1,isLoading:!1,lastSavedAt:null,currentRevision:null,editMode:"suggesting"===localStorage.getItem(ef)?"suggesting":"editing",setEditMode:t=>{localStorage.setItem(ef,t),e({editMode:t})},loadPage:async n=>{let r,i=t();i.isDirty&&i.currentPath&&i.currentPath!==n&&await t().save(),e({currentPath:n,isLoading:!0,loadStatus:"loading",isDirty:!1,content:"",currentRevision:null});let o=(r=ed.get(n))?(ed.delete(n),ed.set(n,r),r):null,s=o??function(e){try{let t=localStorage.getItem(ec);if(!t)return null;let n=JSON.parse(t);if(n.path!==e)return null;return n}catch{return null}}(n);s&&e({content:s.content,frontmatter:s.frontmatter,isLoading:!1,loadStatus:"ok",...o?{currentRevision:o.revision}:{}});let a=eu.get(n);if(a)try{let r=await a;if(t().currentPath!==n)return;e({content:r.content,frontmatter:r.frontmatter,isLoading:!1,loadStatus:"ok",currentRevision:r.revision}),ep({path:n,content:r.content,frontmatter:r.frontmatter});return}catch{}ey?.abort();let l=new AbortController;ey=l;try{let r=await eo(n,l.signal);if(eh(r),t().currentPath!==n)return;e({content:r.content,frontmatter:r.frontmatter,isLoading:!1,loadStatus:"ok",currentRevision:r.revision}),ep({path:n,content:r.content,frontmatter:r.frontmatter})}catch(r){if(r instanceof DOMException&&"AbortError"===r.name||t().currentPath!==n)return;r instanceof ei&&404===r.status?e({isLoading:!1,loadStatus:"missing",content:""}):e({isLoading:!1,loadStatus:"error"})}},updateContent:n=>{"suggesting"===t().editMode?e({content:n}):(e({content:n,isDirty:!0}),em&&clearTimeout(em),em=setTimeout(()=>{t().save()},500))},updateFrontmatter:n=>{e({frontmatter:{...t().frontmatter,...n},isDirty:!0}),em&&clearTimeout(em),em=setTimeout(()=>{t().save()},500)},save:async()=>{let{currentPath:n,content:r,isDirty:i,currentRevision:o,editMode:s}=t();if(n&&i&&"suggesting"!==s){e({saveStatus:"saving"});try{let i=await ea(n,r,o);e({saveStatus:"saved",isDirty:!1,lastSavedAt:Date.now(),currentRevision:i.revision??o}),ep({path:n,content:r,frontmatter:t().frontmatter}),eh({path:n,content:r,frontmatter:t().frontmatter,revision:i.revision??o}),eg&&clearTimeout(eg),eg=setTimeout(()=>{"saved"===t().saveStatus&&e({saveStatus:"idle"})},2e3)}catch(r){r instanceof es?(e({content:r.serverContent,isDirty:!1,saveStatus:"error",currentRevision:r.currentRevision}),ep({path:n,content:r.serverContent,frontmatter:t().frontmatter})):e({saveStatus:"error"})}}},createMissingPage:async n=>{let{currentPath:r}=t();if(!r)return;let i=`# ${n}
97
97
 
98
- `;try{await c(`${r}/index.md`,i),e({content:i,isDirty:!1,loadStatus:"ok"}),f({path:r,content:i,frontmatter:null})}catch{}},clear:()=>{g&&clearTimeout(g),y&&clearTimeout(y),e({currentPath:null,content:"",frontmatter:null,saveStatus:"idle",loadStatus:"idle",isDirty:!1,isLoading:!1,lastSavedAt:null,currentRevision:null})},syncRevision:t=>{e({currentRevision:t})}}));e.s(["prefetchPage",0,function(e){if(u.has(e)||h.has(e))return;let t=s(e).then(e=>(p(e),e)).finally(()=>{h.delete(e)});h.set(e,t),t.catch(()=>{})},"useEditorStore",0,v],96701);let w=(0,t.create)((e,t)=>({nodes:[],selectedPath:null,expandedPaths:new Set,loadTree:async()=>{},selectPage:t=>{e({selectedPath:t})},expandPath:n=>{let{expandedPaths:r}=t();if(!r.has(n)){let t=new Set(r);t.add(n),e({expandedPaths:t})}},focusPath:n=>{let{expandedPaths:r}=t(),i=new Set(r),o=n.split("/");for(let e=1;e<o.length;e++)i.add(o.slice(0,e).join("/"));e({selectedPath:n,expandedPaths:i})}}));e.s(["useTreeStore",0,w],990791);let x="wiki-view-width",k="wiki-view-align",S=["narrow","normal","wide"],C=(0,t.create)(e=>{let t,n;return{width:"narrow"===(t=localStorage.getItem(x))||"normal"===t||"wide"===t?t:"normal",align:"center"===(n=localStorage.getItem(k))||"left"===n?n:"center",setWidth:t=>{localStorage.setItem(x,t),e({width:t})},setAlign:t=>{localStorage.setItem(k,t),e({align:t})},cycle:()=>e(e=>{let t=S.indexOf(e.width),n=S[(t+1)%S.length];return localStorage.setItem(x,n),{width:n}})}});e.s(["VIEW_ALIGN_CLASS",0,{center:"mx-auto",left:"mr-auto"},"VIEW_ALIGN_LABEL",0,{center:"Center",left:"Left"},"VIEW_ALIGN_ML",0,{center:"auto",left:"0"},"VIEW_ALIGN_ORDER",0,["center","left"],"VIEW_WIDTH_CLASS",0,{narrow:"max-w-2xl",normal:"max-w-5xl",wide:"max-w-[90rem]"},"VIEW_WIDTH_CSS",0,{narrow:"42rem",normal:"64rem",wide:"90rem"},"VIEW_WIDTH_LABEL",0,{narrow:"Narrow",normal:"Normal",wide:"Wide"},"VIEW_WIDTH_ORDER",0,S,"useViewWidthStore",0,C],395624);let E=(0,t.create)((e,t)=>({slugs:new Set,slugDir:new Map,loadedAt:null,loading:!1,load:async()=>{let{loadedAt:r,loading:i}=t();if(!i&&!(null!==r&&Date.now()-r<1e4)){e({loading:!0});try{let t=await (0,n.wsFetch)("/api/wiki/slugs");if(!t.ok)throw Error("Failed to fetch wiki slugs");let r=await t.json(),i=new Set,o=new Map;for(let e of["entities","concepts","comparisons","root"])for(let t of r[e])i.add(t),o.has(t)||o.set(t,e);e({slugs:i,slugDir:o,loadedAt:Date.now(),loading:!1})}catch{e({loading:!1})}}},has:e=>t().slugs.has(e),getDir:e=>t().slugDir.get(e)??null,invalidate(){e({loadedAt:null})}}));function M(){return{sidecar:null,snapshotRevision:0,lastEventId:0,snapshotBlocks:[]}}e.s(["useWikiSlugsStore",0,E],246542);let N=(0,t.create)((e,t)=>({byPath:{},loadSidecar:async t=>{let i=encodeURIComponent(t).replace(/%2F/g,"/");try{let o=await (0,n.wsFetch)(`/api/agent/sidecar/${i}`,{headers:r()});if(!o.ok)return;let s=await o.json();e(e=>({byPath:{...e.byPath,[t]:{...e.byPath[t]??M(),sidecar:s,snapshotRevision:s.revision,lastEventId:s.nextEventId-1}}}))}catch{}},loadSnapshot:async t=>{let i=encodeURIComponent(t).replace(/%2F/g,"/");try{let o=await (0,n.wsFetch)(`/api/agent/files/${i}`,{headers:r()});if(!o.ok)return;let s=await o.json();e(e=>({byPath:{...e.byPath,[t]:{...e.byPath[t]??M(),snapshotBlocks:s.blocks,snapshotRevision:s.revision}}}));let a=v.getState();a.currentPath===t&&a.syncRevision(s.revision)}catch{}},pollEvents:async e=>{let i=t().byPath[e]??M(),o=encodeURIComponent(e).replace(/%2F/g,"/");try{let s=await (0,n.wsFetch)(`/api/agent/events/${o}?after=${i.lastEventId}`,{headers:r()});if(!s.ok)return;for(let n of(await s.json()).events)t().applyEvent(e,n)}catch{}},applyEvent:(t,n)=>{e(e=>{let r=e.byPath[t]??M();return{byPath:{...e.byPath,[t]:{...r,lastEventId:Math.max(r.lastEventId,n.id)}}}})},reset:t=>{e(e=>{let n={...e.byPath};return delete n[t],{byPath:n}})}}));async function A(e,t,n){let i=encodeURIComponent(e).replace(/%2F/g,"/"),o=await fetch(`/api/agent/files/${i}`,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":crypto.randomUUID(),...r()},body:JSON.stringify({baseRevision:t,by:"human",ops:[n]})});if(409===o.status){let e=await o.json();return"STALE_REVISION"===e.code&&e.snapshot?.revision!==void 0?{ok:!1,stale:!0,newRevision:e.snapshot.revision}:{ok:!1,stale:!1}}return{ok:o.ok,stale:!1}}async function T(e){let{path:t,ref:n,kind:r,markdown:i,basisDetail:o,getRevision:s,refresh:a}=e,l={type:"suggestion.add",ref:n,kind:r,basis:"suggested"};"delete"!==r&&(l.markdown=i??""),o&&(l.basisDetail=o);let c=await A(t,s(),l);return!c.ok&&c.stale&&void 0!==c.newRevision&&(await a(),c=await A(t,c.newRevision,l)),c.ok}e.s(["useProofStore",0,N],592185),e.s(["captureSuggestion",0,T],926732);var R=e.i(187014);e.s(["showError",0,function(e,t){R.toast.error(e,t)},"showSuccess",0,function(e,t){R.toast.success(e,t)}],417385)},153840,580330,792934,85741,464675,419943,674155,425275,891734,187080,253190,73313,736586,132807,412473,e=>{"use strict";var t=e.i(343603),n=e.i(278928),r=e.i(111092);e.i(150663);var i=e.i(608926),o=class{constructor({editor:e,element:n,view:r,pluginKey:i="bubbleMenu",updateDelay:o=250,resizeDelay:s=60,shouldShow:a,appendTo:l,getReferencedVirtualElement:c,options:d}){var u;this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:e,state:n,from:r,to:i})=>{let{doc:o,selection:s}=n,{empty:a}=s,l=!o.textBetween(r,i).length&&(0,t.isTextSelection)(n.selection),c=this.element.contains(document.activeElement);return!!(e.hasFocus()||c)&&!a&&!l&&!!this.editor.isEditable},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{var t;if(this.editor.isDestroyed)return void this.destroy();if(this.preventHide){this.preventHide=!1;return}(null==e?void 0:e.relatedTarget)&&(null==(t=this.element.parentNode)?void 0:t.contains(e.relatedTarget))||(null==e?void 0:e.relatedTarget)!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(e,t)=>{let n=!(null==t?void 0:t.selection.eq(e.state.selection)),r=!(null==t?void 0:t.doc.eq(e.state.doc));(n||r)&&(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(e,n,r,t)},this.updateDelay))},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;!i&&(t||n)&&(this.getShouldShow(r)?(this.show(),this.updatePosition()):this.hide())},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);"updatePosition"===t?this.updatePosition():t&&"object"==typeof t&&"updateOptions"===t.type?this.updateOptions(t.options):"hide"===t?this.hide():"show"===t&&(this.updatePosition(),this.show())},this.editor=e,this.element=n,this.view=r,this.pluginKey=i,this.updateDelay=o,this.resizeDelay=s,this.appendTo=l,this.scrollTarget=null!=(u=null==d?void 0:d.scrollTarget)?u:window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...d},this.element.tabIndex=0,a&&(this.shouldShow=a),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(r,r.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push((0,n.flip)("boolean"!=typeof this.floatingUIOptions.flip?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push((0,n.shift)("boolean"!=typeof this.floatingUIOptions.shift?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push((0,n.offset)("boolean"!=typeof this.floatingUIOptions.offset?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push((0,n.arrow)(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push((0,n.size)("boolean"!=typeof this.floatingUIOptions.size?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push((0,n.autoPlacement)("boolean"!=typeof this.floatingUIOptions.autoPlacement?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push((0,n.hide)("boolean"!=typeof this.floatingUIOptions.hide?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push((0,n.inline)("boolean"!=typeof this.floatingUIOptions.inline?this.floatingUIOptions.inline:void 0)),e}get virtualElement(){var e,n,o,s,a;let{selection:l}=this.editor.state,c=null==(e=this.getReferencedVirtualElement)?void 0:e.call(this);if(c)return c;if(!(null==(o=null==(n=this.view)?void 0:n.dom)?void 0:o.parentNode))return;let d=(0,t.posToDOMRect)(this.view,l.from,l.to),u={getBoundingClientRect:()=>d,getClientRects:()=>[d]};if(l instanceof r.NodeSelection){let e=this.view.nodeDOM(l.from),t=e.dataset.nodeViewWrapper?e:e.querySelector("[data-node-view-wrapper]");t&&(e=t),e&&(u={getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>[e.getBoundingClientRect()]})}if(l instanceof i.CellSelection){let e,t,n,{$anchorCell:r,$headCell:i}=l,o=r?r.pos:i.pos,c=i?i.pos:r.pos,d=this.view.nodeDOM(o),h=this.view.nodeDOM(c);if(!d||!h)return;let p=d===h?d.getBoundingClientRect():(s=d.getBoundingClientRect(),a=h.getBoundingClientRect(),e=Math.min(s.top,a.top),t=Math.max(s.bottom,a.bottom),n=Math.min(s.left,a.left),new DOMRect(n,e,Math.max(s.right,a.right)-n,t-e));u={getBoundingClientRect:()=>p,getClientRects:()=>[p]}}return u}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&(0,n.computePosition)(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{var i,o;if(this.isVisible&&!this.editor.isDestroyed&&this.element.isConnected){if((null==(i=r.hide)?void 0:i.referenceHidden)||(null==(o=r.hide)?void 0:o.escaped)){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(e,t){let{state:n}=e,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r)return void this.handleDebouncedUpdate(e,t);let i=!(null==t?void 0:t.selection.eq(e.state.selection)),o=!(null==t?void 0:t.doc.eq(e.state.doc));this.updateHandler(e,i,o,t)}getShouldShow(e){var t;let{state:n}=this.view,{selection:r}=n,{ranges:i}=r,o=Math.min(...i.map(e=>e.$from.pos)),s=Math.max(...i.map(e=>e.$to.pos));return(null==(t=this.shouldShow)?void 0:t.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:e,from:o,to:s}))||!1}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";let t="function"==typeof this.appendTo?this.appendTo():this.appendTo;null==(e=null!=t?t:this.view.dom.parentElement)||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(e){var t;if(void 0!==e.updateDelay&&(this.updateDelay=e.updateDelay),void 0!==e.resizeDelay&&(this.resizeDelay=e.resizeDelay),void 0!==e.appendTo&&(this.appendTo=e.appendTo),void 0!==e.getReferencedVirtualElement&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),void 0!==e.shouldShow&&e.shouldShow&&(this.shouldShow=e.shouldShow),void 0!==e.options){let n=null!=(t=e.options.scrollTarget)?t:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},s=e=>new r.Plugin({key:"string"==typeof e.pluginKey?new r.PluginKey(e.pluginKey):e.pluginKey,view:t=>new o({view:t,...e})});t.Extension.create({name:"bubbleMenu",addOptions:()=>({element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}),addProseMirrorPlugins(){return this.options.element?[s({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var a=e.i(885047),l=e.i(101685),c=e.i(380560),d=class{constructor({editor:e,element:t,view:n,pluginKey:r="floatingMenu",updateDelay:i=250,resizeDelay:o=60,options:s,appendTo:a,shouldShow:l}){var c;this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:e,state:t})=>{let{selection:n}=t,{$anchor:r,empty:i}=n,o=1===r.depth,s=r.parent.isTextblock&&!r.parent.type.spec.code&&!r.parent.textContent&&0===r.parent.childCount&&!this.getTextContent(r.parent);return!!e.hasFocus()&&!!i&&!!o&&!!s&&!!this.editor.isEditable},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;!i&&(t||n)&&(this.getShouldShow(r)?(this.updatePosition(),this.show()):this.hide())},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{var t;if(this.preventHide){this.preventHide=!1;return}(null==e?void 0:e.relatedTarget)&&(null==(t=this.element.parentNode)?void 0:t.contains(e.relatedTarget))||(null==e?void 0:e.relatedTarget)!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);"updatePosition"===t?this.updatePosition():t&&"object"==typeof t&&"updateOptions"===t.type?this.updateOptions(t.options):"hide"===t?this.hide():"show"===t&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=o,this.appendTo=a,this.scrollTarget=null!=(c=null==s?void 0:s.scrollTarget)?c:window,this.floatingUIOptions={...this.floatingUIOptions,...s},this.element.tabIndex=0,l&&(this.shouldShow=l),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(e){return(0,t.getText)(e,{textSerializers:(0,t.getTextSerializersFromSchema)(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push((0,n.flip)("boolean"!=typeof this.floatingUIOptions.flip?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push((0,n.shift)("boolean"!=typeof this.floatingUIOptions.shift?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push((0,n.offset)("boolean"!=typeof this.floatingUIOptions.offset?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push((0,n.arrow)(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push((0,n.size)("boolean"!=typeof this.floatingUIOptions.size?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push((0,n.autoPlacement)("boolean"!=typeof this.floatingUIOptions.autoPlacement?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push((0,n.hide)("boolean"!=typeof this.floatingUIOptions.hide?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push((0,n.inline)("boolean"!=typeof this.floatingUIOptions.inline?this.floatingUIOptions.inline:void 0)),e}getShouldShow(e){var t;let{state:n}=this.view,{selection:r}=n,{ranges:i}=r,o=Math.min(...i.map(e=>e.$from.pos)),s=Math.max(...i.map(e=>e.$to.pos));return null==(t=this.shouldShow)?void 0:t.call(this,{editor:this.editor,view:this.view,state:n,oldState:e,from:o,to:s})}updateOptions(e){var t;if(void 0!==e.updateDelay&&(this.updateDelay=e.updateDelay),void 0!==e.resizeDelay&&(this.resizeDelay=e.resizeDelay),void 0!==e.appendTo&&(this.appendTo=e.appendTo),void 0!==e.shouldShow&&e.shouldShow&&(this.shouldShow=e.shouldShow),void 0!==e.options){let n=null!=(t=e.options.scrollTarget)?t:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){var e,r;if(!(null==(r=null==(e=this.view)?void 0:e.dom)?void 0:r.parentNode))return;let{selection:i}=this.editor.state,o=(0,t.posToDOMRect)(this.view,i.from,i.to);(0,n.computePosition)({getBoundingClientRect:()=>o,getClientRects:()=>[o]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{var i,o;if((null==(i=r.hide)?void 0:i.referenceHidden)||(null==(o=r.hide)?void 0:o.escaped)){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){let n=!(null==t?void 0:t.selection.eq(e.state.selection)),r=!(null==t?void 0:t.doc.eq(e.state.doc));this.updateHandler(e,n,r,t)}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";let t="function"==typeof this.appendTo?this.appendTo():this.appendTo;null==(e=null!=t?t:this.view.dom.parentElement)||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},u=e=>new r.Plugin({key:"string"==typeof e.pluginKey?new r.PluginKey(e.pluginKey):e.pluginKey,view:t=>new d({view:t,...e})});function h(e,t){return null!=e?e:new r.PluginKey(t)}t.Extension.create({name:"floatingMenu",addOptions:()=>({element:null,options:{},pluginKey:"floatingMenu",updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}),addCommands(){return{updateFloatingMenuPosition:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(this.options.pluginKey,"updatePosition"),!0)}},addProseMirrorPlugins(){return this.options.element?[u({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});var p="u">typeof window?l.useLayoutEffect:l.useEffect,f=new Set(["left","opacity","position","top","visibility","width"]),m=new Set(["animationIterationCount","aspectRatio","borderImageOutset","borderImageSlice","borderImageWidth","columnCount","columns","fillOpacity","flex","flexGrow","flexShrink","fontWeight","gridArea","gridColumn","gridColumnEnd","gridColumnStart","gridRow","gridRowEnd","gridRowStart","lineClamp","lineHeight","opacity","order","orphans","scale","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth","tabSize","widows","zIndex","zoom"]),g=new Set(["children","className","style"]),y=new Set(["tabIndex"]),b=new Set(["accessKey","autoCapitalize","contentEditable","contextMenu","dir","draggable","enterKeyHint","hidden","id","lang","nonce","role","slot","spellCheck","tabIndex","title","translate"]),v={Blur:"focusout",DoubleClick:"dblclick",Focus:"focusin",MouseEnter:"mouseenter",MouseLeave:"mouseleave"};function w(e,t){return/^on[A-Z]/.test(e)&&"function"==typeof t}function x(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function k(e,t,n){if("tabIndex"===t){e.tabIndex=Number(n);return}e[t]=n}function S(e,t){let n=(0,l.useRef)({}),r=(0,l.useRef)([]);p(()=>{var i,o,s;let a,l,c,d=n.current;return!function(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute("class")}}(e,d.className,t.className),i=d.style,o=t.style,a=null!=i?i:{},l=null!=o?o:{},new Set([...Object.keys(a),...Object.keys(l)]).forEach(t=>{let n=a[t],r=l[t];if(n!==r){if(null==r)return void(!f.has(t)&&e.style.removeProperty(x(t)));f.has(t)||e.style.setProperty(x(t),"number"!=typeof r||0===r||t.startsWith("--")||m.has(t)?String(r):`${r}px`)}}),new Set([...Object.keys(d),...Object.keys(t)]).forEach(n=>{if(g.has(n)||!(n.startsWith("aria-")||n.startsWith("data-")||b.has(n))||w(n,d[n])||w(n,t[n]))return;let r=d[n],i=t[n];if(r===i)return;let o=(n.startsWith("aria-")||n.startsWith("data-"),n);if(null==i||!1===i){y.has(n)&&function(e,t){if("tabIndex"===t)return e.removeAttribute("tabindex");let n=e[t];if("boolean"==typeof n){e[t]=!1;return}if("number"==typeof n){e[t]=0;return}e[t]=""}(e,n),e.removeAttribute(o);return}if(!0===i){y.has(n)&&k(e,n,!0),e.setAttribute(o,"");return}y.has(n)?k(e,n,i):e.setAttribute(o,String(i))}),s=r.current,s.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)}),c=[],Object.entries(t).forEach(([t,n])=>{var r;let i,o;if(!w(t,n))return;let{eventName:s,options:a}={eventName:null!=(r=v[o=((i=t.endsWith("Capture"))?t.slice(0,-7):t).slice(2)])?r:o.toLowerCase(),options:i?{capture:!0}:void 0},l=t=>{let r,i,o;n((r=t.defaultPrevented,i=!1,Object.defineProperties(o=Object.create(t),{nativeEvent:{value:t},currentTarget:{value:e},target:{value:t.target},persist:{value:()=>void 0},isDefaultPrevented:{value:()=>r},isPropagationStopped:{value:()=>i},preventDefault:{value:()=>{r=!0,t.preventDefault()}},stopPropagation:{value:()=>{i=!0,t.stopPropagation()}}}),o))};e.addEventListener(s,l,a),c.push({eventName:s,listener:l,options:a})}),r.current=c,n.current=t,()=>{r.current.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)}),r.current=[]}},[e,t])}var C=l.default.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:o=null,getReferencedVirtualElement:d,options:u,children:p,...f},m)=>{let g=(0,l.useRef)(document.createElement("div")),y=(0,l.useRef)(h(e,"bubbleMenu")).current;S(g.current,f),"function"==typeof m?m(g.current):m&&(m.current=g.current);let{editor:b}=(0,a.useCurrentEditor)(),v=t||b,w={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:y,shouldShow:o,getReferencedVirtualElement:d,options:u},x=(0,l.useRef)(w);x.current=w;let[k,C]=(0,l.useState)(!1),E=(0,l.useRef)(!0);return(0,l.useEffect)(()=>{if(null==v?void 0:v.isDestroyed)return;if(!v)return void console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");let e=g.current;e.style.visibility="hidden",e.style.position="absolute";let t=s({...x.current,editor:v,element:e});v.registerPlugin(t);let n=x.current.pluginKey;return E.current=!0,C(!0),()=>{C(!1),v.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[v]),(0,l.useEffect)(()=>{if(k&&v&&!v.isDestroyed){if(E.current){E.current=!1;return}v.view.dispatch(v.state.tr.setMeta(y,{type:"updateOptions",options:x.current}))}},[k,v,n,r,o,u,i,d,y]),(0,c.createPortal)(p,g.current)});l.default.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:o=null,options:s,children:d,...p},f)=>{let m=(0,l.useRef)(document.createElement("div")),g=(0,l.useRef)(h(e,"floatingMenu")).current;S(m.current,p),"function"==typeof f?f(m.current):f&&(f.current=m.current);let{editor:y}=(0,a.useCurrentEditor)(),b=t||y,v={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:g,shouldShow:o,options:s},w=(0,l.useRef)(v);w.current=v;let[x,k]=(0,l.useState)(!1),C=(0,l.useRef)(!0);return(0,l.useEffect)(()=>{if(null==b?void 0:b.isDestroyed)return;if(!b)return void console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");let e=m.current;e.style.visibility="hidden",e.style.position="absolute";let t=u({...w.current,editor:b,element:e});b.registerPlugin(t);let n=w.current.pluginKey;return C.current=!0,k(!0),()=>{k(!1),b.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[b]),(0,l.useEffect)(()=>{if(x&&b&&!b.isDestroyed){if(C.current){C.current=!1;return}b.view.dispatch(b.state.tr.setMeta(g,{type:"updateOptions",options:w.current}))}},[x,b,n,r,o,s,i,g]),(0,c.createPortal)(d,m.current)}),e.s(["BubbleMenu",0,C],153840);var E=e.i(605993);let M=(0,E.default)("align-center",[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);e.s(["AlignCenter",0,M],580330);let N=(0,E.default)("align-justify",[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);e.s(["AlignJustify",0,N],792934);let A=(0,E.default)("align-left",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);e.s(["AlignLeft",0,A],85741);let T=(0,E.default)("align-right",[["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 18H7",key:"1ygte8"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);e.s(["AlignRight",0,T],464675);let R=(0,E.default)("bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);e.s(["Bold",0,R],419943);let O=(0,E.default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]);e.s(["Code",0,O],674155);let D=(0,E.default)("italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);e.s(["Italic",0,D],425275);let j=(0,E.default)("message-circle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);e.s(["MessageCircle",0,j],891734);let I=(0,E.default)("message-square-plus",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);e.s(["MessageSquarePlus",0,I],187080);let P=(0,E.default)("strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);e.s(["Strikethrough",0,P],253190);let L=(0,E.default)("subscript",[["path",{d:"m4 5 8 8",key:"1eunvl"}],["path",{d:"m12 5-8 8",key:"1ah0jp"}],["path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07",key:"e8ta8j"}]]);e.s(["Subscript",0,L],73313);let z=(0,E.default)("superscript",[["path",{d:"m4 19 8-8",key:"hr47gm"}],["path",{d:"m12 19-8-8",key:"1dhhmo"}],["path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06",key:"1dfcux"}]]);e.s(["Superscript",0,z],736586);let _=(0,E.default)("underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]);e.s(["Underline",0,_],132807);let $=(0,E.default)("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);e.s(["ExternalLink",0,$],412473)},920978,e=>{"use strict";let t=(0,e.i(605993).default)("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);e.s(["Trash2",0,t],920978)},582612,933850,987027,307154,148623,395330,398441,977112,e=>{"use strict";var t=e.i(44501),n=e.i(153840),r=e.i(580330),i=e.i(792934),o=e.i(85741),s=e.i(464675),a=e.i(419943),l=e.i(674155),c=e.i(425275),d=e.i(702166),u=e.i(891734),h=e.i(187080),p=e.i(253190),f=e.i(73313),m=e.i(736586),g=e.i(132807),y=e.i(101685),b=e.i(975157),v=e.i(412473),w=e.i(920978);function x({anchor:e,initialUrl:n="",onCancel:r,onApply:i,onRemove:o}){let[s,a]=(0,y.useState)(n);(0,y.useEffect)(()=>{let e=e=>{"Escape"===e.key&&r()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r]);let l=()=>{let e=s.trim();e?i(e):r()};return(0,t.jsxs)("div",{className:"absolute z-50 w-[340px] bg-popover border border-border rounded-lg shadow-xl overflow-hidden",style:{top:e.top,left:e.left},onMouseDown:e=>e.stopPropagation(),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-[12px] font-medium",children:[(0,t.jsx)(d.Link,{className:"w-3.5 h-3.5"}),n?"Edit link":"Add link"]}),(0,t.jsx)("button",{type:"button",onClick:r,className:"text-[11px] text-muted-foreground hover:text-foreground",children:"Cancel"})]}),(0,t.jsxs)("div",{className:"p-3 space-y-2",children:[(0,t.jsx)("input",{type:"url",autoFocus:!0,value:s,placeholder:"https://example.com",onChange:e=>a(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),l())},className:"w-full bg-background border border-border rounded-md px-2.5 py-1.5 text-[12px] focus:outline-none focus:ring-2 focus:ring-primary/30"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:l,disabled:!s.trim(),className:"flex-1 py-1.5 text-[12px] rounded-md bg-primary text-primary-foreground disabled:opacity-50 hover:bg-primary/90",children:n?"Update":"Add link"}),n&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("a",{href:n,target:"_blank",rel:"noreferrer noopener",className:"p-1.5 rounded-md border border-border hover:bg-accent text-muted-foreground hover:text-foreground",title:"Open link",children:(0,t.jsx)(v.ExternalLink,{className:"w-3.5 h-3.5"})}),o&&(0,t.jsx)("button",{type:"button",onClick:o,className:"p-1.5 rounded-md border border-border hover:bg-accent text-destructive",title:"Remove link",children:(0,t.jsx)(w.Trash2,{className:"w-3.5 h-3.5"})})]})]})]})]})}e.s(["LinkPopover",0,x],933850),e.s(["EditorBubbleMenu",0,function({editor:e,onSuggestEdit:v,onComment:w,readOnly:k}){let[S,C]=(0,y.useState)(null);if((0,y.useEffect)(()=>{if(!S)return;let e=e=>{let t=e.target;t?.closest("[data-bubble-popover='true']")||C(null)},t=window.setTimeout(()=>window.addEventListener("mousedown",e),10);return()=>{window.clearTimeout(t),window.removeEventListener("mousedown",e)}},[S]),!e)return null;let E=e=>(0,b.cn)("h-9 w-9 sm:h-7 sm:w-7 flex items-center justify-center rounded hover:bg-accent text-foreground/80 transition-colors",e&&"bg-accent text-foreground"),M=()=>{let{from:t,to:n}=e.state.selection;return{from:t,to:n}},N=t=>e.chain().focus().setTextSelection(t).run(),A=e=>t=>{t.preventDefault(),e()},T=t=>{S?.type==="align"&&(N(S.range),e.chain().focus().setTextAlign(t).run(),C(null))};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(n.BubbleMenu,{editor:e,options:{placement:"top",offset:8},className:"flex items-center gap-0.5 px-1 py-1 bg-popover border border-border rounded-sm shadow-lg",children:[!k&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",className:E(e.isActive("bold")),onMouseDown:e=>e.preventDefault(),onClick:A(()=>e.chain().focus().toggleBold().run()),"aria-label":"Bold",children:(0,t.jsx)(a.Bold,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{type:"button",className:E(e.isActive("italic")),onMouseDown:e=>e.preventDefault(),onClick:A(()=>e.chain().focus().toggleItalic().run()),"aria-label":"Italic",children:(0,t.jsx)(c.Italic,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{type:"button",className:E(e.isActive("underline")),onMouseDown:e=>e.preventDefault(),onClick:A(()=>e.chain().focus().toggleUnderline().run()),"aria-label":"Underline",children:(0,t.jsx)(g.Underline,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{type:"button",className:E(e.isActive("strike")),onMouseDown:e=>e.preventDefault(),onClick:A(()=>e.chain().focus().toggleStrike().run()),"aria-label":"Strikethrough",children:(0,t.jsx)(p.Strikethrough,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{type:"button",className:E(e.isActive("code")),onMouseDown:e=>e.preventDefault(),onClick:A(()=>e.chain().focus().toggleCode().run()),"aria-label":"Inline code",children:(0,t.jsx)(l.Code,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("div",{className:"w-px h-5 bg-border mx-1"}),(0,t.jsx)("button",{type:"button",className:E(e.isActive("superscript")),onMouseDown:e=>e.preventDefault(),onClick:A(()=>e.chain().focus().toggleSuperscript().run()),"aria-label":"Superscript",children:(0,t.jsx)(m.Superscript,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{type:"button",className:E(e.isActive("subscript")),onMouseDown:e=>e.preventDefault(),onClick:A(()=>e.chain().focus().toggleSubscript().run()),"aria-label":"Subscript",children:(0,t.jsx)(f.Subscript,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("div",{className:"w-px h-5 bg-border mx-1"}),(0,t.jsx)("button",{type:"button",className:E(e.isActive("link")),onMouseDown:e=>e.preventDefault(),onClick:t=>{t.preventDefault();let n=e.getAttributes("link")?.href??"",r=t.currentTarget.getBoundingClientRect();C({type:"link",range:M(),existing:n,anchor:{top:r.bottom+6,left:r.left}})},"aria-label":"Link",children:(0,t.jsx)(d.Link,{className:"w-3.5 h-3.5"})}),(v||w)&&(0,t.jsx)("div",{className:"w-px h-5 bg-border mx-1"}),w&&(0,t.jsx)("button",{type:"button",className:E(!1),onMouseDown:e=>e.preventDefault(),onClick:e=>{e.preventDefault(),w()},"aria-label":"Comment",title:"Comment",children:(0,t.jsx)(u.MessageCircle,{className:"w-3.5 h-3.5"})}),v&&(0,t.jsx)("button",{type:"button",className:E(!1),onMouseDown:e=>e.preventDefault(),onClick:e=>{e.preventDefault(),v()},"aria-label":"Suggest edit",title:"Suggest edit",children:(0,t.jsx)(h.MessageSquarePlus,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("div",{className:"w-px h-5 bg-border mx-1"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("button",{type:"button",className:E(!1),onMouseDown:e=>e.preventDefault(),onClick:e=>{e.preventDefault(),C({type:"align",range:M()})},"aria-label":"Align",children:(0,t.jsx)(o.AlignLeft,{className:"w-3.5 h-3.5"})}),S?.type==="align"&&(0,t.jsxs)("div",{"data-bubble-popover":"true",className:"absolute top-full left-0 mt-1 z-50 bg-popover border border-border rounded-sm shadow-lg p-1 flex gap-0.5",children:[(0,t.jsx)("button",{type:"button",className:E(e.isActive({textAlign:"left"})),onMouseDown:e=>e.preventDefault(),onClick:()=>T("left"),"aria-label":"Align left",children:(0,t.jsx)(o.AlignLeft,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{type:"button",className:E(e.isActive({textAlign:"center"})),onMouseDown:e=>e.preventDefault(),onClick:()=>T("center"),"aria-label":"Align center",children:(0,t.jsx)(r.AlignCenter,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{type:"button",className:E(e.isActive({textAlign:"right"})),onMouseDown:e=>e.preventDefault(),onClick:()=>T("right"),"aria-label":"Align right",children:(0,t.jsx)(s.AlignRight,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{type:"button",className:E(e.isActive({textAlign:"justify"})),onMouseDown:e=>e.preventDefault(),onClick:()=>T("justify"),"aria-label":"Justify",children:(0,t.jsx)(i.AlignJustify,{className:"w-3.5 h-3.5"})})]})]})]}),k&&w&&(0,t.jsx)("button",{type:"button",className:E(!1),onMouseDown:e=>e.preventDefault(),onClick:e=>{e.preventDefault(),w()},"aria-label":"Comment",title:"Add comment",children:(0,t.jsx)(u.MessageCircle,{className:"w-3.5 h-3.5"})})]}),S?.type==="link"&&(0,t.jsx)("div",{"data-bubble-popover":"true",style:{position:"fixed",top:S.anchor.top,left:S.anchor.left,zIndex:60},children:(0,t.jsx)(x,{anchor:{top:0,left:0},initialUrl:S.existing,onCancel:()=>C(null),onApply:t=>{S?.type==="link"&&(N(S.range),e.chain().focus().extendMarkRange("link").setLink({href:t}).run(),C(null))},onRemove:S.existing?()=>{S?.type==="link"&&(N(S.range),e.chain().focus().unsetLink().run(),C(null))}:void 0})})]})}],582612);var k=e.i(605993);let S=(0,k.default)("square-check-big",[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);e.s(["CheckSquare",0,S],987027);let C=(0,k.default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);e.s(["ChevronLeft",0,C],307154);let E=(0,k.default)("file-code",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);e.s(["FileCode",0,E],148623);let M=(0,k.default)("heading-1",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]]);e.s(["Heading1",0,M],395330);let N=(0,k.default)("heading-2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]]);e.s(["Heading2",0,N],398441);let A=(0,k.default)("heading-3",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]]);e.s(["Heading3",0,A],977112)},375707,e=>{"use strict";let t=(0,e.i(605993).default)("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);e.s(["default",0,t])},799916,853840,864255,991685,67667,733716,703550,492622,579767,978375,750110,772436,374435,e=>{"use strict";var t=e.i(375707);e.s(["ImageIcon",()=>t.default],799916);var n=e.i(605993);let r=(0,n.default)("list",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);e.s(["List",0,r],853840);let i=(0,n.default)("list-ordered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);e.s(["ListOrdered",0,i],864255);let o=(0,n.default)("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);e.s(["Minus",0,o],991685);let s=(0,n.default)("pilcrow-left",[["path",{d:"M14 3v11",key:"mlfb7b"}],["path",{d:"M14 9h-3a3 3 0 0 1 0-6h9",key:"1ulc19"}],["path",{d:"M18 3v11",key:"1phi0r"}],["path",{d:"M22 18H2l4-4",key:"yt65j9"}],["path",{d:"m6 22-4-4",key:"6jgyf5"}]]);e.s(["PilcrowLeft",0,s],67667);let a=(0,n.default)("pilcrow-right",[["path",{d:"M10 3v11",key:"o3l5kj"}],["path",{d:"M10 9H7a1 1 0 0 1 0-6h8",key:"1wb1nc"}],["path",{d:"M14 3v11",key:"mlfb7b"}],["path",{d:"m18 14 4 4H2",key:"4r8io1"}],["path",{d:"m22 18-4 4",key:"1hjjrd"}]]);e.s(["PilcrowRight",0,a],733716);let l=(0,n.default)("quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);e.s(["Quote",0,l],703550);let c=(0,n.default)("redo",[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]]);e.s(["Redo",0,c],492622);let d=(0,n.default)("undo",[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]]);e.s(["Undo",0,d],579767);let u=(0,n.default)("video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);e.s(["Video",0,u],978375);var h=e.i(44501),p=e.i(101685);e.i(380560);var f=e.i(206102),m=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let n=(0,f.createSlot)(`Primitive.${t}`),r=p.forwardRef((e,r)=>{let{asChild:i,...o}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,h.jsx)(i?n:t,{...o,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});e.s(["Primitive",0,m],750110);var g="horizontal",y=["horizontal","vertical"],b=p.forwardRef((e,t)=>{var n;let{decorative:r,orientation:i=g,...o}=e,s=(n=i,y.includes(n))?i:g;return(0,h.jsx)(m.div,{"data-orientation":s,...r?{role:"none"}:{"aria-orientation":"vertical"===s?s:void 0,role:"separator"},...o,ref:t})});b.displayName="Separator";var v=e.i(975157);let w=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>(0,h.jsx)(b,{ref:i,decorative:n,orientation:t,className:(0,v.cn)("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",e),...r}));w.displayName=b.displayName,e.s(["Separator",0,w],772436);let x=(0,n.default)("clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);e.s(["Clipboard",0,x],374435)},924782,e=>{"use strict";let t=(0,e.i(605993).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"}]]);e.s(["Upload",0,t],924782)},454184,(e,t,n)=>{class r{constructor(e){void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function i(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function o(e,...t){let n=Object.create(null);for(let t in e)n[t]=e[t];return t.forEach(function(e){for(let t in e)n[t]=e[t]}),n}class s{constructor(e,t){this.buffer="",this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=i(e)}openNode(e){if(!e.scope)return;let t=((e,{prefix:t})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){let n=e.split(".");return[`${t}${n.shift()}`,...n.map((e,t)=>`${e}${"_".repeat(t+1)}`)].join(" ")}return`${t}${e}`})(e.scope,{prefix:this.classPrefix});this.span(t)}closeNode(e){e.scope&&(this.buffer+="</span>")}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}}let a=(e={})=>{let t={children:[]};return Object.assign(t,e),t};class l{constructor(){this.rootNode=a(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){let t=a({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return"string"==typeof t?e.addText(t):t.children&&(e.openNode(t),t.children.forEach(t=>this._walk(e,t)),e.closeNode(t)),e}static _collapse(e){"string"==typeof e||e.children&&(e.children.every(e=>"string"==typeof e)?e.children=[e.children.join("")]:e.children.forEach(e=>{l._collapse(e)}))}}class c extends l{constructor(e){super(),this.options=e}addText(e){""!==e&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){let n=e.root;t&&(n.scope=`language:${t}`),this.add(n)}toHTML(){return new s(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function d(e){return e?"string"==typeof e?e:e.source:null}function u(e){return f("(?=",e,")")}function h(e){return f("(?:",e,")*")}function p(e){return f("(?:",e,")?")}function f(...e){return e.map(e=>d(e)).join("")}function m(...e){let t;return"("+(("object"==typeof(t=e[e.length-1])&&t.constructor===Object?(e.splice(e.length-1,1),t):{}).capture?"":"?:")+e.map(e=>d(e)).join("|")+")"}function g(e){return RegExp(e.toString()+"|").exec("").length-1}let y=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function b(e,{joinWith:t}){let n=0;return e.map(e=>{let t=n+=1,r=d(e),i="";for(;r.length>0;){let e=y.exec(r);if(!e){i+=r;break}i+=r.substring(0,e.index),r=r.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?i+="\\"+String(Number(e[1])+t):(i+=e[0],"("===e[0]&&n++)}return i}).map(e=>`(${e})`).join(t)}let v="[a-zA-Z]\\w*",w="[a-zA-Z_]\\w*",x="\\b\\d+(\\.\\d+)?",k="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",S="\\b(0b[01]+)",C={begin:"\\\\[\\s\\S]",relevance:0},E=function(e,t,n={}){let r=o({scope:"comment",begin:e,end:t,contains:[]},n);r.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let i=m("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:f(/[ ]+/,"(",i,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),r},M=E("//","$"),N=E("/\\*","\\*/"),A=E("#","$");var T=Object.freeze({__proto__:null,APOS_STRING_MODE:{scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[C]},BACKSLASH_ESCAPE:C,BINARY_NUMBER_MODE:{scope:"number",begin:S,relevance:0},BINARY_NUMBER_RE:S,COMMENT:E,C_BLOCK_COMMENT_MODE:N,C_LINE_COMMENT_MODE:M,C_NUMBER_MODE:{scope:"number",begin:k,relevance:0},C_NUMBER_RE:k,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}})},HASH_COMMENT_MODE:A,IDENT_RE:v,MATCH_NOTHING_RE:/\b\B/,METHOD_GUARD:{begin:"\\.\\s*"+w,relevance:0},NUMBER_MODE:{scope:"number",begin:x,relevance:0},NUMBER_RE:x,PHRASAL_WORDS_MODE:{begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},QUOTE_STRING_MODE:{scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[C]},REGEXP_MODE:{scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[C,{begin:/\[/,end:/\]/,relevance:0,contains:[C]}]},RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",SHEBANG:(e={})=>{let t=/^#![ ]*\//;return e.binary&&(e.begin=f(t,/.*\b/,e.binary,/\b.*/)),o({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{0!==e.index&&t.ignoreMatch()}},e)},TITLE_MODE:{scope:"title",begin:v,relevance:0},UNDERSCORE_IDENT_RE:w,UNDERSCORE_TITLE_MODE:{scope:"title",begin:w,relevance:0}});function R(e,t){"."===e.input[e.index-1]&&t.ignoreMatch()}function O(e,t){void 0!==e.className&&(e.scope=e.className,delete e.className)}function D(e,t){!t||e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=R,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,void 0===e.relevance&&(e.relevance=0))}function j(e,t){Array.isArray(e.illegal)&&(e.illegal=m(...e.illegal))}function I(e,t){if(e.match){if(e.begin||e.end)throw Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function P(e,t){void 0===e.relevance&&(e.relevance=1)}let L=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw Error("beforeMatch cannot be used with starts");let n=Object.assign({},e);Object.keys(e).forEach(t=>{delete e[t]}),e.keywords=n.keywords,e.begin=f(n.beforeMatch,u(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},z=["of","and","for","in","not","or","if","then","parent","list","value"],_={},$=e=>{console.error(e)},H=(e,...t)=>{console.log(`WARN: ${e}`,...t)},B=(e,t)=>{_[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),_[`${e}/${t}`]=!0)},F=Error();function V(e,t,{key:n}){let r=0,i=e[n],o={},s={};for(let e=1;e<=t.length;e++)s[e+r]=i[e],o[e+r]=!0,r+=g(t[e-1]);e[n]=s,e[n]._emit=o,e[n]._multi=!0}function U(e){if(e.scope&&"object"==typeof e.scope&&null!==e.scope&&(e.beginScope=e.scope,delete e.scope),"string"==typeof e.beginScope&&(e.beginScope={_wrap:e.beginScope}),"string"==typeof e.endScope&&(e.endScope={_wrap:e.endScope}),Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw $("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),F;if("object"!=typeof e.beginScope||null===e.beginScope)throw $("beginScope must be object"),F;V(e,e.begin,{key:"beginScope"}),e.begin=b(e.begin,{joinWith:""})}if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw $("skip, excludeEnd, returnEnd not compatible with endScope: {}"),F;if("object"!=typeof e.endScope||null===e.endScope)throw $("endScope must be object"),F;V(e,e.end,{key:"endScope"}),e.end=b(e.end,{joinWith:""})}}class W extends Error{constructor(e,t){super(e),this.name="HTMLInjectionError",this.html=t}}let K=Symbol("nomatch"),q=function(e){let t=Object.create(null),n=Object.create(null),s=[],a=!0,l="Could not find the language '{}', did you forget to load/include a language module?",y={disableAutodetect:!0,name:"Plain text",contains:[]},v={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:c};function w(e){return v.noHighlightRe.test(e)}function x(e,t,n){let r="",i="";"object"==typeof t?(r=e,n=t.ignoreIllegals,i=t.language):(B("10.7.0","highlight(lang, code, ...args) has been deprecated."),B("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"),i=e,r=t),void 0===n&&(n=!0);let o={code:r,language:i};_("before:highlight",o);let s=o.result?o.result:k(o.language,o.code,n);return s.code=o.code,_("after:highlight",s),s}function k(e,n,s,c){let u=Object.create(null);function h(){if(!A.keywords)return void R.addText(H);let e=0;A.keywordPatternRe.lastIndex=0;let t=A.keywordPatternRe.exec(H),n="";for(;t;){n+=H.substring(e,t.index);let r=C.case_insensitive?t[0].toLowerCase():t[0],i=A.keywords[r];if(i){let[e,o]=i;if(R.addText(n),n="",u[r]=(u[r]||0)+1,u[r]<=7&&(B+=o),e.startsWith("_"))n+=t[0];else{let n=C.classNameAliases[e]||e;f(t[0],n)}}else n+=t[0];e=A.keywordPatternRe.lastIndex,t=A.keywordPatternRe.exec(H)}n+=H.substring(e),R.addText(n)}function p(){null!=A.subLanguage?function(){if(""===H)return;let e=null;if("string"==typeof A.subLanguage){if(!t[A.subLanguage])return R.addText(H);e=k(A.subLanguage,H,!0,T[A.subLanguage]),T[A.subLanguage]=e._top}else e=S(H,A.subLanguage.length?A.subLanguage:null);A.relevance>0&&(B+=e.relevance),R.__addSublanguage(e._emitter,e.language)}():h(),H=""}function f(e,t){""!==e&&(R.startScope(t),R.addText(e),R.endScope())}function m(e,t){let n=1,r=t.length-1;for(;n<=r;){if(!e._emit[n]){n++;continue}let r=C.classNameAliases[e[n]]||e[n],i=t[n];r?f(i,r):(H=i,h(),H=""),n++}}function y(e,t){return e.scope&&"string"==typeof e.scope&&R.openNode(C.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(f(H,C.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),H=""):e.beginScope._multi&&(m(e.beginScope,t),H="")),A=Object.create(e,{parent:{value:A}})}let w={};function x(t,i){let o=i&&i[0];if(H+=t,null==o)return p(),0;if("begin"===w.type&&"end"===i.type&&w.index===i.index&&""===o){if(H+=n.slice(i.index,i.index+1),!a){let t=Error(`0 width match regex (${e})`);throw t.languageName=e,t.badRule=w.rule,t}return 1}if(w=i,"begin"===i.type){let e=i[0],t=i.rule,n=new r(t);for(let r of[t.__beforeBegin,t["on:begin"]])if(r&&(r(i,n),n.isMatchIgnored))return 0===A.matcher.regexIndex?(H+=e[0],1):(W=!0,0);return t.skip?H+=e:(t.excludeBegin&&(H+=e),p(),t.returnBegin||t.excludeBegin||(H=e)),y(t,i),t.returnBegin?0:e.length}if("illegal"!==i.type||s){if("end"===i.type){let e=function(e){let t=e[0],i=n.substring(e.index),o=function e(t,n,i){var o;let s,a=(o=t.endRe,(s=o&&o.exec(i))&&0===s.index);if(a){if(t["on:end"]){let e=new r(t);t["on:end"](n,e),e.isMatchIgnored&&(a=!1)}if(a){for(;t.endsParent&&t.parent;)t=t.parent;return t}}if(t.endsWithParent)return e(t.parent,n,i)}(A,e,i);if(!o)return K;let s=A;A.endScope&&A.endScope._wrap?(p(),f(t,A.endScope._wrap)):A.endScope&&A.endScope._multi?(p(),m(A.endScope,e)):s.skip?H+=t:(s.returnEnd||s.excludeEnd||(H+=t),p(),s.excludeEnd&&(H=t));do A.scope&&R.closeNode(),A.skip||A.subLanguage||(B+=A.relevance),A=A.parent;while(A!==o.parent)return o.starts&&y(o.starts,e),s.returnEnd?0:t.length}(i);if(e!==K)return e}}else{let e=Error('Illegal lexeme "'+o+'" for mode "'+(A.scope||"<unnamed>")+'"');throw e.mode=A,e}if("illegal"===i.type&&""===o)return H+="\n",1;if(V>1e5&&V>3*i.index)throw Error("potential infinite loop, way more iterations than matches");return H+=o,o.length}let C=N(e);if(!C)throw $(l.replace("{}",e)),Error('Unknown language: "'+e+'"');let E=function(e){function t(t,n){return RegExp(d(t),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(n?"g":""))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,t){t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),this.matchAt+=g(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null);let e=this.regexes.map(e=>e[1]);this.matcherRe=t(b(e,{joinWith:"|"}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;let t=this.matcherRe.exec(e);if(!t)return null;let n=t.findIndex((e,t)=>t>0&&void 0!==e),r=this.matchIndexes[n];return t.splice(0,n),Object.assign(t,r)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];let t=new n;return this.rules.slice(e).forEach(([e,n])=>t.addRule(e,n)),t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,t){this.rules.push([e,t]),"begin"===t.type&&this.count++}exec(e){let t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex;let n=t.exec(e);if(this.resumingScanAtSamePosition())if(n&&n.index===this.lastIndex);else{let t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)}return n&&(this.regexIndex+=n.position+1,this.regexIndex===this.count&&this.considerAll()),n}}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes("self"))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=o(e.classNameAliases||{}),function n(i,s){let a;if(i.isCompiled)return i;[O,I,U,L].forEach(e=>e(i,s)),e.compilerExtensions.forEach(e=>e(i,s)),i.__beforeBegin=null,[D,j,P].forEach(e=>e(i,s)),i.isCompiled=!0;let l=null;return"object"==typeof i.keywords&&i.keywords.$pattern&&(i.keywords=Object.assign({},i.keywords),l=i.keywords.$pattern,delete i.keywords.$pattern),l=l||/\w+/,i.keywords&&(i.keywords=function e(t,n,r="keyword"){let i=Object.create(null);return"string"==typeof t?o(r,t.split(" ")):Array.isArray(t)?o(r,t):Object.keys(t).forEach(function(r){Object.assign(i,e(t[r],n,r))}),i;function o(e,t){n&&(t=t.map(e=>e.toLowerCase())),t.forEach(function(t){var n,r,o;let s=t.split("|");i[s[0]]=[e,(n=s[0],(r=s[1])?Number(r):+(o=n,!z.includes(o.toLowerCase())))]})}}(i.keywords,e.case_insensitive)),i.keywordPatternRe=t(l,!0),s&&(i.begin||(i.begin=/\B|\b/),i.beginRe=t(i.begin),i.end||i.endsWithParent||(i.end=/\B|\b/),i.end&&(i.endRe=t(i.end)),i.terminatorEnd=d(i.end)||"",i.endsWithParent&&s.terminatorEnd&&(i.terminatorEnd+=(i.end?"|":"")+s.terminatorEnd)),i.illegal&&(i.illegalRe=t(i.illegal)),i.contains||(i.contains=[]),i.contains=[].concat(...i.contains.map(function(e){var t;return((t="self"===e?i:e).variants&&!t.cachedVariants&&(t.cachedVariants=t.variants.map(function(e){return o(t,{variants:null},e)})),t.cachedVariants)?t.cachedVariants:!function e(t){return!!t&&(t.endsWithParent||e(t.starts))}(t)?Object.isFrozen(t)?o(t):t:o(t,{starts:t.starts?o(t.starts):null})})),i.contains.forEach(function(e){n(e,i)}),i.starts&&n(i.starts,s),a=new r,i.contains.forEach(e=>a.addRule(e.begin,{rule:e,type:"begin"})),i.terminatorEnd&&a.addRule(i.terminatorEnd,{type:"end"}),i.illegal&&a.addRule(i.illegal,{type:"illegal"}),i.matcher=a,i}(e)}(C),M="",A=c||E,T={},R=new v.__emitter(v),_=[];for(let e=A;e!==C;e=e.parent)e.scope&&_.unshift(e.scope);_.forEach(e=>R.openNode(e));let H="",B=0,F=0,V=0,W=!1;try{if(C.__emitTokens)C.__emitTokens(n,R);else{for(A.matcher.considerAll();;){V++,W?W=!1:A.matcher.considerAll(),A.matcher.lastIndex=F;let e=A.matcher.exec(n);if(!e)break;let t=n.substring(F,e.index),r=x(t,e);F=e.index+r}x(n.substring(F))}return R.finalize(),M=R.toHTML(),{language:e,value:M,relevance:B,illegal:!1,_emitter:R,_top:A}}catch(t){if(t.message&&t.message.includes("Illegal"))return{language:e,value:i(n),illegal:!0,relevance:0,_illegalBy:{message:t.message,index:F,context:n.slice(F-100,F+100),mode:t.mode,resultSoFar:M},_emitter:R};if(a)return{language:e,value:i(n),illegal:!1,relevance:0,errorRaised:t,_emitter:R,_top:A};throw t}}function S(e,n){let r;n=n||v.languages||Object.keys(t);let o=((r={value:i(e),illegal:!1,relevance:0,_top:y,_emitter:new v.__emitter(v)})._emitter.addText(e),r),s=n.filter(N).filter(R).map(t=>k(t,e,!1));s.unshift(o);let[a,l]=s.sort((e,t)=>{if(e.relevance!==t.relevance)return t.relevance-e.relevance;if(e.language&&t.language){if(N(e.language).supersetOf===t.language)return 1;else if(N(t.language).supersetOf===e.language)return -1}return 0});return a.secondBest=l,a}function C(e){var t;let r,i=function(e){let t=e.className+" ";t+=e.parentNode?e.parentNode.className:"";let n=v.languageDetectRe.exec(t);if(n){let t=N(n[1]);return t||(H(l.replace("{}",n[1])),H("Falling back to no-highlight mode for this block.",e)),t?n[1]:"no-highlight"}return t.split(/\s+/).find(e=>w(e)||N(e))}(e);if(w(i))return;if(_("before:highlightElement",{el:e,language:i}),e.dataset.highlighted)return void console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);if(e.children.length>0&&(v.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(e)),v.throwUnescapedHTML))throw new W("One of your code blocks includes unescaped HTML.",e.innerHTML);let o=e.textContent,s=i?x(o,{language:i,ignoreIllegals:!0}):S(o);e.innerHTML=s.value,e.dataset.highlighted="yes",t=s.language,r=i&&n[i]||t,e.classList.add("hljs"),e.classList.add(`language-${r}`),e.result={language:s.language,re:s.relevance,relevance:s.relevance},s.secondBest&&(e.secondBest={language:s.secondBest.language,relevance:s.secondBest.relevance}),_("after:highlightElement",{el:e,result:s,text:o})}let E=!1;function M(){if("loading"===document.readyState){E||window.addEventListener("DOMContentLoaded",function(){M()},!1),E=!0;return}document.querySelectorAll(v.cssSelector).forEach(C)}function N(e){return t[e=(e||"").toLowerCase()]||t[n[e]]}function A(e,{languageName:t}){"string"==typeof e&&(e=[e]),e.forEach(e=>{n[e.toLowerCase()]=t})}function R(e){let t=N(e);return t&&!t.disableAutodetect}function _(e,t){s.forEach(function(n){n[e]&&n[e](t)})}for(let r in Object.assign(e,{highlight:x,highlightAuto:S,highlightAll:M,highlightElement:C,highlightBlock:function(e){return B("10.7.0","highlightBlock will be removed entirely in v12.0"),B("10.7.0","Please use highlightElement now."),C(e)},configure:function(e){v=o(v,e)},initHighlighting:()=>{M(),B("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")},initHighlightingOnLoad:function(){M(),B("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")},registerLanguage:function(n,r){let i=null;try{i=r(e)}catch(e){if($("Language definition for '{}' could not be registered.".replace("{}",n)),a)$(e);else throw e;i=y}i.name||(i.name=n),t[n]=i,i.rawDefinition=r.bind(null,e),i.aliases&&A(i.aliases,{languageName:n})},unregisterLanguage:function(e){for(let r of(delete t[e],Object.keys(n)))n[r]===e&&delete n[r]},listLanguages:function(){return Object.keys(t)},getLanguage:N,registerAliases:A,autoDetection:R,inherit:o,addPlugin:function(e){var t;(t=e)["before:highlightBlock"]&&!t["before:highlightElement"]&&(t["before:highlightElement"]=e=>{t["before:highlightBlock"](Object.assign({block:e.el},e))}),t["after:highlightBlock"]&&!t["after:highlightElement"]&&(t["after:highlightElement"]=e=>{t["after:highlightBlock"](Object.assign({block:e.el},e))}),s.push(e)},removePlugin:function(e){let t=s.indexOf(e);-1!==t&&s.splice(t,1)}}),e.debugMode=function(){a=!1},e.safeMode=function(){a=!0},e.versionString="11.11.1",e.regex={concat:f,lookahead:u,either:m,optional:p,anyNumberOfTimes:h},T)"object"==typeof T[r]&&function e(t){return t instanceof Map?t.clear=t.delete=t.set=function(){throw Error("map is read-only")}:t instanceof Set&&(t.add=t.clear=t.delete=function(){throw Error("set is read-only")}),Object.freeze(t),Object.getOwnPropertyNames(t).forEach(n=>{let r=t[n],i=typeof r;"object"!==i&&"function"!==i||Object.isFrozen(r)||e(r)}),t}(T[r]);return Object.assign(e,T),e},J=q({});J.newInstance=()=>q({}),t.exports=J,J.HighlightJS=J,J.default=J},240409,512527,944404,334609,265590,441228,576500,194633,32033,623568,42420,278909,532270,503658,185503,993667,314206,388503,284766,965837,582966,25688,770271,e=>{"use strict";var t=e.i(44501),n=e.i(580330),r=e.i(792934),i=e.i(85741),o=e.i(464675),s=e.i(419943),a=e.i(987027),l=e.i(307154),c=e.i(10137),d=e.i(674155),u=e.i(148623),h=e.i(395330),p=e.i(398441),f=e.i(977112),m=e.i(799916),g=e.i(425275),y=e.i(702166),b=e.i(853840),v=e.i(864255),w=e.i(991685),x=e.i(67667),k=e.i(733716),S=e.i(703550),C=e.i(492622),E=e.i(253190),M=e.i(73313),N=e.i(736586),A=e.i(132807),T=e.i(579767),R=e.i(978375),O=e.i(101685),D=e.i(772436),j=e.i(975157),I=e.i(96701),P=e.i(933850),L=e.i(374435),z=e.i(924782),_=e.i(671485);async function $(e,t){let n=new FormData;n.append("file",t);try{let t=await (0,_.wsFetch)(`/api/upload/${e}`,{method:"POST",body:n});if(!t.ok)return null;let r=await t.json();return{url:r.url,filename:r.filename}}catch{return null}}function H({kind:e,pagePath:n,onCancel:r,onInsert:i,anchor:o}){let[s,a]=(0,O.useState)("upload"),[l,c]=(0,O.useState)(""),[d,u]=(0,O.useState)(!1),[h,p]=(0,O.useState)(null),f=(0,O.useRef)(null),m=async e=>{if(e&&0!==e.length){u(!0),p(null);try{let t=e[0],r=await $(n,t);if(!r)return void p("Upload failed.");i({url:r.url,alt:t.name,mimeType:t.type})}finally{u(!1)}}},g=()=>{let e=l.trim();e&&i({url:e})};return(0,t.jsxs)("div",{className:"absolute z-50 w-[360px] bg-popover border border-border rounded-xl shadow-e-4 overflow-hidden",style:{top:o.top,left:o.left},onMouseDown:e=>e.stopPropagation(),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[(0,t.jsx)("div",{className:"text-[12px] font-medium",children:"image"===e?"Insert image":"video"===e?"Insert video":"Attach file"}),(0,t.jsx)("button",{type:"button",onClick:r,className:"text-[11px] text-muted-foreground hover:text-foreground",children:"Cancel"})]}),(0,t.jsxs)("div",{className:"flex border-b border-border bg-muted/30",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>a("upload"),className:(0,j.cn)("flex-1 py-1.5 text-[11px] flex items-center justify-center gap-1.5 transition-colors","upload"===s?"bg-background text-foreground border-b-2 border-primary":"text-muted-foreground hover:text-foreground"),children:[(0,t.jsx)(z.Upload,{className:"w-3 h-3"})," Upload"]}),(0,t.jsxs)("button",{type:"button",onClick:()=>a("url"),className:(0,j.cn)("flex-1 py-1.5 text-[11px] flex items-center justify-center gap-1.5 transition-colors","url"===s?"bg-background text-foreground border-b-2 border-primary":"text-muted-foreground hover:text-foreground"),children:[(0,t.jsx)(y.Link,{className:"w-3 h-3"})," From URL"]})]}),"upload"===s?(0,t.jsxs)("div",{className:"p-4",onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),m(e.dataTransfer.files)},children:[(0,t.jsxs)("button",{type:"button",onClick:()=>f.current?.click(),disabled:d,className:"w-full border-2 border-dashed border-border rounded-sm py-6 flex flex-col items-center justify-center text-muted-foreground hover:bg-accent/30 transition-colors",children:[(0,t.jsx)(z.Upload,{className:"w-5 h-5 mb-1.5"}),(0,t.jsx)("span",{className:"text-[12px] font-medium",children:d?"Uploading…":`Click to upload ${e}`}),(0,t.jsx)("span",{className:"text-[10px] mt-0.5",children:"or drop a file here"})]}),(0,t.jsx)("input",{ref:f,type:"file",accept:"image"===e?"image/*":"video"===e?"video/*":"*/*",className:"hidden",onChange:e=>m(e.target.files)}),h&&(0,t.jsx)("div",{className:"mt-2 text-[11px] text-destructive",children:h})]}):(0,t.jsxs)("div",{className:"p-3 space-y-2",children:[(0,t.jsx)("input",{type:"url",autoFocus:!0,value:l,placeholder:"image"===e?"https://example.com/image.png":"video"===e?"https://example.com/video.mp4":"https://example.com/file",onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),g()):"Escape"===e.key&&r()},className:"w-full bg-background border border-border rounded-sm px-2.5 py-1.5 text-[12px] focus:outline-none focus:ring-2 focus:ring-primary/30"}),(0,t.jsx)("button",{type:"button",onClick:g,disabled:!l.trim(),className:"w-full py-1.5 text-[12px] rounded-sm bg-primary text-primary-foreground disabled:opacity-50 hover:bg-primary/90",children:"Insert"})]}),(0,t.jsxs)("div",{className:"px-3 py-2 border-t border-border bg-muted/30 text-[10px] text-muted-foreground flex items-start gap-1.5",children:[(0,t.jsx)(L.Clipboard,{className:"w-3 h-3 shrink-0 mt-[1px]"}),(0,t.jsxs)("span",{children:["Tip: you can also"," ",(0,t.jsx)("strong",{className:"text-foreground/80",children:"paste"})," or"," ",(0,t.jsx)("strong",{className:"text-foreground/80",children:"drag & drop"}),"files directly into the page — they'll be saved alongside this page automatically."]})]})]})}function B({label:e,icon:n,active:r,disabled:i,style:o,onAction:s}){return(0,t.jsx)("button",{type:"button","aria-label":e,title:e,disabled:i,style:o,onMouseDown:e=>{e.preventDefault()},onClick:e=>{e.preventDefault(),s(e)},className:(0,j.cn)("h-8 w-8 shrink-0 inline-flex items-center justify-center rounded-md text-foreground/80 hover:bg-accent hover:text-accent-foreground transition-colors disabled:opacity-40",r&&"bg-accent text-accent-foreground ring-1 ring-inset ring-foreground/15"),children:(0,t.jsx)(n,{className:"h-4 w-4"})})}function F({onClose:e}){return(0,O.useEffect)(()=>{let t=window.setTimeout(()=>{let t=t=>{let n=t.target;n?.closest('[data-editor-popover="true"]')||e()};window.addEventListener("mousedown",t),window.__editorPopClose=()=>window.removeEventListener("mousedown",t)},10);return()=>{window.clearTimeout(t);let e=window;e.__editorPopClose&&(e.__editorPopClose(),e.__editorPopClose=void 0)}},[e]),null}e.s(["MediaPopover",0,H],512527),e.s(["EditorToolbar",0,function({editor:e}){let j=(0,I.useEditorStore)(e=>e.frontmatter),L=(0,I.useEditorStore)(e=>e.updateFrontmatter),z=(0,I.useEditorStore)(e=>e.currentPath),_=j?.dir==="rtl",[$,V]=(0,O.useState)(null),U=(0,O.useRef)(null),[W,K]=(0,O.useState)(!1),[q,J]=(0,O.useState)(!1),[,G]=(0,O.useState)(0);(0,O.useEffect)(()=>{if(!e)return;let t=()=>G(e=>e+1);return e.on("selectionUpdate",t),e.on("transaction",t),()=>{e.off("selectionUpdate",t),e.off("transaction",t)}},[e]);let X=(0,O.useCallback)(()=>{let e=U.current;e&&(K(e.scrollLeft>4),J(e.scrollLeft+e.clientWidth<e.scrollWidth-4))},[]);(0,O.useEffect)(()=>{if(!e)return;let t=U.current;if(!t)return;let n=requestAnimationFrame(X),r=()=>X();window.addEventListener("resize",r),t.addEventListener("scroll",X);let i=new ResizeObserver(()=>X());for(let e of(i.observe(t),Array.from(t.children)))i.observe(e);return()=>{cancelAnimationFrame(n),window.removeEventListener("resize",r),t.removeEventListener("scroll",X),i.disconnect()}},[e,X]);let Z=e=>{let t=U.current;t&&t.scrollBy({left:e*Math.max(160,.6*t.clientWidth),behavior:"smooth"})};if(!e)return null;let Y=(t,n)=>{e.chain().focus().setTextSelection(t).run(),n()},Q=(t,n)=>{let r=t.currentTarget.getBoundingClientRect();V(n({top:r.bottom+6,left:r.left},(()=>{let{from:t,to:n}=e.state.selection;return{from:t,to:n}})()))},ee=[{icon:h.Heading1,action:()=>e.chain().focus().toggleHeading({level:1}).run(),isActive:e.isActive("heading",{level:1}),label:"Heading 1"},{icon:p.Heading2,action:()=>e.chain().focus().toggleHeading({level:2}).run(),isActive:e.isActive("heading",{level:2}),label:"Heading 2"},{icon:f.Heading3,action:()=>e.chain().focus().toggleHeading({level:3}).run(),isActive:e.isActive("heading",{level:3}),label:"Heading 3"},{separator:!0},{icon:s.Bold,action:()=>e.chain().focus().toggleBold().run(),isActive:e.isActive("bold"),label:"Bold"},{icon:g.Italic,action:()=>e.chain().focus().toggleItalic().run(),isActive:e.isActive("italic"),label:"Italic"},{icon:A.Underline,action:()=>e.chain().focus().toggleUnderline().run(),isActive:e.isActive("underline"),label:"Underline"},{icon:E.Strikethrough,action:()=>e.chain().focus().toggleStrike().run(),isActive:e.isActive("strike"),label:"Strikethrough"},{icon:d.Code,action:()=>e.chain().focus().toggleCode().run(),isActive:e.isActive("code"),label:"Inline code"},{icon:y.Link,action:t=>{let n=e.getAttributes("link")?.href??"";Q(t,(e,t)=>({type:"link",anchor:e,range:t,existing:n}))},isActive:e.isActive("link"),label:"Link"},{separator:!0},{icon:b.List,action:()=>e.chain().focus().toggleBulletList().run(),isActive:e.isActive("bulletList"),label:"Bullet list"},{icon:v.ListOrdered,action:()=>e.chain().focus().toggleOrderedList().run(),isActive:e.isActive("orderedList"),label:"Ordered list"},{icon:S.Quote,action:()=>e.chain().focus().toggleBlockquote().run(),isActive:e.isActive("blockquote"),label:"Blockquote"},{icon:a.CheckSquare,action:()=>e.chain().focus().toggleTaskList().run(),isActive:e.isActive("taskList"),label:"Checklist"},{icon:u.FileCode,action:()=>e.chain().focus().toggleCodeBlock().run(),isActive:e.isActive("codeBlock"),label:"Code block"},{icon:w.Minus,action:()=>e.chain().focus().setHorizontalRule().run(),isActive:!1,label:"Divider"}],et=[{icon:i.AlignLeft,action:()=>e.chain().focus().setTextAlign("left").run(),isActive:e.isActive({textAlign:"left"}),label:"Align left"},{icon:n.AlignCenter,action:()=>e.chain().focus().setTextAlign("center").run(),isActive:e.isActive({textAlign:"center"}),label:"Align center"},{icon:o.AlignRight,action:()=>e.chain().focus().setTextAlign("right").run(),isActive:e.isActive({textAlign:"right"}),label:"Align right"},{icon:r.AlignJustify,action:()=>e.chain().focus().setTextAlign("justify").run(),isActive:e.isActive({textAlign:"justify"}),label:"Justify"},{separator:!0},{icon:N.Superscript,action:()=>e.chain().focus().toggleSuperscript().run(),isActive:e.isActive("superscript"),label:"Superscript"},{icon:M.Subscript,action:()=>e.chain().focus().toggleSubscript().run(),isActive:e.isActive("subscript"),label:"Subscript"},{separator:!0},{icon:m.ImageIcon,action:e=>Q(e,e=>({type:"media",kind:"image",anchor:e})),isActive:!1,label:"Insert image"},{icon:R.Video,action:e=>Q(e,e=>({type:"media",kind:"video",anchor:e})),isActive:!1,label:"Insert video"},{separator:!0},{icon:T.Undo,action:()=>e.chain().focus().undo().run(),isActive:!1,label:"Undo"},{icon:C.Redo,action:()=>e.chain().focus().redo().run(),isActive:!1,label:"Redo"},{separator:!0},{icon:_?x.PilcrowLeft:k.PilcrowRight,action:()=>L({dir:_?void 0:"rtl"}),isActive:_,label:_?"Switch to LTR":"Switch to RTL"}];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"relative border-b border-border bg-background/50",children:[W&&(0,t.jsx)("button",{type:"button","aria-label":"Scroll toolbar left",onMouseDown:e=>e.preventDefault(),onClick:()=>Z(-1),className:"absolute left-0 top-0 bottom-0 w-6 z-10 flex items-center justify-start pl-0.5 bg-gradient-to-r from-background via-background/80 to-transparent text-muted-foreground hover:text-foreground transition-colors",children:(0,t.jsx)(l.ChevronLeft,{className:"h-4 w-4"})}),q&&(0,t.jsx)("button",{type:"button","aria-label":"Scroll toolbar right",onMouseDown:e=>e.preventDefault(),onClick:()=>Z(1),className:"absolute right-0 top-0 bottom-0 w-6 z-10 flex items-center justify-end pr-0.5 bg-gradient-to-l from-background via-background/80 to-transparent text-muted-foreground hover:text-foreground transition-colors",children:(0,t.jsx)(c.ChevronRight,{className:"h-4 w-4"})}),(0,t.jsx)("div",{ref:U,onWheel:e=>{let t=U.current;t&&Math.abs(e.deltaY)>Math.abs(e.deltaX)&&(t.scrollLeft+=e.deltaY)},className:"flex items-center gap-0.5 px-2 pt-1 pb-1.5 overflow-x-scroll overflow-y-hidden editor-toolbar-scroll",children:[...ee,{separator:!0},...et].map((e,n)=>"separator"in e?(0,t.jsx)(D.Separator,{orientation:"vertical",className:"mx-1 h-6 shrink-0"},n):(0,t.jsx)(B,{label:e.label,icon:e.icon,active:e.isActive,style:e.style,onAction:e.action},n))})]}),$?.type==="link"&&(0,t.jsx)("div",{"data-editor-popover":"true",style:{position:"fixed",top:$.anchor.top,left:$.anchor.left,zIndex:60},children:(0,t.jsx)(P.LinkPopover,{anchor:{top:0,left:0},initialUrl:$.existing,onCancel:()=>V(null),onApply:t=>{$?.type==="link"&&(Y($.range,()=>{e.chain().focus().extendMarkRange("link").setLink({href:t}).run()}),V(null))},onRemove:$.existing?()=>{$?.type==="link"&&(Y($.range,()=>{e.chain().focus().unsetLink().run()}),V(null))}:void 0})}),$?.type==="media"&&z&&(0,t.jsx)("div",{"data-editor-popover":"true",style:{position:"fixed",top:$.anchor.top,left:$.anchor.left,zIndex:60},children:(0,t.jsx)(H,{kind:$.kind,pagePath:z,anchor:{top:0,left:0},onCancel:()=>V(null),onInsert:t=>((t,n)=>{let{url:r,alt:i,mimeType:o}=n;"image"===t||(o??"").startsWith("image/")||/\.(png|jpe?g|gif|webp|svg|avif)(\?|$)/i.test(r)?e.chain().focus().setImage({src:r,alt:i??""}).run():e.chain().focus().insertContent(`<a href="${r}">${i??r}</a>`).run(),V(null)})($.kind,t)})}),$&&(0,t.jsx)(F,{onClose:()=>V(null)})]})}],240409);var V=e.i(343603),U=e.i(111092),W=/^```([a-z]+)?[\s\n]$/,K=/^~~~([a-z]+)?[\s\n]$/,q=V.Node.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:e=>{var t;let{languageClassPrefix:n}=this.options;if(!n)return null;let r=[...(null==(t=e.firstElementChild)?void 0:t.classList)||[]].filter(e=>e.startsWith(n)).map(e=>e.replace(n,""))[0];return r||null},rendered:!1}}},parseHTML:()=>[{tag:"pre",preserveWhitespace:"full"}],renderHTML({node:e,HTMLAttributes:t}){return["pre",(0,V.mergeAttributes)(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(e,t)=>{var n,r;return(null==(n=e.raw)?void 0:n.startsWith("```"))===!1&&(null==(r=e.raw)?void 0:r.startsWith("~~~"))===!1&&"indented"!==e.codeBlockStyle?[]:t.createNode("codeBlock",{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[])},renderMarkdown:(e,t)=>{var n;let r=(null==(n=e.attrs)?void 0:n.language)||"";return e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join("\n"):`\`\`\`${r}
98
+ `;try{await el(`${r}/index.md`,i),e({content:i,isDirty:!1,loadStatus:"ok"}),ep({path:r,content:i,frontmatter:null})}catch{}},clear:()=>{em&&clearTimeout(em),eg&&clearTimeout(eg),e({currentPath:null,content:"",frontmatter:null,saveStatus:"idle",loadStatus:"idle",isDirty:!1,isLoading:!1,lastSavedAt:null,currentRevision:null})},syncRevision:t=>{e({currentRevision:t})}}));e.s(["prefetchPage",0,function(e){if(ed.has(e)||eu.has(e))return;let t=eo(e).then(e=>(eh(e),e)).finally(()=>{eu.delete(e)});eu.set(e,t),t.catch(()=>{})},"useEditorStore",0,eb],96701);let ev=ee((e,t)=>({nodes:[],selectedPath:null,expandedPaths:new Set,loadTree:async()=>{},selectPage:t=>{e({selectedPath:t})},expandPath:n=>{let{expandedPaths:r}=t();if(!r.has(n)){let t=new Set(r);t.add(n),e({expandedPaths:t})}},focusPath:n=>{let{expandedPaths:r}=t(),i=new Set(r),o=n.split("/");for(let e=1;e<o.length;e++)i.add(o.slice(0,e).join("/"));e({selectedPath:n,expandedPaths:i})}}));e.s(["useTreeStore",0,ev],990791);let ew="wiki-view-width",ex="wiki-view-align",ek=["narrow","normal","wide"],eS=ee(e=>{let t,n;return{width:"narrow"===(t=localStorage.getItem(ew))||"normal"===t||"wide"===t?t:"normal",align:"center"===(n=localStorage.getItem(ex))||"left"===n?n:"center",setWidth:t=>{localStorage.setItem(ew,t),e({width:t})},setAlign:t=>{localStorage.setItem(ex,t),e({align:t})},cycle:()=>e(e=>{let t=ek.indexOf(e.width),n=ek[(t+1)%ek.length];return localStorage.setItem(ew,n),{width:n}})}});e.s(["VIEW_ALIGN_CLASS",0,{center:"mx-auto",left:"mr-auto"},"VIEW_ALIGN_LABEL",0,{center:"Center",left:"Left"},"VIEW_ALIGN_ML",0,{center:"auto",left:"0"},"VIEW_ALIGN_ORDER",0,["center","left"],"VIEW_WIDTH_CLASS",0,{narrow:"max-w-2xl",normal:"max-w-5xl",wide:"max-w-[90rem]"},"VIEW_WIDTH_CSS",0,{narrow:"42rem",normal:"64rem",wide:"90rem"},"VIEW_WIDTH_LABEL",0,{narrow:"Narrow",normal:"Normal",wide:"Wide"},"VIEW_WIDTH_ORDER",0,ek,"useViewWidthStore",0,eS],395624);let eC=ee((e,t)=>({slugs:new Set,slugDir:new Map,loadedAt:null,loading:!1,load:async()=>{let{loadedAt:n,loading:r}=t();if(!r&&!(null!==n&&Date.now()-n<1e4)){e({loading:!0});try{let t=await (0,et.wsFetch)("/api/wiki/slugs");if(!t.ok)throw Error("Failed to fetch wiki slugs");let n=await t.json(),r=new Set,i=new Map;for(let e of["entities","concepts","comparisons","root"])for(let t of n[e])r.add(t),i.has(t)||i.set(t,e);e({slugs:r,slugDir:i,loadedAt:Date.now(),loading:!1})}catch{e({loading:!1})}}},has:e=>t().slugs.has(e),getDir:e=>t().slugDir.get(e)??null,invalidate(){e({loadedAt:null})}}));function eE(){return{sidecar:null,snapshotRevision:0,lastEventId:0,snapshotBlocks:[]}}e.s(["useWikiSlugsStore",0,eC],246542);let eM=ee((e,t)=>({byPath:{},loadSidecar:async t=>{let n=encodeURIComponent(t).replace(/%2F/g,"/");try{let r=await (0,et.wsFetch)(`/api/agent/sidecar/${n}`,{headers:en()});if(!r.ok)return;let i=await r.json();e(e=>({byPath:{...e.byPath,[t]:{...e.byPath[t]??eE(),sidecar:i,snapshotRevision:i.revision,lastEventId:i.nextEventId-1}}}))}catch{}},loadSnapshot:async t=>{let n=encodeURIComponent(t).replace(/%2F/g,"/");try{let r=await (0,et.wsFetch)(`/api/agent/files/${n}`,{headers:en()});if(!r.ok)return;let i=await r.json();e(e=>({byPath:{...e.byPath,[t]:{...e.byPath[t]??eE(),snapshotBlocks:i.blocks,snapshotRevision:i.revision}}}));let o=eb.getState();o.currentPath===t&&o.syncRevision(i.revision)}catch{}},pollEvents:async e=>{let n=t().byPath[e]??eE(),r=encodeURIComponent(e).replace(/%2F/g,"/");try{let i=await (0,et.wsFetch)(`/api/agent/events/${r}?after=${n.lastEventId}`,{headers:en()});if(!i.ok)return;for(let n of(await i.json()).events)t().applyEvent(e,n)}catch{}},applyEvent:(t,n)=>{e(e=>{let r=e.byPath[t]??eE();return{byPath:{...e.byPath,[t]:{...r,lastEventId:Math.max(r.lastEventId,n.id)}}}})},reset:t=>{e(e=>{let n={...e.byPath};return delete n[t],{byPath:n}})}}));async function eN(e,t,n){let r=encodeURIComponent(e).replace(/%2F/g,"/"),i=await fetch(`/api/agent/files/${r}`,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":crypto.randomUUID(),...en()},body:JSON.stringify({baseRevision:t,by:"human",ops:[n]})});if(409===i.status){let e=await i.json();return"STALE_REVISION"===e.code&&e.snapshot?.revision!==void 0?{ok:!1,stale:!0,newRevision:e.snapshot.revision}:{ok:!1,stale:!1}}return{ok:i.ok,stale:!1}}async function eA(e){let{path:t,ref:n,kind:r,markdown:i,basisDetail:o,getRevision:s,refresh:a}=e,l={type:"suggestion.add",ref:n,kind:r,basis:"suggested"};"delete"!==r&&(l.markdown=i??""),o&&(l.basisDetail=o);let c=await eN(t,s(),l);return!c.ok&&c.stale&&void 0!==c.newRevision&&(await a(),c=await eN(t,c.newRevision,l)),c.ok}e.s(["useProofStore",0,eM],592185),e.s(["captureSuggestion",0,eA],926732);var eT=e.i(187014);e.s(["showError",0,function(e,t){eT.toast.error(e,t)},"showSuccess",0,function(e,t){eT.toast.success(e,t)}],417385)},153840,580330,792934,85741,464675,419943,674155,425275,891734,187080,253190,73313,736586,132807,412473,e=>{"use strict";var t=e.i(343603),n=e.i(278928),r=e.i(111092);e.i(150663);var i=e.i(608926),o=class{constructor({editor:e,element:n,view:r,pluginKey:i="bubbleMenu",updateDelay:o=250,resizeDelay:s=60,shouldShow:a,appendTo:l,getReferencedVirtualElement:c,options:d}){var u;this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:e,state:n,from:r,to:i})=>{let{doc:o,selection:s}=n,{empty:a}=s,l=!o.textBetween(r,i).length&&(0,t.isTextSelection)(n.selection),c=this.element.contains(document.activeElement);return!!(e.hasFocus()||c)&&!a&&!l&&!!this.editor.isEditable},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{var t;if(this.editor.isDestroyed)return void this.destroy();if(this.preventHide){this.preventHide=!1;return}(null==e?void 0:e.relatedTarget)&&(null==(t=this.element.parentNode)?void 0:t.contains(e.relatedTarget))||(null==e?void 0:e.relatedTarget)!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(e,t)=>{let n=!(null==t?void 0:t.selection.eq(e.state.selection)),r=!(null==t?void 0:t.doc.eq(e.state.doc));(n||r)&&(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(e,n,r,t)},this.updateDelay))},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;!i&&(t||n)&&(this.getShouldShow(r)?(this.show(),this.updatePosition()):this.hide())},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);"updatePosition"===t?this.updatePosition():t&&"object"==typeof t&&"updateOptions"===t.type?this.updateOptions(t.options):"hide"===t?this.hide():"show"===t&&(this.updatePosition(),this.show())},this.editor=e,this.element=n,this.view=r,this.pluginKey=i,this.updateDelay=o,this.resizeDelay=s,this.appendTo=l,this.scrollTarget=null!=(u=null==d?void 0:d.scrollTarget)?u:window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...d},this.element.tabIndex=0,a&&(this.shouldShow=a),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(r,r.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push((0,n.flip)("boolean"!=typeof this.floatingUIOptions.flip?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push((0,n.shift)("boolean"!=typeof this.floatingUIOptions.shift?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push((0,n.offset)("boolean"!=typeof this.floatingUIOptions.offset?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push((0,n.arrow)(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push((0,n.size)("boolean"!=typeof this.floatingUIOptions.size?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push((0,n.autoPlacement)("boolean"!=typeof this.floatingUIOptions.autoPlacement?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push((0,n.hide)("boolean"!=typeof this.floatingUIOptions.hide?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push((0,n.inline)("boolean"!=typeof this.floatingUIOptions.inline?this.floatingUIOptions.inline:void 0)),e}get virtualElement(){var e,n,o,s,a;let{selection:l}=this.editor.state,c=null==(e=this.getReferencedVirtualElement)?void 0:e.call(this);if(c)return c;if(!(null==(o=null==(n=this.view)?void 0:n.dom)?void 0:o.parentNode))return;let d=(0,t.posToDOMRect)(this.view,l.from,l.to),u={getBoundingClientRect:()=>d,getClientRects:()=>[d]};if(l instanceof r.NodeSelection){let e=this.view.nodeDOM(l.from),t=e.dataset.nodeViewWrapper?e:e.querySelector("[data-node-view-wrapper]");t&&(e=t),e&&(u={getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>[e.getBoundingClientRect()]})}if(l instanceof i.CellSelection){let e,t,n,{$anchorCell:r,$headCell:i}=l,o=r?r.pos:i.pos,c=i?i.pos:r.pos,d=this.view.nodeDOM(o),h=this.view.nodeDOM(c);if(!d||!h)return;let p=d===h?d.getBoundingClientRect():(s=d.getBoundingClientRect(),a=h.getBoundingClientRect(),e=Math.min(s.top,a.top),t=Math.max(s.bottom,a.bottom),n=Math.min(s.left,a.left),new DOMRect(n,e,Math.max(s.right,a.right)-n,t-e));u={getBoundingClientRect:()=>p,getClientRects:()=>[p]}}return u}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&(0,n.computePosition)(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{var i,o;if(this.isVisible&&!this.editor.isDestroyed&&this.element.isConnected){if((null==(i=r.hide)?void 0:i.referenceHidden)||(null==(o=r.hide)?void 0:o.escaped)){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(e,t){let{state:n}=e,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r)return void this.handleDebouncedUpdate(e,t);let i=!(null==t?void 0:t.selection.eq(e.state.selection)),o=!(null==t?void 0:t.doc.eq(e.state.doc));this.updateHandler(e,i,o,t)}getShouldShow(e){var t;let{state:n}=this.view,{selection:r}=n,{ranges:i}=r,o=Math.min(...i.map(e=>e.$from.pos)),s=Math.max(...i.map(e=>e.$to.pos));return(null==(t=this.shouldShow)?void 0:t.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:e,from:o,to:s}))||!1}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";let t="function"==typeof this.appendTo?this.appendTo():this.appendTo;null==(e=null!=t?t:this.view.dom.parentElement)||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(e){var t;if(void 0!==e.updateDelay&&(this.updateDelay=e.updateDelay),void 0!==e.resizeDelay&&(this.resizeDelay=e.resizeDelay),void 0!==e.appendTo&&(this.appendTo=e.appendTo),void 0!==e.getReferencedVirtualElement&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),void 0!==e.shouldShow&&e.shouldShow&&(this.shouldShow=e.shouldShow),void 0!==e.options){let n=null!=(t=e.options.scrollTarget)?t:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},s=e=>new r.Plugin({key:"string"==typeof e.pluginKey?new r.PluginKey(e.pluginKey):e.pluginKey,view:t=>new o({view:t,...e})});t.Extension.create({name:"bubbleMenu",addOptions:()=>({element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}),addProseMirrorPlugins(){return this.options.element?[s({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var a=e.i(885047),l=e.i(101685),c=e.i(380560),d=class{constructor({editor:e,element:t,view:n,pluginKey:r="floatingMenu",updateDelay:i=250,resizeDelay:o=60,options:s,appendTo:a,shouldShow:l}){var c;this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:e,state:t})=>{let{selection:n}=t,{$anchor:r,empty:i}=n,o=1===r.depth,s=r.parent.isTextblock&&!r.parent.type.spec.code&&!r.parent.textContent&&0===r.parent.childCount&&!this.getTextContent(r.parent);return!!e.hasFocus()&&!!i&&!!o&&!!s&&!!this.editor.isEditable},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;!i&&(t||n)&&(this.getShouldShow(r)?(this.updatePosition(),this.show()):this.hide())},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{var t;if(this.preventHide){this.preventHide=!1;return}(null==e?void 0:e.relatedTarget)&&(null==(t=this.element.parentNode)?void 0:t.contains(e.relatedTarget))||(null==e?void 0:e.relatedTarget)!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);"updatePosition"===t?this.updatePosition():t&&"object"==typeof t&&"updateOptions"===t.type?this.updateOptions(t.options):"hide"===t?this.hide():"show"===t&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=o,this.appendTo=a,this.scrollTarget=null!=(c=null==s?void 0:s.scrollTarget)?c:window,this.floatingUIOptions={...this.floatingUIOptions,...s},this.element.tabIndex=0,l&&(this.shouldShow=l),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(e){return(0,t.getText)(e,{textSerializers:(0,t.getTextSerializersFromSchema)(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push((0,n.flip)("boolean"!=typeof this.floatingUIOptions.flip?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push((0,n.shift)("boolean"!=typeof this.floatingUIOptions.shift?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push((0,n.offset)("boolean"!=typeof this.floatingUIOptions.offset?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push((0,n.arrow)(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push((0,n.size)("boolean"!=typeof this.floatingUIOptions.size?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push((0,n.autoPlacement)("boolean"!=typeof this.floatingUIOptions.autoPlacement?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push((0,n.hide)("boolean"!=typeof this.floatingUIOptions.hide?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push((0,n.inline)("boolean"!=typeof this.floatingUIOptions.inline?this.floatingUIOptions.inline:void 0)),e}getShouldShow(e){var t;let{state:n}=this.view,{selection:r}=n,{ranges:i}=r,o=Math.min(...i.map(e=>e.$from.pos)),s=Math.max(...i.map(e=>e.$to.pos));return null==(t=this.shouldShow)?void 0:t.call(this,{editor:this.editor,view:this.view,state:n,oldState:e,from:o,to:s})}updateOptions(e){var t;if(void 0!==e.updateDelay&&(this.updateDelay=e.updateDelay),void 0!==e.resizeDelay&&(this.resizeDelay=e.resizeDelay),void 0!==e.appendTo&&(this.appendTo=e.appendTo),void 0!==e.shouldShow&&e.shouldShow&&(this.shouldShow=e.shouldShow),void 0!==e.options){let n=null!=(t=e.options.scrollTarget)?t:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){var e,r;if(!(null==(r=null==(e=this.view)?void 0:e.dom)?void 0:r.parentNode))return;let{selection:i}=this.editor.state,o=(0,t.posToDOMRect)(this.view,i.from,i.to);(0,n.computePosition)({getBoundingClientRect:()=>o,getClientRects:()=>[o]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{var i,o;if((null==(i=r.hide)?void 0:i.referenceHidden)||(null==(o=r.hide)?void 0:o.escaped)){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){let n=!(null==t?void 0:t.selection.eq(e.state.selection)),r=!(null==t?void 0:t.doc.eq(e.state.doc));this.updateHandler(e,n,r,t)}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";let t="function"==typeof this.appendTo?this.appendTo():this.appendTo;null==(e=null!=t?t:this.view.dom.parentElement)||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},u=e=>new r.Plugin({key:"string"==typeof e.pluginKey?new r.PluginKey(e.pluginKey):e.pluginKey,view:t=>new d({view:t,...e})});function h(e,t){return null!=e?e:new r.PluginKey(t)}t.Extension.create({name:"floatingMenu",addOptions:()=>({element:null,options:{},pluginKey:"floatingMenu",updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}),addCommands(){return{updateFloatingMenuPosition:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(this.options.pluginKey,"updatePosition"),!0)}},addProseMirrorPlugins(){return this.options.element?[u({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});var p="u">typeof window?l.useLayoutEffect:l.useEffect,f=new Set(["left","opacity","position","top","visibility","width"]),m=new Set(["animationIterationCount","aspectRatio","borderImageOutset","borderImageSlice","borderImageWidth","columnCount","columns","fillOpacity","flex","flexGrow","flexShrink","fontWeight","gridArea","gridColumn","gridColumnEnd","gridColumnStart","gridRow","gridRowEnd","gridRowStart","lineClamp","lineHeight","opacity","order","orphans","scale","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth","tabSize","widows","zIndex","zoom"]),g=new Set(["children","className","style"]),y=new Set(["tabIndex"]),b=new Set(["accessKey","autoCapitalize","contentEditable","contextMenu","dir","draggable","enterKeyHint","hidden","id","lang","nonce","role","slot","spellCheck","tabIndex","title","translate"]),v={Blur:"focusout",DoubleClick:"dblclick",Focus:"focusin",MouseEnter:"mouseenter",MouseLeave:"mouseleave"};function w(e,t){return/^on[A-Z]/.test(e)&&"function"==typeof t}function x(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function k(e,t,n){if("tabIndex"===t){e.tabIndex=Number(n);return}e[t]=n}function S(e,t){let n=(0,l.useRef)({}),r=(0,l.useRef)([]);p(()=>{var i,o,s;let a,l,c,d=n.current;return!function(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute("class")}}(e,d.className,t.className),i=d.style,o=t.style,a=null!=i?i:{},l=null!=o?o:{},new Set([...Object.keys(a),...Object.keys(l)]).forEach(t=>{let n=a[t],r=l[t];if(n!==r){if(null==r)return void(!f.has(t)&&e.style.removeProperty(x(t)));f.has(t)||e.style.setProperty(x(t),"number"!=typeof r||0===r||t.startsWith("--")||m.has(t)?String(r):`${r}px`)}}),new Set([...Object.keys(d),...Object.keys(t)]).forEach(n=>{if(g.has(n)||!(n.startsWith("aria-")||n.startsWith("data-")||b.has(n))||w(n,d[n])||w(n,t[n]))return;let r=d[n],i=t[n];if(r===i)return;let o=(n.startsWith("aria-")||n.startsWith("data-"),n);if(null==i||!1===i){y.has(n)&&function(e,t){if("tabIndex"===t)return e.removeAttribute("tabindex");let n=e[t];if("boolean"==typeof n){e[t]=!1;return}if("number"==typeof n){e[t]=0;return}e[t]=""}(e,n),e.removeAttribute(o);return}if(!0===i){y.has(n)&&k(e,n,!0),e.setAttribute(o,"");return}y.has(n)?k(e,n,i):e.setAttribute(o,String(i))}),s=r.current,s.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)}),c=[],Object.entries(t).forEach(([t,n])=>{var r;let i,o;if(!w(t,n))return;let{eventName:s,options:a}={eventName:null!=(r=v[o=((i=t.endsWith("Capture"))?t.slice(0,-7):t).slice(2)])?r:o.toLowerCase(),options:i?{capture:!0}:void 0},l=t=>{let r,i,o;n((r=t.defaultPrevented,i=!1,Object.defineProperties(o=Object.create(t),{nativeEvent:{value:t},currentTarget:{value:e},target:{value:t.target},persist:{value:()=>void 0},isDefaultPrevented:{value:()=>r},isPropagationStopped:{value:()=>i},preventDefault:{value:()=>{r=!0,t.preventDefault()}},stopPropagation:{value:()=>{i=!0,t.stopPropagation()}}}),o))};e.addEventListener(s,l,a),c.push({eventName:s,listener:l,options:a})}),r.current=c,n.current=t,()=>{r.current.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)}),r.current=[]}},[e,t])}var C=l.default.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:o=null,getReferencedVirtualElement:d,options:u,children:p,...f},m)=>{let g=(0,l.useRef)(document.createElement("div")),y=(0,l.useRef)(h(e,"bubbleMenu")).current;S(g.current,f),"function"==typeof m?m(g.current):m&&(m.current=g.current);let{editor:b}=(0,a.useCurrentEditor)(),v=t||b,w={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:y,shouldShow:o,getReferencedVirtualElement:d,options:u},x=(0,l.useRef)(w);x.current=w;let[k,C]=(0,l.useState)(!1),E=(0,l.useRef)(!0);return(0,l.useEffect)(()=>{if(null==v?void 0:v.isDestroyed)return;if(!v)return void console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");let e=g.current;e.style.visibility="hidden",e.style.position="absolute";let t=s({...x.current,editor:v,element:e});v.registerPlugin(t);let n=x.current.pluginKey;return E.current=!0,C(!0),()=>{C(!1),v.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[v]),(0,l.useEffect)(()=>{if(k&&v&&!v.isDestroyed){if(E.current){E.current=!1;return}v.view.dispatch(v.state.tr.setMeta(y,{type:"updateOptions",options:x.current}))}},[k,v,n,r,o,u,i,d,y]),(0,c.createPortal)(p,g.current)});l.default.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:o=null,options:s,children:d,...p},f)=>{let m=(0,l.useRef)(document.createElement("div")),g=(0,l.useRef)(h(e,"floatingMenu")).current;S(m.current,p),"function"==typeof f?f(m.current):f&&(f.current=m.current);let{editor:y}=(0,a.useCurrentEditor)(),b=t||y,v={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:g,shouldShow:o,options:s},w=(0,l.useRef)(v);w.current=v;let[x,k]=(0,l.useState)(!1),C=(0,l.useRef)(!0);return(0,l.useEffect)(()=>{if(null==b?void 0:b.isDestroyed)return;if(!b)return void console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");let e=m.current;e.style.visibility="hidden",e.style.position="absolute";let t=u({...w.current,editor:b,element:e});b.registerPlugin(t);let n=w.current.pluginKey;return C.current=!0,k(!0),()=>{k(!1),b.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[b]),(0,l.useEffect)(()=>{if(x&&b&&!b.isDestroyed){if(C.current){C.current=!1;return}b.view.dispatch(b.state.tr.setMeta(g,{type:"updateOptions",options:w.current}))}},[x,b,n,r,o,s,i,g]),(0,c.createPortal)(d,m.current)}),e.s(["BubbleMenu",0,C],153840);var E=e.i(605993);let M=(0,E.default)("align-center",[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);e.s(["AlignCenter",0,M],580330);let N=(0,E.default)("align-justify",[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);e.s(["AlignJustify",0,N],792934);let A=(0,E.default)("align-left",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);e.s(["AlignLeft",0,A],85741);let T=(0,E.default)("align-right",[["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 18H7",key:"1ygte8"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);e.s(["AlignRight",0,T],464675);let R=(0,E.default)("bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);e.s(["Bold",0,R],419943);let O=(0,E.default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]);e.s(["Code",0,O],674155);let D=(0,E.default)("italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);e.s(["Italic",0,D],425275);let j=(0,E.default)("message-circle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);e.s(["MessageCircle",0,j],891734);let I=(0,E.default)("message-square-plus",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);e.s(["MessageSquarePlus",0,I],187080);let P=(0,E.default)("strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);e.s(["Strikethrough",0,P],253190);let L=(0,E.default)("subscript",[["path",{d:"m4 5 8 8",key:"1eunvl"}],["path",{d:"m12 5-8 8",key:"1ah0jp"}],["path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07",key:"e8ta8j"}]]);e.s(["Subscript",0,L],73313);let z=(0,E.default)("superscript",[["path",{d:"m4 19 8-8",key:"hr47gm"}],["path",{d:"m12 19-8-8",key:"1dhhmo"}],["path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06",key:"1dfcux"}]]);e.s(["Superscript",0,z],736586);let _=(0,E.default)("underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]);e.s(["Underline",0,_],132807);let $=(0,E.default)("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);e.s(["ExternalLink",0,$],412473)},920978,e=>{"use strict";let t=(0,e.i(605993).default)("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);e.s(["Trash2",0,t],920978)},582612,933850,987027,307154,148623,395330,398441,977112,e=>{"use strict";var t=e.i(44501),n=e.i(153840),r=e.i(580330),i=e.i(792934),o=e.i(85741),s=e.i(464675),a=e.i(419943),l=e.i(674155),c=e.i(425275),d=e.i(702166),u=e.i(891734),h=e.i(187080),p=e.i(253190),f=e.i(73313),m=e.i(736586),g=e.i(132807),y=e.i(101685),b=e.i(975157),v=e.i(412473),w=e.i(920978);function x({anchor:e,initialUrl:n="",onCancel:r,onApply:i,onRemove:o}){let[s,a]=(0,y.useState)(n);(0,y.useEffect)(()=>{let e=e=>{"Escape"===e.key&&r()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r]);let l=()=>{let e=s.trim();e?i(e):r()};return(0,t.jsxs)("div",{className:"absolute z-50 w-[340px] bg-popover border border-border rounded-lg shadow-xl overflow-hidden",style:{top:e.top,left:e.left},onMouseDown:e=>e.stopPropagation(),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-[12px] font-medium",children:[(0,t.jsx)(d.Link,{className:"w-3.5 h-3.5"}),n?"Edit link":"Add link"]}),(0,t.jsx)("button",{type:"button",onClick:r,className:"text-[11px] text-muted-foreground hover:text-foreground",children:"Cancel"})]}),(0,t.jsxs)("div",{className:"p-3 space-y-2",children:[(0,t.jsx)("input",{type:"url",autoFocus:!0,value:s,placeholder:"https://example.com",onChange:e=>a(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),l())},className:"w-full bg-background border border-border rounded-md px-2.5 py-1.5 text-[12px] focus:outline-none focus:ring-2 focus:ring-primary/30"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:l,disabled:!s.trim(),className:"flex-1 py-1.5 text-[12px] rounded-md bg-primary text-primary-foreground disabled:opacity-50 hover:bg-primary/90",children:n?"Update":"Add link"}),n&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("a",{href:n,target:"_blank",rel:"noreferrer noopener",className:"p-1.5 rounded-md border border-border hover:bg-accent text-muted-foreground hover:text-foreground",title:"Open link",children:(0,t.jsx)(v.ExternalLink,{className:"w-3.5 h-3.5"})}),o&&(0,t.jsx)("button",{type:"button",onClick:o,className:"p-1.5 rounded-md border border-border hover:bg-accent text-destructive",title:"Remove link",children:(0,t.jsx)(w.Trash2,{className:"w-3.5 h-3.5"})})]})]})]})]})}e.s(["LinkPopover",0,x],933850),e.s(["EditorBubbleMenu",0,function({editor:e,onSuggestEdit:v,onComment:w,readOnly:k}){let[S,C]=(0,y.useState)(null);if((0,y.useEffect)(()=>{if(!S)return;let e=e=>{let t=e.target;t?.closest("[data-bubble-popover='true']")||C(null)},t=window.setTimeout(()=>window.addEventListener("mousedown",e),10);return()=>{window.clearTimeout(t),window.removeEventListener("mousedown",e)}},[S]),!e)return null;let E=e=>(0,b.cn)("h-9 w-9 sm:h-7 sm:w-7 flex items-center justify-center rounded hover:bg-accent text-foreground/80 transition-colors",e&&"bg-accent text-foreground"),M=()=>{let{from:t,to:n}=e.state.selection;return{from:t,to:n}},N=t=>e.chain().focus().setTextSelection(t).run(),A=e=>t=>{t.preventDefault(),e()},T=t=>{S?.type==="align"&&(N(S.range),e.chain().focus().setTextAlign(t).run(),C(null))};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(n.BubbleMenu,{editor:e,options:{placement:"top",offset:8},className:"flex items-center gap-0.5 px-1 py-1 bg-popover border border-border rounded-sm shadow-lg",children:[!k&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",className:E(e.isActive("bold")),onMouseDown:e=>e.preventDefault(),onClick:A(()=>e.chain().focus().toggleBold().run()),"aria-label":"Bold",children:(0,t.jsx)(a.Bold,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{type:"button",className:E(e.isActive("italic")),onMouseDown:e=>e.preventDefault(),onClick:A(()=>e.chain().focus().toggleItalic().run()),"aria-label":"Italic",children:(0,t.jsx)(c.Italic,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{type:"button",className:E(e.isActive("underline")),onMouseDown:e=>e.preventDefault(),onClick:A(()=>e.chain().focus().toggleUnderline().run()),"aria-label":"Underline",children:(0,t.jsx)(g.Underline,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{type:"button",className:E(e.isActive("strike")),onMouseDown:e=>e.preventDefault(),onClick:A(()=>e.chain().focus().toggleStrike().run()),"aria-label":"Strikethrough",children:(0,t.jsx)(p.Strikethrough,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{type:"button",className:E(e.isActive("code")),onMouseDown:e=>e.preventDefault(),onClick:A(()=>e.chain().focus().toggleCode().run()),"aria-label":"Inline code",children:(0,t.jsx)(l.Code,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("div",{className:"w-px h-5 bg-border mx-1"}),(0,t.jsx)("button",{type:"button",className:E(e.isActive("superscript")),onMouseDown:e=>e.preventDefault(),onClick:A(()=>e.chain().focus().toggleSuperscript().run()),"aria-label":"Superscript",children:(0,t.jsx)(m.Superscript,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{type:"button",className:E(e.isActive("subscript")),onMouseDown:e=>e.preventDefault(),onClick:A(()=>e.chain().focus().toggleSubscript().run()),"aria-label":"Subscript",children:(0,t.jsx)(f.Subscript,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("div",{className:"w-px h-5 bg-border mx-1"}),(0,t.jsx)("button",{type:"button",className:E(e.isActive("link")),onMouseDown:e=>e.preventDefault(),onClick:t=>{t.preventDefault();let n=e.getAttributes("link")?.href??"",r=t.currentTarget.getBoundingClientRect();C({type:"link",range:M(),existing:n,anchor:{top:r.bottom+6,left:r.left}})},"aria-label":"Link",children:(0,t.jsx)(d.Link,{className:"w-3.5 h-3.5"})}),(v||w)&&(0,t.jsx)("div",{className:"w-px h-5 bg-border mx-1"}),w&&(0,t.jsx)("button",{type:"button",className:E(!1),onMouseDown:e=>e.preventDefault(),onClick:e=>{e.preventDefault(),w()},"aria-label":"Comment",title:"Comment",children:(0,t.jsx)(u.MessageCircle,{className:"w-3.5 h-3.5"})}),v&&(0,t.jsx)("button",{type:"button",className:E(!1),onMouseDown:e=>e.preventDefault(),onClick:e=>{e.preventDefault(),v()},"aria-label":"Suggest edit",title:"Suggest edit",children:(0,t.jsx)(h.MessageSquarePlus,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("div",{className:"w-px h-5 bg-border mx-1"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("button",{type:"button",className:E(!1),onMouseDown:e=>e.preventDefault(),onClick:e=>{e.preventDefault(),C({type:"align",range:M()})},"aria-label":"Align",children:(0,t.jsx)(o.AlignLeft,{className:"w-3.5 h-3.5"})}),S?.type==="align"&&(0,t.jsxs)("div",{"data-bubble-popover":"true",className:"absolute top-full left-0 mt-1 z-50 bg-popover border border-border rounded-sm shadow-lg p-1 flex gap-0.5",children:[(0,t.jsx)("button",{type:"button",className:E(e.isActive({textAlign:"left"})),onMouseDown:e=>e.preventDefault(),onClick:()=>T("left"),"aria-label":"Align left",children:(0,t.jsx)(o.AlignLeft,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{type:"button",className:E(e.isActive({textAlign:"center"})),onMouseDown:e=>e.preventDefault(),onClick:()=>T("center"),"aria-label":"Align center",children:(0,t.jsx)(r.AlignCenter,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{type:"button",className:E(e.isActive({textAlign:"right"})),onMouseDown:e=>e.preventDefault(),onClick:()=>T("right"),"aria-label":"Align right",children:(0,t.jsx)(s.AlignRight,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{type:"button",className:E(e.isActive({textAlign:"justify"})),onMouseDown:e=>e.preventDefault(),onClick:()=>T("justify"),"aria-label":"Justify",children:(0,t.jsx)(i.AlignJustify,{className:"w-3.5 h-3.5"})})]})]})]}),k&&w&&(0,t.jsx)("button",{type:"button",className:E(!1),onMouseDown:e=>e.preventDefault(),onClick:e=>{e.preventDefault(),w()},"aria-label":"Comment",title:"Add comment",children:(0,t.jsx)(u.MessageCircle,{className:"w-3.5 h-3.5"})})]}),S?.type==="link"&&(0,t.jsx)("div",{"data-bubble-popover":"true",style:{position:"fixed",top:S.anchor.top,left:S.anchor.left,zIndex:60},children:(0,t.jsx)(x,{anchor:{top:0,left:0},initialUrl:S.existing,onCancel:()=>C(null),onApply:t=>{S?.type==="link"&&(N(S.range),e.chain().focus().extendMarkRange("link").setLink({href:t}).run(),C(null))},onRemove:S.existing?()=>{S?.type==="link"&&(N(S.range),e.chain().focus().unsetLink().run(),C(null))}:void 0})})]})}],582612);var k=e.i(605993);let S=(0,k.default)("square-check-big",[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);e.s(["CheckSquare",0,S],987027);let C=(0,k.default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);e.s(["ChevronLeft",0,C],307154);let E=(0,k.default)("file-code",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);e.s(["FileCode",0,E],148623);let M=(0,k.default)("heading-1",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]]);e.s(["Heading1",0,M],395330);let N=(0,k.default)("heading-2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]]);e.s(["Heading2",0,N],398441);let A=(0,k.default)("heading-3",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]]);e.s(["Heading3",0,A],977112)},375707,e=>{"use strict";let t=(0,e.i(605993).default)("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);e.s(["default",0,t])},799916,853840,864255,991685,67667,733716,703550,492622,579767,978375,750110,772436,374435,e=>{"use strict";var t=e.i(375707);e.s(["ImageIcon",()=>t.default],799916);var n=e.i(605993);let r=(0,n.default)("list",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);e.s(["List",0,r],853840);let i=(0,n.default)("list-ordered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);e.s(["ListOrdered",0,i],864255);let o=(0,n.default)("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);e.s(["Minus",0,o],991685);let s=(0,n.default)("pilcrow-left",[["path",{d:"M14 3v11",key:"mlfb7b"}],["path",{d:"M14 9h-3a3 3 0 0 1 0-6h9",key:"1ulc19"}],["path",{d:"M18 3v11",key:"1phi0r"}],["path",{d:"M22 18H2l4-4",key:"yt65j9"}],["path",{d:"m6 22-4-4",key:"6jgyf5"}]]);e.s(["PilcrowLeft",0,s],67667);let a=(0,n.default)("pilcrow-right",[["path",{d:"M10 3v11",key:"o3l5kj"}],["path",{d:"M10 9H7a1 1 0 0 1 0-6h8",key:"1wb1nc"}],["path",{d:"M14 3v11",key:"mlfb7b"}],["path",{d:"m18 14 4 4H2",key:"4r8io1"}],["path",{d:"m22 18-4 4",key:"1hjjrd"}]]);e.s(["PilcrowRight",0,a],733716);let l=(0,n.default)("quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);e.s(["Quote",0,l],703550);let c=(0,n.default)("redo",[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]]);e.s(["Redo",0,c],492622);let d=(0,n.default)("undo",[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]]);e.s(["Undo",0,d],579767);let u=(0,n.default)("video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);e.s(["Video",0,u],978375);var h=e.i(44501),p=e.i(101685);e.i(380560);var f=e.i(206102),m=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let n=(0,f.createSlot)(`Primitive.${t}`),r=p.forwardRef((e,r)=>{let{asChild:i,...o}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,h.jsx)(i?n:t,{...o,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});e.s(["Primitive",0,m],750110);var g="horizontal",y=["horizontal","vertical"],b=p.forwardRef((e,t)=>{var n;let{decorative:r,orientation:i=g,...o}=e,s=(n=i,y.includes(n))?i:g;return(0,h.jsx)(m.div,{"data-orientation":s,...r?{role:"none"}:{"aria-orientation":"vertical"===s?s:void 0,role:"separator"},...o,ref:t})});b.displayName="Separator";var v=e.i(975157);let w=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>(0,h.jsx)(b,{ref:i,decorative:n,orientation:t,className:(0,v.cn)("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",e),...r}));w.displayName=b.displayName,e.s(["Separator",0,w],772436);let x=(0,n.default)("clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);e.s(["Clipboard",0,x],374435)},924782,e=>{"use strict";let t=(0,e.i(605993).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"}]]);e.s(["Upload",0,t],924782)},454184,(e,t,n)=>{class r{constructor(e){void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function i(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function o(e,...t){let n=Object.create(null);for(let t in e)n[t]=e[t];return t.forEach(function(e){for(let t in e)n[t]=e[t]}),n}class s{constructor(e,t){this.buffer="",this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=i(e)}openNode(e){if(!e.scope)return;let t=((e,{prefix:t})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){let n=e.split(".");return[`${t}${n.shift()}`,...n.map((e,t)=>`${e}${"_".repeat(t+1)}`)].join(" ")}return`${t}${e}`})(e.scope,{prefix:this.classPrefix});this.span(t)}closeNode(e){e.scope&&(this.buffer+="</span>")}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}}let a=(e={})=>{let t={children:[]};return Object.assign(t,e),t};class l{constructor(){this.rootNode=a(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){let t=a({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return"string"==typeof t?e.addText(t):t.children&&(e.openNode(t),t.children.forEach(t=>this._walk(e,t)),e.closeNode(t)),e}static _collapse(e){"string"==typeof e||e.children&&(e.children.every(e=>"string"==typeof e)?e.children=[e.children.join("")]:e.children.forEach(e=>{l._collapse(e)}))}}class c extends l{constructor(e){super(),this.options=e}addText(e){""!==e&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){let n=e.root;t&&(n.scope=`language:${t}`),this.add(n)}toHTML(){return new s(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function d(e){return e?"string"==typeof e?e:e.source:null}function u(e){return f("(?=",e,")")}function h(e){return f("(?:",e,")*")}function p(e){return f("(?:",e,")?")}function f(...e){return e.map(e=>d(e)).join("")}function m(...e){let t;return"("+(("object"==typeof(t=e[e.length-1])&&t.constructor===Object?(e.splice(e.length-1,1),t):{}).capture?"":"?:")+e.map(e=>d(e)).join("|")+")"}function g(e){return RegExp(e.toString()+"|").exec("").length-1}let y=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function b(e,{joinWith:t}){let n=0;return e.map(e=>{let t=n+=1,r=d(e),i="";for(;r.length>0;){let e=y.exec(r);if(!e){i+=r;break}i+=r.substring(0,e.index),r=r.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?i+="\\"+String(Number(e[1])+t):(i+=e[0],"("===e[0]&&n++)}return i}).map(e=>`(${e})`).join(t)}let v="[a-zA-Z]\\w*",w="[a-zA-Z_]\\w*",x="\\b\\d+(\\.\\d+)?",k="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",S="\\b(0b[01]+)",C={begin:"\\\\[\\s\\S]",relevance:0},E=function(e,t,n={}){let r=o({scope:"comment",begin:e,end:t,contains:[]},n);r.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let i=m("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:f(/[ ]+/,"(",i,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),r},M=E("//","$"),N=E("/\\*","\\*/"),A=E("#","$");var T=Object.freeze({__proto__:null,APOS_STRING_MODE:{scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[C]},BACKSLASH_ESCAPE:C,BINARY_NUMBER_MODE:{scope:"number",begin:S,relevance:0},BINARY_NUMBER_RE:S,COMMENT:E,C_BLOCK_COMMENT_MODE:N,C_LINE_COMMENT_MODE:M,C_NUMBER_MODE:{scope:"number",begin:k,relevance:0},C_NUMBER_RE:k,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}})},HASH_COMMENT_MODE:A,IDENT_RE:v,MATCH_NOTHING_RE:/\b\B/,METHOD_GUARD:{begin:"\\.\\s*"+w,relevance:0},NUMBER_MODE:{scope:"number",begin:x,relevance:0},NUMBER_RE:x,PHRASAL_WORDS_MODE:{begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},QUOTE_STRING_MODE:{scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[C]},REGEXP_MODE:{scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[C,{begin:/\[/,end:/\]/,relevance:0,contains:[C]}]},RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",SHEBANG:(e={})=>{let t=/^#![ ]*\//;return e.binary&&(e.begin=f(t,/.*\b/,e.binary,/\b.*/)),o({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{0!==e.index&&t.ignoreMatch()}},e)},TITLE_MODE:{scope:"title",begin:v,relevance:0},UNDERSCORE_IDENT_RE:w,UNDERSCORE_TITLE_MODE:{scope:"title",begin:w,relevance:0}});function R(e,t){"."===e.input[e.index-1]&&t.ignoreMatch()}function O(e,t){void 0!==e.className&&(e.scope=e.className,delete e.className)}function D(e,t){!t||e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=R,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,void 0===e.relevance&&(e.relevance=0))}function j(e,t){Array.isArray(e.illegal)&&(e.illegal=m(...e.illegal))}function I(e,t){if(e.match){if(e.begin||e.end)throw Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function P(e,t){void 0===e.relevance&&(e.relevance=1)}let L=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw Error("beforeMatch cannot be used with starts");let n=Object.assign({},e);Object.keys(e).forEach(t=>{delete e[t]}),e.keywords=n.keywords,e.begin=f(n.beforeMatch,u(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},z=["of","and","for","in","not","or","if","then","parent","list","value"],_={},$=e=>{console.error(e)},H=(e,...t)=>{console.log(`WARN: ${e}`,...t)},B=(e,t)=>{_[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),_[`${e}/${t}`]=!0)},F=Error();function V(e,t,{key:n}){let r=0,i=e[n],o={},s={};for(let e=1;e<=t.length;e++)s[e+r]=i[e],o[e+r]=!0,r+=g(t[e-1]);e[n]=s,e[n]._emit=o,e[n]._multi=!0}function U(e){if(e.scope&&"object"==typeof e.scope&&null!==e.scope&&(e.beginScope=e.scope,delete e.scope),"string"==typeof e.beginScope&&(e.beginScope={_wrap:e.beginScope}),"string"==typeof e.endScope&&(e.endScope={_wrap:e.endScope}),Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw $("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),F;if("object"!=typeof e.beginScope||null===e.beginScope)throw $("beginScope must be object"),F;V(e,e.begin,{key:"beginScope"}),e.begin=b(e.begin,{joinWith:""})}if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw $("skip, excludeEnd, returnEnd not compatible with endScope: {}"),F;if("object"!=typeof e.endScope||null===e.endScope)throw $("endScope must be object"),F;V(e,e.end,{key:"endScope"}),e.end=b(e.end,{joinWith:""})}}class W extends Error{constructor(e,t){super(e),this.name="HTMLInjectionError",this.html=t}}let K=Symbol("nomatch"),q=function(e){let t=Object.create(null),n=Object.create(null),s=[],a=!0,l="Could not find the language '{}', did you forget to load/include a language module?",y={disableAutodetect:!0,name:"Plain text",contains:[]},v={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:c};function w(e){return v.noHighlightRe.test(e)}function x(e,t,n){let r="",i="";"object"==typeof t?(r=e,n=t.ignoreIllegals,i=t.language):(B("10.7.0","highlight(lang, code, ...args) has been deprecated."),B("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"),i=e,r=t),void 0===n&&(n=!0);let o={code:r,language:i};_("before:highlight",o);let s=o.result?o.result:k(o.language,o.code,n);return s.code=o.code,_("after:highlight",s),s}function k(e,n,s,c){let u=Object.create(null);function h(){if(!A.keywords)return void R.addText(H);let e=0;A.keywordPatternRe.lastIndex=0;let t=A.keywordPatternRe.exec(H),n="";for(;t;){n+=H.substring(e,t.index);let r=C.case_insensitive?t[0].toLowerCase():t[0],i=A.keywords[r];if(i){let[e,o]=i;if(R.addText(n),n="",u[r]=(u[r]||0)+1,u[r]<=7&&(B+=o),e.startsWith("_"))n+=t[0];else{let n=C.classNameAliases[e]||e;f(t[0],n)}}else n+=t[0];e=A.keywordPatternRe.lastIndex,t=A.keywordPatternRe.exec(H)}n+=H.substring(e),R.addText(n)}function p(){null!=A.subLanguage?function(){if(""===H)return;let e=null;if("string"==typeof A.subLanguage){if(!t[A.subLanguage])return R.addText(H);e=k(A.subLanguage,H,!0,T[A.subLanguage]),T[A.subLanguage]=e._top}else e=S(H,A.subLanguage.length?A.subLanguage:null);A.relevance>0&&(B+=e.relevance),R.__addSublanguage(e._emitter,e.language)}():h(),H=""}function f(e,t){""!==e&&(R.startScope(t),R.addText(e),R.endScope())}function m(e,t){let n=1,r=t.length-1;for(;n<=r;){if(!e._emit[n]){n++;continue}let r=C.classNameAliases[e[n]]||e[n],i=t[n];r?f(i,r):(H=i,h(),H=""),n++}}function y(e,t){return e.scope&&"string"==typeof e.scope&&R.openNode(C.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(f(H,C.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),H=""):e.beginScope._multi&&(m(e.beginScope,t),H="")),A=Object.create(e,{parent:{value:A}})}let w={};function x(t,i){let o=i&&i[0];if(H+=t,null==o)return p(),0;if("begin"===w.type&&"end"===i.type&&w.index===i.index&&""===o){if(H+=n.slice(i.index,i.index+1),!a){let t=Error(`0 width match regex (${e})`);throw t.languageName=e,t.badRule=w.rule,t}return 1}if(w=i,"begin"===i.type){let e=i[0],t=i.rule,n=new r(t);for(let r of[t.__beforeBegin,t["on:begin"]])if(r&&(r(i,n),n.isMatchIgnored))return 0===A.matcher.regexIndex?(H+=e[0],1):(W=!0,0);return t.skip?H+=e:(t.excludeBegin&&(H+=e),p(),t.returnBegin||t.excludeBegin||(H=e)),y(t,i),t.returnBegin?0:e.length}if("illegal"!==i.type||s){if("end"===i.type){let e=function(e){let t=e[0],i=n.substring(e.index),o=function e(t,n,i){var o;let s,a=(o=t.endRe,(s=o&&o.exec(i))&&0===s.index);if(a){if(t["on:end"]){let e=new r(t);t["on:end"](n,e),e.isMatchIgnored&&(a=!1)}if(a){for(;t.endsParent&&t.parent;)t=t.parent;return t}}if(t.endsWithParent)return e(t.parent,n,i)}(A,e,i);if(!o)return K;let s=A;A.endScope&&A.endScope._wrap?(p(),f(t,A.endScope._wrap)):A.endScope&&A.endScope._multi?(p(),m(A.endScope,e)):s.skip?H+=t:(s.returnEnd||s.excludeEnd||(H+=t),p(),s.excludeEnd&&(H=t));do A.scope&&R.closeNode(),A.skip||A.subLanguage||(B+=A.relevance),A=A.parent;while(A!==o.parent)return o.starts&&y(o.starts,e),s.returnEnd?0:t.length}(i);if(e!==K)return e}}else{let e=Error('Illegal lexeme "'+o+'" for mode "'+(A.scope||"<unnamed>")+'"');throw e.mode=A,e}if("illegal"===i.type&&""===o)return H+="\n",1;if(V>1e5&&V>3*i.index)throw Error("potential infinite loop, way more iterations than matches");return H+=o,o.length}let C=N(e);if(!C)throw $(l.replace("{}",e)),Error('Unknown language: "'+e+'"');let E=function(e){function t(t,n){return RegExp(d(t),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(n?"g":""))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,t){t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),this.matchAt+=g(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null);let e=this.regexes.map(e=>e[1]);this.matcherRe=t(b(e,{joinWith:"|"}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;let t=this.matcherRe.exec(e);if(!t)return null;let n=t.findIndex((e,t)=>t>0&&void 0!==e),r=this.matchIndexes[n];return t.splice(0,n),Object.assign(t,r)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];let t=new n;return this.rules.slice(e).forEach(([e,n])=>t.addRule(e,n)),t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,t){this.rules.push([e,t]),"begin"===t.type&&this.count++}exec(e){let t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex;let n=t.exec(e);if(this.resumingScanAtSamePosition())if(n&&n.index===this.lastIndex);else{let t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)}return n&&(this.regexIndex+=n.position+1,this.regexIndex===this.count&&this.considerAll()),n}}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes("self"))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=o(e.classNameAliases||{}),function n(i,s){let a;if(i.isCompiled)return i;[O,I,U,L].forEach(e=>e(i,s)),e.compilerExtensions.forEach(e=>e(i,s)),i.__beforeBegin=null,[D,j,P].forEach(e=>e(i,s)),i.isCompiled=!0;let l=null;return"object"==typeof i.keywords&&i.keywords.$pattern&&(i.keywords=Object.assign({},i.keywords),l=i.keywords.$pattern,delete i.keywords.$pattern),l=l||/\w+/,i.keywords&&(i.keywords=function e(t,n,r="keyword"){let i=Object.create(null);return"string"==typeof t?o(r,t.split(" ")):Array.isArray(t)?o(r,t):Object.keys(t).forEach(function(r){Object.assign(i,e(t[r],n,r))}),i;function o(e,t){n&&(t=t.map(e=>e.toLowerCase())),t.forEach(function(t){var n,r,o;let s=t.split("|");i[s[0]]=[e,(n=s[0],(r=s[1])?Number(r):+(o=n,!z.includes(o.toLowerCase())))]})}}(i.keywords,e.case_insensitive)),i.keywordPatternRe=t(l,!0),s&&(i.begin||(i.begin=/\B|\b/),i.beginRe=t(i.begin),i.end||i.endsWithParent||(i.end=/\B|\b/),i.end&&(i.endRe=t(i.end)),i.terminatorEnd=d(i.end)||"",i.endsWithParent&&s.terminatorEnd&&(i.terminatorEnd+=(i.end?"|":"")+s.terminatorEnd)),i.illegal&&(i.illegalRe=t(i.illegal)),i.contains||(i.contains=[]),i.contains=[].concat(...i.contains.map(function(e){var t;return((t="self"===e?i:e).variants&&!t.cachedVariants&&(t.cachedVariants=t.variants.map(function(e){return o(t,{variants:null},e)})),t.cachedVariants)?t.cachedVariants:!function e(t){return!!t&&(t.endsWithParent||e(t.starts))}(t)?Object.isFrozen(t)?o(t):t:o(t,{starts:t.starts?o(t.starts):null})})),i.contains.forEach(function(e){n(e,i)}),i.starts&&n(i.starts,s),a=new r,i.contains.forEach(e=>a.addRule(e.begin,{rule:e,type:"begin"})),i.terminatorEnd&&a.addRule(i.terminatorEnd,{type:"end"}),i.illegal&&a.addRule(i.illegal,{type:"illegal"}),i.matcher=a,i}(e)}(C),M="",A=c||E,T={},R=new v.__emitter(v),_=[];for(let e=A;e!==C;e=e.parent)e.scope&&_.unshift(e.scope);_.forEach(e=>R.openNode(e));let H="",B=0,F=0,V=0,W=!1;try{if(C.__emitTokens)C.__emitTokens(n,R);else{for(A.matcher.considerAll();;){V++,W?W=!1:A.matcher.considerAll(),A.matcher.lastIndex=F;let e=A.matcher.exec(n);if(!e)break;let t=n.substring(F,e.index),r=x(t,e);F=e.index+r}x(n.substring(F))}return R.finalize(),M=R.toHTML(),{language:e,value:M,relevance:B,illegal:!1,_emitter:R,_top:A}}catch(t){if(t.message&&t.message.includes("Illegal"))return{language:e,value:i(n),illegal:!0,relevance:0,_illegalBy:{message:t.message,index:F,context:n.slice(F-100,F+100),mode:t.mode,resultSoFar:M},_emitter:R};if(a)return{language:e,value:i(n),illegal:!1,relevance:0,errorRaised:t,_emitter:R,_top:A};throw t}}function S(e,n){let r;n=n||v.languages||Object.keys(t);let o=((r={value:i(e),illegal:!1,relevance:0,_top:y,_emitter:new v.__emitter(v)})._emitter.addText(e),r),s=n.filter(N).filter(R).map(t=>k(t,e,!1));s.unshift(o);let[a,l]=s.sort((e,t)=>{if(e.relevance!==t.relevance)return t.relevance-e.relevance;if(e.language&&t.language){if(N(e.language).supersetOf===t.language)return 1;else if(N(t.language).supersetOf===e.language)return -1}return 0});return a.secondBest=l,a}function C(e){var t;let r,i=function(e){let t=e.className+" ";t+=e.parentNode?e.parentNode.className:"";let n=v.languageDetectRe.exec(t);if(n){let t=N(n[1]);return t||(H(l.replace("{}",n[1])),H("Falling back to no-highlight mode for this block.",e)),t?n[1]:"no-highlight"}return t.split(/\s+/).find(e=>w(e)||N(e))}(e);if(w(i))return;if(_("before:highlightElement",{el:e,language:i}),e.dataset.highlighted)return void console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);if(e.children.length>0&&(v.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(e)),v.throwUnescapedHTML))throw new W("One of your code blocks includes unescaped HTML.",e.innerHTML);let o=e.textContent,s=i?x(o,{language:i,ignoreIllegals:!0}):S(o);e.innerHTML=s.value,e.dataset.highlighted="yes",t=s.language,r=i&&n[i]||t,e.classList.add("hljs"),e.classList.add(`language-${r}`),e.result={language:s.language,re:s.relevance,relevance:s.relevance},s.secondBest&&(e.secondBest={language:s.secondBest.language,relevance:s.secondBest.relevance}),_("after:highlightElement",{el:e,result:s,text:o})}let E=!1;function M(){if("loading"===document.readyState){E||window.addEventListener("DOMContentLoaded",function(){M()},!1),E=!0;return}document.querySelectorAll(v.cssSelector).forEach(C)}function N(e){return t[e=(e||"").toLowerCase()]||t[n[e]]}function A(e,{languageName:t}){"string"==typeof e&&(e=[e]),e.forEach(e=>{n[e.toLowerCase()]=t})}function R(e){let t=N(e);return t&&!t.disableAutodetect}function _(e,t){s.forEach(function(n){n[e]&&n[e](t)})}for(let r in Object.assign(e,{highlight:x,highlightAuto:S,highlightAll:M,highlightElement:C,highlightBlock:function(e){return B("10.7.0","highlightBlock will be removed entirely in v12.0"),B("10.7.0","Please use highlightElement now."),C(e)},configure:function(e){v=o(v,e)},initHighlighting:()=>{M(),B("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")},initHighlightingOnLoad:function(){M(),B("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")},registerLanguage:function(n,r){let i=null;try{i=r(e)}catch(e){if($("Language definition for '{}' could not be registered.".replace("{}",n)),a)$(e);else throw e;i=y}i.name||(i.name=n),t[n]=i,i.rawDefinition=r.bind(null,e),i.aliases&&A(i.aliases,{languageName:n})},unregisterLanguage:function(e){for(let r of(delete t[e],Object.keys(n)))n[r]===e&&delete n[r]},listLanguages:function(){return Object.keys(t)},getLanguage:N,registerAliases:A,autoDetection:R,inherit:o,addPlugin:function(e){var t;(t=e)["before:highlightBlock"]&&!t["before:highlightElement"]&&(t["before:highlightElement"]=e=>{t["before:highlightBlock"](Object.assign({block:e.el},e))}),t["after:highlightBlock"]&&!t["after:highlightElement"]&&(t["after:highlightElement"]=e=>{t["after:highlightBlock"](Object.assign({block:e.el},e))}),s.push(e)},removePlugin:function(e){let t=s.indexOf(e);-1!==t&&s.splice(t,1)}}),e.debugMode=function(){a=!1},e.safeMode=function(){a=!0},e.versionString="11.11.1",e.regex={concat:f,lookahead:u,either:m,optional:p,anyNumberOfTimes:h},T)"object"==typeof T[r]&&function e(t){return t instanceof Map?t.clear=t.delete=t.set=function(){throw Error("map is read-only")}:t instanceof Set&&(t.add=t.clear=t.delete=function(){throw Error("set is read-only")}),Object.freeze(t),Object.getOwnPropertyNames(t).forEach(n=>{let r=t[n],i=typeof r;"object"!==i&&"function"!==i||Object.isFrozen(r)||e(r)}),t}(T[r]);return Object.assign(e,T),e},J=q({});J.newInstance=()=>q({}),t.exports=J,J.HighlightJS=J,J.default=J},240409,512527,944404,334609,265590,441228,576500,194633,32033,623568,42420,278909,532270,503658,185503,993667,314206,388503,284766,965837,582966,25688,770271,e=>{"use strict";var t=e.i(44501),n=e.i(580330),r=e.i(792934),i=e.i(85741),o=e.i(464675),s=e.i(419943),a=e.i(987027),l=e.i(307154),c=e.i(10137),d=e.i(674155),u=e.i(148623),h=e.i(395330),p=e.i(398441),f=e.i(977112),m=e.i(799916),g=e.i(425275),y=e.i(702166),b=e.i(853840),v=e.i(864255),w=e.i(991685),x=e.i(67667),k=e.i(733716),S=e.i(703550),C=e.i(492622),E=e.i(253190),M=e.i(73313),N=e.i(736586),A=e.i(132807),T=e.i(579767),R=e.i(978375),O=e.i(101685),D=e.i(772436),j=e.i(975157),I=e.i(96701),P=e.i(933850),L=e.i(374435),z=e.i(924782),_=e.i(671485);async function $(e,t){let n=new FormData;n.append("file",t);try{let t=await (0,_.wsFetch)(`/api/upload/${e}`,{method:"POST",body:n});if(!t.ok)return null;let r=await t.json();return{url:(0,_.withWs)(r.url),filename:r.filename}}catch{return null}}function H({kind:e,pagePath:n,onCancel:r,onInsert:i,anchor:o}){let[s,a]=(0,O.useState)("upload"),[l,c]=(0,O.useState)(""),[d,u]=(0,O.useState)(!1),[h,p]=(0,O.useState)(null),f=(0,O.useRef)(null),m=async e=>{if(e&&0!==e.length){u(!0),p(null);try{let t=e[0],r=await $(n,t);if(!r)return void p("Upload failed.");i({url:r.url,alt:t.name,mimeType:t.type})}finally{u(!1)}}},g=()=>{let e=l.trim();e&&i({url:e})};return(0,t.jsxs)("div",{className:"absolute z-50 w-[360px] bg-popover border border-border rounded-xl shadow-e-4 overflow-hidden",style:{top:o.top,left:o.left},onMouseDown:e=>e.stopPropagation(),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[(0,t.jsx)("div",{className:"text-[12px] font-medium",children:"image"===e?"Insert image":"video"===e?"Insert video":"Attach file"}),(0,t.jsx)("button",{type:"button",onClick:r,className:"text-[11px] text-muted-foreground hover:text-foreground",children:"Cancel"})]}),(0,t.jsxs)("div",{className:"flex border-b border-border bg-muted/30",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>a("upload"),className:(0,j.cn)("flex-1 py-1.5 text-[11px] flex items-center justify-center gap-1.5 transition-colors","upload"===s?"bg-background text-foreground border-b-2 border-primary":"text-muted-foreground hover:text-foreground"),children:[(0,t.jsx)(z.Upload,{className:"w-3 h-3"})," Upload"]}),(0,t.jsxs)("button",{type:"button",onClick:()=>a("url"),className:(0,j.cn)("flex-1 py-1.5 text-[11px] flex items-center justify-center gap-1.5 transition-colors","url"===s?"bg-background text-foreground border-b-2 border-primary":"text-muted-foreground hover:text-foreground"),children:[(0,t.jsx)(y.Link,{className:"w-3 h-3"})," From URL"]})]}),"upload"===s?(0,t.jsxs)("div",{className:"p-4",onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),m(e.dataTransfer.files)},children:[(0,t.jsxs)("button",{type:"button",onClick:()=>f.current?.click(),disabled:d,className:"w-full border-2 border-dashed border-border rounded-sm py-6 flex flex-col items-center justify-center text-muted-foreground hover:bg-accent/30 transition-colors",children:[(0,t.jsx)(z.Upload,{className:"w-5 h-5 mb-1.5"}),(0,t.jsx)("span",{className:"text-[12px] font-medium",children:d?"Uploading…":`Click to upload ${e}`}),(0,t.jsx)("span",{className:"text-[10px] mt-0.5",children:"or drop a file here"})]}),(0,t.jsx)("input",{ref:f,type:"file",accept:"image"===e?"image/*":"video"===e?"video/*":"*/*",className:"hidden",onChange:e=>m(e.target.files)}),h&&(0,t.jsx)("div",{className:"mt-2 text-[11px] text-destructive",children:h})]}):(0,t.jsxs)("div",{className:"p-3 space-y-2",children:[(0,t.jsx)("input",{type:"url",autoFocus:!0,value:l,placeholder:"image"===e?"https://example.com/image.png":"video"===e?"https://example.com/video.mp4":"https://example.com/file",onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),g()):"Escape"===e.key&&r()},className:"w-full bg-background border border-border rounded-sm px-2.5 py-1.5 text-[12px] focus:outline-none focus:ring-2 focus:ring-primary/30"}),(0,t.jsx)("button",{type:"button",onClick:g,disabled:!l.trim(),className:"w-full py-1.5 text-[12px] rounded-sm bg-primary text-primary-foreground disabled:opacity-50 hover:bg-primary/90",children:"Insert"})]}),(0,t.jsxs)("div",{className:"px-3 py-2 border-t border-border bg-muted/30 text-[10px] text-muted-foreground flex items-start gap-1.5",children:[(0,t.jsx)(L.Clipboard,{className:"w-3 h-3 shrink-0 mt-[1px]"}),(0,t.jsxs)("span",{children:["Tip: you can also"," ",(0,t.jsx)("strong",{className:"text-foreground/80",children:"paste"})," or"," ",(0,t.jsx)("strong",{className:"text-foreground/80",children:"drag & drop"}),"files directly into the page — they'll be saved alongside this page automatically."]})]})]})}function B({label:e,icon:n,active:r,disabled:i,style:o,onAction:s}){return(0,t.jsx)("button",{type:"button","aria-label":e,title:e,disabled:i,style:o,onMouseDown:e=>{e.preventDefault()},onClick:e=>{e.preventDefault(),s(e)},className:(0,j.cn)("h-8 w-8 shrink-0 inline-flex items-center justify-center rounded-md text-foreground/80 hover:bg-accent hover:text-accent-foreground transition-colors disabled:opacity-40",r&&"bg-accent text-accent-foreground ring-1 ring-inset ring-foreground/15"),children:(0,t.jsx)(n,{className:"h-4 w-4"})})}function F({onClose:e}){return(0,O.useEffect)(()=>{let t=window.setTimeout(()=>{let t=t=>{let n=t.target;n?.closest('[data-editor-popover="true"]')||e()};window.addEventListener("mousedown",t),window.__editorPopClose=()=>window.removeEventListener("mousedown",t)},10);return()=>{window.clearTimeout(t);let e=window;e.__editorPopClose&&(e.__editorPopClose(),e.__editorPopClose=void 0)}},[e]),null}e.s(["MediaPopover",0,H],512527),e.s(["EditorToolbar",0,function({editor:e}){let j=(0,I.useEditorStore)(e=>e.frontmatter),L=(0,I.useEditorStore)(e=>e.updateFrontmatter),z=(0,I.useEditorStore)(e=>e.currentPath),_=j?.dir==="rtl",[$,V]=(0,O.useState)(null),U=(0,O.useRef)(null),[W,K]=(0,O.useState)(!1),[q,J]=(0,O.useState)(!1),[,G]=(0,O.useState)(0);(0,O.useEffect)(()=>{if(!e)return;let t=()=>G(e=>e+1);return e.on("selectionUpdate",t),e.on("transaction",t),()=>{e.off("selectionUpdate",t),e.off("transaction",t)}},[e]);let X=(0,O.useCallback)(()=>{let e=U.current;e&&(K(e.scrollLeft>4),J(e.scrollLeft+e.clientWidth<e.scrollWidth-4))},[]);(0,O.useEffect)(()=>{if(!e)return;let t=U.current;if(!t)return;let n=requestAnimationFrame(X),r=()=>X();window.addEventListener("resize",r),t.addEventListener("scroll",X);let i=new ResizeObserver(()=>X());for(let e of(i.observe(t),Array.from(t.children)))i.observe(e);return()=>{cancelAnimationFrame(n),window.removeEventListener("resize",r),t.removeEventListener("scroll",X),i.disconnect()}},[e,X]);let Z=e=>{let t=U.current;t&&t.scrollBy({left:e*Math.max(160,.6*t.clientWidth),behavior:"smooth"})};if(!e)return null;let Y=(t,n)=>{e.chain().focus().setTextSelection(t).run(),n()},Q=(t,n)=>{let r=t.currentTarget.getBoundingClientRect();V(n({top:r.bottom+6,left:r.left},(()=>{let{from:t,to:n}=e.state.selection;return{from:t,to:n}})()))},ee=[{icon:h.Heading1,action:()=>e.chain().focus().toggleHeading({level:1}).run(),isActive:e.isActive("heading",{level:1}),label:"Heading 1"},{icon:p.Heading2,action:()=>e.chain().focus().toggleHeading({level:2}).run(),isActive:e.isActive("heading",{level:2}),label:"Heading 2"},{icon:f.Heading3,action:()=>e.chain().focus().toggleHeading({level:3}).run(),isActive:e.isActive("heading",{level:3}),label:"Heading 3"},{separator:!0},{icon:s.Bold,action:()=>e.chain().focus().toggleBold().run(),isActive:e.isActive("bold"),label:"Bold"},{icon:g.Italic,action:()=>e.chain().focus().toggleItalic().run(),isActive:e.isActive("italic"),label:"Italic"},{icon:A.Underline,action:()=>e.chain().focus().toggleUnderline().run(),isActive:e.isActive("underline"),label:"Underline"},{icon:E.Strikethrough,action:()=>e.chain().focus().toggleStrike().run(),isActive:e.isActive("strike"),label:"Strikethrough"},{icon:d.Code,action:()=>e.chain().focus().toggleCode().run(),isActive:e.isActive("code"),label:"Inline code"},{icon:y.Link,action:t=>{let n=e.getAttributes("link")?.href??"";Q(t,(e,t)=>({type:"link",anchor:e,range:t,existing:n}))},isActive:e.isActive("link"),label:"Link"},{separator:!0},{icon:b.List,action:()=>e.chain().focus().toggleBulletList().run(),isActive:e.isActive("bulletList"),label:"Bullet list"},{icon:v.ListOrdered,action:()=>e.chain().focus().toggleOrderedList().run(),isActive:e.isActive("orderedList"),label:"Ordered list"},{icon:S.Quote,action:()=>e.chain().focus().toggleBlockquote().run(),isActive:e.isActive("blockquote"),label:"Blockquote"},{icon:a.CheckSquare,action:()=>e.chain().focus().toggleTaskList().run(),isActive:e.isActive("taskList"),label:"Checklist"},{icon:u.FileCode,action:()=>e.chain().focus().toggleCodeBlock().run(),isActive:e.isActive("codeBlock"),label:"Code block"},{icon:w.Minus,action:()=>e.chain().focus().setHorizontalRule().run(),isActive:!1,label:"Divider"}],et=[{icon:i.AlignLeft,action:()=>e.chain().focus().setTextAlign("left").run(),isActive:e.isActive({textAlign:"left"}),label:"Align left"},{icon:n.AlignCenter,action:()=>e.chain().focus().setTextAlign("center").run(),isActive:e.isActive({textAlign:"center"}),label:"Align center"},{icon:o.AlignRight,action:()=>e.chain().focus().setTextAlign("right").run(),isActive:e.isActive({textAlign:"right"}),label:"Align right"},{icon:r.AlignJustify,action:()=>e.chain().focus().setTextAlign("justify").run(),isActive:e.isActive({textAlign:"justify"}),label:"Justify"},{separator:!0},{icon:N.Superscript,action:()=>e.chain().focus().toggleSuperscript().run(),isActive:e.isActive("superscript"),label:"Superscript"},{icon:M.Subscript,action:()=>e.chain().focus().toggleSubscript().run(),isActive:e.isActive("subscript"),label:"Subscript"},{separator:!0},{icon:m.ImageIcon,action:e=>Q(e,e=>({type:"media",kind:"image",anchor:e})),isActive:!1,label:"Insert image"},{icon:R.Video,action:e=>Q(e,e=>({type:"media",kind:"video",anchor:e})),isActive:!1,label:"Insert video"},{separator:!0},{icon:T.Undo,action:()=>e.chain().focus().undo().run(),isActive:!1,label:"Undo"},{icon:C.Redo,action:()=>e.chain().focus().redo().run(),isActive:!1,label:"Redo"},{separator:!0},{icon:_?x.PilcrowLeft:k.PilcrowRight,action:()=>L({dir:_?void 0:"rtl"}),isActive:_,label:_?"Switch to LTR":"Switch to RTL"}];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"relative border-b border-border bg-background/50",children:[W&&(0,t.jsx)("button",{type:"button","aria-label":"Scroll toolbar left",onMouseDown:e=>e.preventDefault(),onClick:()=>Z(-1),className:"absolute left-0 top-0 bottom-0 w-6 z-10 flex items-center justify-start pl-0.5 bg-gradient-to-r from-background via-background/80 to-transparent text-muted-foreground hover:text-foreground transition-colors",children:(0,t.jsx)(l.ChevronLeft,{className:"h-4 w-4"})}),q&&(0,t.jsx)("button",{type:"button","aria-label":"Scroll toolbar right",onMouseDown:e=>e.preventDefault(),onClick:()=>Z(1),className:"absolute right-0 top-0 bottom-0 w-6 z-10 flex items-center justify-end pr-0.5 bg-gradient-to-l from-background via-background/80 to-transparent text-muted-foreground hover:text-foreground transition-colors",children:(0,t.jsx)(c.ChevronRight,{className:"h-4 w-4"})}),(0,t.jsx)("div",{ref:U,onWheel:e=>{let t=U.current;t&&Math.abs(e.deltaY)>Math.abs(e.deltaX)&&(t.scrollLeft+=e.deltaY)},className:"flex items-center gap-0.5 px-2 pt-1 pb-1.5 overflow-x-scroll overflow-y-hidden editor-toolbar-scroll",children:[...ee,{separator:!0},...et].map((e,n)=>"separator"in e?(0,t.jsx)(D.Separator,{orientation:"vertical",className:"mx-1 h-6 shrink-0"},n):(0,t.jsx)(B,{label:e.label,icon:e.icon,active:e.isActive,style:e.style,onAction:e.action},n))})]}),$?.type==="link"&&(0,t.jsx)("div",{"data-editor-popover":"true",style:{position:"fixed",top:$.anchor.top,left:$.anchor.left,zIndex:60},children:(0,t.jsx)(P.LinkPopover,{anchor:{top:0,left:0},initialUrl:$.existing,onCancel:()=>V(null),onApply:t=>{$?.type==="link"&&(Y($.range,()=>{e.chain().focus().extendMarkRange("link").setLink({href:t}).run()}),V(null))},onRemove:$.existing?()=>{$?.type==="link"&&(Y($.range,()=>{e.chain().focus().unsetLink().run()}),V(null))}:void 0})}),$?.type==="media"&&z&&(0,t.jsx)("div",{"data-editor-popover":"true",style:{position:"fixed",top:$.anchor.top,left:$.anchor.left,zIndex:60},children:(0,t.jsx)(H,{kind:$.kind,pagePath:z,anchor:{top:0,left:0},onCancel:()=>V(null),onInsert:t=>((t,n)=>{let{url:r,alt:i,mimeType:o}=n;"image"===t||(o??"").startsWith("image/")||/\.(png|jpe?g|gif|webp|svg|avif)(\?|$)/i.test(r)?e.chain().focus().setImage({src:r,alt:i??""}).run():e.chain().focus().insertContent(`<a href="${r}">${i??r}</a>`).run(),V(null)})($.kind,t)})}),$&&(0,t.jsx)(F,{onClose:()=>V(null)})]})}],240409);var V=e.i(343603),U=e.i(111092),W=/^```([a-z]+)?[\s\n]$/,K=/^~~~([a-z]+)?[\s\n]$/,q=V.Node.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:e=>{var t;let{languageClassPrefix:n}=this.options;if(!n)return null;let r=[...(null==(t=e.firstElementChild)?void 0:t.classList)||[]].filter(e=>e.startsWith(n)).map(e=>e.replace(n,""))[0];return r||null},rendered:!1}}},parseHTML:()=>[{tag:"pre",preserveWhitespace:"full"}],renderHTML({node:e,HTMLAttributes:t}){return["pre",(0,V.mergeAttributes)(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(e,t)=>{var n,r;return(null==(n=e.raw)?void 0:n.startsWith("```"))===!1&&(null==(r=e.raw)?void 0:r.startsWith("~~~"))===!1&&"indented"!==e.codeBlockStyle?[]:t.createNode("codeBlock",{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[])},renderMarkdown:(e,t)=>{var n;let r=(null==(n=e.attrs)?void 0:n.language)||"";return e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join("\n"):`\`\`\`${r}
99
99
 
100
100
  \`\`\``},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=1===t.pos;return!!e&&t.parent.type.name===this.name&&(!!n||!t.parent.textContent.length)&&this.editor.commands.clearNodes()},Tab:({editor:e})=>{var t;if(!this.options.enableTabIndentation)return!1;let n=null!=(t=this.options.tabSize)?t:4,{state:r}=e,{selection:i}=r,{$from:o,empty:s}=i;if(o.parent.type!==this.type)return!1;let a=" ".repeat(n);return s?e.commands.insertContent(a):e.commands.command(({tr:e})=>{let{from:t,to:n}=i,o=r.doc.textBetween(t,n,"\n","\n").split("\n").map(e=>a+e).join("\n");return e.replaceWith(t,n,r.schema.text(o)),!0})},"Shift-Tab":({editor:e})=>{var t;if(!this.options.enableTabIndentation)return!1;let n=null!=(t=this.options.tabSize)?t:4,{state:r}=e,{selection:i}=r,{$from:o,empty:s}=i;return o.parent.type===this.type&&(s?e.commands.command(({tr:e})=>{var t;let{pos:i}=o,s=o.start(),a=o.end(),l=r.doc.textBetween(s,a,"\n","\n").split("\n"),c=0,d=0,u=i-s;for(let e=0;e<l.length;e+=1){if(d+l[e].length>=u){c=e;break}d+=l[e].length+1}let h=Math.min(((null==(t=l[c].match(/^ */))?void 0:t[0])||"").length,n);if(0===h)return!0;let p=s;for(let e=0;e<c;e+=1)p+=l[e].length+1;return e.delete(p,p+h),i-p<=h&&e.setSelection(U.TextSelection.create(e.doc,p)),!0}):e.commands.command(({tr:e})=>{let{from:t,to:o}=i,s=r.doc.textBetween(t,o,"\n","\n").split("\n").map(e=>{var t;let r=Math.min(((null==(t=e.match(/^ */))?void 0:t[0])||"").length,n);return e.slice(r)}).join("\n");return e.replaceWith(t,o,r.schema.text(s)),!0}))},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;let o=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith("\n\n");return!!o&&!!s&&e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:o}=n;if(!o||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let s=i.after();return void 0!==s&&(r.nodeAt(s)?e.commands.command(({tr:e})=>(e.setSelection(U.Selection.near(r.resolve(s))),!0)):e.commands.exitCode())}}},addInputRules(){return[(0,V.textblockTypeInputRule)({find:W,type:this.type,getAttributes:e=>({language:e[1]})}),(0,V.textblockTypeInputRule)({find:K,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new U.Plugin({key:new U.PluginKey("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,o=null==i?void 0:i.mode;if(!n||!o)return!1;let{tr:s,schema:a}=e.state,l=a.text(n.replace(/\r\n?/g,"\n"));return s.replaceSelectionWith(this.type.create({language:o},l)),s.selection.$from.parent.type!==this.type&&s.setSelection(U.TextSelection.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),e.dispatch(s),!0}}})]}}),J=e.i(362615);let G=e.i(454184).default;function X(e){return e.value||e.children||[]}function Z({doc:e,name:t,lowlight:n,defaultLanguage:r}){let i=[];return(0,V.findChildren)(e,e=>e.type.name===t).forEach(e=>{var t;let o=e.pos+1,s=e.node.attrs.language||r,a=n.listLanguages();(function e(t,n=[]){return t.flatMap(t=>{let r=[...n,...t.properties?t.properties.className:[]];return t.children?e(t.children,r):{text:t.value,classes:r}})})(s&&(a.includes(s)||G.getLanguage(s)||(null==(t=n.registered)?void 0:t.call(n,s)))?X(n.highlight(s,e.node.textContent)):X(n.highlightAuto(e.node.textContent))).forEach(e=>{let t=o+e.text.length;if(e.classes.length){let n=J.Decoration.inline(o,t,{class:e.classes.join(" ")});i.push(n)}o=t})}),J.DecorationSet.create(e,i)}var Y=q.extend({addOptions(){var e;return{...null==(e=this.parent)?void 0:e.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},addProseMirrorPlugins(){var e;return[...(null==(e=this.parent)?void 0:e.call(this))||[],function({name:e,lowlight:t,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(e=>"function"==typeof t[e]))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");let r=new U.Plugin({key:new U.PluginKey("lowlight"),state:{init:(r,{doc:i})=>Z({doc:i,name:e,lowlight:t,defaultLanguage:n}),apply:(r,i,o,s)=>{let a=o.selection.$head.parent.type.name,l=s.selection.$head.parent.type.name,c=(0,V.findChildren)(o.doc,t=>t.type.name===e),d=(0,V.findChildren)(s.doc,t=>t.type.name===e);return r.docChanged&&([a,l].includes(e)||d.length!==c.length||r.steps.some(e=>void 0!==e.from&&void 0!==e.to&&c.some(t=>t.pos>=e.from&&t.pos+t.node.nodeSize<=e.to)))?Z({doc:r.doc,name:e,lowlight:t,defaultLanguage:n}):i.map(r.mapping,r.doc)}},props:{decorations:e=>r.getState(e)}});return r}({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}});let Q="numeric",ee="ascii",et="alpha",en="asciinumeric",er="alphanumeric",ei="domain",eo="emoji",es="whitespace";function ea(e,t,n){for(let r in t[Q]&&(t[en]=!0,t[er]=!0),t[ee]&&(t[en]=!0,t[et]=!0),t[en]&&(t[er]=!0),t[et]&&(t[er]=!0),t[er]&&(t[ei]=!0),t[eo]&&(t[ei]=!0),t){let t=(r in n||(n[r]=[]),n[r]);0>t.indexOf(e)&&t.push(e)}}function el(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}el.groups={},el.prototype={accepts(){return!!this.t},go(e){let t=this.j[e];if(t)return t;for(let t=0;t<this.jr.length;t++){let n=this.jr[t][0],r=this.jr[t][1];if(r&&n.test(e))return r}return this.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let i=0;i<e.length;i++)this.tt(e[i],t,n,r)},tr(e,t,n,r){let i;return r=r||el.groups,t&&t.j?i=t:(i=new el(t),n&&r&&ea(t,n,r)),this.jr.push([e,i]),i},ts(e,t,n,r){let i=this,o=e.length;if(!o)return i;for(let t=0;t<o-1;t++)i=i.tt(e[t]);return i.tt(e[o-1],t,n,r)},tt(e,t,n,r){if(r=r||el.groups,t&&t.j)return this.j[e]=t,t;let i,o=this.go(e);return o?(Object.assign((i=new el).j,o.j),i.jr.push.apply(i.jr,o.jr),i.jd=o.jd,i.t=o.t):i=new el,t&&(r&&(i.t&&"string"==typeof i.t?ea(t,Object.assign(function(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}(i.t,r),n),r):n&&ea(t,n,r)),i.t=t),this.j[e]=i,i}};let ec=(e,t,n,r,i)=>e.ta(t,n,r,i),ed=(e,t,n,r,i)=>e.tr(t,n,r,i),eu=(e,t,n,r,i)=>e.ts(t,n,r,i),eh=(e,t,n,r,i)=>e.tt(t,n,r,i),ep="WORD",ef="UWORD",em="ASCIINUMERICAL",eg="ALPHANUMERICAL",ey="LOCALHOST",eb="UTLD",ev="SCHEME",ew="SLASH_SCHEME",ex="OPENBRACE",ek="CLOSEBRACE",eS="OPENBRACKET",eC="CLOSEBRACKET",eE="OPENPAREN",eM="CLOSEPAREN",eN="OPENANGLEBRACKET",eA="CLOSEANGLEBRACKET",eT="FULLWIDTHLEFTPAREN",eR="FULLWIDTHRIGHTPAREN",eO="LEFTCORNERBRACKET",eD="RIGHTCORNERBRACKET",ej="LEFTWHITECORNERBRACKET",eI="RIGHTWHITECORNERBRACKET",eP="FULLWIDTHLESSTHAN",eL="FULLWIDTHGREATERTHAN",ez="AMPERSAND",e_="APOSTROPHE",e$="ASTERISK",eH="BACKSLASH",eB="BACKTICK",eF="CARET",eV="COLON",eU="COMMA",eW="DOLLAR",eK="EQUALS",eq="EXCLAMATION",eJ="HYPHEN",eG="PERCENT",eX="PIPE",eZ="PLUS",eY="POUND",eQ="QUERY",e0="QUOTE",e1="FULLWIDTHMIDDLEDOT",e2="SEMI",e5="SLASH",e3="TILDE",e4="UNDERSCORE",e6="EMOJI";var e9=Object.freeze({__proto__:null,ALPHANUMERICAL:eg,AMPERSAND:ez,APOSTROPHE:e_,ASCIINUMERICAL:em,ASTERISK:e$,AT:"AT",BACKSLASH:eH,BACKTICK:eB,CARET:eF,CLOSEANGLEBRACKET:eA,CLOSEBRACE:ek,CLOSEBRACKET:eC,CLOSEPAREN:eM,COLON:eV,COMMA:eU,DOLLAR:eW,DOT:"DOT",EMOJI:e6,EQUALS:eK,EXCLAMATION:eq,FULLWIDTHGREATERTHAN:eL,FULLWIDTHLEFTPAREN:eT,FULLWIDTHLESSTHAN:eP,FULLWIDTHMIDDLEDOT:e1,FULLWIDTHRIGHTPAREN:eR,HYPHEN:eJ,LEFTCORNERBRACKET:eO,LEFTWHITECORNERBRACKET:ej,LOCALHOST:ey,NL:"NL",NUM:"NUM",OPENANGLEBRACKET:eN,OPENBRACE:ex,OPENBRACKET:eS,OPENPAREN:eE,PERCENT:eG,PIPE:eX,PLUS:eZ,POUND:eY,QUERY:eQ,QUOTE:e0,RIGHTCORNERBRACKET:eD,RIGHTWHITECORNERBRACKET:eI,SCHEME:ev,SEMI:e2,SLASH:e5,SLASH_SCHEME:ew,SYM:"SYM",TILDE:e3,TLD:"TLD",UNDERSCORE:e4,UTLD:eb,UWORD:ef,WORD:ep,WS:"WS"});let e7=/[a-z]/,e8=/\p{L}/u,te=/\p{Emoji}/u,tt=/\d/,tn=/\s/,tr=null,ti=null;function to(e,t){let n=function(e){let t=[],n=e.length,r=0;for(;r<n;){let i,o=e.charCodeAt(r),s=o<55296||o>56319||r+1===n||(i=e.charCodeAt(r+1))<56320||i>57343?e[r]:e.slice(r,r+2);t.push(s),r+=s.length}return t}(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],o=0,s=0;for(;s<r;){let a=e,l=null,c=0,d=null,u=-1,h=-1;for(;s<r&&(l=a.go(n[s]));)(a=l).accepts()?(u=0,h=0,d=a):u>=0&&(u+=n[s].length,h++),c+=n[s].length,o+=n[s].length,s++;o-=u,s-=h,c-=u,i.push({t:d.t,v:t.slice(o-c,o),s:o-c,e:o})}return i}function ts(e,t,n,r,i){let o,s=t.length;for(let n=0;n<s-1;n++){let s=t[n];e.j[s]?o=e.j[s]:((o=new el(r)).jr=i.slice(),e.j[s]=o),e=o}return(o=new el(n)).jr=i.slice(),e.j[t[s-1]]=o,o}function ta(e){let t=[],n=[],r=0;for(;r<e.length;){let i=0;for(;"0123456789".indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(""));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}let tl={defaultProtocol:"http",events:null,format:td,formatHref:td,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function tc(e,t=null){let n=Object.assign({},tl);e&&(n=Object.assign(n,e instanceof tc?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e<r.length;e++)i.push(r[e].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=i}function td(e){return e}function tu(e,t){this.t="token",this.v=e,this.tk=t}function th(e,t){class n extends tu{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}tc.prototype={o:tl,ignoreTags:[],defaultRender:e=>e,check(e){return this.get("validate",e.toString(),e)},get(e,t,n){let r=null!=t,i=this.o[e];return i&&("object"==typeof i?"function"==typeof(i=n.t in i?i[n.t]:tl[e])&&r&&(i=i(t,n)):"function"==typeof i&&r&&(i=i(t,n.t,n))),i},getObj(e,t,n){let r=this.o[e];return"function"==typeof r&&null!=t&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get("render",null,e)||this.defaultRender)(t,e.t,e)}},tu.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get("truncate",t,this),r=e.get("format",t,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(e){return e.get("formatHref",this.toHref(e.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=tl.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get("validate",this.toString(),this)},render(e){let t=this.toHref(e.get("defaultProtocol")),n=e.get("formatHref",t,this),r=e.get("tagName",t,this),i=this.toFormattedString(e),o={},s=e.get("className",t,this),a=e.get("target",t,this),l=e.get("rel",t,this),c=e.getObj("attributes",t,this),d=e.getObj("events",t,this);return o.href=n,s&&(o.class=s),a&&(o.target=a),l&&(o.rel=l),c&&Object.assign(o,c),{tagName:r,attributes:o,content:i,eventListeners:d}}};let tp=th("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),tf=th("text"),tm=th("nl"),tg=th("url",{isLink:!0,toHref(e=tl.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==ey&&e[1].t===eV}}),ty=e=>new el(e);function tb(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}let tv="u">typeof console&&console&&console.warn||(()=>{}),tw={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function tx(e,t=!1){if(tw.initialized&&tv(`linkifyjs: already initialized - will not register custom scheme "${e}" until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format.
101
101
  1. Must only contain digits, lowercase ASCII letters or "-"
@@ -110,4 +110,4 @@ ${i}
110
110
 
111
111
  If you want to hide the \`${n.titleName}\`, you can wrap it with our VisuallyHidden component.
112
112
 
113
- For more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return t.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},G=({contentRef:e,descriptionId:n})=>{let r=q("DialogDescriptionWarning"),i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${r.contentName}}.`;return t.useEffect(()=>{let t=e.current?.getAttribute("aria-describedby");n&&t&&(document.getElementById(n)||console.warn(i))},[i,e,n]),null};e.s(["Close",0,V,"Content",0,I,"Description",0,B,"Overlay",0,R,"Portal",0,A,"Root",0,k,"Title",0,$,"Trigger",0,C])},22245,e=>{"use strict";let t=(0,e.i(605993).default)("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);e.s(["X",0,t],22245)},776639,e=>{"use strict";var t=e.i(44501),n=e.i(46951),r=e.i(22245),i=e.i(101685),o=e.i(975157);let s=n.Root;n.Trigger;let a=n.Portal;n.Close;let l=i.forwardRef(({className:e,...r},i)=>(0,t.jsx)(n.Overlay,{ref:i,className:(0,o.cn)("fixed inset-0 z-40 bg-overlay backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...r}));l.displayName=n.Overlay.displayName;let c=i.forwardRef(({className:e,children:i,...s},c)=>(0,t.jsxs)(a,{children:[(0,t.jsx)(l,{}),(0,t.jsxs)(n.Content,{ref:c,className:(0,o.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-card p-6 shadow-golden rounded-sm 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",e),...s,children:[i,(0,t.jsxs)(n.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[(0,t.jsx)(r.X,{className:"h-4 w-4"}),(0,t.jsx)("span",{className:"sr-only",children:"Close"})]})]})]}));function d({className:e,...n}){return(0,t.jsx)("div",{className:(0,o.cn)("flex flex-col space-y-1.5 text-center sm:text-left",e),...n})}function u({className:e,...n}){return(0,t.jsx)("div",{className:(0,o.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...n})}c.displayName=n.Content.displayName,d.displayName="DialogHeader",u.displayName="DialogFooter";let h=i.forwardRef(({className:e,...r},i)=>(0,t.jsx)(n.Title,{ref:i,className:(0,o.cn)("text-lg font-normal leading-none tracking-tight",e),...r}));h.displayName=n.Title.displayName;let p=i.forwardRef(({className:e,...r},i)=>(0,t.jsx)(n.Description,{ref:i,className:(0,o.cn)("text-sm text-muted-foreground",e),...r}));p.displayName=n.Description.displayName,e.s(["Dialog",0,s,"DialogContent",0,c,"DialogDescription",0,p,"DialogFooter",0,u,"DialogHeader",0,d,"DialogTitle",0,h])},912235,110204,e=>{"use strict";var t=e.i(44501);e.i(150663);var n=e.i(608926),r=e.i(885047),i=e.i(425732),o=e.i(43240),s=e.i(313393),a=e.i(530229),l=e.i(691520),c=e.i(231597),d=e.i(101685),u=e.i(417068),h=e.i(797715),p=e.i(660885),f=e.i(490275),m=e.i(24800),g=e.i(96701),y=e.i(990791),b=e.i(395624),v=e.i(246542),w=e.i(592185),x=e.i(926732),k=e.i(671485),S=e.i(417385),C=e.i(582612),E=e.i(240409),M=e.i(314206),N=e.i(496668),A=e.i(665794),T=e.i(926128),R=e.i(803043),O=e.i(589676),D=e.i(294250),j=e.i(203195),I=e.i(521470),P=e.i(623616),L=e.i(152555),z=e.i(519455),_=e.i(776639),$=e.i(793479),H=e.i(750110),B=d.forwardRef((e,n)=>(0,t.jsx)(H.Primitive.label,{...e,ref:n,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));B.displayName="Label";var F=e.i(294237),V=e.i(975157);let U=(0,F.cva)("text-sm font-normal leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-50"),W=d.forwardRef(({className:e,...n},r)=>(0,t.jsx)(B,{ref:r,className:(0,V.cn)(U(),e),...n}));W.displayName=B.displayName,e.s(["Label",0,W],110204);let K=["entities","concepts","comparisons"],q=/^[a-z0-9-]+$/;function J({editor:e,onCreateRequest:n}){let[r,i]=(0,d.useState)(!1),[o,s]=(0,d.useState)(""),[a,l]=(0,d.useState)(0),[c,u]=(0,d.useState)({top:0,left:0}),h=(0,d.useRef)(null),p=(0,d.useRef)(0),f=(0,v.useWikiSlugsStore)(e=>e.slugs),m=(0,v.useWikiSlugsStore)(e=>e.slugDir),g=(0,v.useWikiSlugsStore)(e=>e.has),y=Array.from(f).sort().filter(e=>!o||e.includes(o.toLowerCase())).slice(0,20),b=o.length>0&&q.test(o)&&!g(o),w=y.length+ +!!b,x=(0,d.useCallback)(()=>{i(!1),s(""),l(0)},[]),k=(0,d.useCallback)(t=>{if(!e)return;let{from:n}=e.state.selection,r=p.current-2,i=e.state.schema.marks.wikiLink;if(!i)return;let o=i.create({slug:t,alias:null,anchor:null}),s=e.state.schema.text(t,[o]),a=e.state.tr.replaceWith(r,n,s);e.view.dispatch(a),e.commands.focus(),x()},[e,x]),S=(0,d.useCallback)(async t=>{if(e){if(t<y.length)k(y[t]??"");else if(b){let e=await n(o);e.ok?k(e.slug):x()}}},[e,y,b,o,k,n,x]);return((0,d.useEffect)(()=>{if(!e)return;let t=t=>{if(!r){if("["===t.key){let{from:t}=e.state.selection;if("["!==e.state.doc.textBetween(Math.max(0,t-1),t)||e.state.doc.resolve(t).marks().some(e=>"wikiLink"===e.type.name))return;let n=e.view.coordsAtPos(t),r=e.view.dom.getBoundingClientRect();u({top:n.bottom-r.top+4,left:n.left-r.left}),p.current=t+1,i(!0),s(""),l(0)}return}"ArrowDown"===t.key?(t.preventDefault(),l(e=>w>0?(e+1)%w:0)):"ArrowUp"===t.key?(t.preventDefault(),l(e=>w>0?(e-1+w)%w:0)):"Enter"===t.key?(t.preventDefault(),t.stopPropagation(),w>0&&S(a)):"Escape"===t.key||"]"===t.key?x():"Backspace"===t.key?0===o.length?x():(s(e=>e.slice(0,-1)),l(0)):1!==t.key.length||t.metaKey||t.ctrlKey||(s(e=>e+t.key),l(0))};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[e,r,o,a,w,x,S]),(0,d.useEffect)(()=>{if(!r)return;let e=e=>{h.current&&!h.current.contains(e.target)&&x()};return window.addEventListener("mousedown",e),()=>window.removeEventListener("mousedown",e)},[r,x]),r&&0!==w)?(0,t.jsxs)("div",{ref:h,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:c.top,left:c.left},children:[y.map((e,n)=>{let r=m.get(e);return(0,t.jsxs)("button",{type:"button",onMouseDown:e=>{e.preventDefault(),S(n)},onMouseEnter:()=>l(n),className:(0,V.cn)("flex items-center justify-between w-full px-3 py-1.5 text-left text-sm transition-colors",n===a?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:[(0,t.jsx)("span",{className:"truncate",children:e}),r&&(0,t.jsx)("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground bg-muted px-1.5 py-0.5 rounded",children:r})]},e)}),b&&(0,t.jsx)("button",{type:"button",onMouseDown:e=>{e.preventDefault(),S(y.length)},onMouseEnter:()=>l(y.length),className:(0,V.cn)("flex items-center w-full px-3 py-1.5 text-left text-sm transition-colors",y.length===a?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:(0,t.jsxs)("span",{className:"text-muted-foreground",children:["+ Create new “",o,"”"]})})]}):null}var G=e.i(367092),X=e.i(10137);let Z=(0,F.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 Y({className:e,variant:n,...r}){return(0,t.jsx)("div",{className:(0,V.cn)(Z({variant:n}),e),...r})}let Q=new Set(["title","type","status","created","updated","date","tags","sources","private","supersedes","superseded_by"]);function ee({data:e}){let[n,r]=(0,d.useState)(!1),i=Object.keys(e);if(0===i.length)return null;let o="string"==typeof e.title?e.title:null,s="string"==typeof e.type?e.type:null,a="string"==typeof e.status?e.status:null,l="string"==typeof e.created?e.created:null,c="string"==typeof e.updated?e.updated:null,u=!0===e.private,h=Array.isArray(e.tags)?e.tags:[],p=Array.isArray(e.sources)?e.sources:[],f="string"==typeof e.superseded_by?e.superseded_by:null,m=i.filter(e=>!Q.has(e));return(0,t.jsxs)("div",{className:"mb-6 rounded-sm border bg-card/40 px-4 py-3 text-xs",children:[o&&(0,t.jsx)("div",{className:"mb-2 text-base font-normal text-foreground",children:o}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5 text-muted-foreground",children:[s&&(0,t.jsx)(Y,{variant:"outline",className:"font-normal",children:s}),a&&(0,t.jsx)(Y,{variant:"outline",className:"font-normal",children:a}),u&&(0,t.jsx)(Y,{variant:"outline",className:"border-warning-ink/40 font-normal text-warning-ink",children:"private"}),f&&(0,t.jsxs)(Y,{variant:"outline",className:"border-destructive/40 font-normal text-destructive",children:["superseded → ",f]}),l&&(0,t.jsxs)("span",{children:[(0,t.jsx)("span",{className:"opacity-60",children:"created"})," ",(0,t.jsx)("span",{className:"text-foreground/80",children:l})]}),c&&c!==l&&(0,t.jsxs)("span",{children:[(0,t.jsx)("span",{className:"opacity-60",children:"updated"})," ",(0,t.jsx)("span",{className:"text-foreground/80",children:c})]})]}),h.length>0&&(0,t.jsx)("div",{className:"mt-2 flex flex-wrap gap-1",children:h.map(e=>(0,t.jsxs)(Y,{variant:"secondary",className:"font-normal text-[11px]",children:["#",e]},e))}),p.length>0&&(0,t.jsxs)("div",{className:"mt-2",children:[(0,t.jsx)("span",{className:"opacity-60",children:"sources:"})," ",(0,t.jsx)("span",{className:"text-foreground/80",children:p.join(", ")})]}),m.length>0&&(0,t.jsxs)("div",{className:"mt-2 border-t pt-2",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>r(e=>!e),className:"flex items-center gap-1 text-muted-foreground hover:text-foreground",children:[n?(0,t.jsx)(G.ChevronDown,{className:"h-3 w-3"}):(0,t.jsx)(X.ChevronRight,{className:"h-3 w-3"}),(0,t.jsxs)("span",{children:[m.length," more field",1===m.length?"":"s"]})]}),n&&(0,t.jsx)("dl",{className:"mt-1.5 grid grid-cols-[max-content_1fr] gap-x-3 gap-y-0.5",children:m.map(n=>(0,t.jsxs)(d.Fragment,{children:[(0,t.jsx)("dt",{className:"opacity-60",children:n}),(0,t.jsx)("dd",{className:"text-foreground/80 break-words",children:function e(t){if(null==t)return"";if("string"==typeof t)return t;if("number"==typeof t||"boolean"==typeof t)return String(t);if(Array.isArray(t))return t.map(e).join(", ");try{return JSON.stringify(t)}catch{return String(t)}}(e[n])})]},n))})]})]})}var et=e.i(891734);function en({containerRef:e,onComment:n}){let[r,i]=(0,d.useState)(null);return((0,d.useEffect)(()=>{function t(){let t=window.getSelection();if(!t||t.isCollapsed||0===t.rangeCount)return void i(null);let n=t.getRangeAt(0),r=e.current;if(!r||!r.contains(n.commonAncestorContainer))return void i(null);let o=n.getBoundingClientRect();0===o.width&&0===o.height?i(null):i({top:o.top-38,left:o.left+o.width/2})}return document.addEventListener("selectionchange",t),()=>document.removeEventListener("selectionchange",t)},[e]),r)?(0,t.jsxs)("button",{type:"button",style:{position:"fixed",top:r.top,left:r.left,transform:"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:e=>e.preventDefault(),onClick:()=>{n(),i(null)},"aria-label":"Add comment",title:"Add comment",children:[(0,t.jsx)(et.MessageCircle,{className:"w-3.5 h-3.5"}),(0,t.jsx)("span",{children:"Comment"})]}):null}async function er(e,t){let n=new FormData;n.append("file",t);try{let r=await (0,k.wsFetch)(`/api/upload/${e}`,{method:"POST",body:n});if(!r.ok)return(0,S.showError)(`Upload failed: ${t.name}`),null;return(await r.json()).url}catch{return(0,S.showError)(`Upload failed: ${t.name}`),null}}function ei(e){let t=[];for(let n of e)t.push({path:n.path,name:n.name}),n.children&&t.push(...ei(n.children));return t}function eo(e,t,n){let r=ei(n).filter(t=>t.name===e||t.path.endsWith(`/${e}`));if(0===r.length)return null;if(1===r.length)return r[0].path;if(t){let n=t.includes("/")?t.substring(0,t.lastIndexOf("/")):"",i=r.find(t=>t.path===(n?`${n}/${e}`:e));if(i)return i.path}return r[0].path}function es(e,t,n){let r=e.split("/");for(let e=1;e<r.length;e++)n(r.slice(0,e).join("/"));t(e),g.useEditorStore.getState().loadPage(e),setTimeout(()=>{document.querySelector("[data-editor-scroll]")?.scrollTo(0,0)},0)}e.s(["KBEditor",0,function({mode:e}={}){let{currentPath:H,content:B,saveStatus:F,frontmatter:V,isLoading:U,loadStatus:q,createMissingPage:G,editMode:X,setEditMode:Z}=(0,g.useEditorStore)(),Y=e??X,Q="viewing"===Y,et="suggesting"===Y,ea=(0,d.useMemo)(()=>Q?(0,f.parseFrontmatter)(B):{data:{},body:B},[B,Q]),el=(0,y.useTreeStore)(e=>e.nodes),ec=(0,b.useViewWidthStore)(e=>b.VIEW_WIDTH_CSS[e.width]),ed=(0,b.useViewWidthStore)(e=>b.VIEW_ALIGN_ML[e.align]),eu=Q?"rtl"===ea.data.dir:V?.dir==="rtl",{open:eh,clearMessages:ep}=(0,m.useAIPanelStore)(),{open:ef,Dialog:em}=function(){let[e,n]=(0,d.useState)(!1),[r,i]=(0,d.useState)({slug:"",dir:"entities",title:""}),[o,s]=(0,d.useState)(!1),a=(0,d.useRef)(null),l=(0,d.useCallback)(e=>(i({slug:e,dir:"entities",title:e.split("-").filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}),n(!0),new Promise(e=>{a.current=e})),[]),c=(0,d.useCallback)(()=>{n(!1),a.current?.({ok:!1,slug:r.slug}),a.current=null},[r.slug]),u=(0,d.useCallback)(async()=>{let{slug:e,dir:t,title:i}=r;s(!0);try{let r=await (0,k.wsFetch)("/api/wiki/page",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:e,dir:t,title:i.trim()||void 0})});if(r.ok||409===r.status){let r=v.useWikiSlugsStore.getState();r.invalidate(),r.load(),n(!1),a.current?.({ok:!0,slug:e,dir:t}),a.current=null}else{let e=await r.json().catch(()=>({})),t=null!==e&&"object"==typeof e&&"error"in e&&"string"==typeof e.error?e.error:"Failed to create page";(0,S.showError)(t)}}catch{(0,S.showError)("Failed to create page")}finally{s(!1)}},[r]);return{open:l,Dialog:(0,t.jsx)(_.Dialog,{open:e,onOpenChange:e=>{e||c()},children:(0,t.jsxs)(_.DialogContent,{children:[(0,t.jsx)(_.DialogHeader,{children:(0,t.jsx)(_.DialogTitle,{children:"Create wiki page"})}),(0,t.jsxs)("div",{className:"space-y-4 py-2",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(W,{htmlFor:"wiki-create-slug",children:"Slug"}),(0,t.jsx)($.Input,{id:"wiki-create-slug",value:r.slug,readOnly:!0,className:"bg-muted cursor-default select-all"})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(W,{children:"Directory"}),(0,t.jsx)("div",{className:"flex gap-4",children:K.map(e=>(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-sm cursor-pointer",children:[(0,t.jsx)("input",{type:"radio",name:"wiki-create-dir",value:e,checked:r.dir===e,onChange:()=>i(t=>({...t,dir:e})),className:"accent-primary"}),e]},e))})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(W,{htmlFor:"wiki-create-title",children:"Title (optional)"}),(0,t.jsx)($.Input,{id:"wiki-create-title",value:r.title,onChange:e=>i(t=>({...t,title:e.target.value})),placeholder:"Humanized title..."})]})]}),(0,t.jsxs)(_.DialogFooter,{children:[(0,t.jsx)(z.Button,{variant:"outline",onClick:c,disabled:o,children:"Cancel"}),(0,t.jsx)(z.Button,{onClick:()=>void u(),disabled:o,children:o?"Creating...":"Create"})]})]})})}}(),eg=(0,d.useRef)(ef);eg.current=ef;let ey=(0,d.useRef)(!1),eb=(0,d.useRef)(Q);eb.current=Q;let[ev,ew]=(0,d.useState)(!1),[ex,ek]=(0,d.useState)(""),[eS,eC]=(0,d.useState)("page");(0,d.useEffect)(()=>{eC("page")},[]),(0,d.useEffect)(()=>{v.useWikiSlugsStore.getState().load()},[]),(0,d.useEffect)(()=>{if(!H)return;let e=setTimeout(()=>{w.useProofStore.getState().loadSidecar(H)},200);return()=>clearTimeout(e)},[H]),(0,d.useEffect)(()=>{if(!H||Q||!/\.(md|markdown)$/i.test(H))return;let e=e=>{(0,k.wsFetch)("/api/wiki/presence",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:H,action:e}),keepalive:"close"===e}).catch(()=>{})},t=!1,n=null,r=()=>{t&&"hidden"===document.visibilityState&&e("heartbeat")},i=setTimeout(()=>{t=!0,e("open"),n=setInterval(()=>e("heartbeat"),3e4),document.addEventListener("visibilitychange",r)},200);return()=>{clearTimeout(i),n&&clearInterval(n),document.removeEventListener("visibilitychange",r),t&&e("close")}},[H,Q]),(0,d.useEffect)(()=>{let e=new EventSource((0,k.withWs)("/api/wiki/watch"));return e.onmessage=e=>{try{let t=JSON.parse(e.data),n=g.useEditorStore.getState().currentPath;("change"===t.type||"add"===t.type)&&n&&t.path===n&&(w.useProofStore.getState().loadSnapshot(n).then(()=>w.useProofStore.getState().loadSidecar(n)),eb.current&&g.useEditorStore.getState().loadPage(n))}catch{}},()=>{e.close()}},[]);let[eE,eM]=(0,d.useState)(null),eN=(0,d.useRef)(null),[eA,eT]=(0,d.useState)(new Map),eR=(0,w.useProofStore)(e=>H?e.byPath[H]?.snapshotBlocks:void 0),eO=(0,w.useProofStore)(e=>H?e.byPath[H]?.sidecar?.suggestions:void 0),eD=(0,w.useProofStore)(e=>H?e.byPath[H]?.snapshotRevision??0:0),ej=(0,w.useProofStore)(e=>H?e.byPath[H]?.sidecar?.comments:void 0),eI=(0,d.useMemo)(()=>eR??[],[eR]),eP=(0,d.useMemo)(()=>ej??[],[ej]),eL=(0,d.useMemo)(()=>eO?.filter(e=>"pending"===e.status)??[],[eO]),ez=(0,d.useMemo)(()=>{let e={};for(let t of eP)(e[t.ref]??=[]).push(t);return e},[eP]),[e_,e$]=(0,d.useState)(null),[eH,eB]=(0,d.useState)(null),eF=(0,d.useCallback)(()=>{if(!eY.current)return null;let e=eY.current.view,{from:t}=e.state.selection,n=g.useEditorStore.getState().currentPath??"",r=w.useProofStore.getState().byPath[n]?.snapshotBlocks??[],i=e.state.doc.resolve(t),o=i.depth>0?i.index(0):0,s=eN.current?.querySelector(".ProseMirror"),a=(s?Array.from(s.children):[])[o]??null,l=r[o],c=l?.ref??a?.getAttribute("data-block-ref")??null,d=l?.markdown??"";if(!c&&a){let n=e.domAtPos(t),r=n.node.nodeType===Node.ELEMENT_NODE?n.node:n.node.parentElement,i=r?.closest("[data-block-ref]")??null;c=i?.getAttribute("data-block-ref")??null}return c&&a?{blockRef:c,blockEl:a,markdown:d}:null},[]),eV=(0,d.useCallback)(()=>{let e=eF();if(!e)return;let t=e.blockEl.getBoundingClientRect();eB({blockRef:e.blockRef,markdown:e.markdown,anchor:{top:t.bottom+4,left:t.left}})},[eF]),eU=(0,d.useCallback)(()=>{let e=eF();e&&e$({blockRef:e.blockRef,el:e.blockEl})},[eF]),eW=(0,d.useRef)(!1),eK=(0,d.useRef)(!1),eq=(0,d.useRef)(null),eJ=e=>e.replace(/\s+$/g,"").trimStart(),eG=(0,d.useCallback)(async()=>{if(eK.current||eb.current||"suggesting"!==g.useEditorStore.getState().editMode||!eW.current)return;let e=eY.current,t=g.useEditorStore.getState().currentPath;if(!e||!t)return;let n=eN.current?.querySelector(".ProseMirror");if(!n)return;let r=Array.from(n.children),i=w.useProofStore.getState().byPath[t]?.snapshotBlocks??[];if(0!==i.length){eK.current=!0,eW.current=!1;try{let n=()=>w.useProofStore.getState().byPath[t]?.snapshotRevision??0,o=async()=>{await w.useProofStore.getState().loadSnapshot(t),await w.useProofStore.getState().loadSidecar(t)},s=Math.max(r.length,i.length),a=!1;for(let e=0;e<s;e++){let s=r[e],l=i[e],c=s?(0,p.htmlToMarkdown)(s.outerHTML).trim():null;if(l&&null!==c){if(eJ(c)!==eJ(l.markdown)){let e=await (0,x.captureSuggestion)({path:t,ref:l.ref,kind:"replace",markdown:c,getRevision:n,refresh:o});a=a||e}}else if(l&&null===c){let e=await (0,x.captureSuggestion)({path:t,ref:l.ref,kind:"delete",getRevision:n,refresh:o});a=a||e}else if(!l&&null!==c&&c.length>0){let e=i[i.length-1]?.ref;if(e){let r=await (0,x.captureSuggestion)({path:t,ref:e,kind:"insertAfter",markdown:c,getRevision:n,refresh:o});a=a||r}}}if(a){await o();let n=(w.useProofStore.getState().byPath[t]?.snapshotBlocks??i).map(e=>e.markdown).join("\n\n");ey.current=!0;let r=await (0,h.markdownToHtml)(n,t);e.commands.setContent(r),setTimeout(()=>{ey.current=!1},50)}}finally{eK.current=!1}}},[]);(0,d.useEffect)(()=>{if(!H)return;let e=setTimeout(()=>{w.useProofStore.getState().loadSnapshot(H)},200);return()=>clearTimeout(e)},[H]),(0,d.useEffect)(()=>{if(!H||0===eI.length||!eN.current)return;let e=eN.current,t=e.querySelector(".ProseMirror");if(!t)return;let n=Array.from(t.children),r=e.getBoundingClientRect(),i=new Map;for(let t=0;t<Math.min(n.length,eI.length);t++){let o=n[t],s=eI[t];o.setAttribute("data-block-ref",s.ref);let a=o.getBoundingClientRect();i.set(s.ref,{top:a.top-r.top+e.scrollTop,left:a.left-r.left,width:a.width,bottom:a.bottom-r.top+e.scrollTop})}eT(i)},[H,eI]);let eX=(0,d.useCallback)(({editor:e})=>{if(ey.current||eb.current||!e)return;"suggesting"===g.useEditorStore.getState().editMode&&(eW.current=!0);let t=e.getHTML(),n=(0,p.htmlToMarkdown)(t);g.useEditorStore.getState().updateContent(n)},[]),eZ=(0,r.useEditor)({extensions:M.editorExtensions,content:"",editable:!Q,onUpdate:eX,onBlur:()=>{eG()},onSelectionUpdate:({editor:e})=>{if("suggesting"!==g.useEditorStore.getState().editMode)return;let{from:t}=e.state.selection,n=e.state.doc.resolve(t),r=n.depth>0?n.index(0):0,i=eq.current;eq.current=r,null!==i&&i!==r&&eW.current&&eG()},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:(e,t)=>{if((t.metaKey||t.ctrlKey)&&"a"===t.key.toLowerCase()&&(0,n.isInTable)(e.state)){let r=(0,n.cellAround)(e.state.selection.$from),i=r?.nodeAfter;if(!r||!i)return!1;let o=r.pos+1,s=r.pos+i.nodeSize-1;return(e.state.selection.from!==o||e.state.selection.to!==s)&&(t.preventDefault(),eZ?.chain().focus().setTextSelection({from:o,to:s}).run(),!0)}return!1},handleClick:(e,t,n)=>{let r=n.target.closest("a");if(!r)return!1;let i=r.getAttribute("href");if(!i)return!1;if("true"===r.dataset.wikiLink){n.preventDefault(),n.stopPropagation();let e=r.dataset.slug??"",t=r.dataset.anchor??null;if(!e)return!0;let i=v.useWikiSlugsStore.getState();if(i.has(e)){let n=i.getDir(e),r=null===n||"root"===n?`${e}.md`:`${n}/${e}.md`;g.useEditorStore.getState().loadPage(r),t&&setTimeout(()=>{document.querySelector(`[id="${t}"]`)?.scrollIntoView({behavior:"smooth"})},200)}else{if(eb.current)return!0;eg.current(e).then(e=>{if(e.ok){let t=e.dir??"entities",n=`${t}/${e.slug}.md`;g.useEditorStore.getState().loadPage(n)}})}return!0}if(i.startsWith("#page:")){n.preventDefault(),n.stopPropagation();let e=i.replace("#page:",""),{nodes:t,selectPage:r,expandPath:o}=y.useTreeStore.getState(),s=eo(e,g.useEditorStore.getState().currentPath,t);return s&&es(s,r,o),!0}if(/^https?:\/\//.test(i)||i.startsWith("/api/")||i.startsWith("mailto:")||i.startsWith("tel:"))return!1;n.preventDefault(),n.stopPropagation();let{nodes:o,selectPage:s,expandPath:a}=y.useTreeStore.getState(),l=function(e,t,n){let r=ei(n),i=e.replace(/\.md$/,"").replace(/^\.\//,"").replace(/^\//,""),o=r.find(e=>e.path===i);if(o)return o.path;if(t){let e=t.includes("/")?t.substring(0,t.lastIndexOf("/")):"",n=e?`${e}/${i}`:i,o=r.find(e=>e.path===n);if(o)return o.path}return eo(i.includes("/")?i.split("/").pop():i,t,n)}(i,g.useEditorStore.getState().currentPath,o);return l&&es(l,s,a),!0},handlePaste:(e,t)=>{if(eb.current)return!1;let n=t.clipboardData?.files,r=g.useEditorStore.getState().currentPath;if(n&&n.length>0&&r){for(let e of Array.from(n))er(r,e).then(t=>{t&&eZ&&(e.type.startsWith("image/")?eZ.chain().focus().setImage({src:t,alt:e.name}).run():eZ.chain().focus().insertContent(`<a href="${t}">${e.name}</a>`).run())});return!0}return!1},handleDrop:(e,t)=>{if(eb.current)return!1;let n=t.dataTransfer?.files;if(!n||0===n.length)return!1;let r=g.useEditorStore.getState().currentPath;if(!r)return!1;for(let e of(t.preventDefault(),Array.from(n)))er(r,e).then(t=>{t&&eZ&&(e.type.startsWith("image/")?eZ.chain().focus().setImage({src:t,alt:e.name}).run():eZ.chain().focus().insertContent(`<a href="${t}">${e.name}</a>`).run())});return!0}},immediatelyRender:!1}),eY=(0,d.useRef)(eZ);eY.current=eZ,(0,d.useEffect)(()=>{eZ?.setEditable(!Q),Q&&ew(!1)},[eZ,Q]);let eQ=(0,d.useRef)(null),e0=(0,d.useRef)(null),[e1,e2]=(0,d.useState)(null);(0,d.useEffect)(()=>{if(!eZ||null===H||g.useEditorStore.getState().isDirty&&H===eQ.current||U&&""===B)return;let e=ea.body,t=`${H} ${e}`;if(e0.current===t){e1!==H&&e2(H);return}eQ.current=H;let n=!1;return(async()=>{ey.current=!0;let r=await (0,h.markdownToHtml)(e,Q?{pagePath:H,sanitize:!0}:H);if(n||g.useEditorStore.getState().currentPath!==H){ey.current=!1;return}eZ.commands.setContent(r),e0.current=t,e2(H),setTimeout(()=>{ey.current=!1},50)})(),()=>{n=!0}},[eZ,B,H,U,e1,ea.body,Q]),(0,d.useEffect)(()=>{if(!Q||!e1)return;let e=eN.current;e&&e.querySelectorAll('input[type="checkbox"]').forEach(e=>{e.disabled=!0})},[Q,e1,ea.body]);let e5=null!==H&&(U||e1!==H),[e3,e4]=(0,d.useState)(!1);if((0,d.useEffect)(()=>{if(!e5)return void e4(!1);let e=setTimeout(()=>e4(!0),150);return()=>clearTimeout(e)},[e5]),null===H)return(0,t.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,t.jsxs)("div",{className:"text-center space-y-3",children:[(0,t.jsx)("p",{className:"text-lg font-medium tracking-[-0.02em]",children:"No page selected"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground/70",children:"Select a page from the sidebar or create a new one"})]})});if("missing"===q){let e=(H.split("/").pop()||H).replace(/[-_]+/g," ").replace(/\b\w/g,e=>e.toUpperCase()),n=(0,u.findNodeByPath)(el,H),r=n?.children??[],i=r.length>0;return(0,t.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,t.jsxs)("div",{className:"max-w-3xl mx-auto px-6 py-10 space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-lg font-medium tracking-[-0.02em] text-foreground",children:e}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground/80",children:["This folder doesn't have an"," ",(0,t.jsx)("code",{className:"px-1 py-0.5 rounded bg-muted text-[12px]",children:"index.md"}),i?" yet — its contents are listed below.":" yet."]}),(0,t.jsxs)("button",{onClick:()=>void G(e),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,t.jsx)(a.FilePlus,{className:"h-3.5 w-3.5"}),"Create page"]})]}),i&&(0,t.jsx)(N.FolderIndex,{folderPath:H,entries:r},H)]})})}let e6=async()=>{if(ev){if(g.useEditorStore.getState().updateContent(ex),eZ){ey.current=!0;let e=await (0,h.markdownToHtml)(ex,H??void 0);eZ.commands.setContent(e),setTimeout(()=>{ey.current=!1},50)}ew(!1)}else ek(g.useEditorStore.getState().content),ew(!0)},e9=(0,u.findNodeByPath)(el,H),e7=e9?.type==="directory"||e9?.type==="cabinet"?e9.children??[]:[],e8=e7.length>0,te=e8&&"files"===eS;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e8&&(0,t.jsxs)("div",{className:"flex items-center gap-1 px-3 pt-2 border-b border-border",children:[(0,t.jsx)("button",{onClick:()=>eC("page"),className:`px-3 py-1.5 text-[12px] rounded-t-md border-b-2 -mb-px transition-colors ${"page"===eS?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,"aria-pressed":"page"===eS,children:"Page"}),(0,t.jsxs)("button",{onClick:()=>eC("files"),className:`px-3 py-1.5 text-[12px] rounded-t-md border-b-2 -mb-px transition-colors ${"files"===eS?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,"aria-pressed":"files"===eS,children:["Files",(0,t.jsx)("span",{className:"ml-1.5 text-muted-foreground/60",children:e7.length})]})]}),te?(0,t.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,t.jsx)("div",{className:"max-w-3xl mx-auto px-6 py-6",children:(0,t.jsx)(N.FolderIndex,{folderPath:H,entries:e7},H)})}):(0,t.jsxs)(t.Fragment,{children:[!Q&&(0,t.jsxs)("div",{className:"flex items-center min-w-0",children:[(0,t.jsx)("div",{className:"flex-1 min-w-0",children:!ev&&(0,t.jsx)(E.EditorToolbar,{editor:eZ})}),(0,t.jsxs)("button",{onClick:e6,className:`flex items-center gap-1.5 px-3 py-1 mr-2 text-[11px] rounded-md transition-colors border border-border ${ev?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"}`,children:[(0,t.jsx)(s.Code2,{className:"h-3 w-3"}),ev?"Preview":"Markdown"]})]}),ev?(0,t.jsx)("div",{className:"flex-1 overflow-y-auto p-4",dir:eu?"rtl":void 0,children:(0,t.jsx)("textarea",{value:ex,onChange:e=>ek(e.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,t.jsxs)("div",{className:"flex-1 relative",dir:eu?"rtl":void 0,children:[et&&(0,t.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,t.jsx)(I.DocumentOutline,{editor:eZ,scrollContainerRef:eN}),(0,t.jsxs)("div",{ref:eN,className:`absolute inset-0 overflow-y-auto ${et?"pt-7":""}`,style:{"--editor-max-w":ec,"--editor-ml":ed},"data-editor-scroll":!0,children:[(0,t.jsxs)("div",{"aria-hidden":"true",className:"relative pointer-events-none",style:{height:0},children:[Object.entries(ez).map(([e,n])=>{let r=eA.get(e);return r?(0,t.jsx)("div",{style:{pointerEvents:"auto"},children:(0,t.jsx)(A.CommentPip,{blockRef:e,comments:n,top:r.top+4,left:Math.max(0,r.left-20),onClick:()=>{let t=eN.current?.querySelector(`[data-block-ref="${e}"]`);t&&e$({blockRef:e,el:t})}})},`pip-${e}`):null}),H&&eL.map(e=>{let n=eA.get(e.ref),r=eI.find(t=>t.ref===e.ref);if(!n||!r)return null;let i="insertAfter"===e.kind?n.bottom+4:"insertBefore"===e.kind?Math.max(0,n.top-80):n.top;return(0,t.jsx)("div",{style:{pointerEvents:"auto"},children:(0,t.jsx)(O.SuggestionCard,{path:H,suggestion:e,currentMarkdown:r.markdown,baseRevision:eD,getLatestRevision:()=>w.useProofStore.getState().byPath[H]?.snapshotRevision??0,top:i,left:n.left,width:n.width,onSettled:()=>{w.useProofStore.getState().loadSidecar(H),w.useProofStore.getState().loadSnapshot(H)},readOnly:Q})},`sug-${e.id}`)})]}),e_&&H&&(0,t.jsx)(T.CommentThread,{path:H,blockRef:e_.blockRef,comments:ez[e_.blockRef]??[],anchorEl:e_.el,onClose:()=>e$(null),readOnly:Q}),eH&&H&&(0,t.jsx)(D.SuggestEditPopover,{path:H,blockRef:eH.blockRef,currentMarkdown:eH.markdown,anchor:eH.anchor,onClose:()=>eB(null)}),Q&&Object.keys(ea.data).length>0&&(0,t.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,t.jsx)(ee,{data:ea.data})}),(0,t.jsx)(r.EditorContent,{editor:eZ}),H&&/\.(md|markdown)$/i.test(H)&&(0,t.jsx)(P.BacklinksPanel,{currentPath:H}),(0,t.jsx)("div",{"aria-hidden":"true",className:"contents",onMouseOver:e=>{let t=e.target.closest(".proof-span");t&&t!==eE&&eM(t)},onMouseOut:e=>{let t=e.relatedTarget;t?.closest(".proof-span")||eM(null)}}),H&&(0,t.jsx)(R.ProofSpanPopover,{targetEl:eE,path:H,onClose:()=>eM(null),onComment:()=>{if(!eE)return;let e=eE.closest("[data-block-ref]");if(!e)return;let t=e.getAttribute("data-block-ref");t&&e$({blockRef:t,el:e})}}),!Q&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(C.EditorBubbleMenu,{editor:eZ,onSuggestEdit:eV,onComment:eU}),(0,t.jsx)(L.TableMenu,{editor:eZ}),(0,t.jsx)(j.SlashCommands,{editor:eZ}),(0,t.jsx)(J,{editor:eZ,onCreateRequest:eg.current})]}),Q&&(0,t.jsx)(en,{containerRef:eN,onComment:eU}),(0,t.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,t.jsxs)("button",{onClick:()=>{ep(),eh()},className:"group flex items-center gap-2 text-[13px] text-muted-foreground/50 hover:text-muted-foreground transition-colors cursor-pointer",children:[(0,t.jsx)(c.Sparkles,{className:"h-3.5 w-3.5 group-hover:text-primary transition-colors"}),(0,t.jsx)("span",{children:"Edit with AI"})]}),!Q&&(0,t.jsxs)("span",{className:"text-[11px] text-muted-foreground/30 select-none",children:[(0,t.jsx)("kbd",{className:"rounded px-1 py-0.5 font-mono text-[10px] ring-1 ring-foreground/10",children:"/"})," ","for commands"]})]})]}),e3&&(0,t.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,t.jsx)(l.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground/70"})})]}),!Q&&(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-1 border-t border-border text-xs text-muted-foreground/60",children:[(0,t.jsxs)("span",{className:"text-[10.5px] text-muted-foreground/30 select-none hidden sm:block",children:[(0,t.jsx)("kbd",{className:"rounded px-1 font-mono text-[9.5px] ring-1 ring-foreground/10",children:"⌘S"})," ","save",(0,t.jsx)("span",{className:"mx-1.5 opacity-40",children:"·"}),(0,t.jsx)("kbd",{className:"rounded px-1 font-mono text-[9.5px] ring-1 ring-foreground/10",children:"/"})," ","commands"]}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsxs)("div",{className:"flex items-center rounded-md border border-border overflow-hidden text-[10.5px]",role:"radiogroup","aria-label":"Edit mode",children:[(0,t.jsx)("button",{type:"button",role:"radio","aria-checked":"editing"===X,onClick:()=>Z("editing"),className:`px-2 py-0.5 transition-colors ${"editing"===X?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"}`,children:"Editing"}),(0,t.jsx)("button",{type:"button",role:"radio","aria-checked":"suggesting"===X,onClick:()=>Z("suggesting"),className:`px-2 py-0.5 transition-colors ${"suggesting"===X?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"}`,children:"Suggesting"})]}),(0,t.jsxs)("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10.5px] transition-all duration-300 ${"idle"===F?"opacity-0 pointer-events-none":"opacity-100"} ${"saving"===F?"bg-muted text-muted-foreground":"saved"===F?"bg-success/10 text-success":"error"===F?"bg-destructive/10 text-destructive":""}`,children:["saving"===F&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(l.Loader2,{className:"h-2.5 w-2.5 animate-spin"}),"Saving…"]}),"saved"===F&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.Check,{className:"h-2.5 w-2.5"}),"Saved"]}),"error"===F&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(i.AlertCircle,{className:"h-2.5 w-2.5"}),"Save failed"]})]})]})]})]})]}),em]})}],912235)},780569,e=>{"use strict";var t=e.i(44501),n=e.i(43240),r=e.i(792934),i=e.i(519455),o=e.i(755146),s=e.i(395624);e.s(["ViewWidthToggle",0,function({className:e}){let a=(0,s.useViewWidthStore)(e=>e.width),l=(0,s.useViewWidthStore)(e=>e.setWidth),c=(0,s.useViewWidthStore)(e=>e.align),d=(0,s.useViewWidthStore)(e=>e.setAlign);return(0,t.jsxs)(o.DropdownMenu,{children:[(0,t.jsx)(o.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsx)(i.Button,{size:"sm",variant:"ghost",className:`h-7 w-7 p-0 ${e??""}`,title:`Content width: ${s.VIEW_WIDTH_LABEL[a]}`,children:(0,t.jsx)(r.AlignJustify,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(o.DropdownMenuContent,{align:"end",className:"w-36",children:[(0,t.jsx)(o.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Width"}),s.VIEW_WIDTH_ORDER.map(e=>(0,t.jsxs)(o.DropdownMenuItem,{onClick:()=>l(e),className:"flex items-center justify-between text-xs",children:[s.VIEW_WIDTH_LABEL[e],e===a&&(0,t.jsx)(n.Check,{className:"h-3.5 w-3.5"})]},e)),(0,t.jsx)(o.DropdownMenuSeparator,{}),(0,t.jsx)(o.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Alignment"}),s.VIEW_ALIGN_ORDER.map(e=>(0,t.jsxs)(o.DropdownMenuItem,{onClick:()=>d(e),className:"flex items-center justify-between text-xs",children:[s.VIEW_ALIGN_LABEL[e],e===c&&(0,t.jsx)(n.Check,{className:"h-3.5 w-3.5"})]},e))]})]})}])},894013,409082,847463,e=>{"use strict";var t=e.i(44501),n=e.i(605993);let r=(0,n.default)("moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);e.s(["Moon",0,r],409082);let i=(0,n.default)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);e.s(["Sun",0,i],847463);var o=e.i(917356),s=e.i(519455);e.s(["ThemeToggle",0,function({className:e}){let{resolvedTheme:n,setTheme:a}=(0,o.useTheme)();return(0,t.jsx)(s.Button,{size:"sm",variant:"ghost",className:`h-7 w-7 p-0 ${e??""}`,title:"dark"===n?"Switch to light":"Switch to dark",onClick:()=>a("dark"===n?"light":"dark"),children:"dark"===n?(0,t.jsx)(i,{className:"h-3.5 w-3.5"}):(0,t.jsx)(r,{className:"h-3.5 w-3.5"})})}],894013)}]);
113
+ For more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return t.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},G=({contentRef:e,descriptionId:n})=>{let r=q("DialogDescriptionWarning"),i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${r.contentName}}.`;return t.useEffect(()=>{let t=e.current?.getAttribute("aria-describedby");n&&t&&(document.getElementById(n)||console.warn(i))},[i,e,n]),null};e.s(["Close",0,V,"Content",0,I,"Description",0,B,"Overlay",0,R,"Portal",0,A,"Root",0,k,"Title",0,$,"Trigger",0,C])},22245,e=>{"use strict";let t=(0,e.i(605993).default)("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);e.s(["X",0,t],22245)},776639,e=>{"use strict";var t=e.i(44501),n=e.i(46951),r=e.i(22245),i=e.i(101685),o=e.i(975157);let s=n.Root;n.Trigger;let a=n.Portal;n.Close;let l=i.forwardRef(({className:e,...r},i)=>(0,t.jsx)(n.Overlay,{ref:i,className:(0,o.cn)("fixed inset-0 z-40 bg-overlay backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...r}));l.displayName=n.Overlay.displayName;let c=i.forwardRef(({className:e,children:i,...s},c)=>(0,t.jsxs)(a,{children:[(0,t.jsx)(l,{}),(0,t.jsxs)(n.Content,{ref:c,className:(0,o.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-card p-6 shadow-golden rounded-sm 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",e),...s,children:[i,(0,t.jsxs)(n.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[(0,t.jsx)(r.X,{className:"h-4 w-4"}),(0,t.jsx)("span",{className:"sr-only",children:"Close"})]})]})]}));function d({className:e,...n}){return(0,t.jsx)("div",{className:(0,o.cn)("flex flex-col space-y-1.5 text-center sm:text-left min-w-0",e),...n})}function u({className:e,...n}){return(0,t.jsx)("div",{className:(0,o.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...n})}c.displayName=n.Content.displayName,d.displayName="DialogHeader",u.displayName="DialogFooter";let h=i.forwardRef(({className:e,...r},i)=>(0,t.jsx)(n.Title,{ref:i,className:(0,o.cn)("text-lg font-normal leading-none tracking-tight",e),...r}));h.displayName=n.Title.displayName;let p=i.forwardRef(({className:e,...r},i)=>(0,t.jsx)(n.Description,{ref:i,className:(0,o.cn)("text-sm text-muted-foreground break-words",e),...r}));p.displayName=n.Description.displayName,e.s(["Dialog",0,s,"DialogContent",0,c,"DialogDescription",0,p,"DialogFooter",0,u,"DialogHeader",0,d,"DialogTitle",0,h])},912235,110204,e=>{"use strict";var t=e.i(44501);e.i(150663);var n=e.i(608926),r=e.i(885047),i=e.i(425732),o=e.i(43240),s=e.i(313393),a=e.i(530229),l=e.i(691520),c=e.i(231597),d=e.i(101685),u=e.i(417068),h=e.i(797715),p=e.i(660885),f=e.i(490275),m=e.i(24800),g=e.i(96701),y=e.i(990791),b=e.i(395624),v=e.i(246542),w=e.i(592185),x=e.i(926732),k=e.i(671485),S=e.i(417385),C=e.i(582612),E=e.i(240409),M=e.i(314206),N=e.i(496668),A=e.i(665794),T=e.i(926128),R=e.i(803043),O=e.i(589676),D=e.i(294250),j=e.i(203195),I=e.i(521470),P=e.i(623616),L=e.i(152555),z=e.i(519455),_=e.i(776639),$=e.i(793479),H=e.i(750110),B=d.forwardRef((e,n)=>(0,t.jsx)(H.Primitive.label,{...e,ref:n,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));B.displayName="Label";var F=e.i(294237),V=e.i(975157);let U=(0,F.cva)("text-sm font-normal leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-50"),W=d.forwardRef(({className:e,...n},r)=>(0,t.jsx)(B,{ref:r,className:(0,V.cn)(U(),e),...n}));W.displayName=B.displayName,e.s(["Label",0,W],110204);let K=["entities","concepts","comparisons"],q=/^[a-z0-9-]+$/;function J({editor:e,onCreateRequest:n}){let[r,i]=(0,d.useState)(!1),[o,s]=(0,d.useState)(""),[a,l]=(0,d.useState)(0),[c,u]=(0,d.useState)({top:0,left:0}),h=(0,d.useRef)(null),p=(0,d.useRef)(0),f=(0,v.useWikiSlugsStore)(e=>e.slugs),m=(0,v.useWikiSlugsStore)(e=>e.slugDir),g=(0,v.useWikiSlugsStore)(e=>e.has),y=Array.from(f).sort().filter(e=>!o||e.includes(o.toLowerCase())).slice(0,20),b=o.length>0&&q.test(o)&&!g(o),w=y.length+ +!!b,x=(0,d.useCallback)(()=>{i(!1),s(""),l(0)},[]),k=(0,d.useCallback)(t=>{if(!e)return;let{from:n}=e.state.selection,r=p.current-2,i=e.state.schema.marks.wikiLink;if(!i)return;let o=i.create({slug:t,alias:null,anchor:null}),s=e.state.schema.text(t,[o]),a=e.state.tr.replaceWith(r,n,s);e.view.dispatch(a),e.commands.focus(),x()},[e,x]),S=(0,d.useCallback)(async t=>{if(e){if(t<y.length)k(y[t]??"");else if(b){let e=await n(o);e.ok?k(e.slug):x()}}},[e,y,b,o,k,n,x]);return((0,d.useEffect)(()=>{if(!e)return;let t=t=>{if(!r){if("["===t.key){let{from:t}=e.state.selection;if("["!==e.state.doc.textBetween(Math.max(0,t-1),t)||e.state.doc.resolve(t).marks().some(e=>"wikiLink"===e.type.name))return;let n=e.view.coordsAtPos(t),r=e.view.dom.getBoundingClientRect();u({top:n.bottom-r.top+4,left:n.left-r.left}),p.current=t+1,i(!0),s(""),l(0)}return}"ArrowDown"===t.key?(t.preventDefault(),l(e=>w>0?(e+1)%w:0)):"ArrowUp"===t.key?(t.preventDefault(),l(e=>w>0?(e-1+w)%w:0)):"Enter"===t.key?(t.preventDefault(),t.stopPropagation(),w>0&&S(a)):"Escape"===t.key||"]"===t.key?x():"Backspace"===t.key?0===o.length?x():(s(e=>e.slice(0,-1)),l(0)):1!==t.key.length||t.metaKey||t.ctrlKey||(s(e=>e+t.key),l(0))};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[e,r,o,a,w,x,S]),(0,d.useEffect)(()=>{if(!r)return;let e=e=>{h.current&&!h.current.contains(e.target)&&x()};return window.addEventListener("mousedown",e),()=>window.removeEventListener("mousedown",e)},[r,x]),r&&0!==w)?(0,t.jsxs)("div",{ref:h,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:c.top,left:c.left},children:[y.map((e,n)=>{let r=m.get(e);return(0,t.jsxs)("button",{type:"button",onMouseDown:e=>{e.preventDefault(),S(n)},onMouseEnter:()=>l(n),className:(0,V.cn)("flex items-center justify-between w-full px-3 py-1.5 text-left text-sm transition-colors",n===a?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:[(0,t.jsx)("span",{className:"truncate",children:e}),r&&(0,t.jsx)("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground bg-muted px-1.5 py-0.5 rounded",children:r})]},e)}),b&&(0,t.jsx)("button",{type:"button",onMouseDown:e=>{e.preventDefault(),S(y.length)},onMouseEnter:()=>l(y.length),className:(0,V.cn)("flex items-center w-full px-3 py-1.5 text-left text-sm transition-colors",y.length===a?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:(0,t.jsxs)("span",{className:"text-muted-foreground",children:["+ Create new “",o,"”"]})})]}):null}var G=e.i(367092),X=e.i(10137);let Z=(0,F.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 Y({className:e,variant:n,...r}){return(0,t.jsx)("div",{className:(0,V.cn)(Z({variant:n}),e),...r})}let Q=new Set(["title","type","status","created","updated","date","tags","sources","private","supersedes","superseded_by"]);function ee({data:e}){let[n,r]=(0,d.useState)(!1),i=Object.keys(e);if(0===i.length)return null;let o="string"==typeof e.title?e.title:null,s="string"==typeof e.type?e.type:null,a="string"==typeof e.status?e.status:null,l="string"==typeof e.created?e.created:null,c="string"==typeof e.updated?e.updated:null,u=!0===e.private,h=Array.isArray(e.tags)?e.tags:[],p=Array.isArray(e.sources)?e.sources:[],f="string"==typeof e.superseded_by?e.superseded_by:null,m=i.filter(e=>!Q.has(e));return(0,t.jsxs)("div",{className:"mb-6 rounded-sm border bg-card/40 px-4 py-3 text-xs",children:[o&&(0,t.jsx)("div",{className:"mb-2 text-base font-normal text-foreground",children:o}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5 text-muted-foreground",children:[s&&(0,t.jsx)(Y,{variant:"outline",className:"font-normal",children:s}),a&&(0,t.jsx)(Y,{variant:"outline",className:"font-normal",children:a}),u&&(0,t.jsx)(Y,{variant:"outline",className:"border-warning-ink/40 font-normal text-warning-ink",children:"private"}),f&&(0,t.jsxs)(Y,{variant:"outline",className:"border-destructive/40 font-normal text-destructive",children:["superseded → ",f]}),l&&(0,t.jsxs)("span",{children:[(0,t.jsx)("span",{className:"opacity-60",children:"created"})," ",(0,t.jsx)("span",{className:"text-foreground/80",children:l})]}),c&&c!==l&&(0,t.jsxs)("span",{children:[(0,t.jsx)("span",{className:"opacity-60",children:"updated"})," ",(0,t.jsx)("span",{className:"text-foreground/80",children:c})]})]}),h.length>0&&(0,t.jsx)("div",{className:"mt-2 flex flex-wrap gap-1",children:h.map(e=>(0,t.jsxs)(Y,{variant:"secondary",className:"font-normal text-[11px]",children:["#",e]},e))}),p.length>0&&(0,t.jsxs)("div",{className:"mt-2",children:[(0,t.jsx)("span",{className:"opacity-60",children:"sources:"})," ",(0,t.jsx)("span",{className:"text-foreground/80",children:p.join(", ")})]}),m.length>0&&(0,t.jsxs)("div",{className:"mt-2 border-t pt-2",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>r(e=>!e),className:"flex items-center gap-1 text-muted-foreground hover:text-foreground",children:[n?(0,t.jsx)(G.ChevronDown,{className:"h-3 w-3"}):(0,t.jsx)(X.ChevronRight,{className:"h-3 w-3"}),(0,t.jsxs)("span",{children:[m.length," more field",1===m.length?"":"s"]})]}),n&&(0,t.jsx)("dl",{className:"mt-1.5 grid grid-cols-[max-content_1fr] gap-x-3 gap-y-0.5",children:m.map(n=>(0,t.jsxs)(d.Fragment,{children:[(0,t.jsx)("dt",{className:"opacity-60",children:n}),(0,t.jsx)("dd",{className:"text-foreground/80 break-words",children:function e(t){if(null==t)return"";if("string"==typeof t)return t;if("number"==typeof t||"boolean"==typeof t)return String(t);if(Array.isArray(t))return t.map(e).join(", ");try{return JSON.stringify(t)}catch{return String(t)}}(e[n])})]},n))})]})]})}var et=e.i(891734);function en({containerRef:e,onComment:n}){let[r,i]=(0,d.useState)(null);return((0,d.useEffect)(()=>{function t(){let t=window.getSelection();if(!t||t.isCollapsed||0===t.rangeCount)return void i(null);let n=t.getRangeAt(0),r=e.current;if(!r||!r.contains(n.commonAncestorContainer))return void i(null);let o=n.getBoundingClientRect();0===o.width&&0===o.height?i(null):i({top:o.top-38,left:o.left+o.width/2})}return document.addEventListener("selectionchange",t),()=>document.removeEventListener("selectionchange",t)},[e]),r)?(0,t.jsxs)("button",{type:"button",style:{position:"fixed",top:r.top,left:r.left,transform:"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:e=>e.preventDefault(),onClick:()=>{n(),i(null)},"aria-label":"Add comment",title:"Add comment",children:[(0,t.jsx)(et.MessageCircle,{className:"w-3.5 h-3.5"}),(0,t.jsx)("span",{children:"Comment"})]}):null}async function er(e,t){let n=new FormData;n.append("file",t);try{let r=await (0,k.wsFetch)(`/api/upload/${e}`,{method:"POST",body:n});if(!r.ok)return(0,S.showError)(`Upload failed: ${t.name}`),null;let i=await r.json();return i.url?(0,k.withWs)(i.url):i.url}catch{return(0,S.showError)(`Upload failed: ${t.name}`),null}}function ei(e){let t=[];for(let n of e)t.push({path:n.path,name:n.name}),n.children&&t.push(...ei(n.children));return t}function eo(e,t,n){let r=ei(n).filter(t=>t.name===e||t.path.endsWith(`/${e}`));if(0===r.length)return null;if(1===r.length)return r[0].path;if(t){let n=t.includes("/")?t.substring(0,t.lastIndexOf("/")):"",i=r.find(t=>t.path===(n?`${n}/${e}`:e));if(i)return i.path}return r[0].path}function es(e,t,n){let r=e.split("/");for(let e=1;e<r.length;e++)n(r.slice(0,e).join("/"));t(e),g.useEditorStore.getState().loadPage(e),setTimeout(()=>{document.querySelector("[data-editor-scroll]")?.scrollTo(0,0)},0)}e.s(["KBEditor",0,function({mode:e}={}){let{currentPath:H,content:B,saveStatus:F,frontmatter:V,isLoading:U,loadStatus:q,createMissingPage:G,editMode:X,setEditMode:Z}=(0,g.useEditorStore)(),Y=e??X,Q="viewing"===Y,et="suggesting"===Y,ea=(0,d.useMemo)(()=>Q?(0,f.parseFrontmatter)(B):{data:{},body:B},[B,Q]),el=(0,y.useTreeStore)(e=>e.nodes),ec=(0,b.useViewWidthStore)(e=>b.VIEW_WIDTH_CSS[e.width]),ed=(0,b.useViewWidthStore)(e=>b.VIEW_ALIGN_ML[e.align]),eu=Q?"rtl"===ea.data.dir:V?.dir==="rtl",{open:eh,clearMessages:ep}=(0,m.useAIPanelStore)(),{open:ef,Dialog:em}=function(){let[e,n]=(0,d.useState)(!1),[r,i]=(0,d.useState)({slug:"",dir:"entities",title:""}),[o,s]=(0,d.useState)(!1),a=(0,d.useRef)(null),l=(0,d.useCallback)(e=>(i({slug:e,dir:"entities",title:e.split("-").filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}),n(!0),new Promise(e=>{a.current=e})),[]),c=(0,d.useCallback)(()=>{n(!1),a.current?.({ok:!1,slug:r.slug}),a.current=null},[r.slug]),u=(0,d.useCallback)(async()=>{let{slug:e,dir:t,title:i}=r;s(!0);try{let r=await (0,k.wsFetch)("/api/wiki/page",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:e,dir:t,title:i.trim()||void 0})});if(r.ok||409===r.status){let r=v.useWikiSlugsStore.getState();r.invalidate(),r.load(),n(!1),a.current?.({ok:!0,slug:e,dir:t}),a.current=null}else{let e=await r.json().catch(()=>({})),t=null!==e&&"object"==typeof e&&"error"in e&&"string"==typeof e.error?e.error:"Failed to create page";(0,S.showError)(t)}}catch{(0,S.showError)("Failed to create page")}finally{s(!1)}},[r]);return{open:l,Dialog:(0,t.jsx)(_.Dialog,{open:e,onOpenChange:e=>{e||c()},children:(0,t.jsxs)(_.DialogContent,{children:[(0,t.jsx)(_.DialogHeader,{children:(0,t.jsx)(_.DialogTitle,{children:"Create wiki page"})}),(0,t.jsxs)("div",{className:"space-y-4 py-2",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(W,{htmlFor:"wiki-create-slug",children:"Slug"}),(0,t.jsx)($.Input,{id:"wiki-create-slug",value:r.slug,readOnly:!0,className:"bg-muted cursor-default select-all"})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(W,{children:"Directory"}),(0,t.jsx)("div",{className:"flex gap-4",children:K.map(e=>(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-sm cursor-pointer",children:[(0,t.jsx)("input",{type:"radio",name:"wiki-create-dir",value:e,checked:r.dir===e,onChange:()=>i(t=>({...t,dir:e})),className:"accent-primary"}),e]},e))})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(W,{htmlFor:"wiki-create-title",children:"Title (optional)"}),(0,t.jsx)($.Input,{id:"wiki-create-title",value:r.title,onChange:e=>i(t=>({...t,title:e.target.value})),placeholder:"Humanized title..."})]})]}),(0,t.jsxs)(_.DialogFooter,{children:[(0,t.jsx)(z.Button,{variant:"outline",onClick:c,disabled:o,children:"Cancel"}),(0,t.jsx)(z.Button,{onClick:()=>void u(),disabled:o,children:o?"Creating...":"Create"})]})]})})}}(),eg=(0,d.useRef)(ef);eg.current=ef;let ey=(0,d.useRef)(!1),eb=(0,d.useRef)(Q);eb.current=Q;let[ev,ew]=(0,d.useState)(!1),[ex,ek]=(0,d.useState)(""),[eS,eC]=(0,d.useState)("page");(0,d.useEffect)(()=>{eC("page")},[]),(0,d.useEffect)(()=>{v.useWikiSlugsStore.getState().load()},[]),(0,d.useEffect)(()=>{if(!H)return;let e=setTimeout(()=>{w.useProofStore.getState().loadSidecar(H)},200);return()=>clearTimeout(e)},[H]),(0,d.useEffect)(()=>{if(!H||Q||!/\.(md|markdown)$/i.test(H))return;let e=e=>{(0,k.wsFetch)("/api/wiki/presence",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:H,action:e}),keepalive:"close"===e}).catch(()=>{})},t=!1,n=null,r=()=>{t&&"hidden"===document.visibilityState&&e("heartbeat")},i=setTimeout(()=>{t=!0,e("open"),n=setInterval(()=>e("heartbeat"),3e4),document.addEventListener("visibilitychange",r)},200);return()=>{clearTimeout(i),n&&clearInterval(n),document.removeEventListener("visibilitychange",r),t&&e("close")}},[H,Q]),(0,d.useEffect)(()=>{let e=new EventSource((0,k.withWs)("/api/wiki/watch"));return e.onmessage=e=>{try{let t=JSON.parse(e.data),n=g.useEditorStore.getState().currentPath;("change"===t.type||"add"===t.type)&&n&&t.path===n&&(w.useProofStore.getState().loadSnapshot(n).then(()=>w.useProofStore.getState().loadSidecar(n)),eb.current&&g.useEditorStore.getState().loadPage(n))}catch{}},()=>{e.close()}},[]);let[eE,eM]=(0,d.useState)(null),eN=(0,d.useRef)(null),[eA,eT]=(0,d.useState)(new Map),eR=(0,w.useProofStore)(e=>H?e.byPath[H]?.snapshotBlocks:void 0),eO=(0,w.useProofStore)(e=>H?e.byPath[H]?.sidecar?.suggestions:void 0),eD=(0,w.useProofStore)(e=>H?e.byPath[H]?.snapshotRevision??0:0),ej=(0,w.useProofStore)(e=>H?e.byPath[H]?.sidecar?.comments:void 0),eI=(0,d.useMemo)(()=>eR??[],[eR]),eP=(0,d.useMemo)(()=>ej??[],[ej]),eL=(0,d.useMemo)(()=>eO?.filter(e=>"pending"===e.status)??[],[eO]),ez=(0,d.useMemo)(()=>{let e={};for(let t of eP)(e[t.ref]??=[]).push(t);return e},[eP]),[e_,e$]=(0,d.useState)(null),[eH,eB]=(0,d.useState)(null),eF=(0,d.useCallback)(()=>{if(!eY.current)return null;let e=eY.current.view,{from:t}=e.state.selection,n=g.useEditorStore.getState().currentPath??"",r=w.useProofStore.getState().byPath[n]?.snapshotBlocks??[],i=e.state.doc.resolve(t),o=i.depth>0?i.index(0):0,s=eN.current?.querySelector(".ProseMirror"),a=(s?Array.from(s.children):[])[o]??null,l=r[o],c=l?.ref??a?.getAttribute("data-block-ref")??null,d=l?.markdown??"";if(!c&&a){let n=e.domAtPos(t),r=n.node.nodeType===Node.ELEMENT_NODE?n.node:n.node.parentElement,i=r?.closest("[data-block-ref]")??null;c=i?.getAttribute("data-block-ref")??null}return c&&a?{blockRef:c,blockEl:a,markdown:d}:null},[]),eV=(0,d.useCallback)(()=>{let e=eF();if(!e)return;let t=e.blockEl.getBoundingClientRect();eB({blockRef:e.blockRef,markdown:e.markdown,anchor:{top:t.bottom+4,left:t.left}})},[eF]),eU=(0,d.useCallback)(()=>{let e=eF();e&&e$({blockRef:e.blockRef,el:e.blockEl})},[eF]),eW=(0,d.useRef)(!1),eK=(0,d.useRef)(!1),eq=(0,d.useRef)(null),eJ=e=>e.replace(/\s+$/g,"").trimStart(),eG=(0,d.useCallback)(async()=>{if(eK.current||eb.current||"suggesting"!==g.useEditorStore.getState().editMode||!eW.current)return;let e=eY.current,t=g.useEditorStore.getState().currentPath;if(!e||!t)return;let n=eN.current?.querySelector(".ProseMirror");if(!n)return;let r=Array.from(n.children),i=w.useProofStore.getState().byPath[t]?.snapshotBlocks??[];if(0!==i.length){eK.current=!0,eW.current=!1;try{let n=()=>w.useProofStore.getState().byPath[t]?.snapshotRevision??0,o=async()=>{await w.useProofStore.getState().loadSnapshot(t),await w.useProofStore.getState().loadSidecar(t)},s=Math.max(r.length,i.length),a=!1;for(let e=0;e<s;e++){let s=r[e],l=i[e],c=s?(0,p.htmlToMarkdown)(s.outerHTML,t).trim():null;if(l&&null!==c){if(eJ(c)!==eJ(l.markdown)){let e=await (0,x.captureSuggestion)({path:t,ref:l.ref,kind:"replace",markdown:c,getRevision:n,refresh:o});a=a||e}}else if(l&&null===c){let e=await (0,x.captureSuggestion)({path:t,ref:l.ref,kind:"delete",getRevision:n,refresh:o});a=a||e}else if(!l&&null!==c&&c.length>0){let e=i[i.length-1]?.ref;if(e){let r=await (0,x.captureSuggestion)({path:t,ref:e,kind:"insertAfter",markdown:c,getRevision:n,refresh:o});a=a||r}}}if(a){await o();let n=(w.useProofStore.getState().byPath[t]?.snapshotBlocks??i).map(e=>e.markdown).join("\n\n");ey.current=!0;let r=await (0,h.markdownToHtml)(n,t);e.commands.setContent(r),setTimeout(()=>{ey.current=!1},50)}}finally{eK.current=!1}}},[]);(0,d.useEffect)(()=>{if(!H)return;let e=setTimeout(()=>{w.useProofStore.getState().loadSnapshot(H)},200);return()=>clearTimeout(e)},[H]),(0,d.useEffect)(()=>{if(!H||0===eI.length||!eN.current)return;let e=eN.current,t=e.querySelector(".ProseMirror");if(!t)return;let n=Array.from(t.children),r=e.getBoundingClientRect(),i=new Map;for(let t=0;t<Math.min(n.length,eI.length);t++){let o=n[t],s=eI[t];o.setAttribute("data-block-ref",s.ref);let a=o.getBoundingClientRect();i.set(s.ref,{top:a.top-r.top+e.scrollTop,left:a.left-r.left,width:a.width,bottom:a.bottom-r.top+e.scrollTop})}eT(i)},[H,eI]);let eX=(0,d.useCallback)(({editor:e})=>{if(ey.current||eb.current||!e)return;"suggesting"===g.useEditorStore.getState().editMode&&(eW.current=!0);let t=e.getHTML(),n=(0,p.htmlToMarkdown)(t,g.useEditorStore.getState().currentPath??void 0);g.useEditorStore.getState().updateContent(n)},[]),eZ=(0,r.useEditor)({extensions:M.editorExtensions,content:"",editable:!Q,onUpdate:eX,onBlur:()=>{eG()},onSelectionUpdate:({editor:e})=>{if("suggesting"!==g.useEditorStore.getState().editMode)return;let{from:t}=e.state.selection,n=e.state.doc.resolve(t),r=n.depth>0?n.index(0):0,i=eq.current;eq.current=r,null!==i&&i!==r&&eW.current&&eG()},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:(e,t)=>{if((t.metaKey||t.ctrlKey)&&"a"===t.key.toLowerCase()&&(0,n.isInTable)(e.state)){let r=(0,n.cellAround)(e.state.selection.$from),i=r?.nodeAfter;if(!r||!i)return!1;let o=r.pos+1,s=r.pos+i.nodeSize-1;return(e.state.selection.from!==o||e.state.selection.to!==s)&&(t.preventDefault(),eZ?.chain().focus().setTextSelection({from:o,to:s}).run(),!0)}return!1},handleClick:(e,t,n)=>{let r=n.target.closest("a");if(!r)return!1;let i=r.getAttribute("href");if(!i)return!1;if("true"===r.dataset.wikiLink){n.preventDefault(),n.stopPropagation();let e=r.dataset.slug??"",t=r.dataset.anchor??null;if(!e)return!0;let i=v.useWikiSlugsStore.getState();if(i.has(e)){let n=i.getDir(e),r=null===n||"root"===n?`${e}.md`:`${n}/${e}.md`;g.useEditorStore.getState().loadPage(r),t&&setTimeout(()=>{document.querySelector(`[id="${t}"]`)?.scrollIntoView({behavior:"smooth"})},200)}else{if(eb.current)return!0;eg.current(e).then(e=>{if(e.ok){let t=e.dir??"entities",n=`${t}/${e.slug}.md`;g.useEditorStore.getState().loadPage(n)}})}return!0}if(i.startsWith("#page:")){n.preventDefault(),n.stopPropagation();let e=i.replace("#page:",""),{nodes:t,selectPage:r,expandPath:o}=y.useTreeStore.getState(),s=eo(e,g.useEditorStore.getState().currentPath,t);return s&&es(s,r,o),!0}if(/^https?:\/\//.test(i)||i.startsWith("/api/")||i.startsWith("mailto:")||i.startsWith("tel:"))return!1;n.preventDefault(),n.stopPropagation();let{nodes:o,selectPage:s,expandPath:a}=y.useTreeStore.getState(),l=function(e,t,n){let r=ei(n),i=e.replace(/\.md$/,"").replace(/^\.\//,"").replace(/^\//,""),o=r.find(e=>e.path===i);if(o)return o.path;if(t){let e=t.includes("/")?t.substring(0,t.lastIndexOf("/")):"",n=e?`${e}/${i}`:i,o=r.find(e=>e.path===n);if(o)return o.path}return eo(i.includes("/")?i.split("/").pop():i,t,n)}(i,g.useEditorStore.getState().currentPath,o);return l&&es(l,s,a),!0},handlePaste:(e,t)=>{if(eb.current)return!1;let n=t.clipboardData?.files,r=g.useEditorStore.getState().currentPath;if(n&&n.length>0&&r){for(let e of Array.from(n))er(r,e).then(t=>{t&&eZ&&(e.type.startsWith("image/")?eZ.chain().focus().setImage({src:t,alt:e.name}).run():eZ.chain().focus().insertContent(`<a href="${t}">${e.name}</a>`).run())});return!0}return!1},handleDrop:(e,t)=>{if(eb.current)return!1;let n=t.dataTransfer?.files;if(!n||0===n.length)return!1;let r=g.useEditorStore.getState().currentPath;if(!r)return!1;for(let e of(t.preventDefault(),Array.from(n)))er(r,e).then(t=>{t&&eZ&&(e.type.startsWith("image/")?eZ.chain().focus().setImage({src:t,alt:e.name}).run():eZ.chain().focus().insertContent(`<a href="${t}">${e.name}</a>`).run())});return!0}},immediatelyRender:!1}),eY=(0,d.useRef)(eZ);eY.current=eZ,(0,d.useEffect)(()=>{eZ?.setEditable(!Q),Q&&ew(!1)},[eZ,Q]);let eQ=(0,d.useRef)(null),e0=(0,d.useRef)(null),[e1,e2]=(0,d.useState)(null);(0,d.useEffect)(()=>{if(!eZ||null===H||g.useEditorStore.getState().isDirty&&H===eQ.current||U&&""===B)return;let e=ea.body,t=`${H} ${e}`;if(e0.current===t){e1!==H&&e2(H);return}eQ.current=H;let n=!1;return(async()=>{ey.current=!0;let r=await (0,h.markdownToHtml)(e,Q?{pagePath:H,sanitize:!0}:H);if(n||g.useEditorStore.getState().currentPath!==H){ey.current=!1;return}eZ.commands.setContent(r),e0.current=t,e2(H),setTimeout(()=>{ey.current=!1},50)})(),()=>{n=!0}},[eZ,B,H,U,e1,ea.body,Q]),(0,d.useEffect)(()=>{if(!Q||!e1)return;let e=eN.current;e&&e.querySelectorAll('input[type="checkbox"]').forEach(e=>{e.disabled=!0})},[Q,e1,ea.body]);let e5=null!==H&&(U||e1!==H),[e3,e4]=(0,d.useState)(!1);if((0,d.useEffect)(()=>{if(!e5)return void e4(!1);let e=setTimeout(()=>e4(!0),150);return()=>clearTimeout(e)},[e5]),null===H)return(0,t.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,t.jsxs)("div",{className:"text-center space-y-3",children:[(0,t.jsx)("p",{className:"text-lg font-medium tracking-[-0.02em]",children:"No page selected"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground/70",children:"Select a page from the sidebar or create a new one"})]})});if("missing"===q){let e=(H.split("/").pop()||H).replace(/[-_]+/g," ").replace(/\b\w/g,e=>e.toUpperCase()),n=(0,u.findNodeByPath)(el,H),r=n?.children??[],i=r.length>0;return(0,t.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,t.jsxs)("div",{className:"max-w-3xl mx-auto px-6 py-10 space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-lg font-medium tracking-[-0.02em] text-foreground",children:e}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground/80",children:["This folder doesn't have an"," ",(0,t.jsx)("code",{className:"px-1 py-0.5 rounded bg-muted text-[12px]",children:"index.md"}),i?" yet — its contents are listed below.":" yet."]}),(0,t.jsxs)("button",{onClick:()=>void G(e),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,t.jsx)(a.FilePlus,{className:"h-3.5 w-3.5"}),"Create page"]})]}),i&&(0,t.jsx)(N.FolderIndex,{folderPath:H,entries:r},H)]})})}let e6=async()=>{if(ev){if(g.useEditorStore.getState().updateContent(ex),eZ){ey.current=!0;let e=await (0,h.markdownToHtml)(ex,H??void 0);eZ.commands.setContent(e),setTimeout(()=>{ey.current=!1},50)}ew(!1)}else ek(g.useEditorStore.getState().content),ew(!0)},e9=(0,u.findNodeByPath)(el,H),e7=e9?.type==="directory"||e9?.type==="cabinet"?e9.children??[]:[],e8=e7.length>0,te=e8&&"files"===eS;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e8&&(0,t.jsxs)("div",{className:"flex items-center gap-1 px-3 pt-2 border-b border-border",children:[(0,t.jsx)("button",{onClick:()=>eC("page"),className:`px-3 py-1.5 text-[12px] rounded-t-md border-b-2 -mb-px transition-colors ${"page"===eS?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,"aria-pressed":"page"===eS,children:"Page"}),(0,t.jsxs)("button",{onClick:()=>eC("files"),className:`px-3 py-1.5 text-[12px] rounded-t-md border-b-2 -mb-px transition-colors ${"files"===eS?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,"aria-pressed":"files"===eS,children:["Files",(0,t.jsx)("span",{className:"ml-1.5 text-muted-foreground/60",children:e7.length})]})]}),te?(0,t.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,t.jsx)("div",{className:"max-w-3xl mx-auto px-6 py-6",children:(0,t.jsx)(N.FolderIndex,{folderPath:H,entries:e7},H)})}):(0,t.jsxs)(t.Fragment,{children:[!Q&&(0,t.jsxs)("div",{className:"flex items-center min-w-0",children:[(0,t.jsx)("div",{className:"flex-1 min-w-0",children:!ev&&(0,t.jsx)(E.EditorToolbar,{editor:eZ})}),(0,t.jsxs)("button",{onClick:e6,className:`flex items-center gap-1.5 px-3 py-1 mr-2 text-[11px] rounded-md transition-colors border border-border ${ev?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"}`,children:[(0,t.jsx)(s.Code2,{className:"h-3 w-3"}),ev?"Preview":"Markdown"]})]}),ev?(0,t.jsx)("div",{className:"flex-1 overflow-y-auto p-4",dir:eu?"rtl":void 0,children:(0,t.jsx)("textarea",{value:ex,onChange:e=>ek(e.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,t.jsxs)("div",{className:"flex-1 relative",dir:eu?"rtl":void 0,children:[et&&(0,t.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,t.jsx)(I.DocumentOutline,{editor:eZ,scrollContainerRef:eN}),(0,t.jsxs)("div",{ref:eN,className:`absolute inset-0 overflow-y-auto ${et?"pt-7":""}`,style:{"--editor-max-w":ec,"--editor-ml":ed},"data-editor-scroll":!0,children:[(0,t.jsxs)("div",{"aria-hidden":"true",className:"relative pointer-events-none",style:{height:0},children:[Object.entries(ez).map(([e,n])=>{let r=eA.get(e);return r?(0,t.jsx)("div",{style:{pointerEvents:"auto"},children:(0,t.jsx)(A.CommentPip,{blockRef:e,comments:n,top:r.top+4,left:Math.max(0,r.left-20),onClick:()=>{let t=eN.current?.querySelector(`[data-block-ref="${e}"]`);t&&e$({blockRef:e,el:t})}})},`pip-${e}`):null}),H&&eL.map(e=>{let n=eA.get(e.ref),r=eI.find(t=>t.ref===e.ref);if(!n||!r)return null;let i="insertAfter"===e.kind?n.bottom+4:"insertBefore"===e.kind?Math.max(0,n.top-80):n.top;return(0,t.jsx)("div",{style:{pointerEvents:"auto"},children:(0,t.jsx)(O.SuggestionCard,{path:H,suggestion:e,currentMarkdown:r.markdown,baseRevision:eD,getLatestRevision:()=>w.useProofStore.getState().byPath[H]?.snapshotRevision??0,top:i,left:n.left,width:n.width,onSettled:()=>{w.useProofStore.getState().loadSidecar(H),w.useProofStore.getState().loadSnapshot(H)},readOnly:Q})},`sug-${e.id}`)})]}),e_&&H&&(0,t.jsx)(T.CommentThread,{path:H,blockRef:e_.blockRef,comments:ez[e_.blockRef]??[],anchorEl:e_.el,onClose:()=>e$(null),readOnly:Q}),eH&&H&&(0,t.jsx)(D.SuggestEditPopover,{path:H,blockRef:eH.blockRef,currentMarkdown:eH.markdown,anchor:eH.anchor,onClose:()=>eB(null)}),Q&&Object.keys(ea.data).length>0&&(0,t.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,t.jsx)(ee,{data:ea.data})}),(0,t.jsx)(r.EditorContent,{editor:eZ}),H&&/\.(md|markdown)$/i.test(H)&&(0,t.jsx)(P.BacklinksPanel,{currentPath:H}),(0,t.jsx)("div",{"aria-hidden":"true",className:"contents",onMouseOver:e=>{let t=e.target.closest(".proof-span");t&&t!==eE&&eM(t)},onMouseOut:e=>{let t=e.relatedTarget;t?.closest(".proof-span")||eM(null)}}),H&&(0,t.jsx)(R.ProofSpanPopover,{targetEl:eE,path:H,onClose:()=>eM(null),onComment:()=>{if(!eE)return;let e=eE.closest("[data-block-ref]");if(!e)return;let t=e.getAttribute("data-block-ref");t&&e$({blockRef:t,el:e})}}),!Q&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(C.EditorBubbleMenu,{editor:eZ,onSuggestEdit:eV,onComment:eU}),(0,t.jsx)(L.TableMenu,{editor:eZ}),(0,t.jsx)(j.SlashCommands,{editor:eZ}),(0,t.jsx)(J,{editor:eZ,onCreateRequest:eg.current})]}),Q&&(0,t.jsx)(en,{containerRef:eN,onComment:eU}),(0,t.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,t.jsxs)("button",{onClick:()=>{ep(),eh()},className:"group flex items-center gap-2 text-[13px] text-muted-foreground/50 hover:text-muted-foreground transition-colors cursor-pointer",children:[(0,t.jsx)(c.Sparkles,{className:"h-3.5 w-3.5 group-hover:text-primary transition-colors"}),(0,t.jsx)("span",{children:"Edit with AI"})]}),!Q&&(0,t.jsxs)("span",{className:"text-[11px] text-muted-foreground/30 select-none",children:[(0,t.jsx)("kbd",{className:"rounded px-1 py-0.5 font-mono text-[10px] ring-1 ring-foreground/10",children:"/"})," ","for commands"]})]})]}),e3&&(0,t.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,t.jsx)(l.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground/70"})})]}),!Q&&(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-1 border-t border-border text-xs text-muted-foreground/60",children:[(0,t.jsxs)("span",{className:"text-[10.5px] text-muted-foreground/30 select-none hidden sm:block",children:[(0,t.jsx)("kbd",{className:"rounded px-1 font-mono text-[9.5px] ring-1 ring-foreground/10",children:"⌘S"})," ","save",(0,t.jsx)("span",{className:"mx-1.5 opacity-40",children:"·"}),(0,t.jsx)("kbd",{className:"rounded px-1 font-mono text-[9.5px] ring-1 ring-foreground/10",children:"/"})," ","commands"]}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsxs)("div",{className:"flex items-center rounded-md border border-border overflow-hidden text-[10.5px]",role:"radiogroup","aria-label":"Edit mode",children:[(0,t.jsx)("button",{type:"button",role:"radio","aria-checked":"editing"===X,onClick:()=>Z("editing"),className:`px-2 py-0.5 transition-colors ${"editing"===X?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"}`,children:"Editing"}),(0,t.jsx)("button",{type:"button",role:"radio","aria-checked":"suggesting"===X,onClick:()=>Z("suggesting"),className:`px-2 py-0.5 transition-colors ${"suggesting"===X?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"}`,children:"Suggesting"})]}),(0,t.jsxs)("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10.5px] transition-all duration-300 ${"idle"===F?"opacity-0 pointer-events-none":"opacity-100"} ${"saving"===F?"bg-muted text-muted-foreground":"saved"===F?"bg-success/10 text-success":"error"===F?"bg-destructive/10 text-destructive":""}`,children:["saving"===F&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(l.Loader2,{className:"h-2.5 w-2.5 animate-spin"}),"Saving…"]}),"saved"===F&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.Check,{className:"h-2.5 w-2.5"}),"Saved"]}),"error"===F&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(i.AlertCircle,{className:"h-2.5 w-2.5"}),"Save failed"]})]})]})]})]})]}),em]})}],912235)},780569,e=>{"use strict";var t=e.i(44501),n=e.i(43240),r=e.i(792934),i=e.i(519455),o=e.i(755146),s=e.i(395624);e.s(["ViewWidthToggle",0,function({className:e}){let a=(0,s.useViewWidthStore)(e=>e.width),l=(0,s.useViewWidthStore)(e=>e.setWidth),c=(0,s.useViewWidthStore)(e=>e.align),d=(0,s.useViewWidthStore)(e=>e.setAlign);return(0,t.jsxs)(o.DropdownMenu,{children:[(0,t.jsx)(o.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsx)(i.Button,{size:"sm",variant:"ghost",className:`h-7 w-7 p-0 ${e??""}`,title:`Content width: ${s.VIEW_WIDTH_LABEL[a]}`,children:(0,t.jsx)(r.AlignJustify,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(o.DropdownMenuContent,{align:"end",className:"w-36",children:[(0,t.jsx)(o.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Width"}),s.VIEW_WIDTH_ORDER.map(e=>(0,t.jsxs)(o.DropdownMenuItem,{onClick:()=>l(e),className:"flex items-center justify-between text-xs",children:[s.VIEW_WIDTH_LABEL[e],e===a&&(0,t.jsx)(n.Check,{className:"h-3.5 w-3.5"})]},e)),(0,t.jsx)(o.DropdownMenuSeparator,{}),(0,t.jsx)(o.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Alignment"}),s.VIEW_ALIGN_ORDER.map(e=>(0,t.jsxs)(o.DropdownMenuItem,{onClick:()=>d(e),className:"flex items-center justify-between text-xs",children:[s.VIEW_ALIGN_LABEL[e],e===c&&(0,t.jsx)(n.Check,{className:"h-3.5 w-3.5"})]},e))]})]})}])},894013,409082,847463,e=>{"use strict";var t=e.i(44501),n=e.i(605993);let r=(0,n.default)("moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);e.s(["Moon",0,r],409082);let i=(0,n.default)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);e.s(["Sun",0,i],847463);var o=e.i(917356),s=e.i(519455);e.s(["ThemeToggle",0,function({className:e}){let{resolvedTheme:n,setTheme:a}=(0,o.useTheme)();return(0,t.jsx)(s.Button,{size:"sm",variant:"ghost",className:`h-7 w-7 p-0 ${e??""}`,title:"dark"===n?"Switch to light":"Switch to dark",onClick:()=>a("dark"===n?"light":"dark"),children:"dark"===n?(0,t.jsx)(i,{className:"h-3.5 w-3.5"}):(0,t.jsx)(r,{className:"h-3.5 w-3.5"})})}],894013)}]);