@inkeep/open-knowledge 0.15.1-beta.8 → 0.15.1-beta.9
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/dist/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/cli.mjs +5 -5
- package/dist/constants-45kbionG.mjs +2 -0
- package/dist/index.mjs +1 -1
- package/dist/init-CFy1v9OU.mjs +1 -0
- package/dist/{init-aYL9jcNv.mjs → init-S6N7HGlR.mjs} +3 -3
- package/dist/{loader-CWI8ks9W.mjs → loader-BlR5SsS3.mjs} +2 -2
- package/dist/loader-vWnbOeXG.mjs +1 -0
- package/dist/{preview-D8NePS8S.mjs → preview-BdRYuvln.mjs} +2 -2
- package/dist/preview-Bs5B9vWy.mjs +1 -0
- package/dist/public/assets/index-CIPatjw4.css +1 -0
- package/dist/public/assets/{index-COE4tg_p.js → index-CUqVgOkL.js} +2 -2
- package/dist/public/index.html +2 -2
- package/dist/{repair-launch-json-DXLiy3_c.mjs → repair-launch-json-47lc8gQh.mjs} +2 -2
- package/dist/{repair-mcp-configs-DB8b3UTm.mjs → repair-mcp-configs-D6a57B0Q.mjs} +2 -2
- package/dist/{src-S9W6ORmK.mjs → src-DZDtmRql.mjs} +2 -2
- package/dist/{start-8EN9Ekcs.mjs → start-CrHnVN7A.mjs} +2 -2
- package/dist/start-zR3iOFcP.mjs +1 -0
- package/package.json +1 -1
- package/dist/constants-BVR2lBMG.mjs +0 -2
- package/dist/init-CouVGATa.mjs +0 -1
- package/dist/loader-m_58dShD.mjs +0 -1
- package/dist/preview-D3Z-uBc0.mjs +0 -1
- package/dist/public/assets/index-5V9bJ3LG.css +0 -1
- package/dist/start-_FVQvoNg.mjs +0 -1
|
@@ -26,7 +26,7 @@ Error generating stack: `+e.message+`
|
|
|
26
26
|
`).trim();return i.length===0||i.length>gC||i.includes(`
|
|
27
27
|
`)?null:i}function xC(e){let t=ze(e.state);return{current:t.matches.length===0?0:t.activeIndex+1,total:t.matches.length}}function SC(e,t){return e.current===t.current&&e.total===t.total}function CC(e,t,n){e&&!e.isDestroyed&&(e.commands.clearFindMatches(),e.commands.focus()),t(e=>({...e,open:!1,activeIndex:0})),n(hC)}function wC(e){!e||e.isDestroyed||typeof window>`u`||window.requestAnimationFrame(()=>{if(e.isDestroyed)return;let t=w(e);if(!t)return;let n=t.dom.querySelector(`.ok-find-match-active`);n instanceof HTMLElement&&n.scrollIntoView({block:`center`,inline:`nearest`,behavior:`auto`})})}function TC(e){let t=(0,$.c)(81),{activeDocName:n,isSourceMode:r}=e,i=vC(n),a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),s=(0,Q.useRef)(n),c=(0,Q.useRef)(0),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l={open:!1,replaceOpen:!1,query:``,replacement:``,caseSensitive:!1,wholeWord:!1,activeIndex:0},t[0]=l):l=t[0];let[u,d]=(0,Q.useState)(l),[f,p]=(0,Q.useState)(hC),m,h;t[1]===n?(m=t[2],h=t[3]):(m=()=>{s.current!==n&&(s.current=n,d(DC))},h=[n],t[1]=n,t[2]=m,t[3]=h),(0,Q.useEffect)(m,h);let g,_;t[4]===u.activeIndex?(g=t[5],_=t[6]):(g=()=>{c.current=u.activeIndex},_=[u.activeIndex],t[4]=u.activeIndex,t[5]=g,t[6]=_),(0,Q.useEffect)(g,_);let v,y;t[7]===i?(v=t[8],y=t[9]):(v=()=>{let e=o.current;e&&e!==i&&!e.isDestroyed&&e.commands.clearFindMatches(),o.current=i},y=[i],t[7]=i,t[8]=v,t[9]=y),(0,Q.useEffect)(v,y);let b,x;t[10]===u.open?(b=t[11],x=t[12]):(b=()=>{if(!u.open||!a.current)return;let e=requestAnimationFrame(()=>{a.current?.focus(),a.current?.select()});return()=>cancelAnimationFrame(e)},x=[u.open],t[10]=u.open,t[11]=b,t[12]=x),(0,Q.useEffect)(b,x);let S,C;t[13]!==u.open||t[14]!==r?(S=()=>{!u.open||!r||d(EC)},C=[u.open,r],t[13]=u.open,t[14]=r,t[15]=S,t[16]=C):(S=t[15],C=t[16]),(0,Q.useEffect)(S,C);let w,T;t[17]!==i||t[18]!==u.caseSensitive||t[19]!==u.open||t[20]!==u.query||t[21]!==u.wholeWord||t[22]!==r?(w=()=>{if(!i||i.isDestroyed){p(hC);return}if(!u.open||r){i.commands.clearFindMatches(),p(hC);return}let e=window.setTimeout(()=>{if(i.isDestroyed)return;i.commands.setFindQuery(u.query,{options:{caseSensitive:u.caseSensitive,wholeWord:u.wholeWord},activeIndex:c.current});let e=xC(i);p(t=>SC(t,e)?t:e)},_C);return()=>window.clearTimeout(e)},T=[i,u.open,u.query,u.caseSensitive,u.wholeWord,r],t[17]=i,t[18]=u.caseSensitive,t[19]=u.open,t[20]=u.query,t[21]=u.wholeWord,t[22]=r,t[23]=w,t[24]=T):(w=t[23],T=t[24]),(0,Q.useEffect)(w,T);let E,D;t[25]!==i||t[26]!==u.open||t[27]!==r?(E=()=>{if(!i||i.isDestroyed||!u.open||r)return;let e=()=>{let e=ze(i.state),t=xC(i);p(e=>SC(e,t)?e:t),d(t=>t.activeIndex===e.activeIndex?t:{...t,activeIndex:e.activeIndex})};return i.on(`transaction`,e),()=>{i.off(`transaction`,e)}},D=[i,u.open,r],t[25]=i,t[26]=u.open,t[27]=r,t[28]=E,t[29]=D):(E=t[28],D=t[29]),(0,Q.useEffect)(E,D);let O,k;t[30]!==n||t[31]!==i||t[32]!==u.open||t[33]!==r?(O=()=>{let e=function(e){let t=bC(i);d(n=>({...n,open:!0,replaceOpen:e,query:t??n.query,activeIndex:0}))},t=function(t){if(!(!n||r||t.defaultPrevented)){if(qs(t,`find`)){t.preventDefault(),u.open?CC(i,d,p):e(!1);return}if(qs(t,`replace`)){t.preventDefault(),e(!0);return}if(u.open){let e=qs(t,`find-next`),n=qs(t,`find-previous`);if(e||n){t.preventDefault(),(n?i?.commands.selectPreviousFindMatch():i?.commands.selectNextFindMatch())&&wC(i);return}}t.key===`Escape`&&u.open&&(t.preventDefault(),CC(i,d,p))}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},k=[n,i,u.open,r],t[30]=n,t[31]=i,t[32]=u.open,t[33]=r,t[34]=O,t[35]=k):(O=t[34],k=t[35]),(0,Q.useEffect)(O,k);let A;t[36]!==i||t[37]!==u.caseSensitive||t[38]!==u.query||t[39]!==u.wholeWord?(A=function(){return!i||i.isDestroyed?!1:(i.commands.setFindQuery(u.query,{options:{caseSensitive:u.caseSensitive,wholeWord:u.wholeWord},activeIndex:c.current}),!0)},t[36]=i,t[37]=u.caseSensitive,t[38]=u.query,t[39]=u.wholeWord,t[40]=A):A=t[40];let j=A,M;t[41]===i?M=t[42]:(M=function(){if(!i||i.isDestroyed)return;let e=ze(i.state),t=xC(i);p(e=>SC(e,t)?e:t),d(t=>t.activeIndex===e.activeIndex?t:{...t,activeIndex:e.activeIndex})},t[41]=i,t[42]=M);let N=M,P;t[43]===i?P=t[44]:(P=function(){CC(i,d,p)},t[43]=i,t[44]=P);let F=P,I;t[45]!==j||t[46]!==i||t[47]!==N?(I=function(){!i||i.isDestroyed||(j(),i.commands.selectNextFindMatch()&&wC(i),N())},t[45]=j,t[46]=i,t[47]=N,t[48]=I):I=t[48];let L=I,R;t[49]!==j||t[50]!==i||t[51]!==N?(R=function(){!i||i.isDestroyed||(j(),i.commands.selectPreviousFindMatch()&&wC(i),N())},t[49]=j,t[50]=i,t[51]=N,t[52]=R):R=t[52];let z=R,B;t[53]!==j||t[54]!==i||t[55]!==u.replacement||t[56]!==N?(B=function(){!i||i.isDestroyed||(j(),i.commands.replaceCurrentFindMatch(u.replacement)&&wC(i),N())},t[53]=j,t[54]=i,t[55]=u.replacement,t[56]=N,t[57]=B):B=t[57];let V=B,H;t[58]!==j||t[59]!==i||t[60]!==u.replacement||t[61]!==N?(H=function(){!i||i.isDestroyed||(j(),i.commands.replaceAllFindMatches(u.replacement)&&wC(i),N())},t[58]=j,t[59]=i,t[60]=u.replacement,t[61]=N,t[62]=H):H=t[62];let U=H;if(!u.open||!n||r)return null;let W,G,K,q,J;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>d(t=>({...t,query:e,activeIndex:0})),G=e=>d(t=>({...t,replacement:e})),K=e=>d(t=>({...t,replaceOpen:e})),q=e=>d(t=>({...t,caseSensitive:e})),J=e=>d(t=>({...t,wholeWord:e})),t[63]=W,t[64]=G,t[65]=K,t[66]=q,t[67]=J):(W=t[63],G=t[64],K=t[65],q=t[66],J=t[67]);let Y;return t[68]!==F||t[69]!==u.caseSensitive||t[70]!==u.query||t[71]!==u.replaceOpen||t[72]!==u.replacement||t[73]!==u.wholeWord||t[74]!==f.current||t[75]!==f.total||t[76]!==U||t[77]!==V||t[78]!==L||t[79]!==z?(Y=(0,Z.jsx)(`div`,{className:`editor-content-aligned pointer-events-none absolute inset-x-0 top-2 z-30 px-2`,children:(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(mC,{findInputRef:a,query:u.query,replacement:u.replacement,replaceOpen:u.replaceOpen,caseSensitive:u.caseSensitive,wholeWord:u.wholeWord,current:f.current,total:f.total,onQueryChange:W,onReplacementChange:G,onReplaceOpenChange:K,onCaseSensitiveChange:q,onWholeWordChange:J,onNext:L,onPrevious:z,onReplaceCurrent:V,onReplaceAll:U,onClose:F})})}),t[68]=F,t[69]=u.caseSensitive,t[70]=u.query,t[71]=u.replaceOpen,t[72]=u.replacement,t[73]=u.wholeWord,t[74]=f.current,t[75]=f.total,t[76]=U,t[77]=V,t[78]=L,t[79]=z,t[80]=Y):Y=t[80],Y}function EC(e){return{...e,open:!1,activeIndex:0}}function DC(e){return{...e,activeIndex:0}}var OC=300;function kC(e,t){let n=(0,$.c)(4),[r,i]=(0,Q.useState)(gc),a,o;return n[0]!==t||n[1]!==e?(a=()=>{if(!e||!t){i(gc);return}let n=e.document.getText(`source`),r=!1,a=null,o=function(){r||i(xc(n.toString()))};o();let s=function(){a&&clearTimeout(a),a=setTimeout(o,OC)};return n.observe(s),()=>{r=!0,n.unobserve(s),a&&clearTimeout(a)}},o=[e,t],n[0]=t,n[1]=e,n[2]=a,n[3]=o):(a=n[2],o=n[3]),(0,Q.useEffect)(a,o),r}function AC(e){return e&&e.document.getMap(`lifecycle`).get(`status`)===`conflict`?`conflict`:null}function jC(e){let t=(0,$.c)(8),{poolEntries:n}=pt(),r;t[0]!==e||t[1]!==n?(r=e?n.find(t=>t.docName===e)??null:null,t[0]=e,t[1]=n,t[2]=r):r=t[2];let i=r?.provider??null,a;t[3]===i?a=t[4]:(a=()=>AC(i),t[3]=i,t[4]=a);let[o,s]=(0,Q.useState)(a),c,l;return t[5]===i?(c=t[6],l=t[7]):(c=()=>{if(!i){s(null);return}let e=i.document.getMap(`lifecycle`);s(AC(i));let t=()=>s(AC(i));return e.observe(t),()=>{e.unobserve(t)}},l=[i],t[5]=i,t[6]=c,t[7]=l),(0,Q.useEffect)(c,l),o}function MC(e,t){let n=(0,$.c)(3),r;return n[0]!==e||n[1]!==t?(r=()=>Cc(e,t),n[0]=e,n[1]=t,n[2]=r):r=n[2],(0,Q.useSyncExternalStore)(wc,r)}var NC=`ok-doc-panel-width-v1`;function PC(e){return Number.isFinite(e)?e<300?300:e>600?600:Math.round(e):320}function FC(e){try{let t=(e??localStorage).getItem(NC);if(t==null)return 320;let n=Number.parseInt(t,10);return Number.isFinite(n)?PC(n):320}catch{return 320}}function IC(e,t){try{(t??localStorage).setItem(NC,String(PC(e)))}catch{}}function LC(){try{return typeof localStorage>`u`?320:FC()}catch{return 320}}var RC=1024,zC=1280,BC={left:RC,right:zC};function VC(e,t,n){return e==null?t>=BC[n]?`above`:`below`:`embedded`}function HC(e){return e===`above`?`open`:`collapsed`}var UC=`ok-sidebar-pins-v2`;function WC(e){return e===`open`||e===`collapsed`}function GC(e){return e===`above`||e===`below`||e===`embedded`}function KC(e){if(typeof e!=`object`||!e)return!1;let t=e;for(let e of Object.keys(t))if(!GC(e)||!WC(t[e]))return!1;return!0}function qC(e){let t=JSON.parse(e);if(typeof t!=`object`||!t)return{};let n=t,r={};return KC(n.left)&&(r.left=n.left),KC(n.right)&&(r.right=n.right),r}function JC(e){try{let t=(e??localStorage).getItem(UC);return t==null?{}:qC(t)}catch{return{}}}function YC(e,t){try{t.setItem(UC,JSON.stringify(e))}catch{}}function XC(e,t,n){return n[e]?.[t]??HC(t)}function ZC(e,t,n,r){let i=r??localStorage,a=JC(i);return a[e]={...a[e],[t]:n},YC(a,i),a}function QC(e){let t=(0,$.c)(3),[n,r]=(0,Q.useState)(`connecting`),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(!e){r(`connecting`);return}let t=e.configuration.websocketProvider.status;e.isSynced?r(`synced`):r(t===`connected`?`connected`:t===`disconnected`?`disconnected`:`connecting`);let n=e=>{let{status:t}=e;r(t===`connected`?$C:t===`disconnected`?`disconnected`:`connecting`)},i=e=>{let{state:t}=e;r(t?`synced`:`connected`)},a=()=>r(`disconnected`);return e.on(`status`,n),e.on(`synced`,i),e.on(`disconnect`,a),()=>{e.off(`status`,n),e.off(`synced`,i),e.off(`disconnect`,a)}},a=[e],t[0]=e,t[1]=i,t[2]=a),(0,Q.useEffect)(i,a),n}function $C(e){return e===`synced`?`synced`:`connected`}var ew=zr;function tw(e,t={}){let n=Oe(e.componentName);return n.name===`*`?t.unregisteredSuffix?`${e.componentName} (unregistered)`:e.componentName:n.displayName??n.name}var nw=200,rw=`Outside any block`;function iw(e){let t=(0,$.c)(5),{editor:n}=e,r=Gt(n),i=(0,Q.useRef)(null),a=(0,Q.useRef)(null),o=(0,Q.useRef)(!1),s,c;t[0]!==r||t[1]!==n?(s=()=>{if(a.current!==null&&(window.clearTimeout(a.current),a.current=null),!n||!i.current)return;let e=r!==null&&r.ancestorChain.length>0,t;return t=e?aw(n,r):o.current?rw:``,a.current=window.setTimeout(()=>{i.current&&(i.current.textContent=``,i.current.textContent=t),o.current=e,a.current=null},nw),()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)}},c=[n,r],t[0]=r,t[1]=n,t[2]=s,t[3]=c):(s=t[2],c=t[3]),(0,Q.useEffect)(s,c);let l;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`div`,{ref:i,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`}),t[4]=l):l=t[4],l}function aw(e,t){if(!t||t.ancestorChain.length===0)return``;let n=t.ancestorChain,r=n[n.length-1],i=tw(r,{unregisteredSuffix:!0});if(n.length===1)return`Selected: ${i}`;let a=n[n.length-2],o=tw(a);try{let t=e.state.doc.resolve(r.pos),n=t.index(t.depth),a=t.parent.childCount;return`Selected: ${i}, ${n+1} of ${a} in ${o}`}catch{return`Selected: ${i} in ${o}`}}function ow(){let[e]=(0,Q.useState)(Nr);return e}function sw({principal:e,identity:t}){return e&&e.source===`git-config`?{type:`human`,name:br(e.display_name),color:Wn(e.id,Mn),coeditor:t.coeditor,tabId:t.tabId,principalId:e.id}:e&&e.source===`synthesized`?{type:`human`,name:t.name,color:Wn(e.id,Mn),coeditor:t.coeditor,tabId:t.tabId}:{type:`human`,name:t.name,color:t.color,coeditor:t.coeditor,tabId:t.tabId}}function cw(e,t){return e>t}function lw(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.isChangeOrigin===!0?!0:`snapshot`in t&&`prevSnapshot`in t&&t.snapshot===null&&t.prevSnapshot===null}var uw=3,dw=6e4;function fw(e,t){let n=0;for(let r of e)t-r<dw&&(n+=1);return n<uw}var pw=new Map;function mw(e,t){for(let n of e.changed.keys()){let e=n;for(;e!=null;){if(e===t)return!0;let n=e._item;e=n==null?null:n.parent}}return!1}function hw(e){let t=Tt.getState(e);return t?.snapshot!=null||t?.prevSnapshot!=null}function gw(e){let{fragment:t,docName:n,onWedged:r}=e,i=0,a=0,o=!1,s=!1,c=!1,l=null,u=new WeakSet,d=e=>{let t=Tt.getState(e)?.binding;if(!t)return;if(typeof t._prosemirrorChanged!=`function`){ue.count(`ok/editor/binding-guard-disarmed`,{docName:n,reason:`no-prosemirror-changed`}),console.warn(`[binding-staleness-guard] ySync binding on "${n}" exposes no _prosemirrorChanged — write-back gate disarmed (vendored y-tiptap contract change?)`);return}if(u.has(t))return;u.add(t);let r=t._prosemirrorChanged.bind(t);t._prosemirrorChanged=e=>{cw(i,a)||r(e)}},f=()=>{if(c=!1,!s||o||!cw(i,a)||l!==null&&hw(l.state))return;o=!0;let e=Date.now();for(let[t,n]of pw)n.every(t=>e-t>=dw)&&pw.delete(t);let t=(pw.get(n)??[]).filter(t=>e-t<dw);if(!fw(t,e)){pw.set(n,t),ue.count(`ok/editor/binding-wedge-rate-capped`,{docName:n}),console.warn(`[binding-staleness-guard] wedge on "${n}" rate-capped (externalSeq=${i}, appliedSeq=${a}) — publication gate stays closed, no further recycle`);return}t.push(e),pw.set(n,t),console.warn(`[binding-staleness-guard] wedged binding on "${n}" — Y→PM apply missing (externalSeq=${i}, appliedSeq=${a})`);try{r({externalSeq:i,appliedSeq:a})}catch(e){o=!1,ue.count(`ok/editor/binding-wedge-recovery-error`,{docName:n}),console.error(`[binding-staleness-guard] wedge recovery threw for "${n}":`,e)}},p=e=>{e.origin!==Tt&&mw(e,t)&&(i+=1,c||(c=!0,queueMicrotask(f)))};return new ir({state:{init:()=>null,apply:e=>(lw(e.getMeta(Tt))&&(a=i,o&&ue.count(`ok/editor/binding-wedge-recovered`,{docName:n}),o=!1),null)},filterTransaction:(e,t)=>!cw(i,a)||hw(t)?!0:e.getMeta(Tt)!==void 0,view:e=>{let r=t.doc;return r==null?(ue.count(`ok/editor/binding-guard-disarmed`,{docName:n,reason:`no-ydoc`}),console.error(`[binding-staleness-guard] fragment has no Y.Doc for "${n}" — staleness guard disarmed`),{}):(s=!0,l=e,d(e.state),r.off(`beforeObserverCalls`,p),r.on(`beforeObserverCalls`,p),{destroy:()=>{s=!1,l=null,r.off(`beforeObserverCalls`,p)}})}})}function _w(e,t){let n=Math.min(e.top,t.top),r=Math.max(e.bottom,t.bottom),i=Math.min(e.left,t.left),a=Math.max(e.right,t.right)-i,o=r-n;return new DOMRect(i,n,a,o)}var vw=class{constructor({editor:e,element:t,view:n,pluginKey:r=`bubbleMenu`,updateDelay:i=250,resizeDelay:a=60,shouldShow:o,appendTo:s,getReferencedVirtualElement:c,options:l}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:`absolute`,placement:`top`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:e,state:t,from:n,to:r})=>{let{doc:i,selection:a}=t,{empty:o}=a,s=!i.textBetween(n,r).length&&Xn(t.selection),c=this.element.contains(document.activeElement);return!(!(e.hasFocus()||c)||o||s||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(e,t)=>{let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);!n&&!r||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(e,n,r,t)},this.updateDelay))},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.show(),this.updatePosition()}},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=l?.scrollTarget??window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...l},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener(`dragstart`,this.dragstartHandler),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(Es(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(Ms(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(bs(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(js(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(Ns(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(xs(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(ws(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(Cs(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}get virtualElement(){let{selection:e}=this.editor.state,t=this.getReferencedVirtualElement?.call(this);if(t)return t;if(!this.view?.dom?.parentNode)return;let n=Rn(this.view,e.from,e.to),r={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof Hn){let t=this.view.nodeDOM(e.from),n=t.dataset.nodeViewWrapper?t:t.querySelector(`[data-node-view-wrapper]`);n&&(t=n),t&&(r={getBoundingClientRect:()=>t.getBoundingClientRect(),getClientRects:()=>[t.getBoundingClientRect()]})}if(e instanceof Pr){let{$anchorCell:t,$headCell:n}=e,i=t?t.pos:n.pos,a=n?n.pos:t.pos,o=this.view.nodeDOM(i),s=this.view.nodeDOM(a);if(!o||!s)return;let c=o===s?o.getBoundingClientRect():_w(o.getBoundingClientRect(),s.getBoundingClientRect());r={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return r}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&Os(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(!(!this.isVisible||this.editor.isDestroyed||!this.element.isConnected)){if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(e,t){let{state:n}=e,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(e,t);return}let i=!t?.selection.eq(e.state.selection),a=!t?.doc.eq(e.state.doc);this.updateHandler(e,i,a,t)}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,element:this.element,view:this.view,state:t,oldState:e,from:i,to:a})||!1}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener(`dragstart`,this.dragstartHandler),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},yw=e=>new ir({key:typeof e.pluginKey==`string`?new ar(e.pluginKey):e.pluginKey,view:t=>new vw({view:t,...e})});gr.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[yw({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var bw=class{constructor({editor:e,element:t,view:n,pluginKey:r=`floatingMenu`,updateDelay:i=250,resizeDelay:a=60,options:o,appendTo:s,shouldShow:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:e,state:t})=>{let{selection:n}=t,{$anchor:r,empty:i}=n,a=r.depth===1,o=r.parent.isTextblock&&!r.parent.type.spec.code&&!r.parent.textContent&&r.parent.childCount===0&&!this.getTextContent(r.parent);return!(!e.hasFocus()||!i||!a||!o||!this.editor.isEditable)},this.floatingUIOptions={strategy:`absolute`,placement:`right`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.updatePosition(),this.show()}},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=o?.scrollTarget??window,this.floatingUIOptions={...this.floatingUIOptions,...o},this.element.tabIndex=0,c&&(this.shouldShow=c),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(e){return $n(e,{textSerializers:Ar(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(Es(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(Ms(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(bs(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(js(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(Ns(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(xs(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(ws(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(Cs(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,view:this.view,state:t,oldState:e,from:i,to:a})}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){let{selection:e}=this.editor.state,t=Rn(this.view,e.from,e.to);Os({getBoundingClientRect:()=>t,getClientRects:()=>[t]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);this.updateHandler(e,n,r,t)}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},xw=e=>new ir({key:typeof e.pluginKey==`string`?new ar(e.pluginKey):e.pluginKey,view:t=>new bw({view:t,...e})});gr.create({name:`floatingMenu`,addOptions(){return{element:null,options:{},pluginKey:`floatingMenu`,updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}},addCommands(){return{updateFloatingMenuPosition:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(this.options.pluginKey,`updatePosition`),!0)}},addProseMirrorPlugins(){return this.options.element?[xw({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});function Sw(e,t){return e??new ar(t)}var Cw=typeof window<`u`?Q.useLayoutEffect:Q.useEffect,ww=new Set([`left`,`opacity`,`position`,`top`,`visibility`,`width`]),Tw=new Set(`animationIterationCount.aspectRatio.borderImageOutset.borderImageSlice.borderImageWidth.columnCount.columns.fillOpacity.flex.flexGrow.flexShrink.fontWeight.gridArea.gridColumn.gridColumnEnd.gridColumnStart.gridRow.gridRowEnd.gridRowStart.lineClamp.lineHeight.opacity.order.orphans.scale.stopOpacity.strokeDasharray.strokeDashoffset.strokeMiterlimit.strokeOpacity.strokeWidth.tabSize.widows.zIndex.zoom`.split(`.`)),Ew=new Set([`children`,`className`,`style`]),Dw=new Set([`tabIndex`]),Ow=new Set([`accessKey`,`autoCapitalize`,`contentEditable`,`contextMenu`,`dir`,`draggable`,`enterKeyHint`,`hidden`,`id`,`lang`,`nonce`,`role`,`slot`,`spellCheck`,`tabIndex`,`title`,`translate`]),kw={Blur:`focusout`,DoubleClick:`dblclick`,Focus:`focusin`,MouseEnter:`mouseenter`,MouseLeave:`mouseleave`};function Aw(e,t){return/^on[A-Z]/.test(e)&&typeof t==`function`}function jw(e){return e.startsWith(`aria-`)||e.startsWith(`data-`),e}function Mw(e){return e.startsWith(`aria-`)||e.startsWith(`data-`)||Ow.has(e)}function Nw(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function Pw(e){let t=e.endsWith(`Capture`),n=(t?e.slice(0,-7):e).slice(2);return{eventName:kw[n]??n.toLowerCase(),options:t?{capture:!0}:void 0}}function Fw(e,t){let n=t.defaultPrevented,r=!1,i=Object.create(t);return Object.defineProperties(i,{nativeEvent:{value:t},currentTarget:{value:e},target:{value:t.target},persist:{value:()=>void 0},isDefaultPrevented:{value:()=>n},isPropagationStopped:{value:()=>r},preventDefault:{value:()=>{n=!0,t.preventDefault()}},stopPropagation:{value:()=>{r=!0,t.stopPropagation()}}}),i}function Iw(e){return Dw.has(e)}function Lw(e,t,n){if(t===`tabIndex`){e.tabIndex=Number(n);return}e[t]=n}function Rw(e,t){if(t===`tabIndex`){e.removeAttribute(`tabindex`);return}let n=e[t];if(typeof n==`boolean`){e[t]=!1;return}if(typeof n==`number`){e[t]=0;return}e[t]=``}function zw(e,t){return typeof t!=`number`||t===0||e.startsWith(`--`)||Tw.has(e)?String(t):`${t}px`}function Bw(e,t){ww.has(t)||e.style.removeProperty(Nw(t))}function Vw(e,t,n){ww.has(t)||e.style.setProperty(Nw(t),zw(t,n))}function Hw(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(r=>{if(Ew.has(r)||!Mw(r)||Aw(r,t[r])||Aw(r,n[r]))return;let i=t[r],a=n[r];if(i===a)return;let o=jw(r);if(a==null||a===!1){Iw(r)&&Rw(e,r),e.removeAttribute(o);return}if(a===!0){Iw(r)&&Lw(e,r,!0),e.setAttribute(o,``);return}if(Iw(r)){Lw(e,r,a);return}e.setAttribute(o,String(a))})}function Uw(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute(`class`)}}function Ww(e,t,n){let r=t??{},i=n??{};new Set([...Object.keys(r),...Object.keys(i)]).forEach(t=>{let n=r[t],a=i[t];if(n!==a){if(a==null){Bw(e,t);return}Vw(e,t,a)}})}function Gw(e,t,n){t.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)});let r=[];return Object.entries(n).forEach(([t,n])=>{if(!Aw(t,n))return;let{eventName:i,options:a}=Pw(t),o=t=>{n(Fw(e,t))};e.addEventListener(i,o,a),r.push({eventName:i,listener:o,options:a})}),r}function Kw(e,t){let n=(0,Q.useRef)({}),r=(0,Q.useRef)([]);Cw(()=>{let i=n.current;return Uw(e,i.className,t.className),Ww(e,i.style,t.style),Hw(e,i,t),r.current=Gw(e,r.current,t),n.current=t,()=>{r.current.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)}),r.current=[]}},[e,t])}var qw=Q.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,getReferencedVirtualElement:o,options:s,children:c,...l},u)=>{let d=(0,Q.useRef)(document.createElement(`div`)),f=(0,Q.useRef)(Sw(e,`bubbleMenu`)).current;Kw(d.current,l),typeof u==`function`?u(d.current):u&&(u.current=d.current);let{editor:p}=Kt(),m=t||p,h={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:f,shouldShow:a,getReferencedVirtualElement:o,options:s},g=(0,Q.useRef)(h);g.current=h;let[_,v]=(0,Q.useState)(!1),y=(0,Q.useRef)(!0);return(0,Q.useEffect)(()=>{if(m?.isDestroyed)return;if(!m){console.warn(`BubbleMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=d.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=yw({...g.current,editor:m,element:e});m.registerPlugin(t);let n=g.current.pluginKey;return y.current=!0,v(!0),()=>{v(!1),m.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[m]),(0,Q.useEffect)(()=>{if(!(!_||!m||m.isDestroyed)){if(y.current){y.current=!1;return}m.view.dispatch(m.state.tr.setMeta(f,{type:`updateOptions`,options:g.current}))}},[_,m,n,r,a,s,i,o,f]),(0,qc.createPortal)(c,d.current)});Q.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,options:o,children:s,...c},l)=>{let u=(0,Q.useRef)(document.createElement(`div`)),d=(0,Q.useRef)(Sw(e,`floatingMenu`)).current;Kw(u.current,c),typeof l==`function`?l(u.current):l&&(l.current=u.current);let{editor:f}=Kt(),p=t||f,m={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:d,shouldShow:a,options:o},h=(0,Q.useRef)(m);h.current=m;let[g,_]=(0,Q.useState)(!1),v=(0,Q.useRef)(!0);return(0,Q.useEffect)(()=>{if(p?.isDestroyed)return;if(!p){console.warn(`FloatingMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=u.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=xw({...h.current,editor:p,element:e});p.registerPlugin(t);let n=h.current.pluginKey;return v.current=!0,_(!0),()=>{_(!1),p.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[p]),(0,Q.useEffect)(()=>{if(!(!g||!p||p.isDestroyed)){if(v.current){v.current=!1;return}p.view.dispatch(p.state.tr.setMeta(d,{type:`updateOptions`,options:h.current}))}},[g,p,n,r,a,o,i,d]),(0,qc.createPortal)(s,u.current)});var Jw=[{name:`paragraph`,label:`Text`,icon:Nl,isActive:e=>e.isActive(`paragraph`)&&!e.isActive(`list`),command:e=>e.chain().focus().setParagraph().run()},{name:`heading1`,label:`Heading 1`,icon:F,isActive:e=>e.isActive(`heading`,{level:1}),command:e=>e.chain().focus().toggleHeading({level:1}).run()},{name:`heading2`,label:`Heading 2`,icon:St,isActive:e=>e.isActive(`heading`,{level:2}),command:e=>e.chain().focus().toggleHeading({level:2}).run()},{name:`heading3`,label:`Heading 3`,icon:R,isActive:e=>e.isActive(`heading`,{level:3}),command:e=>e.chain().focus().toggleHeading({level:3}).run()},{name:`bulletList`,label:`Bullet List`,icon:h,isActive:e=>e.isActive(`list`,{ordered:!1})&&!e.isActive(`listItem`,{checked:!0})&&!e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleBulletList().run()},{name:`orderedList`,label:`Ordered List`,icon:k,isActive:e=>e.isActive(`list`,{ordered:!0}),command:e=>e.chain().focus().toggleOrderedList().run()},{name:`taskList`,label:`Task List`,icon:_e,isActive:e=>e.isActive(`listItem`,{checked:!0})||e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleTaskList().run()},{name:`blockquote`,label:`Quote`,icon:T,isActive:e=>e.isActive(`blockquote`),command:e=>e.chain().focus().toggleBlockquote().run()},{name:`codeBlock`,label:`Code Block`,icon:Wl,isActive:e=>e.isActive(`codeBlock`),command:e=>e.chain().focus().toggleCodeBlock({language:`js`}).run()}];function Yw(e){let t=(0,$.c)(18),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:Xw},t[0]=n,t[1]=r);let{current:i,activeStates:a}=Le(r),o=i.icon,s;t[2]===o?s=t[3]:(s=(0,Z.jsx)(o,{className:`size-3.5`}),t[2]=o,t[3]=s);let c;t[4]===i.label?c=t[5]:(c=(0,Z.jsx)(`span`,{children:i.label}),t[4]=i.label,t[5]=c);let l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(It,{className:`size-3 opacity-50`}),t[6]=l):l=t[6];let u;t[7]!==s||t[8]!==c?(u=(0,Z.jsx)(ao,{asChild:!0,children:(0,Z.jsxs)(si,{variant:`ghost`,size:`sm`,className:`gap-1 px-2 text-sm font-medium text-accent-foreground/80`,children:[s,c,l]})}),t[7]=s,t[8]=c,t[9]=u):u=t[9];let d;t[10]!==a||t[11]!==n?(d=Jw.map(e=>{let t=e.icon,r=a[e.name];return(0,Z.jsxs)(Fa,{className:r?`bg-accent text-accent-foreground`:``,onSelect:()=>{e.command(n)},children:[(0,Z.jsx)(t,{className:`size-4`}),(0,Z.jsx)(`span`,{children:e.label})]},e.name)}),t[10]=a,t[11]=n,t[12]=d):d=t[12];let f;t[13]===d?f=t[14]:(f=(0,Z.jsx)($a,{align:`start`,sideOffset:8,className:`w-44 max-h-(--radix-dropdown-menu-content-available-height) overflow-y-auto subtle-scrollbar`,children:d}),t[13]=d,t[14]=f);let p;return t[15]!==u||t[16]!==f?(p=(0,Z.jsxs)(ro,{children:[u,f]}),t[15]=u,t[16]=f,t[17]=p):p=t[17],p}function Xw(e){let t=Object.fromEntries(Jw.map(t=>[t.name,t.isActive(e.editor)]));return{current:Jw.find(e=>t[e.name])??Jw[0],activeStates:t}}function Zw(e){let t=(0,$.c)(17),{installStates:n,onPick:r}=e,{_:a}=i(),[o,c]=(0,Q.useState)(``),l;if(t[0]!==a||t[1]!==n||t[2]!==o||t[3]!==r){let e;t[5]===n?e=t[6]:(e=e=>n[e.id]?.installed===!0,t[5]=n,t[6]=e);let i=Fh.filter(e),u=Fh.some(e=>n[e.id]?.installed==null),d;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(`div`,{className:`font-mono text-xs uppercase tracking-wide text-muted-foreground`,children:(0,Z.jsx)(s,{id:`EVnzPs`})}),t[7]=d):d=t[7];let f;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(f=e=>c(e.target.value),t[8]=f):f=t[8];let p;t[9]===a?p=t[10]:(p=a({id:`Rah7yq`}),t[9]=a,t[10]=p);let m;t[11]===a?m=t[12]:(m=a({id:`ZBt4rI`}),t[11]=a,t[12]=m);let h;t[13]!==o||t[14]!==p||t[15]!==m?(h=(0,Z.jsx)(ko,{value:o,onChange:f,placeholder:p,"aria-label":m,"data-testid":`edit-with-ai-instruction`}),t[13]=o,t[14]=p,t[15]=m,t[16]=h):h=t[16],l=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,h,i.length>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`text-muted-foreground text-xs`,"data-testid":`edit-with-ai-send-label`,children:(0,Z.jsx)(s,{id:`C37Zkt`})}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:i.map(e=>(0,Z.jsxs)(si,{type:`button`,variant:`ghost`,className:`w-full justify-start gap-2`,"data-testid":`edit-with-ai-target-${e.id}`,onClick:()=>r(e,o),children:[(0,Z.jsx)(ox,{id:e.id,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{children:e.displayName})]},e.id))})]}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,"data-testid":`edit-with-ai-empty`,"aria-live":`polite`,children:u?(0,Z.jsx)(s,{id:`EcR0fl`}):(0,Z.jsx)(s,{id:`l6OXqI`})})]}),t[0]=a,t[1]=n,t[2]=o,t[3]=r,t[4]=l}else l=t[4];return l}function Qw(e){let t=(0,$.c)(27),{open:n,onOpenChange:r,snapshot:a,children:o}=e,{_:s}=i(),{states:c,refresh:l}=Kg(),{dispatch:u}=Fg(),d;t[0]===l?d=t[1]:(d=()=>{l()},t[0]=l,t[1]=d);let f=(0,Q.useEffectEvent)(d),p;t[2]!==n||t[3]!==f?(p=()=>{n&&f()},t[2]=n,t[3]=f,t[4]=p):p=t[4];let m;t[5]===n?m=t[6]:(m=[n],t[5]=n,t[6]=m),(0,Q.useEffect)(p,m);let h;t[7]!==s||t[8]!==u||t[9]!==r||t[10]!==a?(h=(e,t)=>{if(a!==null){let n=wg({docName:a.docName,workspace:a.workspace,instruction:t,selectionMarkdown:a.selectionMarkdown});n===null?X.error(s({id:`_VRtd7`})):u(e.id,n)}r(!1)},t[7]=s,t[8]=u,t[9]=r,t[10]=a,t[11]=h):h=t[11];let g=h,_;t[12]===o?_=t[13]:(_=(0,Z.jsx)(J,{asChild:!0,children:o}),t[12]=o,t[13]=_);let v;t[14]===s?v=t[15]:(v=s({id:`EVnzPs`}),t[14]=s,t[15]=v);let y;t[16]!==g||t[17]!==c?(y=(0,Z.jsx)(Zw,{installStates:c,onPick:g}),t[16]=g,t[17]=c,t[18]=y):y=t[18];let x;t[19]!==v||t[20]!==y?(x=(0,Z.jsx)(b,{align:`start`,"aria-label":v,"data-testid":`edit-with-ai-popover`,children:y}),t[19]=v,t[20]=y,t[21]=x):x=t[21];let S;return t[22]!==r||t[23]!==n||t[24]!==_||t[25]!==x?(S=(0,Z.jsxs)(pe,{open:n,onOpenChange:r,children:[_,x]}),t[22]=r,t[23]=n,t[24]=_,t[25]=x,t[26]=S):S=t[26],S}function $w(e){let t=P(e.state.selection.content(),e.state.schema);return l().serialize(t).trim()}function eT(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toUpperCase();return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`}function tT(e){let t=(0,$.c)(3),{editor:n,shortcutEnabled:r}=e,i=r===void 0?!1:r,a=qn(),o=Mh();if(!a||o)return null;let s;return t[0]!==n||t[1]!==i?(s=(0,Z.jsx)(nT,{editor:n,shortcutEnabled:i}),t[0]=n,t[1]=i,t[2]=s):s=t[2],s}function nT(e){let t=(0,$.c)(19),{editor:n,shortcutEnabled:r}=e,{_:a}=i(),o=po(),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null),f;if(t[0]!==a||t[1]!==n||t[2]!==o){let e=()=>{let e;try{e=$w(n)}catch(e){return console.error(`Edit with AI: could not read the selection`,e),X.error(a({id:`-RXIMO`})),null}return{docName:_t(n),workspace:o,selectionMarkdown:e}};f=()=>{let t=e();t!==null&&(d(t),l(!0))},t[0]=a,t[1]=n,t[2]=o,t[3]=f}else f=t[3];let p=f,m;t[4]===p?m=t[5]:(m=e=>{if(e){p();return}l(!1),d(null)},t[4]=p,t[5]=m);let h=m,g;t[6]===p?g=t[7]:(g=()=>{p()},t[6]=p,t[7]=g);let _=(0,Q.useEffectEvent)(g),v;t[8]!==_||t[9]!==r?(v=()=>{let e=e=>{r&&qs(e,`edit-with-ai`)&&(eT(e.target)||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),_()))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},t[8]=_,t[9]=r,t[10]=v):v=t[10];let y;t[11]===r?y=t[12]:(y=[r],t[11]=r,t[12]=y),(0,Q.useEffect)(v,y);let b;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(Pi,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[13]=b):b=t[13];let x;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsxs)(si,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`edit-with-ai-bubble-button`,className:`gap-1 px-2 text-sm font-medium text-accent-foreground/80`,children:[(0,Z.jsx)(vi,{className:`size-3.5`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{children:(0,Z.jsx)(s,{id:`EVnzPs`})})]}),t[14]=x):x=t[14];let S;return t[15]!==h||t[16]!==c||t[17]!==u?(S=(0,Z.jsxs)(Z.Fragment,{children:[b,(0,Z.jsx)(Qw,{open:c,onOpenChange:h,snapshot:u,children:x})]}),t[15]=h,t[16]=c,t[17]=u,t[18]=S):S=t[18],S}function rT(e){let t=e.state.selection.node;if(!t||t.type.name!==`jsxComponent`)return null;let n=t.attrs.componentName;if(n!==`File`&&n!==`WikiEmbedFile`)return null;let r=(t.attrs.props??{}).src;return typeof r!=`string`||r.length===0?null:r}function iT(e){let t=e.state.selection.node;if(!t)return``;let n=t.attrs.props??{},r=typeof n.alias==`string`?n.alias:``;if(r.length>0)return r;let i=typeof n.name==`string`?n.name:``;return i.length>0?i:Pt(typeof n.src==`string`?n.src:``)}function aT(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,n.rel=`noopener noreferrer`,n.style.display=`none`,document.body.appendChild(n),n.click(),n.remove()}function oT(e){let t=(0,$.c)(13),{editor:n}=e,{_:r}=i(),a;if(t[0]===n?a=t[1]:(a={editor:n,selector:sT},t[0]=n,t[1]=a),Le(a)===null)return null;let o;t[2]===r?o=t[3]:(o=r({id:`WcWS__`}),t[2]=r,t[3]=o);let c;t[4]===n?c=t[5]:(c=e=>{e.preventDefault();let t=rT(n);t&&aT(t,iT(n))},t[4]=n,t[5]=c);let l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(wa,{className:`size-3.5`}),t[6]=l):l=t[6];let u;t[7]!==o||t[8]!==c?(u=(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(si,{variant:`ghost`,size:`icon-xs`,"aria-label":o,className:`text-accent-foreground`,onMouseDown:c,children:l})}),t[7]=o,t[8]=c,t[9]=u):u=t[9];let d;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(Ds,{side:`bottom`,sideOffset:8,children:(0,Z.jsx)(s,{id:`WcWS__`})}),t[10]=d):d=t[10];let f;return t[11]===u?f=t[12]:(f=(0,Z.jsx)(`div`,{className:`flex items-center gap-0.5`,children:(0,Z.jsxs)(As,{children:[u,d]})}),t[11]=u,t[12]=f),f}function sT(e){return rT(e.editor)}function cT(e){return rT(e)!==null}function lT(e){let t=e.schema.nodes;return!!(t.footnoteReference&&t.footnoteDefinition)}function uT(e){let{from:t,to:n}=e.state.selection,r=!1;return e.state.doc.nodesBetween(t,n,e=>e.type.name===`footnoteReference`?(r=!0,!1):!0),r}function dT(e){let{$from:t,$to:n}=e.state.selection;return!t.sameParent(n)}function fT(e){let t=(0,$.c)(21),{editor:n}=e,{_:r}=i(),a;t[0]===n?a=t[1]:(a={editor:n,selector:pT},t[0]=n,t[1]=a);let o=Le(a),s;t[2]!==o||t[3]!==n?(s=()=>{if(o||!lT(n)||n.state.selection.empty||dT(n)||uT(n))return;let{from:e,to:t}=n.state.selection,r=n.state.doc.textBetween(e,t,` `);if(!r.trim())return;let i=Bn(Vn(n.state.doc)),a=jr(n.state.doc)+1-(t-e);n.chain().focus().deleteSelection().insertFootnoteReference(i).insertContentAt(a,{type:`footnoteDefinition`,attrs:{identifier:i,label:i},content:[{type:`paragraph`,content:[{type:`text`,text:r}]}]}).run()},t[2]=o,t[3]=n,t[4]=s):s=t[4];let c=s,l;t[5]===r?l=t[6]:(l=r({id:`sIGbBZ`}),t[5]=r,t[6]=l);let u;t[7]===c?u=t[8]:(u=e=>{e.preventDefault(),c()},t[7]=c,t[8]=u);let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(K,{className:`size-3.5`,"aria-hidden":`true`}),t[9]=d):d=t[9];let f;t[10]!==o||t[11]!==l||t[12]!==u?(f=(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(si,{type:`button`,variant:`ghost`,size:`icon-xs`,"data-testid":`footnote-bubble-button`,className:`text-accent-foreground/80`,"aria-label":l,onMouseDown:u,disabled:o,children:d})}),t[10]=o,t[11]=l,t[12]=u,t[13]=f):f=t[13];let p;t[14]===r?p=t[15]:(p=r({id:`sIGbBZ`}),t[14]=r,t[15]=p);let m;t[16]===p?m=t[17]:(m=(0,Z.jsx)(Ds,{side:`bottom`,sideOffset:8,children:p}),t[16]=p,t[17]=m);let h;return t[18]!==f||t[19]!==m?(h=(0,Z.jsxs)(As,{children:[f,m]}),t[18]=f,t[19]=m,t[20]=h):h=t[20],h}function pT(e){let t=e.editor;return!!(!lT(t)||t.state.selection.empty||dT(t)||uT(t))}var mT=`img, .ok-embed, .ok-video`,hT=220,gT=`cubic-bezier(0.23, 1, 0.32, 1)`,_T=`ok-image-align-flip`,vT=.5;function yT(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function bT(){return typeof requestAnimationFrame==`function`}function xT(e){return e?e.querySelector(mT):null}function ST(e,t){if(yT()||!bT()){t();return}let n=xT(e);if(!n){t();return}let r=n.getBoundingClientRect().left;t(),requestAnimationFrame(()=>{let t=xT(e);if(!t)return;for(let e of t.getAnimations())e.id===_T&&e.cancel();let n=r-t.getBoundingClientRect().left;if(Math.abs(n)<vT)return;let i=t.animate([{transform:`translateX(${n}px)`},{transform:`translateX(0)`}],{duration:hT,easing:gT,fill:`none`});i.id=_T})}var CT=[{value:`left`,label:`Align left`,icon:eu},{value:`center`,label:`Align center`,icon:Ql},{value:`right`,label:`Align right`,icon:$l}];function wT(e){let t=e.state.selection.node;if(!t||t.type.name!==`jsxComponent`)return null;let n=t.attrs.componentName;if(!Rt.has(String(n)))return null;let r=(t.attrs.props??{}).align;return r===`left`||r===`right`||r===`center`?r:`center`}function TT(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:ET},t[0]=n,t[1]=r);let i=Le(r);if(i===null)return null;let a;t[2]!==i||t[3]!==n?(a=CT.map(e=>{let{value:t,label:r,icon:a}=e,o=i===t;return(0,Z.jsxs)(As,{children:[(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(si,{variant:`ghost`,size:`icon-xs`,"aria-label":r,"aria-pressed":o,className:o?`bg-accent text-primary`:`text-accent-foreground`,onMouseDown:e=>{e.preventDefault();let r=n.state.selection,i=r.node;if(!i||i.type.name!==`jsxComponent`)return;let a=String(i.attrs.componentName??``);if(!Rt.has(a)||i.attrs.kind!==`element`)return;let o=a===`CommonMarkImage`,s=r.from,c={...i.attrs.props??{},align:t},l=o?{...i.attrs,componentName:`img`,props:c,sourceDirty:!0}:{...i.attrs,props:c,sourceDirty:!0},u=n.state.tr.setNodeMarkup(s,null,l);u.setSelection(Hn.create(u.doc,s)),ST(n.view.nodeDOM(s),()=>{n.view.dispatch(u)})},children:(0,Z.jsx)(a,{className:`size-3.5`})})}),(0,Z.jsx)(Ds,{side:`bottom`,sideOffset:8,children:r})]},t)}),t[2]=i,t[3]=n,t[4]=a):a=t[4];let o;return t[5]===a?o=t[6]:(o=(0,Z.jsx)(`div`,{className:`flex items-center gap-0.5`,children:a}),t[5]=a,t[6]=o),o}function ET(e){return wT(e.editor)}function DT(e){return wT(e)!==null}var OT=[{name:`bold`,icon:Kc,command:e=>e.chain().focus().toggleBold().run(),isActive:e=>e.isActive(`strong`),shortcutId:`format-bold`},{name:`italic`,icon:vl,command:e=>e.chain().focus().toggleItalic().run(),isActive:e=>e.isActive(`emphasis`),shortcutId:`format-italic`},{name:`underline`,icon:nu,command:e=>e.chain().focus().toggleUnderline().run(),isActive:e=>e.isActive(`underline`),shortcutId:`format-underline`},{name:`strikethrough`,icon:Yl,command:e=>e.chain().focus().toggleStrike().run(),isActive:e=>e.isActive(`strike`),shortcutId:`format-strike`},{name:`code`,icon:Fe,command:e=>e.chain().focus().toggleCode().run(),isActive:e=>e.isActive(`code`),shortcutId:`format-inline-code`},{name:`highlight`,icon:gl,command:e=>e.chain().focus().toggleHighlight().run(),isActive:e=>e.isActive(`highlight`),shortcutId:`format-highlight`}];function kT(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:AT},t[0]=n,t[1]=r);let i=Le(r),a;t[2]!==i||t[3]!==n?(a=OT.map(e=>{let t=e.icon,r=i[e.name];return(0,Z.jsxs)(As,{children:[(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(si,{variant:`ghost`,size:`icon-xs`,"aria-label":e.name,className:r?`bg-accent text-primary`:`text-accent-foreground`,onMouseDown:t=>{t.preventDefault(),e.command(n)},children:(0,Z.jsx)(t,{className:`size-3.5`})})}),(0,Z.jsxs)(Ds,{side:`bottom`,sideOffset:8,children:[(0,Z.jsx)(`span`,{className:`capitalize`,children:e.name}),(0,Z.jsx)(Jt,{"aria-label":Js(e.shortcutId),children:Ks(e.shortcutId)})]})]},e.name)}),t[2]=i,t[3]=n,t[4]=a):a=t[4];let o;return t[5]===a?o=t[6]:(o=(0,Z.jsx)(`div`,{className:`flex items-center gap-0.5`,children:a}),t[5]=a,t[6]=o),o}function AT(e){return Object.fromEntries(OT.map(t=>[t.name,t.isActive(e.editor)]))}function jT(e){let t=(0,$.c)(66),{editor:n}=e,{_:r}=i(),[a,o]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(``),u=(0,Q.useRef)(null),{folderPaths:d,loading:p,pages:m}=es(),h;t[0]===n?h=t[1]:(h=n.state.selection.empty&&n.isActive(`link`),t[0]=n,t[1]=h);let g=h,v;t[2]===n?v=t[3]:(v=n.getAttributes(`link`).href??``,t[2]=n,t[3]=v);let y=v,b;t[4]===n?b=t[5]:(b=function(){return n.state.selection.empty&&n.isActive(`link`)?n.getAttributes(`link`).href??``:``},t[4]=n,t[5]=b);let x=b,S,C;t[6]===n?(S=t[7],C=t[8]):(S=()=>{let e=function(){n.state.selection.empty&&o(!1)};return n.on(`selectionUpdate`,e),()=>{n.off(`selectionUpdate`,e)}},C=[n],t[6]=n,t[7]=S,t[8]=C),(0,Q.useEffect)(S,C);let w,T;t[9]===a?(w=t[10],T=t[11]):(w=()=>{a&&requestAnimationFrame(()=>u.current?.focus())},T=[a],t[9]=a,t[10]=w,t[11]=T),(0,Q.useEffect)(w,T);let E;t[12]!==n||t[13]!==g||t[14]!==c?(E=function(){c.trim()?n.chain().focus().setLink({href:c.trim()}).run():g&&n.chain().focus().unsetLink().run(),o(!1)},t[12]=n,t[13]=g,t[14]=c,t[15]=E):E=t[15];let D=E,O;t[16]===n?O=t[17]:(O=function(){n.chain().focus().unsetLink().run(),o(!1)},t[16]=n,t[17]=O);let k=O,A;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(A=function(e){l(it(e.path,null))},t[18]=A):A=t[18];let j=A,M;t[19]!==D||t[20]!==n?(M=function(e){e.key===`Enter`&&(e.preventDefault(),D()),e.key===`Escape`&&(e.preventDefault(),o(!1),n.chain().focus().run())},t[19]=D,t[20]=n,t[21]=M):M=t[21];let N=M;if(a){let e;t[22]===r?e=t[23]:(e=r({id:`ZsGpr_`}),t[22]=r,t[23]=e);let n;t[24]===r?n=t[25]:(n=r({id:`roAe2K`}),t[24]=r,t[25]=n);let i;t[26]!==d||t[27]!==N||t[28]!==p||t[29]!==m||t[30]!==e||t[31]!==n||t[32]!==c?(i=(0,Z.jsx)(_,{ref:u,type:`text`,placeholder:e,value:c,pages:m,folderPaths:d,loading:p,onValueChange:l,onSuggestionSelect:j,onKeyDown:N,"aria-label":n,className:`h-5 w-44 rounded-none border-none bg-transparent px-0 py-0 text-sm placeholder:text-muted-foreground focus-visible:border-transparent focus-visible:ring-0 dark:bg-transparent`}),t[26]=d,t[27]=N,t[28]=p,t[29]=m,t[30]=e,t[31]=n,t[32]=c,t[33]=i):i=t[33];let a;t[34]===r?a=t[35]:(a=r({id:`tP5DDk`}),t[34]=r,t[35]=a);let o;t[36]===D?o=t[37]:(o=()=>{D()},t[36]=D,t[37]=o);let h;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(rl,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[38]=h):h=t[38];let v;t[39]!==a||t[40]!==o?(v=(0,Z.jsx)(si,{variant:`ghost`,size:`icon-xs`,"aria-label":a,onClick:o,children:h}),t[39]=a,t[40]=o,t[41]=v):v=t[41];let b;t[42]!==i||t[43]!==v?(b=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border bg-background px-2 py-1 focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50`,children:[i,v]}),t[42]=i,t[43]=v,t[44]=b):b=t[44];let x;t[45]!==r||t[46]!==y||t[47]!==g||t[48]!==k?(x=g&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(As,{children:[(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(si,{variant:`ghost`,size:`icon-xs`,"aria-label":r({id:`2vIPtm`}),onMouseDown:e=>{e.preventDefault(),f(y)},children:(0,Z.jsx)(go,{className:`size-3.5`})})}),(0,Z.jsx)(Ds,{side:`bottom`,sideOffset:8,children:(0,Z.jsx)(s,{id:`2vIPtm`})})]}),(0,Z.jsxs)(As,{children:[(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(si,{variant:`ghost`,size:`icon-xs`,"aria-label":r({id:`484LKL`}),onMouseDown:e=>{e.preventDefault(),k()},children:(0,Z.jsx)(fs,{className:`size-3.5`})})}),(0,Z.jsx)(Ds,{side:`bottom`,sideOffset:8,children:(0,Z.jsx)(s,{id:`484LKL`})})]})]}),t[45]=r,t[46]=y,t[47]=g,t[48]=k,t[49]=x):x=t[49];let S;return t[50]!==b||t[51]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[b,x]}),t[50]=b,t[51]=x,t[52]=S):S=t[52],S}let P;t[53]===r?P=t[54]:(P=r({id:`p0Iq25`}),t[53]=r,t[54]=P);let F=g?`bg-accent text-primary`:`text-accent-foreground`,I;t[55]===x?I=t[56]:(I=e=>{e.preventDefault(),l(x()),o(!0)},t[55]=x,t[56]=I);let L;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsx)(bl,{className:`size-3.5`}),t[57]=L):L=t[57];let R;t[58]!==P||t[59]!==F||t[60]!==I?(R=(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(si,{variant:`ghost`,size:`icon-xs`,"aria-label":P,className:F,onMouseDown:I,children:L})}),t[58]=P,t[59]=F,t[60]=I,t[61]=R):R=t[61];let z;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(s,{id:`yzF66j`}),t[62]=z):z=t[62];let B;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Z.jsxs)(Ds,{side:`bottom`,sideOffset:8,children:[z,(0,Z.jsx)(Jt,{children:Ks(`command-palette`)})]}),t[63]=B):B=t[63];let V;return t[64]===R?V=t[65]:(V=(0,Z.jsxs)(As,{children:[R,B]}),t[64]=R,t[65]=V),V}function MT({editor:e}){if(ze(e.state).query||e.isActive(`codeBlock`))return!1;if(DT(e)||cT(e))return!0;if(e.state.selection.empty)return!1;let{from:t,to:n}=e.state.selection;return!!e.state.doc.textBetween(t,n,` `).trim()}function NT(e){let t=(0,$.c)(23),{editor:n,shortcutEnabled:r}=e,i=r===void 0?!0:r,a=(0,Q.useRef)(null),[o,s]=(0,Q.useState)(0),c=(0,Q.useRef)(null),l;t[0]===n?l=t[1]:(l={editor:n,selector:RT},t[0]=n,t[1]=l);let u=Le(l),d;t[2]===n?d=t[3]:(d={editor:n,selector:LT},t[2]=n,t[3]=d);let f=Le(d),p;t[4]!==n.state||t[5]!==n.view?(p=()=>{try{let{from:e,to:t}=n.state.selection;return Rn(n.view,e,t)}catch{return new DOMRect}},t[4]=n.state,t[5]=n.view,t[6]=p):p=t[6];let m;if(t[7]!==n.view.dom||t[8]!==p){let e={getBoundingClientRect:p,contextElement:n.view.dom};m=()=>{let t=a.current;t&&(c.current?.(),c.current=Ss(e,t,()=>{Os(e,t,{placement:`top`,strategy:`fixed`,middleware:[bs(8),Es(),Ms({padding:8})]}).then(e=>{let{x:n,y:r}=e;t.isConnected&&(t.style.position=`fixed`,t.style.left=`${n}px`,t.style.top=`${r}px`)}).catch(IT)}))},t[7]=n.view.dom,t[8]=p,t[9]=m}else m=t[9];let h=m,g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{c.current?.(),c.current=null,s(FT)},t[10]=g):g=t[10];let _=g,v;t[11]===h?v=t[12]:(v={onShow:h,onHide:_,strategy:`fixed`},t[11]=h,t[12]=v);let y;t[13]!==n||t[14]!==f||t[15]!==u||t[16]!==i||t[17]!==o?(y=u?(0,Z.jsx)(TT,{editor:n},`${o}-img-align`):f?(0,Z.jsx)(oT,{editor:n},`${o}-file`):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Yw,{editor:n}),(0,Z.jsx)(Pi,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),(0,Z.jsx)(kT,{editor:n},o),(0,Z.jsx)(Pi,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),(0,Z.jsx)(jT,{editor:n},`${o}-link`),(0,Z.jsx)(fT,{editor:n},`${o}-footnote`),(0,Z.jsx)(tT,{editor:n,shortcutEnabled:i},`${o}-edit-ai`)]}),t[13]=n,t[14]=f,t[15]=u,t[16]=i,t[17]=o,t[18]=y):y=t[18];let b;return t[19]!==n||t[20]!==v||t[21]!==y?(b=(0,Z.jsx)(qw,{ref:a,editor:n,"data-testid":`bubble-menu-bar`,appendTo:PT,shouldShow:MT,updateDelay:250,options:v,className:`z-50 flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:y}),t[19]=n,t[20]=v,t[21]=y,t[22]=b):b=t[22],b}function PT(){return document.body}function FT(e){return e+1}function IT(){}function LT(e){return cT(e.editor)}function RT(e){return DT(e.editor)}var zT=56,BT=`0 2px 4px rgba(0, 0, 0, 0.08)`,VT=150,HT=globalThis.ScrollTimeline;function UT(e,t,n,r,i){let a=r-i;if(a<=0)return null;let o=e+n-(t+zT);return{startOffset:o,endOffset:o+a,maxShift:a}}var WT=new WeakMap;function GT(e){let t=WT.get(e);if(t){for(let e of t.animations)e.cancel();WT.delete(e)}}function KT(e){for(let t of Array.from(e.cells))GT(t)}var qT=e=>e.cellIndex===0?`3`:`2`;function JT(e,t){return YT(e,t,e=>({transform:`translateY(${e}px)`}))}function YT(e,t,n){if(!(t>0))return[{offset:0,...n(0)},{offset:1,...n(0)}];let r=t=>Math.max(0,Math.min(t-e.startOffset,e.maxShift));return Array.from(new Set([0,e.startOffset/t,e.endOffset/t,1].map(e=>Math.max(0,Math.min(e,1))))).sort((e,t)=>e-t).map(e=>({offset:e,...n(r(e*t))}))}function XT(e,t,n,r){if(!(t>0))return[{...n,offset:0},{...n,offset:1}];let i=e.startOffset/t;if(i<=0)return[{...r,offset:0},{...r,offset:1}];if(i>=1)return[{...n,offset:0},{...n,offset:1}];let a=Math.min(i+1/t,1);return[{...n,offset:0},{...n,offset:i},{...r,offset:a},{...r,offset:1}]}function ZT(e,t,n){return XT(e,t,{zIndex:`auto`,boxShadow:`none`},{zIndex:n,boxShadow:BT})}function QT(e,t){return XT(e,t,{opacity:`0`},{opacity:`1`})}function $T(e,t,n,r){let i=qT(e),a=`sd|${n.startOffset}|${n.maxShift}|${r}|${i}`,o=WT.get(e);if(o?.key===a)return;if(o)for(let e of o.animations)e.cancel();let s={timeline:t,fill:`both`,easing:`linear`},c=e.animate(JT(n,r),s),l=e.animate(ZT(n,r,i),s),u=e.animate(QT(n,r),{...s,pseudoElement:`::before`});WT.set(e,{key:a,animations:[c,l,u]})}function eE(e,t){let n=qT(e),r=`in|${t}|${n}`,i=WT.get(e);if(i?.key===r)return;if(i)for(let e of i.animations)e.cancel();let a=e.animate([{transform:`translateY(${t}px)`,zIndex:n,boxShadow:BT}],{duration:0,fill:`forwards`}),o=e.animate([{opacity:`1`}],{duration:0,fill:`forwards`,pseudoElement:`::before`});WT.set(e,{key:r,animations:[a,o]})}function tE(e,t,n,r){let i=e.getBoundingClientRect().top,a=e.scrollTop,o=e.scrollHeight-e.clientHeight,s=t.querySelectorAll(`.tableWrapper`);for(let e of s){r?.(e);let t=e.querySelector(`table`);if(!t)continue;let s=t.querySelector(`tbody`)?.rows[0];if(!s||!Array.from(s.cells).some(e=>e.tagName===`TH`))continue;let c=t.getBoundingClientRect(),l=s.getBoundingClientRect(),u=UT(a,i,c.top,c.height,l.height);if(!u){KT(s);continue}if(n){if(o<=0){KT(s);continue}for(let e of Array.from(s.cells))$T(e,n,u,o);continue}let d=Math.max(0,Math.min(a-u.startOffset,u.maxShift));if(d<=0||c.bottom<=i+zT){KT(s);continue}for(let e of Array.from(s.cells))eE(e,d)}}var nE=gr.create({name:`frozenTableHeaders`,addProseMirrorPlugins(){return[new ir({key:new ar(`frozenTableHeaders`),view(e){let t=null,n=null,r=null,i=null,a=null,o=!1,s=new Set,c=()=>{o||!t||tE(t,e.dom,n,u)},l=()=>{r??=requestAnimationFrame(()=>{r=null,c()})};function u(e){s.has(e)||(s.add(e),e.addEventListener(`contentvisibilityautostatechange`,l))}let d=()=>{if(n){i??l(),i!=null&&clearTimeout(i),i=setTimeout(()=>{i=null,c()},VT);return}l()};return requestAnimationFrame(()=>{if(!o){if(t=e.dom.closest(`[data-testid="editor-scroll-container"]`),t&&HT)try{n=new HT({source:t,axis:`block`})}catch{n=null}t?.addEventListener(`scroll`,d,{passive:!0}),t&&typeof ResizeObserver<`u`&&(a=new ResizeObserver(l),a.observe(t),a.observe(e.dom)),c()}}),{update(e,t){t.doc.eq(e.state.doc)||c()},destroy(){o=!0,t?.removeEventListener(`scroll`,d),a?.disconnect(),r!=null&&cancelAnimationFrame(r),i!=null&&clearTimeout(i);for(let e of s)e.removeEventListener(`contentvisibilityautostatechange`,l);s.clear();for(let t of e.dom.querySelectorAll(`.tableWrapper > table > tbody > tr:first-child`))KT(t)}}}})]}}),rE=`application/x-open-knowledge-sidebar-item+json`,iE={image:!0,video:!0,audio:!0,pdf:!0,text:!0};function aE(e){return JSON.stringify(e)}function oE(e){return e.kind===`folder`?{target:{kind:`folder`,target:e.folderPath,folderPath:e.folderPath},hash:zo(e.folderPath)}:e.kind===`asset`?{target:{kind:`asset`,target:e.assetPath,assetPath:e.assetPath,mediaKind:e.mediaKind},hash:Uo(e.assetPath)}:{target:ss(e.docName,e.size)??{kind:`doc`,target:e.docName,docName:e.docName},hash:Go(e.docName)}}function sE(e){if(!e||!Array.from(e.types).includes(`application/x-open-knowledge-sidebar-item+json`))return null;let t=e.getData(rE);if(!t)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!cE(n)||n.v!==1||typeof n.kind!=`string`)return null;if(n.kind===`doc`){if(typeof n.docName!=`string`||n.docName.length===0)return null;let e=n.size;return e!==null&&typeof e!=`number`?null:{v:1,kind:`doc`,docName:n.docName,size:e}}if(n.kind===`folder`)return typeof n.folderPath==`string`?{v:1,kind:`folder`,folderPath:n.folderPath}:null;if(n.kind===`asset`){if(typeof n.assetPath!=`string`||n.assetPath.length===0)return null;let e=n.mediaKind;return e!==null&&!lE(e)?null:{v:1,kind:`asset`,assetPath:n.assetPath,mediaKind:e}}return null}function cE(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function lE(e){return typeof e==`string`&&Object.hasOwn(iE,e)}function uE(e,t){return(n,r)=>{let i=r,a=sE(i.dataTransfer);return a?(i.preventDefault(),t?.(a),!0):e(n,i)}}function dE(e,t){let n=oE(e);t(n.target,{tabBehavior:`append`}),Vo(n.hash)}function fE(e){return[...e?[{label:`Toggle header column`,icon:tl,run:e=>e.chain().focus().toggleHeaderColumn().run()}]:[],{label:`Insert column left`,icon:hi,run:e=>e.chain().focus().addColumnBefore().run()},{label:`Insert column right`,icon:Ga,run:e=>e.chain().focus().addColumnAfter().run()},{label:`Delete column`,icon:fs,separatorBefore:!0,run:e=>e.chain().focus().deleteColumn().run()},{label:`Delete table`,icon:ml,run:e=>e.chain().focus().deleteTable().run()}]}function pE(e){return[...e?[{label:`Toggle header row`,icon:Xl,run:e=>e.chain().focus().toggleHeaderRow().run()}]:[],{label:`Insert row above`,icon:yt,run:e=>e.chain().focus().addRowBefore().run()},{label:`Insert row below`,icon:dt,run:e=>e.chain().focus().addRowAfter().run()},{label:`Delete row`,icon:fs,separatorBefore:!0,run:e=>e.chain().focus().deleteRow().run()},{label:`Delete table`,icon:ml,run:e=>e.chain().focus().deleteTable().run()}]}function mE(e){if(!e.isEditable||ze(e.state).query)return null;let{state:t,view:n}=e,r=t.selection.$from,i=-1;for(let e=r.depth;e>0;e--){let t=r.node(e).type.spec.tableRole;if(t===`cell`||t===`header_cell`){i=r.before(e);break}}if(i<0)return null;let a=n.nodeDOM(i);if(!(a instanceof HTMLTableCellElement))return null;let o=a.closest(`table`),s=a.closest(`tr`),c=a.closest(`.ProseMirror`);if(!o||!s||!c)return null;let l=Array.prototype.indexOf.call(o.rows,s),u=a.cellIndex,d=o.rows[0]?.cells[u],f=o.rows[l]?.cells[0];return!d||!f?null:{columnAnchor:d,rowAnchor:f,isFirstColumn:u===0,isFirstRow:l===0}}function hE(e){let t=(0,$.c)(22),{editor:n,anchor:r,axis:i,items:a}=e,o=(0,Q.useRef)(null),s,c;t[0]!==r||t[1]!==i?(s=()=>{let e=o.current;if(!e)return;let t=i===`column`?`top`:`left`,n=i===`column`?-14:-6;return Ss(r,e,()=>{Os(r,e,{strategy:`absolute`,placement:t,middleware:[bs(n)]}).then(t=>{let{x:n,y:r}=t;e.style.left=`${n}px`,e.style.top=`${r}px`,e.style.opacity=`1`}).catch(gE)})},c=[r,i],t[0]=r,t[1]=i,t[2]=s,t[3]=c):(s=t[2],c=t[3]),(0,Q.useEffect)(s,c);let l=i===`column`?al:Pa,u=i===`column`?`h-3 w-7 rounded-full p-0 text-gray-700 dark:text-muted-foreground bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 hover:text-foreground dark:hover:bg-gray-600 dark:hover:text-gray-100 relative before:absolute before:-inset-[6px] before:content-[""]`:`h-7 w-3 rounded-full p-0 text-gray-700 dark:text-muted-foreground bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 hover:text-foreground dark:hover:bg-gray-600 dark:hover:text-gray-100 relative before:absolute before:-inset-[6px] before:content-[""]`,d=i===`column`?`Column options`:`Row options`,f;t[4]===l?f=t[5]:(f=(0,Z.jsx)(l,{className:`size-3.5`,"aria-hidden":!0}),t[4]=l,t[5]=f);let p;t[6]!==u||t[7]!==d||t[8]!==f?(p=(0,Z.jsx)(ao,{asChild:!0,children:(0,Z.jsx)(si,{variant:`secondary`,className:u,"aria-label":d,children:f})}),t[6]=u,t[7]=d,t[8]=f,t[9]=p):p=t[9];let m=i===`column`?`center`:`start`,h=i===`column`?`bottom`:`right`,g;if(t[10]!==n||t[11]!==a){let e;t[13]===n?e=t[14]:(e=e=>(0,Z.jsxs)(Q.Fragment,{children:[e.separatorBefore&&(0,Z.jsx)(Ka,{}),(0,Z.jsxs)(Fa,{onSelect:()=>e.run(n),children:[(0,Z.jsx)(e.icon,{"aria-hidden":!0}),e.label]})]},e.label),t[13]=n,t[14]=e),g=a.map(e),t[10]=n,t[11]=a,t[12]=g}else g=t[12];let _;t[15]!==m||t[16]!==h||t[17]!==g?(_=(0,Z.jsx)($a,{align:m,side:h,className:`w-auto min-w-44 whitespace-nowrap`,children:g}),t[15]=m,t[16]=h,t[17]=g,t[18]=_):_=t[18];let v;return t[19]!==_||t[20]!==p?(v=(0,Z.jsx)(`div`,{ref:o,"data-testid":`table-cell-handle`,className:`absolute left-0 top-0 z-10 opacity-0`,children:(0,Z.jsxs)(ro,{children:[p,_]})}),t[19]=_,t[20]=p,t[21]=v):v=t[21],v}function gE(){}function _E(e){let t=(0,$.c)(18),{editor:n}=e,[r,i]=(0,Q.useState)(null),a,o;if(t[0]===n?(a=t[1],o=t[2]):(a=()=>{let e=()=>i(e=>{let t=mE(n);return e&&t&&e.columnAnchor===t.columnAnchor&&e.rowAnchor===t.rowAnchor?e:t});return e(),n.on(`selectionUpdate`,e),n.on(`update`,e),()=>{n.off(`selectionUpdate`,e),n.off(`update`,e)}},o=[n],t[0]=n,t[1]=a,t[2]=o),(0,Q.useEffect)(a,o),!r)return null;let s=r.columnAnchor,c;t[3]===r.isFirstColumn?c=t[4]:(c=fE(r.isFirstColumn),t[3]=r.isFirstColumn,t[4]=c);let l;t[5]!==r.columnAnchor||t[6]!==n||t[7]!==c?(l=(0,Z.jsx)(hE,{editor:n,anchor:s,axis:`column`,items:c}),t[5]=r.columnAnchor,t[6]=n,t[7]=c,t[8]=l):l=t[8];let u=r.rowAnchor,d;t[9]===r.isFirstRow?d=t[10]:(d=pE(r.isFirstRow),t[9]=r.isFirstRow,t[10]=d);let f;t[11]!==r.rowAnchor||t[12]!==n||t[13]!==d?(f=(0,Z.jsx)(hE,{editor:n,anchor:u,axis:`row`,items:d}),t[11]=r.rowAnchor,t[12]=n,t[13]=d,t[14]=f):f=t[14];let p;return t[15]!==l||t[16]!==f?(p=(0,Z.jsxs)(`div`,{className:`ok-table-cell-handle-layer`,children:[l,f]}),t[15]=l,t[16]=f,t[17]=p):p=t[17],p}function vE(e){let{fragment:t,docName:n}=e,r=!1,i=!1,a=!1,o=()=>{r=!0},s=e=>{console.warn(`[walk-currency] ${e} at view init — stale pre-warm cannot be invalidated: a remote edit that landed in the construct→mount gap will not render, and the first local transaction may silently erase it from the CRDT for every peer and disk (vendored y-tiptap contract change? re-verify y-tiptap.cjs:263-268)`)},c=()=>{i&&(i=!1,t.unobserveDeep(o))},l=e=>{let t=Tt.getState(e.state)?.binding;if(!t){ue.count(`ok/editor/walk-currency-disarmed`,{docName:n,reason:`no-binding`}),s(`no ySync binding on "${n}"`);return}if(typeof t._forceRerender!=`function`){ue.count(`ok/editor/walk-currency-disarmed`,{docName:n,reason:`no-force-rerender`}),s(`ySync binding on "${n}" exposes no _forceRerender`);return}ue.count(`ok/editor/pattern-d-stale-prewarm`,{docName:n}),t._forceRerender()};return gr.create({name:`walkCurrency`,onBeforeCreate(){t.observeDeep(o),i=!0},onDestroy(){c()},addProseMirrorPlugins(){return[new ir({view:e=>(a||(a=!0,c(),r&&l(e)),{})})]}})}var yE=new WeakMap;function bE(e){let t=document.createElement(`span`);t.classList.add(`collaboration-cursor__caret`),t.style.borderColor=e.color;let n=document.createElement(`div`);return n.classList.add(`collaboration-cursor__label`),n.style.backgroundColor=e.color,n.style.color=Hr(e.color),n.textContent=e.name,t.append(n),t}var xE={state:`idle`,count:0,lastFiredAt:null,position:`append`,lastAgentId:null},SE=100,CE=100,wE=3,TE=250;function EE(e){return`contentComponent`in e&&`isEditorContentInitialized`in e}function DE(e,t){let n=w(e);if(!n||t.contains(n.dom))return!1;if(!EE(e))return console.warn(`[TiptapEditor] TipTap EditorContent binding fields missing; detached editor repair skipped`),!1;let r=e;if(r.contentComponent==null)return!1;try{n.setProps({nodeViews:{}})}catch{}return r.contentComponent=null,r.isEditorContentInitialized=!1,!0}function OE(){let e=new sr({extensions:pr});return{mdManager:e,text:xt({mdManager:e}),html:L({mdManager:e}),paste:Se({mdManager:e}),drop:Te({mdManager:e})}}function kE(e,t){return t?{collaboration:fe.configure({document:e.document,ySyncOptions:{mapping:t}}),guard:[vE({fragment:e.document.getXmlFragment(`default`),docName:e.configuration.name??``})]}:{collaboration:fe.configure({document:e.document}),guard:[]}}function AE(e){let{provider:t,placeholder:n,prebuiltMapping:r,onWedged:i}=e,{collaboration:a,guard:o}=kE(t,r);return[...vt.map(e=>e.name===`link`||e.name===`wikiLink`||e.name===`jsxComponent`?e.configure({docName:t.configuration.name??``}):e),ew.configure({placeholder:n??`Type '/' for commands`,showOnlyCurrent:!0}),a,gr.create({name:`imageUploadDecoration`,addProseMirrorPlugins(){return[et]}}),gr.create({name:`collaborationCursor`,addProseMirrorPlugins(){let e=t.awareness;if(!e)throw Error(`[TiptapEditor] HocuspocusProvider has no awareness instance — cursor plugin cannot initialize`);return[mt(e,{cursorBuilder:bE})]}}),gr.create({name:`bindingStalenessGuard`,addProseMirrorPlugins(){return[gw({fragment:t.document.getXmlFragment(`default`),docName:t.configuration.name??``,onWedged:i??(()=>{})})]}}),...o,nE]}function jE(e){let{provider:t,clipboard:n,ctorStart:r}=e;return{onBeforeCreate:({editor:e})=>{yE.set(e,r)},onCreate:({editor:e})=>{n.html.setView(e.view);let r=yE.get(e);if(yE.delete(e),r==null)return;let i=performance.now();ue(`ok/editor/create-tiptap`,{docName:t.configuration.name??`unknown`,ytextLength:t.document.getText(`source`).length},{startTime:r,duration:Math.max(0,i-r)})},editorProps:{attributes:{class:`pt-4 pb-4 h-full`},clipboardTextParser:(e,t,r,i)=>{let a=n.mdManager.parse(e);return i.state.schema.nodeFromJSON(a).content},clipboardTextSerializer:(e,t)=>n.text(e,t),clipboardSerializer:n.html.serializer,handlePaste:(e,t)=>n.paste(e,t),handleDrop:uE(n.drop,e.onSidebarDrop)},extensions:yp(AE(e))}}function ME(e){let{provider:t,placeholder:n,clipboard:r,ctorStart:i,onWedged:a,onSidebarDrop:o}=e,s=t.document.getXmlFragment(`default`),c=new Map,l=jE({provider:t,placeholder:n,clipboard:r,ctorStart:i,prebuiltMapping:c,onWedged:a,onSidebarDrop:o}),u=l.onBeforeCreate;return{...l,onBeforeCreate:e=>{u?.(e);let{editor:t}=e,{doc:n,mapping:r}=Mt(s,t.schema);r.forEach((e,t)=>{c.set(t,e)}),t.options.content=n.toJSON()},element:null}}var NE=e=>{let t=(0,$.c)(24),{provider:n,placeholder:r,isSourceMode:i,portalTarget:a}=e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(xE),c=ow(),{principal:l,activeDocName:u,recycleDocument:d,openTarget:f}=pt(),p=n.configuration.name??``,[m]=(0,Q.useState)(OE),h;t[0]!==m||t[1]!==p||t[2]!==f||t[3]!==r||t[4]!==n||t[5]!==d?(h=()=>()=>({editor:new ei(ME({provider:n,placeholder:r,clipboard:m,ctorStart:performance.now(),onWedged:e=>{let{externalSeq:t,appliedSeq:n}=e;ue(`ok/editor/binding-wedge-recycle`,{docName:p,externalSeq:t,appliedSeq:n}),d(p)},onSidebarDrop:e=>{dE(e,f)}})),ydoc:n.document,ytext:n.document.getText(`source`),provider:n}),t[0]=m,t[1]=p,t[2]=f,t[3]=r,t[4]=n,t[5]=d,t[6]=h):h=t[6];let[g]=(0,Q.useState)(h),_,v;if(t[7]!==g||t[8]!==p||t[9]!==n.document){let e={viewCount:0,bytes:n.document.getText(`source`).length},r=rt(p)??crypto.randomUUID();_=Q.use,v=Y({docName:p,mountId:r,construct:g,sizeStats:e}),t[7]=g,t[8]=p,t[9]=n.document,t[10]=_,t[11]=v}else _=t[10],v=t[11];let y=_(v),b=y.editor,x,S;t[12]===y?(x=t[13],S=t[14]):(x=()=>()=>{de(y)},S=[y],t[12]=y,t[13]=x,t[14]=S),(0,Q.useEffect)(x,S);let C;return t[15]!==u||t[16]!==p||t[17]!==b||t[18]!==c||t[19]!==i||t[20]!==a||t[21]!==l||t[22]!==n?(C=(0,Z.jsx)(PE,{provider:n,isSourceMode:i,docName:p,activeDocName:u,identity:c,principal:l,editor:b,wrapperRef:o,flashStateRef:s,portalTarget:a}),t[15]=u,t[16]=p,t[17]=b,t[18]=c,t[19]=i,t[20]=a,t[21]=l,t[22]=n,t[23]=C):C=t[23],C},PE=e=>{let t=(0,$.c)(98),{provider:n,isSourceMode:r,docName:i,activeDocName:a,identity:o,principal:s,editor:c,wrapperRef:l,flashStateRef:u,portalTarget:f}=e,p=(0,Q.useRef)(null),[m,h]=(0,Q.useState)(0),g,_;t[0]===f?(g=t[1],_=t[2]):(g=()=>{let e=p.current;if(e)return e.appendChild(f),()=>{f.parentNode===e&&e.removeChild(f)}},_=[f],t[0]=f,t[1]=g,t[2]=_),(0,Q.useLayoutEffect)(g,_);let v,b;t[3]!==c||t[4]!==f?(v=()=>{DE(c,f)&&h(FE)},b=[c,f],t[3]=c,t[4]=f,t[5]=v,t[6]=b):(v=t[5],b=t[6]),(0,Q.useEffect)(v,b);let x;t[7]!==c||t[8]!==n.configuration.name?(x=()=>(At(c,n.configuration.name??null),()=>{At(c,null)}),t[7]=c,t[8]=n.configuration.name,t[9]=x):x=t[9];let S;t[10]!==c||t[11]!==n?(S=[c,n],t[10]=c,t[11]=n,t[12]=S):S=t[12],(0,Q.useEffect)(x,S);let C;t[13]!==c||t[14]!==n.configuration.name?(C=()=>{let e=n.configuration.name;if(e)return ne(e,c),()=>N(e,c)},t[13]=c,t[14]=n.configuration.name,t[15]=C):C=t[15];let T;t[16]!==c||t[17]!==n?(T=[c,n],t[16]=c,t[17]=n,t[18]=T):T=t[18],(0,Q.useEffect)(C,T);let E;t[19]!==c||t[20]!==n.configuration.name?(E=()=>{let e=n.configuration.name;if(!e)return;let t=null,r=()=>{t=null,bc(e,`wysiwyg`,Sc(c))},i=()=>{t&&clearTimeout(t),t=setTimeout(r,120)};return r(),c.on(`selectionUpdate`,i),c.on(`update`,i),()=>{t&&clearTimeout(t),c.off(`selectionUpdate`,i),c.off(`update`,i),bc(e,`wysiwyg`,null)}},t[19]=c,t[20]=n.configuration.name,t[21]=E):E=t[21];let D;t[22]!==c||t[23]!==n?(D=[c,n],t[22]=c,t[23]=n,t[24]=D):D=t[24],(0,Q.useEffect)(E,D);let O;t[25]!==c||t[26]!==n.configuration.name?(O=()=>{},t[25]=c,t[26]=n.configuration.name,t[27]=O):O=t[27];let k;t[28]!==c||t[29]!==n?(k=[c,n],t[28]=c,t[29]=n,t[30]=k):k=t[30],(0,Q.useEffect)(O,k);let A,j;t[31]===c?(A=t[32],j=t[33]):(A=()=>{let e=IE,t=null,n=()=>{if(t||c.isDestroyed)return;let n=w(c);n&&(t=n.dom,t.addEventListener(`keydown`,e),t.addEventListener(`paste`,e),t.addEventListener(`drop`,e),t.addEventListener(`cut`,e))},r=()=>{t&&=(t.removeEventListener(`keydown`,e),t.removeEventListener(`paste`,e),t.removeEventListener(`drop`,e),t.removeEventListener(`cut`,e),null)};return w(c)?n():c.on(`create`,n),()=>{c.off(`create`,n),r()}},j=[c],t[31]=c,t[32]=A,t[33]=j),(0,Q.useEffect)(A,j);let M,P;t[34]!==i||t[35]!==c?(M=()=>{let e=!1,t=()=>{if(e||c.isDestroyed||!w(c))return;e=!0;let t=y(i)?.selection??null;if(t)try{let e=c.state.doc.content.size;if(t.type===`text`){let n=Math.max(0,Math.min(t.anchor,e)),r=Math.max(0,Math.min(t.head,e));c.commands.setTextSelection({from:n,to:r})}else{let n=Math.max(0,Math.min(t.from,e));c.commands.setNodeSelection(n)}}catch(e){let t=e,n=t instanceof Error?t.message:String(t);console.warn(JSON.stringify({event:`ok-editor-selection-restore-failed`,docName:i,message:n})),ue(`ok/editor/selection-restore-failed`,{docName:i,message:n})}qt(i)};if(w(c)){t();return}return c.on(`create`,t),()=>{c.off(`create`,t)}},P=[c,i],t[34]=i,t[35]=c,t[36]=M,t[37]=P):(M=t[36],P=t[37]),(0,Q.useEffect)(M,P);let F,I;t[38]!==u||t[39]!==n.document||t[40]!==l?(F=()=>{let e=n.document.getMap(`agent-flash`),t=Date.now(),r=0,i=null,a=null,o=null,s=()=>{let t=null;for(let[,n]of e.entries()){let e=n;e.timestamp&&(!t||e.timestamp>t.timestamp)&&(t={agentId:e.agentId??`unknown`,timestamp:e.timestamp,type:e.type??`insert`,description:e.description})}return t},c=e=>{u.current=e;let t=l.current;t&&(t.setAttribute(`data-agent-flash-state`,e.state),t.setAttribute(`data-agent-flash-count`,String(e.count)),t.setAttribute(`data-agent-flash-position`,e.position),t.setAttribute(`data-agent-flash-agent-id`,e.lastAgentId??``))},d=()=>{let e=s(),t=e?.description?.toLowerCase().includes(`prepend`)?`prepend`:`append`,n={state:`editing`,count:(u.current?.count??0)+1,lastFiredAt:Date.now(),position:t,lastAgentId:e?.agentId??null};c(n),document.dispatchEvent(new CustomEvent(`agent-flash`,{detail:n})),a&&clearTimeout(a),o&&clearTimeout(o),a=window.setTimeout(()=>{let e={...n,state:`settled`};c(e),document.dispatchEvent(new CustomEvent(`agent-flash-end`,{detail:e})),o=window.setTimeout(()=>{c({...e,state:`idle`})},300)},Ln)};c(xE);let f=()=>{if(fr(e),!wr(e,t)||document.visibilityState!==`visible`)return;let n=Date.now();if(t=n,n-r<500){if(!i){let e=500-(n-r);i=window.setTimeout(()=>{i=null,r=Date.now(),d()},e)}return}r=n,d()};e.observe(f);let p=()=>{document.visibilityState===`visible`?wr(e,t)&&(t=Date.now(),r=Date.now(),d()):t=Date.now()};return document.addEventListener(`visibilitychange`,p),()=>{e.unobserve(f),document.removeEventListener(`visibilitychange`,p),i&&clearTimeout(i),a&&clearTimeout(a),o&&clearTimeout(o)}},I=[n.document,u,l],t[38]=u,t[39]=n.document,t[40]=l,t[41]=F,t[42]=I):(F=t[41],I=t[42]),(0,Q.useEffect)(F,I);let L,R;t[43]!==a||t[44]!==i||t[45]!==c||t[46]!==n?(L=()=>{let e=0,t,r=null,o=null,s=null,l=function(){if(e<SE){e+=1,t=window.setTimeout(p,CE);return}r=null,o=null,e=0},u=function(e){let t=w(c);if(!t)return null;let n=CSS.escape(e);return t.dom.querySelector(`#${n}`)??t.dom.querySelector(`[data-mirror-source-id="${n}"]`)},d=function(e){let t=u(e);return t?(t.scrollIntoView({behavior:`smooth`,block:`start`}),!0):!1},f=function(e,n){let r=wE,o=()=>{t=void 0,!(i!==a||window.location.hash!==n)&&(d(e),--r,r>0&&(t=window.setTimeout(o,TE)))};t=window.setTimeout(o,TE)};function p(){if(!r||i!==a)return;let t=r,n=o;if(!n){l();return}d(t)?(s=n,r=null,o=null,e=0,f(t,n)):l()}let m=function(){if(i!==a)return;let n=window.location.hash;if(!r&&s===n)return;let c=Wo(n);if(!c){s=n;return}r=c,o=n,e=0,t!==void 0&&(clearTimeout(t),t=void 0),p()},h=function(){if(i===a){if(r){p();return}m()}};return m(),n.on(`synced`,h),c.on(`transaction`,h),window.addEventListener(`hashchange`,m),()=>{t!==void 0&&clearTimeout(t),n.off(`synced`,h),c.off(`transaction`,h),window.removeEventListener(`hashchange`,m)}},R=[n,c,i,a],t[43]=a,t[44]=i,t[45]=c,t[46]=n,t[47]=L,t[48]=R):(L=t[47],R=t[48]),(0,Q.useEffect)(L,R);let z,B;t[49]===c?(z=t[50],B=t[51]):(z=()=>{let e=function(e){let t=e.detail;if(!t||t.mode!==`wysiwyg`||c.isDestroyed)return;let n=w(c);if(!n)return;let r=n.dom.querySelectorAll(`h1, h2, h3, h4, h5, h6`)[t.index];r&&r.scrollIntoView({behavior:`smooth`,block:`start`})};return window.addEventListener(_c,e),()=>window.removeEventListener(_c,e)},B=[c],t[49]=c,t[50]=z,t[51]=B),(0,Q.useEffect)(z,B);let V;t[52]!==a||t[53]!==i||t[54]!==o||t[55]!==r||t[56]!==s||t[57]!==n.awareness?(V=()=>{let e=n.awareness;if(e){if(i!==a){e.setLocalState(null);return}e.setLocalState({user:sw({principal:s,identity:o}),mode:r?`source`:`wysiwyg`})}},t[52]=a,t[53]=i,t[54]=o,t[55]=r,t[56]=s,t[57]=n.awareness,t[58]=V):V=t[58];let H;t[59]!==a||t[60]!==i||t[61]!==o||t[62]!==r||t[63]!==s||t[64]!==n?(H=[n,i,a,o,s,r],t[59]=a,t[60]=i,t[61]=o,t[62]=r,t[63]=s,t[64]=n,t[65]=H):H=t[65],(0,Q.useEffect)(V,H);let U,W;t[66]!==c||t[67]!==r?(U=()=>(d(c,r),()=>{d(c,!1)}),W=[c,r],t[66]=c,t[67]=r,t[68]=U,t[69]=W):(U=t[68],W=t[69]),(0,Q.useEffect)(U,W);let G;t[70]!==a||t[71]!==i||t[72]!==c||t[73]!==r?(G=!r&&(0,Z.jsx)(NT,{editor:c,shortcutEnabled:i===a}),t[70]=a,t[71]=i,t[72]=c,t[73]=r,t[74]=G):G=t[74];let K;t[75]!==c||t[76]!==r?(K=!r&&(0,Z.jsx)(_E,{editor:c}),t[75]=c,t[76]=r,t[77]=K):K=t[77];let q;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,Z.jsx)(`div`,{ref:p,style:{display:`contents`}}),t[78]=q):q=t[78];let J;t[79]!==c||t[80]!==m?(J=(0,Z.jsx)(je,{editor:c,className:`tiptap-editor-portal-content h-full`},m),t[79]=c,t[80]=m,t[81]=J):J=t[81];let Y;t[82]!==f||t[83]!==J?(Y=(0,qc.createPortal)(J,f),t[82]=f,t[83]=J,t[84]=Y):Y=t[84];let ee;t[85]===c?ee=t[86]:(ee=(0,Z.jsx)(iw,{editor:c}),t[85]=c,t[86]=ee);let te;t[87]===c?te=t[88]:(te=ht(c),t[87]=c,t[88]=te);let re;t[89]===te.store?re=t[90]:(re=(0,Z.jsx)(Dt,{store:te.store}),t[89]=te.store,t[90]=re);let ie;return t[91]!==G||t[92]!==K||t[93]!==Y||t[94]!==ee||t[95]!==re||t[96]!==l?(ie=(0,Z.jsxs)(`div`,{ref:l,className:`tiptap-editor h-full`,"data-agent-flash-state":`idle`,"data-agent-flash-count":`0`,"data-agent-flash-position":`append`,"data-agent-flash-agent-id":``,children:[G,K,q,Y,ee,re]}),t[91]=G,t[92]=K,t[93]=Y,t[94]=ee,t[95]=re,t[96]=l,t[97]=ie):ie=t[97],ie};function FE(e){return e+1}function IE(){return j()}var LE=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}offset(t,n=t){return new e(this.fromA+t,this.toA+t,this.fromB+n,this.toB+n)}};function RE(e,t,n,r,i,a){if(e==r)return[];let o=JE(e,t,n,r,i,a),s=YE(e,t+o,n,r,i+o,a);t+=o,n-=s,i+=o,a-=s;let c=n-t,l=a-i;if(!c||!l)return[new LE(t,n,i,a)];if(c>l){let o=e.slice(t,n).indexOf(r.slice(i,a));if(o>-1)return[new LE(t,t+o,i,i),new LE(t+o+l,n,a,a)]}else if(l>c){let o=r.slice(i,a).indexOf(e.slice(t,n));if(o>-1)return[new LE(t,t,i,i+o),new LE(n,n,i+o+c,a)]}if(c==1||l==1)return[new LE(t,n,i,a)];let u=ZE(e,t,n,r,i,a);if(u){let[o,s,c]=u;return RE(e,t,o,r,i,s).concat(RE(e,o+c,n,r,s+c,a))}return HE(e,t,n,r,i,a)}var zE=1e9,BE=0,VE=!1;function HE(e,t,n,r,i,a){let o=n-t,s=a-i;if(zE<1e9&&Math.min(o,s)>zE*16||BE>0&&Date.now()>BE)return Math.min(o,s)>zE*64?[new LE(t,n,i,a)]:QE(e,t,n,r,i,a);let c=Math.ceil((o+s)/2);WE.reset(c),GE.reset(c);let l=(n,a)=>e.charCodeAt(t+n)==r.charCodeAt(i+a),u=(t,i)=>e.charCodeAt(n-t-1)==r.charCodeAt(a-i-1),d=(o-s)%2==0?null:GE,f=d?null:WE;for(let p=0;p<c;p++){if(p>zE||BE>0&&!(p&63)&&Date.now()>BE)return QE(e,t,n,r,i,a);let m=WE.advance(p,o,s,c,d,!1,l)||GE.advance(p,o,s,c,f,!0,u);if(m)return KE(e,t,n,t+m[0],r,i,a,i+m[1])}return[new LE(t,n,i,a)]}var UE=class{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let e=0;e<this.len;e++)this.vec[e]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,t,n,r,i,a,o){for(let s=-e+this.start;s<=e-this.end;s+=2){let c=r+s,l=s==-e||s!=e&&this.vec[c-1]<this.vec[c+1]?this.vec[c+1]:this.vec[c-1]+1,u=l-s;for(;l<t&&u<n&&o(l,u);)l++,u++;if(this.vec[c]=l,l>t)this.end+=2;else if(u>n)this.start+=2;else if(i){let e=r+(t-n)-s;if(e>=0&&e<this.len&&i.vec[e]!=-1)if(a){let n=i.vec[e];if(n>=t-l)return[n,r+n-e]}else{let n=t-i.vec[e];if(l>=n)return[l,u]}}}return null}},WE=new UE,GE=new UE;function KE(e,t,n,r,i,a,o,s){let c=!1;return!pD(e,r)&&++r==n&&(c=!0),!pD(i,s)&&++s==o&&(c=!0),c?[new LE(t,n,a,o)]:RE(e,t,r,i,a,s).concat(RE(e,r,n,i,s,o))}function qE(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function JE(e,t,n,r,i,a){if(t==n||t==a||e.charCodeAt(t)!=r.charCodeAt(i))return 0;let o=qE(n-t,a-i);for(let s=t,c=i;;){let i=s+o,l=c+o;if(i>n||l>a||e.slice(s,i)!=r.slice(c,l)){if(o==1)return s-t-+!pD(e,s);o>>=1}else if(i==n||l==a)return i-t;else s=i,c=l}}function YE(e,t,n,r,i,a){if(t==n||i==a||e.charCodeAt(n-1)!=r.charCodeAt(a-1))return 0;let o=qE(n-t,a-i);for(let s=n,c=a;;){let a=s-o,l=c-o;if(a<t||l<i||e.slice(a,s)!=r.slice(l,c)){if(o==1)return n-s-+!pD(e,s);o>>=1}else if(a==t||l==i)return n-a;else s=a,c=l}}function XE(e,t,n,r,i,a,o,s){let c=r.slice(i,a),l=null;for(;;){if(l||o<s)return l;for(let s=t+o;;){pD(e,s)||s++;let u=s+o;if(pD(e,u)||(u+=u==s+1?1:-1),u>=n)break;let d=e.slice(s,u),f=-1;for(;(f=c.indexOf(d,f+1))!=-1;){let o=JE(e,u,n,r,i+f+d.length,a),c=YE(e,t,s,r,i,i+f),p=d.length+o+c;(!l||l[2]<p)&&(l=[s-c,i+f-c,p])}s=u}if(s<0)return l;o>>=1}}function ZE(e,t,n,r,i,a){let o=n-t,s=a-i;if(o<s){let o=ZE(r,i,a,e,t,n);return o&&[o[1],o[0],o[2]]}return o<4||s*2<o?null:XE(e,t,n,r,i,a,Math.floor(o/4),-1)}function QE(e,t,n,r,i,a){VE=!0;let o=n-t,s=a-i,c;if(o<s){let s=XE(r,i,a,e,t,n,Math.floor(o/6),50);c=s&&[s[1],s[0],s[2]]}else c=XE(e,t,n,r,i,a,Math.floor(s/6),50);if(!c)return[new LE(t,n,i,a)];let[l,u,d]=c;return RE(e,t,l,r,i,u).concat(RE(e,l+d,n,r,u+d,a))}function $E(e,t){for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n];r.toA>i.fromA-t&&r.toB>i.fromB-t&&(e[n-1]=new LE(r.fromA,i.toA,r.fromB,i.toB),e.splice(n--,1))}}function eD(e,t,n){for(;;){$E(n,1);let r=!1;for(let i=0;i<n.length;i++){let a=n[i],o,s;(o=JE(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new LE(a.fromA+o,a.toA,a.fromB+o,a.toB)),(s=YE(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new LE(a.fromA,a.toA-s,a.fromB,a.toB-s));let c=a.toA-a.fromA,l=a.toB-a.fromB;if(c&&l)continue;let u=a.fromA-(i?n[i-1].toA:0),d=(i<n.length-1?n[i+1].fromA:e.length)-a.toA;if(!u||!d)continue;let f=c?e.slice(a.fromA,a.toA):t.slice(a.fromB,a.toB);u<=f.length&&e.slice(a.fromA-u,a.fromA)==f.slice(f.length-u)?(n[i]=new LE(a.fromA-u,a.toA-u,a.fromB-u,a.toB-u),r=!0):d<=f.length&&e.slice(a.toA,a.toA+d)==f.slice(0,d)&&(n[i]=new LE(a.fromA+d,a.toA+d,a.fromB+d,a.toB+d),r=!0)}if(!r)break}return n}function tD(e,t,n){for(let r=0,i=0;i<e.length;i++){let a=e[i],o=a.toA-a.fromA,s=a.toB-a.fromB;if(o&&s||o>3||s>3){let c=i==e.length-1?t.length:e[i+1].fromA,l=a.fromA-r,u=c-a.toA,d=cD(t,a.fromA,l),f=sD(t,a.toA,u),p=a.fromA-d,m=f-a.toA;if((!o||!s)&&p&&m){let l=Math.max(o,s),[u,h,g]=o?[t,a.fromA,a.toA]:[n,a.fromB,a.toB];l>p&&t.slice(d,a.fromA)==u.slice(g-p,g)?(a=e[i]=new LE(d,d+o,a.fromB-p,a.toB-p),d=a.fromA,f=sD(t,a.toA,c-a.toA)):l>m&&t.slice(a.toA,f)==u.slice(h,h+m)&&(a=e[i]=new LE(f-o,f,a.fromB+m,a.toB+m),f=a.toA,d=cD(t,a.fromA,a.fromA-r)),p=a.fromA-d,m=f-a.toA}if(p||m)a=e[i]=new LE(a.fromA-p,a.toA+m,a.fromB-p,a.toB+m);else if(!o){let t=uD(n,a.fromB,a.toB),r,o=t<0?-1:lD(n,a.toB,a.fromB);t>-1&&(r=t-a.fromB)<=u&&n.slice(a.fromB,t)==n.slice(a.toB,a.toB+r)?a=e[i]=a.offset(r):o>-1&&(r=a.toB-o)<=l&&n.slice(a.fromB-r,a.fromB)==n.slice(o,a.toB)&&(a=e[i]=a.offset(-r))}else if(!s){let n=uD(t,a.fromA,a.toA),r,o=n<0?-1:lD(t,a.toA,a.fromA);n>-1&&(r=n-a.fromA)<=u&&t.slice(a.fromA,n)==t.slice(a.toA,a.toA+r)?a=e[i]=a.offset(r):o>-1&&(r=a.toA-o)<=l&&t.slice(a.fromA-r,a.fromA)==t.slice(o,a.toA)&&(a=e[i]=a.offset(-r))}}r=a.toA}return $E(e,3),e}var nD;try{nD=RegExp(`[\\p{Alphabetic}\\p{Number}]`,`u`)}catch{}function rD(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function iD(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?+!!rD(n):nD?!dD(n)||t==e.length-1?+!!nD.test(String.fromCharCode(n)):nD.test(e.slice(t,t+2))?2:0:0}function aD(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?+!!rD(n):nD?!fD(n)||t==1?+!!nD.test(String.fromCharCode(n)):nD.test(e.slice(t-2,t))?2:0:0}var oD=8;function sD(e,t,n){if(t==e.length||!aD(e,t))return t;for(let r=t,i=t+n,a=0;a<oD;a++){let t=iD(e,r);if(!t||r+t>i)return r;r+=t}return t}function cD(e,t,n){if(!t||!iD(e,t))return t;for(let r=t,i=t-n,a=0;a<oD;a++){let t=aD(e,r);if(!t||r-t<i)return r;r-=t}return t}function lD(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function uD(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}var dD=e=>e>=55296&&e<=56319,fD=e=>e>=56320&&e<=57343;function pD(e,t){return!t||t==e.length||!dD(e.charCodeAt(t-1))||!fD(e.charCodeAt(t))}function mD(e,t,n){let r=n?.override;return r?r(e,t):(zE=(n?.scanLimit??1e9)>>1,BE=n?.timeout?Date.now()+n.timeout:0,VE=!1,eD(e,t,RE(e,0,e.length,t,0,t.length)))}function hD(){return!VE}function gD(e,t,n){return tD(mD(e,t,n),e,t)}var _D=ic.define({combine:e=>e[0]}),vD=ac.define(),yD=ic.define(),bD=$s.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(vD)&&(e=n.value);for(let n of t.state.facet(yD))e=n(e,t);return e}});function xD(e){let t=e.field(bD,!1);if(!t)return null;let n=e.facet(_D);return{chunks:t,side:n?n.side:null}}var SD=class e{constructor(e,t,n,r,i,a=!0){this.changes=e,this.fromA=t,this.toA=n,this.fromB=r,this.toB=i,this.precise=a}offset(t,n){return t||n?new e(this.changes,this.fromA+t,this.toA+t,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,t,n){return TD(gD(e.toString(),t.toString(),n),e,t,0,0,hD())}static updateA(e,t,n,r,i){return kD(OD(e,r,!0,n.length),e,t,n,i)}static updateB(e,t,n,r,i){return kD(OD(e,r,!1,t.length),e,t,n,i)}};function CD(e,t,n,r){let i=n.lineAt(e),a=r.lineAt(t);return i.to==e&&a.to==t&&e<n.length&&t<r.length?[e+1,t+1]:[i.from,a.from]}function wD(e,t,n,r){let i=n.lineAt(e),a=r.lineAt(t);return i.from==e&&a.from==t?[e,t]:[i.to+1,a.to+1]}function TD(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length;s++){let c=e[s],[l,u]=CD(c.fromA+r,c.fromB+i,t,n),[d,f]=wD(c.toA+r,c.toB+i,t,n),p=[c.offset(-l+r,-u+i)];for(;s<e.length-1;){let a=e[s+1],[o,c]=CD(a.fromA+r,a.fromB+i,t,n);if(o>d+1&&c>f+1)break;p.push(a.offset(-l+r,-u+i)),[d,f]=wD(a.toA+r,a.toB+i,t,n),s++}o.push(new SD(p,l,Math.max(l,d),u,Math.max(u,f),a))}return o}var ED=1e3;function DD(e,t,n,r){let i=0,a=e.length;for(;;){if(i==a){let r=0,a=0;i&&({toA:r,toB:a}=e[i-1]);let o=t-(n?r:a);return[r+o,a+o]}let o=i+a>>1,s=e[o],[c,l]=n?[s.fromA,s.toA]:[s.fromB,s.toB];if(c>t)a=o;else if(l<=t)i=o+1;else return r?[s.fromA,s.fromB]:[s.toA,s.toB]}}function OD(e,t,n,r){let i=[];return t.iterChangedRanges((a,o,s,c)=>{let l=0,u=n?t.length:r,d=0,f=n?r:t.length;a>ED&&([l,d]=DD(e,a-ED,n,!0)),o<t.length-ED&&([u,f]=DD(e,o+ED,n,!1));let p=c-s-(o-a),m,[h,g]=n?[p,0]:[0,p];i.length&&(m=i[i.length-1]).toA>=l?i[i.length-1]={fromA:m.fromA,fromB:m.fromB,toA:u,toB:f,diffA:m.diffA+h,diffB:m.diffB+g}:i.push({fromA:l,toA:u,fromB:d,toB:f,diffA:h,diffB:g})}),i}function kD(e,t,n,r,i){if(!e.length)return t;let a=[];for(let o=0,s=0,c=0,l=0;;o++){let u=o==e.length?null:e[o],d=u?u.fromA+s:n.length,f=u?u.fromB+c:r.length;for(;l<t.length;){let e=t[l];if(u&&(e.toA+s>d||e.toB+c>f))break;a.push(e.offset(s,c)),l++}if(!u)break;let p=u.toA+s+u.diffA,m=u.toB+c+u.diffB,h=gD(n.sliceString(d,p),r.sliceString(f,m),i);for(let e of TD(h,n,r,d,f,hD()))a.push(e);for(s+=u.diffA,c+=u.diffB;l<t.length;){let e=t[l];if(e.fromA+s>p&&e.fromB+c>m)break;l++}}return a}var AD={scanLimit:500},jD=oc.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=VD(e))}update(e){(e.docChanged||e.viewportChanged||ND(e.startState,e.state)||PD(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=VD(e.view))}},{decorations:e=>e.deco}),MD=Xs.low(uc({class:`cm-changeGutter`,markers:e=>e.plugin(jD)?.gutter||fc.empty}));function ND(e,t){return e.field(bD,!1)!=t.field(bD,!1)}function PD(e,t){return e.facet(_D)!=t.facet(_D)}var FD=nc.line({class:`cm-changedLine`}),ID=nc.mark({class:`cm-changedText`}),LD=nc.mark({tagName:`ins`,class:`cm-insertedLine`}),RD=nc.mark({tagName:`del`,class:`cm-deletedLine`}),zD=new class extends lc{constructor(){super(...arguments),this.elementClass=`cm-changedLineGutter`}};function BD(e,t,n,r,i,a){let o=n?e.fromA:e.fromB,s=n?e.toA:e.toB,c=0;if(o!=s){i.add(o,o,FD),i.add(o,s,n?RD:LD),a&&a.add(o,o,zD);for(let l=t.iterRange(o,s-1),u=o;!l.next().done;){if(l.lineBreak){u++,i.add(u,u,FD),a&&a.add(u,u,zD);continue}let t=u+l.value.length;if(r)for(;c<e.changes.length;){let r=e.changes[c],a=o+(n?r.fromA:r.fromB),s=o+(n?r.toA:r.toB),l=Math.max(u,a),d=Math.min(t,s);if(l<d&&i.add(l,d,ID),s<t)c++;else break}u=t}}}function VD(e){let t=e.state.field(bD),{side:n,highlightChanges:r,markGutter:i,overrideChunk:a}=e.state.facet(_D),o=n==`a`,s=new rc,c=i?new rc:null,{from:l,to:u}=e.viewport;for(let n of t){if((o?n.fromA:n.fromB)>=u)break;(o?n.toA:n.toB)>l&&(!a||!a(e.state,n,s,c))&&BD(n,e.state.doc,o,r,s,c)}return{deco:s.finish(),gutter:c&&c.finish()}}var HD=class extends Ys{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement(`div`);return e.className=`cm-mergeSpacer`,e.style.height=this.height+`px`,e}updateDOM(e){return e.style.height=this.height+`px`,!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}},UD=ac.define({map:(e,t)=>e.map(t)}),WD=$s.define({create:()=>nc.none,update:(e,t)=>{for(let e of t.effects)if(e.is(UD))return e.value;return e.map(t.changes)},provide:e=>cc.decorations.from(e)}),GD=.01;function KD(e,t){if(e.size!=t.size)return!1;let n=e.iter(),r=t.iter();for(;n.value;){if(n.from!=r.from||Math.abs(n.value.spec.widget.height-r.value.spec.widget.height)>1)return!1;n.next(),r.next()}return!0}function qD(e,t,n){let r=new rc,i=new rc,a=e.state.field(WD).iter(),o=t.state.field(WD).iter(),s=0,c=0,l=0,u=0,d=e.viewport,f=t.viewport;for(let p=0;;p++){let m=p<n.length?n[p]:null,h=m?m.fromA:e.state.doc.length,g=m?m.fromB:t.state.doc.length;if(s<h){let n=e.lineBlockAt(s).top+l-(t.lineBlockAt(c).top+u);n<-GD?(l-=n,r.add(s,s,nc.widget({widget:new HD(-n),block:!0,side:-1}))):n>GD&&(u+=n,i.add(c,c,nc.widget({widget:new HD(n),block:!0,side:-1})))}if(h>s+1e3&&s<d.from&&h>d.from&&c<f.from&&g>f.from){let e=Math.min(d.from-s,f.from-c);s+=e,c+=e,p--}else if(m)s=m.toA,c=m.toB;else break;for(;a.value&&a.from<s;)l-=a.value.spec.widget.height,a.next();for(;o.value&&o.from<c;)u-=o.value.spec.widget.height,o.next()}for(;a.value;)l-=a.value.spec.widget.height,a.next();for(;o.value;)u-=o.value.spec.widget.height,o.next();let p=e.contentHeight+l-(t.contentHeight+u);p<GD?r.add(e.state.doc.length,e.state.doc.length,nc.widget({widget:new HD(-p),block:!0,side:1})):p>GD&&i.add(t.state.doc.length,t.state.doc.length,nc.widget({widget:new HD(p),block:!0,side:1}));let m=r.finish(),h=i.finish();KD(m,e.state.field(WD))||e.dispatch({effects:UD.of(m)}),KD(h,t.state.field(WD))||t.dispatch({effects:UD.of(h)})}var JD=ac.define({map:(e,t)=>t.mapPos(e)}),YD=class extends Ys{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let t=document.createElement(`div`);return t.className=`cm-collapsedLines`,t.textContent=e.state.phrase(`$ unchanged lines`,this.lines),t.addEventListener(`click`,t=>{let n=e.posAtDOM(t.target);e.dispatch({effects:JD.of(n)});let{side:r,sibling:i}=e.state.facet(_D);i&&i().dispatch({effects:JD.of(XD(n,e.state.field(bD),r==`a`))})}),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return`collapsed-unchanged-code`}};function XD(e,t,n){let r=0,i=0;for(let a=0;;a++){let o=a<t.length?t[a]:null;if(!o||(n?o.fromA:o.fromB)>=e)return i+(e-r);[r,i]=n?[o.toA,o.toB]:[o.toB,o.toA]}}var ZD=$s.define({create(e){return nc.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(JD)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>cc.decorations.from(e)});function QD({margin:e=3,minSize:t=4}){return ZD.init(n=>$D(n,e,t))}function $D(e,t,n){let r=new rc,i=e.facet(_D).side==`a`,a=e.field(bD),o=1;for(let s=0;;s++){let c=s<a.length?a[s]:null,l=s?o+t:1,u=c?e.doc.lineAt(i?c.fromA:c.fromB).number-1-t:e.doc.lines,d=u-l+1;if(d>=n&&r.add(e.doc.line(l).from,e.doc.line(u).to,nc.replace({widget:new YD(d),block:!0})),!c)break;o=e.doc.lineAt(Math.min(e.doc.length,i?c.toA:c.toB)).number}return r.finish()}var eO=cc.styleModule.of(new dc({".cm-mergeView":{overflowY:`auto`},".cm-mergeViewEditors":{display:`flex`,alignItems:`stretch`},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:`hidden`},".cm-merge-revert":{width:`1.6em`,flexGrow:0,flexShrink:0,position:`relative`},".cm-merge-revert button":{position:`absolute`,display:`block`,width:`100%`,boxSizing:`border-box`,textAlign:`center`,background:`none`,border:`none`,font:`inherit`,cursor:`pointer`}})),tO=cc.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:`auto !important`,overflowY:`visible !important`},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:`rgba(160, 128, 100, .08)`},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:`rgba(100, 160, 128, .08)`},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat`},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat`},"&light.cm-merge-b .cm-changedText":{background:`linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat`},"&dark.cm-merge-b .cm-changedText":{background:`linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat`},"&.cm-merge-b .cm-deletedText":{background:`#ff000033`},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:`none`},".cm-deletedChunk":{paddingLeft:`6px`,"& .cm-chunkButtons":{position:`absolute`,insetInlineEnd:`5px`},"& button":{border:`none`,cursor:`pointer`,color:`white`,margin:`0 2px`,borderRadius:`3px`,"&[name=accept]":{background:`#2a2`},"&[name=reject]":{background:`#d43`}}},".cm-collapsedLines":{padding:`5px 5px 5px 10px`,cursor:`pointer`,"&:before":{content:`"⦚"`,marginInlineEnd:`7px`},"&:after":{content:`"⦚"`,marginInlineStart:`7px`}},"&light .cm-collapsedLines":{color:`#444`,background:`linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)`},"&dark .cm-collapsedLines":{color:`#ddd`,background:`linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)`},".cm-changeGutter":{width:`3px`,paddingLeft:`1px`},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:`#e43`},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:`#fa9`},"&light.cm-merge-b .cm-changedLineGutter":{background:`#2b2`},"&dark.cm-merge-b .cm-changedLineGutter":{background:`#8f8`},".cm-inlineChangedLineGutter":{background:`#75d`}}),nO=new sc,rO=new sc,iO=class{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||AD;let t=[Xs.low(jD),tO,eO,WD,cc.updateListener.of(e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some(e=>e.effects.some(e=>e.is(UD)))&&this.measure()})],n=[_D.of({side:`a`,sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&n.push(MD);let r=Qs.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],cc.editorAttributes.of({class:`cm-merge-a`}),rO.of(n),t]}),i=[_D.of({side:`b`,sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&i.push(MD);let a=Qs.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],cc.editorAttributes.of({class:`cm-merge-b`}),rO.of(i),t]});this.chunks=SD.build(r.doc,a.doc,this.diffConf);let o=[bD.init(()=>this.chunks),nO.of(e.collapseUnchanged?QD(e.collapseUnchanged):[])];r=r.update({effects:ac.appendConfig.of(o)}).state,a=a.update({effects:ac.appendConfig.of(o)}).state,this.dom=document.createElement(`div`),this.dom.className=`cm-mergeView`,this.editorDOM=this.dom.appendChild(document.createElement(`div`)),this.editorDOM.className=`cm-mergeViewEditors`;let s=e.orientation||`a-b`,c=document.createElement(`div`);c.className=`cm-mergeViewEditor`;let l=document.createElement(`div`);l.className=`cm-mergeViewEditor`,this.editorDOM.appendChild(s==`a-b`?c:l),this.editorDOM.appendChild(s==`a-b`?l:c),this.a=new cc({state:r,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new cc({state:a,parent:l,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls==`b-to-a`,e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,t){if(e.some(e=>e.docChanged)){let n=e[e.length-1],r=e.reduce((e,t)=>e.compose(t.changes),Zs.empty(e[0].startState.doc.length));this.chunks=t==this.a?SD.updateA(this.chunks,n.newDoc,this.b.state.doc,r,this.diffConf):SD.updateB(this.chunks,this.a.state.doc,n.newDoc,r,this.diffConf),t.update([...e,n.state.update({effects:vD.of(this.chunks)})]);let i=t==this.a?this.b:this.a;i.update([i.state.update({effects:vD.of(this.chunks)})]),this.scheduleMeasure()}else t.update(e)}reconfigure(e){if(`diffConfig`in e&&(this.diffConf=e.diffConfig),`orientation`in e){let t=e.orientation!=`b-a`;if(t!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let e=this.a.dom.parentNode,n=this.b.dom.parentNode;e.remove(),n.remove(),this.editorDOM.insertBefore(t?e:n,this.editorDOM.firstChild),this.editorDOM.appendChild(t?n:e),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent=``)}}if(`revertControls`in e||`renderRevertControl`in e){let t=!!this.revertDOM,n=this.revertToA,r=this.renderRevert;`revertControls`in e&&(t=!!e.revertControls,n=e.revertControls==`b-to-a`),`renderRevertControl`in e&&(r=e.renderRevertControl),this.setupRevertControls(t,n,r)}let t=`highlightChanges`in e,n=`gutter`in e,r=`collapseUnchanged`in e;if(t||n||r){let i=[],a=[];if(t||n){let r=this.a.state.facet(_D),o=n?e.gutter!==!1:r.markGutter,s=t?e.highlightChanges!==!1:r.highlightChanges;i.push(rO.reconfigure([_D.of({side:`a`,sibling:()=>this.b,highlightChanges:s,markGutter:o}),o?MD:[]])),a.push(rO.reconfigure([_D.of({side:`b`,sibling:()=>this.a,highlightChanges:s,markGutter:o}),o?MD:[]]))}if(r){let t=nO.reconfigure(e.collapseUnchanged?QD(e.collapseUnchanged):[]);i.push(t),a.push(t)}this.a.dispatch({effects:i}),this.b.dispatch({effects:a})}this.scheduleMeasure()}setupRevertControls(e,t,n){this.revertToA=t,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=n,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement(`div`),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener(`mousedown`,e=>this.revertClicked(e)),this.revertDOM.className=`cm-merge-revert`):this.revertDOM&&(this.revertDOM.textContent=``)}scheduleMeasure(){this.measuring<0&&(this.measuring=(this.dom.ownerDocument.defaultView||window).requestAnimationFrame(()=>{this.measuring=-1,this.measure()}))}measure(){qD(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,t=e.firstChild,n=this.a.viewport,r=this.b.viewport;for(let i=0;i<this.chunks.length;i++){let a=this.chunks[i];if(a.fromA>n.to||a.fromB>r.to)break;if(a.fromA<n.from||a.fromB<r.from)continue;let o=this.a.lineBlockAt(a.fromA).top+`px`;for(;t&&+t.dataset.chunk<i;)t=aO(t);t&&t.dataset.chunk==String(i)?(t.style.top!=o&&(t.style.top=o),t=t.nextSibling):e.insertBefore(this.renderRevertButton(o,i),t)}for(;t;)t=aO(t)}renderRevertButton(e,t){let n;if(this.renderRevert)n=this.renderRevert();else{n=document.createElement(`button`);let e=this.a.state.phrase(`Revert this chunk`);n.setAttribute(`aria-label`,e),n.setAttribute(`title`,e),n.textContent=this.revertToLeft?`⇜`:`⇝`}return n.style.top=e,n.setAttribute(`data-chunk`,String(t)),n}revertClicked(e){let t=e.target,n;for(;t&&t.parentNode!=this.revertDOM;)t=t.parentNode;if(t&&(n=this.chunks[t.dataset.chunk])){let[t,r,i,a,o,s]=this.revertToA?[this.b,this.a,n.fromB,n.toB,n.fromA,n.toA]:[this.a,this.b,n.fromA,n.toA,n.fromB,n.toB],c=t.state.sliceDoc(i,Math.max(i,a-1));i!=a&&s<=r.state.doc.length&&(c+=t.state.lineBreak),r.dispatch({changes:{from:o,to:Math.min(r.state.doc.length,s),insert:c},userEvent:`revert`}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}};function aO(e){let t=e.nextSibling;return e.remove(),t}var oO=new class extends lc{constructor(){super(...arguments),this.elementClass=`cm-deletedLineGutter`}},sO=Xs.low(uc({class:`cm-changeGutter`,markers:e=>e.plugin(jD)?.gutter||fc.empty,widgetMarker:(e,t)=>t instanceof fO?oO:null}));function cO(e){let t=typeof e.original==`string`?tc.of(e.original.split(/\r?\n/)):e.original,n=e.diffConfig||AD;return[Xs.low(jD),_O,tO,cc.editorAttributes.of({class:`cm-merge-b`}),yD.of((e,t)=>{let r=t.effects.find(e=>e.is(lO));return r&&(e=SD.updateA(e,r.value.doc,t.startState.doc,r.value.changes,n)),t.docChanged&&(e=SD.updateB(e,t.state.field(uO),t.newDoc,t.changes,n)),e}),_D.of({highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1,syntaxHighlightDeletions:e.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:e.mergeControls??!0,overrideChunk:e.allowInlineDiffs?CO:void 0,side:`b`}),uO.init(()=>t),e.gutter===!1?[]:sO,e.collapseUnchanged?QD(e.collapseUnchanged):[],bD.init(e=>SD.build(t,e.doc,n))]}var lO=ac.define(),uO=$s.define({create:()=>tc.empty,update(e,t){for(let n of t.effects)n.is(lO)&&(e=n.value.doc);return e}}),dO=new WeakMap,fO=class extends Ys{constructor(e){super(),this.buildDOM=e,this.dom=null}eq(e){return this.dom==e.dom}toDOM(e){return this.dom||=this.buildDOM(e)}};function pO(e,t,n){let r=dO.get(t.changes);if(r)return r;let i=nc.widget({block:!0,side:-1,widget:new fO(r=>{let{highlightChanges:i,syntaxHighlightDeletions:a,syntaxHighlightDeletionsMaxLength:o,mergeControls:s}=e.facet(_D),c=document.createElement(`div`);if(c.className=`cm-deletedChunk`,s){let t=c.appendChild(document.createElement(`div`));t.className=`cm-chunkButtons`;let n=e=>{e.preventDefault(),mO(r,r.posAtDOM(c))},i=e=>{e.preventDefault(),hO(r,r.posAtDOM(c))};if(typeof s==`function`)t.appendChild(s(`accept`,n)),t.appendChild(s(`reject`,i));else{let r=t.appendChild(document.createElement(`button`));r.name=`accept`,r.textContent=e.phrase(`Accept`),r.onmousedown=n;let a=t.appendChild(document.createElement(`button`));a.name=`reject`,a.textContent=e.phrase(`Reject`),a.onmousedown=i}}if(n||t.fromA>=t.toA)return c;let l=r.state.field(uO).sliceString(t.fromA,t.endA),u=a&&e.facet(pc),d=h(),f=t.changes,p=0,m=!1;function h(){let e=c.appendChild(document.createElement(`div`));return e.className=`cm-deletedLine`,e.appendChild(document.createElement(`del`))}function g(e,t,n){for(let r=e;r<t;){if(l.charAt(r)==`
|
|
28
28
|
`){d.firstChild||d.appendChild(document.createElement(`br`)),d=h(),r++;continue}let e=t,a=n+(m?` cm-deletedText`:``),o=!1,s=l.indexOf(`
|
|
29
|
-
`,r);if(s>-1&&s<t&&(e=s),i&&p<f.length){let t=Math.max(0,m?f[p].toA:f[p].fromA);t<=e&&(e=t,m&&p++,o=!0)}if(e>r){let t=document.createTextNode(l.slice(r,e));if(a){let e=d.appendChild(document.createElement(`span`));e.className=a,e.appendChild(t)}else d.appendChild(t);r=e}o&&(m=!m)}}if(u&&t.toA-t.fromA<=o){let t=u.parser.parse(l),n=0;ec(t,{style:t=>mc(e,t)},(e,t,r)=>{e>n&&g(n,e,``),g(e,t,r),n=t}),g(n,l.length,``)}else g(0,l.length,``);return d.firstChild||d.appendChild(document.createElement(`br`)),c})});return dO.set(t.changes,i),i}function mO(e,t){let{state:n}=e,r=t??n.selection.main.head,i=e.state.field(bD).find(e=>e.fromB<=r&&e.endB>=r);if(!i)return!1;let a=e.state.sliceDoc(i.fromB,Math.max(i.fromB,i.toB-1)),o=e.state.field(uO);i.fromB!=i.toB&&i.toA<=o.length&&(a+=e.state.lineBreak);let s=Zs.of({from:i.fromA,to:Math.min(o.length,i.toA),insert:a},o.length);return e.dispatch({effects:lO.of({doc:s.apply(o),changes:s}),userEvent:`accept`}),!0}function hO(e,t){let{state:n}=e,r=t??n.selection.main.head,i=n.field(bD).find(e=>e.fromB<=r&&e.endB>=r);if(!i)return!1;let a=n.field(uO).sliceString(i.fromA,Math.max(i.fromA,i.toA-1));return i.fromA!=i.toA&&i.toB<=n.doc.length&&(a+=n.lineBreak),e.dispatch({changes:{from:i.fromB,to:Math.min(n.doc.length,i.toB),insert:a},userEvent:`revert`}),!0}function gO(e){let t=new rc;for(let n of e.field(bD)){let r=e.facet(_D).overrideChunk&&yO(e,n);t.add(n.fromB,n.fromB,pO(e,n,!!r))}return t.finish()}var _O=$s.define({create:e=>gO(e),update(e,t){return t.state.field(bD,!1)==t.startState.field(bD,!1)?e:gO(t.state)},provide:e=>cc.decorations.from(e)}),vO=new WeakMap;function yO(e,t){let n=vO.get(t);if(n!==void 0)return n;n=null;let r=e.field(uO),i=e.doc,a=r.lineAt(t.endA).number-r.lineAt(t.fromA).number+1,o=i.lineAt(t.endB).number-i.lineAt(t.fromB).number+1;abort:if(a==o&&a<10){let e=[],i=0,o=t.fromA,s=t.fromB;for(let n of t.changes){if(n.fromA<n.toA){i+=n.toA-n.fromA;let t=r.sliceString(o+n.fromA,o+n.toA);if(/\n/.test(t))break abort;e.push(nc.widget({widget:new bO(t),side:-1}).range(s+n.fromB))}n.fromB<n.toB&&e.push(ID.range(s+n.fromB,s+n.toB))}i<t.endA-t.fromA-a*2&&(n=e)}return vO.set(t,n),n}var bO=class extends Ys{constructor(e){super(),this.text=e}eq(e){return this.text==e.text}toDOM(e){let t=document.createElement(`del`);return t.className=`cm-deletedText`,t.textContent=this.text,t}},xO=new class extends lc{constructor(){super(...arguments),this.elementClass=`cm-inlineChangedLineGutter`}},SO=nc.line({class:`cm-inlineChangedLine`});function CO(e,t,n,r){let i=yO(e,t),a=0;if(!i)return!1;for(let o=e.doc.lineAt(t.fromB);;){for(r&&r.add(o.from,o.from,xO),n.add(o.from,o.from,SO);a<i.length&&i[a].to<=o.to;){let e=i[a++];n.add(e.from,e.to,e.value)}if(o.to>=t.endB)break;o=e.doc.lineAt(o.to+1)}return!0}var wO=ee({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}}),TO=G({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}}),EO=cc.theme({".cm-deletedChunk .cm-chunkButtons":{display:`flex`,gap:`0.25rem`},".cm-deletedChunk .cm-chunkButtons button[data-slot='button']":{margin:`0`,border:`1px solid transparent`,borderRadius:`min(var(--radius-md), 10px)`,color:`var(--primary-foreground)`},".cm-deletedChunk .cm-chunkButtons button[data-slot='button'][data-variant='destructive']":{color:`var(--destructive)`}});function DO({addControl:e,nextId:t,removeControl:n,root:r}){return(i,a)=>{let o=document.createElement(`span`);o.className=`inline-flex`;let s=t();return e({id:s,host:o,type:i,action:a}),queueMicrotask(()=>{r.contains(o)||n(s)}),o}}function OO(e){let t=(0,$.c)(32),{oldContent:n,newContent:r,layout:a,conflictMode:o,previewMode:c,oursOverride:l,onResolve:u,onAbort:d}=e,{_:f}=i(),p=l??r,m=(0,Q.useRef)(null),h=(0,Q.useRef)(null),g=(0,Q.useRef)(0),{resolvedTheme:_}=vr(),v=(0,Q.useRef)(u),y=(0,Q.useRef)(d),[b,x]=(0,Q.useState)(null),S;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(S=[],t[0]=S):S=t[0];let[C,w]=(0,Q.useState)(S),T;t[1]!==d||t[2]!==u?(T=()=>{v.current=u,y.current=d},t[1]=d,t[2]=u,t[3]=T):T=t[3],(0,Q.useEffect)(T);let E,D;t[4]!==o||t[5]!==p||t[6]!==a||t[7]!==n||t[8]!==c||t[9]!==_?(E=()=>{let e=m.current;if(!e)return;w([]);let t=new Map,r=!1,i=e=>{r||!t.delete(e)||w(t=>t.filter(t=>t.id!==e))},s=new MutationObserver(()=>{for(let[n,r]of t)e.contains(r)||i(n)});s.observe(e,{childList:!0,subtree:!0});let l=_===`dark`?wO:TO,u=[cc.editable.of(!1),Qs.readOnly.of(!0)],d=[Ec,hc(),...u,l,cc.lineWrapping];if(h.current&&=(h.current.destroy(),null),c)h.current=new cc({doc:p,extensions:d,parent:e}),x(null);else if(o){let a=DO({addControl:e=>{r||(t.set(e.id,e.host),w(t=>[...t,e]))},nextId:()=>(g.current+=1,g.current),removeControl:i,root:e}),o=new cc({doc:p,extensions:[Ec,hc(),cc.editable.of(!1),l,EO,cc.lineWrapping,cO({original:n,highlightChanges:!0,gutter:!0,mergeControls:a,collapseUnchanged:{margin:3,minSize:4}}),cc.updateListener.of(e=>{let t=xD(e.state);x(t?t.chunks.length:0)})],parent:e});h.current=o;let s=xD(o.state);x(s?s.chunks.length:0)}else a===`split`?h.current=new iO({a:{doc:n,extensions:d},b:{doc:p,extensions:d},parent:e,highlightChanges:!0,gutter:!0,collapseUnchanged:{margin:3,minSize:4}}):h.current=new cc({doc:p,extensions:[...d,cO({original:n,highlightChanges:!0,gutter:!0,mergeControls:!1,collapseUnchanged:{margin:3,minSize:4}})],parent:e});return()=>{r=!0,s.disconnect(),h.current&&=(h.current.destroy(),null)}},D=[n,p,a,_,o,c],t[4]=o,t[5]=p,t[6]=a,t[7]=n,t[8]=c,t[9]=_,t[10]=E,t[11]=D):(E=t[10],D=t[11]),(0,Q.useEffect)(E,D);let O;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(O=function(){let e=h.current;!e||!(e instanceof cc)||v.current?.(e.state.doc.toString())},t[12]=O):O=t[12];let k=O,A;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(A=function(){let e=h.current;!e||!(e instanceof cc)||ye(e)},t[13]=A):A=t[13];let j=A,M=b===0,N;t[14]!==f||t[15]!==b?(N=b===null?``:b===0?f({id:`lPzyrU`}):Ko._({id:`8FqTCr`,values:{chunksRemaining:b}}),t[14]=f,t[15]=b,t[16]=N):N=t[16];let P=N,F;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(`div`,{ref:m,className:`diff-view min-h-0 flex-1 overflow-y-auto subtle-scrollbar`}),t[17]=F):F=t[17];let I;if(t[18]!==f||t[19]!==C){let e;t[21]===f?e=t[22]:(e=e=>(0,qc.createPortal)((0,Z.jsx)(si,{type:`button`,variant:e.type===`accept`?`default`:`destructive`,size:`xs`,onClick:t=>{e.action(t.nativeEvent)},children:e.type===`accept`?f({id:`g3UF2V`}):f({id:`1t_NnN`})}),e.host,e.id),t[21]=f,t[22]=e),I=C.map(e),t[18]=f,t[19]=C,t[20]=I}else I=t[20];let L;t[23]!==M||t[24]!==o||t[25]!==P||t[26]!==d||t[27]!==u?(L=o&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 border-t shrink-0`,children:[(0,Z.jsx)(`span`,{className:`text-xs ${M?`text-emerald-600 dark:text-emerald-400`:`text-muted-foreground`}`,children:P}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[d&&(0,Z.jsx)(si,{className:`uppercase font-mono`,variant:`ghost`,size:`sm`,onClick:d,children:(0,Z.jsx)(s,{id:`XyOUTJ`})}),(0,Z.jsx)(si,{className:`uppercase font-mono`,variant:`outline`,size:`sm`,onClick:j,children:`Undo`}),u&&(0,Z.jsx)(si,{variant:`default`,size:`sm`,disabled:!M,onClick:k,children:(0,Z.jsx)(s,{id:`Lcehxn`})})]})]}),t[23]=M,t[24]=o,t[25]=P,t[26]=d,t[27]=u,t[28]=L):L=t[28];let R;return t[29]!==L||t[30]!==I?(R=(0,Z.jsxs)(`div`,{className:`flex flex-col h-full`,children:[F,I,L]}),t[29]=L,t[30]=I,t[31]=R):R=t[31],R}async function kO(e,t,n){try{let r={file:e,strategy:t};n!==void 0&&(r.content=n);let i=await fetch(`/api/sync/resolve-conflict`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(i.ok)return{ok:!0};let a;try{let e=await i.json();typeof e.detail==`string`?a=e.detail:typeof e.title==`string`&&(a=e.title)}catch{}return{ok:!1,detail:a}}catch(n){let r=n instanceof Error?n.message:String(n);return console.warn(JSON.stringify({event:`conflict-resolve-dispatch-failed`,file:e,strategy:t,detail:r})),{ok:!1,detail:r}}}async function AO(e,t){return kO(e,`content`,t)}async function jO(e){return kO(e,`mine`)}async function MO(e){return kO(e,`theirs`)}async function NO(e){return kO(e,`delete`)}async function PO(e){try{let t=await fetch(`/api/sync/conflict-content?file=${encodeURIComponent(e)}&source=ytext`);if(!t.ok){let n;try{let e=await t.json();typeof e.detail==`string`?n=e.detail:typeof e.title==`string`&&(n=e.title)}catch{}return console.warn(JSON.stringify({event:`conflict-content-fetch-failed`,file:e,status:t.status,detail:n})),null}let n=await t.json(),r=n.kind===`delete-modify`||n.kind===`modify-delete`||n.kind===`both-modified`?n.kind:`both-modified`;return n.kind!==r&&console.warn(JSON.stringify({event:`conflict-kind-missing-fallback`,file:e,receivedKind:n.kind??null})),{base:n.base??``,ours:n.ours??``,theirs:n.theirs??``,kind:r}}catch(t){return console.warn(JSON.stringify({event:`conflict-content-fetch-failed`,file:e,status:null,detail:t instanceof Error?t.message:String(t)})),null}}function FO(e){let t=(0,$.c)(84),{docName:n}=e,{_:r}=i(),{conflicts:a,loading:o}=Ni(),c;if(t[0]!==a||t[1]!==n){let e;t[3]===n?e=t[4]:(e=e=>Ho(e.file)===n,t[3]=n,t[4]=e),c=a.find(e),t[0]=a,t[1]=n,t[2]=c}else c=t[2];let l=c,u=l?.file??`${n}.md`,[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),_,v;t[5]===n?(_=t[6],v=t[7]):(_=()=>(console.warn(JSON.stringify({event:`editor-area-swap-to-diffview`,"doc.name":n})),()=>{console.warn(JSON.stringify({event:`editor-area-swap-from-diffview`,"doc.name":n}))}),v=[n],t[5]=n,t[6]=_,t[7]=v),(0,Q.useEffect)(_,v);let y=o||l===void 0,b,x;t[8]!==y||t[9]!==u?(b=()=>{if(y)return;let e=!1;return f(null),m(!1),PO(u).then(t=>{e||(t===null?m(!0):f(t))}),()=>{e=!0}},x=[u,y],t[8]=y,t[9]=u,t[10]=b,t[11]=x):(b=t[10],x=t[11]),(0,Q.useEffect)(b,x);let S;t[12]!==r||t[13]!==u?(S=async function(e){let t=await AO(u,e);t.ok||X.error(r({id:`K-h9cT`,values:{filePath:u}}),{description:t.detail})},t[12]=r,t[13]=u,t[14]=S):S=t[14];let C=S,w;t[15]!==r||t[16]!==u?(w=async function(e){g(!0);let t=await e(u);t.ok||(g(!1),X.error(r({id:`jPUPvG`,values:{filePath:u}}),{description:t.detail}))},t[15]=r,t[16]=u,t[17]=w):w=t[17];let T=w;if(p){let e;return t[18]===u?e=t[19]:(e=(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-sm text-muted-foreground`,children:(0,Z.jsx)(s,{id:`ajz9F8`,values:{filePath:u}})}),t[18]=u,t[19]=e),e}if(d===null){let e;return t[20]===u?e=t[21]:(e=(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-sm text-muted-foreground`,children:(0,Z.jsx)(s,{id:`DF1MtZ`,values:{filePath:u}})}),t[20]=u,t[21]=e),e}if(d.kind===`delete-modify`){let e;t[22]===d.theirs?e=t[23]:(e=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,Z.jsx)(OO,{oldContent:``,newContent:d.theirs,layout:`unified`,previewMode:!0})}),t[22]=d.theirs,t[23]=e);let n;t[24]===u?n=t[25]:(n={filePath:u},t[24]=u,t[25]=n);let r;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(r={0:(0,Z.jsx)(`span`,{className:`font-medium text-foreground`})},t[26]=r):r=t[26];let i;t[27]===n?i=t[28]:(i=(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Z.jsx)(s,{id:`V48OUT`,values:n,components:r})}),t[27]=n,t[28]=i);let a;t[29]===T?a=t[30]:(a=()=>void T(NO),t[29]=T,t[30]=a);let o;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(s,{id:`Vlc75q`}),t[31]=o):o=t[31];let c;t[32]!==h||t[33]!==a?(c=(0,Z.jsx)(si,{type:`button`,variant:`destructive`,disabled:h,onClick:a,children:o}),t[32]=h,t[33]=a,t[34]=c):c=t[34];let l;t[35]===T?l=t[36]:(l=()=>void T(MO),t[35]=T,t[36]=l);let f;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(s,{id:`3mFsc3`}),t[37]=f):f=t[37];let p;t[38]!==h||t[39]!==l?(p=(0,Z.jsx)(si,{type:`button`,variant:`default`,disabled:h,onClick:l,children:f}),t[38]=h,t[39]=l,t[40]=p):p=t[40];let m;t[41]!==c||t[42]!==p?(m=(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-3`,children:[c,p]}),t[41]=c,t[42]=p,t[43]=m):m=t[43];let g;t[44]!==i||t[45]!==m?(g=(0,Z.jsxs)(`div`,{className:`flex flex-shrink-0 flex-wrap items-center justify-between gap-x-6 gap-y-3 border-t px-6 py-4`,children:[i,m]}),t[44]=i,t[45]=m,t[46]=g):g=t[46];let _;return t[47]!==g||t[48]!==e?(_=(0,Z.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[e,g]}),t[47]=g,t[48]=e,t[49]=_):_=t[49],_}if(d.kind===`modify-delete`){let e;t[50]===d.ours?e=t[51]:(e=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,Z.jsx)(OO,{oldContent:``,newContent:d.ours,layout:`unified`,previewMode:!0})}),t[50]=d.ours,t[51]=e);let n;t[52]===u?n=t[53]:(n={filePath:u},t[52]=u,t[53]=n);let r;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(r={0:(0,Z.jsx)(`span`,{className:`font-medium text-foreground`})},t[54]=r):r=t[54];let i;t[55]===n?i=t[56]:(i=(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Z.jsx)(s,{id:`EhDLBx`,values:n,components:r})}),t[55]=n,t[56]=i);let a;t[57]===T?a=t[58]:(a=()=>void T(jO),t[57]=T,t[58]=a);let o;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(s,{id:`0NA4b3`}),t[59]=o):o=t[59];let c;t[60]!==h||t[61]!==a?(c=(0,Z.jsx)(si,{type:`button`,variant:`default`,disabled:h,onClick:a,children:o}),t[60]=h,t[61]=a,t[62]=c):c=t[62];let l;t[63]===T?l=t[64]:(l=()=>void T(NO),t[63]=T,t[64]=l);let f;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(s,{id:`qSxaOz`}),t[65]=f):f=t[65];let p;t[66]!==h||t[67]!==l?(p=(0,Z.jsx)(si,{type:`button`,variant:`destructive`,disabled:h,onClick:l,children:f}),t[66]=h,t[67]=l,t[68]=p):p=t[68];let m;t[69]!==c||t[70]!==p?(m=(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-3`,children:[c,p]}),t[69]=c,t[70]=p,t[71]=m):m=t[71];let g;t[72]!==i||t[73]!==m?(g=(0,Z.jsxs)(`div`,{className:`flex flex-shrink-0 flex-wrap items-center justify-between gap-x-6 gap-y-3 border-t px-6 py-4`,children:[i,m]}),t[72]=i,t[73]=m,t[74]=g):g=t[74];let _;return t[75]!==g||t[76]!==e?(_=(0,Z.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[e,g]}),t[75]=g,t[76]=e,t[77]=_):_=t[77],_}let E;t[78]===C?E=t[79]:(E=e=>void C(e),t[78]=C,t[79]=E);let D;return t[80]!==d.ours||t[81]!==d.theirs||t[82]!==E?(D=(0,Z.jsx)(OO,{oldContent:d.theirs,newContent:d.ours,layout:`unified`,conflictMode:!0,onResolve:E}),t[80]=d.ours,t[81]=d.theirs,t[82]=E,t[83]=D):D=t[83],D}function IO(e){let t=(0,$.c)(2),{docName:n,provider:r,children:i}=e;(0,Q.use)(Ft(n,r));let a;return t[0]===i?a=t[1]:(a=(0,Z.jsx)(Z.Fragment,{children:i}),t[0]=i,t[1]=a),a}var LO=`__back-nav__`;function RO(e){return e instanceof Re||e instanceof gt||e instanceof Ne||e instanceof Qe||e instanceof Ot||e instanceof me?e.docName:null}function zO(e){if(e instanceof Re){let t=e.docName;return{title:Ko._({id:`Jejur6`}),summary:Ko._({id:`jSY41h`,values:{docName:t}})}}if(e instanceof gt){let t=e.docName;return{title:Ko._({id:`V7QxyT`}),summary:Ko._({id:`xG4tb6`,values:{docName:t}})}}if(e instanceof Ne){let t=e.docName;return{title:Ko._({id:`1di5fu`}),summary:Ko._({id:`PQCdtv`,values:{docName:t}})}}if(e instanceof Qe){let t=e.docName;return{title:Ko._({id:`wvbc1r`}),summary:Ko._({id:`IX7-sq`,values:{docName:t}})}}if(e instanceof Ot)return{title:Ko._({id:`Gfr4fu`}),summary:Ko._({id:`j6LB7S`})};if(e instanceof me){let t=e.docName;return{title:Ko._({id:`vv7kpg`}),summary:Ko._({id:`mdKFEy`,values:{docName:t}})}}let t=e instanceof Error&&e.message?e.message:Ko._({id:`W5A0Ly`});return{title:Ko._({id:`29VNqC`}),summary:t}}function BO(e){let t=(0,$.c)(28),{error:n,resetErrorBoundary:r,activeDocName:i,previousDocName:a,onNavigateBack:o}=e,c;t[0]===n?c=t[1]:(c=zO(n),t[0]=n,t[1]=c);let{title:l,summary:u}=c,d=!!a&&!!o,f=(0,Q.useRef)(null),p,m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>{f.current?.focus()},m=[],t[2]=p,t[3]=m):(p=t[2],m=t[3]),(0,Q.useEffect)(p,m);let h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(Vx,{size:80,variant:`sleeping`}),t[4]=h):h=t[4];let g;t[5]===l?g=t[6]:(g=(0,Z.jsx)(`h2`,{id:`document-error-title`,className:`text-2xl font-light tracking-tighter text-balance`,children:l}),t[5]=l,t[6]=g);let _;t[7]===u?_=t[8]:(_=(0,Z.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:u}),t[7]=u,t[8]=_);let v;t[9]!==g||t[10]!==_?(v=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[g,_]}),t[9]=g,t[10]=_,t[11]=v):v=t[11];let y;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(s,{id:`KDw4GX`}),t[12]=y):y=t[12];let b;t[13]===r?b=t[14]:(b=(0,Z.jsx)(si,{ref:f,variant:`default`,onClick:r,children:y}),t[13]=r,t[14]=b);let x;t[15]!==i||t[16]!==d||t[17]!==n||t[18]!==o||t[19]!==a||t[20]!==r?(x=d?(0,Z.jsx)(si,{variant:`ghost`,className:`font-mono uppercase`,onClick:()=>{!a||!o||(st(RO(n)??i),o(a),r(LO))},children:(0,Z.jsx)(s,{id:`CKyk7Q`})}):null,t[15]=i,t[16]=d,t[17]=n,t[18]=o,t[19]=a,t[20]=r,t[21]=x):x=t[21];let S;t[22]!==x||t[23]!==b?(S=(0,Z.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[b,x]}),t[22]=x,t[23]=b,t[24]=S):S=t[24];let C;return t[25]!==S||t[26]!==v?(C=(0,Z.jsxs)(`div`,{role:`alert`,"aria-labelledby":`document-error-title`,"data-slot":`document-error-boundary`,className:`flex h-full flex-col items-center justify-center gap-8 p-8 text-center`,children:[h,v,S]}),t[25]=S,t[26]=v,t[27]=C):C=t[27],C}function VO(e){let t=(0,$.c)(17),{activeDocName:n,previousDocName:r,onNavigateBack:i,onRecycle:a,children:o}=e,s;t[0]!==n||t[1]!==i||t[2]!==r?(s=e=>(0,Z.jsx)(BO,{...e,activeDocName:n,previousDocName:r,onNavigateBack:i}),t[0]=n,t[1]=i,t[2]=r,t[3]=s):s=t[3];let c;t[4]===n?c=t[5]:(c=[n],t[4]=n,t[5]=c);let l;t[6]!==n||t[7]!==a?(l=e=>{if(e.reason===`imperative-api`){if(Array.isArray(e.args)&&e.args[0]===LO){console.warn(`[DocumentErrorBoundary] back-nav reset (no recycle)`);return}a(n),console.warn(`[DocumentErrorBoundary] retry recycled ${n}`)}else console.warn(`[DocumentErrorBoundary] reset by key change (${e.prev?.[0]} → ${e.next?.[0]})`)},t[6]=n,t[7]=a,t[8]=l):l=t[8];let u;t[9]===n?u=t[10]:(u=e=>{console.error(`[DocumentErrorBoundary] rendered fallback for ${n}: ${zO(e).title}`,e)},t[9]=n,t[10]=u);let d;return t[11]!==o||t[12]!==s||t[13]!==c||t[14]!==l||t[15]!==u?(d=(0,Z.jsx)(le,{fallbackRender:s,resetKeys:c,onReset:l,onError:u,children:o}),t[11]=o,t[12]=s,t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}function HO(e){let t=e.document.getText(`source`).toString(),{map:n,parseError:r}=Sr(t);return{map:n,keys:On(t),parseError:r}}function UO(e){let t=(0,$.c)(21),{provider:n}=e,r;t[0]===n?r=t[1]:(r=()=>HO(n),t[0]=n,t[1]=r);let[i,a]=(0,Q.useState)(r),o,s;t[2]===n?(o=t[3],s=t[4]):(o=()=>{let e=jn(n);a(e.current());let t=e.subscribe(e=>{a(e)});return()=>{t(),e.dispose()}},s=[n],t[2]=n,t[3]=o,t[4]=s),(0,Q.useEffect)(o,s);let c;t[5]===i.map.icon?c=t[6]:(c=Xe(i.map.icon),t[5]=i.map.icon,t[6]=c);let l=c,u;t[7]===i.map.cover?u=t[8]:(u=ut(i.map.cover),t[7]=i.map.cover,t[8]=u);let d=u,f=d.kind===`url`||d.kind===`path`,p=l.kind!==`unsupported`;if(!f&&!p)return null;let m=f?`true`:`false`,h=p?`true`:`false`,g;t[9]!==d||t[10]!==f?(g=f?(0,Z.jsx)(WO,{cover:d}):null,t[9]=d,t[10]=f,t[11]=g):g=t[11];let _;t[12]!==f||t[13]!==p||t[14]!==l?(_=p?(0,Z.jsx)(GO,{icon:l,hasCover:f}):null,t[12]=f,t[13]=p,t[14]=l,t[15]=_):_=t[15];let v;return t[16]!==m||t[17]!==h||t[18]!==g||t[19]!==_?(v=(0,Z.jsxs)(`div`,{className:`page-header editor-content-aligned`,"data-has-cover":m,"data-has-icon":h,"aria-hidden":`true`,"data-testid":`page-header`,children:[g,_]}),t[16]=m,t[17]=h,t[18]=g,t[19]=_,t[20]=v):v=t[20],v}function WO(e){let t=(0,$.c)(2),{cover:n}=e,r;return t[0]===n.value?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`page-header-cover`,"data-testid":`page-header-cover`,children:(0,Z.jsx)(`img`,{src:n.value,alt:``,draggable:!1,loading:`lazy`,referrerPolicy:`no-referrer`,className:`page-header-cover-img`})}),t[0]=n.value,t[1]=r),r}function GO(e){let t=(0,$.c)(9),{icon:n,hasCover:r}=e,i=r?`page-header-icon page-header-icon--with-cover`:`page-header-icon`;if(n.kind===`emoji`){let e;return t[0]!==n.value||t[1]!==i?(e=(0,Z.jsx)(`span`,{className:i,"data-testid":`page-header-icon`,"data-kind":`emoji`,children:n.value}),t[0]=n.value,t[1]=i,t[2]=e):e=t[2],e}let a;t[3]===n.value?a=t[4]:(a=(0,Z.jsx)(`img`,{src:n.value,alt:``,draggable:!1,referrerPolicy:`no-referrer`,className:`page-header-icon-img`}),t[3]=n.value,t[4]=a);let o;return t[5]!==n.kind||t[6]!==i||t[7]!==a?(o=(0,Z.jsx)(`span`,{className:i,"data-testid":`page-header-icon`,"data-kind":n.kind,children:a}),t[5]=n.kind,t[6]=i,t[7]=a,t[8]=o):o=t[8],o}function KO(e){let t=e.document.getText(`source`).toString(),{map:n,parseError:r}=Sr(t);return{map:n,keys:On(t),parseError:r}}function qO(e){let t=(0,$.c)(127),{provider:n}=e,{_:r}=i(),[a,o]=(0,Q.useState)(null),c;t[0]===n?c=t[1]:(c=()=>KO(n),t[0]=n,t[1]=c);let[l,u]=(0,Q.useState)(c),d,f;t[2]===n?(d=t[3],f=t[4]):(d=()=>{let e=jn(n);o(e),u(e.current());let t=e.subscribe(e=>{u(e)});return()=>{t(),e.dispose(),o(t=>t===e?null:t)}},f=[n],t[2]=n,t[3]=d,t[4]=f),(0,Q.useEffect)(d,f);let p=l.map,m=l.keys,h=l.parseError,[g,_]=(0,Q.useState)(!1),v;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v={},t[5]=v):v=t[5];let[y,b]=(0,Q.useState)(v),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(null),T;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(T={},t[6]=T):T=t[6];let[E,D]=(0,Q.useState)(T),O;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(O={},t[7]=O):O=t[7];let[k,A]=(0,Q.useState)(O),j=n.configuration.name??``,N;t[8]!==r||t[9]!==a?(N=function(e){if(!a)return{ok:!1,error:r({id:`9zb2WA`})};let t=a.patch(e);if(t.ok)return{ok:!0};if(t.error.code===`WRITE_ERROR`)return console.warn(`[PropertyPanel] binding write error:`,t.error.detail),{ok:!1,error:t.error.detail};let n=yr(t.error);return{ok:!1,error:t.error.issues[0]?.message??r({id:`8fRyLo`}),fieldErrors:Object.keys(n).length>0?n:void 0}},t[8]=r,t[9]=a,t[10]=N):N=t[10];let P=N,F;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(F=function(e){D(t=>{if(!Object.hasOwn(t,e))return t;let n={...t};return delete n[e],n})},t[11]=F):F=t[11];let I=F,L;t[12]===r?L=t[13]:(L=function(e,t){if(e.ok)return;let n=e.error??r({id:`4g19V6`}),i=e.fieldErrors??{};D(e=>{let r={...e};for(let e of t)r[e]=i[e]??n;return r}),A(e=>{let n={...e};for(let e of t)n[e]=(n[e]??0)+1;return n})},t[12]=r,t[13]=L);let R=L,z;t[14]!==P||t[15]!==R?(z=function(e,t){I(e),R(P({[e]:t}),[e])},t[14]=P,t[15]=R,t[16]=z):z=t[16];let B=z,V;t[17]!==P||t[18]!==R?(V=function(e){I(e),R(P({[e]:null}),[e])},t[17]=P,t[18]=R,t[19]=V):V=t[19];let H=V,U;t[20]!==r||t[21]!==a?(U=function(e,t){if(!a)return{ok:!1,error:r({id:`9zb2WA`})};if(e===t)return{ok:!0};let n=a.rename(e,t);if(n.ok)return{ok:!0};if(n.error.code===`WRITE_ERROR`)return{ok:!1,error:n.error.detail};let i=yr(n.error);return{ok:!1,error:n.error.issues[0]?.message??r({id:`I1gRhX`}),fieldErrors:Object.keys(i).length>0?i:void 0}},t[20]=r,t[21]=a,t[22]=U):U=t[22];let W=U,G;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(G=function(e,t){return`${e} ${t}`},t[23]=G):G=t[23];let K=G,q;t[24]!==a||t[25]!==m?(q=function(e){if(!a)return;let t=String(e.active.id),n=e.over?String(e.over.id):null;if(!n||t===n)return;let r=m.map((e,t)=>K(e,t)),i=r.indexOf(t),o=r.indexOf(n);if(i<0||o<0)return;let s=m.slice(),[c]=s.splice(i,1);if(!c)return;s.splice(o,0,c);let l=a.reorder(s);l.ok||console.warn(`[PropertyPanel] reorder failed:`,l.error)},t[24]=a,t[25]=m,t[26]=q):q=t[26];let J=q,Y;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(Y={activationConstraint:{distance:4}},t[27]=Y):Y=t[27];let ee;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(ee={coordinateGetter:ha},t[28]=ee):ee=t[28];let te=Ci(ra(_a,Y),ra(ya,ee)),ne;t[29]!==B||t[30]!==p?(ne=function(e,t){let n=p[e];if(n===void 0)return;b(n=>({...n,[e]:t}));let r=aa(n,t);(!Object.hasOwn(p,e)||!Cr(n,r))&&B(e,r)},t[29]=B,t[30]=p,t[31]=ne):ne=t[31];let re=ne,ie;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(ie=function(){S({name:``,type:`text`,value:``,error:null}),_(!1)},t[32]=ie):ie=t[32];let ae=ie,{addPropertySignal:oe,clearAddProperty:se}=GS(),ce;t[33]!==oe||t[34]!==j?(ce=oe.get(j)??0,t[33]=oe,t[34]=j,t[35]=ce):ce=t[35];let le=ce,ue,de;t[36]===le?(ue=t[37],de=t[38]):(ue=()=>{le>0&&(S({name:``,type:`text`,value:``,error:null}),_(!1))},de=[le],t[36]=le,t[37]=ue,t[38]=de),(0,Q.useEffect)(ue,de);let fe,pe;t[39]!==se||t[40]!==j?(fe=()=>()=>se(j),pe=[j,se],t[39]=se,t[40]=j,t[41]=fe,t[42]=pe):(fe=t[41],pe=t[42]),(0,Q.useEffect)(fe,pe);let me;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(me=function(e){S(t=>{if(!t)return t;let n=e===`date`?new Date().toISOString().slice(0,10):qi[e];return{...t,type:e,value:n,error:null}})},t[43]=me):me=t[43];let he=me,ge;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(ge=function(e){S(t=>t&&{...t,value:e})},t[44]=ge):ge=t[44];let _e=ge,ve;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(ve=function(e){S(t=>t&&{...t,name:e,error:null})},t[45]=ve):ve=t[45];let ye=ve,be;t[46]!==r||t[47]!==x||t[48]!==P||t[49]!==p?(be=function(){if(!x)return;let e=x.name.trim();if(!e){S({...x,error:r({id:`8_brI5`})});return}if(e===`frontmatter`){S({...x,error:r({id:`dURmlQ`})});return}if(Object.hasOwn(p,e)){S({...x,error:r({id:`njU86j`,values:{trimmed:e}})});return}let t=P({[e]:x.value});if(t.ok){S(null);return}let n=t.fieldErrors?.[e],i=t.error??r({id:`OJeiSH`});S({...x,error:n??i})},t[46]=r,t[47]=x,t[48]=P,t[49]=p,t[50]=be):be=t[50];let xe=be,Se;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(Se=function(){S(null)},t[51]=Se):Se=t[51];let Ce=Se,we;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(we=function(e){w({key:e,draft:e,error:null})},t[52]=we):we=t[52];let Te=we,Ee;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=function(e){w(t=>t&&{...t,draft:e,error:null})},t[53]=Ee):Ee=t[53];let De=Ee,Oe;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=function(){w(null)},t[54]=Oe):Oe=t[54];let ke=Oe,Ae;t[55]!==r||t[56]!==p||t[57]!==W||t[58]!==C?(Ae=function(){if(!C)return;let e=C.draft.trim();if(!e){w(null);return}if(e===C.key){w(null);return}if(e===`frontmatter`){w({...C,error:r({id:`dURmlQ`})});return}if(Object.hasOwn(p,e)){w({...C,error:r({id:`njU86j`,values:{trimmed:e}})});return}let t=W(C.key,e);if(t.ok){b(t=>{if(!Object.hasOwn(t,C.key))return t;let n={...t};return n[e]=n[C.key],delete n[C.key],n}),I(C.key),w(null);return}let n=t.fieldErrors?.[e]??t.fieldErrors?.[C.key]??t.error??r({id:`2ryd91`});w({...C,error:n})},t[55]=r,t[56]=p,t[57]=W,t[58]=C,t[59]=Ae):Ae=t[59];let je=Ae,Me;t[60]!==p||t[61]!==m?(Me=m.length>0?m:Object.keys(p),t[60]=p,t[61]=m,t[62]=Me):Me=t[62];let Ne=Me,Pe;if(t[63]!==Ne){Pe=new Map;for(let e of Ne)Pe.set(e,(Pe.get(e)??0)+1);t[63]=Ne,t[64]=Pe}else Pe=t[64];if(Ne.length===0&&!x&&!h)return null;let Fe=!g,Ie;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=e=>_(!e),t[65]=Ie):Ie=t[65];let Le=!g,Re;t[66]===Le?Re=t[67]:(Re=(0,Z.jsx)(jo,{"data-expanded":Le,className:`size-3.5 shrink-0 text-muted-foreground transition-transform duration-150 ease-out data-[expanded=true]:rotate-90`}),t[66]=Le,t[67]=Re);let ze;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(ze=(0,Z.jsx)(`span`,{children:(0,Z.jsx)(s,{id:`l_UFPv`})}),t[68]=ze):ze=t[68];let Be;t[69]===Re?Be=t[70]:(Be=(0,Z.jsx)(Mo,{asChild:!0,children:(0,Z.jsxs)(si,{type:`button`,variant:`ghost`,className:`mb-1.5 flex h-auto w-fit bg-transparent! items-center gap-1 px-1 py-0.5 text-base font-medium text-foreground hover:bg-transparent hover:text-foreground`,children:[Re,ze]})}),t[69]=Re,t[70]=Be);let Ve;t[71]===h?Ve=t[72]:(Ve=h?(0,Z.jsxs)(`div`,{role:`alert`,"data-testid":`property-panel-yaml-error`,className:`mb-1 flex items-start gap-1.5 rounded border border-destructive/30 bg-destructive/5 px-2 py-1.5 text-[11px] text-destructive`,children:[(0,Z.jsx)(ds,{className:`size-3.5 shrink-0 mt-0.5`}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(s,{id:`zaXlhf`}),(0,Z.jsx)(`span`,{className:`block text-[10px] opacity-80`,children:h})]})]}):null,t[71]=h,t[72]=Ve);let He;if(t[73]!==Ne){let e;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(e=(e,t)=>K(e,t),t[75]=e):e=t[75],He=Ne.map(e),t[73]=Ne,t[74]=He}else He=t[74];let Ue;if(t[76]!==B||t[77]!==je||t[78]!==Pe||t[79]!==E||t[80]!==p||t[81]!==y||t[82]!==H||t[83]!==C||t[84]!==Ne||t[85]!==k||t[86]!==re){let e;t[88]!==B||t[89]!==je||t[90]!==Pe||t[91]!==E||t[92]!==p||t[93]!==y||t[94]!==H||t[95]!==C||t[96]!==k||t[97]!==re?(e=(e,t)=>{let n=p[e];if(n===void 0)return null;let r=y[e]??An(n),i=C?.key===e?C:null,a=(Pe.get(e)??0)>1;return(0,Z.jsx)(Fi,{sortableId:K(e,t),keyName:e,value:n,declared:r,error:E[e]??null,resetCounter:k[e]??0,isDuplicate:a,rename:{state:i,onBegin:()=>Te(e),onChangeDraft:De,onCommit:je,onCancel:ke},onCommit:t=>B(e,t),onChangeType:t=>re(e,t),onRemove:()=>H(e)},`${e}-${t}`)},t[88]=B,t[89]=je,t[90]=Pe,t[91]=E,t[92]=p,t[93]=y,t[94]=H,t[95]=C,t[96]=k,t[97]=re,t[98]=e):e=t[98],Ue=Ne.map(e),t[76]=B,t[77]=je,t[78]=Pe,t[79]=E,t[80]=p,t[81]=y,t[82]=H,t[83]=C,t[84]=Ne,t[85]=k,t[86]=re,t[87]=Ue}else Ue=t[87];let We;t[99]!==He||t[100]!==Ue?(We=(0,Z.jsx)(pa,{items:He,strategy:Gi,children:Ue}),t[99]=He,t[100]=Ue,t[101]=We):We=t[101];let Ge;t[102]!==J||t[103]!==te||t[104]!==We?(Ge=(0,Z.jsx)(Ya,{sensors:te,collisionDetection:xa,onDragEnd:J,children:We}),t[102]=J,t[103]=te,t[104]=We,t[105]=Ge):Ge=t[105];let Ke;t[106]!==B||t[107]!==E||t[108]!==p||t[109]!==k?(Ke=Object.hasOwn(p,`tags`)?null:(0,Z.jsx)(Fi,{keyName:`tags`,value:[],declared:`list`,error:E.tags??null,resetCounter:k.tags??0,isPlaceholder:!0,onCommit:e=>B(`tags`,e),onChangeType:JO},`virtual-tags`),t[106]=B,t[107]=E,t[108]=p,t[109]=k,t[110]=Ke):Ke=t[110];let qe;t[111]!==r||t[112]!==x||t[113]!==xe?(qe=x?(0,Z.jsx)(ta,{draft:x,onChangeName:ye,onChangeType:he,onChangeValue:_e,onCommit:xe,onCancel:Ce}):(0,Z.jsxs)(`div`,{className:`mt-1 flex items-center gap-1`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-7 w-4 shrink-0`}),(0,Z.jsxs)(si,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`add-property-trigger`,onClick:ae,"aria-label":r({id:`F-NRCj`}),className:`flex items-center gap-1.5 rounded px-2 py-1 font-medium text-sm hover:bg-muted/50 hover:text-foreground`,children:[(0,Z.jsx)(M,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:(0,Z.jsx)(s,{id:`m16xKo`})})]})]}),t[111]=r,t[112]=x,t[113]=xe,t[114]=qe):qe=t[114];let Je;t[115]!==Ve||t[116]!==Ge||t[117]!==Ke||t[118]!==qe?(Je=(0,Z.jsxs)(Ao,{className:`overflow-hidden data-[state=open]:animate-[collapsible-down_150ms_ease-out] data-[state=closed]:animate-[collapsible-up_150ms_ease-in]`,children:[Ve,Ge,Ke,qe]}),t[115]=Ve,t[116]=Ge,t[117]=Ke,t[118]=qe,t[119]=Je):Je=t[119];let Ye;t[120]!==Fe||t[121]!==Be||t[122]!==Je?(Ye=(0,Z.jsx)(`div`,{className:`property-panel editor-content-aligned pt-4 pb-4 text-sm`,"data-testid":`property-panel`,children:(0,Z.jsxs)(No,{open:Fe,onOpenChange:Ie,children:[Be,Je]})}),t[120]=Fe,t[121]=Be,t[122]=Je,t[123]=Ye):Ye=t[123];let Xe;return t[124]!==a||t[125]!==Ye?(Xe=(0,Z.jsx)(Di,{binding:a,children:Ye}),t[124]=a,t[125]=Ye,t[126]=Xe):Xe=t[126],Xe}function JO(){}var YO=v(`LARGE_DOC_CHAR_THRESHOLD`,5e5);function XO(e){let t=e.threshold??YO;return e.ytextLength>t?{renderSource:e.isSourceMode||e.visitedSource,renderVisual:!e.isSourceMode||e.visitedVisual,isLarge:!0}:{renderSource:!0,renderVisual:!0,isLarge:!1}}function ZO(e){return e.hasEmittedFirstToggle||!e.isLarge?!1:e.renderSource&&e.renderVisual}var QO=v(`ACTIVITY_MOUNT_LIMIT`,3);function $O(){return n(()=>import(`./SourceEditor-CPuDd_gu.js`),__vite__mapDeps([56,1,37,2,38,39,23,40,41,42,43,44,45,46,47,14,6,8,9,22,3,24,4,12,10,11,48,49,57,26,55]),import.meta.url)}var ek=(0,Q.lazy)(async()=>({default:(await $O()).SourceEditor}));function tk(e,t,n){if(n<=0)return[];let r=e.filter(e=>!Ge(e.docName)),i=[...r].sort((e,t)=>t.lastAccessedAt-e.lastAccessedAt).slice(0,n);if(t===null||i.some(e=>e.docName===t))return i;let a=r.find(e=>e.docName===t);return a?[...i.slice(0,n-1),a]:i}function nk(e,t){return t.kind===`idle`?null:t.kind===`failed`&&t.failedDocNames.includes(e)?{kind:`failed`,title:Ko._({id:`MTs6g3`}),summary:t.reason===`clear-data-timeout`?Ko._({id:`Sc1bKE`,values:{docName:e}}):Ko._({id:`ovIGrT`,values:{docName:e}}),actionLabel:Ko._({id:`HpK_8d`})}:t.kind===`recovering`&&t.docNames.includes(e)?{kind:`recovering`,title:Ko._({id:`cF9DyA`}),summary:t.phase===`clearing-local-cache`?Ko._({id:`bmC18N`,values:{docName:e}}):Ko._({id:`pAgkuZ`,values:{docName:e}})}:null}function rk(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(Wt,{name:`activity-pool`,children:(0,Z.jsx)(ik,{...e})}),t[0]=e,t[1]=n),n}function ik(e){let t=(0,$.c)(15),{activeDocName:n,isSourceMode:r,editorPlaceholder:i,previousDocName:a,onNavigateBack:o,onRecycle:s}=e,{poolEntries:c,serverRestartRecovery:l}=pt(),{pages:u,loading:d}=es(),f=tk(c,n,QO),p=(0,Q.useRef)(``),h=f.map(ak).join(`,`),g=(0,Q.useRef)(c),_,v;t[0]===c?(_=t[1],v=t[2]):(_=()=>{g.current=c},v=[c],t[0]=c,t[1]=_,t[2]=v),(0,Q.useLayoutEffect)(_,v),(0,Q.useLayoutEffect)(()=>{if(p.current===h)return;let e=p.current?p.current.split(`,`):[],t=h?h.split(`,`):[],r=e.filter(e=>!t.includes(e)),i=t.filter(t=>!e.includes(t));for(let e of r)m(e);for(let e of i){let t=g.current.find(t=>t.docName===e)?.poolEventId;W(e,t&&t.length>0?t:crypto.randomUUID())}ue(`ok/activity/mount-list-change`,{active:n,mounted:t,evicted:r}),p.current=h,Ut(t)},[h,n]);let y;t[3]!==n||t[4]!==i||t[5]!==r||t[6]!==d||t[7]!==o||t[8]!==s||t[9]!==u||t[10]!==a||t[11]!==l?(y=e=>(0,Z.jsx)(dk,{entry:e,isActive:e.docName===n,isSourceMode:r,editorPlaceholder:i,isNewDoc:!d&&!u.has(e.docName),previousDocName:a,onNavigateBack:o,onRecycle:s,serverRestartRecovery:l},e.docName),t[3]=n,t[4]=i,t[5]=r,t[6]=d,t[7]=o,t[8]=s,t[9]=u,t[10]=a,t[11]=l,t[12]=y):y=t[12];let b=f.map(y),x;return t[13]===b?x=t[14]:(x=(0,Z.jsx)(Z.Fragment,{children:b}),t[13]=b,t[14]=x),x}function ak(e){return e.docName}function ok(e){let t=(0,$.c)(8),{isActive:n,initialScrollTop:r,children:i}=e,a=(0,Q.useRef)(null),o=(0,Q.useRef)(r??0),s,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=a.current;if(!e)return;let t=()=>{e.scrollTop>0&&(o.current=e.scrollTop)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},c=[],t[0]=s,t[1]=c):(s=t[0],c=t[1]),(0,Q.useEffect)(s,c);let l,u;t[2]===n?(l=t[3],u=t[4]):(l=()=>{if(!n)return;let e=a.current;if(!e)return;let t=o.current;if(t===0)return;let r=performance.now(),i=!1;e.scrollTop=t,e.scrollTop===t&&e.scrollHeight>t&&ue(`ok/scroll-restore/phase1-success`,{target:t,elapsedMs:performance.now()-r});let s=!1,c=0,l=()=>{s||(s=!0,cancelAnimationFrame(c),clearTimeout(f),e.removeEventListener(`wheel`,u),e.removeEventListener(`touchstart`,u))},u=()=>l();e.addEventListener(`wheel`,u,{passive:!0}),e.addEventListener(`touchstart`,u,{passive:!0});let d=()=>{s||(e.scrollTop!==t&&e.scrollHeight>t&&(e.scrollTop=t,e.scrollTop===t&&!i&&(ue(`ok/scroll-restore/phase2-success`,{target:t,elapsedMs:performance.now()-r}),i=!0)),c=requestAnimationFrame(d))};c=requestAnimationFrame(d);let f=setTimeout(()=>{s||(e.scrollTop!==t&&e.scrollHeight>t&&ue(`ok/scroll-restore/abandoned`,{target:t,elapsedMs:performance.now()-r,scrollHeight:e.scrollHeight,finalScrollTop:e.scrollTop}),l())},2e3);return l},u=[n],t[2]=n,t[3]=l,t[4]=u),(0,Q.useLayoutEffect)(l,u);let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d={overflowAnchor:`auto`},t[5]=d):d=t[5];let f;return t[6]===i?f=t[7]:(f=(0,Z.jsx)(`div`,{ref:a,"data-testid":`editor-scroll-container`,className:`subtle-scrollbar h-full overflow-y-auto pt-14 scroll-pt-14`,style:d,children:i}),t[6]=i,t[7]=f),f}function sk(e){let t=(0,$.c)(12),{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a}=e,o=r&&i,[s,c]=(0,Q.useState)(o),l,u;if(t[0]===o?(l=t[1],u=t[2]):(l=()=>{o&&c(!0)},u=[o],t[0]=o,t[1]=l,t[2]=u),(0,Q.useEffect)(l,u),!s&&!o)return null;let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(tx,{}),t[3]=d):d=t[3];let f=n.docName,p;t[4]===n.provider.document?p=t[5]:(p=n.provider.document.getText(`source`),t[4]=n.provider.document,t[5]=p);let m;return t[6]!==a||t[7]!==n.docName||t[8]!==n.provider||t[9]!==o||t[10]!==p?(m=(0,Z.jsx)(Q.Suspense,{fallback:d,children:(0,Z.jsx)(ek,{docName:f,ytext:p,provider:n.provider,placeholder:a,isSourceModeActive:o})}),t[6]=a,t[7]=n.docName,t[8]=n.provider,t[9]=o,t[10]=p,t[11]=m):m=t[11],m}function ck(e){let t=(0,$.c)(18),{view:n}=e,r=n.kind===`failed`,i=r?`alert`:`status`,a=!r,o;t[0]===r?o=t[1]:(o=(0,Z.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-full border bg-muted text-muted-foreground`,children:r?(0,Z.jsx)(no,{className:`size-5`,"aria-hidden":`true`}):(0,Z.jsx)(Yt,{className:`size-5 animate-spin`,"aria-hidden":`true`})}),t[0]=r,t[1]=o);let s;t[2]===n.title?s=t[3]:(s=(0,Z.jsx)(`h2`,{className:`text-lg font-medium`,children:n.title}),t[2]=n.title,t[3]=s);let c;t[4]===n.summary?c=t[5]:(c=(0,Z.jsx)(`p`,{className:`max-w-md text-sm text-muted-foreground`,children:n.summary}),t[4]=n.summary,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]!==r||t[10]!==n.actionLabel?(u=r?(0,Z.jsxs)(si,{type:`button`,onClick:lk,children:[(0,Z.jsx)(no,{className:`size-4`,"aria-hidden":`true`}),n.actionLabel]}):null,t[9]=r,t[10]=n.actionLabel,t[11]=u):u=t[11];let d;return t[12]!==i||t[13]!==a||t[14]!==o||t[15]!==l||t[16]!==u?(d=(0,Z.jsxs)(`div`,{"data-slot":`server-restart-recovery`,role:i,"aria-busy":a,className:`flex h-full flex-col items-center justify-center gap-6 p-8 text-center`,children:[o,l,u]}),t[12]=i,t[13]=a,t[14]=o,t[15]=l,t[16]=u,t[17]=d):d=t[17],d}function lk(){return window.location.reload()}function uk(e){let t=(0,$.c)(2),{html:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`tiptap-editor h-full pointer-events-none`,"aria-hidden":`true`,children:(0,Z.jsx)(`div`,{className:`tiptap ProseMirror tiptap-editor-portal-content`,dangerouslySetInnerHTML:{__html:n}})}),t[0]=n,t[1]=r),r}function dk(e){let t=(0,$.c)(53),{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a,isNewDoc:o,previousDocName:s,onNavigateBack:c,onRecycle:l,serverRestartRecovery:u}=e,d;t[0]!==n.docName||t[1]!==u?(d=nk(n.docName,u),t[0]=n.docName,t[1]=u,t[2]=d):d=t[2];let f=d,p=jC(n.docName)===`conflict`,m;t[3]===n.docName?m=t[4]:(m=()=>{let e=document.createElement(`div`);return e.setAttribute(`data-ok-editor-portal`,n.docName),e.style.display=`contents`,e},t[3]=n.docName,t[4]=m);let[h]=(0,Q.useState)(m),g=n.provider.document.getText(`source`).length,[_,v]=(0,Q.useState)(i),[b,x]=(0,Q.useState)(!i),S,C;t[5]!==i||t[6]!==_||t[7]!==b?(S=()=>{i&&!_?v(!0):!i&&!b&&x(!0)},C=[i,_,b],t[5]=i,t[6]=_,t[7]=b,t[8]=S,t[9]=C):(S=t[8],C=t[9]),(0,Q.useEffect)(S,C);let w=XO({ytextLength:g,isSourceMode:i,visitedSource:_,visitedVisual:b}),T=(0,Q.useRef)(``),E=`${w.isLarge}-${w.renderSource}-${w.renderVisual}`,D,O;t[10]!==n.docName||t[11]!==w.isLarge||t[12]!==w.renderSource||t[13]!==w.renderVisual||t[14]!==E||t[15]!==i||t[16]!==g?(D=()=>{T.current!==E&&(T.current=E,w.isLarge&&ue(`ok/activity/defer-mount`,{docName:n.docName,ytextLength:g,isSourceMode:i,renderSource:w.renderSource,renderVisual:w.renderVisual}))},O=[E,w.isLarge,w.renderSource,w.renderVisual,n.docName,g,i],t[10]=n.docName,t[11]=w.isLarge,t[12]=w.renderSource,t[13]=w.renderVisual,t[14]=E,t[15]=i,t[16]=g,t[17]=D,t[18]=O):(D=t[17],O=t[18]),(0,Q.useEffect)(D,O);let k;t[19]===n.docName?k=t[20]:(k=()=>y(n.docName),t[19]=n.docName,t[20]=k);let[A]=(0,Q.useState)(k),j=A?.html??null,[M,N]=(0,Q.useState)(!1),P,F;t[21]!==n.docName||t[22]!==w.isLarge||t[23]!==w.renderSource||t[24]!==w.renderVisual||t[25]!==M||t[26]!==i||t[27]!==g?(P=()=>{ZO({isLarge:w.isLarge,renderSource:w.renderSource,renderVisual:w.renderVisual,hasEmittedFirstToggle:M})&&(ue(`ok/cold/first-toggle`,{docName:n.docName,mountId:rt(n.docName),ytextLength:g,modeEnteredFirst:i?`source`:`visual`}),N(!0))},F=[M,w.isLarge,w.renderSource,w.renderVisual,n.docName,g,i],t[21]=n.docName,t[22]=w.isLarge,t[23]=w.renderSource,t[24]=w.renderVisual,t[25]=M,t[26]=i,t[27]=g,t[28]=P,t[29]=F):(P=t[28],F=t[29]),(0,Q.useEffect)(P,F);let I=r?`visible`:`hidden`,L=`editor:${n.docName}`,R=A?.scrollTop,z;t[30]!==a||t[31]!==n||t[32]!==w.renderSource||t[33]!==w.renderVisual||t[34]!==r||t[35]!==p||t[36]!==o||t[37]!==i||t[38]!==c||t[39]!==l||t[40]!==h||t[41]!==s||t[42]!==f||t[43]!==j?(z=f?(0,Z.jsx)(ck,{view:f}):(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(VO,{activeDocName:n.docName,previousDocName:s,onNavigateBack:c,onRecycle:l,children:(0,Z.jsx)(Q.Suspense,{fallback:j?(0,Z.jsx)(uk,{html:j}):(0,Z.jsx)(tx,{}),children:(0,Z.jsx)(IO,{docName:n.docName,provider:n.provider,children:p?(0,Z.jsx)(FO,{docName:n.docName,provider:n.provider}):(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[!i&&(0,Z.jsx)(UO,{provider:n.provider}),!i&&(0,Z.jsx)(qO,{provider:n.provider}),(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[w.renderSource?(0,Z.jsx)(`div`,{className:i?`h-full`:`ok-mode-hidden h-full`,children:(0,Z.jsx)(sk,{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a})}):null,w.renderVisual?(0,Z.jsx)(`div`,{className:i?`ok-mode-hidden h-full`:`h-full`,children:(0,Z.jsx)(NE,{provider:n.provider,placeholder:a,isSourceMode:i,portalTarget:h},`${n.docName}-${String(o)}-${n.poolEventId}`)}):null]})]})})})})}),t[30]=a,t[31]=n,t[32]=w.renderSource,t[33]=w.renderVisual,t[34]=r,t[35]=p,t[36]=o,t[37]=i,t[38]=c,t[39]=l,t[40]=h,t[41]=s,t[42]=f,t[43]=j,t[44]=z):z=t[44];let B;t[45]!==r||t[46]!==R||t[47]!==z?(B=(0,Z.jsx)(ok,{isActive:r,initialScrollTop:R,children:z}),t[45]=r,t[46]=R,t[47]=z,t[48]=B):B=t[48];let V;return t[49]!==I||t[50]!==L||t[51]!==B?(V=(0,Z.jsx)(Q.Activity,{mode:I,name:L,children:B}),t[49]=I,t[50]=L,t[51]=B,t[52]=V):V=t[52],V}function fk(e){let t=e.endsWith(`rem`)?`rem`:`px`;return{value:Number.parseFloat(e),unit:t}}function pk(e){let{value:t,unit:n}=fk(e);return n===`rem`?t*16:t}function mk(e,t){return`${t===`rem`?e.toFixed(1):Math.round(e)}${t}`}var hk=3600*24*7;function gk(e){let t=(0,$.c)(28),{direction:n,currentWidth:r,onResize:i,onToggle:a,isCollapsed:o,minResizeWidth:s,maxResizeWidth:c,enableToggle:l,enableAutoCollapse:u,autoCollapseThreshold:d,expandThreshold:f,enableDrag:p,setIsDraggingRail:m,widthCookieName:h,widthCookieMaxAge:g,isNested:_}=e,v=n===void 0?`right`:n,y=o===void 0?!1:o,b=s===void 0?`14rem`:s,x=c===void 0?`24rem`:c,S=l===void 0?!0:l,C=u===void 0?!0:u,w=d===void 0?1.5:d,T=f===void 0?.2:f,E=p===void 0?!0:p,D=m===void 0?_k:m,O=g===void 0?hk:g,k=_===void 0?!1:_,A=(0,Q.useRef)(null),j=(0,Q.useRef)(0),M=(0,Q.useRef)(0),N=(0,Q.useRef)(!1),P=(0,Q.useRef)(!1),F=(0,Q.useRef)(null),I=(0,Q.useRef)(0),L=(0,Q.useRef)(!1),R=(0,Q.useRef)(0),z=(0,Q.useRef)(0),B=(0,Q.useRef)(null),V=(0,Q.useRef)(r),H=(0,Q.useRef)(y),U,W;t[0]===r?(U=t[1],W=t[2]):(U=()=>{V.current=r},W=[r],t[0]=r,t[1]=U,t[2]=W),(0,Q.useEffect)(U,W);let G,K;t[3]===y?(G=t[4],K=t[5]):(G=()=>{H.current=y},K=[y],t[3]=y,t[4]=G,t[5]=K),(0,Q.useEffect)(G,K);let q=pk(b),J;t[6]===x?J=t[7]:(J=pk(x),t[6]=x,t[7]=J);let Y=J,ee;t[8]!==E||t[9]!==k?(ee=function(e){E&&(P.current=!0,j.current=H.current?0:pk(V.current),M.current=e.clientX,I.current=e.clientX,F.current=null,L.current=!1,R.current=0,z.current=0,B.current=k&&A.current?A.current.getBoundingClientRect():null,e.preventDefault())},t[8]=E,t[9]=k,t[10]=ee):ee=t[10];let te=ee,ne,re;t[11]!==w||t[12]!==v||t[13]!==C||t[14]!==S||t[15]!==T||t[16]!==k||t[17]!==Y||t[18]!==q||t[19]!==i||t[20]!==a||t[21]!==D||t[22]!==O||t[23]!==h?(ne=()=>{let e=function(e){h&&(document.cookie=`${h}=${e}; path=/; max-age=${O}`)},t=function(e,t){return v===`left`?e<t:e>t},n=function(e,t,n,r){if(k&&r){let r=e.clientX-t;return v===`left`?n-r:n+r}return v===`left`?window.innerWidth-e.clientX:e.clientX},r=function(r){if(!P.current)return;let o=Math.abs(r.clientX-M.current);if(!N.current&&o>5&&(N.current=!0,D(!0)),N.current){let{unit:o}=fk(V.current),s=B.current;k&&A.current&&(s=A.current.getBoundingClientRect());let c=t(r.clientX,I.current)?`expand`:`collapse`;F.current!==c&&(F.current=c),z.current=Math.abs(r.clientX-I.current);let l=Date.now();if(L.current&&l-R.current>200&&(L.current=!1),!L.current){if(C&&a&&!H.current){let e=n(r,M.current,j.current,s),t=!1;if(w<=1)t=e<=q*w;else if(e<=q){let n=q*(w-1);t=q-e>=n}if(c===`collapse`&&t){a(),I.current=r.clientX,L.current=!0,R.current=l;return}}if(a&&H.current&&c===`expand`&&z.current>q*T){a();let t=n(r,M.current,j.current,s),c=Math.max(q,Math.min(Y,t)),u=mk(o===`rem`?c/16:c,o);i(u),e(u),I.current=r.clientX,L.current=!0,R.current=l;return}}if(H.current)return;let u=n(r,M.current,j.current,s),d=Math.max(q,Math.min(Y,u)),f=mk(o===`rem`?d/16:d,o);i(f),e(f)}},o=function(){P.current&&(!N.current&&a&&S&&a(),N.current=!1,P.current=!1,F.current=null,I.current=0,L.current=!1,R.current=0,z.current=0,B.current=null,D(!1))};return document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,o),()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,o)}},re=[i,a,D,q,Y,k,C,w,T,S,h,O,v],t[11]=w,t[12]=v,t[13]=C,t[14]=S,t[15]=T,t[16]=k,t[17]=Y,t[18]=q,t[19]=i,t[20]=a,t[21]=D,t[22]=O,t[23]=h,t[24]=ne,t[25]=re):(ne=t[24],re=t[25]),(0,Q.useEffect)(ne,re);let ie;return t[26]===te?ie=t[27]:(ie={dragRef:A,isDragging:N,handleMouseDown:te},t[26]=te,t[27]=ie),ie}function _k(){}var vk=3600*24*7,yk=`18rem`,bk=`3rem`,xk=`app-file-sidebar`,Sk=`14.625rem`,Ck=`32rem`,wk=`sidebar_width`,Tk=/^\d+(?:\.\d+)?(?:rem|px)$/,Ek=Q.createContext(null);function Dk(e){if(typeof document>`u`)return e;let t=document.cookie.split(`; `).find(e=>e.startsWith(`${wk}=`))?.split(`=`)[1];if(!t)return e;let n;try{n=decodeURIComponent(t)}catch{return e}return Tk.test(n)?n:e}function Ok(){let e=Q.use(Ek);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function kk(e){let t=(0,$.c)(58),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({open:i,onOpenChange:o,className:r,style:s,children:n,defaultWidth:c,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=c===void 0?yk:c,[u]=Q.useState(jk),d;t[8]===u?d=t[9]:(d=()=>VC(u,window.innerWidth,`left`),t[8]=u,t[9]=d);let[f,p]=Q.useState(d),m;t[10]===l?m=t[11]:(m=()=>Dk(l),t[10]=l,t[11]=m);let[h,g]=Q.useState(m),[_,v]=Q.useState(!1),[y,b]=Q.useState(!1),x;t[12]===u?x=t[13]:(x=()=>{let e=JC();return XC(`left`,VC(u,window.innerWidth,`left`),e)===`open`},t[12]=u,t[13]=x);let[S,C]=Q.useState(x),w=i??S,T;t[14]!==w||t[15]!==f||t[16]!==o?(T=e=>{let t=typeof e==`function`?e(w):e;o?o(t):C(t),ZC(`left`,f,t?`open`:`collapsed`)},t[14]=w,t[15]=f,t[16]=o,t[17]=T):T=t[17];let E=T,D;t[18]===E?D=t[19]:(D=function(){E(Ak)},t[18]=E,t[19]=D);let O=D,k=Q.useRef(w),A;t[20]===w?A=t[21]:(A=()=>{k.current=w},t[20]=w,t[21]=A),Q.useLayoutEffect(A);let j;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(j=function(){window.innerWidth>=1024||k.current&&(window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||b(!0))},t[22]=j):j=t[22];let M=j,N,P;t[23]===u?(N=t[24],P=t[25]):(P=()=>{let e=window.matchMedia(`(min-width: ${RC}px)`),t=()=>{let e=VC(u,window.innerWidth,`left`);p(e),C(XC(`left`,e,JC())===`open`)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},N=[u],t[23]=u,t[24]=N,t[25]=P),Q.useEffect(P,N);let F,I;t[26]===w?(F=t[27],I=t[28]):(F=()=>{w||document.getElementById(xk)?.contains(document.activeElement)&&document.querySelector(`[data-sidebar="trigger"]`)?.focus()},I=[w],t[26]=w,t[27]=F,t[28]=I),Q.useLayoutEffect(F,I);let L,R;t[29]!==w||t[30]!==f||t[31]!==E?(L=()=>{if(f===`above`||!w)return;let e=e=>{e.key===`Escape`&&(document.querySelector(`[data-state="open"][role="dialog"], [data-state="open"][role="alertdialog"], [data-state="open"][role="menu"], [data-state="open"][role="listbox"], [data-radix-popper-content-wrapper] [data-state="open"]`)||E(!1))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},R=[f,w,E],t[29]=w,t[30]=f,t[31]=E,t[32]=L,t[33]=R):(L=t[32],R=t[33]),Q.useEffect(L,R);let z,B;t[34]===O?(z=t[35],B=t[36]):(z=()=>{if(typeof window<`u`&&window.okDesktop!=null)return;let e=e=>{qs(e,`toggle-files-sidebar`)&&(e.preventDefault(),O())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},B=[O],t[34]=O,t[35]=z,t[36]=B),Q.useEffect(z,B);let V=w?`expanded`:`collapsed`,H;t[37]!==_||t[38]!==w||t[39]!==E||t[40]!==y||t[41]!==V||t[42]!==O||t[43]!==h?(H={state:V,open:w,setOpen:E,toggleSidebar:O,width:h,setWidth:g,isDraggingRail:_,setIsDraggingRail:v,showPushPulse:y,setShowPushPulse:b,notifySidebarFileSelected:M},t[37]=_,t[38]=w,t[39]=E,t[40]=y,t[41]=V,t[42]=O,t[43]=h,t[44]=H):H=t[44];let U;t[45]!==s||t[46]!==h?(U={"--sidebar-width":h,"--sidebar-width-icon":bk,...s},t[45]=s,t[46]=h,t[47]=U):U=t[47];let W=U,G;t[48]===r?G=t[49]:(G=ai(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),t[48]=r,t[49]=G);let K;t[50]!==n||t[51]!==a||t[52]!==W||t[53]!==G?(K=(0,Z.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:W,className:G,...a,children:n}),t[50]=n,t[51]=a,t[52]=W,t[53]=G,t[54]=K):K=t[54];let q;return t[55]!==H||t[56]!==K?(q=(0,Z.jsx)(Ek.Provider,{value:H,children:K}),t[55]=H,t[56]=K,t[57]=q):q=t[57],q}function Ak(e){return!e}function jk(){return Er()}function Mk(e){let t=(0,$.c)(39),n,r,a,o,s,c;t[0]===e?(n=t[1],r=t[2],a=t[3],o=t[4],s=t[5],c=t[6]):({side:o,variant:s,collapsible:c,className:r,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o,t[5]=s,t[6]=c);let l=o===void 0?`left`:o,u=s===void 0?`sidebar`:s,d=c===void 0?`offcanvas`:c,{_:f}=i(),{state:p,isDraggingRail:m}=Ok();if(d===`none`){let e;t[7]===r?e=t[8]:(e=ai(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),t[7]=r,t[8]=e);let i;return t[9]!==n||t[10]!==a||t[11]!==e||t[12]!==u?(i=(0,Z.jsx)(`div`,{"data-slot":`sidebar`,"data-variant":u,className:e,...a,children:n}),t[9]=n,t[10]=a,t[11]=e,t[12]=u,t[13]=i):i=t[13],i}let h=p===`collapsed`?d:``,g=u===`floating`||u===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,_;t[14]===g?_=t[15]:(_=ai(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,g,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`),t[14]=g,t[15]=_);let v;t[16]===_?v=t[17]:(v=(0,Z.jsx)(`div`,{"data-slot":`sidebar-gap`,className:_}),t[16]=_,t[17]=v);let y;t[18]===f?y=t[19]:(y=f({id:`07q4Qk`}),t[18]=f,t[19]=y);let b=u===`floating`||u===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,x;t[20]!==r||t[21]!==b?(x=ai(`fixed inset-y-0 z-10 flex h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear motion-reduce:transition-none motion-reduce:duration-0 data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]`,b,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`,r),t[20]=r,t[21]=b,t[22]=x):x=t[22];let S;t[23]===n?S=t[24]:(S=(0,Z.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border`,children:n}),t[23]=n,t[24]=S);let C;t[25]!==a||t[26]!==l||t[27]!==x||t[28]!==S||t[29]!==y?(C=(0,Z.jsx)(`nav`,{id:xk,"aria-label":y,"data-slot":`sidebar-container`,"data-side":l,className:x,...a,children:S}),t[25]=a,t[26]=l,t[27]=x,t[28]=S,t[29]=y,t[30]=C):C=t[30];let w;return t[31]!==m||t[32]!==l||t[33]!==p||t[34]!==C||t[35]!==h||t[36]!==v||t[37]!==u?(w=(0,Z.jsxs)(`div`,{className:`group peer text-sidebar-foreground`,"data-state":p,"data-collapsible":h,"data-variant":u,"data-side":l,"data-slot":`sidebar`,"data-dragging":m,children:[v,C]}),t[31]=m,t[32]=l,t[33]=p,t[34]=C,t[35]=h,t[36]=v,t[37]=u,t[38]=w):w=t[38],w}function Nk(e){let t=(0,$.c)(34),n,r,a;t[0]===e?(n=t[1],r=t[2],a=t[3]):({className:n,onClick:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=a);let{_:o}=i(),{toggleSidebar:s,state:c}=Ok(),l,u,d,f,p,m,h,g;if(t[4]!==o||t[5]!==c){let e=Js(`toggle-files-sidebar`);l=si,u=`trigger`,d=`sidebar-trigger`,f=`ghost`,p=`icon-sm`,m=c===`expanded`,h=xk,g=o(c===`expanded`?{id:`4PYsOz`,values:{sidebarShortcutLabel:e}}:{id:`jbSG8V`,values:{sidebarShortcutLabel:e}}),t[4]=o,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m,t[12]=h,t[13]=g}else l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13];let _;t[14]===n?_=t[15]:(_=ai(n),t[14]=n,t[15]=_);let v;t[16]!==r||t[17]!==s?(v=e=>{r?.(e),s()},t[16]=r,t[17]=s,t[18]=v):v=t[18];let y;t[19]===c?y=t[20]:(y=c===`expanded`?(0,Z.jsx)(se,{}):(0,Z.jsx)(kl,{}),t[19]=c,t[20]=y);let b;return t[21]!==l||t[22]!==a||t[23]!==u||t[24]!==y||t[25]!==d||t[26]!==f||t[27]!==p||t[28]!==m||t[29]!==h||t[30]!==g||t[31]!==_||t[32]!==v?(b=(0,Z.jsx)(l,{"data-sidebar":u,"data-slot":d,variant:f,size:p,"aria-expanded":m,"aria-controls":h,"aria-label":g,className:_,onClick:v,...a,children:y}),t[21]=l,t[22]=a,t[23]=u,t[24]=y,t[25]=d,t[26]=f,t[27]=p,t[28]=m,t[29]=h,t[30]=g,t[31]=_,t[32]=v,t[33]=b):b=t[33],b}function Pk(e){let t=(0,$.c)(32),n,r,a,o,s;t[0]===e?(n=t[1],r=t[2],a=t[3],o=t[4],s=t[5]):({className:n,enableDrag:o,enableToggle:s,onMouseDown:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o,t[5]=s);let c=o===void 0?!0:o,l=s===void 0?!0:s,{_:u}=i(),{toggleSidebar:d,setWidth:f,state:p,width:m,setIsDraggingRail:h}=Ok(),g=p===`collapsed`,_;t[6]!==c||t[7]!==l||t[8]!==h||t[9]!==f||t[10]!==g||t[11]!==d||t[12]!==m?(_={direction:`right`,enableDrag:c,enableToggle:l,onResize:f,onToggle:d,currentWidth:m,isCollapsed:g,minResizeWidth:Sk,maxResizeWidth:Ck,setIsDraggingRail:h,widthCookieName:wk,widthCookieMaxAge:vk},t[6]=c,t[7]=l,t[8]=h,t[9]=f,t[10]=g,t[11]=d,t[12]=m,t[13]=_):_=t[13];let{dragRef:v,handleMouseDown:y}=gk(_),b;t[14]!==u||t[15]!==p?(b=u(p===`expanded`?{id:`w3vFfL`}:{id:`e8zRrb`}),t[14]=u,t[15]=p,t[16]=b):b=t[16];let x;t[17]!==y||t[18]!==r?(x=e=>{r?.(e),e.defaultPrevented||y(e)},t[17]=y,t[18]=r,t[19]=x):x=t[19];let S;t[20]!==u||t[21]!==p?(S=u(p===`expanded`?{id:`w3vFfL`}:{id:`e8zRrb`}),t[20]=u,t[21]=p,t[22]=S):S=t[22];let C;t[23]===n?C=t[24]:(C=ai(`absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2`,`in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize`,`[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize`,`group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar`,`[[data-side=left][data-collapsible=offcanvas]_&]:-right-2`,`[[data-side=right][data-collapsible=offcanvas]_&]:-left-2`,`md:group-data-[variant=inset]:after:inset-y-5`,n),t[23]=n,t[24]=C);let w;return t[25]!==v||t[26]!==a||t[27]!==b||t[28]!==x||t[29]!==S||t[30]!==C?(w=(0,Z.jsx)(`button`,{ref:v,"data-sidebar":`rail`,"data-slot":`sidebar-rail`,"aria-label":b,tabIndex:-1,onMouseDown:x,title:S,className:C,...a}),t[25]=v,t[26]=a,t[27]=b,t[28]=x,t[29]=S,t[30]=C,t[31]=w):w=t[31],w}function Fk(e){let t=(0,$.c)(14),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,onAnimationEnd:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let{showPushPulse:a,setShowPushPulse:o}=Ok(),s;t[4]!==r||t[5]!==o?(s=e=>{r?.(e),e.animationName===`sidebar-push-pulse`&&o(!1)},t[4]=r,t[5]=o,t[6]=s):s=t[6];let c=s,l=a?``:void 0,u;t[7]===n?u=t[8]:(u=ai(`relative flex w-full flex-1 flex-col bg-background peer-data-[variant=inset]:m-2 peer-data-[variant=inset]:ml-0 peer-data-[variant=inset]:rounded-xl peer-data-[variant=inset]:shadow-sm peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2`,n),t[7]=n,t[8]=u);let d;return t[9]!==c||t[10]!==i||t[11]!==l||t[12]!==u?(d=(0,Z.jsx)(`main`,{"data-slot":`sidebar-inset`,"data-push-pulse":l,onAnimationEnd:c,className:u,...i}),t[9]=c,t[10]=i,t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function Ik(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`sidebar-header`,"data-sidebar":`header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Lk(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Rk(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function zk(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`flex w-full min-w-0 flex-col gap-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Bk(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`group/menu-item relative`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Vk=ri(`peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-hover hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-hover active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-hover data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground data-active:hover:bg-sidebar-accent [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate`,{variants:{variant:{default:`hover:bg-sidebar-hover hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-hover hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`default`}});function Hk(e){let t=(0,$.c)(28),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({asChild:i,isActive:a,variant:o,size:s,tooltip:c,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=i===void 0?!1:i,u=a===void 0?!1:a,d=o===void 0?`default`:o,f=s===void 0?`default`:s,p=l?oi:`button`,{state:m}=Ok(),h;t[8]!==n||t[9]!==f||t[10]!==d?(h=ai(Vk({variant:d,size:f}),n),t[8]=n,t[9]=f,t[10]=d,t[11]=h):h=t[11];let g;t[12]!==p||t[13]!==u||t[14]!==r||t[15]!==f||t[16]!==h?(g=(0,Z.jsx)(p,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":f,"data-active":u,className:h,...r}),t[12]=p,t[13]=u,t[14]=r,t[15]=f,t[16]=h,t[17]=g):g=t[17];let _=g;if(!c)return _;if(typeof c==`string`){let e;t[18]===c?e=t[19]:(e={children:c},t[18]=c,t[19]=e),c=e}let v;t[20]===_?v=t[21]:(v=(0,Z.jsx)(Ts,{asChild:!0,children:_}),t[20]=_,t[21]=v);let y=m!==`collapsed`,b;t[22]!==y||t[23]!==c?(b=(0,Z.jsx)(Ds,{side:`right`,align:`center`,hidden:y,...c}),t[22]=y,t[23]=c,t[24]=b):b=t[24];let x;return t[25]!==v||t[26]!==b?(x=(0,Z.jsxs)(As,{children:[v,b]}),t[25]=v,t[26]=b,t[27]=x):x=t[27],x}function Uk(e){let t=null,n=!1,r=new Set;function i(e){if(e!==t){t=e;for(let e of r)e()}}e.subscribeToEvent(i);async function a(){if(!n){n=!0;try{i(await e.fetchBranch())}catch{}}}return{getSnapshot:()=>t,subscribe(e){return r.add(e),a(),()=>{r.delete(e)}}}}async function Wk(){let e=await fetch(`/api/server-info`,{signal:AbortSignal.timeout(5e3)});if(!e.ok)return null;let t=await e.json(),n=Fr.safeParse(t);return n.success?n.data.currentBranch??null:null}var Gk=typeof window>`u`?{getSnapshot:()=>null,subscribe:()=>()=>{}}:Uk({fetchBranch:Wk,subscribeToEvent:$o}),Kk=Gk.subscribe,qk=Gk.getSnapshot;function Jk(){return(0,Q.useSyncExternalStore)(Kk,qk,qk)}function Yk(){let e=(0,$.c)(6),t=Jk(),n=po(),{state:r}=Ok(),i=typeof window<`u`?window.okDesktop:void 0;if(i&&r===`expanded`)return null;let a;e[0]===n?a=e[1]:(a=i?.config.projectName??(n&&la(n.contentDir)||null),e[0]=n,e[1]=a);let o=a,s=i?.config.projectPath??n?.contentDir??null;if(o===null&&t===null)return null;let c;return e[2]!==t||e[3]!==o||e[4]!==s?(c={projectName:o,projectPath:s,branch:t},e[2]=t,e[3]=o,e[4]=s,e[5]=c):c=e[5],c}function Xk(e){let t=(0,$.c)(23),{stats:n,selectionStats:r,showStats:a}=e,o=a===void 0?!0:a,{_:c}=i(),l=Yk();if(!o&&l===null)return null;let u=r??n,d=r!=null,{words:f,chars:p,tokens:m}=u,h;t[0]!==c||t[1]!==d||t[2]!==o?(h=c(o?d?{id:`Bv5a9_`}:{id:`L1ZE3M`}:{id:`goO4Ll`}),t[0]=c,t[1]=d,t[2]=o,t[3]=h):h=t[3];let g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-full h-2 bg-linear-to-t from-background to-transparent`}),t[4]=g):g=t[4];let _;t[5]===l?_=t[6]:(_=l===null?null:(0,Z.jsx)(Zk,{identity:l}),t[5]=l,t[6]=_);let v;t[7]===_?v=t[8]:(v=(0,Z.jsx)(`span`,{className:`flex min-w-0 items-center gap-3`,children:_}),t[7]=_,t[8]=v);let y;t[9]!==c||t[10]!==u.chars||t[11]!==u.tokens||t[12]!==u.words||t[13]!==p||t[14]!==d||t[15]!==o||t[16]!==m||t[17]!==f?(y=o?(0,Z.jsxs)(`span`,{className:`flex items-center shrink-0 gap-3`,children:[d?(0,Z.jsx)(`span`,{className:`font-medium text-foreground/70`,"data-testid":`editor-footer-selected-label`,children:c({id:`ylXj1N`})}):null,(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`tabular-nums`,children:u.words.toLocaleString()}),` `,(0,Z.jsx)(s,{id:`gljvbT`,values:{words:f}})]}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`tabular-nums`,children:u.chars.toLocaleString()}),` `,(0,Z.jsx)(s,{id:`d5rK4X`,values:{chars:p}})]}),(0,Z.jsxs)(`span`,{children:[u.tokens>0?`~`:``,(0,Z.jsx)(`span`,{className:`tabular-nums`,children:u.tokens.toLocaleString()}),` `,(0,Z.jsx)(s,{id:`uynXup`,values:{tokens:m}})]})]}):null,t[9]=c,t[10]=u.chars,t[11]=u.tokens,t[12]=u.words,t[13]=p,t[14]=d,t[15]=o,t[16]=m,t[17]=f,t[18]=y):y=t[18];let b;return t[19]!==h||t[20]!==v||t[21]!==y?(b=(0,Z.jsxs)(`section`,{"aria-label":h,className:`relative flex h-6 shrink-0 items-center justify-between gap-3 bg-background px-3 text-2xs text-muted-foreground`,children:[g,v,y]}),t[19]=h,t[20]=v,t[21]=y,t[22]=b):b=t[22],b}function Zk(e){let t=(0,$.c)(8),{identity:n}=e,{projectName:r,projectPath:i,branch:a}=n,o;t[0]!==r||t[1]!==i?(o=r===null?null:i?(0,Z.jsxs)(As,{children:[(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(`span`,{tabIndex:0,className:`truncate`,"data-testid":`editor-footer-project-name`,children:r})}),(0,Z.jsx)(Ds,{side:`top`,className:`max-w-xs break-all`,children:i})]}):(0,Z.jsx)(`span`,{className:`truncate`,"data-testid":`editor-footer-project-name`,children:r}),t[0]=r,t[1]=i,t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=a===null?null:(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,"data-testid":`editor-footer-branch`,children:[(0,Z.jsx)(Ce,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:a})]}),t[3]=a,t[4]=s);let c;return t[5]!==o||t[6]!==s?(c=(0,Z.jsxs)(Z.Fragment,{children:[o,s]}),t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function Qk(e){let t=(0,$.c)(11),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{_:a}=i(),o;t[3]===a?o=t[4]:(o=a({id:`3__SjS`}),t[3]=a,t[4]=o);let s;t[5]===n?s=t[6]:(s=ai(n),t[5]=n,t[6]=s);let c;return t[7]!==r||t[8]!==o||t[9]!==s?(c=(0,Z.jsx)(`nav`,{"aria-label":o,"data-slot":`breadcrumb`,className:s,...r}),t[7]=r,t[8]=o,t[9]=s,t[10]=c):c=t[10],c}function $k(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`ol`,{"data-slot":`breadcrumb-list`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function eA(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`inline-flex items-center gap-1`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`li`,{"data-slot":`breadcrumb-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function tA(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({current:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0||i?`page`:void 0,o;t[4]===n?o=t[5]:(o=ai(`font-normal text-foreground`,n),t[4]=n,t[5]=o);let s;return t[6]!==r||t[7]!==a||t[8]!==o?(s=(0,Z.jsx)(`span`,{"data-slot":`breadcrumb-page`,"aria-current":a,className:o,...r}),t[6]=r,t[7]=a,t[8]=o,t[9]=s):s=t[9],s}function nA(e){let t=(0,$.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({children:n,className:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=ai(`[&>svg]:size-3.5`,r),t[4]=r,t[5]=a);let o;t[6]===n?o=t[7]:(o=n??(0,Z.jsx)(jo,{}),t[6]=n,t[7]=o);let s;return t[8]!==i||t[9]!==a||t[10]!==o?(s=(0,Z.jsx)(`li`,{"data-slot":`breadcrumb-separator`,role:`presentation`,"aria-hidden":`true`,className:a,...i,children:o}),t[8]=i,t[9]=a,t[10]=o,t[11]=s):s=t[11],s}var rA=1,iA=2,aA=4;function oA(e){let t=(0,$.c)(18),{docName:n,className:r}=e;if(!n)return null;let i,a,o,s,c,l;if(t[0]!==r||t[1]!==n){l=Symbol.for(`react.early_return_sentinel`);bb0:{let{prefix:e}=Me(n,``);if(!e){l=null;break bb0}let u=e.replace(/\/$/,``).split(`/`).filter(Boolean);if(u.length===0){l=null;break bb0}let d=(e,t)=>({kind:`segment`,value:e,key:u.slice(0,t+1).join(`/`)}),f=u.length>aA?[...u.slice(0,rA).map((e,t)=>d(e,t)),{kind:`ellipsis`,hidden:u.slice(rA,-iA)},...u.slice(-iA).map((e,t)=>d(e,u.length-iA+t))]:u.map((e,t)=>d(e,t));a=Qk,t[8]===r?c=t[9]:(c=ai(`flex min-w-0 items-center`,r),t[8]=r,t[9]=c),i=$k,o=`min-w-0 flex-nowrap gap-1 overflow-hidden text-muted-foreground/70 text-xs`,s=f.map(sA)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7];if(l!==Symbol.for(`react.early_return_sentinel`))return l;let u;t[10]!==i||t[11]!==o||t[12]!==s?(u=(0,Z.jsx)(i,{className:o,children:s}),t[10]=i,t[11]=o,t[12]=s,t[13]=u):u=t[13];let d;return t[14]!==a||t[15]!==c||t[16]!==u?(d=(0,Z.jsx)(a,{className:c,children:u}),t[14]=a,t[15]=c,t[16]=u,t[17]=d):d=t[17],d}function sA(e,t){let n=e.kind===`segment`?e.key:`ellipsis`;return(0,Z.jsxs)(Q.Fragment,{children:[t>0&&(0,Z.jsx)(nA,{className:`shrink-0 text-muted-foreground/70 [&>svg]:size-3`}),e.kind===`ellipsis`?(0,Z.jsxs)(eA,{className:`shrink-0`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,title:e.hidden.join(` / `),className:`flex size-4 items-center justify-center text-muted-foreground/70`,children:(0,Z.jsx)(al,{className:`size-3.5`})}),(0,Z.jsx)(`span`,{className:`sr-only`,children:e.hidden.join(` / `)})]}):(0,Z.jsx)(eA,{className:`min-w-0`,children:(0,Z.jsx)(tA,{current:!1,className:`min-w-0 truncate font-normal text-muted-foreground/70`,title:e.value,children:e.value})})]},n)}var cA={fill:`none`,height:24,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 24 24`,width:24,xmlns:`http://www.w3.org/2000/svg`},lA=e=>{let t=(0,$.c)(15),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({color:a,size:o,strokeWidth:s,absoluteStrokeWidth:n,className:c,children:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=a===void 0?`currentColor`:a,u=o===void 0?24:o,d=s===void 0?2:s,f=c===void 0?``:c,p=n?Number(d)*24/Number(u):d,m;return t[8]!==r||t[9]!==f||t[10]!==l||t[11]!==i||t[12]!==u||t[13]!==p?(m=(0,Z.jsx)(`svg`,{"aria-hidden":`true`,...cA,className:f,height:u,stroke:l,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:p,width:u,...i,children:r}),t[8]=r,t[9]=f,t[10]=l,t[11]=i,t[12]=u,t[13]=p,t[14]=m):m=t[14],m},uA=e=>{let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`Markdown`}),r=(0,Z.jsx)(`path`,{d:`M232,48H24A16,16,0,0,0,8,64V192a16,16,0,0,0,16,16H232a16,16,0,0,0,16-16V64A16,16,0,0,0,232,48Zm0,144H24V64H232V192ZM128,104v48a8,8,0,0,1-16,0V123.31L93.66,141.66a8,8,0,0,1-11.32,0L64,123.31V152a8,8,0,0,1-16,0V104a8,8,0,0,1,13.66-5.66L88,124.69l26.34-26.35A8,8,0,0,1,128,104Zm77.66,18.34a8,8,0,0,1,0,11.32l-24,24a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L168,132.69V104a8,8,0,0,1,16,0v28.69l10.34-10.35A8,8,0,0,1,205.66,122.34Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,Z.jsxs)(lA,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},dA=e=>{let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`Textbox`}),r=(0,Z.jsx)(`path`,{d:`M112,40a8,8,0,0,0-8,8V64H24A16,16,0,0,0,8,80v96a16,16,0,0,0,16,16h80v16a8,8,0,0,0,16,0V48A8,8,0,0,0,112,40ZM24,176V80h80v96ZM248,80v96a16,16,0,0,1-16,16H144a8,8,0,0,1,0-16h88V80H144a8,8,0,0,1,0-16h88A16,16,0,0,1,248,80ZM88,112a8,8,0,0,1-8,8H72v24a8,8,0,0,1-16,0V120H48a8,8,0,0,1,0-16H80A8,8,0,0,1,88,112Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,Z.jsxs)(lA,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i};function fA(e){let t=(0,$.c)(90),{activeDocName:n,isSourceMode:r,sourceDisabled:a,onModeChange:o,showAddPropertyButton:c,onAddProperty:l,isPanelCollapsed:u,onTogglePanel:d}=e,{_:f}=i(),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=Ks(`toggle-document-panel`),t[0]=p):p=t[0];let m=p,h,g,_,v,y,b,x,S,C,w,T,E,D,O;if(t[1]!==f||t[2]!==n||t[3]!==u||t[4]!==r||t[5]!==l||t[6]!==o||t[7]!==d||t[8]!==c||t[9]!==a){let e=Js(`toggle-document-panel`);v=`editor-toolbar`,y=`pointer-events-none absolute inset-x-0 top-0 z-10`;let i;t[24]===n?i=t[25]:(i=(0,Z.jsx)(`div`,{className:`pointer-events-auto flex min-w-0 items-center`,children:(0,Z.jsx)(oA,{docName:n})}),t[24]=n,t[25]=i);let p=r?`source`:`wysiwyg`,m;t[26]===o?m=t[27]:(m=e=>{e&&o(e)},t[26]=o,t[27]=m);let k;t[28]===f?k=t[29]:(k=f({id:`n7aopT`}),t[28]=f,t[29]=k);let A;t[30]===f?A=t[31]:(A=f({id:`ur2XSb`}),t[30]=f,t[31]=A);let j;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Z.jsx)(Ts,{children:(0,Z.jsx)(dA,{className:`size-4`})}),t[32]=j):j=t[32];let M;t[33]===A?M=t[34]:(M=(0,Z.jsx)(_o,{value:`wysiwyg`,"aria-label":A,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,asChild:!0,children:j}),t[33]=A,t[34]=M);let N;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(Ds,{side:`bottom`,children:(0,Z.jsx)(s,{id:`Mb_20S`})}),t[35]=N):N=t[35];let P;t[36]===M?P=t[37]:(P=(0,Z.jsxs)(As,{children:[M,N]}),t[36]=M,t[37]=P);let F;t[38]===f?F=t[39]:(F=f({id:`xbdtfY`}),t[38]=f,t[39]=F);let I;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(uA,{className:`size-4`}),t[40]=I):I=t[40];let L;t[41]!==a||t[42]!==F?(L=(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(`div`,{children:(0,Z.jsx)(_o,{value:`source`,"aria-label":F,disabled:a,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,children:I})})}),t[41]=a,t[42]=F,t[43]=L):L=t[43];let R;t[44]===a?R=t[45]:(R=(0,Z.jsx)(Ds,{side:`bottom`,children:a?(0,Z.jsx)(s,{id:`G-JBA1`}):(0,Z.jsx)(s,{id:`u6Hp4N`})}),t[44]=a,t[45]=R);let z;t[46]!==L||t[47]!==R?(z=(0,Z.jsxs)(As,{children:[L,R]}),t[46]=L,t[47]=R,t[48]=z):z=t[48];let B;t[49]!==p||t[50]!==m||t[51]!==k||t[52]!==P||t[53]!==z?(B=(0,Z.jsx)(`div`,{className:`pointer-events-auto flex justify-center`,children:(0,Z.jsxs)(yo,{type:`single`,value:p,onValueChange:m,"aria-label":k,variant:`segmented`,size:`sm`,spacing:1,className:`shrink-0 data-[size=sm]:rounded-[10px] bg-muted p-0.5`,children:[P,z]})}),t[49]=p,t[50]=m,t[51]=k,t[52]=P,t[53]=z,t[54]=B):B=t[54],t[55]!==i||t[56]!==B?(b=(0,Z.jsx)(`div`,{className:`editor-content-aligned bg-background py-2`,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 items-center`,children:[i,B]})}),t[55]=i,t[56]=B,t[57]=b):b=t[57],O=`pointer-events-auto absolute top-0 right-0 flex items-center justify-end gap-1 py-2 pr-2`,t[58]!==f||t[59]!==l||t[60]!==c?(_=c&&(0,Z.jsxs)(As,{children:[(0,Z.jsx)(si,{variant:`ghost`,size:`icon`,"aria-label":f({id:`81H_23`}),onClick:l,"data-testid":`add-properties-button`,asChild:!0,children:(0,Z.jsx)(Ts,{children:(0,Z.jsx)(Sl,{})})}),(0,Z.jsx)(Ds,{side:`bottom`,children:(0,Z.jsx)(s,{id:`81H_23`})})]}),t[58]=f,t[59]=l,t[60]=c,t[61]=_):_=t[61],g=As,h=si,x=``,S=`ghost`,C=`icon`,w=d,T=!u,E=`doc-panel`,D=f(u?{id:`u7H-Wn`,values:{panelShortcutLabel:e}}:{id:`2hpdRq`,values:{panelShortcutLabel:e}}),t[1]=f,t[2]=n,t[3]=u,t[4]=r,t[5]=l,t[6]=o,t[7]=d,t[8]=c,t[9]=a,t[10]=h,t[11]=g,t[12]=_,t[13]=v,t[14]=y,t[15]=b,t[16]=x,t[17]=S,t[18]=C,t[19]=w,t[20]=T,t[21]=E,t[22]=D,t[23]=O}else h=t[10],g=t[11],_=t[12],v=t[13],y=t[14],b=t[15],x=t[16],S=t[17],C=t[18],w=t[19],T=t[20],E=t[21],D=t[22],O=t[23];let k;t[62]===u?k=t[63]:(k=(0,Z.jsx)(Ts,{children:u?(0,Z.jsx)(jl,{}):(0,Z.jsx)(Al,{})}),t[62]=u,t[63]=k);let A;t[64]!==h||t[65]!==k||t[66]!==x||t[67]!==S||t[68]!==C||t[69]!==w||t[70]!==T||t[71]!==E||t[72]!==D?(A=(0,Z.jsx)(h,{"data-doc-panel-toggle":x,variant:S,size:C,onClick:w,"aria-expanded":T,"aria-controls":E,"aria-label":D,asChild:!0,children:k}),t[64]=h,t[65]=k,t[66]=x,t[67]=S,t[68]=C,t[69]=w,t[70]=T,t[71]=E,t[72]=D,t[73]=A):A=t[73];let j;t[74]===u?j=t[75]:(j=(0,Z.jsx)(Ds,{side:`bottom`,children:u?(0,Z.jsx)(s,{id:`KFdXwz`,values:{panelShortcut:m}}):(0,Z.jsx)(s,{id:`MsuXaI`,values:{panelShortcut:m}})}),t[74]=u,t[75]=j);let M;t[76]!==g||t[77]!==A||t[78]!==j?(M=(0,Z.jsxs)(g,{children:[A,j]}),t[76]=g,t[77]=A,t[78]=j,t[79]=M):M=t[79];let N;t[80]!==_||t[81]!==M||t[82]!==O?(N=(0,Z.jsxs)(`div`,{className:O,children:[_,M]}),t[80]=_,t[81]=M,t[82]=O,t[83]=N):N=t[83];let P;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none h-2 bg-linear-to-b from-background to-transparent`}),t[84]=P):P=t[84];let F;return t[85]!==v||t[86]!==y||t[87]!==b||t[88]!==N?(F=(0,Z.jsxs)(`div`,{"data-testid":v,className:y,children:[b,N,P]}),t[85]=v,t[86]=y,t[87]=b,t[88]=N,t[89]=F):F=t[89],F}function pA(e){let{activeDocName:t,deferredActiveDocName:n,mountResolved:r,syncResolved:i}=e;return t===null||t===n?!1:!(r&&i)}var mA=`ok-terminal-height-v1`,hA=.5;function gA(e){return Math.max(120,Math.round((Number.isFinite(e)?e:0)*hA))}function _A(e,t){let n=gA(t);return Number.isFinite(e)?e<120?120:e>n?n:Math.round(e):Math.min(240,n)}function vA(){return typeof window>`u`?0:window.innerHeight}function yA(e,t){try{let n=e??localStorage,r=t??vA(),i=n.getItem(mA);if(i==null)return _A(240,r);let a=Number.parseInt(i,10);return _A(Number.isFinite(a)?a:240,r)}catch{return 240}}function bA(e,t,n){try{let r=t??localStorage,i=n??vA();r.setItem(mA,String(_A(e,i)))}catch{}}function xA(){try{return typeof localStorage>`u`?240:yA()}catch{return 240}}var SA=(0,Q.lazy)(()=>n(()=>import(`./TerminalPanel-CDbNsVll.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([58,1,22,6,3,23,9,48,11,59]),import.meta.url));function CA(e){let t=(0,$.c)(12),{bridge:n,onClose:r,onKill:a,launch:o}=e,s=o===void 0?null:o,{enabled:c,synced:l}=ki(),u=so(),{_:d}=i(),f=l&&c===!1,p;t[0]!==d||t[1]!==u?(p=function(){if(u===null){X.error(d({id:`V_6bJ4`}));return}let e=u(!0);e.ok||X.error(d({id:`jKd3AP`,values:{0:e.error}}))},t[0]=d,t[1]=u,t[2]=p):p=t[2];let m=p;if(l&&!f){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`div`,{className:`h-full w-full bg-background`,"aria-hidden":`true`}),t[3]=e):e=t[3];let i;return t[4]!==n||t[5]!==s||t[6]!==r||t[7]!==a?(i=(0,Z.jsx)(le,{fallbackRender:TA,onError:wA,children:(0,Z.jsx)(Q.Suspense,{fallback:e,children:(0,Z.jsx)(SA,{bridge:n,className:`h-full`,onClose:r,onKill:a,launch:s})})}),t[4]=n,t[5]=s,t[6]=r,t[7]=a,t[8]=i):i=t[8],i}let h;return t[9]!==m||t[10]!==f?(h=f?(0,Z.jsx)(OA,{onEnable:m}):(0,Z.jsx)(`div`,{className:`h-full w-full bg-background`,"aria-hidden":`true`}),t[9]=m,t[10]=f,t[11]=h):h=t[11],h}function wA(e,t){console.error(`[TerminalGate] rendered fallback for the terminal panel`,e,t.componentStack)}function TA(e){return(0,Z.jsx)(EA,{...e})}function EA(e){let t=(0,$.c)(15),{error:n}=e,{_:r}=i(),a;t[0]!==r||t[1]!==n?(a=n instanceof Error&&/dynamically imported module|Failed to fetch/i.test(n.message)?r({id:`Y8ViJx`}):r({id:`fbsiBw`}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s;t[3]===r?s=t[4]:(s=r({id:`6MnZEC`}),t[3]=r,t[4]=s);let c;t[5]===o?c=t[6]:(c=(0,Z.jsx)(`p`,{className:`max-w-sm text-sm text-foreground`,children:o}),t[5]=o,t[6]=c);let l;t[7]===r?l=t[8]:(l=r({id:`HpK_8d`}),t[7]=r,t[8]=l);let u;t[9]===l?u=t[10]:(u=(0,Z.jsx)(si,{onClick:DA,children:l}),t[9]=l,t[10]=u);let d;return t[11]!==s||t[12]!==c||t[13]!==u?(d=(0,Z.jsxs)(`section`,{"aria-label":s,className:`flex h-full w-full flex-col items-center justify-center gap-3 bg-background p-6 text-center`,role:`alert`,children:[c,u]}),t[11]=s,t[12]=c,t[13]=u,t[14]=d):d=t[14],d}function DA(){return window.location.reload()}function OA(e){let t=(0,$.c)(20),{onEnable:n}=e,{_:r}=i(),a;t[0]===r?a=t[1]:(a=r({id:`_XWY2J`}),t[0]=r,t[1]=a);let o;t[2]===r?o=t[3]:(o=r({id:`oYepHb`}),t[2]=r,t[3]=o);let s;t[4]===o?s=t[5]:(s=(0,Z.jsx)(`p`,{className:`max-w-sm text-sm text-foreground`,children:o}),t[4]=o,t[5]=s);let c;t[6]===r?c=t[7]:(c=r({id:`v2ZW0K`}),t[6]=r,t[7]=c);let l;t[8]!==n||t[9]!==c?(l=(0,Z.jsx)(si,{onClick:n,children:c}),t[8]=n,t[9]=c,t[10]=l):l=t[10];let u;t[11]===r?u=t[12]:(u=r({id:`ICoNYz`}),t[11]=r,t[12]=u);let d;t[13]===u?d=t[14]:(d=(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u}),t[13]=u,t[14]=d);let f;return t[15]!==a||t[16]!==s||t[17]!==l||t[18]!==d?(f=(0,Z.jsxs)(`section`,{"aria-label":a,className:`flex h-full w-full flex-col items-center justify-center gap-3 bg-background p-6 text-center`,children:[s,l,d]}),t[15]=a,t[16]=s,t[17]=l,t[18]=d,t[19]=f):f=t[19],f}var kA=`terminal-dock-panel`;function AA(e){let t=(0,$.c)(54),{bridge:n,children:r,visible:i,onVisibleChange:a,launch:o}=e,s=o===void 0?null:o,c=Vb(),l=(0,Q.useRef)(null),[u,d]=(0,Q.useState)(!i),[f,p]=(0,Q.useState)(i),[m]=(0,Q.useState)(jA),h=(0,Q.useRef)(m),[g,_]=(0,Q.useState)(!1),v=(0,Q.useRef)(!1),y=(0,Q.useRef)(null),b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b=function(e){y.current!=null&&clearTimeout(y.current),y.current=setTimeout(()=>{bA(e),y.current=null},100)},t[0]=b):b=t[0];let x=b,S=(0,Q.useRef)(null),C,w;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>()=>{y.current!=null&&clearTimeout(y.current),S.current!=null&&(window.removeEventListener(`pointerup`,S.current),S.current=null)},w=[],t[1]=C,t[2]=w):(C=t[1],w=t[2]),(0,Q.useEffect)(C,w);let T,E;t[3]===i?(T=t[4],E=t[5]):(T=()=>{i&&p(!0)},E=[i],t[3]=i,t[4]=T,t[5]=E),(0,Q.useEffect)(T,E);let D;t[6]===a?D=t[7]:(D=function(){p(!1),a(!1),l.current?.focus()},t[6]=a,t[7]=D);let O=D,k=(0,Q.useRef)(O),A;t[8]===O?A=t[9]:(A=()=>{k.current=O},t[8]=O,t[9]=A),(0,Q.useEffect)(A);let j,M;t[10]===n?(j=t[11],M=t[12]):(M=()=>n.onMenuAction(e=>{e===`kill-terminal`&&k.current()}),j=[n],t[10]=n,t[11]=j,t[12]=M),(0,Q.useEffect)(M,j);let N;t[13]!==n.editor||t[14]!==f?(N=()=>{n.editor.notifyViewMenuStateChanged({terminalLive:f})},t[13]=n.editor,t[14]=f,t[15]=N):N=t[15];let P;t[16]!==n||t[17]!==f?(P=[n,f],t[16]=n,t[17]=f,t[18]=P):P=t[18],(0,Q.useEffect)(N,P);let F,I;t[19]!==c||t[20]!==i?(F=()=>{let e=c.current;e!=null&&(i?e.resize(`${h.current}px`):e.collapse())},I=[i,c],t[19]=c,t[20]=i,t[21]=F,t[22]=I):(F=t[21],I=t[22]),(0,Q.useEffect)(F,I);let L,R;t[23]===u?(L=t[24],R=t[25]):(L=()=>{u&&document.getElementById(kA)?.contains(document.activeElement)&&l.current?.focus()},R=[u],t[23]=u,t[24]=L,t[25]=R),(0,Q.useLayoutEffect)(L,R);let z,B;t[26]===u?(z=t[27],B=t[28]):(z=()=>{u||document.getElementById(kA)?.querySelector(`.xterm-helper-textarea`)?.focus()},B=[u],t[26]=u,t[27]=z,t[28]=B),(0,Q.useLayoutEffect)(z,B);let V=g||void 0,H;t[29]===r?H=t[30]:(H=(0,Z.jsx)(oC,{minSize:`20%`,className:`flex min-h-0 flex-col`,children:(0,Z.jsx)(`div`,{ref:l,tabIndex:-1,className:`flex h-full min-h-0 flex-col outline-none`,children:r})}),t[29]=r,t[30]=H);let U;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Z.jsx)(sC,{withHandle:!0,onPointerDown:()=>{_(!0),v.current=!0;let e=()=>{_(!1),v.current=!1,window.removeEventListener(`pointerup`,e),S.current=null};S.current=e,window.addEventListener(`pointerup`,e)}}),t[31]=U):U=t[31];let W=i?`${m}px`:0,G;t[32]!==a||t[33]!==i?(G=e=>{let t=e.asPercentage===0;d(t),v.current&&(t&&i?a(!1):!t&&!i&&a(!0),e.inPixels>0&&(h.current=e.inPixels,x(e.inPixels)))},t[32]=a,t[33]=i,t[34]=G):G=t[34];let K=!g&&`transition-[flex-grow] duration-150 ease-out motion-reduce:transition-none motion-reduce:duration-0`,q;t[35]===K?q=t[36]:(q=ai(`flex flex-col`,K),t[35]=K,t[36]=q);let J;t[37]!==n||t[38]!==O||t[39]!==s||t[40]!==f||t[41]!==a?(J=f?(0,Z.jsx)(CA,{bridge:n,launch:s,onClose:()=>{a(!1),l.current?.focus()},onKill:O}):null,t[37]=n,t[38]=O,t[39]=s,t[40]=f,t[41]=a,t[42]=J):J=t[42];let Y;t[43]!==u||t[44]!==c||t[45]!==W||t[46]!==G||t[47]!==q||t[48]!==J?(Y=(0,Z.jsx)(oC,{id:kA,panelRef:c,defaultSize:W,minSize:`120px`,maxSize:`50%`,collapsible:!0,collapsedSize:0,onResize:G,inert:u,className:q,children:J}),t[43]=u,t[44]=c,t[45]=W,t[46]=G,t[47]=q,t[48]=J,t[49]=Y):Y=t[49];let ee;return t[50]!==V||t[51]!==H||t[52]!==Y?(ee=(0,Z.jsxs)(aC,{orientation:`vertical`,className:`min-h-0 flex-1`,"data-dragging":V,children:[H,U,Y]}),t[50]=V,t[51]=H,t[52]=Y,t[53]=ee):ee=t[53],ee}function jA(){return xA()}var MA=(0,Q.lazy)(async()=>({default:(await n(()=>import(`./ActivityModeContent-Csy-lYtm.js`),__vite__mapDeps([36,1,2,37,38,39,23,40,41,42,43,44,45,46,47,14,6,8,9,22,3,24,4,12,10,11,48,49,50]),import.meta.url)).ActivityModeContent}));function NA(e){let t=(0,$.c)(5),n;t[0]===e?n=t[1]:(n=(0,Z.jsx)(FA,{...e}),t[0]=e,t[1]=n);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(PA,{}),t[2]=r):r=t[2];let i;return t[3]===n?i=t[4]:(i=(0,Z.jsx)(Wt,{name:`editor-area`,children:(0,Z.jsxs)(US,{children:[n,r]})}),t[3]=n,t[4]=i),i}function PA(){let e=(0,$.c)(5),t=Gh(),n;e[0]===t?n=e[1]:(n=e=>{e||t.close()},e[0]=t,e[1]=n);let r;return e[2]!==t.open||e[3]!==n?(r=(0,Z.jsx)(eC,{open:t.open,onOpenChange:n}),e[2]=t.open,e[3]=n,e[4]=r):r=e[4],r}function FA(e){let t=(0,$.c)(148),{editorMode:n,onModeChange:r,activeTab:a,onActiveTabChange:o,terminalBridge:c,terminalVisible:l,onTerminalVisibleChange:u,terminalLaunch:d}=e,f=l===void 0?!1:l,p=d===void 0?null:d,{_:m}=i(),{activeDocName:h,activeProvider:g,activeTarget:_,recycleDocument:v,docPanelMode:y,docPanelAgentId:b,docPanelExpandSignal:S}=pt(),{openDocumentTransition:C}=wt(),{requestAddProperty:w}=GS(),T=kC(g,h),E=MC(h,n===`source`?`source`:`wysiwyg`),D=QC(g),O=D===`connected`||D===`synced`,k=jC(h)===`conflict`,A=(0,Q.useDeferredValue)(h),j=_?.kind===`missing`,M=!!h&&_?.kind!==`folder`,N;t[0]!==m||t[1]!==j?(N=j?m({id:`K-a33w`}):void 0,t[0]=m,t[1]=j,t[2]=N):N=t[2];let P=N,[F]=(0,Q.useState)(RA),I=F!==null,L;t[3]===F?L=t[4]:(L=()=>VC(F,window.innerWidth,`right`),t[3]=F,t[4]=L);let[R,z]=(0,Q.useState)(L),B=(0,Q.useRef)(R),V,H;t[5]===R?(V=t[6],H=t[7]):(V=()=>{B.current=R},H=[R],t[5]=R,t[6]=V,t[7]=H),(0,Q.useEffect)(V,H);let U=Vb(),W;t[8]===R?W=t[9]:(W=()=>XC(`right`,R,JC())===`collapsed`,t[8]=R,t[9]=W);let[G]=(0,Q.useState)(W),[K,q]=(0,Q.useState)(G),J=(0,Q.useRef)(K),Y,ee;t[10]===K?(Y=t[11],ee=t[12]):(Y=()=>{J.current=K},ee=[K],t[10]=K,t[11]=Y,t[12]=ee),(0,Q.useEffect)(Y,ee);let[te,ne]=(0,Q.useState)(!1),re=(0,Q.useRef)(!1),[ie]=(0,Q.useState)(LA),ae=(0,Q.useRef)(ie),oe=(0,Q.useRef)(null),se;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(se=function(e){oe.current!=null&&clearTimeout(oe.current),oe.current=setTimeout(()=>{IC(e),oe.current=null},100)},t[13]=se):se=t[13];let ce=se,le,ue;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>()=>{oe.current!=null&&clearTimeout(oe.current)},ue=[],t[14]=le,t[15]=ue):(le=t[14],ue=t[15]),(0,Q.useEffect)(le,ue);let[de,fe]=(0,Q.useState)(null),pe;t[16]!==K||t[17]!==U?(pe=function(){if(U.current==null)return;let e=B.current;K?(ZC(`right`,e,`open`),U.current?.expand()):(ZC(`right`,e,`collapsed`),U.current?.collapse())},t[16]=K,t[17]=U,t[18]=pe):pe=t[18];let me=pe,he,ge;t[19]!==F||t[20]!==U?(he=()=>{let e=window.matchMedia(`(min-width: ${zC}px)`),t=()=>{let e=VC(F,window.innerWidth,`right`);z(e);let t=XC(`right`,e,JC())===`collapsed`;q(t),t?U.current?.collapse():U.current?.expand()};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},ge=[F,U],t[19]=F,t[20]=U,t[21]=he,t[22]=ge):(he=t[21],ge=t[22]),(0,Q.useEffect)(he,ge);let _e,ve;t[23]!==de||t[24]!==I||t[25]!==U?(_e=()=>{if(de==null||I)return;let e=new ResizeObserver(()=>{J.current||re.current||U.current?.resize(`${ae.current}px`)});return e.observe(de),()=>e.disconnect()},ve=[de,I,U],t[23]=de,t[24]=I,t[25]=U,t[26]=_e,t[27]=ve):(_e=t[26],ve=t[27]),(0,Q.useEffect)(_e,ve);let ye,be;t[28]!==o||t[29]!==U?(ye=()=>{let e=e=>{o(e),U.current?.expand()},t=Gm();return t&&e(t),qm(t=>{Gm(),e(t)})},be=[o,U],t[28]=o,t[29]=U,t[30]=ye,t[31]=be):(ye=t[30],be=t[31]),(0,Q.useEffect)(ye,be);let xe,Se;t[32]!==S||t[33]!==U?(xe=()=>{S!==0&&U.current?.expand()},Se=[S,U],t[32]=S,t[33]=U,t[34]=xe,t[35]=Se):(xe=t[34],Se=t[35]),(0,Q.useEffect)(xe,Se);let Ce,we;t[36]===K?(Ce=t[37],we=t[38]):(Ce=()=>{if(!K||!document.getElementById(`doc-panel`)?.contains(document.activeElement))return;let e=document.querySelector(`[data-doc-panel-toggle]`);if(e){e.focus();return}document.querySelector(`[data-sidebar="trigger"]`)?.focus()},we=[K],t[36]=K,t[37]=Ce,t[38]=we),(0,Q.useLayoutEffect)(Ce,we);let Te,Ee;t[39]===K?(Te=t[40],Ee=t[41]):(Te=()=>{window.okDesktop!=null&&window.okDesktop.editor.notifyViewMenuStateChanged({docPanelVisible:!K})},Ee=[K],t[39]=K,t[40]=Te,t[41]=Ee),(0,Q.useEffect)(Te,Ee);let De,Oe;t[42]===me?(De=t[43],Oe=t[44]):(De=()=>{if(window.okDesktop!=null)return window.okDesktop.onMenuAction(e=>{e===`toggle-doc-panel`&&me()})},Oe=[me],t[42]=me,t[43]=De,t[44]=Oe),(0,Q.useEffect)(De,Oe);let ke,Ae;t[45]===me?(ke=t[46],Ae=t[47]):(ke=()=>{if(window.okDesktop!=null)return;let e=e=>{qs(e,`toggle-document-panel`)&&(e.preventDefault(),me())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},Ae=[me],t[45]=me,t[46]=ke,t[47]=Ae),(0,Q.useEffect)(ke,Ae);let je=(0,Q.useRef)(null),[Me,Ne]=(0,Q.useState)(null),Pe=_?.kind===`large-file`?_.docName:h,Fe,Ie;t[48]===Pe?(Fe=t[49],Ie=t[50]):(Fe=()=>{if(Pe&&Pe!==je.current){let e=je.current;je.current=Pe,Ne(e)}},Ie=[Pe],t[48]=Pe,t[49]=Fe,t[50]=Ie),(0,Q.useEffect)(Fe,Ie);let Le;t[51]===C?Le=t[52]:(Le=function(e){let t=Go(e);window.location.hash===t?C(e):window.location.hash=t},t[51]=C,t[52]=Le);let Re=Le;if(_?.kind===`large-file`){let e;t[53]!==Re||t[54]!==Me?(e=Me?{previousDocName:Me,onNavigateBack:Re}:void 0,t[53]=Re,t[54]=Me,t[55]=e):e=t[55];let n;return t[56]!==_.docName||t[57]!==_.limit||t[58]!==_.size||t[59]!==e?(n=(0,Z.jsx)(zS,{docName:_.docName,size:_.size,limit:_.limit,backNav:e}),t[56]=_.docName,t[57]=_.limit,t[58]=_.size,t[59]=e,t[60]=n):n=t[60],n}if(_?.kind===`folder`){if(!(y===`agent`&&b!==null)){let e;return t[61]===_.folderPath?e=t[62]:(e=(0,Z.jsx)(FS,{folderPath:_.folderPath}),t[61]=_.folderPath,t[62]=e),e}let e;t[63]===_.folderPath?e=t[64]:(e=(0,Z.jsx)(oC,{minSize:`30%`,defaultSize:`75%`,children:(0,Z.jsx)(FS,{folderPath:_.folderPath})}),t[63]=_.folderPath,t[64]=e);let n;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(sC,{withHandle:!0}),t[65]=n):n=t[65];let r;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(oC,{defaultSize:`25%`,minSize:`300px`,maxSize:`40%`,className:`flex flex-col bg-muted/20`,children:(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(`div`,{role:`status`,"aria-busy":`true`,className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:(0,Z.jsx)(s,{id:`ONPvOb`})}),children:(0,Z.jsx)(MA,{showBackButton:!1})})}),t[66]=r):r=t[66];let i;return t[67]===e?i=t[68]:(i=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,Z.jsxs)(aC,{orientation:`horizontal`,children:[e,n,r]})}),t[67]=e,t[68]=i),i}if(_?.kind===`asset`){let e;return t[69]!==_.assetPath||t[70]!==_.mediaKind?(e=(0,Z.jsx)(ex,{assetPath:_.assetPath,mediaKind:_.mediaKind},_.assetPath),t[69]=_.assetPath,t[70]=_.mediaKind,t[71]=e):e=t[71],e}if(!g||!h){if((typeof window<`u`?Po(window.location.hash):null)!==null){let e;return t[72]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(tx,{}),t[72]=e):e=t[72],e}let e;return t[73]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(tS,{}),t[73]=e):e=t[73],e}let ze=n===`source`,Ve=!O,He=K,Ue;t[74]!==h||t[75]!==w?(Ue=function(){h&&w(h)},t[74]=h,t[75]=w,t[76]=Ue):Ue=t[76];let We=Ue,Ge=A??h,Ke=Me??void 0,qe;t[77]!==P||t[78]!==ze||t[79]!==Re||t[80]!==v||t[81]!==Ge||t[82]!==Ke?(qe=(0,Z.jsx)(rk,{activeDocName:Ge,isSourceMode:ze,editorPlaceholder:P,previousDocName:Ke,onNavigateBack:Re,onRecycle:v}),t[77]=P,t[78]=ze,t[79]=Re,t[80]=v,t[81]=Ge,t[82]=Ke,t[83]=qe):qe=t[83];let Je;t[84]!==h||t[85]!==ze?(Je=(0,Z.jsx)(TC,{activeDocName:h,isSourceMode:ze}),t[84]=h,t[85]=ze,t[86]=Je):Je=t[86];let Ye;t[87]!==h||t[88]!==A?(Ye=pA({activeDocName:h,deferredActiveDocName:A,mountResolved:h!==null&&x(h),syncResolved:h!==null&&Be(h)})?(0,Z.jsxs)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:[(0,Z.jsx)(tx,{}),h===null?null:(0,Z.jsx)(BS,{docName:h})]}):null,t[87]=h,t[88]=A,t[89]=Ye):Ye=t[89];let Xe;t[90]!==qe||t[91]!==Je||t[92]!==Ye?(Xe=(0,Z.jsxs)(`div`,{className:`relative h-full`,children:[qe,Je,Ye]}),t[90]=qe,t[91]=Je,t[92]=Ye,t[93]=Xe):Xe=t[93];let Ze;t[94]!==h||t[95]!==k||t[96]!==He||t[97]!==ze||t[98]!==r||t[99]!==We||t[100]!==Ve||t[101]!==me?(Ze=!k&&(0,Z.jsx)(fA,{activeDocName:h,isSourceMode:ze,sourceDisabled:Ve,onModeChange:r,showAddPropertyButton:!ze,onAddProperty:We,isPanelCollapsed:He,onTogglePanel:me}),t[94]=h,t[95]=k,t[96]=He,t[97]=ze,t[98]=r,t[99]=We,t[100]=Ve,t[101]=me,t[102]=Ze):Ze=t[102];let Qe;t[103]!==Xe||t[104]!==Ze?(Qe=(0,Z.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[Xe,Ze]}),t[103]=Xe,t[104]=Ze,t[105]=Qe):Qe=t[105];let $e;t[106]!==E||t[107]!==M||t[108]!==T?($e=(0,Z.jsx)(Xk,{stats:T,selectionStats:E,showStats:M}),t[106]=E,t[107]=M,t[108]=T,t[109]=$e):$e=t[109];let et;t[110]!==Qe||t[111]!==$e?(et=(0,Z.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[Qe,$e]}),t[110]=Qe,t[111]=$e,t[112]=et):et=t[112];let tt=et,nt;t[113]!==tt||t[114]!==u||t[115]!==c||t[116]!==p||t[117]!==f?(nt=c==null?tt:(0,Z.jsx)(AA,{bridge:c,visible:f,onVisibleChange:u??IA,launch:p,children:tt}),t[113]=tt,t[114]=u,t[115]=c,t[116]=p,t[117]=f,t[118]=nt):nt=t[118];let rt=nt,it=te||void 0,at;t[119]===G?at=t[120]:(at=G?{defaultSize:`100%`}:{},t[119]=G,t[120]=at);let ot=te?void 0:`transition-[flex-grow] duration-200 ease-out motion-reduce:transition-none motion-reduce:duration-0`,st;t[121]!==rt||t[122]!==at||t[123]!==ot?(st=(0,Z.jsx)(oC,{minSize:`30%`,...at,className:ot,children:rt}),t[121]=rt,t[122]=at,t[123]=ot,t[124]=st):st=t[124];let ct=I&&K,lt;t[125]===Symbol.for(`react.memo_cache_sentinel`)?(lt=()=>{ne(!0),re.current=!0;let e=()=>{ne(!1),re.current=!1,window.removeEventListener(`pointerup`,e)};window.addEventListener(`pointerup`,e)},t[125]=lt):lt=t[125];let ut;t[126]===ct?ut=t[127]:(ut=(0,Z.jsx)(sC,{withHandle:!0,disabled:ct,onPointerDown:lt}),t[126]=ct,t[127]=ut);let dt=G?0:`${ie}px`,ft;t[128]===Symbol.for(`react.memo_cache_sentinel`)?(ft=e=>{q(e.asPercentage===0),e.inPixels>0&&re.current&&(ae.current=e.inPixels,ce(e.inPixels))},t[128]=ft):ft=t[128];let mt=!te&&`transition-[flex-grow] duration-200 ease-out motion-reduce:transition-none motion-reduce:duration-0`,ht;t[129]===mt?ht=t[130]:(ht=ai(`flex flex-col bg-muted/20`,mt),t[129]=mt,t[130]=ht);let gt;t[131]!==h||t[132]!==a||t[133]!==y||t[134]!==ze||t[135]!==o?(gt=(0,Z.jsx)(qv,{docName:h,isSourceMode:ze,activeTab:a,onActiveTabChange:o,mode:y}),t[131]=h,t[132]=a,t[133]=y,t[134]=ze,t[135]=o,t[136]=gt):gt=t[136];let _t;t[137]!==K||t[138]!==U||t[139]!==dt||t[140]!==ht||t[141]!==gt?(_t=(0,Z.jsx)(oC,{id:`doc-panel`,panelRef:U,defaultSize:dt,minSize:`300px`,maxSize:`600px`,collapsible:!0,collapsedSize:0,onResize:ft,inert:K,className:ht,children:gt}),t[137]=K,t[138]=U,t[139]=dt,t[140]=ht,t[141]=gt,t[142]=_t):_t=t[142];let vt;return t[143]!==it||t[144]!==st||t[145]!==ut||t[146]!==_t?(vt=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1`,ref:fe,children:(0,Z.jsxs)(aC,{orientation:`horizontal`,"data-dragging":it,children:[st,ut,_t]})}),t[143]=it,t[144]=st,t[145]=ut,t[146]=_t,t[147]=vt):vt=t[147],vt}function IA(){}function LA(){return LC()}function RA(){return Er()}function zA(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.kind!==i.kind)return!1;if(r.kind===`human`&&i.kind===`human`){if(r.clientId!==i.clientId||r.mode!==i.mode||r.tabCount!==i.tabCount)return!1;let e=r.user,t=i.user;if(e.name!==t.name||e.color!==t.color||e.icon!==t.icon)return!1}else if(r.kind===`agent`&&i.kind===`agent`){if(r.agentId!==i.agentId)return!1;let e=r.presence,t=i.presence;if(e.displayName!==t.displayName||e.icon!==t.icon||e.color!==t.color||e.currentDoc!==t.currentDoc||e.mode!==t.mode)return!1}}return!0}function BA(e){let t=new Map;for(let n of e){let e=n.user.principalId;if(typeof e==`string`&&e.length>0){let r=t.get(e);r?r.push(n):t.set(e,[n])}}let n=new Map;for(let[e,r]of t){let t=r.reduce((e,t)=>Math.min(e,t.clientId),1/0);n.set(e,{repClientId:t,count:r.length})}let r=[];for(let t of e){let e=t.user.principalId;if(typeof e==`string`&&e.length>0){let i=n.get(e);i&&i.repClientId===t.clientId&&r.push({...t,tabCount:i.count})}else r.push({...t,tabCount:1})}return r}var VA=1e3,HA=!1;function UA(e){return!!(e.localPrincipalId&&e.entryPrincipalId===e.localPrincipalId||!e.localPrincipalId&&e.entryClientId===e.localClientId)}function WA(e,t,n){let r=(0,$.c)(9),i;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={current:[],crossDoc:[]},r[0]=i):i=r[0];let[a,o]=(0,Q.useState)(i),s;r[1]!==n||r[2]!==e?.awareness||r[3]!==t?.awareness?(s=()=>{let r=e?.awareness,i=t?.awareness,a;i==null?a=void 0:xi(i)?a=i:(a=void 0,HA||(HA=!0,console.warn(`[agent-presence] __system__ provider awareness missing getStates() — presence bar will render without agent peers`)));let s=()=>{let e=(r?.getLocalState())?.user?.principalId??null,t=r?.clientID??null,i=[];if(r)for(let[n,a]of r.getStates().entries()){let r=a;if(!r.user||typeof r.user!=`object`)continue;let o=r.user;o.type===`human`&&(UA({entryPrincipalId:o.principalId,entryClientId:n,localPrincipalId:e,localClientId:t})||i.push({kind:`human`,clientId:n,user:o,mode:r.mode??`wysiwyg`,tabCount:1}))}let s=BA(i),{current:c,crossDoc:l}=a?gi(a,n,Date.now()):{current:[],crossDoc:[]},u=GA,d=c.map(u),f=l.map(u),p=[...s,...d],m=f;o(e=>zA(e.current,p)&&zA(e.crossDoc,m)?e:{current:p,crossDoc:m})};s();let c=()=>s(),l=()=>s();r?.on(`change`,c),t?.awareness?.on(`change`,l);let u=setInterval(s,VA);return()=>{r?.off(`change`,c),t?.awareness?.off(`change`,l),clearInterval(u)}},r[1]=n,r[2]=e?.awareness,r[3]=t?.awareness,r[4]=s):s=r[4];let c;return r[5]!==n||r[6]!==e||r[7]!==t?(c=[e,t,n],r[5]=n,r[6]=e,r[7]=t,r[8]=c):c=r[8],(0,Q.useEffect)(s,c),a}function GA(e){let{agentId:t,entry:n}=e;return{kind:`agent`,agentId:t,presence:n}}var KA=`sync-status`;function qA(e,t){let n=(0,$.c)(6),{_:r}=i(),a=Ap(),o=(0,Q.useRef)(!1),s=(0,Q.useRef)(!1),c=(0,Q.useRef)(t),l,u;n[0]!==r||n[1]!==t||n[2]!==a||n[3]!==e?(l=()=>{if(c.current!==t&&(c.current=t,o.current=!1,s.current=!1),t)if(e===`synced`&&(o.current=!0),e===`disconnected`&&o.current){if(a){X.dismiss(KA);return}s.current=!0,X.warning(r({id:`HGNCsl`}),{id:KA,duration:1/0})}else s.current&&e===`synced`&&(s.current=!1,X.success(r({id:`GhjUB_`}),{id:KA,duration:3e3}))},u=[e,t,r,a],n[0]=r,n[1]=t,n[2]=a,n[3]=e,n[4]=l,n[5]=u):(l=n[4],u=n[5]),(0,Q.useEffect)(l,u)}var JA=4,YA=3,XA={Bird:Gc,Cat:Zc,Dog:il,Fish:ll,Mouse:Il,Rabbit:Fl,Shrimp:Hl,Snail:Ul,Squirrel:ql,Turtle:tu};Object.freeze(Object.keys(XA));function ZA(e){if(typeof e.principalId==`string`&&e.principalId.length>0)return{kind:`initials`};let t=e.name.split(` `)[1];return t&&Object.hasOwn(XA,t)?{kind:`animal`,animal:t}:{kind:`initials`}}var QA={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function $A(e){let t=(0,$.c)(28),{user:n,mode:r,tabCount:a}=e,{_:o}=i(),s=ZA(n),c=s.kind===`animal`?XA[s.animal]:void 0,l;t[0]===n.name?l=t[1]:(l=tr(n.name),t[0]=n.name,t[1]=l);let u=l,d;t[2]===n.color?d=t[3]:(d=Hr(n.color),t[2]=n.color,t[3]=d);let f=d,p=n.name,m;t[4]!==o||t[5]!==a||t[6]!==p?(m=a>1?o({id:`qAhFeg`,values:{userName:p,tabCount:a}}):p,t[4]=o,t[5]=a,t[6]=p,t[7]=m):m=t[7];let h=m,g;t[8]!==o||t[9]!==a||t[10]!==p?(g=a>1?o({id:`BEkF-P`,values:{userName:p,tabCount:a}}):p,t[8]=o,t[9]=a,t[10]=p,t[11]=g):g=t[11];let _=g,v;t[12]===n.color?v=t[13]:(v={backgroundColor:n.color},t[12]=n.color,t[13]=v);let y;t[14]!==c||t[15]!==f||t[16]!==u?(y=c?(0,Z.jsx)(c,{size:18,color:f,strokeWidth:1.5}):(0,Z.jsx)(`span`,{className:`font-mono text-2xs font-semibold leading-none`,style:{color:f},children:u}),t[14]=c,t[15]=f,t[16]=u,t[17]=y):y=t[17];let b;t[18]!==_||t[19]!==r||t[20]!==v||t[21]!==y?(b=(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(`div`,{"data-presence-badge":`human`,"data-presence-mode":r,role:`img`,"aria-label":_,className:`inline-flex size-7 shrink-0 cursor-default items-center justify-center rounded-full ring-2 ring-background`,style:v,children:y})}),t[18]=_,t[19]=r,t[20]=v,t[21]=y,t[22]=b):b=t[22];let x;t[23]===h?x=t[24]:(x=(0,Z.jsx)(Ds,{children:h}),t[23]=h,t[24]=x);let S;return t[25]!==b||t[26]!==x?(S=(0,Z.jsxs)(As,{children:[b,x]}),t[25]=b,t[26]=x,t[27]=S):S=t[27],S}function ej(e){let t=QA[e.icon];return e.displayName||t||Ko._({id:`iEQQyu`})}function tj(e){let t=(0,$.c)(3),[n,r]=(0,Q.useState)(e===`writing`),i=(0,Q.useRef)(null),a,o;return t[0]===e?(a=t[1],o=t[2]):(a=()=>{if(e===`writing`){i.current!==null&&(clearTimeout(i.current),i.current=null),r(!0);return}return i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>{i.current=null,r(!1)},600),()=>{i.current!==null&&(clearTimeout(i.current),i.current=null)}},o=[e],t[0]=e,t[1]=a,t[2]=o),(0,Q.useEffect)(a,o),n}function nj(e){let t=(0,$.c)(33),{participant:n,crossDoc:r,scoped:a,onClickAgent:o}=e,{_:c}=i(),{activeDocName:l}=pt(),{presence:u,agentId:d}=n,f=ej(u),p=tj(u.mode),m=!r&&p,h=u.currentDoc&&u.currentDoc!==`(connected)`?u.currentDoc:null,g=l!==null||h!==null,_=g?`cursor-pointer`:`cursor-default opacity-50`,v=a?`ring-primary ring-offset-2 ring-offset-background`:`ring-background`,y=m&&!a?`ring-primary/40 animate-pulse`:``,b;t[0]!==_||t[1]!==v||t[2]!==y?(b=[`inline-flex size-7 shrink-0 items-center justify-center rounded-full ring-2`,_,v,y].filter(Boolean),t[0]=_,t[1]=v,t[2]=y,t[3]=b):b=t[3];let x=b.join(` `),S=r?`true`:void 0,C=a?`true`:void 0,w=g?void 0:`true`,T;t[4]!==u.mode||t[5]!==S||t[6]!==C||t[7]!==w?(T={"data-presence-badge":`agent`,"data-presence-mode":u.mode,"data-presence-crossdoc":S,"data-presence-scoped":C,"data-presence-inert":w},t[4]=u.mode,t[5]=S,t[6]=C,t[7]=w,t[8]=T):T=t[8];let E=T,D=c(r&&h?{id:`b4AQFK`,values:{tooltipName:f,realCurrentDoc:h}}:{id:`RfHNf8`,values:{tooltipName:f}}),O;t[9]!==d||t[10]!==D||t[11]!==E||t[12]!==g||t[13]!==o||t[14]!==u.color||t[15]!==u.icon||t[16]!==h||t[17]!==x||t[18]!==f?(O=g?(0,Z.jsx)(`button`,{type:`button`,...E,"aria-label":D,className:x,style:{backgroundColor:u.color},onClick:()=>o(d,h),children:(0,Z.jsx)(yi,{icon:u.icon,width:16,height:16,className:`text-white`,"aria-hidden":!0})}):(0,Z.jsx)(`div`,{...E,role:`img`,"aria-label":f,className:x,style:{backgroundColor:u.color},children:(0,Z.jsx)(yi,{icon:u.icon,width:16,height:16,className:`text-white`,"aria-hidden":!0})}),t[9]=d,t[10]=D,t[11]=E,t[12]=g,t[13]=o,t[14]=u.color,t[15]=u.icon,t[16]=h,t[17]=x,t[18]=f,t[19]=O):O=t[19];let k=O,A;t[20]===k?A=t[21]:(A=(0,Z.jsx)(Ts,{asChild:!0,children:k}),t[20]=k,t[21]=A);let j;t[22]===f?j=t[23]:(j=(0,Z.jsx)(`span`,{className:`font-medium`,children:f}),t[22]=f,t[23]=j);let M;t[24]!==r||t[25]!==h?(M=r&&h?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:(0,Z.jsx)(s,{id:`Wh0im4`,values:{realCurrentDoc:h}})}):null,t[24]=r,t[25]=h,t[26]=M):M=t[26];let N;t[27]!==j||t[28]!==M?(N=(0,Z.jsxs)(Ds,{className:`flex flex-col gap-0.5`,children:[j,M]}),t[27]=j,t[28]=M,t[29]=N):N=t[29];let P;return t[30]!==A||t[31]!==N?(P=(0,Z.jsxs)(As,{children:[A,N]}),t[30]=A,t[31]=N,t[32]=P):P=t[32],P}function rj(e){let t=(0,$.c)(21),{count:n,remainder:r,crossDoc:i,scopedAgentId:a,onClickAgent:o}=e,s;t[0]!==n||t[1]!==i?(s=i?Ko._({id:`9euN0m`,values:{count:n}}):Ko._({id:`uhJEA2`,values:{count:n}}),t[0]=n,t[1]=i,t[2]=s):s=t[2];let c=s,l=i?`true`:void 0,u;t[3]!==n||t[4]!==c||t[5]!==l?(u=(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`presence-overflow`,"data-presence-crossdoc":l,className:`inline-flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-full bg-muted font-medium text-muted-foreground text-xs ring-2 ring-background hover:bg-muted/80`,"aria-label":c,children:[`+`,n]})}),t[3]=n,t[4]=c,t[5]=l,t[6]=u):u=t[6];let d;if(t[7]!==i||t[8]!==o||t[9]!==r||t[10]!==a){let e;t[12]!==i||t[13]!==o||t[14]!==a?(e=e=>e.kind===`human`?(0,Z.jsx)($A,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(nj,{participant:e,crossDoc:i,scoped:a===e.agentId,onClickAgent:o},e.agentId),t[12]=i,t[13]=o,t[14]=a,t[15]=e):e=t[15],d=r.map(e),t[7]=i,t[8]=o,t[9]=r,t[10]=a,t[11]=d}else d=t[11];let f;t[16]===d?f=t[17]:(f=(0,Z.jsx)(b,{align:`end`,className:`w-auto max-w-xs p-2`,children:(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:d})}),t[16]=d,t[17]=f);let p;return t[18]!==u||t[19]!==f?(p=(0,Z.jsxs)(pe,{children:[u,f]}),t[18]=u,t[19]=f,t[20]=p):p=t[20],p}function ij(e,t,n,r){return e.kind===`human`?(0,Z.jsx)($A,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(nj,{participant:e,crossDoc:n,scoped:r===e.agentId,onClickAgent:t},e.agentId)}function aj(){let e=(0,$.c)(20),{activeProvider:t,activeDocName:n,systemProvider:r,openActivityPanel:i,docPanelMode:a,docPanelAgentId:o}=pt(),{current:s,crossDoc:c}=WA(t,r,n);if(qA(QC(t),n),s.length===0&&c.length===0)return null;let l;if(e[0]!==c||e[1]!==s||e[2]!==o||e[3]!==a||e[4]!==i){let t=s.slice(0,JA),n;e[6]===s?n=e[7]:(n=s.slice(JA),e[6]=s,e[7]=n);let r=n,u=c.slice(0,YA),d;e[8]===c?d=e[9]:(d=c.slice(YA),e[8]=c,e[9]=d);let f=d,p=i,m=a===`agent`?o:null,h;e[10]!==p||e[11]!==m?(h=e=>ij(e,p,!1,m),e[10]=p,e[11]=m,e[12]=h):h=e[12];let g=t.map(h),_;e[13]!==r||e[14]!==p||e[15]!==m?(_=r.length>0?(0,Z.jsx)(rj,{count:r.length,remainder:r,crossDoc:!1,scopedAgentId:m,onClickAgent:p}):null,e[13]=r,e[14]=p,e[15]=m,e[16]=_):_=e[16];let v;e[17]!==g||e[18]!==_?(v=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,"data-presence-section":`current`,children:[g,_]}),e[17]=g,e[18]=_,e[19]=v):v=e[19],l=(0,Z.jsxs)(`div`,{"data-slot":`presence-bar`,className:`flex items-center px-1 py-1.5`,children:[v,c.length>0?(0,Z.jsxs)(`div`,{className:`ml-1.5 flex items-center gap-1.5`,"data-presence-section":`crossdoc`,children:[u.map(e=>ij(e,p,!0,m)),f.length>0?(0,Z.jsx)(rj,{count:f.length,remainder:f,crossDoc:!0,scopedAgentId:m,onClickAgent:p}):null]}):null]}),e[0]=c,e[1]=s,e[2]=o,e[3]=a,e[4]=i,e[5]=l}else l=e[5];return l}function oj(e){let t=e.lastIndexOf(`/`),n=t<0?e:e.slice(t+1),r=n.lastIndexOf(`.`);return r<=0?``:n.slice(r)}function sj(e,t){let n=e.lastIndexOf(`/`),r=n<0?``:e.slice(0,n+1),i=n<0?e:e.slice(n+1),a=i.lastIndexOf(`.`);return`${r}${a<=0?i:i.slice(0,a)}${t}`}function cj(e,t,n,r=!1){if(n)return{kind:`allow`,destinationPath:t};let i=oj(e);if(i===``)return{kind:`allow`,destinationPath:t};let a=oj(t);return r?{kind:`allow`,destinationPath:a?t:sj(t,i)}:a&&a.toLowerCase()!==i.toLowerCase()?{kind:`block`}:{kind:`allow`,destinationPath:sj(t,i)}}var lj=`.md`,uj=/\.(md|mdx)$/i;function dj(e,t=lj){return`${e}${t}`}function fj(e){return zj(e).replace(uj,``)}function pj(e){return Jo(e)?gj(e.path):Io(e)?e.path:dj(e.docName,e.docExt)}function mj(e){let t=zj(e).match(uj);return t?`.${t[1].toLowerCase()}`:void 0}function hj(e){return zj(e)}function gj(e){let t=zj(e.trim());return t?`${t}/`:``}function _j(e){return e.endsWith(`/`)?hj(e):fj(e)}function vj(e){return e.map(pj)}function yj(e){return[...e].sort().join(`\0`)}function bj(e){return yj(vj(e))}function xj(e){let t=new Set;for(let n of e){if(Jo(n)){let e=gj(n.path);e&&t.add(e)}let e=(Jo(n)||Io(n)?n.path:n.docName).split(`/`).filter(Boolean),r=Jo(n)?e.length:e.length-1;for(let n=1;n<=r;n++)t.add(`${e.slice(0,n).join(`/`)}/`)}return[...t].sort()}function Sj(e){if(!e)return[];let t=zj(e.replace(uj,``)).split(`/`).filter(Boolean),n=[],r=e.endsWith(`/`)?t.length:t.length-1;for(let e=1;e<=r;e++)n.push(`${t.slice(0,e).join(`/`)}/`);return n}function Cj(e,t,n){let r=mj(e);if(r)return r;let i=n.find(e=>ls(e)&&e.docName===t);return i?i.docExt??lj:Rj(e).includes(`.`)?void 0:lj}function wj(e,t){let n=e.lastIndexOf(`/`),r=n===-1?``:e.slice(0,n+1),i=n===-1?e:e.slice(n+1),a=t.filter(e=>{if(!Io(e)||!e.path.startsWith(r))return!1;let t=e.path.slice(r.length);return!t.includes(`/`)&&t.startsWith(`${i}.`)});return a.length===1?a[0].path:null}function Tj(e,t,n){if(mj(e))return null;let r=n.find(e=>Io(e)&&e.path===t);return r?r.path:Rj(e).includes(`.`)?t:wj(t,n)}function Ej(e,t){let n=e.kind===`directory`,r=n?hj(e.path):fj(e.path);if(n)return{kind:`folder`,name:zj(Rj(e.path)).replace(uj,``),path:r,treePath:Oj(e.path,!0)};let i=Tj(e.path,r,t);if(i)return{kind:`asset`,name:zj(Rj(i)),path:i,treePath:i};let a=Cj(e.path,r,t);return{kind:`file`,name:zj(Rj(e.path)).replace(uj,``),path:r,treePath:Oj(e.path,!1),docExt:a}}function Dj(e){return e.kind===`directory`?hj(e.path):e.path}function Oj(e,t){return t?gj(e):uj.test(e)?e:`${e}${lj}`}function kj(e,t,n){let r=gj(t),i=new Set(n);for(let t=0;t<100;t++){let n=t===0?``:` ${t+1}`;if(e===`file`){let e=`${r}Untitled${n}${lj}`;if(!i.has(e))return{addPath:e,renamePath:e};continue}let a=`${r}New Folder${n}/`;if(!i.has(a))return{addPath:a,renamePath:a}}throw Error(`Could not allocate a unique tree placeholder`)}function Aj(e,t){return e===`file`?Oj(t,!1):`${hj(t)}/index${lj}`}function jj(e,t){return t.kind===`root`||t.directoryPath==null?Rj(e):`${t.directoryPath}${Rj(e)}`}function Mj(e,t){if(t)return hj(gj(e));let n=fj(e),r=n.lastIndexOf(`/`);return r===-1?``:n.slice(0,r)}function Nj(e,t){let n=hj(gj(e));return n?`${n}/${t}`:t}function Pj(e,t){return(t.path??Nj(e,t.src)).replace(/^\/+/,``)}function Fj(e){let t=e.dataTransfer?.types;if(!t)return!1;let n=Array.from(t);return n.includes(`Files`)&&!n.includes(`application/x-open-knowledge-sidebar-item+json`)}function Ij(e){return Array.from(e.dataTransfer?.files??[]).filter(e=>e.name.length>0||e.size>0)}function Lj(e,t){let n=oj(e).toLowerCase();if(n===``)return null;let r=new Date().toISOString();if(n===`.md`||n===`.mdx`)return{kind:`document`,docName:fj(e),docExt:n,modified:r,size:t.size};let i=n.startsWith(`.`)?n.slice(1):n;return{kind:`asset`,path:e,assetExt:i,mediaKind:rr(i),modified:r,size:t.size}}function Rj(e){let t=zj(e),n=t.lastIndexOf(`/`),r=n===-1?t:t.slice(n+1);return e.endsWith(`/`)?`${r}/`:r}function zj(e){return e.endsWith(`/`)?e.slice(0,-1):e}function Bj(e,t){return t.trim()}function Vj(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function Hj(e,t){let n=Bj(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function Uj(e,t,n=[],r=[]){if(t.length===0&&n.length===0&&r.length===0)return e;let i=new Map(t.map(e=>[e.fromDocName,e.toDocName])),a=new Map(r.map(e=>[e.fromPath,e.toPath]));return e.map(e=>ls(e)?{...e,docName:i.get(e.docName)??e.docName}:Jo(e)?{...e,path:Xj(e.path,n)}:Io(e)?{...e,path:a.get(e.path)??Xj(e.path,n)}:e)}function Wj(e,t,n,r=[]){if(t.length===0&&!n&&r.length===0)return e;let i=new Set(t),a=new Set(r);return e.filter(e=>ls(e)?!i.has(e.docName)&&!eM(e.docName,n):Jo(e)?!eM(e.path,n):Io(e)?!a.has(e.path)&&!eM(e.path,n):!0)}function Gj(e,t){if(e.kind!==`asset`||t.some(t=>Io(t)&&t.path===e.path))return e;let n=wj(e.path,t);return n?{...e,path:n,name:n.split(`/`).pop()??n}:e}function Kj(e,t,n,r=new Date().toISOString()){let i=!1,a=[...e],o=e=>{a.some(t=>Zj(t,e))||(a.push(e),i=!0)};if(n.kind===`file`){let s=e.find(e=>ls(e)&&e.docName===t.path);return o({kind:`document`,docName:n.path,docExt:s?.docExt??t.docExt,size:s?.size??0,modified:r}),i?a:e}let s=e.find(e=>Jo(e)&&e.path===t.path);o({kind:`folder`,path:n.path,size:s?.size??0,modified:r});let c=new Set(n.duplicatedDocNames);for(let i of e){if(ls(i)){let e=$j(i.docName,t.path,n.path);e&&c.has(e)&&o({...i,docName:e,modified:r});continue}if(Jo(i)){let e=Qj(i.path,t.path,n.path);e&&o({...i,path:e,modified:r})}}return i?a:e}function qj(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}function Jj(e,t,n){return e.flatMap(e=>t===e.toDocName||!n(e.toDocName)?[e.fromDocName]:[e.fromDocName,e.toDocName])}function Yj(e,t){let n=e.kind===`file`?dj(e.path,e.docExt):e.path;return gg(t.contentDir,n,t.pathSeparator)}function Xj(e,t){for(let{fromPath:n,toPath:r}of t){if(e===n)return r;if(e.startsWith(`${n}/`))return`${r}${e.slice(n.length)}`}return e}function Zj(e,t){return ls(e)&&ls(t)?e.docName===t.docName:Jo(e)&&Jo(t)||Io(e)&&Io(t)?e.path===t.path:!1}function Qj(e,t,n){return e===t?n:$j(e,t,n)}function $j(e,t,n){return e.startsWith(`${t}/`)?`${n}${e.slice(t.length)}`:null}function eM(e,t){return!!t&&(e===t||e.startsWith(`${t}/`))}function tM(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Z.jsx)(nd,{"data-slot":`context-menu`,...n}),t[2]=n,t[3]=r),r}function nM(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`select-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(rd,{"data-slot":`context-menu-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function rM(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Z.jsx)(ud,{"data-slot":`context-menu-sub`,...n}),t[2]=n,t[3]=r),r}function iM(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`z-50 max-h-(--radix-context-menu-content-available-height) min-w-36 origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 motion-reduce:data-open:animate-none motion-reduce:data-closed:animate-none motion-reduce:duration-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(id,{children:(0,Z.jsx)(ad,{"data-slot":`context-menu-content`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function aM(e){let t=(0,$.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,inset:r,variant:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?`default`:a,s;t[5]===n?s=t[6]:(s=ai(`group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive`,n),t[5]=n,t[6]=s);let c;return t[7]!==r||t[8]!==i||t[9]!==s||t[10]!==o?(c=(0,Z.jsx)(od,{"data-slot":`context-menu-item`,"data-inset":r,"data-variant":o,className:s,...i}),t[7]=r,t[8]=i,t[9]=s,t[10]=o,t[11]=c):c=t[11],c}function oM(e){let t=(0,$.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,inset:i,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=ai(`flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,r),t[5]=r,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(jo,{className:`ml-auto`}),t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==a||t[11]!==o?(c=(0,Z.jsxs)(dd,{"data-slot":`context-menu-sub-trigger`,"data-inset":i,className:o,...a,children:[n,s]}),t[8]=n,t[9]=i,t[10]=a,t[11]=o,t[12]=c):c=t[12],c}function sM(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`z-50 max-h-(--radix-context-menu-content-available-height) min-w-32 origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg border bg-popover p-1 text-popover-foreground shadow-lg data-[state=closed]:overflow-hidden duration-100 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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 motion-reduce:data-open:animate-none motion-reduce:data-closed:animate-none motion-reduce:duration-0 subtle-scrollbar`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(fd,{"data-slot":`context-menu-sub-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function cM(e){let t=(0,$.c)(15),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:i,children:r,checked:n,inset:a,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===i?s=t[7]:(s=ai(`relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,i),t[6]=i,t[7]=s);let c;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(`span`,{className:`pointer-events-none absolute right-2`,children:(0,Z.jsx)(cd,{children:(0,Z.jsx)(Do,{})})}),t[8]=c):c=t[8];let l;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==s?(l=(0,Z.jsxs)(sd,{"data-slot":`context-menu-checkbox-item`,"data-inset":a,className:s,checked:n,...o,children:[c,r]}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=s,t[14]=l):l=t[14],l}function lM(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`-mx-1 my-1 h-px bg-border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(ld,{"data-slot":`context-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var uM=`mr-1.5 flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm text-muted-foreground outline-none transition hover:bg-foreground/10 hover:text-foreground hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/50`,dM=`border-border bg-background text-foreground hover:bg-background focus-visible:bg-background`,fM={start:[Ui.Space],cancel:[Ui.Esc],end:[Ui.Space,Ui.Enter]};function pM(e){return ai(uM,e?`opacity-100`:`pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100`)}function mM(e){return e?void 0:-1}function hM({className:e,isDragging:t}){return ai(e,t&&dM)}function gM(e){return e.code===Ui.Enter&&e.target===e.currentTarget}function _M({event:e,hasKeyboardActivation:t,isDragging:n}){return e.defaultPrevented?`ignore`:!n&&t&&gM(e)?`activate-tab`:`delegate-sortable`}function vM({activeWidth:e,isDragging:t,outerStyle:n,transform:r,transition:i}){let a=t&&e?e:void 0;return{...n,transform:ja.Transform.toString(r?{...r,scaleX:1,scaleY:1}:null),transition:i,flexBasis:a??n?.flexBasis,maxWidth:a??n?.maxWidth,minWidth:a??n?.minWidth,opacity:n?.opacity,width:a??n?.width,zIndex:t?20:n?.zIndex}}function yM(e){let t=e?.querySelectorAll(`[data-editor-tab-sortable]`)??[],n=1/0,r=-1/0;for(let e of t){let t=e.getBoundingClientRect();n=Math.min(n,t.left),r=Math.max(r,t.right)}return Number.isFinite(n)&&Number.isFinite(r)?{left:n,right:r}:null}function bM(e){return({activeNodeRect:t,transform:n})=>{let r={...n,y:0};if(!e||!t)return r;let i=e.left-t.left,a=e.right-t.right;return r.x=Math.min(Math.max(r.x,i),a),r}}var xM=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(r){let e=1/0,i=-1/0,a=null,o=null;for(let r of t){let t=n.get(r.id);t&&(t.left<e&&(e=t.left,a=r),t.right>i&&(i=t.right,o=r))}if(!Number.isFinite(e)||!Number.isFinite(i))return[];let s=r.x<e?a:r.x>i?o:null;if(s)return[{id:s.id,data:{droppableContainer:s,value:0}}]}return xa(e)},SM=[`.md`,`.mdx`],CM=`group relative -mb-px flex h-10 min-w-28 max-w-64 shrink-0 cursor-pointer items-center overflow-hidden border border-transparent font-medium transition-colors`,wM=`z-10 rounded-t-lg rounded-b-none border-border border-b-0 bg-background text-foreground`,TM=ai(wM,`bg-transparent hover:bg-muted focus-visible:bg-muted border-transparent hover:border-border focus-visible:border-border`),EM=`flex h-full min-w-0 flex-1 cursor-pointer items-center overflow-hidden px-3 text-left text-[13px]`;function DM(e){return e.replace(/[^A-Za-z0-9_-]/g,`-`)}function OM(e){let t=Go(e);window.location.hash!==t&&(window.location.hash=t)}function kM(e){Math.abs(e.deltaX)>=Math.abs(e.deltaY)||e.currentTarget.scrollWidth<=e.currentTarget.clientWidth||(e.preventDefault(),e.currentTarget.scrollLeft+=e.deltaY)}function AM(e,t){let n=[t,...SM].filter((e,t,n)=>e&&n.indexOf(e)===t),r=e.toLowerCase(),i=n.find(t=>e.length>t.length&&r.endsWith(t.toLowerCase()));return i?e.slice(0,-i.length):e}function jM(e){let t=(0,$.c)(37),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({activateFromKeyboard:n,className:r,tabId:l,disabled:i,onKeyDown:a,ref:o,style:s,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u;t[9]!==i||t[10]!==l?(u={id:l,disabled:i},t[9]=i,t[10]=l,t[11]=u):u=t[11];let{attributes:d,listeners:f,rect:p,setNodeRef:m,transform:h,transition:g,isDragging:_}=Li(u),v=p.current?.width,y;t[12]!==_||t[13]!==s||t[14]!==v||t[15]!==h||t[16]!==g?(y=vM({activeWidth:v,isDragging:_,outerStyle:s,transform:h,transition:g}),t[12]=_,t[13]=s,t[14]=v,t[15]=h,t[16]=g,t[17]=y):y=t[17];let b=y,x;t[18]!==o||t[19]!==m?(x=function(e){m(e),typeof o==`function`?o(e):o&&`current`in o&&(o.current=e)},t[18]=o,t[19]=m,t[20]=x):x=t[20];let S=x,C=f?.onKeyDown,w;t[21]!==n||t[22]!==_||t[23]!==a||t[24]!==C?(w=function(e){a?.(e);let t=_M({event:e,hasKeyboardActivation:!!n,isDragging:_});if(t!==`ignore`){if(t===`activate-tab`&&n){e.preventDefault(),n();return}C?.(e)}},t[21]=n,t[22]=_,t[23]=a,t[24]=C,t[25]=w):w=t[25];let T=w,E;t[26]!==r||t[27]!==_?(E=hM({className:r,isDragging:_}),t[26]=r,t[27]=_,t[28]=E):E=t[28];let D;return t[29]!==d||t[30]!==S||t[31]!==T||t[32]!==f||t[33]!==c||t[34]!==b||t[35]!==E?(D=(0,Z.jsx)(`div`,{ref:S,"data-editor-tab-sortable":``,className:E,style:b,...c,...d,...f,onKeyDown:T}),t[29]=d,t[30]=S,t[31]=T,t[32]=f,t[33]=c,t[34]=b,t[35]=E,t[36]=D):D=t[36],D}function MM(e){let t=(0,$.c)(52),{children:n,closeTab:r,closeTabs:i,canPin:a,disabled:o,openTabs:c,pinTab:l,pinnedTabIds:u,tabId:d,unpinTab:f}=e,p=a===void 0?!0:a;if(o!==void 0&&o)return n;let m;t[0]!==p||t[1]!==u||t[2]!==d?(m=p&&u.includes(d),t[0]=p,t[1]=u,t[2]=d,t[3]=m):m=t[3];let h=m,g;if(t[4]!==c||t[5]!==u||t[6]!==d){let e;t[8]===d?e=t[9]:(e=e=>e!==d,t[8]=d,t[9]=e),g=qe(c.filter(e),u),t[4]=c,t[5]=u,t[6]=d,t[7]=g}else g=t[7];let _=g,v;t[10]!==c||t[11]!==u?(v=qe(c,u),t[10]=c,t[11]=u,t[12]=v):v=t[12];let y=v,b;t[13]===n?b=t[14]:(b=(0,Z.jsx)(nM,{asChild:!0,children:n}),t[13]=n,t[14]=b);let x;t[15]!==r||t[16]!==d?(x=()=>r(d),t[15]=r,t[16]=d,t[17]=x):x=t[17];let S;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(s,{id:`yz7wBu`}),t[18]=S):S=t[18];let C;t[19]!==h||t[20]!==x?(C=(0,Z.jsx)(aM,{disabled:h,onSelect:x,children:S}),t[19]=h,t[20]=x,t[21]=C):C=t[21];let w=_.length===0,T;t[22]!==i||t[23]!==_?(T=()=>{i(_)},t[22]=i,t[23]=_,t[24]=T):T=t[24];let E;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(s,{id:`omXJcU`}),t[25]=E):E=t[25];let D;t[26]!==w||t[27]!==T?(D=(0,Z.jsx)(aM,{disabled:w,onSelect:T,children:E}),t[26]=w,t[27]=T,t[28]=D):D=t[28];let O=y.length===0,k;t[29]!==y||t[30]!==i?(k=()=>{i(y)},t[29]=y,t[30]=i,t[31]=k):k=t[31];let A;t[32]===u.length?A=t[33]:(A=u.length?(0,Z.jsx)(s,{id:`U2Kx6T`}):(0,Z.jsx)(s,{id:`WyXG7w`}),t[32]=u.length,t[33]=A);let j;t[34]!==O||t[35]!==k||t[36]!==A?(j=(0,Z.jsx)(aM,{disabled:O,"data-testid":`editor-tab-context-close-all`,onSelect:k,children:A}),t[34]=O,t[35]=k,t[36]=A,t[37]=j):j=t[37];let M;t[38]!==p||t[39]!==h||t[40]!==l||t[41]!==d||t[42]!==f?(M=p&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(lM,{}),(0,Z.jsx)(aM,{"data-testid":`editor-tab-context-pin-toggle`,onSelect:()=>h?f(d):l(d),children:h?(0,Z.jsx)(s,{id:`SYfHmN`}):(0,Z.jsx)(s,{id:`3pU8e-`})})]}),t[38]=p,t[39]=h,t[40]=l,t[41]=d,t[42]=f,t[43]=M):M=t[43];let N;t[44]!==D||t[45]!==j||t[46]!==M||t[47]!==C?(N=(0,Z.jsxs)(iM,{className:`min-w-40`,children:[C,D,j,M]}),t[44]=D,t[45]=j,t[46]=M,t[47]=C,t[48]=N):N=t[48];let P;return t[49]!==N||t[50]!==b?(P=(0,Z.jsxs)(tM,{children:[b,N]}),t[49]=N,t[50]=b,t[51]=P):P=t[51],P}function NM(e){let t=(0,$.c)(26),{accessibleLabel:n,closeTab:r,isActive:a,isPinned:o,tabId:s,unpinTab:c}=e,{_:l}=i();if(o){let e;t[0]!==l||t[1]!==n?(e=l({id:`t18QYR`,values:{accessibleLabel:n}}),t[0]=l,t[1]=n,t[2]=e):e=t[2];let r;t[3]!==s||t[4]!==c?(r=e=>{e.stopPropagation(),c(s)},t[3]=s,t[4]=c,t[5]=r):r=t[5];let i;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(Pl,{"aria-hidden":`true`}),t[6]=i):i=t[6];let a;return t[7]!==e||t[8]!==r?(a=(0,Z.jsx)(si,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":e,"data-testid":`editor-tab-unpin-button`,className:`mr-1.5 text-primary! hover:bg-primary/10!`,onClick:r,children:i}),t[7]=e,t[8]=r,t[9]=a):a=t[9],a}let u;t[10]!==l||t[11]!==n?(u=l({id:`JLzQi_`,values:{accessibleLabel:n}}),t[10]=l,t[11]=n,t[12]=u):u=t[12];let d;t[13]===a?d=t[14]:(d=pM(a),t[13]=a,t[14]=d);let f;t[15]===a?f=t[16]:(f=mM(a),t[15]=a,t[16]=f);let p;t[17]!==r||t[18]!==s?(p=e=>{e.stopPropagation(),r(s)},t[17]=r,t[18]=s,t[19]=p):p=t[19];let m;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(ps,{"aria-hidden":`true`}),t[20]=m):m=t[20];let h;return t[21]!==u||t[22]!==d||t[23]!==f||t[24]!==p?(h=(0,Z.jsx)(si,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":u,"data-testid":`editor-tab-close-button`,className:d,tabIndex:f,onClick:p,children:m}),t[21]=u,t[22]=d,t[23]=f,t[24]=p,t[25]=h):h=t[25],h}function PM(e){let t=(0,$.c)(1),{docName:n}=e;if(jC(n)!==`conflict`)return null;let r;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(ds,{"aria-label":`Conflict`,"data-testid":`editor-tab-conflict-badge`,className:`mr-1 size-3.5 shrink-0 text-amber-500`}),t[0]=r):r=t[0],r}function FM(){let e=(0,$.c)(80),{activeDocName:t,activeTabId:n,activeNewTabId:r,activeTarget:a,activateTab:o,activateNewTab:c,closeAndClearForRename:l,closeNewTab:u,closeTab:d,closeTabs:f,getPoolActiveDocName:p,poolHas:m,isNewTabActive:h,newTabIds:g,openNewTab:_,openTabs:v,pinTab:y,pinnedTabIds:b,remapTabsForRename:x,reorderTabs:S,unpinTab:C,visibleTabIds:w}=pt(),{_:T}=i(),{pageMeta:E}=es(),D=(0,Q.useRef)(null),[O,k]=(0,Q.useState)(null),[j,N]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(``),[I,L]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(!1),B=(0,Q.useRef)(null),V=(0,Q.useRef)(!1),H=(0,Q.useRef)(!1),U=(0,Q.useRef)(null),W=(0,Q.useRef)(t),G;e[0]!==n||e[1]!==t||e[2]!==a?(G=n??(a?Ye(a):t?He(t):null),e[0]=n,e[1]=t,e[2]=a,e[3]=G):G=e[3];let K=G,q;e[4]!==r||e[5]!==K||e[6]!==h||e[7]!==g||e[8]!==v?(q=h?`${r??`__new-tab__`}\u0000${v.join(`\0`)}\u0000${g.join(`\0`)}`:K?`${K}\u0000${v.join(`\0`)}`:``,e[4]=r,e[5]=K,e[6]=h,e[7]=g,e[8]=v,e[9]=q):q=e[9];let J=q,Y,ee;e[10]===t?(Y=e[11],ee=e[12]):(Y=()=>{W.current=t},ee=[t],e[10]=t,e[11]=Y,e[12]=ee),(0,Q.useEffect)(Y,ee);let te,ne;e[13]===J?(te=e[14],ne=e[15]):(te=()=>{J&&(D.current?.querySelector(`[data-active-tab="true"]`))?.scrollIntoView({block:`nearest`,inline:`nearest`})},ne=[J],e[13]=J,e[14]=te,e[15]=ne),(0,Q.useEffect)(te,ne);let re,ie;e[16]===j?(re=e[17],ie=e[18]):(re=()=>{j&&(B.current?.focus(),B.current?.select())},ie=[j],e[16]=j,e[17]=re,e[18]=ie),(0,Q.useEffect)(re,ie);let ae,oe;e[19]!==v||e[20]!==j?(ae=()=>{!j||v.includes(j.tabId)||(H.current=!0,U.current=null,N(null),F(``),L(null),z(!1))},oe=[v,j],e[19]=v,e[20]=j,e[21]=ae,e[22]=oe):(ae=e[21],oe=e[22]),(0,Q.useEffect)(ae,oe);let se=function(e,t){let n=t.split(`/`);H.current=!1,U.current=null,N({docName:t,tabId:e}),F(n[n.length-1]),L(null)},ce=function(){H.current=!0,U.current=null,N(null),F(``),L(null),z(!1)},le=async function(){if(H.current){H.current=!1;return}if(V.current)return;let e=j?.docName;if(!e){ce();return}let t=Bj(`file`,AM(P,E.get(e)?.docExt??`.md`)),n=e.split(`/`),r=n[n.length-1];if(t===r){ce();return}if(t===U.current){B.current?.focus();return}if(!Vj(t)){L(T({id:`P8yDjG`})),B.current?.focus();return}let i=Hj({kind:`file`,path:e,name:r},t);V.current=!0,z(!0),L(null);try{let n=await fetch(`/api/rename-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:`file`,fromPath:e,toPath:i})});if(H.current){z(!1),V.current=!1;return}let r=await ve(n,`Server error (HTTP ${n.status})`);if(!r.ok){L(r.title),z(!1),V.current=!1,U.current=t,B.current?.focus();return}let a=A(Xr,r.body,`rename-path:tab`,{renamed:[],renamedAssets:[]}).renamed,o=W.current,s=qj(o,a);Bt(a);let c=!0;try{let e=Jj(a,p(),m);await Promise.all(e.map(e=>l(e))),x(a),is([`files`,`backlinks`,`graph`])}catch(n){let r=n;c=!1,console.warn(`[EditorTabs] post-rename reconciliation failed`,{err:r,docName:e,newDocName:i,normalized:t}),X.error(T({id:`MUBR8r`}))}H.current=!0,N(null),F(``),L(null),z(!1),V.current=!1,U.current=null,c&&s&&s!==o&&OM(s)}catch(n){console.warn(`[EditorTabs] rename failed`,{err:n,docName:e,newDocName:i,normalized:t}),L(T({id:`HIb0vl`})),z(!1),V.current=!1,U.current=t,B.current?.focus()}},ue=typeof window<`u`&&window.okDesktop!=null,de;e[23]===g?de=e[24]:(de=new Set(g),e[23]=g,e[24]=de);let fe=de,pe;e[25]===O?pe=e[26]:(pe=bM(O),e[25]=O,e[26]=pe);let me;e[27]===pe?me=e[28]:(me=[pe],e[27]=pe,e[28]=me);let he=me,ge;e[29]!==u||e[30]!==f||e[31]!==fe?(ge=function(e){let t=[],n=[];for(let r of e)fe.has(r)?n.push(r):t.push(r);t.length>0&&f(t);for(let e of n)u(e)},e[29]=u,e[30]=f,e[31]=fe,e[32]=ge):ge=e[32];let _e=ge,ye;e[33]===Symbol.for(`react.memo_cache_sentinel`)?(ye={activationConstraint:{distance:8}},e[33]=ye):ye=e[33];let be;e[34]===Symbol.for(`react.memo_cache_sentinel`)?(be={coordinateGetter:ha,keyboardCodes:fM},e[34]=be):be=e[34];let xe=Ci(ra(_a,ye),ra(ya,be)),Se;e[35]===Symbol.for(`react.memo_cache_sentinel`)?(Se=function(){k(yM(D.current))},e[35]=Se):Se=e[35];let Ce=Se,we;e[36]===Symbol.for(`react.memo_cache_sentinel`)?(we=function(){k(null)},e[36]=we):we=e[36];let Te=we,Ee;e[37]!==Te||e[38]!==S||e[39]!==w?(Ee=function(e){Te();let t=String(e.active.id),n=e.over?String(e.over.id):null;if(!n||t===n)return;let r=w.indexOf(t),i=w.indexOf(n);r<0||i<0||r===i||S(zi([...w],r,i),t)},e[37]=Te,e[38]=S,e[39]=w,e[40]=Ee):Ee=e[40];let De=Ee,Oe=ue?``:void 0,ke;e[41]===Symbol.for(`react.memo_cache_sentinel`)?(ke=ai(`pl-2 flex h-12 min-w-0 touch-manipulation flex-1 items-end overflow-x-auto overflow-y-hidden overscroll-x-contain scroll-fade-mask-x [scrollbar-width:none]`,ue&&`[-webkit-app-region:drag]`),e[41]=ke):ke=e[41];let Ae=kM,je;e[42]===Symbol.for(`react.memo_cache_sentinel`)?(je=ai(`flex items-end gap-1`,ue&&`[-webkit-app-region:no-drag]`),e[42]=je):je=e[42];let Ne=Ya,Pe=xM,Fe;e[43]===Symbol.for(`react.memo_cache_sentinel`)?(Fe={container:typeof document<`u`?document.body:void 0},e[43]=Fe):Fe=e[43];let Ie=pa,Le;e[44]===w?Le=e[45]:(Le=[...w],e[44]=w,e[45]=Le);let Re=da,ze=w.map(e=>{if(fe.has(e)){let t=e===r;return(0,Z.jsx)(MM,{tabId:e,canPin:!1,openTabs:w,closeTab:u,closeTabs:_e,pinTab:y,pinnedTabIds:b,unpinTab:C,children:(0,Z.jsxs)(jM,{tabId:e,activateFromKeyboard:()=>c(e),"aria-current":t?`page`:void 0,"data-active-tab":t?`true`:void 0,className:ai(CM,t?wM:TM),onAuxClick:t=>{t.button===1&&(t.preventDefault(),u(e))},onClick:t=>{t.target===t.currentTarget&&c(e)},children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":T({id:`zLak8b`}),"data-testid":`editor-new-tab-placeholder-button`,className:EM,onClick:()=>c(e),tabIndex:-1,children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:(0,Z.jsx)(s,{id:`3YvS-c`})})}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":T({id:`xCdTnb`}),"data-testid":`editor-new-tab-placeholder-close`,className:pM(t),tabIndex:mM(t),onClick:t=>{t.stopPropagation(),u(e)},children:(0,Z.jsx)(ps,{"aria-hidden":`true`,className:`size-3.5`})})]})},e)}let t=ft(e),n=e===K,i=b.includes(e);if(t.kind===`folder`){let{baseName:r,label:a,prefix:s}=Me(t.folderPath,`/`),c=`${s}${a}`;return(0,Z.jsx)(MM,{tabId:e,openTabs:w,closeTab:d,closeTabs:_e,pinTab:y,pinnedTabIds:b,unpinTab:C,children:(0,Z.jsxs)(jM,{tabId:e,activateFromKeyboard:()=>o(e),"aria-current":n?`page`:void 0,"data-active-tab":n?`true`:void 0,className:ai(CM,n?wM:TM),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!i&&d(e))},onClick:t=>{t.target===t.currentTarget&&o(e)},children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":c,title:c,className:EM,onClick:()=>{o(e)},tabIndex:-1,children:[s&&(0,Z.jsx)(`span`,{className:ai(`min-w-0 flex-1 truncate`,n&&`text-muted-foreground`),children:s}),(0,Z.jsxs)(`span`,{className:ai(`flex min-w-0 items-center`,s?`max-w-[70%] shrink-0`:`flex-1`),children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:r}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:`/`})]})]}),(0,Z.jsx)(NM,{accessibleLabel:c,closeTab:d,isActive:n,isPinned:i,tabId:e,unpinTab:C})]})},e)}if(t.kind===`asset`){let{baseName:r,label:a,prefix:s}=Me(t.assetPath,``),c=`${s}${a}`;return(0,Z.jsx)(MM,{tabId:e,openTabs:w,closeTab:d,closeTabs:_e,pinTab:y,pinnedTabIds:b,unpinTab:C,children:(0,Z.jsxs)(jM,{tabId:e,activateFromKeyboard:()=>o(e),"aria-current":n?`page`:void 0,"data-active-tab":n?`true`:void 0,className:ai(CM,n?wM:TM),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!i&&d(e))},onClick:t=>{t.target===t.currentTarget&&o(e)},children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":c,className:EM,onClick:()=>{o(e)},tabIndex:-1,children:[s?(0,Z.jsx)(`span`,{className:ai(`min-w-0 flex-1 truncate text-muted-foreground/60`,n&&`text-muted-foreground`),children:s}):null,(0,Z.jsx)(`span`,{className:ai(`min-w-0 truncate`,s?`max-w-[70%] shrink-0`:`flex-1`),children:r})]}),(0,Z.jsx)(NM,{accessibleLabel:c,closeTab:d,isActive:n,isPinned:i,tabId:e,unpinTab:C})]})},e)}let a=t.docName,l=E.get(a)?.docExt??`.md`,{baseName:f,extension:p,label:m,prefix:h}=Me(a,l),g=`${h}${m}`,_=l===`.md`||l===`.mdx`,v=j?.tabId===e,x=`editor-tab-rename-error-${DM(a)}`;return(0,Z.jsx)(MM,{disabled:v,tabId:e,openTabs:w,closeTab:d,closeTabs:_e,pinTab:y,pinnedTabIds:b,unpinTab:C,children:(0,Z.jsx)(jM,{tabId:e,activateFromKeyboard:()=>o(e),disabled:v,"aria-current":n?`page`:void 0,"data-active-tab":n?`true`:void 0,className:ai(CM,n?wM:TM,v&&I&&`border-destructive`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!i&&d(e))},onClick:t=>{t.target===t.currentTarget&&o(e)},children:v?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(cC,{className:`h-full min-w-0 flex-1 rounded-none border-0 bg-transparent dark:bg-transparent`,children:[(0,Z.jsx)(pC,{ref:B,value:P,disabled:R,"aria-label":T({id:`Dw1T_W`,values:{label:m}}),"data-testid":`editor-tab-rename-input`,"aria-invalid":I?!0:void 0,"aria-describedby":I?x:void 0,"aria-busy":R||void 0,title:I??a,className:`h-full min-w-0 px-2 py-0 font-medium text-foreground text-xs selection:bg-primary selection:text-primary-foreground`,onChange:e=>{F(AM(e.target.value,l)),L(null),U.current=null},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),le()):e.key===`Escape`&&(e.preventDefault(),ce())},onBlur:le}),(0,Z.jsx)(uC,{align:`inline-end`,"aria-hidden":`true`,className:`pr-2 text-xs`,children:(0,Z.jsx)(fC,{className:`text-muted-foreground/60 text-xs`,children:l})})]}),I?(0,Z.jsx)(`span`,{id:x,role:`alert`,className:`sr-only`,children:I}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":g,title:g,className:EM,onClick:()=>{o(e)},onDoubleClick:t=>{t.preventDefault(),t.stopPropagation(),se(e,a)},tabIndex:-1,children:[(0,Z.jsx)(PM,{docName:a}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:f}),!_&&(0,Z.jsx)(`span`,{className:`shrink-0`,children:p})]})]}),(0,Z.jsx)(NM,{accessibleLabel:g,closeTab:d,isActive:n,isPinned:i,tabId:e,unpinTab:C})]})})},e)}),Be;e[46]!==Ie||e[47]!==Le||e[48]!==Re||e[49]!==ze?(Be=(0,Z.jsx)(Ie,{items:Le,strategy:Re,children:ze}),e[46]=Ie,e[47]=Le,e[48]=Re,e[49]=ze,e[50]=Be):Be=e[50];let Ve;e[51]!==Ne||e[52]!==Te||e[53]!==De||e[54]!==Ce||e[55]!==xe||e[56]!==!1||e[57]!==Pe||e[58]!==Fe||e[59]!==Be||e[60]!==he?(Ve=(0,Z.jsx)(Ne,{sensors:xe,autoScroll:!1,collisionDetection:Pe,modifiers:he,onDragStart:Ce,onDragEnd:De,onDragCancel:Te,accessibility:Fe,children:Be}),e[51]=Ne,e[52]=Te,e[53]=De,e[54]=Ce,e[55]=xe,e[56]=!1,e[57]=Pe,e[58]=Fe,e[59]=Be,e[60]=he,e[61]=Ve):Ve=e[61];let Ue;e[62]===T?Ue=e[63]:(Ue=T({id:`3YvS-c`}),e[62]=T,e[63]=Ue);let We;e[64]===Symbol.for(`react.memo_cache_sentinel`)?(We=(0,Z.jsx)(M,{"aria-hidden":`true`}),e[64]=We):We=e[64];let Ge;e[65]!==_||e[66]!==Ue?(Ge=(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(si,{type:`button`,size:`icon-xs`,variant:`ghost`,"aria-label":Ue,"data-testid":`editor-new-tab-button`,className:`first:mb-3 mb-1.5`,onClick:_,children:We})}),e[65]=_,e[66]=Ue,e[67]=Ge):Ge=e[67];let Ke;e[68]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=(0,Z.jsx)(Ds,{children:(0,Z.jsx)(s,{id:`3YvS-c`})}),e[68]=Ke):Ke=e[68];let qe;e[69]===Ge?qe=e[70]:(qe=(0,Z.jsxs)(As,{children:[Ge,Ke]}),e[69]=Ge,e[70]=qe);let Je;e[71]!==je||e[72]!==Ve||e[73]!==qe?(Je=(0,Z.jsxs)(`div`,{className:je,children:[Ve,qe]}),e[71]=je,e[72]=Ve,e[73]=qe,e[74]=Je):Je=e[74];let Xe;return e[75]!==Oe||e[76]!==ke||e[77]!==Ae||e[78]!==Je?(Xe=(0,Z.jsx)(`div`,{ref:D,"data-electron-drag":Oe,className:ke,onWheel:Ae,children:Je}),e[75]=Oe,e[76]=ke,e[77]=Ae,e[78]=Je,e[79]=Xe):Xe=e[79],Xe}function IM(e){let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`Discord`}),r=(0,Z.jsx)(`path`,{d:`M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9554 2.4189-2.1568 2.4189Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,Z.jsxs)(`svg`,{role:`img`,fill:`currentColor`,height:24,width:24,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}function LM(e){let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`X (Twitter)`}),r=(0,Z.jsx)(`path`,{d:`M18.901 1.153h3.68l-8.04 9.19L24 22.846h-7.406l-5.8-7.584-6.638 7.584H.474l8.6-9.83L0 1.154h7.594l5.243 6.932ZM17.61 20.644h2.039L6.486 3.24H4.298Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,Z.jsxs)(`svg`,{role:`img`,fill:`currentColor`,height:24,width:24,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}var RM=[{label:{id:`TvY_XA`},href:`https://openknowledge.ai/docs`,icon:Ke},{label:`GitHub`,href:`https://github.com/inkeep/open-knowledge`,icon:Gd},{label:{id:`On0aF2`},href:`https://openknowledge.ai/`,icon:Fo},{label:`Discord`,href:`https://discord.com/invite/YujKpFN49`,icon:IM},{label:`Twitter`,href:`https://x.com/inkeep`,icon:LM}],zM=()=>{let e=(0,$.c)(16),{_:t}=i(),[n,r]=(0,Q.useState)(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(kt,{className:`size-4`}),e[0]=a):a=e[0];let o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsxs)(si,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[a,(0,Z.jsx)(`span`,{className:`sr-only`,children:(0,Z.jsx)(s,{id:`s-MGs7`})})]})})}),e[1]=o):o=e[1];let c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsxs)(As,{children:[o,(0,Z.jsx)(Ds,{children:(0,Z.jsx)(s,{id:`s-MGs7`})})]}),e[2]=c):c=e[2];let l;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs mb-1`,children:(0,Z.jsx)(s,{id:`s-MGs7`})}),e[3]=l):l=e[3];let u;e[4]===t?u=e[5]:(u=t({id:`s-MGs7`}),e[4]=t,e[5]=u);let d;e[6]===t?d=e[7]:(d=RM.map(e=>{let{label:n,href:r,icon:i}=e;return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`a`,{href:r,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>va(e,r),onAuxClick:e=>va(e,r),className:`flex items-center gap-2.5 rounded-md px-2 py-1.5 text-sm text-muted-foreground transition-colors hover:bg-azure-900/5 dark:hover:bg-white/20 hover:text-primary`,children:[(0,Z.jsx)(i,{"aria-hidden":`true`,className:`size-4 shrink-0`}),typeof n==`string`?n:t(n)]})},r)}),e[6]=t,e[7]=d);let f;e[8]===d?f=e[9]:(f=(0,Z.jsx)(`ul`,{className:`space-y-0.5`,children:d}),e[8]=d,e[9]=f);let p;e[10]!==u||e[11]!==f?(p=(0,Z.jsxs)(b,{align:`end`,className:`w-64 p-3`,children:[l,(0,Z.jsx)(`nav`,{"aria-label":u,children:f})]}),e[10]=u,e[11]=f,e[12]=p):p=e[12];let m;return e[13]!==n||e[14]!==p?(m=(0,Z.jsxs)(pe,{open:n,onOpenChange:r,children:[c,p]}),e[13]=n,e[14]=p,e[15]=m):m=e[15],m},BM=(0,Q.createContext)(null);function VM(e){let t=(0,$.c)(3),{value:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,Z.jsx)(BM,{value:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function HM(){return(0,Q.use)(BM)}function UM(e){let t=(0,$.c)(19),{installStates:n,terminalLaunch:r,disabled:a,onPick:o,onLaunchTerminal:c}=e,{_:l}=i(),[u,d]=(0,Q.useState)(``),f;if(t[0]!==l||t[1]!==a||t[2]!==n||t[3]!==u||t[4]!==c||t[5]!==o||t[6]!==r){let e;t[8]===n?e=t[9]:(e=e=>n[e.id]?.installed===!0,t[8]=n,t[9]=e);let i=Fh.filter(e),p=Fh.some(e=>n[e.id]?.installed==null),m=i.length>0||r!==null,h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(h=e=>d(e.target.value),t[10]=h):h=t[10];let g;t[11]===l?g=t[12]:(g=l({id:`Rah7yq`}),t[11]=l,t[12]=g);let _;t[13]===l?_=t[14]:(_=l({id:`ZBt4rI`}),t[13]=l,t[14]=_);let v;t[15]!==u||t[16]!==g||t[17]!==_?(v=(0,Z.jsx)(ko,{value:u,onChange:h,placeholder:g,"aria-label":_,"data-testid":`open-in-agent-instruction`}),t[15]=u,t[16]=g,t[17]=_,t[18]=v):v=t[18],f=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[v,m?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`text-muted-foreground text-xs`,"data-testid":`open-in-agent-send-label`,children:(0,Z.jsx)(s,{id:`C37Zkt`})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[i.map(e=>{let{displayName:t}=e;return(0,Z.jsxs)(si,{type:`button`,variant:`ghost`,className:`w-full justify-start gap-2`,disabled:a,"data-testid":`open-in-agent-item-${e.id}`,"aria-label":l({id:`WqLq6M`,values:{displayName:t}}),onClick:()=>o(e,u),children:[(0,Z.jsx)(ox,{id:e.id,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{children:t})]},e.id)}),r===null?null:(0,Z.jsxs)(Z.Fragment,{children:[i.length>0?(0,Z.jsx)(Pi,{className:`my-1`}):null,(0,Z.jsxs)(si,{type:`button`,variant:`ghost`,className:`w-full justify-start gap-2`,disabled:a,"data-testid":`open-in-agent-terminal`,"aria-label":l({id:`AcK_r0`}),onClick:()=>c(u),children:[(0,Z.jsx)(Kl,{className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{children:(0,Z.jsx)(s,{id:`AcK_r0`})})]})]})]})]}):(0,Z.jsx)(`p`,{className:`text-muted-foreground text-sm`,"data-testid":`open-in-agent-empty`,"aria-live":`polite`,children:p?(0,Z.jsx)(s,{id:`EcR0fl`}):(0,Z.jsx)(s,{id:`l6OXqI`})})]}),t[0]=l,t[1]=a,t[2]=n,t[3]=u,t[4]=c,t[5]=o,t[6]=r,t[7]=f}else f=t[7];return f}function WM(e){let t=(0,$.c)(44),{input:n,open:r,onOpenChange:a}=e,{_:o}=i(),{states:c,refresh:l}=Kg(),{dispatch:u}=Fg(),d=HM(),[f,p]=(0,Q.useState)(!1),m=(0,Q.useRef)(!1),h=Mh(),g=r??f,_;t[0]===l?_=t[1]:(_=()=>{l()},t[0]=l,t[1]=_);let v=(0,Q.useEffectEvent)(_),y;t[2]!==g||t[3]!==v?(y=()=>{g&&v()},t[2]=g,t[3]=v,t[4]=y):y=t[4];let x;if(t[5]===g?x=t[6]:(x=[g],t[5]=g,t[6]=x),(0,Q.useEffect)(y,x),h)return null;let S=typeof window<`u`&&window.okDesktop!=null,C;t[7]!==a||t[8]!==r?(C=e=>{r===void 0&&p(e),a?.(e)},t[7]=a,t[8]=r,t[9]=C):C=t[9];let w=C,T=n===null,E;t[10]===n?E=t[11]:(E=e=>{if(n===null)return null;let t=e.trim();return t?{...n,instruction:t}:n},t[10]=n,t[11]=E);let D=E,O;t[12]!==u||t[13]!==w||t[14]!==D?(O=(e,t)=>{let n=D(t);n!==null&&(u(e.id,n),w(!1))},t[12]=u,t[13]=w,t[14]=D,t[15]=O):O=t[15];let k=O,A;t[16]!==w||t[17]!==D||t[18]!==d?(A=e=>{let t=D(e);t===null||d===null||(d.launchInTerminal(t),w(!1))},t[16]=w,t[17]=D,t[18]=d,t[19]=A):A=t[19];let j=A,M;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(M=S?()=>{m.current=!0}:void 0,t[20]=M):M=t[20];let N;t[21]===w?N=t[22]:(N=S?()=>{if(m.current){m.current=!1;return}w(!0)}:void 0,t[21]=w,t[22]=N);let P,F;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(vi,{className:`size-3.5`,"aria-hidden":`true`}),F=(0,Z.jsx)(s,{id:`O7_W_a`}),t[23]=P,t[24]=F):(P=t[23],F=t[24]);let I;t[25]!==N||t[26]!==T?(I=(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsxs)(si,{variant:`ghost`,size:`sm`,disabled:T,className:`gap-1.5 text-muted-foreground px-1.5`,"data-testid":`open-in-agent-trigger`,onPointerDown:M,onClick:N,children:[P,F]})}),t[25]=N,t[26]=T,t[27]=I):I=t[27];let L;t[28]===o?L=t[29]:(L=o({id:`O7_W_a`}),t[28]=o,t[29]=L);let R=n===null,z;t[30]!==j||t[31]!==k||t[32]!==c||t[33]!==R||t[34]!==d?(z=(0,Z.jsx)(UM,{installStates:c,terminalLaunch:d,disabled:R,onPick:k,onLaunchTerminal:j}),t[30]=j,t[31]=k,t[32]=c,t[33]=R,t[34]=d,t[35]=z):z=t[35];let B;t[36]!==L||t[37]!==z?(B=(0,Z.jsx)(b,{align:`end`,"aria-label":L,"data-testid":`open-in-agent-menu`,children:z}),t[36]=L,t[37]=z,t[38]=B):B=t[38];let V;return t[39]!==w||t[40]!==g||t[41]!==I||t[42]!==B?(V=(0,Z.jsxs)(pe,{open:g,onOpenChange:w,children:[I,B]}),t[39]=w,t[40]=g,t[41]=I,t[42]=B,t[43]=V):V=t[43],V}var GM=50,KM=()=>{let e=(0,$.c)(8),t=(0,Q.useRef)(null),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>{t.current===null&&(t.current=setTimeout(()=>{t.current=null,qS.preload()},GM))},e[0]=n):n=e[0];let r=n,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{t.current!==null&&(clearTimeout(t.current),t.current=null)},e[1]=i):i=e[1];let a=i,o,c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>()=>{t.current!==null&&clearTimeout(t.current)},c=[],e[2]=o,e[3]=c):(o=e[2],c=e[3]),(0,Q.useEffect)(o,c);let l,u;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{a(),window.location.hash!==`#settings`&&(window.location.hash=Vh)},u=(0,Z.jsx)(Bl,{className:`size-4`}),e[4]=l,e[5]=u):(l=e[4],u=e[5]);let d;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsxs)(si,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,"data-testid":`header-settings-button`,onMouseEnter:r,onMouseLeave:a,onFocus:r,onBlur:a,onClick:l,children:[u,(0,Z.jsx)(`span`,{className:`sr-only`,children:(0,Z.jsx)(s,{id:`Tz0i8g`})})]})}),e[6]=d):d=e[6];let f;return e[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsxs)(As,{children:[d,(0,Z.jsx)(Ds,{children:(0,Z.jsx)(s,{id:`Tz0i8g`})})]}),e[7]=f):f=e[7],f};function qM(e){let t=(0,$.c)(30),{input:n,onClickWhenNoRemote:r}=e,{_:a}=i(),{status:o}=oo(),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null),f=(0,Q.useRef)(null),p,m;t[0]===u?(p=t[1],m=t[2]):(p=()=>{!u||!f.current||(f.current.focus(),f.current.select())},m=[u],t[0]=u,t[1]=p,t[2]=m),(0,Q.useEffect)(p,m);let h=o?.hasRemote===!0,g=n===null,_;t[3]!==a||t[4]!==c||t[5]!==h||t[6]!==n||t[7]!==r?(_=async function(){if(!c&&n!==null){l(!0),d(null);try{let e=await sa({...n,hasRemote:h,onClickWhenNoRemote:r},{clipboardWrite:ka,toastSuccess:$M,toastError:QM,logEvent:ZM});e.kind===`clipboard-failed`&&d(e.shareUrl)}catch{X.error(a({id:`u3YnKw`}))}l(!1)}},t[3]=a,t[4]=c,t[5]=h,t[6]=n,t[7]=r,t[8]=_):_=t[8];let v=_,y=u!==null,x;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>{e||d(null)},t[9]=x):x=t[9];let C;t[10]!==a||t[11]!==n?.kind?(C=n?.kind===`folder`?a({id:`WR0y2O`}):a({id:`F4IYWe`}),t[10]=a,t[11]=n?.kind,t[12]=C):C=t[12];let w=c||g,T,E;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(Vl,{className:`size-3.5`,"aria-hidden":!0}),E=(0,Z.jsx)(s,{id:`Z8lGw6`}),t[13]=T,t[14]=E):(T=t[13],E=t[14]);let D;t[15]!==v||t[16]!==C||t[17]!==w?(D=(0,Z.jsx)(S,{asChild:!0,children:(0,Z.jsxs)(si,{variant:`ghost`,size:`sm`,"aria-label":C,onClick:v,disabled:w,className:`gap-1.5 text-muted-foreground px-1.5`,"data-testid":`share-button`,children:[T,E]})}),t[15]=v,t[16]=C,t[17]=w,t[18]=D):D=t[18];let O;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:(0,Z.jsx)(s,{id:`I1m158`})}),t[19]=O):O=t[19];let k;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,Z.jsx)(s,{id:`ndeI89`})}),t[20]=k):k=t[20];let A=u??``,j;t[21]===a?j=t[22]:(j=a({id:`5-FeN2`}),t[21]=a,t[22]=j);let M;t[23]!==A||t[24]!==j?(M=(0,Z.jsxs)(b,{className:`flex w-80 flex-col gap-2`,"data-testid":`share-button-fallback-popover`,children:[O,k,(0,Z.jsx)(ko,{ref:f,readOnly:!0,value:A,onFocus:XM,onClick:YM,onContextMenu:JM,className:`font-mono text-xs`,"data-testid":`share-button-fallback-url`,"aria-label":j})]}),t[23]=A,t[24]=j,t[25]=M):M=t[25];let N;return t[26]!==D||t[27]!==M||t[28]!==y?(N=(0,Z.jsxs)(pe,{open:y,onOpenChange:x,children:[D,M]}),t[26]=D,t[27]=M,t[28]=y,t[29]=N):N=t[29],N}function JM(e){return e.currentTarget.select()}function YM(e){return e.currentTarget.select()}function XM(e){return e.currentTarget.select()}function ZM(e){return console.log(e)}function QM(e){e!==`Link ready but could not copy to clipboard.`&&X.error(e)}function $M(e){return X.success(e)}function eN(e){let t=(0,$.c)(44),{onSignIn:n,onSetIdentity:r,onOpenSearch:a,openInAgentMenuOpen:o,openInAgentMenuInput:c,onOpenInAgentMenuOpenChange:l}=e,{_:u}=i(),{activeDocName:d,activeTarget:f}=pt(),{state:p}=Ok(),m=Bh(),h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=Ks(`toggle-files-sidebar`),t[0]=h):h=t[0];let g=h,_=Ks(`command-palette`),v=po(),[y,b]=(0,Q.useState)(!1),x;bb0:{if(f===null){let e;t[1]===v?e=t[2]:(e=yg({workspace:v}),t[1]=v,t[2]=e),x=e;break bb0}if(f.kind===`folder`){if(!v){x=null;break bb0}let e;t[3]!==f.folderPath||t[4]!==v?(e=Sg({folderRelativePath:f.folderPath,workspace:v}),t[3]=f.folderPath,t[4]=v,t[5]=e):e=t[5],x=e;break bb0}let e;t[6]!==d||t[7]!==v?(e=vg({docName:d,workspace:v}),t[6]=d,t[7]=v,t[8]=e):e=t[8],x=e}let S=c??x,C;bb1:{if(f?.kind===`folder`){let e;t[9]===f.folderPath?e=t[10]:(e=lo(f.folderPath),t[9]=f.folderPath,t[10]=e),C=e;break bb1}if(d){let e;t[11]===d?e=t[12]:(e=Ea(d),t[11]=d,t[12]=e),C=e;break bb1}C=null}let w=C,T=typeof window<`u`&&window.okDesktop!=null,E=p===`collapsed`,D=T?``:void 0,O=T&&E&&`pl-[78px]`,k;t[13]===O?k=t[14]:(k=ai(`flex h-12 shrink-0 items-center bg-muted/35 shadow-[inset_0_-1px_0_var(--border)]`,T&&`[-webkit-app-region:drag]`,O,T&&`motion-safe:transition-[padding] motion-safe:duration-200 motion-safe:ease-linear`),t[13]=O,t[14]=k);let A=!m&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(As,{children:[(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(Nk,{className:ai(`-ml-1 shrink-0 text-muted-foreground`,T&&`[-webkit-app-region:no-drag]`)})}),(0,Z.jsx)(Ds,{children:p===`expanded`?(0,Z.jsx)(s,{id:`ZxXhLY`,values:{sidebarShortcut:g}}):(0,Z.jsx)(s,{id:`Zz25kq`,values:{sidebarShortcut:g}})})]}),E&&a&&(0,Z.jsxs)(As,{children:[(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(si,{variant:`ghost`,size:`icon-sm`,onClick:a,"aria-label":u({id:`IN4UX8`,values:{searchShortcut:_}}),"data-telemetry-event":`ok.editor_header.search.click`,className:ai(`shrink-0 text-muted-foreground`,T&&`[-webkit-app-region:no-drag]`),children:(0,Z.jsx)(te,{"aria-hidden":`true`})})}),(0,Z.jsx)(Ds,{children:(0,Z.jsx)(s,{id:`IN4UX8`,values:{searchShortcut:_}})})]}),(0,Z.jsx)(Pi,{orientation:`vertical`,className:`mr-1 h-4 shrink-0 data-vertical:self-center`}),(0,Z.jsx)(FM,{})]}),j;t[15]===A?j=t[16]:(j=(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 px-3`,children:A}),t[15]=A,t[16]=j);let M;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(M=ai(`flex shrink-0 items-center justify-end gap-2 px-3`,T&&`[&>*]:[-webkit-app-region:no-drag]`),t[17]=M):M=t[17];let N;t[18]!==S||t[19]!==l||t[20]!==o||t[21]!==y||t[22]!==b||t[23]!==w||t[24]!==m?(N=!m&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(WM,{input:S,open:o,onOpenChange:l}),(0,Z.jsx)(qM,{input:w,onClickWhenNoRemote:()=>b(!0)}),(0,Z.jsx)(fo,{open:y,onOpenChange:b})]}),t[18]=S,t[19]=l,t[20]=o,t[21]=y,t[22]=b,t[23]=w,t[24]=m,t[25]=N):N=t[25];let P;t[26]!==r||t[27]!==n?(P=(0,Z.jsx)(Va,{onSignIn:n,onSetIdentity:r}),t[26]=r,t[27]=n,t[28]=P):P=t[28];let F,I,L;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(aj,{}),I=(0,Z.jsx)(Pi,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),L=(0,Z.jsx)(hd,{}),t[29]=F,t[30]=I,t[31]=L):(F=t[29],I=t[30],L=t[31]);let R;t[32]===m?R=t[33]:(R=!m&&(0,Z.jsx)(KM,{}),t[32]=m,t[33]=R);let z;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(zM,{}),t[34]=z):z=t[34];let B;t[35]!==N||t[36]!==P||t[37]!==R?(B=(0,Z.jsxs)(`div`,{className:M,children:[N,P,F,I,L,R,z]}),t[35]=N,t[36]=P,t[37]=R,t[38]=B):B=t[38];let V;return t[39]!==B||t[40]!==D||t[41]!==k||t[42]!==j?(V=(0,Z.jsxs)(`header`,{"data-electron-drag":D,className:k,children:[j,B]}),t[39]=B,t[40]=D,t[41]=k,t[42]=j,t[43]=V):V=t[43],V}var tN=`open-knowledge:terminal-launch`;function nN(e,t=typeof window>`u`?new EventTarget:window){t.dispatchEvent(new CustomEvent(tN,{detail:{prompt:e}}))}function rN(e,t=typeof window>`u`?new EventTarget:window){let n=t=>{let n=t instanceof CustomEvent?t.detail?.prompt:void 0;typeof n==`string`&&e(n)};return t.addEventListener(tN,n),()=>t.removeEventListener(tN,n)}function iN(e){let t=(0,$.c)(61),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{onOpenSearch:r}=n,{_:a}=i(),[o,s]=T_(),[c,l]=(0,Q.useState)(o),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(`auth`),[m,h]=(0,Q.useState)(Hv[0].id),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(null),S=typeof window<`u`?window.okDesktop??null:null,[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(null),D=Ca(),{projectLocalConfig:O,projectLocalSynced:k}=oe(),A=po(),{activeDocName:j}=pt(),M=D?.hasRemote,N=D?.pushPermission?.checkStatus,P;t[2]!==g||t[3]!==O||t[4]!==k||t[5]!==M||t[6]!==N?(P=k_({autoSyncOnboardingDismissed:g,hasRemote:M,projectLocalSynced:k,projectLocalConfig:O,pushPermissionCheckStatus:N}),t[2]=g,t[3]=O,t[4]=k,t[5]=M,t[6]=N,t[7]=P):P=t[7];let F=P,I,L;t[8]===j?(I=t[9],L=t[10]):(I=()=>{let e=function(e){let t=e.detail;t&&j&&yc(j,{kind:`raw-mdx`,detail:t}),l(`source`)};return window.addEventListener(__,e),()=>window.removeEventListener(__,e)},L=[j],t[8]=j,t[9]=I,t[10]=L),(0,Q.useEffect)(I,L);let R,z;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>{let e=window.okDesktop;if(e!=null)return e.onMenuAction(e=>{e===`toggle-terminal`?w(oN):e===`new-terminal`&&w(!0)})},z=[],t[11]=R,t[12]=z):(R=t[11],z=t[12]),(0,Q.useEffect)(R,z);let B,V;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>{if(window.okDesktop!=null)return;let e=function(e){qs(e,`toggle-terminal-panel`)&&(e.preventDefault(),w(aN))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},B=[],t[13]=B,t[14]=V):(B=t[13],V=t[14]),(0,Q.useEffect)(V,B);let H,U;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>rN(e=>{w(!0),E(t=>({prompt:e,nonce:(t?.nonce??0)+1}))}),U=[],t[15]=H,t[16]=U):(H=t[15],U=t[16]),(0,Q.useEffect)(H,U);let W,G;t[17]===C?(W=t[18],G=t[19]):(W=()=>{C||E(null)},G=[C],t[17]=C,t[18]=W,t[19]=G),(0,Q.useEffect)(W,G);let K,q;t[20]===C?(K=t[21],q=t[22]):(K=()=>{window.okDesktop!=null&&window.okDesktop.editor.notifyViewMenuStateChanged({terminalVisible:C})},q=[C],t[20]=C,t[21]=K,t[22]=q),(0,Q.useEffect)(K,q);let J,Y;t[23]===C?(J=t[24],Y=t[25]):(J=()=>{window.okDesktop!=null&&C&&Ma()},Y=[C],t[23]=C,t[24]=J,t[25]=Y),(0,Q.useEffect)(J,Y),E_(D?.pausedReason);let ee;t[26]===s?ee=t[27]:(ee=function(e){l(e),s(e)},t[26]=s,t[27]=ee);let te=ee,ne;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(ne=function(e){y(e),e||x(null)},t[28]=ne):ne=t[28];let re=ne,ie;t[29]!==a||t[30]!==j||t[31]!==A?(ie={openSelection(e){let t=wg({docName:e.docName??j,workspace:A,instruction:e.instruction,selectionMarkdown:e.selectionMarkdown});return t===null?(X.error(a({id:`_VRtd7`})),!1):(x(t),y(!0),!0)}},t[29]=a,t[30]=j,t[31]=A,t[32]=ie):ie=t[32];let ae,se;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>{p(`auth`),d(!0)},se=()=>{p(`identity`),d(!0)},t[33]=ae,t[34]=se):(ae=t[33],se=t[34]);let ce;t[35]!==r||t[36]!==b||t[37]!==v?(ce=(0,Z.jsx)(eN,{onSignIn:ae,onSetIdentity:se,onOpenSearch:r,openInAgentMenuOpen:v,openInAgentMenuInput:b,onOpenInAgentMenuOpenChange:re}),t[35]=r,t[36]=b,t[37]=v,t[38]=ce):ce=t[38];let le;t[39]!==m||t[40]!==c||t[41]!==te||t[42]!==T||t[43]!==C?(le=(0,Z.jsx)(NA,{editorMode:c,onModeChange:te,activeTab:m,onActiveTabChange:h,terminalBridge:S,terminalVisible:C,onTerminalVisibleChange:w,terminalLaunch:T}),t[39]=m,t[40]=c,t[41]=te,t[42]=T,t[43]=C,t[44]=le):le=t[44];let ue;t[45]!==ie||t[46]!==ce||t[47]!==le?(ue=(0,Z.jsxs)(Tc,{value:ie,children:[ce,le]}),t[45]=ie,t[46]=ce,t[47]=le,t[48]=ue):ue=t[48];let de=f===`identity`,fe;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(fe=()=>{d(!1)},t[49]=fe):fe=t[49];let pe;t[50]!==u||t[51]!==de?(pe=(0,Z.jsx)(Xi,{open:u,onOpenChange:d,identityPrompt:de,onSuccess:fe}),t[50]=u,t[51]=de,t[52]=pe):pe=t[52];let me;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(me=()=>_(!0),t[53]=me):me=t[53];let he;t[54]===F?he=t[55]:(he=(0,Z.jsx)(D_,{open:F,onResolved:me}),t[54]=F,t[55]=he);let ge;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,Z.jsx)(m_,{}),t[56]=ge):ge=t[56];let _e;return t[57]!==ue||t[58]!==pe||t[59]!==he?(_e=(0,Z.jsxs)(Z.Fragment,{children:[ue,pe,he,ge]}),t[57]=ue,t[58]=pe,t[59]=he,t[60]=_e):_e=t[60],_e}function aN(e){return!e}function oN(e){return!e}function sN(e){let t=Go(Ho(e));typeof window>`u`||window.location.hash!==t&&(window.location.hash=t)}function cN(){let e=(0,$.c)(11),{conflicts:t,loading:n,error:r}=Ni();if(n)return null;if(r===`server`){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`section`,{"data-testid":`conflicts-section`,"aria-label":`Conflicted files`,className:`border-b border-amber-200/60 bg-amber-50/40 px-2 py-2 dark:border-amber-900/40 dark:bg-amber-950/20`,children:(0,Z.jsxs)(`p`,{"data-testid":`conflicts-section-error`,className:`px-2 py-1.5 text-[12px] text-amber-700 dark:text-amber-400`,children:[(0,Z.jsx)(ds,{"aria-hidden":`true`,className:`mr-1.5 inline size-3`}),`Couldn't load conflicts — reload to retry.`]})}),e[0]=t):t=e[0],t}if(t.length===0)return null;let i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-[11px] uppercase tracking-wider text-amber-700 dark:text-amber-400`,children:[(0,Z.jsx)(ds,{"aria-hidden":`true`,className:`size-3`}),`Conflicts`]}),e[1]=i):i=e[1];let a;e[2]===t.length?a=e[3]:(a=(0,Z.jsxs)(`header`,{className:`flex items-center justify-between px-2 pb-1.5`,children:[i,(0,Z.jsx)(`span`,{"data-testid":`conflicts-section-count`,className:`rounded-full bg-amber-500 px-1.5 py-0.5 font-mono text-[10px] font-medium leading-none text-white`,children:t.length})]}),e[2]=t.length,e[3]=a);let o;e[4]===t?o=e[5]:(o=t.map(lN),e[4]=t,e[5]=o);let s;e[6]===o?s=e[7]:(s=(0,Z.jsx)(`ul`,{className:`flex flex-col gap-px`,children:o}),e[6]=o,e[7]=s);let c;return e[8]!==a||e[9]!==s?(c=(0,Z.jsxs)(`section`,{"data-testid":`conflicts-section`,"aria-label":`Conflicted files`,className:`border-b border-amber-200/60 bg-amber-50/40 px-2 py-2 dark:border-amber-900/40 dark:bg-amber-950/20`,children:[a,s]}),e[8]=a,e[9]=s,e[10]=c):c=e[10],c}function lN(e){return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(si,{variant:`ghost`,size:`sm`,"data-testid":`conflicts-section-row`,"data-file":e.file,title:e.file,className:`h-7 w-full justify-start gap-1.5 px-2 font-normal text-[13px] text-amber-800 hover:bg-amber-100/60 hover:text-amber-900 dark:text-amber-300 dark:hover:bg-amber-900/30 dark:hover:text-amber-200`,onClick:()=>sN(e.file),children:[(0,Z.jsx)(ds,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.file})]})},e.file)}var uN=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
29
|
+
`,r);if(s>-1&&s<t&&(e=s),i&&p<f.length){let t=Math.max(0,m?f[p].toA:f[p].fromA);t<=e&&(e=t,m&&p++,o=!0)}if(e>r){let t=document.createTextNode(l.slice(r,e));if(a){let e=d.appendChild(document.createElement(`span`));e.className=a,e.appendChild(t)}else d.appendChild(t);r=e}o&&(m=!m)}}if(u&&t.toA-t.fromA<=o){let t=u.parser.parse(l),n=0;ec(t,{style:t=>mc(e,t)},(e,t,r)=>{e>n&&g(n,e,``),g(e,t,r),n=t}),g(n,l.length,``)}else g(0,l.length,``);return d.firstChild||d.appendChild(document.createElement(`br`)),c})});return dO.set(t.changes,i),i}function mO(e,t){let{state:n}=e,r=t??n.selection.main.head,i=e.state.field(bD).find(e=>e.fromB<=r&&e.endB>=r);if(!i)return!1;let a=e.state.sliceDoc(i.fromB,Math.max(i.fromB,i.toB-1)),o=e.state.field(uO);i.fromB!=i.toB&&i.toA<=o.length&&(a+=e.state.lineBreak);let s=Zs.of({from:i.fromA,to:Math.min(o.length,i.toA),insert:a},o.length);return e.dispatch({effects:lO.of({doc:s.apply(o),changes:s}),userEvent:`accept`}),!0}function hO(e,t){let{state:n}=e,r=t??n.selection.main.head,i=n.field(bD).find(e=>e.fromB<=r&&e.endB>=r);if(!i)return!1;let a=n.field(uO).sliceString(i.fromA,Math.max(i.fromA,i.toA-1));return i.fromA!=i.toA&&i.toB<=n.doc.length&&(a+=n.lineBreak),e.dispatch({changes:{from:i.fromB,to:Math.min(n.doc.length,i.toB),insert:a},userEvent:`revert`}),!0}function gO(e){let t=new rc;for(let n of e.field(bD)){let r=e.facet(_D).overrideChunk&&yO(e,n);t.add(n.fromB,n.fromB,pO(e,n,!!r))}return t.finish()}var _O=$s.define({create:e=>gO(e),update(e,t){return t.state.field(bD,!1)==t.startState.field(bD,!1)?e:gO(t.state)},provide:e=>cc.decorations.from(e)}),vO=new WeakMap;function yO(e,t){let n=vO.get(t);if(n!==void 0)return n;n=null;let r=e.field(uO),i=e.doc,a=r.lineAt(t.endA).number-r.lineAt(t.fromA).number+1,o=i.lineAt(t.endB).number-i.lineAt(t.fromB).number+1;abort:if(a==o&&a<10){let e=[],i=0,o=t.fromA,s=t.fromB;for(let n of t.changes){if(n.fromA<n.toA){i+=n.toA-n.fromA;let t=r.sliceString(o+n.fromA,o+n.toA);if(/\n/.test(t))break abort;e.push(nc.widget({widget:new bO(t),side:-1}).range(s+n.fromB))}n.fromB<n.toB&&e.push(ID.range(s+n.fromB,s+n.toB))}i<t.endA-t.fromA-a*2&&(n=e)}return vO.set(t,n),n}var bO=class extends Ys{constructor(e){super(),this.text=e}eq(e){return this.text==e.text}toDOM(e){let t=document.createElement(`del`);return t.className=`cm-deletedText`,t.textContent=this.text,t}},xO=new class extends lc{constructor(){super(...arguments),this.elementClass=`cm-inlineChangedLineGutter`}},SO=nc.line({class:`cm-inlineChangedLine`});function CO(e,t,n,r){let i=yO(e,t),a=0;if(!i)return!1;for(let o=e.doc.lineAt(t.fromB);;){for(r&&r.add(o.from,o.from,xO),n.add(o.from,o.from,SO);a<i.length&&i[a].to<=o.to;){let e=i[a++];n.add(e.from,e.to,e.value)}if(o.to>=t.endB)break;o=e.doc.lineAt(o.to+1)}return!0}var wO=ee({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}}),TO=G({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}}),EO=cc.theme({".cm-deletedChunk .cm-chunkButtons":{display:`flex`,gap:`0.25rem`},".cm-deletedChunk .cm-chunkButtons button[data-slot='button']":{margin:`0`,border:`1px solid transparent`,borderRadius:`min(var(--radius-md), 10px)`,color:`var(--primary-foreground)`},".cm-deletedChunk .cm-chunkButtons button[data-slot='button'][data-variant='destructive']":{color:`var(--destructive)`}});function DO({addControl:e,nextId:t,removeControl:n,root:r}){return(i,a)=>{let o=document.createElement(`span`);o.className=`inline-flex`;let s=t();return e({id:s,host:o,type:i,action:a}),queueMicrotask(()=>{r.contains(o)||n(s)}),o}}function OO(e){let t=(0,$.c)(32),{oldContent:n,newContent:r,layout:a,conflictMode:o,previewMode:c,oursOverride:l,onResolve:u,onAbort:d}=e,{_:f}=i(),p=l??r,m=(0,Q.useRef)(null),h=(0,Q.useRef)(null),g=(0,Q.useRef)(0),{resolvedTheme:_}=vr(),v=(0,Q.useRef)(u),y=(0,Q.useRef)(d),[b,x]=(0,Q.useState)(null),S;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(S=[],t[0]=S):S=t[0];let[C,w]=(0,Q.useState)(S),T;t[1]!==d||t[2]!==u?(T=()=>{v.current=u,y.current=d},t[1]=d,t[2]=u,t[3]=T):T=t[3],(0,Q.useEffect)(T);let E,D;t[4]!==o||t[5]!==p||t[6]!==a||t[7]!==n||t[8]!==c||t[9]!==_?(E=()=>{let e=m.current;if(!e)return;w([]);let t=new Map,r=!1,i=e=>{r||!t.delete(e)||w(t=>t.filter(t=>t.id!==e))},s=new MutationObserver(()=>{for(let[n,r]of t)e.contains(r)||i(n)});s.observe(e,{childList:!0,subtree:!0});let l=_===`dark`?wO:TO,u=[cc.editable.of(!1),Qs.readOnly.of(!0)],d=[Ec,hc(),...u,l,cc.lineWrapping];if(h.current&&=(h.current.destroy(),null),c)h.current=new cc({doc:p,extensions:d,parent:e}),x(null);else if(o){let a=DO({addControl:e=>{r||(t.set(e.id,e.host),w(t=>[...t,e]))},nextId:()=>(g.current+=1,g.current),removeControl:i,root:e}),o=new cc({doc:p,extensions:[Ec,hc(),cc.editable.of(!1),l,EO,cc.lineWrapping,cO({original:n,highlightChanges:!0,gutter:!0,mergeControls:a,collapseUnchanged:{margin:3,minSize:4}}),cc.updateListener.of(e=>{let t=xD(e.state);x(t?t.chunks.length:0)})],parent:e});h.current=o;let s=xD(o.state);x(s?s.chunks.length:0)}else a===`split`?h.current=new iO({a:{doc:n,extensions:d},b:{doc:p,extensions:d},parent:e,highlightChanges:!0,gutter:!0,collapseUnchanged:{margin:3,minSize:4}}):h.current=new cc({doc:p,extensions:[...d,cO({original:n,highlightChanges:!0,gutter:!0,mergeControls:!1,collapseUnchanged:{margin:3,minSize:4}})],parent:e});return()=>{r=!0,s.disconnect(),h.current&&=(h.current.destroy(),null)}},D=[n,p,a,_,o,c],t[4]=o,t[5]=p,t[6]=a,t[7]=n,t[8]=c,t[9]=_,t[10]=E,t[11]=D):(E=t[10],D=t[11]),(0,Q.useEffect)(E,D);let O;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(O=function(){let e=h.current;!e||!(e instanceof cc)||v.current?.(e.state.doc.toString())},t[12]=O):O=t[12];let k=O,A;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(A=function(){let e=h.current;!e||!(e instanceof cc)||ye(e)},t[13]=A):A=t[13];let j=A,M=b===0,N;t[14]!==f||t[15]!==b?(N=b===null?``:b===0?f({id:`lPzyrU`}):Ko._({id:`8FqTCr`,values:{chunksRemaining:b}}),t[14]=f,t[15]=b,t[16]=N):N=t[16];let P=N,F;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(`div`,{ref:m,className:`diff-view min-h-0 flex-1 overflow-y-auto subtle-scrollbar`}),t[17]=F):F=t[17];let I;if(t[18]!==f||t[19]!==C){let e;t[21]===f?e=t[22]:(e=e=>(0,qc.createPortal)((0,Z.jsx)(si,{type:`button`,variant:e.type===`accept`?`default`:`destructive`,size:`xs`,onClick:t=>{e.action(t.nativeEvent)},children:e.type===`accept`?f({id:`g3UF2V`}):f({id:`1t_NnN`})}),e.host,e.id),t[21]=f,t[22]=e),I=C.map(e),t[18]=f,t[19]=C,t[20]=I}else I=t[20];let L;t[23]!==M||t[24]!==o||t[25]!==P||t[26]!==d||t[27]!==u?(L=o&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 border-t shrink-0`,children:[(0,Z.jsx)(`span`,{className:`text-xs ${M?`text-emerald-600 dark:text-emerald-400`:`text-muted-foreground`}`,children:P}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[d&&(0,Z.jsx)(si,{className:`uppercase font-mono`,variant:`ghost`,size:`sm`,onClick:d,children:(0,Z.jsx)(s,{id:`XyOUTJ`})}),(0,Z.jsx)(si,{className:`uppercase font-mono`,variant:`outline`,size:`sm`,onClick:j,children:`Undo`}),u&&(0,Z.jsx)(si,{variant:`default`,size:`sm`,disabled:!M,onClick:k,children:(0,Z.jsx)(s,{id:`Lcehxn`})})]})]}),t[23]=M,t[24]=o,t[25]=P,t[26]=d,t[27]=u,t[28]=L):L=t[28];let R;return t[29]!==L||t[30]!==I?(R=(0,Z.jsxs)(`div`,{className:`flex flex-col h-full`,children:[F,I,L]}),t[29]=L,t[30]=I,t[31]=R):R=t[31],R}async function kO(e,t,n){try{let r={file:e,strategy:t};n!==void 0&&(r.content=n);let i=await fetch(`/api/sync/resolve-conflict`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(i.ok)return{ok:!0};let a;try{let e=await i.json();typeof e.detail==`string`?a=e.detail:typeof e.title==`string`&&(a=e.title)}catch{}return{ok:!1,detail:a}}catch(n){let r=n instanceof Error?n.message:String(n);return console.warn(JSON.stringify({event:`conflict-resolve-dispatch-failed`,file:e,strategy:t,detail:r})),{ok:!1,detail:r}}}async function AO(e,t){return kO(e,`content`,t)}async function jO(e){return kO(e,`mine`)}async function MO(e){return kO(e,`theirs`)}async function NO(e){return kO(e,`delete`)}async function PO(e){try{let t=await fetch(`/api/sync/conflict-content?file=${encodeURIComponent(e)}&source=ytext`);if(!t.ok){let n;try{let e=await t.json();typeof e.detail==`string`?n=e.detail:typeof e.title==`string`&&(n=e.title)}catch{}return console.warn(JSON.stringify({event:`conflict-content-fetch-failed`,file:e,status:t.status,detail:n})),null}let n=await t.json(),r=n.kind===`delete-modify`||n.kind===`modify-delete`||n.kind===`both-modified`?n.kind:`both-modified`;return n.kind!==r&&console.warn(JSON.stringify({event:`conflict-kind-missing-fallback`,file:e,receivedKind:n.kind??null})),{base:n.base??``,ours:n.ours??``,theirs:n.theirs??``,kind:r}}catch(t){return console.warn(JSON.stringify({event:`conflict-content-fetch-failed`,file:e,status:null,detail:t instanceof Error?t.message:String(t)})),null}}function FO(e){let t=(0,$.c)(84),{docName:n}=e,{_:r}=i(),{conflicts:a,loading:o}=Ni(),c;if(t[0]!==a||t[1]!==n){let e;t[3]===n?e=t[4]:(e=e=>Ho(e.file)===n,t[3]=n,t[4]=e),c=a.find(e),t[0]=a,t[1]=n,t[2]=c}else c=t[2];let l=c,u=l?.file??`${n}.md`,[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),_,v;t[5]===n?(_=t[6],v=t[7]):(_=()=>(console.warn(JSON.stringify({event:`editor-area-swap-to-diffview`,"doc.name":n})),()=>{console.warn(JSON.stringify({event:`editor-area-swap-from-diffview`,"doc.name":n}))}),v=[n],t[5]=n,t[6]=_,t[7]=v),(0,Q.useEffect)(_,v);let y=o||l===void 0,b,x;t[8]!==y||t[9]!==u?(b=()=>{if(y)return;let e=!1;return f(null),m(!1),PO(u).then(t=>{e||(t===null?m(!0):f(t))}),()=>{e=!0}},x=[u,y],t[8]=y,t[9]=u,t[10]=b,t[11]=x):(b=t[10],x=t[11]),(0,Q.useEffect)(b,x);let S;t[12]!==r||t[13]!==u?(S=async function(e){let t=await AO(u,e);t.ok||X.error(r({id:`K-h9cT`,values:{filePath:u}}),{description:t.detail})},t[12]=r,t[13]=u,t[14]=S):S=t[14];let C=S,w;t[15]!==r||t[16]!==u?(w=async function(e){g(!0);let t=await e(u);t.ok||(g(!1),X.error(r({id:`jPUPvG`,values:{filePath:u}}),{description:t.detail}))},t[15]=r,t[16]=u,t[17]=w):w=t[17];let T=w;if(p){let e;return t[18]===u?e=t[19]:(e=(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-sm text-muted-foreground`,children:(0,Z.jsx)(s,{id:`ajz9F8`,values:{filePath:u}})}),t[18]=u,t[19]=e),e}if(d===null){let e;return t[20]===u?e=t[21]:(e=(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-sm text-muted-foreground`,children:(0,Z.jsx)(s,{id:`DF1MtZ`,values:{filePath:u}})}),t[20]=u,t[21]=e),e}if(d.kind===`delete-modify`){let e;t[22]===d.theirs?e=t[23]:(e=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,Z.jsx)(OO,{oldContent:``,newContent:d.theirs,layout:`unified`,previewMode:!0})}),t[22]=d.theirs,t[23]=e);let n;t[24]===u?n=t[25]:(n={filePath:u},t[24]=u,t[25]=n);let r;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(r={0:(0,Z.jsx)(`span`,{className:`font-medium text-foreground`})},t[26]=r):r=t[26];let i;t[27]===n?i=t[28]:(i=(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Z.jsx)(s,{id:`V48OUT`,values:n,components:r})}),t[27]=n,t[28]=i);let a;t[29]===T?a=t[30]:(a=()=>void T(NO),t[29]=T,t[30]=a);let o;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(s,{id:`Vlc75q`}),t[31]=o):o=t[31];let c;t[32]!==h||t[33]!==a?(c=(0,Z.jsx)(si,{type:`button`,variant:`destructive`,disabled:h,onClick:a,children:o}),t[32]=h,t[33]=a,t[34]=c):c=t[34];let l;t[35]===T?l=t[36]:(l=()=>void T(MO),t[35]=T,t[36]=l);let f;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(s,{id:`3mFsc3`}),t[37]=f):f=t[37];let p;t[38]!==h||t[39]!==l?(p=(0,Z.jsx)(si,{type:`button`,variant:`default`,disabled:h,onClick:l,children:f}),t[38]=h,t[39]=l,t[40]=p):p=t[40];let m;t[41]!==c||t[42]!==p?(m=(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-3`,children:[c,p]}),t[41]=c,t[42]=p,t[43]=m):m=t[43];let g;t[44]!==i||t[45]!==m?(g=(0,Z.jsxs)(`div`,{className:`flex flex-shrink-0 flex-wrap items-center justify-between gap-x-6 gap-y-3 border-t px-6 py-4`,children:[i,m]}),t[44]=i,t[45]=m,t[46]=g):g=t[46];let _;return t[47]!==g||t[48]!==e?(_=(0,Z.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[e,g]}),t[47]=g,t[48]=e,t[49]=_):_=t[49],_}if(d.kind===`modify-delete`){let e;t[50]===d.ours?e=t[51]:(e=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,Z.jsx)(OO,{oldContent:``,newContent:d.ours,layout:`unified`,previewMode:!0})}),t[50]=d.ours,t[51]=e);let n;t[52]===u?n=t[53]:(n={filePath:u},t[52]=u,t[53]=n);let r;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(r={0:(0,Z.jsx)(`span`,{className:`font-medium text-foreground`})},t[54]=r):r=t[54];let i;t[55]===n?i=t[56]:(i=(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Z.jsx)(s,{id:`EhDLBx`,values:n,components:r})}),t[55]=n,t[56]=i);let a;t[57]===T?a=t[58]:(a=()=>void T(jO),t[57]=T,t[58]=a);let o;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(s,{id:`0NA4b3`}),t[59]=o):o=t[59];let c;t[60]!==h||t[61]!==a?(c=(0,Z.jsx)(si,{type:`button`,variant:`default`,disabled:h,onClick:a,children:o}),t[60]=h,t[61]=a,t[62]=c):c=t[62];let l;t[63]===T?l=t[64]:(l=()=>void T(NO),t[63]=T,t[64]=l);let f;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(s,{id:`qSxaOz`}),t[65]=f):f=t[65];let p;t[66]!==h||t[67]!==l?(p=(0,Z.jsx)(si,{type:`button`,variant:`destructive`,disabled:h,onClick:l,children:f}),t[66]=h,t[67]=l,t[68]=p):p=t[68];let m;t[69]!==c||t[70]!==p?(m=(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-3`,children:[c,p]}),t[69]=c,t[70]=p,t[71]=m):m=t[71];let g;t[72]!==i||t[73]!==m?(g=(0,Z.jsxs)(`div`,{className:`flex flex-shrink-0 flex-wrap items-center justify-between gap-x-6 gap-y-3 border-t px-6 py-4`,children:[i,m]}),t[72]=i,t[73]=m,t[74]=g):g=t[74];let _;return t[75]!==g||t[76]!==e?(_=(0,Z.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[e,g]}),t[75]=g,t[76]=e,t[77]=_):_=t[77],_}let E;t[78]===C?E=t[79]:(E=e=>void C(e),t[78]=C,t[79]=E);let D;return t[80]!==d.ours||t[81]!==d.theirs||t[82]!==E?(D=(0,Z.jsx)(OO,{oldContent:d.theirs,newContent:d.ours,layout:`unified`,conflictMode:!0,onResolve:E}),t[80]=d.ours,t[81]=d.theirs,t[82]=E,t[83]=D):D=t[83],D}function IO(e){let t=(0,$.c)(2),{docName:n,provider:r,children:i}=e;(0,Q.use)(Ft(n,r));let a;return t[0]===i?a=t[1]:(a=(0,Z.jsx)(Z.Fragment,{children:i}),t[0]=i,t[1]=a),a}var LO=`__back-nav__`;function RO(e){return e instanceof Re||e instanceof gt||e instanceof Ne||e instanceof Qe||e instanceof Ot||e instanceof me?e.docName:null}function zO(e){if(e instanceof Re){let t=e.docName;return{title:Ko._({id:`Jejur6`}),summary:Ko._({id:`jSY41h`,values:{docName:t}})}}if(e instanceof gt){let t=e.docName;return{title:Ko._({id:`V7QxyT`}),summary:Ko._({id:`xG4tb6`,values:{docName:t}})}}if(e instanceof Ne){let t=e.docName;return{title:Ko._({id:`1di5fu`}),summary:Ko._({id:`PQCdtv`,values:{docName:t}})}}if(e instanceof Qe){let t=e.docName;return{title:Ko._({id:`wvbc1r`}),summary:Ko._({id:`IX7-sq`,values:{docName:t}})}}if(e instanceof Ot)return{title:Ko._({id:`Gfr4fu`}),summary:Ko._({id:`j6LB7S`})};if(e instanceof me){let t=e.docName;return{title:Ko._({id:`vv7kpg`}),summary:Ko._({id:`mdKFEy`,values:{docName:t}})}}let t=e instanceof Error&&e.message?e.message:Ko._({id:`W5A0Ly`});return{title:Ko._({id:`29VNqC`}),summary:t}}function BO(e){let t=(0,$.c)(28),{error:n,resetErrorBoundary:r,activeDocName:i,previousDocName:a,onNavigateBack:o}=e,c;t[0]===n?c=t[1]:(c=zO(n),t[0]=n,t[1]=c);let{title:l,summary:u}=c,d=!!a&&!!o,f=(0,Q.useRef)(null),p,m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>{f.current?.focus()},m=[],t[2]=p,t[3]=m):(p=t[2],m=t[3]),(0,Q.useEffect)(p,m);let h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(Vx,{size:80,variant:`sleeping`}),t[4]=h):h=t[4];let g;t[5]===l?g=t[6]:(g=(0,Z.jsx)(`h2`,{id:`document-error-title`,className:`text-2xl font-light tracking-tighter text-balance`,children:l}),t[5]=l,t[6]=g);let _;t[7]===u?_=t[8]:(_=(0,Z.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:u}),t[7]=u,t[8]=_);let v;t[9]!==g||t[10]!==_?(v=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[g,_]}),t[9]=g,t[10]=_,t[11]=v):v=t[11];let y;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(s,{id:`KDw4GX`}),t[12]=y):y=t[12];let b;t[13]===r?b=t[14]:(b=(0,Z.jsx)(si,{ref:f,variant:`default`,onClick:r,children:y}),t[13]=r,t[14]=b);let x;t[15]!==i||t[16]!==d||t[17]!==n||t[18]!==o||t[19]!==a||t[20]!==r?(x=d?(0,Z.jsx)(si,{variant:`ghost`,className:`font-mono uppercase`,onClick:()=>{!a||!o||(st(RO(n)??i),o(a),r(LO))},children:(0,Z.jsx)(s,{id:`CKyk7Q`})}):null,t[15]=i,t[16]=d,t[17]=n,t[18]=o,t[19]=a,t[20]=r,t[21]=x):x=t[21];let S;t[22]!==x||t[23]!==b?(S=(0,Z.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[b,x]}),t[22]=x,t[23]=b,t[24]=S):S=t[24];let C;return t[25]!==S||t[26]!==v?(C=(0,Z.jsxs)(`div`,{role:`alert`,"aria-labelledby":`document-error-title`,"data-slot":`document-error-boundary`,className:`flex h-full flex-col items-center justify-center gap-8 p-8 text-center`,children:[h,v,S]}),t[25]=S,t[26]=v,t[27]=C):C=t[27],C}function VO(e){let t=(0,$.c)(17),{activeDocName:n,previousDocName:r,onNavigateBack:i,onRecycle:a,children:o}=e,s;t[0]!==n||t[1]!==i||t[2]!==r?(s=e=>(0,Z.jsx)(BO,{...e,activeDocName:n,previousDocName:r,onNavigateBack:i}),t[0]=n,t[1]=i,t[2]=r,t[3]=s):s=t[3];let c;t[4]===n?c=t[5]:(c=[n],t[4]=n,t[5]=c);let l;t[6]!==n||t[7]!==a?(l=e=>{if(e.reason===`imperative-api`){if(Array.isArray(e.args)&&e.args[0]===LO){console.warn(`[DocumentErrorBoundary] back-nav reset (no recycle)`);return}a(n),console.warn(`[DocumentErrorBoundary] retry recycled ${n}`)}else console.warn(`[DocumentErrorBoundary] reset by key change (${e.prev?.[0]} → ${e.next?.[0]})`)},t[6]=n,t[7]=a,t[8]=l):l=t[8];let u;t[9]===n?u=t[10]:(u=e=>{console.error(`[DocumentErrorBoundary] rendered fallback for ${n}: ${zO(e).title}`,e)},t[9]=n,t[10]=u);let d;return t[11]!==o||t[12]!==s||t[13]!==c||t[14]!==l||t[15]!==u?(d=(0,Z.jsx)(le,{fallbackRender:s,resetKeys:c,onReset:l,onError:u,children:o}),t[11]=o,t[12]=s,t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}function HO(e){let t=e.document.getText(`source`).toString(),{map:n,parseError:r}=Sr(t);return{map:n,keys:On(t),parseError:r}}function UO(e){let t=(0,$.c)(21),{provider:n}=e,r;t[0]===n?r=t[1]:(r=()=>HO(n),t[0]=n,t[1]=r);let[i,a]=(0,Q.useState)(r),o,s;t[2]===n?(o=t[3],s=t[4]):(o=()=>{let e=jn(n);a(e.current());let t=e.subscribe(e=>{a(e)});return()=>{t(),e.dispose()}},s=[n],t[2]=n,t[3]=o,t[4]=s),(0,Q.useEffect)(o,s);let c;t[5]===i.map.icon?c=t[6]:(c=Xe(i.map.icon),t[5]=i.map.icon,t[6]=c);let l=c,u;t[7]===i.map.cover?u=t[8]:(u=ut(i.map.cover),t[7]=i.map.cover,t[8]=u);let d=u,f=d.kind===`url`||d.kind===`path`,p=l.kind!==`unsupported`;if(!f&&!p)return null;let m=f?`true`:`false`,h=p?`true`:`false`,g;t[9]!==d||t[10]!==f?(g=f?(0,Z.jsx)(WO,{cover:d}):null,t[9]=d,t[10]=f,t[11]=g):g=t[11];let _;t[12]!==f||t[13]!==p||t[14]!==l?(_=p?(0,Z.jsx)(GO,{icon:l,hasCover:f}):null,t[12]=f,t[13]=p,t[14]=l,t[15]=_):_=t[15];let v;return t[16]!==m||t[17]!==h||t[18]!==g||t[19]!==_?(v=(0,Z.jsxs)(`div`,{className:`page-header editor-content-aligned`,"data-has-cover":m,"data-has-icon":h,"aria-hidden":`true`,"data-testid":`page-header`,children:[g,_]}),t[16]=m,t[17]=h,t[18]=g,t[19]=_,t[20]=v):v=t[20],v}function WO(e){let t=(0,$.c)(2),{cover:n}=e,r;return t[0]===n.value?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`page-header-cover`,"data-testid":`page-header-cover`,children:(0,Z.jsx)(`img`,{src:n.value,alt:``,draggable:!1,loading:`lazy`,referrerPolicy:`no-referrer`,className:`page-header-cover-img`})}),t[0]=n.value,t[1]=r),r}function GO(e){let t=(0,$.c)(9),{icon:n,hasCover:r}=e,i=r?`page-header-icon page-header-icon--with-cover`:`page-header-icon`;if(n.kind===`emoji`){let e;return t[0]!==n.value||t[1]!==i?(e=(0,Z.jsx)(`span`,{className:i,"data-testid":`page-header-icon`,"data-kind":`emoji`,children:n.value}),t[0]=n.value,t[1]=i,t[2]=e):e=t[2],e}let a;t[3]===n.value?a=t[4]:(a=(0,Z.jsx)(`img`,{src:n.value,alt:``,draggable:!1,referrerPolicy:`no-referrer`,className:`page-header-icon-img`}),t[3]=n.value,t[4]=a);let o;return t[5]!==n.kind||t[6]!==i||t[7]!==a?(o=(0,Z.jsx)(`span`,{className:i,"data-testid":`page-header-icon`,"data-kind":n.kind,children:a}),t[5]=n.kind,t[6]=i,t[7]=a,t[8]=o):o=t[8],o}function KO(e){let t=e.document.getText(`source`).toString(),{map:n,parseError:r}=Sr(t);return{map:n,keys:On(t),parseError:r}}function qO(e){let t=(0,$.c)(127),{provider:n}=e,{_:r}=i(),[a,o]=(0,Q.useState)(null),c;t[0]===n?c=t[1]:(c=()=>KO(n),t[0]=n,t[1]=c);let[l,u]=(0,Q.useState)(c),d,f;t[2]===n?(d=t[3],f=t[4]):(d=()=>{let e=jn(n);o(e),u(e.current());let t=e.subscribe(e=>{u(e)});return()=>{t(),e.dispose(),o(t=>t===e?null:t)}},f=[n],t[2]=n,t[3]=d,t[4]=f),(0,Q.useEffect)(d,f);let p=l.map,m=l.keys,h=l.parseError,[g,_]=(0,Q.useState)(!1),v;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v={},t[5]=v):v=t[5];let[y,b]=(0,Q.useState)(v),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(null),T;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(T={},t[6]=T):T=t[6];let[E,D]=(0,Q.useState)(T),O;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(O={},t[7]=O):O=t[7];let[k,A]=(0,Q.useState)(O),j=n.configuration.name??``,N;t[8]!==r||t[9]!==a?(N=function(e){if(!a)return{ok:!1,error:r({id:`9zb2WA`})};let t=a.patch(e);if(t.ok)return{ok:!0};if(t.error.code===`WRITE_ERROR`)return console.warn(`[PropertyPanel] binding write error:`,t.error.detail),{ok:!1,error:t.error.detail};let n=yr(t.error);return{ok:!1,error:t.error.issues[0]?.message??r({id:`8fRyLo`}),fieldErrors:Object.keys(n).length>0?n:void 0}},t[8]=r,t[9]=a,t[10]=N):N=t[10];let P=N,F;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(F=function(e){D(t=>{if(!Object.hasOwn(t,e))return t;let n={...t};return delete n[e],n})},t[11]=F):F=t[11];let I=F,L;t[12]===r?L=t[13]:(L=function(e,t){if(e.ok)return;let n=e.error??r({id:`4g19V6`}),i=e.fieldErrors??{};D(e=>{let r={...e};for(let e of t)r[e]=i[e]??n;return r}),A(e=>{let n={...e};for(let e of t)n[e]=(n[e]??0)+1;return n})},t[12]=r,t[13]=L);let R=L,z;t[14]!==P||t[15]!==R?(z=function(e,t){I(e),R(P({[e]:t}),[e])},t[14]=P,t[15]=R,t[16]=z):z=t[16];let B=z,V;t[17]!==P||t[18]!==R?(V=function(e){I(e),R(P({[e]:null}),[e])},t[17]=P,t[18]=R,t[19]=V):V=t[19];let H=V,U;t[20]!==r||t[21]!==a?(U=function(e,t){if(!a)return{ok:!1,error:r({id:`9zb2WA`})};if(e===t)return{ok:!0};let n=a.rename(e,t);if(n.ok)return{ok:!0};if(n.error.code===`WRITE_ERROR`)return{ok:!1,error:n.error.detail};let i=yr(n.error);return{ok:!1,error:n.error.issues[0]?.message??r({id:`I1gRhX`}),fieldErrors:Object.keys(i).length>0?i:void 0}},t[20]=r,t[21]=a,t[22]=U):U=t[22];let W=U,G;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(G=function(e,t){return`${e} ${t}`},t[23]=G):G=t[23];let K=G,q;t[24]!==a||t[25]!==m?(q=function(e){if(!a)return;let t=String(e.active.id),n=e.over?String(e.over.id):null;if(!n||t===n)return;let r=m.map((e,t)=>K(e,t)),i=r.indexOf(t),o=r.indexOf(n);if(i<0||o<0)return;let s=m.slice(),[c]=s.splice(i,1);if(!c)return;s.splice(o,0,c);let l=a.reorder(s);l.ok||console.warn(`[PropertyPanel] reorder failed:`,l.error)},t[24]=a,t[25]=m,t[26]=q):q=t[26];let J=q,Y;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(Y={activationConstraint:{distance:4}},t[27]=Y):Y=t[27];let ee;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(ee={coordinateGetter:ha},t[28]=ee):ee=t[28];let te=Ci(ra(_a,Y),ra(ya,ee)),ne;t[29]!==B||t[30]!==p?(ne=function(e,t){let n=p[e];if(n===void 0)return;b(n=>({...n,[e]:t}));let r=aa(n,t);(!Object.hasOwn(p,e)||!Cr(n,r))&&B(e,r)},t[29]=B,t[30]=p,t[31]=ne):ne=t[31];let re=ne,ie;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(ie=function(){S({name:``,type:`text`,value:``,error:null}),_(!1)},t[32]=ie):ie=t[32];let ae=ie,{addPropertySignal:oe,clearAddProperty:se}=GS(),ce;t[33]!==oe||t[34]!==j?(ce=oe.get(j)??0,t[33]=oe,t[34]=j,t[35]=ce):ce=t[35];let le=ce,ue,de;t[36]===le?(ue=t[37],de=t[38]):(ue=()=>{le>0&&(S({name:``,type:`text`,value:``,error:null}),_(!1))},de=[le],t[36]=le,t[37]=ue,t[38]=de),(0,Q.useEffect)(ue,de);let fe,pe;t[39]!==se||t[40]!==j?(fe=()=>()=>se(j),pe=[j,se],t[39]=se,t[40]=j,t[41]=fe,t[42]=pe):(fe=t[41],pe=t[42]),(0,Q.useEffect)(fe,pe);let me;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(me=function(e){S(t=>{if(!t)return t;let n=e===`date`?new Date().toISOString().slice(0,10):qi[e];return{...t,type:e,value:n,error:null}})},t[43]=me):me=t[43];let he=me,ge;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(ge=function(e){S(t=>t&&{...t,value:e})},t[44]=ge):ge=t[44];let _e=ge,ve;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(ve=function(e){S(t=>t&&{...t,name:e,error:null})},t[45]=ve):ve=t[45];let ye=ve,be;t[46]!==r||t[47]!==x||t[48]!==P||t[49]!==p?(be=function(){if(!x)return;let e=x.name.trim();if(!e){S({...x,error:r({id:`8_brI5`})});return}if(e===`frontmatter`){S({...x,error:r({id:`dURmlQ`})});return}if(Object.hasOwn(p,e)){S({...x,error:r({id:`njU86j`,values:{trimmed:e}})});return}let t=P({[e]:x.value});if(t.ok){S(null);return}let n=t.fieldErrors?.[e],i=t.error??r({id:`OJeiSH`});S({...x,error:n??i})},t[46]=r,t[47]=x,t[48]=P,t[49]=p,t[50]=be):be=t[50];let xe=be,Se;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(Se=function(){S(null)},t[51]=Se):Se=t[51];let Ce=Se,we;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(we=function(e){w({key:e,draft:e,error:null})},t[52]=we):we=t[52];let Te=we,Ee;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=function(e){w(t=>t&&{...t,draft:e,error:null})},t[53]=Ee):Ee=t[53];let De=Ee,Oe;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=function(){w(null)},t[54]=Oe):Oe=t[54];let ke=Oe,Ae;t[55]!==r||t[56]!==p||t[57]!==W||t[58]!==C?(Ae=function(){if(!C)return;let e=C.draft.trim();if(!e){w(null);return}if(e===C.key){w(null);return}if(e===`frontmatter`){w({...C,error:r({id:`dURmlQ`})});return}if(Object.hasOwn(p,e)){w({...C,error:r({id:`njU86j`,values:{trimmed:e}})});return}let t=W(C.key,e);if(t.ok){b(t=>{if(!Object.hasOwn(t,C.key))return t;let n={...t};return n[e]=n[C.key],delete n[C.key],n}),I(C.key),w(null);return}let n=t.fieldErrors?.[e]??t.fieldErrors?.[C.key]??t.error??r({id:`2ryd91`});w({...C,error:n})},t[55]=r,t[56]=p,t[57]=W,t[58]=C,t[59]=Ae):Ae=t[59];let je=Ae,Me;t[60]!==p||t[61]!==m?(Me=m.length>0?m:Object.keys(p),t[60]=p,t[61]=m,t[62]=Me):Me=t[62];let Ne=Me,Pe;if(t[63]!==Ne){Pe=new Map;for(let e of Ne)Pe.set(e,(Pe.get(e)??0)+1);t[63]=Ne,t[64]=Pe}else Pe=t[64];if(Ne.length===0&&!x&&!h)return null;let Fe=!g,Ie;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=e=>_(!e),t[65]=Ie):Ie=t[65];let Le=!g,Re;t[66]===Le?Re=t[67]:(Re=(0,Z.jsx)(jo,{"data-expanded":Le,className:`size-3.5 shrink-0 text-muted-foreground transition-transform duration-150 ease-out data-[expanded=true]:rotate-90`}),t[66]=Le,t[67]=Re);let ze;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(ze=(0,Z.jsx)(`span`,{children:(0,Z.jsx)(s,{id:`l_UFPv`})}),t[68]=ze):ze=t[68];let Be;t[69]===Re?Be=t[70]:(Be=(0,Z.jsx)(Mo,{asChild:!0,children:(0,Z.jsxs)(si,{type:`button`,variant:`ghost`,className:`mb-1.5 flex h-auto w-fit bg-transparent! items-center gap-1 px-1 py-0.5 text-base font-medium text-foreground hover:bg-transparent hover:text-foreground`,children:[Re,ze]})}),t[69]=Re,t[70]=Be);let Ve;t[71]===h?Ve=t[72]:(Ve=h?(0,Z.jsxs)(`div`,{role:`alert`,"data-testid":`property-panel-yaml-error`,className:`mb-1 flex items-start gap-1.5 rounded border border-destructive/30 bg-destructive/5 px-2 py-1.5 text-[11px] text-destructive`,children:[(0,Z.jsx)(ds,{className:`size-3.5 shrink-0 mt-0.5`}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(s,{id:`zaXlhf`}),(0,Z.jsx)(`span`,{className:`block text-[10px] opacity-80`,children:h})]})]}):null,t[71]=h,t[72]=Ve);let He;if(t[73]!==Ne){let e;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(e=(e,t)=>K(e,t),t[75]=e):e=t[75],He=Ne.map(e),t[73]=Ne,t[74]=He}else He=t[74];let Ue;if(t[76]!==B||t[77]!==je||t[78]!==Pe||t[79]!==E||t[80]!==p||t[81]!==y||t[82]!==H||t[83]!==C||t[84]!==Ne||t[85]!==k||t[86]!==re){let e;t[88]!==B||t[89]!==je||t[90]!==Pe||t[91]!==E||t[92]!==p||t[93]!==y||t[94]!==H||t[95]!==C||t[96]!==k||t[97]!==re?(e=(e,t)=>{let n=p[e];if(n===void 0)return null;let r=y[e]??An(n),i=C?.key===e?C:null,a=(Pe.get(e)??0)>1;return(0,Z.jsx)(Fi,{sortableId:K(e,t),keyName:e,value:n,declared:r,error:E[e]??null,resetCounter:k[e]??0,isDuplicate:a,rename:{state:i,onBegin:()=>Te(e),onChangeDraft:De,onCommit:je,onCancel:ke},onCommit:t=>B(e,t),onChangeType:t=>re(e,t),onRemove:()=>H(e)},`${e}-${t}`)},t[88]=B,t[89]=je,t[90]=Pe,t[91]=E,t[92]=p,t[93]=y,t[94]=H,t[95]=C,t[96]=k,t[97]=re,t[98]=e):e=t[98],Ue=Ne.map(e),t[76]=B,t[77]=je,t[78]=Pe,t[79]=E,t[80]=p,t[81]=y,t[82]=H,t[83]=C,t[84]=Ne,t[85]=k,t[86]=re,t[87]=Ue}else Ue=t[87];let We;t[99]!==He||t[100]!==Ue?(We=(0,Z.jsx)(pa,{items:He,strategy:Gi,children:Ue}),t[99]=He,t[100]=Ue,t[101]=We):We=t[101];let Ge;t[102]!==J||t[103]!==te||t[104]!==We?(Ge=(0,Z.jsx)(Ya,{sensors:te,collisionDetection:xa,onDragEnd:J,children:We}),t[102]=J,t[103]=te,t[104]=We,t[105]=Ge):Ge=t[105];let Ke;t[106]!==B||t[107]!==E||t[108]!==p||t[109]!==k?(Ke=Object.hasOwn(p,`tags`)?null:(0,Z.jsx)(Fi,{keyName:`tags`,value:[],declared:`list`,error:E.tags??null,resetCounter:k.tags??0,isPlaceholder:!0,onCommit:e=>B(`tags`,e),onChangeType:JO},`virtual-tags`),t[106]=B,t[107]=E,t[108]=p,t[109]=k,t[110]=Ke):Ke=t[110];let qe;t[111]!==r||t[112]!==x||t[113]!==xe?(qe=x?(0,Z.jsx)(ta,{draft:x,onChangeName:ye,onChangeType:he,onChangeValue:_e,onCommit:xe,onCancel:Ce}):(0,Z.jsxs)(`div`,{className:`mt-1 flex items-center gap-1`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-7 w-4 shrink-0`}),(0,Z.jsxs)(si,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`add-property-trigger`,onClick:ae,"aria-label":r({id:`F-NRCj`}),className:`flex items-center gap-1.5 rounded px-2 py-1 font-medium text-sm hover:bg-muted/50 hover:text-foreground`,children:[(0,Z.jsx)(M,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:(0,Z.jsx)(s,{id:`m16xKo`})})]})]}),t[111]=r,t[112]=x,t[113]=xe,t[114]=qe):qe=t[114];let Je;t[115]!==Ve||t[116]!==Ge||t[117]!==Ke||t[118]!==qe?(Je=(0,Z.jsxs)(Ao,{className:`overflow-hidden data-[state=open]:animate-[collapsible-down_150ms_ease-out] data-[state=closed]:animate-[collapsible-up_150ms_ease-in]`,children:[Ve,Ge,Ke,qe]}),t[115]=Ve,t[116]=Ge,t[117]=Ke,t[118]=qe,t[119]=Je):Je=t[119];let Ye;t[120]!==Fe||t[121]!==Be||t[122]!==Je?(Ye=(0,Z.jsx)(`div`,{className:`property-panel editor-content-aligned pt-4 pb-4 text-sm`,"data-testid":`property-panel`,children:(0,Z.jsxs)(No,{open:Fe,onOpenChange:Ie,children:[Be,Je]})}),t[120]=Fe,t[121]=Be,t[122]=Je,t[123]=Ye):Ye=t[123];let Xe;return t[124]!==a||t[125]!==Ye?(Xe=(0,Z.jsx)(Di,{binding:a,children:Ye}),t[124]=a,t[125]=Ye,t[126]=Xe):Xe=t[126],Xe}function JO(){}var YO=v(`LARGE_DOC_CHAR_THRESHOLD`,5e5);function XO(e){let t=e.threshold??YO;return e.ytextLength>t?{renderSource:e.isSourceMode||e.visitedSource,renderVisual:!e.isSourceMode||e.visitedVisual,isLarge:!0}:{renderSource:!0,renderVisual:!0,isLarge:!1}}function ZO(e){return e.hasEmittedFirstToggle||!e.isLarge?!1:e.renderSource&&e.renderVisual}var QO=v(`ACTIVITY_MOUNT_LIMIT`,3);function $O(){return n(()=>import(`./SourceEditor-CPuDd_gu.js`),__vite__mapDeps([56,1,37,2,38,39,23,40,41,42,43,44,45,46,47,14,6,8,9,22,3,24,4,12,10,11,48,49,57,26,55]),import.meta.url)}var ek=(0,Q.lazy)(async()=>({default:(await $O()).SourceEditor}));function tk(e,t,n){if(n<=0)return[];let r=e.filter(e=>!Ge(e.docName)),i=[...r].sort((e,t)=>t.lastAccessedAt-e.lastAccessedAt).slice(0,n);if(t===null||i.some(e=>e.docName===t))return i;let a=r.find(e=>e.docName===t);return a?[...i.slice(0,n-1),a]:i}function nk(e,t){return t.kind===`idle`?null:t.kind===`failed`&&t.failedDocNames.includes(e)?{kind:`failed`,title:Ko._({id:`MTs6g3`}),summary:t.reason===`clear-data-timeout`?Ko._({id:`Sc1bKE`,values:{docName:e}}):Ko._({id:`ovIGrT`,values:{docName:e}}),actionLabel:Ko._({id:`HpK_8d`})}:t.kind===`recovering`&&t.docNames.includes(e)?{kind:`recovering`,title:Ko._({id:`cF9DyA`}),summary:t.phase===`clearing-local-cache`?Ko._({id:`bmC18N`,values:{docName:e}}):Ko._({id:`pAgkuZ`,values:{docName:e}})}:null}function rk(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(Wt,{name:`activity-pool`,children:(0,Z.jsx)(ik,{...e})}),t[0]=e,t[1]=n),n}function ik(e){let t=(0,$.c)(15),{activeDocName:n,isSourceMode:r,editorPlaceholder:i,previousDocName:a,onNavigateBack:o,onRecycle:s}=e,{poolEntries:c,serverRestartRecovery:l}=pt(),{pages:u,loading:d}=es(),f=tk(c,n,QO),p=(0,Q.useRef)(``),h=f.map(ak).join(`,`),g=(0,Q.useRef)(c),_,v;t[0]===c?(_=t[1],v=t[2]):(_=()=>{g.current=c},v=[c],t[0]=c,t[1]=_,t[2]=v),(0,Q.useLayoutEffect)(_,v),(0,Q.useLayoutEffect)(()=>{if(p.current===h)return;let e=p.current?p.current.split(`,`):[],t=h?h.split(`,`):[],r=e.filter(e=>!t.includes(e)),i=t.filter(t=>!e.includes(t));for(let e of r)m(e);for(let e of i){let t=g.current.find(t=>t.docName===e)?.poolEventId;W(e,t&&t.length>0?t:crypto.randomUUID())}ue(`ok/activity/mount-list-change`,{active:n,mounted:t,evicted:r}),p.current=h,Ut(t)},[h,n]);let y;t[3]!==n||t[4]!==i||t[5]!==r||t[6]!==d||t[7]!==o||t[8]!==s||t[9]!==u||t[10]!==a||t[11]!==l?(y=e=>(0,Z.jsx)(dk,{entry:e,isActive:e.docName===n,isSourceMode:r,editorPlaceholder:i,isNewDoc:!d&&!u.has(e.docName),previousDocName:a,onNavigateBack:o,onRecycle:s,serverRestartRecovery:l},e.docName),t[3]=n,t[4]=i,t[5]=r,t[6]=d,t[7]=o,t[8]=s,t[9]=u,t[10]=a,t[11]=l,t[12]=y):y=t[12];let b=f.map(y),x;return t[13]===b?x=t[14]:(x=(0,Z.jsx)(Z.Fragment,{children:b}),t[13]=b,t[14]=x),x}function ak(e){return e.docName}function ok(e){let t=(0,$.c)(8),{isActive:n,initialScrollTop:r,children:i}=e,a=(0,Q.useRef)(null),o=(0,Q.useRef)(r??0),s,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=a.current;if(!e)return;let t=()=>{e.scrollTop>0&&(o.current=e.scrollTop)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},c=[],t[0]=s,t[1]=c):(s=t[0],c=t[1]),(0,Q.useEffect)(s,c);let l,u;t[2]===n?(l=t[3],u=t[4]):(l=()=>{if(!n)return;let e=a.current;if(!e)return;let t=o.current;if(t===0)return;let r=performance.now(),i=!1;e.scrollTop=t,e.scrollTop===t&&e.scrollHeight>t&&ue(`ok/scroll-restore/phase1-success`,{target:t,elapsedMs:performance.now()-r});let s=!1,c=0,l=()=>{s||(s=!0,cancelAnimationFrame(c),clearTimeout(f),e.removeEventListener(`wheel`,u),e.removeEventListener(`touchstart`,u))},u=()=>l();e.addEventListener(`wheel`,u,{passive:!0}),e.addEventListener(`touchstart`,u,{passive:!0});let d=()=>{s||(e.scrollTop!==t&&e.scrollHeight>t&&(e.scrollTop=t,e.scrollTop===t&&!i&&(ue(`ok/scroll-restore/phase2-success`,{target:t,elapsedMs:performance.now()-r}),i=!0)),c=requestAnimationFrame(d))};c=requestAnimationFrame(d);let f=setTimeout(()=>{s||(e.scrollTop!==t&&e.scrollHeight>t&&ue(`ok/scroll-restore/abandoned`,{target:t,elapsedMs:performance.now()-r,scrollHeight:e.scrollHeight,finalScrollTop:e.scrollTop}),l())},2e3);return l},u=[n],t[2]=n,t[3]=l,t[4]=u),(0,Q.useLayoutEffect)(l,u);let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d={overflowAnchor:`auto`},t[5]=d):d=t[5];let f;return t[6]===i?f=t[7]:(f=(0,Z.jsx)(`div`,{ref:a,"data-testid":`editor-scroll-container`,className:`subtle-scrollbar h-full overflow-y-auto pt-14 scroll-pt-14`,style:d,children:i}),t[6]=i,t[7]=f),f}function sk(e){let t=(0,$.c)(12),{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a}=e,o=r&&i,[s,c]=(0,Q.useState)(o),l,u;if(t[0]===o?(l=t[1],u=t[2]):(l=()=>{o&&c(!0)},u=[o],t[0]=o,t[1]=l,t[2]=u),(0,Q.useEffect)(l,u),!s&&!o)return null;let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(tx,{}),t[3]=d):d=t[3];let f=n.docName,p;t[4]===n.provider.document?p=t[5]:(p=n.provider.document.getText(`source`),t[4]=n.provider.document,t[5]=p);let m;return t[6]!==a||t[7]!==n.docName||t[8]!==n.provider||t[9]!==o||t[10]!==p?(m=(0,Z.jsx)(Q.Suspense,{fallback:d,children:(0,Z.jsx)(ek,{docName:f,ytext:p,provider:n.provider,placeholder:a,isSourceModeActive:o})}),t[6]=a,t[7]=n.docName,t[8]=n.provider,t[9]=o,t[10]=p,t[11]=m):m=t[11],m}function ck(e){let t=(0,$.c)(18),{view:n}=e,r=n.kind===`failed`,i=r?`alert`:`status`,a=!r,o;t[0]===r?o=t[1]:(o=(0,Z.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-full border bg-muted text-muted-foreground`,children:r?(0,Z.jsx)(no,{className:`size-5`,"aria-hidden":`true`}):(0,Z.jsx)(Yt,{className:`size-5 animate-spin`,"aria-hidden":`true`})}),t[0]=r,t[1]=o);let s;t[2]===n.title?s=t[3]:(s=(0,Z.jsx)(`h2`,{className:`text-lg font-medium`,children:n.title}),t[2]=n.title,t[3]=s);let c;t[4]===n.summary?c=t[5]:(c=(0,Z.jsx)(`p`,{className:`max-w-md text-sm text-muted-foreground`,children:n.summary}),t[4]=n.summary,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]!==r||t[10]!==n.actionLabel?(u=r?(0,Z.jsxs)(si,{type:`button`,onClick:lk,children:[(0,Z.jsx)(no,{className:`size-4`,"aria-hidden":`true`}),n.actionLabel]}):null,t[9]=r,t[10]=n.actionLabel,t[11]=u):u=t[11];let d;return t[12]!==i||t[13]!==a||t[14]!==o||t[15]!==l||t[16]!==u?(d=(0,Z.jsxs)(`div`,{"data-slot":`server-restart-recovery`,role:i,"aria-busy":a,className:`flex h-full flex-col items-center justify-center gap-6 p-8 text-center`,children:[o,l,u]}),t[12]=i,t[13]=a,t[14]=o,t[15]=l,t[16]=u,t[17]=d):d=t[17],d}function lk(){return window.location.reload()}function uk(e){let t=(0,$.c)(2),{html:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`tiptap-editor h-full pointer-events-none`,"aria-hidden":`true`,children:(0,Z.jsx)(`div`,{className:`tiptap ProseMirror tiptap-editor-portal-content`,dangerouslySetInnerHTML:{__html:n}})}),t[0]=n,t[1]=r),r}function dk(e){let t=(0,$.c)(53),{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a,isNewDoc:o,previousDocName:s,onNavigateBack:c,onRecycle:l,serverRestartRecovery:u}=e,d;t[0]!==n.docName||t[1]!==u?(d=nk(n.docName,u),t[0]=n.docName,t[1]=u,t[2]=d):d=t[2];let f=d,p=jC(n.docName)===`conflict`,m;t[3]===n.docName?m=t[4]:(m=()=>{let e=document.createElement(`div`);return e.setAttribute(`data-ok-editor-portal`,n.docName),e.style.display=`contents`,e},t[3]=n.docName,t[4]=m);let[h]=(0,Q.useState)(m),g=n.provider.document.getText(`source`).length,[_,v]=(0,Q.useState)(i),[b,x]=(0,Q.useState)(!i),S,C;t[5]!==i||t[6]!==_||t[7]!==b?(S=()=>{i&&!_?v(!0):!i&&!b&&x(!0)},C=[i,_,b],t[5]=i,t[6]=_,t[7]=b,t[8]=S,t[9]=C):(S=t[8],C=t[9]),(0,Q.useEffect)(S,C);let w=XO({ytextLength:g,isSourceMode:i,visitedSource:_,visitedVisual:b}),T=(0,Q.useRef)(``),E=`${w.isLarge}-${w.renderSource}-${w.renderVisual}`,D,O;t[10]!==n.docName||t[11]!==w.isLarge||t[12]!==w.renderSource||t[13]!==w.renderVisual||t[14]!==E||t[15]!==i||t[16]!==g?(D=()=>{T.current!==E&&(T.current=E,w.isLarge&&ue(`ok/activity/defer-mount`,{docName:n.docName,ytextLength:g,isSourceMode:i,renderSource:w.renderSource,renderVisual:w.renderVisual}))},O=[E,w.isLarge,w.renderSource,w.renderVisual,n.docName,g,i],t[10]=n.docName,t[11]=w.isLarge,t[12]=w.renderSource,t[13]=w.renderVisual,t[14]=E,t[15]=i,t[16]=g,t[17]=D,t[18]=O):(D=t[17],O=t[18]),(0,Q.useEffect)(D,O);let k;t[19]===n.docName?k=t[20]:(k=()=>y(n.docName),t[19]=n.docName,t[20]=k);let[A]=(0,Q.useState)(k),j=A?.html??null,[M,N]=(0,Q.useState)(!1),P,F;t[21]!==n.docName||t[22]!==w.isLarge||t[23]!==w.renderSource||t[24]!==w.renderVisual||t[25]!==M||t[26]!==i||t[27]!==g?(P=()=>{ZO({isLarge:w.isLarge,renderSource:w.renderSource,renderVisual:w.renderVisual,hasEmittedFirstToggle:M})&&(ue(`ok/cold/first-toggle`,{docName:n.docName,mountId:rt(n.docName),ytextLength:g,modeEnteredFirst:i?`source`:`visual`}),N(!0))},F=[M,w.isLarge,w.renderSource,w.renderVisual,n.docName,g,i],t[21]=n.docName,t[22]=w.isLarge,t[23]=w.renderSource,t[24]=w.renderVisual,t[25]=M,t[26]=i,t[27]=g,t[28]=P,t[29]=F):(P=t[28],F=t[29]),(0,Q.useEffect)(P,F);let I=r?`visible`:`hidden`,L=`editor:${n.docName}`,R=A?.scrollTop,z;t[30]!==a||t[31]!==n||t[32]!==w.renderSource||t[33]!==w.renderVisual||t[34]!==r||t[35]!==p||t[36]!==o||t[37]!==i||t[38]!==c||t[39]!==l||t[40]!==h||t[41]!==s||t[42]!==f||t[43]!==j?(z=f?(0,Z.jsx)(ck,{view:f}):(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(VO,{activeDocName:n.docName,previousDocName:s,onNavigateBack:c,onRecycle:l,children:(0,Z.jsx)(Q.Suspense,{fallback:j?(0,Z.jsx)(uk,{html:j}):(0,Z.jsx)(tx,{}),children:(0,Z.jsx)(IO,{docName:n.docName,provider:n.provider,children:p?(0,Z.jsx)(FO,{docName:n.docName,provider:n.provider}):(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[!i&&(0,Z.jsx)(UO,{provider:n.provider}),!i&&(0,Z.jsx)(qO,{provider:n.provider}),(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[w.renderSource?(0,Z.jsx)(`div`,{className:i?`h-full`:`ok-mode-hidden h-full`,children:(0,Z.jsx)(sk,{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a})}):null,w.renderVisual?(0,Z.jsx)(`div`,{className:i?`ok-mode-hidden h-full`:`h-full`,children:(0,Z.jsx)(NE,{provider:n.provider,placeholder:a,isSourceMode:i,portalTarget:h},`${n.docName}-${String(o)}-${n.poolEventId}`)}):null]})]})})})})}),t[30]=a,t[31]=n,t[32]=w.renderSource,t[33]=w.renderVisual,t[34]=r,t[35]=p,t[36]=o,t[37]=i,t[38]=c,t[39]=l,t[40]=h,t[41]=s,t[42]=f,t[43]=j,t[44]=z):z=t[44];let B;t[45]!==r||t[46]!==R||t[47]!==z?(B=(0,Z.jsx)(ok,{isActive:r,initialScrollTop:R,children:z}),t[45]=r,t[46]=R,t[47]=z,t[48]=B):B=t[48];let V;return t[49]!==I||t[50]!==L||t[51]!==B?(V=(0,Z.jsx)(Q.Activity,{mode:I,name:L,children:B}),t[49]=I,t[50]=L,t[51]=B,t[52]=V):V=t[52],V}function fk(e){let t=e.endsWith(`rem`)?`rem`:`px`;return{value:Number.parseFloat(e),unit:t}}function pk(e){let{value:t,unit:n}=fk(e);return n===`rem`?t*16:t}function mk(e,t){return`${t===`rem`?e.toFixed(1):Math.round(e)}${t}`}var hk=3600*24*7;function gk(e){let t=(0,$.c)(28),{direction:n,currentWidth:r,onResize:i,onToggle:a,isCollapsed:o,minResizeWidth:s,maxResizeWidth:c,enableToggle:l,enableAutoCollapse:u,autoCollapseThreshold:d,expandThreshold:f,enableDrag:p,setIsDraggingRail:m,widthCookieName:h,widthCookieMaxAge:g,isNested:_}=e,v=n===void 0?`right`:n,y=o===void 0?!1:o,b=s===void 0?`14rem`:s,x=c===void 0?`24rem`:c,S=l===void 0?!0:l,C=u===void 0?!0:u,w=d===void 0?1.5:d,T=f===void 0?.2:f,E=p===void 0?!0:p,D=m===void 0?_k:m,O=g===void 0?hk:g,k=_===void 0?!1:_,A=(0,Q.useRef)(null),j=(0,Q.useRef)(0),M=(0,Q.useRef)(0),N=(0,Q.useRef)(!1),P=(0,Q.useRef)(!1),F=(0,Q.useRef)(null),I=(0,Q.useRef)(0),L=(0,Q.useRef)(!1),R=(0,Q.useRef)(0),z=(0,Q.useRef)(0),B=(0,Q.useRef)(null),V=(0,Q.useRef)(r),H=(0,Q.useRef)(y),U,W;t[0]===r?(U=t[1],W=t[2]):(U=()=>{V.current=r},W=[r],t[0]=r,t[1]=U,t[2]=W),(0,Q.useEffect)(U,W);let G,K;t[3]===y?(G=t[4],K=t[5]):(G=()=>{H.current=y},K=[y],t[3]=y,t[4]=G,t[5]=K),(0,Q.useEffect)(G,K);let q=pk(b),J;t[6]===x?J=t[7]:(J=pk(x),t[6]=x,t[7]=J);let Y=J,ee;t[8]!==E||t[9]!==k?(ee=function(e){E&&(P.current=!0,j.current=H.current?0:pk(V.current),M.current=e.clientX,I.current=e.clientX,F.current=null,L.current=!1,R.current=0,z.current=0,B.current=k&&A.current?A.current.getBoundingClientRect():null,e.preventDefault())},t[8]=E,t[9]=k,t[10]=ee):ee=t[10];let te=ee,ne,re;t[11]!==w||t[12]!==v||t[13]!==C||t[14]!==S||t[15]!==T||t[16]!==k||t[17]!==Y||t[18]!==q||t[19]!==i||t[20]!==a||t[21]!==D||t[22]!==O||t[23]!==h?(ne=()=>{let e=function(e){h&&(document.cookie=`${h}=${e}; path=/; max-age=${O}`)},t=function(e,t){return v===`left`?e<t:e>t},n=function(e,t,n,r){if(k&&r){let r=e.clientX-t;return v===`left`?n-r:n+r}return v===`left`?window.innerWidth-e.clientX:e.clientX},r=function(r){if(!P.current)return;let o=Math.abs(r.clientX-M.current);if(!N.current&&o>5&&(N.current=!0,D(!0)),N.current){let{unit:o}=fk(V.current),s=B.current;k&&A.current&&(s=A.current.getBoundingClientRect());let c=t(r.clientX,I.current)?`expand`:`collapse`;F.current!==c&&(F.current=c),z.current=Math.abs(r.clientX-I.current);let l=Date.now();if(L.current&&l-R.current>200&&(L.current=!1),!L.current){if(C&&a&&!H.current){let e=n(r,M.current,j.current,s),t=!1;if(w<=1)t=e<=q*w;else if(e<=q){let n=q*(w-1);t=q-e>=n}if(c===`collapse`&&t){a(),I.current=r.clientX,L.current=!0,R.current=l;return}}if(a&&H.current&&c===`expand`&&z.current>q*T){a();let t=n(r,M.current,j.current,s),c=Math.max(q,Math.min(Y,t)),u=mk(o===`rem`?c/16:c,o);i(u),e(u),I.current=r.clientX,L.current=!0,R.current=l;return}}if(H.current)return;let u=n(r,M.current,j.current,s),d=Math.max(q,Math.min(Y,u)),f=mk(o===`rem`?d/16:d,o);i(f),e(f)}},o=function(){P.current&&(!N.current&&a&&S&&a(),N.current=!1,P.current=!1,F.current=null,I.current=0,L.current=!1,R.current=0,z.current=0,B.current=null,D(!1))};return document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,o),()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,o)}},re=[i,a,D,q,Y,k,C,w,T,S,h,O,v],t[11]=w,t[12]=v,t[13]=C,t[14]=S,t[15]=T,t[16]=k,t[17]=Y,t[18]=q,t[19]=i,t[20]=a,t[21]=D,t[22]=O,t[23]=h,t[24]=ne,t[25]=re):(ne=t[24],re=t[25]),(0,Q.useEffect)(ne,re);let ie;return t[26]===te?ie=t[27]:(ie={dragRef:A,isDragging:N,handleMouseDown:te},t[26]=te,t[27]=ie),ie}function _k(){}var vk=3600*24*7,yk=`18rem`,bk=`3rem`,xk=`app-file-sidebar`,Sk=`14.625rem`,Ck=`32rem`,wk=`sidebar_width`,Tk=/^\d+(?:\.\d+)?(?:rem|px)$/,Ek=Q.createContext(null);function Dk(e){if(typeof document>`u`)return e;let t=document.cookie.split(`; `).find(e=>e.startsWith(`${wk}=`))?.split(`=`)[1];if(!t)return e;let n;try{n=decodeURIComponent(t)}catch{return e}return Tk.test(n)?n:e}function Ok(){let e=Q.use(Ek);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function kk(e){let t=(0,$.c)(58),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({open:i,onOpenChange:o,className:r,style:s,children:n,defaultWidth:c,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=c===void 0?yk:c,[u]=Q.useState(jk),d;t[8]===u?d=t[9]:(d=()=>VC(u,window.innerWidth,`left`),t[8]=u,t[9]=d);let[f,p]=Q.useState(d),m;t[10]===l?m=t[11]:(m=()=>Dk(l),t[10]=l,t[11]=m);let[h,g]=Q.useState(m),[_,v]=Q.useState(!1),[y,b]=Q.useState(!1),x;t[12]===u?x=t[13]:(x=()=>{let e=JC();return XC(`left`,VC(u,window.innerWidth,`left`),e)===`open`},t[12]=u,t[13]=x);let[S,C]=Q.useState(x),w=i??S,T;t[14]!==w||t[15]!==f||t[16]!==o?(T=e=>{let t=typeof e==`function`?e(w):e;o?o(t):C(t),ZC(`left`,f,t?`open`:`collapsed`)},t[14]=w,t[15]=f,t[16]=o,t[17]=T):T=t[17];let E=T,D;t[18]===E?D=t[19]:(D=function(){E(Ak)},t[18]=E,t[19]=D);let O=D,k=Q.useRef(w),A;t[20]===w?A=t[21]:(A=()=>{k.current=w},t[20]=w,t[21]=A),Q.useLayoutEffect(A);let j;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(j=function(){window.innerWidth>=1024||k.current&&(window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||b(!0))},t[22]=j):j=t[22];let M=j,N,P;t[23]===u?(N=t[24],P=t[25]):(P=()=>{let e=window.matchMedia(`(min-width: ${RC}px)`),t=()=>{let e=VC(u,window.innerWidth,`left`);p(e),C(XC(`left`,e,JC())===`open`)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},N=[u],t[23]=u,t[24]=N,t[25]=P),Q.useEffect(P,N);let F,I;t[26]===w?(F=t[27],I=t[28]):(F=()=>{w||document.getElementById(xk)?.contains(document.activeElement)&&document.querySelector(`[data-sidebar="trigger"]`)?.focus()},I=[w],t[26]=w,t[27]=F,t[28]=I),Q.useLayoutEffect(F,I);let L,R;t[29]!==w||t[30]!==f||t[31]!==E?(L=()=>{if(f===`above`||!w)return;let e=e=>{e.key===`Escape`&&(document.querySelector(`[data-state="open"][role="dialog"], [data-state="open"][role="alertdialog"], [data-state="open"][role="menu"], [data-state="open"][role="listbox"], [data-radix-popper-content-wrapper] [data-state="open"]`)||E(!1))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},R=[f,w,E],t[29]=w,t[30]=f,t[31]=E,t[32]=L,t[33]=R):(L=t[32],R=t[33]),Q.useEffect(L,R);let z,B;t[34]===O?(z=t[35],B=t[36]):(z=()=>{if(typeof window<`u`&&window.okDesktop!=null)return;let e=e=>{qs(e,`toggle-files-sidebar`)&&(e.preventDefault(),O())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},B=[O],t[34]=O,t[35]=z,t[36]=B),Q.useEffect(z,B);let V=w?`expanded`:`collapsed`,H;t[37]!==_||t[38]!==w||t[39]!==E||t[40]!==y||t[41]!==V||t[42]!==O||t[43]!==h?(H={state:V,open:w,setOpen:E,toggleSidebar:O,width:h,setWidth:g,isDraggingRail:_,setIsDraggingRail:v,showPushPulse:y,setShowPushPulse:b,notifySidebarFileSelected:M},t[37]=_,t[38]=w,t[39]=E,t[40]=y,t[41]=V,t[42]=O,t[43]=h,t[44]=H):H=t[44];let U;t[45]!==s||t[46]!==h?(U={"--sidebar-width":h,"--sidebar-width-icon":bk,...s},t[45]=s,t[46]=h,t[47]=U):U=t[47];let W=U,G;t[48]===r?G=t[49]:(G=ai(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),t[48]=r,t[49]=G);let K;t[50]!==n||t[51]!==a||t[52]!==W||t[53]!==G?(K=(0,Z.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:W,className:G,...a,children:n}),t[50]=n,t[51]=a,t[52]=W,t[53]=G,t[54]=K):K=t[54];let q;return t[55]!==H||t[56]!==K?(q=(0,Z.jsx)(Ek.Provider,{value:H,children:K}),t[55]=H,t[56]=K,t[57]=q):q=t[57],q}function Ak(e){return!e}function jk(){return Er()}function Mk(e){let t=(0,$.c)(39),n,r,a,o,s,c;t[0]===e?(n=t[1],r=t[2],a=t[3],o=t[4],s=t[5],c=t[6]):({side:o,variant:s,collapsible:c,className:r,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o,t[5]=s,t[6]=c);let l=o===void 0?`left`:o,u=s===void 0?`sidebar`:s,d=c===void 0?`offcanvas`:c,{_:f}=i(),{state:p,isDraggingRail:m}=Ok();if(d===`none`){let e;t[7]===r?e=t[8]:(e=ai(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),t[7]=r,t[8]=e);let i;return t[9]!==n||t[10]!==a||t[11]!==e||t[12]!==u?(i=(0,Z.jsx)(`div`,{"data-slot":`sidebar`,"data-variant":u,className:e,...a,children:n}),t[9]=n,t[10]=a,t[11]=e,t[12]=u,t[13]=i):i=t[13],i}let h=p===`collapsed`?d:``,g=u===`floating`||u===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,_;t[14]===g?_=t[15]:(_=ai(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,g,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`),t[14]=g,t[15]=_);let v;t[16]===_?v=t[17]:(v=(0,Z.jsx)(`div`,{"data-slot":`sidebar-gap`,className:_}),t[16]=_,t[17]=v);let y;t[18]===f?y=t[19]:(y=f({id:`07q4Qk`}),t[18]=f,t[19]=y);let b=u===`floating`||u===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,x;t[20]!==r||t[21]!==b?(x=ai(`fixed inset-y-0 z-10 flex h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear motion-reduce:transition-none motion-reduce:duration-0 data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]`,b,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`,r),t[20]=r,t[21]=b,t[22]=x):x=t[22];let S;t[23]===n?S=t[24]:(S=(0,Z.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border`,children:n}),t[23]=n,t[24]=S);let C;t[25]!==a||t[26]!==l||t[27]!==x||t[28]!==S||t[29]!==y?(C=(0,Z.jsx)(`nav`,{id:xk,"aria-label":y,"data-slot":`sidebar-container`,"data-side":l,className:x,...a,children:S}),t[25]=a,t[26]=l,t[27]=x,t[28]=S,t[29]=y,t[30]=C):C=t[30];let w;return t[31]!==m||t[32]!==l||t[33]!==p||t[34]!==C||t[35]!==h||t[36]!==v||t[37]!==u?(w=(0,Z.jsxs)(`div`,{className:`group peer text-sidebar-foreground`,"data-state":p,"data-collapsible":h,"data-variant":u,"data-side":l,"data-slot":`sidebar`,"data-dragging":m,children:[v,C]}),t[31]=m,t[32]=l,t[33]=p,t[34]=C,t[35]=h,t[36]=v,t[37]=u,t[38]=w):w=t[38],w}function Nk(e){let t=(0,$.c)(34),n,r,a;t[0]===e?(n=t[1],r=t[2],a=t[3]):({className:n,onClick:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=a);let{_:o}=i(),{toggleSidebar:s,state:c}=Ok(),l,u,d,f,p,m,h,g;if(t[4]!==o||t[5]!==c){let e=Js(`toggle-files-sidebar`);l=si,u=`trigger`,d=`sidebar-trigger`,f=`ghost`,p=`icon-sm`,m=c===`expanded`,h=xk,g=o(c===`expanded`?{id:`4PYsOz`,values:{sidebarShortcutLabel:e}}:{id:`jbSG8V`,values:{sidebarShortcutLabel:e}}),t[4]=o,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m,t[12]=h,t[13]=g}else l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13];let _;t[14]===n?_=t[15]:(_=ai(n),t[14]=n,t[15]=_);let v;t[16]!==r||t[17]!==s?(v=e=>{r?.(e),s()},t[16]=r,t[17]=s,t[18]=v):v=t[18];let y;t[19]===c?y=t[20]:(y=c===`expanded`?(0,Z.jsx)(se,{}):(0,Z.jsx)(kl,{}),t[19]=c,t[20]=y);let b;return t[21]!==l||t[22]!==a||t[23]!==u||t[24]!==y||t[25]!==d||t[26]!==f||t[27]!==p||t[28]!==m||t[29]!==h||t[30]!==g||t[31]!==_||t[32]!==v?(b=(0,Z.jsx)(l,{"data-sidebar":u,"data-slot":d,variant:f,size:p,"aria-expanded":m,"aria-controls":h,"aria-label":g,className:_,onClick:v,...a,children:y}),t[21]=l,t[22]=a,t[23]=u,t[24]=y,t[25]=d,t[26]=f,t[27]=p,t[28]=m,t[29]=h,t[30]=g,t[31]=_,t[32]=v,t[33]=b):b=t[33],b}function Pk(e){let t=(0,$.c)(32),n,r,a,o,s;t[0]===e?(n=t[1],r=t[2],a=t[3],o=t[4],s=t[5]):({className:n,enableDrag:o,enableToggle:s,onMouseDown:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o,t[5]=s);let c=o===void 0?!0:o,l=s===void 0?!0:s,{_:u}=i(),{toggleSidebar:d,setWidth:f,state:p,width:m,setIsDraggingRail:h}=Ok(),g=p===`collapsed`,_;t[6]!==c||t[7]!==l||t[8]!==h||t[9]!==f||t[10]!==g||t[11]!==d||t[12]!==m?(_={direction:`right`,enableDrag:c,enableToggle:l,onResize:f,onToggle:d,currentWidth:m,isCollapsed:g,minResizeWidth:Sk,maxResizeWidth:Ck,setIsDraggingRail:h,widthCookieName:wk,widthCookieMaxAge:vk},t[6]=c,t[7]=l,t[8]=h,t[9]=f,t[10]=g,t[11]=d,t[12]=m,t[13]=_):_=t[13];let{dragRef:v,handleMouseDown:y}=gk(_),b;t[14]!==u||t[15]!==p?(b=u(p===`expanded`?{id:`w3vFfL`}:{id:`e8zRrb`}),t[14]=u,t[15]=p,t[16]=b):b=t[16];let x;t[17]!==y||t[18]!==r?(x=e=>{r?.(e),e.defaultPrevented||y(e)},t[17]=y,t[18]=r,t[19]=x):x=t[19];let S;t[20]!==u||t[21]!==p?(S=u(p===`expanded`?{id:`w3vFfL`}:{id:`e8zRrb`}),t[20]=u,t[21]=p,t[22]=S):S=t[22];let C;t[23]===n?C=t[24]:(C=ai(`absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2`,`in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize`,`[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize`,`group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar`,`[[data-side=left][data-collapsible=offcanvas]_&]:-right-2`,`[[data-side=right][data-collapsible=offcanvas]_&]:-left-2`,`md:group-data-[variant=inset]:after:inset-y-5`,n),t[23]=n,t[24]=C);let w;return t[25]!==v||t[26]!==a||t[27]!==b||t[28]!==x||t[29]!==S||t[30]!==C?(w=(0,Z.jsx)(`button`,{ref:v,"data-sidebar":`rail`,"data-slot":`sidebar-rail`,"aria-label":b,tabIndex:-1,onMouseDown:x,title:S,className:C,...a}),t[25]=v,t[26]=a,t[27]=b,t[28]=x,t[29]=S,t[30]=C,t[31]=w):w=t[31],w}function Fk(e){let t=(0,$.c)(14),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,onAnimationEnd:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let{showPushPulse:a,setShowPushPulse:o}=Ok(),s;t[4]!==r||t[5]!==o?(s=e=>{r?.(e),e.animationName===`sidebar-push-pulse`&&o(!1)},t[4]=r,t[5]=o,t[6]=s):s=t[6];let c=s,l=a?``:void 0,u;t[7]===n?u=t[8]:(u=ai(`relative flex w-full flex-1 flex-col bg-background peer-data-[variant=inset]:m-2 peer-data-[variant=inset]:ml-0 peer-data-[variant=inset]:rounded-xl peer-data-[variant=inset]:shadow-sm peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2`,n),t[7]=n,t[8]=u);let d;return t[9]!==c||t[10]!==i||t[11]!==l||t[12]!==u?(d=(0,Z.jsx)(`main`,{"data-slot":`sidebar-inset`,"data-push-pulse":l,onAnimationEnd:c,className:u,...i}),t[9]=c,t[10]=i,t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function Ik(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`sidebar-header`,"data-sidebar":`header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Lk(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Rk(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function zk(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`flex w-full min-w-0 flex-col gap-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Bk(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`group/menu-item relative`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Vk=ri(`peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-hover hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-hover active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-hover data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground data-active:hover:bg-sidebar-accent [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate`,{variants:{variant:{default:`hover:bg-sidebar-hover hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-hover hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`default`}});function Hk(e){let t=(0,$.c)(28),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({asChild:i,isActive:a,variant:o,size:s,tooltip:c,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=i===void 0?!1:i,u=a===void 0?!1:a,d=o===void 0?`default`:o,f=s===void 0?`default`:s,p=l?oi:`button`,{state:m}=Ok(),h;t[8]!==n||t[9]!==f||t[10]!==d?(h=ai(Vk({variant:d,size:f}),n),t[8]=n,t[9]=f,t[10]=d,t[11]=h):h=t[11];let g;t[12]!==p||t[13]!==u||t[14]!==r||t[15]!==f||t[16]!==h?(g=(0,Z.jsx)(p,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":f,"data-active":u,className:h,...r}),t[12]=p,t[13]=u,t[14]=r,t[15]=f,t[16]=h,t[17]=g):g=t[17];let _=g;if(!c)return _;if(typeof c==`string`){let e;t[18]===c?e=t[19]:(e={children:c},t[18]=c,t[19]=e),c=e}let v;t[20]===_?v=t[21]:(v=(0,Z.jsx)(Ts,{asChild:!0,children:_}),t[20]=_,t[21]=v);let y=m!==`collapsed`,b;t[22]!==y||t[23]!==c?(b=(0,Z.jsx)(Ds,{side:`right`,align:`center`,hidden:y,...c}),t[22]=y,t[23]=c,t[24]=b):b=t[24];let x;return t[25]!==v||t[26]!==b?(x=(0,Z.jsxs)(As,{children:[v,b]}),t[25]=v,t[26]=b,t[27]=x):x=t[27],x}function Uk(e){let t=null,n=!1,r=new Set;function i(e){if(e!==t){t=e;for(let e of r)e()}}e.subscribeToEvent(i);async function a(){if(!n){n=!0;try{i(await e.fetchBranch())}catch{}}}return{getSnapshot:()=>t,subscribe(e){return r.add(e),a(),()=>{r.delete(e)}}}}async function Wk(){let e=await fetch(`/api/server-info`,{signal:AbortSignal.timeout(5e3)});if(!e.ok)return null;let t=await e.json(),n=Fr.safeParse(t);return n.success?n.data.currentBranch??null:null}var Gk=typeof window>`u`?{getSnapshot:()=>null,subscribe:()=>()=>{}}:Uk({fetchBranch:Wk,subscribeToEvent:$o}),Kk=Gk.subscribe,qk=Gk.getSnapshot;function Jk(){return(0,Q.useSyncExternalStore)(Kk,qk,qk)}function Yk(){let e=(0,$.c)(6),t=Jk(),n=po(),{state:r}=Ok(),i=typeof window<`u`?window.okDesktop:void 0;if(i&&r===`expanded`)return null;let a;e[0]===n?a=e[1]:(a=i?.config.projectName??(n&&la(n.contentDir)||null),e[0]=n,e[1]=a);let o=a,s=i?.config.projectPath??n?.contentDir??null;if(o===null&&t===null)return null;let c;return e[2]!==t||e[3]!==o||e[4]!==s?(c={projectName:o,projectPath:s,branch:t},e[2]=t,e[3]=o,e[4]=s,e[5]=c):c=e[5],c}function Xk(e){let t=(0,$.c)(23),{stats:n,selectionStats:r,showStats:a}=e,o=a===void 0?!0:a,{_:c}=i(),l=Yk();if(!o&&l===null)return null;let u=r??n,d=r!=null,{words:f,chars:p,tokens:m}=u,h;t[0]!==c||t[1]!==d||t[2]!==o?(h=c(o?d?{id:`Bv5a9_`}:{id:`L1ZE3M`}:{id:`goO4Ll`}),t[0]=c,t[1]=d,t[2]=o,t[3]=h):h=t[3];let g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-full h-2 bg-linear-to-t from-background to-transparent`}),t[4]=g):g=t[4];let _;t[5]===l?_=t[6]:(_=l===null?null:(0,Z.jsx)(Zk,{identity:l}),t[5]=l,t[6]=_);let v;t[7]===_?v=t[8]:(v=(0,Z.jsx)(`span`,{className:`flex min-w-0 items-center gap-3`,children:_}),t[7]=_,t[8]=v);let y;t[9]!==c||t[10]!==u.chars||t[11]!==u.tokens||t[12]!==u.words||t[13]!==p||t[14]!==d||t[15]!==o||t[16]!==m||t[17]!==f?(y=o?(0,Z.jsxs)(`span`,{className:`flex items-center shrink-0 gap-3`,children:[d?(0,Z.jsx)(`span`,{className:`font-medium text-foreground/70`,"data-testid":`editor-footer-selected-label`,children:c({id:`ylXj1N`})}):null,(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`tabular-nums`,children:u.words.toLocaleString()}),` `,(0,Z.jsx)(s,{id:`gljvbT`,values:{words:f}})]}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`tabular-nums`,children:u.chars.toLocaleString()}),` `,(0,Z.jsx)(s,{id:`d5rK4X`,values:{chars:p}})]}),(0,Z.jsxs)(`span`,{children:[u.tokens>0?`~`:``,(0,Z.jsx)(`span`,{className:`tabular-nums`,children:u.tokens.toLocaleString()}),` `,(0,Z.jsx)(s,{id:`uynXup`,values:{tokens:m}})]})]}):null,t[9]=c,t[10]=u.chars,t[11]=u.tokens,t[12]=u.words,t[13]=p,t[14]=d,t[15]=o,t[16]=m,t[17]=f,t[18]=y):y=t[18];let b;return t[19]!==h||t[20]!==v||t[21]!==y?(b=(0,Z.jsxs)(`section`,{"aria-label":h,className:`relative flex h-6 shrink-0 items-center justify-between gap-3 bg-background px-3 text-2xs text-muted-foreground`,children:[g,v,y]}),t[19]=h,t[20]=v,t[21]=y,t[22]=b):b=t[22],b}function Zk(e){let t=(0,$.c)(8),{identity:n}=e,{projectName:r,projectPath:i,branch:a}=n,o;t[0]!==r||t[1]!==i?(o=r===null?null:i?(0,Z.jsxs)(As,{children:[(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(`span`,{tabIndex:0,className:`truncate`,"data-testid":`editor-footer-project-name`,children:r})}),(0,Z.jsx)(Ds,{side:`top`,className:`max-w-xs break-all`,children:i})]}):(0,Z.jsx)(`span`,{className:`truncate`,"data-testid":`editor-footer-project-name`,children:r}),t[0]=r,t[1]=i,t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=a===null?null:(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,"data-testid":`editor-footer-branch`,children:[(0,Z.jsx)(Ce,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:a})]}),t[3]=a,t[4]=s);let c;return t[5]!==o||t[6]!==s?(c=(0,Z.jsxs)(Z.Fragment,{children:[o,s]}),t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function Qk(e){let t=(0,$.c)(11),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{_:a}=i(),o;t[3]===a?o=t[4]:(o=a({id:`3__SjS`}),t[3]=a,t[4]=o);let s;t[5]===n?s=t[6]:(s=ai(n),t[5]=n,t[6]=s);let c;return t[7]!==r||t[8]!==o||t[9]!==s?(c=(0,Z.jsx)(`nav`,{"aria-label":o,"data-slot":`breadcrumb`,className:s,...r}),t[7]=r,t[8]=o,t[9]=s,t[10]=c):c=t[10],c}function $k(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`ol`,{"data-slot":`breadcrumb-list`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function eA(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`inline-flex items-center gap-1`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`li`,{"data-slot":`breadcrumb-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function tA(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({current:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0||i?`page`:void 0,o;t[4]===n?o=t[5]:(o=ai(`font-normal text-foreground`,n),t[4]=n,t[5]=o);let s;return t[6]!==r||t[7]!==a||t[8]!==o?(s=(0,Z.jsx)(`span`,{"data-slot":`breadcrumb-page`,"aria-current":a,className:o,...r}),t[6]=r,t[7]=a,t[8]=o,t[9]=s):s=t[9],s}function nA(e){let t=(0,$.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({children:n,className:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=ai(`[&>svg]:size-3.5`,r),t[4]=r,t[5]=a);let o;t[6]===n?o=t[7]:(o=n??(0,Z.jsx)(jo,{}),t[6]=n,t[7]=o);let s;return t[8]!==i||t[9]!==a||t[10]!==o?(s=(0,Z.jsx)(`li`,{"data-slot":`breadcrumb-separator`,role:`presentation`,"aria-hidden":`true`,className:a,...i,children:o}),t[8]=i,t[9]=a,t[10]=o,t[11]=s):s=t[11],s}var rA=1,iA=2,aA=4;function oA(e){let t=(0,$.c)(18),{docName:n,className:r}=e;if(!n)return null;let i,a,o,s,c,l;if(t[0]!==r||t[1]!==n){l=Symbol.for(`react.early_return_sentinel`);bb0:{let{prefix:e}=Me(n,``);if(!e){l=null;break bb0}let u=e.replace(/\/$/,``).split(`/`).filter(Boolean);if(u.length===0){l=null;break bb0}let d=(e,t)=>({kind:`segment`,value:e,key:u.slice(0,t+1).join(`/`)}),f=u.length>aA?[...u.slice(0,rA).map((e,t)=>d(e,t)),{kind:`ellipsis`,hidden:u.slice(rA,-iA)},...u.slice(-iA).map((e,t)=>d(e,u.length-iA+t))]:u.map((e,t)=>d(e,t));a=Qk,t[8]===r?c=t[9]:(c=ai(`flex min-w-0 items-center`,r),t[8]=r,t[9]=c),i=$k,o=`min-w-0 flex-nowrap gap-1 overflow-hidden text-muted-foreground/70 text-xs`,s=f.map(sA)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7];if(l!==Symbol.for(`react.early_return_sentinel`))return l;let u;t[10]!==i||t[11]!==o||t[12]!==s?(u=(0,Z.jsx)(i,{className:o,children:s}),t[10]=i,t[11]=o,t[12]=s,t[13]=u):u=t[13];let d;return t[14]!==a||t[15]!==c||t[16]!==u?(d=(0,Z.jsx)(a,{className:c,children:u}),t[14]=a,t[15]=c,t[16]=u,t[17]=d):d=t[17],d}function sA(e,t){let n=e.kind===`segment`?e.key:`ellipsis`;return(0,Z.jsxs)(Q.Fragment,{children:[t>0&&(0,Z.jsx)(nA,{className:`shrink-0 text-muted-foreground/70 [&>svg]:size-3`}),e.kind===`ellipsis`?(0,Z.jsxs)(eA,{className:`shrink-0`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,title:e.hidden.join(` / `),className:`flex size-4 items-center justify-center text-muted-foreground/70`,children:(0,Z.jsx)(al,{className:`size-3.5`})}),(0,Z.jsx)(`span`,{className:`sr-only`,children:e.hidden.join(` / `)})]}):(0,Z.jsx)(eA,{className:`min-w-0`,children:(0,Z.jsx)(tA,{current:!1,className:`min-w-0 truncate font-normal text-muted-foreground/70`,title:e.value,children:e.value})})]},n)}var cA={fill:`none`,height:24,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 24 24`,width:24,xmlns:`http://www.w3.org/2000/svg`},lA=e=>{let t=(0,$.c)(15),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({color:a,size:o,strokeWidth:s,absoluteStrokeWidth:n,className:c,children:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=a===void 0?`currentColor`:a,u=o===void 0?24:o,d=s===void 0?2:s,f=c===void 0?``:c,p=n?Number(d)*24/Number(u):d,m;return t[8]!==r||t[9]!==f||t[10]!==l||t[11]!==i||t[12]!==u||t[13]!==p?(m=(0,Z.jsx)(`svg`,{"aria-hidden":`true`,...cA,className:f,height:u,stroke:l,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:p,width:u,...i,children:r}),t[8]=r,t[9]=f,t[10]=l,t[11]=i,t[12]=u,t[13]=p,t[14]=m):m=t[14],m},uA=e=>{let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`Markdown`}),r=(0,Z.jsx)(`path`,{d:`M232,48H24A16,16,0,0,0,8,64V192a16,16,0,0,0,16,16H232a16,16,0,0,0,16-16V64A16,16,0,0,0,232,48Zm0,144H24V64H232V192ZM128,104v48a8,8,0,0,1-16,0V123.31L93.66,141.66a8,8,0,0,1-11.32,0L64,123.31V152a8,8,0,0,1-16,0V104a8,8,0,0,1,13.66-5.66L88,124.69l26.34-26.35A8,8,0,0,1,128,104Zm77.66,18.34a8,8,0,0,1,0,11.32l-24,24a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L168,132.69V104a8,8,0,0,1,16,0v28.69l10.34-10.35A8,8,0,0,1,205.66,122.34Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,Z.jsxs)(lA,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},dA=e=>{let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`Textbox`}),r=(0,Z.jsx)(`path`,{d:`M112,40a8,8,0,0,0-8,8V64H24A16,16,0,0,0,8,80v96a16,16,0,0,0,16,16h80v16a8,8,0,0,0,16,0V48A8,8,0,0,0,112,40ZM24,176V80h80v96ZM248,80v96a16,16,0,0,1-16,16H144a8,8,0,0,1,0-16h88V80H144a8,8,0,0,1,0-16h88A16,16,0,0,1,248,80ZM88,112a8,8,0,0,1-8,8H72v24a8,8,0,0,1-16,0V120H48a8,8,0,0,1,0-16H80A8,8,0,0,1,88,112Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,Z.jsxs)(lA,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i};function fA(e){let t=(0,$.c)(90),{activeDocName:n,isSourceMode:r,sourceDisabled:a,onModeChange:o,showAddPropertyButton:c,onAddProperty:l,isPanelCollapsed:u,onTogglePanel:d}=e,{_:f}=i(),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=Ks(`toggle-document-panel`),t[0]=p):p=t[0];let m=p,h,g,_,v,y,b,x,S,C,w,T,E,D,O;if(t[1]!==f||t[2]!==n||t[3]!==u||t[4]!==r||t[5]!==l||t[6]!==o||t[7]!==d||t[8]!==c||t[9]!==a){let e=Js(`toggle-document-panel`);v=`editor-toolbar`,y=`pointer-events-none absolute inset-x-0 top-0 z-10`;let i;t[24]===n?i=t[25]:(i=(0,Z.jsx)(`div`,{className:`pointer-events-auto flex min-w-0 items-center`,children:(0,Z.jsx)(oA,{docName:n})}),t[24]=n,t[25]=i);let p=r?`source`:`wysiwyg`,m;t[26]===o?m=t[27]:(m=e=>{e&&o(e)},t[26]=o,t[27]=m);let k;t[28]===f?k=t[29]:(k=f({id:`n7aopT`}),t[28]=f,t[29]=k);let A;t[30]===f?A=t[31]:(A=f({id:`ur2XSb`}),t[30]=f,t[31]=A);let j;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Z.jsx)(Ts,{children:(0,Z.jsx)(dA,{className:`size-4`})}),t[32]=j):j=t[32];let M;t[33]===A?M=t[34]:(M=(0,Z.jsx)(_o,{value:`wysiwyg`,"aria-label":A,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,asChild:!0,children:j}),t[33]=A,t[34]=M);let N;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(Ds,{side:`bottom`,children:(0,Z.jsx)(s,{id:`Mb_20S`})}),t[35]=N):N=t[35];let P;t[36]===M?P=t[37]:(P=(0,Z.jsxs)(As,{children:[M,N]}),t[36]=M,t[37]=P);let F;t[38]===f?F=t[39]:(F=f({id:`xbdtfY`}),t[38]=f,t[39]=F);let I;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(uA,{className:`size-4`}),t[40]=I):I=t[40];let L;t[41]!==a||t[42]!==F?(L=(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(`div`,{children:(0,Z.jsx)(_o,{value:`source`,"aria-label":F,disabled:a,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,children:I})})}),t[41]=a,t[42]=F,t[43]=L):L=t[43];let R;t[44]===a?R=t[45]:(R=(0,Z.jsx)(Ds,{side:`bottom`,children:a?(0,Z.jsx)(s,{id:`G-JBA1`}):(0,Z.jsx)(s,{id:`u6Hp4N`})}),t[44]=a,t[45]=R);let z;t[46]!==L||t[47]!==R?(z=(0,Z.jsxs)(As,{children:[L,R]}),t[46]=L,t[47]=R,t[48]=z):z=t[48];let B;t[49]!==p||t[50]!==m||t[51]!==k||t[52]!==P||t[53]!==z?(B=(0,Z.jsx)(`div`,{className:`pointer-events-auto flex justify-center`,children:(0,Z.jsxs)(yo,{type:`single`,value:p,onValueChange:m,"aria-label":k,variant:`segmented`,size:`sm`,spacing:1,className:`shrink-0 data-[size=sm]:rounded-[10px] bg-muted p-0.5`,children:[P,z]})}),t[49]=p,t[50]=m,t[51]=k,t[52]=P,t[53]=z,t[54]=B):B=t[54],t[55]!==i||t[56]!==B?(b=(0,Z.jsx)(`div`,{className:`editor-content-aligned bg-background py-2`,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 items-center`,children:[i,B]})}),t[55]=i,t[56]=B,t[57]=b):b=t[57],O=`pointer-events-auto absolute top-0 right-0 flex items-center justify-end gap-1 py-2 pr-2`,t[58]!==f||t[59]!==l||t[60]!==c?(_=c&&(0,Z.jsxs)(As,{children:[(0,Z.jsx)(si,{variant:`ghost`,size:`icon`,"aria-label":f({id:`81H_23`}),onClick:l,"data-testid":`add-properties-button`,asChild:!0,children:(0,Z.jsx)(Ts,{children:(0,Z.jsx)(Sl,{})})}),(0,Z.jsx)(Ds,{side:`bottom`,children:(0,Z.jsx)(s,{id:`81H_23`})})]}),t[58]=f,t[59]=l,t[60]=c,t[61]=_):_=t[61],g=As,h=si,x=``,S=`ghost`,C=`icon`,w=d,T=!u,E=`doc-panel`,D=f(u?{id:`u7H-Wn`,values:{panelShortcutLabel:e}}:{id:`2hpdRq`,values:{panelShortcutLabel:e}}),t[1]=f,t[2]=n,t[3]=u,t[4]=r,t[5]=l,t[6]=o,t[7]=d,t[8]=c,t[9]=a,t[10]=h,t[11]=g,t[12]=_,t[13]=v,t[14]=y,t[15]=b,t[16]=x,t[17]=S,t[18]=C,t[19]=w,t[20]=T,t[21]=E,t[22]=D,t[23]=O}else h=t[10],g=t[11],_=t[12],v=t[13],y=t[14],b=t[15],x=t[16],S=t[17],C=t[18],w=t[19],T=t[20],E=t[21],D=t[22],O=t[23];let k;t[62]===u?k=t[63]:(k=(0,Z.jsx)(Ts,{children:u?(0,Z.jsx)(jl,{}):(0,Z.jsx)(Al,{})}),t[62]=u,t[63]=k);let A;t[64]!==h||t[65]!==k||t[66]!==x||t[67]!==S||t[68]!==C||t[69]!==w||t[70]!==T||t[71]!==E||t[72]!==D?(A=(0,Z.jsx)(h,{"data-doc-panel-toggle":x,variant:S,size:C,onClick:w,"aria-expanded":T,"aria-controls":E,"aria-label":D,asChild:!0,children:k}),t[64]=h,t[65]=k,t[66]=x,t[67]=S,t[68]=C,t[69]=w,t[70]=T,t[71]=E,t[72]=D,t[73]=A):A=t[73];let j;t[74]===u?j=t[75]:(j=(0,Z.jsx)(Ds,{side:`bottom`,children:u?(0,Z.jsx)(s,{id:`KFdXwz`,values:{panelShortcut:m}}):(0,Z.jsx)(s,{id:`MsuXaI`,values:{panelShortcut:m}})}),t[74]=u,t[75]=j);let M;t[76]!==g||t[77]!==A||t[78]!==j?(M=(0,Z.jsxs)(g,{children:[A,j]}),t[76]=g,t[77]=A,t[78]=j,t[79]=M):M=t[79];let N;t[80]!==_||t[81]!==M||t[82]!==O?(N=(0,Z.jsxs)(`div`,{className:O,children:[_,M]}),t[80]=_,t[81]=M,t[82]=O,t[83]=N):N=t[83];let P;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none h-2 bg-linear-to-b from-background to-transparent`}),t[84]=P):P=t[84];let F;return t[85]!==v||t[86]!==y||t[87]!==b||t[88]!==N?(F=(0,Z.jsxs)(`div`,{"data-testid":v,className:y,children:[b,N,P]}),t[85]=v,t[86]=y,t[87]=b,t[88]=N,t[89]=F):F=t[89],F}function pA(e){let{activeDocName:t,deferredActiveDocName:n,mountResolved:r,syncResolved:i}=e;return t===null||t===n?!1:!(r&&i)}var mA=`ok-terminal-height-v1`,hA=.5;function gA(e){return Math.max(120,Math.round((Number.isFinite(e)?e:0)*hA))}function _A(e,t){let n=gA(t);return Number.isFinite(e)?e<120?120:e>n?n:Math.round(e):Math.min(240,n)}function vA(){return typeof window>`u`?0:window.innerHeight}function yA(e,t){try{let n=e??localStorage,r=t??vA(),i=n.getItem(mA);if(i==null)return _A(240,r);let a=Number.parseInt(i,10);return _A(Number.isFinite(a)?a:240,r)}catch{return 240}}function bA(e,t,n){try{let r=t??localStorage,i=n??vA();r.setItem(mA,String(_A(e,i)))}catch{}}function xA(){try{return typeof localStorage>`u`?240:yA()}catch{return 240}}var SA=(0,Q.lazy)(()=>n(()=>import(`./TerminalPanel-CDbNsVll.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([58,1,22,6,3,23,9,48,11,59]),import.meta.url));function CA(e){let t=(0,$.c)(12),{bridge:n,onClose:r,onKill:a,launch:o}=e,s=o===void 0?null:o,{enabled:c,synced:l}=ki(),u=so(),{_:d}=i(),f=l&&c===!1,p;t[0]!==d||t[1]!==u?(p=function(){if(u===null){X.error(d({id:`V_6bJ4`}));return}let e=u(!0);e.ok||X.error(d({id:`jKd3AP`,values:{0:e.error}}))},t[0]=d,t[1]=u,t[2]=p):p=t[2];let m=p;if(l&&!f){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`div`,{className:`h-full w-full bg-background`,"aria-hidden":`true`}),t[3]=e):e=t[3];let i;return t[4]!==n||t[5]!==s||t[6]!==r||t[7]!==a?(i=(0,Z.jsx)(le,{fallbackRender:TA,onError:wA,children:(0,Z.jsx)(Q.Suspense,{fallback:e,children:(0,Z.jsx)(SA,{bridge:n,className:`h-full`,onClose:r,onKill:a,launch:s})})}),t[4]=n,t[5]=s,t[6]=r,t[7]=a,t[8]=i):i=t[8],i}let h;return t[9]!==m||t[10]!==f?(h=f?(0,Z.jsx)(OA,{onEnable:m}):(0,Z.jsx)(`div`,{className:`h-full w-full bg-background`,"aria-hidden":`true`}),t[9]=m,t[10]=f,t[11]=h):h=t[11],h}function wA(e,t){console.error(`[TerminalGate] rendered fallback for the terminal panel`,e,t.componentStack)}function TA(e){return(0,Z.jsx)(EA,{...e})}function EA(e){let t=(0,$.c)(15),{error:n}=e,{_:r}=i(),a;t[0]!==r||t[1]!==n?(a=n instanceof Error&&/dynamically imported module|Failed to fetch/i.test(n.message)?r({id:`Y8ViJx`}):r({id:`fbsiBw`}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s;t[3]===r?s=t[4]:(s=r({id:`6MnZEC`}),t[3]=r,t[4]=s);let c;t[5]===o?c=t[6]:(c=(0,Z.jsx)(`p`,{className:`max-w-sm text-sm text-foreground`,children:o}),t[5]=o,t[6]=c);let l;t[7]===r?l=t[8]:(l=r({id:`HpK_8d`}),t[7]=r,t[8]=l);let u;t[9]===l?u=t[10]:(u=(0,Z.jsx)(si,{onClick:DA,children:l}),t[9]=l,t[10]=u);let d;return t[11]!==s||t[12]!==c||t[13]!==u?(d=(0,Z.jsxs)(`section`,{"aria-label":s,className:`flex h-full w-full flex-col items-center justify-center gap-3 bg-background p-6 text-center`,role:`alert`,children:[c,u]}),t[11]=s,t[12]=c,t[13]=u,t[14]=d):d=t[14],d}function DA(){return window.location.reload()}function OA(e){let t=(0,$.c)(20),{onEnable:n}=e,{_:r}=i(),a;t[0]===r?a=t[1]:(a=r({id:`_XWY2J`}),t[0]=r,t[1]=a);let o;t[2]===r?o=t[3]:(o=r({id:`oYepHb`}),t[2]=r,t[3]=o);let s;t[4]===o?s=t[5]:(s=(0,Z.jsx)(`p`,{className:`max-w-sm text-sm text-foreground`,children:o}),t[4]=o,t[5]=s);let c;t[6]===r?c=t[7]:(c=r({id:`v2ZW0K`}),t[6]=r,t[7]=c);let l;t[8]!==n||t[9]!==c?(l=(0,Z.jsx)(si,{onClick:n,children:c}),t[8]=n,t[9]=c,t[10]=l):l=t[10];let u;t[11]===r?u=t[12]:(u=r({id:`ICoNYz`}),t[11]=r,t[12]=u);let d;t[13]===u?d=t[14]:(d=(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u}),t[13]=u,t[14]=d);let f;return t[15]!==a||t[16]!==s||t[17]!==l||t[18]!==d?(f=(0,Z.jsxs)(`section`,{"aria-label":a,className:`flex h-full w-full flex-col items-center justify-center gap-3 bg-background p-6 text-center`,children:[s,l,d]}),t[15]=a,t[16]=s,t[17]=l,t[18]=d,t[19]=f):f=t[19],f}var kA=`terminal-dock-panel`;function AA(e){let t=(0,$.c)(54),{bridge:n,children:r,visible:i,onVisibleChange:a,launch:o}=e,s=o===void 0?null:o,c=Vb(),l=(0,Q.useRef)(null),[u,d]=(0,Q.useState)(!i),[f,p]=(0,Q.useState)(i),[m]=(0,Q.useState)(jA),h=(0,Q.useRef)(m),[g,_]=(0,Q.useState)(!1),v=(0,Q.useRef)(!1),y=(0,Q.useRef)(null),b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b=function(e){y.current!=null&&clearTimeout(y.current),y.current=setTimeout(()=>{bA(e),y.current=null},100)},t[0]=b):b=t[0];let x=b,S=(0,Q.useRef)(null),C,w;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>()=>{y.current!=null&&clearTimeout(y.current),S.current!=null&&(window.removeEventListener(`pointerup`,S.current),S.current=null)},w=[],t[1]=C,t[2]=w):(C=t[1],w=t[2]),(0,Q.useEffect)(C,w);let T,E;t[3]===i?(T=t[4],E=t[5]):(T=()=>{i&&p(!0)},E=[i],t[3]=i,t[4]=T,t[5]=E),(0,Q.useEffect)(T,E);let D;t[6]===a?D=t[7]:(D=function(){p(!1),a(!1),l.current?.focus()},t[6]=a,t[7]=D);let O=D,k=(0,Q.useRef)(O),A;t[8]===O?A=t[9]:(A=()=>{k.current=O},t[8]=O,t[9]=A),(0,Q.useEffect)(A);let j,M;t[10]===n?(j=t[11],M=t[12]):(M=()=>n.onMenuAction(e=>{e===`kill-terminal`&&k.current()}),j=[n],t[10]=n,t[11]=j,t[12]=M),(0,Q.useEffect)(M,j);let N;t[13]!==n.editor||t[14]!==f?(N=()=>{n.editor.notifyViewMenuStateChanged({terminalLive:f})},t[13]=n.editor,t[14]=f,t[15]=N):N=t[15];let P;t[16]!==n||t[17]!==f?(P=[n,f],t[16]=n,t[17]=f,t[18]=P):P=t[18],(0,Q.useEffect)(N,P);let F,I;t[19]!==c||t[20]!==i?(F=()=>{let e=c.current;e!=null&&(i?e.resize(`${h.current}px`):e.collapse())},I=[i,c],t[19]=c,t[20]=i,t[21]=F,t[22]=I):(F=t[21],I=t[22]),(0,Q.useEffect)(F,I);let L,R;t[23]===u?(L=t[24],R=t[25]):(L=()=>{u&&document.getElementById(kA)?.contains(document.activeElement)&&l.current?.focus()},R=[u],t[23]=u,t[24]=L,t[25]=R),(0,Q.useLayoutEffect)(L,R);let z,B;t[26]===u?(z=t[27],B=t[28]):(z=()=>{u||document.getElementById(kA)?.querySelector(`.xterm-helper-textarea`)?.focus()},B=[u],t[26]=u,t[27]=z,t[28]=B),(0,Q.useLayoutEffect)(z,B);let V=g||void 0,H;t[29]===r?H=t[30]:(H=(0,Z.jsx)(oC,{minSize:`20%`,className:`flex min-h-0 flex-col`,children:(0,Z.jsx)(`div`,{ref:l,tabIndex:-1,className:`flex h-full min-h-0 flex-col outline-none`,children:r})}),t[29]=r,t[30]=H);let U;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Z.jsx)(sC,{withHandle:!0,onPointerDown:()=>{_(!0),v.current=!0;let e=()=>{_(!1),v.current=!1,window.removeEventListener(`pointerup`,e),S.current=null};S.current=e,window.addEventListener(`pointerup`,e)}}),t[31]=U):U=t[31];let W=i?`${m}px`:0,G;t[32]!==a||t[33]!==i?(G=e=>{let t=e.asPercentage===0;d(t),v.current&&(t&&i?a(!1):!t&&!i&&a(!0),e.inPixels>0&&(h.current=e.inPixels,x(e.inPixels)))},t[32]=a,t[33]=i,t[34]=G):G=t[34];let K=!g&&`transition-[flex-grow] duration-150 ease-out motion-reduce:transition-none motion-reduce:duration-0`,q;t[35]===K?q=t[36]:(q=ai(`flex flex-col`,K),t[35]=K,t[36]=q);let J;t[37]!==n||t[38]!==O||t[39]!==s||t[40]!==f||t[41]!==a?(J=f?(0,Z.jsx)(CA,{bridge:n,launch:s,onClose:()=>{a(!1),l.current?.focus()},onKill:O}):null,t[37]=n,t[38]=O,t[39]=s,t[40]=f,t[41]=a,t[42]=J):J=t[42];let Y;t[43]!==u||t[44]!==c||t[45]!==W||t[46]!==G||t[47]!==q||t[48]!==J?(Y=(0,Z.jsx)(oC,{id:kA,panelRef:c,defaultSize:W,minSize:`120px`,maxSize:`50%`,collapsible:!0,collapsedSize:0,onResize:G,inert:u,className:q,children:J}),t[43]=u,t[44]=c,t[45]=W,t[46]=G,t[47]=q,t[48]=J,t[49]=Y):Y=t[49];let ee;return t[50]!==V||t[51]!==H||t[52]!==Y?(ee=(0,Z.jsxs)(aC,{orientation:`vertical`,className:`min-h-0 flex-1`,"data-dragging":V,children:[H,U,Y]}),t[50]=V,t[51]=H,t[52]=Y,t[53]=ee):ee=t[53],ee}function jA(){return xA()}var MA=(0,Q.lazy)(async()=>({default:(await n(()=>import(`./ActivityModeContent-Csy-lYtm.js`),__vite__mapDeps([36,1,2,37,38,39,23,40,41,42,43,44,45,46,47,14,6,8,9,22,3,24,4,12,10,11,48,49,50]),import.meta.url)).ActivityModeContent}));function NA(e){let t=(0,$.c)(5),n;t[0]===e?n=t[1]:(n=(0,Z.jsx)(FA,{...e}),t[0]=e,t[1]=n);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(PA,{}),t[2]=r):r=t[2];let i;return t[3]===n?i=t[4]:(i=(0,Z.jsx)(Wt,{name:`editor-area`,children:(0,Z.jsxs)(US,{children:[n,r]})}),t[3]=n,t[4]=i),i}function PA(){let e=(0,$.c)(5),t=Gh(),n;e[0]===t?n=e[1]:(n=e=>{e||t.close()},e[0]=t,e[1]=n);let r;return e[2]!==t.open||e[3]!==n?(r=(0,Z.jsx)(eC,{open:t.open,onOpenChange:n}),e[2]=t.open,e[3]=n,e[4]=r):r=e[4],r}function FA(e){let t=(0,$.c)(148),{editorMode:n,onModeChange:r,activeTab:a,onActiveTabChange:o,terminalBridge:c,terminalVisible:l,onTerminalVisibleChange:u,terminalLaunch:d}=e,f=l===void 0?!1:l,p=d===void 0?null:d,{_:m}=i(),{activeDocName:h,activeProvider:g,activeTarget:_,recycleDocument:v,docPanelMode:y,docPanelAgentId:b,docPanelExpandSignal:S}=pt(),{openDocumentTransition:C}=wt(),{requestAddProperty:w}=GS(),T=kC(g,h),E=MC(h,n===`source`?`source`:`wysiwyg`),D=QC(g),O=D===`connected`||D===`synced`,k=jC(h)===`conflict`,A=(0,Q.useDeferredValue)(h),j=_?.kind===`missing`,M=!!h&&_?.kind!==`folder`,N;t[0]!==m||t[1]!==j?(N=j?m({id:`K-a33w`}):void 0,t[0]=m,t[1]=j,t[2]=N):N=t[2];let P=N,[F]=(0,Q.useState)(RA),I=F!==null,L;t[3]===F?L=t[4]:(L=()=>VC(F,window.innerWidth,`right`),t[3]=F,t[4]=L);let[R,z]=(0,Q.useState)(L),B=(0,Q.useRef)(R),V,H;t[5]===R?(V=t[6],H=t[7]):(V=()=>{B.current=R},H=[R],t[5]=R,t[6]=V,t[7]=H),(0,Q.useEffect)(V,H);let U=Vb(),W;t[8]===R?W=t[9]:(W=()=>XC(`right`,R,JC())===`collapsed`,t[8]=R,t[9]=W);let[G]=(0,Q.useState)(W),[K,q]=(0,Q.useState)(G),J=(0,Q.useRef)(K),Y,ee;t[10]===K?(Y=t[11],ee=t[12]):(Y=()=>{J.current=K},ee=[K],t[10]=K,t[11]=Y,t[12]=ee),(0,Q.useEffect)(Y,ee);let[te,ne]=(0,Q.useState)(!1),re=(0,Q.useRef)(!1),[ie]=(0,Q.useState)(LA),ae=(0,Q.useRef)(ie),oe=(0,Q.useRef)(null),se;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(se=function(e){oe.current!=null&&clearTimeout(oe.current),oe.current=setTimeout(()=>{IC(e),oe.current=null},100)},t[13]=se):se=t[13];let ce=se,le,ue;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>()=>{oe.current!=null&&clearTimeout(oe.current)},ue=[],t[14]=le,t[15]=ue):(le=t[14],ue=t[15]),(0,Q.useEffect)(le,ue);let[de,fe]=(0,Q.useState)(null),pe;t[16]!==K||t[17]!==U?(pe=function(){if(U.current==null)return;let e=B.current;K?(ZC(`right`,e,`open`),U.current?.expand()):(ZC(`right`,e,`collapsed`),U.current?.collapse())},t[16]=K,t[17]=U,t[18]=pe):pe=t[18];let me=pe,he,ge;t[19]!==F||t[20]!==U?(he=()=>{let e=window.matchMedia(`(min-width: ${zC}px)`),t=()=>{let e=VC(F,window.innerWidth,`right`);z(e);let t=XC(`right`,e,JC())===`collapsed`;q(t),t?U.current?.collapse():U.current?.expand()};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},ge=[F,U],t[19]=F,t[20]=U,t[21]=he,t[22]=ge):(he=t[21],ge=t[22]),(0,Q.useEffect)(he,ge);let _e,ve;t[23]!==de||t[24]!==I||t[25]!==U?(_e=()=>{if(de==null||I)return;let e=new ResizeObserver(()=>{J.current||re.current||U.current?.resize(`${ae.current}px`)});return e.observe(de),()=>e.disconnect()},ve=[de,I,U],t[23]=de,t[24]=I,t[25]=U,t[26]=_e,t[27]=ve):(_e=t[26],ve=t[27]),(0,Q.useEffect)(_e,ve);let ye,be;t[28]!==o||t[29]!==U?(ye=()=>{let e=e=>{o(e),U.current?.expand()},t=Gm();return t&&e(t),qm(t=>{Gm(),e(t)})},be=[o,U],t[28]=o,t[29]=U,t[30]=ye,t[31]=be):(ye=t[30],be=t[31]),(0,Q.useEffect)(ye,be);let xe,Se;t[32]!==S||t[33]!==U?(xe=()=>{S!==0&&U.current?.expand()},Se=[S,U],t[32]=S,t[33]=U,t[34]=xe,t[35]=Se):(xe=t[34],Se=t[35]),(0,Q.useEffect)(xe,Se);let Ce,we;t[36]===K?(Ce=t[37],we=t[38]):(Ce=()=>{if(!K||!document.getElementById(`doc-panel`)?.contains(document.activeElement))return;let e=document.querySelector(`[data-doc-panel-toggle]`);if(e){e.focus();return}document.querySelector(`[data-sidebar="trigger"]`)?.focus()},we=[K],t[36]=K,t[37]=Ce,t[38]=we),(0,Q.useLayoutEffect)(Ce,we);let Te,Ee;t[39]===K?(Te=t[40],Ee=t[41]):(Te=()=>{window.okDesktop!=null&&window.okDesktop.editor.notifyViewMenuStateChanged({docPanelVisible:!K})},Ee=[K],t[39]=K,t[40]=Te,t[41]=Ee),(0,Q.useEffect)(Te,Ee);let De,Oe;t[42]===me?(De=t[43],Oe=t[44]):(De=()=>{if(window.okDesktop!=null)return window.okDesktop.onMenuAction(e=>{e===`toggle-doc-panel`&&me()})},Oe=[me],t[42]=me,t[43]=De,t[44]=Oe),(0,Q.useEffect)(De,Oe);let ke,Ae;t[45]===me?(ke=t[46],Ae=t[47]):(ke=()=>{if(window.okDesktop!=null)return;let e=e=>{qs(e,`toggle-document-panel`)&&(e.preventDefault(),me())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},Ae=[me],t[45]=me,t[46]=ke,t[47]=Ae),(0,Q.useEffect)(ke,Ae);let je=(0,Q.useRef)(null),[Me,Ne]=(0,Q.useState)(null),Pe=_?.kind===`large-file`?_.docName:h,Fe,Ie;t[48]===Pe?(Fe=t[49],Ie=t[50]):(Fe=()=>{if(Pe&&Pe!==je.current){let e=je.current;je.current=Pe,Ne(e)}},Ie=[Pe],t[48]=Pe,t[49]=Fe,t[50]=Ie),(0,Q.useEffect)(Fe,Ie);let Le;t[51]===C?Le=t[52]:(Le=function(e){let t=Go(e);window.location.hash===t?C(e):window.location.hash=t},t[51]=C,t[52]=Le);let Re=Le;if(_?.kind===`large-file`){let e;t[53]!==Re||t[54]!==Me?(e=Me?{previousDocName:Me,onNavigateBack:Re}:void 0,t[53]=Re,t[54]=Me,t[55]=e):e=t[55];let n;return t[56]!==_.docName||t[57]!==_.limit||t[58]!==_.size||t[59]!==e?(n=(0,Z.jsx)(zS,{docName:_.docName,size:_.size,limit:_.limit,backNav:e}),t[56]=_.docName,t[57]=_.limit,t[58]=_.size,t[59]=e,t[60]=n):n=t[60],n}if(_?.kind===`folder`){if(!(y===`agent`&&b!==null)){let e;return t[61]===_.folderPath?e=t[62]:(e=(0,Z.jsx)(FS,{folderPath:_.folderPath}),t[61]=_.folderPath,t[62]=e),e}let e;t[63]===_.folderPath?e=t[64]:(e=(0,Z.jsx)(oC,{minSize:`30%`,defaultSize:`75%`,children:(0,Z.jsx)(FS,{folderPath:_.folderPath})}),t[63]=_.folderPath,t[64]=e);let n;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(sC,{withHandle:!0}),t[65]=n):n=t[65];let r;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(oC,{defaultSize:`25%`,minSize:`300px`,maxSize:`40%`,className:`flex flex-col bg-muted/20`,children:(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(`div`,{role:`status`,"aria-busy":`true`,className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:(0,Z.jsx)(s,{id:`ONPvOb`})}),children:(0,Z.jsx)(MA,{showBackButton:!1})})}),t[66]=r):r=t[66];let i;return t[67]===e?i=t[68]:(i=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,Z.jsxs)(aC,{orientation:`horizontal`,children:[e,n,r]})}),t[67]=e,t[68]=i),i}if(_?.kind===`asset`){let e;return t[69]!==_.assetPath||t[70]!==_.mediaKind?(e=(0,Z.jsx)(ex,{assetPath:_.assetPath,mediaKind:_.mediaKind},_.assetPath),t[69]=_.assetPath,t[70]=_.mediaKind,t[71]=e):e=t[71],e}if(!g||!h){if((typeof window<`u`?Po(window.location.hash):null)!==null){let e;return t[72]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(tx,{}),t[72]=e):e=t[72],e}let e;return t[73]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(tS,{}),t[73]=e):e=t[73],e}let ze=n===`source`,Ve=!O,He=K,Ue;t[74]!==h||t[75]!==w?(Ue=function(){h&&w(h)},t[74]=h,t[75]=w,t[76]=Ue):Ue=t[76];let We=Ue,Ge=A??h,Ke=Me??void 0,qe;t[77]!==P||t[78]!==ze||t[79]!==Re||t[80]!==v||t[81]!==Ge||t[82]!==Ke?(qe=(0,Z.jsx)(rk,{activeDocName:Ge,isSourceMode:ze,editorPlaceholder:P,previousDocName:Ke,onNavigateBack:Re,onRecycle:v}),t[77]=P,t[78]=ze,t[79]=Re,t[80]=v,t[81]=Ge,t[82]=Ke,t[83]=qe):qe=t[83];let Je;t[84]!==h||t[85]!==ze?(Je=(0,Z.jsx)(TC,{activeDocName:h,isSourceMode:ze}),t[84]=h,t[85]=ze,t[86]=Je):Je=t[86];let Ye;t[87]!==h||t[88]!==A?(Ye=pA({activeDocName:h,deferredActiveDocName:A,mountResolved:h!==null&&x(h),syncResolved:h!==null&&Be(h)})?(0,Z.jsxs)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:[(0,Z.jsx)(tx,{}),h===null?null:(0,Z.jsx)(BS,{docName:h})]}):null,t[87]=h,t[88]=A,t[89]=Ye):Ye=t[89];let Xe;t[90]!==qe||t[91]!==Je||t[92]!==Ye?(Xe=(0,Z.jsxs)(`div`,{className:`relative h-full`,children:[qe,Je,Ye]}),t[90]=qe,t[91]=Je,t[92]=Ye,t[93]=Xe):Xe=t[93];let Ze;t[94]!==h||t[95]!==k||t[96]!==He||t[97]!==ze||t[98]!==r||t[99]!==We||t[100]!==Ve||t[101]!==me?(Ze=!k&&(0,Z.jsx)(fA,{activeDocName:h,isSourceMode:ze,sourceDisabled:Ve,onModeChange:r,showAddPropertyButton:!ze,onAddProperty:We,isPanelCollapsed:He,onTogglePanel:me}),t[94]=h,t[95]=k,t[96]=He,t[97]=ze,t[98]=r,t[99]=We,t[100]=Ve,t[101]=me,t[102]=Ze):Ze=t[102];let Qe;t[103]!==Xe||t[104]!==Ze?(Qe=(0,Z.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[Xe,Ze]}),t[103]=Xe,t[104]=Ze,t[105]=Qe):Qe=t[105];let $e;t[106]!==E||t[107]!==M||t[108]!==T?($e=(0,Z.jsx)(Xk,{stats:T,selectionStats:E,showStats:M}),t[106]=E,t[107]=M,t[108]=T,t[109]=$e):$e=t[109];let et;t[110]!==Qe||t[111]!==$e?(et=(0,Z.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[Qe,$e]}),t[110]=Qe,t[111]=$e,t[112]=et):et=t[112];let tt=et,nt;t[113]!==tt||t[114]!==u||t[115]!==c||t[116]!==p||t[117]!==f?(nt=c==null?tt:(0,Z.jsx)(AA,{bridge:c,visible:f,onVisibleChange:u??IA,launch:p,children:tt}),t[113]=tt,t[114]=u,t[115]=c,t[116]=p,t[117]=f,t[118]=nt):nt=t[118];let rt=nt,it=te||void 0,at;t[119]===G?at=t[120]:(at=G?{defaultSize:`100%`}:{},t[119]=G,t[120]=at);let ot=te?void 0:`transition-[flex-grow] duration-200 ease-out motion-reduce:transition-none motion-reduce:duration-0`,st;t[121]!==rt||t[122]!==at||t[123]!==ot?(st=(0,Z.jsx)(oC,{minSize:`30%`,...at,className:ot,children:rt}),t[121]=rt,t[122]=at,t[123]=ot,t[124]=st):st=t[124];let ct=I&&K,lt;t[125]===Symbol.for(`react.memo_cache_sentinel`)?(lt=()=>{ne(!0),re.current=!0;let e=()=>{ne(!1),re.current=!1,window.removeEventListener(`pointerup`,e)};window.addEventListener(`pointerup`,e)},t[125]=lt):lt=t[125];let ut;t[126]===ct?ut=t[127]:(ut=(0,Z.jsx)(sC,{withHandle:!0,disabled:ct,onPointerDown:lt}),t[126]=ct,t[127]=ut);let dt=G?0:`${ie}px`,ft;t[128]===Symbol.for(`react.memo_cache_sentinel`)?(ft=e=>{q(e.asPercentage===0),e.inPixels>0&&re.current&&(ae.current=e.inPixels,ce(e.inPixels))},t[128]=ft):ft=t[128];let mt=!te&&`transition-[flex-grow] duration-200 ease-out motion-reduce:transition-none motion-reduce:duration-0`,ht;t[129]===mt?ht=t[130]:(ht=ai(`flex flex-col bg-muted/20`,mt),t[129]=mt,t[130]=ht);let gt;t[131]!==h||t[132]!==a||t[133]!==y||t[134]!==ze||t[135]!==o?(gt=(0,Z.jsx)(qv,{docName:h,isSourceMode:ze,activeTab:a,onActiveTabChange:o,mode:y}),t[131]=h,t[132]=a,t[133]=y,t[134]=ze,t[135]=o,t[136]=gt):gt=t[136];let _t;t[137]!==K||t[138]!==U||t[139]!==dt||t[140]!==ht||t[141]!==gt?(_t=(0,Z.jsx)(oC,{id:`doc-panel`,panelRef:U,defaultSize:dt,minSize:`300px`,maxSize:`600px`,collapsible:!0,collapsedSize:0,onResize:ft,inert:K,className:ht,children:gt}),t[137]=K,t[138]=U,t[139]=dt,t[140]=ht,t[141]=gt,t[142]=_t):_t=t[142];let vt;return t[143]!==it||t[144]!==st||t[145]!==ut||t[146]!==_t?(vt=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1`,ref:fe,children:(0,Z.jsxs)(aC,{orientation:`horizontal`,"data-dragging":it,children:[st,ut,_t]})}),t[143]=it,t[144]=st,t[145]=ut,t[146]=_t,t[147]=vt):vt=t[147],vt}function IA(){}function LA(){return LC()}function RA(){return Er()}function zA(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.kind!==i.kind)return!1;if(r.kind===`human`&&i.kind===`human`){if(r.clientId!==i.clientId||r.mode!==i.mode||r.tabCount!==i.tabCount)return!1;let e=r.user,t=i.user;if(e.name!==t.name||e.color!==t.color||e.icon!==t.icon)return!1}else if(r.kind===`agent`&&i.kind===`agent`){if(r.agentId!==i.agentId)return!1;let e=r.presence,t=i.presence;if(e.displayName!==t.displayName||e.icon!==t.icon||e.color!==t.color||e.currentDoc!==t.currentDoc||e.mode!==t.mode)return!1}}return!0}function BA(e){let t=new Map;for(let n of e){let e=n.user.principalId;if(typeof e==`string`&&e.length>0){let r=t.get(e);r?r.push(n):t.set(e,[n])}}let n=new Map;for(let[e,r]of t){let t=r.reduce((e,t)=>Math.min(e,t.clientId),1/0);n.set(e,{repClientId:t,count:r.length})}let r=[];for(let t of e){let e=t.user.principalId;if(typeof e==`string`&&e.length>0){let i=n.get(e);i&&i.repClientId===t.clientId&&r.push({...t,tabCount:i.count})}else r.push({...t,tabCount:1})}return r}var VA=1e3,HA=!1;function UA(e){return!!(e.localPrincipalId&&e.entryPrincipalId===e.localPrincipalId||!e.localPrincipalId&&e.entryClientId===e.localClientId)}function WA(e,t,n){let r=(0,$.c)(9),i;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={current:[],crossDoc:[]},r[0]=i):i=r[0];let[a,o]=(0,Q.useState)(i),s;r[1]!==n||r[2]!==e?.awareness||r[3]!==t?.awareness?(s=()=>{let r=e?.awareness,i=t?.awareness,a;i==null?a=void 0:xi(i)?a=i:(a=void 0,HA||(HA=!0,console.warn(`[agent-presence] __system__ provider awareness missing getStates() — presence bar will render without agent peers`)));let s=()=>{let e=(r?.getLocalState())?.user?.principalId??null,t=r?.clientID??null,i=[];if(r)for(let[n,a]of r.getStates().entries()){let r=a;if(!r.user||typeof r.user!=`object`)continue;let o=r.user;o.type===`human`&&(UA({entryPrincipalId:o.principalId,entryClientId:n,localPrincipalId:e,localClientId:t})||i.push({kind:`human`,clientId:n,user:o,mode:r.mode??`wysiwyg`,tabCount:1}))}let s=BA(i),{current:c,crossDoc:l}=a?gi(a,n,Date.now()):{current:[],crossDoc:[]},u=GA,d=c.map(u),f=l.map(u),p=[...s,...d],m=f;o(e=>zA(e.current,p)&&zA(e.crossDoc,m)?e:{current:p,crossDoc:m})};s();let c=()=>s(),l=()=>s();r?.on(`change`,c),t?.awareness?.on(`change`,l);let u=setInterval(s,VA);return()=>{r?.off(`change`,c),t?.awareness?.off(`change`,l),clearInterval(u)}},r[1]=n,r[2]=e?.awareness,r[3]=t?.awareness,r[4]=s):s=r[4];let c;return r[5]!==n||r[6]!==e||r[7]!==t?(c=[e,t,n],r[5]=n,r[6]=e,r[7]=t,r[8]=c):c=r[8],(0,Q.useEffect)(s,c),a}function GA(e){let{agentId:t,entry:n}=e;return{kind:`agent`,agentId:t,presence:n}}var KA=`sync-status`;function qA(e,t){let n=(0,$.c)(6),{_:r}=i(),a=Ap(),o=(0,Q.useRef)(!1),s=(0,Q.useRef)(!1),c=(0,Q.useRef)(t),l,u;n[0]!==r||n[1]!==t||n[2]!==a||n[3]!==e?(l=()=>{if(c.current!==t&&(c.current=t,o.current=!1,s.current=!1),t)if(e===`synced`&&(o.current=!0),e===`disconnected`&&o.current){if(a){X.dismiss(KA);return}s.current=!0,X.warning(r({id:`HGNCsl`}),{id:KA,duration:1/0})}else s.current&&e===`synced`&&(s.current=!1,X.success(r({id:`GhjUB_`}),{id:KA,duration:3e3}))},u=[e,t,r,a],n[0]=r,n[1]=t,n[2]=a,n[3]=e,n[4]=l,n[5]=u):(l=n[4],u=n[5]),(0,Q.useEffect)(l,u)}var JA=4,YA=3,XA={Bird:Gc,Cat:Zc,Dog:il,Fish:ll,Mouse:Il,Rabbit:Fl,Shrimp:Hl,Snail:Ul,Squirrel:ql,Turtle:tu};Object.freeze(Object.keys(XA));function ZA(e){if(typeof e.principalId==`string`&&e.principalId.length>0)return{kind:`initials`};let t=e.name.split(` `)[1];return t&&Object.hasOwn(XA,t)?{kind:`animal`,animal:t}:{kind:`initials`}}var QA={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function $A(e){let t=(0,$.c)(28),{user:n,mode:r,tabCount:a}=e,{_:o}=i(),s=ZA(n),c=s.kind===`animal`?XA[s.animal]:void 0,l;t[0]===n.name?l=t[1]:(l=tr(n.name),t[0]=n.name,t[1]=l);let u=l,d;t[2]===n.color?d=t[3]:(d=Hr(n.color),t[2]=n.color,t[3]=d);let f=d,p=n.name,m;t[4]!==o||t[5]!==a||t[6]!==p?(m=a>1?o({id:`qAhFeg`,values:{userName:p,tabCount:a}}):p,t[4]=o,t[5]=a,t[6]=p,t[7]=m):m=t[7];let h=m,g;t[8]!==o||t[9]!==a||t[10]!==p?(g=a>1?o({id:`BEkF-P`,values:{userName:p,tabCount:a}}):p,t[8]=o,t[9]=a,t[10]=p,t[11]=g):g=t[11];let _=g,v;t[12]===n.color?v=t[13]:(v={backgroundColor:n.color},t[12]=n.color,t[13]=v);let y;t[14]!==c||t[15]!==f||t[16]!==u?(y=c?(0,Z.jsx)(c,{size:18,color:f,strokeWidth:1.5}):(0,Z.jsx)(`span`,{className:`font-mono text-2xs font-semibold leading-none`,style:{color:f},children:u}),t[14]=c,t[15]=f,t[16]=u,t[17]=y):y=t[17];let b;t[18]!==_||t[19]!==r||t[20]!==v||t[21]!==y?(b=(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(`div`,{"data-presence-badge":`human`,"data-presence-mode":r,role:`img`,"aria-label":_,className:`inline-flex size-7 shrink-0 cursor-default items-center justify-center rounded-full ring-2 ring-background`,style:v,children:y})}),t[18]=_,t[19]=r,t[20]=v,t[21]=y,t[22]=b):b=t[22];let x;t[23]===h?x=t[24]:(x=(0,Z.jsx)(Ds,{children:h}),t[23]=h,t[24]=x);let S;return t[25]!==b||t[26]!==x?(S=(0,Z.jsxs)(As,{children:[b,x]}),t[25]=b,t[26]=x,t[27]=S):S=t[27],S}function ej(e){let t=QA[e.icon];return e.displayName||t||Ko._({id:`iEQQyu`})}function tj(e){let t=(0,$.c)(3),[n,r]=(0,Q.useState)(e===`writing`),i=(0,Q.useRef)(null),a,o;return t[0]===e?(a=t[1],o=t[2]):(a=()=>{if(e===`writing`){i.current!==null&&(clearTimeout(i.current),i.current=null),r(!0);return}return i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>{i.current=null,r(!1)},600),()=>{i.current!==null&&(clearTimeout(i.current),i.current=null)}},o=[e],t[0]=e,t[1]=a,t[2]=o),(0,Q.useEffect)(a,o),n}function nj(e){let t=(0,$.c)(33),{participant:n,crossDoc:r,scoped:a,onClickAgent:o}=e,{_:c}=i(),{activeDocName:l}=pt(),{presence:u,agentId:d}=n,f=ej(u),p=tj(u.mode),m=!r&&p,h=u.currentDoc&&u.currentDoc!==`(connected)`?u.currentDoc:null,g=l!==null||h!==null,_=g?`cursor-pointer`:`cursor-default opacity-50`,v=a?`ring-primary ring-offset-2 ring-offset-background`:`ring-background`,y=m&&!a?`ring-primary/40 animate-pulse`:``,b;t[0]!==_||t[1]!==v||t[2]!==y?(b=[`inline-flex size-7 shrink-0 items-center justify-center rounded-full ring-2`,_,v,y].filter(Boolean),t[0]=_,t[1]=v,t[2]=y,t[3]=b):b=t[3];let x=b.join(` `),S=r?`true`:void 0,C=a?`true`:void 0,w=g?void 0:`true`,T;t[4]!==u.mode||t[5]!==S||t[6]!==C||t[7]!==w?(T={"data-presence-badge":`agent`,"data-presence-mode":u.mode,"data-presence-crossdoc":S,"data-presence-scoped":C,"data-presence-inert":w},t[4]=u.mode,t[5]=S,t[6]=C,t[7]=w,t[8]=T):T=t[8];let E=T,D=c(r&&h?{id:`b4AQFK`,values:{tooltipName:f,realCurrentDoc:h}}:{id:`RfHNf8`,values:{tooltipName:f}}),O;t[9]!==d||t[10]!==D||t[11]!==E||t[12]!==g||t[13]!==o||t[14]!==u.color||t[15]!==u.icon||t[16]!==h||t[17]!==x||t[18]!==f?(O=g?(0,Z.jsx)(`button`,{type:`button`,...E,"aria-label":D,className:x,style:{backgroundColor:u.color},onClick:()=>o(d,h),children:(0,Z.jsx)(yi,{icon:u.icon,width:16,height:16,className:`text-white`,"aria-hidden":!0})}):(0,Z.jsx)(`div`,{...E,role:`img`,"aria-label":f,className:x,style:{backgroundColor:u.color},children:(0,Z.jsx)(yi,{icon:u.icon,width:16,height:16,className:`text-white`,"aria-hidden":!0})}),t[9]=d,t[10]=D,t[11]=E,t[12]=g,t[13]=o,t[14]=u.color,t[15]=u.icon,t[16]=h,t[17]=x,t[18]=f,t[19]=O):O=t[19];let k=O,A;t[20]===k?A=t[21]:(A=(0,Z.jsx)(Ts,{asChild:!0,children:k}),t[20]=k,t[21]=A);let j;t[22]===f?j=t[23]:(j=(0,Z.jsx)(`span`,{className:`font-medium`,children:f}),t[22]=f,t[23]=j);let M;t[24]!==r||t[25]!==h?(M=r&&h?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:(0,Z.jsx)(s,{id:`Wh0im4`,values:{realCurrentDoc:h}})}):null,t[24]=r,t[25]=h,t[26]=M):M=t[26];let N;t[27]!==j||t[28]!==M?(N=(0,Z.jsxs)(Ds,{className:`flex flex-col gap-0.5`,children:[j,M]}),t[27]=j,t[28]=M,t[29]=N):N=t[29];let P;return t[30]!==A||t[31]!==N?(P=(0,Z.jsxs)(As,{children:[A,N]}),t[30]=A,t[31]=N,t[32]=P):P=t[32],P}function rj(e){let t=(0,$.c)(21),{count:n,remainder:r,crossDoc:i,scopedAgentId:a,onClickAgent:o}=e,s;t[0]!==n||t[1]!==i?(s=i?Ko._({id:`9euN0m`,values:{count:n}}):Ko._({id:`uhJEA2`,values:{count:n}}),t[0]=n,t[1]=i,t[2]=s):s=t[2];let c=s,l=i?`true`:void 0,u;t[3]!==n||t[4]!==c||t[5]!==l?(u=(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`presence-overflow`,"data-presence-crossdoc":l,className:`inline-flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-full bg-muted font-medium text-muted-foreground text-xs ring-2 ring-background hover:bg-muted/80`,"aria-label":c,children:[`+`,n]})}),t[3]=n,t[4]=c,t[5]=l,t[6]=u):u=t[6];let d;if(t[7]!==i||t[8]!==o||t[9]!==r||t[10]!==a){let e;t[12]!==i||t[13]!==o||t[14]!==a?(e=e=>e.kind===`human`?(0,Z.jsx)($A,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(nj,{participant:e,crossDoc:i,scoped:a===e.agentId,onClickAgent:o},e.agentId),t[12]=i,t[13]=o,t[14]=a,t[15]=e):e=t[15],d=r.map(e),t[7]=i,t[8]=o,t[9]=r,t[10]=a,t[11]=d}else d=t[11];let f;t[16]===d?f=t[17]:(f=(0,Z.jsx)(b,{align:`end`,className:`w-auto max-w-xs p-2`,children:(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:d})}),t[16]=d,t[17]=f);let p;return t[18]!==u||t[19]!==f?(p=(0,Z.jsxs)(pe,{children:[u,f]}),t[18]=u,t[19]=f,t[20]=p):p=t[20],p}function ij(e,t,n,r){return e.kind===`human`?(0,Z.jsx)($A,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(nj,{participant:e,crossDoc:n,scoped:r===e.agentId,onClickAgent:t},e.agentId)}function aj(){let e=(0,$.c)(20),{activeProvider:t,activeDocName:n,systemProvider:r,openActivityPanel:i,docPanelMode:a,docPanelAgentId:o}=pt(),{current:s,crossDoc:c}=WA(t,r,n);if(qA(QC(t),n),s.length===0&&c.length===0)return null;let l;if(e[0]!==c||e[1]!==s||e[2]!==o||e[3]!==a||e[4]!==i){let t=s.slice(0,JA),n;e[6]===s?n=e[7]:(n=s.slice(JA),e[6]=s,e[7]=n);let r=n,u=c.slice(0,YA),d;e[8]===c?d=e[9]:(d=c.slice(YA),e[8]=c,e[9]=d);let f=d,p=i,m=a===`agent`?o:null,h;e[10]!==p||e[11]!==m?(h=e=>ij(e,p,!1,m),e[10]=p,e[11]=m,e[12]=h):h=e[12];let g=t.map(h),_;e[13]!==r||e[14]!==p||e[15]!==m?(_=r.length>0?(0,Z.jsx)(rj,{count:r.length,remainder:r,crossDoc:!1,scopedAgentId:m,onClickAgent:p}):null,e[13]=r,e[14]=p,e[15]=m,e[16]=_):_=e[16];let v;e[17]!==g||e[18]!==_?(v=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,"data-presence-section":`current`,children:[g,_]}),e[17]=g,e[18]=_,e[19]=v):v=e[19],l=(0,Z.jsxs)(`div`,{"data-slot":`presence-bar`,className:`flex items-center px-1 py-1.5`,children:[v,c.length>0?(0,Z.jsxs)(`div`,{className:`ml-1.5 flex items-center gap-1.5`,"data-presence-section":`crossdoc`,children:[u.map(e=>ij(e,p,!0,m)),f.length>0?(0,Z.jsx)(rj,{count:f.length,remainder:f,crossDoc:!0,scopedAgentId:m,onClickAgent:p}):null]}):null]}),e[0]=c,e[1]=s,e[2]=o,e[3]=a,e[4]=i,e[5]=l}else l=e[5];return l}function oj(e){let t=e.lastIndexOf(`/`),n=t<0?e:e.slice(t+1),r=n.lastIndexOf(`.`);return r<=0?``:n.slice(r)}function sj(e,t){let n=e.lastIndexOf(`/`),r=n<0?``:e.slice(0,n+1),i=n<0?e:e.slice(n+1),a=i.lastIndexOf(`.`);return`${r}${a<=0?i:i.slice(0,a)}${t}`}function cj(e,t,n,r=!1){if(n)return{kind:`allow`,destinationPath:t};let i=oj(e);if(i===``)return{kind:`allow`,destinationPath:t};let a=oj(t);return r?{kind:`allow`,destinationPath:a?t:sj(t,i)}:a&&a.toLowerCase()!==i.toLowerCase()?{kind:`block`}:{kind:`allow`,destinationPath:sj(t,i)}}var lj=`.md`,uj=/\.(md|mdx)$/i;function dj(e,t=lj){return`${e}${t}`}function fj(e){return zj(e).replace(uj,``)}function pj(e){return Jo(e)?gj(e.path):Io(e)?e.path:dj(e.docName,e.docExt)}function mj(e){let t=zj(e).match(uj);return t?`.${t[1].toLowerCase()}`:void 0}function hj(e){return zj(e)}function gj(e){let t=zj(e.trim());return t?`${t}/`:``}function _j(e){return e.endsWith(`/`)?hj(e):fj(e)}function vj(e){return e.map(pj)}function yj(e){return[...e].sort().join(`\0`)}function bj(e){return yj(vj(e))}function xj(e){let t=new Set;for(let n of e){if(Jo(n)){let e=gj(n.path);e&&t.add(e)}let e=(Jo(n)||Io(n)?n.path:n.docName).split(`/`).filter(Boolean),r=Jo(n)?e.length:e.length-1;for(let n=1;n<=r;n++)t.add(`${e.slice(0,n).join(`/`)}/`)}return[...t].sort()}function Sj(e){if(!e)return[];let t=zj(e.replace(uj,``)).split(`/`).filter(Boolean),n=[],r=e.endsWith(`/`)?t.length:t.length-1;for(let e=1;e<=r;e++)n.push(`${t.slice(0,e).join(`/`)}/`);return n}function Cj(e,t,n){let r=mj(e);if(r)return r;let i=n.find(e=>ls(e)&&e.docName===t);return i?i.docExt??lj:Rj(e).includes(`.`)?void 0:lj}function wj(e,t){let n=e.lastIndexOf(`/`),r=n===-1?``:e.slice(0,n+1),i=n===-1?e:e.slice(n+1),a=t.filter(e=>{if(!Io(e)||!e.path.startsWith(r))return!1;let t=e.path.slice(r.length);return!t.includes(`/`)&&t.startsWith(`${i}.`)});return a.length===1?a[0].path:null}function Tj(e,t,n){if(mj(e))return null;let r=n.find(e=>Io(e)&&e.path===t);return r?r.path:Rj(e).includes(`.`)?t:wj(t,n)}function Ej(e,t){let n=e.kind===`directory`,r=n?hj(e.path):fj(e.path);if(n)return{kind:`folder`,name:zj(Rj(e.path)).replace(uj,``),path:r,treePath:Oj(e.path,!0)};let i=Tj(e.path,r,t);if(i)return{kind:`asset`,name:zj(Rj(i)),path:i,treePath:i};let a=Cj(e.path,r,t);return{kind:`file`,name:zj(Rj(e.path)).replace(uj,``),path:r,treePath:Oj(e.path,!1),docExt:a}}function Dj(e){return e.kind===`directory`?hj(e.path):e.path}function Oj(e,t){return t?gj(e):uj.test(e)?e:`${e}${lj}`}function kj(e,t,n){let r=gj(t),i=new Set(n);for(let t=0;t<100;t++){let n=t===0?``:` ${t+1}`;if(e===`file`){let e=`${r}Untitled${n}${lj}`;if(!i.has(e))return{addPath:e,renamePath:e};continue}let a=`${r}New Folder${n}/`;if(!i.has(a))return{addPath:a,renamePath:a}}throw Error(`Could not allocate a unique tree placeholder`)}function Aj(e,t){return e===`file`?Oj(t,!1):`${hj(t)}/index${lj}`}function jj(e,t){return t.kind===`root`||t.directoryPath==null?Rj(e):`${t.directoryPath}${Rj(e)}`}function Mj(e,t){if(t)return hj(gj(e));let n=fj(e),r=n.lastIndexOf(`/`);return r===-1?``:n.slice(0,r)}function Nj(e,t){let n=hj(gj(e));return n?`${n}/${t}`:t}function Pj(e,t){return(t.path??Nj(e,t.src)).replace(/^\/+/,``)}function Fj(e){let t=e.dataTransfer?.types;if(!t)return!1;let n=Array.from(t);return n.includes(`Files`)&&!n.includes(`application/x-open-knowledge-sidebar-item+json`)}function Ij(e){return Array.from(e.dataTransfer?.files??[]).filter(e=>e.name.length>0||e.size>0)}function Lj(e,t){let n=oj(e).toLowerCase();if(n===``)return null;let r=new Date().toISOString();if(n===`.md`||n===`.mdx`)return{kind:`document`,docName:fj(e),docExt:n,modified:r,size:t.size};let i=n.startsWith(`.`)?n.slice(1):n;return{kind:`asset`,path:e,assetExt:i,mediaKind:rr(i),modified:r,size:t.size}}function Rj(e){let t=zj(e),n=t.lastIndexOf(`/`),r=n===-1?t:t.slice(n+1);return e.endsWith(`/`)?`${r}/`:r}function zj(e){return e.endsWith(`/`)?e.slice(0,-1):e}function Bj(e,t){return t.trim()}function Vj(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function Hj(e,t){let n=Bj(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function Uj(e,t,n=[],r=[]){if(t.length===0&&n.length===0&&r.length===0)return e;let i=new Map(t.map(e=>[e.fromDocName,e.toDocName])),a=new Map(r.map(e=>[e.fromPath,e.toPath]));return e.map(e=>ls(e)?{...e,docName:i.get(e.docName)??e.docName}:Jo(e)?{...e,path:Xj(e.path,n)}:Io(e)?{...e,path:a.get(e.path)??Xj(e.path,n)}:e)}function Wj(e,t,n,r=[]){if(t.length===0&&!n&&r.length===0)return e;let i=new Set(t),a=new Set(r);return e.filter(e=>ls(e)?!i.has(e.docName)&&!eM(e.docName,n):Jo(e)?!eM(e.path,n):Io(e)?!a.has(e.path)&&!eM(e.path,n):!0)}function Gj(e,t){if(e.kind!==`asset`||t.some(t=>Io(t)&&t.path===e.path))return e;let n=wj(e.path,t);return n?{...e,path:n,name:n.split(`/`).pop()??n}:e}function Kj(e,t,n,r=new Date().toISOString()){let i=!1,a=[...e],o=e=>{a.some(t=>Zj(t,e))||(a.push(e),i=!0)};if(n.kind===`file`){let s=e.find(e=>ls(e)&&e.docName===t.path);return o({kind:`document`,docName:n.path,docExt:s?.docExt??t.docExt,size:s?.size??0,modified:r}),i?a:e}let s=e.find(e=>Jo(e)&&e.path===t.path);o({kind:`folder`,path:n.path,size:s?.size??0,modified:r});let c=new Set(n.duplicatedDocNames);for(let i of e){if(ls(i)){let e=$j(i.docName,t.path,n.path);e&&c.has(e)&&o({...i,docName:e,modified:r});continue}if(Jo(i)){let e=Qj(i.path,t.path,n.path);e&&o({...i,path:e,modified:r})}}return i?a:e}function qj(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}function Jj(e,t,n){return e.flatMap(e=>t===e.toDocName||!n(e.toDocName)?[e.fromDocName]:[e.fromDocName,e.toDocName])}function Yj(e,t){let n=e.kind===`file`?dj(e.path,e.docExt):e.path;return gg(t.contentDir,n,t.pathSeparator)}function Xj(e,t){for(let{fromPath:n,toPath:r}of t){if(e===n)return r;if(e.startsWith(`${n}/`))return`${r}${e.slice(n.length)}`}return e}function Zj(e,t){return ls(e)&&ls(t)?e.docName===t.docName:Jo(e)&&Jo(t)||Io(e)&&Io(t)?e.path===t.path:!1}function Qj(e,t,n){return e===t?n:$j(e,t,n)}function $j(e,t,n){return e.startsWith(`${t}/`)?`${n}${e.slice(t.length)}`:null}function eM(e,t){return!!t&&(e===t||e.startsWith(`${t}/`))}function tM(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Z.jsx)(nd,{"data-slot":`context-menu`,...n}),t[2]=n,t[3]=r),r}function nM(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`select-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(rd,{"data-slot":`context-menu-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function rM(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Z.jsx)(ud,{"data-slot":`context-menu-sub`,...n}),t[2]=n,t[3]=r),r}function iM(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`z-50 max-h-(--radix-context-menu-content-available-height) min-w-36 origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 motion-reduce:data-open:animate-none motion-reduce:data-closed:animate-none motion-reduce:duration-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(id,{children:(0,Z.jsx)(ad,{"data-slot":`context-menu-content`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function aM(e){let t=(0,$.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,inset:r,variant:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?`default`:a,s;t[5]===n?s=t[6]:(s=ai(`group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive`,n),t[5]=n,t[6]=s);let c;return t[7]!==r||t[8]!==i||t[9]!==s||t[10]!==o?(c=(0,Z.jsx)(od,{"data-slot":`context-menu-item`,"data-inset":r,"data-variant":o,className:s,...i}),t[7]=r,t[8]=i,t[9]=s,t[10]=o,t[11]=c):c=t[11],c}function oM(e){let t=(0,$.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,inset:i,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=ai(`flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,r),t[5]=r,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(jo,{className:`ml-auto`}),t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==a||t[11]!==o?(c=(0,Z.jsxs)(dd,{"data-slot":`context-menu-sub-trigger`,"data-inset":i,className:o,...a,children:[n,s]}),t[8]=n,t[9]=i,t[10]=a,t[11]=o,t[12]=c):c=t[12],c}function sM(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`z-50 max-h-(--radix-context-menu-content-available-height) min-w-32 origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg border bg-popover p-1 text-popover-foreground shadow-lg data-[state=closed]:overflow-hidden duration-100 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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 motion-reduce:data-open:animate-none motion-reduce:data-closed:animate-none motion-reduce:duration-0 subtle-scrollbar`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(fd,{"data-slot":`context-menu-sub-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function cM(e){let t=(0,$.c)(15),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:i,children:r,checked:n,inset:a,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===i?s=t[7]:(s=ai(`relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,i),t[6]=i,t[7]=s);let c;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(`span`,{className:`pointer-events-none absolute right-2`,children:(0,Z.jsx)(cd,{children:(0,Z.jsx)(Do,{})})}),t[8]=c):c=t[8];let l;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==s?(l=(0,Z.jsxs)(sd,{"data-slot":`context-menu-checkbox-item`,"data-inset":a,className:s,checked:n,...o,children:[c,r]}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=s,t[14]=l):l=t[14],l}function lM(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=ai(`-mx-1 my-1 h-px bg-border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(ld,{"data-slot":`context-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var uM=`mr-1.5 flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm text-muted-foreground outline-none transition hover:bg-foreground/10 hover:text-foreground hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/50`,dM=`border-border bg-background text-foreground hover:bg-background focus-visible:bg-background`,fM={start:[Ui.Space],cancel:[Ui.Esc],end:[Ui.Space,Ui.Enter]};function pM(e){return ai(uM,e?`opacity-100`:`pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100`)}function mM(e){return e?void 0:-1}function hM({className:e,isDragging:t}){return ai(e,t&&dM)}function gM(e){return e.code===Ui.Enter&&e.target===e.currentTarget}function _M({event:e,hasKeyboardActivation:t,isDragging:n}){return e.defaultPrevented?`ignore`:!n&&t&&gM(e)?`activate-tab`:`delegate-sortable`}function vM({activeWidth:e,isDragging:t,outerStyle:n,transform:r,transition:i}){let a=t&&e?e:void 0;return{...n,transform:ja.Transform.toString(r?{...r,scaleX:1,scaleY:1}:null),transition:i,flexBasis:a??n?.flexBasis,maxWidth:a??n?.maxWidth,minWidth:a??n?.minWidth,opacity:n?.opacity,width:a??n?.width,zIndex:t?20:n?.zIndex}}function yM(e){let t=e?.querySelectorAll(`[data-editor-tab-sortable]`)??[],n=1/0,r=-1/0;for(let e of t){let t=e.getBoundingClientRect();n=Math.min(n,t.left),r=Math.max(r,t.right)}return Number.isFinite(n)&&Number.isFinite(r)?{left:n,right:r}:null}function bM(e){return({activeNodeRect:t,transform:n})=>{let r={...n,y:0};if(!e||!t)return r;let i=e.left-t.left,a=e.right-t.right;return r.x=Math.min(Math.max(r.x,i),a),r}}var xM=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(r){let e=1/0,i=-1/0,a=null,o=null;for(let r of t){let t=n.get(r.id);t&&(t.left<e&&(e=t.left,a=r),t.right>i&&(i=t.right,o=r))}if(!Number.isFinite(e)||!Number.isFinite(i))return[];let s=r.x<e?a:r.x>i?o:null;if(s)return[{id:s.id,data:{droppableContainer:s,value:0}}]}return xa(e)},SM=[`.md`,`.mdx`],CM=`group relative -mb-px flex h-10 min-w-28 max-w-64 shrink-0 cursor-pointer items-center overflow-hidden border border-transparent font-medium transition-colors`,wM=`z-10 rounded-t-lg rounded-b-none border-border border-b-0 bg-background text-foreground`,TM=ai(wM,`bg-transparent hover:bg-muted focus-visible:bg-muted border-transparent hover:border-border focus-visible:border-border`),EM=`flex h-full min-w-0 flex-1 cursor-pointer items-center overflow-hidden px-3 text-left text-[13px]`;function DM(e){return e.replace(/[^A-Za-z0-9_-]/g,`-`)}function OM(e){let t=Go(e);window.location.hash!==t&&(window.location.hash=t)}function kM(e){Math.abs(e.deltaX)>=Math.abs(e.deltaY)||e.currentTarget.scrollWidth<=e.currentTarget.clientWidth||(e.preventDefault(),e.currentTarget.scrollLeft+=e.deltaY)}function AM(e,t){let n=[t,...SM].filter((e,t,n)=>e&&n.indexOf(e)===t),r=e.toLowerCase(),i=n.find(t=>e.length>t.length&&r.endsWith(t.toLowerCase()));return i?e.slice(0,-i.length):e}function jM(e){let t=(0,$.c)(37),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({activateFromKeyboard:n,className:r,tabId:l,disabled:i,onKeyDown:a,ref:o,style:s,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u;t[9]!==i||t[10]!==l?(u={id:l,disabled:i},t[9]=i,t[10]=l,t[11]=u):u=t[11];let{attributes:d,listeners:f,rect:p,setNodeRef:m,transform:h,transition:g,isDragging:_}=Li(u),v=p.current?.width,y;t[12]!==_||t[13]!==s||t[14]!==v||t[15]!==h||t[16]!==g?(y=vM({activeWidth:v,isDragging:_,outerStyle:s,transform:h,transition:g}),t[12]=_,t[13]=s,t[14]=v,t[15]=h,t[16]=g,t[17]=y):y=t[17];let b=y,x;t[18]!==o||t[19]!==m?(x=function(e){m(e),typeof o==`function`?o(e):o&&`current`in o&&(o.current=e)},t[18]=o,t[19]=m,t[20]=x):x=t[20];let S=x,C=f?.onKeyDown,w;t[21]!==n||t[22]!==_||t[23]!==a||t[24]!==C?(w=function(e){a?.(e);let t=_M({event:e,hasKeyboardActivation:!!n,isDragging:_});if(t!==`ignore`){if(t===`activate-tab`&&n){e.preventDefault(),n();return}C?.(e)}},t[21]=n,t[22]=_,t[23]=a,t[24]=C,t[25]=w):w=t[25];let T=w,E;t[26]!==r||t[27]!==_?(E=hM({className:r,isDragging:_}),t[26]=r,t[27]=_,t[28]=E):E=t[28];let D;return t[29]!==d||t[30]!==S||t[31]!==T||t[32]!==f||t[33]!==c||t[34]!==b||t[35]!==E?(D=(0,Z.jsx)(`div`,{ref:S,"data-editor-tab-sortable":``,className:E,style:b,...c,...d,...f,onKeyDown:T}),t[29]=d,t[30]=S,t[31]=T,t[32]=f,t[33]=c,t[34]=b,t[35]=E,t[36]=D):D=t[36],D}function MM(e){let t=(0,$.c)(52),{children:n,closeTab:r,closeTabs:i,canPin:a,disabled:o,openTabs:c,pinTab:l,pinnedTabIds:u,tabId:d,unpinTab:f}=e,p=a===void 0?!0:a;if(o!==void 0&&o)return n;let m;t[0]!==p||t[1]!==u||t[2]!==d?(m=p&&u.includes(d),t[0]=p,t[1]=u,t[2]=d,t[3]=m):m=t[3];let h=m,g;if(t[4]!==c||t[5]!==u||t[6]!==d){let e;t[8]===d?e=t[9]:(e=e=>e!==d,t[8]=d,t[9]=e),g=qe(c.filter(e),u),t[4]=c,t[5]=u,t[6]=d,t[7]=g}else g=t[7];let _=g,v;t[10]!==c||t[11]!==u?(v=qe(c,u),t[10]=c,t[11]=u,t[12]=v):v=t[12];let y=v,b;t[13]===n?b=t[14]:(b=(0,Z.jsx)(nM,{asChild:!0,children:n}),t[13]=n,t[14]=b);let x;t[15]!==r||t[16]!==d?(x=()=>r(d),t[15]=r,t[16]=d,t[17]=x):x=t[17];let S;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(s,{id:`yz7wBu`}),t[18]=S):S=t[18];let C;t[19]!==h||t[20]!==x?(C=(0,Z.jsx)(aM,{disabled:h,onSelect:x,children:S}),t[19]=h,t[20]=x,t[21]=C):C=t[21];let w=_.length===0,T;t[22]!==i||t[23]!==_?(T=()=>{i(_)},t[22]=i,t[23]=_,t[24]=T):T=t[24];let E;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(s,{id:`omXJcU`}),t[25]=E):E=t[25];let D;t[26]!==w||t[27]!==T?(D=(0,Z.jsx)(aM,{disabled:w,onSelect:T,children:E}),t[26]=w,t[27]=T,t[28]=D):D=t[28];let O=y.length===0,k;t[29]!==y||t[30]!==i?(k=()=>{i(y)},t[29]=y,t[30]=i,t[31]=k):k=t[31];let A;t[32]===u.length?A=t[33]:(A=u.length?(0,Z.jsx)(s,{id:`U2Kx6T`}):(0,Z.jsx)(s,{id:`WyXG7w`}),t[32]=u.length,t[33]=A);let j;t[34]!==O||t[35]!==k||t[36]!==A?(j=(0,Z.jsx)(aM,{disabled:O,"data-testid":`editor-tab-context-close-all`,onSelect:k,children:A}),t[34]=O,t[35]=k,t[36]=A,t[37]=j):j=t[37];let M;t[38]!==p||t[39]!==h||t[40]!==l||t[41]!==d||t[42]!==f?(M=p&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(lM,{}),(0,Z.jsx)(aM,{"data-testid":`editor-tab-context-pin-toggle`,onSelect:()=>h?f(d):l(d),children:h?(0,Z.jsx)(s,{id:`SYfHmN`}):(0,Z.jsx)(s,{id:`3pU8e-`})})]}),t[38]=p,t[39]=h,t[40]=l,t[41]=d,t[42]=f,t[43]=M):M=t[43];let N;t[44]!==D||t[45]!==j||t[46]!==M||t[47]!==C?(N=(0,Z.jsxs)(iM,{className:`min-w-40`,children:[C,D,j,M]}),t[44]=D,t[45]=j,t[46]=M,t[47]=C,t[48]=N):N=t[48];let P;return t[49]!==N||t[50]!==b?(P=(0,Z.jsxs)(tM,{children:[b,N]}),t[49]=N,t[50]=b,t[51]=P):P=t[51],P}function NM(e){let t=(0,$.c)(26),{accessibleLabel:n,closeTab:r,isActive:a,isPinned:o,tabId:s,unpinTab:c}=e,{_:l}=i();if(o){let e;t[0]!==l||t[1]!==n?(e=l({id:`t18QYR`,values:{accessibleLabel:n}}),t[0]=l,t[1]=n,t[2]=e):e=t[2];let r;t[3]!==s||t[4]!==c?(r=e=>{e.stopPropagation(),c(s)},t[3]=s,t[4]=c,t[5]=r):r=t[5];let i;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(Pl,{"aria-hidden":`true`}),t[6]=i):i=t[6];let a;return t[7]!==e||t[8]!==r?(a=(0,Z.jsx)(si,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":e,"data-testid":`editor-tab-unpin-button`,className:`mr-1.5 text-primary! hover:bg-primary/10!`,onClick:r,children:i}),t[7]=e,t[8]=r,t[9]=a):a=t[9],a}let u;t[10]!==l||t[11]!==n?(u=l({id:`JLzQi_`,values:{accessibleLabel:n}}),t[10]=l,t[11]=n,t[12]=u):u=t[12];let d;t[13]===a?d=t[14]:(d=pM(a),t[13]=a,t[14]=d);let f;t[15]===a?f=t[16]:(f=mM(a),t[15]=a,t[16]=f);let p;t[17]!==r||t[18]!==s?(p=e=>{e.stopPropagation(),r(s)},t[17]=r,t[18]=s,t[19]=p):p=t[19];let m;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(ps,{"aria-hidden":`true`}),t[20]=m):m=t[20];let h;return t[21]!==u||t[22]!==d||t[23]!==f||t[24]!==p?(h=(0,Z.jsx)(si,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":u,"data-testid":`editor-tab-close-button`,className:d,tabIndex:f,onClick:p,children:m}),t[21]=u,t[22]=d,t[23]=f,t[24]=p,t[25]=h):h=t[25],h}function PM(e){let t=(0,$.c)(1),{docName:n}=e;if(jC(n)!==`conflict`)return null;let r;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(ds,{"aria-label":`Conflict`,"data-testid":`editor-tab-conflict-badge`,className:`mr-1 size-3.5 shrink-0 text-amber-500`}),t[0]=r):r=t[0],r}function FM(){let e=(0,$.c)(80),{activeDocName:t,activeTabId:n,activeNewTabId:r,activeTarget:a,activateTab:o,activateNewTab:c,closeAndClearForRename:l,closeNewTab:u,closeTab:d,closeTabs:f,getPoolActiveDocName:p,poolHas:m,isNewTabActive:h,newTabIds:g,openNewTab:_,openTabs:v,pinTab:y,pinnedTabIds:b,remapTabsForRename:x,reorderTabs:S,unpinTab:C,visibleTabIds:w}=pt(),{_:T}=i(),{pageMeta:E}=es(),D=(0,Q.useRef)(null),[O,k]=(0,Q.useState)(null),[j,N]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(``),[I,L]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(!1),B=(0,Q.useRef)(null),V=(0,Q.useRef)(!1),H=(0,Q.useRef)(!1),U=(0,Q.useRef)(null),W=(0,Q.useRef)(t),G;e[0]!==n||e[1]!==t||e[2]!==a?(G=n??(a?Ye(a):t?He(t):null),e[0]=n,e[1]=t,e[2]=a,e[3]=G):G=e[3];let K=G,q;e[4]!==r||e[5]!==K||e[6]!==h||e[7]!==g||e[8]!==v?(q=h?`${r??`__new-tab__`}\u0000${v.join(`\0`)}\u0000${g.join(`\0`)}`:K?`${K}\u0000${v.join(`\0`)}`:``,e[4]=r,e[5]=K,e[6]=h,e[7]=g,e[8]=v,e[9]=q):q=e[9];let J=q,Y,ee;e[10]===t?(Y=e[11],ee=e[12]):(Y=()=>{W.current=t},ee=[t],e[10]=t,e[11]=Y,e[12]=ee),(0,Q.useEffect)(Y,ee);let te,ne;e[13]===J?(te=e[14],ne=e[15]):(te=()=>{J&&(D.current?.querySelector(`[data-active-tab="true"]`))?.scrollIntoView({block:`nearest`,inline:`nearest`})},ne=[J],e[13]=J,e[14]=te,e[15]=ne),(0,Q.useEffect)(te,ne);let re,ie;e[16]===j?(re=e[17],ie=e[18]):(re=()=>{j&&(B.current?.focus(),B.current?.select())},ie=[j],e[16]=j,e[17]=re,e[18]=ie),(0,Q.useEffect)(re,ie);let ae,oe;e[19]!==v||e[20]!==j?(ae=()=>{!j||v.includes(j.tabId)||(H.current=!0,U.current=null,N(null),F(``),L(null),z(!1))},oe=[v,j],e[19]=v,e[20]=j,e[21]=ae,e[22]=oe):(ae=e[21],oe=e[22]),(0,Q.useEffect)(ae,oe);let se=function(e,t){let n=t.split(`/`);H.current=!1,U.current=null,N({docName:t,tabId:e}),F(n[n.length-1]),L(null)},ce=function(){H.current=!0,U.current=null,N(null),F(``),L(null),z(!1)},le=async function(){if(H.current){H.current=!1;return}if(V.current)return;let e=j?.docName;if(!e){ce();return}let t=Bj(`file`,AM(P,E.get(e)?.docExt??`.md`)),n=e.split(`/`),r=n[n.length-1];if(t===r){ce();return}if(t===U.current){B.current?.focus();return}if(!Vj(t)){L(T({id:`P8yDjG`})),B.current?.focus();return}let i=Hj({kind:`file`,path:e,name:r},t);V.current=!0,z(!0),L(null);try{let n=await fetch(`/api/rename-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:`file`,fromPath:e,toPath:i})});if(H.current){z(!1),V.current=!1;return}let r=await ve(n,`Server error (HTTP ${n.status})`);if(!r.ok){L(r.title),z(!1),V.current=!1,U.current=t,B.current?.focus();return}let a=A(Xr,r.body,`rename-path:tab`,{renamed:[],renamedAssets:[]}).renamed,o=W.current,s=qj(o,a);Bt(a);let c=!0;try{let e=Jj(a,p(),m);await Promise.all(e.map(e=>l(e))),x(a),is([`files`,`backlinks`,`graph`])}catch(n){let r=n;c=!1,console.warn(`[EditorTabs] post-rename reconciliation failed`,{err:r,docName:e,newDocName:i,normalized:t}),X.error(T({id:`MUBR8r`}))}H.current=!0,N(null),F(``),L(null),z(!1),V.current=!1,U.current=null,c&&s&&s!==o&&OM(s)}catch(n){console.warn(`[EditorTabs] rename failed`,{err:n,docName:e,newDocName:i,normalized:t}),L(T({id:`HIb0vl`})),z(!1),V.current=!1,U.current=t,B.current?.focus()}},ue=typeof window<`u`&&window.okDesktop!=null,de;e[23]===g?de=e[24]:(de=new Set(g),e[23]=g,e[24]=de);let fe=de,pe;e[25]===O?pe=e[26]:(pe=bM(O),e[25]=O,e[26]=pe);let me;e[27]===pe?me=e[28]:(me=[pe],e[27]=pe,e[28]=me);let he=me,ge;e[29]!==u||e[30]!==f||e[31]!==fe?(ge=function(e){let t=[],n=[];for(let r of e)fe.has(r)?n.push(r):t.push(r);t.length>0&&f(t);for(let e of n)u(e)},e[29]=u,e[30]=f,e[31]=fe,e[32]=ge):ge=e[32];let _e=ge,ye;e[33]===Symbol.for(`react.memo_cache_sentinel`)?(ye={activationConstraint:{distance:8}},e[33]=ye):ye=e[33];let be;e[34]===Symbol.for(`react.memo_cache_sentinel`)?(be={coordinateGetter:ha,keyboardCodes:fM},e[34]=be):be=e[34];let xe=Ci(ra(_a,ye),ra(ya,be)),Se;e[35]===Symbol.for(`react.memo_cache_sentinel`)?(Se=function(){k(yM(D.current))},e[35]=Se):Se=e[35];let Ce=Se,we;e[36]===Symbol.for(`react.memo_cache_sentinel`)?(we=function(){k(null)},e[36]=we):we=e[36];let Te=we,Ee;e[37]!==Te||e[38]!==S||e[39]!==w?(Ee=function(e){Te();let t=String(e.active.id),n=e.over?String(e.over.id):null;if(!n||t===n)return;let r=w.indexOf(t),i=w.indexOf(n);r<0||i<0||r===i||S(zi([...w],r,i),t)},e[37]=Te,e[38]=S,e[39]=w,e[40]=Ee):Ee=e[40];let De=Ee,Oe=ue?``:void 0,ke;e[41]===Symbol.for(`react.memo_cache_sentinel`)?(ke=ai(`pl-2 flex h-12 min-w-0 touch-manipulation flex-1 items-end overflow-x-auto overflow-y-hidden overscroll-x-contain scroll-fade-mask-x [scrollbar-width:none]`,ue&&`[-webkit-app-region:drag]`),e[41]=ke):ke=e[41];let Ae=kM,je;e[42]===Symbol.for(`react.memo_cache_sentinel`)?(je=ai(`flex items-end gap-1`,ue&&`[-webkit-app-region:no-drag]`),e[42]=je):je=e[42];let Ne=Ya,Pe=xM,Fe;e[43]===Symbol.for(`react.memo_cache_sentinel`)?(Fe={container:typeof document<`u`?document.body:void 0},e[43]=Fe):Fe=e[43];let Ie=pa,Le;e[44]===w?Le=e[45]:(Le=[...w],e[44]=w,e[45]=Le);let Re=da,ze=w.map(e=>{if(fe.has(e)){let t=e===r;return(0,Z.jsx)(MM,{tabId:e,canPin:!1,openTabs:w,closeTab:u,closeTabs:_e,pinTab:y,pinnedTabIds:b,unpinTab:C,children:(0,Z.jsxs)(jM,{tabId:e,activateFromKeyboard:()=>c(e),"aria-current":t?`page`:void 0,"data-active-tab":t?`true`:void 0,className:ai(CM,t?wM:TM),onAuxClick:t=>{t.button===1&&(t.preventDefault(),u(e))},onClick:t=>{t.target===t.currentTarget&&c(e)},children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":T({id:`zLak8b`}),"data-testid":`editor-new-tab-placeholder-button`,className:EM,onClick:()=>c(e),tabIndex:-1,children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:(0,Z.jsx)(s,{id:`3YvS-c`})})}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":T({id:`xCdTnb`}),"data-testid":`editor-new-tab-placeholder-close`,className:pM(t),tabIndex:mM(t),onClick:t=>{t.stopPropagation(),u(e)},children:(0,Z.jsx)(ps,{"aria-hidden":`true`,className:`size-3.5`})})]})},e)}let t=ft(e),n=e===K,i=b.includes(e);if(t.kind===`folder`){let{baseName:r,label:a,prefix:s}=Me(t.folderPath,`/`),c=`${s}${a}`;return(0,Z.jsx)(MM,{tabId:e,openTabs:w,closeTab:d,closeTabs:_e,pinTab:y,pinnedTabIds:b,unpinTab:C,children:(0,Z.jsxs)(jM,{tabId:e,activateFromKeyboard:()=>o(e),"aria-current":n?`page`:void 0,"data-active-tab":n?`true`:void 0,className:ai(CM,n?wM:TM),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!i&&d(e))},onClick:t=>{t.target===t.currentTarget&&o(e)},children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":c,title:c,className:EM,onClick:()=>{o(e)},tabIndex:-1,children:[s&&(0,Z.jsx)(`span`,{className:ai(`min-w-0 flex-1 truncate`,n&&`text-muted-foreground`),children:s}),(0,Z.jsxs)(`span`,{className:ai(`flex min-w-0 items-center`,s?`max-w-[70%] shrink-0`:`flex-1`),children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:r}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:`/`})]})]}),(0,Z.jsx)(NM,{accessibleLabel:c,closeTab:d,isActive:n,isPinned:i,tabId:e,unpinTab:C})]})},e)}if(t.kind===`asset`){let{baseName:r,label:a,prefix:s}=Me(t.assetPath,``),c=`${s}${a}`;return(0,Z.jsx)(MM,{tabId:e,openTabs:w,closeTab:d,closeTabs:_e,pinTab:y,pinnedTabIds:b,unpinTab:C,children:(0,Z.jsxs)(jM,{tabId:e,activateFromKeyboard:()=>o(e),"aria-current":n?`page`:void 0,"data-active-tab":n?`true`:void 0,className:ai(CM,n?wM:TM),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!i&&d(e))},onClick:t=>{t.target===t.currentTarget&&o(e)},children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":c,className:EM,onClick:()=>{o(e)},tabIndex:-1,children:[s?(0,Z.jsx)(`span`,{className:ai(`min-w-0 flex-1 truncate text-muted-foreground/60`,n&&`text-muted-foreground`),children:s}):null,(0,Z.jsx)(`span`,{className:ai(`min-w-0 truncate`,s?`max-w-[70%] shrink-0`:`flex-1`),children:r})]}),(0,Z.jsx)(NM,{accessibleLabel:c,closeTab:d,isActive:n,isPinned:i,tabId:e,unpinTab:C})]})},e)}let a=t.docName,l=E.get(a)?.docExt??`.md`,{baseName:f,extension:p,label:m,prefix:h}=Me(a,l),g=`${h}${m}`,_=l===`.md`||l===`.mdx`,v=j?.tabId===e,x=`editor-tab-rename-error-${DM(a)}`;return(0,Z.jsx)(MM,{disabled:v,tabId:e,openTabs:w,closeTab:d,closeTabs:_e,pinTab:y,pinnedTabIds:b,unpinTab:C,children:(0,Z.jsx)(jM,{tabId:e,activateFromKeyboard:()=>o(e),disabled:v,"aria-current":n?`page`:void 0,"data-active-tab":n?`true`:void 0,className:ai(CM,n?wM:TM,v&&I&&`border-destructive`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!i&&d(e))},onClick:t=>{t.target===t.currentTarget&&o(e)},children:v?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(cC,{className:`h-full min-w-0 flex-1 rounded-none border-0 bg-transparent dark:bg-transparent`,children:[(0,Z.jsx)(pC,{ref:B,value:P,disabled:R,"aria-label":T({id:`Dw1T_W`,values:{label:m}}),"data-testid":`editor-tab-rename-input`,"aria-invalid":I?!0:void 0,"aria-describedby":I?x:void 0,"aria-busy":R||void 0,title:I??a,className:`h-full min-w-0 px-2 py-0 font-medium text-foreground text-xs selection:bg-primary selection:text-primary-foreground`,onChange:e=>{F(AM(e.target.value,l)),L(null),U.current=null},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),le()):e.key===`Escape`&&(e.preventDefault(),ce())},onBlur:le}),(0,Z.jsx)(uC,{align:`inline-end`,"aria-hidden":`true`,className:`pr-2 text-xs`,children:(0,Z.jsx)(fC,{className:`text-muted-foreground/60 text-xs`,children:l})})]}),I?(0,Z.jsx)(`span`,{id:x,role:`alert`,className:`sr-only`,children:I}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":g,title:g,className:EM,onClick:()=>{o(e)},onDoubleClick:t=>{t.preventDefault(),t.stopPropagation(),se(e,a)},tabIndex:-1,children:[(0,Z.jsx)(PM,{docName:a}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:f}),!_&&(0,Z.jsx)(`span`,{className:`shrink-0`,children:p})]})]}),(0,Z.jsx)(NM,{accessibleLabel:g,closeTab:d,isActive:n,isPinned:i,tabId:e,unpinTab:C})]})})},e)}),Be;e[46]!==Ie||e[47]!==Le||e[48]!==Re||e[49]!==ze?(Be=(0,Z.jsx)(Ie,{items:Le,strategy:Re,children:ze}),e[46]=Ie,e[47]=Le,e[48]=Re,e[49]=ze,e[50]=Be):Be=e[50];let Ve;e[51]!==Ne||e[52]!==Te||e[53]!==De||e[54]!==Ce||e[55]!==xe||e[56]!==!1||e[57]!==Pe||e[58]!==Fe||e[59]!==Be||e[60]!==he?(Ve=(0,Z.jsx)(Ne,{sensors:xe,autoScroll:!1,collisionDetection:Pe,modifiers:he,onDragStart:Ce,onDragEnd:De,onDragCancel:Te,accessibility:Fe,children:Be}),e[51]=Ne,e[52]=Te,e[53]=De,e[54]=Ce,e[55]=xe,e[56]=!1,e[57]=Pe,e[58]=Fe,e[59]=Be,e[60]=he,e[61]=Ve):Ve=e[61];let Ue;e[62]===T?Ue=e[63]:(Ue=T({id:`3YvS-c`}),e[62]=T,e[63]=Ue);let We;e[64]===Symbol.for(`react.memo_cache_sentinel`)?(We=(0,Z.jsx)(M,{"aria-hidden":`true`}),e[64]=We):We=e[64];let Ge;e[65]!==_||e[66]!==Ue?(Ge=(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(si,{type:`button`,size:`icon-xs`,variant:`ghost`,"aria-label":Ue,"data-testid":`editor-new-tab-button`,className:`first:mb-3 mb-1.5`,onClick:_,children:We})}),e[65]=_,e[66]=Ue,e[67]=Ge):Ge=e[67];let Ke;e[68]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=(0,Z.jsx)(Ds,{children:(0,Z.jsx)(s,{id:`3YvS-c`})}),e[68]=Ke):Ke=e[68];let qe;e[69]===Ge?qe=e[70]:(qe=(0,Z.jsxs)(As,{children:[Ge,Ke]}),e[69]=Ge,e[70]=qe);let Je;e[71]!==je||e[72]!==Ve||e[73]!==qe?(Je=(0,Z.jsxs)(`div`,{className:je,children:[Ve,qe]}),e[71]=je,e[72]=Ve,e[73]=qe,e[74]=Je):Je=e[74];let Xe;return e[75]!==Oe||e[76]!==ke||e[77]!==Ae||e[78]!==Je?(Xe=(0,Z.jsx)(`div`,{ref:D,"data-electron-drag":Oe,className:ke,onWheel:Ae,children:Je}),e[75]=Oe,e[76]=ke,e[77]=Ae,e[78]=Je,e[79]=Xe):Xe=e[79],Xe}function IM(e){let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`Discord`}),r=(0,Z.jsx)(`path`,{d:`M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9554 2.4189-2.1568 2.4189Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,Z.jsxs)(`svg`,{role:`img`,fill:`currentColor`,height:24,width:24,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}function LM(e){let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`X (Twitter)`}),r=(0,Z.jsx)(`path`,{d:`M18.901 1.153h3.68l-8.04 9.19L24 22.846h-7.406l-5.8-7.584-6.638 7.584H.474l8.6-9.83L0 1.154h7.594l5.243 6.932ZM17.61 20.644h2.039L6.486 3.24H4.298Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,Z.jsxs)(`svg`,{role:`img`,fill:`currentColor`,height:24,width:24,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}var RM=[{label:{id:`TvY_XA`},href:`https://openknowledge.ai/docs`,icon:Ke},{label:`GitHub`,href:`https://github.com/inkeep/open-knowledge`,icon:Gd},{label:{id:`On0aF2`},href:`https://openknowledge.ai/`,icon:Fo},{label:`Discord`,href:`https://discord.com/invite/YujKpFN49`,icon:IM},{label:`Twitter`,href:`https://x.com/inkeep`,icon:LM}],zM=()=>{let e=(0,$.c)(16),{_:t}=i(),[n,r]=(0,Q.useState)(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(kt,{className:`size-4`}),e[0]=a):a=e[0];let o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsxs)(si,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[a,(0,Z.jsx)(`span`,{className:`sr-only`,children:(0,Z.jsx)(s,{id:`s-MGs7`})})]})})}),e[1]=o):o=e[1];let c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsxs)(As,{children:[o,(0,Z.jsx)(Ds,{children:(0,Z.jsx)(s,{id:`s-MGs7`})})]}),e[2]=c):c=e[2];let l;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs mb-1`,children:(0,Z.jsx)(s,{id:`s-MGs7`})}),e[3]=l):l=e[3];let u;e[4]===t?u=e[5]:(u=t({id:`s-MGs7`}),e[4]=t,e[5]=u);let d;e[6]===t?d=e[7]:(d=RM.map(e=>{let{label:n,href:r,icon:i}=e;return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`a`,{href:r,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>va(e,r),onAuxClick:e=>va(e,r),className:`flex items-center gap-2.5 rounded-md px-2 py-1.5 text-sm text-muted-foreground transition-colors hover:bg-azure-900/5 dark:hover:bg-white/20 hover:text-primary`,children:[(0,Z.jsx)(i,{"aria-hidden":`true`,className:`size-4 shrink-0`}),typeof n==`string`?n:t(n)]})},r)}),e[6]=t,e[7]=d);let f;e[8]===d?f=e[9]:(f=(0,Z.jsx)(`ul`,{className:`space-y-0.5`,children:d}),e[8]=d,e[9]=f);let p;e[10]!==u||e[11]!==f?(p=(0,Z.jsxs)(b,{align:`end`,className:`w-64 p-3`,children:[l,(0,Z.jsx)(`nav`,{"aria-label":u,children:f})]}),e[10]=u,e[11]=f,e[12]=p):p=e[12];let m;return e[13]!==n||e[14]!==p?(m=(0,Z.jsxs)(pe,{open:n,onOpenChange:r,children:[c,p]}),e[13]=n,e[14]=p,e[15]=m):m=e[15],m},BM=(0,Q.createContext)(null);function VM(e){let t=(0,$.c)(3),{value:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,Z.jsx)(BM,{value:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function HM(){return(0,Q.use)(BM)}function UM(e){let t=(0,$.c)(19),{installStates:n,terminalLaunch:r,disabled:a,onPick:o,onLaunchTerminal:c}=e,{_:l}=i(),[u,d]=(0,Q.useState)(``),f;if(t[0]!==l||t[1]!==a||t[2]!==n||t[3]!==u||t[4]!==c||t[5]!==o||t[6]!==r){let e;t[8]===n?e=t[9]:(e=e=>n[e.id]?.installed===!0,t[8]=n,t[9]=e);let i=Fh.filter(e),p=Fh.some(e=>n[e.id]?.installed==null),m=i.length>0||r!==null,h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(h=e=>d(e.target.value),t[10]=h):h=t[10];let g;t[11]===l?g=t[12]:(g=l({id:`Rah7yq`}),t[11]=l,t[12]=g);let _;t[13]===l?_=t[14]:(_=l({id:`ZBt4rI`}),t[13]=l,t[14]=_);let v;t[15]!==u||t[16]!==g||t[17]!==_?(v=(0,Z.jsx)(ko,{value:u,onChange:h,placeholder:g,"aria-label":_,"data-testid":`open-in-agent-instruction`}),t[15]=u,t[16]=g,t[17]=_,t[18]=v):v=t[18],f=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[v,m?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`text-muted-foreground text-xs`,"data-testid":`open-in-agent-send-label`,children:(0,Z.jsx)(s,{id:`C37Zkt`})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[i.map(e=>{let{displayName:t}=e;return(0,Z.jsxs)(si,{type:`button`,variant:`ghost`,className:`w-full justify-start gap-2`,disabled:a,"data-testid":`open-in-agent-item-${e.id}`,"aria-label":l({id:`WqLq6M`,values:{displayName:t}}),onClick:()=>o(e,u),children:[(0,Z.jsx)(ox,{id:e.id,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{children:t})]},e.id)}),r===null?null:(0,Z.jsxs)(Z.Fragment,{children:[i.length>0?(0,Z.jsx)(Pi,{className:`my-1`}):null,(0,Z.jsxs)(si,{type:`button`,variant:`ghost`,className:`w-full justify-start gap-2`,disabled:a,"data-testid":`open-in-agent-terminal`,"aria-label":l({id:`AcK_r0`}),onClick:()=>c(u),children:[(0,Z.jsx)(Kl,{className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{children:(0,Z.jsx)(s,{id:`AcK_r0`})})]})]})]})]}):(0,Z.jsx)(`p`,{className:`text-muted-foreground text-sm`,"data-testid":`open-in-agent-empty`,"aria-live":`polite`,children:p?(0,Z.jsx)(s,{id:`EcR0fl`}):(0,Z.jsx)(s,{id:`l6OXqI`})})]}),t[0]=l,t[1]=a,t[2]=n,t[3]=u,t[4]=c,t[5]=o,t[6]=r,t[7]=f}else f=t[7];return f}function WM(e){let t=(0,$.c)(44),{input:n,open:r,onOpenChange:a}=e,{_:o}=i(),{states:c,refresh:l}=Kg(),{dispatch:u}=Fg(),d=HM(),[f,p]=(0,Q.useState)(!1),m=(0,Q.useRef)(!1),h=Mh(),g=r??f,_;t[0]===l?_=t[1]:(_=()=>{l()},t[0]=l,t[1]=_);let v=(0,Q.useEffectEvent)(_),y;t[2]!==g||t[3]!==v?(y=()=>{g&&v()},t[2]=g,t[3]=v,t[4]=y):y=t[4];let x;if(t[5]===g?x=t[6]:(x=[g],t[5]=g,t[6]=x),(0,Q.useEffect)(y,x),h)return null;let S=typeof window<`u`&&window.okDesktop!=null,C;t[7]!==a||t[8]!==r?(C=e=>{r===void 0&&p(e),a?.(e)},t[7]=a,t[8]=r,t[9]=C):C=t[9];let w=C,T=n===null,E;t[10]===n?E=t[11]:(E=e=>{if(n===null)return null;let t=e.trim();return t?{...n,instruction:t}:n},t[10]=n,t[11]=E);let D=E,O;t[12]!==u||t[13]!==w||t[14]!==D?(O=(e,t)=>{let n=D(t);n!==null&&(u(e.id,n),w(!1))},t[12]=u,t[13]=w,t[14]=D,t[15]=O):O=t[15];let k=O,A;t[16]!==w||t[17]!==D||t[18]!==d?(A=e=>{let t=D(e);t===null||d===null||(d.launchInTerminal(t),w(!1))},t[16]=w,t[17]=D,t[18]=d,t[19]=A):A=t[19];let j=A,M;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(M=S?()=>{m.current=!0}:void 0,t[20]=M):M=t[20];let N;t[21]===w?N=t[22]:(N=S?()=>{if(m.current){m.current=!1;return}w(!0)}:void 0,t[21]=w,t[22]=N);let P,F;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(vi,{className:`size-3.5`,"aria-hidden":`true`}),F=(0,Z.jsx)(s,{id:`O7_W_a`}),t[23]=P,t[24]=F):(P=t[23],F=t[24]);let I;t[25]!==N||t[26]!==T?(I=(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsxs)(si,{variant:`ghost`,size:`sm`,disabled:T,className:`gap-1.5 text-muted-foreground px-1.5`,"data-testid":`open-in-agent-trigger`,onPointerDown:M,onClick:N,children:[P,F]})}),t[25]=N,t[26]=T,t[27]=I):I=t[27];let L;t[28]===o?L=t[29]:(L=o({id:`O7_W_a`}),t[28]=o,t[29]=L);let R=n===null,z;t[30]!==j||t[31]!==k||t[32]!==c||t[33]!==R||t[34]!==d?(z=(0,Z.jsx)(UM,{installStates:c,terminalLaunch:d,disabled:R,onPick:k,onLaunchTerminal:j}),t[30]=j,t[31]=k,t[32]=c,t[33]=R,t[34]=d,t[35]=z):z=t[35];let B;t[36]!==L||t[37]!==z?(B=(0,Z.jsx)(b,{align:`end`,"aria-label":L,"data-testid":`open-in-agent-menu`,children:z}),t[36]=L,t[37]=z,t[38]=B):B=t[38];let V;return t[39]!==w||t[40]!==g||t[41]!==I||t[42]!==B?(V=(0,Z.jsxs)(pe,{open:g,onOpenChange:w,children:[I,B]}),t[39]=w,t[40]=g,t[41]=I,t[42]=B,t[43]=V):V=t[43],V}var GM=50,KM=()=>{let e=(0,$.c)(8),t=(0,Q.useRef)(null),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>{t.current===null&&(t.current=setTimeout(()=>{t.current=null,qS.preload()},GM))},e[0]=n):n=e[0];let r=n,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{t.current!==null&&(clearTimeout(t.current),t.current=null)},e[1]=i):i=e[1];let a=i,o,c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>()=>{t.current!==null&&clearTimeout(t.current)},c=[],e[2]=o,e[3]=c):(o=e[2],c=e[3]),(0,Q.useEffect)(o,c);let l,u;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{a(),window.location.hash!==`#settings`&&(window.location.hash=Vh)},u=(0,Z.jsx)(Bl,{className:`size-4`}),e[4]=l,e[5]=u):(l=e[4],u=e[5]);let d;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsxs)(si,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,"data-testid":`header-settings-button`,onMouseEnter:r,onMouseLeave:a,onFocus:r,onBlur:a,onClick:l,children:[u,(0,Z.jsx)(`span`,{className:`sr-only`,children:(0,Z.jsx)(s,{id:`Tz0i8g`})})]})}),e[6]=d):d=e[6];let f;return e[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsxs)(As,{children:[d,(0,Z.jsx)(Ds,{children:(0,Z.jsx)(s,{id:`Tz0i8g`})})]}),e[7]=f):f=e[7],f};function qM(e){let t=(0,$.c)(30),{input:n,onClickWhenNoRemote:r}=e,{_:a}=i(),{status:o}=oo(),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null),f=(0,Q.useRef)(null),p,m;t[0]===u?(p=t[1],m=t[2]):(p=()=>{!u||!f.current||(f.current.focus(),f.current.select())},m=[u],t[0]=u,t[1]=p,t[2]=m),(0,Q.useEffect)(p,m);let h=o?.hasRemote===!0,g=n===null,_;t[3]!==a||t[4]!==c||t[5]!==h||t[6]!==n||t[7]!==r?(_=async function(){if(!c&&n!==null){l(!0),d(null);try{let e=await sa({...n,hasRemote:h,onClickWhenNoRemote:r},{clipboardWrite:ka,toastSuccess:$M,toastError:QM,logEvent:ZM});e.kind===`clipboard-failed`&&d(e.shareUrl)}catch{X.error(a({id:`u3YnKw`}))}l(!1)}},t[3]=a,t[4]=c,t[5]=h,t[6]=n,t[7]=r,t[8]=_):_=t[8];let v=_,y=u!==null,x;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>{e||d(null)},t[9]=x):x=t[9];let C;t[10]!==a||t[11]!==n?.kind?(C=n?.kind===`folder`?a({id:`WR0y2O`}):a({id:`F4IYWe`}),t[10]=a,t[11]=n?.kind,t[12]=C):C=t[12];let w=c||g,T,E;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(Vl,{className:`size-3.5`,"aria-hidden":!0}),E=(0,Z.jsx)(s,{id:`Z8lGw6`}),t[13]=T,t[14]=E):(T=t[13],E=t[14]);let D;t[15]!==v||t[16]!==C||t[17]!==w?(D=(0,Z.jsx)(S,{asChild:!0,children:(0,Z.jsxs)(si,{variant:`ghost`,size:`sm`,"aria-label":C,onClick:v,disabled:w,className:`gap-1.5 text-muted-foreground px-1.5`,"data-testid":`share-button`,children:[T,E]})}),t[15]=v,t[16]=C,t[17]=w,t[18]=D):D=t[18];let O;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:(0,Z.jsx)(s,{id:`I1m158`})}),t[19]=O):O=t[19];let k;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,Z.jsx)(s,{id:`ndeI89`})}),t[20]=k):k=t[20];let A=u??``,j;t[21]===a?j=t[22]:(j=a({id:`5-FeN2`}),t[21]=a,t[22]=j);let M;t[23]!==A||t[24]!==j?(M=(0,Z.jsxs)(b,{className:`flex w-80 flex-col gap-2`,"data-testid":`share-button-fallback-popover`,children:[O,k,(0,Z.jsx)(ko,{ref:f,readOnly:!0,value:A,onFocus:XM,onClick:YM,onContextMenu:JM,className:`font-mono text-xs`,"data-testid":`share-button-fallback-url`,"aria-label":j})]}),t[23]=A,t[24]=j,t[25]=M):M=t[25];let N;return t[26]!==D||t[27]!==M||t[28]!==y?(N=(0,Z.jsxs)(pe,{open:y,onOpenChange:x,children:[D,M]}),t[26]=D,t[27]=M,t[28]=y,t[29]=N):N=t[29],N}function JM(e){return e.currentTarget.select()}function YM(e){return e.currentTarget.select()}function XM(e){return e.currentTarget.select()}function ZM(e){return console.log(e)}function QM(e){e!==`Link ready but could not copy to clipboard.`&&X.error(e)}function $M(e){return X.success(e)}function eN(e){let t=(0,$.c)(45),{onSignIn:n,onSetIdentity:r,onOpenSearch:a,openInAgentMenuOpen:o,openInAgentMenuInput:c,onOpenInAgentMenuOpenChange:l}=e,{_:u}=i(),{activeDocName:d,activeTarget:f}=pt(),{state:p,isDraggingRail:m}=Ok(),h=Bh(),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=Ks(`toggle-files-sidebar`),t[0]=g):g=t[0];let _=g,v=Ks(`command-palette`),y=po(),[b,x]=(0,Q.useState)(!1),S;bb0:{if(f===null){let e;t[1]===y?e=t[2]:(e=yg({workspace:y}),t[1]=y,t[2]=e),S=e;break bb0}if(f.kind===`folder`){if(!y){S=null;break bb0}let e;t[3]!==f.folderPath||t[4]!==y?(e=Sg({folderRelativePath:f.folderPath,workspace:y}),t[3]=f.folderPath,t[4]=y,t[5]=e):e=t[5],S=e;break bb0}let e;t[6]!==d||t[7]!==y?(e=vg({docName:d,workspace:y}),t[6]=d,t[7]=y,t[8]=e):e=t[8],S=e}let C=c??S,w;bb1:{if(f?.kind===`folder`){let e;t[9]===f.folderPath?e=t[10]:(e=lo(f.folderPath),t[9]=f.folderPath,t[10]=e),w=e;break bb1}if(d){let e;t[11]===d?e=t[12]:(e=Ea(d),t[11]=d,t[12]=e),w=e;break bb1}w=null}let T=w,E=typeof window<`u`&&window.okDesktop!=null,D=p===`collapsed`,O=E?``:void 0,k=E&&D&&`pl-[var(--ok-titlebar-reserve-left,1rem)]`,A=E&&!m&&`motion-safe:transition-[padding] motion-safe:duration-200 motion-safe:ease-linear`,j;t[13]!==k||t[14]!==A?(j=ai(`flex h-12 shrink-0 items-center bg-muted/35 shadow-[inset_0_-1px_0_var(--border)]`,E&&`[-webkit-app-region:drag]`,k,A),t[13]=k,t[14]=A,t[15]=j):j=t[15];let M=!h&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(As,{children:[(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(Nk,{className:ai(`-ml-1 shrink-0 text-muted-foreground`,E&&`[-webkit-app-region:no-drag]`)})}),(0,Z.jsx)(Ds,{children:p===`expanded`?(0,Z.jsx)(s,{id:`ZxXhLY`,values:{sidebarShortcut:_}}):(0,Z.jsx)(s,{id:`Zz25kq`,values:{sidebarShortcut:_}})})]}),D&&a&&(0,Z.jsxs)(As,{children:[(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(si,{variant:`ghost`,size:`icon-sm`,onClick:a,"aria-label":u({id:`IN4UX8`,values:{searchShortcut:v}}),"data-telemetry-event":`ok.editor_header.search.click`,className:ai(`shrink-0 text-muted-foreground`,E&&`[-webkit-app-region:no-drag]`),children:(0,Z.jsx)(te,{"aria-hidden":`true`})})}),(0,Z.jsx)(Ds,{children:(0,Z.jsx)(s,{id:`IN4UX8`,values:{searchShortcut:v}})})]}),(0,Z.jsx)(Pi,{orientation:`vertical`,className:`mr-1 h-4 shrink-0 data-vertical:self-center`}),(0,Z.jsx)(FM,{})]}),N;t[16]===M?N=t[17]:(N=(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 px-3`,children:M}),t[16]=M,t[17]=N);let P;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(P=ai(`flex shrink-0 items-center justify-end gap-2 px-3`,E&&`[&>*]:[-webkit-app-region:no-drag]`),t[18]=P):P=t[18];let F;t[19]!==C||t[20]!==l||t[21]!==o||t[22]!==b||t[23]!==x||t[24]!==T||t[25]!==h?(F=!h&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(WM,{input:C,open:o,onOpenChange:l}),(0,Z.jsx)(qM,{input:T,onClickWhenNoRemote:()=>x(!0)}),(0,Z.jsx)(fo,{open:b,onOpenChange:x})]}),t[19]=C,t[20]=l,t[21]=o,t[22]=b,t[23]=x,t[24]=T,t[25]=h,t[26]=F):F=t[26];let I;t[27]!==r||t[28]!==n?(I=(0,Z.jsx)(Va,{onSignIn:n,onSetIdentity:r}),t[27]=r,t[28]=n,t[29]=I):I=t[29];let L,R,z;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsx)(aj,{}),R=(0,Z.jsx)(Pi,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),z=(0,Z.jsx)(hd,{}),t[30]=L,t[31]=R,t[32]=z):(L=t[30],R=t[31],z=t[32]);let B;t[33]===h?B=t[34]:(B=!h&&(0,Z.jsx)(KM,{}),t[33]=h,t[34]=B);let V;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsx)(zM,{}),t[35]=V):V=t[35];let H;t[36]!==F||t[37]!==I||t[38]!==B?(H=(0,Z.jsxs)(`div`,{className:P,children:[F,I,L,R,z,B,V]}),t[36]=F,t[37]=I,t[38]=B,t[39]=H):H=t[39];let U;return t[40]!==N||t[41]!==H||t[42]!==O||t[43]!==j?(U=(0,Z.jsxs)(`header`,{"data-electron-drag":O,className:j,children:[N,H]}),t[40]=N,t[41]=H,t[42]=O,t[43]=j,t[44]=U):U=t[44],U}var tN=`open-knowledge:terminal-launch`;function nN(e,t=typeof window>`u`?new EventTarget:window){t.dispatchEvent(new CustomEvent(tN,{detail:{prompt:e}}))}function rN(e,t=typeof window>`u`?new EventTarget:window){let n=t=>{let n=t instanceof CustomEvent?t.detail?.prompt:void 0;typeof n==`string`&&e(n)};return t.addEventListener(tN,n),()=>t.removeEventListener(tN,n)}function iN(e){let t=(0,$.c)(61),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{onOpenSearch:r}=n,{_:a}=i(),[o,s]=T_(),[c,l]=(0,Q.useState)(o),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(`auth`),[m,h]=(0,Q.useState)(Hv[0].id),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(null),S=typeof window<`u`?window.okDesktop??null:null,[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(null),D=Ca(),{projectLocalConfig:O,projectLocalSynced:k}=oe(),A=po(),{activeDocName:j}=pt(),M=D?.hasRemote,N=D?.pushPermission?.checkStatus,P;t[2]!==g||t[3]!==O||t[4]!==k||t[5]!==M||t[6]!==N?(P=k_({autoSyncOnboardingDismissed:g,hasRemote:M,projectLocalSynced:k,projectLocalConfig:O,pushPermissionCheckStatus:N}),t[2]=g,t[3]=O,t[4]=k,t[5]=M,t[6]=N,t[7]=P):P=t[7];let F=P,I,L;t[8]===j?(I=t[9],L=t[10]):(I=()=>{let e=function(e){let t=e.detail;t&&j&&yc(j,{kind:`raw-mdx`,detail:t}),l(`source`)};return window.addEventListener(__,e),()=>window.removeEventListener(__,e)},L=[j],t[8]=j,t[9]=I,t[10]=L),(0,Q.useEffect)(I,L);let R,z;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>{let e=window.okDesktop;if(e!=null)return e.onMenuAction(e=>{e===`toggle-terminal`?w(oN):e===`new-terminal`&&w(!0)})},z=[],t[11]=R,t[12]=z):(R=t[11],z=t[12]),(0,Q.useEffect)(R,z);let B,V;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>{if(window.okDesktop!=null)return;let e=function(e){qs(e,`toggle-terminal-panel`)&&(e.preventDefault(),w(aN))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},B=[],t[13]=B,t[14]=V):(B=t[13],V=t[14]),(0,Q.useEffect)(V,B);let H,U;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>rN(e=>{w(!0),E(t=>({prompt:e,nonce:(t?.nonce??0)+1}))}),U=[],t[15]=H,t[16]=U):(H=t[15],U=t[16]),(0,Q.useEffect)(H,U);let W,G;t[17]===C?(W=t[18],G=t[19]):(W=()=>{C||E(null)},G=[C],t[17]=C,t[18]=W,t[19]=G),(0,Q.useEffect)(W,G);let K,q;t[20]===C?(K=t[21],q=t[22]):(K=()=>{window.okDesktop!=null&&window.okDesktop.editor.notifyViewMenuStateChanged({terminalVisible:C})},q=[C],t[20]=C,t[21]=K,t[22]=q),(0,Q.useEffect)(K,q);let J,Y;t[23]===C?(J=t[24],Y=t[25]):(J=()=>{window.okDesktop!=null&&C&&Ma()},Y=[C],t[23]=C,t[24]=J,t[25]=Y),(0,Q.useEffect)(J,Y),E_(D?.pausedReason);let ee;t[26]===s?ee=t[27]:(ee=function(e){l(e),s(e)},t[26]=s,t[27]=ee);let te=ee,ne;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(ne=function(e){y(e),e||x(null)},t[28]=ne):ne=t[28];let re=ne,ie;t[29]!==a||t[30]!==j||t[31]!==A?(ie={openSelection(e){let t=wg({docName:e.docName??j,workspace:A,instruction:e.instruction,selectionMarkdown:e.selectionMarkdown});return t===null?(X.error(a({id:`_VRtd7`})),!1):(x(t),y(!0),!0)}},t[29]=a,t[30]=j,t[31]=A,t[32]=ie):ie=t[32];let ae,se;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>{p(`auth`),d(!0)},se=()=>{p(`identity`),d(!0)},t[33]=ae,t[34]=se):(ae=t[33],se=t[34]);let ce;t[35]!==r||t[36]!==b||t[37]!==v?(ce=(0,Z.jsx)(eN,{onSignIn:ae,onSetIdentity:se,onOpenSearch:r,openInAgentMenuOpen:v,openInAgentMenuInput:b,onOpenInAgentMenuOpenChange:re}),t[35]=r,t[36]=b,t[37]=v,t[38]=ce):ce=t[38];let le;t[39]!==m||t[40]!==c||t[41]!==te||t[42]!==T||t[43]!==C?(le=(0,Z.jsx)(NA,{editorMode:c,onModeChange:te,activeTab:m,onActiveTabChange:h,terminalBridge:S,terminalVisible:C,onTerminalVisibleChange:w,terminalLaunch:T}),t[39]=m,t[40]=c,t[41]=te,t[42]=T,t[43]=C,t[44]=le):le=t[44];let ue;t[45]!==ie||t[46]!==ce||t[47]!==le?(ue=(0,Z.jsxs)(Tc,{value:ie,children:[ce,le]}),t[45]=ie,t[46]=ce,t[47]=le,t[48]=ue):ue=t[48];let de=f===`identity`,fe;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(fe=()=>{d(!1)},t[49]=fe):fe=t[49];let pe;t[50]!==u||t[51]!==de?(pe=(0,Z.jsx)(Xi,{open:u,onOpenChange:d,identityPrompt:de,onSuccess:fe}),t[50]=u,t[51]=de,t[52]=pe):pe=t[52];let me;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(me=()=>_(!0),t[53]=me):me=t[53];let he;t[54]===F?he=t[55]:(he=(0,Z.jsx)(D_,{open:F,onResolved:me}),t[54]=F,t[55]=he);let ge;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,Z.jsx)(m_,{}),t[56]=ge):ge=t[56];let _e;return t[57]!==ue||t[58]!==pe||t[59]!==he?(_e=(0,Z.jsxs)(Z.Fragment,{children:[ue,pe,he,ge]}),t[57]=ue,t[58]=pe,t[59]=he,t[60]=_e):_e=t[60],_e}function aN(e){return!e}function oN(e){return!e}function sN(e){let t=Go(Ho(e));typeof window>`u`||window.location.hash!==t&&(window.location.hash=t)}function cN(){let e=(0,$.c)(11),{conflicts:t,loading:n,error:r}=Ni();if(n)return null;if(r===`server`){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`section`,{"data-testid":`conflicts-section`,"aria-label":`Conflicted files`,className:`border-b border-amber-200/60 bg-amber-50/40 px-2 py-2 dark:border-amber-900/40 dark:bg-amber-950/20`,children:(0,Z.jsxs)(`p`,{"data-testid":`conflicts-section-error`,className:`px-2 py-1.5 text-[12px] text-amber-700 dark:text-amber-400`,children:[(0,Z.jsx)(ds,{"aria-hidden":`true`,className:`mr-1.5 inline size-3`}),`Couldn't load conflicts — reload to retry.`]})}),e[0]=t):t=e[0],t}if(t.length===0)return null;let i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-[11px] uppercase tracking-wider text-amber-700 dark:text-amber-400`,children:[(0,Z.jsx)(ds,{"aria-hidden":`true`,className:`size-3`}),`Conflicts`]}),e[1]=i):i=e[1];let a;e[2]===t.length?a=e[3]:(a=(0,Z.jsxs)(`header`,{className:`flex items-center justify-between px-2 pb-1.5`,children:[i,(0,Z.jsx)(`span`,{"data-testid":`conflicts-section-count`,className:`rounded-full bg-amber-500 px-1.5 py-0.5 font-mono text-[10px] font-medium leading-none text-white`,children:t.length})]}),e[2]=t.length,e[3]=a);let o;e[4]===t?o=e[5]:(o=t.map(lN),e[4]=t,e[5]=o);let s;e[6]===o?s=e[7]:(s=(0,Z.jsx)(`ul`,{className:`flex flex-col gap-px`,children:o}),e[6]=o,e[7]=s);let c;return e[8]!==a||e[9]!==s?(c=(0,Z.jsxs)(`section`,{"data-testid":`conflicts-section`,"aria-label":`Conflicted files`,className:`border-b border-amber-200/60 bg-amber-50/40 px-2 py-2 dark:border-amber-900/40 dark:bg-amber-950/20`,children:[a,s]}),e[8]=a,e[9]=s,e[10]=c):c=e[10],c}function lN(e){return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(si,{variant:`ghost`,size:`sm`,"data-testid":`conflicts-section-row`,"data-file":e.file,title:e.file,className:`h-7 w-full justify-start gap-1.5 px-2 font-normal text-[13px] text-amber-800 hover:bg-amber-100/60 hover:text-amber-900 dark:text-amber-300 dark:hover:bg-amber-900/30 dark:hover:text-amber-200`,onClick:()=>sN(e.file),children:[(0,Z.jsx)(ds,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.file})]})},e.file)}var uN=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
30
30
|
<symbol id="file-tree-icon-chevron" viewBox="0 0 16 16">
|
|
31
31
|
<path d="M12.4697 5.46973C12.7626 5.17684 13.2374 5.17684 13.5303 5.46973C13.8232 5.76262 13.8232 6.23738 13.5303 6.53028L8.53028 11.5303C8.23738 11.8232 7.76262 11.8232 7.46973 11.5303L2.46973 6.53028C2.17684 6.23738 2.17684 5.76262 2.46973 5.46973C2.76262 5.17684 3.23738 5.17684 3.53028 5.46973L8 9.93946L12.4697 5.46973Z" fill="currentcolor"/>
|
|
32
32
|
</symbol>
|
|
@@ -2016,4 +2016,4 @@ Error generating stack: `+e.message+`
|
|
|
2016
2016
|
:host([${MG}]) [data-item-focused="true"] {
|
|
2017
2017
|
--trees-focus-ring-color: transparent;
|
|
2018
2018
|
}
|
|
2019
|
-
`}\n${NU}\n${PU}`;function PG(e){let t=e.split(`/`).pop()?.replace(/\.md$/i,``).toLowerCase();return!!t&&_G.has(t)}function FG(e){return e===`darwin`?Ko._({id:`LtSYdi`}):e===`win32`?Ko._({id:`qi1F96`}):Ko._({id:`e1Rn_k`})}function IG(e){let t=(0,$.c)(18),{item:n,workspace:r,onClose:a}=e,{_:o}=i(),s=typeof window<`u`?window.okDesktop:void 0;if(!s)return null;let c=s.platform,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=FG(c),t[0]=l):l=t[0];let u=l,d,f;t[1]!==o||t[2]!==r?(d=r?null:o({id:`wTcjov`}),f=o(c===`darwin`?d?{id:`FvpFSZ`,values:{hint:d}}:{id:`LtSYdi`}:c===`win32`?d?{id:`o4dcAf`,values:{hint:d}}:{id:`qi1F96`}:d?{id:`zUhPuR`,values:{hint:d}}:{id:`e1Rn_k`}),t[1]=o,t[2]=r,t[3]=d,t[4]=f):(d=t[3],f=t[4]);let p=f,m=!r,h;t[5]!==n||t[6]!==a||t[7]!==r?(h=()=>{if(!r)return;a();let e=gg(r.contentDir,Dj(n),r.pathSeparator);s.shell.showItemInFolder(e)},t[5]=n,t[6]=a,t[7]=r,t[8]=h):h=t[8];let g,_;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(ke,{"aria-hidden":`true`}),_=(0,Z.jsx)(`span`,{className:`flex-1`,children:u}),t[9]=g,t[10]=_):(g=t[9],_=t[10]);let v;t[11]===d?v=t[12]:(v=d?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:d}):null,t[11]=d,t[12]=v);let y;return t[13]!==p||t[14]!==m||t[15]!==h||t[16]!==v?(y=(0,Z.jsxs)(Fa,{disabled:m,onSelect:h,"aria-label":p,children:[g,_,v]}),t[13]=p,t[14]=m,t[15]=h,t[16]=v,t[17]=y):y=t[17],y}function LG(e,t){return Ej({kind:e.endsWith(`/`)?`directory`:`file`,name:e,path:e},t)}function RG(e,t){return e!==t&&e.startsWith(t)}function zG(e,t){let n=[...new Set(e)],r=n.filter(e=>e.endsWith(`/`));return n.filter(e=>!r.some(t=>RG(e,t))).map(e=>LG(e,t))}function BG(e,t){return e===t||e.startsWith(`${t}/`)}function VG(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable||e.closest(`[contenteditable="true"]`)!==null}function HG(e,t,n){let r=new Set,i=new Set,a=new Set;for(let o of e){if(o.kind===`file`){r.add(o.path);continue}if(o.kind===`asset`){a.add(o.path);continue}i.add(o.path);for(let e of t)ls(e)&&e.docName.startsWith(`${o.path}/`)?r.add(e.docName):Io(e)&&e.path.startsWith(`${o.path}/`)&&a.add(e.path);for(let e of n){let t=hj(e);BG(t,o.path)&&i.add(t)}}return{docNames:r,folderPaths:i,assetPaths:a}}function UG(e,t){return e.kind===`file`?t.kind===`file`&&e.path===t.createdPath:e.kind===`asset`?!1:BG(t.createdPath,e.path)}function WG(e){let t=(0,$.c)(60),{item:n,context:r,anyActionBusy:a,workspace:o,handoff:c,model:l,okignoreBinding:u,projectLocalBinding:d,mergedConfig:f,onStartCreating:p,onCreateFromTemplate:m,onDuplicate:h,onDelete:g,onExpandSubtree:_,onCollapseSubtree:v,folderTreePaths:y,isAsset:b,documents:x}=e,{_:S}=i(),C=Ej(n,x),w=n.kind===`directory`,T=C.kind===`asset`?null:C,E=T!==null&&u!==null,D;t[0]!==S||t[1]!==w?(D=S(w?{id:`5D3Ior`}:{id:`dbhUX1`}),t[0]=S,t[1]=w,t[2]=D):D=t[2];let O=D,k=f?.appearance?.sidebar?.showHiddenFiles??!1,A=f?.appearance?.sidebar?.showAllFiles??!0,j=d!==null,M;t[3]!==w||t[4]!==n.path?(M=w?hj(n.path):null,t[3]=w,t[4]=n.path,t[5]=M):M=t[5];let N=ea(M),P=N.state.status===`ready`?(N.state.data.folder.templates_available?.length??0)>0:!0,F=l.getSelectedPaths(),I=F.includes(C.treePath)?zG(F,x):[],L=I.length>1?I:[C],R=L.length,z=Ko._({id:`djjdjr`,values:{deleteCount:R}}),B;t[6]!==b||t[7]!==w||t[8]!==n||t[9]!==o?(B=b?null:w?Sg({folderRelativePath:Dj(n),workspace:o}):vg({docName:fj(n.path),workspace:o}),t[6]=b,t[7]=w,t[8]=n,t[9]=o,t[10]=B):B=t[10];let H=B,U;t[11]===r?U=t[12]:(U=()=>r.close({restoreFocus:!1}),t[11]=r,t[12]=U);let W=U,G;t[13]===r?G=t[14]:(G=()=>r.close(),t[13]=r,t[14]=G);let K=G,q;t[15]!==S||t[16]!==d?(q=e=>{if(d===null)return;let t=d.patch({appearance:{sidebar:{showHiddenFiles:e}}});t.ok||(console.warn(`[FileTree] showHiddenFiles toggle rejected:`,qr(t.error)),X.error(S({id:`P47EWZ`}),{description:qr(t.error)}))},t[15]=S,t[16]=d,t[17]=q):q=t[17];let J=q,Y;t[18]!==S||t[19]!==d?(Y=e=>{if(d===null)return;let t=d.patch({appearance:{sidebar:{showAllFiles:e}}});t.ok||(console.warn(`[FileTree] showAllFiles toggle rejected:`,qr(t.error)),X.error(S({id:`P47EWZ`}),{description:qr(t.error)}))},t[18]=S,t[19]=d,t[20]=Y):Y=t[20];let ee=Y,te=0,ne=0;if(w){let e=gj(n.path);for(let t of y)(t===e||t.startsWith(e))&&(te++,OW(l.getItem(t))?.isExpanded()&&ne++)}let re=w&&ne<te,ie=w&&ne>0,ae;t[21]===K?ae=t[22]:(ae=e=>{e||K()},t[21]=K,t[22]=ae);let oe;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,Z.jsx)(ao,{asChild:!0,children:(0,Z.jsx)(`span`,{"aria-hidden":`true`,"data-file-tree-context-menu-root":`true`,className:`block size-px`})}),t[23]=oe):oe=t[23];let se;t[24]!==S||t[25]!==a||t[26]!==E||t[27]!==j||t[28]!==K||t[29]!==W||t[30]!==z||t[31]!==L||t[32]!==P||t[33]!==ee||t[34]!==J||t[35]!==c||t[36]!==H||t[37]!==O||t[38]!==b||t[39]!==w||t[40]!==n||t[41]!==l||t[42]!==u||t[43]!==T||t[44]!==v||t[45]!==m||t[46]!==g||t[47]!==h||t[48]!==_||t[49]!==p||t[50]!==A||t[51]!==k||t[52]!==ie||t[53]!==re||t[54]!==C||t[55]!==o?(se=(0,Z.jsx)($a,{sideOffset:0,align:`start`,"data-file-tree-context-menu-root":`true`,className:`min-w-52`,children:w?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Fa,{disabled:a,onSelect:()=>{W(),p(`file`,hj(n.path))},children:[(0,Z.jsx)(Gl,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`HdkSiO`})]}),P?(0,Z.jsxs)(eo,{children:[(0,Z.jsxs)(Ba,{disabled:a,children:[(0,Z.jsx)(Qa,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`Uuj_R4`})]}),(0,Z.jsx)(Oa,{children:(0,Z.jsx)(DW,{parentDir:hj(n.path),onSelectTemplate:e=>{W(),m(hj(n.path),e)},ItemComponent:Fa})})]}):null,(0,Z.jsxs)(Fa,{disabled:a,onSelect:()=>{W(),p(`folder`,hj(n.path))},children:[(0,Z.jsx)(fl,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`96G6Re`})]}),(0,Z.jsx)(Ka,{}),(0,Z.jsx)(IG,{item:n,workspace:o,onClose:K}),(0,Z.jsx)(XW,{input:H,installStates:c.installStates,isElectronHost:c.isElectronHost,dispatch:c.dispatch}),(0,Z.jsxs)(eo,{children:[(0,Z.jsxs)(Ba,{children:[(0,Z.jsx)(Et,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`oCZkaG`})]}),(0,Z.jsxs)(Oa,{children:[(0,Z.jsx)(Fa,{disabled:!o,onSelect:()=>{o&&(K(),gG(gg(o.contentDir,Dj(n),o.pathSeparator),`full`))},children:(0,Z.jsx)(s,{id:`oQA-cA`})}),(0,Z.jsx)(Fa,{onSelect:()=>{K(),gG(Dj(n),`relative`)},children:(0,Z.jsx)(s,{id:`s061i4`})})]})]}),(0,Z.jsx)(Ka,{}),(0,Z.jsx)(Ua,{checked:k,onCheckedChange:J,disabled:!j,"data-testid":`file-tree-menu-show-hidden-files`,children:(0,Z.jsx)(s,{id:`XcGbim`})}),(0,Z.jsx)(Ua,{checked:A,onCheckedChange:ee,disabled:!j,"data-testid":`file-tree-menu-show-all-files`,children:(0,Z.jsx)(s,{id:`i8dKs-`})}),re||ie?(0,Z.jsx)(Ka,{}):null,re?(0,Z.jsxs)(Fa,{onSelect:()=>{K(),_(n.path)},children:[(0,Z.jsx)(ru,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`OlAl5i`})]}):null,ie?(0,Z.jsxs)(Fa,{onSelect:()=>{K(),v(n.path)},children:[(0,Z.jsx)(ul,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`qvWGzP`})]}):null,(0,Z.jsx)(Ka,{}),(0,Z.jsxs)(Fa,{disabled:a,onSelect:()=>{C.kind!==`asset`&&(K(),h(C))},children:[(0,Z.jsx)($e,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`euc6Ns`})]}),(0,Z.jsxs)(Fa,{disabled:a,onSelect:()=>{W(),l.startRenaming(n.path)},children:[(0,Z.jsx)(V,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`2wxgft`})]}),(0,Z.jsxs)(Fa,{"data-testid":`file-tree-menu-hide`,disabled:!E,onSelect:()=>{if(!u||!T)return;K();let e=ZU(T),t=io(u.current()),n=Wa(t,e);if(n===t)return;u.patch(qa(n));let r=T.path.split(`/`).pop()||T.path;X.success(S({id:`4xtLTl`,values:{basename:r}}),{description:S({id:`nWv1ja`}),duration:5e3})},children:[(0,Z.jsx)(Nt,{"aria-hidden":`true`}),O]}),(0,Z.jsxs)(Fa,{variant:`destructive`,disabled:a,onSelect:()=>{K(),g(L)},children:[(0,Z.jsx)(fs,{"aria-hidden":`true`}),z]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(IG,{item:n,workspace:o,onClose:K}),!b&&(0,Z.jsx)(XW,{input:H,installStates:c.installStates,isElectronHost:c.isElectronHost,dispatch:c.dispatch}),(0,Z.jsxs)(eo,{children:[(0,Z.jsxs)(Ba,{children:[(0,Z.jsx)(Et,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`oCZkaG`})]}),(0,Z.jsxs)(Oa,{children:[(0,Z.jsx)(Fa,{disabled:!o,onSelect:()=>{o&&(K(),gG(gg(o.contentDir,Dj(n),o.pathSeparator),`full`))},children:(0,Z.jsx)(s,{id:`oQA-cA`})}),(0,Z.jsx)(Fa,{onSelect:()=>{K(),gG(Dj(n),`relative`)},children:(0,Z.jsx)(s,{id:`s061i4`})})]})]}),(0,Z.jsx)(Ka,{}),b?null:(0,Z.jsxs)(Fa,{disabled:a,onSelect:()=>{K(),h(C)},children:[(0,Z.jsx)($e,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`euc6Ns`})]}),(0,Z.jsxs)(Fa,{disabled:a,onSelect:()=>{W(),l.startRenaming(n.path)},children:[(0,Z.jsx)(V,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`2wxgft`})]}),T?(0,Z.jsxs)(Fa,{"data-testid":`file-tree-menu-hide`,disabled:!E,onSelect:()=>{if(!u)return;K();let e=ZU(T),t=io(u.current()),n=Wa(t,e);if(n===t)return;u.patch(qa(n));let r=T.path.split(`/`).pop()||T.path;X.success(S({id:`OD0FCX`,values:{basename:r}}),{description:S({id:`nWv1ja`}),duration:5e3})},children:[(0,Z.jsx)(Nt,{"aria-hidden":`true`}),O]}):null,(0,Z.jsxs)(Fa,{variant:`destructive`,disabled:a,onSelect:()=>{K(),g(L)},children:[(0,Z.jsx)(fs,{"aria-hidden":`true`}),z]})]})}),t[24]=S,t[25]=a,t[26]=E,t[27]=j,t[28]=K,t[29]=W,t[30]=z,t[31]=L,t[32]=P,t[33]=ee,t[34]=J,t[35]=c,t[36]=H,t[37]=O,t[38]=b,t[39]=w,t[40]=n,t[41]=l,t[42]=u,t[43]=T,t[44]=v,t[45]=m,t[46]=g,t[47]=h,t[48]=_,t[49]=p,t[50]=A,t[51]=k,t[52]=ie,t[53]=re,t[54]=C,t[55]=o,t[56]=se):se=t[56];let ce;return t[57]!==se||t[58]!==ae?(ce=(0,Z.jsxs)(ro,{open:!0,modal:!1,onOpenChange:ae,children:[oe,se]}),t[57]=se,t[58]=ae,t[59]=ce):ce=t[59],ce}async function GG(e,t,n,r){try{let i=await fetch(`/api/documents?showAll=true&dir=${encodeURIComponent(e)}&depth=1`,{signal:t,headers:VW});if(HW(i)){let e=await GW(i);return{kind:`entries`,entries:Ro(e.entries),truncated:e.truncated}}let a=await ve(i,n);if(!a.ok)return{kind:`http-error`,title:a.title};let o=Or.safeParse(a.body);return o.success?{kind:`entries`,entries:Ro(o.data.documents),truncated:o.data.truncated===!0}:{kind:`http-error`,title:r}}catch(e){return e instanceof UW?{kind:`http-error`,title:e.message}:{kind:`network-error`,cause:e}}}function KG(e){let t=(0,$.c)(356),{ref:n}=e,{_:r,i18n:a}=i(),{activeDocName:o,activeTarget:c,closeTabs:l,closeDocument:u,closeAndClearForRename:d,getPoolActiveDocName:f,poolHas:p,isNewTabActive:m,openTarget:h,prewarm:g,remapTabsForRename:_}=pt(),{notifySidebarFileSelected:v}=Ok(),{resolvedTheme:y}=vr(),{addPage:b,pageMeta:x}=es(),S;t[0]===x?S=t[1]:(S=function(e,t){return ss(e,t??x.get(e)?.size)??{kind:`doc`,target:e,docName:e}},t[0]=x,t[1]=S);let C=S,w;t[2]!==C||t[3]!==v||t[4]!==h?(w=function(e,t){h(C(e,t),{tabBehavior:`replace-active`}),Vo(Go(e)),v()},t[2]=C,t[3]=v,t[4]=h,t[5]=w):w=t[5];let T=w,E;t[6]!==v||t[7]!==h?(E=function(e){let t=zo(e);h({kind:`folder`,target:e,folderPath:e},{tabBehavior:`replace-active`}),Vo(t),v()},t[6]=v,t[7]=h,t[8]=E):E=t[8];let D=E,O;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(O=[],t[9]=O):O=t[9];let[k,j]=(0,Q.useState)(O),[M,N]=(0,Q.useState)(!0),[P,F]=(0,Q.useState)(null),[I,L]=(0,Q.useState)(!1),R=Ap(),z=(0,Q.useRef)(null),[B,V]=(0,Q.useState)(null),[H,U]=(0,Q.useState)(null),[W,G]=(0,Q.useState)(null),[K,q]=(0,Q.useState)(null),{conflicts:J}=Ni(),[Y,ee]=(0,Q.useState)(null),[te,ne]=(0,Q.useState)(null),[re,ie]=(0,Q.useState)(!1),ae=(0,Q.useRef)(re),se;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(se=new Set,t[10]=se):se=t[10];let ce=(0,Q.useRef)(se),le=(0,Q.useRef)(k),ue=(0,Q.useRef)(x),de;t[11]!==k||t[12]!==D||t[13]!==T||t[14]!==v||t[15]!==h?(de=function(e,t){let n=t===void 0?k:t,r=mW(e,n);if(r.kind===`none`){console.debug(`[FileTree] Dropped selection for unknown docName:`,_j(e));return}if(r.kind===`asset`){h({kind:`asset`,target:r.path,assetPath:r.path,mediaKind:r.mediaKind},{tabBehavior:`replace-active`}),Vo(r.hash),v();return}if(r.kind===`folder`){D(r.path);return}let i=n.find(e=>ls(e)&&e.docName===r.path);T(r.path,i?.size)},t[11]=k,t[12]=D,t[13]=T,t[14]=v,t[15]=h,t[16]=de):de=t[16];let fe=de,pe;t[17]!==v||t[18]!==h?(pe=function(e){h({kind:`asset`,target:e,assetPath:e,mediaKind:le.current.find(t=>Io(t)&&t.path===e)?.mediaKind??null},{tabBehavior:`replace-active`}),Vo(Uo(e)),v()},t[17]=v,t[18]=h,t[19]=pe):pe=t[19];let me=pe,he=(0,Q.useRef)(o),ge;t[20]===k?ge=t[21]:(ge=new Set(k.filter(Io).map(yK)),t[20]=k,t[21]=ge);let _e=ge,ye=(0,Q.useRef)(_e),be;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(be=[],t[22]=be):be=t[22];let xe=(0,Q.useRef)(be),Se=(0,Q.useRef)(null),Ce=(0,Q.useRef)(vK),we=(0,Q.useRef)(null),Te=(0,Q.useRef)(null),Ee=(0,Q.useRef)(!1),De=(0,Q.useRef)(!1),Oe=(0,Q.useRef)(null),ke;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ke={row:null,root:null},t[23]=ke):ke=t[23];let Ae=(0,Q.useRef)(ke),je=(0,Q.useRef)(_K),Me=(0,Q.useRef)(null),Ne;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=new Map,t[24]=Ne):Ne=t[24];let Pe=(0,Q.useRef)(Ne),Fe;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=new Set,t[25]=Fe):Fe=t[25];let Ie=(0,Q.useRef)(Fe),Le;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(Le=new Map,t[26]=Le):Le=t[26];let Re=(0,Q.useRef)(Le),ze=(0,Q.useRef)(0),Be;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(Be=new Set,t[27]=Be):Be=t[27];let Ve=(0,Q.useRef)(Be),He=(0,Q.useRef)(gK),Ue=(0,Q.useRef)(hK),We=(0,Q.useRef)(!1),Ge=(0,Q.useRef)(!0),Ke=(0,Q.useRef)(null),qe=(0,Q.useRef)(null),Je=(0,Q.useRef)(mK),Ye=(0,Q.useRef)(pK),Xe=(0,Q.useRef)(fK),Qe=(0,Q.useRef)(dK),$e=(0,Q.useRef)(c),[et,tt]=(0,Q.useState)(!1),nt;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(nt=function(){z.current!==null&&(clearTimeout(z.current),z.current=null)},t[28]=nt):nt=t[28];let rt=nt,it;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(it=function(){rt(),L(!1)},t[29]=it):it=t[29];let at=it,ot;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(ot=function(e){at(),F(e)},t[30]=ot):ot=t[30];let st=ot,ct;t[31]===r?ct=t[32]:(ct=function(){if(rt(),Ep()){F(null),L(!0),z.current=setTimeout(()=>{z.current=null,Ke.current?.()},AG);return}L(!1),F(r({id:`34qyH5`}))},t[31]=r,t[32]=ct);let lt=ct,ut=(0,Q.useRef)(!0),dt;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(dt=()=>{if(ut.current){ut.current=!1;return}Ke.current?.()},t[33]=dt):dt=t[33];let ft;t[34]===R?ft=t[35]:(ft=[R],t[34]=R,t[35]=ft),(0,Q.useEffect)(dt,ft);let mt,ht;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(mt=()=>rt,ht=[],t[36]=mt,t[37]=ht):(mt=t[36],ht=t[37]),(0,Q.useEffect)(mt,ht);let gt,_t;t[38]!==k.length||t[39]!==M?(gt=()=>{if(M||k.length===0)return;let e=qe.current?.querySelector(CP)?.shadowRoot;if(!e)return;let t=e,n=function(){Oe.current!==null&&clearTimeout(Oe.current),Oe.current=setTimeout(()=>{De.current=!1,Oe.current=null},0)},r=function(e){if(!(e instanceof DragEvent))return;let t=xK(e),n=t?.dataset.itemPath;if(!n)return;let r=yW(t.dataset.itemType===`folder`?gj(n):n,le.current,ue.current);r&&(Oe.current!==null&&(clearTimeout(Oe.current),Oe.current=null),De.current=!0,e.dataTransfer?.setData(rE,aE(r)))},i=function(e){if(!(e instanceof DragEvent)||!Fj(e))return;let t=CK(e);if(!t){mG(Ae);return}e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`),hG(Ae,t)},a=function(e){if(!(e instanceof DragEvent)||!Fj(e))return;let n=e.relatedTarget;n instanceof Node&&t.contains(n)||mG(Ae)},o=function(e){if(!(e instanceof DragEvent)||!Fj(e))return;let t=CK(e),n=Ij(e);if(!t||n.length===0){mG(Ae);return}e.preventDefault(),e.stopPropagation(),mG(Ae),je.current(n,t.parentDir,t.busyPath)};return e.addEventListener(`dragstart`,r,{capture:!0}),e.addEventListener(`dragover`,i,{capture:!0}),e.addEventListener(`dragleave`,a,{capture:!0}),e.addEventListener(`drop`,o,{capture:!0}),e.addEventListener(`dragend`,n,{capture:!0}),window.addEventListener(`drop`,n,!0),window.addEventListener(`dragend`,n,!0),()=>{e.removeEventListener(`dragstart`,r,{capture:!0}),e.removeEventListener(`dragover`,i,{capture:!0}),e.removeEventListener(`dragleave`,a,{capture:!0}),e.removeEventListener(`drop`,o,{capture:!0}),e.removeEventListener(`dragend`,n,{capture:!0}),window.removeEventListener(`drop`,n,!0),window.removeEventListener(`dragend`,n,!0),mG(Ae),Oe.current!==null&&(clearTimeout(Oe.current),Oe.current=null),De.current=!1}},_t=[k.length,M],t[38]=k.length,t[39]=M,t[40]=gt,t[41]=_t):(gt=t[40],_t=t[41]),(0,Q.useEffect)(gt,_t);let{selectedFilePath:vt,selectedFolderPath:yt,navigationPath:xt}=pW(c,m?null:o),St=vt?dj(vt,k.find(e=>ls(e)&&e.docName===vt)?.docExt):yt?gj(yt):c?.kind===`asset`?c.assetPath:null,Ct=re?null:St,wt=Kg().states,{dispatch:Tt}=Fg(),Et;t[42]!==Tt||t[43]!==wt?(Et={installStates:wt,isElectronHost:typeof window<`u`&&window.okDesktop!=null,dispatch:Tt},t[42]=Tt,t[43]=wt,t[44]=Et):Et=t[44];let Dt=Et,{okignoreBinding:Ot,projectLocalBinding:kt,merged:At}=oe(),jt=At?.appearance?.sidebar?.showHiddenFiles??!1,Mt=At?.appearance?.sidebar?.showAllFiles??!0,Nt;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(Nt=()=>Me.current===null,t[45]=Nt):Nt=t[45];let Pt=Nt,Ft;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(Ft=[],t[46]=Ft):Ft=t[46];let It;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(It={set:`complete`,spriteSheet:TG,byFileExtension:{md:{name:bG,viewBox:xG},mdx:{name:bG,viewBox:xG}}},t[47]=It):It=t[47];let Lt;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(Lt={contextMenu:{enabled:!0,triggerMode:`both`,buttonVisibility:`when-needed`}},t[48]=Lt):Lt=t[48];let Rt;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(Rt={canDrag:Pt,canDrop:Pt,onDropComplete:e=>Qe.current(e),onDropError:uK},t[49]=Rt):Rt=t[49];let zt,Vt;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(zt={canRename:Pt,onRename:e=>Ye.current(e),onError:e=>Xe.current(e)},Vt=e=>Je.current(e),t[50]=zt,t[51]=Vt):(zt=t[50],Vt=t[51]);let Ht;t[52]===r?Ht=t[53]:(Ht={paths:Ft,initialExpansion:`closed`,fileTreeSearchMode:`hide-non-matches`,initialVisibleRowCount:18,stickyFolders:!0,...jU,icons:It,unsafeCSS:NG,composition:Lt,dragAndDrop:Rt,renaming:zt,onSelectionChange:Vt,renderRowDecoration:e=>{let{item:t}=e;if(t.kind===`file`){let e=le.current.find(e=>ls(e)&&dj(e.docName,e.docExt)===t.path);if(e?.isSymlink){let t=e.targetPath;return{icon:vG,title:r(t?{id:`JE21eh`,values:{targetPath:t}}:{id:`BQu9Pg`})}}return PG(t.path)?{icon:yG,title:r({id:`i9toLO`})}:null}let n=le.current.find(e=>Jo(e)&&gj(e.path)===gj(t.path));if(n?.isSymlink){let e=n.targetPath;return{icon:vG,title:r(e?{id:`JE21eh`,values:{targetPath:e}}:{id:`BQu9Pg`})}}return null}},t[52]=r,t[53]=Ht);let{model:Ut}=AU(Ht),Wt;t[54]===Ut?Wt=t[55]:(Wt=function(e){let t=Ut.getItem(e)??Ut.getItem(gj(e));return t?.isDirectory()?gj(hj(t.getPath())):e},t[54]=Ut,t[55]=Wt);let Gt=Wt,Kt,qt;t[56]===k?(Kt=t[57],qt=t[58]):(qt=vj(k),Kt=yj(qt),t[56]=k,t[57]=Kt,t[58]=qt);let Jt=Kt,Yt=(0,Q.useRef)(qt),Xt;t[59]===k?Xt=t[60]:(Xt=xj(k),t[59]=k,t[60]=Xt);let Zt=Xt,Qt=(0,Q.useRef)(Zt),$t=yt?Sj(gj(yt)).slice(0,-1):Sj(Ct??xt),en=$t.join(`\0`),tn;t[61]===Ut?tn=t[62]:(tn=()=>{let e=new Set;for(let t of Qt.current)OW(Ut.getItem(t))?.isExpanded()&&e.add(t);return e},t[61]=Ut,t[62]=tn);let nn=tn,rn;t[63]===nn?rn=t[64]:(rn=e=>{let t=new Set(xj(e??le.current)),n=nn();for(let e of xe.current)n.add(e);return[...n].filter(e=>t.has(e))},t[63]=nn,t[64]=rn);let an=rn,on;t[65]!==an||t[66]!==Ut?(on=e=>{let t=vj(e??le.current);Ut.resetPaths(t,{initialExpandedPaths:an(e)})},t[65]=an,t[66]=Ut,t[67]=on):on=t[67];let sn=on,cn;t[68]!==r||t[69]!==lt?(cn=async function(e){let t=ze.current,n=new AbortController;Re.current.set(e,n);let i=await GG(hj(e),n.signal,r({id:`8RtNI0`}),r({id:`HlmZBk`}));if(Re.current.get(e)===n&&Re.current.delete(e),n.signal.aborted||t!==ze.current)return;if(i.kind===`network-error`){lt(),console.warn(`[FileTree] lazy folder children fetch failed:`,e,i.cause);return}if(i.kind===`http-error`){console.warn(`[FileTree] lazy folder children http error:`,e,i.title),st(i.title);return}let a=We.current||Ge.current,o=qo(i.entries,a);Ie.current.add(e),j(t=>qW(t,e,o,Pe.current)),F(null),at(),i.truncated&&V(i.entries.length)},t[68]=r,t[69]=lt,t[70]=cn):cn=t[70];let ln=cn,un;t[71]!==nn||t[72]!==ln?(un=()=>{let e=nn(),t=Ve.current;if(Ve.current=e,Ge.current)for(let n of e){if(t.has(n)||Ie.current.has(n)||Re.current.has(n))continue;let e=hj(n);le.current.find(t=>Jo(t)&&t.path===e)?.hasChildren!==!1&&ln(n)}},t[71]=nn,t[72]=ln,t[73]=un):un=t[73];let dn=un,fn;t[74]!==nn||t[75]!==ln?(fn=()=>{for(let e of nn())Ie.current.has(e)||Re.current.has(e)||ln(e)},t[74]=nn,t[75]=ln,t[76]=fn):fn=t[76];let pn=fn,mn;t[77]!==Ut||t[78]!==sn?(mn=(e,t,n,r)=>{let i=r===void 0?[]:r,a=0,o=null;for(let{fromDocName:t,toDocName:r}of n){let n=e.find(e=>ls(e)&&e.docName===t);if(n==null||Ut.getItem(r)==null)continue;let i=dj(r,n.docExt);Ut.move(r,i),o=i,a+=1}for(let{toPath:e}of i){let t=oj(e);if(t===``)continue;let n=e.slice(0,-t.length);Ut.getItem(n)!=null&&(Ut.getItem(e)??Ut.move(n,e),o=e,a+=1)}a!==0&&(sn(t),o!=null&&Ut.focusPath(o))},t[77]=Ut,t[78]=sn,t[79]=mn):mn=t[79];let hn=mn,gn;t[80]===Symbol.for(`react.memo_cache_sentinel`)?(gn=e=>{we.current=bj(e)},t[80]=gn):gn=t[80];let _n=gn,vn;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(vn=e=>ye.current.has(e),t[81]=vn):vn=t[81];let yn=vn,bn;t[82]!==r||t[83]!==b||t[84]!==D||t[85]!==T||t[86]!==sn?(bn=async function(e){if(e.kind===`asset`||Me.current!==null)return;let t=()=>{U(null),Me.current=null};Me.current=e.path,U(e.path),F(null);try{let n=await ve(await fetch(`/api/duplicate-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:e.kind,path:e.path})}),r({id:`dw_dUJ`}));if(!n.ok){X.error(n.title),sn(),t();return}let i=A(Kn,n.body,`duplicate-path`,null);if(i===null){let e=r({id:`67f-3g`});X.error(e),F(e),is([`files`,`backlinks`,`graph`]),sn(),t();return}for(let e of i.duplicatedDocNames)b(e);j(t=>{let n=Kj(t,e,i);return sn(n),_n(n),n}),is([`files`,`backlinks`,`graph`]),i.path!==e.path&&(i.kind===`folder`?D(i.path):T(i.path)),X.success(i.kind===`folder`?r({id:`iilQXA`}):r({id:`A6h5b-`}),{description:i.path}),t()}catch(e){let n=e,i=n instanceof Error?n.message:String(n);console.warn(`[FileTree] duplicate failed:`,n),X.error(r({id:`EBVbtP`}),{description:i}),sn(),t()}},t[82]=r,t[83]=b,t[84]=D,t[85]=T,t[86]=sn,t[87]=bn):bn=t[87];let xn=bn,Sn=(0,Q.useRef)(xn),Cn;t[88]===xn?Cn=t[89]:(Cn=()=>{Sn.current=xn},t[88]=xn,t[89]=Cn),(0,Q.useEffect)(Cn);let wn=function(e){let t=dG(e);if(!t||fG(t))return!1;let n=Ut.getFocusedPath()??Ut.getSelectedPaths()[0]??null;if(!n||n.endsWith(`/`)||yn(n))return!1;let r=fG(n);if(!r)return!1;let i=gj(t);if(!Qt.current.includes(i))return!1;let a=`${t}${r}`;return Yt.current.includes(a)?!1:(cr({sourcePath:n,destinationPath:a,isFolder:!1}),Ut.move(n,a),!0)},Tn;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(Tn=e=>{let t=e??Se.current;!t||Se.current!==t||(t.disposeCommitListener(),Se.current=null)},t[90]=Tn):Tn=t[90];let En=Tn,Dn;t[91]!==r||t[92]!==En||t[93]!==u||t[94]!==l||t[95]!==sn?(Dn=async function(e,t){let n=t===void 0?{}:t,i=n.updateUi??!0,a=n.restoreLocation??i;En(e),i&&U(e.renamePath);try{let t=await fetch(`/api/delete-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:e.kind,path:e.createdPath})});if(!t.ok&&t.status!==404){let n=e.kind,a=e.createdPath,o=await ve(t,r({id:`EcM3k7`,values:{kind:n}}));if(o.ok)return;let s=o.title,c=r({id:`YPFBfr`,values:{detail:s,kind:n,createdPath:a}});i?X.error(c):console.warn(`[FileTree] cleanup pending create failed: ${c}`),i&&(U(null),sn());return}}catch(t){if(console.warn(`[FileTree] cleanup pending create failed:`,t),i){let t=e.kind,n=e.createdPath;X.error(r({id:`_TDESN`,values:{kind:t,createdPath:n}}))}i&&(U(null),sn());return}i&&(e.kind===`file`?u(e.createdPath):l([bt(e.createdPath)],{force:!0})),i&&j(t=>{let n=Wj(t,e.kind===`file`?[e.createdPath]:[],e.kind===`folder`?e.createdPath:void 0);return _n(n),n}),is([`files`,`backlinks`,`graph`]),a&&(window.location.hash=e.previousHash),i&&U(null)},t[91]=r,t[92]=En,t[93]=u,t[94]=l,t[95]=sn,t[96]=Dn):Dn=t[96];let On=Dn,kn,An;t[97]===Symbol.for(`react.memo_cache_sentinel`)?(kn=()=>()=>{let e=Se.current;e&&Ce.current(e,{restoreLocation:!1,updateUi:!1}).catch(lK)},An=[],t[97]=kn,t[98]=An):(kn=t[97],An=t[98]),(0,Q.useEffect)(kn,An);let jn;t[99]!==r||t[100]!==lt?(jn=()=>{let e=!0,t=null,n=BW(async function(){t?.abort();let n=new AbortController;t=n,ze.current+=1;for(let e of Re.current.values())e.abort();Re.current.clear(),Ie.current.clear();try{let t=Ge.current,i=await fetch(t?`/api/documents?showAll=true&dir=&depth=1`:`/api/documents`,{signal:n.signal,headers:t?VW:void 0});if(t&&HW(i)){let{entries:n,truncated:r}=await GW(i);if(!e)return;let a=We.current||t,o=qo(Ro(n),a);j(e=>qW(e,``,o,Pe.current)),F(null),at(),V(r?n.length:null),Ue.current()}else{let n=await ve(i,r({id:`8RtNI0`}));if(!e)return;if(!n.ok)st(n.title),V(null);else{let e=Or.safeParse(n.body);if(!e.success)st(r({id:`HlmZBk`})),V(null);else{let n=We.current||t,r=qo(Ro(e.data.documents),n);j(t?e=>qW(e,``,r,Pe.current):KW(r,le.current,Pe.current)),F(null),at(),V(t&&e.data.truncated===!0?e.data.documents.length:null),t&&Ue.current()}}}}catch(t){let r=t;if(n.signal.aborted)return;e&&(r instanceof UW?st(r.message):lt()),console.warn(`[FileTree] fetch failed:`,r)}e&&N(!1)},()=>t?.abort());Ke.current=()=>n.request(),n.request();let i=()=>{document.visibilityState===`visible`&&n.request()};window.addEventListener(`focus`,i),window.addEventListener(`visibilitychange`,i);let a=Xo(e=>{e.includes(`files`)&&n.request()});return()=>{e=!1,Ke.current=null,n.dispose();for(let e of Re.current.values())e.abort();Re.current.clear(),window.removeEventListener(`focus`,i),window.removeEventListener(`visibilitychange`,i),a()}},t[99]=r,t[100]=lt,t[101]=jn):jn=t[101];let Mn;t[102]===r?Mn=t[103]:(Mn=[r],t[102]=r,t[103]=Mn),(0,Q.useEffect)(jn,Mn);let Nn=(0,Q.useRef)(!0),Fn;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(Fn=()=>{if(Nn.current){Nn.current=!1;return}Ke.current?.()},t[104]=Fn):Fn=t[104];let Ln;t[105]===jt?Ln=t[106]:(Ln=[jt],t[105]=jt,t[106]=Ln),(0,Q.useEffect)(Fn,Ln);let Rn=(0,Q.useRef)(!0),zn;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(zn=()=>{if(Rn.current){Rn.current=!1;return}Ke.current?.()},t[107]=zn):zn=t[107];let Bn;t[108]===Mt?Bn=t[109]:(Bn=[Mt],t[108]=Mt,t[109]=Bn),(0,Q.useEffect)(zn,Bn);let Vn,Hn;t[110]===Symbol.for(`react.memo_cache_sentinel`)?(Vn=()=>{let e=!0;return fetch(`/api/workspace`).then(async t=>{let n=await t.json();if(!e||!t.ok)return;let r=A(In,n,`workspace`,null);r&&ne({contentDir:r.contentDir,pathSeparator:r.pathSeparator})}).catch(cK),()=>{e=!1}},Hn=[],t[110]=Vn,t[111]=Hn):(Vn=t[110],Hn=t[111]),(0,Q.useEffect)(Vn,Hn);let Un;t[112]!==an||t[113]!==Ut||t[114]!==Jt?(Un=()=>{if(we.current===Jt){we.current=null;return}Ut.resetPaths(Yt.current,{initialExpandedPaths:an()})},t[112]=an,t[113]=Ut,t[114]=Jt,t[115]=Un):Un=t[115];let Wn;t[116]!==Ut||t[117]!==Jt?(Wn=[Ut,Jt],t[116]=Ut,t[117]=Jt,t[118]=Wn):Wn=t[118],(0,Q.useEffect)(Un,Wn),AW(Ut,Ct,en,Ee,Jt);let Gn;t[119]===Symbol.for(`react.memo_cache_sentinel`)?(Gn=()=>{ie(!1)},t[119]=Gn):Gn=t[119];let qn;t[120]===St?qn=t[121]:(qn=[St],t[120]=St,t[121]=qn),(0,Q.useEffect)(Gn,qn);let Jn,Yn;t[122]===re?(Jn=t[123],Yn=t[124]):(Jn=()=>{ae.current=re;for(let e of ce.current)e()},Yn=[re],t[122]=re,t[123]=Jn,t[124]=Yn),(0,Q.useEffect)(Jn,Yn);let Xn;t[125]!==Ct||t[126]!==M||t[127]!==Ut?(Xn=()=>{M||!Ct||dW(Ut)},t[125]=Ct,t[126]=M,t[127]=Ut,t[128]=Xn):Xn=t[128];let Zn;t[129]!==en||t[130]!==Ct||t[131]!==M||t[132]!==Ut||t[133]!==Jt?(Zn=[Ct,en,Jt,M,Ut],t[129]=en,t[130]=Ct,t[131]=M,t[132]=Ut,t[133]=Jt,t[134]=Zn):Zn=t[134],(0,Q.useEffect)(Xn,Zn);let $n,er;t[135]===Ut?($n=t[136],er=t[137]):($n=()=>Ut.subscribe(()=>{if(!Ut.isSearchOpen())for(let e of xe.current){let t=OW(Ut.getItem(e));t&&!t.isExpanded()&&t.expand()}}),er=[Ut],t[135]=Ut,t[136]=$n,t[137]=er),(0,Q.useEffect)($n,er);let tr,rr;t[138]===Ut?(tr=t[139],rr=t[140]):(tr=()=>Ut.subscribe(()=>He.current()),rr=[Ut],t[138]=Ut,t[139]=tr,t[140]=rr),(0,Q.useEffect)(tr,rr);let ir,ar;t[141]===Ut?(ir=t[142],ar=t[143]):(ir=()=>Ut.onMutation(`remove`,e=>{let t=Se.current;!t||e.path!==t.renamePath||Ce.current(t)}),ar=[Ut],t[141]=Ut,t[142]=ir,t[143]=ar),(0,Q.useEffect)(ir,ar);let or;t[144]!==b||t[145]!==d||t[146]!==f||t[147]!==me||t[148]!==D||t[149]!==T||t[150]!==p||t[151]!==hn||t[152]!==_?(or=async(e,t,n,r)=>{let i=t===void 0?[]:t,a=n===void 0?[]:n,o=r?.docName??he.current,s=qj(o,e),c=r?.folderPath??($e.current?.kind===`folder`?$e.current.folderPath:null),l=c?Ze(c,i):null,u=r?.assetPath??($e.current?.kind===`asset`?$e.current.assetPath:null),m=u?a.find(e=>e.fromPath===u)?.toPath??Ze(u,i):null;Bt(e);let h=Jj(e,f(),p);await Promise.all(h.map(e=>d(e)));for(let t of e)b(t.toDocName);_(e,i,a),j(t=>{let n=Uj(t,e,i,a);return hn(t,n,e,a),_n(n),n}),c&&l&&l!==c?D(l):s&&s!==o?(T(s),pG(s)):u&&m&&m!==u&&me(m),is([`files`,`backlinks`,`graph`])},t[144]=b,t[145]=d,t[146]=f,t[147]=me,t[148]=D,t[149]=T,t[150]=p,t[151]=hn,t[152]=_,t[153]=or):or=t[153];let sr=or;async function cr(e){let t=!e.isFolder&&yn(e.sourcePath),n=t?e.sourcePath:Oj(e.sourcePath,e.isFolder);U(n),F(null);try{let i=cj(e.sourcePath,e.destinationPath,e.isFolder,t);if(i.kind===`block`){X.error(r({id:`FaBZwp`})),queueMicrotask(()=>{sn()}),En(),U(null);return}let a=t?i.destinationPath:Oj(i.destinationPath,e.isFolder),o=e.isFolder?{kind:`folder`,fromPath:hj(n),toPath:hj(a)}:t?{kind:`asset`,fromPath:n,toPath:a}:{kind:`file`,fromPath:fj(n),toPath:fj(a)},s={docName:he.current,folderPath:$e.current?.kind===`folder`?$e.current.folderPath:null,assetPath:$e.current?.kind===`asset`?$e.current.assetPath:null},c=await ve(await fetch(`/api/rename-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(o)}),r({id:`gijbne`}));if(!c.ok){X.error(c.title),sn();let e=Se.current;e&&e.renamePath===n?await On(e):En(),U(null);return}let l=A(Xr,c.body,`rename-path`,{renamed:[],renamedAssets:[]});try{await sr(l.renamed,e.isFolder?[{fromPath:hj(n),toPath:hj(a)}]:[],l.renamedAssets,s)}catch(e){console.warn(`[FileTree] post-rename reconciliation failed`,{err:e,sourceTreePath:n,destinationTreePath:a,renamedCount:l.renamed.length,renamedAssetCount:l.renamedAssets.length}),X.error(r({id:`dDpCOp`}))}En(),U(null)}catch(e){console.warn(`[FileTree] rename failed:`,e);let t=r({id:`HIb0vl`});X.error(t),F(t),sn();let i=Se.current;i&&i.renamePath===n?await On(i):En(),U(null)}}let lr;t[154]!==r||t[155]!==sr||t[156]!==sn?(lr=async function(e){let t=e.draggedPaths.map(t=>{let n=jj(t,e.target);return t===n?null:{sourcePath:t,destinationTreePath:n}}).filter(sK);if(t.length!==0){U(t[0]?.sourcePath??null),F(null);try{let e=[],n=[],i=[],a={docName:he.current,folderPath:$e.current?.kind===`folder`?$e.current.folderPath:null,assetPath:$e.current?.kind===`asset`?$e.current.assetPath:null};for(let a of t){let t=a.sourcePath.endsWith(`/`),o=!t&&yn(a.sourcePath),s=t?{kind:`folder`,fromPath:hj(a.sourcePath),toPath:hj(a.destinationTreePath)}:o?{kind:`asset`,fromPath:a.sourcePath,toPath:a.destinationTreePath}:{kind:`file`,fromPath:fj(a.sourcePath),toPath:fj(a.destinationTreePath)},c=await ve(await fetch(`/api/rename-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(s)}),r({id:`dOHMA0`}));if(!c.ok){X.error(c.title),sn(),U(null);return}let l=A(Xr,c.body,`rename-path:drop`,{renamed:[],renamedAssets:[]});e=e.concat(l.renamed),n=n.concat(l.renamedAssets),t&&i.push({fromPath:hj(a.sourcePath),toPath:hj(a.destinationTreePath)})}try{await sr(e,i,n,a)}catch(i){console.warn(`[FileTree] post-move reconciliation failed`,{err:i,operationCount:t.length,renamedCount:e.length,renamedAssetCount:n.length}),X.error(r({id:`8OxKZy`}))}U(null)}catch(e){console.warn(`[FileTree] move failed:`,e),X.error(r({id:`HIb0vl`})),sn(),U(null)}}},t[154]=r,t[155]=sr,t[156]=sn,t[157]=lr):lr=t[157];let ur=lr,dr;t[158]!==r||t[159]!==b||t[160]!==sn?(dr=async function(e,t,n){if(e.length===0||Me.current!==null)return;let i=()=>{Me.current=null,U(null)};Me.current=n,U(n),F(null);let a=[],o=0,s=0;for(let n of e){let e=new FormData;e.append(`file`,n),e.append(`parentDocName`,Nj(t,n.name||`upload`));try{let i=await ve(await fetch(`/api/upload`,{method:`POST`,body:e}),r({id:`4Gz2wC`}));if(!i.ok){s+=1,X.error(i.title,{description:n.name});continue}let c=A(nr,i.body,`upload:drop`,null);if(c===null){s+=1,X.error(r({id:`4Gz2wC`}),{description:n.name});continue}let l=Pj(t,c);if(c.deduped===!0){s+=1,X.error(r({id:`4sKwf6`}),{description:l});continue}o+=1;let u=Lj(l,n);u&&a.push(u)}catch(e){let t=e;s+=1,console.warn(`[FileTree] external file upload failed:`,t),X.error(t instanceof TypeError?r({id:`HIb0vl`}):r({id:`4Gz2wC`}),{description:n.name})}}try{if(a.length>0){for(let e of a)ls(e)&&b(e.docName);j(e=>{let t=new Set(e.map(pj)),n=!1,r=[...e];for(let e of a){let i=pj(e);Pe.current.set(i,Date.now()),!t.has(i)&&(t.add(i),r.push(e),n=!0)}return n?(sn(r),_n(r),r):e})}o>0&&(is([`files`,`backlinks`,`graph`]),Ke.current?.(),X.success(Ko._({id:`v75Em9`,values:{uploadedCount:o}}),{description:t||r({id:`RSqaSd`})})),s>0&&F(o>0?Ko._({id:`yH7T4q`,values:{failedCount:s}}):r({id:`4Gz2wC`})),i()}catch(e){let t=e,n=r({id:`VcqWBy`});console.warn(`[FileTree] upload post-upload reconciliation failed:`,t),X.error(n),F(n),i()}},t[158]=r,t[159]=b,t[160]=sn,t[161]=dr):dr=t[161];let fr=dr,pr;t[162]===Symbol.for(`react.memo_cache_sentinel`)?(pr=function(e){ee({parentDir:e})},t[162]=pr):pr=t[162];let mr=pr,hr;t[163]!==r||t[164]!==b||t[165]!==On||t[166]!==En||t[167]!==Ut||t[168]!==D||t[169]!==T||t[170]!==sn||t[171]!==qt?(hr=async function(e,t,n){if(Me.current)return;let i=Se.current;i&&En(i);try{let i=kj(e,t,[...qt,...Qt.current]);U(i.renamePath),Me.current=i.renamePath;let a=window.location.hash,o;if(e===`file`){let e=Aj(`file`,i.addPath),t={path:e};n?.template&&(t.template=n.template);let a=await ve(await fetch(`/api/create-page`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),r({id:`fJgQHX`}));if(!a.ok){X.error(a.title),U(null),Me.current=null;return}let s=fj(e),c=A(Qr,a.body,`create-page`,{docName:s}).docName;o=c;let l={kind:`document`,docName:c,docExt:e.toLowerCase().endsWith(`.mdx`)?`.mdx`:`.md`,modified:new Date().toISOString(),size:0};b(c),j(e=>{if(e.some(e=>ls(e)&&e.docName===c))return e;let t=[...e,l];return _n(t),Pe.current.set(pj(l),Date.now()),t}),is([`files`,`backlinks`,`graph`]),T(c)}else{let e=hj(i.addPath),t=await ve(await fetch(`/api/create-folder`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})}),r({id:`K1ckLX`}));if(!t.ok){X.error(t.title),U(null),Me.current=null;return}o=A(Pn,t.body,`create-folder`,{path:e}).path;let n={kind:`folder`,path:o,modified:new Date().toISOString(),size:0};j(e=>{if(e.some(e=>Jo(e)&&e.path===o))return e;let t=[...e,n];return _n(t),Pe.current.set(pj(n),Date.now()),t}),is([`files`]),D(o)}let s=!1,c=e=>{if(e.key!==`Enter`)return;let t=Se.current;!t||t.renamePath!==i.renamePath||queueMicrotask(()=>En(t))};document.addEventListener(`keydown`,c,!0),Se.current={kind:e,renamePath:i.renamePath,createdPath:o,previousHash:a,disposeCommitListener:()=>{s||(s=!0,document.removeEventListener(`keydown`,c,!0))}},U(null),Me.current=null,Ut.add(i.addPath),Ut.startRenaming(i.renamePath,{removeIfCanceled:!0})}catch(e){console.warn(`[FileTree] create placeholder failed:`,e),X.error(r({id:`S6l5dv`}));let t=Se.current;t?await On(t):En(),U(null),Me.current=null,sn()}},t[163]=r,t[164]=b,t[165]=On,t[166]=En,t[167]=Ut,t[168]=D,t[169]=T,t[170]=sn,t[171]=qt,t[172]=hr):hr=t[172];let gr=hr,_r;t[173]===Ut?_r=t[174]:(_r=function(e){let t=gj(e);(0,Q.startTransition)(()=>{for(let e of Qt.current)if(e===t||e.startsWith(t)){let t=OW(Ut.getItem(e));t&&t.expand()}})},t[173]=Ut,t[174]=_r);let yr=_r,br;t[175]===Ut?br=t[176]:(br=function(e){let t=gj(e),n=new Set(xe.current);(0,Q.startTransition)(()=>{for(let e of[...Qt.current].reverse())if((e===t||e.startsWith(t))&&!n.has(e)){let t=OW(Ut.getItem(e));t&&t.collapse()}})},t[175]=Ut,t[176]=br);let xr=br,Sr;t[177]!==fe||t[178]!==$t||t[179]!==o||t[180]!==c||t[181]!==_e||t[182]!==H||t[183]!==On||t[184]!==dn||t[185]!==k||t[186]!==Zt||t[187]!==ur||t[188]!==cr||t[189]!==Gt||t[190]!==x||t[191]!==wn||t[192]!==pn||t[193]!==Mt||t[194]!==jt||t[195]!==qt||t[196]!==fr?(Sr=()=>{le.current=k,ue.current=x,he.current=o,$e.current=c,ye.current=_e,Me.current=H,We.current=jt,Ge.current=Mt,Yt.current=qt,Qt.current=Zt,xe.current=$t,He.current=dn,Ue.current=pn,Ce.current=On,je.current=(e,t,n)=>{fr(e,t,n)},Je.current=e=>{if(Ee.current||De.current||e.length!==1)return;let t=e[0];t&&(ie(!1),fe(Gt(t),k))},Xe.current=e=>{wn(e)||X.error(e)},Ye.current=cr,Qe.current=ur},t[177]=fe,t[178]=$t,t[179]=o,t[180]=c,t[181]=_e,t[182]=H,t[183]=On,t[184]=dn,t[185]=k,t[186]=Zt,t[187]=ur,t[188]=cr,t[189]=Gt,t[190]=x,t[191]=wn,t[192]=pn,t[193]=Mt,t[194]=jt,t[195]=qt,t[196]=fr,t[197]=Sr):Sr=t[197],(0,Q.useLayoutEffect)(Sr);let Cr,wr;t[198]===Ut?(Cr=t[199],wr=t[200]):(Cr=()=>{let e=e=>{let t=(e.metaKey||e.ctrlKey)&&!e.altKey,n=e.key.toLowerCase(),r=t&&n===`a`,i=t&&!e.shiftKey&&n===`d`;if(!r&&!i||VG(e.target))return;let a=qe.current,o=e.target,s=document.activeElement,c=o instanceof Node&&a?.contains(o),l=s instanceof Node&&a?.contains(s);if(!c&&!l)return;if(i){let t=Ut.getFocusedPath()??Ut.getSelectedPaths()[0]??null;if(!t)return;let n=Ut.getItem(t)??Ut.getItem(gj(t)),r=n?.isDirectory()?gj(hj(n.getPath())):t;if(ye.current.has(r))return;Sn.current(LG(r,le.current)),e.preventDefault(),e.stopPropagation();return}let u=new Set([...Qt.current,...Yt.current]);Ee.current=!0;for(let e of u)e&&Ut.getItem(e)?.select();queueMicrotask(()=>{Ee.current=!1}),e.preventDefault(),e.stopPropagation()};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},wr=[Ut],t[198]=Ut,t[199]=Cr,t[200]=wr),(0,Q.useEffect)(Cr,wr);let Tr,Er;t[201]!==k.length||t[202]!==M?(Tr=()=>{if(M||k.length===0)return;let e=qe.current?.querySelector(CP)?.shadowRoot;if(!e)return;let t=oK,n=()=>{for(let n of e.querySelectorAll(`[data-item-path]`)){let e=n.dataset.itemPath;if(!e)continue;let r=t(e);n.title!==r&&(n.title=r)}let n=e.querySelector(`[data-type="context-menu-anchor"]`);if(n){let r=e.querySelector(`[data-item-context-hover="true"][data-item-path]`)?.dataset.itemPath,i=r?t(r):``;n.title!==i&&(n.title=i)}};n();let r=new MutationObserver(n);return r.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`data-item-path`,`data-item-context-hover`]}),()=>r.disconnect()},Er=[M,k.length],t[201]=k.length,t[202]=M,t[203]=Tr,t[204]=Er):(Tr=t[203],Er=t[204]),(0,Q.useEffect)(Tr,Er);let Dr,Ar;t[205]!==k.length||t[206]!==M?(Dr=()=>{if(M||k.length===0)return;let e=qe.current?.querySelector(CP)?.shadowRoot;if(!e)return;let t=()=>BU(e);t();let n=new MutationObserver(t);return n.observe(e,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:[`data-item-path`]}),()=>n.disconnect()},Ar=[M,k.length],t[205]=k.length,t[206]=M,t[207]=Dr,t[208]=Ar):(Dr=t[207],Ar=t[208]),(0,Q.useEffect)(Dr,Ar);let jr,Mr;t[209]!==k.length||t[210]!==M?(jr=()=>{if(M||k.length===0)return;let e=qe.current?.querySelector(CP)?.shadowRoot;if(!e)return;let t=()=>aW(e);t();let n=new MutationObserver(t);return n.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`data-item-path`]}),()=>n.disconnect()},Mr=[M,k.length],t[209]=k.length,t[210]=M,t[211]=jr,t[212]=Mr):(jr=t[211],Mr=t[212]),(0,Q.useEffect)(jr,Mr);let Nr;t[213]===Symbol.for(`react.memo_cache_sentinel`)?(Nr={folderCount:0,expandedCount:0},t[213]=Nr):Nr=t[213];let Pr=(0,Q.useRef)(Nr),Fr=(0,Q.useRef)(gr),Ir=(0,Q.useRef)(mr),Lr;t[214]===gr?Lr=t[215]:(Lr=()=>{Fr.current=gr,Ir.current=mr},t[214]=gr,t[215]=Lr),(0,Q.useEffect)(Lr);let Rr,zr;t[216]===Ut?(Rr=t[217],zr=t[218]):(Rr=()=>({startCreating(e,t){Fr.current(e,t)},startCreatingFromTemplate(e){Ir.current(e)},createFromTemplate(e,t){Fr.current(`file`,e,{template:t})},expandAll(){(0,Q.startTransition)(()=>{for(let e of Qt.current){let t=OW(Ut.getItem(e));t&&t.expand()}})},collapseAll(){let e=new Set(xe.current);(0,Q.startTransition)(()=>{for(let t of[...Qt.current].reverse()){if(e.has(t))continue;let n=OW(Ut.getItem(t));n&&n.collapse()}})},getFolderState(){let e=Qt.current,t=0;for(let n of e)OW(Ut.getItem(n))?.isExpanded()&&t++;let n=e.length,r=Pr.current;if(r.folderCount===n&&r.expandedCount===t)return r;let i={folderCount:n,expandedCount:t};return Pr.current=i,i},isCreationTargetCleared(){return ae.current},subscribe(e){ce.current.add(e);let t=Ut.subscribe(e);return()=>{ce.current.delete(e),t()}}}),zr=[Ut],t[216]=Ut,t[217]=Rr,t[218]=zr),(0,Q.useImperativeHandle)(n,Rr,zr);let Br;t[219]!==En||t[220]!==d||t[221]!==l||t[222]!==Ut?(Br=async function(e,t,n){let r=HG(e,le.current,Qt.current),i=Se.current;i&&e.some(e=>UG(e,i))&&(i.kind===`file`?r.docNames.add(i.createdPath):r.folderPaths.add(i.createdPath),En(i));let a=new Set([...r.docNames,...t]),o=new Set([...r.folderPaths,...n]),s=new Set([...r.assetPaths,...e.filter(aK).map(iK)]);l([...[...a].map(rK),...[...o].map(nK),...[...s].map(tK)],{force:!0}),await Promise.all([...a].map(e=>d(e)));for(let t of e){let e=t.kind===`folder`?gj(t.path):t.kind===`asset`?t.path:dj(t.path,t.docExt);Ut.getItem(e)&&Ut.remove(e,t.kind===`folder`?{recursive:!0}:void 0)}j(e=>{let t=Wj(e,[...a],void 0,[...s]);for(let e of o)t=Wj(t,[],e);return _n(t),t}),is([`files`,`backlinks`,`graph`])},t[219]=En,t[220]=d,t[221]=l,t[222]=Ut,t[223]=Br):Br=t[223];let Vr=Br,Hr;t[224]!==r||t[225]!==Vr?(Hr=async function(e){let t=[],n=[],i=[];for(let a of e){let e=a.kind;U(a.path);let o=await ve(await fetch(`/api/delete-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:e,path:a.path})}),r({id:`7JtSLi`}));if(!o.ok)return i.length>0&&await Vr(i,t,n),X.error(o.title),!1;let s=A(Qn,o.body,`delete-path`,{deletedDocNames:[]});t.push(...s.deletedDocNames),e===`folder`&&n.push(a.path),i.push(a)}return await Vr(i,t,n),!0},t[224]=r,t[225]=Vr,t[226]=Hr):Hr=t[226];let Ur=Hr,Wr;t[227]===Symbol.for(`react.memo_cache_sentinel`)?(Wr=async function(e,t,n){let r=[],i=[];for(let a of e){U(a.path);let e=Yj(a,n),o=await t.shell.trashItem(e);o.ok?r.push(a):i.push({kind:a.kind,path:a.path,name:a.name,reason:xW(o.reason),detail:o.detail})}return{trashed:r,failed:i}},t[227]=Wr):Wr=t[227];let Gr=Wr,Kr;t[228]===r?Kr=t[229]:(Kr=async function(e){let t=[],n=[],i=[];for(let a of e){let e=a.kind;try{let o=await ve(await fetch(`/api/trash/cleanup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:e,path:a.path})}),r({id:`DVh_Tb`}));if(!o.ok){console.warn(`[FileTree] trash-cleanup failed`,{target:`${a.kind}:${a.path}`,reason:o.title}),i.push({target:a,reason:o.title});continue}let s=A($r,o.body,`trash-cleanup`,{deletedDocNames:[]});t.push(...s.deletedDocNames),e===`folder`&&n.push(a.path)}catch(e){let t=e;console.warn(`[FileTree] trash-cleanup threw`,{target:`${a.kind}:${a.path}`,err:t}),i.push({target:a,reason:r({id:`r4R7AZ`})})}}if(i.length>0){let e=i.length;X.error(r({id:`IrB5AK`,values:{failedCount:e}}),{description:r({id:`vEJDlt`})})}return i.length===e.length&&e.length>0?null:{deletedDocNames:t,deletedFolderPaths:n}},t[228]=r,t[229]=Kr);let qr=Kr,Jr;t[230]!==r||t[231]!==J||t[232]!==Vr||t[233]!==Ur||t[234]!==qr||t[235]!==sn||t[236]!==te?(Jr=async function(e){let t=e.map(e=>Gj(e,le.current)),n=t[0];if(!n)return;let i=J.filter(e=>t.some(t=>{if(t.kind===`file`){let n=`${t.path}${t.docExt??`.md`}`;return e.file===n}return t.kind===`folder`?e.file.startsWith(`${t.path}/`):!1}));if(i.length>0){let e=i.slice(0,3).map(eK),t=i.length>e.length?`, +${i.length-e.length} more`:``;X.error(`Cannot delete files with unresolved conflicts`,{description:`Resolve the conflict on ${e.join(`, `)}${t} before deleting.`});return}U(n.path),G(null);let a=typeof window<`u`?window.okDesktop:void 0;try{if(a&&te){let{trashed:e,failed:n}=await Gr(t,a,te);if(e.length>0){let t=await qr(e);t?await Vr(e,t.deletedDocNames,t.deletedFolderPaths):await Vr(e,e.filter($G).map(QG),e.filter(ZG).map(XG))}n.length>0&&q({failed:n,originalTargets:[...t]}),U(null)}else{let e=await Ur(t);U(null),e||sn()}}catch(e){let t=e,n=t instanceof Error?t.message:String(t);console.warn(`[FileTree] delete failed:`,t),X.error(r({id:`0eHrMb`}),{description:n}),U(null),sn()}},t[230]=r,t[231]=J,t[232]=Vr,t[233]=Ur,t[234]=qr,t[235]=sn,t[236]=te,t[237]=Jr):Jr=t[237];let Yr=Jr,Zr;t[238]!==r||t[239]!==Ur||t[240]!==sn||t[241]!==K?(Zr=async function(){if(!K)return;let e=new Set(K.failed.map(YG)),t=K.originalTargets.filter(t=>e.has(`${t.kind}:${t.path}`));if(q(null),t.length!==0){U(t[0]?.path??null);try{let e=await Ur(t);U(null),e||sn()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);console.warn(`[FileTree] hard-delete fallback failed:`,t),X.error(r({id:`0eHrMb`}),{description:n}),U(null),sn()}}},t[238]=r,t[239]=Ur,t[240]=sn,t[241]=K,t[242]=Zr):Zr=t[242];let ei=Zr,ti;t[243]!==Yr||t[244]!==K?(ti=async function(){if(!K)return;let e=new Set(K.failed.map(JG)),t=K.originalTargets.filter(t=>e.has(`${t.kind}:${t.path}`));q(null),await Yr(t)},t[243]=Yr,t[244]=K,t[245]=ti):ti=t[245];let ni=ti,ri=(0,Q.useRef)(Yr),ii;t[246]===Yr?ii=t[247]:(ii=()=>{ri.current=Yr},t[246]=Yr,t[247]=ii),(0,Q.useEffect)(ii);let oi,ci;t[248]===Symbol.for(`react.memo_cache_sentinel`)?(oi=()=>FW(e=>{if(e.kind===`doc`||e.kind===`folder-index`){let t=e.docName,n=le.current.find(e=>ls(e)&&e.docName===t);ri.current([{kind:`file`,path:t,name:t.split(`/`).pop()??t,docExt:n?.docExt}]);return}if(e.kind===`folder`){ri.current([{kind:`folder`,path:e.folderPath,name:e.folderPath.split(`/`).pop()??e.folderPath}]);return}if(e.kind===`asset`){ri.current([{kind:`asset`,path:e.assetPath,name:e.assetPath.split(`/`).pop()??e.assetPath}]);return}console.warn(JSON.stringify({event:`file-tree-menu-action-delete-unsupported-kind`,kind:e.kind}))}),ci=[],t[248]=oi,t[249]=ci):(oi=t[248],ci=t[249]),(0,Q.useEffect)(oi,ci);let li,ui;t[250]===Symbol.for(`react.memo_cache_sentinel`)?(li=()=>zW(e=>{if(e.kind===`doc`||e.kind===`folder-index`){let t=e.docName,n=le.current.find(e=>ls(e)&&e.docName===t);Sn.current({kind:`file`,path:t,name:t.split(`/`).pop()??t,docExt:n?.docExt});return}if(e.kind===`folder`){Sn.current({kind:`folder`,path:e.folderPath,name:e.folderPath.split(`/`).pop()??e.folderPath});return}console.warn(JSON.stringify({event:`file-tree-menu-action-duplicate-unsupported-kind`,kind:e.kind}))}),ui=[],t[250]=li,t[251]=ui):(li=t[250],ui=t[251]),(0,Q.useEffect)(li,ui);let di,fi;t[252]===Ut?(di=t[253],fi=t[254]):(di=()=>LW(e=>{if(e.kind===`doc`||e.kind===`folder-index`){let t=e.docName,n=dj(t,le.current.find(e=>ls(e)&&e.docName===t)?.docExt);Ut.startRenaming(n);return}if(e.kind===`folder`){Ut.startRenaming(e.folderPath);return}if(e.kind===`asset`){Ut.startRenaming(e.assetPath);return}console.warn(JSON.stringify({event:`file-tree-menu-action-rename-unsupported-kind`,kind:e.kind}))}),fi=[Ut],t[252]=Ut,t[253]=di,t[254]=fi),(0,Q.useEffect)(di,fi);let pi;t[255]===Symbol.for(`react.memo_cache_sentinel`)?(pi=function(){let e=Te.current;e&&lG(e),Te.current=null},t[255]=pi):pi=t[255];let mi=pi,hi;t[256]===g?hi=t[257]:(hi=function(e){let t=bK(e.nativeEvent);if(!t||t.endsWith(`/`)){mi();return}let n=fj(t),r=le.current.find(e=>pj(e)===t);if(r&&Io(r)){mi();return}if(r&&ls(r)&&kr(r.size)){mi();return}Te.current!==n&&(mi(),Te.current=n,cG(n,e=>g(e)))},t[256]=g,t[257]=hi);let gi=hi,_i;t[258]!==fe||t[259]!==Ut||t[260]!==D?(_i=function(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=xK(e.nativeEvent);if(!t){wK(e.nativeEvent)&&ie(!0);return}if(t.getAttribute(`aria-selected`)!==`true`)return;let n=t.dataset.itemPath;if(!n)return;let r=t.dataset.itemType===`folder`?gj(n):n;if(Ut.getSelectedPaths().length!==1)return;if(t.dataset.itemType===`folder`){let e=hj(r);if(window.location.hash===zo(e))return;queueMicrotask(()=>D(e));return}let i=fj(r);window.location.hash!==Go(i)&&queueMicrotask(()=>fe(r))},t[258]=fe,t[259]=Ut,t[260]=D,t[261]=_i):_i=t[261];let vi=_i,yi;t[262]===Symbol.for(`react.memo_cache_sentinel`)?(yi=function(e){Fj(e.nativeEvent)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,tt(!0))},t[262]=yi):yi=t[262];let bi=yi,xi;t[263]===Symbol.for(`react.memo_cache_sentinel`)?(xi=function(e){let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||tt(!1)},t[263]=xi):xi=t[263];let Si=xi,Ci;t[264]===fr?Ci=t[265]:(Ci=function(e){if(!Fj(e.nativeEvent))return;let t=Ij(e.nativeEvent);t.length!==0&&(e.preventDefault(),e.stopPropagation(),tt(!1),fr(t,``,kG))},t[264]=fr,t[265]=Ci);let wi=Ci;if(M){let e;return t[266]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(EK,{}),t[266]=e):e=t[266],e}let Ti;t[267]!==r||t[268]!==I||t[269]!==R?(Ti=I?r(R?{id:`H-vDm3`}:{id:`09Tv5j`}):null,t[267]=r,t[268]=I,t[269]=R,t[270]=Ti):Ti=t[270];let Ei=Ti;if(k.length===0){if(Ei!==null){let e;return t[271]===Ei?e=t[272]:(e=(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-8`,children:(0,Z.jsx)(`span`,{role:`status`,className:`select-none text-sidebar-foreground/50 text-sm`,children:Ei})}),t[271]=Ei,t[272]=e),e}if(P){let e;return t[273]===P?e=t[274]:(e=(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-8`,children:(0,Z.jsx)(`span`,{role:`alert`,className:`select-none text-sidebar-foreground/50 text-sm`,children:P})}),t[273]=P,t[274]=e),e}let e;t[275]===r?e=t[276]:(e=r({id:`5ZB7XC`}),t[275]=r,t[276]=e);let n=et&&`bg-primary/5 ring-2 ring-primary/70 ring-inset`,i;t[277]===n?i=t[278]:(i=ai(`flex flex-1 flex-col items-center justify-center gap-3 rounded-md py-8`,n),t[277]=n,t[278]=i);let a;t[279]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(`span`,{className:`select-none text-sidebar-foreground/30 text-sm`,children:(0,Z.jsx)(s,{id:`xiv-dW`})}),t[279]=a):a=t[279];let o;t[280]===gr?o=t[281]:(o=()=>gr(`file`,``),t[280]=gr,t[281]=o);let c;t[282]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(s,{id:`6ibbCg`}),t[282]=c):c=t[282];let l;t[283]===o?l=t[284]:(l=(0,Z.jsx)(si,{variant:`link`,size:`sm`,className:`font-mono uppercase`,onClick:o,children:c}),t[283]=o,t[284]=l);let u;return t[285]!==wi||t[286]!==e||t[287]!==i||t[288]!==l?(u=(0,Z.jsxs)(`section`,{"aria-label":e,className:i,onDragOver:bi,onDragLeave:Si,onDrop:wi,children:[a,l]}),t[285]=wi,t[286]=e,t[287]=i,t[288]=l,t[289]=u):u=t[289],u}let Di=H!==null,Oi=W?.targets[0]??null,ki=null;if(B!==null){let e;if(t[290]!==a.locale||t[291]!==B){let n=new Intl.NumberFormat(a.locale).format(B);e=Ko._({id:`mSpqzP`,values:{truncatedShownCount:B,formattedCount:n}}),t[290]=a.locale,t[291]=B,t[292]=e}else e=t[292];ki=e}let Ai;t[293]!==P||t[294]!==Ei||t[295]!==ki?(Ai=(P||Ei!==null||ki!==null)&&(0,Z.jsxs)(Z.Fragment,{children:[Ei===null?P&&(0,Z.jsx)(OK,{kind:`error`,children:P}):(0,Z.jsx)(OK,{kind:`reconnecting`,children:Ei}),ki!==null&&(0,Z.jsx)(OK,{kind:`info`,children:ki})]}),t[293]=P,t[294]=Ei,t[295]=ki,t[296]=Ai):Ai=t[296];let ji;t[297]===y?ji=t[298]:(ji=FU(y),t[297]=y,t[298]=ji);let Mi=re?``:void 0,Pi;t[299]===Mi?Pi=t[300]:(Pi={[MG]:Mi},t[299]=Mi,t[300]=Pi);let Fi;t[301]!==Di||t[302]!==_e||t[303]!==xr||t[304]!==k||t[305]!==yr||t[306]!==Zt||t[307]!==xn||t[308]!==Dt||t[309]!==At||t[310]!==Ut||t[311]!==Ot||t[312]!==kt||t[313]!==gr||t[314]!==te?(Fi=(e,t)=>(0,Z.jsx)(WG,{item:e,context:t,anyActionBusy:Di,workspace:te,handoff:Dt,model:Ut,okignoreBinding:Ot,projectLocalBinding:kt,mergedConfig:At,onStartCreating:gr,onCreateFromTemplate:(e,t)=>gr(`file`,e,{template:t}),onDuplicate:xn,onDelete:e=>G({targets:e}),onExpandSubtree:yr,onCollapseSubtree:xr,folderTreePaths:Zt,isAsset:_e.has(e.path),documents:k}),t[301]=Di,t[302]=_e,t[303]=xr,t[304]=k,t[305]=yr,t[306]=Zt,t[307]=xn,t[308]=Dt,t[309]=At,t[310]=Ut,t[311]=Ot,t[312]=kt,t[313]=gr,t[314]=te,t[315]=Fi):Fi=t[315];let Ii;t[316]!==vi||t[317]!==gi||t[318]!==Ut||t[319]!==Ai||t[320]!==ji||t[321]!==Pi||t[322]!==Fi?(Ii=(0,Z.jsx)(`div`,{ref:qe,className:`flex min-h-0 flex-1 flex-col`,children:(0,Z.jsx)(kU,{header:Ai,model:Ut,style:ji,...Pi,onClickCapture:vi,onMouseMove:gi,onMouseLeave:mi,renderContextMenu:Fi})}),t[316]=vi,t[317]=gi,t[318]=Ut,t[319]=Ai,t[320]=ji,t[321]=Pi,t[322]=Fi,t[323]=Ii):Ii=t[323];let Li=!!W,Ri;t[324]===H?Ri=t[325]:(Ri=e=>{!e&&!H&&G(null)},t[324]=H,t[325]=Ri);let zi;t[326]!==r||t[327]!==H||t[328]!==W||t[329]!==Yr||t[330]!==Oi?(zi=W&&Oi&&(0,Z.jsx)(Ia,{...(()=>{let e=_W(typeof window<`u`&&window.okDesktop!=null?`electron`:`web`,W.targets);if(e)return{customTitle:e.title,customDescription:``,customDetail:e.detail,customConfirmLabel:e.confirmLabel,customConfirmLabelBusy:e.confirmLabelBusy,children:e.listedTargets?(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1 font-mono text-foreground text-xs`,children:e.listedTargets.map(qG)}):null};let t=W.targets.length,n=Oi.name;return{itemName:t===1?Oi.kind===`folder`?`${Oi.name}/`:Oi.kind===`file`?`${Oi.name}${Oi.docExt??`.md`}`:Oi.name:void 0,customTitle:t>1?r({id:`abiHje`}):void 0,customDescription:t>1?r({id:`WMIKXK`,values:{targetCount:t}}):Oi.kind===`folder`?r({id:`a5W0q0`,values:{folderName:n}}):void 0}})(),isSubmitting:H!==null,onDelete:()=>Yr(W.targets)}),t[326]=r,t[327]=H,t[328]=W,t[329]=Yr,t[330]=Oi,t[331]=zi):zi=t[331];let Bi;t[332]!==Li||t[333]!==Ri||t[334]!==zi?(Bi=(0,Z.jsx)(Eo,{open:Li,onOpenChange:Ri,children:zi}),t[332]=Li,t[333]=Ri,t[334]=zi,t[335]=Bi):Bi=t[335];let Vi=!!K,Hi;t[336]===H?Hi=t[337]:(Hi=e=>{!e&&!H&&q(null)},t[336]=H,t[337]=Hi);let Ui;t[338]!==H||t[339]!==ei||t[340]!==ni||t[341]!==K?(Ui=K&&(0,Z.jsx)(TW,{failedTargets:K.failed,isSubmitting:H!==null,onDeletePermanently:ei,onRetry:ni,onCancel:()=>q(null)}),t[338]=H,t[339]=ei,t[340]=ni,t[341]=K,t[342]=Ui):Ui=t[342];let Wi;t[343]!==Vi||t[344]!==Hi||t[345]!==Ui?(Wi=(0,Z.jsx)(Eo,{open:Vi,onOpenChange:Hi,children:Ui}),t[343]=Vi,t[344]=Hi,t[345]=Ui,t[346]=Wi):Wi=t[346];let Gi=Y!==null,Ki;t[347]===Symbol.for(`react.memo_cache_sentinel`)?(Ki=e=>{e||ee(null)},t[347]=Ki):Ki=t[347];let qi=Y?.parentDir??``,Ji;t[348]!==Gi||t[349]!==qi?(Ji=(0,Z.jsx)(ih,{open:Gi,onOpenChange:Ki,kind:`file`,initialDir:qi,defaultToTemplate:!0}),t[348]=Gi,t[349]=qi,t[350]=Ji):Ji=t[350];let Yi;return t[351]!==Ii||t[352]!==Bi||t[353]!==Wi||t[354]!==Ji?(Yi=(0,Z.jsxs)(Z.Fragment,{children:[Ii,Bi,Wi,Ji]}),t[351]=Ii,t[352]=Bi,t[353]=Wi,t[354]=Ji,t[355]=Yi):Yi=t[355],Yi}function qG(e){return(0,Z.jsx)(`li`,{"data-testid":`delete-target-row`,children:vW(e)},`${e.kind}:${e.path}`)}function JG(e){return`${e.kind}:${e.path}`}function YG(e){return`${e.kind}:${e.path}`}function XG(e){return e.path}function ZG(e){return e.kind===`folder`}function QG(e){return e.path}function $G(e){return e.kind===`file`}function eK(e){return e.file}function tK(e){return Lt(e)}function nK(e){return bt(e)}function rK(e){return He(e)}function iK(e){return e.path}function aK(e){return e.kind===`asset`}function oK(e){return e.endsWith(`/`)?e.slice(0,-1):e}function sK(e){return!!e}function cK(e){console.warn(`[FileTree] /api/workspace fetch failed:`,e)}function lK(e){console.warn(`[FileTree] unmount cleanup failed:`,e)}function uK(e){X.error(e)}function dK(){}function fK(e){return X.error(e)}function pK(){}function mK(){}function hK(){}function gK(){}function _K(){}async function vK(){}function yK(e){return pj(e)}function bK(e){return xK(e)?.dataset.itemPath??null}function xK(e){for(let t of e.composedPath())if(t instanceof HTMLElement&&t.dataset.itemPath)return t;return null}function SK(e){for(let t of e.composedPath())if(t instanceof HTMLElement&&t.matches(`[data-file-tree-virtualized-root]`))return t;return null}function CK(e){let t=xK(e);if(t){let e=t.dataset.itemPath;if(!e)return null;let n=t.dataset.itemType===`folder`,r=Mj(e,n);return{parentDir:r,row:t,root:null,busyPath:n?gj(r):e}}return wK(e)?{parentDir:``,row:null,root:SK(e),busyPath:kG}:null}function wK(e){for(let t of e.composedPath())if(t instanceof HTMLElement&&t.matches(`[data-file-tree-virtualized-scroll]`))return!0;return!1}var TK=[`w-3/4`,`w-2/3`,`w-4/5`,`w-1/2`,`w-3/5`,`w-2/3`];function EK(){let e=(0,$.c)(5),{_:t}=i(),n;e[0]===t?n=e[1]:(n=t({id:`5Tk8Fb`}),e[0]=t,e[1]=n);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=TK.map(DK),e[2]=r):r=e[2];let a;return e[3]===n?a=e[4]:(a=(0,Z.jsx)(`div`,{className:`flex flex-1 flex-col gap-1 px-2 py-2`,role:`status`,"aria-busy":`true`,"aria-label":n,children:r}),e[3]=n,e[4]=a),a}function DK(e,t){return(0,Z.jsxs)(`div`,{className:`flex h-6 items-center gap-2`,children:[(0,Z.jsx)(za,{className:`h-3 w-3 shrink-0 rounded-sm`}),(0,Z.jsx)(za,{className:`h-3 ${e}`})]},t)}function OK(e){let t=(0,$.c)(14),{kind:n,children:r}=e,i=n===`error`?ds:n===`reconnecting`?no:Oo,a=n===`error`?`alert`:`status`,o=n===`error`?`text-destructive`:`text-muted-foreground`,s;t[0]===o?s=t[1]:(s=ai(`mx-2 mb-1 flex items-start gap-1.5 rounded-md bg-muted/50 px-2 py-1.5 text-xs leading-snug`,o),t[0]=o,t[1]=s);let c=n===`reconnecting`&&`animate-spin motion-reduce:animate-none`,l;t[2]===c?l=t[3]:(l=ai(`mt-0.5 size-3.5 shrink-0`,c),t[2]=c,t[3]=l);let u;t[4]!==i||t[5]!==l?(u=(0,Z.jsx)(i,{"aria-hidden":`true`,className:l}),t[4]=i,t[5]=l,t[6]=u):u=t[6];let d;t[7]===r?d=t[8]:(d=(0,Z.jsx)(`span`,{className:`min-w-0`,children:r}),t[7]=r,t[8]=d);let f;return t[9]!==a||t[10]!==s||t[11]!==u||t[12]!==d?(f=(0,Z.jsxs)(`span`,{role:a,className:s,children:[u,d]}),t[9]=a,t[10]=s,t[11]=u,t[12]=d,t[13]=f):f=t[13],f}function kK(e){return e?Ko._({id:`wTcjov`}):null}function AK(e){let t=(0,$.c)(23),{_:n}=i(),r=Mh(),a=HM();if(r)return null;let{input:o,installStates:c,dispatch:l}=e,u=o===null,d,f,p,m,h,g;if(t[0]!==n||t[1]!==l||t[2]!==o||t[3]!==u||t[4]!==c||t[5]!==a){g=Symbol.for(`react.early_return_sentinel`);bb0:{let e=kK(u),r;t[12]===c?r=t[13]:(r=e=>c[e.id]?.installed===!0,t[12]=c,t[13]=r);let i=Fh.filter(r),_=a!==null;if(i.length===0&&!_){g=null;break bb0}f=rM,t[14]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsxs)(oM,{children:[(0,Z.jsx)(vi,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`O7_W_a`})]}),t[14]=h):h=t[14],d=sM,p=i.map(t=>{let r=!u,{displayName:i}=t,a=n(e?{id:`1ZpfyB`,values:{displayName:i,hint:e}}:{id:`WqLq6M`,values:{displayName:i}});return(0,Z.jsxs)(aM,{disabled:!r,onSelect:()=>{o&&l(t.id,o)},"data-testid":`empty-space-open-in-${t.id}`,"aria-label":a,children:[(0,Z.jsx)(ox,{id:t.id,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:t.displayName}),e?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},t.id)}),m=a===null?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(lM,{}),(0,Z.jsxs)(aM,{onSelect:()=>{o!==null&&a.launchInTerminal(o)},disabled:u,"data-testid":`empty-space-open-in-terminal`,"aria-label":n(e?{id:`LtVw4J`,values:{hint:e}}:{id:`AcK_r0`}),children:[(0,Z.jsx)(Kl,{className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:(0,Z.jsx)(s,{id:`AcK_r0`})}),e?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]})]})}t[0]=n,t[1]=l,t[2]=o,t[3]=u,t[4]=c,t[5]=a,t[6]=d,t[7]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=g}else d=t[6],f=t[7],p=t[8],m=t[9],h=t[10],g=t[11];if(g!==Symbol.for(`react.early_return_sentinel`))return g;let _;t[15]!==d||t[16]!==p||t[17]!==m?(_=(0,Z.jsxs)(d,{children:[p,m]}),t[15]=d,t[16]=p,t[17]=m,t[18]=_):_=t[18];let v;return t[19]!==f||t[20]!==h||t[21]!==_?(v=(0,Z.jsxs)(f,{children:[h,_]}),t[19]=f,t[20]=h,t[21]=_,t[22]=v):v=t[22],v}var jK=(e,t,n)=>cu(e,t,n,`ProjectSwitcher`);function MK(e){let t=(0,$.c)(96),{bridge:n}=e,{_:r}=i(),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],t[0]=a):a=t[0];let[o,c]=(0,Q.useState)(a),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(!1),h=Jk(),g=typeof window<`u`&&window.okDesktop!=null,_=(0,Q.useRef)(!1),v;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>{u(e),e||f(``)},t[1]=v):v=t[1];let y=v,b;t[2]!==r||t[3]!==n.project||t[4]!==l?(b=()=>{if(!l)return;let e=!1;return jK(async()=>{let t=await n.project.listRecent();e||c(t)},r({id:`fYKgzG`})),()=>{e=!0}},t[2]=r,t[3]=n.project,t[4]=l,t[5]=b):b=t[5];let x;t[6]!==r||t[7]!==n||t[8]!==l?(x=[l,n,r],t[6]=r,t[7]=n,t[8]=l,t[9]=x):x=t[9],(0,Q.useEffect)(b,x);let S;t[10]!==r||t[11]!==n.project?(S=e=>{u(!1),jK(()=>n.project.open({path:e,target:`new-window`,entryPoint:`recents`}),r({id:`SUOoXn`}))},t[10]=r,t[11]=n.project,t[12]=S):S=t[12];let C=S,w;t[13]!==r||t[14]!==n.dialog||t[15]!==n.project?(w=()=>{u(!1),jK(async()=>{let e=await n.dialog.openFolder();e&&await n.project.open({path:e,target:`new-window`,entryPoint:`pick-existing`})},r({id:`gmJ0An`}))},t[13]=r,t[14]=n.dialog,t[15]=n.project,t[16]=w):w=t[16];let T=w,E;t[17]!==r||t[18]!==n.navigator?(E=()=>{u(!1),jK(()=>n.navigator.open(),r({id:`jol95m`}))},t[17]=r,t[18]=n.navigator,t[19]=E):E=t[19];let O=E,k;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>{u(!1),m(!0)},t[20]=k):k=t[20];let A=k,j=n.config.projectPath,N,P,F,I,L,R,z,B,V,H,U;if(t[21]!==r||t[22]!==h||t[23]!==n.config.projectName||t[24]!==n.config.projectPath||t[25]!==j||t[26]!==l||t[27]!==C||t[28]!==o||t[29]!==d){let e;t[41]===j?e=t[42]:(e=e=>e.path!==j,t[41]=j,t[42]=e);let i=o.filter(e),a=d.trim().toLowerCase(),c=a?i.filter(e=>e.name.toLowerCase().includes(a)||e.path.toLowerCase().includes(a)):i;P=ro,z=l,B=y,V=!1;let u=h!==null&&`h-auto py-1.5`,p;t[43]===u?p=t[44]:(p=ai(`justify-between text-sidebar-foreground/70 hover:text-sidebar-foreground! data-open:hover:text-sidebar-foreground!`,u),t[43]=u,t[44]=p);let m;t[45]===r?m=t[46]:(m=r({id:`zZ_I5K`}),t[45]=r,t[46]=m);let v;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(v=g?()=>{_.current=!0}:void 0,t[47]=v):v=t[47];let b;t[48]===l?b=t[49]:(b=g?()=>{if(_.current){_.current=!1;return}y(!l)}:void 0,t[48]=l,t[49]=b);let x;t[50]===n.config.projectName?x=t[51]:(x=(0,Z.jsx)(`span`,{className:`truncate`,children:n.config.projectName}),t[50]=n.config.projectName,t[51]=x);let S;t[52]===h?S=t[53]:(S=h===null?null:(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 text-xs text-sidebar-foreground/50 group-hover/menu-button:text-sidebar-foreground`,"data-testid":`project-switcher-branch`,children:[(0,Z.jsx)(Ce,{"aria-hidden":`true`,className:`size-3! shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:h})]}),t[52]=h,t[53]=S);let w;t[54]!==x||t[55]!==S?(w=(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[x,S]}),t[54]=x,t[55]=S,t[56]=w):w=t[56];let T;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(Qc,{"aria-hidden":`true`,className:`opacity-60`}),t[57]=T):T=t[57],t[58]!==n.config.projectPath||t[59]!==p||t[60]!==m||t[61]!==b||t[62]!==w?(H=(0,Z.jsx)(ao,{asChild:!0,children:(0,Z.jsxs)(Hk,{className:p,"data-testid":`project-switcher-trigger`,"aria-label":m,title:n.config.projectPath,onPointerDown:v,onClick:b,children:[w,T]})}),t[58]=n.config.projectPath,t[59]=p,t[60]=m,t[61]=b,t[62]=w,t[63]=H):H=t[63],N=$a,U=`start`,F=`top`,I=`min-w-[260px]`,L=`project-switcher-menu`,R=i.length===0?(0,Z.jsx)(Ta,{className:`font-normal text-muted-foreground text-xs`,children:(0,Z.jsx)(s,{id:`HNnVG1`})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(cC,{className:`mb-1 h-8 border-0 shadow-none has-[[data-slot=input-group-control]:focus-visible]:ring-0`,children:[(0,Z.jsx)(pC,{"aria-label":r({id:`H8Ng4Z`}),placeholder:r({id:`8S1E33`}),value:d,onChange:e=>f(e.target.value),onKeyDown:NK,"data-testid":`project-switcher-search`}),(0,Z.jsx)(uC,{children:(0,Z.jsx)(te,{"aria-hidden":`true`})})]}),(0,Z.jsx)(Ka,{}),c.length===0?(0,Z.jsx)(Ta,{className:`font-normal text-muted-foreground text-xs`,role:`status`,"aria-live":`polite`,children:(0,Z.jsx)(s,{id:`pEQFsW`})}):(0,Z.jsx)(`div`,{className:`max-h-64 overflow-x-hidden overflow-y-auto overscroll-contain subtle-scrollbar scroll-fade-mask`,children:c.slice(0,10).map(e=>(0,Z.jsxs)(Fa,{disabled:e.missing,onSelect:()=>C(e.path),className:`flex w-full min-w-0 flex-col items-start gap-0.5`,"data-testid":`project-switcher-recent-${e.path}`,children:[(0,Z.jsx)(`span`,{className:`w-full truncate font-medium text-sm`,title:e.name,children:e.name}),(0,Z.jsxs)(`span`,{className:`w-full truncate text-muted-foreground text-xs`,title:e.path,children:[e.path,e.missing?r({id:`2Znqb1`}):``]})]},e.path))})]}),t[21]=r,t[22]=h,t[23]=n.config.projectName,t[24]=n.config.projectPath,t[25]=j,t[26]=l,t[27]=C,t[28]=o,t[29]=d,t[30]=N,t[31]=P,t[32]=F,t[33]=I,t[34]=L,t[35]=R,t[36]=z,t[37]=B,t[38]=V,t[39]=H,t[40]=U}else N=t[30],P=t[31],F=t[32],I=t[33],L=t[34],R=t[35],z=t[36],B=t[37],V=t[38],H=t[39],U=t[40];let W;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,Z.jsx)(Ka,{}),t[64]=W):W=t[64];let G,K;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,Z.jsx)(ke,{"aria-hidden":`true`,className:`text-muted-foreground`}),K=(0,Z.jsx)(s,{id:`PVUn_c`}),t[65]=G,t[66]=K):(G=t[65],K=t[66]);let q;t[67]===T?q=t[68]:(q=(0,Z.jsxs)(Fa,{onSelect:T,"data-testid":`project-switcher-open-folder`,children:[G,K]}),t[67]=T,t[68]=q);let J,Y;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,Z.jsx)(D,{"aria-hidden":`true`,className:`text-muted-foreground`}),Y=(0,Z.jsx)(s,{id:`xaDWAI`}),t[69]=J,t[70]=Y):(J=t[69],Y=t[70]);let ee;t[71]===O?ee=t[72]:(ee=(0,Z.jsxs)(Fa,{onSelect:O,"data-testid":`project-switcher-switch-project`,children:[J,Y]}),t[71]=O,t[72]=ee);let ne;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Z.jsxs)(Fa,{onSelect:A,"data-testid":`project-switcher-new-project`,children:[(0,Z.jsx)(M,{"aria-hidden":`true`,className:`text-muted-foreground`}),(0,Z.jsx)(s,{id:`gKi-a_`})]}),t[73]=ne):ne=t[73];let re;t[74]!==N||t[75]!==F||t[76]!==I||t[77]!==L||t[78]!==R||t[79]!==q||t[80]!==ee||t[81]!==U?(re=(0,Z.jsxs)(N,{align:U,side:F,className:I,"data-testid":L,children:[R,W,q,ee,ne]}),t[74]=N,t[75]=F,t[76]=I,t[77]=L,t[78]=R,t[79]=q,t[80]=ee,t[81]=U,t[82]=re):re=t[82];let ie;t[83]!==P||t[84]!==z||t[85]!==B||t[86]!==V||t[87]!==H||t[88]!==re?(ie=(0,Z.jsxs)(P,{open:z,onOpenChange:B,modal:V,children:[H,re]}),t[83]=P,t[84]=z,t[85]=B,t[86]=V,t[87]=H,t[88]=re,t[89]=ie):ie=t[89];let ae;t[90]!==n||t[91]!==p?(ae=(0,Z.jsx)(Id,{open:p,onOpenChange:m,bridge:n}),t[90]=n,t[91]=p,t[92]=ae):ae=t[92];let oe;return t[93]!==ie||t[94]!==ae?(oe=(0,Z.jsxs)(Z.Fragment,{children:[ie,ae]}),t[93]=ie,t[94]=ae,t[95]=oe):oe=t[95],oe}function NK(e){return e.stopPropagation()}function PK(e,t){let n=e instanceof Error?e:Error(String(e));console.warn(JSON.stringify({event:`jsx-render-failure`,component:`sidebarSearchPill`,rawComponentName:`sidebarSearchPill`,error:String(n),stack:t.componentStack})),Fn(`sidebarSearchPill`)}function FK(e){let t=(0,$.c)(8),{onClick:n,className:r}=e,i;t[0]===r?i=t[1]:(i=ai(`rounded-lg h-9 w-full justify-start gap-2 px-3 font-normal text-muted-foreground`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(te,{"aria-hidden":`true`}),t[2]=a):a=t[2];let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(`span`,{className:`flex-1 text-left text-sm`,children:(0,Z.jsx)(s,{id:`A1taO8`})}),t[3]=o):o=t[3];let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(Jt,{className:`text-foreground/70`,children:Ks(`command-palette`)}),t[4]=c):c=t[4];let l;return t[5]!==n||t[6]!==i?(l=(0,Z.jsxs)(si,{variant:`outline`,onClick:n,"data-telemetry-event":`ok.sidebar.search_pill.click`,className:i,children:[a,o,c]}),t[5]=n,t[6]=i,t[7]=l):l=t[7],l}function IK(e){let t=(0,$.c)(37),{notice:n,onDismiss:r}=e,{_:a}=i(),o=n.variant===`error`?`border-destructive/60 bg-sidebar-accent/30 text-muted-foreground`:n.variant===`success`?`border-emerald-500/40 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:`border-sidebar-border bg-sidebar-accent/30 text-muted-foreground`,s;t[0]!==a||t[1]!==n.dismissible||t[2]!==r?(s=n.dismissible===!1?null:(0,Z.jsx)(si,{variant:`ghost`,size:`icon`,className:`size-5 shrink-0 text-muted-foreground hover:text-sidebar-foreground`,"aria-label":a({id:`GUYwCr`}),onClick:r,children:(0,Z.jsx)(ps,{"aria-hidden":`true`,className:`size-3`})}),t[0]=a,t[1]=n.dismissible,t[2]=r,t[3]=s):s=t[3];let c=s,l=`shrink-0 text-xs font-medium underline underline-offset-2 ${n.variant===`success`?`decoration-emerald-500/40`:`decoration-muted-foreground/40`} hover:text-sidebar-foreground hover:decoration-sidebar-foreground`;if(n.secondaryAction){let e=`update-notice-${n.id}`,r=`flex flex-col gap-2 rounded-md border px-2 py-2 text-xs ${o}`,i;t[4]===n.body?i=t[5]:(i=(0,Z.jsx)(`span`,{className:`flex-1 leading-snug`,children:n.body}),t[4]=n.body,t[5]=i);let a;t[6]!==c||t[7]!==i?(a=(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[i,c]}),t[6]=c,t[7]=i,t[8]=a):a=t[8];let s;t[9]!==l||t[10]!==n.action?(s=n.action?(0,Z.jsx)(`button`,{type:`button`,className:l,onClick:()=>{n.action?.onClick()},children:n.action.label}):null,t[9]=l,t[10]=n.action,t[11]=s):s=t[11];let u;t[12]===n.secondaryAction?u=t[13]:(u=()=>{n.secondaryAction?.onClick()},t[12]=n.secondaryAction,t[13]=u);let d;t[14]!==l||t[15]!==n.secondaryAction.label||t[16]!==u?(d=(0,Z.jsx)(`button`,{type:`button`,className:l,onClick:u,children:n.secondaryAction.label}),t[14]=l,t[15]=n.secondaryAction.label,t[16]=u,t[17]=d):d=t[17];let f;t[18]!==s||t[19]!==d?(f=(0,Z.jsxs)(`div`,{className:`flex gap-3 pl-1`,children:[s,d]}),t[18]=s,t[19]=d,t[20]=f):f=t[20];let p;return t[21]!==e||t[22]!==r||t[23]!==a||t[24]!==f?(p=(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":e,className:r,children:[a,f]}),t[21]=e,t[22]=r,t[23]=a,t[24]=f,t[25]=p):p=t[25],p}let u=`update-notice-${n.id}`,d=`flex items-center gap-2 rounded-md border px-2 py-1.5 text-xs ${o}`,f;t[26]===n.body?f=t[27]:(f=(0,Z.jsx)(`span`,{className:`flex-1 leading-snug`,children:n.body}),t[26]=n.body,t[27]=f);let p;t[28]!==l||t[29]!==n.action?(p=n.action?(0,Z.jsx)(`button`,{type:`button`,className:l,onClick:()=>{n.action?.onClick()},children:n.action.label}):null,t[28]=l,t[29]=n.action,t[30]=p):p=t[30];let m;return t[31]!==c||t[32]!==u||t[33]!==d||t[34]!==f||t[35]!==p?(m=(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":u,className:d,children:[f,p,c]}),t[31]=c,t[32]=u,t[33]=d,t[34]=f,t[35]=p,t[36]=m):m=t[36],m}function LK(e){if(e.length===0)return null;let t=e[0];if(!t)return null;for(let n=1;n<e.length;n++){let r=e[n];r&&r.priority<t.priority&&(t=r)}return t}function RK(){let e=(0,$.c)(7),t=(0,Q.useSyncExternalStore)(sm,om,om),n;e[0]===t?n=e[1]:(n=LK(t),e[0]=t,e[1]=n);let r=n;if(!r)return null;let i;e[2]===r?i=e[3]:(i=()=>{r.onDismiss?.(),am(r.id)},e[2]=r,e[3]=i);let a;return e[4]!==r||e[5]!==i?(a=(0,Z.jsx)(`div`,{"data-testid":`update-notices-list`,children:(0,Z.jsx)(IK,{notice:r,onDismiss:i})}),e[4]=r,e[5]=i,e[6]=a):a=e[6],a}function zK(e,t,n){return e?.kind===`doc`&&t||e?.kind===`folder-index`&&t?gg(n.contentDir,_g(t),n.pathSeparator):e?.kind===`folder`?gg(n.contentDir,e.folderPath,n.pathSeparator):e?.kind===`asset`?gg(n.contentDir,e.assetPath,n.pathSeparator):n.contentDir}function BK(e,t){return(e?.kind===`doc`||e?.kind===`folder-index`)&&t?_g(t):e?.kind===`folder`?e.folderPath:e?.kind===`asset`?e.assetPath:``}function VK(e,t,n){return e===null?yg({workspace:n}):e.kind===`folder`?n?Sg({folderRelativePath:e.folderPath,workspace:n}):null:e.kind===`doc`||e.kind===`folder-index`?vg({docName:t,workspace:n}):null}var HK={folderCount:0,expandedCount:0},UK=`button, [role="button"], [role="menuitem"], input, textarea, select, a[href]`;function WK(e){return typeof Element>`u`||!(e instanceof Element)?!1:e.closest(UK)!==null}function GK(e){let t=(0,$.c)(2),{onOpenSearch:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(Wt,{name:`file-sidebar`,children:(0,Z.jsx)(qK,{onOpenSearch:n})}),t[0]=n,t[1]=r),r}var KK=e=>{let t=(0,$.c)(15),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({icon:n,label:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=(0,Z.jsx)(n,{"aria-hidden":`true`}),t[4]=n,t[5]=a);let o;t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(si,{variant:`ghost`,size:`icon-sm`,"aria-label":r,...i,children:a})}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9];let s;t[10]===r?s=t[11]:(s=(0,Z.jsx)(Ds,{children:r}),t[10]=r,t[11]=s);let c;return t[12]!==o||t[13]!==s?(c=(0,Z.jsxs)(As,{children:[o,s]}),t[12]=o,t[13]=s,t[14]=c):c=t[14],c};function qK(e){let t=(0,$.c)(188),{onOpenSearch:n}=e,{_:r}=i(),[a,o]=(0,Q.useState)(null),{activeDocName:c,activeTarget:l}=pt(),u;t[0]!==c||t[1]!==l?(u=l?.kind===`folder`||l?.kind===`folder-index`?l.folderPath:us(c),t[0]=c,t[1]=l,t[2]=u):u=t[2];let d=u,[f,p]=(0,Q.useState)(!1),m=f?``:d,h=typeof window<`u`&&window.okDesktop!=null,{state:g,toggleSidebar:_}=Ok(),v=Mh(),y=g===`expanded`,b=h&&g===`collapsed`,[x,S]=(0,Q.useState)(HK),C,w;t[3]===a?(C=t[4],w=t[5]):(C=()=>{if(a===null)return;let e=()=>{S(a.getFolderState()),p(a.isCreationTargetCleared())};return e(),a.subscribe(e)},w=[a],t[3]=a,t[4]=C,t[5]=w),(0,Q.useEffect)(C,w);let T,E;t[6]===a?(T=t[7],E=t[8]):(T=()=>{if(a!==null)return Yx(e=>{let t=e.initialDir??``;if(e.template){a.createFromTemplate(e.template.folder,e.template.name);return}a.startCreating(`file`,t)})},E=[a],t[6]=a,t[7]=T,t[8]=E),(0,Q.useEffect)(T,E);let D=x.folderCount>0,O=D&&x.expandedCount===x.folderCount,k=x.expandedCount===0,A=ea(``),j=ea(m===``?null:m),M=m===``?A:j,N=A.state.status===`ready`?(A.state.data.folder.templates_available?.length??0)>0:!0,P=M.state.status===`ready`?(M.state.data.folder.templates_available?.length??0)>0:!0,F=typeof window<`u`?window.okDesktop:void 0,I=po(),L=Kg().states,{dispatch:R}=Fg(),z;t[9]===I?z=t[10]:(z=yg({workspace:I}),t[9]=I,t[10]=z);let B=z,{projectLocalBinding:V,merged:H}=oe(),U=H?.appearance?.sidebar?.showHiddenFiles??!1,W=H?.appearance?.sidebar?.showAllFiles??!0,G=D&&!O,K=D&&!k,q=G||K,J=YK,Y;t[11]!==a||t[12]!==I?(Y=()=>{I&&a?.startCreating(`file`,``)},t[11]=a,t[12]=I,t[13]=Y):Y=t[13];let ee=Y,te;t[14]!==a||t[15]!==I?(te=e=>{I&&a?.createFromTemplate(``,e)},t[14]=a,t[15]=I,t[16]=te):te=t[16];let ne=te,re;t[17]!==a||t[18]!==I?(re=()=>{I&&a?.startCreating(`folder`,``)},t[17]=a,t[18]=I,t[19]=re):re=t[19];let ie=re,ae;t[20]===I?ae=t[21]:(ae=()=>{!I||!F||F.shell.showItemInFolder(I.contentDir)},t[20]=I,t[21]=ae);let se=ae,ce;t[22]!==r||t[23]!==I?(ce=async()=>{if(I)try{await navigator.clipboard.writeText(I.contentDir),X.success(r({id:`6_ZOw4`}),{description:I.contentDir})}catch(e){console.warn(`[FileSidebar] clipboard write failed:`,e),X.error(r({id:`vfRlCI`}))}},t[22]=r,t[23]=I,t[24]=ce):ce=t[24];let ue=ce,de;t[25]!==r||t[26]!==V?(de=e=>{if(V===null)return;let t=V.patch({appearance:{sidebar:{showHiddenFiles:e}}});t.ok||(console.warn(`[FileSidebar] showHiddenFiles toggle rejected:`,qr(t.error)),X.error(r({id:`P47EWZ`}),{description:qr(t.error)}))},t[25]=r,t[26]=V,t[27]=de):de=t[27];let fe=de,pe;t[28]!==r||t[29]!==V?(pe=e=>{if(V===null)return;let t=V.patch({appearance:{sidebar:{showAllFiles:e}}});t.ok||(console.warn(`[FileSidebar] showAllFiles toggle rejected:`,qr(t.error)),X.error(r({id:`P47EWZ`}),{description:qr(t.error)}))},t[28]=r,t[29]=V,t[30]=pe):pe=t[30];let me=pe,he;t[31]===a?he=t[32]:(he=()=>{a?.expandAll()},t[31]=a,t[32]=he);let ge=he,_e;t[33]===a?_e=t[34]:(_e=()=>{a?.collapseAll()},t[33]=a,t[34]=_e);let ve=_e,ye,be;t[35]!==W||t[36]!==K||t[37]!==G||t[38]!==U||t[39]!==g?(ye=()=>{F&&F.editor.notifyViewMenuStateChanged({showHiddenFiles:U,showAllFiles:W,canExpandAll:G,canCollapseAll:K,sidebarVisible:g===`expanded`})},be=[F,U,W,G,K,g],t[35]=W,t[36]=K,t[37]=G,t[38]=U,t[39]=g,t[40]=ye,t[41]=be):(ye=t[40],be=t[41]),(0,Q.useEffect)(ye,be);let xe,Se;t[42]!==r||t[43]!==c||t[44]!==l||t[45]!==R||t[46]!==L||t[47]!==m||t[48]!==V||t[49]!==W||t[50]!==U||t[51]!==_||t[52]!==a||t[53]!==I?(xe=()=>{if(F)return F.onMenuAction(e=>{switch(e){case`new-doc`:if(!I||!a)return;a.startCreating(`file`,m);return;case`new-folder`:if(!I||!a)return;a.startCreating(`folder`,m);return;case`new-from-template`:if(!I||!a)return;a.startCreatingFromTemplate(m);return;case`rename`:if(!l)return;IW(l);return;case`duplicate`:if(!l)return;RW(l);return;case`move-to-trash`:if(!l)return;PW(l);return;case`reveal-in-finder`:{if(!F||!I)return;let e=zK(l,c,I);F.shell.showItemInFolder(e);return}case`send-to-ai`:{let e=Fh.filter(e=>L[e.id]?.installed===!0);if(e.length===0){X.error(r({id:`LKOLNn`}));return}let t=VK(l,c,I);if(!t)return;let[n]=e;if(!n)return;R(n.id,t);return}case`copy-full-path`:{if(!I)return;let e=zK(l,c,I);navigator.clipboard.writeText(e).then(()=>X.success(r({id:`6_ZOw4`}),{description:e})).catch(e=>{console.warn(`[FileSidebar] clipboard write failed:`,e),X.error(r({id:`vfRlCI`}))});return}case`copy-relative-path`:{let e=BK(l,c);if(e===``){X.error(r({id:`74eHt-`}));return}navigator.clipboard.writeText(e).then(()=>X.success(r({id:`haHgQj`}),{description:e})).catch(e=>{console.warn(`[FileSidebar] clipboard write failed:`,e),X.error(r({id:`5QGTaA`}))});return}case`toggle-show-hidden-files`:{if(V===null)return;let e=V.patch({appearance:{sidebar:{showHiddenFiles:!U}}});e.ok||(console.warn(`[FileSidebar] toggle-show-hidden-files rejected:`,qr(e.error)),X.error(r({id:`P47EWZ`}),{description:qr(e.error)}));return}case`toggle-show-all-files`:{if(V===null)return;let e=V.patch({appearance:{sidebar:{showAllFiles:!W}}});e.ok||(console.warn(`[FileSidebar] toggle-show-all-files rejected:`,qr(e.error)),X.error(r({id:`P47EWZ`}),{description:qr(e.error)}));return}case`expand-all-tree`:a?.expandAll();return;case`collapse-all-tree`:a?.collapseAll();return;case`toggle-sidebar`:_();return;case`delete`:case`toggle-source`:case`save-version`:case`version-history`:case`focus-search`:case`focus-command-palette`:case`close-active-tab-or-window`:case`toggle-doc-panel`:return}})},Se=[F,a,I,l,c,m,V,U,W,L,R,_,r],t[42]=r,t[43]=c,t[44]=l,t[45]=R,t[46]=L,t[47]=m,t[48]=V,t[49]=W,t[50]=U,t[51]=_,t[52]=a,t[53]=I,t[54]=xe,t[55]=Se):(xe=t[54],Se=t[55]),(0,Q.useEffect)(xe,Se);let Ce=h&&y&&`motion-safe:delay-100`,we=b&&`opacity-0`,Te;t[56]!==Ce||t[57]!==we?(Te=ai(`flex-row h-12 items-center py-0 px-3`,h?`justify-end`:`justify-between`,h&&`motion-safe:transition-opacity motion-safe:duration-100 motion-safe:ease-out`,Ce,we,h&&`[-webkit-app-region:drag]`),t[56]=Ce,t[57]=we,t[58]=Te):Te=t[58];let Ee;t[59]===y?Ee=t[60]:(Ee=y&&!h?(0,Z.jsx)(`span`,{className:`shrink-0 font-mono text-sm uppercase tracking-wider text-sidebar-foreground/50`,children:(0,Z.jsx)(s,{id:`sER-bs`})}):null,t[59]=y,t[60]=Ee);let De;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(De=ai(`flex items-center gap-1`,h&&`[&>*]:[-webkit-app-region:no-drag]`),t[61]=De):De=t[61];let Oe;t[62]!==r||t[63]!==O||t[64]!==D||t[65]!==k||t[66]!==a?(Oe=D?(0,Z.jsxs)(ro,{children:[(0,Z.jsx)(ao,{asChild:!0,children:(0,Z.jsx)(KK,{icon:xl,label:r({id:`Rq1vFD`})})}),(0,Z.jsxs)($a,{align:`end`,children:[O?null:(0,Z.jsxs)(Fa,{onSelect:()=>a?.expandAll(),children:[(0,Z.jsx)(ru,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`OlAl5i`})]}),k?null:(0,Z.jsxs)(Fa,{onSelect:()=>a?.collapseAll(),children:[(0,Z.jsx)(ul,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`qvWGzP`})]})]})]}):null,t[62]=r,t[63]=O,t[64]=D,t[65]=k,t[66]=a,t[67]=Oe):Oe=t[67];let Ae;t[68]===r?Ae=t[69]:(Ae=r({id:`HdkSiO`}),t[68]=r,t[69]=Ae);let je;t[70]!==m||t[71]!==a?(je=()=>a?.startCreating(`file`,m),t[70]=m,t[71]=a,t[72]=je):je=t[72];let Me;t[73]!==Ae||t[74]!==je?(Me=(0,Z.jsx)(KK,{icon:Gl,label:Ae,onClick:je}),t[73]=Ae,t[74]=je,t[75]=Me):Me=t[75];let Ne;t[76]!==r||t[77]!==P||t[78]!==m||t[79]!==a?(Ne=P?(0,Z.jsxs)(ro,{children:[(0,Z.jsx)(ao,{asChild:!0,children:(0,Z.jsx)(KK,{icon:Qa,label:r({id:`Uuj_R4`})})}),(0,Z.jsx)($a,{align:`end`,children:(0,Z.jsx)(DW,{parentDir:m,onSelectTemplate:e=>a?.createFromTemplate(m,e),ItemComponent:Fa})})]}):null,t[76]=r,t[77]=P,t[78]=m,t[79]=a,t[80]=Ne):Ne=t[80];let Pe;t[81]===r?Pe=t[82]:(Pe=r({id:`96G6Re`}),t[81]=r,t[82]=Pe);let Fe;t[83]!==m||t[84]!==a?(Fe=()=>a?.startCreating(`folder`,m),t[83]=m,t[84]=a,t[85]=Fe):Fe=t[85];let Ie;t[86]!==Pe||t[87]!==Fe?(Ie=(0,Z.jsx)(KK,{icon:fl,label:Pe,onClick:Fe}),t[86]=Pe,t[87]=Fe,t[88]=Ie):Ie=t[88];let Le;t[89]!==Oe||t[90]!==Me||t[91]!==Ne||t[92]!==Ie?(Le=(0,Z.jsxs)(`div`,{className:De,children:[Oe,Me,Ne,Ie]}),t[89]=Oe,t[90]=Me,t[91]=Ne,t[92]=Ie,t[93]=Le):Le=t[93];let Re;t[94]!==Te||t[95]!==Ee||t[96]!==Le?(Re=(0,Z.jsxs)(Ik,{"data-electron-drag":h?``:void 0,className:Te,children:[Ee,Le]}),t[94]=Te,t[95]=Ee,t[96]=Le,t[97]=Re):Re=t[97];let ze=h&&y&&`motion-safe:delay-100`,Be=b&&`opacity-0`,Ve;t[98]!==ze||t[99]!==Be?(Ve=ai(`px-2 pb-2`,h&&`[-webkit-app-region:no-drag]`,h&&`motion-safe:transition-opacity motion-safe:duration-100 motion-safe:ease-out`,ze,Be),t[98]=ze,t[99]=Be,t[100]=Ve):Ve=t[100];let He;t[101]===g?He=t[102]:(He=[g],t[101]=g,t[102]=He);let Ue;t[103]===n?Ue=t[104]:(Ue=(0,Z.jsx)(FK,{onClick:n}),t[103]=n,t[104]=Ue);let We;t[105]!==He||t[106]!==Ue?(We=(0,Z.jsx)(le,{fallbackRender:JK,onError:PK,resetKeys:He,children:Ue}),t[105]=He,t[106]=Ue,t[107]=We):We=t[107];let Ge;t[108]!==Ve||t[109]!==We?(Ge=(0,Z.jsx)(`div`,{className:Ve,children:We}),t[108]=Ve,t[109]=We,t[110]=Ge):Ge=t[110];let Ke;t[111]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=(0,Z.jsxs)(Rk,{children:[(0,Z.jsx)(cN,{}),(0,Z.jsx)(KG,{ref:o})]}),t[111]=Ke):Ke=t[111];let qe;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(qe=(0,Z.jsxs)(Lk,{className:`px-0`,children:[(0,Z.jsx)(RK,{}),typeof window<`u`&&window.okDesktop?(0,Z.jsx)(zk,{children:(0,Z.jsx)(Bk,{children:(0,Z.jsx)(MK,{bridge:window.okDesktop})})}):null]}),t[112]=qe):qe=t[112];let Je=!(v&&g===`collapsed`),Ye;t[113]===Je?Ye=t[114]:(Ye=(0,Z.jsx)(Pk,{enableToggle:!1,enableDrag:Je}),t[113]=Je,t[114]=Ye);let Xe;t[115]!==Re||t[116]!==Ge||t[117]!==Ye?(Xe=(0,Z.jsx)(nM,{asChild:!0,children:(0,Z.jsxs)(`div`,{className:`contents`,onContextMenu:J,children:[Re,Ge,Ke,qe,Ye]})}),t[115]=Re,t[116]=Ge,t[117]=Ye,t[118]=Xe):Xe=t[118];let Ze=!I,Qe,$e;t[119]===Symbol.for(`react.memo_cache_sentinel`)?(Qe=(0,Z.jsx)(Gl,{"aria-hidden":`true`}),$e=(0,Z.jsx)(s,{id:`HdkSiO`}),t[119]=Qe,t[120]=$e):(Qe=t[119],$e=t[120]);let et;t[121]!==ee||t[122]!==Ze?(et=(0,Z.jsxs)(aM,{disabled:Ze,onSelect:ee,"data-testid":`empty-space-menu-new-file`,children:[Qe,$e]}),t[121]=ee,t[122]=Ze,t[123]=et):et=t[123];let tt;t[124]!==ne||t[125]!==N||t[126]!==I?(tt=N?(0,Z.jsxs)(rM,{children:[(0,Z.jsxs)(oM,{disabled:!I,"data-testid":`empty-space-menu-new-from-template`,children:[(0,Z.jsx)(Qa,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`Uuj_R4`})]}),(0,Z.jsx)(sM,{children:(0,Z.jsx)(DW,{parentDir:``,onSelectTemplate:ne,ItemComponent:aM})})]}):null,t[124]=ne,t[125]=N,t[126]=I,t[127]=tt):tt=t[127];let nt=!I,rt,it;t[128]===Symbol.for(`react.memo_cache_sentinel`)?(rt=(0,Z.jsx)(fl,{"aria-hidden":`true`}),it=(0,Z.jsx)(s,{id:`96G6Re`}),t[128]=rt,t[129]=it):(rt=t[128],it=t[129]);let at;t[130]!==ie||t[131]!==nt?(at=(0,Z.jsxs)(aM,{disabled:nt,onSelect:ie,"data-testid":`empty-space-menu-new-folder`,children:[rt,it]}),t[130]=ie,t[131]=nt,t[132]=at):at=t[132];let ot;t[133]===Symbol.for(`react.memo_cache_sentinel`)?(ot=(0,Z.jsx)(lM,{}),t[133]=ot):ot=t[133];let st;t[134]!==r||t[135]!==se||t[136]!==I?(st=F?(0,Z.jsxs)(aM,{disabled:!I,onSelect:se,"data-testid":`empty-space-menu-reveal-in-finder`,"aria-label":r(I?{id:`LtSYdi`}:{id:`o2yoFu`}),children:[(0,Z.jsx)(ke,{"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:(0,Z.jsx)(s,{id:`LtSYdi`})}),I?null:(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:(0,Z.jsx)(s,{id:`wTcjov`})})]}):null,t[134]=r,t[135]=se,t[136]=I,t[137]=st):st=t[137];let ct;t[138]!==R||t[139]!==B||t[140]!==L?(ct=(0,Z.jsx)(AK,{input:B,installStates:L,dispatch:R}),t[138]=R,t[139]=B,t[140]=L,t[141]=ct):ct=t[141];let lt=!I,ut;t[142]!==r||t[143]!==I?(ut=r(I?{id:`Up2_7p`}:{id:`U8CD-l`}),t[142]=r,t[143]=I,t[144]=ut):ut=t[144];let dt;t[145]===Symbol.for(`react.memo_cache_sentinel`)?(dt=(0,Z.jsx)(Et,{"aria-hidden":`true`}),t[145]=dt):dt=t[145];let ft;t[146]===Symbol.for(`react.memo_cache_sentinel`)?(ft=(0,Z.jsx)(`span`,{className:`flex-1`,children:(0,Z.jsx)(s,{id:`Up2_7p`})}),t[146]=ft):ft=t[146];let mt;t[147]===I?mt=t[148]:(mt=I?null:(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:(0,Z.jsx)(s,{id:`wTcjov`})}),t[147]=I,t[148]=mt);let ht;t[149]!==ue||t[150]!==lt||t[151]!==ut||t[152]!==mt?(ht=(0,Z.jsxs)(aM,{disabled:lt,onSelect:ue,"data-testid":`empty-space-menu-copy-full-path`,"aria-label":ut,children:[dt,ft,mt]}),t[149]=ue,t[150]=lt,t[151]=ut,t[152]=mt,t[153]=ht):ht=t[153];let gt;t[154]===Symbol.for(`react.memo_cache_sentinel`)?(gt=(0,Z.jsx)(lM,{}),t[154]=gt):gt=t[154];let _t=V===null,vt;t[155]===Symbol.for(`react.memo_cache_sentinel`)?(vt=(0,Z.jsx)(s,{id:`XcGbim`}),t[155]=vt):vt=t[155];let yt;t[156]!==fe||t[157]!==U||t[158]!==_t?(yt=(0,Z.jsx)(cM,{checked:U,onCheckedChange:fe,disabled:_t,"data-testid":`empty-space-menu-show-hidden-files`,children:vt}),t[156]=fe,t[157]=U,t[158]=_t,t[159]=yt):yt=t[159];let bt=V===null,xt;t[160]===Symbol.for(`react.memo_cache_sentinel`)?(xt=(0,Z.jsx)(s,{id:`i8dKs-`}),t[160]=xt):xt=t[160];let St;t[161]!==me||t[162]!==W||t[163]!==bt?(St=(0,Z.jsx)(cM,{checked:W,onCheckedChange:me,disabled:bt,"data-testid":`empty-space-menu-show-all-files`,children:xt}),t[161]=me,t[162]=W,t[163]=bt,t[164]=St):St=t[164];let Ct;t[165]===q?Ct=t[166]:(Ct=q?(0,Z.jsx)(lM,{}):null,t[165]=q,t[166]=Ct);let wt;t[167]!==ge||t[168]!==G?(wt=G?(0,Z.jsxs)(aM,{onSelect:ge,"data-testid":`empty-space-menu-expand-all`,children:[(0,Z.jsx)(ru,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`OlAl5i`})]}):null,t[167]=ge,t[168]=G,t[169]=wt):wt=t[169];let Tt;t[170]!==ve||t[171]!==K?(Tt=K?(0,Z.jsxs)(aM,{onSelect:ve,"data-testid":`empty-space-menu-collapse-all`,children:[(0,Z.jsx)(ul,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`qvWGzP`})]}):null,t[170]=ve,t[171]=K,t[172]=Tt):Tt=t[172];let Dt;t[173]!==et||t[174]!==tt||t[175]!==at||t[176]!==st||t[177]!==ct||t[178]!==ht||t[179]!==yt||t[180]!==St||t[181]!==Ct||t[182]!==wt||t[183]!==Tt?(Dt=(0,Z.jsxs)(iM,{children:[et,tt,at,ot,st,ct,ht,gt,yt,St,Ct,wt,Tt]}),t[173]=et,t[174]=tt,t[175]=at,t[176]=st,t[177]=ct,t[178]=ht,t[179]=yt,t[180]=St,t[181]=Ct,t[182]=wt,t[183]=Tt,t[184]=Dt):Dt=t[184];let Ot;return t[185]!==Xe||t[186]!==Dt?(Ot=(0,Z.jsx)(Mk,{variant:`inset`,children:(0,Z.jsxs)(tM,{children:[Xe,Dt]})}),t[185]=Xe,t[186]=Dt,t[187]=Ot):Ot=t[187],Ot}function JK(){return null}function YK(e){WK(e.target)&&(e.preventDefault(),e.stopPropagation())}function XK(e){let t=e.shareTargetExists,n=e.dirtyConflicts.conflicts,r=e.dirtyConflicts.files;return t&&!n?{kind:`A`,openCurrentEnabled:!0,switchEnabled:!0,conflictingFiles:r}:!t&&!n?{kind:`B`,openCurrentEnabled:!1,switchEnabled:!0,conflictingFiles:r}:t&&n?{kind:`C`,openCurrentEnabled:!0,switchEnabled:!1,conflictingFiles:r}:{kind:`D`,openCurrentEnabled:!1,switchEnabled:!1,conflictingFiles:r}}function ZK(e){return e.detached?e.currentHeadSha:e.currentBranch??`HEAD`}function QK(e){if(e.ok)return{action:`await-cc1`};switch(e.reason){case`dirty-conflict`:return{action:`rerender-conflict`,files:e.files??[]};case`branch-not-found`:return{action:`dismiss-with-toast`,reason:`branch-not-found`};case`fetch-failed`:case`checkout-failed`:return{action:`stay-with-toast`,reason:e.reason};case`branch-in-other-worktree`:{let t=e.otherWorktreePath;return t===void 0||t.length===0?{action:`stay-with-toast`,reason:`checkout-failed`}:{action:`pivot-to-other-worktree`,otherWorktreePath:t}}default:{let t=e.reason;throw Error(`Unhandled CheckoutFailureReason: ${String(t)}`)}}}var $K={phase:`loading`};function eq(e,t){return e.phase===`loading`?t===null?{phase:`error`}:{phase:`ready`,info:t}:e}function tq(e,t){return e.phase===`ready`?{phase:`switching`,info:e.info,pendingDoc:t}:e}function nq(e,t){if(e.phase!==`switching`)return{state:e};if(t===null)return{state:{phase:`ready`,info:e.info},sideEffect:{kind:`toast`,reason:`proxy-null`}};let n=QK(t);return n.action===`await-cc1`?{state:{phase:`awaiting-cc1-recycle`,pendingDoc:e.pendingDoc}}:n.action===`rerender-conflict`?{state:{phase:`ready`,info:{...e.info,dirtyConflicts:{conflicts:!0,files:n.files.slice()}}}}:n.action===`pivot-to-other-worktree`?{state:{phase:`branch-in-other-worktree`,info:e.info,otherWorktreePath:n.otherWorktreePath,pendingDoc:e.pendingDoc}}:n.action===`dismiss-with-toast`?{state:{phase:`dismissed`,reason:n.reason},sideEffect:{kind:`toast`,reason:n.reason}}:{state:{phase:`ready`,info:e.info},sideEffect:{kind:`toast`,reason:n.reason}}}function rq(e){return e!==null&&e.kind===`project-branch-switch`}function iq(e){let t=(0,$.c)(146),{bridge:n,store:r}=e,a=r===void 0?sf:r,{_:o}=i(),c=(0,Q.useSyncExternalStore)(a.subscribe,a.getSnapshot,uq),[l,u]=(0,Q.useState)($K),d=(0,Q.useRef)(!1),f=(0,Q.useRef)(!1),m;t[0]===c?m=t[1]:(m=rq(c)?c:null,t[0]=c,t[1]=m);let h=m,g;t[2]!==o||t[3]!==h?.share.target.kind?(g=h?.share.target.kind===`folder`?o({id:`ugoTXs`}):o({id:`XH30C4`}),t[2]=o,t[3]=h?.share.target.kind,t[4]=g):g=t[4];let _=g,v;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>{u($K),d.current=!1,f.current=!1},t[5]=v):v=t[5];let y;t[6]===c?y=t[7]:(y=[c],t[6]=c,t[7]=y),(0,Q.useEffect)(v,y);let b;t[8]!==h||t[9]!==n?(b=()=>{h&&(d.current||(d.current=!0,n.project.fetchBranchInfo({projectPath:h.projectPath,branch:h.share.branch,kind:h.share.target.kind,path:p(h.share.target)}).then(e=>{u(t=>eq(t,e))}).catch(e=>{console.warn(`[receive] branch-info-fetch-failed`,e instanceof Error?e.message:e),u(lq)})))},t[8]=h,t[9]=n,t[10]=b):b=t[10];let x;t[11]===h?x=t[12]:(x=[h],t[11]=h,t[12]=x),(0,Q.useEffect)(b,x);let S;t[13]!==o||t[14]!==h||t[15]!==l.phase||t[16]!==n||t[17]!==a||t[18]!==_?(S=()=>{if(l.phase!==`awaiting-cc1-recycle`||!h)return;let e=h.share.branch;if(!e){a.dismiss();return}if(f.current)return;f.current=!0;let t=!1;return n.project.awaitBranchSwitched({projectPath:h.projectPath,branch:e,timeoutMs:3e4}).then(r=>{if(!t){if(r.ok){console.log(pu({branch_dialog_action:`branch-switch-complete`,branch:e})),n.project.open({path:h.projectPath,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkTarget:{kind:h.share.target.kind,path:p(h.share.target)},pendingBranch:e}).catch(e=>{console.warn(`[receive] warm-focus-dispatch-failed branch_action=switch`,e instanceof Error?e.message:e),X.error(o({id:`gQV-9w`,values:{targetNoun:_}}))}),a.dismiss();return}console.log(pu({branch_dialog_action:`branch-switch-timeout`,branch:e})),X.error(o({id:`LBwUR6`,values:{targetNoun:_}})),a.dismiss()}}).catch(e=>{t||(console.warn(`[receive] awaitBranchSwitched rejected`,e instanceof Error?e.message:e),X.error(o({id:`Jw6EC4`,values:{targetNoun:_}})),a.dismiss())}),()=>{t=!0}},t[13]=o,t[14]=h,t[15]=l.phase,t[16]=n,t[17]=a,t[18]=_,t[19]=S):S=t[19];let C;if(t[20]!==h||t[21]!==l.phase?(C=[l.phase,h],t[20]=h,t[21]=l.phase,t[22]=C):C=t[22],(0,Q.useEffect)(S,C),!h)return null;let{share:w,projectPath:T,currentBranch:E}=h,D=w.branch,O;t[23]!==o||t[24]!==l.info||t[25]!==l.phase||t[26]!==n.project||t[27]!==T||t[28]!==w.target||t[29]!==D||t[30]!==a?(O=function(){l.phase===`ready`&&XK(l.info).switchEnabled&&(console.log(pu({branch_dialog_action:`switch`,branch_action:`switch`,branch:D})),u(e=>tq(e,p(w.target))),n.project.runCheckout({projectPath:T,branch:D}).then(e=>{let t=null,n=!1;u(r=>{let{state:i,sideEffect:a}=nq(r,e);return a&&(t=a.reason,n=i.phase===`dismissed`),i}),t===`branch-not-found`?X.error(o({id:`NJyQi_`,values:{shareBranch:D}})):t===`fetch-failed`?X.error(o({id:`bWLmRK`})):(t===`checkout-failed`||t===`proxy-null`)&&X.error(o({id:`c863eW`,values:{shareBranch:D}})),n&&a.dismiss()}).catch(e=>{console.warn(`[receive] runCheckout rejected branch_action=switch`,e instanceof Error?e.message:e),u(cq),X.error(o({id:`c863eW`,values:{shareBranch:D}}))}))},t[23]=o,t[24]=l.info,t[25]=l.phase,t[26]=n.project,t[27]=T,t[28]=w.target,t[29]=D,t[30]=a,t[31]=O):O=t[31];let k=O,A;t[32]!==o||t[33]!==n.project||t[34]!==T||t[35]!==w.target||t[36]!==D||t[37]!==a||t[38]!==_?(A=function(){console.log(pu({branch_dialog_action:`open-current`,branch:D})),n.project.open({path:T,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkTarget:{kind:w.target.kind,path:p(w.target)}}).catch(e=>{console.warn(`[receive] warm-focus-dispatch-failed branch_action=open-current`,e instanceof Error?e.message:e),X.error(o({id:`b5aNbi`,values:{targetNoun:_}}))}),a.dismiss()},t[32]=o,t[33]=n.project,t[34]=T,t[35]=w.target,t[36]=D,t[37]=a,t[38]=_,t[39]=A):A=t[39];let j=A,M;t[40]!==o||t[41]!==l.otherWorktreePath||t[42]!==l.phase||t[43]!==n.project||t[44]!==w.target||t[45]!==D||t[46]!==a?(M=function(){if(l.phase!==`branch-in-other-worktree`)return;let e=l.otherWorktreePath;console.log(pu({branch_dialog_action:`pivot-to-other-worktree`,branch:D})),n.project.open({path:e,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkTarget:{kind:w.target.kind,path:p(w.target)},pendingBranch:D}).catch(t=>{console.warn(`[receive] pivot-open-failed branch_action=pivot-to-other-worktree`,t instanceof Error?t.message:t),X.error(o({id:`LdABLa`,values:{target:e}}))}),a.dismiss()},t[40]=o,t[41]=l.otherWorktreePath,t[42]=l.phase,t[43]=n.project,t[44]=w.target,t[45]=D,t[46]=a,t[47]=M):M=t[47];let N=M,P;t[48]===a?P=t[49]:(P=function(){console.log(pu({branch_dialog_action:`cancel`})),a.dismiss()},t[48]=a,t[49]=P);let F=P,I,L,R,z,B,V,H,U,W,G,K,q,J,Y,ee,te,ne;if(t[50]!==o||t[51]!==l.info||t[52]!==l.otherWorktreePath||t[53]!==l.phase||t[54]!==F||t[55]!==E||t[56]!==w.branch||t[57]!==w.owner||t[58]!==w.repo||t[59]!==w.target||t[60]!==D||t[61]!==_){ne=l.phase===`ready`||l.phase===`switching`?XK(l.info):null;let e;t[79]!==l.info||t[80]!==l.phase||t[81]!==E?(e=l.phase===`ready`||l.phase===`switching`?ZK(l.info):E??`HEAD`,t[79]=l.info,t[80]=l.phase,t[81]=E,t[82]=e):e=t[82];let n=e;V=l.phase===`switching`||l.phase===`awaiting-cc1-recycle`;let r;t[83]===o?r=t[84]:(r=o({id:`OuY8t9`}),t[83]=o,t[84]=r),z=r;let i;t[85]!==o||t[86]!==D?(i=o({id:`_BthEY`,values:{shareBranch:D}}),t[85]=o,t[86]=D,t[87]=i):i=t[87],B=i;let a=l.phase===`loading`,c=l.phase===`error`;R=Eo,ee=!0,t[88]===F?te=t[89]:(te=e=>{e||F()},t[88]=F,t[89]=te),L=So,G=`sm:max-w-xl`,K=`share-branch-switch-dialog`,q=sq,J=oq;let u;t[90]===_?u=t[91]:(u=(0,Z.jsx)(xo,{children:(0,Z.jsx)(s,{id:`RY6Bq1`,values:{targetNoun:_}})}),t[90]=_,t[91]=u);let d=w.owner,f=w.repo,m;t[92]===w.target?m=t[93]:(m=p(w.target),t[92]=w.target,t[93]=m);let h;t[94]!==w.owner||t[95]!==w.repo||t[96]!==m?(h=(0,Z.jsx)(bo,{className:`sr-only`,children:(0,Z.jsx)(s,{id:`f8jU-L`,values:{0:d,1:f,2:m}})}),t[94]=w.owner,t[95]=w.repo,t[96]=m,t[97]=h):h=t[97],t[98]!==u||t[99]!==h?(Y=(0,Z.jsxs)(To,{children:[u,h]}),t[98]=u,t[99]=h,t[100]=Y):Y=t[100],I=Co;let g=w.owner,v=w.repo,y;t[101]===w.target?y=t[102]:(y=p(w.target),t[101]=w.target,t[102]=y),t[103]!==w.branch||t[104]!==w.owner||t[105]!==w.repo||t[106]!==w.target.kind||t[107]!==y?(H=(0,Z.jsx)(`div`,{className:`mb-4`,children:(0,Z.jsx)(Qd,{owner:g,repo:v,path:y,kind:w.target.kind,branch:w.branch,testId:`share-branch-switch-metadata`,branchTestId:`share-branch-switch-metadata-branch`})}),t[103]=w.branch,t[104]=w.owner,t[105]=w.repo,t[106]=w.target.kind,t[107]=y,t[108]=H):H=t[108],U=l.phase===`branch-in-other-worktree`?(0,Z.jsxs)(`div`,{className:`text-sm text-muted-foreground`,"data-testid":`share-branch-switch-in-other-worktree`,children:[(0,Z.jsx)(`p`,{className:`leading-6`,children:(0,Z.jsx)(s,{id:`yjExfe`,values:{shareBranch:D},components:{0:(0,Z.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}),(0,Z.jsx)(`p`,{className:`mt-2 break-all rounded bg-muted px-2 py-1 font-mono text-xs text-foreground/80`,"data-testid":`share-branch-switch-in-other-worktree-path`,children:l.otherWorktreePath})]}):a?(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,"data-testid":`share-branch-switch-loading`,role:`status`,"aria-live":`polite`,children:[(0,Z.jsx)(Yt,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`jerqF0`})]}):c?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Z.jsx)(s,{id:`w4hMYl`})}):ne?.kind===`D`?(0,Z.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:(0,Z.jsx)(s,{id:`XnoA1k`,values:{targetNoun:_,shareBranch:D},components:{0:(0,Z.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}):ne?.kind===`B`?(0,Z.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:(0,Z.jsx)(s,{id:`sZ2IOu`,values:{targetNoun:_,shareBranch:D,currentLabel:n},components:{0:(0,Z.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`}),1:(0,Z.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}):(0,Z.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:(0,Z.jsx)(s,{id:`_902BE`,values:{targetNoun:_,shareBranch:D,currentLabel:n},components:{0:(0,Z.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`}),1:(0,Z.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}),W=ne&&!ne.switchEnabled&&ne.conflictingFiles.length>0?(0,Z.jsxs)(`div`,{className:`mt-3 rounded-md border border-border bg-muted/30 p-3 text-1sm`,"data-testid":`share-branch-switch-conflict`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-foreground/90`,children:(0,Z.jsx)(s,{id:`n2lRue`})}),(0,Z.jsx)(`ul`,{id:`share-receive-branch-conflict-files`,className:`mt-1 list-disc space-y-0.5 pl-5 text-muted-foreground`,children:ne.conflictingFiles.map(aq)})]}):null,t[50]=o,t[51]=l.info,t[52]=l.otherWorktreePath,t[53]=l.phase,t[54]=F,t[55]=E,t[56]=w.branch,t[57]=w.owner,t[58]=w.repo,t[59]=w.target,t[60]=D,t[61]=_,t[62]=I,t[63]=L,t[64]=R,t[65]=z,t[66]=B,t[67]=V,t[68]=H,t[69]=U,t[70]=W,t[71]=G,t[72]=K,t[73]=q,t[74]=J,t[75]=Y,t[76]=ee,t[77]=te,t[78]=ne}else I=t[62],L=t[63],R=t[64],z=t[65],B=t[66],V=t[67],H=t[68],U=t[69],W=t[70],G=t[71],K=t[72],q=t[73],J=t[74],Y=t[75],ee=t[76],te=t[77],ne=t[78];let re;t[109]===V?re=t[110]:(re=V?(0,Z.jsxs)(`p`,{className:`mt-3 flex items-center gap-2 text-sm text-muted-foreground`,"data-testid":`share-branch-switch-switching`,role:`status`,"aria-live":`polite`,children:[(0,Z.jsx)(Yt,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`CU3AiE`})]}):null,t[109]=V,t[110]=re);let ie;t[111]!==I||t[112]!==H||t[113]!==U||t[114]!==W||t[115]!==re?(ie=(0,Z.jsxs)(I,{children:[H,U,W,re]}),t[111]=I,t[112]=H,t[113]=U,t[114]=W,t[115]=re,t[116]=ie):ie=t[116];let ae;t[117]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Z.jsx)(s,{id:`dEgA5A`}),t[117]=ae):ae=t[117];let oe;t[118]===F?oe=t[119]:(oe=(0,Z.jsx)(si,{variant:`ghost`,className:`font-mono uppercase`,onClick:F,"data-testid":`share-branch-switch-cancel`,children:ae}),t[118]=F,t[119]=oe);let se;t[120]!==l.phase||t[121]!==j||t[122]!==N||t[123]!==k||t[124]!==z||t[125]!==B||t[126]!==V||t[127]!==ne?(se=l.phase===`branch-in-other-worktree`?(0,Z.jsx)(si,{onClick:N,"data-testid":`share-branch-switch-in-other-worktree-pivot`,children:(0,Z.jsx)(s,{id:`hyCxJY`})}):(0,Z.jsxs)(`div`,{className:`flex flex-col-reverse gap-2 sm:flex-row sm:gap-2`,children:[ne?.openCurrentEnabled?(0,Z.jsxs)(si,{variant:`outline`,className:`font-mono uppercase`,onClick:j,disabled:V,"data-testid":`share-branch-switch-open-current`,children:[(0,Z.jsx)(Tl,{className:`size-3.5`,"aria-hidden":!0}),z]}):null,(0,Z.jsx)(si,{onClick:k,disabled:!ne?.switchEnabled||V,"aria-disabled":!ne?.switchEnabled||V,"aria-describedby":ne&&!ne.switchEnabled&&ne.conflictingFiles.length>0?`share-receive-branch-conflict-files`:void 0,"data-testid":`share-branch-switch-switch`,children:V?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Yt,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}),B]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ce,{className:`size-3.5`,"aria-hidden":!0}),B]})})]}),t[120]=l.phase,t[121]=j,t[122]=N,t[123]=k,t[124]=z,t[125]=B,t[126]=V,t[127]=ne,t[128]=se):se=t[128];let ce;t[129]!==oe||t[130]!==se?(ce=(0,Z.jsxs)(wo,{className:`sm:justify-between`,children:[oe,se]}),t[129]=oe,t[130]=se,t[131]=ce):ce=t[131];let le;t[132]!==L||t[133]!==G||t[134]!==K||t[135]!==q||t[136]!==J||t[137]!==Y||t[138]!==ie||t[139]!==ce?(le=(0,Z.jsxs)(L,{className:G,"data-testid":K,onInteractOutside:q,onPointerDownOutside:J,children:[Y,ie,ce]}),t[132]=L,t[133]=G,t[134]=K,t[135]=q,t[136]=J,t[137]=Y,t[138]=ie,t[139]=ce,t[140]=le):le=t[140];let ue;return t[141]!==R||t[142]!==ee||t[143]!==te||t[144]!==le?(ue=(0,Z.jsx)(R,{open:ee,onOpenChange:te,children:le}),t[141]=R,t[142]=ee,t[143]=te,t[144]=le,t[145]=ue):ue=t[145],ue}function aq(e){return(0,Z.jsx)(`li`,{children:(0,Z.jsx)(`code`,{className:`text-foreground/80`,children:e})},e)}function oq(e){e.preventDefault()}function sq(e){e.preventDefault()}function cq(e){return nq(e,null).state}function lq(e){return eq(e,null)}function uq(){return null}function dq(){let e=(0,$.c)(17),t=Cn(),{collabUrl:n,setSystemProvider:r,updateServerInstanceId:i,onBranchSwitched:a,observeBranch:o,observeDiskAck:s,refreshServerInfo:c}=pt(),l;e[0]!==o||e[1]!==s||e[2]!==a||e[3]!==c||e[4]!==i?(l={updateServerInstanceId:i,onBranchSwitched:a,observeBranch:o,observeDiskAck:s,refreshServerInfo:c},e[0]=o,e[1]=s,e[2]=a,e[3]=c,e[4]=i,e[5]=l):l=e[5];let u=(0,Q.useRef)(l),d;e[6]!==o||e[7]!==s||e[8]!==a||e[9]!==c||e[10]!==i?(d=()=>{u.current={updateServerInstanceId:i,onBranchSwitched:a,observeBranch:o,observeDiskAck:s,refreshServerInfo:c}},e[6]=o,e[7]=s,e[8]=a,e[9]=c,e[10]=i,e[11]=d):d=e[11],(0,Q.useEffect)(d);let f,p;return e[12]!==n||e[13]!==t||e[14]!==r?(f=()=>{if(n===null)return;let e=new Pe,i=new lt({url:n,name:Br,document:e,onStateless:e=>{let{payload:t}=e;H(t,{onServerInfo:e=>{u.current.updateServerInstanceId(e.serverInstanceId),e.currentBranch!==void 0&&u.current.observeBranch(e.currentBranch)},onBranchSwitched:e=>{u.current.onBranchSwitched(e.branch)},onDiskAck:e=>{u.current.observeDiskAck(e.docName,e.sv)},onDerivedView:_q,onConfigValidationRejected:gq,onConfigIgnoreNestedError:hq,onUnknown:mq})},onClose:pq,onDisconnect:fq}),a=Xo(e=>{(e.includes(`files`)||e.includes(`backlinks`))&&(t.invalidateQueries({queryKey:[`backlinks`]}),t.invalidateQueries({queryKey:[`forward-links`]})),(e.includes(`files`)||e.includes(`graph`))&&(t.invalidateQueries({queryKey:[`orphans`]}),t.invalidateQueries({queryKey:[`hubs`]}))}),o=Xt(()=>{u.current.refreshServerInfo()});i.on(`synced`,()=>{is([`files`,`backlinks`,`graph`]),o()});let s=new Set,c=()=>{if(i.awareness)for(let[e,t]of i.awareness.getStates().entries())s.has(e)||t.user?.type===`agent`&&(s.add(e),console.warn(`[agent-presence] observed stale AwarenessUser.type === 'agent' from clientID ${e} — probably a stale bundled client`))};return i.awareness?.on(`change`,c),r(i),()=>{a(),i.awareness?.off(`change`,c),r(null),i.destroy(),e.destroy()}},p=[t,n,r],e[12]=n,e[13]=t,e[14]=r,e[15]=f,e[16]=p):(f=e[15],p=e[16]),(0,Q.useEffect)(f,p),null}function fq(){console.warn(`[CC1] __system__ disconnected - derived views may be stale`)}function pq(e){let{event:t}=e;console.warn(`[CC1] __system__ connection closed:`,t.code,t.reason)}function mq(e){console.warn(`[CC1] Unparseable stateless payload, skipping:`,e.slice(0,100))}function hq(e){Za(e)}function gq(e){to(e)}function _q(e){is([e.ch])}var vq=`#install-claude-desktop`;function yq(e){return e===`#settings`||e===vq}function bq(e,t,n){return[e,t,n].map(e=>[...e].sort().join(`\0`)).join(``)}function xq(){let e=(0,$.c)(23),{clearTarget:t,syncOpenTabsWithKnownTargets:n,tabSessionLoaded:r}=pt(),{openTargetTransition:i}=wt(),{assetPaths:a,folderPaths:o,loading:s,pageMeta:c,pages:l,pagesBySlug:u,pagesByBasename:d}=es(),f=(0,Q.useRef)(null),p;e[0]!==a||e[1]!==o||e[2]!==l?(p=bq(l,o,a),e[0]=a,e[1]=o,e[2]=l,e[3]=p):p=e[3];let m=p,h,g;e[4]!==a||e[5]!==o||e[6]!==s||e[7]!==l||e[8]!==n||e[9]!==r||e[10]!==m?(h=()=>{s||!r||f.current===m||(f.current=m,n({pages:l,folderPaths:o,assetPaths:a}))},g=[a,o,s,l,n,r,m],e[4]=a,e[5]=o,e[6]=s,e[7]=l,e[8]=n,e[9]=r,e[10]=m,e[11]=h,e[12]=g):(h=e[11],g=e[12]),(0,Q.useEffect)(h,g);let _,v;return e[13]!==t||e[14]!==o||e[15]!==s||e[16]!==i||e[17]!==c||e[18]!==l||e[19]!==d||e[20]!==u?(_=()=>{e();function e(){if(yq(window.location.hash))return;let e=ns(window.location.hash);if(e){let t=rr(e.split(`.`).pop()??``);ue(`ok/nav/hash-change`,{docName:null,kind:`asset`}),i({kind:`asset`,target:e,assetPath:e,mediaKind:t});return}if(Bo(window.location.hash)){ue(`ok/nav/hash-change`,{docName:null,kind:`folder`}),i({kind:`folder`,target:``,folderPath:``});return}let n=Po(window.location.hash);if(!n){ue(`ok/nav/hash-change`,{docName:null,kind:`clear`}),t();return}if(s){ue(`ok/nav/hash-change`,{docName:n,kind:`deferred-loading`});return}let r=Qo(n,{pages:l,folderPaths:o,pagesBySlug:u,pagesByBasename:d});if(r.kind===`missing`&&/\/+$/.test(n.trim())){ue(`ok/nav/hash-change`,{docName:n,kind:`deferred-missing-folder`});return}let a=rs(os(r),c);ue(`ok/nav/hash-change`,{docName:n,kind:a.kind}),i(a)}return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},v=[t,o,s,i,c,l,u,d],e[13]=t,e[14]=o,e[15]=s,e[16]=i,e[17]=c,e[18]=l,e[19]=d,e[20]=u,e[21]=_,e[22]=v):(_=e[21],v=e[22]),(0,Q.useEffect)(_,v),null}function Sq(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,Q.useEffect)(Cq,t),null}function Cq(){let e=Eq;if(!e(window.location.hash))return;let t=new AbortController;return ce(t.signal).then(n=>{if(t.signal.aborted||n.status!==`ok`)return;let r=n.config.paneTarget;r?.startsWith(`#/`)&&e(window.location.hash)&&(window.location.hash=r,fetch(`/api/config`,{method:`DELETE`}).catch(Tq))}).catch(wq),()=>t.abort()}function wq(){}function Tq(){}function Eq(e){return!yq(e)&&!ns(e)&&!Po(e)&&(e===``||e===`#`||e===`#/`)}function Dq(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,Q.useEffect)(Oq,t),null}function Oq(){let e=function(e){let t=e.target;Hh({target:t,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,key:e.key})&&(e.preventDefault(),window.location.hash!==`#settings`&&(window.location.hash=Vh))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}function kq(){let e=(0,$.c)(4),{activeTarget:t}=pt(),n=typeof window<`u`?window.okDesktop??null:null,r=t?.kind===`doc`||t?.kind===`folder`||t?.kind===`asset`?t.kind:null,i=t?.kind===`doc`?t.docName:t?.kind===`folder`?t.folderPath:t?.kind===`asset`?t.assetPath:null,a,o;return e[0]!==i||e[1]!==r?(a=()=>{if(n){if(r===null){n.editor.notifyActiveTargetChanged({kind:null});return}i!==null&&n.editor.notifyActiveTargetChanged({kind:r,identifier:i})}},o=[n,r,i],e[0]=i,e[1]=r,e[2]=a,e[3]=o):(a=e[2],o=e[3]),(0,Q.useEffect)(a,o),null}function Aq(){let e=(0,$.c)(8),{activeDocName:t,activeTarget:n}=pt(),[r,i]=(0,Q.useState)(!1),a;e[0]!==t||e[1]!==n?(a=n?.kind===`folder`?n.folderPath:us(t),e[0]=t,e[1]=n,e[2]=a):a=e[2];let o=a,s,c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=function(e){let t=e.target;nh({target:t,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,key:e.key})&&(e.preventDefault(),i(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},c=[],e[3]=s,e[4]=c):(s=e[3],c=e[4]),(0,Q.useEffect)(s,c);let l;return e[5]!==r||e[6]!==o?(l=(0,Z.jsx)(ih,{open:r,onOpenChange:i,kind:`file`,initialDir:o}),e[5]=r,e[6]=o,e[7]=l):l=e[7],l}function jq(e){let t=(0,$.c)(3),{children:n}=e,{collabUrl:r}=pt(),i;return t[0]!==n||t[1]!==r?(i=(0,Z.jsx)(B,{collabUrl:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function Mq(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(Wt,{name:`app`,children:(0,Z.jsx)(jt,{children:(0,Z.jsx)(jq,{children:(0,Z.jsx)(Lh,{children:(0,Z.jsx)(Nq,{})})})})}),e[0]=t):t=e[0],t}function Nq(){let e=(0,$.c)(25),t=typeof window<`u`?window.okDesktop??null:null,n=typeof window<`u`&&window.okDesktop!=null,[r,i]=(0,Q.useState)(!1),a=Bh(),o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=t?{launchInTerminal:Pq}:null,e[0]=o):o=e[0];let s=o,c;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(d_,{}),e[1]=c):c=e[1];let l,u,d,f,p;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(dq,{}),u=(0,Z.jsx)(xq,{}),d=(0,Z.jsx)(Sq,{}),f=(0,Z.jsx)(kq,{}),p=(0,Z.jsx)(Aq,{}),e[2]=l,e[3]=u,e[4]=d,e[5]=f,e[6]=p):(l=e[2],u=e[3],d=e[4],f=e[5],p=e[6]);let m;e[7]===a?m=e[8]:(m=!a&&(0,Z.jsx)(Dq,{}),e[7]=a,e[8]=m);let h,g,_,v;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=!1,v=t?(0,Z.jsx)(f_,{bridge:t}):null,h=(0,Z.jsx)(Jd,{}),g=t?(0,Z.jsx)(iq,{bridge:t}):null,e[9]=h,e[10]=g,e[11]=_,e[12]=v):(h=e[9],g=e[10],_=e[11],v=e[12]);let y;e[13]===r?y=e[14]:(y=(0,Z.jsx)(r_,{bridge:t,open:r,onOpenChange:i}),e[13]=r,e[14]=y);let b;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(b=n&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`editor-window-chrome-drag-strip`,"data-electron-drag":``,className:`pointer-events-none fixed inset-x-0 top-0 z-50 h-2 [-webkit-app-region:drag]`}),e[15]=b):b=e[15];let x;e[16]===a?x=e[17]:(x=!a&&(0,Z.jsx)(GK,{onOpenSearch:()=>i(!0)}),e[16]=a,e[17]=x);let S;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(Fk,{className:`overflow-hidden h-[calc(100vh-var(--layout-inset-offset))]`,children:(0,Z.jsx)(iN,{onOpenSearch:()=>i(!0)})}),e[18]=S):S=e[18];let C;e[19]===x?C=e[20]:(C=(0,Z.jsx)(VM,{value:s,children:(0,Z.jsxs)(kk,{className:`h-screen overflow-hidden`,children:[x,S]})}),e[19]=x,e[20]=C);let w;return e[21]!==y||e[22]!==C||e[23]!==m?(w=(0,Z.jsxs)(Z.Fragment,{children:[c,(0,Z.jsxs)(as,{children:[l,u,d,f,p,m,_,v,h,g,y,b,C]})]}),e[21]=y,e[22]=C,e[23]=m,e[24]=w):w=e[24],w}function Pq(e){nN(Ag(e))}Oc(),kf({apiOrigin:typeof window<`u`?window.okDesktop?.config.apiOrigin:void 0}),Hf(),mp()&&bp(),cm(),kp(),typeof window<`u`&&Wf({bridge:window.okDesktop}),typeof window<`u`&&tp({bridge:window.okDesktop}),typeof window<`u`&&Ws({bridge:window.okDesktop}),typeof window<`u`&&zs({bridge:window.okDesktop}),typeof window<`u`&&qf({bridge:window.okDesktop}),typeof window<`u`&&cf({bridge:window.okDesktop}),Np();var Fq=new Lc({defaultOptions:{queries:{retry:1,staleTime:1e4}}}),Iq=document.getElementById(`root`);if(!Iq)throw Error(`Root element not found`);var Lq=typeof window<`u`&&window.okDesktop?.config.mode===`navigator`;(0,Jc.createRoot)(Iq).render((0,Z.jsx)(Q.StrictMode,{children:(0,Z.jsx)(a,{i18n:Ko,children:(0,Z.jsx)(hn,{client:Fq,children:(0,Z.jsxs)(Wr,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,disableTransitionOnChange:!0,storageKey:`ok-theme-v1`,children:[(0,Z.jsx)(ks,{children:Lq&&window.okDesktop?(0,Z.jsx)(Sf,{bridge:window.okDesktop}):(0,Z.jsx)(Mq,{})}),(0,Z.jsx)(Df,{richColors:!0,closeButton:!0})]})})})}));
|
|
2019
|
+
`}\n${NU}\n${PU}`;function PG(e){let t=e.split(`/`).pop()?.replace(/\.md$/i,``).toLowerCase();return!!t&&_G.has(t)}function FG(e){return e===`darwin`?Ko._({id:`LtSYdi`}):e===`win32`?Ko._({id:`qi1F96`}):Ko._({id:`e1Rn_k`})}function IG(e){let t=(0,$.c)(18),{item:n,workspace:r,onClose:a}=e,{_:o}=i(),s=typeof window<`u`?window.okDesktop:void 0;if(!s)return null;let c=s.platform,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=FG(c),t[0]=l):l=t[0];let u=l,d,f;t[1]!==o||t[2]!==r?(d=r?null:o({id:`wTcjov`}),f=o(c===`darwin`?d?{id:`FvpFSZ`,values:{hint:d}}:{id:`LtSYdi`}:c===`win32`?d?{id:`o4dcAf`,values:{hint:d}}:{id:`qi1F96`}:d?{id:`zUhPuR`,values:{hint:d}}:{id:`e1Rn_k`}),t[1]=o,t[2]=r,t[3]=d,t[4]=f):(d=t[3],f=t[4]);let p=f,m=!r,h;t[5]!==n||t[6]!==a||t[7]!==r?(h=()=>{if(!r)return;a();let e=gg(r.contentDir,Dj(n),r.pathSeparator);s.shell.showItemInFolder(e)},t[5]=n,t[6]=a,t[7]=r,t[8]=h):h=t[8];let g,_;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(ke,{"aria-hidden":`true`}),_=(0,Z.jsx)(`span`,{className:`flex-1`,children:u}),t[9]=g,t[10]=_):(g=t[9],_=t[10]);let v;t[11]===d?v=t[12]:(v=d?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:d}):null,t[11]=d,t[12]=v);let y;return t[13]!==p||t[14]!==m||t[15]!==h||t[16]!==v?(y=(0,Z.jsxs)(Fa,{disabled:m,onSelect:h,"aria-label":p,children:[g,_,v]}),t[13]=p,t[14]=m,t[15]=h,t[16]=v,t[17]=y):y=t[17],y}function LG(e,t){return Ej({kind:e.endsWith(`/`)?`directory`:`file`,name:e,path:e},t)}function RG(e,t){return e!==t&&e.startsWith(t)}function zG(e,t){let n=[...new Set(e)],r=n.filter(e=>e.endsWith(`/`));return n.filter(e=>!r.some(t=>RG(e,t))).map(e=>LG(e,t))}function BG(e,t){return e===t||e.startsWith(`${t}/`)}function VG(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable||e.closest(`[contenteditable="true"]`)!==null}function HG(e,t,n){let r=new Set,i=new Set,a=new Set;for(let o of e){if(o.kind===`file`){r.add(o.path);continue}if(o.kind===`asset`){a.add(o.path);continue}i.add(o.path);for(let e of t)ls(e)&&e.docName.startsWith(`${o.path}/`)?r.add(e.docName):Io(e)&&e.path.startsWith(`${o.path}/`)&&a.add(e.path);for(let e of n){let t=hj(e);BG(t,o.path)&&i.add(t)}}return{docNames:r,folderPaths:i,assetPaths:a}}function UG(e,t){return e.kind===`file`?t.kind===`file`&&e.path===t.createdPath:e.kind===`asset`?!1:BG(t.createdPath,e.path)}function WG(e){let t=(0,$.c)(60),{item:n,context:r,anyActionBusy:a,workspace:o,handoff:c,model:l,okignoreBinding:u,projectLocalBinding:d,mergedConfig:f,onStartCreating:p,onCreateFromTemplate:m,onDuplicate:h,onDelete:g,onExpandSubtree:_,onCollapseSubtree:v,folderTreePaths:y,isAsset:b,documents:x}=e,{_:S}=i(),C=Ej(n,x),w=n.kind===`directory`,T=C.kind===`asset`?null:C,E=T!==null&&u!==null,D;t[0]!==S||t[1]!==w?(D=S(w?{id:`5D3Ior`}:{id:`dbhUX1`}),t[0]=S,t[1]=w,t[2]=D):D=t[2];let O=D,k=f?.appearance?.sidebar?.showHiddenFiles??!1,A=f?.appearance?.sidebar?.showAllFiles??!0,j=d!==null,M;t[3]!==w||t[4]!==n.path?(M=w?hj(n.path):null,t[3]=w,t[4]=n.path,t[5]=M):M=t[5];let N=ea(M),P=N.state.status===`ready`?(N.state.data.folder.templates_available?.length??0)>0:!0,F=l.getSelectedPaths(),I=F.includes(C.treePath)?zG(F,x):[],L=I.length>1?I:[C],R=L.length,z=Ko._({id:`djjdjr`,values:{deleteCount:R}}),B;t[6]!==b||t[7]!==w||t[8]!==n||t[9]!==o?(B=b?null:w?Sg({folderRelativePath:Dj(n),workspace:o}):vg({docName:fj(n.path),workspace:o}),t[6]=b,t[7]=w,t[8]=n,t[9]=o,t[10]=B):B=t[10];let H=B,U;t[11]===r?U=t[12]:(U=()=>r.close({restoreFocus:!1}),t[11]=r,t[12]=U);let W=U,G;t[13]===r?G=t[14]:(G=()=>r.close(),t[13]=r,t[14]=G);let K=G,q;t[15]!==S||t[16]!==d?(q=e=>{if(d===null)return;let t=d.patch({appearance:{sidebar:{showHiddenFiles:e}}});t.ok||(console.warn(`[FileTree] showHiddenFiles toggle rejected:`,qr(t.error)),X.error(S({id:`P47EWZ`}),{description:qr(t.error)}))},t[15]=S,t[16]=d,t[17]=q):q=t[17];let J=q,Y;t[18]!==S||t[19]!==d?(Y=e=>{if(d===null)return;let t=d.patch({appearance:{sidebar:{showAllFiles:e}}});t.ok||(console.warn(`[FileTree] showAllFiles toggle rejected:`,qr(t.error)),X.error(S({id:`P47EWZ`}),{description:qr(t.error)}))},t[18]=S,t[19]=d,t[20]=Y):Y=t[20];let ee=Y,te=0,ne=0;if(w){let e=gj(n.path);for(let t of y)(t===e||t.startsWith(e))&&(te++,OW(l.getItem(t))?.isExpanded()&&ne++)}let re=w&&ne<te,ie=w&&ne>0,ae;t[21]===K?ae=t[22]:(ae=e=>{e||K()},t[21]=K,t[22]=ae);let oe;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,Z.jsx)(ao,{asChild:!0,children:(0,Z.jsx)(`span`,{"aria-hidden":`true`,"data-file-tree-context-menu-root":`true`,className:`block size-px`})}),t[23]=oe):oe=t[23];let se;t[24]!==S||t[25]!==a||t[26]!==E||t[27]!==j||t[28]!==K||t[29]!==W||t[30]!==z||t[31]!==L||t[32]!==P||t[33]!==ee||t[34]!==J||t[35]!==c||t[36]!==H||t[37]!==O||t[38]!==b||t[39]!==w||t[40]!==n||t[41]!==l||t[42]!==u||t[43]!==T||t[44]!==v||t[45]!==m||t[46]!==g||t[47]!==h||t[48]!==_||t[49]!==p||t[50]!==A||t[51]!==k||t[52]!==ie||t[53]!==re||t[54]!==C||t[55]!==o?(se=(0,Z.jsx)($a,{sideOffset:0,align:`start`,"data-file-tree-context-menu-root":`true`,className:`min-w-52`,children:w?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Fa,{disabled:a,onSelect:()=>{W(),p(`file`,hj(n.path))},children:[(0,Z.jsx)(Gl,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`HdkSiO`})]}),P?(0,Z.jsxs)(eo,{children:[(0,Z.jsxs)(Ba,{disabled:a,children:[(0,Z.jsx)(Qa,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`Uuj_R4`})]}),(0,Z.jsx)(Oa,{children:(0,Z.jsx)(DW,{parentDir:hj(n.path),onSelectTemplate:e=>{W(),m(hj(n.path),e)},ItemComponent:Fa})})]}):null,(0,Z.jsxs)(Fa,{disabled:a,onSelect:()=>{W(),p(`folder`,hj(n.path))},children:[(0,Z.jsx)(fl,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`96G6Re`})]}),(0,Z.jsx)(Ka,{}),(0,Z.jsx)(IG,{item:n,workspace:o,onClose:K}),(0,Z.jsx)(XW,{input:H,installStates:c.installStates,isElectronHost:c.isElectronHost,dispatch:c.dispatch}),(0,Z.jsxs)(eo,{children:[(0,Z.jsxs)(Ba,{children:[(0,Z.jsx)(Et,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`oCZkaG`})]}),(0,Z.jsxs)(Oa,{children:[(0,Z.jsx)(Fa,{disabled:!o,onSelect:()=>{o&&(K(),gG(gg(o.contentDir,Dj(n),o.pathSeparator),`full`))},children:(0,Z.jsx)(s,{id:`oQA-cA`})}),(0,Z.jsx)(Fa,{onSelect:()=>{K(),gG(Dj(n),`relative`)},children:(0,Z.jsx)(s,{id:`s061i4`})})]})]}),(0,Z.jsx)(Ka,{}),(0,Z.jsx)(Ua,{checked:k,onCheckedChange:J,disabled:!j,"data-testid":`file-tree-menu-show-hidden-files`,children:(0,Z.jsx)(s,{id:`XcGbim`})}),(0,Z.jsx)(Ua,{checked:A,onCheckedChange:ee,disabled:!j,"data-testid":`file-tree-menu-show-all-files`,children:(0,Z.jsx)(s,{id:`i8dKs-`})}),re||ie?(0,Z.jsx)(Ka,{}):null,re?(0,Z.jsxs)(Fa,{onSelect:()=>{K(),_(n.path)},children:[(0,Z.jsx)(ru,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`OlAl5i`})]}):null,ie?(0,Z.jsxs)(Fa,{onSelect:()=>{K(),v(n.path)},children:[(0,Z.jsx)(ul,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`qvWGzP`})]}):null,(0,Z.jsx)(Ka,{}),(0,Z.jsxs)(Fa,{disabled:a,onSelect:()=>{C.kind!==`asset`&&(K(),h(C))},children:[(0,Z.jsx)($e,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`euc6Ns`})]}),(0,Z.jsxs)(Fa,{disabled:a,onSelect:()=>{W(),l.startRenaming(n.path)},children:[(0,Z.jsx)(V,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`2wxgft`})]}),(0,Z.jsxs)(Fa,{"data-testid":`file-tree-menu-hide`,disabled:!E,onSelect:()=>{if(!u||!T)return;K();let e=ZU(T),t=io(u.current()),n=Wa(t,e);if(n===t)return;u.patch(qa(n));let r=T.path.split(`/`).pop()||T.path;X.success(S({id:`4xtLTl`,values:{basename:r}}),{description:S({id:`nWv1ja`}),duration:5e3})},children:[(0,Z.jsx)(Nt,{"aria-hidden":`true`}),O]}),(0,Z.jsxs)(Fa,{variant:`destructive`,disabled:a,onSelect:()=>{K(),g(L)},children:[(0,Z.jsx)(fs,{"aria-hidden":`true`}),z]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(IG,{item:n,workspace:o,onClose:K}),!b&&(0,Z.jsx)(XW,{input:H,installStates:c.installStates,isElectronHost:c.isElectronHost,dispatch:c.dispatch}),(0,Z.jsxs)(eo,{children:[(0,Z.jsxs)(Ba,{children:[(0,Z.jsx)(Et,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`oCZkaG`})]}),(0,Z.jsxs)(Oa,{children:[(0,Z.jsx)(Fa,{disabled:!o,onSelect:()=>{o&&(K(),gG(gg(o.contentDir,Dj(n),o.pathSeparator),`full`))},children:(0,Z.jsx)(s,{id:`oQA-cA`})}),(0,Z.jsx)(Fa,{onSelect:()=>{K(),gG(Dj(n),`relative`)},children:(0,Z.jsx)(s,{id:`s061i4`})})]})]}),(0,Z.jsx)(Ka,{}),b?null:(0,Z.jsxs)(Fa,{disabled:a,onSelect:()=>{K(),h(C)},children:[(0,Z.jsx)($e,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`euc6Ns`})]}),(0,Z.jsxs)(Fa,{disabled:a,onSelect:()=>{W(),l.startRenaming(n.path)},children:[(0,Z.jsx)(V,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`2wxgft`})]}),T?(0,Z.jsxs)(Fa,{"data-testid":`file-tree-menu-hide`,disabled:!E,onSelect:()=>{if(!u)return;K();let e=ZU(T),t=io(u.current()),n=Wa(t,e);if(n===t)return;u.patch(qa(n));let r=T.path.split(`/`).pop()||T.path;X.success(S({id:`OD0FCX`,values:{basename:r}}),{description:S({id:`nWv1ja`}),duration:5e3})},children:[(0,Z.jsx)(Nt,{"aria-hidden":`true`}),O]}):null,(0,Z.jsxs)(Fa,{variant:`destructive`,disabled:a,onSelect:()=>{K(),g(L)},children:[(0,Z.jsx)(fs,{"aria-hidden":`true`}),z]})]})}),t[24]=S,t[25]=a,t[26]=E,t[27]=j,t[28]=K,t[29]=W,t[30]=z,t[31]=L,t[32]=P,t[33]=ee,t[34]=J,t[35]=c,t[36]=H,t[37]=O,t[38]=b,t[39]=w,t[40]=n,t[41]=l,t[42]=u,t[43]=T,t[44]=v,t[45]=m,t[46]=g,t[47]=h,t[48]=_,t[49]=p,t[50]=A,t[51]=k,t[52]=ie,t[53]=re,t[54]=C,t[55]=o,t[56]=se):se=t[56];let ce;return t[57]!==se||t[58]!==ae?(ce=(0,Z.jsxs)(ro,{open:!0,modal:!1,onOpenChange:ae,children:[oe,se]}),t[57]=se,t[58]=ae,t[59]=ce):ce=t[59],ce}async function GG(e,t,n,r){try{let i=await fetch(`/api/documents?showAll=true&dir=${encodeURIComponent(e)}&depth=1`,{signal:t,headers:VW});if(HW(i)){let e=await GW(i);return{kind:`entries`,entries:Ro(e.entries),truncated:e.truncated}}let a=await ve(i,n);if(!a.ok)return{kind:`http-error`,title:a.title};let o=Or.safeParse(a.body);return o.success?{kind:`entries`,entries:Ro(o.data.documents),truncated:o.data.truncated===!0}:{kind:`http-error`,title:r}}catch(e){return e instanceof UW?{kind:`http-error`,title:e.message}:{kind:`network-error`,cause:e}}}function KG(e){let t=(0,$.c)(356),{ref:n}=e,{_:r,i18n:a}=i(),{activeDocName:o,activeTarget:c,closeTabs:l,closeDocument:u,closeAndClearForRename:d,getPoolActiveDocName:f,poolHas:p,isNewTabActive:m,openTarget:h,prewarm:g,remapTabsForRename:_}=pt(),{notifySidebarFileSelected:v}=Ok(),{resolvedTheme:y}=vr(),{addPage:b,pageMeta:x}=es(),S;t[0]===x?S=t[1]:(S=function(e,t){return ss(e,t??x.get(e)?.size)??{kind:`doc`,target:e,docName:e}},t[0]=x,t[1]=S);let C=S,w;t[2]!==C||t[3]!==v||t[4]!==h?(w=function(e,t){h(C(e,t),{tabBehavior:`replace-active`}),Vo(Go(e)),v()},t[2]=C,t[3]=v,t[4]=h,t[5]=w):w=t[5];let T=w,E;t[6]!==v||t[7]!==h?(E=function(e){let t=zo(e);h({kind:`folder`,target:e,folderPath:e},{tabBehavior:`replace-active`}),Vo(t),v()},t[6]=v,t[7]=h,t[8]=E):E=t[8];let D=E,O;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(O=[],t[9]=O):O=t[9];let[k,j]=(0,Q.useState)(O),[M,N]=(0,Q.useState)(!0),[P,F]=(0,Q.useState)(null),[I,L]=(0,Q.useState)(!1),R=Ap(),z=(0,Q.useRef)(null),[B,V]=(0,Q.useState)(null),[H,U]=(0,Q.useState)(null),[W,G]=(0,Q.useState)(null),[K,q]=(0,Q.useState)(null),{conflicts:J}=Ni(),[Y,ee]=(0,Q.useState)(null),[te,ne]=(0,Q.useState)(null),[re,ie]=(0,Q.useState)(!1),ae=(0,Q.useRef)(re),se;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(se=new Set,t[10]=se):se=t[10];let ce=(0,Q.useRef)(se),le=(0,Q.useRef)(k),ue=(0,Q.useRef)(x),de;t[11]!==k||t[12]!==D||t[13]!==T||t[14]!==v||t[15]!==h?(de=function(e,t){let n=t===void 0?k:t,r=mW(e,n);if(r.kind===`none`){console.debug(`[FileTree] Dropped selection for unknown docName:`,_j(e));return}if(r.kind===`asset`){h({kind:`asset`,target:r.path,assetPath:r.path,mediaKind:r.mediaKind},{tabBehavior:`replace-active`}),Vo(r.hash),v();return}if(r.kind===`folder`){D(r.path);return}let i=n.find(e=>ls(e)&&e.docName===r.path);T(r.path,i?.size)},t[11]=k,t[12]=D,t[13]=T,t[14]=v,t[15]=h,t[16]=de):de=t[16];let fe=de,pe;t[17]!==v||t[18]!==h?(pe=function(e){h({kind:`asset`,target:e,assetPath:e,mediaKind:le.current.find(t=>Io(t)&&t.path===e)?.mediaKind??null},{tabBehavior:`replace-active`}),Vo(Uo(e)),v()},t[17]=v,t[18]=h,t[19]=pe):pe=t[19];let me=pe,he=(0,Q.useRef)(o),ge;t[20]===k?ge=t[21]:(ge=new Set(k.filter(Io).map(yK)),t[20]=k,t[21]=ge);let _e=ge,ye=(0,Q.useRef)(_e),be;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(be=[],t[22]=be):be=t[22];let xe=(0,Q.useRef)(be),Se=(0,Q.useRef)(null),Ce=(0,Q.useRef)(vK),we=(0,Q.useRef)(null),Te=(0,Q.useRef)(null),Ee=(0,Q.useRef)(!1),De=(0,Q.useRef)(!1),Oe=(0,Q.useRef)(null),ke;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ke={row:null,root:null},t[23]=ke):ke=t[23];let Ae=(0,Q.useRef)(ke),je=(0,Q.useRef)(_K),Me=(0,Q.useRef)(null),Ne;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=new Map,t[24]=Ne):Ne=t[24];let Pe=(0,Q.useRef)(Ne),Fe;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=new Set,t[25]=Fe):Fe=t[25];let Ie=(0,Q.useRef)(Fe),Le;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(Le=new Map,t[26]=Le):Le=t[26];let Re=(0,Q.useRef)(Le),ze=(0,Q.useRef)(0),Be;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(Be=new Set,t[27]=Be):Be=t[27];let Ve=(0,Q.useRef)(Be),He=(0,Q.useRef)(gK),Ue=(0,Q.useRef)(hK),We=(0,Q.useRef)(!1),Ge=(0,Q.useRef)(!0),Ke=(0,Q.useRef)(null),qe=(0,Q.useRef)(null),Je=(0,Q.useRef)(mK),Ye=(0,Q.useRef)(pK),Xe=(0,Q.useRef)(fK),Qe=(0,Q.useRef)(dK),$e=(0,Q.useRef)(c),[et,tt]=(0,Q.useState)(!1),nt;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(nt=function(){z.current!==null&&(clearTimeout(z.current),z.current=null)},t[28]=nt):nt=t[28];let rt=nt,it;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(it=function(){rt(),L(!1)},t[29]=it):it=t[29];let at=it,ot;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(ot=function(e){at(),F(e)},t[30]=ot):ot=t[30];let st=ot,ct;t[31]===r?ct=t[32]:(ct=function(){if(rt(),Ep()){F(null),L(!0),z.current=setTimeout(()=>{z.current=null,Ke.current?.()},AG);return}L(!1),F(r({id:`34qyH5`}))},t[31]=r,t[32]=ct);let lt=ct,ut=(0,Q.useRef)(!0),dt;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(dt=()=>{if(ut.current){ut.current=!1;return}Ke.current?.()},t[33]=dt):dt=t[33];let ft;t[34]===R?ft=t[35]:(ft=[R],t[34]=R,t[35]=ft),(0,Q.useEffect)(dt,ft);let mt,ht;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(mt=()=>rt,ht=[],t[36]=mt,t[37]=ht):(mt=t[36],ht=t[37]),(0,Q.useEffect)(mt,ht);let gt,_t;t[38]!==k.length||t[39]!==M?(gt=()=>{if(M||k.length===0)return;let e=qe.current?.querySelector(CP)?.shadowRoot;if(!e)return;let t=e,n=function(){Oe.current!==null&&clearTimeout(Oe.current),Oe.current=setTimeout(()=>{De.current=!1,Oe.current=null},0)},r=function(e){if(!(e instanceof DragEvent))return;let t=xK(e),n=t?.dataset.itemPath;if(!n)return;let r=yW(t.dataset.itemType===`folder`?gj(n):n,le.current,ue.current);r&&(Oe.current!==null&&(clearTimeout(Oe.current),Oe.current=null),De.current=!0,e.dataTransfer?.setData(rE,aE(r)))},i=function(e){if(!(e instanceof DragEvent)||!Fj(e))return;let t=CK(e);if(!t){mG(Ae);return}e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`),hG(Ae,t)},a=function(e){if(!(e instanceof DragEvent)||!Fj(e))return;let n=e.relatedTarget;n instanceof Node&&t.contains(n)||mG(Ae)},o=function(e){if(!(e instanceof DragEvent)||!Fj(e))return;let t=CK(e),n=Ij(e);if(!t||n.length===0){mG(Ae);return}e.preventDefault(),e.stopPropagation(),mG(Ae),je.current(n,t.parentDir,t.busyPath)};return e.addEventListener(`dragstart`,r,{capture:!0}),e.addEventListener(`dragover`,i,{capture:!0}),e.addEventListener(`dragleave`,a,{capture:!0}),e.addEventListener(`drop`,o,{capture:!0}),e.addEventListener(`dragend`,n,{capture:!0}),window.addEventListener(`drop`,n,!0),window.addEventListener(`dragend`,n,!0),()=>{e.removeEventListener(`dragstart`,r,{capture:!0}),e.removeEventListener(`dragover`,i,{capture:!0}),e.removeEventListener(`dragleave`,a,{capture:!0}),e.removeEventListener(`drop`,o,{capture:!0}),e.removeEventListener(`dragend`,n,{capture:!0}),window.removeEventListener(`drop`,n,!0),window.removeEventListener(`dragend`,n,!0),mG(Ae),Oe.current!==null&&(clearTimeout(Oe.current),Oe.current=null),De.current=!1}},_t=[k.length,M],t[38]=k.length,t[39]=M,t[40]=gt,t[41]=_t):(gt=t[40],_t=t[41]),(0,Q.useEffect)(gt,_t);let{selectedFilePath:vt,selectedFolderPath:yt,navigationPath:xt}=pW(c,m?null:o),St=vt?dj(vt,k.find(e=>ls(e)&&e.docName===vt)?.docExt):yt?gj(yt):c?.kind===`asset`?c.assetPath:null,Ct=re?null:St,wt=Kg().states,{dispatch:Tt}=Fg(),Et;t[42]!==Tt||t[43]!==wt?(Et={installStates:wt,isElectronHost:typeof window<`u`&&window.okDesktop!=null,dispatch:Tt},t[42]=Tt,t[43]=wt,t[44]=Et):Et=t[44];let Dt=Et,{okignoreBinding:Ot,projectLocalBinding:kt,merged:At}=oe(),jt=At?.appearance?.sidebar?.showHiddenFiles??!1,Mt=At?.appearance?.sidebar?.showAllFiles??!0,Nt;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(Nt=()=>Me.current===null,t[45]=Nt):Nt=t[45];let Pt=Nt,Ft;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(Ft=[],t[46]=Ft):Ft=t[46];let It;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(It={set:`complete`,spriteSheet:TG,byFileExtension:{md:{name:bG,viewBox:xG},mdx:{name:bG,viewBox:xG}}},t[47]=It):It=t[47];let Lt;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(Lt={contextMenu:{enabled:!0,triggerMode:`both`,buttonVisibility:`when-needed`}},t[48]=Lt):Lt=t[48];let Rt;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(Rt={canDrag:Pt,canDrop:Pt,onDropComplete:e=>Qe.current(e),onDropError:uK},t[49]=Rt):Rt=t[49];let zt,Vt;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(zt={canRename:Pt,onRename:e=>Ye.current(e),onError:e=>Xe.current(e)},Vt=e=>Je.current(e),t[50]=zt,t[51]=Vt):(zt=t[50],Vt=t[51]);let Ht;t[52]===r?Ht=t[53]:(Ht={paths:Ft,initialExpansion:`closed`,fileTreeSearchMode:`hide-non-matches`,initialVisibleRowCount:18,stickyFolders:!0,...jU,icons:It,unsafeCSS:NG,composition:Lt,dragAndDrop:Rt,renaming:zt,onSelectionChange:Vt,renderRowDecoration:e=>{let{item:t}=e;if(t.kind===`file`){let e=le.current.find(e=>ls(e)&&dj(e.docName,e.docExt)===t.path);if(e?.isSymlink){let t=e.targetPath;return{icon:vG,title:r(t?{id:`JE21eh`,values:{targetPath:t}}:{id:`BQu9Pg`})}}return PG(t.path)?{icon:yG,title:r({id:`i9toLO`})}:null}let n=le.current.find(e=>Jo(e)&&gj(e.path)===gj(t.path));if(n?.isSymlink){let e=n.targetPath;return{icon:vG,title:r(e?{id:`JE21eh`,values:{targetPath:e}}:{id:`BQu9Pg`})}}return null}},t[52]=r,t[53]=Ht);let{model:Ut}=AU(Ht),Wt;t[54]===Ut?Wt=t[55]:(Wt=function(e){let t=Ut.getItem(e)??Ut.getItem(gj(e));return t?.isDirectory()?gj(hj(t.getPath())):e},t[54]=Ut,t[55]=Wt);let Gt=Wt,Kt,qt;t[56]===k?(Kt=t[57],qt=t[58]):(qt=vj(k),Kt=yj(qt),t[56]=k,t[57]=Kt,t[58]=qt);let Jt=Kt,Yt=(0,Q.useRef)(qt),Xt;t[59]===k?Xt=t[60]:(Xt=xj(k),t[59]=k,t[60]=Xt);let Zt=Xt,Qt=(0,Q.useRef)(Zt),$t=yt?Sj(gj(yt)).slice(0,-1):Sj(Ct??xt),en=$t.join(`\0`),tn;t[61]===Ut?tn=t[62]:(tn=()=>{let e=new Set;for(let t of Qt.current)OW(Ut.getItem(t))?.isExpanded()&&e.add(t);return e},t[61]=Ut,t[62]=tn);let nn=tn,rn;t[63]===nn?rn=t[64]:(rn=e=>{let t=new Set(xj(e??le.current)),n=nn();for(let e of xe.current)n.add(e);return[...n].filter(e=>t.has(e))},t[63]=nn,t[64]=rn);let an=rn,on;t[65]!==an||t[66]!==Ut?(on=e=>{let t=vj(e??le.current);Ut.resetPaths(t,{initialExpandedPaths:an(e)})},t[65]=an,t[66]=Ut,t[67]=on):on=t[67];let sn=on,cn;t[68]!==r||t[69]!==lt?(cn=async function(e){let t=ze.current,n=new AbortController;Re.current.set(e,n);let i=await GG(hj(e),n.signal,r({id:`8RtNI0`}),r({id:`HlmZBk`}));if(Re.current.get(e)===n&&Re.current.delete(e),n.signal.aborted||t!==ze.current)return;if(i.kind===`network-error`){lt(),console.warn(`[FileTree] lazy folder children fetch failed:`,e,i.cause);return}if(i.kind===`http-error`){console.warn(`[FileTree] lazy folder children http error:`,e,i.title),st(i.title);return}let a=We.current||Ge.current,o=qo(i.entries,a);Ie.current.add(e),j(t=>qW(t,e,o,Pe.current)),F(null),at(),i.truncated&&V(i.entries.length)},t[68]=r,t[69]=lt,t[70]=cn):cn=t[70];let ln=cn,un;t[71]!==nn||t[72]!==ln?(un=()=>{let e=nn(),t=Ve.current;if(Ve.current=e,Ge.current)for(let n of e){if(t.has(n)||Ie.current.has(n)||Re.current.has(n))continue;let e=hj(n);le.current.find(t=>Jo(t)&&t.path===e)?.hasChildren!==!1&&ln(n)}},t[71]=nn,t[72]=ln,t[73]=un):un=t[73];let dn=un,fn;t[74]!==nn||t[75]!==ln?(fn=()=>{for(let e of nn())Ie.current.has(e)||Re.current.has(e)||ln(e)},t[74]=nn,t[75]=ln,t[76]=fn):fn=t[76];let pn=fn,mn;t[77]!==Ut||t[78]!==sn?(mn=(e,t,n,r)=>{let i=r===void 0?[]:r,a=0,o=null;for(let{fromDocName:t,toDocName:r}of n){let n=e.find(e=>ls(e)&&e.docName===t);if(n==null||Ut.getItem(r)==null)continue;let i=dj(r,n.docExt);Ut.move(r,i),o=i,a+=1}for(let{toPath:e}of i){let t=oj(e);if(t===``)continue;let n=e.slice(0,-t.length);Ut.getItem(n)!=null&&(Ut.getItem(e)??Ut.move(n,e),o=e,a+=1)}a!==0&&(sn(t),o!=null&&Ut.focusPath(o))},t[77]=Ut,t[78]=sn,t[79]=mn):mn=t[79];let hn=mn,gn;t[80]===Symbol.for(`react.memo_cache_sentinel`)?(gn=e=>{we.current=bj(e)},t[80]=gn):gn=t[80];let _n=gn,vn;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(vn=e=>ye.current.has(e),t[81]=vn):vn=t[81];let yn=vn,bn;t[82]!==r||t[83]!==b||t[84]!==D||t[85]!==T||t[86]!==sn?(bn=async function(e){if(e.kind===`asset`||Me.current!==null)return;let t=()=>{U(null),Me.current=null};Me.current=e.path,U(e.path),F(null);try{let n=await ve(await fetch(`/api/duplicate-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:e.kind,path:e.path})}),r({id:`dw_dUJ`}));if(!n.ok){X.error(n.title),sn(),t();return}let i=A(Kn,n.body,`duplicate-path`,null);if(i===null){let e=r({id:`67f-3g`});X.error(e),F(e),is([`files`,`backlinks`,`graph`]),sn(),t();return}for(let e of i.duplicatedDocNames)b(e);j(t=>{let n=Kj(t,e,i);return sn(n),_n(n),n}),is([`files`,`backlinks`,`graph`]),i.path!==e.path&&(i.kind===`folder`?D(i.path):T(i.path)),X.success(i.kind===`folder`?r({id:`iilQXA`}):r({id:`A6h5b-`}),{description:i.path}),t()}catch(e){let n=e,i=n instanceof Error?n.message:String(n);console.warn(`[FileTree] duplicate failed:`,n),X.error(r({id:`EBVbtP`}),{description:i}),sn(),t()}},t[82]=r,t[83]=b,t[84]=D,t[85]=T,t[86]=sn,t[87]=bn):bn=t[87];let xn=bn,Sn=(0,Q.useRef)(xn),Cn;t[88]===xn?Cn=t[89]:(Cn=()=>{Sn.current=xn},t[88]=xn,t[89]=Cn),(0,Q.useEffect)(Cn);let wn=function(e){let t=dG(e);if(!t||fG(t))return!1;let n=Ut.getFocusedPath()??Ut.getSelectedPaths()[0]??null;if(!n||n.endsWith(`/`)||yn(n))return!1;let r=fG(n);if(!r)return!1;let i=gj(t);if(!Qt.current.includes(i))return!1;let a=`${t}${r}`;return Yt.current.includes(a)?!1:(cr({sourcePath:n,destinationPath:a,isFolder:!1}),Ut.move(n,a),!0)},Tn;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(Tn=e=>{let t=e??Se.current;!t||Se.current!==t||(t.disposeCommitListener(),Se.current=null)},t[90]=Tn):Tn=t[90];let En=Tn,Dn;t[91]!==r||t[92]!==En||t[93]!==u||t[94]!==l||t[95]!==sn?(Dn=async function(e,t){let n=t===void 0?{}:t,i=n.updateUi??!0,a=n.restoreLocation??i;En(e),i&&U(e.renamePath);try{let t=await fetch(`/api/delete-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:e.kind,path:e.createdPath})});if(!t.ok&&t.status!==404){let n=e.kind,a=e.createdPath,o=await ve(t,r({id:`EcM3k7`,values:{kind:n}}));if(o.ok)return;let s=o.title,c=r({id:`YPFBfr`,values:{detail:s,kind:n,createdPath:a}});i?X.error(c):console.warn(`[FileTree] cleanup pending create failed: ${c}`),i&&(U(null),sn());return}}catch(t){if(console.warn(`[FileTree] cleanup pending create failed:`,t),i){let t=e.kind,n=e.createdPath;X.error(r({id:`_TDESN`,values:{kind:t,createdPath:n}}))}i&&(U(null),sn());return}i&&(e.kind===`file`?u(e.createdPath):l([bt(e.createdPath)],{force:!0})),i&&j(t=>{let n=Wj(t,e.kind===`file`?[e.createdPath]:[],e.kind===`folder`?e.createdPath:void 0);return _n(n),n}),is([`files`,`backlinks`,`graph`]),a&&(window.location.hash=e.previousHash),i&&U(null)},t[91]=r,t[92]=En,t[93]=u,t[94]=l,t[95]=sn,t[96]=Dn):Dn=t[96];let On=Dn,kn,An;t[97]===Symbol.for(`react.memo_cache_sentinel`)?(kn=()=>()=>{let e=Se.current;e&&Ce.current(e,{restoreLocation:!1,updateUi:!1}).catch(lK)},An=[],t[97]=kn,t[98]=An):(kn=t[97],An=t[98]),(0,Q.useEffect)(kn,An);let jn;t[99]!==r||t[100]!==lt?(jn=()=>{let e=!0,t=null,n=BW(async function(){t?.abort();let n=new AbortController;t=n,ze.current+=1;for(let e of Re.current.values())e.abort();Re.current.clear(),Ie.current.clear();try{let t=Ge.current,i=await fetch(t?`/api/documents?showAll=true&dir=&depth=1`:`/api/documents`,{signal:n.signal,headers:t?VW:void 0});if(t&&HW(i)){let{entries:n,truncated:r}=await GW(i);if(!e)return;let a=We.current||t,o=qo(Ro(n),a);j(e=>qW(e,``,o,Pe.current)),F(null),at(),V(r?n.length:null),Ue.current()}else{let n=await ve(i,r({id:`8RtNI0`}));if(!e)return;if(!n.ok)st(n.title),V(null);else{let e=Or.safeParse(n.body);if(!e.success)st(r({id:`HlmZBk`})),V(null);else{let n=We.current||t,r=qo(Ro(e.data.documents),n);j(t?e=>qW(e,``,r,Pe.current):KW(r,le.current,Pe.current)),F(null),at(),V(t&&e.data.truncated===!0?e.data.documents.length:null),t&&Ue.current()}}}}catch(t){let r=t;if(n.signal.aborted)return;e&&(r instanceof UW?st(r.message):lt()),console.warn(`[FileTree] fetch failed:`,r)}e&&N(!1)},()=>t?.abort());Ke.current=()=>n.request(),n.request();let i=()=>{document.visibilityState===`visible`&&n.request()};window.addEventListener(`focus`,i),window.addEventListener(`visibilitychange`,i);let a=Xo(e=>{e.includes(`files`)&&n.request()});return()=>{e=!1,Ke.current=null,n.dispose();for(let e of Re.current.values())e.abort();Re.current.clear(),window.removeEventListener(`focus`,i),window.removeEventListener(`visibilitychange`,i),a()}},t[99]=r,t[100]=lt,t[101]=jn):jn=t[101];let Mn;t[102]===r?Mn=t[103]:(Mn=[r],t[102]=r,t[103]=Mn),(0,Q.useEffect)(jn,Mn);let Nn=(0,Q.useRef)(!0),Fn;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(Fn=()=>{if(Nn.current){Nn.current=!1;return}Ke.current?.()},t[104]=Fn):Fn=t[104];let Ln;t[105]===jt?Ln=t[106]:(Ln=[jt],t[105]=jt,t[106]=Ln),(0,Q.useEffect)(Fn,Ln);let Rn=(0,Q.useRef)(!0),zn;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(zn=()=>{if(Rn.current){Rn.current=!1;return}Ke.current?.()},t[107]=zn):zn=t[107];let Bn;t[108]===Mt?Bn=t[109]:(Bn=[Mt],t[108]=Mt,t[109]=Bn),(0,Q.useEffect)(zn,Bn);let Vn,Hn;t[110]===Symbol.for(`react.memo_cache_sentinel`)?(Vn=()=>{let e=!0;return fetch(`/api/workspace`).then(async t=>{let n=await t.json();if(!e||!t.ok)return;let r=A(In,n,`workspace`,null);r&&ne({contentDir:r.contentDir,pathSeparator:r.pathSeparator})}).catch(cK),()=>{e=!1}},Hn=[],t[110]=Vn,t[111]=Hn):(Vn=t[110],Hn=t[111]),(0,Q.useEffect)(Vn,Hn);let Un;t[112]!==an||t[113]!==Ut||t[114]!==Jt?(Un=()=>{if(we.current===Jt){we.current=null;return}Ut.resetPaths(Yt.current,{initialExpandedPaths:an()})},t[112]=an,t[113]=Ut,t[114]=Jt,t[115]=Un):Un=t[115];let Wn;t[116]!==Ut||t[117]!==Jt?(Wn=[Ut,Jt],t[116]=Ut,t[117]=Jt,t[118]=Wn):Wn=t[118],(0,Q.useEffect)(Un,Wn),AW(Ut,Ct,en,Ee,Jt);let Gn;t[119]===Symbol.for(`react.memo_cache_sentinel`)?(Gn=()=>{ie(!1)},t[119]=Gn):Gn=t[119];let qn;t[120]===St?qn=t[121]:(qn=[St],t[120]=St,t[121]=qn),(0,Q.useEffect)(Gn,qn);let Jn,Yn;t[122]===re?(Jn=t[123],Yn=t[124]):(Jn=()=>{ae.current=re;for(let e of ce.current)e()},Yn=[re],t[122]=re,t[123]=Jn,t[124]=Yn),(0,Q.useEffect)(Jn,Yn);let Xn;t[125]!==Ct||t[126]!==M||t[127]!==Ut?(Xn=()=>{M||!Ct||dW(Ut)},t[125]=Ct,t[126]=M,t[127]=Ut,t[128]=Xn):Xn=t[128];let Zn;t[129]!==en||t[130]!==Ct||t[131]!==M||t[132]!==Ut||t[133]!==Jt?(Zn=[Ct,en,Jt,M,Ut],t[129]=en,t[130]=Ct,t[131]=M,t[132]=Ut,t[133]=Jt,t[134]=Zn):Zn=t[134],(0,Q.useEffect)(Xn,Zn);let $n,er;t[135]===Ut?($n=t[136],er=t[137]):($n=()=>Ut.subscribe(()=>{if(!Ut.isSearchOpen())for(let e of xe.current){let t=OW(Ut.getItem(e));t&&!t.isExpanded()&&t.expand()}}),er=[Ut],t[135]=Ut,t[136]=$n,t[137]=er),(0,Q.useEffect)($n,er);let tr,rr;t[138]===Ut?(tr=t[139],rr=t[140]):(tr=()=>Ut.subscribe(()=>He.current()),rr=[Ut],t[138]=Ut,t[139]=tr,t[140]=rr),(0,Q.useEffect)(tr,rr);let ir,ar;t[141]===Ut?(ir=t[142],ar=t[143]):(ir=()=>Ut.onMutation(`remove`,e=>{let t=Se.current;!t||e.path!==t.renamePath||Ce.current(t)}),ar=[Ut],t[141]=Ut,t[142]=ir,t[143]=ar),(0,Q.useEffect)(ir,ar);let or;t[144]!==b||t[145]!==d||t[146]!==f||t[147]!==me||t[148]!==D||t[149]!==T||t[150]!==p||t[151]!==hn||t[152]!==_?(or=async(e,t,n,r)=>{let i=t===void 0?[]:t,a=n===void 0?[]:n,o=r?.docName??he.current,s=qj(o,e),c=r?.folderPath??($e.current?.kind===`folder`?$e.current.folderPath:null),l=c?Ze(c,i):null,u=r?.assetPath??($e.current?.kind===`asset`?$e.current.assetPath:null),m=u?a.find(e=>e.fromPath===u)?.toPath??Ze(u,i):null;Bt(e);let h=Jj(e,f(),p);await Promise.all(h.map(e=>d(e)));for(let t of e)b(t.toDocName);_(e,i,a),j(t=>{let n=Uj(t,e,i,a);return hn(t,n,e,a),_n(n),n}),c&&l&&l!==c?D(l):s&&s!==o?(T(s),pG(s)):u&&m&&m!==u&&me(m),is([`files`,`backlinks`,`graph`])},t[144]=b,t[145]=d,t[146]=f,t[147]=me,t[148]=D,t[149]=T,t[150]=p,t[151]=hn,t[152]=_,t[153]=or):or=t[153];let sr=or;async function cr(e){let t=!e.isFolder&&yn(e.sourcePath),n=t?e.sourcePath:Oj(e.sourcePath,e.isFolder);U(n),F(null);try{let i=cj(e.sourcePath,e.destinationPath,e.isFolder,t);if(i.kind===`block`){X.error(r({id:`FaBZwp`})),queueMicrotask(()=>{sn()}),En(),U(null);return}let a=t?i.destinationPath:Oj(i.destinationPath,e.isFolder),o=e.isFolder?{kind:`folder`,fromPath:hj(n),toPath:hj(a)}:t?{kind:`asset`,fromPath:n,toPath:a}:{kind:`file`,fromPath:fj(n),toPath:fj(a)},s={docName:he.current,folderPath:$e.current?.kind===`folder`?$e.current.folderPath:null,assetPath:$e.current?.kind===`asset`?$e.current.assetPath:null},c=await ve(await fetch(`/api/rename-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(o)}),r({id:`gijbne`}));if(!c.ok){X.error(c.title),sn();let e=Se.current;e&&e.renamePath===n?await On(e):En(),U(null);return}let l=A(Xr,c.body,`rename-path`,{renamed:[],renamedAssets:[]});try{await sr(l.renamed,e.isFolder?[{fromPath:hj(n),toPath:hj(a)}]:[],l.renamedAssets,s)}catch(e){console.warn(`[FileTree] post-rename reconciliation failed`,{err:e,sourceTreePath:n,destinationTreePath:a,renamedCount:l.renamed.length,renamedAssetCount:l.renamedAssets.length}),X.error(r({id:`dDpCOp`}))}En(),U(null)}catch(e){console.warn(`[FileTree] rename failed:`,e);let t=r({id:`HIb0vl`});X.error(t),F(t),sn();let i=Se.current;i&&i.renamePath===n?await On(i):En(),U(null)}}let lr;t[154]!==r||t[155]!==sr||t[156]!==sn?(lr=async function(e){let t=e.draggedPaths.map(t=>{let n=jj(t,e.target);return t===n?null:{sourcePath:t,destinationTreePath:n}}).filter(sK);if(t.length!==0){U(t[0]?.sourcePath??null),F(null);try{let e=[],n=[],i=[],a={docName:he.current,folderPath:$e.current?.kind===`folder`?$e.current.folderPath:null,assetPath:$e.current?.kind===`asset`?$e.current.assetPath:null};for(let a of t){let t=a.sourcePath.endsWith(`/`),o=!t&&yn(a.sourcePath),s=t?{kind:`folder`,fromPath:hj(a.sourcePath),toPath:hj(a.destinationTreePath)}:o?{kind:`asset`,fromPath:a.sourcePath,toPath:a.destinationTreePath}:{kind:`file`,fromPath:fj(a.sourcePath),toPath:fj(a.destinationTreePath)},c=await ve(await fetch(`/api/rename-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(s)}),r({id:`dOHMA0`}));if(!c.ok){X.error(c.title),sn(),U(null);return}let l=A(Xr,c.body,`rename-path:drop`,{renamed:[],renamedAssets:[]});e=e.concat(l.renamed),n=n.concat(l.renamedAssets),t&&i.push({fromPath:hj(a.sourcePath),toPath:hj(a.destinationTreePath)})}try{await sr(e,i,n,a)}catch(i){console.warn(`[FileTree] post-move reconciliation failed`,{err:i,operationCount:t.length,renamedCount:e.length,renamedAssetCount:n.length}),X.error(r({id:`8OxKZy`}))}U(null)}catch(e){console.warn(`[FileTree] move failed:`,e),X.error(r({id:`HIb0vl`})),sn(),U(null)}}},t[154]=r,t[155]=sr,t[156]=sn,t[157]=lr):lr=t[157];let ur=lr,dr;t[158]!==r||t[159]!==b||t[160]!==sn?(dr=async function(e,t,n){if(e.length===0||Me.current!==null)return;let i=()=>{Me.current=null,U(null)};Me.current=n,U(n),F(null);let a=[],o=0,s=0;for(let n of e){let e=new FormData;e.append(`file`,n),e.append(`parentDocName`,Nj(t,n.name||`upload`));try{let i=await ve(await fetch(`/api/upload`,{method:`POST`,body:e}),r({id:`4Gz2wC`}));if(!i.ok){s+=1,X.error(i.title,{description:n.name});continue}let c=A(nr,i.body,`upload:drop`,null);if(c===null){s+=1,X.error(r({id:`4Gz2wC`}),{description:n.name});continue}let l=Pj(t,c);if(c.deduped===!0){s+=1,X.error(r({id:`4sKwf6`}),{description:l});continue}o+=1;let u=Lj(l,n);u&&a.push(u)}catch(e){let t=e;s+=1,console.warn(`[FileTree] external file upload failed:`,t),X.error(t instanceof TypeError?r({id:`HIb0vl`}):r({id:`4Gz2wC`}),{description:n.name})}}try{if(a.length>0){for(let e of a)ls(e)&&b(e.docName);j(e=>{let t=new Set(e.map(pj)),n=!1,r=[...e];for(let e of a){let i=pj(e);Pe.current.set(i,Date.now()),!t.has(i)&&(t.add(i),r.push(e),n=!0)}return n?(sn(r),_n(r),r):e})}o>0&&(is([`files`,`backlinks`,`graph`]),Ke.current?.(),X.success(Ko._({id:`v75Em9`,values:{uploadedCount:o}}),{description:t||r({id:`RSqaSd`})})),s>0&&F(o>0?Ko._({id:`yH7T4q`,values:{failedCount:s}}):r({id:`4Gz2wC`})),i()}catch(e){let t=e,n=r({id:`VcqWBy`});console.warn(`[FileTree] upload post-upload reconciliation failed:`,t),X.error(n),F(n),i()}},t[158]=r,t[159]=b,t[160]=sn,t[161]=dr):dr=t[161];let fr=dr,pr;t[162]===Symbol.for(`react.memo_cache_sentinel`)?(pr=function(e){ee({parentDir:e})},t[162]=pr):pr=t[162];let mr=pr,hr;t[163]!==r||t[164]!==b||t[165]!==On||t[166]!==En||t[167]!==Ut||t[168]!==D||t[169]!==T||t[170]!==sn||t[171]!==qt?(hr=async function(e,t,n){if(Me.current)return;let i=Se.current;i&&En(i);try{let i=kj(e,t,[...qt,...Qt.current]);U(i.renamePath),Me.current=i.renamePath;let a=window.location.hash,o;if(e===`file`){let e=Aj(`file`,i.addPath),t={path:e};n?.template&&(t.template=n.template);let a=await ve(await fetch(`/api/create-page`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),r({id:`fJgQHX`}));if(!a.ok){X.error(a.title),U(null),Me.current=null;return}let s=fj(e),c=A(Qr,a.body,`create-page`,{docName:s}).docName;o=c;let l={kind:`document`,docName:c,docExt:e.toLowerCase().endsWith(`.mdx`)?`.mdx`:`.md`,modified:new Date().toISOString(),size:0};b(c),j(e=>{if(e.some(e=>ls(e)&&e.docName===c))return e;let t=[...e,l];return _n(t),Pe.current.set(pj(l),Date.now()),t}),is([`files`,`backlinks`,`graph`]),T(c)}else{let e=hj(i.addPath),t=await ve(await fetch(`/api/create-folder`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})}),r({id:`K1ckLX`}));if(!t.ok){X.error(t.title),U(null),Me.current=null;return}o=A(Pn,t.body,`create-folder`,{path:e}).path;let n={kind:`folder`,path:o,modified:new Date().toISOString(),size:0};j(e=>{if(e.some(e=>Jo(e)&&e.path===o))return e;let t=[...e,n];return _n(t),Pe.current.set(pj(n),Date.now()),t}),is([`files`]),D(o)}let s=!1,c=e=>{if(e.key!==`Enter`)return;let t=Se.current;!t||t.renamePath!==i.renamePath||queueMicrotask(()=>En(t))};document.addEventListener(`keydown`,c,!0),Se.current={kind:e,renamePath:i.renamePath,createdPath:o,previousHash:a,disposeCommitListener:()=>{s||(s=!0,document.removeEventListener(`keydown`,c,!0))}},U(null),Me.current=null,Ut.add(i.addPath),Ut.startRenaming(i.renamePath,{removeIfCanceled:!0})}catch(e){console.warn(`[FileTree] create placeholder failed:`,e),X.error(r({id:`S6l5dv`}));let t=Se.current;t?await On(t):En(),U(null),Me.current=null,sn()}},t[163]=r,t[164]=b,t[165]=On,t[166]=En,t[167]=Ut,t[168]=D,t[169]=T,t[170]=sn,t[171]=qt,t[172]=hr):hr=t[172];let gr=hr,_r;t[173]===Ut?_r=t[174]:(_r=function(e){let t=gj(e);(0,Q.startTransition)(()=>{for(let e of Qt.current)if(e===t||e.startsWith(t)){let t=OW(Ut.getItem(e));t&&t.expand()}})},t[173]=Ut,t[174]=_r);let yr=_r,br;t[175]===Ut?br=t[176]:(br=function(e){let t=gj(e),n=new Set(xe.current);(0,Q.startTransition)(()=>{for(let e of[...Qt.current].reverse())if((e===t||e.startsWith(t))&&!n.has(e)){let t=OW(Ut.getItem(e));t&&t.collapse()}})},t[175]=Ut,t[176]=br);let xr=br,Sr;t[177]!==fe||t[178]!==$t||t[179]!==o||t[180]!==c||t[181]!==_e||t[182]!==H||t[183]!==On||t[184]!==dn||t[185]!==k||t[186]!==Zt||t[187]!==ur||t[188]!==cr||t[189]!==Gt||t[190]!==x||t[191]!==wn||t[192]!==pn||t[193]!==Mt||t[194]!==jt||t[195]!==qt||t[196]!==fr?(Sr=()=>{le.current=k,ue.current=x,he.current=o,$e.current=c,ye.current=_e,Me.current=H,We.current=jt,Ge.current=Mt,Yt.current=qt,Qt.current=Zt,xe.current=$t,He.current=dn,Ue.current=pn,Ce.current=On,je.current=(e,t,n)=>{fr(e,t,n)},Je.current=e=>{if(Ee.current||De.current||e.length!==1)return;let t=e[0];t&&(ie(!1),fe(Gt(t),k))},Xe.current=e=>{wn(e)||X.error(e)},Ye.current=cr,Qe.current=ur},t[177]=fe,t[178]=$t,t[179]=o,t[180]=c,t[181]=_e,t[182]=H,t[183]=On,t[184]=dn,t[185]=k,t[186]=Zt,t[187]=ur,t[188]=cr,t[189]=Gt,t[190]=x,t[191]=wn,t[192]=pn,t[193]=Mt,t[194]=jt,t[195]=qt,t[196]=fr,t[197]=Sr):Sr=t[197],(0,Q.useLayoutEffect)(Sr);let Cr,wr;t[198]===Ut?(Cr=t[199],wr=t[200]):(Cr=()=>{let e=e=>{let t=(e.metaKey||e.ctrlKey)&&!e.altKey,n=e.key.toLowerCase(),r=t&&n===`a`,i=t&&!e.shiftKey&&n===`d`;if(!r&&!i||VG(e.target))return;let a=qe.current,o=e.target,s=document.activeElement,c=o instanceof Node&&a?.contains(o),l=s instanceof Node&&a?.contains(s);if(!c&&!l)return;if(i){let t=Ut.getFocusedPath()??Ut.getSelectedPaths()[0]??null;if(!t)return;let n=Ut.getItem(t)??Ut.getItem(gj(t)),r=n?.isDirectory()?gj(hj(n.getPath())):t;if(ye.current.has(r))return;Sn.current(LG(r,le.current)),e.preventDefault(),e.stopPropagation();return}let u=new Set([...Qt.current,...Yt.current]);Ee.current=!0;for(let e of u)e&&Ut.getItem(e)?.select();queueMicrotask(()=>{Ee.current=!1}),e.preventDefault(),e.stopPropagation()};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},wr=[Ut],t[198]=Ut,t[199]=Cr,t[200]=wr),(0,Q.useEffect)(Cr,wr);let Tr,Er;t[201]!==k.length||t[202]!==M?(Tr=()=>{if(M||k.length===0)return;let e=qe.current?.querySelector(CP)?.shadowRoot;if(!e)return;let t=oK,n=()=>{for(let n of e.querySelectorAll(`[data-item-path]`)){let e=n.dataset.itemPath;if(!e)continue;let r=t(e);n.title!==r&&(n.title=r)}let n=e.querySelector(`[data-type="context-menu-anchor"]`);if(n){let r=e.querySelector(`[data-item-context-hover="true"][data-item-path]`)?.dataset.itemPath,i=r?t(r):``;n.title!==i&&(n.title=i)}};n();let r=new MutationObserver(n);return r.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`data-item-path`,`data-item-context-hover`]}),()=>r.disconnect()},Er=[M,k.length],t[201]=k.length,t[202]=M,t[203]=Tr,t[204]=Er):(Tr=t[203],Er=t[204]),(0,Q.useEffect)(Tr,Er);let Dr,Ar;t[205]!==k.length||t[206]!==M?(Dr=()=>{if(M||k.length===0)return;let e=qe.current?.querySelector(CP)?.shadowRoot;if(!e)return;let t=()=>BU(e);t();let n=new MutationObserver(t);return n.observe(e,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:[`data-item-path`]}),()=>n.disconnect()},Ar=[M,k.length],t[205]=k.length,t[206]=M,t[207]=Dr,t[208]=Ar):(Dr=t[207],Ar=t[208]),(0,Q.useEffect)(Dr,Ar);let jr,Mr;t[209]!==k.length||t[210]!==M?(jr=()=>{if(M||k.length===0)return;let e=qe.current?.querySelector(CP)?.shadowRoot;if(!e)return;let t=()=>aW(e);t();let n=new MutationObserver(t);return n.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`data-item-path`]}),()=>n.disconnect()},Mr=[M,k.length],t[209]=k.length,t[210]=M,t[211]=jr,t[212]=Mr):(jr=t[211],Mr=t[212]),(0,Q.useEffect)(jr,Mr);let Nr;t[213]===Symbol.for(`react.memo_cache_sentinel`)?(Nr={folderCount:0,expandedCount:0},t[213]=Nr):Nr=t[213];let Pr=(0,Q.useRef)(Nr),Fr=(0,Q.useRef)(gr),Ir=(0,Q.useRef)(mr),Lr;t[214]===gr?Lr=t[215]:(Lr=()=>{Fr.current=gr,Ir.current=mr},t[214]=gr,t[215]=Lr),(0,Q.useEffect)(Lr);let Rr,zr;t[216]===Ut?(Rr=t[217],zr=t[218]):(Rr=()=>({startCreating(e,t){Fr.current(e,t)},startCreatingFromTemplate(e){Ir.current(e)},createFromTemplate(e,t){Fr.current(`file`,e,{template:t})},expandAll(){(0,Q.startTransition)(()=>{for(let e of Qt.current){let t=OW(Ut.getItem(e));t&&t.expand()}})},collapseAll(){let e=new Set(xe.current);(0,Q.startTransition)(()=>{for(let t of[...Qt.current].reverse()){if(e.has(t))continue;let n=OW(Ut.getItem(t));n&&n.collapse()}})},getFolderState(){let e=Qt.current,t=0;for(let n of e)OW(Ut.getItem(n))?.isExpanded()&&t++;let n=e.length,r=Pr.current;if(r.folderCount===n&&r.expandedCount===t)return r;let i={folderCount:n,expandedCount:t};return Pr.current=i,i},isCreationTargetCleared(){return ae.current},subscribe(e){ce.current.add(e);let t=Ut.subscribe(e);return()=>{ce.current.delete(e),t()}}}),zr=[Ut],t[216]=Ut,t[217]=Rr,t[218]=zr),(0,Q.useImperativeHandle)(n,Rr,zr);let Br;t[219]!==En||t[220]!==d||t[221]!==l||t[222]!==Ut?(Br=async function(e,t,n){let r=HG(e,le.current,Qt.current),i=Se.current;i&&e.some(e=>UG(e,i))&&(i.kind===`file`?r.docNames.add(i.createdPath):r.folderPaths.add(i.createdPath),En(i));let a=new Set([...r.docNames,...t]),o=new Set([...r.folderPaths,...n]),s=new Set([...r.assetPaths,...e.filter(aK).map(iK)]);l([...[...a].map(rK),...[...o].map(nK),...[...s].map(tK)],{force:!0}),await Promise.all([...a].map(e=>d(e)));for(let t of e){let e=t.kind===`folder`?gj(t.path):t.kind===`asset`?t.path:dj(t.path,t.docExt);Ut.getItem(e)&&Ut.remove(e,t.kind===`folder`?{recursive:!0}:void 0)}j(e=>{let t=Wj(e,[...a],void 0,[...s]);for(let e of o)t=Wj(t,[],e);return _n(t),t}),is([`files`,`backlinks`,`graph`])},t[219]=En,t[220]=d,t[221]=l,t[222]=Ut,t[223]=Br):Br=t[223];let Vr=Br,Hr;t[224]!==r||t[225]!==Vr?(Hr=async function(e){let t=[],n=[],i=[];for(let a of e){let e=a.kind;U(a.path);let o=await ve(await fetch(`/api/delete-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:e,path:a.path})}),r({id:`7JtSLi`}));if(!o.ok)return i.length>0&&await Vr(i,t,n),X.error(o.title),!1;let s=A(Qn,o.body,`delete-path`,{deletedDocNames:[]});t.push(...s.deletedDocNames),e===`folder`&&n.push(a.path),i.push(a)}return await Vr(i,t,n),!0},t[224]=r,t[225]=Vr,t[226]=Hr):Hr=t[226];let Ur=Hr,Wr;t[227]===Symbol.for(`react.memo_cache_sentinel`)?(Wr=async function(e,t,n){let r=[],i=[];for(let a of e){U(a.path);let e=Yj(a,n),o=await t.shell.trashItem(e);o.ok?r.push(a):i.push({kind:a.kind,path:a.path,name:a.name,reason:xW(o.reason),detail:o.detail})}return{trashed:r,failed:i}},t[227]=Wr):Wr=t[227];let Gr=Wr,Kr;t[228]===r?Kr=t[229]:(Kr=async function(e){let t=[],n=[],i=[];for(let a of e){let e=a.kind;try{let o=await ve(await fetch(`/api/trash/cleanup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:e,path:a.path})}),r({id:`DVh_Tb`}));if(!o.ok){console.warn(`[FileTree] trash-cleanup failed`,{target:`${a.kind}:${a.path}`,reason:o.title}),i.push({target:a,reason:o.title});continue}let s=A($r,o.body,`trash-cleanup`,{deletedDocNames:[]});t.push(...s.deletedDocNames),e===`folder`&&n.push(a.path)}catch(e){let t=e;console.warn(`[FileTree] trash-cleanup threw`,{target:`${a.kind}:${a.path}`,err:t}),i.push({target:a,reason:r({id:`r4R7AZ`})})}}if(i.length>0){let e=i.length;X.error(r({id:`IrB5AK`,values:{failedCount:e}}),{description:r({id:`vEJDlt`})})}return i.length===e.length&&e.length>0?null:{deletedDocNames:t,deletedFolderPaths:n}},t[228]=r,t[229]=Kr);let qr=Kr,Jr;t[230]!==r||t[231]!==J||t[232]!==Vr||t[233]!==Ur||t[234]!==qr||t[235]!==sn||t[236]!==te?(Jr=async function(e){let t=e.map(e=>Gj(e,le.current)),n=t[0];if(!n)return;let i=J.filter(e=>t.some(t=>{if(t.kind===`file`){let n=`${t.path}${t.docExt??`.md`}`;return e.file===n}return t.kind===`folder`?e.file.startsWith(`${t.path}/`):!1}));if(i.length>0){let e=i.slice(0,3).map(eK),t=i.length>e.length?`, +${i.length-e.length} more`:``;X.error(`Cannot delete files with unresolved conflicts`,{description:`Resolve the conflict on ${e.join(`, `)}${t} before deleting.`});return}U(n.path),G(null);let a=typeof window<`u`?window.okDesktop:void 0;try{if(a&&te){let{trashed:e,failed:n}=await Gr(t,a,te);if(e.length>0){let t=await qr(e);t?await Vr(e,t.deletedDocNames,t.deletedFolderPaths):await Vr(e,e.filter($G).map(QG),e.filter(ZG).map(XG))}n.length>0&&q({failed:n,originalTargets:[...t]}),U(null)}else{let e=await Ur(t);U(null),e||sn()}}catch(e){let t=e,n=t instanceof Error?t.message:String(t);console.warn(`[FileTree] delete failed:`,t),X.error(r({id:`0eHrMb`}),{description:n}),U(null),sn()}},t[230]=r,t[231]=J,t[232]=Vr,t[233]=Ur,t[234]=qr,t[235]=sn,t[236]=te,t[237]=Jr):Jr=t[237];let Yr=Jr,Zr;t[238]!==r||t[239]!==Ur||t[240]!==sn||t[241]!==K?(Zr=async function(){if(!K)return;let e=new Set(K.failed.map(YG)),t=K.originalTargets.filter(t=>e.has(`${t.kind}:${t.path}`));if(q(null),t.length!==0){U(t[0]?.path??null);try{let e=await Ur(t);U(null),e||sn()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);console.warn(`[FileTree] hard-delete fallback failed:`,t),X.error(r({id:`0eHrMb`}),{description:n}),U(null),sn()}}},t[238]=r,t[239]=Ur,t[240]=sn,t[241]=K,t[242]=Zr):Zr=t[242];let ei=Zr,ti;t[243]!==Yr||t[244]!==K?(ti=async function(){if(!K)return;let e=new Set(K.failed.map(JG)),t=K.originalTargets.filter(t=>e.has(`${t.kind}:${t.path}`));q(null),await Yr(t)},t[243]=Yr,t[244]=K,t[245]=ti):ti=t[245];let ni=ti,ri=(0,Q.useRef)(Yr),ii;t[246]===Yr?ii=t[247]:(ii=()=>{ri.current=Yr},t[246]=Yr,t[247]=ii),(0,Q.useEffect)(ii);let oi,ci;t[248]===Symbol.for(`react.memo_cache_sentinel`)?(oi=()=>FW(e=>{if(e.kind===`doc`||e.kind===`folder-index`){let t=e.docName,n=le.current.find(e=>ls(e)&&e.docName===t);ri.current([{kind:`file`,path:t,name:t.split(`/`).pop()??t,docExt:n?.docExt}]);return}if(e.kind===`folder`){ri.current([{kind:`folder`,path:e.folderPath,name:e.folderPath.split(`/`).pop()??e.folderPath}]);return}if(e.kind===`asset`){ri.current([{kind:`asset`,path:e.assetPath,name:e.assetPath.split(`/`).pop()??e.assetPath}]);return}console.warn(JSON.stringify({event:`file-tree-menu-action-delete-unsupported-kind`,kind:e.kind}))}),ci=[],t[248]=oi,t[249]=ci):(oi=t[248],ci=t[249]),(0,Q.useEffect)(oi,ci);let li,ui;t[250]===Symbol.for(`react.memo_cache_sentinel`)?(li=()=>zW(e=>{if(e.kind===`doc`||e.kind===`folder-index`){let t=e.docName,n=le.current.find(e=>ls(e)&&e.docName===t);Sn.current({kind:`file`,path:t,name:t.split(`/`).pop()??t,docExt:n?.docExt});return}if(e.kind===`folder`){Sn.current({kind:`folder`,path:e.folderPath,name:e.folderPath.split(`/`).pop()??e.folderPath});return}console.warn(JSON.stringify({event:`file-tree-menu-action-duplicate-unsupported-kind`,kind:e.kind}))}),ui=[],t[250]=li,t[251]=ui):(li=t[250],ui=t[251]),(0,Q.useEffect)(li,ui);let di,fi;t[252]===Ut?(di=t[253],fi=t[254]):(di=()=>LW(e=>{if(e.kind===`doc`||e.kind===`folder-index`){let t=e.docName,n=dj(t,le.current.find(e=>ls(e)&&e.docName===t)?.docExt);Ut.startRenaming(n);return}if(e.kind===`folder`){Ut.startRenaming(e.folderPath);return}if(e.kind===`asset`){Ut.startRenaming(e.assetPath);return}console.warn(JSON.stringify({event:`file-tree-menu-action-rename-unsupported-kind`,kind:e.kind}))}),fi=[Ut],t[252]=Ut,t[253]=di,t[254]=fi),(0,Q.useEffect)(di,fi);let pi;t[255]===Symbol.for(`react.memo_cache_sentinel`)?(pi=function(){let e=Te.current;e&&lG(e),Te.current=null},t[255]=pi):pi=t[255];let mi=pi,hi;t[256]===g?hi=t[257]:(hi=function(e){let t=bK(e.nativeEvent);if(!t||t.endsWith(`/`)){mi();return}let n=fj(t),r=le.current.find(e=>pj(e)===t);if(r&&Io(r)){mi();return}if(r&&ls(r)&&kr(r.size)){mi();return}Te.current!==n&&(mi(),Te.current=n,cG(n,e=>g(e)))},t[256]=g,t[257]=hi);let gi=hi,_i;t[258]!==fe||t[259]!==Ut||t[260]!==D?(_i=function(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=xK(e.nativeEvent);if(!t){wK(e.nativeEvent)&&ie(!0);return}if(t.getAttribute(`aria-selected`)!==`true`)return;let n=t.dataset.itemPath;if(!n)return;let r=t.dataset.itemType===`folder`?gj(n):n;if(Ut.getSelectedPaths().length!==1)return;if(t.dataset.itemType===`folder`){let e=hj(r);if(window.location.hash===zo(e))return;queueMicrotask(()=>D(e));return}let i=fj(r);window.location.hash!==Go(i)&&queueMicrotask(()=>fe(r))},t[258]=fe,t[259]=Ut,t[260]=D,t[261]=_i):_i=t[261];let vi=_i,yi;t[262]===Symbol.for(`react.memo_cache_sentinel`)?(yi=function(e){Fj(e.nativeEvent)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,tt(!0))},t[262]=yi):yi=t[262];let bi=yi,xi;t[263]===Symbol.for(`react.memo_cache_sentinel`)?(xi=function(e){let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||tt(!1)},t[263]=xi):xi=t[263];let Si=xi,Ci;t[264]===fr?Ci=t[265]:(Ci=function(e){if(!Fj(e.nativeEvent))return;let t=Ij(e.nativeEvent);t.length!==0&&(e.preventDefault(),e.stopPropagation(),tt(!1),fr(t,``,kG))},t[264]=fr,t[265]=Ci);let wi=Ci;if(M){let e;return t[266]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(EK,{}),t[266]=e):e=t[266],e}let Ti;t[267]!==r||t[268]!==I||t[269]!==R?(Ti=I?r(R?{id:`H-vDm3`}:{id:`09Tv5j`}):null,t[267]=r,t[268]=I,t[269]=R,t[270]=Ti):Ti=t[270];let Ei=Ti;if(k.length===0){if(Ei!==null){let e;return t[271]===Ei?e=t[272]:(e=(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-8`,children:(0,Z.jsx)(`span`,{role:`status`,className:`select-none text-sidebar-foreground/50 text-sm`,children:Ei})}),t[271]=Ei,t[272]=e),e}if(P){let e;return t[273]===P?e=t[274]:(e=(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-8`,children:(0,Z.jsx)(`span`,{role:`alert`,className:`select-none text-sidebar-foreground/50 text-sm`,children:P})}),t[273]=P,t[274]=e),e}let e;t[275]===r?e=t[276]:(e=r({id:`5ZB7XC`}),t[275]=r,t[276]=e);let n=et&&`bg-primary/5 ring-2 ring-primary/70 ring-inset`,i;t[277]===n?i=t[278]:(i=ai(`flex flex-1 flex-col items-center justify-center gap-3 rounded-md py-8`,n),t[277]=n,t[278]=i);let a;t[279]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(`span`,{className:`select-none text-sidebar-foreground/30 text-sm`,children:(0,Z.jsx)(s,{id:`xiv-dW`})}),t[279]=a):a=t[279];let o;t[280]===gr?o=t[281]:(o=()=>gr(`file`,``),t[280]=gr,t[281]=o);let c;t[282]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(s,{id:`6ibbCg`}),t[282]=c):c=t[282];let l;t[283]===o?l=t[284]:(l=(0,Z.jsx)(si,{variant:`link`,size:`sm`,className:`font-mono uppercase`,onClick:o,children:c}),t[283]=o,t[284]=l);let u;return t[285]!==wi||t[286]!==e||t[287]!==i||t[288]!==l?(u=(0,Z.jsxs)(`section`,{"aria-label":e,className:i,onDragOver:bi,onDragLeave:Si,onDrop:wi,children:[a,l]}),t[285]=wi,t[286]=e,t[287]=i,t[288]=l,t[289]=u):u=t[289],u}let Di=H!==null,Oi=W?.targets[0]??null,ki=null;if(B!==null){let e;if(t[290]!==a.locale||t[291]!==B){let n=new Intl.NumberFormat(a.locale).format(B);e=Ko._({id:`mSpqzP`,values:{truncatedShownCount:B,formattedCount:n}}),t[290]=a.locale,t[291]=B,t[292]=e}else e=t[292];ki=e}let Ai;t[293]!==P||t[294]!==Ei||t[295]!==ki?(Ai=(P||Ei!==null||ki!==null)&&(0,Z.jsxs)(Z.Fragment,{children:[Ei===null?P&&(0,Z.jsx)(OK,{kind:`error`,children:P}):(0,Z.jsx)(OK,{kind:`reconnecting`,children:Ei}),ki!==null&&(0,Z.jsx)(OK,{kind:`info`,children:ki})]}),t[293]=P,t[294]=Ei,t[295]=ki,t[296]=Ai):Ai=t[296];let ji;t[297]===y?ji=t[298]:(ji=FU(y),t[297]=y,t[298]=ji);let Mi=re?``:void 0,Pi;t[299]===Mi?Pi=t[300]:(Pi={[MG]:Mi},t[299]=Mi,t[300]=Pi);let Fi;t[301]!==Di||t[302]!==_e||t[303]!==xr||t[304]!==k||t[305]!==yr||t[306]!==Zt||t[307]!==xn||t[308]!==Dt||t[309]!==At||t[310]!==Ut||t[311]!==Ot||t[312]!==kt||t[313]!==gr||t[314]!==te?(Fi=(e,t)=>(0,Z.jsx)(WG,{item:e,context:t,anyActionBusy:Di,workspace:te,handoff:Dt,model:Ut,okignoreBinding:Ot,projectLocalBinding:kt,mergedConfig:At,onStartCreating:gr,onCreateFromTemplate:(e,t)=>gr(`file`,e,{template:t}),onDuplicate:xn,onDelete:e=>G({targets:e}),onExpandSubtree:yr,onCollapseSubtree:xr,folderTreePaths:Zt,isAsset:_e.has(e.path),documents:k}),t[301]=Di,t[302]=_e,t[303]=xr,t[304]=k,t[305]=yr,t[306]=Zt,t[307]=xn,t[308]=Dt,t[309]=At,t[310]=Ut,t[311]=Ot,t[312]=kt,t[313]=gr,t[314]=te,t[315]=Fi):Fi=t[315];let Ii;t[316]!==vi||t[317]!==gi||t[318]!==Ut||t[319]!==Ai||t[320]!==ji||t[321]!==Pi||t[322]!==Fi?(Ii=(0,Z.jsx)(`div`,{ref:qe,className:`flex min-h-0 flex-1 flex-col`,children:(0,Z.jsx)(kU,{header:Ai,model:Ut,style:ji,...Pi,onClickCapture:vi,onMouseMove:gi,onMouseLeave:mi,renderContextMenu:Fi})}),t[316]=vi,t[317]=gi,t[318]=Ut,t[319]=Ai,t[320]=ji,t[321]=Pi,t[322]=Fi,t[323]=Ii):Ii=t[323];let Li=!!W,Ri;t[324]===H?Ri=t[325]:(Ri=e=>{!e&&!H&&G(null)},t[324]=H,t[325]=Ri);let zi;t[326]!==r||t[327]!==H||t[328]!==W||t[329]!==Yr||t[330]!==Oi?(zi=W&&Oi&&(0,Z.jsx)(Ia,{...(()=>{let e=_W(typeof window<`u`&&window.okDesktop!=null?`electron`:`web`,W.targets);if(e)return{customTitle:e.title,customDescription:``,customDetail:e.detail,customConfirmLabel:e.confirmLabel,customConfirmLabelBusy:e.confirmLabelBusy,children:e.listedTargets?(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1 font-mono text-foreground text-xs`,children:e.listedTargets.map(qG)}):null};let t=W.targets.length,n=Oi.name;return{itemName:t===1?Oi.kind===`folder`?`${Oi.name}/`:Oi.kind===`file`?`${Oi.name}${Oi.docExt??`.md`}`:Oi.name:void 0,customTitle:t>1?r({id:`abiHje`}):void 0,customDescription:t>1?r({id:`WMIKXK`,values:{targetCount:t}}):Oi.kind===`folder`?r({id:`a5W0q0`,values:{folderName:n}}):void 0}})(),isSubmitting:H!==null,onDelete:()=>Yr(W.targets)}),t[326]=r,t[327]=H,t[328]=W,t[329]=Yr,t[330]=Oi,t[331]=zi):zi=t[331];let Bi;t[332]!==Li||t[333]!==Ri||t[334]!==zi?(Bi=(0,Z.jsx)(Eo,{open:Li,onOpenChange:Ri,children:zi}),t[332]=Li,t[333]=Ri,t[334]=zi,t[335]=Bi):Bi=t[335];let Vi=!!K,Hi;t[336]===H?Hi=t[337]:(Hi=e=>{!e&&!H&&q(null)},t[336]=H,t[337]=Hi);let Ui;t[338]!==H||t[339]!==ei||t[340]!==ni||t[341]!==K?(Ui=K&&(0,Z.jsx)(TW,{failedTargets:K.failed,isSubmitting:H!==null,onDeletePermanently:ei,onRetry:ni,onCancel:()=>q(null)}),t[338]=H,t[339]=ei,t[340]=ni,t[341]=K,t[342]=Ui):Ui=t[342];let Wi;t[343]!==Vi||t[344]!==Hi||t[345]!==Ui?(Wi=(0,Z.jsx)(Eo,{open:Vi,onOpenChange:Hi,children:Ui}),t[343]=Vi,t[344]=Hi,t[345]=Ui,t[346]=Wi):Wi=t[346];let Gi=Y!==null,Ki;t[347]===Symbol.for(`react.memo_cache_sentinel`)?(Ki=e=>{e||ee(null)},t[347]=Ki):Ki=t[347];let qi=Y?.parentDir??``,Ji;t[348]!==Gi||t[349]!==qi?(Ji=(0,Z.jsx)(ih,{open:Gi,onOpenChange:Ki,kind:`file`,initialDir:qi,defaultToTemplate:!0}),t[348]=Gi,t[349]=qi,t[350]=Ji):Ji=t[350];let Yi;return t[351]!==Ii||t[352]!==Bi||t[353]!==Wi||t[354]!==Ji?(Yi=(0,Z.jsxs)(Z.Fragment,{children:[Ii,Bi,Wi,Ji]}),t[351]=Ii,t[352]=Bi,t[353]=Wi,t[354]=Ji,t[355]=Yi):Yi=t[355],Yi}function qG(e){return(0,Z.jsx)(`li`,{"data-testid":`delete-target-row`,children:vW(e)},`${e.kind}:${e.path}`)}function JG(e){return`${e.kind}:${e.path}`}function YG(e){return`${e.kind}:${e.path}`}function XG(e){return e.path}function ZG(e){return e.kind===`folder`}function QG(e){return e.path}function $G(e){return e.kind===`file`}function eK(e){return e.file}function tK(e){return Lt(e)}function nK(e){return bt(e)}function rK(e){return He(e)}function iK(e){return e.path}function aK(e){return e.kind===`asset`}function oK(e){return e.endsWith(`/`)?e.slice(0,-1):e}function sK(e){return!!e}function cK(e){console.warn(`[FileTree] /api/workspace fetch failed:`,e)}function lK(e){console.warn(`[FileTree] unmount cleanup failed:`,e)}function uK(e){X.error(e)}function dK(){}function fK(e){return X.error(e)}function pK(){}function mK(){}function hK(){}function gK(){}function _K(){}async function vK(){}function yK(e){return pj(e)}function bK(e){return xK(e)?.dataset.itemPath??null}function xK(e){for(let t of e.composedPath())if(t instanceof HTMLElement&&t.dataset.itemPath)return t;return null}function SK(e){for(let t of e.composedPath())if(t instanceof HTMLElement&&t.matches(`[data-file-tree-virtualized-root]`))return t;return null}function CK(e){let t=xK(e);if(t){let e=t.dataset.itemPath;if(!e)return null;let n=t.dataset.itemType===`folder`,r=Mj(e,n);return{parentDir:r,row:t,root:null,busyPath:n?gj(r):e}}return wK(e)?{parentDir:``,row:null,root:SK(e),busyPath:kG}:null}function wK(e){for(let t of e.composedPath())if(t instanceof HTMLElement&&t.matches(`[data-file-tree-virtualized-scroll]`))return!0;return!1}var TK=[`w-3/4`,`w-2/3`,`w-4/5`,`w-1/2`,`w-3/5`,`w-2/3`];function EK(){let e=(0,$.c)(5),{_:t}=i(),n;e[0]===t?n=e[1]:(n=t({id:`5Tk8Fb`}),e[0]=t,e[1]=n);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=TK.map(DK),e[2]=r):r=e[2];let a;return e[3]===n?a=e[4]:(a=(0,Z.jsx)(`div`,{className:`flex flex-1 flex-col gap-1 px-2 py-2`,role:`status`,"aria-busy":`true`,"aria-label":n,children:r}),e[3]=n,e[4]=a),a}function DK(e,t){return(0,Z.jsxs)(`div`,{className:`flex h-6 items-center gap-2`,children:[(0,Z.jsx)(za,{className:`h-3 w-3 shrink-0 rounded-sm`}),(0,Z.jsx)(za,{className:`h-3 ${e}`})]},t)}function OK(e){let t=(0,$.c)(14),{kind:n,children:r}=e,i=n===`error`?ds:n===`reconnecting`?no:Oo,a=n===`error`?`alert`:`status`,o=n===`error`?`text-destructive`:`text-muted-foreground`,s;t[0]===o?s=t[1]:(s=ai(`mx-2 mb-1 flex items-start gap-1.5 rounded-md bg-muted/50 px-2 py-1.5 text-xs leading-snug`,o),t[0]=o,t[1]=s);let c=n===`reconnecting`&&`animate-spin motion-reduce:animate-none`,l;t[2]===c?l=t[3]:(l=ai(`mt-0.5 size-3.5 shrink-0`,c),t[2]=c,t[3]=l);let u;t[4]!==i||t[5]!==l?(u=(0,Z.jsx)(i,{"aria-hidden":`true`,className:l}),t[4]=i,t[5]=l,t[6]=u):u=t[6];let d;t[7]===r?d=t[8]:(d=(0,Z.jsx)(`span`,{className:`min-w-0`,children:r}),t[7]=r,t[8]=d);let f;return t[9]!==a||t[10]!==s||t[11]!==u||t[12]!==d?(f=(0,Z.jsxs)(`span`,{role:a,className:s,children:[u,d]}),t[9]=a,t[10]=s,t[11]=u,t[12]=d,t[13]=f):f=t[13],f}function kK(e){return e?Ko._({id:`wTcjov`}):null}function AK(e){let t=(0,$.c)(23),{_:n}=i(),r=Mh(),a=HM();if(r)return null;let{input:o,installStates:c,dispatch:l}=e,u=o===null,d,f,p,m,h,g;if(t[0]!==n||t[1]!==l||t[2]!==o||t[3]!==u||t[4]!==c||t[5]!==a){g=Symbol.for(`react.early_return_sentinel`);bb0:{let e=kK(u),r;t[12]===c?r=t[13]:(r=e=>c[e.id]?.installed===!0,t[12]=c,t[13]=r);let i=Fh.filter(r),_=a!==null;if(i.length===0&&!_){g=null;break bb0}f=rM,t[14]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsxs)(oM,{children:[(0,Z.jsx)(vi,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`O7_W_a`})]}),t[14]=h):h=t[14],d=sM,p=i.map(t=>{let r=!u,{displayName:i}=t,a=n(e?{id:`1ZpfyB`,values:{displayName:i,hint:e}}:{id:`WqLq6M`,values:{displayName:i}});return(0,Z.jsxs)(aM,{disabled:!r,onSelect:()=>{o&&l(t.id,o)},"data-testid":`empty-space-open-in-${t.id}`,"aria-label":a,children:[(0,Z.jsx)(ox,{id:t.id,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:t.displayName}),e?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},t.id)}),m=a===null?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(lM,{}),(0,Z.jsxs)(aM,{onSelect:()=>{o!==null&&a.launchInTerminal(o)},disabled:u,"data-testid":`empty-space-open-in-terminal`,"aria-label":n(e?{id:`LtVw4J`,values:{hint:e}}:{id:`AcK_r0`}),children:[(0,Z.jsx)(Kl,{className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:(0,Z.jsx)(s,{id:`AcK_r0`})}),e?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]})]})}t[0]=n,t[1]=l,t[2]=o,t[3]=u,t[4]=c,t[5]=a,t[6]=d,t[7]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=g}else d=t[6],f=t[7],p=t[8],m=t[9],h=t[10],g=t[11];if(g!==Symbol.for(`react.early_return_sentinel`))return g;let _;t[15]!==d||t[16]!==p||t[17]!==m?(_=(0,Z.jsxs)(d,{children:[p,m]}),t[15]=d,t[16]=p,t[17]=m,t[18]=_):_=t[18];let v;return t[19]!==f||t[20]!==h||t[21]!==_?(v=(0,Z.jsxs)(f,{children:[h,_]}),t[19]=f,t[20]=h,t[21]=_,t[22]=v):v=t[22],v}var jK=(e,t,n)=>cu(e,t,n,`ProjectSwitcher`);function MK(e){let t=(0,$.c)(96),{bridge:n}=e,{_:r}=i(),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],t[0]=a):a=t[0];let[o,c]=(0,Q.useState)(a),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(!1),h=Jk(),g=typeof window<`u`&&window.okDesktop!=null,_=(0,Q.useRef)(!1),v;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>{u(e),e||f(``)},t[1]=v):v=t[1];let y=v,b;t[2]!==r||t[3]!==n.project||t[4]!==l?(b=()=>{if(!l)return;let e=!1;return jK(async()=>{let t=await n.project.listRecent();e||c(t)},r({id:`fYKgzG`})),()=>{e=!0}},t[2]=r,t[3]=n.project,t[4]=l,t[5]=b):b=t[5];let x;t[6]!==r||t[7]!==n||t[8]!==l?(x=[l,n,r],t[6]=r,t[7]=n,t[8]=l,t[9]=x):x=t[9],(0,Q.useEffect)(b,x);let S;t[10]!==r||t[11]!==n.project?(S=e=>{u(!1),jK(()=>n.project.open({path:e,target:`new-window`,entryPoint:`recents`}),r({id:`SUOoXn`}))},t[10]=r,t[11]=n.project,t[12]=S):S=t[12];let C=S,w;t[13]!==r||t[14]!==n.dialog||t[15]!==n.project?(w=()=>{u(!1),jK(async()=>{let e=await n.dialog.openFolder();e&&await n.project.open({path:e,target:`new-window`,entryPoint:`pick-existing`})},r({id:`gmJ0An`}))},t[13]=r,t[14]=n.dialog,t[15]=n.project,t[16]=w):w=t[16];let T=w,E;t[17]!==r||t[18]!==n.navigator?(E=()=>{u(!1),jK(()=>n.navigator.open(),r({id:`jol95m`}))},t[17]=r,t[18]=n.navigator,t[19]=E):E=t[19];let O=E,k;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>{u(!1),m(!0)},t[20]=k):k=t[20];let A=k,j=n.config.projectPath,N,P,F,I,L,R,z,B,V,H,U;if(t[21]!==r||t[22]!==h||t[23]!==n.config.projectName||t[24]!==n.config.projectPath||t[25]!==j||t[26]!==l||t[27]!==C||t[28]!==o||t[29]!==d){let e;t[41]===j?e=t[42]:(e=e=>e.path!==j,t[41]=j,t[42]=e);let i=o.filter(e),a=d.trim().toLowerCase(),c=a?i.filter(e=>e.name.toLowerCase().includes(a)||e.path.toLowerCase().includes(a)):i;P=ro,z=l,B=y,V=!1;let u=h!==null&&`h-auto py-1.5`,p;t[43]===u?p=t[44]:(p=ai(`justify-between text-sidebar-foreground/70 hover:text-sidebar-foreground! data-open:hover:text-sidebar-foreground!`,u),t[43]=u,t[44]=p);let m;t[45]===r?m=t[46]:(m=r({id:`zZ_I5K`}),t[45]=r,t[46]=m);let v;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(v=g?()=>{_.current=!0}:void 0,t[47]=v):v=t[47];let b;t[48]===l?b=t[49]:(b=g?()=>{if(_.current){_.current=!1;return}y(!l)}:void 0,t[48]=l,t[49]=b);let x;t[50]===n.config.projectName?x=t[51]:(x=(0,Z.jsx)(`span`,{className:`truncate`,children:n.config.projectName}),t[50]=n.config.projectName,t[51]=x);let S;t[52]===h?S=t[53]:(S=h===null?null:(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 text-xs text-sidebar-foreground/50 group-hover/menu-button:text-sidebar-foreground`,"data-testid":`project-switcher-branch`,children:[(0,Z.jsx)(Ce,{"aria-hidden":`true`,className:`size-3! shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:h})]}),t[52]=h,t[53]=S);let w;t[54]!==x||t[55]!==S?(w=(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[x,S]}),t[54]=x,t[55]=S,t[56]=w):w=t[56];let T;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(Qc,{"aria-hidden":`true`,className:`opacity-60`}),t[57]=T):T=t[57],t[58]!==n.config.projectPath||t[59]!==p||t[60]!==m||t[61]!==b||t[62]!==w?(H=(0,Z.jsx)(ao,{asChild:!0,children:(0,Z.jsxs)(Hk,{className:p,"data-testid":`project-switcher-trigger`,"aria-label":m,title:n.config.projectPath,onPointerDown:v,onClick:b,children:[w,T]})}),t[58]=n.config.projectPath,t[59]=p,t[60]=m,t[61]=b,t[62]=w,t[63]=H):H=t[63],N=$a,U=`start`,F=`top`,I=`min-w-[260px]`,L=`project-switcher-menu`,R=i.length===0?(0,Z.jsx)(Ta,{className:`font-normal text-muted-foreground text-xs`,children:(0,Z.jsx)(s,{id:`HNnVG1`})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(cC,{className:`mb-1 h-8 border-0 shadow-none has-[[data-slot=input-group-control]:focus-visible]:ring-0`,children:[(0,Z.jsx)(pC,{"aria-label":r({id:`H8Ng4Z`}),placeholder:r({id:`8S1E33`}),value:d,onChange:e=>f(e.target.value),onKeyDown:NK,"data-testid":`project-switcher-search`}),(0,Z.jsx)(uC,{children:(0,Z.jsx)(te,{"aria-hidden":`true`})})]}),(0,Z.jsx)(Ka,{}),c.length===0?(0,Z.jsx)(Ta,{className:`font-normal text-muted-foreground text-xs`,role:`status`,"aria-live":`polite`,children:(0,Z.jsx)(s,{id:`pEQFsW`})}):(0,Z.jsx)(`div`,{className:`max-h-64 overflow-x-hidden overflow-y-auto overscroll-contain subtle-scrollbar scroll-fade-mask`,children:c.slice(0,10).map(e=>(0,Z.jsxs)(Fa,{disabled:e.missing,onSelect:()=>C(e.path),className:`flex w-full min-w-0 flex-col items-start gap-0.5`,"data-testid":`project-switcher-recent-${e.path}`,children:[(0,Z.jsx)(`span`,{className:`w-full truncate font-medium text-sm`,title:e.name,children:e.name}),(0,Z.jsxs)(`span`,{className:`w-full truncate text-muted-foreground text-xs`,title:e.path,children:[e.path,e.missing?r({id:`2Znqb1`}):``]})]},e.path))})]}),t[21]=r,t[22]=h,t[23]=n.config.projectName,t[24]=n.config.projectPath,t[25]=j,t[26]=l,t[27]=C,t[28]=o,t[29]=d,t[30]=N,t[31]=P,t[32]=F,t[33]=I,t[34]=L,t[35]=R,t[36]=z,t[37]=B,t[38]=V,t[39]=H,t[40]=U}else N=t[30],P=t[31],F=t[32],I=t[33],L=t[34],R=t[35],z=t[36],B=t[37],V=t[38],H=t[39],U=t[40];let W;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,Z.jsx)(Ka,{}),t[64]=W):W=t[64];let G,K;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,Z.jsx)(ke,{"aria-hidden":`true`,className:`text-muted-foreground`}),K=(0,Z.jsx)(s,{id:`PVUn_c`}),t[65]=G,t[66]=K):(G=t[65],K=t[66]);let q;t[67]===T?q=t[68]:(q=(0,Z.jsxs)(Fa,{onSelect:T,"data-testid":`project-switcher-open-folder`,children:[G,K]}),t[67]=T,t[68]=q);let J,Y;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,Z.jsx)(D,{"aria-hidden":`true`,className:`text-muted-foreground`}),Y=(0,Z.jsx)(s,{id:`xaDWAI`}),t[69]=J,t[70]=Y):(J=t[69],Y=t[70]);let ee;t[71]===O?ee=t[72]:(ee=(0,Z.jsxs)(Fa,{onSelect:O,"data-testid":`project-switcher-switch-project`,children:[J,Y]}),t[71]=O,t[72]=ee);let ne;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Z.jsxs)(Fa,{onSelect:A,"data-testid":`project-switcher-new-project`,children:[(0,Z.jsx)(M,{"aria-hidden":`true`,className:`text-muted-foreground`}),(0,Z.jsx)(s,{id:`gKi-a_`})]}),t[73]=ne):ne=t[73];let re;t[74]!==N||t[75]!==F||t[76]!==I||t[77]!==L||t[78]!==R||t[79]!==q||t[80]!==ee||t[81]!==U?(re=(0,Z.jsxs)(N,{align:U,side:F,className:I,"data-testid":L,children:[R,W,q,ee,ne]}),t[74]=N,t[75]=F,t[76]=I,t[77]=L,t[78]=R,t[79]=q,t[80]=ee,t[81]=U,t[82]=re):re=t[82];let ie;t[83]!==P||t[84]!==z||t[85]!==B||t[86]!==V||t[87]!==H||t[88]!==re?(ie=(0,Z.jsxs)(P,{open:z,onOpenChange:B,modal:V,children:[H,re]}),t[83]=P,t[84]=z,t[85]=B,t[86]=V,t[87]=H,t[88]=re,t[89]=ie):ie=t[89];let ae;t[90]!==n||t[91]!==p?(ae=(0,Z.jsx)(Id,{open:p,onOpenChange:m,bridge:n}),t[90]=n,t[91]=p,t[92]=ae):ae=t[92];let oe;return t[93]!==ie||t[94]!==ae?(oe=(0,Z.jsxs)(Z.Fragment,{children:[ie,ae]}),t[93]=ie,t[94]=ae,t[95]=oe):oe=t[95],oe}function NK(e){return e.stopPropagation()}function PK(e,t){let n=e instanceof Error?e:Error(String(e));console.warn(JSON.stringify({event:`jsx-render-failure`,component:`sidebarSearchPill`,rawComponentName:`sidebarSearchPill`,error:String(n),stack:t.componentStack})),Fn(`sidebarSearchPill`)}function FK(e){let t=(0,$.c)(8),{onClick:n,className:r}=e,i;t[0]===r?i=t[1]:(i=ai(`rounded-lg h-9 w-full justify-start gap-2 px-3 font-normal text-muted-foreground`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(te,{"aria-hidden":`true`}),t[2]=a):a=t[2];let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(`span`,{className:`flex-1 text-left text-sm`,children:(0,Z.jsx)(s,{id:`A1taO8`})}),t[3]=o):o=t[3];let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(Jt,{className:`text-foreground/70`,children:Ks(`command-palette`)}),t[4]=c):c=t[4];let l;return t[5]!==n||t[6]!==i?(l=(0,Z.jsxs)(si,{variant:`outline`,onClick:n,"data-telemetry-event":`ok.sidebar.search_pill.click`,className:i,children:[a,o,c]}),t[5]=n,t[6]=i,t[7]=l):l=t[7],l}function IK(e){let t=(0,$.c)(37),{notice:n,onDismiss:r}=e,{_:a}=i(),o=n.variant===`error`?`border-destructive/60 bg-sidebar-accent/30 text-muted-foreground`:n.variant===`success`?`border-emerald-500/40 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:`border-sidebar-border bg-sidebar-accent/30 text-muted-foreground`,s;t[0]!==a||t[1]!==n.dismissible||t[2]!==r?(s=n.dismissible===!1?null:(0,Z.jsx)(si,{variant:`ghost`,size:`icon`,className:`size-5 shrink-0 text-muted-foreground hover:text-sidebar-foreground`,"aria-label":a({id:`GUYwCr`}),onClick:r,children:(0,Z.jsx)(ps,{"aria-hidden":`true`,className:`size-3`})}),t[0]=a,t[1]=n.dismissible,t[2]=r,t[3]=s):s=t[3];let c=s,l=`shrink-0 text-xs font-medium underline underline-offset-2 ${n.variant===`success`?`decoration-emerald-500/40`:`decoration-muted-foreground/40`} hover:text-sidebar-foreground hover:decoration-sidebar-foreground`;if(n.secondaryAction){let e=`update-notice-${n.id}`,r=`flex flex-col gap-2 rounded-md border px-2 py-2 text-xs ${o}`,i;t[4]===n.body?i=t[5]:(i=(0,Z.jsx)(`span`,{className:`flex-1 leading-snug`,children:n.body}),t[4]=n.body,t[5]=i);let a;t[6]!==c||t[7]!==i?(a=(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[i,c]}),t[6]=c,t[7]=i,t[8]=a):a=t[8];let s;t[9]!==l||t[10]!==n.action?(s=n.action?(0,Z.jsx)(`button`,{type:`button`,className:l,onClick:()=>{n.action?.onClick()},children:n.action.label}):null,t[9]=l,t[10]=n.action,t[11]=s):s=t[11];let u;t[12]===n.secondaryAction?u=t[13]:(u=()=>{n.secondaryAction?.onClick()},t[12]=n.secondaryAction,t[13]=u);let d;t[14]!==l||t[15]!==n.secondaryAction.label||t[16]!==u?(d=(0,Z.jsx)(`button`,{type:`button`,className:l,onClick:u,children:n.secondaryAction.label}),t[14]=l,t[15]=n.secondaryAction.label,t[16]=u,t[17]=d):d=t[17];let f;t[18]!==s||t[19]!==d?(f=(0,Z.jsxs)(`div`,{className:`flex gap-3 pl-1`,children:[s,d]}),t[18]=s,t[19]=d,t[20]=f):f=t[20];let p;return t[21]!==e||t[22]!==r||t[23]!==a||t[24]!==f?(p=(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":e,className:r,children:[a,f]}),t[21]=e,t[22]=r,t[23]=a,t[24]=f,t[25]=p):p=t[25],p}let u=`update-notice-${n.id}`,d=`flex items-center gap-2 rounded-md border px-2 py-1.5 text-xs ${o}`,f;t[26]===n.body?f=t[27]:(f=(0,Z.jsx)(`span`,{className:`flex-1 leading-snug`,children:n.body}),t[26]=n.body,t[27]=f);let p;t[28]!==l||t[29]!==n.action?(p=n.action?(0,Z.jsx)(`button`,{type:`button`,className:l,onClick:()=>{n.action?.onClick()},children:n.action.label}):null,t[28]=l,t[29]=n.action,t[30]=p):p=t[30];let m;return t[31]!==c||t[32]!==u||t[33]!==d||t[34]!==f||t[35]!==p?(m=(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":u,className:d,children:[f,p,c]}),t[31]=c,t[32]=u,t[33]=d,t[34]=f,t[35]=p,t[36]=m):m=t[36],m}function LK(e){if(e.length===0)return null;let t=e[0];if(!t)return null;for(let n=1;n<e.length;n++){let r=e[n];r&&r.priority<t.priority&&(t=r)}return t}function RK(){let e=(0,$.c)(7),t=(0,Q.useSyncExternalStore)(sm,om,om),n;e[0]===t?n=e[1]:(n=LK(t),e[0]=t,e[1]=n);let r=n;if(!r)return null;let i;e[2]===r?i=e[3]:(i=()=>{r.onDismiss?.(),am(r.id)},e[2]=r,e[3]=i);let a;return e[4]!==r||e[5]!==i?(a=(0,Z.jsx)(`div`,{"data-testid":`update-notices-list`,children:(0,Z.jsx)(IK,{notice:r,onDismiss:i})}),e[4]=r,e[5]=i,e[6]=a):a=e[6],a}function zK(e,t,n){return e?.kind===`doc`&&t||e?.kind===`folder-index`&&t?gg(n.contentDir,_g(t),n.pathSeparator):e?.kind===`folder`?gg(n.contentDir,e.folderPath,n.pathSeparator):e?.kind===`asset`?gg(n.contentDir,e.assetPath,n.pathSeparator):n.contentDir}function BK(e,t){return(e?.kind===`doc`||e?.kind===`folder-index`)&&t?_g(t):e?.kind===`folder`?e.folderPath:e?.kind===`asset`?e.assetPath:``}function VK(e,t,n){return e===null?yg({workspace:n}):e.kind===`folder`?n?Sg({folderRelativePath:e.folderPath,workspace:n}):null:e.kind===`doc`||e.kind===`folder-index`?vg({docName:t,workspace:n}):null}var HK={folderCount:0,expandedCount:0},UK=`button, [role="button"], [role="menuitem"], input, textarea, select, a[href]`;function WK(e){return typeof Element>`u`||!(e instanceof Element)?!1:e.closest(UK)!==null}function GK(e){let t=(0,$.c)(2),{onOpenSearch:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(Wt,{name:`file-sidebar`,children:(0,Z.jsx)(qK,{onOpenSearch:n})}),t[0]=n,t[1]=r),r}var KK=e=>{let t=(0,$.c)(15),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({icon:n,label:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=(0,Z.jsx)(n,{"aria-hidden":`true`}),t[4]=n,t[5]=a);let o;t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,Z.jsx)(Ts,{asChild:!0,children:(0,Z.jsx)(si,{variant:`ghost`,size:`icon-sm`,"aria-label":r,...i,children:a})}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9];let s;t[10]===r?s=t[11]:(s=(0,Z.jsx)(Ds,{children:r}),t[10]=r,t[11]=s);let c;return t[12]!==o||t[13]!==s?(c=(0,Z.jsxs)(As,{children:[o,s]}),t[12]=o,t[13]=s,t[14]=c):c=t[14],c};function qK(e){let t=(0,$.c)(189),{onOpenSearch:n}=e,{_:r}=i(),[a,o]=(0,Q.useState)(null),{activeDocName:c,activeTarget:l}=pt(),u;t[0]!==c||t[1]!==l?(u=l?.kind===`folder`||l?.kind===`folder-index`?l.folderPath:us(c),t[0]=c,t[1]=l,t[2]=u):u=t[2];let d=u,[f,p]=(0,Q.useState)(!1),m=f?``:d,h=typeof window<`u`&&window.okDesktop!=null,{state:g,toggleSidebar:_}=Ok(),v=Mh(),y=g===`expanded`,b=h&&g===`collapsed`,[x,S]=(0,Q.useState)(HK),C,w;t[3]===a?(C=t[4],w=t[5]):(C=()=>{if(a===null)return;let e=()=>{S(a.getFolderState()),p(a.isCreationTargetCleared())};return e(),a.subscribe(e)},w=[a],t[3]=a,t[4]=C,t[5]=w),(0,Q.useEffect)(C,w);let T,E;t[6]===a?(T=t[7],E=t[8]):(T=()=>{if(a!==null)return Yx(e=>{let t=e.initialDir??``;if(e.template){a.createFromTemplate(e.template.folder,e.template.name);return}a.startCreating(`file`,t)})},E=[a],t[6]=a,t[7]=T,t[8]=E),(0,Q.useEffect)(T,E);let D=x.folderCount>0,O=D&&x.expandedCount===x.folderCount,k=x.expandedCount===0,A=ea(``),j=ea(m===``?null:m),M=m===``?A:j,N=A.state.status===`ready`?(A.state.data.folder.templates_available?.length??0)>0:!0,P=M.state.status===`ready`?(M.state.data.folder.templates_available?.length??0)>0:!0,F=typeof window<`u`?window.okDesktop:void 0,I=po(),L=Kg().states,{dispatch:R}=Fg(),z;t[9]===I?z=t[10]:(z=yg({workspace:I}),t[9]=I,t[10]=z);let B=z,{projectLocalBinding:V,merged:H}=oe(),U=H?.appearance?.sidebar?.showHiddenFiles??!1,W=H?.appearance?.sidebar?.showAllFiles??!0,G=D&&!O,K=D&&!k,q=G||K,J=YK,Y;t[11]!==a||t[12]!==I?(Y=()=>{I&&a?.startCreating(`file`,``)},t[11]=a,t[12]=I,t[13]=Y):Y=t[13];let ee=Y,te;t[14]!==a||t[15]!==I?(te=e=>{I&&a?.createFromTemplate(``,e)},t[14]=a,t[15]=I,t[16]=te):te=t[16];let ne=te,re;t[17]!==a||t[18]!==I?(re=()=>{I&&a?.startCreating(`folder`,``)},t[17]=a,t[18]=I,t[19]=re):re=t[19];let ie=re,ae;t[20]===I?ae=t[21]:(ae=()=>{!I||!F||F.shell.showItemInFolder(I.contentDir)},t[20]=I,t[21]=ae);let se=ae,ce;t[22]!==r||t[23]!==I?(ce=async()=>{if(I)try{await navigator.clipboard.writeText(I.contentDir),X.success(r({id:`6_ZOw4`}),{description:I.contentDir})}catch(e){console.warn(`[FileSidebar] clipboard write failed:`,e),X.error(r({id:`vfRlCI`}))}},t[22]=r,t[23]=I,t[24]=ce):ce=t[24];let ue=ce,de;t[25]!==r||t[26]!==V?(de=e=>{if(V===null)return;let t=V.patch({appearance:{sidebar:{showHiddenFiles:e}}});t.ok||(console.warn(`[FileSidebar] showHiddenFiles toggle rejected:`,qr(t.error)),X.error(r({id:`P47EWZ`}),{description:qr(t.error)}))},t[25]=r,t[26]=V,t[27]=de):de=t[27];let fe=de,pe;t[28]!==r||t[29]!==V?(pe=e=>{if(V===null)return;let t=V.patch({appearance:{sidebar:{showAllFiles:e}}});t.ok||(console.warn(`[FileSidebar] showAllFiles toggle rejected:`,qr(t.error)),X.error(r({id:`P47EWZ`}),{description:qr(t.error)}))},t[28]=r,t[29]=V,t[30]=pe):pe=t[30];let me=pe,he;t[31]===a?he=t[32]:(he=()=>{a?.expandAll()},t[31]=a,t[32]=he);let ge=he,_e;t[33]===a?_e=t[34]:(_e=()=>{a?.collapseAll()},t[33]=a,t[34]=_e);let ve=_e,ye,be;t[35]!==W||t[36]!==K||t[37]!==G||t[38]!==U||t[39]!==g?(ye=()=>{F&&F.editor.notifyViewMenuStateChanged({showHiddenFiles:U,showAllFiles:W,canExpandAll:G,canCollapseAll:K,sidebarVisible:g===`expanded`})},be=[F,U,W,G,K,g],t[35]=W,t[36]=K,t[37]=G,t[38]=U,t[39]=g,t[40]=ye,t[41]=be):(ye=t[40],be=t[41]),(0,Q.useEffect)(ye,be);let xe,Se;t[42]!==r||t[43]!==c||t[44]!==l||t[45]!==R||t[46]!==L||t[47]!==m||t[48]!==V||t[49]!==W||t[50]!==U||t[51]!==_||t[52]!==a||t[53]!==I?(xe=()=>{if(F)return F.onMenuAction(e=>{switch(e){case`new-doc`:if(!I||!a)return;a.startCreating(`file`,m);return;case`new-folder`:if(!I||!a)return;a.startCreating(`folder`,m);return;case`new-from-template`:if(!I||!a)return;a.startCreatingFromTemplate(m);return;case`rename`:if(!l)return;IW(l);return;case`duplicate`:if(!l)return;RW(l);return;case`move-to-trash`:if(!l)return;PW(l);return;case`reveal-in-finder`:{if(!F||!I)return;let e=zK(l,c,I);F.shell.showItemInFolder(e);return}case`send-to-ai`:{let e=Fh.filter(e=>L[e.id]?.installed===!0);if(e.length===0){X.error(r({id:`LKOLNn`}));return}let t=VK(l,c,I);if(!t)return;let[n]=e;if(!n)return;R(n.id,t);return}case`copy-full-path`:{if(!I)return;let e=zK(l,c,I);navigator.clipboard.writeText(e).then(()=>X.success(r({id:`6_ZOw4`}),{description:e})).catch(e=>{console.warn(`[FileSidebar] clipboard write failed:`,e),X.error(r({id:`vfRlCI`}))});return}case`copy-relative-path`:{let e=BK(l,c);if(e===``){X.error(r({id:`74eHt-`}));return}navigator.clipboard.writeText(e).then(()=>X.success(r({id:`haHgQj`}),{description:e})).catch(e=>{console.warn(`[FileSidebar] clipboard write failed:`,e),X.error(r({id:`5QGTaA`}))});return}case`toggle-show-hidden-files`:{if(V===null)return;let e=V.patch({appearance:{sidebar:{showHiddenFiles:!U}}});e.ok||(console.warn(`[FileSidebar] toggle-show-hidden-files rejected:`,qr(e.error)),X.error(r({id:`P47EWZ`}),{description:qr(e.error)}));return}case`toggle-show-all-files`:{if(V===null)return;let e=V.patch({appearance:{sidebar:{showAllFiles:!W}}});e.ok||(console.warn(`[FileSidebar] toggle-show-all-files rejected:`,qr(e.error)),X.error(r({id:`P47EWZ`}),{description:qr(e.error)}));return}case`expand-all-tree`:a?.expandAll();return;case`collapse-all-tree`:a?.collapseAll();return;case`toggle-sidebar`:_();return;case`delete`:case`toggle-source`:case`save-version`:case`version-history`:case`focus-search`:case`focus-command-palette`:case`close-active-tab-or-window`:case`toggle-doc-panel`:return}})},Se=[F,a,I,l,c,m,V,U,W,L,R,_,r],t[42]=r,t[43]=c,t[44]=l,t[45]=R,t[46]=L,t[47]=m,t[48]=V,t[49]=W,t[50]=U,t[51]=_,t[52]=a,t[53]=I,t[54]=xe,t[55]=Se):(xe=t[54],Se=t[55]),(0,Q.useEffect)(xe,Se);let Ce=h&&y&&`motion-safe:delay-100`,we=b&&`opacity-0`,Te;t[56]!==Ce||t[57]!==we?(Te=ai(`flex-row h-12 items-center py-0 px-3`,`justify-between`,h&&`overflow-x-clip`,h&&`motion-safe:transition-opacity motion-safe:duration-100 motion-safe:ease-out`,Ce,we,h&&`[-webkit-app-region:drag]`),t[56]=Ce,t[57]=we,t[58]=Te):Te=t[58];let Ee;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=h?(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`sidebar-traffic-light-reserve`,className:`w-[var(--ok-titlebar-reserve-left,0px)] shrink-0 self-stretch`}):null,t[59]=Ee):Ee=t[59];let De;t[60]===y?De=t[61]:(De=y&&!h?(0,Z.jsx)(`span`,{className:`shrink-0 font-mono text-sm uppercase tracking-wider text-sidebar-foreground/50`,children:(0,Z.jsx)(s,{id:`sER-bs`})}):null,t[60]=y,t[61]=De);let Oe;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=ai(`flex items-center gap-1`,h&&`[&>*]:[-webkit-app-region:no-drag]`),t[62]=Oe):Oe=t[62];let Ae;t[63]!==r||t[64]!==O||t[65]!==D||t[66]!==k||t[67]!==a?(Ae=D?(0,Z.jsxs)(ro,{children:[(0,Z.jsx)(ao,{asChild:!0,children:(0,Z.jsx)(KK,{icon:xl,label:r({id:`Rq1vFD`})})}),(0,Z.jsxs)($a,{align:`end`,children:[O?null:(0,Z.jsxs)(Fa,{onSelect:()=>a?.expandAll(),children:[(0,Z.jsx)(ru,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`OlAl5i`})]}),k?null:(0,Z.jsxs)(Fa,{onSelect:()=>a?.collapseAll(),children:[(0,Z.jsx)(ul,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`qvWGzP`})]})]})]}):null,t[63]=r,t[64]=O,t[65]=D,t[66]=k,t[67]=a,t[68]=Ae):Ae=t[68];let je;t[69]===r?je=t[70]:(je=r({id:`HdkSiO`}),t[69]=r,t[70]=je);let Me;t[71]!==m||t[72]!==a?(Me=()=>a?.startCreating(`file`,m),t[71]=m,t[72]=a,t[73]=Me):Me=t[73];let Ne;t[74]!==je||t[75]!==Me?(Ne=(0,Z.jsx)(KK,{icon:Gl,label:je,onClick:Me}),t[74]=je,t[75]=Me,t[76]=Ne):Ne=t[76];let Pe;t[77]!==r||t[78]!==P||t[79]!==m||t[80]!==a?(Pe=P?(0,Z.jsxs)(ro,{children:[(0,Z.jsx)(ao,{asChild:!0,children:(0,Z.jsx)(KK,{icon:Qa,label:r({id:`Uuj_R4`})})}),(0,Z.jsx)($a,{align:`end`,children:(0,Z.jsx)(DW,{parentDir:m,onSelectTemplate:e=>a?.createFromTemplate(m,e),ItemComponent:Fa})})]}):null,t[77]=r,t[78]=P,t[79]=m,t[80]=a,t[81]=Pe):Pe=t[81];let Fe;t[82]===r?Fe=t[83]:(Fe=r({id:`96G6Re`}),t[82]=r,t[83]=Fe);let Ie;t[84]!==m||t[85]!==a?(Ie=()=>a?.startCreating(`folder`,m),t[84]=m,t[85]=a,t[86]=Ie):Ie=t[86];let Le;t[87]!==Fe||t[88]!==Ie?(Le=(0,Z.jsx)(KK,{icon:fl,label:Fe,onClick:Ie}),t[87]=Fe,t[88]=Ie,t[89]=Le):Le=t[89];let Re;t[90]!==Ae||t[91]!==Ne||t[92]!==Pe||t[93]!==Le?(Re=(0,Z.jsxs)(`div`,{"data-testid":`sidebar-toolbar`,className:Oe,children:[Ae,Ne,Pe,Le]}),t[90]=Ae,t[91]=Ne,t[92]=Pe,t[93]=Le,t[94]=Re):Re=t[94];let ze;t[95]!==Te||t[96]!==De||t[97]!==Re?(ze=(0,Z.jsxs)(Ik,{"data-electron-drag":h?``:void 0,className:Te,children:[Ee,De,Re]}),t[95]=Te,t[96]=De,t[97]=Re,t[98]=ze):ze=t[98];let Be=h&&y&&`motion-safe:delay-100`,Ve=b&&`opacity-0`,He;t[99]!==Be||t[100]!==Ve?(He=ai(`px-2 pb-2`,h&&`[-webkit-app-region:no-drag]`,h&&`motion-safe:transition-opacity motion-safe:duration-100 motion-safe:ease-out`,Be,Ve),t[99]=Be,t[100]=Ve,t[101]=He):He=t[101];let Ue;t[102]===g?Ue=t[103]:(Ue=[g],t[102]=g,t[103]=Ue);let We;t[104]===n?We=t[105]:(We=(0,Z.jsx)(FK,{onClick:n}),t[104]=n,t[105]=We);let Ge;t[106]!==Ue||t[107]!==We?(Ge=(0,Z.jsx)(le,{fallbackRender:JK,onError:PK,resetKeys:Ue,children:We}),t[106]=Ue,t[107]=We,t[108]=Ge):Ge=t[108];let Ke;t[109]!==He||t[110]!==Ge?(Ke=(0,Z.jsx)(`div`,{className:He,children:Ge}),t[109]=He,t[110]=Ge,t[111]=Ke):Ke=t[111];let qe;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(qe=(0,Z.jsxs)(Rk,{children:[(0,Z.jsx)(cN,{}),(0,Z.jsx)(KG,{ref:o})]}),t[112]=qe):qe=t[112];let Je;t[113]===Symbol.for(`react.memo_cache_sentinel`)?(Je=(0,Z.jsxs)(Lk,{className:`px-0`,children:[(0,Z.jsx)(RK,{}),typeof window<`u`&&window.okDesktop?(0,Z.jsx)(zk,{children:(0,Z.jsx)(Bk,{children:(0,Z.jsx)(MK,{bridge:window.okDesktop})})}):null]}),t[113]=Je):Je=t[113];let Ye=!(v&&g===`collapsed`),Xe;t[114]===Ye?Xe=t[115]:(Xe=(0,Z.jsx)(Pk,{enableToggle:!1,enableDrag:Ye}),t[114]=Ye,t[115]=Xe);let Ze;t[116]!==ze||t[117]!==Ke||t[118]!==Xe?(Ze=(0,Z.jsx)(nM,{asChild:!0,children:(0,Z.jsxs)(`div`,{className:`contents`,onContextMenu:J,children:[ze,Ke,qe,Je,Xe]})}),t[116]=ze,t[117]=Ke,t[118]=Xe,t[119]=Ze):Ze=t[119];let Qe=!I,$e,et;t[120]===Symbol.for(`react.memo_cache_sentinel`)?($e=(0,Z.jsx)(Gl,{"aria-hidden":`true`}),et=(0,Z.jsx)(s,{id:`HdkSiO`}),t[120]=$e,t[121]=et):($e=t[120],et=t[121]);let tt;t[122]!==ee||t[123]!==Qe?(tt=(0,Z.jsxs)(aM,{disabled:Qe,onSelect:ee,"data-testid":`empty-space-menu-new-file`,children:[$e,et]}),t[122]=ee,t[123]=Qe,t[124]=tt):tt=t[124];let nt;t[125]!==ne||t[126]!==N||t[127]!==I?(nt=N?(0,Z.jsxs)(rM,{children:[(0,Z.jsxs)(oM,{disabled:!I,"data-testid":`empty-space-menu-new-from-template`,children:[(0,Z.jsx)(Qa,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`Uuj_R4`})]}),(0,Z.jsx)(sM,{children:(0,Z.jsx)(DW,{parentDir:``,onSelectTemplate:ne,ItemComponent:aM})})]}):null,t[125]=ne,t[126]=N,t[127]=I,t[128]=nt):nt=t[128];let rt=!I,it,at;t[129]===Symbol.for(`react.memo_cache_sentinel`)?(it=(0,Z.jsx)(fl,{"aria-hidden":`true`}),at=(0,Z.jsx)(s,{id:`96G6Re`}),t[129]=it,t[130]=at):(it=t[129],at=t[130]);let ot;t[131]!==ie||t[132]!==rt?(ot=(0,Z.jsxs)(aM,{disabled:rt,onSelect:ie,"data-testid":`empty-space-menu-new-folder`,children:[it,at]}),t[131]=ie,t[132]=rt,t[133]=ot):ot=t[133];let st;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(st=(0,Z.jsx)(lM,{}),t[134]=st):st=t[134];let ct;t[135]!==r||t[136]!==se||t[137]!==I?(ct=F?(0,Z.jsxs)(aM,{disabled:!I,onSelect:se,"data-testid":`empty-space-menu-reveal-in-finder`,"aria-label":r(I?{id:`LtSYdi`}:{id:`o2yoFu`}),children:[(0,Z.jsx)(ke,{"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:(0,Z.jsx)(s,{id:`LtSYdi`})}),I?null:(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:(0,Z.jsx)(s,{id:`wTcjov`})})]}):null,t[135]=r,t[136]=se,t[137]=I,t[138]=ct):ct=t[138];let lt;t[139]!==R||t[140]!==B||t[141]!==L?(lt=(0,Z.jsx)(AK,{input:B,installStates:L,dispatch:R}),t[139]=R,t[140]=B,t[141]=L,t[142]=lt):lt=t[142];let ut=!I,dt;t[143]!==r||t[144]!==I?(dt=r(I?{id:`Up2_7p`}:{id:`U8CD-l`}),t[143]=r,t[144]=I,t[145]=dt):dt=t[145];let ft;t[146]===Symbol.for(`react.memo_cache_sentinel`)?(ft=(0,Z.jsx)(Et,{"aria-hidden":`true`}),t[146]=ft):ft=t[146];let mt;t[147]===Symbol.for(`react.memo_cache_sentinel`)?(mt=(0,Z.jsx)(`span`,{className:`flex-1`,children:(0,Z.jsx)(s,{id:`Up2_7p`})}),t[147]=mt):mt=t[147];let ht;t[148]===I?ht=t[149]:(ht=I?null:(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:(0,Z.jsx)(s,{id:`wTcjov`})}),t[148]=I,t[149]=ht);let gt;t[150]!==ue||t[151]!==ut||t[152]!==dt||t[153]!==ht?(gt=(0,Z.jsxs)(aM,{disabled:ut,onSelect:ue,"data-testid":`empty-space-menu-copy-full-path`,"aria-label":dt,children:[ft,mt,ht]}),t[150]=ue,t[151]=ut,t[152]=dt,t[153]=ht,t[154]=gt):gt=t[154];let _t;t[155]===Symbol.for(`react.memo_cache_sentinel`)?(_t=(0,Z.jsx)(lM,{}),t[155]=_t):_t=t[155];let vt=V===null,yt;t[156]===Symbol.for(`react.memo_cache_sentinel`)?(yt=(0,Z.jsx)(s,{id:`XcGbim`}),t[156]=yt):yt=t[156];let bt;t[157]!==fe||t[158]!==U||t[159]!==vt?(bt=(0,Z.jsx)(cM,{checked:U,onCheckedChange:fe,disabled:vt,"data-testid":`empty-space-menu-show-hidden-files`,children:yt}),t[157]=fe,t[158]=U,t[159]=vt,t[160]=bt):bt=t[160];let xt=V===null,St;t[161]===Symbol.for(`react.memo_cache_sentinel`)?(St=(0,Z.jsx)(s,{id:`i8dKs-`}),t[161]=St):St=t[161];let Ct;t[162]!==me||t[163]!==W||t[164]!==xt?(Ct=(0,Z.jsx)(cM,{checked:W,onCheckedChange:me,disabled:xt,"data-testid":`empty-space-menu-show-all-files`,children:St}),t[162]=me,t[163]=W,t[164]=xt,t[165]=Ct):Ct=t[165];let wt;t[166]===q?wt=t[167]:(wt=q?(0,Z.jsx)(lM,{}):null,t[166]=q,t[167]=wt);let Tt;t[168]!==ge||t[169]!==G?(Tt=G?(0,Z.jsxs)(aM,{onSelect:ge,"data-testid":`empty-space-menu-expand-all`,children:[(0,Z.jsx)(ru,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`OlAl5i`})]}):null,t[168]=ge,t[169]=G,t[170]=Tt):Tt=t[170];let Dt;t[171]!==ve||t[172]!==K?(Dt=K?(0,Z.jsxs)(aM,{onSelect:ve,"data-testid":`empty-space-menu-collapse-all`,children:[(0,Z.jsx)(ul,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`qvWGzP`})]}):null,t[171]=ve,t[172]=K,t[173]=Dt):Dt=t[173];let Ot;t[174]!==tt||t[175]!==nt||t[176]!==ot||t[177]!==ct||t[178]!==lt||t[179]!==gt||t[180]!==bt||t[181]!==Ct||t[182]!==wt||t[183]!==Tt||t[184]!==Dt?(Ot=(0,Z.jsxs)(iM,{children:[tt,nt,ot,st,ct,lt,gt,_t,bt,Ct,wt,Tt,Dt]}),t[174]=tt,t[175]=nt,t[176]=ot,t[177]=ct,t[178]=lt,t[179]=gt,t[180]=bt,t[181]=Ct,t[182]=wt,t[183]=Tt,t[184]=Dt,t[185]=Ot):Ot=t[185];let kt;return t[186]!==Ze||t[187]!==Ot?(kt=(0,Z.jsx)(Mk,{variant:`inset`,children:(0,Z.jsxs)(tM,{children:[Ze,Ot]})}),t[186]=Ze,t[187]=Ot,t[188]=kt):kt=t[188],kt}function JK(){return null}function YK(e){WK(e.target)&&(e.preventDefault(),e.stopPropagation())}function XK(e){let t=e.shareTargetExists,n=e.dirtyConflicts.conflicts,r=e.dirtyConflicts.files;return t&&!n?{kind:`A`,openCurrentEnabled:!0,switchEnabled:!0,conflictingFiles:r}:!t&&!n?{kind:`B`,openCurrentEnabled:!1,switchEnabled:!0,conflictingFiles:r}:t&&n?{kind:`C`,openCurrentEnabled:!0,switchEnabled:!1,conflictingFiles:r}:{kind:`D`,openCurrentEnabled:!1,switchEnabled:!1,conflictingFiles:r}}function ZK(e){return e.detached?e.currentHeadSha:e.currentBranch??`HEAD`}function QK(e){if(e.ok)return{action:`await-cc1`};switch(e.reason){case`dirty-conflict`:return{action:`rerender-conflict`,files:e.files??[]};case`branch-not-found`:return{action:`dismiss-with-toast`,reason:`branch-not-found`};case`fetch-failed`:case`checkout-failed`:return{action:`stay-with-toast`,reason:e.reason};case`branch-in-other-worktree`:{let t=e.otherWorktreePath;return t===void 0||t.length===0?{action:`stay-with-toast`,reason:`checkout-failed`}:{action:`pivot-to-other-worktree`,otherWorktreePath:t}}default:{let t=e.reason;throw Error(`Unhandled CheckoutFailureReason: ${String(t)}`)}}}var $K={phase:`loading`};function eq(e,t){return e.phase===`loading`?t===null?{phase:`error`}:{phase:`ready`,info:t}:e}function tq(e,t){return e.phase===`ready`?{phase:`switching`,info:e.info,pendingDoc:t}:e}function nq(e,t){if(e.phase!==`switching`)return{state:e};if(t===null)return{state:{phase:`ready`,info:e.info},sideEffect:{kind:`toast`,reason:`proxy-null`}};let n=QK(t);return n.action===`await-cc1`?{state:{phase:`awaiting-cc1-recycle`,pendingDoc:e.pendingDoc}}:n.action===`rerender-conflict`?{state:{phase:`ready`,info:{...e.info,dirtyConflicts:{conflicts:!0,files:n.files.slice()}}}}:n.action===`pivot-to-other-worktree`?{state:{phase:`branch-in-other-worktree`,info:e.info,otherWorktreePath:n.otherWorktreePath,pendingDoc:e.pendingDoc}}:n.action===`dismiss-with-toast`?{state:{phase:`dismissed`,reason:n.reason},sideEffect:{kind:`toast`,reason:n.reason}}:{state:{phase:`ready`,info:e.info},sideEffect:{kind:`toast`,reason:n.reason}}}function rq(e){return e!==null&&e.kind===`project-branch-switch`}function iq(e){let t=(0,$.c)(146),{bridge:n,store:r}=e,a=r===void 0?sf:r,{_:o}=i(),c=(0,Q.useSyncExternalStore)(a.subscribe,a.getSnapshot,uq),[l,u]=(0,Q.useState)($K),d=(0,Q.useRef)(!1),f=(0,Q.useRef)(!1),m;t[0]===c?m=t[1]:(m=rq(c)?c:null,t[0]=c,t[1]=m);let h=m,g;t[2]!==o||t[3]!==h?.share.target.kind?(g=h?.share.target.kind===`folder`?o({id:`ugoTXs`}):o({id:`XH30C4`}),t[2]=o,t[3]=h?.share.target.kind,t[4]=g):g=t[4];let _=g,v;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>{u($K),d.current=!1,f.current=!1},t[5]=v):v=t[5];let y;t[6]===c?y=t[7]:(y=[c],t[6]=c,t[7]=y),(0,Q.useEffect)(v,y);let b;t[8]!==h||t[9]!==n?(b=()=>{h&&(d.current||(d.current=!0,n.project.fetchBranchInfo({projectPath:h.projectPath,branch:h.share.branch,kind:h.share.target.kind,path:p(h.share.target)}).then(e=>{u(t=>eq(t,e))}).catch(e=>{console.warn(`[receive] branch-info-fetch-failed`,e instanceof Error?e.message:e),u(lq)})))},t[8]=h,t[9]=n,t[10]=b):b=t[10];let x;t[11]===h?x=t[12]:(x=[h],t[11]=h,t[12]=x),(0,Q.useEffect)(b,x);let S;t[13]!==o||t[14]!==h||t[15]!==l.phase||t[16]!==n||t[17]!==a||t[18]!==_?(S=()=>{if(l.phase!==`awaiting-cc1-recycle`||!h)return;let e=h.share.branch;if(!e){a.dismiss();return}if(f.current)return;f.current=!0;let t=!1;return n.project.awaitBranchSwitched({projectPath:h.projectPath,branch:e,timeoutMs:3e4}).then(r=>{if(!t){if(r.ok){console.log(pu({branch_dialog_action:`branch-switch-complete`,branch:e})),n.project.open({path:h.projectPath,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkTarget:{kind:h.share.target.kind,path:p(h.share.target)},pendingBranch:e}).catch(e=>{console.warn(`[receive] warm-focus-dispatch-failed branch_action=switch`,e instanceof Error?e.message:e),X.error(o({id:`gQV-9w`,values:{targetNoun:_}}))}),a.dismiss();return}console.log(pu({branch_dialog_action:`branch-switch-timeout`,branch:e})),X.error(o({id:`LBwUR6`,values:{targetNoun:_}})),a.dismiss()}}).catch(e=>{t||(console.warn(`[receive] awaitBranchSwitched rejected`,e instanceof Error?e.message:e),X.error(o({id:`Jw6EC4`,values:{targetNoun:_}})),a.dismiss())}),()=>{t=!0}},t[13]=o,t[14]=h,t[15]=l.phase,t[16]=n,t[17]=a,t[18]=_,t[19]=S):S=t[19];let C;if(t[20]!==h||t[21]!==l.phase?(C=[l.phase,h],t[20]=h,t[21]=l.phase,t[22]=C):C=t[22],(0,Q.useEffect)(S,C),!h)return null;let{share:w,projectPath:T,currentBranch:E}=h,D=w.branch,O;t[23]!==o||t[24]!==l.info||t[25]!==l.phase||t[26]!==n.project||t[27]!==T||t[28]!==w.target||t[29]!==D||t[30]!==a?(O=function(){l.phase===`ready`&&XK(l.info).switchEnabled&&(console.log(pu({branch_dialog_action:`switch`,branch_action:`switch`,branch:D})),u(e=>tq(e,p(w.target))),n.project.runCheckout({projectPath:T,branch:D}).then(e=>{let t=null,n=!1;u(r=>{let{state:i,sideEffect:a}=nq(r,e);return a&&(t=a.reason,n=i.phase===`dismissed`),i}),t===`branch-not-found`?X.error(o({id:`NJyQi_`,values:{shareBranch:D}})):t===`fetch-failed`?X.error(o({id:`bWLmRK`})):(t===`checkout-failed`||t===`proxy-null`)&&X.error(o({id:`c863eW`,values:{shareBranch:D}})),n&&a.dismiss()}).catch(e=>{console.warn(`[receive] runCheckout rejected branch_action=switch`,e instanceof Error?e.message:e),u(cq),X.error(o({id:`c863eW`,values:{shareBranch:D}}))}))},t[23]=o,t[24]=l.info,t[25]=l.phase,t[26]=n.project,t[27]=T,t[28]=w.target,t[29]=D,t[30]=a,t[31]=O):O=t[31];let k=O,A;t[32]!==o||t[33]!==n.project||t[34]!==T||t[35]!==w.target||t[36]!==D||t[37]!==a||t[38]!==_?(A=function(){console.log(pu({branch_dialog_action:`open-current`,branch:D})),n.project.open({path:T,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkTarget:{kind:w.target.kind,path:p(w.target)}}).catch(e=>{console.warn(`[receive] warm-focus-dispatch-failed branch_action=open-current`,e instanceof Error?e.message:e),X.error(o({id:`b5aNbi`,values:{targetNoun:_}}))}),a.dismiss()},t[32]=o,t[33]=n.project,t[34]=T,t[35]=w.target,t[36]=D,t[37]=a,t[38]=_,t[39]=A):A=t[39];let j=A,M;t[40]!==o||t[41]!==l.otherWorktreePath||t[42]!==l.phase||t[43]!==n.project||t[44]!==w.target||t[45]!==D||t[46]!==a?(M=function(){if(l.phase!==`branch-in-other-worktree`)return;let e=l.otherWorktreePath;console.log(pu({branch_dialog_action:`pivot-to-other-worktree`,branch:D})),n.project.open({path:e,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkTarget:{kind:w.target.kind,path:p(w.target)},pendingBranch:D}).catch(t=>{console.warn(`[receive] pivot-open-failed branch_action=pivot-to-other-worktree`,t instanceof Error?t.message:t),X.error(o({id:`LdABLa`,values:{target:e}}))}),a.dismiss()},t[40]=o,t[41]=l.otherWorktreePath,t[42]=l.phase,t[43]=n.project,t[44]=w.target,t[45]=D,t[46]=a,t[47]=M):M=t[47];let N=M,P;t[48]===a?P=t[49]:(P=function(){console.log(pu({branch_dialog_action:`cancel`})),a.dismiss()},t[48]=a,t[49]=P);let F=P,I,L,R,z,B,V,H,U,W,G,K,q,J,Y,ee,te,ne;if(t[50]!==o||t[51]!==l.info||t[52]!==l.otherWorktreePath||t[53]!==l.phase||t[54]!==F||t[55]!==E||t[56]!==w.branch||t[57]!==w.owner||t[58]!==w.repo||t[59]!==w.target||t[60]!==D||t[61]!==_){ne=l.phase===`ready`||l.phase===`switching`?XK(l.info):null;let e;t[79]!==l.info||t[80]!==l.phase||t[81]!==E?(e=l.phase===`ready`||l.phase===`switching`?ZK(l.info):E??`HEAD`,t[79]=l.info,t[80]=l.phase,t[81]=E,t[82]=e):e=t[82];let n=e;V=l.phase===`switching`||l.phase===`awaiting-cc1-recycle`;let r;t[83]===o?r=t[84]:(r=o({id:`OuY8t9`}),t[83]=o,t[84]=r),z=r;let i;t[85]!==o||t[86]!==D?(i=o({id:`_BthEY`,values:{shareBranch:D}}),t[85]=o,t[86]=D,t[87]=i):i=t[87],B=i;let a=l.phase===`loading`,c=l.phase===`error`;R=Eo,ee=!0,t[88]===F?te=t[89]:(te=e=>{e||F()},t[88]=F,t[89]=te),L=So,G=`sm:max-w-xl`,K=`share-branch-switch-dialog`,q=sq,J=oq;let u;t[90]===_?u=t[91]:(u=(0,Z.jsx)(xo,{children:(0,Z.jsx)(s,{id:`RY6Bq1`,values:{targetNoun:_}})}),t[90]=_,t[91]=u);let d=w.owner,f=w.repo,m;t[92]===w.target?m=t[93]:(m=p(w.target),t[92]=w.target,t[93]=m);let h;t[94]!==w.owner||t[95]!==w.repo||t[96]!==m?(h=(0,Z.jsx)(bo,{className:`sr-only`,children:(0,Z.jsx)(s,{id:`f8jU-L`,values:{0:d,1:f,2:m}})}),t[94]=w.owner,t[95]=w.repo,t[96]=m,t[97]=h):h=t[97],t[98]!==u||t[99]!==h?(Y=(0,Z.jsxs)(To,{children:[u,h]}),t[98]=u,t[99]=h,t[100]=Y):Y=t[100],I=Co;let g=w.owner,v=w.repo,y;t[101]===w.target?y=t[102]:(y=p(w.target),t[101]=w.target,t[102]=y),t[103]!==w.branch||t[104]!==w.owner||t[105]!==w.repo||t[106]!==w.target.kind||t[107]!==y?(H=(0,Z.jsx)(`div`,{className:`mb-4`,children:(0,Z.jsx)(Qd,{owner:g,repo:v,path:y,kind:w.target.kind,branch:w.branch,testId:`share-branch-switch-metadata`,branchTestId:`share-branch-switch-metadata-branch`})}),t[103]=w.branch,t[104]=w.owner,t[105]=w.repo,t[106]=w.target.kind,t[107]=y,t[108]=H):H=t[108],U=l.phase===`branch-in-other-worktree`?(0,Z.jsxs)(`div`,{className:`text-sm text-muted-foreground`,"data-testid":`share-branch-switch-in-other-worktree`,children:[(0,Z.jsx)(`p`,{className:`leading-6`,children:(0,Z.jsx)(s,{id:`yjExfe`,values:{shareBranch:D},components:{0:(0,Z.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}),(0,Z.jsx)(`p`,{className:`mt-2 break-all rounded bg-muted px-2 py-1 font-mono text-xs text-foreground/80`,"data-testid":`share-branch-switch-in-other-worktree-path`,children:l.otherWorktreePath})]}):a?(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,"data-testid":`share-branch-switch-loading`,role:`status`,"aria-live":`polite`,children:[(0,Z.jsx)(Yt,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`jerqF0`})]}):c?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Z.jsx)(s,{id:`w4hMYl`})}):ne?.kind===`D`?(0,Z.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:(0,Z.jsx)(s,{id:`XnoA1k`,values:{targetNoun:_,shareBranch:D},components:{0:(0,Z.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}):ne?.kind===`B`?(0,Z.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:(0,Z.jsx)(s,{id:`sZ2IOu`,values:{targetNoun:_,shareBranch:D,currentLabel:n},components:{0:(0,Z.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`}),1:(0,Z.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}):(0,Z.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:(0,Z.jsx)(s,{id:`_902BE`,values:{targetNoun:_,shareBranch:D,currentLabel:n},components:{0:(0,Z.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`}),1:(0,Z.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}})}),W=ne&&!ne.switchEnabled&&ne.conflictingFiles.length>0?(0,Z.jsxs)(`div`,{className:`mt-3 rounded-md border border-border bg-muted/30 p-3 text-1sm`,"data-testid":`share-branch-switch-conflict`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-foreground/90`,children:(0,Z.jsx)(s,{id:`n2lRue`})}),(0,Z.jsx)(`ul`,{id:`share-receive-branch-conflict-files`,className:`mt-1 list-disc space-y-0.5 pl-5 text-muted-foreground`,children:ne.conflictingFiles.map(aq)})]}):null,t[50]=o,t[51]=l.info,t[52]=l.otherWorktreePath,t[53]=l.phase,t[54]=F,t[55]=E,t[56]=w.branch,t[57]=w.owner,t[58]=w.repo,t[59]=w.target,t[60]=D,t[61]=_,t[62]=I,t[63]=L,t[64]=R,t[65]=z,t[66]=B,t[67]=V,t[68]=H,t[69]=U,t[70]=W,t[71]=G,t[72]=K,t[73]=q,t[74]=J,t[75]=Y,t[76]=ee,t[77]=te,t[78]=ne}else I=t[62],L=t[63],R=t[64],z=t[65],B=t[66],V=t[67],H=t[68],U=t[69],W=t[70],G=t[71],K=t[72],q=t[73],J=t[74],Y=t[75],ee=t[76],te=t[77],ne=t[78];let re;t[109]===V?re=t[110]:(re=V?(0,Z.jsxs)(`p`,{className:`mt-3 flex items-center gap-2 text-sm text-muted-foreground`,"data-testid":`share-branch-switch-switching`,role:`status`,"aria-live":`polite`,children:[(0,Z.jsx)(Yt,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`CU3AiE`})]}):null,t[109]=V,t[110]=re);let ie;t[111]!==I||t[112]!==H||t[113]!==U||t[114]!==W||t[115]!==re?(ie=(0,Z.jsxs)(I,{children:[H,U,W,re]}),t[111]=I,t[112]=H,t[113]=U,t[114]=W,t[115]=re,t[116]=ie):ie=t[116];let ae;t[117]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Z.jsx)(s,{id:`dEgA5A`}),t[117]=ae):ae=t[117];let oe;t[118]===F?oe=t[119]:(oe=(0,Z.jsx)(si,{variant:`ghost`,className:`font-mono uppercase`,onClick:F,"data-testid":`share-branch-switch-cancel`,children:ae}),t[118]=F,t[119]=oe);let se;t[120]!==l.phase||t[121]!==j||t[122]!==N||t[123]!==k||t[124]!==z||t[125]!==B||t[126]!==V||t[127]!==ne?(se=l.phase===`branch-in-other-worktree`?(0,Z.jsx)(si,{onClick:N,"data-testid":`share-branch-switch-in-other-worktree-pivot`,children:(0,Z.jsx)(s,{id:`hyCxJY`})}):(0,Z.jsxs)(`div`,{className:`flex flex-col-reverse gap-2 sm:flex-row sm:gap-2`,children:[ne?.openCurrentEnabled?(0,Z.jsxs)(si,{variant:`outline`,className:`font-mono uppercase`,onClick:j,disabled:V,"data-testid":`share-branch-switch-open-current`,children:[(0,Z.jsx)(Tl,{className:`size-3.5`,"aria-hidden":!0}),z]}):null,(0,Z.jsx)(si,{onClick:k,disabled:!ne?.switchEnabled||V,"aria-disabled":!ne?.switchEnabled||V,"aria-describedby":ne&&!ne.switchEnabled&&ne.conflictingFiles.length>0?`share-receive-branch-conflict-files`:void 0,"data-testid":`share-branch-switch-switch`,children:V?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Yt,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}),B]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ce,{className:`size-3.5`,"aria-hidden":!0}),B]})})]}),t[120]=l.phase,t[121]=j,t[122]=N,t[123]=k,t[124]=z,t[125]=B,t[126]=V,t[127]=ne,t[128]=se):se=t[128];let ce;t[129]!==oe||t[130]!==se?(ce=(0,Z.jsxs)(wo,{className:`sm:justify-between`,children:[oe,se]}),t[129]=oe,t[130]=se,t[131]=ce):ce=t[131];let le;t[132]!==L||t[133]!==G||t[134]!==K||t[135]!==q||t[136]!==J||t[137]!==Y||t[138]!==ie||t[139]!==ce?(le=(0,Z.jsxs)(L,{className:G,"data-testid":K,onInteractOutside:q,onPointerDownOutside:J,children:[Y,ie,ce]}),t[132]=L,t[133]=G,t[134]=K,t[135]=q,t[136]=J,t[137]=Y,t[138]=ie,t[139]=ce,t[140]=le):le=t[140];let ue;return t[141]!==R||t[142]!==ee||t[143]!==te||t[144]!==le?(ue=(0,Z.jsx)(R,{open:ee,onOpenChange:te,children:le}),t[141]=R,t[142]=ee,t[143]=te,t[144]=le,t[145]=ue):ue=t[145],ue}function aq(e){return(0,Z.jsx)(`li`,{children:(0,Z.jsx)(`code`,{className:`text-foreground/80`,children:e})},e)}function oq(e){e.preventDefault()}function sq(e){e.preventDefault()}function cq(e){return nq(e,null).state}function lq(e){return eq(e,null)}function uq(){return null}function dq(){let e=(0,$.c)(17),t=Cn(),{collabUrl:n,setSystemProvider:r,updateServerInstanceId:i,onBranchSwitched:a,observeBranch:o,observeDiskAck:s,refreshServerInfo:c}=pt(),l;e[0]!==o||e[1]!==s||e[2]!==a||e[3]!==c||e[4]!==i?(l={updateServerInstanceId:i,onBranchSwitched:a,observeBranch:o,observeDiskAck:s,refreshServerInfo:c},e[0]=o,e[1]=s,e[2]=a,e[3]=c,e[4]=i,e[5]=l):l=e[5];let u=(0,Q.useRef)(l),d;e[6]!==o||e[7]!==s||e[8]!==a||e[9]!==c||e[10]!==i?(d=()=>{u.current={updateServerInstanceId:i,onBranchSwitched:a,observeBranch:o,observeDiskAck:s,refreshServerInfo:c}},e[6]=o,e[7]=s,e[8]=a,e[9]=c,e[10]=i,e[11]=d):d=e[11],(0,Q.useEffect)(d);let f,p;return e[12]!==n||e[13]!==t||e[14]!==r?(f=()=>{if(n===null)return;let e=new Pe,i=new lt({url:n,name:Br,document:e,onStateless:e=>{let{payload:t}=e;H(t,{onServerInfo:e=>{u.current.updateServerInstanceId(e.serverInstanceId),e.currentBranch!==void 0&&u.current.observeBranch(e.currentBranch)},onBranchSwitched:e=>{u.current.onBranchSwitched(e.branch)},onDiskAck:e=>{u.current.observeDiskAck(e.docName,e.sv)},onDerivedView:_q,onConfigValidationRejected:gq,onConfigIgnoreNestedError:hq,onUnknown:mq})},onClose:pq,onDisconnect:fq}),a=Xo(e=>{(e.includes(`files`)||e.includes(`backlinks`))&&(t.invalidateQueries({queryKey:[`backlinks`]}),t.invalidateQueries({queryKey:[`forward-links`]})),(e.includes(`files`)||e.includes(`graph`))&&(t.invalidateQueries({queryKey:[`orphans`]}),t.invalidateQueries({queryKey:[`hubs`]}))}),o=Xt(()=>{u.current.refreshServerInfo()});i.on(`synced`,()=>{is([`files`,`backlinks`,`graph`]),o()});let s=new Set,c=()=>{if(i.awareness)for(let[e,t]of i.awareness.getStates().entries())s.has(e)||t.user?.type===`agent`&&(s.add(e),console.warn(`[agent-presence] observed stale AwarenessUser.type === 'agent' from clientID ${e} — probably a stale bundled client`))};return i.awareness?.on(`change`,c),r(i),()=>{a(),i.awareness?.off(`change`,c),r(null),i.destroy(),e.destroy()}},p=[t,n,r],e[12]=n,e[13]=t,e[14]=r,e[15]=f,e[16]=p):(f=e[15],p=e[16]),(0,Q.useEffect)(f,p),null}function fq(){console.warn(`[CC1] __system__ disconnected - derived views may be stale`)}function pq(e){let{event:t}=e;console.warn(`[CC1] __system__ connection closed:`,t.code,t.reason)}function mq(e){console.warn(`[CC1] Unparseable stateless payload, skipping:`,e.slice(0,100))}function hq(e){Za(e)}function gq(e){to(e)}function _q(e){is([e.ch])}var vq=`#install-claude-desktop`;function yq(e){return e===`#settings`||e===vq}function bq(e,t,n){return[e,t,n].map(e=>[...e].sort().join(`\0`)).join(``)}function xq(){let e=(0,$.c)(23),{clearTarget:t,syncOpenTabsWithKnownTargets:n,tabSessionLoaded:r}=pt(),{openTargetTransition:i}=wt(),{assetPaths:a,folderPaths:o,loading:s,pageMeta:c,pages:l,pagesBySlug:u,pagesByBasename:d}=es(),f=(0,Q.useRef)(null),p;e[0]!==a||e[1]!==o||e[2]!==l?(p=bq(l,o,a),e[0]=a,e[1]=o,e[2]=l,e[3]=p):p=e[3];let m=p,h,g;e[4]!==a||e[5]!==o||e[6]!==s||e[7]!==l||e[8]!==n||e[9]!==r||e[10]!==m?(h=()=>{s||!r||f.current===m||(f.current=m,n({pages:l,folderPaths:o,assetPaths:a}))},g=[a,o,s,l,n,r,m],e[4]=a,e[5]=o,e[6]=s,e[7]=l,e[8]=n,e[9]=r,e[10]=m,e[11]=h,e[12]=g):(h=e[11],g=e[12]),(0,Q.useEffect)(h,g);let _,v;return e[13]!==t||e[14]!==o||e[15]!==s||e[16]!==i||e[17]!==c||e[18]!==l||e[19]!==d||e[20]!==u?(_=()=>{e();function e(){if(yq(window.location.hash))return;let e=ns(window.location.hash);if(e){let t=rr(e.split(`.`).pop()??``);ue(`ok/nav/hash-change`,{docName:null,kind:`asset`}),i({kind:`asset`,target:e,assetPath:e,mediaKind:t});return}if(Bo(window.location.hash)){ue(`ok/nav/hash-change`,{docName:null,kind:`folder`}),i({kind:`folder`,target:``,folderPath:``});return}let n=Po(window.location.hash);if(!n){ue(`ok/nav/hash-change`,{docName:null,kind:`clear`}),t();return}if(s){ue(`ok/nav/hash-change`,{docName:n,kind:`deferred-loading`});return}let r=Qo(n,{pages:l,folderPaths:o,pagesBySlug:u,pagesByBasename:d});if(r.kind===`missing`&&/\/+$/.test(n.trim())){ue(`ok/nav/hash-change`,{docName:n,kind:`deferred-missing-folder`});return}let a=rs(os(r),c);ue(`ok/nav/hash-change`,{docName:n,kind:a.kind}),i(a)}return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},v=[t,o,s,i,c,l,u,d],e[13]=t,e[14]=o,e[15]=s,e[16]=i,e[17]=c,e[18]=l,e[19]=d,e[20]=u,e[21]=_,e[22]=v):(_=e[21],v=e[22]),(0,Q.useEffect)(_,v),null}function Sq(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,Q.useEffect)(Cq,t),null}function Cq(){let e=Eq;if(!e(window.location.hash))return;let t=new AbortController;return ce(t.signal).then(n=>{if(t.signal.aborted||n.status!==`ok`)return;let r=n.config.paneTarget;r?.startsWith(`#/`)&&e(window.location.hash)&&(window.location.hash=r,fetch(`/api/config`,{method:`DELETE`}).catch(Tq))}).catch(wq),()=>t.abort()}function wq(){}function Tq(){}function Eq(e){return!yq(e)&&!ns(e)&&!Po(e)&&(e===``||e===`#`||e===`#/`)}function Dq(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,Q.useEffect)(Oq,t),null}function Oq(){let e=function(e){let t=e.target;Hh({target:t,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,key:e.key})&&(e.preventDefault(),window.location.hash!==`#settings`&&(window.location.hash=Vh))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}function kq(){let e=(0,$.c)(4),{activeTarget:t}=pt(),n=typeof window<`u`?window.okDesktop??null:null,r=t?.kind===`doc`||t?.kind===`folder`||t?.kind===`asset`?t.kind:null,i=t?.kind===`doc`?t.docName:t?.kind===`folder`?t.folderPath:t?.kind===`asset`?t.assetPath:null,a,o;return e[0]!==i||e[1]!==r?(a=()=>{if(n){if(r===null){n.editor.notifyActiveTargetChanged({kind:null});return}i!==null&&n.editor.notifyActiveTargetChanged({kind:r,identifier:i})}},o=[n,r,i],e[0]=i,e[1]=r,e[2]=a,e[3]=o):(a=e[2],o=e[3]),(0,Q.useEffect)(a,o),null}function Aq(){let e=(0,$.c)(8),{activeDocName:t,activeTarget:n}=pt(),[r,i]=(0,Q.useState)(!1),a;e[0]!==t||e[1]!==n?(a=n?.kind===`folder`?n.folderPath:us(t),e[0]=t,e[1]=n,e[2]=a):a=e[2];let o=a,s,c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=function(e){let t=e.target;nh({target:t,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,key:e.key})&&(e.preventDefault(),i(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},c=[],e[3]=s,e[4]=c):(s=e[3],c=e[4]),(0,Q.useEffect)(s,c);let l;return e[5]!==r||e[6]!==o?(l=(0,Z.jsx)(ih,{open:r,onOpenChange:i,kind:`file`,initialDir:o}),e[5]=r,e[6]=o,e[7]=l):l=e[7],l}function jq(e){let t=(0,$.c)(3),{children:n}=e,{collabUrl:r}=pt(),i;return t[0]!==n||t[1]!==r?(i=(0,Z.jsx)(B,{collabUrl:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function Mq(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(Wt,{name:`app`,children:(0,Z.jsx)(jt,{children:(0,Z.jsx)(jq,{children:(0,Z.jsx)(Lh,{children:(0,Z.jsx)(Nq,{})})})})}),e[0]=t):t=e[0],t}function Nq(){let e=(0,$.c)(25),t=typeof window<`u`?window.okDesktop??null:null,n=typeof window<`u`&&window.okDesktop!=null,[r,i]=(0,Q.useState)(!1),a=Bh(),o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=t?{launchInTerminal:Pq}:null,e[0]=o):o=e[0];let s=o,c;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(d_,{}),e[1]=c):c=e[1];let l,u,d,f,p;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(dq,{}),u=(0,Z.jsx)(xq,{}),d=(0,Z.jsx)(Sq,{}),f=(0,Z.jsx)(kq,{}),p=(0,Z.jsx)(Aq,{}),e[2]=l,e[3]=u,e[4]=d,e[5]=f,e[6]=p):(l=e[2],u=e[3],d=e[4],f=e[5],p=e[6]);let m;e[7]===a?m=e[8]:(m=!a&&(0,Z.jsx)(Dq,{}),e[7]=a,e[8]=m);let h,g,_,v;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=!1,v=t?(0,Z.jsx)(f_,{bridge:t}):null,h=(0,Z.jsx)(Jd,{}),g=t?(0,Z.jsx)(iq,{bridge:t}):null,e[9]=h,e[10]=g,e[11]=_,e[12]=v):(h=e[9],g=e[10],_=e[11],v=e[12]);let y;e[13]===r?y=e[14]:(y=(0,Z.jsx)(r_,{bridge:t,open:r,onOpenChange:i}),e[13]=r,e[14]=y);let b;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(b=n&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`editor-window-chrome-drag-strip`,"data-electron-drag":``,className:`pointer-events-none fixed inset-x-0 top-0 z-50 h-2 [-webkit-app-region:drag]`}),e[15]=b):b=e[15];let x;e[16]===a?x=e[17]:(x=!a&&(0,Z.jsx)(GK,{onOpenSearch:()=>i(!0)}),e[16]=a,e[17]=x);let S;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(Fk,{className:`overflow-hidden h-[calc(100vh-var(--layout-inset-offset))]`,children:(0,Z.jsx)(iN,{onOpenSearch:()=>i(!0)})}),e[18]=S):S=e[18];let C;e[19]===x?C=e[20]:(C=(0,Z.jsx)(VM,{value:s,children:(0,Z.jsxs)(kk,{className:`h-screen overflow-hidden`,children:[x,S]})}),e[19]=x,e[20]=C);let w;return e[21]!==y||e[22]!==C||e[23]!==m?(w=(0,Z.jsxs)(Z.Fragment,{children:[c,(0,Z.jsxs)(as,{children:[l,u,d,f,p,m,_,v,h,g,y,b,C]})]}),e[21]=y,e[22]=C,e[23]=m,e[24]=w):w=e[24],w}function Pq(e){nN(Ag(e))}Oc(),kf({apiOrigin:typeof window<`u`?window.okDesktop?.config.apiOrigin:void 0}),Hf(),mp()&&bp(),cm(),kp(),typeof window<`u`&&Wf({bridge:window.okDesktop}),typeof window<`u`&&tp({bridge:window.okDesktop}),typeof window<`u`&&Ws({bridge:window.okDesktop}),typeof window<`u`&&zs({bridge:window.okDesktop}),typeof window<`u`&&qf({bridge:window.okDesktop}),typeof window<`u`&&cf({bridge:window.okDesktop}),Np();var Fq=new Lc({defaultOptions:{queries:{retry:1,staleTime:1e4}}}),Iq=document.getElementById(`root`);if(!Iq)throw Error(`Root element not found`);var Lq=typeof window<`u`&&window.okDesktop?.config.mode===`navigator`;(0,Jc.createRoot)(Iq).render((0,Z.jsx)(Q.StrictMode,{children:(0,Z.jsx)(a,{i18n:Ko,children:(0,Z.jsx)(hn,{client:Fq,children:(0,Z.jsxs)(Wr,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,disableTransitionOnChange:!0,storageKey:`ok-theme-v1`,children:[(0,Z.jsx)(ks,{children:Lq&&window.okDesktop?(0,Z.jsx)(Sf,{bridge:window.okDesktop}):(0,Z.jsx)(Mq,{})}),(0,Z.jsx)(Df,{richColors:!0,closeButton:!0})]})})})}));
|