@inkeep/open-knowledge 0.25.0-beta.21 → 0.25.0-beta.22

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.
@@ -26,7 +26,7 @@ Error generating stack: `+e.message+`
26
26
  `).trim();return i.length===0||i.length>qC||i.includes(`
27
27
  `)?null:i}function QC(e){let t=Ze(e.state);return{current:t.matches.length===0?0:t.activeIndex+1,total:t.matches.length}}function $C(e,t){return e.current===t.current&&e.total===t.total}function ew(e,t,n){e&&!e.isDestroyed&&(e.commands.clearFindMatches(),e.commands.focus()),t(e=>({...e,open:!1,activeIndex:0})),n(KC)}function tw(e){!e||e.isDestroyed||typeof window>`u`||window.requestAnimationFrame(()=>{if(e.isDestroyed)return;let t=he(e);if(!t)return;let n=t.dom.querySelector(`.ok-find-match-active`);n instanceof HTMLElement&&n.scrollIntoView({block:`center`,inline:`nearest`,behavior:`auto`})})}function nw(e){let t=(0,$.c)(81),{activeDocName:n,isSourceMode:r}=e,i=YC(n),a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),s=(0,Q.useRef)(n),c=(0,Q.useRef)(0),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l={open:!1,replaceOpen:!1,query:``,replacement:``,caseSensitive:!1,wholeWord:!1,activeIndex:0},t[0]=l):l=t[0];let[u,d]=(0,Q.useState)(l),[f,p]=(0,Q.useState)(KC),m,h;t[1]===n?(m=t[2],h=t[3]):(m=()=>{s.current!==n&&(s.current=n,d(iw))},h=[n],t[1]=n,t[2]=m,t[3]=h),(0,Q.useEffect)(m,h);let g,_;t[4]===u.activeIndex?(g=t[5],_=t[6]):(g=()=>{c.current=u.activeIndex},_=[u.activeIndex],t[4]=u.activeIndex,t[5]=g,t[6]=_),(0,Q.useEffect)(g,_);let v,y;t[7]===i?(v=t[8],y=t[9]):(v=()=>{let e=o.current;e&&e!==i&&!e.isDestroyed&&e.commands.clearFindMatches(),o.current=i},y=[i],t[7]=i,t[8]=v,t[9]=y),(0,Q.useEffect)(v,y);let b,x;t[10]===u.open?(b=t[11],x=t[12]):(b=()=>{if(!u.open||!a.current)return;let e=requestAnimationFrame(()=>{a.current?.focus(),a.current?.select()});return()=>cancelAnimationFrame(e)},x=[u.open],t[10]=u.open,t[11]=b,t[12]=x),(0,Q.useEffect)(b,x);let S,C;t[13]!==u.open||t[14]!==r?(S=()=>{!u.open||!r||d(rw)},C=[u.open,r],t[13]=u.open,t[14]=r,t[15]=S,t[16]=C):(S=t[15],C=t[16]),(0,Q.useEffect)(S,C);let w,T;t[17]!==i||t[18]!==u.caseSensitive||t[19]!==u.open||t[20]!==u.query||t[21]!==u.wholeWord||t[22]!==r?(w=()=>{if(!i||i.isDestroyed){p(KC);return}if(!u.open||r){i.commands.clearFindMatches(),p(KC);return}let e=window.setTimeout(()=>{if(i.isDestroyed)return;i.commands.setFindQuery(u.query,{options:{caseSensitive:u.caseSensitive,wholeWord:u.wholeWord},activeIndex:c.current});let e=QC(i);p(t=>$C(t,e)?t:e)},JC);return()=>window.clearTimeout(e)},T=[i,u.open,u.query,u.caseSensitive,u.wholeWord,r],t[17]=i,t[18]=u.caseSensitive,t[19]=u.open,t[20]=u.query,t[21]=u.wholeWord,t[22]=r,t[23]=w,t[24]=T):(w=t[23],T=t[24]),(0,Q.useEffect)(w,T);let E,D;t[25]!==i||t[26]!==u.open||t[27]!==r?(E=()=>{if(!i||i.isDestroyed||!u.open||r)return;let e=()=>{let e=Ze(i.state),t=QC(i);p(e=>$C(e,t)?e:t),d(t=>t.activeIndex===e.activeIndex?t:{...t,activeIndex:e.activeIndex})};return i.on(`transaction`,e),()=>{i.off(`transaction`,e)}},D=[i,u.open,r],t[25]=i,t[26]=u.open,t[27]=r,t[28]=E,t[29]=D):(E=t[28],D=t[29]),(0,Q.useEffect)(E,D);let O,k;t[30]!==n||t[31]!==i||t[32]!==u.open||t[33]!==r?(O=()=>{let e=function(e){let t=ZC(i);d(n=>({...n,open:!0,replaceOpen:e,query:t??n.query,activeIndex:0}))},t=function(t){if(!(!n||r||t.defaultPrevented)){if(Al(t,`find`)){t.preventDefault(),u.open?ew(i,d,p):e(!1);return}if(Al(t,`replace`)){t.preventDefault(),e(!0);return}if(u.open){let e=Al(t,`find-next`),n=Al(t,`find-previous`);if(e||n){t.preventDefault(),(n?i?.commands.selectPreviousFindMatch():i?.commands.selectNextFindMatch())&&tw(i);return}}t.key===`Escape`&&u.open&&(t.preventDefault(),ew(i,d,p))}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},k=[n,i,u.open,r],t[30]=n,t[31]=i,t[32]=u.open,t[33]=r,t[34]=O,t[35]=k):(O=t[34],k=t[35]),(0,Q.useEffect)(O,k);let A;t[36]!==i||t[37]!==u.caseSensitive||t[38]!==u.query||t[39]!==u.wholeWord?(A=function(){return!i||i.isDestroyed?!1:(i.commands.setFindQuery(u.query,{options:{caseSensitive:u.caseSensitive,wholeWord:u.wholeWord},activeIndex:c.current}),!0)},t[36]=i,t[37]=u.caseSensitive,t[38]=u.query,t[39]=u.wholeWord,t[40]=A):A=t[40];let j=A,M;t[41]===i?M=t[42]:(M=function(){if(!i||i.isDestroyed)return;let e=Ze(i.state),t=QC(i);p(e=>$C(e,t)?e:t),d(t=>t.activeIndex===e.activeIndex?t:{...t,activeIndex:e.activeIndex})},t[41]=i,t[42]=M);let N=M,P;t[43]===i?P=t[44]:(P=function(){ew(i,d,p)},t[43]=i,t[44]=P);let F=P,I;t[45]!==j||t[46]!==i||t[47]!==N?(I=function(){!i||i.isDestroyed||(j(),i.commands.selectNextFindMatch()&&tw(i),N())},t[45]=j,t[46]=i,t[47]=N,t[48]=I):I=t[48];let L=I,R;t[49]!==j||t[50]!==i||t[51]!==N?(R=function(){!i||i.isDestroyed||(j(),i.commands.selectPreviousFindMatch()&&tw(i),N())},t[49]=j,t[50]=i,t[51]=N,t[52]=R):R=t[52];let z=R,B;t[53]!==j||t[54]!==i||t[55]!==u.replacement||t[56]!==N?(B=function(){!i||i.isDestroyed||(j(),i.commands.replaceCurrentFindMatch(u.replacement)&&tw(i),N())},t[53]=j,t[54]=i,t[55]=u.replacement,t[56]=N,t[57]=B):B=t[57];let V=B,H;t[58]!==j||t[59]!==i||t[60]!==u.replacement||t[61]!==N?(H=function(){!i||i.isDestroyed||(j(),i.commands.replaceAllFindMatches(u.replacement)&&tw(i),N())},t[58]=j,t[59]=i,t[60]=u.replacement,t[61]=N,t[62]=H):H=t[62];let U=H;if(!u.open||!n||r)return null;let W,G,K,ee,te;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>d(t=>({...t,query:e,activeIndex:0})),G=e=>d(t=>({...t,replacement:e})),K=e=>d(t=>({...t,replaceOpen:e})),ee=e=>d(t=>({...t,caseSensitive:e})),te=e=>d(t=>({...t,wholeWord:e})),t[63]=W,t[64]=G,t[65]=K,t[66]=ee,t[67]=te):(W=t[63],G=t[64],K=t[65],ee=t[66],te=t[67]);let ne;return t[68]!==F||t[69]!==u.caseSensitive||t[70]!==u.query||t[71]!==u.replaceOpen||t[72]!==u.replacement||t[73]!==u.wholeWord||t[74]!==f.current||t[75]!==f.total||t[76]!==U||t[77]!==V||t[78]!==L||t[79]!==z?(ne=(0,Z.jsx)(`div`,{className:`editor-content-aligned pointer-events-none absolute inset-x-0 top-2 z-30 px-2`,children:(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(GC,{findInputRef:a,query:u.query,replacement:u.replacement,replaceOpen:u.replaceOpen,caseSensitive:u.caseSensitive,wholeWord:u.wholeWord,current:f.current,total:f.total,onQueryChange:W,onReplacementChange:G,onReplaceOpenChange:K,onCaseSensitiveChange:ee,onWholeWordChange:te,onNext:L,onPrevious:z,onReplaceCurrent:V,onReplaceAll:U,onClose:F})})}),t[68]=F,t[69]=u.caseSensitive,t[70]=u.query,t[71]=u.replaceOpen,t[72]=u.replacement,t[73]=u.wholeWord,t[74]=f.current,t[75]=f.total,t[76]=U,t[77]=V,t[78]=L,t[79]=z,t[80]=ne):ne=t[80],ne}function rw(e){return{...e,open:!1,activeIndex:0}}function iw(e){return{...e,activeIndex:0}}var aw=300;function ow(e,t){let n=(0,$.c)(4),[r,i]=(0,Q.useState)($l),a,o;return n[0]!==t||n[1]!==e?(a=()=>{if(!e||!t){i($l);return}let n=e.document.getText(`source`),r=!1,a=null,o=function(){r||i(ru(n.toString()))};o();let s=function(){a&&clearTimeout(a),a=setTimeout(o,aw)};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 sw(e){return e&&e.document.getMap(`lifecycle`).get(`status`)===`conflict`?`conflict`:null}function cw(e){let t=(0,$.c)(8),{poolEntries:n}=mt(),r;t[0]!==e||t[1]!==n?(r=e?n.find(t=>t.docName===e)??null:null,t[0]=e,t[1]=n,t[2]=r):r=t[2];let i=r?.provider??null,a;t[3]===i?a=t[4]:(a=()=>sw(i),t[3]=i,t[4]=a);let[o,s]=(0,Q.useState)(a),c,l;return t[5]===i?(c=t[6],l=t[7]):(c=()=>{if(!i){s(null);return}let e=i.document.getMap(`lifecycle`);s(sw(i));let t=()=>s(sw(i));return e.observe(t),()=>{e.unobserve(t)}},l=[i],t[5]=i,t[6]=c,t[7]=l),(0,Q.useEffect)(c,l),o}function lw(e,t){let n=(0,$.c)(3),r;return n[0]!==e||n[1]!==t?(r=()=>su(e,t),n[0]=e,n[1]=t,n[2]=r):r=n[2],(0,Q.useSyncExternalStore)(cu,r)}var uw=`ok-doc-panel-width-v1`;function dw(e){return Number.isFinite(e)?e<300?300:e>600?600:Math.round(e):320}function fw(e){try{let t=(e??localStorage).getItem(uw);if(t==null)return 320;let n=Number.parseInt(t,10);return Number.isFinite(n)?dw(n):320}catch{return 320}}function pw(e,t){try{(t??localStorage).setItem(uw,String(dw(e)))}catch{}}function mw(){try{return typeof localStorage>`u`?320:fw()}catch{return 320}}var hw=1024,gw=1280,_w={left:hw,right:gw};function vw(e,t,n){return e==null?t>=_w[n]?`above`:`below`:`embedded`}function yw(e){return e===`above`?`open`:`collapsed`}var bw=`ok-sidebar-pins-v2`;function xw(e){return e===`open`||e===`collapsed`}function Sw(e){return e===`above`||e===`below`||e===`embedded`}function Cw(e){if(typeof e!=`object`||!e)return!1;let t=e;for(let e of Object.keys(t))if(!Sw(e)||!xw(t[e]))return!1;return!0}function ww(e){let t=JSON.parse(e);if(typeof t!=`object`||!t)return{};let n=t,r={};return Cw(n.left)&&(r.left=n.left),Cw(n.right)&&(r.right=n.right),r}function Tw(e){try{let t=(e??localStorage).getItem(bw);return t==null?{}:ww(t)}catch{return{}}}function Ew(e,t){try{t.setItem(bw,JSON.stringify(e))}catch{}}function Dw(e,t,n){return n[e]?.[t]??yw(t)}function Ow(e,t,n,r){let i=r??localStorage,a=Tw(i);return a[e]={...a[e],[t]:n},Ew(a,i),a}var kw=`ok-terminal-width-v1`;function Aw(e){return Number.isFinite(e)?e<320?320:Math.round(e):480}function jw(e){try{let t=(e??localStorage).getItem(kw);if(t==null)return 480;let n=Number.parseInt(t,10);return Number.isFinite(n)?Aw(n):480}catch{return 480}}function Mw(e,t){try{(t??localStorage).setItem(kw,String(Aw(e)))}catch{}}function Nw(){try{return typeof localStorage>`u`?480:jw()}catch{return 480}}function Pw(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`?Fw: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 Fw(e){return e===`synced`?`synced`:`connected`}function Iw(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(t+1):e}function Lw(e){let t=(0,$.c)(21),{path:n,onRemove:r}=e,{_:i}=$t(),a,o;t[0]!==i||t[1]!==n?(a=Iw(n),o=i({id:`hnq8fP`,values:{label:a}}),t[0]=i,t[1]=n,t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s=o,c=`composer-context-chip-file-${n}`,l;t[4]===r?l=t[5]:(l=e=>{(e.key===`Backspace`||e.key===`Delete`)&&(e.preventDefault(),r())},t[4]=r,t[5]=l);let u;t[6]===n?u=t[7]:(u=(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 inline-flex size-3 -translate-x-1/2 -translate-y-1/2 opacity-100 transition-opacity duration-150 ease-out group-hover/chip:opacity-0 group-focus-within/chip:opacity-0 motion-reduce:transition-none`,children:(0,Z.jsx)(Vt,{path:n,className:`size-3`})}),t[6]=n,t[7]=u);let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(Cs,{className:`absolute top-1/2 left-1/2 size-3 -translate-x-1/2 -translate-y-1/2 opacity-0 transition-opacity duration-150 ease-out group-hover/chip:opacity-100 group-focus-within/chip:opacity-100 motion-reduce:transition-none`,"aria-hidden":!0}),t[8]=d):d=t[8];let f;t[9]!==r||t[10]!==s||t[11]!==l||t[12]!==u?(f=(0,Z.jsxs)(X,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s,onClick:r,onKeyDown:l,className:`group/remove relative size-3.5 shrink-0 rounded-sm text-muted-foreground/80 hover:text-foreground`,children:[u,d]}),t[9]=r,t[10]=s,t[11]=l,t[12]=u,t[13]=f):f=t[13];let p;t[14]===a?p=t[15]:(p=(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:a}),t[14]=a,t[15]=p);let m;return t[16]!==n||t[17]!==c||t[18]!==f||t[19]!==p?(m=(0,Z.jsxs)(`span`,{"data-testid":c,title:n,className:`group/chip inline-flex max-w-[14rem] items-center gap-1 rounded-md border bg-muted/40 py-0.5 pr-1.5 pl-1 text-muted-foreground text-xs`,children:[f,p]}),t[16]=n,t[17]=c,t[18]=f,t[19]=p,t[20]=m):m=t[20],m}function Rw(e){let t=(0,$.c)(11),{files:n,onRemoveFile:r,className:i,children:a}=e;if(n.length===0&&a==null)return null;let o;t[0]===i?o=t[1]:(o=Y(`flex flex-wrap items-center gap-1`,i),t[0]=i,t[1]=o);let s;if(t[2]!==n||t[3]!==r){let e;t[5]===r?e=t[6]:(e=e=>(0,Z.jsx)(Lw,{path:e,onRemove:()=>r(e)},e),t[5]=r,t[6]=e),s=n.map(e),t[2]=n,t[3]=r,t[4]=s}else s=t[4];let c;return t[7]!==a||t[8]!==o||t[9]!==s?(c=(0,Z.jsxs)(`div`,{className:o,"data-testid":`composer-context-chips`,children:[s,a]}),t[7]=a,t[8]=o,t[9]=s,t[10]=c):c=t[10],c}function zw(e){let t=(0,$.c)(35),{primary:n,onPrimary:r,primaryDisabled:i,installedTargets:a,selectedTargetId:o,onSelectTarget:s,terminal:c,terminals:l,menuEmptyState:u,onMenuOpenChange:d,menuAlign:f,triggerAriaLabel:p,testIds:m}=e,h=i===void 0?!1:i,g=f===void 0?`end`:f,{_}=$t(),v=a.length>0,y=l&&l.length>0?l:null,b=y!=null||c!=null,x=v||b,S;t[0]===m?S=t[1]:(S=e=>typeof m.terminal==`function`?m.terminal(e):m.terminal,t[0]=m,t[1]=S);let C=S,w;t[2]!==r||t[3]!==n||t[4]!==h||t[5]!==m.primary?(w=(0,Z.jsx)(X,{type:`button`,variant:`outline`,className:`gap-1.5`,disabled:h,onClick:r,"data-testid":m.primary,children:n}),t[2]=r,t[3]=n,t[4]=h,t[5]=m.primary,t[6]=w):w=t[6];let T;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(Gi,{"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`}),t[7]=T):T=t[7];let E;t[8]!==m.trigger||t[9]!==p?(E=(0,Z.jsx)(yc,{asChild:!0,children:(0,Z.jsx)(X,{type:`button`,variant:`outline`,size:`icon`,"aria-label":p,"data-testid":m.trigger,children:T})}),t[8]=m.trigger,t[9]=p,t[10]=E):E=t[10];let D;t[11]!==_||t[12]!==y||t[13]!==x||t[14]!==a||t[15]!==u||t[16]!==s||t[17]!==o||t[18]!==v||t[19]!==b||t[20]!==c||t[21]!==C||t[22]!==m?(D=x?(0,Z.jsxs)(Z.Fragment,{children:[b?(0,Z.jsxs)(Sc,{"aria-label":_({id:`ALhMYW`}),children:[(0,Z.jsx)(Mc,{children:(0,Z.jsx)(J,{id:`ALhMYW`})}),y?y.map(e=>(0,Z.jsxs)(xc,{onSelect:e.onSelect,"data-testid":C(e.cli),"aria-label":e.ariaLabel,children:[(0,Z.jsx)(la,{id:ca(e.cli),className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:e.label}),e.selected?(0,Z.jsx)(Wi,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null]},e.cli)):c?(0,Z.jsxs)(xc,{onSelect:c.onSelect,"data-testid":C(`claude`),"aria-label":_({id:`AcK_r0`}),children:[(0,Z.jsx)(la,{id:ca(`claude`),className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:(0,Z.jsx)(J,{id:`fcgvCA`})}),c.selected?(0,Z.jsx)(Wi,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null]}):null]}):null,v?(0,Z.jsxs)(Z.Fragment,{children:[b?(0,Z.jsx)(Pc,{}):null,(0,Z.jsxs)(Sc,{"aria-label":_({id:`BBqGS9`}),children:[(0,Z.jsx)(Mc,{children:(0,Z.jsx)(J,{id:`BBqGS9`})}),a.map(e=>(0,Z.jsxs)(xc,{onSelect:()=>s(e),"data-testid":m.option(e.id),children:[(0,Z.jsx)(la,{id:e.id,"aria-hidden":`true`,className:`size-4`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:e.displayName}),o===e.id?(0,Z.jsx)(Wi,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null]},e.id))]})]}):null]}):u,t[11]=_,t[12]=y,t[13]=x,t[14]=a,t[15]=u,t[16]=s,t[17]=o,t[18]=v,t[19]=b,t[20]=c,t[21]=C,t[22]=m,t[23]=D):D=t[23];let O;t[24]!==g||t[25]!==D||t[26]!==m.menu?(O=(0,Z.jsx)(Cc,{align:g,className:`min-w-[200px]`,"data-testid":m.menu,children:D}),t[24]=g,t[25]=D,t[26]=m.menu,t[27]=O):O=t[27];let k;t[28]!==d||t[29]!==E||t[30]!==O?(k=(0,Z.jsxs)(kc,{onOpenChange:d,children:[E,O]}),t[28]=d,t[29]=E,t[30]=O,t[31]=k):k=t[31];let A;return t[32]!==w||t[33]!==k?(A=(0,Z.jsxs)(gx,{children:[w,k]}),t[32]=w,t[33]=k,t[34]=A):A=t[34],A}var Bw=`ok-onboarding-card-v1`,Vw={initialized:!1,steps:{file:!1,askedAi:!1},dismissed:!1,completed:!1};function Hw(e){return e===!0}function Uw(e){if(typeof e!=`object`||!e)return Vw;let t=e,n=typeof t.steps==`object`&&t.steps!==null?t.steps:{};return{initialized:Hw(t.initialized),steps:{file:Hw(n.file),askedAi:Hw(n.askedAi)},dismissed:Hw(t.dismissed),completed:Hw(t.completed)}}function Ww(e){try{let t=(e??localStorage).getItem(Bw);return t==null?Vw:Uw(JSON.parse(t))}catch(e){return console.warn(`[onboarding-card-store] readPersistedState failed (corrupt/privacy/SSR)`,e),Vw}}function Gw(e,t){try{(t??localStorage).setItem(Bw,JSON.stringify(e))}catch(e){console.warn(`[onboarding-card-store] writePersistedState failed (quota/privacy/SSR)`,e)}}function Kw(e){let t=Ww(e),n=new Set,r=!1;function i(){for(let e of n)e()}function a(n){t=n,Gw(t,e),i()}return{getSnapshot(){return t},subscribe(e){return n.add(e),()=>{n.delete(e)}},activate(){t.initialized||a({...t,initialized:!0})},markStepComplete(e){t.steps[e]||a({...t,steps:{...t.steps,[e]:!0}})},dismiss(){t.dismissed||a({...t,dismissed:!0})},markCompleted(){t.completed||a({...t,completed:!0})},install(){r||(r=!0,t=Ww(e),i())}}}var qw=Kw();function Jw(e){let t=e===void 0?qw:e;return(0,Q.useSyncExternalStore)(t.subscribe,t.getSnapshot,t.getSnapshot)}function Yw(){qw.install()}function Xw(e){return Cl(e).filter(e=>e.kind===`document`||e.kind===`folder`).length}async function Zw(){let e=await fetch(`/api/documents`);if(!e.ok)throw Error(`documents request failed: ${e.status}`);let t=await e.json(),n=Bn.safeParse(t);if(!n.success)throw Error(`documents response did not match schema`,{cause:n.error});return Xw(n.data.documents)}async function Qw(e=qw){let t=e.getSnapshot();if(!(t.steps.file||!t.initialized))try{await Zw()>=1&&e.markStepComplete(`file`)}catch(e){console.warn(`[onboarding-signals] file-step count read failed; leaving step incomplete`,e)}}function $w(e=qw){e.getSnapshot().initialized&&e.markStepComplete(`askedAi`)}var eT=5200,tT=500;function nT(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toUpperCase();return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`}function rT(){let e=(0,$.c)(2),[t,n]=(0,Q.useState)(iT),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`);n(e.matches);let t=e=>n(e.matches);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 iT(){return typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function aT(e,t){let n=(0,$.c)(9),[r,i]=(0,Q.useState)(0),[a,o]=(0,Q.useState)(!0),s,c;if(n[0]!==t||n[1]!==a?(s=()=>{if(!t)return;if(a){let e=setTimeout(()=>o(!1),eT);return()=>clearTimeout(e)}let e=setTimeout(()=>{i(oT),o(!0)},tT);return()=>clearTimeout(e)},c=[a,t],n[0]=t,n[1]=a,n[2]=s,n[3]=c):(s=n[2],c=n[3]),(0,Q.useEffect)(s,c),!t){let t=e[0]??``,r;return n[4]===t?r=n[5]:(r={text:t,visible:!0},n[4]=t,n[5]=r),r}let l=e[e.length>0?r%e.length:0]??``,u;return n[6]!==l||n[7]!==a?(u={text:l,visible:a},n[6]=l,n[7]=a,n[8]=u):u=n[8],u}function oT(e){return e+1}function sT(e){let t=(0,$.c)(153),{docName:n,surface:r,folderPath:i,dismissed:a,onDismiss:o,onReopen:s}=e,c=a===void 0?!1:a,{_:l}=$t(),u=i!==void 0,d=u?null:n??null,f=r??`wysiwyg`,p=rT(),m=ta(),{states:h}=ha(),{dispatch:g}=Ca(),_=xa(),[v]=(0,Q.useState)(vT),[y,b]=(0,Q.useState)(null),x=Xg(),[S,C]=(0,Q.useState)(!0),[w,T]=(0,Q.useState)(!1),E=(0,Q.useRef)(null),D=(0,Q.useRef)(null),[O]=(0,Q.useState)(_T),k,A;t[0]!==c||t[1]!==n||t[2]!==u||t[3]!==r?(k=()=>{if(u||n==null)return;let e=document.documentElement,t=hT,i=()=>{r===`wysiwyg`&&requestAnimationFrame(()=>{let e=Et(n),t=D.current;if(!(!e||e.isDestroyed||!t))try{let n=e.view,r=n.coordsAtPos(e.state.selection.head).bottom-(t.getBoundingClientRect().top-28);if(r<=0)return;let i=n.dom.closest(`.editor-doc-scroll`);i instanceof HTMLElement&&(i.scrollTop+=r)}catch{}})},a=D.current;if(c||!a){t(),e.style.removeProperty(`--ask-composer-height`);return}let o=()=>{t(),e.style.setProperty(`--ask-composer-height`,`${a.offsetHeight+56}px`)};o(),i();let s=new ResizeObserver(o);return s.observe(a),()=>{s.disconnect(),t(),e.style.removeProperty(`--ask-composer-height`)}},A=[c,r,n,u],t[0]=c,t[1]=n,t[2]=u,t[3]=r,t[4]=k,t[5]=A):(k=t[4],A=t[5]),(0,Q.useEffect)(k,A);let j=(0,Q.useRef)(c),M=(0,Q.useRef)(s),N;t[6]!==c||t[7]!==s?(N=()=>{j.current=c,M.current=s},t[6]=c,t[7]=s,t[8]=N):N=t[8],(0,Q.useEffect)(N);let P,F;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>iu(()=>{j.current?M.current?.():E.current?.focus()}),F=[],t[9]=P,t[10]=F):(P=t[9],F=t[10]),(0,Q.useEffect)(P,F);let I;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(I=[],t[11]=I):I=t[11],(0,Q.useEffect)(pT,I);let L=(0,Q.useRef)(c),R,z;t[12]===c?(R=t[13],z=t[14]):(R=()=>{let e=L.current;L.current=c,e&&!c&&E.current?.focus()},z=[c],t[12]=c,t[13]=R,t[14]=z),(0,Q.useEffect)(R,z);let B;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(B=[],t[15]=B):B=t[15];let[V,H]=(0,Q.useState)(B),[U,W]=(0,Q.useState)(fT),G;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(G=[],t[16]=G):G=t[16];let[K,ee]=(0,Q.useState)(G),te;t[17]!==n||t[18]!==u?(te=u||n==null?``:aa(n),t[17]=n,t[18]=u,t[19]=te):te=t[19];let ne=te,re,ie;t[20]!==ne||t[21]!==U||t[22]!==u||t[23]!==S?(re=()=>{u||S||H(e=>e.includes(ne)||U.has(ne)?e:[...e,ne])},ie=[u,S,ne,U],t[20]=ne,t[21]=U,t[22]=u,t[23]=S,t[24]=re,t[25]=ie):(re=t[24],ie=t[25]),(0,Q.useEffect)(re,ie);let ae;t[26]!==U||t[27]!==u||t[28]!==i||t[29]!==K||t[30]!==V?(ae=u?i&&!U.has(i)&&!K.includes(i)?[i]:[]:V.filter(e=>!U.has(e)&&!K.includes(e)),t[26]=U,t[27]=u,t[28]=i,t[29]=K,t[30]=V,t[31]=ae):ae=t[31];let oe=ae,se=Bi(d,f),ce=Bi(d,`frontmatter`),[le,q]=(0,Q.useState)(null),[ue,de]=(0,Q.useState)(!1),fe,pe;t[32]===se?(fe=t[33],pe=t[34]):(fe=()=>{se&&q(se)},pe=[se],t[32]=se,t[33]=fe,t[34]=pe),(0,Q.useEffect)(fe,pe);let me,he;t[35]===ce?(me=t[36],he=t[37]):(me=()=>{ce&&q(ce)},he=[ce],t[35]=ce,t[36]=me,t[37]=he),(0,Q.useEffect)(me,he);let ge=y??v,_e;t[38]!==ge||t[39]!==_?(_e=_===null?null:a_(ge),t[38]=ge,t[39]=_,t[40]=_e):_e=t[40];let ve=_e,ye;t[41]!==ge||t[42]!==x||t[43]!==_?(ye=_!==null&&ge===null?u_(null,x):null,t[41]=ge,t[42]=x,t[43]=_,t[44]=ye):ye=t[44];let be=ve??ye,xe=be!==null,Se;t[45]!==ge||t[46]!==xe||t[47]!==h?(Se=xe?null:l_(h,ge),t[45]=ge,t[46]=xe,t[47]=h,t[48]=Se):Se=t[48];let Ce=Se,we=!w&&(!S||le!==null)&&(xe||Ce!==null),Te;t[49]===h?Te=t[50]:(Te=ra.filter(e=>h[e.id]?.installed===!0),t[49]=h,t[50]=Te);let Ee=Te,De;t[51]===h?De=t[52]:(De=ra.some(e=>h[e.id]?.installed==null),t[51]=h,t[52]=De);let Oe=De,ke=_===null?void 0:fi.map(e=>{let{displayName:t}=zn[e];return{cli:e,label:t,ariaLabel:l({id:`QYfQdv`,values:{displayName:t}}),selected:be===e,onSelect:()=>Re(e)}}),Ae;t[53]===l?Ae=t[54]:(Ae=l({id:`KYSocE`}),t[53]=l,t[54]=Ae);let je;t[55]===l?je=t[56]:(je=l({id:`7Ongq0`}),t[55]=l,t[56]=je);let Me;t[57]===l?Me=t[58]:(Me=l({id:`HPTPGr`}),t[57]=l,t[58]=Me);let Ne;t[59]===l?Ne=t[60]:(Ne=l({id:`qiRoLb`}),t[59]=l,t[60]=Ne);let Pe;t[61]!==Ae||t[62]!==je||t[63]!==Me||t[64]!==Ne?(Pe=[Ae,je,Me,Ne],t[61]=Ae,t[62]=je,t[63]=Me,t[64]=Ne,t[65]=Pe):Pe=t[65];let Fe=aT(Pe,!p&&S&&!c),Ie;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=e=>{b(e.id),c_(e.id)},t[66]=Ie):Ie=t[66];let Le=Ie,Re=e=>{let t=i_(e);b(t),c_(t)},ze;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(ze=()=>{E.current?.clear(),q(null),de(!1),H([]),W(new Set),mx()},t[67]=ze):ze=t[67];let Be=ze,Ve;t[68]!==l||t[69]!==g||t[70]!==Ce||t[71]!==be||t[72]!==_?(Ve=e=>{if(e===null){Ss.error(l({id:`y8B54M`}));return}if(be!==null&&_!==null){try{_.launchInTerminal(e,be)}catch{Ss.error(l({id:`jBVUXo`}));return}$w(),Be();return}Ce!==null&&(T(!0),g(Ce.id,e).then(dT).finally(()=>{T(!1),Be()}))},t[68]=l,t[69]=g,t[70]=Ce,t[71]=be,t[72]=_,t[73]=Ve):Ve=t[73];let He=Ve,Ue;t[74]!==ne||t[75]!==we||t[76]!==He||t[77]!==n||t[78]!==oe||t[79]!==u||t[80]!==i||t[81]!==le||t[82]!==m?(Ue=()=>{if(!we)return;let{instruction:e,mentions:t}=E.current?.getContent()??{instruction:``,mentions:[]};if(u){He(da({docName:null,folderRelativePath:i,workspace:m,instruction:e,mentions:[...new Set([...oe,...t])].filter(e=>e!==i)}));return}let r=le?pu(le):void 0,a=le?.docName??null,o=le?a:oe.includes(ne)?n??null:null,s=o===null?null:aa(o);He(da({docName:o,workspace:m,instruction:e,mentions:[...new Set([...oe,...t])].filter(e=>e!==s),selection:r}))},t[74]=ne,t[75]=we,t[76]=He,t[77]=n,t[78]=oe,t[79]=u,t[80]=i,t[81]=le,t[82]=m,t[83]=Ue):Ue=t[83];let We=Ue;if(c)return null;let Ge=``,Ke=``;if(le){let e;t[84]===le?e=t[85]:(e=mu(le,aa(le.docName).split(`/`).pop()??``),t[84]=le,t[85]=e),Ge=e;let n;t[86]===le.markdown?n=t[87]:(n=hu(le.markdown),t[86]=le.markdown,t[87]=n),Ke=n}let qe;t[88]!==l||t[89]!==u||t[90]!==o?(qe=u?null:(0,Z.jsx)(X,{type:`button`,variant:`outline`,"aria-label":l({id:`EWX92Z`}),onClick:()=>o?.(),"data-testid":`ask-ai-collapse`,className:`-top-2.5 -translate-x-1/2 absolute left-1/2 z-10 h-5 w-10 rounded-md p-0 text-muted-foreground opacity-0 shadow-sm transition-opacity hover:text-foreground focus-visible:opacity-100 group-focus-within:opacity-100 group-hover:opacity-100`,children:(0,Z.jsx)(Gi,{className:`size-3.5`,"aria-hidden":!0})}),t[88]=l,t[89]=u,t[90]=o,t[91]=qe):qe=t[91];let Je;t[92]===Symbol.for(`react.memo_cache_sentinel`)?(Je=e=>W(t=>{let n=new Set(t);return n.add(e),n}),t[92]=Je):Je=t[92];let Ye;t[93]!==l||t[94]!==Ge||t[95]!==Ke||t[96]!==le||t[97]!==ue?(Ye=le?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{"data-testid":`composer-selection-pill`,title:Ge,className:`group/chip inline-flex max-w-[16rem] items-center gap-1 rounded-md border bg-muted/40 py-0.5 pr-1.5 pl-1 text-muted-foreground text-xs`,children:[(0,Z.jsxs)(X,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":l({id:`irrm_E`}),onClick:()=>{q(null),de(!1)},className:`group/remove relative size-3.5 shrink-0 rounded-sm text-muted-foreground/80 hover:text-foreground`,children:[(0,Z.jsx)(Nf,{className:`absolute top-1/2 left-1/2 size-3 -translate-x-1/2 -translate-y-1/2 opacity-100 transition-opacity duration-150 ease-out group-hover/chip:opacity-0 group-focus-within/chip:opacity-0 motion-reduce:transition-none`,"aria-hidden":!0}),(0,Z.jsx)(Cs,{className:`absolute top-1/2 left-1/2 size-3 -translate-x-1/2 -translate-y-1/2 opacity-0 transition-opacity duration-150 ease-out group-hover/chip:opacity-100 group-focus-within/chip:opacity-100 motion-reduce:transition-none`,"aria-hidden":!0})]}),(0,Z.jsx)(X,{type:`button`,variant:`ghost`,"aria-expanded":ue,"aria-label":l(ue?{id:`UaDyeb`}:{id:`eTL5y9`}),onClick:()=>de(uT),"data-testid":`composer-selection-peek`,className:`h-auto min-h-0 min-w-0 shrink justify-start px-0 py-0 text-left font-normal text-muted-foreground text-xs hover:bg-transparent hover:text-foreground`,children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:Ge})})]}),ue&&Ke!==``?(0,Z.jsx)(`p`,{className:`max-h-24 w-full basis-full overflow-y-auto whitespace-pre-wrap text-2xs text-muted-foreground/80 subtle-scrollbar`,"data-testid":`composer-selection-preview`,children:Ke}):null]}):null,t[93]=l,t[94]=Ge,t[95]=Ke,t[96]=le,t[97]=ue,t[98]=Ye):Ye=t[98];let Xe;t[99]!==oe||t[100]!==Ye?(Xe=(0,Z.jsx)(Rw,{files:oe,onRemoveFile:Je,children:Ye}),t[99]=oe,t[100]=Ye,t[101]=Xe):Xe=t[101];let Ze;t[102]===l?Ze=t[103]:(Ze=l({id:`xWEvuo`}),t[102]=l,t[103]=Ze);let Qe;t[104]!==O||t[105]!==We||t[106]!==Ze?(Qe=(0,Z.jsx)(Fx,{ref:E,ariaLabel:Ze,onEmptyChange:C,onContentChange:px,onMentionsChange:ee,onSubmit:We,initialDoc:O,className:`max-h-[200px] overflow-y-auto text-base md:text-sm`}),t[104]=O,t[105]=We,t[106]=Ze,t[107]=Qe):Qe=t[107];let $e;t[108]!==S||t[109]!==p||t[110]!==Fe?($e=S?(0,Z.jsx)(`div`,{"aria-hidden":!0,className:Y(`pointer-events-none absolute inset-0 truncate px-0 py-1 text-base text-muted-foreground/60 md:text-sm`,!p&&`transition-opacity duration-500 ease-in-out`,Fe.visible?`opacity-100`:`opacity-0`),children:Fe.text}):null,t[108]=S,t[109]=p,t[110]=Fe,t[111]=$e):$e=t[111];let et;t[112]!==Qe||t[113]!==$e?(et=(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[Qe,$e]}),t[112]=Qe,t[113]=$e,t[114]=et):et=t[114];let tt;t[115]!==Ce||t[116]!==be?(tt=be===null?Ce?(0,Z.jsx)(la,{id:Ce.id,className:`size-4`,"aria-hidden":!0}):null:(0,Z.jsx)(la,{id:ca(be),className:`size-4`,"aria-hidden":!0}),t[115]=Ce,t[116]=be,t[117]=tt):tt=t[117];let nt;t[118]!==Ce||t[119]!==be?(nt=(0,Z.jsx)(`span`,{children:be===null?Ce?(0,Z.jsx)(J,{id:`nUNZL4`,values:{0:Ce.displayName}}):(0,Z.jsx)(J,{id:`F-vBv0`}):(0,Z.jsx)(J,{id:`ti6aF_`,values:{0:zn[be].displayName}})}),t[118]=Ce,t[119]=be,t[120]=nt):nt=t[120];let rt;t[121]===w?rt=t[122]:(rt=w?(0,Z.jsx)(ss,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,t[121]=w,t[122]=rt);let it;t[123]!==tt||t[124]!==nt||t[125]!==rt?(it=(0,Z.jsxs)(Z.Fragment,{children:[tt,nt,rt]}),t[123]=tt,t[124]=nt,t[125]=rt,t[126]=it):it=t[126];let at=!we,ot=xe?null:Ce?.id??null,st;t[127]===Oe?st=t[128]:(st=(0,Z.jsx)(`p`,{className:`px-2 py-1.5 text-sm text-muted-foreground`,"aria-live":`polite`,children:Oe?(0,Z.jsx)(J,{id:`EcR0fl`}):(0,Z.jsx)(J,{id:`l6OXqI`})}),t[127]=Oe,t[128]=st);let ct;t[129]===l?ct=t[130]:(ct=l({id:`nskygk`}),t[129]=l,t[130]=ct);let lt;t[131]===Symbol.for(`react.memo_cache_sentinel`)?(lt={primary:`ask-ai-send`,trigger:`ask-ai-agent-trigger`,menu:`ask-ai-agent-menu`,option:lT,terminal:cT},t[131]=lt):lt=t[131];let ut;t[132]!==ke||t[133]!==Le||t[134]!==Ee||t[135]!==We||t[136]!==it||t[137]!==at||t[138]!==ot||t[139]!==st||t[140]!==ct?(ut=(0,Z.jsx)(zw,{primary:it,onPrimary:We,primaryDisabled:at,installedTargets:Ee,selectedTargetId:ot,onSelectTarget:Le,terminals:ke,menuEmptyState:st,triggerAriaLabel:ct,testIds:lt}),t[132]=ke,t[133]=Le,t[134]=Ee,t[135]=We,t[136]=it,t[137]=at,t[138]=ot,t[139]=st,t[140]=ct,t[141]=ut):ut=t[141];let dt;t[142]!==et||t[143]!==ut?(dt=(0,Z.jsxs)(`div`,{className:`flex items-end gap-2`,children:[et,ut]}),t[142]=et,t[143]=ut,t[144]=dt):dt=t[144];let ft;t[145]!==qe||t[146]!==Xe||t[147]!==dt?(ft=(0,Z.jsxs)(`div`,{ref:D,className:`pointer-events-auto group relative flex flex-col gap-1.5 rounded-2xl border border-border/60 bg-card px-3 py-2 shadow-sm transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50`,children:[qe,Xe,dt]}),t[145]=qe,t[146]=Xe,t[147]=dt,t[148]=ft):ft=t[148];let pt=ft;if(u){let e;return t[149]===pt?e=t[150]:(e=(0,Z.jsx)(`div`,{className:`shrink-0 pt-2 pb-3`,"data-testid":`bottom-composer`,children:(0,Z.jsx)(`div`,{className:`mx-auto w-full max-w-4xl px-6`,children:pt})}),t[149]=pt,t[150]=e),e}let mt;return t[151]===pt?mt=t[152]:(mt=(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-[var(--conflict-footer-height,0px)] z-20 editor-content-aligned bg-gradient-to-t from-background from-65% via-background to-transparent pt-10 pb-2`,"data-testid":`bottom-composer`,children:pt}),t[151]=pt,t[152]=mt),mt}function cT(e){return e===`claude`?`ask-ai-agent-option-terminal`:`ask-ai-agent-option-terminal-${e}`}function lT(e){return`ask-ai-agent-option-${e}`}function uT(e){return!e}function dT(e){e.ok&&$w()}function fT(){return new Set}function pT(){let e=mT;return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})}function mT(e){Al(e,`open-ask-ai`)&&(nT(e.target)||(e.preventDefault(),lu()))}function hT(){let e=[...document.querySelectorAll(`.editor-doc-scroll`)].filter(gT);if(e.length===0)return;let t=!1,n=()=>{t=!0};window.addEventListener(`wheel`,n,{passive:!0}),window.addEventListener(`touchstart`,n,{passive:!0});let r=performance.now(),i=()=>{if(t||performance.now()-r>=300){window.removeEventListener(`wheel`,n),window.removeEventListener(`touchstart`,n);return}for(let t of e)t.scrollTop=t.scrollHeight-t.clientHeight;requestAnimationFrame(i)};requestAnimationFrame(i)}function gT(e){let t=e.scrollHeight-e.clientHeight;return t>0&&e.scrollTop>=t-40}function _T(){return fx().doc??void 0}function vT(){return s_()}function yT(e){return!e.terminalVisible&&!e.isEmbedded&&e.activeDocName!==null}function bT(e){return!e.terminalVisible&&!e.isEmbedded}function xT(e,t={}){let n=tt(e.componentName);return n.name===`*`?t.unregisteredSuffix?`${e.componentName} (unregistered)`:e.componentName:n.displayName??n.name}var ST=200,CT=`Outside any block`;function wT(e){let t=(0,$.c)(5),{editor:n}=e,r=qt(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?TT(n,r):o.current?CT:``,a.current=window.setTimeout(()=>{i.current&&(i.current.textContent=``,i.current.textContent=t),o.current=e,a.current=null},ST),()=>{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 TT(e,t){if(!t||t.ancestorChain.length===0)return``;let n=t.ancestorChain,r=n[n.length-1],i=xT(r,{unregisteredSuffix:!0});if(n.length===1)return`Selected: ${i}`;let a=n[n.length-2],o=xT(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}`}}var ET=!1;function DT(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{Tl(n,{durationMs:Math.round(e*1e3)/1e3,threw:!o,...i},{startTime:t,duration:e})}catch{}}}}function OT(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 kT=0,AT=0,jT=0,MT=0,NT=null,PT=[`linkResolutionDecoration$`],FT=new WeakSet,IT=new WeakSet;function LT(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}function RT(){return!1}function zT(){return!RT()}function BT(e,t){if(zT())return t;let n=`ok/cold/nodeview-factory-${LT(e)}`;return function(...r){let i=performance.now();try{return t(...r)}finally{let t=performance.now()-i;Tl(n,{nodeType:e,durationMs:Math.round(t*1e3)/1e3},{startTime:i,duration:t})}}}function VT(e){if(zT())return;let t=e.state.plugins;for(let e of t){if(IT.has(e))continue;let t=e.spec?.key?.key;if(!t||!PT.some(e=>t.startsWith(e)))continue;let n=e.props,r=n.decorations;if(typeof r!=`function`){IT.add(e);continue}let i=`ok/cold/decoration-${LT(t.replace(/\$\d*$/,``))}`;n.decorations=function(...e){let n=performance.now();try{return r.apply(this,e)}finally{let e=performance.now()-n;Tl(i,{pluginKey:t,durationMs:Math.round(e*1e3)/1e3},{startTime:n,duration:e})}},IT.add(e)}}function HT(e){if(zT())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=BT(e,n);r.__okWrapped=!0,t[e]=r}}function UT(e){return zT()?e:e.map(e=>{let t=e.name??`unknown`,n=LT(t);return e.extend({onBeforeCreate(){let e=performance.now();try{this.parent?.()}finally{let r=performance.now()-e;Tl(`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;Tl(`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;Tl(`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;Tl(`ok/cold/ext-${n}-on-destroy`,{ext:t,hook:`onDestroy`,durationMs:Math.round(r*1e3)/1e3},{startTime:e,duration:r})}}})})}function WT(){if(!ET){ET=!0,DT(Ln.prototype,`mount`,`ok/cold/editor-mount`,(e,t,n,r)=>{let i=e;return zT()||(NT=performance.now()),{elementDefault:i.options?.element?.nodeName??null,docSize:OT(i.editorState),durationMs:r}}),DT(Ln.prototype,`createView`,`ok/cold/editor-create-view`,e=>{let t=e;return!zT()&&!FT.has(e)&&t.view&&(VT(t.view),HT(t.view),FT.add(e)),{docSize:OT(t.editorState)}}),DT(Ln.prototype,`createNodeViews`,`ok/cold/create-node-views`,(e,t,n,r)=>{MT+=1;let i=e;return!zT()&&i.view&&HT(i.view),{docSize:OT(i.view),seq:MT,durationMs:r}}),DT(Hr.prototype,`updateState`,`ok/cold/pm-update-state`,(e,t,n,r)=>(AT+=1,{seq:AT,docSize:OT(e.state),durationMs:r})),DT(Hr.prototype,`setProps`,`ok/cold/pm-set-props`,(e,t,n,r)=>(jT+=1,{seq:jT,docSize:OT(e.state),durationMs:r})),DT(O.prototype,`_forceRerender`,`ok/cold/force-rerender`,(e,t,n,r)=>{kT+=1;let i=e,a=(()=>{try{return i.type?.toArray?i.type.toArray().length:null}catch{return null}})();return{seq:kT,topLevelYElements:a,durationMs:r}}),DT(u.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`)&&(Tl(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}),!zT()&&e===`first-paint`&&NT!==null)){let e=NT,n=Math.max(0,t.startTime-e);Tl(`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}),NT=null}}}).observe({type:`paint`,buffered:!0})}catch{}globalThis.__okColdMountInstrumented=!0}}function GT(){let[e]=(0,Q.useState)(sr);return e}function KT({principal:e,identity:t}){return e&&e.source===`git-config`?{type:`human`,name:ci(e.display_name),color:_r(e.id,Wn),coeditor:t.coeditor,tabId:t.tabId,principalId:e.id}:e&&e.source===`synthesized`?{type:`human`,name:t.name,color:_r(e.id,Wn),coeditor:t.coeditor,tabId:t.tabId}:{type:`human`,name:t.name,color:t.color,coeditor:t.coeditor,tabId:t.tabId}}function qT(e,t){return e>t}function JT(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.isChangeOrigin===!0?!0:`snapshot`in t&&`prevSnapshot`in t&&t.snapshot===null&&t.prevSnapshot===null}var YT=3,XT=6e4;function ZT(e,t){let n=0;for(let r of e)t-r<XT&&(n+=1);return n<YT}var QT=new Map;function $T(e,t){for(let n of e.changed.keys()){let e=n;for(;e!=null;){if(e===t)return!0;let n=e._item;e=n==null?null:n.parent}}return!1}function eE(e){let t=T.getState(e);return t?.snapshot!=null||t?.prevSnapshot!=null}function tE(e){let{fragment:t,docName:n,onWedged:r}=e,i=0,a=0,o=!1,s=!1,c=!1,l=null,u=new WeakSet,d=e=>{let t=T.getState(e)?.binding;if(!t)return;if(typeof t._prosemirrorChanged!=`function`){Tl.count(`ok/editor/binding-guard-disarmed`,{docName:n,reason:`no-prosemirror-changed`}),console.warn(`[binding-staleness-guard] ySync binding on "${n}" exposes no _prosemirrorChanged — write-back gate disarmed (vendored y-tiptap contract change?)`);return}if(u.has(t))return;u.add(t);let r=t._prosemirrorChanged.bind(t);t._prosemirrorChanged=e=>{qT(i,a)||r(e)}},f=()=>{if(c=!1,!s||o||!qT(i,a)||l!==null&&eE(l.state))return;o=!0;let e=Date.now();for(let[t,n]of QT)n.every(t=>e-t>=XT)&&QT.delete(t);let t=(QT.get(n)??[]).filter(t=>e-t<XT);if(!ZT(t,e)){QT.set(n,t),Tl.count(`ok/editor/binding-wedge-rate-capped`,{docName:n}),console.warn(`[binding-staleness-guard] wedge on "${n}" rate-capped (externalSeq=${i}, appliedSeq=${a}) — publication gate stays closed, no further recycle`);return}t.push(e),QT.set(n,t),console.warn(`[binding-staleness-guard] wedged binding on "${n}" — Y→PM apply missing (externalSeq=${i}, appliedSeq=${a})`);try{r({externalSeq:i,appliedSeq:a})}catch(e){o=!1,Tl.count(`ok/editor/binding-wedge-recovery-error`,{docName:n}),console.error(`[binding-staleness-guard] wedge recovery threw for "${n}":`,e)}},p=e=>{e.origin!==T&&$T(e,t)&&(i+=1,c||(c=!0,queueMicrotask(f)))};return new Mr({state:{init:()=>null,apply:e=>(JT(e.getMeta(T))&&(a=i,o&&Tl.count(`ok/editor/binding-wedge-recovered`,{docName:n}),o=!1),null)},filterTransaction:(e,t)=>!qT(i,a)||eE(t)?!0:e.getMeta(T)!==void 0,view:e=>{let r=t.doc;return r==null?(Tl.count(`ok/editor/binding-guard-disarmed`,{docName:n,reason:`no-ydoc`}),console.error(`[binding-staleness-guard] fragment has no Y.Doc for "${n}" — staleness guard disarmed`),{}):(s=!0,l=e,d(e.state),r.off(`beforeObserverCalls`,p),r.on(`beforeObserverCalls`,p),{destroy:()=>{s=!1,l=null,r.off(`beforeObserverCalls`,p)}})}})}function nE(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 rE=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&&ii(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(Ks(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(Hs(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(Ws(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(Us(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(Bs(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(Gs(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(Ls(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(Rs(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=ti(this.view,e.from,e.to),r={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof Or){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 qn){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():nE(o.getBoundingClientRect(),s.getBoundingClientRect());r={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return r}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&Vs(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()}},iE=e=>new Mr({key:typeof e.pluginKey==`string`?new Zr(e.pluginKey):e.pluginKey,view:t=>new rE({view:t,...e})});pr.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[iE({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 aE=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 gr(e,{textSerializers:yr(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(Ks(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(Hs(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(Ws(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(Us(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(Bs(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(Gs(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(Ls(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(Rs(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=ti(this.view,e.from,e.to);Vs({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()}},oE=e=>new Mr({key:typeof e.pluginKey==`string`?new Zr(e.pluginKey):e.pluginKey,view:t=>new aE({view:t,...e})});pr.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?[oE({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 sE(e,t){return e??new Zr(t)}var cE=typeof window<`u`?Q.useLayoutEffect:Q.useEffect,lE=new Set([`left`,`opacity`,`position`,`top`,`visibility`,`width`]),uE=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(`.`)),dE=new Set([`children`,`className`,`style`]),fE=new Set([`tabIndex`]),pE=new Set([`accessKey`,`autoCapitalize`,`contentEditable`,`contextMenu`,`dir`,`draggable`,`enterKeyHint`,`hidden`,`id`,`lang`,`nonce`,`role`,`slot`,`spellCheck`,`tabIndex`,`title`,`translate`]),mE={Blur:`focusout`,DoubleClick:`dblclick`,Focus:`focusin`,MouseEnter:`mouseenter`,MouseLeave:`mouseleave`};function hE(e,t){return/^on[A-Z]/.test(e)&&typeof t==`function`}function gE(e){return e.startsWith(`aria-`)||e.startsWith(`data-`),e}function _E(e){return e.startsWith(`aria-`)||e.startsWith(`data-`)||pE.has(e)}function vE(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function yE(e){let t=e.endsWith(`Capture`),n=(t?e.slice(0,-7):e).slice(2);return{eventName:mE[n]??n.toLowerCase(),options:t?{capture:!0}:void 0}}function bE(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 xE(e){return fE.has(e)}function SE(e,t,n){if(t===`tabIndex`){e.tabIndex=Number(n);return}e[t]=n}function CE(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 wE(e,t){return typeof t!=`number`||t===0||e.startsWith(`--`)||uE.has(e)?String(t):`${t}px`}function TE(e,t){lE.has(t)||e.style.removeProperty(vE(t))}function EE(e,t,n){lE.has(t)||e.style.setProperty(vE(t),wE(t,n))}function DE(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(r=>{if(dE.has(r)||!_E(r)||hE(r,t[r])||hE(r,n[r]))return;let i=t[r],a=n[r];if(i===a)return;let o=gE(r);if(a==null||a===!1){xE(r)&&CE(e,r),e.removeAttribute(o);return}if(a===!0){xE(r)&&SE(e,r,!0),e.setAttribute(o,``);return}if(xE(r)){SE(e,r,a);return}e.setAttribute(o,String(a))})}function OE(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute(`class`)}}function kE(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){TE(e,t);return}EE(e,t,a)}})}function AE(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(!hE(t,n))return;let{eventName:i,options:a}=yE(t),o=t=>{n(bE(e,t))};e.addEventListener(i,o,a),r.push({eventName:i,listener:o,options:a})}),r}function jE(e,t){let n=(0,Q.useRef)({}),r=(0,Q.useRef)([]);cE(()=>{let i=n.current;return OE(e,i.className,t.className),kE(e,i.style,t.style),DE(e,i,t),r.current=AE(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 ME=Q.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,getReferencedVirtualElement:o,options:s,children:c,...l},u)=>{let d=(0,Q.useRef)(document.createElement(`div`)),f=(0,Q.useRef)(sE(e,`bubbleMenu`)).current;jE(d.current,l),typeof u==`function`?u(d.current):u&&(u.current=d.current);let{editor:p}=z(),m=t||p,h={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:f,shouldShow:a,getReferencedVirtualElement:o,options:s},g=(0,Q.useRef)(h);g.current=h;let[_,v]=(0,Q.useState)(!1),y=(0,Q.useRef)(!0);return(0,Q.useEffect)(()=>{if(m?.isDestroyed)return;if(!m){console.warn(`BubbleMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=d.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=iE({...g.current,editor:m,element:e});m.registerPlugin(t);let n=g.current.pluginKey;return y.current=!0,v(!0),()=>{v(!1),m.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[m]),(0,Q.useEffect)(()=>{if(!(!_||!m||m.isDestroyed)){if(y.current){y.current=!1;return}m.view.dispatch(m.state.tr.setMeta(f,{type:`updateOptions`,options:g.current}))}},[_,m,n,r,a,s,i,o,f]),(0,_d.createPortal)(c,d.current)});Q.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,options:o,children:s,...c},l)=>{let u=(0,Q.useRef)(document.createElement(`div`)),d=(0,Q.useRef)(sE(e,`floatingMenu`)).current;jE(u.current,c),typeof l==`function`?l(u.current):l&&(l.current=u.current);let{editor:f}=z(),p=t||f,m={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:d,shouldShow:a,options:o},h=(0,Q.useRef)(m);h.current=m;let[g,_]=(0,Q.useState)(!1),v=(0,Q.useRef)(!0);return(0,Q.useEffect)(()=>{if(p?.isDestroyed)return;if(!p){console.warn(`FloatingMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=u.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=oE({...h.current,editor:p,element:e});p.registerPlugin(t);let n=h.current.pluginKey;return v.current=!0,_(!0),()=>{_(!1),p.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[p]),(0,Q.useEffect)(()=>{if(!(!g||!p||p.isDestroyed)){if(v.current){v.current=!1;return}p.view.dispatch(p.state.tr.setMeta(d,{type:`updateOptions`,options:h.current}))}},[g,p,n,r,a,o,i,d]),(0,_d.createPortal)(s,u.current)});var NE=[{name:`paragraph`,label:`Text`,icon:uf,isActive:e=>e.isActive(`paragraph`)&&!e.isActive(`list`),command:e=>e.chain().focus().setParagraph().run()},{name:`heading1`,label:`Heading 1`,icon:be,isActive:e=>e.isActive(`heading`,{level:1}),command:e=>e.chain().focus().toggleHeading({level:1}).run()},{name:`heading2`,label:`Heading 2`,icon:M,isActive:e=>e.isActive(`heading`,{level:2}),command:e=>e.chain().focus().toggleHeading({level:2}).run()},{name:`heading3`,label:`Heading 3`,icon:Tt,isActive:e=>e.isActive(`heading`,{level:3}),command:e=>e.chain().focus().toggleHeading({level:3}).run()},{name:`bulletList`,label:`Bullet List`,icon:pe,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:ue,isActive:e=>e.isActive(`list`,{ordered:!0}),command:e=>e.chain().focus().toggleOrderedList().run()},{name:`taskList`,label:`Task List`,icon:D,isActive:e=>e.isActive(`listItem`,{checked:!0})||e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleTaskList().run()},{name:`blockquote`,label:`Quote`,icon:ie,isActive:e=>e.isActive(`blockquote`),command:e=>e.chain().focus().toggleBlockquote().run()},{name:`codeBlock`,label:`Code Block`,icon:xf,isActive:e=>e.isActive(`codeBlock`),command:e=>e.chain().focus().toggleCodeBlock({language:`js`}).run()}];function PE(e){let t=(0,$.c)(18),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:FE},t[0]=n,t[1]=r);let{current:i,activeStates:a}=K(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)(Gi,{className:`size-3 opacity-50`}),t[6]=l):l=t[6];let u;t[7]!==s||t[8]!==c?(u=(0,Z.jsx)(yc,{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=NE.map(e=>{let t=e.icon,r=a[e.name];return(0,Z.jsxs)(xc,{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)(Cc,{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)(kc,{children:[u,f]}),t[15]=u,t[16]=f,t[17]=p):p=t[17],p}function FE(e){let t=Object.fromEntries(NE.map(t=>[t.name,t.isActive(e.editor)]));return{current:NE.find(e=>t[e.name])??NE[0],activeStates:t}}var IE=`open-knowledge:active-terminal-input`;function LE(e,t=typeof window>`u`?new EventTarget:window){t.dispatchEvent(new CustomEvent(IE,{detail:e}))}function RE(e,t=typeof window>`u`?new EventTarget:window){let n=t=>{let n=t instanceof CustomEvent?t.detail:void 0;typeof n==`string`&&e(n)};return t.addEventListener(IE,n),()=>t.removeEventListener(IE,n)}function zE(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toUpperCase();return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`}function BE(e){let t=(0,$.c)(3),{editor:n,shortcutEnabled:r}=e,i=r===void 0?!1:r;if(pa())return null;let a;return t[0]!==n||t[1]!==i?(a=(0,Z.jsx)(VE,{editor:n,shortcutEnabled:i}),t[0]=n,t[1]=i,t[2]=a):a=t[2],a}function VE(e){let t=(0,$.c)(11),{editor:n,shortcutEnabled:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=jr(),t[0]=i):i=t[0];let a=i,o,s;t[1]===r?(o=t[2],s=t[3]):(o=()=>{if(!a)return;let e=e=>{r&&Al(e,`edit-with-ai`)&&(zE(e.target)||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),lu()))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},s=[r,a],t[1]=r,t[2]=o,t[3]=s),(0,Q.useEffect)(o,s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(Qa,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[4]=c):c=t[4];let l;t[5]===n?l=t[6]:(l=()=>{let e=wt(n),t=vu(n);requestAnimationFrame(()=>{if(e===null||t.trim()===``){lu();return}LE(qr({relativePath:aa(e),instruction:``,selectionMarkdown:t,target:`claude-code`}))})},t[5]=n,t[6]=l);let u,d;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(us,{className:`size-3.5`,"aria-hidden":`true`}),d=(0,Z.jsx)(`span`,{children:(0,Z.jsx)(J,{id:`xWEvuo`})}),t[7]=u,t[8]=d):(u=t[7],d=t[8]);let f;return t[9]===l?f=t[10]:(f=(0,Z.jsxs)(Z.Fragment,{children:[c,(0,Z.jsxs)(X,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`edit-with-ai-bubble-button`,className:`gap-1 px-2 text-sm font-medium text-accent-foreground/80`,onClick:l,children:[u,d]})]}),t[9]=l,t[10]=f),f}function HE(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 UE(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:Fe(typeof n.src==`string`?n.src:``)}function WE(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 GE(e){let t=(0,$.c)(13),{editor:n}=e,{_:r}=$t(),i;if(t[0]===n?i=t[1]:(i={editor:n,selector:KE},t[0]=n,t[1]=i),K(i)===null)return null;let a;t[2]===r?a=t[3]:(a=r({id:`WcWS__`}),t[2]=r,t[3]=a);let o;t[4]===n?o=t[5]:(o=e=>{e.preventDefault();let t=HE(n);t&&WE(t,UE(n))},t[4]=n,t[5]=o);let s;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(po,{className:`size-3.5`}),t[6]=s):s=t[6];let c;t[7]!==a||t[8]!==o?(c=(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":a,className:`text-accent-foreground`,onMouseDown:o,children:s})}),t[7]=a,t[8]=o,t[9]=c):c=t[9];let l;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(Ns,{side:`bottom`,sideOffset:8,children:(0,Z.jsx)(J,{id:`WcWS__`})}),t[10]=l):l=t[10];let u;return t[11]===c?u=t[12]:(u=(0,Z.jsx)(`div`,{className:`flex items-center gap-0.5`,children:(0,Z.jsxs)(Fs,{children:[c,l]})}),t[11]=c,t[12]=u),u}function KE(e){return HE(e.editor)}function qE(e){return HE(e)!==null}function JE(e){let t=e.schema.nodes;return!!(t.footnoteReference&&t.footnoteDefinition)}function YE(e){let{from:t,to:n}=e.state.selection,r=!1;return e.state.doc.nodesBetween(t,n,e=>e.type.name===`footnoteReference`?(r=!0,!1):!0),r}function XE(e){let{$from:t,$to:n}=e.state.selection;return!t.sameParent(n)}function ZE(e){let t=(0,$.c)(21),{editor:n}=e,{_:r}=$t(),i;t[0]===n?i=t[1]:(i={editor:n,selector:QE},t[0]=n,t[1]=i);let a=K(i),o;t[2]!==a||t[3]!==n?(o=()=>{if(a||!JE(n)||n.state.selection.empty||XE(n)||YE(n))return;let{from:e,to:t}=n.state.selection,r=n.state.doc.textBetween(e,t,` `);if(!r.trim())return;let i=ai(vr(n.state.doc)),o=Fr(n.state.doc)+1-(t-e);n.chain().focus().deleteSelection().insertFootnoteReference(i).insertContentAt(o,{type:`footnoteDefinition`,attrs:{identifier:i,label:i},content:[{type:`paragraph`,content:[{type:`text`,text:r}]}]}).run()},t[2]=a,t[3]=n,t[4]=o):o=t[4];let s=o,c;t[5]===r?c=t[6]:(c=r({id:`sIGbBZ`}),t[5]=r,t[6]=c);let l;t[7]===s?l=t[8]:(l=e=>{e.preventDefault(),s()},t[7]=s,t[8]=l);let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(A,{className:`size-3.5`,"aria-hidden":`true`}),t[9]=u):u=t[9];let d;t[10]!==a||t[11]!==c||t[12]!==l?(d=(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-xs`,"data-testid":`footnote-bubble-button`,className:`text-accent-foreground/80`,"aria-label":c,onMouseDown:l,disabled:a,children:u})}),t[10]=a,t[11]=c,t[12]=l,t[13]=d):d=t[13];let f;t[14]===r?f=t[15]:(f=r({id:`sIGbBZ`}),t[14]=r,t[15]=f);let p;t[16]===f?p=t[17]:(p=(0,Z.jsx)(Ns,{side:`bottom`,sideOffset:8,children:f}),t[16]=f,t[17]=p);let m;return t[18]!==d||t[19]!==p?(m=(0,Z.jsxs)(Fs,{children:[d,p]}),t[18]=d,t[19]=p,t[20]=m):m=t[20],m}function QE(e){let t=e.editor;return!!(!JE(t)||t.state.selection.empty||XE(t)||YE(t))}var $E=`img, .ok-embed, .ok-video`,eD=220,tD=`cubic-bezier(0.23, 1, 0.32, 1)`,nD=`ok-image-align-flip`,rD=.5;function iD(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function aD(){return typeof requestAnimationFrame==`function`}function oD(e){return e?e.querySelector($E):null}function sD(e,t){if(iD()||!aD()){t();return}let n=oD(e);if(!n){t();return}let r=n.getBoundingClientRect().left;t(),requestAnimationFrame(()=>{let t=oD(e);if(!t)return;for(let e of t.getAnimations())e.id===nD&&e.cancel();let n=r-t.getBoundingClientRect().left;if(Math.abs(n)<rD)return;let i=t.animate([{transform:`translateX(${n}px)`},{transform:`translateX(0)`}],{duration:eD,easing:tD,fill:`none`});i.id=nD})}var cD=[{value:`left`,label:`Align left`,icon:Mf},{value:`center`,label:`Align center`,icon:Af},{value:`right`,label:`Align right`,icon:jf}];function lD(e){let t=e.state.selection.node;if(!t||t.type.name!==`jsxComponent`)return null;let n=t.attrs.componentName;if(!Bt.has(String(n)))return null;let r=(t.attrs.props??{}).align;return r===`left`||r===`right`||r===`center`?r:`center`}function uD(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:dD},t[0]=n,t[1]=r);let i=K(r);if(i===null)return null;let a;t[2]!==i||t[3]!==n?(a=cD.map(e=>{let{value:t,label:r,icon:a}=e,o=i===t;return(0,Z.jsxs)(Fs,{children:[(0,Z.jsx)(Ms,{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(!Bt.has(a)||i.attrs.kind!==`element`)return;let o=a===`CommonMarkImage`,s=r.from,c={...i.attrs.props??{},align:t},l=o?{...i.attrs,componentName:`img`,props:c,sourceDirty:!0}:{...i.attrs,props:c,sourceDirty:!0},u=n.state.tr.setNodeMarkup(s,null,l);u.setSelection(Or.create(u.doc,s)),sD(n.view.nodeDOM(s),()=>{n.view.dispatch(u)})},children:(0,Z.jsx)(a,{className:`size-3.5`})})}),(0,Z.jsx)(Ns,{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 dD(e){return lD(e.editor)}function fD(e){return lD(e)!==null}var pD=[{name:`bold`,icon:hd,command:e=>e.chain().focus().toggleBold().run(),isActive:e=>e.isActive(`strong`),shortcutId:`format-bold`},{name:`italic`,icon:Gd,command:e=>e.chain().focus().toggleItalic().run(),isActive:e=>e.isActive(`emphasis`),shortcutId:`format-italic`},{name:`underline`,icon:Ff,command:e=>e.chain().focus().toggleUnderline().run(),isActive:e=>e.isActive(`underline`),shortcutId:`format-underline`},{name:`strikethrough`,icon:Df,command:e=>e.chain().focus().toggleStrike().run(),isActive:e=>e.isActive(`strike`),shortcutId:`format-strike`},{name:`code`,icon:gt,command:e=>e.chain().focus().toggleCode().run(),isActive:e=>e.isActive(`code`),shortcutId:`format-inline-code`},{name:`highlight`,icon:Ud,command:e=>e.chain().focus().toggleHighlight().run(),isActive:e=>e.isActive(`highlight`),shortcutId:`format-highlight`}];function mD(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:hD},t[0]=n,t[1]=r);let i=K(r),a;t[2]!==i||t[3]!==n?(a=pD.map(e=>{let t=e.icon,r=i[e.name];return(0,Z.jsxs)(Fs,{children:[(0,Z.jsx)(Ms,{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)(Ns,{side:`bottom`,sideOffset:8,children:[(0,Z.jsx)(`span`,{className:`capitalize`,children:e.name}),(0,Z.jsx)(P,{"aria-label":jl(e.shortcutId),children:kl(e.shortcutId)})]})]},e.name)}),t[2]=i,t[3]=n,t[4]=a):a=t[4];let o;return t[5]===a?o=t[6]:(o=(0,Z.jsx)(`div`,{className:`flex items-center gap-0.5`,children:a}),t[5]=a,t[6]=o),o}function hD(e){return Object.fromEntries(pD.map(t=>[t.name,t.isActive(e.editor)]))}function gD(e){let t=(0,$.c)(66),{editor:n}=e,{_:r}=$t(),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(``),c=(0,Q.useRef)(null),{folderPaths:l,loading:u,pages:d}=Xi(),f;t[0]===n?f=t[1]:(f=n.state.selection.empty&&n.isActive(`link`),t[0]=n,t[1]=f);let p=f,m;t[2]===n?m=t[3]:(m=n.getAttributes(`link`).href??``,t[2]=n,t[3]=m);let h=m,g;t[4]===n?g=t[5]:(g=function(){return n.state.selection.empty&&n.isActive(`link`)?n.getAttributes(`link`).href??``:``},t[4]=n,t[5]=g);let _=g,v,y;t[6]===n?(v=t[7],y=t[8]):(v=()=>{let e=function(){n.state.selection.empty&&a(!1)};return n.on(`selectionUpdate`,e),()=>{n.off(`selectionUpdate`,e)}},y=[n],t[6]=n,t[7]=v,t[8]=y),(0,Q.useEffect)(v,y);let b,x;t[9]===i?(b=t[10],x=t[11]):(b=()=>{i&&requestAnimationFrame(()=>c.current?.focus())},x=[i],t[9]=i,t[10]=b,t[11]=x),(0,Q.useEffect)(b,x);let S;t[12]!==n||t[13]!==p||t[14]!==o?(S=function(){o.trim()?n.chain().focus().setLink({href:o.trim()}).run():p&&n.chain().focus().unsetLink().run(),a(!1)},t[12]=n,t[13]=p,t[14]=o,t[15]=S):S=t[15];let C=S,w;t[16]===n?w=t[17]:(w=function(){n.chain().focus().unsetLink().run(),a(!1)},t[16]=n,t[17]=w);let T=w,E;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(E=function(e){s(re(e.path,null))},t[18]=E):E=t[18];let D=E,O;t[19]!==C||t[20]!==n?(O=function(e){e.key===`Enter`&&(e.preventDefault(),C()),e.key===`Escape`&&(e.preventDefault(),a(!1),n.chain().focus().run())},t[19]=C,t[20]=n,t[21]=O):O=t[21];let k=O;if(i){let e;t[22]===r?e=t[23]:(e=r({id:`ZsGpr_`}),t[22]=r,t[23]=e);let n;t[24]===r?n=t[25]:(n=r({id:`roAe2K`}),t[24]=r,t[25]=n);let i;t[26]!==l||t[27]!==k||t[28]!==u||t[29]!==d||t[30]!==e||t[31]!==n||t[32]!==o?(i=(0,Z.jsx)(at,{ref:c,type:`text`,placeholder:e,value:o,pages:d,folderPaths:l,loading:u,onValueChange:s,onSuggestionSelect:D,onKeyDown:k,"aria-label":n,className:`h-5 w-44 rounded-none border-none bg-transparent px-0 py-0 text-sm placeholder:text-muted-foreground focus-visible:border-transparent focus-visible:ring-0 dark:bg-transparent`}),t[26]=l,t[27]=k,t[28]=u,t[29]=d,t[30]=e,t[31]=n,t[32]=o,t[33]=i):i=t[33];let a;t[34]===r?a=t[35]:(a=r({id:`tP5DDk`}),t[34]=r,t[35]=a);let f;t[36]===C?f=t[37]:(f=()=>{C()},t[36]=C,t[37]=f);let m;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(Od,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[38]=m):m=t[38];let g;t[39]!==a||t[40]!==f?(g=(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":a,onClick:f,children:m}),t[39]=a,t[40]=f,t[41]=g):g=t[41];let _;t[42]!==i||t[43]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border bg-background px-2 py-1 focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50`,children:[i,g]}),t[42]=i,t[43]=g,t[44]=_):_=t[44];let v;t[45]!==r||t[46]!==h||t[47]!==p||t[48]!==T?(v=p&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Fs,{children:[(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":r({id:`2vIPtm`}),onMouseDown:e=>{e.preventDefault(),Xt(h)},children:(0,Z.jsx)(Ai,{className:`size-3.5`})})}),(0,Z.jsx)(Ns,{side:`bottom`,sideOffset:8,children:(0,Z.jsx)(J,{id:`2vIPtm`})})]}),(0,Z.jsxs)(Fs,{children:[(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":r({id:`484LKL`}),onMouseDown:e=>{e.preventDefault(),T()},children:(0,Z.jsx)(Ao,{className:`size-3.5`})})}),(0,Z.jsx)(Ns,{side:`bottom`,sideOffset:8,children:(0,Z.jsx)(J,{id:`484LKL`})})]})]}),t[45]=r,t[46]=h,t[47]=p,t[48]=T,t[49]=v):v=t[49];let y;return t[50]!==_||t[51]!==v?(y=(0,Z.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[_,v]}),t[50]=_,t[51]=v,t[52]=y):y=t[52],y}let A;t[53]===r?A=t[54]:(A=r({id:`p0Iq25`}),t[53]=r,t[54]=A);let j=p?`bg-accent text-primary`:`text-accent-foreground`,M;t[55]===_?M=t[56]:(M=e=>{e.preventDefault(),s(_()),a(!0)},t[55]=_,t[56]=M);let N;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(qd,{className:`size-3.5`}),t[57]=N):N=t[57];let F;t[58]!==A||t[59]!==j||t[60]!==M?(F=(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":A,className:j,onMouseDown:M,children:N})}),t[58]=A,t[59]=j,t[60]=M,t[61]=F):F=t[61];let I;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(J,{id:`yzF66j`}),t[62]=I):I=t[62];let L;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsxs)(Ns,{side:`bottom`,sideOffset:8,children:[I,(0,Z.jsx)(P,{children:kl(`command-palette`)})]}),t[63]=L):L=t[63];let R;return t[64]===F?R=t[65]:(R=(0,Z.jsxs)(Fs,{children:[F,L]}),t[64]=F,t[65]=R),R}function _D({editor:e}){if(Ze(e.state).query||e.isActive(`codeBlock`))return!1;if(fD(e)||qE(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 vD(e){let t=(0,$.c)(23),{editor:n,shortcutEnabled:r}=e,i=r===void 0?!0:r,a=(0,Q.useRef)(null),[o,s]=(0,Q.useState)(0),c=(0,Q.useRef)(null),l;t[0]===n?l=t[1]:(l={editor:n,selector:CD},t[0]=n,t[1]=l);let u=K(l),d;t[2]===n?d=t[3]:(d={editor:n,selector:SD},t[2]=n,t[3]=d);let f=K(d),p;t[4]!==n.state||t[5]!==n.view?(p=()=>{try{let{from:e,to:t}=n.state.selection;return ti(n.view,e,t)}catch{return new DOMRect}},t[4]=n.state,t[5]=n.view,t[6]=p):p=t[6];let m;if(t[7]!==n.view.dom||t[8]!==p){let e={getBoundingClientRect:p,contextElement:n.view.dom};m=()=>{let t=a.current;t&&(c.current?.(),c.current=Is(e,t,()=>{Vs(e,t,{placement:`top`,strategy:`fixed`,middleware:[Ws(8),Ks(),Hs({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(xD)}))},t[7]=n.view.dom,t[8]=p,t[9]=m}else m=t[9];let h=m,g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{c.current?.(),c.current=null,s(bD)},t[10]=g):g=t[10];let _=g,v;t[11]===h?v=t[12]:(v={onShow:h,onHide:_,strategy:`fixed`},t[11]=h,t[12]=v);let y;t[13]!==n||t[14]!==f||t[15]!==u||t[16]!==i||t[17]!==o?(y=u?(0,Z.jsx)(uD,{editor:n},`${o}-img-align`):f?(0,Z.jsx)(GE,{editor:n},`${o}-file`):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(PE,{editor:n}),(0,Z.jsx)(Qa,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),(0,Z.jsx)(mD,{editor:n},o),(0,Z.jsx)(Qa,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),(0,Z.jsx)(gD,{editor:n},`${o}-link`),(0,Z.jsx)(ZE,{editor:n},`${o}-footnote`),(0,Z.jsx)(BE,{editor:n,shortcutEnabled:i},`${o}-edit-ai`)]}),t[13]=n,t[14]=f,t[15]=u,t[16]=i,t[17]=o,t[18]=y):y=t[18];let b;return t[19]!==n||t[20]!==v||t[21]!==y?(b=(0,Z.jsx)(ME,{ref:a,editor:n,"data-testid":`bubble-menu-bar`,appendTo:yD,shouldShow:_D,updateDelay:250,options:v,className:`z-50 flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:y}),t[19]=n,t[20]=v,t[21]=y,t[22]=b):b=t[22],b}function yD(){return document.body}function bD(e){return e+1}function xD(){}function SD(e){return qE(e.editor)}function CD(e){return fD(e.editor)}var wD=56,TD=`0 2px 4px rgba(0, 0, 0, 0.08)`,ED=150,DD=globalThis.ScrollTimeline;function OD(e,t,n,r,i){let a=r-i;if(a<=0)return null;let o=e+n-(t+wD);return{startOffset:o,endOffset:o+a,maxShift:a}}var kD=new WeakMap;function AD(e){let t=kD.get(e);if(t){for(let e of t.animations)e.cancel();kD.delete(e)}}function jD(e){for(let t of Array.from(e.cells))AD(t)}var MD=e=>e.cellIndex===0?`3`:`2`;function ND(e,t){return PD(e,t,e=>({transform:`translateY(${e}px)`}))}function PD(e,t,n){if(!(t>0))return[{offset:0,...n(0)},{offset:1,...n(0)}];let r=t=>Math.max(0,Math.min(t-e.startOffset,e.maxShift));return Array.from(new Set([0,e.startOffset/t,e.endOffset/t,1].map(e=>Math.max(0,Math.min(e,1))))).sort((e,t)=>e-t).map(e=>({offset:e,...n(r(e*t))}))}function FD(e,t,n,r){if(!(t>0))return[{...n,offset:0},{...n,offset:1}];let i=e.startOffset/t;if(i<=0)return[{...r,offset:0},{...r,offset:1}];if(i>=1)return[{...n,offset:0},{...n,offset:1}];let a=Math.min(i+1/t,1);return[{...n,offset:0},{...n,offset:i},{...r,offset:a},{...r,offset:1}]}function ID(e,t,n){return FD(e,t,{zIndex:`auto`,boxShadow:`none`},{zIndex:n,boxShadow:TD})}function LD(e,t){return FD(e,t,{opacity:`0`},{opacity:`1`})}function RD(e,t,n,r){let i=MD(e),a=`sd|${n.startOffset}|${n.maxShift}|${r}|${i}`,o=kD.get(e);if(o?.key===a)return;if(o)for(let e of o.animations)e.cancel();let s={timeline:t,fill:`both`,easing:`linear`},c=e.animate(ND(n,r),s),l=e.animate(ID(n,r,i),s),u=e.animate(LD(n,r),{...s,pseudoElement:`::before`});kD.set(e,{key:a,animations:[c,l,u]})}function zD(e,t){let n=MD(e),r=`in|${t}|${n}`,i=kD.get(e);if(i?.key===r)return;if(i)for(let e of i.animations)e.cancel();let a=e.animate([{transform:`translateY(${t}px)`,zIndex:n,boxShadow:TD}],{duration:0,fill:`forwards`}),o=e.animate([{opacity:`1`}],{duration:0,fill:`forwards`,pseudoElement:`::before`});kD.set(e,{key:r,animations:[a,o]})}function BD(e,t,n,r){let i=e.getBoundingClientRect().top,a=e.scrollTop,o=e.scrollHeight-e.clientHeight,s=t.querySelectorAll(`.tableWrapper`);for(let e of s){r?.(e);let t=e.querySelector(`table`);if(!t)continue;let s=t.querySelector(`tbody`)?.rows[0];if(!s||!Array.from(s.cells).some(e=>e.tagName===`TH`))continue;let c=t.getBoundingClientRect(),l=s.getBoundingClientRect(),u=OD(a,i,c.top,c.height,l.height);if(!u){jD(s);continue}if(n){if(o<=0){jD(s);continue}for(let e of Array.from(s.cells))RD(e,n,u,o);continue}let d=Math.max(0,Math.min(a-u.startOffset,u.maxShift));if(d<=0||c.bottom<=i+wD){jD(s);continue}for(let e of Array.from(s.cells))zD(e,d)}}var VD=pr.create({name:`frozenTableHeaders`,addProseMirrorPlugins(){return[new Mr({key:new Zr(`frozenTableHeaders`),view(e){let t=null,n=null,r=null,i=null,a=null,o=!1,s=new Set,c=()=>{o||!t||BD(t,e.dom,n,u)},l=()=>{r??=requestAnimationFrame(()=>{r=null,c()})};function u(e){s.has(e)||(s.add(e),e.addEventListener(`contentvisibilityautostatechange`,l))}let d=()=>{if(n){i??l(),i!=null&&clearTimeout(i),i=setTimeout(()=>{i=null,c()},ED);return}l()};return requestAnimationFrame(()=>{if(!o){if(t=e.dom.closest(`[data-testid="editor-scroll-container"]`),t&&DD)try{n=new DD({source:t,axis:`block`})}catch{n=null}t?.addEventListener(`scroll`,d,{passive:!0}),t&&typeof ResizeObserver<`u`&&(a=new ResizeObserver(l),a.observe(t),a.observe(e.dom)),c()}}),{update(e,t){t.doc.eq(e.state.doc)||c()},destroy(){o=!0,t?.removeEventListener(`scroll`,d),a?.disconnect(),r!=null&&cancelAnimationFrame(r),i!=null&&clearTimeout(i);for(let e of s)e.removeEventListener(`contentvisibilityautostatechange`,l);s.clear();for(let t of e.dom.querySelectorAll(`.tableWrapper > table > tbody > tr:first-child`))jD(t)}}}})]}});function HD(e,t){return(n,r)=>{let i=r,a=Su(i.dataTransfer);return a?(i.preventDefault(),t?.(a),!0):e(n,i)}}function UD(e,t){let n=bu(e);t(n.target,{tabBehavior:`append`}),cl(n.hash)}var WD=5,GD=1;function KD(e){let t=(0,$.c)(14),{editor:n,axis:r,anchor:i,onClickGesture:a}=e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(null),c=(0,Q.useRef)(a),l,u;t[0]===a?(l=t[1],u=t[2]):(l=()=>{c.current=a},u=[a],t[0]=a,t[1]=l,t[2]=u),(0,Q.useEffect)(l,u);let d,f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>()=>{s.current?.abort(),s.current=null,o.current=null,document.body.style.cursor=``,document.body.style.userSelect=``},f=[],t[3]=d,t[4]=f):(d=t[3],f=t[4]),(0,Q.useEffect)(d,f);let[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(null),_;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>!(e&&o.current!==null),t[5]=_):_=t[5];let v=_,y;t[6]!==i||t[7]!==r||t[8]!==n?(y=e=>{if(e.button!==0)return;s.current?.abort(),o.current={startX:e.clientX,startY:e.clientY,isDragging:!1,lastTarget:null};let t=new AbortController;s.current=t;let{signal:a}=t,l=e=>{let t=o.current;if(!t)return;if(!t.isDragging){let n=e.clientX-t.startX,r=e.clientY-t.startY;if(Math.hypot(n,r)<WD)return;t.isDragging=!0,m(!0),document.body.style.cursor=`grabbing`,document.body.style.userSelect=`none`}let n=qD(i,r,e.clientX,e.clientY);t.lastTarget=n,g(n)},u=()=>{t.abort(),s.current===t&&(s.current=null),document.body.style.cursor=``,document.body.style.userSelect=``;let e=o.current;o.current=null,m(!1),g(null),e&&(e.isDragging&&e.lastTarget?ZD(n,i,r,e.lastTarget.index):e.isDragging||c.current())};document.addEventListener(`pointermove`,l,{signal:a}),document.addEventListener(`pointerup`,u,{signal:a}),document.addEventListener(`pointercancel`,u,{signal:a})},t[6]=i,t[7]=r,t[8]=n,t[9]=y):y=t[9];let b=y,x;return t[10]!==h||t[11]!==p||t[12]!==b?(x={onPointerDown:b,shouldAllowOpen:v,isDragging:p,indicator:h},t[10]=h,t[11]=p,t[12]=b,t[13]=x):x=t[13],x}function qD(e,t,n,r){let i=e.closest(`table`);if(!i)return null;let a=i.getBoundingClientRect();if(t===`row`){let e=Array.from(i.rows);if(e.length===0)return null;for(let t=0;t<e.length;t++){let n=e[t].getBoundingClientRect();if(r<n.top)return{index:GD,rect:YD(a,JD(e,0,n.top))};if(r<=n.bottom){let i=r>=n.top+n.height/2,o=i?t+1:t,s=Math.max(GD,o);return{index:s,rect:YD(a,s===o?i?n.bottom:n.top:JD(e,0,n.top))}}}let t=e[e.length-1].getBoundingClientRect();return{index:e.length,rect:YD(a,t.bottom)}}let o=i.rows[0];if(!o)return null;let s=Array.from(o.cells);if(s.length===0)return null;for(let e=0;e<s.length;e++){let t=s[e].getBoundingClientRect();if(n<t.left)return{index:0,rect:XD(a,t.left)};if(n<=t.right){let r=n>=t.left+t.width/2,i=r?t.right:t.left;return{index:r?e+1:e,rect:XD(a,i)}}}let c=s[s.length-1].getBoundingClientRect();return{index:s.length,rect:XD(a,c.right)}}function JD(e,t,n){let r=e[t];return r?r.getBoundingClientRect().bottom:n}function YD(e,t){return{left:e.left,top:t-1,width:e.width,height:2}}function XD(e,t){return{left:t-1,top:e.top,width:2,height:e.height}}function ZD(e,t,n,r){let i=n===`row`?QD(t):t.cellIndex;if(i<0||n===`row`&&(i<GD||r<GD)||r===i||r===i+1)return;let{state:a,view:o}=e,s=$D(a.selection.$from);if(s<0){console.warn(`[table-drag-reorder] no table found at selection depth`);return}let c=a.doc.nodeAt(s);if(!c){console.warn(`[table-drag-reorder] nodeAt returned null at tablePos`,s);return}let l=a.tr;nO(l,s,c,n===`row`?eO(c,i,r):tO(c,i,r)),o.dispatch(l)}function QD(e){let t=e.parentElement,n=t?.closest(`table`);return n?Array.prototype.indexOf.call(n.rows,t):-1}function $D(e){for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole===`table`)return e.before(t);return-1}function eO(e,t,n){let r=[];e.forEach(e=>{r.push(e)});let[i]=r.splice(t,1),a=n>t?n-1:n;return r.splice(a,0,i),e.type.create(e.attrs,r,e.marks)}function tO(e,t,n){let r=n>t?n-1:n,i=[];return e.forEach(e=>{let n=[];e.forEach(e=>{n.push(e)});let[a]=n.splice(t,1);n.splice(r,0,a),i.push(e.type.create(e.attrs,n,e.marks))}),e.type.create(e.attrs,i,e.marks)}function nO(e,t,n,r){e.replaceRangeWith(t,t+n.nodeSize,r)}function rO(e){return[...e?[{label:`Toggle header column`,icon:Ed,run:e=>e.chain().focus().toggleHeaderColumn().run()}]:[],{label:`Insert column left`,icon:Rt,run:e=>e.chain().focus().addColumnBefore().run()},{label:`Insert column right`,icon:lt,run:e=>e.chain().focus().addColumnAfter().run()},{label:`Delete column`,icon:Ao,separatorBefore:!0,run:e=>e.chain().focus().deleteColumn().run()},{label:`Delete table`,icon:Bd,run:e=>e.chain().focus().deleteTable().run()}]}function iO(e){return[...e?[{label:`Toggle header row`,icon:Of,run:e=>e.chain().focus().toggleHeaderRow().run()}]:[],{label:`Insert row above`,icon:Pe,run:e=>e.chain().focus().addRowBefore().run()},{label:`Insert row below`,icon:Re,run:e=>e.chain().focus().addRowAfter().run()},{label:`Delete row`,icon:Ao,separatorBefore:!0,run:e=>e.chain().focus().deleteRow().run()},{label:`Delete table`,icon:Bd,run:e=>e.chain().focus().deleteTable().run()}]}function aO(e){if(!e.isEditable||Ze(e.state).query)return null;let{state:t,view:n}=e,r=t.selection.$from,i=-1;for(let e=r.depth;e>0;e--){let t=r.node(e).type.spec.tableRole;if(t===`cell`||t===`header_cell`){i=r.before(e);break}}if(i<0)return null;let a=n.nodeDOM(i);if(!(a instanceof HTMLTableCellElement))return null;let o=a.closest(`table`),s=a.closest(`tr`),c=a.closest(`.ProseMirror`);if(!o||!s||!c)return null;let l=Array.prototype.indexOf.call(o.rows,s),u=a.cellIndex,d=o.rows[0]?.cells[u],f=o.rows[l]?.cells[0];return!d||!f?null:{columnAnchor:d,rowAnchor:f,isFirstColumn:u===0,isFirstRow:l===0}}function oO(e){let t=(0,$.c)(37),{editor:n,anchor:r,axis:i,items:a}=e,o=(0,Q.useRef)(null),[s,c]=(0,Q.useState)(!1),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>c(!0),t[0]=l):l=t[0];let u;t[1]!==r||t[2]!==i||t[3]!==n?(u={editor:n,axis:i,anchor:r,onClickGesture:l},t[1]=r,t[2]=i,t[3]=n,t[4]=u):u=t[4];let d=KD(u),f,p;t[5]!==r||t[6]!==i?(f=()=>{let e=o.current;if(!e)return;let t=i===`column`?`top`:`left`,n=i===`column`?-14:-6;return Is(r,e,()=>{Vs(r,e,{strategy:`absolute`,placement:t,middleware:[Ws(n)]}).then(t=>{let{x:n,y:r}=t;e.style.left=`${n}px`,e.style.top=`${r}px`,e.style.opacity=`1`}).catch(sO)})},p=[r,i],t[5]=r,t[6]=i,t[7]=f,t[8]=p):(f=t[7],p=t[8]),(0,Q.useEffect)(f,p);let m=i===`column`?Ad:to,h;t[9]===d?h=t[10]:(h=e=>{d.shouldAllowOpen(e)&&c(e)},t[9]=d,t[10]=h);let g=i===`column`?`h-3 w-7 rounded-full p-0 text-gray-700 dark:text-muted-foreground bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 hover:text-foreground dark:hover:bg-gray-600 dark:hover:text-gray-100 relative cursor-grab before:absolute before:-inset-[6px] before:content-[""]`:`h-7 w-3 rounded-full p-0 text-gray-700 dark:text-muted-foreground bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 hover:text-foreground dark:hover:bg-gray-600 dark:hover:text-gray-100 relative cursor-grab before:absolute before:-inset-[6px] before:content-[""]`,_=i===`column`?`Column options`:`Row options`,v;t[11]===m?v=t[12]:(v=(0,Z.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),t[11]=m,t[12]=v);let y;t[13]!==d.onPointerDown||t[14]!==g||t[15]!==_||t[16]!==v?(y=(0,Z.jsx)(yc,{asChild:!0,children:(0,Z.jsx)(X,{variant:`secondary`,onPointerDown:d.onPointerDown,className:g,"aria-label":_,children:v})}),t[13]=d.onPointerDown,t[14]=g,t[15]=_,t[16]=v,t[17]=y):y=t[17];let b=i===`column`?`center`:`start`,x=i===`column`?`bottom`:`right`,S;if(t[18]!==n||t[19]!==a){let e;t[21]===n?e=t[22]:(e=e=>(0,Z.jsxs)(Q.Fragment,{children:[e.separatorBefore&&(0,Z.jsx)(Pc,{}),(0,Z.jsxs)(xc,{onSelect:()=>e.run(n),children:[(0,Z.jsx)(e.icon,{"aria-hidden":!0}),e.label]})]},e.label),t[21]=n,t[22]=e),S=a.map(e),t[18]=n,t[19]=a,t[20]=S}else S=t[20];let C;t[23]!==b||t[24]!==x||t[25]!==S?(C=(0,Z.jsx)(Cc,{align:b,side:x,className:`w-auto min-w-44 whitespace-nowrap`,children:S}),t[23]=b,t[24]=x,t[25]=S,t[26]=C):C=t[26];let w;t[27]!==s||t[28]!==C||t[29]!==h||t[30]!==y?(w=(0,Z.jsx)(`div`,{ref:o,"data-testid":`table-cell-handle`,className:`absolute left-0 top-0 z-10 opacity-0`,children:(0,Z.jsxs)(kc,{open:s,onOpenChange:h,children:[y,C]})}),t[27]=s,t[28]=C,t[29]=h,t[30]=y,t[31]=w):w=t[31];let T;t[32]===d.indicator?T=t[33]:(T=d.indicator&&(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none fixed z-50 bg-primary`,style:{left:d.indicator.rect.left,top:d.indicator.rect.top,width:d.indicator.rect.width,height:d.indicator.rect.height}}),t[32]=d.indicator,t[33]=T);let E;return t[34]!==w||t[35]!==T?(E=(0,Z.jsxs)(Z.Fragment,{children:[w,T]}),t[34]=w,t[35]=T,t[36]=E):E=t[36],E}function sO(){}function cO(e){let t=(0,$.c)(18),{editor:n}=e,[r,i]=(0,Q.useState)(null),a,o;if(t[0]===n?(a=t[1],o=t[2]):(a=()=>{let e=()=>i(e=>{let t=aO(n);return e&&t&&e.columnAnchor===t.columnAnchor&&e.rowAnchor===t.rowAnchor?e:t});return e(),n.on(`selectionUpdate`,e),n.on(`update`,e),()=>{n.off(`selectionUpdate`,e),n.off(`update`,e)}},o=[n],t[0]=n,t[1]=a,t[2]=o),(0,Q.useEffect)(a,o),!r)return null;let s=r.columnAnchor,c;t[3]===r.isFirstColumn?c=t[4]:(c=rO(r.isFirstColumn),t[3]=r.isFirstColumn,t[4]=c);let l;t[5]!==r.columnAnchor||t[6]!==n||t[7]!==c?(l=(0,Z.jsx)(oO,{editor:n,anchor:s,axis:`column`,items:c}),t[5]=r.columnAnchor,t[6]=n,t[7]=c,t[8]=l):l=t[8];let u=r.rowAnchor,d;t[9]===r.isFirstRow?d=t[10]:(d=iO(r.isFirstRow),t[9]=r.isFirstRow,t[10]=d);let f;t[11]!==r.rowAnchor||t[12]!==n||t[13]!==d?(f=(0,Z.jsx)(oO,{editor:n,anchor:u,axis:`row`,items:d}),t[11]=r.rowAnchor,t[12]=n,t[13]=d,t[14]=f):f=t[14];let p;return t[15]!==l||t[16]!==f?(p=(0,Z.jsxs)(`div`,{className:`ok-table-cell-handle-layer`,children:[l,f]}),t[15]=l,t[16]=f,t[17]=p):p=t[17],p}function lO(e){let{fragment:t,docName:n}=e,r=!1,i=!1,a=!1,o=()=>{r=!0},s=e=>{console.warn(`[walk-currency] ${e} at view init — stale pre-warm cannot be invalidated: a remote edit that landed in the construct→mount gap will not render, and the first local transaction may silently erase it from the CRDT for every peer and disk (vendored y-tiptap contract change? re-verify y-tiptap.cjs:263-268)`)},c=()=>{i&&(i=!1,t.unobserveDeep(o))},l=e=>{let t=T.getState(e.state)?.binding;if(!t){Tl.count(`ok/editor/walk-currency-disarmed`,{docName:n,reason:`no-binding`}),s(`no ySync binding on "${n}"`);return}if(typeof t._forceRerender!=`function`){Tl.count(`ok/editor/walk-currency-disarmed`,{docName:n,reason:`no-force-rerender`}),s(`ySync binding on "${n}" exposes no _forceRerender`);return}Tl.count(`ok/editor/pattern-d-stale-prewarm`,{docName:n}),t._forceRerender()};return pr.create({name:`walkCurrency`,onBeforeCreate(){t.observeDeep(o),i=!0},onDestroy(){c()},addProseMirrorPlugins(){return[new Mr({view:e=>(a||(a=!0,c(),r&&l(e)),{})})]}})}var uO=new WeakMap;function dO(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=oi(e.color),n.textContent=e.name,t.append(n),t}var fO={state:`idle`,count:0,lastFiredAt:null,position:`append`,lastAgentId:null},pO=100,mO=100,hO=3,gO=250;function _O(e){return`contentComponent`in e&&`isEditorContentInitialized`in e}function vO(e,t){let n=he(e);if(!n||t.contains(n.dom))return!1;if(!_O(e))return console.warn(`[TiptapEditor] TipTap EditorContent binding fields missing; detached editor repair skipped`),!1;let r=e;if(r.contentComponent==null)return!1;try{n.setProps({nodeViews:{}})}catch{}return r.contentComponent=null,r.isEditorContentInitialized=!1,!0}function yO(){let e=new Xn({extensions:li});return{mdManager:e,text:He({mdManager:e}),html:o({mdManager:e}),paste:kt({mdManager:e}),drop:_t({mdManager:e})}}function bO(e,t){return t?{collaboration:nt.configure({document:e.document,ySyncOptions:{mapping:t}}),guard:[lO({fragment:e.document.getXmlFragment(`default`),docName:e.configuration.name??``})]}:{collaboration:nt.configure({document:e.document}),guard:[]}}function xO(e){let{provider:t,placeholder:n,prebuiltMapping:r,onWedged:i}=e,{collaboration:a,guard:o}=bO(t,r);return[...St.map(e=>e.name===`link`||e.name===`wikiLink`||e.name===`jsxComponent`?e.configure({docName:t.configuration.name??``}):e),_x.configure({placeholder:n??`Type '/' for commands`,showOnlyCurrent:!0}),a,pr.create({name:`imageUploadDecoration`,addProseMirrorPlugins(){return[ze]}}),pr.create({name:`collaborationCursor`,addProseMirrorPlugins(){let e=t.awareness;if(!e)throw Error(`[TiptapEditor] HocuspocusProvider has no awareness instance — cursor plugin cannot initialize`);return[_e(e,{cursorBuilder:dO})]}}),pr.create({name:`bindingStalenessGuard`,addProseMirrorPlugins(){return[tE({fragment:t.document.getXmlFragment(`default`),docName:t.configuration.name??``,onWedged:i??(()=>{})})]}}),...o,VD]}function SO(e){let{provider:t,clipboard:n,ctorStart:r}=e;return{onBeforeCreate:({editor:e})=>{uO.set(e,r)},onCreate:({editor:e})=>{n.html.setView(e.view);let r=uO.get(e);if(uO.delete(e),r==null)return;let i=performance.now();Tl(`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:HD(n.drop,e.onSidebarDrop)},extensions:UT(xO(e))}}function CO(e){let{provider:t,placeholder:n,clipboard:r,ctorStart:i,onWedged:a,onSidebarDrop:o}=e,s=t.document.getXmlFragment(`default`),c=new Map,l=SO({provider:t,placeholder:n,clipboard:r,ctorStart:i,prebuiltMapping:c,onWedged:a,onSidebarDrop:o}),u=l.onBeforeCreate;return{...l,onBeforeCreate:e=>{u?.(e);let{editor:t}=e,{doc:n,mapping:r}=de(s,t.schema);r.forEach((e,t)=>{c.set(t,e)}),t.options.content=n.toJSON()},element:null}}var wO=e=>{let t=(0,$.c)(24),{provider:n,placeholder:r,isSourceMode:i,portalTarget:a}=e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(fO),c=GT(),{principal:l,activeDocName:u,recycleDocument:d,openTarget:f}=mt(),m=n.configuration.name??``,[h]=(0,Q.useState)(yO),g;t[0]!==h||t[1]!==m||t[2]!==f||t[3]!==r||t[4]!==n||t[5]!==d?(g=()=>()=>({editor:new Ln(CO({provider:n,placeholder:r,clipboard:h,ctorStart:performance.now(),onWedged:e=>{let{externalSeq:t,appliedSeq:n}=e;Tl(`ok/editor/binding-wedge-recycle`,{docName:m,externalSeq:t,appliedSeq:n}),d(m)},onSidebarDrop:e=>{UD(e,f)}})),ydoc:n.document,ytext:n.document.getText(`source`),provider:n}),t[0]=h,t[1]=m,t[2]=f,t[3]=r,t[4]=n,t[5]=d,t[6]=g):g=t[6];let[_]=(0,Q.useState)(g),v,y;if(t[7]!==_||t[8]!==m||t[9]!==n.document){let e={viewCount:0,bytes:n.document.getText(`source`).length},r=p(m)??crypto.randomUUID();v=Q.use,y=R({docName:m,mountId:r,construct:_,sizeStats:e}),t[7]=_,t[8]=m,t[9]=n.document,t[10]=v,t[11]=y}else v=t[10],y=t[11];let b=v(y),x=b.editor,S,C;t[12]===b?(S=t[13],C=t[14]):(S=()=>()=>{it(b)},C=[b],t[12]=b,t[13]=S,t[14]=C),(0,Q.useEffect)(S,C);let w;return t[15]!==u||t[16]!==m||t[17]!==x||t[18]!==c||t[19]!==i||t[20]!==a||t[21]!==l||t[22]!==n?(w=(0,Z.jsx)(TO,{provider:n,isSourceMode:i,docName:m,activeDocName:u,identity:c,principal:l,editor:x,wrapperRef:o,flashStateRef:s,portalTarget:a}),t[15]=u,t[16]=m,t[17]=x,t[18]=c,t[19]=i,t[20]=a,t[21]=l,t[22]=n,t[23]=w):w=t[23],w},TO=e=>{let t=(0,$.c)(98),{provider:n,isSourceMode:r,docName:i,activeDocName:a,identity:o,principal:s,editor:c,wrapperRef:l,flashStateRef:u,portalTarget:d}=e,f=(0,Q.useRef)(null),[p,m]=(0,Q.useState)(0),h,g;t[0]===d?(h=t[1],g=t[2]):(h=()=>{let e=f.current;if(e)return e.appendChild(d),()=>{d.parentNode===e&&e.removeChild(d)}},g=[d],t[0]=d,t[1]=h,t[2]=g),(0,Q.useLayoutEffect)(h,g);let v,y;t[3]!==c||t[4]!==d?(v=()=>{vO(c,d)&&m(EO)},y=[c,d],t[3]=c,t[4]=d,t[5]=v,t[6]=y):(v=t[5],y=t[6]),(0,Q.useEffect)(v,y);let b;t[7]!==c||t[8]!==n.configuration.name?(b=()=>(pt(c,n.configuration.name??null),()=>{pt(c,null)}),t[7]=c,t[8]=n.configuration.name,t[9]=b):b=t[9];let x;t[10]!==c||t[11]!==n?(x=[c,n],t[10]=c,t[11]=n,t[12]=x):x=t[12],(0,Q.useEffect)(b,x);let S;t[13]!==c||t[14]!==n.configuration.name?(S=()=>{let e=n.configuration.name;if(e)return N(e,c),()=>ye(e,c)},t[13]=c,t[14]=n.configuration.name,t[15]=S):S=t[15];let C;t[16]!==c||t[17]!==n?(C=[c,n],t[16]=c,t[17]=n,t[18]=C):C=t[18],(0,Q.useEffect)(S,C);let w;t[19]!==c||t[20]!==n.configuration.name?(w=()=>{let e=n.configuration.name;if(!e)return;let t=null,r=()=>{t=null,nu(e,`wysiwyg`,au(c)),gu(e,`wysiwyg`,_u(c,e))},i=()=>{t&&clearTimeout(t),t=setTimeout(r,120)};return r(),c.on(`selectionUpdate`,i),c.on(`update`,i),()=>{t&&clearTimeout(t),c.off(`selectionUpdate`,i),c.off(`update`,i),nu(e,`wysiwyg`,null),gu(e,`wysiwyg`,null)}},t[19]=c,t[20]=n.configuration.name,t[21]=w):w=t[21];let T;t[22]!==c||t[23]!==n?(T=[c,n],t[22]=c,t[23]=n,t[24]=T):T=t[24],(0,Q.useEffect)(w,T);let E;t[25]!==c||t[26]!==n.configuration.name?(E=()=>{},t[25]=c,t[26]=n.configuration.name,t[27]=E):E=t[27];let D;t[28]!==c||t[29]!==n?(D=[c,n],t[28]=c,t[29]=n,t[30]=D):D=t[30],(0,Q.useEffect)(E,D);let O,k;t[31]===c?(O=t[32],k=t[33]):(O=()=>{let e=DO,t=null,n=()=>{if(t||c.isDestroyed)return;let n=he(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 he(c)?n():c.on(`create`,n),()=>{c.off(`create`,n),r()}},k=[c],t[31]=c,t[32]=O,t[33]=k),(0,Q.useEffect)(O,k);let A,j;t[34]!==i||t[35]!==c?(A=()=>{let e=!1,t=()=>{if(e||c.isDestroyed||!he(c))return;e=!0;let t=B(i)?.selection??null;if(t)try{let e=c.state.doc.content.size;if(t.type===`text`){let n=Math.max(0,Math.min(t.anchor,e)),r=Math.max(0,Math.min(t.head,e));c.commands.setTextSelection({from:n,to:r})}else{let n=Math.max(0,Math.min(t.from,e));c.commands.setNodeSelection(n)}}catch(e){let t=e,n=t instanceof Error?t.message:String(t);console.warn(JSON.stringify({event:`ok-editor-selection-restore-failed`,docName:i,message:n})),Tl(`ok/editor/selection-restore-failed`,{docName:i,message:n})}G(i)};if(he(c)){t();return}return c.on(`create`,t),()=>{c.off(`create`,t)}},j=[c,i],t[34]=i,t[35]=c,t[36]=A,t[37]=j):(A=t[36],j=t[37]),(0,Q.useEffect)(A,j);let M,P;t[38]!==u||t[39]!==n.document||t[40]!==l?(M=()=>{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)},Fn)};c(fO);let f=()=>{if(Nr(e),!di(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`?di(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)}},P=[n.document,u,l],t[38]=u,t[39]=n.document,t[40]=l,t[41]=M,t[42]=P):(M=t[41],P=t[42]),(0,Q.useEffect)(M,P);let F,I;t[43]!==a||t[44]!==i||t[45]!==c||t[46]!==n?(F=()=>{let e=0,t,r=null,o=null,s=null,l=function(){if(e<pO){e+=1,t=window.setTimeout(p,mO);return}r=null,o=null,e=0},u=function(e){let t=he(c);if(!t)return null;let n=CSS.escape(e);return t.dom.querySelector(`#${n}`)??t.dom.querySelector(`[data-mirror-source-id="${n}"]`)},d=function(e){let t=u(e);return t?(t.scrollIntoView({behavior:`smooth`,block:`start`}),!0):!1},f=function(e,n){let r=hO,o=()=>{t=void 0,!(i!==a||window.location.hash!==n)&&(d(e),--r,r>0&&(t=window.setTimeout(o,gO)))};t=window.setTimeout(o,gO)};function p(){if(!r||i!==a)return;let t=r,n=o;if(!n){l();return}d(t)?(s=n,r=null,o=null,e=0,f(t,n)):l()}let m=function(){if(i!==a)return;let n=window.location.hash;if(!r&&s===n)return;let c=bl(n);if(!c){s=n;return}r=c,o=n,e=0,t!==void 0&&(clearTimeout(t),t=void 0),p()},h=function(){if(i===a){if(r){p();return}m()}};return m(),n.on(`synced`,h),c.on(`transaction`,h),window.addEventListener(`hashchange`,m),()=>{t!==void 0&&clearTimeout(t),n.off(`synced`,h),c.off(`transaction`,h),window.removeEventListener(`hashchange`,m)}},I=[n,c,i,a],t[43]=a,t[44]=i,t[45]=c,t[46]=n,t[47]=F,t[48]=I):(F=t[47],I=t[48]),(0,Q.useEffect)(F,I);let L,R;t[49]===c?(L=t[50],R=t[51]):(L=()=>{let e=function(e){let t=e.detail;if(!t||t.mode!==`wysiwyg`||c.isDestroyed)return;let n=he(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(eu,e),()=>window.removeEventListener(eu,e)},R=[c],t[49]=c,t[50]=L,t[51]=R),(0,Q.useEffect)(L,R);let z;t[52]!==a||t[53]!==i||t[54]!==o||t[55]!==r||t[56]!==s||t[57]!==n.awareness?(z=()=>{let e=n.awareness;if(e){if(i!==a){e.setLocalState(null);return}e.setLocalState({user:KT({principal:s,identity:o}),mode:r?`source`:`wysiwyg`})}},t[52]=a,t[53]=i,t[54]=o,t[55]=r,t[56]=s,t[57]=n.awareness,t[58]=z):z=t[58];let V;t[59]!==a||t[60]!==i||t[61]!==o||t[62]!==r||t[63]!==s||t[64]!==n?(V=[n,i,a,o,s,r],t[59]=a,t[60]=i,t[61]=o,t[62]=r,t[63]=s,t[64]=n,t[65]=V):V=t[65],(0,Q.useEffect)(z,V);let H,U;t[66]!==c||t[67]!==r?(H=()=>(_(c,r),()=>{_(c,!1)}),U=[c,r],t[66]=c,t[67]=r,t[68]=H,t[69]=U):(H=t[68],U=t[69]),(0,Q.useEffect)(H,U);let W;t[70]!==a||t[71]!==i||t[72]!==c||t[73]!==r?(W=!r&&(0,Z.jsx)(vD,{editor:c,shortcutEnabled:i===a}),t[70]=a,t[71]=i,t[72]=c,t[73]=r,t[74]=W):W=t[74];let K;t[75]!==c||t[76]!==r?(K=!r&&(0,Z.jsx)(cO,{editor:c}),t[75]=c,t[76]=r,t[77]=K):K=t[77];let ee;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Z.jsx)(`div`,{ref:f,style:{display:`contents`}}),t[78]=ee):ee=t[78];let te;t[79]!==c||t[80]!==p?(te=(0,Z.jsx)(ot,{editor:c,className:`tiptap-editor-portal-content h-full`},p),t[79]=c,t[80]=p,t[81]=te):te=t[81];let ne;t[82]!==d||t[83]!==te?(ne=(0,_d.createPortal)(te,d),t[82]=d,t[83]=te,t[84]=ne):ne=t[84];let re;t[85]===c?re=t[86]:(re=(0,Z.jsx)(wT,{editor:c}),t[85]=c,t[86]=re);let ie;t[87]===c?ie=t[88]:(ie=ut(c),t[87]=c,t[88]=ie);let ae;t[89]===ie.store?ae=t[90]:(ae=(0,Z.jsx)(zt,{store:ie.store}),t[89]=ie.store,t[90]=ae);let oe;return t[91]!==W||t[92]!==K||t[93]!==ne||t[94]!==re||t[95]!==ae||t[96]!==l?(oe=(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:[W,K,ee,ne,re,ae]}),t[91]=W,t[92]=K,t[93]=ne,t[94]=re,t[95]=ae,t[96]=l,t[97]=oe):oe=t[97],oe};function EO(e){return e+1}function DO(){return C()}var OO=null;function kO(e){let t=(0,$.c)(3),n=(0,Q.useRef)(null),r,i;return t[0]===e?(r=t[1],i=t[2]):(r=()=>{if(!e)return;let t=n.current;if(!t)return;let r={};OO=r;let i=document.documentElement,a=null,o=()=>{if(OO!==r)return;let e=`${t.offsetHeight}px`;e!==a&&(a=e,i.style.setProperty(`--conflict-footer-height`,e))};o();let s=new ResizeObserver(o);return s.observe(t),()=>{s.disconnect(),OO===r&&(OO=null,i.style.removeProperty(`--conflict-footer-height`))}},i=[e],t[0]=e,t[1]=r,t[2]=i),(0,Q.useEffect)(r,i),n}var AO=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 jO(e,t,n,r,i,a){if(e==r)return[];let o=VO(e,t,n,r,i,a),s=HO(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 AO(t,n,i,a)];if(c>l){let o=e.slice(t,n).indexOf(r.slice(i,a));if(o>-1)return[new AO(t,t+o,i,i),new AO(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 AO(t,t,i,i+o),new AO(n,n,i+o+c,a)]}if(c==1||l==1)return[new AO(t,n,i,a)];let u=WO(e,t,n,r,i,a);if(u){let[o,s,c]=u;return jO(e,t,o,r,i,s).concat(jO(e,o+c,n,r,s+c,a))}return FO(e,t,n,r,i,a)}var MO=1e9,NO=0,PO=!1;function FO(e,t,n,r,i,a){let o=n-t,s=a-i;if(MO<1e9&&Math.min(o,s)>MO*16||NO>0&&Date.now()>NO)return Math.min(o,s)>MO*64?[new AO(t,n,i,a)]:GO(e,t,n,r,i,a);let c=Math.ceil((o+s)/2);LO.reset(c),RO.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:RO,f=d?null:LO;for(let p=0;p<c;p++){if(p>MO||NO>0&&!(p&63)&&Date.now()>NO)return GO(e,t,n,r,i,a);let m=LO.advance(p,o,s,c,d,!1,l)||RO.advance(p,o,s,c,f,!0,u);if(m)return zO(e,t,n,t+m[0],r,i,a,i+m[1])}return[new AO(t,n,i,a)]}var IO=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}},LO=new IO,RO=new IO;function zO(e,t,n,r,i,a,o,s){let c=!1;return!ok(e,r)&&++r==n&&(c=!0),!ok(i,s)&&++s==o&&(c=!0),c?[new AO(t,n,a,o)]:jO(e,t,r,i,a,s).concat(jO(e,r,n,i,s,o))}function BO(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function VO(e,t,n,r,i,a){if(t==n||t==a||e.charCodeAt(t)!=r.charCodeAt(i))return 0;let o=BO(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-+!ok(e,s);o>>=1}else if(i==n||l==a)return i-t;else s=i,c=l}}function HO(e,t,n,r,i,a){if(t==n||i==a||e.charCodeAt(n-1)!=r.charCodeAt(a-1))return 0;let o=BO(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-+!ok(e,s);o>>=1}else if(a==t||l==i)return n-a;else s=a,c=l}}function UO(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;;){ok(e,s)||s++;let u=s+o;if(ok(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=VO(e,u,n,r,i+f+d.length,a),c=HO(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 WO(e,t,n,r,i,a){let o=n-t,s=a-i;if(o<s){let o=WO(r,i,a,e,t,n);return o&&[o[1],o[0],o[2]]}return o<4||s*2<o?null:UO(e,t,n,r,i,a,Math.floor(o/4),-1)}function GO(e,t,n,r,i,a){PO=!0;let o=n-t,s=a-i,c;if(o<s){let s=UO(r,i,a,e,t,n,Math.floor(o/6),50);c=s&&[s[1],s[0],s[2]]}else c=UO(e,t,n,r,i,a,Math.floor(s/6),50);if(!c)return[new AO(t,n,i,a)];let[l,u,d]=c;return jO(e,t,l,r,i,u).concat(jO(e,l+d,n,r,u+d,a))}function KO(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 AO(r.fromA,i.toA,r.fromB,i.toB),e.splice(n--,1))}}function qO(e,t,n){for(;;){KO(n,1);let r=!1;for(let i=0;i<n.length;i++){let a=n[i],o,s;(o=VO(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new AO(a.fromA+o,a.toA,a.fromB+o,a.toB)),(s=HO(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new AO(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 AO(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 AO(a.fromA+d,a.toA+d,a.fromB+d,a.toB+d),r=!0)}if(!r)break}return n}function JO(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=tk(t,a.fromA,l),f=ek(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 AO(d,d+o,a.fromB-p,a.toB-p),d=a.fromA,f=ek(t,a.toA,c-a.toA)):l>m&&t.slice(a.toA,f)==u.slice(h,h+m)&&(a=e[i]=new AO(f-o,f,a.fromB+m,a.toB+m),f=a.toA,d=tk(t,a.fromA,a.fromA-r)),p=a.fromA-d,m=f-a.toA}if(p||m)a=e[i]=new AO(a.fromA-p,a.toA+m,a.fromB-p,a.toB+m);else if(!o){let t=rk(n,a.fromB,a.toB),r,o=t<0?-1:nk(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=rk(t,a.fromA,a.toA),r,o=n<0?-1:nk(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 KO(e,3),e}var YO;try{YO=RegExp(`[\\p{Alphabetic}\\p{Number}]`,`u`)}catch{}function XO(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function ZO(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?+!!XO(n):YO?!ik(n)||t==e.length-1?+!!YO.test(String.fromCharCode(n)):YO.test(e.slice(t,t+2))?2:0:0}function QO(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?+!!XO(n):YO?!ak(n)||t==1?+!!YO.test(String.fromCharCode(n)):YO.test(e.slice(t-2,t))?2:0:0}var $O=8;function ek(e,t,n){if(t==e.length||!QO(e,t))return t;for(let r=t,i=t+n,a=0;a<$O;a++){let t=ZO(e,r);if(!t||r+t>i)return r;r+=t}return t}function tk(e,t,n){if(!t||!ZO(e,t))return t;for(let r=t,i=t-n,a=0;a<$O;a++){let t=QO(e,r);if(!t||r-t<i)return r;r-=t}return t}function nk(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function rk(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}var ik=e=>e>=55296&&e<=56319,ak=e=>e>=56320&&e<=57343;function ok(e,t){return!t||t==e.length||!ik(e.charCodeAt(t-1))||!ak(e.charCodeAt(t))}function sk(e,t,n){let r=n?.override;return r?r(e,t):(MO=(n?.scanLimit??1e9)>>1,NO=n?.timeout?Date.now()+n.timeout:0,PO=!1,qO(e,t,jO(e,0,e.length,t,0,t.length)))}function ck(){return!PO}function lk(e,t,n){return JO(sk(e,t,n),e,t)}var uk=Vl.define({combine:e=>e[0]}),dk=Hl.define(),fk=Vl.define(),pk=Il.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(dk)&&(e=n.value);for(let n of t.state.facet(fk))e=n(e,t);return e}});function mk(e){let t=e.field(pk,!1);if(!t)return null;let n=e.facet(uk);return{chunks:t,side:n?n.side:null}}var hk=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 vk(lk(e.toString(),t.toString(),n),e,t,0,0,ck())}static updateA(e,t,n,r,i){return Sk(xk(e,r,!0,n.length),e,t,n,i)}static updateB(e,t,n,r,i){return Sk(xk(e,r,!1,t.length),e,t,n,i)}};function gk(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 _k(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 vk(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length;s++){let c=e[s],[l,u]=gk(c.fromA+r,c.fromB+i,t,n),[d,f]=_k(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]=gk(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]=_k(a.toA+r,a.toB+i,t,n),s++}o.push(new hk(p,l,Math.max(l,d),u,Math.max(u,f),a))}return o}var yk=1e3;function bk(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 xk(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>yk&&([l,d]=bk(e,a-yk,n,!0)),o<t.length-yk&&([u,f]=bk(e,o+yk,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 Sk(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=lk(n.sliceString(d,p),r.sliceString(f,m),i);for(let e of vk(h,n,r,d,f,ck()))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 Ck={scanLimit:500},wk=Ul.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=Pk(e))}update(e){(e.docChanged||e.viewportChanged||Ek(e.startState,e.state)||Dk(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=Pk(e.view))}},{decorations:e=>e.deco}),Tk=Nl.low(ql({class:`cm-changeGutter`,markers:e=>e.plugin(wk)?.gutter||Yl.empty}));function Ek(e,t){return e.field(pk,!1)!=t.field(pk,!1)}function Dk(e,t){return e.facet(uk)!=t.facet(uk)}var Ok=zl.line({class:`cm-changedLine`}),kk=zl.mark({class:`cm-changedText`}),Ak=zl.mark({tagName:`ins`,class:`cm-insertedLine`}),jk=zl.mark({tagName:`del`,class:`cm-deletedLine`}),Mk=new class extends Kl{constructor(){super(...arguments),this.elementClass=`cm-changedLineGutter`}};function Nk(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,Ok),i.add(o,s,n?jk:Ak),a&&a.add(o,o,Mk);for(let l=t.iterRange(o,s-1),u=o;!l.next().done;){if(l.lineBreak){u++,i.add(u,u,Ok),a&&a.add(u,u,Mk);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,kk),s<t)c++;else break}u=t}}}function Pk(e){let t=e.state.field(pk),{side:n,highlightChanges:r,markGutter:i,overrideChunk:a}=e.state.facet(uk),o=n==`a`,s=new Bl,c=i?new Bl: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))&&Nk(n,e.state.doc,o,r,s,c)}return{deco:s.finish(),gutter:c&&c.finish()}}var Fk=class extends Ml{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}},Ik=Hl.define({map:(e,t)=>e.map(t)}),Lk=Il.define({create:()=>zl.none,update:(e,t)=>{for(let e of t.effects)if(e.is(Ik))return e.value;return e.map(t.changes)},provide:e=>Gl.decorations.from(e)}),Rk=.01;function zk(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 Bk(e,t,n){let r=new Bl,i=new Bl,a=e.state.field(Lk).iter(),o=t.state.field(Lk).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<-Rk?(l-=n,r.add(s,s,zl.widget({widget:new Fk(-n),block:!0,side:-1}))):n>Rk&&(u+=n,i.add(c,c,zl.widget({widget:new Fk(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<Rk?r.add(e.state.doc.length,e.state.doc.length,zl.widget({widget:new Fk(-p),block:!0,side:1})):p>Rk&&i.add(t.state.doc.length,t.state.doc.length,zl.widget({widget:new Fk(p),block:!0,side:1}));let m=r.finish(),h=i.finish();zk(m,e.state.field(Lk))||e.dispatch({effects:Ik.of(m)}),zk(h,t.state.field(Lk))||t.dispatch({effects:Ik.of(h)})}var Vk=Hl.define({map:(e,t)=>t.mapPos(e)}),Hk=class extends Ml{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:Vk.of(n)});let{side:r,sibling:i}=e.state.facet(uk);i&&i().dispatch({effects:Vk.of(Uk(n,e.state.field(pk),r==`a`))})}),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return`collapsed-unchanged-code`}};function Uk(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 Wk=Il.define({create(e){return zl.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Vk)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>Gl.decorations.from(e)});function Gk({margin:e=3,minSize:t=4}){return Wk.init(n=>Kk(n,e,t))}function Kk(e,t,n){let r=new Bl,i=e.facet(uk).side==`a`,a=e.field(pk),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,zl.replace({widget:new Hk(d),block:!0})),!c)break;o=e.doc.lineAt(Math.min(e.doc.length,i?c.toA:c.toB)).number}return r.finish()}var qk=Gl.styleModule.of(new Jl({".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`}})),Jk=Gl.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`}}),Yk=new Wl,Xk=new Wl,Zk=class{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||Ck;let t=[Nl.low(wk),Jk,qk,Lk,Gl.updateListener.of(e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some(e=>e.effects.some(e=>e.is(Ik)))&&this.measure()})],n=[uk.of({side:`a`,sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&n.push(Tk);let r=Fl.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],Gl.editorAttributes.of({class:`cm-merge-a`}),Xk.of(n),t]}),i=[uk.of({side:`b`,sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&i.push(Tk);let a=Fl.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],Gl.editorAttributes.of({class:`cm-merge-b`}),Xk.of(i),t]});this.chunks=hk.build(r.doc,a.doc,this.diffConf);let o=[pk.init(()=>this.chunks),Yk.of(e.collapseUnchanged?Gk(e.collapseUnchanged):[])];r=r.update({effects:Hl.appendConfig.of(o)}).state,a=a.update({effects:Hl.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 Gl({state:r,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new Gl({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),Pl.empty(e[0].startState.doc.length));this.chunks=t==this.a?hk.updateA(this.chunks,n.newDoc,this.b.state.doc,r,this.diffConf):hk.updateB(this.chunks,this.a.state.doc,n.newDoc,r,this.diffConf),t.update([...e,n.state.update({effects:dk.of(this.chunks)})]);let i=t==this.a?this.b:this.a;i.update([i.state.update({effects:dk.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(uk),o=n?e.gutter!==!1:r.markGutter,s=t?e.highlightChanges!==!1:r.highlightChanges;i.push(Xk.reconfigure([uk.of({side:`a`,sibling:()=>this.b,highlightChanges:s,markGutter:o}),o?Tk:[]])),a.push(Xk.reconfigure([uk.of({side:`b`,sibling:()=>this.a,highlightChanges:s,markGutter:o}),o?Tk:[]]))}if(r){let t=Yk.reconfigure(e.collapseUnchanged?Gk(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(){Bk(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=Qk(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=Qk(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 Qk(e){let t=e.nextSibling;return e.remove(),t}var $k=new class extends Kl{constructor(){super(...arguments),this.elementClass=`cm-deletedLineGutter`}},eA=Nl.low(ql({class:`cm-changeGutter`,markers:e=>e.plugin(wk)?.gutter||Yl.empty,widgetMarker:(e,t)=>t instanceof aA?$k:null}));function tA(e){let t=typeof e.original==`string`?Rl.of(e.original.split(/\r?\n/)):e.original,n=e.diffConfig||Ck;return[Nl.low(wk),uA,Jk,Gl.editorAttributes.of({class:`cm-merge-b`}),fk.of((e,t)=>{let r=t.effects.find(e=>e.is(nA));return r&&(e=hk.updateA(e,r.value.doc,t.startState.doc,r.value.changes,n)),t.docChanged&&(e=hk.updateB(e,t.state.field(rA),t.newDoc,t.changes,n)),e}),uk.of({highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1,syntaxHighlightDeletions:e.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:e.mergeControls??!0,overrideChunk:e.allowInlineDiffs?gA:void 0,side:`b`}),rA.init(()=>t),e.gutter===!1?[]:eA,e.collapseUnchanged?Gk(e.collapseUnchanged):[],pk.init(e=>hk.build(t,e.doc,n))]}var nA=Hl.define(),rA=Il.define({create:()=>Rl.empty,update(e,t){for(let n of t.effects)n.is(nA)&&(e=n.value.doc);return e}}),iA=new WeakMap,aA=class extends Ml{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 oA(e,t,n){let r=iA.get(t.changes);if(r)return r;let i=zl.widget({block:!0,side:-1,widget:new aA(r=>{let{highlightChanges:i,syntaxHighlightDeletions:a,syntaxHighlightDeletionsMaxLength:o,mergeControls:s}=e.facet(uk),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(),sA(r,r.posAtDOM(c))},i=e=>{e.preventDefault(),cA(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(rA).sliceString(t.fromA,t.endA),u=a&&e.facet(Xl),d=h(),f=t.changes,p=0,m=!1;function h(){let e=c.appendChild(document.createElement(`div`));return e.className=`cm-deletedLine`,e.appendChild(document.createElement(`del`))}function g(e,t,n){for(let r=e;r<t;){if(l.charAt(r)==`
28
28
  `){d.firstChild||d.appendChild(document.createElement(`br`)),d=h(),r++;continue}let e=t,a=n+(m?` cm-deletedText`:``),o=!1,s=l.indexOf(`
29
- `,r);if(s>-1&&s<t&&(e=s),i&&p<f.length){let t=Math.max(0,m?f[p].toA:f[p].fromA);t<=e&&(e=t,m&&p++,o=!0)}if(e>r){let t=document.createTextNode(l.slice(r,e));if(a){let e=d.appendChild(document.createElement(`span`));e.className=a,e.appendChild(t)}else d.appendChild(t);r=e}o&&(m=!m)}}if(u&&t.toA-t.fromA<=o){let t=u.parser.parse(l),n=0;Ll(t,{style:t=>Zl(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 iA.set(t.changes,i),i}function sA(e,t){let{state:n}=e,r=t??n.selection.main.head,i=e.state.field(pk).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(rA);i.fromB!=i.toB&&i.toA<=o.length&&(a+=e.state.lineBreak);let s=Pl.of({from:i.fromA,to:Math.min(o.length,i.toA),insert:a},o.length);return e.dispatch({effects:nA.of({doc:s.apply(o),changes:s}),userEvent:`accept`}),!0}function cA(e,t){let{state:n}=e,r=t??n.selection.main.head,i=n.field(pk).find(e=>e.fromB<=r&&e.endB>=r);if(!i)return!1;let a=n.field(rA).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 lA(e){let t=new Bl;for(let n of e.field(pk)){let r=e.facet(uk).overrideChunk&&fA(e,n);t.add(n.fromB,n.fromB,oA(e,n,!!r))}return t.finish()}var uA=Il.define({create:e=>lA(e),update(e,t){return t.state.field(pk,!1)==t.startState.field(pk,!1)?e:lA(t.state)},provide:e=>Gl.decorations.from(e)}),dA=new WeakMap;function fA(e,t){let n=dA.get(t);if(n!==void 0)return n;n=null;let r=e.field(rA),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(zl.widget({widget:new pA(t),side:-1}).range(s+n.fromB))}n.fromB<n.toB&&e.push(kk.range(s+n.fromB,s+n.toB))}i<t.endA-t.fromA-a*2&&(n=e)}return dA.set(t,n),n}var pA=class extends Ml{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}},mA=new class extends Kl{constructor(){super(...arguments),this.elementClass=`cm-inlineChangedLineGutter`}},hA=zl.line({class:`cm-inlineChangedLine`});function gA(e,t,n,r){let i=fA(e,t),a=0;if(!i)return!1;for(let o=e.doc.lineAt(t.fromB);;){for(r&&r.add(o.from,o.from,mA),n.add(o.from,o.from,hA);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 _A=q({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}}),vA=E({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}}),yA=Gl.theme({".cm-deletedChunk .cm-chunkButtons":{display:`flex`,gap:`0.25rem`},".cm-deletedChunk .cm-chunkButtons button[data-slot='button']":{margin:`0`,border:`1px solid transparent`,borderRadius:`min(var(--radius-md), 10px)`,color:`var(--primary-foreground)`},".cm-deletedChunk .cm-chunkButtons button[data-slot='button'][data-variant='destructive']":{color:`var(--destructive)`}});function bA({addControl:e,nextId:t,removeControl:n,root:r}){return(i,a)=>{let o=document.createElement(`span`);o.className=`inline-flex`;let s=t();return e({id:s,host:o,type:i,action:a}),queueMicrotask(()=>{r.contains(o)||n(s)}),o}}function xA(e){let t=(0,$.c)(33),{oldContent:n,newContent:r,layout:i,conflictMode:a,previewMode:o,oursOverride:s,onResolve:c,onAbort:l}=e,{_:u}=$t(),d=s??r,f=(0,Q.useRef)(null),p=(0,Q.useRef)(null),m=(0,Q.useRef)(0),{resolvedTheme:h}=Mn(),g=(0,Q.useRef)(c),_=(0,Q.useRef)(l),[v,y]=(0,Q.useState)(null),b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b=[],t[0]=b):b=t[0];let[x,S]=(0,Q.useState)(b),C=kO(a===!0),w;t[1]!==l||t[2]!==c?(w=()=>{g.current=c,_.current=l},t[1]=l,t[2]=c,t[3]=w):w=t[3],(0,Q.useEffect)(w);let T,E;t[4]!==a||t[5]!==d||t[6]!==i||t[7]!==n||t[8]!==o||t[9]!==h?(T=()=>{let e=f.current;if(!e)return;S([]);let t=new Map,r=!1,s=e=>{r||!t.delete(e)||S(t=>t.filter(t=>t.id!==e))},c=new MutationObserver(()=>{for(let[n,r]of t)e.contains(r)||s(n)});c.observe(e,{childList:!0,subtree:!0});let l=h===`dark`?_A:vA,u=[Gl.editable.of(!1),Fl.readOnly.of(!0)],g=[uu,Ql(),...u,l,Gl.lineWrapping];if(p.current&&=(p.current.destroy(),null),o)p.current=new Gl({doc:d,extensions:g,parent:e}),y(null);else if(a){let i=bA({addControl:e=>{r||(t.set(e.id,e.host),S(t=>[...t,e]))},nextId:()=>(m.current+=1,m.current),removeControl:s,root:e}),a=new Gl({doc:d,extensions:[uu,Ql(),Gl.editable.of(!1),l,yA,Gl.lineWrapping,tA({original:n,highlightChanges:!0,gutter:!0,mergeControls:i,collapseUnchanged:{margin:3,minSize:4}}),Gl.updateListener.of(e=>{let t=mk(e.state);y(t?t.chunks.length:0)})],parent:e});p.current=a;let o=mk(a.state);y(o?o.chunks.length:0)}else i===`split`?p.current=new Zk({a:{doc:n,extensions:g},b:{doc:d,extensions:g},parent:e,highlightChanges:!0,gutter:!0,collapseUnchanged:{margin:3,minSize:4}}):p.current=new Gl({doc:d,extensions:[...g,tA({original:n,highlightChanges:!0,gutter:!0,mergeControls:!1,collapseUnchanged:{margin:3,minSize:4}})],parent:e});return()=>{r=!0,c.disconnect(),p.current&&=(p.current.destroy(),null)}},E=[n,d,i,h,a,o],t[4]=a,t[5]=d,t[6]=i,t[7]=n,t[8]=o,t[9]=h,t[10]=T,t[11]=E):(T=t[10],E=t[11]),(0,Q.useEffect)(T,E);let D;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(D=function(){let e=p.current;!e||!(e instanceof Gl)||g.current?.(e.state.doc.toString())},t[12]=D):D=t[12];let O=D,k;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(k=function(){let e=p.current;!e||!(e instanceof Gl)||Se(e)},t[13]=k):k=t[13];let A=k,j=v===0,M;t[14]!==u||t[15]!==v?(M=v===null?``:v===0?u({id:`lPzyrU`}):Kc._({id:`8FqTCr`,values:{chunksRemaining:v}}),t[14]=u,t[15]=v,t[16]=M):M=t[16];let N=M,P;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(`div`,{ref:f,className:`diff-view min-h-0 flex-1 overflow-y-auto subtle-scrollbar`}),t[17]=P):P=t[17];let F;if(t[18]!==u||t[19]!==x){let e;t[21]===u?e=t[22]:(e=e=>(0,_d.createPortal)((0,Z.jsx)(X,{type:`button`,variant:e.type===`accept`?`default`:`destructive`,size:`xs`,onClick:t=>{e.action(t.nativeEvent)},children:e.type===`accept`?u({id:`g3UF2V`}):u({id:`1t_NnN`})}),e.host,e.id),t[21]=u,t[22]=e),F=x.map(e),t[18]=u,t[19]=x,t[20]=F}else F=t[20];let I;t[23]!==j||t[24]!==C||t[25]!==a||t[26]!==N||t[27]!==l||t[28]!==c?(I=a&&(0,Z.jsxs)(`div`,{ref:C,className:`flex items-center justify-between gap-2 px-3 py-2 border-t shrink-0`,children:[(0,Z.jsx)(`span`,{className:`text-xs ${j?`text-emerald-600 dark:text-emerald-400`:`text-muted-foreground`}`,children:N}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l&&(0,Z.jsx)(X,{className:`uppercase font-mono`,variant:`ghost`,size:`sm`,onClick:l,children:(0,Z.jsx)(J,{id:`XyOUTJ`})}),(0,Z.jsx)(X,{className:`uppercase font-mono`,variant:`outline`,size:`sm`,onClick:A,children:`Undo`}),c&&(0,Z.jsx)(X,{variant:`default`,size:`sm`,disabled:!j,onClick:O,children:(0,Z.jsx)(J,{id:`Lcehxn`})})]})]}),t[23]=j,t[24]=C,t[25]=a,t[26]=N,t[27]=l,t[28]=c,t[29]=I):I=t[29];let L;return t[30]!==I||t[31]!==F?(L=(0,Z.jsxs)(`div`,{className:`flex flex-col h-full`,children:[P,F,I]}),t[30]=I,t[31]=F,t[32]=L):L=t[32],L}async function SA(e,t,n){try{let r={file:e,strategy:t};n!==void 0&&(r.content=n);let i=await fetch(`/api/sync/resolve-conflict`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(i.ok)return{ok:!0};let a;try{let e=await i.json();typeof e.detail==`string`?a=e.detail:typeof e.title==`string`&&(a=e.title)}catch{}return{ok:!1,detail:a}}catch(n){let r=n instanceof Error?n.message:String(n);return console.warn(JSON.stringify({event:`conflict-resolve-dispatch-failed`,file:e,strategy:t,detail:r})),{ok:!1,detail:r}}}async function CA(e,t){return SA(e,`content`,t)}async function wA(e){return SA(e,`mine`)}async function TA(e){return SA(e,`theirs`)}async function EA(e){return SA(e,`delete`)}async function DA(e){try{let t=await fetch(`/api/sync/conflict-content?file=${encodeURIComponent(e)}&source=ytext`);if(!t.ok){let n;try{let e=await t.json();typeof e.detail==`string`?n=e.detail:typeof e.title==`string`&&(n=e.title)}catch{}return console.warn(JSON.stringify({event:`conflict-content-fetch-failed`,file:e,status:t.status,detail:n})),null}let n=await t.json(),r=n.kind===`delete-modify`||n.kind===`modify-delete`||n.kind===`both-modified`?n.kind:`both-modified`;return n.kind!==r&&console.warn(JSON.stringify({event:`conflict-kind-missing-fallback`,file:e,receivedKind:n.kind??null})),{base:n.base??``,ours:n.ours??``,theirs:n.theirs??``,kind:r}}catch(t){return console.warn(JSON.stringify({event:`conflict-content-fetch-failed`,file:e,status:null,detail:t instanceof Error?t.message:String(t)})),null}}function OA(e){let t=(0,$.c)(86),{docName:n}=e,{_:r}=$t(),{conflicts:i,loading:a}=To(),o;if(t[0]!==i||t[1]!==n){let e;t[3]===n?e=t[4]:(e=e=>ol(e.file)===n,t[3]=n,t[4]=e),o=i.find(e),t[0]=i,t[1]=n,t[2]=o}else o=t[2];let s=o,c=s?.file??`${n}.md`,[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),h=kO(l?.kind===`delete-modify`||l?.kind===`modify-delete`),g,_;t[5]===n?(g=t[6],_=t[7]):(g=()=>(console.warn(JSON.stringify({event:`editor-area-swap-to-diffview`,"doc.name":n})),()=>{console.warn(JSON.stringify({event:`editor-area-swap-from-diffview`,"doc.name":n}))}),_=[n],t[5]=n,t[6]=g,t[7]=_),(0,Q.useEffect)(g,_);let v=a||s===void 0,y,b;t[8]!==v||t[9]!==c?(y=()=>{if(v)return;let e=!1;return u(null),f(!1),DA(c).then(t=>{e||(t===null?f(!0):u(t))}),()=>{e=!0}},b=[c,v],t[8]=v,t[9]=c,t[10]=y,t[11]=b):(y=t[10],b=t[11]),(0,Q.useEffect)(y,b);let x;t[12]!==r||t[13]!==c?(x=async function(e){let t=await CA(c,e);t.ok||Ss.error(r({id:`K-h9cT`,values:{filePath:c}}),{description:t.detail})},t[12]=r,t[13]=c,t[14]=x):x=t[14];let S=x,C;t[15]!==r||t[16]!==c?(C=async function(e){m(!0);let t=await e(c);t.ok||(m(!1),Ss.error(r({id:`jPUPvG`,values:{filePath:c}}),{description:t.detail}))},t[15]=r,t[16]=c,t[17]=C):C=t[17];let w=C;if(d){let e;return t[18]===c?e=t[19]:(e=(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-sm text-muted-foreground`,children:(0,Z.jsx)(J,{id:`ajz9F8`,values:{filePath:c}})}),t[18]=c,t[19]=e),e}if(l===null){let e;return t[20]===c?e=t[21]:(e=(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-sm text-muted-foreground`,children:(0,Z.jsx)(J,{id:`DF1MtZ`,values:{filePath:c}})}),t[20]=c,t[21]=e),e}if(l.kind===`delete-modify`){let e;t[22]===l.theirs?e=t[23]:(e=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,Z.jsx)(xA,{oldContent:``,newContent:l.theirs,layout:`unified`,previewMode:!0})}),t[22]=l.theirs,t[23]=e);let n;t[24]===c?n=t[25]:(n={filePath:c},t[24]=c,t[25]=n);let r;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(r={0:(0,Z.jsx)(`span`,{className:`font-medium text-foreground`})},t[26]=r):r=t[26];let i;t[27]===n?i=t[28]:(i=(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Z.jsx)(J,{id:`V48OUT`,values:n,components:r})}),t[27]=n,t[28]=i);let a;t[29]===w?a=t[30]:(a=()=>void w(EA),t[29]=w,t[30]=a);let o;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(J,{id:`Vlc75q`}),t[31]=o):o=t[31];let s;t[32]!==p||t[33]!==a?(s=(0,Z.jsx)(X,{type:`button`,variant:`destructive`,disabled:p,onClick:a,children:o}),t[32]=p,t[33]=a,t[34]=s):s=t[34];let u;t[35]===w?u=t[36]:(u=()=>void w(TA),t[35]=w,t[36]=u);let d;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(J,{id:`3mFsc3`}),t[37]=d):d=t[37];let f;t[38]!==p||t[39]!==u?(f=(0,Z.jsx)(X,{type:`button`,variant:`default`,disabled:p,onClick:u,children:d}),t[38]=p,t[39]=u,t[40]=f):f=t[40];let m;t[41]!==s||t[42]!==f?(m=(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-3`,children:[s,f]}),t[41]=s,t[42]=f,t[43]=m):m=t[43];let g;t[44]!==h||t[45]!==i||t[46]!==m?(g=(0,Z.jsxs)(`div`,{ref:h,className:`flex flex-shrink-0 flex-wrap items-center justify-between gap-x-6 gap-y-3 border-t px-6 py-4`,children:[i,m]}),t[44]=h,t[45]=i,t[46]=m,t[47]=g):g=t[47];let _;return t[48]!==g||t[49]!==e?(_=(0,Z.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[e,g]}),t[48]=g,t[49]=e,t[50]=_):_=t[50],_}if(l.kind===`modify-delete`){let e;t[51]===l.ours?e=t[52]:(e=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,Z.jsx)(xA,{oldContent:``,newContent:l.ours,layout:`unified`,previewMode:!0})}),t[51]=l.ours,t[52]=e);let n;t[53]===c?n=t[54]:(n={filePath:c},t[53]=c,t[54]=n);let r;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(r={0:(0,Z.jsx)(`span`,{className:`font-medium text-foreground`})},t[55]=r):r=t[55];let i;t[56]===n?i=t[57]:(i=(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Z.jsx)(J,{id:`EhDLBx`,values:n,components:r})}),t[56]=n,t[57]=i);let a;t[58]===w?a=t[59]:(a=()=>void w(wA),t[58]=w,t[59]=a);let o;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(J,{id:`0NA4b3`}),t[60]=o):o=t[60];let s;t[61]!==p||t[62]!==a?(s=(0,Z.jsx)(X,{type:`button`,variant:`default`,disabled:p,onClick:a,children:o}),t[61]=p,t[62]=a,t[63]=s):s=t[63];let u;t[64]===w?u=t[65]:(u=()=>void w(EA),t[64]=w,t[65]=u);let d;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(J,{id:`qSxaOz`}),t[66]=d):d=t[66];let f;t[67]!==p||t[68]!==u?(f=(0,Z.jsx)(X,{type:`button`,variant:`destructive`,disabled:p,onClick:u,children:d}),t[67]=p,t[68]=u,t[69]=f):f=t[69];let m;t[70]!==s||t[71]!==f?(m=(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-3`,children:[s,f]}),t[70]=s,t[71]=f,t[72]=m):m=t[72];let g;t[73]!==h||t[74]!==i||t[75]!==m?(g=(0,Z.jsxs)(`div`,{ref:h,className:`flex flex-shrink-0 flex-wrap items-center justify-between gap-x-6 gap-y-3 border-t px-6 py-4`,children:[i,m]}),t[73]=h,t[74]=i,t[75]=m,t[76]=g):g=t[76];let _;return t[77]!==g||t[78]!==e?(_=(0,Z.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[e,g]}),t[77]=g,t[78]=e,t[79]=_):_=t[79],_}let T;t[80]===S?T=t[81]:(T=e=>void S(e),t[80]=S,t[81]=T);let E;return t[82]!==l.ours||t[83]!==l.theirs||t[84]!==T?(E=(0,Z.jsx)(xA,{oldContent:l.theirs,newContent:l.ours,layout:`unified`,conflictMode:!0,onResolve:T}),t[82]=l.ours,t[83]=l.theirs,t[84]=T,t[85]=E):E=t[85],E}function kA(e){let t=(0,$.c)(2),{docName:n,provider:r,children:i}=e;(0,Q.use)(It(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 AA=`__back-nav__`;function jA(e){return e instanceof Me||e instanceof vt||e instanceof De||e instanceof Qe||e instanceof At||e instanceof ee?e.docName:null}function MA(e){return e instanceof Me||e instanceof vt}function NA(e){if(e instanceof Me){let t=e.docName;return{title:Kc._({id:`Jejur6`}),summary:Kc._({id:`jSY41h`,values:{docName:t}})}}if(e instanceof vt){let t=e.docName;return{title:Kc._({id:`V7QxyT`}),summary:Kc._({id:`xG4tb6`,values:{docName:t}})}}if(e instanceof De){let t=e.docName;return{title:Kc._({id:`1di5fu`}),summary:Kc._({id:`PQCdtv`,values:{docName:t}})}}if(e instanceof Qe){let t=e.docName;return{title:Kc._({id:`wvbc1r`}),summary:Kc._({id:`IX7-sq`,values:{docName:t}})}}if(e instanceof At)return{title:Kc._({id:`Gfr4fu`}),summary:Kc._({id:`UW2Fg3`})};if(e instanceof ee){let t=e.docName;return{title:Kc._({id:`vv7kpg`}),summary:Kc._({id:`mdKFEy`,values:{docName:t}})}}let t=e instanceof Error&&e.message?e.message:Kc._({id:`W5A0Ly`});return{title:Kc._({id:`29VNqC`}),summary:t}}function PA(e){let t=(0,$.c)(31),{error:n,resetErrorBoundary:r,activeDocName:i,previousDocName:a,onNavigateBack:o}=e,s;t[0]===n?s=t[1]:(s=NA(n),t[0]=n,t[1]=s);let{title:c,summary:l}=s,u=!!a&&!!o,d=(0,Q.useRef)(null),f=typeof window<`u`?window.okDesktop:void 0,p=f&&MA(n)?f:null,m,h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{d.current?.focus()},h=[],t[2]=m,t[3]=h):(m=t[2],h=t[3]),(0,Q.useEffect)(m,h);let g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(hS,{size:80,variant:`sleeping`}),t[4]=g):g=t[4];let _;t[5]===c?_=t[6]:(_=(0,Z.jsx)(`h2`,{id:`document-error-title`,className:`text-2xl font-light tracking-tighter text-balance`,children:c}),t[5]=c,t[6]=_);let v;t[7]===l?v=t[8]:(v=(0,Z.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:l}),t[7]=l,t[8]=v);let y;t[9]!==_||t[10]!==v?(y=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[_,v]}),t[9]=_,t[10]=v,t[11]=y):y=t[11];let b;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(J,{id:`KDw4GX`}),t[12]=b):b=t[12];let x;t[13]===r?x=t[14]:(x=(0,Z.jsx)(X,{ref:d,variant:`default`,onClick:r,children:b}),t[13]=r,t[14]=x);let S;t[15]===p?S=t[16]:(S=p?(0,Z.jsx)(X,{variant:`secondary`,onClick:()=>{Ag(p).then(IA).catch(FA)},children:(0,Z.jsx)(J,{id:`uaUc6t`})}):null,t[15]=p,t[16]=S);let C;t[17]!==i||t[18]!==u||t[19]!==n||t[20]!==o||t[21]!==a||t[22]!==r?(C=u?(0,Z.jsx)(X,{variant:`ghost`,className:`font-mono uppercase`,onClick:()=>{!a||!o||(st(jA(n)??i),o(a),r(AA))},children:(0,Z.jsx)(J,{id:`CKyk7Q`})}):null,t[17]=i,t[18]=u,t[19]=n,t[20]=o,t[21]=a,t[22]=r,t[23]=C):C=t[23];let w;t[24]!==S||t[25]!==C||t[26]!==x?(w=(0,Z.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[x,S,C]}),t[24]=S,t[25]=C,t[26]=x,t[27]=w):w=t[27];let T;return t[28]!==w||t[29]!==y?(T=(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:[g,y,w]}),t[28]=w,t[29]=y,t[30]=T):T=t[30],T}function FA(){}function IA(e){e.ok||Ss.error(e.message,{id:`server-restart-error`,duration:1/0})}function LA(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)(PA,{...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]===AA){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}: ${NA(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)(g,{fallbackRender:s,resetKeys:c,onReset:l,onError:u,children:o}),t[11]=o,t[12]=s,t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}function RA(e){let t=e.document.getText(`source`).toString(),{map:n,parseError:r}=Qr(t);return{map:n,keys:Pr(t),parseError:r}}function zA(e){let t=(0,$.c)(21),{provider:n}=e,r;t[0]===n?r=t[1]:(r=()=>RA(n),t[0]=n,t[1]=r);let[i,a]=(0,Q.useState)(r),o,s;t[2]===n?(o=t[3],s=t[4]):(o=()=>{let e=Jn(n);a(e.current());let t=e.subscribe(e=>{a(e)});return()=>{t(),e.dispose()}},s=[n],t[2]=n,t[3]=o,t[4]=s),(0,Q.useEffect)(o,s);let c;t[5]===i.map.icon?c=t[6]:(c=Ye(i.map.icon),t[5]=i.map.icon,t[6]=c);let l=c,u;t[7]===i.map.cover?u=t[8]:(u=dt(i.map.cover),t[7]=i.map.cover,t[8]=u);let d=u,f=d.kind===`url`||d.kind===`path`,p=l.kind!==`unsupported`;if(!f&&!p)return null;let m=f?`true`:`false`,h=p?`true`:`false`,g;t[9]!==d||t[10]!==f?(g=f?(0,Z.jsx)(BA,{cover:d}):null,t[9]=d,t[10]=f,t[11]=g):g=t[11];let _;t[12]!==f||t[13]!==p||t[14]!==l?(_=p?(0,Z.jsx)(VA,{icon:l,hasCover:f}):null,t[12]=f,t[13]=p,t[14]=l,t[15]=_):_=t[15];let v;return t[16]!==m||t[17]!==h||t[18]!==g||t[19]!==_?(v=(0,Z.jsxs)(`div`,{className:`page-header editor-content-aligned`,"data-has-cover":m,"data-has-icon":h,"aria-hidden":`true`,"data-testid":`page-header`,children:[g,_]}),t[16]=m,t[17]=h,t[18]=g,t[19]=_,t[20]=v):v=t[20],v}function BA(e){let t=(0,$.c)(2),{cover:n}=e,r;return t[0]===n.value?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`page-header-cover`,"data-testid":`page-header-cover`,children:(0,Z.jsx)(`img`,{src:n.value,alt:``,draggable:!1,loading:`lazy`,referrerPolicy:`no-referrer`,className:`page-header-cover-img`})}),t[0]=n.value,t[1]=r),r}function VA(e){let t=(0,$.c)(9),{icon:n,hasCover:r}=e,i=r?`page-header-icon page-header-icon--with-cover`:`page-header-icon`;if(n.kind===`emoji`){let e;return t[0]!==n.value||t[1]!==i?(e=(0,Z.jsx)(`span`,{className:i,"data-testid":`page-header-icon`,"data-kind":`emoji`,children:n.value}),t[0]=n.value,t[1]=i,t[2]=e):e=t[2],e}let a;t[3]===n.value?a=t[4]:(a=(0,Z.jsx)(`img`,{src:n.value,alt:``,draggable:!1,referrerPolicy:`no-referrer`,className:`page-header-icon-img`}),t[3]=n.value,t[4]=a);let o;return t[5]!==n.kind||t[6]!==i||t[7]!==a?(o=(0,Z.jsx)(`span`,{className:i,"data-testid":`page-header-icon`,"data-kind":n.kind,children:a}),t[5]=n.kind,t[6]=i,t[7]=a,t[8]=o):o=t[8],o}var HA=(0,Q.lazy)(async()=>({default:(await n(async()=>{let{ManagedArtifactProperties:e}=await import(`./ManagedArtifactProperties-7tx2h5fh.js`);return{ManagedArtifactProperties:e}},__vite__mapDeps([79,1,37,2,38,39,11,40,41,42,43,44,45,46,47,15,16,13,7,17,18,10,3,48,49,33,12,6,4,50,51,52,20,53,54,55,56,30,31,32,57,58,59,60,61,62,68,70,19,80,69,81,82,35,77]),import.meta.url)).ManagedArtifactProperties})),UA=Dl(`LARGE_DOC_CHAR_THRESHOLD`,5e5);function WA(e){let t=e.threshold??UA;return e.ytextLength>t?{renderSource:e.isSourceMode||e.visitedSource,renderVisual:!e.isSourceMode||e.visitedVisual,isLarge:!0}:{renderSource:!0,renderVisual:!0,isLarge:!1}}function GA(e){return e.hasEmittedFirstToggle||!e.isLarge?!1:e.renderSource&&e.renderVisual}var KA=Dl(`ACTIVITY_MOUNT_LIMIT`,3);function qA(){return n(()=>import(`./SourceEditor-z66BI1TW.js`),__vite__mapDeps([83,1,37,2,38,39,11,40,41,42,43,44,45,46,47,15,16,13,7,17,18,10,3,48,49,33,12,6,4,50,51,52,20,53,54,55,56,30,31,32,57,58,59,60,61,62,84,21,82,78]),import.meta.url)}var JA=(0,Q.lazy)(async()=>({default:(await qA()).SourceEditor}));function YA(e,t,n){if(n<=0)return[];let r=e.filter(e=>!Ue(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 XA(e,t){return t.kind===`idle`?null:t.kind===`failed`&&t.failedDocNames.includes(e)?{kind:`failed`,title:Kc._({id:`MTs6g3`}),summary:t.reason===`clear-data-timeout`?Kc._({id:`Sc1bKE`,values:{docName:e}}):Kc._({id:`ovIGrT`,values:{docName:e}}),actionLabel:Kc._({id:`HpK_8d`})}:t.kind===`recovering`&&t.docNames.includes(e)?{kind:`recovering`,title:Kc._({id:`cF9DyA`}),summary:t.phase===`clearing-local-cache`?Kc._({id:`bmC18N`,values:{docName:e}}):Kc._({id:`pAgkuZ`,values:{docName:e}})}:null}function ZA(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(El,{name:`activity-pool`,children:(0,Z.jsx)(QA,{...e})}),t[0]=e,t[1]=n),n}function QA(e){let t=(0,$.c)(15),{activeDocName:n,isSourceMode:r,editorPlaceholder:i,previousDocName:a,onNavigateBack:o,onRecycle:s}=e,{poolEntries:c,serverRestartRecovery:l}=mt(),{pages:u,loading:d}=Xi(),f=YA(c,n,KA),p=(0,Q.useRef)(``),m=f.map($A).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)Qt(e);for(let e of i){let t=h.current.find(t=>t.docName===e)?.poolEventId;me(e,t&&t.length>0?t:crypto.randomUUID())}Tl(`ok/activity/mount-list-change`,{active:n,mounted:t,evicted:r}),p.current=m,H(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)(aj,{entry:e,isActive:e.docName===n,isSourceMode:r,editorPlaceholder:i,isNewDoc:!d&&!u.has(e.docName)&&!hr(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 $A(e){return e.docName}function ej(e){let t=(0,$.c)(8),{isActive:n,initialScrollTop:r,children:i}=e,a=(0,Q.useRef)(null),o=(0,Q.useRef)(r??0),s,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=a.current;if(!e)return;let t=()=>{e.scrollTop>0&&(o.current=e.scrollTop)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},c=[],t[0]=s,t[1]=c):(s=t[0],c=t[1]),(0,Q.useEffect)(s,c);let l,u;t[2]===n?(l=t[3],u=t[4]):(l=()=>{if(!n)return;let e=a.current;if(!e)return;let t=o.current;if(t===0)return;let r=performance.now(),i=!1;e.scrollTop=t,e.scrollTop===t&&e.scrollHeight>t&&Tl(`ok/scroll-restore/phase1-success`,{target:t,elapsedMs:performance.now()-r});let s=!1,c=0,l=()=>{s||(s=!0,cancelAnimationFrame(c),clearTimeout(f),e.removeEventListener(`wheel`,u),e.removeEventListener(`touchstart`,u))},u=()=>l();e.addEventListener(`wheel`,u,{passive:!0}),e.addEventListener(`touchstart`,u,{passive:!0});let d=()=>{s||(e.scrollTop!==t&&e.scrollHeight>t&&(e.scrollTop=t,e.scrollTop===t&&!i&&(Tl(`ok/scroll-restore/phase2-success`,{target:t,elapsedMs:performance.now()-r}),i=!0)),c=requestAnimationFrame(d))};c=requestAnimationFrame(d);let f=setTimeout(()=>{s||(e.scrollTop!==t&&e.scrollHeight>t&&Tl(`ok/scroll-restore/abandoned`,{target:t,elapsedMs:performance.now()-r,scrollHeight:e.scrollHeight,finalScrollTop:e.scrollTop}),l())},2e3);return l},u=[n],t[2]=n,t[3]=l,t[4]=u),(0,Q.useLayoutEffect)(l,u);let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d={overflowAnchor:`auto`},t[5]=d):d=t[5];let f;return t[6]===i?f=t[7]:(f=(0,Z.jsx)(`div`,{ref:a,"data-testid":`editor-scroll-container`,className:`editor-doc-scroll subtle-scrollbar h-full overflow-y-auto pt-14 scroll-pt-14`,style:d,children:i}),t[6]=i,t[7]=f),f}function tj(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)(Qb,{}),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)(JA,{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 nj(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)(ls,{className:`size-5`,"aria-hidden":`true`}):(0,Z.jsx)(ss,{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:rj,children:[(0,Z.jsx)(ls,{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 rj(){return window.location.reload()}function ij(e){let t=(0,$.c)(2),{html:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`tiptap-editor h-full pointer-events-none`,"aria-hidden":`true`,children:(0,Z.jsx)(`div`,{className:`tiptap ProseMirror tiptap-editor-portal-content`,dangerouslySetInnerHTML:{__html:n}})}),t[0]=n,t[1]=r),r}function aj(e){let t=(0,$.c)(53),{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a,isNewDoc:o,previousDocName:s,onNavigateBack:c,onRecycle:l,serverRestartRecovery:u}=e,d;t[0]!==n.docName||t[1]!==u?(d=XA(n.docName,u),t[0]=n.docName,t[1]=u,t[2]=d):d=t[2];let f=d,m=cw(n.docName)===`conflict`,h;t[3]===n.docName?h=t[4]:(h=()=>{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]=h);let[g]=(0,Q.useState)(h),_=n.provider.document.getText(`source`).length,[v,y]=(0,Q.useState)(i),[b,x]=(0,Q.useState)(!i),S,C;t[5]!==i||t[6]!==v||t[7]!==b?(S=()=>{i&&!v?y(!0):!i&&!b&&x(!0)},C=[i,v,b],t[5]=i,t[6]=v,t[7]=b,t[8]=S,t[9]=C):(S=t[8],C=t[9]),(0,Q.useEffect)(S,C);let w=WA({ytextLength:_,isSourceMode:i,visitedSource:v,visitedVisual:b}),T=(0,Q.useRef)(``),E=`${w.isLarge}-${w.renderSource}-${w.renderVisual}`,D,O;t[10]!==n.docName||t[11]!==w.isLarge||t[12]!==w.renderSource||t[13]!==w.renderVisual||t[14]!==E||t[15]!==i||t[16]!==_?(D=()=>{T.current!==E&&(T.current=E,w.isLarge&&Tl(`ok/activity/defer-mount`,{docName:n.docName,ytextLength:_,isSourceMode:i,renderSource:w.renderSource,renderVisual:w.renderVisual}))},O=[E,w.isLarge,w.renderSource,w.renderVisual,n.docName,_,i],t[10]=n.docName,t[11]=w.isLarge,t[12]=w.renderSource,t[13]=w.renderVisual,t[14]=E,t[15]=i,t[16]=_,t[17]=D,t[18]=O):(D=t[17],O=t[18]),(0,Q.useEffect)(D,O);let k;t[19]===n.docName?k=t[20]:(k=()=>B(n.docName),t[19]=n.docName,t[20]=k);let[A]=(0,Q.useState)(k),j=A?.html??null,[M,N]=(0,Q.useState)(!1),P,F;t[21]!==n.docName||t[22]!==w.isLarge||t[23]!==w.renderSource||t[24]!==w.renderVisual||t[25]!==M||t[26]!==i||t[27]!==_?(P=()=>{GA({isLarge:w.isLarge,renderSource:w.renderSource,renderVisual:w.renderVisual,hasEmittedFirstToggle:M})&&(Tl(`ok/cold/first-toggle`,{docName:n.docName,mountId:p(n.docName),ytextLength:_,modeEnteredFirst:i?`source`:`visual`}),N(!0))},F=[M,w.isLarge,w.renderSource,w.renderVisual,n.docName,_,i],t[21]=n.docName,t[22]=w.isLarge,t[23]=w.renderSource,t[24]=w.renderVisual,t[25]=M,t[26]=i,t[27]=_,t[28]=P,t[29]=F):(P=t[28],F=t[29]),(0,Q.useEffect)(P,F);let I=r?`visible`:`hidden`,L=`editor:${n.docName}`,R=A?.scrollTop,z;t[30]!==a||t[31]!==n||t[32]!==w.renderSource||t[33]!==w.renderVisual||t[34]!==r||t[35]!==m||t[36]!==o||t[37]!==i||t[38]!==c||t[39]!==l||t[40]!==g||t[41]!==s||t[42]!==f||t[43]!==j?(z=f?(0,Z.jsx)(nj,{view:f}):(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(LA,{activeDocName:n.docName,previousDocName:s,onNavigateBack:c,onRecycle:l,children:(0,Z.jsx)(Q.Suspense,{fallback:j?(0,Z.jsx)(ij,{html:j}):(0,Z.jsx)(Qb,{}),children:(0,Z.jsx)(kA,{docName:n.docName,provider:n.provider,children:m?(0,Z.jsx)(OA,{docName:n.docName,provider:n.provider}):(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[!i&&(hr(n.docName)||Wt(n.docName)?(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(HA,{docName:n.docName,provider:n.provider})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(zA,{provider:n.provider}),(0,Z.jsx)(Hi,{provider:n.provider})]})),(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[w.renderSource?(0,Z.jsx)(`div`,{className:i?`h-full`:`ok-mode-hidden h-full`,children:(0,Z.jsx)(tj,{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a})}):null,w.renderVisual?(0,Z.jsx)(`div`,{className:i?`ok-mode-hidden h-full`:`h-full`,children:(0,Z.jsx)(wO,{provider:n.provider,placeholder:a,isSourceMode:i,portalTarget:g},`${n.docName}-${String(o)}-${n.poolEventId}`)}):null]})]})})})})}),t[30]=a,t[31]=n,t[32]=w.renderSource,t[33]=w.renderVisual,t[34]=r,t[35]=m,t[36]=o,t[37]=i,t[38]=c,t[39]=l,t[40]=g,t[41]=s,t[42]=f,t[43]=j,t[44]=z):z=t[44];let V;t[45]!==r||t[46]!==R||t[47]!==z?(V=(0,Z.jsx)(ej,{isActive:r,initialScrollTop:R,children:z}),t[45]=r,t[46]=R,t[47]=z,t[48]=V):V=t[48];let H;return t[49]!==I||t[50]!==L||t[51]!==V?(H=(0,Z.jsx)(Q.Activity,{mode:I,name:L,children:V}),t[49]=I,t[50]=L,t[51]=V,t[52]=H):H=t[52],H}function oj(e){let t=e.endsWith(`rem`)?`rem`:`px`;return{value:Number.parseFloat(e),unit:t}}function sj(e){let{value:t,unit:n}=oj(e);return n===`rem`?t*16:t}function cj(e,t){return`${t===`rem`?e.toFixed(1):Math.round(e)}${t}`}var lj=3600*24*7;function uj(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?dj:m,O=g===void 0?lj: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 ee=sj(b),te;t[6]===x?te=t[7]:(te=sj(x),t[6]=x,t[7]=te);let ne=te,re;t[8]!==E||t[9]!==k?(re=function(e){E&&(P.current=!0,j.current=H.current?0:sj(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]=re):re=t[10];let ie=re,ae,oe;t[11]!==w||t[12]!==v||t[13]!==C||t[14]!==S||t[15]!==T||t[16]!==k||t[17]!==ne||t[18]!==ee||t[19]!==i||t[20]!==a||t[21]!==D||t[22]!==O||t[23]!==h?(ae=()=>{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}=oj(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<=ee*w;else if(e<=ee){let n=ee*(w-1);t=ee-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>ee*T){a();let t=n(r,M.current,j.current,s),c=Math.max(ee,Math.min(ne,t)),u=cj(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(ee,Math.min(ne,u)),f=cj(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)}},oe=[i,a,D,ee,ne,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]=ne,t[18]=ee,t[19]=i,t[20]=a,t[21]=D,t[22]=O,t[23]=h,t[24]=ae,t[25]=oe):(ae=t[24],oe=t[25]),(0,Q.useEffect)(ae,oe);let se;return t[26]===ie?se=t[27]:(se={dragRef:A,isDragging:N,handleMouseDown:ie},t[26]=ie,t[27]=se),se}function dj(){}var fj=3600*24*7,pj=`18rem`,mj=`3rem`,hj=`app-file-sidebar`,gj=`14.625rem`,_j=`32rem`,vj=`sidebar_width`,yj=/^\d+(?:\.\d+)?(?:rem|px)$/,bj=Q.createContext(null);function xj(e){if(typeof document>`u`)return e;let t=document.cookie.split(`; `).find(e=>e.startsWith(`${vj}=`))?.split(`=`)[1];if(!t)return e;let n;try{n=decodeURIComponent(t)}catch{return e}return yj.test(n)?n:e}function Sj(){let e=Q.use(bj);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function Cj(e){let t=(0,$.c)(58),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({open:i,onOpenChange:o,className:r,style:s,children:n,defaultWidth:c,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=c===void 0?pj:c,[u]=Q.useState(Tj),d;t[8]===u?d=t[9]:(d=()=>vw(u,window.innerWidth,`left`),t[8]=u,t[9]=d);let[f,p]=Q.useState(d),m;t[10]===l?m=t[11]:(m=()=>xj(l),t[10]=l,t[11]=m);let[h,g]=Q.useState(m),[_,v]=Q.useState(!1),[y,b]=Q.useState(!1),x;t[12]===u?x=t[13]:(x=()=>{let e=Tw();return Dw(`left`,vw(u,window.innerWidth,`left`),e)===`open`},t[12]=u,t[13]=x);let[S,C]=Q.useState(x),w=i??S,T;t[14]!==w||t[15]!==f||t[16]!==o?(T=e=>{let t=typeof e==`function`?e(w):e;o?o(t):C(t),Ow(`left`,f,t?`open`:`collapsed`)},t[14]=w,t[15]=f,t[16]=o,t[17]=T):T=t[17];let E=T,D;t[18]===E?D=t[19]:(D=function(){E(wj)},t[18]=E,t[19]=D);let O=D,k=Q.useRef(w),A;t[20]===w?A=t[21]:(A=()=>{k.current=w},t[20]=w,t[21]=A),Q.useLayoutEffect(A);let j;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(j=function(){window.innerWidth>=1024||k.current&&(window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||b(!0))},t[22]=j):j=t[22];let M=j,N,P;t[23]===u?(N=t[24],P=t[25]):(P=()=>{let e=window.matchMedia(`(min-width: ${hw}px)`),t=()=>{let e=vw(u,window.innerWidth,`left`);p(e),C(Dw(`left`,e,Tw())===`open`)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},N=[u],t[23]=u,t[24]=N,t[25]=P),Q.useEffect(P,N);let F,I;t[26]===w?(F=t[27],I=t[28]):(F=()=>{w||document.getElementById(hj)?.contains(document.activeElement)&&document.querySelector(`[data-sidebar="trigger"]`)?.focus()},I=[w],t[26]=w,t[27]=F,t[28]=I),Q.useLayoutEffect(F,I);let L,R;t[29]!==w||t[30]!==f||t[31]!==E?(L=()=>{if(f===`above`||!w)return;let e=e=>{e.key===`Escape`&&(document.querySelector(`[data-state="open"][role="dialog"], [data-state="open"][role="alertdialog"], [data-state="open"][role="menu"], [data-state="open"][role="listbox"], [data-radix-popper-content-wrapper] [data-state="open"]`)||E(!1))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},R=[f,w,E],t[29]=w,t[30]=f,t[31]=E,t[32]=L,t[33]=R):(L=t[32],R=t[33]),Q.useEffect(L,R);let z,B;t[34]===O?(z=t[35],B=t[36]):(z=()=>{if(typeof window<`u`&&window.okDesktop!=null)return;let e=e=>{Al(e,`toggle-files-sidebar`)&&(e.preventDefault(),O())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},B=[O],t[34]=O,t[35]=z,t[36]=B),Q.useEffect(z,B);let V=w?`expanded`:`collapsed`,H;t[37]!==_||t[38]!==w||t[39]!==E||t[40]!==y||t[41]!==V||t[42]!==O||t[43]!==h?(H={state:V,open:w,setOpen:E,toggleSidebar:O,width:h,setWidth:g,isDraggingRail:_,setIsDraggingRail:v,showPushPulse:y,setShowPushPulse:b,notifySidebarFileSelected:M},t[37]=_,t[38]=w,t[39]=E,t[40]=y,t[41]=V,t[42]=O,t[43]=h,t[44]=H):H=t[44];let U;t[45]!==s||t[46]!==h?(U={"--sidebar-width":h,"--sidebar-width-icon":mj,...s},t[45]=s,t[46]=h,t[47]=U):U=t[47];let W=U,G;t[48]===r?G=t[49]:(G=Y(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),t[48]=r,t[49]=G);let K;t[50]!==n||t[51]!==a||t[52]!==W||t[53]!==G?(K=(0,Z.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:W,className:G,...a,children:n}),t[50]=n,t[51]=a,t[52]=W,t[53]=G,t[54]=K):K=t[54];let ee;return t[55]!==H||t[56]!==K?(ee=(0,Z.jsx)(bj.Provider,{value:H,children:K}),t[55]=H,t[56]=K,t[57]=ee):ee=t[57],ee}function wj(e){return!e}function Tj(){return kr()}function Ej(e){let t=(0,$.c)(39),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,{_:d}=$t(),{state:f,isDraggingRail:p}=Sj();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}let m=f===`collapsed`?u:``,h=l===`floating`||l===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,g;t[14]===h?g=t[15]:(g=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`,h,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`),t[14]=h,t[15]=g);let _;t[16]===g?_=t[17]:(_=(0,Z.jsx)(`div`,{"data-slot":`sidebar-gap`,className:g}),t[16]=g,t[17]=_);let v;t[18]===d?v=t[19]:(v=d({id:`07q4Qk`}),t[18]=d,t[19]=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[20]!==r||t[21]!==y?(b=Y(`fixed inset-y-0 z-10 flex h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear motion-reduce:transition-none motion-reduce:duration-0 data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]`,y,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`,r),t[20]=r,t[21]=y,t[22]=b):b=t[22];let x;t[23]===n?x=t[24]:(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[23]=n,t[24]=x);let S;t[25]!==i||t[26]!==c||t[27]!==b||t[28]!==x||t[29]!==v?(S=(0,Z.jsx)(`nav`,{id:hj,"aria-label":v,"data-slot":`sidebar-container`,"data-side":c,className:b,...i,children:x}),t[25]=i,t[26]=c,t[27]=b,t[28]=x,t[29]=v,t[30]=S):S=t[30];let C;return t[31]!==p||t[32]!==c||t[33]!==f||t[34]!==S||t[35]!==m||t[36]!==_||t[37]!==l?(C=(0,Z.jsxs)(`div`,{className:`group peer text-sidebar-foreground`,"data-state":f,"data-collapsible":m,"data-variant":l,"data-side":c,"data-slot":`sidebar`,"data-dragging":p,children:[_,S]}),t[31]=p,t[32]=c,t[33]=f,t[34]=S,t[35]=m,t[36]=_,t[37]=l,t[38]=C):C=t[38],C}function Dj(e){let t=(0,$.c)(34),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{_:a}=$t(),{toggleSidebar:o,state:s}=Sj(),c,l,u,d,p,m,h,g;if(t[4]!==a||t[5]!==s){let e=jl(`toggle-files-sidebar`);c=X,l=`trigger`,u=`sidebar-trigger`,d=`ghost`,p=`icon-sm`,m=s===`expanded`,h=hj,g=a(s===`expanded`?{id:`4PYsOz`,values:{sidebarShortcutLabel:e}}:{id:`jbSG8V`,values:{sidebarShortcutLabel:e}}),t[4]=a,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=p,t[11]=m,t[12]=h,t[13]=g}else c=t[6],l=t[7],u=t[8],d=t[9],p=t[10],m=t[11],h=t[12],g=t[13];let _;t[14]===n?_=t[15]:(_=Y(n),t[14]=n,t[15]=_);let v;t[16]!==r||t[17]!==o?(v=e=>{r?.(e),o()},t[16]=r,t[17]=o,t[18]=v):v=t[18];let y;t[19]===s?y=t[20]:(y=s===`expanded`?(0,Z.jsx)(f,{}):(0,Z.jsx)(af,{}),t[19]=s,t[20]=y);let b;return t[21]!==c||t[22]!==i||t[23]!==l||t[24]!==y||t[25]!==u||t[26]!==d||t[27]!==p||t[28]!==m||t[29]!==h||t[30]!==g||t[31]!==_||t[32]!==v?(b=(0,Z.jsx)(c,{"data-sidebar":l,"data-slot":u,variant:d,size:p,"aria-expanded":m,"aria-controls":h,"aria-label":g,className:_,onClick:v,...i,children:y}),t[21]=c,t[22]=i,t[23]=l,t[24]=y,t[25]=u,t[26]=d,t[27]=p,t[28]=m,t[29]=h,t[30]=g,t[31]=_,t[32]=v,t[33]=b):b=t[33],b}function Oj(e){let t=(0,$.c)(32),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,{_:l}=$t(),{toggleSidebar:u,setWidth:d,state:f,width:p,setIsDraggingRail:m}=Sj(),h=f===`collapsed`,g;t[6]!==s||t[7]!==c||t[8]!==m||t[9]!==d||t[10]!==h||t[11]!==u||t[12]!==p?(g={direction:`right`,enableDrag:s,enableToggle:c,onResize:d,onToggle:u,currentWidth:p,isCollapsed:h,minResizeWidth:gj,maxResizeWidth:_j,setIsDraggingRail:m,widthCookieName:vj,widthCookieMaxAge:fj},t[6]=s,t[7]=c,t[8]=m,t[9]=d,t[10]=h,t[11]=u,t[12]=p,t[13]=g):g=t[13];let{dragRef:_,handleMouseDown:v}=uj(g),y;t[14]!==l||t[15]!==f?(y=l(f===`expanded`?{id:`w3vFfL`}:{id:`e8zRrb`}),t[14]=l,t[15]=f,t[16]=y):y=t[16];let b;t[17]!==v||t[18]!==r?(b=e=>{r?.(e),e.defaultPrevented||v(e)},t[17]=v,t[18]=r,t[19]=b):b=t[19];let x;t[20]!==l||t[21]!==f?(x=l(f===`expanded`?{id:`w3vFfL`}:{id:`e8zRrb`}),t[20]=l,t[21]=f,t[22]=x):x=t[22];let S;t[23]===n?S=t[24]:(S=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[23]=n,t[24]=S);let C;return t[25]!==_||t[26]!==i||t[27]!==y||t[28]!==b||t[29]!==x||t[30]!==S?(C=(0,Z.jsx)(`button`,{ref:_,"data-sidebar":`rail`,"data-slot":`sidebar-rail`,"aria-label":y,tabIndex:-1,onMouseDown:b,title:x,className:S,...i}),t[25]=_,t[26]=i,t[27]=y,t[28]=b,t[29]=x,t[30]=S,t[31]=C):C=t[31],C}function kj(e){let t=(0,$.c)(14),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,onAnimationEnd:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let{showPushPulse:a,setShowPushPulse:o}=Sj(),s;t[4]!==r||t[5]!==o?(s=e=>{r?.(e),e.animationName===`sidebar-push-pulse`&&o(!1)},t[4]=r,t[5]=o,t[6]=s):s=t[6];let c=s,l=a?``:void 0,u;t[7]===n?u=t[8]:(u=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`,n),t[7]=n,t[8]=u);let d;return t[9]!==c||t[10]!==i||t[11]!==l||t[12]!==u?(d=(0,Z.jsx)(`main`,{"data-slot":`sidebar-inset`,"data-push-pulse":l,onAnimationEnd:c,className:u,...i}),t[9]=c,t[10]=i,t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function Aj(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 jj(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 Mj(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 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(`relative flex w-full min-w-0 flex-col 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-group`,"data-sidebar":`group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Pj(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,asChild:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i?gi:`div`,o;t[4]===n?o=t[5]:(o=Y(`flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0`,n),t[4]=n,t[5]=o);let s;return t[6]!==a||t[7]!==r||t[8]!==o?(s=(0,Z.jsx)(a,{"data-slot":`sidebar-group-label`,"data-sidebar":`group-label`,className:o,...r}),t[6]=a,t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function Fj(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,asChild:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i?gi:`button`,o;t[4]===n?o=t[5]:(o=Y(`absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0`,n),t[4]=n,t[5]=o);let s;return t[6]!==a||t[7]!==r||t[8]!==o?(s=(0,Z.jsx)(a,{"data-slot":`sidebar-group-action`,"data-sidebar":`group-action`,className:o,...r}),t[6]=a,t[7]=r,t[8]=o,t[9]=s):s=t[9],s}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(`w-full text-sm`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`sidebar-group-content`,"data-sidebar":`group-content`,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(`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 Rj(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 zj=_i(`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 Bj(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?gi:`button`,{state:m}=Sj(),h;t[8]!==n||t[9]!==f||t[10]!==d?(h=Y(zj({variant:d,size:f}),n),t[8]=n,t[9]=f,t[10]=d,t[11]=h):h=t[11];let g;t[12]!==p||t[13]!==u||t[14]!==r||t[15]!==f||t[16]!==h?(g=(0,Z.jsx)(p,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":f,"data-active":u,className:h,...r}),t[12]=p,t[13]=u,t[14]=r,t[15]=f,t[16]=h,t[17]=g):g=t[17];let _=g;if(!c)return _;if(typeof c==`string`){let e;t[18]===c?e=t[19]:(e={children:c},t[18]=c,t[19]=e),c=e}let v;t[20]===_?v=t[21]:(v=(0,Z.jsx)(Ms,{asChild:!0,children:_}),t[20]=_,t[21]=v);let y=m!==`collapsed`,b;t[22]!==y||t[23]!==c?(b=(0,Z.jsx)(Ns,{side:`right`,align:`center`,hidden:y,...c}),t[22]=y,t[23]=c,t[24]=b):b=t[24];let x;return t[25]!==v||t[26]!==b?(x=(0,Z.jsxs)(Fs,{children:[v,b]}),t[25]=v,t[26]=b,t[27]=x):x=t[27],x}function Vj(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,asChild:i,showOnHover:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?!1:i,s=a===void 0?!1:a,c=o?gi:`button`,l=s&&`group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0`,u;t[5]!==n||t[6]!==l?(u=Y(`absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0`,l,n),t[5]=n,t[6]=l,t[7]=u):u=t[7];let d;return t[8]!==c||t[9]!==r||t[10]!==u?(d=(0,Z.jsx)(c,{"data-slot":`sidebar-menu-action`,"data-sidebar":`menu-action`,className:u,...r}),t[8]=c,t[9]=r,t[10]=u,t[11]=d):d=t[11],d}function Hj(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-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden`,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-sub`,"data-sidebar":`menu-sub`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Uj(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-sub-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-sub-item`,"data-sidebar":`menu-sub-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Wj(e){let t=(0,$.c)(14),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({asChild:i,size:a,isActive:o,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=i===void 0?!1:i,c=a===void 0?`md`:a,l=o===void 0?!1:o,u=s?gi:`a`,d;t[6]===n?d=t[7]:(d=Y(`flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden 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-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground data-active:hover:bg-sidebar-accent [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground`,n),t[6]=n,t[7]=d);let f;return t[8]!==u||t[9]!==l||t[10]!==r||t[11]!==c||t[12]!==d?(f=(0,Z.jsx)(u,{"data-slot":`sidebar-menu-sub-button`,"data-sidebar":`menu-sub-button`,"data-size":c,"data-active":l,className:d,...r}),t[8]=u,t[9]=l,t[10]=r,t[11]=c,t[12]=d,t[13]=f):f=t[13],f}function Gj(e){let t=null,n=!1,r=new Set;function i(e){if(e!==t){t=e;for(let e of r)e()}}e.subscribeToEvent(i);async function a(){if(!n){n=!0;try{i(await e.fetchBranch())}catch{}}}return{getSnapshot:()=>t,subscribe(e){return r.add(e),a(),()=>{r.delete(e)}}}}async function Kj(){let e=await fetch(`/api/server-info`,{signal:AbortSignal.timeout(5e3)});if(!e.ok)return null;let t=await e.json(),n=Wr.safeParse(t);return n.success?n.data.currentBranch??null:null}var qj=typeof window>`u`?{getSnapshot:()=>null,subscribe:()=>()=>{}}:Gj({fetchBranch:Kj,subscribeToEvent:Wc}),Jj=qj.subscribe,Yj=qj.getSnapshot;function Xj(){return(0,Q.useSyncExternalStore)(Jj,Yj,Yj)}function Zj(){let e=(0,$.c)(6),t=Xj(),n=ta(),{state:r}=Sj(),i=typeof window<`u`?window.okDesktop:void 0;if(i&&r===`expanded`)return null;let a;e[0]===n?a=e[1]:(a=i?.config.projectName??(n&&za(n.contentDir)||null),e[0]=n,e[1]=a);let o=a,s=i?.config.projectPath??n?.contentDir??null;if(o===null&&t===null)return null;let c;return e[2]!==t||e[3]!==o||e[4]!==s?(c={projectName:o,projectPath:s,branch:t},e[2]=t,e[3]=o,e[4]=s,e[5]=c):c=e[5],c}function Qj(e){let t=(0,$.c)(30),{stats:n,selectionStats:r,showStats:i,composerBadge:a,reserveRightGutter:o}=e,s=i===void 0?!0:i,c=o===void 0?!1:o,{_:l}=$t(),u=Zj();if(!s&&u===null&&a==null)return null;let d=r??n,f=r!=null,{words:p,chars:m,tokens:h}=d,g;t[0]!==l||t[1]!==f||t[2]!==s?(g=l(s?f?{id:`Bv5a9_`}:{id:`L1ZE3M`}:{id:`goO4Ll`}),t[0]=l,t[1]=f,t[2]=s,t[3]=g):g=t[3];let _=c&&`pr-12`,v;t[4]===_?v=t[5]:(v=Y(`relative flex h-6 shrink-0 items-center justify-between gap-3 bg-background px-3 text-2xs text-muted-foreground`,_),t[4]=_,t[5]=v);let y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=(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[6]=y):y=t[6];let b;t[7]!==l||t[8]!==a?(b=a?(0,Z.jsxs)(X,{type:`button`,variant:`outline`,onClick:a.onReopen,"data-testid":`ask-ai-reopen-badge`,className:`-translate-x-1/2 absolute bottom-0 left-1/2 z-10 h-auto gap-1 rounded-md rounded-b-none bg-card px-2.5 py-0.5 text-2xs font-normal text-muted-foreground shadow-sm hover:text-foreground active:not-aria-[haspopup]:translate-y-0`,children:[(0,Z.jsx)(us,{className:`size-3`,"aria-hidden":!0}),l({id:`xWEvuo`}),(0,Z.jsx)(bt,{className:`size-3`,"aria-hidden":!0})]}):null,t[7]=l,t[8]=a,t[9]=b):b=t[9];let x;t[10]===u?x=t[11]:(x=u===null?null:(0,Z.jsx)($j,{identity:u}),t[10]=u,t[11]=x);let S;t[12]===x?S=t[13]:(S=(0,Z.jsx)(`span`,{className:`flex min-w-0 items-center gap-3`,children:x}),t[12]=x,t[13]=S);let C;t[14]!==l||t[15]!==d.chars||t[16]!==d.tokens||t[17]!==d.words||t[18]!==m||t[19]!==f||t[20]!==s||t[21]!==h||t[22]!==p?(C=s?(0,Z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-3`,children:[f?(0,Z.jsx)(`span`,{className:`font-medium text-foreground/70`,"data-testid":`editor-footer-selected-label`,children:l({id:`ylXj1N`})}):null,(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`tabular-nums`,children:d.words.toLocaleString()}),` `,(0,Z.jsx)(J,{id:`gljvbT`,values:{words:p}})]}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`tabular-nums`,children:d.chars.toLocaleString()}),` `,(0,Z.jsx)(J,{id:`d5rK4X`,values:{chars:m}})]}),(0,Z.jsxs)(`span`,{children:[d.tokens>0?`~`:``,(0,Z.jsx)(`span`,{className:`tabular-nums`,children:d.tokens.toLocaleString()}),` `,(0,Z.jsx)(J,{id:`uynXup`,values:{tokens:h}})]})]}):null,t[14]=l,t[15]=d.chars,t[16]=d.tokens,t[17]=d.words,t[18]=m,t[19]=f,t[20]=s,t[21]=h,t[22]=p,t[23]=C):C=t[23];let w;return t[24]!==C||t[25]!==g||t[26]!==v||t[27]!==b||t[28]!==S?(w=(0,Z.jsxs)(`section`,{"aria-label":g,className:v,children:[y,b,S,C]}),t[24]=C,t[25]=g,t[26]=v,t[27]=b,t[28]=S,t[29]=w):w=t[29],w}function $j(e){let t=(0,$.c)(8),{identity:n}=e,{projectName:r,projectPath:i,branch:a}=n,o;t[0]!==r||t[1]!==i?(o=r===null?null:i?(0,Z.jsxs)(Fs,{children:[(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(`span`,{tabIndex:0,className:`truncate`,"data-testid":`editor-footer-project-name`,children:r})}),(0,Z.jsx)(Ns,{side:`top`,className:`max-w-xs break-all`,children:i})]}):(0,Z.jsx)(`span`,{className:`truncate`,"data-testid":`editor-footer-project-name`,children:r}),t[0]=r,t[1]=i,t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=a===null?null:(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,"data-testid":`editor-footer-branch`,children:[(0,Z.jsx)(Vo,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:a})]}),t[3]=a,t[4]=s);let c;return t[5]!==o||t[6]!==s?(c=(0,Z.jsxs)(Z.Fragment,{children:[o,s]}),t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function eM(e){let t=(0,$.c)(11),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{_:i}=$t(),a;t[3]===i?a=t[4]:(a=i({id:`3__SjS`}),t[3]=i,t[4]=a);let o;t[5]===n?o=t[6]:(o=Y(n),t[5]=n,t[6]=o);let s;return t[7]!==r||t[8]!==a||t[9]!==o?(s=(0,Z.jsx)(`nav`,{"aria-label":a,"data-slot":`breadcrumb`,className:o,...r}),t[7]=r,t[8]=a,t[9]=o,t[10]=s):s=t[10],s}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 flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`ol`,{"data-slot":`breadcrumb-list`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function nM(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Y(`inline-flex items-center gap-1`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`li`,{"data-slot":`breadcrumb-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function rM(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({current:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0||i?`page`:void 0,o;t[4]===n?o=t[5]:(o=Y(`font-normal text-foreground`,n),t[4]=n,t[5]=o);let s;return t[6]!==r||t[7]!==a||t[8]!==o?(s=(0,Z.jsx)(`span`,{"data-slot":`breadcrumb-page`,"aria-current":a,className:o,...r}),t[6]=r,t[7]=a,t[8]=o,t[9]=s):s=t[9],s}function iM(e){let t=(0,$.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({children:n,className:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=Y(`[&>svg]:size-3.5`,r),t[4]=r,t[5]=a);let o;t[6]===n?o=t[7]:(o=n??(0,Z.jsx)(qi,{}),t[6]=n,t[7]=o);let s;return t[8]!==i||t[9]!==a||t[10]!==o?(s=(0,Z.jsx)(`li`,{"data-slot":`breadcrumb-separator`,role:`presentation`,"aria-hidden":`true`,className:a,...i,children:o}),t[8]=i,t[9]=a,t[10]=o,t[11]=s):s=t[11],s}var aM=1,oM=2,sM=4;function cM(e){let t=(0,$.c)(18),{docName:n,className:r}=e;if(!n)return null;let i,a,o,s,c,l;if(t[0]!==r||t[1]!==n){l=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Xr(n),u=e?e.kind===`template`?e.folder.split(`/`).filter(Boolean):[]:h(n,``).prefix.replace(/\/$/,``).split(`/`).filter(Boolean);if(u.length===0){l=null;break bb0}let d=(e,t)=>({kind:`segment`,value:e,key:u.slice(0,t+1).join(`/`)}),f=u.length>sM?[...u.slice(0,aM).map((e,t)=>d(e,t)),{kind:`ellipsis`,hidden:u.slice(aM,-oM)},...u.slice(-oM).map((e,t)=>d(e,u.length-oM+t))]:u.map((e,t)=>d(e,t));a=eM,t[8]===r?c=t[9]:(c=Y(`flex min-w-0 items-center`,r),t[8]=r,t[9]=c),i=tM,o=`min-w-0 flex-nowrap gap-1 overflow-hidden text-muted-foreground/70 text-xs`,s=f.map(lM)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7];if(l!==Symbol.for(`react.early_return_sentinel`))return l;let u;t[10]!==i||t[11]!==o||t[12]!==s?(u=(0,Z.jsx)(i,{className:o,children:s}),t[10]=i,t[11]=o,t[12]=s,t[13]=u):u=t[13];let d;return t[14]!==a||t[15]!==c||t[16]!==u?(d=(0,Z.jsx)(a,{className:c,children:u}),t[14]=a,t[15]=c,t[16]=u,t[17]=d):d=t[17],d}function lM(e,t){let n=e.kind===`segment`?e.key:`ellipsis`;return(0,Z.jsxs)(Q.Fragment,{children:[t>0&&(0,Z.jsx)(iM,{className:`shrink-0 text-muted-foreground/70 [&>svg]:size-3`}),e.kind===`ellipsis`?(0,Z.jsxs)(nM,{className:`shrink-0`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,title:e.hidden.join(` / `),className:`flex size-4 items-center justify-center text-muted-foreground/70`,children:(0,Z.jsx)(Ad,{className:`size-3.5`})}),(0,Z.jsx)(`span`,{className:`sr-only`,children:e.hidden.join(` / `)})]}):(0,Z.jsx)(nM,{className:`min-w-0`,children:(0,Z.jsx)(rM,{current:!1,className:`min-w-0 truncate font-normal text-muted-foreground/70`,title:e.value,children:e.value})})]},n)}var uM={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`},dM=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`,...uM,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},fM=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)(dM,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},pM=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)(dM,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i};function mM(e){let t=(0,$.c)(29),{isSourceMode:n,onModeChange:r,sourceDisabled:i}=e,a=i===void 0?!1:i,{_:o}=$t(),s=n?`source`:`wysiwyg`,c;t[0]===r?c=t[1]:(c=e=>{e&&r(e)},t[0]=r,t[1]=c);let l;t[2]===o?l=t[3]:(l=o({id:`n7aopT`}),t[2]=o,t[3]=l);let u;t[4]===o?u=t[5]:(u=o({id:`ur2XSb`}),t[4]=o,t[5]=u);let d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(Ms,{children:(0,Z.jsx)(pM,{className:`size-4`})}),t[6]=d):d=t[6];let f;t[7]===u?f=t[8]:(f=(0,Z.jsx)(ji,{value:`wysiwyg`,"aria-label":u,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,asChild:!0,children:d}),t[7]=u,t[8]=f);let p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(Ns,{side:`bottom`,children:(0,Z.jsx)(J,{id:`Mb_20S`})}),t[9]=p):p=t[9];let m;t[10]===f?m=t[11]:(m=(0,Z.jsxs)(Fs,{children:[f,p]}),t[10]=f,t[11]=m);let h;t[12]===o?h=t[13]:(h=o({id:`xbdtfY`}),t[12]=o,t[13]=h);let g;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(fM,{className:`size-4`}),t[14]=g):g=t[14];let _;t[15]!==a||t[16]!==h?(_=(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(`div`,{children:(0,Z.jsx)(ji,{value:`source`,"aria-label":h,disabled:a,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,children:g})})}),t[15]=a,t[16]=h,t[17]=_):_=t[17];let v;t[18]===a?v=t[19]:(v=(0,Z.jsx)(Ns,{side:`bottom`,children:a?(0,Z.jsx)(J,{id:`G-JBA1`}):(0,Z.jsx)(J,{id:`u6Hp4N`})}),t[18]=a,t[19]=v);let y;t[20]!==_||t[21]!==v?(y=(0,Z.jsxs)(Fs,{children:[_,v]}),t[20]=_,t[21]=v,t[22]=y):y=t[22];let b;return t[23]!==y||t[24]!==s||t[25]!==c||t[26]!==l||t[27]!==m?(b=(0,Z.jsxs)(Ni,{type:`single`,value:s,onValueChange:c,"aria-label":l,variant:`segmented`,size:`sm`,spacing:1,className:`shrink-0 bg-muted p-0.5 data-[size=sm]:rounded-[10px]`,children:[m,y]}),t[23]=y,t[24]=s,t[25]=c,t[26]=l,t[27]=m,t[28]=b):b=t[28],b}var hM=(0,Q.lazy)(async()=>({default:(await n(async()=>{let{SkillEditorActions:e}=await import(`./SkillEditorActions-zGJNqarO.js`);return{SkillEditorActions:e}},__vite__mapDeps([85,1,10,3,11,6,7,13,70,15,16,17,18,12,51,52,19,54,56,55,75,71,57,49,59,76,64,33,61]),import.meta.url)).SkillEditorActions}));function gM(e){let t=(0,$.c)(82),{activeDocName:n,isSourceMode:r,sourceDisabled:i,onModeChange:a,showAddPropertyButton:o,onAddProperty:s,isPanelCollapsed:c,onTogglePanel:l,reserveRightGutter:u}=e,d=u===void 0?!1:u,{_:f}=$t(),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=kl(`toggle-document-panel`),t[0]=p):p=t[0];let m=p,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k;if(t[1]!==f||t[2]!==n||t[3]!==c||t[4]!==r||t[5]!==s||t[6]!==a||t[7]!==l||t[8]!==d||t[9]!==o||t[10]!==i){let e=jl(`toggle-document-panel`),u;t[26]===n?u=t[27]:(u=n?Xr(n):null,t[26]=n,t[27]=u);let p=u,m;t[28]===n?m=t[29]:(m=n?Wt(n):null,t[28]=n,t[29]=m);let A=m,j;t[30]!==p||t[31]!==A?(j=p?.kind===`skill`?{scope:p.scope,name:p.name}:A?{scope:`project`,name:A}:null,t[30]=p,t[31]=A,t[32]=j):j=t[32];let M=j;b=`editor-toolbar`,x=`pointer-events-none absolute inset-x-0 top-0 z-10`;let N;t[33]!==n||t[34]!==M?(N=M?null:(0,Z.jsx)(cM,{docName:n}),t[33]=n,t[34]=M,t[35]=N):N=t[35];let P;t[36]===N?P=t[37]:(P=(0,Z.jsx)(`div`,{className:`pointer-events-auto flex min-w-0 items-center`,children:N}),t[36]=N,t[37]=P);let F;t[38]!==r||t[39]!==a||t[40]!==i?(F=(0,Z.jsx)(`div`,{className:`pointer-events-auto flex justify-center`,children:(0,Z.jsx)(mM,{isSourceMode:r,onModeChange:a,sourceDisabled:i})}),t[38]=r,t[39]=a,t[40]=i,t[41]=F):F=t[41],t[42]!==P||t[43]!==F?(S=(0,Z.jsx)(`div`,{className:`editor-content-aligned bg-background py-2`,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 items-center`,children:[P,F]})}),t[42]=P,t[43]=F,t[44]=S):S=t[44];let I=d&&`pr-9`;t[45]===I?_=t[46]:(_=Y(`pointer-events-auto absolute top-0 right-0 flex items-center justify-end gap-1 py-2 pr-2`,I),t[45]=I,t[46]=_),t[47]===M?v=t[48]:(v=M?(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(hM,{scope:M.scope,name:M.name})}):null,t[47]=M,t[48]=v),t[49]!==f||t[50]!==s||t[51]!==o?(y=o&&(0,Z.jsxs)(Fs,{children:[(0,Z.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":f({id:`81H_23`}),onClick:s,"data-testid":`add-properties-button`,asChild:!0,children:(0,Z.jsx)(Ms,{children:(0,Z.jsx)(Yd,{})})}),(0,Z.jsx)(Ns,{side:`bottom`,children:(0,Z.jsx)(J,{id:`81H_23`})})]}),t[49]=f,t[50]=s,t[51]=o,t[52]=y):y=t[52],g=Fs,h=X,C=``,w=`ghost`,T=`icon`,E=l,D=!c,O=`doc-panel`,k=f(c?{id:`u7H-Wn`,values:{panelShortcutLabel:e}}:{id:`2hpdRq`,values:{panelShortcutLabel:e}}),t[1]=f,t[2]=n,t[3]=c,t[4]=r,t[5]=s,t[6]=a,t[7]=l,t[8]=d,t[9]=o,t[10]=i,t[11]=h,t[12]=g,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,t[23]=D,t[24]=O,t[25]=k}else h=t[11],g=t[12],_=t[13],v=t[14],y=t[15],b=t[16],x=t[17],S=t[18],C=t[19],w=t[20],T=t[21],E=t[22],D=t[23],O=t[24],k=t[25];let A;t[53]===c?A=t[54]:(A=(0,Z.jsx)(Ms,{children:c?(0,Z.jsx)(sf,{}):(0,Z.jsx)(of,{})}),t[53]=c,t[54]=A);let j;t[55]!==h||t[56]!==A||t[57]!==C||t[58]!==w||t[59]!==T||t[60]!==E||t[61]!==D||t[62]!==O||t[63]!==k?(j=(0,Z.jsx)(h,{"data-doc-panel-toggle":C,variant:w,size:T,onClick:E,"aria-expanded":D,"aria-controls":O,"aria-label":k,asChild:!0,children:A}),t[55]=h,t[56]=A,t[57]=C,t[58]=w,t[59]=T,t[60]=E,t[61]=D,t[62]=O,t[63]=k,t[64]=j):j=t[64];let M;t[65]===c?M=t[66]:(M=(0,Z.jsx)(Ns,{side:`bottom`,children:c?(0,Z.jsx)(J,{id:`KFdXwz`,values:{panelShortcut:m}}):(0,Z.jsx)(J,{id:`MsuXaI`,values:{panelShortcut:m}})}),t[65]=c,t[66]=M);let N;t[67]!==g||t[68]!==j||t[69]!==M?(N=(0,Z.jsxs)(g,{children:[j,M]}),t[67]=g,t[68]=j,t[69]=M,t[70]=N):N=t[70];let P;t[71]!==_||t[72]!==v||t[73]!==y||t[74]!==N?(P=(0,Z.jsxs)(`div`,{className:_,children:[v,y,N]}),t[71]=_,t[72]=v,t[73]=y,t[74]=N,t[75]=P):P=t[75];let F;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none h-2 bg-linear-to-b from-background to-transparent`}),t[76]=F):F=t[76];let I;return t[77]!==b||t[78]!==x||t[79]!==S||t[80]!==P?(I=(0,Z.jsxs)(`div`,{"data-testid":b,className:x,children:[S,P,F]}),t[77]=b,t[78]=x,t[79]=S,t[80]=P,t[81]=I):I=t[81],I}function _M(e){let{activeDocName:t,deferredActiveDocName:n,mountResolved:r,syncResolved:i}=e;return t===null||t===n?!1:!(r&&i)}function vM(e){let{currentLayout:t,containerPx:n,pinnedPx:r,residualId:i}=e;if(n<=0||!(i in t))return t;let a={...t},o=0;for(let[e,i]of Object.entries(r)){if(!(e in t))continue;let r=i/n*100;a[e]=r,o+=r}let s=0;for(let[e,n]of Object.entries(t))e===i||e in r||(s+=n);let c=100-o-s;return c<0?t:(a[i]=c,a)}var yM=`ok-terminal-height-v1`,bM=1/3,xM=.5;function SM(e){return Math.max(120,Math.round((Number.isFinite(e)?e:0)*xM))}function CM(e){let t=Number.isFinite(e)?e:0;return t<=0?240:Math.round(t*bM)}function wM(e,t){let n=SM(t);return Number.isFinite(e)?e<120?120:e>n?n:Math.round(e):Math.min(CM(t),n)}function TM(){return typeof window>`u`?0:window.innerHeight}function EM(e,t){try{let n=e??localStorage,r=t??TM(),i=n.getItem(yM);if(i==null)return wM(CM(r),r);let a=Number.parseInt(i,10);return wM(Number.isFinite(a)?a:CM(r),r)}catch{return 240}}function DM(e,t,n){try{let r=t??localStorage,i=n??TM();r.setItem(yM,String(wM(e,i)))}catch{}}function OM(){try{return typeof localStorage>`u`?240:EM()}catch{return 240}}function kM(e){let t=(0,$.c)(19),{dockPosition:n,onReveal:r,className:i}=e,{_:a}=$t(),o=n===`right`,s;t[0]===a?s=t[1]:(s=a({id:`0SBTff`}),t[0]=a,t[1]=s);let c=s,l=o?`rounded-r-none border-r-0`:`rounded-b-none border-b-0`,u;t[2]!==i||t[3]!==l?(u=Y(`absolute z-20 shrink-0 bg-background text-muted-foreground shadow-sm hover:text-foreground`,l,i),t[2]=i,t[3]=l,t[4]=u):u=t[4];let d;t[5]===o?d=t[6]:(d=o?(0,Z.jsx)(Ki,{"aria-hidden":`true`}):(0,Z.jsx)(bt,{"aria-hidden":`true`}),t[5]=o,t[6]=d);let f;t[7]!==n||t[8]!==c||t[9]!==r||t[10]!==u||t[11]!==d?(f=(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(X,{type:`button`,variant:`outline`,size:`icon-sm`,"aria-label":c,"data-terminal-reveal":n,onClick:r,className:u,children:d})}),t[7]=n,t[8]=c,t[9]=r,t[10]=u,t[11]=d,t[12]=f):f=t[12];let p=o?`left`:`top`,m;t[13]!==c||t[14]!==p?(m=(0,Z.jsx)(Ns,{side:p,sideOffset:8,children:c}),t[13]=c,t[14]=p,t[15]=m):m=t[15];let h;return t[16]!==f||t[17]!==m?(h=(0,Z.jsxs)(Fs,{children:[f,m]}),t[16]=f,t[17]=m,t[18]=h):h=t[18],h}var AM=`terminal-dock-panel`;function jM(e){let t=(0,$.c)(44),{children:n,visible:r,onVisibleChange:i,dockPosition:a,onBottomContainer:o,onEditorRegion:s,onReveal:c}=e,l=a===void 0?`bottom`:a,{resolvedTheme:u}=Mn(),d=Ib(),[f,p]=(0,Q.useState)(!r),m;t[0]===u?m=t[1]:(m=wu(u),t[0]=u,t[1]=m);let h=m.background,g=r&&l===`bottom`,_=!r&&l===`bottom`&&c!=null,[v]=(0,Q.useState)(MM),y=(0,Q.useRef)(v),[b,x]=(0,Q.useState)(!1),S=(0,Q.useRef)(!1),C=(0,Q.useRef)(null),w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=function(e){C.current!=null&&clearTimeout(C.current),C.current=setTimeout(()=>{DM(e),C.current=null},100)},t[2]=w):w=t[2];let T=w,E=(0,Q.useRef)(null),D,O;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(D=()=>()=>{C.current!=null&&clearTimeout(C.current),E.current!=null&&(window.removeEventListener(`pointerup`,E.current),E.current=null)},O=[],t[3]=D,t[4]=O):(D=t[3],O=t[4]),(0,Q.useEffect)(D,O);let k,A;t[5]!==g||t[6]!==d?(k=()=>{let e=d.current;e!=null&&(g?e.resize(`${y.current}px`):e.collapse())},A=[g,d],t[5]=g,t[6]=d,t[7]=k,t[8]=A):(k=t[7],A=t[8]),(0,Q.useEffect)(k,A);let j=b||void 0,M;t[9]!==c||t[10]!==_?(M=_&&c?(0,Z.jsx)(kM,{dockPosition:`bottom`,onReveal:c,className:`right-3 bottom-0`}):null,t[9]=c,t[10]=_,t[11]=M):M=t[11];let N;t[12]!==n||t[13]!==s||t[14]!==M?(N=(0,Z.jsx)(LC,{minSize:`5%`,className:`flex min-h-0 flex-col`,children:(0,Z.jsxs)(`div`,{ref:s,tabIndex:-1,className:`relative flex h-full min-h-0 flex-col outline-none`,children:[n,M]})}),t[12]=n,t[13]=s,t[14]=M,t[15]=N):N=t[15];let P=!g,F;t[16]===g?F=t[17]:(F=()=>{if(!g)return;x(!0),S.current=!0;let e=()=>{x(!1),S.current=!1,window.removeEventListener(`pointerup`,e),E.current=null};E.current=e,window.addEventListener(`pointerup`,e)},t[16]=g,t[17]=F);let I;t[18]!==g||t[19]!==P||t[20]!==F?(I=(0,Z.jsx)(RC,{withHandle:g,disabled:P,onPointerDown:F}),t[18]=g,t[19]=P,t[20]=F,t[21]=I):I=t[21];let L;t[22]===h?L=t[23]:(L={backgroundColor:h},t[22]=h,t[23]=L);let R=g?`${v}px`:0,z;t[24]!==i||t[25]!==r?(z=e=>{let t=e.asPercentage===0;p(t),S.current&&(t&&r?i(!1):!t&&!r&&i(!0),e.inPixels>0&&(y.current=e.inPixels,T(e.inPixels)))},t[24]=i,t[25]=r,t[26]=z):z=t[26];let B=!b&&`transition-[flex-grow] duration-150 ease-out motion-reduce:transition-none motion-reduce:duration-0`,V;t[27]===B?V=t[28]:(V=Y(`flex flex-col`,B),t[27]=B,t[28]=V);let H;t[29]===o?H=t[30]:(H=(0,Z.jsx)(`div`,{ref:o,className:`flex min-h-0 flex-1 flex-col overflow-hidden`}),t[29]=o,t[30]=H);let U;t[31]!==f||t[32]!==d||t[33]!==L||t[34]!==R||t[35]!==z||t[36]!==V||t[37]!==H?(U=(0,Z.jsx)(LC,{id:AM,style:L,panelRef:d,defaultSize:R,minSize:`120px`,maxSize:`95%`,collapsible:!0,collapsedSize:0,onResize:z,inert:f,className:V,children:H}),t[31]=f,t[32]=d,t[33]=L,t[34]=R,t[35]=z,t[36]=V,t[37]=H,t[38]=U):U=t[38];let W;return t[39]!==N||t[40]!==I||t[41]!==U||t[42]!==j?(W=(0,Z.jsxs)(IC,{orientation:`vertical`,className:`min-h-0 flex-1`,"data-dragging":j,children:[N,I,U]}),t[39]=N,t[40]=I,t[41]=U,t[42]=j,t[43]=W):W=t[43],W}function MM(){return OM()}var NM=(0,Q.lazy)(async()=>({default:(await n(()=>import(`./ActivityModeContent-Bq2-szSy.js`),__vite__mapDeps([36,1,2,37,38,39,11,40,41,42,43,44,45,46,47,15,16,13,7,17,18,10,3,48,49,33,12,6,4,50,51,52,20,53,54,55,56,30,31,32,57,58,59,60,61,62,63,64]),import.meta.url)).ActivityModeContent})),PM=`300px`,FM=`600px`,IM=new Set([`doc-panel`,`terminal-column`,`agent-panel`]);function LM(e){let t=(0,$.c)(5),n;t[0]===e?n=t[1]:(n=(0,Z.jsx)(zM,{...e}),t[0]=e,t[1]=n);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(RM,{}),t[2]=r):r=t[2];let i;return t[3]===n?i=t[4]:(i=(0,Z.jsx)(El,{name:`editor-area`,children:(0,Z.jsxs)(Li,{children:[n,r]})}),t[3]=n,t[4]=i),i}function RM(){let e=(0,$.c)(5),t=yo(),n;e[0]===t?n=e[1]:(n=e=>{e||t.close()},e[0]=t,e[1]=n);let r;return e[2]!==t.open||e[3]!==n?(r=(0,Z.jsx)(jC,{open:t.open,onOpenChange:n}),e[2]=t.open,e[3]=n,e[4]=r):r=e[4],r}function zM(e){let t=(0,$.c)(243),{editorMode:n,onModeChange:r,activeTab:i,onActiveTabChange:a,terminalBridge:o,terminalVisible:s,onTerminalVisibleChange:c,terminalDock:l,onTerminalPlacement:u,onRevealTerminal:d}=e,f=s===void 0?!1:s,p=l===void 0?`right`:l,{_:m}=$t(),{resolvedTheme:h}=Mn(),g;t[0]===h?g=t[1]:(g=wu(h),t[0]=h,t[1]=g);let _=g.background,{activeDocName:v,activeProvider:y,activeTarget:b,recycleDocument:x,docPanelMode:S,docPanelAgentId:C,docPanelExpandSignal:w}=mt(),{openDocumentTransition:T}=Dt(),{requestAddProperty:E}=Pi(),D=ow(y,v),O=lw(v,n===`source`?`source`:`wysiwyg`),k=Pw(y),A=k===`connected`||k===`synced`,M=cw(v)===`conflict`,[N,P]=(0,Q.useState)(!1),F,I;t[2]!==y||t[3]!==N?(F=()=>{y!=null&&!N&&P(!0)},I=[y,N],t[2]=y,t[3]=N,t[4]=F,t[5]=I):(F=t[4],I=t[5]),(0,Q.useEffect)(F,I);let L=(0,Q.useDeferredValue)(v),R=b?.kind===`missing`,z=!!v&&b?.kind!==`folder`,B;t[6]!==m||t[7]!==R?(B=R?m({id:`K-a33w`}):void 0,t[6]=m,t[7]=R,t[8]=B):B=t[8];let V=B,H=(0,Q.useSyncExternalStore)(xi.subscribe,xi.getSnapshot,xi.getSnapshot),U;t[9]!==b||t[10]!==H?(U=wi(b,H),t[9]=b,t[10]=H,t[11]=U):U=t[11];let W=U,[G]=(0,Q.useState)(WM),K=G!==null,ee;t[12]===G?ee=t[13]:(ee=()=>vw(G,window.innerWidth,`right`),t[12]=G,t[13]=ee);let[te,ne]=(0,Q.useState)(ee),re=(0,Q.useRef)(te),ie,ae;t[14]===te?(ie=t[15],ae=t[16]):(ae=()=>{re.current=te},ie=[te],t[14]=te,t[15]=ie,t[16]=ae),(0,Q.useEffect)(ae,ie);let oe=Ib(),se=Ib(),ce;t[17]===te?ce=t[18]:(ce=()=>Dw(`right`,te,Tw())===`collapsed`,t[17]=te,t[18]=ce);let[le]=(0,Q.useState)(ce),[q,ue]=(0,Q.useState)(le),de=(0,Q.useRef)(q),[fe,pe]=(0,Q.useState)(null),[me,he]=(0,Q.useState)(null),[ge,_e]=(0,Q.useState)(null),ve=p===`right`,ye=ve?`right`:`bottom`,be=o!=null&&ve&&f,xe=o!=null&&!f&&d!=null,Se=xe&&!ve,Ce=xe&&ve,we=ve&&f&&fe!=null,Te=we?fe:me,Ee=(ve?we:f)&&Te!=null,De,Oe;t[19]!==Te||t[20]!==u||t[21]!==ye||t[22]!==ge||t[23]!==Ee?(De=()=>{u?.({container:Te,isShowing:Ee,dockPosition:ye,editorRegion:ge})},Oe=[u,Te,Ee,ye,ge],t[19]=Te,t[20]=u,t[21]=ye,t[22]=ge,t[23]=Ee,t[24]=De,t[25]=Oe):(De=t[24],Oe=t[25]),(0,Q.useEffect)(De,Oe);let ke,Ae;t[26]===q?(ke=t[27],Ae=t[28]):(ke=()=>{de.current=q},Ae=[q],t[26]=q,t[27]=ke,t[28]=Ae),(0,Q.useEffect)(ke,Ae);let[je,Me]=(0,Q.useState)(!1),Ne=(0,Q.useRef)(!1),[Pe]=(0,Q.useState)(UM),Fe=(0,Q.useRef)(Pe),Le=(0,Q.useRef)(null),Re;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(Re=function(e){Le.current!=null&&clearTimeout(Le.current),Le.current=setTimeout(()=>{pw(e),Le.current=null},100)},t[29]=Re):Re=t[29];let ze=Re,[Be]=(0,Q.useState)(HM),Ve=(0,Q.useRef)(Be),[He,Ue]=(0,Q.useState)(!1),We=(0,Q.useRef)(!1),Ge=(0,Q.useRef)(null),Ke;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=function(e){Ge.current!=null&&clearTimeout(Ge.current),Ge.current=setTimeout(()=>{Mw(e),Ge.current=null},100)},t[30]=Ke):Ke=t[30];let qe=Ke,Je,Ye;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(Je=()=>()=>{Le.current!=null&&clearTimeout(Le.current),Ge.current!=null&&clearTimeout(Ge.current)},Ye=[],t[31]=Je,t[32]=Ye):(Je=t[31],Ye=t[32]),(0,Q.useEffect)(Je,Ye);let[Xe,Ze]=(0,Q.useState)(null),Qe=(0,Q.useRef)(null),$e=jb(),et=(0,Q.useRef)(be),tt,nt;t[33]===be?(tt=t[34],nt=t[35]):(tt=()=>{et.current=be},nt=[be],t[33]=be,t[34]=tt,t[35]=nt),(0,Q.useEffect)(tt,nt);let rt;t[36]!==oe||t[37]!==se?(rt=function(){for(let e of[oe,se]){let t=e.current?.getSize();if(t!=null&&t.asPercentage>1&&t.inPixels>0)return t.inPixels/t.asPercentage*100}let e=Qe.current;return e!=null&&e.offsetWidth>0?e.offsetWidth:null},t[36]=oe,t[37]=se,t[38]=rt):rt=t[38];let it=rt,at;t[39]!==$e||t[40]!==it?(at=function(e){if(Ne.current||We.current)return;let t=$e.current;if(t!=null)try{let n=it();if(n==null)return;let r=t.getLayout(),i=Object.keys(r);if(i.length===0)return;let a=i.find(VM);if(a==null)return;let o={};if(`doc-panel`in r&&(o[`doc-panel`]=e?0:Fe.current),`terminal-column`in r&&(o[`terminal-column`]=Ve.current),Object.keys(o).length===0)return;let s=vM({currentLayout:r,containerPx:n,pinnedPx:o,residualId:a});s!==r&&t.setLayout(s)}catch{}},t[39]=$e,t[40]=it,t[41]=at):at=t[41];let ot=at,st=(0,Q.useRef)(ot),ct;t[42]===ot?ct=t[43]:(ct=()=>{st.current=ot},t[42]=ot,t[43]=ct),(0,Q.useEffect)(ct);let lt;t[44]!==ot||t[45]!==oe?(lt=function(){et.current?ot(!1):oe.current?.expand()},t[44]=ot,t[45]=oe,t[46]=lt):lt=t[46];let ut=lt,dt;t[47]!==ot||t[48]!==q||t[49]!==oe?(dt=function(){if(oe.current==null)return;let e=re.current;q?(Ow(`right`,e,`open`),et.current?ot(!1):oe.current?.expand()):(Ow(`right`,e,`collapsed`),et.current?ot(!0):oe.current?.collapse())},t[47]=ot,t[48]=q,t[49]=oe,t[50]=dt):dt=t[50];let ft=dt,pt,ht;t[51]!==ot||t[52]!==G||t[53]!==oe?(pt=()=>{let e=window.matchMedia(`(min-width: ${gw}px)`),t=()=>{let e=vw(G,window.innerWidth,`right`);ne(e);let t=Dw(`right`,e,Tw())===`collapsed`;ue(t),et.current?ot(t):t?oe.current?.collapse():oe.current?.expand()};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},ht=[G,oe,ot],t[51]=ot,t[52]=G,t[53]=oe,t[54]=pt,t[55]=ht):(pt=t[54],ht=t[55]),(0,Q.useEffect)(pt,ht);let gt,_t;t[56]!==Xe||t[57]!==K?(gt=()=>{if(Xe==null||K)return;let e=new ResizeObserver(()=>{st.current(de.current)});return e.observe(Xe),()=>e.disconnect()},_t=[Xe,K],t[56]=Xe,t[57]=K,t[58]=gt,t[59]=_t):(gt=t[58],_t=t[59]),(0,Q.useEffect)(gt,_t);let vt,yt;t[60]!==ut||t[61]!==a?(vt=()=>{let e=e=>{a(e),ut()},t=$m();return t&&e(t),th(t=>{$m(),e(t)})},yt=[a,ut],t[60]=ut,t[61]=a,t[62]=vt,t[63]=yt):(vt=t[62],yt=t[63]),(0,Q.useEffect)(vt,yt);let bt,xt;t[64]!==w||t[65]!==ut?(bt=()=>{w!==0&&ut()},xt=[w,ut],t[64]=w,t[65]=ut,t[66]=bt,t[67]=xt):(bt=t[66],xt=t[67]),(0,Q.useEffect)(bt,xt);let St=(0,Q.useRef)(be),Ct,wt;t[68]!==q||t[69]!==be?(Ct=()=>{if(St.current===be)return;St.current=be;let e=q;queueMicrotask(()=>{st.current(e)})},wt=[be,q],t[68]=q,t[69]=be,t[70]=Ct,t[71]=wt):(Ct=t[70],wt=t[71]),(0,Q.useLayoutEffect)(Ct,wt);let Tt,Et;t[72]===q?(Tt=t[73],Et=t[74]):(Tt=()=>{if(!q||!document.getElementById(`doc-panel`)?.contains(document.activeElement))return;let e=document.querySelector(`[data-doc-panel-toggle]`);if(e){e.focus();return}document.querySelector(`[data-sidebar="trigger"]`)?.focus()},Et=[q],t[72]=q,t[73]=Tt,t[74]=Et),(0,Q.useLayoutEffect)(Tt,Et);let Ot,kt;t[75]===q?(Ot=t[76],kt=t[77]):(Ot=()=>{window.okDesktop!=null&&window.okDesktop.editor.notifyViewMenuStateChanged({docPanelVisible:!q})},kt=[q],t[75]=q,t[76]=Ot,t[77]=kt),(0,Q.useEffect)(Ot,kt);let At,jt;t[78]===ft?(At=t[79],jt=t[80]):(At=()=>{if(window.okDesktop!=null)return window.okDesktop.onMenuAction(e=>{e===`toggle-doc-panel`&&ft()})},jt=[ft],t[78]=ft,t[79]=At,t[80]=jt),(0,Q.useEffect)(At,jt);let Mt,Nt;t[81]===ft?(Mt=t[82],Nt=t[83]):(Mt=()=>{if(window.okDesktop!=null)return;let e=e=>{Al(e,`toggle-document-panel`)&&(e.preventDefault(),ft())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},Nt=[ft],t[81]=ft,t[82]=Mt,t[83]=Nt),(0,Q.useEffect)(Mt,Nt);let Pt=(0,Q.useRef)(null),[Ft,It]=(0,Q.useState)(null),[Lt,Rt]=(0,Q.useState)(!1),zt=b?.kind===`large-file`?b.docName:v,Bt,Vt;t[84]===zt?(Bt=t[85],Vt=t[86]):(Bt=()=>{if(zt&&zt!==Pt.current){let e=Pt.current;Pt.current=zt,It(e)}},Vt=[zt],t[84]=zt,t[85]=Bt,t[86]=Vt),(0,Q.useEffect)(Bt,Vt);let Ht;t[87]===T?Ht=t[88]:(Ht=function(e){let t=yl(e);window.location.hash===t?T(e):window.location.hash=t},t[87]=T,t[88]=Ht);let Ut=Ht,Wt,Gt=null;if(b?.kind===`large-file`){let e;t[89]!==Ut||t[90]!==Ft?(e=Ft?{previousDocName:Ft,onNavigateBack:Ut}:void 0,t[89]=Ut,t[90]=Ft,t[91]=e):e=t[91];let n;t[92]!==b.docName||t[93]!==b.limit||t[94]!==b.size||t[95]!==e?(n=(0,Z.jsx)(pC,{docName:b.docName,size:b.size,limit:b.limit,backNav:e}),t[92]=b.docName,t[93]=b.limit,t[94]=b.size,t[95]=e,t[96]=n):n=t[96],Wt=n}else if(b?.kind===`folder`){let e;t[97]!==K||t[98]!==f?(e=bT({terminalVisible:f,isEmbedded:K}),t[97]=K,t[98]=f,t[99]=e):e=t[99];let n=e,r;t[100]===b.folderPath?r=t[101]:(r=(0,Z.jsx)(lC,{folderPath:b.folderPath}),t[100]=b.folderPath,t[101]=r);let i;t[102]!==b.folderPath||t[103]!==n?(i=n?(0,Z.jsx)(sT,{folderPath:b.folderPath}):null,t[102]=b.folderPath,t[103]=n,t[104]=i):i=t[104];let a;if(t[105]!==r||t[106]!==i?(a=(0,Z.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,children:[r,i]}),t[105]=r,t[106]=i,t[107]=a):a=t[107],Wt=a,S===`agent`&&C!==null){let e;t[108]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(RC,{withHandle:!0}),t[108]=e):e=t[108];let n;t[109]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsxs)(Z.Fragment,{children:[e,(0,Z.jsx)(LC,{id:`agent-panel`,defaultSize:`25%`,minSize:`300px`,maxSize:`40%`,className:`flex flex-col bg-muted/20`,children:(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(`div`,{role:`status`,"aria-busy":`true`,className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:(0,Z.jsx)(J,{id:`ONPvOb`})}),children:(0,Z.jsx)(NM,{showBackButton:!1})})})]}),t[109]=n):n=t[109],Gt=n}}else if(b?.kind===`asset`){let e;t[110]!==b.assetPath||t[111]!==b.mediaKind?(e=(0,Z.jsx)(Zb,{assetPath:b.assetPath,mediaKind:b.mediaKind},b.assetPath),t[110]=b.assetPath,t[111]=b.mediaKind,t[112]=e):e=t[112],Wt=e}else if(b?.kind===`skill-file`){let e=`${b.scope}/${b.name}/${b.path}`,n;t[113]!==b.name||t[114]!==b.path||t[115]!==b.scope||t[116]!==e?(n=(0,Z.jsx)(SC,{scope:b.scope,name:b.name,path:b.path},e),t[113]=b.name,t[114]=b.path,t[115]=b.scope,t[116]=e,t[117]=n):n=t[117],Wt=n}else if(W){let e;t[118]===W?e=t[119]:(e=(0,Z.jsx)(gC,{nav:W},W.path),t[118]=W,t[119]=e),Wt=e}else if(!y||!v)if((typeof window<`u`?vl(window.location.hash):null)!==null)if(o!=null&&N){let e;t[120]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Qb,{}),t[120]=e):e=t[120],Wt=e;let n;t[121]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(RC,{withHandle:!0,disabled:!0}),t[121]=n):n=t[121];let r=le?0:`${Pe}px`,i;t[122]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1`}),t[122]=i):i=t[122];let a;t[123]===r?a=t[124]:(a=(0,Z.jsxs)(Z.Fragment,{children:[n,(0,Z.jsx)(LC,{id:`doc-panel`,defaultSize:r,minSize:PM,maxSize:FM,collapsible:!0,collapsedSize:0,inert:!0,className:`flex flex-col bg-muted/20`,children:i})]}),t[123]=r,t[124]=a),Gt=a}else{let e;return t[125]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Qb,{}),t[125]=e):e=t[125],e}else{let e=f?ye:null,n;t[126]===e?n=t[127]:(n=(0,Z.jsx)(AS,{terminalDock:e}),t[126]=e,t[127]=n),Wt=n}else{let e=n===`source`,o=!A,s=q,c;t[128]!==v||t[129]!==E?(c=function(){v&&E(v)},t[128]=v,t[129]=E,t[130]=c):c=t[130];let l=c,u;t[131]!==v||t[132]!==K||t[133]!==f?(u=yT({terminalVisible:f,isEmbedded:K,activeDocName:v}),t[131]=v,t[132]=K,t[133]=f,t[134]=u):u=t[134];let d=u,p=L??v,m=Ft??void 0,h;t[135]!==V||t[136]!==e||t[137]!==Ut||t[138]!==x||t[139]!==p||t[140]!==m?(h=(0,Z.jsx)(ZA,{activeDocName:p,isSourceMode:e,editorPlaceholder:V,previousDocName:m,onNavigateBack:Ut,onRecycle:x}),t[135]=V,t[136]=e,t[137]=Ut,t[138]=x,t[139]=p,t[140]=m,t[141]=h):h=t[141];let g;t[142]!==v||t[143]!==e?(g=(0,Z.jsx)(nw,{activeDocName:v,isSourceMode:e}),t[142]=v,t[143]=e,t[144]=g):g=t[144];let _;t[145]!==v||t[146]!==L?(_=_M({activeDocName:v,deferredActiveDocName:L,mountResolved:v!==null&&j(v),syncResolved:v!==null&&Ie(v)})?(0,Z.jsxs)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:[(0,Z.jsx)(Qb,{}),v===null?null:(0,Z.jsx)(mC,{docName:v})]}):null,t[145]=v,t[146]=L,t[147]=_):_=t[147];let y;t[148]!==h||t[149]!==g||t[150]!==_?(y=(0,Z.jsxs)(`div`,{className:`relative h-full`,children:[h,g,_]}),t[148]=h,t[149]=g,t[150]=_,t[151]=y):y=t[151];let b;t[152]!==v||t[153]!==M||t[154]!==s||t[155]!==e||t[156]!==r||t[157]!==l||t[158]!==Ce||t[159]!==o||t[160]!==ft?(b=!M&&(0,Z.jsx)(gM,{activeDocName:v,isSourceMode:e,sourceDisabled:o,onModeChange:r,showAddPropertyButton:!e,onAddProperty:l,isPanelCollapsed:s,onTogglePanel:ft,reserveRightGutter:Ce&&s}),t[152]=v,t[153]=M,t[154]=s,t[155]=e,t[156]=r,t[157]=l,t[158]=Ce,t[159]=o,t[160]=ft,t[161]=b):b=t[161];let C;t[162]!==v||t[163]!==Lt||t[164]!==e||t[165]!==d?(C=d?(0,Z.jsx)(sT,{docName:v,surface:e?`source`:`wysiwyg`,dismissed:Lt,onDismiss:()=>Rt(!0),onReopen:()=>Rt(!1)}):null,t[162]=v,t[163]=Lt,t[164]=e,t[165]=d,t[166]=C):C=t[166];let w;t[167]!==y||t[168]!==b||t[169]!==C?(w=(0,Z.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[y,b,C]}),t[167]=y,t[168]=b,t[169]=C,t[170]=w):w=t[170];let T;t[171]!==Lt||t[172]!==d?(T=d&&Lt?{onReopen:()=>Rt(!1)}:null,t[171]=Lt,t[172]=d,t[173]=T):T=t[173];let k;t[174]!==Se||t[175]!==O||t[176]!==z||t[177]!==D||t[178]!==T?(k=(0,Z.jsx)(Qj,{stats:D,selectionStats:O,showStats:z,composerBadge:T,reserveRightGutter:Se}),t[174]=Se,t[175]=O,t[176]=z,t[177]=D,t[178]=T,t[179]=k):k=t[179];let N;t[180]!==w||t[181]!==k?(N=(0,Z.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[w,k]}),t[180]=w,t[181]=k,t[182]=N):N=t[182],Wt=N;let P=be&&q,F=!q,I;t[183]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>{Me(!0),Ne.current=!0;let e=()=>{Me(!1),Ne.current=!1,window.removeEventListener(`pointerup`,e)};window.addEventListener(`pointerup`,e)},t[183]=I):I=t[183];let R;t[184]!==q||t[185]!==F?(R=(0,Z.jsx)(RC,{withHandle:F,disabled:q,onPointerDown:I}),t[184]=q,t[185]=F,t[186]=R):R=t[186];let B=le?0:`${Pe}px`,H=P?`0px`:PM,U;t[187]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>{ue(e.asPercentage===0),e.inPixels>0&&Ne.current&&(Fe.current=e.inPixels,ze(e.inPixels))},t[187]=U):U=t[187];let W=!je&&`transition-[flex-grow] duration-200 ease-out motion-reduce:transition-none motion-reduce:duration-0`,G;t[188]===W?G=t[189]:(G=Y(`flex flex-col bg-muted/20`,W),t[188]=W,t[189]=G);let ee;t[190]!==v||t[191]!==i||t[192]!==S||t[193]!==e||t[194]!==a?(ee=(0,Z.jsx)(Vv,{docName:v,isSourceMode:e,activeTab:i,onActiveTabChange:a,mode:S}),t[190]=v,t[191]=i,t[192]=S,t[193]=e,t[194]=a,t[195]=ee):ee=t[195];let te;t[196]!==P||t[197]!==q||t[198]!==oe||t[199]!==B||t[200]!==H||t[201]!==G||t[202]!==ee?(te=(0,Z.jsx)(LC,{id:`doc-panel`,panelRef:oe,disabled:P,defaultSize:B,minSize:H,maxSize:FM,collapsible:!0,collapsedSize:0,onResize:U,inert:q,className:G,children:ee}),t[196]=P,t[197]=q,t[198]=oe,t[199]=B,t[200]=H,t[201]=G,t[202]=ee,t[203]=te):te=t[203];let ne;t[204]!==R||t[205]!==te?(ne=(0,Z.jsxs)(Z.Fragment,{children:[R,te]}),t[204]=R,t[205]=te,t[206]=ne):ne=t[206],Gt=ne}let Kt;t[207]!==d||t[208]!==c||t[209]!==o||t[210]!==ye||t[211]!==f||t[212]!==Wt?(Kt=o==null?Wt:(0,Z.jsx)(jM,{visible:f,onVisibleChange:c??BM,dockPosition:ye,onBottomContainer:he,onEditorRegion:_e,onReveal:d,children:Wt}),t[207]=d,t[208]=c,t[209]=o,t[210]=ye,t[211]=f,t[212]=Wt,t[213]=Kt):Kt=t[213];let qt=Kt,Jt;t[214]!==Be||t[215]!==He||t[216]!==c||t[217]!==se||t[218]!==be||t[219]!==_?(Jt=be?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(RC,{withHandle:!0,onPointerDown:()=>{Ue(!0),We.current=!0;let e=()=>{Ue(!1),We.current=!1,window.removeEventListener(`pointerup`,e),se.current?.isCollapsed()&&c?.(!1)};window.addEventListener(`pointerup`,e)}}),(0,Z.jsx)(LC,{id:`terminal-column`,panelRef:se,style:{backgroundColor:_},defaultSize:`${Be}px`,minSize:`320px`,maxSize:`95%`,collapsible:!0,collapsedSize:0,onResize:e=>{e.inPixels>0&&We.current&&(Ve.current=e.inPixels,qe(e.inPixels))},className:Y(`flex flex-col`,!He&&`transition-[flex-grow] duration-200 ease-out motion-reduce:transition-none motion-reduce:duration-0`),children:(0,Z.jsx)(`div`,{ref:pe,className:`flex min-h-0 flex-1 flex-col overflow-hidden`})})]}):null,t[214]=Be,t[215]=He,t[216]=c,t[217]=se,t[218]=be,t[219]=_,t[220]=Jt):Jt=t[220];let Yt=Jt,Xt=Gt!=null&&!le||be,Zt;t[221]===Symbol.for(`react.memo_cache_sentinel`)?(Zt=e=>{Ze(e),Qe.current=e},t[221]=Zt):Zt=t[221];let Qt=je||He||void 0,en=be?`5%`:`30%`,tn;t[222]===Xt?tn=t[223]:(tn=Xt?{}:{defaultSize:`100%`},t[222]=Xt,t[223]=tn);let nn=!(je||He)&&`transition-[flex-grow] duration-200 ease-out motion-reduce:transition-none motion-reduce:duration-0`,rn;t[224]===nn?rn=t[225]:(rn=Y(nn),t[224]=nn,t[225]=rn);let an;t[226]!==qt||t[227]!==en||t[228]!==tn||t[229]!==rn?(an=(0,Z.jsx)(LC,{minSize:en,...tn,className:rn,children:qt}),t[226]=qt,t[227]=en,t[228]=tn,t[229]=rn,t[230]=an):an=t[230];let on;t[231]!==$e||t[232]!==Gt||t[233]!==Qt||t[234]!==an||t[235]!==Yt?(on=(0,Z.jsxs)(IC,{orientation:`horizontal`,groupRef:$e,"data-dragging":Qt,children:[an,Gt,Yt]}),t[231]=$e,t[232]=Gt,t[233]=Qt,t[234]=an,t[235]=Yt,t[236]=on):on=t[236];let sn;t[237]!==d||t[238]!==Ce?(sn=Ce?(0,Z.jsx)(kM,{dockPosition:`right`,onReveal:d,className:`top-2.5 right-0`}):null,t[237]=d,t[238]=Ce,t[239]=sn):sn=t[239];let cn;return t[240]!==on||t[241]!==sn?(cn=(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,ref:Zt,children:[on,sn]}),t[240]=on,t[241]=sn,t[242]=cn):cn=t[242],cn}function BM(){}function VM(e){return!IM.has(e)}function HM(){return Nw()}function UM(){return mw()}function WM(){return kr()}function GM(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 KM(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 qM=1e3,JM=!1;function YM(e){return!!(e.localPrincipalId&&e.entryPrincipalId===e.localPrincipalId||!e.localPrincipalId&&e.entryClientId===e.localClientId)}function XM(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:xs(i)?a=i:(a=void 0,JM||(JM=!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`&&(YM({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=KM(i),{current:c,crossDoc:l}=a?_s(a,n,Date.now()):{current:[],crossDoc:[]},u=ZM,d=c.map(u),f=l.map(u),p=[...s,...d],m=f;o(e=>GM(e.current,p)&&GM(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,qM);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 ZM(e){let{agentId:t,entry:n}=e;return{kind:`agent`,agentId:t,presence:n}}var QM=!1,$M=new Set,eN=!1;function tN(){for(let e of $M)e()}function nN(e){QM!==e&&(QM=e,tN())}function rN(){return QM}function iN(e){return $M.add(e),()=>{$M.delete(e)}}function aN(e){let t=[e.onUpdateRelaunching(()=>nN(!0)),e.onUpdateRelaunchFailed(()=>nN(!1))];return()=>{for(let e of t)e()}}function oN(){if(eN||typeof window>`u`)return;let e=window.okDesktop;e&&(eN=!0,aN(e))}function sN(){return(0,Q.useSyncExternalStore)(iN,rN,cN)}function cN(){return!1}var lN=`sync-status`;async function uN(e){try{let t=await Ag(e);t.ok||Ss.error(t.message,{id:lN,duration:1/0})}catch{}}function dN(e,t){let n=(0,$.c)(6),{_:r}=$t(),i=sN(),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(!1),s=(0,Q.useRef)(t),c,l;n[0]!==r||n[1]!==t||n[2]!==i||n[3]!==e?(c=()=>{if(s.current!==t&&(s.current=t,a.current=!1,o.current=!1),t)if(e===`synced`&&(a.current=!0),e===`disconnected`&&a.current){if(i){Ss.dismiss(lN);return}o.current=!0;let e=window.okDesktop;Ss.warning(r({id:`HGNCsl`}),{id:lN,duration:1/0,...e?{action:{label:r({id:`uaUc6t`}),onClick:()=>{uN(e)}}}:{}})}else o.current&&e===`synced`&&(o.current=!1,Ss.success(r({id:`GhjUB_`}),{id:lN,duration:3e3}))},l=[e,t,r,i],n[0]=r,n[1]=t,n[2]=i,n[3]=e,n[4]=c,n[5]=l):(c=n[4],l=n[5]),(0,Q.useEffect)(c,l)}var fN=4,pN=3,mN={Bird:md,Cat:xd,Dog:kd,Fish:Fd,Mouse:pf,Rabbit:ff,Shrimp:yf,Snail:bf,Squirrel:wf,Turtle:Pf};Object.freeze(Object.keys(mN));function hN(e){if(typeof e.principalId==`string`&&e.principalId.length>0)return{kind:`initials`};let t=e.name.split(` `)[1];return t&&Object.hasOwn(mN,t)?{kind:`animal`,animal:t}:{kind:`initials`}}var gN={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function _N(e){let t=(0,$.c)(28),{user:n,mode:r,tabCount:i}=e,{_:a}=$t(),o=hN(n),s=o.kind===`animal`?mN[o.animal]:void 0,c;t[0]===n.name?c=t[1]:(c=Sr(n.name),t[0]=n.name,t[1]=c);let l=c,u;t[2]===n.color?u=t[3]:(u=oi(n.color),t[2]=n.color,t[3]=u);let d=u,f=n.name,p;t[4]!==a||t[5]!==i||t[6]!==f?(p=i>1?a({id:`qAhFeg`,values:{userName:f,tabCount:i}}):f,t[4]=a,t[5]=i,t[6]=f,t[7]=p):p=t[7];let m=p,h;t[8]!==a||t[9]!==i||t[10]!==f?(h=i>1?a({id:`BEkF-P`,values:{userName:f,tabCount:i}}):f,t[8]=a,t[9]=i,t[10]=f,t[11]=h):h=t[11];let g=h,_;t[12]===n.color?_=t[13]:(_={backgroundColor:n.color},t[12]=n.color,t[13]=_);let v;t[14]!==s||t[15]!==d||t[16]!==l?(v=s?(0,Z.jsx)(s,{size:18,color:d,strokeWidth:1.5}):(0,Z.jsx)(`span`,{className:`font-mono text-2xs font-semibold leading-none`,style:{color:d},children:l}),t[14]=s,t[15]=d,t[16]=l,t[17]=v):v=t[17];let y;t[18]!==g||t[19]!==r||t[20]!==_||t[21]!==v?(y=(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(`div`,{"data-presence-badge":`human`,"data-presence-mode":r,role:`img`,"aria-label":g,className:`inline-flex size-7 shrink-0 cursor-default items-center justify-center rounded-full ring-2 ring-background`,style:_,children:v})}),t[18]=g,t[19]=r,t[20]=_,t[21]=v,t[22]=y):y=t[22];let b;t[23]===m?b=t[24]:(b=(0,Z.jsx)(Ns,{children:m}),t[23]=m,t[24]=b);let x;return t[25]!==y||t[26]!==b?(x=(0,Z.jsxs)(Fs,{children:[y,b]}),t[25]=y,t[26]=b,t[27]=x):x=t[27],x}function vN(e){let t=gN[e.icon];return e.displayName||t||Kc._({id:`iEQQyu`})}function yN(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 bN(e){let t=(0,$.c)(33),{participant:n,crossDoc:r,scoped:i,onClickAgent:a}=e,{_:o}=$t(),{activeDocName:s}=mt(),{presence:c,agentId:l}=n,u=vN(c),d=yN(c.mode),f=!r&&d,p=c.currentDoc&&c.currentDoc!==`(connected)`?c.currentDoc:null,m=s!==null||p!==null,h=m?`cursor-pointer`:`cursor-default opacity-50`,g=i?`ring-primary ring-offset-2 ring-offset-background`:`ring-background`,_=f&&!i?`ring-primary/40 animate-pulse`:``,v;t[0]!==h||t[1]!==g||t[2]!==_?(v=[`inline-flex size-7 shrink-0 items-center justify-center rounded-full ring-2`,h,g,_].filter(Boolean),t[0]=h,t[1]=g,t[2]=_,t[3]=v):v=t[3];let y=v.join(` `),b=r?`true`:void 0,x=i?`true`:void 0,S=m?void 0:`true`,C;t[4]!==c.mode||t[5]!==b||t[6]!==x||t[7]!==S?(C={"data-presence-badge":`agent`,"data-presence-mode":c.mode,"data-presence-crossdoc":b,"data-presence-scoped":x,"data-presence-inert":S},t[4]=c.mode,t[5]=b,t[6]=x,t[7]=S,t[8]=C):C=t[8];let w=C,T=o(r&&p?{id:`b4AQFK`,values:{tooltipName:u,realCurrentDoc:p}}:{id:`RfHNf8`,values:{tooltipName:u}}),E;t[9]!==l||t[10]!==T||t[11]!==w||t[12]!==m||t[13]!==a||t[14]!==c.color||t[15]!==c.icon||t[16]!==p||t[17]!==y||t[18]!==u?(E=m?(0,Z.jsx)(`button`,{type:`button`,...w,"aria-label":T,className:y,style:{backgroundColor:c.color},onClick:()=>a(l,p),children:(0,Z.jsx)(ys,{icon:c.icon,width:16,height:16,className:`text-white`,"aria-hidden":!0})}):(0,Z.jsx)(`div`,{...w,role:`img`,"aria-label":u,className:y,style:{backgroundColor:c.color},children:(0,Z.jsx)(ys,{icon:c.icon,width:16,height:16,className:`text-white`,"aria-hidden":!0})}),t[9]=l,t[10]=T,t[11]=w,t[12]=m,t[13]=a,t[14]=c.color,t[15]=c.icon,t[16]=p,t[17]=y,t[18]=u,t[19]=E):E=t[19];let D=E,O;t[20]===D?O=t[21]:(O=(0,Z.jsx)(Ms,{asChild:!0,children:D}),t[20]=D,t[21]=O);let k;t[22]===u?k=t[23]:(k=(0,Z.jsx)(`span`,{className:`font-medium`,children:u}),t[22]=u,t[23]=k);let A;t[24]!==r||t[25]!==p?(A=r&&p?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:(0,Z.jsx)(J,{id:`Wh0im4`,values:{realCurrentDoc:p}})}):null,t[24]=r,t[25]=p,t[26]=A):A=t[26];let j;t[27]!==k||t[28]!==A?(j=(0,Z.jsxs)(Ns,{className:`flex flex-col gap-0.5`,children:[k,A]}),t[27]=k,t[28]=A,t[29]=j):j=t[29];let M;return t[30]!==O||t[31]!==j?(M=(0,Z.jsxs)(Fs,{children:[O,j]}),t[30]=O,t[31]=j,t[32]=M):M=t[32],M}function xN(e){let t=(0,$.c)(21),{count:n,remainder:r,crossDoc:i,scopedAgentId:a,onClickAgent:o}=e,s;t[0]!==n||t[1]!==i?(s=i?Kc._({id:`9euN0m`,values:{count:n}}):Kc._({id:`uhJEA2`,values:{count:n}}),t[0]=n,t[1]=i,t[2]=s):s=t[2];let c=s,l=i?`true`:void 0,u;t[3]!==n||t[4]!==c||t[5]!==l?(u=(0,Z.jsx)(jt,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`presence-overflow`,"data-presence-crossdoc":l,className:`inline-flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-full bg-muted font-medium text-muted-foreground text-xs ring-2 ring-background hover:bg-muted/80`,"aria-label":c,children:[`+`,n]})}),t[3]=n,t[4]=c,t[5]=l,t[6]=u):u=t[6];let d;if(t[7]!==i||t[8]!==o||t[9]!==r||t[10]!==a){let e;t[12]!==i||t[13]!==o||t[14]!==a?(e=e=>e.kind===`human`?(0,Z.jsx)(_N,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(bN,{participant:e,crossDoc:i,scoped:a===e.agentId,onClickAgent:o},e.agentId),t[12]=i,t[13]=o,t[14]=a,t[15]=e):e=t[15],d=r.map(e),t[7]=i,t[8]=o,t[9]=r,t[10]=a,t[11]=d}else d=t[11];let f;t[16]===d?f=t[17]:(f=(0,Z.jsx)(yt,{align:`end`,className:`w-auto max-w-xs p-2`,children:(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:d})}),t[16]=d,t[17]=f);let p;return t[18]!==u||t[19]!==f?(p=(0,Z.jsxs)($e,{children:[u,f]}),t[18]=u,t[19]=f,t[20]=p):p=t[20],p}function SN(e,t,n,r){return e.kind===`human`?(0,Z.jsx)(_N,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(bN,{participant:e,crossDoc:n,scoped:r===e.agentId,onClickAgent:t},e.agentId)}function CN(){let e=(0,$.c)(20),{activeProvider:t,activeDocName:n,systemProvider:r,openActivityPanel:i,docPanelMode:a,docPanelAgentId:o}=mt(),{current:s,crossDoc:c}=XM(t,r,n);if(dN(Pw(t),n),s.length===0&&c.length===0)return null;let l;if(e[0]!==c||e[1]!==s||e[2]!==o||e[3]!==a||e[4]!==i){let t=s.slice(0,fN),n;e[6]===s?n=e[7]:(n=s.slice(fN),e[6]=s,e[7]=n);let r=n,u=c.slice(0,pN),d;e[8]===c?d=e[9]:(d=c.slice(pN),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=>SN(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)(xN,{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=>SN(e,p,!0,m)),f.length>0?(0,Z.jsx)(xN,{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 wN(){let e=(0,$.c)(4),[t,n]=(0,Q.useState)(null),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.okDesktop;if(!e)return;let t=!1;return e.state.query().then(e=>{t||n(e.channel)}).catch(TN),()=>{t=!0}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Q.useEffect)(r,i);let a;return e[2]===t?a=e[3]:(a={channel:t},e[2]=t,e[3]=a),a}function TN(e){console.warn(`[use-update-channel] bridge.state.query() failed`,e)}function EN(e){let t=(0,$.c)(6),{className:n}=e,{_:r}=$t(),{channel:i}=wN();if(i!==`beta`)return null;let a;t[0]===r?a=t[1]:(a=r({id:`9fhQRL`}),t[0]=r,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(J,{id:`cSCbv3`}),t[2]=o):o=t[2];let s;return t[3]!==n||t[4]!==a?(s=(0,Z.jsx)(qe,{variant:`secondary`,"aria-label":a,"data-testid":`beta-badge`,className:n,children:o}),t[3]=n,t[4]=a,t[5]=s):s=t[5],s}function DN(e,t){return t.trim()}function ON(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function kN(e,t){let n=DN(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function AN(e,t,n=[],r=[],i=[]){if(t.length===0&&n.length===0&&r.length===0&&i.length===0)return e;let a=new Map(t.map(e=>[e.fromDocName,e.toDocName])),o=new Map(i.map(e=>[e.toDocName,e.docExt])),s=new Map(r.map(e=>[e.fromPath,e.toPath]));return e.map(e=>{if(rl(e)){let t=s.get(Vu(e.docName,e.docExt));if(t){let n=il(t);return{kind:`asset`,path:t,assetExt:n,mediaKind:Gn(n),size:e.size,modified:e.modified,referencedBy:[]}}let n=a.get(e.docName)??e.docName;return{...e,docName:n,docExt:o.get(n)??e.docExt}}if(nl(e))return{...e,path:LN(e.path,n)};if(al(e)){let t=s.get(e.path);return t&&Qc(t)?{kind:`document`,docName:Du(t),docExt:el(t),size:e.size,modified:e.modified}:{...e,path:t??LN(e.path,n)}}return e})}function jN(e,t,n,r=[]){if(t.length===0&&!n&&r.length===0)return e;let i=new Set(t),a=new Set(r);return e.filter(e=>rl(e)?!i.has(e.docName)&&!VN(e.docName,n):nl(e)?!VN(e.path,n):al(e)?!a.has(e.path)&&!VN(e.path,n):!0)}function MN(e,t){if(e.kind!==`asset`||t.some(t=>al(t)&&t.path===e.path))return e;let n=Wu(e.path,t);return n?{...e,path:n,name:n.split(`/`).pop()??n}:e}function NN(e,t,n,r=new Date().toISOString()){let i=!1,a=[...e],o=e=>{a.some(t=>RN(t,e))||(a.push(e),i=!0)};if(n.kind===`file`){let s=e.find(e=>rl(e)&&e.docName===t.path);return o({kind:`document`,docName:n.path,docExt:s?.docExt??t.docExt,size:s?.size??0,modified:r}),i?a:e}let s=e.find(e=>nl(e)&&e.path===t.path);o({kind:`folder`,path:n.path,size:s?.size??0,modified:r});let c=new Set(n.duplicatedDocNames);for(let i of e){if(rl(i)){let e=BN(i.docName,t.path,n.path);e&&c.has(e)&&o({...i,docName:e,modified:r});continue}if(nl(i)){let e=zN(i.path,t.path,n.path);e&&o({...i,path:e,modified:r})}}return i?a:e}function PN(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}function FN(e,t,n){return e.flatMap(e=>t===e.toDocName||!n(e.toDocName)?[e.fromDocName]:[e.fromDocName,e.toDocName])}function IN(e,t){let n=e.kind===`file`?Vu(e.path,e.docExt):e.path;return na(t.contentDir,n,t.pathSeparator)}function LN(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 RN(e,t){return rl(e)&&rl(t)?e.docName===t.docName:nl(e)&&nl(t)||al(e)&&al(t)?e.path===t.path:!1}function zN(e,t,n){return e===t?n:BN(e,t,n)}function BN(e,t,n){return e.startsWith(`${t}/`)?`${n}${e.slice(t.length)}`:null}function VN(e,t){return!!t&&(e===t||e.startsWith(`${t}/`))}function HN(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)(Cp,{"data-slot":`context-menu`,...n}),t[2]=n,t[3]=r),r}function UN(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)(wp,{"data-slot":`context-menu-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function WN(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)(Dp,{"data-slot":`context-menu-group`,...n}),t[2]=n,t[3]=r),r}function GN(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)(Np,{"data-slot":`context-menu-sub`,...n}),t[2]=n,t[3]=r),r}function KN(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 motion-reduce:data-open:animate-none motion-reduce:data-closed:animate-none motion-reduce:duration-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Tp,{children:(0,Z.jsx)(Ep,{"data-slot":`context-menu-content`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function qN(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)(kp,{"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 JN(e){let t=(0,$.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,inset:i,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=Y(`flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,r),t[5]=r,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(qi,{className:`ml-auto`}),t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==a||t[11]!==o?(c=(0,Z.jsxs)(Pp,{"data-slot":`context-menu-sub-trigger`,"data-inset":i,className:o,...a,children:[n,s]}),t[8]=n,t[9]=i,t[10]=a,t[11]=o,t[12]=c):c=t[12],c}function YN(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-32 origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg border bg-popover p-1 text-popover-foreground shadow-lg data-[state=closed]:overflow-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 motion-reduce:data-open:animate-none motion-reduce:data-closed:animate-none motion-reduce:duration-0 subtle-scrollbar`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Fp,{"data-slot":`context-menu-sub-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function XN(e){let t=(0,$.c)(15),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:i,children:r,checked:n,inset:a,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===i?s=t[7]:(s=Y(`relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,i),t[6]=i,t[7]=s);let c;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(`span`,{className:`pointer-events-none absolute right-2`,children:(0,Z.jsx)(jp,{children:(0,Z.jsx)(Wi,{})})}),t[8]=c):c=t[8];let l;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==s?(l=(0,Z.jsxs)(Ap,{"data-slot":`context-menu-checkbox-item`,"data-inset":a,className:s,checked:n,...o,children:[c,r]}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=s,t[14]=l):l=t[14],l}function ZN(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,inset:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=Y(`px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,Z.jsx)(Op,{"data-slot":`context-menu-label`,"data-inset":r,className:a,...i}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function QN(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)(Mp,{"data-slot":`context-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var $N=`mr-1.5 flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm text-muted-foreground outline-none transition hover:bg-foreground/10 hover:text-foreground hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/50`,eP=`border-border bg-background text-foreground hover:bg-background focus-visible:bg-background`,tP={start:[Zo.Space],cancel:[Zo.Esc],end:[Zo.Space,Zo.Enter]};function nP(e){return Y($N,e?`opacity-100`:`pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100`)}function rP(e){return e?void 0:-1}function iP({className:e,isDragging:t}){return Y(e,t&&eP)}function aP(e){return e.code===Zo.Enter&&e.target===e.currentTarget}function oP({event:e,hasKeyboardActivation:t,isDragging:n}){return e.defaultPrevented?`ignore`:!n&&t&&aP(e)?`activate-tab`:`delegate-sortable`}function sP({activeWidth:e,isDragging:t,outerStyle:n,transform:r,transition:i}){let a=t&&e?e:void 0;return{...n,transform:ns.Transform.toString(r?{...r,scaleX:1,scaleY:1}:null),transition:i,flexBasis:a??n?.flexBasis,maxWidth:a??n?.maxWidth,minWidth:a??n?.minWidth,opacity:n?.opacity,width:a??n?.width,zIndex:t?20:n?.zIndex}}function cP(e){let t=e?.querySelectorAll(`[data-editor-tab-sortable]`)??[],n=1/0,r=-1/0;for(let e of t){let t=e.getBoundingClientRect();n=Math.min(n,t.left),r=Math.max(r,t.right)}return Number.isFinite(n)&&Number.isFinite(r)?{left:n,right:r}:null}function lP(e){return({activeNodeRect:t,transform:n})=>{let r={...n,y:0};if(!e||!t)return r;let i=e.left-t.left,a=e.right-t.right;return r.x=Math.min(Math.max(r.x,i),a),r}}var uP=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(r){let e=1/0,i=-1/0,a=null,o=null;for(let r of t){let t=n.get(r.id);t&&(t.left<e&&(e=t.left,a=r),t.right>i&&(i=t.right,o=r))}if(!Number.isFinite(e)||!Number.isFinite(i))return[];let s=r.x<e?a:r.x>i?o:null;if(s)return[{id:s.id,data:{droppableContainer:s,value:0}}]}return Go(e)},dP=[`.md`,`.mdx`],fP=`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`,pP=`z-10 rounded-t-lg rounded-b-none border-border border-b-0 bg-background text-foreground`,mP=Y(pP,`bg-transparent hover:bg-muted focus-visible:bg-muted border-transparent hover:border-border focus-visible:border-border`),hP=`flex h-full min-w-0 flex-1 cursor-pointer items-center overflow-hidden px-3 text-left text-[13px]`;function gP(e){return e.replace(/[^A-Za-z0-9_-]/g,`-`)}function _P(e){let t=yl(e);window.location.hash!==t&&(window.location.hash=t)}function vP(e){Math.abs(e.deltaX)>=Math.abs(e.deltaY)||e.currentTarget.scrollWidth<=e.currentTarget.clientWidth||(e.preventDefault(),e.currentTarget.scrollLeft+=e.deltaY)}function yP(e,t){let n=[t,...dP].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 bP(e){return e.metaKey||e.ctrlKey}var xP=1e3;function SP(e,t){return e<0||e>=t?null:e<8?String(e+1):e===t-1?`9`:null}function CP(e,t){return SP(e,t)}function wP(e,t){let n=SP(e,t);if(n)return[`Meta+${n}`,`Control+${n}`].join(` `)}function TP(e,t){if(!bP(e)||e.altKey||e.shiftKey||!/^[1-9]$/.test(e.key))return null;let n=Number(e.key);if(n===9)return t>0?t-1:null;let r=n-1;return r<Math.min(8,t)?r:null}function EP(e){let t=(0,$.c)(3),{value:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=Y(nP(!0),`font-mono tabular-nums hover:bg-transparent animate-in fade-in-0 zoom-in-95 duration-150 motion-reduce:animate-none motion-reduce:duration-0`),t[0]=r):r=t[0];let i=`⌘${n}`,a;return t[1]===i?a=t[2]:(a=(0,Z.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`editor-tab-shortcut-hint`,className:r,children:(0,Z.jsx)(P,{className:`text-[10px]`,children:i})}),t[1]=i,t[2]=a),a}function DP(e){let t=(0,$.c)(37),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({activateFromKeyboard:n,className:r,tabId:l,disabled:i,onKeyDown:a,ref:o,style:s,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u;t[9]!==i||t[10]!==l?(u={id:l,disabled:i},t[9]=i,t[10]=l,t[11]=u):u=t[11];let{attributes:d,listeners:f,rect:p,setNodeRef:m,transform:h,transition:g,isDragging:_}=es(u),v=p.current?.width,y;t[12]!==_||t[13]!==s||t[14]!==v||t[15]!==h||t[16]!==g?(y=sP({activeWidth:v,isDragging:_,outerStyle:s,transform:h,transition:g}),t[12]=_,t[13]=s,t[14]=v,t[15]=h,t[16]=g,t[17]=y):y=t[17];let b=y,x;t[18]!==o||t[19]!==m?(x=function(e){m(e),typeof o==`function`?o(e):o&&`current`in o&&(o.current=e)},t[18]=o,t[19]=m,t[20]=x):x=t[20];let S=x,C=f?.onKeyDown,w;t[21]!==n||t[22]!==_||t[23]!==a||t[24]!==C?(w=function(e){a?.(e);let t=oP({event:e,hasKeyboardActivation:!!n,isDragging:_});if(t!==`ignore`){if(t===`activate-tab`&&n){e.preventDefault(),n();return}C?.(e)}},t[21]=n,t[22]=_,t[23]=a,t[24]=C,t[25]=w):w=t[25];let T=w,E;t[26]!==r||t[27]!==_?(E=iP({className:r,isDragging:_}),t[26]=r,t[27]=_,t[28]=E):E=t[28];let D;return t[29]!==d||t[30]!==S||t[31]!==T||t[32]!==f||t[33]!==c||t[34]!==b||t[35]!==E?(D=(0,Z.jsx)(`div`,{ref:S,"data-editor-tab-sortable":``,className:E,style:b,...c,...d,...f,onKeyDown:T}),t[29]=d,t[30]=S,t[31]=T,t[32]=f,t[33]=c,t[34]=b,t[35]=E,t[36]=D):D=t[36],D}function OP(e){let t=(0,$.c)(52),{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=Ht(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?(_=Ht(s,l),t[10]=s,t[11]=l,t[12]=_):_=t[12];let v=_,y;t[13]===n?y=t[14]:(y=(0,Z.jsx)(UN,{asChild:!0,children:n}),t[13]=n,t[14]=y);let b;t[15]!==r||t[16]!==u?(b=()=>r(u),t[15]=r,t[16]=u,t[17]=b):b=t[17];let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(J,{id:`yz7wBu`}),t[18]=x):x=t[18];let S;t[19]!==m||t[20]!==b?(S=(0,Z.jsx)(qN,{disabled:m,onSelect:b,children:x}),t[19]=m,t[20]=b,t[21]=S):S=t[21];let C=g.length===0,w;t[22]!==i||t[23]!==g?(w=()=>{i(g)},t[22]=i,t[23]=g,t[24]=w):w=t[24];let T;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(J,{id:`omXJcU`}),t[25]=T):T=t[25];let E;t[26]!==C||t[27]!==w?(E=(0,Z.jsx)(qN,{disabled:C,onSelect:w,children:T}),t[26]=C,t[27]=w,t[28]=E):E=t[28];let D=v.length===0,O;t[29]!==v||t[30]!==i?(O=()=>{i(v)},t[29]=v,t[30]=i,t[31]=O):O=t[31];let k;t[32]===l.length?k=t[33]:(k=l.length?(0,Z.jsx)(J,{id:`U2Kx6T`}):(0,Z.jsx)(J,{id:`WyXG7w`}),t[32]=l.length,t[33]=k);let A;t[34]!==D||t[35]!==O||t[36]!==k?(A=(0,Z.jsx)(qN,{disabled:D,"data-testid":`editor-tab-context-close-all`,onSelect:O,children:k}),t[34]=D,t[35]=O,t[36]=k,t[37]=A):A=t[37];let j;t[38]!==f||t[39]!==m||t[40]!==c||t[41]!==u||t[42]!==d?(j=f&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(QN,{}),(0,Z.jsx)(qN,{"data-testid":`editor-tab-context-pin-toggle`,onSelect:()=>m?d(u):c(u),children:m?(0,Z.jsx)(J,{id:`SYfHmN`}):(0,Z.jsx)(J,{id:`3pU8e-`})})]}),t[38]=f,t[39]=m,t[40]=c,t[41]=u,t[42]=d,t[43]=j):j=t[43];let M;t[44]!==E||t[45]!==A||t[46]!==j||t[47]!==S?(M=(0,Z.jsxs)(KN,{className:`min-w-40`,children:[S,E,A,j]}),t[44]=E,t[45]=A,t[46]=j,t[47]=S,t[48]=M):M=t[48];let N;return t[49]!==M||t[50]!==y?(N=(0,Z.jsxs)(HN,{children:[y,M]}),t[49]=M,t[50]=y,t[51]=N):N=t[51],N}function kP(e){let t=(0,$.c)(28),{accessibleLabel:n,closeTab:r,forceCloseVisible:i,isActive:a,isPinned:o,shortcutHint:s,tabId:c,unpinTab:l}=e,u=i===void 0?!1:i,d=s===void 0?null:s,{_:f}=$t();if(d){let e;return t[0]===d?e=t[1]:(e=(0,Z.jsx)(EP,{value:d}),t[0]=d,t[1]=e),e}if(o){let e;t[2]!==f||t[3]!==n?(e=f({id:`t18QYR`,values:{accessibleLabel:n}}),t[2]=f,t[3]=n,t[4]=e):e=t[4];let r;t[5]!==c||t[6]!==l?(r=e=>{e.stopPropagation(),l(c)},t[5]=c,t[6]=l,t[7]=r):r=t[7];let i;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(df,{"aria-hidden":`true`}),t[8]=i):i=t[8];let a;return t[9]!==e||t[10]!==r?(a=(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":e,"data-testid":`editor-tab-unpin-button`,className:`mr-1.5 text-primary! hover:bg-primary/10!`,onClick:r,children:i}),t[9]=e,t[10]=r,t[11]=a):a=t[11],a}let p;t[12]!==f||t[13]!==n?(p=f({id:`JLzQi_`,values:{accessibleLabel:n}}),t[12]=f,t[13]=n,t[14]=p):p=t[14];let m=u||a,h;t[15]===m?h=t[16]:(h=nP(m),t[15]=m,t[16]=h);let g;t[17]===a?g=t[18]:(g=rP(a),t[17]=a,t[18]=g);let _;t[19]!==r||t[20]!==c?(_=e=>{e.stopPropagation(),r(c)},t[19]=r,t[20]=c,t[21]=_):_=t[21];let v;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(Cs,{"aria-hidden":`true`}),t[22]=v):v=t[22];let y;return t[23]!==p||t[24]!==h||t[25]!==g||t[26]!==_?(y=(0,Z.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":p,"data-testid":`editor-tab-close-button`,className:h,tabIndex:g,onClick:_,children:v}),t[23]=p,t[24]=h,t[25]=g,t[26]=_,t[27]=y):y=t[27],y}function AP(e){let t=(0,$.c)(1),{hasConflict:n}=e;if(!n)return null;let r;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(Yi,{"aria-hidden":`true`,"data-testid":`editor-tab-conflict-badge`,className:`mr-1 size-3.5 shrink-0 text-amber-500`}),t[0]=r):r=t[0],r}function jP(e){let t=(0,$.c)(27),{accessibleLabel:n,activateTab:r,baseName:i,docName:a,enterRenameMode:o,extension:s,hideDocExtension:c,tabId:l}=e,{_:u}=$t(),d=cw(a)===`conflict`,f;t[0]!==u||t[1]!==n||t[2]!==d?(f=d?u({id:`mVFyH-`,values:{accessibleLabel:n}}):n,t[0]=u,t[1]=n,t[2]=d,t[3]=f):f=t[3];let p=f,m;t[4]!==r||t[5]!==l?(m=()=>{r(l)},t[4]=r,t[5]=l,t[6]=m):m=t[6];let h;t[7]!==a||t[8]!==o||t[9]!==l?(h=e=>{e.preventDefault(),e.stopPropagation(),o(l,a)},t[7]=a,t[8]=o,t[9]=l,t[10]=h):h=t[10];let g;t[11]===d?g=t[12]:(g=(0,Z.jsx)(AP,{hasConflict:d}),t[11]=d,t[12]=g);let _;t[13]===i?_=t[14]:(_=(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:i}),t[13]=i,t[14]=_);let v;t[15]!==s||t[16]!==c?(v=!c&&(0,Z.jsx)(`span`,{className:`shrink-0`,children:s}),t[15]=s,t[16]=c,t[17]=v):v=t[17];let y;t[18]!==_||t[19]!==v?(y=(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center`,children:[_,v]}),t[18]=_,t[19]=v,t[20]=y):y=t[20];let b;return t[21]!==p||t[22]!==m||t[23]!==h||t[24]!==g||t[25]!==y?(b=(0,Z.jsxs)(`button`,{type:`button`,"aria-label":p,title:p,className:hP,onClick:m,onDoubleClick:h,tabIndex:-1,children:[g,y]}),t[21]=p,t[22]=m,t[23]=h,t[24]=g,t[25]=y,t[26]=b):b=t[26],b}function MP(){let e=(0,$.c)(94),{activeDocName:t,activeTabId:n,activeNewTabId:r,activeTarget:i,activateTab:a,activateNewTab:o,closeAndClearForRename:s,closeNewTab:c,closeTab:l,closeTabs:u,getPoolActiveDocName:d,poolHas:f,isNewTabActive:p,newTabIds:m,openNewTab:g,openTabs:_,pinTab:y,pinnedTabIds:b,reopenClosedTab:x,remapTabsForRename:S,reorderTabs:C,unpinTab:w,visibleTabIds:T}=mt(),{_:E}=$t(),{pageMeta:D}=Xi(),O=(0,Q.useRef)(null),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(null),[N,P]=(0,Q.useState)(``),[F,I]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(!1),[z,B]=(0,Q.useState)(!1),V=(0,Q.useRef)(null),H=(0,Q.useRef)(!1),U=(0,Q.useRef)(!1),W=(0,Q.useRef)(null),G=(0,Q.useRef)(t),K=(0,Q.useRef)(null),ee=(0,Q.useRef)(!1),te=(0,Q.useRef)(!1),ne;e[0]!==n||e[1]!==t||e[2]!==i?(ne=n??(i?se(i):t?Ee(t):null),e[0]=n,e[1]=t,e[2]=i,e[3]=ne):ne=e[3];let re=ne,ie;e[4]!==r||e[5]!==re||e[6]!==p||e[7]!==m||e[8]!==_?(ie=p?`${r??`__new-tab__`}\u0000${_.join(`\0`)}\u0000${m.join(`\0`)}`:re?`${re}\u0000${_.join(`\0`)}`:``,e[4]=r,e[5]=re,e[6]=p,e[7]=m,e[8]=_,e[9]=ie):ie=e[9];let ae=ie,oe,ce;e[10]===t?(oe=e[11],ce=e[12]):(oe=()=>{G.current=t},ce=[t],e[10]=t,e[11]=oe,e[12]=ce),(0,Q.useEffect)(oe,ce);let le,q;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>()=>{K.current!==null&&(window.clearTimeout(K.current),K.current=null)},q=[],e[13]=le,e[14]=q):(le=e[13],q=e[14]),(0,Q.useEffect)(le,q);let ue,de;e[15]===ae?(ue=e[16],de=e[17]):(ue=()=>{ae&&(O.current?.querySelector(`[data-active-tab="true"]`))?.scrollIntoView({block:`nearest`,inline:`nearest`})},de=[ae],e[15]=ae,e[16]=ue,e[17]=de),(0,Q.useEffect)(ue,de);let fe,pe;e[18]===j?(fe=e[19],pe=e[20]):(fe=()=>{j&&(V.current?.focus(),V.current?.select())},pe=[j],e[18]=j,e[19]=fe,e[20]=pe),(0,Q.useEffect)(fe,pe);let me,he;e[21]!==_||e[22]!==j?(me=()=>{!j||_.includes(j.tabId)||(U.current=!0,W.current=null,M(null),P(``),I(null),R(!1))},he=[_,j],e[21]=_,e[22]=j,e[23]=me,e[24]=he):(me=e[23],he=e[24]),(0,Q.useEffect)(me,he);let ge;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(ge=function(e,t){let n=t.split(`/`);U.current=!1,W.current=null,M({docName:t,tabId:e}),P(n[n.length-1]),I(null)},e[25]=ge):ge=e[25];let _e=ge,ve=function(){U.current=!0,W.current=null,M(null),P(``),I(null),R(!1)},ye=async function(){if(U.current){U.current=!1;return}if(H.current)return;let e=j?.docName;if(!e){ve();return}let t=DN(`file`,yP(N,D.get(e)?.docExt??`.md`)),n=e.split(`/`),r=n[n.length-1];if(t===r){ve();return}if(t===W.current){V.current?.focus();return}if(!ON(t)){I(E({id:`P8yDjG`})),V.current?.focus();return}let i=kN({kind:`file`,path:e,name:r},t);H.current=!0,R(!0),I(null);try{let n=await fetch(`/api/rename-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:`file`,fromPath:e,toPath:i})});if(U.current){R(!1),H.current=!1;return}let r=await ht(n,`Server error (HTTP ${n.status})`);if(!r.ok){I(r.title),R(!1),H.current=!1,W.current=t,V.current?.focus();return}let a=Ot(Dr,r.body,`rename-path:tab`,{renamed:[],renamedAssets:[]}).renamed,o=G.current,c=PN(o,a);v(a);let l=!0;try{let e=FN(a,d(),f);await Promise.all(e.map(e=>s(e))),S(a),qc([`files`,`backlinks`,`graph`])}catch(n){let r=n;l=!1,console.warn(`[EditorTabs] post-rename reconciliation failed`,{err:r,docName:e,newDocName:i,normalized:t}),Ss.error(E({id:`MUBR8r`}))}U.current=!0,M(null),P(``),I(null),R(!1),H.current=!1,W.current=null,l&&c&&c!==o&&_P(c)}catch(n){console.warn(`[EditorTabs] rename failed`,{err:n,docName:e,newDocName:i,normalized:t}),I(E({id:`HIb0vl`})),R(!1),H.current=!1,W.current=t,V.current?.focus()}},be=typeof window<`u`&&window.okDesktop!=null,xe;e[26]===m?xe=e[27]:(xe=new Set(m),e[26]=m,e[27]=xe);let Se=xe,Ce;e[28]===k?Ce=e[29]:(Ce=lP(k),e[28]=k,e[29]=Ce);let we;e[30]===Ce?we=e[31]:(we=[Ce],e[30]=Ce,e[31]=we);let Te=we,De;e[32]!==c||e[33]!==u||e[34]!==Se?(De=function(e){let t=[],n=[];for(let r of e)Se.has(r)?n.push(r):t.push(r);t.length>0&&u(t);for(let e of n)c(e)},e[32]=c,e[33]=u,e[34]=Se,e[35]=De):De=e[35];let Oe=De,ke,Ae;e[36]!==o||e[37]!==a||e[38]!==r||e[39]!==re||e[40]!==p||e[41]!==m||e[42]!==g||e[43]!==x||e[44]!==T?(ke=()=>{let e=new Set(m),t=function(){K.current!==null&&(window.clearTimeout(K.current),K.current=null)},n=function(e){ee.current!==e&&(ee.current=e)},i=function(e){te.current!==e&&(te.current=e,B(e))},s=function(){n(!0),!(te.current||K.current!==null)&&(K.current=window.setTimeout(()=>{K.current=null,ee.current&&i(!0)},xP))},c=function(){t(),n(!1),i(!1)},l=function(t){e.has(t)?o(t):a(t)},u=function(e){if(T.length===0)return;let t=p?r:re,n=t?T.indexOf(t):-1;l(T[((n>=0?n:0)+e+T.length)%T.length])},d=function(e){if(bP(e)&&s(),Al(e,`tab-new`)){e.preventDefault(),g();return}if(Al(e,`tab-reopen-closed`)){e.preventDefault(),x();return}if(Al(e,`tab-next`)){e.preventDefault(),u(1);return}if(Al(e,`tab-previous`)){e.preventDefault(),u(-1);return}let t=TP(e,T.length);t!==null&&(e.preventDefault(),l(T[t]))},f=function(e){!e.metaKey&&!e.ctrlKey&&c()};return window.addEventListener(`keydown`,d,{capture:!0}),window.addEventListener(`keyup`,f,{capture:!0}),window.addEventListener(`blur`,c),document.addEventListener(`visibilitychange`,c),()=>{window.removeEventListener(`keydown`,d,{capture:!0}),window.removeEventListener(`keyup`,f,{capture:!0}),window.removeEventListener(`blur`,c),document.removeEventListener(`visibilitychange`,c)}},Ae=[r,re,o,a,p,m,g,x,T],e[36]=o,e[37]=a,e[38]=r,e[39]=re,e[40]=p,e[41]=m,e[42]=g,e[43]=x,e[44]=T,e[45]=ke,e[46]=Ae):(ke=e[45],Ae=e[46]),(0,Q.useEffect)(ke,Ae);let Me;e[47]===Symbol.for(`react.memo_cache_sentinel`)?(Me={activationConstraint:{distance:8}},e[47]=Me):Me=e[47];let Ne;e[48]===Symbol.for(`react.memo_cache_sentinel`)?(Ne={coordinateGetter:Jo,keyboardCodes:tP},e[48]=Ne):Ne=e[48];let Pe=ts(Ho(Ko,Me),Ho(Yo,Ne)),Fe=z,Ie;e[49]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=function(){A(cP(O.current))},e[49]=Ie):Ie=e[49];let Le=Ie,Re;e[50]===Symbol.for(`react.memo_cache_sentinel`)?(Re=function(){A(null)},e[50]=Re):Re=e[50];let ze=Re,Be;e[51]!==ze||e[52]!==C||e[53]!==T?(Be=function(e){ze();let t=String(e.active.id),n=e.over?String(e.over.id):null;if(!n||t===n)return;let r=T.indexOf(t),i=T.indexOf(n);r<0||i<0||r===i||C(Qo([...T],r,i),t)},e[51]=ze,e[52]=C,e[53]=T,e[54]=Be):Be=e[54];let Ve=Be,He=be?``:void 0,Ue;e[55]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=Y(`pl-2 flex h-12 min-w-0 touch-manipulation flex-1 items-end overflow-x-auto overflow-y-hidden overscroll-x-contain scroll-fade-mask-x [scrollbar-width:none]`,be&&`[-webkit-app-region:drag]`),e[55]=Ue):Ue=e[55];let We=vP,Ge;e[56]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=Y(`flex items-end gap-1`,be&&`[-webkit-app-region:no-drag]`),e[56]=Ge):Ge=e[56];let Ke=Wo,qe=uP,Je;e[57]===Symbol.for(`react.memo_cache_sentinel`)?(Je={container:typeof document<`u`?document.body:void 0},e[57]=Je):Je=e[57];let Ye=Xo,Xe;e[58]===T?Xe=e[59]:(Xe=[...T],e[58]=T,e[59]=Xe);let Ze=Uo,Qe=T.map((e,t)=>{let n=z?CP(t,T.length):null,i=wP(t,T.length);if(Se.has(e)){let t=e===r;return(0,Z.jsx)(OP,{tabId:e,canPin:!1,openTabs:T,closeTab:c,closeTabs:Oe,pinTab:y,pinnedTabIds:b,unpinTab:w,children:(0,Z.jsxs)(DP,{tabId:e,activateFromKeyboard:()=>o(e),"aria-current":t?`page`:void 0,"aria-keyshortcuts":i,"data-active-tab":t?`true`:void 0,className:Y(fP,t?pP:mP),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":E({id:`zLak8b`}),"data-testid":`editor-new-tab-placeholder-button`,className:hP,onClick:()=>o(e),tabIndex:-1,children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:(0,Z.jsx)(J,{id:`3YvS-c`})})}),n?(0,Z.jsx)(EP,{value:n}):(0,Z.jsx)(`button`,{type:`button`,"aria-label":E({id:`xCdTnb`}),"data-testid":`editor-new-tab-placeholder-close`,className:nP(Fe||t),tabIndex:rP(t),onClick:t=>{t.stopPropagation(),c(e)},children:(0,Z.jsx)(Cs,{"aria-hidden":`true`,className:`size-3.5`})})]})},e)}let s=je(e),u=e===re,d=b.includes(e);if(s.kind===`folder`){let{baseName:t,label:r,prefix:o}=h(s.folderPath,`/`),c=`${o}${r}`;return(0,Z.jsx)(OP,{tabId:e,openTabs:T,closeTab:l,closeTabs:Oe,pinTab:y,pinnedTabIds:b,unpinTab:w,children:(0,Z.jsxs)(DP,{tabId:e,activateFromKeyboard:()=>a(e),"aria-current":u?`page`:void 0,"aria-keyshortcuts":i,"data-active-tab":u?`true`:void 0,className:Y(fP,u?pP:mP),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":c,title:c,className:hP,onClick:()=>{a(e)},tabIndex:-1,children:[o&&(0,Z.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate`,u&&`text-muted-foreground`),children:o}),(0,Z.jsxs)(`span`,{className:Y(`flex min-w-0 items-center`,o?`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)(kP,{accessibleLabel:c,closeTab:l,forceCloseVisible:Fe,isActive:u,isPinned:d,shortcutHint:n,tabId:e,unpinTab:w})]})},e)}if(s.kind===`asset`||s.kind===`skill-file`){let{baseName:t,label:r,prefix:o}=h(s.kind===`asset`?s.assetPath:s.path,``),c=`${o}${r}`;return(0,Z.jsx)(OP,{tabId:e,openTabs:T,closeTab:l,closeTabs:Oe,pinTab:y,pinnedTabIds:b,unpinTab:w,children:(0,Z.jsxs)(DP,{tabId:e,activateFromKeyboard:()=>a(e),"aria-current":u?`page`:void 0,"aria-keyshortcuts":i,"data-active-tab":u?`true`:void 0,className:Y(fP,u?pP:mP),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":c,className:hP,onClick:()=>{a(e)},tabIndex:-1,children:[o?(0,Z.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate text-muted-foreground/60`,u&&`text-muted-foreground`),children:o}):null,(0,Z.jsx)(`span`,{className:Y(`min-w-0 truncate`,o?`max-w-[70%] shrink-0`:`flex-1`),children:t})]}),(0,Z.jsx)(kP,{accessibleLabel:c,closeTab:l,forceCloseVisible:Fe,isActive:u,isPinned:d,shortcutHint:n,tabId:e,unpinTab:w})]})},e)}let f=s.docName,p=D.get(f)?.docExt??`.md`,{baseName:m,extension:g,label:_,prefix:v}=h(f,p),x=`${v}${_}`,S=p===`.md`||p===`.mdx`,C=j?.tabId===e,O=`editor-tab-rename-error-${gP(f)}`;return(0,Z.jsx)(OP,{disabled:C,tabId:e,openTabs:T,closeTab:l,closeTabs:Oe,pinTab:y,pinnedTabIds:b,unpinTab:w,children:(0,Z.jsx)(DP,{tabId:e,activateFromKeyboard:()=>a(e),disabled:C,"aria-current":u?`page`:void 0,"aria-keyshortcuts":i,"data-active-tab":u?`true`:void 0,className:Y(fP,u?pP:mP,C&&F&&`border-destructive`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!d&&l(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:C?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(zC,{className:`h-full min-w-0 flex-1 rounded-none border-0 bg-transparent dark:bg-transparent`,children:[(0,Z.jsx)(WC,{ref:V,value:N,disabled:L,"aria-label":E({id:`Dw1T_W`,values:{label:_}}),"data-testid":`editor-tab-rename-input`,"aria-invalid":F?!0:void 0,"aria-describedby":F?O:void 0,"aria-busy":L||void 0,title:F??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=>{P(yP(e.target.value,p)),I(null),W.current=null},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),ye()):e.key===`Escape`&&(e.preventDefault(),ve())},onBlur:ye}),(0,Z.jsx)(VC,{align:`inline-end`,"aria-hidden":`true`,className:`pr-2 text-xs`,children:(0,Z.jsx)(UC,{className:`text-muted-foreground/60 text-xs`,children:p})})]}),F?(0,Z.jsx)(`span`,{id:O,role:`alert`,className:`sr-only`,children:F}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(jP,{accessibleLabel:x,activateTab:a,baseName:m,docName:f,enterRenameMode:_e,extension:g,hideDocExtension:S,tabId:e}),(0,Z.jsx)(kP,{accessibleLabel:x,closeTab:l,forceCloseVisible:Fe,isActive:u,isPinned:d,shortcutHint:n,tabId:e,unpinTab:w})]})})},e)}),$e;e[60]!==Ye||e[61]!==Xe||e[62]!==Ze||e[63]!==Qe?($e=(0,Z.jsx)(Ye,{items:Xe,strategy:Ze,children:Qe}),e[60]=Ye,e[61]=Xe,e[62]=Ze,e[63]=Qe,e[64]=$e):$e=e[64];let et;e[65]!==Ke||e[66]!==ze||e[67]!==Ve||e[68]!==Le||e[69]!==Pe||e[70]!==!1||e[71]!==qe||e[72]!==Je||e[73]!==$e||e[74]!==Te?(et=(0,Z.jsx)(Ke,{sensors:Pe,autoScroll:!1,collisionDetection:qe,modifiers:Te,onDragStart:Le,onDragEnd:Ve,onDragCancel:ze,accessibility:Je,children:$e}),e[65]=Ke,e[66]=ze,e[67]=Ve,e[68]=Le,e[69]=Pe,e[70]=!1,e[71]=qe,e[72]=Je,e[73]=$e,e[74]=Te,e[75]=et):et=e[75];let tt;e[76]===E?tt=e[77]:(tt=E({id:`3YvS-c`}),e[76]=E,e[77]=tt);let nt;e[78]===Symbol.for(`react.memo_cache_sentinel`)?(nt=(0,Z.jsx)(Zt,{"aria-hidden":`true`}),e[78]=nt):nt=e[78];let rt;e[79]!==g||e[80]!==tt?(rt=(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(X,{type:`button`,size:`icon-xs`,variant:`ghost`,"aria-label":tt,"data-testid":`editor-new-tab-button`,className:`first:mb-3 mb-1.5`,onClick:g,children:nt})}),e[79]=g,e[80]=tt,e[81]=rt):rt=e[81];let it;e[82]===Symbol.for(`react.memo_cache_sentinel`)?(it=(0,Z.jsx)(Ns,{children:(0,Z.jsx)(J,{id:`3YvS-c`})}),e[82]=it):it=e[82];let at;e[83]===rt?at=e[84]:(at=(0,Z.jsxs)(Fs,{children:[rt,it]}),e[83]=rt,e[84]=at);let ot;e[85]!==Ge||e[86]!==et||e[87]!==at?(ot=(0,Z.jsxs)(`div`,{className:Ge,children:[et,at]}),e[85]=Ge,e[86]=et,e[87]=at,e[88]=ot):ot=e[88];let st;return e[89]!==He||e[90]!==Ue||e[91]!==We||e[92]!==ot?(st=(0,Z.jsx)(`div`,{ref:O,"data-electron-drag":He,className:Ue,onWheel:We,children:ot}),e[89]=He,e[90]=Ue,e[91]=We,e[92]=ot,e[93]=st):st=e[93],st}var NP=(e,t,n)=>{if(e&&`reportValidity`in e){let r=io(n,t);e.setCustomValidity(r&&r.message||``),e.reportValidity()}},PP=(e,t)=>{for(let n in t.fields){let r=t.fields[n];r&&r.ref&&`reportValidity`in r.ref?NP(r.ref,n,e):r&&r.refs&&r.refs.forEach(t=>NP(t,n,e))}},FP=(e,t)=>{t.shouldUseNativeValidation&&PP(e,t);let n={};for(let r in e){let i=io(t.fields,r),a=Object.assign(e[r]||{},{ref:i&&i.ref});if(IP(t.names||Object.keys(e),r)){let e=Object.assign({},io(n,r));Da(e,`root`,a),Da(n,r,e)}else Da(n,r,a)}return n},IP=(e,t)=>{let n=LP(t).replace(/[.*+?^${}()|\\]/g,`\\$&`);return e.some(e=>LP(e).match(`^${n}\\.\\d+`))};function LP(e){return e.replace(/[\[\]]/g,``)}function RP(){return RP=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},RP.apply(null,arguments)}function zP(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}function BP(e,t){for(var n={};e.length;){var r=e[0],i=r.code,a=r.message,o=r.path.join(`.`);if(!n[o])if(`unionErrors`in r){var s=r.unionErrors[0].errors[0];n[o]={message:s.message,type:s.code}}else n[o]={message:a,type:i};if(`unionErrors`in r&&r.unionErrors.forEach(function(t){return t.errors.forEach(function(t){return e.push(t)})}),t){var c=n[o].types,l=c&&c[r.code];n[o]=La(o,t,n,i,l?[].concat(l,r.message):r.message)}e.shift()}return n}function VP(e,t){for(var n={},r=function(){var r=e[0],i=r.code,a=r.message,o=r.path.join(`.`);if(!n[o])if(r.code===`invalid_union`&&r.errors.length>0){var s=r.errors[0][0];n[o]={message:s.message,type:s.code}}else n[o]={message:a,type:i};if(r.code===`invalid_union`&&r.errors.forEach(function(t){return t.forEach(function(t){return e.push(RP({},t,{path:[].concat(r.path,t.path)}))})}),t){var c=n[o].types,l=c&&c[r.code];n[o]=La(o,t,n,i,l?[].concat(l,r.message):r.message)}e.shift()};e.length;)r();return n}function HP(e,t,n){if(n===void 0&&(n={}),function(e){return`_def`in e&&typeof e._def==`object`&&`typeName`in e._def}(e))return function(r,i,a){try{return Promise.resolve(zP(function(){return Promise.resolve(e[n.mode===`sync`?`parse`:`parseAsync`](r,t)).then(function(e){return a.shouldUseNativeValidation&&PP({},a),{errors:{},values:n.raw?Object.assign({},r):e}})},function(e){if(function(e){return Array.isArray(e?.issues)}(e))return{values:{},errors:FP(BP(e.errors,!a.shouldUseNativeValidation&&a.criteriaMode===`all`),a)};throw e}))}catch(e){return Promise.reject(e)}};if(function(e){return`_zod`in e&&typeof e._zod==`object`}(e))return function(r,i,a){try{return Promise.resolve(zP(function(){return Promise.resolve((n.mode===`sync`?Yn:ur)(e,r,t)).then(function(e){return a.shouldUseNativeValidation&&PP({},a),{errors:{},values:n.raw?Object.assign({},r):e}})},function(e){if(function(e){return e instanceof mr}(e))return{values:{},errors:FP(VP(e.issues,!a.shouldUseNativeValidation&&a.criteriaMode===`all`),a)};throw e}))}catch(e){return Promise.reject(e)}};throw Error(`Invalid input: not a Zod schema`)}var UP=`https://openknowledge.ai/api/subscribe`;async function WP(e,t){try{let n=await fetch(UP,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({email:e,source:t}),signal:AbortSignal.timeout(15e3)});return n.ok?{ok:!0}:n.status===400?{ok:!1,reason:`invalid`}:n.status===503?{ok:!1,reason:`unavailable`}:(console.warn(`[subscribe] action=submit result=http-error status=${n.status}`),{ok:!1,reason:`error`})}catch(e){return console.warn(`[subscribe] action=submit result=network-error message=${e instanceof Error?e.message:String(e)}`),{ok:!1,reason:`error`}}}function GP(e){let t=(0,$.c)(49),{source:n,title:r,description:i,onSuccess:a,onDismiss:o,autoFocus:s,compactSubmit:c,className:l}=e,{_:u}=$t(),[d,f]=(0,Q.useState)(!1),p=(0,Q.useRef)(null),m,h;t[0]===d?(m=t[1],h=t[2]):(m=()=>{d&&p.current?.focus()},h=[d],t[0]=d,t[1]=m,t[2]=h),(0,Q.useEffect)(m,h);let g,_;if(t[3]!==u){let e=In({email:ir({message:u({id:`Wq6Wcm`})})});_=ro,g=HP(e),t[3]=u,t[4]=g,t[5]=_}else g=t[4],_=t[5];let v;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(v={email:``},t[6]=v):v=t[6];let y;t[7]===g?y=t[8]:(y={resolver:g,defaultValues:v},t[7]=g,t[8]=y);let b=_(y),{isSubmitting:x}=b.formState,S=b.formState.errors.email?.message??b.formState.errors.root?.message,C;t[9]!==u||t[10]!==b||t[11]!==a||t[12]!==n?(C=async function(e){b.clearErrors(`root`);let t=await WP(e.email,n);if(t.ok){f(!0),a?.();return}if(t.reason===`invalid`){b.setError(`email`,{message:u({id:`Wq6Wcm`})});return}if(t.reason===`unavailable`){b.setError(`root`,{message:u({id:`4mLBx9`})});return}b.setError(`root`,{message:u({id:`fWsBTs`})})},t[9]=u,t[10]=b,t[11]=a,t[12]=n,t[13]=C):C=t[13];let w=C,T;t[14]===l?T=t[15]:(T=Y(`flex flex-col gap-3`,l),t[14]=l,t[15]=T);let E=d?-1:void 0,D;t[16]!==d||t[17]!==r?(D=d?(0,Z.jsxs)(`span`,{className:`mb-1.5 inline-flex flex-row items-center gap-2`,children:[(0,Z.jsx)(Wi,{className:`size-4 text-primary`}),(0,Z.jsx)(J,{id:`PIMM5l`})]}):r??(0,Z.jsx)(J,{id:`GzPQ2f`}),t[16]=d,t[17]=r,t[18]=D):D=t[18];let O;t[19]!==D||t[20]!==E?(O=(0,Z.jsx)(`p`,{ref:p,tabIndex:E,className:`text-sm font-medium leading-tight text-foreground focus:outline-none`,children:D}),t[19]=D,t[20]=E,t[21]=O):O=t[21];let k;t[22]!==i||t[23]!==d?(k=d?(0,Z.jsx)(J,{id:`pBROkv`}):i??(0,Z.jsx)(J,{id:`WmPbvm`}),t[22]=i,t[23]=d,t[24]=k):k=t[24];let A;t[25]===k?A=t[26]:(A=(0,Z.jsx)(`p`,{className:`text-1sm text-muted-foreground`,role:`status`,children:k}),t[25]=k,t[26]=A);let j;t[27]!==O||t[28]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[O,A]}),t[27]=O,t[28]=A,t[29]=j):j=t[29];let M;t[30]!==u||t[31]!==o?(M=o?(0,Z.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,onClick:o,"aria-label":u({id:`yz7wBu`}),className:`-mr-1.5 -mt-1 size-7 shrink-0 text-muted-foreground opacity-60`,children:(0,Z.jsx)(Cs,{className:`size-4`})}):null,t[30]=u,t[31]=o,t[32]=M):M=t[32];let N;t[33]!==j||t[34]!==M?(N=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[j,M]}),t[33]=j,t[34]=M,t[35]=N):N=t[35];let P;t[36]!==u||t[37]!==s||t[38]!==c||t[39]!==S||t[40]!==b||t[41]!==x||t[42]!==w||t[43]!==d?(P=d?null:(0,Z.jsxs)(`form`,{onSubmit:b.handleSubmit(w),className:`flex flex-col gap-2`,noValidate:!0,children:[(0,Z.jsx)(ka,{control:b.control,name:`email`,render:e=>{let{field:t,fieldState:n}=e;return(0,Z.jsxs)(zC,{className:`h-10 rounded-xl`,children:[(0,Z.jsx)(VC,{className:`pl-2.5`,children:(0,Z.jsx)(Qd,{className:`size-4 text-muted-foreground opacity-60`})}),(0,Z.jsx)(WC,{...t,id:t.name,type:`email`,inputMode:`email`,autoComplete:`email`,spellCheck:!1,autoFocus:s,placeholder:u({id:`2hYmUH`}),"aria-invalid":n.invalid,"aria-label":u({id:`ATGYL1`}),"data-testid":`subscribe-email`,className:`placeholder:text-muted-foreground/60`}),(0,Z.jsx)(X,{type:`submit`,disabled:x,size:c?`icon`:`default`,className:Y(`mr-1 ml-auto text-1sm`,c&&`size-8 shrink-0 rounded-lg`),"data-testid":`subscribe-submit`,children:x?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ss,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`sr-only`,children:(0,Z.jsx)(J,{id:`lCC_D5`})})]}):c?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(lt,{className:`size-4`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`sr-only`,children:(0,Z.jsx)(J,{id:`EDl9kS`})})]}):(0,Z.jsx)(J,{id:`EDl9kS`})})]})}}),S?(0,Z.jsx)(`p`,{className:`text-sm text-destructive`,role:`alert`,children:S}):null]}),t[36]=u,t[37]=s,t[38]=c,t[39]=S,t[40]=b,t[41]=x,t[42]=w,t[43]=d,t[44]=P):P=t[44];let F;return t[45]!==N||t[46]!==P||t[47]!==T?(F=(0,Z.jsxs)(`div`,{className:T,children:[N,P]}),t[45]=N,t[46]=P,t[47]=T,t[48]=F):F=t[48],F}var KP=`https://github.com/inkeep/open-knowledge`,qP=`https://discord.com/invite/YujKpFN49`,JP=`https://x.com/OpenKnowledgeAI`,YP=`ok-subscribe-card-v1`,XP={subscribed:!1,dismissed:!1,shownVersions:[]};function ZP(e,t){return!e.subscribed&&!e.dismissed&&e.shownVersions.length<3&&!e.shownVersions.includes(t)}function QP(e){return e===!0}function $P(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function eF(e){if(typeof e!=`object`||!e)return XP;let t=e;return{subscribed:QP(t.subscribed),dismissed:QP(t.dismissed),shownVersions:$P(t.shownVersions)}}function tF(e){try{let t=(e??localStorage).getItem(YP);return t==null?XP:eF(JSON.parse(t))}catch(e){return console.warn(`[subscribe-card-store] readPersistedState failed (corrupt/privacy/SSR)`,e),XP}}function nF(e,t){try{(t??localStorage).setItem(YP,JSON.stringify(e))}catch(e){console.warn(`[subscribe-card-store] writePersistedState failed (quota/privacy/SSR)`,e)}}function rF(e){let t=tF(e),n=new Set,r=!1;function i(){for(let e of n)e()}function a(n){t=n,nF(t,e),i()}return{getSnapshot(){return t},subscribe(e){return n.add(e),()=>{n.delete(e)}},markSubscribed(){t.subscribed||a({...t,subscribed:!0})},dismiss(){t.dismissed||a({...t,dismissed:!0})},recordShown(e){t.shownVersions.includes(e)||a({...t,shownVersions:[...t.shownVersions,e]})},install(){r||(r=!0,t=tF(e),i())}}}var iF=rF();function aF(){iF.install()}function oF(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 sF(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 cF(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 lF=[{key:`resources`,heading:{id:`s-MGs7`},links:[{label:{id:`TbjyhA`},href:`https://openknowledge.ai/docs`,icon:Mt},{label:{id:`PCNIuJ`},href:`${KP}/issues/new`,icon:Cd},{label:{id:`On0aF2`},href:`https://openknowledge.ai/`,icon:Zi}]},{key:`community`,heading:{id:`chL5IG`},links:[{label:`Discord`,href:qP,icon:oF},{label:`X (Twitter)`,href:JP,icon:cF},{label:`GitHub`,href:KP,icon:sF}]}],uF=`${KP}/releases`,dF=`group 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`;function fF(e){if(e<1e3)return String(e);let t=e/1e3;return`${t>=10?Math.round(t):t.toFixed(1)}k`}var pF=e=>{let t=(0,$.c)(12),{count:n}=e,{_:r}=$t(),i,a,o,s;t[0]!==r||t[1]!==n?(i=fF(n),a=`img`,o=`ml-auto flex items-center gap-1 text-xs tabular-nums text-muted-foreground`,s=r({id:`SVLPt5`,values:{formatted:i}}),t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s):(i=t[2],a=t[3],o=t[4],s=t[5]);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(Tf,{className:`size-3 fill-current`,"aria-hidden":`true`}),t[6]=c):c=t[6];let l;return t[7]!==i||t[8]!==a||t[9]!==o||t[10]!==s?(l=(0,Z.jsxs)(`span`,{role:a,className:o,"aria-label":s,children:[c,i]}),t[7]=i,t[8]=a,t[9]=o,t[10]=s,t[11]=l):l=t[11],l},mF=e=>{let t=(0,$.c)(15),{link:n,trailing:r}=e,{_:i}=$t(),{label:a,href:o,icon:s}=n,c,l;t[0]===o?(c=t[1],l=t[2]):(c=e=>du(e,o),l=e=>du(e,o),t[0]=o,t[1]=c,t[2]=l);let u;t[3]===s?u=t[4]:(u=(0,Z.jsx)(s,{"aria-hidden":`true`,className:`size-4 shrink-0`}),t[3]=s,t[4]=u);let d;t[5]!==i||t[6]!==a?(d=typeof a==`string`?a:i(a),t[5]=i,t[6]=a,t[7]=d):d=t[7];let f;return t[8]!==o||t[9]!==c||t[10]!==l||t[11]!==u||t[12]!==d||t[13]!==r?(f=(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`a`,{href:o,target:`_blank`,rel:`noopener noreferrer`,onClick:c,onAuxClick:l,className:dF,children:[u,d,r]})}),t[8]=o,t[9]=c,t[10]=l,t[11]=u,t[12]=d,t[13]=r,t[14]=f):f=t[14],f},hF=e=>{let t=(0,$.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs mb-1`,children:n}),t[0]=n,t[1]=r),r},gF=()=>{let e=(0,$.c)(28),{_:t}=$t(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(null),c,l;e[0]!==n||e[1]!==o?(c=()=>{if(!n||o!==null)return;let e=new AbortController;return Cr({signal:e.signal}).then(e=>{e!==null&&s(e)}),()=>e.abort()},l=[n,o],e[0]=n,e[1]=o,e[2]=c,e[3]=l):(c=e[2],l=e[3]),(0,Q.useEffect)(c,l);let u;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=e=>{r(e),e||a(!1)},e[4]=u):u=e[4];let d;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(et,{className:`size-4`}),e[5]=d):d=e[5];let f;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(jt,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[d,(0,Z.jsx)(`span`,{className:`sr-only`,children:(0,Z.jsx)(J,{id:`s-MGs7`})})]})})}),e[6]=f):f=e[6];let p;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsxs)(Fs,{children:[f,(0,Z.jsx)(Ns,{children:(0,Z.jsx)(J,{id:`s-MGs7`})})]}),e[7]=p):p=e[7];let m;e[8]!==t||e[9]!==o?(m=lF.map((e,n)=>(0,Z.jsxs)(`div`,{className:Y(n>0&&`mt-3`),children:[(0,Z.jsx)(hF,{children:t(e.heading)}),(0,Z.jsx)(`nav`,{"aria-label":t(e.heading),children:(0,Z.jsx)(`ul`,{className:`space-y-0.5`,children:e.links.map(e=>(0,Z.jsx)(mF,{link:e,trailing:e.href===`https://github.com/inkeep/open-knowledge`&&o!==null?(0,Z.jsx)(pF,{count:o}):void 0},e.href))})})]},e.key)),e[8]=t,e[9]=o,e[10]=m):m=e[10];let h;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(hF,{children:(0,Z.jsx)(J,{id:`arUUsK`})}),e[11]=h):h=e[11];let g;e[12]===t?g=e[13]:(g=t({id:`arUUsK`}),e[12]=t,e[13]=g);let _;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(mF,{link:{label:{id:`3ePd3I`},href:uF,icon:$d}}),e[14]=_):_=e[14];let v;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(jt,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,className:Y(dF,`h-auto w-full justify-start font-normal`),children:[(0,Z.jsx)(Qd,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,Z.jsx)(J,{id:`EDl9kS`})]})}),e[15]=v):v=e[15];let y;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(yt,{side:`left`,align:`center`,sideOffset:20,className:`w-80`,children:(0,Z.jsx)(GP,{source:`resources_menu`,autoFocus:!0,onDismiss:()=>a(!1),onSuccess:_F})}),e[16]=y):y=e[16];let b;e[17]===i?b=e[18]:(b=(0,Z.jsxs)(`ul`,{className:`space-y-0.5`,children:[_,(0,Z.jsx)(`li`,{children:(0,Z.jsxs)($e,{open:i,onOpenChange:a,children:[v,y]})})]}),e[17]=i,e[18]=b);let x;e[19]!==b||e[20]!==g?(x=(0,Z.jsxs)(`div`,{className:`mt-3`,children:[h,(0,Z.jsx)(`nav`,{"aria-label":g,children:b})]}),e[19]=b,e[20]=g,e[21]=x):x=e[21];let S;e[22]!==x||e[23]!==m?(S=(0,Z.jsxs)(yt,{align:`end`,className:`w-56 p-3`,children:[m,x]}),e[22]=x,e[23]=m,e[24]=S):S=e[24];let C;return e[25]!==n||e[26]!==S?(C=(0,Z.jsxs)($e,{open:n,onOpenChange:u,children:[p,S]}),e[25]=n,e[26]=S,e[27]=C):C=e[27],C};function _F(){return iF.markSubscribed()}var vF=50,yF=()=>{let e=(0,$.c)(8),t=(0,Q.useRef)(null),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>{t.current===null&&(t.current=setTimeout(()=>{t.current=null,wC.preload()},vF))},e[0]=n):n=e[0];let r=n,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{t.current!==null&&(clearTimeout(t.current),t.current=null)},e[1]=i):i=e[1];let a=i,o,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>()=>{t.current!==null&&clearTimeout(t.current)},s=[],e[2]=o,e[3]=s):(o=e[2],s=e[3]),(0,Q.useEffect)(o,s);let c,l;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{a(),window.location.hash!==`#settings`&&(window.location.hash=Ea)},l=(0,Z.jsx)(_f,{className:`size-4`}),e[4]=c,e[5]=l):(c=e[4],l=e[5]);let u;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(Ms,{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`,onMouseEnter:r,onMouseLeave:a,onFocus:r,onBlur:a,onClick:c,children:[l,(0,Z.jsx)(`span`,{className:`sr-only`,children:(0,Z.jsx)(J,{id:`Tz0i8g`})})]})}),e[6]=u):u=e[6];let d;return e[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsxs)(Fs,{children:[u,(0,Z.jsx)(Ns,{children:(0,Z.jsx)(J,{id:`Tz0i8g`})})]}),e[7]=d):d=e[7],d},bF=`https://git-scm.com/docs/git-push`;function xF(e,t){return!(e!==`stale`&&e!==`absent`||e===`stale`&&t?.syncEnabled===!0)}function SF(e){return e?e.state!==`dormant`&&e.state!==`disabled`&&e.state!==`auth-error`&&e.state!==`conflict`:!1}function CF(e){let t=(0,$.c)(47),{freshness:n,status:r,kind:i}=e,{_:a}=$t(),{confirmOpen:o,setConfirmOpen:s,onToggleRequest:c,onConfirm:l}=Di(Ei()),[u,d]=(0,Q.useState)(`idle`),f=(0,Q.useRef)(null),p,m;if(t[0]!==r||t[1]!==u?(p=()=>{if(!(u!==`pending`||!r)){if(r.pushError||r.pushErrorCode){d(`idle`);return}(r.lastSyncUtc??null)!==f.current&&d(`synced`)}},m=[u,r],t[0]=r,t[1]=u,t[2]=p,t[3]=m):(p=t[2],m=t[3]),(0,Q.useEffect)(p,m),!xF(n,r))return null;if(u===`synced`){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed border-border bg-muted/40 p-2 text-xs text-muted-foreground`,"data-testid":`share-freshness-row`,children:[(0,Z.jsx)(Wi,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{children:(0,Z.jsx)(J,{id:`fxbCNQ`})})]}),t[4]=e):e=t[4],e}let h=r?.syncEnabled===!0,g=r?.pushPermission?.checkStatus===`denied`,_=!!(r?.pushError||r?.pushErrorCode),v=g||_,y=n===`absent`&&!h,b;if(n===`absent`&&!h){let e;t[5]!==a||t[6]!==i?(e=a(i===`folder`?{id:`PrJYSN`}:{id:`3BnyYc`}),t[5]=a,t[6]=i,t[7]=e):e=t[7],b=e}else if(n===`stale`){let e;t[8]!==a||t[9]!==i?(e=a(i===`folder`?{id:`Gt4gOO`}:{id:`2IYGkU`}),t[8]=a,t[9]=i,t[10]=e):e=t[10],b=e}else{let e;t[11]!==a||t[12]!==i?(e=a(i===`folder`?{id:`nqV0Kk`}:{id:`gwykHF`}),t[11]=a,t[12]=i,t[13]=e):e=t[13],b=e}let x;t[14]!==a||t[15]!==_||t[16]!==g?(x=g?a({id:`9OIqw4`}):_?a({id:`K6MQQk`}):null,t[14]=a,t[15]=_,t[16]=g,t[17]=x):x=t[17];let S=x,C;t[18]===r?.lastSyncUtc?C=t[19]:(C=()=>{f.current=r?.lastSyncUtc??null,d(`pending`),Co(`sync`).catch(e=>{console.warn(`[share-freshness] sync trigger failed`,e instanceof Error?e.message:e),d(`idle`)})},t[18]=r?.lastSyncUtc,t[19]=C);let w=C,T=y?Yi:rs,E;t[20]===T?E=t[21]:(E=(0,Z.jsx)(T,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`}),t[20]=T,t[21]=E);let D;t[22]===b?D=t[23]:(D=(0,Z.jsx)(`span`,{children:b}),t[22]=b,t[23]=D);let O;t[24]===S?O=t[25]:(O=S?(0,Z.jsx)(`span`,{children:S}):null,t[24]=S,t[25]=O);let k;t[26]!==v||t[27]!==w||t[28]!==c||t[29]!==r||t[30]!==h||t[31]!==u?(k=v?null:h?SF(r)?(0,Z.jsx)(`div`,{children:u===`pending`?(0,Z.jsxs)(X,{variant:`outline`,size:`xs`,disabled:!0,children:[(0,Z.jsx)(ls,{className:`size-3 shrink-0 animate-spin`,"aria-hidden":`true`}),(0,Z.jsx)(J,{id:`EHu0x2`})]}):(0,Z.jsx)(X,{variant:`outline`,size:`xs`,onClick:w,children:(0,Z.jsx)(J,{id:`lb_UU4`})})}):null:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,Z.jsx)(X,{variant:`outline`,size:`xs`,onClick:()=>c(!0),children:(0,Z.jsx)(J,{id:`XU0OXn`})}),(0,Z.jsxs)(`a`,{href:bF,target:`_blank`,rel:`noopener noreferrer`,onClick:TF,onAuxClick:wF,className:`inline-flex items-center gap-1 transition-colors hover:text-primary`,children:[(0,Z.jsx)(J,{id:`GLxIKR`}),(0,Z.jsx)(Ai,{className:`size-3 shrink-0`,"aria-hidden":`true`})]})]}),t[26]=v,t[27]=w,t[28]=c,t[29]=r,t[30]=h,t[31]=u,t[32]=k):k=t[32];let A;t[33]!==D||t[34]!==O||t[35]!==k?(A=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[D,O,k]}),t[33]=D,t[34]=O,t[35]=k,t[36]=A):A=t[36];let j;t[37]!==E||t[38]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed border-border bg-muted/40 p-2 text-xs text-muted-foreground`,"data-testid":`share-freshness-row`,children:[E,A]}),t[37]=E,t[38]=A,t[39]=j):j=t[39];let M;t[40]!==o||t[41]!==l||t[42]!==s?(M=(0,Z.jsx)(ki,{open:o,onOpenChange:s,onConfirm:l}),t[40]=o,t[41]=l,t[42]=s,t[43]=M):M=t[43];let N;return t[44]!==j||t[45]!==M?(N=(0,Z.jsxs)(Z.Fragment,{children:[j,M]}),t[44]=j,t[45]=M,t[46]=N):N=t[46],N}function wF(e){return du(e,bF)}function TF(e){return du(e,bF)}var EF=`https://openknowledge.ai/docs/features/share`;function DF(e){let t=(0,$.c)(50),{input:n,onClickWhenNoRemote:r}=e,{_:i}=$t(),{status:a}=Ra(),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(null),d;t[0]===c?.autoCopyFailed?d=t[1]:(d=()=>{!c?.autoCopyFailed||!u.current||(u.current.focus(),u.current.select())},t[0]=c?.autoCopyFailed,t[1]=d);let f;t[2]===c?f=t[3]:(f=[c],t[2]=c,t[3]=f),(0,Q.useEffect)(d,f);let p=a?.hasRemote===!0,m=n===null,h=xF(c?.freshness,a),g;t[4]!==i||t[5]!==o||t[6]!==p||t[7]!==n||t[8]!==r?(g=async function(){if(!o&&n!==null){s(!0),l(null);try{let e=await Ia({...n,hasRemote:p,onClickWhenNoRemote:r},{clipboardWrite:va,toastSuccess:FF,toastError:PF,logEvent:NF});e.kind===`copied`?l({url:e.shareUrl,autoCopyFailed:!1,freshness:e.freshness}):e.kind===`clipboard-failed`&&l({url:e.shareUrl,autoCopyFailed:!0,freshness:e.freshness})}catch{Ss.error(i({id:`u3YnKw`}))}s(!1)}},t[4]=i,t[5]=o,t[6]=p,t[7]=n,t[8]=r,t[9]=g):g=t[9];let _=g,v=c!==null,y;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{e||l(null)},t[10]=y):y=t[10];let b;t[11]!==i||t[12]!==n?.kind?(b=n?.kind===`folder`?i({id:`WR0y2O`}):i({id:`F4IYWe`}),t[11]=i,t[12]=n?.kind,t[13]=b):b=t[13];let x=o||m,S,C;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(vf,{className:`size-3.5`,"aria-hidden":!0}),C=(0,Z.jsx)(J,{id:`Z8lGw6`}),t[14]=S,t[15]=C):(S=t[14],C=t[15]);let w;t[16]!==_||t[17]!==b||t[18]!==x?(w=(0,Z.jsx)(Oe,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,size:`sm`,"aria-label":b,onClick:_,disabled:x,className:`gap-1.5 text-muted-foreground px-1.5`,"data-testid":`share-button`,children:[S,C]})}),t[16]=_,t[17]=b,t[18]=x,t[19]=w):w=t[19];let T=h?`w-96`:`w-80`,E;t[20]===T?E=t[21]:(E=Y(`flex flex-col gap-2`,T),t[20]=T,t[21]=E);let D;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs`,children:(0,Z.jsx)(J,{id:`Z8lGw6`})}),t[22]=D):D=t[22];let O;t[23]===c?.autoCopyFailed?O=t[24]:(O=c?.autoCopyFailed?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,Z.jsx)(J,{id:`ndeI89`})}):null,t[23]=c?.autoCopyFailed,t[24]=O);let k=c?.url??``,A;t[25]===i?A=t[26]:(A=i({id:`5-FeN2`}),t[25]=i,t[26]=A);let j;t[27]!==k||t[28]!==A?(j=(0,Z.jsx)(Uc,{ref:u,readOnly:!0,value:k,onFocus:MF,onClick:jF,onContextMenu:AF,className:`select-all bg-muted font-mono text-xs text-muted-foreground`,"data-testid":`share-button-url`,"aria-label":A}),t[27]=k,t[28]=A,t[29]=j):j=t[29];let M=c?.url??``,N=c?.autoCopyFailed===!1,P;t[30]!==M||t[31]!==N?(P=(0,Z.jsx)(`div`,{className:`absolute inset-y-0 right-1 flex items-center`,children:(0,Z.jsx)(`div`,{className:`rounded-md bg-background/50 backdrop-blur-sm`,children:(0,Z.jsx)(U,{copyContent:M,clipboardWrite:va,initialCopied:N})})}),t[30]=M,t[31]=N,t[32]=P):P=t[32];let F;t[33]!==j||t[34]!==P?(F=(0,Z.jsxs)(`div`,{className:`relative`,children:[j,P]}),t[33]=j,t[34]=P,t[35]=F):F=t[35];let I=c?.freshness,L=n?.kind??`doc`,R;t[36]!==a||t[37]!==I||t[38]!==L?(R=(0,Z.jsx)(CF,{freshness:I,status:a,kind:L}),t[36]=a,t[37]=I,t[38]=L,t[39]=R):R=t[39];let z;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsxs)(`a`,{href:EF,target:`_blank`,rel:`noopener noreferrer`,onClick:kF,onAuxClick:OF,className:`mt-2 flex items-center gap-1.5 self-start text-xs text-muted-foreground transition-colors hover:text-primary`,children:[(0,Z.jsx)(et,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Z.jsx)(J,{id:`aByJ8j`})]}),t[40]=z):z=t[40];let B;t[41]!==E||t[42]!==O||t[43]!==F||t[44]!==R?(B=(0,Z.jsxs)(yt,{align:`end`,className:E,"data-testid":`share-button-popover`,children:[D,O,F,R,z]}),t[41]=E,t[42]=O,t[43]=F,t[44]=R,t[45]=B):B=t[45];let V;return t[46]!==w||t[47]!==B||t[48]!==v?(V=(0,Z.jsxs)($e,{open:v,onOpenChange:y,children:[w,B]}),t[46]=w,t[47]=B,t[48]=v,t[49]=V):V=t[49],V}function OF(e){return du(e,EF)}function kF(e){return du(e,EF)}function AF(e){return e.currentTarget.select()}function jF(e){return e.currentTarget.select()}function MF(e){return e.currentTarget.select()}function NF(e){return console.log(e)}function PF(e){e!==`Link ready but could not copy to clipboard.`&&Ss.error(e)}function FF(e){return Ss.success(e)}function IF(e){let t=(0,$.c)(35),{onSignIn:n,onSetIdentity:r,onOpenSearch:i}=e,{_:a}=$t(),{activeDocName:o,activeTarget:s}=mt(),c=o?Xr(o):null,{state:l,isDraggingRail:u}=Sj(),d=cg(),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=kl(`toggle-files-sidebar`),t[0]=f):f=t[0];let p=f,m=kl(`command-palette`),[h,g]=(0,Q.useState)(!1),_;bb0:{if(s?.kind===`folder`){let e;t[1]===s.folderPath?e=t[2]:(e=Na(s.folderPath),t[1]=s.folderPath,t[2]=e),_=e;break bb0}if(o&&!c){let e;t[3]===o?e=t[4]:(e=Aa(o),t[3]=o,t[4]=e),_=e;break bb0}if(!s&&!o){let e;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=Na(``),t[5]=e):e=t[5],_=e;break bb0}_=null}let v=_,y=typeof window<`u`&&window.okDesktop!=null,b=l===`collapsed`,x=y?``:void 0,S=y&&b&&`pl-[var(--ok-titlebar-reserve-left,1rem)]`,C=y&&!u&&`motion-safe:transition-[padding] motion-safe:duration-200 motion-safe:ease-linear`,w;t[6]!==S||t[7]!==C?(w=Y(`flex h-12 shrink-0 items-center bg-muted/35 shadow-[inset_0_-1px_0_var(--border)]`,y&&`[-webkit-app-region:drag]`,S,C),t[6]=S,t[7]=C,t[8]=w):w=t[8];let T=!d&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Fs,{children:[(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(Dj,{className:Y(`-ml-1 shrink-0 text-muted-foreground`,y&&`[-webkit-app-region:no-drag]`)})}),(0,Z.jsx)(Ns,{children:l===`expanded`?(0,Z.jsx)(J,{id:`ZxXhLY`,values:{sidebarShortcut:p}}):(0,Z.jsx)(J,{id:`Zz25kq`,values:{sidebarShortcut:p}})})]}),b&&i&&(0,Z.jsxs)(Fs,{children:[(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-sm`,onClick:i,"aria-label":a({id:`IN4UX8`,values:{searchShortcut:m}}),"data-telemetry-event":`ok.editor_header.search.click`,className:Y(`shrink-0 text-muted-foreground`,y&&`[-webkit-app-region:no-drag]`),children:(0,Z.jsx)(L,{"aria-hidden":`true`})})}),(0,Z.jsx)(Ns,{children:(0,Z.jsx)(J,{id:`IN4UX8`,values:{searchShortcut:m}})})]}),(0,Z.jsx)(Qa,{orientation:`vertical`,className:`mr-1 h-4 shrink-0 data-vertical:self-center`}),(0,Z.jsx)(MP,{})]}),E;t[9]===T?E=t[10]:(E=(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 px-3`,children:T}),t[9]=T,t[10]=E);let D;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(D=Y(`flex shrink-0 items-center justify-end gap-2 px-3`,y&&`[&>*]:[-webkit-app-region:no-drag]`),t[11]=D):D=t[11];let O;t[12]!==h||t[13]!==g||t[14]!==v||t[15]!==d?(O=!d&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(DF,{input:v,onClickWhenNoRemote:()=>g(!0)}),(0,Z.jsx)(Ba,{open:h,onOpenChange:g})]}),t[12]=h,t[13]=g,t[14]=v,t[15]=d,t[16]=O):O=t[16];let k;t[17]!==r||t[18]!==n?(k=(0,Z.jsx)(Xa,{onSignIn:n,onSetIdentity:r}),t[17]=r,t[18]=n,t[19]=k):k=t[19];let A,j,M;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(CN,{}),j=(0,Z.jsx)(Qa,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),M=(0,Z.jsx)(EN,{}),t[20]=A,t[21]=j,t[22]=M):(A=t[20],j=t[21],M=t[22]);let N;t[23]===d?N=t[24]:(N=!d&&(0,Z.jsx)(yF,{}),t[23]=d,t[24]=N);let P;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(gF,{}),t[25]=P):P=t[25];let F;t[26]!==O||t[27]!==k||t[28]!==N?(F=(0,Z.jsxs)(`div`,{className:D,children:[O,k,A,j,M,N,P]}),t[26]=O,t[27]=k,t[28]=N,t[29]=F):F=t[29];let I;return t[30]!==F||t[31]!==x||t[32]!==w||t[33]!==E?(I=(0,Z.jsxs)(`header`,{"data-electron-drag":x,className:w,children:[E,F]}),t[30]=F,t[31]=x,t[32]=w,t[33]=E,t[34]=I):I=t[34],I}var LF=`open-knowledge:terminal-launch`;function RF(e,t,n=typeof window>`u`?new EventTarget:window){n.dispatchEvent(new CustomEvent(LF,{detail:{prompt:e,cli:t}}))}function zF(e,t=typeof window>`u`?new EventTarget:window){let n=t=>{let n=t instanceof CustomEvent?t.detail:void 0;n&&typeof n.prompt==`string`&&e(n.prompt,n.cli)};return t.addEventListener(LF,n),()=>t.removeEventListener(LF,n)}function BF(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,orientation:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`horizontal`:i,o;t[4]===n?o=t[5]:(o=Y(`group/tabs flex gap-2 data-horizontal:flex-col`,n),t[4]=n,t[5]=o);let s;return t[6]!==a||t[7]!==r||t[8]!==o?(s=(0,Z.jsx)(Zp,{"data-slot":`tabs`,"data-orientation":a,className:o,...r}),t[6]=a,t[7]=r,t[8]=o,t[9]=s):s=t[9],s}var VF=_i(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function HF(e){let t=(0,$.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,variant:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`default`:i,o;t[4]!==n||t[5]!==a?(o=Y(VF({variant:a}),n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==o||t[9]!==a?(s=(0,Z.jsx)(Qp,{"data-slot":`tabs-list`,"data-variant":a,className:o,...r}),t[7]=r,t[8]=o,t[9]=a,t[10]=s):s=t[10],s}function UF(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(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)($p,{"data-slot":`tabs-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function WF(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 text-sm outline-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(em,{"data-slot":`tabs-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var GF=(0,Q.lazy)(()=>n(()=>import(`./TerminalPanel-vd5LQunA.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([86,1,10,3,11,6,7,13,52,17,33,87,60,31,88]),import.meta.url));function KF(e){let t=(0,$.c)(14),{bridge:n,onClose:r,onTitleChange:i,launch:a,adoptPtyId:o,onPtyId:s}=e,c=a===void 0?null:a,l=o===void 0?null:o,{enabled:u,synced:d}=So(),f=wo(),{_:p}=$t(),m=d&&u===!1,h;t[0]!==p||t[1]!==f?(h=function(){if(f===null){Ss.error(p({id:`V_6bJ4`}));return}let e=f(!0);e.ok||Ss.error(p({id:`jKd3AP`,values:{0:e.error}}))},t[0]=p,t[1]=f,t[2]=h):h=t[2];let _=h;if(d&&!m){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`div`,{className:`h-full w-full bg-background`,"aria-hidden":`true`}),t[3]=e):e=t[3];let a;return t[4]!==l||t[5]!==n||t[6]!==c||t[7]!==r||t[8]!==s||t[9]!==i?(a=(0,Z.jsx)(g,{fallbackRender:JF,onError:qF,children:(0,Z.jsx)(Q.Suspense,{fallback:e,children:(0,Z.jsx)(GF,{bridge:n,className:`h-full`,onClose:r,onTitleChange:i,launch:c,adoptPtyId:l,onPtyId:s})})}),t[4]=l,t[5]=n,t[6]=c,t[7]=r,t[8]=s,t[9]=i,t[10]=a):a=t[10],a}let v;return t[11]!==_||t[12]!==m?(v=m?(0,Z.jsx)(ZF,{onEnable:_}):(0,Z.jsx)(`div`,{className:`h-full w-full bg-background`,"aria-hidden":`true`}),t[11]=_,t[12]=m,t[13]=v):v=t[13],v}function qF(e,t){console.error(`[TerminalGate] rendered fallback for the terminal panel`,e,t.componentStack)}function JF(e){return(0,Z.jsx)(YF,{...e})}function YF(e){let t=(0,$.c)(15),{error:n}=e,{_:r}=$t(),i;t[0]!==r||t[1]!==n?(i=n instanceof Error&&/dynamically imported module|Failed to fetch/i.test(n.message)?r({id:`Y8ViJx`}):r({id:`fbsiBw`}),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;t[3]===r?o=t[4]:(o=r({id:`6MnZEC`}),t[3]=r,t[4]=o);let s;t[5]===a?s=t[6]:(s=(0,Z.jsx)(`p`,{className:`max-w-sm text-sm text-foreground`,children:a}),t[5]=a,t[6]=s);let c;t[7]===r?c=t[8]:(c=r({id:`HpK_8d`}),t[7]=r,t[8]=c);let l;t[9]===c?l=t[10]:(l=(0,Z.jsx)(X,{onClick:XF,children:c}),t[9]=c,t[10]=l);let u;return t[11]!==o||t[12]!==s||t[13]!==l?(u=(0,Z.jsxs)(`section`,{"aria-label":o,className:`flex h-full w-full flex-col items-center justify-center gap-3 bg-background p-6 text-center`,role:`alert`,children:[s,l]}),t[11]=o,t[12]=s,t[13]=l,t[14]=u):u=t[14],u}function XF(){return window.location.reload()}function ZF(e){let t=(0,$.c)(20),{onEnable:n}=e,{_:r}=$t(),i;t[0]===r?i=t[1]:(i=r({id:`_XWY2J`}),t[0]=r,t[1]=i);let a;t[2]===r?a=t[3]:(a=r({id:`oYepHb`}),t[2]=r,t[3]=a);let o;t[4]===a?o=t[5]:(o=(0,Z.jsx)(`p`,{className:`max-w-sm text-sm text-foreground`,children:a}),t[4]=a,t[5]=o);let s;t[6]===r?s=t[7]:(s=r({id:`v2ZW0K`}),t[6]=r,t[7]=s);let c;t[8]!==n||t[9]!==s?(c=(0,Z.jsx)(X,{onClick:n,children:s}),t[8]=n,t[9]=s,t[10]=c):c=t[10];let l;t[11]===r?l=t[12]:(l=r({id:`ICoNYz`}),t[11]=r,t[12]=l);let u;t[13]===l?u=t[14]:(u=(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l}),t[13]=l,t[14]=u);let d;return t[15]!==i||t[16]!==o||t[17]!==c||t[18]!==u?(d=(0,Z.jsxs)(`section`,{"aria-label":i,className:`flex h-full w-full flex-col items-center justify-center gap-3 bg-background p-6 text-center`,children:[o,c,u]}),t[15]=i,t[16]=o,t[17]=c,t[18]=u,t[19]=d):d=t[19],d}function QF(e){let t=(0,$.c)(48),{selected:n,onLaunchSelected:r,onPickCli:i,onPickTerminal:a,className:o}=e,{_:s}=$t(),c=n===`terminal`,l;t[0]!==s||t[1]!==c||t[2]!==n?(l=s(c?{id:`AB4qw9`}:{id:`nP-KFo`,values:{0:zn[n].displayName}}),t[0]=s,t[1]=c,t[2]=n,t[3]=l):l=t[3];let u=l,d;t[4]===o?d=t[5]:(d=Y(`flex shrink-0 items-center`,o),t[4]=o,t[5]=d);let f;t[6]!==c||t[7]!==n?(f=c?(0,Z.jsx)(Cf,{"aria-hidden":`true`,className:`size-3.5`}):(0,Z.jsx)(la,{id:ca(n),className:`size-3.5`,"aria-hidden":`true`}),t[6]=c,t[7]=n,t[8]=f):f=t[8];let p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(Zt,{"aria-hidden":`true`,className:`size-3`}),t[9]=p):p=t[9];let m;t[10]!==r||t[11]!==u||t[12]!==f?(m=(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsxs)(X,{type:`button`,variant:`ghost`,size:`xs`,"aria-label":u,"data-testid":`terminal-new-chat`,className:`cursor-pointer gap-0.5 rounded-r-none px-1.5 text-muted-foreground hover:text-foreground`,onClick:r,children:[f,p]})}),t[10]=r,t[11]=u,t[12]=f,t[13]=m):m=t[13];let h;t[14]===u?h=t[15]:(h=(0,Z.jsx)(Ns,{side:`bottom`,sideOffset:8,children:u}),t[14]=u,t[15]=h);let g;t[16]!==m||t[17]!==h?(g=(0,Z.jsxs)(Fs,{children:[m,h]}),t[16]=m,t[17]=h,t[18]=g):g=t[18];let _;t[19]===s?_=t[20]:(_=s({id:`QJaG-9`}),t[19]=s,t[20]=_);let v;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(Gi,{"aria-hidden":`true`,className:`size-3`}),t[21]=v):v=t[21];let y;t[22]===_?y=t[23]:(y=(0,Z.jsx)(yc,{asChild:!0,children:(0,Z.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":_,"data-testid":`terminal-new-chat-menu`,className:`cursor-pointer rounded-l-none text-muted-foreground hover:text-foreground`,children:v})}),t[22]=_,t[23]=y);let b;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(Mc,{children:(0,Z.jsx)(J,{id:`hIQkLb`})}),t[24]=b):b=t[24];let x;t[25]!==s||t[26]!==i||t[27]!==n?(x=ba.map(e=>{let{displayName:t}=zn[e];return(0,Z.jsxs)(xc,{onSelect:()=>i(e),"data-testid":`terminal-new-chat-cli-${e}`,"aria-label":s({id:`9mEZeD`,values:{name:t}}),"aria-current":n===e?`true`:void 0,children:[(0,Z.jsx)(la,{id:ca(e),className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:t}),n===e?(0,Z.jsx)(Wi,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null]},e)}),t[25]=s,t[26]=i,t[27]=n,t[28]=x):x=t[28];let S;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(Pc,{}),t[29]=S):S=t[29];let C=c?`true`:void 0,w;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(Cf,{"aria-hidden":`true`,className:`size-4`}),t[30]=w):w=t[30];let T;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(`span`,{className:`flex-1`,children:(0,Z.jsx)(J,{id:`ALhMYW`})}),t[31]=T):T=t[31];let E;t[32]===c?E=t[33]:(E=c?(0,Z.jsx)(Wi,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null,t[32]=c,t[33]=E);let D;t[34]!==a||t[35]!==C||t[36]!==E?(D=(0,Z.jsxs)(xc,{onSelect:a,"data-testid":`terminal-new-chat-terminal`,"aria-current":C,children:[w,T,E]}),t[34]=a,t[35]=C,t[36]=E,t[37]=D):D=t[37];let O;t[38]!==x||t[39]!==D?(O=(0,Z.jsxs)(Cc,{align:`start`,className:`min-w-[180px]`,children:[b,x,S,D]}),t[38]=x,t[39]=D,t[40]=O):O=t[40];let k;t[41]!==y||t[42]!==O?(k=(0,Z.jsxs)(kc,{children:[y,O]}),t[41]=y,t[42]=O,t[43]=k):k=t[43];let A;return t[44]!==d||t[45]!==k||t[46]!==g?(A=(0,Z.jsxs)(`div`,{className:d,children:[g,k]}),t[44]=d,t[45]=k,t[46]=g,t[47]=A):A=t[47],A}function $F(e){let t=(0,$.c)(52),{sessions:n,activeSessionId:r,onSelect:i,onTabActivate:a,newChatSelected:o,onNewChatLaunch:s,onNewChatPickCli:c,onNewChatPickTerminal:l,onClose:u,dockPosition:d,onToggleDock:f,onCollapse:p,children:m,className:h,draggable:g}=e,{_}=$t(),v=d===`right`,y;t[0]===h?y=t[1]:(y=Y(`flex min-h-0 min-w-0 flex-1 flex-col`,h),t[0]=h,t[1]=y);let b=g?``:void 0,x=g&&`h-[62px] [-webkit-app-region:drag] pr-[22px] pl-[calc(var(--ok-titlebar-reserve-left,1rem)+0.75rem)]`,S;t[2]===x?S=t[3]:(S=Y(`flex shrink-0 flex-row items-center gap-1 px-1.5 py-1`,x),t[2]=x,t[3]=S);let C;t[4]===_?C=t[5]:(C=_({id:`1MGRQl`}),t[4]=_,t[5]=C);let w;if(t[6]!==_||t[7]!==r||t[8]!==g||t[9]!==u||t[10]!==a||t[11]!==n){let e;t[13]!==_||t[14]!==r||t[15]!==g||t[16]!==u||t[17]!==a?(e=e=>{let t=e.id===r;return(0,Z.jsxs)(`div`,{className:Y(`group flex shrink-0 cursor-default items-center rounded-md pr-0.5 transition-colors`,t?`bg-muted`:`hover:bg-muted/50`),children:[(0,Z.jsxs)(Fs,{children:[(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(UF,{value:e.id,onClick:()=>a?.(e.id),className:Y(`h-7 flex-none rounded-md px-2 text-xs`,g&&`[-webkit-app-region:no-drag]`),children:(0,Z.jsx)(`span`,{className:`max-w-40 truncate`,children:e.label})})}),(0,Z.jsx)(Ns,{side:`bottom`,sideOffset:8,children:e.label})]}),(0,Z.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":_({id:`nzHlj8`,values:{0:e.label}}),tabIndex:t?0:-1,className:Y(`text-muted-foreground opacity-0 transition-opacity hover:text-foreground group-hover:opacity-100 group-focus-within:opacity-100`,t&&`opacity-100`,g&&`[-webkit-app-region:no-drag]`),onClick:t=>{t.stopPropagation(),u(e.id)},children:(0,Z.jsx)(Cs,{"aria-hidden":`true`})})]},e.id)},t[13]=_,t[14]=r,t[15]=g,t[16]=u,t[17]=a,t[18]=e):e=t[18],w=n.map(e),t[6]=_,t[7]=r,t[8]=g,t[9]=u,t[10]=a,t[11]=n,t[12]=w}else w=t[12];let T;t[19]!==C||t[20]!==w?(T=(0,Z.jsx)(HF,{variant:`line`,"aria-label":C,className:`flex h-auto min-w-0 items-center justify-start gap-0.5 overflow-x-auto bg-transparent p-0 [scrollbar-width:none] scroll-fade-mask-x`,children:w}),t[19]=C,t[20]=w,t[21]=T):T=t[21];let E=g&&`[-webkit-app-region:no-drag]`,D;t[22]===E?D=t[23]:(D=Y(`shrink-0`,E),t[22]=E,t[23]=D);let O;t[24]!==o||t[25]!==s||t[26]!==c||t[27]!==l||t[28]!==D?(O=(0,Z.jsx)(QF,{selected:o,onLaunchSelected:s,onPickCli:c,onPickTerminal:l,className:D}),t[24]=o,t[25]=s,t[26]=c,t[27]=l,t[28]=D,t[29]=O):O=t[29];let k;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Z.jsx)(`div`,{className:`flex-1`}),t[30]=k):k=t[30];let A;t[31]!==_||t[32]!==f||t[33]!==v?(A=f==null?null:(0,Z.jsxs)(Fs,{children:[(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":_(v?{id:`rf6x3F`}:{id:`QNxpRm`}),className:`shrink-0 cursor-pointer text-muted-foreground hover:text-foreground`,onClick:f,children:v?(0,Z.jsx)(rf,{"aria-hidden":`true`}):(0,Z.jsx)(cf,{"aria-hidden":`true`})})}),(0,Z.jsx)(Ns,{side:`bottom`,sideOffset:8,children:v?(0,Z.jsx)(J,{id:`rf6x3F`}):(0,Z.jsx)(J,{id:`QNxpRm`})})]}),t[31]=_,t[32]=f,t[33]=v,t[34]=A):A=t[34];let j;t[35]!==_||t[36]!==p||t[37]!==v?(j=p==null?null:(0,Z.jsxs)(Fs,{children:[(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":_({id:`VZGGPK`}),className:`shrink-0 cursor-pointer text-muted-foreground hover:text-foreground`,onClick:p,children:v?(0,Z.jsx)(qi,{"aria-hidden":`true`}):(0,Z.jsx)(Gi,{"aria-hidden":`true`})})}),(0,Z.jsx)(Ns,{side:`bottom`,sideOffset:8,children:(0,Z.jsx)(J,{id:`VZGGPK`})})]}),t[35]=_,t[36]=p,t[37]=v,t[38]=j):j=t[38];let M;t[39]!==O||t[40]!==A||t[41]!==j||t[42]!==b||t[43]!==S||t[44]!==T?(M=(0,Z.jsxs)(`div`,{"data-electron-drag":b,className:S,children:[T,O,k,A,j]}),t[39]=O,t[40]=A,t[41]=j,t[42]=b,t[43]=S,t[44]=T,t[45]=M):M=t[45];let N;return t[46]!==r||t[47]!==m||t[48]!==i||t[49]!==y||t[50]!==M?(N=(0,Z.jsxs)(BF,{value:r,onValueChange:i,className:y,children:[M,m]}),t[46]=r,t[47]=m,t[48]=i,t[49]=y,t[50]=M,t[51]=N):N=t[51],N}function eI(e){return`terminal-session-${e}`}function tI(e){e!==``&&document.querySelector(`[data-terminal-session="${e}"] .xterm-helper-textarea`)?.focus()}function nI(e){let t=(0,$.c)(79),{bridge:n,variant:r,visible:i,onVisibleChange:a,launch:o,installedClis:s,container:c,isShowing:l,onRequestEditorFocus:u,dockPosition:d,onToggleDock:f,onHasSessionsChange:p}=e,m=r===void 0?`dock`:r,h=o===void 0?null:o,{_:g}=$t(),[_]=(0,Q.useState)(cI),v,y;t[0]!==c||t[1]!==_?(v=()=>{_==null||c==null||_.parentElement!==c&&c.appendChild(_)},y=[_,c],t[0]=c,t[1]=_,t[2]=v,t[3]=y):(v=t[2],y=t[3]),(0,Q.useLayoutEffect)(v,y);let b=typeof n.terminal?.list==`function`,x;t[4]!==b||t[5]!==h||t[6]!==i?(x=()=>!b&&i?[{id:eI(1),launch:h,title:null,adoptPtyId:null}]:[],t[4]=b,t[5]=h,t[6]=i,t[7]=x):x=t[7];let[S,C]=(0,Q.useState)(x),w;t[8]!==b||t[9]!==i?(w=()=>!b&&i?eI(1):``,t[8]=b,t[9]=i,t[10]=w):w=t[10];let[T,E]=(0,Q.useState)(w),[D,O]=(0,Q.useState)(!b),k=(0,Q.useRef)(!1),A=(0,Q.useRef)(T),j=(0,Q.useRef)(S),M=(0,Q.useRef)(!b&&i?1:0),N=(0,Q.useRef)(i&&h?h.nonce:null),P=(0,Q.useRef)(m===`window`?!1:i),F=(0,Q.useRef)(new Map),I=function(e,t){t===null?F.current.delete(e):F.current.set(e,t)},L=(0,Q.useRef)(0),R;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(R=function(e){M.current+=1;let t=eI(M.current);C(n=>[...n,{id:t,launch:e,title:null,adoptPtyId:null}]),E(t)},t[11]=R):R=t[11];let z=R,[B,V]=(0,Q.useState)(sI),[H,U]=(0,Q.useState)(oI),W;t[12]===s?W=t[13]:(W=s??{},t[12]=s,t[13]=W);let G;t[14]!==B||t[15]!==W?(G=u_(B,W),t[14]=B,t[15]=W,t[16]=G):G=t[16];let K=G,ee=H?`terminal`:K,te;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(te=function(e){L.current+=1,z({prompt:null,cli:e,nonce:L.current})},t[17]=te):te=t[17];let ne=te,re;t[18]!==K||t[19]!==H?(re=function(){H?z(null):ne(K)},t[18]=K,t[19]=H,t[20]=re):re=t[20];let ie=re,ae;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(ae=function(e){U(!1),y_(!1);let t=i_(e);V(t),c_(t),ne(e)},t[21]=ae):ae=t[21];let oe=ae,se;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(se=function(){U(!0),y_(!0),z(null)},t[22]=se):se=t[22];let ce=se,le;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(le=function(e,t){let n=t.trim()===``?null:t.trim();C(t=>t.some(t=>t.id===e&&t.title!==n)?t.map(t=>t.id===e?{...t,title:n}:t):t)},t[23]=le):le=t[23];let q=le,ue=(0,Q.useRef)(z),de;t[24]!==T||t[25]!==u||t[26]!==a?(de=function(e){let t=j.current,n=t.findIndex(t=>t.id===e);if(n===-1)return;let r=t.filter(t=>t.id!==e);if(e===T){let e=(t[n-1]??t[n+1])?.id??``;E(e),e!==``&&queueMicrotask(()=>tI(e))}C(r),r.length===0&&(a(!1),u())},t[24]=T,t[25]=u,t[26]=a,t[27]=de):de=t[27];let fe=de,pe=(0,Q.useRef)(aI),me;t[28]!==T||t[29]!==fe||t[30]!==S?(me=()=>{ue.current=z,A.current=T,j.current=S,pe.current=()=>{T!==``&&fe(T)}},t[28]=T,t[29]=fe,t[30]=S,t[31]=me):me=t[31],(0,Q.useEffect)(me);let he,ge;t[32]!==h||t[33]!==D||t[34]!==S.length||t[35]!==i?(he=()=>{if(!D)return;let e=P.current;if(P.current=i,h!=null&&h.nonce!==N.current){N.current=h.nonce,ue.current(h);return}i&&!e&&S.length===0&&ue.current(null)},ge=[i,h,S.length,D],t[32]=h,t[33]=D,t[34]=S.length,t[35]=i,t[36]=he,t[37]=ge):(he=t[36],ge=t[37]),(0,Q.useEffect)(he,ge);let _e;t[38]===n.terminal?_e=t[39]:(_e=()=>{if(typeof n.terminal?.list!=`function`||k.current)return;k.current=!0;let e=!1;return(async()=>{let t;try{t=await n.terminal.list()??[]}catch(e){console.error(`[terminal] reload session list() failed; cold-starting:`,e),t=[]}if(!e){if(t.length>0){let e=t.map(iI);M.current=e.length,C(e),E(e[0]?.id??``)}O(!0)}})(),()=>{e=!0,k.current=!1}},t[38]=n.terminal,t[39]=_e);let ve;t[40]===n?ve=t[41]:(ve=[n],t[40]=n,t[41]=ve),(0,Q.useEffect)(_e,ve);let ye;t[42]===n?ye=t[43]:(ye=[n],t[42]=n,t[43]=ye),(0,Q.useEffect)(()=>RE(e=>{let t=A.current,r=t===``?void 0:F.current.get(t);r==null?lu():(n.terminal.input(r,e),queueMicrotask(()=>tI(t)))}),ye);let be,xe;t[44]!==n||t[45]!==m?(be=()=>n.onMenuAction(e=>{e===`new-terminal`?ue.current(null):(e===`kill-terminal`||e===`close-active-tab-or-window`&&m===`window`)&&pe.current()}),xe=[n,m],t[44]=n,t[45]=m,t[46]=be,t[47]=xe):(be=t[46],xe=t[47]),(0,Q.useEffect)(be,xe);let Se,Ce;t[48]!==_||t[49]!==m?(Se=()=>{let e=function(e){if(!e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||!/^[1-9]$/.test(e.key)||m!==`window`&&(_==null||!_.contains(document.activeElement)))return;let t=j.current[Number(e.key)-1];t!=null&&(e.preventDefault(),e.stopPropagation(),E(t.id),queueMicrotask(()=>tI(t.id)))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},Ce=[_,m],t[48]=_,t[49]=m,t[50]=Se,t[51]=Ce):(Se=t[50],Ce=t[51]),(0,Q.useEffect)(Se,Ce);let we;t[52]!==n.editor||t[53]!==S.length?(we=()=>{n.editor.notifyViewMenuStateChanged({terminalLive:S.length>0})},t[52]=n.editor,t[53]=S.length,t[54]=we):we=t[54];let Te;t[55]!==n||t[56]!==S.length?(Te=[n,S.length],t[55]=n,t[56]=S.length,t[57]=Te):Te=t[57],(0,Q.useEffect)(we,Te);let Ee,De;t[58]!==p||t[59]!==S.length?(Ee=()=>{p?.(S.length>0)},De=[p,S.length],t[58]=p,t[59]=S.length,t[60]=Ee,t[61]=De):(Ee=t[60],De=t[61]),(0,Q.useEffect)(Ee,De);let Oe,ke;t[62]!==_||t[63]!==l||t[64]!==u||t[65]!==i?(Oe=()=>{l||i||_==null||!_.contains(document.activeElement)||u()},ke=[l,i,_,u],t[62]=_,t[63]=l,t[64]=u,t[65]=i,t[66]=Oe,t[67]=ke):(Oe=t[66],ke=t[67]),(0,Q.useLayoutEffect)(Oe,ke);let Ae,je;t[68]===l?(Ae=t[69],je=t[70]):(Ae=()=>{l&&tI(A.current)},je=[l],t[68]=l,t[69]=Ae,t[70]=je),(0,Q.useEffect)(Ae,je);let Me;if(t[71]!==g||t[72]!==S){let e;t[74]===g?e=t[75]:(e=(e,t)=>({id:e.id,label:e.title??g({id:`OVjNeX`,values:{0:t+1}})}),t[74]=g,t[75]=e),Me=S.map(e),t[71]=g,t[72]=S,t[73]=Me}else Me=t[73];let Ne=Me,Pe=S.length>0?(0,Z.jsx)($F,{sessions:Ne,activeSessionId:T,onSelect:E,onTabActivate:rI,newChatSelected:ee,onNewChatLaunch:ie,onNewChatPickCli:oe,onNewChatPickTerminal:ce,onClose:fe,dockPosition:d,onToggleDock:f,onCollapse:m===`window`?void 0:()=>a(!1),draggable:m===`window`,className:`h-full`,children:S.map(e=>(0,Z.jsx)(WF,{value:e.id,forceMount:!0,"data-terminal-session":e.id,className:Y(`m-0 flex min-h-0 flex-1 flex-col overflow-hidden data-[state=inactive]:hidden`,m===`window`&&`px-[22px] pb-[22px]`),children:(0,Z.jsx)(KF,{bridge:n,launch:e.launch,adoptPtyId:e.adoptPtyId,onPtyId:t=>I(e.id,t),onTitleChange:t=>q(e.id,t),onClose:()=>fe(e.id)})},e.id))}):null,Fe;return t[76]!==_||t[77]!==Pe?(Fe=_==null?null:(0,_d.createPortal)(Pe,_),t[76]=_,t[77]=Pe,t[78]=Fe):Fe=t[78],Fe}function rI(e){return queueMicrotask(()=>tI(e))}function iI(e,t){return{id:eI(t+1),launch:null,title:null,adoptPtyId:e.ptyId}}function aI(){}function oI(){return b_()}function sI(){return s_()}function cI(){if(typeof document>`u`)return null;let e=document.createElement(`div`);return e.className=`flex min-h-0 flex-1 flex-col overflow-hidden`,e}function lI(e){let t=(0,$.c)(74),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{onOpenSearch:r}=n,[i,a]=Yg(),[o,s]=(0,Q.useState)(i),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(`auth`),[f,p]=(0,Q.useState)(Iv[0].id),[m,h]=(0,Q.useState)(!1),g=typeof window<`u`?window.okDesktop??null:null,_=g!=null&&g.terminal!=null,[v,y]=(0,Q.useState)(!1),b=Xg(),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),T=(0,Q.useRef)(!1),[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(g_),A;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(A=function(e){k(e),h_(e),y(!0)},t[2]=A):A=t[2];let j=A,M;t[3]===O?M=t[4]:(M=function(){j(O===`right`?`bottom`:`right`)},t[3]=O,t[4]=M);let N=M,P;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(P={container:null,isShowing:!1,dockPosition:`bottom`,editorRegion:null},t[5]=P):P=t[5];let[F,I]=(0,Q.useState)(P),L=(0,Q.useRef)(0),R;t[6]===b?R=t[7]:(R=function(e){let t=e??u_(s_(),b);y(!0),L.current+=1,D({prompt:null,cli:t,nonce:L.current})},t[6]=b,t[7]=R);let z=R,B;t[8]!==x||t[9]!==z?(B=function(){y(!0),!x&&!v_()&&z()},t[8]=x,t[9]=z,t[10]=B):B=t[10];let V=B,H=Ka(),{projectConfig:U,projectLocalConfig:W,projectLocalSynced:G,projectSynced:K}=zo(),{activeDocName:ee}=mt(),te=H?.hasRemote,ne=H?.pushPermission?.checkStatus,re;t[11]!==m||t[12]!==U||t[13]!==W||t[14]!==G||t[15]!==K||t[16]!==te||t[17]!==ne?(re=C_({autoSyncOnboardingDismissed:m,hasRemote:te,projectLocalSynced:G,projectSynced:K,projectLocalConfig:W,projectConfig:U,pushPermissionCheckStatus:ne}),t[11]=m,t[12]=U,t[13]=W,t[14]=G,t[15]=K,t[16]=te,t[17]=ne,t[18]=re):re=t[18];let ie=re,ae,oe;t[19]===ee?(ae=t[20],oe=t[21]):(ae=()=>{let e=function(e){let t=e.detail;t&&ee&&tu(ee,{kind:`raw-mdx`,detail:t}),s(`source`)};return window.addEventListener(Vg,e),()=>window.removeEventListener(Vg,e)},oe=[ee],t[19]=ee,t[20]=ae,t[21]=oe),(0,Q.useEffect)(ae,oe);let se,ce;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>{let e=window.okDesktop;if(e!=null)return e.onMenuAction(e=>{e===`toggle-terminal`?y(fI):e===`new-terminal`&&y(!0)})},ce=[],t[22]=se,t[23]=ce):(se=t[22],ce=t[23]),(0,Q.useEffect)(se,ce);let le,q;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>{if(window.okDesktop!=null)return;let e=function(e){Al(e,`toggle-terminal-panel`)&&(e.preventDefault(),y(dI))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},q=[],t[24]=le,t[25]=q):(le=t[24],q=t[25]),(0,Q.useEffect)(le,q);let ue,de;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>zF((e,t)=>{y(!0),L.current+=1,D({prompt:e,cli:t,nonce:L.current})}),de=[],t[26]=ue,t[27]=de):(ue=t[26],de=t[27]),(0,Q.useEffect)(ue,de);let fe,pe;t[28]===v?(fe=t[29],pe=t[30]):(fe=()=>{v||D(null)},pe=[v],t[28]=v,t[29]=fe,t[30]=pe),(0,Q.useEffect)(fe,pe);let me,he;t[31]!==C||t[32]!==v?(me=()=>{window.okDesktop!=null&&C&&window.okDesktop.editor.notifyViewMenuStateChanged({terminalVisible:v})},he=[v,C],t[31]=C,t[32]=v,t[33]=me,t[34]=he):(me=t[33],he=t[34]),(0,Q.useEffect)(me,he);let ge,_e;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ge=()=>{let e=window.okDesktop;if(e==null)return;if(typeof e.terminal?.getDockState!=`function`){w(!0);return}let t=!1;return e.terminal.getDockState().then(e=>{t||!e.visible||(T.current=!0,y(!0))}).catch(uI).finally(()=>{t||w(!0)}),()=>{t=!0}},_e=[],t[35]=ge,t[36]=_e):(ge=t[35],_e=t[36]),(0,Q.useEffect)(ge,_e);let ve,ye;t[37]===v?(ve=t[38],ye=t[39]):(ve=()=>{if(window.okDesktop!=null){if(T.current){T.current=!1;return}v&&Wa()}},ye=[v],t[37]=v,t[38]=ve,t[39]=ye),(0,Q.useEffect)(ve,ye),Qg(H?.pausedReason),$g();let be;t[40]===a?be=t[41]:(be=function(e){s(e),a(e)},t[40]=a,t[41]=be);let xe=be,Se,Ce;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(Se=()=>{d(`auth`),l(!0)},Ce=()=>{d(`identity`),l(!0)},t[42]=Se,t[43]=Ce):(Se=t[42],Ce=t[43]);let we;t[44]===r?we=t[45]:(we=(0,Z.jsx)(IF,{onSignIn:Se,onSetIdentity:Ce,onOpenSearch:r}),t[44]=r,t[45]=we);let Te=_?V:void 0,Ee;t[46]!==f||t[47]!==o||t[48]!==xe||t[49]!==Te||t[50]!==O||t[51]!==v?(Ee=(0,Z.jsx)(LM,{editorMode:o,onModeChange:xe,activeTab:f,onActiveTabChange:p,terminalBridge:g,terminalVisible:v,onTerminalVisibleChange:y,terminalDock:O,onTerminalPlacement:I,onRevealTerminal:Te}),t[46]=f,t[47]=o,t[48]=xe,t[49]=Te,t[50]=O,t[51]=v,t[52]=Ee):Ee=t[52];let De;t[53]!==b||t[54]!==O||t[55]!==E||t[56]!==F||t[57]!==v||t[58]!==N?(De=_&&g!=null?(0,Z.jsx)(nI,{bridge:g,visible:v,onVisibleChange:y,launch:E,installedClis:b,container:F.container,isShowing:F.isShowing,onRequestEditorFocus:()=>F.editorRegion?.focus(),dockPosition:O,onToggleDock:N,onHasSessionsChange:S}):null,t[53]=b,t[54]=O,t[55]=E,t[56]=F,t[57]=v,t[58]=N,t[59]=De):De=t[59];let Oe=u===`identity`,ke;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(ke=()=>{l(!1)},t[60]=ke):ke=t[60];let Ae;t[61]!==c||t[62]!==Oe?(Ae=(0,Z.jsx)(ja,{open:c,onOpenChange:l,identityPrompt:Oe,onSuccess:ke}),t[61]=c,t[62]=Oe,t[63]=Ae):Ae=t[63];let je;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(je=()=>h(!0),t[64]=je):je=t[64];let Me;t[65]===ie?Me=t[66]:(Me=(0,Z.jsx)(x_,{open:ie,onResolved:je}),t[65]=ie,t[66]=Me);let Ne;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=(0,Z.jsx)(Rg,{}),t[67]=Ne):Ne=t[67];let Pe;return t[68]!==we||t[69]!==Ee||t[70]!==De||t[71]!==Ae||t[72]!==Me?(Pe=(0,Z.jsxs)(Z.Fragment,{children:[we,Ee,De,Ae,Me,Ne]}),t[68]=we,t[69]=Ee,t[70]=De,t[71]=Ae,t[72]=Me,t[73]=Pe):Pe=t[73],Pe}function uI(e){console.error(`[terminal] dock-state restore failed; staying hidden:`,e)}function dI(e){return!e}function fI(e){return!e}function pI(e){let t=yl(ol(e));typeof window>`u`||window.location.hash!==t&&(window.location.hash=t)}function mI(){let e=(0,$.c)(11),{conflicts:t,loading:n,error:r}=To();if(n)return null;if(r===`server`){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`section`,{"data-testid":`conflicts-section`,"aria-label":`Conflicted files`,className:`border-b border-amber-200/60 bg-amber-50/40 px-2 py-2 dark:border-amber-900/40 dark:bg-amber-950/20`,children:(0,Z.jsxs)(`p`,{"data-testid":`conflicts-section-error`,className:`px-2 py-1.5 text-[12px] text-amber-700 dark:text-amber-400`,children:[(0,Z.jsx)(Yi,{"aria-hidden":`true`,className:`mr-1.5 inline size-3`}),`Couldn't load conflicts — reload to retry.`]})}),e[0]=t):t=e[0],t}if(t.length===0)return null;let i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-[11px] uppercase tracking-wider text-amber-700 dark:text-amber-400`,children:[(0,Z.jsx)(Yi,{"aria-hidden":`true`,className:`size-3`}),`Conflicts`]}),e[1]=i):i=e[1];let a;e[2]===t.length?a=e[3]:(a=(0,Z.jsxs)(`header`,{className:`flex items-center justify-between px-2 pb-1.5`,children:[i,(0,Z.jsx)(`span`,{"data-testid":`conflicts-section-count`,className:`rounded-full bg-amber-500 px-1.5 py-0.5 font-mono text-[10px] font-medium leading-none text-white`,children:t.length})]}),e[2]=t.length,e[3]=a);let o;e[4]===t?o=e[5]:(o=t.map(hI),e[4]=t,e[5]=o);let s;e[6]===o?s=e[7]:(s=(0,Z.jsx)(`ul`,{className:`flex flex-col gap-px`,children:o}),e[6]=o,e[7]=s);let c;return e[8]!==a||e[9]!==s?(c=(0,Z.jsxs)(`section`,{"data-testid":`conflicts-section`,"aria-label":`Conflicted files`,className:`border-b border-amber-200/60 bg-amber-50/40 px-2 py-2 dark:border-amber-900/40 dark:bg-amber-950/20`,children:[a,s]}),e[8]=a,e[9]=s,e[10]=c):c=e[10],c}function hI(e){return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(X,{variant:`ghost`,size:`sm`,"data-testid":`conflicts-section-row`,"data-file":e.file,title:e.file,className:`h-7 w-full justify-start gap-1.5 px-2 font-normal text-[13px] text-amber-800 hover:bg-amber-100/60 hover:text-amber-900 dark:text-amber-300 dark:hover:bg-amber-900/30 dark:hover:text-amber-200`,onClick:()=>pI(e.file),children:[(0,Z.jsx)(Yi,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.file})]})},e.file)}var gI=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
29
+ `,r);if(s>-1&&s<t&&(e=s),i&&p<f.length){let t=Math.max(0,m?f[p].toA:f[p].fromA);t<=e&&(e=t,m&&p++,o=!0)}if(e>r){let t=document.createTextNode(l.slice(r,e));if(a){let e=d.appendChild(document.createElement(`span`));e.className=a,e.appendChild(t)}else d.appendChild(t);r=e}o&&(m=!m)}}if(u&&t.toA-t.fromA<=o){let t=u.parser.parse(l),n=0;Ll(t,{style:t=>Zl(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 iA.set(t.changes,i),i}function sA(e,t){let{state:n}=e,r=t??n.selection.main.head,i=e.state.field(pk).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(rA);i.fromB!=i.toB&&i.toA<=o.length&&(a+=e.state.lineBreak);let s=Pl.of({from:i.fromA,to:Math.min(o.length,i.toA),insert:a},o.length);return e.dispatch({effects:nA.of({doc:s.apply(o),changes:s}),userEvent:`accept`}),!0}function cA(e,t){let{state:n}=e,r=t??n.selection.main.head,i=n.field(pk).find(e=>e.fromB<=r&&e.endB>=r);if(!i)return!1;let a=n.field(rA).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 lA(e){let t=new Bl;for(let n of e.field(pk)){let r=e.facet(uk).overrideChunk&&fA(e,n);t.add(n.fromB,n.fromB,oA(e,n,!!r))}return t.finish()}var uA=Il.define({create:e=>lA(e),update(e,t){return t.state.field(pk,!1)==t.startState.field(pk,!1)?e:lA(t.state)},provide:e=>Gl.decorations.from(e)}),dA=new WeakMap;function fA(e,t){let n=dA.get(t);if(n!==void 0)return n;n=null;let r=e.field(rA),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(zl.widget({widget:new pA(t),side:-1}).range(s+n.fromB))}n.fromB<n.toB&&e.push(kk.range(s+n.fromB,s+n.toB))}i<t.endA-t.fromA-a*2&&(n=e)}return dA.set(t,n),n}var pA=class extends Ml{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}},mA=new class extends Kl{constructor(){super(...arguments),this.elementClass=`cm-inlineChangedLineGutter`}},hA=zl.line({class:`cm-inlineChangedLine`});function gA(e,t,n,r){let i=fA(e,t),a=0;if(!i)return!1;for(let o=e.doc.lineAt(t.fromB);;){for(r&&r.add(o.from,o.from,mA),n.add(o.from,o.from,hA);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 _A=q({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}}),vA=E({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}}),yA=Gl.theme({".cm-deletedChunk .cm-chunkButtons":{display:`flex`,gap:`0.25rem`},".cm-deletedChunk .cm-chunkButtons button[data-slot='button']":{margin:`0`,border:`1px solid transparent`,borderRadius:`min(var(--radius-md), 10px)`,color:`var(--primary-foreground)`},".cm-deletedChunk .cm-chunkButtons button[data-slot='button'][data-variant='destructive']":{color:`var(--destructive)`}});function bA({addControl:e,nextId:t,removeControl:n,root:r}){return(i,a)=>{let o=document.createElement(`span`);o.className=`inline-flex`;let s=t();return e({id:s,host:o,type:i,action:a}),queueMicrotask(()=>{r.contains(o)||n(s)}),o}}function xA(e){let t=(0,$.c)(33),{oldContent:n,newContent:r,layout:i,conflictMode:a,previewMode:o,oursOverride:s,onResolve:c,onAbort:l}=e,{_:u}=$t(),d=s??r,f=(0,Q.useRef)(null),p=(0,Q.useRef)(null),m=(0,Q.useRef)(0),{resolvedTheme:h}=Mn(),g=(0,Q.useRef)(c),_=(0,Q.useRef)(l),[v,y]=(0,Q.useState)(null),b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b=[],t[0]=b):b=t[0];let[x,S]=(0,Q.useState)(b),C=kO(a===!0),w;t[1]!==l||t[2]!==c?(w=()=>{g.current=c,_.current=l},t[1]=l,t[2]=c,t[3]=w):w=t[3],(0,Q.useEffect)(w);let T,E;t[4]!==a||t[5]!==d||t[6]!==i||t[7]!==n||t[8]!==o||t[9]!==h?(T=()=>{let e=f.current;if(!e)return;S([]);let t=new Map,r=!1,s=e=>{r||!t.delete(e)||S(t=>t.filter(t=>t.id!==e))},c=new MutationObserver(()=>{for(let[n,r]of t)e.contains(r)||s(n)});c.observe(e,{childList:!0,subtree:!0});let l=h===`dark`?_A:vA,u=[Gl.editable.of(!1),Fl.readOnly.of(!0)],g=[uu,Ql(),...u,l,Gl.lineWrapping];if(p.current&&=(p.current.destroy(),null),o)p.current=new Gl({doc:d,extensions:g,parent:e}),y(null);else if(a){let i=bA({addControl:e=>{r||(t.set(e.id,e.host),S(t=>[...t,e]))},nextId:()=>(m.current+=1,m.current),removeControl:s,root:e}),a=new Gl({doc:d,extensions:[uu,Ql(),Gl.editable.of(!1),l,yA,Gl.lineWrapping,tA({original:n,highlightChanges:!0,gutter:!0,mergeControls:i,collapseUnchanged:{margin:3,minSize:4}}),Gl.updateListener.of(e=>{let t=mk(e.state);y(t?t.chunks.length:0)})],parent:e});p.current=a;let o=mk(a.state);y(o?o.chunks.length:0)}else i===`split`?p.current=new Zk({a:{doc:n,extensions:g},b:{doc:d,extensions:g},parent:e,highlightChanges:!0,gutter:!0,collapseUnchanged:{margin:3,minSize:4}}):p.current=new Gl({doc:d,extensions:[...g,tA({original:n,highlightChanges:!0,gutter:!0,mergeControls:!1,collapseUnchanged:{margin:3,minSize:4}})],parent:e});return()=>{r=!0,c.disconnect(),p.current&&=(p.current.destroy(),null)}},E=[n,d,i,h,a,o],t[4]=a,t[5]=d,t[6]=i,t[7]=n,t[8]=o,t[9]=h,t[10]=T,t[11]=E):(T=t[10],E=t[11]),(0,Q.useEffect)(T,E);let D;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(D=function(){let e=p.current;!e||!(e instanceof Gl)||g.current?.(e.state.doc.toString())},t[12]=D):D=t[12];let O=D,k;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(k=function(){let e=p.current;!e||!(e instanceof Gl)||Se(e)},t[13]=k):k=t[13];let A=k,j=v===0,M;t[14]!==u||t[15]!==v?(M=v===null?``:v===0?u({id:`lPzyrU`}):Kc._({id:`8FqTCr`,values:{chunksRemaining:v}}),t[14]=u,t[15]=v,t[16]=M):M=t[16];let N=M,P;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(`div`,{ref:f,className:`diff-view min-h-0 flex-1 overflow-y-auto subtle-scrollbar`}),t[17]=P):P=t[17];let F;if(t[18]!==u||t[19]!==x){let e;t[21]===u?e=t[22]:(e=e=>(0,_d.createPortal)((0,Z.jsx)(X,{type:`button`,variant:e.type===`accept`?`default`:`destructive`,size:`xs`,onClick:t=>{e.action(t.nativeEvent)},children:e.type===`accept`?u({id:`g3UF2V`}):u({id:`1t_NnN`})}),e.host,e.id),t[21]=u,t[22]=e),F=x.map(e),t[18]=u,t[19]=x,t[20]=F}else F=t[20];let I;t[23]!==j||t[24]!==C||t[25]!==a||t[26]!==N||t[27]!==l||t[28]!==c?(I=a&&(0,Z.jsxs)(`div`,{ref:C,className:`flex items-center justify-between gap-2 px-3 py-2 border-t shrink-0`,children:[(0,Z.jsx)(`span`,{className:`text-xs ${j?`text-emerald-600 dark:text-emerald-400`:`text-muted-foreground`}`,children:N}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l&&(0,Z.jsx)(X,{className:`uppercase font-mono`,variant:`ghost`,size:`sm`,onClick:l,children:(0,Z.jsx)(J,{id:`XyOUTJ`})}),(0,Z.jsx)(X,{className:`uppercase font-mono`,variant:`outline`,size:`sm`,onClick:A,children:`Undo`}),c&&(0,Z.jsx)(X,{variant:`default`,size:`sm`,disabled:!j,onClick:O,children:(0,Z.jsx)(J,{id:`Lcehxn`})})]})]}),t[23]=j,t[24]=C,t[25]=a,t[26]=N,t[27]=l,t[28]=c,t[29]=I):I=t[29];let L;return t[30]!==I||t[31]!==F?(L=(0,Z.jsxs)(`div`,{className:`flex flex-col h-full`,children:[P,F,I]}),t[30]=I,t[31]=F,t[32]=L):L=t[32],L}async function SA(e,t,n){try{let r={file:e,strategy:t};n!==void 0&&(r.content=n);let i=await fetch(`/api/sync/resolve-conflict`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(i.ok)return{ok:!0};let a;try{let e=await i.json();typeof e.detail==`string`?a=e.detail:typeof e.title==`string`&&(a=e.title)}catch{}return{ok:!1,detail:a}}catch(n){let r=n instanceof Error?n.message:String(n);return console.warn(JSON.stringify({event:`conflict-resolve-dispatch-failed`,file:e,strategy:t,detail:r})),{ok:!1,detail:r}}}async function CA(e,t){return SA(e,`content`,t)}async function wA(e){return SA(e,`mine`)}async function TA(e){return SA(e,`theirs`)}async function EA(e){return SA(e,`delete`)}async function DA(e){try{let t=await fetch(`/api/sync/conflict-content?file=${encodeURIComponent(e)}&source=ytext`);if(!t.ok){let n;try{let e=await t.json();typeof e.detail==`string`?n=e.detail:typeof e.title==`string`&&(n=e.title)}catch{}return console.warn(JSON.stringify({event:`conflict-content-fetch-failed`,file:e,status:t.status,detail:n})),null}let n=await t.json(),r=n.kind===`delete-modify`||n.kind===`modify-delete`||n.kind===`both-modified`?n.kind:`both-modified`;return n.kind!==r&&console.warn(JSON.stringify({event:`conflict-kind-missing-fallback`,file:e,receivedKind:n.kind??null})),{base:n.base??``,ours:n.ours??``,theirs:n.theirs??``,kind:r}}catch(t){return console.warn(JSON.stringify({event:`conflict-content-fetch-failed`,file:e,status:null,detail:t instanceof Error?t.message:String(t)})),null}}function OA(e){let t=(0,$.c)(86),{docName:n}=e,{_:r}=$t(),{conflicts:i,loading:a}=To(),o;if(t[0]!==i||t[1]!==n){let e;t[3]===n?e=t[4]:(e=e=>ol(e.file)===n,t[3]=n,t[4]=e),o=i.find(e),t[0]=i,t[1]=n,t[2]=o}else o=t[2];let s=o,c=s?.file??`${n}.md`,[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),h=kO(l?.kind===`delete-modify`||l?.kind===`modify-delete`),g,_;t[5]===n?(g=t[6],_=t[7]):(g=()=>(console.warn(JSON.stringify({event:`editor-area-swap-to-diffview`,"doc.name":n})),()=>{console.warn(JSON.stringify({event:`editor-area-swap-from-diffview`,"doc.name":n}))}),_=[n],t[5]=n,t[6]=g,t[7]=_),(0,Q.useEffect)(g,_);let v=a||s===void 0,y,b;t[8]!==v||t[9]!==c?(y=()=>{if(v)return;let e=!1;return u(null),f(!1),DA(c).then(t=>{e||(t===null?f(!0):u(t))}),()=>{e=!0}},b=[c,v],t[8]=v,t[9]=c,t[10]=y,t[11]=b):(y=t[10],b=t[11]),(0,Q.useEffect)(y,b);let x;t[12]!==r||t[13]!==c?(x=async function(e){let t=await CA(c,e);t.ok||Ss.error(r({id:`K-h9cT`,values:{filePath:c}}),{description:t.detail})},t[12]=r,t[13]=c,t[14]=x):x=t[14];let S=x,C;t[15]!==r||t[16]!==c?(C=async function(e){m(!0);let t=await e(c);t.ok||(m(!1),Ss.error(r({id:`jPUPvG`,values:{filePath:c}}),{description:t.detail}))},t[15]=r,t[16]=c,t[17]=C):C=t[17];let w=C;if(d){let e;return t[18]===c?e=t[19]:(e=(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-sm text-muted-foreground`,children:(0,Z.jsx)(J,{id:`ajz9F8`,values:{filePath:c}})}),t[18]=c,t[19]=e),e}if(l===null){let e;return t[20]===c?e=t[21]:(e=(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-sm text-muted-foreground`,children:(0,Z.jsx)(J,{id:`DF1MtZ`,values:{filePath:c}})}),t[20]=c,t[21]=e),e}if(l.kind===`delete-modify`){let e;t[22]===l.theirs?e=t[23]:(e=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,Z.jsx)(xA,{oldContent:``,newContent:l.theirs,layout:`unified`,previewMode:!0})}),t[22]=l.theirs,t[23]=e);let n;t[24]===c?n=t[25]:(n={filePath:c},t[24]=c,t[25]=n);let r;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(r={0:(0,Z.jsx)(`span`,{className:`font-medium text-foreground`})},t[26]=r):r=t[26];let i;t[27]===n?i=t[28]:(i=(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Z.jsx)(J,{id:`V48OUT`,values:n,components:r})}),t[27]=n,t[28]=i);let a;t[29]===w?a=t[30]:(a=()=>void w(EA),t[29]=w,t[30]=a);let o;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(J,{id:`Vlc75q`}),t[31]=o):o=t[31];let s;t[32]!==p||t[33]!==a?(s=(0,Z.jsx)(X,{type:`button`,variant:`destructive`,disabled:p,onClick:a,children:o}),t[32]=p,t[33]=a,t[34]=s):s=t[34];let u;t[35]===w?u=t[36]:(u=()=>void w(TA),t[35]=w,t[36]=u);let d;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(J,{id:`3mFsc3`}),t[37]=d):d=t[37];let f;t[38]!==p||t[39]!==u?(f=(0,Z.jsx)(X,{type:`button`,variant:`default`,disabled:p,onClick:u,children:d}),t[38]=p,t[39]=u,t[40]=f):f=t[40];let m;t[41]!==s||t[42]!==f?(m=(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-3`,children:[s,f]}),t[41]=s,t[42]=f,t[43]=m):m=t[43];let g;t[44]!==h||t[45]!==i||t[46]!==m?(g=(0,Z.jsxs)(`div`,{ref:h,className:`flex flex-shrink-0 flex-wrap items-center justify-between gap-x-6 gap-y-3 border-t px-6 py-4`,children:[i,m]}),t[44]=h,t[45]=i,t[46]=m,t[47]=g):g=t[47];let _;return t[48]!==g||t[49]!==e?(_=(0,Z.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[e,g]}),t[48]=g,t[49]=e,t[50]=_):_=t[50],_}if(l.kind===`modify-delete`){let e;t[51]===l.ours?e=t[52]:(e=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,Z.jsx)(xA,{oldContent:``,newContent:l.ours,layout:`unified`,previewMode:!0})}),t[51]=l.ours,t[52]=e);let n;t[53]===c?n=t[54]:(n={filePath:c},t[53]=c,t[54]=n);let r;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(r={0:(0,Z.jsx)(`span`,{className:`font-medium text-foreground`})},t[55]=r):r=t[55];let i;t[56]===n?i=t[57]:(i=(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Z.jsx)(J,{id:`EhDLBx`,values:n,components:r})}),t[56]=n,t[57]=i);let a;t[58]===w?a=t[59]:(a=()=>void w(wA),t[58]=w,t[59]=a);let o;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(J,{id:`0NA4b3`}),t[60]=o):o=t[60];let s;t[61]!==p||t[62]!==a?(s=(0,Z.jsx)(X,{type:`button`,variant:`default`,disabled:p,onClick:a,children:o}),t[61]=p,t[62]=a,t[63]=s):s=t[63];let u;t[64]===w?u=t[65]:(u=()=>void w(EA),t[64]=w,t[65]=u);let d;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(J,{id:`qSxaOz`}),t[66]=d):d=t[66];let f;t[67]!==p||t[68]!==u?(f=(0,Z.jsx)(X,{type:`button`,variant:`destructive`,disabled:p,onClick:u,children:d}),t[67]=p,t[68]=u,t[69]=f):f=t[69];let m;t[70]!==s||t[71]!==f?(m=(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-3`,children:[s,f]}),t[70]=s,t[71]=f,t[72]=m):m=t[72];let g;t[73]!==h||t[74]!==i||t[75]!==m?(g=(0,Z.jsxs)(`div`,{ref:h,className:`flex flex-shrink-0 flex-wrap items-center justify-between gap-x-6 gap-y-3 border-t px-6 py-4`,children:[i,m]}),t[73]=h,t[74]=i,t[75]=m,t[76]=g):g=t[76];let _;return t[77]!==g||t[78]!==e?(_=(0,Z.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[e,g]}),t[77]=g,t[78]=e,t[79]=_):_=t[79],_}let T;t[80]===S?T=t[81]:(T=e=>void S(e),t[80]=S,t[81]=T);let E;return t[82]!==l.ours||t[83]!==l.theirs||t[84]!==T?(E=(0,Z.jsx)(xA,{oldContent:l.theirs,newContent:l.ours,layout:`unified`,conflictMode:!0,onResolve:T}),t[82]=l.ours,t[83]=l.theirs,t[84]=T,t[85]=E):E=t[85],E}function kA(e){let t=(0,$.c)(2),{docName:n,provider:r,children:i}=e;(0,Q.use)(It(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 AA=`__back-nav__`;function jA(e){return e instanceof Me||e instanceof vt||e instanceof De||e instanceof Qe||e instanceof At||e instanceof ee?e.docName:null}function MA(e){return e instanceof Me||e instanceof vt}function NA(e){if(e instanceof Me){let t=e.docName;return{title:Kc._({id:`Jejur6`}),summary:Kc._({id:`jSY41h`,values:{docName:t}})}}if(e instanceof vt){let t=e.docName;return{title:Kc._({id:`V7QxyT`}),summary:Kc._({id:`xG4tb6`,values:{docName:t}})}}if(e instanceof De){let t=e.docName;return{title:Kc._({id:`1di5fu`}),summary:Kc._({id:`PQCdtv`,values:{docName:t}})}}if(e instanceof Qe){let t=e.docName;return{title:Kc._({id:`wvbc1r`}),summary:Kc._({id:`IX7-sq`,values:{docName:t}})}}if(e instanceof At)return{title:Kc._({id:`Gfr4fu`}),summary:Kc._({id:`UW2Fg3`})};if(e instanceof ee){let t=e.docName;return{title:Kc._({id:`vv7kpg`}),summary:Kc._({id:`mdKFEy`,values:{docName:t}})}}let t=e instanceof Error&&e.message?e.message:Kc._({id:`W5A0Ly`});return{title:Kc._({id:`29VNqC`}),summary:t}}function PA(e){let t=(0,$.c)(31),{error:n,resetErrorBoundary:r,activeDocName:i,previousDocName:a,onNavigateBack:o}=e,s;t[0]===n?s=t[1]:(s=NA(n),t[0]=n,t[1]=s);let{title:c,summary:l}=s,u=!!a&&!!o,d=(0,Q.useRef)(null),f=typeof window<`u`?window.okDesktop:void 0,p=f&&MA(n)?f:null,m,h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{d.current?.focus()},h=[],t[2]=m,t[3]=h):(m=t[2],h=t[3]),(0,Q.useEffect)(m,h);let g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(hS,{size:80,variant:`sleeping`}),t[4]=g):g=t[4];let _;t[5]===c?_=t[6]:(_=(0,Z.jsx)(`h2`,{id:`document-error-title`,className:`text-2xl font-light tracking-tighter text-balance`,children:c}),t[5]=c,t[6]=_);let v;t[7]===l?v=t[8]:(v=(0,Z.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:l}),t[7]=l,t[8]=v);let y;t[9]!==_||t[10]!==v?(y=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[_,v]}),t[9]=_,t[10]=v,t[11]=y):y=t[11];let b;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(J,{id:`KDw4GX`}),t[12]=b):b=t[12];let x;t[13]===r?x=t[14]:(x=(0,Z.jsx)(X,{ref:d,variant:`default`,onClick:r,children:b}),t[13]=r,t[14]=x);let S;t[15]===p?S=t[16]:(S=p?(0,Z.jsx)(X,{variant:`secondary`,onClick:()=>{Ag(p).then(IA).catch(FA)},children:(0,Z.jsx)(J,{id:`uaUc6t`})}):null,t[15]=p,t[16]=S);let C;t[17]!==i||t[18]!==u||t[19]!==n||t[20]!==o||t[21]!==a||t[22]!==r?(C=u?(0,Z.jsx)(X,{variant:`ghost`,className:`font-mono uppercase`,onClick:()=>{!a||!o||(st(jA(n)??i),o(a),r(AA))},children:(0,Z.jsx)(J,{id:`CKyk7Q`})}):null,t[17]=i,t[18]=u,t[19]=n,t[20]=o,t[21]=a,t[22]=r,t[23]=C):C=t[23];let w;t[24]!==S||t[25]!==C||t[26]!==x?(w=(0,Z.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[x,S,C]}),t[24]=S,t[25]=C,t[26]=x,t[27]=w):w=t[27];let T;return t[28]!==w||t[29]!==y?(T=(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:[g,y,w]}),t[28]=w,t[29]=y,t[30]=T):T=t[30],T}function FA(){}function IA(e){e.ok||Ss.error(e.message,{id:`server-restart-error`,duration:1/0})}function LA(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)(PA,{...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]===AA){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}: ${NA(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)(g,{fallbackRender:s,resetKeys:c,onReset:l,onError:u,children:o}),t[11]=o,t[12]=s,t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}function RA(e){let t=e.document.getText(`source`).toString(),{map:n,parseError:r}=Qr(t);return{map:n,keys:Pr(t),parseError:r}}function zA(e){let t=(0,$.c)(21),{provider:n}=e,r;t[0]===n?r=t[1]:(r=()=>RA(n),t[0]=n,t[1]=r);let[i,a]=(0,Q.useState)(r),o,s;t[2]===n?(o=t[3],s=t[4]):(o=()=>{let e=Jn(n);a(e.current());let t=e.subscribe(e=>{a(e)});return()=>{t(),e.dispose()}},s=[n],t[2]=n,t[3]=o,t[4]=s),(0,Q.useEffect)(o,s);let c;t[5]===i.map.icon?c=t[6]:(c=Ye(i.map.icon),t[5]=i.map.icon,t[6]=c);let l=c,u;t[7]===i.map.cover?u=t[8]:(u=dt(i.map.cover),t[7]=i.map.cover,t[8]=u);let d=u,f=d.kind===`url`||d.kind===`path`,p=l.kind!==`unsupported`;if(!f&&!p)return null;let m=f?`true`:`false`,h=p?`true`:`false`,g;t[9]!==d||t[10]!==f?(g=f?(0,Z.jsx)(BA,{cover:d}):null,t[9]=d,t[10]=f,t[11]=g):g=t[11];let _;t[12]!==f||t[13]!==p||t[14]!==l?(_=p?(0,Z.jsx)(VA,{icon:l,hasCover:f}):null,t[12]=f,t[13]=p,t[14]=l,t[15]=_):_=t[15];let v;return t[16]!==m||t[17]!==h||t[18]!==g||t[19]!==_?(v=(0,Z.jsxs)(`div`,{className:`page-header editor-content-aligned`,"data-has-cover":m,"data-has-icon":h,"aria-hidden":`true`,"data-testid":`page-header`,children:[g,_]}),t[16]=m,t[17]=h,t[18]=g,t[19]=_,t[20]=v):v=t[20],v}function BA(e){let t=(0,$.c)(2),{cover:n}=e,r;return t[0]===n.value?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`page-header-cover`,"data-testid":`page-header-cover`,children:(0,Z.jsx)(`img`,{src:n.value,alt:``,draggable:!1,loading:`lazy`,referrerPolicy:`no-referrer`,className:`page-header-cover-img`})}),t[0]=n.value,t[1]=r),r}function VA(e){let t=(0,$.c)(9),{icon:n,hasCover:r}=e,i=r?`page-header-icon page-header-icon--with-cover`:`page-header-icon`;if(n.kind===`emoji`){let e;return t[0]!==n.value||t[1]!==i?(e=(0,Z.jsx)(`span`,{className:i,"data-testid":`page-header-icon`,"data-kind":`emoji`,children:n.value}),t[0]=n.value,t[1]=i,t[2]=e):e=t[2],e}let a;t[3]===n.value?a=t[4]:(a=(0,Z.jsx)(`img`,{src:n.value,alt:``,draggable:!1,referrerPolicy:`no-referrer`,className:`page-header-icon-img`}),t[3]=n.value,t[4]=a);let o;return t[5]!==n.kind||t[6]!==i||t[7]!==a?(o=(0,Z.jsx)(`span`,{className:i,"data-testid":`page-header-icon`,"data-kind":n.kind,children:a}),t[5]=n.kind,t[6]=i,t[7]=a,t[8]=o):o=t[8],o}var HA=(0,Q.lazy)(async()=>({default:(await n(async()=>{let{ManagedArtifactProperties:e}=await import(`./ManagedArtifactProperties-7tx2h5fh.js`);return{ManagedArtifactProperties:e}},__vite__mapDeps([79,1,37,2,38,39,11,40,41,42,43,44,45,46,47,15,16,13,7,17,18,10,3,48,49,33,12,6,4,50,51,52,20,53,54,55,56,30,31,32,57,58,59,60,61,62,68,70,19,80,69,81,82,35,77]),import.meta.url)).ManagedArtifactProperties})),UA=Dl(`LARGE_DOC_CHAR_THRESHOLD`,5e5);function WA(e){let t=e.threshold??UA;return e.ytextLength>t?{renderSource:e.isSourceMode||e.visitedSource,renderVisual:!e.isSourceMode||e.visitedVisual,isLarge:!0}:{renderSource:!0,renderVisual:!0,isLarge:!1}}function GA(e){return e.hasEmittedFirstToggle||!e.isLarge?!1:e.renderSource&&e.renderVisual}var KA=Dl(`ACTIVITY_MOUNT_LIMIT`,3);function qA(){return n(()=>import(`./SourceEditor-z66BI1TW.js`),__vite__mapDeps([83,1,37,2,38,39,11,40,41,42,43,44,45,46,47,15,16,13,7,17,18,10,3,48,49,33,12,6,4,50,51,52,20,53,54,55,56,30,31,32,57,58,59,60,61,62,84,21,82,78]),import.meta.url)}var JA=(0,Q.lazy)(async()=>({default:(await qA()).SourceEditor}));function YA(e,t,n){if(n<=0)return[];let r=e.filter(e=>!Ue(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 XA(e,t){return t.kind===`idle`?null:t.kind===`failed`&&t.failedDocNames.includes(e)?{kind:`failed`,title:Kc._({id:`MTs6g3`}),summary:t.reason===`clear-data-timeout`?Kc._({id:`Sc1bKE`,values:{docName:e}}):Kc._({id:`ovIGrT`,values:{docName:e}}),actionLabel:Kc._({id:`HpK_8d`})}:t.kind===`recovering`&&t.docNames.includes(e)?{kind:`recovering`,title:Kc._({id:`cF9DyA`}),summary:t.phase===`clearing-local-cache`?Kc._({id:`bmC18N`,values:{docName:e}}):Kc._({id:`pAgkuZ`,values:{docName:e}})}:null}function ZA(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(El,{name:`activity-pool`,children:(0,Z.jsx)(QA,{...e})}),t[0]=e,t[1]=n),n}function QA(e){let t=(0,$.c)(15),{activeDocName:n,isSourceMode:r,editorPlaceholder:i,previousDocName:a,onNavigateBack:o,onRecycle:s}=e,{poolEntries:c,serverRestartRecovery:l}=mt(),{pages:u,loading:d}=Xi(),f=YA(c,n,KA),p=(0,Q.useRef)(``),m=f.map($A).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)Qt(e);for(let e of i){let t=h.current.find(t=>t.docName===e)?.poolEventId;me(e,t&&t.length>0?t:crypto.randomUUID())}Tl(`ok/activity/mount-list-change`,{active:n,mounted:t,evicted:r}),p.current=m,H(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)(aj,{entry:e,isActive:e.docName===n,isSourceMode:r,editorPlaceholder:i,isNewDoc:!d&&!u.has(e.docName)&&!hr(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 $A(e){return e.docName}function ej(e){let t=(0,$.c)(8),{isActive:n,initialScrollTop:r,children:i}=e,a=(0,Q.useRef)(null),o=(0,Q.useRef)(r??0),s,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=a.current;if(!e)return;let t=()=>{e.scrollTop>0&&(o.current=e.scrollTop)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},c=[],t[0]=s,t[1]=c):(s=t[0],c=t[1]),(0,Q.useEffect)(s,c);let l,u;t[2]===n?(l=t[3],u=t[4]):(l=()=>{if(!n)return;let e=a.current;if(!e)return;let t=o.current;if(t===0)return;let r=performance.now(),i=!1;e.scrollTop=t,e.scrollTop===t&&e.scrollHeight>t&&Tl(`ok/scroll-restore/phase1-success`,{target:t,elapsedMs:performance.now()-r});let s=!1,c=0,l=()=>{s||(s=!0,cancelAnimationFrame(c),clearTimeout(f),e.removeEventListener(`wheel`,u),e.removeEventListener(`touchstart`,u))},u=()=>l();e.addEventListener(`wheel`,u,{passive:!0}),e.addEventListener(`touchstart`,u,{passive:!0});let d=()=>{s||(e.scrollTop!==t&&e.scrollHeight>t&&(e.scrollTop=t,e.scrollTop===t&&!i&&(Tl(`ok/scroll-restore/phase2-success`,{target:t,elapsedMs:performance.now()-r}),i=!0)),c=requestAnimationFrame(d))};c=requestAnimationFrame(d);let f=setTimeout(()=>{s||(e.scrollTop!==t&&e.scrollHeight>t&&Tl(`ok/scroll-restore/abandoned`,{target:t,elapsedMs:performance.now()-r,scrollHeight:e.scrollHeight,finalScrollTop:e.scrollTop}),l())},2e3);return l},u=[n],t[2]=n,t[3]=l,t[4]=u),(0,Q.useLayoutEffect)(l,u);let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d={overflowAnchor:`auto`},t[5]=d):d=t[5];let f;return t[6]===i?f=t[7]:(f=(0,Z.jsx)(`div`,{ref:a,"data-testid":`editor-scroll-container`,className:`editor-doc-scroll subtle-scrollbar h-full overflow-y-auto pt-14 scroll-pt-14`,style:d,children:i}),t[6]=i,t[7]=f),f}function tj(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)(Qb,{}),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)(JA,{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 nj(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)(ls,{className:`size-5`,"aria-hidden":`true`}):(0,Z.jsx)(ss,{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:rj,children:[(0,Z.jsx)(ls,{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 rj(){return window.location.reload()}function ij(e){let t=(0,$.c)(2),{html:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`tiptap-editor h-full pointer-events-none`,"aria-hidden":`true`,children:(0,Z.jsx)(`div`,{className:`tiptap ProseMirror tiptap-editor-portal-content`,dangerouslySetInnerHTML:{__html:n}})}),t[0]=n,t[1]=r),r}function aj(e){let t=(0,$.c)(53),{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a,isNewDoc:o,previousDocName:s,onNavigateBack:c,onRecycle:l,serverRestartRecovery:u}=e,d;t[0]!==n.docName||t[1]!==u?(d=XA(n.docName,u),t[0]=n.docName,t[1]=u,t[2]=d):d=t[2];let f=d,m=cw(n.docName)===`conflict`,h;t[3]===n.docName?h=t[4]:(h=()=>{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]=h);let[g]=(0,Q.useState)(h),_=n.provider.document.getText(`source`).length,[v,y]=(0,Q.useState)(i),[b,x]=(0,Q.useState)(!i),S,C;t[5]!==i||t[6]!==v||t[7]!==b?(S=()=>{i&&!v?y(!0):!i&&!b&&x(!0)},C=[i,v,b],t[5]=i,t[6]=v,t[7]=b,t[8]=S,t[9]=C):(S=t[8],C=t[9]),(0,Q.useEffect)(S,C);let w=WA({ytextLength:_,isSourceMode:i,visitedSource:v,visitedVisual:b}),T=(0,Q.useRef)(``),E=`${w.isLarge}-${w.renderSource}-${w.renderVisual}`,D,O;t[10]!==n.docName||t[11]!==w.isLarge||t[12]!==w.renderSource||t[13]!==w.renderVisual||t[14]!==E||t[15]!==i||t[16]!==_?(D=()=>{T.current!==E&&(T.current=E,w.isLarge&&Tl(`ok/activity/defer-mount`,{docName:n.docName,ytextLength:_,isSourceMode:i,renderSource:w.renderSource,renderVisual:w.renderVisual}))},O=[E,w.isLarge,w.renderSource,w.renderVisual,n.docName,_,i],t[10]=n.docName,t[11]=w.isLarge,t[12]=w.renderSource,t[13]=w.renderVisual,t[14]=E,t[15]=i,t[16]=_,t[17]=D,t[18]=O):(D=t[17],O=t[18]),(0,Q.useEffect)(D,O);let k;t[19]===n.docName?k=t[20]:(k=()=>B(n.docName),t[19]=n.docName,t[20]=k);let[A]=(0,Q.useState)(k),j=A?.html??null,[M,N]=(0,Q.useState)(!1),P,F;t[21]!==n.docName||t[22]!==w.isLarge||t[23]!==w.renderSource||t[24]!==w.renderVisual||t[25]!==M||t[26]!==i||t[27]!==_?(P=()=>{GA({isLarge:w.isLarge,renderSource:w.renderSource,renderVisual:w.renderVisual,hasEmittedFirstToggle:M})&&(Tl(`ok/cold/first-toggle`,{docName:n.docName,mountId:p(n.docName),ytextLength:_,modeEnteredFirst:i?`source`:`visual`}),N(!0))},F=[M,w.isLarge,w.renderSource,w.renderVisual,n.docName,_,i],t[21]=n.docName,t[22]=w.isLarge,t[23]=w.renderSource,t[24]=w.renderVisual,t[25]=M,t[26]=i,t[27]=_,t[28]=P,t[29]=F):(P=t[28],F=t[29]),(0,Q.useEffect)(P,F);let I=r?`visible`:`hidden`,L=`editor:${n.docName}`,R=A?.scrollTop,z;t[30]!==a||t[31]!==n||t[32]!==w.renderSource||t[33]!==w.renderVisual||t[34]!==r||t[35]!==m||t[36]!==o||t[37]!==i||t[38]!==c||t[39]!==l||t[40]!==g||t[41]!==s||t[42]!==f||t[43]!==j?(z=f?(0,Z.jsx)(nj,{view:f}):(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(LA,{activeDocName:n.docName,previousDocName:s,onNavigateBack:c,onRecycle:l,children:(0,Z.jsx)(Q.Suspense,{fallback:j?(0,Z.jsx)(ij,{html:j}):(0,Z.jsx)(Qb,{}),children:(0,Z.jsx)(kA,{docName:n.docName,provider:n.provider,children:m?(0,Z.jsx)(OA,{docName:n.docName,provider:n.provider}):(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[!i&&(hr(n.docName)||Wt(n.docName)?(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(HA,{docName:n.docName,provider:n.provider})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(zA,{provider:n.provider}),(0,Z.jsx)(Hi,{provider:n.provider})]})),(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[w.renderSource?(0,Z.jsx)(`div`,{className:i?`h-full`:`ok-mode-hidden h-full`,children:(0,Z.jsx)(tj,{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a})}):null,w.renderVisual?(0,Z.jsx)(`div`,{className:i?`ok-mode-hidden h-full`:`h-full`,children:(0,Z.jsx)(wO,{provider:n.provider,placeholder:a,isSourceMode:i,portalTarget:g},`${n.docName}-${String(o)}-${n.poolEventId}`)}):null]})]})})})})}),t[30]=a,t[31]=n,t[32]=w.renderSource,t[33]=w.renderVisual,t[34]=r,t[35]=m,t[36]=o,t[37]=i,t[38]=c,t[39]=l,t[40]=g,t[41]=s,t[42]=f,t[43]=j,t[44]=z):z=t[44];let V;t[45]!==r||t[46]!==R||t[47]!==z?(V=(0,Z.jsx)(ej,{isActive:r,initialScrollTop:R,children:z}),t[45]=r,t[46]=R,t[47]=z,t[48]=V):V=t[48];let H;return t[49]!==I||t[50]!==L||t[51]!==V?(H=(0,Z.jsx)(Q.Activity,{mode:I,name:L,children:V}),t[49]=I,t[50]=L,t[51]=V,t[52]=H):H=t[52],H}function oj(e){let t=e.endsWith(`rem`)?`rem`:`px`;return{value:Number.parseFloat(e),unit:t}}function sj(e){let{value:t,unit:n}=oj(e);return n===`rem`?t*16:t}function cj(e,t){return`${t===`rem`?e.toFixed(1):Math.round(e)}${t}`}var lj=3600*24*7;function uj(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?dj:m,O=g===void 0?lj: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 ee=sj(b),te;t[6]===x?te=t[7]:(te=sj(x),t[6]=x,t[7]=te);let ne=te,re;t[8]!==E||t[9]!==k?(re=function(e){E&&(P.current=!0,j.current=H.current?0:sj(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]=re):re=t[10];let ie=re,ae,oe;t[11]!==w||t[12]!==v||t[13]!==C||t[14]!==S||t[15]!==T||t[16]!==k||t[17]!==ne||t[18]!==ee||t[19]!==i||t[20]!==a||t[21]!==D||t[22]!==O||t[23]!==h?(ae=()=>{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}=oj(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<=ee*w;else if(e<=ee){let n=ee*(w-1);t=ee-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>ee*T){a();let t=n(r,M.current,j.current,s),c=Math.max(ee,Math.min(ne,t)),u=cj(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(ee,Math.min(ne,u)),f=cj(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)}},oe=[i,a,D,ee,ne,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]=ne,t[18]=ee,t[19]=i,t[20]=a,t[21]=D,t[22]=O,t[23]=h,t[24]=ae,t[25]=oe):(ae=t[24],oe=t[25]),(0,Q.useEffect)(ae,oe);let se;return t[26]===ie?se=t[27]:(se={dragRef:A,isDragging:N,handleMouseDown:ie},t[26]=ie,t[27]=se),se}function dj(){}var fj=3600*24*7,pj=`18rem`,mj=`3rem`,hj=`app-file-sidebar`,gj=`14.625rem`,_j=`32rem`,vj=`sidebar_width`,yj=/^\d+(?:\.\d+)?(?:rem|px)$/,bj=Q.createContext(null);function xj(e){if(typeof document>`u`)return e;let t=document.cookie.split(`; `).find(e=>e.startsWith(`${vj}=`))?.split(`=`)[1];if(!t)return e;let n;try{n=decodeURIComponent(t)}catch{return e}return yj.test(n)?n:e}function Sj(){let e=Q.use(bj);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function Cj(e){let t=(0,$.c)(58),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({open:i,onOpenChange:o,className:r,style:s,children:n,defaultWidth:c,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=c===void 0?pj:c,[u]=Q.useState(Tj),d;t[8]===u?d=t[9]:(d=()=>vw(u,window.innerWidth,`left`),t[8]=u,t[9]=d);let[f,p]=Q.useState(d),m;t[10]===l?m=t[11]:(m=()=>xj(l),t[10]=l,t[11]=m);let[h,g]=Q.useState(m),[_,v]=Q.useState(!1),[y,b]=Q.useState(!1),x;t[12]===u?x=t[13]:(x=()=>{let e=Tw();return Dw(`left`,vw(u,window.innerWidth,`left`),e)===`open`},t[12]=u,t[13]=x);let[S,C]=Q.useState(x),w=i??S,T;t[14]!==w||t[15]!==f||t[16]!==o?(T=e=>{let t=typeof e==`function`?e(w):e;o?o(t):C(t),Ow(`left`,f,t?`open`:`collapsed`)},t[14]=w,t[15]=f,t[16]=o,t[17]=T):T=t[17];let E=T,D;t[18]===E?D=t[19]:(D=function(){E(wj)},t[18]=E,t[19]=D);let O=D,k=Q.useRef(w),A;t[20]===w?A=t[21]:(A=()=>{k.current=w},t[20]=w,t[21]=A),Q.useLayoutEffect(A);let j;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(j=function(){window.innerWidth>=1024||k.current&&(window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||b(!0))},t[22]=j):j=t[22];let M=j,N,P;t[23]===u?(N=t[24],P=t[25]):(P=()=>{let e=window.matchMedia(`(min-width: ${hw}px)`),t=()=>{let e=vw(u,window.innerWidth,`left`);p(e),C(Dw(`left`,e,Tw())===`open`)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},N=[u],t[23]=u,t[24]=N,t[25]=P),Q.useEffect(P,N);let F,I;t[26]===w?(F=t[27],I=t[28]):(F=()=>{w||document.getElementById(hj)?.contains(document.activeElement)&&document.querySelector(`[data-sidebar="trigger"]`)?.focus()},I=[w],t[26]=w,t[27]=F,t[28]=I),Q.useLayoutEffect(F,I);let L,R;t[29]!==w||t[30]!==f||t[31]!==E?(L=()=>{if(f===`above`||!w)return;let e=e=>{e.key===`Escape`&&(document.querySelector(`[data-state="open"][role="dialog"], [data-state="open"][role="alertdialog"], [data-state="open"][role="menu"], [data-state="open"][role="listbox"], [data-radix-popper-content-wrapper] [data-state="open"]`)||E(!1))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},R=[f,w,E],t[29]=w,t[30]=f,t[31]=E,t[32]=L,t[33]=R):(L=t[32],R=t[33]),Q.useEffect(L,R);let z,B;t[34]===O?(z=t[35],B=t[36]):(z=()=>{if(typeof window<`u`&&window.okDesktop!=null)return;let e=e=>{Al(e,`toggle-files-sidebar`)&&(e.preventDefault(),O())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},B=[O],t[34]=O,t[35]=z,t[36]=B),Q.useEffect(z,B);let V=w?`expanded`:`collapsed`,H;t[37]!==_||t[38]!==w||t[39]!==E||t[40]!==y||t[41]!==V||t[42]!==O||t[43]!==h?(H={state:V,open:w,setOpen:E,toggleSidebar:O,width:h,setWidth:g,isDraggingRail:_,setIsDraggingRail:v,showPushPulse:y,setShowPushPulse:b,notifySidebarFileSelected:M},t[37]=_,t[38]=w,t[39]=E,t[40]=y,t[41]=V,t[42]=O,t[43]=h,t[44]=H):H=t[44];let U;t[45]!==s||t[46]!==h?(U={"--sidebar-width":h,"--sidebar-width-icon":mj,...s},t[45]=s,t[46]=h,t[47]=U):U=t[47];let W=U,G;t[48]===r?G=t[49]:(G=Y(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),t[48]=r,t[49]=G);let K;t[50]!==n||t[51]!==a||t[52]!==W||t[53]!==G?(K=(0,Z.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:W,className:G,...a,children:n}),t[50]=n,t[51]=a,t[52]=W,t[53]=G,t[54]=K):K=t[54];let ee;return t[55]!==H||t[56]!==K?(ee=(0,Z.jsx)(bj.Provider,{value:H,children:K}),t[55]=H,t[56]=K,t[57]=ee):ee=t[57],ee}function wj(e){return!e}function Tj(){return kr()}function Ej(e){let t=(0,$.c)(39),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,{_:d}=$t(),{state:f,isDraggingRail:p}=Sj();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}let m=f===`collapsed`?u:``,h=l===`floating`||l===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,g;t[14]===h?g=t[15]:(g=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`,h,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`),t[14]=h,t[15]=g);let _;t[16]===g?_=t[17]:(_=(0,Z.jsx)(`div`,{"data-slot":`sidebar-gap`,className:g}),t[16]=g,t[17]=_);let v;t[18]===d?v=t[19]:(v=d({id:`07q4Qk`}),t[18]=d,t[19]=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[20]!==r||t[21]!==y?(b=Y(`fixed inset-y-0 z-10 flex h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear motion-reduce:transition-none motion-reduce:duration-0 data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]`,y,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`,r),t[20]=r,t[21]=y,t[22]=b):b=t[22];let x;t[23]===n?x=t[24]:(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[23]=n,t[24]=x);let S;t[25]!==i||t[26]!==c||t[27]!==b||t[28]!==x||t[29]!==v?(S=(0,Z.jsx)(`nav`,{id:hj,"aria-label":v,"data-slot":`sidebar-container`,"data-side":c,className:b,...i,children:x}),t[25]=i,t[26]=c,t[27]=b,t[28]=x,t[29]=v,t[30]=S):S=t[30];let C;return t[31]!==p||t[32]!==c||t[33]!==f||t[34]!==S||t[35]!==m||t[36]!==_||t[37]!==l?(C=(0,Z.jsxs)(`div`,{className:`group peer text-sidebar-foreground`,"data-state":f,"data-collapsible":m,"data-variant":l,"data-side":c,"data-slot":`sidebar`,"data-dragging":p,children:[_,S]}),t[31]=p,t[32]=c,t[33]=f,t[34]=S,t[35]=m,t[36]=_,t[37]=l,t[38]=C):C=t[38],C}function Dj(e){let t=(0,$.c)(34),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{_:a}=$t(),{toggleSidebar:o,state:s}=Sj(),c,l,u,d,p,m,h,g;if(t[4]!==a||t[5]!==s){let e=jl(`toggle-files-sidebar`);c=X,l=`trigger`,u=`sidebar-trigger`,d=`ghost`,p=`icon-sm`,m=s===`expanded`,h=hj,g=a(s===`expanded`?{id:`4PYsOz`,values:{sidebarShortcutLabel:e}}:{id:`jbSG8V`,values:{sidebarShortcutLabel:e}}),t[4]=a,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=p,t[11]=m,t[12]=h,t[13]=g}else c=t[6],l=t[7],u=t[8],d=t[9],p=t[10],m=t[11],h=t[12],g=t[13];let _;t[14]===n?_=t[15]:(_=Y(n),t[14]=n,t[15]=_);let v;t[16]!==r||t[17]!==o?(v=e=>{r?.(e),o()},t[16]=r,t[17]=o,t[18]=v):v=t[18];let y;t[19]===s?y=t[20]:(y=s===`expanded`?(0,Z.jsx)(f,{}):(0,Z.jsx)(af,{}),t[19]=s,t[20]=y);let b;return t[21]!==c||t[22]!==i||t[23]!==l||t[24]!==y||t[25]!==u||t[26]!==d||t[27]!==p||t[28]!==m||t[29]!==h||t[30]!==g||t[31]!==_||t[32]!==v?(b=(0,Z.jsx)(c,{"data-sidebar":l,"data-slot":u,variant:d,size:p,"aria-expanded":m,"aria-controls":h,"aria-label":g,className:_,onClick:v,...i,children:y}),t[21]=c,t[22]=i,t[23]=l,t[24]=y,t[25]=u,t[26]=d,t[27]=p,t[28]=m,t[29]=h,t[30]=g,t[31]=_,t[32]=v,t[33]=b):b=t[33],b}function Oj(e){let t=(0,$.c)(32),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,{_:l}=$t(),{toggleSidebar:u,setWidth:d,state:f,width:p,setIsDraggingRail:m}=Sj(),h=f===`collapsed`,g;t[6]!==s||t[7]!==c||t[8]!==m||t[9]!==d||t[10]!==h||t[11]!==u||t[12]!==p?(g={direction:`right`,enableDrag:s,enableToggle:c,onResize:d,onToggle:u,currentWidth:p,isCollapsed:h,minResizeWidth:gj,maxResizeWidth:_j,setIsDraggingRail:m,widthCookieName:vj,widthCookieMaxAge:fj},t[6]=s,t[7]=c,t[8]=m,t[9]=d,t[10]=h,t[11]=u,t[12]=p,t[13]=g):g=t[13];let{dragRef:_,handleMouseDown:v}=uj(g),y;t[14]!==l||t[15]!==f?(y=l(f===`expanded`?{id:`w3vFfL`}:{id:`e8zRrb`}),t[14]=l,t[15]=f,t[16]=y):y=t[16];let b;t[17]!==v||t[18]!==r?(b=e=>{r?.(e),e.defaultPrevented||v(e)},t[17]=v,t[18]=r,t[19]=b):b=t[19];let x;t[20]!==l||t[21]!==f?(x=l(f===`expanded`?{id:`w3vFfL`}:{id:`e8zRrb`}),t[20]=l,t[21]=f,t[22]=x):x=t[22];let S;t[23]===n?S=t[24]:(S=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[23]=n,t[24]=S);let C;return t[25]!==_||t[26]!==i||t[27]!==y||t[28]!==b||t[29]!==x||t[30]!==S?(C=(0,Z.jsx)(`button`,{ref:_,"data-sidebar":`rail`,"data-slot":`sidebar-rail`,"aria-label":y,tabIndex:-1,onMouseDown:b,title:x,className:S,...i}),t[25]=_,t[26]=i,t[27]=y,t[28]=b,t[29]=x,t[30]=S,t[31]=C):C=t[31],C}function kj(e){let t=(0,$.c)(14),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,onAnimationEnd:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let{showPushPulse:a,setShowPushPulse:o}=Sj(),s;t[4]!==r||t[5]!==o?(s=e=>{r?.(e),e.animationName===`sidebar-push-pulse`&&o(!1)},t[4]=r,t[5]=o,t[6]=s):s=t[6];let c=s,l=a?``:void 0,u;t[7]===n?u=t[8]:(u=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`,n),t[7]=n,t[8]=u);let d;return t[9]!==c||t[10]!==i||t[11]!==l||t[12]!==u?(d=(0,Z.jsx)(`main`,{"data-slot":`sidebar-inset`,"data-push-pulse":l,onAnimationEnd:c,className:u,...i}),t[9]=c,t[10]=i,t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function Aj(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 jj(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 Mj(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 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(`relative flex w-full min-w-0 flex-col 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-group`,"data-sidebar":`group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Pj(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,asChild:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i?gi:`div`,o;t[4]===n?o=t[5]:(o=Y(`flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0`,n),t[4]=n,t[5]=o);let s;return t[6]!==a||t[7]!==r||t[8]!==o?(s=(0,Z.jsx)(a,{"data-slot":`sidebar-group-label`,"data-sidebar":`group-label`,className:o,...r}),t[6]=a,t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function Fj(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,asChild:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i?gi:`button`,o;t[4]===n?o=t[5]:(o=Y(`absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0`,n),t[4]=n,t[5]=o);let s;return t[6]!==a||t[7]!==r||t[8]!==o?(s=(0,Z.jsx)(a,{"data-slot":`sidebar-group-action`,"data-sidebar":`group-action`,className:o,...r}),t[6]=a,t[7]=r,t[8]=o,t[9]=s):s=t[9],s}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(`w-full text-sm`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`sidebar-group-content`,"data-sidebar":`group-content`,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(`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 Rj(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 zj=_i(`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 Bj(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?gi:`button`,{state:m}=Sj(),h;t[8]!==n||t[9]!==f||t[10]!==d?(h=Y(zj({variant:d,size:f}),n),t[8]=n,t[9]=f,t[10]=d,t[11]=h):h=t[11];let g;t[12]!==p||t[13]!==u||t[14]!==r||t[15]!==f||t[16]!==h?(g=(0,Z.jsx)(p,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":f,"data-active":u,className:h,...r}),t[12]=p,t[13]=u,t[14]=r,t[15]=f,t[16]=h,t[17]=g):g=t[17];let _=g;if(!c)return _;if(typeof c==`string`){let e;t[18]===c?e=t[19]:(e={children:c},t[18]=c,t[19]=e),c=e}let v;t[20]===_?v=t[21]:(v=(0,Z.jsx)(Ms,{asChild:!0,children:_}),t[20]=_,t[21]=v);let y=m!==`collapsed`,b;t[22]!==y||t[23]!==c?(b=(0,Z.jsx)(Ns,{side:`right`,align:`center`,hidden:y,...c}),t[22]=y,t[23]=c,t[24]=b):b=t[24];let x;return t[25]!==v||t[26]!==b?(x=(0,Z.jsxs)(Fs,{children:[v,b]}),t[25]=v,t[26]=b,t[27]=x):x=t[27],x}function Vj(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,asChild:i,showOnHover:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?!1:i,s=a===void 0?!1:a,c=o?gi:`button`,l=s&&`group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0`,u;t[5]!==n||t[6]!==l?(u=Y(`absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0`,l,n),t[5]=n,t[6]=l,t[7]=u):u=t[7];let d;return t[8]!==c||t[9]!==r||t[10]!==u?(d=(0,Z.jsx)(c,{"data-slot":`sidebar-menu-action`,"data-sidebar":`menu-action`,className:u,...r}),t[8]=c,t[9]=r,t[10]=u,t[11]=d):d=t[11],d}function Hj(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-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden`,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-sub`,"data-sidebar":`menu-sub`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Uj(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-sub-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-sub-item`,"data-sidebar":`menu-sub-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Wj(e){let t=(0,$.c)(14),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({asChild:i,size:a,isActive:o,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=i===void 0?!1:i,c=a===void 0?`md`:a,l=o===void 0?!1:o,u=s?gi:`a`,d;t[6]===n?d=t[7]:(d=Y(`flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden 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-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground data-active:hover:bg-sidebar-accent [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground`,n),t[6]=n,t[7]=d);let f;return t[8]!==u||t[9]!==l||t[10]!==r||t[11]!==c||t[12]!==d?(f=(0,Z.jsx)(u,{"data-slot":`sidebar-menu-sub-button`,"data-sidebar":`menu-sub-button`,"data-size":c,"data-active":l,className:d,...r}),t[8]=u,t[9]=l,t[10]=r,t[11]=c,t[12]=d,t[13]=f):f=t[13],f}function Gj(e){let t=null,n=!1,r=new Set;function i(e){if(e!==t){t=e;for(let e of r)e()}}e.subscribeToEvent(i);async function a(){if(!n){n=!0;try{i(await e.fetchBranch())}catch{}}}return{getSnapshot:()=>t,subscribe(e){return r.add(e),a(),()=>{r.delete(e)}}}}async function Kj(){let e=await fetch(`/api/server-info`,{signal:AbortSignal.timeout(5e3)});if(!e.ok)return null;let t=await e.json(),n=Wr.safeParse(t);return n.success?n.data.currentBranch??null:null}var qj=typeof window>`u`?{getSnapshot:()=>null,subscribe:()=>()=>{}}:Gj({fetchBranch:Kj,subscribeToEvent:Wc}),Jj=qj.subscribe,Yj=qj.getSnapshot;function Xj(){return(0,Q.useSyncExternalStore)(Jj,Yj,Yj)}function Zj(){let e=(0,$.c)(6),t=Xj(),n=ta(),{state:r}=Sj(),i=typeof window<`u`?window.okDesktop:void 0;if(i&&r===`expanded`)return null;let a;e[0]===n?a=e[1]:(a=i?.config.projectName??(n&&za(n.contentDir)||null),e[0]=n,e[1]=a);let o=a,s=i?.config.projectPath??n?.contentDir??null;if(o===null&&t===null)return null;let c;return e[2]!==t||e[3]!==o||e[4]!==s?(c={projectName:o,projectPath:s,branch:t},e[2]=t,e[3]=o,e[4]=s,e[5]=c):c=e[5],c}function Qj(e){let t=(0,$.c)(30),{stats:n,selectionStats:r,showStats:i,composerBadge:a,reserveRightGutter:o}=e,s=i===void 0?!0:i,c=o===void 0?!1:o,{_:l}=$t(),u=Zj();if(!s&&u===null&&a==null)return null;let d=r??n,f=r!=null,{words:p,chars:m,tokens:h}=d,g;t[0]!==l||t[1]!==f||t[2]!==s?(g=l(s?f?{id:`Bv5a9_`}:{id:`L1ZE3M`}:{id:`goO4Ll`}),t[0]=l,t[1]=f,t[2]=s,t[3]=g):g=t[3];let _=c&&`pr-12`,v;t[4]===_?v=t[5]:(v=Y(`relative flex h-6 shrink-0 items-center justify-between gap-3 bg-background px-3 text-2xs text-muted-foreground`,_),t[4]=_,t[5]=v);let y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=(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[6]=y):y=t[6];let b;t[7]!==l||t[8]!==a?(b=a?(0,Z.jsxs)(X,{type:`button`,variant:`outline`,onClick:a.onReopen,"data-testid":`ask-ai-reopen-badge`,className:`-translate-x-1/2 absolute bottom-0 left-1/2 z-10 h-auto gap-1 rounded-md rounded-b-none bg-card px-2.5 py-0.5 text-2xs font-normal text-muted-foreground shadow-sm hover:text-foreground active:not-aria-[haspopup]:translate-y-0`,children:[(0,Z.jsx)(us,{className:`size-3`,"aria-hidden":!0}),l({id:`xWEvuo`}),(0,Z.jsx)(bt,{className:`size-3`,"aria-hidden":!0})]}):null,t[7]=l,t[8]=a,t[9]=b):b=t[9];let x;t[10]===u?x=t[11]:(x=u===null?null:(0,Z.jsx)($j,{identity:u}),t[10]=u,t[11]=x);let S;t[12]===x?S=t[13]:(S=(0,Z.jsx)(`span`,{className:`flex min-w-0 items-center gap-3`,children:x}),t[12]=x,t[13]=S);let C;t[14]!==l||t[15]!==d.chars||t[16]!==d.tokens||t[17]!==d.words||t[18]!==m||t[19]!==f||t[20]!==s||t[21]!==h||t[22]!==p?(C=s?(0,Z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-3`,children:[f?(0,Z.jsx)(`span`,{className:`font-medium text-foreground/70`,"data-testid":`editor-footer-selected-label`,children:l({id:`ylXj1N`})}):null,(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`tabular-nums`,children:d.words.toLocaleString()}),` `,(0,Z.jsx)(J,{id:`gljvbT`,values:{words:p}})]}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`tabular-nums`,children:d.chars.toLocaleString()}),` `,(0,Z.jsx)(J,{id:`d5rK4X`,values:{chars:m}})]}),(0,Z.jsxs)(`span`,{children:[d.tokens>0?`~`:``,(0,Z.jsx)(`span`,{className:`tabular-nums`,children:d.tokens.toLocaleString()}),` `,(0,Z.jsx)(J,{id:`uynXup`,values:{tokens:h}})]})]}):null,t[14]=l,t[15]=d.chars,t[16]=d.tokens,t[17]=d.words,t[18]=m,t[19]=f,t[20]=s,t[21]=h,t[22]=p,t[23]=C):C=t[23];let w;return t[24]!==C||t[25]!==g||t[26]!==v||t[27]!==b||t[28]!==S?(w=(0,Z.jsxs)(`section`,{"aria-label":g,className:v,children:[y,b,S,C]}),t[24]=C,t[25]=g,t[26]=v,t[27]=b,t[28]=S,t[29]=w):w=t[29],w}function $j(e){let t=(0,$.c)(8),{identity:n}=e,{projectName:r,projectPath:i,branch:a}=n,o;t[0]!==r||t[1]!==i?(o=r===null?null:i?(0,Z.jsxs)(Fs,{children:[(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(`span`,{tabIndex:0,className:`truncate`,"data-testid":`editor-footer-project-name`,children:r})}),(0,Z.jsx)(Ns,{side:`top`,className:`max-w-xs break-all`,children:i})]}):(0,Z.jsx)(`span`,{className:`truncate`,"data-testid":`editor-footer-project-name`,children:r}),t[0]=r,t[1]=i,t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=a===null?null:(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,"data-testid":`editor-footer-branch`,children:[(0,Z.jsx)(Vo,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:a})]}),t[3]=a,t[4]=s);let c;return t[5]!==o||t[6]!==s?(c=(0,Z.jsxs)(Z.Fragment,{children:[o,s]}),t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function eM(e){let t=(0,$.c)(11),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{_:i}=$t(),a;t[3]===i?a=t[4]:(a=i({id:`3__SjS`}),t[3]=i,t[4]=a);let o;t[5]===n?o=t[6]:(o=Y(n),t[5]=n,t[6]=o);let s;return t[7]!==r||t[8]!==a||t[9]!==o?(s=(0,Z.jsx)(`nav`,{"aria-label":a,"data-slot":`breadcrumb`,className:o,...r}),t[7]=r,t[8]=a,t[9]=o,t[10]=s):s=t[10],s}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 flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`ol`,{"data-slot":`breadcrumb-list`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function nM(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Y(`inline-flex items-center gap-1`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`li`,{"data-slot":`breadcrumb-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function rM(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({current:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0||i?`page`:void 0,o;t[4]===n?o=t[5]:(o=Y(`font-normal text-foreground`,n),t[4]=n,t[5]=o);let s;return t[6]!==r||t[7]!==a||t[8]!==o?(s=(0,Z.jsx)(`span`,{"data-slot":`breadcrumb-page`,"aria-current":a,className:o,...r}),t[6]=r,t[7]=a,t[8]=o,t[9]=s):s=t[9],s}function iM(e){let t=(0,$.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({children:n,className:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=Y(`[&>svg]:size-3.5`,r),t[4]=r,t[5]=a);let o;t[6]===n?o=t[7]:(o=n??(0,Z.jsx)(qi,{}),t[6]=n,t[7]=o);let s;return t[8]!==i||t[9]!==a||t[10]!==o?(s=(0,Z.jsx)(`li`,{"data-slot":`breadcrumb-separator`,role:`presentation`,"aria-hidden":`true`,className:a,...i,children:o}),t[8]=i,t[9]=a,t[10]=o,t[11]=s):s=t[11],s}var aM=1,oM=2,sM=4;function cM(e){let t=(0,$.c)(18),{docName:n,className:r}=e;if(!n)return null;let i,a,o,s,c,l;if(t[0]!==r||t[1]!==n){l=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Xr(n),u=e?e.kind===`template`?e.folder.split(`/`).filter(Boolean):[]:h(n,``).prefix.replace(/\/$/,``).split(`/`).filter(Boolean);if(u.length===0){l=null;break bb0}let d=(e,t)=>({kind:`segment`,value:e,key:u.slice(0,t+1).join(`/`)}),f=u.length>sM?[...u.slice(0,aM).map((e,t)=>d(e,t)),{kind:`ellipsis`,hidden:u.slice(aM,-oM)},...u.slice(-oM).map((e,t)=>d(e,u.length-oM+t))]:u.map((e,t)=>d(e,t));a=eM,t[8]===r?c=t[9]:(c=Y(`flex min-w-0 items-center`,r),t[8]=r,t[9]=c),i=tM,o=`min-w-0 flex-nowrap gap-1 overflow-hidden text-muted-foreground/70 text-xs`,s=f.map(lM)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7];if(l!==Symbol.for(`react.early_return_sentinel`))return l;let u;t[10]!==i||t[11]!==o||t[12]!==s?(u=(0,Z.jsx)(i,{className:o,children:s}),t[10]=i,t[11]=o,t[12]=s,t[13]=u):u=t[13];let d;return t[14]!==a||t[15]!==c||t[16]!==u?(d=(0,Z.jsx)(a,{className:c,children:u}),t[14]=a,t[15]=c,t[16]=u,t[17]=d):d=t[17],d}function lM(e,t){let n=e.kind===`segment`?e.key:`ellipsis`;return(0,Z.jsxs)(Q.Fragment,{children:[t>0&&(0,Z.jsx)(iM,{className:`shrink-0 text-muted-foreground/70 [&>svg]:size-3`}),e.kind===`ellipsis`?(0,Z.jsxs)(nM,{className:`shrink-0`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,title:e.hidden.join(` / `),className:`flex size-4 items-center justify-center text-muted-foreground/70`,children:(0,Z.jsx)(Ad,{className:`size-3.5`})}),(0,Z.jsx)(`span`,{className:`sr-only`,children:e.hidden.join(` / `)})]}):(0,Z.jsx)(nM,{className:`min-w-0`,children:(0,Z.jsx)(rM,{current:!1,className:`min-w-0 truncate font-normal text-muted-foreground/70`,title:e.value,children:e.value})})]},n)}var uM={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`},dM=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`,...uM,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},fM=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)(dM,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},pM=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)(dM,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i};function mM(e){let t=(0,$.c)(29),{isSourceMode:n,onModeChange:r,sourceDisabled:i}=e,a=i===void 0?!1:i,{_:o}=$t(),s=n?`source`:`wysiwyg`,c;t[0]===r?c=t[1]:(c=e=>{e&&r(e)},t[0]=r,t[1]=c);let l;t[2]===o?l=t[3]:(l=o({id:`n7aopT`}),t[2]=o,t[3]=l);let u;t[4]===o?u=t[5]:(u=o({id:`ur2XSb`}),t[4]=o,t[5]=u);let d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(Ms,{children:(0,Z.jsx)(pM,{className:`size-4`})}),t[6]=d):d=t[6];let f;t[7]===u?f=t[8]:(f=(0,Z.jsx)(ji,{value:`wysiwyg`,"aria-label":u,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,asChild:!0,children:d}),t[7]=u,t[8]=f);let p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(Ns,{side:`bottom`,children:(0,Z.jsx)(J,{id:`Mb_20S`})}),t[9]=p):p=t[9];let m;t[10]===f?m=t[11]:(m=(0,Z.jsxs)(Fs,{children:[f,p]}),t[10]=f,t[11]=m);let h;t[12]===o?h=t[13]:(h=o({id:`xbdtfY`}),t[12]=o,t[13]=h);let g;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(fM,{className:`size-4`}),t[14]=g):g=t[14];let _;t[15]!==a||t[16]!==h?(_=(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(`div`,{children:(0,Z.jsx)(ji,{value:`source`,"aria-label":h,disabled:a,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,children:g})})}),t[15]=a,t[16]=h,t[17]=_):_=t[17];let v;t[18]===a?v=t[19]:(v=(0,Z.jsx)(Ns,{side:`bottom`,children:a?(0,Z.jsx)(J,{id:`G-JBA1`}):(0,Z.jsx)(J,{id:`u6Hp4N`})}),t[18]=a,t[19]=v);let y;t[20]!==_||t[21]!==v?(y=(0,Z.jsxs)(Fs,{children:[_,v]}),t[20]=_,t[21]=v,t[22]=y):y=t[22];let b;return t[23]!==y||t[24]!==s||t[25]!==c||t[26]!==l||t[27]!==m?(b=(0,Z.jsxs)(Ni,{type:`single`,value:s,onValueChange:c,"aria-label":l,variant:`segmented`,size:`sm`,spacing:1,className:`shrink-0 bg-muted p-0.5 data-[size=sm]:rounded-[10px]`,children:[m,y]}),t[23]=y,t[24]=s,t[25]=c,t[26]=l,t[27]=m,t[28]=b):b=t[28],b}var hM=(0,Q.lazy)(async()=>({default:(await n(async()=>{let{SkillEditorActions:e}=await import(`./SkillEditorActions-zGJNqarO.js`);return{SkillEditorActions:e}},__vite__mapDeps([85,1,10,3,11,6,7,13,70,15,16,17,18,12,51,52,19,54,56,55,75,71,57,49,59,76,64,33,61]),import.meta.url)).SkillEditorActions}));function gM(e){let t=(0,$.c)(82),{activeDocName:n,isSourceMode:r,sourceDisabled:i,onModeChange:a,showAddPropertyButton:o,onAddProperty:s,isPanelCollapsed:c,onTogglePanel:l,reserveRightGutter:u}=e,d=u===void 0?!1:u,{_:f}=$t(),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=kl(`toggle-document-panel`),t[0]=p):p=t[0];let m=p,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k;if(t[1]!==f||t[2]!==n||t[3]!==c||t[4]!==r||t[5]!==s||t[6]!==a||t[7]!==l||t[8]!==d||t[9]!==o||t[10]!==i){let e=jl(`toggle-document-panel`),u;t[26]===n?u=t[27]:(u=n?Xr(n):null,t[26]=n,t[27]=u);let p=u,m;t[28]===n?m=t[29]:(m=n?Wt(n):null,t[28]=n,t[29]=m);let A=m,j;t[30]!==p||t[31]!==A?(j=p?.kind===`skill`?{scope:p.scope,name:p.name}:A?{scope:`project`,name:A}:null,t[30]=p,t[31]=A,t[32]=j):j=t[32];let M=j;b=`editor-toolbar`,x=`pointer-events-none absolute inset-x-0 top-0 z-10`;let N;t[33]!==n||t[34]!==M?(N=M?null:(0,Z.jsx)(cM,{docName:n}),t[33]=n,t[34]=M,t[35]=N):N=t[35];let P;t[36]===N?P=t[37]:(P=(0,Z.jsx)(`div`,{className:`pointer-events-auto flex min-w-0 items-center`,children:N}),t[36]=N,t[37]=P);let F;t[38]!==r||t[39]!==a||t[40]!==i?(F=(0,Z.jsx)(`div`,{className:`pointer-events-auto flex justify-center`,children:(0,Z.jsx)(mM,{isSourceMode:r,onModeChange:a,sourceDisabled:i})}),t[38]=r,t[39]=a,t[40]=i,t[41]=F):F=t[41],t[42]!==P||t[43]!==F?(S=(0,Z.jsx)(`div`,{className:`editor-content-aligned bg-background py-2`,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 items-center`,children:[P,F]})}),t[42]=P,t[43]=F,t[44]=S):S=t[44];let I=d&&`pr-9`;t[45]===I?_=t[46]:(_=Y(`pointer-events-auto absolute top-0 right-0 flex items-center justify-end gap-1 py-2 pr-2`,I),t[45]=I,t[46]=_),t[47]===M?v=t[48]:(v=M?(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(hM,{scope:M.scope,name:M.name})}):null,t[47]=M,t[48]=v),t[49]!==f||t[50]!==s||t[51]!==o?(y=o&&(0,Z.jsxs)(Fs,{children:[(0,Z.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":f({id:`81H_23`}),onClick:s,"data-testid":`add-properties-button`,asChild:!0,children:(0,Z.jsx)(Ms,{children:(0,Z.jsx)(Yd,{})})}),(0,Z.jsx)(Ns,{side:`bottom`,children:(0,Z.jsx)(J,{id:`81H_23`})})]}),t[49]=f,t[50]=s,t[51]=o,t[52]=y):y=t[52],g=Fs,h=X,C=``,w=`ghost`,T=`icon`,E=l,D=!c,O=`doc-panel`,k=f(c?{id:`u7H-Wn`,values:{panelShortcutLabel:e}}:{id:`2hpdRq`,values:{panelShortcutLabel:e}}),t[1]=f,t[2]=n,t[3]=c,t[4]=r,t[5]=s,t[6]=a,t[7]=l,t[8]=d,t[9]=o,t[10]=i,t[11]=h,t[12]=g,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,t[23]=D,t[24]=O,t[25]=k}else h=t[11],g=t[12],_=t[13],v=t[14],y=t[15],b=t[16],x=t[17],S=t[18],C=t[19],w=t[20],T=t[21],E=t[22],D=t[23],O=t[24],k=t[25];let A;t[53]===c?A=t[54]:(A=(0,Z.jsx)(Ms,{children:c?(0,Z.jsx)(sf,{}):(0,Z.jsx)(of,{})}),t[53]=c,t[54]=A);let j;t[55]!==h||t[56]!==A||t[57]!==C||t[58]!==w||t[59]!==T||t[60]!==E||t[61]!==D||t[62]!==O||t[63]!==k?(j=(0,Z.jsx)(h,{"data-doc-panel-toggle":C,variant:w,size:T,onClick:E,"aria-expanded":D,"aria-controls":O,"aria-label":k,asChild:!0,children:A}),t[55]=h,t[56]=A,t[57]=C,t[58]=w,t[59]=T,t[60]=E,t[61]=D,t[62]=O,t[63]=k,t[64]=j):j=t[64];let M;t[65]===c?M=t[66]:(M=(0,Z.jsx)(Ns,{side:`bottom`,children:c?(0,Z.jsx)(J,{id:`KFdXwz`,values:{panelShortcut:m}}):(0,Z.jsx)(J,{id:`MsuXaI`,values:{panelShortcut:m}})}),t[65]=c,t[66]=M);let N;t[67]!==g||t[68]!==j||t[69]!==M?(N=(0,Z.jsxs)(g,{children:[j,M]}),t[67]=g,t[68]=j,t[69]=M,t[70]=N):N=t[70];let P;t[71]!==_||t[72]!==v||t[73]!==y||t[74]!==N?(P=(0,Z.jsxs)(`div`,{className:_,children:[v,y,N]}),t[71]=_,t[72]=v,t[73]=y,t[74]=N,t[75]=P):P=t[75];let F;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none h-2 bg-linear-to-b from-background to-transparent`}),t[76]=F):F=t[76];let I;return t[77]!==b||t[78]!==x||t[79]!==S||t[80]!==P?(I=(0,Z.jsxs)(`div`,{"data-testid":b,className:x,children:[S,P,F]}),t[77]=b,t[78]=x,t[79]=S,t[80]=P,t[81]=I):I=t[81],I}function _M(e){let{activeDocName:t,deferredActiveDocName:n,mountResolved:r,syncResolved:i}=e;return t===null||t===n?!1:!(r&&i)}function vM(e){let{currentLayout:t,containerPx:n,pinnedPx:r,residualId:i}=e;if(n<=0||!(i in t))return t;let a={...t},o=0;for(let[e,i]of Object.entries(r)){if(!(e in t))continue;let r=i/n*100;a[e]=r,o+=r}let s=0;for(let[e,n]of Object.entries(t))e===i||e in r||(s+=n);let c=100-o-s;return c<0?t:(a[i]=c,a)}var yM=`ok-terminal-height-v1`,bM=1/3,xM=.5;function SM(e){return Math.max(120,Math.round((Number.isFinite(e)?e:0)*xM))}function CM(e){let t=Number.isFinite(e)?e:0;return t<=0?240:Math.round(t*bM)}function wM(e,t){let n=SM(t);return Number.isFinite(e)?e<120?120:e>n?n:Math.round(e):Math.min(CM(t),n)}function TM(){return typeof window>`u`?0:window.innerHeight}function EM(e,t){try{let n=e??localStorage,r=t??TM(),i=n.getItem(yM);if(i==null)return wM(CM(r),r);let a=Number.parseInt(i,10);return wM(Number.isFinite(a)?a:CM(r),r)}catch{return 240}}function DM(e,t,n){try{let r=t??localStorage,i=n??TM();r.setItem(yM,String(wM(e,i)))}catch{}}function OM(){try{return typeof localStorage>`u`?240:EM()}catch{return 240}}function kM(e){let t=(0,$.c)(19),{dockPosition:n,onReveal:r,className:i}=e,{_:a}=$t(),o=n===`right`,s;t[0]===a?s=t[1]:(s=a({id:`0SBTff`}),t[0]=a,t[1]=s);let c=s,l=o?`rounded-r-none border-r-0`:`rounded-b-none border-b-0`,u;t[2]!==i||t[3]!==l?(u=Y(`absolute z-20 shrink-0 bg-background text-muted-foreground shadow-sm hover:text-foreground`,l,i),t[2]=i,t[3]=l,t[4]=u):u=t[4];let d;t[5]===o?d=t[6]:(d=o?(0,Z.jsx)(Ki,{"aria-hidden":`true`}):(0,Z.jsx)(bt,{"aria-hidden":`true`}),t[5]=o,t[6]=d);let f;t[7]!==n||t[8]!==c||t[9]!==r||t[10]!==u||t[11]!==d?(f=(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(X,{type:`button`,variant:`outline`,size:`icon-sm`,"aria-label":c,"data-terminal-reveal":n,onClick:r,className:u,children:d})}),t[7]=n,t[8]=c,t[9]=r,t[10]=u,t[11]=d,t[12]=f):f=t[12];let p=o?`left`:`top`,m;t[13]!==c||t[14]!==p?(m=(0,Z.jsx)(Ns,{side:p,sideOffset:8,children:c}),t[13]=c,t[14]=p,t[15]=m):m=t[15];let h;return t[16]!==f||t[17]!==m?(h=(0,Z.jsxs)(Fs,{children:[f,m]}),t[16]=f,t[17]=m,t[18]=h):h=t[18],h}var AM=`terminal-dock-panel`;function jM(e){let t=(0,$.c)(44),{children:n,visible:r,onVisibleChange:i,dockPosition:a,onBottomContainer:o,onEditorRegion:s,onReveal:c}=e,l=a===void 0?`bottom`:a,{resolvedTheme:u}=Mn(),d=Ib(),[f,p]=(0,Q.useState)(!r),m;t[0]===u?m=t[1]:(m=wu(u),t[0]=u,t[1]=m);let h=m.background,g=r&&l===`bottom`,_=!r&&l===`bottom`&&c!=null,[v]=(0,Q.useState)(MM),y=(0,Q.useRef)(v),[b,x]=(0,Q.useState)(!1),S=(0,Q.useRef)(!1),C=(0,Q.useRef)(null),w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=function(e){C.current!=null&&clearTimeout(C.current),C.current=setTimeout(()=>{DM(e),C.current=null},100)},t[2]=w):w=t[2];let T=w,E=(0,Q.useRef)(null),D,O;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(D=()=>()=>{C.current!=null&&clearTimeout(C.current),E.current!=null&&(window.removeEventListener(`pointerup`,E.current),E.current=null)},O=[],t[3]=D,t[4]=O):(D=t[3],O=t[4]),(0,Q.useEffect)(D,O);let k,A;t[5]!==g||t[6]!==d?(k=()=>{let e=d.current;e!=null&&(g?e.resize(`${y.current}px`):e.collapse())},A=[g,d],t[5]=g,t[6]=d,t[7]=k,t[8]=A):(k=t[7],A=t[8]),(0,Q.useEffect)(k,A);let j=b||void 0,M;t[9]!==c||t[10]!==_?(M=_&&c?(0,Z.jsx)(kM,{dockPosition:`bottom`,onReveal:c,className:`right-3 bottom-0`}):null,t[9]=c,t[10]=_,t[11]=M):M=t[11];let N;t[12]!==n||t[13]!==s||t[14]!==M?(N=(0,Z.jsx)(LC,{minSize:`5%`,className:`flex min-h-0 flex-col`,children:(0,Z.jsxs)(`div`,{ref:s,tabIndex:-1,className:`relative flex h-full min-h-0 flex-col outline-none`,children:[n,M]})}),t[12]=n,t[13]=s,t[14]=M,t[15]=N):N=t[15];let P=!g,F;t[16]===g?F=t[17]:(F=()=>{if(!g)return;x(!0),S.current=!0;let e=()=>{x(!1),S.current=!1,window.removeEventListener(`pointerup`,e),E.current=null};E.current=e,window.addEventListener(`pointerup`,e)},t[16]=g,t[17]=F);let I;t[18]!==g||t[19]!==P||t[20]!==F?(I=(0,Z.jsx)(RC,{withHandle:g,disabled:P,onPointerDown:F}),t[18]=g,t[19]=P,t[20]=F,t[21]=I):I=t[21];let L;t[22]===h?L=t[23]:(L={backgroundColor:h},t[22]=h,t[23]=L);let R=g?`${v}px`:0,z;t[24]!==i||t[25]!==r?(z=e=>{let t=e.asPercentage===0;p(t),S.current&&(t&&r?i(!1):!t&&!r&&i(!0),e.inPixels>0&&(y.current=e.inPixels,T(e.inPixels)))},t[24]=i,t[25]=r,t[26]=z):z=t[26];let B=!b&&`transition-[flex-grow] duration-150 ease-out motion-reduce:transition-none motion-reduce:duration-0`,V;t[27]===B?V=t[28]:(V=Y(`flex flex-col`,B),t[27]=B,t[28]=V);let H;t[29]===o?H=t[30]:(H=(0,Z.jsx)(`div`,{ref:o,className:`flex min-h-0 flex-1 flex-col overflow-hidden`}),t[29]=o,t[30]=H);let U;t[31]!==f||t[32]!==d||t[33]!==L||t[34]!==R||t[35]!==z||t[36]!==V||t[37]!==H?(U=(0,Z.jsx)(LC,{id:AM,style:L,panelRef:d,defaultSize:R,minSize:`120px`,maxSize:`95%`,collapsible:!0,collapsedSize:0,onResize:z,inert:f,className:V,children:H}),t[31]=f,t[32]=d,t[33]=L,t[34]=R,t[35]=z,t[36]=V,t[37]=H,t[38]=U):U=t[38];let W;return t[39]!==N||t[40]!==I||t[41]!==U||t[42]!==j?(W=(0,Z.jsxs)(IC,{orientation:`vertical`,className:`min-h-0 flex-1`,"data-dragging":j,children:[N,I,U]}),t[39]=N,t[40]=I,t[41]=U,t[42]=j,t[43]=W):W=t[43],W}function MM(){return OM()}var NM=(0,Q.lazy)(async()=>({default:(await n(()=>import(`./ActivityModeContent-Bq2-szSy.js`),__vite__mapDeps([36,1,2,37,38,39,11,40,41,42,43,44,45,46,47,15,16,13,7,17,18,10,3,48,49,33,12,6,4,50,51,52,20,53,54,55,56,30,31,32,57,58,59,60,61,62,63,64]),import.meta.url)).ActivityModeContent})),PM=`300px`,FM=`600px`,IM=new Set([`doc-panel`,`terminal-column`,`agent-panel`]);function LM(e){let t=(0,$.c)(5),n;t[0]===e?n=t[1]:(n=(0,Z.jsx)(zM,{...e}),t[0]=e,t[1]=n);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(RM,{}),t[2]=r):r=t[2];let i;return t[3]===n?i=t[4]:(i=(0,Z.jsx)(El,{name:`editor-area`,children:(0,Z.jsxs)(Li,{children:[n,r]})}),t[3]=n,t[4]=i),i}function RM(){let e=(0,$.c)(5),t=yo(),n;e[0]===t?n=e[1]:(n=e=>{e||t.close()},e[0]=t,e[1]=n);let r;return e[2]!==t.open||e[3]!==n?(r=(0,Z.jsx)(jC,{open:t.open,onOpenChange:n}),e[2]=t.open,e[3]=n,e[4]=r):r=e[4],r}function zM(e){let t=(0,$.c)(243),{editorMode:n,onModeChange:r,activeTab:i,onActiveTabChange:a,terminalBridge:o,terminalVisible:s,onTerminalVisibleChange:c,terminalDock:l,onTerminalPlacement:u,onRevealTerminal:d}=e,f=s===void 0?!1:s,p=l===void 0?`right`:l,{_:m}=$t(),{resolvedTheme:h}=Mn(),g;t[0]===h?g=t[1]:(g=wu(h),t[0]=h,t[1]=g);let _=g.background,{activeDocName:v,activeProvider:y,activeTarget:b,recycleDocument:x,docPanelMode:S,docPanelAgentId:C,docPanelExpandSignal:w}=mt(),{openDocumentTransition:T}=Dt(),{requestAddProperty:E}=Pi(),D=ow(y,v),O=lw(v,n===`source`?`source`:`wysiwyg`),k=Pw(y),A=k===`connected`||k===`synced`,M=cw(v)===`conflict`,[N,P]=(0,Q.useState)(!1),F,I;t[2]!==y||t[3]!==N?(F=()=>{y!=null&&!N&&P(!0)},I=[y,N],t[2]=y,t[3]=N,t[4]=F,t[5]=I):(F=t[4],I=t[5]),(0,Q.useEffect)(F,I);let L=(0,Q.useDeferredValue)(v),R=b?.kind===`missing`,z=!!v&&b?.kind!==`folder`,B;t[6]!==m||t[7]!==R?(B=R?m({id:`K-a33w`}):void 0,t[6]=m,t[7]=R,t[8]=B):B=t[8];let V=B,H=(0,Q.useSyncExternalStore)(xi.subscribe,xi.getSnapshot,xi.getSnapshot),U;t[9]!==b||t[10]!==H?(U=wi(b,H),t[9]=b,t[10]=H,t[11]=U):U=t[11];let W=U,[G]=(0,Q.useState)(WM),K=G!==null,ee;t[12]===G?ee=t[13]:(ee=()=>vw(G,window.innerWidth,`right`),t[12]=G,t[13]=ee);let[te,ne]=(0,Q.useState)(ee),re=(0,Q.useRef)(te),ie,ae;t[14]===te?(ie=t[15],ae=t[16]):(ae=()=>{re.current=te},ie=[te],t[14]=te,t[15]=ie,t[16]=ae),(0,Q.useEffect)(ae,ie);let oe=Ib(),se=Ib(),ce;t[17]===te?ce=t[18]:(ce=()=>Dw(`right`,te,Tw())===`collapsed`,t[17]=te,t[18]=ce);let[le]=(0,Q.useState)(ce),[q,ue]=(0,Q.useState)(le),de=(0,Q.useRef)(q),[fe,pe]=(0,Q.useState)(null),[me,he]=(0,Q.useState)(null),[ge,_e]=(0,Q.useState)(null),ve=p===`right`,ye=ve?`right`:`bottom`,be=o!=null&&ve&&f,xe=o!=null&&!f&&d!=null,Se=xe&&!ve,Ce=xe&&ve,we=ve&&f&&fe!=null,Te=we?fe:me,Ee=(ve?we:f)&&Te!=null,De,Oe;t[19]!==Te||t[20]!==u||t[21]!==ye||t[22]!==ge||t[23]!==Ee?(De=()=>{u?.({container:Te,isShowing:Ee,dockPosition:ye,editorRegion:ge})},Oe=[u,Te,Ee,ye,ge],t[19]=Te,t[20]=u,t[21]=ye,t[22]=ge,t[23]=Ee,t[24]=De,t[25]=Oe):(De=t[24],Oe=t[25]),(0,Q.useEffect)(De,Oe);let ke,Ae;t[26]===q?(ke=t[27],Ae=t[28]):(ke=()=>{de.current=q},Ae=[q],t[26]=q,t[27]=ke,t[28]=Ae),(0,Q.useEffect)(ke,Ae);let[je,Me]=(0,Q.useState)(!1),Ne=(0,Q.useRef)(!1),[Pe]=(0,Q.useState)(UM),Fe=(0,Q.useRef)(Pe),Le=(0,Q.useRef)(null),Re;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(Re=function(e){Le.current!=null&&clearTimeout(Le.current),Le.current=setTimeout(()=>{pw(e),Le.current=null},100)},t[29]=Re):Re=t[29];let ze=Re,[Be]=(0,Q.useState)(HM),Ve=(0,Q.useRef)(Be),[He,Ue]=(0,Q.useState)(!1),We=(0,Q.useRef)(!1),Ge=(0,Q.useRef)(null),Ke;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=function(e){Ge.current!=null&&clearTimeout(Ge.current),Ge.current=setTimeout(()=>{Mw(e),Ge.current=null},100)},t[30]=Ke):Ke=t[30];let qe=Ke,Je,Ye;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(Je=()=>()=>{Le.current!=null&&clearTimeout(Le.current),Ge.current!=null&&clearTimeout(Ge.current)},Ye=[],t[31]=Je,t[32]=Ye):(Je=t[31],Ye=t[32]),(0,Q.useEffect)(Je,Ye);let[Xe,Ze]=(0,Q.useState)(null),Qe=(0,Q.useRef)(null),$e=jb(),et=(0,Q.useRef)(be),tt,nt;t[33]===be?(tt=t[34],nt=t[35]):(tt=()=>{et.current=be},nt=[be],t[33]=be,t[34]=tt,t[35]=nt),(0,Q.useEffect)(tt,nt);let rt;t[36]!==oe||t[37]!==se?(rt=function(){for(let e of[oe,se]){let t=e.current?.getSize();if(t!=null&&t.asPercentage>1&&t.inPixels>0)return t.inPixels/t.asPercentage*100}let e=Qe.current;return e!=null&&e.offsetWidth>0?e.offsetWidth:null},t[36]=oe,t[37]=se,t[38]=rt):rt=t[38];let it=rt,at;t[39]!==$e||t[40]!==it?(at=function(e){if(Ne.current||We.current)return;let t=$e.current;if(t!=null)try{let n=it();if(n==null)return;let r=t.getLayout(),i=Object.keys(r);if(i.length===0)return;let a=i.find(VM);if(a==null)return;let o={};if(`doc-panel`in r&&(o[`doc-panel`]=e?0:Fe.current),`terminal-column`in r&&(o[`terminal-column`]=Ve.current),Object.keys(o).length===0)return;let s=vM({currentLayout:r,containerPx:n,pinnedPx:o,residualId:a});s!==r&&t.setLayout(s)}catch{}},t[39]=$e,t[40]=it,t[41]=at):at=t[41];let ot=at,st=(0,Q.useRef)(ot),ct;t[42]===ot?ct=t[43]:(ct=()=>{st.current=ot},t[42]=ot,t[43]=ct),(0,Q.useEffect)(ct);let lt;t[44]!==ot||t[45]!==oe?(lt=function(){et.current?ot(!1):oe.current?.expand()},t[44]=ot,t[45]=oe,t[46]=lt):lt=t[46];let ut=lt,dt;t[47]!==ot||t[48]!==q||t[49]!==oe?(dt=function(){if(oe.current==null)return;let e=re.current;q?(Ow(`right`,e,`open`),et.current?ot(!1):oe.current?.expand()):(Ow(`right`,e,`collapsed`),et.current?ot(!0):oe.current?.collapse())},t[47]=ot,t[48]=q,t[49]=oe,t[50]=dt):dt=t[50];let ft=dt,pt,ht;t[51]!==ot||t[52]!==G||t[53]!==oe?(pt=()=>{let e=window.matchMedia(`(min-width: ${gw}px)`),t=()=>{let e=vw(G,window.innerWidth,`right`);ne(e);let t=Dw(`right`,e,Tw())===`collapsed`;ue(t),et.current?ot(t):t?oe.current?.collapse():oe.current?.expand()};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},ht=[G,oe,ot],t[51]=ot,t[52]=G,t[53]=oe,t[54]=pt,t[55]=ht):(pt=t[54],ht=t[55]),(0,Q.useEffect)(pt,ht);let gt,_t;t[56]!==Xe||t[57]!==K?(gt=()=>{if(Xe==null||K)return;let e=new ResizeObserver(()=>{st.current(de.current)});return e.observe(Xe),()=>e.disconnect()},_t=[Xe,K],t[56]=Xe,t[57]=K,t[58]=gt,t[59]=_t):(gt=t[58],_t=t[59]),(0,Q.useEffect)(gt,_t);let vt,yt;t[60]!==ut||t[61]!==a?(vt=()=>{let e=e=>{a(e),ut()},t=$m();return t&&e(t),th(t=>{$m(),e(t)})},yt=[a,ut],t[60]=ut,t[61]=a,t[62]=vt,t[63]=yt):(vt=t[62],yt=t[63]),(0,Q.useEffect)(vt,yt);let bt,xt;t[64]!==w||t[65]!==ut?(bt=()=>{w!==0&&ut()},xt=[w,ut],t[64]=w,t[65]=ut,t[66]=bt,t[67]=xt):(bt=t[66],xt=t[67]),(0,Q.useEffect)(bt,xt);let St=(0,Q.useRef)(be),Ct,wt;t[68]!==q||t[69]!==be?(Ct=()=>{if(St.current===be)return;St.current=be;let e=q;queueMicrotask(()=>{st.current(e)})},wt=[be,q],t[68]=q,t[69]=be,t[70]=Ct,t[71]=wt):(Ct=t[70],wt=t[71]),(0,Q.useLayoutEffect)(Ct,wt);let Tt,Et;t[72]===q?(Tt=t[73],Et=t[74]):(Tt=()=>{if(!q||!document.getElementById(`doc-panel`)?.contains(document.activeElement))return;let e=document.querySelector(`[data-doc-panel-toggle]`);if(e){e.focus();return}document.querySelector(`[data-sidebar="trigger"]`)?.focus()},Et=[q],t[72]=q,t[73]=Tt,t[74]=Et),(0,Q.useLayoutEffect)(Tt,Et);let Ot,kt;t[75]===q?(Ot=t[76],kt=t[77]):(Ot=()=>{window.okDesktop!=null&&window.okDesktop.editor.notifyViewMenuStateChanged({docPanelVisible:!q})},kt=[q],t[75]=q,t[76]=Ot,t[77]=kt),(0,Q.useEffect)(Ot,kt);let At,jt;t[78]===ft?(At=t[79],jt=t[80]):(At=()=>{if(window.okDesktop!=null)return window.okDesktop.onMenuAction(e=>{e===`toggle-doc-panel`&&ft()})},jt=[ft],t[78]=ft,t[79]=At,t[80]=jt),(0,Q.useEffect)(At,jt);let Mt,Nt;t[81]===ft?(Mt=t[82],Nt=t[83]):(Mt=()=>{if(window.okDesktop!=null)return;let e=e=>{Al(e,`toggle-document-panel`)&&(e.preventDefault(),ft())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},Nt=[ft],t[81]=ft,t[82]=Mt,t[83]=Nt),(0,Q.useEffect)(Mt,Nt);let Pt=(0,Q.useRef)(null),[Ft,It]=(0,Q.useState)(null),[Lt,Rt]=(0,Q.useState)(!1),zt=b?.kind===`large-file`?b.docName:v,Bt,Vt;t[84]===zt?(Bt=t[85],Vt=t[86]):(Bt=()=>{if(zt&&zt!==Pt.current){let e=Pt.current;Pt.current=zt,It(e)}},Vt=[zt],t[84]=zt,t[85]=Bt,t[86]=Vt),(0,Q.useEffect)(Bt,Vt);let Ht;t[87]===T?Ht=t[88]:(Ht=function(e){let t=yl(e);window.location.hash===t?T(e):window.location.hash=t},t[87]=T,t[88]=Ht);let Ut=Ht,Wt,Gt=null;if(b?.kind===`large-file`){let e;t[89]!==Ut||t[90]!==Ft?(e=Ft?{previousDocName:Ft,onNavigateBack:Ut}:void 0,t[89]=Ut,t[90]=Ft,t[91]=e):e=t[91];let n;t[92]!==b.docName||t[93]!==b.limit||t[94]!==b.size||t[95]!==e?(n=(0,Z.jsx)(pC,{docName:b.docName,size:b.size,limit:b.limit,backNav:e}),t[92]=b.docName,t[93]=b.limit,t[94]=b.size,t[95]=e,t[96]=n):n=t[96],Wt=n}else if(b?.kind===`folder`){let e;t[97]!==K||t[98]!==f?(e=bT({terminalVisible:f,isEmbedded:K}),t[97]=K,t[98]=f,t[99]=e):e=t[99];let n=e,r;t[100]===b.folderPath?r=t[101]:(r=(0,Z.jsx)(lC,{folderPath:b.folderPath}),t[100]=b.folderPath,t[101]=r);let i;t[102]!==b.folderPath||t[103]!==n?(i=n?(0,Z.jsx)(sT,{folderPath:b.folderPath}):null,t[102]=b.folderPath,t[103]=n,t[104]=i):i=t[104];let a;if(t[105]!==r||t[106]!==i?(a=(0,Z.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,children:[r,i]}),t[105]=r,t[106]=i,t[107]=a):a=t[107],Wt=a,S===`agent`&&C!==null){let e;t[108]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(RC,{withHandle:!0}),t[108]=e):e=t[108];let n;t[109]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsxs)(Z.Fragment,{children:[e,(0,Z.jsx)(LC,{id:`agent-panel`,defaultSize:`25%`,minSize:`300px`,maxSize:`40%`,className:`flex flex-col bg-muted/20`,children:(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(`div`,{role:`status`,"aria-busy":`true`,className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:(0,Z.jsx)(J,{id:`ONPvOb`})}),children:(0,Z.jsx)(NM,{showBackButton:!1})})})]}),t[109]=n):n=t[109],Gt=n}}else if(b?.kind===`asset`){let e;t[110]!==b.assetPath||t[111]!==b.mediaKind?(e=(0,Z.jsx)(Zb,{assetPath:b.assetPath,mediaKind:b.mediaKind},b.assetPath),t[110]=b.assetPath,t[111]=b.mediaKind,t[112]=e):e=t[112],Wt=e}else if(b?.kind===`skill-file`){let e=`${b.scope}/${b.name}/${b.path}`,n;t[113]!==b.name||t[114]!==b.path||t[115]!==b.scope||t[116]!==e?(n=(0,Z.jsx)(SC,{scope:b.scope,name:b.name,path:b.path},e),t[113]=b.name,t[114]=b.path,t[115]=b.scope,t[116]=e,t[117]=n):n=t[117],Wt=n}else if(W){let e;t[118]===W?e=t[119]:(e=(0,Z.jsx)(gC,{nav:W},W.path),t[118]=W,t[119]=e),Wt=e}else if(!y||!v)if((typeof window<`u`?vl(window.location.hash):null)!==null)if(o!=null&&N){let e;t[120]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Qb,{}),t[120]=e):e=t[120],Wt=e;let n;t[121]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(RC,{withHandle:!0,disabled:!0}),t[121]=n):n=t[121];let r=le?0:`${Pe}px`,i;t[122]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1`}),t[122]=i):i=t[122];let a;t[123]===r?a=t[124]:(a=(0,Z.jsxs)(Z.Fragment,{children:[n,(0,Z.jsx)(LC,{id:`doc-panel`,defaultSize:r,minSize:PM,maxSize:FM,collapsible:!0,collapsedSize:0,inert:!0,className:`flex flex-col bg-muted/20`,children:i})]}),t[123]=r,t[124]=a),Gt=a}else{let e;return t[125]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Qb,{}),t[125]=e):e=t[125],e}else{let e=f?ye:null,n;t[126]===e?n=t[127]:(n=(0,Z.jsx)(AS,{terminalDock:e}),t[126]=e,t[127]=n),Wt=n}else{let e=n===`source`,o=!A,s=q,c;t[128]!==v||t[129]!==E?(c=function(){v&&E(v)},t[128]=v,t[129]=E,t[130]=c):c=t[130];let l=c,u;t[131]!==v||t[132]!==K||t[133]!==f?(u=yT({terminalVisible:f,isEmbedded:K,activeDocName:v}),t[131]=v,t[132]=K,t[133]=f,t[134]=u):u=t[134];let d=u,p=L??v,m=Ft??void 0,h;t[135]!==V||t[136]!==e||t[137]!==Ut||t[138]!==x||t[139]!==p||t[140]!==m?(h=(0,Z.jsx)(ZA,{activeDocName:p,isSourceMode:e,editorPlaceholder:V,previousDocName:m,onNavigateBack:Ut,onRecycle:x}),t[135]=V,t[136]=e,t[137]=Ut,t[138]=x,t[139]=p,t[140]=m,t[141]=h):h=t[141];let g;t[142]!==v||t[143]!==e?(g=(0,Z.jsx)(nw,{activeDocName:v,isSourceMode:e}),t[142]=v,t[143]=e,t[144]=g):g=t[144];let _;t[145]!==v||t[146]!==L?(_=_M({activeDocName:v,deferredActiveDocName:L,mountResolved:v!==null&&j(v),syncResolved:v!==null&&Ie(v)})?(0,Z.jsxs)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:[(0,Z.jsx)(Qb,{}),v===null?null:(0,Z.jsx)(mC,{docName:v})]}):null,t[145]=v,t[146]=L,t[147]=_):_=t[147];let y;t[148]!==h||t[149]!==g||t[150]!==_?(y=(0,Z.jsxs)(`div`,{className:`relative h-full`,children:[h,g,_]}),t[148]=h,t[149]=g,t[150]=_,t[151]=y):y=t[151];let b;t[152]!==v||t[153]!==M||t[154]!==s||t[155]!==e||t[156]!==r||t[157]!==l||t[158]!==Ce||t[159]!==o||t[160]!==ft?(b=!M&&(0,Z.jsx)(gM,{activeDocName:v,isSourceMode:e,sourceDisabled:o,onModeChange:r,showAddPropertyButton:!e,onAddProperty:l,isPanelCollapsed:s,onTogglePanel:ft,reserveRightGutter:Ce&&s}),t[152]=v,t[153]=M,t[154]=s,t[155]=e,t[156]=r,t[157]=l,t[158]=Ce,t[159]=o,t[160]=ft,t[161]=b):b=t[161];let C;t[162]!==v||t[163]!==Lt||t[164]!==e||t[165]!==d?(C=d?(0,Z.jsx)(sT,{docName:v,surface:e?`source`:`wysiwyg`,dismissed:Lt,onDismiss:()=>Rt(!0),onReopen:()=>Rt(!1)}):null,t[162]=v,t[163]=Lt,t[164]=e,t[165]=d,t[166]=C):C=t[166];let w;t[167]!==y||t[168]!==b||t[169]!==C?(w=(0,Z.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[y,b,C]}),t[167]=y,t[168]=b,t[169]=C,t[170]=w):w=t[170];let T;t[171]!==Lt||t[172]!==d?(T=d&&Lt?{onReopen:()=>Rt(!1)}:null,t[171]=Lt,t[172]=d,t[173]=T):T=t[173];let k;t[174]!==Se||t[175]!==O||t[176]!==z||t[177]!==D||t[178]!==T?(k=(0,Z.jsx)(Qj,{stats:D,selectionStats:O,showStats:z,composerBadge:T,reserveRightGutter:Se}),t[174]=Se,t[175]=O,t[176]=z,t[177]=D,t[178]=T,t[179]=k):k=t[179];let N;t[180]!==w||t[181]!==k?(N=(0,Z.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[w,k]}),t[180]=w,t[181]=k,t[182]=N):N=t[182],Wt=N;let P=be&&q,F=!q,I;t[183]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>{Me(!0),Ne.current=!0;let e=()=>{Me(!1),Ne.current=!1,window.removeEventListener(`pointerup`,e)};window.addEventListener(`pointerup`,e)},t[183]=I):I=t[183];let R;t[184]!==q||t[185]!==F?(R=(0,Z.jsx)(RC,{withHandle:F,disabled:q,onPointerDown:I}),t[184]=q,t[185]=F,t[186]=R):R=t[186];let B=le?0:`${Pe}px`,H=P?`0px`:PM,U;t[187]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>{ue(e.asPercentage===0),e.inPixels>0&&Ne.current&&(Fe.current=e.inPixels,ze(e.inPixels))},t[187]=U):U=t[187];let W=!je&&`transition-[flex-grow] duration-200 ease-out motion-reduce:transition-none motion-reduce:duration-0`,G;t[188]===W?G=t[189]:(G=Y(`flex flex-col bg-muted/20`,W),t[188]=W,t[189]=G);let ee;t[190]!==v||t[191]!==i||t[192]!==S||t[193]!==e||t[194]!==a?(ee=(0,Z.jsx)(Vv,{docName:v,isSourceMode:e,activeTab:i,onActiveTabChange:a,mode:S}),t[190]=v,t[191]=i,t[192]=S,t[193]=e,t[194]=a,t[195]=ee):ee=t[195];let te;t[196]!==P||t[197]!==q||t[198]!==oe||t[199]!==B||t[200]!==H||t[201]!==G||t[202]!==ee?(te=(0,Z.jsx)(LC,{id:`doc-panel`,panelRef:oe,disabled:P,defaultSize:B,minSize:H,maxSize:FM,collapsible:!0,collapsedSize:0,onResize:U,inert:q,className:G,children:ee}),t[196]=P,t[197]=q,t[198]=oe,t[199]=B,t[200]=H,t[201]=G,t[202]=ee,t[203]=te):te=t[203];let ne;t[204]!==R||t[205]!==te?(ne=(0,Z.jsxs)(Z.Fragment,{children:[R,te]}),t[204]=R,t[205]=te,t[206]=ne):ne=t[206],Gt=ne}let Kt;t[207]!==d||t[208]!==c||t[209]!==o||t[210]!==ye||t[211]!==f||t[212]!==Wt?(Kt=o==null?Wt:(0,Z.jsx)(jM,{visible:f,onVisibleChange:c??BM,dockPosition:ye,onBottomContainer:he,onEditorRegion:_e,onReveal:d,children:Wt}),t[207]=d,t[208]=c,t[209]=o,t[210]=ye,t[211]=f,t[212]=Wt,t[213]=Kt):Kt=t[213];let qt=Kt,Jt;t[214]!==Be||t[215]!==He||t[216]!==c||t[217]!==se||t[218]!==be||t[219]!==_?(Jt=be?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(RC,{withHandle:!0,onPointerDown:()=>{Ue(!0),We.current=!0;let e=()=>{Ue(!1),We.current=!1,window.removeEventListener(`pointerup`,e),se.current?.isCollapsed()&&c?.(!1)};window.addEventListener(`pointerup`,e)}}),(0,Z.jsx)(LC,{id:`terminal-column`,panelRef:se,style:{backgroundColor:_},defaultSize:`${Be}px`,minSize:`320px`,maxSize:`95%`,collapsible:!0,collapsedSize:0,onResize:e=>{e.inPixels>0&&We.current&&(Ve.current=e.inPixels,qe(e.inPixels))},className:Y(`flex flex-col`,!He&&`transition-[flex-grow] duration-200 ease-out motion-reduce:transition-none motion-reduce:duration-0`),children:(0,Z.jsx)(`div`,{ref:pe,className:`flex min-h-0 flex-1 flex-col overflow-hidden`})})]}):null,t[214]=Be,t[215]=He,t[216]=c,t[217]=se,t[218]=be,t[219]=_,t[220]=Jt):Jt=t[220];let Yt=Jt,Xt=Gt!=null&&!le||be,Zt;t[221]===Symbol.for(`react.memo_cache_sentinel`)?(Zt=e=>{Ze(e),Qe.current=e},t[221]=Zt):Zt=t[221];let Qt=je||He||void 0,en=be?`5%`:`30%`,tn;t[222]===Xt?tn=t[223]:(tn=Xt?{}:{defaultSize:`100%`},t[222]=Xt,t[223]=tn);let nn=!(je||He)&&`transition-[flex-grow] duration-200 ease-out motion-reduce:transition-none motion-reduce:duration-0`,rn;t[224]===nn?rn=t[225]:(rn=Y(nn),t[224]=nn,t[225]=rn);let an;t[226]!==qt||t[227]!==en||t[228]!==tn||t[229]!==rn?(an=(0,Z.jsx)(LC,{minSize:en,...tn,className:rn,children:qt}),t[226]=qt,t[227]=en,t[228]=tn,t[229]=rn,t[230]=an):an=t[230];let on;t[231]!==$e||t[232]!==Gt||t[233]!==Qt||t[234]!==an||t[235]!==Yt?(on=(0,Z.jsxs)(IC,{orientation:`horizontal`,groupRef:$e,"data-dragging":Qt,children:[an,Gt,Yt]}),t[231]=$e,t[232]=Gt,t[233]=Qt,t[234]=an,t[235]=Yt,t[236]=on):on=t[236];let sn;t[237]!==d||t[238]!==Ce?(sn=Ce?(0,Z.jsx)(kM,{dockPosition:`right`,onReveal:d,className:`top-2.5 right-0`}):null,t[237]=d,t[238]=Ce,t[239]=sn):sn=t[239];let cn;return t[240]!==on||t[241]!==sn?(cn=(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,ref:Zt,children:[on,sn]}),t[240]=on,t[241]=sn,t[242]=cn):cn=t[242],cn}function BM(){}function VM(e){return!IM.has(e)}function HM(){return Nw()}function UM(){return mw()}function WM(){return kr()}function GM(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 KM(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 qM=1e3,JM=!1;function YM(e){return!!(e.localPrincipalId&&e.entryPrincipalId===e.localPrincipalId||!e.localPrincipalId&&e.entryClientId===e.localClientId)}function XM(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:xs(i)?a=i:(a=void 0,JM||(JM=!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`&&(YM({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=KM(i),{current:c,crossDoc:l}=a?_s(a,n,Date.now()):{current:[],crossDoc:[]},u=ZM,d=c.map(u),f=l.map(u),p=[...s,...d],m=f;o(e=>GM(e.current,p)&&GM(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,qM);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 ZM(e){let{agentId:t,entry:n}=e;return{kind:`agent`,agentId:t,presence:n}}var QM=!1,$M=new Set,eN=!1;function tN(){for(let e of $M)e()}function nN(e){QM!==e&&(QM=e,tN())}function rN(){return QM}function iN(e){return $M.add(e),()=>{$M.delete(e)}}function aN(e){let t=[e.onUpdateRelaunching(()=>nN(!0)),e.onUpdateRelaunchFailed(()=>nN(!1))];return()=>{for(let e of t)e()}}function oN(){if(eN||typeof window>`u`)return;let e=window.okDesktop;e&&(eN=!0,aN(e))}function sN(){return(0,Q.useSyncExternalStore)(iN,rN,cN)}function cN(){return!1}var lN=`sync-status`;async function uN(e){try{let t=await Ag(e);t.ok||Ss.error(t.message,{id:lN,duration:1/0})}catch{}}function dN(e,t){let n=(0,$.c)(6),{_:r}=$t(),i=sN(),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(!1),s=(0,Q.useRef)(t),c,l;n[0]!==r||n[1]!==t||n[2]!==i||n[3]!==e?(c=()=>{if(s.current!==t&&(s.current=t,a.current=!1,o.current=!1),t)if(e===`synced`&&(a.current=!0),e===`disconnected`&&a.current){if(i){Ss.dismiss(lN);return}o.current=!0;let e=window.okDesktop;Ss.warning(r({id:`HGNCsl`}),{id:lN,duration:1/0,...e?{action:{label:r({id:`uaUc6t`}),onClick:()=>{uN(e)}}}:{}})}else o.current&&e===`synced`&&(o.current=!1,Ss.success(r({id:`GhjUB_`}),{id:lN,duration:3e3}))},l=[e,t,r,i],n[0]=r,n[1]=t,n[2]=i,n[3]=e,n[4]=c,n[5]=l):(c=n[4],l=n[5]),(0,Q.useEffect)(c,l)}var fN=4,pN=3,mN={Bird:md,Cat:xd,Dog:kd,Fish:Fd,Mouse:pf,Rabbit:ff,Shrimp:yf,Snail:bf,Squirrel:wf,Turtle:Pf};Object.freeze(Object.keys(mN));function hN(e){if(typeof e.principalId==`string`&&e.principalId.length>0)return{kind:`initials`};let t=e.name.split(` `)[1];return t&&Object.hasOwn(mN,t)?{kind:`animal`,animal:t}:{kind:`initials`}}var gN={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function _N(e){let t=(0,$.c)(28),{user:n,mode:r,tabCount:i}=e,{_:a}=$t(),o=hN(n),s=o.kind===`animal`?mN[o.animal]:void 0,c;t[0]===n.name?c=t[1]:(c=Sr(n.name),t[0]=n.name,t[1]=c);let l=c,u;t[2]===n.color?u=t[3]:(u=oi(n.color),t[2]=n.color,t[3]=u);let d=u,f=n.name,p;t[4]!==a||t[5]!==i||t[6]!==f?(p=i>1?a({id:`qAhFeg`,values:{userName:f,tabCount:i}}):f,t[4]=a,t[5]=i,t[6]=f,t[7]=p):p=t[7];let m=p,h;t[8]!==a||t[9]!==i||t[10]!==f?(h=i>1?a({id:`BEkF-P`,values:{userName:f,tabCount:i}}):f,t[8]=a,t[9]=i,t[10]=f,t[11]=h):h=t[11];let g=h,_;t[12]===n.color?_=t[13]:(_={backgroundColor:n.color},t[12]=n.color,t[13]=_);let v;t[14]!==s||t[15]!==d||t[16]!==l?(v=s?(0,Z.jsx)(s,{size:18,color:d,strokeWidth:1.5}):(0,Z.jsx)(`span`,{className:`font-mono text-2xs font-semibold leading-none`,style:{color:d},children:l}),t[14]=s,t[15]=d,t[16]=l,t[17]=v):v=t[17];let y;t[18]!==g||t[19]!==r||t[20]!==_||t[21]!==v?(y=(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(`div`,{"data-presence-badge":`human`,"data-presence-mode":r,role:`img`,"aria-label":g,className:`inline-flex size-7 shrink-0 cursor-default items-center justify-center rounded-full ring-2 ring-background`,style:_,children:v})}),t[18]=g,t[19]=r,t[20]=_,t[21]=v,t[22]=y):y=t[22];let b;t[23]===m?b=t[24]:(b=(0,Z.jsx)(Ns,{children:m}),t[23]=m,t[24]=b);let x;return t[25]!==y||t[26]!==b?(x=(0,Z.jsxs)(Fs,{children:[y,b]}),t[25]=y,t[26]=b,t[27]=x):x=t[27],x}function vN(e){let t=gN[e.icon];return e.displayName||t||Kc._({id:`iEQQyu`})}function yN(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 bN(e){let t=(0,$.c)(33),{participant:n,crossDoc:r,scoped:i,onClickAgent:a}=e,{_:o}=$t(),{activeDocName:s}=mt(),{presence:c,agentId:l}=n,u=vN(c),d=yN(c.mode),f=!r&&d,p=c.currentDoc&&c.currentDoc!==`(connected)`?c.currentDoc:null,m=s!==null||p!==null,h=m?`cursor-pointer`:`cursor-default opacity-50`,g=i?`ring-primary ring-offset-2 ring-offset-background`:`ring-background`,_=f&&!i?`ring-primary/40 animate-pulse`:``,v;t[0]!==h||t[1]!==g||t[2]!==_?(v=[`inline-flex size-7 shrink-0 items-center justify-center rounded-full ring-2`,h,g,_].filter(Boolean),t[0]=h,t[1]=g,t[2]=_,t[3]=v):v=t[3];let y=v.join(` `),b=r?`true`:void 0,x=i?`true`:void 0,S=m?void 0:`true`,C;t[4]!==c.mode||t[5]!==b||t[6]!==x||t[7]!==S?(C={"data-presence-badge":`agent`,"data-presence-mode":c.mode,"data-presence-crossdoc":b,"data-presence-scoped":x,"data-presence-inert":S},t[4]=c.mode,t[5]=b,t[6]=x,t[7]=S,t[8]=C):C=t[8];let w=C,T=o(r&&p?{id:`b4AQFK`,values:{tooltipName:u,realCurrentDoc:p}}:{id:`RfHNf8`,values:{tooltipName:u}}),E;t[9]!==l||t[10]!==T||t[11]!==w||t[12]!==m||t[13]!==a||t[14]!==c.color||t[15]!==c.icon||t[16]!==p||t[17]!==y||t[18]!==u?(E=m?(0,Z.jsx)(`button`,{type:`button`,...w,"aria-label":T,className:y,style:{backgroundColor:c.color},onClick:()=>a(l,p),children:(0,Z.jsx)(ys,{icon:c.icon,width:16,height:16,className:`text-white`,"aria-hidden":!0})}):(0,Z.jsx)(`div`,{...w,role:`img`,"aria-label":u,className:y,style:{backgroundColor:c.color},children:(0,Z.jsx)(ys,{icon:c.icon,width:16,height:16,className:`text-white`,"aria-hidden":!0})}),t[9]=l,t[10]=T,t[11]=w,t[12]=m,t[13]=a,t[14]=c.color,t[15]=c.icon,t[16]=p,t[17]=y,t[18]=u,t[19]=E):E=t[19];let D=E,O;t[20]===D?O=t[21]:(O=(0,Z.jsx)(Ms,{asChild:!0,children:D}),t[20]=D,t[21]=O);let k;t[22]===u?k=t[23]:(k=(0,Z.jsx)(`span`,{className:`font-medium`,children:u}),t[22]=u,t[23]=k);let A;t[24]!==r||t[25]!==p?(A=r&&p?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:(0,Z.jsx)(J,{id:`Wh0im4`,values:{realCurrentDoc:p}})}):null,t[24]=r,t[25]=p,t[26]=A):A=t[26];let j;t[27]!==k||t[28]!==A?(j=(0,Z.jsxs)(Ns,{className:`flex flex-col gap-0.5`,children:[k,A]}),t[27]=k,t[28]=A,t[29]=j):j=t[29];let M;return t[30]!==O||t[31]!==j?(M=(0,Z.jsxs)(Fs,{children:[O,j]}),t[30]=O,t[31]=j,t[32]=M):M=t[32],M}function xN(e){let t=(0,$.c)(21),{count:n,remainder:r,crossDoc:i,scopedAgentId:a,onClickAgent:o}=e,s;t[0]!==n||t[1]!==i?(s=i?Kc._({id:`9euN0m`,values:{count:n}}):Kc._({id:`uhJEA2`,values:{count:n}}),t[0]=n,t[1]=i,t[2]=s):s=t[2];let c=s,l=i?`true`:void 0,u;t[3]!==n||t[4]!==c||t[5]!==l?(u=(0,Z.jsx)(jt,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`presence-overflow`,"data-presence-crossdoc":l,className:`inline-flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-full bg-muted font-medium text-muted-foreground text-xs ring-2 ring-background hover:bg-muted/80`,"aria-label":c,children:[`+`,n]})}),t[3]=n,t[4]=c,t[5]=l,t[6]=u):u=t[6];let d;if(t[7]!==i||t[8]!==o||t[9]!==r||t[10]!==a){let e;t[12]!==i||t[13]!==o||t[14]!==a?(e=e=>e.kind===`human`?(0,Z.jsx)(_N,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(bN,{participant:e,crossDoc:i,scoped:a===e.agentId,onClickAgent:o},e.agentId),t[12]=i,t[13]=o,t[14]=a,t[15]=e):e=t[15],d=r.map(e),t[7]=i,t[8]=o,t[9]=r,t[10]=a,t[11]=d}else d=t[11];let f;t[16]===d?f=t[17]:(f=(0,Z.jsx)(yt,{align:`end`,className:`w-auto max-w-xs p-2`,children:(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:d})}),t[16]=d,t[17]=f);let p;return t[18]!==u||t[19]!==f?(p=(0,Z.jsxs)($e,{children:[u,f]}),t[18]=u,t[19]=f,t[20]=p):p=t[20],p}function SN(e,t,n,r){return e.kind===`human`?(0,Z.jsx)(_N,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(bN,{participant:e,crossDoc:n,scoped:r===e.agentId,onClickAgent:t},e.agentId)}function CN(){let e=(0,$.c)(20),{activeProvider:t,activeDocName:n,systemProvider:r,openActivityPanel:i,docPanelMode:a,docPanelAgentId:o}=mt(),{current:s,crossDoc:c}=XM(t,r,n);if(dN(Pw(t),n),s.length===0&&c.length===0)return null;let l;if(e[0]!==c||e[1]!==s||e[2]!==o||e[3]!==a||e[4]!==i){let t=s.slice(0,fN),n;e[6]===s?n=e[7]:(n=s.slice(fN),e[6]=s,e[7]=n);let r=n,u=c.slice(0,pN),d;e[8]===c?d=e[9]:(d=c.slice(pN),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=>SN(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)(xN,{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=>SN(e,p,!0,m)),f.length>0?(0,Z.jsx)(xN,{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 wN(){let e=(0,$.c)(4),[t,n]=(0,Q.useState)(null),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.okDesktop;if(!e)return;let t=!1;return e.state.query().then(e=>{t||n(e.channel)}).catch(TN),()=>{t=!0}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Q.useEffect)(r,i);let a;return e[2]===t?a=e[3]:(a={channel:t},e[2]=t,e[3]=a),a}function TN(e){console.warn(`[use-update-channel] bridge.state.query() failed`,e)}function EN(e){let t=(0,$.c)(6),{className:n}=e,{_:r}=$t(),{channel:i}=wN();if(i!==`beta`)return null;let a;t[0]===r?a=t[1]:(a=r({id:`9fhQRL`}),t[0]=r,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(J,{id:`cSCbv3`}),t[2]=o):o=t[2];let s;return t[3]!==n||t[4]!==a?(s=(0,Z.jsx)(qe,{variant:`secondary`,"aria-label":a,"data-testid":`beta-badge`,className:n,children:o}),t[3]=n,t[4]=a,t[5]=s):s=t[5],s}function DN(e,t){return t.trim()}function ON(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function kN(e,t){let n=DN(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function AN(e,t,n=[],r=[],i=[]){if(t.length===0&&n.length===0&&r.length===0&&i.length===0)return e;let a=new Map(t.map(e=>[e.fromDocName,e.toDocName])),o=new Map(i.map(e=>[e.toDocName,e.docExt])),s=new Map(r.map(e=>[e.fromPath,e.toPath]));return e.map(e=>{if(rl(e)){let t=s.get(Vu(e.docName,e.docExt));if(t){let n=il(t);return{kind:`asset`,path:t,assetExt:n,mediaKind:Gn(n),size:e.size,modified:e.modified,referencedBy:[]}}let n=a.get(e.docName)??e.docName;return{...e,docName:n,docExt:o.get(n)??e.docExt}}if(nl(e))return{...e,path:LN(e.path,n)};if(al(e)){let t=s.get(e.path);return t&&Qc(t)?{kind:`document`,docName:Du(t),docExt:el(t),size:e.size,modified:e.modified}:{...e,path:t??LN(e.path,n)}}return e})}function jN(e,t,n,r=[]){if(t.length===0&&!n&&r.length===0)return e;let i=new Set(t),a=new Set(r);return e.filter(e=>rl(e)?!i.has(e.docName)&&!VN(e.docName,n):nl(e)?!VN(e.path,n):al(e)?!a.has(e.path)&&!VN(e.path,n):!0)}function MN(e,t){if(e.kind!==`asset`||t.some(t=>al(t)&&t.path===e.path))return e;let n=Wu(e.path,t);return n?{...e,path:n,name:n.split(`/`).pop()??n}:e}function NN(e,t,n,r=new Date().toISOString()){let i=!1,a=[...e],o=e=>{a.some(t=>RN(t,e))||(a.push(e),i=!0)};if(n.kind===`file`){let s=e.find(e=>rl(e)&&e.docName===t.path);return o({kind:`document`,docName:n.path,docExt:s?.docExt??t.docExt,size:s?.size??0,modified:r}),i?a:e}let s=e.find(e=>nl(e)&&e.path===t.path);o({kind:`folder`,path:n.path,size:s?.size??0,modified:r});let c=new Set(n.duplicatedDocNames);for(let i of e){if(rl(i)){let e=BN(i.docName,t.path,n.path);e&&c.has(e)&&o({...i,docName:e,modified:r});continue}if(nl(i)){let e=zN(i.path,t.path,n.path);e&&o({...i,path:e,modified:r})}}return i?a:e}function PN(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}function FN(e,t,n){return e.flatMap(e=>t===e.toDocName||!n(e.toDocName)?[e.fromDocName]:[e.fromDocName,e.toDocName])}function IN(e,t){let n=e.kind===`file`?Vu(e.path,e.docExt):e.path;return na(t.contentDir,n,t.pathSeparator)}function LN(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 RN(e,t){return rl(e)&&rl(t)?e.docName===t.docName:nl(e)&&nl(t)||al(e)&&al(t)?e.path===t.path:!1}function zN(e,t,n){return e===t?n:BN(e,t,n)}function BN(e,t,n){return e.startsWith(`${t}/`)?`${n}${e.slice(t.length)}`:null}function VN(e,t){return!!t&&(e===t||e.startsWith(`${t}/`))}function HN(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)(Cp,{"data-slot":`context-menu`,...n}),t[2]=n,t[3]=r),r}function UN(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)(wp,{"data-slot":`context-menu-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function WN(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)(Dp,{"data-slot":`context-menu-group`,...n}),t[2]=n,t[3]=r),r}function GN(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)(Np,{"data-slot":`context-menu-sub`,...n}),t[2]=n,t[3]=r),r}function KN(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 motion-reduce:data-open:animate-none motion-reduce:data-closed:animate-none motion-reduce:duration-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Tp,{children:(0,Z.jsx)(Ep,{"data-slot":`context-menu-content`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function qN(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)(kp,{"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 JN(e){let t=(0,$.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,inset:i,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=Y(`flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,r),t[5]=r,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(qi,{className:`ml-auto`}),t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==a||t[11]!==o?(c=(0,Z.jsxs)(Pp,{"data-slot":`context-menu-sub-trigger`,"data-inset":i,className:o,...a,children:[n,s]}),t[8]=n,t[9]=i,t[10]=a,t[11]=o,t[12]=c):c=t[12],c}function YN(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-32 origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg border bg-popover p-1 text-popover-foreground shadow-lg data-[state=closed]:overflow-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 motion-reduce:data-open:animate-none motion-reduce:data-closed:animate-none motion-reduce:duration-0 subtle-scrollbar`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Fp,{"data-slot":`context-menu-sub-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function XN(e){let t=(0,$.c)(15),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:i,children:r,checked:n,inset:a,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===i?s=t[7]:(s=Y(`relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,i),t[6]=i,t[7]=s);let c;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(`span`,{className:`pointer-events-none absolute right-2`,children:(0,Z.jsx)(jp,{children:(0,Z.jsx)(Wi,{})})}),t[8]=c):c=t[8];let l;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==s?(l=(0,Z.jsxs)(Ap,{"data-slot":`context-menu-checkbox-item`,"data-inset":a,className:s,checked:n,...o,children:[c,r]}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=s,t[14]=l):l=t[14],l}function ZN(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,inset:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=Y(`px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,Z.jsx)(Op,{"data-slot":`context-menu-label`,"data-inset":r,className:a,...i}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function QN(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)(Mp,{"data-slot":`context-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var $N=`mr-1.5 flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm text-muted-foreground outline-none transition hover:bg-foreground/10 hover:text-foreground hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/50`,eP=`border-border bg-background text-foreground hover:bg-background focus-visible:bg-background`,tP={start:[Zo.Space],cancel:[Zo.Esc],end:[Zo.Space,Zo.Enter]};function nP(e){return Y($N,e?`opacity-100`:`pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100`)}function rP(e){return e?void 0:-1}function iP({className:e,isDragging:t}){return Y(e,t&&eP)}function aP(e){return e.code===Zo.Enter&&e.target===e.currentTarget}function oP({event:e,hasKeyboardActivation:t,isDragging:n}){return e.defaultPrevented?`ignore`:!n&&t&&aP(e)?`activate-tab`:`delegate-sortable`}function sP({activeWidth:e,isDragging:t,outerStyle:n,transform:r,transition:i}){let a=t&&e?e:void 0;return{...n,transform:ns.Transform.toString(r?{...r,scaleX:1,scaleY:1}:null),transition:i,flexBasis:a??n?.flexBasis,maxWidth:a??n?.maxWidth,minWidth:a??n?.minWidth,opacity:n?.opacity,width:a??n?.width,zIndex:t?20:n?.zIndex}}function cP(e){let t=e?.querySelectorAll(`[data-editor-tab-sortable]`)??[],n=1/0,r=-1/0;for(let e of t){let t=e.getBoundingClientRect();n=Math.min(n,t.left),r=Math.max(r,t.right)}return Number.isFinite(n)&&Number.isFinite(r)?{left:n,right:r}:null}function lP(e){return({activeNodeRect:t,transform:n})=>{let r={...n,y:0};if(!e||!t)return r;let i=e.left-t.left,a=e.right-t.right;return r.x=Math.min(Math.max(r.x,i),a),r}}var uP=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(r){let e=1/0,i=-1/0,a=null,o=null;for(let r of t){let t=n.get(r.id);t&&(t.left<e&&(e=t.left,a=r),t.right>i&&(i=t.right,o=r))}if(!Number.isFinite(e)||!Number.isFinite(i))return[];let s=r.x<e?a:r.x>i?o:null;if(s)return[{id:s.id,data:{droppableContainer:s,value:0}}]}return Go(e)},dP=[`.md`,`.mdx`],fP=`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`,pP=`z-10 rounded-t-lg rounded-b-none border-border border-b-0 bg-background text-foreground`,mP=Y(pP,`bg-transparent hover:bg-muted focus-visible:bg-muted border-transparent hover:border-border focus-visible:border-border`),hP=`flex h-full min-w-0 flex-1 cursor-pointer items-center overflow-hidden px-3 text-left text-[13px]`;function gP(e){return e.replace(/[^A-Za-z0-9_-]/g,`-`)}function _P(e){let t=yl(e);window.location.hash!==t&&(window.location.hash=t)}function vP(e){Math.abs(e.deltaX)>=Math.abs(e.deltaY)||e.currentTarget.scrollWidth<=e.currentTarget.clientWidth||(e.preventDefault(),e.currentTarget.scrollLeft+=e.deltaY)}function yP(e,t){let n=[t,...dP].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 bP(e){return e.metaKey||e.ctrlKey}var xP=1e3;function SP(e,t){return e<0||e>=t?null:e<8?String(e+1):e===t-1?`9`:null}function CP(e,t){return SP(e,t)}function wP(e,t){let n=SP(e,t);if(n)return[`Meta+${n}`,`Control+${n}`].join(` `)}function TP(e,t){if(!bP(e)||e.altKey||e.shiftKey||!/^[1-9]$/.test(e.key))return null;let n=Number(e.key);if(n===9)return t>0?t-1:null;let r=n-1;return r<Math.min(8,t)?r:null}function EP(e){let t=(0,$.c)(3),{value:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=Y(nP(!0),`font-mono tabular-nums hover:bg-transparent animate-in fade-in-0 zoom-in-95 duration-150 motion-reduce:animate-none motion-reduce:duration-0`),t[0]=r):r=t[0];let i=`⌘${n}`,a;return t[1]===i?a=t[2]:(a=(0,Z.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`editor-tab-shortcut-hint`,className:r,children:(0,Z.jsx)(P,{className:`text-[10px]`,children:i})}),t[1]=i,t[2]=a),a}function DP(e){let t=(0,$.c)(37),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({activateFromKeyboard:n,className:r,tabId:l,disabled:i,onKeyDown:a,ref:o,style:s,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u;t[9]!==i||t[10]!==l?(u={id:l,disabled:i},t[9]=i,t[10]=l,t[11]=u):u=t[11];let{attributes:d,listeners:f,rect:p,setNodeRef:m,transform:h,transition:g,isDragging:_}=es(u),v=p.current?.width,y;t[12]!==_||t[13]!==s||t[14]!==v||t[15]!==h||t[16]!==g?(y=sP({activeWidth:v,isDragging:_,outerStyle:s,transform:h,transition:g}),t[12]=_,t[13]=s,t[14]=v,t[15]=h,t[16]=g,t[17]=y):y=t[17];let b=y,x;t[18]!==o||t[19]!==m?(x=function(e){m(e),typeof o==`function`?o(e):o&&`current`in o&&(o.current=e)},t[18]=o,t[19]=m,t[20]=x):x=t[20];let S=x,C=f?.onKeyDown,w;t[21]!==n||t[22]!==_||t[23]!==a||t[24]!==C?(w=function(e){a?.(e);let t=oP({event:e,hasKeyboardActivation:!!n,isDragging:_});if(t!==`ignore`){if(t===`activate-tab`&&n){e.preventDefault(),n();return}C?.(e)}},t[21]=n,t[22]=_,t[23]=a,t[24]=C,t[25]=w):w=t[25];let T=w,E;t[26]!==r||t[27]!==_?(E=iP({className:r,isDragging:_}),t[26]=r,t[27]=_,t[28]=E):E=t[28];let D;return t[29]!==d||t[30]!==S||t[31]!==T||t[32]!==f||t[33]!==c||t[34]!==b||t[35]!==E?(D=(0,Z.jsx)(`div`,{ref:S,"data-editor-tab-sortable":``,className:E,style:b,...c,...d,...f,onKeyDown:T}),t[29]=d,t[30]=S,t[31]=T,t[32]=f,t[33]=c,t[34]=b,t[35]=E,t[36]=D):D=t[36],D}function OP(e){let t=(0,$.c)(52),{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=Ht(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?(_=Ht(s,l),t[10]=s,t[11]=l,t[12]=_):_=t[12];let v=_,y;t[13]===n?y=t[14]:(y=(0,Z.jsx)(UN,{asChild:!0,children:n}),t[13]=n,t[14]=y);let b;t[15]!==r||t[16]!==u?(b=()=>r(u),t[15]=r,t[16]=u,t[17]=b):b=t[17];let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(J,{id:`yz7wBu`}),t[18]=x):x=t[18];let S;t[19]!==m||t[20]!==b?(S=(0,Z.jsx)(qN,{disabled:m,onSelect:b,children:x}),t[19]=m,t[20]=b,t[21]=S):S=t[21];let C=g.length===0,w;t[22]!==i||t[23]!==g?(w=()=>{i(g)},t[22]=i,t[23]=g,t[24]=w):w=t[24];let T;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(J,{id:`omXJcU`}),t[25]=T):T=t[25];let E;t[26]!==C||t[27]!==w?(E=(0,Z.jsx)(qN,{disabled:C,onSelect:w,children:T}),t[26]=C,t[27]=w,t[28]=E):E=t[28];let D=v.length===0,O;t[29]!==v||t[30]!==i?(O=()=>{i(v)},t[29]=v,t[30]=i,t[31]=O):O=t[31];let k;t[32]===l.length?k=t[33]:(k=l.length?(0,Z.jsx)(J,{id:`U2Kx6T`}):(0,Z.jsx)(J,{id:`WyXG7w`}),t[32]=l.length,t[33]=k);let A;t[34]!==D||t[35]!==O||t[36]!==k?(A=(0,Z.jsx)(qN,{disabled:D,"data-testid":`editor-tab-context-close-all`,onSelect:O,children:k}),t[34]=D,t[35]=O,t[36]=k,t[37]=A):A=t[37];let j;t[38]!==f||t[39]!==m||t[40]!==c||t[41]!==u||t[42]!==d?(j=f&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(QN,{}),(0,Z.jsx)(qN,{"data-testid":`editor-tab-context-pin-toggle`,onSelect:()=>m?d(u):c(u),children:m?(0,Z.jsx)(J,{id:`SYfHmN`}):(0,Z.jsx)(J,{id:`3pU8e-`})})]}),t[38]=f,t[39]=m,t[40]=c,t[41]=u,t[42]=d,t[43]=j):j=t[43];let M;t[44]!==E||t[45]!==A||t[46]!==j||t[47]!==S?(M=(0,Z.jsxs)(KN,{className:`min-w-40`,children:[S,E,A,j]}),t[44]=E,t[45]=A,t[46]=j,t[47]=S,t[48]=M):M=t[48];let N;return t[49]!==M||t[50]!==y?(N=(0,Z.jsxs)(HN,{children:[y,M]}),t[49]=M,t[50]=y,t[51]=N):N=t[51],N}function kP(e){let t=(0,$.c)(28),{accessibleLabel:n,closeTab:r,forceCloseVisible:i,isActive:a,isPinned:o,shortcutHint:s,tabId:c,unpinTab:l}=e,u=i===void 0?!1:i,d=s===void 0?null:s,{_:f}=$t();if(d){let e;return t[0]===d?e=t[1]:(e=(0,Z.jsx)(EP,{value:d}),t[0]=d,t[1]=e),e}if(o){let e;t[2]!==f||t[3]!==n?(e=f({id:`t18QYR`,values:{accessibleLabel:n}}),t[2]=f,t[3]=n,t[4]=e):e=t[4];let r;t[5]!==c||t[6]!==l?(r=e=>{e.stopPropagation(),l(c)},t[5]=c,t[6]=l,t[7]=r):r=t[7];let i;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(df,{"aria-hidden":`true`}),t[8]=i):i=t[8];let a;return t[9]!==e||t[10]!==r?(a=(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":e,"data-testid":`editor-tab-unpin-button`,className:`mr-1.5 text-primary! hover:bg-primary/10!`,onClick:r,children:i}),t[9]=e,t[10]=r,t[11]=a):a=t[11],a}let p;t[12]!==f||t[13]!==n?(p=f({id:`JLzQi_`,values:{accessibleLabel:n}}),t[12]=f,t[13]=n,t[14]=p):p=t[14];let m=u||a,h;t[15]===m?h=t[16]:(h=nP(m),t[15]=m,t[16]=h);let g;t[17]===a?g=t[18]:(g=rP(a),t[17]=a,t[18]=g);let _;t[19]!==r||t[20]!==c?(_=e=>{e.stopPropagation(),r(c)},t[19]=r,t[20]=c,t[21]=_):_=t[21];let v;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(Cs,{"aria-hidden":`true`}),t[22]=v):v=t[22];let y;return t[23]!==p||t[24]!==h||t[25]!==g||t[26]!==_?(y=(0,Z.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":p,"data-testid":`editor-tab-close-button`,className:h,tabIndex:g,onClick:_,children:v}),t[23]=p,t[24]=h,t[25]=g,t[26]=_,t[27]=y):y=t[27],y}function AP(e){let t=(0,$.c)(1),{hasConflict:n}=e;if(!n)return null;let r;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(Yi,{"aria-hidden":`true`,"data-testid":`editor-tab-conflict-badge`,className:`mr-1 size-3.5 shrink-0 text-amber-500`}),t[0]=r):r=t[0],r}function jP(e){let t=(0,$.c)(27),{accessibleLabel:n,activateTab:r,baseName:i,docName:a,enterRenameMode:o,extension:s,hideDocExtension:c,tabId:l}=e,{_:u}=$t(),d=cw(a)===`conflict`,f;t[0]!==u||t[1]!==n||t[2]!==d?(f=d?u({id:`mVFyH-`,values:{accessibleLabel:n}}):n,t[0]=u,t[1]=n,t[2]=d,t[3]=f):f=t[3];let p=f,m;t[4]!==r||t[5]!==l?(m=()=>{r(l)},t[4]=r,t[5]=l,t[6]=m):m=t[6];let h;t[7]!==a||t[8]!==o||t[9]!==l?(h=e=>{e.preventDefault(),e.stopPropagation(),o(l,a)},t[7]=a,t[8]=o,t[9]=l,t[10]=h):h=t[10];let g;t[11]===d?g=t[12]:(g=(0,Z.jsx)(AP,{hasConflict:d}),t[11]=d,t[12]=g);let _;t[13]===i?_=t[14]:(_=(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:i}),t[13]=i,t[14]=_);let v;t[15]!==s||t[16]!==c?(v=!c&&(0,Z.jsx)(`span`,{className:`shrink-0`,children:s}),t[15]=s,t[16]=c,t[17]=v):v=t[17];let y;t[18]!==_||t[19]!==v?(y=(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center`,children:[_,v]}),t[18]=_,t[19]=v,t[20]=y):y=t[20];let b;return t[21]!==p||t[22]!==m||t[23]!==h||t[24]!==g||t[25]!==y?(b=(0,Z.jsxs)(`button`,{type:`button`,"aria-label":p,title:p,className:hP,onClick:m,onDoubleClick:h,tabIndex:-1,children:[g,y]}),t[21]=p,t[22]=m,t[23]=h,t[24]=g,t[25]=y,t[26]=b):b=t[26],b}function MP(){let e=(0,$.c)(94),{activeDocName:t,activeTabId:n,activeNewTabId:r,activeTarget:i,activateTab:a,activateNewTab:o,closeAndClearForRename:s,closeNewTab:c,closeTab:l,closeTabs:u,getPoolActiveDocName:d,poolHas:f,isNewTabActive:p,newTabIds:m,openNewTab:g,openTabs:_,pinTab:y,pinnedTabIds:b,reopenClosedTab:x,remapTabsForRename:S,reorderTabs:C,unpinTab:w,visibleTabIds:T}=mt(),{_:E}=$t(),{pageMeta:D}=Xi(),O=(0,Q.useRef)(null),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(null),[N,P]=(0,Q.useState)(``),[F,I]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(!1),[z,B]=(0,Q.useState)(!1),V=(0,Q.useRef)(null),H=(0,Q.useRef)(!1),U=(0,Q.useRef)(!1),W=(0,Q.useRef)(null),G=(0,Q.useRef)(t),K=(0,Q.useRef)(null),ee=(0,Q.useRef)(!1),te=(0,Q.useRef)(!1),ne;e[0]!==n||e[1]!==t||e[2]!==i?(ne=n??(i?se(i):t?Ee(t):null),e[0]=n,e[1]=t,e[2]=i,e[3]=ne):ne=e[3];let re=ne,ie;e[4]!==r||e[5]!==re||e[6]!==p||e[7]!==m||e[8]!==_?(ie=p?`${r??`__new-tab__`}\u0000${_.join(`\0`)}\u0000${m.join(`\0`)}`:re?`${re}\u0000${_.join(`\0`)}`:``,e[4]=r,e[5]=re,e[6]=p,e[7]=m,e[8]=_,e[9]=ie):ie=e[9];let ae=ie,oe,ce;e[10]===t?(oe=e[11],ce=e[12]):(oe=()=>{G.current=t},ce=[t],e[10]=t,e[11]=oe,e[12]=ce),(0,Q.useEffect)(oe,ce);let le,q;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>()=>{K.current!==null&&(window.clearTimeout(K.current),K.current=null)},q=[],e[13]=le,e[14]=q):(le=e[13],q=e[14]),(0,Q.useEffect)(le,q);let ue,de;e[15]===ae?(ue=e[16],de=e[17]):(ue=()=>{ae&&(O.current?.querySelector(`[data-active-tab="true"]`))?.scrollIntoView({block:`nearest`,inline:`nearest`})},de=[ae],e[15]=ae,e[16]=ue,e[17]=de),(0,Q.useEffect)(ue,de);let fe,pe;e[18]===j?(fe=e[19],pe=e[20]):(fe=()=>{j&&(V.current?.focus(),V.current?.select())},pe=[j],e[18]=j,e[19]=fe,e[20]=pe),(0,Q.useEffect)(fe,pe);let me,he;e[21]!==_||e[22]!==j?(me=()=>{!j||_.includes(j.tabId)||(U.current=!0,W.current=null,M(null),P(``),I(null),R(!1))},he=[_,j],e[21]=_,e[22]=j,e[23]=me,e[24]=he):(me=e[23],he=e[24]),(0,Q.useEffect)(me,he);let ge;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(ge=function(e,t){let n=t.split(`/`);U.current=!1,W.current=null,M({docName:t,tabId:e}),P(n[n.length-1]),I(null)},e[25]=ge):ge=e[25];let _e=ge,ve=function(){U.current=!0,W.current=null,M(null),P(``),I(null),R(!1)},ye=async function(){if(U.current){U.current=!1;return}if(H.current)return;let e=j?.docName;if(!e){ve();return}let t=DN(`file`,yP(N,D.get(e)?.docExt??`.md`)),n=e.split(`/`),r=n[n.length-1];if(t===r){ve();return}if(t===W.current){V.current?.focus();return}if(!ON(t)){I(E({id:`P8yDjG`})),V.current?.focus();return}let i=kN({kind:`file`,path:e,name:r},t);H.current=!0,R(!0),I(null);try{let n=await fetch(`/api/rename-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:`file`,fromPath:e,toPath:i})});if(U.current){R(!1),H.current=!1;return}let r=await ht(n,`Server error (HTTP ${n.status})`);if(!r.ok){I(r.title),R(!1),H.current=!1,W.current=t,V.current?.focus();return}let a=Ot(Dr,r.body,`rename-path:tab`,{renamed:[],renamedAssets:[]}).renamed,o=G.current,c=PN(o,a);v(a);let l=!0;try{let e=FN(a,d(),f);await Promise.all(e.map(e=>s(e))),S(a),qc([`files`,`backlinks`,`graph`])}catch(n){let r=n;l=!1,console.warn(`[EditorTabs] post-rename reconciliation failed`,{err:r,docName:e,newDocName:i,normalized:t}),Ss.error(E({id:`MUBR8r`}))}U.current=!0,M(null),P(``),I(null),R(!1),H.current=!1,W.current=null,l&&c&&c!==o&&_P(c)}catch(n){console.warn(`[EditorTabs] rename failed`,{err:n,docName:e,newDocName:i,normalized:t}),I(E({id:`HIb0vl`})),R(!1),H.current=!1,W.current=t,V.current?.focus()}},be=typeof window<`u`&&window.okDesktop!=null,xe;e[26]===m?xe=e[27]:(xe=new Set(m),e[26]=m,e[27]=xe);let Se=xe,Ce;e[28]===k?Ce=e[29]:(Ce=lP(k),e[28]=k,e[29]=Ce);let we;e[30]===Ce?we=e[31]:(we=[Ce],e[30]=Ce,e[31]=we);let Te=we,De;e[32]!==c||e[33]!==u||e[34]!==Se?(De=function(e){let t=[],n=[];for(let r of e)Se.has(r)?n.push(r):t.push(r);t.length>0&&u(t);for(let e of n)c(e)},e[32]=c,e[33]=u,e[34]=Se,e[35]=De):De=e[35];let Oe=De,ke,Ae;e[36]!==o||e[37]!==a||e[38]!==r||e[39]!==re||e[40]!==p||e[41]!==m||e[42]!==g||e[43]!==x||e[44]!==T?(ke=()=>{let e=new Set(m),t=function(){K.current!==null&&(window.clearTimeout(K.current),K.current=null)},n=function(e){ee.current!==e&&(ee.current=e)},i=function(e){te.current!==e&&(te.current=e,B(e))},s=function(){n(!0),!(te.current||K.current!==null)&&(K.current=window.setTimeout(()=>{K.current=null,ee.current&&i(!0)},xP))},c=function(){t(),n(!1),i(!1)},l=function(t){e.has(t)?o(t):a(t)},u=function(e){if(T.length===0)return;let t=p?r:re,n=t?T.indexOf(t):-1;l(T[((n>=0?n:0)+e+T.length)%T.length])},d=function(e){if(bP(e)&&s(),Al(e,`tab-new`)){e.preventDefault(),g();return}if(Al(e,`tab-reopen-closed`)){e.preventDefault(),x();return}if(Al(e,`tab-next`)){e.preventDefault(),u(1);return}if(Al(e,`tab-previous`)){e.preventDefault(),u(-1);return}let t=TP(e,T.length);t!==null&&(e.preventDefault(),l(T[t]))},f=function(e){!e.metaKey&&!e.ctrlKey&&c()};return window.addEventListener(`keydown`,d,{capture:!0}),window.addEventListener(`keyup`,f,{capture:!0}),window.addEventListener(`blur`,c),document.addEventListener(`visibilitychange`,c),()=>{window.removeEventListener(`keydown`,d,{capture:!0}),window.removeEventListener(`keyup`,f,{capture:!0}),window.removeEventListener(`blur`,c),document.removeEventListener(`visibilitychange`,c)}},Ae=[r,re,o,a,p,m,g,x,T],e[36]=o,e[37]=a,e[38]=r,e[39]=re,e[40]=p,e[41]=m,e[42]=g,e[43]=x,e[44]=T,e[45]=ke,e[46]=Ae):(ke=e[45],Ae=e[46]),(0,Q.useEffect)(ke,Ae);let Me;e[47]===Symbol.for(`react.memo_cache_sentinel`)?(Me={activationConstraint:{distance:8}},e[47]=Me):Me=e[47];let Ne;e[48]===Symbol.for(`react.memo_cache_sentinel`)?(Ne={coordinateGetter:Jo,keyboardCodes:tP},e[48]=Ne):Ne=e[48];let Pe=ts(Ho(Ko,Me),Ho(Yo,Ne)),Fe=z,Ie;e[49]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=function(){A(cP(O.current))},e[49]=Ie):Ie=e[49];let Le=Ie,Re;e[50]===Symbol.for(`react.memo_cache_sentinel`)?(Re=function(){A(null)},e[50]=Re):Re=e[50];let ze=Re,Be;e[51]!==ze||e[52]!==C||e[53]!==T?(Be=function(e){ze();let t=String(e.active.id),n=e.over?String(e.over.id):null;if(!n||t===n)return;let r=T.indexOf(t),i=T.indexOf(n);r<0||i<0||r===i||C(Qo([...T],r,i),t)},e[51]=ze,e[52]=C,e[53]=T,e[54]=Be):Be=e[54];let Ve=Be,He=be?``:void 0,Ue;e[55]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=Y(`pl-2 flex h-12 min-w-0 touch-manipulation flex-1 items-end overflow-x-auto overflow-y-hidden overscroll-x-contain scroll-fade-mask-x [scrollbar-width:none]`,be&&`[-webkit-app-region:drag]`),e[55]=Ue):Ue=e[55];let We=vP,Ge;e[56]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=Y(`flex items-end gap-1`,be&&`[-webkit-app-region:no-drag]`),e[56]=Ge):Ge=e[56];let Ke=Wo,qe=uP,Je;e[57]===Symbol.for(`react.memo_cache_sentinel`)?(Je={container:typeof document<`u`?document.body:void 0},e[57]=Je):Je=e[57];let Ye=Xo,Xe;e[58]===T?Xe=e[59]:(Xe=[...T],e[58]=T,e[59]=Xe);let Ze=Uo,Qe=T.map((e,t)=>{let n=z?CP(t,T.length):null,i=wP(t,T.length);if(Se.has(e)){let t=e===r;return(0,Z.jsx)(OP,{tabId:e,canPin:!1,openTabs:T,closeTab:c,closeTabs:Oe,pinTab:y,pinnedTabIds:b,unpinTab:w,children:(0,Z.jsxs)(DP,{tabId:e,activateFromKeyboard:()=>o(e),"aria-current":t?`page`:void 0,"aria-keyshortcuts":i,"data-active-tab":t?`true`:void 0,className:Y(fP,t?pP:mP),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":E({id:`zLak8b`}),"data-testid":`editor-new-tab-placeholder-button`,className:hP,onClick:()=>o(e),tabIndex:-1,children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:(0,Z.jsx)(J,{id:`3YvS-c`})})}),n?(0,Z.jsx)(EP,{value:n}):(0,Z.jsx)(`button`,{type:`button`,"aria-label":E({id:`xCdTnb`}),"data-testid":`editor-new-tab-placeholder-close`,className:nP(Fe||t),tabIndex:rP(t),onClick:t=>{t.stopPropagation(),c(e)},children:(0,Z.jsx)(Cs,{"aria-hidden":`true`,className:`size-3.5`})})]})},e)}let s=je(e),u=e===re,d=b.includes(e);if(s.kind===`folder`){let{baseName:t,label:r,prefix:o}=h(s.folderPath,`/`),c=`${o}${r}`;return(0,Z.jsx)(OP,{tabId:e,openTabs:T,closeTab:l,closeTabs:Oe,pinTab:y,pinnedTabIds:b,unpinTab:w,children:(0,Z.jsxs)(DP,{tabId:e,activateFromKeyboard:()=>a(e),"aria-current":u?`page`:void 0,"aria-keyshortcuts":i,"data-active-tab":u?`true`:void 0,className:Y(fP,u?pP:mP),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":c,title:c,className:hP,onClick:()=>{a(e)},tabIndex:-1,children:[o&&(0,Z.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate`,u&&`text-muted-foreground`),children:o}),(0,Z.jsxs)(`span`,{className:Y(`flex min-w-0 items-center`,o?`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)(kP,{accessibleLabel:c,closeTab:l,forceCloseVisible:Fe,isActive:u,isPinned:d,shortcutHint:n,tabId:e,unpinTab:w})]})},e)}if(s.kind===`asset`||s.kind===`skill-file`){let{baseName:t,label:r,prefix:o}=h(s.kind===`asset`?s.assetPath:s.path,``),c=`${o}${r}`;return(0,Z.jsx)(OP,{tabId:e,openTabs:T,closeTab:l,closeTabs:Oe,pinTab:y,pinnedTabIds:b,unpinTab:w,children:(0,Z.jsxs)(DP,{tabId:e,activateFromKeyboard:()=>a(e),"aria-current":u?`page`:void 0,"aria-keyshortcuts":i,"data-active-tab":u?`true`:void 0,className:Y(fP,u?pP:mP),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":c,className:hP,onClick:()=>{a(e)},tabIndex:-1,children:[o?(0,Z.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate text-muted-foreground/60`,u&&`text-muted-foreground`),children:o}):null,(0,Z.jsx)(`span`,{className:Y(`min-w-0 truncate`,o?`max-w-[70%] shrink-0`:`flex-1`),children:t})]}),(0,Z.jsx)(kP,{accessibleLabel:c,closeTab:l,forceCloseVisible:Fe,isActive:u,isPinned:d,shortcutHint:n,tabId:e,unpinTab:w})]})},e)}let f=s.docName,p=D.get(f)?.docExt??`.md`,{baseName:m,extension:g,label:_,prefix:v}=h(f,p),x=`${v}${_}`,S=p===`.md`||p===`.mdx`,C=j?.tabId===e,O=`editor-tab-rename-error-${gP(f)}`;return(0,Z.jsx)(OP,{disabled:C,tabId:e,openTabs:T,closeTab:l,closeTabs:Oe,pinTab:y,pinnedTabIds:b,unpinTab:w,children:(0,Z.jsx)(DP,{tabId:e,activateFromKeyboard:()=>a(e),disabled:C,"aria-current":u?`page`:void 0,"aria-keyshortcuts":i,"data-active-tab":u?`true`:void 0,className:Y(fP,u?pP:mP,C&&F&&`border-destructive`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!d&&l(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:C?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(zC,{className:`h-full min-w-0 flex-1 rounded-none border-0 bg-transparent dark:bg-transparent`,children:[(0,Z.jsx)(WC,{ref:V,value:N,disabled:L,"aria-label":E({id:`Dw1T_W`,values:{label:_}}),"data-testid":`editor-tab-rename-input`,"aria-invalid":F?!0:void 0,"aria-describedby":F?O:void 0,"aria-busy":L||void 0,title:F??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=>{P(yP(e.target.value,p)),I(null),W.current=null},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),ye()):e.key===`Escape`&&(e.preventDefault(),ve())},onBlur:ye}),(0,Z.jsx)(VC,{align:`inline-end`,"aria-hidden":`true`,className:`pr-2 text-xs`,children:(0,Z.jsx)(UC,{className:`text-muted-foreground/60 text-xs`,children:p})})]}),F?(0,Z.jsx)(`span`,{id:O,role:`alert`,className:`sr-only`,children:F}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(jP,{accessibleLabel:x,activateTab:a,baseName:m,docName:f,enterRenameMode:_e,extension:g,hideDocExtension:S,tabId:e}),(0,Z.jsx)(kP,{accessibleLabel:x,closeTab:l,forceCloseVisible:Fe,isActive:u,isPinned:d,shortcutHint:n,tabId:e,unpinTab:w})]})})},e)}),$e;e[60]!==Ye||e[61]!==Xe||e[62]!==Ze||e[63]!==Qe?($e=(0,Z.jsx)(Ye,{items:Xe,strategy:Ze,children:Qe}),e[60]=Ye,e[61]=Xe,e[62]=Ze,e[63]=Qe,e[64]=$e):$e=e[64];let et;e[65]!==Ke||e[66]!==ze||e[67]!==Ve||e[68]!==Le||e[69]!==Pe||e[70]!==!1||e[71]!==qe||e[72]!==Je||e[73]!==$e||e[74]!==Te?(et=(0,Z.jsx)(Ke,{sensors:Pe,autoScroll:!1,collisionDetection:qe,modifiers:Te,onDragStart:Le,onDragEnd:Ve,onDragCancel:ze,accessibility:Je,children:$e}),e[65]=Ke,e[66]=ze,e[67]=Ve,e[68]=Le,e[69]=Pe,e[70]=!1,e[71]=qe,e[72]=Je,e[73]=$e,e[74]=Te,e[75]=et):et=e[75];let tt;e[76]===E?tt=e[77]:(tt=E({id:`3YvS-c`}),e[76]=E,e[77]=tt);let nt;e[78]===Symbol.for(`react.memo_cache_sentinel`)?(nt=(0,Z.jsx)(Zt,{"aria-hidden":`true`}),e[78]=nt):nt=e[78];let rt;e[79]!==g||e[80]!==tt?(rt=(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(X,{type:`button`,size:`icon-xs`,variant:`ghost`,"aria-label":tt,"data-testid":`editor-new-tab-button`,className:`first:mb-3 mb-1.5`,onClick:g,children:nt})}),e[79]=g,e[80]=tt,e[81]=rt):rt=e[81];let it;e[82]===Symbol.for(`react.memo_cache_sentinel`)?(it=(0,Z.jsx)(Ns,{children:(0,Z.jsx)(J,{id:`3YvS-c`})}),e[82]=it):it=e[82];let at;e[83]===rt?at=e[84]:(at=(0,Z.jsxs)(Fs,{children:[rt,it]}),e[83]=rt,e[84]=at);let ot;e[85]!==Ge||e[86]!==et||e[87]!==at?(ot=(0,Z.jsxs)(`div`,{className:Ge,children:[et,at]}),e[85]=Ge,e[86]=et,e[87]=at,e[88]=ot):ot=e[88];let st;return e[89]!==He||e[90]!==Ue||e[91]!==We||e[92]!==ot?(st=(0,Z.jsx)(`div`,{ref:O,"data-electron-drag":He,className:Ue,onWheel:We,children:ot}),e[89]=He,e[90]=Ue,e[91]=We,e[92]=ot,e[93]=st):st=e[93],st}var NP=(e,t,n)=>{if(e&&`reportValidity`in e){let r=io(n,t);e.setCustomValidity(r&&r.message||``),e.reportValidity()}},PP=(e,t)=>{for(let n in t.fields){let r=t.fields[n];r&&r.ref&&`reportValidity`in r.ref?NP(r.ref,n,e):r&&r.refs&&r.refs.forEach(t=>NP(t,n,e))}},FP=(e,t)=>{t.shouldUseNativeValidation&&PP(e,t);let n={};for(let r in e){let i=io(t.fields,r),a=Object.assign(e[r]||{},{ref:i&&i.ref});if(IP(t.names||Object.keys(e),r)){let e=Object.assign({},io(n,r));Da(e,`root`,a),Da(n,r,e)}else Da(n,r,a)}return n},IP=(e,t)=>{let n=LP(t).replace(/[.*+?^${}()|\\]/g,`\\$&`);return e.some(e=>LP(e).match(`^${n}\\.\\d+`))};function LP(e){return e.replace(/[\[\]]/g,``)}function RP(){return RP=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},RP.apply(null,arguments)}function zP(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}function BP(e,t){for(var n={};e.length;){var r=e[0],i=r.code,a=r.message,o=r.path.join(`.`);if(!n[o])if(`unionErrors`in r){var s=r.unionErrors[0].errors[0];n[o]={message:s.message,type:s.code}}else n[o]={message:a,type:i};if(`unionErrors`in r&&r.unionErrors.forEach(function(t){return t.errors.forEach(function(t){return e.push(t)})}),t){var c=n[o].types,l=c&&c[r.code];n[o]=La(o,t,n,i,l?[].concat(l,r.message):r.message)}e.shift()}return n}function VP(e,t){for(var n={},r=function(){var r=e[0],i=r.code,a=r.message,o=r.path.join(`.`);if(!n[o])if(r.code===`invalid_union`&&r.errors.length>0){var s=r.errors[0][0];n[o]={message:s.message,type:s.code}}else n[o]={message:a,type:i};if(r.code===`invalid_union`&&r.errors.forEach(function(t){return t.forEach(function(t){return e.push(RP({},t,{path:[].concat(r.path,t.path)}))})}),t){var c=n[o].types,l=c&&c[r.code];n[o]=La(o,t,n,i,l?[].concat(l,r.message):r.message)}e.shift()};e.length;)r();return n}function HP(e,t,n){if(n===void 0&&(n={}),function(e){return`_def`in e&&typeof e._def==`object`&&`typeName`in e._def}(e))return function(r,i,a){try{return Promise.resolve(zP(function(){return Promise.resolve(e[n.mode===`sync`?`parse`:`parseAsync`](r,t)).then(function(e){return a.shouldUseNativeValidation&&PP({},a),{errors:{},values:n.raw?Object.assign({},r):e}})},function(e){if(function(e){return Array.isArray(e?.issues)}(e))return{values:{},errors:FP(BP(e.errors,!a.shouldUseNativeValidation&&a.criteriaMode===`all`),a)};throw e}))}catch(e){return Promise.reject(e)}};if(function(e){return`_zod`in e&&typeof e._zod==`object`}(e))return function(r,i,a){try{return Promise.resolve(zP(function(){return Promise.resolve((n.mode===`sync`?Yn:ur)(e,r,t)).then(function(e){return a.shouldUseNativeValidation&&PP({},a),{errors:{},values:n.raw?Object.assign({},r):e}})},function(e){if(function(e){return e instanceof mr}(e))return{values:{},errors:FP(VP(e.issues,!a.shouldUseNativeValidation&&a.criteriaMode===`all`),a)};throw e}))}catch(e){return Promise.reject(e)}};throw Error(`Invalid input: not a Zod schema`)}var UP=`https://openknowledge.ai/api/subscribe`;async function WP(e,t){try{let n=await fetch(UP,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({email:e,source:t}),signal:AbortSignal.timeout(15e3)});return n.ok?{ok:!0}:n.status===400?{ok:!1,reason:`invalid`}:n.status===503?{ok:!1,reason:`unavailable`}:(console.warn(`[subscribe] action=submit result=http-error status=${n.status}`),{ok:!1,reason:`error`})}catch(e){return console.warn(`[subscribe] action=submit result=network-error message=${e instanceof Error?e.message:String(e)}`),{ok:!1,reason:`error`}}}function GP(e){let t=(0,$.c)(49),{source:n,title:r,description:i,onSuccess:a,onDismiss:o,autoFocus:s,compactSubmit:c,className:l}=e,{_:u}=$t(),[d,f]=(0,Q.useState)(!1),p=(0,Q.useRef)(null),m,h;t[0]===d?(m=t[1],h=t[2]):(m=()=>{d&&p.current?.focus()},h=[d],t[0]=d,t[1]=m,t[2]=h),(0,Q.useEffect)(m,h);let g,_;if(t[3]!==u){let e=In({email:ir({message:u({id:`Wq6Wcm`})})});_=ro,g=HP(e),t[3]=u,t[4]=g,t[5]=_}else g=t[4],_=t[5];let v;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(v={email:``},t[6]=v):v=t[6];let y;t[7]===g?y=t[8]:(y={resolver:g,defaultValues:v},t[7]=g,t[8]=y);let b=_(y),{isSubmitting:x}=b.formState,S=b.formState.errors.email?.message??b.formState.errors.root?.message,C;t[9]!==u||t[10]!==b||t[11]!==a||t[12]!==n?(C=async function(e){b.clearErrors(`root`);let t=await WP(e.email,n);if(t.ok){f(!0),a?.();return}if(t.reason===`invalid`){b.setError(`email`,{message:u({id:`Wq6Wcm`})});return}if(t.reason===`unavailable`){b.setError(`root`,{message:u({id:`4mLBx9`})});return}b.setError(`root`,{message:u({id:`fWsBTs`})})},t[9]=u,t[10]=b,t[11]=a,t[12]=n,t[13]=C):C=t[13];let w=C,T;t[14]===l?T=t[15]:(T=Y(`flex flex-col gap-3`,l),t[14]=l,t[15]=T);let E=d?-1:void 0,D;t[16]!==d||t[17]!==r?(D=d?(0,Z.jsxs)(`span`,{className:`mb-1.5 inline-flex flex-row items-center gap-2`,children:[(0,Z.jsx)(Wi,{className:`size-4 text-primary`}),(0,Z.jsx)(J,{id:`PIMM5l`})]}):r??(0,Z.jsx)(J,{id:`GzPQ2f`}),t[16]=d,t[17]=r,t[18]=D):D=t[18];let O;t[19]!==D||t[20]!==E?(O=(0,Z.jsx)(`p`,{ref:p,tabIndex:E,className:`text-sm font-medium leading-tight text-foreground focus:outline-none`,children:D}),t[19]=D,t[20]=E,t[21]=O):O=t[21];let k;t[22]!==i||t[23]!==d?(k=d?(0,Z.jsx)(J,{id:`pBROkv`}):i??(0,Z.jsx)(J,{id:`WmPbvm`}),t[22]=i,t[23]=d,t[24]=k):k=t[24];let A;t[25]===k?A=t[26]:(A=(0,Z.jsx)(`p`,{className:`text-1sm text-muted-foreground`,role:`status`,children:k}),t[25]=k,t[26]=A);let j;t[27]!==O||t[28]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[O,A]}),t[27]=O,t[28]=A,t[29]=j):j=t[29];let M;t[30]!==u||t[31]!==o?(M=o?(0,Z.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,onClick:o,"aria-label":u({id:`yz7wBu`}),className:`-mr-1.5 -mt-1 size-7 shrink-0 text-muted-foreground opacity-60`,children:(0,Z.jsx)(Cs,{className:`size-4`})}):null,t[30]=u,t[31]=o,t[32]=M):M=t[32];let N;t[33]!==j||t[34]!==M?(N=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[j,M]}),t[33]=j,t[34]=M,t[35]=N):N=t[35];let P;t[36]!==u||t[37]!==s||t[38]!==c||t[39]!==S||t[40]!==b||t[41]!==x||t[42]!==w||t[43]!==d?(P=d?null:(0,Z.jsxs)(`form`,{onSubmit:b.handleSubmit(w),className:`flex flex-col gap-2`,noValidate:!0,children:[(0,Z.jsx)(ka,{control:b.control,name:`email`,render:e=>{let{field:t,fieldState:n}=e;return(0,Z.jsxs)(zC,{className:`h-10 rounded-xl`,children:[(0,Z.jsx)(VC,{className:`pl-2.5`,children:(0,Z.jsx)(Qd,{className:`size-4 text-muted-foreground opacity-60`})}),(0,Z.jsx)(WC,{...t,id:t.name,type:`email`,inputMode:`email`,autoComplete:`email`,spellCheck:!1,autoFocus:s,placeholder:u({id:`2hYmUH`}),"aria-invalid":n.invalid,"aria-label":u({id:`ATGYL1`}),"data-testid":`subscribe-email`,className:`placeholder:text-muted-foreground/60`}),(0,Z.jsx)(X,{type:`submit`,disabled:x,size:c?`icon`:`default`,className:Y(`mr-1 ml-auto text-1sm`,c&&`size-8 shrink-0 rounded-lg`),"data-testid":`subscribe-submit`,children:x?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ss,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`sr-only`,children:(0,Z.jsx)(J,{id:`lCC_D5`})})]}):c?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(lt,{className:`size-4`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`sr-only`,children:(0,Z.jsx)(J,{id:`EDl9kS`})})]}):(0,Z.jsx)(J,{id:`EDl9kS`})})]})}}),S?(0,Z.jsx)(`p`,{className:`text-sm text-destructive`,role:`alert`,children:S}):null]}),t[36]=u,t[37]=s,t[38]=c,t[39]=S,t[40]=b,t[41]=x,t[42]=w,t[43]=d,t[44]=P):P=t[44];let F;return t[45]!==N||t[46]!==P||t[47]!==T?(F=(0,Z.jsxs)(`div`,{className:T,children:[N,P]}),t[45]=N,t[46]=P,t[47]=T,t[48]=F):F=t[48],F}var KP=`https://github.com/inkeep/open-knowledge`,qP=`https://discord.com/invite/YujKpFN49`,JP=`https://x.com/OpenKnowledge`,YP=`ok-subscribe-card-v1`,XP={subscribed:!1,dismissed:!1,shownVersions:[]};function ZP(e,t){return!e.subscribed&&!e.dismissed&&e.shownVersions.length<3&&!e.shownVersions.includes(t)}function QP(e){return e===!0}function $P(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function eF(e){if(typeof e!=`object`||!e)return XP;let t=e;return{subscribed:QP(t.subscribed),dismissed:QP(t.dismissed),shownVersions:$P(t.shownVersions)}}function tF(e){try{let t=(e??localStorage).getItem(YP);return t==null?XP:eF(JSON.parse(t))}catch(e){return console.warn(`[subscribe-card-store] readPersistedState failed (corrupt/privacy/SSR)`,e),XP}}function nF(e,t){try{(t??localStorage).setItem(YP,JSON.stringify(e))}catch(e){console.warn(`[subscribe-card-store] writePersistedState failed (quota/privacy/SSR)`,e)}}function rF(e){let t=tF(e),n=new Set,r=!1;function i(){for(let e of n)e()}function a(n){t=n,nF(t,e),i()}return{getSnapshot(){return t},subscribe(e){return n.add(e),()=>{n.delete(e)}},markSubscribed(){t.subscribed||a({...t,subscribed:!0})},dismiss(){t.dismissed||a({...t,dismissed:!0})},recordShown(e){t.shownVersions.includes(e)||a({...t,shownVersions:[...t.shownVersions,e]})},install(){r||(r=!0,t=tF(e),i())}}}var iF=rF();function aF(){iF.install()}function oF(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 sF(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 cF(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 lF=[{key:`resources`,heading:{id:`s-MGs7`},links:[{label:{id:`TbjyhA`},href:`https://openknowledge.ai/docs`,icon:Mt},{label:{id:`PCNIuJ`},href:`${KP}/issues/new`,icon:Cd},{label:{id:`On0aF2`},href:`https://openknowledge.ai/`,icon:Zi}]},{key:`community`,heading:{id:`chL5IG`},links:[{label:`Discord`,href:qP,icon:oF},{label:`X (Twitter)`,href:JP,icon:cF},{label:`GitHub`,href:KP,icon:sF}]}],uF=`${KP}/releases`,dF=`group 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`;function fF(e){if(e<1e3)return String(e);let t=e/1e3;return`${t>=10?Math.round(t):t.toFixed(1)}k`}var pF=e=>{let t=(0,$.c)(12),{count:n}=e,{_:r}=$t(),i,a,o,s;t[0]!==r||t[1]!==n?(i=fF(n),a=`img`,o=`ml-auto flex items-center gap-1 text-xs tabular-nums text-muted-foreground`,s=r({id:`SVLPt5`,values:{formatted:i}}),t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s):(i=t[2],a=t[3],o=t[4],s=t[5]);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(Tf,{className:`size-3 fill-current`,"aria-hidden":`true`}),t[6]=c):c=t[6];let l;return t[7]!==i||t[8]!==a||t[9]!==o||t[10]!==s?(l=(0,Z.jsxs)(`span`,{role:a,className:o,"aria-label":s,children:[c,i]}),t[7]=i,t[8]=a,t[9]=o,t[10]=s,t[11]=l):l=t[11],l},mF=e=>{let t=(0,$.c)(15),{link:n,trailing:r}=e,{_:i}=$t(),{label:a,href:o,icon:s}=n,c,l;t[0]===o?(c=t[1],l=t[2]):(c=e=>du(e,o),l=e=>du(e,o),t[0]=o,t[1]=c,t[2]=l);let u;t[3]===s?u=t[4]:(u=(0,Z.jsx)(s,{"aria-hidden":`true`,className:`size-4 shrink-0`}),t[3]=s,t[4]=u);let d;t[5]!==i||t[6]!==a?(d=typeof a==`string`?a:i(a),t[5]=i,t[6]=a,t[7]=d):d=t[7];let f;return t[8]!==o||t[9]!==c||t[10]!==l||t[11]!==u||t[12]!==d||t[13]!==r?(f=(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`a`,{href:o,target:`_blank`,rel:`noopener noreferrer`,onClick:c,onAuxClick:l,className:dF,children:[u,d,r]})}),t[8]=o,t[9]=c,t[10]=l,t[11]=u,t[12]=d,t[13]=r,t[14]=f):f=t[14],f},hF=e=>{let t=(0,$.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs mb-1`,children:n}),t[0]=n,t[1]=r),r},gF=()=>{let e=(0,$.c)(28),{_:t}=$t(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(null),c,l;e[0]!==n||e[1]!==o?(c=()=>{if(!n||o!==null)return;let e=new AbortController;return Cr({signal:e.signal}).then(e=>{e!==null&&s(e)}),()=>e.abort()},l=[n,o],e[0]=n,e[1]=o,e[2]=c,e[3]=l):(c=e[2],l=e[3]),(0,Q.useEffect)(c,l);let u;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=e=>{r(e),e||a(!1)},e[4]=u):u=e[4];let d;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(et,{className:`size-4`}),e[5]=d):d=e[5];let f;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(jt,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[d,(0,Z.jsx)(`span`,{className:`sr-only`,children:(0,Z.jsx)(J,{id:`s-MGs7`})})]})})}),e[6]=f):f=e[6];let p;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsxs)(Fs,{children:[f,(0,Z.jsx)(Ns,{children:(0,Z.jsx)(J,{id:`s-MGs7`})})]}),e[7]=p):p=e[7];let m;e[8]!==t||e[9]!==o?(m=lF.map((e,n)=>(0,Z.jsxs)(`div`,{className:Y(n>0&&`mt-3`),children:[(0,Z.jsx)(hF,{children:t(e.heading)}),(0,Z.jsx)(`nav`,{"aria-label":t(e.heading),children:(0,Z.jsx)(`ul`,{className:`space-y-0.5`,children:e.links.map(e=>(0,Z.jsx)(mF,{link:e,trailing:e.href===`https://github.com/inkeep/open-knowledge`&&o!==null?(0,Z.jsx)(pF,{count:o}):void 0},e.href))})})]},e.key)),e[8]=t,e[9]=o,e[10]=m):m=e[10];let h;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(hF,{children:(0,Z.jsx)(J,{id:`arUUsK`})}),e[11]=h):h=e[11];let g;e[12]===t?g=e[13]:(g=t({id:`arUUsK`}),e[12]=t,e[13]=g);let _;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(mF,{link:{label:{id:`3ePd3I`},href:uF,icon:$d}}),e[14]=_):_=e[14];let v;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(jt,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,className:Y(dF,`h-auto w-full justify-start font-normal`),children:[(0,Z.jsx)(Qd,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,Z.jsx)(J,{id:`EDl9kS`})]})}),e[15]=v):v=e[15];let y;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(yt,{side:`left`,align:`center`,sideOffset:20,className:`w-80`,children:(0,Z.jsx)(GP,{source:`resources_menu`,autoFocus:!0,onDismiss:()=>a(!1),onSuccess:_F})}),e[16]=y):y=e[16];let b;e[17]===i?b=e[18]:(b=(0,Z.jsxs)(`ul`,{className:`space-y-0.5`,children:[_,(0,Z.jsx)(`li`,{children:(0,Z.jsxs)($e,{open:i,onOpenChange:a,children:[v,y]})})]}),e[17]=i,e[18]=b);let x;e[19]!==b||e[20]!==g?(x=(0,Z.jsxs)(`div`,{className:`mt-3`,children:[h,(0,Z.jsx)(`nav`,{"aria-label":g,children:b})]}),e[19]=b,e[20]=g,e[21]=x):x=e[21];let S;e[22]!==x||e[23]!==m?(S=(0,Z.jsxs)(yt,{align:`end`,className:`w-56 p-3`,children:[m,x]}),e[22]=x,e[23]=m,e[24]=S):S=e[24];let C;return e[25]!==n||e[26]!==S?(C=(0,Z.jsxs)($e,{open:n,onOpenChange:u,children:[p,S]}),e[25]=n,e[26]=S,e[27]=C):C=e[27],C};function _F(){return iF.markSubscribed()}var vF=50,yF=()=>{let e=(0,$.c)(8),t=(0,Q.useRef)(null),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>{t.current===null&&(t.current=setTimeout(()=>{t.current=null,wC.preload()},vF))},e[0]=n):n=e[0];let r=n,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{t.current!==null&&(clearTimeout(t.current),t.current=null)},e[1]=i):i=e[1];let a=i,o,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>()=>{t.current!==null&&clearTimeout(t.current)},s=[],e[2]=o,e[3]=s):(o=e[2],s=e[3]),(0,Q.useEffect)(o,s);let c,l;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{a(),window.location.hash!==`#settings`&&(window.location.hash=Ea)},l=(0,Z.jsx)(_f,{className:`size-4`}),e[4]=c,e[5]=l):(c=e[4],l=e[5]);let u;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(Ms,{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`,onMouseEnter:r,onMouseLeave:a,onFocus:r,onBlur:a,onClick:c,children:[l,(0,Z.jsx)(`span`,{className:`sr-only`,children:(0,Z.jsx)(J,{id:`Tz0i8g`})})]})}),e[6]=u):u=e[6];let d;return e[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsxs)(Fs,{children:[u,(0,Z.jsx)(Ns,{children:(0,Z.jsx)(J,{id:`Tz0i8g`})})]}),e[7]=d):d=e[7],d},bF=`https://git-scm.com/docs/git-push`;function xF(e,t){return!(e!==`stale`&&e!==`absent`||e===`stale`&&t?.syncEnabled===!0)}function SF(e){return e?e.state!==`dormant`&&e.state!==`disabled`&&e.state!==`auth-error`&&e.state!==`conflict`:!1}function CF(e){let t=(0,$.c)(47),{freshness:n,status:r,kind:i}=e,{_:a}=$t(),{confirmOpen:o,setConfirmOpen:s,onToggleRequest:c,onConfirm:l}=Di(Ei()),[u,d]=(0,Q.useState)(`idle`),f=(0,Q.useRef)(null),p,m;if(t[0]!==r||t[1]!==u?(p=()=>{if(!(u!==`pending`||!r)){if(r.pushError||r.pushErrorCode){d(`idle`);return}(r.lastSyncUtc??null)!==f.current&&d(`synced`)}},m=[u,r],t[0]=r,t[1]=u,t[2]=p,t[3]=m):(p=t[2],m=t[3]),(0,Q.useEffect)(p,m),!xF(n,r))return null;if(u===`synced`){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed border-border bg-muted/40 p-2 text-xs text-muted-foreground`,"data-testid":`share-freshness-row`,children:[(0,Z.jsx)(Wi,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{children:(0,Z.jsx)(J,{id:`fxbCNQ`})})]}),t[4]=e):e=t[4],e}let h=r?.syncEnabled===!0,g=r?.pushPermission?.checkStatus===`denied`,_=!!(r?.pushError||r?.pushErrorCode),v=g||_,y=n===`absent`&&!h,b;if(n===`absent`&&!h){let e;t[5]!==a||t[6]!==i?(e=a(i===`folder`?{id:`PrJYSN`}:{id:`3BnyYc`}),t[5]=a,t[6]=i,t[7]=e):e=t[7],b=e}else if(n===`stale`){let e;t[8]!==a||t[9]!==i?(e=a(i===`folder`?{id:`Gt4gOO`}:{id:`2IYGkU`}),t[8]=a,t[9]=i,t[10]=e):e=t[10],b=e}else{let e;t[11]!==a||t[12]!==i?(e=a(i===`folder`?{id:`nqV0Kk`}:{id:`gwykHF`}),t[11]=a,t[12]=i,t[13]=e):e=t[13],b=e}let x;t[14]!==a||t[15]!==_||t[16]!==g?(x=g?a({id:`9OIqw4`}):_?a({id:`K6MQQk`}):null,t[14]=a,t[15]=_,t[16]=g,t[17]=x):x=t[17];let S=x,C;t[18]===r?.lastSyncUtc?C=t[19]:(C=()=>{f.current=r?.lastSyncUtc??null,d(`pending`),Co(`sync`).catch(e=>{console.warn(`[share-freshness] sync trigger failed`,e instanceof Error?e.message:e),d(`idle`)})},t[18]=r?.lastSyncUtc,t[19]=C);let w=C,T=y?Yi:rs,E;t[20]===T?E=t[21]:(E=(0,Z.jsx)(T,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`}),t[20]=T,t[21]=E);let D;t[22]===b?D=t[23]:(D=(0,Z.jsx)(`span`,{children:b}),t[22]=b,t[23]=D);let O;t[24]===S?O=t[25]:(O=S?(0,Z.jsx)(`span`,{children:S}):null,t[24]=S,t[25]=O);let k;t[26]!==v||t[27]!==w||t[28]!==c||t[29]!==r||t[30]!==h||t[31]!==u?(k=v?null:h?SF(r)?(0,Z.jsx)(`div`,{children:u===`pending`?(0,Z.jsxs)(X,{variant:`outline`,size:`xs`,disabled:!0,children:[(0,Z.jsx)(ls,{className:`size-3 shrink-0 animate-spin`,"aria-hidden":`true`}),(0,Z.jsx)(J,{id:`EHu0x2`})]}):(0,Z.jsx)(X,{variant:`outline`,size:`xs`,onClick:w,children:(0,Z.jsx)(J,{id:`lb_UU4`})})}):null:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,Z.jsx)(X,{variant:`outline`,size:`xs`,onClick:()=>c(!0),children:(0,Z.jsx)(J,{id:`XU0OXn`})}),(0,Z.jsxs)(`a`,{href:bF,target:`_blank`,rel:`noopener noreferrer`,onClick:TF,onAuxClick:wF,className:`inline-flex items-center gap-1 transition-colors hover:text-primary`,children:[(0,Z.jsx)(J,{id:`GLxIKR`}),(0,Z.jsx)(Ai,{className:`size-3 shrink-0`,"aria-hidden":`true`})]})]}),t[26]=v,t[27]=w,t[28]=c,t[29]=r,t[30]=h,t[31]=u,t[32]=k):k=t[32];let A;t[33]!==D||t[34]!==O||t[35]!==k?(A=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[D,O,k]}),t[33]=D,t[34]=O,t[35]=k,t[36]=A):A=t[36];let j;t[37]!==E||t[38]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed border-border bg-muted/40 p-2 text-xs text-muted-foreground`,"data-testid":`share-freshness-row`,children:[E,A]}),t[37]=E,t[38]=A,t[39]=j):j=t[39];let M;t[40]!==o||t[41]!==l||t[42]!==s?(M=(0,Z.jsx)(ki,{open:o,onOpenChange:s,onConfirm:l}),t[40]=o,t[41]=l,t[42]=s,t[43]=M):M=t[43];let N;return t[44]!==j||t[45]!==M?(N=(0,Z.jsxs)(Z.Fragment,{children:[j,M]}),t[44]=j,t[45]=M,t[46]=N):N=t[46],N}function wF(e){return du(e,bF)}function TF(e){return du(e,bF)}var EF=`https://openknowledge.ai/docs/features/share`;function DF(e){let t=(0,$.c)(50),{input:n,onClickWhenNoRemote:r}=e,{_:i}=$t(),{status:a}=Ra(),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(null),d;t[0]===c?.autoCopyFailed?d=t[1]:(d=()=>{!c?.autoCopyFailed||!u.current||(u.current.focus(),u.current.select())},t[0]=c?.autoCopyFailed,t[1]=d);let f;t[2]===c?f=t[3]:(f=[c],t[2]=c,t[3]=f),(0,Q.useEffect)(d,f);let p=a?.hasRemote===!0,m=n===null,h=xF(c?.freshness,a),g;t[4]!==i||t[5]!==o||t[6]!==p||t[7]!==n||t[8]!==r?(g=async function(){if(!o&&n!==null){s(!0),l(null);try{let e=await Ia({...n,hasRemote:p,onClickWhenNoRemote:r},{clipboardWrite:va,toastSuccess:FF,toastError:PF,logEvent:NF});e.kind===`copied`?l({url:e.shareUrl,autoCopyFailed:!1,freshness:e.freshness}):e.kind===`clipboard-failed`&&l({url:e.shareUrl,autoCopyFailed:!0,freshness:e.freshness})}catch{Ss.error(i({id:`u3YnKw`}))}s(!1)}},t[4]=i,t[5]=o,t[6]=p,t[7]=n,t[8]=r,t[9]=g):g=t[9];let _=g,v=c!==null,y;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{e||l(null)},t[10]=y):y=t[10];let b;t[11]!==i||t[12]!==n?.kind?(b=n?.kind===`folder`?i({id:`WR0y2O`}):i({id:`F4IYWe`}),t[11]=i,t[12]=n?.kind,t[13]=b):b=t[13];let x=o||m,S,C;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(vf,{className:`size-3.5`,"aria-hidden":!0}),C=(0,Z.jsx)(J,{id:`Z8lGw6`}),t[14]=S,t[15]=C):(S=t[14],C=t[15]);let w;t[16]!==_||t[17]!==b||t[18]!==x?(w=(0,Z.jsx)(Oe,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,size:`sm`,"aria-label":b,onClick:_,disabled:x,className:`gap-1.5 text-muted-foreground px-1.5`,"data-testid":`share-button`,children:[S,C]})}),t[16]=_,t[17]=b,t[18]=x,t[19]=w):w=t[19];let T=h?`w-96`:`w-80`,E;t[20]===T?E=t[21]:(E=Y(`flex flex-col gap-2`,T),t[20]=T,t[21]=E);let D;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs`,children:(0,Z.jsx)(J,{id:`Z8lGw6`})}),t[22]=D):D=t[22];let O;t[23]===c?.autoCopyFailed?O=t[24]:(O=c?.autoCopyFailed?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,Z.jsx)(J,{id:`ndeI89`})}):null,t[23]=c?.autoCopyFailed,t[24]=O);let k=c?.url??``,A;t[25]===i?A=t[26]:(A=i({id:`5-FeN2`}),t[25]=i,t[26]=A);let j;t[27]!==k||t[28]!==A?(j=(0,Z.jsx)(Uc,{ref:u,readOnly:!0,value:k,onFocus:MF,onClick:jF,onContextMenu:AF,className:`select-all bg-muted font-mono text-xs text-muted-foreground`,"data-testid":`share-button-url`,"aria-label":A}),t[27]=k,t[28]=A,t[29]=j):j=t[29];let M=c?.url??``,N=c?.autoCopyFailed===!1,P;t[30]!==M||t[31]!==N?(P=(0,Z.jsx)(`div`,{className:`absolute inset-y-0 right-1 flex items-center`,children:(0,Z.jsx)(`div`,{className:`rounded-md bg-background/50 backdrop-blur-sm`,children:(0,Z.jsx)(U,{copyContent:M,clipboardWrite:va,initialCopied:N})})}),t[30]=M,t[31]=N,t[32]=P):P=t[32];let F;t[33]!==j||t[34]!==P?(F=(0,Z.jsxs)(`div`,{className:`relative`,children:[j,P]}),t[33]=j,t[34]=P,t[35]=F):F=t[35];let I=c?.freshness,L=n?.kind??`doc`,R;t[36]!==a||t[37]!==I||t[38]!==L?(R=(0,Z.jsx)(CF,{freshness:I,status:a,kind:L}),t[36]=a,t[37]=I,t[38]=L,t[39]=R):R=t[39];let z;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsxs)(`a`,{href:EF,target:`_blank`,rel:`noopener noreferrer`,onClick:kF,onAuxClick:OF,className:`mt-2 flex items-center gap-1.5 self-start text-xs text-muted-foreground transition-colors hover:text-primary`,children:[(0,Z.jsx)(et,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Z.jsx)(J,{id:`aByJ8j`})]}),t[40]=z):z=t[40];let B;t[41]!==E||t[42]!==O||t[43]!==F||t[44]!==R?(B=(0,Z.jsxs)(yt,{align:`end`,className:E,"data-testid":`share-button-popover`,children:[D,O,F,R,z]}),t[41]=E,t[42]=O,t[43]=F,t[44]=R,t[45]=B):B=t[45];let V;return t[46]!==w||t[47]!==B||t[48]!==v?(V=(0,Z.jsxs)($e,{open:v,onOpenChange:y,children:[w,B]}),t[46]=w,t[47]=B,t[48]=v,t[49]=V):V=t[49],V}function OF(e){return du(e,EF)}function kF(e){return du(e,EF)}function AF(e){return e.currentTarget.select()}function jF(e){return e.currentTarget.select()}function MF(e){return e.currentTarget.select()}function NF(e){return console.log(e)}function PF(e){e!==`Link ready but could not copy to clipboard.`&&Ss.error(e)}function FF(e){return Ss.success(e)}function IF(e){let t=(0,$.c)(35),{onSignIn:n,onSetIdentity:r,onOpenSearch:i}=e,{_:a}=$t(),{activeDocName:o,activeTarget:s}=mt(),c=o?Xr(o):null,{state:l,isDraggingRail:u}=Sj(),d=cg(),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=kl(`toggle-files-sidebar`),t[0]=f):f=t[0];let p=f,m=kl(`command-palette`),[h,g]=(0,Q.useState)(!1),_;bb0:{if(s?.kind===`folder`){let e;t[1]===s.folderPath?e=t[2]:(e=Na(s.folderPath),t[1]=s.folderPath,t[2]=e),_=e;break bb0}if(o&&!c){let e;t[3]===o?e=t[4]:(e=Aa(o),t[3]=o,t[4]=e),_=e;break bb0}if(!s&&!o){let e;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=Na(``),t[5]=e):e=t[5],_=e;break bb0}_=null}let v=_,y=typeof window<`u`&&window.okDesktop!=null,b=l===`collapsed`,x=y?``:void 0,S=y&&b&&`pl-[var(--ok-titlebar-reserve-left,1rem)]`,C=y&&!u&&`motion-safe:transition-[padding] motion-safe:duration-200 motion-safe:ease-linear`,w;t[6]!==S||t[7]!==C?(w=Y(`flex h-12 shrink-0 items-center bg-muted/35 shadow-[inset_0_-1px_0_var(--border)]`,y&&`[-webkit-app-region:drag]`,S,C),t[6]=S,t[7]=C,t[8]=w):w=t[8];let T=!d&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Fs,{children:[(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(Dj,{className:Y(`-ml-1 shrink-0 text-muted-foreground`,y&&`[-webkit-app-region:no-drag]`)})}),(0,Z.jsx)(Ns,{children:l===`expanded`?(0,Z.jsx)(J,{id:`ZxXhLY`,values:{sidebarShortcut:p}}):(0,Z.jsx)(J,{id:`Zz25kq`,values:{sidebarShortcut:p}})})]}),b&&i&&(0,Z.jsxs)(Fs,{children:[(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-sm`,onClick:i,"aria-label":a({id:`IN4UX8`,values:{searchShortcut:m}}),"data-telemetry-event":`ok.editor_header.search.click`,className:Y(`shrink-0 text-muted-foreground`,y&&`[-webkit-app-region:no-drag]`),children:(0,Z.jsx)(L,{"aria-hidden":`true`})})}),(0,Z.jsx)(Ns,{children:(0,Z.jsx)(J,{id:`IN4UX8`,values:{searchShortcut:m}})})]}),(0,Z.jsx)(Qa,{orientation:`vertical`,className:`mr-1 h-4 shrink-0 data-vertical:self-center`}),(0,Z.jsx)(MP,{})]}),E;t[9]===T?E=t[10]:(E=(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 px-3`,children:T}),t[9]=T,t[10]=E);let D;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(D=Y(`flex shrink-0 items-center justify-end gap-2 px-3`,y&&`[&>*]:[-webkit-app-region:no-drag]`),t[11]=D):D=t[11];let O;t[12]!==h||t[13]!==g||t[14]!==v||t[15]!==d?(O=!d&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(DF,{input:v,onClickWhenNoRemote:()=>g(!0)}),(0,Z.jsx)(Ba,{open:h,onOpenChange:g})]}),t[12]=h,t[13]=g,t[14]=v,t[15]=d,t[16]=O):O=t[16];let k;t[17]!==r||t[18]!==n?(k=(0,Z.jsx)(Xa,{onSignIn:n,onSetIdentity:r}),t[17]=r,t[18]=n,t[19]=k):k=t[19];let A,j,M;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(CN,{}),j=(0,Z.jsx)(Qa,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),M=(0,Z.jsx)(EN,{}),t[20]=A,t[21]=j,t[22]=M):(A=t[20],j=t[21],M=t[22]);let N;t[23]===d?N=t[24]:(N=!d&&(0,Z.jsx)(yF,{}),t[23]=d,t[24]=N);let P;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(gF,{}),t[25]=P):P=t[25];let F;t[26]!==O||t[27]!==k||t[28]!==N?(F=(0,Z.jsxs)(`div`,{className:D,children:[O,k,A,j,M,N,P]}),t[26]=O,t[27]=k,t[28]=N,t[29]=F):F=t[29];let I;return t[30]!==F||t[31]!==x||t[32]!==w||t[33]!==E?(I=(0,Z.jsxs)(`header`,{"data-electron-drag":x,className:w,children:[E,F]}),t[30]=F,t[31]=x,t[32]=w,t[33]=E,t[34]=I):I=t[34],I}var LF=`open-knowledge:terminal-launch`;function RF(e,t,n=typeof window>`u`?new EventTarget:window){n.dispatchEvent(new CustomEvent(LF,{detail:{prompt:e,cli:t}}))}function zF(e,t=typeof window>`u`?new EventTarget:window){let n=t=>{let n=t instanceof CustomEvent?t.detail:void 0;n&&typeof n.prompt==`string`&&e(n.prompt,n.cli)};return t.addEventListener(LF,n),()=>t.removeEventListener(LF,n)}function BF(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,orientation:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`horizontal`:i,o;t[4]===n?o=t[5]:(o=Y(`group/tabs flex gap-2 data-horizontal:flex-col`,n),t[4]=n,t[5]=o);let s;return t[6]!==a||t[7]!==r||t[8]!==o?(s=(0,Z.jsx)(Zp,{"data-slot":`tabs`,"data-orientation":a,className:o,...r}),t[6]=a,t[7]=r,t[8]=o,t[9]=s):s=t[9],s}var VF=_i(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function HF(e){let t=(0,$.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,variant:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`default`:i,o;t[4]!==n||t[5]!==a?(o=Y(VF({variant:a}),n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==o||t[9]!==a?(s=(0,Z.jsx)(Qp,{"data-slot":`tabs-list`,"data-variant":a,className:o,...r}),t[7]=r,t[8]=o,t[9]=a,t[10]=s):s=t[10],s}function UF(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(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)($p,{"data-slot":`tabs-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function WF(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 text-sm outline-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(em,{"data-slot":`tabs-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var GF=(0,Q.lazy)(()=>n(()=>import(`./TerminalPanel-vd5LQunA.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([86,1,10,3,11,6,7,13,52,17,33,87,60,31,88]),import.meta.url));function KF(e){let t=(0,$.c)(14),{bridge:n,onClose:r,onTitleChange:i,launch:a,adoptPtyId:o,onPtyId:s}=e,c=a===void 0?null:a,l=o===void 0?null:o,{enabled:u,synced:d}=So(),f=wo(),{_:p}=$t(),m=d&&u===!1,h;t[0]!==p||t[1]!==f?(h=function(){if(f===null){Ss.error(p({id:`V_6bJ4`}));return}let e=f(!0);e.ok||Ss.error(p({id:`jKd3AP`,values:{0:e.error}}))},t[0]=p,t[1]=f,t[2]=h):h=t[2];let _=h;if(d&&!m){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`div`,{className:`h-full w-full bg-background`,"aria-hidden":`true`}),t[3]=e):e=t[3];let a;return t[4]!==l||t[5]!==n||t[6]!==c||t[7]!==r||t[8]!==s||t[9]!==i?(a=(0,Z.jsx)(g,{fallbackRender:JF,onError:qF,children:(0,Z.jsx)(Q.Suspense,{fallback:e,children:(0,Z.jsx)(GF,{bridge:n,className:`h-full`,onClose:r,onTitleChange:i,launch:c,adoptPtyId:l,onPtyId:s})})}),t[4]=l,t[5]=n,t[6]=c,t[7]=r,t[8]=s,t[9]=i,t[10]=a):a=t[10],a}let v;return t[11]!==_||t[12]!==m?(v=m?(0,Z.jsx)(ZF,{onEnable:_}):(0,Z.jsx)(`div`,{className:`h-full w-full bg-background`,"aria-hidden":`true`}),t[11]=_,t[12]=m,t[13]=v):v=t[13],v}function qF(e,t){console.error(`[TerminalGate] rendered fallback for the terminal panel`,e,t.componentStack)}function JF(e){return(0,Z.jsx)(YF,{...e})}function YF(e){let t=(0,$.c)(15),{error:n}=e,{_:r}=$t(),i;t[0]!==r||t[1]!==n?(i=n instanceof Error&&/dynamically imported module|Failed to fetch/i.test(n.message)?r({id:`Y8ViJx`}):r({id:`fbsiBw`}),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;t[3]===r?o=t[4]:(o=r({id:`6MnZEC`}),t[3]=r,t[4]=o);let s;t[5]===a?s=t[6]:(s=(0,Z.jsx)(`p`,{className:`max-w-sm text-sm text-foreground`,children:a}),t[5]=a,t[6]=s);let c;t[7]===r?c=t[8]:(c=r({id:`HpK_8d`}),t[7]=r,t[8]=c);let l;t[9]===c?l=t[10]:(l=(0,Z.jsx)(X,{onClick:XF,children:c}),t[9]=c,t[10]=l);let u;return t[11]!==o||t[12]!==s||t[13]!==l?(u=(0,Z.jsxs)(`section`,{"aria-label":o,className:`flex h-full w-full flex-col items-center justify-center gap-3 bg-background p-6 text-center`,role:`alert`,children:[s,l]}),t[11]=o,t[12]=s,t[13]=l,t[14]=u):u=t[14],u}function XF(){return window.location.reload()}function ZF(e){let t=(0,$.c)(20),{onEnable:n}=e,{_:r}=$t(),i;t[0]===r?i=t[1]:(i=r({id:`_XWY2J`}),t[0]=r,t[1]=i);let a;t[2]===r?a=t[3]:(a=r({id:`oYepHb`}),t[2]=r,t[3]=a);let o;t[4]===a?o=t[5]:(o=(0,Z.jsx)(`p`,{className:`max-w-sm text-sm text-foreground`,children:a}),t[4]=a,t[5]=o);let s;t[6]===r?s=t[7]:(s=r({id:`v2ZW0K`}),t[6]=r,t[7]=s);let c;t[8]!==n||t[9]!==s?(c=(0,Z.jsx)(X,{onClick:n,children:s}),t[8]=n,t[9]=s,t[10]=c):c=t[10];let l;t[11]===r?l=t[12]:(l=r({id:`ICoNYz`}),t[11]=r,t[12]=l);let u;t[13]===l?u=t[14]:(u=(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l}),t[13]=l,t[14]=u);let d;return t[15]!==i||t[16]!==o||t[17]!==c||t[18]!==u?(d=(0,Z.jsxs)(`section`,{"aria-label":i,className:`flex h-full w-full flex-col items-center justify-center gap-3 bg-background p-6 text-center`,children:[o,c,u]}),t[15]=i,t[16]=o,t[17]=c,t[18]=u,t[19]=d):d=t[19],d}function QF(e){let t=(0,$.c)(48),{selected:n,onLaunchSelected:r,onPickCli:i,onPickTerminal:a,className:o}=e,{_:s}=$t(),c=n===`terminal`,l;t[0]!==s||t[1]!==c||t[2]!==n?(l=s(c?{id:`AB4qw9`}:{id:`nP-KFo`,values:{0:zn[n].displayName}}),t[0]=s,t[1]=c,t[2]=n,t[3]=l):l=t[3];let u=l,d;t[4]===o?d=t[5]:(d=Y(`flex shrink-0 items-center`,o),t[4]=o,t[5]=d);let f;t[6]!==c||t[7]!==n?(f=c?(0,Z.jsx)(Cf,{"aria-hidden":`true`,className:`size-3.5`}):(0,Z.jsx)(la,{id:ca(n),className:`size-3.5`,"aria-hidden":`true`}),t[6]=c,t[7]=n,t[8]=f):f=t[8];let p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(Zt,{"aria-hidden":`true`,className:`size-3`}),t[9]=p):p=t[9];let m;t[10]!==r||t[11]!==u||t[12]!==f?(m=(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsxs)(X,{type:`button`,variant:`ghost`,size:`xs`,"aria-label":u,"data-testid":`terminal-new-chat`,className:`cursor-pointer gap-0.5 rounded-r-none px-1.5 text-muted-foreground hover:text-foreground`,onClick:r,children:[f,p]})}),t[10]=r,t[11]=u,t[12]=f,t[13]=m):m=t[13];let h;t[14]===u?h=t[15]:(h=(0,Z.jsx)(Ns,{side:`bottom`,sideOffset:8,children:u}),t[14]=u,t[15]=h);let g;t[16]!==m||t[17]!==h?(g=(0,Z.jsxs)(Fs,{children:[m,h]}),t[16]=m,t[17]=h,t[18]=g):g=t[18];let _;t[19]===s?_=t[20]:(_=s({id:`QJaG-9`}),t[19]=s,t[20]=_);let v;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(Gi,{"aria-hidden":`true`,className:`size-3`}),t[21]=v):v=t[21];let y;t[22]===_?y=t[23]:(y=(0,Z.jsx)(yc,{asChild:!0,children:(0,Z.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":_,"data-testid":`terminal-new-chat-menu`,className:`cursor-pointer rounded-l-none text-muted-foreground hover:text-foreground`,children:v})}),t[22]=_,t[23]=y);let b;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(Mc,{children:(0,Z.jsx)(J,{id:`hIQkLb`})}),t[24]=b):b=t[24];let x;t[25]!==s||t[26]!==i||t[27]!==n?(x=ba.map(e=>{let{displayName:t}=zn[e];return(0,Z.jsxs)(xc,{onSelect:()=>i(e),"data-testid":`terminal-new-chat-cli-${e}`,"aria-label":s({id:`9mEZeD`,values:{name:t}}),"aria-current":n===e?`true`:void 0,children:[(0,Z.jsx)(la,{id:ca(e),className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:t}),n===e?(0,Z.jsx)(Wi,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null]},e)}),t[25]=s,t[26]=i,t[27]=n,t[28]=x):x=t[28];let S;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(Pc,{}),t[29]=S):S=t[29];let C=c?`true`:void 0,w;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(Cf,{"aria-hidden":`true`,className:`size-4`}),t[30]=w):w=t[30];let T;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(`span`,{className:`flex-1`,children:(0,Z.jsx)(J,{id:`ALhMYW`})}),t[31]=T):T=t[31];let E;t[32]===c?E=t[33]:(E=c?(0,Z.jsx)(Wi,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null,t[32]=c,t[33]=E);let D;t[34]!==a||t[35]!==C||t[36]!==E?(D=(0,Z.jsxs)(xc,{onSelect:a,"data-testid":`terminal-new-chat-terminal`,"aria-current":C,children:[w,T,E]}),t[34]=a,t[35]=C,t[36]=E,t[37]=D):D=t[37];let O;t[38]!==x||t[39]!==D?(O=(0,Z.jsxs)(Cc,{align:`start`,className:`min-w-[180px]`,children:[b,x,S,D]}),t[38]=x,t[39]=D,t[40]=O):O=t[40];let k;t[41]!==y||t[42]!==O?(k=(0,Z.jsxs)(kc,{children:[y,O]}),t[41]=y,t[42]=O,t[43]=k):k=t[43];let A;return t[44]!==d||t[45]!==k||t[46]!==g?(A=(0,Z.jsxs)(`div`,{className:d,children:[g,k]}),t[44]=d,t[45]=k,t[46]=g,t[47]=A):A=t[47],A}function $F(e){let t=(0,$.c)(52),{sessions:n,activeSessionId:r,onSelect:i,onTabActivate:a,newChatSelected:o,onNewChatLaunch:s,onNewChatPickCli:c,onNewChatPickTerminal:l,onClose:u,dockPosition:d,onToggleDock:f,onCollapse:p,children:m,className:h,draggable:g}=e,{_}=$t(),v=d===`right`,y;t[0]===h?y=t[1]:(y=Y(`flex min-h-0 min-w-0 flex-1 flex-col`,h),t[0]=h,t[1]=y);let b=g?``:void 0,x=g&&`h-[62px] [-webkit-app-region:drag] pr-[22px] pl-[calc(var(--ok-titlebar-reserve-left,1rem)+0.75rem)]`,S;t[2]===x?S=t[3]:(S=Y(`flex shrink-0 flex-row items-center gap-1 px-1.5 py-1`,x),t[2]=x,t[3]=S);let C;t[4]===_?C=t[5]:(C=_({id:`1MGRQl`}),t[4]=_,t[5]=C);let w;if(t[6]!==_||t[7]!==r||t[8]!==g||t[9]!==u||t[10]!==a||t[11]!==n){let e;t[13]!==_||t[14]!==r||t[15]!==g||t[16]!==u||t[17]!==a?(e=e=>{let t=e.id===r;return(0,Z.jsxs)(`div`,{className:Y(`group flex shrink-0 cursor-default items-center rounded-md pr-0.5 transition-colors`,t?`bg-muted`:`hover:bg-muted/50`),children:[(0,Z.jsxs)(Fs,{children:[(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(UF,{value:e.id,onClick:()=>a?.(e.id),className:Y(`h-7 flex-none rounded-md px-2 text-xs`,g&&`[-webkit-app-region:no-drag]`),children:(0,Z.jsx)(`span`,{className:`max-w-40 truncate`,children:e.label})})}),(0,Z.jsx)(Ns,{side:`bottom`,sideOffset:8,children:e.label})]}),(0,Z.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":_({id:`nzHlj8`,values:{0:e.label}}),tabIndex:t?0:-1,className:Y(`text-muted-foreground opacity-0 transition-opacity hover:text-foreground group-hover:opacity-100 group-focus-within:opacity-100`,t&&`opacity-100`,g&&`[-webkit-app-region:no-drag]`),onClick:t=>{t.stopPropagation(),u(e.id)},children:(0,Z.jsx)(Cs,{"aria-hidden":`true`})})]},e.id)},t[13]=_,t[14]=r,t[15]=g,t[16]=u,t[17]=a,t[18]=e):e=t[18],w=n.map(e),t[6]=_,t[7]=r,t[8]=g,t[9]=u,t[10]=a,t[11]=n,t[12]=w}else w=t[12];let T;t[19]!==C||t[20]!==w?(T=(0,Z.jsx)(HF,{variant:`line`,"aria-label":C,className:`flex h-auto min-w-0 items-center justify-start gap-0.5 overflow-x-auto bg-transparent p-0 [scrollbar-width:none] scroll-fade-mask-x`,children:w}),t[19]=C,t[20]=w,t[21]=T):T=t[21];let E=g&&`[-webkit-app-region:no-drag]`,D;t[22]===E?D=t[23]:(D=Y(`shrink-0`,E),t[22]=E,t[23]=D);let O;t[24]!==o||t[25]!==s||t[26]!==c||t[27]!==l||t[28]!==D?(O=(0,Z.jsx)(QF,{selected:o,onLaunchSelected:s,onPickCli:c,onPickTerminal:l,className:D}),t[24]=o,t[25]=s,t[26]=c,t[27]=l,t[28]=D,t[29]=O):O=t[29];let k;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Z.jsx)(`div`,{className:`flex-1`}),t[30]=k):k=t[30];let A;t[31]!==_||t[32]!==f||t[33]!==v?(A=f==null?null:(0,Z.jsxs)(Fs,{children:[(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":_(v?{id:`rf6x3F`}:{id:`QNxpRm`}),className:`shrink-0 cursor-pointer text-muted-foreground hover:text-foreground`,onClick:f,children:v?(0,Z.jsx)(rf,{"aria-hidden":`true`}):(0,Z.jsx)(cf,{"aria-hidden":`true`})})}),(0,Z.jsx)(Ns,{side:`bottom`,sideOffset:8,children:v?(0,Z.jsx)(J,{id:`rf6x3F`}):(0,Z.jsx)(J,{id:`QNxpRm`})})]}),t[31]=_,t[32]=f,t[33]=v,t[34]=A):A=t[34];let j;t[35]!==_||t[36]!==p||t[37]!==v?(j=p==null?null:(0,Z.jsxs)(Fs,{children:[(0,Z.jsx)(Ms,{asChild:!0,children:(0,Z.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":_({id:`VZGGPK`}),className:`shrink-0 cursor-pointer text-muted-foreground hover:text-foreground`,onClick:p,children:v?(0,Z.jsx)(qi,{"aria-hidden":`true`}):(0,Z.jsx)(Gi,{"aria-hidden":`true`})})}),(0,Z.jsx)(Ns,{side:`bottom`,sideOffset:8,children:(0,Z.jsx)(J,{id:`VZGGPK`})})]}),t[35]=_,t[36]=p,t[37]=v,t[38]=j):j=t[38];let M;t[39]!==O||t[40]!==A||t[41]!==j||t[42]!==b||t[43]!==S||t[44]!==T?(M=(0,Z.jsxs)(`div`,{"data-electron-drag":b,className:S,children:[T,O,k,A,j]}),t[39]=O,t[40]=A,t[41]=j,t[42]=b,t[43]=S,t[44]=T,t[45]=M):M=t[45];let N;return t[46]!==r||t[47]!==m||t[48]!==i||t[49]!==y||t[50]!==M?(N=(0,Z.jsxs)(BF,{value:r,onValueChange:i,className:y,children:[M,m]}),t[46]=r,t[47]=m,t[48]=i,t[49]=y,t[50]=M,t[51]=N):N=t[51],N}function eI(e){return`terminal-session-${e}`}function tI(e){e!==``&&document.querySelector(`[data-terminal-session="${e}"] .xterm-helper-textarea`)?.focus()}function nI(e){let t=(0,$.c)(79),{bridge:n,variant:r,visible:i,onVisibleChange:a,launch:o,installedClis:s,container:c,isShowing:l,onRequestEditorFocus:u,dockPosition:d,onToggleDock:f,onHasSessionsChange:p}=e,m=r===void 0?`dock`:r,h=o===void 0?null:o,{_:g}=$t(),[_]=(0,Q.useState)(cI),v,y;t[0]!==c||t[1]!==_?(v=()=>{_==null||c==null||_.parentElement!==c&&c.appendChild(_)},y=[_,c],t[0]=c,t[1]=_,t[2]=v,t[3]=y):(v=t[2],y=t[3]),(0,Q.useLayoutEffect)(v,y);let b=typeof n.terminal?.list==`function`,x;t[4]!==b||t[5]!==h||t[6]!==i?(x=()=>!b&&i?[{id:eI(1),launch:h,title:null,adoptPtyId:null}]:[],t[4]=b,t[5]=h,t[6]=i,t[7]=x):x=t[7];let[S,C]=(0,Q.useState)(x),w;t[8]!==b||t[9]!==i?(w=()=>!b&&i?eI(1):``,t[8]=b,t[9]=i,t[10]=w):w=t[10];let[T,E]=(0,Q.useState)(w),[D,O]=(0,Q.useState)(!b),k=(0,Q.useRef)(!1),A=(0,Q.useRef)(T),j=(0,Q.useRef)(S),M=(0,Q.useRef)(!b&&i?1:0),N=(0,Q.useRef)(i&&h?h.nonce:null),P=(0,Q.useRef)(m===`window`?!1:i),F=(0,Q.useRef)(new Map),I=function(e,t){t===null?F.current.delete(e):F.current.set(e,t)},L=(0,Q.useRef)(0),R;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(R=function(e){M.current+=1;let t=eI(M.current);C(n=>[...n,{id:t,launch:e,title:null,adoptPtyId:null}]),E(t)},t[11]=R):R=t[11];let z=R,[B,V]=(0,Q.useState)(sI),[H,U]=(0,Q.useState)(oI),W;t[12]===s?W=t[13]:(W=s??{},t[12]=s,t[13]=W);let G;t[14]!==B||t[15]!==W?(G=u_(B,W),t[14]=B,t[15]=W,t[16]=G):G=t[16];let K=G,ee=H?`terminal`:K,te;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(te=function(e){L.current+=1,z({prompt:null,cli:e,nonce:L.current})},t[17]=te):te=t[17];let ne=te,re;t[18]!==K||t[19]!==H?(re=function(){H?z(null):ne(K)},t[18]=K,t[19]=H,t[20]=re):re=t[20];let ie=re,ae;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(ae=function(e){U(!1),y_(!1);let t=i_(e);V(t),c_(t),ne(e)},t[21]=ae):ae=t[21];let oe=ae,se;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(se=function(){U(!0),y_(!0),z(null)},t[22]=se):se=t[22];let ce=se,le;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(le=function(e,t){let n=t.trim()===``?null:t.trim();C(t=>t.some(t=>t.id===e&&t.title!==n)?t.map(t=>t.id===e?{...t,title:n}:t):t)},t[23]=le):le=t[23];let q=le,ue=(0,Q.useRef)(z),de;t[24]!==T||t[25]!==u||t[26]!==a?(de=function(e){let t=j.current,n=t.findIndex(t=>t.id===e);if(n===-1)return;let r=t.filter(t=>t.id!==e);if(e===T){let e=(t[n-1]??t[n+1])?.id??``;E(e),e!==``&&queueMicrotask(()=>tI(e))}C(r),r.length===0&&(a(!1),u())},t[24]=T,t[25]=u,t[26]=a,t[27]=de):de=t[27];let fe=de,pe=(0,Q.useRef)(aI),me;t[28]!==T||t[29]!==fe||t[30]!==S?(me=()=>{ue.current=z,A.current=T,j.current=S,pe.current=()=>{T!==``&&fe(T)}},t[28]=T,t[29]=fe,t[30]=S,t[31]=me):me=t[31],(0,Q.useEffect)(me);let he,ge;t[32]!==h||t[33]!==D||t[34]!==S.length||t[35]!==i?(he=()=>{if(!D)return;let e=P.current;if(P.current=i,h!=null&&h.nonce!==N.current){N.current=h.nonce,ue.current(h);return}i&&!e&&S.length===0&&ue.current(null)},ge=[i,h,S.length,D],t[32]=h,t[33]=D,t[34]=S.length,t[35]=i,t[36]=he,t[37]=ge):(he=t[36],ge=t[37]),(0,Q.useEffect)(he,ge);let _e;t[38]===n.terminal?_e=t[39]:(_e=()=>{if(typeof n.terminal?.list!=`function`||k.current)return;k.current=!0;let e=!1;return(async()=>{let t;try{t=await n.terminal.list()??[]}catch(e){console.error(`[terminal] reload session list() failed; cold-starting:`,e),t=[]}if(!e){if(t.length>0){let e=t.map(iI);M.current=e.length,C(e),E(e[0]?.id??``)}O(!0)}})(),()=>{e=!0,k.current=!1}},t[38]=n.terminal,t[39]=_e);let ve;t[40]===n?ve=t[41]:(ve=[n],t[40]=n,t[41]=ve),(0,Q.useEffect)(_e,ve);let ye;t[42]===n?ye=t[43]:(ye=[n],t[42]=n,t[43]=ye),(0,Q.useEffect)(()=>RE(e=>{let t=A.current,r=t===``?void 0:F.current.get(t);r==null?lu():(n.terminal.input(r,e),queueMicrotask(()=>tI(t)))}),ye);let be,xe;t[44]!==n||t[45]!==m?(be=()=>n.onMenuAction(e=>{e===`new-terminal`?ue.current(null):(e===`kill-terminal`||e===`close-active-tab-or-window`&&m===`window`)&&pe.current()}),xe=[n,m],t[44]=n,t[45]=m,t[46]=be,t[47]=xe):(be=t[46],xe=t[47]),(0,Q.useEffect)(be,xe);let Se,Ce;t[48]!==_||t[49]!==m?(Se=()=>{let e=function(e){if(!e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||!/^[1-9]$/.test(e.key)||m!==`window`&&(_==null||!_.contains(document.activeElement)))return;let t=j.current[Number(e.key)-1];t!=null&&(e.preventDefault(),e.stopPropagation(),E(t.id),queueMicrotask(()=>tI(t.id)))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},Ce=[_,m],t[48]=_,t[49]=m,t[50]=Se,t[51]=Ce):(Se=t[50],Ce=t[51]),(0,Q.useEffect)(Se,Ce);let we;t[52]!==n.editor||t[53]!==S.length?(we=()=>{n.editor.notifyViewMenuStateChanged({terminalLive:S.length>0})},t[52]=n.editor,t[53]=S.length,t[54]=we):we=t[54];let Te;t[55]!==n||t[56]!==S.length?(Te=[n,S.length],t[55]=n,t[56]=S.length,t[57]=Te):Te=t[57],(0,Q.useEffect)(we,Te);let Ee,De;t[58]!==p||t[59]!==S.length?(Ee=()=>{p?.(S.length>0)},De=[p,S.length],t[58]=p,t[59]=S.length,t[60]=Ee,t[61]=De):(Ee=t[60],De=t[61]),(0,Q.useEffect)(Ee,De);let Oe,ke;t[62]!==_||t[63]!==l||t[64]!==u||t[65]!==i?(Oe=()=>{l||i||_==null||!_.contains(document.activeElement)||u()},ke=[l,i,_,u],t[62]=_,t[63]=l,t[64]=u,t[65]=i,t[66]=Oe,t[67]=ke):(Oe=t[66],ke=t[67]),(0,Q.useLayoutEffect)(Oe,ke);let Ae,je;t[68]===l?(Ae=t[69],je=t[70]):(Ae=()=>{l&&tI(A.current)},je=[l],t[68]=l,t[69]=Ae,t[70]=je),(0,Q.useEffect)(Ae,je);let Me;if(t[71]!==g||t[72]!==S){let e;t[74]===g?e=t[75]:(e=(e,t)=>({id:e.id,label:e.title??g({id:`OVjNeX`,values:{0:t+1}})}),t[74]=g,t[75]=e),Me=S.map(e),t[71]=g,t[72]=S,t[73]=Me}else Me=t[73];let Ne=Me,Pe=S.length>0?(0,Z.jsx)($F,{sessions:Ne,activeSessionId:T,onSelect:E,onTabActivate:rI,newChatSelected:ee,onNewChatLaunch:ie,onNewChatPickCli:oe,onNewChatPickTerminal:ce,onClose:fe,dockPosition:d,onToggleDock:f,onCollapse:m===`window`?void 0:()=>a(!1),draggable:m===`window`,className:`h-full`,children:S.map(e=>(0,Z.jsx)(WF,{value:e.id,forceMount:!0,"data-terminal-session":e.id,className:Y(`m-0 flex min-h-0 flex-1 flex-col overflow-hidden data-[state=inactive]:hidden`,m===`window`&&`px-[22px] pb-[22px]`),children:(0,Z.jsx)(KF,{bridge:n,launch:e.launch,adoptPtyId:e.adoptPtyId,onPtyId:t=>I(e.id,t),onTitleChange:t=>q(e.id,t),onClose:()=>fe(e.id)})},e.id))}):null,Fe;return t[76]!==_||t[77]!==Pe?(Fe=_==null?null:(0,_d.createPortal)(Pe,_),t[76]=_,t[77]=Pe,t[78]=Fe):Fe=t[78],Fe}function rI(e){return queueMicrotask(()=>tI(e))}function iI(e,t){return{id:eI(t+1),launch:null,title:null,adoptPtyId:e.ptyId}}function aI(){}function oI(){return b_()}function sI(){return s_()}function cI(){if(typeof document>`u`)return null;let e=document.createElement(`div`);return e.className=`flex min-h-0 flex-1 flex-col overflow-hidden`,e}function lI(e){let t=(0,$.c)(74),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{onOpenSearch:r}=n,[i,a]=Yg(),[o,s]=(0,Q.useState)(i),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(`auth`),[f,p]=(0,Q.useState)(Iv[0].id),[m,h]=(0,Q.useState)(!1),g=typeof window<`u`?window.okDesktop??null:null,_=g!=null&&g.terminal!=null,[v,y]=(0,Q.useState)(!1),b=Xg(),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),T=(0,Q.useRef)(!1),[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(g_),A;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(A=function(e){k(e),h_(e),y(!0)},t[2]=A):A=t[2];let j=A,M;t[3]===O?M=t[4]:(M=function(){j(O===`right`?`bottom`:`right`)},t[3]=O,t[4]=M);let N=M,P;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(P={container:null,isShowing:!1,dockPosition:`bottom`,editorRegion:null},t[5]=P):P=t[5];let[F,I]=(0,Q.useState)(P),L=(0,Q.useRef)(0),R;t[6]===b?R=t[7]:(R=function(e){let t=e??u_(s_(),b);y(!0),L.current+=1,D({prompt:null,cli:t,nonce:L.current})},t[6]=b,t[7]=R);let z=R,B;t[8]!==x||t[9]!==z?(B=function(){y(!0),!x&&!v_()&&z()},t[8]=x,t[9]=z,t[10]=B):B=t[10];let V=B,H=Ka(),{projectConfig:U,projectLocalConfig:W,projectLocalSynced:G,projectSynced:K}=zo(),{activeDocName:ee}=mt(),te=H?.hasRemote,ne=H?.pushPermission?.checkStatus,re;t[11]!==m||t[12]!==U||t[13]!==W||t[14]!==G||t[15]!==K||t[16]!==te||t[17]!==ne?(re=C_({autoSyncOnboardingDismissed:m,hasRemote:te,projectLocalSynced:G,projectSynced:K,projectLocalConfig:W,projectConfig:U,pushPermissionCheckStatus:ne}),t[11]=m,t[12]=U,t[13]=W,t[14]=G,t[15]=K,t[16]=te,t[17]=ne,t[18]=re):re=t[18];let ie=re,ae,oe;t[19]===ee?(ae=t[20],oe=t[21]):(ae=()=>{let e=function(e){let t=e.detail;t&&ee&&tu(ee,{kind:`raw-mdx`,detail:t}),s(`source`)};return window.addEventListener(Vg,e),()=>window.removeEventListener(Vg,e)},oe=[ee],t[19]=ee,t[20]=ae,t[21]=oe),(0,Q.useEffect)(ae,oe);let se,ce;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>{let e=window.okDesktop;if(e!=null)return e.onMenuAction(e=>{e===`toggle-terminal`?y(fI):e===`new-terminal`&&y(!0)})},ce=[],t[22]=se,t[23]=ce):(se=t[22],ce=t[23]),(0,Q.useEffect)(se,ce);let le,q;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>{if(window.okDesktop!=null)return;let e=function(e){Al(e,`toggle-terminal-panel`)&&(e.preventDefault(),y(dI))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},q=[],t[24]=le,t[25]=q):(le=t[24],q=t[25]),(0,Q.useEffect)(le,q);let ue,de;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>zF((e,t)=>{y(!0),L.current+=1,D({prompt:e,cli:t,nonce:L.current})}),de=[],t[26]=ue,t[27]=de):(ue=t[26],de=t[27]),(0,Q.useEffect)(ue,de);let fe,pe;t[28]===v?(fe=t[29],pe=t[30]):(fe=()=>{v||D(null)},pe=[v],t[28]=v,t[29]=fe,t[30]=pe),(0,Q.useEffect)(fe,pe);let me,he;t[31]!==C||t[32]!==v?(me=()=>{window.okDesktop!=null&&C&&window.okDesktop.editor.notifyViewMenuStateChanged({terminalVisible:v})},he=[v,C],t[31]=C,t[32]=v,t[33]=me,t[34]=he):(me=t[33],he=t[34]),(0,Q.useEffect)(me,he);let ge,_e;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ge=()=>{let e=window.okDesktop;if(e==null)return;if(typeof e.terminal?.getDockState!=`function`){w(!0);return}let t=!1;return e.terminal.getDockState().then(e=>{t||!e.visible||(T.current=!0,y(!0))}).catch(uI).finally(()=>{t||w(!0)}),()=>{t=!0}},_e=[],t[35]=ge,t[36]=_e):(ge=t[35],_e=t[36]),(0,Q.useEffect)(ge,_e);let ve,ye;t[37]===v?(ve=t[38],ye=t[39]):(ve=()=>{if(window.okDesktop!=null){if(T.current){T.current=!1;return}v&&Wa()}},ye=[v],t[37]=v,t[38]=ve,t[39]=ye),(0,Q.useEffect)(ve,ye),Qg(H?.pausedReason),$g();let be;t[40]===a?be=t[41]:(be=function(e){s(e),a(e)},t[40]=a,t[41]=be);let xe=be,Se,Ce;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(Se=()=>{d(`auth`),l(!0)},Ce=()=>{d(`identity`),l(!0)},t[42]=Se,t[43]=Ce):(Se=t[42],Ce=t[43]);let we;t[44]===r?we=t[45]:(we=(0,Z.jsx)(IF,{onSignIn:Se,onSetIdentity:Ce,onOpenSearch:r}),t[44]=r,t[45]=we);let Te=_?V:void 0,Ee;t[46]!==f||t[47]!==o||t[48]!==xe||t[49]!==Te||t[50]!==O||t[51]!==v?(Ee=(0,Z.jsx)(LM,{editorMode:o,onModeChange:xe,activeTab:f,onActiveTabChange:p,terminalBridge:g,terminalVisible:v,onTerminalVisibleChange:y,terminalDock:O,onTerminalPlacement:I,onRevealTerminal:Te}),t[46]=f,t[47]=o,t[48]=xe,t[49]=Te,t[50]=O,t[51]=v,t[52]=Ee):Ee=t[52];let De;t[53]!==b||t[54]!==O||t[55]!==E||t[56]!==F||t[57]!==v||t[58]!==N?(De=_&&g!=null?(0,Z.jsx)(nI,{bridge:g,visible:v,onVisibleChange:y,launch:E,installedClis:b,container:F.container,isShowing:F.isShowing,onRequestEditorFocus:()=>F.editorRegion?.focus(),dockPosition:O,onToggleDock:N,onHasSessionsChange:S}):null,t[53]=b,t[54]=O,t[55]=E,t[56]=F,t[57]=v,t[58]=N,t[59]=De):De=t[59];let Oe=u===`identity`,ke;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(ke=()=>{l(!1)},t[60]=ke):ke=t[60];let Ae;t[61]!==c||t[62]!==Oe?(Ae=(0,Z.jsx)(ja,{open:c,onOpenChange:l,identityPrompt:Oe,onSuccess:ke}),t[61]=c,t[62]=Oe,t[63]=Ae):Ae=t[63];let je;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(je=()=>h(!0),t[64]=je):je=t[64];let Me;t[65]===ie?Me=t[66]:(Me=(0,Z.jsx)(x_,{open:ie,onResolved:je}),t[65]=ie,t[66]=Me);let Ne;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=(0,Z.jsx)(Rg,{}),t[67]=Ne):Ne=t[67];let Pe;return t[68]!==we||t[69]!==Ee||t[70]!==De||t[71]!==Ae||t[72]!==Me?(Pe=(0,Z.jsxs)(Z.Fragment,{children:[we,Ee,De,Ae,Me,Ne]}),t[68]=we,t[69]=Ee,t[70]=De,t[71]=Ae,t[72]=Me,t[73]=Pe):Pe=t[73],Pe}function uI(e){console.error(`[terminal] dock-state restore failed; staying hidden:`,e)}function dI(e){return!e}function fI(e){return!e}function pI(e){let t=yl(ol(e));typeof window>`u`||window.location.hash!==t&&(window.location.hash=t)}function mI(){let e=(0,$.c)(11),{conflicts:t,loading:n,error:r}=To();if(n)return null;if(r===`server`){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`section`,{"data-testid":`conflicts-section`,"aria-label":`Conflicted files`,className:`border-b border-amber-200/60 bg-amber-50/40 px-2 py-2 dark:border-amber-900/40 dark:bg-amber-950/20`,children:(0,Z.jsxs)(`p`,{"data-testid":`conflicts-section-error`,className:`px-2 py-1.5 text-[12px] text-amber-700 dark:text-amber-400`,children:[(0,Z.jsx)(Yi,{"aria-hidden":`true`,className:`mr-1.5 inline size-3`}),`Couldn't load conflicts — reload to retry.`]})}),e[0]=t):t=e[0],t}if(t.length===0)return null;let i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-[11px] uppercase tracking-wider text-amber-700 dark:text-amber-400`,children:[(0,Z.jsx)(Yi,{"aria-hidden":`true`,className:`size-3`}),`Conflicts`]}),e[1]=i):i=e[1];let a;e[2]===t.length?a=e[3]:(a=(0,Z.jsxs)(`header`,{className:`flex items-center justify-between px-2 pb-1.5`,children:[i,(0,Z.jsx)(`span`,{"data-testid":`conflicts-section-count`,className:`rounded-full bg-amber-500 px-1.5 py-0.5 font-mono text-[10px] font-medium leading-none text-white`,children:t.length})]}),e[2]=t.length,e[3]=a);let o;e[4]===t?o=e[5]:(o=t.map(hI),e[4]=t,e[5]=o);let s;e[6]===o?s=e[7]:(s=(0,Z.jsx)(`ul`,{className:`flex flex-col gap-px`,children:o}),e[6]=o,e[7]=s);let c;return e[8]!==a||e[9]!==s?(c=(0,Z.jsxs)(`section`,{"data-testid":`conflicts-section`,"aria-label":`Conflicted files`,className:`border-b border-amber-200/60 bg-amber-50/40 px-2 py-2 dark:border-amber-900/40 dark:bg-amber-950/20`,children:[a,s]}),e[8]=a,e[9]=s,e[10]=c):c=e[10],c}function hI(e){return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(X,{variant:`ghost`,size:`sm`,"data-testid":`conflicts-section-row`,"data-file":e.file,title:e.file,className:`h-7 w-full justify-start gap-1.5 px-2 font-normal text-[13px] text-amber-800 hover:bg-amber-100/60 hover:text-amber-900 dark:text-amber-300 dark:hover:bg-amber-900/30 dark:hover:text-amber-200`,onClick:()=>pI(e.file),children:[(0,Z.jsx)(Yi,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.file})]})},e.file)}var gI=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
30
30
  <symbol id="file-tree-icon-chevron" viewBox="0 0 16 16">
31
31
  <path d="M12.4697 5.46973C12.7626 5.17684 13.2374 5.17684 13.5303 5.46973C13.8232 5.76262 13.8232 6.23738 13.5303 6.53028L8.53028 11.5303C8.23738 11.8232 7.76262 11.8232 7.46973 11.5303L2.46973 6.53028C2.17684 6.23738 2.17684 5.76262 2.46973 5.46973C2.76262 5.17684 3.23738 5.17684 3.53028 5.46973L8 9.93946L12.4697 5.46973Z" fill="currentcolor"/>
32
32
  </symbol>