wiki-viewer 1.5.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/api/wiki/upload/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0-ao6a_._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{0~w0_katex_dist_katex_mjs_055boxx._.js → 0~w0_katex_dist_katex_mjs_00650~e._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__134_q7l._.js → [root-of-the-server]__12ahxbl._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/_0pqaawz._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0rc1vh5._.js → node_modules__pnpm_02gx8km._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0t4unpg._.js → node_modules__pnpm_02mew~s._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_12-ni1n._.js → node_modules__pnpm_03ij5.g._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_12~a4c_._.js → node_modules__pnpm_03v21p-._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0f~_mm3._.js → node_modules__pnpm_05qsply._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0alwr5e._.js → node_modules__pnpm_06pgebo._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_02zxe7o._.js → node_modules__pnpm_08ibh0w._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0hr027i._.js → node_modules__pnpm_099cv.b._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0znncy9._.js → node_modules__pnpm_0cwpt9p._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0-pisfi._.js → node_modules__pnpm_0f9fpy5._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0zhbnni._.js → node_modules__pnpm_0f_uzgy._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0-w-d-.._.js → node_modules__pnpm_0fixtms._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_03z0vkh._.js → node_modules__pnpm_0gofu~q._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_10i6lh6._.js → node_modules__pnpm_0iojvye._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0-hfev1._.js → node_modules__pnpm_0li2vzs._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_13kfy_z._.js → node_modules__pnpm_0m5-azh._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_071f6vl._.js → node_modules__pnpm_0n1kfcp._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_07uh2kc._.js → node_modules__pnpm_0rebktf._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0okw1r.._.js → node_modules__pnpm_0tkiej3._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0xuz.8f._.js → node_modules__pnpm_0v_nwsz._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0zb6573._.js → node_modules__pnpm_0wffzo0._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0d7jxsf._.js → node_modules__pnpm_0wouz19._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0egenev._.js → node_modules__pnpm_0xxwmv2._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0j9bq9s._.js → node_modules__pnpm_0zzzsrj._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0irsd.b._.js → node_modules__pnpm_0~.6dgb._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0erwv_m._.js → node_modules__pnpm_0~2~c30._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0y9k6h~._.js → node_modules__pnpm_10413dq._.js} +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
- package/.next/standalone/.next/server/middleware-manifest.json +1 -1
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/static/chunks/{14luv~jq7e6-n.js → 17~r3.8awh3qg.js} +2 -2
- package/.next/standalone/agents/bootstrap-prompt.md +1 -1
- package/.next/standalone/agents/wiki-viewer-skill/SKILL.md +1 -1
- package/.next/standalone/package.json +1 -1
- package/.next/standalone/src/app/api/system/auth-settings/route.ts +1 -0
- package/.next/standalone/src/components/ai-panel/ai-panel.tsx +70 -124
- package/.next/standalone/src/components/ai-panel/token-section.tsx +8 -7
- package/.next/standalone/src/components/auth-settings-sheet.tsx +81 -22
- package/.next/standalone/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- /package/.next/standalone/.next/static/{19j4-_brJLoulXAMekpM2 → _avhhNXTnEvzPnQc1sIDF}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{19j4-_brJLoulXAMekpM2 → _avhhNXTnEvzPnQc1sIDF}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{19j4-_brJLoulXAMekpM2 → _avhhNXTnEvzPnQc1sIDF}/_ssgManifest.js +0 -0
|
@@ -112,7 +112,7 @@ ${i}
|
|
|
112
112
|
`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[u1({find:Aw,type:this.type})]}}),AT=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,AN=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,AA=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,AS=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,AC=uD.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>"normal"!==e.style.fontWeight&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return AE("strong",{...dq(this.options.HTMLAttributes,e),children:AE("slot",{})})},markdownTokenName:"strong",parseMarkdown:(e,t)=>t.applyMark("bold",t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[uJ({find:AT,type:this.type}),uJ({find:AA,type:this.type})]},addPasteRules(){return[hi({find:AN,type:this.type}),hi({find:AS,type:this.type})]}}),A_=/(^|[^`])`([^`]+)`(?!`)$/,AM=/(^|[^`])`([^`]+)`(?!`)/g,AO=uD.create({name:"code",addOptions:()=>({HTMLAttributes:{}}),excludes:"_",code:!0,exitable:!0,parseHTML:()=>[{tag:"code"}],renderHTML({HTMLAttributes:e}){return["code",dq(this.options.HTMLAttributes,e),0]},markdownTokenName:"codespan",parseMarkdown:(e,t)=>t.applyMark("code",[{type:"text",text:e.text||""}]),renderMarkdown:(e,t)=>e.content?`\`${t.renderChildren(e.content)}\``:"",addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[uJ({find:A_,type:this.type})]},addPasteRules(){return[hi({find:AM,type:this.type})]}}),AI=hn.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n\n"):""}),AD=hn.create({name:"hardBreak",markdownTokenName:"br",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:e}){return["br",dq(this.options.HTMLAttributes,e)]},renderText:()=>"\n",renderMarkdown:()=>`
|
|
113
113
|
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:o}=this.options,{splittableMarks:s}=r.extensionManager,a=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&a&&o){let t=a.filter(e=>s.includes(e.type.name));e.ensureMarks(t)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),AR=hn.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){let n=this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0];return[`h${n}`,dq(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode("heading",{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{var n;let r=(null==(n=e.attrs)?void 0:n.level)?parseInt(e.attrs.level,10):1,i="#".repeat(r);return e.content?`${i} ${t.renderChildren(e.content)}`:""},addCommands(){return{setHeading:e=>({commands:t})=>!!this.options.levels.includes(e.level)&&t.setNode(this.name,e),toggleHeading:e=>({commands:t})=>!!this.options.levels.includes(e.level)&&t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>u0({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),AL=hn.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{},nextNodeType:"paragraph"}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:e}){return["hr",dq(this.options.HTMLAttributes,e)]},markdownTokenName:"hr",parseMarkdown:(e,t)=>t.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!function(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof op){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}(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return ue(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(ou.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(op.create(t.doc,n.pos)):t.setSelection(ou.create(t.doc,n.pos));else{let i=e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType,o=null==i?void 0:i.create();o&&(t.insert(r,o),t.setSelection(ou.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[uZ({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),AP=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Aj=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,AB=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,AF=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,AH=uD.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>"normal"!==e.style.fontStyle&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",dq(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(e,t)=>t.applyMark("italic",t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[uJ({find:AP,type:this.type}),uJ({find:AB,type:this.type})]},addPasteRules(){return[hi({find:Aj,type:this.type}),hi({find:AF,type:this.type})]}}),AU=" ",Az=hn.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:e}){return["p",dq(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(1===n.length&&"image"===n[0].type)return t.parseChildren([n[0]]);let r=t.parseInline(n);return 1===n.length&&"text"===n[0].type&&(n[0].raw===AU||n[0].text===AU||" "===n[0].raw||" "===n[0].text)&&1===r.length&&"text"===r[0].type&&(r[0].text===AU||" "===r[0].text)?t.createNode("paragraph",void 0,[]):t.createNode("paragraph",void 0,r)},renderMarkdown:(e,t,n)=>{var r,i;if(!e)return"";let o=Array.isArray(e.content)?e.content:[];if(0===o.length){let e=Array.isArray(null==(r=null==n?void 0:n.previousNode)?void 0:r.content)?n.previousNode.content:[];return(null==(i=null==n?void 0:n.previousNode)?void 0:i.type)==="paragraph"&&0===e.length?AU:""}return t.renderChildren(o)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),A$=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,AG=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Aq=uD.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("line-through")&&{}}],renderHTML({HTMLAttributes:e}){return["s",dq(this.options.HTMLAttributes,e),0]},markdownTokenName:"del",parseMarkdown:(e,t)=>t.applyMark("strike",t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[uJ({find:A$,type:this.type})]},addPasteRules(){return[hi({find:AG,type:this.type})]}}),AV=hn.create({name:"text",group:"inline",parseMarkdown:e=>({type:"text",text:e.text||""}),renderMarkdown:e=>e.text||""}),AW=uD.create({name:"underline",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("underline")&&{}}],renderHTML({HTMLAttributes:e}){return["u",dq(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||"underline",t.parseInline(e.tokens||[]))},renderMarkdown:(e,t)=>`++${t.renderChildren(e)}++`,markdownTokenizer:{name:"underline",level:"inline",start:e=>e.indexOf("++"),tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:"underline",raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),AK=uj.create({name:"starterKit",addExtensions(){var e,t,n,r;let i=[];return!1!==this.options.bold&&i.push(AC.configure(this.options.bold)),!1!==this.options.blockquote&&i.push(Ak.configure(this.options.blockquote)),!1!==this.options.bulletList&&i.push(N6.configure(this.options.bulletList)),!1!==this.options.code&&i.push(AO.configure(this.options.code)),!1!==this.options.codeBlock&&i.push(kR.configure(this.options.codeBlock)),!1!==this.options.document&&i.push(AI.configure(this.options.document)),!1!==this.options.dropcursor&&i.push(NI.configure(this.options.dropcursor)),!1!==this.options.gapcursor&&i.push(ND.configure(this.options.gapcursor)),!1!==this.options.hardBreak&&i.push(AD.configure(this.options.hardBreak)),!1!==this.options.heading&&i.push(AR.configure(this.options.heading)),!1!==this.options.undoRedo&&i.push(Nz.configure(this.options.undoRedo)),!1!==this.options.horizontalRule&&i.push(AL.configure(this.options.horizontalRule)),!1!==this.options.italic&&i.push(AH.configure(this.options.italic)),!1!==this.options.listItem&&i.push(N9.configure(this.options.listItem)),!1!==this.options.listKeymap&&i.push(Au.configure(null==(e=this.options)?void 0:e.listKeymap)),!1!==this.options.link&&i.push(No.configure(null==(t=this.options)?void 0:t.link)),!1!==this.options.orderedList&&i.push(Ag.configure(this.options.orderedList)),!1!==this.options.paragraph&&i.push(Az.configure(this.options.paragraph)),!1!==this.options.strike&&i.push(Aq.configure(this.options.strike)),!1!==this.options.text&&i.push(AV.configure(this.options.text)),!1!==this.options.underline&&i.push(AW.configure(null==(n=this.options)?void 0:n.underline)),!1!==this.options.trailingNode&&i.push(NU.configure(null==(r=this.options)?void 0:r.trailingNode)),i}});function AY(e){let t=e.regex,n={};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},{begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]}]});let r={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},i=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),o={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},s={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,r]};r.contains.push(s);let a={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},l=e.SHEBANG({binary:"(fish|bash|zsh|sh|csh|ksh|tcsh|dash|scsh)",relevance:10}),c={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0};return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],literal:["true","false"],built_in:["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset","alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias","set","shopt","autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp","chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"]},contains:[l,e.SHEBANG(),c,a,i,o,{match:/(\/[a-z._-]+)+/},s,{match:/\\"/},{className:"string",begin:/'/,end:/'/},{match:/\\'/},n]}}let AX=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video","defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],AQ=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),AJ=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),AZ=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),A0=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function A1(e){let t=e.regex,n={IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}},r=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,{begin:/-(webkit|moz|ms|o)-(?=[a-z])/},n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\.[a-zA-Z-][a-zA-Z0-9_-]*",relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+AJ.join("|")+")"},{begin:":(:)?("+AZ.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+A0.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...r,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...r,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:/@-?\w[\w]*(-\w+)*/},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:"and or not only",attribute:AQ.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...r,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+AX.join("|")+")\\b"}]}}function A2(e){let t={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:t,illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"string",variants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[e.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:t,illegal:/["']/}]}]}}let A3="[A-Za-z$_][0-9A-Za-z$_]*",A5=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],A4=["true","false","null","undefined","NaN","Infinity"],A6=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],A9=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],A7=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],A8=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Se=[].concat(A7,A6,A9);function St(e){var t;let n=e.regex,r=/<[A-Za-z0-9\\._:-]+/,i=/\/[A-Za-z0-9\\._:-]+>|\/>/,o={$pattern:A3,keyword:A5,literal:A4,built_in:Se,"variable.language":A8},s="[0-9](_?[0-9])*",a=`\\.(${s})`,l="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",c={className:"number",variants:[{begin:`(\\b(${l})((${a})|\\.)?|(${a}))[eE][+-]?(${s})\\b`},{begin:`\\b(${l})\\b((${a})\\b|\\.)?|(${a})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},d={className:"subst",begin:"\\$\\{",end:"\\}",keywords:o,contains:[]},u={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,d],subLanguage:"xml"}},h={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,d],subLanguage:"css"}},p={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,d],subLanguage:"graphql"}},f={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,d]},m={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:A3+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},g=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,u,h,p,f,{match:/\$\d+/},c];d.contains=g.concat({begin:/\{/,end:/\}/,keywords:o,contains:["self"].concat(g)});let b=[].concat(m,d.contains),y=b.concat([{begin:/(\s*)\(/,end:/\)/,keywords:o,contains:["self"].concat(b)}]),x={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:y},v={variants:[{match:[/class/,/\s+/,A3,/\s+/,/extends/,/\s+/,n.concat(A3,"(",n.concat(/\./,A3),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,A3],scope:{1:"keyword",3:"title.class"}}]},E={relevance:0,match:n.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...A6,...A9]}},w={match:n.concat(/\b/,(t=[...A7,"super","import"].map(e=>`${e}\\s*\\(`),n.concat("(?!",t.join("|"),")")),A3,n.lookahead(/\s*\(/)),className:"title.function",relevance:0},k={begin:n.concat(/\./,n.lookahead(n.concat(A3,/(?![0-9A-Za-z$_(])/))),end:A3,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},T="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",N={match:[/const|var|let/,/\s+/,A3,/\s*/,/=\s*/,/(async\s*)?/,n.lookahead(T)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[x]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:o,exports:{PARAMS_CONTAINS:y,CLASS_REFERENCE:E},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),{label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,u,h,p,f,m,{match:/\$\d+/},c,E,{scope:"attr",match:A3+n.lookahead(":"),relevance:0},N,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[m,e.REGEXP_MODE,{className:"function",begin:T,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:y}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:"<>",end:"</>"},{match:/<[A-Za-z0-9\\._:-]+\s*\/>/},{begin:r,"on:begin":(e,t)=>{let n,r=e[0].length+e.index,i=e.input[r];if("<"===i||","===i)return void t.ignoreMatch();">"!==i||((e,{after:t})=>{let n="</"+e[0].slice(1);return -1!==e.input.indexOf(n,t)})(e,{after:r})||t.ignoreMatch();let o=e.input.substring(r);if((n=o.match(/^\s*=/))||(n=o.match(/^\s+extends\s+/))&&0===n.index)return void t.ignoreMatch()},end:i}],subLanguage:"xml",contains:[{begin:r,end:i,skip:!0,contains:["self"]}]}]},{variants:[{match:[/function/,/\s+/,A3,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[x],illegal:/%/},{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[x,e.inherit(e.TITLE_MODE,{begin:A3,className:"title.function"})]},{match:/\.\.\./,relevance:0},k,{match:"\\$"+A3,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[x]},w,{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},v,{match:[/get|set/,/\s+/,A3,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},x]},{match:/\$[(.]/}]}}function Sn(e){let t=["true","false","null"],n={scope:"literal",beginKeywords:t.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:t},contains:[{className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},{match:/[{}[\],:]/,className:"punctuation",relevance:0},e.QUOTE_STRING_MODE,n,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function Sr(e){let t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,/[A-Za-z][A-Za-z0-9+.-]*/,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},i={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},o={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},s=e.inherit(i,{contains:[]}),a=e.inherit(o,{contains:[]});i.contains.push(a),o.contains.push(s);let l=[n,r];return[i,o,s,a].forEach(e=>{e.contains=e.contains.concat(l)}),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:l=l.concat(i,o)},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:l}]}]},n,{className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},i,o,{className:"quote",begin:"^>\\s+",contains:l,end:"$"},{className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},{begin:"^[-\\*]{3,}",end:"$"},r,{begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function Si(e){let t=e.regex,n=/[\p{XID_Start}_]\p{XID_Continue}*/u,r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],i={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},o={className:"meta",begin:/^(>>>|\.\.\.) /},s={className:"subst",begin:/\{/,end:/\}/,keywords:i,illegal:/#/},a={begin:/\{\{/,relevance:0},l={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,o],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,o],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,o,a,s]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,o,a,s]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,a,s]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,a,s]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},c="[0-9](_?[0-9])*",d=`(\\b(${c}))?\\.(${c})|\\b(${c})\\.`,u=`\\b|${r.join("|")}`,h={className:"number",relevance:0,variants:[{begin:`(\\b(${c})|(${d}))[eE][+-]?(${c})[jJ]?(?=${u})`},{begin:`(${d})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${u})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${u})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${u})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${u})`},{begin:`\\b(${c})[jJ](?=${u})`}]},p={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:i,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},f={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:i,contains:["self",o,h,l,e.HASH_COMMENT_MODE]}]};return s.contains=[l,h,o],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:i,illegal:/(<\/|\?)|=>/,contains:[o,h,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},l,p,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[f]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[h,f,l]}]}}function So(e){let t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),i=t.concat(n,e.IDENT_RE),o={className:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,i,t.lookahead(/\s*\(/))},s="([ui](8|16|32|64|128|size)|f(32|64))?",a=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],l=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:l,keyword:["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],literal:["true","false","Some","None","Ok","Err"],built_in:a},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+s},{begin:"\\b0o([0-7_]+)"+s},{begin:"\\b0x([A-Fa-f0-9_]+)"+s},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+s}],relevance:0},{begin:[/fn/,/\s+/,r],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:a,type:l}},{className:"punctuation",begin:"->"},o]}}function Ss(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function Sa(e){let t=e.regex,n=e.COMMENT("--","$"),r=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],i=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year","add","asc","collation","desc","final","first","last","view"].filter(e=>!r.includes(e)),o={match:t.concat(/\b/,t.either(...r),/\s*\(/),relevance:0,keywords:{built_in:r}};function s(e){return t.concat(/\b/,t.either(...e.map(e=>e.replace(/\s+/,"\\s+"))),/\b/)}let a={scope:"keyword",match:s(["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"]),relevance:0};return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:function(e,{exceptions:t,when:n}={}){return t=t||[],e.map(e=>e.match(/\|\d+$/)||t.includes(e)?e:n(e)?`${e}|0`:e)}(i,{when:e=>e.length<3}),literal:["true","false","unknown"],type:["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],built_in:["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"]},contains:[{scope:"type",match:s(["double precision","large object","with timezone","without timezone"])},a,o,{scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},{scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},{begin:/"/,end:/"/,contains:[{match:/""/}]},e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,{scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0}]}}let Sl="[A-Za-z$_][0-9A-Za-z$_]*",Sc=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],Sd=["true","false","null","undefined","NaN","Infinity"],Su=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Sh=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Sp=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Sf=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Sm=[].concat(Sp,Su,Sh);function Sg(e){var t;let n,r,i,o,s,a,l,c,d,u,h,p,f,m,g,b,y,x,v,E,w,k,T,N,A,S=e.regex,C=(n=e.regex,r=/<[A-Za-z0-9\\._:-]+/,i=/\/[A-Za-z0-9\\._:-]+>|\/>/,o=(e,t)=>{let n,r=e[0].length+e.index,i=e.input[r];if("<"===i||","===i)return void t.ignoreMatch();">"!==i||((e,{after:t})=>{let n="</"+e[0].slice(1);return -1!==e.input.indexOf(n,t)})(e,{after:r})||t.ignoreMatch();let o=e.input.substring(r);if((n=o.match(/^\s*=/))||(n=o.match(/^\s+extends\s+/))&&0===n.index)return void t.ignoreMatch()},s={$pattern:Sl,keyword:Sc,literal:Sd,built_in:Sm,"variable.language":Sf},a="[0-9](_?[0-9])*",l=`\\.(${a})`,c="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",d={className:"number",variants:[{begin:`(\\b(${c})((${l})|\\.)?|(${l}))[eE][+-]?(${a})\\b`},{begin:`\\b(${c})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},u={className:"subst",begin:"\\$\\{",end:"\\}",keywords:s,contains:[]},h={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,u],subLanguage:"xml"}},p={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,u],subLanguage:"css"}},f={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,u],subLanguage:"graphql"}},m={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,u]},g={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:Sl+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},u.contains=(b=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,h,p,f,m,{match:/\$\d+/},d]).concat({begin:/\{/,end:/\}/,keywords:s,contains:["self"].concat(b)}),x=(y=[].concat(g,u.contains)).concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:["self"].concat(y)}]),v={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:x},E={variants:[{match:[/class/,/\s+/,Sl,/\s+/,/extends/,/\s+/,n.concat(Sl,"(",n.concat(/\./,Sl),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,Sl],scope:{1:"keyword",3:"title.class"}}]},w={relevance:0,match:n.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Su,...Sh]}},k={match:n.concat(/\b/,(t=[...Sp,"super","import"].map(e=>`${e}\\s*\\(`),n.concat("(?!",t.join("|"),")")),Sl,n.lookahead(/\s*\(/)),className:"title.function",relevance:0},T={begin:n.concat(/\./,n.lookahead(n.concat(Sl,/(?![0-9A-Za-z$_(])/))),end:Sl,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},N="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",A={match:[/const|var|let/,/\s+/,Sl,/\s*/,/=\s*/,/(async\s*)?/,n.lookahead(N)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[v]},{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:s,exports:{PARAMS_CONTAINS:x,CLASS_REFERENCE:w},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),{label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,h,p,f,m,g,{match:/\$\d+/},d,w,{scope:"attr",match:Sl+n.lookahead(":"),relevance:0},A,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[g,e.REGEXP_MODE,{className:"function",begin:N,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:x}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:"<>",end:"</>"},{match:/<[A-Za-z0-9\\._:-]+\s*\/>/},{begin:r,"on:begin":o,end:i}],subLanguage:"xml",contains:[{begin:r,end:i,skip:!0,contains:["self"]}]}]},{variants:[{match:[/function/,/\s+/,Sl,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[v],illegal:/%/},{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[v,e.inherit(e.TITLE_MODE,{begin:Sl,className:"title.function"})]},{match:/\.\.\./,relevance:0},T,{match:"\\$"+Sl,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[v]},k,{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},E,{match:[/get|set/,/\s+/,Sl,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},v]},{match:/\$[(.]/}]}),_=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],M={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},O={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:_},contains:[C.exports.CLASS_REFERENCE]},I={$pattern:Sl,keyword:Sc.concat(["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"]),literal:Sd,built_in:Sm.concat(_),"variable.language":Sf},D={className:"meta",begin:"@"+Sl},R=(e,t,n)=>{let r=e.contains.findIndex(e=>e.label===t);if(-1===r)throw Error("can not find mode to replace");e.contains.splice(r,1,n)};Object.assign(C.keywords,I),C.exports.PARAMS_CONTAINS.push(D);let L=C.contains.find(e=>"attr"===e.scope),P=Object.assign({},L,{match:S.concat(Sl,S.lookahead(/\s*\?:/))});return C.exports.PARAMS_CONTAINS.push([C.exports.CLASS_REFERENCE,L,P]),C.contains=C.contains.concat([D,M,O,P]),R(C,"shebang",e.SHEBANG()),R(C,"use_strict",{className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/}),C.contains.find(e=>"func.def"===e.label).relevance=0,Object.assign(C,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),C}function Sb(e){let t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},i={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=e.inherit(i,{begin:/\(/,end:/\)/}),s=e.inherit(e.APOS_STRING_MODE,{className:"string"}),a=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),l={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:/[\p{L}0-9._:-]+/u,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[r]},{begin:/'/,end:/'/,contains:[r]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[i,a,s,o,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,o,a,s]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},r,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[a]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[l],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[l],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:l}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function Sy(e){let t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,{className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]}]},i=e.inherit(r,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),o={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},s=[{className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},{className:"number",begin:"\\b[0-9]{4}(-[0-9][0-9]){0,2}([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?(\\.[0-9]*)?([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?\\b"},{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},{begin:/\{/,end:/\}/,contains:[o],illegal:"\\n",relevance:0},{begin:"\\[",end:"\\]",contains:[o],illegal:"\\n",relevance:0},{className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},r],a=[...s];return a.pop(),a.push(i),o.contains=a,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:s}}let Sx={};function Sv(e){let t=kL.newInstance();return e&&i(e),{highlight:n,highlightAuto:function(e,i){let o;h3("string"==typeof e,"expected `string` as `value`");let s=(i||Sx).subset||r(),a=-1,l=0;for(;++a<s.length;){let r=s[a];if(!t.getLanguage(r))continue;let c=n(r,e,i);c.data&&void 0!==c.data.relevance&&c.data.relevance>l&&(l=c.data.relevance,o=c)}return o||{type:"root",children:[],data:{language:void 0,relevance:l}}},listLanguages:r,register:i,registerAlias:function(e,n){if("string"==typeof e)h3(void 0!==n),t.registerAliases("string"==typeof n?n:[...n],{languageName:e});else{let n;for(n in e)if(Object.hasOwn(e,n)){let r=e[n];t.registerAliases("string"==typeof r?r:[...r],{languageName:n})}}},registered:function(e){return!!t.getLanguage(e)}};function n(e,n,r){h3("string"==typeof e,"expected `string` as `name`"),h3("string"==typeof n,"expected `string` as `value`");let i=r||Sx,o="string"==typeof i.prefix?i.prefix:"hljs-";if(!t.getLanguage(e))throw Error("Unknown language: `"+e+"` is not registered");t.configure({__emitter:SE,classPrefix:o});let s=t.highlight(n,{ignoreIllegals:!0,language:e});if(s.errorRaised)throw Error("Could not highlight with `Highlight.js`",{cause:s.errorRaised});let a=s._emitter.root,l=a.data;return l.language=s.language,l.relevance=s.relevance,a}function r(){return t.listLanguages()}function i(e,n){if("string"==typeof e)h3(void 0!==n,"expected `grammar`"),t.registerLanguage(e,n);else{let n;for(n in e)Object.hasOwn(e,n)&&t.registerLanguage(n,e[n])}}}class SE{constructor(e){this.options=e,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(e){if(""===e)return;let t=this.stack[this.stack.length-1],n=t.children[t.children.length-1];n&&"text"===n.type?n.value+=e:t.children.push({type:"text",value:e})}startScope(e){this.openNode(String(e))}endScope(){this.closeNode()}__addSublanguage(e,t){let n=this.stack[this.stack.length-1],r=e.root.children;t?n.children.push({type:"element",tagName:"span",properties:{className:[t]},children:r}):n.children.push(...r)}openNode(e){let t=this,n=e.split(".").map(function(e,n){return n?e+"_".repeat(n):t.options.classPrefix+e}),r=this.stack[this.stack.length-1],i={type:"element",tagName:"span",properties:{className:n},children:[]};r.children.push(i),this.stack.push(i)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}let Sw=hn.create({name:"callout",group:"block",content:"block+",defining:!0,addAttributes:()=>({type:{default:"info",parseHTML:e=>e.getAttribute("data-callout-type")||"info",renderHTML:e=>({"data-callout-type":e.type})}}),parseHTML:()=>[{tag:'div[data-callout="true"]'}],renderHTML:({HTMLAttributes:e})=>["div",dq(e,{"data-callout":"true",class:`callout callout-${e["data-callout-type"]||"info"}`}),0]});function Sk(e,t,n){let{selection:r,doc:i}=e,o=i.resolve(r.from);for(;o.depth>1;)o=i.resolve(o.before(o.depth));if(0===o.depth)return!1;let s=o.before(1),a=i.nodeAt(s);if(!a)return!1;let l=o.index(0),c="up"===n?l-1:l+1;if(c<0||c>=i.childCount)return!1;let d=i.child(c),u=e.tr,h=s+a.nodeSize,p="up"===n?s-d.nodeSize:h,f="up"===n?s:h+d.nodeSize;if("up"===n)u=(u=(u=u.delete(s,h)).insert(p,a)).setSelection(op.create(u.doc,p));else{u=u.delete(s,h);let e=f-a.nodeSize;u=(u=u.insert(e,a)).setSelection(op.create(u.doc,e))}return t&&t(u.scrollIntoView()),!0}let ST="cabinet-drag-handle",SN="cabinet-gutter-add",SA=uj.create({name:"dragHandle",addKeyboardShortcuts:()=>({"Mod-Alt-ArrowUp":({editor:e})=>Sk(e.state,e.view.dispatch,"up"),"Mod-Alt-ArrowDown":({editor:e})=>Sk(e.state,e.view.dispatch,"down"),"Alt-Shift-ArrowUp":({editor:e})=>Sk(e.state,e.view.dispatch,"up"),"Alt-Shift-ArrowDown":({editor:e})=>Sk(e.state,e.view.dispatch,"down")}),addProseMirrorPlugins(){let e,t,n=null,r="u">typeof document?((e=document.getElementById(ST))||((e=document.createElement("div")).id=ST,e.setAttribute("data-drag-handle","true"),e.draggable=!0,e.innerHTML='<svg width="10" height="16" viewBox="0 0 10 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><circle cx="2.5" cy="3" r="1.2"/><circle cx="2.5" cy="8" r="1.2"/><circle cx="2.5" cy="13" r="1.2"/><circle cx="7.5" cy="3" r="1.2"/><circle cx="7.5" cy="8" r="1.2"/><circle cx="7.5" cy="13" r="1.2"/></svg>',Object.assign(e.style,{position:"absolute",display:"none",cursor:"grab",padding:"2px 4px",borderRadius:"4px",color:"var(--muted-foreground)",opacity:"0.55",zIndex:"40",userSelect:"none",transition:"opacity 120ms ease"}),e.addEventListener("mouseenter",()=>{e&&(e.style.opacity="1")}),e.addEventListener("mouseleave",()=>{e&&(e.style.opacity="0.55")}),document.body.appendChild(e)),e):null,i="u">typeof document?((t=document.getElementById(SN))||((t=document.createElement("button")).id=SN,t.type="button",t.setAttribute("aria-label","Add block"),t.title="Add block",t.innerHTML='<svg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5 1V9M1 5H9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>',Object.assign(t.style,{position:"absolute",display:"none",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",cursor:"pointer",borderRadius:"4px",color:"var(--muted-foreground)",opacity:"0.55",zIndex:"40",transition:"opacity 120ms ease, background 120ms ease",background:"transparent",border:"none",padding:"0"}),t.addEventListener("mouseenter",()=>{t&&(t.style.opacity="1",t.style.background="var(--muted)")}),t.addEventListener("mouseleave",()=>{t&&(t.style.opacity="0.55",t.style.background="transparent")}),document.body.appendChild(t)),t):null,o=()=>{r&&(r.style.display="none"),i&&(i.style.display="none"),n=null};return[new oN({key:new oC("cabinetDragHandle"),view:e=>{if(!r)return{destroy:()=>{}};let t=t=>{if(!e.editable)return;let s=e.dom.getBoundingClientRect();if(t.clientX<s.left-60||t.clientX>s.right+60||t.clientY<s.top||t.clientY>s.bottom)return void o();let a=function(e,t){let n=e.posAtCoords(t);if(!n)return null;let r=e.state.doc.resolve(n.inside>=0?n.inside:n.pos);for(;r.depth>0&&!r.parent.type.isBlock;)r=e.state.doc.resolve(r.before());let i=r.depth;for(;i>1&&"doc"!==e.state.doc.resolve(r.before(i)).parent.type.name;)i-=1;let o=0===i?0:r.before(Math.max(i,1)),s=e.state.doc.nodeAt(o);if(!s)return null;let a=e.nodeDOM(o);return{pos:o,node:s,dom:a}}(e,{left:Math.max(s.left+20,Math.min(s.right-20,t.clientX)),top:t.clientY});if(!a?.dom||!(a.dom instanceof HTMLElement))return void o();n=a;let l=a.dom.getBoundingClientRect();r.style.display="flex",r.style.top=`${window.scrollY+l.top+4}px`,r.style.left=`${window.scrollX+l.left-22}px`,i&&(i.style.display="flex",i.style.top=`${window.scrollY+l.top+4}px`,i.style.left=`${window.scrollX+l.left-44}px`)},s=()=>o(),a=()=>{if(!n)return;let t=n.pos+n.node.nodeSize,r=t<=e.state.doc.content.size,i=e.state.tr;if(r){let n=ou.create(e.state.doc,Math.min(t-1,e.state.doc.content.size));e.dispatch(i.setSelection(n))}e.focus();let o=e.state.tr.split(e.state.selection.from);e.dispatch(o),e.dom.dispatchEvent(new KeyboardEvent("keydown",{key:"/",bubbles:!0,cancelable:!0}))},l=t=>{if(!n||!t.dataTransfer)return;let{pos:r,dom:i}=n,o=e.state.tr.setSelection(op.create(e.state.doc,r));e.dispatch(o);let s=e.state.selection.content(),a=document.createElement("div");a.appendChild(e.someProp("clipboardSerializer")?.serializeFragment(s.content)??document.createElement("div")),t.dataTransfer.clearData(),t.dataTransfer.setData("text/html",a.innerHTML),t.dataTransfer.setData("text/plain",i.textContent??""),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage(i,0,0),e.dragging={slice:s,move:!0}};return window.addEventListener("mousemove",t),e.dom.addEventListener("mouseleave",s),r.addEventListener("dragstart",l),i&&i.addEventListener("click",a),{destroy(){window.removeEventListener("mousemove",t),e.dom.removeEventListener("mouseleave",s),r.removeEventListener("dragstart",l),i&&i.removeEventListener("click",a),o()}}}})]}}),SS=new oC("headingAnchors");function SC(e){let t=[],n=new Map;return e.descendants((e,r)=>{if("heading"!==e.type.name)return;let i=e.textContent.toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-");if(!i)return;let o=n.get(i)??0;n.set(i,o+1);let s=0===o?i:`${i}-${o}`;t.push(a_.node(r,r+e.nodeSize,{id:s}))}),aI.create(e,t)}let S_=uj.create({name:"headingAnchors",addProseMirrorPlugins:()=>[new oN({key:SS,state:{init:(e,{doc:t})=>SC(t),apply:(e,t)=>e.docChanged?SC(e.doc):t},props:{decorations:e=>SS.getState(e)}})]}),SM=uD.create({name:"proofSpan",priority:900,inclusive:!1,keepOnSplit:!1,addAttributes:()=>({spanId:{default:null,parseHTML:e=>e.getAttribute("id"),renderHTML:e=>({id:e.spanId})},origin:{default:"ai",parseHTML:e=>e.getAttribute("origin"),renderHTML:e=>({origin:e.origin})},basis:{default:null,parseHTML:e=>e.getAttribute("basis"),renderHTML:e=>({basis:e.basis})},basisDetail:{default:null,parseHTML:e=>e.getAttribute("basis-detail"),renderHTML:e=>({"basis-detail":e.basisDetail})},by:{default:null,parseHTML:e=>e.getAttribute("by"),renderHTML:e=>({by:e.by})},at:{default:null,parseHTML:e=>e.getAttribute("at"),renderHTML:e=>({at:e.at})},inResponseTo:{default:null,parseHTML:e=>e.getAttribute("in-response-to"),renderHTML:e=>({"in-response-to":e.inResponseTo})}}),parseHTML:()=>[{tag:"proof-span"}],renderHTML:({HTMLAttributes:e})=>["proof-span",dq(e,{class:"proof-span"}),0]});var SO=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;function SI(e){let{node:t,updateAttributes:n,selected:r,editor:i}=e,o=t.attrs,s=(0,Q.useRef)(null),a=(0,Q.useRef)(null),[l,c]=(0,Q.useState)(null),d=o.align??"center",u=(0,Q.useCallback)((e,t)=>{if(!i.isEditable)return;e.preventDefault(),e.stopPropagation();let r=s.current,o=a.current;if(!r||!o)return;let l=e.clientX,d=r.getBoundingClientRect().width,u=o.parentElement?.getBoundingClientRect().width??800,h=e=>{c(Math.max(80,Math.min(u,d+("right"===t?e.clientX-l:l-e.clientX))))},p=()=>{window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",p),c(e=>(null!=e&&n({width:Math.round(e)}),null))};window.addEventListener("pointermove",h),window.addEventListener("pointerup",p)},[i.isEditable,n]),h=null!=l?`${Math.round(l)}px`:"number"==typeof o.width?`${o.width}px`:"string"==typeof o.width&&o.width?o.width:void 0,p="left"===d?"mr-auto":"right"===d?"ml-auto":"mx-auto";return(0,X.jsx)(hW,{as:"div",className:`resizable-image my-3 ${p}`,"data-align":d,style:{width:h??"fit-content",maxWidth:"100%"},children:(0,X.jsxs)("div",{ref:a,className:`relative group inline-block max-w-full ${r?"ring-2 ring-primary rounded-md":""}`,contentEditable:!1,children:[(0,X.jsx)("img",{ref:s,src:o.src,alt:o.alt??"",title:o.title??void 0,className:"block rounded-md max-w-full h-auto",style:{width:h},draggable:!1}),i.isEditable&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("div",{"aria-label":"Resize from left",onPointerDown:e=>u(e,"left"),className:"absolute left-0 top-0 bottom-0 w-2 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:(0,X.jsx)("div",{className:"w-1 h-8 bg-card border border-border rounded-full shadow"})}),(0,X.jsx)("div",{"aria-label":"Resize from right",onPointerDown:e=>u(e,"right"),className:"absolute right-0 top-0 bottom-0 w-2 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:(0,X.jsx)("div",{className:"w-1 h-8 bg-card border border-border rounded-full shadow"})}),null!=l&&(0,X.jsxs)("div",{className:"absolute top-1 right-1 text-[10px] px-1.5 py-0.5 rounded bg-primary/80 text-primary-foreground font-mono",children:[Math.round(l),"px"]})]})]})})}let SD=hn.create({name:"image",addOptions:()=>({inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}),inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes:()=>({src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}),parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:e}){return["img",dq(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode("image",{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{var t,n,r,i,o,s;let a=null!=(n=null==(t=e.attrs)?void 0:t.src)?n:"",l=null!=(i=null==(r=e.attrs)?void 0:r.alt)?i:"",c=null!=(s=null==(o=e.attrs)?void 0:o.title)?s:"";return c?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||"u"<typeof document)return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:o,HTMLAttributes:s,editor:a})=>{let l=document.createElement("img");Object.entries(s).forEach(([e,t])=>{if(null!=t)switch(e){case"width":case"height":break;default:l.setAttribute(e,t)}}),l.src=s.src;let c=new u2({element:l,editor:a,node:i,getPos:o,onResize:(e,t)=>{l.style.width=`${e}px`,l.style.height=`${t}px`},onCommit:(e,t)=>{let n=o();void 0!==n&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:e,height:t}).run()},onUpdate:(e,t,n)=>e.type===i.type,options:{directions:e,min:{width:t,height:n},preserveAspectRatio:!0===r}}),d=c.dom;return d.style.visibility="hidden",d.style.pointerEvents="none",l.onload=()=>{d.style.visibility="",d.style.pointerEvents=""},c}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[uZ({find:SO,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}).extend({name:"image",draggable:!0,addAttributes(){return{...this.parent?.(),width:{default:null,parseHTML:e=>{let t=e.getAttribute("width")??e.style.width;if(!t)return null;let n=/^(\d+)(px)?$/.exec(t);return n?Number(n[1]):t},renderHTML:e=>{if(!e.width)return{};let t="number"==typeof e.width?`${e.width}px`:e.width;return{style:`width: ${t}`}}},align:{default:null,parseHTML:e=>e.getAttribute("data-align"),renderHTML:e=>e.align?{"data-align":e.align}:{}}}},addNodeView:()=>e=>e.editor.contentComponent?new hQ(SI,e,void 0):{}}),SR=new oC("wikiLinkDecorator"),SL="wikiLinkDecorator:refresh";function SP(e){let{has:t}=Ex.getState(),n=e.schema.marks.wikiLink;if(!n)return aI.empty;let r=[];return e.doc.descendants((e,i)=>{if(!e.isText)return;let o=e.marks.find(e=>e.type===n);if(!o)return;let s=o.attrs.slug;!s||t(s)||r.push(a_.inline(i,i+e.nodeSize,{"data-broken":"true"}))}),aI.create(e.doc,r)}let Sj=/\[\[([a-z0-9-]+)(?:\|([^\]#|]+)|#([a-z0-9-]+))?\]\]$/,SB=uD.create({name:"wikiLink",priority:1e3,keepOnSplit:!1,inclusive:!1,addAttributes:()=>({slug:{default:null,parseHTML:e=>e.getAttribute("data-slug"),renderHTML:e=>({"data-slug":e.slug})},alias:{default:null,parseHTML:e=>e.getAttribute("data-alias"),renderHTML:e=>null!=e.alias?{"data-alias":e.alias}:{}},anchor:{default:null,parseHTML:e=>e.getAttribute("data-anchor"),renderHTML:e=>null!=e.anchor?{"data-anchor":e.anchor}:{}}}),parseHTML:()=>[{tag:'a[data-wiki-link="true"]'}],renderHTML({HTMLAttributes:e}){let t=String(e["data-slug"]??""),n=null!=e["data-anchor"]?String(e["data-anchor"]):null;return["a",dq(e,{"data-wiki-link":"true",href:n?`#wiki:${t}#${n}`:`#wiki:${t}`,class:"wiki-link"}),0]},addInputRules(){return[new u_({find:Sj,handler:({state:e,range:t,match:n})=>{let r=n[1]??"",i=n[2]??null,o=n[3]??null,s=i??(o?`${r}#${o}`:r),{tr:a}=e;a.replaceWith(t.from,t.to,e.schema.text(s,[this.type.create({slug:r,alias:i,anchor:o})]))}})]},addProseMirrorPlugins:()=>[new oN({key:SR,state:{init:(e,t)=>SP(t),apply:(e,t,n,r)=>e.getMeta(SL)||e.docChanged?SP(r):t.map(e.mapping,e.doc)},props:{decorations:e=>SR.getState(e)??aI.empty},view(e){let t=Ex.subscribe(()=>{let t=e.state.tr.setMeta(SL,!0);e.dispatch(t)});return{destroy(){t()}}}})],addCommands(){return{setWikiLink:e=>({commands:t})=>t.setMark(this.name,{slug:e.slug,alias:e.alias??null,anchor:e.anchor??null}),unsetWikiLink:()=>({commands:e})=>e.unsetMark(this.name)}}}),SF=Sv({bash:AY,css:A1,go:A2,javascript:St,json:Sn,markdown:Sr,python:Si,rust:So,shell:Ss,sql:Sa,typescript:Sg,xml:Sb,yaml:Sy}),SH=[AK.configure({heading:{levels:[1,2,3,4]},codeBlock:!1,link:!1,underline:!1}),kB.configure({lowlight:SF,HTMLAttributes:{class:"rounded-md bg-muted p-4 font-mono text-sm"}}),NF.configure({placeholder:"Start writing, or press '/' for commands..."}),SD.configure({HTMLAttributes:{class:"rounded-lg max-w-full"},allowBase64:!1}),N2.configure({resizable:!0,lastColumnResizable:!1,HTMLAttributes:{class:"border-collapse w-full"}}),NY,NW,NK,Ax.configure({HTMLAttributes:{class:"task-list"}}),Ay.configure({nested:!0}),No.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}}).extend({parseHTML:()=>[{tag:'a[href]:not([data-wiki-link="true"])'}],addKeyboardShortcuts(){return{"Mod-e":()=>{let{state:e}=this.editor,{from:t,to:n}=e.selection;if(t===n)return!1;let r=this.editor.getAttributes("link").href??"",i=window.prompt("Link URL",r);return null!==i&&(""===i?this.editor.chain().focus().extendMarkRange("link").unsetLink().run():this.editor.chain().focus().extendMarkRange("link").setLink({href:i}).run())}}}}),Sw,SM,Av.configure({types:["heading","paragraph"]}),N$,NG,SA,S_,SB],SU=en("app-window",[["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}],["path",{d:"M10 4v4",key:"pp8u80"}],["path",{d:"M2 8h20",key:"d11cs7"}],["path",{d:"M6 4v4",key:"1svtjw"}]]),Sz=en("file-audio",[["path",{d:"M17.5 22h.5a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"rslqgf"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 19a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 1 1-4 0v-1a2 2 0 1 1 4 0",key:"9f7x3i"}]]),S$=en("file-code-2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]),SG=en("file-image",[["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"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]),Sq=en("file-spreadsheet",[["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:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]),SV=en("file-video",[["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:"m10 11 5 3-5 3v-6Z",key:"7ntvm4"}]]),SW=en("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),SK="kb-folder-view-mode";function SY(e){return"image"===e.type}function SX(e){switch(e.type){case"directory":case"cabinet":return eu;case"image":return SG;case"video":return SV;case"audio":return Sz;case"code":return S$;case"csv":case"xlsx":return Sq;case"website":return ef;case"app":return SU;default:return ed}}function SQ(e){let{selectPage:t,expandPath:n}=Eh.getState(),r=e.split("/");for(let e=1;e<r.length;e++)n(r.slice(0,e).join("/"));t(e),Eu.getState().loadPage(e)}function SJ({folderPath:e,entries:t}){let n=(0,Q.useMemo)(()=>(function(e){if(0===e.length)return!1;let t=e.filter(SY).length;return t>=4&&t/e.length>=.6})(t),[t]),[r,i]=(0,Q.useState)(()=>{let t=function(e){try{let t=localStorage.getItem(SK);if(!t)return null;return JSON.parse(t)[e]??null}catch{return null}}(e);return t||(n?"gallery":"list")}),o=t=>{i(t);try{let n=localStorage.getItem(SK),r=n?JSON.parse(n):{};r[e]=t,localStorage.setItem(SK,JSON.stringify(r))}catch{}},s=(0,Q.useMemo)(()=>{let e=[...t];return e.sort((e,t)=>{let n="directory"===e.type||"cabinet"===e.type;return n!==("directory"===t.type||"cabinet"===t.type)?n?-1:1:e.name.localeCompare(t.name)}),e},[t]);return(0,X.jsxs)("div",{className:"space-y-3",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between",children:[(0,X.jsxs)("p",{className:"text-[11px] uppercase tracking-wider text-muted-foreground/70",children:[s.length," ",1===s.length?"item":"items"]}),(0,X.jsxs)("div",{className:"inline-flex items-center rounded-md border border-border p-0.5 text-[11px]",children:[(0,X.jsxs)("button",{onClick:()=>o("list"),className:`flex items-center gap-1 px-2 py-1 rounded transition-colors ${"list"===r?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"}`,"aria-pressed":"list"===r,title:"List view",children:[(0,X.jsx)(kh,{className:"h-3 w-3"}),"List"]}),(0,X.jsxs)("button",{onClick:()=>o("gallery"),className:`flex items-center gap-1 px-2 py-1 rounded transition-colors ${"gallery"===r?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"}`,"aria-pressed":"gallery"===r,title:"Gallery view",children:[(0,X.jsx)(SW,{className:"h-3 w-3"}),"Gallery"]})]})]}),"list"===r?(0,X.jsx)("ul",{className:"divide-y divide-border rounded-md border border-border overflow-hidden",children:s.map(e=>{let t=SX(e),n=e.frontmatter?.title||e.name;return(0,X.jsx)("li",{children:(0,X.jsxs)("button",{onClick:()=>SQ(e.path),className:"w-full flex items-center gap-3 px-3 py-2 text-left text-sm hover:bg-accent/50 transition-colors",children:[(0,X.jsx)(t,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,X.jsx)("span",{className:"flex-1 truncate",children:n}),(0,X.jsx)("span",{className:"text-[11px] text-muted-foreground/60 capitalize",children:e.type})]})},e.path)})}):(0,X.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-3",children:s.map(e=>{let t=e.frontmatter?.title||e.name;if(SY(e))return(0,X.jsxs)("button",{onClick:()=>SQ(e.path),className:"group flex flex-col gap-1.5 text-left",title:t,children:[(0,X.jsx)("div",{className:"aspect-square w-full overflow-hidden rounded-md border border-border bg-muted",children:(0,X.jsx)("img",{src:`/api/assets/${e.path}`,alt:t,loading:"lazy",className:"h-full w-full object-cover transition-transform group-hover:scale-[1.02]"})}),(0,X.jsx)("span",{className:"truncate text-[12px] text-muted-foreground group-hover:text-foreground",children:t})]},e.path);let n=SX(e);return(0,X.jsxs)("button",{onClick:()=>SQ(e.path),className:"group flex flex-col gap-1.5 text-left",title:t,children:[(0,X.jsx)("div",{className:"aspect-square w-full flex items-center justify-center rounded-md border border-border bg-muted/40 group-hover:bg-muted transition-colors",children:(0,X.jsx)(n,{className:"h-8 w-8 text-muted-foreground/60"})}),(0,X.jsx)("span",{className:"truncate text-[12px] text-muted-foreground group-hover:text-foreground",children:t})]},e.path)})})]})}let SZ=en("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);function S0({blockRef:e,comments:t,top:n,left:r,onClick:i}){let o;if(0===t.length)return null;let s=t.filter(e=>!e.resolved);if(0===s.length)o="check";else{let e=s[0].turns.at(-1);o=e?.by.startsWith("ai:")?"dot-ai":"ring-human"}return(0,X.jsxs)("button",{type:"button",onClick:i,style:{position:"absolute",top:n,left:r,transform:"translateY(2px)"},className:"z-10 p-2 sm:p-0.5 -m-1.5 sm:m-0 rounded transition-colors hover:bg-accent focus:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-label":`Comment thread for block ${e}`,children:["check"===o&&(0,X.jsx)(SZ,{className:"h-3.5 w-3.5 text-muted-foreground/30"}),"dot-ai"===o&&(0,X.jsx)(w9,{className:"h-3.5 w-3.5 fill-primary text-primary"}),"ring-human"===o&&(0,X.jsx)(w9,{className:"h-3.5 w-3.5 text-muted-foreground/70"})]})}var S1="u">typeof document?Q.useLayoutEffect:function(){};function S2(e,t){let n,r,i;if(e===t)return!0;if(typeof e!=typeof t)return!1;if("function"==typeof e&&e.toString()===t.toString())return!0;if(e&&t&&"object"==typeof e){if(Array.isArray(e)){if((n=e.length)!==t.length)return!1;for(r=n;0!=r--;)if(!S2(e[r],t[r]))return!1;return!0}if((n=(i=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(r=n;0!=r--;)if(!({}).hasOwnProperty.call(t,i[r]))return!1;for(r=n;0!=r--;){let n=i[r];if(("_owner"!==n||!e.$$typeof)&&!S2(e[n],t[n]))return!1}return!0}return e!=e&&t!=t}function S3(e){return"u"<typeof window?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function S5(e,t){let n=S3(e);return Math.round(t*n)/n}function S4(e){let t=Q.useRef(e);return S1(()=>{t.current=e}),t}var S6=Q.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...o}=e;return(0,X.jsx)(t3.svg,{...o,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:(0,X.jsx)("polygon",{points:"0,0 30,0 15,10"})})});S6.displayName="Arrow";var S9="Popper",[S7,S8]=tV(S9),[Ce,Ct]=S7(S9),Cn=e=>{let{__scopePopper:t,children:n}=e,[r,i]=Q.useState(null);return(0,X.jsx)(Ce,{scope:t,anchor:r,onAnchorChange:i,children:n})};Cn.displayName=S9;var Cr="PopperAnchor",Ci=Q.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,o=Ct(Cr,n),s=Q.useRef(null),a=eM(t,s),l=Q.useRef(null);return Q.useEffect(()=>{let e=l.current;l.current=r?.current||s.current,e!==l.current&&o.onAnchorChange(l.current)}),r?null:(0,X.jsx)(t3.div,{...i,ref:a})});Ci.displayName=Cr;var Co="PopperContent",[Cs,Ca]=S7(Co),Cl=Q.forwardRef((e,t)=>{var n,r,i,o,s,a,l,c,d,u,h,p,f,m,g,b;let y,x,v,E,w,k,{__scopePopper:T,side:N="bottom",sideOffset:A=0,align:S="center",alignOffset:C=0,arrowPadding:_=0,avoidCollisions:M=!0,collisionBoundary:O=[],collisionPadding:I=0,sticky:D="partial",hideWhenDetached:R=!1,updatePositionStrategy:L="optimized",onPlaced:P,...j}=e,B=Ct(Co,T),[F,H]=Q.useState(null),U=eM(t,e=>H(e)),[z,$]=Q.useState(null),G=function(e){let[t,n]=Q.useState(void 0);return tW(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{let r,i;if(!Array.isArray(t)||!t.length)return;let o=t[0];if("borderBoxSize"in o){let e=o.borderBoxSize,t=Array.isArray(e)?e[0]:e;r=t.inlineSize,i=t.blockSize}else r=e.offsetWidth,i=e.offsetHeight;n({width:r,height:i})});return t.observe(e,{box:"border-box"}),()=>t.unobserve(e)}n(void 0)},[e]),t}(z),q=G?.width??0,V=G?.height??0,W="number"==typeof I?I:{top:0,right:0,bottom:0,left:0,...I},K=Array.isArray(O)?O:[O],Y=K.length>0,J={padding:W,boundary:K.filter(Ch),altBoundary:Y},{refs:Z,floatingStyles:ee,placement:et,isPositioned:en,middlewareData:er}=function(e){void 0===e&&(e={});let{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:o,floating:s}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,u]=Q.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=Q.useState(r);S2(h,r)||p(r);let[f,m]=Q.useState(null),[g,b]=Q.useState(null),y=Q.useCallback(e=>{e!==w.current&&(w.current=e,m(e))},[]),x=Q.useCallback(e=>{e!==k.current&&(k.current=e,b(e))},[]),v=o||f,E=s||g,w=Q.useRef(null),k=Q.useRef(null),T=Q.useRef(d),N=null!=l,A=S4(l),S=S4(i),C=S4(c),_=Q.useCallback(()=>{if(!w.current||!k.current)return;let e={placement:t,strategy:n,middleware:h};S.current&&(e.platform=S.current),wL(w.current,k.current,e).then(e=>{let t={...e,isPositioned:!1!==C.current};M.current&&!S2(T.current,t)&&(T.current=t,tZ.flushSync(()=>{u(t)}))})},[h,t,n,S,C]);S1(()=>{!1===c&&T.current.isPositioned&&(T.current.isPositioned=!1,u(e=>({...e,isPositioned:!1})))},[c]);let M=Q.useRef(!1);S1(()=>(M.current=!0,()=>{M.current=!1}),[]),S1(()=>{if(v&&(w.current=v),E&&(k.current=E),v&&E){if(A.current)return A.current(v,E,_);_()}},[v,E,_,A,N]);let O=Q.useMemo(()=>({reference:w,floating:k,setReference:y,setFloating:x}),[y,x]),I=Q.useMemo(()=>({reference:v,floating:E}),[v,E]),D=Q.useMemo(()=>{let e={position:n,left:0,top:0};if(!I.floating)return e;let t=S5(I.floating,d.x),r=S5(I.floating,d.y);return a?{...e,transform:"translate("+t+"px, "+r+"px)",...S3(I.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:t,top:r}},[n,a,I.floating,d.x,d.y]);return Q.useMemo(()=>({...d,update:_,refs:O,elements:I,floatingStyles:D}),[d,_,O,I,D])}({strategy:"fixed",placement:N+("center"!==S?"-"+S:""),whileElementsMounted:(...e)=>(function(e,t,n,r){let i;void 0===r&&(r={});let{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:l="function"==typeof IntersectionObserver,animationFrame:c=!1}=r,d=wp(e),u=o||s?[...d?wd(d):[],...t?wd(t):[]]:[];u.forEach(e=>{o&&e.addEventListener("scroll",n,{passive:!0}),s&&e.addEventListener("resize",n)});let h=d&&l?function(e,t){let n,r=null,i=E5(e);function o(){var e;clearTimeout(n),null==(e=r)||e.disconnect(),r=null}return!function s(a,l){void 0===a&&(a=!1),void 0===l&&(l=1),o();let c=e.getBoundingClientRect(),{left:d,top:u,width:h,height:p}=c;if(a||t(),!h||!p)return;let f={rootMargin:-E_(u)+"px "+-E_(i.clientWidth-(d+h))+"px "+-E_(i.clientHeight-(u+p))+"px "+-E_(d)+"px",threshold:ES(0,EA(1,l))||1},m=!0;function g(t){let r=t[0].intersectionRatio;if(r!==l){if(!m)return s();r?s(!1,r):n=setTimeout(()=>{s(!1,1e-7)},1e3)}1!==r||wA(c,e.getBoundingClientRect())||s(),m=!1}try{r=new IntersectionObserver(g,{...f,root:i.ownerDocument})}catch(e){r=new IntersectionObserver(g,f)}r.observe(e)}(!0),o}(d,n):null,p=-1,f=null;a&&(f=new ResizeObserver(e=>{let[r]=e;r&&r.target===d&&f&&t&&(f.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var e;null==(e=f)||e.observe(t)})),n()}),d&&!c&&f.observe(d),t&&f.observe(t));let m=c?wb(e):null;return c&&function t(){let r=wb(e);m&&!wA(m,r)&&n(),m=r,i=requestAnimationFrame(t)}(),n(),()=>{var e;u.forEach(e=>{o&&e.removeEventListener("scroll",n),s&&e.removeEventListener("resize",n)}),null==h||h(),null==(e=f)||e.disconnect(),f=null,c&&cancelAnimationFrame(i)}})(...e,{animationFrame:"always"===L}),elements:{reference:B.anchor},middleware:[{name:(y=wS(n={mainAxis:A+V,alignmentAxis:C})).name,fn:y.fn,options:[n,r]},M&&{name:(x=w_(a={mainAxis:!0,crossAxis:!1,limiter:"partial"===D?{fn:(void 0===(s=i)&&(s={}),{options:s,fn(e){let{x:t,y:n,placement:r,rects:i,middlewareData:o}=e,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=EI(s,e),d={x:t,y:n},u=Ej(r),h=EL(u),p=d[h],f=d[u],m=EI(a,e),g="number"==typeof m?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){let e="y"===h?"height":"width",t=i.reference[h]-i.floating[e]+g.mainAxis,n=i.reference[h]+i.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(c){var b,y;let e="y"===h?"width":"height",t=EZ.has(ED(r)),n=i.reference[u]-i.floating[e]+(t&&(null==(b=o.offset)?void 0:b[u])||0)+(t?0:g.crossAxis),s=i.reference[u]+i.reference[e]+(t?0:(null==(y=o.offset)?void 0:y[u])||0)-(t?g.crossAxis:0);f<n?f=n:f>s&&(f=s)}return{[h]:p,[u]:f}}}).fn,options:[i,o]}:void 0,...J})).name,fn:x.fn,options:[a,l]},M&&{name:(v=wM(c={...J})).name,fn:v.fn,options:[c,d]},{name:(E=wO(u={...J,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:o}=t.reference,s=e.floating.style;s.setProperty("--radix-popper-available-width",`${n}px`),s.setProperty("--radix-popper-available-height",`${r}px`),s.setProperty("--radix-popper-anchor-width",`${i}px`),s.setProperty("--radix-popper-anchor-height",`${o}px`)}})).name,fn:E.fn,options:[u,h]},z&&{name:(w={name:"arrow",options:m=p={element:z,padding:_},fn(e){let{element:t,padding:n}="function"==typeof m?m(e):m;return t&&({}).hasOwnProperty.call(t,"current")?null!=t.current?wD({element:t.current,padding:n}).fn(e):{}:t?wD({element:t,padding:n}).fn(e):{}}}).name,fn:w.fn,options:[p,f]},Cp({arrowWidth:q,arrowHeight:V}),R&&{name:(k=wI(g={strategy:"referenceHidden",...J})).name,fn:k.fn,options:[g,b]}]}),[ei,eo]=Cf(et),es=t4(P);tW(()=>{en&&es?.()},[en,es]);let ea=er.arrow?.x,el=er.arrow?.y,ec=er.arrow?.centerOffset!==0,[ed,eu]=Q.useState();return tW(()=>{F&&eu(window.getComputedStyle(F).zIndex)},[F]),(0,X.jsx)("div",{ref:Z.setFloating,"data-radix-popper-content-wrapper":"",style:{...ee,transform:en?ee.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ed,"--radix-popper-transform-origin":[er.transformOrigin?.x,er.transformOrigin?.y].join(" "),...er.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:(0,X.jsx)(Cs,{scope:T,placedSide:ei,onArrowChange:$,arrowX:ea,arrowY:el,shouldHideArrow:ec,children:(0,X.jsx)(t3.div,{"data-side":ei,"data-align":eo,...j,ref:U,style:{...j.style,animation:en?void 0:"none"}})})})});Cl.displayName=Co;var Cc="PopperArrow",Cd={top:"bottom",right:"left",bottom:"top",left:"right"},Cu=Q.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Ca(Cc,n),o=Cd[i.placedSide];return(0,X.jsx)("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:(0,X.jsx)(S6,{...r,ref:t,style:{...r.style,display:"block"}})})});function Ch(e){return null!==e}Cu.displayName=Cc;var Cp=e=>({name:"transformOrigin",options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,o=i.arrow?.centerOffset!==0,s=o?0:e.arrowWidth,a=o?0:e.arrowHeight,[l,c]=Cf(n),d={start:"0%",center:"50%",end:"100%"}[c],u=(i.arrow?.x??0)+s/2,h=(i.arrow?.y??0)+a/2,p="",f="";return"bottom"===l?(p=o?d:`${u}px`,f=`${-a}px`):"top"===l?(p=o?d:`${u}px`,f=`${r.floating.height+a}px`):"right"===l?(p=`${-a}px`,f=o?d:`${h}px`):"left"===l&&(p=`${r.floating.width+a}px`,f=o?d:`${h}px`),{data:{x:p,y:f}}}});function Cf(e){let[t,n="center"]=e.split("-");return[t,n]}var Cm="Popover",[Cg,Cb]=tV(Cm,[S8]),Cy=S8(),[Cx,Cv]=Cg(Cm),CE=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:s=!1}=e,a=Cy(t),l=Q.useRef(null),[c,d]=Q.useState(!1),[u,h]=tJ({prop:r,defaultProp:i??!1,onChange:o,caller:Cm});return(0,X.jsx)(Cn,{...a,children:(0,X.jsx)(Cx,{scope:t,contentId:tX(),triggerRef:l,open:u,onOpenChange:h,onOpenToggle:Q.useCallback(()=>h(e=>!e),[h]),hasCustomAnchor:c,onCustomAnchorAdd:Q.useCallback(()=>d(!0),[]),onCustomAnchorRemove:Q.useCallback(()=>d(!1),[]),modal:s,children:n})})};CE.displayName=Cm;var Cw="PopoverAnchor",Ck=Q.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Cv(Cw,n),o=Cy(n),{onCustomAnchorAdd:s,onCustomAnchorRemove:a}=i;return Q.useEffect(()=>(s(),()=>a()),[s,a]),(0,X.jsx)(Ci,{...o,...r,ref:t})});Ck.displayName=Cw;var CT="PopoverTrigger";Q.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Cv(CT,n),o=Cy(n),s=eM(t,i.triggerRef),a=(0,X.jsx)(t3.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Cj(i.open),...r,ref:s,onClick:tq(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?a:(0,X.jsx)(Ci,{asChild:!0,...o,children:a})}).displayName=CT;var CN="PopoverPortal",[CA,CS]=Cg(CN,{forceMount:void 0}),CC=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,o=Cv(CN,t);return(0,X.jsx)(CA,{scope:t,forceMount:n,children:(0,X.jsx)(nu,{present:n||o.open,children:(0,X.jsx)(nd,{asChild:!0,container:i,children:r})})})};CC.displayName=CN;var C_="PopoverContent",CM=Q.forwardRef((e,t)=>{let n=CS(C_,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,o=Cv(C_,e.__scopePopover);return(0,X.jsx)(nu,{present:r||o.open,children:o.modal?(0,X.jsx)(CI,{...i,ref:t}):(0,X.jsx)(CD,{...i,ref:t})})});CM.displayName=C_;var CO=t0("PopoverContent.RemoveScroll"),CI=Q.forwardRef((e,t)=>{let n=Cv(C_,e.__scopePopover),r=Q.useRef(null),i=eM(t,r),o=Q.useRef(!1);return Q.useEffect(()=>{let e=r.current;if(e)return n6(e)},[]),(0,X.jsx)(nZ,{as:CO,allowPinchZoom:!0,children:(0,X.jsx)(CR,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:tq(e.onCloseAutoFocus,e=>{e.preventDefault(),o.current||n.triggerRef.current?.focus()}),onPointerDownOutside:tq(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;o.current=2===t.button||n},{checkForDefaultPrevented:!1}),onFocusOutside:tq(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),CD=Q.forwardRef((e,t)=>{let n=Cv(C_,e.__scopePopover),r=Q.useRef(!1),i=Q.useRef(!1);return(0,X.jsx)(CR,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,"pointerdown"===t.detail.originalEvent.type&&(i.current=!0));let o=t.target;n.triggerRef.current?.contains(o)&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&i.current&&t.preventDefault()}})}),CR=Q.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:d,...u}=e,h=Cv(C_,n),p=Cy(n);return nf(),(0,X.jsx)(ni,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:(0,X.jsx)(t7,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:d,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1),children:(0,X.jsx)(Cl,{"data-state":Cj(h.open),role:"dialog",id:h.contentId,...p,...u,ref:t,style:{...u.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),CL="PopoverClose";Q.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Cv(CL,n);return(0,X.jsx)(t3.button,{type:"button",...r,ref:t,onClick:tq(e.onClick,()=>i.onOpenChange(!1))})}).displayName=CL;var CP=Q.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Cy(n);return(0,X.jsx)(Cu,{...i,...r,ref:t})});function Cj(e){return e?"open":"closed"}CP.displayName="PopoverArrow";let CB=new Intl.RelativeTimeFormat("en",{numeric:"auto"});async function CF(e,t,n,r){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(),...{}},body:JSON.stringify({baseRevision:t,by:n,ops:r})});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 o.ok?{ok:!0,stale:!1}:{ok:!1,stale:!1}}function CH({path:e,blockRef:t,comments:n,anchorEl:r,onClose:i}){let[o,s]=(0,Q.useState)(null),[a,l]=(0,Q.useState)(""),[c,d]=(0,Q.useState)(!1),u=(0,Q.useRef)(null),h=n.filter(e=>!e.resolved),p=h.length>0,f=h[0]??n[0]??null;if((0,Q.useEffect)(()=>{if(!r)return void s(null);let e=r.getBoundingClientRect();s({top:e.bottom+4,left:e.left})},[r]),(0,Q.useEffect)(()=>{if(!r)return;let e=e=>{"Escape"===e.key&&i()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r,i]),(0,Q.useEffect)(()=>{o&&setTimeout(()=>u.current?.focus(),50)},[o]),!r||!o)return null;function m(){let t=EE.getState().byPath[e];return t?.snapshotRevision??0}async function g(){if(a.trim()&&!c){d(!0);try{let n=f?{type:"comment.reply",commentId:f.id,text:a.trim()}:{type:"comment.add",ref:t,text:a.trim()},r=m(),o=await CF(e,r,"human",[n]);!o.ok&&o.stale&&void 0!==o.newRevision&&(await EE.getState().loadSidecar(e),r=o.newRevision,o=await CF(e,r,"human",[n])),o.ok&&(await EE.getState().loadSidecar(e),l(""),i())}finally{d(!1)}}}async function b(){if(f&&!c){d(!0);try{let t=f.resolved?"comment.reopen":"comment.resolve",n=m(),r=await CF(e,n,"human",[{type:t,commentId:f.id}]);!r.ok&&r.stale&&void 0!==r.newRevision&&(await EE.getState().loadSidecar(e),n=r.newRevision,r=await CF(e,n,"human",[{type:t,commentId:f.id}])),r.ok&&(await EE.getState().loadSidecar(e),i())}finally{d(!1)}}}let y=n.flatMap(e=>e.turns.map(t=>({...t,resolved:e.resolved,commentId:e.id})));return(0,X.jsxs)(CE,{open:!0,children:[(0,X.jsx)(Ck,{asChild:!0,children:(0,X.jsx)("span",{"aria-hidden":"true",style:{position:"fixed",top:o.top,left:o.left,width:0,height:0,pointerEvents:"none"}})}),(0,X.jsx)(CC,{children:(0,X.jsxs)(CM,{side:"bottom",align:"start",sideOffset:4,collisionPadding:8,onInteractOutside:i,className:"z-50 w-[min(18rem,calc(100vw-1rem))] bg-popover border border-border rounded-lg shadow-xl p-3 space-y-2 text-[12px] focus:outline-none",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between",children:[(0,X.jsx)("span",{className:"text-[11px] font-mono text-muted-foreground/60 truncate",children:t}),f&&(0,X.jsx)("button",{type:"button",disabled:c,onClick:()=>void b(),className:"ml-2 shrink-0 text-[10px] px-1.5 py-0.5 rounded border border-border hover:bg-accent disabled:opacity-50 transition-colors",children:f.resolved?"Reopen":"Resolve"})]}),y.length>0&&(0,X.jsx)("div",{className:"space-y-2 max-h-48 overflow-y-auto pr-1",children:y.map((e,t)=>(0,X.jsxs)("div",{className:"space-y-0.5",children:[(0,X.jsxs)("p",{className:"text-[10px] text-muted-foreground/60",children:[e.by," · ",function(e){let t=Math.round((Date.now()-new Date(e).getTime())/1e3);if(60>Math.abs(t))return CB.format(-t,"second");let n=Math.round(t/60);if(60>Math.abs(n))return CB.format(-n,"minute");let r=Math.round(n/60);return 24>Math.abs(r)?CB.format(-r,"hour"):CB.format(-Math.round(r/24),"day")}(e.at)]}),(0,X.jsx)("p",{className:"text-foreground leading-snug whitespace-pre-wrap",children:e.text})]},t))}),(!f?.resolved||0===n.length)&&(0,X.jsxs)("div",{className:"space-y-1.5 pt-1",children:[(0,X.jsx)("textarea",{ref:u,value:a,onChange:e=>l(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&g()},placeholder:p?"Reply…":"Add a comment…",rows:2,className:"w-full resize-none rounded-md border border-border bg-background px-2 py-1.5 text-[12px] focus:outline-none focus-visible:ring-1 focus-visible:ring-ring placeholder:text-muted-foreground/40"}),(0,X.jsxs)("div",{className:"flex items-center justify-between",children:[(0,X.jsx)("span",{className:"text-[10px] text-muted-foreground/40",children:"⌘↵ send"}),(0,X.jsx)("button",{type:"button",disabled:c||!a.trim(),onClick:()=>void g(),className:"px-2.5 py-1 rounded-md bg-primary text-primary-foreground text-[11px] font-medium hover:bg-primary/90 disabled:opacity-50 transition-colors",children:"Send"})]})]}),(0,X.jsx)(CP,{className:"fill-border"})]})})]})}function CU({targetEl:e,path:t,onClose:n,onComment:r}){let[i,o]=(0,Q.useState)(null),[s,a]=(0,Q.useState)(null),[l,c]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{if(!e){o(null),a(null);return}let t=e.getBoundingClientRect();o({top:t.bottom+window.scrollY+4,left:t.left+window.scrollX}),a({spanId:e.getAttribute("id")??"",origin:e.getAttribute("origin"),basis:e.getAttribute("basis"),basisDetail:e.getAttribute("basis-detail"),by:e.getAttribute("by"),at:e.getAttribute("at")})},[e]),(0,Q.useEffect)(()=>{if(!e)return;let t=e=>{"Escape"===e.key&&n()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e,n]),!e||!i||!s)return null;async function d(e){if(!l&&s){c(!0);try{await fetch("/api/agent/internal/span",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t,spanId:s.spanId,action:e,idempotencyKey:crypto.randomUUID()})})}finally{c(!1),n()}}}return(0,X.jsxs)(CE,{open:!0,children:[(0,X.jsx)(Ck,{asChild:!0,children:(0,X.jsx)("span",{"aria-hidden":"true",style:{position:"fixed",top:i.top,left:i.left,width:0,height:0,pointerEvents:"none"}})}),(0,X.jsx)(CC,{children:(0,X.jsxs)(CM,{side:"bottom",align:"start",sideOffset:4,collisionPadding:8,onInteractOutside:n,className:"z-50 w-[min(16rem,calc(100vw-1rem))] bg-popover border border-border rounded-lg shadow-xl p-3 space-y-2 text-[12px] focus:outline-none",children:[(0,X.jsxs)("div",{className:"space-y-0.5",children:[(0,X.jsxs)("p",{className:"font-medium text-foreground truncate",children:[s.by??"unknown"," · ",s.basis??"—"," · ",function(e){if(!e)return"";let t=Math.floor((Date.now()-new Date(e).getTime())/1e3);if(t<60)return`${t}s ago`;let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}(s.at)]}),s.basisDetail&&(0,X.jsxs)("p",{className:"text-muted-foreground italic truncate",children:["“",s.basisDetail,"”"]}),s.origin&&(0,X.jsxs)("p",{className:"text-muted-foreground/60",children:["origin: ",s.origin]})]}),(0,X.jsxs)("div",{className:"flex items-center gap-1.5 pt-1",children:[(0,X.jsx)("button",{type:"button",disabled:l,onClick:()=>void d("accept"),className:"flex-1 py-1 rounded-md bg-primary text-primary-foreground text-[11px] font-medium hover:bg-primary/90 disabled:opacity-50 transition-colors",children:"Accept"}),(0,X.jsx)("button",{type:"button",disabled:l,onClick:()=>void d("revert"),className:"flex-1 py-1 rounded-md border border-border text-[11px] font-medium hover:bg-accent disabled:opacity-50 transition-colors",children:"Revert"}),(0,X.jsx)("button",{type:"button",disabled:l,onClick:()=>{r?.(),n()},className:"flex-1 py-1 rounded-md border border-border text-[11px] font-medium hover:bg-accent disabled:opacity-50 transition-colors",children:"Comment"})]}),(0,X.jsx)(CP,{className:"fill-border"})]})})]})}async function Cz(e,t,n,r){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(),...{}},body:JSON.stringify({baseRevision:t,by:"human",ops:[{type:n,suggestionId:r}]})});return{ok:o.ok,status:o.status}}function C$({suggestion:e,currentMarkdown:t,path:n,baseRevision:r,getLatestRevision:i,top:o,left:s,width:a,onSettled:l}){let[c,d]=(0,Q.useState)(!1);async function u(){if(!c){d(!0);try{let t=await Cz(n,r,"suggestion.accept",e.id);t.ok||409!==t.status||(t=await Cz(n,i(),"suggestion.accept",e.id))}finally{d(!1),l()}}}async function h(){if(!c){d(!0);try{await Cz(n,r,"suggestion.reject",e.id)}finally{d(!1),l()}}}let p="delete"===e.kind,f="insertAfter"===e.kind||"insertBefore"===e.kind;return(0,X.jsxs)("div",{style:{position:"absolute",top:o,left:s,width:a>0?a:void 0,zIndex:30},className:"my-1 rounded-lg border border-border bg-card shadow-md text-[12px] overflow-hidden",role:"region","aria-label":`Suggestion by ${e.by}`,children:[(0,X.jsx)("div",{className:"flex items-center justify-between px-3 py-2 bg-muted/50 border-b border-border",children:(0,X.jsxs)("span",{className:"font-medium text-foreground",children:[(0,X.jsx)("span",{className:"text-primary",children:e.by})," suggests ",(0,X.jsx)("span",{className:"text-muted-foreground",children:function(e){switch(e){case"replace":return"replacing this block";case"insertAfter":return"inserting content after this block";case"insertBefore":return"inserting content before this block";case"delete":return"deleting this block"}}(e.kind)})]})}),(0,X.jsxs)("div",{className:"p-3 space-y-2",children:["replace"===e.kind&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)("div",{children:[(0,X.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/60 mb-1",children:"─ current ─"}),(0,X.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-muted-foreground bg-destructive/5 rounded px-2 py-1",children:t||"(empty)"})]}),(0,X.jsxs)("div",{children:[(0,X.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/60 mb-1",children:"─ proposed ─"}),(0,X.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-foreground bg-primary/5 rounded px-2 py-1",children:e.markdown??"(empty)"})]})]}),f&&(0,X.jsxs)("div",{children:[(0,X.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/60 mb-1",children:"─ will be inserted ─"}),(0,X.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-foreground bg-primary/5 rounded px-2 py-1",children:e.markdown??"(empty)"})]}),p&&(0,X.jsxs)("div",{children:[(0,X.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/60 mb-1",children:"─ will be deleted ─"}),(0,X.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-muted-foreground line-through bg-destructive/5 rounded px-2 py-1",children:t||"(empty)"})]}),e.basisDetail&&(0,X.jsxs)("p",{className:"italic text-muted-foreground/70 text-[11px]",children:["Reason: ",e.basisDetail]})]}),(0,X.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-t border-border bg-muted/30",children:[(0,X.jsx)("button",{type:"button",disabled:c,onClick:()=>void u(),className:"flex-1 py-1 rounded-md bg-primary text-primary-foreground text-[11px] font-medium hover:bg-primary/90 disabled:opacity-50 transition-colors",children:"Accept"}),(0,X.jsx)("button",{type:"button",disabled:c,onClick:()=>void h(),className:"flex-1 py-1 rounded-md border border-border text-[11px] font-medium hover:bg-accent disabled:opacity-50 transition-colors",children:"Reject"})]})]})}async function CG(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(),...{}},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 i.ok?{ok:!0,stale:!1}:{ok:!1,stale:!1}}let Cq={replace:"Replace block",insertAfter:"Insert after",insertBefore:"Insert before",delete:"Delete block"};function CV({path:e,blockRef:t,currentMarkdown:n,anchor:r,onClose:i}){let[o,s]=(0,Q.useState)("replace"),[a,l]=(0,Q.useState)(n),[c,d]=(0,Q.useState)(""),[u,h]=(0,Q.useState)(!1),p=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{"replace"===o?l(n):l("")},[o,n]),(0,Q.useEffect)(()=>{let e=e=>{"Escape"===e.key&&i()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[i]),(0,Q.useEffect)(()=>{setTimeout(()=>p.current?.focus(),50)},[]);let f="delete"!==o,m=!u&&(!f||a.trim().length>0);async function g(){if(m){h(!0);try{let n={type:"suggestion.add",ref:t,kind:o,basis:"suggested"};f&&(n.markdown=a),c.trim()&&(n.basisDetail=c.trim());let r=EE.getState().byPath[e]?.snapshotRevision??0,s=await CG(e,r,[n]);!s.ok&&s.stale&&void 0!==s.newRevision&&(await EE.getState().loadSidecar(e),r=s.newRevision,s=await CG(e,r,[n])),s.ok&&(await EE.getState().loadSidecar(e),await EE.getState().loadSnapshot(e),i())}finally{h(!1)}}}return(0,X.jsxs)(CE,{open:!0,children:[(0,X.jsx)(Ck,{asChild:!0,children:(0,X.jsx)("span",{"aria-hidden":"true",style:{position:"fixed",top:r.top,left:r.left,width:0,height:0,pointerEvents:"none"}})}),(0,X.jsx)(CC,{children:(0,X.jsxs)(CM,{side:"bottom",align:"start",sideOffset:4,collisionPadding:8,onInteractOutside:i,className:"z-50 w-[min(20rem,calc(100vw-1rem))] bg-popover border border-border rounded-lg shadow-xl p-3 space-y-2.5 text-[12px] focus:outline-none",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between",children:[(0,X.jsx)("span",{className:"font-medium text-foreground",children:"Suggest an edit"}),(0,X.jsx)("span",{className:"text-[11px] font-mono text-muted-foreground/60 truncate ml-2",children:t})]}),(0,X.jsx)("div",{className:"flex flex-wrap gap-1",children:Object.keys(Cq).map(e=>(0,X.jsx)("button",{type:"button",onClick:()=>s(e),className:`px-2 py-0.5 rounded-md text-[10.5px] border transition-colors ${o===e?"bg-primary text-primary-foreground border-primary":"border-border text-muted-foreground hover:bg-accent"}`,children:Cq[e]},e))}),"delete"===o&&(0,X.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-muted-foreground line-through bg-destructive/5 rounded px-2 py-1 max-h-32 overflow-y-auto",children:n||"(empty)"}),f&&(0,X.jsxs)("div",{className:"space-y-1",children:[(0,X.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/60",children:"replace"===o?"proposed content":"content to insert"}),(0,X.jsx)("textarea",{ref:p,value:a,onChange:e=>l(e.target.value),rows:4,placeholder:"Markdown…",className:"w-full resize-y rounded-md border border-border bg-background px-2 py-1.5 font-mono text-[11px] focus:outline-none focus-visible:ring-1 focus-visible:ring-ring placeholder:text-muted-foreground/40"})]}),(0,X.jsx)("input",{type:"text",value:c,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&g()},placeholder:"Reason (optional)",className:"w-full rounded-md border border-border bg-background px-2 py-1.5 text-[12px] focus:outline-none focus-visible:ring-1 focus-visible:ring-ring placeholder:text-muted-foreground/40"}),(0,X.jsxs)("div",{className:"flex items-center justify-between pt-0.5",children:[(0,X.jsx)("span",{className:"text-[10px] text-muted-foreground/40",children:"⌘↵ submit"}),(0,X.jsxs)("div",{className:"flex items-center gap-2",children:[(0,X.jsx)("button",{type:"button",disabled:u,onClick:i,className:"px-2.5 py-1 rounded-md border border-border text-[11px] font-medium hover:bg-accent disabled:opacity-50 transition-colors",children:"Cancel"}),(0,X.jsx)("button",{type:"button",disabled:!m,onClick:()=>void g(),className:"px-2.5 py-1 rounded-md bg-primary text-primary-foreground text-[11px] font-medium hover:bg-primary/90 disabled:opacity-50 transition-colors",children:"Suggest"})]})]}),(0,X.jsx)(CP,{className:"fill-border"})]})})]})}let CW=en("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),CK=en("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),CY=en("sigma",[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]]),CX=en("table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]),CQ=[{label:"Text",icon:en("type",[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]]),description:"Start writing plain text",category:"basic",action:{type:"direct",run:e=>e.chain().focus().setParagraph().run()}},{label:"Heading 1",icon:kc,description:"Large section heading",category:"basic",action:{type:"direct",run:e=>e.chain().focus().toggleHeading({level:1}).run()}},{label:"Heading 2",icon:kd,description:"Medium section heading",category:"basic",action:{type:"direct",run:e=>e.chain().focus().toggleHeading({level:2}).run()}},{label:"Heading 3",icon:ku,description:"Small section heading",category:"basic",action:{type:"direct",run:e=>e.chain().focus().toggleHeading({level:3}).run()}},{label:"Bullet List",icon:kh,description:"Create a bullet list",category:"basic",action:{type:"direct",run:e=>e.chain().focus().toggleBulletList().run()}},{label:"Numbered List",icon:kp,description:"Create a numbered list",category:"basic",action:{type:"direct",run:e=>e.chain().focus().toggleOrderedList().run()}},{label:"Checklist",icon:ks,description:"Create a task checklist",category:"basic",action:{type:"direct",run:e=>e.chain().focus().toggleTaskList().run()}},{label:"Code Block",icon:w5,description:"Insert a code block",category:"basic",action:{type:"direct",run:e=>e.chain().focus().toggleCodeBlock().run()}},{label:"Blockquote",icon:kb,description:"Insert a blockquote",category:"basic",action:{type:"direct",run:e=>e.chain().focus().toggleBlockquote().run()}},{label:"Divider",icon:kf,description:"Insert a horizontal rule",category:"basic",action:{type:"direct",run:e=>e.chain().focus().setHorizontalRule().run()}},{label:"Table",icon:CX,description:"Insert a 3x3 table",category:"basic",action:{type:"direct",run:e=>e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},{label:"Image",icon:em,description:"Upload, paste URL, or drop an image",category:"media",action:{type:"popover",kind:{type:"media",kind:"image"}}},{label:"Video",icon:kv,description:"Upload or paste a video URL",category:"media",action:{type:"popover",kind:{type:"media",kind:"video"}}},{label:"File",icon:el,description:"Attach any file to this page",category:"media",action:{type:"popover",kind:{type:"media",kind:"file"}}},{label:"Callout",icon:CK,description:"Insert an info callout",category:"advanced",action:{type:"direct",run:e=>e.chain().focus().wrapIn("callout",{type:"info"}).run()}},{label:"Warning",icon:CW,description:"Insert a warning callout",category:"advanced",action:{type:"direct",run:e=>e.chain().focus().wrapIn("callout",{type:"warning"}).run()}},{label:"Math",icon:CY,description:"Insert a LaTeX math expression",category:"advanced",action:{type:"direct",run:e=>e.chain().focus().insertContent("$x=y$").run()}}];function CJ({editor:e}){let[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(""),[o,s]=(0,Q.useState)(0),[a,l]=(0,Q.useState)({top:0,left:0}),[c,d]=(0,Q.useState)(null),u=(0,Q.useRef)(null),h=Eu(e=>e.currentPath),p=CQ.filter(e=>e.label.toLowerCase().includes(r.toLowerCase())||e.description.toLowerCase().includes(r.toLowerCase())),f=(0,Q.useCallback)(()=>{n(!1),i(""),s(0)},[]),m=(0,Q.useCallback)(t=>{if(!e)return;let{from:o}=e.state.selection,s=o-r.length-1;e.chain().focus().deleteRange({from:s,to:o}).run(),"direct"===t.action.type?(t.action.run(e),f()):(d(t.action.kind),n(!1),i(""))},[e,r,f]);if((0,Q.useEffect)(()=>{if(!e)return;let a=a=>{if(!t){if("/"===a.key){let{from:t}=e.state.selection,r=e.state.doc.textBetween(Math.max(0,t-1),t);if(1===t||""===r||"\n"===r||" "===r){let r=e.view.coordsAtPos(t),o=e.view.dom.getBoundingClientRect();l({top:r.bottom-o.top+4,left:r.left-o.left}),n(!0),i(""),s(0)}}return}"Escape"===a.key?(a.preventDefault(),f()):"ArrowDown"===a.key?(a.preventDefault(),s(e=>Math.min(e+1,p.length-1))):"ArrowUp"===a.key?(a.preventDefault(),s(e=>Math.max(e-1,0))):"Enter"===a.key?(a.preventDefault(),p[o]&&m(p[o])):"Backspace"===a.key?0===r.length?f():(i(e=>e.slice(0,-1)),s(0)):" "===a.key?f():1!==a.key.length||a.metaKey||a.ctrlKey||(i(e=>e+a.key),s(0))};return window.addEventListener("keydown",a,!0),()=>window.removeEventListener("keydown",a,!0)},[e,t,r,o,p,f,m]),(0,Q.useEffect)(()=>{if(!t)return;let e=e=>{u.current&&!u.current.contains(e.target)&&f()};return window.addEventListener("mousedown",e),()=>window.removeEventListener("mousedown",e)},[t,f]),(!t||0===p.length)&&!c)return null;let g=new Map;for(let e of p){let t=g.get(e.category)??[];t.push(e),g.set(e.category,t)}return(0,X.jsxs)(X.Fragment,{children:[t&&p.length>0&&(0,X.jsx)("div",{ref:u,className:"absolute z-50 w-[280px] bg-popover border border-border rounded-lg shadow-lg py-1 overflow-hidden max-h-[380px] overflow-y-auto",style:{top:a.top,left:a.left},children:[{key:"basic",title:"Basic"},{key:"media",title:"Media"},{key:"advanced",title:"Advanced"}].map(e=>{let t=g.get(e.key);return t&&0!==t.length?(0,X.jsxs)("div",{children:[(0,X.jsx)("div",{className:"text-[9px] uppercase tracking-wider text-muted-foreground px-3 pt-2 pb-1",children:e.title}),t.map(e=>{let t=p.indexOf(e),n=e.icon;return(0,X.jsxs)("button",{onMouseDown:t=>{t.preventDefault(),m(e)},onMouseEnter:()=>s(t),className:tz("flex items-center gap-3 w-full px-3 py-1.5 text-left transition-colors",t===o?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:[(0,X.jsx)(n,{className:"h-4 w-4 text-muted-foreground shrink-0"}),(0,X.jsxs)("div",{className:"min-w-0",children:[(0,X.jsx)("p",{className:"text-[12px] font-medium truncate",children:e.label}),(0,X.jsx)("p",{className:"text-[10px] text-muted-foreground truncate",children:e.description})]})]},e.label)})]},e.key):null})}),c&&e?"media"===c.type?h?(0,X.jsx)(kC,{kind:c.kind,pagePath:h,anchor:a,onCancel:()=>d(null),onInsert:t=>((t,n)=>{if(!e)return;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(),d(null)})(c.kind,t)}):null:null:null]})}let CZ=en("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),C0=en("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),C1=en("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),C2=en("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),C3=en("columns-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),C5=en("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),C4=en("panel-top",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]]),C6=en("rows-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);function C9({label:e,icon:t,disabled:n,active:r,danger:i,onAction:o}){return(0,X.jsx)("button",{type:"button","aria-label":e,title:e,disabled:n,onMouseDown:e=>e.preventDefault(),onClick:e=>{e.preventDefault(),o()},className:tz("h-7 w-7 inline-flex items-center justify-center rounded text-foreground/80 hover:bg-accent transition-colors disabled:pointer-events-none disabled:opacity-35",r&&"bg-accent text-foreground",i&&"text-destructive hover:bg-destructive/10"),children:(0,X.jsx)(t,{className:"h-3.5 w-3.5"})})}function C7(){return(0,X.jsx)("div",{className:"mx-1 h-5 w-px bg-border"})}function C8({editor:e}){if(!e)return null;let t=()=>{if(!lu(e.state))return null;try{return lI(e.state)}catch{return null}},n=t=>{t()&&(e.commands.focus(),e.commands.fixTables())},r=n=>{let r=t();if(!r)return;let i=r.top,o=i+n;if(!(o<0)&&!(o>=r.map.height)){var s;(s={from:i,to:o},(e,t)=>{let{from:n,to:r,select:i=!0,pos:o=e.selection.from}=s,a=e.tr;return!!function(e){var t,n,r,i,o;let s,{tr:a,originIndex:l,targetIndex:c,select:d,pos:u}=e,h=lA(a.doc.resolve(u));if(!h)return!1;let p=null==(t=lM(a,l))?void 0:t.indexes,f=null==(n=lM(a,c))?void 0:n.indexes;if(!p||!f||p.includes(c))return!1;let m=(r=h.node,i=p,o=f,s=lk(r),lT(r,s=lN(s,i,o,0)));if(a.replaceWith(h.pos,h.pos+h.node.nodeSize,m),!d)return!0;let g=la.get(m),b=h.start,y=g.positionAt(c,g.width-1,m),x=a.doc.resolve(b+y),v=g.positionAt(c,0,m),E=a.doc.resolve(b+v);return a.setSelection(ly.rowSelection(x,E)),!0}({tr:a,originIndex:n,targetIndex:r,select:i,pos:o})&&(null==t||t(a),!0)})(e.state,e.view.dispatch),e.commands.focus()}},i=n=>{let r=t();if(!r)return;let i=r.left,o=i+n;if(!(o<0)&&!(o>=r.map.width)){var s;(s={from:i,to:o},(e,t)=>{let{from:n,to:r,select:i=!0,pos:o=e.selection.from}=s,a=e.tr;return!!function(e){var t,n,r,i,o;let s,{tr:a,originIndex:l,targetIndex:c,select:d,pos:u}=e,h=lA(a.doc.resolve(u));if(!h)return!1;let p=null==(t=l_(a,l))?void 0:t.indexes,f=null==(n=l_(a,c))?void 0:n.indexes;if(!p||!f||p.includes(c))return!1;let m=(r=h.node,i=p,o=f,s=lO(lk(r)),lT(r,s=lO(s=lN(s,i,o,0))));if(a.replaceWith(h.pos,h.pos+h.node.nodeSize,m),!d)return!0;let g=la.get(m),b=h.start,y=g.positionAt(g.height-1,c,m),x=a.doc.resolve(b+y),v=g.positionAt(0,c,m),E=a.doc.resolve(b+v);return a.setSelection(ly.colSelection(x,E)),!0}({tr:a,originIndex:n,targetIndex:r,select:i,pos:o})&&(null==t||t(a),!0)})(e.state,e.view.dispatch),e.commands.focus()}},o=t(),s=!!o&&o.top>0,a=!!o&&o.top<o.map.height-1,l=!!o&&o.left>0,c=!!o&&o.left<o.map.width-1;return(0,X.jsxs)(wJ,{editor:e,pluginKey:"tableMenu",options:{placement:"top",offset:10},shouldShow:({editor:e})=>e.isActive("table"),className:"flex items-center gap-0.5 rounded-md border border-border bg-popover px-1 py-1 shadow-lg",children:[(0,X.jsx)(C9,{label:"Select cell text",icon:CX,onAction:()=>{let t=ld(e.state.selection.$from),n=t?.nodeAfter;t&&n&&e.chain().focus().setTextSelection({from:t.pos+1,to:t.pos+n.nodeSize-1}).run()}}),(0,X.jsx)(C7,{}),(0,X.jsx)(C9,{label:"Add row above",icon:C6,onAction:()=>n(()=>e.chain().focus().addRowBefore().run())}),(0,X.jsx)(C9,{label:"Add row below",icon:CZ,onAction:()=>n(()=>e.chain().focus().addRowAfter().run())}),(0,X.jsx)(C9,{label:"Move row up",icon:C2,disabled:!s,onAction:()=>r(-1)}),(0,X.jsx)(C9,{label:"Move row down",icon:CZ,disabled:!a,onAction:()=>r(1)}),(0,X.jsx)(C9,{label:"Delete row",icon:eN,danger:!0,onAction:()=>n(()=>e.chain().focus().deleteRow().run())}),(0,X.jsx)(C7,{}),(0,X.jsx)(C9,{label:"Add column before",icon:C3,onAction:()=>n(()=>e.chain().focus().addColumnBefore().run())}),(0,X.jsx)(C9,{label:"Add column after",icon:C1,onAction:()=>n(()=>e.chain().focus().addColumnAfter().run())}),(0,X.jsx)(C9,{label:"Move column left",icon:C0,disabled:!l,onAction:()=>i(-1)}),(0,X.jsx)(C9,{label:"Move column right",icon:C1,disabled:!c,onAction:()=>i(1)}),(0,X.jsx)(C9,{label:"Delete column",icon:eN,danger:!0,onAction:()=>n(()=>e.chain().focus().deleteColumn().run())}),(0,X.jsx)(C7,{}),(0,X.jsx)(C9,{label:"Toggle header row",icon:C4,onAction:()=>n(()=>e.chain().focus().toggleHeaderRow().run())}),(0,X.jsx)(C9,{label:"Toggle header column",icon:C5,onAction:()=>n(()=>e.chain().focus().toggleHeaderColumn().run())}),(0,X.jsx)(C7,{}),(0,X.jsx)(C9,{label:"Delete table",icon:eN,danger:!0,onAction:()=>e.chain().focus().deleteTable().run()})]})}let _e=Q.forwardRef(({className:e,type:t,...n},r)=>(0,X.jsx)("input",{type:t,className:tz("flex h-9 w-full rounded-sm border border-input bg-secondary px-3 py-1 text-sm shadow-e-1 transition-colors file:border-0 file:bg-transparent file:text-sm file:font-normal placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));_e.displayName="Input";var _t=Q.forwardRef((e,t)=>(0,X.jsx)(kE.label,{...e,ref:t,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));_t.displayName="Label";let _n=eH("text-sm font-normal leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-50"),_r=Q.forwardRef(({className:e,...t},n)=>(0,X.jsx)(_t,{ref:n,className:tz(_n(),e),...t}));_r.displayName=_t.displayName;var _i=e.i(187014);function _o(e,t){_i.toast.error(e,t)}let _s=["entities","concepts","comparisons"],_a=/^[a-z0-9-]+$/;function _l({editor:e,onCreateRequest:t}){let[n,r]=(0,Q.useState)(!1),[i,o]=(0,Q.useState)(""),[s,a]=(0,Q.useState)(0),[l,c]=(0,Q.useState)({top:0,left:0}),d=(0,Q.useRef)(null),u=(0,Q.useRef)(0),h=Ex(e=>e.slugs),p=Ex(e=>e.slugDir),f=Ex(e=>e.has),m=Array.from(h).sort().filter(e=>!i||e.includes(i.toLowerCase())).slice(0,20),g=i.length>0&&_a.test(i)&&!f(i),b=m.length+ +!!g,y=(0,Q.useCallback)(()=>{r(!1),o(""),a(0)},[]),x=(0,Q.useCallback)(t=>{if(!e)return;let{from:n}=e.state.selection,r=u.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(),y()},[e,y]),v=(0,Q.useCallback)(async n=>{if(e){if(n<m.length)x(m[n]??"");else if(g){let e=await t(i);e.ok?x(e.slug):y()}}},[e,m,g,i,x,t,y]);return((0,Q.useEffect)(()=>{if(!e)return;let t=t=>{if(!n){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),i=e.view.dom.getBoundingClientRect();c({top:n.bottom-i.top+4,left:n.left-i.left}),u.current=t+1,r(!0),o(""),a(0)}return}"ArrowDown"===t.key?(t.preventDefault(),a(e=>b>0?(e+1)%b:0)):"ArrowUp"===t.key?(t.preventDefault(),a(e=>b>0?(e-1+b)%b:0)):"Enter"===t.key?(t.preventDefault(),t.stopPropagation(),b>0&&v(s)):"Escape"===t.key||"]"===t.key?y():"Backspace"===t.key?0===i.length?y():(o(e=>e.slice(0,-1)),a(0)):1!==t.key.length||t.metaKey||t.ctrlKey||(o(e=>e+t.key),a(0))};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[e,n,i,s,b,y,v]),(0,Q.useEffect)(()=>{if(!n)return;let e=e=>{d.current&&!d.current.contains(e.target)&&y()};return window.addEventListener("mousedown",e),()=>window.removeEventListener("mousedown",e)},[n,y]),n&&0!==b)?(0,X.jsxs)("div",{ref:d,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:l.top,left:l.left},children:[m.map((e,t)=>{let n=p.get(e);return(0,X.jsxs)("button",{type:"button",onMouseDown:e=>{e.preventDefault(),v(t)},onMouseEnter:()=>a(t),className:tz("flex items-center justify-between w-full px-3 py-1.5 text-left text-sm transition-colors",t===s?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:[(0,X.jsx)("span",{className:"truncate",children:e}),n&&(0,X.jsx)("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground bg-muted px-1.5 py-0.5 rounded",children:n})]},e)}),g&&(0,X.jsx)("button",{type:"button",onMouseDown:e=>{e.preventDefault(),v(m.length)},onMouseEnter:()=>a(m.length),className:tz("flex items-center w-full px-3 py-1.5 text-left text-sm transition-colors",m.length===s?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:(0,X.jsxs)("span",{className:"text-muted-foreground",children:["+ Create new “",i,"”"]})})]}):null}async function _c(e,t){let n=new FormData;n.append("file",t);try{let t=await fetch(`/api/upload/${e}`,{method:"POST",body:n});if(!t.ok)return null;return(await t.json()).url}catch{return null}}function _d(e){let t=[];for(let n of e)t.push({path:n.path,name:n.name}),n.children&&t.push(..._d(n.children));return t}function _u(e,t,n){let r=_d(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 _h(e,t,n){let r=e.split("/");for(let e=1;e<r.length;e++)n(r.slice(0,e).join("/"));t(e),Eu.getState().loadPage(e),setTimeout(()=>{document.querySelector("[data-editor-scroll]")?.scrollTo(0,0)},0)}function _p(){let{currentPath:e,content:t,saveStatus:n,frontmatter:r,isLoading:i,loadStatus:o,createMissingPage:s,editMode:a,setEditMode:l}=Eu(),c=Eh(e=>e.nodes),d=Ey(e=>Em[e.width]),u=r?.dir==="rtl",{open:h,clearMessages:p}=Ee(),{open:f,Dialog:m}=function(){let[e,t]=(0,Q.useState)(!1),[n,r]=(0,Q.useState)({slug:"",dir:"entities",title:""}),[i,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),a=(0,Q.useCallback)(e=>(r({slug:e,dir:"entities",title:e.split("-").filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}),t(!0),new Promise(e=>{s.current=e})),[]),l=(0,Q.useCallback)(()=>{t(!1),s.current?.({ok:!1,slug:n.slug}),s.current=null},[n.slug]),c=(0,Q.useCallback)(async()=>{let{slug:e,dir:r,title:i}=n;o(!0);try{let n=await fetch("/api/wiki/page",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:e,dir:r,title:i.trim()||void 0})});if(n.ok||409===n.status){let n=Ex.getState();n.invalidate(),n.load(),t(!1),s.current?.({ok:!0,slug:e,dir:r}),s.current=null}else{let e=await n.json().catch(()=>({})),t=null!==e&&"object"==typeof e&&"error"in e&&"string"==typeof e.error?e.error:"Failed to create page";_o(t)}}catch{_o("Failed to create page")}finally{o(!1)}},[n]);return{open:a,Dialog:(0,X.jsx)(rn,{open:e,onOpenChange:e=>{e||l()},children:(0,X.jsxs)(rM,{children:[(0,X.jsx)(rO,{children:(0,X.jsx)(rD,{children:"Create wiki page"})}),(0,X.jsxs)("div",{className:"space-y-4 py-2",children:[(0,X.jsxs)("div",{className:"space-y-1.5",children:[(0,X.jsx)(_r,{htmlFor:"wiki-create-slug",children:"Slug"}),(0,X.jsx)(_e,{id:"wiki-create-slug",value:n.slug,readOnly:!0,className:"bg-muted cursor-default select-all"})]}),(0,X.jsxs)("div",{className:"space-y-1.5",children:[(0,X.jsx)(_r,{children:"Directory"}),(0,X.jsx)("div",{className:"flex gap-4",children:_s.map(e=>(0,X.jsxs)("label",{className:"flex items-center gap-1.5 text-sm cursor-pointer",children:[(0,X.jsx)("input",{type:"radio",name:"wiki-create-dir",value:e,checked:n.dir===e,onChange:()=>r(t=>({...t,dir:e})),className:"accent-primary"}),e]},e))})]}),(0,X.jsxs)("div",{className:"space-y-1.5",children:[(0,X.jsx)(_r,{htmlFor:"wiki-create-title",children:"Title (optional)"}),(0,X.jsx)(_e,{id:"wiki-create-title",value:n.title,onChange:e=>r(t=>({...t,title:e.target.value})),placeholder:"Humanized title..."})]})]}),(0,X.jsxs)(rI,{children:[(0,X.jsx)(tG,{variant:"outline",onClick:l,disabled:i,children:"Cancel"}),(0,X.jsx)(tG,{onClick:()=>void c(),disabled:i,children:i?"Creating...":"Create"})]})]})})}}(),g=(0,Q.useRef)(f);g.current=f;let b=(0,Q.useRef)(!1),[y,x]=(0,Q.useState)(!1),[v,E]=(0,Q.useState)(""),[w,k]=(0,Q.useState)("page");(0,Q.useEffect)(()=>{k("page")},[]),(0,Q.useEffect)(()=>{Ex.getState().load()},[]),(0,Q.useEffect)(()=>{e&&EE.getState().loadSidecar(e)},[e]),(0,Q.useEffect)(()=>{if(!e||!/\.(md|markdown)$/i.test(e))return;let t=t=>{fetch("/api/wiki/presence",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,action:t}),keepalive:"close"===t}).catch(()=>{})};t("open");let n=setInterval(()=>t("heartbeat"),3e4),r=()=>{"hidden"===document.visibilityState&&t("heartbeat")};return document.addEventListener("visibilitychange",r),()=>{clearInterval(n),document.removeEventListener("visibilitychange",r),t("close")}},[e]),(0,Q.useEffect)(()=>{let e=new EventSource("/api/wiki/watch");return e.onmessage=e=>{try{let t=JSON.parse(e.data),n=Eu.getState().currentPath;("change"===t.type||"add"===t.type)&&n&&t.path===n&&EE.getState().loadSnapshot(n).then(()=>EE.getState().loadSidecar(n))}catch{}},()=>{e.close()}},[]);let[T,N]=(0,Q.useState)(null),A=(0,Q.useRef)(null),[S,C]=(0,Q.useState)(new Map),_=EE(t=>e?t.byPath[e]?.snapshotBlocks:void 0),M=EE(t=>e?t.byPath[e]?.sidecar?.suggestions:void 0),O=EE(t=>e?t.byPath[e]?.snapshotRevision??0:0),I=EE(t=>e?t.byPath[e]?.sidecar?.comments:void 0),D=(0,Q.useMemo)(()=>_??[],[_]),R=(0,Q.useMemo)(()=>I??[],[I]),L=(0,Q.useMemo)(()=>M?.filter(e=>"pending"===e.status)??[],[M]),P=(0,Q.useMemo)(()=>{let e={};for(let t of R)(e[t.ref]??=[]).push(t);return e},[R]),[j,B]=(0,Q.useState)(null),[F,H]=(0,Q.useState)(null),U=(0,Q.useCallback)(()=>{if(!J.current)return null;let e=J.current.view,{from:t}=e.state.selection,n=Eu.getState().currentPath??"",r=EE.getState().byPath[n]?.snapshotBlocks??[],i=e.state.doc.resolve(t),o=i.depth>0?i.index(0):0,s=A.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},[]),z=(0,Q.useCallback)(()=>{let e=U();if(!e)return;let t=e.blockEl.getBoundingClientRect();H({blockRef:e.blockRef,markdown:e.markdown,anchor:{top:t.bottom+4,left:t.left}})},[U]),$=(0,Q.useCallback)(()=>{let e=U();e&&B({blockRef:e.blockRef,el:e.blockEl})},[U]),G=(0,Q.useRef)(!1),q=(0,Q.useRef)(!1),V=(0,Q.useRef)(null),W=e=>e.replace(/\s+$/g,"").trimStart(),K=(0,Q.useCallback)(async()=>{if(q.current||"suggesting"!==Eu.getState().editMode||!G.current)return;let e=J.current,t=Eu.getState().currentPath;if(!e||!t)return;let n=A.current?.querySelector(".ProseMirror");if(!n)return;let r=Array.from(n.children),i=EE.getState().byPath[t]?.snapshotBlocks??[];if(0!==i.length){q.current=!0,G.current=!1;try{let n=()=>EE.getState().byPath[t]?.snapshotRevision??0,o=async()=>{await EE.getState().loadSnapshot(t),await EE.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?v6(s.outerHTML).trim():null;if(l&&null!==c){if(W(c)!==W(l.markdown)){let e=await Ek({path:t,ref:l.ref,kind:"replace",markdown:c,getRevision:n,refresh:o});a=a||e}}else if(l&&null===c){let e=await Ek({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 Ek({path:t,ref:e,kind:"insertAfter",markdown:c,getRevision:n,refresh:o});a=a||r}}}if(a){await o();let n=(EE.getState().byPath[t]?.snapshotBlocks??i).map(e=>e.markdown).join("\n\n");b.current=!0;let r=await vg(n,t);e.commands.setContent(r),setTimeout(()=>{b.current=!1},50)}}finally{q.current=!1}}},[]);(0,Q.useEffect)(()=>{e&&EE.getState().loadSnapshot(e)},[e]),(0,Q.useEffect)(()=>{if(!e||0===D.length||!A.current)return;let t=A.current,n=t.querySelector(".ProseMirror");if(!n)return;let r=Array.from(n.children),i=t.getBoundingClientRect(),o=new Map;for(let e=0;e<Math.min(r.length,D.length);e++){let n=r[e],s=D[e];n.setAttribute("data-block-ref",s.ref);let a=n.getBoundingClientRect();o.set(s.ref,{top:a.top-i.top+t.scrollTop,left:a.left-i.left,width:a.width,bottom:a.bottom-i.top+t.scrollTop})}C(o)},[e,D]);let Y=function(e={},t=[]){let n=(0,ct.useRef)(e);n.current=e;let[r]=(0,ct.useState)(()=>new h$(n)),i=(0,cn.useSyncExternalStore)(r.subscribe,r.getEditor,r.getServerSnapshot);return(0,ct.useDebugValue)(i),(0,ct.useEffect)(r.onRender(t)),!function(e){var t;let[n]=(0,ct.useState)(()=>new hH(e.editor)),r=(0,hR.useSyncExternalStoreWithSelector)(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,null!=(t=e.equalityFn)?t:hI);hF(()=>n.watch(e.editor),[e.editor,n]),(0,ct.useDebugValue)(r)}({editor:i,selector:({transactionNumber:t})=>!1===e.shouldRerenderOnTransaction||void 0===e.shouldRerenderOnTransaction?null:e.immediatelyRender&&0===t?0:t+1}),i}({extensions:SH,content:"",onUpdate:(0,Q.useCallback)(({editor:e})=>{if(b.current||!e)return;"suggesting"===Eu.getState().editMode&&(G.current=!0);let t=v6(e.getHTML());Eu.getState().updateContent(t)},[]),onBlur:()=>{K()},onSelectionUpdate:({editor:e})=>{if("suggesting"!==Eu.getState().editMode)return;let{from:t}=e.state.selection,n=e.state.doc.resolve(t),r=n.depth>0?n.index(0):0,i=V.current;V.current=r,null!==i&&i!==r&&G.current&&K()},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)] mx-auto"},handleKeyDown:(e,t)=>{if((t.metaKey||t.ctrlKey)&&"a"===t.key.toLowerCase()&&lu(e.state)){let n=ld(e.state.selection.$from),r=n?.nodeAfter;if(!n||!r)return!1;let i=n.pos+1,o=n.pos+r.nodeSize-1;return(e.state.selection.from!==i||e.state.selection.to!==o)&&(t.preventDefault(),Y?.chain().focus().setTextSelection({from:i,to:o}).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=Ex.getState();if(i.has(e)){let n=i.getDir(e),r=null===n||"root"===n?`${e}.md`:`${n}/${e}.md`;Eu.getState().loadPage(r),t&&setTimeout(()=>{document.querySelector(`[id="${t}"]`)?.scrollIntoView({behavior:"smooth"})},200)}else g.current(e).then(e=>{if(e.ok){let t=e.dir??"entities",n=`${t}/${e.slug}.md`;Eu.getState().loadPage(n)}});return!0}if(i.startsWith("#page:")){n.preventDefault(),n.stopPropagation();let e=i.replace("#page:",""),{nodes:t,selectPage:r,expandPath:o}=Eh.getState(),s=_u(e,Eu.getState().currentPath,t);return s&&_h(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}=Eh.getState(),l=function(e,t,n){let r=_d(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 _u(i.includes("/")?i.split("/").pop():i,t,n)}(i,Eu.getState().currentPath,o);return l&&_h(l,s,a),!0},handlePaste:(e,t)=>{let n=t.clipboardData?.files,r=Eu.getState().currentPath;if(n&&n.length>0&&r){for(let e of Array.from(n))_c(r,e).then(t=>{t&&Y&&(e.type.startsWith("image/")?Y.chain().focus().setImage({src:t,alt:e.name}).run():Y.chain().focus().insertContent(`<a href="${t}">${e.name}</a>`).run())});return!0}return!1},handleDrop:(e,t)=>{let n=t.dataTransfer?.files;if(!n||0===n.length)return!1;let r=Eu.getState().currentPath;if(!r)return!1;for(let e of(t.preventDefault(),Array.from(n)))_c(r,e).then(t=>{t&&Y&&(e.type.startsWith("image/")?Y.chain().focus().setImage({src:t,alt:e.name}).run():Y.chain().focus().insertContent(`<a href="${t}">${e.name}</a>`).run())});return!0}},immediatelyRender:!1}),J=(0,Q.useRef)(Y);J.current=Y;let Z=(0,Q.useRef)(null),ee=(0,Q.useRef)(null),[et,en]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(!Y||null===e||Eu.getState().isDirty&&e===Z.current||i&&""===t)return;let n=`${e} ${t}`;if(ee.current===n){et!==e&&en(e);return}Z.current=e,(async()=>{b.current=!0;let r=await vg(t,e);Y.commands.setContent(r),ee.current=n,en(e),setTimeout(()=>{b.current=!1},50)})()},[Y,t,e,i,et]);let er=null!==e&&(i||et!==e);if(null===e)return(0,X.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,X.jsxs)("div",{className:"text-center space-y-3",children:[(0,X.jsx)("p",{className:"text-lg font-medium tracking-[-0.02em]",children:"No page selected"}),(0,X.jsx)("p",{className:"text-sm text-muted-foreground/70",children:"Select a page from the sidebar or create a new one"})]})});if("missing"===o){let t=(e.split("/").pop()||e).replace(/[-_]+/g," ").replace(/\b\w/g,e=>e.toUpperCase()),n=h2(c,e),r=n?.children??[],i=r.length>0;return(0,X.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,X.jsxs)("div",{className:"max-w-3xl mx-auto px-6 py-10 space-y-6",children:[(0,X.jsxs)("div",{className:"space-y-3",children:[(0,X.jsx)("p",{className:"text-lg font-medium tracking-[-0.02em] text-foreground",children:t}),(0,X.jsxs)("p",{className:"text-sm text-muted-foreground/80",children:["This folder doesn't have an"," ",(0,X.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,X.jsxs)("button",{onClick:()=>void s(t),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,X.jsx)(ec,{className:"h-3.5 w-3.5"}),"Create page"]})]}),i&&(0,X.jsx)(SJ,{folderPath:e,entries:r},e)]})})}let ei=async()=>{if(y){if(Eu.getState().updateContent(v),Y){b.current=!0;let t=await vg(v,e??void 0);Y.commands.setContent(t),setTimeout(()=>{b.current=!1},50)}x(!1)}else E(Eu.getState().content),x(!0)},eo=h2(c,e),es=eo?.type==="directory"||eo?.type==="cabinet"?eo.children??[]:[],ea=es.length>0,el=ea&&"files"===w;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[ea&&(0,X.jsxs)("div",{className:"flex items-center gap-1 px-3 pt-2 border-b border-border",children:[(0,X.jsx)("button",{onClick:()=>k("page"),className:`px-3 py-1.5 text-[12px] rounded-t-md border-b-2 -mb-px transition-colors ${"page"===w?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,"aria-pressed":"page"===w,children:"Page"}),(0,X.jsxs)("button",{onClick:()=>k("files"),className:`px-3 py-1.5 text-[12px] rounded-t-md border-b-2 -mb-px transition-colors ${"files"===w?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,"aria-pressed":"files"===w,children:["Files",(0,X.jsx)("span",{className:"ml-1.5 text-muted-foreground/60",children:es.length})]})]}),el?(0,X.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,X.jsx)("div",{className:"max-w-3xl mx-auto px-6 py-6",children:(0,X.jsx)(SJ,{folderPath:e,entries:es},e)})}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)("div",{className:"flex items-center min-w-0",children:[(0,X.jsx)("div",{className:"flex-1 min-w-0",children:!y&&(0,X.jsx)(kM,{editor:Y})}),(0,X.jsxs)("button",{onClick:ei,className:`flex items-center gap-1.5 px-3 py-1 mr-2 text-[11px] rounded-md transition-colors border border-border ${y?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"}`,children:[(0,X.jsx)(rP,{className:"h-3 w-3"}),y?"Preview":"Markdown"]})]}),y?(0,X.jsx)("div",{className:"flex-1 overflow-y-auto p-4",dir:u?"rtl":void 0,children:(0,X.jsx)("textarea",{value:v,onChange:e=>E(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,X.jsxs)("div",{className:"flex-1 relative",dir:u?"rtl":void 0,children:["suggesting"===a&&(0,X.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,X.jsxs)("div",{ref:A,className:`absolute inset-0 overflow-y-auto ${"suggesting"===a?"pt-7":""}`,style:{"--editor-max-w":d},"data-editor-scroll":!0,children:[(0,X.jsxs)("div",{"aria-hidden":"true",className:"relative pointer-events-none",style:{height:0},children:[Object.entries(P).map(([e,t])=>{let n=S.get(e);return n?(0,X.jsx)("div",{style:{pointerEvents:"auto"},children:(0,X.jsx)(S0,{blockRef:e,comments:t,top:n.top+4,left:Math.max(0,n.left-20),onClick:()=>{let t=A.current?.querySelector(`[data-block-ref="${e}"]`);t&&B({blockRef:e,el:t})}})},`pip-${e}`):null}),e&&L.map(t=>{let n=S.get(t.ref),r=D.find(e=>e.ref===t.ref);if(!n||!r)return null;let i="insertAfter"===t.kind?n.bottom+4:"insertBefore"===t.kind?Math.max(0,n.top-80):n.top;return(0,X.jsx)("div",{style:{pointerEvents:"auto"},children:(0,X.jsx)(C$,{path:e,suggestion:t,currentMarkdown:r.markdown,baseRevision:O,getLatestRevision:()=>EE.getState().byPath[e]?.snapshotRevision??0,top:i,left:n.left,width:n.width,onSettled:()=>{EE.getState().loadSidecar(e),EE.getState().loadSnapshot(e)}})},`sug-${t.id}`)})]}),j&&e&&(0,X.jsx)(CH,{path:e,blockRef:j.blockRef,comments:P[j.blockRef]??[],anchorEl:j.el,onClose:()=>B(null)}),F&&e&&(0,X.jsx)(CV,{path:e,blockRef:F.blockRef,currentMarkdown:F.markdown,anchor:F.anchor,onClose:()=>H(null)}),(0,X.jsx)(hB,{editor:Y}),(0,X.jsx)("div",{"aria-hidden":"true",className:"contents",onMouseOver:e=>{let t=e.target.closest(".proof-span");t&&t!==T&&N(t)},onMouseOut:e=>{let t=e.relatedTarget;t?.closest(".proof-span")||N(null)}}),e&&(0,X.jsx)(CU,{targetEl:T,path:e,onClose:()=>N(null),onComment:()=>{if(!T)return;let e=T.closest("[data-block-ref]");if(!e)return;let t=e.getAttribute("data-block-ref");t&&B({blockRef:t,el:e})}}),(0,X.jsx)(ko,{editor:Y,onSuggestEdit:z,onComment:$}),(0,X.jsx)(C8,{editor:Y}),(0,X.jsx)(CJ,{editor:Y}),(0,X.jsx)(_l,{editor:Y,onCreateRequest:g.current}),(0,X.jsxs)("div",{className:"max-w-[var(--editor-max-w,48rem)] mx-auto px-8 pb-8 flex items-center gap-4",children:[(0,X.jsxs)("button",{onClick:()=>{p(),h()},className:"group flex items-center gap-2 text-[13px] text-muted-foreground/50 hover:text-muted-foreground transition-colors cursor-pointer",children:[(0,X.jsx)(h1,{className:"h-3.5 w-3.5 group-hover:text-primary transition-colors"}),(0,X.jsx)("span",{children:"Edit with AI"})]}),(0,X.jsxs)("span",{className:"text-[11px] text-muted-foreground/30 select-none",children:[(0,X.jsx)("kbd",{className:"rounded px-1 py-0.5 font-mono text-[10px] ring-1 ring-foreground/10",children:"/"})," ","for commands"]})]})]}),er&&(0,X.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,X.jsx)(eg,{className:"h-5 w-5 animate-spin text-muted-foreground/70"})})]}),(0,X.jsxs)("div",{className:"flex items-center justify-between px-4 py-1 border-t border-border text-xs text-muted-foreground/60",children:[(0,X.jsxs)("span",{className:"text-[10.5px] text-muted-foreground/30 select-none hidden sm:block",children:[(0,X.jsx)("kbd",{className:"rounded px-1 font-mono text-[9.5px] ring-1 ring-foreground/10",children:"⌘S"})," ","save",(0,X.jsx)("span",{className:"mx-1.5 opacity-40",children:"·"}),(0,X.jsx)("kbd",{className:"rounded px-1 font-mono text-[9.5px] ring-1 ring-foreground/10",children:"/"})," ","commands"]}),(0,X.jsxs)("div",{className:"flex items-center gap-3",children:[(0,X.jsxs)("div",{className:"flex items-center rounded-md border border-border overflow-hidden text-[10.5px]",role:"radiogroup","aria-label":"Edit mode",children:[(0,X.jsx)("button",{type:"button",role:"radio","aria-checked":"editing"===a,onClick:()=>l("editing"),className:`px-2 py-0.5 transition-colors ${"editing"===a?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"}`,children:"Editing"}),(0,X.jsx)("button",{type:"button",role:"radio","aria-checked":"suggesting"===a,onClick:()=>l("suggesting"),className:`px-2 py-0.5 transition-colors ${"suggesting"===a?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"}`,children:"Suggesting"})]}),(0,X.jsxs)("span",{children:["saving"===n&&"Saving...","saved"===n&&"Saved","error"===n&&"Save failed"]})]})]})]})]}),m]})}function _f({path:e}){let t=`/api/assets/${e}`,n=e.split("/").pop()||e,r=n.includes(".")?n.split(".").pop()?.toUpperCase():"",i=async()=>{try{await fetch("/api/system/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})})}catch{}};return(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,X.jsx)(rF,{path:e,badge:r||void 0}),(0,X.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,X.jsxs)("div",{className:"flex flex-col items-center gap-4 text-center max-w-sm",children:[(0,X.jsx)("div",{className:"flex size-16 items-center justify-center rounded-2xl bg-muted",children:(0,X.jsx)(el,{className:"size-8 text-muted-foreground/50"})}),(0,X.jsxs)("div",{className:"space-y-1",children:[(0,X.jsx)("p",{className:"text-sm font-medium",children:n}),(0,X.jsx)("p",{className:"text-xs text-muted-foreground",children:"This file type can't be previewed in Cabinet."})]}),(0,X.jsxs)("div",{className:"flex items-center gap-2",children:[(0,X.jsxs)(tG,{variant:"outline",size:"sm",className:"gap-2",onClick:i,children:[(0,X.jsx)(eh,{className:"h-4 w-4"}),"Open in Finder"]}),(0,X.jsxs)(tG,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>{let e=document.createElement("a");e.href=t,e.download=n,e.click()},children:[(0,X.jsx)(rj,{className:"h-4 w-4"}),"Download"]})]})]})})]})}function _m({path:e,title:t}){let n=`/api/assets/${e}`,r=e.split("/").pop()||e,i=r.includes(".")?r.split(".").pop()?.toUpperCase():"IMG";return(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,X.jsxs)(rF,{path:e,badge:i,children:[(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let e=document.createElement("a");e.href=n,e.download=r,e.click()},children:[(0,X.jsx)(rj,{className:"h-3.5 w-3.5"}),"Download"]}),(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(n,"_blank"),children:[(0,X.jsx)(kr,{className:"h-3.5 w-3.5"}),"Open in new tab"]})]}),(0,X.jsx)("div",{className:"flex-1 overflow-auto flex items-center justify-center bg-[#1a1a1a] p-8",children:(0,X.jsx)("img",{src:n,alt:t,className:"max-w-full max-h-full object-contain rounded-md shadow-lg",style:{imageRendering:"auto"}})})]})}function _g({path:e,type:t}){let n=`/api/assets/${e}`,r=e.split("/").pop()||e,i=r.includes(".")?r.split(".").pop()?.toUpperCase():t.toUpperCase();return(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,X.jsxs)(rF,{path:e,badge:i,children:[(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let e=document.createElement("a");e.href=n,e.download=r,e.click()},children:[(0,X.jsx)(rj,{className:"h-3.5 w-3.5"}),"Download"]}),(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(n,"_blank"),children:[(0,X.jsx)(kr,{className:"h-3.5 w-3.5"}),"Open in new tab"]})]}),(0,X.jsx)("div",{className:"flex-1 overflow-auto flex items-center justify-center bg-[#1a1a1a] p-8",children:"video"===t?(0,X.jsx)("video",{src:n,controls:!0,className:"max-w-full max-h-full rounded-md shadow-lg",children:"Your browser does not support the video element."}):(0,X.jsxs)("div",{className:"w-full max-w-lg space-y-4",children:[(0,X.jsx)("div",{className:"text-center text-muted-foreground text-sm",children:r}),(0,X.jsx)("audio",{src:n,controls:!0,className:"w-full",children:"Your browser does not support the audio element."})]})})]})}let _b=en("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),_y=en("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),_x=en("maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]),_v=en("zoom-in",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),_E=en("zoom-out",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);function _w({path:t,title:n}){let[r,i]=(0,Q.useState)(""),[o,s]=(0,Q.useState)(""),[a,l]=(0,Q.useState)(""),[c,d]=(0,Q.useState)(!0),[u,h]=(0,Q.useState)(!1),[p,f]=(0,Q.useState)(!1),[m,g]=(0,Q.useState)(1),[b,y]=(0,Q.useState)({x:0,y:0}),[x,v]=(0,Q.useState)(!1),E=(0,Q.useRef)({x:0,y:0,panX:0,panY:0}),w=(0,Q.useRef)(null),k=(0,Q.useRef)(null),T=(0,Q.useRef)(0),N=(0,Q.useCallback)(e=>{if(e.ctrlKey||e.metaKey){e.preventDefault();let t=e.deltaY>0?-.25:.25;g(e=>Math.min(Math.max(e+t,.25),5))}},[]),A=(0,Q.useCallback)(e=>{0===e.button&&(v(!0),E.current={x:e.clientX,y:e.clientY,panX:b.x,panY:b.y},e.target.setPointerCapture(e.pointerId))},[b]),S=(0,Q.useCallback)(e=>{x&&y({x:E.current.panX+(e.clientX-E.current.x),y:E.current.panY+(e.clientY-E.current.y)})},[x]),C=(0,Q.useCallback)(()=>{v(!1)},[]),_=`/api/assets/${t}`;t.split("/").pop();let M=(0,Q.useCallback)(async()=>{d(!0),l("");try{let t=await fetch(_);if(!t.ok)throw Error("Failed to fetch file");let n=await t.text();i(n);let r=(await e.A(890793)).default;r.initialize({startOnLoad:!1,theme:document.documentElement.classList.contains("dark")?"dark":"default",securityLevel:"loose",suppressErrorRendering:!0}),await r.parse(n.trim());let o=`mermaid-${++T.current}`,{svg:a}=await r.render(o,n.trim());s(a)}catch(e){document.querySelectorAll('[id^="dmermaid-"], [id^="d"]:has(> .error-icon)').forEach(e=>e.remove()),l(e instanceof Error?e.message:"Failed to render diagram")}finally{d(!1)}},[_]);return(0,Q.useEffect)(()=>{M()},[M]),(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,X.jsxs)(rF,{path:t,badge:"MERMAID",children:[(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:`h-7 gap-1.5 text-xs ${u?"bg-muted":""}`,onClick:()=>h(e=>!e),children:[u?(0,X.jsx)(_y,{className:"h-3.5 w-3.5"}):(0,X.jsx)(rP,{className:"h-3.5 w-3.5"}),u?"Diagram":"Code"]}),(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{navigator.clipboard.writeText(r),f(!0),setTimeout(()=>f(!1),2e3)},children:[p?(0,X.jsx)(eo,{className:"h-3.5 w-3.5 text-green-500"}):(0,X.jsx)(_b,{className:"h-3.5 w-3.5"}),p?"Copied":"Copy"]}),o&&!u&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("div",{className:"h-4 w-px bg-border mx-0.5"}),(0,X.jsx)(tG,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>g(e=>Math.max(e-.25,.25)),title:"Zoom out",children:(0,X.jsx)(_E,{className:"h-3.5 w-3.5"})}),(0,X.jsxs)("span",{className:"text-[11px] text-muted-foreground tabular-nums w-10 text-center select-none",children:[Math.round(100*m),"%"]}),(0,X.jsx)(tG,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>g(e=>Math.min(e+.25,5)),title:"Zoom in",children:(0,X.jsx)(_v,{className:"h-3.5 w-3.5"})}),(0,X.jsx)(tG,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{g(1),y({x:0,y:0})},title:"Reset view",children:(0,X.jsx)(_x,{className:"h-3.5 w-3.5"})}),(0,X.jsx)("div",{className:"h-4 w-px bg-border mx-0.5"})]}),o&&(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{if(!o)return;let e=new Blob([o],{type:"image/svg+xml"}),t=URL.createObjectURL(e),r=document.createElement("a");r.href=t,r.download=`${n}.svg`,r.click(),URL.revokeObjectURL(t)},children:[(0,X.jsx)(rj,{className:"h-3.5 w-3.5"}),"SVG"]})]}),(0,X.jsx)("div",{className:"flex-1 overflow-auto",children:c?(0,X.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Rendering diagram..."}):u?(0,X.jsx)("pre",{className:"p-4 text-[13px] leading-relaxed font-mono bg-[#1e1e1e]",children:(0,X.jsx)("code",{children:r.split("\n").map((e,t)=>(0,X.jsxs)("div",{className:"flex",children:[(0,X.jsx)("span",{className:"inline-block w-12 pr-4 text-right text-[#858585] select-none shrink-0",children:t+1}),(0,X.jsx)("span",{className:"text-[#d4d4d4] flex-1",children:e||"\n"})]},t))})}):a?(0,X.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-sm p-8",children:[(0,X.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,X.jsx)("div",{className:"h-10 w-10 rounded-full bg-red-500/10 flex items-center justify-center",children:(0,X.jsx)(rP,{className:"h-5 w-5 text-red-500"})}),(0,X.jsx)("p",{className:"text-red-500 font-medium",children:"Diagram syntax error"})]}),(0,X.jsx)("pre",{className:"text-muted-foreground text-xs max-w-lg text-left bg-muted rounded-md p-3 overflow-auto whitespace-pre-wrap",children:a}),(0,X.jsx)(tG,{variant:"outline",size:"sm",onClick:()=>h(!0),children:"View source to fix"})]}):(0,X.jsx)("div",{ref:k,className:"relative w-full h-full overflow-hidden",style:{cursor:x?"grabbing":"grab"},onWheel:N,onPointerDown:A,onPointerMove:S,onPointerUp:C,children:(0,X.jsx)("div",{ref:w,className:"flex items-center justify-center p-8 min-h-full [&_svg]:max-w-full origin-center select-none",style:{transform:`translate(${b.x}px, ${b.y}px) scale(${m})`},dangerouslySetInnerHTML:{__html:o}})})})]})}var _k="[0-9](_*[0-9])*",_T=`\\.(${_k})`,_N="[0-9a-fA-F](_*[0-9a-fA-F])*",_A={className:"number",variants:[{begin:`(\\b(${_k})((${_T})|\\.)?|(${_T}))[eE][+-]?(${_k})[fFdD]?\\b`},{begin:`\\b(${_k})((${_T})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${_T})[fFdD]?\\b`},{begin:`\\b(${_k})[fFdD]\\b`},{begin:`\\b0[xX]((${_N})\\.?|(${_N})?\\.(${_N}))[pP][+-]?(${_k})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${_N})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0},_S="[0-9](_*[0-9])*",_C=`\\.(${_S})`,__="[0-9a-fA-F](_*[0-9a-fA-F])*",_M={className:"number",variants:[{begin:`(\\b(${_S})((${_C})|\\.)?|(${_C}))[eE][+-]?(${_S})[fFdD]?\\b`},{begin:`\\b(${_S})((${_C})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${_C})[fFdD]?\\b`},{begin:`\\b(${_S})[fFdD]\\b`},{begin:`\\b0[xX]((${__})\\.?|(${__})?\\.(${__}))[pP][+-]?(${_S})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${__})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};let _O=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video","defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],_I=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),_D=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),_R=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),_L=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse(),_P=_D.concat(_R).sort().reverse(),_j=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video","defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],_B=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),_F=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),_H=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),_U=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function _z(e){return e?"string"==typeof e?e:e.source:null}function _$(e){return _G("(?=",e,")")}function _G(...e){return e.map(e=>_z(e)).join("")}function _q(...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=>_z(e)).join("|")+")"}let _V=e=>_G(/\b/,e,/\w$/.test(e)?/\b/:/\B/),_W=["Protocol","Type"].map(_V),_K=["init","self"].map(_V),_Y=["Any","Self"],_X=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],_Q=["false","nil","true"],_J=["assignment","associativity","higherThan","left","lowerThan","none","right"],_Z=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],_0=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],_1=_q(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),_2=_q(_1,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),_3=_G(_1,_2,"*"),_5=_q(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),_4=_q(_5,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),_6=_G(_5,_4,"*"),_9=_G(/[A-Z]/,_4,"*"),_7=["attached","autoclosure",_G(/convention\(/,_q("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",_G(/objc\(/,_6,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],_8=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"],Me={arduino:function(e){let t,n,r,i,o,s,a,l,c,d,u,h,p,f,m,g,b=(t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),i="[a-zA-Z_]\\w*::",o="(?!struct)("+(r="decltype\\(auto\\)")+"|"+t.optional(i)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",s={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},a={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},l={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},c={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(a,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},d={className:"title",begin:t.optional(i)+e.IDENT_RE,relevance:0},u=t.optional(i)+e.IDENT_RE+"\\s*\\(",m={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:h={type:["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],keyword:["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"]},contains:(f=[p={className:"function.dispatch",relevance:0,keywords:{_hint:["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"]},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},c,s,n,e.C_BLOCK_COMMENT_MODE,l,a]).concat([{begin:/\(/,end:/\)/,keywords:h,contains:f.concat(["self"]),relevance:0}]),relevance:0},g={className:"function",begin:"("+o+"[\\*&\\s]+)+"+u,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:h,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:h,relevance:0},{begin:u,returnBegin:!0,contains:[d],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[a,l]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:h,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,a,l,s,{begin:/\(/,end:/\)/,keywords:h,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,a,l,s]}]},s,n,e.C_BLOCK_COMMENT_MODE,c]},{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:h,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(m,g,p,f,[c,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:h,contains:["self",s]},{begin:e.IDENT_RE+"::",keywords:h},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}),y=b.keywords;return y.type=[...y.type,"boolean","byte","word","String"],y.literal=[...y.literal,"DIGITAL_MESSAGE","FIRMATA_STRING","ANALOG_MESSAGE","REPORT_DIGITAL","REPORT_ANALOG","INPUT_PULLUP","SET_PIN_MODE","INTERNAL2V56","SYSTEM_RESET","LED_BUILTIN","INTERNAL1V1","SYSEX_START","INTERNAL","EXTERNAL","DEFAULT","OUTPUT","INPUT","HIGH","LOW"],y.built_in=[...y.built_in,"KeyboardController","MouseController","SoftwareSerial","EthernetServer","EthernetClient","LiquidCrystal","RobotControl","GSMVoiceCall","EthernetUDP","EsploraTFT","HttpClient","RobotMotor","WiFiClient","GSMScanner","FileSystem","Scheduler","GSMServer","YunClient","YunServer","IPAddress","GSMClient","GSMModem","Keyboard","Ethernet","Console","GSMBand","Esplora","Stepper","Process","WiFiUDP","GSM_SMS","Mailbox","USBHost","Firmata","PImage","Client","Server","GSMPIN","FileIO","Bridge","Serial","EEPROM","Stream","Mouse","Audio","Servo","File","Task","GPRS","WiFi","Wire","TFT","GSM","SPI","SD"],y._hints=["setup","loop","runShellCommandAsynchronously","analogWriteResolution","retrieveCallingNumber","printFirmwareVersion","analogReadResolution","sendDigitalPortPair","noListenOnLocalhost","readJoystickButton","setFirmwareVersion","readJoystickSwitch","scrollDisplayRight","getVoiceCallStatus","scrollDisplayLeft","writeMicroseconds","delayMicroseconds","beginTransmission","getSignalStrength","runAsynchronously","getAsynchronously","listenOnLocalhost","getCurrentCarrier","readAccelerometer","messageAvailable","sendDigitalPorts","lineFollowConfig","countryNameWrite","runShellCommand","readStringUntil","rewindDirectory","readTemperature","setClockDivider","readLightSensor","endTransmission","analogReference","detachInterrupt","countryNameRead","attachInterrupt","encryptionType","readBytesUntil","robotNameWrite","readMicrophone","robotNameRead","cityNameWrite","userNameWrite","readJoystickY","readJoystickX","mouseReleased","openNextFile","scanNetworks","noInterrupts","digitalWrite","beginSpeaker","mousePressed","isActionDone","mouseDragged","displayLogos","noAutoscroll","addParameter","remoteNumber","getModifiers","keyboardRead","userNameRead","waitContinue","processInput","parseCommand","printVersion","readNetworks","writeMessage","blinkVersion","cityNameRead","readMessage","setDataMode","parsePacket","isListening","setBitOrder","beginPacket","isDirectory","motorsWrite","drawCompass","digitalRead","clearScreen","serialEvent","rightToLeft","setTextSize","leftToRight","requestFrom","keyReleased","compassRead","analogWrite","interrupts","WiFiServer","disconnect","playMelody","parseFloat","autoscroll","getPINUsed","setPINUsed","setTimeout","sendAnalog","readSlider","analogRead","beginWrite","createChar","motorsStop","keyPressed","tempoWrite","readButton","subnetMask","debugPrint","macAddress","writeGreen","randomSeed","attachGPRS","readString","sendString","remotePort","releaseAll","mouseMoved","background","getXChange","getYChange","answerCall","getResult","voiceCall","endPacket","constrain","getSocket","writeJSON","getButton","available","connected","findUntil","readBytes","exitValue","readGreen","writeBlue","startLoop","IPAddress","isPressed","sendSysex","pauseMode","gatewayIP","setCursor","getOemKey","tuneWrite","noDisplay","loadImage","switchPIN","onRequest","onReceive","changePIN","playFile","noBuffer","parseInt","overflow","checkPIN","knobRead","beginTFT","bitClear","updateIR","bitWrite","position","writeRGB","highByte","writeRed","setSpeed","readBlue","noStroke","remoteIP","transfer","shutdown","hangCall","beginSMS","endWrite","attached","maintain","noCursor","checkReg","checkPUK","shiftOut","isValid","shiftIn","pulseIn","connect","println","localIP","pinMode","getIMEI","display","noBlink","process","getBand","running","beginSD","drawBMP","lowByte","setBand","release","bitRead","prepare","pointTo","readRed","setMode","noFill","remove","listen","stroke","detach","attach","noTone","exists","buffer","height","bitSet","circle","config","cursor","random","IRread","setDNS","endSMS","getKey","micros","millis","begin","print","write","ready","flush","width","isPIN","blink","clear","press","mkdir","rmdir","close","point","yield","image","BSSID","click","delay","read","text","move","peek","beep","rect","line","open","seek","fill","size","turn","stop","home","find","step","tone","sqrt","RSSI","SSID","end","bit","tan","cos","sin","pow","map","abs","max","min","get","run","put"],b.name="Arduino",b.aliases=["ino"],b.supersetOf="cpp",b},bash:AY,c:function(e){let t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",i="[a-zA-Z_]\\w*::",o="("+r+"|"+t.optional(i)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",s={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},a={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},l={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},c={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(a,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},d={className:"title",begin:t.optional(i)+e.IDENT_RE,relevance:0},u=t.optional(i)+e.IDENT_RE+"\\s*\\(",h={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},p=[c,s,n,e.C_BLOCK_COMMENT_MODE,l,a],f={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:h,contains:p.concat([{begin:/\(/,end:/\)/,keywords:h,contains:p.concat(["self"]),relevance:0}]),relevance:0},m={begin:"("+o+"[\\*&\\s]+)+"+u,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:h,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:h,relevance:0},{begin:u,returnBegin:!0,contains:[e.inherit(d,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:h,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,a,l,s,{begin:/\(/,end:/\)/,keywords:h,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,a,l,s]}]},s,n,e.C_BLOCK_COMMENT_MODE,c]};return{name:"C",aliases:["h"],keywords:h,disableAutodetect:!0,illegal:"</",contains:[].concat(f,m,p,[c,{begin:e.IDENT_RE+"::",keywords:h},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},e.TITLE_MODE]}]),exports:{preprocessor:c,strings:a,keywords:h}}},cpp:function(e){let t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",i="[a-zA-Z_]\\w*::",o="(?!struct)("+r+"|"+t.optional(i)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",s={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},a={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},l={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},c={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(a,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},d={className:"title",begin:t.optional(i)+e.IDENT_RE,relevance:0},u=t.optional(i)+e.IDENT_RE+"\\s*\\(",h={type:["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],keyword:["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"]},p={className:"function.dispatch",relevance:0,keywords:{_hint:["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"]},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},f=[p,c,s,n,e.C_BLOCK_COMMENT_MODE,l,a],m={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:h,contains:f.concat([{begin:/\(/,end:/\)/,keywords:h,contains:f.concat(["self"]),relevance:0}]),relevance:0},g={className:"function",begin:"("+o+"[\\*&\\s]+)+"+u,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:h,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:h,relevance:0},{begin:u,returnBegin:!0,contains:[d],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[a,l]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:h,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,a,l,s,{begin:/\(/,end:/\)/,keywords:h,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,a,l,s]}]},s,n,e.C_BLOCK_COMMENT_MODE,c]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:h,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(m,g,p,f,[c,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:h,contains:["self",s]},{begin:e.IDENT_RE+"::",keywords:h},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}},csharp:function(e){let t={keyword:["abstract","as","base","break","case","catch","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","scoped","sealed","sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"].concat(["add","alias","and","ascending","args","async","await","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value|0","var","when","where","with","yield"]),built_in:["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],literal:["default","false","null","true"]},n=e.inherit(e.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),r={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},i={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},o=e.inherit(i,{illegal:/\n/}),s={className:"subst",begin:/\{/,end:/\}/,keywords:t},a=e.inherit(s,{illegal:/\n/}),l={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},e.BACKSLASH_ESCAPE,a]},c={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},s]},d=e.inherit(c,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},a]});s.contains=[c,l,i,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,r,e.C_BLOCK_COMMENT_MODE],a.contains=[d,l,o,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,r,e.inherit(e.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];let u={variants:[{className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},c,l,i,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},h={begin:"<",end:">",contains:[{beginKeywords:"in out"},n]},p=e.IDENT_RE+"(<"+e.IDENT_RE+"(\\s*,\\s*"+e.IDENT_RE+")*>)?(\\[\\])?",f={begin:"@"+e.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:t,illegal:/::/,contains:[e.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:"<!--|-->"},{begin:"</?",end:">"}]}]}),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},u,r,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},n,h,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[n,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[n,h,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+p+"\\s+)+"+e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:t,contains:[{beginKeywords:"public private protected static internal protected abstract async extern override unsafe virtual new sealed partial",relevance:0},{begin:e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[e.TITLE_MODE,h],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:t,relevance:0,contains:[u,r,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},f]}},css:A1,diff:function(e){let t=e.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:t.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:t.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}},go:A2,graphql:function(e){let t=e.regex;return{name:"GraphQL",aliases:["gql"],case_insensitive:!0,disableAutodetect:!1,keywords:{keyword:["query","mutation","subscription","type","input","schema","directive","interface","union","scalar","fragment","enum","on"],literal:["true","false","null"]},contains:[e.HASH_COMMENT_MODE,e.QUOTE_STRING_MODE,e.NUMBER_MODE,{scope:"punctuation",match:/[.]{3}/,relevance:0},{scope:"punctuation",begin:/[\!\(\)\:\=\[\]\{\|\}]{1}/,relevance:0},{scope:"variable",begin:/\$/,end:/\W/,excludeEnd:!0,relevance:0},{scope:"meta",match:/@\w+/,excludeEnd:!0},{scope:"symbol",begin:t.concat(/[_A-Za-z][_0-9A-Za-z]*/,t.lookahead(/\s*:/)),relevance:0}],illegal:[/[;<']/,/BEGIN/]}},ini:function(e){let t=e.regex,n={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:e.NUMBER_RE}]},r=e.COMMENT();r.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];let i={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},o={className:"literal",begin:/\bon|off|true|false|yes|no\b/},s={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},a=t.either(/[A-Za-z0-9_-]+/,/"(\\"|[^"])*"/,/'[^']*'/);return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[r,{className:"section",begin:/\[+/,end:/\]+/},{begin:t.concat(a,"(\\s*\\.\\s*",a,")*",t.lookahead(/\s*=\s*[^#\s]/)),className:"attr",starts:{end:/$/,contains:[r,{begin:/\[/,end:/\]/,contains:[r,o,i,s,n,"self"],relevance:0},o,i,s,n]}}]}},java:function(e){let t=e.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=n+function e(t,n,r){return -1===r?"":t.replace(n,i=>e(t,n,r-1))}("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),i={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},o={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},s={className:"params",begin:/\(/,end:/\)/,keywords:i,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:i,illegal:/<\/|#/,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[e.BACKSLASH_ESCAPE]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[t.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[s,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+r+"\\s+)",e.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:i,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:i,relevance:0,contains:[o,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,_A,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},_A,o]}},javascript:St,json:Sn,kotlin:function(e){let t={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},n={className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"@"},r={className:"subst",begin:/\$\{/,end:/\}/,contains:[e.C_NUMBER_MODE]},i={className:"variable",begin:"\\$"+e.UNDERSCORE_IDENT_RE},o={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[i,r]},{begin:"'",end:"'",illegal:/\n/,contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[e.BACKSLASH_ESCAPE,i,r]}]};r.contains.push(o);let s={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+e.UNDERSCORE_IDENT_RE+")?"},a={className:"meta",begin:"@"+e.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[e.inherit(o,{className:"string"}),"self"]}]},l=e.COMMENT("/\\*","\\*/",{contains:[e.C_BLOCK_COMMENT_MODE]}),c={variants:[{className:"type",begin:e.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]};return c.variants[1].contains=[c],c.variants[1].contains=[c],{name:"Kotlin",aliases:["kt","kts"],keywords:t,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),e.C_LINE_COMMENT_MODE,l,{className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},n,s,a,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:t,relevance:5,contains:[{begin:e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[e.UNDERSCORE_TITLE_MODE]},{className:"type",begin:/</,end:/>/,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:t,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[c,e.C_LINE_COMMENT_MODE,l],relevance:0},e.C_LINE_COMMENT_MODE,l,s,a,o,e.C_NUMBER_MODE]},l]},{begin:[/class|interface|trait/,/\s+/,e.UNDERSCORE_IDENT_RE],beginScope:{3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},e.UNDERSCORE_TITLE_MODE,{className:"type",begin:/</,end:/>/,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},s,a]},o,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:"\n"},_M]}},less:function(e){let t={IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}},n="[\\w-]+",r="("+n+"|@\\{"+n+"\\})",i=[],o=[],s=function(e){return{className:"string",begin:"~?"+e+".*?"+e}},a=function(e,t,n){return{className:e,begin:t,relevance:n}},l={$pattern:/[a-z-]+/,keyword:"and or not only",attribute:_I.join(" ")};o.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,s("'"),s('"'),t.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},t.HEXCOLOR,{begin:"\\(",end:"\\)",contains:o,keywords:l,relevance:0},a("variable","@@?"+n,10),a("variable","@\\{"+n+"\\}"),a("built_in","~?`[^`]*?`"),{className:"attribute",begin:n+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},t.IMPORTANT,{beginKeywords:"and not"},t.FUNCTION_DISPATCH);let c=o.concat({begin:/\{/,end:/\}/,contains:i}),d={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(o)},u={begin:r+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+_L.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:o}}]},h={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:r,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:"[<='$\"]",relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,d,a("keyword","all\\b"),a("variable","@\\{"+n+"\\}"),{begin:"\\b("+_O.join("|")+")\\b",className:"selector-tag"},t.CSS_NUMBER_MODE,a("selector-tag",r,0),a("selector-id","#"+r),a("selector-class","\\."+r,0),a("selector-tag","&",0),t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+_D.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+_R.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:c},{begin:"!important"},t.FUNCTION_DISPATCH]},p={begin:n+":(:)?"+`(${_P.join("|")})`,returnBegin:!0,contains:[h]};return i.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:l,returnEnd:!0,contains:o,relevance:0}},{className:"variable",variants:[{begin:"@"+n+"\\s*:",relevance:15},{begin:"@"+n}],starts:{end:"[;}]",returnEnd:!0,contains:c}},p,u,h,d,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:"[=>'/<($\"]",contains:i}},lua:function(e){let t="\\[=*\\[",n="\\]=*\\]",r={begin:t,end:n,contains:["self"]},i=[e.COMMENT("--(?!"+t+")","$"),e.COMMENT("--"+t,n,{contains:[r],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:e.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:i.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[e.inherit(e.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:i}].concat(i)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:t,end:n,contains:[r],relevance:5}])}},makefile:function(e){let t={className:"variable",variants:[{begin:"\\$\\("+e.UNDERSCORE_IDENT_RE+"\\)",contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},n={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,t]},r={begin:"^"+e.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"};return{name:"Makefile",aliases:["mk","mak","make"],keywords:{$pattern:/[\w-]+/,keyword:"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath"},contains:[e.HASH_COMMENT_MODE,t,n,{className:"variable",begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value"},contains:[t,n]},r,{className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},{className:"section",begin:/^[^\s]+:/,end:/$/,contains:[t]}]}},markdown:Sr,objectivec:function(e){let t=/[a-zA-Z@][a-zA-Z0-9_]*/,n={$pattern:t,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:{"variable.language":["this","super"],$pattern:t,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},illegal:"</",contains:[{className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.C_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]}]},{className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+n.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:n,contains:[e.UNDERSCORE_TITLE_MODE]},{begin:"\\."+e.UNDERSCORE_IDENT_RE,relevance:0}]}},perl:function(e){let t=e.regex,n=/[dualxmsipngr]{0,12}/,r={$pattern:/[\w.]+/,keyword:"abs accept alarm and atan2 bind binmode bless break caller chdir chmod chomp chop chown chr chroot class close closedir connect continue cos crypt dbmclose dbmopen defined delete die do dump each else elsif endgrent endhostent endnetent endprotoent endpwent endservent eof eval exec exists exit exp fcntl field fileno flock for foreach fork format formline getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr getnetbyname getnetent getpeername getpgrp getpriority getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport getservent getsockname getsockopt given glob gmtime goto grep gt hex if index int ioctl join keys kill last lc lcfirst length link listen local localtime log lstat lt ma map method mkdir msgctl msgget msgrcv msgsnd my ne next no not oct open opendir or ord our pack package pipe pop pos print printf prototype push q|0 qq quotemeta qw qx rand read readdir readline readlink readpipe recv redo ref rename require reset return reverse rewinddir rindex rmdir say scalar seek seekdir select semctl semget semop send setgrent sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split sprintf sqrt srand stat state study sub substr symlink syscall sysopen sysread sysseek system syswrite tell telldir tie tied time times tr truncate uc ucfirst umask undef unless unlink unpack unshift untie until use utime values vec wait waitpid wantarray warn when while write x|0 xor y|0"},i={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:r},o={begin:/->\{/,end:/\}/},s={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},a={scope:"variable",variants:[{begin:/\$\d/},{begin:t.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[s]},l={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},c=[e.BACKSLASH_ESCAPE,i,a],d=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],u=(e,r,i="\\1")=>{let o="\\1"===i?i:t.concat(i,r);return t.concat(t.concat("(?:",e,")"),r,/(?:\\.|[^\\\/])*?/,o,/(?:\\.|[^\\\/])*?/,i,n)},h=(e,r,i)=>t.concat(t.concat("(?:",e,")"),r,/(?:\\.|[^\\\/])*?/,i,n),p=[a,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),o,{className:"string",contains:c,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},l,{begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[e.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:u("s|tr|y",t.either(...d,{capture:!0}))},{begin:u("s|tr|y","\\(","\\)")},{begin:u("s|tr|y","\\[","\\]")},{begin:u("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:h("(?:m|qr)?",/\//,/\//)},{begin:h("m|qr",t.either(...d,{capture:!0}),/\1/)},{begin:h("m|qr",/\(/,/\)/)},{begin:h("m|qr",/\[/,/\]/)},{begin:h("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,s]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,s,l]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return i.contains=p,o.contains=p,{name:"Perl",aliases:["pl","pm"],keywords:r,contains:p}},php:function(e){let t,n=e.regex,r=/(?![A-Za-z0-9])(?![$])/,i=n.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,r),o=n.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,r),s=n.concat(/[A-Z]+/,r),a={scope:"variable",match:"\\$+"+i},l={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},c=e.inherit(e.APOS_STRING_MODE,{illegal:null}),d=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(l)}),u={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(l),"on:begin":(e,t)=>{t.data._beginMatch=e[1]||e[2]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}},h=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),p="[ \n]",f={scope:"string",variants:[d,c,u,h]},m={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},g=["false","null","true"],b=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],y=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],x={keyword:b,literal:(t=[],g.forEach(e=>{t.push(e),e.toLowerCase()===e?t.push(e.toUpperCase()):t.push(e.toLowerCase())}),t),built_in:y},v=e=>e.map(e=>e.replace(/\|\d+$/,"")),E={variants:[{match:[/new/,n.concat(p,"+"),n.concat("(?!",v(y).join("\\b|"),"\\b)"),o],scope:{1:"keyword",4:"title.class"}}]},w=n.concat(i,"\\b(?!\\()"),k={variants:[{match:[n.concat(/::/,n.lookahead(/(?!class\b)/)),w],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[o,n.concat(/::/,n.lookahead(/(?!class\b)/)),w],scope:{1:"title.class",3:"variable.constant"}},{match:[o,n.concat("::",n.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[o,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},T={scope:"attr",match:n.concat(i,n.lookahead(":"),n.lookahead(/(?!::)/))},N={relevance:0,begin:/\(/,end:/\)/,keywords:x,contains:[T,a,k,e.C_BLOCK_COMMENT_MODE,f,m,E]},A={relevance:0,match:[/\b/,n.concat("(?!fn\\b|function\\b|",v(b).join("\\b|"),"|",v(y).join("\\b|"),"\\b)"),i,n.concat(p,"*"),n.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[N]};N.contains.push(A);let S=[T,k,e.C_BLOCK_COMMENT_MODE,f,m,E],C={begin:n.concat(/#\[\s*\\?/,n.either(o,s)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:g,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:g,keyword:["new","array"]},contains:["self",...S]},...S,{scope:"meta",variants:[{match:o},{match:s}]}]};return{case_insensitive:!1,keywords:x,contains:[C,e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},{scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},{scope:"variable.language",match:/\$this\b/},a,A,k,{match:[/const/,/\s/,i],scope:{1:"keyword",3:"variable.constant"}},E,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:x,contains:["self",C,a,k,e.C_BLOCK_COMMENT_MODE,f,m]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},f,m]}},"php-template":function(e){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},e.inherit(e.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}},plaintext:function(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}},python:Si,"python-repl":function(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}},r:function(e){let t=e.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,r=t.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),i=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,o=t.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:n,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:t.lookahead(t.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:n},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[i,r]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,r]},{scope:{1:"punctuation",2:"number"},match:[o,r]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,r]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:i},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:o},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}},ruby:function(e){let t=e.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",r=t.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),i=t.concat(r,/(::\w+)*/),o={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield","include","extend","prepend","public","private","protected","raise","throw"],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},s={className:"doctag",begin:"@[A-Za-z]+"},a={begin:"#<",end:">"},l=[e.COMMENT("#","$",{contains:[s]}),e.COMMENT("^=begin","^=end",{contains:[s],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],c={className:"subst",begin:/#\{/,end:/\}/,keywords:o},d={className:"string",contains:[e.BACKSLASH_ESCAPE,c],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:t.concat(/<<[-~]?'?/,t.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,c]})]}]},u="[0-9](_?[0-9])*",h={className:"number",relevance:0,variants:[{begin:`\\b([1-9](_?[0-9])*|0)(\\.(${u}))?([eE][+-]?(${u})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},p={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:o}]},f=[d,{variants:[{match:[/class\s+/,i,/\s+<\s+/,i]},{match:[/\b(class|module)\s+/,i]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:o},{match:[/(include|extend)\s+/,i],scope:{2:"title.class"},keywords:o},{relevance:0,match:[i,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:r,scope:"title.class"},{match:[/def/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[p]},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[d,{begin:n}],relevance:0},h,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:o},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,c],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(a,l),relevance:0}].concat(a,l);c.contains=f,p.contains=f;let m=[{begin:/^\s*=>/,starts:{end:"$",contains:f}},{className:"meta.prompt",begin:"^([>?]>|[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]|(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>)(?=[ ])",starts:{end:"$",keywords:o,contains:f}}];return l.unshift(a),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:o,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(m).concat(l).concat(f)}},rust:So,scss:function(e){let t={IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}},n="@[a-z-]+",r={className:"variable",begin:"(\\$[a-zA-Z-][a-zA-Z0-9_-]*)\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,t.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+_j.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+_F.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+_H.join("|")+")"},r,{begin:/\(/,end:/\)/,contains:[t.CSS_NUMBER_MODE]},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+_U.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[t.BLOCK_COMMENT,r,t.HEXCOLOR,t.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.IMPORTANT,t.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:n,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:"and or not only",attribute:_B.join(" ")},contains:[{begin:n,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},r,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.HEXCOLOR,t.CSS_NUMBER_MODE]},t.FUNCTION_DISPATCH]}},shell:Ss,sql:Sa,swift:function(e){let t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[e.C_LINE_COMMENT_MODE,n],i={match:[/\./,_q(..._W,..._K)],className:{2:"keyword"}},o={match:_G(/\./,_q(..._X)),relevance:0},s=_X.filter(e=>"string"==typeof e).concat(["_|0"]),a={variants:[{className:"keyword",match:_q(..._X.filter(e=>"string"!=typeof e).concat(_Y).map(_V),..._K)}]},l={$pattern:_q(/\b\w+/,/#\w+/),keyword:s.concat(_Z),literal:_Q},c=[i,o,a],d=[{match:_G(/\./,_q(..._0)),relevance:0},{className:"built_in",match:_G(/\b/,_q(..._0),/(?=\()/)}],u={match:/->/,relevance:0},h=[u,{className:"operator",relevance:0,variants:[{match:_3},{match:`\\.(\\.|${_2})+`}]}],p="([0-9]_*)+",f="([0-9a-fA-F]_*)+",m={className:"number",relevance:0,variants:[{match:`\\b(${p})(\\.(${p}))?([eE][+-]?(${p}))?\\b`},{match:`\\b0x(${f})(\\.(${f}))?([pP][+-]?(${p}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},g=(e="")=>({className:"subst",variants:[{match:_G(/\\/,e,/[0\\tnr"']/)},{match:_G(/\\/,e,/u\{[0-9a-fA-F]{1,8}\}/)}]}),b=(e="")=>({className:"subst",label:"interpol",begin:_G(/\\/,e,/\(/),end:/\)/}),y=(e="")=>({begin:_G(e,/"""/),end:_G(/"""/,e),contains:[g(e),((e="")=>({className:"subst",match:_G(/\\/,e,/[\t ]*(?:[\r\n]|\r\n)/)}))(e),b(e)]}),x=(e="")=>({begin:_G(e,/"/),end:_G(/"/,e),contains:[g(e),b(e)]}),v={className:"string",variants:[y(),y("#"),y("##"),y("###"),x(),x("#"),x("##"),x("###")]},E=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],w=e=>{let t=_G(e,/\//),n=_G(/\//,e);return{begin:t,end:n,contains:[...E,{scope:"comment",begin:`#(?!.*${n})`,end:/$/}]}},k={scope:"regexp",variants:[w("###"),w("##"),w("#"),{begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:E}]},T={match:_G(/`/,_6,/`/)},N=[T,{className:"variable",match:/\$\d+/},{className:"variable",match:`\\$${_4}+`}],A=[{match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:_8,contains:[...h,m,v]}]}},{scope:"keyword",match:_G(/@/,_q(..._7),_$(_q(/\(/,/\s+/)))},{scope:"meta",match:_G(/@/,_6)}],S={match:_$(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:_G(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,_4,"+")},{className:"type",match:_9,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:_G(/\s+&\s+/,_$(_9)),relevance:0}]},C={begin:/</,end:/>/,keywords:l,contains:[...r,...c,...A,u,S]};S.contains.push(C);let _={begin:/\(/,end:/\)/,relevance:0,keywords:l,contains:["self",{match:_G(_6,/\s*:/),keywords:"_|0",relevance:0},...r,k,...c,...d,...h,m,v,...N,...A,S]},M={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,S]},O={begin:/\(/,end:/\)/,keywords:l,contains:[{begin:_q(_$(_G(_6,/\s*:/)),_$(_G(_6,/\s+/,_6,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:_6}]},...r,...c,...h,m,v,...A,S,_],endsParent:!0,illegal:/["']/},I={match:[/(func|macro)/,/\s+/,_q(T.match,_6,_3)],className:{1:"keyword",3:"title.function"},contains:[M,O,t],illegal:[/\[/,/%/]},D={begin:[/precedencegroup/,/\s+/,_9],className:{1:"keyword",3:"title"},contains:[S],keywords:[..._J,..._Q],end:/}/},R={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,_6,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:l,contains:[M,...c,{begin:/:/,end:/\{/,keywords:l,contains:[{scope:"title.class.inherited",match:_9},...c],relevance:0}]};for(let e of v.variants){let t=e.contains.find(e=>"interpol"===e.label);t.keywords=l;let n=[...c,...d,...h,m,v,...N];t.contains=[...n,{begin:/\(/,end:/\)/,contains:["self",...n]}]}return{name:"Swift",keywords:l,contains:[...r,I,{match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[M,O,t],illegal:/\[|%/},{match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},{match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},R,{match:[/operator/,/\s+/,_3],className:{1:"keyword",3:"title"}},D,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},k,...c,...d,...h,m,v,...N,...A,S,_]}},typescript:Sg,vbnet:function(e){let t=e.regex,n=/\d{1,2}\/\d{1,2}\/\d{4}/,r=/\d{4}-\d{1,2}-\d{1,2}/,i=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,o=/\d{1,2}(:\d{1,2}){1,2}/,s={className:"literal",variants:[{begin:t.concat(/# */,t.either(r,n),/ *#/)},{begin:t.concat(/# */,o,/ *#/)},{begin:t.concat(/# */,i,/ *#/)},{begin:t.concat(/# */,t.either(r,n),/ +/,t.either(i,o),/ *#/)}]},a=e.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),l=e.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[{className:"string",begin:/"(""|[^/n])"C\b/},{className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},s,{className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},{className:"label",begin:/^\w+:/},a,l,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[l]}]}},wasm:function(e){e.regex;let t=e.COMMENT(/\(;/,/;\)/);return t.contains.push("self"),{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"]},contains:[e.COMMENT(/;;/,/$/),t,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},{className:"variable",begin:/\$[\w_]+/},{match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},{begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},e.QUOTE_STRING_MODE,{match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},{className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/},{className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/}]}},xml:Sb,yaml:Sy},Mt=Sv(Me);function Mn(e){return Array.isArray(e)?e.join(""):e??""}let Mr=/\x1b\[[0-9;]*[A-Za-z]/g;function Mi(e){return e.replace(Mr,"")}function Mo({output:e}){if("stream"===e.output_type){let t=Mi(Mn(e.text)),n="stderr"===e.name;return(0,X.jsx)("pre",{className:`whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md ${n?"bg-[rgba(139,46,62,0.06)] text-[#8B2E3E]":"bg-[#F5EEDC] text-[#2A221B]"}`,children:t})}if("error"===e.output_type){let t=e.traceback.map(Mi).join("\n");return(0,X.jsxs)("pre",{className:"whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md bg-[rgba(139,46,62,0.08)] text-[#8B2E3E] border border-[rgba(139,46,62,0.18)]",children:[(0,X.jsxs)("span",{className:"font-semibold",children:[e.ename,": ",e.evalue]}),t?`
|
|
114
114
|
|
|
115
|
-
${t}`:""]})}let t=e.data||{};if(t["image/png"]){let e=`data:image/png;base64,${Mn(t["image/png"]).replace(/\s/g,"")}`;return(0,X.jsx)("img",{src:e,alt:"output",className:"max-w-full rounded-md bg-card p-2"})}if(t["image/jpeg"]){let e=`data:image/jpeg;base64,${Mn(t["image/jpeg"]).replace(/\s/g,"")}`;return(0,X.jsx)("img",{src:e,alt:"output",className:"max-w-full rounded-md bg-card p-2"})}if(t["image/svg+xml"]){let e=Mn(t["image/svg+xml"]);return(0,X.jsx)("div",{className:"max-w-full rounded-md bg-card p-2 overflow-auto",dangerouslySetInnerHTML:{__html:e}})}if(t["text/html"]){let e=Mn(t["text/html"]);return(0,X.jsx)("iframe",{srcDoc:`<!doctype html><html><head><base target="_blank"><style>body{margin:0;padding:8px;font-family:-apple-system,BlinkMacSystemFont,Inter,system-ui,sans-serif;background:#FFF9E9;color:#2A221B;font-size:13px}table{border-collapse:collapse}th,td{border:1px solid #D4C4B0;padding:4px 8px;text-align:left}thead{background:#EFE5CC}</style></head><body>${e}</body></html>`,sandbox:"allow-scripts",className:"w-full bg-[#FFF9E9] rounded-md border border-[#E8DDC5]",style:{height:360}})}return t["text/plain"]?(0,X.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md bg-[#F5EEDC] text-[#2A221B]",children:Mi(Mn(t["text/plain"]))}):null}function Ms({cell:e,language:t}){let n=Mn(e.source),r=(0,Q.useMemo)(()=>(function(e,t){try{let n=t?Mt.highlight(t,e):Mt.highlightAuto(e);return bl(n)}catch{return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}})(n,t),[n,t]),i=e.execution_count??" ",o=(e.outputs?.length??0)>0;return(0,X.jsxs)("div",{className:"grid grid-cols-[60px_1fr] gap-3 mb-5",children:[(0,X.jsxs)("div",{className:"text-right pt-3 select-none font-mono text-[11px] text-[#8B5E3C]",children:["In [",i,"]:"]}),(0,X.jsxs)("div",{children:[(0,X.jsx)("pre",{className:"whitespace-pre overflow-x-auto font-mono text-[13px] leading-relaxed px-4 py-3 rounded-md bg-[#FFF9E9] border border-[#E8DDC5] text-[#2A221B]",children:(0,X.jsx)("code",{dangerouslySetInnerHTML:{__html:r}})}),o&&(0,X.jsxs)("div",{className:"mt-2 grid grid-cols-[60px_1fr] gap-3",children:[(0,X.jsxs)("div",{className:"text-right pt-3 select-none font-mono text-[11px] text-[#8B2E3E]",children:["Out[",i,"]:"]}),(0,X.jsx)("div",{className:"space-y-2",children:e.outputs?.map((e,t)=>(0,X.jsx)(Mo,{output:e},t))})]})]})]})}function Ma({cell:e}){let[t,n]=(0,Q.useState)("");return(0,Q.useEffect)(()=>{let t=!1;return vg(Mn(e.source)).then(e=>{t||n(e)}),()=>{t=!0}},[e.source]),(0,X.jsx)("div",{className:"prose prose-sm max-w-none mb-5 px-1 [&_h1]:font-serif [&_h2]:font-serif [&_h3]:font-serif [&_a]:text-[#8B5E3C] [&_a:hover]:underline [&_code]:bg-[#F5EEDC] [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:rounded [&_code]:text-[#8B2E3E]",dangerouslySetInnerHTML:{__html:t}})}function Ml({cell:e}){return(0,X.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md bg-[#F5EEDC] text-[#2A221B] mb-5",children:Mn(e.source)})}function Mc({path:e}){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!0),[o,s]=(0,Q.useState)(null),[a,l]=(0,Q.useState)(!1),c=`/api/assets/${e}`,d=e.split("/").pop()||e,u=(0,Q.useCallback)(async()=>{i(!0),s(null);try{let e=await fetch(c);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();n(t)}catch(e){s(e instanceof Error?e.message:"Failed to load notebook")}finally{i(!1)}},[c]);(0,Q.useEffect)(()=>{u()},[u]);let h=t?.metadata?.language_info?.name||t?.metadata?.kernelspec?.name||"python",p=t?.cells?.length??0,f=t?.cells?.filter(e=>"code"===e.cell_type).length??0,m=t?.cells?.some(e=>"code"===e.cell_type&&(e.outputs?.length??0)>0)??!1;return(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,X.jsxs)(rF,{path:e,badge:"IPYNB",sublabel:`${p} cells \xb7 ${f} code \xb7 ${h}`,children:[(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{navigator.clipboard.writeText(`jupyter lab ${e}`),l(!0),setTimeout(()=>l(!1),2e3)},title:"Copy: jupyter lab <path>",children:[a?(0,X.jsx)(eo,{className:"h-3.5 w-3.5 text-green-500"}):(0,X.jsx)(_b,{className:"h-3.5 w-3.5"}),a?"Copied":"Copy run cmd"]}),(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let e=document.createElement("a");e.href=c,e.download=d,e.click()},children:[(0,X.jsx)(rj,{className:"h-3.5 w-3.5"}),"Download"]}),(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(c,"_blank"),children:[(0,X.jsx)(kr,{className:"h-3.5 w-3.5"}),"Raw JSON"]})]}),(0,X.jsx)("div",{className:"flex-1 overflow-auto bg-[#F5EEDC]",children:r?(0,X.jsx)("div",{className:"flex items-center justify-center h-full text-[#7A6B5D] text-sm",children:"Loading notebook…"}):o?(0,X.jsxs)("div",{className:"flex items-center justify-center h-full text-[#8B2E3E] text-sm gap-2",children:[(0,X.jsx)(er,{className:"h-4 w-4"})," ",o]}):t?(0,X.jsxs)("div",{className:"max-w-[1100px] mx-auto py-8 px-6",children:[!m&&f>0&&(0,X.jsxs)("div",{className:"mb-6 rounded-md border border-[#E8DDC5] bg-[#FFF9E9] px-4 py-3 text-[13px] text-[#7A6B5D]",children:[(0,X.jsx)("span",{className:"font-semibold text-[#0c0a09]",children:"This notebook hasn't been run yet."})," ","Code and markdown cells display below; outputs appear once the author runs the notebook in Jupyter (or you do, then re-save)."]}),t.cells?.map((e,t)=>"markdown"===e.cell_type?(0,X.jsx)(Ma,{cell:e},t):"raw"===e.cell_type?(0,X.jsx)(Ml,{cell:e},t):(0,X.jsx)(Ms,{cell:e,language:h},t))]}):null})]})}function Md({path:e,extLabel:t,external:n,hideFinder:r}){let i=`/api/assets/${e}`,o=e.split("/").pop()||e,s=async()=>{try{await fetch("/api/system/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})})}catch{}};return(0,X.jsxs)(rF,{path:e,badge:t||void 0,children:[n&&(0,X.jsxs)("a",{href:n.href,target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-center gap-1.5 text-[11px] h-7 px-2.5 rounded-md border border-border hover:bg-accent transition-colors",children:[(0,X.jsx)(kr,{className:"h-3.5 w-3.5"}),n.label]}),!r&&(0,X.jsxs)(tG,{variant:"outline",size:"sm",className:"gap-1.5 text-[11px] h-7",onClick:s,title:"Open in Finder",children:[(0,X.jsx)(eh,{className:"h-3.5 w-3.5"}),"Reveal"]}),!r&&(0,X.jsxs)(tG,{variant:"outline",size:"sm",className:"gap-1.5 text-[11px] h-7",onClick:()=>{let e=document.createElement("a");e.href=i,e.download=o,e.click()},title:"Download original",children:[(0,X.jsx)(rj,{className:"h-3.5 w-3.5"}),"Download"]})]})}function Mu({path:t,title:n}){let r=(0,Q.useRef)(null),[i,o]=(0,Q.useState)(!0),[s,a]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{let n=!1,i=r.current;if(i)return i.innerHTML="",(async()=>{o(!0),a(null);try{let[{renderAsync:r},s]=await Promise.all([e.A(410052),fetch(`/api/assets/${t}`)]);if(n)return;if(!s.ok)throw Error(`Failed to load file (${s.status})`);let a=await s.blob();if(n)return;await r(a,i,void 0,{className:"docx-rendered",inWrapper:!0,ignoreWidth:!1,ignoreHeight:!1,breakPages:!0,renderHeaders:!0,renderFooters:!0,renderFootnotes:!0,experimental:!0,useBase64URL:!0}),n||o(!1)}catch(e){n||(a(e instanceof Error?e.message:"Failed to render document"),o(!1))}})(),()=>{n=!0}},[t]),(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,X.jsx)(Md,{path:t,title:n,extLabel:"DOCX"}),(0,X.jsxs)("div",{className:"flex-1 overflow-y-auto bg-muted/30",children:[i&&!s&&(0,X.jsxs)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:[(0,X.jsx)(eg,{className:"h-5 w-5 animate-spin mr-2"}),"Rendering document…"]}),s&&(0,X.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,X.jsxs)("div",{className:"text-center space-y-2",children:[(0,X.jsx)("p",{className:"text-sm text-destructive",children:s}),(0,X.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try downloading the file and opening it externally."})]})}),(0,X.jsx)("div",{ref:r,className:"docx-viewer-body mx-auto max-w-5xl py-6 px-4"})]})]})}function Mh({path:t,title:n}){let r=(0,Q.useRef)(null),[i,o]=(0,Q.useState)(!0),[s,a]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{let n=!1,i=r.current;if(!i)return;i.innerHTML="";let s=null;return(async()=>{o(!0),a(null);try{let[{init:r},a]=await Promise.all([e.A(355350),fetch(`/api/assets/${t}`)]);if(n)return;if(!a.ok)throw Error(`Failed to load file (${a.status})`);let l=await a.arrayBuffer();if(n)return;let c=i.clientWidth||960,d=Math.round(9*c/16);s=r(i,{width:c,height:d,mode:"list"}),await s.preview(l),n||o(!1)}catch(e){n||(a(e instanceof Error?e.message:"Failed to render presentation"),o(!1))}})(),()=>{n=!0;try{s?.destroy?.()}catch{}}},[t]),(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,X.jsx)(Md,{path:t,title:n,extLabel:"PPTX"}),(0,X.jsxs)("div",{className:"flex-1 overflow-auto bg-muted/30 py-4",children:[i&&!s&&(0,X.jsxs)("div",{className:"h-[60vh] flex items-center justify-center text-muted-foreground",children:[(0,X.jsx)(eg,{className:"h-5 w-5 animate-spin mr-2"}),"Rendering slides…"]}),s&&(0,X.jsx)("div",{className:"h-[60vh] flex items-center justify-center",children:(0,X.jsxs)("div",{className:"text-center space-y-2",children:[(0,X.jsx)("p",{className:"text-sm text-destructive",children:s}),(0,X.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try downloading the file and opening it externally."})]})}),(0,X.jsx)("div",{ref:r,className:"pptx-viewer-body mx-auto max-w-5xl px-4"})]})]})}function Mp({path:t,title:n}){let[r,i]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(0),[a,l]=(0,Q.useState)(!0),[c,d]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let n=!1;return l(!0),d(null),i(null),(async()=>{try{let[r,o]=await Promise.all([e.A(432302),fetch(`/api/assets/${t}`)]);if(n)return;if(!o.ok)throw Error(`Failed to load file (${o.status})`);let a=await o.arrayBuffer();if(n)return;let c=r.read(a,{type:"array",cellDates:!0,cellStyles:!0}),d=c.SheetNames.map(e=>({name:e,html:r.utils.sheet_to_html(c.Sheets[e],{editable:!1})}));if(n)return;i(d),s(0),l(!1)}catch(e){n||(d(e instanceof Error?e.message:"Failed to parse spreadsheet"),l(!1))}})(),()=>{n=!0}},[t]);let u=(0,Q.useMemo)(()=>r?.[o]??null,[r,o]);return(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,X.jsx)(Md,{path:t,title:n,extLabel:"XLSX"}),r&&r.length>1&&(0,X.jsx)("div",{className:"flex items-center gap-0.5 border-b border-border bg-muted/40 px-2 overflow-x-auto scrollbar-none",children:r.map((e,t)=>(0,X.jsx)("button",{type:"button",onClick:()=>s(t),className:tz("px-3 py-1.5 text-[12px] rounded-t whitespace-nowrap transition-colors",t===o?"bg-background text-foreground font-medium border-t border-x border-border -mb-px":"text-muted-foreground hover:text-foreground"),children:e.name},e.name+t))}),(0,X.jsxs)("div",{className:"flex-1 overflow-auto",children:[a&&!c&&(0,X.jsxs)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:[(0,X.jsx)(eg,{className:"h-5 w-5 animate-spin mr-2"}),"Parsing spreadsheet…"]}),c&&(0,X.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,X.jsxs)("div",{className:"text-center space-y-2",children:[(0,X.jsx)("p",{className:"text-sm text-destructive",children:c}),(0,X.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try downloading the file and opening it externally."})]})}),u&&(0,X.jsx)("div",{className:"xlsx-sheet p-3 text-[12px]",dangerouslySetInnerHTML:{__html:u.html}})]})]})}function Mf({path:e,title:t}){let n=`/api/assets/${e}`;return(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,X.jsx)(rF,{path:e,badge:"PDF",children:(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(n,"_blank"),children:[(0,X.jsx)(kr,{className:"h-3.5 w-3.5"}),"Open in new tab"]})}),(0,X.jsx)("iframe",{src:n,className:"flex-1 w-full border-0",title:t})]})}let Mm=en("wrap-text",[["path",{d:"m16 16-2 2 2 2",key:"kkc6pm"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["path",{d:"M3 18h7",key:"sq21v6"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]),Mg=Sv(Me),Mb={".js":"javascript",".cjs":"javascript",".mjs":"javascript",".ts":"typescript",".tsx":"typescript",".jsx":"javascript",".py":"python",".rb":"ruby",".php":"php",".sh":"bash",".bash":"bash",".zsh":"bash",".ps1":"powershell",".css":"css",".scss":"scss",".html":"xml",".json":"json",".jsonc":"json",".yaml":"yaml",".yml":"yaml",".toml":"ini",".ini":"ini",".xml":"xml",".sql":"sql",".graphql":"graphql",".gql":"graphql",".go":"go",".rs":"rust",".swift":"swift",".java":"java",".kt":"kotlin",".kts":"kotlin",".c":"c",".cpp":"cpp",".h":"c",".env":"bash",".txt":"",".text":"",".log":"",".rst":"",".mdx":"markdown"};function My({path:e}){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!0),[o,s]=(0,Q.useState)(!1),[a,l]=(0,Q.useState)(!1),c=`/api/assets/${e}`,d=e.split("/").pop()||e,u=Mb[d.includes(".")?`.${d.split(".").pop()?.toLowerCase()}`:""]??"",h=(0,Q.useCallback)(async()=>{i(!0);try{let e=await fetch(c);if(e.ok){let t=await e.text();n(t)}}catch{}finally{i(!1)}},[c]);(0,Q.useEffect)(()=>{h()},[h]);let p=(0,Q.useMemo)(()=>{if(!t)return[];try{let e=u?Mg.highlight(u,t):Mg.highlightAuto(t);return bl(e).split("\n")}catch{return t.split("\n").map(e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"))}},[t,u]);return(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,X.jsxs)(rF,{path:e,badge:d.includes(".")?d.split(".").pop()?.toUpperCase()??"TEXT":"TEXT",sublabel:u||void 0,children:[(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:`h-7 gap-1.5 text-xs ${o?"bg-muted":""}`,onClick:()=>s(e=>!e),title:o?"Disable line wrap":"Enable line wrap",children:[(0,X.jsx)(Mm,{className:"h-3.5 w-3.5"}),"Wrap"]}),(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{t&&(navigator.clipboard.writeText(t),l(!0),setTimeout(()=>l(!1),2e3))},title:"Copy file contents",children:[a?(0,X.jsx)(eo,{className:"h-3.5 w-3.5 text-green-500"}):(0,X.jsx)(_b,{className:"h-3.5 w-3.5"}),a?"Copied":"Copy"]}),(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let e=document.createElement("a");e.href=c,e.download=d,e.click()},title:"Download file",children:[(0,X.jsx)(rj,{className:"h-3.5 w-3.5"}),"Download"]}),(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(c,"_blank"),children:[(0,X.jsx)(kr,{className:"h-3.5 w-3.5"}),"Raw"]})]}),(0,X.jsx)("div",{className:"flex-1 overflow-auto source-viewer-code bg-[#1e1e1e]",children:r?(0,X.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading..."}):(0,X.jsx)("table",{className:"w-full border-collapse text-[13px] leading-relaxed font-mono",children:(0,X.jsx)("tbody",{children:p.map((e,t)=>(0,X.jsxs)("tr",{className:"hover:bg-white/5",children:[(0,X.jsx)("td",{className:"w-12 pr-4 text-right text-[#858585] select-none align-top sticky left-0 bg-[#1e1e1e]",children:t+1}),(0,X.jsx)("td",{className:`text-[#d4d4d4] pl-2 ${o?"whitespace-pre-wrap break-all":"whitespace-pre"}`,dangerouslySetInnerHTML:{__html:e||" "}})]},t))})})})]})}function Mx({path:e,title:t,src:n,fullscreen:r,onExit:i}){let o=n??`/api/assets/${e}/index.html`,s=r&&i?(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:i,title:"Exit app",children:[(0,X.jsx)(C0,{className:"h-3.5 w-3.5"}),"Exit app"]}):null;return(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,X.jsx)(rF,{path:e,badge:r?"App":void 0,showBreadcrumb:!r,leading:r?(0,X.jsxs)(X.Fragment,{children:[s,(0,X.jsx)("span",{className:"truncate text-[13px] font-medium text-foreground",children:t})]}):null,children:(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(o,"_blank"),children:[(0,X.jsx)(kr,{className:"h-3.5 w-3.5"}),"Open in new tab"]})}),(0,X.jsx)("iframe",{src:o,className:"flex-1 w-full border-0 bg-card",title:t,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-top-navigation-by-user-activation"})]})}let Mv=en("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]),ME=en("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),Mw={stopped:"Stopped",installing:"Installing dependencies…",starting:"Starting…",running:"Running",error:"Error"};function Mk({path:e,title:t}){let[n,r]=(0,Q.useState)("stopped"),[i,o]=(0,Q.useState)(null),[s,a]=(0,Q.useState)([]),[l,c]=(0,Q.useState)(null),[d,u]=(0,Q.useState)(!1),[h,p]=(0,Q.useState)(0),f=(0,Q.useRef)(null),m=(0,Q.useRef)(null),g=`/api/app-proxy/${e}/`,b=()=>{f.current&&(clearInterval(f.current),f.current=null)},y=(0,Q.useCallback)(async()=>{try{let t=await fetch(`/api/wiki/app?path=${encodeURIComponent(e)}`);if(!t.ok)return;let n=await t.json();r(n.status),a(n.logs??[]),n.port&&o(n.port),n.error&&c(n.error),("running"===n.status||"stopped"===n.status||"error"===n.status)&&b()}catch{}},[e]);(0,Q.useEffect)(()=>("installing"===n||"starting"===n?f.current||(f.current=setInterval(y,800)):b(),b),[n,y]),(0,Q.useEffect)(()=>{m.current?.scrollIntoView({behavior:"smooth"})},[s]),(0,Q.useEffect)(()=>{y()},[y]);let x=async()=>{c(null),a([]),r("starting");try{let t=await fetch("/api/wiki/app",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}),n=await t.json();if(!t.ok||n.error){r("error"),c(n.error??"Failed to start");return}n.port&&o(n.port),await y()}catch(e){r("error"),c(String(e))}},v=async()=>{await fetch("/api/wiki/app",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}),r("stopped"),o(null)},E=async()=>{await v(),await x(),p(e=>e+1)};return(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,X.jsxs)(rF,{path:e,badge:"Node app",children:["running"===n&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>p(e=>e+1),children:[(0,X.jsx)(ew,{className:"h-3.5 w-3.5"}),"Refresh"]}),(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(g,"_blank"),children:[(0,X.jsx)(kr,{className:"h-3.5 w-3.5"}),"Open in new tab"]}),(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:E,children:[(0,X.jsx)(ew,{className:"h-3.5 w-3.5"}),"Restart"]}),(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs text-destructive hover:text-destructive",onClick:v,children:[(0,X.jsx)(ME,{className:"h-3.5 w-3.5"}),"Stop"]})]}),(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>u(e=>!e),children:[(0,X.jsx)(eT,{className:"h-3.5 w-3.5"}),"Logs"]})]}),d&&(0,X.jsxs)("div",{className:"border-b bg-black/90 text-green-400 font-mono text-xs h-40 overflow-auto p-2 shrink-0",children:[0===s.length?(0,X.jsx)("span",{className:"text-muted-foreground",children:"No output yet."}):s.map((e,t)=>(0,X.jsx)("div",{className:"whitespace-pre-wrap leading-5",children:e},t)),(0,X.jsx)("div",{ref:m})]}),(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:["stopped"===n&&(0,X.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-4",children:[(0,X.jsxs)("div",{className:"text-center space-y-1",children:[(0,X.jsx)("p",{className:"text-sm font-medium",children:t}),(0,X.jsx)("p",{className:"text-xs text-muted-foreground",children:"Node.js app — will be started on a local port"})]}),(0,X.jsxs)(tG,{onClick:x,className:"gap-2",children:[(0,X.jsx)(Mv,{className:"h-4 w-4"}),"Launch app"]})]}),("installing"===n||"starting"===n)&&(0,X.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3",children:[(0,X.jsx)(eg,{className:"h-6 w-6 animate-spin text-muted-foreground"}),(0,X.jsx)("p",{className:"text-sm text-muted-foreground",children:Mw[n]}),i&&(0,X.jsxs)("p",{className:"text-xs text-muted-foreground/60",children:["port ",i]})]}),"error"===n&&(0,X.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-6",children:[(0,X.jsx)(er,{className:"h-8 w-8 text-destructive"}),(0,X.jsxs)("div",{className:"text-center space-y-1 max-w-md",children:[(0,X.jsx)("p",{className:"text-sm font-medium text-destructive",children:"Failed to start app"}),(0,X.jsx)("p",{className:"text-xs text-muted-foreground break-words",children:l??"Unknown error"})]}),(0,X.jsxs)(tG,{onClick:x,variant:"outline",className:"gap-2",children:[(0,X.jsx)(ew,{className:"h-4 w-4"}),"Try again"]})]}),"running"===n&&(0,X.jsx)("iframe",{src:g,className:"flex-1 w-full border-0 bg-card",title:t,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-top-navigation-by-user-activation"},h)]})]})}let MT=en("hard-drive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]),MN=en("house",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]),MA=en("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]),MS=en("pin-off",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);function MC({onSelect:e}){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!0),[o,s]=(0,Q.useState)(null),[a,l]=(0,Q.useState)(""),[c,d]=(0,Q.useState)(!1),[u,h]=(0,Q.useState)([]),[p,f]=(0,Q.useState)(!1),m=(0,Q.useRef)(null),g=(0,Q.useRef)(null),b=(0,Q.useCallback)(async(e,t=!0)=>{g.current&&(clearTimeout(g.current),g.current=null),i(!0),s(null);try{let r=await fetch(`/api/system/browse?path=${encodeURIComponent(e)}`);if(!r.ok){let e=await r.json();s(e.error??"Cannot open directory");return}let i=await r.json();n(i),t&&l(i.path)}catch{s("Network error")}finally{i(!1)}},[]);(0,Q.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await fetch("/api/system/config");if(t.ok&&!e){let e=await t.json();h(e.pinnedPaths??[]),await b(e.lastOpenedPath??"");return}}catch{}e||await b("")})(),()=>{e=!0}},[]);let y=async n=>{let r=n??t?.path;if(r){d(!0);try{let t=await fetch("/api/system/set-root",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r})});if(!t.ok){let e=await t.json();s(e.error??"Cannot use that directory");return}e(r)}catch{s("Network error")}finally{d(!1)}}},x=!!t&&u.includes(t.path),v=async()=>{if(t){f(!0);try{let e=x?"unpin":"pin";(await fetch("/api/system/pins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t.path,action:e})})).ok&&h(n=>"pin"===e?[...n,t.path]:n.filter(e=>e!==t.path))}catch{}finally{f(!1)}}},E=async e=>{try{(await fetch("/api/system/pins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,action:"unpin"})})).ok&&h(t=>t.filter(t=>t!==e))}catch{}},w=(t?.path??"").split(/[/\\]/).filter(Boolean).reduce((e,t)=>{let n=e[e.length-1]?.path??"/";return e.push({label:t,path:`${"/"===n?"":n}/${t}`}),e},[{label:"/",path:"/"}]);return(0,X.jsx)("div",{className:"flex flex-1 items-center justify-center bg-background p-4",children:(0,X.jsxs)("div",{className:"flex w-full max-w-xl flex-col gap-4",children:[(0,X.jsxs)("div",{className:"text-center space-y-1",children:[(0,X.jsxs)("div",{className:"flex items-center justify-center gap-2 mb-1",children:[(0,X.jsx)("img",{src:"/logo.svg",alt:"Wiki Viewer",className:"h-8 w-8"}),(0,X.jsx)("span",{className:"text-xl font-semibold tracking-tight",children:"Wiki Viewer"})]}),(0,X.jsx)("h1",{className:"text-xl font-medium",children:"Choose a directory"}),(0,X.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Select the folder wiki-viewer should serve.",(0,X.jsx)("br",{}),"This directory lives on the server — use the browser below."]})]}),(0,X.jsxs)("div",{className:"rounded-lg border bg-card shadow-sm overflow-hidden",children:[(0,X.jsx)("div",{className:"flex items-center gap-2 border-b px-3 py-2 bg-muted",children:(0,X.jsx)("input",{ref:m,className:"flex-1 bg-transparent text-sm outline-none font-mono min-w-0",value:a,onChange:e=>{let t=e.target.value;l(t),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,b(t.trim(),!1)},500)},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),g.current&&(clearTimeout(g.current),g.current=null),b(a.trim())),"Escape"===e.key&&(g.current&&(clearTimeout(g.current),g.current=null),l(t?.path??""),m.current?.blur())},spellCheck:!1,placeholder:"Enter a path…"})}),(0,X.jsx)("div",{className:"flex items-center gap-1 border-b px-3 py-1.5 bg-muted/50 overflow-x-auto shrink-0 min-h-[32px]",children:w.map((e,t)=>(0,X.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[t>0&&(0,X.jsx)(ea,{className:"h-3 w-3 text-muted-foreground/50"}),(0,X.jsx)("button",{type:"button",className:"text-xs hover:text-foreground text-muted-foreground transition-colors rounded px-0.5",onClick:()=>b(e.path),children:0===t?(0,X.jsx)(MT,{className:"h-3.5 w-3.5"}):e.label})]},e.path))}),(0,X.jsx)("div",{className:"max-h-60 overflow-y-auto",children:r?(0,X.jsx)("div",{className:"flex justify-center py-8",children:(0,X.jsx)(eg,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):o?(0,X.jsx)("div",{className:"px-4 py-3 text-sm text-destructive",children:o}):(0,X.jsxs)(X.Fragment,{children:[t?.parent&&(0,X.jsxs)("button",{type:"button",className:"flex w-full items-center gap-2.5 px-3 py-2 text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>b(t.parent),children:[(0,X.jsx)(eu,{className:"h-4 w-4 shrink-0"}),(0,X.jsx)("span",{className:"font-mono text-xs",children:".."})]}),t?.entries.length===0&&(0,X.jsx)("p",{className:"px-4 py-3 text-sm text-muted-foreground/60",children:"No subdirectories"}),t?.entries.map(e=>(0,X.jsxs)("button",{type:"button",className:"flex w-full items-center gap-2.5 px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>b(e.path),children:[(0,X.jsx)(eu,{className:"h-4 w-4 shrink-0 text-warning"}),(0,X.jsx)("span",{className:"truncate",children:e.name})]},e.path))]})}),(0,X.jsxs)("div",{className:"border-t px-3 py-2 flex items-center justify-between gap-2 bg-muted",children:[(0,X.jsxs)("button",{type:"button",className:tz("flex items-center gap-1.5 text-xs transition-colors rounded px-1.5 py-1",x?"text-foreground hover:text-destructive":"text-muted-foreground hover:text-foreground"),title:x?"Unpin this path":"Pin this path for quick access",onClick:v,disabled:p||!t,children:[p?(0,X.jsx)(eg,{className:"h-3.5 w-3.5 animate-spin"}):x?(0,X.jsx)(MS,{className:"h-3.5 w-3.5"}):(0,X.jsx)(MA,{className:"h-3.5 w-3.5"}),x?"Unpin":"Pin"]}),(0,X.jsxs)(tG,{size:"sm",className:"shrink-0 gap-1.5",disabled:!t||c,onClick:()=>y(),children:[c?(0,X.jsx)(eg,{className:"h-3.5 w-3.5 animate-spin"}):(0,X.jsx)(eh,{className:"h-3.5 w-3.5"}),"Select"]})]})]}),u.length>0&&(0,X.jsxs)("div",{className:"rounded-lg border bg-card shadow-sm overflow-hidden",children:[(0,X.jsx)("div",{className:"px-3 py-2 border-b bg-muted",children:(0,X.jsxs)("span",{className:"text-xs font-medium text-muted-foreground flex items-center gap-1.5",children:[(0,X.jsx)(MA,{className:"h-3 w-3"})," Pinned"]})}),(0,X.jsx)("div",{className:"max-h-40 overflow-y-auto",children:u.map(e=>(0,X.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 hover:bg-accent group",children:[(0,X.jsxs)("button",{type:"button",className:"flex-1 flex items-center gap-2 text-sm text-left min-w-0",onClick:()=>b(e),children:[(0,X.jsx)(eu,{className:"h-4 w-4 shrink-0 text-warning"}),(0,X.jsx)("span",{className:"truncate font-mono text-xs",children:e})]}),(0,X.jsx)("button",{type:"button",className:"shrink-0 text-muted-foreground/50 hover:text-destructive opacity-0 group-hover:opacity-100 transition-all",onClick:()=>E(e),title:"Remove pin",children:(0,X.jsx)(eS,{className:"h-3.5 w-3.5"})})]},e))})]}),t?.shortcuts&&t.shortcuts.length>0&&(0,X.jsx)("div",{className:"flex flex-wrap gap-1.5 justify-center",children:t.shortcuts.map(e=>(0,X.jsxs)(tG,{variant:"outline",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>b(e.path),children:["Home"===e.label?(0,X.jsx)(MN,{className:"h-3 w-3"}):(0,X.jsx)(MT,{className:"h-3 w-3"}),e.label]},e.path))})]})})}function M_(e){let t=e+"CollectionProvider",[n,r]=tV(t),[i,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=e=>{let{scope:t,children:n}=e,r=Q.default.useRef(null),o=Q.default.useRef(new Map).current;return(0,X.jsx)(i,{scope:t,itemMap:o,collectionRef:r,children:n})};s.displayName=t;let a=e+"CollectionSlot",l=t0(a),c=Q.default.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=eM(t,o(a,n).collectionRef);return(0,X.jsx)(l,{ref:i,children:r})});c.displayName=a;let d=e+"CollectionItemSlot",u="data-radix-collection-item",h=t0(d),p=Q.default.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,s=Q.default.useRef(null),a=eM(t,s),l=o(d,n);return Q.default.useEffect(()=>(l.itemMap.set(s,{ref:s,...i}),()=>void l.itemMap.delete(s))),(0,X.jsx)(h,{...{[u]:""},ref:a,children:r})});return p.displayName=d,[{Provider:s,Slot:c,ItemSlot:p},function(t){let n=o(e+"CollectionConsumer",t);return Q.default.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${u}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])},r]}var MM=new WeakMap;function MO(e,t){var n,r;let i,o,s;if("at"in Array.prototype)return Array.prototype.at.call(e,t);let a=(n=e,r=t,i=n.length,(s=(o=MI(r))>=0?o:i+o)<0||s>=i?-1:s);return -1===a?void 0:e[a]}function MI(e){return e!=e||0===e?0:Math.trunc(e)}(class e extends Map{#e;constructor(e){super(e),this.#e=[...super.keys()],MM.set(this,!0)}set(e,t){return MM.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r,i=this.has(t),o=this.#e.length,s=MI(e),a=s>=0?s:o+s,l=a<0||a>=o?-1:a;if(l===this.size||i&&l===this.size-1||-1===l)return this.set(t,n),this;let c=this.size+ +!i;s<0&&a++;let d=[...this.#e],u=!1;for(let e=a;e<c;e++)if(a===e){let o=d[e];d[e]===t&&(o=d[e+1]),i&&this.delete(t),r=this.get(o),this.set(t,n)}else{u||d[e-1]!==t||(u=!0);let n=d[u?e:e-1],i=r;r=this.get(n),this.delete(n),this.set(n,i)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return -1===r?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(-1!==(t=-1===t||t===this.size-1?-1:t+1))return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return -1===r?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return void 0!==t&&this.delete(t)}at(e){let t=MO(this.#e,e);if(void 0!==t)return this.get(t)}entryAt(e){let t=MO(this.#e,e);if(void 0!==t)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return MO(this.#e,e)}from(e,t){let n=this.indexOf(e);if(-1===n)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(-1===n)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return -1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=0===r&&1===e.length?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&1===e.length?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){return new e([...this.entries()].sort(t))}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(void 0===t)return r;t<0&&(t+=this.size),void 0!==n&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}});var MD=Q.createContext(void 0);function MR(e){let t=Q.useContext(MD);return e||t||"ltr"}var ML="rovingFocusGroup.onEntryFocus",MP={bubbles:!1,cancelable:!0},Mj="RovingFocusGroup",[MB,MF,MH]=M_(Mj),[MU,Mz]=tV(Mj,[MH]),[M$,MG]=MU(Mj),Mq=Q.forwardRef((e,t)=>(0,X.jsx)(MB.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,X.jsx)(MB.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,X.jsx)(MV,{...e,ref:t})})}));Mq.displayName=Mj;var MV=Q.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:o,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...u}=e,h=Q.useRef(null),p=eM(t,h),f=MR(o),[m,g]=tJ({prop:s,defaultProp:a??null,onChange:l,caller:Mj}),[b,y]=Q.useState(!1),x=t4(c),v=MF(n),E=Q.useRef(!1),[w,k]=Q.useState(0);return Q.useEffect(()=>{let e=h.current;if(e)return e.addEventListener(ML,x),()=>e.removeEventListener(ML,x)},[x]),(0,X.jsx)(M$,{scope:n,orientation:r,dir:f,loop:i,currentTabStopId:m,onItemFocus:Q.useCallback(e=>g(e),[g]),onItemShiftTab:Q.useCallback(()=>y(!0),[]),onFocusableItemAdd:Q.useCallback(()=>k(e=>e+1),[]),onFocusableItemRemove:Q.useCallback(()=>k(e=>e-1),[]),children:(0,X.jsx)(t3.div,{tabIndex:b||0===w?-1:0,"data-orientation":r,...u,ref:p,style:{outline:"none",...e.style},onMouseDown:tq(e.onMouseDown,()=>{E.current=!0}),onFocus:tq(e.onFocus,e=>{let t=!E.current;if(e.target===e.currentTarget&&t&&!b){let t=new CustomEvent(ML,MP);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=v().filter(e=>e.focusable);MX([e.find(e=>e.active),e.find(e=>e.id===m),...e].filter(Boolean).map(e=>e.ref.current),d)}}E.current=!1}),onBlur:tq(e.onBlur,()=>y(!1))})})}),MW="RovingFocusGroupItem",MK=Q.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:o,children:s,...a}=e,l=tX(),c=o||l,d=MG(MW,n),u=d.currentTabStopId===c,h=MF(n),{onFocusableItemAdd:p,onFocusableItemRemove:f,currentTabStopId:m}=d;return Q.useEffect(()=>{if(r)return p(),()=>f()},[r,p,f]),(0,X.jsx)(MB.ItemSlot,{scope:n,id:c,focusable:r,active:i,children:(0,X.jsx)(t3.span,{tabIndex:u?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:tq(e.onMouseDown,e=>{r?d.onItemFocus(c):e.preventDefault()}),onFocus:tq(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:tq(e.onKeyDown,e=>{if("Tab"===e.key&&e.shiftKey)return void d.onItemShiftTab();if(e.target!==e.currentTarget)return;let t=function(e,t,n){var r;let i=(r=e.key,"rtl"!==n?r:"ArrowLeft"===r?"ArrowRight":"ArrowRight"===r?"ArrowLeft":r);if(!("vertical"===t&&["ArrowLeft","ArrowRight"].includes(i))&&!("horizontal"===t&&["ArrowUp","ArrowDown"].includes(i)))return MY[i]}(e,d.orientation,d.dir);if(void 0!==t){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let i=h().filter(e=>e.focusable).map(e=>e.ref.current);if("last"===t)i.reverse();else if("prev"===t||"next"===t){var n,r;"prev"===t&&i.reverse();let o=i.indexOf(e.currentTarget);i=d.loop?(n=i,r=o+1,n.map((e,t)=>n[(r+t)%n.length])):i.slice(o+1)}setTimeout(()=>MX(i))}}),children:"function"==typeof s?s({isCurrentTabStop:u,hasTabStop:null!=m}):s})})});MK.displayName=MW;var MY={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function MX(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}var MQ=["Enter"," "],MJ=["ArrowUp","PageDown","End"],MZ=["ArrowDown","PageUp","Home",...MJ],M0={ltr:[...MQ,"ArrowRight"],rtl:[...MQ,"ArrowLeft"]},M1={ltr:["ArrowLeft"],rtl:["ArrowRight"]},M2="Menu",[M3,M5,M4]=M_(M2),[M6,M9]=tV(M2,[M4,S8,Mz]),M7=S8(),M8=Mz(),[Oe,Ot]=M6(M2),[On,Or]=M6(M2),Oi=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:o,modal:s=!0}=e,a=M7(t),[l,c]=Q.useState(null),d=Q.useRef(!1),u=t4(o),h=MR(i);return Q.useEffect(()=>{let e=()=>{d.current=!0,document.addEventListener("pointerdown",t,{capture:!0,once:!0}),document.addEventListener("pointermove",t,{capture:!0,once:!0})},t=()=>d.current=!1;return document.addEventListener("keydown",e,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointermove",t,{capture:!0})}},[]),(0,X.jsx)(Cn,{...a,children:(0,X.jsx)(Oe,{scope:t,open:n,onOpenChange:u,content:l,onContentChange:c,children:(0,X.jsx)(On,{scope:t,onClose:Q.useCallback(()=>u(!1),[u]),isUsingKeyboardRef:d,dir:h,modal:s,children:r})})})};Oi.displayName=M2;var Oo=Q.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=M7(n);return(0,X.jsx)(Ci,{...i,...r,ref:t})});Oo.displayName="MenuAnchor";var Os="MenuPortal",[Oa,Ol]=M6(Os,{forceMount:void 0}),Oc=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,o=Ot(Os,t);return(0,X.jsx)(Oa,{scope:t,forceMount:n,children:(0,X.jsx)(nu,{present:n||o.open,children:(0,X.jsx)(nd,{asChild:!0,container:i,children:r})})})};Oc.displayName=Os;var Od="MenuContent",[Ou,Oh]=M6(Od),Op=Q.forwardRef((e,t)=>{let n=Ol(Od,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=Ot(Od,e.__scopeMenu),s=Or(Od,e.__scopeMenu);return(0,X.jsx)(M3.Provider,{scope:e.__scopeMenu,children:(0,X.jsx)(nu,{present:r||o.open,children:(0,X.jsx)(M3.Slot,{scope:e.__scopeMenu,children:s.modal?(0,X.jsx)(Of,{...i,ref:t}):(0,X.jsx)(Om,{...i,ref:t})})})})}),Of=Q.forwardRef((e,t)=>{let n=Ot(Od,e.__scopeMenu),r=Q.useRef(null),i=eM(t,r);return Q.useEffect(()=>{let e=r.current;if(e)return n6(e)},[]),(0,X.jsx)(Ob,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:tq(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Om=Q.forwardRef((e,t)=>{let n=Ot(Od,e.__scopeMenu);return(0,X.jsx)(Ob,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Og=t0("MenuContent.ScrollLock"),Ob=Q.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:h,onDismiss:p,disableOutsideScroll:f,...m}=e,g=Ot(Od,n),b=Or(Od,n),y=M7(n),x=M8(n),v=M5(n),[E,w]=Q.useState(null),k=Q.useRef(null),T=eM(t,k,g.onContentChange),N=Q.useRef(0),A=Q.useRef(""),S=Q.useRef(0),C=Q.useRef(null),_=Q.useRef("right"),M=Q.useRef(0),O=f?nZ:Q.Fragment;Q.useEffect(()=>()=>window.clearTimeout(N.current),[]),nf();let I=Q.useCallback(e=>{var t,n;return _.current===C.current?.side&&(t=e,!!(n=C.current?.area)&&function(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,o=t.length-1;e<t.length;o=e++){let s=t[e],a=t[o],l=s.x,c=s.y,d=a.x,u=a.y;c>r!=u>r&&n<(d-l)*(r-c)/(u-c)+l&&(i=!i)}return i}({x:t.clientX,y:t.clientY},n))},[]);return(0,X.jsx)(Ou,{scope:n,searchRef:A,onItemEnter:Q.useCallback(e=>{I(e)&&e.preventDefault()},[I]),onItemLeave:Q.useCallback(e=>{I(e)||(k.current?.focus(),w(null))},[I]),onTriggerLeave:Q.useCallback(e=>{I(e)&&e.preventDefault()},[I]),pointerGraceTimerRef:S,onPointerGraceIntentChange:Q.useCallback(e=>{C.current=e},[]),children:(0,X.jsx)(O,{...f?{as:Og,allowPinchZoom:!0}:void 0,children:(0,X.jsx)(ni,{asChild:!0,trapped:i,onMountAutoFocus:tq(o,e=>{e.preventDefault(),k.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:(0,X.jsx)(t7,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:h,onDismiss:p,children:(0,X.jsx)(Mq,{asChild:!0,...x,dir:b.dir,orientation:"vertical",loop:r,currentTabStopId:E,onCurrentTabStopIdChange:w,onEntryFocus:tq(l,e=>{b.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,X.jsx)(Cl,{role:"menu","aria-orientation":"vertical","data-state":O$(g.open),"data-radix-menu-content":"",dir:b.dir,...y,...m,ref:T,style:{outline:"none",...m.style},onKeyDown:tq(m.onKeyDown,e=>{let t=e.target.closest("[data-radix-menu-content]")===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=1===e.key.length;if(t){var i;let t,o,s,a,l,c;"Tab"===e.key&&e.preventDefault(),!n&&r&&(i=e.key,t=A.current+i,o=v().filter(e=>!e.disabled),s=document.activeElement,a=o.find(e=>e.ref.current===s)?.textValue,l=function(e,t,n){var r;let i=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,o=n?e.indexOf(n):-1,s=(r=Math.max(o,0),e.map((t,n)=>e[(r+n)%e.length]));1===i.length&&(s=s.filter(e=>e!==n));let a=s.find(e=>e.toLowerCase().startsWith(i.toLowerCase()));return a!==n?a:void 0}(o.map(e=>e.textValue),t,a),c=o.find(e=>e.textValue===l)?.ref.current,function e(t){A.current=t,window.clearTimeout(N.current),""!==t&&(N.current=window.setTimeout(()=>e(""),1e3))}(t),c&&setTimeout(()=>c.focus()))}let o=k.current;if(e.target!==o||!MZ.includes(e.key))return;e.preventDefault();let s=v().filter(e=>!e.disabled).map(e=>e.ref.current);MJ.includes(e.key)&&s.reverse(),function(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}(s)}),onBlur:tq(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(N.current),A.current="")}),onPointerMove:tq(e.onPointerMove,OV(e=>{let t=e.target,n=M.current!==e.clientX;e.currentTarget.contains(t)&&n&&(_.current=e.clientX>M.current?"right":"left",M.current=e.clientX)}))})})})})})})});Op.displayName=Od;var Oy=Q.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,X.jsx)(t3.div,{role:"group",...r,ref:t})});Oy.displayName="MenuGroup";var Ox=Q.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,X.jsx)(t3.div,{...r,ref:t})});Ox.displayName="MenuLabel";var Ov="MenuItem",OE="menu.itemSelect",Ow=Q.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,o=Q.useRef(null),s=Or(Ov,e.__scopeMenu),a=Oh(Ov,e.__scopeMenu),l=eM(t,o),c=Q.useRef(!1);return(0,X.jsx)(Ok,{...i,ref:l,disabled:n,onClick:tq(e.onClick,()=>{let e=o.current;if(!n&&e){let t=new CustomEvent(OE,{bubbles:!0,cancelable:!0});e.addEventListener(OE,e=>r?.(e),{once:!0}),t5(e,t),t.defaultPrevented?c.current=!1:s.onClose()}}),onPointerDown:t=>{e.onPointerDown?.(t),c.current=!0},onPointerUp:tq(e.onPointerUp,e=>{c.current||e.currentTarget?.click()}),onKeyDown:tq(e.onKeyDown,e=>{let t=""!==a.searchRef.current;n||t&&" "===e.key||MQ.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});Ow.displayName=Ov;var Ok=Q.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...o}=e,s=Oh(Ov,n),a=M8(n),l=Q.useRef(null),c=eM(t,l),[d,u]=Q.useState(!1),[h,p]=Q.useState("");return Q.useEffect(()=>{let e=l.current;e&&p((e.textContent??"").trim())},[o.children]),(0,X.jsx)(M3.ItemSlot,{scope:n,disabled:r,textValue:i??h,children:(0,X.jsx)(MK,{asChild:!0,...a,focusable:!r,children:(0,X.jsx)(t3.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...o,ref:c,onPointerMove:tq(e.onPointerMove,OV(e=>{r?s.onItemLeave(e):(s.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:tq(e.onPointerLeave,OV(e=>s.onItemLeave(e))),onFocus:tq(e.onFocus,()=>u(!0)),onBlur:tq(e.onBlur,()=>u(!1))})})})}),OT=Q.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,X.jsx)(OI,{scope:e.__scopeMenu,checked:n,children:(0,X.jsx)(Ow,{role:"menuitemcheckbox","aria-checked":OG(n)?"mixed":n,...i,ref:t,"data-state":Oq(n),onSelect:tq(i.onSelect,()=>r?.(!!OG(n)||!n),{checkForDefaultPrevented:!1})})})});OT.displayName="MenuCheckboxItem";var ON="MenuRadioGroup",[OA,OS]=M6(ON,{value:void 0,onValueChange:()=>{}}),OC=Q.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,o=t4(r);return(0,X.jsx)(OA,{scope:e.__scopeMenu,value:n,onValueChange:o,children:(0,X.jsx)(Oy,{...i,ref:t})})});OC.displayName=ON;var O_="MenuRadioItem",OM=Q.forwardRef((e,t)=>{let{value:n,...r}=e,i=OS(O_,e.__scopeMenu),o=n===i.value;return(0,X.jsx)(OI,{scope:e.__scopeMenu,checked:o,children:(0,X.jsx)(Ow,{role:"menuitemradio","aria-checked":o,...r,ref:t,"data-state":Oq(o),onSelect:tq(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});OM.displayName=O_;var OO="MenuItemIndicator",[OI,OD]=M6(OO,{checked:!1}),OR=Q.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,o=OD(OO,n);return(0,X.jsx)(nu,{present:r||OG(o.checked)||!0===o.checked,children:(0,X.jsx)(t3.span,{...i,ref:t,"data-state":Oq(o.checked)})})});OR.displayName=OO;var OL=Q.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,X.jsx)(t3.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});OL.displayName="MenuSeparator";var OP=Q.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=M7(n);return(0,X.jsx)(Cu,{...i,...r,ref:t})});OP.displayName="MenuArrow";var[Oj,OB]=M6("MenuSub"),OF="MenuSubTrigger",OH=Q.forwardRef((e,t)=>{let n=Ot(OF,e.__scopeMenu),r=Or(OF,e.__scopeMenu),i=OB(OF,e.__scopeMenu),o=Oh(OF,e.__scopeMenu),s=Q.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=o,c={__scopeMenu:e.__scopeMenu},d=Q.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);return Q.useEffect(()=>d,[d]),Q.useEffect(()=>{let e=a.current;return()=>{window.clearTimeout(e),l(null)}},[a,l]),(0,X.jsx)(Oo,{asChild:!0,...c,children:(0,X.jsx)(Ok,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":O$(n.open),...e,ref:e_(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),e.disabled||t.defaultPrevented||(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:tq(e.onPointerMove,OV(t=>{o.onItemEnter(t),!t.defaultPrevented&&(e.disabled||n.open||s.current||(o.onPointerGraceIntentChange(null),s.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100)))})),onPointerLeave:tq(e.onPointerLeave,OV(e=>{d();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i="right"===r,s=t[i?"left":"right"],l=t[i?"right":"left"];o.onPointerGraceIntentChange({area:[{x:e.clientX+(i?-5:5),y:e.clientY},{x:s,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:s,y:t.bottom}],side:r}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(e),e.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:tq(e.onKeyDown,t=>{let i=""!==o.searchRef.current;e.disabled||i&&" "===t.key||M0[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});OH.displayName=OF;var OU="MenuSubContent",Oz=Q.forwardRef((e,t)=>{let n=Ol(Od,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=Ot(Od,e.__scopeMenu),s=Or(Od,e.__scopeMenu),a=OB(OU,e.__scopeMenu),l=Q.useRef(null),c=eM(t,l);return(0,X.jsx)(M3.Provider,{scope:e.__scopeMenu,children:(0,X.jsx)(nu,{present:r||o.open,children:(0,X.jsx)(M3.Slot,{scope:e.__scopeMenu,children:(0,X.jsx)(Ob,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:c,align:"start",side:"rtl"===s.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{s.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:tq(e.onFocusOutside,e=>{e.target!==a.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:tq(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:tq(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=M1[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),a.trigger?.focus(),e.preventDefault())})})})})})});function O$(e){return e?"open":"closed"}function OG(e){return"indeterminate"===e}function Oq(e){return OG(e)?"indeterminate":e?"checked":"unchecked"}function OV(e){return t=>"mouse"===t.pointerType?e(t):void 0}Oz.displayName=OU;var OW="DropdownMenu",[OK,OY]=tV(OW,[M9]),OX=M9(),[OQ,OJ]=OK(OW),OZ=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:o,onOpenChange:s,modal:a=!0}=e,l=OX(t),c=Q.useRef(null),[d,u]=tJ({prop:i,defaultProp:o??!1,onChange:s,caller:OW});return(0,X.jsx)(OQ,{scope:t,triggerId:tX(),triggerRef:c,contentId:tX(),open:d,onOpenChange:u,onOpenToggle:Q.useCallback(()=>u(e=>!e),[u]),modal:a,children:(0,X.jsx)(Oi,{...l,open:d,onOpenChange:u,dir:r,modal:a,children:n})})};OZ.displayName=OW;var O0="DropdownMenuTrigger",O1=Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,o=OJ(O0,n),s=OX(n);return(0,X.jsx)(Oo,{asChild:!0,...s,children:(0,X.jsx)(t3.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:e_(t,o.triggerRef),onPointerDown:tq(e.onPointerDown,e=>{!r&&0===e.button&&!1===e.ctrlKey&&(o.onOpenToggle(),o.open||e.preventDefault())}),onKeyDown:tq(e.onKeyDown,e=>{!r&&(["Enter"," "].includes(e.key)&&o.onOpenToggle(),"ArrowDown"===e.key&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(e.key)&&e.preventDefault())})})})});O1.displayName=O0;var O2=e=>{let{__scopeDropdownMenu:t,...n}=e,r=OX(t);return(0,X.jsx)(Oc,{...r,...n})};O2.displayName="DropdownMenuPortal";var O3="DropdownMenuContent",O5=Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OJ(O3,n),o=OX(n),s=Q.useRef(!1);return(0,X.jsx)(Op,{id:i.contentId,"aria-labelledby":i.triggerId,...o,...r,ref:t,onCloseAutoFocus:tq(e.onCloseAutoFocus,e=>{s.current||i.triggerRef.current?.focus(),s.current=!1,e.preventDefault()}),onInteractOutside:tq(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey,r=2===t.button||n;(!i.modal||r)&&(s.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});O5.displayName=O3,Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(Oy,{...i,...r,ref:t})}).displayName="DropdownMenuGroup";var O4=Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(Ox,{...i,...r,ref:t})});O4.displayName="DropdownMenuLabel";var O6=Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(Ow,{...i,...r,ref:t})});O6.displayName="DropdownMenuItem";var O9=Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(OT,{...i,...r,ref:t})});O9.displayName="DropdownMenuCheckboxItem",Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(OC,{...i,...r,ref:t})}).displayName="DropdownMenuRadioGroup";var O7=Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(OM,{...i,...r,ref:t})});O7.displayName="DropdownMenuRadioItem";var O8=Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(OR,{...i,...r,ref:t})});O8.displayName="DropdownMenuItemIndicator";var Ie=Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(OL,{...i,...r,ref:t})});Ie.displayName="DropdownMenuSeparator",Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(OP,{...i,...r,ref:t})}).displayName="DropdownMenuArrow";var It=Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(OH,{...i,...r,ref:t})});It.displayName="DropdownMenuSubTrigger";var In=Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(Oz,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});In.displayName="DropdownMenuSubContent";let Ir=en("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);Q.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,X.jsxs)(It,{ref:i,className:tz("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,(0,X.jsx)(ea,{className:"ml-auto h-4 w-4"})]})).displayName=It.displayName,Q.forwardRef(({className:e,...t},n)=>(0,X.jsx)(In,{ref:n,className:tz("z-50 min-w-[8rem] overflow-hidden rounded-sm border bg-popover p-1 text-popover-foreground shadow-golden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t})).displayName=In.displayName;let Ii=Q.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,X.jsx)(O2,{children:(0,X.jsx)(O5,{ref:r,sideOffset:t,className:tz("z-50 min-w-[8rem] overflow-hidden rounded-sm border bg-popover p-1 text-popover-foreground shadow-golden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Ii.displayName=O5.displayName;let Io=Q.forwardRef(({className:e,inset:t,...n},r)=>(0,X.jsx)(O6,{ref:r,className:tz("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Io.displayName=O6.displayName,Q.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,X.jsxs)(O9,{ref:i,className:tz("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[(0,X.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,X.jsx)(O8,{children:(0,X.jsx)(eo,{className:"h-4 w-4"})})}),t]})).displayName=O9.displayName,Q.forwardRef(({className:e,children:t,...n},r)=>(0,X.jsxs)(O7,{ref:r,className:tz("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[(0,X.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,X.jsx)(O8,{children:(0,X.jsx)(Ir,{className:"h-2 w-2 fill-current"})})}),t]})).displayName=O7.displayName,Q.forwardRef(({className:e,inset:t,...n},r)=>(0,X.jsx)(O4,{ref:r,className:tz("px-2 py-1.5 text-sm font-normal",t&&"pl-8",e),...n})).displayName=O4.displayName,Q.forwardRef(({className:e,...t},n)=>(0,X.jsx)(Ie,{ref:n,className:tz("-mx-1 my-1 h-px bg-muted",e),...t})).displayName=Ie.displayName;let Is=en("moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]),Ia=en("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"}]]);var Il=e.i(917356);function Ic({className:e}){let{resolvedTheme:t,setTheme:n}=(0,Il.useTheme)();return(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:`h-7 w-7 p-0 ${e??""}`,title:"dark"===t?"Switch to light":"Switch to dark",onClick:()=>n("dark"===t?"light":"dark"),children:"dark"===t?(0,X.jsx)(Ia,{className:"h-3.5 w-3.5"}):(0,X.jsx)(Is,{className:"h-3.5 w-3.5"})})}let Id=Q.forwardRef(({className:e,...t},n)=>(0,X.jsx)(rc,{ref:n,className:tz("fixed inset-0 z-40 bg-black/40 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),...t}));Id.displayName="SheetOverlay";let Iu={bottom:"inset-x-0 bottom-0 data-[state=open]:slide-in-from-bottom data-[state=closed]:slide-out-to-bottom",top:"inset-x-0 top-0 data-[state=open]:slide-in-from-top data-[state=closed]:slide-out-to-top",left:"inset-y-0 left-0 data-[state=open]:slide-in-from-left data-[state=closed]:slide-out-to-left",right:"inset-y-0 right-0 data-[state=open]:slide-in-from-right data-[state=closed]:slide-out-to-right"},Ih=Q.forwardRef(({side:e="bottom",showClose:t=!1,className:n,children:r,...i},o)=>(0,X.jsxs)(ra,{children:[(0,X.jsx)(Id,{}),(0,X.jsxs)(rp,{ref:o,className:tz("fixed z-50 bg-background shadow-golden transition-all ease-in-out","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:duration-300",Iu[e],n),...i,children:[r,t&&(0,X.jsxs)(rw,{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",children:[(0,X.jsx)(eS,{className:"h-4 w-4"}),(0,X.jsx)("span",{className:"sr-only",children:"Close"})]})]})]}));function Ip({className:e,...t}){return(0,X.jsx)("div",{className:tz("flex flex-col space-y-1.5",e),...t})}function If({className:e,...t}){return(0,X.jsx)("div",{className:tz("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t})}Ih.displayName="SheetContent",Ip.displayName="SheetHeader",If.displayName="SheetFooter";let Im=Q.forwardRef(({className:e,...t},n)=>(0,X.jsx)(ry,{ref:n,className:tz("text-sm font-medium leading-none tracking-tight",e),...t}));Im.displayName="SheetTitle";let Ig=Q.forwardRef(({className:e,...t},n)=>(0,X.jsx)(rv,{ref:n,className:tz("text-sm text-muted-foreground",e),...t}));function Ib(e){return e.split(/[\n,]/).map(e=>e.trim()).filter(Boolean)}function Iy({open:e,onOpenChange:t}){let[n,r]=(0,Q.useState)(!1),[i,o]=(0,Q.useState)(!1),[s,a]=(0,Q.useState)(null),[l,c]=(0,Q.useState)("env"),[d,u]=(0,Q.useState)(""),[h,p]=(0,Q.useState)(""),f=(0,Q.useCallback)(async()=>{r(!0),a(null);try{let e=await fetch("/api/system/auth-settings");if(!e.ok)throw Error("Failed to load settings");let t=await e.json();u(t.allowedEmails.join("\n")),p(t.allowedDomains.join("\n")),c(t.source)}catch(e){a(e instanceof Error?e.message:"Failed to load")}finally{r(!1)}},[]);async function m(){o(!0),a(null);try{let e=await fetch("/api/system/auth-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({allowedEmails:Ib(d),allowedDomains:Ib(h)})}),n=await e.json();if(!e.ok){a(n.error??"Save failed"),_o(n.error??"Save failed");return}n.source&&c(n.source),t(!1)}catch{a("Save failed")}finally{o(!1)}}(0,Q.useEffect)(()=>{e&&f()},[e,f]);let g=0===Ib(d).length&&0===Ib(h).length;return(0,X.jsx)(rn,{open:e,onOpenChange:t,children:(0,X.jsxs)(Ih,{side:"right",className:"w-full sm:max-w-md flex flex-col",children:[(0,X.jsxs)(Ip,{children:[(0,X.jsx)(Im,{children:"Signup allowlist"}),(0,X.jsx)(Ig,{children:"Control who can create an account. Leave both lists empty to allow any email. Saving here overrides the AUTH_ALLOWED_EMAILS and AUTH_ALLOWED_DOMAIN environment variables."})]}),n?(0,X.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,X.jsx)(eg,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,X.jsxs)("div",{className:"flex-1 space-y-5 overflow-auto py-4",children:["env"===l&&(0,X.jsxs)("div",{className:"flex items-start gap-2 rounded-md bg-muted px-3 py-2 text-xs text-muted-foreground",children:[(0,X.jsx)(er,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}),(0,X.jsx)("span",{children:"Current values come from environment variables. Saving moves the allowlist into config and takes precedence going forward."})]}),(0,X.jsxs)("div",{className:"space-y-1.5",children:[(0,X.jsx)("label",{htmlFor:"allowed-emails",className:"text-sm font-medium",children:"Allowed emails"}),(0,X.jsx)("p",{className:"text-xs text-muted-foreground",children:"One per line (or comma-separated). Exact match, case-insensitive."}),(0,X.jsx)("textarea",{id:"allowed-emails",value:d,onChange:e=>u(e.target.value),spellCheck:!1,rows:5,placeholder:"alice@example.com bob@example.com",className:"w-full resize-y rounded-md border border-border bg-background px-3 py-2 font-mono text-sm outline-none focus:ring-2 focus:ring-primary"})]}),(0,X.jsxs)("div",{className:"space-y-1.5",children:[(0,X.jsx)("label",{htmlFor:"allowed-domains",className:"text-sm font-medium",children:"Allowed domains"}),(0,X.jsx)("p",{className:"text-xs text-muted-foreground",children:"One per line (or comma-separated). Matches any email at that domain."}),(0,X.jsx)("textarea",{id:"allowed-domains",value:h,onChange:e=>p(e.target.value),spellCheck:!1,rows:4,placeholder:"example.com trusted.org",className:"w-full resize-y rounded-md border border-border bg-background px-3 py-2 font-mono text-sm outline-none focus:ring-2 focus:ring-primary"})]}),g&&(0,X.jsxs)("div",{className:"flex items-start gap-2 rounded-md bg-warning-soft px-3 py-2 text-xs text-warning-ink",children:[(0,X.jsx)(er,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}),(0,X.jsx)("span",{children:"Both lists are empty. Anyone with the signup URL can create an account."})]}),s&&(0,X.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[(0,X.jsx)(er,{className:"h-3.5 w-3.5 shrink-0"}),s]})]}),(0,X.jsxs)(If,{children:[(0,X.jsx)(tG,{variant:"ghost",onClick:()=>t(!1),disabled:i,children:"Cancel"}),(0,X.jsxs)(tG,{onClick:m,disabled:i||n,className:"gap-1.5",children:[i&&(0,X.jsx)(eg,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]})]})})}Ig.displayName="SheetDescription";let Ix=Q.forwardRef(({className:e,...t},n)=>(0,X.jsx)("div",{ref:n,className:tz("rounded-md border border-border bg-card text-card-foreground shadow-e-2",e),...t}));Ix.displayName="Card",Q.forwardRef(({className:e,...t},n)=>(0,X.jsx)("div",{ref:n,className:tz("flex flex-col space-y-1.5 p-6",e),...t})).displayName="CardHeader",Q.forwardRef(({className:e,...t},n)=>(0,X.jsx)("div",{ref:n,className:tz("text-lg font-normal leading-none tracking-tight",e),...t})).displayName="CardTitle",Q.forwardRef(({className:e,...t},n)=>(0,X.jsx)("div",{ref:n,className:tz("text-sm text-muted-foreground",e),...t})).displayName="CardDescription",Q.forwardRef(({className:e,...t},n)=>(0,X.jsx)("div",{ref:n,className:tz("p-6 pt-0",e),...t})).displayName="CardContent";let Iv=eH("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 IE({className:e,variant:t,...n}){return(0,X.jsx)("div",{className:tz(Iv({variant:t}),e),...n})}let Iw=new Set(["title","type","status","created","updated","date","tags","sources","private","supersedes","superseded_by"]);function Ik({data:e}){let[t,n]=(0,Q.useState)(!1),r=Object.keys(e);if(0===r.length)return null;let i="string"==typeof e.title?e.title:null,o="string"==typeof e.type?e.type:null,s="string"==typeof e.status?e.status:null,a="string"==typeof e.created?e.created:null,l="string"==typeof e.updated?e.updated:null,c=!0===e.private,d=Array.isArray(e.tags)?e.tags:[],u=Array.isArray(e.sources)?e.sources:[],h="string"==typeof e.superseded_by?e.superseded_by:null,p=r.filter(e=>!Iw.has(e));return(0,X.jsxs)("div",{className:"mb-6 rounded-sm border bg-card/40 px-4 py-3 text-xs",children:[i&&(0,X.jsx)("div",{className:"mb-2 text-base font-normal text-foreground",children:i}),(0,X.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5 text-muted-foreground",children:[o&&(0,X.jsx)(IE,{variant:"outline",className:"font-normal",children:o}),s&&(0,X.jsx)(IE,{variant:"outline",className:"font-normal",children:s}),c&&(0,X.jsx)(IE,{variant:"outline",className:"border-warning-ink/40 font-normal text-warning-ink",children:"private"}),h&&(0,X.jsxs)(IE,{variant:"outline",className:"border-destructive/40 font-normal text-destructive",children:["superseded → ",h]}),a&&(0,X.jsxs)("span",{children:[(0,X.jsx)("span",{className:"opacity-60",children:"created"})," ",(0,X.jsx)("span",{className:"text-foreground/80",children:a})]}),l&&l!==a&&(0,X.jsxs)("span",{children:[(0,X.jsx)("span",{className:"opacity-60",children:"updated"})," ",(0,X.jsx)("span",{className:"text-foreground/80",children:l})]})]}),d.length>0&&(0,X.jsx)("div",{className:"mt-2 flex flex-wrap gap-1",children:d.map(e=>(0,X.jsxs)(IE,{variant:"secondary",className:"font-normal text-[11px]",children:["#",e]},e))}),u.length>0&&(0,X.jsxs)("div",{className:"mt-2",children:[(0,X.jsx)("span",{className:"opacity-60",children:"sources:"})," ",(0,X.jsx)("span",{className:"text-foreground/80",children:u.join(", ")})]}),p.length>0&&(0,X.jsxs)("div",{className:"mt-2 border-t pt-2",children:[(0,X.jsxs)("button",{type:"button",onClick:()=>n(e=>!e),className:"flex items-center gap-1 text-muted-foreground hover:text-foreground",children:[t?(0,X.jsx)(es,{className:"h-3 w-3"}):(0,X.jsx)(ea,{className:"h-3 w-3"}),(0,X.jsxs)("span",{children:[p.length," more field",1===p.length?"":"s"]})]}),t&&(0,X.jsx)("dl",{className:"mt-1.5 grid grid-cols-[max-content_1fr] gap-x-3 gap-y-0.5",children:p.map(t=>(0,X.jsxs)(Q.Fragment,{children:[(0,X.jsx)("dt",{className:"opacity-60",children:t}),(0,X.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[t])})]},t))})]})]})}function IT({markdown:e,pagePath:t,onNavigate:n}){let[r,i]=(0,Q.useState)(""),o=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let n=!1;return vg(e,{pagePath:t,sanitize:!0}).then(e=>{n||i(e)}),()=>{n=!0}},[e,t]);let s=(0,Q.useCallback)(e=>{let t=e.target.closest("a");if(!t)return;if("true"===t.dataset.wikiLink){e.preventDefault();let r=t.dataset.slug??"";if(!r)return;let i=Ex.getState().getDir(r);if(!i)return;n("root"===i?`${r}.md`:`${i}/${r}.md`,t.dataset.anchor??null);return}let r=t.getAttribute("href")??"";if(/^https?:\/\//.test(r)){t.target||(t.setAttribute("target","_blank"),t.setAttribute("rel","noreferrer"));return}},[n]);(0,Q.useEffect)(()=>{let e=o.current;if(e)return e.querySelectorAll("a[href^='http']").forEach(e=>{e.target||(e.setAttribute("target","_blank"),e.setAttribute("rel","noreferrer"))}),e.addEventListener("click",s),()=>e.removeEventListener("click",s)},[r,s]);let a=Ex(e=>e.loadedAt);return(0,Q.useEffect)(()=>{let e=o.current;if(!e)return;let t=Ex.getState();e.querySelectorAll('a[data-wiki-link="true"]').forEach(e=>{let n=e.dataset.slug??"";n&&!t.has(n)?e.dataset.broken="true":delete e.dataset.broken})},[r,a]),(0,Q.useEffect)(()=>{let e=o.current;e&&e.querySelectorAll('input[type="checkbox"]').forEach(e=>{e.disabled=!0})},[r]),(0,X.jsx)("div",{ref:o,className:"tiptap md-preview",dangerouslySetInnerHTML:{__html:r}})}let IN=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/;function IA(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=>IA(e))}return t}let IS=en("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]),IC=en("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]),I_=en("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),IM=en("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);function IO(e){let t=Date.now()-new Date(e).getTime();return t<6e4?"just now":t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}function II({scope:e}){return(0,X.jsxs)("span",{className:"text-[10px] text-muted-foreground/70 font-mono",children:[e.paths.join(", ")," · ",e.ops.join(",")]})}function ID({reg:e,onApprove:t,onDeny:n}){let[r,i]=(0,Q.useState)(!1);async function o(t){i(!0);try{await t(e.registrationId)}finally{i(!1)}}return(0,X.jsxs)("li",{className:"py-1.5 border-b border-border/40 last:border-0",children:[(0,X.jsxs)("div",{className:"flex items-start justify-between gap-1",children:[(0,X.jsxs)("div",{className:"min-w-0",children:[(0,X.jsx)("p",{className:"text-xs font-mono truncate",children:e.displayName}),(0,X.jsx)("p",{className:"text-[10px] text-muted-foreground/60 truncate",children:e.agentId}),(0,X.jsx)(II,{scope:e.requestedScope})]}),(0,X.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,X.jsxs)(tG,{size:"sm",variant:"default",className:"h-6 px-2 text-[10px]",disabled:r,onClick:()=>void o(t),title:"Approve",children:[(0,X.jsx)(IC,{className:"h-3 w-3 mr-0.5"}),"Approve"]}),(0,X.jsxs)(tG,{size:"sm",variant:"ghost",className:"h-6 px-2 text-[10px] text-destructive hover:text-destructive",disabled:r,onClick:()=>void o(n),title:"Deny",children:[(0,X.jsx)(I_,{className:"h-3 w-3 mr-0.5"}),"Deny"]})]})]}),(0,X.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 mt-0.5",children:["Requested ",IO(e.requestedAt)]})]})}function IR({agent:e,onRevoke:t}){let[n,r]=(0,Q.useState)(!1);return(0,X.jsxs)("li",{className:"py-1.5 border-b border-border/40 last:border-0",children:[(0,X.jsxs)("div",{className:"flex items-start justify-between gap-1",children:[(0,X.jsxs)("div",{className:"min-w-0",children:[(0,X.jsx)("p",{className:"text-xs font-mono truncate",children:e.displayName}),(0,X.jsx)("p",{className:"text-[10px] text-muted-foreground/60 truncate",children:e.id}),(0,X.jsx)(II,{scope:e.scope})]}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0 text-destructive hover:text-destructive",disabled:n,onClick:async()=>{r(!0);try{await t(e.id)}finally{r(!1)}},title:"Revoke agent",children:(0,X.jsx)(eN,{className:"h-3 w-3"})})]}),(0,X.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 mt-0.5",children:["Last seen ",IO(e.lastSeen)]})]})}function IL(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)([]),[i,o]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{fetch("/api/owner/init",{credentials:"same-origin"}).then(e=>{(e.ok||204===e.status)&&o(!0)}).catch(()=>{o(!0)})},[]);let s=(0,Q.useCallback)(async()=>{try{let e=await fetch("/api/agent/admin/registrations",{credentials:"same-origin"});if(!e.ok)return;let n=await e.json();t(n.pending)}catch{}},[]),a=(0,Q.useCallback)(async()=>{try{let e=await fetch("/api/agent/admin/agents",{credentials:"same-origin"});if(!e.ok)return;let t=await e.json();r(t.agents)}catch{}},[]);(0,Q.useEffect)(()=>{if(!i)return;s(),a();let e=setInterval(()=>void s(),5e3),t=setInterval(()=>void a(),3e4);return()=>{clearInterval(e),clearInterval(t)}},[i,s,a]);let l=(0,Q.useCallback)(async e=>{(await fetch(`/api/agent/admin/registrations/${e}/approve`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:"{}"})).ok?(_i.toast.success("Agent approved"),await Promise.all([s(),a()])):_i.toast.error("Failed to approve agent")},[s,a]),c=(0,Q.useCallback)(async e=>{(await fetch(`/api/agent/admin/registrations/${e}/deny`,{method:"POST",credentials:"same-origin"})).ok?(_i.toast.success("Registration denied"),await s()):_i.toast.error("Failed to deny registration")},[s]),d=(0,Q.useCallback)(async e=>{(await fetch(`/api/agent/admin/agents/${encodeURIComponent(e)}/revoke`,{method:"POST",credentials:"same-origin"})).ok?(_i.toast.success("Agent revoked"),await a()):_i.toast.error("Failed to revoke agent")},[a]);return(0,X.jsxs)("section",{className:"space-y-2",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between",children:[(0,X.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Agents"}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-5 w-5 p-0",title:"Refresh",onClick:()=>void Promise.all([s(),a()]),children:(0,X.jsx)(ew,{className:"h-3 w-3"})})]}),e.length>0&&(0,X.jsxs)("div",{className:"rounded-md border border-amber-500/40 bg-amber-50/10 p-2",children:[(0,X.jsxs)("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-amber-600/80 mb-1 flex items-center gap-1",children:[(0,X.jsx)(IM,{className:"h-3 w-3"}),"Pending (",e.length,")"]}),(0,X.jsx)("ul",{children:e.map(e=>(0,X.jsx)(ID,{reg:e,onApprove:l,onDeny:c},e.registrationId))})]}),(0,X.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-2",children:0===n.length?(0,X.jsxs)("p",{className:"text-xs text-muted-foreground/60 py-1",children:["No registered agents."," ",(0,X.jsx)("span",{className:"text-muted-foreground/40",children:"Agents register via POST /api/agent/register."})]}):(0,X.jsx)("ul",{children:n.map(e=>(0,X.jsx)(IR,{agent:e,onRevoke:d},e.id))})}),(0,X.jsxs)("p",{className:"text-[10px] text-muted-foreground/60 leading-relaxed",children:["Agents authenticate via bearer token + X-Agent-Id header. Use"," ",(0,X.jsx)("code",{className:"bg-muted px-0.5 rounded",children:"POST /api/agent/register"})," to start the TOFU flow."]})]})}function IP({event:e}){var t;let n=e.path.split("/").pop()??e.path,r="string"==typeof e.ref?e.ref:"";return(0,X.jsxs)("div",{className:"flex flex-col gap-0.5 py-1.5 border-b border-border/50 last:border-0",children:[(0,X.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,X.jsx)("span",{className:"text-xs font-mono text-foreground/80 truncate",title:e.path,children:n}),(0,X.jsx)("span",{className:"text-[10px] text-muted-foreground shrink-0",children:function(e){let t=Math.floor(Math.max(0,Date.now()-new Date(e).getTime())/1e3);if(t<60)return`${t}s ago`;let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}(e.at)})]}),(0,X.jsxs)("p",{className:"text-[11px] text-muted-foreground truncate",children:[(0,X.jsx)("span",{className:"text-foreground/60",children:e.by})," ",{"block.replace":"replaced","block.insertAfter":"inserted after","block.insertBefore":"inserted before","block.delete":"deleted","block.append":"appended","block.prepend":"prepended","comment.add":"commented on","comment.reply":"replied to comment","comment.resolve":"resolved comment","comment.reopen":"reopened comment","suggestion.add":"suggested","suggestion.accept":"accepted suggestion","suggestion.reject":"rejected suggestion"}[t=e.type]??t,r&&(0,X.jsxs)(X.Fragment,{children:[" ",(0,X.jsx)("span",{className:"font-mono text-[10px] text-muted-foreground/60",children:r})]})]})]})}var Ij=e.i(199075);let IB="npx skills add anh-chu/wiki-viewer/agents/wiki-viewer-skill";function IF(e){let[t,n]=(0,Q.useState)(!1);return{copied:t,copy:(0,Q.useCallback)(async()=>{await navigator.clipboard.writeText(e()),n(!0),setTimeout(()=>n(!1),1500)},[e])}}function IH({currentPath:e}){let t=Ee(e=>e.isOpen),n=Ee(e=>e.close),r=Ee(e=>e.activity),i=Ee(e=>e.connections),o=Ee(e=>e.rateLimit),s=Ee(e=>e.loadActivity),{copied:a,copy:l}=function(e){let[t,n]=(0,Q.useState)(!1);return{copied:t,copy:(0,Q.useCallback)(async()=>{let t=window.location.origin,r=`# 1. Register
|
|
115
|
+
${t}`:""]})}let t=e.data||{};if(t["image/png"]){let e=`data:image/png;base64,${Mn(t["image/png"]).replace(/\s/g,"")}`;return(0,X.jsx)("img",{src:e,alt:"output",className:"max-w-full rounded-md bg-card p-2"})}if(t["image/jpeg"]){let e=`data:image/jpeg;base64,${Mn(t["image/jpeg"]).replace(/\s/g,"")}`;return(0,X.jsx)("img",{src:e,alt:"output",className:"max-w-full rounded-md bg-card p-2"})}if(t["image/svg+xml"]){let e=Mn(t["image/svg+xml"]);return(0,X.jsx)("div",{className:"max-w-full rounded-md bg-card p-2 overflow-auto",dangerouslySetInnerHTML:{__html:e}})}if(t["text/html"]){let e=Mn(t["text/html"]);return(0,X.jsx)("iframe",{srcDoc:`<!doctype html><html><head><base target="_blank"><style>body{margin:0;padding:8px;font-family:-apple-system,BlinkMacSystemFont,Inter,system-ui,sans-serif;background:#FFF9E9;color:#2A221B;font-size:13px}table{border-collapse:collapse}th,td{border:1px solid #D4C4B0;padding:4px 8px;text-align:left}thead{background:#EFE5CC}</style></head><body>${e}</body></html>`,sandbox:"allow-scripts",className:"w-full bg-[#FFF9E9] rounded-md border border-[#E8DDC5]",style:{height:360}})}return t["text/plain"]?(0,X.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md bg-[#F5EEDC] text-[#2A221B]",children:Mi(Mn(t["text/plain"]))}):null}function Ms({cell:e,language:t}){let n=Mn(e.source),r=(0,Q.useMemo)(()=>(function(e,t){try{let n=t?Mt.highlight(t,e):Mt.highlightAuto(e);return bl(n)}catch{return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}})(n,t),[n,t]),i=e.execution_count??" ",o=(e.outputs?.length??0)>0;return(0,X.jsxs)("div",{className:"grid grid-cols-[60px_1fr] gap-3 mb-5",children:[(0,X.jsxs)("div",{className:"text-right pt-3 select-none font-mono text-[11px] text-[#8B5E3C]",children:["In [",i,"]:"]}),(0,X.jsxs)("div",{children:[(0,X.jsx)("pre",{className:"whitespace-pre overflow-x-auto font-mono text-[13px] leading-relaxed px-4 py-3 rounded-md bg-[#FFF9E9] border border-[#E8DDC5] text-[#2A221B]",children:(0,X.jsx)("code",{dangerouslySetInnerHTML:{__html:r}})}),o&&(0,X.jsxs)("div",{className:"mt-2 grid grid-cols-[60px_1fr] gap-3",children:[(0,X.jsxs)("div",{className:"text-right pt-3 select-none font-mono text-[11px] text-[#8B2E3E]",children:["Out[",i,"]:"]}),(0,X.jsx)("div",{className:"space-y-2",children:e.outputs?.map((e,t)=>(0,X.jsx)(Mo,{output:e},t))})]})]})]})}function Ma({cell:e}){let[t,n]=(0,Q.useState)("");return(0,Q.useEffect)(()=>{let t=!1;return vg(Mn(e.source)).then(e=>{t||n(e)}),()=>{t=!0}},[e.source]),(0,X.jsx)("div",{className:"prose prose-sm max-w-none mb-5 px-1 [&_h1]:font-serif [&_h2]:font-serif [&_h3]:font-serif [&_a]:text-[#8B5E3C] [&_a:hover]:underline [&_code]:bg-[#F5EEDC] [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:rounded [&_code]:text-[#8B2E3E]",dangerouslySetInnerHTML:{__html:t}})}function Ml({cell:e}){return(0,X.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md bg-[#F5EEDC] text-[#2A221B] mb-5",children:Mn(e.source)})}function Mc({path:e}){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!0),[o,s]=(0,Q.useState)(null),[a,l]=(0,Q.useState)(!1),c=`/api/assets/${e}`,d=e.split("/").pop()||e,u=(0,Q.useCallback)(async()=>{i(!0),s(null);try{let e=await fetch(c);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();n(t)}catch(e){s(e instanceof Error?e.message:"Failed to load notebook")}finally{i(!1)}},[c]);(0,Q.useEffect)(()=>{u()},[u]);let h=t?.metadata?.language_info?.name||t?.metadata?.kernelspec?.name||"python",p=t?.cells?.length??0,f=t?.cells?.filter(e=>"code"===e.cell_type).length??0,m=t?.cells?.some(e=>"code"===e.cell_type&&(e.outputs?.length??0)>0)??!1;return(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,X.jsxs)(rF,{path:e,badge:"IPYNB",sublabel:`${p} cells \xb7 ${f} code \xb7 ${h}`,children:[(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{navigator.clipboard.writeText(`jupyter lab ${e}`),l(!0),setTimeout(()=>l(!1),2e3)},title:"Copy: jupyter lab <path>",children:[a?(0,X.jsx)(eo,{className:"h-3.5 w-3.5 text-green-500"}):(0,X.jsx)(_b,{className:"h-3.5 w-3.5"}),a?"Copied":"Copy run cmd"]}),(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let e=document.createElement("a");e.href=c,e.download=d,e.click()},children:[(0,X.jsx)(rj,{className:"h-3.5 w-3.5"}),"Download"]}),(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(c,"_blank"),children:[(0,X.jsx)(kr,{className:"h-3.5 w-3.5"}),"Raw JSON"]})]}),(0,X.jsx)("div",{className:"flex-1 overflow-auto bg-[#F5EEDC]",children:r?(0,X.jsx)("div",{className:"flex items-center justify-center h-full text-[#7A6B5D] text-sm",children:"Loading notebook…"}):o?(0,X.jsxs)("div",{className:"flex items-center justify-center h-full text-[#8B2E3E] text-sm gap-2",children:[(0,X.jsx)(er,{className:"h-4 w-4"})," ",o]}):t?(0,X.jsxs)("div",{className:"max-w-[1100px] mx-auto py-8 px-6",children:[!m&&f>0&&(0,X.jsxs)("div",{className:"mb-6 rounded-md border border-[#E8DDC5] bg-[#FFF9E9] px-4 py-3 text-[13px] text-[#7A6B5D]",children:[(0,X.jsx)("span",{className:"font-semibold text-[#0c0a09]",children:"This notebook hasn't been run yet."})," ","Code and markdown cells display below; outputs appear once the author runs the notebook in Jupyter (or you do, then re-save)."]}),t.cells?.map((e,t)=>"markdown"===e.cell_type?(0,X.jsx)(Ma,{cell:e},t):"raw"===e.cell_type?(0,X.jsx)(Ml,{cell:e},t):(0,X.jsx)(Ms,{cell:e,language:h},t))]}):null})]})}function Md({path:e,extLabel:t,external:n,hideFinder:r}){let i=`/api/assets/${e}`,o=e.split("/").pop()||e,s=async()=>{try{await fetch("/api/system/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})})}catch{}};return(0,X.jsxs)(rF,{path:e,badge:t||void 0,children:[n&&(0,X.jsxs)("a",{href:n.href,target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-center gap-1.5 text-[11px] h-7 px-2.5 rounded-md border border-border hover:bg-accent transition-colors",children:[(0,X.jsx)(kr,{className:"h-3.5 w-3.5"}),n.label]}),!r&&(0,X.jsxs)(tG,{variant:"outline",size:"sm",className:"gap-1.5 text-[11px] h-7",onClick:s,title:"Open in Finder",children:[(0,X.jsx)(eh,{className:"h-3.5 w-3.5"}),"Reveal"]}),!r&&(0,X.jsxs)(tG,{variant:"outline",size:"sm",className:"gap-1.5 text-[11px] h-7",onClick:()=>{let e=document.createElement("a");e.href=i,e.download=o,e.click()},title:"Download original",children:[(0,X.jsx)(rj,{className:"h-3.5 w-3.5"}),"Download"]})]})}function Mu({path:t,title:n}){let r=(0,Q.useRef)(null),[i,o]=(0,Q.useState)(!0),[s,a]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{let n=!1,i=r.current;if(i)return i.innerHTML="",(async()=>{o(!0),a(null);try{let[{renderAsync:r},s]=await Promise.all([e.A(410052),fetch(`/api/assets/${t}`)]);if(n)return;if(!s.ok)throw Error(`Failed to load file (${s.status})`);let a=await s.blob();if(n)return;await r(a,i,void 0,{className:"docx-rendered",inWrapper:!0,ignoreWidth:!1,ignoreHeight:!1,breakPages:!0,renderHeaders:!0,renderFooters:!0,renderFootnotes:!0,experimental:!0,useBase64URL:!0}),n||o(!1)}catch(e){n||(a(e instanceof Error?e.message:"Failed to render document"),o(!1))}})(),()=>{n=!0}},[t]),(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,X.jsx)(Md,{path:t,title:n,extLabel:"DOCX"}),(0,X.jsxs)("div",{className:"flex-1 overflow-y-auto bg-muted/30",children:[i&&!s&&(0,X.jsxs)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:[(0,X.jsx)(eg,{className:"h-5 w-5 animate-spin mr-2"}),"Rendering document…"]}),s&&(0,X.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,X.jsxs)("div",{className:"text-center space-y-2",children:[(0,X.jsx)("p",{className:"text-sm text-destructive",children:s}),(0,X.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try downloading the file and opening it externally."})]})}),(0,X.jsx)("div",{ref:r,className:"docx-viewer-body mx-auto max-w-5xl py-6 px-4"})]})]})}function Mh({path:t,title:n}){let r=(0,Q.useRef)(null),[i,o]=(0,Q.useState)(!0),[s,a]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{let n=!1,i=r.current;if(!i)return;i.innerHTML="";let s=null;return(async()=>{o(!0),a(null);try{let[{init:r},a]=await Promise.all([e.A(355350),fetch(`/api/assets/${t}`)]);if(n)return;if(!a.ok)throw Error(`Failed to load file (${a.status})`);let l=await a.arrayBuffer();if(n)return;let c=i.clientWidth||960,d=Math.round(9*c/16);s=r(i,{width:c,height:d,mode:"list"}),await s.preview(l),n||o(!1)}catch(e){n||(a(e instanceof Error?e.message:"Failed to render presentation"),o(!1))}})(),()=>{n=!0;try{s?.destroy?.()}catch{}}},[t]),(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,X.jsx)(Md,{path:t,title:n,extLabel:"PPTX"}),(0,X.jsxs)("div",{className:"flex-1 overflow-auto bg-muted/30 py-4",children:[i&&!s&&(0,X.jsxs)("div",{className:"h-[60vh] flex items-center justify-center text-muted-foreground",children:[(0,X.jsx)(eg,{className:"h-5 w-5 animate-spin mr-2"}),"Rendering slides…"]}),s&&(0,X.jsx)("div",{className:"h-[60vh] flex items-center justify-center",children:(0,X.jsxs)("div",{className:"text-center space-y-2",children:[(0,X.jsx)("p",{className:"text-sm text-destructive",children:s}),(0,X.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try downloading the file and opening it externally."})]})}),(0,X.jsx)("div",{ref:r,className:"pptx-viewer-body mx-auto max-w-5xl px-4"})]})]})}function Mp({path:t,title:n}){let[r,i]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(0),[a,l]=(0,Q.useState)(!0),[c,d]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let n=!1;return l(!0),d(null),i(null),(async()=>{try{let[r,o]=await Promise.all([e.A(432302),fetch(`/api/assets/${t}`)]);if(n)return;if(!o.ok)throw Error(`Failed to load file (${o.status})`);let a=await o.arrayBuffer();if(n)return;let c=r.read(a,{type:"array",cellDates:!0,cellStyles:!0}),d=c.SheetNames.map(e=>({name:e,html:r.utils.sheet_to_html(c.Sheets[e],{editable:!1})}));if(n)return;i(d),s(0),l(!1)}catch(e){n||(d(e instanceof Error?e.message:"Failed to parse spreadsheet"),l(!1))}})(),()=>{n=!0}},[t]);let u=(0,Q.useMemo)(()=>r?.[o]??null,[r,o]);return(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,X.jsx)(Md,{path:t,title:n,extLabel:"XLSX"}),r&&r.length>1&&(0,X.jsx)("div",{className:"flex items-center gap-0.5 border-b border-border bg-muted/40 px-2 overflow-x-auto scrollbar-none",children:r.map((e,t)=>(0,X.jsx)("button",{type:"button",onClick:()=>s(t),className:tz("px-3 py-1.5 text-[12px] rounded-t whitespace-nowrap transition-colors",t===o?"bg-background text-foreground font-medium border-t border-x border-border -mb-px":"text-muted-foreground hover:text-foreground"),children:e.name},e.name+t))}),(0,X.jsxs)("div",{className:"flex-1 overflow-auto",children:[a&&!c&&(0,X.jsxs)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:[(0,X.jsx)(eg,{className:"h-5 w-5 animate-spin mr-2"}),"Parsing spreadsheet…"]}),c&&(0,X.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,X.jsxs)("div",{className:"text-center space-y-2",children:[(0,X.jsx)("p",{className:"text-sm text-destructive",children:c}),(0,X.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try downloading the file and opening it externally."})]})}),u&&(0,X.jsx)("div",{className:"xlsx-sheet p-3 text-[12px]",dangerouslySetInnerHTML:{__html:u.html}})]})]})}function Mf({path:e,title:t}){let n=`/api/assets/${e}`;return(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,X.jsx)(rF,{path:e,badge:"PDF",children:(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(n,"_blank"),children:[(0,X.jsx)(kr,{className:"h-3.5 w-3.5"}),"Open in new tab"]})}),(0,X.jsx)("iframe",{src:n,className:"flex-1 w-full border-0",title:t})]})}let Mm=en("wrap-text",[["path",{d:"m16 16-2 2 2 2",key:"kkc6pm"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["path",{d:"M3 18h7",key:"sq21v6"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]),Mg=Sv(Me),Mb={".js":"javascript",".cjs":"javascript",".mjs":"javascript",".ts":"typescript",".tsx":"typescript",".jsx":"javascript",".py":"python",".rb":"ruby",".php":"php",".sh":"bash",".bash":"bash",".zsh":"bash",".ps1":"powershell",".css":"css",".scss":"scss",".html":"xml",".json":"json",".jsonc":"json",".yaml":"yaml",".yml":"yaml",".toml":"ini",".ini":"ini",".xml":"xml",".sql":"sql",".graphql":"graphql",".gql":"graphql",".go":"go",".rs":"rust",".swift":"swift",".java":"java",".kt":"kotlin",".kts":"kotlin",".c":"c",".cpp":"cpp",".h":"c",".env":"bash",".txt":"",".text":"",".log":"",".rst":"",".mdx":"markdown"};function My({path:e}){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!0),[o,s]=(0,Q.useState)(!1),[a,l]=(0,Q.useState)(!1),c=`/api/assets/${e}`,d=e.split("/").pop()||e,u=Mb[d.includes(".")?`.${d.split(".").pop()?.toLowerCase()}`:""]??"",h=(0,Q.useCallback)(async()=>{i(!0);try{let e=await fetch(c);if(e.ok){let t=await e.text();n(t)}}catch{}finally{i(!1)}},[c]);(0,Q.useEffect)(()=>{h()},[h]);let p=(0,Q.useMemo)(()=>{if(!t)return[];try{let e=u?Mg.highlight(u,t):Mg.highlightAuto(t);return bl(e).split("\n")}catch{return t.split("\n").map(e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"))}},[t,u]);return(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,X.jsxs)(rF,{path:e,badge:d.includes(".")?d.split(".").pop()?.toUpperCase()??"TEXT":"TEXT",sublabel:u||void 0,children:[(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:`h-7 gap-1.5 text-xs ${o?"bg-muted":""}`,onClick:()=>s(e=>!e),title:o?"Disable line wrap":"Enable line wrap",children:[(0,X.jsx)(Mm,{className:"h-3.5 w-3.5"}),"Wrap"]}),(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{t&&(navigator.clipboard.writeText(t),l(!0),setTimeout(()=>l(!1),2e3))},title:"Copy file contents",children:[a?(0,X.jsx)(eo,{className:"h-3.5 w-3.5 text-green-500"}):(0,X.jsx)(_b,{className:"h-3.5 w-3.5"}),a?"Copied":"Copy"]}),(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let e=document.createElement("a");e.href=c,e.download=d,e.click()},title:"Download file",children:[(0,X.jsx)(rj,{className:"h-3.5 w-3.5"}),"Download"]}),(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(c,"_blank"),children:[(0,X.jsx)(kr,{className:"h-3.5 w-3.5"}),"Raw"]})]}),(0,X.jsx)("div",{className:"flex-1 overflow-auto source-viewer-code bg-[#1e1e1e]",children:r?(0,X.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading..."}):(0,X.jsx)("table",{className:"w-full border-collapse text-[13px] leading-relaxed font-mono",children:(0,X.jsx)("tbody",{children:p.map((e,t)=>(0,X.jsxs)("tr",{className:"hover:bg-white/5",children:[(0,X.jsx)("td",{className:"w-12 pr-4 text-right text-[#858585] select-none align-top sticky left-0 bg-[#1e1e1e]",children:t+1}),(0,X.jsx)("td",{className:`text-[#d4d4d4] pl-2 ${o?"whitespace-pre-wrap break-all":"whitespace-pre"}`,dangerouslySetInnerHTML:{__html:e||" "}})]},t))})})})]})}function Mx({path:e,title:t,src:n,fullscreen:r,onExit:i}){let o=n??`/api/assets/${e}/index.html`,s=r&&i?(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:i,title:"Exit app",children:[(0,X.jsx)(C0,{className:"h-3.5 w-3.5"}),"Exit app"]}):null;return(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,X.jsx)(rF,{path:e,badge:r?"App":void 0,showBreadcrumb:!r,leading:r?(0,X.jsxs)(X.Fragment,{children:[s,(0,X.jsx)("span",{className:"truncate text-[13px] font-medium text-foreground",children:t})]}):null,children:(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(o,"_blank"),children:[(0,X.jsx)(kr,{className:"h-3.5 w-3.5"}),"Open in new tab"]})}),(0,X.jsx)("iframe",{src:o,className:"flex-1 w-full border-0 bg-card",title:t,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-top-navigation-by-user-activation"})]})}let Mv=en("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]),ME=en("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),Mw={stopped:"Stopped",installing:"Installing dependencies…",starting:"Starting…",running:"Running",error:"Error"};function Mk({path:e,title:t}){let[n,r]=(0,Q.useState)("stopped"),[i,o]=(0,Q.useState)(null),[s,a]=(0,Q.useState)([]),[l,c]=(0,Q.useState)(null),[d,u]=(0,Q.useState)(!1),[h,p]=(0,Q.useState)(0),f=(0,Q.useRef)(null),m=(0,Q.useRef)(null),g=`/api/app-proxy/${e}/`,b=()=>{f.current&&(clearInterval(f.current),f.current=null)},y=(0,Q.useCallback)(async()=>{try{let t=await fetch(`/api/wiki/app?path=${encodeURIComponent(e)}`);if(!t.ok)return;let n=await t.json();r(n.status),a(n.logs??[]),n.port&&o(n.port),n.error&&c(n.error),("running"===n.status||"stopped"===n.status||"error"===n.status)&&b()}catch{}},[e]);(0,Q.useEffect)(()=>("installing"===n||"starting"===n?f.current||(f.current=setInterval(y,800)):b(),b),[n,y]),(0,Q.useEffect)(()=>{m.current?.scrollIntoView({behavior:"smooth"})},[s]),(0,Q.useEffect)(()=>{y()},[y]);let x=async()=>{c(null),a([]),r("starting");try{let t=await fetch("/api/wiki/app",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}),n=await t.json();if(!t.ok||n.error){r("error"),c(n.error??"Failed to start");return}n.port&&o(n.port),await y()}catch(e){r("error"),c(String(e))}},v=async()=>{await fetch("/api/wiki/app",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}),r("stopped"),o(null)},E=async()=>{await v(),await x(),p(e=>e+1)};return(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,X.jsxs)(rF,{path:e,badge:"Node app",children:["running"===n&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>p(e=>e+1),children:[(0,X.jsx)(ew,{className:"h-3.5 w-3.5"}),"Refresh"]}),(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(g,"_blank"),children:[(0,X.jsx)(kr,{className:"h-3.5 w-3.5"}),"Open in new tab"]}),(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:E,children:[(0,X.jsx)(ew,{className:"h-3.5 w-3.5"}),"Restart"]}),(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs text-destructive hover:text-destructive",onClick:v,children:[(0,X.jsx)(ME,{className:"h-3.5 w-3.5"}),"Stop"]})]}),(0,X.jsxs)(tG,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>u(e=>!e),children:[(0,X.jsx)(eT,{className:"h-3.5 w-3.5"}),"Logs"]})]}),d&&(0,X.jsxs)("div",{className:"border-b bg-black/90 text-green-400 font-mono text-xs h-40 overflow-auto p-2 shrink-0",children:[0===s.length?(0,X.jsx)("span",{className:"text-muted-foreground",children:"No output yet."}):s.map((e,t)=>(0,X.jsx)("div",{className:"whitespace-pre-wrap leading-5",children:e},t)),(0,X.jsx)("div",{ref:m})]}),(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:["stopped"===n&&(0,X.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-4",children:[(0,X.jsxs)("div",{className:"text-center space-y-1",children:[(0,X.jsx)("p",{className:"text-sm font-medium",children:t}),(0,X.jsx)("p",{className:"text-xs text-muted-foreground",children:"Node.js app — will be started on a local port"})]}),(0,X.jsxs)(tG,{onClick:x,className:"gap-2",children:[(0,X.jsx)(Mv,{className:"h-4 w-4"}),"Launch app"]})]}),("installing"===n||"starting"===n)&&(0,X.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3",children:[(0,X.jsx)(eg,{className:"h-6 w-6 animate-spin text-muted-foreground"}),(0,X.jsx)("p",{className:"text-sm text-muted-foreground",children:Mw[n]}),i&&(0,X.jsxs)("p",{className:"text-xs text-muted-foreground/60",children:["port ",i]})]}),"error"===n&&(0,X.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-6",children:[(0,X.jsx)(er,{className:"h-8 w-8 text-destructive"}),(0,X.jsxs)("div",{className:"text-center space-y-1 max-w-md",children:[(0,X.jsx)("p",{className:"text-sm font-medium text-destructive",children:"Failed to start app"}),(0,X.jsx)("p",{className:"text-xs text-muted-foreground break-words",children:l??"Unknown error"})]}),(0,X.jsxs)(tG,{onClick:x,variant:"outline",className:"gap-2",children:[(0,X.jsx)(ew,{className:"h-4 w-4"}),"Try again"]})]}),"running"===n&&(0,X.jsx)("iframe",{src:g,className:"flex-1 w-full border-0 bg-card",title:t,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-top-navigation-by-user-activation"},h)]})]})}let MT=en("hard-drive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]),MN=en("house",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]),MA=en("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]),MS=en("pin-off",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);function MC({onSelect:e}){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!0),[o,s]=(0,Q.useState)(null),[a,l]=(0,Q.useState)(""),[c,d]=(0,Q.useState)(!1),[u,h]=(0,Q.useState)([]),[p,f]=(0,Q.useState)(!1),m=(0,Q.useRef)(null),g=(0,Q.useRef)(null),b=(0,Q.useCallback)(async(e,t=!0)=>{g.current&&(clearTimeout(g.current),g.current=null),i(!0),s(null);try{let r=await fetch(`/api/system/browse?path=${encodeURIComponent(e)}`);if(!r.ok){let e=await r.json();s(e.error??"Cannot open directory");return}let i=await r.json();n(i),t&&l(i.path)}catch{s("Network error")}finally{i(!1)}},[]);(0,Q.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await fetch("/api/system/config");if(t.ok&&!e){let e=await t.json();h(e.pinnedPaths??[]),await b(e.lastOpenedPath??"");return}}catch{}e||await b("")})(),()=>{e=!0}},[]);let y=async n=>{let r=n??t?.path;if(r){d(!0);try{let t=await fetch("/api/system/set-root",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r})});if(!t.ok){let e=await t.json();s(e.error??"Cannot use that directory");return}e(r)}catch{s("Network error")}finally{d(!1)}}},x=!!t&&u.includes(t.path),v=async()=>{if(t){f(!0);try{let e=x?"unpin":"pin";(await fetch("/api/system/pins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t.path,action:e})})).ok&&h(n=>"pin"===e?[...n,t.path]:n.filter(e=>e!==t.path))}catch{}finally{f(!1)}}},E=async e=>{try{(await fetch("/api/system/pins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,action:"unpin"})})).ok&&h(t=>t.filter(t=>t!==e))}catch{}},w=(t?.path??"").split(/[/\\]/).filter(Boolean).reduce((e,t)=>{let n=e[e.length-1]?.path??"/";return e.push({label:t,path:`${"/"===n?"":n}/${t}`}),e},[{label:"/",path:"/"}]);return(0,X.jsx)("div",{className:"flex flex-1 items-center justify-center bg-background p-4",children:(0,X.jsxs)("div",{className:"flex w-full max-w-xl flex-col gap-4",children:[(0,X.jsxs)("div",{className:"text-center space-y-1",children:[(0,X.jsxs)("div",{className:"flex items-center justify-center gap-2 mb-1",children:[(0,X.jsx)("img",{src:"/logo.svg",alt:"Wiki Viewer",className:"h-8 w-8"}),(0,X.jsx)("span",{className:"text-xl font-semibold tracking-tight",children:"Wiki Viewer"})]}),(0,X.jsx)("h1",{className:"text-xl font-medium",children:"Choose a directory"}),(0,X.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Select the folder wiki-viewer should serve.",(0,X.jsx)("br",{}),"This directory lives on the server — use the browser below."]})]}),(0,X.jsxs)("div",{className:"rounded-lg border bg-card shadow-sm overflow-hidden",children:[(0,X.jsx)("div",{className:"flex items-center gap-2 border-b px-3 py-2 bg-muted",children:(0,X.jsx)("input",{ref:m,className:"flex-1 bg-transparent text-sm outline-none font-mono min-w-0",value:a,onChange:e=>{let t=e.target.value;l(t),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,b(t.trim(),!1)},500)},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),g.current&&(clearTimeout(g.current),g.current=null),b(a.trim())),"Escape"===e.key&&(g.current&&(clearTimeout(g.current),g.current=null),l(t?.path??""),m.current?.blur())},spellCheck:!1,placeholder:"Enter a path…"})}),(0,X.jsx)("div",{className:"flex items-center gap-1 border-b px-3 py-1.5 bg-muted/50 overflow-x-auto shrink-0 min-h-[32px]",children:w.map((e,t)=>(0,X.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[t>0&&(0,X.jsx)(ea,{className:"h-3 w-3 text-muted-foreground/50"}),(0,X.jsx)("button",{type:"button",className:"text-xs hover:text-foreground text-muted-foreground transition-colors rounded px-0.5",onClick:()=>b(e.path),children:0===t?(0,X.jsx)(MT,{className:"h-3.5 w-3.5"}):e.label})]},e.path))}),(0,X.jsx)("div",{className:"max-h-60 overflow-y-auto",children:r?(0,X.jsx)("div",{className:"flex justify-center py-8",children:(0,X.jsx)(eg,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):o?(0,X.jsx)("div",{className:"px-4 py-3 text-sm text-destructive",children:o}):(0,X.jsxs)(X.Fragment,{children:[t?.parent&&(0,X.jsxs)("button",{type:"button",className:"flex w-full items-center gap-2.5 px-3 py-2 text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>b(t.parent),children:[(0,X.jsx)(eu,{className:"h-4 w-4 shrink-0"}),(0,X.jsx)("span",{className:"font-mono text-xs",children:".."})]}),t?.entries.length===0&&(0,X.jsx)("p",{className:"px-4 py-3 text-sm text-muted-foreground/60",children:"No subdirectories"}),t?.entries.map(e=>(0,X.jsxs)("button",{type:"button",className:"flex w-full items-center gap-2.5 px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>b(e.path),children:[(0,X.jsx)(eu,{className:"h-4 w-4 shrink-0 text-warning"}),(0,X.jsx)("span",{className:"truncate",children:e.name})]},e.path))]})}),(0,X.jsxs)("div",{className:"border-t px-3 py-2 flex items-center justify-between gap-2 bg-muted",children:[(0,X.jsxs)("button",{type:"button",className:tz("flex items-center gap-1.5 text-xs transition-colors rounded px-1.5 py-1",x?"text-foreground hover:text-destructive":"text-muted-foreground hover:text-foreground"),title:x?"Unpin this path":"Pin this path for quick access",onClick:v,disabled:p||!t,children:[p?(0,X.jsx)(eg,{className:"h-3.5 w-3.5 animate-spin"}):x?(0,X.jsx)(MS,{className:"h-3.5 w-3.5"}):(0,X.jsx)(MA,{className:"h-3.5 w-3.5"}),x?"Unpin":"Pin"]}),(0,X.jsxs)(tG,{size:"sm",className:"shrink-0 gap-1.5",disabled:!t||c,onClick:()=>y(),children:[c?(0,X.jsx)(eg,{className:"h-3.5 w-3.5 animate-spin"}):(0,X.jsx)(eh,{className:"h-3.5 w-3.5"}),"Select"]})]})]}),u.length>0&&(0,X.jsxs)("div",{className:"rounded-lg border bg-card shadow-sm overflow-hidden",children:[(0,X.jsx)("div",{className:"px-3 py-2 border-b bg-muted",children:(0,X.jsxs)("span",{className:"text-xs font-medium text-muted-foreground flex items-center gap-1.5",children:[(0,X.jsx)(MA,{className:"h-3 w-3"})," Pinned"]})}),(0,X.jsx)("div",{className:"max-h-40 overflow-y-auto",children:u.map(e=>(0,X.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 hover:bg-accent group",children:[(0,X.jsxs)("button",{type:"button",className:"flex-1 flex items-center gap-2 text-sm text-left min-w-0",onClick:()=>b(e),children:[(0,X.jsx)(eu,{className:"h-4 w-4 shrink-0 text-warning"}),(0,X.jsx)("span",{className:"truncate font-mono text-xs",children:e})]}),(0,X.jsx)("button",{type:"button",className:"shrink-0 text-muted-foreground/50 hover:text-destructive opacity-0 group-hover:opacity-100 transition-all",onClick:()=>E(e),title:"Remove pin",children:(0,X.jsx)(eS,{className:"h-3.5 w-3.5"})})]},e))})]}),t?.shortcuts&&t.shortcuts.length>0&&(0,X.jsx)("div",{className:"flex flex-wrap gap-1.5 justify-center",children:t.shortcuts.map(e=>(0,X.jsxs)(tG,{variant:"outline",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>b(e.path),children:["Home"===e.label?(0,X.jsx)(MN,{className:"h-3 w-3"}):(0,X.jsx)(MT,{className:"h-3 w-3"}),e.label]},e.path))})]})})}function M_(e){let t=e+"CollectionProvider",[n,r]=tV(t),[i,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=e=>{let{scope:t,children:n}=e,r=Q.default.useRef(null),o=Q.default.useRef(new Map).current;return(0,X.jsx)(i,{scope:t,itemMap:o,collectionRef:r,children:n})};s.displayName=t;let a=e+"CollectionSlot",l=t0(a),c=Q.default.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=eM(t,o(a,n).collectionRef);return(0,X.jsx)(l,{ref:i,children:r})});c.displayName=a;let d=e+"CollectionItemSlot",u="data-radix-collection-item",h=t0(d),p=Q.default.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,s=Q.default.useRef(null),a=eM(t,s),l=o(d,n);return Q.default.useEffect(()=>(l.itemMap.set(s,{ref:s,...i}),()=>void l.itemMap.delete(s))),(0,X.jsx)(h,{...{[u]:""},ref:a,children:r})});return p.displayName=d,[{Provider:s,Slot:c,ItemSlot:p},function(t){let n=o(e+"CollectionConsumer",t);return Q.default.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${u}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])},r]}var MM=new WeakMap;function MO(e,t){var n,r;let i,o,s;if("at"in Array.prototype)return Array.prototype.at.call(e,t);let a=(n=e,r=t,i=n.length,(s=(o=MI(r))>=0?o:i+o)<0||s>=i?-1:s);return -1===a?void 0:e[a]}function MI(e){return e!=e||0===e?0:Math.trunc(e)}(class e extends Map{#e;constructor(e){super(e),this.#e=[...super.keys()],MM.set(this,!0)}set(e,t){return MM.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r,i=this.has(t),o=this.#e.length,s=MI(e),a=s>=0?s:o+s,l=a<0||a>=o?-1:a;if(l===this.size||i&&l===this.size-1||-1===l)return this.set(t,n),this;let c=this.size+ +!i;s<0&&a++;let d=[...this.#e],u=!1;for(let e=a;e<c;e++)if(a===e){let o=d[e];d[e]===t&&(o=d[e+1]),i&&this.delete(t),r=this.get(o),this.set(t,n)}else{u||d[e-1]!==t||(u=!0);let n=d[u?e:e-1],i=r;r=this.get(n),this.delete(n),this.set(n,i)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return -1===r?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(-1!==(t=-1===t||t===this.size-1?-1:t+1))return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return -1===r?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return void 0!==t&&this.delete(t)}at(e){let t=MO(this.#e,e);if(void 0!==t)return this.get(t)}entryAt(e){let t=MO(this.#e,e);if(void 0!==t)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return MO(this.#e,e)}from(e,t){let n=this.indexOf(e);if(-1===n)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(-1===n)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return -1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=0===r&&1===e.length?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&1===e.length?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){return new e([...this.entries()].sort(t))}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(void 0===t)return r;t<0&&(t+=this.size),void 0!==n&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}});var MD=Q.createContext(void 0);function MR(e){let t=Q.useContext(MD);return e||t||"ltr"}var ML="rovingFocusGroup.onEntryFocus",MP={bubbles:!1,cancelable:!0},Mj="RovingFocusGroup",[MB,MF,MH]=M_(Mj),[MU,Mz]=tV(Mj,[MH]),[M$,MG]=MU(Mj),Mq=Q.forwardRef((e,t)=>(0,X.jsx)(MB.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,X.jsx)(MB.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,X.jsx)(MV,{...e,ref:t})})}));Mq.displayName=Mj;var MV=Q.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:o,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...u}=e,h=Q.useRef(null),p=eM(t,h),f=MR(o),[m,g]=tJ({prop:s,defaultProp:a??null,onChange:l,caller:Mj}),[b,y]=Q.useState(!1),x=t4(c),v=MF(n),E=Q.useRef(!1),[w,k]=Q.useState(0);return Q.useEffect(()=>{let e=h.current;if(e)return e.addEventListener(ML,x),()=>e.removeEventListener(ML,x)},[x]),(0,X.jsx)(M$,{scope:n,orientation:r,dir:f,loop:i,currentTabStopId:m,onItemFocus:Q.useCallback(e=>g(e),[g]),onItemShiftTab:Q.useCallback(()=>y(!0),[]),onFocusableItemAdd:Q.useCallback(()=>k(e=>e+1),[]),onFocusableItemRemove:Q.useCallback(()=>k(e=>e-1),[]),children:(0,X.jsx)(t3.div,{tabIndex:b||0===w?-1:0,"data-orientation":r,...u,ref:p,style:{outline:"none",...e.style},onMouseDown:tq(e.onMouseDown,()=>{E.current=!0}),onFocus:tq(e.onFocus,e=>{let t=!E.current;if(e.target===e.currentTarget&&t&&!b){let t=new CustomEvent(ML,MP);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=v().filter(e=>e.focusable);MX([e.find(e=>e.active),e.find(e=>e.id===m),...e].filter(Boolean).map(e=>e.ref.current),d)}}E.current=!1}),onBlur:tq(e.onBlur,()=>y(!1))})})}),MW="RovingFocusGroupItem",MK=Q.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:o,children:s,...a}=e,l=tX(),c=o||l,d=MG(MW,n),u=d.currentTabStopId===c,h=MF(n),{onFocusableItemAdd:p,onFocusableItemRemove:f,currentTabStopId:m}=d;return Q.useEffect(()=>{if(r)return p(),()=>f()},[r,p,f]),(0,X.jsx)(MB.ItemSlot,{scope:n,id:c,focusable:r,active:i,children:(0,X.jsx)(t3.span,{tabIndex:u?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:tq(e.onMouseDown,e=>{r?d.onItemFocus(c):e.preventDefault()}),onFocus:tq(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:tq(e.onKeyDown,e=>{if("Tab"===e.key&&e.shiftKey)return void d.onItemShiftTab();if(e.target!==e.currentTarget)return;let t=function(e,t,n){var r;let i=(r=e.key,"rtl"!==n?r:"ArrowLeft"===r?"ArrowRight":"ArrowRight"===r?"ArrowLeft":r);if(!("vertical"===t&&["ArrowLeft","ArrowRight"].includes(i))&&!("horizontal"===t&&["ArrowUp","ArrowDown"].includes(i)))return MY[i]}(e,d.orientation,d.dir);if(void 0!==t){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let i=h().filter(e=>e.focusable).map(e=>e.ref.current);if("last"===t)i.reverse();else if("prev"===t||"next"===t){var n,r;"prev"===t&&i.reverse();let o=i.indexOf(e.currentTarget);i=d.loop?(n=i,r=o+1,n.map((e,t)=>n[(r+t)%n.length])):i.slice(o+1)}setTimeout(()=>MX(i))}}),children:"function"==typeof s?s({isCurrentTabStop:u,hasTabStop:null!=m}):s})})});MK.displayName=MW;var MY={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function MX(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}var MQ=["Enter"," "],MJ=["ArrowUp","PageDown","End"],MZ=["ArrowDown","PageUp","Home",...MJ],M0={ltr:[...MQ,"ArrowRight"],rtl:[...MQ,"ArrowLeft"]},M1={ltr:["ArrowLeft"],rtl:["ArrowRight"]},M2="Menu",[M3,M5,M4]=M_(M2),[M6,M9]=tV(M2,[M4,S8,Mz]),M7=S8(),M8=Mz(),[Oe,Ot]=M6(M2),[On,Or]=M6(M2),Oi=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:o,modal:s=!0}=e,a=M7(t),[l,c]=Q.useState(null),d=Q.useRef(!1),u=t4(o),h=MR(i);return Q.useEffect(()=>{let e=()=>{d.current=!0,document.addEventListener("pointerdown",t,{capture:!0,once:!0}),document.addEventListener("pointermove",t,{capture:!0,once:!0})},t=()=>d.current=!1;return document.addEventListener("keydown",e,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointermove",t,{capture:!0})}},[]),(0,X.jsx)(Cn,{...a,children:(0,X.jsx)(Oe,{scope:t,open:n,onOpenChange:u,content:l,onContentChange:c,children:(0,X.jsx)(On,{scope:t,onClose:Q.useCallback(()=>u(!1),[u]),isUsingKeyboardRef:d,dir:h,modal:s,children:r})})})};Oi.displayName=M2;var Oo=Q.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=M7(n);return(0,X.jsx)(Ci,{...i,...r,ref:t})});Oo.displayName="MenuAnchor";var Os="MenuPortal",[Oa,Ol]=M6(Os,{forceMount:void 0}),Oc=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,o=Ot(Os,t);return(0,X.jsx)(Oa,{scope:t,forceMount:n,children:(0,X.jsx)(nu,{present:n||o.open,children:(0,X.jsx)(nd,{asChild:!0,container:i,children:r})})})};Oc.displayName=Os;var Od="MenuContent",[Ou,Oh]=M6(Od),Op=Q.forwardRef((e,t)=>{let n=Ol(Od,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=Ot(Od,e.__scopeMenu),s=Or(Od,e.__scopeMenu);return(0,X.jsx)(M3.Provider,{scope:e.__scopeMenu,children:(0,X.jsx)(nu,{present:r||o.open,children:(0,X.jsx)(M3.Slot,{scope:e.__scopeMenu,children:s.modal?(0,X.jsx)(Of,{...i,ref:t}):(0,X.jsx)(Om,{...i,ref:t})})})})}),Of=Q.forwardRef((e,t)=>{let n=Ot(Od,e.__scopeMenu),r=Q.useRef(null),i=eM(t,r);return Q.useEffect(()=>{let e=r.current;if(e)return n6(e)},[]),(0,X.jsx)(Ob,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:tq(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Om=Q.forwardRef((e,t)=>{let n=Ot(Od,e.__scopeMenu);return(0,X.jsx)(Ob,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Og=t0("MenuContent.ScrollLock"),Ob=Q.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:h,onDismiss:p,disableOutsideScroll:f,...m}=e,g=Ot(Od,n),b=Or(Od,n),y=M7(n),x=M8(n),v=M5(n),[E,w]=Q.useState(null),k=Q.useRef(null),T=eM(t,k,g.onContentChange),N=Q.useRef(0),A=Q.useRef(""),S=Q.useRef(0),C=Q.useRef(null),_=Q.useRef("right"),M=Q.useRef(0),O=f?nZ:Q.Fragment;Q.useEffect(()=>()=>window.clearTimeout(N.current),[]),nf();let I=Q.useCallback(e=>{var t,n;return _.current===C.current?.side&&(t=e,!!(n=C.current?.area)&&function(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,o=t.length-1;e<t.length;o=e++){let s=t[e],a=t[o],l=s.x,c=s.y,d=a.x,u=a.y;c>r!=u>r&&n<(d-l)*(r-c)/(u-c)+l&&(i=!i)}return i}({x:t.clientX,y:t.clientY},n))},[]);return(0,X.jsx)(Ou,{scope:n,searchRef:A,onItemEnter:Q.useCallback(e=>{I(e)&&e.preventDefault()},[I]),onItemLeave:Q.useCallback(e=>{I(e)||(k.current?.focus(),w(null))},[I]),onTriggerLeave:Q.useCallback(e=>{I(e)&&e.preventDefault()},[I]),pointerGraceTimerRef:S,onPointerGraceIntentChange:Q.useCallback(e=>{C.current=e},[]),children:(0,X.jsx)(O,{...f?{as:Og,allowPinchZoom:!0}:void 0,children:(0,X.jsx)(ni,{asChild:!0,trapped:i,onMountAutoFocus:tq(o,e=>{e.preventDefault(),k.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:(0,X.jsx)(t7,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:h,onDismiss:p,children:(0,X.jsx)(Mq,{asChild:!0,...x,dir:b.dir,orientation:"vertical",loop:r,currentTabStopId:E,onCurrentTabStopIdChange:w,onEntryFocus:tq(l,e=>{b.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,X.jsx)(Cl,{role:"menu","aria-orientation":"vertical","data-state":O$(g.open),"data-radix-menu-content":"",dir:b.dir,...y,...m,ref:T,style:{outline:"none",...m.style},onKeyDown:tq(m.onKeyDown,e=>{let t=e.target.closest("[data-radix-menu-content]")===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=1===e.key.length;if(t){var i;let t,o,s,a,l,c;"Tab"===e.key&&e.preventDefault(),!n&&r&&(i=e.key,t=A.current+i,o=v().filter(e=>!e.disabled),s=document.activeElement,a=o.find(e=>e.ref.current===s)?.textValue,l=function(e,t,n){var r;let i=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,o=n?e.indexOf(n):-1,s=(r=Math.max(o,0),e.map((t,n)=>e[(r+n)%e.length]));1===i.length&&(s=s.filter(e=>e!==n));let a=s.find(e=>e.toLowerCase().startsWith(i.toLowerCase()));return a!==n?a:void 0}(o.map(e=>e.textValue),t,a),c=o.find(e=>e.textValue===l)?.ref.current,function e(t){A.current=t,window.clearTimeout(N.current),""!==t&&(N.current=window.setTimeout(()=>e(""),1e3))}(t),c&&setTimeout(()=>c.focus()))}let o=k.current;if(e.target!==o||!MZ.includes(e.key))return;e.preventDefault();let s=v().filter(e=>!e.disabled).map(e=>e.ref.current);MJ.includes(e.key)&&s.reverse(),function(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}(s)}),onBlur:tq(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(N.current),A.current="")}),onPointerMove:tq(e.onPointerMove,OV(e=>{let t=e.target,n=M.current!==e.clientX;e.currentTarget.contains(t)&&n&&(_.current=e.clientX>M.current?"right":"left",M.current=e.clientX)}))})})})})})})});Op.displayName=Od;var Oy=Q.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,X.jsx)(t3.div,{role:"group",...r,ref:t})});Oy.displayName="MenuGroup";var Ox=Q.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,X.jsx)(t3.div,{...r,ref:t})});Ox.displayName="MenuLabel";var Ov="MenuItem",OE="menu.itemSelect",Ow=Q.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,o=Q.useRef(null),s=Or(Ov,e.__scopeMenu),a=Oh(Ov,e.__scopeMenu),l=eM(t,o),c=Q.useRef(!1);return(0,X.jsx)(Ok,{...i,ref:l,disabled:n,onClick:tq(e.onClick,()=>{let e=o.current;if(!n&&e){let t=new CustomEvent(OE,{bubbles:!0,cancelable:!0});e.addEventListener(OE,e=>r?.(e),{once:!0}),t5(e,t),t.defaultPrevented?c.current=!1:s.onClose()}}),onPointerDown:t=>{e.onPointerDown?.(t),c.current=!0},onPointerUp:tq(e.onPointerUp,e=>{c.current||e.currentTarget?.click()}),onKeyDown:tq(e.onKeyDown,e=>{let t=""!==a.searchRef.current;n||t&&" "===e.key||MQ.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});Ow.displayName=Ov;var Ok=Q.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...o}=e,s=Oh(Ov,n),a=M8(n),l=Q.useRef(null),c=eM(t,l),[d,u]=Q.useState(!1),[h,p]=Q.useState("");return Q.useEffect(()=>{let e=l.current;e&&p((e.textContent??"").trim())},[o.children]),(0,X.jsx)(M3.ItemSlot,{scope:n,disabled:r,textValue:i??h,children:(0,X.jsx)(MK,{asChild:!0,...a,focusable:!r,children:(0,X.jsx)(t3.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...o,ref:c,onPointerMove:tq(e.onPointerMove,OV(e=>{r?s.onItemLeave(e):(s.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:tq(e.onPointerLeave,OV(e=>s.onItemLeave(e))),onFocus:tq(e.onFocus,()=>u(!0)),onBlur:tq(e.onBlur,()=>u(!1))})})})}),OT=Q.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,X.jsx)(OI,{scope:e.__scopeMenu,checked:n,children:(0,X.jsx)(Ow,{role:"menuitemcheckbox","aria-checked":OG(n)?"mixed":n,...i,ref:t,"data-state":Oq(n),onSelect:tq(i.onSelect,()=>r?.(!!OG(n)||!n),{checkForDefaultPrevented:!1})})})});OT.displayName="MenuCheckboxItem";var ON="MenuRadioGroup",[OA,OS]=M6(ON,{value:void 0,onValueChange:()=>{}}),OC=Q.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,o=t4(r);return(0,X.jsx)(OA,{scope:e.__scopeMenu,value:n,onValueChange:o,children:(0,X.jsx)(Oy,{...i,ref:t})})});OC.displayName=ON;var O_="MenuRadioItem",OM=Q.forwardRef((e,t)=>{let{value:n,...r}=e,i=OS(O_,e.__scopeMenu),o=n===i.value;return(0,X.jsx)(OI,{scope:e.__scopeMenu,checked:o,children:(0,X.jsx)(Ow,{role:"menuitemradio","aria-checked":o,...r,ref:t,"data-state":Oq(o),onSelect:tq(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});OM.displayName=O_;var OO="MenuItemIndicator",[OI,OD]=M6(OO,{checked:!1}),OR=Q.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,o=OD(OO,n);return(0,X.jsx)(nu,{present:r||OG(o.checked)||!0===o.checked,children:(0,X.jsx)(t3.span,{...i,ref:t,"data-state":Oq(o.checked)})})});OR.displayName=OO;var OL=Q.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,X.jsx)(t3.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});OL.displayName="MenuSeparator";var OP=Q.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=M7(n);return(0,X.jsx)(Cu,{...i,...r,ref:t})});OP.displayName="MenuArrow";var[Oj,OB]=M6("MenuSub"),OF="MenuSubTrigger",OH=Q.forwardRef((e,t)=>{let n=Ot(OF,e.__scopeMenu),r=Or(OF,e.__scopeMenu),i=OB(OF,e.__scopeMenu),o=Oh(OF,e.__scopeMenu),s=Q.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=o,c={__scopeMenu:e.__scopeMenu},d=Q.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);return Q.useEffect(()=>d,[d]),Q.useEffect(()=>{let e=a.current;return()=>{window.clearTimeout(e),l(null)}},[a,l]),(0,X.jsx)(Oo,{asChild:!0,...c,children:(0,X.jsx)(Ok,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":O$(n.open),...e,ref:e_(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),e.disabled||t.defaultPrevented||(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:tq(e.onPointerMove,OV(t=>{o.onItemEnter(t),!t.defaultPrevented&&(e.disabled||n.open||s.current||(o.onPointerGraceIntentChange(null),s.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100)))})),onPointerLeave:tq(e.onPointerLeave,OV(e=>{d();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i="right"===r,s=t[i?"left":"right"],l=t[i?"right":"left"];o.onPointerGraceIntentChange({area:[{x:e.clientX+(i?-5:5),y:e.clientY},{x:s,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:s,y:t.bottom}],side:r}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(e),e.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:tq(e.onKeyDown,t=>{let i=""!==o.searchRef.current;e.disabled||i&&" "===t.key||M0[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});OH.displayName=OF;var OU="MenuSubContent",Oz=Q.forwardRef((e,t)=>{let n=Ol(Od,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=Ot(Od,e.__scopeMenu),s=Or(Od,e.__scopeMenu),a=OB(OU,e.__scopeMenu),l=Q.useRef(null),c=eM(t,l);return(0,X.jsx)(M3.Provider,{scope:e.__scopeMenu,children:(0,X.jsx)(nu,{present:r||o.open,children:(0,X.jsx)(M3.Slot,{scope:e.__scopeMenu,children:(0,X.jsx)(Ob,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:c,align:"start",side:"rtl"===s.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{s.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:tq(e.onFocusOutside,e=>{e.target!==a.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:tq(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:tq(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=M1[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),a.trigger?.focus(),e.preventDefault())})})})})})});function O$(e){return e?"open":"closed"}function OG(e){return"indeterminate"===e}function Oq(e){return OG(e)?"indeterminate":e?"checked":"unchecked"}function OV(e){return t=>"mouse"===t.pointerType?e(t):void 0}Oz.displayName=OU;var OW="DropdownMenu",[OK,OY]=tV(OW,[M9]),OX=M9(),[OQ,OJ]=OK(OW),OZ=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:o,onOpenChange:s,modal:a=!0}=e,l=OX(t),c=Q.useRef(null),[d,u]=tJ({prop:i,defaultProp:o??!1,onChange:s,caller:OW});return(0,X.jsx)(OQ,{scope:t,triggerId:tX(),triggerRef:c,contentId:tX(),open:d,onOpenChange:u,onOpenToggle:Q.useCallback(()=>u(e=>!e),[u]),modal:a,children:(0,X.jsx)(Oi,{...l,open:d,onOpenChange:u,dir:r,modal:a,children:n})})};OZ.displayName=OW;var O0="DropdownMenuTrigger",O1=Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,o=OJ(O0,n),s=OX(n);return(0,X.jsx)(Oo,{asChild:!0,...s,children:(0,X.jsx)(t3.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:e_(t,o.triggerRef),onPointerDown:tq(e.onPointerDown,e=>{!r&&0===e.button&&!1===e.ctrlKey&&(o.onOpenToggle(),o.open||e.preventDefault())}),onKeyDown:tq(e.onKeyDown,e=>{!r&&(["Enter"," "].includes(e.key)&&o.onOpenToggle(),"ArrowDown"===e.key&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(e.key)&&e.preventDefault())})})})});O1.displayName=O0;var O2=e=>{let{__scopeDropdownMenu:t,...n}=e,r=OX(t);return(0,X.jsx)(Oc,{...r,...n})};O2.displayName="DropdownMenuPortal";var O3="DropdownMenuContent",O5=Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OJ(O3,n),o=OX(n),s=Q.useRef(!1);return(0,X.jsx)(Op,{id:i.contentId,"aria-labelledby":i.triggerId,...o,...r,ref:t,onCloseAutoFocus:tq(e.onCloseAutoFocus,e=>{s.current||i.triggerRef.current?.focus(),s.current=!1,e.preventDefault()}),onInteractOutside:tq(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey,r=2===t.button||n;(!i.modal||r)&&(s.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});O5.displayName=O3,Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(Oy,{...i,...r,ref:t})}).displayName="DropdownMenuGroup";var O4=Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(Ox,{...i,...r,ref:t})});O4.displayName="DropdownMenuLabel";var O6=Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(Ow,{...i,...r,ref:t})});O6.displayName="DropdownMenuItem";var O9=Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(OT,{...i,...r,ref:t})});O9.displayName="DropdownMenuCheckboxItem",Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(OC,{...i,...r,ref:t})}).displayName="DropdownMenuRadioGroup";var O7=Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(OM,{...i,...r,ref:t})});O7.displayName="DropdownMenuRadioItem";var O8=Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(OR,{...i,...r,ref:t})});O8.displayName="DropdownMenuItemIndicator";var Ie=Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(OL,{...i,...r,ref:t})});Ie.displayName="DropdownMenuSeparator",Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(OP,{...i,...r,ref:t})}).displayName="DropdownMenuArrow";var It=Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(OH,{...i,...r,ref:t})});It.displayName="DropdownMenuSubTrigger";var In=Q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=OX(n);return(0,X.jsx)(Oz,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});In.displayName="DropdownMenuSubContent";let Ir=en("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);Q.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,X.jsxs)(It,{ref:i,className:tz("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,(0,X.jsx)(ea,{className:"ml-auto h-4 w-4"})]})).displayName=It.displayName,Q.forwardRef(({className:e,...t},n)=>(0,X.jsx)(In,{ref:n,className:tz("z-50 min-w-[8rem] overflow-hidden rounded-sm border bg-popover p-1 text-popover-foreground shadow-golden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t})).displayName=In.displayName;let Ii=Q.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,X.jsx)(O2,{children:(0,X.jsx)(O5,{ref:r,sideOffset:t,className:tz("z-50 min-w-[8rem] overflow-hidden rounded-sm border bg-popover p-1 text-popover-foreground shadow-golden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Ii.displayName=O5.displayName;let Io=Q.forwardRef(({className:e,inset:t,...n},r)=>(0,X.jsx)(O6,{ref:r,className:tz("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Io.displayName=O6.displayName,Q.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,X.jsxs)(O9,{ref:i,className:tz("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[(0,X.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,X.jsx)(O8,{children:(0,X.jsx)(eo,{className:"h-4 w-4"})})}),t]})).displayName=O9.displayName,Q.forwardRef(({className:e,children:t,...n},r)=>(0,X.jsxs)(O7,{ref:r,className:tz("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[(0,X.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,X.jsx)(O8,{children:(0,X.jsx)(Ir,{className:"h-2 w-2 fill-current"})})}),t]})).displayName=O7.displayName,Q.forwardRef(({className:e,inset:t,...n},r)=>(0,X.jsx)(O4,{ref:r,className:tz("px-2 py-1.5 text-sm font-normal",t&&"pl-8",e),...n})).displayName=O4.displayName,Q.forwardRef(({className:e,...t},n)=>(0,X.jsx)(Ie,{ref:n,className:tz("-mx-1 my-1 h-px bg-muted",e),...t})).displayName=Ie.displayName;let Is=en("moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]),Ia=en("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"}]]);var Il=e.i(917356);function Ic({className:e}){let{resolvedTheme:t,setTheme:n}=(0,Il.useTheme)();return(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:`h-7 w-7 p-0 ${e??""}`,title:"dark"===t?"Switch to light":"Switch to dark",onClick:()=>n("dark"===t?"light":"dark"),children:"dark"===t?(0,X.jsx)(Ia,{className:"h-3.5 w-3.5"}):(0,X.jsx)(Is,{className:"h-3.5 w-3.5"})})}let Id=Q.forwardRef(({className:e,...t},n)=>(0,X.jsx)(rc,{ref:n,className:tz("fixed inset-0 z-40 bg-black/40 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),...t}));Id.displayName="SheetOverlay";let Iu={bottom:"inset-x-0 bottom-0 data-[state=open]:slide-in-from-bottom data-[state=closed]:slide-out-to-bottom",top:"inset-x-0 top-0 data-[state=open]:slide-in-from-top data-[state=closed]:slide-out-to-top",left:"inset-y-0 left-0 data-[state=open]:slide-in-from-left data-[state=closed]:slide-out-to-left",right:"inset-y-0 right-0 data-[state=open]:slide-in-from-right data-[state=closed]:slide-out-to-right"},Ih=Q.forwardRef(({side:e="bottom",showClose:t=!1,className:n,children:r,...i},o)=>(0,X.jsxs)(ra,{children:[(0,X.jsx)(Id,{}),(0,X.jsxs)(rp,{ref:o,className:tz("fixed z-50 bg-background shadow-golden transition-all ease-in-out","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:duration-300",Iu[e],n),...i,children:[r,t&&(0,X.jsxs)(rw,{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",children:[(0,X.jsx)(eS,{className:"h-4 w-4"}),(0,X.jsx)("span",{className:"sr-only",children:"Close"})]})]})]}));Ih.displayName="SheetContent",Q.forwardRef(({className:e,...t},n)=>(0,X.jsx)(ry,{ref:n,className:tz("text-sm font-medium leading-none tracking-tight",e),...t})).displayName="SheetTitle",Q.forwardRef(({className:e,...t},n)=>(0,X.jsx)(rv,{ref:n,className:tz("text-sm text-muted-foreground",e),...t})).displayName="SheetDescription";var Ip=e.i(199075);function If(e){return e.split(/[\n,]/).map(e=>e.trim()).filter(Boolean)}function Im({open:e,onOpenChange:t}){let[n,r]=(0,Q.useState)(!1),[i,o]=(0,Q.useState)(!1),[s,a]=(0,Q.useState)(null),[l,c]=(0,Q.useState)("env"),[d,u]=(0,Q.useState)(""),[h,p]=(0,Q.useState)(""),[f,m]=(0,Q.useState)(null),{data:g}=Ip.authClient.useSession(),b=(0,Q.useCallback)(async()=>{r(!0),a(null);try{let e=await fetch("/api/system/auth-settings");if(!e.ok)throw Error("Failed to load settings");let t=await e.json();u(t.allowedEmails.join("\n")),p(t.allowedDomains.join("\n")),c(t.source),m("number"==typeof t.rateLimit?t.rateLimit:null)}catch(e){a(e instanceof Error?e.message:"Failed to load")}finally{r(!1)}},[]);async function y(){o(!0),a(null);try{let e=await fetch("/api/system/auth-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({allowedEmails:If(d),allowedDomains:If(h)})}),n=await e.json();if(!e.ok){a(n.error??"Save failed"),_o(n.error??"Save failed");return}n.source&&c(n.source),t(!1)}catch{a("Save failed")}finally{o(!1)}}(0,Q.useEffect)(()=>{e&&b()},[e,b]);let x=0===If(d).length&&0===If(h).length;return(0,X.jsx)(rn,{open:e,onOpenChange:t,children:(0,X.jsxs)(Ih,{side:"right",className:"w-80 sm:max-w-md flex flex-col border-l border-border p-0",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[(0,X.jsx)("span",{className:"text-sm font-semibold",children:"Settings"}),(0,X.jsxs)(rw,{className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent focus:outline-none focus:ring-2 focus:ring-ring",children:[(0,X.jsx)(eS,{className:"h-3.5 w-3.5"}),(0,X.jsx)("span",{className:"sr-only",children:"Close"})]})]}),n?(0,X.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,X.jsx)(eg,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,X.jsxs)("div",{className:"flex-1 space-y-5 overflow-y-auto px-4 py-4",children:[g?.user&&(0,X.jsxs)("section",{className:"space-y-2",children:[(0,X.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Account"}),(0,X.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border bg-muted/40 p-3",children:[(0,X.jsxs)("div",{className:"text-sm min-w-0",children:[(0,X.jsx)("div",{className:"font-medium truncate",children:g.user.name}),(0,X.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:g.user.email})]}),(0,X.jsx)("button",{type:"button",onClick:async()=>{await Ip.authClient.signOut(),window.location.href="/signin"},className:"ml-2 shrink-0 text-xs px-2 py-1 rounded border border-border hover:bg-accent",children:"Sign out"})]})]}),(0,X.jsxs)("section",{className:"space-y-2",children:[(0,X.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Signup allowlist"}),(0,X.jsxs)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:["Control who can create an account. Leave both lists empty to allow any email. Saving here overrides the"," ",(0,X.jsx)("code",{className:"bg-muted px-0.5 rounded",children:"AUTH_ALLOWED_EMAILS"})," ","and"," ",(0,X.jsx)("code",{className:"bg-muted px-0.5 rounded",children:"AUTH_ALLOWED_DOMAIN"})," ","environment variables."]}),"env"===l&&(0,X.jsxs)("div",{className:"flex items-start gap-2 rounded-md bg-muted px-3 py-2 text-xs text-muted-foreground",children:[(0,X.jsx)(er,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}),(0,X.jsx)("span",{children:"Current values come from environment variables. Saving moves the allowlist into config and takes precedence going forward."})]}),(0,X.jsxs)("div",{className:"space-y-1.5",children:[(0,X.jsx)("label",{htmlFor:"allowed-emails",className:"text-sm font-medium",children:"Allowed emails"}),(0,X.jsx)("p",{className:"text-xs text-muted-foreground",children:"One per line (or comma-separated). Exact match, case-insensitive."}),(0,X.jsx)("textarea",{id:"allowed-emails",value:d,onChange:e=>u(e.target.value),spellCheck:!1,rows:5,placeholder:"alice@example.com bob@example.com",className:"w-full resize-y rounded-md border border-border bg-background px-3 py-2 font-mono text-sm outline-none focus:ring-2 focus:ring-primary"})]}),(0,X.jsxs)("div",{className:"space-y-1.5",children:[(0,X.jsx)("label",{htmlFor:"allowed-domains",className:"text-sm font-medium",children:"Allowed domains"}),(0,X.jsx)("p",{className:"text-xs text-muted-foreground",children:"One per line (or comma-separated). Matches any email at that domain."}),(0,X.jsx)("textarea",{id:"allowed-domains",value:h,onChange:e=>p(e.target.value),spellCheck:!1,rows:4,placeholder:"example.com trusted.org",className:"w-full resize-y rounded-md border border-border bg-background px-3 py-2 font-mono text-sm outline-none focus:ring-2 focus:ring-primary"})]}),x&&(0,X.jsxs)("div",{className:"flex items-start gap-2 rounded-md bg-warning-soft px-3 py-2 text-xs text-warning-ink",children:[(0,X.jsx)(er,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}),(0,X.jsx)("span",{children:"Both lists are empty. Anyone with the signup URL can create an account."})]}),s&&(0,X.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[(0,X.jsx)(er,{className:"h-3.5 w-3.5 shrink-0"}),s]})]}),(0,X.jsxs)("section",{className:"space-y-2",children:[(0,X.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Agent rate limit"}),(0,X.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,X.jsx)("span",{className:"text-muted-foreground",children:"Per agent"}),(0,X.jsx)("span",{className:"font-mono",children:null!==f?`${f} ops/min`:"--"})]}),(0,X.jsxs)("p",{className:"text-[10px] text-muted-foreground/60",children:["Override with ",(0,X.jsx)("code",{className:"bg-muted px-0.5 rounded",children:"AGENT_RATE_LIMIT"})," env var."]})]})]})]}),(0,X.jsxs)("div",{className:"flex items-center justify-end gap-2 border-t border-border px-4 py-3 shrink-0",children:[(0,X.jsx)(tG,{size:"sm",variant:"ghost",onClick:()=>t(!1),disabled:i,children:"Cancel"}),(0,X.jsxs)(tG,{size:"sm",onClick:y,disabled:i||n,className:"gap-1.5",children:[i&&(0,X.jsx)(eg,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]})]})})}let Ig=Q.forwardRef(({className:e,...t},n)=>(0,X.jsx)("div",{ref:n,className:tz("rounded-md border border-border bg-card text-card-foreground shadow-e-2",e),...t}));Ig.displayName="Card",Q.forwardRef(({className:e,...t},n)=>(0,X.jsx)("div",{ref:n,className:tz("flex flex-col space-y-1.5 p-6",e),...t})).displayName="CardHeader",Q.forwardRef(({className:e,...t},n)=>(0,X.jsx)("div",{ref:n,className:tz("text-lg font-normal leading-none tracking-tight",e),...t})).displayName="CardTitle",Q.forwardRef(({className:e,...t},n)=>(0,X.jsx)("div",{ref:n,className:tz("text-sm text-muted-foreground",e),...t})).displayName="CardDescription",Q.forwardRef(({className:e,...t},n)=>(0,X.jsx)("div",{ref:n,className:tz("p-6 pt-0",e),...t})).displayName="CardContent";let Ib=eH("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 Iy({className:e,variant:t,...n}){return(0,X.jsx)("div",{className:tz(Ib({variant:t}),e),...n})}let Ix=new Set(["title","type","status","created","updated","date","tags","sources","private","supersedes","superseded_by"]);function Iv({data:e}){let[t,n]=(0,Q.useState)(!1),r=Object.keys(e);if(0===r.length)return null;let i="string"==typeof e.title?e.title:null,o="string"==typeof e.type?e.type:null,s="string"==typeof e.status?e.status:null,a="string"==typeof e.created?e.created:null,l="string"==typeof e.updated?e.updated:null,c=!0===e.private,d=Array.isArray(e.tags)?e.tags:[],u=Array.isArray(e.sources)?e.sources:[],h="string"==typeof e.superseded_by?e.superseded_by:null,p=r.filter(e=>!Ix.has(e));return(0,X.jsxs)("div",{className:"mb-6 rounded-sm border bg-card/40 px-4 py-3 text-xs",children:[i&&(0,X.jsx)("div",{className:"mb-2 text-base font-normal text-foreground",children:i}),(0,X.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5 text-muted-foreground",children:[o&&(0,X.jsx)(Iy,{variant:"outline",className:"font-normal",children:o}),s&&(0,X.jsx)(Iy,{variant:"outline",className:"font-normal",children:s}),c&&(0,X.jsx)(Iy,{variant:"outline",className:"border-warning-ink/40 font-normal text-warning-ink",children:"private"}),h&&(0,X.jsxs)(Iy,{variant:"outline",className:"border-destructive/40 font-normal text-destructive",children:["superseded → ",h]}),a&&(0,X.jsxs)("span",{children:[(0,X.jsx)("span",{className:"opacity-60",children:"created"})," ",(0,X.jsx)("span",{className:"text-foreground/80",children:a})]}),l&&l!==a&&(0,X.jsxs)("span",{children:[(0,X.jsx)("span",{className:"opacity-60",children:"updated"})," ",(0,X.jsx)("span",{className:"text-foreground/80",children:l})]})]}),d.length>0&&(0,X.jsx)("div",{className:"mt-2 flex flex-wrap gap-1",children:d.map(e=>(0,X.jsxs)(Iy,{variant:"secondary",className:"font-normal text-[11px]",children:["#",e]},e))}),u.length>0&&(0,X.jsxs)("div",{className:"mt-2",children:[(0,X.jsx)("span",{className:"opacity-60",children:"sources:"})," ",(0,X.jsx)("span",{className:"text-foreground/80",children:u.join(", ")})]}),p.length>0&&(0,X.jsxs)("div",{className:"mt-2 border-t pt-2",children:[(0,X.jsxs)("button",{type:"button",onClick:()=>n(e=>!e),className:"flex items-center gap-1 text-muted-foreground hover:text-foreground",children:[t?(0,X.jsx)(es,{className:"h-3 w-3"}):(0,X.jsx)(ea,{className:"h-3 w-3"}),(0,X.jsxs)("span",{children:[p.length," more field",1===p.length?"":"s"]})]}),t&&(0,X.jsx)("dl",{className:"mt-1.5 grid grid-cols-[max-content_1fr] gap-x-3 gap-y-0.5",children:p.map(t=>(0,X.jsxs)(Q.Fragment,{children:[(0,X.jsx)("dt",{className:"opacity-60",children:t}),(0,X.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[t])})]},t))})]})]})}function IE({markdown:e,pagePath:t,onNavigate:n}){let[r,i]=(0,Q.useState)(""),o=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let n=!1;return vg(e,{pagePath:t,sanitize:!0}).then(e=>{n||i(e)}),()=>{n=!0}},[e,t]);let s=(0,Q.useCallback)(e=>{let t=e.target.closest("a");if(!t)return;if("true"===t.dataset.wikiLink){e.preventDefault();let r=t.dataset.slug??"";if(!r)return;let i=Ex.getState().getDir(r);if(!i)return;n("root"===i?`${r}.md`:`${i}/${r}.md`,t.dataset.anchor??null);return}let r=t.getAttribute("href")??"";if(/^https?:\/\//.test(r)){t.target||(t.setAttribute("target","_blank"),t.setAttribute("rel","noreferrer"));return}},[n]);(0,Q.useEffect)(()=>{let e=o.current;if(e)return e.querySelectorAll("a[href^='http']").forEach(e=>{e.target||(e.setAttribute("target","_blank"),e.setAttribute("rel","noreferrer"))}),e.addEventListener("click",s),()=>e.removeEventListener("click",s)},[r,s]);let a=Ex(e=>e.loadedAt);return(0,Q.useEffect)(()=>{let e=o.current;if(!e)return;let t=Ex.getState();e.querySelectorAll('a[data-wiki-link="true"]').forEach(e=>{let n=e.dataset.slug??"";n&&!t.has(n)?e.dataset.broken="true":delete e.dataset.broken})},[r,a]),(0,Q.useEffect)(()=>{let e=o.current;e&&e.querySelectorAll('input[type="checkbox"]').forEach(e=>{e.disabled=!0})},[r]),(0,X.jsx)("div",{ref:o,className:"tiptap md-preview",dangerouslySetInnerHTML:{__html:r}})}let Iw=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/;function Ik(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=>Ik(e))}return t}let IT=en("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]),IN=en("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]),IA=en("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),IS=en("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);function IC(e){let t=Date.now()-new Date(e).getTime();return t<6e4?"just now":t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}function I_({scope:e}){return(0,X.jsxs)("span",{className:"text-[10px] text-muted-foreground/70 font-mono",children:[e.paths.join(", ")," · ",e.ops.join(",")]})}function IM({reg:e,onApprove:t,onDeny:n}){let[r,i]=(0,Q.useState)(!1);async function o(t){i(!0);try{await t(e.registrationId)}finally{i(!1)}}return(0,X.jsxs)("li",{className:"py-1.5 border-b border-border/40 last:border-0",children:[(0,X.jsxs)("div",{className:"flex items-start justify-between gap-1",children:[(0,X.jsxs)("div",{className:"min-w-0",children:[(0,X.jsx)("p",{className:"text-xs font-mono truncate",children:e.displayName}),(0,X.jsx)("p",{className:"text-[10px] text-muted-foreground/60 truncate",children:e.agentId}),(0,X.jsx)(I_,{scope:e.requestedScope})]}),(0,X.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,X.jsxs)(tG,{size:"sm",variant:"default",className:"h-6 px-2 text-[10px]",disabled:r,onClick:()=>void o(t),title:"Approve",children:[(0,X.jsx)(IN,{className:"h-3 w-3 mr-0.5"}),"Approve"]}),(0,X.jsxs)(tG,{size:"sm",variant:"ghost",className:"h-6 px-2 text-[10px] text-destructive hover:text-destructive",disabled:r,onClick:()=>void o(n),title:"Deny",children:[(0,X.jsx)(IA,{className:"h-3 w-3 mr-0.5"}),"Deny"]})]})]}),(0,X.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 mt-0.5",children:["Requested ",IC(e.requestedAt)]})]})}function IO({agent:e,onRevoke:t}){let[n,r]=(0,Q.useState)(!1);return(0,X.jsxs)("li",{className:"py-1.5 border-b border-border/40 last:border-0",children:[(0,X.jsxs)("div",{className:"flex items-start justify-between gap-1",children:[(0,X.jsxs)("div",{className:"min-w-0",children:[(0,X.jsx)("p",{className:"text-xs font-mono truncate",children:e.displayName}),(0,X.jsx)("p",{className:"text-[10px] text-muted-foreground/60 truncate",children:e.id}),(0,X.jsx)(I_,{scope:e.scope})]}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0 text-destructive hover:text-destructive",disabled:n,onClick:async()=>{r(!0);try{await t(e.id)}finally{r(!1)}},title:"Revoke agent",children:(0,X.jsx)(eN,{className:"h-3 w-3"})})]}),(0,X.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 mt-0.5",children:["Last seen ",IC(e.lastSeen)]})]})}function II(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)([]),[i,o]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{fetch("/api/owner/init",{credentials:"same-origin"}).then(e=>{(e.ok||204===e.status)&&o(!0)}).catch(()=>{o(!0)})},[]);let s=(0,Q.useCallback)(async()=>{try{let e=await fetch("/api/agent/admin/registrations",{credentials:"same-origin"});if(!e.ok)return;let n=await e.json();t(n.pending)}catch{}},[]),a=(0,Q.useCallback)(async()=>{try{let e=await fetch("/api/agent/admin/agents",{credentials:"same-origin"});if(!e.ok)return;let t=await e.json();r(t.agents)}catch{}},[]);(0,Q.useEffect)(()=>{if(!i)return;s(),a();let e=setInterval(()=>void s(),5e3),t=setInterval(()=>void a(),3e4);return()=>{clearInterval(e),clearInterval(t)}},[i,s,a]);let l=(0,Q.useCallback)(async e=>{(await fetch(`/api/agent/admin/registrations/${e}/approve`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:"{}"})).ok?(_i.toast.success("Agent approved"),await Promise.all([s(),a()])):_i.toast.error("Failed to approve agent")},[s,a]),c=(0,Q.useCallback)(async e=>{(await fetch(`/api/agent/admin/registrations/${e}/deny`,{method:"POST",credentials:"same-origin"})).ok?(_i.toast.success("Registration denied"),await s()):_i.toast.error("Failed to deny registration")},[s]),d=(0,Q.useCallback)(async e=>{(await fetch(`/api/agent/admin/agents/${encodeURIComponent(e)}/revoke`,{method:"POST",credentials:"same-origin"})).ok?(_i.toast.success("Agent revoked"),await a()):_i.toast.error("Failed to revoke agent")},[a]);return(0,X.jsxs)("section",{className:"space-y-2",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between",children:[(0,X.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Agents · approve & manage access"}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-5 w-5 p-0",title:"Refresh",onClick:()=>void Promise.all([s(),a()]),children:(0,X.jsx)(ew,{className:"h-3 w-3"})})]}),e.length>0&&(0,X.jsxs)("div",{className:"rounded-md border border-amber-500/40 bg-amber-50/10 p-2",children:[(0,X.jsxs)("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-amber-600/80 mb-1 flex items-center gap-1",children:[(0,X.jsx)(IS,{className:"h-3 w-3"}),"Waiting for your approval (",e.length,")"]}),(0,X.jsx)("ul",{children:e.map(e=>(0,X.jsx)(IM,{reg:e,onApprove:l,onDeny:c},e.registrationId))})]}),(0,X.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-2",children:0===n.length?(0,X.jsxs)("p",{className:"text-xs text-muted-foreground/60 py-1",children:["No assistants connected yet."," ",(0,X.jsx)("span",{className:"text-muted-foreground/40",children:"Connect one above; once it requests access it’ll appear here for you to approve."})]}):(0,X.jsx)("ul",{children:n.map(e=>(0,X.jsx)(IO,{agent:e,onRevoke:d},e.id))})}),(0,X.jsx)("p",{className:"text-[10px] text-muted-foreground/60 leading-relaxed",children:"Each assistant gets its own access that you can revoke anytime. New requests appear above for your approval before they can read or edit anything."})]})}function ID({event:e}){var t;let n=e.path.split("/").pop()??e.path,r="string"==typeof e.ref?e.ref:"";return(0,X.jsxs)("div",{className:"flex flex-col gap-0.5 py-1.5 border-b border-border/50 last:border-0",children:[(0,X.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,X.jsx)("span",{className:"text-xs font-mono text-foreground/80 truncate",title:e.path,children:n}),(0,X.jsx)("span",{className:"text-[10px] text-muted-foreground shrink-0",children:function(e){let t=Math.floor(Math.max(0,Date.now()-new Date(e).getTime())/1e3);if(t<60)return`${t}s ago`;let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}(e.at)})]}),(0,X.jsxs)("p",{className:"text-[11px] text-muted-foreground truncate",children:[(0,X.jsx)("span",{className:"text-foreground/60",children:e.by})," ",{"block.replace":"replaced","block.insertAfter":"inserted after","block.insertBefore":"inserted before","block.delete":"deleted","block.append":"appended","block.prepend":"prepended","comment.add":"commented on","comment.reply":"replied to comment","comment.resolve":"resolved comment","comment.reopen":"reopened comment","suggestion.add":"suggested","suggestion.accept":"accepted suggestion","suggestion.reject":"rejected suggestion"}[t=e.type]??t,r&&(0,X.jsxs)(X.Fragment,{children:[" ",(0,X.jsx)("span",{className:"font-mono text-[10px] text-muted-foreground/60",children:r})]})]})]})}let IR="npx skills add anh-chu/wiki-viewer/agents/wiki-viewer-skill";function IL(e){let[t,n]=(0,Q.useState)(!1);return{copied:t,copy:(0,Q.useCallback)(async()=>{await navigator.clipboard.writeText(e()),n(!0),setTimeout(()=>n(!1),1500)},[e])}}function IP({currentPath:e}){let t=Ee(e=>e.isOpen),n=Ee(e=>e.close),r=Ee(e=>e.activity),i=Ee(e=>e.connections),o=Ee(e=>e.loadActivity),{copied:s,copy:a}=function(e){let[t,n]=(0,Q.useState)(!1);return{copied:t,copy:(0,Q.useCallback)(async()=>{let t=window.location.origin,r=`# 1. Register
|
|
116
116
|
REG=$(curl -s -X POST -H 'Content-Type: application/json' \\
|
|
117
117
|
-d '{"id":"ai:claude","displayName":"Claude"}' \\
|
|
118
118
|
${t}/api/agent/register)
|
|
@@ -126,4 +126,4 @@ TOKEN=<paste token here>
|
|
|
126
126
|
# 3. Read snapshot
|
|
127
127
|
curl -s -H "Authorization: Bearer $TOKEN" \\
|
|
128
128
|
-H "X-Agent-Id: ai:claude" \\
|
|
129
|
-
${t}/api/agent/files/${e??"<path/to/file.md>"}`;await navigator.clipboard.writeText(r),n(!0),setTimeout(()=>n(!1),1500)},[e])}}(e??null),[c,d]=(0,Q.useState)(""),u=(0,Q.useRef)(null),h=window.location.origin,p=(0,Q.useCallback)(()=>IB,[]),f=(0,Q.useCallback)(()=>c.replace(/\$WIKI_URL/g,h),[c,h]),m=(0,Q.useCallback)(()=>`npx wiki-viewer-mcp register --url ${h} --id ai:myagent --name "My Agent"`,[h]),g=(0,Q.useCallback)(()=>JSON.stringify({servers:{"wiki-viewer":{command:"npx",args:["wiki-viewer-mcp"],env:{WIKI_VIEWER_URL:h,WIKI_VIEWER_TOKEN:"<token from register>",WIKI_VIEWER_AGENT_ID:"ai:myagent"}}}},null,2),[h]),b=IF(p),y=IF(f),x=IF(m),v=IF(g);return((0,Q.useEffect)(()=>{if(t)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e);function e(e){"Escape"===e.key&&n()}},[t,n]),(0,Q.useEffect)(()=>{t&&u.current?.focus()},[t]),(0,Q.useEffect)(()=>{if(!t)return;s();let e=setInterval(()=>void s(),1e4);return()=>clearInterval(e)},[t,s]),(0,Q.useEffect)(()=>{t&&fetch("/api/agents/install").then(e=>e.json()).then(e=>{e.bootstrapPrompt&&d(e.bootstrapPrompt)}).catch(()=>void 0)},[t]),t)?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("div",{className:"fixed inset-0 z-40 bg-black/20 backdrop-blur-[1px]",onClick:n,"aria-hidden":!0}),(0,X.jsxs)("aside",{ref:u,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":"AI Agent Panel",className:"fixed right-0 top-0 bottom-0 z-50 flex w-80 flex-col border-l border-border bg-background shadow-xl outline-none",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[(0,X.jsxs)("div",{className:"flex items-center gap-2",children:[(0,X.jsx)(ei,{className:"h-4 w-4 text-muted-foreground"}),(0,X.jsx)("span",{className:"text-sm font-semibold",children:"AI Agent"})]}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:n,title:"Close panel (Esc)",children:(0,X.jsx)(eS,{className:"h-3.5 w-3.5"})})]}),(0,X.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-5 px-4 py-4",children:[(0,X.jsx)(IU,{}),(0,X.jsxs)("section",{className:"space-y-2",children:[(0,X.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Bridge Endpoint"}),(0,X.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-2",children:[(0,X.jsxs)("div",{className:"flex items-center gap-2",children:[(0,X.jsx)("code",{className:"flex-1 text-xs font-mono text-foreground/80 truncate",children:h}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy curl example",onClick:()=>void l(),children:a?(0,X.jsx)(eo,{className:"h-3.5 w-3.5 text-green-500"}):(0,X.jsx)(_b,{className:"h-3.5 w-3.5"})})]}),(0,X.jsxs)("p",{className:"text-[10px] text-muted-foreground/70",children:["Copy icon copies a registration-flow ",(0,X.jsx)("code",{className:"bg-muted px-0.5 rounded",children:"curl"})," trace for the current file."]})]})]}),(0,X.jsxs)("section",{className:"space-y-2",children:[(0,X.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Install for AI Agents"}),(0,X.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-3",children:[(0,X.jsxs)("div",{className:"space-y-1",children:[(0,X.jsxs)("p",{className:"text-[10px] text-muted-foreground/70",children:["MCP server ",(0,X.jsx)("span",{className:"text-muted-foreground/50",children:"(Claude Code, Cursor, Codex):"})]}),(0,X.jsx)("p",{className:"text-[10px] text-muted-foreground/50",children:"1. Register & get a token:"}),(0,X.jsxs)("div",{className:"flex items-center gap-2",children:[(0,X.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:m()}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy register command",onClick:()=>void x.copy(),children:x.copied?(0,X.jsx)(eo,{className:"h-3.5 w-3.5 text-green-500"}):(0,X.jsx)(_b,{className:"h-3.5 w-3.5"})})]}),(0,X.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 pt-1",children:["2. Approve below, then add to your ",(0,X.jsx)("code",{className:"bg-muted px-0.5 rounded",children:"mcp.json"}),":"]}),(0,X.jsx)(tG,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void v.copy(),children:v.copied?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(eo,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(_b,{className:"h-3.5 w-3.5"})," Copy mcp.json"]})})]}),(0,X.jsx)("div",{className:"h-px bg-border/60"}),(0,X.jsxs)("div",{className:"space-y-1",children:[(0,X.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Agent Skills standard:"}),(0,X.jsxs)("div",{className:"flex items-center gap-2",children:[(0,X.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:IB}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy CLI command",onClick:()=>void b.copy(),children:b.copied?(0,X.jsx)(eo,{className:"h-3.5 w-3.5 text-green-500"}):(0,X.jsx)(_b,{className:"h-3.5 w-3.5"})})]})]}),(0,X.jsxs)("div",{className:"space-y-1",children:[(0,X.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Any agent (paste into chat):"}),(0,X.jsx)(tG,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void y.copy(),disabled:!c,children:y.copied?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(eo,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(_b,{className:"h-3.5 w-3.5"})," Copy bootstrap prompt"]})})]}),(0,X.jsxs)("div",{className:"flex flex-wrap gap-x-3 gap-y-1 pt-1",children:[(0,X.jsxs)("a",{href:"/api/agents/skill.tar.gz",download:!0,className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,X.jsx)(rj,{className:"h-3 w-3"})," skill (.tar.gz)"]}),(0,X.jsxs)("a",{href:"/api/agents/skill",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,X.jsx)(kr,{className:"h-3 w-3"})," skill markdown"]}),(0,X.jsxs)("a",{href:"/api/agents/install",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,X.jsx)(kr,{className:"h-3 w-3"})," install JSON"]})]})]})]}),(0,X.jsx)(IL,{}),(0,X.jsxs)("section",{className:"space-y-2",children:[(0,X.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:["Active Connections"," ",(0,X.jsx)("span",{className:"normal-case font-normal text-muted-foreground/50",children:"(last 5 min)"})]}),(0,X.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-3",children:0===i.length?(0,X.jsxs)("p",{className:"text-xs text-muted-foreground/60 flex items-center gap-1.5",children:[(0,X.jsx)(IS,{className:"h-3.5 w-3.5"}),"No recent activity"]}):(0,X.jsx)("ul",{className:"space-y-1.5",children:i.map(e=>(0,X.jsxs)("li",{className:"flex items-center justify-between text-xs",children:[(0,X.jsx)("span",{className:"font-mono text-foreground/80 truncate",children:e.by}),(0,X.jsxs)("span",{className:"text-muted-foreground shrink-0",children:[e.opCount," op",1!==e.opCount?"s":""]})]},e.by))})})]}),(0,X.jsxs)("section",{className:"space-y-2",children:[(0,X.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Recent Activity"}),(0,X.jsx)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-1 max-h-72 overflow-y-auto",children:0===r.length?(0,X.jsx)("p",{className:"text-xs text-muted-foreground/60 py-2",children:"No events recorded"}):r.map(e=>(0,X.jsx)(IP,{event:e},`${e.path}-${e.id}`))})]}),(0,X.jsxs)("section",{className:"space-y-2",children:[(0,X.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Settings"}),(0,X.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,X.jsx)("span",{className:"text-muted-foreground",children:"Rate limit"}),(0,X.jsx)("span",{className:"font-mono",children:null!==o?`${o} ops/min`:"--"})]}),(0,X.jsxs)("p",{className:"text-[10px] text-muted-foreground/60",children:["Override with ",(0,X.jsx)("code",{className:"bg-muted px-0.5 rounded",children:"AGENT_RATE_LIMIT"})," env var."]})]})]}),(0,X.jsx)("section",{children:(0,X.jsx)("a",{href:"/docs/agent-collab-plan.md",target:"_blank",rel:"noreferrer",className:"text-xs text-primary underline hover:no-underline",children:"Agent collaboration docs →"})})]})]})]}):null}function IU(){let{data:e}=Ij.authClient.useSession();return e?.user?(0,X.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border bg-muted/40 p-3",children:[(0,X.jsxs)("div",{className:"text-sm min-w-0",children:[(0,X.jsx)("div",{className:"font-medium truncate",children:e.user.name}),(0,X.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:e.user.email})]}),(0,X.jsx)("button",{type:"button",onClick:async()=>{await Ij.authClient.signOut(),window.location.href="/signin"},className:"ml-2 shrink-0 text-xs px-2 py-1 rounded border border-border hover:bg-accent",children:"Sign out"})]}):null}function Iz({className:e}){let t=Ey(e=>e.width),n=Ey(e=>e.setWidth);return(0,X.jsxs)(OZ,{children:[(0,X.jsx)(O1,{asChild:!0,children:(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:`h-7 w-7 p-0 ${e??""}`,title:`Content width: ${Eg[t]}`,children:(0,X.jsx)(w0,{className:"h-3.5 w-3.5"})})}),(0,X.jsx)(Ii,{align:"end",className:"w-36",children:Eb.map(e=>(0,X.jsxs)(Io,{onClick:()=>n(e),className:"flex items-center justify-between text-xs",children:[Eg[e],e===t&&(0,X.jsx)(eo,{className:"h-3.5 w-3.5"})]},e))})]})}function I$(e){return e.split(".").pop()?.toLowerCase()??""}function IG(e,t){if("node-app"===t)return"node-app";if("app"===t)return"app";if("dir"===t)return"fallback";let n=I$(e);return n?["md","markdown"].includes(n)?"editor":"txt"===n?"text":["csv","tsv"].includes(n)?"csv":"pdf"===n?"pdf":["mmd","mermaid"].includes(n)?"mermaid":"ipynb"===n?"notebook":["png","jpg","jpeg","gif","webp","svg","avif","ico","bmp"].includes(n)?"image":["mp4","webm","mov","m4v","mp3","wav","ogg","m4a","aac"].includes(n)?"media":"docx"===n?"docx":["xlsx","xlsm"].includes(n)?"xlsx":"pptx"===n?"pptx":"html"===n?"html":["py","js","ts","tsx","jsx","go","rs","java","c","cpp","h","sh","bash","zsh","rb","php","swift","kt","lua","sql","yaml","yml","toml","json","xml","css","scss"].includes(n)?"source":"fallback":"fallback"}let Iq=new Set(["txt","md","markdown","json","yaml","yml","toml","csv","tsv","xml","html","css","js","ts","tsx","jsx","sh","bash","zsh","rb","py","go","rs","java","c","cpp","h","php","swift","kt","lua","sql","scss","mmd","mermaid","ini","env","log","conf"]);function IV(e){let t=IG(e,"file");return"editor"===t||"text"===t||Iq.has(I$(e))}function IW(e){return["md","markdown"].includes(I$(e))}function IK(e){return"image"===IG(e,"file")}async function IY(e){let t=await fetch(`/api/wiki?dir=${encodeURIComponent(e)}`);return t.ok?(await t.json()).entries.map(t=>({name:t.name,path:e?`${e}/${t.name}`:t.name,type:t.type,size:t.size,modifiedAt:t.modifiedAt,expanded:!1})):[]}function IX(e,t,n){return e.map(e=>e.path===t?n(e):e.children?{...e,children:IX(e.children,t,n)}:e)}e.s(["default",0,function(){let e;Ex(e=>e.loadedAt),(0,Q.useEffect)(()=>{Ex.getState().load()},[]);let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{fetch("/api/system/root-status").then(e=>e.json()).then(e=>{n(e.configured),i(e.path)}).catch(()=>n(!1))},[]);let o=Eu(e=>e.currentPath),s=(0,Q.useRef)(new URLSearchParams(window.location.search).get("path")),a=(0,Q.useRef)(!1),[l,c]=(0,Q.useState)([]),[d,u]=(0,Q.useState)(!1),[h,p]=(0,Q.useState)(!1),f=(0,Q.useRef)(!1),[m,g]=(0,Q.useState)(!1),[b,y]=(0,Q.useState)(!1),[x,v]=(0,Q.useState)(null),E=(0,Q.useRef)(null),w=(0,Q.useRef)(""),[k,T]=(0,Q.useState)(null),[N,A]=(0,Q.useState)(""),[S,C]=(0,Q.useState)(null),[_,M]=(0,Q.useState)(null),[O,I]=(0,Q.useState)(""),[D,R]=(0,Q.useState)(null),[L,P]=(0,Q.useState)(null),[j,B]=(0,Q.useState)(!1),[F,H]=(0,Q.useState)(null),[U,z]=(0,Q.useState)(!1),[$,G]=(0,Q.useState)(0),[q,V]=(0,Q.useState)(!1),[W,K]=(0,Q.useState)(!1),[Y,J]=(0,Q.useState)(null),[Z,ee]=(0,Q.useState)(!1),[et,en]=(0,Q.useState)(!1),[eC,e_]=(0,Q.useState)(""),[eM,eO]=(0,Q.useState)(!1),[eI,eD]=(0,Q.useState)(null),eR=(0,Q.useRef)(null),[eL,eP]=(0,Q.useState)(null),ej=(0,Q.useRef)(null),eB=(0,Q.useRef)(!1),eF=(0,Q.useRef)(async()=>{});(0,Q.useEffect)(()=>{d||f.current||(f.current=!0,p(!0),IY("").then(e=>{c(e),u(!0),p(!1)}).catch(()=>{f.current=!1,p(!1)}))},[d]);let eH=(0,Q.useCallback)(async e=>{let t=e.split("/");if(t.length<=1)return;let n=[],r="";for(let e=0;e<t.length-1;e++)r=r?`${r}/${t[e]}`:t[e],n.push({prefix:r,children:await IY(r)});c(e=>{let t=e;for(let{prefix:e,children:r}of n)t=IX(t,e,e=>({...e,children:r,expanded:!0}));return t})},[]),eU=(0,Q.useCallback)(async e=>{let t=await IY(e);""===e?c(e=>{let n=new Map(e.map(e=>[e.path,e]));return t.map(e=>{let t=n.get(e.path);return t&&("dir"===t.type||"app"===t.type)?{...e,expanded:t.expanded,children:t.children}:e})}):c(n=>IX(n,e,e=>({...e,children:t,expanded:!0})))},[]),ez=(0,Q.useCallback)(e=>{let t=[];for(let n of e)("dir"===n.type||"app"===n.type)&&n.expanded&&n.children&&(t.push(n.path),t.push(...ez(n.children)));return t},[]),e$=(0,Q.useCallback)(async()=>{g(!0);try{let e=ez(l),t=await IY("");for(let n of(c(t),e)){let e=await IY(n);c(t=>IX(t,n,t=>({...t,children:e,expanded:!0})))}}finally{g(!1)}},[l,ez]),eG=(0,Q.useCallback)(async()=>{if(F&&(["editor","text"].includes(IG(F.name,F.nodeType))||IV(F.name))){ee(!0);try{let e=await fetch(`/api/wiki/content?path=${encodeURIComponent(F.path)}`);if(e.ok){let t=await e.json();J(t.content)}}catch{}ee(!1)}},[F]);async function eq(e){if("dir"===e.type||"app"===e.type)if(e.expanded)c(t=>IX(t,e.path,e=>({...e,expanded:!1})));else if(void 0===e.children){c(t=>IX(t,e.path,e=>({...e,loading:!0})));let t=await IY(e.path);c(n=>IX(n,e.path,e=>({...e,loading:!1,children:t,expanded:!0})))}else c(t=>IX(t,e.path,e=>({...e,expanded:!0})))}async function eV(e){if(H({path:e.path,name:e.name,nodeType:"app"===e.type?"app":"node-app"===e.type?"node-app":"file"}),en(!1),eD(null),J(null),["editor","text"].includes(IG(e.name,e.type))||IV(e.name)){ee(!0);try{let t=await fetch(`/api/wiki/content?path=${encodeURIComponent(e.path)}`);if(t.ok){let e=await t.json();J(e.content)}}catch{}ee(!1)}}(0,Q.useEffect)(()=>{ej.current=F},[F]),(0,Q.useEffect)(()=>{eB.current=et},[et]),(0,Q.useEffect)(()=>{eF.current=eG},[eG]),(0,Q.useEffect)(()=>{if(!t)return;let e=new Map,n=new EventSource("/api/wiki/watch");return n.onmessage=t=>{var n;let r;try{r=JSON.parse(t.data)}catch{return}let{type:i,path:o}=r,s=o.split("/");if(n=s.length>1?s.slice(0,-1).join("/"):"",e.has(n)&&clearTimeout(e.get(n)),e.set(n,setTimeout(()=>{e.delete(n),eU(n)},300)),"change"===i&&ej.current?.path===o&&!eB.current){let t=`__file__${o}`;e.has(t)&&clearTimeout(e.get(t)),e.set(t,setTimeout(()=>{e.delete(t),eF.current()},400))}},()=>{for(let t of(n.close(),e.values()))clearTimeout(t)}},[t,eU]),(0,Q.useEffect)(()=>{z(!1)},[]),(0,Q.useEffect)(()=>{if(!o||F&&F.path===o)return;let e=o.split("/").pop()??o;eV({path:o,name:e,type:"file"})},[o]),(0,Q.useEffect)(()=>{let e=new URL(window.location.href);F?e.searchParams.set("path",F.path):e.searchParams.delete("path"),window.history.replaceState(null,"",e.toString())},[F]),(0,Q.useEffect)(()=>{if(a.current||!d)return;let e=s.current;if(!e){a.current=!0;return}a.current=!0,(async()=>{let t=e.split("/"),n=t[t.length-1],r=t.slice(0,-1).join("/"),i=(await IY(r)).find(t=>t.path===e);i&&(await eH(e),eV({path:e,name:n,type:i.type,modifiedAt:i.modifiedAt}))})()},[d,eH]);let eW=async()=>{await fetch("/api/system/clear-root",{method:"POST"}),H(null),J(null),en(!1),c([]),u(!1),f.current=!1,i(null),n(!1)};async function eK(){if(!F)return;eO(!0),eD(null);let e=await fetch("/api/wiki/content",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:F.path,content:eC})});e.ok?(J(eC),en(!1)):eD((await e.json()).error??"Save failed"),eO(!1)}let eY=(0,Q.useCallback)(async(e,t)=>{let n=Array.from(e);if(n.length){y(!0),v(null);try{for(let e of n){let n=new FormData;n.append("file",e),n.append("dir",t);let r=await fetch("/api/wiki/upload",{method:"POST",body:n});if(!r.ok){let e=await r.json();v(e.error??"Upload failed"),_o(e.error??"Upload failed");break}}await eU(t)}catch{v("Upload failed.")}finally{y(!1),E.current&&(E.current.value="")}}},[eU]);function eX(e){w.current=e,E.current?.click()}async function eQ(){let e=N.trim();if(!e||null===k)return;C(null);let t=k?`${k}/${e}`:e,n=await fetch("/api/wiki/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});n.ok?(T(null),A(""),await eU(k),""!==k&&c(e=>IX(e,k,e=>({...e,expanded:!0})))):C((await n.json()).error??"Failed")}async function eJ(){let e=O.trim();if(!e||null===_)return;R(null);let t=e.includes(".")?e:`${e}.md`,n=_?`${_}/${t}`:t,r=await fetch("/api/wiki/new-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})});r.ok?(M(null),I(""),await eU(_),""!==_&&c(e=>IX(e,_,e=>({...e,expanded:!0}))),eV({path:n,name:t,type:"file",modifiedAt:new Date().toISOString()})):R((await r.json()).error??"Failed")}async function eZ(){L&&(await fetch("/api/wiki",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:L})}),(F?.path===L||F?.path.startsWith(`${L}/`))&&(H(null),J(null)),c(e=>(function e(t,n){return t.filter(e=>e.path!==n).map(t=>t.children?{...t,children:e(t.children,n)}:t)})(e,L)),P(null))}function e0(e,t,n){e.preventDefault(),e.stopPropagation();let r=eR.current;!r||r.path===t||t.startsWith(`${r.path}/`)||(e.dataTransfer.dropEffect="move",eP("root"===n?"":t))}async function e1(e,t){e.preventDefault(),e.stopPropagation(),eP(null);let n=eR.current;if(eR.current=null,!n||n.path===t||t.startsWith(`${n.path}/`))return;let r=t?`${t}/${n.name}`:n.name;if(r!==n.path&&(await fetch("/api/wiki/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:n.path,to:r})})).ok){let e=n.path.includes("/")?n.path.split("/").slice(0,-1).join("/"):"";await eU(e),t!==e&&await eU(t),F?.path===n.path&&H({path:r,name:n.name,nodeType:F.nodeType})}}let e2=F?IG(F.name,F.nodeType):null,e3=Ey(e=>e.width),e5=null===e2||"editor"===e2||"text"===e2||"source"===e2||"notebook"===e2||"fallback"===e2,e4=e5?Ef[e3]:"";return(0,X.jsxs)("div",{className:"flex h-screen gap-0 overflow-hidden bg-background",children:[null===t&&(0,X.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,X.jsx)(eg,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),!1===t&&(0,X.jsx)(MC,{onSelect:e=>{u(!1),f.current=!1,i(e),n(!0)}}),!0===t&&(0,X.jsxs)(X.Fragment,{children:[!q&&(0,X.jsxs)(Ix,{className:"flex flex-col w-72 shrink-0 overflow-hidden rounded-none border-r border-l-0 border-t-0 border-b-0",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b bg-muted shrink-0",children:[(0,X.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,X.jsx)("img",{src:"/logo.svg",alt:"Wiki Viewer",className:"h-5 w-5 shrink-0"}),(0,X.jsx)("span",{className:"truncate text-xs font-semibold tracking-tight",children:"Wiki Viewer"})]}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 shrink-0",title:"Collapse sidebar",onClick:()=>V(!0),children:(0,X.jsx)(ey,{className:"h-3.5 w-3.5"})})]}),(0,X.jsxs)("div",{className:"flex items-center justify-between gap-1 px-3 py-1.5 border-b bg-muted/50 shrink-0",children:[(0,X.jsxs)(OZ,{children:[(0,X.jsx)(O1,{asChild:!0,children:(0,X.jsxs)(tG,{size:"sm",variant:"ghost",className:"h-7 gap-1 px-2 text-xs",disabled:b,children:[b?(0,X.jsx)(eg,{className:"h-3.5 w-3.5 animate-spin"}):(0,X.jsx)(eE,{className:"h-3.5 w-3.5"}),"New",(0,X.jsx)(es,{className:"h-3 w-3 opacity-60"})]})}),(0,X.jsxs)(Ii,{align:"start",className:"w-44",children:[(0,X.jsxs)(Io,{onClick:()=>{M(""),I(""),R(null)},children:[(0,X.jsx)(ec,{className:"mr-2 h-3.5 w-3.5"}),"New file"]}),(0,X.jsxs)(Io,{onClick:()=>{T(""),A(""),C(null)},children:[(0,X.jsx)(ep,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}),(0,X.jsxs)(Io,{onClick:()=>eX(""),disabled:b,children:[(0,X.jsx)(eA,{className:"mr-2 h-3.5 w-3.5"}),"Upload"]})]})]}),(0,X.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh tree",onClick:e$,disabled:m,children:m?(0,X.jsx)(eg,{className:"h-3.5 w-3.5 animate-spin"}):(0,X.jsx)(ew,{className:"h-3.5 w-3.5"})}),(0,X.jsx)(Ic,{}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"AI Agent panel",onClick:()=>Ee.getState().toggle(),children:(0,X.jsx)(ei,{className:"h-3.5 w-3.5"})}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Settings",onClick:()=>K(!0),children:(0,X.jsx)(ek,{className:"h-3.5 w-3.5"})})]})]}),x&&(0,X.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0",children:[(0,X.jsx)(er,{className:"h-3.5 w-3.5 shrink-0"}),x]}),""===k&&(0,X.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,X.jsx)(eu,{className:"h-4 w-4 shrink-0 text-warning"}),(0,X.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:N,onChange:e=>A(e.target.value),onKeyDown:e=>{"Enter"===e.key&&eQ(),"Escape"===e.key&&(T(null),A(""))}}),S&&(0,X.jsx)("span",{className:"text-xs text-destructive",children:S}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:eQ,children:(0,X.jsx)(eo,{className:"h-3 w-3"})}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{T(null),A("")},children:(0,X.jsx)(eS,{className:"h-3 w-3"})})]}),""===_&&(0,X.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,X.jsx)(ed,{className:"h-4 w-4 shrink-0 text-accent"}),(0,X.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:O,onChange:e=>I(e.target.value),onKeyDown:e=>{"Enter"===e.key&&eJ(),"Escape"===e.key&&(M(null),I(""))}}),D&&(0,X.jsx)("span",{className:"text-xs text-destructive",children:D}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:eJ,children:(0,X.jsx)(eo,{className:"h-3 w-3"})}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{M(null),I("")},children:(0,X.jsx)(eS,{className:"h-3 w-3"})})]}),(0,X.jsx)("div",{className:tz("flex-1 overflow-auto py-1",""===eL&&"ring-2 ring-inset ring-primary bg-primary/5"),onDragOver:e=>e0(e,"","root"),onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||eP(null)},onDrop:e=>e1(e,""),children:h?(0,X.jsx)("div",{className:"flex justify-center py-6",children:(0,X.jsx)(eg,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):0===l.length?(0,X.jsxs)("div",{className:"flex flex-col items-center gap-3 px-4 py-8 text-center",children:[(0,X.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,X.jsx)(ed,{className:"h-6 w-6 text-muted-foreground"})}),(0,X.jsxs)("div",{className:"space-y-1",children:[(0,X.jsx)("p",{className:"text-sm font-medium",children:"No files yet"}),(0,X.jsx)("p",{className:"text-xs text-muted-foreground",children:"Upload files or add them to the configured directory"})]}),(0,X.jsxs)(tG,{size:"sm",variant:"outline",className:"w-full gap-1.5 max-w-[180px]",onClick:()=>eX(""),disabled:b,children:[b?(0,X.jsx)(eg,{className:"h-3.5 w-3.5 animate-spin"}):(0,X.jsx)(eA,{className:"h-3.5 w-3.5"}),"Upload Files"]})]}):function e(t,n=0){return t.map(t=>(0,X.jsxs)("div",{children:[(0,X.jsxs)("div",{role:"treeitem",tabIndex:0,draggable:!0,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),"dir"===t.type?eq(t):"app"===t.type?(eV(t),eq(t)):eV(t))},onDragStart:e=>{eR.current=t,e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",t.path)},onDragOver:e=>"dir"===t.type?e0(e,t.path,"dir"):e.preventDefault(),onDragLeave:()=>eP(null),onDrop:e=>"dir"===t.type?e1(e,t.path):e.preventDefault(),className:tz("flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer group transition-colors select-none",F?.path===t.path?"bg-accent text-accent-foreground":"hover:bg-accent/50",eL===t.path&&"ring-2 ring-primary bg-primary-soft",t.name.startsWith(".")&&"opacity-40"),style:{paddingLeft:`${14*n+8}px`},onClick:()=>{"dir"===t.type?eq(t):"app"===t.type?(eV(t),eq(t)):eV(t)},children:["dir"===t.type||"app"===t.type?t.loading?(0,X.jsx)(eg,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}):t.expanded?(0,X.jsx)(es,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):(0,X.jsx)(ea,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):(0,X.jsx)("span",{className:"w-3.5 shrink-0"}),"dir"===t.type?t.expanded?(0,X.jsx)(eh,{className:tz("h-4 w-4 shrink-0",F?.path!==t.path&&"text-warning")}):(0,X.jsx)(eu,{className:tz("h-4 w-4 shrink-0",F?.path!==t.path&&"text-warning")}):"app"===t.type?(0,X.jsx)(ef,{className:tz("h-4 w-4 shrink-0",F?.path!==t.path&&"text-accent")}):"node-app"===t.type?(0,X.jsx)(eT,{className:tz("h-4 w-4 shrink-0",F?.path!==t.path&&"text-emerald-500")}):"html"===IG(t.name,"file")?(0,X.jsx)(ef,{className:tz("h-4 w-4 shrink-0",F?.path!==t.path&&"text-accent/70")}):IK(t.name)?(0,X.jsx)(em,{className:tz("h-4 w-4 shrink-0",F?.path!==t.path&&"text-sunshine-700")}):IV(t.name)?(0,X.jsx)(ed,{className:tz("h-4 w-4 shrink-0",F?.path!==t.path&&"text-accent")}):(0,X.jsx)(el,{className:tz("h-4 w-4 shrink-0",F?.path!==t.path&&"text-muted-foreground")}),(0,X.jsx)("span",{className:"flex-1 truncate",children:t.name}),(0,X.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:["dir"===t.type&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",title:"New file here (default .md)",onClick:async()=>{t.expanded||await eq(t),M(t.path),I(""),R(null)},children:(0,X.jsx)(ec,{className:"h-3 w-3"})}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",title:"Upload here",onClick:()=>eX(t.path),children:(0,X.jsx)(eA,{className:"h-3 w-3"})}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",title:"New subfolder",onClick:()=>{T(t.path),A(""),C(null)},children:(0,X.jsx)(ep,{className:"h-3 w-3"})})]}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-destructive hover:text-destructive",title:"Delete",onClick:()=>{P(t.path),B("file"!==t.type)},children:(0,X.jsx)(eN,{className:"h-3 w-3"})})]})]}),k===t.path&&"dir"===t.type&&(0,X.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(n+1)*14+8}px`},children:[(0,X.jsx)("span",{className:"w-3.5 shrink-0"}),(0,X.jsx)(eu,{className:"h-4 w-4 shrink-0 text-warning"}),(0,X.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:N,onChange:e=>A(e.target.value),onKeyDown:e=>{"Enter"===e.key&&eQ(),"Escape"===e.key&&(T(null),A(""))}}),S&&(0,X.jsx)("span",{className:"text-xs text-destructive",children:S}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:eQ,children:(0,X.jsx)(eo,{className:"h-3 w-3"})}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{T(null),A("")},children:(0,X.jsx)(eS,{className:"h-3 w-3"})})]}),_===t.path&&"dir"===t.type&&(0,X.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(n+1)*14+8}px`},children:[(0,X.jsx)("span",{className:"w-3.5 shrink-0"}),(0,X.jsx)(ed,{className:"h-4 w-4 shrink-0 text-accent"}),(0,X.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:O,onChange:e=>I(e.target.value),onKeyDown:e=>{"Enter"===e.key&&eJ(),"Escape"===e.key&&(M(null),I(""))}}),D&&(0,X.jsx)("span",{className:"text-xs text-destructive",children:D}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:eJ,children:(0,X.jsx)(eo,{className:"h-3 w-3"})}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{M(null),I("")},children:(0,X.jsx)(eS,{className:"h-3 w-3"})})]}),("dir"===t.type||"app"===t.type)&&t.expanded&&t.children&&t.children.length>0&&e(t.children,n+1),("dir"===t.type||"app"===t.type)&&t.expanded&&t.children?.length===0&&(0,X.jsx)("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:`${(n+1)*14+8+14+6+16+6}px`},children:"Empty"})]},t.path))}(l)}),(0,X.jsxs)("div",{className:"border-t px-3 py-2 flex items-center gap-2 bg-muted shrink-0",children:[(0,X.jsx)("span",{className:"flex-1 text-xs text-muted-foreground font-mono truncate",title:r??"",children:r??""}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 shrink-0 text-xs px-2 text-muted-foreground hover:text-foreground",onClick:eW,children:"Change"})]})]}),(0,X.jsxs)("div",{className:"flex-1 flex flex-col min-w-0 relative",children:[q&&(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"absolute left-0 top-1/2 -translate-y-1/2 z-10 h-7 w-7 p-0 rounded-full bg-background/50 backdrop-blur-xl backdrop-saturate-150 border border-white/[0.08] text-foreground/60 hover:text-foreground/90 hover:bg-background/70 shadow-[0_0_12px_rgba(0,0,0,0.15)] [transform:translate(-50%,-50%)_translateZ(0)]",title:"Show sidebar",onClick:()=>V(!1),children:(0,X.jsx)(ex,{className:"h-3.5 w-3.5"})}),F?"node-app"===e2?(0,X.jsx)(Mk,{path:F.path,title:F.name}):"app"===e2||"html"===e2?(e="html"===e2?`/api/assets/${F.path}`:void 0,U?(0,X.jsx)(Mx,{path:F.path,title:F.name,src:e,fullscreen:!0,onExit:()=>z(!1)}):(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0",children:[(0,X.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,X.jsx)(ef,{className:"h-4 w-4 shrink-0 text-accent"}),(0,X.jsx)("span",{className:"text-sm font-normal truncate",title:F.path,children:F.path})]}),(0,X.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:["html"===e2&&!et&&null!==Y&&(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Edit source",onClick:()=>{en(!0),e_(Y),eD(null)},children:(0,X.jsx)(ev,{className:"h-3.5 w-3.5"})}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh",onClick:()=>G(e=>e+1),children:(0,X.jsx)(ew,{className:"h-3.5 w-3.5"})}),(0,X.jsxs)(tG,{size:"sm",variant:"ghost",className:"h-7 gap-1.5 text-xs",onClick:()=>z(!0),children:[(0,X.jsx)(eb,{className:"h-3.5 w-3.5"}),"Open fullscreen"]}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{H(null),en(!1)},children:(0,X.jsx)(eS,{className:"h-3.5 w-3.5"})})]})]}),et&&"html"===e2?(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[(0,X.jsx)("textarea",{value:eC,onChange:e=>e_(e.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"}),(0,X.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[eI&&(0,X.jsx)("span",{className:"text-xs text-destructive mr-auto",children:eI}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",onClick:()=>{en(!1),eD(null)},children:"Cancel"}),(0,X.jsxs)(tG,{size:"sm",className:"gap-1",onClick:eK,disabled:eM,children:[eM&&(0,X.jsx)(eg,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):(0,X.jsx)(Mx,{path:F.path,title:F.name,src:e},$)]})):(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0",children:[(0,X.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[IK(F.name)?(0,X.jsx)(em,{className:"h-4 w-4 shrink-0 text-sunshine-700"}):IV(F.name)?(0,X.jsx)(ed,{className:"h-4 w-4 shrink-0 text-accent"}):(0,X.jsx)(el,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,X.jsx)("span",{className:"text-sm font-normal truncate",title:F.path,children:F.path})]}),(0,X.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[IV(F.name)&&!et&&null!==Y&&(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{en(!0),e_(Y),eD(null),IW(F.name)&&Eu.getState().loadPage(F.path)},children:(0,X.jsx)(ev,{className:"h-3.5 w-3.5"})}),IV(F.name)&&!et&&null!==Y&&(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh",onClick:eG,disabled:Z,children:Z?(0,X.jsx)(eg,{className:"h-3.5 w-3.5 animate-spin"}):(0,X.jsx)(ew,{className:"h-3.5 w-3.5"})}),e5&&(0,X.jsx)(Iz,{}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{H(null),J(null),en(!1)},children:(0,X.jsx)(eS,{className:"h-3.5 w-3.5"})})]})]}),et?(0,X.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:IW(F.name)?(0,X.jsx)(_p,{}):(0,X.jsx)("textarea",{value:eC,onChange:e=>e_(e.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"})}):(0,X.jsx)("div",{className:"flex-1 overflow-auto p-4 min-h-0",children:(0,X.jsx)("div",{className:tz("mx-auto w-full",e4),children:Z?(0,X.jsx)("div",{className:"flex justify-center py-8",children:(0,X.jsx)(eg,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):"csv"===e2?(0,X.jsx)(rz,{path:F.path,title:F.name}):"pdf"===e2?(0,X.jsx)(Mf,{path:F.path,title:F.name}):"mermaid"===e2?(0,X.jsx)(_w,{path:F.path,title:F.name}):"notebook"===e2?(0,X.jsx)(Mc,{path:F.path,title:F.name}):"image"===e2?(0,X.jsx)(_m,{path:F.path,title:F.name}):"media"===e2?(0,X.jsx)(_g,{path:F.path,title:F.name,type:["mp4","webm","mov","m4v"].includes(I$(F.name))?"video":"audio"}):"docx"===e2?(0,X.jsx)(Mu,{path:F.path,title:F.name}):"xlsx"===e2?(0,X.jsx)(Mp,{path:F.path,title:F.name}):"pptx"===e2?(0,X.jsx)(Mh,{path:F.path,title:F.name}):"source"===e2?(0,X.jsx)(My,{path:F.path,title:F.name}):"fallback"===e2?(0,X.jsx)(_f,{path:F.path,title:F.name}):null!==Y?["md","markdown"].includes(I$(F.name))?(()=>{let{data:e,body:t}=function(e){let t=IN.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(IA(n[1])),t+=1}if(e.length>0){o[n]=e,a=t;continue}o[n]="",a+=1;continue}o[n]=IA(r),a+=1}return 0===Object.keys(o).length?{data:{},body:e}:{data:o,body:r}}(Y);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ik,{data:e}),(0,X.jsx)(IT,{markdown:t,pagePath:F.path,onNavigate:(e,t)=>{eV({path:e,name:e.split("/").pop()??e,type:"file"}),t&&setTimeout(()=>{document.getElementById(t)?.scrollIntoView({behavior:"smooth"})},200)}})]})})():(0,X.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words leading-relaxed",children:Y}):IV(F.name)?(0,X.jsx)("p",{className:"text-sm text-muted-foreground",children:"Could not load file."}):(0,X.jsx)("p",{className:"text-sm text-muted-foreground",children:"Preview not available for this file type."})})}),et&&(0,X.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[eI&&(0,X.jsx)("span",{className:"text-xs text-destructive mr-auto",children:eI}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",onClick:()=>{en(!1),eD(null)},children:"Cancel"}),(0,X.jsxs)(tG,{size:"sm",className:"gap-1",onClick:eK,disabled:eM,children:[eM&&(0,X.jsx)(eg,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):(0,X.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center",children:(0,X.jsxs)("div",{className:"flex flex-col items-center gap-2 text-center px-4",children:[(0,X.jsx)(ed,{className:"h-8 w-8 text-muted-foreground"}),(0,X.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a file to view or edit"})]})})]}),(0,X.jsx)(Iy,{open:W,onOpenChange:K}),(0,X.jsx)(IH,{currentPath:F?.path}),(0,X.jsx)("input",{ref:E,type:"file",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&eY(e.target.files,w.current)}}),(0,X.jsx)(rL,{open:!!L,onOpenChange:e=>{e||P(null)},title:j?"Delete folder?":"Delete file?",description:j?`"${L?.split("/").pop()}" and all its contents will be permanently deleted.`:`"${L?.split("/").pop()}" will be permanently removed.`,onConfirm:eZ})]})]})}],952683)}]);
|
|
129
|
+
${t}/api/agent/files/${e??"<path/to/file.md>"}`;await navigator.clipboard.writeText(r),n(!0),setTimeout(()=>n(!1),1500)},[e])}}(e??null),[l,c]=(0,Q.useState)(""),d=(0,Q.useRef)(null),u=window.location.origin,h=(0,Q.useCallback)(()=>IR,[]),p=(0,Q.useCallback)(()=>l.replace(/\$WIKI_URL/g,u),[l,u]),f=(0,Q.useCallback)(()=>`npx wiki-viewer-mcp register --url ${u} --id ai:myagent --name "My Agent"`,[u]),m=(0,Q.useCallback)(()=>JSON.stringify({servers:{"wiki-viewer":{command:"npx",args:["wiki-viewer-mcp"],env:{WIKI_VIEWER_URL:u,WIKI_VIEWER_TOKEN:"<token from register>",WIKI_VIEWER_AGENT_ID:"ai:myagent"}}}},null,2),[u]),g=IL(h),b=IL(p),y=IL(f),x=IL(m);return((0,Q.useEffect)(()=>{if(t)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e);function e(e){"Escape"===e.key&&n()}},[t,n]),(0,Q.useEffect)(()=>{t&&d.current?.focus()},[t]),(0,Q.useEffect)(()=>{if(!t)return;o();let e=setInterval(()=>void o(),1e4);return()=>clearInterval(e)},[t,o]),(0,Q.useEffect)(()=>{t&&fetch("/api/agents/install").then(e=>e.json()).then(e=>{e.bootstrapPrompt&&c(e.bootstrapPrompt)}).catch(()=>void 0)},[t]),t)?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("div",{className:"fixed inset-0 z-40 bg-black/20 backdrop-blur-[1px]",onClick:n,"aria-hidden":!0}),(0,X.jsxs)("aside",{ref:d,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":"AI Agent Panel",className:"fixed right-0 top-0 bottom-0 z-50 flex w-80 flex-col border-l border-border bg-background shadow-xl outline-none",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[(0,X.jsxs)("div",{className:"flex items-center gap-2",children:[(0,X.jsx)(ei,{className:"h-4 w-4 text-muted-foreground"}),(0,X.jsx)("span",{className:"text-sm font-semibold",children:"AI Agent"})]}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:n,title:"Close panel (Esc)",children:(0,X.jsx)(eS,{className:"h-3.5 w-3.5"})})]}),(0,X.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-5 px-4 py-4",children:[(0,X.jsxs)("section",{className:"rounded-md border border-border bg-muted/30 p-3",children:[(0,X.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Work with this wiki using AI"}),(0,X.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:["Connect Claude, Cursor, ChatGPT, and more. Pick by what you want — each option gives a copy-paste setup. You approve every assistant in ",(0,X.jsx)("span",{className:"font-medium text-foreground/80",children:"Agents"})," below before it gets access."]})]}),(0,X.jsxs)("section",{className:"space-y-3",children:[(0,X.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,X.jsx)("p",{className:"text-xs font-semibold text-foreground",children:"Co-write docs with you"}),(0,X.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Edits arrive as suggestions with comments you accept or revert. No MCP needed."}),(0,X.jsx)(tG,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void b.copy(),disabled:!l,children:b.copied?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(eo,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(_b,{className:"h-3.5 w-3.5"})," Paste into any chatbot"]})}),(0,X.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 pt-1",children:["Or install once so it sticks"," ",(0,X.jsx)("span",{className:"text-muted-foreground/40",children:"· Claude, OpenCode"}),":"]}),(0,X.jsxs)("div",{className:"flex items-center gap-2",children:[(0,X.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:IR}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void g.copy(),children:g.copied?(0,X.jsx)(eo,{className:"h-3.5 w-3.5 text-green-500"}):(0,X.jsx)(_b,{className:"h-3.5 w-3.5"})})]})]}),(0,X.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,X.jsxs)("p",{className:"text-xs font-semibold text-foreground",children:["Edit files directly"," ",(0,X.jsx)("span",{className:"font-normal text-muted-foreground/60",children:"· Claude Code, Cursor, Codex"})]}),(0,X.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Native read / search / edit tools over MCP. Run to request access:"}),(0,X.jsxs)("div",{className:"flex items-center gap-2",children:[(0,X.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:f()}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void y.copy(),children:y.copied?(0,X.jsx)(eo,{className:"h-3.5 w-3.5 text-green-500"}):(0,X.jsx)(_b,{className:"h-3.5 w-3.5"})})]}),(0,X.jsxs)("p",{className:"text-[10px] text-muted-foreground/50",children:["Approve in ",(0,X.jsx)("span",{className:"font-medium text-foreground/70",children:"Agents"}),", then add to your tool:"]}),(0,X.jsx)(tG,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void x.copy(),children:x.copied?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(eo,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(_b,{className:"h-3.5 w-3.5"})," Copy config (mcp.json)"]})})]}),(0,X.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,X.jsx)("span",{className:"text-[10px] text-muted-foreground/50",children:"For developers:"}),(0,X.jsxs)("button",{type:"button",onClick:()=>void a(),className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[s?(0,X.jsx)(eo,{className:"h-3 w-3 text-green-500"}):(0,X.jsx)(_b,{className:"h-3 w-3"})," curl example"]}),(0,X.jsxs)("a",{href:"/api/agents/skill",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,X.jsx)(kr,{className:"h-3 w-3"})," skill"]}),(0,X.jsxs)("a",{href:"/api/agents/install",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,X.jsx)(kr,{className:"h-3 w-3"})," install JSON"]})]})]}),(0,X.jsx)(II,{}),(0,X.jsxs)("section",{className:"space-y-2",children:[(0,X.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:["Active Connections"," ",(0,X.jsx)("span",{className:"normal-case font-normal text-muted-foreground/50",children:"(last 5 min)"})]}),(0,X.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-3",children:0===i.length?(0,X.jsxs)("p",{className:"text-xs text-muted-foreground/60 flex items-center gap-1.5",children:[(0,X.jsx)(IT,{className:"h-3.5 w-3.5"}),"No recent activity"]}):(0,X.jsx)("ul",{className:"space-y-1.5",children:i.map(e=>(0,X.jsxs)("li",{className:"flex items-center justify-between text-xs",children:[(0,X.jsx)("span",{className:"font-mono text-foreground/80 truncate",children:e.by}),(0,X.jsxs)("span",{className:"text-muted-foreground shrink-0",children:[e.opCount," op",1!==e.opCount?"s":""]})]},e.by))})})]}),(0,X.jsxs)("section",{className:"space-y-2",children:[(0,X.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Recent Activity"}),(0,X.jsx)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-1 max-h-72 overflow-y-auto",children:0===r.length?(0,X.jsx)("p",{className:"text-xs text-muted-foreground/60 py-2",children:"No events recorded"}):r.map(e=>(0,X.jsx)(ID,{event:e},`${e.path}-${e.id}`))})]}),(0,X.jsx)("section",{children:(0,X.jsx)("a",{href:"/docs/agent-collab-plan.md",target:"_blank",rel:"noreferrer",className:"text-xs text-primary underline hover:no-underline",children:"Agent collaboration docs →"})})]})]})]}):null}function Ij({className:e}){let t=Ey(e=>e.width),n=Ey(e=>e.setWidth);return(0,X.jsxs)(OZ,{children:[(0,X.jsx)(O1,{asChild:!0,children:(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:`h-7 w-7 p-0 ${e??""}`,title:`Content width: ${Eg[t]}`,children:(0,X.jsx)(w0,{className:"h-3.5 w-3.5"})})}),(0,X.jsx)(Ii,{align:"end",className:"w-36",children:Eb.map(e=>(0,X.jsxs)(Io,{onClick:()=>n(e),className:"flex items-center justify-between text-xs",children:[Eg[e],e===t&&(0,X.jsx)(eo,{className:"h-3.5 w-3.5"})]},e))})]})}function IB(e){return e.split(".").pop()?.toLowerCase()??""}function IF(e,t){if("node-app"===t)return"node-app";if("app"===t)return"app";if("dir"===t)return"fallback";let n=IB(e);return n?["md","markdown"].includes(n)?"editor":"txt"===n?"text":["csv","tsv"].includes(n)?"csv":"pdf"===n?"pdf":["mmd","mermaid"].includes(n)?"mermaid":"ipynb"===n?"notebook":["png","jpg","jpeg","gif","webp","svg","avif","ico","bmp"].includes(n)?"image":["mp4","webm","mov","m4v","mp3","wav","ogg","m4a","aac"].includes(n)?"media":"docx"===n?"docx":["xlsx","xlsm"].includes(n)?"xlsx":"pptx"===n?"pptx":"html"===n?"html":["py","js","ts","tsx","jsx","go","rs","java","c","cpp","h","sh","bash","zsh","rb","php","swift","kt","lua","sql","yaml","yml","toml","json","xml","css","scss"].includes(n)?"source":"fallback":"fallback"}let IH=new Set(["txt","md","markdown","json","yaml","yml","toml","csv","tsv","xml","html","css","js","ts","tsx","jsx","sh","bash","zsh","rb","py","go","rs","java","c","cpp","h","php","swift","kt","lua","sql","scss","mmd","mermaid","ini","env","log","conf"]);function IU(e){let t=IF(e,"file");return"editor"===t||"text"===t||IH.has(IB(e))}function Iz(e){return["md","markdown"].includes(IB(e))}function I$(e){return"image"===IF(e,"file")}async function IG(e){let t=await fetch(`/api/wiki?dir=${encodeURIComponent(e)}`);return t.ok?(await t.json()).entries.map(t=>({name:t.name,path:e?`${e}/${t.name}`:t.name,type:t.type,size:t.size,modifiedAt:t.modifiedAt,expanded:!1})):[]}function Iq(e,t,n){return e.map(e=>e.path===t?n(e):e.children?{...e,children:Iq(e.children,t,n)}:e)}e.s(["default",0,function(){let e;Ex(e=>e.loadedAt),(0,Q.useEffect)(()=>{Ex.getState().load()},[]);let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{fetch("/api/system/root-status").then(e=>e.json()).then(e=>{n(e.configured),i(e.path)}).catch(()=>n(!1))},[]);let o=Eu(e=>e.currentPath),s=(0,Q.useRef)(new URLSearchParams(window.location.search).get("path")),a=(0,Q.useRef)(!1),[l,c]=(0,Q.useState)([]),[d,u]=(0,Q.useState)(!1),[h,p]=(0,Q.useState)(!1),f=(0,Q.useRef)(!1),[m,g]=(0,Q.useState)(!1),[b,y]=(0,Q.useState)(!1),[x,v]=(0,Q.useState)(null),E=(0,Q.useRef)(null),w=(0,Q.useRef)(""),[k,T]=(0,Q.useState)(null),[N,A]=(0,Q.useState)(""),[S,C]=(0,Q.useState)(null),[_,M]=(0,Q.useState)(null),[O,I]=(0,Q.useState)(""),[D,R]=(0,Q.useState)(null),[L,P]=(0,Q.useState)(null),[j,B]=(0,Q.useState)(!1),[F,H]=(0,Q.useState)(null),[U,z]=(0,Q.useState)(!1),[$,G]=(0,Q.useState)(0),[q,V]=(0,Q.useState)(!1),[W,K]=(0,Q.useState)(!1),[Y,J]=(0,Q.useState)(null),[Z,ee]=(0,Q.useState)(!1),[et,en]=(0,Q.useState)(!1),[eC,e_]=(0,Q.useState)(""),[eM,eO]=(0,Q.useState)(!1),[eI,eD]=(0,Q.useState)(null),eR=(0,Q.useRef)(null),[eL,eP]=(0,Q.useState)(null),ej=(0,Q.useRef)(null),eB=(0,Q.useRef)(!1),eF=(0,Q.useRef)(async()=>{});(0,Q.useEffect)(()=>{d||f.current||(f.current=!0,p(!0),IG("").then(e=>{c(e),u(!0),p(!1)}).catch(()=>{f.current=!1,p(!1)}))},[d]);let eH=(0,Q.useCallback)(async e=>{let t=e.split("/");if(t.length<=1)return;let n=[],r="";for(let e=0;e<t.length-1;e++)r=r?`${r}/${t[e]}`:t[e],n.push({prefix:r,children:await IG(r)});c(e=>{let t=e;for(let{prefix:e,children:r}of n)t=Iq(t,e,e=>({...e,children:r,expanded:!0}));return t})},[]),eU=(0,Q.useCallback)(async e=>{let t=await IG(e);""===e?c(e=>{let n=new Map(e.map(e=>[e.path,e]));return t.map(e=>{let t=n.get(e.path);return t&&("dir"===t.type||"app"===t.type)?{...e,expanded:t.expanded,children:t.children}:e})}):c(n=>Iq(n,e,e=>({...e,children:t,expanded:!0})))},[]),ez=(0,Q.useCallback)(e=>{let t=[];for(let n of e)("dir"===n.type||"app"===n.type)&&n.expanded&&n.children&&(t.push(n.path),t.push(...ez(n.children)));return t},[]),e$=(0,Q.useCallback)(async()=>{g(!0);try{let e=ez(l),t=await IG("");for(let n of(c(t),e)){let e=await IG(n);c(t=>Iq(t,n,t=>({...t,children:e,expanded:!0})))}}finally{g(!1)}},[l,ez]),eG=(0,Q.useCallback)(async()=>{if(F&&(["editor","text"].includes(IF(F.name,F.nodeType))||IU(F.name))){ee(!0);try{let e=await fetch(`/api/wiki/content?path=${encodeURIComponent(F.path)}`);if(e.ok){let t=await e.json();J(t.content)}}catch{}ee(!1)}},[F]);async function eq(e){if("dir"===e.type||"app"===e.type)if(e.expanded)c(t=>Iq(t,e.path,e=>({...e,expanded:!1})));else if(void 0===e.children){c(t=>Iq(t,e.path,e=>({...e,loading:!0})));let t=await IG(e.path);c(n=>Iq(n,e.path,e=>({...e,loading:!1,children:t,expanded:!0})))}else c(t=>Iq(t,e.path,e=>({...e,expanded:!0})))}async function eV(e){if(H({path:e.path,name:e.name,nodeType:"app"===e.type?"app":"node-app"===e.type?"node-app":"file"}),en(!1),eD(null),J(null),["editor","text"].includes(IF(e.name,e.type))||IU(e.name)){ee(!0);try{let t=await fetch(`/api/wiki/content?path=${encodeURIComponent(e.path)}`);if(t.ok){let e=await t.json();J(e.content)}}catch{}ee(!1)}}(0,Q.useEffect)(()=>{ej.current=F},[F]),(0,Q.useEffect)(()=>{eB.current=et},[et]),(0,Q.useEffect)(()=>{eF.current=eG},[eG]),(0,Q.useEffect)(()=>{if(!t)return;let e=new Map,n=new EventSource("/api/wiki/watch");return n.onmessage=t=>{var n;let r;try{r=JSON.parse(t.data)}catch{return}let{type:i,path:o}=r,s=o.split("/");if(n=s.length>1?s.slice(0,-1).join("/"):"",e.has(n)&&clearTimeout(e.get(n)),e.set(n,setTimeout(()=>{e.delete(n),eU(n)},300)),"change"===i&&ej.current?.path===o&&!eB.current){let t=`__file__${o}`;e.has(t)&&clearTimeout(e.get(t)),e.set(t,setTimeout(()=>{e.delete(t),eF.current()},400))}},()=>{for(let t of(n.close(),e.values()))clearTimeout(t)}},[t,eU]),(0,Q.useEffect)(()=>{z(!1)},[]),(0,Q.useEffect)(()=>{if(!o||F&&F.path===o)return;let e=o.split("/").pop()??o;eV({path:o,name:e,type:"file"})},[o]),(0,Q.useEffect)(()=>{let e=new URL(window.location.href);F?e.searchParams.set("path",F.path):e.searchParams.delete("path"),window.history.replaceState(null,"",e.toString())},[F]),(0,Q.useEffect)(()=>{if(a.current||!d)return;let e=s.current;if(!e){a.current=!0;return}a.current=!0,(async()=>{let t=e.split("/"),n=t[t.length-1],r=t.slice(0,-1).join("/"),i=(await IG(r)).find(t=>t.path===e);i&&(await eH(e),eV({path:e,name:n,type:i.type,modifiedAt:i.modifiedAt}))})()},[d,eH]);let eW=async()=>{await fetch("/api/system/clear-root",{method:"POST"}),H(null),J(null),en(!1),c([]),u(!1),f.current=!1,i(null),n(!1)};async function eK(){if(!F)return;eO(!0),eD(null);let e=await fetch("/api/wiki/content",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:F.path,content:eC})});e.ok?(J(eC),en(!1)):eD((await e.json()).error??"Save failed"),eO(!1)}let eY=(0,Q.useCallback)(async(e,t)=>{let n=Array.from(e);if(n.length){y(!0),v(null);try{for(let e of n){let n=new FormData;n.append("file",e),n.append("dir",t);let r=await fetch("/api/wiki/upload",{method:"POST",body:n});if(!r.ok){let e=await r.json();v(e.error??"Upload failed"),_o(e.error??"Upload failed");break}}await eU(t)}catch{v("Upload failed.")}finally{y(!1),E.current&&(E.current.value="")}}},[eU]);function eX(e){w.current=e,E.current?.click()}async function eQ(){let e=N.trim();if(!e||null===k)return;C(null);let t=k?`${k}/${e}`:e,n=await fetch("/api/wiki/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});n.ok?(T(null),A(""),await eU(k),""!==k&&c(e=>Iq(e,k,e=>({...e,expanded:!0})))):C((await n.json()).error??"Failed")}async function eJ(){let e=O.trim();if(!e||null===_)return;R(null);let t=e.includes(".")?e:`${e}.md`,n=_?`${_}/${t}`:t,r=await fetch("/api/wiki/new-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})});r.ok?(M(null),I(""),await eU(_),""!==_&&c(e=>Iq(e,_,e=>({...e,expanded:!0}))),eV({path:n,name:t,type:"file",modifiedAt:new Date().toISOString()})):R((await r.json()).error??"Failed")}async function eZ(){L&&(await fetch("/api/wiki",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:L})}),(F?.path===L||F?.path.startsWith(`${L}/`))&&(H(null),J(null)),c(e=>(function e(t,n){return t.filter(e=>e.path!==n).map(t=>t.children?{...t,children:e(t.children,n)}:t)})(e,L)),P(null))}function e0(e,t,n){e.preventDefault(),e.stopPropagation();let r=eR.current;!r||r.path===t||t.startsWith(`${r.path}/`)||(e.dataTransfer.dropEffect="move",eP("root"===n?"":t))}async function e1(e,t){e.preventDefault(),e.stopPropagation(),eP(null);let n=eR.current;if(eR.current=null,!n||n.path===t||t.startsWith(`${n.path}/`))return;let r=t?`${t}/${n.name}`:n.name;if(r!==n.path&&(await fetch("/api/wiki/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:n.path,to:r})})).ok){let e=n.path.includes("/")?n.path.split("/").slice(0,-1).join("/"):"";await eU(e),t!==e&&await eU(t),F?.path===n.path&&H({path:r,name:n.name,nodeType:F.nodeType})}}let e2=F?IF(F.name,F.nodeType):null,e3=Ey(e=>e.width),e5=null===e2||"editor"===e2||"text"===e2||"source"===e2||"notebook"===e2||"fallback"===e2,e4=e5?Ef[e3]:"";return(0,X.jsxs)("div",{className:"flex h-screen gap-0 overflow-hidden bg-background",children:[null===t&&(0,X.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,X.jsx)(eg,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),!1===t&&(0,X.jsx)(MC,{onSelect:e=>{u(!1),f.current=!1,i(e),n(!0)}}),!0===t&&(0,X.jsxs)(X.Fragment,{children:[!q&&(0,X.jsxs)(Ig,{className:"flex flex-col w-72 shrink-0 overflow-hidden rounded-none border-r border-l-0 border-t-0 border-b-0",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b bg-muted shrink-0",children:[(0,X.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,X.jsx)("img",{src:"/logo.svg",alt:"Wiki Viewer",className:"h-5 w-5 shrink-0"}),(0,X.jsx)("span",{className:"truncate text-xs font-semibold tracking-tight",children:"Wiki Viewer"})]}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 shrink-0",title:"Collapse sidebar",onClick:()=>V(!0),children:(0,X.jsx)(ey,{className:"h-3.5 w-3.5"})})]}),(0,X.jsxs)("div",{className:"flex items-center justify-between gap-1 px-3 py-1.5 border-b bg-muted/50 shrink-0",children:[(0,X.jsxs)(OZ,{children:[(0,X.jsx)(O1,{asChild:!0,children:(0,X.jsxs)(tG,{size:"sm",variant:"ghost",className:"h-7 gap-1 px-2 text-xs",disabled:b,children:[b?(0,X.jsx)(eg,{className:"h-3.5 w-3.5 animate-spin"}):(0,X.jsx)(eE,{className:"h-3.5 w-3.5"}),"New",(0,X.jsx)(es,{className:"h-3 w-3 opacity-60"})]})}),(0,X.jsxs)(Ii,{align:"start",className:"w-44",children:[(0,X.jsxs)(Io,{onClick:()=>{M(""),I(""),R(null)},children:[(0,X.jsx)(ec,{className:"mr-2 h-3.5 w-3.5"}),"New file"]}),(0,X.jsxs)(Io,{onClick:()=>{T(""),A(""),C(null)},children:[(0,X.jsx)(ep,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}),(0,X.jsxs)(Io,{onClick:()=>eX(""),disabled:b,children:[(0,X.jsx)(eA,{className:"mr-2 h-3.5 w-3.5"}),"Upload"]})]})]}),(0,X.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh tree",onClick:e$,disabled:m,children:m?(0,X.jsx)(eg,{className:"h-3.5 w-3.5 animate-spin"}):(0,X.jsx)(ew,{className:"h-3.5 w-3.5"})}),(0,X.jsx)(Ic,{}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"AI Agent panel",onClick:()=>Ee.getState().toggle(),children:(0,X.jsx)(ei,{className:"h-3.5 w-3.5"})}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Settings",onClick:()=>K(!0),children:(0,X.jsx)(ek,{className:"h-3.5 w-3.5"})})]})]}),x&&(0,X.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0",children:[(0,X.jsx)(er,{className:"h-3.5 w-3.5 shrink-0"}),x]}),""===k&&(0,X.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,X.jsx)(eu,{className:"h-4 w-4 shrink-0 text-warning"}),(0,X.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:N,onChange:e=>A(e.target.value),onKeyDown:e=>{"Enter"===e.key&&eQ(),"Escape"===e.key&&(T(null),A(""))}}),S&&(0,X.jsx)("span",{className:"text-xs text-destructive",children:S}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:eQ,children:(0,X.jsx)(eo,{className:"h-3 w-3"})}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{T(null),A("")},children:(0,X.jsx)(eS,{className:"h-3 w-3"})})]}),""===_&&(0,X.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,X.jsx)(ed,{className:"h-4 w-4 shrink-0 text-accent"}),(0,X.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:O,onChange:e=>I(e.target.value),onKeyDown:e=>{"Enter"===e.key&&eJ(),"Escape"===e.key&&(M(null),I(""))}}),D&&(0,X.jsx)("span",{className:"text-xs text-destructive",children:D}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:eJ,children:(0,X.jsx)(eo,{className:"h-3 w-3"})}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{M(null),I("")},children:(0,X.jsx)(eS,{className:"h-3 w-3"})})]}),(0,X.jsx)("div",{className:tz("flex-1 overflow-auto py-1",""===eL&&"ring-2 ring-inset ring-primary bg-primary/5"),onDragOver:e=>e0(e,"","root"),onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||eP(null)},onDrop:e=>e1(e,""),children:h?(0,X.jsx)("div",{className:"flex justify-center py-6",children:(0,X.jsx)(eg,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):0===l.length?(0,X.jsxs)("div",{className:"flex flex-col items-center gap-3 px-4 py-8 text-center",children:[(0,X.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,X.jsx)(ed,{className:"h-6 w-6 text-muted-foreground"})}),(0,X.jsxs)("div",{className:"space-y-1",children:[(0,X.jsx)("p",{className:"text-sm font-medium",children:"No files yet"}),(0,X.jsx)("p",{className:"text-xs text-muted-foreground",children:"Upload files or add them to the configured directory"})]}),(0,X.jsxs)(tG,{size:"sm",variant:"outline",className:"w-full gap-1.5 max-w-[180px]",onClick:()=>eX(""),disabled:b,children:[b?(0,X.jsx)(eg,{className:"h-3.5 w-3.5 animate-spin"}):(0,X.jsx)(eA,{className:"h-3.5 w-3.5"}),"Upload Files"]})]}):function e(t,n=0){return t.map(t=>(0,X.jsxs)("div",{children:[(0,X.jsxs)("div",{role:"treeitem",tabIndex:0,draggable:!0,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),"dir"===t.type?eq(t):"app"===t.type?(eV(t),eq(t)):eV(t))},onDragStart:e=>{eR.current=t,e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",t.path)},onDragOver:e=>"dir"===t.type?e0(e,t.path,"dir"):e.preventDefault(),onDragLeave:()=>eP(null),onDrop:e=>"dir"===t.type?e1(e,t.path):e.preventDefault(),className:tz("flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer group transition-colors select-none",F?.path===t.path?"bg-accent text-accent-foreground":"hover:bg-accent/50",eL===t.path&&"ring-2 ring-primary bg-primary-soft",t.name.startsWith(".")&&"opacity-40"),style:{paddingLeft:`${14*n+8}px`},onClick:()=>{"dir"===t.type?eq(t):"app"===t.type?(eV(t),eq(t)):eV(t)},children:["dir"===t.type||"app"===t.type?t.loading?(0,X.jsx)(eg,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}):t.expanded?(0,X.jsx)(es,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):(0,X.jsx)(ea,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):(0,X.jsx)("span",{className:"w-3.5 shrink-0"}),"dir"===t.type?t.expanded?(0,X.jsx)(eh,{className:tz("h-4 w-4 shrink-0",F?.path!==t.path&&"text-warning")}):(0,X.jsx)(eu,{className:tz("h-4 w-4 shrink-0",F?.path!==t.path&&"text-warning")}):"app"===t.type?(0,X.jsx)(ef,{className:tz("h-4 w-4 shrink-0",F?.path!==t.path&&"text-accent")}):"node-app"===t.type?(0,X.jsx)(eT,{className:tz("h-4 w-4 shrink-0",F?.path!==t.path&&"text-emerald-500")}):"html"===IF(t.name,"file")?(0,X.jsx)(ef,{className:tz("h-4 w-4 shrink-0",F?.path!==t.path&&"text-accent/70")}):I$(t.name)?(0,X.jsx)(em,{className:tz("h-4 w-4 shrink-0",F?.path!==t.path&&"text-sunshine-700")}):IU(t.name)?(0,X.jsx)(ed,{className:tz("h-4 w-4 shrink-0",F?.path!==t.path&&"text-accent")}):(0,X.jsx)(el,{className:tz("h-4 w-4 shrink-0",F?.path!==t.path&&"text-muted-foreground")}),(0,X.jsx)("span",{className:"flex-1 truncate",children:t.name}),(0,X.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:["dir"===t.type&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",title:"New file here (default .md)",onClick:async()=>{t.expanded||await eq(t),M(t.path),I(""),R(null)},children:(0,X.jsx)(ec,{className:"h-3 w-3"})}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",title:"Upload here",onClick:()=>eX(t.path),children:(0,X.jsx)(eA,{className:"h-3 w-3"})}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",title:"New subfolder",onClick:()=>{T(t.path),A(""),C(null)},children:(0,X.jsx)(ep,{className:"h-3 w-3"})})]}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-destructive hover:text-destructive",title:"Delete",onClick:()=>{P(t.path),B("file"!==t.type)},children:(0,X.jsx)(eN,{className:"h-3 w-3"})})]})]}),k===t.path&&"dir"===t.type&&(0,X.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(n+1)*14+8}px`},children:[(0,X.jsx)("span",{className:"w-3.5 shrink-0"}),(0,X.jsx)(eu,{className:"h-4 w-4 shrink-0 text-warning"}),(0,X.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:N,onChange:e=>A(e.target.value),onKeyDown:e=>{"Enter"===e.key&&eQ(),"Escape"===e.key&&(T(null),A(""))}}),S&&(0,X.jsx)("span",{className:"text-xs text-destructive",children:S}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:eQ,children:(0,X.jsx)(eo,{className:"h-3 w-3"})}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{T(null),A("")},children:(0,X.jsx)(eS,{className:"h-3 w-3"})})]}),_===t.path&&"dir"===t.type&&(0,X.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(n+1)*14+8}px`},children:[(0,X.jsx)("span",{className:"w-3.5 shrink-0"}),(0,X.jsx)(ed,{className:"h-4 w-4 shrink-0 text-accent"}),(0,X.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:O,onChange:e=>I(e.target.value),onKeyDown:e=>{"Enter"===e.key&&eJ(),"Escape"===e.key&&(M(null),I(""))}}),D&&(0,X.jsx)("span",{className:"text-xs text-destructive",children:D}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:eJ,children:(0,X.jsx)(eo,{className:"h-3 w-3"})}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{M(null),I("")},children:(0,X.jsx)(eS,{className:"h-3 w-3"})})]}),("dir"===t.type||"app"===t.type)&&t.expanded&&t.children&&t.children.length>0&&e(t.children,n+1),("dir"===t.type||"app"===t.type)&&t.expanded&&t.children?.length===0&&(0,X.jsx)("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:`${(n+1)*14+8+14+6+16+6}px`},children:"Empty"})]},t.path))}(l)}),(0,X.jsxs)("div",{className:"border-t px-3 py-2 flex items-center gap-2 bg-muted shrink-0",children:[(0,X.jsx)("span",{className:"flex-1 text-xs text-muted-foreground font-mono truncate",title:r??"",children:r??""}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-6 shrink-0 text-xs px-2 text-muted-foreground hover:text-foreground",onClick:eW,children:"Change"})]})]}),(0,X.jsxs)("div",{className:"flex-1 flex flex-col min-w-0 relative",children:[q&&(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"absolute left-0 top-1/2 -translate-y-1/2 z-10 h-7 w-7 p-0 rounded-full bg-background/50 backdrop-blur-xl backdrop-saturate-150 border border-white/[0.08] text-foreground/60 hover:text-foreground/90 hover:bg-background/70 shadow-[0_0_12px_rgba(0,0,0,0.15)] [transform:translate(-50%,-50%)_translateZ(0)]",title:"Show sidebar",onClick:()=>V(!1),children:(0,X.jsx)(ex,{className:"h-3.5 w-3.5"})}),F?"node-app"===e2?(0,X.jsx)(Mk,{path:F.path,title:F.name}):"app"===e2||"html"===e2?(e="html"===e2?`/api/assets/${F.path}`:void 0,U?(0,X.jsx)(Mx,{path:F.path,title:F.name,src:e,fullscreen:!0,onExit:()=>z(!1)}):(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0",children:[(0,X.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,X.jsx)(ef,{className:"h-4 w-4 shrink-0 text-accent"}),(0,X.jsx)("span",{className:"text-sm font-normal truncate",title:F.path,children:F.path})]}),(0,X.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:["html"===e2&&!et&&null!==Y&&(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Edit source",onClick:()=>{en(!0),e_(Y),eD(null)},children:(0,X.jsx)(ev,{className:"h-3.5 w-3.5"})}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh",onClick:()=>G(e=>e+1),children:(0,X.jsx)(ew,{className:"h-3.5 w-3.5"})}),(0,X.jsxs)(tG,{size:"sm",variant:"ghost",className:"h-7 gap-1.5 text-xs",onClick:()=>z(!0),children:[(0,X.jsx)(eb,{className:"h-3.5 w-3.5"}),"Open fullscreen"]}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{H(null),en(!1)},children:(0,X.jsx)(eS,{className:"h-3.5 w-3.5"})})]})]}),et&&"html"===e2?(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[(0,X.jsx)("textarea",{value:eC,onChange:e=>e_(e.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"}),(0,X.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[eI&&(0,X.jsx)("span",{className:"text-xs text-destructive mr-auto",children:eI}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",onClick:()=>{en(!1),eD(null)},children:"Cancel"}),(0,X.jsxs)(tG,{size:"sm",className:"gap-1",onClick:eK,disabled:eM,children:[eM&&(0,X.jsx)(eg,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):(0,X.jsx)(Mx,{path:F.path,title:F.name,src:e},$)]})):(0,X.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0",children:[(0,X.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[I$(F.name)?(0,X.jsx)(em,{className:"h-4 w-4 shrink-0 text-sunshine-700"}):IU(F.name)?(0,X.jsx)(ed,{className:"h-4 w-4 shrink-0 text-accent"}):(0,X.jsx)(el,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,X.jsx)("span",{className:"text-sm font-normal truncate",title:F.path,children:F.path})]}),(0,X.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[IU(F.name)&&!et&&null!==Y&&(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{en(!0),e_(Y),eD(null),Iz(F.name)&&Eu.getState().loadPage(F.path)},children:(0,X.jsx)(ev,{className:"h-3.5 w-3.5"})}),IU(F.name)&&!et&&null!==Y&&(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh",onClick:eG,disabled:Z,children:Z?(0,X.jsx)(eg,{className:"h-3.5 w-3.5 animate-spin"}):(0,X.jsx)(ew,{className:"h-3.5 w-3.5"})}),e5&&(0,X.jsx)(Ij,{}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{H(null),J(null),en(!1)},children:(0,X.jsx)(eS,{className:"h-3.5 w-3.5"})})]})]}),et?(0,X.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:Iz(F.name)?(0,X.jsx)(_p,{}):(0,X.jsx)("textarea",{value:eC,onChange:e=>e_(e.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"})}):(0,X.jsx)("div",{className:"flex-1 overflow-auto p-4 min-h-0",children:(0,X.jsx)("div",{className:tz("mx-auto w-full",e4),children:Z?(0,X.jsx)("div",{className:"flex justify-center py-8",children:(0,X.jsx)(eg,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):"csv"===e2?(0,X.jsx)(rz,{path:F.path,title:F.name}):"pdf"===e2?(0,X.jsx)(Mf,{path:F.path,title:F.name}):"mermaid"===e2?(0,X.jsx)(_w,{path:F.path,title:F.name}):"notebook"===e2?(0,X.jsx)(Mc,{path:F.path,title:F.name}):"image"===e2?(0,X.jsx)(_m,{path:F.path,title:F.name}):"media"===e2?(0,X.jsx)(_g,{path:F.path,title:F.name,type:["mp4","webm","mov","m4v"].includes(IB(F.name))?"video":"audio"}):"docx"===e2?(0,X.jsx)(Mu,{path:F.path,title:F.name}):"xlsx"===e2?(0,X.jsx)(Mp,{path:F.path,title:F.name}):"pptx"===e2?(0,X.jsx)(Mh,{path:F.path,title:F.name}):"source"===e2?(0,X.jsx)(My,{path:F.path,title:F.name}):"fallback"===e2?(0,X.jsx)(_f,{path:F.path,title:F.name}):null!==Y?["md","markdown"].includes(IB(F.name))?(()=>{let{data:e,body:t}=function(e){let t=Iw.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(Ik(n[1])),t+=1}if(e.length>0){o[n]=e,a=t;continue}o[n]="",a+=1;continue}o[n]=Ik(r),a+=1}return 0===Object.keys(o).length?{data:{},body:e}:{data:o,body:r}}(Y);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Iv,{data:e}),(0,X.jsx)(IE,{markdown:t,pagePath:F.path,onNavigate:(e,t)=>{eV({path:e,name:e.split("/").pop()??e,type:"file"}),t&&setTimeout(()=>{document.getElementById(t)?.scrollIntoView({behavior:"smooth"})},200)}})]})})():(0,X.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words leading-relaxed",children:Y}):IU(F.name)?(0,X.jsx)("p",{className:"text-sm text-muted-foreground",children:"Could not load file."}):(0,X.jsx)("p",{className:"text-sm text-muted-foreground",children:"Preview not available for this file type."})})}),et&&(0,X.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[eI&&(0,X.jsx)("span",{className:"text-xs text-destructive mr-auto",children:eI}),(0,X.jsx)(tG,{size:"sm",variant:"ghost",onClick:()=>{en(!1),eD(null)},children:"Cancel"}),(0,X.jsxs)(tG,{size:"sm",className:"gap-1",onClick:eK,disabled:eM,children:[eM&&(0,X.jsx)(eg,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):(0,X.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center",children:(0,X.jsxs)("div",{className:"flex flex-col items-center gap-2 text-center px-4",children:[(0,X.jsx)(ed,{className:"h-8 w-8 text-muted-foreground"}),(0,X.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a file to view or edit"})]})})]}),(0,X.jsx)(Im,{open:W,onOpenChange:K}),(0,X.jsx)(IP,{currentPath:F?.path}),(0,X.jsx)("input",{ref:E,type:"file",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&eY(e.target.files,w.current)}}),(0,X.jsx)(rL,{open:!!L,onOpenChange:e=>{e||P(null)},title:j?"Delete folder?":"Delete file?",description:j?`"${L?.split("/").pop()}" and all its contents will be permanently deleted.`:`"${L?.split("/").pop()}" will be permanently removed.`,onConfirm:eZ})]})]})}],952683)}]);
|