@inkeep/open-knowledge 0.5.0-beta.14 → 0.5.0-beta.16
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/open-knowledge/SKILL.md +12 -3
- package/dist/{banner-4PRLiK-I.mjs → banner-DdbR6AZr.mjs} +1 -1
- package/dist/cli.mjs +4 -4
- package/dist/constants-XCszYh-u.mjs +2 -0
- package/dist/{dist-JvyJrwkx.mjs → dist-D5J2z1mI.mjs} +1 -1
- package/dist/{dist-BFaejI07.mjs → dist-V31CRf7D.mjs} +326 -9
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{init-DoDYKuWt.mjs → init-Db-MJvF_.mjs} +5 -5
- package/dist/init-De5O5Atd.mjs +1 -0
- package/dist/{loader-DwY1uRWB.mjs → loader-BF1HVIAE.mjs} +2 -2
- package/dist/loader-C1hxiMbK.mjs +1 -0
- package/dist/{open-browser-CoKDMbx5.mjs → open-browser-BOeCxs2W.mjs} +1 -1
- package/dist/preview-N6-E_vFx.mjs +1 -0
- package/dist/{preview-D0Cwj9ak.mjs → preview-qR7FFUro.mjs} +2 -2
- package/dist/public/assets/{index-Cpe78yvf.js → index-BXFJIE7O.js} +2 -2
- package/dist/public/index.html +1 -1
- package/dist/repair-mcp-configs-DUU6zN1U.mjs +2 -0
- package/dist/{src-T_WN5ziD.mjs → src-DzWkP5Kf.mjs} +2 -2
- package/dist/start-D6YbKWO-.mjs +1 -0
- package/dist/{start-Bi19bmNy.mjs → start-DivgyWbO.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-BMZzAuZK.mjs +0 -2
- package/dist/init-DeafrQoL.mjs +0 -1
- package/dist/loader-DyZnLFXV.mjs +0 -1
- package/dist/preview-DCoA7FqK.mjs +0 -1
- package/dist/start-CxJ_Uuo2.mjs +0 -1
|
@@ -12,7 +12,7 @@ Error generating stack: `+e.message+`
|
|
|
12
12
|
`);i=o.pop()??``;for(let e of o)if(e.trim()&&t(e)===`terminal`)return!0}}function jc(e){let t=[],n=[],r=new AbortController,i=!1,a=()=>{for(let e of n.splice(0))e(null)};return e(e=>{i||(n.length>0?n.shift()?.(e):t.push(e),(e.type===`complete`||e.type===`error`)&&(i=!0,r.abort(),a()))},r.signal),{events:{[Symbol.asyncIterator](){return{async next(){if(t.length>0){let e=t.shift();return e===void 0?{value:void 0,done:!0}:{value:e,done:!1}}return i?{value:void 0,done:!0}:new Promise(e=>{n.push(t=>{e(t===null?{value:void 0,done:!0}:{value:t,done:!1})})})}}}},cancel:()=>{i||(i=!0,r.abort(),a())}}}function Mc(){return{start(){return jc((e,t)=>{(async()=>{try{let n=await fetch(`/api/local-op/auth/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({json:!0}),signal:t});if(!n.ok){let t=`Failed to start sign-in — try again`;try{let e=await n.json(),r=ir.safeParse(e);r.success&&(t=r.data.title)}catch{}e({type:`error`,message:t});return}if(!n.body){e({type:`error`,message:`Failed to start sign-in — try again`});return}!await Ac(n.body,t=>{let n;try{n=JSON.parse(t)}catch{return console.warn(`[auth-transport] Dropped unparseable NDJSON line:`,t.slice(0,100)),`continue`}if(n&&typeof n==`object`&&n.type===`error`&&`problem`in n){let t=n.problem;return e({type:`error`,message:t?.detail||t?.title||`Unknown error`}),`terminal`}let r=n;return e(r),r.type===`complete`||r.type===`error`?`terminal`:`continue`})&&!t.aborted&&e({type:`error`,message:`Sign-in stream ended without confirmation — please try again`})}catch(t){if(t instanceof Error&&t.name===`AbortError`)return;e({type:`error`,message:`Connection error — try again`})}})()})}}}function Nc(e){return{start(){return e.localOp.auth.start()}}}function Pc(){return{start(e){return jc((t,n)=>{(async()=>{try{let r=await fetch(`/api/local-op/clone`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e.url,dir:e.dir||void 0}),signal:n});if(!r.ok){let e=`Clone failed — check the URL and try again (${r.status})`;try{let t=await r.json(),n=ir.safeParse(t);n.success&&(e=`Clone failed: ${n.data.title}`)}catch{}t({type:`error`,message:e});return}if(!r.body){t({type:`error`,message:`Clone failed — empty response body`});return}let i=r.body.getReader(),a=new TextDecoder,o=``;for(;;){let{done:e,value:r}=await i.read();if(e)break;o+=a.decode(r,{stream:!0});let s=o.split(`
|
|
13
13
|
`);o=s.pop()??``;for(let e of s){if(!e.trim())continue;let n;try{n=JSON.parse(e)}catch{console.warn(`[clone-transport] Dropped unparseable NDJSON line:`,e.slice(0,100));continue}if(n&&typeof n==`object`&&n.type===`error`&&`problem`in n){let e=n.problem;t({type:`error`,message:e?.detail||e?.title||`Unknown error`});break}t(n)}if(n.aborted)break}n.aborted||t({type:`error`,message:`Clone stream ended unexpectedly — check if the clone completed`})}catch(e){if(e instanceof Error&&e.name===`AbortError`)return;t({type:`error`,message:`Clone failed — connection error`})}})()})}}}function Fc(e){return{start(t){return e.localOp.clone.start(t)}}}var Ic=`ContextMenu`,[Lc,Rc]=Ur(Ic,[Ni]),zc=Ni(),[Bc,Vc]=Lc(Ic),Hc=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,dir:i,modal:a=!0}=e,[o,s]=Q.useState(!1),c=zc(t),l=Gr(r),u=Q.useCallback(e=>{s(e),l(e)},[l]);return(0,Z.jsx)(Bc,{scope:t,open:o,onOpenChange:u,modal:a,children:(0,Z.jsx)(Ui,{...c,dir:i,open:o,onOpenChange:u,modal:a,children:n})})};Hc.displayName=Ic;var Uc=`ContextMenuTrigger`,Wc=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,disabled:r=!1,...i}=e,a=Vc(Uc,n),o=zc(n),s=Q.useRef({x:0,y:0}),c=Q.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...s.current})}),l=Q.useRef(0),u=Q.useCallback(()=>window.clearTimeout(l.current),[]),d=e=>{s.current={x:e.clientX,y:e.clientY},a.onOpenChange(!0)};return Q.useEffect(()=>u,[u]),Q.useEffect(()=>void(r&&u()),[r,u]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(fa,{...o,virtualRef:c}),(0,Z.jsx)(Br.span,{"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,...i,ref:t,style:{WebkitTouchCallout:`none`,...e.style},onContextMenu:r?e.onContextMenu:zr(e.onContextMenu,e=>{u(),d(e),e.preventDefault()}),onPointerDown:r?e.onPointerDown:zr(e.onPointerDown,yl(e=>{u(),l.current=window.setTimeout(()=>d(e),700)})),onPointerMove:r?e.onPointerMove:zr(e.onPointerMove,yl(u)),onPointerCancel:r?e.onPointerCancel:zr(e.onPointerCancel,yl(u)),onPointerUp:r?e.onPointerUp:zr(e.onPointerUp,yl(u))})]})});Wc.displayName=Uc;var Gc=`ContextMenuPortal`,Kc=e=>{let{__scopeContextMenu:t,...n}=e,r=zc(t);return(0,Z.jsx)(ua,{...r,...n})};Kc.displayName=Gc;var qc=`ContextMenuContent`,Jc=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Vc(qc,n),a=zc(n),o=Q.useRef(!1);return(0,Z.jsx)(ca,{...a,...r,ref:t,side:`right`,sideOffset:2,align:`start`,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),!t.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Jc.displayName=qc;var Yc=`ContextMenuGroup`,Xc=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=zc(n);return(0,Z.jsx)(xa,{...i,...r,ref:t})});Xc.displayName=Yc;var Zc=`ContextMenuLabel`,Qc=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=zc(n);return(0,Z.jsx)(ma,{...i,...r,ref:t})});Qc.displayName=Zc;var $c=`ContextMenuItem`,el=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=zc(n);return(0,Z.jsx)(Yi,{...i,...r,ref:t})});el.displayName=$c;var tl=`ContextMenuCheckboxItem`,nl=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=zc(n);return(0,Z.jsx)(Ji,{...i,...r,ref:t})});nl.displayName=tl;var rl=`ContextMenuRadioGroup`,il=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=zc(n);return(0,Z.jsx)(na,{...i,...r,ref:t})});il.displayName=rl;var al=`ContextMenuRadioItem`,ol=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=zc(n);return(0,Z.jsx)(ea,{...i,...r,ref:t})});ol.displayName=al;var sl=`ContextMenuItemIndicator`,cl=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=zc(n);return(0,Z.jsx)(Qi,{...i,...r,ref:t})});cl.displayName=sl;var ll=`ContextMenuSeparator`,ul=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=zc(n);return(0,Z.jsx)(Ca,{...i,...r,ref:t})});ul.displayName=ll;var dl=`ContextMenuArrow`,fl=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=zc(n);return(0,Z.jsx)(va,{...i,...r,ref:t})});fl.displayName=dl;var pl=`ContextMenuSub`,ml=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,open:i,defaultOpen:a}=e,o=zc(t),[s,c]=Kr({prop:i,defaultProp:a??!1,onChange:r,caller:pl});return(0,Z.jsx)(ka,{...o,open:s,onOpenChange:c,children:n})};ml.displayName=pl;var hl=`ContextMenuSubTrigger`,gl=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=zc(n);return(0,Z.jsx)(Da,{...i,...r,ref:t})});gl.displayName=hl;var _l=`ContextMenuSubContent`,vl=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=zc(n);return(0,Z.jsx)(qi,{...i,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});vl.displayName=_l;function yl(e){return t=>t.pointerType===`mouse`?void 0:e(t)}var bl=Hc,xl=Wc,Sl=Kc,Cl=Jc,wl=el,Tl=ul,El=`Radio`,[Dl,Ol]=Ur(El),[kl,Al]=Dl(El),jl=Q.forwardRef((e,t)=>{let{__scopeRadio:n,name:r,checked:i=!1,required:a,disabled:o,value:s=`on`,onCheck:c,form:l,...u}=e,[d,f]=Q.useState(null),p=Jr(t,e=>f(e)),m=Q.useRef(!1),h=d?l||!!d.closest(`form`):!0;return(0,Z.jsxs)(kl,{scope:n,checked:i,disabled:o,children:[(0,Z.jsx)(Br.button,{type:`button`,role:`radio`,"aria-checked":i,"data-state":Il(i),"data-disabled":o?``:void 0,disabled:o,value:s,...u,ref:p,onClick:zr(e.onClick,e=>{i||c?.(),h&&(m.current=e.isPropagationStopped(),m.current||e.stopPropagation())})}),h&&(0,Z.jsx)(Fl,{control:d,bubbles:!m.current,name:r,value:s,checked:i,required:a,disabled:o,form:l,style:{transform:`translateX(-100%)`}})]})});jl.displayName=El;var Ml=`RadioIndicator`,Nl=Q.forwardRef((e,t)=>{let{__scopeRadio:n,forceMount:r,...i}=e,a=Al(Ml,n);return(0,Z.jsx)(Hr,{present:r||a.checked,children:(0,Z.jsx)(Br.span,{"data-state":Il(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t})})});Nl.displayName=Ml;var Pl=`RadioBubbleInput`,Fl=Q.forwardRef(({__scopeRadio:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=Q.useRef(null),s=Jr(o,a),c=Pa(n),l=Za(t);return Q.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,Z.jsx)(Br.input,{type:`radio`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});Fl.displayName=Pl;function Il(e){return e?`checked`:`unchecked`}var Ll=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`],Rl=`RadioGroup`,[zl,Bl]=Ur(Rl,[to,Ol]),Vl=to(),Hl=Ol(),[Ul,Wl]=zl(Rl),Gl=Q.forwardRef((e,t)=>{let{__scopeRadioGroup:n,name:r,defaultValue:i,value:a,required:o=!1,disabled:s=!1,orientation:c,dir:l,loop:u=!0,onValueChange:d,...f}=e,p=Vl(n),m=un(l),[h,g]=Kr({prop:a,defaultProp:i??null,onChange:d,caller:Rl});return(0,Z.jsx)(Ul,{scope:n,name:r,required:o,disabled:s,value:h,onValueChange:g,children:(0,Z.jsx)(no,{asChild:!0,...p,orientation:c,dir:m,loop:u,children:(0,Z.jsx)(Br.div,{role:`radiogroup`,"aria-required":o,"aria-orientation":c,"data-disabled":s?``:void 0,dir:m,...f,ref:t})})})});Gl.displayName=Rl;var Kl=`RadioGroupItem`,ql=Q.forwardRef((e,t)=>{let{__scopeRadioGroup:n,disabled:r,...i}=e,a=Wl(Kl,n),o=a.disabled||r,s=Vl(n),c=Hl(n),l=Q.useRef(null),u=Jr(t,l),d=a.value===i.value,f=Q.useRef(!1);return Q.useEffect(()=>{let e=e=>{Ll.includes(e.key)&&(f.current=!0)},t=()=>f.current=!1;return document.addEventListener(`keydown`,e),document.addEventListener(`keyup`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`keyup`,t)}},[]),(0,Z.jsx)(io,{asChild:!0,...s,focusable:!o,active:d,children:(0,Z.jsx)(jl,{disabled:o,required:a.required,checked:d,...c,...i,name:a.name,ref:u,onCheck:()=>a.onValueChange(i.value),onKeyDown:zr(e=>{e.key===`Enter`&&e.preventDefault()}),onFocus:zr(i.onFocus,()=>{f.current&&l.current?.click()})})})});ql.displayName=Kl;var Jl=`RadioGroupIndicator`,Yl=Q.forwardRef((e,t)=>{let{__scopeRadioGroup:n,...r}=e;return(0,Z.jsx)(Nl,{...Hl(n),...r,ref:t})});Yl.displayName=Jl;var Xl=Gl,Zl=ql,Ql=Yl;async function $l(e){try{await navigator.clipboard.writeText(e)}catch{}}var eu=120*1e3;function tu(e){let t=(0,$.c)(26),{onSuccess:n,onCancel:r,transport:i}=e,[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(`https://github.com/login/device`),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(eu),_=(0,Q.useRef)(null),v=(0,Q.useRef)(null),y;t[0]!==n||t[1]!==i?(y=async function(){f(null),m(!0);try{let e=i.start();_.current=e.cancel;let t=e.events[Symbol.asyncIterator](),r=!1,a=await t.next();for(;!a.done;){let e=a.value;if(e.type===`verification`)o(e.user_code),c(e.verification_uri),g(e.expires_in*1e3),$l(e.user_code).then(()=>{u(!0),setTimeout(()=>u(!1),2e3)});else if(e.type===`complete`){r=!0,m(!1),n({login:e.login,name:e.name,email:e.email,avatarUrl:e.avatarUrl});break}else if(e.type===`error`){r=!0,f(e.message),m(!1);break}a=await t.next()}r||(f(`Sign-in stream ended without confirmation — please try again`),m(!1))}catch(e){let t=e;t instanceof Error&&t.name!==`AbortError`&&f(`Connection error — try again`),m(!1)}},t[0]=n,t[1]=i,t[2]=y):y=t[2];let b=y,x;t[3]===b?x=t[4]:(x=()=>{let e=!1;return queueMicrotask(()=>{e||b()}),()=>{e=!0,_.current?.(),_.current=null,v.current&&clearInterval(v.current)}},t[3]=b,t[4]=x);let S;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(S=[],t[5]=S):S=t[5],(0,Q.useEffect)(x,S);let C,w;t[6]===a?(C=t[7],w=t[8]):(C=()=>{if(!a)return;let e=Date.now();return v.current=setInterval(()=>{let t=eu-(Date.now()-e);t<=0?(g(0),v.current&&clearInterval(v.current),f(`Code expired — please try again`)):g(t)},1e3),()=>{v.current&&clearInterval(v.current)}},w=[a],t[6]=a,t[7]=C,t[8]=w),(0,Q.useEffect)(C,w);let T=Math.floor(h/6e4),E=Math.floor(h%6e4/1e3),D;t[9]===E?D=t[10]:(D=E.toString().padStart(2,`0`),t[9]=E,t[10]=D);let O=`${T}:${D}`,k;t[11]!==l||t[12]!==d||t[13]!==O||t[14]!==a||t[15]!==s?(k=a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Open`,` `,(0,Z.jsx)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>pi(e,s),onAuxClick:e=>pi(e,s),className:`underline underline-offset-2`,children:s}),` `,`and enter this code:`]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`code`,{className:`flex-1 text-center text-2xl font-mono font-bold tracking-widest border rounded-md py-3 bg-muted`,children:a}),(0,Z.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>void $l(a).then(()=>{u(!0),setTimeout(()=>u(!1),2e3)}),children:l?`Copied!`:`Copy`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-500 animate-pulse`}),`Waiting for authorization`]}),(0,Z.jsxs)(`span`,{children:[`Expires in `,O]})]})]}):(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-6 text-sm text-muted-foreground`,children:d?null:`Starting sign-in flow`}),t[11]=l,t[12]=d,t[13]=O,t[14]=a,t[15]=s,t[16]=k):k=t[16];let A;t[17]===d?A=t[18]:(A=d&&(0,Z.jsx)(`p`,{className:`text-sm text-destructive`,children:d}),t[17]=d,t[18]=A);let j;t[19]!==r||t[20]!==p?(j=p&&(0,Z.jsx)(X,{variant:`ghost`,size:`sm`,onClick:r,children:`Cancel`}),t[19]=r,t[20]=p,t[21]=j):j=t[21];let M;return t[22]!==k||t[23]!==A||t[24]!==j?(M=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[k,A,j]}),t[22]=k,t[23]=A,t[24]=j,t[25]=M):M=t[25],M}function nu(e){let t=(0,$.c)(32),{onSuccess:n,onCancel:r}=e,[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(null),d,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>()=>{u.current?.abort()},f=[],t[0]=d,t[1]=f):(d=t[0],f=t[1]),(0,Q.useEffect)(d,f);let p;t[2]!==n||t[3]!==i?(p=async function(){if(!i.trim()){l(`Paste a personal access token`);return}u.current?.abort();let e=new AbortController;u.current=e,s(!0),l(null);try{let t=await fetch(`/api/local-op/auth/pat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pat:i.trim()}),signal:e.signal});if(!t.ok){let e=`Invalid token — check that it has repo scope`;try{let n=await t.json(),r=ir.safeParse(n);r.success&&(e=r.data.title)}catch{}l(e),s(!1);return}if(!t.body){l(`Invalid token — check that it has repo scope`),s(!1);return}await Ac(t.body,e=>{let t;try{t=JSON.parse(e)}catch{return`continue`}return t.type===`complete`?(n({login:t.login,name:t.name,email:t.email}),s(!1),`terminal`):`continue`})||l(`No response — try again`)}catch(e){let t=e;t instanceof Error&&t.name!==`AbortError`&&l(`Connection error — try again`)}s(!1)},t[2]=n,t[3]=i,t[4]=p):p=t[4];let m=p,h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(`a`,{href:`https://github.com/settings/tokens`,target:`_blank`,rel:`noopener noreferrer`,onClick:iu,onAuxClick:ru,className:`underline underline-offset-2`,children:`github.com/settings/tokens`}),t[5]=h):h=t[5];let g;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Create a token at`,` `,h,` `,`with `,(0,Z.jsx)(`code`,{className:`text-xs bg-muted px-1 rounded`,children:`repo`}),` scope.`]}),t[6]=g):g=t[6];let _;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>a(e.target.value),t[7]=_):_=t[7];let v;t[8]===m?v=t[9]:(v=e=>{e.key===`Enter`&&m()},t[8]=m,t[9]=v);let y;t[10]!==o||t[11]!==i||t[12]!==v?(y=(0,Z.jsx)(fo,{type:`password`,"aria-label":`Personal access token`,placeholder:`ghp_…`,value:i,onChange:_,disabled:o,onKeyDown:v}),t[10]=o,t[11]=i,t[12]=v,t[13]=y):y=t[13];let b;t[14]===c?b=t[15]:(b=c&&(0,Z.jsx)(`p`,{className:`text-sm text-destructive`,children:c}),t[14]=c,t[15]=b);let x;t[16]===m?x=t[17]:(x=()=>void m(),t[16]=m,t[17]=x);let S=o?`Validating`:`Add token`,C;t[18]!==o||t[19]!==x||t[20]!==S?(C=(0,Z.jsx)(X,{className:`flex-1`,onClick:x,disabled:o,children:S}),t[18]=o,t[19]=x,t[20]=S,t[21]=C):C=t[21];let w;t[22]!==o||t[23]!==r?(w=(0,Z.jsx)(X,{variant:`ghost`,onClick:r,disabled:o,children:`Cancel`}),t[22]=o,t[23]=r,t[24]=w):w=t[24];let T;t[25]!==C||t[26]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[C,w]}),t[25]=C,t[26]=w,t[27]=T):T=t[27];let E;return t[28]!==T||t[29]!==y||t[30]!==b?(E=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[g,y,b,T]}),t[28]=T,t[29]=y,t[30]=b,t[31]=E):E=t[31],E}function ru(e){return pi(e,`https://github.com/settings/tokens`)}function iu(e){return pi(e,`https://github.com/settings/tokens`)}function au(e){let t=(0,$.c)(27),{login:n,onSave:r,onSkip:i}=e,[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Before syncing, set your identity for git commits:`}),t[0]=l):l=t[0];let u=`Name (e.g. ${n})`,d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=e=>o(e.target.value),t[1]=d):d=t[1];let f;t[2]!==a||t[3]!==u?(f=(0,Z.jsx)(fo,{"aria-label":`Name`,placeholder:u,value:a,onChange:d}),t[2]=a,t[3]=u,t[4]=f):f=t[4];let p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>c(e.target.value),t[5]=p):p=t[5];let m;t[6]===s?m=t[7]:(m=(0,Z.jsx)(fo,{type:`email`,"aria-label":`Email`,placeholder:`Email`,value:s,onChange:p}),t[6]=s,t[7]=m);let h;t[8]!==s||t[9]!==a||t[10]!==r?(h=()=>r(a.trim(),s.trim()),t[8]=s,t[9]=a,t[10]=r,t[11]=h):h=t[11];let g;t[12]!==s||t[13]!==a?(g=!a.trim()||!s.trim(),t[12]=s,t[13]=a,t[14]=g):g=t[14];let _;t[15]!==h||t[16]!==g?(_=(0,Z.jsx)(X,{className:`flex-1`,onClick:h,disabled:g,children:`Save`}),t[15]=h,t[16]=g,t[17]=_):_=t[17];let v;t[18]===i?v=t[19]:(v=(0,Z.jsx)(X,{variant:`ghost`,onClick:i,children:`Skip`}),t[18]=i,t[19]=v);let y;t[20]!==v||t[21]!==_?(y=(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[_,v]}),t[20]=v,t[21]=_,t[22]=y):y=t[22];let b;return t[23]!==y||t[24]!==f||t[25]!==m?(b=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[l,f,m,y]}),t[23]=y,t[24]=f,t[25]=m,t[26]=b):b=t[26],b}function ou(e){let t=(0,$.c)(42),{open:n,onOpenChange:r,onSuccess:i,identityPrompt:a,reauth:o,transport:s}=e,c;t[0]===s?c=t[1]:(c=s??Mc(),t[0]=s,t[1]=c);let l=c,[u,d]=(0,Q.useState)(`device`),[f,p]=(0,Q.useState)(`auth`),[m,h]=(0,Q.useState)(null),g,_;t[2]===n?(g=t[3],_=t[4]):(g=()=>{n&&(d(`device`),p(`auth`),h(null))},_=[n],t[2]=n,t[3]=g,t[4]=_),(0,Q.useEffect)(g,_);let v;t[5]!==a||t[6]!==r||t[7]!==i?(v=function(e){h(e),a&&(!e.name||!e.email)?p(`identity`):(p(`done`),i?.(e),r(!1),Xa.success(`Signed in as @${e.login}`))},t[5]=a,t[6]=r,t[7]=i,t[8]=v):v=t[8];let y=v,b;t[9]!==m||t[10]!==r||t[11]!==i?(b=function(e,t){fetch(`/api/local-op/auth/set-identity`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e,email:t})}).catch(su);let n={...m??{login:``},name:e,email:t};p(`done`),i?.(n),r(!1),Xa.success(`Signed in as @${n.login}`)},t[9]=m,t[10]=r,t[11]=i,t[12]=b):b=t[12];let x=b,S;t[13]!==m||t[14]!==r||t[15]!==i?(S=function(){m&&(p(`done`),i?.(m),r(!1),Xa.success(`Signed in as @${m.login}`))},t[13]=m,t[14]=r,t[15]=i,t[16]=S):S=t[16];let C=S,w;t[17]===r?w=t[18]:(w=function(){r(!1)},t[17]=r,t[18]=w);let T=w,E=o?`Re-authenticate with GitHub`:`Sign in to GitHub`,D;t[19]===E?D=t[20]:(D=(0,Z.jsx)(qa,{children:(0,Z.jsx)(Ra,{children:E})}),t[19]=E,t[20]=D);let O;t[21]!==y||t[22]!==T||t[23]!==l||t[24]!==f||t[25]!==u?(O=f===`auth`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex gap-1 border-b pb-2 mb-1`,children:[(0,Z.jsx)(X,{variant:u===`device`?`secondary`:`ghost`,size:`sm`,onClick:()=>d(`device`),children:`GitHub App`}),(0,Z.jsx)(X,{variant:u===`pat`?`secondary`:`ghost`,size:`sm`,onClick:()=>d(`pat`),children:`Token`})]}),u===`device`?(0,Z.jsx)(tu,{onSuccess:y,onCancel:T,transport:l}):(0,Z.jsx)(nu,{onSuccess:y,onCancel:T})]}),t[21]=y,t[22]=T,t[23]=l,t[24]=f,t[25]=u,t[26]=O):O=t[26];let k;t[27]!==m||t[28]!==x||t[29]!==C||t[30]!==f?(k=f===`identity`&&m&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Signed in as @`,m.login]}),(0,Z.jsx)(au,{login:m.login,onSave:x,onSkip:C})]}),t[27]=m,t[28]=x,t[29]=C,t[30]=f,t[31]=k):k=t[31];let A;t[32]!==k||t[33]!==O?(A=(0,Z.jsxs)(Wa,{children:[O,k]}),t[32]=k,t[33]=O,t[34]=A):A=t[34];let j;t[35]!==A||t[36]!==D?(j=(0,Z.jsxs)(Va,{className:`sm:max-w-md`,children:[D,A]}),t[35]=A,t[36]=D,t[37]=j):j=t[37];let M;return t[38]!==r||t[39]!==n||t[40]!==j?(M=(0,Z.jsx)(Ja,{open:n,onOpenChange:r,children:j}),t[38]=r,t[39]=n,t[40]=j,t[41]=M):M=t[41],M}function su(){}function cu(e){let t=(0,$.c)(2),{className:n}=e,{channel:r}=bc();if(r!==`beta`)return null;let i;return t[0]===n?i=t[1]:(i=(0,Z.jsx)(Ne,{variant:`secondary`,"aria-label":`Beta channel`,"data-testid":`beta-badge`,className:n,children:`BETA`}),t[0]=n,t[1]=i),i}function lu(e){switch(e){case`receiving`:return`Receiving objects`;case`resolving`:return`Resolving deltas`;case`checking`:return`Checking out files`;case`init`:return`Initializing project`;case`done`:return`Complete`;default:return`Cloning`}}function uu(e){let t=e.trim();if(/^[\w.-]+\/[\w.-]+$/.test(t))return t.split(`/`)[1];try{return new URL(t.replace(/^git@([^:]+):/,`https://$1/`)).pathname.replace(/\.git$/,``).split(`/`).pop()??`repo`}catch{return t.split(`/`).pop()?.replace(/\.git$/,``)??`repo`}}function du(e){let t=(0,$.c)(94),{open:n,onOpenChange:r,onSignIn:i,onCloneComplete:a,transport:o,authQueryTransport:s,pickParentFolder:c}=e,l;t[0]===o?l=t[1]:(l=o??Pc(),t[0]=o,t[1]=l);let u=l,d;t[2]===s?d=t[3]:(d=s??Oc(),t[2]=s,t[3]=d);let f=d,p=c!==void 0,[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(``),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(!1),O=(0,Q.useRef)(null),k=(0,Q.useRef)(null),A;t[4]!==n||t[5]!==f?(A=()=>{if(!n)return;let e=!1;return f.status().then(t=>{e||T(t.authenticated)}).catch(()=>{e||T(!1)}),()=>{e=!0}},t[4]=n,t[5]=f,t[6]=A):A=t[6];let j;t[7]===n?j=t[8]:(j=[n],t[7]=n,t[8]=j),(0,Q.useEffect)(A,j);let M;t[9]!==w||t[10]!==n||t[11]!==f?(M=()=>{if(!w||!n)return;let e=!1;return x(!0),f.repos().then(t=>{e||(y(t.ok?t.repos:[]),x(!1))}).catch(()=>{e||(y([]),x(!1))}),()=>{e=!0}},t[9]=w,t[10]=n,t[11]=f,t[12]=M):M=t[12];let N;t[13]!==w||t[14]!==n?(N=[w,n],t[13]=w,t[14]=n,t[15]=N):N=t[15],(0,Q.useEffect)(M,N);let P;t[16]===p?P=t[17]:(P=function(e){if(h(e),p)return;let t=uu(e);t&&_(`~/Documents/${t}`)},t[16]=p,t[17]=P);let F=P,I;t[18]===p?I=t[19]:(I=function(e){if(h(e.clone_url),p)return;let t=e.full_name.split(`/`)[1];_(`~/Documents/${t}`)},t[18]=p,t[19]=I);let L=I,R;t[20]!==g||t[21]!==a||t[22]!==r||t[23]!==c||t[24]!==u||t[25]!==m?(R=async function(){let e=m.trim();if(!e){Xa.error(`Enter a repository URL or owner/repo`);return}let t=g||``;if(c){D(!0);let n=await c();if(!n){D(!1);return}let r=uu(e);t=`${n.replace(/\/$/,``)}/${r}`}else D(!0);let n=Xa.loading(`Starting clone`,{duration:1/0});k.current=n;let i=u.start({url:e,dir:t});O.current=i.cancel;try{let e=i.events[Symbol.asyncIterator](),t=await e.next();for(;!t.done;){let i=t.value;if(i.type===`progress`)Xa.loading(`${lu(i.phase)} — ${i.pct}%`,{id:n});else if(i.type===`complete`){Xa.success(`Clone complete — opening project`,{id:n}),r(!1),D(!1),O.current=null;let e=`port`in i?i.port:void 0;a?a({port:e,dir:i.dir}):e!==void 0&&(window.location.href=`http://localhost:${e}`);return}else if(i.type===`error`){Xa.error(`Clone failed: ${i.message}`,{id:n}),D(!1),O.current=null;return}t=await e.next()}Xa.error(`Clone stream ended unexpectedly — check if the clone completed`,{id:n}),D(!1),O.current=null}catch(e){console.error(`[CloneDialog] clone iteration failed:`,e),Xa.error(`Clone failed — connection error`,{id:n}),D(!1),O.current=null}},t[20]=g,t[21]=a,t[22]=r,t[23]=c,t[24]=u,t[25]=m,t[26]=R):R=t[26];let z=R,B;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(B=function(){O.current?.(),O.current=null,D(!1),Xa.dismiss(k.current??void 0)},t[27]=B):B=t[27];let V=B,H;t[28]!==E||t[29]!==r||t[30]!==p?(H=function(e){E||(r(e),e||(h(``),p||_(``),C(``)))},t[28]=E,t[29]=r,t[30]=p,t[31]=H):H=t[31];let U=H,W,G,K,q,ee,te,ne,re,ie,ae;if(t[32]!==E||t[33]!==U||t[34]!==L||t[35]!==F||t[36]!==w||t[37]!==b||t[38]!==n||t[39]!==S||t[40]!==v||t[41]!==m){let e=v?.filter(e=>e.full_name.toLowerCase().includes(S.toLowerCase()));K=Ja,ie=n,ae=U,G=Va,ne=`sm:max-w-lg`,t[52]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Z.jsx)(qa,{children:(0,Z.jsx)(Ra,{children:`Clone from GitHub`})}),t[52]=re):re=t[52],W=Wa,q=`flex flex-col gap-4`;let r;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(`label`,{htmlFor:`clone-url`,className:`text-sm font-medium`,children:`Repository URL or owner/repo`}),t[53]=r):r=t[53];let i;t[54]===F?i=t[55]:(i=e=>F(e.target.value),t[54]=F,t[55]=i),t[56]!==E||t[57]!==i||t[58]!==m?(ee=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[r,(0,Z.jsx)(fo,{id:`clone-url`,placeholder:`https://github.com/owner/repo or owner/repo`,value:m,onChange:i,disabled:E})]}),t[56]=E,t[57]=i,t[58]=m,t[59]=ee):ee=t[59],te=w&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`repo-filter`,className:`text-sm font-medium`,children:`Your repositories`}),(0,Z.jsx)(fo,{id:`repo-filter`,"aria-label":`Filter repositories`,placeholder:`Filter repositories`,value:S,onChange:e=>C(e.target.value),disabled:E||b&&v===null}),(0,Z.jsx)(`div`,{className:`border rounded-md max-h-40 overflow-y-auto subtle-scrollbar`,"aria-busy":b&&v===null,children:b&&v===null?(0,Z.jsxs)(`output`,{className:`flex flex-col gap-1.5 px-3 py-2`,"aria-label":`Loading repositories`,children:[(0,Z.jsx)(Gi,{className:`h-4 w-2/3`}),(0,Z.jsx)(Gi,{className:`h-4 w-1/2`}),(0,Z.jsx)(Gi,{className:`h-4 w-3/4`}),(0,Z.jsx)(Gi,{className:`h-4 w-2/5`}),(0,Z.jsx)(Gi,{className:`h-4 w-3/5`})]}):e?.length===0?(0,Z.jsx)(`p`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:v?.length===0?`No repositories found.`:`No matches.`}):e?.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`w-full text-left px-3 py-1.5 text-sm hover:bg-muted flex items-center gap-2 truncate disabled:opacity-50`,onClick:()=>L(e),disabled:E,children:[e.private&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:`🔒`}),e.full_name]},e.full_name))})]}),t[32]=E,t[33]=U,t[34]=L,t[35]=F,t[36]=w,t[37]=b,t[38]=n,t[39]=S,t[40]=v,t[41]=m,t[42]=W,t[43]=G,t[44]=K,t[45]=q,t[46]=ee,t[47]=te,t[48]=ne,t[49]=re,t[50]=ie,t[51]=ae}else W=t[42],G=t[43],K=t[44],q=t[45],ee=t[46],te=t[47],ne=t[48],re=t[49],ie=t[50],ae=t[51];let oe;t[60]!==E||t[61]!==w||t[62]!==i?(oe=!w&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:`Browse your repos:`}),(0,Z.jsx)(X,{variant:`link`,size:`sm`,className:`h-auto p-0`,onClick:()=>i?.(),disabled:E,children:`Sign in to GitHub`})]}),t[60]=E,t[61]=w,t[62]=i,t[63]=oe):oe=t[63];let se;t[64]!==E||t[65]!==g||t[66]!==p?(se=!p&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`clone-path`,className:`text-sm font-medium`,children:`Local path`}),(0,Z.jsx)(fo,{id:`clone-path`,placeholder:`~/Documents/repo-name`,value:g,onChange:e=>_(e.target.value),disabled:E})]}),t[64]=E,t[65]=g,t[66]=p,t[67]=se):se=t[67];let ce;t[68]!==q||t[69]!==ee||t[70]!==te||t[71]!==oe||t[72]!==se?(ce=(0,Z.jsxs)(`div`,{className:q,children:[ee,te,oe,se]}),t[68]=q,t[69]=ee,t[70]=te,t[71]=oe,t[72]=se,t[73]=ce):ce=t[73];let le;t[74]!==W||t[75]!==ce?(le=(0,Z.jsx)(W,{children:ce}),t[74]=W,t[75]=ce,t[76]=le):le=t[76];let ue;t[77]!==E||t[78]!==z||t[79]!==U||t[80]!==m||t[81]!==p?(ue=(0,Z.jsx)(Ga,{children:E?(0,Z.jsx)(X,{variant:`outline`,className:`font-mono uppercase`,onClick:V,children:`Cancel`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(X,{variant:`outline`,className:`font-mono uppercase`,onClick:()=>U(!1),children:`Cancel`}),(0,Z.jsx)(X,{onClick:()=>void z(),disabled:!m.trim(),"aria-describedby":p?`clone-picker-hint`:void 0,children:`Clone`}),p&&(0,Z.jsx)(`span`,{id:`clone-picker-hint`,className:`sr-only`,children:`Opens a folder picker to choose where to clone the repository.`})]})}),t[77]=E,t[78]=z,t[79]=U,t[80]=m,t[81]=p,t[82]=ue):ue=t[82];let de;t[83]!==G||t[84]!==ne||t[85]!==re||t[86]!==le||t[87]!==ue?(de=(0,Z.jsxs)(G,{className:ne,children:[re,le,ue]}),t[83]=G,t[84]=ne,t[85]=re,t[86]=le,t[87]=ue,t[88]=de):de=t[88];let fe;return t[89]!==K||t[90]!==ie||t[91]!==ae||t[92]!==de?(fe=(0,Z.jsx)(K,{open:ie,onOpenChange:ae,children:de}),t[89]=K,t[90]=ie,t[91]=ae,t[92]=de,t[93]=fe):fe=t[93],fe}var fu=(0,Q.lazy)(()=>r(()=>import(`./ConsentDialogBody-BYenkRKt.js`),__vite__mapDeps([5,1,6,7,8,9,10,11]),import.meta.url));function pu(){let e=(0,$.c)(1);if(!(0,Q.useSyncExternalStore)(ho.subscribe,hu,mu))return null;let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(fu,{})}),e[0]=t):t=e[0],t}function mu(){return!1}function hu(){return ho.getSnapshot()!==null}var gu=180;function _u(e,t){if(e===``||t===``)return``;let n=e.includes(`\\`)&&!e.includes(`/`)?`\\`:`/`;return`${e.replace(/[/\\]+$/,``)}${n}${t}`}function vu(e){if(e===``)return``;let t=e.split(/[/\\]/).filter(Boolean);return t.length>0?t[t.length-1]??e:e}function yu(e){let{parent:t,sanitizedName:n,enclosingProject:r,enclosingGit:i,targetState:a}=e;return t===``||n===``?{kind:`idle`}:r===null?i===null?a===`exists-nonempty`?{kind:`block-nonempty`}:{kind:`free`}:{kind:`confirm-git`,gitRoot:i.gitRoot}:{kind:`block-nested`,rootPath:r.rootPath}}function bu(e){let t=e instanceof Error?e.message:String(e);for(let e of Cr)if(t.startsWith(`${e}:`)||t.includes(`${e}: `))return e===`nested-project`||e===`target-not-empty`?{reason:e}:{reason:e,message:t};return{reason:`unknown`,message:t}}function xu(e){switch(e.reason){case`nested-project`:return`A project already exists at this location. Pick a different parent folder.`;case`target-not-empty`:return`A non-empty folder with this name already exists. Use a different name.`;case`invalid-args`:return`Invalid input — please check the name and try again.`;case`mkdir-failed`:return`Could not create the project folder. Try a different name or location.`;case`git-init-failed`:return`Project folder created, but git init failed. Try again.`;case`init-failed`:return`Could not write project files. Try a different location.`;case`discovery-failed`:return`Could not finalize project setup. Try again.`;case`unknown`:return`Could not create project. Try again or pick a different location.`}}function Su(e){let t=(0,$.c)(94),{open:n,onOpenChange:r,bridge:i}=e,[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(Tu),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p={kind:`idle`},t[0]=p):p=t[0];let[m,h]=(0,Q.useState)(p),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),b;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(b=new Map,t[1]=b):b=t[1];let x=(0,Q.useRef)(b),S;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(S=new Set,t[2]=S):S=t[2];let C=(0,Q.useRef)(S),w=(0,Q.useRef)(null),T=(0,Q.useRef)(null),E=(0,Q.useRef)(null),D,O;t[3]!==i||t[4]!==n?(D=()=>{if(!n)return;x.current.clear(),C.current.clear(),y(null),h({kind:`idle`}),_(!1),o(``),f(new Set(cn));let e=!1;u(!0),i.fs.defaultProjectsRoot().then(t=>{e||c(t)}).catch(wu).finally(()=>{e||u(!1)});let t=requestAnimationFrame(()=>{E.current?.focus()});return()=>{e=!0,cancelAnimationFrame(t)}},O=[n,i],t[3]=i,t[4]=n,t[5]=D,t[6]=O):(D=t[5],O=t[6]),(0,Q.useEffect)(D,O);let k,A;t[7]!==i||t[8]!==a||t[9]!==n||t[10]!==s?(k=()=>{if(!n)return;T.current!==null&&clearTimeout(T.current),w.current!==null&&w.current.abort();let e=jn(a);if(s===``||e===``){h({kind:`idle`});return}let t=_u(s,e),r=x.current.get(t);if(r!==void 0){h(yu({parent:s,sanitizedName:e,enclosingProject:r.enclosingProject,enclosingGit:r.enclosingGit,targetState:r.targetState}));return}h({kind:`pending`});let o=new AbortController;return w.current=o,T.current=setTimeout(()=>{Promise.all([i.fs.findEnclosingProjectRoot(s),i.fs.findEnclosingGitRoot(s),i.fs.folderState(t)]).then(n=>{let[r,i,a]=n;o.signal.aborted||(x.current.set(t,{enclosingProject:r,enclosingGit:i,targetState:a}),h(yu({parent:s,sanitizedName:e,enclosingProject:r,enclosingGit:i,targetState:a})))}).catch(e=>{o.signal.aborted||(console.warn(`[CreateProjectDialog] cascade probe failed:`,e),h({kind:`free`}))})},gu),()=>{T.current!==null&&clearTimeout(T.current),o.abort()}},A=[n,a,s,i],t[7]=i,t[8]=a,t[9]=n,t[10]=s,t[11]=k,t[12]=A):(k=t[11],A=t[12]),(0,Q.useEffect)(k,A);let j,M;t[13]!==i||t[14]!==m||t[15]!==n?(j=()=>{if(!n)return;let e=null;m.kind===`block-nested`?e=`nested`:m.kind===`block-nonempty`?e=`nonempty`:m.kind===`confirm-git`&&(e=`git-confirm`),e!==null&&(C.current.has(e)||(C.current.add(e),i.project.recordCreateNewBannerShown(e).catch(Cu)))},M=[n,m,i],t[13]=i,t[14]=m,t[15]=n,t[16]=j,t[17]=M):(j=t[16],M=t[17]),(0,Q.useEffect)(j,M);let N,P;t[18]!==a||t[19]!==s?(N=jn(a),P=N===``||s===``?``:_u(s,N),t[18]=a,t[19]=s,t[20]=N,t[21]=P):(N=t[20],P=t[21]);let F=P,I=F===``?s:F,L=!g&&N!==``&&s!==``&&(m.kind===`free`||m.kind===`confirm-git`),R;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(R=function(e){f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[22]=R):R=t[22];let z=R,B;t[23]===i?B=t[24]:(B=async function(){try{let e=await i.dialog.openFolder();if(e===null)return;c(e)}catch(e){console.warn(`[CreateProjectDialog] dialog.openFolder failed:`,e)}},t[23]=i,t[24]=B);let V=B,H;t[25]!==i||t[26]!==L||t[27]!==d||t[28]!==r||t[29]!==s||t[30]!==N?(H=async function(e){if(e.preventDefault(),L){_(!0),y(null);try{await i.project.createNew({parent:s,name:N,editors:Array.from(d)}),r(!1)}catch(e){y(bu(e)),_(!1)}}},t[25]=i,t[26]=L,t[27]=d,t[28]=r,t[29]=s,t[30]=N,t[31]=H):H=t[31];let U=H,W;t[32]!==g||t[33]!==r?(W=function(e){g||r(e)},t[32]=g,t[33]=r,t[34]=W):W=t[34];let G=W,K;t[35]!==i||t[36]!==r?(K=async function(e){r(!1);try{await i.project.open({path:e,target:`new-window`,entryPoint:`create-new-nested-redirect`})}catch(e){console.warn(`[CreateProjectDialog] project.open failed:`,e)}},t[35]=i,t[36]=r,t[37]=K):K=t[37];let q=K,ee;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Z.jsxs)(qa,{children:[(0,Z.jsx)(Ra,{children:`Create new project`}),(0,Z.jsx)(Ia,{children:`Make a new folder for a brand-new Open Knowledge project.`})]}),t[38]=ee):ee=t[38];let te;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Z.jsx)(oo,{htmlFor:`create-name`,className:`block`,children:`Name`}),t[39]=te):te=t[39];let ne;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(ne=e=>{o(e.target.value),y(null)},t[40]=ne):ne=t[40];let re;t[41]!==g||t[42]!==a?(re=(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[te,(0,Z.jsx)(fo,{id:`create-name`,ref:E,value:a,onChange:ne,disabled:g,placeholder:`My Notes`,autoComplete:`off`,spellCheck:!1,"aria-describedby":`create-target-caption`,"data-testid":`create-name`})]}),t[41]=g,t[42]=a,t[43]=re):re=t[43];let ie;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Z.jsx)(oo,{htmlFor:`create-location`,className:`block`,children:`Location`}),t[44]=ie):ie=t[44];let ae=g||l,oe;t[45]===V?oe=t[46]:(oe=()=>void V(),t[45]=V,t[46]=oe);let se;t[47]!==ae||t[48]!==oe?(se=(0,Z.jsx)(`div`,{className:`flex items-stretch gap-2`,children:(0,Z.jsx)(X,{id:`create-location`,type:`button`,variant:`outline`,disabled:ae,onClick:oe,"data-testid":`create-browse`,children:`Browse`})}),t[47]=ae,t[48]=oe,t[49]=se):se=t[49];let ce;t[50]===I?ce=t[51]:(ce=I===``?(0,Z.jsx)(`span`,{className:`sr-only`,children:`No target path yet`}):I,t[50]=I,t[51]=ce);let le;t[52]===ce?le=t[53]:(le=(0,Z.jsx)(`p`,{id:`create-target-caption`,className:`text-xs text-muted-foreground`,"aria-live":`polite`,"data-testid":`create-target-caption`,children:ce}),t[52]=ce,t[53]=le);let ue;t[54]!==se||t[55]!==le?(ue=(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[ie,se,le]}),t[54]=se,t[55]=le,t[56]=ue):ue=t[56];let de;t[57]!==m||t[58]!==q?(de=(0,Z.jsx)(Eu,{cascade:m,onOpenNested:q}),t[57]=m,t[58]=q,t[59]=de):de=t[59];let fe,pe;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,Z.jsx)(`legend`,{className:`text-sm font-medium`,children:`Connect AI editors`}),pe=(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`All editors are checked by default — uncheck the ones you don't use.`}),t[60]=fe,t[61]=pe):(fe=t[60],pe=t[61]);let me;t[62]!==g||t[63]!==d?(me=cn.map(e=>{let t=`create-editor-${e}`;return(0,Z.jsxs)(oo,{htmlFor:t,className:`text-sm font-normal`,children:[(0,Z.jsx)($a,{id:t,checked:d.has(e),onCheckedChange:()=>z(e),disabled:g,"data-testid":`create-editor-${e}`}),(0,Z.jsx)(`span`,{children:qn[e]})]},e)}),t[62]=g,t[63]=d,t[64]=me):me=t[64];let he;t[65]===me?he=t[66]:(he=(0,Z.jsxs)(`fieldset`,{className:`space-y-2 pb-2`,children:[fe,pe,me]}),t[65]=me,t[66]=he);let ge;t[67]===v?ge=t[68]:(ge=v===null?null:(0,Z.jsx)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,"data-testid":`create-submit-error`,children:xu(v)}),t[67]=v,t[68]=ge);let _e;t[69]!==re||t[70]!==ue||t[71]!==de||t[72]!==he||t[73]!==ge?(_e=(0,Z.jsxs)(Wa,{className:`space-y-4`,children:[re,ue,de,he,ge]}),t[69]=re,t[70]=ue,t[71]=de,t[72]=he,t[73]=ge,t[74]=_e):_e=t[74];let ve;t[75]===r?ve=t[76]:(ve=()=>r(!1),t[75]=r,t[76]=ve);let ye;t[77]!==g||t[78]!==ve?(ye=(0,Z.jsx)(X,{type:`button`,variant:`outline`,className:`font-mono uppercase`,onClick:ve,disabled:g,"data-testid":`create-cancel`,children:`Cancel`}),t[77]=g,t[78]=ve,t[79]=ye):ye=t[79];let be=!L,xe=g?`Creating`:`Create`,Se;t[80]!==be||t[81]!==xe?(Se=(0,Z.jsx)(X,{type:`submit`,disabled:be,"data-testid":`create-submit`,children:xe}),t[80]=be,t[81]=xe,t[82]=Se):Se=t[82];let Ce;t[83]!==ye||t[84]!==Se?(Ce=(0,Z.jsxs)(Ga,{children:[ye,Se]}),t[83]=ye,t[84]=Se,t[85]=Ce):Ce=t[85];let we;t[86]!==U||t[87]!==_e||t[88]!==Ce?(we=(0,Z.jsxs)(Va,{className:`sm:max-w-lg motion-reduce:duration-0 motion-reduce:data-open:animate-none motion-reduce:data-closed:animate-none`,"data-testid":`create-project-dialog`,children:[ee,(0,Z.jsxs)(`form`,{onSubmit:U,"data-testid":`create-project-form`,className:`flex min-h-0 flex-1 flex-col`,children:[_e,Ce]})]}),t[86]=U,t[87]=_e,t[88]=Ce,t[89]=we):we=t[89];let J;return t[90]!==G||t[91]!==n||t[92]!==we?(J=(0,Z.jsx)(Ja,{open:n,onOpenChange:G,children:we}),t[90]=G,t[91]=n,t[92]=we,t[93]=J):J=t[93],J}function Cu(){}function wu(e){console.warn(`[CreateProjectDialog] defaultProjectsRoot probe failed:`,e)}function Tu(){return new Set(cn)}function Eu(e){let t=(0,$.c)(19),{cascade:n,onOpenNested:r}=e;if(n.kind===`idle`||n.kind===`pending`||n.kind===`free`)return null;if(n.kind===`block-nested`){let e;t[0]===n.rootPath?e=t[1]:(e=vu(n.rootPath),t[0]=n.rootPath,t[1]=e);let i=e,a;t[2]===n.rootPath?a=t[3]:(a=(0,Z.jsxs)(`p`,{className:`mb-2`,children:[`Can't nest projects. An Open Knowledge project already exists at`,` `,(0,Z.jsx)(`code`,{className:`font-mono break-all`,children:n.rootPath}),`. Choose a location outside it, or open that project instead.`]}),t[2]=n.rootPath,t[3]=a);let o;t[4]!==n.rootPath||t[5]!==r?(o=()=>r(n.rootPath),t[4]=n.rootPath,t[5]=r,t[6]=o):o=t[6];let s;t[7]!==i||t[8]!==o?(s=(0,Z.jsxs)(X,{type:`button`,variant:`outline`,size:`sm`,onClick:o,"data-testid":`create-banner-nested-open`,children:[`Open `,i]}),t[7]=i,t[8]=o,t[9]=s):s=t[9];let c;return t[10]!==a||t[11]!==s?(c=(0,Z.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,"data-testid":`create-banner-nested`,children:[a,s]}),t[10]=a,t[11]=s,t[12]=c):c=t[12],c}if(n.kind===`confirm-git`){let e;t[13]===n.gitRoot?e=t[14]:(e=(0,Z.jsx)(`code`,{children:n.gitRoot}),t[13]=n.gitRoot,t[14]=e);let r;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(`code`,{children:`.git`}),t[15]=r):r=t[15];let i;return t[16]===e?i=t[17]:(i=(0,Z.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`rounded-md border border-blue-300 bg-blue-50 px-3 py-2 text-sm text-blue-900 dark:border-blue-700 dark:bg-blue-950 dark:text-blue-200`,"data-testid":`create-banner-git-confirm`,children:(0,Z.jsxs)(`p`,{children:[`Open Knowledge will be initialized at `,e,` — the parent of your new folder, because it contains a `,r,` folder (one project per git repo).`]})}),t[16]=e,t[17]=i),i}let i;return t[18]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`div`,{role:`alert`,className:`rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-700 dark:bg-amber-950 dark:text-amber-200`,"data-testid":`create-banner-nonempty`,children:(0,Z.jsx)(`p`,{children:`A non-empty folder with this name already exists. Use "Open folder on disk" instead.`})}),t[18]=i):i=t[18],i}function Du(e){let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`GitHub`}),r=(0,Z.jsx)(`path`,{d:`M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12`}),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 Ou(e){let t=(0,$.c)(5),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`Open Knowledge icon`}),t[0]=n):n=t[0];let r;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsxs)(`g`,{filter:`url(#filter0_d_ok)`,children:[(0,Z.jsx)(`path`,{d:`M66.8902 16.1017C58.2694 3.86669 46.1739 -0.690239 29.9182 2.17749C21.3995 3.67813 13.4602 9.555 8.67934 17.9009C3.93974 26.1701 2.98514 35.6533 6.05714 43.9166C9.31574 52.6868 16.7168 58.4752 24.2299 63.4231C25.7973 64.4562 26.1351 65.7172 26.3551 68.9896C26.5221 71.4625 26.799 75.6011 30.6842 77.7204C31.8176 78.3372 33.0648 78.6515 34.3946 78.6515C37.0796 78.6515 39.4033 77.3649 40.5189 76.7482C47.1049 73.1046 68.8878 59.7147 72.6453 40.4027C74.3444 31.6679 70.9797 21.9019 66.8922 16.1017H66.8902Z`,fill:`white`}),(0,Z.jsx)(`path`,{d:`M37.4214 71.154C28.7888 75.929 36.787 64.0397 27.7458 58.0843C21.6372 54.0616 14.788 49.0568 12.0499 41.6911C6.74463 27.4192 17.5438 10.8473 31.028 8.47262C45.1977 5.97613 54.6946 9.8947 61.6635 19.7844C65.2089 24.8167 67.6013 32.8365 66.3658 39.1828C63.6906 52.9341 49.073 64.7075 37.4214 71.154Z`,fill:`#69A3FF`}),(0,Z.jsx)(`path`,{d:`M52.7244 29.2638C53.4665 28.5217 54.6697 28.5217 55.4119 29.2638V29.2638C56.154 30.0059 56.154 31.2091 55.4119 31.9513L49.2589 38.1042L46.5715 35.4167L52.7244 29.2638Z`,fill:`#D5E5FF`}),(0,Z.jsx)(`path`,{d:`M55.4119 38.8821C56.154 39.6242 56.154 40.8274 55.4119 41.5696V41.5696C54.6698 42.3117 53.4665 42.3117 52.7244 41.5696L46.5715 35.4166L49.259 32.7292L55.4119 38.8821Z`,fill:`#D5E5FF`})]}),t[1]=r):r=t[1];let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`defs`,{children:(0,Z.jsxs)(`filter`,{id:`filter0_d_ok`,x:`-9.53674e-07`,y:`-0.0799994`,width:`77.3817`,height:`85.8743`,filterUnits:`userSpaceOnUse`,colorInterpolationFilters:`sRGB`,children:[(0,Z.jsx)(`feFlood`,{floodOpacity:`0`,result:`BackgroundImageFix`}),(0,Z.jsx)(`feColorMatrix`,{in:`SourceAlpha`,type:`matrix`,values:`0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0`,result:`hardAlpha`}),(0,Z.jsx)(`feOffset`,{dy:`2.85714`}),(0,Z.jsx)(`feGaussianBlur`,{stdDeviation:`2.14286`}),(0,Z.jsx)(`feComposite`,{in2:`hardAlpha`,operator:`out`}),(0,Z.jsx)(`feColorMatrix`,{type:`matrix`,values:`0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0`}),(0,Z.jsx)(`feBlend`,{mode:`normal`,in2:`BackgroundImageFix`,result:`effect1_dropShadow_ok`}),(0,Z.jsx)(`feBlend`,{mode:`normal`,in:`SourceGraphic`,in2:`effect1_dropShadow_ok`,result:`shape`})]})}),t[2]=i):i=t[2];let a;return t[3]===e?a=t[4]:(a=(0,Z.jsxs)(`svg`,{role:`img`,"aria-label":`Open Knowledge icon`,fill:`none`,height:24,width:24,viewBox:`0 0 78 80`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n,r,i]}),t[3]=e,t[4]=a),a}var ku=(0,Q.lazy)(()=>r(()=>import(`./McpConsentDialogBody-CEvkljQ2.js`),__vite__mapDeps([12,1,6,7,13,14,15,8,16]),import.meta.url));function Au(){let e=(0,$.c)(1);if(!(0,Q.useSyncExternalStore)(Qa.subscribe,Mu,ju))return null;let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(ku,{})}),e[0]=t):t=e[0],t}function ju(){return!1}function Mu(){return Qa.getSnapshot()!==null}var Nu=(e,t,n)=>Cc(e,t,n,`NavigatorApp`);function Pu(e){let t=(0,$.c)(74),{bridge:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let[i,a]=(0,Q.useState)(r),[o,s]=(0,Q.useState)(!0),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(!1),v=typeof window<`u`&&window.okDesktop!=null,[y,b]=(0,Q.useState)(`auth`),{channel:x}=bc(),{theme:S}=yr();Ta(n,S??`system`);let C;t[1]===n.project?C=t[2]:(C=()=>{let e=!1;return n.project.listRecent().then(t=>{e||a(t)}).catch(t=>{console.error(`[NavigatorApp] listRecent failed:`,t),e||l(t instanceof Error?t.message:`Failed to load recent projects.`)}).finally(()=>{e||s(!1)}),()=>{e=!0}},t[1]=n.project,t[2]=C);let w;t[3]===n?w=t[4]:(w=[n],t[3]=n,t[4]=w),(0,Q.useEffect)(C,w);let T;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(T=(e,t)=>Nu(e,t,l),t[5]=T):T=t[5];let E=T,D;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(D=()=>d(!0),t[6]=D):D=t[6];let O=D,k;t[7]===n?k=t[8]:(k=()=>E(async()=>{let e=await n.dialog.openFolder();e&&await Lu(n,e,`pick-existing`)},`Failed to open folder.`),t[7]=n,t[8]=k);let A=k,j;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>p(!0),t[9]=j):j=t[9];let M=j,N;t[10]===n?N=t[11]:(N=e=>E(async()=>{await Lu(n,e,`recents`)},`Failed to open project.`),t[10]=n,t[11]=N);let P=N,F;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(Ou,{className:`size-12 shrink-0`}),t[12]=F):F=t[12];let I;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`h1`,{className:`font-medium text-xl tracking-tight`,children:`Open Knowledge`}),(0,Z.jsx)(cu,{})]}),t[13]=I):I=t[13];let L;t[14]===n.appVersion?L=t[15]:(L=(0,Z.jsxs)(`p`,{className:`text-muted-foreground text-xs font-mono`,children:[`v`,n.appVersion]}),t[14]=n.appVersion,t[15]=L);let R;t[16]===x?R=t[17]:(R=x!==null&&(0,Z.jsx)(Ne,{variant:`gray`,className:`text-2xs font-mono`,children:x===`beta`?`Beta`:`Stable`}),t[16]=x,t[17]=R);let z;t[18]!==L||t[19]!==R?(z=(0,Z.jsx)(`div`,{className:`shrink-0 ${v?`[-webkit-app-region:drag]`:``}`,"data-testid":`nav-chrome-row`,children:(0,Z.jsx)(`div`,{className:`mx-auto w-full max-w-5xl px-12 pt-12 pb-10`,children:(0,Z.jsxs)(`header`,{className:`shrink-0 flex-wrap flex items-center gap-2.5`,children:[F,(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[I,(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[L,R]})]})]})})}),t[18]=L,t[19]=R,t[20]=z):z=t[20];let B=`mx-auto flex w-full max-w-5xl flex-1 flex-col overflow-hidden px-12 pb-12 space-y-10 ${!o&&i.length===0?`justify-center`:``}`,V;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsx)(Fu,{title:`Clone from GitHub`,description:`Bring a remote repository onto this machine.`,onClick:O,dataTestId:`nav-clone`,Icon:Du}),t[21]=V):V=t[21];let H;t[22]===A?H=t[23]:(H=(0,Z.jsx)(Fu,{title:`Open folder on disk`,description:`Use a folder you already have.`,onClick:A,dataTestId:`nav-open`,Icon:G}),t[22]=A,t[23]=H);let U;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Z.jsx)(Fu,{title:`Create new project`,description:`Make a new folder for a brand-new project.`,onClick:M,dataTestId:`nav-create-new`,Icon:Fi}),t[24]=U):U=t[24];let W;t[25]===H?W=t[26]:(W=(0,Z.jsxs)(`section`,{className:`grid shrink-0 sm:grid-cols-3 gap-3`,children:[V,H,U]}),t[25]=H,t[26]=W);let K;t[27]===c?K=t[28]:(K=c===null?null:(0,Z.jsxs)(`div`,{className:`mb-3 flex shrink-0 items-start justify-between gap-3 rounded-md border border-red-500/30 bg-red-500/10 px-3 py-2`,"data-testid":`nav-error-banner`,role:`alert`,children:[(0,Z.jsx)(`span`,{className:`text-red-700 text-xs dark:text-red-300`,children:c}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>l(null),className:`text-red-700 text-xs underline hover:no-underline dark:text-red-300`,"data-testid":`nav-error-dismiss`,children:`Dismiss`})]}),t[27]=c,t[28]=K);let q;t[29]!==o||t[30]!==P||t[31]!==i?(q=o?(0,Z.jsx)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,Z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Z.jsx)(Ze,{className:`size-4 animate-spin text-muted-foreground/60`})})}):i.length>0?(0,Z.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,Z.jsx)(`h2`,{className:`mb-2 shrink-0 font-medium text-muted-foreground font-mono text-xs uppercase tracking-wide`,children:`Recent`}),(0,Z.jsx)(`ul`,{className:`min-h-0 flex-1 subtle-scrollbar overflow-y-auto space-y-0.5 -mx-4`,"data-testid":`nav-recent-list`,children:i.map(e=>(0,Z.jsx)(Iu,{project:e,onOpen:()=>P(e.path)},e.path))})]}):null,t[29]=o,t[30]=P,t[31]=i,t[32]=q):q=t[32];let ee;t[33]!==B||t[34]!==W||t[35]!==K||t[36]!==q?(ee=(0,Z.jsxs)(`div`,{className:B,children:[W,K,q]}),t[33]=B,t[34]=W,t[35]=K,t[36]=q,t[37]=ee):ee=t[37];let te,ne;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Z.jsx)(Au,{}),ne=(0,Z.jsx)(pu,{}),t[38]=te,t[39]=ne):(te=t[38],ne=t[39]);let re;t[40]!==n||t[41]!==f?(re=(0,Z.jsx)(Su,{open:f,onOpenChange:p,bridge:n}),t[40]=n,t[41]=f,t[42]=re):re=t[42];let ie;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(ie=e=>{h(e),e||_(!1)},t[43]=ie):ie=t[43];let ae;t[44]===n?ae=t[45]:(ae=Nc(n),t[44]=n,t[45]=ae);let oe=y===`identity`,se;t[46]===g?se=t[47]:(se=()=>{h(!1),g&&(_(!1),d(!0))},t[46]=g,t[47]=se);let ce;t[48]!==m||t[49]!==ae||t[50]!==oe||t[51]!==se?(ce=(0,Z.jsx)(ou,{open:m,onOpenChange:ie,transport:ae,identityPrompt:oe,onSuccess:se}),t[48]=m,t[49]=ae,t[50]=oe,t[51]=se,t[52]=ce):ce=t[52];let le;t[53]===n?le=t[54]:(le=Fc(n),t[53]=n,t[54]=le);let ue;t[55]===n?ue=t[56]:(ue=kc(n),t[55]=n,t[56]=ue);let de;t[57]===n.dialog?de=t[58]:(de=()=>n.dialog.openFolder(),t[57]=n.dialog,t[58]=de);let fe;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(fe=()=>{d(!1),b(`auth`),_(!0),h(!0)},t[59]=fe):fe=t[59];let pe;t[60]===n?pe=t[61]:(pe=e=>{let{dir:t}=e;E(()=>Lu(n,t,`pick-existing`),`Failed to open cloned project.`)},t[60]=n,t[61]=pe);let me;t[62]!==u||t[63]!==le||t[64]!==ue||t[65]!==de||t[66]!==pe?(me=(0,Z.jsx)(du,{open:u,onOpenChange:d,transport:le,authQueryTransport:ue,pickParentFolder:de,onSignIn:fe,onCloneComplete:pe}),t[62]=u,t[63]=le,t[64]=ue,t[65]=de,t[66]=pe,t[67]=me):me=t[67];let he;return t[68]!==z||t[69]!==ee||t[70]!==re||t[71]!==ce||t[72]!==me?(he=(0,Z.jsxs)(`div`,{className:`flex h-screen w-screen flex-col overflow-hidden bg-primary-foreground dark:bg-background text-foreground`,children:[z,ee,te,ne,re,ce,me]}),t[68]=z,t[69]=ee,t[70]=re,t[71]=ce,t[72]=me,t[73]=he):he=t[73],he}function Fu(e){let t=(0,$.c)(14),{title:n,description:r,onClick:i,dataTestId:a,Icon:o}=e,s;t[0]===o?s=t[1]:(s=o?(0,Z.jsx)(o,{className:`size-4 shrink-0 text-muted-foreground`}):null,t[0]=o,t[1]=s);let c;t[2]===n?c=t[3]:(c=(0,Z.jsx)(`span`,{className:`font-medium text-gray-700 dark:text-foreground text-sm`,children:n}),t[2]=n,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===r?u=t[8]:(u=(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs leading-snug`,children:r}),t[7]=r,t[8]=u);let d;return t[9]!==a||t[10]!==i||t[11]!==l||t[12]!==u?(d=(0,Z.jsxs)(`button`,{type:`button`,onClick:i,"data-testid":a,className:`flex flex-col items-start gap-1.5 rounded-lg border border-border bg-card py-3.5 px-4 text-left transition-colors hover:bg-accent`,children:[l,u]}),t[9]=a,t[10]=i,t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function Iu(e){let t=(0,$.c)(17),{project:n,onOpen:r}=e,i=`flex items-center justify-between ${n.missing?`opacity-50`:``}`,a;t[0]===n.name?a=t[1]:(a=(0,Z.jsx)(`span`,{className:`font-medium text-sm text-gray-700 dark:text-foreground`,children:n.name}),t[0]=n.name,t[1]=a);let o;t[2]===n.path?o=t[3]:(o=(0,Z.jsx)(`span`,{className:`truncate w-full text-muted-foreground text-xs`,children:n.path}),t[2]=n.path,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 truncate`,children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===n.missing?c=t[8]:(c=n.missing?(0,Z.jsx)(Ne,{className:`text-2xs rounded-sm`,variant:`warning`,children:`Missing`}):null,t[7]=n.missing,t[8]=c);let l;t[9]!==r||t[10]!==n.missing||t[11]!==s||t[12]!==c?(l=(0,Z.jsxs)(`button`,{type:`button`,onClick:r,disabled:n.missing,className:`flex min-w-0 flex-1 items-center text-left disabled:cursor-not-allowed py-3.5 px-4 hover:bg-accent rounded-lg gap-2 justify-between`,children:[s,c]}),t[9]=r,t[10]=n.missing,t[11]=s,t[12]=c,t[13]=l):l=t[13];let u;return t[14]!==i||t[15]!==l?(u=(0,Z.jsx)(`li`,{className:i,children:l}),t[14]=i,t[15]=l,t[16]=u):u=t[16],u}async function Lu(e,t,n){await e.project.open({path:t,target:`new-window`,entryPoint:n})}var Ru=e=>{let t=(0,$.c)(8),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let{theme:r}=yr(),i=r===void 0?`system`:r,a,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a={success:(0,Z.jsx)(sn,{className:`size-4`}),info:(0,Z.jsx)(le,{className:`size-4`}),warning:(0,Z.jsx)(Dn,{className:`size-4`}),error:(0,Z.jsx)(Ks,{className:`size-4`}),loading:(0,Z.jsx)(Ze,{className:`size-4 animate-spin`})},o={"--normal-bg":`var(--popover)`,"--normal-text":`var(--popover-foreground)`,"--normal-border":`var(--border)`,"--border-radius":`var(--radius)`},t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s={classNames:{toast:`cn-toast`}},t[4]=s):s=t[4];let c;return t[5]!==n||t[6]!==i?(c=(0,Z.jsx)(La,{theme:i,className:`toaster group`,icons:a,style:o,toastOptions:s,...n}),t[5]=n,t[6]=i,t[7]=c):c=t[7],c};function zu(e){let{apiOrigin:t}=e;if(!t)return;let n=Symbol.for(`ok.desktop.fetchRewrite`);if(window.fetch[n])return;let r=window.fetch.bind(window),i=((e,n)=>{if(typeof e==`string`)return r(Bu(e,t),n);if(e instanceof URL)return e.pathname.startsWith(`/api/`)&&(e.origin===window.location.origin||e.protocol===`file:`)?r(t+(e.pathname+e.search+e.hash),n):r(e,n);try{let i=new URL(e.url,window.location.origin);if(i.pathname.startsWith(`/api/`)){let a=i.pathname+i.search+i.hash;return r(new Request(t+a,e),n)}}catch{}return r(e,n)});i[n]=!0,window.fetch=i}function Bu(e,t){return e.startsWith(`/api/`)?t+e:e}function Vu(e){return`#/${encodeURIComponent(e)}`}function Hu(e){let t=e.bridge;if(!t)return;let n=e.setHash??(e=>{window.location.hash=e});return t.onDeepLink(e=>{n(Vu(e.doc))})}var Uu=4e3,Wu=1440*60*1e3;function Gu(e){let t=e.bridge;if(t&&t.onboarding)return t.onboarding.onToast(e=>{if(e.kind===`ancestor-promote`){Xa.success(`Opened existing OK project at ${e.ancestorPath}`,{duration:Uu});return}if(e.kind===`mcp-repaired`){let t=e.editors.map(e=>qn[e]??e).join(`, `);Xa.success(`Repaired ${t} MCP integration. Restart ${t} if already open.`,{duration:Wu});return}if(e.kind===`mcp-repair-failed`){Xa.error(`MCP auto-repair failed — open Settings → AI Tool Integration to fix.`,{duration:Wu});return}let t=mo(e.gitRoot,e.pickedPath)??e.pickedPath;Xa.success(`Initialized OK at ${e.gitRoot} — opened parent of ${t} because it contains a .git folder`,{duration:Uu})})}var Ku=!1;function qu(e,t,n,r){let i=e[t];if(typeof i!=`function`){console.warn(`[cold-mount-instrumentation] target missing method "${t}"`);return}e[t]=function(...e){let t=performance.now(),a,o=!1;try{return a=i.apply(this,e),o=!0,a}finally{let e=performance.now()-t,i;if(o&&r)try{i=r(this,a,t,e)}catch(e){i={"instrumentation-error":e instanceof Error?e.message:String(e)}}try{Ge(n,{durationMs:Math.round(e*1e3)/1e3,threw:!o,...i},{startTime:t,duration:e})}catch{}}}}function Ju(e){return e?.doc?typeof e.doc.nodeSize==`number`?e.doc.nodeSize:e.doc.content&&typeof e.doc.content.size==`number`?e.doc.content.size:null:null}var Yu=0,Xu=0,Zu=0,Qu=0,$u=null,ed=[`linkResolutionDecoration$`],td=new WeakSet,nd=new WeakSet;function rd(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}function id(){return!1}function ad(){return!id()}function od(e,t){if(ad())return t;let n=`ok/cold/nodeview-factory-${rd(e)}`;return function(...r){let i=performance.now();try{return t(...r)}finally{let t=performance.now()-i;Ge(n,{nodeType:e,durationMs:Math.round(t*1e3)/1e3},{startTime:i,duration:t})}}}function sd(e){if(ad())return;let t=e.state.plugins;for(let e of t){if(nd.has(e))continue;let t=e.spec?.key?.key;if(!t||!ed.some(e=>t.startsWith(e)))continue;let n=e.props,r=n.decorations;if(typeof r!=`function`){nd.add(e);continue}let i=`ok/cold/decoration-${rd(t.replace(/\$\d*$/,``))}`;n.decorations=function(...e){let n=performance.now();try{return r.apply(this,e)}finally{let e=performance.now()-n;Ge(i,{pluginKey:t,durationMs:Math.round(e*1e3)/1e3},{startTime:n,duration:e})}},nd.add(e)}}function cd(e){if(ad())return;let t=e._props?.nodeViews;if(!(!t||typeof t!=`object`))for(let[e,n]of Object.entries(t)){if(typeof n!=`function`||n.__okWrapped===!0)continue;let r=od(e,n);r.__okWrapped=!0,t[e]=r}}function ld(e){return ad()?e:e.map(e=>{let t=e.name??`unknown`,n=rd(t);return e.extend({onBeforeCreate(){let e=performance.now();try{this.parent?.()}finally{let r=performance.now()-e;Ge(`ok/cold/ext-${n}-on-before-create`,{ext:t,hook:`onBeforeCreate`,durationMs:Math.round(r*1e3)/1e3},{startTime:e,duration:r})}},onCreate(){let e=performance.now();try{this.parent?.()}finally{let r=performance.now()-e;Ge(`ok/cold/ext-${n}-on-create`,{ext:t,hook:`onCreate`,durationMs:Math.round(r*1e3)/1e3},{startTime:e,duration:r})}},onUpdate(){let e=performance.now();try{this.parent?.()}finally{let r=performance.now()-e;Ge(`ok/cold/ext-${n}-on-update`,{ext:t,hook:`onUpdate`,durationMs:Math.round(r*1e3)/1e3},{startTime:e,duration:r})}},onDestroy(){let e=performance.now();try{this.parent?.()}finally{let r=performance.now()-e;Ge(`ok/cold/ext-${n}-on-destroy`,{ext:t,hook:`onDestroy`,durationMs:Math.round(r*1e3)/1e3},{startTime:e,duration:r})}}})})}function ud(){if(!Ku){Ku=!0,qu(hr.prototype,`mount`,`ok/cold/editor-mount`,(e,t,n,r)=>{let i=e;return ad()||($u=performance.now()),{elementDefault:i.options?.element?.nodeName??null,docSize:Ju(i.editorState),durationMs:r}}),qu(hr.prototype,`createView`,`ok/cold/editor-create-view`,e=>{let t=e;return!ad()&&!td.has(e)&&t.view&&(sd(t.view),cd(t.view),td.add(e)),{docSize:Ju(t.editorState)}}),qu(hr.prototype,`createNodeViews`,`ok/cold/create-node-views`,(e,t,n,r)=>{Qu+=1;let i=e;return!ad()&&i.view&&cd(i.view),{docSize:Ju(i.view),seq:Qu,durationMs:r}}),qu(Tn.prototype,`updateState`,`ok/cold/pm-update-state`,(e,t,n,r)=>(Xu+=1,{seq:Xu,docSize:Ju(e.state),durationMs:r})),qu(Tn.prototype,`setProps`,`ok/cold/pm-set-props`,(e,t,n,r)=>(Zu+=1,{seq:Zu,docSize:Ju(e.state),durationMs:r})),qu(x.prototype,`_forceRerender`,`ok/cold/force-rerender`,(e,t,n,r)=>{Yu+=1;let i=e,a=(()=>{try{return i.type?.toArray?i.type.toArray().length:null}catch{return null}})();return{seq:Yu,topLevelYElements:a,durationMs:r}}),qu(H.prototype,`init`,`ok/cold/ec-init`,e=>({editorPresent:!!e.props?.editor}));try{typeof PerformanceObserver<`u`&&new PerformanceObserver(e=>{for(let t of e.getEntries()){let e=t.name;if((e===`first-paint`||e===`first-contentful-paint`)&&(Ge(e===`first-paint`?`ok/cold/paint-fp`:`ok/cold/paint-fcp`,{entryType:t.entryType,startTime:Math.round(t.startTime*1e3)/1e3},{startTime:t.startTime,duration:0}),!ad()&&e===`first-paint`&&$u!==null)){let e=$u,n=Math.max(0,t.startTime-e);Ge(`ok/cold/append-to-paint`,{paintEntryType:t.entryType,durationMs:Math.round(n*1e3)/1e3,paintAt:Math.round(t.startTime*1e3)/1e3},{startTime:e,duration:n}),$u=null}}}).observe({type:`paint`,buffered:!0})}catch{}globalThis.__okColdMountInstrumented=!0}}var dd=`Relaunch`,fd=`Release notes`,pd=`Updates paused`,md=`Download`,hd=`Reset to defaults`,gd=`Relaunch failed — please restart manually`,_d=`Recovery action failed — please try again`;function vd(e,t){let n=t instanceof Error&&t.message?t.message:``;return n?`${e}: ${n}`:e}function yd(e){return`Version ${e} ready to install`}function bd(e){return`Updated to Version ${e}`}function xd(e){return`Your settings and recent projects were saved by a newer build than this one (v${e}). Reset to defaults to continue.`}var Sd=0,Cd=0,wd=1,Td=2,Ed=3;function Dd(e,t,n=()=>{}){let r=[];return r.push(e.onUpdateDownloaded(({version:r})=>{let i=`update-downloaded-${r}`;t({id:i,body:yd(r),priority:Td,action:{label:dd,onClick:()=>{e.update.relaunchNow().then(()=>{n(i)},e=>{t({id:`relaunch-error-${r}`,body:vd(gd,e),variant:`error`,priority:wd})})}}})})),r.push(e.onWhatsNew(({version:n,releaseUrl:r})=>{t({id:`whats-new-${n}`,body:bd(n),priority:Ed,action:{label:fd,onClick:()=>{e.shell.openExternal(r)}}})})),r.push(e.onUpdateStuckHint(({downloadUrl:n})=>{t({id:`update-stuck-hint`,body:pd,priority:Cd,action:{label:md,onClick:()=>{e.shell.openExternal(n)}}})})),()=>{for(let e of r)e()}}function Od(e,t,n,r=()=>{}){let i=`schema-incompatibility-${t.persistedSchemaVersion}`,a=`schema-incompatibility-error-${t.persistedSchemaVersion}`,o=e=>{r(i),n({id:a,body:vd(_d,e),variant:`error`,priority:Sd})};n({id:i,body:xd(t.currentBuild),priority:Sd,action:{label:hd,onClick:()=>{e.state.resetIncompatible().then(()=>{r(i)},o)}}})}var kd=[],Ad=new Set,jd=!1;function Md(){for(let e of Ad)e()}function Nd(e){let t=kd.findIndex(t=>t.id===e.id);if(t===-1)kd=[...kd,e];else{let n=kd.slice();n[t]=e,kd=n}Md()}function Pd(e){let t=kd.filter(t=>t.id!==e);t.length!==kd.length&&(kd=t,Md())}function Fd(){return kd}function Id(e){return Ad.add(e),()=>{Ad.delete(e)}}function Ld(){if(jd||typeof window>`u`)return;let e=window.okDesktop;e&&(jd=!0,Dd(e,Nd,Pd),e.state.query().then(t=>{t.schemaIncompatibility&&Od(e,t.schemaIncompatibility,Nd,Pd)},e=>{console.warn(`[update-notices-store] bridge.state.query() failed`,e)}))}var Rd=`ok-omnibar-recents-v1`,zd=10;function Bd(e){return typeof e==`object`&&!!e&&(e.kind===`file`||e.kind===`folder`)&&typeof e.path==`string`&&typeof e.lastOpenedAt==`string`}function Vd(e){if(e)return e;if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function Hd(e,t){return`${e}:${t}`}function Ud(e){let t=Vd(e);if(!t)return[];try{let e=t.getItem(Rd);if(!e)return[];let n=JSON.parse(e);return Array.isArray(n)?n.filter(Bd).slice(0,zd):[]}catch{return[]}}function Wd(e,t){let n=Vd(t);if(n)try{n.setItem(Rd,JSON.stringify(e.slice(0,zd)))}catch(e){console.warn(`[omnibar] Failed to save recent entries:`,e)}}function Gd(e,t){return[t,...e.filter(e=>e.kind!==t.kind||e.path!==t.path)].slice(0,zd)}function Kd(e,t){return e.filter(e=>t.has(Hd(e.kind,e.path)))}var qd=50,Jd=30,Yd=``,Xd=null;function Zd(e){return e.trim().toLowerCase()}function Qd(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function $d(e){let t=e.trim();return t?[...new Set(t.split(/\s+/).filter(Boolean))].sort((e,t)=>t.length-e.length):[]}function ef(e,t,n=new Map,r=new Map){let i=[];for(let t of e){let e=r.get(t)?.modified,a=n.get(t);i.push({kind:`file`,path:t,name:pr(t),...a?{title:a}:{},...e?{modifiedTs:Date.parse(e)}:{}})}for(let e of t)i.push({kind:`folder`,path:e,name:pr(e)});return i.sort((e,t)=>{let n=e.path.localeCompare(t.path);return n===0?e.kind===t.kind?0:e.kind===`folder`?-1:1:n}),i}function tf(e){return cr({kind:e.kind===`file`?`page`:`folder`,path:e.path,title:e.title??e.name,modifiedTs:e.modifiedTs??0})}function nf(e){return{entries:e,byId:new Map(e.map(e=>[`${e.kind===`file`?`page`:`folder`}:${e.path}`,e])),corpus:Un(e.map(tf))}}function rf(e){return e.map(e=>`${e.kind}\u0000${e.path}\u0000${e.title??``}\u0000${e.modifiedTs??0}`).join(``)}function af(e){let t=rf(e);return Xd&&Yd===t?Xd:(Yd=t,Xd=nf(e),Xd)}function of(e,t,n=qd){return sf(af(e),t,n)}function sf(e,t,n=qd){let r=Zd(t);return r?kn(e.corpus,r,{intent:`omnibar`,limit:n,scopes:[`page`,`folder`]}).map(t=>e.byId.get(t.document.id)).filter(e=>e!==void 0):e.entries.slice(0,20)}function cf(e,t){let n=$d(t);if(n.length===0||e.length===0)return[{text:e,match:!1,start:0}];let r=RegExp(`(${n.map(Qd).join(`|`)})`,`gi`),i=[],a=0;for(let t of e.matchAll(r)){let n=t.index??0;n>a&&i.push({text:e.slice(a,n),match:!1,start:a}),i.push({text:t[0],match:!0,start:n}),a=n+t[0].length}return a<e.length&&i.push({text:e.slice(a),match:!1,start:a}),i.length>0?i:[{text:e,match:!1,start:0}]}function lf(e){if(e.kind!==`page`&&e.kind!==`folder`||typeof e.path!=`string`)return null;let t=pr(e.path);return{kind:e.kind===`page`?`file`:`folder`,path:e.path,name:t,...e.title&&{title:e.title},...e.snippet&&{snippet:e.snippet},...typeof e.score==`number`&&{score:e.score}}}async function uf(e,t={}){let n=e.trim();if(!n)return[];let r=await fetch(`/api/search`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({query:n,intent:`full_text`,scopes:[`page`,`folder`,`content`],limit:t.limit??Jd}),signal:t.signal});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(Bn(e)??`Search failed with status ${r.status}`)}return((await r.json()).results??[]).map(lf).filter(e=>!!e)}function df(e,t,n=[]){let r=Zd(t);return r?Zd([e,...n].join(` `)).includes(r):!0}var ff=`tag:`;function pf(e,t){if(!e.toLowerCase().startsWith(`tag:`))return{kind:`normal`,query:e};let n=e.slice(4).replace(/^\s+/,``).trim();return n&&t.has(n)?{kind:`tag-docs`,tagName:n}:{kind:`tag-list`,query:n}}function mf(e,t){return B(e,t)}var hf=F;async function gf(e){let t=await fetch(`/api/tags/${encodeURIComponent(e)}`);if(!t.ok)throw Error(`/api/tags/${e} responded with ${t.status}`);let n=await t.json();return Array.isArray(n.docs)?n.docs:[]}var _f=`open-knowledge:doc-panel-tab`,vf=null;function yf(){let e=vf;return vf=null,e}function bf(e,t=typeof window>`u`?new EventTarget:window){vf=e,t.dispatchEvent(new CustomEvent(_f,{detail:{tab:e}}))}function xf(e,t=typeof window>`u`?new EventTarget:window){let n=t=>{let n=t instanceof CustomEvent?t.detail?.tab:void 0;n&&e(n)};return t.addEventListener(_f,n),()=>t.removeEventListener(_f,n)}function Sf(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=Y(`grid w-full gap-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Xl,{"data-slot":`radio-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Cf(e){let t=(0,$.c)(9),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=Y(`group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border border-input outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary`,n),t[3]=n,t[4]=i);let a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Ql,{"data-slot":`radio-group-indicator`,className:`flex size-4 items-center justify-center`,children:(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary-foreground`})}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,Z.jsx)(Zl,{"data-slot":`radio-group-item`,className:i,...r,children:a}),t[6]=r,t[7]=i,t[8]=o):o=t[8],o}var wf=[`.md`,`.mdx`];function Tf(e){let t=e.toLowerCase();for(let e of wf)if(t.endsWith(e))return e;return null}function Ef(e){let t=Tf(e);return t?e.slice(0,-t.length):e}var Df=`__blank__`,Of={local:0,inherited:1,user:2};function kf(e){return[...e].sort((e,t)=>{let n=Of[e.scope]-Of[t.scope];if(n!==0)return n;let r=(e.title??e.name).toLowerCase(),i=(t.title??t.name).toLowerCase();return r.localeCompare(i)})}function Af(e){return e.trim()?e.includes(`..`)?`Path cannot contain ".."`:e.startsWith(`/`)?`Path cannot start with "/"`:e.includes(`\\`)?`Path cannot contain backslashes`:e.includes(`\0`)?`Path cannot contain null bytes`:null:`Name cannot be empty`}function jf(e){let t=e.fileName.trim(),n=Tf(t)?t:`${t}${e.fileExtension??`.md`}`;if(e.kind===`folder`){let t=(e.folderName??``).trim();return`${e.initialDir?`${e.initialDir}/${t}`:t}/${n}`}return e.initialDir?`${e.initialDir}/${n}`:n}function Mf(e){let t=e.target;return t?.tagName===`INPUT`||t?.tagName===`TEXTAREA`||t?.isContentEditable?!1:!!((e.metaKey||e.ctrlKey)&&e.altKey&&e.key.toLowerCase()===`n`)}function Nf(e){let t=e.value.lastIndexOf(`.`);t>0?e.setSelectionRange(0,t):e.select()}function Pf(e){let t=(0,$.c)(115),{open:n,onOpenChange:r,kind:i,initialDir:a,suggestedName:o,initialTemplate:s,description:c,onCreated:l,folderConfig:u}=e,{addPage:d}=wr(),f=ra(u?null:a),p=u??f,[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(`.md`),[b,x]=(0,Q.useState)(Df),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(null),O=(0,Q.useId)(),k=(0,Q.useId)(),A=(0,Q.useId)(),j=(0,Q.useId)(),M=(0,Q.useRef)(null),N=(0,Q.useRef)(null),P,F;t[0]!==s||t[1]!==i||t[2]!==n||t[3]!==o?(P=()=>{if(n){C(null),D(null),T(!1),_(``),x(i===`file`&&s?s:Df);let e=i===`file`?o??`untitled`:`index`,t=Tf(e);y(t??`.md`),h(t?Ef(e):e)}},F=[n,i,o,s],t[0]=s,t[1]=i,t[2]=n,t[3]=o,t[4]=P,t[5]=F):(P=t[4],F=t[5]),(0,Q.useEffect)(P,F);let I=p.state.status===`ready`?kf(p.state.data.folder.templates_available??[]):[],L;t[6]!==p.state.data||t[7]!==p.state.status||t[8]!==n||t[9]!==b?(L=()=>{n&&b!==Df&&p.state.status===`ready`&&((p.state.data.folder.templates_available??[]).some(e=>e.name===b)||x(Df))},t[6]=p.state.data,t[7]=p.state.status,t[8]=n,t[9]=b,t[10]=L):L=t[10];let R;t[11]!==p.state||t[12]!==n||t[13]!==b?(R=[n,b,p.state],t[11]=p.state,t[12]=n,t[13]=b,t[14]=R):R=t[14],(0,Q.useEffect)(L,R);let z=i===`file`,B=p.state.status===`loading`||p.state.status===`idle`,V=p.state.status===`error`?p.state.message:null,H;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(H=function(e){let t=Tf(e);t?(y(t),h(Ef(e))):h(e),C(null)},t[15]=H):H=t[15];let U=H,W;t[16]!==v||t[17]!==m||t[18]!==g||t[19]!==a||t[20]!==i?(W=function(){return jf({kind:i,initialDir:a,fileName:m,fileExtension:v,folderName:g})},t[16]=v,t[17]=m,t[18]=g,t[19]=a,t[20]=i,t[21]=W):W=t[21];let G=W,K;t[22]!==m||t[23]!==g||t[24]!==i?(K=function(){if(i===`folder`){let e=Af(g.trim());if(e)return{message:`Folder name: ${e}`,field:`folder`}}let e=Af(m.trim());return e?{message:e,field:`file`}:null},t[22]=m,t[23]=g,t[24]=i,t[25]=K):K=t[25];let q=K,ee;t[26]!==w||t[27]!==m||t[28]!==g||t[29]!==i?(ee=w||!m.trim()||i===`folder`&&!g.trim(),t[26]=w,t[27]=m,t[28]=g,t[29]=i,t[30]=ee):ee=t[30];let te=ee,ne;t[31]!==d||t[32]!==G||t[33]!==q||t[34]!==i||t[35]!==l||t[36]!==r||t[37]!==b?(ne=async function(){let e=q();if(e){C(e.message),D(e.field);return}T(!0),C(null),D(null);let t=G(),n=i===`file`&&b!==Df?b:void 0,a={path:t};n!==void 0&&(a.template=n);try{let e=await fetch(`/api/create-page`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(a)}),t=await Le(e,`Server error (HTTP ${e.status})`);if(!t.ok){T(!1),C(t.title),D(`form`);return}let n=Er.safeParse(t.body);if(T(!1),!n.success){C(`Failed to create ${i}`),D(`form`);return}let o=n.data.docName;r(!1),window.location.hash=`#/${o}`,d(o),Kn([`files`,`backlinks`,`graph`]),l?.(o)}catch(e){console.warn(`[NewItemDialog] create failed:`,e),T(!1),C(`Network error — please try again`),D(`form`)}},t[31]=d,t[32]=G,t[33]=q,t[34]=i,t[35]=l,t[36]=r,t[37]=b,t[38]=ne):ne=t[38];let re=ne,ie=a||`(root)`,ae=i===`file`?`New file`:`New folder`,oe=Ja,se=Va,ce;t[39]===ae?ce=t[40]:(ce=(0,Z.jsx)(Ra,{children:ae}),t[39]=ae,t[40]=ce);let le;t[41]!==c||t[42]!==ie?(le=c??(0,Z.jsxs)(Z.Fragment,{children:[`Create in `,(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:ie})]}),t[41]=c,t[42]=ie,t[43]=le):le=t[43];let ue;t[44]===le?ue=t[45]:(ue=(0,Z.jsx)(Ia,{children:le}),t[44]=le,t[45]=ue);let de;t[46]!==ce||t[47]!==ue?(de=(0,Z.jsxs)(qa,{children:[ce,ue]}),t[46]=ce,t[47]=ue,t[48]=de):de=t[48];let fe=Wa,pe=z&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{id:j,className:`mb-1.5 text-sm font-medium`,children:`Start from`}),B?(0,Z.jsx)(`div`,{className:`rounded-md border border-border bg-muted/30 px-3 py-2 text-xs text-muted-foreground`,children:`Loading templates`}):(0,Z.jsxs)(Z.Fragment,{children:[V?(0,Z.jsxs)(`p`,{role:`alert`,className:`mb-1.5 text-xs text-destructive`,children:[`Could not load templates: `,V,`. You can still create a blank note.`]}):null,(0,Z.jsxs)(Sf,{value:b,onValueChange:x,"aria-labelledby":j,className:`max-h-56 overflow-y-auto rounded-md border border-border bg-card subtle-scrollbar`,children:[(0,Z.jsx)(Rf,{value:Df,title:`Blank note`,description:`Empty starting content`}),I.length===0&&!V?(0,Z.jsx)(`p`,{className:`px-3 pb-2 text-xs text-muted-foreground`,children:`No templates resolve here. Add one in this folder's Templates section, or in Settings → User templates.`}):I.map(Lf)]})]})]}),me;t[49]!==S||t[50]!==E||t[51]!==O||t[52]!==k||t[53]!==g||t[54]!==i?(me=i===`folder`&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:k,children:`Folder name`}),(0,Z.jsx)(fo,{ref:N,id:k,value:g,onChange:e=>{_(e.target.value),C(null)},placeholder:`folder-name`,autoFocus:!0,"aria-describedby":S&&(E===`folder`||E===`form`)?O:void 0,"aria-invalid":S&&(E===`folder`||E===`form`)?!0:void 0,onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault();let t=Af(g.trim());if(t){C(`Folder name: ${t}`),D(`folder`);return}M.current?.focus()}}})]}),t[49]=S,t[50]=E,t[51]=O,t[52]=k,t[53]=g,t[54]=i,t[55]=me):me=t[55];let he=i===`folder`?`First file name`:`File name`,ge;t[56]!==A||t[57]!==he?(ge=(0,Z.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:A,children:he}),t[56]=A,t[57]=he,t[58]=ge):ge=t[58];let _e;t[59]===U?_e=t[60]:(_e=e=>U(e.target.value),t[59]=U,t[60]=_e);let ve=i===`file`,ye=S&&(E===`file`||E===`form`)?O:void 0,be=S&&(E===`file`||E===`form`)?!0:void 0,xe;t[61]!==re||t[62]!==te?(xe=e=>{e.key===`Enter`&&!te&&re()},t[61]=re,t[62]=te,t[63]=xe):xe=t[63];let Se;t[64]!==A||t[65]!==m||t[66]!==_e||t[67]!==ve||t[68]!==ye||t[69]!==be||t[70]!==xe?(Se=(0,Z.jsx)(fo,{ref:M,id:A,value:m,onChange:_e,placeholder:`my-note`,autoFocus:ve,"aria-describedby":ye,"aria-invalid":be,onFocus:If,onKeyDown:xe,className:`flex-1`}),t[64]=A,t[65]=m,t[66]=_e,t[67]=ve,t[68]=ye,t[69]=be,t[70]=xe,t[71]=Se):Se=t[71];let Ce;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=e=>{(e===`.md`||e===`.mdx`)&&y(e)},t[72]=Ce):Ce=t[72];let we;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(we=wf.map(Ff),t[73]=we):we=t[73];let J;t[74]===v?J=t[75]:(J=(0,Z.jsx)(ao,{type:`single`,value:v,onValueChange:Ce,variant:`outline`,size:`sm`,"aria-label":`File extension`,className:`shrink-0`,children:we}),t[74]=v,t[75]=J);let Te;t[76]!==Se||t[77]!==J?(Te=(0,Z.jsxs)(`div`,{className:`flex items-stretch gap-2`,children:[Se,J]}),t[76]=Se,t[77]=J,t[78]=Te):Te=t[78];let Ee;t[79]!==S||t[80]!==O?(Ee=S&&(0,Z.jsx)(`p`,{id:O,role:`alert`,className:`text-xs text-red-600 dark:text-red-400`,children:S}),t[79]=S,t[80]=O,t[81]=Ee):Ee=t[81];let De;t[82]!==ge||t[83]!==Te||t[84]!==Ee?(De=(0,Z.jsxs)(`div`,{children:[ge,Te,Ee]}),t[82]=ge,t[83]=Te,t[84]=Ee,t[85]=De):De=t[85];let Oe;t[86]!==pe||t[87]!==me||t[88]!==De?(Oe=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[pe,me,De]}),t[86]=pe,t[87]=me,t[88]=De,t[89]=Oe):Oe=t[89];let ke;t[90]!==fe||t[91]!==Oe?(ke=(0,Z.jsx)(fe,{children:Oe}),t[90]=fe,t[91]=Oe,t[92]=ke):ke=t[92];let Ae;t[93]===r?Ae=t[94]:(Ae=()=>r(!1),t[93]=r,t[94]=Ae);let je;t[95]!==w||t[96]!==Ae?(je=(0,Z.jsx)(X,{variant:`outline`,className:`font-mono uppercase`,onClick:Ae,disabled:w,children:`Cancel`}),t[95]=w,t[96]=Ae,t[97]=je):je=t[97];let Me=w?`Creating`:`Create`,Ne;t[98]!==re||t[99]!==te||t[100]!==Me?(Ne=(0,Z.jsx)(X,{onClick:re,disabled:te,children:Me}),t[98]=re,t[99]=te,t[100]=Me,t[101]=Ne):Ne=t[101];let Pe;t[102]!==je||t[103]!==Ne?(Pe=(0,Z.jsxs)(Ga,{children:[je,Ne]}),t[102]=je,t[103]=Ne,t[104]=Pe):Pe=t[104];let Fe;t[105]!==se||t[106]!==de||t[107]!==ke||t[108]!==Pe?(Fe=(0,Z.jsxs)(se,{className:`sm:max-w-md`,"data-ok-layer-spawned":``,children:[de,ke,Pe]}),t[105]=se,t[106]=de,t[107]=ke,t[108]=Pe,t[109]=Fe):Fe=t[109];let Ie;return t[110]!==oe||t[111]!==r||t[112]!==n||t[113]!==Fe?(Ie=(0,Z.jsx)(oe,{open:n,onOpenChange:r,children:Fe}),t[110]=oe,t[111]=r,t[112]=n,t[113]=Fe,t[114]=Ie):Ie=t[114],Ie}function Ff(e){return(0,Z.jsx)(ro,{value:e,"aria-label":`Use ${e} extension`,children:e},e)}function If(e){return Nf(e.currentTarget)}function Lf(e){return(0,Z.jsx)(Rf,{value:e.name,title:e.title??e.name,subName:e.title&&e.title!==e.name?e.name:void 0,description:e.description,scope:e.scope,sourceFolder:e.source_folder},`${e.scope}:${e.source_folder}:${e.name}`)}function Rf(e){let t=(0,$.c)(26),{value:n,title:r,subName:i,description:a,scope:o,sourceFolder:s}=e,c=(0,Q.useId)(),l;t[0]!==c||t[1]!==n?(l=(0,Z.jsx)(Cf,{id:c,value:n,className:`mt-1`}),t[0]=c,t[1]=n,t[2]=l):l=t[2];let u;t[3]===r?u=t[4]:(u=(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium`,children:r}),t[3]=r,t[4]=u);let d;t[5]===i?d=t[6]:(d=i?(0,Z.jsx)(`code`,{className:`font-mono text-2xs text-muted-foreground shrink-0`,children:i}):null,t[5]=i,t[6]=d);let f;t[7]!==o||t[8]!==s?(f=o===`inherited`&&s?(0,Z.jsx)(Ne,{variant:`gray`,className:`ml-auto shrink-0 text-2xs`,children:s||`root`}):null,t[7]=o,t[8]=s,t[9]=f):f=t[9];let p;t[10]===o?p=t[11]:(p=o===`user`?(0,Z.jsx)(Ne,{variant:`primary`,className:`ml-auto shrink-0 text-2xs`,children:`user`}):null,t[10]=o,t[11]=p);let m;t[12]!==u||t[13]!==d||t[14]!==f||t[15]!==p?(m=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[u,d,f,p]}),t[12]=u,t[13]=d,t[14]=f,t[15]=p,t[16]=m):m=t[16];let h;t[17]===a?h=t[18]:(h=a?(0,Z.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:a}):null,t[17]=a,t[18]=h);let g;t[19]!==m||t[20]!==h?(g=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[m,h]}),t[19]=m,t[20]=h,t[21]=g):g=t[21];let _;return t[22]!==c||t[23]!==l||t[24]!==g?(_=(0,Z.jsxs)(`label`,{htmlFor:c,className:`flex cursor-pointer items-start gap-3 px-3 py-2 transition-colors hover:bg-muted/50 has-data-[state=checked]:bg-muted/70`,children:[l,g]}),t[22]=c,t[23]=l,t[24]=g,t[25]=_):_=t[25],_}var zf=[{id:`claude-cowork`,displayName:`Claude Cowork`,appBrandName:`Claude Desktop`,schemes:[`claude:`],installUrl:`https://claude.com/download`,hasWebFallback:!0,tagline:`Conversational pairing in Claude Desktop's Cowork tab.`},{id:`claude-code`,displayName:`Claude Code`,appBrandName:`Claude Desktop`,schemes:[`claude:`],installUrl:`https://claude.com/download`,hasWebFallback:!0,tagline:`Agentic coding in Claude Desktop's Code tab.`},{id:`codex`,displayName:`Codex`,appBrandName:`Codex Desktop`,schemes:[`codex:`],installUrl:`https://openai.com/codex`,tagline:`OpenAI's coding agent, terminal-native.`},{id:`cursor`,displayName:`Cursor`,schemes:[`cursor:`],installUrl:`https://cursor.com/`,tagline:`AI-first VS Code fork with multi-file edits.`}],Bf=`#settings`;function Vf(e){let t=e.target;return t?.tagName===`INPUT`||t?.tagName===`TEXTAREA`||t?.isContentEditable?!1:!!((e.metaKey||e.ctrlKey)&&!e.altKey&&e.key===`,`)}function Hf(e){return e.replace(/^#/,``)===`settings`}function Uf(){return typeof window>`u`?``:window.location.hash}function Wf(){let e=(0,$.c)(4),[t,n]=(0,Q.useState)(Kf),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=()=>{n(Hf(Uf()))};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Q.useEffect)(r,i);let a=Gf,o;return e[2]===t?o=e[3]:(o={open:t,close:a},e[2]=t,e[3]=o),o}function Gf(){typeof window>`u`||Hf(Uf())&&window.history.back()}function Kf(){return Hf(Uf())}function qf(){let e=(0,$.c)(3),[t,n]=(0,Q.useState)(Xf),r,i;return e[0]===t?(r=e[1],i=e[2]):(r=()=>{if(t!==null||typeof window>`u`||window.okDesktop)return;let e=!0;return fetch(`/api/workspace`).then(async t=>{let r=await t.json().catch(Yf);if(!e||!t.ok)return;let i=On.safeParse(r);i.success&&n({contentDir:i.data.contentDir,pathSeparator:i.data.pathSeparator})}).catch(Jf),()=>{e=!1}},i=[t],e[0]=t,e[1]=r,e[2]=i),(0,Q.useEffect)(r,i),t}function Jf(e){console.warn(`[useWorkspace] /api/workspace fetch failed:`,e)}function Yf(){return null}function Xf(){return Zf()}function Zf(e=typeof window>`u`?void 0:window){if(!e)return null;let t=e.okDesktop;return t?{contentDir:t.config.projectPath,pathSeparator:t.platform===`win32`?`\\`:`/`}:null}function Qf(e){return{async install(t){let n;try{n=await e.buildAndOpen(t?.force?{force:!0}:void 0)}catch(e){return{ok:!1,reason:`bridge-error`,message:e instanceof Error?e.message:String(e)}}return n.ok?{ok:!0,path:n.path}:{ok:!1,reason:n.reason,message:n.message}}}}function $f(e={}){let t=e.fetch??globalThis.fetch,n=`${e.apiOrigin??``}/api/install-skill`;return{async install(e){let r;try{r=await t(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?.force?{force:!0}:{})})}catch(e){return{ok:!1,reason:`network-error`,message:e instanceof Error?e.message:String(e)}}if(!r.ok){let e=`HTTP ${r.status}`;try{let t=Bn(await r.json());t&&(e=t)}catch{}return{ok:!1,reason:`http-error`,message:e}}let i;try{i=await r.json()}catch(e){return{ok:!1,reason:`parse-error`,message:e instanceof Error?e.message:`Invalid server response`}}return!i||typeof i.status!=`string`?{ok:!1,reason:`parse-error`,message:`Invalid server response shape`}:i.status===`failed`?{ok:!1,reason:`build-failed`,message:i.buildError??`unknown build failure`}:{ok:!0,path:i.outputPath,handoffWarning:i.handoffError?.message}}}}function ep(){if(typeof window>`u`)return null;let e=window.okDesktop?.skill;return e?Qf(e):$f()}var tp=`ok:skill:cowork:installed`,np=`1`,rp=250,ip=`/api/skill/install-state`;function ap(e){return`${tp}:v${e}`}var op=new Map;async function sp(e={},t={}){let n=t.force?`__force__`:`__default__`,r=op.get(n);if(r)return r;let i=cp(e,t);return op.set(n,i),i.finally(()=>{op.get(n)===i&&op.delete(n)}),i}async function cp(e,t){let n=e.installer===void 0?ep():e.installer,r=lp(e.storage),i=e.fetchSnapshot??dp,a=e.serverTimeoutMs??rp,o=null;if(!t.force){try{o=await fp(i(),a)}catch(e){console.warn(`[cowork-skill] server install-state check failed; falling through:`,e)}if(o){let e=o.targets[`claude-cowork`]??null;if(e&&e.version===o.currentVersion)return{kind:`already-installed`,source:`server`}}}let s=ap(o?.currentVersion??e.fallbackSkillVersion??up());if(!t.force&&r?.getItem(s)===np)return{kind:`already-installed`,source:`local`};if(!n)return{kind:`host-unsupported`};let c=await n.install({force:t.force??!1});if(!c.ok)return{kind:`install-failed`,reason:c.reason,message:c.message};try{r?.setItem(s,np)}catch(e){console.warn(`[cowork-skill] storage.setItem failed (guard will not persist):`,e)}return{kind:`installed-now`,path:c.path,handoffWarning:c.handoffWarning}}function lp(e){if(e!==void 0)return e;if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function up(){return typeof window>`u`?`unknown`:window.okDesktop?.appVersion??`unknown`}async function dp(){let e;try{e=await fetch(ip,{method:`GET`,cache:`no-store`})}catch{return null}if(!e.ok)return null;try{let t=await e.json();return typeof t?.currentVersion==`string`?t:null}catch{return null}}async function fp(e,t){return Promise.race([e,new Promise(e=>{setTimeout(()=>e(null),t)})])}function pp(e){return sp({},e)}function mp(){return sp({},{force:!0})}async function hp(e,t){let n;try{n=await t(`/api/handoff`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})}catch(e){return{ok:!1,reason:`dispatch-error`,detail:e instanceof Error?e.message:String(e)}}return n.status===200?{ok:!0}:n.status===404?{ok:!1,reason:`not-installed`,detail:`POST /api/handoff returned 404`}:n.status===422?{ok:!1,reason:`not-installed`,detail:`POST /api/handoff returned ${n.status}`}:{ok:!1,reason:`dispatch-error`,detail:`POST /api/handoff returned ${n.status}`}}async function gp(e,t={}){let n=t.fetch??globalThis.fetch.bind(globalThis);switch(e.target){case`claude-cowork`:return hp({target:`claude-cowork`,url:An({mode:`cowork`},e)},n);case`claude-code`:return hp({target:`claude-code`,url:An({mode:`code`},e)},n);case`codex`:return hp({target:`codex`,url:Pn(e)},n);case`cursor`:return hp({target:`cursor`,url:Cn(e),workspacePath:e.projectDir},n);default:{let t=e.target;return{ok:!1,reason:`invalid-payload`,detail:`unknown target: ${String(t)}`}}}}async function _p(e,t={}){let n=t.okDesktop??(typeof window<`u`?window.okDesktop:void 0);if(n?.shell?.openExternal)try{return await n.shell.openExternal(e),{ok:!0}}catch(e){return{ok:!1,reason:`dispatch-error`,detail:vp(e)}}let r=t.doc??(typeof document<`u`?document:void 0);if(!r)return{ok:!1,reason:`dispatch-error`,detail:`no DOM available`};try{let t=r.createElement(`a`);return t.href=e,t.rel=`noopener noreferrer`,/^https?:/i.test(e)&&(t.target=`_blank`),r.body.appendChild(t),t.click(),t.remove(),{ok:!0}}catch(e){return{ok:!1,reason:`dispatch-error`,detail:vp(e)}}}function vp(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}async function yp(e,t={}){let n=t.okDesktop??(typeof window<`u`?window.okDesktop:void 0);if(n?.shell?.recordHandoff)try{await n.shell.recordHandoff(e)}catch(e){(t.warn??(e=>console.warn(e)))(`[handoff] recordHandoff IPC rejected (telemetry skipped): ${e instanceof Error?e.message:String(e)}`)}}function bp(e,t,n){let r=n===`\\`?t.replaceAll(`/`,`\\`):t;return`${e.endsWith(n)?e.slice(0,-1):e}${n}${r}`}function xp(e){return`${e}.md`}function Sp(e){if(!e.docName||!e.workspace)return null;let t=xp(e.docName),{contentDir:n,pathSeparator:r}=e.workspace;return{docContext:{relativePath:t},projectDir:n,docPath:bp(n,t,r)}}function Cp(e){return e.workspace?.contentDir?{docContext:null,projectDir:e.workspace.contentDir,docPath:``}:null}function wp(e){return _p(e.installUrl).then(()=>void 0)}function Tp(e){return`Opened in ${e}.`}function Ep(e,t=1){return t>=3?`Couldn't reach ${e} — please try again later.`:t===2?`Still couldn't reach ${e} — try one more time?`:`Couldn't reach ${e} — try again?`}function Dp(e){return e>=3?null:e===2?`Try one more time`:`Retry`}function Op(e,t,n,r){return t.ok?{target:e,host:n,outcome:`ok`,ts:r}:{target:e,host:n,outcome:`error`,ts:r,reason:t.reason}}async function kp(e,t,n,r=1){if(e===`claude-cowork`&&r===1){let e;try{e=await n.ensureCoworkSkillInstalled()}catch(e){let t=e instanceof Error?e.message:String(e);return n.toast.error(`Couldn't install Open Knowledge skill — ${t}`),{ok:!1,reason:`dispatch-error`,detail:`install-error: ${t}`}}if(e.kind===`installed-now`)return n.toast.success(`Open Knowledge skill saved. Upload it in Claude Desktop, then click Cowork again.`),{ok:!0};if(e.kind===`install-failed`){let t=e.message??e.reason;return n.toast.error(`Couldn't install Open Knowledge skill — ${t}`),{ok:!1,reason:`dispatch-error`,detail:`install-failed: ${t}`}}}let i={target:e,projectDir:t.projectDir,docPath:t.docPath,prompt:t.docContext===null?``:tr(t.docContext)},a=await n.dispatchHandoff(i),o=Op(e,a,n.isElectronHost()?`electron`:`web`,n.now().toISOString());await n.recordHandoff(o);let s=n.getDisplayName(e);if(a.ok)n.toast.success(Tp(s));else{let i=Dp(r),a=Ep(s,r);i===null?n.toast.error(a):n.toast.error(a,{action:{label:i,onClick:()=>{kp(e,t,n,r+1)}}})}return a}function Ap(e){return zf.find(t=>t.id===e)?.displayName??e}function jp(e=typeof window<`u`?window:void 0){return e?.okDesktop!=null}function Mp(){return{dispatchHandoff:gp,recordHandoff:yp,toast:{success:e=>{Xa.success(e)},error:(e,t)=>{Xa.error(e,t?{action:t.action}:void 0)}},now:()=>new Date,isElectronHost:()=>jp(),getDisplayName:Ap,ensureCoworkSkillInstalled:pp}}function Np(){return{dispatch:(e,t)=>kp(e,t,Mp()),reinstallCoworkSkill:mp}}var Pp=[...new Set(zf.flatMap(e=>e.schemes))];function Fp(e,t){let n=t.now?.()??Date.now(),r={};for(let t of zf){let i=t.schemes[0],a=i===void 0?void 0:e[i];if(!a){r[t.id]={installed:null};continue}r[t.id]={installed:a.installed,...a.displayName===void 0?{}:{displayName:a.displayName},lastChecked:n}}return r}function Ip(e){return Fp({},e)}async function Lp(e){let t=e.schemes??Pp,n=await Promise.all(t.map(async t=>{let n=t.replace(/:$/,``);try{return[t,await e.detectProtocol(n)]}catch{return[t,{installed:!1}]}}));return Object.fromEntries(n)}var Rp=Object.fromEntries(Pp.map(e=>[e,{installed:!1}]));async function zp(e){let t;try{t=await e.fetch(`/api/installed-agents`,{signal:e.signal,headers:{Accept:`application/json`}})}catch(e){if(e.name===`AbortError`)throw e;return Rp}if(!t.ok)return Rp;let n;try{n=await t.json()}catch{return Rp}if(typeof n!=`object`||!n||Array.isArray(n))return Rp;let r=n,i={};for(let e of Pp)i[e]={installed:r[e.replace(/:$/,``)]===!0};return i}function Bp(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(!n||!i||n.installed!==i.installed||n.displayName!==i.displayName)return!1}return!0}function Vp(e){let t=e.throttleMs??1e4,n=!1,r=null,i=null,a={},o=Ip({isElectronHost:e.isElectronHost(),now:e.now}),s=new Set,c=()=>{if(!n)for(let e of s)e(o)},l=()=>{o=Fp(a,{isElectronHost:e.isElectronHost(),now:e.now})};return{probe:async()=>{if(n)return;if(i)return i;if(r!==null&&e.now()-r<t)return;let o=(async()=>{try{let t=await e.probe();if(n)return;let i=!Bp(a,t);a=t,i&&(l(),c()),r=e.now()}catch{}finally{i=null}})();return i=o,o},getTargetStates:()=>o,subscribe:e=>(s.add(e),()=>{s.delete(e)}),cancel:()=>{n=!0,s.clear()}}}function Hp(e=typeof window<`u`?window:void 0){return e?.okDesktop!=null}function Up(){let e=typeof window<`u`?window.okDesktop:void 0;if(e){let t=t=>e.shell.detectProtocol(t);return{probe:()=>Lp({detectProtocol:t}),isElectronHost:()=>!0,now:Date.now}}let t=globalThis.fetch.bind(globalThis);return{probe:()=>zp({fetch:t}),isElectronHost:()=>!1,now:Date.now}}function Wp(){let e=(0,$.c)(5),[t,n]=(0,Q.useState)(Gp),r=(0,Q.useRef)(null),i,a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{let e=Vp(Up());r.current=e;let t=e.subscribe(n);e.probe();let i=()=>{e.probe()};return typeof window<`u`&&window.addEventListener(`focus`,i),()=>{typeof window<`u`&&window.removeEventListener(`focus`,i),t(),e.cancel(),r.current=null}},a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),(0,Q.useEffect)(i,a);let o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>r.current?.probe()??Promise.resolve(),e[2]=o):o=e[2];let s;return e[3]===t?s=e[4]:(s={states:t,refresh:o},e[3]=t,e[4]=s),s}function Gp(){return Ip({isElectronHost:Hp(),now:Date.now})}var Kp=3e3,qp=(e,t,n)=>wc(e,t,n,`CommandPalette`);function Jp(e){window.location.assign(er(e))}function Yp(e,t){return e?.kind===`folder`||e?.kind===`folder-index`?e.folderPath:Jn(t)}function Xp(e){let t=(0,$.c)(23),{entry:n,query:r,onSelect:i}=e,a=r===void 0?``:r,o=n.kind===`folder`?G:ws,s;t[0]===n?s=t[1]:(s=`title`in n&&n.title?n.title:n.path.split(`/`).pop()??n.path,t[0]=n,t[1]=s);let c=s,l=`snippet`in n?n.snippet:void 0,u=`${n.kind} ${n.path}`,d=`command-palette-nav-${n.kind}-${n.path}`,f;t[2]===o?f=t[3]:(f=(0,Z.jsx)(o,{className:`mt-0.5`}),t[2]=o,t[3]=f);let p;t[4]!==a||t[5]!==c?(p=(0,Z.jsx)(`span`,{className:`truncate font-medium`,children:(0,Z.jsx)(Zp,{query:a,text:c})}),t[4]=a,t[5]=c,t[6]=p):p=t[6];let m;t[7]!==n.path||t[8]!==a?(m=(0,Z.jsx)(`span`,{className:`truncate text-muted-foreground text-xs`,children:(0,Z.jsx)(Zp,{query:a,text:n.path})}),t[7]=n.path,t[8]=a,t[9]=m):m=t[9];let h;t[10]!==a||t[11]!==l?(h=l?(0,Z.jsx)(`span`,{className:`max-h-10 overflow-hidden text-muted-foreground text-xs leading-relaxed`,children:(0,Z.jsx)(Zp,{query:a,text:l})}):null,t[10]=a,t[11]=l,t[12]=h):h=t[12];let g;t[13]!==p||t[14]!==m||t[15]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[p,m,h]}),t[13]=p,t[14]=m,t[15]=h,t[16]=g):g=t[16];let _;return t[17]!==i||t[18]!==u||t[19]!==d||t[20]!==f||t[21]!==g?(_=(0,Z.jsxs)(L,{value:u,onSelect:i,"data-testid":d,className:`items-start`,children:[f,g]}),t[17]=i,t[18]=u,t[19]=d,t[20]=f,t[21]=g,t[22]=_):_=t[22],_}function Zp(e){let t=(0,$.c)(5),{text:n,query:r}=e,i;t[0]!==r||t[1]!==n?(i=cf(n,r).map(Qp),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,Z.jsx)(Z.Fragment,{children:i}),t[3]=i,t[4]=a),a}function Qp(e){let t=`${e.start}:${e.match?`match`:`plain`}`;return e.match?(0,Z.jsx)(`mark`,{className:`rounded-sm bg-primary/10 px-0.5 font-semibold text-primary`,children:e.text},t):(0,Z.jsx)(`span`,{children:e.text},t)}function $p({searchResults:e,fallbackSearchResults:t,searchStatus:n}){return e.length>0?e:n===`success`?[]:t}function em(e){let t=(0,$.c)(104),{bridge:n,open:r,onOpenChange:i}=e,a=n===void 0?null:n,[o,s]=(0,Q.useState)(``),c=(0,Q.useDeferredValue)(o),l=c.trim(),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=[],t[0]=d):d=t[0];let[f,p]=(0,Q.useState)(d),[m,h]=(0,Q.useState)(`idle`),_;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(_=[],t[1]=_):_=t[1];let[v,b]=(0,Q.useState)(_),x;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=[],t[2]=x):x=t[2];let[S,C]=(0,Q.useState)(x),[w,T]=(0,Q.useState)(null),E;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(E=[],t[3]=E):E=t[3];let[D,O]=(0,Q.useState)(E),[k,A]=(0,Q.useState)(`idle`),j;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(j=[],t[4]=j):j=t[4];let[M,N]=(0,Q.useState)(j),[P,F]=(0,Q.useState)(`idle`),I=(0,Q.useRef)(!1),R=(0,Q.useRef)(null),z=(0,Q.useRef)(null),{activeDocName:B,activeTarget:V}=We(),{pages:H,pageTitles:U,pageMeta:W,folderPaths:K}=wr(),q=qf(),{states:ee,refresh:ne}=Wp(),{dispatch:re}=Np(),ie=Sp({docName:B,workspace:q}),ae=ef(H,K,U,W),oe=Kd(S,new Set(ae.map(rm))),se=a?.config.projectPath??null,ce=a?v.filter(e=>e.path!==se):[],le;t[5]!==B||t[6]!==V?(le=Yp(V,B),t[5]=B,t[6]=V,t[7]=le):le=t[7];let ue=le,de=l===``?[]:of(ae,l,8),fe,pe;t[8]!==i||t[9]!==r?(fe=()=>{let e=function(e){e.key===`k`&&(Vr()?e.metaKey:e.ctrlKey)&&(e.preventDefault(),i(!r))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},pe=[i,r],t[8]=i,t[9]=r,t[10]=fe,t[11]=pe):(fe=t[10],pe=t[11]),(0,Q.useEffect)(fe,pe);let me,he;t[12]!==a||t[13]!==r||t[14]!==ne?(me=()=>{if(r){if(C(Ud()),ne(),a){let e=!1;return qp(async()=>{let t=await a.project.listRecent();e||b(t)},`Failed to load recent projects.`),()=>{e=!0}}return}s(``),O([]),A(`idle`),I.current=!1,N([]),F(`idle`)},he=[r,a,ne],t[12]=a,t[13]=r,t[14]=ne,t[15]=me,t[16]=he):(me=t[15],he=t[16]),(0,Q.useEffect)(me,he);let ge;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(ge=()=>{R.current&&(R.current.scrollTop=0)},t[17]=ge):ge=t[17];let _e;t[18]===o?_e=t[19]:(_e=[o],t[18]=o,t[19]=_e),(0,Q.useEffect)(ge,_e);let ve=pf(c,new Set(D.map(nm))),ye=ve.kind!==`normal`,be,xe;t[20]!==ye||t[21]!==r?(be=()=>{if(!r||!ye||I.current)return;I.current=!0,A(`loading`);let e=!1;return hf().then(t=>{e||(O(t),A(`success`))}).catch(t=>{e||(console.error(`[command-palette-tag] fetch tags failed`,t),O([]),A(`error`))}),()=>{e=!0}},xe=[r,ye],t[20]=ye,t[21]=r,t[22]=be,t[23]=xe):(be=t[22],xe=t[23]),(0,Q.useEffect)(be,xe);let Se=ve.kind===`tag-docs`?ve.tagName:null;(0,Q.useEffect)(()=>{if(!r||Se===null){N([]),F(`idle`);return}F(`loading`),N([]);let e=!1;return gf(Se).then(t=>{e||(N(t),F(`success`))}).catch(t=>{e||(console.error(`[command-palette-tag] fetch tag docs failed`,t),N([]),F(`error`))}),()=>{e=!0}},[r,Se]),(0,Q.useEffect)(()=>{if(!r||!l||ye){p([]),h(`idle`);return}let e=new AbortController;h(`loading`);let t=!1,n=window.setTimeout(()=>{t=!0,e.abort(),p([]),h(`error`)},Kp);return uf(l,{signal:e.signal}).then(e=>{window.clearTimeout(n),p(e),h(`success`)}).catch(e=>{window.clearTimeout(n),!(e instanceof Error&&e.name===`AbortError`&&!t)&&(p([]),h(`error`))}),()=>{window.clearTimeout(n),e.abort()}},[r,l,ye]);let Ce;t[24]===i?Ce=t[25]:(Ce=(e,t)=>{let n=t===void 0?`Command failed.`:t;i(!1),qp(async()=>{await e()},n)},t[24]=i,t[25]=Ce);let we=Ce,J;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(J=function(e){let t={kind:e.kind,path:e.path,lastOpenedAt:new Date().toISOString()},n=Gd(Ud(),t);Wd(n),C(n)},t[26]=J):J=t[26];let Te=J,Ee;t[27]===i?Ee=t[28]:(Ee=function(e){i(!1),Te(e),Jp(e.path)},t[27]=i,t[28]=Ee);let De=Ee,Oe=!ye&&l===``&&oe.length>0,ke=$p({searchResults:f,fallbackSearchResults:de,searchStatus:m}),Ae=!ye&&ke.length>0,je=!ye&&l!==``&&m===`loading`&&!Ae,Me;t[29]!==c||t[30]!==ye?(Me=!ye&&df(`New file`,c,[`create file`]),t[29]=c,t[30]=ye,t[31]=Me):Me=t[31];let Ne=Me,Pe;t[32]!==c||t[33]!==ye?(Pe=!ye&&df(`New folder`,c,[`create folder`]),t[32]=c,t[33]=ye,t[34]=Pe):Pe=t[34];let Fe=Pe,Ie;t[35]!==B||t[36]!==c||t[37]!==ye?(Ie=!ye&&B!==null&&df(`Open graph`,c,[`graph panel network`]),t[35]=B,t[36]=c,t[37]=ye,t[38]=Ie):Ie=t[38];let Le=Ie,ze=!ye&&a!==null&&df(`Open folder on disk`,c,[`project`]),Be=!ye&&a!==null&&df(`Switch Project`,c,[`switch project navigator projects`]),Ve=!ye&&df(`Settings`,c,[`preferences config`]),He=!ye&&df(`Install for Claude Chat & Cowork (Desktop App)`,c,[`claude desktop install cowork`]),Ue=!ye&&a!==null&&ce.length>0&&(l===``||ce.some(e=>df(`${e.name} ${e.path}`,c,[`recent project`]))),Ge=!ye&&ie!==null&&(l===``||zf.some(e=>df(`Open in ${e.displayName}`,c,[e.id,`agent handoff`]))),Ke=ve.kind===`tag-list`?mf(D,ve.query):[],qe=ve.kind===`tag-list`&&k!==`loading`&&Ke.length===0,Je=ve.kind===`tag-docs`&&P===`success`&&M.length===0,Ye=ye||Oe||Ae||je||Ne||Fe||Le||ze||Be||Ve||He||Ue||Ge,Xe;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=function(e){s(`${ff}${e}`)},t[39]=Xe):Xe=t[39];let Ze=Xe,Qe=ht,$e;t[40]===Symbol.for(`react.memo_cache_sentinel`)?($e={shouldFilter:!1,className:`[&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4`},t[40]=$e):$e=t[40];let et;t[41]===o?et=t[42]:(et=(0,Z.jsx)(g,{ref:z,value:o,onValueChange:s,placeholder:`Search files, folders, or commands`}),t[41]=o,t[42]=et);let tt;t[43]===ye?tt=t[44]:(tt=()=>{s(ye?``:ff),z.current?.focus()},t[43]=ye,t[44]=tt);let nt=ye?`border-primary/30 bg-primary/10 text-primary`:`border-border bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground`,rt;t[45]===nt?rt=t[46]:(rt=Y(`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors`,nt),t[45]=nt,t[46]=rt);let it,at;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(it=(0,Z.jsx)(_t,{className:`size-3.5`}),at=(0,Z.jsx)(`span`,{children:`By tag`}),t[47]=it,t[48]=at):(it=t[47],at=t[48]);let ot;t[49]!==ye||t[50]!==tt||t[51]!==rt?(ot=(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5 border-b px-3 py-2`,children:(0,Z.jsxs)(`button`,{type:`button`,onClick:tt,"data-testid":`command-palette-filter-tag`,"data-active":ye,"aria-pressed":ye,className:rt,children:[it,at]})}),t[49]=ye,t[50]=tt,t[51]=rt,t[52]=ot):ot=t[52];let st=Re,ct;t[53]!==Ae||t[54]!==je?(ct=je&&!Ae?(0,Z.jsx)(te,{children:`Searching`}):null,t[53]=Ae,t[54]=je,t[55]=ct):ct=t[55];let lt=Ye?null:(0,Z.jsx)(te,{children:m===`error`?`Search failed.`:`No matching commands.`}),ut=ve.kind===`tag-list`?(0,Z.jsxs)(y,{heading:ve.query?`Tags matching "${ve.query}"`:`All tags`,children:[k===`loading`?(0,Z.jsx)(te,{children:`Loading tags`}):null,k===`error`?(0,Z.jsx)(te,{children:`Failed to load tags. Press Escape and re-open to retry.`}):null,qe?(0,Z.jsx)(te,{children:ve.query?`No tags match "${ve.query}".`:"No tags yet — author `#tagname` in any doc to populate the index."}):null,Ke.map(e=>(0,Z.jsxs)(L,{value:`tag ${e.name}`,onSelect:()=>Ze(e.name),"data-testid":`command-palette-tag-${e.name}`,children:[(0,Z.jsx)(_t,{}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.name}),(0,Z.jsxs)(`span`,{className:`ml-auto shrink-0 text-[11px] text-muted-foreground tabular-nums`,children:[e.count,` `,e.count===1?`doc`:`docs`]})]},`tag:${e.name}`))]}):null,dt;t[56]!==i||t[57]!==ve||t[58]!==Je||t[59]!==M||t[60]!==P?(dt=ve.kind===`tag-docs`?(0,Z.jsxs)(y,{heading:`Docs tagged #${ve.tagName}`,children:[P===`loading`?(0,Z.jsx)(te,{children:`Loading docs`}):null,P===`error`?(0,Z.jsx)(te,{children:`Failed to load docs. Press Escape and re-open to retry.`}):null,Je?(0,Z.jsx)(te,{children:`No docs registered under #${ve.tagName}.`}):null,M.map(e=>{let t=e.title||e.docName.split(`/`).pop()||e.docName;return(0,Z.jsxs)(L,{value:`tag-doc ${e.docName}`,onSelect:()=>{i(!1),Jp(e.docName)},"data-testid":`command-palette-tag-doc-${e.docName}`,className:`items-start`,children:[(0,Z.jsx)(ws,{className:`mt-0.5`}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`truncate font-medium`,children:t}),(0,Z.jsx)(`span`,{className:`truncate text-muted-foreground text-xs`,children:e.docName}),e.matchingTags.length>0&&e.matchingTags.some(e=>e!==ve.tagName)?(0,Z.jsxs)(`span`,{className:`truncate text-muted-foreground text-[11px]`,children:[`via`,` `,e.matchingTags.filter(e=>e!==ve.tagName).map(tm).join(`, `)]}):null]})]},`tag-doc:${e.docName}`)})]}):null,t[56]=i,t[57]=ve,t[58]=Je,t[59]=M,t[60]=P,t[61]=dt):dt=t[61];let ft=Oe?(0,Z.jsx)(y,{heading:`Recently opened`,children:oe.map(e=>(0,Z.jsx)(Xp,{entry:e,onSelect:()=>De(e)},Hd(e.kind,e.path)))}):null,pt;t[62]!==B||t[63]!==i||t[64]!==T||t[65]!==Ne||t[66]!==Fe||t[67]!==Le?(pt=Ne||Fe||Le?(0,Z.jsxs)(y,{heading:`Commands`,children:[Ne?(0,Z.jsxs)(L,{value:`new file create file`,onSelect:()=>{i(!1),T(`file`)},"data-testid":`command-palette-new-file`,children:[(0,Z.jsx)(mt,{}),(0,Z.jsx)(`span`,{children:`New file`})]}):null,Fe?(0,Z.jsxs)(L,{value:`new folder create folder`,onSelect:()=>{i(!1),T(`folder`)},"data-testid":`command-palette-new-folder`,children:[(0,Z.jsx)(Os,{}),(0,Z.jsx)(`span`,{children:`New folder`})]}):null,Le?(0,Z.jsxs)(L,{value:`open graph graph panel network`,onSelect:()=>{B&&(i(!1),bf(`graph`))},"data-testid":`command-palette-open-graph`,children:[(0,Z.jsx)(Gs,{}),(0,Z.jsx)(`span`,{children:`Open graph`})]}):null]}):null,t[62]=B,t[63]=i,t[64]=T,t[65]=Ne,t[66]=Fe,t[67]=Le,t[68]=pt):pt=t[68];let gt=Ge?(0,Z.jsx)(y,{heading:`Open in agent`,children:zf.filter(e=>df(`Open in ${e.displayName}`,c,[e.id,`agent handoff`])).map(e=>{let t=ee[e.id],n=t.installed===!0&&ie!==null,r=t.installed===null?`Detecting`:t.installed===!1?`Not installed`:null,a=r?`Open in ${e.displayName}, ${r}`:`Open in ${e.displayName}`;return(0,Z.jsxs)(L,{value:`open in ${e.displayName} ${e.id} agent`,disabled:!n,onSelect:()=>{!n||!ie||(i(!1),re(e.id,ie))},"data-testid":`command-palette-open-in-${e.id}`,"aria-label":a,children:[(0,Z.jsxs)(`span`,{className:`flex-1`,children:[`Open in `,e.displayName]}),r?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-auto text-muted-foreground text-xs`,children:r}):null]},e.id)})}):null,vt=ze||Be||Ve||He||Ue?(0,Z.jsxs)(y,{heading:`Project`,children:[ze&&a?(0,Z.jsxs)(L,{value:`open folder on disk project`,onSelect:()=>we(async()=>{let e=await a.dialog.openFolder();e&&await a.project.open({path:e,target:`new-window`,entryPoint:`pick-existing`})}),"data-testid":`command-palette-open-folder`,children:[(0,Z.jsx)(G,{}),(0,Z.jsx)(`span`,{children:`Open folder on disk`}),(0,Z.jsx)(u,{children:`⌘O`})]}):null,Be&&a?(0,Z.jsxs)(L,{value:`switch-project navigator projects`,onSelect:()=>we(()=>a.navigator.open(),`Failed to open Project Navigator.`),"data-testid":`command-palette-switch-project`,children:[(0,Z.jsx)(Fs,{}),(0,Z.jsx)(`span`,{children:`Switch Project`}),(0,Z.jsx)(u,{children:`⌘⇧N`})]}):null,Ve?(0,Z.jsxs)(L,{value:`settings preferences config`,onSelect:()=>{i(!1),window.location.hash!==`#settings`&&(window.location.hash=Bf)},"data-testid":`command-palette-settings`,children:[(0,Z.jsx)(rc,{}),(0,Z.jsx)(`span`,{children:`Settings`}),(0,Z.jsx)(u,{children:`⌘,`})]}):null,He?(0,Z.jsxs)(L,{value:`install claude desktop cowork app`,onSelect:()=>{i(!1),window.location.hash=`#install-claude-desktop`},"data-testid":`command-palette-install-claude-desktop`,children:[(0,Z.jsx)(Oi,{}),(0,Z.jsx)(`span`,{children:`Install for Claude Chat & Cowork (Desktop App)`})]}):null,Ue&&a?ce.filter(e=>df(`${e.name} ${e.path}`,c,[`recent project`])).slice(0,10).map(e=>(0,Z.jsxs)(L,{value:`${e.name} ${e.path} recent project`,disabled:e.missing,onSelect:()=>we(()=>a.project.open({path:e.path,target:`new-window`,entryPoint:`recents`}),`Failed to open project.`),"data-testid":`command-palette-recent-${e.path}`,children:[(0,Z.jsx)(ii,{}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),(0,Z.jsxs)(`span`,{className:`truncate text-muted-foreground text-xs`,children:[e.path,e.missing?` (missing)`:``]})]})]},e.path)):null]}):null,yt=Ae?(0,Z.jsx)(y,{heading:`Search`,children:ke.map(e=>(0,Z.jsx)(Xp,{entry:e,query:l,onSelect:()=>De(e)},Hd(e.kind,e.path)))}):null,bt;t[69]!==st||t[70]!==ct||t[71]!==lt||t[72]!==ut||t[73]!==dt||t[74]!==ft||t[75]!==pt||t[76]!==gt||t[77]!==vt||t[78]!==yt?(bt=(0,Z.jsxs)(st,{ref:R,className:`subtle-scrollbar`,children:[ct,lt,ut,dt,ft,pt,gt,vt,yt]}),t[69]=st,t[70]=ct,t[71]=lt,t[72]=ut,t[73]=dt,t[74]=ft,t[75]=pt,t[76]=gt,t[77]=vt,t[78]=yt,t[79]=bt):bt=t[79];let xt;t[80]!==Qe||t[81]!==i||t[82]!==r||t[83]!==$e||t[84]!==et||t[85]!==ot||t[86]!==bt?(xt=(0,Z.jsxs)(Qe,{open:r,onOpenChange:i,title:`Workspace Command Palette`,description:`Search files, folders, and commands for the current workspace.`,className:`sm:max-w-2xl`,commandProps:$e,children:[et,ot,bt]}),t[80]=Qe,t[81]=i,t[82]=r,t[83]=$e,t[84]=et,t[85]=ot,t[86]=bt,t[87]=xt):xt=t[87];let St=w===`file`,Ct;t[88]===T?Ct=t[89]:(Ct=e=>{e||T(null)},t[88]=T,t[89]=Ct);let wt;t[90]!==ue||t[91]!==St||t[92]!==Ct?(wt=(0,Z.jsx)(Pf,{open:St,onOpenChange:Ct,kind:`file`,initialDir:ue}),t[90]=ue,t[91]=St,t[92]=Ct,t[93]=wt):wt=t[93];let Tt=w===`folder`,Et;t[94]===T?Et=t[95]:(Et=e=>{e||T(null)},t[94]=T,t[95]=Et);let Dt;t[96]!==ue||t[97]!==Tt||t[98]!==Et?(Dt=(0,Z.jsx)(Pf,{open:Tt,onOpenChange:Et,kind:`folder`,initialDir:ue}),t[96]=ue,t[97]=Tt,t[98]=Et,t[99]=Dt):Dt=t[99];let Ot;return t[100]!==xt||t[101]!==wt||t[102]!==Dt?(Ot=(0,Z.jsxs)(Z.Fragment,{children:[xt,wt,Dt]}),t[100]=xt,t[101]=wt,t[102]=Dt,t[103]=Ot):Ot=t[103],Ot}function tm(e){return`#${e}`}function nm(e){return e.name}function rm(e){return Hd(e.kind,e.path)}var im=500;function am(e,t,n){return t?`terminal`:e===null&&n?`retrying`:`hidden`}function om(e){return e===null?`no response`:e.kind===`null-collab`?`ok ui responded but server.lock has no port yet`:e.code===`network`?"network error (is `ok ui` running?)":e.code===`invalid-body`?`/api/config returned a malformed body`:`/api/config returned HTTP ${e.code}`}function sm(){let e=(0,$.c)(16),{collabUrl:t,collabTerminal:n,collabLastError:r,retryCollab:i}=We(),[a,o]=(0,Q.useState)(!1),s,c;e[0]!==n||e[1]!==t?(s=()=>{if(t!==null||n){o(!1);return}let e=setTimeout(()=>o(!0),im);return()=>clearTimeout(e)},c=[t,n],e[0]=n,e[1]=t,e[2]=s,e[3]=c):(s=e[2],c=e[3]),(0,Q.useEffect)(s,c);let l=am(t,n,a);if(l===`hidden`)return null;if(l===`terminal`){let t;e[4]===r?t=e[5]:(t=om(r),e[4]=r,e[5]=t);let n;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`code`,{className:`bg-red-100/60 px-1 rounded`,children:`ok status`}),e[6]=n):n=e[6];let a;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(`code`,{className:`bg-red-100/60 px-1 rounded`,children:`.ok/local/last-spawn-error.log`}),e[7]=a):a=e[7];let o;e[8]===t?o=e[9]:(o=(0,Z.jsxs)(`span`,{children:[`Couldn't reach collab server — `,t,`. Try`,` `,n,` or check`,` `,a,`.`]}),e[8]=t,e[9]=o);let s;e[10]===i?s=e[11]:(s=(0,Z.jsx)(`button`,{type:`button`,onClick:i,className:`bg-red-950 text-red-50 px-2 py-0.5 rounded text-xs font-medium hover:bg-red-900`,children:`Retry`}),e[10]=i,e[11]=s);let c;return e[12]!==o||e[13]!==s?(c=(0,Z.jsxs)(`div`,{role:`alert`,"aria-live":`assertive`,className:`fixed top-0 inset-x-0 z-50 bg-red-500/95 text-red-950 text-sm text-center py-2 px-4 shadow-md flex items-center justify-center gap-3 flex-wrap`,children:[o,s]}),e[12]=o,e[13]=s,e[14]=c):c=e[14],c}let u;return e[15]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`fixed top-0 inset-x-0 z-50 bg-amber-500/95 text-amber-950 text-sm text-center py-2 px-4 shadow-md`,children:`Connecting — waiting for collab server`}),e[15]=u):u=e[15],u}async function cm(e){let t=await fetch(`/api/tags/${encodeURIComponent(e)}`);if(!t.ok){let e=await t.json().catch(()=>null);throw Error(Bn(e)??`Server error: ${t.status} ${t.statusText}`)}return(await t.json()).docs??[]}function lm(){let e=(0,$.c)(15),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(null),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={kind:`idle`},e[0]=a):a=e[0];let[o,s]=(0,Q.useState)(a),c=(0,Q.useRef)(0),l,u;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=function(e){let t=e.detail;if(!t||typeof t.value!=`string`)return;let r=c.current+=1;i(t.value),n(!0),s({kind:`loading`}),cm(t.value).then(e=>{c.current===r&&s({kind:`ready`,docs:e})}).catch(e=>{c.current===r&&s({kind:`error`,message:e instanceof Error?e.message:String(e)})})};return document.addEventListener(Ve,e),()=>document.removeEventListener(Ve,e)},u=[],e[1]=l,e[2]=u):(l=e[1],u=e[2]),(0,Q.useEffect)(l,u);let d;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=function(e){n(!1),window.location.assign(er(e))},e[3]=d):d=e[3];let f=d,p=r??``,m;e[4]===p?m=e[5]:(m=(0,Z.jsx)(qa,{children:(0,Z.jsxs)(Ra,{children:[`Documents tagged `,(0,Z.jsxs)(`span`,{className:`font-mono`,children:[`#`,p]})]})}),e[4]=p,e[5]=m);let h=r??``,g;e[6]!==o||e[7]!==h?(g=(0,Z.jsx)(Wa,{children:(0,Z.jsx)(um,{fetchState:o,tag:h,onSelectDoc:f})}),e[6]=o,e[7]=h,e[8]=g):g=e[8];let _;e[9]!==m||e[10]!==g?(_=(0,Z.jsxs)(Va,{children:[m,g]}),e[9]=m,e[10]=g,e[11]=_):_=e[11];let v;return e[12]!==t||e[13]!==_?(v=(0,Z.jsx)(Ja,{open:t,onOpenChange:n,children:_}),e[12]=t,e[13]=_,e[14]=v):v=e[14],v}function um(e){let t=(0,$.c)(12),{fetchState:n,tag:r,onSelectDoc:i}=e;if(n.kind===`idle`||n.kind===`loading`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`p`,{className:`text-muted-foreground text-sm`,"data-testid":`tag-dialog-loading`,children:`Loading`}),t[0]=e):e=t[0],e}if(n.kind===`error`){let e;return t[1]===n.message?e=t[2]:(e=(0,Z.jsx)(`p`,{className:`text-destructive text-sm`,"data-testid":`tag-dialog-error`,children:n.message}),t[1]=n.message,t[2]=e),e}if(n.docs.length===0){let e;return t[3]===r?e=t[4]:(e=(0,Z.jsxs)(`p`,{className:`text-muted-foreground text-sm`,"data-testid":`tag-dialog-empty`,children:[`Only the current document uses `,(0,Z.jsxs)(`span`,{className:`font-mono`,children:[`#`,r]}),`.`]}),t[3]=r,t[4]=e),e}let a;if(t[5]!==n.docs||t[6]!==i){let e;t[8]===i?e=t[9]:(e=e=>{let t=e.matchingTags??[];return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,className:`w-full rounded-md px-2 py-1.5 text-left text-sm hover:bg-muted focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring`,onClick:()=>i(e.docName),"data-testid":`tag-dialog-row`,children:[(0,Z.jsx)(`span`,{className:`block truncate font-medium`,children:e.title}),e.docName===e.title?null:(0,Z.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:e.docName}),t.length>0?(0,Z.jsx)(`span`,{className:`mt-1 flex flex-wrap items-center gap-1`,"data-testid":`tag-dialog-row-matches`,children:t.map(dm)}):null]})},e.docName)},t[8]=i,t[9]=e),a=n.docs.map(e),t[5]=n.docs,t[6]=i,t[7]=a}else a=t[7];let o;return t[10]===a?o=t[11]:(o=(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1`,"data-testid":`tag-dialog-list`,children:a}),t[10]=a,t[11]=o),o}function dm(e){return(0,Z.jsxs)(`span`,{"data-testid":`tag-dialog-row-match`,"data-tag":e,className:`tag pointer-events-none text-xs`,children:[`#`,e]},e)}var fm=`raw-mdx-nav`,pm=`ok-editor-mode-v1`,mm=[`wysiwyg`,`source`],hm=`wysiwyg`;function gm(e){return mm.includes(e)}function _m(e=localStorage){try{let t=e.getItem(pm);if(t===null)return hm;if(gm(t))return t;console.warn(`[editor-mode] invalid persisted value, falling back to default`,{raw:t})}catch{}return hm}function vm(e=window,t=localStorage){let n=e.__OK_EDITOR_MODE__;return gm(n)?n:_m(t)}function ym(e,t=localStorage){try{return t.setItem(pm,e),!0}catch(e){return console.warn(`[editor-mode] persist failed`,e),!1}}function bm(){let e=(0,$.c)(3),[t,n]=(0,Q.useState)(vm),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=function(e){n(e),ym(e)},e[0]=r):r=e[0];let i=r,a;return e[1]===t?a=e[2]:(a=[t,i],e[1]=t,e[2]=a),a}function xm(e){let t=(0,$.c)(21),{open:n,onResolved:r}=e,i=Vi(),a;t[0]!==r||t[1]!==i?(a=function(e){if(i===null){Xa.error(`Sync settings not yet loaded — try again in a moment`);return}let t=i(e);if(!t.ok){Xa.error(`Could not ${e?`enable sync`:`save sync preference`}: ${t.error}`);return}r()},t[0]=r,t[1]=i,t[2]=a):a=t[2];let o=a,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(qa,{children:(0,Z.jsx)(Ai,{})}),t[3]=s):s=t[3];let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(Wa,{children:(0,Z.jsx)(li,{})}),t[4]=c):c=t[4];let l;t[5]===o?l=t[6]:(l=()=>o(!1),t[5]=o,t[6]=l);let u=i===null,d;t[7]!==l||t[8]!==u?(d=(0,Z.jsx)(X,{variant:`ghost`,className:`uppercase font-mono`,onClick:l,disabled:u,children:`Keep disabled`}),t[7]=l,t[8]=u,t[9]=d):d=t[9];let f;t[10]===o?f=t[11]:(f=()=>o(!0),t[10]=o,t[11]=f);let p=i===null,m;t[12]!==f||t[13]!==p?(m=(0,Z.jsx)(X,{onClick:f,disabled:p,children:`Enable auto-sync`}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,Z.jsxs)(Va,{className:`sm:max-w-lg`,showCloseButton:!1,children:[s,c,(0,Z.jsxs)(Ga,{children:[d,m]})]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;return t[18]!==n||t[19]!==h?(g=(0,Z.jsx)(Ja,{open:n,onOpenChange:Sm,children:h}),t[18]=n,t[19]=h,t[20]=g):g=t[20],g}function Sm(){}function Cm(e){let t=(0,$.c)(9),{onOpenResolver:n}=e,r=da();if(!r||r.state!==`conflict`)return null;let i=r.conflictCount,a=i>0?`${i} page${i===1?``:`s`}`:`Some pages`,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(Dn,{className:`size-4 shrink-0`}),t[0]=o):o=t[0];let s=i===1?`has`:`have`,c;t[1]!==a||t[2]!==s?(c=(0,Z.jsxs)(`span`,{className:`flex-1`,children:[a,` `,s,` conflicting changes.`]}),t[1]=a,t[2]=s,t[3]=c):c=t[3];let l;t[4]===n?l=t[5]:(l=(0,Z.jsx)(X,{variant:`outline`,size:`xs`,className:`shrink-0 border-amber-400 dark:border-amber-700 text-amber-800 dark:text-amber-300 hover:bg-amber-100 dark:hover:bg-amber-900/50`,onClick:n,children:`Review and resolve`}),t[4]=n,t[5]=l);let u;return t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm border-b bg-amber-50 dark:bg-amber-950/30 text-amber-800 dark:text-amber-300 shrink-0`,children:[o,c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8],u}var wm=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 Tm(e,t,n,r,i,a){if(e==r)return[];let o=Fm(e,t,n,r,i,a),s=Im(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 wm(t,n,i,a)];if(c>l){let o=e.slice(t,n).indexOf(r.slice(i,a));if(o>-1)return[new wm(t,t+o,i,i),new wm(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 wm(t,t,i,i+o),new wm(n,n,i+o+c,a)]}if(c==1||l==1)return[new wm(t,n,i,a)];let u=Rm(e,t,n,r,i,a);if(u){let[o,s,c]=u;return Tm(e,t,o,r,i,s).concat(Tm(e,o+c,n,r,s+c,a))}return km(e,t,n,r,i,a)}var Em=1e9,Dm=0,Om=!1;function km(e,t,n,r,i,a){let o=n-t,s=a-i;if(Em<1e9&&Math.min(o,s)>Em*16||Dm>0&&Date.now()>Dm)return Math.min(o,s)>Em*64?[new wm(t,n,i,a)]:zm(e,t,n,r,i,a);let c=Math.ceil((o+s)/2);jm.reset(c),Mm.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:Mm,f=d?null:jm;for(let p=0;p<c;p++){if(p>Em||Dm>0&&!(p&63)&&Date.now()>Dm)return zm(e,t,n,r,i,a);let m=jm.advance(p,o,s,c,d,!1,l)||Mm.advance(p,o,s,c,f,!0,u);if(m)return Nm(e,t,n,t+m[0],r,i,a,i+m[1])}return[new wm(t,n,i,a)]}var Am=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}},jm=new Am,Mm=new Am;function Nm(e,t,n,r,i,a,o,s){let c=!1;return!eh(e,r)&&++r==n&&(c=!0),!eh(i,s)&&++s==o&&(c=!0),c?[new wm(t,n,a,o)]:Tm(e,t,r,i,a,s).concat(Tm(e,r,n,i,s,o))}function Pm(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function Fm(e,t,n,r,i,a){if(t==n||t==a||e.charCodeAt(t)!=r.charCodeAt(i))return 0;let o=Pm(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-+!eh(e,s);o>>=1}else if(i==n||l==a)return i-t;else s=i,c=l}}function Im(e,t,n,r,i,a){if(t==n||i==a||e.charCodeAt(n-1)!=r.charCodeAt(a-1))return 0;let o=Pm(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-+!eh(e,s);o>>=1}else if(a==t||l==i)return n-a;else s=a,c=l}}function Lm(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;;){eh(e,s)||s++;let u=s+o;if(eh(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=Fm(e,u,n,r,i+f+d.length,a),c=Im(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 Rm(e,t,n,r,i,a){let o=n-t,s=a-i;if(o<s){let o=Rm(r,i,a,e,t,n);return o&&[o[1],o[0],o[2]]}return o<4||s*2<o?null:Lm(e,t,n,r,i,a,Math.floor(o/4),-1)}function zm(e,t,n,r,i,a){Om=!0;let o=n-t,s=a-i,c;if(o<s){let s=Lm(r,i,a,e,t,n,Math.floor(o/6),50);c=s&&[s[1],s[0],s[2]]}else c=Lm(e,t,n,r,i,a,Math.floor(s/6),50);if(!c)return[new wm(t,n,i,a)];let[l,u,d]=c;return Tm(e,t,l,r,i,u).concat(Tm(e,l+d,n,r,u+d,a))}function Bm(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 wm(r.fromA,i.toA,r.fromB,i.toB),e.splice(n--,1))}}function Vm(e,t,n){for(;;){Bm(n,1);let r=!1;for(let i=0;i<n.length;i++){let a=n[i],o,s;(o=Fm(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new wm(a.fromA+o,a.toA,a.fromB+o,a.toB)),(s=Im(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new wm(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 wm(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 wm(a.fromA+d,a.toA+d,a.fromB+d,a.toB+d),r=!0)}if(!r)break}return n}function Hm(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=Ym(t,a.fromA,l),f=Jm(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 wm(d,d+o,a.fromB-p,a.toB-p),d=a.fromA,f=Jm(t,a.toA,c-a.toA)):l>m&&t.slice(a.toA,f)==u.slice(h,h+m)&&(a=e[i]=new wm(f-o,f,a.fromB+m,a.toB+m),f=a.toA,d=Ym(t,a.fromA,a.fromA-r)),p=a.fromA-d,m=f-a.toA}if(p||m)a=e[i]=new wm(a.fromA-p,a.toA+m,a.fromB-p,a.toB+m);else if(!o){let t=Zm(n,a.fromB,a.toB),r,o=t<0?-1:Xm(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=Zm(t,a.fromA,a.toA),r,o=n<0?-1:Xm(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 Bm(e,3),e}var Um;try{Um=RegExp(`[\\p{Alphabetic}\\p{Number}]`,`u`)}catch{}function Wm(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function Gm(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?+!!Wm(n):Um?!Qm(n)||t==e.length-1?+!!Um.test(String.fromCharCode(n)):Um.test(e.slice(t,t+2))?2:0:0}function Km(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?+!!Wm(n):Um?!$m(n)||t==1?+!!Um.test(String.fromCharCode(n)):Um.test(e.slice(t-2,t))?2:0:0}var qm=8;function Jm(e,t,n){if(t==e.length||!Km(e,t))return t;for(let r=t,i=t+n,a=0;a<qm;a++){let t=Gm(e,r);if(!t||r+t>i)return r;r+=t}return t}function Ym(e,t,n){if(!t||!Gm(e,t))return t;for(let r=t,i=t-n,a=0;a<qm;a++){let t=Km(e,r);if(!t||r-t<i)return r;r-=t}return t}function Xm(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function Zm(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}var Qm=e=>e>=55296&&e<=56319,$m=e=>e>=56320&&e<=57343;function eh(e,t){return!t||t==e.length||!Qm(e.charCodeAt(t-1))||!$m(e.charCodeAt(t))}function th(e,t,n){let r=n?.override;return r?r(e,t):(Em=(n?.scanLimit??1e9)>>1,Dm=n?.timeout?Date.now()+n.timeout:0,Om=!1,Vm(e,t,Tm(e,0,e.length,t,0,t.length)))}function nh(){return!Om}function rh(e,t,n){return Hm(th(e,t,n),e,t)}var ih=To.define({combine:e=>e[0]}),ah=Eo.define(),oh=To.define(),sh=bo.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(ah)&&(e=n.value);for(let n of t.state.facet(oh))e=n(e,t);return e}});function ch(e){let t=e.field(sh,!1);if(!t)return null;let n=e.facet(ih);return{chunks:t,side:n?n.side:null}}var lh=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 fh(rh(e.toString(),t.toString(),n),e,t,0,0,nh())}static updateA(e,t,n,r,i){return gh(hh(e,r,!0,n.length),e,t,n,i)}static updateB(e,t,n,r,i){return gh(hh(e,r,!1,t.length),e,t,n,i)}};function uh(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 dh(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 fh(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length;s++){let c=e[s],[l,u]=uh(c.fromA+r,c.fromB+i,t,n),[d,f]=dh(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]=uh(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]=dh(a.toA+r,a.toB+i,t,n),s++}o.push(new lh(p,l,Math.max(l,d),u,Math.max(u,f),a))}return o}var ph=1e3;function mh(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 hh(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>ph&&([l,d]=mh(e,a-ph,n,!0)),o<t.length-ph&&([u,f]=mh(e,o+ph,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 gh(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=rh(n.sliceString(d,p),r.sliceString(f,m),i);for(let e of fh(h,n,r,d,f,nh()))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 _h={scanLimit:500},vh=Do.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=Oh(e))}update(e){(e.docChanged||e.viewportChanged||bh(e.startState,e.state)||xh(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=Oh(e.view))}},{decorations:e=>e.deco}),yh=_o.low(jo({class:`cm-changeGutter`,markers:e=>e.plugin(vh)?.gutter||No.empty}));function bh(e,t){return e.field(sh,!1)!=t.field(sh,!1)}function xh(e,t){return e.facet(ih)!=t.facet(ih)}var Sh=Co.line({class:`cm-changedLine`}),Ch=Co.mark({class:`cm-changedText`}),wh=Co.mark({tagName:`ins`,class:`cm-insertedLine`}),Th=Co.mark({tagName:`del`,class:`cm-deletedLine`}),Eh=new class extends Ao{constructor(){super(...arguments),this.elementClass=`cm-changedLineGutter`}};function Dh(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,Sh),i.add(o,s,n?Th:wh),a&&a.add(o,o,Eh);for(let l=t.iterRange(o,s-1),u=o;!l.next().done;){if(l.lineBreak){u++,i.add(u,u,Sh),a&&a.add(u,u,Eh);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,Ch),s<t)c++;else break}u=t}}}function Oh(e){let t=e.state.field(sh),{side:n,highlightChanges:r,markGutter:i,overrideChunk:a}=e.state.facet(ih),o=n==`a`,s=new wo,c=i?new wo: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))&&Dh(n,e.state.doc,o,r,s,c)}return{deco:s.finish(),gutter:c&&c.finish()}}var kh=class extends go{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}},Ah=Eo.define({map:(e,t)=>e.map(t)}),jh=bo.define({create:()=>Co.none,update:(e,t)=>{for(let e of t.effects)if(e.is(Ah))return e.value;return e.map(t.changes)},provide:e=>ko.decorations.from(e)}),Mh=.01;function Nh(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 Ph(e,t,n){let r=new wo,i=new wo,a=e.state.field(jh).iter(),o=t.state.field(jh).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<-Mh?(l-=n,r.add(s,s,Co.widget({widget:new kh(-n),block:!0,side:-1}))):n>Mh&&(u+=n,i.add(c,c,Co.widget({widget:new kh(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<Mh?r.add(e.state.doc.length,e.state.doc.length,Co.widget({widget:new kh(-p),block:!0,side:1})):p>Mh&&i.add(t.state.doc.length,t.state.doc.length,Co.widget({widget:new kh(p),block:!0,side:1}));let m=r.finish(),h=i.finish();Nh(m,e.state.field(jh))||e.dispatch({effects:Ah.of(m)}),Nh(h,t.state.field(jh))||t.dispatch({effects:Ah.of(h)})}var Fh=Eo.define({map:(e,t)=>t.mapPos(e)}),Ih=class extends go{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:Fh.of(n)});let{side:r,sibling:i}=e.state.facet(ih);i&&i().dispatch({effects:Fh.of(Lh(n,e.state.field(sh),r==`a`))})}),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return`collapsed-unchanged-code`}};function Lh(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 Rh=bo.define({create(e){return Co.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Fh)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>ko.decorations.from(e)});function zh({margin:e=3,minSize:t=4}){return Rh.init(n=>Bh(n,e,t))}function Bh(e,t,n){let r=new wo,i=e.facet(ih).side==`a`,a=e.field(sh),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,Co.replace({widget:new Ih(d),block:!0})),!c)break;o=e.doc.lineAt(Math.min(e.doc.length,i?c.toA:c.toB)).number}return r.finish()}var Vh=ko.styleModule.of(new Mo({".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`}})),Hh=ko.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`}}),Uh=new Oo,Wh=new Oo,Gh=class{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||_h;let t=[_o.low(vh),Hh,Vh,jh,ko.updateListener.of(e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some(e=>e.effects.some(e=>e.is(Ah)))&&this.measure()})],n=[ih.of({side:`a`,sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&n.push(yh);let r=yo.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],ko.editorAttributes.of({class:`cm-merge-a`}),Wh.of(n),t]}),i=[ih.of({side:`b`,sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&i.push(yh);let a=yo.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],ko.editorAttributes.of({class:`cm-merge-b`}),Wh.of(i),t]});this.chunks=lh.build(r.doc,a.doc,this.diffConf);let o=[sh.init(()=>this.chunks),Uh.of(e.collapseUnchanged?zh(e.collapseUnchanged):[])];r=r.update({effects:Eo.appendConfig.of(o)}).state,a=a.update({effects:Eo.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 ko({state:r,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new ko({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),vo.empty(e[0].startState.doc.length));this.chunks=t==this.a?lh.updateA(this.chunks,n.newDoc,this.b.state.doc,r,this.diffConf):lh.updateB(this.chunks,this.a.state.doc,n.newDoc,r,this.diffConf),t.update([...e,n.state.update({effects:ah.of(this.chunks)})]);let i=t==this.a?this.b:this.a;i.update([i.state.update({effects:ah.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(ih),o=n?e.gutter!==!1:r.markGutter,s=t?e.highlightChanges!==!1:r.highlightChanges;i.push(Wh.reconfigure([ih.of({side:`a`,sibling:()=>this.b,highlightChanges:s,markGutter:o}),o?yh:[]])),a.push(Wh.reconfigure([ih.of({side:`b`,sibling:()=>this.a,highlightChanges:s,markGutter:o}),o?yh:[]]))}if(r){let t=Uh.reconfigure(e.collapseUnchanged?zh(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(){Ph(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=Kh(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=Kh(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 Kh(e){let t=e.nextSibling;return e.remove(),t}var qh=new class extends Ao{constructor(){super(...arguments),this.elementClass=`cm-deletedLineGutter`}},Jh=_o.low(jo({class:`cm-changeGutter`,markers:e=>e.plugin(vh)?.gutter||No.empty,widgetMarker:(e,t)=>t instanceof $h?qh:null}));function Yh(e){let t=typeof e.original==`string`?So.of(e.original.split(/\r?\n/)):e.original,n=e.diffConfig||_h;return[_o.low(vh),ig,Hh,ko.editorAttributes.of({class:`cm-merge-b`}),oh.of((e,t)=>{let r=t.effects.find(e=>e.is(Xh));return r&&(e=lh.updateA(e,r.value.doc,t.startState.doc,r.value.changes,n)),t.docChanged&&(e=lh.updateB(e,t.state.field(Zh),t.newDoc,t.changes,n)),e}),ih.of({highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1,syntaxHighlightDeletions:e.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:e.mergeControls??!0,overrideChunk:e.allowInlineDiffs?ug:void 0,side:`b`}),Zh.init(()=>t),e.gutter===!1?[]:Jh,e.collapseUnchanged?zh(e.collapseUnchanged):[],sh.init(e=>lh.build(t,e.doc,n))]}var Xh=Eo.define(),Zh=bo.define({create:()=>So.empty,update(e,t){for(let n of t.effects)n.is(Xh)&&(e=n.value.doc);return e}}),Qh=new WeakMap,$h=class extends go{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 eg(e,t,n){let r=Qh.get(t.changes);if(r)return r;let i=Co.widget({block:!0,side:-1,widget:new $h(r=>{let{highlightChanges:i,syntaxHighlightDeletions:a,syntaxHighlightDeletionsMaxLength:o,mergeControls:s}=e.facet(ih),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(),tg(r,r.posAtDOM(c))},i=e=>{e.preventDefault(),ng(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(Zh).sliceString(t.fromA,t.endA),u=a&&e.facet(Po),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)==`
|
|
14
14
|
`){d.firstChild||d.appendChild(document.createElement(`br`)),d=h(),r++;continue}let e=t,a=n+(m?` cm-deletedText`:``),o=!1,s=l.indexOf(`
|
|
15
|
-
`,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;xo(t,{style:t=>Fo(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 Qh.set(t.changes,i),i}function tg(e,t){let{state:n}=e,r=t??n.selection.main.head,i=e.state.field(sh).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(Zh);i.fromB!=i.toB&&i.toA<=o.length&&(a+=e.state.lineBreak);let s=vo.of({from:i.fromA,to:Math.min(o.length,i.toA),insert:a},o.length);return e.dispatch({effects:Xh.of({doc:s.apply(o),changes:s}),userEvent:`accept`}),!0}function ng(e,t){let{state:n}=e,r=t??n.selection.main.head,i=n.field(sh).find(e=>e.fromB<=r&&e.endB>=r);if(!i)return!1;let a=n.field(Zh).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 rg(e){let t=new wo;for(let n of e.field(sh)){let r=e.facet(ih).overrideChunk&&og(e,n);t.add(n.fromB,n.fromB,eg(e,n,!!r))}return t.finish()}var ig=bo.define({create:e=>rg(e),update(e,t){return t.state.field(sh,!1)==t.startState.field(sh,!1)?e:rg(t.state)},provide:e=>ko.decorations.from(e)}),ag=new WeakMap;function og(e,t){let n=ag.get(t);if(n!==void 0)return n;n=null;let r=e.field(Zh),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(Co.widget({widget:new sg(t),side:-1}).range(s+n.fromB))}n.fromB<n.toB&&e.push(Ch.range(s+n.fromB,s+n.toB))}i<t.endA-t.fromA-a*2&&(n=e)}return ag.set(t,n),n}var sg=class extends go{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}},cg=new class extends Ao{constructor(){super(...arguments),this.elementClass=`cm-inlineChangedLineGutter`}},lg=Co.line({class:`cm-inlineChangedLine`});function ug(e,t,n,r){let i=og(e,t),a=0;if(!i)return!1;for(let o=e.doc.lineAt(t.fromB);;){for(r&&r.add(o.from,o.from,cg),n.add(o.from,o.from,lg);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 dg=W({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}}),fg=gt({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}});function pg(e){let t=(0,$.c)(20),{oldContent:n,newContent:r,layout:i,conflictMode:a,onResolve:o,onAbort:s}=e,c=(0,Q.useRef)(null),l=(0,Q.useRef)(null),{resolvedTheme:u}=yr(),d=(0,Q.useRef)(o),f=(0,Q.useRef)(s),[p,m]=(0,Q.useState)(null),h;t[0]!==s||t[1]!==o?(h=()=>{d.current=o,f.current=s},t[0]=s,t[1]=o,t[2]=h):h=t[2],(0,Q.useEffect)(h);let g,v;t[3]!==a||t[4]!==i||t[5]!==r||t[6]!==n||t[7]!==u?(g=()=>{if(!c.current)return;let e=u===`dark`?dg:fg,t=[ko.editable.of(!1),yo.readOnly.of(!0)],o=[Ro,_(),...t,e,ko.lineWrapping];if(l.current&&=(l.current.destroy(),null),a){let t=new ko({doc:r,extensions:[Ro,_(),ko.editable.of(!1),e,ko.lineWrapping,Yh({original:n,highlightChanges:!0,gutter:!0,mergeControls:!0,collapseUnchanged:{margin:3,minSize:4}}),ko.updateListener.of(e=>{let t=ch(e.state);m(t?t.chunks.length:0)})],parent:c.current});l.current=t;let i=ch(t.state);m(i?i.chunks.length:0)}else i===`split`?l.current=new Gh({a:{doc:n,extensions:o},b:{doc:r,extensions:o},parent:c.current,highlightChanges:!0,gutter:!0,collapseUnchanged:{margin:3,minSize:4}}):l.current=new ko({doc:r,extensions:[...o,Yh({original:n,highlightChanges:!0,gutter:!0,mergeControls:!1,collapseUnchanged:{margin:3,minSize:4}})],parent:c.current});return()=>{l.current&&=(l.current.destroy(),null)}},v=[n,r,i,u,a],t[3]=a,t[4]=i,t[5]=r,t[6]=n,t[7]=u,t[8]=g,t[9]=v):(g=t[8],v=t[9]),(0,Q.useEffect)(g,v);let y;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(y=function(){let e=l.current;!e||!(e instanceof ko)||d.current?.(e.state.doc.toString())},t[10]=y):y=t[10];let b=y,x=p===0,S=p===null?``:p===0?`All hunks resolved`:`${p} unresolved hunk${p===1?``:`s`}`,C;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(`div`,{ref:c,className:`diff-view min-h-0 flex-1 overflow-y-auto subtle-scrollbar`}),t[11]=C):C=t[11];let w;t[12]!==x||t[13]!==a||t[14]!==S||t[15]!==s||t[16]!==o?(w=a&&(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 ${x?`text-emerald-600 dark:text-emerald-400`:`text-muted-foreground`}`,children:S}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s&&(0,Z.jsx)(X,{variant:`ghost`,size:`sm`,onClick:s,children:`Exit merge`}),o&&(0,Z.jsx)(X,{variant:`default`,size:`sm`,disabled:!x,onClick:b,children:`Save resolution`})]})]}),t[12]=x,t[13]=a,t[14]=S,t[15]=s,t[16]=o,t[17]=w):w=t[17];let T;return t[18]===w?T=t[19]:(T=(0,Z.jsxs)(`div`,{className:`flex flex-col h-full`,children:[C,w]}),t[18]=w,t[19]=T),T}function mg(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)(Ua,{"data-slot":`sheet`,...n}),t[2]=n,t[3]=r),r}function hg(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)(Ka,{"data-slot":`sheet-portal`,...n}),t[2]=n,t[3]=r),r}function gg(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=Y(`fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(za,{"data-slot":`sheet-overlay`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function _g(e){let t=(0,$.c)(17),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,side:a,showCloseButton:o,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=a===void 0?`right`:a,c=o===void 0?!0:o,l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(gg,{}),t[6]=l):l=t[6];let u;t[7]===r?u=t[8]:(u=Y(`fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10`,r),t[7]=r,t[8]=u);let d;t[9]===c?d=t[10]:(d=c&&(0,Z.jsx)(Ha,{"data-slot":`sheet-close`,asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`,children:[(0,Z.jsx)(Fa,{}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Close`})]})}),t[9]=c,t[10]=d);let f;return t[11]!==n||t[12]!==i||t[13]!==s||t[14]!==u||t[15]!==d?(f=(0,Z.jsxs)(hg,{children:[l,(0,Z.jsxs)(Ya,{"data-slot":`sheet-content`,"data-side":s,className:u,...i,children:[n,d]})]}),t[11]=n,t[12]=i,t[13]=s,t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function vg(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=Y(`flex flex-col gap-0.5 p-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`sheet-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function yg(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=Y(`font-heading text-base font-medium text-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Ba,{"data-slot":`sheet-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}async function bg(){try{let e=await fetch(`/api/sync/conflicts`);return e.ok?{conflicts:(await e.json()).conflicts??[]}:{conflicts:[],error:`server`}}catch{return{conflicts:[],error:`network`}}}async function xg(e){try{let t=await fetch(`/api/sync/conflict-content?file=${encodeURIComponent(e)}`);if(!t.ok)return{ours:``,theirs:``,base:``};let n=await t.json();return{ours:n.ours??``,theirs:n.theirs??``,base:n.base??``}}catch{return{ours:``,theirs:``,base:``}}}async function Sg(e,t,n){try{let r={file:e,strategy:t};return n!==void 0&&(r.content=n),(await fetch(`/api/sync/resolve-conflict`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)})).ok}catch{return!1}}var Cg=`w-[98vw] !max-w-[98vw] h-[96vh] flex flex-col gap-0 sm:!max-w-[98vw]`;function wg(e){let t=(0,$.c)(31),{file:n,onResolve:r,onAbort:i}=e,[a,o]=(0,Q.useState)(null),s,c;if(t[0]===n?(s=t[1],c=t[2]):(s=()=>{let e=!1;return xg(n).then(t=>{e||o(t)}),()=>{e=!0}},c=[n],t[0]=n,t[1]=s,t[2]=c),(0,Q.useEffect)(s,c),a===null){let e;t[3]===i?e=t[4]:(e=e=>!e&&i(),t[3]=i,t[4]=e);let r;t[5]===n?r=t[6]:(r=(0,Z.jsx)(qa,{className:`shrink-0`,children:(0,Z.jsxs)(Ra,{children:[`Resolving: `,n]})}),t[5]=n,t[6]=r);let a;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted-foreground`,children:`Loading`}),t[7]=a):a=t[7];let o;t[8]===r?o=t[9]:(o=(0,Z.jsxs)(Va,{className:Cg,children:[r,a]}),t[8]=r,t[9]=o);let s;return t[10]!==e||t[11]!==o?(s=(0,Z.jsx)(Ja,{open:!0,onOpenChange:e,children:o}),t[10]=e,t[11]=o,t[12]=s):s=t[12],s}let l;t[13]===i?l=t[14]:(l=e=>!e&&i(),t[13]=i,t[14]=l);let u;t[15]===n?u=t[16]:(u=(0,Z.jsxs)(Ra,{className:`text-sm font-medium`,children:[`Resolving: `,n]}),t[15]=n,t[16]=u);let d;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Red = your version (ours). Green = team's version (theirs). Accept each hunk to take theirs, reject to keep yours, then save.`}),t[17]=d):d=t[17];let f;t[18]===u?f=t[19]:(f=(0,Z.jsxs)(qa,{className:`px-4 pt-4 pb-2 shrink-0`,children:[u,d]}),t[18]=u,t[19]=f);let p;t[20]!==i||t[21]!==r||t[22]!==a.ours||t[23]!==a.theirs?(p=(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:(0,Z.jsx)(pg,{oldContent:a.ours,newContent:a.theirs,layout:`unified`,conflictMode:!0,onResolve:r,onAbort:i})}),t[20]=i,t[21]=r,t[22]=a.ours,t[23]=a.theirs,t[24]=p):p=t[24];let m;t[25]!==f||t[26]!==p?(m=(0,Z.jsxs)(Va,{className:`${Cg} p-0`,children:[f,p]}),t[25]=f,t[26]=p,t[27]=m):m=t[27];let h;return t[28]!==l||t[29]!==m?(h=(0,Z.jsx)(Ja,{open:!0,onOpenChange:l,children:m}),t[28]=l,t[29]=m,t[30]=h):h=t[30],h}function Tg(e){let t=(0,$.c)(50),{open:n,onOpenChange:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=[],t[0]=i):i=t[0];let[a,o]=(0,Q.useState)(i),[s,c]=(0,Q.useState)(null),l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l=new Set,t[1]=l):l=t[1];let[u,d]=(0,Q.useState)(l),f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=new Set,t[2]=f):f=t[2];let[p,m]=(0,Q.useState)(f),[h,g]=(0,Q.useState)(null),_;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=function(){bg().then(e=>{let{conflicts:t,error:n}=e;c(n??null),o(t),d(e=>{let n=new Set(t.map(Eg));return new Set([...e].filter(e=>!n.has(e)))})})},t[3]=_):_=t[3];let v=_,y,b;t[4]===n?(y=t[5],b=t[6]):(y=()=>{n&&v()},b=[n],t[4]=n,t[5]=y,t[6]=b),(0,Q.useEffect)(y,b);let x,S;t[7]===n?(x=t[8],S=t[9]):(x=()=>_r(e=>{e.includes(`sync-status`)&&n&&v()}),S=[n],t[7]=n,t[8]=x,t[9]=S),(0,Q.useEffect)(x,S);let C,w;t[10]!==a.length||t[11]!==r||t[12]!==n||t[13]!==u.size?(w=()=>{n&&a.length>0&&u.size>=a.length&&(Xa.success(`All conflicts resolved — sync resuming`),r(!1),d(new Set))},C=[n,a.length,u.size,r],t[10]=a.length,t[11]=r,t[12]=n,t[13]=u.size,t[14]=C,t[15]=w):(C=t[14],w=t[15]),(0,Q.useEffect)(w,C);let T;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(T=async function(e,t,n){m(t=>new Set([...t,e]));let r=await Sg(e,t,n);m(t=>{let n=new Set(t);return n.delete(e),n}),r?d(t=>new Set([...t,e])):Xa.error(`Failed to resolve ${e}`)},t[16]=T):T=t[16];let E=T,D;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(D=function(e){g(e)},t[17]=D):D=t[17];let O=D,k;t[18]===h?k=t[19]:(k=async function(e){if(!h)return;let t=h;g(null),await E(t,`content`,e)},t[18]=h,t[19]=k);let A=k,j;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(j=function(){g(null)},t[20]=j):j=t[20];let M=j,N;t[21]===r?N=t[22]:(N=async function(){try{(await fetch(`/api/sync/abort-merge`,{method:`POST`})).ok?Xa.info(`Merge aborted — sync paused`):Xa.error(`Failed to abort merge`)}catch{Xa.error(`Failed to abort merge — connection error`)}r(!1),d(new Set)},t[21]=r,t[22]=N);let P=N,F=a.length,I=u.size,L;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsx)(yg,{className:`text-sm font-medium`,children:`Resolve conflicts`}),t[23]=L):L=t[23];let R;t[24]!==I||t[25]!==F?(R=F>0&&(0,Z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[I,` of `,F,` resolved`]}),t[24]=I,t[25]=F,t[26]=R):R=t[26];let z;t[27]===R?z=t[28]:(z=(0,Z.jsxs)(vg,{className:`px-4 py-3 border-b shrink-0`,children:[L,R]}),t[27]=R,t[28]=z);let B;t[29]!==a||t[30]!==s||t[31]!==u||t[32]!==p?(B=(0,Z.jsx)(`div`,{className:`flex-1 overflow-y-auto subtle-scrollbar`,children:s?(0,Z.jsxs)(`div`,{className:`px-4 py-6 text-sm text-center space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-destructive`,children:s===`network`?`Could not reach the sync server — check your connection.`:`Sync server error — try again in a moment.`}),(0,Z.jsx)(X,{variant:`outline`,size:`sm`,onClick:v,children:`Retry`})]}):a.length===0?(0,Z.jsx)(`p`,{className:`px-4 py-6 text-sm text-muted-foreground text-center`,children:`No conflicts found.`}):(0,Z.jsx)(`ul`,{className:`divide-y`,children:a.map(e=>{let t=u.has(e.file),n=p.has(e.file),r=e.file.split(`/`).pop()??e.file;return(0,Z.jsxs)(`li`,{className:`px-4 py-3 ${t?`opacity-50`:``}`,children:[(0,Z.jsxs)(`p`,{className:`text-sm font-medium truncate mb-2`,title:e.file,children:[t?`✓ `:``,r]}),!t&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,Z.jsx)(X,{variant:`outline`,size:`xs`,disabled:n,onClick:()=>void E(e.file,`mine`),children:`Keep my version`}),(0,Z.jsx)(X,{variant:`outline`,size:`xs`,disabled:n,onClick:()=>void E(e.file,`theirs`),children:`Keep team's version`}),(0,Z.jsx)(X,{variant:`ghost`,size:`xs`,disabled:n,onClick:()=>O(e.file),children:`Resolve manually`})]})]},e.file)})})}),t[29]=a,t[30]=s,t[31]=u,t[32]=p,t[33]=B):B=t[33];let V;t[34]===P?V=t[35]:(V=(0,Z.jsx)(`div`,{className:`px-4 py-3 border-t shrink-0`,children:(0,Z.jsx)(X,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:P,children:`Exit merge`})}),t[34]=P,t[35]=V);let H;t[36]!==z||t[37]!==B||t[38]!==V?(H=(0,Z.jsxs)(_g,{side:`right`,className:`w-80 sm:w-96 flex flex-col gap-0 p-0`,children:[z,B,V]}),t[36]=z,t[37]=B,t[38]=V,t[39]=H):H=t[39];let U;t[40]!==r||t[41]!==n||t[42]!==H?(U=(0,Z.jsx)(mg,{open:n,onOpenChange:r,children:H}),t[40]=r,t[41]=n,t[42]=H,t[43]=U):U=t[43];let W;t[44]!==A||t[45]!==h?(W=h&&(0,Z.jsx)(wg,{file:h,onResolve:e=>void A(e),onAbort:M}),t[44]=A,t[45]=h,t[46]=W):W=t[46];let G;return t[47]!==U||t[48]!==W?(G=(0,Z.jsxs)(Z.Fragment,{children:[U,W]}),t[47]=U,t[48]=W,t[49]=G):G=t[49],G}function Eg(e){return e.file}var Dg=5;async function Og(e){let t=await fetch(`/api/backlinks?docName=${encodeURIComponent(e)}`),n=await t.json().catch(()=>null);if(!t.ok){let e=ir.safeParse(n);throw e.success?Error(e.data.title):new Ce(`Failed to parse backlinks error response (HTTP ${t.status})`,{status:t.status})}let r=fn.safeParse(n);if(!r.success)throw new Ce(`Backlinks response did not match expected shape.`,{status:t.status});return r.data.backlinks}async function kg(e){let t=await fetch(`/api/forward-links?docName=${encodeURIComponent(e)}`),n=await t.json().catch(()=>null);if(!t.ok){let e=ir.safeParse(n);throw e.success?Error(e.data.title):new Ce(`Failed to parse forward-links error response (HTTP ${t.status})`,{status:t.status})}let r=Zn.safeParse(n);if(!r.success)throw new Ce(`Forward-links response did not match expected shape.`,{status:t.status});return r.data.forwardLinks}function Ag(e){let t=e.split(`/`);return t.length<=2?e:`…/${t.slice(-2).join(`/`)}`}function jg(e){window.location.hash=er(e)}function Mg(e){let t=(0,$.c)(9),{title:n,count:r,isLoading:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Ie,{className:`size-3.5 text-muted-foreground transition-transform group-data-[state=closed]:-rotate-90`}),t[0]=a):a=t[0];let o;t[1]===n?o=t[2]:(o=(0,Z.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[a,(0,Z.jsx)(Gt,{children:n})]}),t[1]=n,t[2]=o);let s;t[3]!==r||t[4]!==i?(s=!i&&(0,Z.jsx)(Wt,{children:r}),t[3]=r,t[4]=i,t[5]=s):s=t[5];let c;return t[6]!==o||t[7]!==s?(c=(0,Z.jsxs)(R,{className:`group flex w-full cursor-pointer items-center justify-between px-5 py-3 text-left transition-colors hover:bg-muted/40`,children:[o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function Ng(e){let t=(0,$.c)(7),{total:n,expanded:r,onToggle:i}=e;if(n<=Dg)return null;let a=n-Dg,o;t[0]===r?o=t[1]:(o=r?(0,Z.jsx)(Ie,{className:`size-3`}):(0,Z.jsx)(l,{className:`size-3`}),t[0]=r,t[1]=o);let s=r?`Show fewer`:`Show ${a} more`,c;return t[2]!==r||t[3]!==i||t[4]!==o||t[5]!==s?(c=(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":r,className:`mt-2 inline-flex cursor-pointer items-center gap-1 px-3 text-xs text-muted-foreground transition-colors hover:text-foreground`,onClick:i,children:[o,s]}),t[2]=r,t[3]=i,t[4]=o,t[5]=s,t[6]=c):c=t[6],c}function Pg(e){let t=(0,$.c)(38),{icon:n,iconColorClass:r,rowTooltip:i,title:a,path:o,anchor:s,snippet:c,titleHover:l,ariaLabel:u,href:d,external:f,disabled:p,onClick:m,hoverAction:h}=e,g=o!==void 0&&o!==a,_=r??`text-muted-foreground`,v;t[0]===_?v=t[1]:(v=Y(`mt-0.5 shrink-0`,_),t[0]=_,t[1]=v);let y;t[2]!==n||t[3]!==v?(y=(0,Z.jsx)(`span`,{className:v,children:n}),t[2]=n,t[3]=v,t[4]=y):y=t[4];let b=y,x;t[5]!==u||t[6]!==p||t[7]!==f||t[8]!==d||t[9]!==m||t[10]!==a||t[11]!==l?(x=d?(0,Z.jsxs)(`a`,{href:d,target:f?`_blank`:void 0,rel:f?`noopener noreferrer`:void 0,"aria-label":u,title:l,onClick:m,className:`block w-full truncate text-left font-medium text-foreground no-underline outline-none after:absolute after:inset-0 after:rounded-md focus-visible:after:ring-2 focus-visible:after:ring-ring`,children:[a,f?(0,Z.jsx)(`span`,{className:`sr-only`,children:` (opens in new tab)`}):null]}):(0,Z.jsx)(`button`,{type:`button`,"aria-label":u,title:l,disabled:p,onClick:m,className:Y(`block w-full truncate text-left font-medium text-foreground no-underline outline-none after:absolute after:inset-0 after:rounded-md focus-visible:after:ring-2 focus-visible:after:ring-ring`,`cursor-pointer bg-transparent p-0 disabled:cursor-not-allowed disabled:opacity-60`),children:a}),t[5]=u,t[6]=p,t[7]=f,t[8]=d,t[9]=m,t[10]=a,t[11]=l,t[12]=x):x=t[12];let S=x,C;t[13]===b?C=t[14]:(C=(0,Z.jsx)(`div`,{className:`mt-px flex items-center`,children:b}),t[13]=b,t[14]=C);let w;t[15]!==s||t[16]!==o||t[17]!==g?(w=g?(0,Z.jsxs)(`div`,{className:`truncate font-mono text-xs text-muted-foreground`,children:[o,s?(0,Z.jsxs)(`span`,{className:`ml-1`,children:[`· #`,s]}):null]}):null,t[15]=s,t[16]=o,t[17]=g,t[18]=w):w=t[18];let T;t[19]===c?T=t[20]:(T=c?(0,Z.jsx)(`p`,{className:`line-clamp-2 text-muted-foreground`,children:c}):null,t[19]=c,t[20]=T);let E;t[21]!==S||t[22]!==w||t[23]!==T?(E=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5 text-1sm`,children:[S,w,T]}),t[21]=S,t[22]=w,t[23]=T,t[24]=E):E=t[24];let D;t[25]===h?D=t[26]:(D=h?(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"aria-label":h.tooltip,disabled:h.disabled,className:`relative z-10 shrink-0 cursor-pointer rounded-md p-1 text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-muted-foreground group-hover:opacity-100`,onClick:h.onClick,children:h.icon})}),(0,Z.jsx)(co,{side:`top`,children:h.tooltip})]}):null,t[25]=h,t[26]=D);let O;t[27]!==C||t[28]!==E||t[29]!==D?(O=(0,Z.jsxs)(`div`,{className:`group relative flex items-start gap-2.5 rounded-md px-3 py-2.5 transition-colors hover:bg-muted/80`,children:[C,E,D]}),t[27]=C,t[28]=E,t[29]=D,t[30]=O):O=t[30];let k=O;if(i){let e;t[31]===k?e=t[32]:(e=(0,Z.jsx)(so,{asChild:!0,children:k}),t[31]=k,t[32]=e);let n;t[33]===i?n=t[34]:(n=(0,Z.jsx)(co,{side:`top`,children:i}),t[33]=i,t[34]=n);let r;return t[35]!==e||t[36]!==n?(r=(0,Z.jsxs)(uo,{children:[e,n]}),t[35]=e,t[36]=n,t[37]=r):r=t[37],r}return k}function Fg(e){let t=(0,$.c)(33),{docName:n}=e,{folderPaths:r,pages:i,loading:a}=wr(),o,s;t[0]===n?(o=t[1],s=t[2]):(o=[`backlinks`,n],s=()=>Og(n),t[0]=n,t[1]=o,t[2]=s);let c;t[3]!==n||t[4]!==a||t[5]!==i?(c=!a&&i.has(n),t[3]=n,t[4]=a,t[5]=i,t[6]=c):c=t[6];let l;t[7]!==o||t[8]!==s||t[9]!==c?(l={queryKey:o,queryFn:s,enabled:c},t[7]=o,t[8]=s,t[9]=c,t[10]=l):l=t[10];let{data:u,isLoading:d,error:f}=Nt(l),m;t[11]===u?m=t[12]:(m=u===void 0?[]:u,t[11]=u,t[12]=m);let h=m,[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(n);v!==n&&(y(n),_(!1));let b;t[13]!==h||t[14]!==g?(b=g?h:h.slice(0,Dg),t[13]=h,t[14]=g,t[15]=b):b=t[15];let x=b,S;t[16]!==h.length||t[17]!==d?(S=(0,Z.jsx)(Mg,{title:`Backlinks`,count:h.length,isLoading:d}),t[16]=h.length,t[17]=d,t[18]=S):S=t[18];let C;t[19]!==h.length||t[20]!==f||t[21]!==g||t[22]!==r||t[23]!==d||t[24]!==i||t[25]!==x?(C=f?(0,Z.jsx)(`div`,{className:`px-3`,children:(0,Z.jsx)(jt,{children:f instanceof Error?f.message:`Failed to load backlinks`})}):h.length===0&&!d?(0,Z.jsx)(`div`,{className:`px-3`,children:(0,Z.jsx)(Rt,{children:`No pages link here yet.`})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`flex flex-col gap-1`,children:x.map((e,t)=>{let n=Na(e.source,{pages:i,folderPaths:r});return(0,Z.jsx)(Pg,{icon:(0,Z.jsx)(p,{className:`size-3.5`}),title:e.title,path:Ag(e.source),titleHover:e.source,anchor:e.anchor,snippet:e.snippet,href:er(n.hashDocName,e.anchor)},`${e.source}-${t}`)})}),(0,Z.jsx)(Ng,{total:h.length,expanded:g,onToggle:()=>_(Ig)})]}),t[19]=h.length,t[20]=f,t[21]=g,t[22]=r,t[23]=d,t[24]=i,t[25]=x,t[26]=C):C=t[26];let w;t[27]!==d||t[28]!==C?(w=(0,Z.jsx)(N,{children:(0,Z.jsx)(`div`,{className:`px-2 pb-3`,"aria-busy":d,children:C})}),t[27]=d,t[28]=C,t[29]=w):w=t[29];let T;return t[30]!==w||t[31]!==S?(T=(0,Z.jsxs)(A,{defaultOpen:!0,children:[S,w]}),t[30]=w,t[31]=S,t[32]=T):T=t[32],T}function Ig(e){return!e}function Lg(e){let t=(0,$.c)(42),{docName:n}=e,{addPage:r,folderPaths:i,pages:a,pagesBySlug:o,loading:s}=wr(),c,l;t[0]===n?(c=t[1],l=t[2]):(c=[`forward-links`,n],l=()=>kg(n),t[0]=n,t[1]=c,t[2]=l);let u;t[3]!==n||t[4]!==a||t[5]!==s?(u=!s&&a.has(n),t[3]=n,t[4]=a,t[5]=s,t[6]=u):u=t[6];let f;t[7]!==c||t[8]!==l||t[9]!==u?(f={queryKey:c,queryFn:l,enabled:u},t[7]=c,t[8]=l,t[9]=u,t[10]=f):f=t[10];let{data:m,isLoading:h,error:g}=Nt(f),_;t[11]===m?_=t[12]:(_=m===void 0?[]:m,t[11]=m,t[12]=_);let v=_,[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(n);C!==n&&(w(n),S(!1),b(null));let T;t[13]!==x||t[14]!==v?(T=x?v:v.slice(0,Dg),t[13]=x,t[14]=v,t[15]=T):T=t[15];let E=T,D;t[16]!==r||t[17]!==y?(D=async function(e,t){if(!y){b(t);try{await U(e,{addPage:r,onCreated:jg}),b(null)}catch(e){let t=e;Xa.error(t instanceof Error?t.message:`Failed to create page`),b(null)}}},t[16]=r,t[17]=y,t[18]=D):D=t[18];let O=D,k;t[19]!==y||t[20]!==i||t[21]!==O||t[22]!==a||t[23]!==o||t[24]!==s?(k=function(e){if(e.kind===`external`){let t=e.title===e.url;return(0,Z.jsx)(Pg,{icon:(0,Z.jsx)(Ma,{className:`size-3.5`}),rowTooltip:`Opens in a new tab`,title:e.title,path:t?void 0:e.url,titleHover:e.url,snippet:e.snippet,href:e.url,external:!0},`ext:${e.url}`)}let t=d(e.docName,{pages:a,folderPaths:i,pagesBySlug:o}),n=!s&&t.kind===`create`,r=!s&&t.kind===`navigate`&&t.displayState===`folder`,c=Ag(e.docName),l=e.title===e.docName?c:e.title,u=`doc:${e.docName}:${e.anchor??``}`,f=er(t.kind===`navigate`?t.hashDocName:e.docName,e.anchor);if(n&&t.kind===`create`){let n={initialDir:t.initialDir,suggestedName:t.suggestedName};return(0,Z.jsx)(Pg,{icon:(0,Z.jsx)(Dn,{className:`size-3.5`}),iconColorClass:`text-amber-600 dark:text-amber-400`,rowTooltip:y===u?`Creating page`:`Missing page — click to create`,ariaLabel:y===u?`Creating page: ${e.title}.`:`Missing page: ${e.title}. Click to create.`,title:l,path:c,titleHover:e.docName,anchor:e.anchor,snippet:e.snippet,disabled:y!==null,onClick:()=>void O(n,u)},u)}if(r&&t.kind===`navigate`){let n=xt(t);return(0,Z.jsx)(Pg,{icon:(0,Z.jsx)(ks,{className:`size-3.5`}),iconColorClass:`text-sky-600 dark:text-sky-400`,ariaLabel:`Folder target: ${e.title}. Click to open the overview.`,title:l,path:c,titleHover:e.docName,anchor:e.anchor,snippet:e.snippet,href:f,hoverAction:{icon:(0,Z.jsx)(Fi,{className:`size-3.5`}),tooltip:y===u?`Creating index note`:`Create index note`,disabled:y!==null||n===null,onClick:()=>{n&&O(n,u)}}},u)}return(0,Z.jsx)(Pg,{icon:(0,Z.jsx)(p,{className:`size-3.5`}),title:l,path:c,titleHover:e.docName,anchor:e.anchor,snippet:e.snippet,href:f},u)},t[19]=y,t[20]=i,t[21]=O,t[22]=a,t[23]=o,t[24]=s,t[25]=k):k=t[25];let j=k,M;t[26]!==h||t[27]!==v.length?(M=(0,Z.jsx)(Mg,{title:`Outgoing`,count:v.length,isLoading:h}),t[26]=h,t[27]=v.length,t[28]=M):M=t[28];let P;t[29]!==g||t[30]!==x||t[31]!==h||t[32]!==v.length||t[33]!==j||t[34]!==E?(P=g?(0,Z.jsx)(`div`,{className:`px-3`,children:(0,Z.jsx)(jt,{children:g instanceof Error?g.message:`Failed to load outgoing links`})}):v.length===0&&!h?(0,Z.jsx)(`div`,{className:`px-3`,children:(0,Z.jsx)(Rt,{children:`This page doesn't link to anything yet.`})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`flex flex-col gap-1`,children:E.map(j)}),(0,Z.jsx)(Ng,{total:v.length,expanded:x,onToggle:()=>S(Rg)})]}),t[29]=g,t[30]=x,t[31]=h,t[32]=v.length,t[33]=j,t[34]=E,t[35]=P):P=t[35];let F;t[36]!==h||t[37]!==P?(F=(0,Z.jsx)(N,{children:(0,Z.jsx)(`div`,{className:`px-2 pb-3`,"aria-busy":h,children:P})}),t[36]=h,t[37]=P,t[38]=F):F=t[38];let I;return t[39]!==M||t[40]!==F?(I=(0,Z.jsxs)(A,{defaultOpen:!0,children:[M,F]}),t[39]=M,t[40]=F,t[41]=I):I=t[41],I}function Rg(e){return!e}function zg(e){let t=(0,$.c)(11),{docName:n,className:r}=e,i=r===void 0?``:r,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(Fg,{docName:n}),t[0]=n,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(Bi,{}),t[2]=o):o=t[2];let s;t[3]===n?s=t[4]:(s=(0,Z.jsx)(Lg,{docName:n}),t[3]=n,t[4]=s);let c;t[5]!==a||t[6]!==s?(c=(0,Z.jsxs)(Ht,{className:`px-0 py-0`,children:[a,o,s]}),t[5]=a,t[6]=s,t[7]=c):c=t[7];let l;return t[8]!==i||t[9]!==c?(l=(0,Z.jsx)(Kt,{className:i,children:c}),t[8]=i,t[9]=c,t[10]=l):l=t[10],l}var Bg=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}};new class extends Bg{};function Vg(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function Hg(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function Ug(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function Wg(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function Gg(e,t){return Ug(e,t,``)}function Kg(e,t){return Wg(e,t,``)}function qg(e,t){return t.slice(0,Jg(e,t))}function Jg(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function Yg(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function Xg(e,t){if(t)return Qg(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function Zg(e,t){if(t)return Qg(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function Qg(e,t){if(!t)return[Zg(e),Xg(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=Yg(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var $g=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,e_=RegExp(`[${$g}]+|\\s+|[^${$g}]`,`ug`);new class extends Bg{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=Yg(e,r)}else n=e.match(e_)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&t_(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&t_(n,i,r,null,t.intlSegmenter),e}};function t_(e,t,n,r,i){if(t&&n){let[a,o]=Qg(t.value,i),[s,c]=Qg(n.value,i);if(e){let r=Vg(a,s);e.value=Wg(e.value,s,r),t.value=Gg(t.value,r),n.value=Gg(n.value,r)}if(r){let e=Hg(o,c);r.value=Ug(r.value,c,e),t.value=Kg(t.value,e),n.value=Kg(n.value,e)}}else if(n){if(e){let e=Zg(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=Zg(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=Zg(r.value,i),[a,o]=Qg(t.value,i),s=Vg(n,a);t.value=Gg(t.value,s);let c=Hg(Gg(n,s),o);t.value=Kg(t.value,c),r.value=Ug(r.value,n,c),e.value=Wg(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=Zg(r.value,i),n=qg(Xg(t.value,i),e);t.value=Kg(t.value,n)}else if(e){let n=qg(Xg(e.value,i),Zg(t.value,i));t.value=Gg(t.value,n)}}new class extends Bg{tokenize(e){let t=RegExp(`(\\r?\\n)|[${$g}]+|[^\\S\\n\\r]+|[^${$g}]`,`ug`);return e.match(t)||[]}};var n_=new class extends Bg{constructor(){super(...arguments),this.tokenize=i_}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
15
|
+
`,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;xo(t,{style:t=>Fo(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 Qh.set(t.changes,i),i}function tg(e,t){let{state:n}=e,r=t??n.selection.main.head,i=e.state.field(sh).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(Zh);i.fromB!=i.toB&&i.toA<=o.length&&(a+=e.state.lineBreak);let s=vo.of({from:i.fromA,to:Math.min(o.length,i.toA),insert:a},o.length);return e.dispatch({effects:Xh.of({doc:s.apply(o),changes:s}),userEvent:`accept`}),!0}function ng(e,t){let{state:n}=e,r=t??n.selection.main.head,i=n.field(sh).find(e=>e.fromB<=r&&e.endB>=r);if(!i)return!1;let a=n.field(Zh).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 rg(e){let t=new wo;for(let n of e.field(sh)){let r=e.facet(ih).overrideChunk&&og(e,n);t.add(n.fromB,n.fromB,eg(e,n,!!r))}return t.finish()}var ig=bo.define({create:e=>rg(e),update(e,t){return t.state.field(sh,!1)==t.startState.field(sh,!1)?e:rg(t.state)},provide:e=>ko.decorations.from(e)}),ag=new WeakMap;function og(e,t){let n=ag.get(t);if(n!==void 0)return n;n=null;let r=e.field(Zh),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(Co.widget({widget:new sg(t),side:-1}).range(s+n.fromB))}n.fromB<n.toB&&e.push(Ch.range(s+n.fromB,s+n.toB))}i<t.endA-t.fromA-a*2&&(n=e)}return ag.set(t,n),n}var sg=class extends go{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}},cg=new class extends Ao{constructor(){super(...arguments),this.elementClass=`cm-inlineChangedLineGutter`}},lg=Co.line({class:`cm-inlineChangedLine`});function ug(e,t,n,r){let i=og(e,t),a=0;if(!i)return!1;for(let o=e.doc.lineAt(t.fromB);;){for(r&&r.add(o.from,o.from,cg),n.add(o.from,o.from,lg);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 dg=W({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}}),fg=gt({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}});function pg(e){let t=(0,$.c)(20),{oldContent:n,newContent:r,layout:i,conflictMode:a,onResolve:o,onAbort:s}=e,c=(0,Q.useRef)(null),l=(0,Q.useRef)(null),{resolvedTheme:u}=yr(),d=(0,Q.useRef)(o),f=(0,Q.useRef)(s),[p,m]=(0,Q.useState)(null),h;t[0]!==s||t[1]!==o?(h=()=>{d.current=o,f.current=s},t[0]=s,t[1]=o,t[2]=h):h=t[2],(0,Q.useEffect)(h);let g,v;t[3]!==a||t[4]!==i||t[5]!==r||t[6]!==n||t[7]!==u?(g=()=>{if(!c.current)return;let e=u===`dark`?dg:fg,t=[ko.editable.of(!1),yo.readOnly.of(!0)],o=[Ro,_(),...t,e,ko.lineWrapping];if(l.current&&=(l.current.destroy(),null),a){let t=new ko({doc:r,extensions:[Ro,_(),ko.editable.of(!1),e,ko.lineWrapping,Yh({original:n,highlightChanges:!0,gutter:!0,mergeControls:!0,collapseUnchanged:{margin:3,minSize:4}}),ko.updateListener.of(e=>{let t=ch(e.state);m(t?t.chunks.length:0)})],parent:c.current});l.current=t;let i=ch(t.state);m(i?i.chunks.length:0)}else i===`split`?l.current=new Gh({a:{doc:n,extensions:o},b:{doc:r,extensions:o},parent:c.current,highlightChanges:!0,gutter:!0,collapseUnchanged:{margin:3,minSize:4}}):l.current=new ko({doc:r,extensions:[...o,Yh({original:n,highlightChanges:!0,gutter:!0,mergeControls:!1,collapseUnchanged:{margin:3,minSize:4}})],parent:c.current});return()=>{l.current&&=(l.current.destroy(),null)}},v=[n,r,i,u,a],t[3]=a,t[4]=i,t[5]=r,t[6]=n,t[7]=u,t[8]=g,t[9]=v):(g=t[8],v=t[9]),(0,Q.useEffect)(g,v);let y;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(y=function(){let e=l.current;!e||!(e instanceof ko)||d.current?.(e.state.doc.toString())},t[10]=y):y=t[10];let b=y,x=p===0,S=p===null?``:p===0?`All hunks resolved`:`${p} unresolved hunk${p===1?``:`s`}`,C;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(`div`,{ref:c,className:`diff-view min-h-0 flex-1 overflow-y-auto subtle-scrollbar`}),t[11]=C):C=t[11];let w;t[12]!==x||t[13]!==a||t[14]!==S||t[15]!==s||t[16]!==o?(w=a&&(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 ${x?`text-emerald-600 dark:text-emerald-400`:`text-muted-foreground`}`,children:S}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s&&(0,Z.jsx)(X,{variant:`ghost`,size:`sm`,onClick:s,children:`Exit merge`}),o&&(0,Z.jsx)(X,{variant:`default`,size:`sm`,disabled:!x,onClick:b,children:`Save resolution`})]})]}),t[12]=x,t[13]=a,t[14]=S,t[15]=s,t[16]=o,t[17]=w):w=t[17];let T;return t[18]===w?T=t[19]:(T=(0,Z.jsxs)(`div`,{className:`flex flex-col h-full`,children:[C,w]}),t[18]=w,t[19]=T),T}function mg(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)(Ua,{"data-slot":`sheet`,...n}),t[2]=n,t[3]=r),r}function hg(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)(Ka,{"data-slot":`sheet-portal`,...n}),t[2]=n,t[3]=r),r}function gg(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=Y(`fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(za,{"data-slot":`sheet-overlay`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function _g(e){let t=(0,$.c)(17),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,side:a,showCloseButton:o,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=a===void 0?`right`:a,c=o===void 0?!0:o,l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(gg,{}),t[6]=l):l=t[6];let u;t[7]===r?u=t[8]:(u=Y(`fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10`,r),t[7]=r,t[8]=u);let d;t[9]===c?d=t[10]:(d=c&&(0,Z.jsx)(Ha,{"data-slot":`sheet-close`,asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`,children:[(0,Z.jsx)(Fa,{}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Close`})]})}),t[9]=c,t[10]=d);let f;return t[11]!==n||t[12]!==i||t[13]!==s||t[14]!==u||t[15]!==d?(f=(0,Z.jsxs)(hg,{children:[l,(0,Z.jsxs)(Ya,{"data-slot":`sheet-content`,"data-side":s,className:u,...i,children:[n,d]})]}),t[11]=n,t[12]=i,t[13]=s,t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function vg(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=Y(`flex flex-col gap-0.5 p-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`sheet-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function yg(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=Y(`font-heading text-base font-medium text-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Ba,{"data-slot":`sheet-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}async function bg(){try{let e=await fetch(`/api/sync/conflicts`);return e.ok?{conflicts:(await e.json()).conflicts??[]}:{conflicts:[],error:`server`}}catch{return{conflicts:[],error:`network`}}}async function xg(e){try{let t=await fetch(`/api/sync/conflict-content?file=${encodeURIComponent(e)}`);if(!t.ok)return{ours:``,theirs:``,base:``};let n=await t.json();return{ours:n.ours??``,theirs:n.theirs??``,base:n.base??``}}catch{return{ours:``,theirs:``,base:``}}}async function Sg(e,t,n){try{let r={file:e,strategy:t};return n!==void 0&&(r.content=n),(await fetch(`/api/sync/resolve-conflict`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)})).ok}catch{return!1}}var Cg=`w-[98vw] !max-w-[98vw] h-[96vh] flex flex-col gap-0 sm:!max-w-[98vw]`;function wg(e){let t=(0,$.c)(31),{file:n,onResolve:r,onAbort:i}=e,[a,o]=(0,Q.useState)(null),s,c;if(t[0]===n?(s=t[1],c=t[2]):(s=()=>{let e=!1;return xg(n).then(t=>{e||o(t)}),()=>{e=!0}},c=[n],t[0]=n,t[1]=s,t[2]=c),(0,Q.useEffect)(s,c),a===null){let e;t[3]===i?e=t[4]:(e=e=>!e&&i(),t[3]=i,t[4]=e);let r;t[5]===n?r=t[6]:(r=(0,Z.jsx)(qa,{className:`shrink-0`,children:(0,Z.jsxs)(Ra,{children:[`Resolving: `,n]})}),t[5]=n,t[6]=r);let a;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted-foreground`,children:`Loading`}),t[7]=a):a=t[7];let o;t[8]===r?o=t[9]:(o=(0,Z.jsxs)(Va,{className:Cg,children:[r,a]}),t[8]=r,t[9]=o);let s;return t[10]!==e||t[11]!==o?(s=(0,Z.jsx)(Ja,{open:!0,onOpenChange:e,children:o}),t[10]=e,t[11]=o,t[12]=s):s=t[12],s}let l;t[13]===i?l=t[14]:(l=e=>!e&&i(),t[13]=i,t[14]=l);let u;t[15]===n?u=t[16]:(u=(0,Z.jsxs)(Ra,{className:`text-sm font-medium`,children:[`Resolving: `,n]}),t[15]=n,t[16]=u);let d;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Red = your version (ours). Green = team's version (theirs). Accept each hunk to take theirs, reject to keep yours, then save.`}),t[17]=d):d=t[17];let f;t[18]===u?f=t[19]:(f=(0,Z.jsxs)(qa,{className:`px-4 pt-4 pb-2 shrink-0`,children:[u,d]}),t[18]=u,t[19]=f);let p;t[20]!==i||t[21]!==r||t[22]!==a.ours||t[23]!==a.theirs?(p=(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:(0,Z.jsx)(pg,{oldContent:a.ours,newContent:a.theirs,layout:`unified`,conflictMode:!0,onResolve:r,onAbort:i})}),t[20]=i,t[21]=r,t[22]=a.ours,t[23]=a.theirs,t[24]=p):p=t[24];let m;t[25]!==f||t[26]!==p?(m=(0,Z.jsxs)(Va,{className:`${Cg} p-0`,children:[f,p]}),t[25]=f,t[26]=p,t[27]=m):m=t[27];let h;return t[28]!==l||t[29]!==m?(h=(0,Z.jsx)(Ja,{open:!0,onOpenChange:l,children:m}),t[28]=l,t[29]=m,t[30]=h):h=t[30],h}function Tg(e){let t=(0,$.c)(50),{open:n,onOpenChange:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=[],t[0]=i):i=t[0];let[a,o]=(0,Q.useState)(i),[s,c]=(0,Q.useState)(null),l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l=new Set,t[1]=l):l=t[1];let[u,d]=(0,Q.useState)(l),f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=new Set,t[2]=f):f=t[2];let[p,m]=(0,Q.useState)(f),[h,g]=(0,Q.useState)(null),_;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=function(){bg().then(e=>{let{conflicts:t,error:n}=e;c(n??null),o(t),d(e=>{let n=new Set(t.map(Eg));return new Set([...e].filter(e=>!n.has(e)))})})},t[3]=_):_=t[3];let v=_,y,b;t[4]===n?(y=t[5],b=t[6]):(y=()=>{n&&v()},b=[n],t[4]=n,t[5]=y,t[6]=b),(0,Q.useEffect)(y,b);let x,S;t[7]===n?(x=t[8],S=t[9]):(x=()=>_r(e=>{e.includes(`sync-status`)&&n&&v()}),S=[n],t[7]=n,t[8]=x,t[9]=S),(0,Q.useEffect)(x,S);let C,w;t[10]!==a.length||t[11]!==r||t[12]!==n||t[13]!==u.size?(w=()=>{n&&a.length>0&&u.size>=a.length&&(Xa.success(`All conflicts resolved — sync resuming`),r(!1),d(new Set))},C=[n,a.length,u.size,r],t[10]=a.length,t[11]=r,t[12]=n,t[13]=u.size,t[14]=C,t[15]=w):(C=t[14],w=t[15]),(0,Q.useEffect)(w,C);let T;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(T=async function(e,t,n){m(t=>new Set([...t,e]));let r=await Sg(e,t,n);m(t=>{let n=new Set(t);return n.delete(e),n}),r?d(t=>new Set([...t,e])):Xa.error(`Failed to resolve ${e}`)},t[16]=T):T=t[16];let E=T,D;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(D=function(e){g(e)},t[17]=D):D=t[17];let O=D,k;t[18]===h?k=t[19]:(k=async function(e){if(!h)return;let t=h;g(null),await E(t,`content`,e)},t[18]=h,t[19]=k);let A=k,j;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(j=function(){g(null)},t[20]=j):j=t[20];let M=j,N;t[21]===r?N=t[22]:(N=async function(){try{(await fetch(`/api/sync/abort-merge`,{method:`POST`})).ok?Xa.info(`Merge aborted — sync paused`):Xa.error(`Failed to abort merge`)}catch{Xa.error(`Failed to abort merge — connection error`)}r(!1),d(new Set)},t[21]=r,t[22]=N);let P=N,F=a.length,I=u.size,L;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsx)(yg,{className:`text-sm font-medium`,children:`Resolve conflicts`}),t[23]=L):L=t[23];let R;t[24]!==I||t[25]!==F?(R=F>0&&(0,Z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[I,` of `,F,` resolved`]}),t[24]=I,t[25]=F,t[26]=R):R=t[26];let z;t[27]===R?z=t[28]:(z=(0,Z.jsxs)(vg,{className:`px-4 py-3 border-b shrink-0`,children:[L,R]}),t[27]=R,t[28]=z);let B;t[29]!==a||t[30]!==s||t[31]!==u||t[32]!==p?(B=(0,Z.jsx)(`div`,{className:`flex-1 overflow-y-auto subtle-scrollbar`,children:s?(0,Z.jsxs)(`div`,{className:`px-4 py-6 text-sm text-center space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-destructive`,children:s===`network`?`Could not reach the sync server — check your connection.`:`Sync server error — try again in a moment.`}),(0,Z.jsx)(X,{variant:`outline`,size:`sm`,onClick:v,children:`Retry`})]}):a.length===0?(0,Z.jsx)(`p`,{className:`px-4 py-6 text-sm text-muted-foreground text-center`,children:`No conflicts found.`}):(0,Z.jsx)(`ul`,{className:`divide-y`,children:a.map(e=>{let t=u.has(e.file),n=p.has(e.file),r=e.file.split(`/`).pop()??e.file;return(0,Z.jsxs)(`li`,{className:`px-4 py-3 ${t?`opacity-50`:``}`,children:[(0,Z.jsxs)(`p`,{className:`text-sm font-medium truncate mb-2`,title:e.file,children:[t?`✓ `:``,r]}),!t&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,Z.jsx)(X,{variant:`outline`,size:`xs`,disabled:n,onClick:()=>void E(e.file,`mine`),children:`Keep my version`}),(0,Z.jsx)(X,{variant:`outline`,size:`xs`,disabled:n,onClick:()=>void E(e.file,`theirs`),children:`Keep team's version`}),(0,Z.jsx)(X,{variant:`ghost`,size:`xs`,disabled:n,onClick:()=>O(e.file),children:`Resolve manually`})]})]},e.file)})})}),t[29]=a,t[30]=s,t[31]=u,t[32]=p,t[33]=B):B=t[33];let V;t[34]===P?V=t[35]:(V=(0,Z.jsx)(`div`,{className:`px-4 py-3 border-t shrink-0`,children:(0,Z.jsx)(X,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:P,children:`Exit merge`})}),t[34]=P,t[35]=V);let H;t[36]!==z||t[37]!==B||t[38]!==V?(H=(0,Z.jsxs)(_g,{side:`right`,className:`w-80 sm:w-96 flex flex-col gap-0 p-0`,children:[z,B,V]}),t[36]=z,t[37]=B,t[38]=V,t[39]=H):H=t[39];let U;t[40]!==r||t[41]!==n||t[42]!==H?(U=(0,Z.jsx)(mg,{open:n,onOpenChange:r,children:H}),t[40]=r,t[41]=n,t[42]=H,t[43]=U):U=t[43];let W;t[44]!==A||t[45]!==h?(W=h&&(0,Z.jsx)(wg,{file:h,onResolve:e=>void A(e),onAbort:M}),t[44]=A,t[45]=h,t[46]=W):W=t[46];let G;return t[47]!==U||t[48]!==W?(G=(0,Z.jsxs)(Z.Fragment,{children:[U,W]}),t[47]=U,t[48]=W,t[49]=G):G=t[49],G}function Eg(e){return e.file}var Dg=5;async function Og(e){let t=await fetch(`/api/backlinks?docName=${encodeURIComponent(e)}`),n=await t.json().catch(()=>null);if(!t.ok){let e=ir.safeParse(n);throw e.success?Error(e.data.title):new Ce(`Failed to parse backlinks error response (HTTP ${t.status})`,{status:t.status})}let r=fn.safeParse(n);if(!r.success)throw new Ce(`Backlinks response did not match expected shape.`,{status:t.status});return r.data.backlinks}async function kg(e){let t=await fetch(`/api/forward-links?docName=${encodeURIComponent(e)}`),n=await t.json().catch(()=>null);if(!t.ok){let e=ir.safeParse(n);throw e.success?Error(e.data.title):new Ce(`Failed to parse forward-links error response (HTTP ${t.status})`,{status:t.status})}let r=Zn.safeParse(n);if(!r.success)throw new Ce(`Forward-links response did not match expected shape.`,{status:t.status});return r.data.forwardLinks}function Ag(e){let t=e.split(`/`);return t.length<=2?e:`…/${t.slice(-2).join(`/`)}`}function jg(e){window.location.hash=er(e)}function Mg(e){let t=(0,$.c)(9),{title:n,count:r,isLoading:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Ie,{className:`size-3.5 text-muted-foreground transition-transform group-data-[state=closed]:-rotate-90`}),t[0]=a):a=t[0];let o;t[1]===n?o=t[2]:(o=(0,Z.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[a,(0,Z.jsx)(Gt,{children:n})]}),t[1]=n,t[2]=o);let s;t[3]!==r||t[4]!==i?(s=!i&&(0,Z.jsx)(Wt,{children:r}),t[3]=r,t[4]=i,t[5]=s):s=t[5];let c;return t[6]!==o||t[7]!==s?(c=(0,Z.jsxs)(R,{className:`group flex w-full cursor-pointer items-center justify-between px-5 py-3 text-left transition-colors hover:bg-muted/40`,children:[o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function Ng(e){let t=(0,$.c)(7),{total:n,expanded:r,onToggle:i}=e;if(n<=Dg)return null;let a=n-Dg,o;t[0]===r?o=t[1]:(o=r?(0,Z.jsx)(Ie,{className:`size-3`}):(0,Z.jsx)(l,{className:`size-3`}),t[0]=r,t[1]=o);let s=r?`Show fewer`:`Show ${a} more`,c;return t[2]!==r||t[3]!==i||t[4]!==o||t[5]!==s?(c=(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":r,className:`mt-2 inline-flex cursor-pointer items-center gap-1 px-3 text-xs text-muted-foreground transition-colors hover:text-foreground`,onClick:i,children:[o,s]}),t[2]=r,t[3]=i,t[4]=o,t[5]=s,t[6]=c):c=t[6],c}function Pg(e){let t=(0,$.c)(38),{icon:n,iconColorClass:r,rowTooltip:i,title:a,path:o,anchor:s,snippet:c,titleHover:l,ariaLabel:u,href:d,external:f,disabled:p,onClick:m,hoverAction:h}=e,g=o!==void 0&&o!==a,_=r??`text-muted-foreground`,v;t[0]===_?v=t[1]:(v=Y(`mt-0.5 shrink-0`,_),t[0]=_,t[1]=v);let y;t[2]!==n||t[3]!==v?(y=(0,Z.jsx)(`span`,{className:v,children:n}),t[2]=n,t[3]=v,t[4]=y):y=t[4];let b=y,x;t[5]!==u||t[6]!==p||t[7]!==f||t[8]!==d||t[9]!==m||t[10]!==a||t[11]!==l?(x=d?(0,Z.jsxs)(`a`,{href:d,target:f?`_blank`:void 0,rel:f?`noopener noreferrer`:void 0,"aria-label":u,title:l,onClick:m,className:`block w-full truncate text-left font-medium text-foreground no-underline outline-none after:absolute after:inset-0 after:rounded-md focus-visible:after:ring-2 focus-visible:after:ring-ring`,children:[a,f?(0,Z.jsx)(`span`,{className:`sr-only`,children:` (opens in new tab)`}):null]}):(0,Z.jsx)(`button`,{type:`button`,"aria-label":u,title:l,disabled:p,onClick:m,className:Y(`block w-full truncate text-left font-medium text-foreground no-underline outline-none after:absolute after:inset-0 after:rounded-md focus-visible:after:ring-2 focus-visible:after:ring-ring`,`cursor-pointer bg-transparent p-0 disabled:cursor-not-allowed disabled:opacity-60`),children:a}),t[5]=u,t[6]=p,t[7]=f,t[8]=d,t[9]=m,t[10]=a,t[11]=l,t[12]=x):x=t[12];let S=x,C;t[13]===b?C=t[14]:(C=(0,Z.jsx)(`div`,{className:`mt-px flex items-center`,children:b}),t[13]=b,t[14]=C);let w;t[15]!==s||t[16]!==o||t[17]!==g?(w=g?(0,Z.jsxs)(`div`,{className:`truncate font-mono text-xs text-muted-foreground`,children:[o,s?(0,Z.jsxs)(`span`,{className:`ml-1`,children:[`· #`,s]}):null]}):null,t[15]=s,t[16]=o,t[17]=g,t[18]=w):w=t[18];let T;t[19]===c?T=t[20]:(T=c?(0,Z.jsx)(`p`,{className:`line-clamp-2 text-muted-foreground`,children:c}):null,t[19]=c,t[20]=T);let E;t[21]!==S||t[22]!==w||t[23]!==T?(E=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5 text-1sm`,children:[S,w,T]}),t[21]=S,t[22]=w,t[23]=T,t[24]=E):E=t[24];let D;t[25]===h?D=t[26]:(D=h?(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"aria-label":h.tooltip,disabled:h.disabled,className:`relative z-10 shrink-0 cursor-pointer rounded-md p-1 text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-muted-foreground group-hover:opacity-100`,onClick:h.onClick,children:h.icon})}),(0,Z.jsx)(co,{side:`top`,children:h.tooltip})]}):null,t[25]=h,t[26]=D);let O;t[27]!==C||t[28]!==E||t[29]!==D?(O=(0,Z.jsxs)(`div`,{className:`group relative flex items-start gap-2.5 rounded-md px-3 py-2.5 transition-colors hover:bg-muted/80`,children:[C,E,D]}),t[27]=C,t[28]=E,t[29]=D,t[30]=O):O=t[30];let k=O;if(i){let e;t[31]===k?e=t[32]:(e=(0,Z.jsx)(so,{asChild:!0,children:k}),t[31]=k,t[32]=e);let n;t[33]===i?n=t[34]:(n=(0,Z.jsx)(co,{side:`top`,children:i}),t[33]=i,t[34]=n);let r;return t[35]!==e||t[36]!==n?(r=(0,Z.jsxs)(uo,{children:[e,n]}),t[35]=e,t[36]=n,t[37]=r):r=t[37],r}return k}function Fg(e){let t=(0,$.c)(33),{docName:n}=e,{folderPaths:r,pages:i,loading:a}=wr(),o,s;t[0]===n?(o=t[1],s=t[2]):(o=[`backlinks`,n],s=()=>Og(n),t[0]=n,t[1]=o,t[2]=s);let c;t[3]!==n||t[4]!==a||t[5]!==i?(c=!a&&i.has(n),t[3]=n,t[4]=a,t[5]=i,t[6]=c):c=t[6];let l;t[7]!==o||t[8]!==s||t[9]!==c?(l={queryKey:o,queryFn:s,enabled:c},t[7]=o,t[8]=s,t[9]=c,t[10]=l):l=t[10];let{data:u,isLoading:d,error:f}=Nt(l),m;t[11]===u?m=t[12]:(m=u===void 0?[]:u,t[11]=u,t[12]=m);let h=m,[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(n);v!==n&&(y(n),_(!1));let b;t[13]!==h||t[14]!==g?(b=g?h:h.slice(0,Dg),t[13]=h,t[14]=g,t[15]=b):b=t[15];let x=b,S;t[16]!==h.length||t[17]!==d?(S=(0,Z.jsx)(Mg,{title:`Backlinks`,count:h.length,isLoading:d}),t[16]=h.length,t[17]=d,t[18]=S):S=t[18];let C;t[19]!==h.length||t[20]!==f||t[21]!==g||t[22]!==r||t[23]!==d||t[24]!==i||t[25]!==x?(C=f?(0,Z.jsx)(`div`,{className:`px-3`,children:(0,Z.jsx)(jt,{children:f instanceof Error?f.message:`Failed to load backlinks`})}):h.length===0&&!d?(0,Z.jsx)(`div`,{className:`px-3`,children:(0,Z.jsx)(Rt,{children:`No pages link here yet.`})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`flex flex-col gap-1`,children:x.map((e,t)=>{let n=Na(e.source,{pages:i,folderPaths:r});return(0,Z.jsx)(Pg,{icon:(0,Z.jsx)(p,{className:`size-3.5`}),title:e.title,path:Ag(e.source),titleHover:e.source,anchor:e.anchor,snippet:e.snippet,href:er(n.hashDocName,e.anchor)},`${e.source}-${t}`)})}),(0,Z.jsx)(Ng,{total:h.length,expanded:g,onToggle:()=>_(Ig)})]}),t[19]=h.length,t[20]=f,t[21]=g,t[22]=r,t[23]=d,t[24]=i,t[25]=x,t[26]=C):C=t[26];let w;t[27]!==d||t[28]!==C?(w=(0,Z.jsx)(N,{children:(0,Z.jsx)(`div`,{className:`px-2 pb-3`,"aria-busy":d,children:C})}),t[27]=d,t[28]=C,t[29]=w):w=t[29];let T;return t[30]!==w||t[31]!==S?(T=(0,Z.jsxs)(A,{defaultOpen:!0,children:[S,w]}),t[30]=w,t[31]=S,t[32]=T):T=t[32],T}function Ig(e){return!e}function Lg(e){let t=(0,$.c)(42),{docName:n}=e,{addPage:r,folderPaths:i,pages:a,pagesBySlug:o,loading:s}=wr(),c,l;t[0]===n?(c=t[1],l=t[2]):(c=[`forward-links`,n],l=()=>kg(n),t[0]=n,t[1]=c,t[2]=l);let u;t[3]!==n||t[4]!==a||t[5]!==s?(u=!s&&a.has(n),t[3]=n,t[4]=a,t[5]=s,t[6]=u):u=t[6];let f;t[7]!==c||t[8]!==l||t[9]!==u?(f={queryKey:c,queryFn:l,enabled:u},t[7]=c,t[8]=l,t[9]=u,t[10]=f):f=t[10];let{data:m,isLoading:h,error:g}=Nt(f),_;t[11]===m?_=t[12]:(_=m===void 0?[]:m,t[11]=m,t[12]=_);let v=_,[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(n);C!==n&&(w(n),S(!1),b(null));let T;t[13]!==x||t[14]!==v?(T=x?v:v.slice(0,Dg),t[13]=x,t[14]=v,t[15]=T):T=t[15];let E=T,D;t[16]!==r||t[17]!==y?(D=async function(e,t){if(!y){b(t);try{await U(e,{addPage:r,onCreated:jg}),b(null)}catch(e){let t=e;Xa.error(t instanceof Error?t.message:`Failed to create page`),b(null)}}},t[16]=r,t[17]=y,t[18]=D):D=t[18];let O=D,k;t[19]!==y||t[20]!==i||t[21]!==O||t[22]!==a||t[23]!==o||t[24]!==s?(k=function(e){if(e.kind===`external`){let t=e.title===e.url;return(0,Z.jsx)(Pg,{icon:(0,Z.jsx)(Ma,{className:`size-3.5`}),rowTooltip:`Opens in a new tab`,title:e.title,path:t?void 0:e.url,titleHover:e.url,snippet:e.snippet,href:e.url,external:!0},`ext:${e.url}`)}let t=d(e.docName,{pages:a,folderPaths:i,pagesBySlug:o}),n=!s&&t.kind===`create`,r=!s&&t.kind===`navigate`&&t.displayState===`folder`,c=Ag(e.docName),l=e.title===e.docName?c:e.title,u=`doc:${e.docName}:${e.anchor??``}`,f=er(t.kind===`navigate`?t.hashDocName:e.docName,e.anchor);if(n&&t.kind===`create`){let n={initialDir:t.initialDir,suggestedName:t.suggestedName};return(0,Z.jsx)(Pg,{icon:(0,Z.jsx)(Dn,{className:`size-3.5`}),iconColorClass:`text-amber-600 dark:text-amber-400`,rowTooltip:y===u?`Creating page`:`Missing page — click to create`,ariaLabel:y===u?`Creating page: ${e.title}.`:`Missing page: ${e.title}. Click to create.`,title:l,path:c,titleHover:e.docName,anchor:e.anchor,snippet:e.snippet,disabled:y!==null,onClick:()=>void O(n,u)},u)}if(r&&t.kind===`navigate`){let n=xt(t);return(0,Z.jsx)(Pg,{icon:(0,Z.jsx)(ks,{className:`size-3.5`}),iconColorClass:`text-sky-600 dark:text-sky-400`,ariaLabel:`Folder target: ${e.title}. Click to open the overview.`,title:l,path:c,titleHover:e.docName,anchor:e.anchor,snippet:e.snippet,href:f,hoverAction:{icon:(0,Z.jsx)(Fi,{className:`size-3.5`}),tooltip:y===u?`Creating index note`:`Create index note`,disabled:y!==null||n===null,onClick:()=>{n&&O(n,u)}}},u)}return(0,Z.jsx)(Pg,{icon:(0,Z.jsx)(p,{className:`size-3.5`}),title:l,path:c,titleHover:e.docName,anchor:e.anchor,snippet:e.snippet,href:f},u)},t[19]=y,t[20]=i,t[21]=O,t[22]=a,t[23]=o,t[24]=s,t[25]=k):k=t[25];let j=k,M;t[26]!==h||t[27]!==v.length?(M=(0,Z.jsx)(Mg,{title:`Outgoing`,count:v.length,isLoading:h}),t[26]=h,t[27]=v.length,t[28]=M):M=t[28];let P;t[29]!==g||t[30]!==x||t[31]!==h||t[32]!==v.length||t[33]!==j||t[34]!==E?(P=g?(0,Z.jsx)(`div`,{className:`px-3`,children:(0,Z.jsx)(jt,{children:g instanceof Error?g.message:`Failed to load outgoing links`})}):v.length===0&&!h?(0,Z.jsx)(`div`,{className:`px-3`,children:(0,Z.jsx)(Rt,{children:`This page doesn't link to anything yet.`})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`flex flex-col gap-1`,children:E.map(j)}),(0,Z.jsx)(Ng,{total:v.length,expanded:x,onToggle:()=>S(Rg)})]}),t[29]=g,t[30]=x,t[31]=h,t[32]=v.length,t[33]=j,t[34]=E,t[35]=P):P=t[35];let F;t[36]!==h||t[37]!==P?(F=(0,Z.jsx)(N,{children:(0,Z.jsx)(`div`,{className:`px-2 pb-3`,"aria-busy":h,children:P})}),t[36]=h,t[37]=P,t[38]=F):F=t[38];let I;return t[39]!==M||t[40]!==F?(I=(0,Z.jsxs)(A,{defaultOpen:!0,children:[M,F]}),t[39]=M,t[40]=F,t[41]=I):I=t[41],I}function Rg(e){return!e}function zg(e){let t=(0,$.c)(11),{docName:n,className:r}=e,i=r===void 0?``:r,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(Lg,{docName:n}),t[0]=n,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(Bi,{}),t[2]=o):o=t[2];let s;t[3]===n?s=t[4]:(s=(0,Z.jsx)(Fg,{docName:n}),t[3]=n,t[4]=s);let c;t[5]!==a||t[6]!==s?(c=(0,Z.jsxs)(Ht,{className:`px-0 py-0`,children:[a,o,s]}),t[5]=a,t[6]=s,t[7]=c):c=t[7];let l;return t[8]!==i||t[9]!==c?(l=(0,Z.jsx)(Kt,{className:i,children:c}),t[8]=i,t[9]=c,t[10]=l):l=t[10],l}var Bg=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}};new class extends Bg{};function Vg(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function Hg(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function Ug(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function Wg(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function Gg(e,t){return Ug(e,t,``)}function Kg(e,t){return Wg(e,t,``)}function qg(e,t){return t.slice(0,Jg(e,t))}function Jg(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function Yg(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function Xg(e,t){if(t)return Qg(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function Zg(e,t){if(t)return Qg(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function Qg(e,t){if(!t)return[Zg(e),Xg(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=Yg(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var $g=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,e_=RegExp(`[${$g}]+|\\s+|[^${$g}]`,`ug`);new class extends Bg{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=Yg(e,r)}else n=e.match(e_)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&t_(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&t_(n,i,r,null,t.intlSegmenter),e}};function t_(e,t,n,r,i){if(t&&n){let[a,o]=Qg(t.value,i),[s,c]=Qg(n.value,i);if(e){let r=Vg(a,s);e.value=Wg(e.value,s,r),t.value=Gg(t.value,r),n.value=Gg(n.value,r)}if(r){let e=Hg(o,c);r.value=Ug(r.value,c,e),t.value=Kg(t.value,e),n.value=Kg(n.value,e)}}else if(n){if(e){let e=Zg(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=Zg(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=Zg(r.value,i),[a,o]=Qg(t.value,i),s=Vg(n,a);t.value=Gg(t.value,s);let c=Hg(Gg(n,s),o);t.value=Kg(t.value,c),r.value=Ug(r.value,n,c),e.value=Wg(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=Zg(r.value,i),n=qg(Xg(t.value,i),e);t.value=Kg(t.value,n)}else if(e){let n=qg(Xg(e.value,i),Zg(t.value,i));t.value=Gg(t.value,n)}}new class extends Bg{tokenize(e){let t=RegExp(`(\\r?\\n)|[${$g}]+|[^\\S\\n\\r]+|[^${$g}]`,`ug`);return e.match(t)||[]}};var n_=new class extends Bg{constructor(){super(...arguments),this.tokenize=i_}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
16
16
|
`))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
|
|
17
17
|
`))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
18
18
|
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
@@ -31,7 +31,7 @@ This template lives at an ancestor folder — deleting affects every folder unde
|
|
|
31
31
|
This template lives in your user home (~/.ok/templates/) — deleting affects every OK project you open with this user account.`:``}`}),t[37]=c,t[38]=f,t[39]=_,t[40]=k):k=t[40],t[41]!==D||t[42]!==O||t[43]!==k?(w=(0,Z.jsx)(Ja,{open:D,onOpenChange:O,children:k}),t[41]=D,t[42]=O,t[43]=k,t[44]=w):w=t[44],y=Hi,b=n,x=new Set(e.map($D)),t[7]=c,t[8]=f,t[9]=o,t[10]=n,t[11]=_,t[12]=i,t[13]=v,t[14]=y,t[15]=b,t[16]=x,t[17]=S,t[18]=C,t[19]=w}else y=t[14],b=t[15],x=t[16],S=t[17],C=t[18],w=t[19];let T;t[45]!==y||t[46]!==m||t[47]!==i||t[48]!==b||t[49]!==x?(T=(0,Z.jsx)(y,{folderPath:b,existingNames:x,open:m,onOpenChange:h,onCreated:i}),t[45]=y,t[46]=m,t[47]=i,t[48]=b,t[49]=x,t[50]=T):T=t[50];let E=u!==null,D;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>{e||d(null)},t[51]=D):D=t[51];let O=u??void 0,k;t[52]!==a||t[53]!==n||t[54]!==O||t[55]!==E?(k=(0,Z.jsx)(Pf,{open:E,onOpenChange:D,kind:`file`,initialDir:n,initialTemplate:O,folderConfig:a}),t[52]=a,t[53]=n,t[54]=O,t[55]=E,t[56]=k):k=t[56];let A;return t[57]!==k||t[58]!==S||t[59]!==C||t[60]!==w||t[61]!==T?(A=(0,Z.jsxs)(Z.Fragment,{children:[S,C,w,T,k]}),t[57]=k,t[58]=S,t[59]=C,t[60]=w,t[61]=T,t[62]=A):A=t[62],A}function $D(e){return e.name}function eO(e){return e.scope!==`user`}function tO(e){let t=(0,$.c)(43),{template:n,onCreate:r,onEdit:i,onDelete:a}=e,o=n.title&&n.title!==n.name,s=n.title??n.name,c;t[0]===s?c=t[1]:(c=(0,Z.jsx)(`span`,{className:`font-medium truncate`,children:s}),t[0]=s,t[1]=c);let l;t[2]!==o||t[3]!==n.name?(l=o?(0,Z.jsx)(`code`,{className:`font-mono text-xs text-muted-foreground shrink-0`,children:n.name}):null,t[2]=o,t[3]=n.name,t[4]=l):l=t[4];let u;t[5]===n.scope?u=t[6]:(u=n.scope===`inherited`?(0,Z.jsx)(Ne,{variant:`gray`,className:`ml-auto shrink-0 text-2xs`,children:`inherited`}):null,t[5]=n.scope,t[6]=u);let d;t[7]===n.scope?d=t[8]:(d=n.scope===`user`?(0,Z.jsx)(Ne,{variant:`primary`,className:`ml-auto shrink-0 text-2xs`,children:`user`}):null,t[7]=n.scope,t[8]=d);let f;t[9]!==c||t[10]!==l||t[11]!==u||t[12]!==d?(f=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[c,l,u,d]}),t[9]=c,t[10]=l,t[11]=u,t[12]=d,t[13]=f):f=t[13];let p;t[14]===n.description?p=t[15]:(p=n.description?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground truncate mt-0.5`,children:n.description}):null,t[14]=n.description,t[15]=p);let m;t[16]!==i||t[17]!==f||t[18]!==p?(m=(0,Z.jsxs)(`button`,{type:`button`,onClick:i,className:`min-w-0 flex-1 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm`,children:[f,p]}),t[16]=i,t[17]=f,t[18]=p,t[19]=m):m=t[19];let h=`Create note from ${s}`,g;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(Cs,{className:`size-3.5`,"aria-hidden":!0}),t[20]=g):g=t[20];let _;t[21]!==r||t[22]!==h?(_=(0,Z.jsxs)(X,{type:`button`,variant:`ghost`,size:`sm`,className:`font-mono uppercase shrink-0 opacity-0 group-hover:opacity-100 focus-visible:opacity-100`,onClick:r,"aria-label":h,children:[g,`Create`]}),t[21]=r,t[22]=h,t[23]=_):_=t[23];let v=`Actions for ${s}`,y;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(hi,{className:`size-4`,"aria-hidden":!0}),t[24]=y):y=t[24];let b;t[25]===v?b=t[26]:(b=(0,Z.jsx)(Si,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon`,className:`size-7 shrink-0 opacity-0 group-hover:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100`,"aria-label":v,children:y})}),t[25]=v,t[26]=b);let x;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(be,{"aria-hidden":!0}),t[27]=x):x=t[27];let S;t[28]===i?S=t[29]:(S=(0,Z.jsxs)(di,{onSelect:i,children:[x,`Edit`]}),t[28]=i,t[29]=S);let C;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(fe,{"aria-hidden":!0}),t[30]=C):C=t[30];let w;t[31]===a?w=t[32]:(w=(0,Z.jsxs)(di,{variant:`destructive`,onSelect:a,children:[C,`Delete`]}),t[31]=a,t[32]=w);let T;t[33]!==S||t[34]!==w?(T=(0,Z.jsxs)(Aa,{align:`end`,children:[S,w]}),t[33]=S,t[34]=w,t[35]=T):T=t[35];let E;t[36]!==b||t[37]!==T?(E=(0,Z.jsxs)(ji,{children:[b,T]}),t[36]=b,t[37]=T,t[38]=E):E=t[38];let D;return t[39]!==_||t[40]!==E||t[41]!==m?(D=(0,Z.jsxs)(`li`,{className:`group flex items-center gap-2 rounded-md px-2 py-2 hover:bg-muted/50 text-sm`,children:[m,_,E]}),t[39]=_,t[40]=E,t[41]=m,t[42]=D):D=t[42],D}function nO(e){let t=(0,$.c)(14),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,containerClassName:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=Y(`relative w-full overflow-x-auto subtle-scrollbar`,r),t[4]=r,t[5]=a);let o;t[6]===n?o=t[7]:(o=Y(`w-full caption-bottom text-sm`,n),t[6]=n,t[7]=o);let s;t[8]!==i||t[9]!==o?(s=(0,Z.jsx)(`table`,{"data-slot":`table`,className:o,...i}),t[8]=i,t[9]=o,t[10]=s):s=t[10];let c;return t[11]!==a||t[12]!==s?(c=(0,Z.jsx)(`div`,{"data-slot":`table-container`,className:a,children:s}),t[11]=a,t[12]=s,t[13]=c):c=t[13],c}function rO(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=Y(`[&_tr]:border-b`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`thead`,{"data-slot":`table-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function iO(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=Y(`[&_tr:last-child]:border-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`tbody`,{"data-slot":`table-body`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function aO(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,noHover:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=(i===void 0?!1:i)&&`hover:bg-transparent`,o;t[4]!==n||t[5]!==a?(o=Y(`hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors`,a,n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==o?(s=(0,Z.jsx)(`tr`,{"data-slot":`table-row`,className:o,...r}),t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function oO(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,scope:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`col`:i,o;t[4]===n?o=t[5]:(o=Y(`font-mono uppercase text-xs text-muted-foreground h-10 px-4 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,n),t[4]=n,t[5]=o);let s;return t[6]!==r||t[7]!==a||t[8]!==o?(s=(0,Z.jsx)(`th`,{"data-slot":`table-head`,scope:a,className:o,...r}),t[6]=r,t[7]=a,t[8]=o,t[9]=s):s=t[9],s}function sO(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=Y(`py-3 px-4 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`td`,{"data-slot":`table-cell`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function cO(e){if(!e)return`—`;let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<30?`${a}d ago`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function lO(e,t,n){return[...e].sort((e,r)=>{if(e.kind!==r.kind)return e.kind===`folder`?-1:1;let i=0;switch(t){case`name`:i=e.title.localeCompare(r.title)||e.name.localeCompare(r.name);break;case`modified`:{let t=e.kind===`file`?e.modified:``,n=r.kind===`file`?r.modified:``;i=t.localeCompare(n);break}}return n===`asc`?i:-i})}function uO(e){let t=(0,$.c)(10),{label:n,sortKey:r,activeKey:i,activeDir:a,onSort:o}=e,s=i===r,c;t[0]!==o||t[1]!==r?(c=()=>o(r),t[0]=o,t[1]=r,t[2]=c):c=t[2];let l;t[3]!==a||t[4]!==s?(l=s?a===`asc`?(0,Z.jsx)(P,{className:`ml-1 size-3`}):(0,Z.jsx)(z,{className:`ml-1 size-3`}):(0,Z.jsx)(ts,{className:`ml-1 size-3 text-muted-foreground/50`}),t[3]=a,t[4]=s,t[5]=l):l=t[5];let u;return t[6]!==n||t[7]!==c||t[8]!==l?(u=(0,Z.jsxs)(X,{variant:`ghost`,size:`sm`,className:`-ml-3 h-8 uppercase font-mono`,onClick:c,children:[n,l]}),t[6]=n,t[7]=c,t[8]=l,t[9]=u):u=t[9],u}function dO(e){let t=(0,$.c)(81),{folderPath:n}=e,{folderPaths:r,loading:i,pages:a,pageTitles:o,pageMeta:s}=wr(),c=ra(n),{state:l,refresh:u}=c,[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(`name`),[h,g]=(0,Q.useState)(`asc`);if(i){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Gi,{className:`size-5 rounded`}),(0,Z.jsx)(Gi,{className:`h-7 w-48`})]}),(0,Z.jsx)(Gi,{className:`h-9 w-20 rounded-md`})]}),t[0]=e):e=t[0];let n;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(Gi,{className:`h-4 w-16`}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start overflow-y-auto subtle-scrollbar`,role:`status`,"aria-busy":`true`,"aria-label":`Loading folder contents`,children:(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-8`,children:[e,(0,Z.jsxs)(`div`,{className:`rounded-lg border`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-4 border-b px-4 py-3`,children:[n,(0,Z.jsx)(`div`,{className:`ml-auto`,children:(0,Z.jsx)(Gi,{className:`h-4 w-20`})})]}),[`a`,`b`,`c`,`d`].map(mO)]})]})}),t[2]=r):r=t[2],r}let _,v,y,b,x,S,C,w,T,E;if(t[3]!==l||t[4]!==c||t[5]!==n||t[6]!==r||t[7]!==s||t[8]!==o||t[9]!==a||t[10]!==u||t[11]!==h||t[12]!==p){let e=ZD(n,{pages:a,pageTitles:o,pageMeta:s,folderPaths:r}),i=lO(e.children,p,h),d;t[23]===p?d=t[24]:(d=function(e){e===p?g(pO):(m(e),g(`asc`))},t[23]=p,t[24]=d);let D=d;E=`flex min-h-0 flex-1 items-start overflow-y-auto subtle-scrollbar`,S=`mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-8`;let O;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(G,{className:`size-5 text-muted-foreground`}),t[25]=O):O=t[25];let k=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[O,(0,Z.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:e.title})]}),A;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsxs)(X,{onClick:()=>f(!0),children:[(0,Z.jsx)(Fi,{className:`size-4`}),`New`]}),t[26]=A):A=t[26],t[27]===k?C=t[28]:(C=(0,Z.jsx)(`div`,{className:`flex flex-col gap-6`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[k,A]})}),t[27]=k,t[28]=C),t[29]!==l||t[30]!==n||t[31]!==u?(w=(0,Z.jsx)(GD,{folderPath:n,state:l,onChange:u}),t[29]=l,t[30]=n,t[31]=u,t[32]=w):w=t[32],t[33]!==l||t[34]!==c||t[35]!==n||t[36]!==u?(T=(0,Z.jsx)(QD,{folderPath:n,state:l,onChange:u,folderConfigHandle:c}),t[33]=l,t[34]=c,t[35]=n,t[36]=u,t[37]=T):T=t[37],x=`rounded-lg border`,v=nO;let j=p===`name`?h===`asc`?`ascending`:`descending`:`none`,M;t[38]!==D||t[39]!==h||t[40]!==p?(M=(0,Z.jsx)(uO,{label:`Name`,sortKey:`name`,activeKey:p,activeDir:h,onSort:D}),t[38]=D,t[39]=h,t[40]=p,t[41]=M):M=t[41];let N;t[42]!==j||t[43]!==M?(N=(0,Z.jsx)(oO,{"aria-sort":j,children:M}),t[42]=j,t[43]=M,t[44]=N):N=t[44];let P=p===`modified`?h===`asc`?`ascending`:`descending`:`none`,F;t[45]!==D||t[46]!==h||t[47]!==p?(F=(0,Z.jsx)(uO,{label:`Modified`,sortKey:`modified`,activeKey:p,activeDir:h,onSort:D}),t[45]=D,t[46]=h,t[47]=p,t[48]=F):F=t[48];let I;t[49]!==P||t[50]!==F?(I=(0,Z.jsx)(oO,{className:`w-32`,"aria-sort":P,children:F}),t[49]=P,t[50]=F,t[51]=I):I=t[51],t[52]!==N||t[53]!==I?(b=(0,Z.jsx)(rO,{children:(0,Z.jsxs)(aO,{children:[N,I]})}),t[52]=N,t[53]=I,t[54]=b):b=t[54],_=iO,y=i.length?i.map(fO):(0,Z.jsx)(aO,{children:(0,Z.jsx)(sO,{colSpan:2,className:`h-24 text-center text-muted-foreground`,children:`This folder is empty.`})}),t[3]=l,t[4]=c,t[5]=n,t[6]=r,t[7]=s,t[8]=o,t[9]=a,t[10]=u,t[11]=h,t[12]=p,t[13]=_,t[14]=v,t[15]=y,t[16]=b,t[17]=x,t[18]=S,t[19]=C,t[20]=w,t[21]=T,t[22]=E}else _=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];let D;t[55]!==_||t[56]!==y?(D=(0,Z.jsx)(_,{children:y}),t[55]=_,t[56]=y,t[57]=D):D=t[57];let O;t[58]!==v||t[59]!==b||t[60]!==D?(O=(0,Z.jsxs)(v,{children:[b,D]}),t[58]=v,t[59]=b,t[60]=D,t[61]=O):O=t[61];let k;t[62]!==O||t[63]!==x?(k=(0,Z.jsx)(`div`,{className:x,children:O}),t[62]=O,t[63]=x,t[64]=k):k=t[64];let A;t[65]!==k||t[66]!==S||t[67]!==C||t[68]!==w||t[69]!==T?(A=(0,Z.jsxs)(`div`,{className:S,children:[C,w,T,k]}),t[65]=k,t[66]=S,t[67]=C,t[68]=w,t[69]=T,t[70]=A):A=t[70];let j;t[71]!==A||t[72]!==E?(j=(0,Z.jsx)(`div`,{className:E,children:A}),t[71]=A,t[72]=E,t[73]=j):j=t[73];let M;t[74]!==d||t[75]!==c||t[76]!==n?(M=(0,Z.jsx)(Pf,{open:d,onOpenChange:f,kind:`file`,initialDir:n,folderConfig:c,suggestedName:`index`}),t[74]=d,t[75]=c,t[76]=n,t[77]=M):M=t[77];let N;return t[78]!==j||t[79]!==M?(N=(0,Z.jsxs)(Z.Fragment,{children:[j,M]}),t[78]=j,t[79]=M,t[80]=N):N=t[80],N}function fO(e){return(0,Z.jsxs)(aO,{children:[(0,Z.jsx)(sO,{children:(0,Z.jsxs)(`a`,{href:er(e.path),className:`flex items-center gap-2 rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[e.kind===`folder`?(0,Z.jsx)(ks,{className:`size-4 shrink-0 text-muted-foreground`}):(0,Z.jsx)(p,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.title})]})}),(0,Z.jsx)(sO,{className:`text-muted-foreground`,children:e.kind===`file`?cO(e.modified):`—`})]},e.path)}function pO(e){return e===`asc`?`desc`:`asc`}function mO(e){return(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 border-b px-4 py-3 last:border-b-0`,children:[(0,Z.jsx)(Gi,{className:`size-4 rounded`}),(0,Z.jsx)(Gi,{className:`h-4 w-40`}),(0,Z.jsx)(`div`,{className:`ml-auto`,children:(0,Z.jsx)(Gi,{className:`h-4 w-16`})})]},e)}function hO(e){let t=(0,$.c)(7),{docName:n}=e,[r,i]=(0,Q.useState)(gO),a,o;if(t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>ue(e=>{i(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})}),o=[],t[0]=a,t[1]=o):(a=t[0],o=t[1]),(0,Q.useEffect)(a,o),!r.has(n))return null;let s;t[2]===n?s=t[3]:(s=function(){Ue(n)?.abort(),i(e=>{if(!e.has(n))return e;let t=new Set(e);return t.delete(n),t})},t[2]=n,t[3]=s);let c=s,l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`span`,{children:`Still loading`}),t[4]=l):l=t[4];let u;return t[5]===c?u=t[6]:(u=(0,Z.jsxs)(`div`,{className:`absolute inset-x-0 bottom-8 z-20 flex justify-center text-xs text-muted-foreground`,children:[l,(0,Z.jsx)(X,{variant:`link`,size:`sm`,className:`h-auto px-2 py-0 text-xs`,onClick:c,children:`Cancel`})]}),t[5]=c,t[6]=u),u}function gO(){return new Set}var _O=(0,Q.createContext)(null);function vO(e){let t=(0,$.c)(7),{children:n}=e,[r,i]=(0,Q.useState)(yO),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>{i(t=>{let n=new Map(t);return n.set(e,(t.get(e)??0)+1),n})},t[0]=a):a=t[0];let o=a,s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=e=>{i(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},t[1]=s):s=t[1];let c=s,l;t[2]===r?l=t[3]:(l={addPropertySignal:r,requestAddProperty:o,clearAddProperty:c},t[2]=r,t[3]=l);let u=l,d;return t[4]!==n||t[5]!==u?(d=(0,Z.jsx)(_O,{value:u,children:n}),t[4]=n,t[5]=u,t[6]=d):d=t[6],d}function yO(){return new Map}function bO(){let e=(0,Q.use)(_O);if(e===null)throw Error(`useProperties must be used within <PropertyProvider />`);return e}function xO(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=Y(`flex h-full w-full aria-[orientation=vertical]:flex-col`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Ly,{"data-slot":`resizable-panel-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function SO(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)(By,{"data-slot":`resizable-panel`,...n}),t[2]=n,t[3]=r),r}function CO(e){let t=(0,$.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({withHandle:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=Y(`relative flex w-px items-center justify-center bg-border ring-offset-background after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90`,n),t[4]=n,t[5]=a);let o;t[6]===i?o=t[7]:(o=i&&(0,Z.jsx)(`div`,{className:`z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border`}),t[6]=i,t[7]=o);let s;return t[8]!==r||t[9]!==a||t[10]!==o?(s=(0,Z.jsx)(Wy,{"data-slot":`resizable-handle`,className:a,...r,children:o}),t[8]=r,t[9]=a,t[10]=o,t[11]=s):s=t[11],s}var wO=960,TO=1024;function EO(){let e=(0,$.c)(5),[t,n]=(0,Q.useState)(OO),[r,i]=(0,Q.useState)(DO),a,o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{let e=window.matchMedia(`(max-width: ${wO-1}px)`),t=window.matchMedia(`(max-width: ${TO-1}px)`),r=()=>{let r=e.matches;n(r?`sheet`:`panel`),i(!r&&t.matches)};return e.addEventListener(`change`,r),t.addEventListener(`change`,r),()=>{e.removeEventListener(`change`,r),t.removeEventListener(`change`,r)}},o=[],e[0]=a,e[1]=o):(a=e[0],o=e[1]),(0,Q.useEffect)(a,o);let s;return e[2]!==r||e[3]!==t?(s={layout:t,autoCollapse:r},e[2]=r,e[3]=t,e[4]=s):s=e[4],s}function DO(){return window.innerWidth>=wO&&window.innerWidth<TO}function OO(){return window.innerWidth<wO?`sheet`:`panel`}var kO={words:0,chars:0,tokens:0},AO=/[ -〿-ゟ゠-ヿ㐀-䶿一-鿿豈---ក-]/,jO=/[\p{L}\p{N}]/u,MO=new Set([`text`,`inlineCode`,`code`,`tag`]),NO=new Set([`html`,`definition`,`footnoteDefinition`,`yaml`,`toml`,`image`,`imageReference`,`mdxFlowExpression`,`mdxTextExpression`,`mdxjsEsm`,`rawMdxFallback`,`rawMdxFallbackMdast`]),PO=new Set([`paragraph`,`heading`,`blockquote`,`list`,`listItem`,`thematicBreak`,`table`,`tableRow`,`tableCell`,`mdxJsxFlowElement`,`commentBlock`]);function FO(e,t){if(!e)return;let n=e.type;if(!NO.has(n)){if(MO.has(n)){e.value&&(t.push(e.value),n===`code`&&t.push(`
|
|
32
32
|
`));return}if(n===`wikiLink`||n===`wikiLinkEmbed`){let n=e.data?.alias??e.value??``;n&&t.push(n);return}if(Array.isArray(e.children)){for(let n of e.children)FO(n,t);if(PO.has(n)&&t.length>0){let e=t[t.length-1];e&&!e.endsWith(`
|
|
33
33
|
`)&&t.push(`
|
|
34
|
-
`)}}}}function IO(e){try{let t=f().parseToMdast(e),n=[];return FO(t,n),n.join(``).trim()}catch(t){return console.warn(`[document-stats] mdast parse failed, falling back to raw text`,t),e.trim()}}function LO(e){if(!e)return 0;let t=0;for(let n of e.split(/\s+/))jO.test(n)&&t++;return t}function RO(e){let t=globalThis.Intl.Segmenter;if(!t)return LO(e);let n=new t(void 0,{granularity:`word`}),r=0;for(let t of n.segment(e))t.isWordLike&&r++;return r}function zO(e){let t=AO.test(e)?1.5:4;return Math.ceil(e.length/t)}function BO(e){if(!e)return{words:0,chars:0,tokens:0};let{body:t}=Sn(e);if(!t.trim())return{words:0,chars:0,tokens:0};let n=IO(t);return n?{words:AO.test(n)?RO(n):LO(n),chars:n.length,tokens:zO(n)}:{words:0,chars:0,tokens:0}}var VO=300;function HO(e,t){let n=(0,$.c)(4),[r,i]=(0,Q.useState)(kO),a,o;return n[0]!==t||n[1]!==e?(a=()=>{if(!e||!t){i(kO);return}let n=e.document.getText(`source`),r=!1,a=null,o=function(){r||i(BO(n.toString()))};o();let s=function(){a&&clearTimeout(a),a=setTimeout(o,VO)};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 UO(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`?WO: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 WO(e){return e===`synced`?`synced`:`connected`}var GO=nr;function KO(e,t={}){let n=oe(e.componentName);return n.name===`*`?t.unregisteredSuffix?`${e.componentName} (unregistered)`:e.componentName:n.displayName??n.name}var qO=200,JO=`Outside any block`;function YO(e){let t=(0,$.c)(5),{editor:n}=e,r=ce(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?XO(n,r):o.current?JO:``,a.current=window.setTimeout(()=>{i.current&&(i.current.textContent=``,i.current.textContent=t),o.current=e,a.current=null},qO),()=>{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 XO(e,t){if(!t||t.ancestorChain.length===0)return``;let n=t.ancestorChain,r=n[n.length-1],i=KO(r,{unregisteredSuffix:!0});if(n.length===1)return`Selected: ${i}`;let a=n[n.length-2],o=KO(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 ZO(){let[e]=(0,Q.useState)(jr);return e}function QO({principal:e,identity:t}){return e&&e.source===`git-config`?{type:`human`,name:Yn(e.display_name),color:Sr(e.id,In),coeditor:t.coeditor,tabId:t.tabId,principalId:e.id}:e&&e.source===`synthesized`?{type:`human`,name:t.name,color:Sr(e.id,In),coeditor:t.coeditor,tabId:t.tabId}:{type:`human`,name:t.name,color:t.color,coeditor:t.coeditor,tabId:t.tabId}}function $O(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 ek=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&&Fr(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(Qt(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(xn(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(_n(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(rn(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(an(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(tn(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(rr(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(hn(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=Nr(this.view,e.from,e.to),r={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof nn){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 zn){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():$O(o.getBoundingClientRect(),s.getBoundingClientRect());r={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return r}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&ar(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()}},tk=e=>new bn({key:typeof e.pluginKey==`string`?new or(e.pluginKey):e.pluginKey,view:t=>new ek({view:t,...e})});Tr.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[tk({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 nk=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 Qn(e,{textSerializers:Xn(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(Qt(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(xn(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(_n(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(rn(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(an(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(tn(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(rr(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(hn(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=Nr(this.view,e.from,e.to);ar({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()}},rk=e=>new bn({key:typeof e.pluginKey==`string`?new or(e.pluginKey):e.pluginKey,view:t=>new nk({view:t,...e})});Tr.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?[rk({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 ik(e,t){return e??new or(t)}var ak=typeof window<`u`?Q.useLayoutEffect:Q.useEffect,ok=new Set([`left`,`opacity`,`position`,`top`,`visibility`,`width`]),sk=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(`.`)),ck=new Set([`children`,`className`,`style`]),lk=new Set([`tabIndex`]),uk=new Set([`accessKey`,`autoCapitalize`,`contentEditable`,`contextMenu`,`dir`,`draggable`,`enterKeyHint`,`hidden`,`id`,`lang`,`nonce`,`role`,`slot`,`spellCheck`,`tabIndex`,`title`,`translate`]),dk={Blur:`focusout`,DoubleClick:`dblclick`,Focus:`focusin`,MouseEnter:`mouseenter`,MouseLeave:`mouseleave`};function fk(e,t){return/^on[A-Z]/.test(e)&&typeof t==`function`}function pk(e){return e.startsWith(`aria-`)||e.startsWith(`data-`),e}function mk(e){return e.startsWith(`aria-`)||e.startsWith(`data-`)||uk.has(e)}function hk(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function gk(e){let t=e.endsWith(`Capture`),n=(t?e.slice(0,-7):e).slice(2);return{eventName:dk[n]??n.toLowerCase(),options:t?{capture:!0}:void 0}}function _k(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 vk(e){return lk.has(e)}function yk(e,t,n){if(t===`tabIndex`){e.tabIndex=Number(n);return}e[t]=n}function bk(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 xk(e,t){return typeof t!=`number`||t===0||e.startsWith(`--`)||sk.has(e)?String(t):`${t}px`}function Sk(e,t){ok.has(t)||e.style.removeProperty(hk(t))}function Ck(e,t,n){ok.has(t)||e.style.setProperty(hk(t),xk(t,n))}function wk(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(r=>{if(ck.has(r)||!mk(r)||fk(r,t[r])||fk(r,n[r]))return;let i=t[r],a=n[r];if(i===a)return;let o=pk(r);if(a==null||a===!1){vk(r)&&bk(e,r),e.removeAttribute(o);return}if(a===!0){vk(r)&&yk(e,r,!0),e.setAttribute(o,``);return}if(vk(r)){yk(e,r,a);return}e.setAttribute(o,String(a))})}function Tk(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute(`class`)}}function Ek(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){Sk(e,t);return}Ck(e,t,a)}})}function Dk(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(!fk(t,n))return;let{eventName:i,options:a}=gk(t),o=t=>{n(_k(e,t))};e.addEventListener(i,o,a),r.push({eventName:i,listener:o,options:a})}),r}function Ok(e,t){let n=(0,Q.useRef)({}),r=(0,Q.useRef)([]);ak(()=>{let i=n.current;return Tk(e,i.className,t.className),Ek(e,i.style,t.style),wk(e,i,t),r.current=Dk(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 kk=Q.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,getReferencedVirtualElement:o,options:s,children:l,...u},d)=>{let f=(0,Q.useRef)(document.createElement(`div`)),p=(0,Q.useRef)(ik(e,`bubbleMenu`)).current;Ok(f.current,u),typeof d==`function`?d(f.current):d&&(d.current=f.current);let{editor:m}=c(),h=t||m,g={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:p,shouldShow:a,getReferencedVirtualElement:o,options:s},_=(0,Q.useRef)(g);_.current=g;let[v,y]=(0,Q.useState)(!1),b=(0,Q.useRef)(!0);return(0,Q.useEffect)(()=>{if(h?.isDestroyed)return;if(!h){console.warn(`BubbleMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=f.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=tk({..._.current,editor:h,element:e});h.registerPlugin(t);let n=_.current.pluginKey;return b.current=!0,y(!0),()=>{y(!1),h.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[h]),(0,Q.useEffect)(()=>{if(!(!v||!h||h.isDestroyed)){if(b.current){b.current=!1;return}h.view.dispatch(h.state.tr.setMeta(p,{type:`updateOptions`,options:_.current}))}},[v,h,n,r,a,s,i,o,p]),(0,is.createPortal)(l,f.current)});Q.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,options:o,children:s,...l},u)=>{let d=(0,Q.useRef)(document.createElement(`div`)),f=(0,Q.useRef)(ik(e,`floatingMenu`)).current;Ok(d.current,l),typeof u==`function`?u(d.current):u&&(u.current=d.current);let{editor:p}=c(),m=t||p,h={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:f,shouldShow:a,options:o},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(`FloatingMenu 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=rk({...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,o,i,f]),(0,is.createPortal)(s,d.current)});var Ak=[{name:`paragraph`,label:`Text`,icon:Xs,isActive:e=>e.isActive(`paragraph`)&&!e.isActive(`list`),command:e=>e.chain().focus().setParagraph().run()},{name:`heading1`,label:`Heading 1`,icon:me,isActive:e=>e.isActive(`heading`,{level:1}),command:e=>e.chain().focus().toggleHeading({level:1}).run()},{name:`heading2`,label:`Heading 2`,icon:yt,isActive:e=>e.isActive(`heading`,{level:2}),command:e=>e.chain().focus().toggleHeading({level:2}).run()},{name:`heading3`,label:`Heading 3`,icon:dt,isActive:e=>e.isActive(`heading`,{level:3}),command:e=>e.chain().focus().toggleHeading({level:3}).run()},{name:`bulletList`,label:`Bullet List`,icon:He,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:De,isActive:e=>e.isActive(`list`,{ordered:!0}),command:e=>e.chain().focus().toggleOrderedList().run()},{name:`taskList`,label:`Task List`,icon:Ae,isActive:e=>e.isActive(`listItem`,{checked:!0})||e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleTaskList().run()},{name:`blockquote`,label:`Quote`,icon:ut,isActive:e=>e.isActive(`blockquote`),command:e=>e.chain().focus().toggleBlockquote().run()},{name:`codeBlock`,label:`Code Block`,icon:sc,isActive:e=>e.isActive(`codeBlock`),command:e=>e.chain().focus().toggleCodeBlock().run()}];function jk(e){let t=(0,$.c)(18),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:Mk},t[0]=n,t[1]=r);let{current:i,activeStates:a}=Se(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)(Ie,{className:`size-3 opacity-50`}),t[6]=l):l=t[6];let u;t[7]!==s||t[8]!==c?(u=(0,Z.jsx)(Si,{asChild:!0,children:(0,Z.jsxs)(X,{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=Ak.map(e=>{let t=e.icon,r=a[e.name];return(0,Z.jsxs)(di,{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)(Aa,{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)(ji,{children:[u,f]}),t[15]=u,t[16]=f,t[17]=p):p=t[17],p}function Mk(e){let t=Object.fromEntries(Ak.map(t=>[t.name,t.isActive(e.editor)]));return{current:Ak.find(e=>t[e.name])??Ak[0],activeStates:t}}function Nk(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 Pk(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:V(typeof n.src==`string`?n.src:``)}function Fk(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 Ik(e){let t=(0,$.c)(10),{editor:n}=e,r;if(t[0]===n?r=t[1]:(r={editor:n,selector:Lk},t[0]=n,t[1]=r),Se(r)===null)return null;let i;t[2]===n?i=t[3]:(i=e=>{e.preventDefault();let t=Nk(n);t&&Fk(t,Pk(n))},t[2]=n,t[3]=i);let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Oi,{className:`size-3.5`}),t[4]=a):a=t[4];let o;t[5]===i?o=t[6]:(o=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":`Download file`,className:`text-accent-foreground`,onMouseDown:i,children:a})}),t[5]=i,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(co,{side:`bottom`,sideOffset:8,children:`Download file`}),t[7]=s):s=t[7];let c;return t[8]===o?c=t[9]:(c=(0,Z.jsx)(`div`,{className:`flex items-center gap-0.5`,children:(0,Z.jsxs)(uo,{children:[o,s]})}),t[8]=o,t[9]=c),c}function Lk(e){return Nk(e.editor)}function Rk(e){return Nk(e)!==null}var zk=[{value:`left`,label:`Align left`,icon:Je},{value:`center`,label:`Align center`,icon:_e},{value:`right`,label:`Align right`,icon:it}];function Bk(e){let t=e.state.selection.node;if(!t||t.type.name!==`jsxComponent`)return null;let n=t.attrs.componentName;if(n!==`img`&&n!==`CommonMarkImage`&&n!==`Embed`)return null;let r=(t.attrs.props??{}).align;return r===`left`||r===`right`||r===`center`?r:`center`}function Vk(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:Hk},t[0]=n,t[1]=r);let i=Se(r);if(i===null)return null;let a;t[2]!==i||t[3]!==n?(a=zk.map(e=>{let{value:t,label:r,icon:a}=e,o=i===t;return(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{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(a!==`img`&&a!==`CommonMarkImage`&&a!==`Embed`||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(nn.create(u.doc,s)),Ee(n.view.nodeDOM(s),()=>{n.view.dispatch(u)})},children:(0,Z.jsx)(a,{className:`size-3.5`})})}),(0,Z.jsx)(co,{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 Hk(e){return Bk(e.editor)}function Uk(e){return Bk(e)!==null}var Wk=[{name:`bold`,icon:rs,command:e=>e.chain().focus().toggleBold().run(),isActive:e=>e.isActive(`strong`),shortcut:`⌘B`},{name:`italic`,icon:Ps,command:e=>e.chain().focus().toggleItalic().run(),isActive:e=>e.isActive(`emphasis`),shortcut:`⌘I`},{name:`underline`,icon:gc,command:e=>e.chain().focus().toggleUnderline().run(),isActive:e=>e.isActive(`underline`),shortcut:`⌘U`},{name:`strikethrough`,icon:dc,command:e=>e.chain().focus().toggleStrike().run(),isActive:e=>e.isActive(`strike`),shortcut:`⌘⇧X`},{name:`code`,icon:ms,command:e=>e.chain().focus().toggleCode().run(),isActive:e=>e.isActive(`code`),shortcut:`⌘E`},{name:`highlight`,icon:Ns,command:e=>e.chain().focus().toggleHighlight().run(),isActive:e=>e.isActive(`highlight`),shortcut:`⌘⇧H`}];function Gk(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:Kk},t[0]=n,t[1]=r);let i=Se(r),a;t[2]!==i||t[3]!==n?(a=Wk.map(e=>{let t=e.icon,r=i[e.name];return(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{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)(co,{side:`bottom`,sideOffset:8,children:[(0,Z.jsx)(`span`,{className:`capitalize`,children:e.name}),(0,Z.jsx)(`kbd`,{className:`ml-1.5 text-[10px] opacity-60`,children:e.shortcut})]})]},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 Kk(e){return Object.fromEntries(Wk.map(t=>[t.name,t.isActive(e.editor)]))}function qk(e){let t=(0,$.c)(46),{editor:n}=e,[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),s=(0,Q.useRef)(null),c;t[0]===n?c=t[1]:(c=n.isActive(`link`),t[0]=n,t[1]=c);let l=c,u;t[2]===n?u=t[3]:(u=n.getAttributes(`link`).href??``,t[2]=n,t[3]=u);let d=u,f,p;t[4]===n?(f=t[5],p=t[6]):(f=()=>{let e=function(){n.state.selection.empty&&i(!1)};return n.on(`selectionUpdate`,e),()=>{n.off(`selectionUpdate`,e)}},p=[n],t[4]=n,t[5]=f,t[6]=p),(0,Q.useEffect)(f,p);let m,h;t[7]!==d||t[8]!==r?(m=()=>{r&&(o(d),requestAnimationFrame(()=>s.current?.focus()))},h=[r,d],t[7]=d,t[8]=r,t[9]=m,t[10]=h):(m=t[9],h=t[10]),(0,Q.useEffect)(m,h);let g;t[11]!==n||t[12]!==l||t[13]!==a?(g=function(){a.trim()?n.chain().focus().setLink({href:a.trim()}).run():l&&n.chain().focus().unsetLink().run(),i(!1)},t[11]=n,t[12]=l,t[13]=a,t[14]=g):g=t[14];let _=g,v;t[15]===n?v=t[16]:(v=function(){n.chain().focus().unsetLink().run(),i(!1)},t[15]=n,t[16]=v);let y=v,b;t[17]!==_||t[18]!==n?(b=function(e){e.key===`Enter`&&(e.preventDefault(),_()),e.key===`Escape`&&(e.preventDefault(),i(!1),n.chain().focus().run())},t[17]=_,t[18]=n,t[19]=b):b=t[19];let x=b;if(r){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=e=>o(e.target.value),t[20]=e):e=t[20];let n;t[21]!==x||t[22]!==a?(n=(0,Z.jsx)(`input`,{ref:s,type:`url`,placeholder:`Paste link`,value:a,onChange:e,onKeyDown:x,"aria-label":`Link URL`,className:`h-5 w-44 bg-transparent text-sm border-none outline-none placeholder:text-muted-foreground`}),t[21]=x,t[22]=a,t[23]=n):n=t[23];let r;t[24]===_?r=t[25]:(r=()=>{_()},t[24]=_,t[25]=r);let i;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(ys,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[26]=i):i=t[26];let c;t[27]===r?c=t[28]:(c=(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":`Apply link`,onClick:r,children:i}),t[27]=r,t[28]=c);let u;t[29]!==n||t[30]!==c?(u=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border bg-background px-2 py-1`,children:[n,c]}),t[29]=n,t[30]=c,t[31]=u):u=t[31];let f;t[32]!==d||t[33]!==l||t[34]!==y?(f=l&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":`Open link in new tab`,onMouseDown:e=>{e.preventDefault(),ne(d)},children:(0,Z.jsx)(Ma,{className:`size-3.5`})})}),(0,Z.jsx)(co,{side:`bottom`,sideOffset:8,children:`Open link in new tab`})]}),(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":`Remove link`,onMouseDown:e=>{e.preventDefault(),y()},children:(0,Z.jsx)(fe,{className:`size-3.5`})})}),(0,Z.jsx)(co,{side:`bottom`,sideOffset:8,children:`Remove link`})]})]}),t[32]=d,t[33]=l,t[34]=y,t[35]=f):f=t[35];let p;return t[36]!==u||t[37]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[u,f]}),t[36]=u,t[37]=f,t[38]=p):p=t[38],p}let S=l?`bg-accent text-primary`:`text-accent-foreground`,C,w;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{e.preventDefault(),i(!0)},w=(0,Z.jsx)(zs,{className:`size-3.5`}),t[39]=C,t[40]=w):(C=t[39],w=t[40]);let T;t[41]===S?T=t[42]:(T=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":`Insert link`,className:S,onMouseDown:C,children:w})}),t[41]=S,t[42]=T);let E;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsxs)(co,{side:`bottom`,sideOffset:8,children:[`Link`,(0,Z.jsx)(`kbd`,{className:`ml-1.5 text-[10px] opacity-60`,children:`⌘K`})]}),t[43]=E):E=t[43];let D;return t[44]===T?D=t[45]:(D=(0,Z.jsxs)(uo,{children:[T,E]}),t[44]=T,t[45]=D),D}function Jk({editor:e}){if(e.isActive(`codeBlock`))return!1;if(Uk(e)||Rk(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 Yk(e){let t=(0,$.c)(22),{editor:n}=e,r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(0),o=(0,Q.useRef)(null),s;t[0]===n?s=t[1]:(s={editor:n,selector:eA},t[0]=n,t[1]=s);let c=Se(s),l;t[2]===n?l=t[3]:(l={editor:n,selector:$k},t[2]=n,t[3]=l);let u=Se(l),d;t[4]!==n.state||t[5]!==n.view?(d=()=>{try{let{from:e,to:t}=n.state.selection;return Nr(n.view,e,t)}catch{return new DOMRect}},t[4]=n.state,t[5]=n.view,t[6]=d):d=t[6];let f;if(t[7]!==n.view.dom||t[8]!==d){let e={getBoundingClientRect:d,contextElement:n.view.dom};f=()=>{let t=r.current;t&&(o.current?.(),o.current=yn(e,t,()=>{ar(e,t,{placement:`top`,strategy:`fixed`,middleware:[_n(8),Qt(),xn({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(Qk)}))},t[7]=n.view.dom,t[8]=d,t[9]=f}else f=t[9];let p=f,m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{o.current?.(),o.current=null,a(Zk)},t[10]=m):m=t[10];let h=m,g;t[11]===p?g=t[12]:(g={onShow:p,onHide:h,strategy:`fixed`},t[11]=p,t[12]=g);let _;t[13]!==n||t[14]!==u||t[15]!==c||t[16]!==i?(_=c?(0,Z.jsx)(Vk,{editor:n},`${i}-img-align`):u?(0,Z.jsx)(Ik,{editor:n},`${i}-file`):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(jk,{editor:n}),(0,Z.jsx)(Bi,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),(0,Z.jsx)(Gk,{editor:n},i),(0,Z.jsx)(Bi,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),(0,Z.jsx)(qk,{editor:n},`${i}-link`)]}),t[13]=n,t[14]=u,t[15]=c,t[16]=i,t[17]=_):_=t[17];let v;return t[18]!==n||t[19]!==g||t[20]!==_?(v=(0,Z.jsx)(kk,{ref:r,editor:n,appendTo:Xk,shouldShow:Jk,updateDelay:250,options:g,className:`z-50 flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:_}),t[18]=n,t[19]=g,t[20]=_,t[21]=v):v=t[21],v}function Xk(){return document.body}function Zk(e){return e+1}function Qk(){}function $k(e){return Rk(e.editor)}function eA(e){return Uk(e.editor)}var tA=[{name:`addRowBefore`,icon:P,label:`Add row above`,command:e=>e.chain().focus().addRowBefore().run()},{name:`addRowAfter`,icon:z,label:`Add row below`,command:e=>e.chain().focus().addRowAfter().run()},{name:`deleteRow`,icon:fe,label:`Delete row`,command:e=>e.chain().focus().deleteRow().run()}],nA=[{name:`addColumnBefore`,icon:ti,label:`Add column left`,command:e=>e.chain().focus().addColumnBefore().run()},{name:`addColumnAfter`,icon:oa,label:`Add column right`,command:e=>e.chain().focus().addColumnAfter().run()},{name:`deleteColumn`,icon:fe,label:`Delete column`,command:e=>e.chain().focus().deleteColumn().run()}],rA=[{name:`toggleHeaderRow`,icon:pc,label:`Toggle header row`,command:e=>e.chain().focus().toggleHeaderRow().run()},{name:`toggleHeaderColumn`,icon:gs,label:`Toggle header column`,command:e=>e.chain().focus().toggleHeaderColumn().run()},{name:`deleteTable`,icon:js,label:`Delete table`,command:e=>e.chain().focus().deleteTable().run()}];function iA({editor:e}){return e.isActive(`table`)}function aA(e){let t=(0,$.c)(14),{action:n,editor:r}=e,i=n.icon,a;t[0]!==n||t[1]!==r?(a=e=>{e.preventDefault(),n.command(r)},t[0]=n,t[1]=r,t[2]=a):a=t[2];let o;t[3]===i?o=t[4]:(o=(0,Z.jsx)(i,{className:`size-3.5`}),t[3]=i,t[4]=o);let s;t[5]!==n.label||t[6]!==a||t[7]!==o?(s=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":n.label,className:`text-muted-foreground`,onMouseDown:a,children:o})}),t[5]=n.label,t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;t[9]===n.label?c=t[10]:(c=(0,Z.jsx)(co,{side:`bottom`,sideOffset:8,children:n.label}),t[9]=n.label,t[10]=c);let l;return t[11]!==s||t[12]!==c?(l=(0,Z.jsxs)(uo,{children:[s,c]}),t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function oA(e){let t=(0,$.c)(13),{editor:n}=e,r;t[0]===n?r=t[1]:(r=tA.map(e=>(0,Z.jsx)(aA,{action:e,editor:n},e.name)),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(Bi,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[2]=i):i=t[2];let a;t[3]===n?a=t[4]:(a=nA.map(e=>(0,Z.jsx)(aA,{action:e,editor:n},e.name)),t[3]=n,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(Bi,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[5]=o):o=t[5];let s;t[6]===n?s=t[7]:(s=rA.map(e=>(0,Z.jsx)(aA,{action:e,editor:n},e.name)),t[6]=n,t[7]=s);let c;return t[8]!==n||t[9]!==r||t[10]!==a||t[11]!==s?(c=(0,Z.jsxs)(kk,{editor:n,shouldShow:iA,updateDelay:100,className:`flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:[r,i,a,o,s]}),t[8]=n,t[9]=r,t[10]=a,t[11]=s,t[12]=c):c=t[12],c}var sA=new WeakMap;function cA(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=Or(e.color),n.textContent=e.name,t.append(n),t}var lA={state:`idle`,count:0,lastFiredAt:null,position:`append`,lastAgentId:null};function uA(){let e=new Mr({extensions:Nn});return{mdManager:e,text:S({mdManager:e}),html:re({mdManager:e}),paste:$e({mdManager:e}),drop:D({mdManager:e})}}function dA(e){let{provider:t,placeholder:n,prebuiltMapping:r}=e;return[...Xe.map(e=>e.name===`link`||e.name===`wikiLink`?e.configure({docName:t.configuration.name??``}):e),GO.configure({placeholder:n??`Type '/' for commands`,showOnlyCurrent:!0}),C.configure({document:t.document,...r?{ySyncOptions:{mapping:r}}:{}}),Tr.create({name:`imageUploadDecoration`,addProseMirrorPlugins(){return[s]}}),Tr.create({name:`collaborationCursor`,addProseMirrorPlugins(){let e=t.awareness;if(!e)throw Error(`[TiptapEditor] HocuspocusProvider has no awareness instance — cursor plugin cannot initialize`);return[k(e,{cursorBuilder:cA})]}})]}function fA(e){let{provider:t,clipboard:n,ctorStart:r}=e;return{onBeforeCreate:({editor:e})=>{sA.set(e,r)},onCreate:({editor:e})=>{n.html.setView(e.view);let r=sA.get(e);if(sA.delete(e),r==null)return;let i=performance.now();Ge(`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:(e,t)=>n.drop(e,t)},extensions:ld(dA(e))}}function pA(e){let{provider:t,placeholder:n,clipboard:r,ctorStart:i}=e,a=ur(dA({provider:t,placeholder:n,clipboard:r,ctorStart:i})),{doc:o,mapping:s}=T(t.document.getXmlFragment(`default`),a);return{...fA({provider:t,placeholder:n,clipboard:r,ctorStart:i,prebuiltMapping:s}),content:o.toJSON(),element:null}}var mA=e=>{let t=(0,$.c)(21),{provider:n,placeholder:r,isSourceMode:i,portalTarget:a}=e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(lA),c=ZO(),{principal:l,activeDocName:u}=We(),d=n.configuration.name??``,[f]=(0,Q.useState)(uA),p;t[0]!==f||t[1]!==r||t[2]!==n?(p=()=>()=>({editor:new hr(pA({provider:n,placeholder:r,clipboard:f,ctorStart:performance.now()})),ydoc:n.document,ytext:n.document.getText(`source`),provider:n}),t[0]=f,t[1]=r,t[2]=n,t[3]=p):p=t[3];let[m]=(0,Q.useState)(p),h,g;if(t[4]!==m||t[5]!==d||t[6]!==n.document){let e={viewCount:0,bytes:n.document.getText(`source`).length},r=bt(d)??crypto.randomUUID();h=Q.use,g=Oe({docName:d,mountId:r,construct:m,sizeStats:e}),t[4]=m,t[5]=d,t[6]=n.document,t[7]=h,t[8]=g}else h=t[7],g=t[8];let _=h(g),v=_.editor,y,b;t[9]===_?(y=t[10],b=t[11]):(y=()=>()=>{xe(_)},b=[_],t[9]=_,t[10]=y,t[11]=b),(0,Q.useEffect)(y,b);let x;return t[12]!==u||t[13]!==d||t[14]!==v||t[15]!==c||t[16]!==i||t[17]!==a||t[18]!==l||t[19]!==n?(x=(0,Z.jsx)(hA,{provider:n,isSourceMode:i,docName:d,activeDocName:u,identity:c,principal:l,editor:v,wrapperRef:o,flashStateRef:s,portalTarget:a}),t[12]=u,t[13]=d,t[14]=v,t[15]=c,t[16]=i,t[17]=a,t[18]=l,t[19]=n,t[20]=x):x=t[20],x},hA=e=>{let t=(0,$.c)(71),{provider:n,isSourceMode:r,docName:i,activeDocName:a,identity:o,principal:s,editor:c,wrapperRef:l,flashStateRef:u,portalTarget:d}=e,f=(0,Q.useRef)(null),p,m;t[0]===d?(p=t[1],m=t[2]):(p=()=>{let e=f.current;if(e)return e.appendChild(d),()=>{d.parentNode===e&&e.removeChild(d)}},m=[d],t[0]=d,t[1]=p,t[2]=m),(0,Q.useLayoutEffect)(p,m);let h;t[3]!==c||t[4]!==n.configuration.name?(h=()=>(ct(c,n.configuration.name??null),()=>{ct(c,null)}),t[3]=c,t[4]=n.configuration.name,t[5]=h):h=t[5];let g;t[6]!==c||t[7]!==n?(g=[c,n],t[6]=c,t[7]=n,t[8]=g):g=t[8],(0,Q.useEffect)(h,g);let _;t[9]!==c||t[10]!==n.configuration.name?(_=()=>{},t[9]=c,t[10]=n.configuration.name,t[11]=_):_=t[11];let v;t[12]!==c||t[13]!==n?(v=[c,n],t[12]=c,t[13]=n,t[14]=v):v=t[14],(0,Q.useEffect)(_,v);let y;t[15]!==c||t[16]!==n.configuration.name?(y=()=>{},t[15]=c,t[16]=n.configuration.name,t[17]=y):y=t[17];let b;t[18]!==c||t[19]!==n?(b=[c,n],t[18]=c,t[19]=n,t[20]=b):b=t[20],(0,Q.useEffect)(y,b);let x,S;t[21]===c?(x=t[22],S=t[23]):(S=()=>{let e=gA,t=null,n=()=>{if(t||c.isDestroyed)return;let n=pt(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 pt(c)?n():c.on(`create`,n),()=>{c.off(`create`,n),r()}},x=[c],t[21]=c,t[22]=x,t[23]=S),(0,Q.useEffect)(S,x);let C,T;t[24]!==u||t[25]!==n.document||t[26]!==l?(C=()=>{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)},dr)};c(lA);let f=()=>{if(Wn(e),!Vn(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`?Vn(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)}},T=[n.document,u,l],t[24]=u,t[25]=n.document,t[26]=l,t[27]=C,t[28]=T):(C=t[27],T=t[28]),(0,Q.useEffect)(C,T);let E,D;t[29]===n?(E=t[30],D=t[31]):(E=()=>{let e=window.location.hash,t=e.indexOf(`?`),r=t>=0?new URLSearchParams(e.slice(t+1)).get(`anchor`):null;if(!r)return;let i=r,a=0,o,s=!1;function c(){if(s)return;let e=document.getElementById(i);e?(e.scrollIntoView({behavior:`smooth`,block:`start`}),s=!0,n.off(`synced`,c)):a<20&&(a+=1,o=window.setTimeout(c,100))}return c(),n.on(`synced`,c),()=>{o!==void 0&&clearTimeout(o),n.off(`synced`,c)}},D=[n],t[29]=n,t[30]=E,t[31]=D),(0,Q.useEffect)(E,D);let k,A;t[32]===c?(k=t[33],A=t[34]):(k=()=>{let e=function(e){let t=e.detail;if(!t||t.mode!==`wysiwyg`||c.isDestroyed)return;let n=pt(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(zo,e),()=>window.removeEventListener(zo,e)},A=[c],t[32]=c,t[33]=k,t[34]=A),(0,Q.useEffect)(k,A);let j;t[35]!==a||t[36]!==i||t[37]!==o||t[38]!==r||t[39]!==s||t[40]!==n.awareness?(j=()=>{let e=n.awareness;if(e){if(i!==a){e.setLocalState(null);return}e.setLocalState({user:QO({principal:s,identity:o}),mode:r?`source`:`wysiwyg`})}},t[35]=a,t[36]=i,t[37]=o,t[38]=r,t[39]=s,t[40]=n.awareness,t[41]=j):j=t[41];let M;t[42]!==a||t[43]!==i||t[44]!==o||t[45]!==r||t[46]!==s||t[47]!==n?(M=[n,i,a,o,s,r],t[42]=a,t[43]=i,t[44]=o,t[45]=r,t[46]=s,t[47]=n,t[48]=M):M=t[48],(0,Q.useEffect)(j,M);let N,P;t[49]===c?(N=t[50],P=t[51]):(N=(0,Z.jsx)(Yk,{editor:c}),P=(0,Z.jsx)(oA,{editor:c}),t[49]=c,t[50]=N,t[51]=P);let F;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(`div`,{ref:f,style:{display:`contents`}}),t[52]=F):F=t[52];let I;t[53]===c?I=t[54]:(I=(0,Z.jsx)(se,{editor:c,className:`tiptap-editor-portal-content h-full`}),t[53]=c,t[54]=I);let L;t[55]!==d||t[56]!==I?(L=(0,is.createPortal)(I,d),t[55]=d,t[56]=I,t[57]=L):L=t[57];let R;t[58]===c?R=t[59]:(R=(0,Z.jsx)(YO,{editor:c}),t[58]=c,t[59]=R);let z;t[60]===c?z=t[61]:(z=w(c),t[60]=c,t[61]=z);let B;t[62]===z.store?B=t[63]:(B=(0,Z.jsx)(O,{store:z.store}),t[62]=z.store,t[63]=B);let V;return t[64]!==N||t[65]!==P||t[66]!==L||t[67]!==R||t[68]!==B||t[69]!==l?(V=(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:[N,P,F,L,R,B]}),t[64]=N,t[65]=P,t[66]=L,t[67]=R,t[68]=B,t[69]=l,t[70]=V):V=t[70],V};function gA(){return q()}function _A(e){let t=(0,$.c)(2),{docName:n,provider:r,children:i}=e;(0,Q.use)(lt(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 vA=`__back-nav__`;function yA(e){return e instanceof ge||e instanceof qe||e instanceof de||e instanceof Me||e instanceof rt||e instanceof Qe?e.docName:null}function bA(e){return e instanceof ge?{title:`Couldn't load document`,summary:`"${e.docName}" took too long. Check your connection.`}:e instanceof qe?{title:`Connection dropped`,summary:`Lost connection to "${e.docName}".`}:e instanceof de?{title:`Document not found`,summary:`"${e.docName}" doesn't exist.`}:e instanceof Me?{title:`Couldn't open document`,summary:`Something went wrong opening "${e.docName}".`}:e instanceof rt?{title:`Server can't open documents`,summary:`This project's running server doesn't support live editing. Restart Open Knowledge to fix.`}:e instanceof Qe?{title:`Cancelled`,summary:`You cancelled loading "${e.docName}".`}:{title:`Unknown error`,summary:e instanceof Error&&e.message?e.message:`An unexpected error occurred.`}}function xA(e){let t=(0,$.c)(27),{error:n,resetErrorBoundary:r,activeDocName:i,previousDocName:a,onNavigateBack:o}=e,s;t[0]===n?s=t[1]:(s=bA(n),t[0]=n,t[1]=s);let{title:c,summary:l}=s,u=!!a&&!!o,d=(0,Q.useRef)(null),f,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{d.current?.focus()},p=[],t[2]=f,t[3]=p):(f=t[2],p=t[3]),(0,Q.useEffect)(f,p);let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(jb,{size:80,variant:`sleeping`}),t[4]=m):m=t[4];let h;t[5]===c?h=t[6]:(h=(0,Z.jsx)(`h2`,{id:`document-error-title`,className:`text-2xl font-light tracking-tighter text-balance`,children:c}),t[5]=c,t[6]=h);let g;t[7]===l?g=t[8]:(g=(0,Z.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:l}),t[7]=l,t[8]=g);let _;t[9]!==h||t[10]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[h,g]}),t[9]=h,t[10]=g,t[11]=_):_=t[11];let v;t[12]===r?v=t[13]:(v=(0,Z.jsx)(X,{ref:d,variant:`default`,onClick:r,children:`Try again`}),t[12]=r,t[13]=v);let y;t[14]!==i||t[15]!==u||t[16]!==n||t[17]!==o||t[18]!==a||t[19]!==r?(y=u?(0,Z.jsx)(X,{variant:`ghost`,className:`font-mono uppercase`,onClick:()=>{!a||!o||(ze(yA(n)??i),o(a),r(vA))},children:`Go back`}):null,t[14]=i,t[15]=u,t[16]=n,t[17]=o,t[18]=a,t[19]=r,t[20]=y):y=t[20];let b;t[21]!==v||t[22]!==y?(b=(0,Z.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[v,y]}),t[21]=v,t[22]=y,t[23]=b):b=t[23];let x;return t[24]!==b||t[25]!==_?(x=(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:[m,_,b]}),t[24]=b,t[25]=_,t[26]=x):x=t[26],x}function SA(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)(xA,{...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]===vA){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}: ${bA(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)(b,{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}var CA={text:``,number:0,boolean:!1,date:``,list:[]};function wA(e){let t=e.document.getText(`source`).toString(),{map:n,parseError:r}=vr(t);return{map:n,keys:pn(t),parseError:r}}function TA(e){let t=(0,$.c)(169),{provider:n}=e,[r,i]=(0,Q.useState)(null),a;t[0]===n?a=t[1]:(a=()=>wA(n),t[0]=n,t[1]=a);let[o,s]=(0,Q.useState)(a),c,u;t[2]===n?(c=t[3],u=t[4]):(c=()=>{let e=br(n);i(e),s(e.current());let t=e.subscribe(e=>{s(e)});return()=>{t(),e.dispose(),i(t=>t===e?null:t)}},u=[n],t[2]=n,t[3]=c,t[4]=u),(0,Q.useEffect)(c,u);let d=o.map,f=o.keys,p=o.parseError,[m,h]=(0,Q.useState)(!1),g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g={},t[5]=g):g=t[5];let[_,v]=(0,Q.useState)(g),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(null),C;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(C={},t[6]=C):C=t[6];let[w,T]=(0,Q.useState)(C),E;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(E={},t[7]=E):E=t[7];let[D,O]=(0,Q.useState)(E),k=n.configuration.name??``,j;t[8]===k?j=t[9]:(j=DA(k),t[8]=k,t[9]=j);let M=ra(j),P;t[10]!==M.state.data||t[11]!==M.state.status?(P=M.state.status===`ready`?M.state.data.folder.frontmatter_defaults??{}:{},t[10]=M.state.data,t[11]=M.state.status,t[12]=P):P=t[12];let F=P,I;t[13]!==M.state.data||t[14]!==M.state.status?(I=M.state.status===`ready`?M.state.data.frontmatterSources:{},t[13]=M.state.data,t[14]=M.state.status,t[15]=I):I=t[15];let L=I,z;t[16]===r?z=t[17]:(z=function(e){if(!r)return{ok:!1,error:`Connecting`};let t=r.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=lr(t.error);return{ok:!1,error:t.error.issues[0]?.message??`Invalid patch payload`,fieldErrors:Object.keys(n).length>0?n:void 0}},t[16]=r,t[17]=z);let B=z,V;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(V=function(e){T(t=>{if(!Object.hasOwn(t,e))return t;let n={...t};return delete n[e],n})},t[18]=V):V=t[18];let H=V,U;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(U=function(e,t){if(e.ok)return;let n=e.error??`Failed to update property`,r=e.fieldErrors??{};T(e=>{let i={...e};for(let e of t)i[e]=r[e]??n;return i}),O(e=>{let n={...e};for(let e of t)n[e]=(n[e]??0)+1;return n})},t[19]=U):U=t[19];let W=U,G;t[20]===B?G=t[21]:(G=function(e,t){H(e),W(B({[e]:t}),[e])},t[20]=B,t[21]=G);let K=G,q;t[22]===B?q=t[23]:(q=function(e){H(e),W(B({[e]:null}),[e])},t[22]=B,t[23]=q);let ee=q,te;t[24]===r?te=t[25]:(te=function(e,t){if(!r)return{ok:!1,error:`Connecting`};if(e===t)return{ok:!0};let n=r.rename(e,t);if(n.ok)return{ok:!0};if(n.error.code===`WRITE_ERROR`)return{ok:!1,error:n.error.detail};let i=lr(n.error);return{ok:!1,error:n.error.issues[0]?.message??`Failed to rename`,fieldErrors:Object.keys(i).length>0?i:void 0}},t[24]=r,t[25]=te);let ne=te,re;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(re=function(e,t){return`${e} ${t}`},t[26]=re):re=t[26];let ie=re,ae;t[27]!==r||t[28]!==f?(ae=function(e){if(!r)return;let t=String(e.active.id),n=e.over?String(e.over.id):null;if(!n||t===n)return;let i=f.map((e,t)=>ie(e,t)),a=i.indexOf(t),o=i.indexOf(n);if(a<0||o<0)return;let s=f.slice(),[c]=s.splice(a,1);if(!c)return;s.splice(o,0,c);let l=r.reorder(s);l.ok||console.warn(`[PropertyPanel] reorder failed:`,l.error)},t[27]=r,t[28]=f,t[29]=ae):ae=t[29];let oe=ae,se;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(se={activationConstraint:{distance:4}},t[30]=se):se=t[30];let ce;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(ce={coordinateGetter:fi},t[31]=ce):ce=t[31];let le=ia(ui(Di,se),ui(mi,ce)),ue;t[32]!==F||t[33]!==K||t[34]!==d?(ue=function(e,t){let n=d[e]??OA(F[e]);if(n===void 0)return;v(n=>({...n,[e]:t}));let r=MD(n,t);(!Object.hasOwn(d,e)||!EA(n,r))&&K(e,r)},t[32]=F,t[33]=K,t[34]=d,t[35]=ue):ue=t[35];let de=ue,fe;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(fe=function(){b({name:``,type:`text`,value:``,error:null}),h(!1)},t[36]=fe):fe=t[36];let pe=fe,{addPropertySignal:me,clearAddProperty:he}=bO(),ge;t[37]!==me||t[38]!==k?(ge=me.get(k)??0,t[37]=me,t[38]=k,t[39]=ge):ge=t[39];let _e=ge,ve,ye;t[40]===_e?(ve=t[41],ye=t[42]):(ve=()=>{_e>0&&(b({name:``,type:`text`,value:``,error:null}),h(!1))},ye=[_e],t[40]=_e,t[41]=ve,t[42]=ye),(0,Q.useEffect)(ve,ye);let be,xe;t[43]!==he||t[44]!==k?(be=()=>()=>he(k),xe=[k,he],t[43]=he,t[44]=k,t[45]=be,t[46]=xe):(be=t[45],xe=t[46]),(0,Q.useEffect)(be,xe);let Se;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(Se=function(e){b(t=>{if(!t)return t;let n=e===`date`?new Date().toISOString().slice(0,10):CA[e];return{...t,type:e,value:n,error:null}})},t[47]=Se):Se=t[47];let Ce=Se,we;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(we=function(e){b(t=>t&&{...t,value:e})},t[48]=we):we=t[48];let J=we,Te;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(Te=function(e){b(t=>t&&{...t,name:e,error:null})},t[49]=Te):Te=t[49];let Ee=Te,De;t[50]!==y||t[51]!==B||t[52]!==d?(De=function(){if(!y)return;let e=y.name.trim();if(!e){b({...y,error:`Name is required`});return}if(e===`frontmatter`){b({...y,error:`"frontmatter" is a reserved property name`});return}if(Object.hasOwn(d,e)){b({...y,error:`Property "${e}" already exists`});return}let t=B({[e]:y.value});if(t.ok){b(null);return}let n=t.fieldErrors?.[e],r=t.error??`Failed to add property`;b({...y,error:n??r})},t[50]=y,t[51]=B,t[52]=d,t[53]=De):De=t[53];let Oe=De,ke;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ke=function(){b(null)},t[54]=ke):ke=t[54];let Ae=ke,je;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(je=function(e){S({key:e,draft:e,error:null})},t[55]=je):je=t[55];let Me=je,Ne;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=function(e){S(t=>t&&{...t,draft:e,error:null})},t[56]=Ne):Ne=t[56];let Pe=Ne,Fe;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=function(){S(null)},t[57]=Fe):Fe=t[57];let Ie=Fe,Le;t[58]!==d||t[59]!==ne||t[60]!==x?(Le=function(){if(!x)return;let e=x.draft.trim();if(!e){S(null);return}if(e===x.key){S(null);return}if(e===`frontmatter`){S({...x,error:`"frontmatter" is a reserved property name`});return}if(Object.hasOwn(d,e)){S({...x,error:`Property "${e}" already exists`});return}let t=ne(x.key,e);if(t.ok){v(t=>{if(!Object.hasOwn(t,x.key))return t;let n={...t};return n[e]=n[x.key],delete n[x.key],n}),H(x.key),S(null);return}let n=t.fieldErrors?.[e]??t.fieldErrors?.[x.key]??t.error??`Failed to rename property`;S({...x,error:n})},t[58]=d,t[59]=ne,t[60]=x,t[61]=Le):Le=t[61];let Re=Le,ze;t[62]!==d||t[63]!==f?(ze=f.length>0?f:Object.keys(d),t[62]=d,t[63]=f,t[64]=ze):ze=t[64];let Be=ze,Ve;if(t[65]!==Be){Ve=new Map;for(let e of Be)Ve.set(e,(Ve.get(e)??0)+1);t[65]=Be,t[66]=Ve}else Ve=t[66];let He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe,$e;if(t[67]!==y||t[68]!==F||t[69]!==L||t[70]!==m||t[71]!==K||t[72]!==Re||t[73]!==Ve||t[74]!==w||t[75]!==oe||t[76]!==d||t[77]!==_||t[78]!==p||t[79]!==ee||t[80]!==x||t[81]!==Be||t[82]!==D||t[83]!==le||t[84]!==de){$e=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Object.keys(F).filter(e=>!Object.hasOwn(d,e)).sort();if(Be.length===0&&e.length===0&&!y&&!p){$e=null;break bb0}Ze=`property-panel editor-content-aligned pt-4 pb-4 text-sm`,Qe=`property-panel`,Ue=A,Je=!m,t[97]===Symbol.for(`react.memo_cache_sentinel`)?(Ye=e=>h(!e),t[97]=Ye):Ye=t[97];let n=!m,r;t[98]===n?r=t[99]:(r=(0,Z.jsx)(l,{"data-expanded":n,className:`size-3.5 shrink-0 text-muted-foreground transition-transform duration-150 ease-out data-[expanded=true]:rotate-90`}),t[98]=n,t[99]=r);let i;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`span`,{children:`Properties`}),t[100]=i):i=t[100],t[101]===r?Xe=t[102]:(Xe=(0,Z.jsx)(R,{asChild:!0,children:(0,Z.jsxs)(X,{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:[r,i]})}),t[101]=r,t[102]=Xe),He=N,We=`overflow-hidden data-[state=open]:animate-[collapsible-down_150ms_ease-out] data-[state=closed]:animate-[collapsible-up_150ms_ease-in]`,t[103]===p?Ge=t[104]:(Ge=p?(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)(Dn,{className:`size-3.5 shrink-0 mt-0.5`}),(0,Z.jsxs)(`div`,{children:[`Frontmatter YAML is malformed; fix in source mode to recover.`,(0,Z.jsx)(`span`,{className:`block text-[10px] opacity-80`,children:p})]})]}):null,t[103]=p,t[104]=Ge);let a;if(t[105]!==Be){let e;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(e=(e,t)=>ie(e,t),t[107]=e):e=t[107],a=Be.map(e),t[105]=Be,t[106]=a}else a=t[106];let o;if(t[108]!==F||t[109]!==L||t[110]!==K||t[111]!==Re||t[112]!==Ve||t[113]!==w||t[114]!==d||t[115]!==_||t[116]!==ee||t[117]!==x||t[118]!==Be||t[119]!==D||t[120]!==de){let e;t[122]!==F||t[123]!==L||t[124]!==K||t[125]!==Re||t[126]!==Ve||t[127]!==w||t[128]!==d||t[129]!==_||t[130]!==ee||t[131]!==x||t[132]!==D||t[133]!==de?(e=(e,t)=>{let n=d[e];if(n===void 0)return null;let r=_[e]??on(n),i=x?.key===e?x:null,a=(Ve.get(e)??0)>1,o=Object.hasOwn(F,e)?(0,Z.jsx)(kA,{source:L[e]??``}):void 0;return(0,Z.jsx)(PD,{sortableId:ie(e,t),keyName:e,value:n,declared:r,error:w[e]??null,resetCounter:D[e]??0,isDuplicate:a,badge:o,rename:{state:i,onBegin:()=>Me(e),onChangeDraft:Pe,onCommit:Re,onCancel:Ie},onCommit:t=>K(e,t),onChangeType:t=>de(e,t),onRemove:()=>ee(e)},`${e}-${t}`)},t[122]=F,t[123]=L,t[124]=K,t[125]=Re,t[126]=Ve,t[127]=w,t[128]=d,t[129]=_,t[130]=ee,t[131]=x,t[132]=D,t[133]=de,t[134]=e):e=t[134],o=Be.map(e),t[108]=F,t[109]=L,t[110]=K,t[111]=Re,t[112]=Ve,t[113]=w,t[114]=d,t[115]=_,t[116]=ee,t[117]=x,t[118]=Be,t[119]=D,t[120]=de,t[121]=o}else o=t[121];let s;t[135]!==a||t[136]!==o?(s=(0,Z.jsx)(Mi,{items:a,strategy:Pi,children:o}),t[135]=a,t[136]=o,t[137]=s):s=t[137],t[138]!==oe||t[139]!==le||t[140]!==s?(Ke=(0,Z.jsx)(gi,{sensors:le,collisionDetection:aa,onDragEnd:oe,children:s}),t[138]=oe,t[139]=le,t[140]=s,t[141]=Ke):Ke=t[141];let c;t[142]!==F||t[143]!==L||t[144]!==K||t[145]!==w||t[146]!==D||t[147]!==de?(c=e=>{let t=F[e],n=OA(t),r=on(n),i=L[e]??``;return(0,Z.jsx)(PD,{keyName:e,value:n,declared:r,error:w[e]??null,resetCounter:D[e]??0,isInherited:!0,badge:(0,Z.jsx)(VD,{source:i}),onCommit:t=>K(e,t),onChangeType:t=>de(e,t)},`inherited-${e}`)},t[142]=F,t[143]=L,t[144]=K,t[145]=w,t[146]=D,t[147]=de,t[148]=c):c=t[148],qe=e.map(c)}t[67]=y,t[68]=F,t[69]=L,t[70]=m,t[71]=K,t[72]=Re,t[73]=Ve,t[74]=w,t[75]=oe,t[76]=d,t[77]=_,t[78]=p,t[79]=ee,t[80]=x,t[81]=Be,t[82]=D,t[83]=le,t[84]=de,t[85]=He,t[86]=Ue,t[87]=We,t[88]=Ge,t[89]=Ke,t[90]=qe,t[91]=Je,t[92]=Ye,t[93]=Xe,t[94]=Ze,t[95]=Qe,t[96]=$e}else He=t[85],Ue=t[86],We=t[87],Ge=t[88],Ke=t[89],qe=t[90],Je=t[91],Ye=t[92],Xe=t[93],Ze=t[94],Qe=t[95],$e=t[96];if($e!==Symbol.for(`react.early_return_sentinel`))return $e;let et;t[149]!==y||t[150]!==Oe?(et=y?(0,Z.jsx)(zD,{draft:y,onChangeName:Ee,onChangeType:Ce,onChangeValue:J,onCommit:Oe,onCancel:Ae}):(0,Z.jsxs)(X,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`add-property-trigger`,onClick:pe,className:`mt-1 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)(Fi,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:`Add property`})]}),t[149]=y,t[150]=Oe,t[151]=et):et=t[151];let tt;t[152]!==He||t[153]!==We||t[154]!==Ge||t[155]!==Ke||t[156]!==qe||t[157]!==et?(tt=(0,Z.jsxs)(He,{className:We,children:[Ge,Ke,qe,et]}),t[152]=He,t[153]=We,t[154]=Ge,t[155]=Ke,t[156]=qe,t[157]=et,t[158]=tt):tt=t[158];let nt;t[159]!==Ue||t[160]!==Je||t[161]!==Ye||t[162]!==Xe||t[163]!==tt?(nt=(0,Z.jsxs)(Ue,{open:Je,onOpenChange:Ye,children:[Xe,tt]}),t[159]=Ue,t[160]=Je,t[161]=Ye,t[162]=Xe,t[163]=tt,t[164]=nt):nt=t[164];let rt;return t[165]!==Ze||t[166]!==Qe||t[167]!==nt?(rt=(0,Z.jsx)(`div`,{className:Ze,"data-testid":Qe,children:nt}),t[165]=Ze,t[166]=Qe,t[167]=nt,t[168]=rt):rt=t[168],rt}function EA(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length?e.every((e,n)=>e===t[n]):!1:e===t}function DA(e){if(!e)return``;let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function OA(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`?e:Array.isArray(e)?e.map(e=>typeof e==`string`?e:JSON.stringify(e)):e==null?``:JSON.stringify(e)}function kA(e){let t=(0,$.c)(2),{source:n}=e,r=`Overrides default from ${n===``?`.ok/frontmatter.yml`:`${n}/.ok/frontmatter.yml`}. Remove to revert.`,i;return t[0]===r?i=t[1]:(i=(0,Z.jsx)(Ne,{variant:`primary`,"data-testid":`property-override-badge`,title:r,className:`text-2xs`,children:`overrides`}),t[0]=r,t[1]=i),i}var AA=tt(`LARGE_DOC_CHAR_THRESHOLD`,5e5);function jA(e){let t=e.threshold??AA;return e.ytextLength>t?{renderSource:e.isSourceMode||e.visitedSource,renderVisual:!e.isSourceMode||e.visitedVisual,isLarge:!0}:{renderSource:!0,renderVisual:!0,isLarge:!1}}function MA(e){return e.hasEmittedFirstToggle||!e.isLarge?!1:e.renderSource&&e.renderVisual}var NA=tt(`ACTIVITY_MOUNT_LIMIT`,3);function PA(){return r(()=>import(`./SourceEditor-CSsFAy0n.js`),__vite__mapDeps([43,1,35,2,36,37,21,38,39,40,41,20,3,6,7,15,4,8,14,9,44,24]),import.meta.url)}var FA=(0,Q.lazy)(async()=>({default:(await PA()).SourceEditor}));function IA(e,t,n){if(n<=0)return[];let r=e.filter(e=>!we(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 LA(e,t){return t.kind===`idle`?null:t.kind===`failed`&&t.failedDocNames.includes(e)?{kind:`failed`,title:`Couldn't reconnect after server restart`,summary:t.reason===`clear-data-timeout`?`Local collaboration data for "${e}" could not be cleared in time. Reload to retry.`:`Local collaboration data for "${e}" could not be cleared. Reload to retry.`,actionLabel:`Reload`}:t.kind===`recovering`&&t.docNames.includes(e)?{kind:`recovering`,title:`Reconnecting after server restart`,summary:t.phase===`clearing-local-cache`?`Clearing local collaboration data for "${e}" before reconnecting.`:`Reopening "${e}" with a fresh local collaboration cache.`}:null}function RA(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(st,{name:`activity-pool`,children:(0,Z.jsx)(zA,{...e})}),t[0]=e,t[1]=n),n}function zA(e){let t=(0,$.c)(15),{activeDocName:n,isSourceMode:r,editorPlaceholder:i,previousDocName:a,onNavigateBack:o,onRecycle:s}=e,{poolEntries:c,serverRestartRecovery:l}=We(),{pages:u,loading:d}=wr(),f=IA(c,n,NA),p=(0,Q.useRef)(``),m=f.map(BA).join(`,`),h=(0,Q.useRef)(c),g,_;t[0]===c?(g=t[1],_=t[2]):(g=()=>{h.current=c},_=[c],t[0]=c,t[1]=g,t[2]=_),(0,Q.useLayoutEffect)(g,_),(0,Q.useLayoutEffect)(()=>{if(p.current===m)return;let e=p.current?p.current.split(`,`):[],t=m?m.split(`,`):[],r=e.filter(e=>!t.includes(e)),i=t.filter(t=>!e.includes(t));for(let e of r)ft(e);for(let e of i){let t=h.current.find(t=>t.docName===e)?.poolEventId;he(e,t&&t.length>0?t:crypto.randomUUID())}Ge(`ok/activity/mount-list-change`,{active:n,mounted:t,evicted:r}),p.current=m,Te(t)},[m,n]);let v;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?(v=e=>(0,Z.jsx)(GA,{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]=v):v=t[12];let y=f.map(v),b;return t[13]===y?b=t[14]:(b=(0,Z.jsx)(Z.Fragment,{children:y}),t[13]=y,t[14]=b),b}function BA(e){return e.docName}function VA(e){let t=(0,$.c)(8),{isActive:n,children:r}=e,i=(0,Q.useRef)(null),a=(0,Q.useRef)(0),o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{let e=i.current;if(!e)return;let t=()=>{e.scrollTop>0&&(a.current=e.scrollTop)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},s=[],t[0]=o,t[1]=s):(o=t[0],s=t[1]),(0,Q.useEffect)(o,s);let c,l;t[2]===n?(c=t[3],l=t[4]):(c=()=>{if(!n)return;let e=i.current;if(!e)return;let t=a.current;if(t===0||(e.scrollTop=t,e.scrollTop===t))return;let r=!1,o=()=>{r||(r=!0,s.disconnect(),clearTimeout(c))},s=new ResizeObserver(()=>{r||!e||e.scrollHeight>t&&(e.scrollTop=t,e.scrollTop===t&&o())});s.observe(e);let c=setTimeout(o,500);return o},l=[n],t[2]=n,t[3]=c,t[4]=l),(0,Q.useLayoutEffect)(c,l);let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u={overflowAnchor:`auto`},t[5]=u):u=t[5];let d;return t[6]===r?d=t[7]:(d=(0,Z.jsx)(`div`,{ref:i,"data-testid":`editor-scroll-container`,className:`subtle-scrollbar h-full overflow-y-auto pt-14 scroll-pt-14`,style:u,children:r}),t[6]=r,t[7]=d),d}function HA(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)(qy,{}),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)(FA,{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 UA(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)(ec,{className:`size-5`,"aria-hidden":`true`}):(0,Z.jsx)(Ze,{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)(X,{type:`button`,onClick:WA,children:[(0,Z.jsx)(ec,{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 WA(){return window.location.reload()}function GA(e){let t=(0,$.c)(48),{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=LA(n.docName,u),t[0]=n.docName,t[1]=u,t[2]=d):d=t[2];let f=d,p;t[3]===n.docName?p=t[4]:(p=()=>{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]=p);let[m]=(0,Q.useState)(p),h=n.provider.document.getText(`source`).length,[g,_]=(0,Q.useState)(i),[v,y]=(0,Q.useState)(!i),b,x;t[5]!==i||t[6]!==g||t[7]!==v?(b=()=>{i&&!g?_(!0):!i&&!v&&y(!0)},x=[i,g,v],t[5]=i,t[6]=g,t[7]=v,t[8]=b,t[9]=x):(b=t[8],x=t[9]),(0,Q.useEffect)(b,x);let S=jA({ytextLength:h,isSourceMode:i,visitedSource:g,visitedVisual:v}),C=(0,Q.useRef)(``),w=`${S.isLarge}-${S.renderSource}-${S.renderVisual}`,T,E;t[10]!==n.docName||t[11]!==S.isLarge||t[12]!==S.renderSource||t[13]!==S.renderVisual||t[14]!==w||t[15]!==i||t[16]!==h?(T=()=>{C.current!==w&&(C.current=w,S.isLarge&&Ge(`ok/activity/defer-mount`,{docName:n.docName,ytextLength:h,isSourceMode:i,renderSource:S.renderSource,renderVisual:S.renderVisual}))},E=[w,S.isLarge,S.renderSource,S.renderVisual,n.docName,h,i],t[10]=n.docName,t[11]=S.isLarge,t[12]=S.renderSource,t[13]=S.renderVisual,t[14]=w,t[15]=i,t[16]=h,t[17]=T,t[18]=E):(T=t[17],E=t[18]),(0,Q.useEffect)(T,E);let[D,O]=(0,Q.useState)(!1),k,A;t[19]!==n.docName||t[20]!==S.isLarge||t[21]!==S.renderSource||t[22]!==S.renderVisual||t[23]!==D||t[24]!==i||t[25]!==h?(k=()=>{MA({isLarge:S.isLarge,renderSource:S.renderSource,renderVisual:S.renderVisual,hasEmittedFirstToggle:D})&&(Ge(`ok/cold/first-toggle`,{docName:n.docName,mountId:bt(n.docName),ytextLength:h,modeEnteredFirst:i?`source`:`visual`}),O(!0))},A=[D,S.isLarge,S.renderSource,S.renderVisual,n.docName,h,i],t[19]=n.docName,t[20]=S.isLarge,t[21]=S.renderSource,t[22]=S.renderVisual,t[23]=D,t[24]=i,t[25]=h,t[26]=k,t[27]=A):(k=t[26],A=t[27]),(0,Q.useEffect)(k,A);let j=r?`visible`:`hidden`,M=`editor:${n.docName}`,N;t[28]!==a||t[29]!==n||t[30]!==S.renderSource||t[31]!==S.renderVisual||t[32]!==r||t[33]!==o||t[34]!==i||t[35]!==c||t[36]!==l||t[37]!==m||t[38]!==s||t[39]!==f?(N=f?(0,Z.jsx)(UA,{view:f}):(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(SA,{activeDocName:n.docName,previousDocName:s,onNavigateBack:c,onRecycle:l,children:(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(qy,{}),children:(0,Z.jsx)(_A,{docName:n.docName,provider:n.provider,children:(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[!i&&(0,Z.jsx)(TA,{provider:n.provider}),(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[S.renderSource?(0,Z.jsx)(`div`,{className:i?`h-full`:`ok-mode-hidden h-full`,children:(0,Z.jsx)(HA,{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a})}):null,S.renderVisual?(0,Z.jsx)(`div`,{className:i?`ok-mode-hidden h-full`:`h-full`,children:(0,Z.jsx)(mA,{provider:n.provider,placeholder:a,isSourceMode:i,portalTarget:m},`${n.docName}-${String(o)}`)}):null]})]})})})})}),t[28]=a,t[29]=n,t[30]=S.renderSource,t[31]=S.renderVisual,t[32]=r,t[33]=o,t[34]=i,t[35]=c,t[36]=l,t[37]=m,t[38]=s,t[39]=f,t[40]=N):N=t[40];let P;t[41]!==r||t[42]!==N?(P=(0,Z.jsx)(VA,{isActive:r,children:N}),t[41]=r,t[42]=N,t[43]=P):P=t[43];let F;return t[44]!==M||t[45]!==P||t[46]!==j?(F=(0,Z.jsx)(Q.Activity,{mode:j,name:M,children:P}),t[44]=M,t[45]=P,t[46]=j,t[47]=F):F=t[47],F}function KA(e){let t=(0,$.c)(27),{stats:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(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[0]=r):r=t[0];let i;t[1]===n.words?i=t[2]:(i=n.words.toLocaleString(),t[1]=n.words,t[2]=i);let a;t[3]===i?a=t[4]:(a=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:i}),t[3]=i,t[4]=a);let o=n.words===1?`word`:`words`,s;t[5]!==a||t[6]!==o?(s=(0,Z.jsxs)(`span`,{children:[a,` `,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7];let c;t[8]===n.chars?c=t[9]:(c=n.chars.toLocaleString(),t[8]=n.chars,t[9]=c);let l;t[10]===c?l=t[11]:(l=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:c}),t[10]=c,t[11]=l);let u=n.chars===1?`char`:`chars`,d;t[12]!==l||t[13]!==u?(d=(0,Z.jsxs)(`span`,{children:[l,` `,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f=n.tokens>0?`~`:``,p;t[15]===n.tokens?p=t[16]:(p=n.tokens.toLocaleString(),t[15]=n.tokens,t[16]=p);let m;t[17]===p?m=t[18]:(m=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:p}),t[17]=p,t[18]=m);let h=n.tokens===1?`token`:`tokens`,g;t[19]!==f||t[20]!==m||t[21]!==h?(g=(0,Z.jsxs)(`span`,{children:[f,m,` `,h]}),t[19]=f,t[20]=m,t[21]=h,t[22]=g):g=t[22];let _;return t[23]!==g||t[24]!==s||t[25]!==d?(_=(0,Z.jsxs)(`section`,{"aria-label":`Document statistics`,className:`relative flex h-6 shrink-0 items-center justify-end gap-3 bg-background px-3 text-2xs text-muted-foreground`,children:[r,s,d,g]}),t[23]=g,t[24]=s,t[25]=d,t[26]=_):_=t[26],_}var qA={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`},JA=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`,...qA,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},YA=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)(JA,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},XA=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)(JA,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i};function ZA(e){let t=(0,$.c)(39),{isSourceMode:n,sourceDisabled:r,onModeChange:i,showAddPropertyButton:a,onAddProperty:o,showPanelOpen:s,onTogglePanel:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`div`,{}),t[0]=l):l=t[0];let u=n?`source`:`wysiwyg`,d;t[1]===i?d=t[2]:(d=e=>{e&&i(e)},t[1]=i,t[2]=d);let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(ro,{value:`wysiwyg`,"aria-label":`Visual editor`,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,asChild:!0,children:(0,Z.jsx)(so,{children:(0,Z.jsx)(XA,{className:`size-4`})})}),(0,Z.jsx)(co,{side:`bottom`,children:`Visual`})]}),t[3]=f):f=t[3];let p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(YA,{className:`size-4`}),t[4]=p):p=t[4];let m;t[5]===r?m=t[6]:(m=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(`div`,{children:(0,Z.jsx)(ro,{value:`source`,"aria-label":`Markdown source`,disabled:r,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,children:p})})}),t[5]=r,t[6]=m);let h=r?`Source mode requires a live connection — your edits are saved and will appear when you reconnect.`:`Markdown`,g;t[7]===h?g=t[8]:(g=(0,Z.jsx)(co,{side:`bottom`,children:h}),t[7]=h,t[8]=g);let _;t[9]!==m||t[10]!==g?(_=(0,Z.jsxs)(uo,{children:[m,g]}),t[9]=m,t[10]=g,t[11]=_):_=t[11];let v;t[12]!==u||t[13]!==d||t[14]!==_?(v=(0,Z.jsx)(`div`,{className:`pointer-events-auto flex justify-center`,children:(0,Z.jsxs)(ao,{type:`single`,value:u,onValueChange:d,"aria-label":`Editor mode`,variant:`segmented`,size:`sm`,spacing:1,className:`shrink-0 data-[size=sm]:rounded-[10px] bg-muted p-0.5`,children:[f,_]})}),t[12]=u,t[13]=d,t[14]=_,t[15]=v):v=t[15];let y;t[16]!==o||t[17]!==a?(y=a&&(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`Add properties`,onClick:o,"data-testid":`add-properties-button`,asChild:!0,children:(0,Z.jsx)(so,{children:(0,Z.jsx)(Vs,{})})}),(0,Z.jsx)(co,{side:`bottom`,children:`Add properties`})]}),t[16]=o,t[17]=a,t[18]=y):y=t[18];let b=s?`Show document panel`:`Hide document panel`,x;t[19]===s?x=t[20]:(x=(0,Z.jsx)(so,{children:s?(0,Z.jsx)(Js,{}):(0,Z.jsx)(qs,{})}),t[19]=s,t[20]=x);let S;t[21]!==c||t[22]!==b||t[23]!==x?(S=(0,Z.jsx)(X,{variant:`ghost`,size:`icon`,onClick:c,"aria-label":b,asChild:!0,children:x}),t[21]=c,t[22]=b,t[23]=x,t[24]=S):S=t[24];let C=s?`Show panel`:`Hide panel`,w;t[25]===C?w=t[26]:(w=(0,Z.jsx)(co,{side:`bottom`,children:C}),t[25]=C,t[26]=w);let T;t[27]!==S||t[28]!==w?(T=(0,Z.jsxs)(uo,{children:[S,w]}),t[27]=S,t[28]=w,t[29]=T):T=t[29];let E;t[30]!==y||t[31]!==T?(E=(0,Z.jsxs)(`div`,{className:`pointer-events-auto flex items-center justify-end gap-1`,children:[y,T]}),t[30]=y,t[31]=T,t[32]=E):E=t[32];let D;t[33]!==v||t[34]!==E?(D=(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 items-center px-2 py-2 bg-background`,children:[l,v,E]}),t[33]=v,t[34]=E,t[35]=D):D=t[35];let O;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none h-2 bg-linear-to-b from-background to-transparent`}),t[36]=O):O=t[36];let k;return t[37]===D?k=t[38]:(k=(0,Z.jsxs)(`div`,{"data-testid":`editor-toolbar`,className:`pointer-events-none absolute inset-x-0 top-0 z-10`,children:[D,O]}),t[37]=D,t[38]=k),k}function QA(e){let{activeDocName:t,deferredActiveDocName:n,mountResolved:r,syncResolved:i}=e;return t===null||t===n?!1:!(r&&i)}var $A=(0,Q.lazy)(()=>r(()=>import(`./SettingsDialog-x6fsBA_3.js`).then(e=>({default:e.SettingsDialog})),__vite__mapDeps([45,1,35,2,36,37,21,38,39,40,41,20,3,6,7,15,4,8,14,9,46,16,22,10,23]),import.meta.url));function ej(e){let t=(0,$.c)(5),n;t[0]===e?n=t[1]:(n=(0,Z.jsx)(nj,{...e}),t[0]=e,t[1]=n);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(tj,{}),t[2]=r):r=t[2];let i;return t[3]===n?i=t[4]:(i=(0,Z.jsx)(st,{name:`editor-area`,children:(0,Z.jsxs)(vO,{children:[n,r]})}),t[3]=n,t[4]=i),i}function tj(){let e=(0,$.c)(8),t=Wf(),[n,r]=(0,Q.useState)(!1),i,a;if(e[0]===t.open?(i=e[1],a=e[2]):(i=()=>{t.open&&r(!0)},a=[t.open],e[0]=t.open,e[1]=i,e[2]=a),(0,Q.useEffect)(i,a),!n)return null;let o;e[3]===t?o=e[4]:(o=e=>{e||t.close()},e[3]=t,e[4]=o);let s;return e[5]!==t.open||e[6]!==o?(s=(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)($A,{open:t.open,onOpenChange:o})}),e[5]=t.open,e[6]=o,e[7]=s):s=e[7],s}function nj(e){let t=(0,$.c)(95),{editorMode:n,onModeChange:r,activeTab:i,onActiveTabChange:a}=e,{activeDocName:o,activeProvider:s,activeTarget:c,recycleDocument:l,docPanelMode:u,docPanelExpandSignal:d}=We(),{openDocumentTransition:f}=et(),{requestAddProperty:p}=bO(),m=HO(s,o),h=UO(s),g=h===`connected`||h===`synced`,_=(0,Q.useDeferredValue)(o),v=c?.kind===`missing`,y=!!o&&c?.kind!==`folder`,b=v?`Start writing to create this page`:void 0,x=Hy(),[S,C]=(0,Q.useState)(!1),{layout:w,autoCollapse:T}=EO(),E=w===`sheet`,[D,O]=(0,Q.useState)(!1),k=(0,Q.useRef)(!1),A,j;t[0]!==T||t[1]!==w||t[2]!==x?(A=()=>{w===`panel`&&(T?(k.current=!1,x.current?.collapse()):k.current||x.current?.expand())},j=[T,w,x],t[0]=T,t[1]=w,t[2]=x,t[3]=A,t[4]=j):(A=t[3],j=t[4]),(0,Q.useEffect)(A,j);let M,N;t[5]!==E||t[6]!==a||t[7]!==x?(M=()=>{let e=e=>{a(e),E?O(!0):(k.current=!1,x.current?.expand())},t=yf();return t&&e(t),xf(t=>{yf(),e(t)})},N=[E,a,x],t[5]=E,t[6]=a,t[7]=x,t[8]=M,t[9]=N):(M=t[8],N=t[9]),(0,Q.useEffect)(M,N);let P,F;t[10]!==d||t[11]!==E||t[12]!==x?(P=()=>{d!==0&&(E?O(!0):(k.current=!1,x.current?.expand()))},F=[d,E,x],t[10]=d,t[11]=E,t[12]=x,t[13]=P,t[14]=F):(P=t[13],F=t[14]),(0,Q.useEffect)(P,F);let I=(0,Q.useRef)(null),[L,R]=(0,Q.useState)(null),z,B;if(t[15]===o?(z=t[16],B=t[17]):(z=()=>{if(o&&o!==I.current){let e=I.current;I.current=o,R(e)}},B=[o],t[15]=o,t[16]=z,t[17]=B),(0,Q.useEffect)(z,B),c?.kind===`folder`){let e;return t[18]===c.folderPath?e=t[19]:(e=(0,Z.jsx)(dO,{folderPath:c.folderPath}),t[18]=c.folderPath,t[19]=e),e}if(c?.kind===`asset`){let e;return t[20]!==c.assetPath||t[21]!==c.mediaKind?(e=(0,Z.jsx)(Ky,{assetPath:c.assetPath,mediaKind:c.mediaKind}),t[20]=c.assetPath,t[21]=c.mediaKind,t[22]=e):e=t[22],e}if(!s||!o){if((typeof window<`u`?fr(window.location.hash):null)!==null){let e;return t[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(qy,{}),t[23]=e):e=t[23],e}let e;return t[24]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(px,{}),t[24]=e):e=t[24],e}let V=n===`source`,H=!g,U=E?!D:S,W;t[25]!==o||t[26]!==p?(W=function(){o&&p(o)},t[25]=o,t[26]=p,t[27]=W):W=t[27];let G=W,K;t[28]!==S||t[29]!==E||t[30]!==x?(K=function(){E?O(rj):S?(k.current=!1,x.current?.expand()):(k.current=!0,x.current?.collapse())},t[28]=S,t[29]=E,t[30]=x,t[31]=K):K=t[31];let q=K,ee=_??o,te=L??void 0,ne;t[32]===f?ne=t[33]:(ne=e=>{let t=er(e);window.location.hash===t?f(e):window.location.hash=t},t[32]=f,t[33]=ne);let re;t[34]!==b||t[35]!==V||t[36]!==l||t[37]!==ee||t[38]!==te||t[39]!==ne?(re=(0,Z.jsx)(RA,{activeDocName:ee,isSourceMode:V,editorPlaceholder:b,previousDocName:te,onNavigateBack:ne,onRecycle:l}),t[34]=b,t[35]=V,t[36]=l,t[37]=ee,t[38]=te,t[39]=ne,t[40]=re):re=t[40];let ie;t[41]!==o||t[42]!==_?(ie=QA({activeDocName:o,deferredActiveDocName:_,mountResolved:o!==null&&je(o),syncResolved:o!==null&&ye(o)})?(0,Z.jsxs)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:[(0,Z.jsx)(qy,{}),o===null?null:(0,Z.jsx)(hO,{docName:o})]}):null,t[41]=o,t[42]=_,t[43]=ie):ie=t[43];let ae;t[44]!==re||t[45]!==ie?(ae=(0,Z.jsxs)(`div`,{className:`relative h-full`,children:[re,ie]}),t[44]=re,t[45]=ie,t[46]=ae):ae=t[46];let oe=!V,se;t[47]!==V||t[48]!==r||t[49]!==G||t[50]!==U||t[51]!==H||t[52]!==oe||t[53]!==q?(se=(0,Z.jsx)(ZA,{isSourceMode:V,sourceDisabled:H,onModeChange:r,showAddPropertyButton:oe,onAddProperty:G,showPanelOpen:U,onTogglePanel:q}),t[47]=V,t[48]=r,t[49]=G,t[50]=U,t[51]=H,t[52]=oe,t[53]=q,t[54]=se):se=t[54];let ce;t[55]!==ae||t[56]!==se?(ce=(0,Z.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[ae,se]}),t[55]=ae,t[56]=se,t[57]=ce):ce=t[57];let le;t[58]!==y||t[59]!==m?(le=y&&(0,Z.jsx)(KA,{stats:m}),t[58]=y,t[59]=m,t[60]=le):le=t[60];let ue;t[61]!==ce||t[62]!==le?(ue=(0,Z.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[ce,le]}),t[61]=ce,t[62]=le,t[63]=ue):ue=t[63];let de=ue;if(E){let e;t[64]===de?e=t[65]:(e=(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:de}),t[64]=de,t[65]=e);let n;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(vg,{className:`sr-only`,children:(0,Z.jsx)(yg,{children:`Document panel`})}),t[66]=n):n=t[66];let r;t[67]!==o||t[68]!==i||t[69]!==u||t[70]!==V||t[71]!==a?(r=(0,Z.jsxs)(_g,{side:`right`,className:`flex w-80 sm:w-96 flex-col gap-0 p-0`,children:[n,(0,Z.jsx)(Y_,{docName:o,isSourceMode:V,activeTab:i,onActiveTabChange:a,mode:u})]}),t[67]=o,t[68]=i,t[69]=u,t[70]=V,t[71]=a,t[72]=r):r=t[72];let s;t[73]!==D||t[74]!==r?(s=(0,Z.jsx)(mg,{open:D,onOpenChange:O,children:r}),t[73]=D,t[74]=r,t[75]=s):s=t[75];let c;return t[76]!==e||t[77]!==s?(c=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[e,s]}),t[76]=e,t[77]=s,t[78]=c):c=t[78],c}let fe;t[79]===de?fe=t[80]:(fe=(0,Z.jsx)(SO,{minSize:`30%`,defaultSize:`75%`,children:de}),t[79]=de,t[80]=fe);let pe;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Z.jsx)(CO,{withHandle:!0}),t[81]=pe):pe=t[81];let me;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(me=e=>C(e.asPercentage===0),t[82]=me):me=t[82];let he;t[83]!==o||t[84]!==i||t[85]!==u||t[86]!==V||t[87]!==a?(he=(0,Z.jsx)(Y_,{docName:o,isSourceMode:V,activeTab:i,onActiveTabChange:a,mode:u}),t[83]=o,t[84]=i,t[85]=u,t[86]=V,t[87]=a,t[88]=he):he=t[88];let ge;t[89]!==x||t[90]!==he?(ge=(0,Z.jsx)(SO,{panelRef:x,defaultSize:`25%`,minSize:`300px`,maxSize:`40%`,collapsible:!0,collapsedSize:0,onResize:me,className:`flex flex-col bg-muted/20`,children:he}),t[89]=x,t[90]=he,t[91]=ge):ge=t[91];let _e;return t[92]!==fe||t[93]!==ge?(_e=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,Z.jsxs)(xO,{orientation:`horizontal`,children:[fe,pe,ge]})}),t[92]=fe,t[93]=ge,t[94]=_e):_e=t[94],_e}function rj(e){return!e}var ij=1280;function aj(){let e=(0,$.c)(2),[t,n]=(0,Q.useState)(oj),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${ij-1}px)`),t=()=>{n(window.innerWidth<ij)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Q.useEffect)(r,i),t}function oj(){return window.innerWidth<ij}function sj(e){let t=e.endsWith(`rem`)?`rem`:`px`;return{value:Number.parseFloat(e),unit:t}}function cj(e){let{value:t,unit:n}=sj(e);return n===`rem`?t*16:t}function lj(e,t){return`${t===`rem`?e.toFixed(1):Math.round(e)}${t}`}var uj=3600*24*7;function dj(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?fj:m,O=g===void 0?uj: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=cj(b),ee;t[6]===x?ee=t[7]:(ee=cj(x),t[6]=x,t[7]=ee);let te=ee,ne;t[8]!==E||t[9]!==k?(ne=function(e){P.current=!0,E&&(j.current=H.current?0:cj(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]=ne):ne=t[10];let re=ne,ie,ae;t[11]!==w||t[12]!==v||t[13]!==C||t[14]!==S||t[15]!==T||t[16]!==k||t[17]!==te||t[18]!==q||t[19]!==i||t[20]!==a||t[21]!==D||t[22]!==O||t[23]!==h?(ie=()=>{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}=sj(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(te,t)),u=lj(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(te,u)),f=lj(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)}},ae=[i,a,D,q,te,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]=te,t[18]=q,t[19]=i,t[20]=a,t[21]=D,t[22]=O,t[23]=h,t[24]=ie,t[25]=ae):(ie=t[24],ae=t[25]),(0,Q.useEffect)(ie,ae);let oe;return t[26]===re?oe=t[27]:(oe={dragRef:A,isDragging:N,handleMouseDown:re},t[26]=re,t[27]=oe),oe}function fj(){}var pj=`sidebar_state`,mj=3600*24*7,hj=`18rem`,gj=`3rem`,_j=`\\`,vj=`app-file-sidebar`,yj=`14.625rem`,bj=`22rem`,xj=`sidebar_width`,Sj=/^\d+(?:\.\d+)?(?:rem|px)$/,Cj=Q.createContext(null);function wj(e){if(typeof document>`u`)return e;let t=document.cookie.split(`; `).find(e=>e.startsWith(`${xj}=`))?.split(`=`)[1];if(!t)return e;let n;try{n=decodeURIComponent(t)}catch{return e}return Sj.test(n)?n:e}function Tj(){let e=Q.use(Cj);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function Ej(e){let t=(0,$.c)(53),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]):({defaultOpen:c,open:i,onOpenChange:o,className:r,style:s,children:n,defaultWidth:l,...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,t[8]=l);let u=c===void 0?!0:c,d=l===void 0?hj:l,f=aj(),p;t[9]===d?p=t[10]:(p=()=>wj(d),t[9]=d,t[10]=p);let[m,h]=Q.useState(p),[g,_]=Q.useState(!1),v=Q.useRef(g),[y,b]=Q.useState(!1),[x,S]=Q.useState(!1),[C,w]=Q.useState(u),T=i??C,E;t[11]!==T||t[12]!==o?(E=e=>{let t=typeof e==`function`?e(T):e;o?o(t):w(t),document.cookie=`${pj}=${t}; path=/; max-age=${mj}`},t[11]=T,t[12]=o,t[13]=E):E=t[13];let D=E,O;t[14]===D?O=t[15]:(O=function(){return window.innerWidth<1280?_(Oj):D(Dj)},t[14]=D,t[15]=O);let k=O,A;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(A=function(){window.innerWidth>=1280||v.current&&(window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||S(!0))},t[16]=A):A=t[16];let j=A,M;t[17]===g?M=t[18]:(M=()=>{v.current=g},t[17]=g,t[18]=M),Q.useLayoutEffect(M);let N,P;t[19]===k?(N=t[20],P=t[21]):(N=()=>{let e=e=>{e.key===_j&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),k())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},P=[k],t[19]=k,t[20]=N,t[21]=P),Q.useEffect(N,P);let F,I;t[22]!==f||t[23]!==g?(F=()=>{if(!f||!g)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"]`)||_(!1))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},I=[f,g],t[22]=f,t[23]=g,t[24]=F,t[25]=I):(F=t[24],I=t[25]),Q.useEffect(F,I);let L=Q.useRef(f),R,z;t[26]!==f||t[27]!==T?(R=()=>{!L.current&&f&&_(T),L.current=f},z=[f,T],t[26]=f,t[27]=T,t[28]=R,t[29]=z):(R=t[28],z=t[29]),Q.useEffect(R,z);let B=f?g?`expanded`:`collapsed`:T?`expanded`:`collapsed`,V;t[30]!==y||t[31]!==f||t[32]!==T||t[33]!==g||t[34]!==D||t[35]!==x||t[36]!==B||t[37]!==k||t[38]!==m?(V={state:B,open:T,setOpen:D,isMobile:f,openMobile:g,setOpenMobile:_,toggleSidebar:k,width:m,setWidth:h,isDraggingRail:y,setIsDraggingRail:b,showPushPulse:x,setShowPushPulse:S,notifySidebarFileSelected:j},t[30]=y,t[31]=f,t[32]=T,t[33]=g,t[34]=D,t[35]=x,t[36]=B,t[37]=k,t[38]=m,t[39]=V):V=t[39];let H;t[40]!==s||t[41]!==m?(H={"--sidebar-width":m,"--sidebar-width-icon":gj,...s},t[40]=s,t[41]=m,t[42]=H):H=t[42];let U=H,W;t[43]===r?W=t[44]:(W=Y(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),t[43]=r,t[44]=W);let G;t[45]!==n||t[46]!==a||t[47]!==U||t[48]!==W?(G=(0,Z.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:U,className:W,...a,children:n}),t[45]=n,t[46]=a,t[47]=U,t[48]=W,t[49]=G):G=t[49];let K;return t[50]!==V||t[51]!==G?(K=(0,Z.jsx)(Cj.Provider,{value:V,children:G}),t[50]=V,t[51]=G,t[52]=K):K=t[52],K}function Dj(e){return!e}function Oj(e){return!e}function kj(e){let t=(0,$.c)(51),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({side:a,variant:o,collapsible:s,className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=a===void 0?`left`:a,l=o===void 0?`sidebar`:o,u=s===void 0?`offcanvas`:s,{isMobile:d,state:f,openMobile:p,isDraggingRail:m}=Tj();if(u===`none`){let e;t[7]===r?e=t[8]:(e=Y(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),t[7]=r,t[8]=e);let a;return t[9]!==n||t[10]!==i||t[11]!==e||t[12]!==l?(a=(0,Z.jsx)(`div`,{"data-slot":`sidebar`,"data-variant":l,className:e,...i,children:n}),t[9]=n,t[10]=i,t[11]=e,t[12]=l,t[13]=a):a=t[13],a}if(d){let e=p?`expanded`:`collapsed`,a=l===`floating`||l===`inset`?`p-2`:``,o;t[14]!==r||t[15]!==a?(o=Y(`fixed inset-y-0 z-30 flex h-svh w-(--sidebar-width)`,`transition-transform duration-200 ease-linear motion-reduce:transition-none`,`data-[side=left]:left-0 data-[side=right]:right-0`,`group-data-[state=collapsed]:data-[side=left]:-translate-x-full`,`group-data-[state=collapsed]:data-[side=right]:translate-x-full`,a,r),t[14]=r,t[15]=a,t[16]=o):o=t[16];let s;t[17]===n?s=t[18]:(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[17]=n,t[18]=s);let u;t[19]!==i||t[20]!==c||t[21]!==o||t[22]!==s?(u=(0,Z.jsx)(`nav`,{id:vj,"aria-label":`File sidebar`,"data-slot":`sidebar-container`,"data-side":c,className:o,...i,children:s}),t[19]=i,t[20]=c,t[21]=o,t[22]=s,t[23]=u):u=t[23];let d;return t[24]!==e||t[25]!==c||t[26]!==u||t[27]!==l?(d=(0,Z.jsx)(`div`,{className:`group peer text-sidebar-foreground`,"data-state":e,"data-variant":l,"data-side":c,"data-slot":`sidebar`,"data-mobile":`true`,children:u}),t[24]=e,t[25]=c,t[26]=u,t[27]=l,t[28]=d):d=t[28],d}let h=f===`collapsed`?u:``,g=l===`floating`||l===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,_;t[29]===g?_=t[30]:(_=Y(`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[29]=g,t[30]=_);let v;t[31]===_?v=t[32]:(v=(0,Z.jsx)(`div`,{"data-slot":`sidebar-gap`,className:_}),t[31]=_,t[32]=v);let y=l===`floating`||l===`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`,b;t[33]!==r||t[34]!==y?(b=Y(`fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear 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)] md:flex`,y,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`,r),t[33]=r,t[34]=y,t[35]=b):b=t[35];let x;t[36]===n?x=t[37]:(x=(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[36]=n,t[37]=x);let S;t[38]!==i||t[39]!==c||t[40]!==x||t[41]!==b?(S=(0,Z.jsx)(`div`,{"data-slot":`sidebar-container`,"data-side":c,className:b,...i,children:x}),t[38]=i,t[39]=c,t[40]=x,t[41]=b,t[42]=S):S=t[42];let C;return t[43]!==m||t[44]!==c||t[45]!==f||t[46]!==S||t[47]!==h||t[48]!==v||t[49]!==l?(C=(0,Z.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":f,"data-collapsible":h,"data-variant":l,"data-side":c,"data-slot":`sidebar`,"data-dragging":m,children:[v,S]}),t[43]=m,t[44]=c,t[45]=f,t[46]=S,t[47]=h,t[48]=v,t[49]=l,t[50]=C):C=t[50],C}function Aj(e){let t=(0,$.c)(16),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,onClick:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let{toggleSidebar:a,state:o}=Tj(),s=o===`expanded`,c;t[4]===n?c=t[5]:(c=Y(n),t[4]=n,t[5]=c);let l;t[6]!==r||t[7]!==a?(l=e=>{r?.(e),a()},t[6]=r,t[7]=a,t[8]=l):l=t[8];let u,d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(J,{}),d=(0,Z.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`}),t[9]=u,t[10]=d):(u=t[9],d=t[10]);let f;return t[11]!==i||t[12]!==s||t[13]!==c||t[14]!==l?(f=(0,Z.jsxs)(X,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon-sm`,"aria-expanded":s,"aria-controls":vj,className:c,onClick:l,...i,children:[u,d]}),t[11]=i,t[12]=s,t[13]=c,t[14]=l,t[15]=f):f=t[15],f}function jj(e){let t=(0,$.c)(24),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:n,enableDrag:a,enableToggle:o,onMouseDown:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=a===void 0?!0:a,c=o===void 0?!0:o,{toggleSidebar:l,setWidth:u,state:d,width:f,setIsDraggingRail:p}=Tj(),m=d===`collapsed`,h;t[6]!==s||t[7]!==c||t[8]!==p||t[9]!==u||t[10]!==m||t[11]!==l||t[12]!==f?(h={direction:`right`,enableDrag:s,enableToggle:c,onResize:u,onToggle:l,currentWidth:f,isCollapsed:m,minResizeWidth:yj,maxResizeWidth:bj,setIsDraggingRail:p,widthCookieName:xj,widthCookieMaxAge:mj},t[6]=s,t[7]=c,t[8]=p,t[9]=u,t[10]=m,t[11]=l,t[12]=f,t[13]=h):h=t[13];let{dragRef:g,handleMouseDown:_}=dj(h),v;t[14]!==_||t[15]!==r?(v=e=>{r?.(e),e.defaultPrevented||_(e)},t[14]=_,t[15]=r,t[16]=v):v=t[16];let y;t[17]===n?y=t[18]:(y=Y(`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[17]=n,t[18]=y);let b;return t[19]!==g||t[20]!==i||t[21]!==v||t[22]!==y?(b=(0,Z.jsx)(`button`,{ref:g,"data-sidebar":`rail`,"data-slot":`sidebar-rail`,"aria-label":`Toggle Sidebar`,tabIndex:-1,onMouseDown:v,title:`Toggle Sidebar`,className:y,...i}),t[19]=g,t[20]=i,t[21]=v,t[22]=y,t[23]=b):b=t[23],b}function Mj(e){let t=(0,$.c)(21),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,onClick:i,onAnimationEnd:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{isMobile:o,openMobile:s,setOpenMobile:c,showPushPulse:l,setShowPushPulse:u}=Tj(),d;t[5]!==o||t[6]!==i||t[7]!==s||t[8]!==c?(d=e=>{i?.(e),!e.defaultPrevented&&(!o||!s||e.target?.closest(`[data-sidebar="trigger"]`)||c(!1))},t[5]=o,t[6]=i,t[7]=s,t[8]=c,t[9]=d):d=t[9];let f=d,p;t[10]!==r||t[11]!==u?(p=e=>{r?.(e),e.animationName===`sidebar-push-pulse`&&u(!1)},t[10]=r,t[11]=u,t[12]=p):p=t[12];let m=p,h=l?``:void 0,g;t[13]===n?g=t[14]:(g=Y(`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`,`transition-transform duration-200 ease-linear motion-reduce:transition-none`,`peer-data-[mobile=true]:peer-data-[state=expanded]:translate-x-(--sidebar-width)`,n),t[13]=n,t[14]=g);let _;return t[15]!==m||t[16]!==f||t[17]!==a||t[18]!==h||t[19]!==g?(_=(0,Z.jsx)(`main`,{"data-slot":`sidebar-inset`,"data-push-pulse":h,onClick:f,onAnimationEnd:m,className:g,...a}),t[15]=m,t[16]=f,t[17]=a,t[18]=h,t[19]=g,t[20]=_):_=t[20],_}function Nj(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=Y(`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 Pj(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=Y(`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 Fj(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=Y(`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 Ij(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=Y(`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 Lj(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=Y(`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 Rj=Lr(`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 zj(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?Rr:`button`,{isMobile:m,state:h}=Tj(),g;t[8]!==n||t[9]!==f||t[10]!==d?(g=Y(Rj({variant:d,size:f}),n),t[8]=n,t[9]=f,t[10]=d,t[11]=g):g=t[11];let _;t[12]!==p||t[13]!==u||t[14]!==r||t[15]!==f||t[16]!==g?(_=(0,Z.jsx)(p,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":f,"data-active":u,className:g,...r}),t[12]=p,t[13]=u,t[14]=r,t[15]=f,t[16]=g,t[17]=_):_=t[17];let v=_;if(!c)return v;if(typeof c==`string`){let e;t[18]===c?e=t[19]:(e={children:c},t[18]=c,t[19]=e),c=e}let y;t[20]===v?y=t[21]:(y=(0,Z.jsx)(so,{asChild:!0,children:v}),t[20]=v,t[21]=y);let b=h!==`collapsed`||m,x;t[22]!==b||t[23]!==c?(x=(0,Z.jsx)(co,{side:`right`,align:`center`,hidden:b,...c}),t[22]=b,t[23]=c,t[24]=x):x=t[24];let S;return t[25]!==y||t[26]!==x?(S=(0,Z.jsxs)(uo,{children:[y,x]}),t[25]=y,t[26]=x,t[27]=S):S=t[27],S}function Bj(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 Vj(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 Hj=1e3,Uj=!1;function Wj(e){return!!(e.localPrincipalId&&e.entryPrincipalId===e.localPrincipalId||!e.localPrincipalId&&e.entryClientId===e.localClientId)}function Gj(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:si(i)?a=i:(a=void 0,Uj||(Uj=!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`&&(Wj({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=Vj(i),{current:c,crossDoc:l}=a?ni(a,n,Date.now()):{current:[],crossDoc:[]},u=Kj,d=c.map(u),f=l.map(u),p=[...s,...d],m=f;o(e=>Bj(e.current,p)&&Bj(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,Hj);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 Kj(e){let{agentId:t,entry:n}=e;return{kind:`agent`,agentId:t,presence:n}}var qj=`sync-status`;function Jj(e,t){let n=(0,$.c)(4),r=(0,Q.useRef)(!1),i=(0,Q.useRef)(!1),a=(0,Q.useRef)(t),o,s;n[0]!==t||n[1]!==e?(o=()=>{a.current!==t&&(a.current=t,r.current=!1,i.current=!1),t&&(e===`synced`&&(r.current=!0),e===`disconnected`&&r.current?(i.current=!0,Xa.warning(`Connection lost — keep this tab open, your edits will sync when reconnected`,{id:qj,duration:1/0})):i.current&&e===`synced`&&(i.current=!1,Xa.success(`Reconnected`,{id:qj,duration:3e3})))},s=[e,t],n[0]=t,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),(0,Q.useEffect)(o,s)}var Yj=4,Xj=3,Zj={Bird:ns,Cat:cs,Dog:xs,Fish:Ts,Mouse:$s,Rabbit:Qs,Shrimp:ic,Snail:ac,Squirrel:lc,Turtle:mc};Object.freeze([...Object.keys(Zj)]);function Qj(e){if(typeof e.principalId==`string`&&e.principalId.length>0)return{kind:`initials`};let t=e.name.split(` `)[1];return t&&Object.hasOwn(Zj,t)?{kind:`animal`,animal:t}:{kind:`initials`}}var $j={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function eM(e){let t=(0,$.c)(20),{user:n,mode:r,tabCount:i}=e,a=Qj(n),o=a.kind===`animal`?Zj[a.animal]:void 0,s;t[0]===n.name?s=t[1]:(s=Rn(n.name),t[0]=n.name,t[1]=s);let c=s,l;t[2]===n.color?l=t[3]:(l=Or(n.color),t[2]=n.color,t[3]=l);let u=l,d=i>1?`${n.name} · ${i} tabs`:n.name,f=i>1?`${n.name}, ${i} concurrent tabs`:n.name,p;t[4]===n.color?p=t[5]:(p={backgroundColor:n.color},t[4]=n.color,t[5]=p);let m;t[6]!==o||t[7]!==u||t[8]!==c?(m=o?(0,Z.jsx)(o,{size:18,color:u,strokeWidth:1.5}):(0,Z.jsx)(`span`,{className:`font-mono text-2xs font-semibold leading-none`,style:{color:u},children:c}),t[6]=o,t[7]=u,t[8]=c,t[9]=m):m=t[9];let h;t[10]!==f||t[11]!==r||t[12]!==p||t[13]!==m?(h=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(`div`,{"data-presence-badge":`human`,"data-presence-mode":r,role:`img`,"aria-label":f,className:`inline-flex size-7 shrink-0 cursor-default items-center justify-center rounded-full ring-2 ring-background`,style:p,children:m})}),t[10]=f,t[11]=r,t[12]=p,t[13]=m,t[14]=h):h=t[14];let g;t[15]===d?g=t[16]:(g=(0,Z.jsx)(co,{children:d}),t[15]=d,t[16]=g);let _;return t[17]!==h||t[18]!==g?(_=(0,Z.jsxs)(uo,{children:[h,g]}),t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function tM(e){let t=$j[e.icon];return e.displayName||t||`Agent`}function nM(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 rM(e){let t=(0,$.c)(36),{participant:n,crossDoc:r,scoped:i,onClickAgent:a}=e,{presence:o,agentId:s}=n,c;t[0]===o?c=t[1]:(c=tM(o),t[0]=o,t[1]=c);let l=c,u=nM(o.mode),d=!r&&u,f=i?`ring-primary ring-offset-2 ring-offset-background`:`ring-background`,p=d&&!i?`ring-primary/40 animate-pulse`:``,m;t[2]!==f||t[3]!==p?(m=[`inline-flex size-7 shrink-0 items-center justify-center rounded-full ring-2 cursor-pointer`,f,p].filter(Boolean),t[2]=f,t[3]=p,t[4]=m):m=t[4];let h=m.join(` `),g=r?`true`:void 0,_=i?`true`:void 0,v;t[5]!==o.mode||t[6]!==g||t[7]!==_?(v={"data-presence-badge":`agent`,"data-presence-mode":o.mode,"data-presence-crossdoc":g,"data-presence-scoped":_},t[5]=o.mode,t[6]=g,t[7]=_,t[8]=v):v=t[8];let y=v,b=o.currentDoc&&o.currentDoc!==`(connected)`?o.currentDoc:null,x=r&&b?`Open activity panel for ${l}, editing ${b}`:`Open activity panel for ${l}`,S;t[9]===o.color?S=t[10]:(S={backgroundColor:o.color},t[9]=o.color,t[10]=S);let C;t[11]!==s||t[12]!==a?(C=()=>a(s),t[11]=s,t[12]=a,t[13]=C):C=t[13];let w;t[14]===o.icon?w=t[15]:(w=(0,Z.jsx)(ai,{icon:o.icon,width:16,height:16,className:`text-white`}),t[14]=o.icon,t[15]=w);let T;t[16]!==x||t[17]!==y||t[18]!==h||t[19]!==w||t[20]!==S||t[21]!==C?(T=(0,Z.jsx)(`button`,{type:`button`,...y,"aria-label":x,className:h,style:S,onClick:C,children:w}),t[16]=x,t[17]=y,t[18]=h,t[19]=w,t[20]=S,t[21]=C,t[22]=T):T=t[22];let E=T,D;t[23]===E?D=t[24]:(D=(0,Z.jsx)(so,{asChild:!0,children:E}),t[23]=E,t[24]=D);let O;t[25]===l?O=t[26]:(O=(0,Z.jsx)(`span`,{className:`font-medium`,children:l}),t[25]=l,t[26]=O);let k;t[27]!==r||t[28]!==b?(k=r&&b?(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`editing [[`,b,`]]`]}):null,t[27]=r,t[28]=b,t[29]=k):k=t[29];let A;t[30]!==O||t[31]!==k?(A=(0,Z.jsxs)(co,{className:`flex flex-col gap-0.5`,children:[O,k]}),t[30]=O,t[31]=k,t[32]=A):A=t[32];let j;return t[33]!==D||t[34]!==A?(j=(0,Z.jsxs)(uo,{children:[D,A]}),t[33]=D,t[34]=A,t[35]=j):j=t[35],j}function iM(e){let t=(0,$.c)(18),{count:n,remainder:r,crossDoc:i,scopedAgentId:a,onClickAgent:o}=e,s=i?`true`:void 0,c=`${n} more ${i?`cross-doc `:``}${n===1?`participant`:`participants`}`,l;t[0]!==n||t[1]!==s||t[2]!==c?(l=(0,Z.jsx)(ie,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`presence-overflow`,"data-presence-crossdoc":s,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[0]=n,t[1]=s,t[2]=c,t[3]=l):l=t[3];let u;if(t[4]!==i||t[5]!==o||t[6]!==r||t[7]!==a){let e;t[9]!==i||t[10]!==o||t[11]!==a?(e=e=>e.kind===`human`?(0,Z.jsx)(eM,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(rM,{participant:e,crossDoc:i,scoped:a===e.agentId,onClickAgent:o},e.agentId),t[9]=i,t[10]=o,t[11]=a,t[12]=e):e=t[12],u=r.map(e),t[4]=i,t[5]=o,t[6]=r,t[7]=a,t[8]=u}else u=t[8];let d;t[13]===u?d=t[14]:(d=(0,Z.jsx)(ae,{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:u})}),t[13]=u,t[14]=d);let f;return t[15]!==l||t[16]!==d?(f=(0,Z.jsxs)(E,{children:[l,d]}),t[15]=l,t[16]=d,t[17]=f):f=t[17],f}function aM(e,t,n,r){return e.kind===`human`?(0,Z.jsx)(eM,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(rM,{participant:e,crossDoc:n,scoped:r===e.agentId,onClickAgent:t},e.agentId)}function oM(){let e=(0,$.c)(20),{activeProvider:t,activeDocName:n,systemProvider:r,openActivityPanel:i,docPanelMode:a,docPanelAgentId:o}=We(),{current:s,crossDoc:c}=Gj(t,r,n);Jj(UO(t),n);let l;if(e[0]!==c||e[1]!==s||e[2]!==o||e[3]!==a||e[4]!==i){let t=s.slice(0,Yj),n;e[6]===s?n=e[7]:(n=s.slice(Yj),e[6]=s,e[7]=n);let r=n,u=c.slice(0,Xj),d;e[8]===c?d=e[9]:(d=c.slice(Xj),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=>aM(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)(iM,{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=>aM(e,p,!0,m)),f.length>0?(0,Z.jsx)(iM,{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 sM(e,t){return t.trim()}function cM(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function lM(e,t){let n=sM(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function uM(e,t,n=[]){if(t.length===0&&n.length===0)return e;let r=new Map(t.map(e=>[e.fromDocName,e.toDocName]));return e.map(e=>Ar(e)?{...e,docName:r.get(e.docName)??e.docName}:Pr(e)||Fn(e)?{...e,path:pM(e.path,n)}:e)}function dM(e,t,n){if(t.length===0&&!n)return e;let r=new Set(t);return e.filter(e=>Ar(e)?!r.has(e.docName)&&!mM(e.docName,n):Pr(e)||Fn(e)?!mM(e.path,n):!0)}function fM(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}function pM(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 mM(e,t){return!!t&&(e===t||e.startsWith(`${t}/`))}function hM(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)(bl,{"data-slot":`context-menu`,...n}),t[2]=n,t[3]=r),r}function gM(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=Y(`select-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(xl,{"data-slot":`context-menu-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function _M(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=Y(`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`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Sl,{children:(0,Z.jsx)(Cl,{"data-slot":`context-menu-content`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function vM(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=Y(`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)(wl,{"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 yM(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=Y(`-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)(Tl,{"data-slot":`context-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function bM(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=Y(`group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`input-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var xM=Lr(`flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4`,{variants:{align:{"inline-start":`order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]`,"inline-end":`order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]`,"block-start":`order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2`,"block-end":`order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2`}},defaultVariants:{align:`inline-start`}});function SM(e){let t=(0,$.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,align:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`inline-start`:i,o;t[4]!==a||t[5]!==n?(o=Y(xM({align:a}),n),t[4]=a,t[5]=n,t[6]=o):o=t[6];let s;return t[7]!==a||t[8]!==r||t[9]!==o?(s=(0,Z.jsx)(`div`,{"data-slot":`input-group-addon`,"data-align":a,className:o,onMouseDown:CM,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function CM(e){e.target.closest(`button`)||(e.preventDefault(),e.currentTarget.parentElement?.querySelector(`input`)?.focus())}Lr(`flex items-center gap-2 text-sm shadow-none`,{variants:{size:{xs:`h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5`,sm:``,"icon-xs":`size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0`,"icon-sm":`size-8 p-0 has-[>svg]:p-0`}},defaultVariants:{size:`xs`}});function wM(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=Y(`flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`span`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function TM(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=Y(`flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(fo,{"data-slot":`input-group-control`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var EM=[`.md`,`.mdx`],DM=`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`,OM=`z-10 rounded-t-lg rounded-b-none border-border border-b-0 bg-background text-foreground`,kM=Y(OM,`bg-transparent hover:bg-muted focus-visible:bg-muted border-transparent hover:border-border focus-visible:border-border`),AM=`flex h-full min-w-0 flex-1 cursor-pointer items-center overflow-hidden px-3 text-left text-[13px] outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,jM=`mr-2 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 focus-visible:opacity-100`;function MM(e){return Y(jM,e?`opacity-100`:`pointer-events-none opacity-0 group-focus-within:pointer-events-auto group-focus-within:opacity-100 group-hover:pointer-events-auto group-hover:opacity-100`)}function NM(e,t){let n=e.lastIndexOf(`/`),r=n<0?e:e.slice(n+1),i=`${r}${t}`;return n<0?{baseName:r,extension:t,label:i,prefix:``}:{baseName:r,extension:t,label:i,prefix:`${e.slice(0,n)}/`}}function PM(e){return e.replace(/[^A-Za-z0-9_-]/g,`-`)}function FM(e){let t=er(e);window.location.hash!==t&&(window.location.hash=t)}function IM(e){Math.abs(e.deltaX)>=Math.abs(e.deltaY)||e.currentTarget.scrollWidth<=e.currentTarget.clientWidth||(e.preventDefault(),e.currentTarget.scrollLeft+=e.deltaY)}function LM(e,t){let n=[t,...EM].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 RM(e){let t=(0,$.c)(48),{children:n,closeTab:r,closeTabs:i,canPin:a,disabled:o,openTabs:s,pinTab:c,pinnedTabIds:l,tabId:u,unpinTab:d}=e,f=a===void 0?!0:a;if(o!==void 0&&o)return n;let p;t[0]!==f||t[1]!==l||t[2]!==u?(p=f&&l.includes(u),t[0]=f,t[1]=l,t[2]=u,t[3]=p):p=t[3];let m=p,h;if(t[4]!==s||t[5]!==l||t[6]!==u){let e;t[8]===u?e=t[9]:(e=e=>e!==u,t[8]=u,t[9]=e),h=Pe(s.filter(e),l),t[4]=s,t[5]=l,t[6]=u,t[7]=h}else h=t[7];let g=h,_;t[10]!==s||t[11]!==l?(_=Pe(s,l),t[10]=s,t[11]=l,t[12]=_):_=t[12];let v=_,y=l.length?`Close all unpinned`:`Close all`,b;t[13]===n?b=t[14]:(b=(0,Z.jsx)(gM,{asChild:!0,children:n}),t[13]=n,t[14]=b);let x;t[15]!==r||t[16]!==u?(x=()=>r(u),t[15]=r,t[16]=u,t[17]=x):x=t[17];let S;t[18]!==m||t[19]!==x?(S=(0,Z.jsx)(vM,{disabled:m,onSelect:x,children:`Close`}),t[18]=m,t[19]=x,t[20]=S):S=t[20];let C=g.length===0,w;t[21]!==i||t[22]!==g?(w=()=>{i(g)},t[21]=i,t[22]=g,t[23]=w):w=t[23];let T;t[24]!==w||t[25]!==C?(T=(0,Z.jsx)(vM,{disabled:C,onSelect:w,children:`Close others`}),t[24]=w,t[25]=C,t[26]=T):T=t[26];let E=v.length===0,D;t[27]!==v||t[28]!==i?(D=()=>{i(v)},t[27]=v,t[28]=i,t[29]=D):D=t[29];let O;t[30]!==y||t[31]!==E||t[32]!==D?(O=(0,Z.jsx)(vM,{disabled:E,onSelect:D,children:y}),t[30]=y,t[31]=E,t[32]=D,t[33]=O):O=t[33];let k;t[34]!==f||t[35]!==m||t[36]!==c||t[37]!==u||t[38]!==d?(k=f&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(yM,{}),(0,Z.jsx)(vM,{onSelect:()=>m?d(u):c(u),children:m?`Unpin tab`:`Pin tab`})]}),t[34]=f,t[35]=m,t[36]=c,t[37]=u,t[38]=d,t[39]=k):k=t[39];let A;t[40]!==T||t[41]!==O||t[42]!==k||t[43]!==S?(A=(0,Z.jsxs)(_M,{className:`min-w-40`,children:[S,T,O,k]}),t[40]=T,t[41]=O,t[42]=k,t[43]=S,t[44]=A):A=t[44];let j;return t[45]!==A||t[46]!==b?(j=(0,Z.jsxs)(hM,{children:[b,A]}),t[45]=A,t[46]=b,t[47]=j):j=t[47],j}function zM(e){let t=(0,$.c)(14),{accessibleLabel:n,closeTab:r,isPinned:i,tabId:a,unpinTab:o}=e;if(i){let e=`Unpin ${n}`,r;t[0]!==a||t[1]!==o?(r=e=>{e.stopPropagation(),o(a)},t[0]=a,t[1]=o,t[2]=r):r=t[2];let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(Zs,{"aria-hidden":`true`}),t[3]=i):i=t[3];let s;return t[4]!==e||t[5]!==r?(s=(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":e,className:`mr-2 text-primary! hover:bg-primary/10!`,onClick:r,children:i}),t[4]=e,t[5]=r,t[6]=s):s=t[6],s}let s=`Close ${n}`,c;t[7]!==r||t[8]!==a?(c=e=>{e.stopPropagation(),r(a)},t[7]=r,t[8]=a,t[9]=c):c=t[9];let l;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(Fa,{"aria-hidden":`true`}),t[10]=l):l=t[10];let u;return t[11]!==s||t[12]!==c?(u=(0,Z.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":s,className:`mr-2`,onClick:c,children:l}),t[11]=s,t[12]=c,t[13]=u):u=t[13],u}function BM(){let e=(0,$.c)(68),{activeDocName:t,activeTabId:n,activeNewTabId:r,activeTarget:i,activateTab:a,activateNewTab:o,closeAndClearForRename:s,closeNewTab:c,closeTab:l,closeTabs:u,isNewTabActive:d,newTabIds:f,openNewTab:p,openTabs:m,pinTab:h,pinnedTabIds:g,remapTabsForRename:_,unpinTab:v,visibleTabIds:y}=We(),{pageMeta:b}=wr(),x=(0,Q.useRef)(null),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(!1),A=(0,Q.useRef)(null),j=(0,Q.useRef)(!1),N=(0,Q.useRef)(!1),P=(0,Q.useRef)(null),F=(0,Q.useRef)(t),I;e[0]!==n||e[1]!==t||e[2]!==i?(I=n??(i?ve(i):t?nt(t):null),e[0]=n,e[1]=t,e[2]=i,e[3]=I):I=e[3];let L=I,R;e[4]!==r||e[5]!==L||e[6]!==d||e[7]!==f||e[8]!==m?(R=d?`${r??`__new-tab__`}\u0000${m.join(`\0`)}\u0000${f.join(`\0`)}`:L?`${L}\u0000${m.join(`\0`)}`:``,e[4]=r,e[5]=L,e[6]=d,e[7]=f,e[8]=m,e[9]=R):R=e[9];let z=R,B,V;e[10]===t?(B=e[11],V=e[12]):(B=()=>{F.current=t},V=[t],e[10]=t,e[11]=B,e[12]=V),(0,Q.useEffect)(B,V);let H,U;e[13]===z?(H=e[14],U=e[15]):(H=()=>{z&&(x.current?.querySelector(`[data-active-tab="true"]`))?.scrollIntoView({block:`nearest`,inline:`nearest`})},U=[z],e[13]=z,e[14]=H,e[15]=U),(0,Q.useEffect)(H,U);let W,G;e[16]===S?(W=e[17],G=e[18]):(W=()=>{S&&(A.current?.focus(),A.current?.select())},G=[S],e[16]=S,e[17]=W,e[18]=G),(0,Q.useEffect)(W,G);let K,q;e[19]!==m||e[20]!==S?(K=()=>{!S||m.includes(S.tabId)||(N.current=!0,P.current=null,C(null),T(``),D(null),k(!1))},q=[m,S],e[19]=m,e[20]=S,e[21]=K,e[22]=q):(K=e[21],q=e[22]),(0,Q.useEffect)(K,q);let ee,te,ne,re,ie;if(e[23]!==o||e[24]!==a||e[25]!==r||e[26]!==L||e[27]!==s||e[28]!==c||e[29]!==l||e[30]!==u||e[31]!==O||e[32]!==f||e[33]!==b||e[34]!==h||e[35]!==g||e[36]!==_||e[37]!==E||e[38]!==w||e[39]!==S?.docName||e[40]!==S?.tabId||e[41]!==v||e[42]!==y){let t=function(e,t){let n=t.split(`/`);N.current=!1,P.current=null,C({docName:t,tabId:e}),T(n[n.length-1]),D(null)},n=function(){N.current=!0,P.current=null,C(null),T(``),D(null),k(!1)},i=async function(){if(N.current){N.current=!1;return}if(j.current)return;let e=S?.docName;if(!e){n();return}let t=sM(`file`,LM(w,b.get(e)?.docExt??`.md`)),r=e.split(`/`),i=r[r.length-1];if(t===i){n();return}if(t===P.current){A.current?.focus();return}if(!cM(t)){D(`Name can’t be empty, ".", "..", or contain / or \\`),A.current?.focus();return}let a=lM({kind:`file`,path:e,name:i},t);j.current=!0,k(!0),D(null);try{let n=await fetch(`/api/rename-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:`file`,fromPath:e,toPath:a})});if(N.current){k(!1),j.current=!1;return}let r=await Le(n,`Server error (HTTP ${n.status})`);if(!r.ok){D(r.title),k(!1),j.current=!1,P.current=t,A.current?.focus();return}let i=M(vn,r.body,`rename-path:tab`,{renamed:[]}).renamed,o=F.current,c=fM(o,i);await Promise.all(i.flatMap(e=>[s(e.fromDocName),s(e.toDocName)])),_(i),Kn([`files`,`backlinks`,`graph`]),N.current=!0,C(null),T(``),D(null),k(!1),j.current=!1,P.current=null,c&&c!==o&&FM(c)}catch(n){console.warn(`[EditorTabs] rename failed`,{err:n,docName:e,newDocName:a,normalized:t}),D(`Network error — please try again`),k(!1),j.current=!1,P.current=t,A.current?.focus()}};ee=typeof window<`u`&&window.okDesktop!=null;let d;e[48]===f?d=e[49]:(d=new Set(f),e[48]=f,e[49]=d);let p=d,m;e[50]!==c||e[51]!==u||e[52]!==p?(m=function(e){let t=[],n=[];for(let r of e)p.has(r)?n.push(r):t.push(r);t.length>0&&u(t);for(let e of n)c(e)},e[50]=c,e[51]=u,e[52]=p,e[53]=m):m=e[53];let I=m;te=x,e[54]===Symbol.for(`react.memo_cache_sentinel`)?(ne=Y(`pl-2 flex h-12 min-w-0 touch-manipulation flex-1 items-end gap-1 overflow-x-auto overflow-y-hidden overscroll-x-contain scroll-fade-mask-x [scrollbar-width:none]`,ee&&`[-webkit-app-region:drag]`),e[54]=ne):ne=e[54],re=IM,ie=y.map(e=>{if(p.has(e)){let t=e===r;return(0,Z.jsx)(RM,{tabId:e,canPin:!1,openTabs:y,closeTab:c,closeTabs:I,pinTab:h,pinnedTabIds:g,unpinTab:v,children:(0,Z.jsxs)(`div`,{role:`presentation`,"data-active-tab":t?`true`:void 0,className:Y(DM,t?OM:kM,ee&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),c(e))},onClick:t=>{t.target===t.currentTarget&&o(e)},children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Activate new tab`,className:AM,onClick:()=>o(e),children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:`New tab`})}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Close new tab`,className:MM(t),onClick:t=>{t.stopPropagation(),c(e)},children:(0,Z.jsx)(Fa,{"aria-hidden":`true`,className:`size-3.5`})})]})},e)}let s=Ye(e),u=e===L,d=g.includes(e);if(s.kind===`folder`){let{baseName:t,label:n,prefix:r}=NM(s.folderPath,`/`),i=`${r}${n}`;return(0,Z.jsx)(RM,{tabId:e,openTabs:y,closeTab:l,closeTabs:I,pinTab:h,pinnedTabIds:g,unpinTab:v,children:(0,Z.jsxs)(`div`,{role:`presentation`,"data-active-tab":u?`true`:void 0,className:Y(DM,u?OM:kM,ee&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!d&&l(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":i,className:AM,onClick:()=>{a(e)},children:[r&&(0,Z.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate`,u&&`text-muted-foreground`),children:r}),(0,Z.jsxs)(`span`,{className:Y(`flex min-w-0 items-center`,r?`max-w-[70%] shrink-0`:`flex-1`),children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:`/`})]})]}),(0,Z.jsx)(zM,{accessibleLabel:i,closeTab:l,isPinned:d,tabId:e,unpinTab:v})]})},e)}if(s.kind===`asset`){let{baseName:t,label:n,prefix:r}=NM(s.assetPath,``),i=`${r}${n}`;return(0,Z.jsx)(RM,{tabId:e,openTabs:y,closeTab:l,closeTabs:I,pinTab:h,pinnedTabIds:g,unpinTab:v,children:(0,Z.jsxs)(`div`,{role:`presentation`,"data-active-tab":u?`true`:void 0,className:Y(DM,u?OM:kM,ee&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!d&&l(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":i,className:AM,onClick:()=>{a(e)},children:[r?(0,Z.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate text-muted-foreground/60`,u&&`text-muted-foreground`),children:r}):null,(0,Z.jsx)(`span`,{className:Y(`min-w-0 truncate`,r?`max-w-[70%] shrink-0`:`flex-1`),children:t})]}),(0,Z.jsx)(zM,{accessibleLabel:i,closeTab:l,isPinned:d,tabId:e,unpinTab:v})]})},e)}let f=s.docName,m=b.get(f)?.docExt??`.md`,{baseName:_,extension:x,label:C,prefix:k}=NM(f,m),j=`${k}${C}`,M=S?.tabId===e,N=`editor-tab-rename-error-${PM(f)}`;return(0,Z.jsx)(RM,{disabled:M,tabId:e,openTabs:y,closeTab:l,closeTabs:I,pinTab:h,pinnedTabIds:g,unpinTab:v,children:(0,Z.jsx)(`div`,{role:`presentation`,"data-active-tab":u?`true`:void 0,className:Y(DM,u?OM:kM,M&&E&&`border-destructive`,ee&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!d&&l(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:M?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(bM,{className:`h-full min-w-0 flex-1 rounded-none border-0 bg-transparent dark:bg-transparent`,children:[(0,Z.jsx)(TM,{ref:A,value:w,disabled:O,"aria-label":`Rename ${C}`,"aria-invalid":E?!0:void 0,"aria-describedby":E?N:void 0,"aria-busy":O||void 0,title:E??f,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=>{T(LM(e.target.value,m)),D(null),P.current=null},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),i()):e.key===`Escape`&&(e.preventDefault(),n())},onBlur:i}),(0,Z.jsx)(SM,{align:`inline-end`,"aria-hidden":`true`,className:`pr-2 text-xs`,children:(0,Z.jsx)(wM,{className:`text-muted-foreground/60 text-xs`,children:m})})]}),E?(0,Z.jsx)(`span`,{id:N,role:`alert`,className:`sr-only`,children:E}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":j,className:AM,onClick:()=>{a(e)},onDoubleClick:n=>{n.preventDefault(),n.stopPropagation(),t(e,f)},children:[k&&(0,Z.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate text-muted-foreground/60`,u&&`text-muted-foreground`),children:k}),(0,Z.jsxs)(`span`,{className:Y(`flex min-w-0 items-center`,k?`max-w-[70%] shrink-0`:`flex-1`),children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:_}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:x})]})]}),(0,Z.jsx)(zM,{accessibleLabel:j,closeTab:l,isPinned:d,tabId:e,unpinTab:v})]})})},e)}),e[23]=o,e[24]=a,e[25]=r,e[26]=L,e[27]=s,e[28]=c,e[29]=l,e[30]=u,e[31]=O,e[32]=f,e[33]=b,e[34]=h,e[35]=g,e[36]=_,e[37]=E,e[38]=w,e[39]=S?.docName,e[40]=S?.tabId,e[41]=v,e[42]=y,e[43]=ee,e[44]=te,e[45]=ne,e[46]=re,e[47]=ie}else ee=e[43],te=e[44],ne=e[45],re=e[46],ie=e[47];let ae;e[55]===Symbol.for(`react.memo_cache_sentinel`)?(ae=Y(`first:mb-3 mb-1.5`,ee&&`[-webkit-app-region:no-drag]`),e[55]=ae):ae=e[55];let oe;e[56]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,Z.jsx)(Fi,{"aria-hidden":`true`}),e[56]=oe):oe=e[56];let se;e[57]===p?se=e[58]:(se=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{type:`button`,size:`icon-xs`,variant:`ghost`,"aria-label":`New tab`,className:ae,onClick:p,children:oe})}),e[57]=p,e[58]=se);let ce;e[59]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Z.jsx)(co,{children:`New tab`}),e[59]=ce):ce=e[59];let le;e[60]===se?le=e[61]:(le=(0,Z.jsxs)(uo,{children:[se,ce]}),e[60]=se,e[61]=le);let ue;return e[62]!==te||e[63]!==ne||e[64]!==re||e[65]!==ie||e[66]!==le?(ue=(0,Z.jsxs)(`div`,{ref:te,className:ne,onWheel:re,children:[ie,le]}),e[62]=te,e[63]=ne,e[64]=re,e[65]=ie,e[66]=le,e[67]=ue):ue=e[67],ue}function VM(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 HM(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 UM=[{label:`Documentation`,href:`https://openknowledge.ai/docs`,icon:j},{label:`GitHub`,href:`https://github.com/inkeep/open-knowledge`,icon:Du},{label:`Website`,href:`https://openknowledge.ai/`,icon:ja},{label:`Discord`,href:`https://go.inkeep.com/ok-discord`,icon:VM},{label:`Twitter`,href:`https://x.com/inkeep`,icon:HM}],WM=()=>{let e=(0,$.c)(5),[t,n]=(0,Q.useState)(!1),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(ie,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[(0,Z.jsx)(I,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Resources`})]})})}),(0,Z.jsx)(co,{children:`Resources`})]}),e[0]=r):r=e[0];let i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs mb-1`,children:`Resources`}),e[1]=i):i=e[1];let a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsxs)(ae,{align:`end`,className:`w-64 p-3`,children:[i,(0,Z.jsx)(`nav`,{"aria-label":`Resources`,children:(0,Z.jsx)(`ul`,{className:`space-y-0.5`,children:UM.map(GM)})})]}),e[2]=a):a=e[2];let o;return e[3]===t?o=e[4]:(o=(0,Z.jsxs)(E,{open:t,onOpenChange:n,children:[r,a]}),e[3]=t,e[4]=o),o};function GM(e){let{label:t,href:n,icon:r}=e;return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>pi(e,n),onAuxClick:e=>pi(e,n),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)(r,{"aria-hidden":`true`,className:`size-4 shrink-0`}),t]})},n)}function KM(e){let t=(0,$.c)(70),{input:n}=e,{states:r,refresh:i}=Wp(),{dispatch:a}=Np(),{skillInstalled:o,refresh:s}=la(),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),f=typeof window<`u`&&window.okDesktop!=null,p;t[0]===i?p=t[1]:(p=e=>{l(e),e&&i()},t[0]=i,t[1]=p);let m=p,h=n===null,g;t[2]===n?g=t[3]:(g=n!==null&&n.docContext!==null?tr(n.docContext):``,t[2]=n,t[3]=g);let _=g,y;t[4]!==a||t[5]!==n?(y=e=>{n!==null&&a(e.id,n)},t[4]=a,t[5]=n,t[6]=y):y=t[6];let b=y,x,S,C,w,T,E,D,O,k,A,j,M;if(t[7]!==m||t[8]!==b||t[9]!==n||t[10]!==c||t[11]!==_||t[12]!==o||t[13]!==r||t[14]!==h){let e;t[27]===r?e=t[28]:(e=e=>r[e.id]?.installed===!0,t[27]=r,t[28]=e);let i=zf.filter(e);C=r[`claude-cowork`]?.installed===!0;let a;t[29]!==n||t[30]!==_?(a=()=>{n!==null&&tb(_)},t[29]=n,t[30]=_,t[31]=a):a=t[31],w=a,S=ji,M=c,T=m;let s;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(ii,{className:`size-4`}),t[32]=s):s=t[32];let l;t[33]===h?l=t[34]:(l=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(Si,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit with AI`,disabled:h,className:`text-muted-foreground`,"data-testid":`open-in-agent-trigger`,children:s})})}),t[33]=h,t[34]=l);let u;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(co,{children:`Edit with AI`}),t[35]=u):u=t[35],t[36]===l?E=t[37]:(E=(0,Z.jsxs)(uo,{children:[l,u]}),t[36]=l,t[37]=E),x=Aa,D=`end`,O=`min-w-[220px]`,k=`open-in-agent-menu`,t[38]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(Li,{className:`font-mono font-normal tracking-wide uppercase text-muted-foreground text-xs`,children:`Open in`}),t[38]=A):A=t[38];let p;t[39]!==b||t[40]!==_||t[41]!==o||t[42]!==r?(p=e=>{let t=r[e.id];return(0,Z.jsx)(rb,{target:e,installState:t,isElectronHost:f,prompt:_,onSelect:()=>b(e),onInstallSkillRequest:e.id===`claude-cowork`&&!o?()=>d(!0):void 0},e.id)},t[39]=b,t[40]=_,t[41]=o,t[42]=r,t[43]=p):p=t[43],j=i.map(p),t[7]=m,t[8]=b,t[9]=n,t[10]=c,t[11]=_,t[12]=o,t[13]=r,t[14]=h,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]=k,t[24]=A,t[25]=j,t[26]=M}else x=t[15],S=t[16],C=t[17],w=t[18],T=t[19],E=t[20],D=t[21],O=t[22],k=t[23],A=t[24],j=t[25],M=t[26];let N;t[44]!==C||t[45]!==w||t[46]!==n?(N=C?null:(0,Z.jsxs)(di,{onSelect:w,disabled:n===null,"data-testid":`open-in-agent-claude-web-fallback`,"aria-label":`Open in claude.ai, opens in browser with prompt pre-filled`,children:[(0,Z.jsx)(v,{className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:`Open in claude.ai →`}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`opens in browser`})]}),t[44]=C,t[45]=w,t[46]=n,t[47]=N):N=t[47];let P;t[48]!==x||t[49]!==N||t[50]!==D||t[51]!==O||t[52]!==k||t[53]!==A||t[54]!==j?(P=(0,Z.jsxs)(x,{align:D,className:O,"data-testid":k,children:[A,j,N]}),t[48]=x,t[49]=N,t[50]=D,t[51]=O,t[52]=k,t[53]=A,t[54]=j,t[55]=P):P=t[55];let F;t[56]!==S||t[57]!==T||t[58]!==E||t[59]!==P||t[60]!==M?(F=(0,Z.jsxs)(S,{open:M,onOpenChange:T,children:[E,P]}),t[56]=S,t[57]=T,t[58]=E,t[59]=P,t[60]=M,t[61]=F):F=t[61];let I;t[62]===s?I=t[63]:(I=e=>{d(e),e||s()},t[62]=s,t[63]=I);let L;t[64]!==u||t[65]!==I?(L=(0,Z.jsx)(ta,{open:u,onOpenChange:I}),t[64]=u,t[65]=I,t[66]=L):L=t[66];let R;return t[67]!==F||t[68]!==L?(R=(0,Z.jsxs)(Z.Fragment,{children:[F,L]}),t[67]=F,t[68]=L,t[69]=R):R=t[69],R}var qM=()=>{let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,"data-testid":`header-settings-button`,onClick:JM,children:[(0,Z.jsx)(rc,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Settings`})]})}),(0,Z.jsx)(co,{children:`Settings`})]}),e[0]=t):t=e[0],t};function JM(){window.location.hash!==`#settings`&&(window.location.hash=Bf)}function YM(e){if(!e)return`never`;let t=Date.now()-new Date(e).getTime();return t<6e4?`just now`:t<36e5?`${Math.floor(t/6e4)} min ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:new Date(e).toLocaleDateString()}async function XM(e){await fetch(`/api/sync/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({op:e})})}function ZM(e){let t=(0,$.c)(9),{status:n}=e;switch(n.state){case`dormant`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ps,{className:`size-3.5 text-muted-foreground`}),t[0]=e):e=t[0],e}case`idle`:{if(n.ahead>0||n.behind>0){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ec,{className:`size-3.5 text-muted-foreground`}),t[1]=e):e=t[1],e}let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ps,{className:`size-3.5 text-emerald-500`}),t[2]=e):e=t[2],e}case`fetching`:case`pulling`:case`pushing`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ec,{className:`size-3.5 text-muted-foreground animate-spin`}),t[3]=e):e=t[3],e}case`conflict`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Dn,{className:`size-3.5 text-amber-500`}),t[4]=e):e=t[4],e}case`offline`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(fs,{className:`size-3.5 text-muted-foreground`}),t[5]=e):e=t[5],e}case`auth-error`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Us,{className:`size-3.5 text-destructive`}),t[6]=e):e=t[6],e}case`disabled`:{let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Dn,{className:`size-3.5 text-amber-500`}),t[7]=e):e=t[7],e}default:{let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ps,{className:`size-3.5 text-muted-foreground`}),t[8]=e):e=t[8],e}}}function QM(e){switch(e.state){case`idle`:return e.ahead>0?`↑${e.ahead}`:e.behind>0?`↓${e.behind}`:``;case`fetching`:case`pulling`:case`pushing`:return``;case`conflict`:return e.conflictCount>0?`${e.conflictCount}`:``;case`offline`:return``;case`auth-error`:return``;default:return``}}function $M(e){switch(e){case`dormant`:return`No git remote`;case`idle`:return`Synced`;case`fetching`:return`Fetching`;case`pulling`:return`Pulling`;case`pushing`:return`Pushing`;case`conflict`:return`Conflict`;case`offline`:return`Offline`;case`auth-error`:return`Sign in required`;case`disabled`:return`Sync disabled`;default:return e}}function eN(e){switch(e){case`external-changes-pending`:return`External changes pending`;case`dirty-tree`:return`Working tree has uncommitted changes`;case`detached-head`:return`Detached HEAD — checkout a branch to resume`;case`auth-error`:return`Sign in required`;case`protected-branch`:return`Protected branch — cannot push`;default:return e}}function tN(e){return e.syncEnabled?e.state===`idle`?e.ahead>0&&e.behind>0?`${e.ahead} ahead, ${e.behind} behind`:e.ahead>0?`${e.ahead} ahead`:e.behind>0?`${e.behind} behind`:`Synced`:e.state===`conflict`&&e.conflictCount>0?`${e.conflictCount} conflict${e.conflictCount===1?``:`s`}`:$M(e.state):`Sync off`}function nN(e){let t=(0,$.c)(76),{status:n,onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a}=e,{projectLocalConfig:o,projectLocalSynced:s}=ba(),c=o?.autoSync?.enabled??!1,{confirmOpen:l,setConfirmOpen:u,onToggleRequest:d,onConfirm:f}=zi(Vi()),p;t[0]===n?p=t[1]:(p=(0,Z.jsx)(ZM,{status:n}),t[0]=n,t[1]=p);let m;t[2]===n.state?m=t[3]:(m=$M(n.state),t[2]=n.state,t[3]=m);let h;t[4]===m?h=t[5]:(h=(0,Z.jsx)(`span`,{className:`text-sm font-medium truncate`,children:m}),t[4]=m,t[5]=h);let g;t[6]!==p||t[7]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[p,h]}),t[6]=p,t[7]=h,t[8]=g):g=t[8];let _=!s,v=c?`Disable sync`:`Enable sync`,y;t[9]!==c||t[10]!==d||t[11]!==_||t[12]!==v?(y=(0,Z.jsx)(Fe,{checked:c,disabled:_,onCheckedChange:d,"aria-label":v}),t[9]=c,t[10]=d,t[11]=_,t[12]=v,t[13]=y):y=t[13];let b;t[14]!==g||t[15]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[g,y]}),t[14]=g,t[15]=y,t[16]=b):b=t[16];let x;t[17]!==l||t[18]!==f||t[19]!==u?(x=(0,Z.jsx)(pa,{open:l,onOpenChange:u,onConfirm:f}),t[17]=l,t[18]=f,t[19]=u,t[20]=x):x=t[20];let S;t[21]===n.error?S=t[22]:(S=n.error&&(0,Z.jsx)(`p`,{className:`text-xs text-destructive`,children:n.error}),t[21]=n.error,t[22]=S);let C;t[23]===n.pausedReason?C=t[24]:(C=n.pausedReason&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:eN(n.pausedReason)}),t[23]=n.pausedReason,t[24]=C);let w;t[25]===n.state?w=t[26]:(w=n.state===`conflict`&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-400`,children:`Sync paused — resolve conflicts to resume.`}),t[25]=n.state,t[26]=w);let T;t[27]!==c||t[28]!==n.lastSyncUtc||t[29]!==n.state?(T=c&&n.state!==`dormant`&&(0,Z.jsxs)(`div`,{children:[`Last synced: `,YM(n.lastSyncUtc)]}),t[27]=c,t[28]=n.lastSyncUtc,t[29]=n.state,t[30]=T):T=t[30];let E;t[31]===n.ahead?E=t[32]:(E=n.ahead>0&&(0,Z.jsxs)(`div`,{children:[n.ahead,` commit`,n.ahead===1?``:`s`,` ahead`]}),t[31]=n.ahead,t[32]=E);let D;t[33]===n.behind?D=t[34]:(D=n.behind>0&&(0,Z.jsxs)(`div`,{children:[n.behind,` commit`,n.behind===1?``:`s`,` behind`]}),t[33]=n.behind,t[34]=D);let O;t[35]===n.conflictCount?O=t[36]:(O=n.conflictCount>0&&(0,Z.jsxs)(`div`,{children:[n.conflictCount,` file`,n.conflictCount===1?``:`s`,` conflicted`]}),t[35]=n.conflictCount,t[36]=O);let k;t[37]===c?k=t[38]:(k=!c&&(0,Z.jsx)(`div`,{children:`Sync is off — your edits will not sync to the remote repository.`}),t[37]=c,t[38]=k);let A;t[39]!==T||t[40]!==E||t[41]!==D||t[42]!==O||t[43]!==k?(A=(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-0.5`,children:[T,E,D,O,k]}),t[39]=T,t[40]=E,t[41]=D,t[42]=O,t[43]=k,t[44]=A):A=t[44];let j;t[45]!==a||t[46]!==n.identityUnresolved?(j=n.identityUnresolved&&a&&(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed p-2`,children:[(0,Z.jsx)(vc,{className:`size-3.5 mt-0.5 text-muted-foreground shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground leading-snug`,children:`Git identity isn't set — commits use a default author. Set yours so teammates see your name.`}),(0,Z.jsx)(X,{variant:`outline`,size:`xs`,className:`self-start`,onClick:a,children:`Set identity`})]})]}),t[45]=a,t[46]=n.identityUnresolved,t[47]=j):j=t[47];let M;t[48]!==c||t[49]!==n.state?(M=c&&n.state!==`dormant`&&n.state!==`disabled`&&n.state!==`auth-error`&&n.state!==`conflict`&&(0,Z.jsx)(X,{variant:`outline`,size:`xs`,onClick:iN,children:`Sync now`}),t[48]=c,t[49]=n.state,t[50]=M):M=t[50];let N;t[51]!==c||t[52]!==r||t[53]!==n.state?(N=c&&n.state===`auth-error`&&(0,Z.jsx)(X,{variant:`outline`,size:`xs`,onClick:r,children:`Sign in`}),t[51]=c,t[52]=r,t[53]=n.state,t[54]=N):N=t[54];let P;t[55]!==c||t[56]!==n.state?(P=c&&n.state===`offline`&&(0,Z.jsx)(X,{variant:`outline`,size:`xs`,onClick:rN,children:`Retry`}),t[55]=c,t[56]=n.state,t[57]=P):P=t[57];let F;t[58]!==c||t[59]!==i||t[60]!==n.state?(F=c&&n.state===`conflict`&&i&&(0,Z.jsx)(X,{variant:`outline`,size:`xs`,onClick:i,children:`Review conflicts`}),t[58]=c,t[59]=i,t[60]=n.state,t[61]=F):F=t[61];let I;t[62]!==M||t[63]!==N||t[64]!==P||t[65]!==F?(I=(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1 pt-1`,children:[M,N,P,F]}),t[62]=M,t[63]=N,t[64]=P,t[65]=F,t[66]=I):I=t[66];let L;return t[67]!==S||t[68]!==C||t[69]!==w||t[70]!==A||t[71]!==j||t[72]!==I||t[73]!==b||t[74]!==x?(L=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[b,x,S,C,w,A,j,I]}),t[67]=S,t[68]=C,t[69]=w,t[70]=A,t[71]=j,t[72]=I,t[73]=b,t[74]=x,t[75]=L):L=t[75],L}function rN(){XM(`sync`)}function iN(){XM(`sync`)}function aN(e){let t=(0,$.c)(36),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a}=n,{status:o,fetchError:s}=_a();if(!o){if(s){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":`Sync status unavailable`,disabled:!0,children:(0,Z.jsx)(fs,{className:`size-3.5`})})}),t[2]=e):e=t[2];let n=s===`network`?`Sync status unavailable — server unreachable.`:`Sync status unavailable — server error.`,r;return t[3]===n?r=t[4]:(r=(0,Z.jsxs)(uo,{children:[e,(0,Z.jsx)(co,{children:n})]}),t[3]=n,t[4]=r),r}return null}if(o.state===`dormant`&&!o.hasRemote||o.state===`disabled`&&!o.pausedReason)return null;let c;t[5]===o?c=t[6]:(c=QM(o),t[5]=o,t[6]=c);let l=c,u=!!o.identityUnresolved,d;t[7]===o.state?d=t[8]:(d=$M(o.state),t[7]=o.state,t[8]=d);let f=`Sync status: ${d}${u?` — git identity unset`:``}`,p;t[9]===o?p=t[10]:(p=(0,Z.jsx)(ZM,{status:o}),t[9]=o,t[10]=p);let m;t[11]===l?m=t[12]:(m=l&&(0,Z.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 text-[9px] leading-none font-medium bg-background border rounded-full px-0.5`,children:l}),t[11]=l,t[12]=m);let h;t[13]!==l||t[14]!==u?(h=!l&&u&&(0,Z.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 size-1.5 rounded-full bg-amber-500 ring-2 ring-background`,"aria-hidden":!0}),t[13]=l,t[14]=u,t[15]=h):h=t[15];let g;t[16]!==f||t[17]!==p||t[18]!==m||t[19]!==h?(g=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(ie,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground relative`,"aria-label":f,children:[p,m,h]})})}),t[16]=f,t[17]=p,t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;t[21]===o?_=t[22]:(_=tN(o),t[21]=o,t[22]=_);let v;t[23]===_?v=t[24]:(v=(0,Z.jsx)(co,{children:_}),t[23]=_,t[24]=v);let y;t[25]!==v||t[26]!==g?(y=(0,Z.jsxs)(uo,{children:[g,v]}),t[25]=v,t[26]=g,t[27]=y):y=t[27];let b;t[28]!==i||t[29]!==a||t[30]!==r||t[31]!==o?(b=(0,Z.jsx)(ae,{align:`end`,className:`w-64 p-3`,children:(0,Z.jsx)(nN,{status:o,onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a})}),t[28]=i,t[29]=a,t[30]=r,t[31]=o,t[32]=b):b=t[32];let x;return t[33]!==y||t[34]!==b?(x=(0,Z.jsxs)(E,{children:[y,b]}),t[33]=y,t[34]=b,t[35]=x):x=t[35],x}var oN=[{value:`light`,label:`Light`,icon:fc},{value:`dark`,label:`Dark`,icon:Ws},{value:`system`,label:`System`,icon:vs}],sN=()=>{let e=(0,$.c)(16),{theme:t}=yr(),{merged:n,userBinding:r}=ba(),i=n?.appearance?.theme??t??`system`,a;e[0]===r?a=e[1]:(a=e=>{if(e!==`light`&&e!==`dark`&&e!==`system`||!r)return;let t=r.patch({appearance:{theme:e}});t.ok||Xa.error(wn(t.error))},e[0]=r,e[1]=a);let o=a,s=i===`system`?vs:i===`dark`?Ws:fc,c;e[2]===s?c=e[3]:(c=(0,Z.jsx)(s,{}),e[2]=s,e[3]=c);let l;e[4]===i?l=e[5]:(l=(0,Z.jsxs)(`span`,{className:`sr-only`,children:[`Toggle theme (current: `,i,`)`]}),e[4]=i,e[5]=l);let u;e[6]!==c||e[7]!==l?(u=(0,Z.jsx)(Si,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[c,l]})}),e[6]=c,e[7]=l,e[8]=u):u=e[8];let d;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=oN.map(cN),e[9]=d):d=e[9];let f;e[10]!==i||e[11]!==o?(f=(0,Z.jsx)(Aa,{align:`end`,children:(0,Z.jsx)(bi,{value:i,onValueChange:o,children:d})}),e[10]=i,e[11]=o,e[12]=f):f=e[12];let p;return e[13]!==u||e[14]!==f?(p=(0,Z.jsxs)(ji,{children:[u,f]}),e[13]=u,e[14]=f,e[15]=p):p=e[15],p};function cN(e){let{value:t,label:n,icon:r}=e;return(0,Z.jsxs)(Ii,{value:t,className:`capitalize`,children:[(0,Z.jsx)(r,{className:`text-muted-foreground`}),n]},t)}function lN(e){let t=(0,$.c)(38),{onSaveVersion:n,saving:r,onSignIn:i,onSetIdentity:a,onOpenConflictResolver:o}=e,{activeDocName:s}=We(),{state:c}=Tj(),l=qf(),u;t[0]!==s||t[1]!==l?(u=Sp({docName:s,workspace:l}),t[0]=s,t[1]=l,t[2]=u):u=t[2];let d=u,f=typeof window<`u`&&window.okDesktop!=null,p=f&&c===`collapsed`&&`pl-[78px]`,m;t[3]===p?m=t[4]:(m=Y(`flex h-12 shrink-0 items-center bg-muted/35 shadow-[inset_0_-1px_0_var(--border)]`,f&&`[-webkit-app-region:drag]`,p,f&&`motion-safe:transition-[padding] motion-safe:duration-200 motion-safe:ease-linear`),t[3]=p,t[4]=m);let h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(Aj,{className:Y(`-ml-1 shrink-0 text-muted-foreground`,f&&`[-webkit-app-region:no-drag]`)})}),t[5]=h):h=t[5];let g=c===`expanded`?`Hide Files`:`Show Files`,_;t[6]===g?_=t[7]:(_=(0,Z.jsxs)(uo,{children:[h,(0,Z.jsx)(co,{children:g})]}),t[6]=g,t[7]=_);let v,y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(Bi,{orientation:`vertical`,className:`mr-1 h-4 shrink-0 data-vertical:self-center`}),y=(0,Z.jsx)(BM,{}),t[8]=v,t[9]=y):(v=t[8],y=t[9]);let b;t[10]===_?b=t[11]:(b=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 px-3`,children:[_,v,y]}),t[10]=_,t[11]=b);let x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(x=Y(`flex shrink-0 items-center justify-end gap-2 px-3`,f&&`[&>*]:[-webkit-app-region:no-drag]`),t[12]=x):x=t[12];let S;t[13]!==s||t[14]!==n||t[15]!==r?(S=s&&(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":`Checkpoint version`,onClick:n,disabled:r,className:`text-muted-foreground`,children:(0,Z.jsx)(nc,{className:`size-3.5`})})}),(0,Z.jsx)(co,{children:r?`Saving`:`Checkpoint version`})]}),t[13]=s,t[14]=n,t[15]=r,t[16]=S):S=t[16];let C;t[17]!==s||t[18]!==d?(C=s&&(0,Z.jsx)(KM,{input:d}),t[17]=s,t[18]=d,t[19]=C):C=t[19];let w;t[20]!==o||t[21]!==a||t[22]!==i?(w=(0,Z.jsx)(aN,{onSignIn:i,onSetIdentity:a,onOpenConflictResolver:o}),t[20]=o,t[21]=a,t[22]=i,t[23]=w):w=t[23];let T,E,D,O,k,A;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(oM,{}),E=(0,Z.jsx)(Bi,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),D=(0,Z.jsx)(cu,{}),O=(0,Z.jsx)(qM,{}),k=(0,Z.jsx)(WM,{}),A=(0,Z.jsx)(sN,{}),t[24]=T,t[25]=E,t[26]=D,t[27]=O,t[28]=k,t[29]=A):(T=t[24],E=t[25],D=t[26],O=t[27],k=t[28],A=t[29]);let j;t[30]!==S||t[31]!==C||t[32]!==w?(j=(0,Z.jsxs)(`div`,{className:x,children:[S,C,w,T,E,D,O,k,A]}),t[30]=S,t[31]=C,t[32]=w,t[33]=j):j=t[33];let M;return t[34]!==j||t[35]!==m||t[36]!==b?(M=(0,Z.jsxs)(`header`,{className:m,children:[b,j]}),t[34]=j,t[35]=m,t[36]=b,t[37]=M):M=t[37],M}function uN(){let e=(0,$.c)(32),[t,n]=bm(),[r,i]=(0,Q.useState)(t),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(`auth`),[d,f]=(0,Q.useState)(G_[0].id),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),_=da(),{projectLocalConfig:v,projectLocalSynced:y}=ba(),{activeDocName:b}=We(),x=!h&&_?.hasRemote===!0&&y===!0&&v!==null&&v.autoSync?.enabled===null,S,C;e[0]===b?(S=e[1],C=e[2]):(S=()=>{let e=function(e){let t=e.detail;t&&b&&Lo(b,{kind:`raw-mdx`,detail:t}),i(`source`)};return window.addEventListener(fm,e),()=>window.removeEventListener(fm,e)},C=[b],e[0]=b,e[1]=S,e[2]=C),(0,Q.useEffect)(S,C);let w;e[3]===n?w=e[4]:(w=function(e){i(e),n(e)},e[3]=n,e[4]=w);let T=w,E;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(E=async function(){m(!0);try{let e=await fetch(`/api/save-version`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});e.ok?Xa.success(`Checkpoint saved`):(console.error(`[save-version] failed:`,await e.text()),Xa.error(`Checkpoint failed — try again`))}catch(e){console.error(`[save-version] failed:`,e),Xa.error(`Checkpoint failed — try again`)}m(!1)},e[5]=E):E=e[5];let D=E,O;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(Cm,{onOpenResolver:()=>o(!0)}),e[6]=O):O=e[6];let k,A,j;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>{u(`auth`),c(!0)},A=()=>{u(`identity`),c(!0)},j=()=>o(!0),e[7]=k,e[8]=A,e[9]=j):(k=e[7],A=e[8],j=e[9]);let M;e[10]===p?M=e[11]:(M=(0,Z.jsx)(lN,{onSaveVersion:D,saving:p,onSignIn:k,onSetIdentity:A,onOpenConflictResolver:j}),e[10]=p,e[11]=M);let N;e[12]!==d||e[13]!==r||e[14]!==T?(N=(0,Z.jsx)(ej,{editorMode:r,onModeChange:T,activeTab:d,onActiveTabChange:f}),e[12]=d,e[13]=r,e[14]=T,e[15]=N):N=e[15];let P;e[16]===a?P=e[17]:(P=(0,Z.jsx)(Tg,{open:a,onOpenChange:o}),e[16]=a,e[17]=P);let F=l===`identity`,I;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>{c(!1)},e[18]=I):I=e[18];let L;e[19]!==s||e[20]!==F?(L=(0,Z.jsx)(ou,{open:s,onOpenChange:c,identityPrompt:F,onSuccess:I}),e[19]=s,e[20]=F,e[21]=L):L=e[21];let R;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>g(!0),e[22]=R):R=e[22];let z;e[23]===x?z=e[24]:(z=(0,Z.jsx)(xm,{open:x,onResolved:R}),e[23]=x,e[24]=z);let B;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Z.jsx)(lm,{}),e[25]=B):B=e[25];let V;return e[26]!==P||e[27]!==L||e[28]!==z||e[29]!==M||e[30]!==N?(V=(0,Z.jsxs)(Z.Fragment,{children:[O,M,N,P,L,z,B]}),e[26]=P,e[27]=L,e[28]=z,e[29]=M,e[30]=N,e[31]=V):V=e[31],V}var dN=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
34
|
+
`)}}}}function IO(e){try{let t=f().parseToMdast(e),n=[];return FO(t,n),n.join(``).trim()}catch(t){return console.warn(`[document-stats] mdast parse failed, falling back to raw text`,t),e.trim()}}function LO(e){if(!e)return 0;let t=0;for(let n of e.split(/\s+/))jO.test(n)&&t++;return t}function RO(e){let t=globalThis.Intl.Segmenter;if(!t)return LO(e);let n=new t(void 0,{granularity:`word`}),r=0;for(let t of n.segment(e))t.isWordLike&&r++;return r}function zO(e){let t=AO.test(e)?1.5:4;return Math.ceil(e.length/t)}function BO(e){if(!e)return{words:0,chars:0,tokens:0};let{body:t}=Sn(e);if(!t.trim())return{words:0,chars:0,tokens:0};let n=IO(t);return n?{words:AO.test(n)?RO(n):LO(n),chars:n.length,tokens:zO(n)}:{words:0,chars:0,tokens:0}}var VO=300;function HO(e,t){let n=(0,$.c)(4),[r,i]=(0,Q.useState)(kO),a,o;return n[0]!==t||n[1]!==e?(a=()=>{if(!e||!t){i(kO);return}let n=e.document.getText(`source`),r=!1,a=null,o=function(){r||i(BO(n.toString()))};o();let s=function(){a&&clearTimeout(a),a=setTimeout(o,VO)};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 UO(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`?WO: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 WO(e){return e===`synced`?`synced`:`connected`}var GO=nr;function KO(e,t={}){let n=oe(e.componentName);return n.name===`*`?t.unregisteredSuffix?`${e.componentName} (unregistered)`:e.componentName:n.displayName??n.name}var qO=200,JO=`Outside any block`;function YO(e){let t=(0,$.c)(5),{editor:n}=e,r=ce(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?XO(n,r):o.current?JO:``,a.current=window.setTimeout(()=>{i.current&&(i.current.textContent=``,i.current.textContent=t),o.current=e,a.current=null},qO),()=>{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 XO(e,t){if(!t||t.ancestorChain.length===0)return``;let n=t.ancestorChain,r=n[n.length-1],i=KO(r,{unregisteredSuffix:!0});if(n.length===1)return`Selected: ${i}`;let a=n[n.length-2],o=KO(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 ZO(){let[e]=(0,Q.useState)(jr);return e}function QO({principal:e,identity:t}){return e&&e.source===`git-config`?{type:`human`,name:Yn(e.display_name),color:Sr(e.id,In),coeditor:t.coeditor,tabId:t.tabId,principalId:e.id}:e&&e.source===`synthesized`?{type:`human`,name:t.name,color:Sr(e.id,In),coeditor:t.coeditor,tabId:t.tabId}:{type:`human`,name:t.name,color:t.color,coeditor:t.coeditor,tabId:t.tabId}}function $O(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 ek=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&&Fr(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(Qt(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(xn(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(_n(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(rn(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(an(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(tn(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(rr(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(hn(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=Nr(this.view,e.from,e.to),r={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof nn){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 zn){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():$O(o.getBoundingClientRect(),s.getBoundingClientRect());r={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return r}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&ar(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()}},tk=e=>new bn({key:typeof e.pluginKey==`string`?new or(e.pluginKey):e.pluginKey,view:t=>new ek({view:t,...e})});Tr.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[tk({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 nk=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 Qn(e,{textSerializers:Xn(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(Qt(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(xn(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(_n(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(rn(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(an(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(tn(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(rr(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(hn(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=Nr(this.view,e.from,e.to);ar({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()}},rk=e=>new bn({key:typeof e.pluginKey==`string`?new or(e.pluginKey):e.pluginKey,view:t=>new nk({view:t,...e})});Tr.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?[rk({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 ik(e,t){return e??new or(t)}var ak=typeof window<`u`?Q.useLayoutEffect:Q.useEffect,ok=new Set([`left`,`opacity`,`position`,`top`,`visibility`,`width`]),sk=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(`.`)),ck=new Set([`children`,`className`,`style`]),lk=new Set([`tabIndex`]),uk=new Set([`accessKey`,`autoCapitalize`,`contentEditable`,`contextMenu`,`dir`,`draggable`,`enterKeyHint`,`hidden`,`id`,`lang`,`nonce`,`role`,`slot`,`spellCheck`,`tabIndex`,`title`,`translate`]),dk={Blur:`focusout`,DoubleClick:`dblclick`,Focus:`focusin`,MouseEnter:`mouseenter`,MouseLeave:`mouseleave`};function fk(e,t){return/^on[A-Z]/.test(e)&&typeof t==`function`}function pk(e){return e.startsWith(`aria-`)||e.startsWith(`data-`),e}function mk(e){return e.startsWith(`aria-`)||e.startsWith(`data-`)||uk.has(e)}function hk(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function gk(e){let t=e.endsWith(`Capture`),n=(t?e.slice(0,-7):e).slice(2);return{eventName:dk[n]??n.toLowerCase(),options:t?{capture:!0}:void 0}}function _k(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 vk(e){return lk.has(e)}function yk(e,t,n){if(t===`tabIndex`){e.tabIndex=Number(n);return}e[t]=n}function bk(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 xk(e,t){return typeof t!=`number`||t===0||e.startsWith(`--`)||sk.has(e)?String(t):`${t}px`}function Sk(e,t){ok.has(t)||e.style.removeProperty(hk(t))}function Ck(e,t,n){ok.has(t)||e.style.setProperty(hk(t),xk(t,n))}function wk(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(r=>{if(ck.has(r)||!mk(r)||fk(r,t[r])||fk(r,n[r]))return;let i=t[r],a=n[r];if(i===a)return;let o=pk(r);if(a==null||a===!1){vk(r)&&bk(e,r),e.removeAttribute(o);return}if(a===!0){vk(r)&&yk(e,r,!0),e.setAttribute(o,``);return}if(vk(r)){yk(e,r,a);return}e.setAttribute(o,String(a))})}function Tk(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute(`class`)}}function Ek(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){Sk(e,t);return}Ck(e,t,a)}})}function Dk(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(!fk(t,n))return;let{eventName:i,options:a}=gk(t),o=t=>{n(_k(e,t))};e.addEventListener(i,o,a),r.push({eventName:i,listener:o,options:a})}),r}function Ok(e,t){let n=(0,Q.useRef)({}),r=(0,Q.useRef)([]);ak(()=>{let i=n.current;return Tk(e,i.className,t.className),Ek(e,i.style,t.style),wk(e,i,t),r.current=Dk(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 kk=Q.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,getReferencedVirtualElement:o,options:s,children:l,...u},d)=>{let f=(0,Q.useRef)(document.createElement(`div`)),p=(0,Q.useRef)(ik(e,`bubbleMenu`)).current;Ok(f.current,u),typeof d==`function`?d(f.current):d&&(d.current=f.current);let{editor:m}=c(),h=t||m,g={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:p,shouldShow:a,getReferencedVirtualElement:o,options:s},_=(0,Q.useRef)(g);_.current=g;let[v,y]=(0,Q.useState)(!1),b=(0,Q.useRef)(!0);return(0,Q.useEffect)(()=>{if(h?.isDestroyed)return;if(!h){console.warn(`BubbleMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=f.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=tk({..._.current,editor:h,element:e});h.registerPlugin(t);let n=_.current.pluginKey;return b.current=!0,y(!0),()=>{y(!1),h.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[h]),(0,Q.useEffect)(()=>{if(!(!v||!h||h.isDestroyed)){if(b.current){b.current=!1;return}h.view.dispatch(h.state.tr.setMeta(p,{type:`updateOptions`,options:_.current}))}},[v,h,n,r,a,s,i,o,p]),(0,is.createPortal)(l,f.current)});Q.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,options:o,children:s,...l},u)=>{let d=(0,Q.useRef)(document.createElement(`div`)),f=(0,Q.useRef)(ik(e,`floatingMenu`)).current;Ok(d.current,l),typeof u==`function`?u(d.current):u&&(u.current=d.current);let{editor:p}=c(),m=t||p,h={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:f,shouldShow:a,options:o},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(`FloatingMenu 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=rk({...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,o,i,f]),(0,is.createPortal)(s,d.current)});var Ak=[{name:`paragraph`,label:`Text`,icon:Xs,isActive:e=>e.isActive(`paragraph`)&&!e.isActive(`list`),command:e=>e.chain().focus().setParagraph().run()},{name:`heading1`,label:`Heading 1`,icon:me,isActive:e=>e.isActive(`heading`,{level:1}),command:e=>e.chain().focus().toggleHeading({level:1}).run()},{name:`heading2`,label:`Heading 2`,icon:yt,isActive:e=>e.isActive(`heading`,{level:2}),command:e=>e.chain().focus().toggleHeading({level:2}).run()},{name:`heading3`,label:`Heading 3`,icon:dt,isActive:e=>e.isActive(`heading`,{level:3}),command:e=>e.chain().focus().toggleHeading({level:3}).run()},{name:`bulletList`,label:`Bullet List`,icon:He,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:De,isActive:e=>e.isActive(`list`,{ordered:!0}),command:e=>e.chain().focus().toggleOrderedList().run()},{name:`taskList`,label:`Task List`,icon:Ae,isActive:e=>e.isActive(`listItem`,{checked:!0})||e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleTaskList().run()},{name:`blockquote`,label:`Quote`,icon:ut,isActive:e=>e.isActive(`blockquote`),command:e=>e.chain().focus().toggleBlockquote().run()},{name:`codeBlock`,label:`Code Block`,icon:sc,isActive:e=>e.isActive(`codeBlock`),command:e=>e.chain().focus().toggleCodeBlock().run()}];function jk(e){let t=(0,$.c)(18),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:Mk},t[0]=n,t[1]=r);let{current:i,activeStates:a}=Se(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)(Ie,{className:`size-3 opacity-50`}),t[6]=l):l=t[6];let u;t[7]!==s||t[8]!==c?(u=(0,Z.jsx)(Si,{asChild:!0,children:(0,Z.jsxs)(X,{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=Ak.map(e=>{let t=e.icon,r=a[e.name];return(0,Z.jsxs)(di,{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)(Aa,{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)(ji,{children:[u,f]}),t[15]=u,t[16]=f,t[17]=p):p=t[17],p}function Mk(e){let t=Object.fromEntries(Ak.map(t=>[t.name,t.isActive(e.editor)]));return{current:Ak.find(e=>t[e.name])??Ak[0],activeStates:t}}function Nk(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 Pk(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:V(typeof n.src==`string`?n.src:``)}function Fk(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 Ik(e){let t=(0,$.c)(10),{editor:n}=e,r;if(t[0]===n?r=t[1]:(r={editor:n,selector:Lk},t[0]=n,t[1]=r),Se(r)===null)return null;let i;t[2]===n?i=t[3]:(i=e=>{e.preventDefault();let t=Nk(n);t&&Fk(t,Pk(n))},t[2]=n,t[3]=i);let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Oi,{className:`size-3.5`}),t[4]=a):a=t[4];let o;t[5]===i?o=t[6]:(o=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":`Download file`,className:`text-accent-foreground`,onMouseDown:i,children:a})}),t[5]=i,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(co,{side:`bottom`,sideOffset:8,children:`Download file`}),t[7]=s):s=t[7];let c;return t[8]===o?c=t[9]:(c=(0,Z.jsx)(`div`,{className:`flex items-center gap-0.5`,children:(0,Z.jsxs)(uo,{children:[o,s]})}),t[8]=o,t[9]=c),c}function Lk(e){return Nk(e.editor)}function Rk(e){return Nk(e)!==null}var zk=[{value:`left`,label:`Align left`,icon:Je},{value:`center`,label:`Align center`,icon:_e},{value:`right`,label:`Align right`,icon:it}];function Bk(e){let t=e.state.selection.node;if(!t||t.type.name!==`jsxComponent`)return null;let n=t.attrs.componentName;if(n!==`img`&&n!==`CommonMarkImage`&&n!==`Embed`)return null;let r=(t.attrs.props??{}).align;return r===`left`||r===`right`||r===`center`?r:`center`}function Vk(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:Hk},t[0]=n,t[1]=r);let i=Se(r);if(i===null)return null;let a;t[2]!==i||t[3]!==n?(a=zk.map(e=>{let{value:t,label:r,icon:a}=e,o=i===t;return(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{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(a!==`img`&&a!==`CommonMarkImage`&&a!==`Embed`||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(nn.create(u.doc,s)),Ee(n.view.nodeDOM(s),()=>{n.view.dispatch(u)})},children:(0,Z.jsx)(a,{className:`size-3.5`})})}),(0,Z.jsx)(co,{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 Hk(e){return Bk(e.editor)}function Uk(e){return Bk(e)!==null}var Wk=[{name:`bold`,icon:rs,command:e=>e.chain().focus().toggleBold().run(),isActive:e=>e.isActive(`strong`),shortcut:`⌘B`},{name:`italic`,icon:Ps,command:e=>e.chain().focus().toggleItalic().run(),isActive:e=>e.isActive(`emphasis`),shortcut:`⌘I`},{name:`underline`,icon:gc,command:e=>e.chain().focus().toggleUnderline().run(),isActive:e=>e.isActive(`underline`),shortcut:`⌘U`},{name:`strikethrough`,icon:dc,command:e=>e.chain().focus().toggleStrike().run(),isActive:e=>e.isActive(`strike`),shortcut:`⌘⇧X`},{name:`code`,icon:ms,command:e=>e.chain().focus().toggleCode().run(),isActive:e=>e.isActive(`code`),shortcut:`⌘E`},{name:`highlight`,icon:Ns,command:e=>e.chain().focus().toggleHighlight().run(),isActive:e=>e.isActive(`highlight`),shortcut:`⌘⇧H`}];function Gk(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:Kk},t[0]=n,t[1]=r);let i=Se(r),a;t[2]!==i||t[3]!==n?(a=Wk.map(e=>{let t=e.icon,r=i[e.name];return(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{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)(co,{side:`bottom`,sideOffset:8,children:[(0,Z.jsx)(`span`,{className:`capitalize`,children:e.name}),(0,Z.jsx)(`kbd`,{className:`ml-1.5 text-[10px] opacity-60`,children:e.shortcut})]})]},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 Kk(e){return Object.fromEntries(Wk.map(t=>[t.name,t.isActive(e.editor)]))}function qk(e){let t=(0,$.c)(46),{editor:n}=e,[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),s=(0,Q.useRef)(null),c;t[0]===n?c=t[1]:(c=n.isActive(`link`),t[0]=n,t[1]=c);let l=c,u;t[2]===n?u=t[3]:(u=n.getAttributes(`link`).href??``,t[2]=n,t[3]=u);let d=u,f,p;t[4]===n?(f=t[5],p=t[6]):(f=()=>{let e=function(){n.state.selection.empty&&i(!1)};return n.on(`selectionUpdate`,e),()=>{n.off(`selectionUpdate`,e)}},p=[n],t[4]=n,t[5]=f,t[6]=p),(0,Q.useEffect)(f,p);let m,h;t[7]!==d||t[8]!==r?(m=()=>{r&&(o(d),requestAnimationFrame(()=>s.current?.focus()))},h=[r,d],t[7]=d,t[8]=r,t[9]=m,t[10]=h):(m=t[9],h=t[10]),(0,Q.useEffect)(m,h);let g;t[11]!==n||t[12]!==l||t[13]!==a?(g=function(){a.trim()?n.chain().focus().setLink({href:a.trim()}).run():l&&n.chain().focus().unsetLink().run(),i(!1)},t[11]=n,t[12]=l,t[13]=a,t[14]=g):g=t[14];let _=g,v;t[15]===n?v=t[16]:(v=function(){n.chain().focus().unsetLink().run(),i(!1)},t[15]=n,t[16]=v);let y=v,b;t[17]!==_||t[18]!==n?(b=function(e){e.key===`Enter`&&(e.preventDefault(),_()),e.key===`Escape`&&(e.preventDefault(),i(!1),n.chain().focus().run())},t[17]=_,t[18]=n,t[19]=b):b=t[19];let x=b;if(r){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=e=>o(e.target.value),t[20]=e):e=t[20];let n;t[21]!==x||t[22]!==a?(n=(0,Z.jsx)(`input`,{ref:s,type:`url`,placeholder:`Paste link`,value:a,onChange:e,onKeyDown:x,"aria-label":`Link URL`,className:`h-5 w-44 bg-transparent text-sm border-none outline-none placeholder:text-muted-foreground`}),t[21]=x,t[22]=a,t[23]=n):n=t[23];let r;t[24]===_?r=t[25]:(r=()=>{_()},t[24]=_,t[25]=r);let i;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(ys,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[26]=i):i=t[26];let c;t[27]===r?c=t[28]:(c=(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":`Apply link`,onClick:r,children:i}),t[27]=r,t[28]=c);let u;t[29]!==n||t[30]!==c?(u=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border bg-background px-2 py-1`,children:[n,c]}),t[29]=n,t[30]=c,t[31]=u):u=t[31];let f;t[32]!==d||t[33]!==l||t[34]!==y?(f=l&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":`Open link in new tab`,onMouseDown:e=>{e.preventDefault(),ne(d)},children:(0,Z.jsx)(Ma,{className:`size-3.5`})})}),(0,Z.jsx)(co,{side:`bottom`,sideOffset:8,children:`Open link in new tab`})]}),(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":`Remove link`,onMouseDown:e=>{e.preventDefault(),y()},children:(0,Z.jsx)(fe,{className:`size-3.5`})})}),(0,Z.jsx)(co,{side:`bottom`,sideOffset:8,children:`Remove link`})]})]}),t[32]=d,t[33]=l,t[34]=y,t[35]=f):f=t[35];let p;return t[36]!==u||t[37]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[u,f]}),t[36]=u,t[37]=f,t[38]=p):p=t[38],p}let S=l?`bg-accent text-primary`:`text-accent-foreground`,C,w;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{e.preventDefault(),i(!0)},w=(0,Z.jsx)(zs,{className:`size-3.5`}),t[39]=C,t[40]=w):(C=t[39],w=t[40]);let T;t[41]===S?T=t[42]:(T=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":`Insert link`,className:S,onMouseDown:C,children:w})}),t[41]=S,t[42]=T);let E;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsxs)(co,{side:`bottom`,sideOffset:8,children:[`Link`,(0,Z.jsx)(`kbd`,{className:`ml-1.5 text-[10px] opacity-60`,children:`⌘K`})]}),t[43]=E):E=t[43];let D;return t[44]===T?D=t[45]:(D=(0,Z.jsxs)(uo,{children:[T,E]}),t[44]=T,t[45]=D),D}function Jk({editor:e}){if(e.isActive(`codeBlock`))return!1;if(Uk(e)||Rk(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 Yk(e){let t=(0,$.c)(22),{editor:n}=e,r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(0),o=(0,Q.useRef)(null),s;t[0]===n?s=t[1]:(s={editor:n,selector:eA},t[0]=n,t[1]=s);let c=Se(s),l;t[2]===n?l=t[3]:(l={editor:n,selector:$k},t[2]=n,t[3]=l);let u=Se(l),d;t[4]!==n.state||t[5]!==n.view?(d=()=>{try{let{from:e,to:t}=n.state.selection;return Nr(n.view,e,t)}catch{return new DOMRect}},t[4]=n.state,t[5]=n.view,t[6]=d):d=t[6];let f;if(t[7]!==n.view.dom||t[8]!==d){let e={getBoundingClientRect:d,contextElement:n.view.dom};f=()=>{let t=r.current;t&&(o.current?.(),o.current=yn(e,t,()=>{ar(e,t,{placement:`top`,strategy:`fixed`,middleware:[_n(8),Qt(),xn({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(Qk)}))},t[7]=n.view.dom,t[8]=d,t[9]=f}else f=t[9];let p=f,m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{o.current?.(),o.current=null,a(Zk)},t[10]=m):m=t[10];let h=m,g;t[11]===p?g=t[12]:(g={onShow:p,onHide:h,strategy:`fixed`},t[11]=p,t[12]=g);let _;t[13]!==n||t[14]!==u||t[15]!==c||t[16]!==i?(_=c?(0,Z.jsx)(Vk,{editor:n},`${i}-img-align`):u?(0,Z.jsx)(Ik,{editor:n},`${i}-file`):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(jk,{editor:n}),(0,Z.jsx)(Bi,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),(0,Z.jsx)(Gk,{editor:n},i),(0,Z.jsx)(Bi,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),(0,Z.jsx)(qk,{editor:n},`${i}-link`)]}),t[13]=n,t[14]=u,t[15]=c,t[16]=i,t[17]=_):_=t[17];let v;return t[18]!==n||t[19]!==g||t[20]!==_?(v=(0,Z.jsx)(kk,{ref:r,editor:n,appendTo:Xk,shouldShow:Jk,updateDelay:250,options:g,className:`z-50 flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:_}),t[18]=n,t[19]=g,t[20]=_,t[21]=v):v=t[21],v}function Xk(){return document.body}function Zk(e){return e+1}function Qk(){}function $k(e){return Rk(e.editor)}function eA(e){return Uk(e.editor)}var tA=[{name:`addRowBefore`,icon:P,label:`Add row above`,command:e=>e.chain().focus().addRowBefore().run()},{name:`addRowAfter`,icon:z,label:`Add row below`,command:e=>e.chain().focus().addRowAfter().run()},{name:`deleteRow`,icon:fe,label:`Delete row`,command:e=>e.chain().focus().deleteRow().run()}],nA=[{name:`addColumnBefore`,icon:ti,label:`Add column left`,command:e=>e.chain().focus().addColumnBefore().run()},{name:`addColumnAfter`,icon:oa,label:`Add column right`,command:e=>e.chain().focus().addColumnAfter().run()},{name:`deleteColumn`,icon:fe,label:`Delete column`,command:e=>e.chain().focus().deleteColumn().run()}],rA=[{name:`toggleHeaderRow`,icon:pc,label:`Toggle header row`,command:e=>e.chain().focus().toggleHeaderRow().run()},{name:`toggleHeaderColumn`,icon:gs,label:`Toggle header column`,command:e=>e.chain().focus().toggleHeaderColumn().run()},{name:`deleteTable`,icon:js,label:`Delete table`,command:e=>e.chain().focus().deleteTable().run()}];function iA({editor:e}){return e.isActive(`table`)}function aA(e){let t=(0,$.c)(14),{action:n,editor:r}=e,i=n.icon,a;t[0]!==n||t[1]!==r?(a=e=>{e.preventDefault(),n.command(r)},t[0]=n,t[1]=r,t[2]=a):a=t[2];let o;t[3]===i?o=t[4]:(o=(0,Z.jsx)(i,{className:`size-3.5`}),t[3]=i,t[4]=o);let s;t[5]!==n.label||t[6]!==a||t[7]!==o?(s=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":n.label,className:`text-muted-foreground`,onMouseDown:a,children:o})}),t[5]=n.label,t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;t[9]===n.label?c=t[10]:(c=(0,Z.jsx)(co,{side:`bottom`,sideOffset:8,children:n.label}),t[9]=n.label,t[10]=c);let l;return t[11]!==s||t[12]!==c?(l=(0,Z.jsxs)(uo,{children:[s,c]}),t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function oA(e){let t=(0,$.c)(13),{editor:n}=e,r;t[0]===n?r=t[1]:(r=tA.map(e=>(0,Z.jsx)(aA,{action:e,editor:n},e.name)),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(Bi,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[2]=i):i=t[2];let a;t[3]===n?a=t[4]:(a=nA.map(e=>(0,Z.jsx)(aA,{action:e,editor:n},e.name)),t[3]=n,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(Bi,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[5]=o):o=t[5];let s;t[6]===n?s=t[7]:(s=rA.map(e=>(0,Z.jsx)(aA,{action:e,editor:n},e.name)),t[6]=n,t[7]=s);let c;return t[8]!==n||t[9]!==r||t[10]!==a||t[11]!==s?(c=(0,Z.jsxs)(kk,{editor:n,shouldShow:iA,updateDelay:100,className:`flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:[r,i,a,o,s]}),t[8]=n,t[9]=r,t[10]=a,t[11]=s,t[12]=c):c=t[12],c}var sA=new WeakMap;function cA(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=Or(e.color),n.textContent=e.name,t.append(n),t}var lA={state:`idle`,count:0,lastFiredAt:null,position:`append`,lastAgentId:null};function uA(){let e=new Mr({extensions:Nn});return{mdManager:e,text:S({mdManager:e}),html:re({mdManager:e}),paste:$e({mdManager:e}),drop:D({mdManager:e})}}function dA(e){let{provider:t,placeholder:n,prebuiltMapping:r}=e;return[...Xe.map(e=>e.name===`link`||e.name===`wikiLink`?e.configure({docName:t.configuration.name??``}):e),GO.configure({placeholder:n??`Type '/' for commands`,showOnlyCurrent:!0}),C.configure({document:t.document,...r?{ySyncOptions:{mapping:r}}:{}}),Tr.create({name:`imageUploadDecoration`,addProseMirrorPlugins(){return[s]}}),Tr.create({name:`collaborationCursor`,addProseMirrorPlugins(){let e=t.awareness;if(!e)throw Error(`[TiptapEditor] HocuspocusProvider has no awareness instance — cursor plugin cannot initialize`);return[k(e,{cursorBuilder:cA})]}})]}function fA(e){let{provider:t,clipboard:n,ctorStart:r}=e;return{onBeforeCreate:({editor:e})=>{sA.set(e,r)},onCreate:({editor:e})=>{n.html.setView(e.view);let r=sA.get(e);if(sA.delete(e),r==null)return;let i=performance.now();Ge(`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:(e,t)=>n.drop(e,t)},extensions:ld(dA(e))}}function pA(e){let{provider:t,placeholder:n,clipboard:r,ctorStart:i}=e,a=ur(dA({provider:t,placeholder:n,clipboard:r,ctorStart:i})),{doc:o,mapping:s}=T(t.document.getXmlFragment(`default`),a);return{...fA({provider:t,placeholder:n,clipboard:r,ctorStart:i,prebuiltMapping:s}),content:o.toJSON(),element:null}}var mA=e=>{let t=(0,$.c)(21),{provider:n,placeholder:r,isSourceMode:i,portalTarget:a}=e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(lA),c=ZO(),{principal:l,activeDocName:u}=We(),d=n.configuration.name??``,[f]=(0,Q.useState)(uA),p;t[0]!==f||t[1]!==r||t[2]!==n?(p=()=>()=>({editor:new hr(pA({provider:n,placeholder:r,clipboard:f,ctorStart:performance.now()})),ydoc:n.document,ytext:n.document.getText(`source`),provider:n}),t[0]=f,t[1]=r,t[2]=n,t[3]=p):p=t[3];let[m]=(0,Q.useState)(p),h,g;if(t[4]!==m||t[5]!==d||t[6]!==n.document){let e={viewCount:0,bytes:n.document.getText(`source`).length},r=bt(d)??crypto.randomUUID();h=Q.use,g=Oe({docName:d,mountId:r,construct:m,sizeStats:e}),t[4]=m,t[5]=d,t[6]=n.document,t[7]=h,t[8]=g}else h=t[7],g=t[8];let _=h(g),v=_.editor,y,b;t[9]===_?(y=t[10],b=t[11]):(y=()=>()=>{xe(_)},b=[_],t[9]=_,t[10]=y,t[11]=b),(0,Q.useEffect)(y,b);let x;return t[12]!==u||t[13]!==d||t[14]!==v||t[15]!==c||t[16]!==i||t[17]!==a||t[18]!==l||t[19]!==n?(x=(0,Z.jsx)(hA,{provider:n,isSourceMode:i,docName:d,activeDocName:u,identity:c,principal:l,editor:v,wrapperRef:o,flashStateRef:s,portalTarget:a}),t[12]=u,t[13]=d,t[14]=v,t[15]=c,t[16]=i,t[17]=a,t[18]=l,t[19]=n,t[20]=x):x=t[20],x},hA=e=>{let t=(0,$.c)(71),{provider:n,isSourceMode:r,docName:i,activeDocName:a,identity:o,principal:s,editor:c,wrapperRef:l,flashStateRef:u,portalTarget:d}=e,f=(0,Q.useRef)(null),p,m;t[0]===d?(p=t[1],m=t[2]):(p=()=>{let e=f.current;if(e)return e.appendChild(d),()=>{d.parentNode===e&&e.removeChild(d)}},m=[d],t[0]=d,t[1]=p,t[2]=m),(0,Q.useLayoutEffect)(p,m);let h;t[3]!==c||t[4]!==n.configuration.name?(h=()=>(ct(c,n.configuration.name??null),()=>{ct(c,null)}),t[3]=c,t[4]=n.configuration.name,t[5]=h):h=t[5];let g;t[6]!==c||t[7]!==n?(g=[c,n],t[6]=c,t[7]=n,t[8]=g):g=t[8],(0,Q.useEffect)(h,g);let _;t[9]!==c||t[10]!==n.configuration.name?(_=()=>{},t[9]=c,t[10]=n.configuration.name,t[11]=_):_=t[11];let v;t[12]!==c||t[13]!==n?(v=[c,n],t[12]=c,t[13]=n,t[14]=v):v=t[14],(0,Q.useEffect)(_,v);let y;t[15]!==c||t[16]!==n.configuration.name?(y=()=>{},t[15]=c,t[16]=n.configuration.name,t[17]=y):y=t[17];let b;t[18]!==c||t[19]!==n?(b=[c,n],t[18]=c,t[19]=n,t[20]=b):b=t[20],(0,Q.useEffect)(y,b);let x,S;t[21]===c?(x=t[22],S=t[23]):(S=()=>{let e=gA,t=null,n=()=>{if(t||c.isDestroyed)return;let n=pt(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 pt(c)?n():c.on(`create`,n),()=>{c.off(`create`,n),r()}},x=[c],t[21]=c,t[22]=x,t[23]=S),(0,Q.useEffect)(S,x);let C,T;t[24]!==u||t[25]!==n.document||t[26]!==l?(C=()=>{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)},dr)};c(lA);let f=()=>{if(Wn(e),!Vn(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`?Vn(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)}},T=[n.document,u,l],t[24]=u,t[25]=n.document,t[26]=l,t[27]=C,t[28]=T):(C=t[27],T=t[28]),(0,Q.useEffect)(C,T);let E,D;t[29]===n?(E=t[30],D=t[31]):(E=()=>{let e=window.location.hash,t=e.indexOf(`?`),r=t>=0?new URLSearchParams(e.slice(t+1)).get(`anchor`):null;if(!r)return;let i=r,a=0,o,s=!1;function c(){if(s)return;let e=document.getElementById(i);e?(e.scrollIntoView({behavior:`smooth`,block:`start`}),s=!0,n.off(`synced`,c)):a<20&&(a+=1,o=window.setTimeout(c,100))}return c(),n.on(`synced`,c),()=>{o!==void 0&&clearTimeout(o),n.off(`synced`,c)}},D=[n],t[29]=n,t[30]=E,t[31]=D),(0,Q.useEffect)(E,D);let k,A;t[32]===c?(k=t[33],A=t[34]):(k=()=>{let e=function(e){let t=e.detail;if(!t||t.mode!==`wysiwyg`||c.isDestroyed)return;let n=pt(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(zo,e),()=>window.removeEventListener(zo,e)},A=[c],t[32]=c,t[33]=k,t[34]=A),(0,Q.useEffect)(k,A);let j;t[35]!==a||t[36]!==i||t[37]!==o||t[38]!==r||t[39]!==s||t[40]!==n.awareness?(j=()=>{let e=n.awareness;if(e){if(i!==a){e.setLocalState(null);return}e.setLocalState({user:QO({principal:s,identity:o}),mode:r?`source`:`wysiwyg`})}},t[35]=a,t[36]=i,t[37]=o,t[38]=r,t[39]=s,t[40]=n.awareness,t[41]=j):j=t[41];let M;t[42]!==a||t[43]!==i||t[44]!==o||t[45]!==r||t[46]!==s||t[47]!==n?(M=[n,i,a,o,s,r],t[42]=a,t[43]=i,t[44]=o,t[45]=r,t[46]=s,t[47]=n,t[48]=M):M=t[48],(0,Q.useEffect)(j,M);let N,P;t[49]===c?(N=t[50],P=t[51]):(N=(0,Z.jsx)(Yk,{editor:c}),P=(0,Z.jsx)(oA,{editor:c}),t[49]=c,t[50]=N,t[51]=P);let F;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(`div`,{ref:f,style:{display:`contents`}}),t[52]=F):F=t[52];let I;t[53]===c?I=t[54]:(I=(0,Z.jsx)(se,{editor:c,className:`tiptap-editor-portal-content h-full`}),t[53]=c,t[54]=I);let L;t[55]!==d||t[56]!==I?(L=(0,is.createPortal)(I,d),t[55]=d,t[56]=I,t[57]=L):L=t[57];let R;t[58]===c?R=t[59]:(R=(0,Z.jsx)(YO,{editor:c}),t[58]=c,t[59]=R);let z;t[60]===c?z=t[61]:(z=w(c),t[60]=c,t[61]=z);let B;t[62]===z.store?B=t[63]:(B=(0,Z.jsx)(O,{store:z.store}),t[62]=z.store,t[63]=B);let V;return t[64]!==N||t[65]!==P||t[66]!==L||t[67]!==R||t[68]!==B||t[69]!==l?(V=(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:[N,P,F,L,R,B]}),t[64]=N,t[65]=P,t[66]=L,t[67]=R,t[68]=B,t[69]=l,t[70]=V):V=t[70],V};function gA(){return q()}function _A(e){let t=(0,$.c)(2),{docName:n,provider:r,children:i}=e;(0,Q.use)(lt(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 vA=`__back-nav__`;function yA(e){return e instanceof ge||e instanceof qe||e instanceof de||e instanceof Me||e instanceof rt||e instanceof Qe?e.docName:null}function bA(e){return e instanceof ge?{title:`Couldn't load document`,summary:`"${e.docName}" took too long. Check your connection.`}:e instanceof qe?{title:`Connection dropped`,summary:`Lost connection to "${e.docName}".`}:e instanceof de?{title:`Document not found`,summary:`"${e.docName}" doesn't exist.`}:e instanceof Me?{title:`Couldn't open document`,summary:`Something went wrong opening "${e.docName}".`}:e instanceof rt?{title:`Server can't open documents`,summary:`This project's running server doesn't support live editing. Restart Open Knowledge to fix.`}:e instanceof Qe?{title:`Cancelled`,summary:`You cancelled loading "${e.docName}".`}:{title:`Unknown error`,summary:e instanceof Error&&e.message?e.message:`An unexpected error occurred.`}}function xA(e){let t=(0,$.c)(27),{error:n,resetErrorBoundary:r,activeDocName:i,previousDocName:a,onNavigateBack:o}=e,s;t[0]===n?s=t[1]:(s=bA(n),t[0]=n,t[1]=s);let{title:c,summary:l}=s,u=!!a&&!!o,d=(0,Q.useRef)(null),f,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{d.current?.focus()},p=[],t[2]=f,t[3]=p):(f=t[2],p=t[3]),(0,Q.useEffect)(f,p);let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(jb,{size:80,variant:`sleeping`}),t[4]=m):m=t[4];let h;t[5]===c?h=t[6]:(h=(0,Z.jsx)(`h2`,{id:`document-error-title`,className:`text-2xl font-light tracking-tighter text-balance`,children:c}),t[5]=c,t[6]=h);let g;t[7]===l?g=t[8]:(g=(0,Z.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:l}),t[7]=l,t[8]=g);let _;t[9]!==h||t[10]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[h,g]}),t[9]=h,t[10]=g,t[11]=_):_=t[11];let v;t[12]===r?v=t[13]:(v=(0,Z.jsx)(X,{ref:d,variant:`default`,onClick:r,children:`Try again`}),t[12]=r,t[13]=v);let y;t[14]!==i||t[15]!==u||t[16]!==n||t[17]!==o||t[18]!==a||t[19]!==r?(y=u?(0,Z.jsx)(X,{variant:`ghost`,className:`font-mono uppercase`,onClick:()=>{!a||!o||(ze(yA(n)??i),o(a),r(vA))},children:`Go back`}):null,t[14]=i,t[15]=u,t[16]=n,t[17]=o,t[18]=a,t[19]=r,t[20]=y):y=t[20];let b;t[21]!==v||t[22]!==y?(b=(0,Z.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[v,y]}),t[21]=v,t[22]=y,t[23]=b):b=t[23];let x;return t[24]!==b||t[25]!==_?(x=(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:[m,_,b]}),t[24]=b,t[25]=_,t[26]=x):x=t[26],x}function SA(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)(xA,{...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]===vA){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}: ${bA(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)(b,{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}var CA={text:``,number:0,boolean:!1,date:``,list:[]};function wA(e){let t=e.document.getText(`source`).toString(),{map:n,parseError:r}=vr(t);return{map:n,keys:pn(t),parseError:r}}function TA(e){let t=(0,$.c)(169),{provider:n}=e,[r,i]=(0,Q.useState)(null),a;t[0]===n?a=t[1]:(a=()=>wA(n),t[0]=n,t[1]=a);let[o,s]=(0,Q.useState)(a),c,u;t[2]===n?(c=t[3],u=t[4]):(c=()=>{let e=br(n);i(e),s(e.current());let t=e.subscribe(e=>{s(e)});return()=>{t(),e.dispose(),i(t=>t===e?null:t)}},u=[n],t[2]=n,t[3]=c,t[4]=u),(0,Q.useEffect)(c,u);let d=o.map,f=o.keys,p=o.parseError,[m,h]=(0,Q.useState)(!1),g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g={},t[5]=g):g=t[5];let[_,v]=(0,Q.useState)(g),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(null),C;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(C={},t[6]=C):C=t[6];let[w,T]=(0,Q.useState)(C),E;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(E={},t[7]=E):E=t[7];let[D,O]=(0,Q.useState)(E),k=n.configuration.name??``,j;t[8]===k?j=t[9]:(j=DA(k),t[8]=k,t[9]=j);let M=ra(j),P;t[10]!==M.state.data||t[11]!==M.state.status?(P=M.state.status===`ready`?M.state.data.folder.frontmatter_defaults??{}:{},t[10]=M.state.data,t[11]=M.state.status,t[12]=P):P=t[12];let F=P,I;t[13]!==M.state.data||t[14]!==M.state.status?(I=M.state.status===`ready`?M.state.data.frontmatterSources:{},t[13]=M.state.data,t[14]=M.state.status,t[15]=I):I=t[15];let L=I,z;t[16]===r?z=t[17]:(z=function(e){if(!r)return{ok:!1,error:`Connecting`};let t=r.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=lr(t.error);return{ok:!1,error:t.error.issues[0]?.message??`Invalid patch payload`,fieldErrors:Object.keys(n).length>0?n:void 0}},t[16]=r,t[17]=z);let B=z,V;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(V=function(e){T(t=>{if(!Object.hasOwn(t,e))return t;let n={...t};return delete n[e],n})},t[18]=V):V=t[18];let H=V,U;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(U=function(e,t){if(e.ok)return;let n=e.error??`Failed to update property`,r=e.fieldErrors??{};T(e=>{let i={...e};for(let e of t)i[e]=r[e]??n;return i}),O(e=>{let n={...e};for(let e of t)n[e]=(n[e]??0)+1;return n})},t[19]=U):U=t[19];let W=U,G;t[20]===B?G=t[21]:(G=function(e,t){H(e),W(B({[e]:t}),[e])},t[20]=B,t[21]=G);let K=G,q;t[22]===B?q=t[23]:(q=function(e){H(e),W(B({[e]:null}),[e])},t[22]=B,t[23]=q);let ee=q,te;t[24]===r?te=t[25]:(te=function(e,t){if(!r)return{ok:!1,error:`Connecting`};if(e===t)return{ok:!0};let n=r.rename(e,t);if(n.ok)return{ok:!0};if(n.error.code===`WRITE_ERROR`)return{ok:!1,error:n.error.detail};let i=lr(n.error);return{ok:!1,error:n.error.issues[0]?.message??`Failed to rename`,fieldErrors:Object.keys(i).length>0?i:void 0}},t[24]=r,t[25]=te);let ne=te,re;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(re=function(e,t){return`${e} ${t}`},t[26]=re):re=t[26];let ie=re,ae;t[27]!==r||t[28]!==f?(ae=function(e){if(!r)return;let t=String(e.active.id),n=e.over?String(e.over.id):null;if(!n||t===n)return;let i=f.map((e,t)=>ie(e,t)),a=i.indexOf(t),o=i.indexOf(n);if(a<0||o<0)return;let s=f.slice(),[c]=s.splice(a,1);if(!c)return;s.splice(o,0,c);let l=r.reorder(s);l.ok||console.warn(`[PropertyPanel] reorder failed:`,l.error)},t[27]=r,t[28]=f,t[29]=ae):ae=t[29];let oe=ae,se;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(se={activationConstraint:{distance:4}},t[30]=se):se=t[30];let ce;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(ce={coordinateGetter:fi},t[31]=ce):ce=t[31];let le=ia(ui(Di,se),ui(mi,ce)),ue;t[32]!==F||t[33]!==K||t[34]!==d?(ue=function(e,t){let n=d[e]??OA(F[e]);if(n===void 0)return;v(n=>({...n,[e]:t}));let r=MD(n,t);(!Object.hasOwn(d,e)||!EA(n,r))&&K(e,r)},t[32]=F,t[33]=K,t[34]=d,t[35]=ue):ue=t[35];let de=ue,fe;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(fe=function(){b({name:``,type:`text`,value:``,error:null}),h(!1)},t[36]=fe):fe=t[36];let pe=fe,{addPropertySignal:me,clearAddProperty:he}=bO(),ge;t[37]!==me||t[38]!==k?(ge=me.get(k)??0,t[37]=me,t[38]=k,t[39]=ge):ge=t[39];let _e=ge,ve,ye;t[40]===_e?(ve=t[41],ye=t[42]):(ve=()=>{_e>0&&(b({name:``,type:`text`,value:``,error:null}),h(!1))},ye=[_e],t[40]=_e,t[41]=ve,t[42]=ye),(0,Q.useEffect)(ve,ye);let be,xe;t[43]!==he||t[44]!==k?(be=()=>()=>he(k),xe=[k,he],t[43]=he,t[44]=k,t[45]=be,t[46]=xe):(be=t[45],xe=t[46]),(0,Q.useEffect)(be,xe);let Se;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(Se=function(e){b(t=>{if(!t)return t;let n=e===`date`?new Date().toISOString().slice(0,10):CA[e];return{...t,type:e,value:n,error:null}})},t[47]=Se):Se=t[47];let Ce=Se,we;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(we=function(e){b(t=>t&&{...t,value:e})},t[48]=we):we=t[48];let J=we,Te;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(Te=function(e){b(t=>t&&{...t,name:e,error:null})},t[49]=Te):Te=t[49];let Ee=Te,De;t[50]!==y||t[51]!==B||t[52]!==d?(De=function(){if(!y)return;let e=y.name.trim();if(!e){b({...y,error:`Name is required`});return}if(e===`frontmatter`){b({...y,error:`"frontmatter" is a reserved property name`});return}if(Object.hasOwn(d,e)){b({...y,error:`Property "${e}" already exists`});return}let t=B({[e]:y.value});if(t.ok){b(null);return}let n=t.fieldErrors?.[e],r=t.error??`Failed to add property`;b({...y,error:n??r})},t[50]=y,t[51]=B,t[52]=d,t[53]=De):De=t[53];let Oe=De,ke;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ke=function(){b(null)},t[54]=ke):ke=t[54];let Ae=ke,je;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(je=function(e){S({key:e,draft:e,error:null})},t[55]=je):je=t[55];let Me=je,Ne;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=function(e){S(t=>t&&{...t,draft:e,error:null})},t[56]=Ne):Ne=t[56];let Pe=Ne,Fe;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=function(){S(null)},t[57]=Fe):Fe=t[57];let Ie=Fe,Le;t[58]!==d||t[59]!==ne||t[60]!==x?(Le=function(){if(!x)return;let e=x.draft.trim();if(!e){S(null);return}if(e===x.key){S(null);return}if(e===`frontmatter`){S({...x,error:`"frontmatter" is a reserved property name`});return}if(Object.hasOwn(d,e)){S({...x,error:`Property "${e}" already exists`});return}let t=ne(x.key,e);if(t.ok){v(t=>{if(!Object.hasOwn(t,x.key))return t;let n={...t};return n[e]=n[x.key],delete n[x.key],n}),H(x.key),S(null);return}let n=t.fieldErrors?.[e]??t.fieldErrors?.[x.key]??t.error??`Failed to rename property`;S({...x,error:n})},t[58]=d,t[59]=ne,t[60]=x,t[61]=Le):Le=t[61];let Re=Le,ze;t[62]!==d||t[63]!==f?(ze=f.length>0?f:Object.keys(d),t[62]=d,t[63]=f,t[64]=ze):ze=t[64];let Be=ze,Ve;if(t[65]!==Be){Ve=new Map;for(let e of Be)Ve.set(e,(Ve.get(e)??0)+1);t[65]=Be,t[66]=Ve}else Ve=t[66];let He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe,$e;if(t[67]!==y||t[68]!==F||t[69]!==L||t[70]!==m||t[71]!==K||t[72]!==Re||t[73]!==Ve||t[74]!==w||t[75]!==oe||t[76]!==d||t[77]!==_||t[78]!==p||t[79]!==ee||t[80]!==x||t[81]!==Be||t[82]!==D||t[83]!==le||t[84]!==de){$e=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Object.keys(F).filter(e=>!Object.hasOwn(d,e)).sort();if(Be.length===0&&e.length===0&&!y&&!p){$e=null;break bb0}Ze=`property-panel editor-content-aligned pt-4 pb-4 text-sm`,Qe=`property-panel`,Ue=A,Je=!m,t[97]===Symbol.for(`react.memo_cache_sentinel`)?(Ye=e=>h(!e),t[97]=Ye):Ye=t[97];let n=!m,r;t[98]===n?r=t[99]:(r=(0,Z.jsx)(l,{"data-expanded":n,className:`size-3.5 shrink-0 text-muted-foreground transition-transform duration-150 ease-out data-[expanded=true]:rotate-90`}),t[98]=n,t[99]=r);let i;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`span`,{children:`Properties`}),t[100]=i):i=t[100],t[101]===r?Xe=t[102]:(Xe=(0,Z.jsx)(R,{asChild:!0,children:(0,Z.jsxs)(X,{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:[r,i]})}),t[101]=r,t[102]=Xe),He=N,We=`overflow-hidden data-[state=open]:animate-[collapsible-down_150ms_ease-out] data-[state=closed]:animate-[collapsible-up_150ms_ease-in]`,t[103]===p?Ge=t[104]:(Ge=p?(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)(Dn,{className:`size-3.5 shrink-0 mt-0.5`}),(0,Z.jsxs)(`div`,{children:[`Frontmatter YAML is malformed; fix in source mode to recover.`,(0,Z.jsx)(`span`,{className:`block text-[10px] opacity-80`,children:p})]})]}):null,t[103]=p,t[104]=Ge);let a;if(t[105]!==Be){let e;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(e=(e,t)=>ie(e,t),t[107]=e):e=t[107],a=Be.map(e),t[105]=Be,t[106]=a}else a=t[106];let o;if(t[108]!==F||t[109]!==L||t[110]!==K||t[111]!==Re||t[112]!==Ve||t[113]!==w||t[114]!==d||t[115]!==_||t[116]!==ee||t[117]!==x||t[118]!==Be||t[119]!==D||t[120]!==de){let e;t[122]!==F||t[123]!==L||t[124]!==K||t[125]!==Re||t[126]!==Ve||t[127]!==w||t[128]!==d||t[129]!==_||t[130]!==ee||t[131]!==x||t[132]!==D||t[133]!==de?(e=(e,t)=>{let n=d[e];if(n===void 0)return null;let r=_[e]??on(n),i=x?.key===e?x:null,a=(Ve.get(e)??0)>1,o=Object.hasOwn(F,e)?(0,Z.jsx)(kA,{source:L[e]??``}):void 0;return(0,Z.jsx)(PD,{sortableId:ie(e,t),keyName:e,value:n,declared:r,error:w[e]??null,resetCounter:D[e]??0,isDuplicate:a,badge:o,rename:{state:i,onBegin:()=>Me(e),onChangeDraft:Pe,onCommit:Re,onCancel:Ie},onCommit:t=>K(e,t),onChangeType:t=>de(e,t),onRemove:()=>ee(e)},`${e}-${t}`)},t[122]=F,t[123]=L,t[124]=K,t[125]=Re,t[126]=Ve,t[127]=w,t[128]=d,t[129]=_,t[130]=ee,t[131]=x,t[132]=D,t[133]=de,t[134]=e):e=t[134],o=Be.map(e),t[108]=F,t[109]=L,t[110]=K,t[111]=Re,t[112]=Ve,t[113]=w,t[114]=d,t[115]=_,t[116]=ee,t[117]=x,t[118]=Be,t[119]=D,t[120]=de,t[121]=o}else o=t[121];let s;t[135]!==a||t[136]!==o?(s=(0,Z.jsx)(Mi,{items:a,strategy:Pi,children:o}),t[135]=a,t[136]=o,t[137]=s):s=t[137],t[138]!==oe||t[139]!==le||t[140]!==s?(Ke=(0,Z.jsx)(gi,{sensors:le,collisionDetection:aa,onDragEnd:oe,children:s}),t[138]=oe,t[139]=le,t[140]=s,t[141]=Ke):Ke=t[141];let c;t[142]!==F||t[143]!==L||t[144]!==K||t[145]!==w||t[146]!==D||t[147]!==de?(c=e=>{let t=F[e],n=OA(t),r=on(n),i=L[e]??``;return(0,Z.jsx)(PD,{keyName:e,value:n,declared:r,error:w[e]??null,resetCounter:D[e]??0,isInherited:!0,badge:(0,Z.jsx)(VD,{source:i}),onCommit:t=>K(e,t),onChangeType:t=>de(e,t)},`inherited-${e}`)},t[142]=F,t[143]=L,t[144]=K,t[145]=w,t[146]=D,t[147]=de,t[148]=c):c=t[148],qe=e.map(c)}t[67]=y,t[68]=F,t[69]=L,t[70]=m,t[71]=K,t[72]=Re,t[73]=Ve,t[74]=w,t[75]=oe,t[76]=d,t[77]=_,t[78]=p,t[79]=ee,t[80]=x,t[81]=Be,t[82]=D,t[83]=le,t[84]=de,t[85]=He,t[86]=Ue,t[87]=We,t[88]=Ge,t[89]=Ke,t[90]=qe,t[91]=Je,t[92]=Ye,t[93]=Xe,t[94]=Ze,t[95]=Qe,t[96]=$e}else He=t[85],Ue=t[86],We=t[87],Ge=t[88],Ke=t[89],qe=t[90],Je=t[91],Ye=t[92],Xe=t[93],Ze=t[94],Qe=t[95],$e=t[96];if($e!==Symbol.for(`react.early_return_sentinel`))return $e;let et;t[149]!==y||t[150]!==Oe?(et=y?(0,Z.jsx)(zD,{draft:y,onChangeName:Ee,onChangeType:Ce,onChangeValue:J,onCommit:Oe,onCancel:Ae}):(0,Z.jsxs)(X,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`add-property-trigger`,onClick:pe,className:`mt-1 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)(Fi,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:`Add property`})]}),t[149]=y,t[150]=Oe,t[151]=et):et=t[151];let tt;t[152]!==He||t[153]!==We||t[154]!==Ge||t[155]!==Ke||t[156]!==qe||t[157]!==et?(tt=(0,Z.jsxs)(He,{className:We,children:[Ge,Ke,qe,et]}),t[152]=He,t[153]=We,t[154]=Ge,t[155]=Ke,t[156]=qe,t[157]=et,t[158]=tt):tt=t[158];let nt;t[159]!==Ue||t[160]!==Je||t[161]!==Ye||t[162]!==Xe||t[163]!==tt?(nt=(0,Z.jsxs)(Ue,{open:Je,onOpenChange:Ye,children:[Xe,tt]}),t[159]=Ue,t[160]=Je,t[161]=Ye,t[162]=Xe,t[163]=tt,t[164]=nt):nt=t[164];let rt;return t[165]!==Ze||t[166]!==Qe||t[167]!==nt?(rt=(0,Z.jsx)(`div`,{className:Ze,"data-testid":Qe,children:nt}),t[165]=Ze,t[166]=Qe,t[167]=nt,t[168]=rt):rt=t[168],rt}function EA(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length?e.every((e,n)=>e===t[n]):!1:e===t}function DA(e){if(!e)return``;let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function OA(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`?e:Array.isArray(e)?e.map(e=>typeof e==`string`?e:JSON.stringify(e)):e==null?``:JSON.stringify(e)}function kA(e){let t=(0,$.c)(2),{source:n}=e,r=`Overrides default from ${n===``?`.ok/frontmatter.yml`:`${n}/.ok/frontmatter.yml`}. Remove to revert.`,i;return t[0]===r?i=t[1]:(i=(0,Z.jsx)(Ne,{variant:`primary`,"data-testid":`property-override-badge`,title:r,className:`text-2xs`,children:`overrides`}),t[0]=r,t[1]=i),i}var AA=tt(`LARGE_DOC_CHAR_THRESHOLD`,5e5);function jA(e){let t=e.threshold??AA;return e.ytextLength>t?{renderSource:e.isSourceMode||e.visitedSource,renderVisual:!e.isSourceMode||e.visitedVisual,isLarge:!0}:{renderSource:!0,renderVisual:!0,isLarge:!1}}function MA(e){return e.hasEmittedFirstToggle||!e.isLarge?!1:e.renderSource&&e.renderVisual}var NA=tt(`ACTIVITY_MOUNT_LIMIT`,3);function PA(){return r(()=>import(`./SourceEditor-CSsFAy0n.js`),__vite__mapDeps([43,1,35,2,36,37,21,38,39,40,41,20,3,6,7,15,4,8,14,9,44,24]),import.meta.url)}var FA=(0,Q.lazy)(async()=>({default:(await PA()).SourceEditor}));function IA(e,t,n){if(n<=0)return[];let r=e.filter(e=>!we(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 LA(e,t){return t.kind===`idle`?null:t.kind===`failed`&&t.failedDocNames.includes(e)?{kind:`failed`,title:`Couldn't reconnect after server restart`,summary:t.reason===`clear-data-timeout`?`Local collaboration data for "${e}" could not be cleared in time. Reload to retry.`:`Local collaboration data for "${e}" could not be cleared. Reload to retry.`,actionLabel:`Reload`}:t.kind===`recovering`&&t.docNames.includes(e)?{kind:`recovering`,title:`Reconnecting after server restart`,summary:t.phase===`clearing-local-cache`?`Clearing local collaboration data for "${e}" before reconnecting.`:`Reopening "${e}" with a fresh local collaboration cache.`}:null}function RA(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(st,{name:`activity-pool`,children:(0,Z.jsx)(zA,{...e})}),t[0]=e,t[1]=n),n}function zA(e){let t=(0,$.c)(15),{activeDocName:n,isSourceMode:r,editorPlaceholder:i,previousDocName:a,onNavigateBack:o,onRecycle:s}=e,{poolEntries:c,serverRestartRecovery:l}=We(),{pages:u,loading:d}=wr(),f=IA(c,n,NA),p=(0,Q.useRef)(``),m=f.map(BA).join(`,`),h=(0,Q.useRef)(c),g,_;t[0]===c?(g=t[1],_=t[2]):(g=()=>{h.current=c},_=[c],t[0]=c,t[1]=g,t[2]=_),(0,Q.useLayoutEffect)(g,_),(0,Q.useLayoutEffect)(()=>{if(p.current===m)return;let e=p.current?p.current.split(`,`):[],t=m?m.split(`,`):[],r=e.filter(e=>!t.includes(e)),i=t.filter(t=>!e.includes(t));for(let e of r)ft(e);for(let e of i){let t=h.current.find(t=>t.docName===e)?.poolEventId;he(e,t&&t.length>0?t:crypto.randomUUID())}Ge(`ok/activity/mount-list-change`,{active:n,mounted:t,evicted:r}),p.current=m,Te(t)},[m,n]);let v;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?(v=e=>(0,Z.jsx)(GA,{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]=v):v=t[12];let y=f.map(v),b;return t[13]===y?b=t[14]:(b=(0,Z.jsx)(Z.Fragment,{children:y}),t[13]=y,t[14]=b),b}function BA(e){return e.docName}function VA(e){let t=(0,$.c)(8),{isActive:n,children:r}=e,i=(0,Q.useRef)(null),a=(0,Q.useRef)(0),o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{let e=i.current;if(!e)return;let t=()=>{e.scrollTop>0&&(a.current=e.scrollTop)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},s=[],t[0]=o,t[1]=s):(o=t[0],s=t[1]),(0,Q.useEffect)(o,s);let c,l;t[2]===n?(c=t[3],l=t[4]):(c=()=>{if(!n)return;let e=i.current;if(!e)return;let t=a.current;if(t===0||(e.scrollTop=t,e.scrollTop===t))return;let r=!1,o=()=>{r||(r=!0,s.disconnect(),clearTimeout(c))},s=new ResizeObserver(()=>{r||!e||e.scrollHeight>t&&(e.scrollTop=t,e.scrollTop===t&&o())});s.observe(e);let c=setTimeout(o,500);return o},l=[n],t[2]=n,t[3]=c,t[4]=l),(0,Q.useLayoutEffect)(c,l);let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u={overflowAnchor:`auto`},t[5]=u):u=t[5];let d;return t[6]===r?d=t[7]:(d=(0,Z.jsx)(`div`,{ref:i,"data-testid":`editor-scroll-container`,className:`subtle-scrollbar h-full overflow-y-auto pt-14 scroll-pt-14`,style:u,children:r}),t[6]=r,t[7]=d),d}function HA(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)(qy,{}),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)(FA,{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 UA(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)(ec,{className:`size-5`,"aria-hidden":`true`}):(0,Z.jsx)(Ze,{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)(X,{type:`button`,onClick:WA,children:[(0,Z.jsx)(ec,{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 WA(){return window.location.reload()}function GA(e){let t=(0,$.c)(48),{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=LA(n.docName,u),t[0]=n.docName,t[1]=u,t[2]=d):d=t[2];let f=d,p;t[3]===n.docName?p=t[4]:(p=()=>{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]=p);let[m]=(0,Q.useState)(p),h=n.provider.document.getText(`source`).length,[g,_]=(0,Q.useState)(i),[v,y]=(0,Q.useState)(!i),b,x;t[5]!==i||t[6]!==g||t[7]!==v?(b=()=>{i&&!g?_(!0):!i&&!v&&y(!0)},x=[i,g,v],t[5]=i,t[6]=g,t[7]=v,t[8]=b,t[9]=x):(b=t[8],x=t[9]),(0,Q.useEffect)(b,x);let S=jA({ytextLength:h,isSourceMode:i,visitedSource:g,visitedVisual:v}),C=(0,Q.useRef)(``),w=`${S.isLarge}-${S.renderSource}-${S.renderVisual}`,T,E;t[10]!==n.docName||t[11]!==S.isLarge||t[12]!==S.renderSource||t[13]!==S.renderVisual||t[14]!==w||t[15]!==i||t[16]!==h?(T=()=>{C.current!==w&&(C.current=w,S.isLarge&&Ge(`ok/activity/defer-mount`,{docName:n.docName,ytextLength:h,isSourceMode:i,renderSource:S.renderSource,renderVisual:S.renderVisual}))},E=[w,S.isLarge,S.renderSource,S.renderVisual,n.docName,h,i],t[10]=n.docName,t[11]=S.isLarge,t[12]=S.renderSource,t[13]=S.renderVisual,t[14]=w,t[15]=i,t[16]=h,t[17]=T,t[18]=E):(T=t[17],E=t[18]),(0,Q.useEffect)(T,E);let[D,O]=(0,Q.useState)(!1),k,A;t[19]!==n.docName||t[20]!==S.isLarge||t[21]!==S.renderSource||t[22]!==S.renderVisual||t[23]!==D||t[24]!==i||t[25]!==h?(k=()=>{MA({isLarge:S.isLarge,renderSource:S.renderSource,renderVisual:S.renderVisual,hasEmittedFirstToggle:D})&&(Ge(`ok/cold/first-toggle`,{docName:n.docName,mountId:bt(n.docName),ytextLength:h,modeEnteredFirst:i?`source`:`visual`}),O(!0))},A=[D,S.isLarge,S.renderSource,S.renderVisual,n.docName,h,i],t[19]=n.docName,t[20]=S.isLarge,t[21]=S.renderSource,t[22]=S.renderVisual,t[23]=D,t[24]=i,t[25]=h,t[26]=k,t[27]=A):(k=t[26],A=t[27]),(0,Q.useEffect)(k,A);let j=r?`visible`:`hidden`,M=`editor:${n.docName}`,N;t[28]!==a||t[29]!==n||t[30]!==S.renderSource||t[31]!==S.renderVisual||t[32]!==r||t[33]!==o||t[34]!==i||t[35]!==c||t[36]!==l||t[37]!==m||t[38]!==s||t[39]!==f?(N=f?(0,Z.jsx)(UA,{view:f}):(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(SA,{activeDocName:n.docName,previousDocName:s,onNavigateBack:c,onRecycle:l,children:(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(qy,{}),children:(0,Z.jsx)(_A,{docName:n.docName,provider:n.provider,children:(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[!i&&(0,Z.jsx)(TA,{provider:n.provider}),(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[S.renderSource?(0,Z.jsx)(`div`,{className:i?`h-full`:`ok-mode-hidden h-full`,children:(0,Z.jsx)(HA,{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a})}):null,S.renderVisual?(0,Z.jsx)(`div`,{className:i?`ok-mode-hidden h-full`:`h-full`,children:(0,Z.jsx)(mA,{provider:n.provider,placeholder:a,isSourceMode:i,portalTarget:m},`${n.docName}-${String(o)}`)}):null]})]})})})})}),t[28]=a,t[29]=n,t[30]=S.renderSource,t[31]=S.renderVisual,t[32]=r,t[33]=o,t[34]=i,t[35]=c,t[36]=l,t[37]=m,t[38]=s,t[39]=f,t[40]=N):N=t[40];let P;t[41]!==r||t[42]!==N?(P=(0,Z.jsx)(VA,{isActive:r,children:N}),t[41]=r,t[42]=N,t[43]=P):P=t[43];let F;return t[44]!==M||t[45]!==P||t[46]!==j?(F=(0,Z.jsx)(Q.Activity,{mode:j,name:M,children:P}),t[44]=M,t[45]=P,t[46]=j,t[47]=F):F=t[47],F}function KA(e){let t=(0,$.c)(27),{stats:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(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[0]=r):r=t[0];let i;t[1]===n.words?i=t[2]:(i=n.words.toLocaleString(),t[1]=n.words,t[2]=i);let a;t[3]===i?a=t[4]:(a=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:i}),t[3]=i,t[4]=a);let o=n.words===1?`word`:`words`,s;t[5]!==a||t[6]!==o?(s=(0,Z.jsxs)(`span`,{children:[a,` `,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7];let c;t[8]===n.chars?c=t[9]:(c=n.chars.toLocaleString(),t[8]=n.chars,t[9]=c);let l;t[10]===c?l=t[11]:(l=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:c}),t[10]=c,t[11]=l);let u=n.chars===1?`char`:`chars`,d;t[12]!==l||t[13]!==u?(d=(0,Z.jsxs)(`span`,{children:[l,` `,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f=n.tokens>0?`~`:``,p;t[15]===n.tokens?p=t[16]:(p=n.tokens.toLocaleString(),t[15]=n.tokens,t[16]=p);let m;t[17]===p?m=t[18]:(m=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:p}),t[17]=p,t[18]=m);let h=n.tokens===1?`token`:`tokens`,g;t[19]!==f||t[20]!==m||t[21]!==h?(g=(0,Z.jsxs)(`span`,{children:[f,m,` `,h]}),t[19]=f,t[20]=m,t[21]=h,t[22]=g):g=t[22];let _;return t[23]!==g||t[24]!==s||t[25]!==d?(_=(0,Z.jsxs)(`section`,{"aria-label":`Document statistics`,className:`relative flex h-6 shrink-0 items-center justify-end gap-3 bg-background px-3 text-2xs text-muted-foreground`,children:[r,s,d,g]}),t[23]=g,t[24]=s,t[25]=d,t[26]=_):_=t[26],_}var qA={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`},JA=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`,...qA,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},YA=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)(JA,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},XA=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)(JA,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i};function ZA(e){let t=(0,$.c)(39),{isSourceMode:n,sourceDisabled:r,onModeChange:i,showAddPropertyButton:a,onAddProperty:o,showPanelOpen:s,onTogglePanel:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`div`,{}),t[0]=l):l=t[0];let u=n?`source`:`wysiwyg`,d;t[1]===i?d=t[2]:(d=e=>{e&&i(e)},t[1]=i,t[2]=d);let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(ro,{value:`wysiwyg`,"aria-label":`Visual editor`,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,asChild:!0,children:(0,Z.jsx)(so,{children:(0,Z.jsx)(XA,{className:`size-4`})})}),(0,Z.jsx)(co,{side:`bottom`,children:`Visual`})]}),t[3]=f):f=t[3];let p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(YA,{className:`size-4`}),t[4]=p):p=t[4];let m;t[5]===r?m=t[6]:(m=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(`div`,{children:(0,Z.jsx)(ro,{value:`source`,"aria-label":`Markdown source`,disabled:r,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,children:p})})}),t[5]=r,t[6]=m);let h=r?`Source mode requires a live connection — your edits are saved and will appear when you reconnect.`:`Markdown`,g;t[7]===h?g=t[8]:(g=(0,Z.jsx)(co,{side:`bottom`,children:h}),t[7]=h,t[8]=g);let _;t[9]!==m||t[10]!==g?(_=(0,Z.jsxs)(uo,{children:[m,g]}),t[9]=m,t[10]=g,t[11]=_):_=t[11];let v;t[12]!==u||t[13]!==d||t[14]!==_?(v=(0,Z.jsx)(`div`,{className:`pointer-events-auto flex justify-center`,children:(0,Z.jsxs)(ao,{type:`single`,value:u,onValueChange:d,"aria-label":`Editor mode`,variant:`segmented`,size:`sm`,spacing:1,className:`shrink-0 data-[size=sm]:rounded-[10px] bg-muted p-0.5`,children:[f,_]})}),t[12]=u,t[13]=d,t[14]=_,t[15]=v):v=t[15];let y;t[16]!==o||t[17]!==a?(y=a&&(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`Add properties`,onClick:o,"data-testid":`add-properties-button`,asChild:!0,children:(0,Z.jsx)(so,{children:(0,Z.jsx)(Vs,{})})}),(0,Z.jsx)(co,{side:`bottom`,children:`Add properties`})]}),t[16]=o,t[17]=a,t[18]=y):y=t[18];let b=s?`Show document panel`:`Hide document panel`,x;t[19]===s?x=t[20]:(x=(0,Z.jsx)(so,{children:s?(0,Z.jsx)(Js,{}):(0,Z.jsx)(qs,{})}),t[19]=s,t[20]=x);let S;t[21]!==c||t[22]!==b||t[23]!==x?(S=(0,Z.jsx)(X,{variant:`ghost`,size:`icon`,onClick:c,"aria-label":b,asChild:!0,children:x}),t[21]=c,t[22]=b,t[23]=x,t[24]=S):S=t[24];let C=s?`Show panel`:`Hide panel`,w;t[25]===C?w=t[26]:(w=(0,Z.jsx)(co,{side:`bottom`,children:C}),t[25]=C,t[26]=w);let T;t[27]!==S||t[28]!==w?(T=(0,Z.jsxs)(uo,{children:[S,w]}),t[27]=S,t[28]=w,t[29]=T):T=t[29];let E;t[30]!==y||t[31]!==T?(E=(0,Z.jsxs)(`div`,{className:`pointer-events-auto flex items-center justify-end gap-1`,children:[y,T]}),t[30]=y,t[31]=T,t[32]=E):E=t[32];let D;t[33]!==v||t[34]!==E?(D=(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 items-center px-2 py-2 bg-background`,children:[l,v,E]}),t[33]=v,t[34]=E,t[35]=D):D=t[35];let O;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none h-2 bg-linear-to-b from-background to-transparent`}),t[36]=O):O=t[36];let k;return t[37]===D?k=t[38]:(k=(0,Z.jsxs)(`div`,{"data-testid":`editor-toolbar`,className:`pointer-events-none absolute inset-x-0 top-0 z-10`,children:[D,O]}),t[37]=D,t[38]=k),k}function QA(e){let{activeDocName:t,deferredActiveDocName:n,mountResolved:r,syncResolved:i}=e;return t===null||t===n?!1:!(r&&i)}var $A=(0,Q.lazy)(()=>r(()=>import(`./SettingsDialog-x6fsBA_3.js`).then(e=>({default:e.SettingsDialog})),__vite__mapDeps([45,1,35,2,36,37,21,38,39,40,41,20,3,6,7,15,4,8,14,9,46,16,22,10,23]),import.meta.url));function ej(e){let t=(0,$.c)(5),n;t[0]===e?n=t[1]:(n=(0,Z.jsx)(nj,{...e}),t[0]=e,t[1]=n);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(tj,{}),t[2]=r):r=t[2];let i;return t[3]===n?i=t[4]:(i=(0,Z.jsx)(st,{name:`editor-area`,children:(0,Z.jsxs)(vO,{children:[n,r]})}),t[3]=n,t[4]=i),i}function tj(){let e=(0,$.c)(8),t=Wf(),[n,r]=(0,Q.useState)(!1),i,a;if(e[0]===t.open?(i=e[1],a=e[2]):(i=()=>{t.open&&r(!0)},a=[t.open],e[0]=t.open,e[1]=i,e[2]=a),(0,Q.useEffect)(i,a),!n)return null;let o;e[3]===t?o=e[4]:(o=e=>{e||t.close()},e[3]=t,e[4]=o);let s;return e[5]!==t.open||e[6]!==o?(s=(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)($A,{open:t.open,onOpenChange:o})}),e[5]=t.open,e[6]=o,e[7]=s):s=e[7],s}function nj(e){let t=(0,$.c)(93),{editorMode:n,onModeChange:r,activeTab:i,onActiveTabChange:a}=e,{activeDocName:o,activeProvider:s,activeTarget:c,recycleDocument:l,docPanelMode:u,docPanelExpandSignal:d}=We(),{openDocumentTransition:f}=et(),{requestAddProperty:p}=bO(),m=HO(s,o),h=UO(s),g=h===`connected`||h===`synced`,_=(0,Q.useDeferredValue)(o),v=c?.kind===`missing`,y=!!o&&c?.kind!==`folder`,b=v?`Start writing to create this page`:void 0,x=Hy(),[S,C]=(0,Q.useState)(!1),{layout:w,autoCollapse:T}=EO(),E=w===`sheet`,[D,O]=(0,Q.useState)(!1),k=(0,Q.useRef)(!1),A,j;t[0]!==T||t[1]!==w||t[2]!==x?(A=()=>{if(w!==`panel`)return;let e=requestAnimationFrame(()=>{T?(k.current=!1,x.current?.collapse()):k.current||x.current?.expand()});return()=>cancelAnimationFrame(e)},j=[T,w,x],t[0]=T,t[1]=w,t[2]=x,t[3]=A,t[4]=j):(A=t[3],j=t[4]),(0,Q.useEffect)(A,j);let M,N;t[5]!==E||t[6]!==a||t[7]!==x?(M=()=>{let e=e=>{a(e),E?O(!0):(k.current=!1,x.current?.expand())},t=yf();return t&&e(t),xf(t=>{yf(),e(t)})},N=[E,a,x],t[5]=E,t[6]=a,t[7]=x,t[8]=M,t[9]=N):(M=t[8],N=t[9]),(0,Q.useEffect)(M,N);let P,F;t[10]!==d||t[11]!==E||t[12]!==x?(P=()=>{d!==0&&(E?O(!0):(k.current=!1,x.current?.expand()))},F=[d,E,x],t[10]=d,t[11]=E,t[12]=x,t[13]=P,t[14]=F):(P=t[13],F=t[14]),(0,Q.useEffect)(P,F);let I=(0,Q.useRef)(null),[L,R]=(0,Q.useState)(null),z,B;if(t[15]===o?(z=t[16],B=t[17]):(z=()=>{if(o&&o!==I.current){let e=I.current;I.current=o,R(e)}},B=[o],t[15]=o,t[16]=z,t[17]=B),(0,Q.useEffect)(z,B),c?.kind===`folder`){let e;return t[18]===c.folderPath?e=t[19]:(e=(0,Z.jsx)(dO,{folderPath:c.folderPath}),t[18]=c.folderPath,t[19]=e),e}if(c?.kind===`asset`){let e;return t[20]!==c.assetPath||t[21]!==c.mediaKind?(e=(0,Z.jsx)(Ky,{assetPath:c.assetPath,mediaKind:c.mediaKind}),t[20]=c.assetPath,t[21]=c.mediaKind,t[22]=e):e=t[22],e}if(!s||!o){if((typeof window<`u`?fr(window.location.hash):null)!==null){let e;return t[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(qy,{}),t[23]=e):e=t[23],e}let e;return t[24]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(px,{}),t[24]=e):e=t[24],e}let V=n===`source`,H=!g,U=E?!D:S,W;t[25]!==o||t[26]!==p?(W=function(){o&&p(o)},t[25]=o,t[26]=p,t[27]=W):W=t[27];let G=W,K;t[28]!==S||t[29]!==E||t[30]!==x?(K=function(){E?O(rj):S?(k.current=!1,x.current?.expand()):(k.current=!0,x.current?.collapse())},t[28]=S,t[29]=E,t[30]=x,t[31]=K):K=t[31];let q=K,ee=_??o,te=L??void 0,ne;t[32]===f?ne=t[33]:(ne=e=>{let t=er(e);window.location.hash===t?f(e):window.location.hash=t},t[32]=f,t[33]=ne);let re;t[34]!==b||t[35]!==V||t[36]!==l||t[37]!==ee||t[38]!==te||t[39]!==ne?(re=(0,Z.jsx)(RA,{activeDocName:ee,isSourceMode:V,editorPlaceholder:b,previousDocName:te,onNavigateBack:ne,onRecycle:l}),t[34]=b,t[35]=V,t[36]=l,t[37]=ee,t[38]=te,t[39]=ne,t[40]=re):re=t[40];let ie;t[41]!==o||t[42]!==_?(ie=QA({activeDocName:o,deferredActiveDocName:_,mountResolved:o!==null&&je(o),syncResolved:o!==null&&ye(o)})?(0,Z.jsxs)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:[(0,Z.jsx)(qy,{}),o===null?null:(0,Z.jsx)(hO,{docName:o})]}):null,t[41]=o,t[42]=_,t[43]=ie):ie=t[43];let ae;t[44]!==re||t[45]!==ie?(ae=(0,Z.jsxs)(`div`,{className:`relative h-full`,children:[re,ie]}),t[44]=re,t[45]=ie,t[46]=ae):ae=t[46];let oe=!V,se;t[47]!==V||t[48]!==r||t[49]!==G||t[50]!==U||t[51]!==H||t[52]!==oe||t[53]!==q?(se=(0,Z.jsx)(ZA,{isSourceMode:V,sourceDisabled:H,onModeChange:r,showAddPropertyButton:oe,onAddProperty:G,showPanelOpen:U,onTogglePanel:q}),t[47]=V,t[48]=r,t[49]=G,t[50]=U,t[51]=H,t[52]=oe,t[53]=q,t[54]=se):se=t[54];let ce;t[55]!==ae||t[56]!==se?(ce=(0,Z.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[ae,se]}),t[55]=ae,t[56]=se,t[57]=ce):ce=t[57];let le;t[58]!==y||t[59]!==m?(le=y&&(0,Z.jsx)(KA,{stats:m}),t[58]=y,t[59]=m,t[60]=le):le=t[60];let ue;t[61]!==ce||t[62]!==le?(ue=(0,Z.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[ce,le]}),t[61]=ce,t[62]=le,t[63]=ue):ue=t[63];let de=ue,fe=E?`100%`:`30%`,pe=E?`100%`:`75%`,me;t[64]!==de||t[65]!==fe||t[66]!==pe?(me=(0,Z.jsx)(SO,{minSize:fe,defaultSize:pe,children:de}),t[64]=de,t[65]=fe,t[66]=pe,t[67]=me):me=t[67];let he;t[68]===E?he=t[69]:(he=E?null:(0,Z.jsx)(CO,{withHandle:!0}),t[68]=E,t[69]=he);let ge;t[70]!==o||t[71]!==i||t[72]!==u||t[73]!==E||t[74]!==V||t[75]!==a||t[76]!==x?(ge=E?null:(0,Z.jsx)(SO,{panelRef:x,defaultSize:`25%`,minSize:`300px`,maxSize:`40%`,collapsible:!0,collapsedSize:0,onResize:e=>C(e.asPercentage===0),className:`flex flex-col bg-muted/20`,children:(0,Z.jsx)(Y_,{docName:o,isSourceMode:V,activeTab:i,onActiveTabChange:a,mode:u})}),t[70]=o,t[71]=i,t[72]=u,t[73]=E,t[74]=V,t[75]=a,t[76]=x,t[77]=ge):ge=t[77];let _e;t[78]!==me||t[79]!==he||t[80]!==ge?(_e=(0,Z.jsxs)(xO,{orientation:`horizontal`,children:[me,he,ge]}),t[78]=me,t[79]=he,t[80]=ge,t[81]=_e):_e=t[81];let ve;t[82]!==o||t[83]!==i||t[84]!==u||t[85]!==E||t[86]!==V||t[87]!==a||t[88]!==D?(ve=E?(0,Z.jsx)(mg,{open:D,onOpenChange:O,children:(0,Z.jsxs)(_g,{side:`right`,className:`flex w-80 sm:w-96 flex-col gap-0 p-0`,children:[(0,Z.jsx)(vg,{className:`sr-only`,children:(0,Z.jsx)(yg,{children:`Document panel`})}),(0,Z.jsx)(Y_,{docName:o,isSourceMode:V,activeTab:i,onActiveTabChange:a,mode:u})]})}):null,t[82]=o,t[83]=i,t[84]=u,t[85]=E,t[86]=V,t[87]=a,t[88]=D,t[89]=ve):ve=t[89];let be;return t[90]!==_e||t[91]!==ve?(be=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[_e,ve]}),t[90]=_e,t[91]=ve,t[92]=be):be=t[92],be}function rj(e){return!e}var ij=1280;function aj(){let e=(0,$.c)(2),[t,n]=(0,Q.useState)(oj),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${ij-1}px)`),t=()=>{n(window.innerWidth<ij)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Q.useEffect)(r,i),t}function oj(){return window.innerWidth<ij}function sj(e){let t=e.endsWith(`rem`)?`rem`:`px`;return{value:Number.parseFloat(e),unit:t}}function cj(e){let{value:t,unit:n}=sj(e);return n===`rem`?t*16:t}function lj(e,t){return`${t===`rem`?e.toFixed(1):Math.round(e)}${t}`}var uj=3600*24*7;function dj(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?fj:m,O=g===void 0?uj: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=cj(b),ee;t[6]===x?ee=t[7]:(ee=cj(x),t[6]=x,t[7]=ee);let te=ee,ne;t[8]!==E||t[9]!==k?(ne=function(e){P.current=!0,E&&(j.current=H.current?0:cj(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]=ne):ne=t[10];let re=ne,ie,ae;t[11]!==w||t[12]!==v||t[13]!==C||t[14]!==S||t[15]!==T||t[16]!==k||t[17]!==te||t[18]!==q||t[19]!==i||t[20]!==a||t[21]!==D||t[22]!==O||t[23]!==h?(ie=()=>{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}=sj(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(te,t)),u=lj(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(te,u)),f=lj(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)}},ae=[i,a,D,q,te,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]=te,t[18]=q,t[19]=i,t[20]=a,t[21]=D,t[22]=O,t[23]=h,t[24]=ie,t[25]=ae):(ie=t[24],ae=t[25]),(0,Q.useEffect)(ie,ae);let oe;return t[26]===re?oe=t[27]:(oe={dragRef:A,isDragging:N,handleMouseDown:re},t[26]=re,t[27]=oe),oe}function fj(){}var pj=`sidebar_state`,mj=3600*24*7,hj=`18rem`,gj=`3rem`,_j=`\\`,vj=`app-file-sidebar`,yj=`14.625rem`,bj=`22rem`,xj=`sidebar_width`,Sj=/^\d+(?:\.\d+)?(?:rem|px)$/,Cj=Q.createContext(null);function wj(e){if(typeof document>`u`)return e;let t=document.cookie.split(`; `).find(e=>e.startsWith(`${xj}=`))?.split(`=`)[1];if(!t)return e;let n;try{n=decodeURIComponent(t)}catch{return e}return Sj.test(n)?n:e}function Tj(){let e=Q.use(Cj);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function Ej(e){let t=(0,$.c)(53),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]):({defaultOpen:c,open:i,onOpenChange:o,className:r,style:s,children:n,defaultWidth:l,...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,t[8]=l);let u=c===void 0?!0:c,d=l===void 0?hj:l,f=aj(),p;t[9]===d?p=t[10]:(p=()=>wj(d),t[9]=d,t[10]=p);let[m,h]=Q.useState(p),[g,_]=Q.useState(!1),v=Q.useRef(g),[y,b]=Q.useState(!1),[x,S]=Q.useState(!1),[C,w]=Q.useState(u),T=i??C,E;t[11]!==T||t[12]!==o?(E=e=>{let t=typeof e==`function`?e(T):e;o?o(t):w(t),document.cookie=`${pj}=${t}; path=/; max-age=${mj}`},t[11]=T,t[12]=o,t[13]=E):E=t[13];let D=E,O;t[14]===D?O=t[15]:(O=function(){return window.innerWidth<1280?_(Oj):D(Dj)},t[14]=D,t[15]=O);let k=O,A;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(A=function(){window.innerWidth>=1280||v.current&&(window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||S(!0))},t[16]=A):A=t[16];let j=A,M;t[17]===g?M=t[18]:(M=()=>{v.current=g},t[17]=g,t[18]=M),Q.useLayoutEffect(M);let N,P;t[19]===k?(N=t[20],P=t[21]):(N=()=>{let e=e=>{e.key===_j&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),k())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},P=[k],t[19]=k,t[20]=N,t[21]=P),Q.useEffect(N,P);let F,I;t[22]!==f||t[23]!==g?(F=()=>{if(!f||!g)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"]`)||_(!1))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},I=[f,g],t[22]=f,t[23]=g,t[24]=F,t[25]=I):(F=t[24],I=t[25]),Q.useEffect(F,I);let L=Q.useRef(f),R,z;t[26]!==f||t[27]!==T?(R=()=>{!L.current&&f&&_(T),L.current=f},z=[f,T],t[26]=f,t[27]=T,t[28]=R,t[29]=z):(R=t[28],z=t[29]),Q.useEffect(R,z);let B=f?g?`expanded`:`collapsed`:T?`expanded`:`collapsed`,V;t[30]!==y||t[31]!==f||t[32]!==T||t[33]!==g||t[34]!==D||t[35]!==x||t[36]!==B||t[37]!==k||t[38]!==m?(V={state:B,open:T,setOpen:D,isMobile:f,openMobile:g,setOpenMobile:_,toggleSidebar:k,width:m,setWidth:h,isDraggingRail:y,setIsDraggingRail:b,showPushPulse:x,setShowPushPulse:S,notifySidebarFileSelected:j},t[30]=y,t[31]=f,t[32]=T,t[33]=g,t[34]=D,t[35]=x,t[36]=B,t[37]=k,t[38]=m,t[39]=V):V=t[39];let H;t[40]!==s||t[41]!==m?(H={"--sidebar-width":m,"--sidebar-width-icon":gj,...s},t[40]=s,t[41]=m,t[42]=H):H=t[42];let U=H,W;t[43]===r?W=t[44]:(W=Y(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),t[43]=r,t[44]=W);let G;t[45]!==n||t[46]!==a||t[47]!==U||t[48]!==W?(G=(0,Z.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:U,className:W,...a,children:n}),t[45]=n,t[46]=a,t[47]=U,t[48]=W,t[49]=G):G=t[49];let K;return t[50]!==V||t[51]!==G?(K=(0,Z.jsx)(Cj.Provider,{value:V,children:G}),t[50]=V,t[51]=G,t[52]=K):K=t[52],K}function Dj(e){return!e}function Oj(e){return!e}function kj(e){let t=(0,$.c)(51),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({side:a,variant:o,collapsible:s,className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=a===void 0?`left`:a,l=o===void 0?`sidebar`:o,u=s===void 0?`offcanvas`:s,{isMobile:d,state:f,openMobile:p,isDraggingRail:m}=Tj();if(u===`none`){let e;t[7]===r?e=t[8]:(e=Y(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),t[7]=r,t[8]=e);let a;return t[9]!==n||t[10]!==i||t[11]!==e||t[12]!==l?(a=(0,Z.jsx)(`div`,{"data-slot":`sidebar`,"data-variant":l,className:e,...i,children:n}),t[9]=n,t[10]=i,t[11]=e,t[12]=l,t[13]=a):a=t[13],a}if(d){let e=p?`expanded`:`collapsed`,a=l===`floating`||l===`inset`?`p-2`:``,o;t[14]!==r||t[15]!==a?(o=Y(`fixed inset-y-0 z-30 flex h-svh w-(--sidebar-width)`,`transition-transform duration-200 ease-linear motion-reduce:transition-none`,`data-[side=left]:left-0 data-[side=right]:right-0`,`group-data-[state=collapsed]:data-[side=left]:-translate-x-full`,`group-data-[state=collapsed]:data-[side=right]:translate-x-full`,a,r),t[14]=r,t[15]=a,t[16]=o):o=t[16];let s;t[17]===n?s=t[18]:(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[17]=n,t[18]=s);let u;t[19]!==i||t[20]!==c||t[21]!==o||t[22]!==s?(u=(0,Z.jsx)(`nav`,{id:vj,"aria-label":`File sidebar`,"data-slot":`sidebar-container`,"data-side":c,className:o,...i,children:s}),t[19]=i,t[20]=c,t[21]=o,t[22]=s,t[23]=u):u=t[23];let d;return t[24]!==e||t[25]!==c||t[26]!==u||t[27]!==l?(d=(0,Z.jsx)(`div`,{className:`group peer text-sidebar-foreground`,"data-state":e,"data-variant":l,"data-side":c,"data-slot":`sidebar`,"data-mobile":`true`,children:u}),t[24]=e,t[25]=c,t[26]=u,t[27]=l,t[28]=d):d=t[28],d}let h=f===`collapsed`?u:``,g=l===`floating`||l===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,_;t[29]===g?_=t[30]:(_=Y(`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[29]=g,t[30]=_);let v;t[31]===_?v=t[32]:(v=(0,Z.jsx)(`div`,{"data-slot":`sidebar-gap`,className:_}),t[31]=_,t[32]=v);let y=l===`floating`||l===`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`,b;t[33]!==r||t[34]!==y?(b=Y(`fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear 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)] md:flex`,y,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`,r),t[33]=r,t[34]=y,t[35]=b):b=t[35];let x;t[36]===n?x=t[37]:(x=(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[36]=n,t[37]=x);let S;t[38]!==i||t[39]!==c||t[40]!==x||t[41]!==b?(S=(0,Z.jsx)(`div`,{"data-slot":`sidebar-container`,"data-side":c,className:b,...i,children:x}),t[38]=i,t[39]=c,t[40]=x,t[41]=b,t[42]=S):S=t[42];let C;return t[43]!==m||t[44]!==c||t[45]!==f||t[46]!==S||t[47]!==h||t[48]!==v||t[49]!==l?(C=(0,Z.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":f,"data-collapsible":h,"data-variant":l,"data-side":c,"data-slot":`sidebar`,"data-dragging":m,children:[v,S]}),t[43]=m,t[44]=c,t[45]=f,t[46]=S,t[47]=h,t[48]=v,t[49]=l,t[50]=C):C=t[50],C}function Aj(e){let t=(0,$.c)(16),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,onClick:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let{toggleSidebar:a,state:o}=Tj(),s=o===`expanded`,c;t[4]===n?c=t[5]:(c=Y(n),t[4]=n,t[5]=c);let l;t[6]!==r||t[7]!==a?(l=e=>{r?.(e),a()},t[6]=r,t[7]=a,t[8]=l):l=t[8];let u,d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(J,{}),d=(0,Z.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`}),t[9]=u,t[10]=d):(u=t[9],d=t[10]);let f;return t[11]!==i||t[12]!==s||t[13]!==c||t[14]!==l?(f=(0,Z.jsxs)(X,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon-sm`,"aria-expanded":s,"aria-controls":vj,className:c,onClick:l,...i,children:[u,d]}),t[11]=i,t[12]=s,t[13]=c,t[14]=l,t[15]=f):f=t[15],f}function jj(e){let t=(0,$.c)(24),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:n,enableDrag:a,enableToggle:o,onMouseDown:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=a===void 0?!0:a,c=o===void 0?!0:o,{toggleSidebar:l,setWidth:u,state:d,width:f,setIsDraggingRail:p}=Tj(),m=d===`collapsed`,h;t[6]!==s||t[7]!==c||t[8]!==p||t[9]!==u||t[10]!==m||t[11]!==l||t[12]!==f?(h={direction:`right`,enableDrag:s,enableToggle:c,onResize:u,onToggle:l,currentWidth:f,isCollapsed:m,minResizeWidth:yj,maxResizeWidth:bj,setIsDraggingRail:p,widthCookieName:xj,widthCookieMaxAge:mj},t[6]=s,t[7]=c,t[8]=p,t[9]=u,t[10]=m,t[11]=l,t[12]=f,t[13]=h):h=t[13];let{dragRef:g,handleMouseDown:_}=dj(h),v;t[14]!==_||t[15]!==r?(v=e=>{r?.(e),e.defaultPrevented||_(e)},t[14]=_,t[15]=r,t[16]=v):v=t[16];let y;t[17]===n?y=t[18]:(y=Y(`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[17]=n,t[18]=y);let b;return t[19]!==g||t[20]!==i||t[21]!==v||t[22]!==y?(b=(0,Z.jsx)(`button`,{ref:g,"data-sidebar":`rail`,"data-slot":`sidebar-rail`,"aria-label":`Toggle Sidebar`,tabIndex:-1,onMouseDown:v,title:`Toggle Sidebar`,className:y,...i}),t[19]=g,t[20]=i,t[21]=v,t[22]=y,t[23]=b):b=t[23],b}function Mj(e){let t=(0,$.c)(21),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,onClick:i,onAnimationEnd:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{isMobile:o,openMobile:s,setOpenMobile:c,showPushPulse:l,setShowPushPulse:u}=Tj(),d;t[5]!==o||t[6]!==i||t[7]!==s||t[8]!==c?(d=e=>{i?.(e),!e.defaultPrevented&&(!o||!s||e.target?.closest(`[data-sidebar="trigger"]`)||c(!1))},t[5]=o,t[6]=i,t[7]=s,t[8]=c,t[9]=d):d=t[9];let f=d,p;t[10]!==r||t[11]!==u?(p=e=>{r?.(e),e.animationName===`sidebar-push-pulse`&&u(!1)},t[10]=r,t[11]=u,t[12]=p):p=t[12];let m=p,h=l?``:void 0,g;t[13]===n?g=t[14]:(g=Y(`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`,`transition-transform duration-200 ease-linear motion-reduce:transition-none`,`peer-data-[mobile=true]:peer-data-[state=expanded]:translate-x-(--sidebar-width)`,n),t[13]=n,t[14]=g);let _;return t[15]!==m||t[16]!==f||t[17]!==a||t[18]!==h||t[19]!==g?(_=(0,Z.jsx)(`main`,{"data-slot":`sidebar-inset`,"data-push-pulse":h,onClick:f,onAnimationEnd:m,className:g,...a}),t[15]=m,t[16]=f,t[17]=a,t[18]=h,t[19]=g,t[20]=_):_=t[20],_}function Nj(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=Y(`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 Pj(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=Y(`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 Fj(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=Y(`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 Ij(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=Y(`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 Lj(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=Y(`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 Rj=Lr(`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 zj(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?Rr:`button`,{isMobile:m,state:h}=Tj(),g;t[8]!==n||t[9]!==f||t[10]!==d?(g=Y(Rj({variant:d,size:f}),n),t[8]=n,t[9]=f,t[10]=d,t[11]=g):g=t[11];let _;t[12]!==p||t[13]!==u||t[14]!==r||t[15]!==f||t[16]!==g?(_=(0,Z.jsx)(p,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":f,"data-active":u,className:g,...r}),t[12]=p,t[13]=u,t[14]=r,t[15]=f,t[16]=g,t[17]=_):_=t[17];let v=_;if(!c)return v;if(typeof c==`string`){let e;t[18]===c?e=t[19]:(e={children:c},t[18]=c,t[19]=e),c=e}let y;t[20]===v?y=t[21]:(y=(0,Z.jsx)(so,{asChild:!0,children:v}),t[20]=v,t[21]=y);let b=h!==`collapsed`||m,x;t[22]!==b||t[23]!==c?(x=(0,Z.jsx)(co,{side:`right`,align:`center`,hidden:b,...c}),t[22]=b,t[23]=c,t[24]=x):x=t[24];let S;return t[25]!==y||t[26]!==x?(S=(0,Z.jsxs)(uo,{children:[y,x]}),t[25]=y,t[26]=x,t[27]=S):S=t[27],S}function Bj(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 Vj(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 Hj=1e3,Uj=!1;function Wj(e){return!!(e.localPrincipalId&&e.entryPrincipalId===e.localPrincipalId||!e.localPrincipalId&&e.entryClientId===e.localClientId)}function Gj(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:si(i)?a=i:(a=void 0,Uj||(Uj=!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`&&(Wj({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=Vj(i),{current:c,crossDoc:l}=a?ni(a,n,Date.now()):{current:[],crossDoc:[]},u=Kj,d=c.map(u),f=l.map(u),p=[...s,...d],m=f;o(e=>Bj(e.current,p)&&Bj(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,Hj);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 Kj(e){let{agentId:t,entry:n}=e;return{kind:`agent`,agentId:t,presence:n}}var qj=`sync-status`;function Jj(e,t){let n=(0,$.c)(4),r=(0,Q.useRef)(!1),i=(0,Q.useRef)(!1),a=(0,Q.useRef)(t),o,s;n[0]!==t||n[1]!==e?(o=()=>{a.current!==t&&(a.current=t,r.current=!1,i.current=!1),t&&(e===`synced`&&(r.current=!0),e===`disconnected`&&r.current?(i.current=!0,Xa.warning(`Connection lost — keep this tab open, your edits will sync when reconnected`,{id:qj,duration:1/0})):i.current&&e===`synced`&&(i.current=!1,Xa.success(`Reconnected`,{id:qj,duration:3e3})))},s=[e,t],n[0]=t,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),(0,Q.useEffect)(o,s)}var Yj=4,Xj=3,Zj={Bird:ns,Cat:cs,Dog:xs,Fish:Ts,Mouse:$s,Rabbit:Qs,Shrimp:ic,Snail:ac,Squirrel:lc,Turtle:mc};Object.freeze([...Object.keys(Zj)]);function Qj(e){if(typeof e.principalId==`string`&&e.principalId.length>0)return{kind:`initials`};let t=e.name.split(` `)[1];return t&&Object.hasOwn(Zj,t)?{kind:`animal`,animal:t}:{kind:`initials`}}var $j={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function eM(e){let t=(0,$.c)(20),{user:n,mode:r,tabCount:i}=e,a=Qj(n),o=a.kind===`animal`?Zj[a.animal]:void 0,s;t[0]===n.name?s=t[1]:(s=Rn(n.name),t[0]=n.name,t[1]=s);let c=s,l;t[2]===n.color?l=t[3]:(l=Or(n.color),t[2]=n.color,t[3]=l);let u=l,d=i>1?`${n.name} · ${i} tabs`:n.name,f=i>1?`${n.name}, ${i} concurrent tabs`:n.name,p;t[4]===n.color?p=t[5]:(p={backgroundColor:n.color},t[4]=n.color,t[5]=p);let m;t[6]!==o||t[7]!==u||t[8]!==c?(m=o?(0,Z.jsx)(o,{size:18,color:u,strokeWidth:1.5}):(0,Z.jsx)(`span`,{className:`font-mono text-2xs font-semibold leading-none`,style:{color:u},children:c}),t[6]=o,t[7]=u,t[8]=c,t[9]=m):m=t[9];let h;t[10]!==f||t[11]!==r||t[12]!==p||t[13]!==m?(h=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(`div`,{"data-presence-badge":`human`,"data-presence-mode":r,role:`img`,"aria-label":f,className:`inline-flex size-7 shrink-0 cursor-default items-center justify-center rounded-full ring-2 ring-background`,style:p,children:m})}),t[10]=f,t[11]=r,t[12]=p,t[13]=m,t[14]=h):h=t[14];let g;t[15]===d?g=t[16]:(g=(0,Z.jsx)(co,{children:d}),t[15]=d,t[16]=g);let _;return t[17]!==h||t[18]!==g?(_=(0,Z.jsxs)(uo,{children:[h,g]}),t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function tM(e){let t=$j[e.icon];return e.displayName||t||`Agent`}function nM(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 rM(e){let t=(0,$.c)(36),{participant:n,crossDoc:r,scoped:i,onClickAgent:a}=e,{presence:o,agentId:s}=n,c;t[0]===o?c=t[1]:(c=tM(o),t[0]=o,t[1]=c);let l=c,u=nM(o.mode),d=!r&&u,f=i?`ring-primary ring-offset-2 ring-offset-background`:`ring-background`,p=d&&!i?`ring-primary/40 animate-pulse`:``,m;t[2]!==f||t[3]!==p?(m=[`inline-flex size-7 shrink-0 items-center justify-center rounded-full ring-2 cursor-pointer`,f,p].filter(Boolean),t[2]=f,t[3]=p,t[4]=m):m=t[4];let h=m.join(` `),g=r?`true`:void 0,_=i?`true`:void 0,v;t[5]!==o.mode||t[6]!==g||t[7]!==_?(v={"data-presence-badge":`agent`,"data-presence-mode":o.mode,"data-presence-crossdoc":g,"data-presence-scoped":_},t[5]=o.mode,t[6]=g,t[7]=_,t[8]=v):v=t[8];let y=v,b=o.currentDoc&&o.currentDoc!==`(connected)`?o.currentDoc:null,x=r&&b?`Open activity panel for ${l}, editing ${b}`:`Open activity panel for ${l}`,S;t[9]===o.color?S=t[10]:(S={backgroundColor:o.color},t[9]=o.color,t[10]=S);let C;t[11]!==s||t[12]!==a?(C=()=>a(s),t[11]=s,t[12]=a,t[13]=C):C=t[13];let w;t[14]===o.icon?w=t[15]:(w=(0,Z.jsx)(ai,{icon:o.icon,width:16,height:16,className:`text-white`}),t[14]=o.icon,t[15]=w);let T;t[16]!==x||t[17]!==y||t[18]!==h||t[19]!==w||t[20]!==S||t[21]!==C?(T=(0,Z.jsx)(`button`,{type:`button`,...y,"aria-label":x,className:h,style:S,onClick:C,children:w}),t[16]=x,t[17]=y,t[18]=h,t[19]=w,t[20]=S,t[21]=C,t[22]=T):T=t[22];let E=T,D;t[23]===E?D=t[24]:(D=(0,Z.jsx)(so,{asChild:!0,children:E}),t[23]=E,t[24]=D);let O;t[25]===l?O=t[26]:(O=(0,Z.jsx)(`span`,{className:`font-medium`,children:l}),t[25]=l,t[26]=O);let k;t[27]!==r||t[28]!==b?(k=r&&b?(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`editing [[`,b,`]]`]}):null,t[27]=r,t[28]=b,t[29]=k):k=t[29];let A;t[30]!==O||t[31]!==k?(A=(0,Z.jsxs)(co,{className:`flex flex-col gap-0.5`,children:[O,k]}),t[30]=O,t[31]=k,t[32]=A):A=t[32];let j;return t[33]!==D||t[34]!==A?(j=(0,Z.jsxs)(uo,{children:[D,A]}),t[33]=D,t[34]=A,t[35]=j):j=t[35],j}function iM(e){let t=(0,$.c)(18),{count:n,remainder:r,crossDoc:i,scopedAgentId:a,onClickAgent:o}=e,s=i?`true`:void 0,c=`${n} more ${i?`cross-doc `:``}${n===1?`participant`:`participants`}`,l;t[0]!==n||t[1]!==s||t[2]!==c?(l=(0,Z.jsx)(ie,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`presence-overflow`,"data-presence-crossdoc":s,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[0]=n,t[1]=s,t[2]=c,t[3]=l):l=t[3];let u;if(t[4]!==i||t[5]!==o||t[6]!==r||t[7]!==a){let e;t[9]!==i||t[10]!==o||t[11]!==a?(e=e=>e.kind===`human`?(0,Z.jsx)(eM,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(rM,{participant:e,crossDoc:i,scoped:a===e.agentId,onClickAgent:o},e.agentId),t[9]=i,t[10]=o,t[11]=a,t[12]=e):e=t[12],u=r.map(e),t[4]=i,t[5]=o,t[6]=r,t[7]=a,t[8]=u}else u=t[8];let d;t[13]===u?d=t[14]:(d=(0,Z.jsx)(ae,{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:u})}),t[13]=u,t[14]=d);let f;return t[15]!==l||t[16]!==d?(f=(0,Z.jsxs)(E,{children:[l,d]}),t[15]=l,t[16]=d,t[17]=f):f=t[17],f}function aM(e,t,n,r){return e.kind===`human`?(0,Z.jsx)(eM,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(rM,{participant:e,crossDoc:n,scoped:r===e.agentId,onClickAgent:t},e.agentId)}function oM(){let e=(0,$.c)(20),{activeProvider:t,activeDocName:n,systemProvider:r,openActivityPanel:i,docPanelMode:a,docPanelAgentId:o}=We(),{current:s,crossDoc:c}=Gj(t,r,n);Jj(UO(t),n);let l;if(e[0]!==c||e[1]!==s||e[2]!==o||e[3]!==a||e[4]!==i){let t=s.slice(0,Yj),n;e[6]===s?n=e[7]:(n=s.slice(Yj),e[6]=s,e[7]=n);let r=n,u=c.slice(0,Xj),d;e[8]===c?d=e[9]:(d=c.slice(Xj),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=>aM(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)(iM,{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=>aM(e,p,!0,m)),f.length>0?(0,Z.jsx)(iM,{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 sM(e,t){return t.trim()}function cM(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function lM(e,t){let n=sM(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function uM(e,t,n=[]){if(t.length===0&&n.length===0)return e;let r=new Map(t.map(e=>[e.fromDocName,e.toDocName]));return e.map(e=>Ar(e)?{...e,docName:r.get(e.docName)??e.docName}:Pr(e)||Fn(e)?{...e,path:pM(e.path,n)}:e)}function dM(e,t,n){if(t.length===0&&!n)return e;let r=new Set(t);return e.filter(e=>Ar(e)?!r.has(e.docName)&&!mM(e.docName,n):Pr(e)||Fn(e)?!mM(e.path,n):!0)}function fM(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}function pM(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 mM(e,t){return!!t&&(e===t||e.startsWith(`${t}/`))}function hM(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)(bl,{"data-slot":`context-menu`,...n}),t[2]=n,t[3]=r),r}function gM(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=Y(`select-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(xl,{"data-slot":`context-menu-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function _M(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=Y(`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`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Sl,{children:(0,Z.jsx)(Cl,{"data-slot":`context-menu-content`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function vM(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=Y(`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)(wl,{"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 yM(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=Y(`-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)(Tl,{"data-slot":`context-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function bM(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=Y(`group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`input-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var xM=Lr(`flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4`,{variants:{align:{"inline-start":`order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]`,"inline-end":`order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]`,"block-start":`order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2`,"block-end":`order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2`}},defaultVariants:{align:`inline-start`}});function SM(e){let t=(0,$.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,align:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`inline-start`:i,o;t[4]!==a||t[5]!==n?(o=Y(xM({align:a}),n),t[4]=a,t[5]=n,t[6]=o):o=t[6];let s;return t[7]!==a||t[8]!==r||t[9]!==o?(s=(0,Z.jsx)(`div`,{"data-slot":`input-group-addon`,"data-align":a,className:o,onMouseDown:CM,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function CM(e){e.target.closest(`button`)||(e.preventDefault(),e.currentTarget.parentElement?.querySelector(`input`)?.focus())}Lr(`flex items-center gap-2 text-sm shadow-none`,{variants:{size:{xs:`h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5`,sm:``,"icon-xs":`size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0`,"icon-sm":`size-8 p-0 has-[>svg]:p-0`}},defaultVariants:{size:`xs`}});function wM(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=Y(`flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`span`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function TM(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=Y(`flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(fo,{"data-slot":`input-group-control`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var EM=[`.md`,`.mdx`],DM=`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`,OM=`z-10 rounded-t-lg rounded-b-none border-border border-b-0 bg-background text-foreground`,kM=Y(OM,`bg-transparent hover:bg-muted focus-visible:bg-muted border-transparent hover:border-border focus-visible:border-border`),AM=`flex h-full min-w-0 flex-1 cursor-pointer items-center overflow-hidden px-3 text-left text-[13px] outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,jM=`mr-2 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 focus-visible:opacity-100`;function MM(e){return Y(jM,e?`opacity-100`:`pointer-events-none opacity-0 group-focus-within:pointer-events-auto group-focus-within:opacity-100 group-hover:pointer-events-auto group-hover:opacity-100`)}function NM(e,t){let n=e.lastIndexOf(`/`),r=n<0?e:e.slice(n+1),i=`${r}${t}`;return n<0?{baseName:r,extension:t,label:i,prefix:``}:{baseName:r,extension:t,label:i,prefix:`${e.slice(0,n)}/`}}function PM(e){return e.replace(/[^A-Za-z0-9_-]/g,`-`)}function FM(e){let t=er(e);window.location.hash!==t&&(window.location.hash=t)}function IM(e){Math.abs(e.deltaX)>=Math.abs(e.deltaY)||e.currentTarget.scrollWidth<=e.currentTarget.clientWidth||(e.preventDefault(),e.currentTarget.scrollLeft+=e.deltaY)}function LM(e,t){let n=[t,...EM].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 RM(e){let t=(0,$.c)(48),{children:n,closeTab:r,closeTabs:i,canPin:a,disabled:o,openTabs:s,pinTab:c,pinnedTabIds:l,tabId:u,unpinTab:d}=e,f=a===void 0?!0:a;if(o!==void 0&&o)return n;let p;t[0]!==f||t[1]!==l||t[2]!==u?(p=f&&l.includes(u),t[0]=f,t[1]=l,t[2]=u,t[3]=p):p=t[3];let m=p,h;if(t[4]!==s||t[5]!==l||t[6]!==u){let e;t[8]===u?e=t[9]:(e=e=>e!==u,t[8]=u,t[9]=e),h=Pe(s.filter(e),l),t[4]=s,t[5]=l,t[6]=u,t[7]=h}else h=t[7];let g=h,_;t[10]!==s||t[11]!==l?(_=Pe(s,l),t[10]=s,t[11]=l,t[12]=_):_=t[12];let v=_,y=l.length?`Close all unpinned`:`Close all`,b;t[13]===n?b=t[14]:(b=(0,Z.jsx)(gM,{asChild:!0,children:n}),t[13]=n,t[14]=b);let x;t[15]!==r||t[16]!==u?(x=()=>r(u),t[15]=r,t[16]=u,t[17]=x):x=t[17];let S;t[18]!==m||t[19]!==x?(S=(0,Z.jsx)(vM,{disabled:m,onSelect:x,children:`Close`}),t[18]=m,t[19]=x,t[20]=S):S=t[20];let C=g.length===0,w;t[21]!==i||t[22]!==g?(w=()=>{i(g)},t[21]=i,t[22]=g,t[23]=w):w=t[23];let T;t[24]!==w||t[25]!==C?(T=(0,Z.jsx)(vM,{disabled:C,onSelect:w,children:`Close others`}),t[24]=w,t[25]=C,t[26]=T):T=t[26];let E=v.length===0,D;t[27]!==v||t[28]!==i?(D=()=>{i(v)},t[27]=v,t[28]=i,t[29]=D):D=t[29];let O;t[30]!==y||t[31]!==E||t[32]!==D?(O=(0,Z.jsx)(vM,{disabled:E,onSelect:D,children:y}),t[30]=y,t[31]=E,t[32]=D,t[33]=O):O=t[33];let k;t[34]!==f||t[35]!==m||t[36]!==c||t[37]!==u||t[38]!==d?(k=f&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(yM,{}),(0,Z.jsx)(vM,{onSelect:()=>m?d(u):c(u),children:m?`Unpin tab`:`Pin tab`})]}),t[34]=f,t[35]=m,t[36]=c,t[37]=u,t[38]=d,t[39]=k):k=t[39];let A;t[40]!==T||t[41]!==O||t[42]!==k||t[43]!==S?(A=(0,Z.jsxs)(_M,{className:`min-w-40`,children:[S,T,O,k]}),t[40]=T,t[41]=O,t[42]=k,t[43]=S,t[44]=A):A=t[44];let j;return t[45]!==A||t[46]!==b?(j=(0,Z.jsxs)(hM,{children:[b,A]}),t[45]=A,t[46]=b,t[47]=j):j=t[47],j}function zM(e){let t=(0,$.c)(14),{accessibleLabel:n,closeTab:r,isPinned:i,tabId:a,unpinTab:o}=e;if(i){let e=`Unpin ${n}`,r;t[0]!==a||t[1]!==o?(r=e=>{e.stopPropagation(),o(a)},t[0]=a,t[1]=o,t[2]=r):r=t[2];let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(Zs,{"aria-hidden":`true`}),t[3]=i):i=t[3];let s;return t[4]!==e||t[5]!==r?(s=(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":e,className:`mr-2 text-primary! hover:bg-primary/10!`,onClick:r,children:i}),t[4]=e,t[5]=r,t[6]=s):s=t[6],s}let s=`Close ${n}`,c;t[7]!==r||t[8]!==a?(c=e=>{e.stopPropagation(),r(a)},t[7]=r,t[8]=a,t[9]=c):c=t[9];let l;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(Fa,{"aria-hidden":`true`}),t[10]=l):l=t[10];let u;return t[11]!==s||t[12]!==c?(u=(0,Z.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":s,className:`mr-2`,onClick:c,children:l}),t[11]=s,t[12]=c,t[13]=u):u=t[13],u}function BM(){let e=(0,$.c)(68),{activeDocName:t,activeTabId:n,activeNewTabId:r,activeTarget:i,activateTab:a,activateNewTab:o,closeAndClearForRename:s,closeNewTab:c,closeTab:l,closeTabs:u,isNewTabActive:d,newTabIds:f,openNewTab:p,openTabs:m,pinTab:h,pinnedTabIds:g,remapTabsForRename:_,unpinTab:v,visibleTabIds:y}=We(),{pageMeta:b}=wr(),x=(0,Q.useRef)(null),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(!1),A=(0,Q.useRef)(null),j=(0,Q.useRef)(!1),N=(0,Q.useRef)(!1),P=(0,Q.useRef)(null),F=(0,Q.useRef)(t),I;e[0]!==n||e[1]!==t||e[2]!==i?(I=n??(i?ve(i):t?nt(t):null),e[0]=n,e[1]=t,e[2]=i,e[3]=I):I=e[3];let L=I,R;e[4]!==r||e[5]!==L||e[6]!==d||e[7]!==f||e[8]!==m?(R=d?`${r??`__new-tab__`}\u0000${m.join(`\0`)}\u0000${f.join(`\0`)}`:L?`${L}\u0000${m.join(`\0`)}`:``,e[4]=r,e[5]=L,e[6]=d,e[7]=f,e[8]=m,e[9]=R):R=e[9];let z=R,B,V;e[10]===t?(B=e[11],V=e[12]):(B=()=>{F.current=t},V=[t],e[10]=t,e[11]=B,e[12]=V),(0,Q.useEffect)(B,V);let H,U;e[13]===z?(H=e[14],U=e[15]):(H=()=>{z&&(x.current?.querySelector(`[data-active-tab="true"]`))?.scrollIntoView({block:`nearest`,inline:`nearest`})},U=[z],e[13]=z,e[14]=H,e[15]=U),(0,Q.useEffect)(H,U);let W,G;e[16]===S?(W=e[17],G=e[18]):(W=()=>{S&&(A.current?.focus(),A.current?.select())},G=[S],e[16]=S,e[17]=W,e[18]=G),(0,Q.useEffect)(W,G);let K,q;e[19]!==m||e[20]!==S?(K=()=>{!S||m.includes(S.tabId)||(N.current=!0,P.current=null,C(null),T(``),D(null),k(!1))},q=[m,S],e[19]=m,e[20]=S,e[21]=K,e[22]=q):(K=e[21],q=e[22]),(0,Q.useEffect)(K,q);let ee,te,ne,re,ie;if(e[23]!==o||e[24]!==a||e[25]!==r||e[26]!==L||e[27]!==s||e[28]!==c||e[29]!==l||e[30]!==u||e[31]!==O||e[32]!==f||e[33]!==b||e[34]!==h||e[35]!==g||e[36]!==_||e[37]!==E||e[38]!==w||e[39]!==S?.docName||e[40]!==S?.tabId||e[41]!==v||e[42]!==y){let t=function(e,t){let n=t.split(`/`);N.current=!1,P.current=null,C({docName:t,tabId:e}),T(n[n.length-1]),D(null)},n=function(){N.current=!0,P.current=null,C(null),T(``),D(null),k(!1)},i=async function(){if(N.current){N.current=!1;return}if(j.current)return;let e=S?.docName;if(!e){n();return}let t=sM(`file`,LM(w,b.get(e)?.docExt??`.md`)),r=e.split(`/`),i=r[r.length-1];if(t===i){n();return}if(t===P.current){A.current?.focus();return}if(!cM(t)){D(`Name can’t be empty, ".", "..", or contain / or \\`),A.current?.focus();return}let a=lM({kind:`file`,path:e,name:i},t);j.current=!0,k(!0),D(null);try{let n=await fetch(`/api/rename-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:`file`,fromPath:e,toPath:a})});if(N.current){k(!1),j.current=!1;return}let r=await Le(n,`Server error (HTTP ${n.status})`);if(!r.ok){D(r.title),k(!1),j.current=!1,P.current=t,A.current?.focus();return}let i=M(vn,r.body,`rename-path:tab`,{renamed:[]}).renamed,o=F.current,c=fM(o,i);await Promise.all(i.flatMap(e=>[s(e.fromDocName),s(e.toDocName)])),_(i),Kn([`files`,`backlinks`,`graph`]),N.current=!0,C(null),T(``),D(null),k(!1),j.current=!1,P.current=null,c&&c!==o&&FM(c)}catch(n){console.warn(`[EditorTabs] rename failed`,{err:n,docName:e,newDocName:a,normalized:t}),D(`Network error — please try again`),k(!1),j.current=!1,P.current=t,A.current?.focus()}};ee=typeof window<`u`&&window.okDesktop!=null;let d;e[48]===f?d=e[49]:(d=new Set(f),e[48]=f,e[49]=d);let p=d,m;e[50]!==c||e[51]!==u||e[52]!==p?(m=function(e){let t=[],n=[];for(let r of e)p.has(r)?n.push(r):t.push(r);t.length>0&&u(t);for(let e of n)c(e)},e[50]=c,e[51]=u,e[52]=p,e[53]=m):m=e[53];let I=m;te=x,e[54]===Symbol.for(`react.memo_cache_sentinel`)?(ne=Y(`pl-2 flex h-12 min-w-0 touch-manipulation flex-1 items-end gap-1 overflow-x-auto overflow-y-hidden overscroll-x-contain scroll-fade-mask-x [scrollbar-width:none]`,ee&&`[-webkit-app-region:drag]`),e[54]=ne):ne=e[54],re=IM,ie=y.map(e=>{if(p.has(e)){let t=e===r;return(0,Z.jsx)(RM,{tabId:e,canPin:!1,openTabs:y,closeTab:c,closeTabs:I,pinTab:h,pinnedTabIds:g,unpinTab:v,children:(0,Z.jsxs)(`div`,{role:`presentation`,"data-active-tab":t?`true`:void 0,className:Y(DM,t?OM:kM,ee&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),c(e))},onClick:t=>{t.target===t.currentTarget&&o(e)},children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Activate new tab`,className:AM,onClick:()=>o(e),children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:`New tab`})}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Close new tab`,className:MM(t),onClick:t=>{t.stopPropagation(),c(e)},children:(0,Z.jsx)(Fa,{"aria-hidden":`true`,className:`size-3.5`})})]})},e)}let s=Ye(e),u=e===L,d=g.includes(e);if(s.kind===`folder`){let{baseName:t,label:n,prefix:r}=NM(s.folderPath,`/`),i=`${r}${n}`;return(0,Z.jsx)(RM,{tabId:e,openTabs:y,closeTab:l,closeTabs:I,pinTab:h,pinnedTabIds:g,unpinTab:v,children:(0,Z.jsxs)(`div`,{role:`presentation`,"data-active-tab":u?`true`:void 0,className:Y(DM,u?OM:kM,ee&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!d&&l(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":i,className:AM,onClick:()=>{a(e)},children:[r&&(0,Z.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate`,u&&`text-muted-foreground`),children:r}),(0,Z.jsxs)(`span`,{className:Y(`flex min-w-0 items-center`,r?`max-w-[70%] shrink-0`:`flex-1`),children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:`/`})]})]}),(0,Z.jsx)(zM,{accessibleLabel:i,closeTab:l,isPinned:d,tabId:e,unpinTab:v})]})},e)}if(s.kind===`asset`){let{baseName:t,label:n,prefix:r}=NM(s.assetPath,``),i=`${r}${n}`;return(0,Z.jsx)(RM,{tabId:e,openTabs:y,closeTab:l,closeTabs:I,pinTab:h,pinnedTabIds:g,unpinTab:v,children:(0,Z.jsxs)(`div`,{role:`presentation`,"data-active-tab":u?`true`:void 0,className:Y(DM,u?OM:kM,ee&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!d&&l(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":i,className:AM,onClick:()=>{a(e)},children:[r?(0,Z.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate text-muted-foreground/60`,u&&`text-muted-foreground`),children:r}):null,(0,Z.jsx)(`span`,{className:Y(`min-w-0 truncate`,r?`max-w-[70%] shrink-0`:`flex-1`),children:t})]}),(0,Z.jsx)(zM,{accessibleLabel:i,closeTab:l,isPinned:d,tabId:e,unpinTab:v})]})},e)}let f=s.docName,m=b.get(f)?.docExt??`.md`,{baseName:_,extension:x,label:C,prefix:k}=NM(f,m),j=`${k}${C}`,M=S?.tabId===e,N=`editor-tab-rename-error-${PM(f)}`;return(0,Z.jsx)(RM,{disabled:M,tabId:e,openTabs:y,closeTab:l,closeTabs:I,pinTab:h,pinnedTabIds:g,unpinTab:v,children:(0,Z.jsx)(`div`,{role:`presentation`,"data-active-tab":u?`true`:void 0,className:Y(DM,u?OM:kM,M&&E&&`border-destructive`,ee&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!d&&l(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:M?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(bM,{className:`h-full min-w-0 flex-1 rounded-none border-0 bg-transparent dark:bg-transparent`,children:[(0,Z.jsx)(TM,{ref:A,value:w,disabled:O,"aria-label":`Rename ${C}`,"aria-invalid":E?!0:void 0,"aria-describedby":E?N:void 0,"aria-busy":O||void 0,title:E??f,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=>{T(LM(e.target.value,m)),D(null),P.current=null},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),i()):e.key===`Escape`&&(e.preventDefault(),n())},onBlur:i}),(0,Z.jsx)(SM,{align:`inline-end`,"aria-hidden":`true`,className:`pr-2 text-xs`,children:(0,Z.jsx)(wM,{className:`text-muted-foreground/60 text-xs`,children:m})})]}),E?(0,Z.jsx)(`span`,{id:N,role:`alert`,className:`sr-only`,children:E}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":j,className:AM,onClick:()=>{a(e)},onDoubleClick:n=>{n.preventDefault(),n.stopPropagation(),t(e,f)},children:[k&&(0,Z.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate text-muted-foreground/60`,u&&`text-muted-foreground`),children:k}),(0,Z.jsxs)(`span`,{className:Y(`flex min-w-0 items-center`,k?`max-w-[70%] shrink-0`:`flex-1`),children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:_}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:x})]})]}),(0,Z.jsx)(zM,{accessibleLabel:j,closeTab:l,isPinned:d,tabId:e,unpinTab:v})]})})},e)}),e[23]=o,e[24]=a,e[25]=r,e[26]=L,e[27]=s,e[28]=c,e[29]=l,e[30]=u,e[31]=O,e[32]=f,e[33]=b,e[34]=h,e[35]=g,e[36]=_,e[37]=E,e[38]=w,e[39]=S?.docName,e[40]=S?.tabId,e[41]=v,e[42]=y,e[43]=ee,e[44]=te,e[45]=ne,e[46]=re,e[47]=ie}else ee=e[43],te=e[44],ne=e[45],re=e[46],ie=e[47];let ae;e[55]===Symbol.for(`react.memo_cache_sentinel`)?(ae=Y(`first:mb-3 mb-1.5`,ee&&`[-webkit-app-region:no-drag]`),e[55]=ae):ae=e[55];let oe;e[56]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,Z.jsx)(Fi,{"aria-hidden":`true`}),e[56]=oe):oe=e[56];let se;e[57]===p?se=e[58]:(se=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{type:`button`,size:`icon-xs`,variant:`ghost`,"aria-label":`New tab`,className:ae,onClick:p,children:oe})}),e[57]=p,e[58]=se);let ce;e[59]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Z.jsx)(co,{children:`New tab`}),e[59]=ce):ce=e[59];let le;e[60]===se?le=e[61]:(le=(0,Z.jsxs)(uo,{children:[se,ce]}),e[60]=se,e[61]=le);let ue;return e[62]!==te||e[63]!==ne||e[64]!==re||e[65]!==ie||e[66]!==le?(ue=(0,Z.jsxs)(`div`,{ref:te,className:ne,onWheel:re,children:[ie,le]}),e[62]=te,e[63]=ne,e[64]=re,e[65]=ie,e[66]=le,e[67]=ue):ue=e[67],ue}function VM(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 HM(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 UM=[{label:`Documentation`,href:`https://openknowledge.ai/docs`,icon:j},{label:`GitHub`,href:`https://github.com/inkeep/open-knowledge`,icon:Du},{label:`Website`,href:`https://openknowledge.ai/`,icon:ja},{label:`Discord`,href:`https://go.inkeep.com/ok-discord`,icon:VM},{label:`Twitter`,href:`https://x.com/inkeep`,icon:HM}],WM=()=>{let e=(0,$.c)(5),[t,n]=(0,Q.useState)(!1),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(ie,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[(0,Z.jsx)(I,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Resources`})]})})}),(0,Z.jsx)(co,{children:`Resources`})]}),e[0]=r):r=e[0];let i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs mb-1`,children:`Resources`}),e[1]=i):i=e[1];let a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsxs)(ae,{align:`end`,className:`w-64 p-3`,children:[i,(0,Z.jsx)(`nav`,{"aria-label":`Resources`,children:(0,Z.jsx)(`ul`,{className:`space-y-0.5`,children:UM.map(GM)})})]}),e[2]=a):a=e[2];let o;return e[3]===t?o=e[4]:(o=(0,Z.jsxs)(E,{open:t,onOpenChange:n,children:[r,a]}),e[3]=t,e[4]=o),o};function GM(e){let{label:t,href:n,icon:r}=e;return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>pi(e,n),onAuxClick:e=>pi(e,n),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)(r,{"aria-hidden":`true`,className:`size-4 shrink-0`}),t]})},n)}function KM(e){let t=(0,$.c)(70),{input:n}=e,{states:r,refresh:i}=Wp(),{dispatch:a}=Np(),{skillInstalled:o,refresh:s}=la(),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),f=typeof window<`u`&&window.okDesktop!=null,p;t[0]===i?p=t[1]:(p=e=>{l(e),e&&i()},t[0]=i,t[1]=p);let m=p,h=n===null,g;t[2]===n?g=t[3]:(g=n!==null&&n.docContext!==null?tr(n.docContext):``,t[2]=n,t[3]=g);let _=g,y;t[4]!==a||t[5]!==n?(y=e=>{n!==null&&a(e.id,n)},t[4]=a,t[5]=n,t[6]=y):y=t[6];let b=y,x,S,C,w,T,E,D,O,k,A,j,M;if(t[7]!==m||t[8]!==b||t[9]!==n||t[10]!==c||t[11]!==_||t[12]!==o||t[13]!==r||t[14]!==h){let e;t[27]===r?e=t[28]:(e=e=>r[e.id]?.installed===!0,t[27]=r,t[28]=e);let i=zf.filter(e);C=r[`claude-cowork`]?.installed===!0;let a;t[29]!==n||t[30]!==_?(a=()=>{n!==null&&tb(_)},t[29]=n,t[30]=_,t[31]=a):a=t[31],w=a,S=ji,M=c,T=m;let s;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(ii,{className:`size-4`}),t[32]=s):s=t[32];let l;t[33]===h?l=t[34]:(l=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(Si,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit with AI`,disabled:h,className:`text-muted-foreground`,"data-testid":`open-in-agent-trigger`,children:s})})}),t[33]=h,t[34]=l);let u;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(co,{children:`Edit with AI`}),t[35]=u):u=t[35],t[36]===l?E=t[37]:(E=(0,Z.jsxs)(uo,{children:[l,u]}),t[36]=l,t[37]=E),x=Aa,D=`end`,O=`min-w-[220px]`,k=`open-in-agent-menu`,t[38]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(Li,{className:`font-mono font-normal tracking-wide uppercase text-muted-foreground text-xs`,children:`Open in`}),t[38]=A):A=t[38];let p;t[39]!==b||t[40]!==_||t[41]!==o||t[42]!==r?(p=e=>{let t=r[e.id];return(0,Z.jsx)(rb,{target:e,installState:t,isElectronHost:f,prompt:_,onSelect:()=>b(e),onInstallSkillRequest:e.id===`claude-cowork`&&!o?()=>d(!0):void 0},e.id)},t[39]=b,t[40]=_,t[41]=o,t[42]=r,t[43]=p):p=t[43],j=i.map(p),t[7]=m,t[8]=b,t[9]=n,t[10]=c,t[11]=_,t[12]=o,t[13]=r,t[14]=h,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]=k,t[24]=A,t[25]=j,t[26]=M}else x=t[15],S=t[16],C=t[17],w=t[18],T=t[19],E=t[20],D=t[21],O=t[22],k=t[23],A=t[24],j=t[25],M=t[26];let N;t[44]!==C||t[45]!==w||t[46]!==n?(N=C?null:(0,Z.jsxs)(di,{onSelect:w,disabled:n===null,"data-testid":`open-in-agent-claude-web-fallback`,"aria-label":`Open in claude.ai, opens in browser with prompt pre-filled`,children:[(0,Z.jsx)(v,{className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:`Open in claude.ai →`}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`opens in browser`})]}),t[44]=C,t[45]=w,t[46]=n,t[47]=N):N=t[47];let P;t[48]!==x||t[49]!==N||t[50]!==D||t[51]!==O||t[52]!==k||t[53]!==A||t[54]!==j?(P=(0,Z.jsxs)(x,{align:D,className:O,"data-testid":k,children:[A,j,N]}),t[48]=x,t[49]=N,t[50]=D,t[51]=O,t[52]=k,t[53]=A,t[54]=j,t[55]=P):P=t[55];let F;t[56]!==S||t[57]!==T||t[58]!==E||t[59]!==P||t[60]!==M?(F=(0,Z.jsxs)(S,{open:M,onOpenChange:T,children:[E,P]}),t[56]=S,t[57]=T,t[58]=E,t[59]=P,t[60]=M,t[61]=F):F=t[61];let I;t[62]===s?I=t[63]:(I=e=>{d(e),e||s()},t[62]=s,t[63]=I);let L;t[64]!==u||t[65]!==I?(L=(0,Z.jsx)(ta,{open:u,onOpenChange:I}),t[64]=u,t[65]=I,t[66]=L):L=t[66];let R;return t[67]!==F||t[68]!==L?(R=(0,Z.jsxs)(Z.Fragment,{children:[F,L]}),t[67]=F,t[68]=L,t[69]=R):R=t[69],R}var qM=()=>{let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,"data-testid":`header-settings-button`,onClick:JM,children:[(0,Z.jsx)(rc,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Settings`})]})}),(0,Z.jsx)(co,{children:`Settings`})]}),e[0]=t):t=e[0],t};function JM(){window.location.hash!==`#settings`&&(window.location.hash=Bf)}function YM(e){if(!e)return`never`;let t=Date.now()-new Date(e).getTime();return t<6e4?`just now`:t<36e5?`${Math.floor(t/6e4)} min ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:new Date(e).toLocaleDateString()}async function XM(e){await fetch(`/api/sync/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({op:e})})}function ZM(e){let t=(0,$.c)(9),{status:n}=e;switch(n.state){case`dormant`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ps,{className:`size-3.5 text-muted-foreground`}),t[0]=e):e=t[0],e}case`idle`:{if(n.ahead>0||n.behind>0){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ec,{className:`size-3.5 text-muted-foreground`}),t[1]=e):e=t[1],e}let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ps,{className:`size-3.5 text-emerald-500`}),t[2]=e):e=t[2],e}case`fetching`:case`pulling`:case`pushing`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ec,{className:`size-3.5 text-muted-foreground animate-spin`}),t[3]=e):e=t[3],e}case`conflict`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Dn,{className:`size-3.5 text-amber-500`}),t[4]=e):e=t[4],e}case`offline`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(fs,{className:`size-3.5 text-muted-foreground`}),t[5]=e):e=t[5],e}case`auth-error`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Us,{className:`size-3.5 text-destructive`}),t[6]=e):e=t[6],e}case`disabled`:{let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Dn,{className:`size-3.5 text-amber-500`}),t[7]=e):e=t[7],e}default:{let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ps,{className:`size-3.5 text-muted-foreground`}),t[8]=e):e=t[8],e}}}function QM(e){switch(e.state){case`idle`:return e.ahead>0?`↑${e.ahead}`:e.behind>0?`↓${e.behind}`:``;case`fetching`:case`pulling`:case`pushing`:return``;case`conflict`:return e.conflictCount>0?`${e.conflictCount}`:``;case`offline`:return``;case`auth-error`:return``;default:return``}}function $M(e){switch(e){case`dormant`:return`No git remote`;case`idle`:return`Synced`;case`fetching`:return`Fetching`;case`pulling`:return`Pulling`;case`pushing`:return`Pushing`;case`conflict`:return`Conflict`;case`offline`:return`Offline`;case`auth-error`:return`Sign in required`;case`disabled`:return`Sync disabled`;default:return e}}function eN(e){switch(e){case`external-changes-pending`:return`External changes pending`;case`dirty-tree`:return`Working tree has uncommitted changes`;case`detached-head`:return`Detached HEAD — checkout a branch to resume`;case`auth-error`:return`Sign in required`;case`protected-branch`:return`Protected branch — cannot push`;default:return e}}function tN(e){return e.syncEnabled?e.state===`idle`?e.ahead>0&&e.behind>0?`${e.ahead} ahead, ${e.behind} behind`:e.ahead>0?`${e.ahead} ahead`:e.behind>0?`${e.behind} behind`:`Synced`:e.state===`conflict`&&e.conflictCount>0?`${e.conflictCount} conflict${e.conflictCount===1?``:`s`}`:$M(e.state):`Sync off`}function nN(e){let t=(0,$.c)(76),{status:n,onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a}=e,{projectLocalConfig:o,projectLocalSynced:s}=ba(),c=o?.autoSync?.enabled??!1,{confirmOpen:l,setConfirmOpen:u,onToggleRequest:d,onConfirm:f}=zi(Vi()),p;t[0]===n?p=t[1]:(p=(0,Z.jsx)(ZM,{status:n}),t[0]=n,t[1]=p);let m;t[2]===n.state?m=t[3]:(m=$M(n.state),t[2]=n.state,t[3]=m);let h;t[4]===m?h=t[5]:(h=(0,Z.jsx)(`span`,{className:`text-sm font-medium truncate`,children:m}),t[4]=m,t[5]=h);let g;t[6]!==p||t[7]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[p,h]}),t[6]=p,t[7]=h,t[8]=g):g=t[8];let _=!s,v=c?`Disable sync`:`Enable sync`,y;t[9]!==c||t[10]!==d||t[11]!==_||t[12]!==v?(y=(0,Z.jsx)(Fe,{checked:c,disabled:_,onCheckedChange:d,"aria-label":v}),t[9]=c,t[10]=d,t[11]=_,t[12]=v,t[13]=y):y=t[13];let b;t[14]!==g||t[15]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[g,y]}),t[14]=g,t[15]=y,t[16]=b):b=t[16];let x;t[17]!==l||t[18]!==f||t[19]!==u?(x=(0,Z.jsx)(pa,{open:l,onOpenChange:u,onConfirm:f}),t[17]=l,t[18]=f,t[19]=u,t[20]=x):x=t[20];let S;t[21]===n.error?S=t[22]:(S=n.error&&(0,Z.jsx)(`p`,{className:`text-xs text-destructive`,children:n.error}),t[21]=n.error,t[22]=S);let C;t[23]===n.pausedReason?C=t[24]:(C=n.pausedReason&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:eN(n.pausedReason)}),t[23]=n.pausedReason,t[24]=C);let w;t[25]===n.state?w=t[26]:(w=n.state===`conflict`&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-400`,children:`Sync paused — resolve conflicts to resume.`}),t[25]=n.state,t[26]=w);let T;t[27]!==c||t[28]!==n.lastSyncUtc||t[29]!==n.state?(T=c&&n.state!==`dormant`&&(0,Z.jsxs)(`div`,{children:[`Last synced: `,YM(n.lastSyncUtc)]}),t[27]=c,t[28]=n.lastSyncUtc,t[29]=n.state,t[30]=T):T=t[30];let E;t[31]===n.ahead?E=t[32]:(E=n.ahead>0&&(0,Z.jsxs)(`div`,{children:[n.ahead,` commit`,n.ahead===1?``:`s`,` ahead`]}),t[31]=n.ahead,t[32]=E);let D;t[33]===n.behind?D=t[34]:(D=n.behind>0&&(0,Z.jsxs)(`div`,{children:[n.behind,` commit`,n.behind===1?``:`s`,` behind`]}),t[33]=n.behind,t[34]=D);let O;t[35]===n.conflictCount?O=t[36]:(O=n.conflictCount>0&&(0,Z.jsxs)(`div`,{children:[n.conflictCount,` file`,n.conflictCount===1?``:`s`,` conflicted`]}),t[35]=n.conflictCount,t[36]=O);let k;t[37]===c?k=t[38]:(k=!c&&(0,Z.jsx)(`div`,{children:`Sync is off — your edits will not sync to the remote repository.`}),t[37]=c,t[38]=k);let A;t[39]!==T||t[40]!==E||t[41]!==D||t[42]!==O||t[43]!==k?(A=(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-0.5`,children:[T,E,D,O,k]}),t[39]=T,t[40]=E,t[41]=D,t[42]=O,t[43]=k,t[44]=A):A=t[44];let j;t[45]!==a||t[46]!==n.identityUnresolved?(j=n.identityUnresolved&&a&&(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed p-2`,children:[(0,Z.jsx)(vc,{className:`size-3.5 mt-0.5 text-muted-foreground shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground leading-snug`,children:`Git identity isn't set — commits use a default author. Set yours so teammates see your name.`}),(0,Z.jsx)(X,{variant:`outline`,size:`xs`,className:`self-start`,onClick:a,children:`Set identity`})]})]}),t[45]=a,t[46]=n.identityUnresolved,t[47]=j):j=t[47];let M;t[48]!==c||t[49]!==n.state?(M=c&&n.state!==`dormant`&&n.state!==`disabled`&&n.state!==`auth-error`&&n.state!==`conflict`&&(0,Z.jsx)(X,{variant:`outline`,size:`xs`,onClick:iN,children:`Sync now`}),t[48]=c,t[49]=n.state,t[50]=M):M=t[50];let N;t[51]!==c||t[52]!==r||t[53]!==n.state?(N=c&&n.state===`auth-error`&&(0,Z.jsx)(X,{variant:`outline`,size:`xs`,onClick:r,children:`Sign in`}),t[51]=c,t[52]=r,t[53]=n.state,t[54]=N):N=t[54];let P;t[55]!==c||t[56]!==n.state?(P=c&&n.state===`offline`&&(0,Z.jsx)(X,{variant:`outline`,size:`xs`,onClick:rN,children:`Retry`}),t[55]=c,t[56]=n.state,t[57]=P):P=t[57];let F;t[58]!==c||t[59]!==i||t[60]!==n.state?(F=c&&n.state===`conflict`&&i&&(0,Z.jsx)(X,{variant:`outline`,size:`xs`,onClick:i,children:`Review conflicts`}),t[58]=c,t[59]=i,t[60]=n.state,t[61]=F):F=t[61];let I;t[62]!==M||t[63]!==N||t[64]!==P||t[65]!==F?(I=(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1 pt-1`,children:[M,N,P,F]}),t[62]=M,t[63]=N,t[64]=P,t[65]=F,t[66]=I):I=t[66];let L;return t[67]!==S||t[68]!==C||t[69]!==w||t[70]!==A||t[71]!==j||t[72]!==I||t[73]!==b||t[74]!==x?(L=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[b,x,S,C,w,A,j,I]}),t[67]=S,t[68]=C,t[69]=w,t[70]=A,t[71]=j,t[72]=I,t[73]=b,t[74]=x,t[75]=L):L=t[75],L}function rN(){XM(`sync`)}function iN(){XM(`sync`)}function aN(e){let t=(0,$.c)(36),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a}=n,{status:o,fetchError:s}=_a();if(!o){if(s){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":`Sync status unavailable`,disabled:!0,children:(0,Z.jsx)(fs,{className:`size-3.5`})})}),t[2]=e):e=t[2];let n=s===`network`?`Sync status unavailable — server unreachable.`:`Sync status unavailable — server error.`,r;return t[3]===n?r=t[4]:(r=(0,Z.jsxs)(uo,{children:[e,(0,Z.jsx)(co,{children:n})]}),t[3]=n,t[4]=r),r}return null}if(o.state===`dormant`&&!o.hasRemote||o.state===`disabled`&&!o.pausedReason)return null;let c;t[5]===o?c=t[6]:(c=QM(o),t[5]=o,t[6]=c);let l=c,u=!!o.identityUnresolved,d;t[7]===o.state?d=t[8]:(d=$M(o.state),t[7]=o.state,t[8]=d);let f=`Sync status: ${d}${u?` — git identity unset`:``}`,p;t[9]===o?p=t[10]:(p=(0,Z.jsx)(ZM,{status:o}),t[9]=o,t[10]=p);let m;t[11]===l?m=t[12]:(m=l&&(0,Z.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 text-[9px] leading-none font-medium bg-background border rounded-full px-0.5`,children:l}),t[11]=l,t[12]=m);let h;t[13]!==l||t[14]!==u?(h=!l&&u&&(0,Z.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 size-1.5 rounded-full bg-amber-500 ring-2 ring-background`,"aria-hidden":!0}),t[13]=l,t[14]=u,t[15]=h):h=t[15];let g;t[16]!==f||t[17]!==p||t[18]!==m||t[19]!==h?(g=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(ie,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground relative`,"aria-label":f,children:[p,m,h]})})}),t[16]=f,t[17]=p,t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;t[21]===o?_=t[22]:(_=tN(o),t[21]=o,t[22]=_);let v;t[23]===_?v=t[24]:(v=(0,Z.jsx)(co,{children:_}),t[23]=_,t[24]=v);let y;t[25]!==v||t[26]!==g?(y=(0,Z.jsxs)(uo,{children:[g,v]}),t[25]=v,t[26]=g,t[27]=y):y=t[27];let b;t[28]!==i||t[29]!==a||t[30]!==r||t[31]!==o?(b=(0,Z.jsx)(ae,{align:`end`,className:`w-64 p-3`,children:(0,Z.jsx)(nN,{status:o,onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a})}),t[28]=i,t[29]=a,t[30]=r,t[31]=o,t[32]=b):b=t[32];let x;return t[33]!==y||t[34]!==b?(x=(0,Z.jsxs)(E,{children:[y,b]}),t[33]=y,t[34]=b,t[35]=x):x=t[35],x}var oN=[{value:`light`,label:`Light`,icon:fc},{value:`dark`,label:`Dark`,icon:Ws},{value:`system`,label:`System`,icon:vs}],sN=()=>{let e=(0,$.c)(16),{theme:t}=yr(),{merged:n,userBinding:r}=ba(),i=n?.appearance?.theme??t??`system`,a;e[0]===r?a=e[1]:(a=e=>{if(e!==`light`&&e!==`dark`&&e!==`system`||!r)return;let t=r.patch({appearance:{theme:e}});t.ok||Xa.error(wn(t.error))},e[0]=r,e[1]=a);let o=a,s=i===`system`?vs:i===`dark`?Ws:fc,c;e[2]===s?c=e[3]:(c=(0,Z.jsx)(s,{}),e[2]=s,e[3]=c);let l;e[4]===i?l=e[5]:(l=(0,Z.jsxs)(`span`,{className:`sr-only`,children:[`Toggle theme (current: `,i,`)`]}),e[4]=i,e[5]=l);let u;e[6]!==c||e[7]!==l?(u=(0,Z.jsx)(Si,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[c,l]})}),e[6]=c,e[7]=l,e[8]=u):u=e[8];let d;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=oN.map(cN),e[9]=d):d=e[9];let f;e[10]!==i||e[11]!==o?(f=(0,Z.jsx)(Aa,{align:`end`,children:(0,Z.jsx)(bi,{value:i,onValueChange:o,children:d})}),e[10]=i,e[11]=o,e[12]=f):f=e[12];let p;return e[13]!==u||e[14]!==f?(p=(0,Z.jsxs)(ji,{children:[u,f]}),e[13]=u,e[14]=f,e[15]=p):p=e[15],p};function cN(e){let{value:t,label:n,icon:r}=e;return(0,Z.jsxs)(Ii,{value:t,className:`capitalize`,children:[(0,Z.jsx)(r,{className:`text-muted-foreground`}),n]},t)}function lN(e){let t=(0,$.c)(38),{onSaveVersion:n,saving:r,onSignIn:i,onSetIdentity:a,onOpenConflictResolver:o}=e,{activeDocName:s}=We(),{state:c}=Tj(),l=qf(),u;t[0]!==s||t[1]!==l?(u=Sp({docName:s,workspace:l}),t[0]=s,t[1]=l,t[2]=u):u=t[2];let d=u,f=typeof window<`u`&&window.okDesktop!=null,p=f&&c===`collapsed`&&`pl-[78px]`,m;t[3]===p?m=t[4]:(m=Y(`flex h-12 shrink-0 items-center bg-muted/35 shadow-[inset_0_-1px_0_var(--border)]`,f&&`[-webkit-app-region:drag]`,p,f&&`motion-safe:transition-[padding] motion-safe:duration-200 motion-safe:ease-linear`),t[3]=p,t[4]=m);let h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(Aj,{className:Y(`-ml-1 shrink-0 text-muted-foreground`,f&&`[-webkit-app-region:no-drag]`)})}),t[5]=h):h=t[5];let g=c===`expanded`?`Hide Files`:`Show Files`,_;t[6]===g?_=t[7]:(_=(0,Z.jsxs)(uo,{children:[h,(0,Z.jsx)(co,{children:g})]}),t[6]=g,t[7]=_);let v,y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(Bi,{orientation:`vertical`,className:`mr-1 h-4 shrink-0 data-vertical:self-center`}),y=(0,Z.jsx)(BM,{}),t[8]=v,t[9]=y):(v=t[8],y=t[9]);let b;t[10]===_?b=t[11]:(b=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 px-3`,children:[_,v,y]}),t[10]=_,t[11]=b);let x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(x=Y(`flex shrink-0 items-center justify-end gap-2 px-3`,f&&`[&>*]:[-webkit-app-region:no-drag]`),t[12]=x):x=t[12];let S;t[13]!==s||t[14]!==n||t[15]!==r?(S=s&&(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":`Checkpoint version`,onClick:n,disabled:r,className:`text-muted-foreground`,children:(0,Z.jsx)(nc,{className:`size-3.5`})})}),(0,Z.jsx)(co,{children:r?`Saving`:`Checkpoint version`})]}),t[13]=s,t[14]=n,t[15]=r,t[16]=S):S=t[16];let C;t[17]!==s||t[18]!==d?(C=s&&(0,Z.jsx)(KM,{input:d}),t[17]=s,t[18]=d,t[19]=C):C=t[19];let w;t[20]!==o||t[21]!==a||t[22]!==i?(w=(0,Z.jsx)(aN,{onSignIn:i,onSetIdentity:a,onOpenConflictResolver:o}),t[20]=o,t[21]=a,t[22]=i,t[23]=w):w=t[23];let T,E,D,O,k,A;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(oM,{}),E=(0,Z.jsx)(Bi,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),D=(0,Z.jsx)(cu,{}),O=(0,Z.jsx)(qM,{}),k=(0,Z.jsx)(WM,{}),A=(0,Z.jsx)(sN,{}),t[24]=T,t[25]=E,t[26]=D,t[27]=O,t[28]=k,t[29]=A):(T=t[24],E=t[25],D=t[26],O=t[27],k=t[28],A=t[29]);let j;t[30]!==S||t[31]!==C||t[32]!==w?(j=(0,Z.jsxs)(`div`,{className:x,children:[S,C,w,T,E,D,O,k,A]}),t[30]=S,t[31]=C,t[32]=w,t[33]=j):j=t[33];let M;return t[34]!==j||t[35]!==m||t[36]!==b?(M=(0,Z.jsxs)(`header`,{className:m,children:[b,j]}),t[34]=j,t[35]=m,t[36]=b,t[37]=M):M=t[37],M}function uN(){let e=(0,$.c)(32),[t,n]=bm(),[r,i]=(0,Q.useState)(t),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(`auth`),[d,f]=(0,Q.useState)(G_[0].id),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),_=da(),{projectLocalConfig:v,projectLocalSynced:y}=ba(),{activeDocName:b}=We(),x=!h&&_?.hasRemote===!0&&y===!0&&v!==null&&v.autoSync?.enabled===null,S,C;e[0]===b?(S=e[1],C=e[2]):(S=()=>{let e=function(e){let t=e.detail;t&&b&&Lo(b,{kind:`raw-mdx`,detail:t}),i(`source`)};return window.addEventListener(fm,e),()=>window.removeEventListener(fm,e)},C=[b],e[0]=b,e[1]=S,e[2]=C),(0,Q.useEffect)(S,C);let w;e[3]===n?w=e[4]:(w=function(e){i(e),n(e)},e[3]=n,e[4]=w);let T=w,E;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(E=async function(){m(!0);try{let e=await fetch(`/api/save-version`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});e.ok?Xa.success(`Checkpoint saved`):(console.error(`[save-version] failed:`,await e.text()),Xa.error(`Checkpoint failed — try again`))}catch(e){console.error(`[save-version] failed:`,e),Xa.error(`Checkpoint failed — try again`)}m(!1)},e[5]=E):E=e[5];let D=E,O;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(Cm,{onOpenResolver:()=>o(!0)}),e[6]=O):O=e[6];let k,A,j;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>{u(`auth`),c(!0)},A=()=>{u(`identity`),c(!0)},j=()=>o(!0),e[7]=k,e[8]=A,e[9]=j):(k=e[7],A=e[8],j=e[9]);let M;e[10]===p?M=e[11]:(M=(0,Z.jsx)(lN,{onSaveVersion:D,saving:p,onSignIn:k,onSetIdentity:A,onOpenConflictResolver:j}),e[10]=p,e[11]=M);let N;e[12]!==d||e[13]!==r||e[14]!==T?(N=(0,Z.jsx)(ej,{editorMode:r,onModeChange:T,activeTab:d,onActiveTabChange:f}),e[12]=d,e[13]=r,e[14]=T,e[15]=N):N=e[15];let P;e[16]===a?P=e[17]:(P=(0,Z.jsx)(Tg,{open:a,onOpenChange:o}),e[16]=a,e[17]=P);let F=l===`identity`,I;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>{c(!1)},e[18]=I):I=e[18];let L;e[19]!==s||e[20]!==F?(L=(0,Z.jsx)(ou,{open:s,onOpenChange:c,identityPrompt:F,onSuccess:I}),e[19]=s,e[20]=F,e[21]=L):L=e[21];let R;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>g(!0),e[22]=R):R=e[22];let z;e[23]===x?z=e[24]:(z=(0,Z.jsx)(xm,{open:x,onResolved:R}),e[23]=x,e[24]=z);let B;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Z.jsx)(lm,{}),e[25]=B):B=e[25];let V;return e[26]!==P||e[27]!==L||e[28]!==z||e[29]!==M||e[30]!==N?(V=(0,Z.jsxs)(Z.Fragment,{children:[O,M,N,P,L,z,B]}),e[26]=P,e[27]=L,e[28]=z,e[29]=M,e[30]=N,e[31]=V):V=e[31],V}var dN=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
35
35
|
<symbol id="file-tree-icon-chevron" viewBox="0 0 16 16">
|
|
36
36
|
<path d="M3.47 5.47a.75.75 0 0 1 1.06 0L8 8.94l3.47-3.47a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 0 1 0-1.06" fill="currentcolor"/>
|
|
37
37
|
</symbol>
|