@inkeep/open-knowledge 0.5.0-beta.47 → 0.5.0-beta.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/skills/open-knowledge/SKILL.md +1 -1
- package/dist/cli.mjs +4 -4
- package/dist/constants-BvIV9-u3.mjs +2 -0
- package/dist/index.mjs +1 -1
- package/dist/{init-CmQ_C7Dm.mjs → init-C9ho5PLw.mjs} +3 -3
- package/dist/init-Dft22e1h.mjs +1 -0
- package/dist/loader-B5wdvkGE.mjs +1 -0
- package/dist/{loader-CHhQuNxK.mjs → loader-F8wUMFGk.mjs} +2 -2
- package/dist/preview-DIuZwdT3.mjs +1 -0
- package/dist/{preview-CIgVuEry.mjs → preview-DM4jIpLN.mjs} +2 -2
- package/dist/public/assets/{ActivityModeContent-fhFzM0sk.js → ActivityModeContent-B8J4OFHO.js} +1 -1
- package/dist/public/assets/ConsentDialogBody-Dfx6N7pC.js +2 -0
- package/dist/public/assets/{DocumentContext-LS9HBbXh.js → DocumentContext-fSMev29P.js} +2 -2
- package/dist/public/assets/McpConsentDialogBody-fka4wJP7.js +1 -0
- package/dist/public/assets/{SettingsDialogBody-alvj4xbx.js → SettingsDialogBody-8zs3jwhI.js} +1 -1
- package/dist/public/assets/{SourceEditor-CuJQDNNo.js → SourceEditor-BCHJFeGa.js} +1 -1
- package/dist/public/assets/{config-validation-events-Dxvq0Gmu.js → config-validation-events-BtPgkHlf.js} +1 -1
- package/dist/public/assets/{index-D6UM1028.js → index-BZCMU4ot.js} +7 -7
- package/dist/public/assets/{index-BgKCFonW.css → index-D9afOIIc.css} +1 -1
- package/dist/public/assets/{typing-burst-detector-mzjjQOqs.js → typing-burst-detector-Cm3a_0Rp.js} +1 -1
- package/dist/public/index.html +5 -5
- package/dist/{repair-launch-json-tbV_XaNr.mjs → repair-launch-json-yfbhku73.mjs} +2 -2
- package/dist/{repair-mcp-configs-B9q5NKQh.mjs → repair-mcp-configs-3DOkuM0T.mjs} +2 -2
- package/dist/{src-CzxqX1w-.mjs → src-6iWoC0XU.mjs} +2 -2
- package/dist/{start-B5WsKMpt.mjs → start-CO8Evcw9.mjs} +2 -2
- package/dist/start-Caiq4CNh.mjs +1 -0
- package/package.json +1 -1
- package/dist/constants-BbmMpMCp.mjs +0 -2
- package/dist/init-CU0LqAeV.mjs +0 -1
- package/dist/loader-CKCKCJLW.mjs +0 -1
- package/dist/preview-DA93kG_C.mjs +0 -1
- package/dist/public/assets/ConsentDialogBody-CSNo2n5l.js +0 -2
- package/dist/public/assets/McpConsentDialogBody-Cp08S9eY.js +0 -1
- package/dist/start-Duh1Cxij.mjs +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./telemetry-impl-DPRMO_b_.js","./chunk-CFjPhJqf.js","./preload-helper-2ej06EnG.js","./trace-api-CiCjX4Sz.js","./propagation-api-3kmMXRwS.js","./ConsentDialogBody-
|
|
2
|
-
import{o as e,t}from"./chunk-CFjPhJqf.js";import{t as n}from"./preload-helper-2ej06EnG.js";import{n as r,r as i,t as a}from"./compiler-runtime-CVnuRdak.js";import{$ as o,A as s,An as c,At as l,B as u,Bn as d,Bt as f,C as p,Cn as m,Ct as h,Dn as g,Dt as _,En as v,Et as y,F as b,Fn as x,Ft as S,G as C,Gt as w,H as T,Hn as E,Ht as D,I as O,In as k,It as A,J as j,Jn as M,Jt as N,K as P,Kn as F,Kt as I,L,Ln as R,Lt as z,M as B,Mn as V,Mt as H,N as U,Nn as W,Nt as G,On as K,Ot as q,P as ee,Pn as te,Pt as ne,Q as re,R as ie,Rn as ae,Rt as oe,S as se,Sn as ce,St as le,T as J,Tn as ue,Tt as de,Un as fe,Ut as pe,V as me,Vn as he,Vt as ge,W as _e,Wn as ve,Wt as ye,X as be,Xn as xe,Xt as Se,Y as Ce,Yn as we,Z as Te,Zn as Ee,_ as De,_n as Oe,_t as ke,a as Ae,at as je,bn as Me,bt as Ne,c as Pe,cn as Fe,ct as Ie,d as Le,dn as Re,et as ze,f as Be,fn as Ve,g as He,gn as Ue,gt as We,hn as Ge,ht as Ke,i as qe,it as Je,j as Ye,jn as Xe,jt as Ze,kn as Qe,kt as $e,l as et,ln as tt,lt as nt,m as rt,mn as it,mt as at,n as ot,nt as st,o as ct,ot as lt,p as ut,pn as dt,pt as ft,q as pt,qn as mt,qt as ht,r as gt,rt as _t,s as vt,st as yt,t as bt,tt as xt,u as St,un as Ct,ut as wt,vn as Tt,vt as Et,w as Dt,wn as Ot,wt as kt,x as At,xn as jt,xt as Mt,yn as Nt,yt as Pt,z as Ft,zn as It,zt as Lt}from"./DocumentContext-LS9HBbXh.js";import{A as Rt,C as zt,D as Bt,E as Vt,O as Ht,S as Ut,T as Wt,_ as Gt,a as Kt,b as qt,c as Jt,d as Yt,f as Xt,g as Zt,h as Qt,i as $t,k as en,l as tn,m as nn,n as rn,p as an,r as on,s as sn,t as cn,u as ln,v as un,w as dn,x as fn,y as pn}from"./panel-Co559KoC.js";import{B as mn,C as hn,Cn as gn,Cr as _n,D as vn,E as yn,En as bn,F as xn,Fn as Sn,G as Cn,Gr as wn,H as Tn,I as En,Ir as Dn,J as On,Jt as kn,Kr as An,Kt as jn,L as Mn,Ln as Nn,Lr as Pn,Mr as Fn,Mt as In,Nn as Ln,Nr as Rn,O as zn,R as Bn,Rn as Vn,S as Hn,Sr as Un,St as Wn,T as Gn,Tn as Kn,Tt as qn,U as Jn,Ur as Yn,V as Xn,Vt as Zn,W as Qn,Wt as $n,X as er,Xn as tr,Y as nr,Yt as rr,Zt as ir,_n as ar,a as or,b as sr,bn as cr,bt as lr,c as ur,ci as dr,cn as fr,di as pr,dn as mr,dt as hr,et as gr,f as _r,fi as vr,fr as yr,g as br,gn as xr,gr as Sr,hr as Cr,ht as wr,i as Tr,ir as Er,jn as Dr,jr as Or,k as kr,kn as Ar,l as jr,li as Mr,ln as Nr,lr as Pr,m as Fr,mr as Ir,mt as Lr,n as Rr,o as zr,on as Br,pr as Vr,qn as Hr,qr as Ur,qt as Wr,r as Gr,rn as Kr,s as qr,t as Jr,u as Yr,ui as Xr,un as Zr,ur as Qr,vn as $r,vt as ei,w as ti,wn as ni,wr as ri,wt as ii,x as ai,xr as oi,yn as si,yr as ci,yt as li,z as ui,zr as di,zt as fi}from"./doc-hash-CMD_NjP8.js";import{C as pi,S as mi,b as hi,c as gi,d as _i,g as vi,l as yi,m as bi,o as xi,p as Si,r as Ci,t as Y,w as wi,x as Ti}from"./button-DBLnjjvQ.js";import{a as Ei,c as Di,d as Oi,f as ki,i as Ai,l as ji,m as Mi,n as Ni,o as Pi,p as Fi,r as Ii,s as Li,t as Ri,u as zi}from"./agent-presence-8VSgL2U2.js";import{$ as Bi,A as Vi,At as Hi,B as Ui,C as Wi,Ct as Gi,D as Ki,Dt as qi,E as Ji,Et as Yi,F as Xi,Ft as Zi,G as Qi,H as $i,I as ea,J as ta,K as na,L as ra,M as ia,N as aa,Nt as oa,O as sa,Ot as ca,P as la,Pt as ua,Q as da,R as fa,S as pa,St as ma,T as ha,Tt as ga,U as _a,V as va,W as ya,X as ba,Y as xa,Z as Sa,_ as Ca,_t as wa,a as Ta,at as Ea,b as Da,bt as Oa,ct as ka,dt as Aa,et as ja,ft as Ma,g as Na,gt as Pa,h as Fa,ht as Ia,it as La,j as Ra,jt as za,k as Ba,kt as Va,lt as Ha,m as Ua,mt as Wa,nt as Ga,o as Ka,ot as qa,p as Ja,pt as Ya,q as Xa,r as Za,rt as Qa,st as $a,t as eo,tt as to,u as no,ut as ro,v as io,vt as ao,w as oo,wt as so,x as co,xt as lo,y as uo,yt as fo,z as po}from"./config-validation-events-Dxvq0Gmu.js";import{n as mo,t as ho}from"./target-navigation-intent-DxRtD10o.js";import{C as go,S as _o,a as vo,b as yo,c as bo,d as xo,f as So,h as Co,i as wo,l as To,m as Eo,n as Do,o as Oo,p as ko,s as Ao,t as jo,u as Mo,x as X}from"./dialog-DSzqKgdW.js";import{a as No,i as Po,n as Fo,r as Io,t as Lo}from"./collapsible-L2bca9Ur.js";import{t as Ro}from"./checkbox-kroC1jEP.js";import{a as zo,i as Bo,n as Vo,o as Ho,r as Uo,t as Wo}from"./toggle-group-DQWMrY_b.js";import{t as Go}from"./label-CdSs0Skc.js";import{i as Ko,n as qo,r as Jo}from"./project-paths-DKT5BePl.js";import{n as Yo,t as Xo}from"./mcp-consent-store-BPw6Zd40.js";import{$ as Zo,At as Qo,Ct as $o,Dt as es,Ft as ts,I as ns,It as rs,J as is,Mt as as,Ot as os,Pt as ss,Q as cs,Tt as ls,X as us,Z as ds,at as fs,bt as ps,c as ms,jt as hs,k as gs,w as _s}from"./dist-D3YXABda.js";import{n as vs}from"./dist-D-oqC0-R.js";import{n as ys,o as bs,r as xs,t as Ss}from"./typing-burst-detector-mzjjQOqs.js";import{t as Cs}from"./textarea-5ach84qM.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function ws(){({BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1})?.VITE_OTEL_ENABLED===`true`&&n(()=>import(`./telemetry-impl-DPRMO_b_.js`).then(e=>e.install()),__vite__mapDeps([0,1,2,3,4]),import.meta.url)}function Ts(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{Zt(e,()=>t.signal,()=>n=!0)},u=pn(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?un:Gt;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?Ds:Es,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Es(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function Es(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Ds(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Os=class extends Xt{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||ks(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=an({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}})(this.state),Qt.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function ks(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var As=class extends Rt{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Os({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=js(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=js(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=js(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=js(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){Qt.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>zt(t,e))}findAll(e={}){return this.getAll().filter(t=>zt(e,t))}notify(e){Qt.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return Qt.batch(()=>Promise.all(e.map(e=>e.continue().catch(Wt))))}};function js(e){return e.options.scope?.id}var Ms=class extends Rt{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??Ut(r,t),a=this.get(i);return a||(a=new Yt({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){Qt.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>dn(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>dn(e,t)):t}notify(e){Qt.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Qt.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Qt.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Ns=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Ms,this.#t=e.mutationCache||new As,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=en.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=nn.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Bt(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=qt(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return Qt.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;Qt.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return Qt.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=Qt.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Wt).catch(Wt)}invalidateQueries(e,t={}){return Qt.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=Qt.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(Wt)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Wt)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Bt(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Wt).catch(Wt)}fetchInfiniteQuery(e){return e.behavior=Ts(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Wt).catch(Wt)}ensureInfiniteQueryData(e){return e.behavior=Ts(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return nn.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(fn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Vt(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(fn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Vt(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=Ut(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===Ht&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Ps=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Fs=t(((e,t)=>{t.exports=Ps()})),Is=t((e=>{var t=Fs(),n=r(),i=wi();function a(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function s(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function c(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(s(e)!==e)throw Error(a(188))}function d(e){var t=e.alternate;if(!t){if(t=s(e),t===null)throw Error(a(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return u(i),e;if(o===r)return u(i),t;o=o.sibling}throw Error(a(188))}if(n.return!==r.return)n=i,r=o;else{for(var c=!1,l=i.child;l;){if(l===n){c=!0,n=i,r=o;break}if(l===r){c=!0,r=i,n=o;break}l=l.sibling}if(!c){for(l=o.child;l;){if(l===n){c=!0,n=o,r=i;break}if(l===r){c=!0,r=o,n=i;break}l=l.sibling}if(!c)throw Error(a(189))}}if(n.alternate!==r)throw Error(a(190))}if(n.tag!==3)throw Error(a(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var p=Object.assign,m=Symbol.for(`react.element`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.memo_cache_sentinel`),k=Symbol.iterator;function A(e){return typeof e!=`object`||!e?null:(e=k&&e[k]||e[`@@iterator`],typeof e==`function`?e:null)}var j=Symbol.for(`react.client.reference`);function M(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===j?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return t=e.displayName||null,t===null?M(e.type)||`Memo`:t;case E:t=e._payload,e=e._init;try{return M(e(t))}catch{}}return null}var N=Array.isArray,P=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},L=[],R=-1;function z(e){return{current:e}}function B(e){0>R||(e.current=L[R],L[R]=null,R--)}function V(e,t){R++,L[R]=e.current,e.current=t}var H=z(null),U=z(null),W=z(null),G=z(null);function K(e,t){switch(V(W,t),V(U,e),V(H,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}B(H),V(H,e)}function q(){B(H),B(U),B(W)}function ee(e){e.memoizedState!==null&&V(G,e);var t=H.current,n=Hd(t,e.type);t!==n&&(V(U,e),V(H,n))}function te(e){U.current===e&&(B(H),B(U)),G.current===e&&(B(G),Qf._currentValue=I)}var ne,re;function ie(e){if(ne===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ne=t&&t[1]||``,re=-1<e.stack.indexOf(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./telemetry-impl-DPRMO_b_.js","./chunk-CFjPhJqf.js","./preload-helper-2ej06EnG.js","./trace-api-CiCjX4Sz.js","./propagation-api-3kmMXRwS.js","./ConsentDialogBody-Dfx6N7pC.js","./button-DBLnjjvQ.js","./compiler-runtime-CVnuRdak.js","./checkbox-kroC1jEP.js","./dialog-DSzqKgdW.js","./collapsible-L2bca9Ur.js","./textarea-5ach84qM.js","./project-paths-DKT5BePl.js","./McpConsentDialogBody-fka4wJP7.js","./label-CdSs0Skc.js","./mcp-consent-store-BPw6Zd40.js","./ActivityPanelDiffView-d4ec9M69.js","./ActivityPanelDiffView-legcy4jI.css","./GraphPanel-CbVOnaKD.js","./doc-hash-CMD_NjP8.js","./w3c-keyname-B5t0fahT.js","./toggle-group-DQWMrY_b.js","./panel-Co559KoC.js","./min-CHzARyU6.js","./src-Dz70a8sm.js","./colors-CuFmRbNJ.js","./ordinal-Dk6d5Y-0.js","./init-D-V7N9g_.js","./isObjectLike-HLvQwJYx.js","./now-BN_Nj6nz.js","./isSymbol-BKUBGC2u.js","./target-navigation-intent-DxRtD10o.js","./ActivityModeContent-B8J4OFHO.js","./DocumentContext-fSMev29P.js","./dist-DllAuqQQ.js","./dist-D3YXABda.js","./dist-D-oqC0-R.js","./dist-DXgyWuz5.js","./dist-DQ1oWohr.js","./stex-ChE_gMQ6.js","./DocumentContext-B0sQn39F.css","./agent-presence-8VSgL2U2.js","./SettingsDialogBody-8zs3jwhI.js","./config-validation-events-BtPgkHlf.js","./SourceEditor-BCHJFeGa.js","./typing-burst-detector-Cm3a_0Rp.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e,t}from"./chunk-CFjPhJqf.js";import{t as n}from"./preload-helper-2ej06EnG.js";import{n as r,r as i,t as a}from"./compiler-runtime-CVnuRdak.js";import{$ as o,A as s,An as c,At as l,B as u,Bn as d,Bt as f,C as p,Cn as m,Ct as h,Dn as g,Dt as _,En as v,Et as y,F as b,Fn as x,Ft as S,G as C,Gt as w,H as T,Hn as E,Ht as D,I as O,In as k,It as A,J as j,Jn as M,Jt as N,K as P,Kn as F,Kt as I,L,Ln as R,Lt as z,M as B,Mn as V,Mt as H,N as U,Nn as W,Nt as G,On as K,Ot as q,P as ee,Pn as te,Pt as ne,Q as re,R as ie,Rn as ae,Rt as oe,S as se,Sn as ce,St as le,T as J,Tn as ue,Tt as de,Un as fe,Ut as pe,V as me,Vn as he,Vt as ge,W as _e,Wn as ve,Wt as ye,X as be,Xn as xe,Xt as Se,Y as Ce,Yn as we,Z as Te,Zn as Ee,_ as De,_n as Oe,_t as ke,a as Ae,at as je,bn as Me,bt as Ne,c as Pe,cn as Fe,ct as Ie,d as Le,dn as Re,et as ze,f as Be,fn as Ve,g as He,gn as Ue,gt as We,hn as Ge,ht as Ke,i as qe,it as Je,j as Ye,jn as Xe,jt as Ze,kn as Qe,kt as $e,l as et,ln as tt,lt as nt,m as rt,mn as it,mt as at,n as ot,nt as st,o as ct,ot as lt,p as ut,pn as dt,pt as ft,q as pt,qn as mt,qt as ht,r as gt,rt as _t,s as vt,st as yt,t as bt,tt as xt,u as St,un as Ct,ut as wt,vn as Tt,vt as Et,w as Dt,wn as Ot,wt as kt,x as At,xn as jt,xt as Mt,yn as Nt,yt as Pt,z as Ft,zn as It,zt as Lt}from"./DocumentContext-fSMev29P.js";import{A as Rt,C as zt,D as Bt,E as Vt,O as Ht,S as Ut,T as Wt,_ as Gt,a as Kt,b as qt,c as Jt,d as Yt,f as Xt,g as Zt,h as Qt,i as $t,k as en,l as tn,m as nn,n as rn,p as an,r as on,s as sn,t as cn,u as ln,v as un,w as dn,x as fn,y as pn}from"./panel-Co559KoC.js";import{B as mn,C as hn,Cn as gn,Cr as _n,D as vn,E as yn,En as bn,F as xn,Fn as Sn,G as Cn,Gr as wn,H as Tn,I as En,Ir as Dn,J as On,Jt as kn,Kr as An,Kt as jn,L as Mn,Ln as Nn,Lr as Pn,Mr as Fn,Mt as In,Nn as Ln,Nr as Rn,O as zn,R as Bn,Rn as Vn,S as Hn,Sr as Un,St as Wn,T as Gn,Tn as Kn,Tt as qn,U as Jn,Ur as Yn,V as Xn,Vt as Zn,W as Qn,Wt as $n,X as er,Xn as tr,Y as nr,Yt as rr,Zt as ir,_n as ar,a as or,b as sr,bn as cr,bt as lr,c as ur,ci as dr,cn as fr,di as pr,dn as mr,dt as hr,et as gr,f as _r,fi as vr,fr as yr,g as br,gn as xr,gr as Sr,hr as Cr,ht as wr,i as Tr,ir as Er,jn as Dr,jr as Or,k as kr,kn as Ar,l as jr,li as Mr,ln as Nr,lr as Pr,m as Fr,mr as Ir,mt as Lr,n as Rr,o as zr,on as Br,pr as Vr,qn as Hr,qr as Ur,qt as Wr,r as Gr,rn as Kr,s as qr,t as Jr,u as Yr,ui as Xr,un as Zr,ur as Qr,vn as $r,vt as ei,w as ti,wn as ni,wr as ri,wt as ii,x as ai,xr as oi,yn as si,yr as ci,yt as li,z as ui,zr as di,zt as fi}from"./doc-hash-CMD_NjP8.js";import{C as pi,S as mi,b as hi,c as gi,d as _i,g as vi,l as yi,m as bi,o as xi,p as Si,r as Ci,t as Y,w as wi,x as Ti}from"./button-DBLnjjvQ.js";import{a as Ei,c as Di,d as Oi,f as ki,i as Ai,l as ji,m as Mi,n as Ni,o as Pi,p as Fi,r as Ii,s as Li,t as Ri,u as zi}from"./agent-presence-8VSgL2U2.js";import{$ as Bi,A as Vi,At as Hi,B as Ui,C as Wi,Ct as Gi,D as Ki,Dt as qi,E as Ji,Et as Yi,F as Xi,Ft as Zi,G as Qi,H as $i,I as ea,J as ta,K as na,L as ra,M as ia,N as aa,Nt as oa,O as sa,Ot as ca,P as la,Pt as ua,Q as da,R as fa,S as pa,St as ma,T as ha,Tt as ga,U as _a,V as va,W as ya,X as ba,Y as xa,Z as Sa,_ as Ca,_t as wa,a as Ta,at as Ea,b as Da,bt as Oa,ct as ka,dt as Aa,et as ja,ft as Ma,g as Na,gt as Pa,h as Fa,ht as Ia,it as La,j as Ra,jt as za,k as Ba,kt as Va,lt as Ha,m as Ua,mt as Wa,nt as Ga,o as Ka,ot as qa,p as Ja,pt as Ya,q as Xa,r as Za,rt as Qa,st as $a,t as eo,tt as to,u as no,ut as ro,v as io,vt as ao,w as oo,wt as so,x as co,xt as lo,y as uo,yt as fo,z as po}from"./config-validation-events-BtPgkHlf.js";import{n as mo,t as ho}from"./target-navigation-intent-DxRtD10o.js";import{C as go,S as _o,a as vo,b as yo,c as bo,d as xo,f as So,h as Co,i as wo,l as To,m as Eo,n as Do,o as Oo,p as ko,s as Ao,t as jo,u as Mo,x as X}from"./dialog-DSzqKgdW.js";import{a as No,i as Po,n as Fo,r as Io,t as Lo}from"./collapsible-L2bca9Ur.js";import{t as Ro}from"./checkbox-kroC1jEP.js";import{a as zo,i as Bo,n as Vo,o as Ho,r as Uo,t as Wo}from"./toggle-group-DQWMrY_b.js";import{t as Go}from"./label-CdSs0Skc.js";import{i as Ko,n as qo,r as Jo}from"./project-paths-DKT5BePl.js";import{n as Yo,t as Xo}from"./mcp-consent-store-BPw6Zd40.js";import{$ as Zo,At as Qo,Ct as $o,Dt as es,Ft as ts,I as ns,It as rs,J as is,Mt as as,Ot as os,Pt as ss,Q as cs,Tt as ls,X as us,Z as ds,at as fs,bt as ps,c as ms,jt as hs,k as gs,w as _s}from"./dist-D3YXABda.js";import{n as vs}from"./dist-D-oqC0-R.js";import{n as ys,o as bs,r as xs,t as Ss}from"./typing-burst-detector-Cm3a_0Rp.js";import{t as Cs}from"./textarea-5ach84qM.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function ws(){({BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1})?.VITE_OTEL_ENABLED===`true`&&n(()=>import(`./telemetry-impl-DPRMO_b_.js`).then(e=>e.install()),__vite__mapDeps([0,1,2,3,4]),import.meta.url)}function Ts(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{Zt(e,()=>t.signal,()=>n=!0)},u=pn(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?un:Gt;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?Ds:Es,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Es(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function Es(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Ds(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Os=class extends Xt{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||ks(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=an({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}})(this.state),Qt.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function ks(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var As=class extends Rt{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Os({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=js(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=js(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=js(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=js(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){Qt.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>zt(t,e))}findAll(e={}){return this.getAll().filter(t=>zt(e,t))}notify(e){Qt.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return Qt.batch(()=>Promise.all(e.map(e=>e.continue().catch(Wt))))}};function js(e){return e.options.scope?.id}var Ms=class extends Rt{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??Ut(r,t),a=this.get(i);return a||(a=new Yt({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){Qt.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>dn(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>dn(e,t)):t}notify(e){Qt.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Qt.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Qt.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Ns=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Ms,this.#t=e.mutationCache||new As,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=en.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=nn.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Bt(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=qt(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return Qt.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;Qt.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return Qt.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=Qt.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Wt).catch(Wt)}invalidateQueries(e,t={}){return Qt.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=Qt.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(Wt)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Wt)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Bt(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Wt).catch(Wt)}fetchInfiniteQuery(e){return e.behavior=Ts(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Wt).catch(Wt)}ensureInfiniteQueryData(e){return e.behavior=Ts(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return nn.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(fn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Vt(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(fn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Vt(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=Ut(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===Ht&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Ps=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Fs=t(((e,t)=>{t.exports=Ps()})),Is=t((e=>{var t=Fs(),n=r(),i=wi();function a(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function s(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function c(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(s(e)!==e)throw Error(a(188))}function d(e){var t=e.alternate;if(!t){if(t=s(e),t===null)throw Error(a(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return u(i),e;if(o===r)return u(i),t;o=o.sibling}throw Error(a(188))}if(n.return!==r.return)n=i,r=o;else{for(var c=!1,l=i.child;l;){if(l===n){c=!0,n=i,r=o;break}if(l===r){c=!0,r=i,n=o;break}l=l.sibling}if(!c){for(l=o.child;l;){if(l===n){c=!0,n=o,r=i;break}if(l===r){c=!0,r=o,n=i;break}l=l.sibling}if(!c)throw Error(a(189))}}if(n.alternate!==r)throw Error(a(190))}if(n.tag!==3)throw Error(a(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var p=Object.assign,m=Symbol.for(`react.element`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.memo_cache_sentinel`),k=Symbol.iterator;function A(e){return typeof e!=`object`||!e?null:(e=k&&e[k]||e[`@@iterator`],typeof e==`function`?e:null)}var j=Symbol.for(`react.client.reference`);function M(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===j?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return t=e.displayName||null,t===null?M(e.type)||`Memo`:t;case E:t=e._payload,e=e._init;try{return M(e(t))}catch{}}return null}var N=Array.isArray,P=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},L=[],R=-1;function z(e){return{current:e}}function B(e){0>R||(e.current=L[R],L[R]=null,R--)}function V(e,t){R++,L[R]=e.current,e.current=t}var H=z(null),U=z(null),W=z(null),G=z(null);function K(e,t){switch(V(W,t),V(U,e),V(H,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}B(H),V(H,e)}function q(){B(H),B(U),B(W)}function ee(e){e.memoizedState!==null&&V(G,e);var t=H.current,n=Hd(t,e.type);t!==n&&(V(U,e),V(H,n))}function te(e){U.current===e&&(B(H),B(U)),G.current===e&&(B(G),Qf._currentValue=I)}var ne,re;function ie(e){if(ne===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ne=t&&t[1]||``,re=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+ne+e+re}var ae=!1;function oe(e,t){if(!e||ae)return``;ae=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,`props`,{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,`name`,{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
5
5
|
`),l=s.split(`
|
|
@@ -10,7 +10,7 @@ Error generating stack: `+e.message+`
|
|
|
10
10
|
`).replace(kd,``)}function jd(e,t){return t=Ad(t),Ad(e)===t}function Md(e,t,n,r,i,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Nt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Nt(e,``+r);break;case`className`:_t(e,`class`,r);break;case`tabIndex`:_t(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:_t(e,n,r);break;case`style`:It(e,r,o);break;case`data`:if(t!==`object`){_t(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Bt(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&Md(e,t,`name`,i.name,i,null),Md(e,t,`formEncType`,i.formEncType,i,null),Md(e,t,`formMethod`,i.formMethod,i,null),Md(e,t,`formTarget`,i.formTarget,i,null)):(Md(e,t,`encType`,i.encType,i,null),Md(e,t,`method`,i.method,i,null),Md(e,t,`target`,i.target,i,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Bt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Vt);break;case`onScroll`:r!=null&&vd(`scroll`,e);break;case`onScrollEnd`:r!=null&&vd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(a(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(a(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Bt(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:vd(`beforetoggle`,e),vd(`toggle`,e),gt(e,`popover`,r);break;case`xlinkActuate`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:vt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:vt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:vt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:gt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Rt.get(n)||n,gt(e,n,r))}}function Nd(e,t,n,r,i,o){switch(n){case`style`:It(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(a(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(a(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Nt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Nt(e,``+r);break;case`onScroll`:r!=null&&vd(`scroll`,e);break;case`onScrollEnd`:r!=null&&vd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=Vt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!lt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(i=n.endsWith(`Capture`),t=n.slice(2,i?n.length-7:void 0),o=e[Ye]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,i),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,i);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):gt(e,n,r)}}}function Pd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:vd(`error`,e),vd(`load`,e);var r=!1,i=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:i=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(a(137,t));default:Md(e,t,o,s,n,null)}}i&&Md(e,t,`srcSet`,n.srcSet,n,null),r&&Md(e,t,`src`,n.src,n,null);return;case`input`:vd(`invalid`,e);var c=o=s=i=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:i=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(a(137,t));break;default:Md(e,t,r,d,n,null)}}Ot(e,o,c,l,u,s,i,!1);return;case`select`:for(i in vd(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(i)&&(c=n[i],c!=null))switch(i){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Md(e,t,i,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&At(e,!!r,n,!0):At(e,!!r,t,!1);return;case`textarea`:for(s in vd(`invalid`,e),o=i=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:i=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(a(91));break;default:Md(e,t,s,c,n,null)}Mt(e,r,i,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Md(e,t,l,r,n,null)}return;case`dialog`:vd(`beforetoggle`,e),vd(`toggle`,e),vd(`cancel`,e),vd(`close`,e);break;case`iframe`:case`object`:vd(`load`,e);break;case`video`:case`audio`:for(r=0;r<hd.length;r++)vd(hd[r],e);break;case`image`:vd(`error`,e),vd(`load`,e);break;case`details`:vd(`toggle`,e);break;case`embed`:case`source`:case`link`:vd(`error`,e),vd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(a(137,t));default:Md(e,t,u,r,n,null)}return;default:if(Lt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Nd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Md(e,t,c,r,n,null))}function Fd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var i=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Md(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:i=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(a(137,t));break;default:m!==f&&Md(e,t,p,m,r,f)}}Dt(e,s,c,l,u,d,o,i);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Md(e,t,o,null,r,l)}for(i in r)if(o=r[i],l=n[i],r.hasOwnProperty(i)&&(o!=null||l!=null))switch(i){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Md(e,t,i,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?At(e,!!n,n?[]:``,!1):At(e,!!n,t,!0)):At(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(i=n[c],n.hasOwnProperty(c)&&i!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Md(e,t,c,null,r,i)}for(s in r)if(i=r[s],o=n[s],r.hasOwnProperty(s)&&(i!=null||o!=null))switch(s){case`value`:p=i;break;case`defaultValue`:m=i;break;case`children`:break;case`dangerouslySetInnerHTML`:if(i!=null)throw Error(a(91));break;default:i!==o&&Md(e,t,s,i,r,o)}jt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Md(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Md(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Md(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(a(137,t));break;default:Md(e,t,u,p,r,m)}return;default:if(Lt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Nd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Nd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Md(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Md(e,t,f,p,r,m)}function Id(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Ld(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Id(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Id(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Rd=null,zd=null;function Bd(e){return e.nodeType===9?e:e.ownerDocument}function Vd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Hd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Ud(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Wd=null;function Gd(){var e=window.event;return e&&e.type===`popstate`?e===Wd?!1:(Wd=e,!0):(Wd=null,!1)}var Kd=typeof setTimeout==`function`?setTimeout:void 0,qd=typeof clearTimeout==`function`?clearTimeout:void 0,Jd=typeof Promise==`function`?Promise:void 0,Yd=typeof queueMicrotask==`function`?queueMicrotask:Jd===void 0?Kd:function(e){return Jd.resolve(null).then(e).catch(Xd)};function Xd(e){setTimeout(function(){throw e})}function Zd(e){return e===`head`}function Qd(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Np(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)pf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,pf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[tt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&pf(e.ownerDocument.body);n=i}while(n);Np(t)}function $d(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function ef(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:ef(n),nt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function tf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[tt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=cf(e.nextSibling),e===null)break}return null}function nf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=cf(e.nextSibling),e===null))return null;return e}function rf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=cf(e.nextSibling),e===null))return null;return e}function af(e){return e.data===`$?`||e.data===`$~`}function of(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function sf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function cf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var lf=null;function uf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return cf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function df(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function ff(e,t,n){switch(t=Bd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(a(452));return e;case`head`:if(e=t.head,!e)throw Error(a(453));return e;case`body`:if(e=t.body,!e)throw Error(a(454));return e;default:throw Error(a(451))}}function pf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);nt(e)}var mf=new Map,hf=new Set;function gf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var _f=F.d;F.d={f:vf,r:yf,D:Sf,C:Cf,L:wf,m:Tf,X:Df,S:Ef,M:Of};function vf(){var e=_f.f(),t=_u();return e||t}function yf(e){var t=it(e);t!==null&&t.tag===5&&t.type===`form`?vs(t):_f.r(e)}var bf=typeof document>`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=Et(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),st(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Et(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Et(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Et(n.imageSizes)+`"]`)):i+=`[href="`+Et(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=p({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),st(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Et(r)+`"][href="`+Et(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=p({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),st(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=ot(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=p({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);st(c),Pd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=ot(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=p({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),st(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=ot(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=p({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),st(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var i=(i=W.current)?gf(i):null;if(!i)throw Error(a(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=ot(i).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Af(n.href);var o=ot(i).hoistableStyles,s=o.get(e);if(s||(i=i.ownerDocument||i,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=i.querySelector(jf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),o||Nf(i,e,n,s.state))),t&&r===null)throw Error(a(528,``));return s}if(t&&r!==null)throw Error(a(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=ot(i).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(a(444,e))}}function Af(e){return`href="`+Et(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return p({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),st(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Et(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Et(n.href)+`"]`);if(r)return t.instance=r,st(r),r;var i=p({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),st(r),Pd(r,`style`,i),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Af(n.href);var o=e.querySelector(jf(i));if(o)return t.state.loading|=4,t.instance=o,st(o),o;r=Mf(n),(i=mf.get(i))&&Rf(r,i),o=(e.ownerDocument||e).createElement(`link`),st(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Pd(o,`link`,r),t.state.loading|=4,Lf(o,n.precedence,e),t.instance=o;case`script`:return o=Pf(n.src),(i=e.querySelector(Ff(o)))?(t.instance=i,st(i),i):(r=n,(i=mf.get(o))&&(r=p({},n),zf(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),st(i),Pd(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(a(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Rf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function zf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Bf=null;function Vf(e,t,n){if(Bf===null){var r=new Map,i=Bf=new Map;i.set(n,r)}else i=Bf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[tt]||a[Je]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Hf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Uf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,st(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),st(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&Kf===0&&(Kf=62500*Ld());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Jf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var Qf={$$typeof:x,Provider:null,Consumer:null,_currentValue:I,_currentValue2:I,_threadCount:0};function $f(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Le(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Le(0),this.hiddenUpdates=Le(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function ep(e,t,n,r,i,a,o,s,c,l,u,d){return e=new $f(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Xr(3,null,null,t),e.current=a,a.stateNode=e,t=Zi(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Aa(a),e}function tp(e){return e?(e=Jr,e):Jr}function np(e,t,n,r,i,a){i=tp(i),r.context===null?r.context=i:r.pendingContext=i,r=Ma(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Na(e,r,t),n!==null&&(fu(n,e,t),Pa(n,e,t))}function rp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ip(e,t){rp(e,t),(e=e.alternate)&&rp(e,t)}function ap(e){if(e.tag===13||e.tag===31){var t=Gr(e,67108864);t!==null&&fu(t,e,67108864),ip(e,67108864)}}function op(e){if(e.tag===13||e.tag===31){var t=uu();t=Ue(t);var n=Gr(e,t);n!==null&&fu(n,e,t),ip(e,t)}}var sp=!0;function cp(e,t,n,r){var i=P.T;P.T=null;var a=F.p;try{F.p=2,up(e,t,n,r)}finally{F.p=a,P.T=i}}function lp(e,t,n,r){var i=P.T;P.T=null;var a=F.p;try{F.p=8,up(e,t,n,r)}finally{F.p=a,P.T=i}}function up(e,t,n,r){if(sp){var i=dp(r);if(i===null)Cd(e,t,r,fp,n),Cp(e,r);else if(Tp(i,e,t,n,r))r.stopPropagation();else if(Cp(e,r),t&4&&-1<Sp.indexOf(e)){for(;i!==null;){var a=it(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Me(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Te(o);s.entanglements[1]|=c,o&=~c}td(a),!(jl&6)&&(Ql=pe()+500,nd(0,!1))}}break;case 31:case 13:s=Gr(a,2),s!==null&&fu(s,a,2),_u(),ip(a,2)}if(a=dp(r),a===null&&Cd(e,t,r,fp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Cd(e,t,r,null,n)}}function dp(e){return e=Ut(e),pp(e)}var fp=null;function pp(e){if(fp=null,e=rt(e),e!==null){var t=s(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=c(t),e!==null)return e;e=null}else if(n===31){if(e=l(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return fp=e,null}function mp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(me()){case he:return 2;case ge:return 8;case _e:case ve:return 32;case ye:return 268435456;default:return 32}default:return 32}}var hp=!1,gp=null,_p=null,vp=null,yp=new Map,bp=new Map,xp=[],Sp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Cp(e,t){switch(e){case`focusin`:case`focusout`:gp=null;break;case`dragenter`:case`dragleave`:_p=null;break;case`mouseover`:case`mouseout`:vp=null;break;case`pointerover`:case`pointerout`:yp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:bp.delete(t.pointerId)}}function wp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=it(t),t!==null&&ap(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Tp(e,t,n,r,i){switch(t){case`focusin`:return gp=wp(gp,e,t,n,r,i),!0;case`dragenter`:return _p=wp(_p,e,t,n,r,i),!0;case`mouseover`:return vp=wp(vp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return yp.set(a,wp(yp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,bp.set(a,wp(bp.get(a)||null,e,t,n,r,i)),!0}return!1}function Ep(e){var t=rt(e.target);if(t!==null){var n=s(t);if(n!==null){if(t=n.tag,t===13){if(t=c(n),t!==null){e.blockedOn=t,Ke(e.priority,function(){op(n)});return}}else if(t===31){if(t=l(n),t!==null){e.blockedOn=t,Ke(e.priority,function(){op(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Dp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=dp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Ht=r,n.target.dispatchEvent(r),Ht=null}else return t=it(n),t!==null&&ap(t),e.blockedOn=n,!1;t.shift()}return!0}function Op(e,t,n){Dp(e)&&n.delete(t)}function kp(){hp=!1,gp!==null&&Dp(gp)&&(gp=null),_p!==null&&Dp(_p)&&(_p=null),vp!==null&&Dp(vp)&&(vp=null),yp.forEach(Op),bp.forEach(Op)}function Ap(e,n){e.blockedOn===n&&(e.blockedOn=null,hp||(hp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,kp)))}var jp=null;function Mp(e){jp!==e&&(jp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){jp===e&&(jp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(pp(r||n)===null)continue;break}var a=it(n);a!==null&&(e.splice(t,3),t-=3,gs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Np(e){function t(t){return Ap(t,e)}gp!==null&&Ap(gp,e),_p!==null&&Ap(_p,e),vp!==null&&Ap(vp,e),yp.forEach(t),bp.forEach(t);for(var n=0;n<xp.length;n++){var r=xp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<xp.length&&(n=xp[0],n.blockedOn===null);)Ep(n),n.blockedOn===null&&xp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[Ye]||null;if(typeof a==`function`)o||Mp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[Ye]||null)s=o.formAction;else if(pp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Mp(n)}}}function Pp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Fp(e){this._internalRoot=e}Ip.prototype.render=Fp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(a(409));var n=t.current;np(n,uu(),e,t,null,null)},Ip.prototype.unmount=Fp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;np(e.current,2,null,e,null,null),_u(),t[Xe]=null}};function Ip(e){this._internalRoot=e}Ip.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ge();e={blockedOn:null,target:e,priority:t};for(var n=0;n<xp.length&&t!==0&&t<xp[n].priority;n++);xp.splice(n,0,e),n===0&&Ep(e)}};var Lp=n.version;if(Lp!==`19.2.5`)throw Error(a(527,Lp,`19.2.5`));F.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(a(188)):(e=Object.keys(e).join(`,`),Error(a(268,e)));return e=d(t),e=e===null?null:f(e),e=e===null?null:e.stateNode,e};var Rp={bundleType:0,version:`19.2.5`,rendererPackageName:`react-dom`,currentDispatcherRef:P,reconcilerVersion:`19.2.5`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var zp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zp.isDisabled&&zp.supportsFiber)try{Se=zp.inject(Rp),Ce=zp}catch{}}e.createRoot=function(e,t){if(!o(e))throw Error(a(299));var n=!1,r=``,i=Bs,s=Vs,c=Z;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(i=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=ep(e,1,!1,null,null,n,r,null,i,s,c,Pp),e[Xe]=t.current,xd(e),new Fp(t)}})),Ls=t(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Is()})),Rs=pi(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),zs=pi(`arrow-up-down`,[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]),Bs=pi(`bird`,[[`path`,{d:`M16 7h.01`,key:`1kdx03`}],[`path`,{d:`M3.4 18H12a8 8 0 0 0 8-8V7a4 4 0 0 0-7.28-2.3L2 20`,key:`oj1oa8`}],[`path`,{d:`m20 7 2 .5-2 .5`,key:`12nv4d`}],[`path`,{d:`M10 18v3`,key:`1yea0a`}],[`path`,{d:`M14 17.75V21`,key:`1pymcb`}],[`path`,{d:`M7 18a6 6 0 0 0 3.84-10.61`,key:`1npnn0`}]]),Vs=pi(`bold`,[[`path`,{d:`M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8`,key:`mg9rjx`}]]),Z=i(),Q=e(r(),1),Hs=e(wi(),1),Us=Ls(),$=a(),Ws=[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]];pi(`bot`,Ws);var Gs=pi(`case-sensitive`,[[`path`,{d:`m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16`,key:`d5nyq2`}],[`path`,{d:`M22 9v7`,key:`pvm9v3`}],[`path`,{d:`M3.304 13h6.392`,key:`1q3zxz`}],[`circle`,{cx:`18.5`,cy:`12.5`,r:`3.5`,key:`z97x68`}]]),Ks=pi(`cat`,[[`path`,{d:`M12 5c.67 0 1.35.09 2 .26 1.78-2 5.03-2.84 6.42-2.26 1.4.58-.42 7-.42 7 .57 1.07 1 2.24 1 3.44C21 17.9 16.97 21 12 21s-9-3-9-7.56c0-1.25.5-2.4 1-3.44 0 0-1.89-6.42-.5-7 1.39-.58 4.72.23 6.5 2.23A9.04 9.04 0 0 1 12 5Z`,key:`x6xyqk`}],[`path`,{d:`M8 14v.5`,key:`1nzgdb`}],[`path`,{d:`M16 14v.5`,key:`1lajdz`}],[`path`,{d:`M11.25 16.25h1.5L12 17l-.75-.75Z`,key:`12kq1m`}]]),qs=pi(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Js=pi(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Ys=pi(`cloud-off`,[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Xs=pi(`cloud`,[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]),Zs=pi(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Qs=pi(`columns-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]]),$s=pi(`columns-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),ec=pi(`compass`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}]]),tc=pi(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),nc=pi(`diamond`,[[`path`,{d:`M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z`,key:`1f1r0c`}]]),rc=pi(`dog`,[[`path`,{d:`M11.25 16.25h1.5L12 17z`,key:`w7jh35`}],[`path`,{d:`M16 14v.5`,key:`1lajdz`}],[`path`,{d:`M4.42 11.247A13.152 13.152 0 0 0 4 14.556C4 18.728 7.582 21 12 21s8-2.272 8-6.444a11.702 11.702 0 0 0-.493-3.309`,key:`u7s9ue`}],[`path`,{d:`M8 14v.5`,key:`1nzgdb`}],[`path`,{d:`M8.5 8.5c-.384 1.05-1.083 2.028-2.344 2.5-1.931.722-3.576-.297-3.656-1-.113-.994 1.177-6.53 4-7 1.923-.321 3.651.845 3.651 2.235A7.497 7.497 0 0 1 14 5.277c0-1.39 1.844-2.598 3.767-2.277 2.823.47 4.113 6.006 4 7-.08.703-1.725 1.722-3.656 1-1.261-.472-1.855-1.45-2.239-2.5`,key:`v8hric`}]]),ic=pi(`file-archive`,[[`path`,{d:`M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5`,key:`4pqfef`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 12v-1`,key:`1ej8lb`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`path`,{d:`M8 7V6`,key:`1nbb54`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]),ac=pi(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),oc=pi(`file-plus`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]),sc=pi(`fish`,[[`path`,{d:`M6.5 12c.94-3.46 4.94-6 8.5-6 3.56 0 6.06 2.54 7 6-.94 3.47-3.44 6-7 6s-7.56-2.53-8.5-6Z`,key:`15baut`}],[`path`,{d:`M18 12v.5`,key:`18hhni`}],[`path`,{d:`M16 17.93a9.77 9.77 0 0 1 0-11.86`,key:`16dt7o`}],[`path`,{d:`M7 10.67C7 8 5.58 5.97 2.73 5.5c-1 1.5-1 5 .23 6.5-1.24 1.5-1.24 5-.23 6.5C5.58 18.03 7 16 7 13.33`,key:`l9di03`}],[`path`,{d:`M10.46 7.26C10.2 5.88 9.17 4.24 8 3h5.8a2 2 0 0 1 1.98 1.67l.23 1.4`,key:`1kjonw`}],[`path`,{d:`m16.01 17.93-.23 1.4A2 2 0 0 1 13.8 21H9.5a5.96 5.96 0 0 0 1.49-3.98`,key:`1zlm23`}]]),cc=pi(`fold-vertical`,[[`path`,{d:`M12 22v-6`,key:`6o8u61`}],[`path`,{d:`M12 8V2`,key:`1wkif3`}],[`path`,{d:`M4 12H2`,key:`rhcxmi`}],[`path`,{d:`M10 12H8`,key:`s88cx1`}],[`path`,{d:`M16 12h-2`,key:`10asgb`}],[`path`,{d:`M22 12h-2`,key:`14jgyd`}],[`path`,{d:`m15 19-3-3-3 3`,key:`e37ymu`}],[`path`,{d:`m15 5-3 3-3-3`,key:`19d6lf`}]]),lc=pi(`folder-cog`,[[`path`,{d:`M10.3 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.98a2 2 0 0 1 1.69.9l.66 1.2A2 2 0 0 0 12 6h8a2 2 0 0 1 2 2v3.3`,key:`128dxu`}],[`path`,{d:`m14.305 19.53.923-.382`,key:`3m78fa`}],[`path`,{d:`m15.228 16.852-.923-.383`,key:`npixar`}],[`path`,{d:`m16.852 15.228-.383-.923`,key:`5xggr7`}],[`path`,{d:`m16.852 20.772-.383.924`,key:`dpfhf9`}],[`path`,{d:`m19.148 15.228.383-.923`,key:`1reyyz`}],[`path`,{d:`m19.53 21.696-.382-.924`,key:`1goivc`}],[`path`,{d:`m20.772 16.852.924-.383`,key:`htqkph`}],[`path`,{d:`m20.772 19.148.924.383`,key:`9w9pjp`}],[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}]]),uc=pi(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),dc=pi(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),fc=pi(`grid-2x2-x`,[[`path`,{d:`M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3`,key:`11za1p`}],[`path`,{d:`m16 16 5 5`,key:`8tpb07`}],[`path`,{d:`m16 21 5-5`,key:`193jll`}]]),pc=pi(`hard-drive`,[[`path`,{d:`M10 16h.01`,key:`1bzywj`}],[`path`,{d:`M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`18tbho`}],[`path`,{d:`M21.946 12.013H2.054`,key:`zqlbp7`}],[`path`,{d:`M6 16h.01`,key:`1pmjb7`}]]),mc=pi(`highlighter`,[[`path`,{d:`m9 11-6 6v3h9l3-3`,key:`1a3l36`}],[`path`,{d:`m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4`,key:`14a9rk`}]]),hc=pi(`italic`,[[`line`,{x1:`19`,x2:`10`,y1:`4`,y2:`4`,key:`15jd3p`}],[`line`,{x1:`14`,x2:`5`,y1:`20`,y2:`20`,key:`bu0au3`}],[`line`,{x1:`15`,x2:`9`,y1:`4`,y2:`20`,key:`uljnxc`}]]),gc=pi(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),_c=pi(`library`,[[`path`,{d:`m16 6 4 14`,key:`ji33uf`}],[`path`,{d:`M12 6v14`,key:`1n7gus`}],[`path`,{d:`M8 8v12`,key:`1gg7y9`}],[`path`,{d:`M4 4v16`,key:`6qkkli`}]]),vc=pi(`link`,[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]),yc=pi(`list-collapse`,[[`path`,{d:`M10 5h11`,key:`1hkqpe`}],[`path`,{d:`M10 12h11`,key:`6m4ad9`}],[`path`,{d:`M10 19h11`,key:`14g2nv`}],[`path`,{d:`m3 10 3-3-3-3`,key:`i7pm08`}],[`path`,{d:`m3 20 3-3-3-3`,key:`20gx1n`}]]),bc=pi(`list-plus`,[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M11 12H3`,key:`51ecnj`}],[`path`,{d:`M16 19H3`,key:`zzsher`}],[`path`,{d:`M18 9v6`,key:`1twb98`}],[`path`,{d:`M21 12h-6`,key:`bt1uis`}]]),xc=pi(`list-tree`,[[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`M3 10a2 2 0 0 0 2 2h3`,key:`1npucw`}],[`path`,{d:`M3 5v12a2 2 0 0 0 2 2h3`,key:`x1gjn2`}]]),Sc=pi(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),Cc=pi(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),wc=pi(`octagon-x`,[[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z`,key:`2d38gg`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),Tc=pi(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),Ec=pi(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),Dc=pi(`panel-right-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]),Oc=pi(`panel-right-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]),kc=pi(`pen-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),Ac=pi(`pilcrow`,[[`path`,{d:`M13 4v16`,key:`8vvj80`}],[`path`,{d:`M17 4v16`,key:`7dpous`}],[`path`,{d:`M19 4H9.5a4.5 4.5 0 0 0 0 9H13`,key:`sh4n9v`}]]),jc=pi(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),Mc=pi(`rabbit`,[[`path`,{d:`M13 16a3 3 0 0 1 2.24 5`,key:`1epib5`}],[`path`,{d:`M18 12h.01`,key:`yjnet6`}],[`path`,{d:`M18 21h-8a4 4 0 0 1-4-4 7 7 0 0 1 7-7h.2L9.6 6.4a1 1 0 1 1 2.8-2.8L15.8 7h.2c3.3 0 6 2.7 6 6v1a2 2 0 0 1-2 2h-1a3 3 0 0 0-3 3`,key:`ue9ozu`}],[`path`,{d:`M20 8.54V4a2 2 0 1 0-4 0v3`,key:`49iql8`}],[`path`,{d:`M7.612 12.524a3 3 0 1 0-1.6 4.3`,key:`1e33i0`}]]),Nc=pi(`rat`,[[`path`,{d:`M13 22H4a2 2 0 0 1 0-4h12`,key:`bt3f23`}],[`path`,{d:`M13.236 18a3 3 0 0 0-2.2-5`,key:`1tbvmo`}],[`path`,{d:`M16 9h.01`,key:`1bdo4e`}],[`path`,{d:`M16.82 3.94a3 3 0 1 1 3.237 4.868l1.815 2.587a1.5 1.5 0 0 1-1.5 2.1l-2.872-.453a3 3 0 0 0-3.5 3`,key:`9ch7kn`}],[`path`,{d:`M17 4.988a3 3 0 1 0-5.2 2.052A7 7 0 0 0 4 14.015 4 4 0 0 0 8 18`,key:`3s7e9i`}]]),Pc=pi(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Fc=pi(`replace-all`,[[`path`,{d:`M14 14a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1`,key:`zg1ipl`}],[`path`,{d:`M14 4a1 1 0 0 1 1-1`,key:`dhj8ez`}],[`path`,{d:`M15 10a1 1 0 0 1-1-1`,key:`1mnyi5`}],[`path`,{d:`M19 14a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1`,key:`txt6k4`}],[`path`,{d:`M21 4a1 1 0 0 0-1-1`,key:`sfs9ap`}],[`path`,{d:`M21 9a1 1 0 0 1-1 1`,key:`mp6qeo`}],[`path`,{d:`m3 7 3 3 3-3`,key:`x25e72`}],[`path`,{d:`M6 10V5a2 2 0 0 1 2-2h2`,key:`15xut4`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}]]),Ic=pi(`replace`,[[`path`,{d:`M14 4a1 1 0 0 1 1-1`,key:`dhj8ez`}],[`path`,{d:`M15 10a1 1 0 0 1-1-1`,key:`1mnyi5`}],[`path`,{d:`M21 4a1 1 0 0 0-1-1`,key:`sfs9ap`}],[`path`,{d:`M21 9a1 1 0 0 1-1 1`,key:`mp6qeo`}],[`path`,{d:`m3 7 3 3 3-3`,key:`x25e72`}],[`path`,{d:`M6 10V5a2 2 0 0 1 2-2h2`,key:`15xut4`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}]]),Lc=pi(`rows-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}]]),Rc=pi(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),zc=pi(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Bc=pi(`share-2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]),Vc=pi(`shrimp`,[[`path`,{d:`M11 12h.01`,key:`1lr4k6`}],[`path`,{d:`M13 22c.5-.5 1.12-1 2.5-1-1.38 0-2-.5-2.5-1`,key:`fatpdi`}],[`path`,{d:`M14 2a3.28 3.28 0 0 1-3.227 1.798l-6.17-.561A2.387 2.387 0 1 0 4.387 8H15.5a1 1 0 0 1 0 13 1 1 0 0 0 0-5H12a7 7 0 0 1-7-7V8`,key:`kehrqe`}],[`path`,{d:`M14 8a8.5 8.5 0 0 1 0 8`,key:`1imjx2`}],[`path`,{d:`M16 16c2 0 4.5-4 4-6`,key:`z0nejz`}]]),Hc=pi(`snail`,[[`path`,{d:`M2 13a6 6 0 1 0 12 0 4 4 0 1 0-8 0 2 2 0 0 0 4 0`,key:`hneq2s`}],[`circle`,{cx:`10`,cy:`13`,r:`8`,key:`194lz3`}],[`path`,{d:`M2 21h12c4.4 0 8-3.6 8-8V7a2 2 0 1 0-4 0v6`,key:`ixqyt7`}],[`path`,{d:`M18 3 19.1 5.2`,key:`9tjm43`}],[`path`,{d:`M22 3 20.9 5.2`,key:`j3odrs`}]]),Uc=pi(`square-code`,[[`path`,{d:`m10 9-3 3 3 3`,key:`1oro0q`}],[`path`,{d:`m14 15 3-3-3-3`,key:`bz13h7`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]),Wc=pi(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Gc=pi(`squirrel`,[[`path`,{d:`M15.236 22a3 3 0 0 0-2.2-5`,key:`21bitc`}],[`path`,{d:`M16 20a3 3 0 0 1 3-3h1a2 2 0 0 0 2-2v-2a4 4 0 0 0-4-4V4`,key:`oh0fg0`}],[`path`,{d:`M18 13h.01`,key:`9veqaj`}],[`path`,{d:`M18 6a4 4 0 0 0-4 4 7 7 0 0 0-7 7c0-5 4-5 4-10.5a4.5 4.5 0 1 0-9 0 2.5 2.5 0 0 0 5 0C7 10 3 11 3 17c0 2.8 2.2 5 5 5h10`,key:`980v8a`}]]),Kc=pi(`sticky-note`,[[`path`,{d:`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,key:`1dfntj`}],[`path`,{d:`M15 3v5a1 1 0 0 0 1 1h5`,key:`6s6qgf`}]]),qc=pi(`strikethrough`,[[`path`,{d:`M16 4H9a3 3 0 0 0-2.83 4`,key:`43sutm`}],[`path`,{d:`M14 12a4 4 0 0 1 0 8H6`,key:`nlfj13`}],[`line`,{x1:`4`,x2:`20`,y1:`12`,y2:`12`,key:`1e0a9i`}]]),Jc=pi(`table-properties`,[[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M21 9H3`,key:`1338ky`}],[`path`,{d:`M21 15H3`,key:`9uk58r`}]]),Yc=pi(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),Xc=pi(`turtle`,[[`path`,{d:`m12 10 2 4v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-3a8 8 0 1 0-16 0v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-3l2-4h4Z`,key:`1lbbv7`}],[`path`,{d:`M4.82 7.9 8 10`,key:`m9wose`}],[`path`,{d:`M15.18 7.9 12 10`,key:`p8dp2u`}],[`path`,{d:`M16.93 10H20a2 2 0 0 1 0 4H2`,key:`12nsm7`}]]),Zc=pi(`underline`,[[`path`,{d:`M6 4v6a6 6 0 0 0 12 0V4`,key:`9kb039`}],[`line`,{x1:`4`,x2:`20`,y1:`20`,y2:`20`,key:`nun2al`}]]),Qc=pi(`unfold-vertical`,[[`path`,{d:`M12 22v-6`,key:`6o8u61`}],[`path`,{d:`M12 8V2`,key:`1wkif3`}],[`path`,{d:`M4 12H2`,key:`rhcxmi`}],[`path`,{d:`M10 12H8`,key:`s88cx1`}],[`path`,{d:`M16 12h-2`,key:`10asgb`}],[`path`,{d:`M22 12h-2`,key:`14jgyd`}],[`path`,{d:`m15 19-3 3-3-3`,key:`11eu04`}],[`path`,{d:`m15 5-3-3-3 3`,key:`itvq4r`}]]),$c=pi(`user-cog`,[[`path`,{d:`M10 15H6a4 4 0 0 0-4 4v2`,key:`1nfge6`}],[`path`,{d:`m14.305 16.53.923-.382`,key:`1itpsq`}],[`path`,{d:`m15.228 13.852-.923-.383`,key:`eplpkm`}],[`path`,{d:`m16.852 12.228-.383-.923`,key:`13v3q0`}],[`path`,{d:`m16.852 17.772-.383.924`,key:`1i8mnm`}],[`path`,{d:`m19.148 12.228.383-.923`,key:`1q8j1v`}],[`path`,{d:`m19.53 18.696-.382-.924`,key:`vk1qj3`}],[`path`,{d:`m20.772 13.852.924-.383`,key:`n880s0`}],[`path`,{d:`m20.772 16.148.924.383`,key:`1g6xey`}],[`circle`,{cx:`18`,cy:`15`,r:`3`,key:`gjjjvw`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),el=pi(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),tl=pi(`whole-word`,[[`circle`,{cx:`7`,cy:`12`,r:`3`,key:`12clwm`}],[`path`,{d:`M10 9v6`,key:`17i7lo`}],[`circle`,{cx:`17`,cy:`12`,r:`3`,key:`gl7c2s`}],[`path`,{d:`M14 7v8`,key:`dl84cr`}],[`path`,{d:`M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1`,key:`lt2kga`}]]);function nl(e,t){return e instanceof Error&&e.message?e.message:t}async function rl(e,t,n,r=`action`){try{n(null),await e()}catch(e){console.error(`[${r}] action failed:`,e),n(nl(e,t))}}async function il(e,t,n=X,r=`action`){await rl(e,t,e=>{e!==null&&n.error(e)},r)}function al(e){let t=/\/([^/]+?)(?:\.git)?\/?$/.exec(e);return t?t[1]:`repo`}function ol(e){return{async getAuthStatus(){return e.authQueryTransport.status()},async startSignIn(){return e.openSignIn()},async runClone({url:t}){let n=await e.bridge.dialog.openFolder();if(!n)return{kind:`cancelled`};let r=al(t),i=`${n.replace(/\/$/,``)}/${r}`,a=X.loading(`Cloning ${r}...`,{duration:1/0}),o=e.cloneTransport.start({url:t,dir:i});try{for await(let e of o.events){if(e.type===`progress`){X.loading(`Cloning ${r}...`,{id:a,description:`${e.phase} — ${Math.round(e.pct)}%`,duration:1/0});continue}if(e.type===`complete`)return X.success(`Cloned ${r}.`,{id:a,duration:4e3}),{kind:`ok`,dir:e.dir};if(e.type===`error`)return X.error(`Clone failed: ${e.message}`,{id:a,duration:8e3}),{kind:`error`}}return X.error(`Clone ended unexpectedly.`,{id:a,duration:8e3}),{kind:`error`}}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return X.error(`Clone failed: ${t}`,{id:a,duration:8e3}),{kind:`error`}}}}}async function sl(e){try{let t=await e.json(),n=fi.safeParse(t);if(n.success)return n.data.title}catch{}}async function cl(e,t){return fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})})}function ll(e){let t=e.split(`
|
|
11
11
|
`);for(let e=t.length-1;e>=0;e--){let n=t[e]?.trim();if(n)try{let e=JSON.parse(n);if(e&&typeof e==`object`)return e}catch{}}return null}function ul(){return{async status(e){let t=e?.host??`github.com`,n=await cl(`/api/local-op/auth/status`,e);if(!n.ok)return{authenticated:!1,host:t,error:await sl(n)};let r=await n.json(),i=typeof r.host==`string`?r.host:t;if(r.authenticated===!0&&typeof r.login==`string`){let e=r.tier===`A`||r.tier===`B`||r.tier===`C`?r.tier:void 0;return{authenticated:!0,host:i,login:r.login,tier:e,name:typeof r.name==`string`?r.name:void 0,email:typeof r.email==`string`?r.email:void 0}}return{authenticated:!1,host:i,error:typeof r.error==`string`?r.error:void 0}},async repos(e){let t=e?.host??`github.com`,n=await cl(`/api/local-op/auth/repos`,e);if(!n.ok)return{ok:!1,error:await sl(n)??`Failed to fetch repositories`};let r=ll(await n.text());if(r&&r.type===`error`&&r.problem&&typeof r.problem==`object`){let e=r.problem;return{ok:!1,error:e.detail||e.title||`Failed to fetch repositories`}}if(!r||!Array.isArray(r.repos))return{ok:!1,error:`Failed to fetch repositories`};let i=[];for(let e of r.repos){let t=e;typeof t?.full_name==`string`&&typeof t.clone_url==`string`&&i.push({full_name:t.full_name,clone_url:t.clone_url,private:t.private===!0})}return{ok:!0,host:typeof r.host==`string`?r.host:t,repos:i}}}}function dl(e){return{status:t=>e.localOp.authStatus(t),repos:t=>e.localOp.authRepos(t)}}async function fl(e,t){let n=e.getReader(),r=new TextDecoder,i=``;for(;;){let{done:e,value:a}=await n.read();if(e)return i+=r.decode(),!!(i.trim()&&t(i)===`terminal`);i+=r.decode(a,{stream:!0});let o=i.split(`
|
|
12
12
|
`);i=o.pop()??``;for(let e of o)if(e.trim()&&t(e)===`terminal`)return!0}}function pl(e){let t=[],n=[],r=new AbortController,i=!1,a=()=>{for(let e of n.splice(0))e(null)};return e(e=>{i||(n.length>0?n.shift()?.(e):t.push(e),(e.type===`complete`||e.type===`error`)&&(i=!0,r.abort(),a()))},r.signal),{events:{[Symbol.asyncIterator](){return{async next(){if(t.length>0){let e=t.shift();return e===void 0?{value:void 0,done:!0}:{value:e,done:!1}}return i?{value:void 0,done:!0}:new Promise(e=>{n.push(t=>{e(t===null?{value:void 0,done:!0}:{value:t,done:!1})})})}}}},cancel:()=>{i||(i=!0,r.abort(),a())}}}function ml(){return{start(){return pl((e,t)=>{(async()=>{try{let n=await fetch(`/api/local-op/auth/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({json:!0}),signal:t});if(!n.ok){let t=`Failed to start sign-in — try again`;try{let e=await n.json(),r=fi.safeParse(e);r.success&&(t=r.data.title)}catch{}e({type:`error`,message:t});return}if(!n.body){e({type:`error`,message:`Failed to start sign-in — try again`});return}!await fl(n.body,t=>{let n;try{n=JSON.parse(t)}catch{return console.warn(`[auth-transport] Dropped unparseable NDJSON line:`,t.slice(0,100)),`continue`}if(n&&typeof n==`object`&&n.type===`error`&&`problem`in n){let t=n.problem;return e({type:`error`,message:t?.detail||t?.title||`Unknown error`}),`terminal`}let r=n;return e(r),r.type===`complete`||r.type===`error`?`terminal`:`continue`})&&!t.aborted&&e({type:`error`,message:`Sign-in stream ended without confirmation — please try again`})}catch(t){if(t instanceof Error&&t.name===`AbortError`)return;e({type:`error`,message:`Connection error — try again`})}})()})}}}function hl(e){return{start(){return e.localOp.auth.start()}}}function gl(){return{start(e){return pl((t,n)=>{(async()=>{try{let r=await fetch(`/api/local-op/clone`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e.url,dir:e.dir||void 0}),signal:n});if(!r.ok){let e=`Clone failed — check the URL and try again (${r.status})`;try{let t=await r.json(),n=fi.safeParse(t);n.success&&(e=`Clone failed: ${n.data.title}`)}catch{}t({type:`error`,message:e});return}if(!r.body){t({type:`error`,message:`Clone failed — empty response body`});return}let i=r.body.getReader(),a=new TextDecoder,o=``;for(;;){let{done:e,value:r}=await i.read();if(e)break;o+=a.decode(r,{stream:!0});let s=o.split(`
|
|
13
|
-
`);o=s.pop()??``;for(let e of s){if(!e.trim())continue;let n;try{n=JSON.parse(e)}catch{console.warn(`[clone-transport] Dropped unparseable NDJSON line:`,e.slice(0,100));continue}if(n&&typeof n==`object`&&n.type===`error`&&`problem`in n){let e=n.problem;t({type:`error`,message:e?.detail||e?.title||`Unknown error`});break}t(n)}if(n.aborted)break}n.aborted||t({type:`error`,message:`Clone stream ended unexpectedly — check if the clone completed`})}catch(e){if(e instanceof Error&&e.name===`AbortError`)return;t({type:`error`,message:`Clone failed — connection error`})}})()})}}}function _l(e){return{start(t){return e.localOp.clone.start(t)}}}var vl=`ContextMenu`,[yl,bl]=Si(vl,[Va]),xl=Va(),[Sl,Cl]=yl(vl),wl=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,dir:i,modal:a=!0}=e,[o,s]=Q.useState(!1),c=xl(t),l=xi(r),u=Q.useCallback(e=>{s(e),l(e)},[l]);return(0,Z.jsx)(Sl,{scope:t,open:o,onOpenChange:u,modal:a,children:(0,Z.jsx)(so,{...c,dir:i,open:o,onOpenChange:u,modal:a,children:n})})};wl.displayName=vl;var Tl=`ContextMenuTrigger`,El=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,disabled:r=!1,...i}=e,a=Cl(Tl,n),o=xl(n),s=Q.useRef({x:0,y:0}),c=Q.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...s.current})}),l=Q.useRef(0),u=Q.useCallback(()=>window.clearTimeout(l.current),[]),d=e=>{s.current={x:e.clientX,y:e.clientY},a.onOpenChange(!0)};return Q.useEffect(()=>u,[u]),Q.useEffect(()=>void(r&&u()),[r,u]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ya,{...o,virtualRef:c}),(0,Z.jsx)(bi.span,{"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,...i,ref:t,style:{WebkitTouchCallout:`none`,...e.style},onContextMenu:r?e.onContextMenu:_i(e.onContextMenu,e=>{u(),d(e),e.preventDefault()}),onPointerDown:r?e.onPointerDown:_i(e.onPointerDown,tu(e=>{u(),l.current=window.setTimeout(()=>d(e),700)})),onPointerMove:r?e.onPointerMove:_i(e.onPointerMove,tu(u)),onPointerCancel:r?e.onPointerCancel:_i(e.onPointerCancel,tu(u)),onPointerUp:r?e.onPointerUp:_i(e.onPointerUp,tu(u))})]})});El.displayName=Tl;var Dl=`ContextMenuPortal`,Ol=e=>{let{__scopeContextMenu:t,...n}=e,r=xl(t);return(0,Z.jsx)(lo,{...r,...n})};Ol.displayName=Dl;var kl=`ContextMenuContent`,Al=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Cl(kl,n),a=xl(n),o=Q.useRef(!1);return(0,Z.jsx)(Pa,{...a,...r,ref:t,side:`right`,sideOffset:2,align:`start`,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),!t.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Al.displayName=kl;var jl=`ContextMenuGroup`,Ml=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(wa,{...i,...r,ref:t})});Ml.displayName=jl;var Nl=`ContextMenuLabel`,Pl=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(Oa,{...i,...r,ref:t})});Pl.displayName=Nl;var Fl=`ContextMenuItem`,Il=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(ao,{...i,...r,ref:t})});Il.displayName=Fl;var Ll=`ContextMenuCheckboxItem`,Rl=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(Ia,{...i,...r,ref:t})});Rl.displayName=Ll;var zl=`ContextMenuRadioGroup`,Bl=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(ma,{...i,...r,ref:t})});Bl.displayName=zl;var Vl=`ContextMenuRadioItem`,Hl=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(Gi,{...i,...r,ref:t})});Hl.displayName=Vl;var Ul=`ContextMenuItemIndicator`,Wl=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(fo,{...i,...r,ref:t})});Wl.displayName=Ul;var Gl=`ContextMenuSeparator`,Kl=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(ga,{...i,...r,ref:t})});Kl.displayName=Gl;var ql=`ContextMenuArrow`,Jl=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(Wa,{...i,...r,ref:t})});Jl.displayName=ql;var Yl=`ContextMenuSub`,Xl=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,open:i,defaultOpen:a}=e,o=xl(t),[s,c]=yi({prop:i,defaultProp:a??!1,onChange:r,caller:Yl});return(0,Z.jsx)(Yi,{...o,open:s,onOpenChange:c,children:n})};Xl.displayName=Yl;var Zl=`ContextMenuSubTrigger`,Ql=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(ca,{...i,...r,ref:t})});Ql.displayName=Zl;var $l=`ContextMenuSubContent`,eu=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(qi,{...i,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});eu.displayName=$l;function tu(e){return t=>t.pointerType===`mouse`?void 0:e(t)}var nu=wl,ru=El,iu=Ol,au=Al,ou=Il,su=Rl,cu=Wl,lu=Kl,uu=Xl,du=Ql,fu=eu,pu=`Radio`,[mu,hu]=Si(pu),[gu,_u]=mu(pu),vu=Q.forwardRef((e,t)=>{let{__scopeRadio:n,name:r,checked:i=!1,required:a,disabled:o,value:s=`on`,onCheck:c,form:l,...u}=e,[d,f]=Q.useState(null),p=hi(t,e=>f(e)),m=Q.useRef(!1),h=d?l||!!d.closest(`form`):!0;return(0,Z.jsxs)(gu,{scope:n,checked:i,disabled:o,children:[(0,Z.jsx)(bi.button,{type:`button`,role:`radio`,"aria-checked":i,"data-state":Cu(i),"data-disabled":o?``:void 0,disabled:o,value:s,...u,ref:p,onClick:_i(e.onClick,e=>{i||c?.(),h&&(m.current=e.isPropagationStopped(),m.current||e.stopPropagation())})}),h&&(0,Z.jsx)(Su,{control:d,bubbles:!m.current,name:r,value:s,checked:i,required:a,disabled:o,form:l,style:{transform:`translateX(-100%)`}})]})});vu.displayName=pu;var yu=`RadioIndicator`,bu=Q.forwardRef((e,t)=>{let{__scopeRadio:n,forceMount:r,...i}=e,a=_u(yu,n);return(0,Z.jsx)(gi,{present:r||a.checked,children:(0,Z.jsx)(bi.span,{"data-state":Cu(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t})})});bu.displayName=yu;var xu=`RadioBubbleInput`,Su=Q.forwardRef(({__scopeRadio:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=Q.useRef(null),s=hi(o,a),c=To(n),l=Ci(t);return Q.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,Z.jsx)(bi.input,{type:`radio`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});Su.displayName=xu;function Cu(e){return e?`checked`:`unchecked`}var wu=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`],Tu=`RadioGroup`,[Eu,Du]=Si(Tu,[Ho,hu]),Ou=Ho(),ku=hu(),[Au,ju]=Eu(Tu),Mu=Q.forwardRef((e,t)=>{let{__scopeRadioGroup:n,name:r,defaultValue:i,value:a,required:o=!1,disabled:s=!1,orientation:c,dir:l,loop:u=!0,onValueChange:d,...f}=e,p=Ou(n),m=Cn(l),[h,g]=yi({prop:a,defaultProp:i??null,onChange:d,caller:Tu});return(0,Z.jsx)(Au,{scope:n,name:r,required:o,disabled:s,value:h,onValueChange:g,children:(0,Z.jsx)(zo,{asChild:!0,...p,orientation:c,dir:m,loop:u,children:(0,Z.jsx)(bi.div,{role:`radiogroup`,"aria-required":o,"aria-orientation":c,"data-disabled":s?``:void 0,dir:m,...f,ref:t})})})});Mu.displayName=Tu;var Nu=`RadioGroupItem`,Pu=Q.forwardRef((e,t)=>{let{__scopeRadioGroup:n,disabled:r,...i}=e,a=ju(Nu,n),o=a.disabled||r,s=Ou(n),c=ku(n),l=Q.useRef(null),u=hi(t,l),d=a.value===i.value,f=Q.useRef(!1);return Q.useEffect(()=>{let e=e=>{wu.includes(e.key)&&(f.current=!0)},t=()=>f.current=!1;return document.addEventListener(`keydown`,e),document.addEventListener(`keyup`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`keyup`,t)}},[]),(0,Z.jsx)(Bo,{asChild:!0,...s,focusable:!o,active:d,children:(0,Z.jsx)(vu,{disabled:o,required:a.required,checked:d,...c,...i,name:a.name,ref:u,onCheck:()=>a.onValueChange(i.value),onKeyDown:_i(e=>{e.key===`Enter`&&e.preventDefault()}),onFocus:_i(i.onFocus,()=>{f.current&&l.current?.click()})})})});Pu.displayName=Nu;var Fu=`RadioGroupIndicator`,Iu=Q.forwardRef((e,t)=>{let{__scopeRadioGroup:n,...r}=e;return(0,Z.jsx)(bu,{...ku(n),...r,ref:t})});Iu.displayName=Fu;var Lu=Mu,Ru=Pu,zu=Iu;async function Bu(e){try{await navigator.clipboard.writeText(e)}catch{}}var Vu=120*1e3;function Hu(e){let t=(0,$.c)(26),{onSuccess:n,onCancel:r,transport:i}=e,[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(`https://github.com/login/device`),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(Vu),_=(0,Q.useRef)(null),v=(0,Q.useRef)(null),y;t[0]!==n||t[1]!==i?(y=async function(){f(null),m(!0);try{let e=i.start();_.current=e.cancel;let t=e.events[Symbol.asyncIterator](),r=!1,a=await t.next();for(;!a.done;){let e=a.value;if(e.type===`verification`)o(e.user_code),c(e.verification_uri),g(e.expires_in*1e3),Bu(e.user_code).then(()=>{u(!0),setTimeout(()=>u(!1),2e3)});else if(e.type===`complete`){r=!0,m(!1),n({login:e.login,name:e.name,email:e.email,avatarUrl:e.avatarUrl});break}else if(e.type===`error`){r=!0,f(e.message),m(!1);break}a=await t.next()}r||(f(`Sign-in stream ended without confirmation — please try again`),m(!1))}catch(e){let t=e;t instanceof Error&&t.name!==`AbortError`&&f(`Connection error — try again`),m(!1)}},t[0]=n,t[1]=i,t[2]=y):y=t[2];let b=y,x;t[3]===b?x=t[4]:(x=()=>{let e=!1;return queueMicrotask(()=>{e||b()}),()=>{e=!0,_.current?.(),_.current=null,v.current&&clearInterval(v.current)}},t[3]=b,t[4]=x);let S;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(S=[],t[5]=S):S=t[5],(0,Q.useEffect)(x,S);let C,w;t[6]===a?(C=t[7],w=t[8]):(C=()=>{if(!a)return;let e=Date.now();return v.current=setInterval(()=>{let t=Vu-(Date.now()-e);t<=0?(g(0),v.current&&clearInterval(v.current),f(`Code expired — please try again`)):g(t)},1e3),()=>{v.current&&clearInterval(v.current)}},w=[a],t[6]=a,t[7]=C,t[8]=w),(0,Q.useEffect)(C,w);let T=Math.floor(h/6e4),E=Math.floor(h%6e4/1e3),D;t[9]===E?D=t[10]:(D=E.toString().padStart(2,`0`),t[9]=E,t[10]=D);let O=`${T}:${D}`,k;t[11]!==l||t[12]!==d||t[13]!==O||t[14]!==a||t[15]!==s?(k=a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Open`,` `,(0,Z.jsx)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>Hi(e,s),onAuxClick:e=>Hi(e,s),className:`underline underline-offset-2`,children:s}),` `,`and enter this code:`]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`code`,{className:`flex-1 text-center text-2xl font-mono font-bold tracking-widest border rounded-md py-3 bg-muted`,children:a}),(0,Z.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>void Bu(a).then(()=>{u(!0),setTimeout(()=>u(!1),2e3)}),children:l?`Copied!`:`Copy`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-500 animate-pulse`}),`Waiting for authorization`]}),(0,Z.jsxs)(`span`,{children:[`Expires in `,O]})]})]}):(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-6 text-sm text-muted-foreground`,children:d?null:`Starting sign-in flow`}),t[11]=l,t[12]=d,t[13]=O,t[14]=a,t[15]=s,t[16]=k):k=t[16];let A;t[17]===d?A=t[18]:(A=d&&(0,Z.jsx)(`p`,{className:`text-sm text-destructive`,children:d}),t[17]=d,t[18]=A);let j;t[19]!==r||t[20]!==p?(j=p&&(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:r,children:`Cancel`}),t[19]=r,t[20]=p,t[21]=j):j=t[21];let M;return t[22]!==k||t[23]!==A||t[24]!==j?(M=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[k,A,j]}),t[22]=k,t[23]=A,t[24]=j,t[25]=M):M=t[25],M}function Uu(e){let t=(0,$.c)(32),{onSuccess:n,onCancel:r}=e,[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(null),d,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>()=>{u.current?.abort()},f=[],t[0]=d,t[1]=f):(d=t[0],f=t[1]),(0,Q.useEffect)(d,f);let p;t[2]!==n||t[3]!==i?(p=async function(){if(!i.trim()){l(`Paste a personal access token`);return}u.current?.abort();let e=new AbortController;u.current=e,s(!0),l(null);try{let t=await fetch(`/api/local-op/auth/pat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pat:i.trim()}),signal:e.signal});if(!t.ok){let e=`Invalid token — check that it has repo scope`;try{let n=await t.json(),r=fi.safeParse(n);r.success&&(e=r.data.title)}catch{}l(e),s(!1);return}if(!t.body){l(`Invalid token — check that it has repo scope`),s(!1);return}await fl(t.body,e=>{let t;try{t=JSON.parse(e)}catch{return`continue`}return t.type===`complete`?(n({login:t.login,name:t.name,email:t.email}),s(!1),`terminal`):`continue`})||l(`No response — try again`)}catch(e){let t=e;t instanceof Error&&t.name!==`AbortError`&&l(`Connection error — try again`)}s(!1)},t[2]=n,t[3]=i,t[4]=p):p=t[4];let m=p,h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(`a`,{href:`https://github.com/settings/tokens`,target:`_blank`,rel:`noopener noreferrer`,onClick:Gu,onAuxClick:Wu,className:`underline underline-offset-2`,children:`github.com/settings/tokens`}),t[5]=h):h=t[5];let g;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Create a token at`,` `,h,` `,`with `,(0,Z.jsx)(`code`,{className:`text-xs bg-muted px-1 rounded`,children:`repo`}),` scope.`]}),t[6]=g):g=t[6];let _;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>a(e.target.value),t[7]=_):_=t[7];let v;t[8]===m?v=t[9]:(v=e=>{e.key===`Enter`&&m()},t[8]=m,t[9]=v);let y;t[10]!==o||t[11]!==i||t[12]!==v?(y=(0,Z.jsx)(Po,{type:`password`,"aria-label":`Personal access token`,placeholder:`ghp_…`,value:i,onChange:_,disabled:o,onKeyDown:v}),t[10]=o,t[11]=i,t[12]=v,t[13]=y):y=t[13];let b;t[14]===c?b=t[15]:(b=c&&(0,Z.jsx)(`p`,{className:`text-sm text-destructive`,children:c}),t[14]=c,t[15]=b);let x;t[16]===m?x=t[17]:(x=()=>void m(),t[16]=m,t[17]=x);let S=o?`Validating`:`Add token`,C;t[18]!==o||t[19]!==x||t[20]!==S?(C=(0,Z.jsx)(Y,{className:`flex-1`,onClick:x,disabled:o,children:S}),t[18]=o,t[19]=x,t[20]=S,t[21]=C):C=t[21];let w;t[22]!==o||t[23]!==r?(w=(0,Z.jsx)(Y,{variant:`ghost`,onClick:r,disabled:o,children:`Cancel`}),t[22]=o,t[23]=r,t[24]=w):w=t[24];let T;t[25]!==C||t[26]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[C,w]}),t[25]=C,t[26]=w,t[27]=T):T=t[27];let E;return t[28]!==T||t[29]!==y||t[30]!==b?(E=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[g,y,b,T]}),t[28]=T,t[29]=y,t[30]=b,t[31]=E):E=t[31],E}function Wu(e){return Hi(e,`https://github.com/settings/tokens`)}function Gu(e){return Hi(e,`https://github.com/settings/tokens`)}function Ku(e){let t=(0,$.c)(27),{login:n,onSave:r,onSkip:i}=e,[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Before syncing, set your identity for git commits:`}),t[0]=l):l=t[0];let u=`Name (e.g. ${n})`,d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=e=>o(e.target.value),t[1]=d):d=t[1];let f;t[2]!==a||t[3]!==u?(f=(0,Z.jsx)(Po,{"aria-label":`Name`,placeholder:u,value:a,onChange:d}),t[2]=a,t[3]=u,t[4]=f):f=t[4];let p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>c(e.target.value),t[5]=p):p=t[5];let m;t[6]===s?m=t[7]:(m=(0,Z.jsx)(Po,{type:`email`,"aria-label":`Email`,placeholder:`Email`,value:s,onChange:p}),t[6]=s,t[7]=m);let h;t[8]!==s||t[9]!==a||t[10]!==r?(h=()=>r(a.trim(),s.trim()),t[8]=s,t[9]=a,t[10]=r,t[11]=h):h=t[11];let g;t[12]!==s||t[13]!==a?(g=!a.trim()||!s.trim(),t[12]=s,t[13]=a,t[14]=g):g=t[14];let _;t[15]!==h||t[16]!==g?(_=(0,Z.jsx)(Y,{className:`flex-1`,onClick:h,disabled:g,children:`Save`}),t[15]=h,t[16]=g,t[17]=_):_=t[17];let v;t[18]===i?v=t[19]:(v=(0,Z.jsx)(Y,{variant:`ghost`,onClick:i,children:`Skip`}),t[18]=i,t[19]=v);let y;t[20]!==v||t[21]!==_?(y=(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[_,v]}),t[20]=v,t[21]=_,t[22]=y):y=t[22];let b;return t[23]!==y||t[24]!==f||t[25]!==m?(b=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[l,f,m,y]}),t[23]=y,t[24]=f,t[25]=m,t[26]=b):b=t[26],b}function qu(e){let t=(0,$.c)(42),{open:n,onOpenChange:r,onSuccess:i,identityPrompt:a,reauth:o,transport:s}=e,c;t[0]===s?c=t[1]:(c=s??ml(),t[0]=s,t[1]=c);let l=c,[u,d]=(0,Q.useState)(`device`),[f,p]=(0,Q.useState)(`auth`),[m,h]=(0,Q.useState)(null),g,_;t[2]===n?(g=t[3],_=t[4]):(g=()=>{n&&(d(`device`),p(`auth`),h(null))},_=[n],t[2]=n,t[3]=g,t[4]=_),(0,Q.useEffect)(g,_);let v;t[5]!==a||t[6]!==r||t[7]!==i?(v=function(e){h(e),a&&(!e.name||!e.email)?p(`identity`):(p(`done`),i?.(e),r(!1),X.success(`Signed in as @${e.login}`))},t[5]=a,t[6]=r,t[7]=i,t[8]=v):v=t[8];let y=v,b;t[9]!==m||t[10]!==r||t[11]!==i?(b=function(e,t){fetch(`/api/local-op/auth/set-identity`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e,email:t})}).catch(Ju);let n={...m??{login:``},name:e,email:t};p(`done`),i?.(n),r(!1),X.success(`Signed in as @${n.login}`)},t[9]=m,t[10]=r,t[11]=i,t[12]=b):b=t[12];let x=b,S;t[13]!==m||t[14]!==r||t[15]!==i?(S=function(){m&&(p(`done`),i?.(m),r(!1),X.success(`Signed in as @${m.login}`))},t[13]=m,t[14]=r,t[15]=i,t[16]=S):S=t[16];let C=S,w;t[17]===r?w=t[18]:(w=function(){r(!1)},t[17]=r,t[18]=w);let T=w,E=o?`Re-authenticate with GitHub`:`Sign in to GitHub`,D;t[19]===E?D=t[20]:(D=(0,Z.jsx)(Ao,{children:(0,Z.jsx)(bo,{children:E})}),t[19]=E,t[20]=D);let O;t[21]!==y||t[22]!==T||t[23]!==l||t[24]!==f||t[25]!==u?(O=f===`auth`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex gap-1 border-b pb-2 mb-1`,children:[(0,Z.jsx)(Y,{variant:u===`device`?`secondary`:`ghost`,size:`sm`,onClick:()=>d(`device`),children:`GitHub App`}),(0,Z.jsx)(Y,{variant:u===`pat`?`secondary`:`ghost`,size:`sm`,onClick:()=>d(`pat`),children:`Token`})]}),u===`device`?(0,Z.jsx)(Hu,{onSuccess:y,onCancel:T,transport:l}):(0,Z.jsx)(Uu,{onSuccess:y,onCancel:T})]}),t[21]=y,t[22]=T,t[23]=l,t[24]=f,t[25]=u,t[26]=O):O=t[26];let k;t[27]!==m||t[28]!==x||t[29]!==C||t[30]!==f?(k=f===`identity`&&m&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Signed in as @`,m.login]}),(0,Z.jsx)(Ku,{login:m.login,onSave:x,onSkip:C})]}),t[27]=m,t[28]=x,t[29]=C,t[30]=f,t[31]=k):k=t[31];let A;t[32]!==k||t[33]!==O?(A=(0,Z.jsxs)(Do,{children:[O,k]}),t[32]=k,t[33]=O,t[34]=A):A=t[34];let j;t[35]!==A||t[36]!==D?(j=(0,Z.jsxs)(wo,{className:`sm:max-w-md`,children:[D,A]}),t[35]=A,t[36]=D,t[37]=j):j=t[37];let M;return t[38]!==r||t[39]!==n||t[40]!==j?(M=(0,Z.jsx)(jo,{open:n,onOpenChange:r,children:j}),t[38]=r,t[39]=n,t[40]=j,t[41]=M):M=t[41],M}function Ju(){}function Yu(){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(Xu),()=>{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 Xu(e){console.warn(`[use-update-channel] bridge.state.query() failed`,e)}function Zu(e){let t=(0,$.c)(2),{className:n}=e,{channel:r}=Yu();if(r!==`beta`)return null;let i;return t[0]===n?i=t[1]:(i=(0,Z.jsx)(Ge,{variant:`secondary`,"aria-label":`Beta channel`,"data-testid":`beta-badge`,className:n,children:`BETA`}),t[0]=n,t[1]=i),i}function Qu(e){switch(e){case`receiving`:return`Receiving objects`;case`resolving`:return`Resolving deltas`;case`checking`:return`Checking out files`;case`init`:return`Initializing project`;case`done`:return`Complete`;default:return`Cloning`}}function $u(e){let t=e.trim();if(/^[\w.-]+\/[\w.-]+$/.test(t))return t.split(`/`)[1];try{return new URL(t.replace(/^git@([^:]+):/,`https://$1/`)).pathname.replace(/\.git$/,``).split(`/`).pop()??`repo`}catch{return t.split(`/`).pop()?.replace(/\.git$/,``)??`repo`}}function ed(e){let t=(0,$.c)(99),{open:n,onOpenChange:r,onSignIn:i,onCloneComplete:a,transport:o,authQueryTransport:s,pickParentFolder:c,initialUrl:l}=e,u;t[0]===o?u=t[1]:(u=o??gl(),t[0]=o,t[1]=u);let d=u,f;t[2]===s?f=t[3]:(f=s??ul(),t[2]=s,t[3]=f);let p=f,m=c!==void 0,[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(!1),k=(0,Q.useRef)(null),A=(0,Q.useRef)(null),j;t[4]!==n||t[5]!==p?(j=()=>{if(!n)return;let e=!1;return p.status().then(t=>{e||E(t.authenticated)}).catch(()=>{e||E(!1)}),()=>{e=!0}},t[4]=n,t[5]=p,t[6]=j):j=t[6];let M;t[7]===n?M=t[8]:(M=[n],t[7]=n,t[8]=M),(0,Q.useEffect)(j,M);let N;t[9]!==T||t[10]!==n||t[11]!==p?(N=()=>{if(!T||!n)return;let e=!1;return S(!0),p.repos().then(t=>{e||(b(t.ok?t.repos:[]),S(!1))}).catch(()=>{e||(b([]),S(!1))}),()=>{e=!0}},t[9]=T,t[10]=n,t[11]=p,t[12]=N):N=t[12];let P;t[13]!==T||t[14]!==n?(P=[T,n],t[13]=T,t[14]=n,t[15]=P):P=t[15],(0,Q.useEffect)(N,P);let F,I;t[16]!==l||t[17]!==n||t[18]!==m?(F=()=>{if(!n||!l||(g(l),m))return;let e=$u(l);e&&v(`~/Documents/${e}`)},I=[n,l,m],t[16]=l,t[17]=n,t[18]=m,t[19]=F,t[20]=I):(F=t[19],I=t[20]),(0,Q.useEffect)(F,I);let L;t[21]===m?L=t[22]:(L=function(e){if(g(e),m)return;let t=$u(e);t&&v(`~/Documents/${t}`)},t[21]=m,t[22]=L);let R=L,z;t[23]===m?z=t[24]:(z=function(e){if(g(e.clone_url),m)return;let t=e.full_name.split(`/`)[1];v(`~/Documents/${t}`)},t[23]=m,t[24]=z);let B=z,V;t[25]!==_||t[26]!==a||t[27]!==r||t[28]!==c||t[29]!==d||t[30]!==h?(V=async function(){let e=h.trim();if(!e){X.error(`Enter a repository URL or owner/repo`);return}let t=_||``;if(c){O(!0);let n=await c();if(!n){O(!1);return}let r=$u(e);t=`${n.replace(/\/$/,``)}/${r}`}else O(!0);let n=X.loading(`Starting clone`,{duration:1/0});A.current=n;let i=d.start({url:e,dir:t});k.current=i.cancel;try{let e=i.events[Symbol.asyncIterator](),t=await e.next();for(;!t.done;){let i=t.value;if(i.type===`progress`)X.loading(`${Qu(i.phase)} — ${i.pct}%`,{id:n});else if(i.type===`complete`){X.success(`Clone complete — opening project`,{id:n}),r(!1),O(!1),k.current=null;let e=`port`in i?i.port:void 0;a?a({port:e,dir:i.dir}):e!==void 0&&(window.location.href=`http://localhost:${e}`);return}else if(i.type===`error`){X.error(`Clone failed: ${i.message}`,{id:n}),O(!1),k.current=null;return}t=await e.next()}X.error(`Clone stream ended unexpectedly — check if the clone completed`,{id:n}),O(!1),k.current=null}catch(e){console.error(`[CloneDialog] clone iteration failed:`,e),X.error(`Clone failed — connection error`,{id:n}),O(!1),k.current=null}},t[25]=_,t[26]=a,t[27]=r,t[28]=c,t[29]=d,t[30]=h,t[31]=V):V=t[31];let H=V,U;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(U=function(){k.current?.(),k.current=null,O(!1),X.dismiss(A.current??void 0)},t[32]=U):U=t[32];let W=U,G;t[33]!==D||t[34]!==r||t[35]!==m?(G=function(e){D||(r(e),e||(g(``),m||v(``),w(``)))},t[33]=D,t[34]=r,t[35]=m,t[36]=G):G=t[36];let K=G,q,ee,te,ne,re,ie,ae,oe,se,ce;if(t[37]!==D||t[38]!==K||t[39]!==B||t[40]!==R||t[41]!==T||t[42]!==x||t[43]!==n||t[44]!==C||t[45]!==y||t[46]!==h){let e=y?.filter(e=>e.full_name.toLowerCase().includes(C.toLowerCase()));te=jo,se=n,ce=K,ee=wo,ae=`sm:max-w-lg`,t[57]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,Z.jsx)(Ao,{children:(0,Z.jsx)(bo,{children:`Clone from GitHub`})}),t[57]=oe):oe=t[57],q=Do,ne=`flex flex-col gap-4`;let r;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(`label`,{htmlFor:`clone-url`,className:`text-sm font-medium`,children:`Repository URL or owner/repo`}),t[58]=r):r=t[58];let i;t[59]===R?i=t[60]:(i=e=>R(e.target.value),t[59]=R,t[60]=i),t[61]!==D||t[62]!==i||t[63]!==h?(re=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r,(0,Z.jsx)(Po,{id:`clone-url`,placeholder:`https://github.com/owner/repo or owner/repo`,value:h,onChange:i,disabled:D})]}),t[61]=D,t[62]=i,t[63]=h,t[64]=re):re=t[64],ie=T&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`label`,{htmlFor:`repo-filter`,className:`text-sm font-medium`,children:`Your repositories`}),(0,Z.jsx)(Po,{id:`repo-filter`,"aria-label":`Filter repositories`,placeholder:`Filter repositories`,value:C,onChange:e=>w(e.target.value),disabled:D||x&&y===null}),(0,Z.jsx)(`div`,{className:`border rounded-md max-h-40 overflow-y-auto subtle-scrollbar`,"aria-busy":x&&y===null,children:x&&y===null?(0,Z.jsxs)(`output`,{className:`flex flex-col gap-1.5 px-3 py-2`,"aria-label":`Loading repositories`,children:[(0,Z.jsx)(Ma,{className:`h-4 w-2/3`}),(0,Z.jsx)(Ma,{className:`h-4 w-1/2`}),(0,Z.jsx)(Ma,{className:`h-4 w-3/4`}),(0,Z.jsx)(Ma,{className:`h-4 w-2/5`}),(0,Z.jsx)(Ma,{className:`h-4 w-3/5`})]}):e?.length===0?(0,Z.jsx)(`p`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:y?.length===0?`No repositories found.`:`No matches.`}):e?.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`w-full text-left px-3 py-1.5 text-sm hover:bg-muted flex items-center gap-2 truncate disabled:opacity-50`,onClick:()=>B(e),disabled:D,children:[e.private&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:`🔒`}),e.full_name]},e.full_name))})]}),t[37]=D,t[38]=K,t[39]=B,t[40]=R,t[41]=T,t[42]=x,t[43]=n,t[44]=C,t[45]=y,t[46]=h,t[47]=q,t[48]=ee,t[49]=te,t[50]=ne,t[51]=re,t[52]=ie,t[53]=ae,t[54]=oe,t[55]=se,t[56]=ce}else q=t[47],ee=t[48],te=t[49],ne=t[50],re=t[51],ie=t[52],ae=t[53],oe=t[54],se=t[55],ce=t[56];let le;t[65]!==D||t[66]!==T||t[67]!==i?(le=!T&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:`Browse your repos:`}),(0,Z.jsx)(Y,{variant:`link`,className:`h-auto p-0`,onClick:()=>i?.(),disabled:D,children:`Sign in to GitHub`})]}),t[65]=D,t[66]=T,t[67]=i,t[68]=le):le=t[68];let J;t[69]!==D||t[70]!==_||t[71]!==m?(J=!m&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`label`,{htmlFor:`clone-path`,className:`text-sm font-medium`,children:`Local path`}),(0,Z.jsx)(Po,{id:`clone-path`,placeholder:`~/Documents/repo-name`,value:_,onChange:e=>v(e.target.value),disabled:D})]}),t[69]=D,t[70]=_,t[71]=m,t[72]=J):J=t[72];let ue;t[73]!==ne||t[74]!==re||t[75]!==ie||t[76]!==le||t[77]!==J?(ue=(0,Z.jsxs)(`div`,{className:ne,children:[re,ie,le,J]}),t[73]=ne,t[74]=re,t[75]=ie,t[76]=le,t[77]=J,t[78]=ue):ue=t[78];let de;t[79]!==q||t[80]!==ue?(de=(0,Z.jsx)(q,{children:ue}),t[79]=q,t[80]=ue,t[81]=de):de=t[81];let fe;t[82]!==D||t[83]!==H||t[84]!==K||t[85]!==h||t[86]!==m?(fe=(0,Z.jsx)(Oo,{children:D?(0,Z.jsx)(Y,{variant:`outline`,className:`font-mono uppercase`,onClick:W,children:`Cancel`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{variant:`outline`,className:`font-mono uppercase`,onClick:()=>K(!1),children:`Cancel`}),(0,Z.jsx)(Y,{onClick:()=>void H(),disabled:!h.trim(),"aria-describedby":m?`clone-picker-hint`:void 0,children:`Clone`}),m&&(0,Z.jsx)(`span`,{id:`clone-picker-hint`,className:`sr-only`,children:`Opens a folder picker to choose where to clone the repository.`})]})}),t[82]=D,t[83]=H,t[84]=K,t[85]=h,t[86]=m,t[87]=fe):fe=t[87];let pe;t[88]!==ee||t[89]!==ae||t[90]!==oe||t[91]!==de||t[92]!==fe?(pe=(0,Z.jsxs)(ee,{className:ae,children:[oe,de,fe]}),t[88]=ee,t[89]=ae,t[90]=oe,t[91]=de,t[92]=fe,t[93]=pe):pe=t[93];let me;return t[94]!==te||t[95]!==se||t[96]!==ce||t[97]!==pe?(me=(0,Z.jsx)(te,{open:se,onOpenChange:ce,children:pe}),t[94]=te,t[95]=se,t[96]=ce,t[97]=pe,t[98]=me):me=t[98],me}var td=(0,Q.lazy)(()=>n(()=>import(`./ConsentDialogBody-CSNo2n5l.js`),__vite__mapDeps([5,1,6,7,8,9,10,11,12]),import.meta.url));function nd(){let e=(0,$.c)(1);if(!(0,Q.useSyncExternalStore)(Jo.subscribe,id,rd))return null;let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(td,{})}),e[0]=t):t=e[0],t}function rd(){return!1}function id(){return Jo.getSnapshot()!==null}var ad=180,od=5e3;function sd(e,t){if(e===``||t===``)return``;let n=e.includes(`\\`)&&!e.includes(`/`)?`\\`:`/`;return`${e.replace(/[/\\]+$/,``)}${n}${t}`}function cd(e){if(e===``)return``;let t=e.split(/[/\\]/).filter(Boolean);return t.length>0?t[t.length-1]??e:e}function ld(e){if(e===``)return``;let t=e.replace(/[/\\]+$/,``);if(t===``)return``;let n=t.match(/[/\\][^/\\]+$/);if(n===null)return``;let r=t.length-n[0].length;return r===0?t[0]??``:t.slice(0,r)}function ud(e){let{parent:t,sanitizedName:n,enclosingProject:r,enclosingGit:i,targetState:a}=e;return t===``||n===``?{kind:`idle`}:r===null?i===null?a===`exists-nonempty`?{kind:`block-nonempty`}:{kind:`free`}:{kind:`confirm-git`,gitRoot:i.gitRoot}:{kind:`block-nested`,rootPath:r.rootPath}}function dd(e){let t=e instanceof Error?e.message:String(e);for(let e of hr)if(t.startsWith(`${e}:`)||t.includes(`${e}: `))return e===`nested-project`||e===`target-not-empty`?{reason:e}:{reason:e,message:t};return{reason:`unknown`,message:t}}function fd(e){switch(e.reason){case`nested-project`:return`A project already exists at this location. Pick a different parent folder.`;case`target-not-empty`:return`A non-empty folder already exists at this path. Pick a different folder.`;case`invalid-args`:return`Invalid input — pick a different folder.`;case`mkdir-failed`:return`Could not create the project folder. Pick a different folder.`;case`git-init-failed`:return`Project folder created, but git init failed. Try again.`;case`init-failed`:return`Could not write project files. Try a different location.`;case`discovery-failed`:return`Could not finalize project setup. Try again.`;case`unknown`:return`Could not create project. Try again or pick a different location.`}}function pd(e){let t=(0,$.c)(152),{open:n,onOpenChange:r,bridge:i}=e,a=(0,Q.useId)(),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(bd),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f={kind:`idle`},t[0]=f):f=t[0];let[p,m]=(0,Q.useState)(f),[h,g]=(0,Q.useState)(`idle`),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(null),x;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(x={kind:`idle`},t[1]=x):x=t[1];let[S,C]=(0,Q.useState)(x),[w,T]=(0,Q.useState)(0),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(``),A;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(A=new Set,t[2]=A):A=t[2];let j=(0,Q.useRef)(A),M=(0,Q.useRef)(null),N=(0,Q.useRef)(null),P=(0,Q.useRef)(null),F=(0,Q.useRef)(0),I,L;t[3]!==i||t[4]!==n?(I=()=>{if(!n)return;j.current.clear(),b(null),m({kind:`idle`}),g(`idle`),v(!1),s(``),d(new Set(er)),C({kind:`idle`}),D(!1),k(``),F.current+=1;let e=!1;l(``),i.fs.defaultProjectsRoot().then(t=>{e||l(t)}).catch(yd);let t=requestAnimationFrame(()=>{P.current?.focus()});return()=>{e=!0,cancelAnimationFrame(t)}},L=[n,i],t[3]=i,t[4]=n,t[5]=I,t[6]=L):(I=t[5],L=t[6]),(0,Q.useEffect)(I,L);let R;t[7]!==i||t[8]!==E||t[9]!==n||t[10]!==o||t[11]!==O?(R=()=>{if(!n)return;if(N.current!==null&&clearTimeout(N.current),M.current!==null&&M.current.abort(),o===``){m({kind:`idle`}),g(`idle`);return}let e=O.trim(),t=E&&e!==``,r=t?o:ld(o),a=yr(t?e:cd(o));if(r===``||a===``){m({kind:`idle`}),g(`idle`);return}let s=sd(r,a),c=new AbortController;return M.current=c,N.current=setTimeout(()=>{g(`in-flight`),Promise.all([i.fs.findEnclosingProjectRoot(r),i.fs.findEnclosingGitRoot(r),i.fs.folderState(s)]).then(e=>{let[t,n,i]=e;if(c.signal.aborted)return;g(`idle`);let o=ud({parent:r,sanitizedName:a,enclosingProject:t,enclosingGit:n,targetState:i});m(o),o.kind===`block-nonempty`&&D(!0)}).catch(e=>{c.signal.aborted||(console.warn(`[CreateProjectDialog] cascade probe failed:`,e),g(`idle`),m({kind:`free`}))})},ad),()=>{N.current!==null&&clearTimeout(N.current),c.abort()}},t[7]=i,t[8]=E,t[9]=n,t[10]=o,t[11]=O,t[12]=R):R=t[12];let z;t[13]!==i||t[14]!==E||t[15]!==n||t[16]!==o||t[17]!==w||t[18]!==O?(z=[n,o,i,w,E,O],t[13]=i,t[14]=E,t[15]=n,t[16]=o,t[17]=w,t[18]=O,t[19]=z):z=t[19],(0,Q.useEffect)(R,z);let B,V;t[20]===n?(B=t[21],V=t[22]):(B=()=>{if(!n)return;let e=()=>T(vd);return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},V=[n],t[20]=n,t[21]=B,t[22]=V),(0,Q.useEffect)(B,V);let H=(0,Q.useRef)(`idle`),U,W;t[23]===h?(U=t[24],W=t[25]):(U=()=>{H.current=h},W=[h],t[23]=h,t[24]=U,t[25]=W),(0,Q.useEffect)(U,W);let G,K;t[26]!==p.kind||t[27]!==n?(G=()=>{if(!n||p.kind!==`confirm-git`)return;let e=setInterval(()=>{H.current!==`in-flight`&&T(_d)},od);return()=>clearInterval(e)},K=[n,p.kind],t[26]=p.kind,t[27]=n,t[28]=G,t[29]=K):(G=t[28],K=t[29]),(0,Q.useEffect)(G,K);let q;t[30]!==p.gitRoot||t[31]!==p.kind||t[32]!==S.gitRoot||t[33]!==S.kind?(q=()=>{if(p.kind!==`confirm-git`){S.kind!==`idle`&&(F.current+=1,C({kind:`idle`}));return}S.kind===`confirming`&&S.gitRoot!==p.gitRoot&&C({kind:`idle`}),S.kind===`pending`&&S.gitRoot!==p.gitRoot&&(F.current+=1,C({kind:`idle`}))},t[30]=p.gitRoot,t[31]=p.kind,t[32]=S.gitRoot,t[33]=S.kind,t[34]=q):q=t[34];let ee;t[35]!==p||t[36]!==S?(ee=[p,S],t[35]=p,t[36]=S,t[37]=ee):ee=t[37],(0,Q.useEffect)(q,ee);let te;t[38]!==i||t[39]!==p.kind||t[40]!==n?(te=()=>{if(!n)return;let e=null;p.kind===`block-nested`?e=`nested`:p.kind===`block-nonempty`?e=`nonempty`:p.kind===`confirm-git`&&(e=`git-confirm`),e!==null&&(j.current.has(e)||(j.current.add(e),i.project.recordCreateNewBannerShown(e).catch(gd)))},t[38]=i,t[39]=p.kind,t[40]=n,t[41]=te):te=t[41];let ne;t[42]!==i||t[43]!==p||t[44]!==n?(ne=[n,p,i],t[42]=i,t[43]=p,t[44]=n,t[45]=ne):ne=t[45],(0,Q.useEffect)(te,ne);let re,ie,ae,oe,se,ce,le;t[46]!==E||t[47]!==o||t[48]!==O?(ce=O.trim(),se=E&&ce!==``,re=o===``?``:se?ce:cd(o),oe=o===``?``:yr(re),ie=o!==``&&oe!==re&&oe!==``,ae=o!==``&&re!==``&&oe===``,le=se?sd(o,oe):o,t[46]=E,t[47]=o,t[48]=O,t[49]=re,t[50]=ie,t[51]=ae,t[52]=oe,t[53]=se,t[54]=ce,t[55]=le):(re=t[49],ie=t[50],ae=t[51],oe=t[52],se=t[53],ce=t[54],le=t[55]);let J=le,ue=!_&&o!==``&&oe!==``&&h===`idle`&&(p.kind===`free`||p.kind===`confirm-git`),de;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(de=function(e){d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[56]=de):de=t[56];let fe=de,pe;t[57]!==i||t[58]!==c?(pe=async function(){try{let e=await i.dialog.openFolder(c===``?void 0:{defaultPath:c});if(e===null)return;s(e),T(hd),b(null),D(!1),k(``)}catch(e){console.warn(`[CreateProjectDialog] dialog.openFolder failed:`,e)}},t[57]=i,t[58]=c,t[59]=pe):pe=t[59];let me=pe,he;t[60]!==i||t[61]!==ue||t[62]!==u||t[63]!==r||t[64]!==o||t[65]!==oe||t[66]!==se?(he=async function(e){if(e.preventDefault(),ue){v(!0),b(null);try{await i.project.createNew({parent:se?o:ld(o),name:oe,editors:Array.from(u)}),r(!1)}catch(e){b(dd(e)),v(!1)}}},t[60]=i,t[61]=ue,t[62]=u,t[63]=r,t[64]=o,t[65]=oe,t[66]=se,t[67]=he):he=t[67];let ge=he,_e;t[68]!==_||t[69]!==r?(_e=function(e){_||r(e)},t[68]=_,t[69]=r,t[70]=_e):_e=t[70];let ve=_e,ye;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ye=async function(e){C({kind:`confirming`,gitRoot:e})},t[71]=ye):ye=t[71];let be=ye,xe;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(xe=async function(){C({kind:`idle`})},t[72]=xe):xe=t[72];let Se=xe,Ce;t[73]===i?Ce=t[74]:(Ce=async function(e){let t=F.current+1;F.current=t,C({kind:`pending`,gitRoot:e});try{if(await i.fs.removeGitFolder(e),F.current!==t)return;T(md),C({kind:`idle`})}catch(e){let n=e;if(F.current!==t)return;let r=n instanceof Error?n.message:String(n);console.error(`[CreateProjectDialog] bridge.fs.removeGitFolder failed:`,n),C({kind:`error`,message:r})}},t[73]=i,t[74]=Ce);let we=Ce,Te;t[75]!==i||t[76]!==r?(Te=async function(e){r(!1);try{await i.project.open({path:e,target:`new-window`,entryPoint:`create-new-nested-redirect`})}catch(e){console.warn(`[CreateProjectDialog] project.open failed:`,e)}},t[75]=i,t[76]=r,t[77]=Te):Te=t[77];let Ee=Te,De;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,Z.jsxs)(Ao,{children:[(0,Z.jsx)(bo,{children:`Create new project`}),(0,Z.jsx)(vo,{children:`Create a new Open Knowledge project in the folder of your choice.`})]}),t[78]=De):De=t[78];let Oe;t[79]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,Z.jsx)(Go,{htmlFor:`create-location`,children:`Location`}),t[79]=Oe):Oe=t[79];let ke;t[80]===me?ke=t[81]:(ke=()=>void me(),t[80]=me,t[81]=ke);let Ae;t[82]!==_||t[83]!==ke?(Ae=(0,Z.jsx)(`div`,{className:`flex items-stretch gap-2`,children:(0,Z.jsx)(Y,{id:`create-location`,ref:P,type:`button`,variant:`outline`,disabled:_,onClick:ke,"aria-describedby":`create-target-caption`,"data-testid":`create-browse`,children:`Browse`})}),t[82]=_,t[83]=ke,t[84]=Ae):Ae=t[84];let je=J===``?`Click Browse to pick or create a project folder.`:J,Me;t[85]===je?Me=t[86]:(Me=(0,Z.jsx)(`p`,{id:`create-target-caption`,className:`text-1sm text-muted-foreground`,"aria-live":`polite`,"data-testid":`create-target-caption`,children:je}),t[85]=je,t[86]=Me);let Ne;t[87]!==Ae||t[88]!==Me?(Ne=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Oe,Ae,Me]}),t[87]=Ae,t[88]=Me,t[89]=Ne):Ne=t[89];let Pe;t[90]!==_||t[91]!==p.kind||t[92]!==E||t[93]!==ie||t[94]!==ae||t[95]!==oe||t[96]!==se||t[97]!==O||t[98]!==ce?(Pe=E?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,"data-testid":`create-subfolder-rescue`,children:[(0,Z.jsx)(Go,{htmlFor:`create-subfolder-name`,children:`Subfolder name`}),(0,Z.jsx)(Po,{id:`create-subfolder-name`,value:O,placeholder:`my-project`,onChange:e=>k(e.target.value),disabled:_,autoFocus:!0,"aria-invalid":se&&(ae||p.kind===`block-nonempty`),"data-testid":`create-subfolder-input`}),ce===``?(0,Z.jsx)(`p`,{role:`status`,"aria-live":`polite`,className:`text-1sm text-muted-foreground`,"data-testid":`create-subfolder-empty-error`,children:`This folder already has files. Add a name to create a new subfolder inside it.`}):ae?(0,Z.jsx)(`p`,{role:`alert`,className:`text-1sm text-destructive`,"data-testid":`create-subfolder-erased-error`,children:`This name has no characters that are safe for a folder identifier. Try a name with at least one letter or number.`}):p.kind===`block-nonempty`?(0,Z.jsxs)(`p`,{role:`alert`,className:`text-1sm text-destructive`,"data-testid":`create-subfolder-taken-error`,children:[`A folder named `,(0,Z.jsx)(`code`,{className:`font-mono break-all`,children:oe}),` already has files at this location. Pick a different name.`]}):ie?(0,Z.jsxs)(`p`,{className:`text-1sm text-muted-foreground`,children:[`Will be saved as `,(0,Z.jsx)(`code`,{className:`font-mono break-all`,children:oe}),`.`]}):null]}):null,t[90]=_,t[91]=p.kind,t[92]=E,t[93]=ie,t[94]=ae,t[95]=oe,t[96]=se,t[97]=O,t[98]=ce,t[99]=Pe):Pe=t[99];let Fe;t[100]!==E||t[101]!==re||t[102]!==ie||t[103]!==oe?(Fe=!E&&ie?(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-900 dark:border-amber-700 dark:bg-amber-950 dark:text-amber-200`,"data-testid":`create-banner-sanitize-diverged`,children:[`The folder name `,(0,Z.jsx)(`code`,{className:`font-mono break-all`,children:re}),` contains characters that aren't safe for the project's on-disk identifier. The project will be created as `,(0,Z.jsx)(`code`,{className:`font-mono break-all`,children:oe}),`. Click Browse again to pick a folder with a safer name.`]}):null,t[100]=E,t[101]=re,t[102]=ie,t[103]=oe,t[104]=Fe):Fe=t[104];let Ie;t[105]!==E||t[106]!==re||t[107]!==ae?(Ie=!E&&ae?(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-900 dark:border-amber-700 dark:bg-amber-950 dark:text-amber-200`,"data-testid":`create-banner-sanitize-erased`,children:[`The folder name `,(0,Z.jsx)(`code`,{className:`font-mono break-all`,children:re}),` can't be used as a project identifier — it has no characters left after sanitization. Click Browse to pick a folder whose name contains at least one alphanumeric character.`]}):null,t[105]=E,t[106]=re,t[107]=ae,t[108]=Ie):Ie=t[108];let Le;t[109]!==p||t[110]!==we||t[111]!==Ee||t[112]!==S?(Le=(0,Z.jsx)(xd,{cascade:p,onOpenNested:Ee,removeGitState:S,onRequestRemoveGit:be,onCancelRemoveGit:Se,onConfirmRemoveGit:we}),t[109]=p,t[110]=we,t[111]=Ee,t[112]=S,t[113]=Le):Le=t[113];let Re,ze;t[114]===Symbol.for(`react.memo_cache_sentinel`)?(Re=(0,Z.jsx)(`legend`,{className:`text-sm font-medium`,children:`Connect to AI tools`}),ze=(0,Z.jsx)(`p`,{className:`text-1sm text-muted-foreground`,children:`Each selected tool gets an Open Knowledge MCP entry.`}),t[114]=Re,t[115]=ze):(Re=t[114],ze=t[115]);let Be;t[116]!==_||t[117]!==u?(Be=er.map(e=>{let t=`create-editor-${e}`;return(0,Z.jsxs)(Go,{htmlFor:t,className:`text-sm font-normal`,children:[(0,Z.jsx)(Ro,{id:t,checked:u.has(e),onCheckedChange:()=>fe(e),disabled:_,"data-testid":`create-editor-${e}`}),(0,Z.jsx)(`span`,{children:lr[e]})]},e)}),t[116]=_,t[117]=u,t[118]=Be):Be=t[118];let Ve;t[119]===Be?Ve=t[120]:(Ve=(0,Z.jsxs)(`fieldset`,{className:`flex flex-col space-y-2 pb-2`,children:[Re,ze,Be]}),t[119]=Be,t[120]=Ve);let He;t[121]===y?He=t[122]:(He=y===null?null:(0,Z.jsx)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,"data-testid":`create-submit-error`,children:fd(y)}),t[121]=y,t[122]=He);let Ue;t[123]!==a||t[124]!==ge||t[125]!==Ne||t[126]!==Pe||t[127]!==Fe||t[128]!==Ie||t[129]!==Le||t[130]!==Ve||t[131]!==He?(Ue=(0,Z.jsx)(Do,{className:`space-y-4`,children:(0,Z.jsxs)(`form`,{id:a,onSubmit:ge,"data-testid":`create-project-form`,className:`space-y-4`,children:[Ne,Pe,Fe,Ie,Le,Ve,He]})}),t[123]=a,t[124]=ge,t[125]=Ne,t[126]=Pe,t[127]=Fe,t[128]=Ie,t[129]=Le,t[130]=Ve,t[131]=He,t[132]=Ue):Ue=t[132];let We;t[133]===r?We=t[134]:(We=()=>r(!1),t[133]=r,t[134]=We);let Ge;t[135]!==_||t[136]!==We?(Ge=(0,Z.jsx)(Y,{type:`button`,variant:`outline`,className:`font-mono uppercase`,onClick:We,disabled:_,"data-testid":`create-cancel`,children:`Cancel`}),t[135]=_,t[136]=We,t[137]=Ge):Ge=t[137];let Ke=!ue,qe=_?`Creating`:`Create`,Je;t[138]!==a||t[139]!==Ke||t[140]!==qe?(Je=(0,Z.jsx)(Y,{type:`submit`,form:a,disabled:Ke,"data-testid":`create-submit`,children:qe}),t[138]=a,t[139]=Ke,t[140]=qe,t[141]=Je):Je=t[141];let Ye;t[142]!==Ge||t[143]!==Je?(Ye=(0,Z.jsxs)(Oo,{children:[Ge,Je]}),t[142]=Ge,t[143]=Je,t[144]=Ye):Ye=t[144];let Xe;t[145]!==Ue||t[146]!==Ye?(Xe=(0,Z.jsxs)(wo,{className:`sm:max-w-lg`,"data-testid":`create-project-dialog`,children:[De,Ue,Ye]}),t[145]=Ue,t[146]=Ye,t[147]=Xe):Xe=t[147];let Ze;return t[148]!==ve||t[149]!==n||t[150]!==Xe?(Ze=(0,Z.jsx)(jo,{open:n,onOpenChange:ve,children:Xe}),t[148]=ve,t[149]=n,t[150]=Xe,t[151]=Ze):Ze=t[151],Ze}function md(e){return e+1}function hd(e){return e+1}function gd(){}function _d(e){return e+1}function vd(e){return e+1}function yd(e){console.warn(`[CreateProjectDialog] defaultProjectsRoot probe failed:`,e)}function bd(){return new Set(er)}function xd(e){let t=(0,$.c)(32),{cascade:n,onOpenNested:r,removeGitState:i,onRequestRemoveGit:a,onCancelRemoveGit:o,onConfirmRemoveGit:s}=e;if(n.kind===`idle`||n.kind===`free`||n.kind===`block-nonempty`)return null;if(n.kind===`block-nested`){let e;t[0]===n.rootPath?e=t[1]:(e=cd(n.rootPath),t[0]=n.rootPath,t[1]=e);let i=e,a;t[2]===n.rootPath?a=t[3]:(a=(0,Z.jsxs)(`p`,{className:`mb-2`,children:[`Can't nest projects. An Open Knowledge project already exists at`,` `,(0,Z.jsx)(`code`,{className:`font-mono break-all`,children:n.rootPath}),`. Choose a location outside it, or open that project instead.`]}),t[2]=n.rootPath,t[3]=a);let o;t[4]!==n.rootPath||t[5]!==r?(o=()=>r(n.rootPath),t[4]=n.rootPath,t[5]=r,t[6]=o):o=t[6];let s;t[7]!==i||t[8]!==o?(s=(0,Z.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:o,"data-testid":`create-banner-nested-open`,children:[`Open `,i]}),t[7]=i,t[8]=o,t[9]=s):s=t[9];let c;return t[10]!==a||t[11]!==s?(c=(0,Z.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,"data-testid":`create-banner-nested`,children:[a,s]}),t[10]=a,t[11]=s,t[12]=c):c=t[12],c}if(n.kind===`confirm-git`){let{gitRoot:e}=n,r;if(t[13]!==e){let n;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(n=/\/+$/,t[15]=n):n=t[15],r=e.replace(n,``),t[13]=e,t[14]=r}else r=t[14];let c=`${r}/.git`,l;t[16]===e?l=t[17]:(l=(0,Z.jsx)(`code`,{children:e}),t[16]=e,t[17]=l);let u;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(`code`,{children:`.git`}),t[18]=u):u=t[18];let d;t[19]===l?d=t[20]:(d=(0,Z.jsxs)(`p`,{children:[`Open Knowledge will be initialized at `,l,` — the parent of your new folder, because it contains a `,u,` folder (one project per git repo).`]}),t[19]=l,t[20]=d);let f;t[21]!==e||t[22]!==o||t[23]!==s||t[24]!==a||t[25]!==i.kind||t[26]!==i.message||t[27]!==c?(f=i.kind===`idle`||i.kind===`error`?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1`,children:[(0,Z.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(e),"data-testid":`create-banner-git-remove`,children:[`Remove the parent `,(0,Z.jsx)(`code`,{children:`.git`}),` folder`]}),i.kind===`error`?(0,Z.jsxs)(`p`,{role:`alert`,className:`text-xs text-destructive`,"data-testid":`create-banner-git-remove-error`,children:[`Couldn't remove `,(0,Z.jsx)(`code`,{children:c}),`: `,i.message]}):null]}):(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2 rounded border border-blue-400/60 bg-white/40 p-2 dark:border-blue-600/60 dark:bg-black/20`,"data-testid":`create-banner-git-remove-confirm`,children:[(0,Z.jsxs)(`p`,{className:`text-xs`,children:[`This will permanently delete`,` `,(0,Z.jsx)(`code`,{className:`font-mono break-all`,children:c}),`. All git history in that folder is lost; the working files stay in place. Only confirm if the parent git repository is unintended. If the parent is intentionally a git repository (you cloned it on purpose), cancel and pick a location outside it instead.`]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(Y,{type:`button`,variant:`destructive`,size:`sm`,disabled:i.kind===`pending`,onClick:()=>s(e),"data-testid":`create-banner-git-remove-confirm-button`,children:i.kind===`pending`?`Removing…`:`Delete ${c}`}),(0,Z.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:i.kind===`pending`,onClick:o,"data-testid":`create-banner-git-remove-cancel`,children:`Cancel`})]})]}),t[21]=e,t[22]=o,t[23]=s,t[24]=a,t[25]=i.kind,t[26]=i.message,t[27]=c,t[28]=f):f=t[28];let p;return t[29]!==d||t[30]!==f?(p=(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`rounded-md border border-blue-300 bg-blue-50 px-3 py-2 text-sm text-blue-900 dark:border-blue-700 dark:bg-blue-950 dark:text-blue-200`,"data-testid":`create-banner-git-confirm`,children:[d,f]}),t[29]=d,t[30]=f,t[31]=p):p=t[31],p}return null}function Sd(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 Cd(e){let t=(0,$.c)(5),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`Open Knowledge icon`}),t[0]=n):n=t[0];let r;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsxs)(`g`,{filter:`url(#filter0_d_ok)`,children:[(0,Z.jsx)(`path`,{d:`M66.8902 16.1017C58.2694 3.86669 46.1739 -0.690239 29.9182 2.17749C21.3995 3.67813 13.4602 9.555 8.67934 17.9009C3.93974 26.1701 2.98514 35.6533 6.05714 43.9166C9.31574 52.6868 16.7168 58.4752 24.2299 63.4231C25.7973 64.4562 26.1351 65.7172 26.3551 68.9896C26.5221 71.4625 26.799 75.6011 30.6842 77.7204C31.8176 78.3372 33.0648 78.6515 34.3946 78.6515C37.0796 78.6515 39.4033 77.3649 40.5189 76.7482C47.1049 73.1046 68.8878 59.7147 72.6453 40.4027C74.3444 31.6679 70.9797 21.9019 66.8922 16.1017H66.8902Z`,fill:`white`}),(0,Z.jsx)(`path`,{d:`M37.4214 71.154C28.7888 75.929 36.787 64.0397 27.7458 58.0843C21.6372 54.0616 14.788 49.0568 12.0499 41.6911C6.74463 27.4192 17.5438 10.8473 31.028 8.47262C45.1977 5.97613 54.6946 9.8947 61.6635 19.7844C65.2089 24.8167 67.6013 32.8365 66.3658 39.1828C63.6906 52.9341 49.073 64.7075 37.4214 71.154Z`,fill:`#69A3FF`}),(0,Z.jsx)(`path`,{d:`M52.7244 29.2638C53.4665 28.5217 54.6697 28.5217 55.4119 29.2638V29.2638C56.154 30.0059 56.154 31.2091 55.4119 31.9513L49.2589 38.1042L46.5715 35.4167L52.7244 29.2638Z`,fill:`#D5E5FF`}),(0,Z.jsx)(`path`,{d:`M55.4119 38.8821C56.154 39.6242 56.154 40.8274 55.4119 41.5696V41.5696C54.6698 42.3117 53.4665 42.3117 52.7244 41.5696L46.5715 35.4166L49.259 32.7292L55.4119 38.8821Z`,fill:`#D5E5FF`})]}),t[1]=r):r=t[1];let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`defs`,{children:(0,Z.jsxs)(`filter`,{id:`filter0_d_ok`,x:`-9.53674e-07`,y:`-0.0799994`,width:`77.3817`,height:`85.8743`,filterUnits:`userSpaceOnUse`,colorInterpolationFilters:`sRGB`,children:[(0,Z.jsx)(`feFlood`,{floodOpacity:`0`,result:`BackgroundImageFix`}),(0,Z.jsx)(`feColorMatrix`,{in:`SourceAlpha`,type:`matrix`,values:`0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0`,result:`hardAlpha`}),(0,Z.jsx)(`feOffset`,{dy:`2.85714`}),(0,Z.jsx)(`feGaussianBlur`,{stdDeviation:`2.14286`}),(0,Z.jsx)(`feComposite`,{in2:`hardAlpha`,operator:`out`}),(0,Z.jsx)(`feColorMatrix`,{type:`matrix`,values:`0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0`}),(0,Z.jsx)(`feBlend`,{mode:`normal`,in2:`BackgroundImageFix`,result:`effect1_dropShadow_ok`}),(0,Z.jsx)(`feBlend`,{mode:`normal`,in:`SourceGraphic`,in2:`effect1_dropShadow_ok`,result:`shape`})]})}),t[2]=i):i=t[2];let a;return t[3]===e?a=t[4]:(a=(0,Z.jsxs)(`svg`,{role:`img`,"aria-label":`Open Knowledge icon`,fill:`none`,height:24,width:24,viewBox:`0 0 78 80`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n,r,i]}),t[3]=e,t[4]=a),a}var wd=(0,Q.lazy)(()=>n(()=>import(`./McpConsentDialogBody-Cp08S9eY.js`),__vite__mapDeps([13,1,6,7,8,9,14,15]),import.meta.url));function Td(){let e=(0,$.c)(1);if(!(0,Q.useSyncExternalStore)(Yo.subscribe,Dd,Ed))return null;let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(wd,{})}),e[0]=t):t=e[0],t}function Ed(){return!1}function Dd(){return Yo.getSnapshot()!==null}function Od(e){return`https://github.com/${e.owner}/${e.repo}.git`}function kd(e){let t=e.toLowerCase().trim();return t.endsWith(`/`)&&(t=t.slice(0,-1)),t.endsWith(`.git`)&&(t=t.slice(0,-4)),t}function Ad(e,t){let n=kd(Od(t));for(let t of e)if(t.missing!==!0&&t.gitRemoteUrl&&kd(t.gitRemoteUrl)===n)return t;return null}function jd(e){return`https://github.com/${e.owner}/${e.repo}.git`}function Md(e,t){switch(e.kind){case`ok`:return null;case`not-git`:return`This folder doesn't contain a git repository. Pick a different folder?`;case`wrong-repo`:return`This folder is a clone of ${e.actualOwner}/${e.actualRepo}, not ${t.owner}/${t.repo}. Pick a different folder?`;case`no-origin`:case`non-github`:case`symlink-escape`:return`This folder isn't a clone of ${t.owner}/${t.repo}. Pick a different folder?`}}function Nd(e){return e.kind===`unsupported-version`?{kind:`unsupported-version`,message:`Update Open Knowledge to open this share.`}:e.kind===`invalid`?{kind:`invalid`,message:`Invalid share URL.`}:null}function Pd(e){return e.kind===`ok`?{owner:e.owner,repo:e.repo,branch:e.branch,path:e.path,blobUrl:e.blobUrl}:null}function Fd(e){let t=[`[receive]`];return e.q1_hit!==void 0&&t.push(`q1_hit=${e.q1_hit}`),e.q2_path!==void 0&&t.push(`q2_path=${e.q2_path}`),e.folder_validate!==void 0&&t.push(`folder_validate=${e.folder_validate}`),t.join(` `)}function Id(){let e=null,t=new Set,n=!1,r=null;function i(){for(let e of t)e()}function a(){e!==null&&(e=null,i())}return{install({bridge:t}){if(t)return n?r??void 0:(n=!0,r=t.onShareReceived(t=>{e=t,i()}),()=>{r?.(),r=null,n=!1,a()})},getSnapshot(){return e},subscribe(e){return t.add(e),()=>{t.delete(e)}},dismiss(){a()}}}var Ld=Id();function Rd(e){return Ld.install(e)}function zd(e){let t=(0,$.c)(96),{bridge:n,cloneController:r,store:i}=e,a=i===void 0?Ld:i,o=(0,Q.useSyncExternalStore)(a.subscribe,a.getSnapshot,Bd),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),_=(0,Q.useRef)(!1),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>{c(!1),u(!1),f(null),m(!1),g(!1),_.current=!1},t[0]=v):v=t[0];let y;t[1]===o?y=t[2]:(y=[o],t[1]=o,t[2]=y),(0,Q.useEffect)(v,y);let b;t[3]!==d||t[4]!==r||t[5]!==o||t[6]!==s?(b=()=>{r&&(!o||o.kind!==`ok`||s&&d===null&&(_.current||(_.current=!0,m(!0),r.getAuthStatus().then(e=>{f(e)}).catch(()=>{f({authenticated:!1,host:`github.com`})}).finally(()=>{m(!1)}))))},t[3]=d,t[4]=r,t[5]=o,t[6]=s,t[7]=b):b=t[7];let x;t[8]!==d||t[9]!==o||t[10]!==s?(x=[o,s,d],t[8]=d,t[9]=o,t[10]=s,t[11]=x):x=t[11],(0,Q.useEffect)(b,x);let S,C;t[12]!==o||t[13]!==a?(S=()=>{if(!o)return;let e=Nd(o);e&&(X.error(e.message),a.dismiss())},C=[o,a],t[12]=o,t[13]=a,t[14]=S,t[15]=C):(S=t[14],C=t[15]),(0,Q.useEffect)(S,C);let w,T;t[16]!==n||t[17]!==o||t[18]!==s||t[19]!==a?(w=()=>{if(!o||o.kind!==`ok`||s)return;let e=!1;return Vd(o,n).then(t=>{if(!e){if(t.kind===`hit`){console.log(Fd({q1_hit:!0})),a.dismiss();return}console.log(Fd({q1_hit:!1})),c(!0)}}),()=>{e=!0}},T=[o,s,n,a],t[16]=n,t[17]=o,t[18]=s,t[19]=a,t[20]=w,t[21]=T):(w=t[20],T=t[21]),(0,Q.useEffect)(w,T);let E;t[22]===o?E=t[23]:(E=o?Pd(o):null,t[22]=o,t[23]=E);let D=E;if(!D)return null;let O;t[24]!==D.owner||t[25]!==D.repo?(O={owner:D.owner,repo:D.repo},t[24]=D.owner,t[25]=D.repo,t[26]=O):O=t[26];let k=O;if(!s)return null;let A;t[27]!==d?.authenticated||t[28]!==n||t[29]!==r||t[30]!==h||t[31]!==k||t[32]!==D||t[33]!==a?(A=async function(){if(!D)return;if(console.log(Fd({q2_path:`clone`})),!r){X.info(`Clone happens in the Project Navigator. Reclick the share link there.`,{action:{label:`Open Navigator`,onClick:()=>{n.navigator.open()}},duration:8e3});return}if(!d?.authenticated||h)return;g(!0);let e=jd(k),t;try{t=await r.runClone({url:e})}catch{X.error(`Clone failed. Please try again.`),g(!1);return}if(g(!1),t.kind===`ok`){try{await n.project.open({path:t.dir,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkDoc:D.path})}catch{X.error(`Cloned successfully, but could not open the project.`)}a.dismiss();return}},t[27]=d?.authenticated,t[28]=n,t[29]=r,t[30]=h,t[31]=k,t[32]=D,t[33]=a,t[34]=A):A=t[34];let j=A,M;t[35]!==p||t[36]!==r?(M=async function(){if(!(!r||p)){m(!0);try{let e=await r.startSignIn();m(!1),e!==null&&f(e)}catch{m(!1)}}},t[35]=p,t[36]=r,t[37]=M):M=t[37];let N=M,P;t[38]!==n||t[39]!==k||t[40]!==l||t[41]!==D||t[42]!==a?(P=async function(){if(!(!D||l)){u(!0),console.log(Fd({q2_path:`local`}));try{for(;;){let e=await n.dialog.openFolder();if(!e)break;let t=await n.share.validateLocalFolder({folderPath:e,owner:k.owner,repo:k.repo});if(console.log(Fd({folder_validate:t.kind})),t.kind===`ok`){await n.project.open({path:e,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkDoc:D.path}),a.dismiss();break}let r=Md(t,k);r&&X.error(r)}}catch{X.error(`Could not validate folder. Please try again.`)}u(!1)}},t[38]=n,t[39]=k,t[40]=l,t[41]=D,t[42]=a,t[43]=P):P=t[43];let F=P,I=r!==void 0&&d?.authenticated===!0&&!h,L=h?`Cloning...`:r&&d?.authenticated===!1?`Sign in to clone`:`Clone to a new folder`,R;t[44]===a?R=t[45]:(R=e=>{e||a.dismiss()},t[44]=a,t[45]=R);let z;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(bo,{children:`Open shared document`}),t[46]=z):z=t[46];let B=D.path?` · ${D.path}`:null,V;t[47]!==D.owner||t[48]!==D.repo||t[49]!==B?(V=(0,Z.jsxs)(Ao,{children:[z,(0,Z.jsxs)(vo,{children:[D.owner,`/`,D.repo,B]})]}),t[47]=D.owner,t[48]=D.repo,t[49]=B,t[50]=V):V=t[50];let H;t[51]===j?H=t[52]:(H=()=>{j()},t[51]=j,t[52]=H);let U=r!==void 0&&!I,W=r!==void 0&&!I,G;t[53]===L?G=t[54]:(G=(0,Z.jsx)(`span`,{className:`text-sm font-semibold`,children:L}),t[53]=L,t[54]=G);let K;t[55]!==D.owner||t[56]!==D.repo?(K=(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Downloads `,D.owner,`/`,D.repo,` from GitHub.`]}),t[55]=D.owner,t[56]=D.repo,t[57]=K):K=t[57];let q;t[58]!==H||t[59]!==U||t[60]!==W||t[61]!==G||t[62]!==K?(q=(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`share-receive-clone`,className:`flex flex-col items-start gap-2 rounded-lg border-2 border-primary/40 bg-card p-4 text-left transition hover:border-primary hover:bg-accent focus:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:border-primary/40 disabled:hover:bg-card`,onClick:H,disabled:U,"aria-disabled":W,children:[G,K]}),t[58]=H,t[59]=U,t[60]=W,t[61]=G,t[62]=K,t[63]=q):q=t[63];let ee;t[64]===F?ee=t[65]:(ee=()=>{F()},t[64]=F,t[65]=ee);let te=l||h,ne,re;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Z.jsx)(`span`,{className:`text-sm font-semibold`,children:`I already have it locally →`}),re=(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Pick the folder where you've cloned it.`}),t[66]=ne,t[67]=re):(ne=t[66],re=t[67]);let ie;t[68]!==ee||t[69]!==te?(ie=(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`share-receive-local`,className:`flex flex-col items-start gap-2 rounded-lg border border-border bg-card p-4 text-left transition hover:border-foreground/50 hover:bg-accent focus:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:ee,disabled:te,children:[ne,re]}),t[68]=ee,t[69]=te,t[70]=ie):ie=t[70];let ae;t[71]!==q||t[72]!==ie?(ae=(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[q,ie]}),t[71]=q,t[72]=ie,t[73]=ae):ae=t[73];let oe;t[74]!==p||t[75]!==d||t[76]!==r||t[77]!==N?(oe=r?(0,Z.jsx)(`div`,{className:`mt-3 flex items-center justify-between rounded-md border border-border bg-muted/30 px-3 py-2 text-xs`,"data-testid":`share-receive-auth-banner`,children:d===null?(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`Checking GitHub sign-in...`}):d.authenticated?(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Signed in as`,` `,(0,Z.jsxs)(`span`,{className:`font-medium text-foreground/90`,children:[`@`,d.login]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`Not signed in to GitHub.`}),(0,Z.jsx)(`button`,{type:`button`,"data-testid":`share-receive-signin`,className:`font-medium text-primary underline-offset-2 hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded`,onClick:()=>{N()},disabled:p,children:p?`Opening...`:`Sign in to GitHub`})]})}):null,t[74]=p,t[75]=d,t[76]=r,t[77]=N,t[78]=oe):oe=t[78];let se;t[79]===k?se=t[80]:(se=Od(k),t[79]=k,t[80]=se);let ce;t[81]===se?ce=t[82]:(ce=(0,Z.jsxs)(`p`,{className:`mt-3 text-[11px] text-muted-foreground`,children:[`Looking for`,` `,(0,Z.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-foreground/80`,children:se}),`.`]}),t[81]=se,t[82]=ce);let le;t[83]!==ae||t[84]!==oe||t[85]!==ce?(le=(0,Z.jsxs)(Do,{children:[ae,oe,ce]}),t[83]=ae,t[84]=oe,t[85]=ce,t[86]=le):le=t[86];let J;t[87]===a?J=t[88]:(J=(0,Z.jsx)(Oo,{children:(0,Z.jsx)(Y,{variant:`ghost`,onClick:()=>a.dismiss(),children:`Cancel`})}),t[87]=a,t[88]=J);let ue;t[89]!==V||t[90]!==le||t[91]!==J?(ue=(0,Z.jsxs)(wo,{className:`sm:max-w-xl`,"data-testid":`share-receive-dialog`,children:[V,le,J]}),t[89]=V,t[90]=le,t[91]=J,t[92]=ue):ue=t[92];let de;return t[93]!==R||t[94]!==ue?(de=(0,Z.jsx)(jo,{open:!0,onOpenChange:R,children:ue}),t[93]=R,t[94]=ue,t[95]=de):de=t[95],de}function Bd(){return null}async function Vd(e,t){let n;try{n=Ad(await t.project.listRecent(),{owner:e.owner,repo:e.repo})}catch{return{kind:`miss`}}if(!n)return{kind:`miss`};try{if((await t.share.validateLocalFolder({folderPath:n.path,owner:e.owner,repo:e.repo})).kind!==`ok`)return{kind:`miss`}}catch{return{kind:`miss`}}try{return await t.project.open({path:n.path,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkDoc:e.path}),{kind:`hit`}}catch{return{kind:`miss`}}}var Hd=(e,t,n)=>rl(e,t,n,`NavigatorApp`);function Ud(e,t){return e.filter(e=>e.path!==t)}function Wd(e){let t=(0,$.c)(82),{bridge:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let[i,a]=(0,Q.useState)(r),[o,s]=(0,Q.useState)(!0),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),b=typeof window<`u`&&window.okDesktop!=null,[x,S]=(0,Q.useState)(`auth`),{theme:C}=vr();za(n,C??`system`);let w;t[1]===n.project?w=t[2]:(w=()=>{let e=!1;return n.project.listRecent().then(t=>{e||a(t)}).catch(t=>{console.error(`[NavigatorApp] listRecent failed:`,t),e||l(t instanceof Error?t.message:`Failed to load recent projects.`)}).finally(()=>{e||s(!1)}),()=>{e=!0}},t[1]=n.project,t[2]=w);let T;t[3]===n?T=t[4]:(T=[n],t[3]=n,t[4]=T),(0,Q.useEffect)(w,T);let E;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(E=(e,t)=>Hd(e,t,l),t[5]=E):E=t[5];let D=E,O;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>d(!0),t[6]=O):O=t[6];let k=O,A;t[7]===n?A=t[8]:(A=()=>D(async()=>{let e=await n.dialog.openFolder();e&&await qd(n,e,`pick-existing`)},`Failed to open folder.`),t[7]=n,t[8]=A);let j=A,M;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>p(!0),t[9]=M):M=t[9];let N=M,P;t[10]===n?P=t[11]:(P=e=>D(async()=>{await qd(n,e,`recents`)},`Failed to open project.`),t[10]=n,t[11]=P);let F=P,I;t[12]===n.project?I=t[13]:(I=e=>D(async()=>{await n.project.removeRecent(e),a(t=>Ud(t,e))},`Failed to remove project.`),t[12]=n.project,t[13]=I);let L=I,z;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 z-10 h-9 ${b?`[-webkit-app-region:drag]`:``}`,"data-testid":`nav-chrome-row`}),t[14]=z):z=t[14];let B;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Z.jsx)(Cd,{className:`size-12 shrink-0`}),t[15]=B):B=t[15];let V;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`h1`,{className:`font-medium text-xl tracking-tight`,children:`Open Knowledge`}),(0,Z.jsx)(Zu,{})]}),t[16]=V):V=t[16];let H;t[17]===n.appVersion?H=t[18]:(H=(0,Z.jsxs)(`header`,{className:`shrink-0 flex-wrap flex items-center gap-2.5`,children:[B,(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[V,(0,Z.jsxs)(`p`,{className:`text-muted-foreground text-xs font-mono`,children:[`v`,n.appVersion]})]})]}),t[17]=n.appVersion,t[18]=H);let U;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Z.jsx)(Gd,{title:`Clone from GitHub`,description:`Bring a remote repository onto this machine.`,onClick:k,dataTestId:`nav-clone`,Icon:Sd}),t[19]=U):U=t[19];let W;t[20]===j?W=t[21]:(W=(0,Z.jsx)(Gd,{title:`Open folder on disk`,description:`Use a folder you already have.`,onClick:j,dataTestId:`nav-open`,Icon:R}),t[20]=j,t[21]=W);let G;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,Z.jsx)(Gd,{title:`Create new project`,description:`Start a new Open Knowledge project.`,onClick:N,dataTestId:`nav-create-new`,Icon:ce}),t[22]=G):G=t[22];let K;t[23]===W?K=t[24]:(K=(0,Z.jsxs)(`section`,{className:`grid shrink-0 sm:grid-cols-3 gap-3`,children:[U,W,G]}),t[23]=W,t[24]=K);let q;t[25]===c?q=t[26]:(q=c===null?null:(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 rounded-md border border-red-500/30 bg-red-500/10 px-3 py-2`,"data-testid":`nav-error-banner`,role:`alert`,children:[(0,Z.jsx)(`span`,{className:`text-red-700 text-xs dark:text-red-300`,children:c}),(0,Z.jsx)(Y,{type:`button`,variant:`link`,size:`sm`,onClick:()=>l(null),className:`h-auto p-0 text-red-700 text-xs dark:text-red-300`,"data-testid":`nav-error-dismiss`,children:`Dismiss`})]}),t[25]=c,t[26]=q);let ee;t[27]!==o||t[28]!==F||t[29]!==L||t[30]!==i?(ee=o?(0,Z.jsx)(`section`,{className:`flex shrink-0 flex-col items-center`,children:(0,Z.jsx)(ue,{className:`size-4 animate-spin text-muted-foreground/60`})}):i.length>0?(0,Z.jsxs)(`section`,{className:`flex min-h-0 flex-col`,children:[(0,Z.jsx)(`h2`,{className:`mb-2 shrink-0 font-medium text-muted-foreground font-mono text-xs uppercase tracking-wide`,children:`Recent`}),(0,Z.jsx)(`ul`,{className:`min-h-0 max-h-48 subtle-scrollbar scroll-fade-mask overflow-y-auto space-y-0.5 -mx-4`,"data-testid":`nav-recent-list`,children:i.map(e=>(0,Z.jsx)(Kd,{project:e,onOpen:()=>F(e.path),onRemove:()=>L(e.path)},e.path))})]}):null,t[27]=o,t[28]=F,t[29]=L,t[30]=i,t[31]=ee):ee=t[31];let te;t[32]!==H||t[33]!==K||t[34]!==q||t[35]!==ee?(te=(0,Z.jsx)(`div`,{className:`mx-auto flex h-full w-full max-w-5xl flex-col overflow-hidden px-12 py-12`,children:(0,Z.jsxs)(`div`,{className:`my-auto flex min-h-0 flex-col space-y-10`,children:[H,K,q,ee]})}),t[32]=H,t[33]=K,t[34]=q,t[35]=ee,t[36]=te):te=t[36];let ne,re;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Z.jsx)(Td,{}),re=(0,Z.jsx)(nd,{}),t[37]=ne,t[38]=re):(ne=t[37],re=t[38]);let ie;t[39]!==n||t[40]!==f?(ie=(0,Z.jsx)(pd,{open:f,onOpenChange:p,bridge:n}),t[39]=n,t[40]=f,t[41]=ie):ie=t[41];let ae;t[42]===v?ae=t[43]:(ae=e=>{h(e),e||(_(!1),v&&(v(null),y(null)))},t[42]=v,t[43]=ae);let oe;t[44]===n?oe=t[45]:(oe=hl(n),t[44]=n,t[45]=oe);let se=x===`identity`,le;t[46]!==g||t[47]!==v?(le=e=>{h(!1),g&&(_(!1),d(!0)),v&&(v({authenticated:!0,host:`github.com`,login:e.login}),y(null))},t[46]=g,t[47]=v,t[48]=le):le=t[48];let J;t[49]!==m||t[50]!==ae||t[51]!==oe||t[52]!==se||t[53]!==le?(J=(0,Z.jsx)(qu,{open:m,onOpenChange:ae,transport:oe,identityPrompt:se,onSuccess:le}),t[49]=m,t[50]=ae,t[51]=oe,t[52]=se,t[53]=le,t[54]=J):J=t[54];let de;t[55]===n?de=t[56]:(de=_l(n),t[55]=n,t[56]=de);let fe;t[57]===n?fe=t[58]:(fe=dl(n),t[57]=n,t[58]=fe);let pe;t[59]===n.dialog?pe=t[60]:(pe=()=>n.dialog.openFolder(),t[59]=n.dialog,t[60]=pe);let me;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(me=()=>{d(!1),S(`auth`),_(!0),h(!0)},t[61]=me):me=t[61];let he;t[62]===n?he=t[63]:(he=e=>{let{dir:t}=e;D(()=>qd(n,t,`pick-existing`),`Failed to open cloned project.`)},t[62]=n,t[63]=he);let ge;t[64]!==u||t[65]!==de||t[66]!==fe||t[67]!==pe||t[68]!==he?(ge=(0,Z.jsx)(ed,{open:u,onOpenChange:d,transport:de,authQueryTransport:fe,pickParentFolder:pe,onSignIn:me,onCloneComplete:he}),t[64]=u,t[65]=de,t[66]=fe,t[67]=pe,t[68]=he,t[69]=ge):ge=t[69];let _e;if(t[70]!==n){let e;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>new Promise(e=>{y(()=>e),h(!0)}),t[72]=e):e=t[72],_e=ol({bridge:n,authQueryTransport:dl(n),cloneTransport:_l(n),openSignIn:e}),t[70]=n,t[71]=_e}else _e=t[71];let ve;t[73]!==n||t[74]!==_e?(ve=(0,Z.jsx)(zd,{bridge:n,cloneController:_e}),t[73]=n,t[74]=_e,t[75]=ve):ve=t[75];let ye;return t[76]!==te||t[77]!==ie||t[78]!==J||t[79]!==ge||t[80]!==ve?(ye=(0,Z.jsxs)(`div`,{className:`relative flex h-screen w-screen flex-col overflow-hidden bg-primary-foreground dark:bg-background text-foreground`,children:[z,te,ne,re,ie,J,ge,ve]}),t[76]=te,t[77]=ie,t[78]=J,t[79]=ge,t[80]=ve,t[81]=ye):ye=t[81],ye}function Gd(e){let t=(0,$.c)(14),{title:n,description:r,onClick:i,dataTestId:a,Icon:o}=e,s;t[0]===o?s=t[1]:(s=o?(0,Z.jsx)(o,{className:`size-4 shrink-0 text-muted-foreground`}):null,t[0]=o,t[1]=s);let c;t[2]===n?c=t[3]:(c=(0,Z.jsx)(`span`,{className:`font-medium text-gray-700 dark:text-foreground text-sm`,children:n}),t[2]=n,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===r?u=t[8]:(u=(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs leading-snug`,children:r}),t[7]=r,t[8]=u);let d;return t[9]!==a||t[10]!==i||t[11]!==l||t[12]!==u?(d=(0,Z.jsxs)(Y,{type:`button`,variant:`outline`,onClick:i,"data-testid":a,className:`h-auto flex-col items-start justify-start gap-1.5 whitespace-normal bg-card px-4 py-3.5 text-left`,children:[l,u]}),t[9]=a,t[10]=i,t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function Kd(e){let t=(0,$.c)(25),{project:n,onOpen:r,onRemove:i}=e,a=n.missing,o=n.missing&&`opacity-50`,s;t[0]===o?s=t[1]:(s=mi(`h-auto min-w-0 flex-1 justify-between gap-2 py-3.5 pl-4 pr-2 text-left hover:bg-transparent`,o),t[0]=o,t[1]=s);let c;t[2]===n.name?c=t[3]:(c=(0,Z.jsx)(`span`,{className:`font-medium text-sm text-gray-700 dark:text-foreground`,children:n.name}),t[2]=n.name,t[3]=c);let l;t[4]===n.path?l=t[5]:(l=(0,Z.jsx)(`span`,{className:`truncate w-full text-muted-foreground text-xs`,children:n.path}),t[4]=n.path,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 truncate`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]===n.missing?d=t[10]:(d=n.missing?(0,Z.jsx)(Ge,{className:`text-2xs rounded-sm`,variant:`warning`,children:`Missing`}):null,t[9]=n.missing,t[10]=d);let f;t[11]!==r||t[12]!==n.missing||t[13]!==s||t[14]!==u||t[15]!==d?(f=(0,Z.jsxs)(Y,{type:`button`,variant:`ghost`,onClick:r,disabled:a,className:s,children:[u,d]}),t[11]=r,t[12]=n.missing,t[13]=s,t[14]=u,t[15]=d,t[16]=f):f=t[16];let p=`Remove ${n.name} from recent projects`,m=`nav-recent-remove-${n.path}`,h;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(_o,{"aria-hidden":`true`}),t[17]=h):h=t[17];let g;t[18]!==i||t[19]!==m||t[20]!==p?(g=(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:i,"aria-label":p,title:`Remove from recent projects`,className:`pointer-events-none mr-2 opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 focus-visible:pointer-events-auto focus-visible:opacity-100`,"data-testid":m,children:h}),t[18]=i,t[19]=m,t[20]=p,t[21]=g):g=t[21];let _;return t[22]!==g||t[23]!==f?(_=(0,Z.jsxs)(`li`,{className:`group flex items-center justify-between rounded-lg hover:bg-accent`,children:[f,g]}),t[22]=g,t[23]=f,t[24]=_):_=t[24],_}async function qd(e,t,n){await e.project.open({path:t,target:`new-window`,entryPoint:n})}var Jd=e=>{let t=(0,$.c)(8),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let{theme:r}=vr(),i=r===void 0?`system`:r,a,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a={success:(0,Z.jsx)(Xr,{className:`size-4`}),info:(0,Z.jsx)(Xe,{className:`size-4`}),warning:(0,Z.jsx)(dr,{className:`size-4`}),error:(0,Z.jsx)(wc,{className:`size-4`}),loading:(0,Z.jsx)(ue,{className:`size-4 animate-spin`})},o={"--normal-bg":`var(--popover)`,"--normal-text":`var(--popover-foreground)`,"--normal-border":`var(--border)`,"--border-radius":`var(--radius)`},t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s={classNames:{toast:`cn-toast`}},t[4]=s):s=t[4];let c;return t[5]!==n||t[6]!==i?(c=(0,Z.jsx)(yo,{theme:i,className:`toaster group`,icons:a,style:o,toastOptions:s,...n}),t[5]=n,t[6]=i,t[7]=c):c=t[7],c};function Yd(e){let{apiOrigin:t}=e;if(!t)return;let n=Symbol.for(`ok.desktop.fetchRewrite`);if(window.fetch[n])return;let r=window.fetch.bind(window),i=((e,n)=>{if(typeof e==`string`)return r(Xd(e,t),n);if(e instanceof URL)return e.pathname.startsWith(`/api/`)&&(e.origin===window.location.origin||e.protocol===`file:`)?r(t+(e.pathname+e.search+e.hash),n):r(e,n);try{let i=new URL(e.url,window.location.origin);if(i.pathname.startsWith(`/api/`)){let a=i.pathname+i.search+i.hash;return r(new Request(t+a,e),n)}}catch{}return r(e,n)});i[n]=!0,window.fetch=i}function Xd(e,t){return e.startsWith(`/api/`)?t+e:e}function Zd(e){return`#/${encodeURIComponent(e)}`}function Qd(e){let t=e.bridge;if(!t)return;let n=e.setHash??(e=>{window.location.hash=e});return t.onDeepLink(e=>{n(Zd(e.doc))})}var $d=4e3,ef=1440*60*1e3;function tf(e){let t=e.bridge;if(t&&t.onboarding)return t.onboarding.onToast(e=>{if(e.kind===`ancestor-promote`){X.success(`Opened existing OK project at ${e.ancestorPath}`,{duration:$d});return}if(e.kind===`startup-reclaim`){let t=[];if(e.mcp.status===`repaired`){let n=e.mcp.editors.map(e=>lr[e]??e).join(`, `);t.push(`repaired ${n} MCP integration`)}else e.mcp.status===`failed`&&t.push(`MCP auto-repair failed`);e.path.status===`installed`&&t.push(e.path.summary),e.path.status===`failed`&&t.push(`PATH install failed: ${e.path.summary}`);let n=t.length>0?t.join(`; `):`Open Knowledge integrations checked.`,r=e.mcp.status===`failed`||e.path.status===`failed`;X[r?`error`:`success`](n,{duration:r?ef:$d});return}let t=qo(e.gitRoot,e.pickedPath)??e.pickedPath;X.success(`Initialized OK at ${e.gitRoot} — opened parent of ${t} because it contains a .git folder`,{duration:$d})})}var nf=!1;function rf(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{dt(n,{durationMs:Math.round(e*1e3)/1e3,threw:!o,...i},{startTime:t,duration:e})}catch{}}}}function af(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 of=0,sf=0,cf=0,lf=0,uf=null,df=[`linkResolutionDecoration$`],ff=new WeakSet,pf=new WeakSet;function mf(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}function hf(){return!1}function gf(){return!hf()}function _f(e,t){if(gf())return t;let n=`ok/cold/nodeview-factory-${mf(e)}`;return function(...r){let i=performance.now();try{return t(...r)}finally{let t=performance.now()-i;dt(n,{nodeType:e,durationMs:Math.round(t*1e3)/1e3},{startTime:i,duration:t})}}}function vf(e){if(gf())return;let t=e.state.plugins;for(let e of t){if(pf.has(e))continue;let t=e.spec?.key?.key;if(!t||!df.some(e=>t.startsWith(e)))continue;let n=e.props,r=n.decorations;if(typeof r!=`function`){pf.add(e);continue}let i=`ok/cold/decoration-${mf(t.replace(/\$\d*$/,``))}`;n.decorations=function(...e){let n=performance.now();try{return r.apply(this,e)}finally{let e=performance.now()-n;dt(i,{pluginKey:t,durationMs:Math.round(e*1e3)/1e3},{startTime:n,duration:e})}},pf.add(e)}}function yf(e){if(gf())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=_f(e,n);r.__okWrapped=!0,t[e]=r}}function bf(e){return gf()?e:e.map(e=>{let t=e.name??`unknown`,n=mf(t);return e.extend({onBeforeCreate(){let e=performance.now();try{this.parent?.()}finally{let r=performance.now()-e;dt(`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;dt(`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;dt(`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;dt(`ok/cold/ext-${n}-on-destroy`,{ext:t,hook:`onDestroy`,durationMs:Math.round(r*1e3)/1e3},{startTime:e,duration:r})}}})})}function xf(){if(!nf){nf=!0,rf(_n.prototype,`mount`,`ok/cold/editor-mount`,(e,t,n,r)=>{let i=e;return gf()||(uf=performance.now()),{elementDefault:i.options?.element?.nodeName??null,docSize:af(i.editorState),durationMs:r}}),rf(_n.prototype,`createView`,`ok/cold/editor-create-view`,e=>{let t=e;return!gf()&&!ff.has(e)&&t.view&&(vf(t.view),yf(t.view),ff.add(e)),{docSize:af(t.editorState)}}),rf(_n.prototype,`createNodeViews`,`ok/cold/create-node-views`,(e,t,n,r)=>{lf+=1;let i=e;return!gf()&&i.view&&yf(i.view),{docSize:af(i.view),seq:lf,durationMs:r}}),rf(Yn.prototype,`updateState`,`ok/cold/pm-update-state`,(e,t,n,r)=>(sf+=1,{seq:sf,docSize:af(e.state),durationMs:r})),rf(Yn.prototype,`setProps`,`ok/cold/pm-set-props`,(e,t,n,r)=>(cf+=1,{seq:cf,docSize:af(e.state),durationMs:r})),rf(I.prototype,`_forceRerender`,`ok/cold/force-rerender`,(e,t,n,r)=>{of+=1;let i=e,a=(()=>{try{return i.type?.toArray?i.type.toArray().length:null}catch{return null}})();return{seq:of,topLevelYElements:a,durationMs:r}}),rf(tt.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`)&&(dt(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}),!gf()&&e===`first-paint`&&uf!==null)){let e=uf,n=Math.max(0,t.startTime-e);dt(`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}),uf=null}}}).observe({type:`paint`,buffered:!0})}catch{}globalThis.__okColdMountInstrumented=!0}}var Sf=`Relaunch`,Cf=`Release notes`,wf=`Updates paused`,Tf=`Download`,Ef=`Reset to defaults`,Df=`Relaunch failed — please restart manually`,Of=`Recovery action failed — please try again`;function kf(e,t){let n=t instanceof Error&&t.message?t.message:``;return n?`${e}: ${n}`:e}function Af(e){return`Version ${e} ready to install`}function jf(e){return`Updated to Version ${e}`}function Mf(e){return`Your settings and recent projects were saved by a newer build than this one (v${e}). Reset to defaults to continue.`}var Nf=0,Pf=0,Ff=1,If=2,Lf=3;function Rf(e,t,n=()=>{}){let r=[];return r.push(e.onUpdateDownloaded(({version:r})=>{let i=`update-downloaded`;t({id:i,body:Af(r),priority:If,action:{label:Sf,onClick:()=>{e.update.relaunchNow().then(()=>{n(i)},e=>{t({id:`relaunch-error-${r}`,body:kf(Df,e),variant:`error`,priority:Ff})})}}})})),r.push(e.onWhatsNew(({version:n,releaseUrl:r})=>{t({id:`whats-new-${n}`,body:jf(n),priority:Lf,action:{label:Cf,onClick:()=>{e.shell.openExternal(r)}}})})),r.push(e.onUpdateStuckHint(({downloadUrl:n})=>{t({id:`update-stuck-hint`,body:wf,priority:Pf,action:{label:Tf,onClick:()=>{e.shell.openExternal(n)}}})})),()=>{for(let e of r)e()}}function zf(e,t,n,r=()=>{}){let i=`schema-incompatibility-${t.persistedSchemaVersion}`,a=`schema-incompatibility-error-${t.persistedSchemaVersion}`,o=e=>{r(i),n({id:a,body:kf(Of,e),variant:`error`,priority:Nf})};n({id:i,body:Mf(t.currentBuild),priority:Nf,action:{label:Ef,onClick:()=>{e.state.resetIncompatible().then(()=>{r(i)},o)}}})}var Bf=[],Vf=new Set,Hf=!1;function Uf(){for(let e of Vf)e()}function Wf(e){let t=Bf.findIndex(t=>t.id===e.id);if(t===-1)Bf=[...Bf,e];else{let n=Bf.slice();n[t]=e,Bf=n}Uf()}function Gf(e){let t=Bf.filter(t=>t.id!==e);t.length!==Bf.length&&(Bf=t,Uf())}function Kf(){return Bf}function qf(e){return Vf.add(e),()=>{Vf.delete(e)}}function Jf(){if(Hf||typeof window>`u`)return;let e=window.okDesktop;e&&(Hf=!0,Rf(e,Wf,Gf),e.state.query().then(t=>{t.schemaIncompatibility&&zf(e,t.schemaIncompatibility,Wf,Gf)},e=>{console.warn(`[update-notices-store] bridge.state.query() failed`,e)}))}var Yf=`ok-omnibar-recents-v1`,Xf=10;function Zf(e){return typeof e==`object`&&!!e&&(e.kind===`file`||e.kind===`folder`)&&typeof e.path==`string`&&typeof e.lastOpenedAt==`string`}function Qf(e){if(e)return e;if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function $f(e,t){return`${e}:${t}`}function ep(e){let t=Qf(e);if(!t)return[];try{let e=t.getItem(Yf);if(!e)return[];let n=JSON.parse(e);return Array.isArray(n)?n.filter(Zf).slice(0,Xf):[]}catch{return[]}}function tp(e,t){let n=Qf(t);if(n)try{n.setItem(Yf,JSON.stringify(e.slice(0,Xf)))}catch(e){console.warn(`[omnibar] Failed to save recent entries:`,e)}}function np(e,t){return[t,...e.filter(e=>e.kind!==t.kind||e.path!==t.path)].slice(0,Xf)}function rp(e,t){return e.filter(e=>t.has($f(e.kind,e.path)))}var ip=50,ap=30,op=``,sp=null;function cp(e){return e.trim().toLowerCase()}function lp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function up(e){let t=e.trim();return t?[...new Set(t.split(/\s+/).filter(Boolean))].sort((e,t)=>t.length-e.length):[]}function dp(e,t,n=new Map,r=new Map){let i=[];for(let t of e){let e=r.get(t)?.modified,a=n.get(t);i.push({kind:`file`,path:t,name:ci(t),...a?{title:a}:{},...e?{modifiedTs:Date.parse(e)}:{}})}for(let e of t)i.push({kind:`folder`,path:e,name:ci(e)});return i.sort((e,t)=>{let n=e.path.localeCompare(t.path);return n===0?e.kind===t.kind?0:e.kind===`folder`?-1:1:n}),i}function fp(e){return ni({kind:e.kind===`file`?`page`:`folder`,path:e.path,title:e.title??e.name,modifiedTs:e.modifiedTs??0})}function pp(e){return{entries:e,byId:new Map(e.map(e=>[`${e.kind===`file`?`page`:`folder`}:${e.path}`,e])),corpus:gn(e.map(fp))}}function mp(e){return e.map(e=>`${e.kind}\u0000${e.path}\u0000${e.title??``}\u0000${e.modifiedTs??0}`).join(``)}function hp(e){let t=mp(e);return sp&&op===t?sp:(op=t,sp=pp(e),sp)}function gp(e,t,n=ip){return _p(hp(e),t,n)}function _p(e,t,n=ip){let r=cp(t);return r?Vr(e.corpus,r,{intent:`omnibar`,limit:n,scopes:[`page`,`folder`]}).map(t=>e.byId.get(t.document.id)).filter(e=>e!==void 0):e.entries.slice(0,20)}function vp(e,t){let n=up(t);if(n.length===0||e.length===0)return[{text:e,match:!1,start:0}];let r=RegExp(`(${n.map(lp).join(`|`)})`,`gi`),i=[],a=0;for(let t of e.matchAll(r)){let n=t.index??0;n>a&&i.push({text:e.slice(a,n),match:!1,start:a}),i.push({text:t[0],match:!0,start:n}),a=n+t[0].length}return a<e.length&&i.push({text:e.slice(a),match:!1,start:a}),i.length>0?i:[{text:e,match:!1,start:0}]}function yp(e){if(e.kind!==`page`&&e.kind!==`folder`||typeof e.path!=`string`)return null;let t=ci(e.path);return{kind:e.kind===`page`?`file`:`folder`,path:e.path,name:t,...e.title&&{title:e.title},...e.snippet&&{snippet:e.snippet},...typeof e.score==`number`&&{score:e.score}}}async function bp(e,t={}){let n=e.trim();if(!n)return[];let r=await fetch(`/api/search`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({query:n,intent:`full_text`,scopes:[`page`,`folder`,`content`],limit:t.limit??ap}),signal:t.signal});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(Gn(e)??`Search failed with status ${r.status}`)}return((await r.json()).results??[]).map(yp).filter(e=>!!e)}function xp(e,t,n=[]){let r=cp(t);return r?cp([e,...n].join(` `)).includes(r):!0}var Sp=`tag:`;function Cp(e,t){if(!e.toLowerCase().startsWith(`tag:`))return{kind:`normal`,query:e};let n=e.slice(4).replace(/^\s+/,``).trim();return n&&t.has(n)?{kind:`tag-docs`,tagName:n}:{kind:`tag-list`,query:n}}function wp(e,t){return ye(e,t)}var Tp=pe;async function Ep(e){let t=await fetch(`/api/tags/${encodeURIComponent(e)}`);if(!t.ok)throw Error(`/api/tags/${e} responded with ${t.status}`);let n=await t.json();return Array.isArray(n.docs)?n.docs:[]}var Dp=`open-knowledge:doc-panel-tab`,Op=null;function kp(){let e=Op;return Op=null,e}function Ap(e,t=typeof window>`u`?new EventTarget:window){Op=e,t.dispatchEvent(new CustomEvent(Dp,{detail:{tab:e}}))}function jp(e,t=typeof window>`u`?new EventTarget:window){let n=t=>{let n=t instanceof CustomEvent?t.detail?.tab:void 0;n&&e(n)};return t.addEventListener(Dp,n),()=>t.removeEventListener(Dp,n)}var Mp=[`.md`,`.mdx`];function Np(e){let t=e.toLowerCase();for(let e of Mp)if(t.endsWith(e))return e;return null}function Pp(e){let t=Np(e);return t?e.slice(0,-t.length):e}var Fp=`__blank__`,Ip={local:0,inherited:1};function Lp(e){return[...e].sort((e,t)=>{let n=Ip[e.scope]-Ip[t.scope];if(n!==0)return n;let r=(e.title??e.name).toLowerCase(),i=(t.title??t.name).toLowerCase();return r.localeCompare(i)})}function Rp(e){return e.trim()?e.includes(`..`)?`Path cannot contain ".."`:e.startsWith(`/`)?`Path cannot start with "/"`:e.includes(`\\`)?`Path cannot contain backslashes`:e.includes(`\0`)?`Path cannot contain null bytes`:null:`Name cannot be empty`}function zp(e){let t=e.fileName.trim(),n=Np(t)?t:`${t}${e.fileExtension??`.md`}`;if(e.kind===`folder`){let t=(e.folderName??``).trim();return`${e.initialDir?`${e.initialDir}/${t}`:t}/${n}`}return e.initialDir?`${e.initialDir}/${n}`:n}function Bp(e){let t=e.target;return t?.tagName===`INPUT`||t?.tagName===`TEXTAREA`||t?.isContentEditable?!1:!!((e.metaKey||e.ctrlKey)&&e.altKey&&e.key.toLowerCase()===`n`)}function Vp(e){let t=e.value.lastIndexOf(`.`);t>0?e.setSelectionRange(0,t):e.select()}function Hp(e){let t=(0,$.c)(120),{open:n,onOpenChange:r,kind:i,initialDir:a,suggestedName:o,initialTemplate:s,description:c,onCreated:u,folderConfig:d}=e,{addPage:f}=qr(),p=Aa(d?null:a),m=d??p,[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(`.md`),[x,S]=(0,Q.useState)(Fp),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(null),k=(0,Q.useId)(),A=(0,Q.useId)(),j=(0,Q.useId)(),M=(0,Q.useId)(),N=(0,Q.useId)(),[P,F]=(0,Q.useState)(!1),I=(0,Q.useRef)(null),L=(0,Q.useRef)(null),R,z;t[0]!==s||t[1]!==i||t[2]!==n||t[3]!==o?(R=()=>{if(n){w(null),O(null),E(!1),v(``),S(i===`file`&&s?s:Fp),F(!1);let e=i===`file`?o??`untitled`:`index`,t=Np(e);b(t??`.md`),g(t?Pp(e):e)}},z=[n,i,o,s],t[0]=s,t[1]=i,t[2]=n,t[3]=o,t[4]=R,t[5]=z):(R=t[4],z=t[5]),(0,Q.useEffect)(R,z);let B;t[6]!==m.state.data||t[7]!==m.state.status?(B=m.state.status===`ready`?Lp(m.state.data.folder.templates_available??[]):[],t[6]=m.state.data,t[7]=m.state.status,t[8]=B):B=t[8];let V=B,H;t[9]!==m.state.data||t[10]!==m.state.status||t[11]!==n||t[12]!==x?(H=()=>{n&&x!==Fp&&m.state.status===`ready`&&((m.state.data.folder.templates_available??[]).some(e=>e.name===x)||S(Fp))},t[9]=m.state.data,t[10]=m.state.status,t[11]=n,t[12]=x,t[13]=H):H=t[13];let U;t[14]!==m.state||t[15]!==n||t[16]!==x?(U=[n,x,m.state],t[14]=m.state,t[15]=n,t[16]=x,t[17]=U):U=t[17],(0,Q.useEffect)(H,U);let W=i===`file`,G=m.state.status===`loading`||m.state.status===`idle`,K=m.state.status===`error`?m.state.message:null,q;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(q=function(e){let t=Np(e);t?(b(t),g(Pp(e))):g(e),w(null)},t[18]=q):q=t[18];let ee=q,te;t[19]!==y||t[20]!==h||t[21]!==_||t[22]!==a||t[23]!==i?(te=function(){return zp({kind:i,initialDir:a,fileName:h,fileExtension:y,folderName:_})},t[19]=y,t[20]=h,t[21]=_,t[22]=a,t[23]=i,t[24]=te):te=t[24];let ne=te,re;t[25]!==h||t[26]!==_||t[27]!==i?(re=function(){if(i===`folder`){let e=Rp(_.trim());if(e)return{message:`Folder name: ${e}`,field:`folder`}}let e=Rp(h.trim());return e?{message:e,field:`file`}:null},t[25]=h,t[26]=_,t[27]=i,t[28]=re):re=t[28];let ie=re,ae;t[29]!==T||t[30]!==h||t[31]!==_||t[32]!==i?(ae=T||!h.trim()||i===`folder`&&!_.trim(),t[29]=T,t[30]=h,t[31]=_,t[32]=i,t[33]=ae):ae=t[33];let oe=ae,se;t[34]!==f||t[35]!==ne||t[36]!==ie||t[37]!==i||t[38]!==u||t[39]!==r||t[40]!==x?(se=async function(){let e=ie();if(e){w(e.message),O(e.field);return}E(!0),w(null),O(null);let t=ne(),n=i===`file`&&x!==Fp?x:void 0,a={path:t};n!==void 0&&(a.template=n);try{let e=await fetch(`/api/create-page`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(a)}),t=await l(e,`Server error (HTTP ${e.status})`);if(!t.ok){E(!1),w(t.title),O(`form`);return}let n=wr.safeParse(t.body);if(E(!1),!n.success){w(`Failed to create ${i}`),O(`form`);return}let o=n.data.docName;r(!1),window.location.hash=`#/${o}`,f(o),Fr([`files`,`backlinks`,`graph`]),u?.(o)}catch(e){console.warn(`[NewItemDialog] create failed:`,e),E(!1),w(`Network error — please try again`),O(`form`)}},t[34]=f,t[35]=ne,t[36]=ie,t[37]=i,t[38]=u,t[39]=r,t[40]=x,t[41]=se):se=t[41];let ce=se,le=a||`(root)`,J=i===`file`?`New file`:`New folder`,ue;t[42]===J?ue=t[43]:(ue=(0,Z.jsx)(bo,{children:J}),t[42]=J,t[43]=ue);let de;t[44]!==c||t[45]!==le?(de=c??(0,Z.jsxs)(Z.Fragment,{children:[`Create in `,(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:le})]}),t[44]=c,t[45]=le,t[46]=de):de=t[46];let fe;t[47]===de?fe=t[48]:(fe=(0,Z.jsx)(vo,{children:de}),t[47]=de,t[48]=fe);let pe;t[49]!==ue||t[50]!==fe?(pe=(0,Z.jsxs)(Ao,{children:[ue,fe]}),t[49]=ue,t[50]=fe,t[51]=pe):pe=t[51];let me;t[52]!==x||t[53]!==W||t[54]!==M||t[55]!==P||t[56]!==N||t[57]!==V||t[58]!==K||t[59]!==G?(me=W&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{id:M,className:`mb-1.5 block text-sm font-medium`,children:`Start from`}),K?(0,Z.jsxs)(`p`,{role:`alert`,className:`mb-1.5 text-xs text-destructive`,children:[`Could not load templates: `,K,`. You can still create a blank note.`]}):null,(0,Z.jsx)(Gp,{triggerId:N,labelledById:M,open:P,onOpenChange:F,value:x,onValueChange:S,templates:V,loading:G}),!G&&!K&&V.length===0?(0,Z.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`No templates resolve here. Add one in this folder's Templates section, or in Settings → Templates.`}):null]}),t[52]=x,t[53]=W,t[54]=M,t[55]=P,t[56]=N,t[57]=V,t[58]=K,t[59]=G,t[60]=me):me=t[60];let he;t[61]!==C||t[62]!==D||t[63]!==k||t[64]!==A||t[65]!==_||t[66]!==i?(he=i===`folder`&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:A,children:`Folder name`}),(0,Z.jsx)(Po,{ref:L,id:A,value:_,onChange:e=>{v(e.target.value),w(null)},placeholder:`folder-name`,autoFocus:!0,"aria-describedby":C&&(D===`folder`||D===`form`)?k:void 0,"aria-invalid":C&&(D===`folder`||D===`form`)?!0:void 0,onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault();let t=Rp(_.trim());if(t){w(`Folder name: ${t}`),O(`folder`);return}I.current?.focus()}}})]}),t[61]=C,t[62]=D,t[63]=k,t[64]=A,t[65]=_,t[66]=i,t[67]=he):he=t[67];let ge=i===`folder`?`First file name`:`File name`,_e;t[68]!==j||t[69]!==ge?(_e=(0,Z.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:j,children:ge}),t[68]=j,t[69]=ge,t[70]=_e):_e=t[70];let ve;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ve=e=>ee(e.target.value),t[71]=ve):ve=t[71];let ye=i===`file`,be=C&&(D===`file`||D===`form`)?k:void 0,xe=C&&(D===`file`||D===`form`)?!0:void 0,Se;t[72]!==ce||t[73]!==oe?(Se=e=>{e.key===`Enter`&&!oe&&ce()},t[72]=ce,t[73]=oe,t[74]=Se):Se=t[74];let Ce;t[75]!==j||t[76]!==h||t[77]!==ye||t[78]!==be||t[79]!==xe||t[80]!==Se?(Ce=(0,Z.jsx)(Po,{ref:I,id:j,value:h,onChange:ve,placeholder:`my-note`,autoFocus:ye,"aria-describedby":be,"aria-invalid":xe,onFocus:Wp,onKeyDown:Se,className:`flex-1`}),t[75]=j,t[76]=h,t[77]=ye,t[78]=be,t[79]=xe,t[80]=Se,t[81]=Ce):Ce=t[81];let we;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(we=e=>{(e===`.md`||e===`.mdx`)&&b(e)},t[82]=we):we=t[82];let Te;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(Te=Mp.map(Up),t[83]=Te):Te=t[83];let Ee;t[84]===y?Ee=t[85]:(Ee=(0,Z.jsx)(Wo,{type:`single`,value:y,onValueChange:we,variant:`outline`,"aria-label":`File extension`,className:`shrink-0`,children:Te}),t[84]=y,t[85]=Ee);let De;t[86]!==Ce||t[87]!==Ee?(De=(0,Z.jsxs)(`div`,{className:`flex items-stretch gap-2`,children:[Ce,Ee]}),t[86]=Ce,t[87]=Ee,t[88]=De):De=t[88];let Oe;t[89]!==C||t[90]!==k?(Oe=C&&(0,Z.jsx)(`p`,{id:k,role:`alert`,className:`text-xs text-red-600 dark:text-red-400`,children:C}),t[89]=C,t[90]=k,t[91]=Oe):Oe=t[91];let ke;t[92]!==_e||t[93]!==De||t[94]!==Oe?(ke=(0,Z.jsxs)(`div`,{children:[_e,De,Oe]}),t[92]=_e,t[93]=De,t[94]=Oe,t[95]=ke):ke=t[95];let Ae;t[96]!==me||t[97]!==he||t[98]!==ke?(Ae=(0,Z.jsx)(Do,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[me,he,ke]})}),t[96]=me,t[97]=he,t[98]=ke,t[99]=Ae):Ae=t[99];let je;t[100]===r?je=t[101]:(je=()=>r(!1),t[100]=r,t[101]=je);let Me;t[102]!==T||t[103]!==je?(Me=(0,Z.jsx)(Y,{variant:`outline`,className:`font-mono uppercase`,onClick:je,disabled:T,children:`Cancel`}),t[102]=T,t[103]=je,t[104]=Me):Me=t[104];let Ne=T?`Creating`:`Create`,Pe;t[105]!==ce||t[106]!==oe||t[107]!==Ne?(Pe=(0,Z.jsx)(Y,{onClick:ce,disabled:oe,children:Ne}),t[105]=ce,t[106]=oe,t[107]=Ne,t[108]=Pe):Pe=t[108];let Fe;t[109]!==Me||t[110]!==Pe?(Fe=(0,Z.jsxs)(Oo,{children:[Me,Pe]}),t[109]=Me,t[110]=Pe,t[111]=Fe):Fe=t[111];let Ie;t[112]!==pe||t[113]!==Ae||t[114]!==Fe?(Ie=(0,Z.jsxs)(wo,{className:`sm:max-w-md`,"data-ok-layer-spawned":``,children:[pe,Ae,Fe]}),t[112]=pe,t[113]=Ae,t[114]=Fe,t[115]=Ie):Ie=t[115];let Le;return t[116]!==r||t[117]!==n||t[118]!==Ie?(Le=(0,Z.jsx)(jo,{open:n,onOpenChange:r,children:Ie}),t[116]=r,t[117]=n,t[118]=Ie,t[119]=Le):Le=t[119],Le}function Up(e){return(0,Z.jsx)(Vo,{value:e,"aria-label":`Use ${e} extension`,children:e},e)}function Wp(e){return Vp(e.currentTarget)}function Gp(e){let t=(0,$.c)(53),{triggerId:n,labelledById:r,open:i,onOpenChange:a,value:o,onValueChange:s,templates:c,loading:l}=e,u=(0,Q.useId)(),d;if(t[0]!==c||t[1]!==o){let e;t[3]===o?e=t[4]:(e=e=>e.name===o,t[3]=o,t[4]=e),d=c.find(e),t[0]=c,t[1]=o,t[2]=d}else d=t[2];let p=d,m=o===Fp,h=i?u:void 0,g=`${r} ${n}`,_=l?`Loading templates`:m?`Blank note`:p?.title??p?.name??o,v;t[5]===_?v=t[6]:(v=(0,Z.jsx)(`span`,{className:`truncate`,children:_}),t[5]=_,t[6]=v);let y;t[7]!==m||t[8]!==l||t[9]!==p?(y=!l&&!m&&p?(0,Z.jsx)(Yp,{entry:p}):null,t[7]=m,t[8]=l,t[9]=p,t[10]=y):y=t[10];let b;t[11]!==v||t[12]!==y?(b=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[v,y]}),t[11]=v,t[12]=y,t[13]=b):b=t[13];let x;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(qs,{className:`ml-2 size-4 shrink-0 opacity-50`,"aria-hidden":`true`}),t[14]=x):x=t[14];let C;t[15]!==l||t[16]!==i||t[17]!==h||t[18]!==g||t[19]!==b||t[20]!==n?(C=(0,Z.jsx)(ne,{asChild:!0,children:(0,Z.jsxs)(Y,{id:n,type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":i,"aria-haspopup":`listbox`,"aria-controls":h,"aria-labelledby":g,disabled:l,className:`w-full justify-between font-normal`,children:[b,x]})}),t[15]=l,t[16]=i,t[17]=h,t[18]=g,t[19]=b,t[20]=n,t[21]=C):C=t[21];let w;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(Lt,{placeholder:`Search templates`}),t[22]=w):w=t[22];let T;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(z,{children:`No templates found.`}),t[23]=T):T=t[23];let E;t[24]!==a||t[25]!==s?(E=()=>{s(Fp),a(!1)},t[24]=a,t[25]=s,t[26]=E):E=t[26];let D=o===Fp?`opacity-100`:`opacity-0`,O;t[27]===D?O=t[28]:(O=mi(`mt-1 size-4 shrink-0`,D),t[27]=D,t[28]=O);let k;t[29]===O?k=t[30]:(k=(0,Z.jsx)(go,{className:O,"aria-hidden":`true`}),t[29]=O,t[30]=k);let A;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:`Blank note`}),(0,Z.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:`Empty starting content`})]}),t[31]=A):A=t[31];let j;t[32]!==E||t[33]!==k?(j=(0,Z.jsxs)(f,{value:`Blank note empty`,onSelect:E,className:`items-start gap-3`,children:[k,A]}),t[32]=E,t[33]=k,t[34]=j):j=t[34];let M;if(t[35]!==a||t[36]!==s||t[37]!==c||t[38]!==o){let e;t[40]!==a||t[41]!==s||t[42]!==o?(e=e=>{let t=e.title??e.name,n=e.title&&e.title!==e.name?e.name:void 0,r=`${e.scope}:${e.source_folder}:${e.name}`;return(0,Z.jsxs)(f,{value:r,keywords:[t,e.name,e.description??``,e.scope,e.source_folder??``],onSelect:()=>{s(e.name),a(!1)},className:`items-start gap-3`,children:[(0,Z.jsx)(go,{className:mi(`mt-1 size-4 shrink-0`,o===e.name?`opacity-100`:`opacity-0`),"aria-hidden":`true`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium`,children:t}),n?(0,Z.jsx)(`code`,{className:`font-mono text-2xs text-muted-foreground shrink-0`,children:n}):null,(0,Z.jsx)(Yp,{entry:e,className:`ml-auto`})]}),e.description?(0,Z.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:e.description}):null]})]},r)},t[40]=a,t[41]=s,t[42]=o,t[43]=e):e=t[43],M=c.map(e),t[35]=a,t[36]=s,t[37]=c,t[38]=o,t[39]=M}else M=t[39];let N;t[44]!==u||t[45]!==j||t[46]!==M?(N=(0,Z.jsx)(G,{className:`w-[var(--radix-popover-trigger-width)] p-0`,align:`start`,onOpenAutoFocus:Jp,onWheel:qp,onTouchMove:Kp,children:(0,Z.jsxs)(S,{children:[w,(0,Z.jsxs)(ge,{id:u,className:`subtle-scrollbar`,children:[T,j,M]})]})}),t[44]=u,t[45]=j,t[46]=M,t[47]=N):N=t[47];let P;return t[48]!==a||t[49]!==i||t[50]!==N||t[51]!==C?(P=(0,Z.jsxs)(H,{open:i,onOpenChange:a,children:[C,N]}),t[48]=a,t[49]=i,t[50]=N,t[51]=C,t[52]=P):P=t[52],P}function Kp(e){e.stopPropagation()}function qp(e){e.stopPropagation()}function Jp(e){e.preventDefault(),e.currentTarget.querySelector(`[cmdk-input]`)?.focus()}function Yp(e){let t=(0,$.c)(5),{entry:n,className:r}=e;if(n.scope===`inherited`){let e;t[0]===r?e=t[1]:(e=mi(`shrink-0 text-2xs`,r),t[0]=r,t[1]=e);let i=n.source_folder||`root`,a;return t[2]!==e||t[3]!==i?(a=(0,Z.jsx)(Ge,{variant:`gray`,className:e,children:i}),t[2]=e,t[3]=i,t[4]=a):a=t[4],a}return null}function Xp(e){return e.split(`/`).pop()??e}function Zp(e,t){let n=new Map;for(let e of t?.folders??[])n.set(e.path,e.summary);let r=e.created.filter(e=>e.kind===`folder`).map(e=>({kind:`folder`,name:`${e.path}/`,description:n.get(Xp(e.path))??``})),i=e.created.filter(e=>e.kind===`file`).map(e=>({kind:`file`,name:e.path,description:Xp(e.path)===`log.md`?`Append-only timeline`:``}));return[...r,...i]}function Qp(e){let t=(0,$.c)(20),{plan:n,selectedPack:r}=e,i,a,o,s,c,l;if(t[0]!==n||t[1]!==r){let e=[...Zp(n,r)].sort(tm),u=new Set(e.map(em));c=`space-y-2`,t[8]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase font-mono tracking-wider text-primary`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`flex items-center justify-center`,children:`◇`}),`What gets created`]}),t[8]=l):l=t[8],s=`overflow-hidden rounded-md border border-border/60 bg-muted/20`,i=`Items to be created`,a=`py-1.5`,o=e.map(e=>{let t=e.name.replace(/\/$/,``).split(`/`),n=0,r=0;for(let e=1;e<t.length;e++){let i=t.slice(0,e).join(`/`);u.has(i)&&(n++,r=e)}let i=t.slice(r).join(`/`)+(e.kind===`folder`?`/`:``),a=e.kind===`folder`;return(0,Z.jsxs)(`li`,{className:`relative flex min-w-0 items-center gap-1.5 py-1 pr-3`,style:{paddingLeft:`${12+n*16}px`},children:[Array.from({length:n},$p),a?(0,Z.jsx)(dc,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`,strokeWidth:1.5}):(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Z.jsx)(`code`,{className:`font-mono text-1sm shrink-0 text-foreground/80`,children:i}),a&&e.description?(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{"aria-label":`Show description`,className:`flex shrink-0 cursor-help rounded outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,children:(0,Z.jsx)(Xe,{"aria-hidden":`true`,className:`size-3 text-muted-foreground/60`,strokeWidth:1.5})}),(0,Z.jsx)(vn,{children:e.description})]}):null]},e.name)}),t[0]=n,t[1]=r,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];let u;t[9]!==i||t[10]!==a||t[11]!==o?(u=(0,Z.jsx)(`ul`,{"aria-label":i,className:a,children:o}),t[9]=i,t[10]=a,t[11]=o,t[12]=u):u=t[12];let d;t[13]!==s||t[14]!==u?(d=(0,Z.jsx)(`div`,{className:s,children:u}),t[13]=s,t[14]=u,t[15]=d):d=t[15];let f;return t[16]!==c||t[17]!==l||t[18]!==d?(f=(0,Z.jsxs)(`section`,{className:c,children:[l,d]}),t[16]=c,t[17]=l,t[18]=d,t[19]=f):f=t[19],f}function $p(e,t){return(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`absolute top-0 bottom-0 w-px bg-border/50`,style:{left:`${12+t*16+8}px`}},`guide:${t}`)}function em(e){return e.name.replace(/\/$/,``)}function tm(e,t){return e.name.localeCompare(t.name)}async function nm(e){let t=await e.json().catch(()=>null),n=fi.safeParse(t);if(!n.success)return{kind:`internal`,message:`HTTP ${e.status}`};let r=n.data.detail??n.data.title,i=n.data.type;return i===`urn:ok:error:seed-prerequisite-missing`?{kind:`prerequisite-missing`,message:r}:i===`urn:ok:error:seed-invalid-root`?{kind:`invalid-root`,message:r}:i===`urn:ok:error:no-project-dir`?{kind:`no-project`,message:r}:{kind:`internal`,message:r}}function rm(){let e=typeof window<`u`?window.okDesktop:void 0;return e?.seed?{plan:e.seed.plan,apply:e.seed.apply,listPacks:e.seed.listPacks}:{plan:async e=>{let t=new URLSearchParams;e?.rootDir&&t.set(`rootDir`,e.rootDir),e?.packId&&t.set(`packId`,e.packId);let n=t.toString(),r=await fetch(`/api/seed/plan${n?`?${n}`:``}`);if(!r.ok)return{ok:!1,error:await nm(r)};let i=await r.json().catch(()=>null);return i?.plan?{ok:!0,plan:i.plan}:{ok:!1,error:{kind:`internal`,message:`Malformed plan response`}}},apply:async(e,t)=>{let n=await fetch(`/api/seed/apply`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({plan:e,packId:t?.packId})});if(!n.ok)return{ok:!1,error:await nm(n)};let r=await n.json().catch(()=>null);return r?.result?{ok:!0,result:r.result}:{ok:!1,error:{kind:`internal`,message:`Malformed apply response`}}},listPacks:async()=>{let e=await fetch(`/api/seed/packs`);if(!e.ok)return{ok:!1,error:{kind:`internal`,message:`HTTP ${e.status}`}};let t=await e.json().catch(()=>null);return!t||!Array.isArray(t.packs)?{ok:!1,error:{kind:`internal`,message:`Malformed listPacks response`}}:{ok:!0,packs:t.packs}}}}var im={"knowledge-base":_c,"software-lifecycle":k,"plain-notes":Kc,worldbuilding:ec,"writing-pipeline":kc,gbrain:Cc};function am(e){return im[e]??_c}function om(e){let t=(0,$.c)(28),{onPackSelect:n,className:r,packs:i}=e,[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(null),l=i===void 0,u,d;t[0]===l?(u=t[1],d=t[2]):(u=()=>{if(!l)return;let e=!1;return(async()=>{try{let t=await rm().listPacks();if(e)return;t.ok?o(t.packs):c(t.error.message)}catch(t){let n=t;if(e)return;c(n instanceof Error?n.message:String(n))}})(),()=>{e=!0}},d=[l],t[0]=l,t[1]=u,t[2]=d),(0,Q.useEffect)(u,d);let f=l?a:i;if(s!==null){let e;t[3]===r?e=t[4]:(e=mi(`rounded-md bg-destructive/10 p-4 text-sm text-destructive`,r),t[3]=r,t[4]=e);let n;return t[5]!==s||t[6]!==e?(n=(0,Z.jsxs)(`div`,{role:`alert`,className:e,children:[`Couldn't load starter packs: `,s]}),t[5]=s,t[6]=e,t[7]=n):n=t[7],n}if(f===null){let e;t[8]===r?e=t[9]:(e=mi(`grid w-full max-w-5xl gap-4 sm:grid-cols-2 lg:grid-cols-3`,r),t[8]=r,t[9]=e);let n;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(n=Array.from({length:6},cm).map(sm),t[10]=n):n=t[10];let i;return t[11]!==e||t[12]!==n?(i=(0,Z.jsx)(`div`,{role:`status`,className:e,"aria-busy":`true`,"aria-label":`Loading starter packs`,children:n}),t[11]=e,t[12]=n,t[13]=i):i=t[13],i}if(f.length===0){let e;t[14]===r?e=t[15]:(e=mi(`flex w-full max-w-5xl items-center justify-center rounded-2xl border border-dashed border-border/60 bg-muted/20 p-8 text-sm text-muted-foreground`,r),t[14]=r,t[15]=e);let n;return t[16]===e?n=t[17]:(n=(0,Z.jsx)(`div`,{role:`status`,className:e,children:`No starter packs available.`}),t[16]=e,t[17]=n),n}let p;t[18]===r?p=t[19]:(p=mi(`grid w-full max-w-5xl gap-4 sm:grid-cols-2 lg:grid-cols-3`,r),t[18]=r,t[19]=p);let m;if(t[20]!==n||t[21]!==f){let e;t[23]===n?e=t[24]:(e=e=>(0,Z.jsx)(lm,{pack:e,onSelect:()=>n(e.id)},e.id),t[23]=n,t[24]=e),m=f.map(e),t[20]=n,t[21]=f,t[22]=m}else m=t[22];let h;return t[25]!==p||t[26]!==m?(h=(0,Z.jsx)(`div`,{className:p,children:m}),t[25]=p,t[26]=m,t[27]=h):h=t[27],h}function sm(e){return(0,Z.jsx)(dm,{},`skeleton-${e}`)}function cm(e,t){return t}function lm(e){let t=(0,$.c)(23),{pack:n,onSelect:r}=e,i;t[0]===n.id?i=t[1]:(i=am(n.id),t[0]=n.id,t[1]=i);let a=i,{files:o,folders:s}=n.entryCounts,c;t[2]===a?c=t[3]:(c=(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`flex size-8 items-center justify-center rounded-lg bg-primary/5 text-primary`,children:(0,Z.jsx)(a,{className:`size-4`})}),t[2]=a,t[3]=c);let l;t[4]===n.name?l=t[5]:(l=(0,Z.jsx)(`h3`,{className:`text-sm font-medium leading-tight`,children:n.name}),t[4]=n.name,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center gap-2`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]===n.description?d=t[10]:(d=(0,Z.jsx)(`p`,{className:`text-1sm leading-relaxed text-muted-foreground`,children:n.description}),t[9]=n.description,t[10]=d);let f;t[11]!==u||t[12]!==d?(f=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[u,d]}),t[11]=u,t[12]=d,t[13]=f):f=t[13];let p;t[14]!==o||t[15]!==s?(p=um({files:o,folders:s}),t[14]=o,t[15]=s,t[16]=p):p=t[16];let m;t[17]===p?m=t[18]:(m=(0,Z.jsx)(`p`,{className:`mt-auto pt-2 font-mono text-2xs uppercase tracking-wider text-muted-foreground`,children:p}),t[17]=p,t[18]=m);let h;return t[19]!==r||t[20]!==f||t[21]!==m?(h=(0,Z.jsxs)(`button`,{type:`button`,onClick:r,className:`group flex h-full flex-col items-start gap-4 rounded-2xl border border-border/60 bg-card p-5 text-left transition-[border-color,box-shadow,transform] hover:border-border hover:shadow-sm focus-visible:border-ring focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 active:translate-y-px`,children:[f,m]}),t[19]=r,t[20]=f,t[21]=m,t[22]=h):h=t[22],h}function um({files:e,folders:t}){let n=e>0?`${e} ${e===1?`file`:`files`}`:null,r=`${t} ${t===1?`folder`:`folders`}`;return n?`${n} · ${r}`:r}function dm(){let e=(0,$.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`span`,{className:`size-10 animate-pulse rounded-lg bg-muted`,"aria-hidden":`true`,children:(0,Z.jsx)(ue,{className:`size-5 animate-spin text-muted-foreground opacity-0`})}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsxs)(`div`,{className:`flex h-full min-h-[200px] flex-col items-start gap-4 rounded-xl border border-border/60 bg-card p-6`,children:[t,(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,children:[(0,Z.jsx)(`div`,{className:`h-4 w-1/2 animate-pulse rounded bg-muted`}),(0,Z.jsx)(`div`,{className:`h-3 w-full animate-pulse rounded bg-muted`}),(0,Z.jsx)(`div`,{className:`h-3 w-4/5 animate-pulse rounded bg-muted`})]}),(0,Z.jsx)(`div`,{className:`mt-auto h-3 w-20 animate-pulse rounded bg-muted`})]}),e[1]=n):n=e[1],n}function fm(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=mi(`grid w-full gap-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Lu,{"data-slot":`radio-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function pm(e){let t=(0,$.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=mi(`group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border border-input outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary`,n),t[3]=n,t[4]=i);let a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(zu,{"data-slot":`radio-group-indicator`,className:`flex size-4 items-center justify-center`,children:(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary-foreground`})}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,Z.jsx)(Ru,{"data-slot":`radio-group-item`,className:i,...r,children:a}),t[6]=r,t[7]=i,t[8]=o):o=t[8],o}var mm=`knowledge-base`;function hm(e){let t=(0,$.c)(74),{open:n,onOpenChange:r,onSeedApplied:i,initialPackId:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={kind:`loading`},t[0]=o):o=t[0];let[s,c]=(0,Q.useState)(o),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(a??mm),[p,m]=(0,Q.useState)(`project-root`),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(a===void 0?`pick`:`configure`),y=(0,Q.useRef)(!0),b;t[1]!==l||t[2]!==d?(b=l?.find(e=>e.id===d),t[1]=l,t[2]=d,t[3]=b):b=t[3];let x=b,S,C;t[4]!==n||t[5]!==l?(S=()=>{if(!n||l!==null)return;let e=!1;return(async()=>{try{let t=await rm().listPacks();if(e)return;t.ok?u(t.packs):(u([]),c({kind:`error`,message:t.error.message}))}catch(t){let n=t;if(e)return;u([]),c({kind:`error`,message:n instanceof Error?n.message:String(n)})}})(),()=>{e=!0}},C=[n,l],t[4]=n,t[5]=l,t[6]=S,t[7]=C):(S=t[6],C=t[7]),(0,Q.useEffect)(S,C);let w,T;t[8]!==a||t[9]!==n?(w=()=>{n&&(f(a??mm),m(`project-root`),g(``),v(a===void 0?`pick`:`configure`),c({kind:`loading`}),y.current=!0)},T=[n,a],t[8]=a,t[9]=n,t[10]=w,t[11]=T):(w=t[10],T=t[11]),(0,Q.useEffect)(w,T);let E,D;t[12]===x?(E=t[13],D=t[14]):(E=()=>{x&&g(x.defaultSubfolder??``)},D=[x],t[12]=x,t[13]=E,t[14]=D),(0,Q.useEffect)(E,D);let O;t[15]===h?O=t[16]:(O=h.trim(),t[15]=h,t[16]=O);let k=O,A=p===`subfolder`&&k===``,j,M;t[17]!==n||t[18]!==l||t[19]!==p||t[20]!==d||t[21]!==_||t[22]!==A||t[23]!==k?(j=()=>{if(!n||_!==`configure`||l===null)return;if(A){c({kind:`error`,message:`Enter a folder name (e.g. brain).`});return}let e=p===`project-root`?void 0:k,t=y.current?0:200;y.current=!1;let r=!1,i=setTimeout(()=>{r||(c(gm),rm().plan({rootDir:e,packId:d}).then(e=>{if(!r){if(!e.ok){c({kind:`error`,message:e.error.message});return}c(e.plan.created.length>0?{kind:`plan`,plan:e.plan}:{kind:`already-seeded`,plan:e.plan})}}).catch(e=>{r||c({kind:`error`,message:e instanceof Error?e.message:String(e)})}))},t);return()=>{r=!0,clearTimeout(i)}},M=[n,_,l,d,p,k,A],t[17]=n,t[18]=l,t[19]=p,t[20]=d,t[21]=_,t[22]=A,t[23]=k,t[24]=j,t[25]=M):(j=t[24],M=t[25]),(0,Q.useEffect)(j,M);let N;t[26]!==r||t[27]!==i||t[28]!==s.kind||t[29]!==s.plan||t[30]!==x?.name||t[31]!==d?(N=async function(){if(s.kind!==`plan`)return;let e=s.plan;c({kind:`applying`,plan:e});let t;try{t=await rm().apply(e,{packId:d})}catch(t){let n=t,r=n instanceof Error?n.message:String(n);X.error(`Initialize failed: ${r}`),c({kind:`plan`,plan:e});return}if(t.ok){let e=x?.name??`starter pack`,n=t.result.applied,a=n===0?`${e} was already set up. Nothing to do.`:`${e} initialized (${n} ${n===1?`entry`:`entries`})`;X.success(a),i?.(),r(!1)}else X.error(`Initialize failed: ${t.error.message}`),c({kind:`plan`,plan:e})},t[26]=r,t[27]=i,t[28]=s.kind,t[29]=s.plan,t[30]=x?.name,t[31]=d,t[32]=N):N=t[32];let P=N,F=a!==void 0,I=_===`configure`&&x?`Initialize ${x.name}`:`Initialize a starter pack`,L=_===`configure`&&x?x.description:`Pick a layout that matches what you're building. Each pack ships with folders, templates, and agent-readable descriptions. You can mix and match later.`,R;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(R=function(e){f(e),v(`configure`),y.current=!0},t[33]=R):R=t[33];let z=R,B;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(B=function(){v(`pick`),c({kind:`loading`}),y.current=!0},t[34]=B):B=t[34];let V=B,H;t[35]===I?H=t[36]:(H=(0,Z.jsx)(bo,{children:I}),t[35]=I,t[36]=H);let U;t[37]===L?U=t[38]:(U=(0,Z.jsx)(vo,{children:L}),t[37]=L,t[38]=U);let W;t[39]!==H||t[40]!==U?(W=(0,Z.jsxs)(Ao,{children:[H,U]}),t[39]=H,t[40]=U,t[41]=W):W=t[41];let G;t[42]!==l||t[43]!==s||t[44]!==p||t[45]!==x||t[46]!==_||t[47]!==h?(G=_===`pick`?(0,Z.jsx)(Do,{children:(0,Z.jsx)(om,{packs:l,onPackSelect:z})}):(0,Z.jsxs)(Do,{className:`space-y-6`,children:[(0,Z.jsx)(_m,{choice:p,subfolder:h,placeholder:x?.defaultSubfolder??`subfolder`,onChoiceChange:m,onSubfolderChange:g}),(0,Z.jsx)(vm,{phase:s,selectedPack:x})]}),t[42]=l,t[43]=s,t[44]=p,t[45]=x,t[46]=_,t[47]=h,t[48]=G):G=t[48];let K;t[49]!==F||t[50]!==_?(K=_===`configure`&&!F?(0,Z.jsxs)(Y,{className:`mr-auto uppercase font-mono`,variant:`ghost`,onClick:V,children:[(0,Z.jsx)(Mi,{"aria-hidden":`true`,className:`h-4 w-4`}),`Back`]}):null,t[49]=F,t[50]=_,t[51]=K):K=t[51];let q;t[52]===r?q=t[53]:(q=()=>r(!1),t[52]=r,t[53]=q);let ee=s.kind===`already-seeded`||s.kind===`error`?`Close`:`Cancel`,te;t[54]!==q||t[55]!==ee?(te=(0,Z.jsx)(Y,{className:`uppercase font-mono`,variant:`ghost`,onClick:q,children:ee}),t[54]=q,t[55]=ee,t[56]=te):te=t[56];let ne;t[57]!==P||t[58]!==s.kind||t[59]!==_||t[60]!==A?(ne=_===`configure`&&s.kind===`plan`?(0,Z.jsx)(Y,{onClick:P,disabled:A,children:`Initialize`}):_===`configure`&&s.kind===`applying`?(0,Z.jsxs)(Y,{disabled:!0,children:[(0,Z.jsx)(ue,{"aria-hidden":`true`,className:`h-4 w-4 animate-spin`}),`Setting up`]}):null,t[57]=P,t[58]=s.kind,t[59]=_,t[60]=A,t[61]=ne):ne=t[61];let re;t[62]!==K||t[63]!==te||t[64]!==ne?(re=(0,Z.jsxs)(Oo,{children:[K,te,ne]}),t[62]=K,t[63]=te,t[64]=ne,t[65]=re):re=t[65];let ie;t[66]!==W||t[67]!==G||t[68]!==re?(ie=(0,Z.jsxs)(wo,{className:`sm:max-w-3xl`,"data-ok-layer-spawned":``,children:[W,G,re]}),t[66]=W,t[67]=G,t[68]=re,t[69]=ie):ie=t[69];let ae;return t[70]!==r||t[71]!==n||t[72]!==ie?(ae=(0,Z.jsx)(jo,{open:n,onOpenChange:r,children:ie}),t[70]=r,t[71]=n,t[72]=ie,t[73]=ae):ae=t[73],ae}function gm(e){return e.kind===`plan`||e.kind===`already-seeded`?e:{kind:`loading`}}function _m(e){let t=(0,$.c)(20),{choice:n,subfolder:r,placeholder:i,onChoiceChange:a,onSubfolderChange:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:`Where should it live?`}),t[0]=s):s=t[0];let c;t[1]===a?c=t[2]:(c=e=>a(e),t[1]=a,t[2]=c);let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(ka,{htmlFor:`seed-root-project-root`,children:(0,Z.jsxs)(Ea,{orientation:`horizontal`,children:[(0,Z.jsxs)(qa,{children:[(0,Z.jsx)(Ha,{children:`Project root`}),(0,Z.jsx)($a,{className:`text-1sm`,children:`Scaffold directly under this project.`})]}),(0,Z.jsx)(pm,{value:`project-root`,id:`seed-root-project-root`})]})}),t[3]=l):l=t[3];let u,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(Ha,{children:`In a subfolder`}),d=(0,Z.jsx)($a,{className:`nth-last-2:mt-0 text-1sm`,children:`Created if missing; reused if it exists.`}),t[4]=u,t[5]=d):(u=t[4],d=t[5]);let f;t[6]!==n||t[7]!==o||t[8]!==i||t[9]!==r?(f=n===`subfolder`&&(0,Z.jsx)(Po,{value:r,onChange:e=>o(e.target.value),placeholder:i,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,className:`mt-1.5 font-mono text-xs bg-background`}),t[6]=n,t[7]=o,t[8]=i,t[9]=r,t[10]=f):f=t[10];let p;t[11]===f?p=t[12]:(p=(0,Z.jsxs)(qa,{children:[u,d,f]}),t[11]=f,t[12]=p);let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(pm,{value:`subfolder`,id:`seed-root-subfolder`}),t[13]=m):m=t[13];let h;t[14]===p?h=t[15]:(h=(0,Z.jsx)(ka,{htmlFor:`seed-root-subfolder`,children:(0,Z.jsxs)(Ea,{orientation:`horizontal`,children:[p,m]})}),t[14]=p,t[15]=h);let g;return t[16]!==n||t[17]!==c||t[18]!==h?(g=(0,Z.jsxs)(`div`,{className:`space-y-2 py-1`,children:[s,(0,Z.jsxs)(fm,{className:`sm:flex`,value:n,onValueChange:c,children:[l,h]})]}),t[16]=n,t[17]=c,t[18]=h,t[19]=g):g=t[19],g}function vm(e){let t=(0,$.c)(12),{phase:n,selectedPack:r}=e;if(n.kind===`loading`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 py-4 text-sm text-muted-foreground`,children:[(0,Z.jsx)(ue,{"aria-hidden":`true`,className:`h-4 w-4 animate-spin`}),`Computing scaffold plan`]}),t[0]=e):e=t[0],e}if(n.kind===`error`){let e;return t[1]===n.message?e=t[2]:(e=(0,Z.jsx)(`div`,{className:`rounded-md bg-destructive/10 p-3 text-sm text-destructive`,children:n.message}),t[1]=n.message,t[2]=e),e}if(n.kind===`already-seeded`){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`div`,{className:`py-2 text-sm`,children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:`This pack is already set up here.`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:`The folders and templates are in place; there's nothing left to scaffold.`})]}),t[3]=e):e=t[3],e}let i;t[4]!==n.plan||t[5]!==r?(i=(0,Z.jsx)(Qp,{plan:n.plan,selectedPack:r}),t[4]=n.plan,t[5]=r,t[6]=i):i=t[6];let a;t[7]===n.plan.warnings?a=t[8]:(a=n.plan.warnings.length>0?(0,Z.jsx)(`div`,{className:`rounded-md bg-warning/10 p-3 text-xs text-warning-foreground`,children:n.plan.warnings.map(ym)}):null,t[7]=n.plan.warnings,t[8]=a);let o;return t[9]!==i||t[10]!==a?(o=(0,Z.jsxs)(`div`,{className:`space-y-6 py-1 text-sm`,children:[i,a]}),t[9]=i,t[10]=a,t[11]=o):o=t[11],o}function ym(e){return(0,Z.jsx)(`p`,{children:e},e)}var bm=[{id:`claude-cowork`,displayName:`Claude Cowork`,appBrandName:`Claude Desktop`,schemes:[`claude:`],installUrl:`https://claude.com/download`,hasWebFallback:!0,tagline:`Conversational pairing in Claude Desktop's Cowork tab.`},{id:`claude-code`,displayName:`Claude`,appBrandName:`Claude Desktop`,schemes:[`claude:`],installUrl:`https://claude.com/download`,hasWebFallback:!0,tagline:`Agentic coding in Claude Desktop's Code tab.`},{id:`codex`,displayName:`Codex`,appBrandName:`Codex Desktop`,schemes:[`codex:`],installUrl:`https://openai.com/codex`,tagline:`OpenAI's coding agent, terminal-native.`},{id:`cursor`,displayName:`Cursor`,schemes:[`cursor:`],installUrl:`https://cursor.com/`,tagline:`AI-first VS Code fork with multi-file edits.`}],xm=bm.filter(e=>e.id!==`claude-cowork`),Sm=`#settings`;function Cm(e){let t=e.target;return t?.tagName===`INPUT`||t?.tagName===`TEXTAREA`||t?.isContentEditable?!1:!!((e.metaKey||e.ctrlKey)&&!e.altKey&&e.key===`,`)}function wm(e){return e.replace(/^#/,``)===`settings`}function Tm(){return typeof window>`u`?``:window.location.hash}function Em(){let e=(0,$.c)(4),[t,n]=(0,Q.useState)(Om),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=()=>{(0,Q.startTransition)(()=>{n(wm(Tm()))})};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Q.useEffect)(r,i);let a=Dm,o;return e[2]===t?o=e[3]:(o={open:t,close:a},e[2]=t,e[3]=o),o}function Dm(){typeof window>`u`||wm(Tm())&&window.history.back()}function Om(){return wm(Tm())}function km(){let e=(0,$.c)(3),[t,n]=(0,Q.useState)(Mm),r,i;return e[0]===t?(r=e[1],i=e[2]):(r=()=>{if(t!==null||window.okDesktop)return;let e=!0;return fetch(`/api/workspace`).then(async t=>{let r=await t.json().catch(jm);if(!e||!t.ok)return;let i=Kr.safeParse(r);i.success&&n({contentDir:i.data.contentDir,pathSeparator:i.data.pathSeparator})}).catch(Am),()=>{e=!1}},i=[t],e[0]=t,e[1]=r,e[2]=i),(0,Q.useEffect)(r,i),t}function Am(e){console.warn(`[useWorkspace] /api/workspace fetch failed:`,e)}function jm(){return null}function Mm(){return Nm()}function Nm(e=typeof window>`u`?void 0:window){if(!e)return null;let t=e.okDesktop;return t?{contentDir:t.config.projectPath,pathSeparator:t.platform===`win32`?`\\`:`/`}:null}function Pm(e){return{async install(t){let n;try{n=await e.buildAndOpen(t?.force?{force:!0}:void 0)}catch(e){return{ok:!1,reason:`bridge-error`,message:e instanceof Error?e.message:String(e)}}return n.ok?{ok:!0,path:n.path}:{ok:!1,reason:n.reason,message:n.message}}}}function Fm(e={}){let t=e.fetch??globalThis.fetch,n=`${e.apiOrigin??``}/api/install-skill`;return{async install(e){let r;try{r=await t(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?.force?{force:!0}:{})})}catch(e){return{ok:!1,reason:`network-error`,message:e instanceof Error?e.message:String(e)}}if(!r.ok){let e=`HTTP ${r.status}`;try{let t=Gn(await r.json());t&&(e=t)}catch{}return{ok:!1,reason:`http-error`,message:e}}let i;try{i=await r.json()}catch(e){return{ok:!1,reason:`parse-error`,message:e instanceof Error?e.message:`Invalid server response`}}return!i||typeof i.status!=`string`?{ok:!1,reason:`parse-error`,message:`Invalid server response shape`}:i.status===`failed`?{ok:!1,reason:`build-failed`,message:i.buildError??`unknown build failure`}:{ok:!0,path:i.outputPath,handoffWarning:i.handoffError?.message}}}}function Im(){if(typeof window>`u`)return null;let e=window.okDesktop?.skill;return e?Pm(e):Fm()}var Lm=`ok:skill:cowork:installed`,Rm=`1`,zm=250,Bm=`/api/skill/install-state`;function Vm(e){return`${Lm}:v${e}`}var Hm=new Map;async function Um(e={},t={}){let n=t.force?`__force__`:`__default__`,r=Hm.get(n);if(r)return r;let i=Wm(e,t);return Hm.set(n,i),i.finally(()=>{Hm.get(n)===i&&Hm.delete(n)}),i}async function Wm(e,t){let n=e.installer===void 0?Im():e.installer,r=Gm(e.storage),i=e.fetchSnapshot??qm,a=e.serverTimeoutMs??zm,o=null;if(!t.force){try{o=await Jm(i(),a)}catch(e){console.warn(`[cowork-skill] server install-state check failed; falling through:`,e)}if(o){let e=o.targets[`claude-cowork`]??null;if(e&&e.version===o.currentVersion)return{kind:`already-installed`,source:`server`}}}let s=Vm(o?.currentVersion??e.fallbackSkillVersion??Km());if(!t.force&&r?.getItem(s)===Rm)return{kind:`already-installed`,source:`local`};if(!n)return{kind:`host-unsupported`};let c=await n.install({force:t.force??!1});if(!c.ok)return{kind:`install-failed`,reason:c.reason,message:c.message};try{r?.setItem(s,Rm)}catch(e){console.warn(`[cowork-skill] storage.setItem failed (guard will not persist):`,e)}return{kind:`installed-now`,path:c.path,handoffWarning:c.handoffWarning}}function Gm(e){if(e!==void 0)return e;if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function Km(){return typeof window>`u`?`unknown`:window.okDesktop?.appVersion??`unknown`}async function qm(){let e;try{e=await fetch(Bm,{method:`GET`,cache:`no-store`})}catch{return null}if(!e.ok)return null;try{let t=await e.json();return typeof t?.currentVersion==`string`?t:null}catch{return null}}async function Jm(e,t){return Promise.race([e,new Promise(e=>{setTimeout(()=>e(null),t)})])}function Ym(e){return Um({},e)}function Xm(){return Um({},{force:!0})}async function Zm(e,t){let n;try{n=await t(`/api/handoff`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})}catch(e){return{ok:!1,reason:`dispatch-error`,detail:e instanceof Error?e.message:String(e)}}return n.status===200?{ok:!0}:n.status===404?{ok:!1,reason:`not-installed`,detail:`POST /api/handoff returned 404`}:n.status===422?{ok:!1,reason:`not-installed`,detail:`POST /api/handoff returned ${n.status}`}:{ok:!1,reason:`dispatch-error`,detail:`POST /api/handoff returned ${n.status}`}}async function Qm(e,t={}){let n=t.fetch??globalThis.fetch.bind(globalThis);switch(e.target){case`claude-cowork`:return Zm({target:`claude-cowork`,url:Nr({mode:`cowork`},e)},n);case`claude-code`:return Zm({target:`claude-code`,url:Nr({mode:`code`},e)},n);case`codex`:return Zm({target:`codex`,url:Zr(e)},n);case`cursor`:return Zm({target:`cursor`,url:mr(e),workspacePath:e.projectDir},n);default:{let t=e.target;return{ok:!1,reason:`invalid-payload`,detail:`unknown target: ${String(t)}`}}}}async function $m(e,t={}){let n=t.okDesktop??(typeof window<`u`?window.okDesktop:void 0);if(n?.shell?.openExternal)try{return await n.shell.openExternal(e),{ok:!0}}catch(e){return{ok:!1,reason:`dispatch-error`,detail:eh(e)}}let r=t.doc??(typeof document<`u`?document:void 0);if(!r)return{ok:!1,reason:`dispatch-error`,detail:`no DOM available`};try{let t=r.createElement(`a`);return t.href=e,t.rel=`noopener noreferrer`,/^https?:/i.test(e)&&(t.target=`_blank`),r.body.appendChild(t),t.click(),t.remove(),{ok:!0}}catch(e){return{ok:!1,reason:`dispatch-error`,detail:eh(e)}}}function eh(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}async function th(e,t={}){let n=t.okDesktop??(typeof window<`u`?window.okDesktop:void 0);if(n?.shell?.recordHandoff)try{await n.shell.recordHandoff(e)}catch(e){(t.warn??(e=>console.warn(e)))(`[handoff] recordHandoff IPC rejected (telemetry skipped): ${e instanceof Error?e.message:String(e)}`)}}function nh(e,t,n){let r=n===`\\`?t.replaceAll(`/`,`\\`):t;return`${e.endsWith(n)?e.slice(0,-1):e}${n}${r}`}function rh(e){return`${e}.md`}function ih(e){if(!e.docName||!e.workspace)return null;let t=rh(e.docName),{contentDir:n,pathSeparator:r}=e.workspace;return{docContext:{relativePath:t},projectDir:n,docPath:nh(n,t,r)}}function ah(e){return e.workspace?.contentDir?{docContext:null,projectDir:e.workspace.contentDir,docPath:``}:null}function oh(e){return!e.workspace?.contentDir||!e.folderAbsPath||!e.folderRelativePath?null:{docContext:null,folderRelativePath:e.folderRelativePath,projectDir:e.folderAbsPath,docPath:``}}function sh(e){return $m(e.installUrl).then(()=>void 0)}function ch(e){return`Opened in ${e}.`}function lh(e,t=1){return t>=3?`Couldn't reach ${e} — please try again later.`:t===2?`Still couldn't reach ${e} — try one more time?`:`Couldn't reach ${e} — try again?`}function uh(e){return e>=3?null:e===2?`Try one more time`:`Retry`}function dh(e,t,n,r){return t.ok?{target:e,host:n,outcome:`ok`,ts:r}:{target:e,host:n,outcome:`error`,ts:r,reason:t.reason}}function fh(e){return e.docContext===null?e.folderRelativePath?si(e.folderRelativePath):ar():$r(e.docContext.relativePath)}async function ph(e,t,n,r=1){if(e===`claude-cowork`&&r===1){let e;try{e=await n.ensureCoworkSkillInstalled()}catch(e){let t=e instanceof Error?e.message:String(e);return n.toast.error(`Couldn't install Open Knowledge skill — ${t}`),{ok:!1,reason:`dispatch-error`,detail:`install-error: ${t}`}}if(e.kind===`installed-now`)return n.toast.success(`Open Knowledge skill saved. Upload it in Claude Desktop, then click Cowork again.`),{ok:!0};if(e.kind===`install-failed`){let t=e.message??e.reason;return n.toast.error(`Couldn't install Open Knowledge skill — ${t}`),{ok:!1,reason:`dispatch-error`,detail:`install-failed: ${t}`}}}let i={target:e,projectDir:t.projectDir,docPath:t.docPath,prompt:fh(t)},a=await n.dispatchHandoff(i),o=dh(e,a,n.isElectronHost()?`electron`:`web`,n.now().toISOString());await n.recordHandoff(o);let s=n.getDisplayName(e);if(a.ok)n.toast.success(ch(s));else{let i=uh(r),a=lh(s,r);i===null?n.toast.error(a):n.toast.error(a,{action:{label:i,onClick:()=>{ph(e,t,n,r+1)}}})}return a}function mh(e){return bm.find(t=>t.id===e)?.displayName??e}function hh(e=typeof window<`u`?window:void 0){return e?.okDesktop!=null}function gh(){return{dispatchHandoff:Qm,recordHandoff:th,toast:{success:e=>{X.success(e)},error:(e,t)=>{X.error(e,t?{action:t.action}:void 0)}},now:()=>new Date,isElectronHost:()=>hh(),getDisplayName:mh,ensureCoworkSkillInstalled:Ym}}function _h(){return{dispatch:(e,t)=>ph(e,t,gh()),reinstallCoworkSkill:Xm}}var vh=[...new Set(bm.flatMap(e=>e.schemes))];function yh(e,t){let n=t.now?.()??Date.now(),r={};for(let t of bm){let i=t.schemes[0],a=i===void 0?void 0:e[i];if(!a){r[t.id]={installed:null};continue}r[t.id]={installed:a.installed,...a.displayName===void 0?{}:{displayName:a.displayName},lastChecked:n}}return r}function bh(e){return yh({},e)}async function xh(e){let t=e.schemes??vh,n=await Promise.all(t.map(async t=>{let n=t.replace(/:$/,``);try{return[t,await e.detectProtocol(n)]}catch{return[t,{installed:!1}]}}));return Object.fromEntries(n)}var Sh=Object.fromEntries(vh.map(e=>[e,{installed:!1}]));async function Ch(e){let t;try{t=await e.fetch(`/api/installed-agents`,{signal:e.signal,headers:{Accept:`application/json`}})}catch(e){if(e.name===`AbortError`)throw e;return Sh}if(!t.ok)return Sh;let n;try{n=await t.json()}catch{return Sh}if(typeof n!=`object`||!n||Array.isArray(n))return Sh;let r=n,i={};for(let e of vh)i[e]={installed:r[e.replace(/:$/,``)]===!0};return i}function wh(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(!n||!i||n.installed!==i.installed||n.displayName!==i.displayName)return!1}return!0}function Th(e){let t=e.throttleMs??1e4,n=!1,r=null,i=null,a={},o=bh({isElectronHost:e.isElectronHost(),now:e.now}),s=new Set,c=()=>{if(!n)for(let e of s)e(o)},l=()=>{o=yh(a,{isElectronHost:e.isElectronHost(),now:e.now})};return{probe:async()=>{if(n)return;if(i)return i;if(r!==null&&e.now()-r<t)return;let o=(async()=>{try{let t=await e.probe();if(n)return;let i=!wh(a,t);a=t,i&&(l(),c()),r=e.now()}catch{}finally{i=null}})();return i=o,o},getTargetStates:()=>o,subscribe:e=>(s.add(e),()=>{s.delete(e)}),cancel:()=>{n=!0,s.clear()}}}function Eh(e=typeof window<`u`?window:void 0){return e?.okDesktop!=null}function Dh(){let e=typeof window<`u`?window.okDesktop:void 0;if(e){let t=t=>e.shell.detectProtocol(t);return{probe:()=>xh({detectProtocol:t}),isElectronHost:()=>!0,now:Date.now}}let t=globalThis.fetch.bind(globalThis);return{probe:()=>Ch({fetch:t}),isElectronHost:()=>!1,now:Date.now}}function Oh(){let e=(0,$.c)(5),[t,n]=(0,Q.useState)(kh),r=(0,Q.useRef)(null),i,a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{let e=Th(Dh());r.current=e;let t=e.subscribe(n);e.probe();let i=()=>{e.probe()};return window.addEventListener(`focus`,i),()=>{window.removeEventListener(`focus`,i),t(),e.cancel(),r.current=null}},a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),(0,Q.useEffect)(i,a);let o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>r.current?.probe()??Promise.resolve(),e[2]=o):o=e[2];let s;return e[3]===t?s=e[4]:(s={states:t,refresh:o},e[3]=t,e[4]=s),s}function kh(){return bh({isElectronHost:Eh(),now:Date.now})}var Ah=3e3,jh=(e,t,n)=>il(e,t,n,`CommandPalette`);function Mh(e){window.location.assign(Tr(e))}function Nh(e,t){return e?.kind===`folder`||e?.kind===`folder-index`?e.folderPath:sr(t)}function Ph(e){let t=(0,$.c)(23),{entry:n,query:r,onSelect:i}=e,a=r===void 0?``:r,o=n.kind===`folder`?R:It,s;t[0]===n?s=t[1]:(s=`title`in n&&n.title?n.title:n.path.split(`/`).pop()??n.path,t[0]=n,t[1]=s);let c=s,l=`snippet`in n?n.snippet:void 0,u=`${n.kind} ${n.path}`,d=`command-palette-nav-${n.kind}-${n.path}`,p;t[2]===o?p=t[3]:(p=(0,Z.jsx)(o,{className:`mt-0.5`}),t[2]=o,t[3]=p);let m;t[4]!==a||t[5]!==c?(m=(0,Z.jsx)(`span`,{className:`truncate font-medium`,children:(0,Z.jsx)(Fh,{query:a,text:c})}),t[4]=a,t[5]=c,t[6]=m):m=t[6];let h;t[7]!==n.path||t[8]!==a?(h=(0,Z.jsx)(`span`,{className:`truncate text-muted-foreground text-xs`,children:(0,Z.jsx)(Fh,{query:a,text:n.path})}),t[7]=n.path,t[8]=a,t[9]=h):h=t[9];let g;t[10]!==a||t[11]!==l?(g=l?(0,Z.jsx)(`span`,{className:`max-h-10 overflow-hidden text-muted-foreground text-xs leading-relaxed`,children:(0,Z.jsx)(Fh,{query:a,text:l})}):null,t[10]=a,t[11]=l,t[12]=g):g=t[12];let _;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[m,h,g]}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;return t[17]!==i||t[18]!==u||t[19]!==d||t[20]!==p||t[21]!==_?(v=(0,Z.jsxs)(f,{value:u,onSelect:i,"data-testid":d,className:`items-start`,children:[p,_]}),t[17]=i,t[18]=u,t[19]=d,t[20]=p,t[21]=_,t[22]=v):v=t[22],v}function Fh(e){let t=(0,$.c)(5),{text:n,query:r}=e,i;t[0]!==r||t[1]!==n?(i=vp(n,r).map(Ih),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,Z.jsx)(Z.Fragment,{children:i}),t[3]=i,t[4]=a),a}function Ih(e){let t=`${e.start}:${e.match?`match`:`plain`}`;return e.match?(0,Z.jsx)(`mark`,{className:`rounded-sm bg-primary/10 px-0.5 font-semibold text-primary`,children:e.text},t):(0,Z.jsx)(`span`,{children:e.text},t)}function Lh({searchResults:e,fallbackSearchResults:t,searchStatus:n}){return e.length>0?e:n===`success`?[]:t}function Rh(e){let t=(0,$.c)(136),{bridge:n,open:r,onOpenChange:i}=e,a=n===void 0?null:n,[o,s]=(0,Q.useState)(``),c=(0,Q.useDeferredValue)(o),l=c.trim(),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],t[0]=u):u=t[0];let[d,p]=(0,Q.useState)(u),[m,h]=(0,Q.useState)(`idle`),g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],t[1]=g):g=t[1];let[_,v]=(0,Q.useState)(g),y;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(y=[],t[2]=y):y=t[2];let[b,S]=(0,Q.useState)(y),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),O;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(O=[],t[3]=O):O=t[3];let[k,j]=(0,Q.useState)(O),[N,P]=(0,Q.useState)(`idle`),F;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(F=[],t[4]=F):F=t[4];let[I,L]=(0,Q.useState)(F),[B,V]=(0,Q.useState)(`idle`),H=(0,Q.useRef)(!1),U=(0,Q.useRef)(null),W=(0,Q.useRef)(null),{activeDocName:G,activeTarget:K}=ot(),{pages:q,pageTitles:ee,pageMeta:te,folderPaths:ne}=qr(),re=km(),{states:ie,refresh:ae}=Oh(),{dispatch:se}=_h(),ce=ih({docName:G,workspace:re}),le=dp(q,ne,ee,te),J=rp(b,new Set(le.map(Vh))),ue=a?.config.projectPath??null,de=a?_.filter(e=>e.path!==ue):[],fe;t[5]!==G||t[6]!==K?(fe=Nh(K,G),t[5]=G,t[6]=K,t[7]=fe):fe=t[7];let pe=fe,me=l===``?[]:gp(le,l,8),he,_e;t[8]!==i||t[9]!==r?(he=()=>{let e=function(e){e.key===`k`&&(Dn()?e.metaKey:e.ctrlKey)&&(e.preventDefault(),i(!r))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},_e=[i,r],t[8]=i,t[9]=r,t[10]=he,t[11]=_e):(he=t[10],_e=t[11]),(0,Q.useEffect)(he,_e);let ve,ye;t[12]!==a||t[13]!==r||t[14]!==ae?(ve=()=>{if(r){if(S(ep()),ae(),a){let e=!1;return jh(async()=>{let t=await a.project.listRecent();e||v(t)},`Failed to load recent projects.`),()=>{e=!0}}return}s(``),j([]),P(`idle`),H.current=!1,L([]),V(`idle`)},ye=[r,a,ae],t[12]=a,t[13]=r,t[14]=ae,t[15]=ve,t[16]=ye):(ve=t[15],ye=t[16]),(0,Q.useEffect)(ve,ye);let be;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(be=()=>{U.current&&(U.current.scrollTop=0)},t[17]=be):be=t[17];let xe;t[18]===o?xe=t[19]:(xe=[o],t[18]=o,t[19]=xe),(0,Q.useEffect)(be,xe);let Se=Cp(c,new Set(k.map(Bh))),Ce=Se.kind!==`normal`,we,Te;t[20]!==Ce||t[21]!==r?(we=()=>{if(!r||!Ce||H.current)return;H.current=!0,P(`loading`);let e=!1;return Tp().then(t=>{e||(j(t),P(`success`))}).catch(t=>{e||(console.error(`[command-palette-tag] fetch tags failed`,t),j([]),P(`error`))}),()=>{e=!0}},Te=[r,Ce],t[20]=Ce,t[21]=r,t[22]=we,t[23]=Te):(we=t[22],Te=t[23]),(0,Q.useEffect)(we,Te);let Ee=Se.kind===`tag-docs`?Se.tagName:null;(0,Q.useEffect)(()=>{if(!r||Ee===null){L([]),V(`idle`);return}V(`loading`),L([]);let e=!1;return Ep(Ee).then(t=>{e||(L(t),V(`success`))}).catch(t=>{e||(console.error(`[command-palette-tag] fetch tag docs failed`,t),L([]),V(`error`))}),()=>{e=!0}},[r,Ee]),(0,Q.useEffect)(()=>{if(!r||!l||Ce){p([]),h(`idle`);return}let e=new AbortController;h(`loading`);let t=!1,n=window.setTimeout(()=>{t=!0,e.abort(),p([]),h(`error`)},Ah);return bp(l,{signal:e.signal}).then(e=>{window.clearTimeout(n),p(e),h(`success`)}).catch(e=>{window.clearTimeout(n),!(e instanceof Error&&e.name===`AbortError`&&!t)&&(p([]),h(`error`))}),()=>{window.clearTimeout(n),e.abort()}},[r,l,Ce]);let De;t[24]===i?De=t[25]:(De=(e,t)=>{let n=t===void 0?`Command failed.`:t;i(!1),jh(async()=>{await e()},n)},t[24]=i,t[25]=De);let Oe=De,ke;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(ke=function(e){let t={kind:e.kind,path:e.path,lastOpenedAt:new Date().toISOString()},n=np(ep(),t);tp(n),S(n)},t[26]=ke):ke=t[26];let Ae=ke,je;t[27]===i?je=t[28]:(je=function(e){i(!1),Ae(e),Mh(e.path)},t[27]=i,t[28]=je);let Me=je,Ne=!Ce&&l===``&&J.length>0,Pe=Lh({searchResults:d,fallbackSearchResults:me,searchStatus:m}),Fe=!Ce&&Pe.length>0,Ie=!Ce&&l!==``&&m===`loading`&&!Fe,Le;t[29]!==c||t[30]!==Ce?(Le=!Ce&&xp(`New file`,c,[`create file`]),t[29]=c,t[30]=Ce,t[31]=Le):Le=t[31];let Re=Le,ze;t[32]!==c||t[33]!==Ce?(ze=!Ce&&xp(`New folder`,c,[`create folder`]),t[32]=c,t[33]=Ce,t[34]=ze):ze=t[34];let Be=ze,Ve;t[35]!==G||t[36]!==c||t[37]!==Ce?(Ve=!Ce&&G!==null&&xp(`Open graph`,c,[`graph panel network`]),t[35]=G,t[36]=c,t[37]=Ce,t[38]=Ve):Ve=t[38];let He=Ve,Ue;t[39]!==c||t[40]!==Ce?(Ue=!Ce&&xp(`Initialize starter pack`,c,[`scaffold`,`seed`,`pack`,`starter`]),t[39]=c,t[40]=Ce,t[41]=Ue):Ue=t[41];let We=Ue,Ge;t[42]!==a||t[43]!==c||t[44]!==Ce?(Ge=!Ce&&a!==null&&xp(`Open folder on disk`,c,[`project`]),t[42]=a,t[43]=c,t[44]=Ce,t[45]=Ge):Ge=t[45];let Ke=Ge,qe;t[46]!==a||t[47]!==c||t[48]!==Ce?(qe=!Ce&&a!==null&&xp(`Switch Project`,c,[`switch project navigator projects`]),t[46]=a,t[47]=c,t[48]=Ce,t[49]=qe):qe=t[49];let Je=qe,Ye;t[50]!==c||t[51]!==Ce?(Ye=!Ce&&xp(`Settings`,c,[`preferences config`]),t[50]=c,t[51]=Ce,t[52]=Ye):Ye=t[52];let Xe=Ye,Ze;t[53]!==c||t[54]!==Ce?(Ze=!Ce&&xp(`Install for Claude Chat & Cowork (Desktop App)`,c,[`claude desktop install cowork`]),t[53]=c,t[54]=Ce,t[55]=Ze):Ze=t[55];let Qe=Ze,$e=!Ce&&a!==null&&de.length>0&&(l===``||de.some(e=>xp(`${e.name} ${e.path}`,c,[`open recent project`]))),et=!Ce&&ce!==null&&(l===``||xm.some(e=>xp(`Open with AI ${e.displayName}`,c,[e.id,`agent handoff`,`open in`]))),tt=Se.kind===`tag-list`?wp(k,Se.query):[],nt=Se.kind===`tag-list`&&N!==`loading`&&tt.length===0,rt=Se.kind===`tag-docs`&&B===`success`&&I.length===0,it=Ce||Ne||Fe||Ie||Re||Be||He||We||Ke||Je||Xe||Qe||$e||et,at;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(at=function(e){s(`${Sp}${e}`)},t[56]=at):at=t[56];let st=at,ct=A,lt;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(lt={shouldFilter:!1,className:`[&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4`},t[57]=lt):lt=t[57];let ut;t[58]===o?ut=t[59]:(ut=(0,Z.jsx)(Lt,{ref:W,value:o,onValueChange:s,placeholder:`Search files, folders, or commands`}),t[58]=o,t[59]=ut);let dt;t[60]===Ce?dt=t[61]:(dt=()=>{s(Ce?``:Sp),W.current?.focus()},t[60]=Ce,t[61]=dt);let ft=Ce?`border-primary/30 bg-primary/10 text-primary`:`border-border bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground`,pt;t[62]===ft?pt=t[63]:(pt=mi(`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors`,ft),t[62]=ft,t[63]=pt);let mt,ht;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(mt=(0,Z.jsx)(x,{className:`size-3.5`}),ht=(0,Z.jsx)(`span`,{children:`By tag`}),t[64]=mt,t[65]=ht):(mt=t[64],ht=t[65]);let gt;t[66]!==Ce||t[67]!==dt||t[68]!==pt?(gt=(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5 border-b px-3 py-2`,children:(0,Z.jsxs)(`button`,{type:`button`,onClick:dt,"data-testid":`command-palette-filter-tag`,"data-active":Ce,"aria-pressed":Ce,className:pt,children:[mt,ht]})}),t[66]=Ce,t[67]=dt,t[68]=pt,t[69]=gt):gt=t[69];let _t=ge,vt;t[70]!==Fe||t[71]!==Ie?(vt=Ie&&!Fe?(0,Z.jsx)(z,{children:`Searching`}):null,t[70]=Fe,t[71]=Ie,t[72]=vt):vt=t[72];let yt=it?null:(0,Z.jsx)(z,{children:m===`error`?`Search failed.`:`No matching commands.`}),bt=Se.kind===`tag-list`?(0,Z.jsxs)(oe,{heading:Se.query?`Tags matching "${Se.query}"`:`All tags`,children:[N===`loading`?(0,Z.jsx)(z,{children:`Loading tags`}):null,N===`error`?(0,Z.jsx)(z,{children:`Failed to load tags. Press Escape and re-open to retry.`}):null,nt?(0,Z.jsx)(z,{children:Se.query?`No tags match "${Se.query}".`:"No tags yet — author `#tagname` in any doc to populate the index."}):null,tt.map(e=>(0,Z.jsxs)(f,{value:`tag ${e.name}`,onSelect:()=>st(e.name),"data-testid":`command-palette-tag-${e.name}`,children:[(0,Z.jsx)(x,{}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.name}),(0,Z.jsxs)(`span`,{className:`ml-auto shrink-0 text-[11px] text-muted-foreground tabular-nums`,children:[e.count,` `,e.count===1?`doc`:`docs`]})]},`tag:${e.name}`))]}):null,xt;t[73]!==i||t[74]!==Se||t[75]!==rt||t[76]!==I||t[77]!==B?(xt=Se.kind===`tag-docs`?(0,Z.jsxs)(oe,{heading:`Docs tagged #${Se.tagName}`,children:[B===`loading`?(0,Z.jsx)(z,{children:`Loading docs`}):null,B===`error`?(0,Z.jsx)(z,{children:`Failed to load docs. Press Escape and re-open to retry.`}):null,rt?(0,Z.jsx)(z,{children:`No docs registered under #${Se.tagName}.`}):null,I.map(e=>{let t=e.title||e.docName.split(`/`).pop()||e.docName;return(0,Z.jsxs)(f,{value:`tag-doc ${e.docName}`,onSelect:()=>{i(!1),Mh(e.docName)},"data-testid":`command-palette-tag-doc-${e.docName}`,className:`items-start`,children:[(0,Z.jsx)(It,{className:`mt-0.5`}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`truncate font-medium`,children:t}),(0,Z.jsx)(`span`,{className:`truncate text-muted-foreground text-xs`,children:e.docName}),e.matchingTags.length>0&&e.matchingTags.some(e=>e!==Se.tagName)?(0,Z.jsxs)(`span`,{className:`truncate text-muted-foreground text-[11px]`,children:[`via`,` `,e.matchingTags.filter(e=>e!==Se.tagName).map(zh).join(`, `)]}):null]})]},`tag-doc:${e.docName}`)})]}):null,t[73]=i,t[74]=Se,t[75]=rt,t[76]=I,t[77]=B,t[78]=xt):xt=t[78];let St=Ne?(0,Z.jsx)(oe,{heading:`Recently opened`,children:J.map(e=>(0,Z.jsx)(Ph,{entry:e,onSelect:()=>Me(e)},$f(e.kind,e.path)))}):null,Ct;t[79]!==G||t[80]!==i||t[81]!==w||t[82]!==E||t[83]!==Re||t[84]!==Be||t[85]!==He||t[86]!==We?(Ct=Re||Be||He||We?(0,Z.jsxs)(oe,{heading:`Commands`,children:[Re?(0,Z.jsxs)(f,{value:`new file create file`,onSelect:()=>{i(!1),w(`file`)},"data-testid":`command-palette-new-file`,children:[(0,Z.jsx)(ac,{}),(0,Z.jsx)(`span`,{children:`New file`})]}):null,Be?(0,Z.jsxs)(f,{value:`new folder create folder`,onSelect:()=>{i(!1),w(`folder`)},"data-testid":`command-palette-new-folder`,children:[(0,Z.jsx)(uc,{}),(0,Z.jsx)(`span`,{children:`New folder`})]}):null,He?(0,Z.jsxs)(f,{value:`open graph graph panel network`,onSelect:()=>{G&&(i(!1),Ap(`graph`))},"data-testid":`command-palette-open-graph`,children:[(0,Z.jsx)(Cc,{}),(0,Z.jsx)(`span`,{children:`Open graph`})]}):null,We?(0,Z.jsxs)(f,{value:`initialize starter pack scaffold seed`,onSelect:()=>{i(!1),E(!0)},"data-testid":`command-palette-initialize-starter-pack`,children:[(0,Z.jsx)(Tc,{}),(0,Z.jsx)(`span`,{children:`Initialize starter pack`})]}):null]}):null,t[79]=G,t[80]=i,t[81]=w,t[82]=E,t[83]=Re,t[84]=Be,t[85]=He,t[86]=We,t[87]=Ct):Ct=t[87];let wt=et?(0,Z.jsx)(oe,{heading:`Open with AI`,children:xm.filter(e=>xp(`Open with AI ${e.displayName}`,c,[e.id,`agent handoff`,`open in`])).map(e=>{let t=ie[e.id],n=t.installed===!0&&ce!==null,r=t.installed===null?`Detecting`:t.installed===!1?`Not installed`:null,a=r?`Open with AI ${e.displayName}, ${r}`:`Open with AI ${e.displayName}`;return(0,Z.jsxs)(f,{value:`send to ai ${e.displayName} ${e.id} agent open in`,disabled:!n,onSelect:()=>{!n||!ce||(i(!1),se(e.id,ce))},"data-testid":`command-palette-open-in-${e.id}`,"aria-label":a,children:[(0,Z.jsxs)(`span`,{className:`flex-1`,children:[`Open with AI `,e.displayName]}),r?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-auto text-muted-foreground text-xs`,children:r}):null]},e.id)})}):null,Tt;t[88]!==a||t[89]!==i||t[90]!==Oe||t[91]!==Qe||t[92]!==Ke||t[93]!==Je||t[94]!==Xe?(Tt=Ke||Je||Xe||Qe?(0,Z.jsxs)(oe,{heading:`Project`,children:[Ke&&a?(0,Z.jsxs)(f,{value:`open folder on disk project`,onSelect:()=>Oe(async()=>{let e=await a.dialog.openFolder();e&&await a.project.open({path:e,target:`new-window`,entryPoint:`pick-existing`})}),"data-testid":`command-palette-open-folder`,children:[(0,Z.jsx)(R,{}),(0,Z.jsx)(`span`,{children:`Open folder on disk`}),(0,Z.jsx)(D,{children:`⌘O`})]}):null,Je&&a?(0,Z.jsxs)(f,{value:`switch-project navigator projects`,onSelect:()=>Oe(()=>a.navigator.open(),`Failed to open Project Navigator.`),"data-testid":`command-palette-switch-project`,children:[(0,Z.jsx)(gc,{}),(0,Z.jsx)(`span`,{children:`Switch Project`}),(0,Z.jsx)(D,{children:`⌘⇧N`})]}):null,Xe?(0,Z.jsxs)(f,{value:`settings preferences config`,onSelect:()=>{i(!1),window.location.hash!==`#settings`&&(window.location.hash=Sm)},"data-testid":`command-palette-settings`,children:[(0,Z.jsx)(zc,{}),(0,Z.jsx)(`span`,{children:`Settings`}),(0,Z.jsx)(D,{children:`⌘,`})]}):null,Qe?(0,Z.jsxs)(f,{value:`install claude desktop cowork app`,onSelect:()=>{i(!1),window.location.hash=`#install-claude-desktop`},"data-testid":`command-palette-install-claude-desktop`,children:[(0,Z.jsx)(ua,{}),(0,Z.jsx)(`span`,{children:`Install for Claude Chat & Cowork (Desktop App)`})]}):null]}):null,t[88]=a,t[89]=i,t[90]=Oe,t[91]=Qe,t[92]=Ke,t[93]=Je,t[94]=Xe,t[95]=Tt):Tt=t[95];let Et=$e&&a?(0,Z.jsx)(oe,{heading:`Open recent project`,children:de.filter(e=>xp(`${e.name} ${e.path}`,c,[`open recent project`])).slice(0,10).map(e=>(0,Z.jsxs)(f,{value:`${e.name} ${e.path} recent project`,disabled:e.missing,onSelect:()=>Oe(()=>a.project.open({path:e.path,target:`new-window`,entryPoint:`recents`}),`Failed to open project.`),"data-testid":`command-palette-recent-${e.path}`,className:`items-start`,children:[(0,Z.jsx)(M,{className:`mt-0.5`}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),(0,Z.jsxs)(`span`,{className:`truncate text-muted-foreground text-xs`,children:[e.path,e.missing?` (missing)`:``]})]})]},e.path))}):null,Dt=Fe?(0,Z.jsx)(oe,{heading:`Search`,children:Pe.map(e=>(0,Z.jsx)(Ph,{entry:e,query:l,onSelect:()=>Me(e)},$f(e.kind,e.path)))}):null,Ot;t[96]!==_t||t[97]!==vt||t[98]!==yt||t[99]!==bt||t[100]!==xt||t[101]!==St||t[102]!==Ct||t[103]!==wt||t[104]!==Tt||t[105]!==Et||t[106]!==Dt?(Ot=(0,Z.jsxs)(_t,{ref:U,className:`subtle-scrollbar`,children:[vt,yt,bt,xt,St,Ct,wt,Tt,Et,Dt]}),t[96]=_t,t[97]=vt,t[98]=yt,t[99]=bt,t[100]=xt,t[101]=St,t[102]=Ct,t[103]=wt,t[104]=Tt,t[105]=Et,t[106]=Dt,t[107]=Ot):Ot=t[107];let kt;t[108]!==ct||t[109]!==i||t[110]!==r||t[111]!==lt||t[112]!==ut||t[113]!==gt||t[114]!==Ot?(kt=(0,Z.jsxs)(ct,{open:r,onOpenChange:i,title:`Workspace Command Palette`,description:`Search files, folders, and commands for the current workspace.`,className:`sm:max-w-2xl`,commandProps:lt,children:[ut,gt,Ot]}),t[108]=ct,t[109]=i,t[110]=r,t[111]=lt,t[112]=ut,t[113]=gt,t[114]=Ot,t[115]=kt):kt=t[115];let At=C===`file`,jt;t[116]===w?jt=t[117]:(jt=e=>{e||w(null)},t[116]=w,t[117]=jt);let Mt;t[118]!==pe||t[119]!==At||t[120]!==jt?(Mt=(0,Z.jsx)(Hp,{open:At,onOpenChange:jt,kind:`file`,initialDir:pe}),t[118]=pe,t[119]=At,t[120]=jt,t[121]=Mt):Mt=t[121];let Nt=C===`folder`,Pt;t[122]===w?Pt=t[123]:(Pt=e=>{e||w(null)},t[122]=w,t[123]=Pt);let Ft;t[124]!==pe||t[125]!==Nt||t[126]!==Pt?(Ft=(0,Z.jsx)(Hp,{open:Nt,onOpenChange:Pt,kind:`folder`,initialDir:pe}),t[124]=pe,t[125]=Nt,t[126]=Pt,t[127]=Ft):Ft=t[127];let Rt;t[128]!==T||t[129]!==E?(Rt=(0,Z.jsx)(hm,{open:T,onOpenChange:E}),t[128]=T,t[129]=E,t[130]=Rt):Rt=t[130];let zt;return t[131]!==kt||t[132]!==Mt||t[133]!==Ft||t[134]!==Rt?(zt=(0,Z.jsxs)(Z.Fragment,{children:[kt,Mt,Ft,Rt]}),t[131]=kt,t[132]=Mt,t[133]=Ft,t[134]=Rt,t[135]=zt):zt=t[135],zt}function zh(e){return`#${e}`}function Bh(e){return e.name}function Vh(e){return $f(e.kind,e.path)}var Hh=500;function Uh(e,t,n){return t?`terminal`:e===null&&n?`retrying`:`hidden`}function Wh(e){return e===null?`no response`:e.kind===`null-collab`?`ok ui responded but server.lock has no port yet`:e.code===`network`?"network error (is `ok ui` running?)":e.code===`invalid-body`?`/api/config returned a malformed body`:`/api/config returned HTTP ${e.code}`}function Gh(){let e=(0,$.c)(16),{collabUrl:t,collabTerminal:n,collabLastError:r,retryCollab:i}=ot(),[a,o]=(0,Q.useState)(!1),s,c;e[0]!==n||e[1]!==t?(s=()=>{if(t!==null||n){o(!1);return}let e=setTimeout(()=>o(!0),Hh);return()=>clearTimeout(e)},c=[t,n],e[0]=n,e[1]=t,e[2]=s,e[3]=c):(s=e[2],c=e[3]),(0,Q.useEffect)(s,c);let l=Uh(t,n,a);if(l===`hidden`)return null;if(l===`terminal`){let t;e[4]===r?t=e[5]:(t=Wh(r),e[4]=r,e[5]=t);let n;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`code`,{className:`bg-red-100/60 px-1 rounded`,children:`ok status`}),e[6]=n):n=e[6];let a;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(`code`,{className:`bg-red-100/60 px-1 rounded`,children:`.ok/local/last-spawn-error.log`}),e[7]=a):a=e[7];let o;e[8]===t?o=e[9]:(o=(0,Z.jsxs)(`span`,{children:[`Couldn't reach collab server — `,t,`. Try`,` `,n,` or check`,` `,a,`.`]}),e[8]=t,e[9]=o);let s;e[10]===i?s=e[11]:(s=(0,Z.jsx)(`button`,{type:`button`,onClick:i,className:`bg-red-950 text-red-50 px-2 py-0.5 rounded text-xs font-medium hover:bg-red-900`,children:`Retry`}),e[10]=i,e[11]=s);let c;return e[12]!==o||e[13]!==s?(c=(0,Z.jsxs)(`div`,{role:`alert`,"aria-live":`assertive`,className:`fixed top-0 inset-x-0 z-50 bg-red-500/95 text-red-950 text-sm text-center py-2 px-4 pl-[var(--ok-titlebar-reserve-left,1rem)] shadow-md flex items-center justify-center gap-3 flex-wrap`,children:[o,s]}),e[12]=o,e[13]=s,e[14]=c):c=e[14],c}let u;return e[15]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`fixed top-0 inset-x-0 z-50 bg-amber-500/95 text-amber-950 text-sm text-center py-2 px-4 pl-[var(--ok-titlebar-reserve-left,1rem)] shadow-md`,children:`Connecting — waiting for collab server`}),e[15]=u):u=e[15],u}async function Kh(e){let t=await fetch(`/api/tags/${encodeURIComponent(e)}`);if(!t.ok){let e=await t.json().catch(()=>null);throw Error(Gn(e)??`Server error: ${t.status} ${t.statusText}`)}return(await t.json()).docs??[]}function qh(){let e=(0,$.c)(15),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(null),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={kind:`idle`},e[0]=a):a=e[0];let[o,s]=(0,Q.useState)(a),c=(0,Q.useRef)(0),l,u;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=function(e){let t=e.detail;if(!t||typeof t.value!=`string`)return;let r=c.current+=1;i(t.value),n(!0),s({kind:`loading`}),Kh(t.value).then(e=>{c.current===r&&s({kind:`ready`,docs:e})}).catch(e=>{c.current===r&&s({kind:`error`,message:e instanceof Error?e.message:String(e)})})};return document.addEventListener(rt,e),()=>document.removeEventListener(rt,e)},u=[],e[1]=l,e[2]=u):(l=e[1],u=e[2]),(0,Q.useEffect)(l,u);let d;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=function(e){n(!1),window.location.assign(Tr(e))},e[3]=d):d=e[3];let f=d,p=r??``,m;e[4]===p?m=e[5]:(m=(0,Z.jsx)(Ao,{children:(0,Z.jsxs)(bo,{children:[`Documents tagged `,(0,Z.jsxs)(`span`,{className:`font-mono`,children:[`#`,p]})]})}),e[4]=p,e[5]=m);let h=r??``,g;e[6]!==o||e[7]!==h?(g=(0,Z.jsx)(Do,{children:(0,Z.jsx)(Jh,{fetchState:o,tag:h,onSelectDoc:f})}),e[6]=o,e[7]=h,e[8]=g):g=e[8];let _;e[9]!==m||e[10]!==g?(_=(0,Z.jsxs)(wo,{children:[m,g]}),e[9]=m,e[10]=g,e[11]=_):_=e[11];let v;return e[12]!==t||e[13]!==_?(v=(0,Z.jsx)(jo,{open:t,onOpenChange:n,children:_}),e[12]=t,e[13]=_,e[14]=v):v=e[14],v}function Jh(e){let t=(0,$.c)(12),{fetchState:n,tag:r,onSelectDoc:i}=e;if(n.kind===`idle`||n.kind===`loading`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`p`,{className:`text-muted-foreground text-sm`,"data-testid":`tag-dialog-loading`,children:`Loading`}),t[0]=e):e=t[0],e}if(n.kind===`error`){let e;return t[1]===n.message?e=t[2]:(e=(0,Z.jsx)(`p`,{className:`text-destructive text-sm`,"data-testid":`tag-dialog-error`,children:n.message}),t[1]=n.message,t[2]=e),e}if(n.docs.length===0){let e;return t[3]===r?e=t[4]:(e=(0,Z.jsxs)(`p`,{className:`text-muted-foreground text-sm`,"data-testid":`tag-dialog-empty`,children:[`Only the current document uses `,(0,Z.jsxs)(`span`,{className:`font-mono`,children:[`#`,r]}),`.`]}),t[3]=r,t[4]=e),e}let a;if(t[5]!==n.docs||t[6]!==i){let e;t[8]===i?e=t[9]:(e=e=>{let t=e.matchingTags??[];return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,className:`w-full rounded-md px-2 py-1.5 text-left text-sm hover:bg-muted focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring`,onClick:()=>i(e.docName),"data-testid":`tag-dialog-row`,children:[(0,Z.jsx)(`span`,{className:`block truncate font-medium`,children:e.title}),e.docName===e.title?null:(0,Z.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:e.docName}),t.length>0?(0,Z.jsx)(`span`,{className:`mt-1 flex flex-wrap items-center gap-1`,"data-testid":`tag-dialog-row-matches`,children:t.map(Yh)}):null]})},e.docName)},t[8]=i,t[9]=e),a=n.docs.map(e),t[5]=n.docs,t[6]=i,t[7]=a}else a=t[7];let o;return t[10]===a?o=t[11]:(o=(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1`,"data-testid":`tag-dialog-list`,children:a}),t[10]=a,t[11]=o),o}function Yh(e){return(0,Z.jsxs)(`span`,{"data-testid":`tag-dialog-row-match`,"data-tag":e,className:`tag pointer-events-none text-xs`,children:[`#`,e]},e)}var Xh=`raw-mdx-nav`,Zh=`ok-editor-mode-v1`,Qh=[`wysiwyg`,`source`],$h=`wysiwyg`;function eg(e){return Qh.includes(e)}function tg(e=localStorage){try{let t=e.getItem(Zh);if(t===null)return $h;if(eg(t))return t;console.warn(`[editor-mode] invalid persisted value, falling back to default`,{raw:t})}catch{}return $h}function ng(e=window,t=localStorage){let n=e.__OK_EDITOR_MODE__;return eg(n)?n:tg(t)}function rg(e,t=localStorage){try{return t.setItem(Zh,e),!0}catch(e){return console.warn(`[editor-mode] persist failed`,e),!1}}function ig(){let e=(0,$.c)(3),[t,n]=(0,Q.useState)(ng),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=function(e){n(e),rg(e)},e[0]=r):r=e[0];let i=r,a;return e[1]===t?a=e[2]:(a=[t,i],e[1]=t,e[2]=a),a}function ag(e){let t=(0,$.c)(22),{open:n,onResolved:r}=e,i=da(),a;t[0]!==r||t[1]!==i?(a=function(e){if(i===null){X.error(`Sync settings not yet loaded — try again in a moment`);return}let t=i(e);if(!t.ok){X.error(`Could not ${e?`enable sync`:`save sync preference`}: ${t.error}`);return}r()},t[0]=r,t[1]=i,t[2]=a):a=t[2];let o=a,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(Ao,{children:(0,Z.jsx)(Bi,{})}),t[3]=s):s=t[3];let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(ja,{}),t[4]=c):c=t[4];let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsxs)(Do,{children:[c,(0,Z.jsxs)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:[`You can turn this on later in `,(0,Z.jsx)(`span`,{className:`font-medium`,children:`Settings → Sync`}),`.`]})]}),t[5]=l):l=t[5];let u;t[6]===o?u=t[7]:(u=()=>o(!1),t[6]=o,t[7]=u);let d=i===null,f;t[8]!==u||t[9]!==d?(f=(0,Z.jsx)(Y,{variant:`ghost`,className:`uppercase font-mono`,onClick:u,disabled:d,children:`Keep disabled`}),t[8]=u,t[9]=d,t[10]=f):f=t[10];let p;t[11]===o?p=t[12]:(p=()=>o(!0),t[11]=o,t[12]=p);let m=i===null,h;t[13]!==p||t[14]!==m?(h=(0,Z.jsx)(Y,{onClick:p,disabled:m,children:`Enable auto-sync`}),t[13]=p,t[14]=m,t[15]=h):h=t[15];let g;t[16]!==h||t[17]!==f?(g=(0,Z.jsxs)(wo,{className:`sm:max-w-lg`,showCloseButton:!1,children:[s,l,(0,Z.jsxs)(Oo,{children:[f,h]})]}),t[16]=h,t[17]=f,t[18]=g):g=t[18];let _;return t[19]!==n||t[20]!==g?(_=(0,Z.jsx)(jo,{open:n,onOpenChange:og,children:g}),t[19]=n,t[20]=g,t[21]=_):_=t[21],_}function og(){}function sg(e){let t=(0,$.c)(9),{onOpenResolver:n}=e,r=Qa();if(!r||r.state!==`conflict`)return null;let i=r.conflictCount,a=i>0?`${i} page${i===1?``:`s`}`:`Some pages`,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(dr,{className:`size-4 shrink-0`}),t[0]=o):o=t[0];let s=i===1?`has`:`have`,c;t[1]!==a||t[2]!==s?(c=(0,Z.jsxs)(`span`,{className:`flex-1`,children:[a,` `,s,` conflicting changes.`]}),t[1]=a,t[2]=s,t[3]=c):c=t[3];let l;t[4]===n?l=t[5]:(l=(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,className:`shrink-0 border-amber-400 dark:border-amber-700 text-amber-800 dark:text-amber-300 hover:bg-amber-100 dark:hover:bg-amber-900/50`,onClick:n,children:`Review and resolve`}),t[4]=n,t[5]=l);let u;return t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm border-b bg-amber-50 dark:bg-amber-950/30 text-amber-800 dark:text-amber-300 shrink-0`,children:[o,c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8],u}var cg=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 lg(e,t,n,r,i,a){if(e==r)return[];let o=yg(e,t,n,r,i,a),s=bg(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 cg(t,n,i,a)];if(c>l){let o=e.slice(t,n).indexOf(r.slice(i,a));if(o>-1)return[new cg(t,t+o,i,i),new cg(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 cg(t,t,i,i+o),new cg(n,n,i+o+c,a)]}if(c==1||l==1)return[new cg(t,n,i,a)];let u=Sg(e,t,n,r,i,a);if(u){let[o,s,c]=u;return lg(e,t,o,r,i,s).concat(lg(e,o+c,n,r,s+c,a))}return pg(e,t,n,r,i,a)}var ug=1e9,dg=0,fg=!1;function pg(e,t,n,r,i,a){let o=n-t,s=a-i;if(ug<1e9&&Math.min(o,s)>ug*16||dg>0&&Date.now()>dg)return Math.min(o,s)>ug*64?[new cg(t,n,i,a)]:Cg(e,t,n,r,i,a);let c=Math.ceil((o+s)/2);hg.reset(c),gg.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:gg,f=d?null:hg;for(let p=0;p<c;p++){if(p>ug||dg>0&&!(p&63)&&Date.now()>dg)return Cg(e,t,n,r,i,a);let m=hg.advance(p,o,s,c,d,!1,l)||gg.advance(p,o,s,c,f,!0,u);if(m)return _g(e,t,n,t+m[0],r,i,a,i+m[1])}return[new cg(t,n,i,a)]}var mg=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}},hg=new mg,gg=new mg;function _g(e,t,n,r,i,a,o,s){let c=!1;return!Rg(e,r)&&++r==n&&(c=!0),!Rg(i,s)&&++s==o&&(c=!0),c?[new cg(t,n,a,o)]:lg(e,t,r,i,a,s).concat(lg(e,r,n,i,s,o))}function vg(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function yg(e,t,n,r,i,a){if(t==n||t==a||e.charCodeAt(t)!=r.charCodeAt(i))return 0;let o=vg(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-+!Rg(e,s);o>>=1}else if(i==n||l==a)return i-t;else s=i,c=l}}function bg(e,t,n,r,i,a){if(t==n||i==a||e.charCodeAt(n-1)!=r.charCodeAt(a-1))return 0;let o=vg(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-+!Rg(e,s);o>>=1}else if(a==t||l==i)return n-a;else s=a,c=l}}function xg(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;;){Rg(e,s)||s++;let u=s+o;if(Rg(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=yg(e,u,n,r,i+f+d.length,a),c=bg(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 Sg(e,t,n,r,i,a){let o=n-t,s=a-i;if(o<s){let o=Sg(r,i,a,e,t,n);return o&&[o[1],o[0],o[2]]}return o<4||s*2<o?null:xg(e,t,n,r,i,a,Math.floor(o/4),-1)}function Cg(e,t,n,r,i,a){fg=!0;let o=n-t,s=a-i,c;if(o<s){let s=xg(r,i,a,e,t,n,Math.floor(o/6),50);c=s&&[s[1],s[0],s[2]]}else c=xg(e,t,n,r,i,a,Math.floor(s/6),50);if(!c)return[new cg(t,n,i,a)];let[l,u,d]=c;return lg(e,t,l,r,i,u).concat(lg(e,l+d,n,r,u+d,a))}function wg(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 cg(r.fromA,i.toA,r.fromB,i.toB),e.splice(n--,1))}}function Tg(e,t,n){for(;;){wg(n,1);let r=!1;for(let i=0;i<n.length;i++){let a=n[i],o,s;(o=yg(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new cg(a.fromA+o,a.toA,a.fromB+o,a.toB)),(s=bg(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new cg(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 cg(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 cg(a.fromA+d,a.toA+d,a.fromB+d,a.toB+d),r=!0)}if(!r)break}return n}function Eg(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=Ng(t,a.fromA,l),f=Mg(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 cg(d,d+o,a.fromB-p,a.toB-p),d=a.fromA,f=Mg(t,a.toA,c-a.toA)):l>m&&t.slice(a.toA,f)==u.slice(h,h+m)&&(a=e[i]=new cg(f-o,f,a.fromB+m,a.toB+m),f=a.toA,d=Ng(t,a.fromA,a.fromA-r)),p=a.fromA-d,m=f-a.toA}if(p||m)a=e[i]=new cg(a.fromA-p,a.toA+m,a.fromB-p,a.toB+m);else if(!o){let t=Fg(n,a.fromB,a.toB),r,o=t<0?-1:Pg(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=Fg(t,a.fromA,a.toA),r,o=n<0?-1:Pg(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 wg(e,3),e}var Dg;try{Dg=RegExp(`[\\p{Alphabetic}\\p{Number}]`,`u`)}catch{}function Og(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function kg(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?+!!Og(n):Dg?!Ig(n)||t==e.length-1?+!!Dg.test(String.fromCharCode(n)):Dg.test(e.slice(t,t+2))?2:0:0}function Ag(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?+!!Og(n):Dg?!Lg(n)||t==1?+!!Dg.test(String.fromCharCode(n)):Dg.test(e.slice(t-2,t))?2:0:0}var jg=8;function Mg(e,t,n){if(t==e.length||!Ag(e,t))return t;for(let r=t,i=t+n,a=0;a<jg;a++){let t=kg(e,r);if(!t||r+t>i)return r;r+=t}return t}function Ng(e,t,n){if(!t||!kg(e,t))return t;for(let r=t,i=t-n,a=0;a<jg;a++){let t=Ag(e,r);if(!t||r-t<i)return r;r-=t}return t}function Pg(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function Fg(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}var Ig=e=>e>=55296&&e<=56319,Lg=e=>e>=56320&&e<=57343;function Rg(e,t){return!t||t==e.length||!Ig(e.charCodeAt(t-1))||!Lg(e.charCodeAt(t))}function zg(e,t,n){let r=n?.override;return r?r(e,t):(ug=(n?.scanLimit??1e9)>>1,dg=n?.timeout?Date.now()+n.timeout:0,fg=!1,Tg(e,t,lg(e,0,e.length,t,0,t.length)))}function Bg(){return!fg}function Vg(e,t,n){return Eg(zg(e,t,n),e,t)}var Hg=os.define({combine:e=>e[0]}),Ug=ss.define(),Wg=os.define(),Gg=ts.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(Ug)&&(e=n.value);for(let n of t.state.facet(Wg))e=n(e,t);return e}});function Kg(e){let t=e.field(Gg,!1);if(!t)return null;let n=e.facet(Hg);return{chunks:t,side:n?n.side:null}}var qg=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 Xg(Vg(e.toString(),t.toString(),n),e,t,0,0,Bg())}static updateA(e,t,n,r,i){return e_($g(e,r,!0,n.length),e,t,n,i)}static updateB(e,t,n,r,i){return e_($g(e,r,!1,t.length),e,t,n,i)}};function Jg(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 Yg(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 Xg(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length;s++){let c=e[s],[l,u]=Jg(c.fromA+r,c.fromB+i,t,n),[d,f]=Yg(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]=Jg(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]=Yg(a.toA+r,a.toB+i,t,n),s++}o.push(new qg(p,l,Math.max(l,d),u,Math.max(u,f),a))}return o}var Zg=1e3;function Qg(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 $g(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>Zg&&([l,d]=Qg(e,a-Zg,n,!0)),o<t.length-Zg&&([u,f]=Qg(e,o+Zg,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 e_(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=Vg(n.sliceString(d,p),r.sliceString(f,m),i);for(let e of Xg(h,n,r,d,f,Bg()))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 t_={scanLimit:500},n_=cs.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=f_(e))}update(e){(e.docChanged||e.viewportChanged||i_(e.startState,e.state)||a_(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=f_(e.view))}},{decorations:e=>e.deco}),r_=Qo.low(fs({class:`cm-changeGutter`,markers:e=>e.plugin(n_)?.gutter||hs.empty}));function i_(e,t){return e.field(Gg,!1)!=t.field(Gg,!1)}function a_(e,t){return e.facet(Hg)!=t.facet(Hg)}var o_=is.line({class:`cm-changedLine`}),s_=is.mark({class:`cm-changedText`}),c_=is.mark({tagName:`ins`,class:`cm-insertedLine`}),l_=is.mark({tagName:`del`,class:`cm-deletedLine`}),u_=new class extends ds{constructor(){super(...arguments),this.elementClass=`cm-changedLineGutter`}};function d_(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,o_),i.add(o,s,n?l_:c_),a&&a.add(o,o,u_);for(let l=t.iterRange(o,s-1),u=o;!l.next().done;){if(l.lineBreak){u++,i.add(u,u,o_),a&&a.add(u,u,u_);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,s_),s<t)c++;else break}u=t}}}function f_(e){let t=e.state.field(Gg),{side:n,highlightChanges:r,markGutter:i,overrideChunk:a}=e.state.facet(Hg),o=n==`a`,s=new as,c=i?new as: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))&&d_(n,e.state.doc,o,r,s,c)}return{deco:s.finish(),gutter:c&&c.finish()}}var p_=class extends Zo{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}},m_=ss.define({map:(e,t)=>e.map(t)}),h_=ts.define({create:()=>is.none,update:(e,t)=>{for(let e of t.effects)if(e.is(m_))return e.value;return e.map(t.changes)},provide:e=>us.decorations.from(e)}),g_=.01;function __(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 v_(e,t,n){let r=new as,i=new as,a=e.state.field(h_).iter(),o=t.state.field(h_).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<-g_?(l-=n,r.add(s,s,is.widget({widget:new p_(-n),block:!0,side:-1}))):n>g_&&(u+=n,i.add(c,c,is.widget({widget:new p_(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<g_?r.add(e.state.doc.length,e.state.doc.length,is.widget({widget:new p_(-p),block:!0,side:1})):p>g_&&i.add(t.state.doc.length,t.state.doc.length,is.widget({widget:new p_(p),block:!0,side:1}));let m=r.finish(),h=i.finish();__(m,e.state.field(h_))||e.dispatch({effects:m_.of(m)}),__(h,t.state.field(h_))||t.dispatch({effects:m_.of(h)})}var y_=ss.define({map:(e,t)=>t.mapPos(e)}),b_=class extends Zo{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:y_.of(n)});let{side:r,sibling:i}=e.state.facet(Hg);i&&i().dispatch({effects:y_.of(x_(n,e.state.field(Gg),r==`a`))})}),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return`collapsed-unchanged-code`}};function x_(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 S_=ts.define({create(e){return is.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(y_)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>us.decorations.from(e)});function C_({margin:e=3,minSize:t=4}){return S_.init(n=>w_(n,e,t))}function w_(e,t,n){let r=new as,i=e.facet(Hg).side==`a`,a=e.field(Gg),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,is.replace({widget:new b_(d),block:!0})),!c)break;o=e.doc.lineAt(Math.min(e.doc.length,i?c.toA:c.toB)).number}return r.finish()}var T_=us.styleModule.of(new ps({".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`}})),E_=us.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`}}),D_=new ls,O_=new ls,k_=class{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||t_;let t=[Qo.low(n_),E_,T_,h_,us.updateListener.of(e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some(e=>e.effects.some(e=>e.is(m_)))&&this.measure()})],n=[Hg.of({side:`a`,sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&n.push(r_);let r=es.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],us.editorAttributes.of({class:`cm-merge-a`}),O_.of(n),t]}),i=[Hg.of({side:`b`,sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&i.push(r_);let a=es.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],us.editorAttributes.of({class:`cm-merge-b`}),O_.of(i),t]});this.chunks=qg.build(r.doc,a.doc,this.diffConf);let o=[Gg.init(()=>this.chunks),D_.of(e.collapseUnchanged?C_(e.collapseUnchanged):[])];r=r.update({effects:ss.appendConfig.of(o)}).state,a=a.update({effects:ss.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 us({state:r,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new us({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),$o.empty(e[0].startState.doc.length));this.chunks=t==this.a?qg.updateA(this.chunks,n.newDoc,this.b.state.doc,r,this.diffConf):qg.updateB(this.chunks,this.a.state.doc,n.newDoc,r,this.diffConf),t.update([...e,n.state.update({effects:Ug.of(this.chunks)})]);let i=t==this.a?this.b:this.a;i.update([i.state.update({effects:Ug.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(Hg),o=n?e.gutter!==!1:r.markGutter,s=t?e.highlightChanges!==!1:r.highlightChanges;i.push(O_.reconfigure([Hg.of({side:`a`,sibling:()=>this.b,highlightChanges:s,markGutter:o}),o?r_:[]])),a.push(O_.reconfigure([Hg.of({side:`b`,sibling:()=>this.a,highlightChanges:s,markGutter:o}),o?r_:[]]))}if(r){let t=D_.reconfigure(e.collapseUnchanged?C_(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(){v_(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=A_(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=A_(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 A_(e){let t=e.nextSibling;return e.remove(),t}var j_=new class extends ds{constructor(){super(...arguments),this.elementClass=`cm-deletedLineGutter`}},M_=Qo.low(fs({class:`cm-changeGutter`,markers:e=>e.plugin(n_)?.gutter||hs.empty,widgetMarker:(e,t)=>t instanceof L_?j_:null}));function N_(e){let t=typeof e.original==`string`?rs.of(e.original.split(/\r?\n/)):e.original,n=e.diffConfig||t_;return[Qo.low(n_),H_,E_,us.editorAttributes.of({class:`cm-merge-b`}),Wg.of((e,t)=>{let r=t.effects.find(e=>e.is(P_));return r&&(e=qg.updateA(e,r.value.doc,t.startState.doc,r.value.changes,n)),t.docChanged&&(e=qg.updateB(e,t.state.field(F_),t.newDoc,t.changes,n)),e}),Hg.of({highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1,syntaxHighlightDeletions:e.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:e.mergeControls??!0,overrideChunk:e.allowInlineDiffs?J_:void 0,side:`b`}),F_.init(()=>t),e.gutter===!1?[]:M_,e.collapseUnchanged?C_(e.collapseUnchanged):[],Gg.init(e=>qg.build(t,e.doc,n))]}var P_=ss.define(),F_=ts.define({create:()=>rs.empty,update(e,t){for(let n of t.effects)n.is(P_)&&(e=n.value.doc);return e}}),I_=new WeakMap,L_=class extends Zo{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 R_(e,t,n){let r=I_.get(t.changes);if(r)return r;let i=is.widget({block:!0,side:-1,widget:new L_(r=>{let{highlightChanges:i,syntaxHighlightDeletions:a,syntaxHighlightDeletionsMaxLength:o,mergeControls:s}=e.facet(Hg),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(),z_(r,r.posAtDOM(c))},i=e=>{e.preventDefault(),B_(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(F_).sliceString(t.fromA,t.endA),u=a&&e.facet(gs),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)==`
|
|
13
|
+
`);o=s.pop()??``;for(let e of s){if(!e.trim())continue;let n;try{n=JSON.parse(e)}catch{console.warn(`[clone-transport] Dropped unparseable NDJSON line:`,e.slice(0,100));continue}if(n&&typeof n==`object`&&n.type===`error`&&`problem`in n){let e=n.problem;t({type:`error`,message:e?.detail||e?.title||`Unknown error`});break}t(n)}if(n.aborted)break}n.aborted||t({type:`error`,message:`Clone stream ended unexpectedly — check if the clone completed`})}catch(e){if(e instanceof Error&&e.name===`AbortError`)return;t({type:`error`,message:`Clone failed — connection error`})}})()})}}}function _l(e){return{start(t){return e.localOp.clone.start(t)}}}var vl=`ContextMenu`,[yl,bl]=Si(vl,[Va]),xl=Va(),[Sl,Cl]=yl(vl),wl=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,dir:i,modal:a=!0}=e,[o,s]=Q.useState(!1),c=xl(t),l=xi(r),u=Q.useCallback(e=>{s(e),l(e)},[l]);return(0,Z.jsx)(Sl,{scope:t,open:o,onOpenChange:u,modal:a,children:(0,Z.jsx)(so,{...c,dir:i,open:o,onOpenChange:u,modal:a,children:n})})};wl.displayName=vl;var Tl=`ContextMenuTrigger`,El=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,disabled:r=!1,...i}=e,a=Cl(Tl,n),o=xl(n),s=Q.useRef({x:0,y:0}),c=Q.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...s.current})}),l=Q.useRef(0),u=Q.useCallback(()=>window.clearTimeout(l.current),[]),d=e=>{s.current={x:e.clientX,y:e.clientY},a.onOpenChange(!0)};return Q.useEffect(()=>u,[u]),Q.useEffect(()=>void(r&&u()),[r,u]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ya,{...o,virtualRef:c}),(0,Z.jsx)(bi.span,{"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,...i,ref:t,style:{WebkitTouchCallout:`none`,...e.style},onContextMenu:r?e.onContextMenu:_i(e.onContextMenu,e=>{u(),d(e),e.preventDefault()}),onPointerDown:r?e.onPointerDown:_i(e.onPointerDown,tu(e=>{u(),l.current=window.setTimeout(()=>d(e),700)})),onPointerMove:r?e.onPointerMove:_i(e.onPointerMove,tu(u)),onPointerCancel:r?e.onPointerCancel:_i(e.onPointerCancel,tu(u)),onPointerUp:r?e.onPointerUp:_i(e.onPointerUp,tu(u))})]})});El.displayName=Tl;var Dl=`ContextMenuPortal`,Ol=e=>{let{__scopeContextMenu:t,...n}=e,r=xl(t);return(0,Z.jsx)(lo,{...r,...n})};Ol.displayName=Dl;var kl=`ContextMenuContent`,Al=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Cl(kl,n),a=xl(n),o=Q.useRef(!1);return(0,Z.jsx)(Pa,{...a,...r,ref:t,side:`right`,sideOffset:2,align:`start`,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),!t.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Al.displayName=kl;var jl=`ContextMenuGroup`,Ml=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(wa,{...i,...r,ref:t})});Ml.displayName=jl;var Nl=`ContextMenuLabel`,Pl=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(Oa,{...i,...r,ref:t})});Pl.displayName=Nl;var Fl=`ContextMenuItem`,Il=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(ao,{...i,...r,ref:t})});Il.displayName=Fl;var Ll=`ContextMenuCheckboxItem`,Rl=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(Ia,{...i,...r,ref:t})});Rl.displayName=Ll;var zl=`ContextMenuRadioGroup`,Bl=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(ma,{...i,...r,ref:t})});Bl.displayName=zl;var Vl=`ContextMenuRadioItem`,Hl=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(Gi,{...i,...r,ref:t})});Hl.displayName=Vl;var Ul=`ContextMenuItemIndicator`,Wl=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(fo,{...i,...r,ref:t})});Wl.displayName=Ul;var Gl=`ContextMenuSeparator`,Kl=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(ga,{...i,...r,ref:t})});Kl.displayName=Gl;var ql=`ContextMenuArrow`,Jl=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(Wa,{...i,...r,ref:t})});Jl.displayName=ql;var Yl=`ContextMenuSub`,Xl=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,open:i,defaultOpen:a}=e,o=xl(t),[s,c]=yi({prop:i,defaultProp:a??!1,onChange:r,caller:Yl});return(0,Z.jsx)(Yi,{...o,open:s,onOpenChange:c,children:n})};Xl.displayName=Yl;var Zl=`ContextMenuSubTrigger`,Ql=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(ca,{...i,...r,ref:t})});Ql.displayName=Zl;var $l=`ContextMenuSubContent`,eu=Q.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=xl(n);return(0,Z.jsx)(qi,{...i,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});eu.displayName=$l;function tu(e){return t=>t.pointerType===`mouse`?void 0:e(t)}var nu=wl,ru=El,iu=Ol,au=Al,ou=Il,su=Rl,cu=Wl,lu=Kl,uu=Xl,du=Ql,fu=eu,pu=`Radio`,[mu,hu]=Si(pu),[gu,_u]=mu(pu),vu=Q.forwardRef((e,t)=>{let{__scopeRadio:n,name:r,checked:i=!1,required:a,disabled:o,value:s=`on`,onCheck:c,form:l,...u}=e,[d,f]=Q.useState(null),p=hi(t,e=>f(e)),m=Q.useRef(!1),h=d?l||!!d.closest(`form`):!0;return(0,Z.jsxs)(gu,{scope:n,checked:i,disabled:o,children:[(0,Z.jsx)(bi.button,{type:`button`,role:`radio`,"aria-checked":i,"data-state":Cu(i),"data-disabled":o?``:void 0,disabled:o,value:s,...u,ref:p,onClick:_i(e.onClick,e=>{i||c?.(),h&&(m.current=e.isPropagationStopped(),m.current||e.stopPropagation())})}),h&&(0,Z.jsx)(Su,{control:d,bubbles:!m.current,name:r,value:s,checked:i,required:a,disabled:o,form:l,style:{transform:`translateX(-100%)`}})]})});vu.displayName=pu;var yu=`RadioIndicator`,bu=Q.forwardRef((e,t)=>{let{__scopeRadio:n,forceMount:r,...i}=e,a=_u(yu,n);return(0,Z.jsx)(gi,{present:r||a.checked,children:(0,Z.jsx)(bi.span,{"data-state":Cu(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t})})});bu.displayName=yu;var xu=`RadioBubbleInput`,Su=Q.forwardRef(({__scopeRadio:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=Q.useRef(null),s=hi(o,a),c=To(n),l=Ci(t);return Q.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,Z.jsx)(bi.input,{type:`radio`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});Su.displayName=xu;function Cu(e){return e?`checked`:`unchecked`}var wu=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`],Tu=`RadioGroup`,[Eu,Du]=Si(Tu,[Ho,hu]),Ou=Ho(),ku=hu(),[Au,ju]=Eu(Tu),Mu=Q.forwardRef((e,t)=>{let{__scopeRadioGroup:n,name:r,defaultValue:i,value:a,required:o=!1,disabled:s=!1,orientation:c,dir:l,loop:u=!0,onValueChange:d,...f}=e,p=Ou(n),m=Cn(l),[h,g]=yi({prop:a,defaultProp:i??null,onChange:d,caller:Tu});return(0,Z.jsx)(Au,{scope:n,name:r,required:o,disabled:s,value:h,onValueChange:g,children:(0,Z.jsx)(zo,{asChild:!0,...p,orientation:c,dir:m,loop:u,children:(0,Z.jsx)(bi.div,{role:`radiogroup`,"aria-required":o,"aria-orientation":c,"data-disabled":s?``:void 0,dir:m,...f,ref:t})})})});Mu.displayName=Tu;var Nu=`RadioGroupItem`,Pu=Q.forwardRef((e,t)=>{let{__scopeRadioGroup:n,disabled:r,...i}=e,a=ju(Nu,n),o=a.disabled||r,s=Ou(n),c=ku(n),l=Q.useRef(null),u=hi(t,l),d=a.value===i.value,f=Q.useRef(!1);return Q.useEffect(()=>{let e=e=>{wu.includes(e.key)&&(f.current=!0)},t=()=>f.current=!1;return document.addEventListener(`keydown`,e),document.addEventListener(`keyup`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`keyup`,t)}},[]),(0,Z.jsx)(Bo,{asChild:!0,...s,focusable:!o,active:d,children:(0,Z.jsx)(vu,{disabled:o,required:a.required,checked:d,...c,...i,name:a.name,ref:u,onCheck:()=>a.onValueChange(i.value),onKeyDown:_i(e=>{e.key===`Enter`&&e.preventDefault()}),onFocus:_i(i.onFocus,()=>{f.current&&l.current?.click()})})})});Pu.displayName=Nu;var Fu=`RadioGroupIndicator`,Iu=Q.forwardRef((e,t)=>{let{__scopeRadioGroup:n,...r}=e;return(0,Z.jsx)(bu,{...ku(n),...r,ref:t})});Iu.displayName=Fu;var Lu=Mu,Ru=Pu,zu=Iu;async function Bu(e){try{await navigator.clipboard.writeText(e)}catch{}}var Vu=120*1e3;function Hu(e){let t=(0,$.c)(26),{onSuccess:n,onCancel:r,transport:i}=e,[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(`https://github.com/login/device`),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(Vu),_=(0,Q.useRef)(null),v=(0,Q.useRef)(null),y;t[0]!==n||t[1]!==i?(y=async function(){f(null),m(!0);try{let e=i.start();_.current=e.cancel;let t=e.events[Symbol.asyncIterator](),r=!1,a=await t.next();for(;!a.done;){let e=a.value;if(e.type===`verification`)o(e.user_code),c(e.verification_uri),g(e.expires_in*1e3),Bu(e.user_code).then(()=>{u(!0),setTimeout(()=>u(!1),2e3)});else if(e.type===`complete`){r=!0,m(!1),n({login:e.login,name:e.name,email:e.email,avatarUrl:e.avatarUrl});break}else if(e.type===`error`){r=!0,f(e.message),m(!1);break}a=await t.next()}r||(f(`Sign-in stream ended without confirmation — please try again`),m(!1))}catch(e){let t=e;t instanceof Error&&t.name!==`AbortError`&&f(`Connection error — try again`),m(!1)}},t[0]=n,t[1]=i,t[2]=y):y=t[2];let b=y,x;t[3]===b?x=t[4]:(x=()=>{let e=!1;return queueMicrotask(()=>{e||b()}),()=>{e=!0,_.current?.(),_.current=null,v.current&&clearInterval(v.current)}},t[3]=b,t[4]=x);let S;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(S=[],t[5]=S):S=t[5],(0,Q.useEffect)(x,S);let C,w;t[6]===a?(C=t[7],w=t[8]):(C=()=>{if(!a)return;let e=Date.now();return v.current=setInterval(()=>{let t=Vu-(Date.now()-e);t<=0?(g(0),v.current&&clearInterval(v.current),f(`Code expired — please try again`)):g(t)},1e3),()=>{v.current&&clearInterval(v.current)}},w=[a],t[6]=a,t[7]=C,t[8]=w),(0,Q.useEffect)(C,w);let T=Math.floor(h/6e4),E=Math.floor(h%6e4/1e3),D;t[9]===E?D=t[10]:(D=E.toString().padStart(2,`0`),t[9]=E,t[10]=D);let O=`${T}:${D}`,k;t[11]!==l||t[12]!==d||t[13]!==O||t[14]!==a||t[15]!==s?(k=a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Open`,` `,(0,Z.jsx)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>Hi(e,s),onAuxClick:e=>Hi(e,s),className:`underline underline-offset-2`,children:s}),` `,`and enter this code:`]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`code`,{className:`flex-1 text-center text-2xl font-mono font-bold tracking-widest border rounded-md py-3 bg-muted`,children:a}),(0,Z.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>void Bu(a).then(()=>{u(!0),setTimeout(()=>u(!1),2e3)}),children:l?`Copied!`:`Copy`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-500 animate-pulse`}),`Waiting for authorization`]}),(0,Z.jsxs)(`span`,{children:[`Expires in `,O]})]})]}):(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-6 text-sm text-muted-foreground`,children:d?null:`Starting sign-in flow`}),t[11]=l,t[12]=d,t[13]=O,t[14]=a,t[15]=s,t[16]=k):k=t[16];let A;t[17]===d?A=t[18]:(A=d&&(0,Z.jsx)(`p`,{className:`text-sm text-destructive`,children:d}),t[17]=d,t[18]=A);let j;t[19]!==r||t[20]!==p?(j=p&&(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:r,children:`Cancel`}),t[19]=r,t[20]=p,t[21]=j):j=t[21];let M;return t[22]!==k||t[23]!==A||t[24]!==j?(M=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[k,A,j]}),t[22]=k,t[23]=A,t[24]=j,t[25]=M):M=t[25],M}function Uu(e){let t=(0,$.c)(32),{onSuccess:n,onCancel:r}=e,[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(null),d,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>()=>{u.current?.abort()},f=[],t[0]=d,t[1]=f):(d=t[0],f=t[1]),(0,Q.useEffect)(d,f);let p;t[2]!==n||t[3]!==i?(p=async function(){if(!i.trim()){l(`Paste a personal access token`);return}u.current?.abort();let e=new AbortController;u.current=e,s(!0),l(null);try{let t=await fetch(`/api/local-op/auth/pat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pat:i.trim()}),signal:e.signal});if(!t.ok){let e=`Invalid token — check that it has repo scope`;try{let n=await t.json(),r=fi.safeParse(n);r.success&&(e=r.data.title)}catch{}l(e),s(!1);return}if(!t.body){l(`Invalid token — check that it has repo scope`),s(!1);return}await fl(t.body,e=>{let t;try{t=JSON.parse(e)}catch{return`continue`}return t.type===`complete`?(n({login:t.login,name:t.name,email:t.email}),s(!1),`terminal`):`continue`})||l(`No response — try again`)}catch(e){let t=e;t instanceof Error&&t.name!==`AbortError`&&l(`Connection error — try again`)}s(!1)},t[2]=n,t[3]=i,t[4]=p):p=t[4];let m=p,h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(`a`,{href:`https://github.com/settings/tokens`,target:`_blank`,rel:`noopener noreferrer`,onClick:Gu,onAuxClick:Wu,className:`underline underline-offset-2`,children:`github.com/settings/tokens`}),t[5]=h):h=t[5];let g;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Create a token at`,` `,h,` `,`with `,(0,Z.jsx)(`code`,{className:`text-xs bg-muted px-1 rounded`,children:`repo`}),` scope.`]}),t[6]=g):g=t[6];let _;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>a(e.target.value),t[7]=_):_=t[7];let v;t[8]===m?v=t[9]:(v=e=>{e.key===`Enter`&&m()},t[8]=m,t[9]=v);let y;t[10]!==o||t[11]!==i||t[12]!==v?(y=(0,Z.jsx)(Po,{type:`password`,"aria-label":`Personal access token`,placeholder:`ghp_…`,value:i,onChange:_,disabled:o,onKeyDown:v}),t[10]=o,t[11]=i,t[12]=v,t[13]=y):y=t[13];let b;t[14]===c?b=t[15]:(b=c&&(0,Z.jsx)(`p`,{className:`text-sm text-destructive`,children:c}),t[14]=c,t[15]=b);let x;t[16]===m?x=t[17]:(x=()=>void m(),t[16]=m,t[17]=x);let S=o?`Validating`:`Add token`,C;t[18]!==o||t[19]!==x||t[20]!==S?(C=(0,Z.jsx)(Y,{className:`flex-1`,onClick:x,disabled:o,children:S}),t[18]=o,t[19]=x,t[20]=S,t[21]=C):C=t[21];let w;t[22]!==o||t[23]!==r?(w=(0,Z.jsx)(Y,{variant:`ghost`,onClick:r,disabled:o,children:`Cancel`}),t[22]=o,t[23]=r,t[24]=w):w=t[24];let T;t[25]!==C||t[26]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[C,w]}),t[25]=C,t[26]=w,t[27]=T):T=t[27];let E;return t[28]!==T||t[29]!==y||t[30]!==b?(E=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[g,y,b,T]}),t[28]=T,t[29]=y,t[30]=b,t[31]=E):E=t[31],E}function Wu(e){return Hi(e,`https://github.com/settings/tokens`)}function Gu(e){return Hi(e,`https://github.com/settings/tokens`)}function Ku(e){let t=(0,$.c)(27),{login:n,onSave:r,onSkip:i}=e,[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Before syncing, set your identity for git commits:`}),t[0]=l):l=t[0];let u=`Name (e.g. ${n})`,d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=e=>o(e.target.value),t[1]=d):d=t[1];let f;t[2]!==a||t[3]!==u?(f=(0,Z.jsx)(Po,{"aria-label":`Name`,placeholder:u,value:a,onChange:d}),t[2]=a,t[3]=u,t[4]=f):f=t[4];let p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>c(e.target.value),t[5]=p):p=t[5];let m;t[6]===s?m=t[7]:(m=(0,Z.jsx)(Po,{type:`email`,"aria-label":`Email`,placeholder:`Email`,value:s,onChange:p}),t[6]=s,t[7]=m);let h;t[8]!==s||t[9]!==a||t[10]!==r?(h=()=>r(a.trim(),s.trim()),t[8]=s,t[9]=a,t[10]=r,t[11]=h):h=t[11];let g;t[12]!==s||t[13]!==a?(g=!a.trim()||!s.trim(),t[12]=s,t[13]=a,t[14]=g):g=t[14];let _;t[15]!==h||t[16]!==g?(_=(0,Z.jsx)(Y,{className:`flex-1`,onClick:h,disabled:g,children:`Save`}),t[15]=h,t[16]=g,t[17]=_):_=t[17];let v;t[18]===i?v=t[19]:(v=(0,Z.jsx)(Y,{variant:`ghost`,onClick:i,children:`Skip`}),t[18]=i,t[19]=v);let y;t[20]!==v||t[21]!==_?(y=(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[_,v]}),t[20]=v,t[21]=_,t[22]=y):y=t[22];let b;return t[23]!==y||t[24]!==f||t[25]!==m?(b=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[l,f,m,y]}),t[23]=y,t[24]=f,t[25]=m,t[26]=b):b=t[26],b}function qu(e){let t=(0,$.c)(42),{open:n,onOpenChange:r,onSuccess:i,identityPrompt:a,reauth:o,transport:s}=e,c;t[0]===s?c=t[1]:(c=s??ml(),t[0]=s,t[1]=c);let l=c,[u,d]=(0,Q.useState)(`device`),[f,p]=(0,Q.useState)(`auth`),[m,h]=(0,Q.useState)(null),g,_;t[2]===n?(g=t[3],_=t[4]):(g=()=>{n&&(d(`device`),p(`auth`),h(null))},_=[n],t[2]=n,t[3]=g,t[4]=_),(0,Q.useEffect)(g,_);let v;t[5]!==a||t[6]!==r||t[7]!==i?(v=function(e){h(e),a&&(!e.name||!e.email)?p(`identity`):(p(`done`),i?.(e),r(!1),X.success(`Signed in as @${e.login}`))},t[5]=a,t[6]=r,t[7]=i,t[8]=v):v=t[8];let y=v,b;t[9]!==m||t[10]!==r||t[11]!==i?(b=function(e,t){fetch(`/api/local-op/auth/set-identity`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e,email:t})}).catch(Ju);let n={...m??{login:``},name:e,email:t};p(`done`),i?.(n),r(!1),X.success(`Signed in as @${n.login}`)},t[9]=m,t[10]=r,t[11]=i,t[12]=b):b=t[12];let x=b,S;t[13]!==m||t[14]!==r||t[15]!==i?(S=function(){m&&(p(`done`),i?.(m),r(!1),X.success(`Signed in as @${m.login}`))},t[13]=m,t[14]=r,t[15]=i,t[16]=S):S=t[16];let C=S,w;t[17]===r?w=t[18]:(w=function(){r(!1)},t[17]=r,t[18]=w);let T=w,E=o?`Re-authenticate with GitHub`:`Sign in to GitHub`,D;t[19]===E?D=t[20]:(D=(0,Z.jsx)(Ao,{children:(0,Z.jsx)(bo,{children:E})}),t[19]=E,t[20]=D);let O;t[21]!==y||t[22]!==T||t[23]!==l||t[24]!==f||t[25]!==u?(O=f===`auth`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex gap-1 border-b pb-2 mb-1`,children:[(0,Z.jsx)(Y,{variant:u===`device`?`secondary`:`ghost`,size:`sm`,onClick:()=>d(`device`),children:`GitHub App`}),(0,Z.jsx)(Y,{variant:u===`pat`?`secondary`:`ghost`,size:`sm`,onClick:()=>d(`pat`),children:`Token`})]}),u===`device`?(0,Z.jsx)(Hu,{onSuccess:y,onCancel:T,transport:l}):(0,Z.jsx)(Uu,{onSuccess:y,onCancel:T})]}),t[21]=y,t[22]=T,t[23]=l,t[24]=f,t[25]=u,t[26]=O):O=t[26];let k;t[27]!==m||t[28]!==x||t[29]!==C||t[30]!==f?(k=f===`identity`&&m&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Signed in as @`,m.login]}),(0,Z.jsx)(Ku,{login:m.login,onSave:x,onSkip:C})]}),t[27]=m,t[28]=x,t[29]=C,t[30]=f,t[31]=k):k=t[31];let A;t[32]!==k||t[33]!==O?(A=(0,Z.jsxs)(Do,{children:[O,k]}),t[32]=k,t[33]=O,t[34]=A):A=t[34];let j;t[35]!==A||t[36]!==D?(j=(0,Z.jsxs)(wo,{className:`sm:max-w-md`,children:[D,A]}),t[35]=A,t[36]=D,t[37]=j):j=t[37];let M;return t[38]!==r||t[39]!==n||t[40]!==j?(M=(0,Z.jsx)(jo,{open:n,onOpenChange:r,children:j}),t[38]=r,t[39]=n,t[40]=j,t[41]=M):M=t[41],M}function Ju(){}function Yu(){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(Xu),()=>{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 Xu(e){console.warn(`[use-update-channel] bridge.state.query() failed`,e)}function Zu(e){let t=(0,$.c)(2),{className:n}=e,{channel:r}=Yu();if(r!==`beta`)return null;let i;return t[0]===n?i=t[1]:(i=(0,Z.jsx)(Ge,{variant:`secondary`,"aria-label":`Beta channel`,"data-testid":`beta-badge`,className:n,children:`BETA`}),t[0]=n,t[1]=i),i}function Qu(e){switch(e){case`receiving`:return`Receiving objects`;case`resolving`:return`Resolving deltas`;case`checking`:return`Checking out files`;case`init`:return`Initializing project`;case`done`:return`Complete`;default:return`Cloning`}}function $u(e){let t=e.trim();if(/^[\w.-]+\/[\w.-]+$/.test(t))return t.split(`/`)[1];try{return new URL(t.replace(/^git@([^:]+):/,`https://$1/`)).pathname.replace(/\.git$/,``).split(`/`).pop()??`repo`}catch{return t.split(`/`).pop()?.replace(/\.git$/,``)??`repo`}}function ed(e){let t=(0,$.c)(99),{open:n,onOpenChange:r,onSignIn:i,onCloneComplete:a,transport:o,authQueryTransport:s,pickParentFolder:c,initialUrl:l}=e,u;t[0]===o?u=t[1]:(u=o??gl(),t[0]=o,t[1]=u);let d=u,f;t[2]===s?f=t[3]:(f=s??ul(),t[2]=s,t[3]=f);let p=f,m=c!==void 0,[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(!1),k=(0,Q.useRef)(null),A=(0,Q.useRef)(null),j;t[4]!==n||t[5]!==p?(j=()=>{if(!n)return;let e=!1;return p.status().then(t=>{e||E(t.authenticated)}).catch(()=>{e||E(!1)}),()=>{e=!0}},t[4]=n,t[5]=p,t[6]=j):j=t[6];let M;t[7]===n?M=t[8]:(M=[n],t[7]=n,t[8]=M),(0,Q.useEffect)(j,M);let N;t[9]!==T||t[10]!==n||t[11]!==p?(N=()=>{if(!T||!n)return;let e=!1;return S(!0),p.repos().then(t=>{e||(b(t.ok?t.repos:[]),S(!1))}).catch(()=>{e||(b([]),S(!1))}),()=>{e=!0}},t[9]=T,t[10]=n,t[11]=p,t[12]=N):N=t[12];let P;t[13]!==T||t[14]!==n?(P=[T,n],t[13]=T,t[14]=n,t[15]=P):P=t[15],(0,Q.useEffect)(N,P);let F,I;t[16]!==l||t[17]!==n||t[18]!==m?(F=()=>{if(!n||!l||(g(l),m))return;let e=$u(l);e&&v(`~/Documents/${e}`)},I=[n,l,m],t[16]=l,t[17]=n,t[18]=m,t[19]=F,t[20]=I):(F=t[19],I=t[20]),(0,Q.useEffect)(F,I);let L;t[21]===m?L=t[22]:(L=function(e){if(g(e),m)return;let t=$u(e);t&&v(`~/Documents/${t}`)},t[21]=m,t[22]=L);let R=L,z;t[23]===m?z=t[24]:(z=function(e){if(g(e.clone_url),m)return;let t=e.full_name.split(`/`)[1];v(`~/Documents/${t}`)},t[23]=m,t[24]=z);let B=z,V;t[25]!==_||t[26]!==a||t[27]!==r||t[28]!==c||t[29]!==d||t[30]!==h?(V=async function(){let e=h.trim();if(!e){X.error(`Enter a repository URL or owner/repo`);return}let t=_||``;if(c){O(!0);let n=await c();if(!n){O(!1);return}let r=$u(e);t=`${n.replace(/\/$/,``)}/${r}`}else O(!0);let n=X.loading(`Starting clone`,{duration:1/0});A.current=n;let i=d.start({url:e,dir:t});k.current=i.cancel;try{let e=i.events[Symbol.asyncIterator](),t=await e.next();for(;!t.done;){let i=t.value;if(i.type===`progress`)X.loading(`${Qu(i.phase)} — ${i.pct}%`,{id:n});else if(i.type===`complete`){X.success(`Clone complete — opening project`,{id:n}),r(!1),O(!1),k.current=null;let e=`port`in i?i.port:void 0;a?a({port:e,dir:i.dir}):e!==void 0&&(window.location.href=`http://localhost:${e}`);return}else if(i.type===`error`){X.error(`Clone failed: ${i.message}`,{id:n}),O(!1),k.current=null;return}t=await e.next()}X.error(`Clone stream ended unexpectedly — check if the clone completed`,{id:n}),O(!1),k.current=null}catch(e){console.error(`[CloneDialog] clone iteration failed:`,e),X.error(`Clone failed — connection error`,{id:n}),O(!1),k.current=null}},t[25]=_,t[26]=a,t[27]=r,t[28]=c,t[29]=d,t[30]=h,t[31]=V):V=t[31];let H=V,U;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(U=function(){k.current?.(),k.current=null,O(!1),X.dismiss(A.current??void 0)},t[32]=U):U=t[32];let W=U,G;t[33]!==D||t[34]!==r||t[35]!==m?(G=function(e){D||(r(e),e||(g(``),m||v(``),w(``)))},t[33]=D,t[34]=r,t[35]=m,t[36]=G):G=t[36];let K=G,q,ee,te,ne,re,ie,ae,oe,se,ce;if(t[37]!==D||t[38]!==K||t[39]!==B||t[40]!==R||t[41]!==T||t[42]!==x||t[43]!==n||t[44]!==C||t[45]!==y||t[46]!==h){let e=y?.filter(e=>e.full_name.toLowerCase().includes(C.toLowerCase()));te=jo,se=n,ce=K,ee=wo,ae=`sm:max-w-lg`,t[57]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,Z.jsx)(Ao,{children:(0,Z.jsx)(bo,{children:`Clone from GitHub`})}),t[57]=oe):oe=t[57],q=Do,ne=`flex flex-col gap-4`;let r;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(`label`,{htmlFor:`clone-url`,className:`text-sm font-medium`,children:`Repository URL or owner/repo`}),t[58]=r):r=t[58];let i;t[59]===R?i=t[60]:(i=e=>R(e.target.value),t[59]=R,t[60]=i),t[61]!==D||t[62]!==i||t[63]!==h?(re=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r,(0,Z.jsx)(Po,{id:`clone-url`,placeholder:`https://github.com/owner/repo or owner/repo`,value:h,onChange:i,disabled:D})]}),t[61]=D,t[62]=i,t[63]=h,t[64]=re):re=t[64],ie=T&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`label`,{htmlFor:`repo-filter`,className:`text-sm font-medium`,children:`Your repositories`}),(0,Z.jsx)(Po,{id:`repo-filter`,"aria-label":`Filter repositories`,placeholder:`Filter repositories`,value:C,onChange:e=>w(e.target.value),disabled:D||x&&y===null}),(0,Z.jsx)(`div`,{className:`border rounded-md max-h-40 overflow-y-auto subtle-scrollbar`,"aria-busy":x&&y===null,children:x&&y===null?(0,Z.jsxs)(`output`,{className:`flex flex-col gap-1.5 px-3 py-2`,"aria-label":`Loading repositories`,children:[(0,Z.jsx)(Ma,{className:`h-4 w-2/3`}),(0,Z.jsx)(Ma,{className:`h-4 w-1/2`}),(0,Z.jsx)(Ma,{className:`h-4 w-3/4`}),(0,Z.jsx)(Ma,{className:`h-4 w-2/5`}),(0,Z.jsx)(Ma,{className:`h-4 w-3/5`})]}):e?.length===0?(0,Z.jsx)(`p`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:y?.length===0?`No repositories found.`:`No matches.`}):e?.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`w-full text-left px-3 py-1.5 text-sm hover:bg-muted flex items-center gap-2 truncate disabled:opacity-50`,onClick:()=>B(e),disabled:D,children:[e.private&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:`🔒`}),e.full_name]},e.full_name))})]}),t[37]=D,t[38]=K,t[39]=B,t[40]=R,t[41]=T,t[42]=x,t[43]=n,t[44]=C,t[45]=y,t[46]=h,t[47]=q,t[48]=ee,t[49]=te,t[50]=ne,t[51]=re,t[52]=ie,t[53]=ae,t[54]=oe,t[55]=se,t[56]=ce}else q=t[47],ee=t[48],te=t[49],ne=t[50],re=t[51],ie=t[52],ae=t[53],oe=t[54],se=t[55],ce=t[56];let le;t[65]!==D||t[66]!==T||t[67]!==i?(le=!T&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:`Browse your repos:`}),(0,Z.jsx)(Y,{variant:`link`,className:`h-auto p-0`,onClick:()=>i?.(),disabled:D,children:`Sign in to GitHub`})]}),t[65]=D,t[66]=T,t[67]=i,t[68]=le):le=t[68];let J;t[69]!==D||t[70]!==_||t[71]!==m?(J=!m&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`label`,{htmlFor:`clone-path`,className:`text-sm font-medium`,children:`Local path`}),(0,Z.jsx)(Po,{id:`clone-path`,placeholder:`~/Documents/repo-name`,value:_,onChange:e=>v(e.target.value),disabled:D})]}),t[69]=D,t[70]=_,t[71]=m,t[72]=J):J=t[72];let ue;t[73]!==ne||t[74]!==re||t[75]!==ie||t[76]!==le||t[77]!==J?(ue=(0,Z.jsxs)(`div`,{className:ne,children:[re,ie,le,J]}),t[73]=ne,t[74]=re,t[75]=ie,t[76]=le,t[77]=J,t[78]=ue):ue=t[78];let de;t[79]!==q||t[80]!==ue?(de=(0,Z.jsx)(q,{children:ue}),t[79]=q,t[80]=ue,t[81]=de):de=t[81];let fe;t[82]!==D||t[83]!==H||t[84]!==K||t[85]!==h||t[86]!==m?(fe=(0,Z.jsx)(Oo,{children:D?(0,Z.jsx)(Y,{variant:`outline`,className:`font-mono uppercase`,onClick:W,children:`Cancel`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{variant:`outline`,className:`font-mono uppercase`,onClick:()=>K(!1),children:`Cancel`}),(0,Z.jsx)(Y,{onClick:()=>void H(),disabled:!h.trim(),"aria-describedby":m?`clone-picker-hint`:void 0,children:`Clone`}),m&&(0,Z.jsx)(`span`,{id:`clone-picker-hint`,className:`sr-only`,children:`Opens a folder picker to choose where to clone the repository.`})]})}),t[82]=D,t[83]=H,t[84]=K,t[85]=h,t[86]=m,t[87]=fe):fe=t[87];let pe;t[88]!==ee||t[89]!==ae||t[90]!==oe||t[91]!==de||t[92]!==fe?(pe=(0,Z.jsxs)(ee,{className:ae,children:[oe,de,fe]}),t[88]=ee,t[89]=ae,t[90]=oe,t[91]=de,t[92]=fe,t[93]=pe):pe=t[93];let me;return t[94]!==te||t[95]!==se||t[96]!==ce||t[97]!==pe?(me=(0,Z.jsx)(te,{open:se,onOpenChange:ce,children:pe}),t[94]=te,t[95]=se,t[96]=ce,t[97]=pe,t[98]=me):me=t[98],me}var td=(0,Q.lazy)(()=>n(()=>import(`./ConsentDialogBody-Dfx6N7pC.js`),__vite__mapDeps([5,1,6,7,8,9,10,11,12]),import.meta.url));function nd(){let e=(0,$.c)(1);if(!(0,Q.useSyncExternalStore)(Jo.subscribe,id,rd))return null;let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(td,{})}),e[0]=t):t=e[0],t}function rd(){return!1}function id(){return Jo.getSnapshot()!==null}var ad=180,od=5e3;function sd(e,t){if(e===``||t===``)return``;let n=e.includes(`\\`)&&!e.includes(`/`)?`\\`:`/`;return`${e.replace(/[/\\]+$/,``)}${n}${t}`}function cd(e){if(e===``)return``;let t=e.split(/[/\\]/).filter(Boolean);return t.length>0?t[t.length-1]??e:e}function ld(e){if(e===``)return``;let t=e.replace(/[/\\]+$/,``);if(t===``)return``;let n=t.match(/[/\\][^/\\]+$/);if(n===null)return``;let r=t.length-n[0].length;return r===0?t[0]??``:t.slice(0,r)}function ud(e){let{parent:t,sanitizedName:n,enclosingProject:r,enclosingGit:i,targetState:a}=e;return t===``||n===``?{kind:`idle`}:r===null?i===null?a===`exists-nonempty`?{kind:`block-nonempty`}:{kind:`free`}:{kind:`confirm-git`,gitRoot:i.gitRoot}:{kind:`block-nested`,rootPath:r.rootPath}}function dd(e){let t=e instanceof Error?e.message:String(e);for(let e of hr)if(t.startsWith(`${e}:`)||t.includes(`${e}: `))return e===`nested-project`||e===`target-not-empty`?{reason:e}:{reason:e,message:t};return{reason:`unknown`,message:t}}function fd(e){switch(e.reason){case`nested-project`:return`A project already exists at this location. Pick a different parent folder.`;case`target-not-empty`:return`A non-empty folder already exists at this path. Pick a different folder.`;case`invalid-args`:return`Invalid input — pick a different folder.`;case`mkdir-failed`:return`Could not create the project folder. Pick a different folder.`;case`git-init-failed`:return`Project folder created, but git init failed. Try again.`;case`init-failed`:return`Could not write project files. Try a different location.`;case`discovery-failed`:return`Could not finalize project setup. Try again.`;case`unknown`:return`Could not create project. Try again or pick a different location.`}}function pd(e){let t=(0,$.c)(152),{open:n,onOpenChange:r,bridge:i}=e,a=(0,Q.useId)(),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(bd),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f={kind:`idle`},t[0]=f):f=t[0];let[p,m]=(0,Q.useState)(f),[h,g]=(0,Q.useState)(`idle`),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(null),x;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(x={kind:`idle`},t[1]=x):x=t[1];let[S,C]=(0,Q.useState)(x),[w,T]=(0,Q.useState)(0),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(``),A;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(A=new Set,t[2]=A):A=t[2];let j=(0,Q.useRef)(A),M=(0,Q.useRef)(null),N=(0,Q.useRef)(null),P=(0,Q.useRef)(null),F=(0,Q.useRef)(0),I,L;t[3]!==i||t[4]!==n?(I=()=>{if(!n)return;j.current.clear(),b(null),m({kind:`idle`}),g(`idle`),v(!1),s(``),d(new Set(er)),C({kind:`idle`}),D(!1),k(``),F.current+=1;let e=!1;l(``),i.fs.defaultProjectsRoot().then(t=>{e||l(t)}).catch(yd);let t=requestAnimationFrame(()=>{P.current?.focus()});return()=>{e=!0,cancelAnimationFrame(t)}},L=[n,i],t[3]=i,t[4]=n,t[5]=I,t[6]=L):(I=t[5],L=t[6]),(0,Q.useEffect)(I,L);let R;t[7]!==i||t[8]!==E||t[9]!==n||t[10]!==o||t[11]!==O?(R=()=>{if(!n)return;if(N.current!==null&&clearTimeout(N.current),M.current!==null&&M.current.abort(),o===``){m({kind:`idle`}),g(`idle`);return}let e=O.trim(),t=E&&e!==``,r=t?o:ld(o),a=yr(t?e:cd(o));if(r===``||a===``){m({kind:`idle`}),g(`idle`);return}let s=sd(r,a),c=new AbortController;return M.current=c,N.current=setTimeout(()=>{g(`in-flight`),Promise.all([i.fs.findEnclosingProjectRoot(r),i.fs.findEnclosingGitRoot(r),i.fs.folderState(s)]).then(e=>{let[t,n,i]=e;if(c.signal.aborted)return;g(`idle`);let o=ud({parent:r,sanitizedName:a,enclosingProject:t,enclosingGit:n,targetState:i});m(o),o.kind===`block-nonempty`&&D(!0)}).catch(e=>{c.signal.aborted||(console.warn(`[CreateProjectDialog] cascade probe failed:`,e),g(`idle`),m({kind:`free`}))})},ad),()=>{N.current!==null&&clearTimeout(N.current),c.abort()}},t[7]=i,t[8]=E,t[9]=n,t[10]=o,t[11]=O,t[12]=R):R=t[12];let z;t[13]!==i||t[14]!==E||t[15]!==n||t[16]!==o||t[17]!==w||t[18]!==O?(z=[n,o,i,w,E,O],t[13]=i,t[14]=E,t[15]=n,t[16]=o,t[17]=w,t[18]=O,t[19]=z):z=t[19],(0,Q.useEffect)(R,z);let B,V;t[20]===n?(B=t[21],V=t[22]):(B=()=>{if(!n)return;let e=()=>T(vd);return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},V=[n],t[20]=n,t[21]=B,t[22]=V),(0,Q.useEffect)(B,V);let H=(0,Q.useRef)(`idle`),U,W;t[23]===h?(U=t[24],W=t[25]):(U=()=>{H.current=h},W=[h],t[23]=h,t[24]=U,t[25]=W),(0,Q.useEffect)(U,W);let G,K;t[26]!==p.kind||t[27]!==n?(G=()=>{if(!n||p.kind!==`confirm-git`)return;let e=setInterval(()=>{H.current!==`in-flight`&&T(_d)},od);return()=>clearInterval(e)},K=[n,p.kind],t[26]=p.kind,t[27]=n,t[28]=G,t[29]=K):(G=t[28],K=t[29]),(0,Q.useEffect)(G,K);let q;t[30]!==p.gitRoot||t[31]!==p.kind||t[32]!==S.gitRoot||t[33]!==S.kind?(q=()=>{if(p.kind!==`confirm-git`){S.kind!==`idle`&&(F.current+=1,C({kind:`idle`}));return}S.kind===`confirming`&&S.gitRoot!==p.gitRoot&&C({kind:`idle`}),S.kind===`pending`&&S.gitRoot!==p.gitRoot&&(F.current+=1,C({kind:`idle`}))},t[30]=p.gitRoot,t[31]=p.kind,t[32]=S.gitRoot,t[33]=S.kind,t[34]=q):q=t[34];let ee;t[35]!==p||t[36]!==S?(ee=[p,S],t[35]=p,t[36]=S,t[37]=ee):ee=t[37],(0,Q.useEffect)(q,ee);let te;t[38]!==i||t[39]!==p.kind||t[40]!==n?(te=()=>{if(!n)return;let e=null;p.kind===`block-nested`?e=`nested`:p.kind===`block-nonempty`?e=`nonempty`:p.kind===`confirm-git`&&(e=`git-confirm`),e!==null&&(j.current.has(e)||(j.current.add(e),i.project.recordCreateNewBannerShown(e).catch(gd)))},t[38]=i,t[39]=p.kind,t[40]=n,t[41]=te):te=t[41];let ne;t[42]!==i||t[43]!==p||t[44]!==n?(ne=[n,p,i],t[42]=i,t[43]=p,t[44]=n,t[45]=ne):ne=t[45],(0,Q.useEffect)(te,ne);let re,ie,ae,oe,se,ce,le;t[46]!==E||t[47]!==o||t[48]!==O?(ce=O.trim(),se=E&&ce!==``,re=o===``?``:se?ce:cd(o),oe=o===``?``:yr(re),ie=o!==``&&oe!==re&&oe!==``,ae=o!==``&&re!==``&&oe===``,le=se?sd(o,oe):o,t[46]=E,t[47]=o,t[48]=O,t[49]=re,t[50]=ie,t[51]=ae,t[52]=oe,t[53]=se,t[54]=ce,t[55]=le):(re=t[49],ie=t[50],ae=t[51],oe=t[52],se=t[53],ce=t[54],le=t[55]);let J=le,ue=!_&&o!==``&&oe!==``&&h===`idle`&&(p.kind===`free`||p.kind===`confirm-git`),de;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(de=function(e){d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[56]=de):de=t[56];let fe=de,pe;t[57]!==i||t[58]!==c?(pe=async function(){try{let e=await i.dialog.openFolder(c===``?void 0:{defaultPath:c});if(e===null)return;s(e),T(hd),b(null),D(!1),k(``)}catch(e){console.warn(`[CreateProjectDialog] dialog.openFolder failed:`,e)}},t[57]=i,t[58]=c,t[59]=pe):pe=t[59];let me=pe,he;t[60]!==i||t[61]!==ue||t[62]!==u||t[63]!==r||t[64]!==o||t[65]!==oe||t[66]!==se?(he=async function(e){if(e.preventDefault(),ue){v(!0),b(null);try{await i.project.createNew({parent:se?o:ld(o),name:oe,editors:Array.from(u)}),r(!1)}catch(e){b(dd(e)),v(!1)}}},t[60]=i,t[61]=ue,t[62]=u,t[63]=r,t[64]=o,t[65]=oe,t[66]=se,t[67]=he):he=t[67];let ge=he,_e;t[68]!==_||t[69]!==r?(_e=function(e){_||r(e)},t[68]=_,t[69]=r,t[70]=_e):_e=t[70];let ve=_e,ye;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ye=async function(e){C({kind:`confirming`,gitRoot:e})},t[71]=ye):ye=t[71];let be=ye,xe;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(xe=async function(){C({kind:`idle`})},t[72]=xe):xe=t[72];let Se=xe,Ce;t[73]===i?Ce=t[74]:(Ce=async function(e){let t=F.current+1;F.current=t,C({kind:`pending`,gitRoot:e});try{if(await i.fs.removeGitFolder(e),F.current!==t)return;T(md),C({kind:`idle`})}catch(e){let n=e;if(F.current!==t)return;let r=n instanceof Error?n.message:String(n);console.error(`[CreateProjectDialog] bridge.fs.removeGitFolder failed:`,n),C({kind:`error`,message:r})}},t[73]=i,t[74]=Ce);let we=Ce,Te;t[75]!==i||t[76]!==r?(Te=async function(e){r(!1);try{await i.project.open({path:e,target:`new-window`,entryPoint:`create-new-nested-redirect`})}catch(e){console.warn(`[CreateProjectDialog] project.open failed:`,e)}},t[75]=i,t[76]=r,t[77]=Te):Te=t[77];let Ee=Te,De;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,Z.jsxs)(Ao,{children:[(0,Z.jsx)(bo,{children:`Create new project`}),(0,Z.jsx)(vo,{children:`Create a new Open Knowledge project in the folder of your choice.`})]}),t[78]=De):De=t[78];let Oe;t[79]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,Z.jsx)(Go,{htmlFor:`create-location`,children:`Location`}),t[79]=Oe):Oe=t[79];let ke;t[80]===me?ke=t[81]:(ke=()=>void me(),t[80]=me,t[81]=ke);let Ae;t[82]!==_||t[83]!==ke?(Ae=(0,Z.jsx)(`div`,{className:`flex items-stretch gap-2`,children:(0,Z.jsx)(Y,{id:`create-location`,ref:P,type:`button`,variant:`outline`,disabled:_,onClick:ke,"aria-describedby":`create-target-caption`,"data-testid":`create-browse`,children:`Browse`})}),t[82]=_,t[83]=ke,t[84]=Ae):Ae=t[84];let je=J===``?`Click Browse to pick or create a project folder.`:J,Me;t[85]===je?Me=t[86]:(Me=(0,Z.jsx)(`p`,{id:`create-target-caption`,className:`text-1sm text-muted-foreground`,"aria-live":`polite`,"data-testid":`create-target-caption`,children:je}),t[85]=je,t[86]=Me);let Ne;t[87]!==Ae||t[88]!==Me?(Ne=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Oe,Ae,Me]}),t[87]=Ae,t[88]=Me,t[89]=Ne):Ne=t[89];let Pe;t[90]!==_||t[91]!==p.kind||t[92]!==E||t[93]!==ie||t[94]!==ae||t[95]!==oe||t[96]!==se||t[97]!==O||t[98]!==ce?(Pe=E?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,"data-testid":`create-subfolder-rescue`,children:[(0,Z.jsx)(Go,{htmlFor:`create-subfolder-name`,children:`Subfolder name`}),(0,Z.jsx)(Po,{id:`create-subfolder-name`,value:O,placeholder:`my-project`,onChange:e=>k(e.target.value),disabled:_,autoFocus:!0,"aria-invalid":se&&(ae||p.kind===`block-nonempty`),"data-testid":`create-subfolder-input`}),ce===``?(0,Z.jsx)(`p`,{role:`status`,"aria-live":`polite`,className:`text-1sm text-muted-foreground`,"data-testid":`create-subfolder-empty-error`,children:`This folder already has files. Add a name to create a new subfolder inside it.`}):ae?(0,Z.jsx)(`p`,{role:`alert`,className:`text-1sm text-destructive`,"data-testid":`create-subfolder-erased-error`,children:`This name has no characters that are safe for a folder identifier. Try a name with at least one letter or number.`}):p.kind===`block-nonempty`?(0,Z.jsxs)(`p`,{role:`alert`,className:`text-1sm text-destructive`,"data-testid":`create-subfolder-taken-error`,children:[`A folder named `,(0,Z.jsx)(`code`,{className:`font-mono break-all`,children:oe}),` already has files at this location. Pick a different name.`]}):ie?(0,Z.jsxs)(`p`,{className:`text-1sm text-muted-foreground`,children:[`Will be saved as `,(0,Z.jsx)(`code`,{className:`font-mono break-all`,children:oe}),`.`]}):null]}):null,t[90]=_,t[91]=p.kind,t[92]=E,t[93]=ie,t[94]=ae,t[95]=oe,t[96]=se,t[97]=O,t[98]=ce,t[99]=Pe):Pe=t[99];let Fe;t[100]!==E||t[101]!==re||t[102]!==ie||t[103]!==oe?(Fe=!E&&ie?(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-900 dark:border-amber-700 dark:bg-amber-950 dark:text-amber-200`,"data-testid":`create-banner-sanitize-diverged`,children:[(0,Z.jsx)(`code`,{className:`font-mono break-all`,children:re}),` has characters unsafe for the on-disk identifier, so the project will be created as`,` `,(0,Z.jsx)(`code`,{className:`font-mono break-all`,children:oe}),`. Click Browse to pick a safer name.`]}):null,t[100]=E,t[101]=re,t[102]=ie,t[103]=oe,t[104]=Fe):Fe=t[104];let Ie;t[105]!==E||t[106]!==re||t[107]!==ae?(Ie=!E&&ae?(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-900 dark:border-amber-700 dark:bg-amber-950 dark:text-amber-200`,"data-testid":`create-banner-sanitize-erased`,children:[`The folder name `,(0,Z.jsx)(`code`,{className:`font-mono break-all`,children:re}),` can't be used as a project identifier — it has no characters left after sanitization. Click Browse to pick a folder whose name contains at least one alphanumeric character.`]}):null,t[105]=E,t[106]=re,t[107]=ae,t[108]=Ie):Ie=t[108];let Le;t[109]!==p||t[110]!==we||t[111]!==Ee||t[112]!==S?(Le=(0,Z.jsx)(xd,{cascade:p,onOpenNested:Ee,removeGitState:S,onRequestRemoveGit:be,onCancelRemoveGit:Se,onConfirmRemoveGit:we}),t[109]=p,t[110]=we,t[111]=Ee,t[112]=S,t[113]=Le):Le=t[113];let Re,ze;t[114]===Symbol.for(`react.memo_cache_sentinel`)?(Re=(0,Z.jsx)(`legend`,{className:`text-sm font-medium`,children:`Connect to AI tools`}),ze=(0,Z.jsx)(`p`,{className:`text-1sm text-muted-foreground`,children:`Each selected tool gets an Open Knowledge MCP entry.`}),t[114]=Re,t[115]=ze):(Re=t[114],ze=t[115]);let Be;t[116]!==_||t[117]!==u?(Be=er.map(e=>{let t=`create-editor-${e}`;return(0,Z.jsxs)(Go,{htmlFor:t,className:`text-sm font-normal`,children:[(0,Z.jsx)(Ro,{id:t,checked:u.has(e),onCheckedChange:()=>fe(e),disabled:_,"data-testid":`create-editor-${e}`}),(0,Z.jsx)(`span`,{children:lr[e]})]},e)}),t[116]=_,t[117]=u,t[118]=Be):Be=t[118];let Ve;t[119]===Be?Ve=t[120]:(Ve=(0,Z.jsxs)(`fieldset`,{className:`flex flex-col space-y-2 pb-2`,children:[Re,ze,Be]}),t[119]=Be,t[120]=Ve);let He;t[121]===y?He=t[122]:(He=y===null?null:(0,Z.jsx)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,"data-testid":`create-submit-error`,children:fd(y)}),t[121]=y,t[122]=He);let Ue;t[123]!==a||t[124]!==ge||t[125]!==Ne||t[126]!==Pe||t[127]!==Fe||t[128]!==Ie||t[129]!==Le||t[130]!==Ve||t[131]!==He?(Ue=(0,Z.jsx)(Do,{className:`space-y-4`,children:(0,Z.jsxs)(`form`,{id:a,onSubmit:ge,"data-testid":`create-project-form`,className:`space-y-4`,children:[Ne,Pe,Fe,Ie,Le,Ve,He]})}),t[123]=a,t[124]=ge,t[125]=Ne,t[126]=Pe,t[127]=Fe,t[128]=Ie,t[129]=Le,t[130]=Ve,t[131]=He,t[132]=Ue):Ue=t[132];let We;t[133]===r?We=t[134]:(We=()=>r(!1),t[133]=r,t[134]=We);let Ge;t[135]!==_||t[136]!==We?(Ge=(0,Z.jsx)(Y,{type:`button`,variant:`outline`,className:`font-mono uppercase`,onClick:We,disabled:_,"data-testid":`create-cancel`,children:`Cancel`}),t[135]=_,t[136]=We,t[137]=Ge):Ge=t[137];let Ke=!ue,qe=_?`Creating`:`Create`,Je;t[138]!==a||t[139]!==Ke||t[140]!==qe?(Je=(0,Z.jsx)(Y,{type:`submit`,form:a,disabled:Ke,"data-testid":`create-submit`,children:qe}),t[138]=a,t[139]=Ke,t[140]=qe,t[141]=Je):Je=t[141];let Ye;t[142]!==Ge||t[143]!==Je?(Ye=(0,Z.jsxs)(Oo,{children:[Ge,Je]}),t[142]=Ge,t[143]=Je,t[144]=Ye):Ye=t[144];let Xe;t[145]!==Ue||t[146]!==Ye?(Xe=(0,Z.jsxs)(wo,{className:`sm:max-w-lg`,"data-testid":`create-project-dialog`,children:[De,Ue,Ye]}),t[145]=Ue,t[146]=Ye,t[147]=Xe):Xe=t[147];let Ze;return t[148]!==ve||t[149]!==n||t[150]!==Xe?(Ze=(0,Z.jsx)(jo,{open:n,onOpenChange:ve,children:Xe}),t[148]=ve,t[149]=n,t[150]=Xe,t[151]=Ze):Ze=t[151],Ze}function md(e){return e+1}function hd(e){return e+1}function gd(){}function _d(e){return e+1}function vd(e){return e+1}function yd(e){console.warn(`[CreateProjectDialog] defaultProjectsRoot probe failed:`,e)}function bd(){return new Set(er)}function xd(e){let t=(0,$.c)(32),{cascade:n,onOpenNested:r,removeGitState:i,onRequestRemoveGit:a,onCancelRemoveGit:o,onConfirmRemoveGit:s}=e;if(n.kind===`idle`||n.kind===`free`||n.kind===`block-nonempty`)return null;if(n.kind===`block-nested`){let e;t[0]===n.rootPath?e=t[1]:(e=cd(n.rootPath),t[0]=n.rootPath,t[1]=e);let i=e,a;t[2]===n.rootPath?a=t[3]:(a=(0,Z.jsxs)(`p`,{className:`mb-2`,children:[`Can't nest projects. An Open Knowledge project already exists at`,` `,(0,Z.jsx)(`code`,{className:`font-mono break-all`,children:n.rootPath}),`. Choose a location outside it, or open that project instead.`]}),t[2]=n.rootPath,t[3]=a);let o;t[4]!==n.rootPath||t[5]!==r?(o=()=>r(n.rootPath),t[4]=n.rootPath,t[5]=r,t[6]=o):o=t[6];let s;t[7]!==i||t[8]!==o?(s=(0,Z.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:o,"data-testid":`create-banner-nested-open`,children:[`Open `,i]}),t[7]=i,t[8]=o,t[9]=s):s=t[9];let c;return t[10]!==a||t[11]!==s?(c=(0,Z.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,"data-testid":`create-banner-nested`,children:[a,s]}),t[10]=a,t[11]=s,t[12]=c):c=t[12],c}if(n.kind===`confirm-git`){let{gitRoot:e}=n,r;if(t[13]!==e){let n;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(n=/\/+$/,t[15]=n):n=t[15],r=e.replace(n,``),t[13]=e,t[14]=r}else r=t[14];let c=`${r}/.git`,l;t[16]===e?l=t[17]:(l=(0,Z.jsx)(`code`,{children:e}),t[16]=e,t[17]=l);let u;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(`code`,{children:`.git`}),t[18]=u):u=t[18];let d;t[19]===l?d=t[20]:(d=(0,Z.jsxs)(`p`,{children:[`Open Knowledge will be initialized at `,l,` — the parent of your new folder, because it contains a `,u,` folder (one project per git repo).`]}),t[19]=l,t[20]=d);let f;t[21]!==e||t[22]!==o||t[23]!==s||t[24]!==a||t[25]!==i.kind||t[26]!==i.message||t[27]!==c?(f=i.kind===`idle`||i.kind===`error`?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1`,children:[(0,Z.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(e),"data-testid":`create-banner-git-remove`,children:[`Remove the parent `,(0,Z.jsx)(`code`,{children:`.git`}),` folder`]}),i.kind===`error`?(0,Z.jsxs)(`p`,{role:`alert`,className:`text-xs text-destructive`,"data-testid":`create-banner-git-remove-error`,children:[`Couldn't remove `,(0,Z.jsx)(`code`,{children:c}),`: `,i.message]}):null]}):(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2 rounded border border-blue-400/60 bg-white/40 p-2 dark:border-blue-600/60 dark:bg-black/20`,"data-testid":`create-banner-git-remove-confirm`,children:[(0,Z.jsxs)(`p`,{className:`text-xs`,children:[`Permanently deletes `,(0,Z.jsx)(`code`,{className:`font-mono break-all`,children:c}),` and all its git history. Working files stay in place. If the parent git repo is intentional (e.g. you cloned it), cancel and pick a location outside it.`]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(Y,{type:`button`,variant:`destructive`,size:`sm`,disabled:i.kind===`pending`,onClick:()=>s(e),"data-testid":`create-banner-git-remove-confirm-button`,children:i.kind===`pending`?`Removing…`:`Delete ${c}`}),(0,Z.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:i.kind===`pending`,onClick:o,"data-testid":`create-banner-git-remove-cancel`,children:`Cancel`})]})]}),t[21]=e,t[22]=o,t[23]=s,t[24]=a,t[25]=i.kind,t[26]=i.message,t[27]=c,t[28]=f):f=t[28];let p;return t[29]!==d||t[30]!==f?(p=(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`rounded-md border border-blue-300 bg-blue-50 px-3 py-2 text-sm text-blue-900 dark:border-blue-700 dark:bg-blue-950 dark:text-blue-200`,"data-testid":`create-banner-git-confirm`,children:[d,f]}),t[29]=d,t[30]=f,t[31]=p):p=t[31],p}return null}function Sd(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 Cd(e){let t=(0,$.c)(5),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`Open Knowledge icon`}),t[0]=n):n=t[0];let r;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsxs)(`g`,{filter:`url(#filter0_d_ok)`,children:[(0,Z.jsx)(`path`,{d:`M66.8902 16.1017C58.2694 3.86669 46.1739 -0.690239 29.9182 2.17749C21.3995 3.67813 13.4602 9.555 8.67934 17.9009C3.93974 26.1701 2.98514 35.6533 6.05714 43.9166C9.31574 52.6868 16.7168 58.4752 24.2299 63.4231C25.7973 64.4562 26.1351 65.7172 26.3551 68.9896C26.5221 71.4625 26.799 75.6011 30.6842 77.7204C31.8176 78.3372 33.0648 78.6515 34.3946 78.6515C37.0796 78.6515 39.4033 77.3649 40.5189 76.7482C47.1049 73.1046 68.8878 59.7147 72.6453 40.4027C74.3444 31.6679 70.9797 21.9019 66.8922 16.1017H66.8902Z`,fill:`white`}),(0,Z.jsx)(`path`,{d:`M37.4214 71.154C28.7888 75.929 36.787 64.0397 27.7458 58.0843C21.6372 54.0616 14.788 49.0568 12.0499 41.6911C6.74463 27.4192 17.5438 10.8473 31.028 8.47262C45.1977 5.97613 54.6946 9.8947 61.6635 19.7844C65.2089 24.8167 67.6013 32.8365 66.3658 39.1828C63.6906 52.9341 49.073 64.7075 37.4214 71.154Z`,fill:`#69A3FF`}),(0,Z.jsx)(`path`,{d:`M52.7244 29.2638C53.4665 28.5217 54.6697 28.5217 55.4119 29.2638V29.2638C56.154 30.0059 56.154 31.2091 55.4119 31.9513L49.2589 38.1042L46.5715 35.4167L52.7244 29.2638Z`,fill:`#D5E5FF`}),(0,Z.jsx)(`path`,{d:`M55.4119 38.8821C56.154 39.6242 56.154 40.8274 55.4119 41.5696V41.5696C54.6698 42.3117 53.4665 42.3117 52.7244 41.5696L46.5715 35.4166L49.259 32.7292L55.4119 38.8821Z`,fill:`#D5E5FF`})]}),t[1]=r):r=t[1];let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`defs`,{children:(0,Z.jsxs)(`filter`,{id:`filter0_d_ok`,x:`-9.53674e-07`,y:`-0.0799994`,width:`77.3817`,height:`85.8743`,filterUnits:`userSpaceOnUse`,colorInterpolationFilters:`sRGB`,children:[(0,Z.jsx)(`feFlood`,{floodOpacity:`0`,result:`BackgroundImageFix`}),(0,Z.jsx)(`feColorMatrix`,{in:`SourceAlpha`,type:`matrix`,values:`0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0`,result:`hardAlpha`}),(0,Z.jsx)(`feOffset`,{dy:`2.85714`}),(0,Z.jsx)(`feGaussianBlur`,{stdDeviation:`2.14286`}),(0,Z.jsx)(`feComposite`,{in2:`hardAlpha`,operator:`out`}),(0,Z.jsx)(`feColorMatrix`,{type:`matrix`,values:`0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0`}),(0,Z.jsx)(`feBlend`,{mode:`normal`,in2:`BackgroundImageFix`,result:`effect1_dropShadow_ok`}),(0,Z.jsx)(`feBlend`,{mode:`normal`,in:`SourceGraphic`,in2:`effect1_dropShadow_ok`,result:`shape`})]})}),t[2]=i):i=t[2];let a;return t[3]===e?a=t[4]:(a=(0,Z.jsxs)(`svg`,{role:`img`,"aria-label":`Open Knowledge icon`,fill:`none`,height:24,width:24,viewBox:`0 0 78 80`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n,r,i]}),t[3]=e,t[4]=a),a}var wd=(0,Q.lazy)(()=>n(()=>import(`./McpConsentDialogBody-fka4wJP7.js`),__vite__mapDeps([13,1,6,7,8,9,14,15]),import.meta.url));function Td(){let e=(0,$.c)(1);if(!(0,Q.useSyncExternalStore)(Yo.subscribe,Dd,Ed))return null;let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(wd,{})}),e[0]=t):t=e[0],t}function Ed(){return!1}function Dd(){return Yo.getSnapshot()!==null}function Od(e){return`https://github.com/${e.owner}/${e.repo}.git`}function kd(e){let t=e.toLowerCase().trim();return t.endsWith(`/`)&&(t=t.slice(0,-1)),t.endsWith(`.git`)&&(t=t.slice(0,-4)),t}function Ad(e,t){let n=kd(Od(t));for(let t of e)if(t.missing!==!0&&t.gitRemoteUrl&&kd(t.gitRemoteUrl)===n)return t;return null}function jd(e){return`https://github.com/${e.owner}/${e.repo}.git`}function Md(e,t){switch(e.kind){case`ok`:return null;case`not-git`:return`This folder doesn't contain a git repository. Pick a different folder?`;case`wrong-repo`:return`This folder is a clone of ${e.actualOwner}/${e.actualRepo}, not ${t.owner}/${t.repo}. Pick a different folder?`;case`no-origin`:case`non-github`:case`symlink-escape`:return`This folder isn't a clone of ${t.owner}/${t.repo}. Pick a different folder?`}}function Nd(e){return e.kind===`unsupported-version`?{kind:`unsupported-version`,message:`Update Open Knowledge to open this share.`}:e.kind===`invalid`?{kind:`invalid`,message:`Invalid share URL.`}:null}function Pd(e){return e.kind===`ok`?{owner:e.owner,repo:e.repo,branch:e.branch,path:e.path,blobUrl:e.blobUrl}:null}function Fd(e){let t=[`[receive]`];return e.q1_hit!==void 0&&t.push(`q1_hit=${e.q1_hit}`),e.q2_path!==void 0&&t.push(`q2_path=${e.q2_path}`),e.folder_validate!==void 0&&t.push(`folder_validate=${e.folder_validate}`),t.join(` `)}function Id(){let e=null,t=new Set,n=!1,r=null;function i(){for(let e of t)e()}function a(){e!==null&&(e=null,i())}return{install({bridge:t}){if(t)return n?r??void 0:(n=!0,r=t.onShareReceived(t=>{e=t,i()}),()=>{r?.(),r=null,n=!1,a()})},getSnapshot(){return e},subscribe(e){return t.add(e),()=>{t.delete(e)}},dismiss(){a()}}}var Ld=Id();function Rd(e){return Ld.install(e)}function zd(e){let t=(0,$.c)(96),{bridge:n,cloneController:r,store:i}=e,a=i===void 0?Ld:i,o=(0,Q.useSyncExternalStore)(a.subscribe,a.getSnapshot,Bd),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),_=(0,Q.useRef)(!1),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>{c(!1),u(!1),f(null),m(!1),g(!1),_.current=!1},t[0]=v):v=t[0];let y;t[1]===o?y=t[2]:(y=[o],t[1]=o,t[2]=y),(0,Q.useEffect)(v,y);let b;t[3]!==d||t[4]!==r||t[5]!==o||t[6]!==s?(b=()=>{r&&(!o||o.kind!==`ok`||s&&d===null&&(_.current||(_.current=!0,m(!0),r.getAuthStatus().then(e=>{f(e)}).catch(()=>{f({authenticated:!1,host:`github.com`})}).finally(()=>{m(!1)}))))},t[3]=d,t[4]=r,t[5]=o,t[6]=s,t[7]=b):b=t[7];let x;t[8]!==d||t[9]!==o||t[10]!==s?(x=[o,s,d],t[8]=d,t[9]=o,t[10]=s,t[11]=x):x=t[11],(0,Q.useEffect)(b,x);let S,C;t[12]!==o||t[13]!==a?(S=()=>{if(!o)return;let e=Nd(o);e&&(X.error(e.message),a.dismiss())},C=[o,a],t[12]=o,t[13]=a,t[14]=S,t[15]=C):(S=t[14],C=t[15]),(0,Q.useEffect)(S,C);let w,T;t[16]!==n||t[17]!==o||t[18]!==s||t[19]!==a?(w=()=>{if(!o||o.kind!==`ok`||s)return;let e=!1;return Vd(o,n).then(t=>{if(!e){if(t.kind===`hit`){console.log(Fd({q1_hit:!0})),a.dismiss();return}console.log(Fd({q1_hit:!1})),c(!0)}}),()=>{e=!0}},T=[o,s,n,a],t[16]=n,t[17]=o,t[18]=s,t[19]=a,t[20]=w,t[21]=T):(w=t[20],T=t[21]),(0,Q.useEffect)(w,T);let E;t[22]===o?E=t[23]:(E=o?Pd(o):null,t[22]=o,t[23]=E);let D=E;if(!D)return null;let O;t[24]!==D.owner||t[25]!==D.repo?(O={owner:D.owner,repo:D.repo},t[24]=D.owner,t[25]=D.repo,t[26]=O):O=t[26];let k=O;if(!s)return null;let A;t[27]!==d?.authenticated||t[28]!==n||t[29]!==r||t[30]!==h||t[31]!==k||t[32]!==D||t[33]!==a?(A=async function(){if(!D)return;if(console.log(Fd({q2_path:`clone`})),!r){X.info(`Clone happens in the Project Navigator. Reclick the share link there.`,{action:{label:`Open Navigator`,onClick:()=>{n.navigator.open()}},duration:8e3});return}if(!d?.authenticated||h)return;g(!0);let e=jd(k),t;try{t=await r.runClone({url:e})}catch{X.error(`Clone failed. Please try again.`),g(!1);return}if(g(!1),t.kind===`ok`){try{await n.project.open({path:t.dir,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkDoc:D.path})}catch{X.error(`Cloned successfully, but could not open the project.`)}a.dismiss();return}},t[27]=d?.authenticated,t[28]=n,t[29]=r,t[30]=h,t[31]=k,t[32]=D,t[33]=a,t[34]=A):A=t[34];let j=A,M;t[35]!==p||t[36]!==r?(M=async function(){if(!(!r||p)){m(!0);try{let e=await r.startSignIn();m(!1),e!==null&&f(e)}catch{m(!1)}}},t[35]=p,t[36]=r,t[37]=M):M=t[37];let N=M,P;t[38]!==n||t[39]!==k||t[40]!==l||t[41]!==D||t[42]!==a?(P=async function(){if(!(!D||l)){u(!0),console.log(Fd({q2_path:`local`}));try{for(;;){let e=await n.dialog.openFolder();if(!e)break;let t=await n.share.validateLocalFolder({folderPath:e,owner:k.owner,repo:k.repo});if(console.log(Fd({folder_validate:t.kind})),t.kind===`ok`){await n.project.open({path:e,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkDoc:D.path}),a.dismiss();break}let r=Md(t,k);r&&X.error(r)}}catch{X.error(`Could not validate folder. Please try again.`)}u(!1)}},t[38]=n,t[39]=k,t[40]=l,t[41]=D,t[42]=a,t[43]=P):P=t[43];let F=P,I=r!==void 0&&d?.authenticated===!0&&!h,L=h?`Cloning...`:r&&d?.authenticated===!1?`Sign in to clone`:`Clone to a new folder`,R;t[44]===a?R=t[45]:(R=e=>{e||a.dismiss()},t[44]=a,t[45]=R);let z;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(bo,{children:`Open shared document`}),t[46]=z):z=t[46];let B=D.path?` · ${D.path}`:null,V;t[47]!==D.owner||t[48]!==D.repo||t[49]!==B?(V=(0,Z.jsxs)(Ao,{children:[z,(0,Z.jsxs)(vo,{children:[D.owner,`/`,D.repo,B]})]}),t[47]=D.owner,t[48]=D.repo,t[49]=B,t[50]=V):V=t[50];let H;t[51]===j?H=t[52]:(H=()=>{j()},t[51]=j,t[52]=H);let U=r!==void 0&&!I,W=r!==void 0&&!I,G;t[53]===L?G=t[54]:(G=(0,Z.jsx)(`span`,{className:`text-sm font-semibold`,children:L}),t[53]=L,t[54]=G);let K;t[55]!==D.owner||t[56]!==D.repo?(K=(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Downloads `,D.owner,`/`,D.repo,` from GitHub.`]}),t[55]=D.owner,t[56]=D.repo,t[57]=K):K=t[57];let q;t[58]!==H||t[59]!==U||t[60]!==W||t[61]!==G||t[62]!==K?(q=(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`share-receive-clone`,className:`flex flex-col items-start gap-2 rounded-lg border-2 border-primary/40 bg-card p-4 text-left transition hover:border-primary hover:bg-accent focus:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:border-primary/40 disabled:hover:bg-card`,onClick:H,disabled:U,"aria-disabled":W,children:[G,K]}),t[58]=H,t[59]=U,t[60]=W,t[61]=G,t[62]=K,t[63]=q):q=t[63];let ee;t[64]===F?ee=t[65]:(ee=()=>{F()},t[64]=F,t[65]=ee);let te=l||h,ne,re;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Z.jsx)(`span`,{className:`text-sm font-semibold`,children:`I already have it locally →`}),re=(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Pick the folder where you've cloned it.`}),t[66]=ne,t[67]=re):(ne=t[66],re=t[67]);let ie;t[68]!==ee||t[69]!==te?(ie=(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`share-receive-local`,className:`flex flex-col items-start gap-2 rounded-lg border border-border bg-card p-4 text-left transition hover:border-foreground/50 hover:bg-accent focus:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:ee,disabled:te,children:[ne,re]}),t[68]=ee,t[69]=te,t[70]=ie):ie=t[70];let ae;t[71]!==q||t[72]!==ie?(ae=(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[q,ie]}),t[71]=q,t[72]=ie,t[73]=ae):ae=t[73];let oe;t[74]!==p||t[75]!==d||t[76]!==r||t[77]!==N?(oe=r?(0,Z.jsx)(`div`,{className:`mt-3 flex items-center justify-between rounded-md border border-border bg-muted/30 px-3 py-2 text-xs`,"data-testid":`share-receive-auth-banner`,children:d===null?(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`Checking GitHub sign-in...`}):d.authenticated?(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Signed in as`,` `,(0,Z.jsxs)(`span`,{className:`font-medium text-foreground/90`,children:[`@`,d.login]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`Not signed in to GitHub.`}),(0,Z.jsx)(`button`,{type:`button`,"data-testid":`share-receive-signin`,className:`font-medium text-primary underline-offset-2 hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded`,onClick:()=>{N()},disabled:p,children:p?`Opening...`:`Sign in to GitHub`})]})}):null,t[74]=p,t[75]=d,t[76]=r,t[77]=N,t[78]=oe):oe=t[78];let se;t[79]===k?se=t[80]:(se=Od(k),t[79]=k,t[80]=se);let ce;t[81]===se?ce=t[82]:(ce=(0,Z.jsxs)(`p`,{className:`mt-3 text-[11px] text-muted-foreground`,children:[`Looking for`,` `,(0,Z.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-foreground/80`,children:se}),`.`]}),t[81]=se,t[82]=ce);let le;t[83]!==ae||t[84]!==oe||t[85]!==ce?(le=(0,Z.jsxs)(Do,{children:[ae,oe,ce]}),t[83]=ae,t[84]=oe,t[85]=ce,t[86]=le):le=t[86];let J;t[87]===a?J=t[88]:(J=(0,Z.jsx)(Oo,{children:(0,Z.jsx)(Y,{variant:`ghost`,onClick:()=>a.dismiss(),children:`Cancel`})}),t[87]=a,t[88]=J);let ue;t[89]!==V||t[90]!==le||t[91]!==J?(ue=(0,Z.jsxs)(wo,{className:`sm:max-w-xl`,"data-testid":`share-receive-dialog`,children:[V,le,J]}),t[89]=V,t[90]=le,t[91]=J,t[92]=ue):ue=t[92];let de;return t[93]!==R||t[94]!==ue?(de=(0,Z.jsx)(jo,{open:!0,onOpenChange:R,children:ue}),t[93]=R,t[94]=ue,t[95]=de):de=t[95],de}function Bd(){return null}async function Vd(e,t){let n;try{n=Ad(await t.project.listRecent(),{owner:e.owner,repo:e.repo})}catch{return{kind:`miss`}}if(!n)return{kind:`miss`};try{if((await t.share.validateLocalFolder({folderPath:n.path,owner:e.owner,repo:e.repo})).kind!==`ok`)return{kind:`miss`}}catch{return{kind:`miss`}}try{return await t.project.open({path:n.path,target:`new-window`,entryPoint:`share-receive`,pendingDeepLinkDoc:e.path}),{kind:`hit`}}catch{return{kind:`miss`}}}var Hd=(e,t,n)=>rl(e,t,n,`NavigatorApp`);function Ud(e,t){return e.filter(e=>e.path!==t)}function Wd(e){let t=(0,$.c)(82),{bridge:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let[i,a]=(0,Q.useState)(r),[o,s]=(0,Q.useState)(!0),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),b=typeof window<`u`&&window.okDesktop!=null,[x,S]=(0,Q.useState)(`auth`),{theme:C}=vr();za(n,C??`system`);let w;t[1]===n.project?w=t[2]:(w=()=>{let e=!1;return n.project.listRecent().then(t=>{e||a(t)}).catch(t=>{console.error(`[NavigatorApp] listRecent failed:`,t),e||l(t instanceof Error?t.message:`Failed to load recent projects.`)}).finally(()=>{e||s(!1)}),()=>{e=!0}},t[1]=n.project,t[2]=w);let T;t[3]===n?T=t[4]:(T=[n],t[3]=n,t[4]=T),(0,Q.useEffect)(w,T);let E;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(E=(e,t)=>Hd(e,t,l),t[5]=E):E=t[5];let D=E,O;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>d(!0),t[6]=O):O=t[6];let k=O,A;t[7]===n?A=t[8]:(A=()=>D(async()=>{let e=await n.dialog.openFolder();e&&await qd(n,e,`pick-existing`)},`Failed to open folder.`),t[7]=n,t[8]=A);let j=A,M;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>p(!0),t[9]=M):M=t[9];let N=M,P;t[10]===n?P=t[11]:(P=e=>D(async()=>{await qd(n,e,`recents`)},`Failed to open project.`),t[10]=n,t[11]=P);let F=P,I;t[12]===n.project?I=t[13]:(I=e=>D(async()=>{await n.project.removeRecent(e),a(t=>Ud(t,e))},`Failed to remove project.`),t[12]=n.project,t[13]=I);let L=I,z;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 z-10 h-9 ${b?`[-webkit-app-region:drag]`:``}`,"data-testid":`nav-chrome-row`}),t[14]=z):z=t[14];let B;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Z.jsx)(Cd,{className:`size-12 shrink-0`}),t[15]=B):B=t[15];let V;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`h1`,{className:`font-medium text-xl tracking-tight`,children:`Open Knowledge`}),(0,Z.jsx)(Zu,{})]}),t[16]=V):V=t[16];let H;t[17]===n.appVersion?H=t[18]:(H=(0,Z.jsxs)(`header`,{className:`shrink-0 flex-wrap flex items-center gap-2.5`,children:[B,(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[V,(0,Z.jsxs)(`p`,{className:`text-muted-foreground text-xs font-mono`,children:[`v`,n.appVersion]})]})]}),t[17]=n.appVersion,t[18]=H);let U;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Z.jsx)(Gd,{title:`Clone from GitHub`,description:`Bring a remote repository onto this machine.`,onClick:k,dataTestId:`nav-clone`,Icon:Sd}),t[19]=U):U=t[19];let W;t[20]===j?W=t[21]:(W=(0,Z.jsx)(Gd,{title:`Open folder on disk`,description:`Use a folder you already have.`,onClick:j,dataTestId:`nav-open`,Icon:R}),t[20]=j,t[21]=W);let G;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,Z.jsx)(Gd,{title:`Create new project`,description:`Start a new Open Knowledge project.`,onClick:N,dataTestId:`nav-create-new`,Icon:ce}),t[22]=G):G=t[22];let K;t[23]===W?K=t[24]:(K=(0,Z.jsxs)(`section`,{className:`grid shrink-0 sm:grid-cols-3 gap-3`,children:[U,W,G]}),t[23]=W,t[24]=K);let q;t[25]===c?q=t[26]:(q=c===null?null:(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 rounded-md border border-red-500/30 bg-red-500/10 px-3 py-2`,"data-testid":`nav-error-banner`,role:`alert`,children:[(0,Z.jsx)(`span`,{className:`text-red-700 text-xs dark:text-red-300`,children:c}),(0,Z.jsx)(Y,{type:`button`,variant:`link`,size:`sm`,onClick:()=>l(null),className:`h-auto p-0 text-red-700 text-xs dark:text-red-300`,"data-testid":`nav-error-dismiss`,children:`Dismiss`})]}),t[25]=c,t[26]=q);let ee;t[27]!==o||t[28]!==F||t[29]!==L||t[30]!==i?(ee=o?(0,Z.jsx)(`section`,{className:`flex shrink-0 flex-col items-center`,children:(0,Z.jsx)(ue,{className:`size-4 animate-spin text-muted-foreground/60`})}):i.length>0?(0,Z.jsxs)(`section`,{className:`flex min-h-0 flex-col`,children:[(0,Z.jsx)(`h2`,{className:`mb-2 shrink-0 font-medium text-muted-foreground font-mono text-xs uppercase tracking-wide`,children:`Recent`}),(0,Z.jsx)(`ul`,{className:`min-h-0 max-h-48 subtle-scrollbar scroll-fade-mask overflow-y-auto space-y-0.5 -mx-4`,"data-testid":`nav-recent-list`,children:i.map(e=>(0,Z.jsx)(Kd,{project:e,onOpen:()=>F(e.path),onRemove:()=>L(e.path)},e.path))})]}):null,t[27]=o,t[28]=F,t[29]=L,t[30]=i,t[31]=ee):ee=t[31];let te;t[32]!==H||t[33]!==K||t[34]!==q||t[35]!==ee?(te=(0,Z.jsx)(`div`,{className:`mx-auto flex h-full w-full max-w-5xl flex-col overflow-hidden px-12 py-12`,children:(0,Z.jsxs)(`div`,{className:`my-auto flex min-h-0 flex-col space-y-10`,children:[H,K,q,ee]})}),t[32]=H,t[33]=K,t[34]=q,t[35]=ee,t[36]=te):te=t[36];let ne,re;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Z.jsx)(Td,{}),re=(0,Z.jsx)(nd,{}),t[37]=ne,t[38]=re):(ne=t[37],re=t[38]);let ie;t[39]!==n||t[40]!==f?(ie=(0,Z.jsx)(pd,{open:f,onOpenChange:p,bridge:n}),t[39]=n,t[40]=f,t[41]=ie):ie=t[41];let ae;t[42]===v?ae=t[43]:(ae=e=>{h(e),e||(_(!1),v&&(v(null),y(null)))},t[42]=v,t[43]=ae);let oe;t[44]===n?oe=t[45]:(oe=hl(n),t[44]=n,t[45]=oe);let se=x===`identity`,le;t[46]!==g||t[47]!==v?(le=e=>{h(!1),g&&(_(!1),d(!0)),v&&(v({authenticated:!0,host:`github.com`,login:e.login}),y(null))},t[46]=g,t[47]=v,t[48]=le):le=t[48];let J;t[49]!==m||t[50]!==ae||t[51]!==oe||t[52]!==se||t[53]!==le?(J=(0,Z.jsx)(qu,{open:m,onOpenChange:ae,transport:oe,identityPrompt:se,onSuccess:le}),t[49]=m,t[50]=ae,t[51]=oe,t[52]=se,t[53]=le,t[54]=J):J=t[54];let de;t[55]===n?de=t[56]:(de=_l(n),t[55]=n,t[56]=de);let fe;t[57]===n?fe=t[58]:(fe=dl(n),t[57]=n,t[58]=fe);let pe;t[59]===n.dialog?pe=t[60]:(pe=()=>n.dialog.openFolder(),t[59]=n.dialog,t[60]=pe);let me;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(me=()=>{d(!1),S(`auth`),_(!0),h(!0)},t[61]=me):me=t[61];let he;t[62]===n?he=t[63]:(he=e=>{let{dir:t}=e;D(()=>qd(n,t,`pick-existing`),`Failed to open cloned project.`)},t[62]=n,t[63]=he);let ge;t[64]!==u||t[65]!==de||t[66]!==fe||t[67]!==pe||t[68]!==he?(ge=(0,Z.jsx)(ed,{open:u,onOpenChange:d,transport:de,authQueryTransport:fe,pickParentFolder:pe,onSignIn:me,onCloneComplete:he}),t[64]=u,t[65]=de,t[66]=fe,t[67]=pe,t[68]=he,t[69]=ge):ge=t[69];let _e;if(t[70]!==n){let e;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>new Promise(e=>{y(()=>e),h(!0)}),t[72]=e):e=t[72],_e=ol({bridge:n,authQueryTransport:dl(n),cloneTransport:_l(n),openSignIn:e}),t[70]=n,t[71]=_e}else _e=t[71];let ve;t[73]!==n||t[74]!==_e?(ve=(0,Z.jsx)(zd,{bridge:n,cloneController:_e}),t[73]=n,t[74]=_e,t[75]=ve):ve=t[75];let ye;return t[76]!==te||t[77]!==ie||t[78]!==J||t[79]!==ge||t[80]!==ve?(ye=(0,Z.jsxs)(`div`,{className:`relative flex h-screen w-screen flex-col overflow-hidden bg-primary-foreground dark:bg-background text-foreground`,children:[z,te,ne,re,ie,J,ge,ve]}),t[76]=te,t[77]=ie,t[78]=J,t[79]=ge,t[80]=ve,t[81]=ye):ye=t[81],ye}function Gd(e){let t=(0,$.c)(14),{title:n,description:r,onClick:i,dataTestId:a,Icon:o}=e,s;t[0]===o?s=t[1]:(s=o?(0,Z.jsx)(o,{className:`size-4 shrink-0 text-muted-foreground`}):null,t[0]=o,t[1]=s);let c;t[2]===n?c=t[3]:(c=(0,Z.jsx)(`span`,{className:`font-medium text-gray-700 dark:text-foreground text-sm`,children:n}),t[2]=n,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===r?u=t[8]:(u=(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs leading-snug`,children:r}),t[7]=r,t[8]=u);let d;return t[9]!==a||t[10]!==i||t[11]!==l||t[12]!==u?(d=(0,Z.jsxs)(Y,{type:`button`,variant:`outline`,onClick:i,"data-testid":a,className:`h-auto flex-col items-start justify-start gap-1.5 whitespace-normal bg-card px-4 py-3.5 text-left`,children:[l,u]}),t[9]=a,t[10]=i,t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function Kd(e){let t=(0,$.c)(25),{project:n,onOpen:r,onRemove:i}=e,a=n.missing,o=n.missing&&`opacity-50`,s;t[0]===o?s=t[1]:(s=mi(`h-auto min-w-0 flex-1 justify-between gap-2 py-3.5 pl-4 pr-2 text-left hover:bg-transparent`,o),t[0]=o,t[1]=s);let c;t[2]===n.name?c=t[3]:(c=(0,Z.jsx)(`span`,{className:`font-medium text-sm text-gray-700 dark:text-foreground`,children:n.name}),t[2]=n.name,t[3]=c);let l;t[4]===n.path?l=t[5]:(l=(0,Z.jsx)(`span`,{className:`truncate w-full text-muted-foreground text-xs`,children:n.path}),t[4]=n.path,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 truncate`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]===n.missing?d=t[10]:(d=n.missing?(0,Z.jsx)(Ge,{className:`text-2xs rounded-sm`,variant:`warning`,children:`Missing`}):null,t[9]=n.missing,t[10]=d);let f;t[11]!==r||t[12]!==n.missing||t[13]!==s||t[14]!==u||t[15]!==d?(f=(0,Z.jsxs)(Y,{type:`button`,variant:`ghost`,onClick:r,disabled:a,className:s,children:[u,d]}),t[11]=r,t[12]=n.missing,t[13]=s,t[14]=u,t[15]=d,t[16]=f):f=t[16];let p=`Remove ${n.name} from recent projects`,m=`nav-recent-remove-${n.path}`,h;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(_o,{"aria-hidden":`true`}),t[17]=h):h=t[17];let g;t[18]!==i||t[19]!==m||t[20]!==p?(g=(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:i,"aria-label":p,title:`Remove from recent projects`,className:`pointer-events-none mr-2 opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 focus-visible:pointer-events-auto focus-visible:opacity-100`,"data-testid":m,children:h}),t[18]=i,t[19]=m,t[20]=p,t[21]=g):g=t[21];let _;return t[22]!==g||t[23]!==f?(_=(0,Z.jsxs)(`li`,{className:`group flex items-center justify-between rounded-lg hover:bg-accent`,children:[f,g]}),t[22]=g,t[23]=f,t[24]=_):_=t[24],_}async function qd(e,t,n){await e.project.open({path:t,target:`new-window`,entryPoint:n})}var Jd=e=>{let t=(0,$.c)(8),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let{theme:r}=vr(),i=r===void 0?`system`:r,a,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a={success:(0,Z.jsx)(Xr,{className:`size-4`}),info:(0,Z.jsx)(Xe,{className:`size-4`}),warning:(0,Z.jsx)(dr,{className:`size-4`}),error:(0,Z.jsx)(wc,{className:`size-4`}),loading:(0,Z.jsx)(ue,{className:`size-4 animate-spin`})},o={"--normal-bg":`var(--popover)`,"--normal-text":`var(--popover-foreground)`,"--normal-border":`var(--border)`,"--border-radius":`var(--radius)`},t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s={classNames:{toast:`cn-toast`}},t[4]=s):s=t[4];let c;return t[5]!==n||t[6]!==i?(c=(0,Z.jsx)(yo,{theme:i,className:`toaster group`,icons:a,style:o,toastOptions:s,...n}),t[5]=n,t[6]=i,t[7]=c):c=t[7],c};function Yd(e){let{apiOrigin:t}=e;if(!t)return;let n=Symbol.for(`ok.desktop.fetchRewrite`);if(window.fetch[n])return;let r=window.fetch.bind(window),i=((e,n)=>{if(typeof e==`string`)return r(Xd(e,t),n);if(e instanceof URL)return e.pathname.startsWith(`/api/`)&&(e.origin===window.location.origin||e.protocol===`file:`)?r(t+(e.pathname+e.search+e.hash),n):r(e,n);try{let i=new URL(e.url,window.location.origin);if(i.pathname.startsWith(`/api/`)){let a=i.pathname+i.search+i.hash;return r(new Request(t+a,e),n)}}catch{}return r(e,n)});i[n]=!0,window.fetch=i}function Xd(e,t){return e.startsWith(`/api/`)?t+e:e}function Zd(e){return`#/${encodeURIComponent(e)}`}function Qd(e){let t=e.bridge;if(!t)return;let n=e.setHash??(e=>{window.location.hash=e});return t.onDeepLink(e=>{n(Zd(e.doc))})}var $d=4e3,ef=1440*60*1e3;function tf(e){let t=e.bridge;if(t&&t.onboarding)return t.onboarding.onToast(e=>{if(e.kind===`ancestor-promote`){X.success(`Opened existing Open Knowledge project at ${e.ancestorPath}`,{duration:$d});return}if(e.kind===`startup-reclaim`){let t=[];if(e.mcp.status===`repaired`){let n=e.mcp.editors.map(e=>lr[e]??e).join(`, `);t.push(`repaired ${n} MCP integration`)}else e.mcp.status===`failed`&&t.push(`MCP auto-repair failed`);e.path.status===`installed`&&t.push(e.path.summary),e.path.status===`failed`&&t.push(`PATH install failed: ${e.path.summary}`);let n=t.length>0?t.join(`; `):`Open Knowledge integrations checked.`,r=e.mcp.status===`failed`||e.path.status===`failed`;X[r?`error`:`success`](n,{duration:r?ef:$d});return}let t=qo(e.gitRoot,e.pickedPath)??e.pickedPath;X.success(`Initialized Open Knowledge at ${e.gitRoot} — opened parent of ${t} because it contains a .git folder`,{duration:$d})})}var nf=!1;function rf(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{dt(n,{durationMs:Math.round(e*1e3)/1e3,threw:!o,...i},{startTime:t,duration:e})}catch{}}}}function af(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 of=0,sf=0,cf=0,lf=0,uf=null,df=[`linkResolutionDecoration$`],ff=new WeakSet,pf=new WeakSet;function mf(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}function hf(){return!1}function gf(){return!hf()}function _f(e,t){if(gf())return t;let n=`ok/cold/nodeview-factory-${mf(e)}`;return function(...r){let i=performance.now();try{return t(...r)}finally{let t=performance.now()-i;dt(n,{nodeType:e,durationMs:Math.round(t*1e3)/1e3},{startTime:i,duration:t})}}}function vf(e){if(gf())return;let t=e.state.plugins;for(let e of t){if(pf.has(e))continue;let t=e.spec?.key?.key;if(!t||!df.some(e=>t.startsWith(e)))continue;let n=e.props,r=n.decorations;if(typeof r!=`function`){pf.add(e);continue}let i=`ok/cold/decoration-${mf(t.replace(/\$\d*$/,``))}`;n.decorations=function(...e){let n=performance.now();try{return r.apply(this,e)}finally{let e=performance.now()-n;dt(i,{pluginKey:t,durationMs:Math.round(e*1e3)/1e3},{startTime:n,duration:e})}},pf.add(e)}}function yf(e){if(gf())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=_f(e,n);r.__okWrapped=!0,t[e]=r}}function bf(e){return gf()?e:e.map(e=>{let t=e.name??`unknown`,n=mf(t);return e.extend({onBeforeCreate(){let e=performance.now();try{this.parent?.()}finally{let r=performance.now()-e;dt(`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;dt(`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;dt(`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;dt(`ok/cold/ext-${n}-on-destroy`,{ext:t,hook:`onDestroy`,durationMs:Math.round(r*1e3)/1e3},{startTime:e,duration:r})}}})})}function xf(){if(!nf){nf=!0,rf(_n.prototype,`mount`,`ok/cold/editor-mount`,(e,t,n,r)=>{let i=e;return gf()||(uf=performance.now()),{elementDefault:i.options?.element?.nodeName??null,docSize:af(i.editorState),durationMs:r}}),rf(_n.prototype,`createView`,`ok/cold/editor-create-view`,e=>{let t=e;return!gf()&&!ff.has(e)&&t.view&&(vf(t.view),yf(t.view),ff.add(e)),{docSize:af(t.editorState)}}),rf(_n.prototype,`createNodeViews`,`ok/cold/create-node-views`,(e,t,n,r)=>{lf+=1;let i=e;return!gf()&&i.view&&yf(i.view),{docSize:af(i.view),seq:lf,durationMs:r}}),rf(Yn.prototype,`updateState`,`ok/cold/pm-update-state`,(e,t,n,r)=>(sf+=1,{seq:sf,docSize:af(e.state),durationMs:r})),rf(Yn.prototype,`setProps`,`ok/cold/pm-set-props`,(e,t,n,r)=>(cf+=1,{seq:cf,docSize:af(e.state),durationMs:r})),rf(I.prototype,`_forceRerender`,`ok/cold/force-rerender`,(e,t,n,r)=>{of+=1;let i=e,a=(()=>{try{return i.type?.toArray?i.type.toArray().length:null}catch{return null}})();return{seq:of,topLevelYElements:a,durationMs:r}}),rf(tt.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`)&&(dt(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}),!gf()&&e===`first-paint`&&uf!==null)){let e=uf,n=Math.max(0,t.startTime-e);dt(`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}),uf=null}}}).observe({type:`paint`,buffered:!0})}catch{}globalThis.__okColdMountInstrumented=!0}}var Sf=`Relaunch`,Cf=`Release notes`,wf=`Updates paused`,Tf=`Download`,Ef=`Reset to defaults`,Df=`Relaunch failed — please restart manually`,Of=`Recovery action failed — please try again`;function kf(e,t){let n=t instanceof Error&&t.message?t.message:``;return n?`${e}: ${n}`:e}function Af(e){return`Version ${e} ready to install`}function jf(e){return`Updated to Version ${e}`}function Mf(e){return`Your settings and recent projects were saved by a newer build than this one (v${e}). Reset to defaults to continue.`}var Nf=0,Pf=0,Ff=1,If=2,Lf=3;function Rf(e,t,n=()=>{}){let r=[];return r.push(e.onUpdateDownloaded(({version:r})=>{let i=`update-downloaded`;t({id:i,body:Af(r),priority:If,action:{label:Sf,onClick:()=>{e.update.relaunchNow().then(()=>{n(i)},e=>{t({id:`relaunch-error-${r}`,body:kf(Df,e),variant:`error`,priority:Ff})})}}})})),r.push(e.onWhatsNew(({version:n,releaseUrl:r})=>{t({id:`whats-new-${n}`,body:jf(n),priority:Lf,action:{label:Cf,onClick:()=>{e.shell.openExternal(r)}}})})),r.push(e.onUpdateStuckHint(({downloadUrl:n})=>{t({id:`update-stuck-hint`,body:wf,priority:Pf,action:{label:Tf,onClick:()=>{e.shell.openExternal(n)}}})})),()=>{for(let e of r)e()}}function zf(e,t,n,r=()=>{}){let i=`schema-incompatibility-${t.persistedSchemaVersion}`,a=`schema-incompatibility-error-${t.persistedSchemaVersion}`,o=e=>{r(i),n({id:a,body:kf(Of,e),variant:`error`,priority:Nf})};n({id:i,body:Mf(t.currentBuild),priority:Nf,action:{label:Ef,onClick:()=>{e.state.resetIncompatible().then(()=>{r(i)},o)}}})}var Bf=[],Vf=new Set,Hf=!1;function Uf(){for(let e of Vf)e()}function Wf(e){let t=Bf.findIndex(t=>t.id===e.id);if(t===-1)Bf=[...Bf,e];else{let n=Bf.slice();n[t]=e,Bf=n}Uf()}function Gf(e){let t=Bf.filter(t=>t.id!==e);t.length!==Bf.length&&(Bf=t,Uf())}function Kf(){return Bf}function qf(e){return Vf.add(e),()=>{Vf.delete(e)}}function Jf(){if(Hf||typeof window>`u`)return;let e=window.okDesktop;e&&(Hf=!0,Rf(e,Wf,Gf),e.state.query().then(t=>{t.schemaIncompatibility&&zf(e,t.schemaIncompatibility,Wf,Gf)},e=>{console.warn(`[update-notices-store] bridge.state.query() failed`,e)}))}var Yf=`ok-omnibar-recents-v1`,Xf=10;function Zf(e){return typeof e==`object`&&!!e&&(e.kind===`file`||e.kind===`folder`)&&typeof e.path==`string`&&typeof e.lastOpenedAt==`string`}function Qf(e){if(e)return e;if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function $f(e,t){return`${e}:${t}`}function ep(e){let t=Qf(e);if(!t)return[];try{let e=t.getItem(Yf);if(!e)return[];let n=JSON.parse(e);return Array.isArray(n)?n.filter(Zf).slice(0,Xf):[]}catch{return[]}}function tp(e,t){let n=Qf(t);if(n)try{n.setItem(Yf,JSON.stringify(e.slice(0,Xf)))}catch(e){console.warn(`[omnibar] Failed to save recent entries:`,e)}}function np(e,t){return[t,...e.filter(e=>e.kind!==t.kind||e.path!==t.path)].slice(0,Xf)}function rp(e,t){return e.filter(e=>t.has($f(e.kind,e.path)))}var ip=50,ap=30,op=``,sp=null;function cp(e){return e.trim().toLowerCase()}function lp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function up(e){let t=e.trim();return t?[...new Set(t.split(/\s+/).filter(Boolean))].sort((e,t)=>t.length-e.length):[]}function dp(e,t,n=new Map,r=new Map){let i=[];for(let t of e){let e=r.get(t)?.modified,a=n.get(t);i.push({kind:`file`,path:t,name:ci(t),...a?{title:a}:{},...e?{modifiedTs:Date.parse(e)}:{}})}for(let e of t)i.push({kind:`folder`,path:e,name:ci(e)});return i.sort((e,t)=>{let n=e.path.localeCompare(t.path);return n===0?e.kind===t.kind?0:e.kind===`folder`?-1:1:n}),i}function fp(e){return ni({kind:e.kind===`file`?`page`:`folder`,path:e.path,title:e.title??e.name,modifiedTs:e.modifiedTs??0})}function pp(e){return{entries:e,byId:new Map(e.map(e=>[`${e.kind===`file`?`page`:`folder`}:${e.path}`,e])),corpus:gn(e.map(fp))}}function mp(e){return e.map(e=>`${e.kind}\u0000${e.path}\u0000${e.title??``}\u0000${e.modifiedTs??0}`).join(``)}function hp(e){let t=mp(e);return sp&&op===t?sp:(op=t,sp=pp(e),sp)}function gp(e,t,n=ip){return _p(hp(e),t,n)}function _p(e,t,n=ip){let r=cp(t);return r?Vr(e.corpus,r,{intent:`omnibar`,limit:n,scopes:[`page`,`folder`]}).map(t=>e.byId.get(t.document.id)).filter(e=>e!==void 0):e.entries.slice(0,20)}function vp(e,t){let n=up(t);if(n.length===0||e.length===0)return[{text:e,match:!1,start:0}];let r=RegExp(`(${n.map(lp).join(`|`)})`,`gi`),i=[],a=0;for(let t of e.matchAll(r)){let n=t.index??0;n>a&&i.push({text:e.slice(a,n),match:!1,start:a}),i.push({text:t[0],match:!0,start:n}),a=n+t[0].length}return a<e.length&&i.push({text:e.slice(a),match:!1,start:a}),i.length>0?i:[{text:e,match:!1,start:0}]}function yp(e){if(e.kind!==`page`&&e.kind!==`folder`||typeof e.path!=`string`)return null;let t=ci(e.path);return{kind:e.kind===`page`?`file`:`folder`,path:e.path,name:t,...e.title&&{title:e.title},...e.snippet&&{snippet:e.snippet},...typeof e.score==`number`&&{score:e.score}}}async function bp(e,t={}){let n=e.trim();if(!n)return[];let r=await fetch(`/api/search`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({query:n,intent:`full_text`,scopes:[`page`,`folder`,`content`],limit:t.limit??ap}),signal:t.signal});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(Gn(e)??`Search failed with status ${r.status}`)}return((await r.json()).results??[]).map(yp).filter(e=>!!e)}function xp(e,t,n=[]){let r=cp(t);return r?cp([e,...n].join(` `)).includes(r):!0}var Sp=`tag:`;function Cp(e,t){if(!e.toLowerCase().startsWith(`tag:`))return{kind:`normal`,query:e};let n=e.slice(4).replace(/^\s+/,``).trim();return n&&t.has(n)?{kind:`tag-docs`,tagName:n}:{kind:`tag-list`,query:n}}function wp(e,t){return ye(e,t)}var Tp=pe;async function Ep(e){let t=await fetch(`/api/tags/${encodeURIComponent(e)}`);if(!t.ok)throw Error(`/api/tags/${e} responded with ${t.status}`);let n=await t.json();return Array.isArray(n.docs)?n.docs:[]}var Dp=`open-knowledge:doc-panel-tab`,Op=null;function kp(){let e=Op;return Op=null,e}function Ap(e,t=typeof window>`u`?new EventTarget:window){Op=e,t.dispatchEvent(new CustomEvent(Dp,{detail:{tab:e}}))}function jp(e,t=typeof window>`u`?new EventTarget:window){let n=t=>{let n=t instanceof CustomEvent?t.detail?.tab:void 0;n&&e(n)};return t.addEventListener(Dp,n),()=>t.removeEventListener(Dp,n)}var Mp=[`.md`,`.mdx`];function Np(e){let t=e.toLowerCase();for(let e of Mp)if(t.endsWith(e))return e;return null}function Pp(e){let t=Np(e);return t?e.slice(0,-t.length):e}var Fp=`__blank__`,Ip={local:0,inherited:1};function Lp(e){return[...e].sort((e,t)=>{let n=Ip[e.scope]-Ip[t.scope];if(n!==0)return n;let r=(e.title??e.name).toLowerCase(),i=(t.title??t.name).toLowerCase();return r.localeCompare(i)})}function Rp(e){return e.trim()?e.includes(`..`)?`Path cannot contain ".."`:e.startsWith(`/`)?`Path cannot start with "/"`:e.includes(`\\`)?`Path cannot contain backslashes`:e.includes(`\0`)?`Path cannot contain null bytes`:null:`Name cannot be empty`}function zp(e){let t=e.fileName.trim(),n=Np(t)?t:`${t}${e.fileExtension??`.md`}`;if(e.kind===`folder`){let t=(e.folderName??``).trim();return`${e.initialDir?`${e.initialDir}/${t}`:t}/${n}`}return e.initialDir?`${e.initialDir}/${n}`:n}function Bp(e){let t=e.target;return t?.tagName===`INPUT`||t?.tagName===`TEXTAREA`||t?.isContentEditable?!1:!!((e.metaKey||e.ctrlKey)&&e.altKey&&e.key.toLowerCase()===`n`)}function Vp(e){let t=e.value.lastIndexOf(`.`);t>0?e.setSelectionRange(0,t):e.select()}function Hp(e){let t=(0,$.c)(120),{open:n,onOpenChange:r,kind:i,initialDir:a,suggestedName:o,initialTemplate:s,description:c,onCreated:u,folderConfig:d}=e,{addPage:f}=qr(),p=Aa(d?null:a),m=d??p,[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(`.md`),[x,S]=(0,Q.useState)(Fp),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(null),k=(0,Q.useId)(),A=(0,Q.useId)(),j=(0,Q.useId)(),M=(0,Q.useId)(),N=(0,Q.useId)(),[P,F]=(0,Q.useState)(!1),I=(0,Q.useRef)(null),L=(0,Q.useRef)(null),R,z;t[0]!==s||t[1]!==i||t[2]!==n||t[3]!==o?(R=()=>{if(n){w(null),O(null),E(!1),v(``),S(i===`file`&&s?s:Fp),F(!1);let e=i===`file`?o??`untitled`:`index`,t=Np(e);b(t??`.md`),g(t?Pp(e):e)}},z=[n,i,o,s],t[0]=s,t[1]=i,t[2]=n,t[3]=o,t[4]=R,t[5]=z):(R=t[4],z=t[5]),(0,Q.useEffect)(R,z);let B;t[6]!==m.state.data||t[7]!==m.state.status?(B=m.state.status===`ready`?Lp(m.state.data.folder.templates_available??[]):[],t[6]=m.state.data,t[7]=m.state.status,t[8]=B):B=t[8];let V=B,H;t[9]!==m.state.data||t[10]!==m.state.status||t[11]!==n||t[12]!==x?(H=()=>{n&&x!==Fp&&m.state.status===`ready`&&((m.state.data.folder.templates_available??[]).some(e=>e.name===x)||S(Fp))},t[9]=m.state.data,t[10]=m.state.status,t[11]=n,t[12]=x,t[13]=H):H=t[13];let U;t[14]!==m.state||t[15]!==n||t[16]!==x?(U=[n,x,m.state],t[14]=m.state,t[15]=n,t[16]=x,t[17]=U):U=t[17],(0,Q.useEffect)(H,U);let W=i===`file`,G=m.state.status===`loading`||m.state.status===`idle`,K=m.state.status===`error`?m.state.message:null,q;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(q=function(e){let t=Np(e);t?(b(t),g(Pp(e))):g(e),w(null)},t[18]=q):q=t[18];let ee=q,te;t[19]!==y||t[20]!==h||t[21]!==_||t[22]!==a||t[23]!==i?(te=function(){return zp({kind:i,initialDir:a,fileName:h,fileExtension:y,folderName:_})},t[19]=y,t[20]=h,t[21]=_,t[22]=a,t[23]=i,t[24]=te):te=t[24];let ne=te,re;t[25]!==h||t[26]!==_||t[27]!==i?(re=function(){if(i===`folder`){let e=Rp(_.trim());if(e)return{message:`Folder name: ${e}`,field:`folder`}}let e=Rp(h.trim());return e?{message:e,field:`file`}:null},t[25]=h,t[26]=_,t[27]=i,t[28]=re):re=t[28];let ie=re,ae;t[29]!==T||t[30]!==h||t[31]!==_||t[32]!==i?(ae=T||!h.trim()||i===`folder`&&!_.trim(),t[29]=T,t[30]=h,t[31]=_,t[32]=i,t[33]=ae):ae=t[33];let oe=ae,se;t[34]!==f||t[35]!==ne||t[36]!==ie||t[37]!==i||t[38]!==u||t[39]!==r||t[40]!==x?(se=async function(){let e=ie();if(e){w(e.message),O(e.field);return}E(!0),w(null),O(null);let t=ne(),n=i===`file`&&x!==Fp?x:void 0,a={path:t};n!==void 0&&(a.template=n);try{let e=await fetch(`/api/create-page`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(a)}),t=await l(e,`Server error (HTTP ${e.status})`);if(!t.ok){E(!1),w(t.title),O(`form`);return}let n=wr.safeParse(t.body);if(E(!1),!n.success){w(`Failed to create ${i}`),O(`form`);return}let o=n.data.docName;r(!1),window.location.hash=`#/${o}`,f(o),Fr([`files`,`backlinks`,`graph`]),u?.(o)}catch(e){console.warn(`[NewItemDialog] create failed:`,e),E(!1),w(`Network error — please try again`),O(`form`)}},t[34]=f,t[35]=ne,t[36]=ie,t[37]=i,t[38]=u,t[39]=r,t[40]=x,t[41]=se):se=t[41];let ce=se,le=a||`(root)`,J=i===`file`?`New file`:`New folder`,ue;t[42]===J?ue=t[43]:(ue=(0,Z.jsx)(bo,{children:J}),t[42]=J,t[43]=ue);let de;t[44]!==c||t[45]!==le?(de=c??(0,Z.jsxs)(Z.Fragment,{children:[`Create in `,(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:le})]}),t[44]=c,t[45]=le,t[46]=de):de=t[46];let fe;t[47]===de?fe=t[48]:(fe=(0,Z.jsx)(vo,{children:de}),t[47]=de,t[48]=fe);let pe;t[49]!==ue||t[50]!==fe?(pe=(0,Z.jsxs)(Ao,{children:[ue,fe]}),t[49]=ue,t[50]=fe,t[51]=pe):pe=t[51];let me;t[52]!==x||t[53]!==W||t[54]!==M||t[55]!==P||t[56]!==N||t[57]!==V||t[58]!==K||t[59]!==G?(me=W&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{id:M,className:`mb-1.5 block text-sm font-medium`,children:`Start from`}),K?(0,Z.jsxs)(`p`,{role:`alert`,className:`mb-1.5 text-xs text-destructive`,children:[`Could not load templates: `,K,`. You can still create a blank note.`]}):null,(0,Z.jsx)(Gp,{triggerId:N,labelledById:M,open:P,onOpenChange:F,value:x,onValueChange:S,templates:V,loading:G}),!G&&!K&&V.length===0?(0,Z.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`No templates resolve here. Add one in this folder's Templates section, or in Settings → Templates.`}):null]}),t[52]=x,t[53]=W,t[54]=M,t[55]=P,t[56]=N,t[57]=V,t[58]=K,t[59]=G,t[60]=me):me=t[60];let he;t[61]!==C||t[62]!==D||t[63]!==k||t[64]!==A||t[65]!==_||t[66]!==i?(he=i===`folder`&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:A,children:`Folder name`}),(0,Z.jsx)(Po,{ref:L,id:A,value:_,onChange:e=>{v(e.target.value),w(null)},placeholder:`folder-name`,autoFocus:!0,"aria-describedby":C&&(D===`folder`||D===`form`)?k:void 0,"aria-invalid":C&&(D===`folder`||D===`form`)?!0:void 0,onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault();let t=Rp(_.trim());if(t){w(`Folder name: ${t}`),O(`folder`);return}I.current?.focus()}}})]}),t[61]=C,t[62]=D,t[63]=k,t[64]=A,t[65]=_,t[66]=i,t[67]=he):he=t[67];let ge=i===`folder`?`First file name`:`File name`,_e;t[68]!==j||t[69]!==ge?(_e=(0,Z.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:j,children:ge}),t[68]=j,t[69]=ge,t[70]=_e):_e=t[70];let ve;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ve=e=>ee(e.target.value),t[71]=ve):ve=t[71];let ye=i===`file`,be=C&&(D===`file`||D===`form`)?k:void 0,xe=C&&(D===`file`||D===`form`)?!0:void 0,Se;t[72]!==ce||t[73]!==oe?(Se=e=>{e.key===`Enter`&&!oe&&ce()},t[72]=ce,t[73]=oe,t[74]=Se):Se=t[74];let Ce;t[75]!==j||t[76]!==h||t[77]!==ye||t[78]!==be||t[79]!==xe||t[80]!==Se?(Ce=(0,Z.jsx)(Po,{ref:I,id:j,value:h,onChange:ve,placeholder:`my-note`,autoFocus:ye,"aria-describedby":be,"aria-invalid":xe,onFocus:Wp,onKeyDown:Se,className:`flex-1`}),t[75]=j,t[76]=h,t[77]=ye,t[78]=be,t[79]=xe,t[80]=Se,t[81]=Ce):Ce=t[81];let we;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(we=e=>{(e===`.md`||e===`.mdx`)&&b(e)},t[82]=we):we=t[82];let Te;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(Te=Mp.map(Up),t[83]=Te):Te=t[83];let Ee;t[84]===y?Ee=t[85]:(Ee=(0,Z.jsx)(Wo,{type:`single`,value:y,onValueChange:we,variant:`outline`,"aria-label":`File extension`,className:`shrink-0`,children:Te}),t[84]=y,t[85]=Ee);let De;t[86]!==Ce||t[87]!==Ee?(De=(0,Z.jsxs)(`div`,{className:`flex items-stretch gap-2`,children:[Ce,Ee]}),t[86]=Ce,t[87]=Ee,t[88]=De):De=t[88];let Oe;t[89]!==C||t[90]!==k?(Oe=C&&(0,Z.jsx)(`p`,{id:k,role:`alert`,className:`text-xs text-red-600 dark:text-red-400`,children:C}),t[89]=C,t[90]=k,t[91]=Oe):Oe=t[91];let ke;t[92]!==_e||t[93]!==De||t[94]!==Oe?(ke=(0,Z.jsxs)(`div`,{children:[_e,De,Oe]}),t[92]=_e,t[93]=De,t[94]=Oe,t[95]=ke):ke=t[95];let Ae;t[96]!==me||t[97]!==he||t[98]!==ke?(Ae=(0,Z.jsx)(Do,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[me,he,ke]})}),t[96]=me,t[97]=he,t[98]=ke,t[99]=Ae):Ae=t[99];let je;t[100]===r?je=t[101]:(je=()=>r(!1),t[100]=r,t[101]=je);let Me;t[102]!==T||t[103]!==je?(Me=(0,Z.jsx)(Y,{variant:`outline`,className:`font-mono uppercase`,onClick:je,disabled:T,children:`Cancel`}),t[102]=T,t[103]=je,t[104]=Me):Me=t[104];let Ne=T?`Creating`:`Create`,Pe;t[105]!==ce||t[106]!==oe||t[107]!==Ne?(Pe=(0,Z.jsx)(Y,{onClick:ce,disabled:oe,children:Ne}),t[105]=ce,t[106]=oe,t[107]=Ne,t[108]=Pe):Pe=t[108];let Fe;t[109]!==Me||t[110]!==Pe?(Fe=(0,Z.jsxs)(Oo,{children:[Me,Pe]}),t[109]=Me,t[110]=Pe,t[111]=Fe):Fe=t[111];let Ie;t[112]!==pe||t[113]!==Ae||t[114]!==Fe?(Ie=(0,Z.jsxs)(wo,{className:`sm:max-w-md`,"data-ok-layer-spawned":``,children:[pe,Ae,Fe]}),t[112]=pe,t[113]=Ae,t[114]=Fe,t[115]=Ie):Ie=t[115];let Le;return t[116]!==r||t[117]!==n||t[118]!==Ie?(Le=(0,Z.jsx)(jo,{open:n,onOpenChange:r,children:Ie}),t[116]=r,t[117]=n,t[118]=Ie,t[119]=Le):Le=t[119],Le}function Up(e){return(0,Z.jsx)(Vo,{value:e,"aria-label":`Use ${e} extension`,children:e},e)}function Wp(e){return Vp(e.currentTarget)}function Gp(e){let t=(0,$.c)(53),{triggerId:n,labelledById:r,open:i,onOpenChange:a,value:o,onValueChange:s,templates:c,loading:l}=e,u=(0,Q.useId)(),d;if(t[0]!==c||t[1]!==o){let e;t[3]===o?e=t[4]:(e=e=>e.name===o,t[3]=o,t[4]=e),d=c.find(e),t[0]=c,t[1]=o,t[2]=d}else d=t[2];let p=d,m=o===Fp,h=i?u:void 0,g=`${r} ${n}`,_=l?`Loading templates`:m?`Blank note`:p?.title??p?.name??o,v;t[5]===_?v=t[6]:(v=(0,Z.jsx)(`span`,{className:`truncate`,children:_}),t[5]=_,t[6]=v);let y;t[7]!==m||t[8]!==l||t[9]!==p?(y=!l&&!m&&p?(0,Z.jsx)(Yp,{entry:p}):null,t[7]=m,t[8]=l,t[9]=p,t[10]=y):y=t[10];let b;t[11]!==v||t[12]!==y?(b=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[v,y]}),t[11]=v,t[12]=y,t[13]=b):b=t[13];let x;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(qs,{className:`ml-2 size-4 shrink-0 opacity-50`,"aria-hidden":`true`}),t[14]=x):x=t[14];let C;t[15]!==l||t[16]!==i||t[17]!==h||t[18]!==g||t[19]!==b||t[20]!==n?(C=(0,Z.jsx)(ne,{asChild:!0,children:(0,Z.jsxs)(Y,{id:n,type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":i,"aria-haspopup":`listbox`,"aria-controls":h,"aria-labelledby":g,disabled:l,className:`w-full justify-between font-normal`,children:[b,x]})}),t[15]=l,t[16]=i,t[17]=h,t[18]=g,t[19]=b,t[20]=n,t[21]=C):C=t[21];let w;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(Lt,{placeholder:`Search templates`}),t[22]=w):w=t[22];let T;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(z,{children:`No templates found.`}),t[23]=T):T=t[23];let E;t[24]!==a||t[25]!==s?(E=()=>{s(Fp),a(!1)},t[24]=a,t[25]=s,t[26]=E):E=t[26];let D=o===Fp?`opacity-100`:`opacity-0`,O;t[27]===D?O=t[28]:(O=mi(`mt-1 size-4 shrink-0`,D),t[27]=D,t[28]=O);let k;t[29]===O?k=t[30]:(k=(0,Z.jsx)(go,{className:O,"aria-hidden":`true`}),t[29]=O,t[30]=k);let A;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:`Blank note`}),(0,Z.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:`Empty starting content`})]}),t[31]=A):A=t[31];let j;t[32]!==E||t[33]!==k?(j=(0,Z.jsxs)(f,{value:`Blank note empty`,onSelect:E,className:`items-start gap-3`,children:[k,A]}),t[32]=E,t[33]=k,t[34]=j):j=t[34];let M;if(t[35]!==a||t[36]!==s||t[37]!==c||t[38]!==o){let e;t[40]!==a||t[41]!==s||t[42]!==o?(e=e=>{let t=e.title??e.name,n=e.title&&e.title!==e.name?e.name:void 0,r=`${e.scope}:${e.source_folder}:${e.name}`;return(0,Z.jsxs)(f,{value:r,keywords:[t,e.name,e.description??``,e.scope,e.source_folder??``],onSelect:()=>{s(e.name),a(!1)},className:`items-start gap-3`,children:[(0,Z.jsx)(go,{className:mi(`mt-1 size-4 shrink-0`,o===e.name?`opacity-100`:`opacity-0`),"aria-hidden":`true`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium`,children:t}),n?(0,Z.jsx)(`code`,{className:`font-mono text-2xs text-muted-foreground shrink-0`,children:n}):null,(0,Z.jsx)(Yp,{entry:e,className:`ml-auto`})]}),e.description?(0,Z.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:e.description}):null]})]},r)},t[40]=a,t[41]=s,t[42]=o,t[43]=e):e=t[43],M=c.map(e),t[35]=a,t[36]=s,t[37]=c,t[38]=o,t[39]=M}else M=t[39];let N;t[44]!==u||t[45]!==j||t[46]!==M?(N=(0,Z.jsx)(G,{className:`w-[var(--radix-popover-trigger-width)] p-0`,align:`start`,onOpenAutoFocus:Jp,onWheel:qp,onTouchMove:Kp,children:(0,Z.jsxs)(S,{children:[w,(0,Z.jsxs)(ge,{id:u,className:`subtle-scrollbar`,children:[T,j,M]})]})}),t[44]=u,t[45]=j,t[46]=M,t[47]=N):N=t[47];let P;return t[48]!==a||t[49]!==i||t[50]!==N||t[51]!==C?(P=(0,Z.jsxs)(H,{open:i,onOpenChange:a,children:[C,N]}),t[48]=a,t[49]=i,t[50]=N,t[51]=C,t[52]=P):P=t[52],P}function Kp(e){e.stopPropagation()}function qp(e){e.stopPropagation()}function Jp(e){e.preventDefault(),e.currentTarget.querySelector(`[cmdk-input]`)?.focus()}function Yp(e){let t=(0,$.c)(5),{entry:n,className:r}=e;if(n.scope===`inherited`){let e;t[0]===r?e=t[1]:(e=mi(`shrink-0 text-2xs`,r),t[0]=r,t[1]=e);let i=n.source_folder||`root`,a;return t[2]!==e||t[3]!==i?(a=(0,Z.jsx)(Ge,{variant:`gray`,className:e,children:i}),t[2]=e,t[3]=i,t[4]=a):a=t[4],a}return null}function Xp(e){return e.split(`/`).pop()??e}function Zp(e,t){let n=new Map;for(let e of t?.folders??[])n.set(e.path,e.summary);let r=e.created.filter(e=>e.kind===`folder`).map(e=>({kind:`folder`,name:`${e.path}/`,description:n.get(Xp(e.path))??``})),i=e.created.filter(e=>e.kind===`file`).map(e=>({kind:`file`,name:e.path,description:Xp(e.path)===`log.md`?`Append-only timeline`:``}));return[...r,...i]}function Qp(e){let t=(0,$.c)(20),{plan:n,selectedPack:r}=e,i,a,o,s,c,l;if(t[0]!==n||t[1]!==r){let e=[...Zp(n,r)].sort(tm),u=new Set(e.map(em));c=`space-y-2`,t[8]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase font-mono tracking-wider text-primary`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`flex items-center justify-center`,children:`◇`}),`What gets created`]}),t[8]=l):l=t[8],s=`overflow-hidden rounded-md border border-border/60 bg-muted/20`,i=`Items to be created`,a=`py-1.5`,o=e.map(e=>{let t=e.name.replace(/\/$/,``).split(`/`),n=0,r=0;for(let e=1;e<t.length;e++){let i=t.slice(0,e).join(`/`);u.has(i)&&(n++,r=e)}let i=t.slice(r).join(`/`)+(e.kind===`folder`?`/`:``),a=e.kind===`folder`;return(0,Z.jsxs)(`li`,{className:`relative flex min-w-0 items-center gap-1.5 py-1 pr-3`,style:{paddingLeft:`${12+n*16}px`},children:[Array.from({length:n},$p),a?(0,Z.jsx)(dc,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`,strokeWidth:1.5}):(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Z.jsx)(`code`,{className:`font-mono text-1sm shrink-0 text-foreground/80`,children:i}),a&&e.description?(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{"aria-label":`Show description`,className:`flex shrink-0 cursor-help rounded outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,children:(0,Z.jsx)(Xe,{"aria-hidden":`true`,className:`size-3 text-muted-foreground/60`,strokeWidth:1.5})}),(0,Z.jsx)(vn,{children:e.description})]}):null]},e.name)}),t[0]=n,t[1]=r,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];let u;t[9]!==i||t[10]!==a||t[11]!==o?(u=(0,Z.jsx)(`ul`,{"aria-label":i,className:a,children:o}),t[9]=i,t[10]=a,t[11]=o,t[12]=u):u=t[12];let d;t[13]!==s||t[14]!==u?(d=(0,Z.jsx)(`div`,{className:s,children:u}),t[13]=s,t[14]=u,t[15]=d):d=t[15];let f;return t[16]!==c||t[17]!==l||t[18]!==d?(f=(0,Z.jsxs)(`section`,{className:c,children:[l,d]}),t[16]=c,t[17]=l,t[18]=d,t[19]=f):f=t[19],f}function $p(e,t){return(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`absolute top-0 bottom-0 w-px bg-border/50`,style:{left:`${12+t*16+8}px`}},`guide:${t}`)}function em(e){return e.name.replace(/\/$/,``)}function tm(e,t){return e.name.localeCompare(t.name)}async function nm(e){let t=await e.json().catch(()=>null),n=fi.safeParse(t);if(!n.success)return{kind:`internal`,message:`HTTP ${e.status}`};let r=n.data.detail??n.data.title,i=n.data.type;return i===`urn:ok:error:seed-prerequisite-missing`?{kind:`prerequisite-missing`,message:r}:i===`urn:ok:error:seed-invalid-root`?{kind:`invalid-root`,message:r}:i===`urn:ok:error:no-project-dir`?{kind:`no-project`,message:r}:{kind:`internal`,message:r}}function rm(){let e=typeof window<`u`?window.okDesktop:void 0;return e?.seed?{plan:e.seed.plan,apply:e.seed.apply,listPacks:e.seed.listPacks}:{plan:async e=>{let t=new URLSearchParams;e?.rootDir&&t.set(`rootDir`,e.rootDir),e?.packId&&t.set(`packId`,e.packId);let n=t.toString(),r=await fetch(`/api/seed/plan${n?`?${n}`:``}`);if(!r.ok)return{ok:!1,error:await nm(r)};let i=await r.json().catch(()=>null);return i?.plan?{ok:!0,plan:i.plan}:{ok:!1,error:{kind:`internal`,message:`Malformed plan response`}}},apply:async(e,t)=>{let n=await fetch(`/api/seed/apply`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({plan:e,packId:t?.packId})});if(!n.ok)return{ok:!1,error:await nm(n)};let r=await n.json().catch(()=>null);return r?.result?{ok:!0,result:r.result}:{ok:!1,error:{kind:`internal`,message:`Malformed apply response`}}},listPacks:async()=>{let e=await fetch(`/api/seed/packs`);if(!e.ok)return{ok:!1,error:{kind:`internal`,message:`HTTP ${e.status}`}};let t=await e.json().catch(()=>null);return!t||!Array.isArray(t.packs)?{ok:!1,error:{kind:`internal`,message:`Malformed listPacks response`}}:{ok:!0,packs:t.packs}}}}var im={"knowledge-base":_c,"software-lifecycle":k,"plain-notes":Kc,worldbuilding:ec,"writing-pipeline":kc,gbrain:Cc};function am(e){return im[e]??_c}function om(e){let t=(0,$.c)(28),{onPackSelect:n,className:r,packs:i}=e,[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(null),l=i===void 0,u,d;t[0]===l?(u=t[1],d=t[2]):(u=()=>{if(!l)return;let e=!1;return(async()=>{try{let t=await rm().listPacks();if(e)return;t.ok?o(t.packs):c(t.error.message)}catch(t){let n=t;if(e)return;c(n instanceof Error?n.message:String(n))}})(),()=>{e=!0}},d=[l],t[0]=l,t[1]=u,t[2]=d),(0,Q.useEffect)(u,d);let f=l?a:i;if(s!==null){let e;t[3]===r?e=t[4]:(e=mi(`rounded-md bg-destructive/10 p-4 text-sm text-destructive`,r),t[3]=r,t[4]=e);let n;return t[5]!==s||t[6]!==e?(n=(0,Z.jsxs)(`div`,{role:`alert`,className:e,children:[`Couldn't load starter packs: `,s]}),t[5]=s,t[6]=e,t[7]=n):n=t[7],n}if(f===null){let e;t[8]===r?e=t[9]:(e=mi(`grid w-full max-w-5xl gap-4 sm:grid-cols-2 lg:grid-cols-3`,r),t[8]=r,t[9]=e);let n;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(n=Array.from({length:6},cm).map(sm),t[10]=n):n=t[10];let i;return t[11]!==e||t[12]!==n?(i=(0,Z.jsx)(`div`,{role:`status`,className:e,"aria-busy":`true`,"aria-label":`Loading starter packs`,children:n}),t[11]=e,t[12]=n,t[13]=i):i=t[13],i}if(f.length===0){let e;t[14]===r?e=t[15]:(e=mi(`flex w-full max-w-5xl items-center justify-center rounded-2xl border border-dashed border-border/60 bg-muted/20 p-8 text-sm text-muted-foreground`,r),t[14]=r,t[15]=e);let n;return t[16]===e?n=t[17]:(n=(0,Z.jsx)(`div`,{role:`status`,className:e,children:`No starter packs available.`}),t[16]=e,t[17]=n),n}let p;t[18]===r?p=t[19]:(p=mi(`grid w-full max-w-5xl gap-4 sm:grid-cols-2 lg:grid-cols-3`,r),t[18]=r,t[19]=p);let m;if(t[20]!==n||t[21]!==f){let e;t[23]===n?e=t[24]:(e=e=>(0,Z.jsx)(lm,{pack:e,onSelect:()=>n(e.id)},e.id),t[23]=n,t[24]=e),m=f.map(e),t[20]=n,t[21]=f,t[22]=m}else m=t[22];let h;return t[25]!==p||t[26]!==m?(h=(0,Z.jsx)(`div`,{className:p,children:m}),t[25]=p,t[26]=m,t[27]=h):h=t[27],h}function sm(e){return(0,Z.jsx)(dm,{},`skeleton-${e}`)}function cm(e,t){return t}function lm(e){let t=(0,$.c)(23),{pack:n,onSelect:r}=e,i;t[0]===n.id?i=t[1]:(i=am(n.id),t[0]=n.id,t[1]=i);let a=i,{files:o,folders:s}=n.entryCounts,c;t[2]===a?c=t[3]:(c=(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`flex size-8 items-center justify-center rounded-lg bg-primary/5 text-primary`,children:(0,Z.jsx)(a,{className:`size-4`})}),t[2]=a,t[3]=c);let l;t[4]===n.name?l=t[5]:(l=(0,Z.jsx)(`h3`,{className:`text-sm font-medium leading-tight`,children:n.name}),t[4]=n.name,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center gap-2`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]===n.description?d=t[10]:(d=(0,Z.jsx)(`p`,{className:`text-1sm leading-relaxed text-muted-foreground`,children:n.description}),t[9]=n.description,t[10]=d);let f;t[11]!==u||t[12]!==d?(f=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[u,d]}),t[11]=u,t[12]=d,t[13]=f):f=t[13];let p;t[14]!==o||t[15]!==s?(p=um({files:o,folders:s}),t[14]=o,t[15]=s,t[16]=p):p=t[16];let m;t[17]===p?m=t[18]:(m=(0,Z.jsx)(`p`,{className:`mt-auto pt-2 font-mono text-2xs uppercase tracking-wider text-muted-foreground`,children:p}),t[17]=p,t[18]=m);let h;return t[19]!==r||t[20]!==f||t[21]!==m?(h=(0,Z.jsxs)(`button`,{type:`button`,onClick:r,className:`group flex h-full flex-col items-start gap-4 rounded-2xl border border-border/60 bg-card p-5 text-left transition-[border-color,box-shadow,transform] hover:border-border hover:shadow-sm focus-visible:border-ring focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 active:translate-y-px`,children:[f,m]}),t[19]=r,t[20]=f,t[21]=m,t[22]=h):h=t[22],h}function um({files:e,folders:t}){let n=e>0?`${e} ${e===1?`file`:`files`}`:null,r=`${t} ${t===1?`folder`:`folders`}`;return n?`${n} · ${r}`:r}function dm(){let e=(0,$.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`span`,{className:`size-10 animate-pulse rounded-lg bg-muted`,"aria-hidden":`true`,children:(0,Z.jsx)(ue,{className:`size-5 animate-spin text-muted-foreground opacity-0`})}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsxs)(`div`,{className:`flex h-full min-h-[200px] flex-col items-start gap-4 rounded-xl border border-border/60 bg-card p-6`,children:[t,(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,children:[(0,Z.jsx)(`div`,{className:`h-4 w-1/2 animate-pulse rounded bg-muted`}),(0,Z.jsx)(`div`,{className:`h-3 w-full animate-pulse rounded bg-muted`}),(0,Z.jsx)(`div`,{className:`h-3 w-4/5 animate-pulse rounded bg-muted`})]}),(0,Z.jsx)(`div`,{className:`mt-auto h-3 w-20 animate-pulse rounded bg-muted`})]}),e[1]=n):n=e[1],n}function fm(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=mi(`grid w-full gap-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Lu,{"data-slot":`radio-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function pm(e){let t=(0,$.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=mi(`group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border border-input outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary`,n),t[3]=n,t[4]=i);let a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(zu,{"data-slot":`radio-group-indicator`,className:`flex size-4 items-center justify-center`,children:(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary-foreground`})}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,Z.jsx)(Ru,{"data-slot":`radio-group-item`,className:i,...r,children:a}),t[6]=r,t[7]=i,t[8]=o):o=t[8],o}var mm=`knowledge-base`;function hm(e){let t=(0,$.c)(74),{open:n,onOpenChange:r,onSeedApplied:i,initialPackId:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={kind:`loading`},t[0]=o):o=t[0];let[s,c]=(0,Q.useState)(o),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(a??mm),[p,m]=(0,Q.useState)(`project-root`),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(a===void 0?`pick`:`configure`),y=(0,Q.useRef)(!0),b;t[1]!==l||t[2]!==d?(b=l?.find(e=>e.id===d),t[1]=l,t[2]=d,t[3]=b):b=t[3];let x=b,S,C;t[4]!==n||t[5]!==l?(S=()=>{if(!n||l!==null)return;let e=!1;return(async()=>{try{let t=await rm().listPacks();if(e)return;t.ok?u(t.packs):(u([]),c({kind:`error`,message:t.error.message}))}catch(t){let n=t;if(e)return;u([]),c({kind:`error`,message:n instanceof Error?n.message:String(n)})}})(),()=>{e=!0}},C=[n,l],t[4]=n,t[5]=l,t[6]=S,t[7]=C):(S=t[6],C=t[7]),(0,Q.useEffect)(S,C);let w,T;t[8]!==a||t[9]!==n?(w=()=>{n&&(f(a??mm),m(`project-root`),g(``),v(a===void 0?`pick`:`configure`),c({kind:`loading`}),y.current=!0)},T=[n,a],t[8]=a,t[9]=n,t[10]=w,t[11]=T):(w=t[10],T=t[11]),(0,Q.useEffect)(w,T);let E,D;t[12]===x?(E=t[13],D=t[14]):(E=()=>{x&&g(x.defaultSubfolder??``)},D=[x],t[12]=x,t[13]=E,t[14]=D),(0,Q.useEffect)(E,D);let O;t[15]===h?O=t[16]:(O=h.trim(),t[15]=h,t[16]=O);let k=O,A=p===`subfolder`&&k===``,j,M;t[17]!==n||t[18]!==l||t[19]!==p||t[20]!==d||t[21]!==_||t[22]!==A||t[23]!==k?(j=()=>{if(!n||_!==`configure`||l===null)return;if(A){c({kind:`error`,message:`Enter a folder name (e.g. brain).`});return}let e=p===`project-root`?void 0:k,t=y.current?0:200;y.current=!1;let r=!1,i=setTimeout(()=>{r||(c(gm),rm().plan({rootDir:e,packId:d}).then(e=>{if(!r){if(!e.ok){c({kind:`error`,message:e.error.message});return}c(e.plan.created.length>0?{kind:`plan`,plan:e.plan}:{kind:`already-seeded`,plan:e.plan})}}).catch(e=>{r||c({kind:`error`,message:e instanceof Error?e.message:String(e)})}))},t);return()=>{r=!0,clearTimeout(i)}},M=[n,_,l,d,p,k,A],t[17]=n,t[18]=l,t[19]=p,t[20]=d,t[21]=_,t[22]=A,t[23]=k,t[24]=j,t[25]=M):(j=t[24],M=t[25]),(0,Q.useEffect)(j,M);let N;t[26]!==r||t[27]!==i||t[28]!==s.kind||t[29]!==s.plan||t[30]!==x?.name||t[31]!==d?(N=async function(){if(s.kind!==`plan`)return;let e=s.plan;c({kind:`applying`,plan:e});let t;try{t=await rm().apply(e,{packId:d})}catch(t){let n=t,r=n instanceof Error?n.message:String(n);X.error(`Initialize failed: ${r}`),c({kind:`plan`,plan:e});return}if(t.ok){let e=x?.name??`starter pack`,n=t.result.applied,a=n===0?`${e} was already set up. Nothing to do.`:`${e} initialized (${n} ${n===1?`entry`:`entries`})`;X.success(a),i?.(),r(!1)}else X.error(`Initialize failed: ${t.error.message}`),c({kind:`plan`,plan:e})},t[26]=r,t[27]=i,t[28]=s.kind,t[29]=s.plan,t[30]=x?.name,t[31]=d,t[32]=N):N=t[32];let P=N,F=a!==void 0,I=_===`configure`&&x?`Initialize ${x.name}`:`Initialize a starter pack`,L=_===`configure`&&x?x.description:`Pick a layout that matches what you're building. Each pack ships with folders, templates, and agent-readable descriptions. You can mix and match later.`,R;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(R=function(e){f(e),v(`configure`),y.current=!0},t[33]=R):R=t[33];let z=R,B;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(B=function(){v(`pick`),c({kind:`loading`}),y.current=!0},t[34]=B):B=t[34];let V=B,H;t[35]===I?H=t[36]:(H=(0,Z.jsx)(bo,{children:I}),t[35]=I,t[36]=H);let U;t[37]===L?U=t[38]:(U=(0,Z.jsx)(vo,{children:L}),t[37]=L,t[38]=U);let W;t[39]!==H||t[40]!==U?(W=(0,Z.jsxs)(Ao,{children:[H,U]}),t[39]=H,t[40]=U,t[41]=W):W=t[41];let G;t[42]!==l||t[43]!==s||t[44]!==p||t[45]!==x||t[46]!==_||t[47]!==h?(G=_===`pick`?(0,Z.jsx)(Do,{children:(0,Z.jsx)(om,{packs:l,onPackSelect:z})}):(0,Z.jsxs)(Do,{className:`space-y-6`,children:[(0,Z.jsx)(_m,{choice:p,subfolder:h,placeholder:x?.defaultSubfolder??`subfolder`,onChoiceChange:m,onSubfolderChange:g}),(0,Z.jsx)(vm,{phase:s,selectedPack:x})]}),t[42]=l,t[43]=s,t[44]=p,t[45]=x,t[46]=_,t[47]=h,t[48]=G):G=t[48];let K;t[49]!==F||t[50]!==_?(K=_===`configure`&&!F?(0,Z.jsxs)(Y,{className:`mr-auto uppercase font-mono`,variant:`ghost`,onClick:V,children:[(0,Z.jsx)(Mi,{"aria-hidden":`true`,className:`h-4 w-4`}),`Back`]}):null,t[49]=F,t[50]=_,t[51]=K):K=t[51];let q;t[52]===r?q=t[53]:(q=()=>r(!1),t[52]=r,t[53]=q);let ee=s.kind===`already-seeded`||s.kind===`error`?`Close`:`Cancel`,te;t[54]!==q||t[55]!==ee?(te=(0,Z.jsx)(Y,{className:`uppercase font-mono`,variant:`ghost`,onClick:q,children:ee}),t[54]=q,t[55]=ee,t[56]=te):te=t[56];let ne;t[57]!==P||t[58]!==s.kind||t[59]!==_||t[60]!==A?(ne=_===`configure`&&s.kind===`plan`?(0,Z.jsx)(Y,{onClick:P,disabled:A,children:`Initialize`}):_===`configure`&&s.kind===`applying`?(0,Z.jsxs)(Y,{disabled:!0,children:[(0,Z.jsx)(ue,{"aria-hidden":`true`,className:`h-4 w-4 animate-spin`}),`Setting up`]}):null,t[57]=P,t[58]=s.kind,t[59]=_,t[60]=A,t[61]=ne):ne=t[61];let re;t[62]!==K||t[63]!==te||t[64]!==ne?(re=(0,Z.jsxs)(Oo,{children:[K,te,ne]}),t[62]=K,t[63]=te,t[64]=ne,t[65]=re):re=t[65];let ie;t[66]!==W||t[67]!==G||t[68]!==re?(ie=(0,Z.jsxs)(wo,{className:`sm:max-w-3xl`,"data-ok-layer-spawned":``,children:[W,G,re]}),t[66]=W,t[67]=G,t[68]=re,t[69]=ie):ie=t[69];let ae;return t[70]!==r||t[71]!==n||t[72]!==ie?(ae=(0,Z.jsx)(jo,{open:n,onOpenChange:r,children:ie}),t[70]=r,t[71]=n,t[72]=ie,t[73]=ae):ae=t[73],ae}function gm(e){return e.kind===`plan`||e.kind===`already-seeded`?e:{kind:`loading`}}function _m(e){let t=(0,$.c)(20),{choice:n,subfolder:r,placeholder:i,onChoiceChange:a,onSubfolderChange:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:`Where should it live?`}),t[0]=s):s=t[0];let c;t[1]===a?c=t[2]:(c=e=>a(e),t[1]=a,t[2]=c);let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(ka,{htmlFor:`seed-root-project-root`,children:(0,Z.jsxs)(Ea,{orientation:`horizontal`,children:[(0,Z.jsxs)(qa,{children:[(0,Z.jsx)(Ha,{children:`Project root`}),(0,Z.jsx)($a,{className:`text-1sm`,children:`Scaffold directly under this project.`})]}),(0,Z.jsx)(pm,{value:`project-root`,id:`seed-root-project-root`})]})}),t[3]=l):l=t[3];let u,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(Ha,{children:`In a subfolder`}),d=(0,Z.jsx)($a,{className:`nth-last-2:mt-0 text-1sm`,children:`Created if missing; reused if it exists.`}),t[4]=u,t[5]=d):(u=t[4],d=t[5]);let f;t[6]!==n||t[7]!==o||t[8]!==i||t[9]!==r?(f=n===`subfolder`&&(0,Z.jsx)(Po,{value:r,onChange:e=>o(e.target.value),placeholder:i,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,className:`mt-1.5 font-mono text-xs bg-background`}),t[6]=n,t[7]=o,t[8]=i,t[9]=r,t[10]=f):f=t[10];let p;t[11]===f?p=t[12]:(p=(0,Z.jsxs)(qa,{children:[u,d,f]}),t[11]=f,t[12]=p);let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(pm,{value:`subfolder`,id:`seed-root-subfolder`}),t[13]=m):m=t[13];let h;t[14]===p?h=t[15]:(h=(0,Z.jsx)(ka,{htmlFor:`seed-root-subfolder`,children:(0,Z.jsxs)(Ea,{orientation:`horizontal`,children:[p,m]})}),t[14]=p,t[15]=h);let g;return t[16]!==n||t[17]!==c||t[18]!==h?(g=(0,Z.jsxs)(`div`,{className:`space-y-2 py-1`,children:[s,(0,Z.jsxs)(fm,{className:`sm:flex`,value:n,onValueChange:c,children:[l,h]})]}),t[16]=n,t[17]=c,t[18]=h,t[19]=g):g=t[19],g}function vm(e){let t=(0,$.c)(12),{phase:n,selectedPack:r}=e;if(n.kind===`loading`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 py-4 text-sm text-muted-foreground`,children:[(0,Z.jsx)(ue,{"aria-hidden":`true`,className:`h-4 w-4 animate-spin`}),`Computing scaffold plan`]}),t[0]=e):e=t[0],e}if(n.kind===`error`){let e;return t[1]===n.message?e=t[2]:(e=(0,Z.jsx)(`div`,{className:`rounded-md bg-destructive/10 p-3 text-sm text-destructive`,children:n.message}),t[1]=n.message,t[2]=e),e}if(n.kind===`already-seeded`){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`div`,{className:`py-2 text-sm`,children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:`This pack is already set up here.`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:`The folders and templates are in place; there's nothing left to scaffold.`})]}),t[3]=e):e=t[3],e}let i;t[4]!==n.plan||t[5]!==r?(i=(0,Z.jsx)(Qp,{plan:n.plan,selectedPack:r}),t[4]=n.plan,t[5]=r,t[6]=i):i=t[6];let a;t[7]===n.plan.warnings?a=t[8]:(a=n.plan.warnings.length>0?(0,Z.jsx)(`div`,{className:`rounded-md bg-warning/10 p-3 text-xs text-warning-foreground`,children:n.plan.warnings.map(ym)}):null,t[7]=n.plan.warnings,t[8]=a);let o;return t[9]!==i||t[10]!==a?(o=(0,Z.jsxs)(`div`,{className:`space-y-6 py-1 text-sm`,children:[i,a]}),t[9]=i,t[10]=a,t[11]=o):o=t[11],o}function ym(e){return(0,Z.jsx)(`p`,{children:e},e)}var bm=[{id:`claude-cowork`,displayName:`Claude Cowork`,appBrandName:`Claude Desktop`,schemes:[`claude:`],installUrl:`https://claude.com/download`,hasWebFallback:!0,tagline:`Conversational pairing in Claude Desktop's Cowork tab.`},{id:`claude-code`,displayName:`Claude`,appBrandName:`Claude Desktop`,schemes:[`claude:`],installUrl:`https://claude.com/download`,hasWebFallback:!0,tagline:`Agentic coding in Claude Desktop's Code tab.`},{id:`codex`,displayName:`Codex`,appBrandName:`Codex Desktop`,schemes:[`codex:`],installUrl:`https://openai.com/codex`,tagline:`OpenAI's coding agent, terminal-native.`},{id:`cursor`,displayName:`Cursor`,schemes:[`cursor:`],installUrl:`https://cursor.com/`,tagline:`AI-first VS Code fork with multi-file edits.`}],xm=bm.filter(e=>e.id!==`claude-cowork`),Sm=`#settings`;function Cm(e){let t=e.target;return t?.tagName===`INPUT`||t?.tagName===`TEXTAREA`||t?.isContentEditable?!1:!!((e.metaKey||e.ctrlKey)&&!e.altKey&&e.key===`,`)}function wm(e){return e.replace(/^#/,``)===`settings`}function Tm(){return typeof window>`u`?``:window.location.hash}function Em(){let e=(0,$.c)(4),[t,n]=(0,Q.useState)(Om),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=()=>{(0,Q.startTransition)(()=>{n(wm(Tm()))})};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Q.useEffect)(r,i);let a=Dm,o;return e[2]===t?o=e[3]:(o={open:t,close:a},e[2]=t,e[3]=o),o}function Dm(){typeof window>`u`||wm(Tm())&&window.history.back()}function Om(){return wm(Tm())}function km(){let e=(0,$.c)(3),[t,n]=(0,Q.useState)(Mm),r,i;return e[0]===t?(r=e[1],i=e[2]):(r=()=>{if(t!==null||window.okDesktop)return;let e=!0;return fetch(`/api/workspace`).then(async t=>{let r=await t.json().catch(jm);if(!e||!t.ok)return;let i=Kr.safeParse(r);i.success&&n({contentDir:i.data.contentDir,pathSeparator:i.data.pathSeparator})}).catch(Am),()=>{e=!1}},i=[t],e[0]=t,e[1]=r,e[2]=i),(0,Q.useEffect)(r,i),t}function Am(e){console.warn(`[useWorkspace] /api/workspace fetch failed:`,e)}function jm(){return null}function Mm(){return Nm()}function Nm(e=typeof window>`u`?void 0:window){if(!e)return null;let t=e.okDesktop;return t?{contentDir:t.config.projectPath,pathSeparator:t.platform===`win32`?`\\`:`/`}:null}function Pm(e){return{async install(t){let n;try{n=await e.buildAndOpen(t?.force?{force:!0}:void 0)}catch(e){return{ok:!1,reason:`bridge-error`,message:e instanceof Error?e.message:String(e)}}return n.ok?{ok:!0,path:n.path}:{ok:!1,reason:n.reason,message:n.message}}}}function Fm(e={}){let t=e.fetch??globalThis.fetch,n=`${e.apiOrigin??``}/api/install-skill`;return{async install(e){let r;try{r=await t(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?.force?{force:!0}:{})})}catch(e){return{ok:!1,reason:`network-error`,message:e instanceof Error?e.message:String(e)}}if(!r.ok){let e=`HTTP ${r.status}`;try{let t=Gn(await r.json());t&&(e=t)}catch{}return{ok:!1,reason:`http-error`,message:e}}let i;try{i=await r.json()}catch(e){return{ok:!1,reason:`parse-error`,message:e instanceof Error?e.message:`Invalid server response`}}return!i||typeof i.status!=`string`?{ok:!1,reason:`parse-error`,message:`Invalid server response shape`}:i.status===`failed`?{ok:!1,reason:`build-failed`,message:i.buildError??`unknown build failure`}:{ok:!0,path:i.outputPath,handoffWarning:i.handoffError?.message}}}}function Im(){if(typeof window>`u`)return null;let e=window.okDesktop?.skill;return e?Pm(e):Fm()}var Lm=`ok:skill:cowork:installed`,Rm=`1`,zm=250,Bm=`/api/skill/install-state`;function Vm(e){return`${Lm}:v${e}`}var Hm=new Map;async function Um(e={},t={}){let n=t.force?`__force__`:`__default__`,r=Hm.get(n);if(r)return r;let i=Wm(e,t);return Hm.set(n,i),i.finally(()=>{Hm.get(n)===i&&Hm.delete(n)}),i}async function Wm(e,t){let n=e.installer===void 0?Im():e.installer,r=Gm(e.storage),i=e.fetchSnapshot??qm,a=e.serverTimeoutMs??zm,o=null;if(!t.force){try{o=await Jm(i(),a)}catch(e){console.warn(`[cowork-skill] server install-state check failed; falling through:`,e)}if(o){let e=o.targets[`claude-cowork`]??null;if(e&&e.version===o.currentVersion)return{kind:`already-installed`,source:`server`}}}let s=Vm(o?.currentVersion??e.fallbackSkillVersion??Km());if(!t.force&&r?.getItem(s)===Rm)return{kind:`already-installed`,source:`local`};if(!n)return{kind:`host-unsupported`};let c=await n.install({force:t.force??!1});if(!c.ok)return{kind:`install-failed`,reason:c.reason,message:c.message};try{r?.setItem(s,Rm)}catch(e){console.warn(`[cowork-skill] storage.setItem failed (guard will not persist):`,e)}return{kind:`installed-now`,path:c.path,handoffWarning:c.handoffWarning}}function Gm(e){if(e!==void 0)return e;if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function Km(){return typeof window>`u`?`unknown`:window.okDesktop?.appVersion??`unknown`}async function qm(){let e;try{e=await fetch(Bm,{method:`GET`,cache:`no-store`})}catch{return null}if(!e.ok)return null;try{let t=await e.json();return typeof t?.currentVersion==`string`?t:null}catch{return null}}async function Jm(e,t){return Promise.race([e,new Promise(e=>{setTimeout(()=>e(null),t)})])}function Ym(e){return Um({},e)}function Xm(){return Um({},{force:!0})}async function Zm(e,t){let n;try{n=await t(`/api/handoff`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})}catch(e){return{ok:!1,reason:`dispatch-error`,detail:e instanceof Error?e.message:String(e)}}return n.status===200?{ok:!0}:n.status===404?{ok:!1,reason:`not-installed`,detail:`POST /api/handoff returned 404`}:n.status===422?{ok:!1,reason:`not-installed`,detail:`POST /api/handoff returned ${n.status}`}:{ok:!1,reason:`dispatch-error`,detail:`POST /api/handoff returned ${n.status}`}}async function Qm(e,t={}){let n=t.fetch??globalThis.fetch.bind(globalThis);switch(e.target){case`claude-cowork`:return Zm({target:`claude-cowork`,url:Nr({mode:`cowork`},e)},n);case`claude-code`:return Zm({target:`claude-code`,url:Nr({mode:`code`},e)},n);case`codex`:return Zm({target:`codex`,url:Zr(e)},n);case`cursor`:return Zm({target:`cursor`,url:mr(e),workspacePath:e.projectDir},n);default:{let t=e.target;return{ok:!1,reason:`invalid-payload`,detail:`unknown target: ${String(t)}`}}}}async function $m(e,t={}){let n=t.okDesktop??(typeof window<`u`?window.okDesktop:void 0);if(n?.shell?.openExternal)try{return await n.shell.openExternal(e),{ok:!0}}catch(e){return{ok:!1,reason:`dispatch-error`,detail:eh(e)}}let r=t.doc??(typeof document<`u`?document:void 0);if(!r)return{ok:!1,reason:`dispatch-error`,detail:`no DOM available`};try{let t=r.createElement(`a`);return t.href=e,t.rel=`noopener noreferrer`,/^https?:/i.test(e)&&(t.target=`_blank`),r.body.appendChild(t),t.click(),t.remove(),{ok:!0}}catch(e){return{ok:!1,reason:`dispatch-error`,detail:eh(e)}}}function eh(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}async function th(e,t={}){let n=t.okDesktop??(typeof window<`u`?window.okDesktop:void 0);if(n?.shell?.recordHandoff)try{await n.shell.recordHandoff(e)}catch(e){(t.warn??(e=>console.warn(e)))(`[handoff] recordHandoff IPC rejected (telemetry skipped): ${e instanceof Error?e.message:String(e)}`)}}function nh(e,t,n){let r=n===`\\`?t.replaceAll(`/`,`\\`):t;return`${e.endsWith(n)?e.slice(0,-1):e}${n}${r}`}function rh(e){return`${e}.md`}function ih(e){if(!e.docName||!e.workspace)return null;let t=rh(e.docName),{contentDir:n,pathSeparator:r}=e.workspace;return{docContext:{relativePath:t},projectDir:n,docPath:nh(n,t,r)}}function ah(e){return e.workspace?.contentDir?{docContext:null,projectDir:e.workspace.contentDir,docPath:``}:null}function oh(e){return!e.workspace?.contentDir||!e.folderAbsPath||!e.folderRelativePath?null:{docContext:null,folderRelativePath:e.folderRelativePath,projectDir:e.folderAbsPath,docPath:``}}function sh(e){return $m(e.installUrl).then(()=>void 0)}function ch(e){return`Opened in ${e}.`}function lh(e,t=1){return t>=3?`Couldn't reach ${e} — please try again later.`:t===2?`Still couldn't reach ${e} — try one more time?`:`Couldn't reach ${e} — try again?`}function uh(e){return e>=3?null:e===2?`Try one more time`:`Retry`}function dh(e,t,n,r){return t.ok?{target:e,host:n,outcome:`ok`,ts:r}:{target:e,host:n,outcome:`error`,ts:r,reason:t.reason}}function fh(e){return e.docContext===null?e.folderRelativePath?si(e.folderRelativePath):ar():$r(e.docContext.relativePath)}async function ph(e,t,n,r=1){if(e===`claude-cowork`&&r===1){let e;try{e=await n.ensureCoworkSkillInstalled()}catch(e){let t=e instanceof Error?e.message:String(e);return n.toast.error(`Couldn't install Open Knowledge skill — ${t}`),{ok:!1,reason:`dispatch-error`,detail:`install-error: ${t}`}}if(e.kind===`installed-now`)return n.toast.success(`Open Knowledge skill saved. Upload it in Claude Desktop, then click Cowork again.`),{ok:!0};if(e.kind===`install-failed`){let t=e.message??e.reason;return n.toast.error(`Couldn't install Open Knowledge skill — ${t}`),{ok:!1,reason:`dispatch-error`,detail:`install-failed: ${t}`}}}let i={target:e,projectDir:t.projectDir,docPath:t.docPath,prompt:fh(t)},a=await n.dispatchHandoff(i),o=dh(e,a,n.isElectronHost()?`electron`:`web`,n.now().toISOString());await n.recordHandoff(o);let s=n.getDisplayName(e);if(a.ok)n.toast.success(ch(s));else{let i=uh(r),a=lh(s,r);i===null?n.toast.error(a):n.toast.error(a,{action:{label:i,onClick:()=>{ph(e,t,n,r+1)}}})}return a}function mh(e){return bm.find(t=>t.id===e)?.displayName??e}function hh(e=typeof window<`u`?window:void 0){return e?.okDesktop!=null}function gh(){return{dispatchHandoff:Qm,recordHandoff:th,toast:{success:e=>{X.success(e)},error:(e,t)=>{X.error(e,t?{action:t.action}:void 0)}},now:()=>new Date,isElectronHost:()=>hh(),getDisplayName:mh,ensureCoworkSkillInstalled:Ym}}function _h(){return{dispatch:(e,t)=>ph(e,t,gh()),reinstallCoworkSkill:Xm}}var vh=[...new Set(bm.flatMap(e=>e.schemes))];function yh(e,t){let n=t.now?.()??Date.now(),r={};for(let t of bm){let i=t.schemes[0],a=i===void 0?void 0:e[i];if(!a){r[t.id]={installed:null};continue}r[t.id]={installed:a.installed,...a.displayName===void 0?{}:{displayName:a.displayName},lastChecked:n}}return r}function bh(e){return yh({},e)}async function xh(e){let t=e.schemes??vh,n=await Promise.all(t.map(async t=>{let n=t.replace(/:$/,``);try{return[t,await e.detectProtocol(n)]}catch{return[t,{installed:!1}]}}));return Object.fromEntries(n)}var Sh=Object.fromEntries(vh.map(e=>[e,{installed:!1}]));async function Ch(e){let t;try{t=await e.fetch(`/api/installed-agents`,{signal:e.signal,headers:{Accept:`application/json`}})}catch(e){if(e.name===`AbortError`)throw e;return Sh}if(!t.ok)return Sh;let n;try{n=await t.json()}catch{return Sh}if(typeof n!=`object`||!n||Array.isArray(n))return Sh;let r=n,i={};for(let e of vh)i[e]={installed:r[e.replace(/:$/,``)]===!0};return i}function wh(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(!n||!i||n.installed!==i.installed||n.displayName!==i.displayName)return!1}return!0}function Th(e){let t=e.throttleMs??1e4,n=!1,r=null,i=null,a={},o=bh({isElectronHost:e.isElectronHost(),now:e.now}),s=new Set,c=()=>{if(!n)for(let e of s)e(o)},l=()=>{o=yh(a,{isElectronHost:e.isElectronHost(),now:e.now})};return{probe:async()=>{if(n)return;if(i)return i;if(r!==null&&e.now()-r<t)return;let o=(async()=>{try{let t=await e.probe();if(n)return;let i=!wh(a,t);a=t,i&&(l(),c()),r=e.now()}catch{}finally{i=null}})();return i=o,o},getTargetStates:()=>o,subscribe:e=>(s.add(e),()=>{s.delete(e)}),cancel:()=>{n=!0,s.clear()}}}function Eh(e=typeof window<`u`?window:void 0){return e?.okDesktop!=null}function Dh(){let e=typeof window<`u`?window.okDesktop:void 0;if(e){let t=t=>e.shell.detectProtocol(t);return{probe:()=>xh({detectProtocol:t}),isElectronHost:()=>!0,now:Date.now}}let t=globalThis.fetch.bind(globalThis);return{probe:()=>Ch({fetch:t}),isElectronHost:()=>!1,now:Date.now}}function Oh(){let e=(0,$.c)(5),[t,n]=(0,Q.useState)(kh),r=(0,Q.useRef)(null),i,a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{let e=Th(Dh());r.current=e;let t=e.subscribe(n);e.probe();let i=()=>{e.probe()};return window.addEventListener(`focus`,i),()=>{window.removeEventListener(`focus`,i),t(),e.cancel(),r.current=null}},a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),(0,Q.useEffect)(i,a);let o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>r.current?.probe()??Promise.resolve(),e[2]=o):o=e[2];let s;return e[3]===t?s=e[4]:(s={states:t,refresh:o},e[3]=t,e[4]=s),s}function kh(){return bh({isElectronHost:Eh(),now:Date.now})}var Ah=3e3,jh=(e,t,n)=>il(e,t,n,`CommandPalette`);function Mh(e){window.location.assign(Tr(e))}function Nh(e,t){return e?.kind===`folder`||e?.kind===`folder-index`?e.folderPath:sr(t)}function Ph(e){let t=(0,$.c)(23),{entry:n,query:r,onSelect:i}=e,a=r===void 0?``:r,o=n.kind===`folder`?R:It,s;t[0]===n?s=t[1]:(s=`title`in n&&n.title?n.title:n.path.split(`/`).pop()??n.path,t[0]=n,t[1]=s);let c=s,l=`snippet`in n?n.snippet:void 0,u=`${n.kind} ${n.path}`,d=`command-palette-nav-${n.kind}-${n.path}`,p;t[2]===o?p=t[3]:(p=(0,Z.jsx)(o,{className:`mt-0.5`}),t[2]=o,t[3]=p);let m;t[4]!==a||t[5]!==c?(m=(0,Z.jsx)(`span`,{className:`truncate font-medium`,children:(0,Z.jsx)(Fh,{query:a,text:c})}),t[4]=a,t[5]=c,t[6]=m):m=t[6];let h;t[7]!==n.path||t[8]!==a?(h=(0,Z.jsx)(`span`,{className:`truncate text-muted-foreground text-xs`,children:(0,Z.jsx)(Fh,{query:a,text:n.path})}),t[7]=n.path,t[8]=a,t[9]=h):h=t[9];let g;t[10]!==a||t[11]!==l?(g=l?(0,Z.jsx)(`span`,{className:`max-h-10 overflow-hidden text-muted-foreground text-xs leading-relaxed`,children:(0,Z.jsx)(Fh,{query:a,text:l})}):null,t[10]=a,t[11]=l,t[12]=g):g=t[12];let _;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[m,h,g]}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;return t[17]!==i||t[18]!==u||t[19]!==d||t[20]!==p||t[21]!==_?(v=(0,Z.jsxs)(f,{value:u,onSelect:i,"data-testid":d,className:`items-start`,children:[p,_]}),t[17]=i,t[18]=u,t[19]=d,t[20]=p,t[21]=_,t[22]=v):v=t[22],v}function Fh(e){let t=(0,$.c)(5),{text:n,query:r}=e,i;t[0]!==r||t[1]!==n?(i=vp(n,r).map(Ih),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,Z.jsx)(Z.Fragment,{children:i}),t[3]=i,t[4]=a),a}function Ih(e){let t=`${e.start}:${e.match?`match`:`plain`}`;return e.match?(0,Z.jsx)(`mark`,{className:`rounded-sm bg-primary/10 px-0.5 font-semibold text-primary`,children:e.text},t):(0,Z.jsx)(`span`,{children:e.text},t)}function Lh({searchResults:e,fallbackSearchResults:t,searchStatus:n}){return e.length>0?e:n===`success`?[]:t}function Rh(e){let t=(0,$.c)(136),{bridge:n,open:r,onOpenChange:i}=e,a=n===void 0?null:n,[o,s]=(0,Q.useState)(``),c=(0,Q.useDeferredValue)(o),l=c.trim(),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],t[0]=u):u=t[0];let[d,p]=(0,Q.useState)(u),[m,h]=(0,Q.useState)(`idle`),g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],t[1]=g):g=t[1];let[_,v]=(0,Q.useState)(g),y;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(y=[],t[2]=y):y=t[2];let[b,S]=(0,Q.useState)(y),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),O;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(O=[],t[3]=O):O=t[3];let[k,j]=(0,Q.useState)(O),[N,P]=(0,Q.useState)(`idle`),F;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(F=[],t[4]=F):F=t[4];let[I,L]=(0,Q.useState)(F),[B,V]=(0,Q.useState)(`idle`),H=(0,Q.useRef)(!1),U=(0,Q.useRef)(null),W=(0,Q.useRef)(null),{activeDocName:G,activeTarget:K}=ot(),{pages:q,pageTitles:ee,pageMeta:te,folderPaths:ne}=qr(),re=km(),{states:ie,refresh:ae}=Oh(),{dispatch:se}=_h(),ce=ih({docName:G,workspace:re}),le=dp(q,ne,ee,te),J=rp(b,new Set(le.map(Vh))),ue=a?.config.projectPath??null,de=a?_.filter(e=>e.path!==ue):[],fe;t[5]!==G||t[6]!==K?(fe=Nh(K,G),t[5]=G,t[6]=K,t[7]=fe):fe=t[7];let pe=fe,me=l===``?[]:gp(le,l,8),he,_e;t[8]!==i||t[9]!==r?(he=()=>{let e=function(e){e.key===`k`&&(Dn()?e.metaKey:e.ctrlKey)&&(e.preventDefault(),i(!r))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},_e=[i,r],t[8]=i,t[9]=r,t[10]=he,t[11]=_e):(he=t[10],_e=t[11]),(0,Q.useEffect)(he,_e);let ve,ye;t[12]!==a||t[13]!==r||t[14]!==ae?(ve=()=>{if(r){if(S(ep()),ae(),a){let e=!1;return jh(async()=>{let t=await a.project.listRecent();e||v(t)},`Failed to load recent projects.`),()=>{e=!0}}return}s(``),j([]),P(`idle`),H.current=!1,L([]),V(`idle`)},ye=[r,a,ae],t[12]=a,t[13]=r,t[14]=ae,t[15]=ve,t[16]=ye):(ve=t[15],ye=t[16]),(0,Q.useEffect)(ve,ye);let be;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(be=()=>{U.current&&(U.current.scrollTop=0)},t[17]=be):be=t[17];let xe;t[18]===o?xe=t[19]:(xe=[o],t[18]=o,t[19]=xe),(0,Q.useEffect)(be,xe);let Se=Cp(c,new Set(k.map(Bh))),Ce=Se.kind!==`normal`,we,Te;t[20]!==Ce||t[21]!==r?(we=()=>{if(!r||!Ce||H.current)return;H.current=!0,P(`loading`);let e=!1;return Tp().then(t=>{e||(j(t),P(`success`))}).catch(t=>{e||(console.error(`[command-palette-tag] fetch tags failed`,t),j([]),P(`error`))}),()=>{e=!0}},Te=[r,Ce],t[20]=Ce,t[21]=r,t[22]=we,t[23]=Te):(we=t[22],Te=t[23]),(0,Q.useEffect)(we,Te);let Ee=Se.kind===`tag-docs`?Se.tagName:null;(0,Q.useEffect)(()=>{if(!r||Ee===null){L([]),V(`idle`);return}V(`loading`),L([]);let e=!1;return Ep(Ee).then(t=>{e||(L(t),V(`success`))}).catch(t=>{e||(console.error(`[command-palette-tag] fetch tag docs failed`,t),L([]),V(`error`))}),()=>{e=!0}},[r,Ee]),(0,Q.useEffect)(()=>{if(!r||!l||Ce){p([]),h(`idle`);return}let e=new AbortController;h(`loading`);let t=!1,n=window.setTimeout(()=>{t=!0,e.abort(),p([]),h(`error`)},Ah);return bp(l,{signal:e.signal}).then(e=>{window.clearTimeout(n),p(e),h(`success`)}).catch(e=>{window.clearTimeout(n),!(e instanceof Error&&e.name===`AbortError`&&!t)&&(p([]),h(`error`))}),()=>{window.clearTimeout(n),e.abort()}},[r,l,Ce]);let De;t[24]===i?De=t[25]:(De=(e,t)=>{let n=t===void 0?`Command failed.`:t;i(!1),jh(async()=>{await e()},n)},t[24]=i,t[25]=De);let Oe=De,ke;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(ke=function(e){let t={kind:e.kind,path:e.path,lastOpenedAt:new Date().toISOString()},n=np(ep(),t);tp(n),S(n)},t[26]=ke):ke=t[26];let Ae=ke,je;t[27]===i?je=t[28]:(je=function(e){i(!1),Ae(e),Mh(e.path)},t[27]=i,t[28]=je);let Me=je,Ne=!Ce&&l===``&&J.length>0,Pe=Lh({searchResults:d,fallbackSearchResults:me,searchStatus:m}),Fe=!Ce&&Pe.length>0,Ie=!Ce&&l!==``&&m===`loading`&&!Fe,Le;t[29]!==c||t[30]!==Ce?(Le=!Ce&&xp(`New file`,c,[`create file`]),t[29]=c,t[30]=Ce,t[31]=Le):Le=t[31];let Re=Le,ze;t[32]!==c||t[33]!==Ce?(ze=!Ce&&xp(`New folder`,c,[`create folder`]),t[32]=c,t[33]=Ce,t[34]=ze):ze=t[34];let Be=ze,Ve;t[35]!==G||t[36]!==c||t[37]!==Ce?(Ve=!Ce&&G!==null&&xp(`Open graph`,c,[`graph panel network`]),t[35]=G,t[36]=c,t[37]=Ce,t[38]=Ve):Ve=t[38];let He=Ve,Ue;t[39]!==c||t[40]!==Ce?(Ue=!Ce&&xp(`Initialize starter pack`,c,[`scaffold`,`seed`,`pack`,`starter`]),t[39]=c,t[40]=Ce,t[41]=Ue):Ue=t[41];let We=Ue,Ge;t[42]!==a||t[43]!==c||t[44]!==Ce?(Ge=!Ce&&a!==null&&xp(`Open folder on disk`,c,[`project`]),t[42]=a,t[43]=c,t[44]=Ce,t[45]=Ge):Ge=t[45];let Ke=Ge,qe;t[46]!==a||t[47]!==c||t[48]!==Ce?(qe=!Ce&&a!==null&&xp(`Switch Project`,c,[`switch project navigator projects`]),t[46]=a,t[47]=c,t[48]=Ce,t[49]=qe):qe=t[49];let Je=qe,Ye;t[50]!==c||t[51]!==Ce?(Ye=!Ce&&xp(`Settings`,c,[`preferences config`]),t[50]=c,t[51]=Ce,t[52]=Ye):Ye=t[52];let Xe=Ye,Ze;t[53]!==c||t[54]!==Ce?(Ze=!Ce&&xp(`Install for Claude Chat & Cowork (Desktop App)`,c,[`claude desktop install cowork`]),t[53]=c,t[54]=Ce,t[55]=Ze):Ze=t[55];let Qe=Ze,$e=!Ce&&a!==null&&de.length>0&&(l===``||de.some(e=>xp(`${e.name} ${e.path}`,c,[`open recent project`]))),et=!Ce&&ce!==null&&(l===``||xm.some(e=>xp(`Open with AI ${e.displayName}`,c,[e.id,`agent handoff`,`open in`]))),tt=Se.kind===`tag-list`?wp(k,Se.query):[],nt=Se.kind===`tag-list`&&N!==`loading`&&tt.length===0,rt=Se.kind===`tag-docs`&&B===`success`&&I.length===0,it=Ce||Ne||Fe||Ie||Re||Be||He||We||Ke||Je||Xe||Qe||$e||et,at;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(at=function(e){s(`${Sp}${e}`)},t[56]=at):at=t[56];let st=at,ct=A,lt;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(lt={shouldFilter:!1,className:`[&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4`},t[57]=lt):lt=t[57];let ut;t[58]===o?ut=t[59]:(ut=(0,Z.jsx)(Lt,{ref:W,value:o,onValueChange:s,placeholder:`Search files, folders, or commands`}),t[58]=o,t[59]=ut);let dt;t[60]===Ce?dt=t[61]:(dt=()=>{s(Ce?``:Sp),W.current?.focus()},t[60]=Ce,t[61]=dt);let ft=Ce?`border-primary/30 bg-primary/10 text-primary`:`border-border bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground`,pt;t[62]===ft?pt=t[63]:(pt=mi(`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors`,ft),t[62]=ft,t[63]=pt);let mt,ht;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(mt=(0,Z.jsx)(x,{className:`size-3.5`}),ht=(0,Z.jsx)(`span`,{children:`By tag`}),t[64]=mt,t[65]=ht):(mt=t[64],ht=t[65]);let gt;t[66]!==Ce||t[67]!==dt||t[68]!==pt?(gt=(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5 border-b px-3 py-2`,children:(0,Z.jsxs)(`button`,{type:`button`,onClick:dt,"data-testid":`command-palette-filter-tag`,"data-active":Ce,"aria-pressed":Ce,className:pt,children:[mt,ht]})}),t[66]=Ce,t[67]=dt,t[68]=pt,t[69]=gt):gt=t[69];let _t=ge,vt;t[70]!==Fe||t[71]!==Ie?(vt=Ie&&!Fe?(0,Z.jsx)(z,{children:`Searching`}):null,t[70]=Fe,t[71]=Ie,t[72]=vt):vt=t[72];let yt=it?null:(0,Z.jsx)(z,{children:m===`error`?`Search failed.`:`No matching commands.`}),bt=Se.kind===`tag-list`?(0,Z.jsxs)(oe,{heading:Se.query?`Tags matching "${Se.query}"`:`All tags`,children:[N===`loading`?(0,Z.jsx)(z,{children:`Loading tags`}):null,N===`error`?(0,Z.jsx)(z,{children:`Failed to load tags. Press Escape and re-open to retry.`}):null,nt?(0,Z.jsx)(z,{children:Se.query?`No tags match "${Se.query}".`:"No tags yet — author `#tagname` in any doc to populate the index."}):null,tt.map(e=>(0,Z.jsxs)(f,{value:`tag ${e.name}`,onSelect:()=>st(e.name),"data-testid":`command-palette-tag-${e.name}`,children:[(0,Z.jsx)(x,{}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.name}),(0,Z.jsxs)(`span`,{className:`ml-auto shrink-0 text-[11px] text-muted-foreground tabular-nums`,children:[e.count,` `,e.count===1?`doc`:`docs`]})]},`tag:${e.name}`))]}):null,xt;t[73]!==i||t[74]!==Se||t[75]!==rt||t[76]!==I||t[77]!==B?(xt=Se.kind===`tag-docs`?(0,Z.jsxs)(oe,{heading:`Docs tagged #${Se.tagName}`,children:[B===`loading`?(0,Z.jsx)(z,{children:`Loading docs`}):null,B===`error`?(0,Z.jsx)(z,{children:`Failed to load docs. Press Escape and re-open to retry.`}):null,rt?(0,Z.jsx)(z,{children:`No docs registered under #${Se.tagName}.`}):null,I.map(e=>{let t=e.title||e.docName.split(`/`).pop()||e.docName;return(0,Z.jsxs)(f,{value:`tag-doc ${e.docName}`,onSelect:()=>{i(!1),Mh(e.docName)},"data-testid":`command-palette-tag-doc-${e.docName}`,className:`items-start`,children:[(0,Z.jsx)(It,{className:`mt-0.5`}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`truncate font-medium`,children:t}),(0,Z.jsx)(`span`,{className:`truncate text-muted-foreground text-xs`,children:e.docName}),e.matchingTags.length>0&&e.matchingTags.some(e=>e!==Se.tagName)?(0,Z.jsxs)(`span`,{className:`truncate text-muted-foreground text-[11px]`,children:[`via`,` `,e.matchingTags.filter(e=>e!==Se.tagName).map(zh).join(`, `)]}):null]})]},`tag-doc:${e.docName}`)})]}):null,t[73]=i,t[74]=Se,t[75]=rt,t[76]=I,t[77]=B,t[78]=xt):xt=t[78];let St=Ne?(0,Z.jsx)(oe,{heading:`Recently opened`,children:J.map(e=>(0,Z.jsx)(Ph,{entry:e,onSelect:()=>Me(e)},$f(e.kind,e.path)))}):null,Ct;t[79]!==G||t[80]!==i||t[81]!==w||t[82]!==E||t[83]!==Re||t[84]!==Be||t[85]!==He||t[86]!==We?(Ct=Re||Be||He||We?(0,Z.jsxs)(oe,{heading:`Commands`,children:[Re?(0,Z.jsxs)(f,{value:`new file create file`,onSelect:()=>{i(!1),w(`file`)},"data-testid":`command-palette-new-file`,children:[(0,Z.jsx)(ac,{}),(0,Z.jsx)(`span`,{children:`New file`})]}):null,Be?(0,Z.jsxs)(f,{value:`new folder create folder`,onSelect:()=>{i(!1),w(`folder`)},"data-testid":`command-palette-new-folder`,children:[(0,Z.jsx)(uc,{}),(0,Z.jsx)(`span`,{children:`New folder`})]}):null,He?(0,Z.jsxs)(f,{value:`open graph graph panel network`,onSelect:()=>{G&&(i(!1),Ap(`graph`))},"data-testid":`command-palette-open-graph`,children:[(0,Z.jsx)(Cc,{}),(0,Z.jsx)(`span`,{children:`Open graph`})]}):null,We?(0,Z.jsxs)(f,{value:`initialize starter pack scaffold seed`,onSelect:()=>{i(!1),E(!0)},"data-testid":`command-palette-initialize-starter-pack`,children:[(0,Z.jsx)(Tc,{}),(0,Z.jsx)(`span`,{children:`Initialize starter pack`})]}):null]}):null,t[79]=G,t[80]=i,t[81]=w,t[82]=E,t[83]=Re,t[84]=Be,t[85]=He,t[86]=We,t[87]=Ct):Ct=t[87];let wt=et?(0,Z.jsx)(oe,{heading:`Open with AI`,children:xm.filter(e=>xp(`Open with AI ${e.displayName}`,c,[e.id,`agent handoff`,`open in`])).map(e=>{let t=ie[e.id],n=t.installed===!0&&ce!==null,r=t.installed===null?`Detecting`:t.installed===!1?`Not installed`:null,a=r?`Open with AI ${e.displayName}, ${r}`:`Open with AI ${e.displayName}`;return(0,Z.jsxs)(f,{value:`send to ai ${e.displayName} ${e.id} agent open in`,disabled:!n,onSelect:()=>{!n||!ce||(i(!1),se(e.id,ce))},"data-testid":`command-palette-open-in-${e.id}`,"aria-label":a,children:[(0,Z.jsxs)(`span`,{className:`flex-1`,children:[`Open with AI `,e.displayName]}),r?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-auto text-muted-foreground text-xs`,children:r}):null]},e.id)})}):null,Tt;t[88]!==a||t[89]!==i||t[90]!==Oe||t[91]!==Qe||t[92]!==Ke||t[93]!==Je||t[94]!==Xe?(Tt=Ke||Je||Xe||Qe?(0,Z.jsxs)(oe,{heading:`Project`,children:[Ke&&a?(0,Z.jsxs)(f,{value:`open folder on disk project`,onSelect:()=>Oe(async()=>{let e=await a.dialog.openFolder();e&&await a.project.open({path:e,target:`new-window`,entryPoint:`pick-existing`})}),"data-testid":`command-palette-open-folder`,children:[(0,Z.jsx)(R,{}),(0,Z.jsx)(`span`,{children:`Open folder on disk`}),(0,Z.jsx)(D,{children:`⌘O`})]}):null,Je&&a?(0,Z.jsxs)(f,{value:`switch-project navigator projects`,onSelect:()=>Oe(()=>a.navigator.open(),`Failed to open Project Navigator.`),"data-testid":`command-palette-switch-project`,children:[(0,Z.jsx)(gc,{}),(0,Z.jsx)(`span`,{children:`Switch Project`}),(0,Z.jsx)(D,{children:`⌘⇧N`})]}):null,Xe?(0,Z.jsxs)(f,{value:`settings preferences config`,onSelect:()=>{i(!1),window.location.hash!==`#settings`&&(window.location.hash=Sm)},"data-testid":`command-palette-settings`,children:[(0,Z.jsx)(zc,{}),(0,Z.jsx)(`span`,{children:`Settings`}),(0,Z.jsx)(D,{children:`⌘,`})]}):null,Qe?(0,Z.jsxs)(f,{value:`install claude desktop cowork app`,onSelect:()=>{i(!1),window.location.hash=`#install-claude-desktop`},"data-testid":`command-palette-install-claude-desktop`,children:[(0,Z.jsx)(ua,{}),(0,Z.jsx)(`span`,{children:`Install for Claude Chat & Cowork (Desktop App)`})]}):null]}):null,t[88]=a,t[89]=i,t[90]=Oe,t[91]=Qe,t[92]=Ke,t[93]=Je,t[94]=Xe,t[95]=Tt):Tt=t[95];let Et=$e&&a?(0,Z.jsx)(oe,{heading:`Open recent project`,children:de.filter(e=>xp(`${e.name} ${e.path}`,c,[`open recent project`])).slice(0,10).map(e=>(0,Z.jsxs)(f,{value:`${e.name} ${e.path} recent project`,disabled:e.missing,onSelect:()=>Oe(()=>a.project.open({path:e.path,target:`new-window`,entryPoint:`recents`}),`Failed to open project.`),"data-testid":`command-palette-recent-${e.path}`,className:`items-start`,children:[(0,Z.jsx)(M,{className:`mt-0.5`}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),(0,Z.jsxs)(`span`,{className:`truncate text-muted-foreground text-xs`,children:[e.path,e.missing?` (missing)`:``]})]})]},e.path))}):null,Dt=Fe?(0,Z.jsx)(oe,{heading:`Search`,children:Pe.map(e=>(0,Z.jsx)(Ph,{entry:e,query:l,onSelect:()=>Me(e)},$f(e.kind,e.path)))}):null,Ot;t[96]!==_t||t[97]!==vt||t[98]!==yt||t[99]!==bt||t[100]!==xt||t[101]!==St||t[102]!==Ct||t[103]!==wt||t[104]!==Tt||t[105]!==Et||t[106]!==Dt?(Ot=(0,Z.jsxs)(_t,{ref:U,className:`subtle-scrollbar`,children:[vt,yt,bt,xt,St,Ct,wt,Tt,Et,Dt]}),t[96]=_t,t[97]=vt,t[98]=yt,t[99]=bt,t[100]=xt,t[101]=St,t[102]=Ct,t[103]=wt,t[104]=Tt,t[105]=Et,t[106]=Dt,t[107]=Ot):Ot=t[107];let kt;t[108]!==ct||t[109]!==i||t[110]!==r||t[111]!==lt||t[112]!==ut||t[113]!==gt||t[114]!==Ot?(kt=(0,Z.jsxs)(ct,{open:r,onOpenChange:i,title:`Workspace Command Palette`,description:`Search files, folders, and commands for the current workspace.`,className:`sm:max-w-2xl`,commandProps:lt,children:[ut,gt,Ot]}),t[108]=ct,t[109]=i,t[110]=r,t[111]=lt,t[112]=ut,t[113]=gt,t[114]=Ot,t[115]=kt):kt=t[115];let At=C===`file`,jt;t[116]===w?jt=t[117]:(jt=e=>{e||w(null)},t[116]=w,t[117]=jt);let Mt;t[118]!==pe||t[119]!==At||t[120]!==jt?(Mt=(0,Z.jsx)(Hp,{open:At,onOpenChange:jt,kind:`file`,initialDir:pe}),t[118]=pe,t[119]=At,t[120]=jt,t[121]=Mt):Mt=t[121];let Nt=C===`folder`,Pt;t[122]===w?Pt=t[123]:(Pt=e=>{e||w(null)},t[122]=w,t[123]=Pt);let Ft;t[124]!==pe||t[125]!==Nt||t[126]!==Pt?(Ft=(0,Z.jsx)(Hp,{open:Nt,onOpenChange:Pt,kind:`folder`,initialDir:pe}),t[124]=pe,t[125]=Nt,t[126]=Pt,t[127]=Ft):Ft=t[127];let Rt;t[128]!==T||t[129]!==E?(Rt=(0,Z.jsx)(hm,{open:T,onOpenChange:E}),t[128]=T,t[129]=E,t[130]=Rt):Rt=t[130];let zt;return t[131]!==kt||t[132]!==Mt||t[133]!==Ft||t[134]!==Rt?(zt=(0,Z.jsxs)(Z.Fragment,{children:[kt,Mt,Ft,Rt]}),t[131]=kt,t[132]=Mt,t[133]=Ft,t[134]=Rt,t[135]=zt):zt=t[135],zt}function zh(e){return`#${e}`}function Bh(e){return e.name}function Vh(e){return $f(e.kind,e.path)}var Hh=500;function Uh(e,t,n){return t?`terminal`:e===null&&n?`retrying`:`hidden`}function Wh(e){return e===null?`no response`:e.kind===`null-collab`?`ok ui responded but server.lock has no port yet`:e.code===`network`?"network error (is `ok ui` running?)":e.code===`invalid-body`?`/api/config returned a malformed body`:`/api/config returned HTTP ${e.code}`}function Gh(){let e=(0,$.c)(16),{collabUrl:t,collabTerminal:n,collabLastError:r,retryCollab:i}=ot(),[a,o]=(0,Q.useState)(!1),s,c;e[0]!==n||e[1]!==t?(s=()=>{if(t!==null||n){o(!1);return}let e=setTimeout(()=>o(!0),Hh);return()=>clearTimeout(e)},c=[t,n],e[0]=n,e[1]=t,e[2]=s,e[3]=c):(s=e[2],c=e[3]),(0,Q.useEffect)(s,c);let l=Uh(t,n,a);if(l===`hidden`)return null;if(l===`terminal`){let t;e[4]===r?t=e[5]:(t=Wh(r),e[4]=r,e[5]=t);let n;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`code`,{className:`bg-red-100/60 px-1 rounded`,children:`ok status`}),e[6]=n):n=e[6];let a;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(`code`,{className:`bg-red-100/60 px-1 rounded`,children:`.ok/local/last-spawn-error.log`}),e[7]=a):a=e[7];let o;e[8]===t?o=e[9]:(o=(0,Z.jsxs)(`span`,{children:[`Couldn't reach collab server — `,t,`. Try`,` `,n,` or check`,` `,a,`.`]}),e[8]=t,e[9]=o);let s;e[10]===i?s=e[11]:(s=(0,Z.jsx)(`button`,{type:`button`,onClick:i,className:`bg-red-950 text-red-50 px-2 py-0.5 rounded text-xs font-medium hover:bg-red-900`,children:`Retry`}),e[10]=i,e[11]=s);let c;return e[12]!==o||e[13]!==s?(c=(0,Z.jsxs)(`div`,{role:`alert`,"aria-live":`assertive`,className:`fixed top-0 inset-x-0 z-50 bg-red-500/95 text-red-950 text-sm text-center py-2 px-4 pl-[var(--ok-titlebar-reserve-left,1rem)] shadow-md flex items-center justify-center gap-3 flex-wrap`,children:[o,s]}),e[12]=o,e[13]=s,e[14]=c):c=e[14],c}let u;return e[15]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`fixed top-0 inset-x-0 z-50 bg-amber-500/95 text-amber-950 text-sm text-center py-2 px-4 pl-[var(--ok-titlebar-reserve-left,1rem)] shadow-md`,children:`Connecting — waiting for collab server`}),e[15]=u):u=e[15],u}async function Kh(e){let t=await fetch(`/api/tags/${encodeURIComponent(e)}`);if(!t.ok){let e=await t.json().catch(()=>null);throw Error(Gn(e)??`Server error: ${t.status} ${t.statusText}`)}return(await t.json()).docs??[]}function qh(){let e=(0,$.c)(15),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(null),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={kind:`idle`},e[0]=a):a=e[0];let[o,s]=(0,Q.useState)(a),c=(0,Q.useRef)(0),l,u;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=function(e){let t=e.detail;if(!t||typeof t.value!=`string`)return;let r=c.current+=1;i(t.value),n(!0),s({kind:`loading`}),Kh(t.value).then(e=>{c.current===r&&s({kind:`ready`,docs:e})}).catch(e=>{c.current===r&&s({kind:`error`,message:e instanceof Error?e.message:String(e)})})};return document.addEventListener(rt,e),()=>document.removeEventListener(rt,e)},u=[],e[1]=l,e[2]=u):(l=e[1],u=e[2]),(0,Q.useEffect)(l,u);let d;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=function(e){n(!1),window.location.assign(Tr(e))},e[3]=d):d=e[3];let f=d,p=r??``,m;e[4]===p?m=e[5]:(m=(0,Z.jsx)(Ao,{children:(0,Z.jsxs)(bo,{children:[`Documents tagged `,(0,Z.jsxs)(`span`,{className:`font-mono`,children:[`#`,p]})]})}),e[4]=p,e[5]=m);let h=r??``,g;e[6]!==o||e[7]!==h?(g=(0,Z.jsx)(Do,{children:(0,Z.jsx)(Jh,{fetchState:o,tag:h,onSelectDoc:f})}),e[6]=o,e[7]=h,e[8]=g):g=e[8];let _;e[9]!==m||e[10]!==g?(_=(0,Z.jsxs)(wo,{children:[m,g]}),e[9]=m,e[10]=g,e[11]=_):_=e[11];let v;return e[12]!==t||e[13]!==_?(v=(0,Z.jsx)(jo,{open:t,onOpenChange:n,children:_}),e[12]=t,e[13]=_,e[14]=v):v=e[14],v}function Jh(e){let t=(0,$.c)(12),{fetchState:n,tag:r,onSelectDoc:i}=e;if(n.kind===`idle`||n.kind===`loading`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`p`,{className:`text-muted-foreground text-sm`,"data-testid":`tag-dialog-loading`,children:`Loading`}),t[0]=e):e=t[0],e}if(n.kind===`error`){let e;return t[1]===n.message?e=t[2]:(e=(0,Z.jsx)(`p`,{className:`text-destructive text-sm`,"data-testid":`tag-dialog-error`,children:n.message}),t[1]=n.message,t[2]=e),e}if(n.docs.length===0){let e;return t[3]===r?e=t[4]:(e=(0,Z.jsxs)(`p`,{className:`text-muted-foreground text-sm`,"data-testid":`tag-dialog-empty`,children:[`Only the current document uses `,(0,Z.jsxs)(`span`,{className:`font-mono`,children:[`#`,r]}),`.`]}),t[3]=r,t[4]=e),e}let a;if(t[5]!==n.docs||t[6]!==i){let e;t[8]===i?e=t[9]:(e=e=>{let t=e.matchingTags??[];return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,className:`w-full rounded-md px-2 py-1.5 text-left text-sm hover:bg-muted focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring`,onClick:()=>i(e.docName),"data-testid":`tag-dialog-row`,children:[(0,Z.jsx)(`span`,{className:`block truncate font-medium`,children:e.title}),e.docName===e.title?null:(0,Z.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:e.docName}),t.length>0?(0,Z.jsx)(`span`,{className:`mt-1 flex flex-wrap items-center gap-1`,"data-testid":`tag-dialog-row-matches`,children:t.map(Yh)}):null]})},e.docName)},t[8]=i,t[9]=e),a=n.docs.map(e),t[5]=n.docs,t[6]=i,t[7]=a}else a=t[7];let o;return t[10]===a?o=t[11]:(o=(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1`,"data-testid":`tag-dialog-list`,children:a}),t[10]=a,t[11]=o),o}function Yh(e){return(0,Z.jsxs)(`span`,{"data-testid":`tag-dialog-row-match`,"data-tag":e,className:`tag pointer-events-none text-xs`,children:[`#`,e]},e)}var Xh=`raw-mdx-nav`,Zh=`ok-editor-mode-v1`,Qh=[`wysiwyg`,`source`],$h=`wysiwyg`;function eg(e){return Qh.includes(e)}function tg(e=localStorage){try{let t=e.getItem(Zh);if(t===null)return $h;if(eg(t))return t;console.warn(`[editor-mode] invalid persisted value, falling back to default`,{raw:t})}catch{}return $h}function ng(e=window,t=localStorage){let n=e.__OK_EDITOR_MODE__;return eg(n)?n:tg(t)}function rg(e,t=localStorage){try{return t.setItem(Zh,e),!0}catch(e){return console.warn(`[editor-mode] persist failed`,e),!1}}function ig(){let e=(0,$.c)(3),[t,n]=(0,Q.useState)(ng),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=function(e){n(e),rg(e)},e[0]=r):r=e[0];let i=r,a;return e[1]===t?a=e[2]:(a=[t,i],e[1]=t,e[2]=a),a}function ag(e){let t=(0,$.c)(22),{open:n,onResolved:r}=e,i=da(),a;t[0]!==r||t[1]!==i?(a=function(e){if(i===null){X.error(`Sync settings not yet loaded — try again in a moment`);return}let t=i(e);if(!t.ok){X.error(`Could not ${e?`enable sync`:`save sync preference`}: ${t.error}`);return}r()},t[0]=r,t[1]=i,t[2]=a):a=t[2];let o=a,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(Ao,{children:(0,Z.jsx)(Bi,{})}),t[3]=s):s=t[3];let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(ja,{}),t[4]=c):c=t[4];let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsxs)(Do,{children:[c,(0,Z.jsxs)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:[`You can turn this on later in `,(0,Z.jsx)(`span`,{className:`font-medium`,children:`Settings → Sync`}),`.`]})]}),t[5]=l):l=t[5];let u;t[6]===o?u=t[7]:(u=()=>o(!1),t[6]=o,t[7]=u);let d=i===null,f;t[8]!==u||t[9]!==d?(f=(0,Z.jsx)(Y,{variant:`ghost`,className:`uppercase font-mono`,onClick:u,disabled:d,children:`Keep disabled`}),t[8]=u,t[9]=d,t[10]=f):f=t[10];let p;t[11]===o?p=t[12]:(p=()=>o(!0),t[11]=o,t[12]=p);let m=i===null,h;t[13]!==p||t[14]!==m?(h=(0,Z.jsx)(Y,{onClick:p,disabled:m,children:`Enable auto-sync`}),t[13]=p,t[14]=m,t[15]=h):h=t[15];let g;t[16]!==h||t[17]!==f?(g=(0,Z.jsxs)(wo,{className:`sm:max-w-lg`,showCloseButton:!1,children:[s,l,(0,Z.jsxs)(Oo,{children:[f,h]})]}),t[16]=h,t[17]=f,t[18]=g):g=t[18];let _;return t[19]!==n||t[20]!==g?(_=(0,Z.jsx)(jo,{open:n,onOpenChange:og,children:g}),t[19]=n,t[20]=g,t[21]=_):_=t[21],_}function og(){}function sg(e){let t=(0,$.c)(9),{onOpenResolver:n}=e,r=Qa();if(!r||r.state!==`conflict`)return null;let i=r.conflictCount,a=i>0?`${i} page${i===1?``:`s`}`:`Some pages`,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(dr,{className:`size-4 shrink-0`}),t[0]=o):o=t[0];let s=i===1?`has`:`have`,c;t[1]!==a||t[2]!==s?(c=(0,Z.jsxs)(`span`,{className:`flex-1`,children:[a,` `,s,` conflicting changes.`]}),t[1]=a,t[2]=s,t[3]=c):c=t[3];let l;t[4]===n?l=t[5]:(l=(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,className:`shrink-0 border-amber-400 dark:border-amber-700 text-amber-800 dark:text-amber-300 hover:bg-amber-100 dark:hover:bg-amber-900/50`,onClick:n,children:`Review and resolve`}),t[4]=n,t[5]=l);let u;return t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm border-b bg-amber-50 dark:bg-amber-950/30 text-amber-800 dark:text-amber-300 shrink-0`,children:[o,c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8],u}var cg=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 lg(e,t,n,r,i,a){if(e==r)return[];let o=yg(e,t,n,r,i,a),s=bg(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 cg(t,n,i,a)];if(c>l){let o=e.slice(t,n).indexOf(r.slice(i,a));if(o>-1)return[new cg(t,t+o,i,i),new cg(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 cg(t,t,i,i+o),new cg(n,n,i+o+c,a)]}if(c==1||l==1)return[new cg(t,n,i,a)];let u=Sg(e,t,n,r,i,a);if(u){let[o,s,c]=u;return lg(e,t,o,r,i,s).concat(lg(e,o+c,n,r,s+c,a))}return pg(e,t,n,r,i,a)}var ug=1e9,dg=0,fg=!1;function pg(e,t,n,r,i,a){let o=n-t,s=a-i;if(ug<1e9&&Math.min(o,s)>ug*16||dg>0&&Date.now()>dg)return Math.min(o,s)>ug*64?[new cg(t,n,i,a)]:Cg(e,t,n,r,i,a);let c=Math.ceil((o+s)/2);hg.reset(c),gg.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:gg,f=d?null:hg;for(let p=0;p<c;p++){if(p>ug||dg>0&&!(p&63)&&Date.now()>dg)return Cg(e,t,n,r,i,a);let m=hg.advance(p,o,s,c,d,!1,l)||gg.advance(p,o,s,c,f,!0,u);if(m)return _g(e,t,n,t+m[0],r,i,a,i+m[1])}return[new cg(t,n,i,a)]}var mg=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}},hg=new mg,gg=new mg;function _g(e,t,n,r,i,a,o,s){let c=!1;return!Rg(e,r)&&++r==n&&(c=!0),!Rg(i,s)&&++s==o&&(c=!0),c?[new cg(t,n,a,o)]:lg(e,t,r,i,a,s).concat(lg(e,r,n,i,s,o))}function vg(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function yg(e,t,n,r,i,a){if(t==n||t==a||e.charCodeAt(t)!=r.charCodeAt(i))return 0;let o=vg(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-+!Rg(e,s);o>>=1}else if(i==n||l==a)return i-t;else s=i,c=l}}function bg(e,t,n,r,i,a){if(t==n||i==a||e.charCodeAt(n-1)!=r.charCodeAt(a-1))return 0;let o=vg(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-+!Rg(e,s);o>>=1}else if(a==t||l==i)return n-a;else s=a,c=l}}function xg(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;;){Rg(e,s)||s++;let u=s+o;if(Rg(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=yg(e,u,n,r,i+f+d.length,a),c=bg(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 Sg(e,t,n,r,i,a){let o=n-t,s=a-i;if(o<s){let o=Sg(r,i,a,e,t,n);return o&&[o[1],o[0],o[2]]}return o<4||s*2<o?null:xg(e,t,n,r,i,a,Math.floor(o/4),-1)}function Cg(e,t,n,r,i,a){fg=!0;let o=n-t,s=a-i,c;if(o<s){let s=xg(r,i,a,e,t,n,Math.floor(o/6),50);c=s&&[s[1],s[0],s[2]]}else c=xg(e,t,n,r,i,a,Math.floor(s/6),50);if(!c)return[new cg(t,n,i,a)];let[l,u,d]=c;return lg(e,t,l,r,i,u).concat(lg(e,l+d,n,r,u+d,a))}function wg(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 cg(r.fromA,i.toA,r.fromB,i.toB),e.splice(n--,1))}}function Tg(e,t,n){for(;;){wg(n,1);let r=!1;for(let i=0;i<n.length;i++){let a=n[i],o,s;(o=yg(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new cg(a.fromA+o,a.toA,a.fromB+o,a.toB)),(s=bg(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new cg(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 cg(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 cg(a.fromA+d,a.toA+d,a.fromB+d,a.toB+d),r=!0)}if(!r)break}return n}function Eg(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=Ng(t,a.fromA,l),f=Mg(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 cg(d,d+o,a.fromB-p,a.toB-p),d=a.fromA,f=Mg(t,a.toA,c-a.toA)):l>m&&t.slice(a.toA,f)==u.slice(h,h+m)&&(a=e[i]=new cg(f-o,f,a.fromB+m,a.toB+m),f=a.toA,d=Ng(t,a.fromA,a.fromA-r)),p=a.fromA-d,m=f-a.toA}if(p||m)a=e[i]=new cg(a.fromA-p,a.toA+m,a.fromB-p,a.toB+m);else if(!o){let t=Fg(n,a.fromB,a.toB),r,o=t<0?-1:Pg(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=Fg(t,a.fromA,a.toA),r,o=n<0?-1:Pg(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 wg(e,3),e}var Dg;try{Dg=RegExp(`[\\p{Alphabetic}\\p{Number}]`,`u`)}catch{}function Og(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function kg(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?+!!Og(n):Dg?!Ig(n)||t==e.length-1?+!!Dg.test(String.fromCharCode(n)):Dg.test(e.slice(t,t+2))?2:0:0}function Ag(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?+!!Og(n):Dg?!Lg(n)||t==1?+!!Dg.test(String.fromCharCode(n)):Dg.test(e.slice(t-2,t))?2:0:0}var jg=8;function Mg(e,t,n){if(t==e.length||!Ag(e,t))return t;for(let r=t,i=t+n,a=0;a<jg;a++){let t=kg(e,r);if(!t||r+t>i)return r;r+=t}return t}function Ng(e,t,n){if(!t||!kg(e,t))return t;for(let r=t,i=t-n,a=0;a<jg;a++){let t=Ag(e,r);if(!t||r-t<i)return r;r-=t}return t}function Pg(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function Fg(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}var Ig=e=>e>=55296&&e<=56319,Lg=e=>e>=56320&&e<=57343;function Rg(e,t){return!t||t==e.length||!Ig(e.charCodeAt(t-1))||!Lg(e.charCodeAt(t))}function zg(e,t,n){let r=n?.override;return r?r(e,t):(ug=(n?.scanLimit??1e9)>>1,dg=n?.timeout?Date.now()+n.timeout:0,fg=!1,Tg(e,t,lg(e,0,e.length,t,0,t.length)))}function Bg(){return!fg}function Vg(e,t,n){return Eg(zg(e,t,n),e,t)}var Hg=os.define({combine:e=>e[0]}),Ug=ss.define(),Wg=os.define(),Gg=ts.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(Ug)&&(e=n.value);for(let n of t.state.facet(Wg))e=n(e,t);return e}});function Kg(e){let t=e.field(Gg,!1);if(!t)return null;let n=e.facet(Hg);return{chunks:t,side:n?n.side:null}}var qg=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 Xg(Vg(e.toString(),t.toString(),n),e,t,0,0,Bg())}static updateA(e,t,n,r,i){return e_($g(e,r,!0,n.length),e,t,n,i)}static updateB(e,t,n,r,i){return e_($g(e,r,!1,t.length),e,t,n,i)}};function Jg(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 Yg(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 Xg(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length;s++){let c=e[s],[l,u]=Jg(c.fromA+r,c.fromB+i,t,n),[d,f]=Yg(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]=Jg(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]=Yg(a.toA+r,a.toB+i,t,n),s++}o.push(new qg(p,l,Math.max(l,d),u,Math.max(u,f),a))}return o}var Zg=1e3;function Qg(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 $g(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>Zg&&([l,d]=Qg(e,a-Zg,n,!0)),o<t.length-Zg&&([u,f]=Qg(e,o+Zg,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 e_(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=Vg(n.sliceString(d,p),r.sliceString(f,m),i);for(let e of Xg(h,n,r,d,f,Bg()))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 t_={scanLimit:500},n_=cs.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=f_(e))}update(e){(e.docChanged||e.viewportChanged||i_(e.startState,e.state)||a_(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=f_(e.view))}},{decorations:e=>e.deco}),r_=Qo.low(fs({class:`cm-changeGutter`,markers:e=>e.plugin(n_)?.gutter||hs.empty}));function i_(e,t){return e.field(Gg,!1)!=t.field(Gg,!1)}function a_(e,t){return e.facet(Hg)!=t.facet(Hg)}var o_=is.line({class:`cm-changedLine`}),s_=is.mark({class:`cm-changedText`}),c_=is.mark({tagName:`ins`,class:`cm-insertedLine`}),l_=is.mark({tagName:`del`,class:`cm-deletedLine`}),u_=new class extends ds{constructor(){super(...arguments),this.elementClass=`cm-changedLineGutter`}};function d_(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,o_),i.add(o,s,n?l_:c_),a&&a.add(o,o,u_);for(let l=t.iterRange(o,s-1),u=o;!l.next().done;){if(l.lineBreak){u++,i.add(u,u,o_),a&&a.add(u,u,u_);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,s_),s<t)c++;else break}u=t}}}function f_(e){let t=e.state.field(Gg),{side:n,highlightChanges:r,markGutter:i,overrideChunk:a}=e.state.facet(Hg),o=n==`a`,s=new as,c=i?new as: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))&&d_(n,e.state.doc,o,r,s,c)}return{deco:s.finish(),gutter:c&&c.finish()}}var p_=class extends Zo{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}},m_=ss.define({map:(e,t)=>e.map(t)}),h_=ts.define({create:()=>is.none,update:(e,t)=>{for(let e of t.effects)if(e.is(m_))return e.value;return e.map(t.changes)},provide:e=>us.decorations.from(e)}),g_=.01;function __(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 v_(e,t,n){let r=new as,i=new as,a=e.state.field(h_).iter(),o=t.state.field(h_).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<-g_?(l-=n,r.add(s,s,is.widget({widget:new p_(-n),block:!0,side:-1}))):n>g_&&(u+=n,i.add(c,c,is.widget({widget:new p_(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<g_?r.add(e.state.doc.length,e.state.doc.length,is.widget({widget:new p_(-p),block:!0,side:1})):p>g_&&i.add(t.state.doc.length,t.state.doc.length,is.widget({widget:new p_(p),block:!0,side:1}));let m=r.finish(),h=i.finish();__(m,e.state.field(h_))||e.dispatch({effects:m_.of(m)}),__(h,t.state.field(h_))||t.dispatch({effects:m_.of(h)})}var y_=ss.define({map:(e,t)=>t.mapPos(e)}),b_=class extends Zo{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:y_.of(n)});let{side:r,sibling:i}=e.state.facet(Hg);i&&i().dispatch({effects:y_.of(x_(n,e.state.field(Gg),r==`a`))})}),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return`collapsed-unchanged-code`}};function x_(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 S_=ts.define({create(e){return is.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(y_)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>us.decorations.from(e)});function C_({margin:e=3,minSize:t=4}){return S_.init(n=>w_(n,e,t))}function w_(e,t,n){let r=new as,i=e.facet(Hg).side==`a`,a=e.field(Gg),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,is.replace({widget:new b_(d),block:!0})),!c)break;o=e.doc.lineAt(Math.min(e.doc.length,i?c.toA:c.toB)).number}return r.finish()}var T_=us.styleModule.of(new ps({".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`}})),E_=us.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`}}),D_=new ls,O_=new ls,k_=class{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||t_;let t=[Qo.low(n_),E_,T_,h_,us.updateListener.of(e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some(e=>e.effects.some(e=>e.is(m_)))&&this.measure()})],n=[Hg.of({side:`a`,sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&n.push(r_);let r=es.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],us.editorAttributes.of({class:`cm-merge-a`}),O_.of(n),t]}),i=[Hg.of({side:`b`,sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&i.push(r_);let a=es.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],us.editorAttributes.of({class:`cm-merge-b`}),O_.of(i),t]});this.chunks=qg.build(r.doc,a.doc,this.diffConf);let o=[Gg.init(()=>this.chunks),D_.of(e.collapseUnchanged?C_(e.collapseUnchanged):[])];r=r.update({effects:ss.appendConfig.of(o)}).state,a=a.update({effects:ss.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 us({state:r,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new us({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),$o.empty(e[0].startState.doc.length));this.chunks=t==this.a?qg.updateA(this.chunks,n.newDoc,this.b.state.doc,r,this.diffConf):qg.updateB(this.chunks,this.a.state.doc,n.newDoc,r,this.diffConf),t.update([...e,n.state.update({effects:Ug.of(this.chunks)})]);let i=t==this.a?this.b:this.a;i.update([i.state.update({effects:Ug.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(Hg),o=n?e.gutter!==!1:r.markGutter,s=t?e.highlightChanges!==!1:r.highlightChanges;i.push(O_.reconfigure([Hg.of({side:`a`,sibling:()=>this.b,highlightChanges:s,markGutter:o}),o?r_:[]])),a.push(O_.reconfigure([Hg.of({side:`b`,sibling:()=>this.a,highlightChanges:s,markGutter:o}),o?r_:[]]))}if(r){let t=D_.reconfigure(e.collapseUnchanged?C_(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(){v_(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=A_(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=A_(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 A_(e){let t=e.nextSibling;return e.remove(),t}var j_=new class extends ds{constructor(){super(...arguments),this.elementClass=`cm-deletedLineGutter`}},M_=Qo.low(fs({class:`cm-changeGutter`,markers:e=>e.plugin(n_)?.gutter||hs.empty,widgetMarker:(e,t)=>t instanceof L_?j_:null}));function N_(e){let t=typeof e.original==`string`?rs.of(e.original.split(/\r?\n/)):e.original,n=e.diffConfig||t_;return[Qo.low(n_),H_,E_,us.editorAttributes.of({class:`cm-merge-b`}),Wg.of((e,t)=>{let r=t.effects.find(e=>e.is(P_));return r&&(e=qg.updateA(e,r.value.doc,t.startState.doc,r.value.changes,n)),t.docChanged&&(e=qg.updateB(e,t.state.field(F_),t.newDoc,t.changes,n)),e}),Hg.of({highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1,syntaxHighlightDeletions:e.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:e.mergeControls??!0,overrideChunk:e.allowInlineDiffs?J_:void 0,side:`b`}),F_.init(()=>t),e.gutter===!1?[]:M_,e.collapseUnchanged?C_(e.collapseUnchanged):[],Gg.init(e=>qg.build(t,e.doc,n))]}var P_=ss.define(),F_=ts.define({create:()=>rs.empty,update(e,t){for(let n of t.effects)n.is(P_)&&(e=n.value.doc);return e}}),I_=new WeakMap,L_=class extends Zo{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 R_(e,t,n){let r=I_.get(t.changes);if(r)return r;let i=is.widget({block:!0,side:-1,widget:new L_(r=>{let{highlightChanges:i,syntaxHighlightDeletions:a,syntaxHighlightDeletionsMaxLength:o,mergeControls:s}=e.facet(Hg),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(),z_(r,r.posAtDOM(c))},i=e=>{e.preventDefault(),B_(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(F_).sliceString(t.fromA,t.endA),u=a&&e.facet(gs),d=h(),f=t.changes,p=0,m=!1;function h(){let e=c.appendChild(document.createElement(`div`));return e.className=`cm-deletedLine`,e.appendChild(document.createElement(`del`))}function g(e,t,n){for(let r=e;r<t;){if(l.charAt(r)==`
|
|
14
14
|
`){d.firstChild||d.appendChild(document.createElement(`br`)),d=h(),r++;continue}let e=t,a=n+(m?` cm-deletedText`:``),o=!1,s=l.indexOf(`
|
|
15
15
|
`,r);if(s>-1&&s<t&&(e=s),i&&p<f.length){let t=Math.max(0,m?f[p].toA:f[p].fromA);t<=e&&(e=t,m&&p++,o=!0)}if(e>r){let t=document.createTextNode(l.slice(r,e));if(a){let e=d.appendChild(document.createElement(`span`));e.className=a,e.appendChild(t)}else d.appendChild(t);r=e}o&&(m=!m)}}if(u&&t.toA-t.fromA<=o){let t=u.parser.parse(l),n=0;ns(t,{style:t=>_s(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 I_.set(t.changes,i),i}function z_(e,t){let{state:n}=e,r=t??n.selection.main.head,i=e.state.field(Gg).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(F_);i.fromB!=i.toB&&i.toA<=o.length&&(a+=e.state.lineBreak);let s=$o.of({from:i.fromA,to:Math.min(o.length,i.toA),insert:a},o.length);return e.dispatch({effects:P_.of({doc:s.apply(o),changes:s}),userEvent:`accept`}),!0}function B_(e,t){let{state:n}=e,r=t??n.selection.main.head,i=n.field(Gg).find(e=>e.fromB<=r&&e.endB>=r);if(!i)return!1;let a=n.field(F_).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 V_(e){let t=new as;for(let n of e.field(Gg)){let r=e.facet(Hg).overrideChunk&&W_(e,n);t.add(n.fromB,n.fromB,R_(e,n,!!r))}return t.finish()}var H_=ts.define({create:e=>V_(e),update(e,t){return t.state.field(Gg,!1)==t.startState.field(Gg,!1)?e:V_(t.state)},provide:e=>us.decorations.from(e)}),U_=new WeakMap;function W_(e,t){let n=U_.get(t);if(n!==void 0)return n;n=null;let r=e.field(F_),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(is.widget({widget:new G_(t),side:-1}).range(s+n.fromB))}n.fromB<n.toB&&e.push(s_.range(s+n.fromB,s+n.toB))}i<t.endA-t.fromA-a*2&&(n=e)}return U_.set(t,n),n}var G_=class extends Zo{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}},K_=new class extends ds{constructor(){super(...arguments),this.elementClass=`cm-inlineChangedLineGutter`}},q_=is.line({class:`cm-inlineChangedLine`});function J_(e,t,n,r){let i=W_(e,t),a=0;if(!i)return!1;for(let o=e.doc.lineAt(t.fromB);;){for(r&&r.add(o.from,o.from,K_),n.add(o.from,o.from,q_);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 Y_=se({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}}),X_=At({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}});function Z_(e){let t=(0,$.c)(20),{oldContent:n,newContent:r,layout:i,conflictMode:a,onResolve:o,onAbort:s}=e,c=(0,Q.useRef)(null),l=(0,Q.useRef)(null),{resolvedTheme:u}=vr(),d=(0,Q.useRef)(o),f=(0,Q.useRef)(s),[p,m]=(0,Q.useState)(null),h;t[0]!==s||t[1]!==o?(h=()=>{d.current=o,f.current=s},t[0]=s,t[1]=o,t[2]=h):h=t[2],(0,Q.useEffect)(h);let g,_;t[3]!==a||t[4]!==i||t[5]!==r||t[6]!==n||t[7]!==u?(g=()=>{if(!c.current)return;let e=u===`dark`?Y_:X_,t=[us.editable.of(!1),es.readOnly.of(!0)],o=[xs,J(),...t,e,us.lineWrapping];if(l.current&&=(l.current.destroy(),null),a){let t=new us({doc:r,extensions:[xs,J(),us.editable.of(!1),e,us.lineWrapping,N_({original:n,highlightChanges:!0,gutter:!0,mergeControls:!0,collapseUnchanged:{margin:3,minSize:4}}),us.updateListener.of(e=>{let t=Kg(e.state);m(t?t.chunks.length:0)})],parent:c.current});l.current=t;let i=Kg(t.state);m(i?i.chunks.length:0)}else i===`split`?l.current=new k_({a:{doc:n,extensions:o},b:{doc:r,extensions:o},parent:c.current,highlightChanges:!0,gutter:!0,collapseUnchanged:{margin:3,minSize:4}}):l.current=new us({doc:r,extensions:[...o,N_({original:n,highlightChanges:!0,gutter:!0,mergeControls:!1,collapseUnchanged:{margin:3,minSize:4}})],parent:c.current});return()=>{l.current&&=(l.current.destroy(),null)}},_=[n,r,i,u,a],t[3]=a,t[4]=i,t[5]=r,t[6]=n,t[7]=u,t[8]=g,t[9]=_):(g=t[8],_=t[9]),(0,Q.useEffect)(g,_);let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=function(){let e=l.current;!e||!(e instanceof us)||d.current?.(e.state.doc.toString())},t[10]=v):v=t[10];let y=v,b=p===0,x=p===null?``:p===0?`All hunks resolved`:`${p} unresolved hunk${p===1?``:`s`}`,S;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(`div`,{ref:c,className:`diff-view min-h-0 flex-1 overflow-y-auto subtle-scrollbar`}),t[11]=S):S=t[11];let C;t[12]!==b||t[13]!==a||t[14]!==x||t[15]!==s||t[16]!==o?(C=a&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 border-t shrink-0`,children:[(0,Z.jsx)(`span`,{className:`text-xs ${b?`text-emerald-600 dark:text-emerald-400`:`text-muted-foreground`}`,children:x}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s&&(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:s,children:`Exit merge`}),o&&(0,Z.jsx)(Y,{variant:`default`,size:`sm`,disabled:!b,onClick:y,children:`Save resolution`})]})]}),t[12]=b,t[13]=a,t[14]=x,t[15]=s,t[16]=o,t[17]=C):C=t[17];let w;return t[18]===C?w=t[19]:(w=(0,Z.jsxs)(`div`,{className:`flex flex-col h-full`,children:[S,C]}),t[18]=C,t[19]=w),w}function Q_(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)(Eo,{"data-slot":`sheet`,...n}),t[2]=n,t[3]=r),r}function $_(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)(ko,{"data-slot":`sheet-portal`,...n}),t[2]=n,t[3]=r),r}function ev(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=mi(`fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 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)(So,{"data-slot":`sheet-overlay`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function tv(e){let t=(0,$.c)(17),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,side:a,showCloseButton:o,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=a===void 0?`right`:a,c=o===void 0?!0:o,l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(ev,{}),t[6]=l):l=t[6];let u;t[7]===r?u=t[8]:(u=mi(`fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10 motion-reduce:transition-none motion-reduce:duration-0 motion-reduce:data-open:animate-none motion-reduce:data-closed:animate-none`,r),t[7]=r,t[8]=u);let d;t[9]===c?d=t[10]:(d=c&&(0,Z.jsx)(Mo,{"data-slot":`sheet-close`,asChild:!0,children:(0,Z.jsxs)(Y,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`,children:[(0,Z.jsx)(_o,{}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Close`})]})}),t[9]=c,t[10]=d);let f;return t[11]!==n||t[12]!==i||t[13]!==s||t[14]!==u||t[15]!==d?(f=(0,Z.jsxs)($_,{children:[l,(0,Z.jsxs)(xo,{"data-slot":`sheet-content`,"data-side":s,className:u,...i,children:[n,d]})]}),t[11]=n,t[12]=i,t[13]=s,t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function nv(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=mi(`flex flex-col gap-0.5 p-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`sheet-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function rv(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=mi(`font-heading text-base font-medium text-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Co,{"data-slot":`sheet-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}async function iv(){try{let e=await fetch(`/api/sync/conflicts`);return e.ok?{conflicts:(await e.json()).conflicts??[]}:{conflicts:[],error:`server`}}catch{return{conflicts:[],error:`network`}}}async function av(e){try{let t=await fetch(`/api/sync/conflict-content?file=${encodeURIComponent(e)}`);if(!t.ok)return{ours:``,theirs:``,base:``};let n=await t.json();return{ours:n.ours??``,theirs:n.theirs??``,base:n.base??``}}catch{return{ours:``,theirs:``,base:``}}}async function ov(e,t,n){try{let r={file:e,strategy:t};return n!==void 0&&(r.content=n),(await fetch(`/api/sync/resolve-conflict`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)})).ok}catch{return!1}}var sv=`w-[98vw] !max-w-[98vw] h-[96vh] flex flex-col gap-0 sm:!max-w-[98vw]`;function cv(e){let t=(0,$.c)(31),{file:n,onResolve:r,onAbort:i}=e,[a,o]=(0,Q.useState)(null),s,c;if(t[0]===n?(s=t[1],c=t[2]):(s=()=>{let e=!1;return av(n).then(t=>{e||o(t)}),()=>{e=!0}},c=[n],t[0]=n,t[1]=s,t[2]=c),(0,Q.useEffect)(s,c),a===null){let e;t[3]===i?e=t[4]:(e=e=>!e&&i(),t[3]=i,t[4]=e);let r;t[5]===n?r=t[6]:(r=(0,Z.jsx)(Ao,{className:`shrink-0`,children:(0,Z.jsxs)(bo,{children:[`Resolving: `,n]})}),t[5]=n,t[6]=r);let a;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted-foreground`,children:`Loading`}),t[7]=a):a=t[7];let o;t[8]===r?o=t[9]:(o=(0,Z.jsxs)(wo,{className:sv,children:[r,a]}),t[8]=r,t[9]=o);let s;return t[10]!==e||t[11]!==o?(s=(0,Z.jsx)(jo,{open:!0,onOpenChange:e,children:o}),t[10]=e,t[11]=o,t[12]=s):s=t[12],s}let l;t[13]===i?l=t[14]:(l=e=>!e&&i(),t[13]=i,t[14]=l);let u;t[15]===n?u=t[16]:(u=(0,Z.jsxs)(bo,{className:`text-sm font-medium`,children:[`Resolving: `,n]}),t[15]=n,t[16]=u);let d;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Red = your version (ours). Green = team's version (theirs). Accept each hunk to take theirs, reject to keep yours, then save.`}),t[17]=d):d=t[17];let f;t[18]===u?f=t[19]:(f=(0,Z.jsxs)(Ao,{className:`px-4 pt-4 pb-2 shrink-0`,children:[u,d]}),t[18]=u,t[19]=f);let p;t[20]!==i||t[21]!==r||t[22]!==a.ours||t[23]!==a.theirs?(p=(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:(0,Z.jsx)(Z_,{oldContent:a.ours,newContent:a.theirs,layout:`unified`,conflictMode:!0,onResolve:r,onAbort:i})}),t[20]=i,t[21]=r,t[22]=a.ours,t[23]=a.theirs,t[24]=p):p=t[24];let m;t[25]!==f||t[26]!==p?(m=(0,Z.jsxs)(wo,{className:`${sv} p-0`,children:[f,p]}),t[25]=f,t[26]=p,t[27]=m):m=t[27];let h;return t[28]!==l||t[29]!==m?(h=(0,Z.jsx)(jo,{open:!0,onOpenChange:l,children:m}),t[28]=l,t[29]=m,t[30]=h):h=t[30],h}function lv(e){let t=(0,$.c)(50),{open:n,onOpenChange:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=[],t[0]=i):i=t[0];let[a,o]=(0,Q.useState)(i),[s,c]=(0,Q.useState)(null),l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l=new Set,t[1]=l):l=t[1];let[u,d]=(0,Q.useState)(l),f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=new Set,t[2]=f):f=t[2];let[p,m]=(0,Q.useState)(f),[h,g]=(0,Q.useState)(null),_;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=function(){iv().then(e=>{let{conflicts:t,error:n}=e;c(n??null),o(t),d(e=>{let n=new Set(t.map(uv));return new Set([...e].filter(e=>!n.has(e)))})})},t[3]=_):_=t[3];let v=_,y,b;t[4]===n?(y=t[5],b=t[6]):(y=()=>{n&&v()},b=[n],t[4]=n,t[5]=y,t[6]=b),(0,Q.useEffect)(y,b);let x,S;t[7]===n?(x=t[8],S=t[9]):(x=()=>br(e=>{e.includes(`sync-status`)&&n&&v()}),S=[n],t[7]=n,t[8]=x,t[9]=S),(0,Q.useEffect)(x,S);let C,w;t[10]!==a.length||t[11]!==r||t[12]!==n||t[13]!==u.size?(w=()=>{n&&a.length>0&&u.size>=a.length&&(X.success(`All conflicts resolved — sync resuming`),r(!1),d(new Set))},C=[n,a.length,u.size,r],t[10]=a.length,t[11]=r,t[12]=n,t[13]=u.size,t[14]=C,t[15]=w):(C=t[14],w=t[15]),(0,Q.useEffect)(w,C);let T;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(T=async function(e,t,n){m(t=>new Set([...t,e]));let r=await ov(e,t,n);m(t=>{let n=new Set(t);return n.delete(e),n}),r?d(t=>new Set([...t,e])):X.error(`Failed to resolve ${e}`)},t[16]=T):T=t[16];let E=T,D;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(D=function(e){g(e)},t[17]=D):D=t[17];let O=D,k;t[18]===h?k=t[19]:(k=async function(e){if(!h)return;let t=h;g(null),await E(t,`content`,e)},t[18]=h,t[19]=k);let A=k,j;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(j=function(){g(null)},t[20]=j):j=t[20];let M=j,N;t[21]===r?N=t[22]:(N=async function(){try{(await fetch(`/api/sync/abort-merge`,{method:`POST`})).ok?X.info(`Merge aborted — sync paused`):X.error(`Failed to abort merge`)}catch{X.error(`Failed to abort merge — connection error`)}r(!1),d(new Set)},t[21]=r,t[22]=N);let P=N,F=a.length,I=u.size,L;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsx)(rv,{className:`text-sm font-medium`,children:`Resolve conflicts`}),t[23]=L):L=t[23];let R;t[24]!==I||t[25]!==F?(R=F>0&&(0,Z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[I,` of `,F,` resolved`]}),t[24]=I,t[25]=F,t[26]=R):R=t[26];let z;t[27]===R?z=t[28]:(z=(0,Z.jsxs)(nv,{className:`px-4 py-3 border-b shrink-0`,children:[L,R]}),t[27]=R,t[28]=z);let B;t[29]!==a||t[30]!==s||t[31]!==u||t[32]!==p?(B=(0,Z.jsx)(`div`,{className:`flex-1 overflow-y-auto subtle-scrollbar`,children:s?(0,Z.jsxs)(`div`,{className:`px-4 py-6 text-sm text-center space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-destructive`,children:s===`network`?`Could not reach the sync server — check your connection.`:`Sync server error — try again in a moment.`}),(0,Z.jsx)(Y,{variant:`outline`,size:`sm`,onClick:v,children:`Retry`})]}):a.length===0?(0,Z.jsx)(`p`,{className:`px-4 py-6 text-sm text-muted-foreground text-center`,children:`No conflicts found.`}):(0,Z.jsx)(`ul`,{className:`divide-y`,children:a.map(e=>{let t=u.has(e.file),n=p.has(e.file),r=e.file.split(`/`).pop()??e.file;return(0,Z.jsxs)(`li`,{className:`px-4 py-3 ${t?`opacity-50`:``}`,children:[(0,Z.jsxs)(`p`,{className:`text-sm font-medium truncate mb-2`,title:e.file,children:[t?`✓ `:``,r]}),!t&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,disabled:n,onClick:()=>void E(e.file,`mine`),children:`Keep my version`}),(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,disabled:n,onClick:()=>void E(e.file,`theirs`),children:`Keep team's version`}),(0,Z.jsx)(Y,{variant:`ghost`,size:`xs`,disabled:n,onClick:()=>O(e.file),children:`Resolve manually`})]})]},e.file)})})}),t[29]=a,t[30]=s,t[31]=u,t[32]=p,t[33]=B):B=t[33];let V;t[34]===P?V=t[35]:(V=(0,Z.jsx)(`div`,{className:`px-4 py-3 border-t shrink-0`,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:P,children:`Exit merge`})}),t[34]=P,t[35]=V);let H;t[36]!==z||t[37]!==B||t[38]!==V?(H=(0,Z.jsxs)(tv,{side:`right`,className:`w-80 sm:w-96 flex flex-col gap-0 p-0`,children:[z,B,V]}),t[36]=z,t[37]=B,t[38]=V,t[39]=H):H=t[39];let U;t[40]!==r||t[41]!==n||t[42]!==H?(U=(0,Z.jsx)(Q_,{open:n,onOpenChange:r,children:H}),t[40]=r,t[41]=n,t[42]=H,t[43]=U):U=t[43];let W;t[44]!==A||t[45]!==h?(W=h&&(0,Z.jsx)(cv,{file:h,onResolve:e=>void A(e),onAbort:M}),t[44]=A,t[45]=h,t[46]=W):W=t[46];let G;return t[47]!==U||t[48]!==W?(G=(0,Z.jsxs)(Z.Fragment,{children:[U,W]}),t[47]=U,t[48]=W,t[49]=G):G=t[49],G}function uv(e){return e.file}var dv=5;async function fv(e){let t=await fetch(`/api/backlinks?docName=${encodeURIComponent(e)}`),n=await t.json().catch(()=>null);if(!t.ok){let e=fi.safeParse(n);throw e.success?Error(e.data.title):new ze(`Failed to parse backlinks error response (HTTP ${t.status})`,{status:t.status})}let r=gr.safeParse(n);if(!r.success)throw new ze(`Backlinks response did not match expected shape.`,{status:t.status});return r.data.backlinks}async function pv(e){let t=await fetch(`/api/forward-links?docName=${encodeURIComponent(e)}`),n=await t.json().catch(()=>null);if(!t.ok){let e=fi.safeParse(n);throw e.success?Error(e.data.title):new ze(`Failed to parse forward-links error response (HTTP ${t.status})`,{status:t.status})}let r=ii.safeParse(n);if(!r.success)throw new ze(`Forward-links response did not match expected shape.`,{status:t.status});return r.data.forwardLinks}function mv(e){let t=e.split(`/`);return t.length<=2?e:`…/${t.slice(-2).join(`/`)}`}function hv(e){window.location.hash=Tr(e)}function gv(e){let t=(0,$.c)(9),{title:n,count:r,isLoading:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(mt,{className:`size-3.5 text-muted-foreground transition-transform group-data-[state=closed]:-rotate-90`}),t[0]=a):a=t[0];let o;t[1]===n?o=t[2]:(o=(0,Z.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[a,(0,Z.jsx)(sn,{children:n})]}),t[1]=n,t[2]=o);let s;t[3]!==r||t[4]!==i?(s=!i&&(0,Z.jsx)(on,{children:r}),t[3]=r,t[4]=i,t[5]=s):s=t[5];let c;return t[6]!==o||t[7]!==s?(c=(0,Z.jsxs)(Io,{className:`group flex w-full cursor-pointer items-center justify-between px-5 py-3 text-left transition-colors hover:bg-muted/40`,children:[o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function _v(e){let t=(0,$.c)(7),{total:n,expanded:r,onToggle:i}=e;if(n<=dv)return null;let a=n-dv,o;t[0]===r?o=t[1]:(o=r?(0,Z.jsx)(mt,{className:`size-3`}):(0,Z.jsx)(No,{className:`size-3`}),t[0]=r,t[1]=o);let s=r?`Show fewer`:`Show ${a} more`,c;return t[2]!==r||t[3]!==i||t[4]!==o||t[5]!==s?(c=(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":r,className:`mt-2 inline-flex cursor-pointer items-center gap-1 px-3 text-xs text-muted-foreground transition-colors hover:text-foreground`,onClick:i,children:[o,s]}),t[2]=r,t[3]=i,t[4]=o,t[5]=s,t[6]=c):c=t[6],c}function vv(e){let t=(0,$.c)(35),{icon:n,iconColorClass:r,rowTooltip:i,title:a,path:o,anchor:s,snippet:c,titleHover:l,ariaLabel:u,href:d,external:f,disabled:p,onClick:m}=e,h=o!==void 0&&o!==a,g=r??`text-muted-foreground`,_;t[0]===g?_=t[1]:(_=mi(`mt-0.5 shrink-0`,g),t[0]=g,t[1]=_);let v;t[2]!==n||t[3]!==_?(v=(0,Z.jsx)(`span`,{className:_,children:n}),t[2]=n,t[3]=_,t[4]=v):v=t[4];let y=v,b;t[5]!==u||t[6]!==p||t[7]!==f||t[8]!==d||t[9]!==m||t[10]!==a||t[11]!==l?(b=d?(0,Z.jsxs)(`a`,{href:d,target:f?`_blank`:void 0,rel:f?`noopener noreferrer`:void 0,"aria-label":u,title:l,onClick:m,className:`block w-full truncate text-left font-medium text-foreground no-underline outline-none after:absolute after:inset-0 after:rounded-md focus-visible:after:ring-2 focus-visible:after:ring-ring`,children:[a,f?(0,Z.jsx)(`span`,{className:`sr-only`,children:` (opens in new tab)`}):null]}):(0,Z.jsx)(`button`,{type:`button`,"aria-label":u,title:l,disabled:p,onClick:m,className:mi(`block w-full truncate text-left font-medium text-foreground no-underline outline-none after:absolute after:inset-0 after:rounded-md focus-visible:after:ring-2 focus-visible:after:ring-ring`,`cursor-pointer bg-transparent p-0 disabled:cursor-not-allowed disabled:opacity-60`),children:a}),t[5]=u,t[6]=p,t[7]=f,t[8]=d,t[9]=m,t[10]=a,t[11]=l,t[12]=b):b=t[12];let x=b,S;t[13]===y?S=t[14]:(S=(0,Z.jsx)(`div`,{className:`mt-px flex items-center`,children:y}),t[13]=y,t[14]=S);let C;t[15]!==s||t[16]!==o||t[17]!==h?(C=h?(0,Z.jsxs)(`div`,{className:`truncate font-mono text-xs text-muted-foreground`,children:[o,s?(0,Z.jsxs)(`span`,{className:`ml-1`,children:[`· #`,s]}):null]}):null,t[15]=s,t[16]=o,t[17]=h,t[18]=C):C=t[18];let w;t[19]===c?w=t[20]:(w=c?(0,Z.jsx)(`p`,{className:`line-clamp-2 text-muted-foreground`,children:c}):null,t[19]=c,t[20]=w);let T;t[21]!==x||t[22]!==C||t[23]!==w?(T=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5 text-1sm`,children:[x,C,w]}),t[21]=x,t[22]=C,t[23]=w,t[24]=T):T=t[24];let E;t[25]!==S||t[26]!==T?(E=(0,Z.jsxs)(`div`,{className:`group relative flex items-start gap-2.5 rounded-md px-3 py-2.5 transition-colors hover:bg-muted/80`,children:[S,T]}),t[25]=S,t[26]=T,t[27]=E):E=t[27];let D=E;if(i){let e;t[28]===D?e=t[29]:(e=(0,Z.jsx)(kr,{asChild:!0,children:D}),t[28]=D,t[29]=e);let n;t[30]===i?n=t[31]:(n=(0,Z.jsx)(vn,{side:`top`,children:i}),t[30]=i,t[31]=n);let r;return t[32]!==e||t[33]!==n?(r=(0,Z.jsxs)(yn,{children:[e,n]}),t[32]=e,t[33]=n,t[34]=r):r=t[34],r}return D}function yv(e){let t=(0,$.c)(33),{docName:n}=e,{folderPaths:r,pages:i,loading:a}=qr(),o,s;t[0]===n?(o=t[1],s=t[2]):(o=[`backlinks`,n],s=()=>fv(n),t[0]=n,t[1]=o,t[2]=s);let c;t[3]!==n||t[4]!==a||t[5]!==i?(c=!a&&i.has(n),t[3]=n,t[4]=a,t[5]=i,t[6]=c):c=t[6];let l;t[7]!==o||t[8]!==s||t[9]!==c?(l={queryKey:o,queryFn:s,enabled:c},t[7]=o,t[8]=s,t[9]=c,t[10]=l):l=t[10];let{data:u,isLoading:d,error:f}=Jt(l),p;t[11]===u?p=t[12]:(p=u===void 0?[]:u,t[11]=u,t[12]=p);let m=p,[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(n);_!==n&&(v(n),g(!1));let y;t[13]!==m||t[14]!==h?(y=h?m:m.slice(0,dv),t[13]=m,t[14]=h,t[15]=y):y=t[15];let b=y,x;t[16]!==m.length||t[17]!==d?(x=(0,Z.jsx)(gv,{title:`Backlinks`,count:m.length,isLoading:d}),t[16]=m.length,t[17]=d,t[18]=x):x=t[18];let S;t[19]!==m.length||t[20]!==f||t[21]!==h||t[22]!==r||t[23]!==d||t[24]!==i||t[25]!==b?(S=f?(0,Z.jsx)(`div`,{className:`px-3`,children:(0,Z.jsx)(Kt,{children:f instanceof Error?f.message:`Failed to load backlinks`})}):m.length===0&&!d?(0,Z.jsx)(`div`,{className:`px-3`,children:(0,Z.jsx)($t,{children:`No pages link here yet.`})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`flex flex-col gap-1`,children:b.map((e,t)=>{let n=ho(e.source,{pages:i,folderPaths:r});return(0,Z.jsx)(vv,{icon:(0,Z.jsx)(ae,{className:`size-3.5`}),title:e.title,path:mv(e.source),titleHover:e.source,anchor:e.anchor,snippet:e.snippet,href:Tr(n.hashDocName,e.anchor)},`${e.source}-${t}`)})}),(0,Z.jsx)(_v,{total:m.length,expanded:h,onToggle:()=>g(bv)})]}),t[19]=m.length,t[20]=f,t[21]=h,t[22]=r,t[23]=d,t[24]=i,t[25]=b,t[26]=S):S=t[26];let C;t[27]!==d||t[28]!==S?(C=(0,Z.jsx)(Fo,{children:(0,Z.jsx)(`div`,{className:`px-2 pb-3`,"aria-busy":d,children:S})}),t[27]=d,t[28]=S,t[29]=C):C=t[29];let w;return t[30]!==C||t[31]!==x?(w=(0,Z.jsxs)(Lo,{defaultOpen:!0,children:[x,C]}),t[30]=C,t[31]=x,t[32]=w):w=t[32],w}function bv(e){return!e}function xv(e){let t=(0,$.c)(42),{docName:n}=e,{addPage:r,folderPaths:i,pages:a,pagesBySlug:o,loading:s}=qr(),c,l;t[0]===n?(c=t[1],l=t[2]):(c=[`forward-links`,n],l=()=>pv(n),t[0]=n,t[1]=c,t[2]=l);let d;t[3]!==n||t[4]!==a||t[5]!==s?(d=!s&&a.has(n),t[3]=n,t[4]=a,t[5]=s,t[6]=d):d=t[6];let f;t[7]!==c||t[8]!==l||t[9]!==d?(f={queryKey:c,queryFn:l,enabled:d},t[7]=c,t[8]=l,t[9]=d,t[10]=f):f=t[10];let{data:p,isLoading:m,error:h}=Jt(f),g;t[11]===p?g=t[12]:(g=p===void 0?[]:p,t[11]=p,t[12]=g);let _=g,[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(n);S!==n&&(C(n),x(!1),y(null));let w;t[13]!==b||t[14]!==_?(w=b?_:_.slice(0,dv),t[13]=b,t[14]=_,t[15]=w):w=t[15];let T=w,E;t[16]!==r||t[17]!==v?(E=async function(e,t){if(!v){y(t);try{await Ft(e,{addPage:r,onCreated:hv}),y(null)}catch(e){let t=e;X.error(t instanceof Error?t.message:`Failed to create page`),y(null)}}},t[16]=r,t[17]=v,t[18]=E):E=t[18];let D=E,O;t[19]!==v||t[20]!==i||t[21]!==D||t[22]!==a||t[23]!==o||t[24]!==s?(O=function(e){if(e.kind===`external`){let t=e.title===e.url;return(0,Z.jsx)(vv,{icon:(0,Z.jsx)(mo,{className:`size-3.5`}),rowTooltip:`Opens in a new tab`,title:e.title,path:t?void 0:e.url,titleHover:e.url,snippet:e.snippet,href:e.url,external:!0},`ext:${e.url}`)}let t=u(e.docName,{pages:a,folderPaths:i,pagesBySlug:o}),n=!s&&t.kind===`create`,r=!s&&t.kind===`navigate`&&t.displayState===`folder`,c=mv(e.docName),l=e.title===e.docName?c:e.title,d=`doc:${e.docName}:${e.anchor??``}`,f=Tr(t.kind===`navigate`?t.hashDocName:e.docName,e.anchor);if(n&&t.kind===`create`){let n={initialDir:t.initialDir,suggestedName:t.suggestedName};return(0,Z.jsx)(vv,{icon:(0,Z.jsx)(dr,{className:`size-3.5`}),iconColorClass:`text-amber-600 dark:text-amber-400`,rowTooltip:v===d?`Creating page`:`Missing page — click to create`,ariaLabel:v===d?`Creating page: ${e.title}.`:`Missing page: ${e.title}. Click to create.`,title:l,path:c,titleHover:e.docName,anchor:e.anchor,snippet:e.snippet,disabled:v!==null,onClick:()=>void D(n,d)},d)}return r&&t.kind===`navigate`?(0,Z.jsx)(vv,{icon:(0,Z.jsx)(dc,{className:`size-3.5`}),iconColorClass:`text-sky-600 dark:text-sky-400`,ariaLabel:`Folder target: ${e.title}. Click to open the overview.`,title:l,path:c,titleHover:e.docName,anchor:e.anchor,snippet:e.snippet,href:f},d):(0,Z.jsx)(vv,{icon:(0,Z.jsx)(ae,{className:`size-3.5`}),title:l,path:c,titleHover:e.docName,anchor:e.anchor,snippet:e.snippet,href:f},d)},t[19]=v,t[20]=i,t[21]=D,t[22]=a,t[23]=o,t[24]=s,t[25]=O):O=t[25];let k=O,A;t[26]!==m||t[27]!==_.length?(A=(0,Z.jsx)(gv,{title:`Outgoing`,count:_.length,isLoading:m}),t[26]=m,t[27]=_.length,t[28]=A):A=t[28];let j;t[29]!==h||t[30]!==b||t[31]!==m||t[32]!==_.length||t[33]!==k||t[34]!==T?(j=h?(0,Z.jsx)(`div`,{className:`px-3`,children:(0,Z.jsx)(Kt,{children:h instanceof Error?h.message:`Failed to load outgoing links`})}):_.length===0&&!m?(0,Z.jsx)(`div`,{className:`px-3`,children:(0,Z.jsx)($t,{children:`This page doesn't link to anything yet.`})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`flex flex-col gap-1`,children:T.map(k)}),(0,Z.jsx)(_v,{total:_.length,expanded:b,onToggle:()=>x(Sv)})]}),t[29]=h,t[30]=b,t[31]=m,t[32]=_.length,t[33]=k,t[34]=T,t[35]=j):j=t[35];let M;t[36]!==m||t[37]!==j?(M=(0,Z.jsx)(Fo,{children:(0,Z.jsx)(`div`,{className:`px-2 pb-3`,"aria-busy":m,children:j})}),t[36]=m,t[37]=j,t[38]=M):M=t[38];let N;return t[39]!==A||t[40]!==M?(N=(0,Z.jsxs)(Lo,{defaultOpen:!0,children:[A,M]}),t[39]=A,t[40]=M,t[41]=N):N=t[41],N}function Sv(e){return!e}function Cv(e){let t=(0,$.c)(11),{docName:n,className:r}=e,i=r===void 0?``:r,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(xv,{docName:n}),t[0]=n,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(ro,{}),t[2]=o):o=t[2];let s;t[3]===n?s=t[4]:(s=(0,Z.jsx)(yv,{docName:n}),t[3]=n,t[4]=s);let c;t[5]!==a||t[6]!==s?(c=(0,Z.jsxs)(rn,{className:`px-0 py-0`,children:[a,o,s]}),t[5]=a,t[6]=s,t[7]=c):c=t[7];let l;return t[8]!==i||t[9]!==c?(l=(0,Z.jsx)(cn,{className:i,children:c}),t[8]=i,t[9]=c,t[10]=l):l=t[10],l}var wv=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}};new class extends wv{};function Tv(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function Ev(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function Dv(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function Ov(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function kv(e,t){return Dv(e,t,``)}function Av(e,t){return Ov(e,t,``)}function jv(e,t){return t.slice(0,Mv(e,t))}function Mv(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function Nv(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function Pv(e,t){if(t)return Iv(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function Fv(e,t){if(t)return Iv(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function Iv(e,t){if(!t)return[Fv(e),Pv(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=Nv(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var Lv=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,Rv=RegExp(`[${Lv}]+|\\s+|[^${Lv}]`,`ug`);new class extends wv{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=Nv(e,r)}else n=e.match(Rv)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&zv(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&zv(n,i,r,null,t.intlSegmenter),e}};function zv(e,t,n,r,i){if(t&&n){let[a,o]=Iv(t.value,i),[s,c]=Iv(n.value,i);if(e){let r=Tv(a,s);e.value=Ov(e.value,s,r),t.value=kv(t.value,r),n.value=kv(n.value,r)}if(r){let e=Ev(o,c);r.value=Dv(r.value,c,e),t.value=Av(t.value,e),n.value=Av(n.value,e)}}else if(n){if(e){let e=Fv(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=Fv(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=Fv(r.value,i),[a,o]=Iv(t.value,i),s=Tv(n,a);t.value=kv(t.value,s);let c=Ev(kv(n,s),o);t.value=Av(t.value,c),r.value=Dv(r.value,n,c),e.value=Ov(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=Fv(r.value,i),n=jv(Pv(t.value,i),e);t.value=Av(t.value,n)}else if(e){let n=jv(Pv(e.value,i),Fv(t.value,i));t.value=kv(t.value,n)}}new class extends wv{tokenize(e){let t=RegExp(`(\\r?\\n)|[${Lv}]+|[^\\S\\n\\r]+|[^${Lv}]`,`ug`);return e.match(t)||[]}};var Bv=new class extends wv{constructor(){super(...arguments),this.tokenize=Hv}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
16
16
|
`))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
|
|
@@ -24,15 +24,15 @@ Error generating stack: `+e.message+`
|
|
|
24
24
|
`}function Jv(e,t,n,r,i,a,o){if(typeof o==`function`&&(o={callback:o}),o?.callback){let{callback:s}=o;Kv(e,t,n,r,i,a,Object.assign(Object.assign({},o),{callback:e=>{s(e?qv(e,o.headerOptions):void 0)}}))}else{let s=Kv(e,t,n,r,i,a,o);return s?qv(s,o?.headerOptions):void 0}}function Yv(e,t,n,r,i,a){return Jv(e,e,t,n,r,i,a)}function Xv(e){let t=e.endsWith(`
|
|
25
25
|
`),n=e.split(`
|
|
26
26
|
`).map(e=>e+`
|
|
27
|
-
`);return t?n.pop():n.push(n.pop().slice(0,-1)),n}function Zv(e,t){return`${e}\u0000${t}`}function Qv(e,t,n){let r=Cr(e).body,i=Cr(t).body;return r===i?``:Yv(n,r,i,``,``,{context:3})}function $v(e,t,n){let r=(0,$.c)(8),{activeProvider:i}=ot(),a;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={status:`idle`,diff:null},r[0]=a):a=r[0];let[o,s]=(0,Q.useState)(a),c=(0,Q.useRef)(i),l;r[1]===i?l=r[2]:(l=()=>{c.current=i},r[1]=i,r[2]=l),(0,Q.useEffect)(l);let u,d;return r[3]!==n||r[4]!==t||r[5]!==e?(u=()=>{if(!e){s({status:`idle`,diff:null});return}let r=e,i=!1;return s({status:`loading`,diff:null}),(async function(){try{let e=Zv(t,r),a=n.get(e);if(a===void 0){let o=await fetch(`/api/history/${r}?docName=${encodeURIComponent(t)}`);if(i)return;if(!o.ok){s({status:`error`,diff:null});return}let c=await o.json();if(i)return;a=c.content??``,n.set(e,a)}if(i)return;let o=c.current?.document.getText(`source`).toString()??``,l=Qv(a,o,t);if(i)return;s({status:`ready`,diff:l})}catch(e){i||(console.error(`[timeline-diff] failed to load entry diff`,{sha:r,docName:t,err:e}),s({status:`error`,diff:null}))}})(),()=>{i=!0}},d=[e,t,n],r[3]=n,r[4]=t,r[5]=e,r[6]=u,r[7]=d):(u=r[6],d=r[7]),(0,Q.useEffect)(u,d),o}var ey=(0,Q.lazy)(async()=>({default:(await n(()=>import(`./ActivityPanelDiffView-d4ec9M69.js`),__vite__mapDeps([16,1,7,17]),import.meta.url)).ActivityPanelDiffView}));function ty(e){let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/1e3);if(r<60)return`just now`;if(r<3600)return`${Math.floor(r/60)} min ago`;if(r<86400)return`${Math.floor(r/3600)}h ago`;if(r<86400*2)return`yesterday`;let i=Math.floor(r/86400);return i<7?`${i} days ago`:t.toLocaleDateString()}function ny(e){return new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function ry(e){return e.slice(0,7)}function iy(e){return e.type===`upstream`?`Upstream sync`:e.contributors.length===1?e.contributors[0].name:e.contributors.length>1?e.contributors.map(e=>e.name).join(`, `):e.author===`openknowledge-server`||e.author===`server`?`Auto-save`:e.author}function ay(e){let t=(0,$.c)(17),n,r;if(t[0]===e?(n=t[1],r=t[2]):({icon:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),n===`claude`){let e;return t[3]===r?e=t[4]:(e=(0,Z.jsx)(Oi,{...r}),t[3]=r,t[4]=e),e}if(n===`cursor`){let e;return t[5]===r?e=t[6]:(e=(0,Z.jsx)(Pi,{...r}),t[5]=r,t[6]=e),e}if(n===`windsurf`){let e;return t[7]===r?e=t[8]:(e=(0,Z.jsx)(Ei,{...r}),t[7]=r,t[8]=e),e}if(n===`openai`){let e;return t[9]===r?e=t[10]:(e=(0,Z.jsx)(ji,{...r}),t[9]=r,t[10]=e),e}if(n===`cline`){let e;return t[11]===r?e=t[12]:(e=(0,Z.jsx)(zi,{...r}),t[11]=r,t[12]=e),e}if(n===`github`){let e;return t[13]===r?e=t[14]:(e=(0,Z.jsx)(Li,{...r}),t[13]=r,t[14]=e),e}let i=r,a;return t[15]===i?a=t[16]:(a=(0,Z.jsx)(Fi,{strokeWidth:1.5,...i}),t[15]=i,t[16]=a),a}function oy(e){let t=(0,$.c)(17),{entry:n,isDark:r}=e;if(n.type===`upstream`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(k,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[0]=e):e=t[0],e}if(n.contributors.length>0){let e=n.contributors[0],i=e.colorSeed??e.name,a;t[1]===i?a=t[2]:(a=Vn(i),t[1]=i,t[2]=a);let o=a,s=r?nr[o]??On[o]:On[o],c;t[3]!==s||t[4]!==i?(c=s??xr(i),t[3]=s,t[4]=i,t[5]=c):c=t[5];let l=c;if(o!==`bot`){let e;t[6]===l?e=t[7]:(e={color:l},t[6]=l,t[7]=e);let n;return t[8]!==o||t[9]!==e?(n=(0,Z.jsx)(ay,{icon:o,width:14,height:14,className:`shrink-0`,style:e}),t[8]=o,t[9]=e,t[10]=n):n=t[10],n}if(e.name===`File System`){let e;return t[11]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(pc,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[11]=e):e=t[11],e}if(e.name===`Open Knowledge (service)`||e.name===`Git (upstream)`){let e;return t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Rs,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[12]=e):e=t[12],e}let u;return t[13]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(el,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[13]=u):u=t[13],u}if(n.authorEmail.includes(`agent`)||n.author.includes(`agent`)||n.authorEmail.includes(`cursor`)||n.authorEmail.includes(`claude`)){let e;return t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Fi,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[14]=e):e=t[14],e}if(n.author===`openknowledge-server`||n.author===`server`){let e;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Rs,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[15]=e):e=t[15],e}let i;return t[16]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(el,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[16]=i):i=t[16],i}function sy(e){let t=(0,$.c)(20),{entries:n,defaultExpanded:r,isDark:i,diffLayout:a,cache:o,docName:s,expandedShas:c,onToggleExpanded:l,onRestoreSuccess:u}=e,[d,f]=(0,Q.useState)(r);if(n.length===0)return null;let p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>f(cy),t[0]=p):p=t[0];let m;t[1]===d?m=t[2]:(m=d?(0,Z.jsx)(mt,{className:`size-3`}):(0,Z.jsx)(No,{className:`size-3`}),t[1]=d,t[2]=m);let h=d?`Hide ${n.length} auto-save${n.length>1?`s`:``}`:`Show ${n.length} auto-save${n.length>1?`s`:``}`,g;t[3]!==d||t[4]!==m||t[5]!==h?(g=(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":d,className:`flex items-center gap-1.5 rounded-lg px-3 py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/80 transition-colors text-left`,onClick:p,children:[m,h]}),t[3]=d,t[4]=m,t[5]=h,t[6]=g):g=t[6];let _;t[7]!==o||t[8]!==a||t[9]!==s||t[10]!==n||t[11]!==d||t[12]!==c||t[13]!==i||t[14]!==u||t[15]!==l?(_=d&&n.map(e=>(0,Z.jsx)(Sy,{entry:e,isDark:i,diffLayout:a,cache:o,docName:s,expanded:c.has(e.sha),onToggleExpanded:l,onRestoreSuccess:u},e.sha)),t[7]=o,t[8]=a,t[9]=s,t[10]=n,t[11]=d,t[12]=c,t[13]=i,t[14]=u,t[15]=l,t[16]=_):_=t[16];let v;return t[17]!==g||t[18]!==_?(v=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19],v}function cy(e){return!e}function ly(e){return e.checkpoint?e.checkpoint.kind:`save`}function uy(e){let t=ly(e);if(t===`save`)return`Save Version`;let n=e.checkpoint?.size??null,r=n!=null&&n>0?` (${dy(n)})`:``;return t===`bridge-merge-loss`?`Auto-saved before a concurrent edit${r}`:`Recovered from an external change${r}`}function dy(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/102.4)/10} KB`:`${Math.round(e/104857.6)/10} MB`}function fy(e){return e.type===`checkpoint`?ly(e)===`save`?`version`:`auto-save`:`wip`}var py={version:`Restore this version`,"auto-save":`Restore this auto-save`,wip:`Restore to this point`},my={version:`Restore this version?`,"auto-save":`Restore this auto-save?`,wip:`Restore to this point?`};function hy(e){return py[fy(e)]}function gy(e){return my[fy(e)]}function _y(e){let t=[];for(let n of e.contributors)if(n.summaries)for(let e of n.summaries)t.push(e);return t}function vy(e){let t=(0,$.c)(20),{summaries:n}=e,[r,i]=(0,Q.useState)(!1),a=(0,Q.useId)();if(n.length===0)return null;let o,s;t[0]===n?(o=t[1],s=t[2]):([o,...s]=n,t[0]=n,t[1]=o,t[2]=s);let c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:`• `}),t[3]=c):c=t[3];let l;t[4]===o?l=t[5]:(l=(0,Z.jsxs)(`li`,{className:`text-xs text-foreground/90`,children:[c,o]}),t[4]=o,t[5]=l);let u;t[6]!==r||t[7]!==s?(u=r&&s.map(by),t[6]=r,t[7]=s,t[8]=u):u=t[8];let d;t[9]!==a||t[10]!==l||t[11]!==u?(d=(0,Z.jsxs)(`ul`,{id:a,className:`list-none`,children:[l,u]}),t[9]=a,t[10]=l,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==r||t[14]!==a||t[15]!==s.length?(f=s.length>0&&(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":r,"aria-controls":a,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,onClick:e=>{e.stopPropagation(),i(yy)},children:[r?(0,Z.jsx)(mt,{className:`size-3`}):(0,Z.jsx)(No,{className:`size-3`}),r?`Hide`:`Show ${s.length} more`]}),t[13]=r,t[14]=a,t[15]=s.length,t[16]=f):f=t[16];let p;return t[17]!==d||t[18]!==f?(p=(0,Z.jsxs)(`div`,{className:`mt-0.5`,children:[d,f]}),t[17]=d,t[18]=f,t[19]=p):p=t[19],p}function yy(e){return!e}function by(e,t){return(0,Z.jsxs)(`li`,{className:`text-xs text-foreground/90`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:`• `}),e]},`${t}-${e}`)}function xy(e){let t=(0,$.c)(13),{sha:n,docName:r,cache:i,diffLayout:a,panelId:o}=e,s=$v(n,r,i),c;t[0]===s.status?c=t[1]:(c=s.status===`loading`&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(ue,{className:`size-3 animate-spin`}),`Loading diff`]}),t[0]=s.status,t[1]=c);let l;t[2]===s.status?l=t[3]:(l=s.status===`error`&&(0,Z.jsx)(`p`,{className:`py-2 text-xs text-destructive`,children:`Diff unavailable`}),t[2]=s.status,t[3]=l);let u;t[4]!==a||t[5]!==s.diff||t[6]!==s.status?(u=s.status===`ready`&&(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(ue,{className:`size-3 animate-spin`}),`Loading diff renderer`]}),children:(0,Z.jsx)(ey,{diff:s.diff,viewType:a})}),t[4]=a,t[5]=s.diff,t[6]=s.status,t[7]=u):u=t[7];let d;return t[8]!==o||t[9]!==c||t[10]!==l||t[11]!==u?(d=(0,Z.jsxs)(`div`,{id:o,className:`px-3 pb-2`,"data-testid":`timeline-entry-diff`,children:[c,l,u]}),t[8]=o,t[9]=c,t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function Sy(e){let t=(0,$.c)(128),{entry:n,prominent:r,isDark:i,diffLayout:a,cache:o,docName:s,expanded:c,onToggleExpanded:l,onRestoreSuccess:u}=e,d=r===void 0?!1:r,f;t[0]===n.timestamp?f=t[1]:(f=ty(n.timestamp),t[0]=n.timestamp,t[1]=f);let p=f,m;t[2]===n?m=t[3]:(m=iy(n),t[2]=n,t[3]=m);let h=m,g=n.contributors.flatMap(Cy),_;t[4]===n?_=t[5]:(_=_y(n),t[4]=n,t[5]=_);let v=_,[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),C=(0,Q.useRef)(null),w=(0,Q.useId)(),T,E;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>()=>C.current?.abort(),E=[],t[6]=T,t[7]=E):(T=t[6],E=t[7]),(0,Q.useEffect)(T,E);let D;t[8]!==n.sha||t[9]!==l?(D=()=>l(n.sha),t[8]=n.sha,t[9]=l,t[10]=D):D=t[10];let O=D,k;t[11]===b?k=t[12]:(k=function(){C.current?.abort(),C.current=null,S(!1),b(!1)},t[11]=b,t[12]=k);let A=k,j;t[13]!==s||t[14]!==n.sha||t[15]!==u||t[16]!==b?(j=async function(){S(!0);let e=new AbortController;C.current=e;let t=function(){e.signal.aborted||S(!1),C.current===e&&(C.current=null)},r;try{r=await fetch(`/api/rollback`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({docName:s,commitSha:n.sha}),signal:e.signal})}catch(r){let i=r;!e.signal.aborted&&!(i instanceof DOMException&&i.name===`AbortError`)&&(console.error(`[timeline] rollback fetch failed`,{docName:s,sha:n.sha,err:i}),X.error(`Restore failed — document unchanged`,{duration:4e3})),t();return}if(e.signal.aborted){t();return}if(r.ok)b(!1),u();else{let e=`HTTP ${r.status}`;try{let t=fi.safeParse(await r.json());t.success&&(e=t.data.title)}catch{}console.error(`[timeline] rollback failed`,{docName:s,sha:n.sha,status:r.status,detail:e}),X.error(`Restore failed`,{description:e,duration:6e3})}t()},t[13]=s,t[14]=n.sha,t[15]=u,t[16]=b,t[17]=j):j=t[17];let M=j,N;t[18]!==n||t[19]!==i||t[20]!==d?(N=d?(()=>{let e=ly(n);return e===`bridge-merge-loss`?(0,Z.jsx)(dr,{className:`size-3.5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":`true`}):e===`external-change-rescue`?(0,Z.jsx)(ic,{className:`size-3.5 shrink-0 text-sky-600 dark:text-sky-400`,"aria-hidden":`true`}):(0,Z.jsx)(nc,{className:`size-3.5 shrink-0 text-muted-foreground`})})():(0,Z.jsx)(oy,{entry:n,isDark:i}),t[18]=n,t[19]=i,t[20]=d,t[21]=N):N=t[21];let P=N,F=c?w:void 0,I=c?`bg-muted`:`hover:bg-muted/80`,L;t[22]===I?L=t[23]:(L=[`group flex w-full items-start gap-2.5 rounded-lg px-3 py-2.5 text-left transition-colors cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-ring`,I],t[22]=I,t[23]=L);let R=L.join(` `),z;t[24]===O?z=t[25]:(z=e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),O())},t[24]=O,t[25]=z);let B;t[26]===P?B=t[27]:(B=(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:P}),t[26]=P,t[27]=B);let V;t[28]!==h||t[29]!==n||t[30]!==d?(V=d?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-xs text-foreground truncate`,children:uy(n)}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground/50`,children:`·`}),(0,Z.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:h})]}):(0,Z.jsx)(`span`,{className:`truncate text-xs text-foreground`,children:h}),t[28]=h,t[29]=n,t[30]=d,t[31]=V):V=t[31];let H;t[32]!==n.timestamp||t[33]!==p?(H=(0,Z.jsx)(`time`,{className:`ml-auto shrink-0 text-xs text-muted-foreground/80`,dateTime:n.timestamp,title:n.timestamp,children:p}),t[32]=n.timestamp,t[33]=p,t[34]=H):H=t[34];let U;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px shrink-0 bg-border`}),t[35]=U):U=t[35];let W;t[36]===n?W=t[37]:(W=hy(n),t[36]=n,t[37]=W);let G;t[38]===b?G=t[39]:(G=e=>{e.stopPropagation(),b(!0)},t[38]=b,t[39]=G);let K;t[40]===x?K=t[41]:(K=x?(0,Z.jsx)(ue,{className:`size-3 animate-spin`}):(0,Z.jsx)(ki,{className:`size-3`}),t[40]=x,t[41]=K);let q;t[42]!==x||t[43]!==W||t[44]!==G||t[45]!==K?(q=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon`,className:`size-5 shrink-0 text-muted-foreground hover:text-destructive`,"data-testid":`timeline-entry-restore`,"aria-label":W,disabled:x,onClick:G,children:K})}),t[42]=x,t[43]=W,t[44]=G,t[45]=K,t[46]=q):q=t[46];let ee;t[47]===n?ee=t[48]:(ee=hy(n),t[47]=n,t[48]=ee);let te;t[49]===ee?te=t[50]:(te=(0,Z.jsx)(vn,{side:`top`,children:ee}),t[49]=ee,t[50]=te);let ne;t[51]!==q||t[52]!==te?(ne=(0,Z.jsxs)(yn,{children:[q,te]}),t[51]=q,t[52]=te,t[53]=ne):ne=t[53];let re;t[54]!==V||t[55]!==H||t[56]!==ne?(re=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[V,H,U,ne]}),t[54]=V,t[55]=H,t[56]=ne,t[57]=re):re=t[57];let ie;t[58]===v?ie=t[59]:(ie=v.length>0&&(0,Z.jsx)(vy,{summaries:v}),t[58]=v,t[59]=ie);let ae=g.length>0?(0,Z.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,title:g.join(`, `),children:g.join(`, `)}):(0,Z.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,title:n.message,children:n.message}),oe;t[60]!==re||t[61]!==ie||t[62]!==ae?(oe=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[re,ie,ae]}),t[60]=re,t[61]=ie,t[62]=ae,t[63]=oe):oe=t[63];let se;t[64]!==c||t[65]!==O||t[66]!==F||t[67]!==R||t[68]!==z||t[69]!==B||t[70]!==oe?(se=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":c,"aria-controls":F,"data-testid":`timeline-entry-expand`,className:R,onClick:O,onKeyDown:z,children:[B,oe]}),t[64]=c,t[65]=O,t[66]=F,t[67]=R,t[68]=z,t[69]=B,t[70]=oe,t[71]=se):se=t[71];let ce;t[72]!==o||t[73]!==a||t[74]!==w||t[75]!==s||t[76]!==n.sha||t[77]!==c?(ce=c&&(0,Z.jsx)(xy,{sha:n.sha,docName:s,cache:o,diffLayout:a,panelId:w}),t[72]=o,t[73]=a,t[74]=w,t[75]=s,t[76]=n.sha,t[77]=c,t[78]=ce):ce=t[78];let le;t[79]!==se||t[80]!==ce?(le=(0,Z.jsxs)(`div`,{className:`flex flex-col rounded-lg`,children:[se,ce]}),t[79]=se,t[80]=ce,t[81]=le):le=t[81];let J;t[82]!==A||t[83]!==b?(J=e=>{e?b(!0):A()},t[82]=A,t[83]=b,t[84]=J):J=t[84];let de;t[85]===n?de=t[86]:(de=gy(n),t[85]=n,t[86]=de);let fe;t[87]===de?fe=t[88]:(fe=(0,Z.jsx)(bo,{children:de}),t[87]=de,t[88]=fe);let pe;t[89]===n.timestamp?pe=t[90]:(pe=ny(n.timestamp),t[89]=n.timestamp,t[90]=pe);let me;t[91]===n.sha?me=t[92]:(me=ry(n.sha),t[91]=n.sha,t[92]=me);let he;t[93]!==p||t[94]!==pe||t[95]!==me?(he=(0,Z.jsxs)(`span`,{className:`font-medium text-foreground`,children:[p,` (`,pe,`, `,me,`)`]}),t[93]=p,t[94]=pe,t[95]=me,t[96]=he):he=t[96];let ge;t[97]===h?ge=t[98]:(ge=(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:h}),t[97]=h,t[98]=ge);let _e;t[99]!==he||t[100]!==ge?(_e=(0,Z.jsxs)(vo,{children:[`This will replace the current document content with the version from`,` `,he,` `,`by `,ge,`. Your current content is already saved in the timeline — you can restore it anytime.`]}),t[99]=he,t[100]=ge,t[101]=_e):_e=t[101];let ve;t[102]!==fe||t[103]!==_e?(ve=(0,Z.jsxs)(Ao,{children:[fe,_e]}),t[102]=fe,t[103]=_e,t[104]=ve):ve=t[104];let ye;t[105]===A?ye=t[106]:(ye=(0,Z.jsx)(Y,{variant:`outline`,"data-testid":`timeline-entry-restore-cancel`,onClick:A,children:`Cancel`}),t[105]=A,t[106]=ye);let be;t[107]===M?be=t[108]:(be=()=>M(),t[107]=M,t[108]=be);let xe;t[109]===x?xe=t[110]:(xe=x?(0,Z.jsx)(ue,{className:`mr-2 size-4 animate-spin`}):null,t[109]=x,t[110]=xe);let Se;t[111]!==x||t[112]!==be||t[113]!==xe?(Se=(0,Z.jsxs)(Y,{variant:`destructive`,"data-testid":`timeline-entry-restore-confirm`,disabled:x,onClick:be,children:[xe,`Restore`]}),t[111]=x,t[112]=be,t[113]=xe,t[114]=Se):Se=t[114];let Ce;t[115]!==ye||t[116]!==Se?(Ce=(0,Z.jsxs)(Oo,{children:[ye,Se]}),t[115]=ye,t[116]=Se,t[117]=Ce):Ce=t[117];let we;t[118]!==ve||t[119]!==Ce?(we=(0,Z.jsxs)(wo,{children:[ve,Ce]}),t[118]=ve,t[119]=Ce,t[120]=we):we=t[120];let Te;t[121]!==y||t[122]!==J||t[123]!==we?(Te=(0,Z.jsx)(jo,{open:y,onOpenChange:J,children:we}),t[121]=y,t[122]=J,t[123]=we,t[124]=Te):Te=t[124];let Ee;return t[125]!==le||t[126]!==Te?(Ee=(0,Z.jsxs)(Z.Fragment,{children:[le,Te]}),t[125]=le,t[126]=Te,t[127]=Ee):Ee=t[127],Ee}function Cy(e){return e.docs}function wy(e){let t=(0,$.c)(63),{docName:n,diffLayout:r,onDiffLayoutChange:i}=e,{resolvedTheme:a}=vr(),o=a===`dark`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[0]=s):s=t[0];let[c,l]=(0,Q.useState)(s),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(null),m=(0,Q.useRef)(null),[h]=(0,Q.useState)(Oy),[g,_]=(0,Q.useState)(Dy),v;t[1]===h?v=t[2]:(v=()=>{_(new Set),h.clear()},t[1]=h,t[2]=v);let y;t[3]===n?y=t[4]:(y=[n],t[3]=n,t[4]=y),(0,Q.useEffect)(v,y);let b;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(b=function(e){_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[5]=b):b=t[5];let x=b,S;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(S=function(){_(new Set)},t[6]=S):S=t[6];let C=S,w,T;t[7]===n?(w=t[8],T=t[9]):(w=()=>{if(!n){l([]);return}let e=!1,t=async function(){if(n)try{let t=await fetch(`/api/history?docName=${encodeURIComponent(n)}&limit=100`);if(e)return;if(!t.ok){p(`History unavailable`);return}let r=await t.json();if(e)return;l(r.entries??[]),p(null)}catch(t){let n=t;if(e)return;p(`History unavailable`),console.error(`[timeline]`,n)}};return d(!0),t().finally(()=>{e||d(!1)}),m.current=setInterval(t,1e4),()=>{e=!0,m.current&&clearInterval(m.current)}},T=[n],t[7]=n,t[8]=w,t[9]=T),(0,Q.useEffect)(w,T);let E,D,O,k,A,j,M,N;if(t[10]!==h||t[11]!==r||t[12]!==n||t[13]!==c||t[14]!==f||t[15]!==g||t[16]!==o||t[17]!==u||t[18]!==i){let e=[],a=[],s=!1;for(let t of c)t.type===`checkpoint`?(a.length>0&&(e.push({kind:`wip-group`,entries:a,isPreCheckpoint:!s}),a=[]),e.push({kind:`checkpoint`,entry:t}),s=!0):a.push(t);a.length>0&&e.push({kind:`wip-group`,entries:a,isPreCheckpoint:!s});let l;t[27]===c?l=t[28]:(l=c.some(Ey),t[27]=c,t[28]=l);let d=!l,p=!u&&!f&&c.length>0;A=`flex h-full flex-col`,t[29]!==r||t[30]!==p||t[31]!==i?(j=p&&(0,Z.jsx)(`div`,{className:`flex items-center justify-end gap-1 px-2 py-1.5`,children:(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsxs)(Wo,{type:`single`,value:r,onValueChange:e=>{e&&i(e)},"aria-label":`Diff layout`,variant:`segmented`,size:`sm`,spacing:1,className:`bg-muted dark:bg-background p-0.5 rounded-md shrink-0`,children:[(0,Z.jsx)(Vo,{value:`unified`,"aria-label":`Unified diff`,className:`size-6 px-0`,children:(0,Z.jsx)(Lc,{className:`size-3.5`})}),(0,Z.jsx)(Vo,{value:`split`,"aria-label":`Split diff`,className:`size-6 px-0`,children:(0,Z.jsx)(Qs,{className:`size-3.5`})})]})}),(0,Z.jsx)(vn,{children:r===`unified`?`Unified diff`:`Split diff`})]})}),t[29]=r,t[30]=p,t[31]=i,t[32]=j):j=t[32],M=`flex-1 overflow-y-auto subtle-scrollbar scroll-fade-mask`,t[33]===u?N=t[34]:(N=u&&(0,Z.jsx)(`div`,{className:`flex flex-col gap-1 p-2`,role:`status`,"aria-busy":`true`,"aria-label":`Loading timeline history`,children:[1,2,3].map(Ty)}),t[33]=u,t[34]=N),t[35]!==f||t[36]!==u?(E=!u&&f&&(0,Z.jsx)(`div`,{className:`px-4 py-3`,children:(0,Z.jsx)(`p`,{className:`text-xs text-destructive`,children:f})}),t[35]=f,t[36]=u,t[37]=E):E=t[37],t[38]!==c.length||t[39]!==f||t[40]!==u?(D=!u&&!f&&c.length===0&&(0,Z.jsx)(`div`,{className:`px-4 py-8 text-center`,children:(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No history yet`})}),t[38]=c.length,t[39]=f,t[40]=u,t[41]=D):D=t[41],t[42]!==h||t[43]!==r||t[44]!==n||t[45]!==c||t[46]!==f||t[47]!==g||t[48]!==d||t[49]!==o||t[50]!==u?(O=!u&&!f&&d&&c.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-col gap-1 p-2`,children:c.map(e=>(0,Z.jsx)(Sy,{entry:e,isDark:o,diffLayout:r,cache:h,docName:n,expanded:g.has(e.sha),onToggleExpanded:x,onRestoreSuccess:C},e.sha))}),t[42]=h,t[43]=r,t[44]=n,t[45]=c,t[46]=f,t[47]=g,t[48]=d,t[49]=o,t[50]=u,t[51]=O):O=t[51],k=!u&&!f&&!d&&(0,Z.jsx)(`div`,{className:`flex flex-col gap-1 p-2`,children:e.map((e,t)=>e.kind===`checkpoint`?(0,Z.jsx)(Sy,{entry:e.entry,prominent:!0,isDark:o,diffLayout:r,cache:h,docName:n,expanded:g.has(e.entry.sha),onToggleExpanded:x,onRestoreSuccess:C},e.entry.sha):(0,Z.jsx)(sy,{entries:e.entries,defaultExpanded:e.isPreCheckpoint,isDark:o,diffLayout:r,cache:h,docName:n,expandedShas:g,onToggleExpanded:x,onRestoreSuccess:C},e.entries[0]?.sha??`wip-${t}`))}),t[10]=h,t[11]=r,t[12]=n,t[13]=c,t[14]=f,t[15]=g,t[16]=o,t[17]=u,t[18]=i,t[19]=E,t[20]=D,t[21]=O,t[22]=k,t[23]=A,t[24]=j,t[25]=M,t[26]=N}else E=t[19],D=t[20],O=t[21],k=t[22],A=t[23],j=t[24],M=t[25],N=t[26];let P;t[52]!==E||t[53]!==D||t[54]!==O||t[55]!==k||t[56]!==M||t[57]!==N?(P=(0,Z.jsxs)(`div`,{className:M,children:[N,E,D,O,k]}),t[52]=E,t[53]=D,t[54]=O,t[55]=k,t[56]=M,t[57]=N,t[58]=P):P=t[58];let F;return t[59]!==A||t[60]!==j||t[61]!==P?(F=(0,Z.jsxs)(`div`,{className:A,children:[j,P]}),t[59]=A,t[60]=j,t[61]=P,t[62]=F):F=t[62],F}function Ty(e){return(0,Z.jsxs)(`div`,{className:`flex items-start gap-2.5 rounded-lg px-3 py-2.5`,children:[(0,Z.jsx)(Ma,{className:`size-3.5 rounded mt-0.5 shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,Z.jsx)(Ma,{className:`h-3 w-28`}),(0,Z.jsx)(Ma,{className:`h-3 w-40`})]})]},e)}function Ey(e){return e.type===`checkpoint`}function Dy(){return new Set}function Oy(){return new Ai(32)}var ky=[{id:`outline`,label:`Outline`,icon:xc},{id:`links`,label:`Links`,icon:Qe},{id:`graph`,label:`Graph`,icon:Cc},{id:`timeline`,label:`Timeline`,icon:Js}];function Ay(){return n(()=>import(`./GraphPanel-CbVOnaKD.js`),__vite__mapDeps([18,1,19,3,6,7,20,21,22,23,24,25,26,27,28,29,30,31]),import.meta.url)}var jy=(0,Q.lazy)(async()=>({default:(await Ay()).GraphPanel})),My=(0,Q.lazy)(async()=>({default:(await n(()=>import(`./ActivityModeContent-fhFzM0sk.js`),__vite__mapDeps([32,1,2,33,34,35,20,36,37,38,39,19,3,6,7,4,10,9,40,41]),import.meta.url)).ActivityModeContent}));function Ny(e){let t=(0,$.c)(13),{docName:n,isSourceMode:r,activeTab:i,onActiveTabChange:a,mode:o}=e,[s,c]=(0,Q.useState)(`unified`),l;t[0]!==i||t[1]!==o||t[2]!==a?(l=o===`doc`?(0,Z.jsx)(`div`,{className:`flex flex-row items-center justify-center gap-3 p-2`,children:(0,Z.jsx)(Wo,{type:`single`,variant:`outline`,value:i,onValueChange:e=>{e&&a(e)},"aria-label":`Document panels`,children:ky.map(Py)})}):null,t[0]=i,t[1]=o,t[2]=a,t[3]=l):l=t[3];let u;t[4]!==i||t[5]!==s||t[6]!==n||t[7]!==r||t[8]!==o?(u=o===`doc`?(0,Z.jsxs)(`div`,{role:`tabpanel`,id:`panel-${i}`,"aria-labelledby":`tab-${i}`,className:`min-h-0 flex-1`,children:[i===`outline`&&(0,Z.jsx)(ys,{docName:n,isSourceMode:r}),i===`links`&&(0,Z.jsx)(Cv,{docName:n}),i===`graph`&&(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Loading graph`}),children:(0,Z.jsx)(jy,{activeDocName:n})}),i===`timeline`&&(0,Z.jsx)(wy,{docName:n,diffLayout:s,onDiffLayoutChange:c})]}):(0,Z.jsx)(`div`,{className:`min-h-0 flex-1`,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:`Loading agent activity`}),children:(0,Z.jsx)(My,{})})}),t[4]=i,t[5]=s,t[6]=n,t[7]=r,t[8]=o,t[9]=u):u=t[9];let d;return t[10]!==l||t[11]!==u?(d=(0,Z.jsxs)(Z.Fragment,{children:[l,u]}),t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function Py(e){let{id:t,label:n,icon:r}=e;return(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(Vo,{value:t,role:`tab`,id:`tab-${t}`,"aria-controls":`panel-${t}`,"aria-label":n,asChild:!0,children:(0,Z.jsx)(kr,{children:(0,Z.jsx)(r,{})})}),(0,Z.jsx)(vn,{side:`bottom`,children:n})]},t)}function Fy(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Iy(e,t){let n=getComputedStyle(e.ownerDocument.body);return t*parseFloat(n.fontSize)}function Ly(e){return e/100*window.innerHeight}function Ry(e){return e/100*window.innerWidth}function zy(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function By({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=zy(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Iy(t,i);break;case`em`:r=Fy(t,i);break;case`vh`:r=Ly(i);break;case`vw`:r=Ry(i);break}return r}function Vy(e){return parseFloat(e.toFixed(3))}function Hy({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function Uy(e){let{panels:t}=e,n=Hy({group:e});return n===0?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=Vy(By({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=Vy(By({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=Vy(By({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=Vy(By({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function Wy(e,t=`Assertion error`){if(!e)throw Error(t)}function Gy(e,t){return Array.from(t).sort(e===`horizontal`?Ky:qy)}function Ky(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function qy(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function Jy(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function Yy(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function Xy({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=Yy(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return Wy(i,`No rect found`),i}var Zy;function Qy(){return Zy===void 0&&(Zy=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),Zy}function $y(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=Gy(n,Array.from(t.children).filter(Jy).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.hasAttribute(`data-disabled`)||(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,Xy({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=Qy()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:Hy({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var eb=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},tb=new Map,nb=new eb;function rb(e){tb=new Map(tb),tb.delete(e)}function ib(e,t){for(let[t]of tb)if(t.id===e)return t}function ab(e,t){for(let[t,n]of tb)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function ob(){return tb}function sb(e,t){return nb.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function cb(e,t){let n=tb.get(e);tb=new Map(tb),tb.set(e,t),nb.emit(`groupChange`,{group:e,prev:n,next:t})}function lb(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=Yy(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function ub(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function db(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:_b(e),b:_b(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();Wy(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:gb(hb(n.a)),b:gb(hb(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var fb=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function pb(e){let t=getComputedStyle(vb(e)??e).display;return t===`flex`||t===`inline-flex`}function mb(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||pb(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||fb.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function hb(e){let t=e.length;for(;t--;){let n=e[t];if(Wy(n,`Missing node`),mb(n))return n}return null}function gb(e){return e&&Number(getComputedStyle(e).zIndex)||0}function _b(e){let t=[];for(;e;)t.push(e),e=vb(e);return t}function vb(e){let{parentNode:t}=e;return ub(t)?t.host:t}function yb(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function bb({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!Jy(n)||n.contains(e)||e.contains(n))return!0;if(db(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(yb(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function xb(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=$y(r),a=lb(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&bb({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function Sb(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function Cb(e,t,n=0){return Math.abs(Vy(e)-Vy(t))<=n}function wb(e,t){return Cb(e,t)?0:e>t?1:-1}function Tb({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if(wb(r,c)<0)if(a){let e=(i+c)/2;r=wb(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=Vy(r),r}function Eb({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(Cb(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;Wy(u!=null,`Invalid first pivot index`),Wy(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];Wy(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(Wy(n!=null,`Previous layout not found for panel index ${t}`),Cb(n,i)){let t=o-n;wb(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];Wy(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(Wy(n!=null,`Previous layout not found for panel index ${t}`),Cb(n,o)){let t=n-i;wb(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];Wy(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&wb(i,c)<0)if(e>0){let t=c-o,n=t/2;wb(i+e,c)<0&&(e=wb(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;wb(i-e,c)<0&&(e=wb(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];Wy(e!=null,`Previous layout not found for panel index ${r}`);let a=Tb({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];Wy(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=Tb({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!Cb(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(Sb(c,l))return i;{let t=e<0?d:u,r=s[t];Wy(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=Tb({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!Cb(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];Wy(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=Tb({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(Cb(i,s)||(t-=s-i,l[r]=s),Cb(t,0))break;e>0?r--:r++}}}if(!Cb(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function Db(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||wb(e[n],t[n])!==0)return!1;return!0}function Ob({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!Cb(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];Wy(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];Wy(i!=null,`No layout data found for index ${e}`);let o=r[e];Wy(o!=null,`No layout data found for index ${e}`);let s=Tb({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!Cb(a,0))for(let e=0;e<t.length;e++){let n=r[e];Wy(n!=null,`No layout data found for index ${e}`);let i=n+a,o=Tb({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,Cb(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function kb({groupId:e,panelId:t}){let n=()=>{let t=ob();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,groupSize:o,separatorToPanels:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,groupSize:o,layout:a,separatorToPanels:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=e=>{let r=a();if(e===r)return;let{defaultLayoutDeferred:i,derivedPanelConstraints:o,group:s,groupSize:c,layout:l,separatorToPanels:u}=n(),d=s.panels.findIndex(e=>e.id===t),f=d===s.panels.length-1,p=Ob({layout:Eb({delta:f?r-e:e-r,initialLayout:l,panelConstraints:o,pivotIndices:f?[d-1,d]:[d,d+1],prevLayout:l,trigger:`imperative-api`}),panelConstraints:o});Db(l,p)||cb(s,{defaultLayoutDeferred:i,derivedPanelConstraints:o,groupSize:c,layout:p,separatorToPanels:u})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),s=a();e&&s!==t&&(n.expandToSize=s,o(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:s}=i(),c=a();if(e&&c===t){let e=s.expandToSize??n;e===0&&(e=1),o(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&Cb(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=Hy({group:t});o(Vy(By({groupSize:a,panelElement:r,styleProp:e})/a*100))}}}function Ab(e){e.defaultPrevented||xb(e,ob()).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=kb({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function jb(e){let t=ob();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function Mb({groupId:e}){let t=()=>{let t=ob();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,groupSize:a,layout:o,separatorToPanels:s}=t(),c=Ob({layout:e,panelConstraints:r});return n?o:(Db(o,c)||cb(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function Nb(e,t){let n=jb(e),r=ab(n.id,!0),i=n.separators.find(t=>t.element===e);Wy(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);Wy(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=Mb({groupId:n.id}).getLayout(),c=Ob({layout:Eb({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});Db(s,c)||cb(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels})}function Pb(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=jb(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&Nb(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&Nb(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&Nb(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&Nb(t,-5);break;case`End`:e.preventDefault(),Nb(t,100);break;case`Enter`:{e.preventDefault();let n=jb(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=ab(n.id,!0),o=n.separators.find(e=>e.element===t);Wy(o,`Matching separator not found`);let s=a.get(o);Wy(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(Wy(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];Nb(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=jb(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);Wy(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),Nb(t,-100);break}}var Fb={cursorFlags:0,state:`inactive`},Ib=new eb;function Lb(){return Fb}function Rb(e){return Ib.addListener(`change`,e)}function zb(e){let t=Fb,n={...Fb};n.cursorFlags=e,Fb=n,Ib.emit(`change`,{prev:t,next:n})}function Bb(e){let t=Fb;Fb=e,Ib.emit(`change`,{prev:t,next:e})}function Vb(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=ob(),n=xb(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus({preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),Bb({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}var Hb=e=>e,Ub=()=>{},Wb=1,Gb=2,Kb=4,qb=8,Jb=3,Yb=12,Xb;function Zb(){return Xb===void 0&&(Xb=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(Xb=!0)),Xb}function Qb({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&Zb()){let t=(e&Wb)!==0,n=(e&Gb)!==0,r=(e&Kb)!==0,i=(e&qb)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return Zb()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var $b=new WeakMap;function ex(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=$b.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(n));let r=Lb();switch(r.state){case`active`:case`hover`:{let e=Qb({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}$b.set(e,{prevStyle:t,styleSheet:n})}function tx({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:c,panels:l}=n,{disableCursor:u}=n.mutableState,d=0;d=a?c===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:c===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let f=r.get(n),p=i.get(n);if(!f||!p)return;let{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:_,separatorToPanels:v}=p;if(h&&_&&v){let t=Eb({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(Db(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?Wb:Gb;break;case`vertical`:s|=d<0?Kb:qb;break}}else cb(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&Jb:c|=s&Jb,t.movementY===0?c|=o&Yb:c|=s&Yb,zb(c),ex(e)}function nx(e){let t=ob(),n=Lb();switch(n.state){case`active`:tx({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function rx(e){if(e.defaultPrevented)return;let t=Lb(),n=ob();switch(t.state){case`active`:if(e.buttons===0){Bb({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=ab(e.group.id,!0);cb(e.group,t)});return}for(let n of t.hitRegions)if(n.separator){let{element:t}=n.separator;t.hasPointerCapture?.(e.pointerId)||t.setPointerCapture?.(e.pointerId)}tx({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=xb(e,n);r.length===0?t.state!==`inactive`&&Bb({cursorFlags:0,state:`inactive`}):Bb({cursorFlags:0,hitRegions:r,state:`hover`}),ex(e.currentTarget);break}}}function ix(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Lb().state){case`hover`:Bb({cursorFlags:0,state:`inactive`})}}function ax(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=Lb();switch(t.state){case`active`:Bb({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(ex(e.currentTarget),t.hitRegions.forEach(e=>{let t=ab(e.group.id,!0);cb(e.group,t)}),e.preventDefault())}}function ox(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=Vy(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=Vy((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function sx(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=Hy({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:Vy(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function cx(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function lx({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.panels){let e=r[l.id]??0;switch(l.panelConstraints.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=Vy(e/100*n/t*100);s.set(l.id,r),i+=r;break}default:c.push(l.id),a+=e;break}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=Vy((r[e]??0)/a*l);else{let e=Vy(l/c.length);for(let t of c)u[t]=e}return u}function ux(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var dx=new Map;function fx(e){let t=!0;Wy(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){let t=Hy({group:e});if(t===0)return;let n=ab(e.id);if(!n)return;let r=Uy(e),i=n.defaultLayoutDeferred?ox(r):n.layout,a=Ob({layout:lx({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&Db(n.layout,a)&&cx(n.derivedPanelConstraints,r)&&n.groupSize===t)return;cb(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else sx(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{Wy(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=Hy({group:e}),s=Uy(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(ux(e.panels,l)||(l=void 0));let u=Ob({layout:e.mutableState.layouts[c]??l??ox(s),panelConstraints:s}),d=e.element.ownerDocument;dx.set(d,(dx.get(d)??0)+1);let f=new Map;return $y(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),cb(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{Wy(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,Pb)}),dx.get(d)===1&&(d.addEventListener(`dblclick`,Ab,!0),d.addEventListener(`pointerdown`,Vb,!0),d.addEventListener(`pointerleave`,nx),d.addEventListener(`pointermove`,rx),d.addEventListener(`pointerout`,ix),d.addEventListener(`pointerup`,ax,!0)),function(){t=!1,dx.set(d,Math.max(0,(dx.get(d)??0)-1)),rb(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,Pb)}),dx.get(d)||(d.removeEventListener(`dblclick`,Ab,!0),d.removeEventListener(`pointerdown`,Vb,!0),d.removeEventListener(`pointerleave`,nx),d.removeEventListener(`pointermove`,rx),d.removeEventListener(`pointerout`,ix),d.removeEventListener(`pointerup`,ax,!0)),a.disconnect()}}function px(){let[e,t]=(0,Q.useState)({});return[e,(0,Q.useCallback)(()=>t({}),[])]}function mx(e){let t=(0,Q.useId)();return`${e??t}`}var hx=typeof window<`u`?Q.useLayoutEffect:Q.useEffect;function gx(e){let t=(0,Q.useRef)(e);return hx(()=>{t.current=e},[e]),(0,Q.useCallback)((...e)=>t.current?.(...e),[t])}function _x(...e){return gx(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function vx(e){let t=(0,Q.useRef)({...e});return hx(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var yx=(0,Q.createContext)(null);function bx(e,t){let n=(0,Q.useRef)({getLayout:()=>({}),setLayout:Hb});(0,Q.useImperativeHandle)(t,()=>n.current,[]),hx(()=>{Object.assign(n.current,Mb({groupId:e}))})}function xx({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,Q.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=gx(e=>{Db(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=gx(e=>{Db(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),_=mx(s),v=(0,Q.useRef)(null),[y,b]=px(),x=(0,Q.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=_x(v,a);bx(_,o);let C=gx((e,t)=>{let r=Lb(),i=ib(e),a=ab(e);if(a){let e=!1;switch(r.state){case`active`:e=r.hitRegions.some(e=>e.group===i);break}return{flexGrow:a.layout[t]??1,pointerEvents:e?`none`:void 0}}if(n?.[t])return{flexGrow:n?.[t]}}),w=vx({defaultLayout:n,disableCursor:r}),T=(0,Q.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=Gy(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=Gy(u,[...t.separators,e]),b(),()=>{t.separators=t.separators.filter(t=>t!==e),b()}},updatePanelProps:(e,{disabled:t})=>{let n=x.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=ib(_),i=ab(_);r&&i&&cb(r,{...i,derivedPanelConstraints:Uy(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=x.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[C,_,b,u,w]),E=(0,Q.useRef)(null);return hx(()=>{let e=v.current;if(e===null)return;let t=x.current,n;if(w.defaultLayout!==void 0&&Object.keys(w.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=w.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:_,mutableState:{defaultLayout:n,disableCursor:!!w.disableCursor,expandedPanelSizes:x.current.lastExpandedPanelSizes,layouts:x.current.layouts},orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};E.current=r;let a=fx(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=ab(r.id,!0);!o&&s.length>0&&(h(c),g(c));let l=sb(_,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:i}=e.next;if(t||n.length===0)return;let a=r.panels.map(({id:e})=>e).join(`,`);r.mutableState.layouts[a]=i,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=Cb(t.collapsedSize,i[t.panelId]),a=Cb(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=Lb().state!==`active`;h(i),o&&g(i)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,Q.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,Z.jsx)(yx.Provider,{value:T,children:(0,Z.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:S,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}xx.displayName=`Group`;function Sx(){let e=(0,Q.useContext)(yx);return Wy(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function Cx(e,t){let{id:n}=Sx(),r=(0,Q.useRef)({collapse:Ub,expand:Ub,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Ub});(0,Q.useImperativeHandle)(t,()=>r.current,[]),hx(()=>{Object.assign(r.current,kb({groupId:n,panelId:e}))})}function wx({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,groupResizeBehavior:s=`preserve-relative-size`,id:c,maxSize:l=`100%`,minSize:u=`0%`,onResize:d,panelRef:f,style:p,...m}){let h=!!c,g=mx(c),_=vx({disabled:a}),v=(0,Q.useRef)(null),y=_x(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=Sx(),T=d!==null,E=gx((e,t,n)=>{d?.(e,c,n)});hx(()=>{let e=v.current;if(e!==null)return C({element:e,id:g,idIsStable:h,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:T?E:void 0,panelConstraints:{groupResizeBehavior:s,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:l,minSize:u}})},[s,n,r,i,T,g,h,l,u,E,C,_]),(0,Q.useEffect)(()=>{w(g,{disabled:a})},[a,g,w]),Cx(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},O=(0,Q.useSyncExternalStore)(e=>sb(x,e),D,D),k;return k=O?JSON.parse(O):i?{flexGrow:void 0,flexShrink:void 0,flexBasis:i}:{flexGrow:1},(0,Z.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...Tx,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...k},children:(0,Z.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}wx.displayName=`Panel`;var Tx={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function Ex(){return(0,Q.useRef)(null)}function Dx({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=Ob({layout:Eb({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=Ob({layout:Eb({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function Ox({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=mx(a),l=vx({disabled:n,disableDoubleClick:r}),[u,d]=(0,Q.useState)({}),[f,p]=(0,Q.useState)(`inactive`),m=(0,Q.useRef)(null),h=_x(m,i),{disableCursor:g,id:_,orientation:v,registerSeparator:y,updateSeparatorProps:b}=Sx(),x=v===`horizontal`?`vertical`:`horizontal`;hx(()=>{let e=m.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=y(t),r=Rb(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=sb(_,e=>{let{derivedPanelConstraints:n,layout:r,separatorToPanels:i}=e.next,a=i.get(t);if(a){let e=a[0],t=a.indexOf(e);d(Dx({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[_,c,y,l]),(0,Q.useEffect)(()=>{b(c,{disabled:n,disableDoubleClick:r})},[n,r,c,b]);let S;return n&&!g&&(S=`not-allowed`),(0,Z.jsx)(`div`,{...s,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":x,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":n?`disabled`:f,"data-testid":c,id:c,ref:h,role:`separator`,style:{flexBasis:`auto`,cursor:S,...o,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}Ox.displayName=`Separator`;var kx={name:`toml`,startState:function(){return{inString:!1,stringType:``,lhs:!0,inArray:0}},token:function(e,t){let n;if(!t.inString&&(n=e.match(/^('''|"""|'|")/))&&(t.stringType=n[0],t.inString=!0),e.sol()&&!t.inString&&t.inArray===0&&(t.lhs=!0),t.inString){for(;t.inString;)if(e.match(t.stringType))t.inString=!1;else if(e.peek()===`\\`)e.next(),e.next();else if(e.eol())break;else e.match(/^.[^\\\"\']*/);return t.lhs?`property`:`string`}else if(t.inArray&&e.peek()===`]`)return e.next(),t.inArray--,`bracket`;else if(t.lhs&&e.peek()===`[`&&e.skipTo(`]`))return e.next(),e.peek()===`]`&&e.next(),`atom`;else if(e.peek()===`#`)return e.skipToEnd(),`comment`;else if(e.eatSpace())return null;else if(t.lhs&&e.eatWhile(function(e){return e!=`=`&&e!=` `}))return`property`;else if(t.lhs&&e.peek()===`=`)return e.next(),t.lhs=!1,null;else if(!t.lhs&&e.match(/^\d\d\d\d[\d\-\:\.T]*Z/))return`atom`;else if(!t.lhs&&(e.match(`true`)||e.match(`false`)))return`atom`;else if(!t.lhs&&e.peek()===`[`)return t.inArray++,e.next(),`bracket`;else if(!t.lhs&&e.match(/^\-?\d+(?:\.\d+)?/))return`number`;else e.eatSpace()||e.next();return null},languageData:{commentTokens:{line:`#`}}},Ax=se({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}}),jx=At({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}});function Mx(e){switch(e.toLowerCase()){case`json`:return vs().language;case`toml`:return ms.define(kx);default:return null}}function Nx(e){let t=(0,$.c)(4),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={status:`loading`},t[0]=n):n=t[0];let[r,i]=(0,Q.useState)(n),a,o;return t[1]===e?(a=t[2],o=t[3]):(a=()=>{let t=!1,n=new AbortController;return i({status:`loading`}),fetch(e,{credentials:`same-origin`,signal:n.signal}).then(Px).then(e=>{t||i({status:`loaded`,content:e})}).catch(e=>{t||e instanceof Error&&e.name===`AbortError`||i({status:`error`,message:e instanceof Error?e.message:`Failed to load file`})}),()=>{t=!0,n.abort()}},o=[e],t[1]=e,t[2]=a,t[3]=o),(0,Q.useEffect)(a,o),r}async function Px(e){if(!e.ok)throw Error(`Failed to load file (HTTP ${e.status})`);return e.text()}function Fx(e){let t=(0,$.c)(27),{src:n,fileName:r,extension:i}=e,a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),{resolvedTheme:s}=vr(),c=Nx(n),l=c.status===`loaded`?c.content:null,u,d;if(t[0]!==i||t[1]!==l||t[2]!==s?(u=()=>{if(!a.current||l===null)return;let e=Mx(i),t=s===`dark`?Ax:jx,n=[xs,...e?[e]:[],us.editable.of(!1),es.readOnly.of(!0),us.lineWrapping,t],r=new us({state:es.create({doc:l,extensions:n}),parent:a.current});return o.current=r,()=>{r.destroy(),o.current=null}},d=[l,i,s],t[0]=i,t[1]=l,t[2]=s,t[3]=u,t[4]=d):(u=t[3],d=t[4]),(0,Q.useEffect)(u,d),c.status===`loading`){let e;t[5]===r?e=t[6]:(e=(0,Z.jsxs)(`span`,{children:[`Loading `,r]}),t[5]=r,t[6]=e);let n;return t[7]!==i||t[8]!==r||t[9]!==e?(n=(0,Z.jsx)(`main`,{className:`flex h-full min-h-0 flex-col items-center justify-center bg-background text-muted-foreground text-sm`,"aria-label":r,"data-text-viewer":``,"data-text-viewer-state":`loading`,"data-text-viewer-extension":i,children:e}),t[7]=i,t[8]=r,t[9]=e,t[10]=n):n=t[10],n}if(c.status===`error`){let e;t[11]===r?e=t[12]:(e=(0,Z.jsxs)(`div`,{className:`font-medium text-sm`,children:[`Couldn't load `,r]}),t[11]=r,t[12]=e);let a;t[13]===c.message?a=t[14]:(a=(0,Z.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:c.message}),t[13]=c.message,t[14]=a);let o;t[15]===n?o=t[16]:(o=(0,Z.jsx)(`a`,{href:n,className:`mt-2 rounded-md border px-3 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground`,children:`Open file`}),t[15]=n,t[16]=o);let s;return t[17]!==i||t[18]!==r||t[19]!==e||t[20]!==a||t[21]!==o?(s=(0,Z.jsxs)(`main`,{className:`flex h-full min-h-0 flex-col items-center justify-center gap-2 bg-background p-4 text-center`,"aria-label":r,"data-text-viewer":``,"data-text-viewer-state":`error`,"data-text-viewer-extension":i,children:[e,a,o]}),t[17]=i,t[18]=r,t[19]=e,t[20]=a,t[21]=o,t[22]=s):s=t[22],s}let f;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(`div`,{ref:a,className:`min-h-0 flex-1 overflow-auto`}),t[23]=f):f=t[23];let p;return t[24]!==i||t[25]!==r?(p=(0,Z.jsx)(`main`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-label":r,"data-text-viewer":``,"data-text-viewer-state":`loaded`,"data-text-viewer-extension":i,children:f}),t[24]=i,t[25]=r,t[26]=p):p=t[26],p}function Ix(e){return Sr(`/api/asset?path=${encodeURIComponent(e)}`)}function Lx(e){return`/api/asset-text?path=${encodeURIComponent(e)}`}function Rx(e){let t=(0,$.c)(28),{assetPath:n,mediaKind:r}=e,[i,a]=(0,Q.useState)(!1),o;t[0]===n?o=t[1]:(o=Ix(n),t[0]=n,t[1]=o);let s=o,c;t[2]===n?c=t[3]:(c=n.split(`/`).pop()??n,t[2]=n,t[3]=c);let l=c,u,d,f;if(t[4]!==n||t[5]!==l||t[6]!==i||t[7]!==r||t[8]!==s){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=l.includes(`.`)?l.split(`.`).pop()??``:``;if(d=e.length>0?e.toUpperCase():`FILE`,u=i?`text`:r,u===`pdf`){let e;t[12]!==l||t[13]!==s?(e=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(Ce,{src:s,title:l,fillContainer:!0})}),t[12]=l,t[13]=s,t[14]=e):e=t[14];let n;t[15]!==l||t[16]!==e?(n=(0,Z.jsx)(`main`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-label":l,children:e}),t[15]=l,t[16]=e,t[17]=n):n=t[17],f=n;break bb0}if(u===`text`){let r;t[18]===n?r=t[19]:(r=Lx(n),t[18]=n,t[19]=r),f=(0,Z.jsx)(Fx,{src:r,fileName:l,extension:e.toLowerCase()},n);break bb0}}t[4]=n,t[5]=l,t[6]=i,t[7]=r,t[8]=s,t[9]=u,t[10]=d,t[11]=f}else u=t[9],d=t[10],f=t[11];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[20]!==u||t[21]!==d||t[22]!==l||t[23]!==s?(p=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:u===`image`?(0,Z.jsx)(Te,{src:s,alt:l,draggable:!1,slotClassName:`flex h-full w-full items-center justify-center`,className:`max-h-full max-w-full`}):u===`video`?(0,Z.jsx)(`video`,{src:s,controls:!0,className:`max-h-full max-w-full`}):u===`audio`?(0,Z.jsx)(`audio`,{src:s,controls:!0,className:`w-full max-w-md`}):(0,Z.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-3 text-center`,children:[(0,Z.jsx)(`div`,{className:`flex size-16 items-center justify-center rounded-md border bg-muted font-medium text-muted-foreground text-sm`,children:d}),(0,Z.jsx)(`div`,{className:`max-w-full break-words font-medium text-sm`,children:l}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,Z.jsx)(Y,{asChild:!0,variant:`outline`,size:`sm`,children:(0,Z.jsx)(`a`,{href:s,children:`Open file`})}),(0,Z.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>a(!0),"data-testid":`asset-preview-open-as-text`,children:`Open with built-in text editor`})]})]})}),t[20]=u,t[21]=d,t[22]=l,t[23]=s,t[24]=p):p=t[24];let m;return t[25]!==l||t[26]!==p?(m=(0,Z.jsx)(`main`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-label":l,children:p}),t[25]=l,t[26]=p,t[27]=m):m=t[27],m}function zx(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`div`,{className:`tiptap-editor pt-10`,role:`status`,"aria-busy":`true`,"aria-label":`Loading document`,children:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(Ma,{className:`h-9 w-2/5 mt-6 mb-5`}),(0,Z.jsx)(Ma,{className:`h-4 w-full`}),(0,Z.jsx)(Ma,{className:`h-4 w-3/4`})]})}),e[0]=t):t=e[0],t}var Bx={"claude-cowork":`claude`,"claude-code":`claude`,codex:`openai`,cursor:`cursor`};function Vx(e){let t=(0,$.c)(23),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({id:r,style:a,className:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{resolvedTheme:o}=vr(),s=Bx[r],c=s?(o===`dark`?nr[s]:void 0)??On[s]:void 0,l;t[5]!==c||t[6]!==a?(l=c?{...a,"--ok-brand-color":c}:a,t[5]=c,t[6]=a,t[7]=l):l=t[7];let u=l,d=c&&`[&_*]:![color:var(--ok-brand-color)]`,f;t[8]!==n||t[9]!==d?(f=mi(d,n),t[8]=n,t[9]=d,t[10]=f):f=t[10];let p=f;if(r===`claude-cowork`||r===`claude-code`){let e;return t[11]!==p||t[12]!==u||t[13]!==i?(e=(0,Z.jsx)(Oi,{style:u,className:p,...i}),t[11]=p,t[12]=u,t[13]=i,t[14]=e):e=t[14],e}if(r===`codex`){let e;return t[15]!==p||t[16]!==u||t[17]!==i?(e=(0,Z.jsx)(Di,{style:u,className:p,...i}),t[15]=p,t[16]=u,t[17]=i,t[18]=e):e=t[18],e}if(r===`cursor`){let e;return t[19]!==p||t[20]!==u||t[21]!==i?(e=(0,Z.jsx)(Pi,{style:u,className:p,...i}),t[19]=p,t[20]=u,t[21]=i,t[22]=e):e=t[22],e}return null}function Hx(e){let{installState:t}=e;return t.installed===null?`Detecting`:t.installed===!1?`Not installed`:null}function Ux(e){let{target:t,installState:n}=e;if(n.installed===null)return{enabled:!1,tooltip:null};if(n.installed===!1){let e=t.appBrandName??t.displayName;return{enabled:!1,tooltip:{message:`Requires ${e}.`,installAction:{label:`Install ${e} →`,url:t.installUrl},...t.hasWebFallback?{webFallback:{label:`Open in claude.ai →`,url:``}}:{}}}}return{enabled:!0,tooltip:null}}function Wx(e){return fr(e)}function Gx(e){return`Opened ${e} in your browser.`}var Kx=`claude.ai`;async function qx(e,t=$m){(await t(fr(e))).ok?X.success(Gx(Kx)):X.error(`Couldn't open ${Kx} in your browser.`)}function Jx(e){let t=(0,$.c)(73),{target:n,installState:r,isElectronHost:i,prompt:a,onSelect:o}=e,s=e.openExternal??$m,c=e.onWebFallbackSuccess??Xx,l=e.onWebFallbackError??Yx,u;t[0]!==r||t[1]!==i||t[2]!==n?(u=Ux({target:n,installState:r,isElectronHost:i}),t[0]=r,t[1]=i,t[2]=n,t[3]=u):u=t[3];let d=u,f;t[4]!==r||t[5]!==i||t[6]!==n?(f=Hx({target:n,installState:r,isElectronHost:i}),t[4]=r,t[5]=i,t[6]=n,t[7]=f):f=t[7];let p=f,m;t[8]!==s||t[9]!==d.tooltip?(m=()=>{d.tooltip&&s(d.tooltip.installAction.url)},t[8]=s,t[9]=d.tooltip,t[10]=m):m=t[10];let h=m,g;t[11]!==l||t[12]!==c||t[13]!==s||t[14]!==a||t[15]!==n?(g=()=>{(async()=>{let e=await s(Wx(a));e.ok?c(n):l(n,e.detail??e.reason)})()},t[11]=l,t[12]=c,t[13]=s,t[14]=a,t[15]=n,t[16]=g):g=t[16];let _=g;if(d.enabled){let e=`open-in-agent-item-${n.id}`,r=`Open with AI ${n.displayName}`,i;t[17]===n.id?i=t[18]:(i=(0,Z.jsx)(Vx,{id:n.id,"aria-hidden":`true`}),t[17]=n.id,t[18]=i);let a;t[19]===n.displayName?a=t[20]:(a=(0,Z.jsx)(`span`,{children:n.displayName}),t[19]=n.displayName,t[20]=a);let s;return t[21]!==o||t[22]!==e||t[23]!==r||t[24]!==i||t[25]!==a?(s=(0,Z.jsxs)(ya,{onSelect:o,"data-testid":e,"aria-label":r,children:[i,a]}),t[21]=o,t[22]=e,t[23]=r,t[24]=i,t[25]=a,t[26]=s):s=t[26],s}if(!d.tooltip){let e=p?`Open with AI ${n.displayName}, ${p}`:`Open with AI ${n.displayName}`,r=`open-in-agent-item-${n.id}`,i;t[27]===n.id?i=t[28]:(i=(0,Z.jsx)(Vx,{id:n.id,"aria-hidden":`true`}),t[27]=n.id,t[28]=i);let a;t[29]===n.displayName?a=t[30]:(a=(0,Z.jsx)(`span`,{className:`flex-1`,children:n.displayName}),t[29]=n.displayName,t[30]=a);let o;t[31]===p?o=t[32]:(o=p?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:p}):null,t[31]=p,t[32]=o);let s;return t[33]!==e||t[34]!==r||t[35]!==i||t[36]!==a||t[37]!==o?(s=(0,Z.jsxs)(ya,{disabled:!0,"data-testid":r,"aria-label":e,children:[i,a,o]}),t[33]=e,t[34]=r,t[35]=i,t[36]=a,t[37]=o,t[38]=s):s=t[38],s}let v=p?`Open with AI ${n.displayName}, ${p}`:`Open with AI ${n.displayName}`,y=`open-in-agent-item-${n.id}`,b;t[39]===n.id?b=t[40]:(b=(0,Z.jsx)(Vx,{id:n.id,"aria-hidden":`true`,className:`mr-2`}),t[39]=n.id,t[40]=b);let x;t[41]===n.displayName?x=t[42]:(x=(0,Z.jsx)(`span`,{className:`flex-1`,children:n.displayName}),t[41]=n.displayName,t[42]=x);let S;t[43]===p?S=t[44]:(S=p?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:p}):null,t[43]=p,t[44]=S);let C;t[45]!==v||t[46]!==y||t[47]!==b||t[48]!==x||t[49]!==S?(C=(0,Z.jsxs)(xa,{"data-testid":y,"data-row-disabled":``,"aria-label":v,children:[b,x,S]}),t[45]=v,t[46]=y,t[47]=b,t[48]=x,t[49]=S,t[50]=C):C=t[50];let w=`open-in-agent-submenu-${n.id}`,T=`open-in-agent-message-${n.id}`,E;t[51]!==d.tooltip.message||t[52]!==T?(E=(0,Z.jsx)(Qi,{className:`font-normal text-muted-foreground text-xs`,"data-testid":T,children:d.tooltip.message}),t[51]=d.tooltip.message,t[52]=T,t[53]=E):E=t[53];let D;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(na,{}),t[54]=D):D=t[54];let O=`open-in-agent-install-${n.id}`,k;t[55]===d.tooltip.installAction.label?k=t[56]:(k=(0,Z.jsx)(`span`,{children:d.tooltip.installAction.label}),t[55]=d.tooltip.installAction.label,t[56]=k);let A;t[57]!==h||t[58]!==O||t[59]!==k?(A=(0,Z.jsx)(ya,{onSelect:h,"data-testid":O,children:k}),t[57]=h,t[58]=O,t[59]=k,t[60]=A):A=t[60];let j;t[61]!==_||t[62]!==d.tooltip.webFallback||t[63]!==n.id?(j=d.tooltip.webFallback?(0,Z.jsxs)(ya,{onSelect:_,"data-testid":`open-in-agent-web-fallback-${n.id}`,"aria-label":`${d.tooltip.webFallback.label}, opens in browser with prompt pre-filled`,children:[(0,Z.jsx)(`span`,{className:`flex-1`,children:d.tooltip.webFallback.label}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`opens in browser with prompt pre-filled`})]}):null,t[61]=_,t[62]=d.tooltip.webFallback,t[63]=n.id,t[64]=j):j=t[64];let M;t[65]!==E||t[66]!==A||t[67]!==j||t[68]!==w?(M=(0,Z.jsxs)(ta,{className:`min-w-[260px]`,"data-testid":w,children:[E,D,A,j]}),t[65]=E,t[66]=A,t[67]=j,t[68]=w,t[69]=M):M=t[69];let N;return t[70]!==M||t[71]!==C?(N=(0,Z.jsxs)(Xa,{children:[C,M]}),t[70]=M,t[71]=C,t[72]=N):N=t[72],N}function Yx(){}function Xx(){}function Zx(e){let t=(0,$.c)(12),{className:n}=e,{states:r,refresh:i}=Oh(),{dispatch:a}=_h(),o=km(),s,c;if(t[0]!==n||t[1]!==a||t[2]!==i||t[3]!==r||t[4]!==o){let e=ah({workspace:o});t[7]===n?s=t[8]:(s=mi(`grid w-full max-w-5xl gap-4 sm:grid-cols-3`,n),t[7]=n,t[8]=s),c=xm.map(t=>{let n=r[t.id]?.installed,o=n===!0?`installed`:n===!1?`missing`:`pending`;return(0,Z.jsx)(Qx,{target:t,status:o,onOpen:o===`installed`&&e!==null?()=>{a(t.id,e)}:void 0,onInstall:()=>{sh(t),i()}},t.id)}),t[0]=n,t[1]=a,t[2]=i,t[3]=r,t[4]=o,t[5]=s,t[6]=c}else s=t[5],c=t[6];let l;return t[9]!==s||t[10]!==c?(l=(0,Z.jsx)(`div`,{className:s,children:c}),t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function Qx(e){let t=(0,$.c)(22),{target:n,status:r,onOpen:i,onInstall:a}=e,o=r===`installed`?i:r===`missing`?a:void 0,s=r===`pending`||r===`installed`&&i===void 0,c=r===`installed`?`Open`:r===`missing`?`Install`:`Checking`,l;t[0]===n.id?l=t[1]:(l=(0,Z.jsx)(Vx,{id:n.id,"aria-hidden":`true`,className:`size-4`}),t[0]=n.id,t[1]=l);let u;t[2]===n.displayName?u=t[3]:(u=(0,Z.jsx)(`h3`,{className:`text-sm font-medium leading-tight`,children:n.displayName}),t[2]=n.displayName,t[3]=u);let d;t[4]!==l||t[5]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center gap-2`,children:[l,u]}),t[4]=l,t[5]=u,t[6]=d):d=t[6];let f;t[7]===n.tagline?f=t[8]:(f=n.tagline?(0,Z.jsx)(`p`,{className:`text-1sm leading-relaxed text-muted-foreground`,children:n.tagline}):null,t[7]=n.tagline,t[8]=f);let p;t[9]!==d||t[10]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[d,f]}),t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===r?m=t[13]:(m=r===`missing`?(0,Z.jsx)(mo,{"aria-hidden":`true`,className:`size-3`}):null,t[12]=r,t[13]=m);let h;t[14]!==c||t[15]!==m?(h=(0,Z.jsxs)(`p`,{className:`mt-auto inline-flex items-center gap-1 pt-2 font-mono text-2xs uppercase tracking-wider text-muted-foreground`,children:[c,m]}),t[14]=c,t[15]=m,t[16]=h):h=t[16];let g;return t[17]!==s||t[18]!==o||t[19]!==p||t[20]!==h?(g=(0,Z.jsxs)(`button`,{type:`button`,onClick:o,disabled:s,className:`group flex h-full flex-col items-start gap-4 rounded-2xl border border-border/60 bg-card p-5 text-left transition-[border-color,box-shadow,transform] hover:border-border hover:shadow-sm focus-visible:border-ring focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 active:translate-y-px disabled:cursor-not-allowed disabled:opacity-60`,children:[p,h]}),t[17]=s,t[18]=o,t[19]=p,t[20]=h,t[21]=g):g=t[21],g}var $x=3100,eS=3;function tS(e,t,n){let r=n?.windowMs??600,i=n?.maxLevel??eS;if(e===0||t>=r)return 1;let a=e+1;return a>i?i:a}var nS={0:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},1:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},2:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},3:{count:16,startRadius:11,baseDistance:7,distanceVariance:3,sizeMin:.45,sizeMax:1.2,maxDelay:500,durationMin:1100,durationMax:2400}},rS=[`var(--color-azure-blue)`,`var(--color-sky-blue)`,`var(--color-violet-300)`,`var(--color-orange-light)`,`var(--color-crystal-blue)`,`var(--color-white-cream)`];function iS(e,t={}){let n=t.rng??Math.random,r=t.colors??rS,i=nS[e];if(i.count===0||r.length===0)return[];let a=[],o=Math.PI*2/i.count;for(let e=0;e<i.count;e++){let t=e*o+(n()-.5)*o*.7,s=i.baseDistance+(n()-.5)*2*i.distanceVariance,c=i.sizeMin+n()*(i.sizeMax-i.sizeMin),l=n()*i.maxDelay,u=i.durationMin+n()*(i.durationMax-i.durationMin),d=Math.floor(n()*r.length),f=Math.cos(t),p=Math.sin(t);a.push({id:e,dx:f*s,dy:p*s,originDx:f*i.startRadius,originDy:p*i.startRadius,size:c,color:r[d]??`currentColor`,delay:l,duration:u})}return a}var aS=1.8,oS=90,sS=16,cS=380,lS=.025,uS=.1,dS=.18,fS=400,pS=9.2736,mS=18.1799,hS=14.5244,gS={1:{halfWidth:1.5,apexLift:2.2},2:{halfWidth:1.4,apexLift:2.6},3:{halfWidth:1.25,apexLift:3}};function _S(e,t){let{halfWidth:n,apexLift:r}=gS[t];return`M${e-n} ${hS+.3} Q${e} ${hS-r}, ${e+n} ${hS+.3}`}function vS(e){let t=1.5,n=.3;return`M${e-t} ${hS-n} Q${e} ${hS+1.4}, ${e+t} ${hS-n}`}var yS=15,bS=15;function xS(e){return{fill:e.color,"--fx-tx":`${e.dx}px`,"--fx-ty":`${e.dy}px`,"--fx-delay":`${e.delay}ms`,"--fx-duration":`${e.duration}ms`}}function SS(e){let t=(0,$.c)(71),{size:n,className:r,trackMouse:i,variant:a,celebrateSignal:o}=e,s=n===void 0?48:n,c=i===void 0?!0:i,l=a===void 0?`default`:a,u=o===void 0?0:o,d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),p=(0,Q.useRef)(null),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m={x:0,y:0},t[0]=m):m=t[0];let h=(0,Q.useRef)(m),[g,_]=(0,Q.useState)(0),[v,y]=(0,Q.useState)(0),b;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(b=[],t[1]=b):b=t[1];let[x,S]=(0,Q.useState)(b),C=(0,Q.useRef)(0),w=(0,Q.useRef)(void 0),T=l===`sleeping`,E;t[2]!==g||t[3]!==T?(E=function(){if(T)return;let e=typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),t=C.current===0?1/0:e-C.current;C.current=e;let n=tS(g,t);_(n),y(ES),S(iS(n)),clearTimeout(w.current),w.current=setTimeout(()=>{_(0),S([])},$x)},t[2]=g,t[3]=T,t[4]=E):E=t[4];let D=E,O,k;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>()=>clearTimeout(w.current),k=[],t[5]=O,t[6]=k):(O=t[5],k=t[6]),(0,Q.useEffect)(O,k);let A,j;t[7]!==u||t[8]!==T?(A=()=>{u===0||T||(_(3),y(TS),S(iS(3)),clearTimeout(w.current),w.current=setTimeout(()=>{_(0),S([])},$x))},j=[u,T],t[7]=u,t[8]=T,t[9]=A,t[10]=j):(A=t[9],j=t[10]),(0,Q.useEffect)(A,j);let M,N;t[11]!==T||t[12]!==c?(M=()=>{if(!c||T||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let e=0,t=0,n=!1,r=0,i=0,a=0,o=0,s=0,l=function(){s===0&&(s=requestAnimationFrame(m))},u=function(r){e=r.clientX,t=r.clientY,n=!0,l()};function m(){s=0;let c=f.current,u=d.current;if(!c||!u){l();return}let m=n;n=!1;let g=c.getBoundingClientRect(),_=g.left+g.width/2,v=g.top+g.height*.48,y=e-_,b=t-v,x=Math.hypot(y,b),S=Math.max(-1,Math.min(1,y/cS)),C=Math.max(-1,Math.min(1,b/cS)),w=S*sS,T=-C*sS,E=0,D=0;if(x>=1){let e=Math.min(x/oS,1)*aS;E=y/x*e,D=b/x*e}let O=Math.abs(T-r)<.01&&Math.abs(w-i)<.01&&Math.abs(E-a)<.01&&Math.abs(D-o)<.01;if(!m&&O)return;l(),r+=(T-r)*uS,i+=(w-i)*uS,u.style.transform=`perspective(${fS}px) rotateX(${r.toFixed(3)}deg) rotateY(${i.toFixed(3)}deg)`,a+=(E-a)*dS,o+=(D-o)*dS;let k=i*lS,A=-r*lS,j=a+k,M=o+A;h.current.x=j,h.current.y=M,p.current?.setAttribute(`transform`,`translate(${j.toFixed(3)} ${M.toFixed(3)})`)}return document.addEventListener(`mousemove`,u,{passive:!0}),l(),()=>{document.removeEventListener(`mousemove`,u),s!==0&&cancelAnimationFrame(s),s=0,d.current&&(d.current.style.transform=``),h.current={x:0,y:0},p.current?.removeAttribute(`transform`)}},N=[c,T],t[11]=T,t[12]=c,t[13]=M,t[14]=N):(M=t[13],N=t[14]),(0,Q.useEffect)(M,N);let P;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>{let e=p.current;if(!e)return;let{x:t,y:n}=h.current;e.setAttribute(`transform`,`translate(${t.toFixed(3)} ${n.toFixed(3)})`)},t[15]=P):P=t[15],(0,Q.useLayoutEffect)(P);let F=g>0,I=F?g:1,L=F?`ok-blob-clicked-${g}`:null,R;t[16]===r?R=t[17]:(R=mi(`ok-blob-3d-wrapper`,r),t[16]=r,t[17]=R);let z=T?`cursor-default`:`cursor-pointer`,B=`body-${v}`,V=T&&`ok-blob-sleeping`,H;t[18]!==L||t[19]!==V?(H=mi(`ok-blob-group`,V,L),t[18]=L,t[19]=V,t[20]=H):H=t[20];let U;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Z.jsx)(`path`,{d:`M25.2339 6.78134C25.5199 7.35734 25.8179 8.47234 26.0179 9.07834C26.0189 9.08234 26.0209 9.08634 26.0219 9.09134C26.0229 9.09534 26.0249 9.10034 26.0259 9.10434C26.0539 9.19734 26.0949 9.29533 26.1519 9.41633C26.2919 9.71133 26.5269 10.1173 27.1299 11.1683C27.3259 11.4643 27.5209 11.7693 27.7119 12.0903C29.9739 15.1623 29.3259 20.1913 27.0469 22.9153C26.7779 23.2953 26.4869 23.6043 26.1889 23.8863C26.1519 23.9253 26.1129 23.9643 26.0729 24.0033C25.3159 24.7543 24.2949 25.4673 23.6129 25.8323C22.7469 26.2983 22.1349 26.5483 21.6299 26.7463C20.3649 27.3063 19.0609 27.7733 17.6569 28.0423C15.9649 28.3513 14.1939 28.4433 12.4569 28.1373C11.4779 27.9663 10.5119 27.6663 9.60891 27.2493C8.77491 26.8663 7.99192 26.3853 7.26992 25.8403C6.83592 25.5393 6.43893 25.2343 6.08093 24.9383C5.57893 24.5223 5.15993 24.1263 4.83493 23.7793C4.04993 22.9443 3.31593 21.8893 2.80893 21.0953C2.72593 20.9663 2.64792 20.8433 2.57592 20.7293C2.56192 20.7093 2.54793 20.6893 2.53393 20.6703C2.08593 20.0263 1.71892 19.3293 1.43792 18.5993C1.42892 18.5453 1.42093 18.4903 1.41293 18.4353C1.32093 17.7443 1.08292 16.9423 1.01092 15.6333C0.984921 15.0653 0.998928 14.4013 1.12393 13.6353C1.20693 13.1413 1.31993 12.9023 1.40893 12.7113C1.43593 12.6543 1.46193 12.6023 1.48593 12.5483C1.56793 12.3653 1.59392 12.1563 1.63592 11.9083C1.68992 11.5883 1.76992 11.1943 2.04592 10.7553C2.94392 9.37934 3.36792 8.81934 3.66592 8.33934C3.75592 8.20334 3.84292 8.08134 3.94192 7.96634C4.21592 7.64634 4.67693 7.29534 5.10293 7.05734C5.16693 7.02234 5.23093 6.98834 5.29193 6.95534C5.62993 6.77834 6.22592 6.30135 6.66992 5.92035C6.83692 5.77635 7.08193 5.60735 7.37393 5.40935C7.67393 5.20535 8.02593 4.96934 8.39193 4.70234C9.32093 4.02634 9.84091 3.69134 10.2599 3.42334C10.3799 3.34734 10.4919 3.27734 10.6049 3.20834C10.9609 2.98834 11.4149 2.73034 11.8869 2.48634C12.4519 2.19334 13.0469 1.92133 13.5089 1.72233C14.7399 1.30233 16.0539 1.01333 17.4169 1.00033C18.1169 0.991333 18.7939 1.16534 19.2389 1.43034C19.6869 1.69534 19.8689 2.00335 19.8039 2.23935C19.7379 2.47835 19.4399 2.63634 19.0109 2.74734C18.5789 2.85634 18.0469 2.92035 17.4889 2.96135C16.3639 3.04235 15.2399 3.36435 14.1499 3.80835C12.8199 4.35135 11.5379 5.07133 10.2719 5.84733C9.38691 6.39133 8.51192 6.97334 7.63592 7.56834C7.54492 7.63034 7.45492 7.69135 7.36492 7.75235C6.97392 8.06635 6.58293 8.38134 6.22293 8.66334C5.97893 8.85734 5.76793 9.04834 5.59393 9.21434C5.26893 9.52334 5.02393 9.74334 4.81893 9.93934C4.67793 10.0753 4.55793 10.2013 4.45593 10.3443C4.40093 10.4213 4.32992 10.5273 4.24792 10.6593C3.90492 11.1933 3.44493 12.1693 3.15393 13.1173C3.01893 13.5363 2.87991 14.0343 2.79391 14.5253C2.66591 15.2253 2.65594 15.9053 2.71994 16.2373C2.82794 16.8193 2.95593 17.4833 3.14093 18.0553C3.31293 18.6003 3.52991 19.0583 3.70791 19.2823C3.81591 19.4183 3.90394 19.5473 3.99594 19.6913C4.09394 19.8413 4.19191 20.0073 4.31091 20.2033C4.47891 20.4803 4.68592 20.8163 5.00192 21.2493C5.36492 21.7463 5.61793 22.1043 5.83493 22.4023C6.14493 22.8243 6.38591 23.1343 6.83691 23.5033C7.33891 23.9113 7.86593 24.3113 8.26693 24.6393C8.44893 24.7883 8.66993 24.9443 8.90493 25.0963C9.21593 25.2963 9.55192 25.4893 9.85592 25.6703C10.1059 25.8203 10.3059 25.9633 10.4869 26.0863C10.5429 26.1243 10.5979 26.1603 10.6519 26.1943C10.8699 26.2803 11.0929 26.3593 11.3159 26.4283C11.3539 26.4323 11.3949 26.4353 11.4369 26.4393C11.6509 26.4573 11.9089 26.4733 12.2209 26.5133C12.7169 26.5753 13.1399 26.6603 13.6019 26.7243C13.9589 26.7733 14.3409 26.8083 14.7729 26.7893C15.0729 26.7753 15.4069 26.7353 15.7389 26.6813C16.2349 26.6023 16.7179 26.4943 17.0569 26.4473C17.1499 26.4343 17.2359 26.4343 17.3209 26.4373C17.3489 26.4393 17.3799 26.4413 17.4109 26.4433C17.4119 26.4433 17.4119 26.4433 17.4129 26.4433C17.4199 26.4433 17.4279 26.4443 17.4349 26.4443C18.2329 26.2413 19.0259 25.9433 19.7959 25.5983C19.8609 25.5633 19.9259 25.5273 19.9899 25.4913C20.3059 25.3173 20.6049 25.1383 20.7869 24.9943C20.9829 24.8393 21.5189 24.5373 22.0579 24.1853C22.4109 23.9553 22.7649 23.7053 23.0369 23.4833C23.1949 23.3553 23.3689 23.2693 23.5479 23.1773C23.7129 23.0923 23.8809 23.0013 24.0349 22.8653C24.1109 22.7983 24.1869 22.7173 24.2639 22.6303C24.3309 22.5563 24.4039 22.4723 24.4759 22.3923C24.5459 22.3153 24.7199 22.1723 24.9139 21.9793C25.0079 21.8863 25.1059 21.7783 25.1909 21.6713C25.2199 21.6323 25.2489 21.5943 25.2769 21.5553C25.5919 21.0403 25.8779 20.5003 26.1019 19.9653C26.1299 19.8403 26.1379 19.7293 26.1279 19.6373C26.1199 19.5703 26.1029 19.5113 26.0839 19.4503C26.0599 19.3643 26.0329 19.2773 26.0239 19.1723C26.0169 19.0893 26.0309 19.0043 26.0629 18.9543C26.0779 18.9323 26.0969 18.9143 26.1129 18.8993C26.1329 18.8823 26.1499 18.8673 26.1569 18.8443C26.1609 18.8273 26.1579 18.8073 26.1529 18.7833C26.1459 18.7443 26.1369 18.6943 26.1539 18.6293C26.2189 18.3853 26.2869 18.1103 26.3319 17.8383C26.3829 17.5393 26.4049 17.2433 26.3949 17.0123C26.3849 16.7493 26.3909 16.3823 26.3469 16.0003C26.3179 15.7343 26.2659 15.4663 26.1979 15.2383C26.1319 15.0143 26.0219 14.7913 25.9039 14.5783C25.7629 14.3223 25.6119 14.0783 25.5169 13.8453C25.4969 13.7983 25.4999 13.7263 25.4999 13.6323C25.5009 13.5673 25.4999 13.4913 25.4919 13.4083C25.3239 13.1243 25.1459 12.8423 24.9589 12.5483C24.9479 12.5413 24.9369 12.5333 24.9249 12.5263C24.6689 12.3503 24.3139 12.1173 24.0769 11.5503C24.0179 11.4063 24.0069 11.2983 23.9969 11.1993C23.9859 11.1013 23.9799 11.0183 23.9289 10.9093C23.8709 10.7853 23.7759 10.6583 23.6709 10.4993C23.5849 10.3703 23.4899 10.2133 23.4199 10.0423C23.3819 9.95134 23.3509 9.85734 23.3329 9.75934C23.3299 9.74334 23.3269 9.72534 23.3229 9.70634C23.2899 9.52734 23.2439 9.26534 23.2409 8.98634C23.0209 8.24434 22.8339 7.48833 22.6519 6.77633C22.3429 5.57133 22.0519 4.54234 21.3329 3.95434C20.9839 3.65334 20.5689 3.35433 20.2459 3.05433C19.9259 2.75633 19.7449 2.47534 19.8019 2.23834C19.8639 2.00634 20.1589 1.82934 20.6659 1.80534C21.1699 1.78334 21.8699 1.93235 22.5209 2.39235C23.6159 3.14235 24.2029 4.38334 24.5599 5.35734C24.5829 5.40834 24.6049 5.46034 24.6259 5.51234C24.7849 5.89434 24.9529 6.22834 25.1199 6.55534C25.1579 6.63034 25.1969 6.70834 25.2339 6.78134Z`,className:`ok-blob-body`}),t[21]=U):U=t[21];let W=(F||T)&&`ok-blob-eye-hidden`,G;t[22]===W?G=t[23]:(G=mi(`ok-blob-eye`,W),t[22]=W,t[23]=G);let K;t[24]===G?K=t[25]:(K=(0,Z.jsx)(`ellipse`,{cx:pS,cy:hS,rx:1.2722,ry:1.9083,className:G}),t[24]=G,t[25]=K);let q=(F||T)&&`ok-blob-eye-hidden`,ee;t[26]===q?ee=t[27]:(ee=mi(`ok-blob-eye ok-blob-eye-right`,q),t[26]=q,t[27]=ee);let te;t[28]===ee?te=t[29]:(te=(0,Z.jsx)(`ellipse`,{cx:mS,cy:hS,rx:1.2722,ry:1.9083,className:ee}),t[28]=ee,t[29]=te);let ne;t[30]===I?ne=t[31]:(ne=_S(pS,I),t[30]=I,t[31]=ne);let re=(!F||T)&&`ok-blob-eye-hidden`,ie;t[32]===re?ie=t[33]:(ie=mi(`ok-blob-happy-eye`,re),t[32]=re,t[33]=ie);let ae;t[34]!==ne||t[35]!==ie?(ae=(0,Z.jsx)(`path`,{d:ne,strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:ie}),t[34]=ne,t[35]=ie,t[36]=ae):ae=t[36];let oe;t[37]===I?oe=t[38]:(oe=_S(mS,I),t[37]=I,t[38]=oe);let se=(!F||T)&&`ok-blob-eye-hidden`,ce;t[39]===se?ce=t[40]:(ce=mi(`ok-blob-happy-eye`,se),t[39]=se,t[40]=ce);let le;t[41]!==oe||t[42]!==ce?(le=(0,Z.jsx)(`path`,{d:oe,strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:ce}),t[41]=oe,t[42]=ce,t[43]=le):le=t[43];let J;t[44]===T?J=t[45]:(J=T?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`path`,{d:vS(pS),strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:`ok-blob-sleeping-eye`}),(0,Z.jsx)(`path`,{d:vS(mS),strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:`ok-blob-sleeping-eye`})]}):null,t[44]=T,t[45]=J);let ue;t[46]!==K||t[47]!==te||t[48]!==ae||t[49]!==le||t[50]!==J?(ue=(0,Z.jsxs)(`g`,{ref:p,children:[K,te,ae,le,J]}),t[46]=K,t[47]=te,t[48]=ae,t[49]=le,t[50]=J,t[51]=ue):ue=t[51];let de;t[52]!==B||t[53]!==H||t[54]!==ue?(de=(0,Z.jsxs)(`g`,{className:H,children:[U,ue]},B),t[52]=B,t[53]=H,t[54]=ue,t[55]=de):de=t[55];let fe;t[56]===T?fe=t[57]:(fe=T?(0,Z.jsxs)(`g`,{children:[(0,Z.jsx)(`text`,{x:21,y:7,className:`ok-blob-z ok-blob-z-1`,children:`z`}),(0,Z.jsx)(`text`,{x:26,y:2,className:`ok-blob-z ok-blob-z-2`,children:`z`})]}):null,t[56]=T,t[57]=fe);let pe;t[58]!==v||t[59]!==x?(pe=x.length>0&&(0,Z.jsx)(`g`,{children:x.map(CS)},`firework-${v}`),t[58]=v,t[59]=x,t[60]=pe):pe=t[60];let me;t[61]!==D||t[62]!==s||t[63]!==z||t[64]!==de||t[65]!==fe||t[66]!==pe?(me=(0,Z.jsxs)(`svg`,{ref:f,width:s,height:s,viewBox:`0 0 30 30`,fill:`none`,overflow:`visible`,xmlns:`http://www.w3.org/2000/svg`,className:z,"aria-hidden":`true`,onClick:D,onMouseDown:wS,children:[de,fe,pe]}),t[61]=D,t[62]=s,t[63]=z,t[64]=de,t[65]=fe,t[66]=pe,t[67]=me):me=t[67];let he;return t[68]!==R||t[69]!==me?(he=(0,Z.jsx)(`span`,{ref:d,className:R,children:me}),t[68]=R,t[69]=me,t[70]=he):he=t[70],he}function CS(e){return(0,Z.jsx)(`circle`,{cx:yS+e.originDx,cy:bS+e.originDy,r:e.size,className:`ok-blob-firework`,style:xS(e)},e.id)}function wS(e){return e.preventDefault()}function TS(e){return e+1}function ES(e){return e+1}function DS(e){let t=(0,$.c)(12),{title:n,subtitle:r,celebrateSignal:i}=e,a;t[0]===i?a=t[1]:(a=(0,Z.jsx)(SS,{size:64,celebrateSignal:i}),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,Z.jsx)(`h2`,{className:`text-2xl font-light tracking-tighter text-balance`,children:n}),t[2]=n,t[3]=o);let s;t[4]===r?s=t[5]:(s=r?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r}):null,t[4]=r,t[5]=s);let c;t[6]!==o||t[7]!==s?(c=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;return t[9]!==a||t[10]!==c?(l=(0,Z.jsxs)(`div`,{className:`flex items-center gap-4`,children:[a,c]}),t[9]=a,t[10]=c,t[11]=l):l=t[11],l}function OS(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=mi(`pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm bg-muted px-1 font-sans text-xs font-medium text-muted-foreground select-none in-data-[slot=tooltip-content]:bg-background/20 in-data-[slot=tooltip-content]:text-background dark:in-data-[slot=tooltip-content]:bg-background/10 [&_svg:not([class*='size-'])]:size-3`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`kbd`,{"data-slot":`kbd`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function kS(){let e=(0,$.c)(2),t=Dn()?`⌘ K`:`Ctrl K`,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(OS,{children:t}),e[0]=n):n=e[0];let r;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[n,` `,(0,Z.jsx)(`span`,{children:`Search`})]}),e[1]=r):r=e[1],r}var AS=`open-knowledge:create-top-level-file`;function jS(){window.dispatchEvent(new CustomEvent(AS))}function MS(e){let t=()=>e();return window.addEventListener(AS,t),()=>window.removeEventListener(AS,t)}function NS(){let e=(0,$.c)(14),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(void 0),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(0),l=(0,Q.useRef)(!1),u=(0,Q.useRef)(void 0),d,f;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{let e=!1,t=async function(){try{let t=await fetch(`/api/documents`),n=await t.json().catch(LS);if(e)return;let r=t.ok?li.safeParse(n):null;r?.success?(o(RS(r.data.documents)),l.current=!0):l.current||=(o(1),!0)}catch{!e&&!l.current&&(o(1),l.current=!0)}};t();let n=br(e=>{e.includes(`files`)&&t()});return()=>{e=!0,n(),clearTimeout(u.current)}},f=[],e[0]=d,e[1]=f):(d=e[0],f=e[1]),(0,Q.useEffect)(d,f);let p;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=function(){clearTimeout(u.current),u.current=setTimeout(()=>c(IS),500),fetch(`/api/documents`).then(async e=>{let t=await e.json().catch(FS);if(!e.ok)return;let n=li.safeParse(t);n.success&&o(RS(n.data.documents))}).catch(PS)},e[2]=p):p=e[2];let m=p,h=a!==null,g=a===0,_;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=function(e){n(e),e||i(void 0)},e[3]=_):_=e[3];let v=_,y;e[4]!==s||e[5]!==g||e[6]!==h?(y=h?g?(0,Z.jsx)(zS,{celebrateSignal:s,onPackSelect:e=>{i(e),n(!0)}}):(0,Z.jsx)(BS,{celebrateSignal:s,onAddStarterPack:()=>{n(!0)}}):null,e[4]=s,e[5]=g,e[6]=h,e[7]=y):y=e[7];let b;e[8]!==r||e[9]!==t?(b=(0,Z.jsx)(hm,{open:t,onOpenChange:v,onSeedApplied:m,initialPackId:r}),e[8]=r,e[9]=t,e[10]=b):b=e[10];let x;return e[11]!==y||e[12]!==b?(x=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center overflow-y-auto px-6 subtle-scrollbar`,children:[y,b]}),e[11]=y,e[12]=b,e[13]=x):x=e[13],x}function PS(){}function FS(){return null}function IS(e){return e+1}function LS(){return null}function RS(e){return ai(e).filter(e=>e.kind===`document`||e.kind===`folder`).length}function zS(e){let t=(0,$.c)(10),{celebrateSignal:n,onPackSelect:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(DS,{title:`Let's set up your project.`,subtitle:`Pick a starter pack to scaffold folders, templates, and AI-readable rules.`,celebrateSignal:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Z.jsx)(om,{onPackSelect:r}),t[2]=r,t[3]=a);let o;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsxs)(Y,{variant:`link`,className:`text-muted-foreground font-normal justify-end`,size:`sm`,onClick:jS,children:[`or start from scratch `,(0,Z.jsx)(Zi,{"aria-hidden":`true`,className:`size-3`})]}),t[4]=o):o=t[4];let s;t[5]===a?s=t[6]:(s=(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-3`,children:[a,o]}),t[5]=a,t[6]=s);let c;return t[7]!==i||t[8]!==s?(c=(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-10 py-12 max-w-5xl my-auto`,children:[i,s]}),t[7]=i,t[8]=s,t[9]=c):c=t[9],c}function BS(e){let t=(0,$.c)(12),{celebrateSignal:n,onAddStarterPack:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(DS,{title:`Open in your favorite AI editor.`,subtitle:`Select a file from the sidebar, or pick where to edit alongside your agent.`,celebrateSignal:n}),t[0]=n,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Zx,{}),t[2]=a):a=t[2];let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(ce,{"aria-hidden":`true`,className:`size-3`}),t[3]=o):o=t[3];let s;t[4]===r?s=t[5]:(s=(0,Z.jsxs)(Y,{onClick:r,variant:`link`,size:`xs`,className:`font-mono text-2xs uppercase tracking-wider text-muted-foreground font-normal hover:text-foreground hover:no-underline`,children:[o,`Add a starter pack`]}),t[4]=r,t[5]=s);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(kS,{}),t[6]=c):c=t[6];let l;t[7]===s?l=t[8]:(l=(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[a,(0,Z.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-4`,children:[s,c]})]}),t[7]=s,t[8]=l);let u;return t[9]!==i||t[10]!==l?(u=(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-10 py-12 max-w-5xl my-auto`,children:[i,l]}),t[9]=i,t[10]=l,t[11]=u):u=t[11],u}function VS(e){let t=(0,$.c)(74),{folderPath:n,state:r,onChange:i}=e,[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null);if(r.status===`idle`||r.status===`loading`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`section`,{className:`rounded-lg border bg-card p-4 space-y-3`,children:[(0,Z.jsx)(US,{}),(0,Z.jsx)(Ma,{className:`h-7 w-full`}),(0,Z.jsx)(Ma,{className:`h-7 w-full`}),(0,Z.jsx)(Ma,{className:`h-7 w-full`})]}),t[0]=e):e=t[0],e}if(r.status===`error`){let e;return t[1]===r.message?e=t[2]:(e=(0,Z.jsxs)(`section`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive`,role:`alert`,children:[`Failed to load folder defaults: `,r.message]}),t[1]=r.message,t[2]=e),e}let d;t[3]===r.data.folder.frontmatter_defaults?d=t[4]:(d=r.data.folder.frontmatter_defaults??{},t[3]=r.data.folder.frontmatter_defaults,t[4]=d);let f=d,p;t[5]===r.data.frontmatterLocal?p=t[6]:(p=r.data.frontmatterLocal??{},t[5]=r.data.frontmatterLocal,t[6]=p);let m=p,h=r.data.frontmatterSources,g;t[7]===r.data.folder.path?g=t[8]:(g=uo(r.data.folder.path),t[7]=r.data.folder.path,t[8]=g);let _=g,v,y,b,x,S,C,w,T,E,D,O,k,A;if(t[9]!==s||t[10]!==a||t[11]!==_||t[12]!==n||t[13]!==m||t[14]!==f||t[15]!==i||t[16]!==l||t[17]!==h){let e=Object.keys(f),r=async function(e,t){let r=await co(n,{[e]:t});if(!r.ok){X.error(`Save failed: ${r.error}`);return}i()},d=async function(e){let t=await co(n,{[e]:null});if(!t.ok){X.error(`Remove failed: ${t.error}`);return}i()},p=function(e,t){let n=f[e];r(e,Ji(n,t))},g;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(g=function(){c({name:``,type:`text`,value:``,error:null}),o(!1)},t[31]=g):g=t[31],b=g;let j;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(j=function(e){c(t=>{if(!t)return t;let n=e===`date`?new Date().toISOString().slice(0,10):ha[e];return{...t,type:e,value:n,error:null}})},t[32]=j):j=t[32],S=j;let M;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(M=function(e){c(t=>t&&{...t,value:e})},t[33]=M):M=t[33],C=M;let N;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(N=function(e){c(t=>t&&{...t,name:e,error:null})},t[34]=N):N=t[34],x=N;let P;t[35]!==s||t[36]!==n||t[37]!==f||t[38]!==i?(P=async function(){if(!s)return;let e=s.name.trim();if(!e){c({...s,error:`Name is required`});return}if(Object.hasOwn(f,e)){c({...s,error:`Key "${e}" already resolves here`});return}let t=await co(n,{[e]:s.value});if(!t.ok){c({...s,error:t.error});return}c(null),i()},t[35]=s,t[36]=n,t[37]=f,t[38]=i,t[39]=P):P=t[39],w=P;let F=function(e){u({key:e,draft:e,error:null})},I=function(e){u(t=>t&&{...t,draft:e,error:null})},L=async function(){if(!l)return;let e=l.draft.trim();if(!e){u({...l,error:`Name is required`});return}if(e===l.key){u(null);return}if(Object.hasOwn(f,e)){u({...l,error:`Key "${e}" already resolves here`});return}let t=f[l.key],r=await co(n,{[l.key]:null,[e]:t});if(!r.ok){u({...l,error:r.error});return}u(null),i()},R=function(){u(null)};A=`rounded-lg border bg-card`,y=Lo,D=!a,t[40]===Symbol.for(`react.memo_cache_sentinel`)?(O=e=>o(!e),t[40]=O):O=t[40];let z=`size-3 transition-transform ${a?``:`rotate-90`}`,B;t[41]===z?B=t[42]:(B=(0,Z.jsx)(No,{className:z,"aria-hidden":!0}),t[41]=z,t[42]=B);let V;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsx)(`span`,{children:`Folder defaults`}),t[43]=V):V=t[43];let H;t[44]===B?H=t[45]:(H=(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase font-mono tracking-wider text-muted-foreground`,children:[B,V]}),t[44]=B,t[45]=H);let U;t[46]===_?U=t[47]:(U=(0,Z.jsx)(`code`,{className:`text-xs text-muted-foreground font-mono cursor-text select-text`,onClick:HS,children:_}),t[46]=_,t[47]=U),t[48]!==H||t[49]!==U?(k=(0,Z.jsxs)(Io,{className:`flex w-full cursor-pointer items-center justify-between gap-2 px-3 py-2.5 data-[state=open]:border-b border-border`,children:[H,U]}),t[48]=H,t[49]=U,t[50]=k):k=t[50],v=Fo,T=`px-2 py-2`,E=e.length===0&&!s?(0,Z.jsx)(`p`,{className:`px-1 py-1 text-sm text-muted-foreground`,children:`No defaults declared. Add a property to set a value every doc in this folder inherits.`}):e.map(e=>{let t=f[e],n=Object.hasOwn(m,e);return(0,Z.jsx)(Wi,{keyName:e,value:t,declared:Ki(t,tr(t)),rename:n?{state:l?.key===e?l:null,onBegin:()=>F(e),onChangeDraft:I,onCommit:L,onCancel:R}:void 0,badge:n?null:(0,Z.jsx)(oo,{source:h[e]??``}),isInherited:!n,onCommit:t=>void r(e,t),onChangeType:t=>p(e,t),onRemove:n?()=>void d(e):void 0},e)}),t[9]=s,t[10]=a,t[11]=_,t[12]=n,t[13]=m,t[14]=f,t[15]=i,t[16]=l,t[17]=h,t[18]=v,t[19]=y,t[20]=b,t[21]=x,t[22]=S,t[23]=C,t[24]=w,t[25]=T,t[26]=E,t[27]=D,t[28]=O,t[29]=k,t[30]=A}else v=t[18],y=t[19],b=t[20],x=t[21],S=t[22],C=t[23],w=t[24],T=t[25],E=t[26],D=t[27],O=t[28],k=t[29],A=t[30];let j;t[51]!==s||t[52]!==b||t[53]!==x||t[54]!==S||t[55]!==C||t[56]!==w?(j=s?(0,Z.jsx)(pa,{draft:s,onChangeName:x,onChangeType:S,onChangeValue:C,onCommit:()=>void w(),onCancel:()=>c(null)}):(0,Z.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`add-property-trigger`,onClick:b,className:`mt-1 flex items-center gap-1.5 rounded px-2 py-1 font-medium text-sm hover:bg-muted/50 hover:text-foreground`,children:[(0,Z.jsx)(ce,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:`Add property`})]}),t[51]=s,t[52]=b,t[53]=x,t[54]=S,t[55]=C,t[56]=w,t[57]=j):j=t[57];let M;t[58]!==j||t[59]!==T||t[60]!==E?(M=(0,Z.jsxs)(`div`,{className:T,children:[E,j]}),t[58]=j,t[59]=T,t[60]=E,t[61]=M):M=t[61];let N;t[62]!==v||t[63]!==M?(N=(0,Z.jsx)(v,{children:M}),t[62]=v,t[63]=M,t[64]=N):N=t[64];let P;t[65]!==y||t[66]!==N||t[67]!==D||t[68]!==O||t[69]!==k?(P=(0,Z.jsxs)(y,{open:D,onOpenChange:O,children:[k,N]}),t[65]=y,t[66]=N,t[67]=D,t[68]=O,t[69]=k,t[70]=P):P=t[70];let F;return t[71]!==P||t[72]!==A?(F=(0,Z.jsx)(`section`,{className:A,children:P}),t[71]=P,t[72]=A,t[73]=F):F=t[73],F}function HS(e){return e.stopPropagation()}function US(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(lc,{className:`size-4 text-muted-foreground`,"aria-hidden":!0}),(0,Z.jsx)(`h2`,{className:`text-xs font-semibold uppercase font-mono tracking-wider text-muted-foreground`,children:`Folder defaults`})]}),e[0]=t):t=e[0],t}function WS(e){let t=e.split(`/`).pop();return t?`${e}/${t}`:null}function GS(e,t){let n=t.get(`${e}/index`);if(n)return n;let r=WS(e);if(r){let e=t.get(r);if(e)return e}return e.split(`/`).pop()??e}function KS(e,t,n){let r=n.get(e);return r&&r!==e?r:t}function qS(e,t){let n=`${e}/`,r=[...t.folderPaths].filter(e=>e.startsWith(n)).map(e=>({path:e,rel:e.slice(n.length)})).filter(e=>e.rel.length>0&&!e.rel.includes(`/`)).map(({path:e,rel:n})=>({kind:`folder`,path:e,name:n,title:GS(e,t.pageTitles)})),i=[...t.pages].filter(e=>e.startsWith(n)).map(e=>({docName:e,rel:e.slice(n.length)})).filter(e=>e.rel.length>0&&!e.rel.includes(`/`)).map(({docName:e,rel:n})=>{let r=t.pageMeta.get(e);return{kind:`file`,path:e,name:n,title:KS(e,n,t.pageTitles),size:r?.size??0,modified:r?.modified??``}}),a=[...r,...i].sort((e,t)=>e.kind===t.kind?e.title.localeCompare(t.title)||e.name.localeCompare(t.name):e.kind===`folder`?-1:1);return{title:GS(e,t.pageTitles),children:a}}function JS(e){let t=(0,$.c)(52),{folderPath:n,state:r,onChange:i,folderConfigHandle:a}=e,[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!1),g;t[0]===i?g=t[1]:(g=async function(e){p(!0);let t=await Da(e.source_folder,e.name);if(p(!1),!t.ok){X.error(`Delete failed: ${t.error}`);return}X.success(`Template "${e.name}" deleted`),l(null),i()},t[0]=i,t[1]=g);let _=g;if(r.status===`idle`||r.status===`loading`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`section`,{className:`rounded-lg border bg-card px-3 py-2.5 space-y-3`,children:[(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(`h2`,{className:`text-xs font-semibold uppercase font-mono tracking-wider text-muted-foreground`,children:`Templates available`})}),(0,Z.jsx)(Ma,{className:`h-12 w-full`}),(0,Z.jsx)(Ma,{className:`h-12 w-full`})]}),t[2]=e):e=t[2],e}if(r.status===`error`){let e;return t[3]===r.message?e=t[4]:(e=(0,Z.jsxs)(`section`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive`,role:`alert`,children:[`Failed to load templates: `,r.message]}),t[3]=r.message,t[4]=e),e}let v;t[5]===r.data.folder.templates_available?v=t[6]:(v=r.data.folder.templates_available??[],t[5]=r.data.folder.templates_available,t[6]=v);let y=v,b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(`h2`,{className:`text-xs font-semibold uppercase font-mono tracking-wider text-muted-foreground`,children:`Templates available`}),t[7]=b):b=t[7];let x;t[8]===y.length?x=t[9]:(x=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b,(0,Z.jsx)(Ge,{className:`text-xs`,variant:`secondary`,children:y.length})]}),t[8]=y.length,t[9]=x);let S;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsxs)(Y,{variant:`ghost`,className:`font-mono uppercase`,size:`sm`,onClick:()=>h(!0),children:[(0,Z.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0}),`New template`]}),t[10]=S):S=t[10];let C;t[11]===x?C=t[12]:(C=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-1`,children:[x,S]}),t[11]=x,t[12]=C);let w;t[13]===y?w=t[14]:(w=(0,Z.jsx)(`div`,{className:`px-3 py-2.5`,children:y.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No templates resolve here. Add one to seed new docs in this folder.`}):(0,Z.jsx)(`ul`,{className:`space-y-1`,children:y.map(e=>(0,Z.jsx)(XS,{template:e,onCreate:()=>d(e.name),onEdit:()=>s(e),onDelete:()=>l(e)},e.path))})}),t[13]=y,t[14]=w);let T;t[15]!==C||t[16]!==w?(T=(0,Z.jsxs)(`section`,{className:`rounded-lg border bg-card`,children:[C,w]}),t[15]=C,t[16]=w,t[17]=T):T=t[17];let E;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>{e||s(null)},t[18]=E):E=t[18];let D;t[19]!==o||t[20]!==n||t[21]!==i?(D=(0,Z.jsx)(Na,{folderPath:n,template:o,onOpenChange:E,onSaved:i}),t[19]=o,t[20]=n,t[21]=i,t[22]=D):D=t[22];let O=!!c,k;t[23]===f?k=t[24]:(k=e=>{!e&&!f&&l(null)},t[23]=f,t[24]=k);let A;t[25]!==c||t[26]!==f||t[27]!==_?(A=c&&(0,Z.jsx)(io,{itemName:`template "${c.name}"`,isSubmitting:f,onDelete:()=>_(c),customDescription:`This permanently removes ${c.path}. Agents that reference this template by name will fail until it's recreated or shadowed by an ancestor.${c.scope===`inherited`?`
|
|
27
|
+
`);return t?n.pop():n.push(n.pop().slice(0,-1)),n}function Zv(e,t){return`${e}\u0000${t}`}function Qv(e,t,n){let r=Cr(e).body,i=Cr(t).body;return r===i?``:Yv(n,r,i,``,``,{context:3})}function $v(e,t,n){let r=(0,$.c)(8),{activeProvider:i}=ot(),a;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={status:`idle`,diff:null},r[0]=a):a=r[0];let[o,s]=(0,Q.useState)(a),c=(0,Q.useRef)(i),l;r[1]===i?l=r[2]:(l=()=>{c.current=i},r[1]=i,r[2]=l),(0,Q.useEffect)(l);let u,d;return r[3]!==n||r[4]!==t||r[5]!==e?(u=()=>{if(!e){s({status:`idle`,diff:null});return}let r=e,i=!1;return s({status:`loading`,diff:null}),(async function(){try{let e=Zv(t,r),a=n.get(e);if(a===void 0){let o=await fetch(`/api/history/${r}?docName=${encodeURIComponent(t)}`);if(i)return;if(!o.ok){s({status:`error`,diff:null});return}let c=await o.json();if(i)return;a=c.content??``,n.set(e,a)}if(i)return;let o=c.current?.document.getText(`source`).toString()??``,l=Qv(a,o,t);if(i)return;s({status:`ready`,diff:l})}catch(e){i||(console.error(`[timeline-diff] failed to load entry diff`,{sha:r,docName:t,err:e}),s({status:`error`,diff:null}))}})(),()=>{i=!0}},d=[e,t,n],r[3]=n,r[4]=t,r[5]=e,r[6]=u,r[7]=d):(u=r[6],d=r[7]),(0,Q.useEffect)(u,d),o}var ey=(0,Q.lazy)(async()=>({default:(await n(()=>import(`./ActivityPanelDiffView-d4ec9M69.js`),__vite__mapDeps([16,1,7,17]),import.meta.url)).ActivityPanelDiffView}));function ty(e){let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/1e3);if(r<60)return`just now`;if(r<3600)return`${Math.floor(r/60)} min ago`;if(r<86400)return`${Math.floor(r/3600)}h ago`;if(r<86400*2)return`yesterday`;let i=Math.floor(r/86400);return i<7?`${i} days ago`:t.toLocaleDateString()}function ny(e){return new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function ry(e){return e.slice(0,7)}function iy(e){return e.type===`upstream`?`Upstream sync`:e.contributors.length===1?e.contributors[0].name:e.contributors.length>1?e.contributors.map(e=>e.name).join(`, `):e.author===`openknowledge-server`||e.author===`server`?`Auto-save`:e.author}function ay(e){let t=(0,$.c)(17),n,r;if(t[0]===e?(n=t[1],r=t[2]):({icon:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),n===`claude`){let e;return t[3]===r?e=t[4]:(e=(0,Z.jsx)(Oi,{...r}),t[3]=r,t[4]=e),e}if(n===`cursor`){let e;return t[5]===r?e=t[6]:(e=(0,Z.jsx)(Pi,{...r}),t[5]=r,t[6]=e),e}if(n===`windsurf`){let e;return t[7]===r?e=t[8]:(e=(0,Z.jsx)(Ei,{...r}),t[7]=r,t[8]=e),e}if(n===`openai`){let e;return t[9]===r?e=t[10]:(e=(0,Z.jsx)(ji,{...r}),t[9]=r,t[10]=e),e}if(n===`cline`){let e;return t[11]===r?e=t[12]:(e=(0,Z.jsx)(zi,{...r}),t[11]=r,t[12]=e),e}if(n===`github`){let e;return t[13]===r?e=t[14]:(e=(0,Z.jsx)(Li,{...r}),t[13]=r,t[14]=e),e}let i=r,a;return t[15]===i?a=t[16]:(a=(0,Z.jsx)(Fi,{strokeWidth:1.5,...i}),t[15]=i,t[16]=a),a}function oy(e){let t=(0,$.c)(17),{entry:n,isDark:r}=e;if(n.type===`upstream`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(k,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[0]=e):e=t[0],e}if(n.contributors.length>0){let e=n.contributors[0],i=e.colorSeed??e.name,a;t[1]===i?a=t[2]:(a=Vn(i),t[1]=i,t[2]=a);let o=a,s=r?nr[o]??On[o]:On[o],c;t[3]!==s||t[4]!==i?(c=s??xr(i),t[3]=s,t[4]=i,t[5]=c):c=t[5];let l=c;if(o!==`bot`){let e;t[6]===l?e=t[7]:(e={color:l},t[6]=l,t[7]=e);let n;return t[8]!==o||t[9]!==e?(n=(0,Z.jsx)(ay,{icon:o,width:14,height:14,className:`shrink-0`,style:e}),t[8]=o,t[9]=e,t[10]=n):n=t[10],n}if(e.name===`File System`){let e;return t[11]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(pc,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[11]=e):e=t[11],e}if(e.name===`Open Knowledge (service)`||e.name===`Git (upstream)`){let e;return t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Rs,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[12]=e):e=t[12],e}let u;return t[13]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(el,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[13]=u):u=t[13],u}if(n.authorEmail.includes(`agent`)||n.author.includes(`agent`)||n.authorEmail.includes(`cursor`)||n.authorEmail.includes(`claude`)){let e;return t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Fi,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[14]=e):e=t[14],e}if(n.author===`openknowledge-server`||n.author===`server`){let e;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Rs,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[15]=e):e=t[15],e}let i;return t[16]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(el,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[16]=i):i=t[16],i}function sy(e){let t=(0,$.c)(20),{entries:n,defaultExpanded:r,isDark:i,diffLayout:a,cache:o,docName:s,expandedShas:c,onToggleExpanded:l,onRestoreSuccess:u}=e,[d,f]=(0,Q.useState)(r);if(n.length===0)return null;let p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>f(cy),t[0]=p):p=t[0];let m;t[1]===d?m=t[2]:(m=d?(0,Z.jsx)(mt,{className:`size-3`}):(0,Z.jsx)(No,{className:`size-3`}),t[1]=d,t[2]=m);let h=d?`Hide ${n.length} auto-save${n.length>1?`s`:``}`:`Show ${n.length} auto-save${n.length>1?`s`:``}`,g;t[3]!==d||t[4]!==m||t[5]!==h?(g=(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":d,className:`flex items-center gap-1.5 rounded-lg px-3 py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/80 transition-colors text-left`,onClick:p,children:[m,h]}),t[3]=d,t[4]=m,t[5]=h,t[6]=g):g=t[6];let _;t[7]!==o||t[8]!==a||t[9]!==s||t[10]!==n||t[11]!==d||t[12]!==c||t[13]!==i||t[14]!==u||t[15]!==l?(_=d&&n.map(e=>(0,Z.jsx)(Sy,{entry:e,isDark:i,diffLayout:a,cache:o,docName:s,expanded:c.has(e.sha),onToggleExpanded:l,onRestoreSuccess:u},e.sha)),t[7]=o,t[8]=a,t[9]=s,t[10]=n,t[11]=d,t[12]=c,t[13]=i,t[14]=u,t[15]=l,t[16]=_):_=t[16];let v;return t[17]!==g||t[18]!==_?(v=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19],v}function cy(e){return!e}function ly(e){return e.checkpoint?e.checkpoint.kind:`save`}function uy(e){let t=ly(e);if(t===`save`)return`Save Version`;let n=e.checkpoint?.size??null,r=n!=null&&n>0?` (${dy(n)})`:``;return t===`bridge-merge-loss`?`Auto-saved before a concurrent edit${r}`:`Recovered from an external change${r}`}function dy(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/102.4)/10} KB`:`${Math.round(e/104857.6)/10} MB`}function fy(e){return e.type===`checkpoint`?ly(e)===`save`?`version`:`auto-save`:`wip`}var py={version:`Restore this version`,"auto-save":`Restore this auto-save`,wip:`Restore to this point`},my={version:`Restore this version?`,"auto-save":`Restore this auto-save?`,wip:`Restore to this point?`};function hy(e){return py[fy(e)]}function gy(e){return my[fy(e)]}function _y(e){let t=[];for(let n of e.contributors)if(n.summaries)for(let e of n.summaries)t.push(e);return t}function vy(e){let t=(0,$.c)(20),{summaries:n}=e,[r,i]=(0,Q.useState)(!1),a=(0,Q.useId)();if(n.length===0)return null;let o,s;t[0]===n?(o=t[1],s=t[2]):([o,...s]=n,t[0]=n,t[1]=o,t[2]=s);let c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:`• `}),t[3]=c):c=t[3];let l;t[4]===o?l=t[5]:(l=(0,Z.jsxs)(`li`,{className:`text-xs text-foreground/90`,children:[c,o]}),t[4]=o,t[5]=l);let u;t[6]!==r||t[7]!==s?(u=r&&s.map(by),t[6]=r,t[7]=s,t[8]=u):u=t[8];let d;t[9]!==a||t[10]!==l||t[11]!==u?(d=(0,Z.jsxs)(`ul`,{id:a,className:`list-none`,children:[l,u]}),t[9]=a,t[10]=l,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==r||t[14]!==a||t[15]!==s.length?(f=s.length>0&&(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":r,"aria-controls":a,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,onClick:e=>{e.stopPropagation(),i(yy)},children:[r?(0,Z.jsx)(mt,{className:`size-3`}):(0,Z.jsx)(No,{className:`size-3`}),r?`Hide`:`Show ${s.length} more`]}),t[13]=r,t[14]=a,t[15]=s.length,t[16]=f):f=t[16];let p;return t[17]!==d||t[18]!==f?(p=(0,Z.jsxs)(`div`,{className:`mt-0.5`,children:[d,f]}),t[17]=d,t[18]=f,t[19]=p):p=t[19],p}function yy(e){return!e}function by(e,t){return(0,Z.jsxs)(`li`,{className:`text-xs text-foreground/90`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:`• `}),e]},`${t}-${e}`)}function xy(e){let t=(0,$.c)(13),{sha:n,docName:r,cache:i,diffLayout:a,panelId:o}=e,s=$v(n,r,i),c;t[0]===s.status?c=t[1]:(c=s.status===`loading`&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(ue,{className:`size-3 animate-spin`}),`Loading diff`]}),t[0]=s.status,t[1]=c);let l;t[2]===s.status?l=t[3]:(l=s.status===`error`&&(0,Z.jsx)(`p`,{className:`py-2 text-xs text-destructive`,children:`Diff unavailable`}),t[2]=s.status,t[3]=l);let u;t[4]!==a||t[5]!==s.diff||t[6]!==s.status?(u=s.status===`ready`&&(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(ue,{className:`size-3 animate-spin`}),`Loading diff renderer`]}),children:(0,Z.jsx)(ey,{diff:s.diff,viewType:a})}),t[4]=a,t[5]=s.diff,t[6]=s.status,t[7]=u):u=t[7];let d;return t[8]!==o||t[9]!==c||t[10]!==l||t[11]!==u?(d=(0,Z.jsxs)(`div`,{id:o,className:`px-3 pb-2`,"data-testid":`timeline-entry-diff`,children:[c,l,u]}),t[8]=o,t[9]=c,t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function Sy(e){let t=(0,$.c)(128),{entry:n,prominent:r,isDark:i,diffLayout:a,cache:o,docName:s,expanded:c,onToggleExpanded:l,onRestoreSuccess:u}=e,d=r===void 0?!1:r,f;t[0]===n.timestamp?f=t[1]:(f=ty(n.timestamp),t[0]=n.timestamp,t[1]=f);let p=f,m;t[2]===n?m=t[3]:(m=iy(n),t[2]=n,t[3]=m);let h=m,g=n.contributors.flatMap(Cy),_;t[4]===n?_=t[5]:(_=_y(n),t[4]=n,t[5]=_);let v=_,[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),C=(0,Q.useRef)(null),w=(0,Q.useId)(),T,E;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>()=>C.current?.abort(),E=[],t[6]=T,t[7]=E):(T=t[6],E=t[7]),(0,Q.useEffect)(T,E);let D;t[8]!==n.sha||t[9]!==l?(D=()=>l(n.sha),t[8]=n.sha,t[9]=l,t[10]=D):D=t[10];let O=D,k;t[11]===b?k=t[12]:(k=function(){C.current?.abort(),C.current=null,S(!1),b(!1)},t[11]=b,t[12]=k);let A=k,j;t[13]!==s||t[14]!==n.sha||t[15]!==u||t[16]!==b?(j=async function(){S(!0);let e=new AbortController;C.current=e;let t=function(){e.signal.aborted||S(!1),C.current===e&&(C.current=null)},r;try{r=await fetch(`/api/rollback`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({docName:s,commitSha:n.sha}),signal:e.signal})}catch(r){let i=r;!e.signal.aborted&&!(i instanceof DOMException&&i.name===`AbortError`)&&(console.error(`[timeline] rollback fetch failed`,{docName:s,sha:n.sha,err:i}),X.error(`Restore failed — document unchanged`,{duration:4e3})),t();return}if(e.signal.aborted){t();return}if(r.ok)b(!1),u();else{let e=`HTTP ${r.status}`;try{let t=fi.safeParse(await r.json());t.success&&(e=t.data.title)}catch{}console.error(`[timeline] rollback failed`,{docName:s,sha:n.sha,status:r.status,detail:e}),X.error(`Restore failed`,{description:e,duration:6e3})}t()},t[13]=s,t[14]=n.sha,t[15]=u,t[16]=b,t[17]=j):j=t[17];let M=j,N;t[18]!==n||t[19]!==i||t[20]!==d?(N=d?(()=>{let e=ly(n);return e===`bridge-merge-loss`?(0,Z.jsx)(dr,{className:`size-3.5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":`true`}):e===`external-change-rescue`?(0,Z.jsx)(ic,{className:`size-3.5 shrink-0 text-sky-600 dark:text-sky-400`,"aria-hidden":`true`}):(0,Z.jsx)(nc,{className:`size-3.5 shrink-0 text-muted-foreground`})})():(0,Z.jsx)(oy,{entry:n,isDark:i}),t[18]=n,t[19]=i,t[20]=d,t[21]=N):N=t[21];let P=N,F=c?w:void 0,I=c?`bg-muted`:`hover:bg-muted/80`,L;t[22]===I?L=t[23]:(L=[`group flex w-full items-start gap-2.5 rounded-lg px-3 py-2.5 text-left transition-colors cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-ring`,I],t[22]=I,t[23]=L);let R=L.join(` `),z;t[24]===O?z=t[25]:(z=e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),O())},t[24]=O,t[25]=z);let B;t[26]===P?B=t[27]:(B=(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:P}),t[26]=P,t[27]=B);let V;t[28]!==h||t[29]!==n||t[30]!==d?(V=d?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-xs text-foreground truncate`,children:uy(n)}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground/50`,children:`·`}),(0,Z.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:h})]}):(0,Z.jsx)(`span`,{className:`truncate text-xs text-foreground`,children:h}),t[28]=h,t[29]=n,t[30]=d,t[31]=V):V=t[31];let H;t[32]!==n.timestamp||t[33]!==p?(H=(0,Z.jsx)(`time`,{className:`ml-auto shrink-0 text-xs text-muted-foreground/80`,dateTime:n.timestamp,title:n.timestamp,children:p}),t[32]=n.timestamp,t[33]=p,t[34]=H):H=t[34];let U;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px shrink-0 bg-border`}),t[35]=U):U=t[35];let W;t[36]===n?W=t[37]:(W=hy(n),t[36]=n,t[37]=W);let G;t[38]===b?G=t[39]:(G=e=>{e.stopPropagation(),b(!0)},t[38]=b,t[39]=G);let K;t[40]===x?K=t[41]:(K=x?(0,Z.jsx)(ue,{className:`size-3 animate-spin`}):(0,Z.jsx)(ki,{className:`size-3`}),t[40]=x,t[41]=K);let q;t[42]!==x||t[43]!==W||t[44]!==G||t[45]!==K?(q=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon`,className:`size-5 shrink-0 text-muted-foreground hover:text-destructive`,"data-testid":`timeline-entry-restore`,"aria-label":W,disabled:x,onClick:G,children:K})}),t[42]=x,t[43]=W,t[44]=G,t[45]=K,t[46]=q):q=t[46];let ee;t[47]===n?ee=t[48]:(ee=hy(n),t[47]=n,t[48]=ee);let te;t[49]===ee?te=t[50]:(te=(0,Z.jsx)(vn,{side:`top`,children:ee}),t[49]=ee,t[50]=te);let ne;t[51]!==q||t[52]!==te?(ne=(0,Z.jsxs)(yn,{children:[q,te]}),t[51]=q,t[52]=te,t[53]=ne):ne=t[53];let re;t[54]!==V||t[55]!==H||t[56]!==ne?(re=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[V,H,U,ne]}),t[54]=V,t[55]=H,t[56]=ne,t[57]=re):re=t[57];let ie;t[58]===v?ie=t[59]:(ie=v.length>0&&(0,Z.jsx)(vy,{summaries:v}),t[58]=v,t[59]=ie);let ae=g.length>0?(0,Z.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,title:g.join(`, `),children:g.join(`, `)}):(0,Z.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,title:n.message,children:n.message}),oe;t[60]!==re||t[61]!==ie||t[62]!==ae?(oe=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[re,ie,ae]}),t[60]=re,t[61]=ie,t[62]=ae,t[63]=oe):oe=t[63];let se;t[64]!==c||t[65]!==O||t[66]!==F||t[67]!==R||t[68]!==z||t[69]!==B||t[70]!==oe?(se=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":c,"aria-controls":F,"data-testid":`timeline-entry-expand`,className:R,onClick:O,onKeyDown:z,children:[B,oe]}),t[64]=c,t[65]=O,t[66]=F,t[67]=R,t[68]=z,t[69]=B,t[70]=oe,t[71]=se):se=t[71];let ce;t[72]!==o||t[73]!==a||t[74]!==w||t[75]!==s||t[76]!==n.sha||t[77]!==c?(ce=c&&(0,Z.jsx)(xy,{sha:n.sha,docName:s,cache:o,diffLayout:a,panelId:w}),t[72]=o,t[73]=a,t[74]=w,t[75]=s,t[76]=n.sha,t[77]=c,t[78]=ce):ce=t[78];let le;t[79]!==se||t[80]!==ce?(le=(0,Z.jsxs)(`div`,{className:`flex flex-col rounded-lg`,children:[se,ce]}),t[79]=se,t[80]=ce,t[81]=le):le=t[81];let J;t[82]!==A||t[83]!==b?(J=e=>{e?b(!0):A()},t[82]=A,t[83]=b,t[84]=J):J=t[84];let de;t[85]===n?de=t[86]:(de=gy(n),t[85]=n,t[86]=de);let fe;t[87]===de?fe=t[88]:(fe=(0,Z.jsx)(bo,{children:de}),t[87]=de,t[88]=fe);let pe;t[89]===n.timestamp?pe=t[90]:(pe=ny(n.timestamp),t[89]=n.timestamp,t[90]=pe);let me;t[91]===n.sha?me=t[92]:(me=ry(n.sha),t[91]=n.sha,t[92]=me);let he;t[93]!==p||t[94]!==pe||t[95]!==me?(he=(0,Z.jsxs)(`span`,{className:`font-medium text-foreground`,children:[p,` (`,pe,`, `,me,`)`]}),t[93]=p,t[94]=pe,t[95]=me,t[96]=he):he=t[96];let ge;t[97]===h?ge=t[98]:(ge=(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:h}),t[97]=h,t[98]=ge);let _e;t[99]!==he||t[100]!==ge?(_e=(0,Z.jsxs)(vo,{children:[`This will replace the current document content with the version from`,` `,he,` `,`by `,ge,`. Your current content is already saved in the timeline — you can restore it anytime.`]}),t[99]=he,t[100]=ge,t[101]=_e):_e=t[101];let ve;t[102]!==fe||t[103]!==_e?(ve=(0,Z.jsxs)(Ao,{children:[fe,_e]}),t[102]=fe,t[103]=_e,t[104]=ve):ve=t[104];let ye;t[105]===A?ye=t[106]:(ye=(0,Z.jsx)(Y,{variant:`outline`,"data-testid":`timeline-entry-restore-cancel`,onClick:A,children:`Cancel`}),t[105]=A,t[106]=ye);let be;t[107]===M?be=t[108]:(be=()=>M(),t[107]=M,t[108]=be);let xe;t[109]===x?xe=t[110]:(xe=x?(0,Z.jsx)(ue,{className:`mr-2 size-4 animate-spin`}):null,t[109]=x,t[110]=xe);let Se;t[111]!==x||t[112]!==be||t[113]!==xe?(Se=(0,Z.jsxs)(Y,{variant:`destructive`,"data-testid":`timeline-entry-restore-confirm`,disabled:x,onClick:be,children:[xe,`Restore`]}),t[111]=x,t[112]=be,t[113]=xe,t[114]=Se):Se=t[114];let Ce;t[115]!==ye||t[116]!==Se?(Ce=(0,Z.jsxs)(Oo,{children:[ye,Se]}),t[115]=ye,t[116]=Se,t[117]=Ce):Ce=t[117];let we;t[118]!==ve||t[119]!==Ce?(we=(0,Z.jsxs)(wo,{children:[ve,Ce]}),t[118]=ve,t[119]=Ce,t[120]=we):we=t[120];let Te;t[121]!==y||t[122]!==J||t[123]!==we?(Te=(0,Z.jsx)(jo,{open:y,onOpenChange:J,children:we}),t[121]=y,t[122]=J,t[123]=we,t[124]=Te):Te=t[124];let Ee;return t[125]!==le||t[126]!==Te?(Ee=(0,Z.jsxs)(Z.Fragment,{children:[le,Te]}),t[125]=le,t[126]=Te,t[127]=Ee):Ee=t[127],Ee}function Cy(e){return e.docs}function wy(e){let t=(0,$.c)(63),{docName:n,diffLayout:r,onDiffLayoutChange:i}=e,{resolvedTheme:a}=vr(),o=a===`dark`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[0]=s):s=t[0];let[c,l]=(0,Q.useState)(s),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(null),m=(0,Q.useRef)(null),[h]=(0,Q.useState)(Oy),[g,_]=(0,Q.useState)(Dy),v;t[1]===h?v=t[2]:(v=()=>{_(new Set),h.clear()},t[1]=h,t[2]=v);let y;t[3]===n?y=t[4]:(y=[n],t[3]=n,t[4]=y),(0,Q.useEffect)(v,y);let b;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(b=function(e){_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[5]=b):b=t[5];let x=b,S;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(S=function(){_(new Set)},t[6]=S):S=t[6];let C=S,w,T;t[7]===n?(w=t[8],T=t[9]):(w=()=>{if(!n){l([]);return}let e=!1,t=async function(){if(n)try{let t=await fetch(`/api/history?docName=${encodeURIComponent(n)}&limit=100`);if(e)return;if(!t.ok){p(`History unavailable`);return}let r=await t.json();if(e)return;l(r.entries??[]),p(null)}catch(t){let n=t;if(e)return;p(`History unavailable`),console.error(`[timeline]`,n)}};return d(!0),t().finally(()=>{e||d(!1)}),m.current=setInterval(t,1e4),()=>{e=!0,m.current&&clearInterval(m.current)}},T=[n],t[7]=n,t[8]=w,t[9]=T),(0,Q.useEffect)(w,T);let E,D,O,k,A,j,M,N;if(t[10]!==h||t[11]!==r||t[12]!==n||t[13]!==c||t[14]!==f||t[15]!==g||t[16]!==o||t[17]!==u||t[18]!==i){let e=[],a=[],s=!1;for(let t of c)t.type===`checkpoint`?(a.length>0&&(e.push({kind:`wip-group`,entries:a,isPreCheckpoint:!s}),a=[]),e.push({kind:`checkpoint`,entry:t}),s=!0):a.push(t);a.length>0&&e.push({kind:`wip-group`,entries:a,isPreCheckpoint:!s});let l;t[27]===c?l=t[28]:(l=c.some(Ey),t[27]=c,t[28]=l);let d=!l,p=!u&&!f&&c.length>0;A=`flex h-full flex-col`,t[29]!==r||t[30]!==p||t[31]!==i?(j=p&&(0,Z.jsx)(`div`,{className:`flex items-center justify-end gap-1 px-2 py-1.5`,children:(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsxs)(Wo,{type:`single`,value:r,onValueChange:e=>{e&&i(e)},"aria-label":`Diff layout`,variant:`segmented`,size:`sm`,spacing:1,className:`bg-muted dark:bg-background p-0.5 rounded-md shrink-0`,children:[(0,Z.jsx)(Vo,{value:`unified`,"aria-label":`Unified diff`,className:`size-6 px-0`,children:(0,Z.jsx)(Lc,{className:`size-3.5`})}),(0,Z.jsx)(Vo,{value:`split`,"aria-label":`Split diff`,className:`size-6 px-0`,children:(0,Z.jsx)(Qs,{className:`size-3.5`})})]})}),(0,Z.jsx)(vn,{children:r===`unified`?`Unified diff`:`Split diff`})]})}),t[29]=r,t[30]=p,t[31]=i,t[32]=j):j=t[32],M=`flex-1 overflow-y-auto subtle-scrollbar scroll-fade-mask`,t[33]===u?N=t[34]:(N=u&&(0,Z.jsx)(`div`,{className:`flex flex-col gap-1 p-2`,role:`status`,"aria-busy":`true`,"aria-label":`Loading timeline history`,children:[1,2,3].map(Ty)}),t[33]=u,t[34]=N),t[35]!==f||t[36]!==u?(E=!u&&f&&(0,Z.jsx)(`div`,{className:`px-4 py-3`,children:(0,Z.jsx)(`p`,{className:`text-xs text-destructive`,children:f})}),t[35]=f,t[36]=u,t[37]=E):E=t[37],t[38]!==c.length||t[39]!==f||t[40]!==u?(D=!u&&!f&&c.length===0&&(0,Z.jsx)(`div`,{className:`px-4 py-8 text-center`,children:(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No history yet`})}),t[38]=c.length,t[39]=f,t[40]=u,t[41]=D):D=t[41],t[42]!==h||t[43]!==r||t[44]!==n||t[45]!==c||t[46]!==f||t[47]!==g||t[48]!==d||t[49]!==o||t[50]!==u?(O=!u&&!f&&d&&c.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-col gap-1 p-2`,children:c.map(e=>(0,Z.jsx)(Sy,{entry:e,isDark:o,diffLayout:r,cache:h,docName:n,expanded:g.has(e.sha),onToggleExpanded:x,onRestoreSuccess:C},e.sha))}),t[42]=h,t[43]=r,t[44]=n,t[45]=c,t[46]=f,t[47]=g,t[48]=d,t[49]=o,t[50]=u,t[51]=O):O=t[51],k=!u&&!f&&!d&&(0,Z.jsx)(`div`,{className:`flex flex-col gap-1 p-2`,children:e.map((e,t)=>e.kind===`checkpoint`?(0,Z.jsx)(Sy,{entry:e.entry,prominent:!0,isDark:o,diffLayout:r,cache:h,docName:n,expanded:g.has(e.entry.sha),onToggleExpanded:x,onRestoreSuccess:C},e.entry.sha):(0,Z.jsx)(sy,{entries:e.entries,defaultExpanded:e.isPreCheckpoint,isDark:o,diffLayout:r,cache:h,docName:n,expandedShas:g,onToggleExpanded:x,onRestoreSuccess:C},e.entries[0]?.sha??`wip-${t}`))}),t[10]=h,t[11]=r,t[12]=n,t[13]=c,t[14]=f,t[15]=g,t[16]=o,t[17]=u,t[18]=i,t[19]=E,t[20]=D,t[21]=O,t[22]=k,t[23]=A,t[24]=j,t[25]=M,t[26]=N}else E=t[19],D=t[20],O=t[21],k=t[22],A=t[23],j=t[24],M=t[25],N=t[26];let P;t[52]!==E||t[53]!==D||t[54]!==O||t[55]!==k||t[56]!==M||t[57]!==N?(P=(0,Z.jsxs)(`div`,{className:M,children:[N,E,D,O,k]}),t[52]=E,t[53]=D,t[54]=O,t[55]=k,t[56]=M,t[57]=N,t[58]=P):P=t[58];let F;return t[59]!==A||t[60]!==j||t[61]!==P?(F=(0,Z.jsxs)(`div`,{className:A,children:[j,P]}),t[59]=A,t[60]=j,t[61]=P,t[62]=F):F=t[62],F}function Ty(e){return(0,Z.jsxs)(`div`,{className:`flex items-start gap-2.5 rounded-lg px-3 py-2.5`,children:[(0,Z.jsx)(Ma,{className:`size-3.5 rounded mt-0.5 shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,Z.jsx)(Ma,{className:`h-3 w-28`}),(0,Z.jsx)(Ma,{className:`h-3 w-40`})]})]},e)}function Ey(e){return e.type===`checkpoint`}function Dy(){return new Set}function Oy(){return new Ai(32)}var ky=[{id:`outline`,label:`Outline`,icon:xc},{id:`links`,label:`Links`,icon:Qe},{id:`graph`,label:`Graph`,icon:Cc},{id:`timeline`,label:`Timeline`,icon:Js}];function Ay(){return n(()=>import(`./GraphPanel-CbVOnaKD.js`),__vite__mapDeps([18,1,19,3,6,7,20,21,22,23,24,25,26,27,28,29,30,31]),import.meta.url)}var jy=(0,Q.lazy)(async()=>({default:(await Ay()).GraphPanel})),My=(0,Q.lazy)(async()=>({default:(await n(()=>import(`./ActivityModeContent-B8J4OFHO.js`),__vite__mapDeps([32,1,2,33,34,35,20,36,37,38,39,19,3,6,7,4,10,9,40,41]),import.meta.url)).ActivityModeContent}));function Ny(e){let t=(0,$.c)(13),{docName:n,isSourceMode:r,activeTab:i,onActiveTabChange:a,mode:o}=e,[s,c]=(0,Q.useState)(`unified`),l;t[0]!==i||t[1]!==o||t[2]!==a?(l=o===`doc`?(0,Z.jsx)(`div`,{className:`flex flex-row items-center justify-center gap-3 p-2`,children:(0,Z.jsx)(Wo,{type:`single`,variant:`outline`,value:i,onValueChange:e=>{e&&a(e)},"aria-label":`Document panels`,children:ky.map(Py)})}):null,t[0]=i,t[1]=o,t[2]=a,t[3]=l):l=t[3];let u;t[4]!==i||t[5]!==s||t[6]!==n||t[7]!==r||t[8]!==o?(u=o===`doc`?(0,Z.jsxs)(`div`,{role:`tabpanel`,id:`panel-${i}`,"aria-labelledby":`tab-${i}`,className:`min-h-0 flex-1`,children:[i===`outline`&&(0,Z.jsx)(ys,{docName:n,isSourceMode:r}),i===`links`&&(0,Z.jsx)(Cv,{docName:n}),i===`graph`&&(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Loading graph`}),children:(0,Z.jsx)(jy,{activeDocName:n})}),i===`timeline`&&(0,Z.jsx)(wy,{docName:n,diffLayout:s,onDiffLayoutChange:c})]}):(0,Z.jsx)(`div`,{className:`min-h-0 flex-1`,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:`Loading agent activity`}),children:(0,Z.jsx)(My,{})})}),t[4]=i,t[5]=s,t[6]=n,t[7]=r,t[8]=o,t[9]=u):u=t[9];let d;return t[10]!==l||t[11]!==u?(d=(0,Z.jsxs)(Z.Fragment,{children:[l,u]}),t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function Py(e){let{id:t,label:n,icon:r}=e;return(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(Vo,{value:t,role:`tab`,id:`tab-${t}`,"aria-controls":`panel-${t}`,"aria-label":n,asChild:!0,children:(0,Z.jsx)(kr,{children:(0,Z.jsx)(r,{})})}),(0,Z.jsx)(vn,{side:`bottom`,children:n})]},t)}function Fy(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Iy(e,t){let n=getComputedStyle(e.ownerDocument.body);return t*parseFloat(n.fontSize)}function Ly(e){return e/100*window.innerHeight}function Ry(e){return e/100*window.innerWidth}function zy(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function By({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=zy(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Iy(t,i);break;case`em`:r=Fy(t,i);break;case`vh`:r=Ly(i);break;case`vw`:r=Ry(i);break}return r}function Vy(e){return parseFloat(e.toFixed(3))}function Hy({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function Uy(e){let{panels:t}=e,n=Hy({group:e});return n===0?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=Vy(By({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=Vy(By({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=Vy(By({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=Vy(By({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function Wy(e,t=`Assertion error`){if(!e)throw Error(t)}function Gy(e,t){return Array.from(t).sort(e===`horizontal`?Ky:qy)}function Ky(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function qy(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function Jy(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function Yy(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function Xy({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=Yy(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return Wy(i,`No rect found`),i}var Zy;function Qy(){return Zy===void 0&&(Zy=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),Zy}function $y(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=Gy(n,Array.from(t.children).filter(Jy).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.hasAttribute(`data-disabled`)||(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,Xy({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=Qy()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:Hy({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var eb=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},tb=new Map,nb=new eb;function rb(e){tb=new Map(tb),tb.delete(e)}function ib(e,t){for(let[t]of tb)if(t.id===e)return t}function ab(e,t){for(let[t,n]of tb)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function ob(){return tb}function sb(e,t){return nb.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function cb(e,t){let n=tb.get(e);tb=new Map(tb),tb.set(e,t),nb.emit(`groupChange`,{group:e,prev:n,next:t})}function lb(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=Yy(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function ub(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function db(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:_b(e),b:_b(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();Wy(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:gb(hb(n.a)),b:gb(hb(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var fb=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function pb(e){let t=getComputedStyle(vb(e)??e).display;return t===`flex`||t===`inline-flex`}function mb(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||pb(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||fb.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function hb(e){let t=e.length;for(;t--;){let n=e[t];if(Wy(n,`Missing node`),mb(n))return n}return null}function gb(e){return e&&Number(getComputedStyle(e).zIndex)||0}function _b(e){let t=[];for(;e;)t.push(e),e=vb(e);return t}function vb(e){let{parentNode:t}=e;return ub(t)?t.host:t}function yb(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function bb({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!Jy(n)||n.contains(e)||e.contains(n))return!0;if(db(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(yb(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function xb(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=$y(r),a=lb(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&bb({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function Sb(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function Cb(e,t,n=0){return Math.abs(Vy(e)-Vy(t))<=n}function wb(e,t){return Cb(e,t)?0:e>t?1:-1}function Tb({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if(wb(r,c)<0)if(a){let e=(i+c)/2;r=wb(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=Vy(r),r}function Eb({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(Cb(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;Wy(u!=null,`Invalid first pivot index`),Wy(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];Wy(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(Wy(n!=null,`Previous layout not found for panel index ${t}`),Cb(n,i)){let t=o-n;wb(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];Wy(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(Wy(n!=null,`Previous layout not found for panel index ${t}`),Cb(n,o)){let t=n-i;wb(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];Wy(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&wb(i,c)<0)if(e>0){let t=c-o,n=t/2;wb(i+e,c)<0&&(e=wb(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;wb(i-e,c)<0&&(e=wb(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];Wy(e!=null,`Previous layout not found for panel index ${r}`);let a=Tb({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];Wy(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=Tb({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!Cb(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(Sb(c,l))return i;{let t=e<0?d:u,r=s[t];Wy(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=Tb({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!Cb(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];Wy(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=Tb({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(Cb(i,s)||(t-=s-i,l[r]=s),Cb(t,0))break;e>0?r--:r++}}}if(!Cb(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function Db(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||wb(e[n],t[n])!==0)return!1;return!0}function Ob({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!Cb(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];Wy(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];Wy(i!=null,`No layout data found for index ${e}`);let o=r[e];Wy(o!=null,`No layout data found for index ${e}`);let s=Tb({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!Cb(a,0))for(let e=0;e<t.length;e++){let n=r[e];Wy(n!=null,`No layout data found for index ${e}`);let i=n+a,o=Tb({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,Cb(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function kb({groupId:e,panelId:t}){let n=()=>{let t=ob();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,groupSize:o,separatorToPanels:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,groupSize:o,layout:a,separatorToPanels:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=e=>{let r=a();if(e===r)return;let{defaultLayoutDeferred:i,derivedPanelConstraints:o,group:s,groupSize:c,layout:l,separatorToPanels:u}=n(),d=s.panels.findIndex(e=>e.id===t),f=d===s.panels.length-1,p=Ob({layout:Eb({delta:f?r-e:e-r,initialLayout:l,panelConstraints:o,pivotIndices:f?[d-1,d]:[d,d+1],prevLayout:l,trigger:`imperative-api`}),panelConstraints:o});Db(l,p)||cb(s,{defaultLayoutDeferred:i,derivedPanelConstraints:o,groupSize:c,layout:p,separatorToPanels:u})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),s=a();e&&s!==t&&(n.expandToSize=s,o(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:s}=i(),c=a();if(e&&c===t){let e=s.expandToSize??n;e===0&&(e=1),o(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&Cb(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=Hy({group:t});o(Vy(By({groupSize:a,panelElement:r,styleProp:e})/a*100))}}}function Ab(e){e.defaultPrevented||xb(e,ob()).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=kb({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function jb(e){let t=ob();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function Mb({groupId:e}){let t=()=>{let t=ob();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,groupSize:a,layout:o,separatorToPanels:s}=t(),c=Ob({layout:e,panelConstraints:r});return n?o:(Db(o,c)||cb(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function Nb(e,t){let n=jb(e),r=ab(n.id,!0),i=n.separators.find(t=>t.element===e);Wy(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);Wy(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=Mb({groupId:n.id}).getLayout(),c=Ob({layout:Eb({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});Db(s,c)||cb(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels})}function Pb(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=jb(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&Nb(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&Nb(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&Nb(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&Nb(t,-5);break;case`End`:e.preventDefault(),Nb(t,100);break;case`Enter`:{e.preventDefault();let n=jb(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=ab(n.id,!0),o=n.separators.find(e=>e.element===t);Wy(o,`Matching separator not found`);let s=a.get(o);Wy(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(Wy(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];Nb(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=jb(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);Wy(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),Nb(t,-100);break}}var Fb={cursorFlags:0,state:`inactive`},Ib=new eb;function Lb(){return Fb}function Rb(e){return Ib.addListener(`change`,e)}function zb(e){let t=Fb,n={...Fb};n.cursorFlags=e,Fb=n,Ib.emit(`change`,{prev:t,next:n})}function Bb(e){let t=Fb;Fb=e,Ib.emit(`change`,{prev:t,next:e})}function Vb(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=ob(),n=xb(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus({preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),Bb({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}var Hb=e=>e,Ub=()=>{},Wb=1,Gb=2,Kb=4,qb=8,Jb=3,Yb=12,Xb;function Zb(){return Xb===void 0&&(Xb=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(Xb=!0)),Xb}function Qb({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&Zb()){let t=(e&Wb)!==0,n=(e&Gb)!==0,r=(e&Kb)!==0,i=(e&qb)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return Zb()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var $b=new WeakMap;function ex(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=$b.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(n));let r=Lb();switch(r.state){case`active`:case`hover`:{let e=Qb({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}$b.set(e,{prevStyle:t,styleSheet:n})}function tx({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:c,panels:l}=n,{disableCursor:u}=n.mutableState,d=0;d=a?c===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:c===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let f=r.get(n),p=i.get(n);if(!f||!p)return;let{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:_,separatorToPanels:v}=p;if(h&&_&&v){let t=Eb({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(Db(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?Wb:Gb;break;case`vertical`:s|=d<0?Kb:qb;break}}else cb(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&Jb:c|=s&Jb,t.movementY===0?c|=o&Yb:c|=s&Yb,zb(c),ex(e)}function nx(e){let t=ob(),n=Lb();switch(n.state){case`active`:tx({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function rx(e){if(e.defaultPrevented)return;let t=Lb(),n=ob();switch(t.state){case`active`:if(e.buttons===0){Bb({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=ab(e.group.id,!0);cb(e.group,t)});return}for(let n of t.hitRegions)if(n.separator){let{element:t}=n.separator;t.hasPointerCapture?.(e.pointerId)||t.setPointerCapture?.(e.pointerId)}tx({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=xb(e,n);r.length===0?t.state!==`inactive`&&Bb({cursorFlags:0,state:`inactive`}):Bb({cursorFlags:0,hitRegions:r,state:`hover`}),ex(e.currentTarget);break}}}function ix(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Lb().state){case`hover`:Bb({cursorFlags:0,state:`inactive`})}}function ax(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=Lb();switch(t.state){case`active`:Bb({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(ex(e.currentTarget),t.hitRegions.forEach(e=>{let t=ab(e.group.id,!0);cb(e.group,t)}),e.preventDefault())}}function ox(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=Vy(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=Vy((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function sx(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=Hy({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:Vy(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function cx(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function lx({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.panels){let e=r[l.id]??0;switch(l.panelConstraints.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=Vy(e/100*n/t*100);s.set(l.id,r),i+=r;break}default:c.push(l.id),a+=e;break}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=Vy((r[e]??0)/a*l);else{let e=Vy(l/c.length);for(let t of c)u[t]=e}return u}function ux(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var dx=new Map;function fx(e){let t=!0;Wy(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){let t=Hy({group:e});if(t===0)return;let n=ab(e.id);if(!n)return;let r=Uy(e),i=n.defaultLayoutDeferred?ox(r):n.layout,a=Ob({layout:lx({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&Db(n.layout,a)&&cx(n.derivedPanelConstraints,r)&&n.groupSize===t)return;cb(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else sx(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{Wy(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=Hy({group:e}),s=Uy(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(ux(e.panels,l)||(l=void 0));let u=Ob({layout:e.mutableState.layouts[c]??l??ox(s),panelConstraints:s}),d=e.element.ownerDocument;dx.set(d,(dx.get(d)??0)+1);let f=new Map;return $y(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),cb(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{Wy(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,Pb)}),dx.get(d)===1&&(d.addEventListener(`dblclick`,Ab,!0),d.addEventListener(`pointerdown`,Vb,!0),d.addEventListener(`pointerleave`,nx),d.addEventListener(`pointermove`,rx),d.addEventListener(`pointerout`,ix),d.addEventListener(`pointerup`,ax,!0)),function(){t=!1,dx.set(d,Math.max(0,(dx.get(d)??0)-1)),rb(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,Pb)}),dx.get(d)||(d.removeEventListener(`dblclick`,Ab,!0),d.removeEventListener(`pointerdown`,Vb,!0),d.removeEventListener(`pointerleave`,nx),d.removeEventListener(`pointermove`,rx),d.removeEventListener(`pointerout`,ix),d.removeEventListener(`pointerup`,ax,!0)),a.disconnect()}}function px(){let[e,t]=(0,Q.useState)({});return[e,(0,Q.useCallback)(()=>t({}),[])]}function mx(e){let t=(0,Q.useId)();return`${e??t}`}var hx=typeof window<`u`?Q.useLayoutEffect:Q.useEffect;function gx(e){let t=(0,Q.useRef)(e);return hx(()=>{t.current=e},[e]),(0,Q.useCallback)((...e)=>t.current?.(...e),[t])}function _x(...e){return gx(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function vx(e){let t=(0,Q.useRef)({...e});return hx(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var yx=(0,Q.createContext)(null);function bx(e,t){let n=(0,Q.useRef)({getLayout:()=>({}),setLayout:Hb});(0,Q.useImperativeHandle)(t,()=>n.current,[]),hx(()=>{Object.assign(n.current,Mb({groupId:e}))})}function xx({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,Q.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=gx(e=>{Db(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=gx(e=>{Db(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),_=mx(s),v=(0,Q.useRef)(null),[y,b]=px(),x=(0,Q.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=_x(v,a);bx(_,o);let C=gx((e,t)=>{let r=Lb(),i=ib(e),a=ab(e);if(a){let e=!1;switch(r.state){case`active`:e=r.hitRegions.some(e=>e.group===i);break}return{flexGrow:a.layout[t]??1,pointerEvents:e?`none`:void 0}}if(n?.[t])return{flexGrow:n?.[t]}}),w=vx({defaultLayout:n,disableCursor:r}),T=(0,Q.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=Gy(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=Gy(u,[...t.separators,e]),b(),()=>{t.separators=t.separators.filter(t=>t!==e),b()}},updatePanelProps:(e,{disabled:t})=>{let n=x.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=ib(_),i=ab(_);r&&i&&cb(r,{...i,derivedPanelConstraints:Uy(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=x.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[C,_,b,u,w]),E=(0,Q.useRef)(null);return hx(()=>{let e=v.current;if(e===null)return;let t=x.current,n;if(w.defaultLayout!==void 0&&Object.keys(w.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=w.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:_,mutableState:{defaultLayout:n,disableCursor:!!w.disableCursor,expandedPanelSizes:x.current.lastExpandedPanelSizes,layouts:x.current.layouts},orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};E.current=r;let a=fx(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=ab(r.id,!0);!o&&s.length>0&&(h(c),g(c));let l=sb(_,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:i}=e.next;if(t||n.length===0)return;let a=r.panels.map(({id:e})=>e).join(`,`);r.mutableState.layouts[a]=i,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=Cb(t.collapsedSize,i[t.panelId]),a=Cb(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=Lb().state!==`active`;h(i),o&&g(i)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,Q.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,Z.jsx)(yx.Provider,{value:T,children:(0,Z.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:S,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}xx.displayName=`Group`;function Sx(){let e=(0,Q.useContext)(yx);return Wy(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function Cx(e,t){let{id:n}=Sx(),r=(0,Q.useRef)({collapse:Ub,expand:Ub,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Ub});(0,Q.useImperativeHandle)(t,()=>r.current,[]),hx(()=>{Object.assign(r.current,kb({groupId:n,panelId:e}))})}function wx({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,groupResizeBehavior:s=`preserve-relative-size`,id:c,maxSize:l=`100%`,minSize:u=`0%`,onResize:d,panelRef:f,style:p,...m}){let h=!!c,g=mx(c),_=vx({disabled:a}),v=(0,Q.useRef)(null),y=_x(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=Sx(),T=d!==null,E=gx((e,t,n)=>{d?.(e,c,n)});hx(()=>{let e=v.current;if(e!==null)return C({element:e,id:g,idIsStable:h,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:T?E:void 0,panelConstraints:{groupResizeBehavior:s,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:l,minSize:u}})},[s,n,r,i,T,g,h,l,u,E,C,_]),(0,Q.useEffect)(()=>{w(g,{disabled:a})},[a,g,w]),Cx(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},O=(0,Q.useSyncExternalStore)(e=>sb(x,e),D,D),k;return k=O?JSON.parse(O):i?{flexGrow:void 0,flexShrink:void 0,flexBasis:i}:{flexGrow:1},(0,Z.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...Tx,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...k},children:(0,Z.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}wx.displayName=`Panel`;var Tx={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function Ex(){return(0,Q.useRef)(null)}function Dx({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=Ob({layout:Eb({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=Ob({layout:Eb({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function Ox({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=mx(a),l=vx({disabled:n,disableDoubleClick:r}),[u,d]=(0,Q.useState)({}),[f,p]=(0,Q.useState)(`inactive`),m=(0,Q.useRef)(null),h=_x(m,i),{disableCursor:g,id:_,orientation:v,registerSeparator:y,updateSeparatorProps:b}=Sx(),x=v===`horizontal`?`vertical`:`horizontal`;hx(()=>{let e=m.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=y(t),r=Rb(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=sb(_,e=>{let{derivedPanelConstraints:n,layout:r,separatorToPanels:i}=e.next,a=i.get(t);if(a){let e=a[0],t=a.indexOf(e);d(Dx({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[_,c,y,l]),(0,Q.useEffect)(()=>{b(c,{disabled:n,disableDoubleClick:r})},[n,r,c,b]);let S;return n&&!g&&(S=`not-allowed`),(0,Z.jsx)(`div`,{...s,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":x,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":n?`disabled`:f,"data-testid":c,id:c,ref:h,role:`separator`,style:{flexBasis:`auto`,cursor:S,...o,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}Ox.displayName=`Separator`;var kx={name:`toml`,startState:function(){return{inString:!1,stringType:``,lhs:!0,inArray:0}},token:function(e,t){let n;if(!t.inString&&(n=e.match(/^('''|"""|'|")/))&&(t.stringType=n[0],t.inString=!0),e.sol()&&!t.inString&&t.inArray===0&&(t.lhs=!0),t.inString){for(;t.inString;)if(e.match(t.stringType))t.inString=!1;else if(e.peek()===`\\`)e.next(),e.next();else if(e.eol())break;else e.match(/^.[^\\\"\']*/);return t.lhs?`property`:`string`}else if(t.inArray&&e.peek()===`]`)return e.next(),t.inArray--,`bracket`;else if(t.lhs&&e.peek()===`[`&&e.skipTo(`]`))return e.next(),e.peek()===`]`&&e.next(),`atom`;else if(e.peek()===`#`)return e.skipToEnd(),`comment`;else if(e.eatSpace())return null;else if(t.lhs&&e.eatWhile(function(e){return e!=`=`&&e!=` `}))return`property`;else if(t.lhs&&e.peek()===`=`)return e.next(),t.lhs=!1,null;else if(!t.lhs&&e.match(/^\d\d\d\d[\d\-\:\.T]*Z/))return`atom`;else if(!t.lhs&&(e.match(`true`)||e.match(`false`)))return`atom`;else if(!t.lhs&&e.peek()===`[`)return t.inArray++,e.next(),`bracket`;else if(!t.lhs&&e.match(/^\-?\d+(?:\.\d+)?/))return`number`;else e.eatSpace()||e.next();return null},languageData:{commentTokens:{line:`#`}}},Ax=se({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}}),jx=At({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}});function Mx(e){switch(e.toLowerCase()){case`json`:return vs().language;case`toml`:return ms.define(kx);default:return null}}function Nx(e){let t=(0,$.c)(4),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={status:`loading`},t[0]=n):n=t[0];let[r,i]=(0,Q.useState)(n),a,o;return t[1]===e?(a=t[2],o=t[3]):(a=()=>{let t=!1,n=new AbortController;return i({status:`loading`}),fetch(e,{credentials:`same-origin`,signal:n.signal}).then(Px).then(e=>{t||i({status:`loaded`,content:e})}).catch(e=>{t||e instanceof Error&&e.name===`AbortError`||i({status:`error`,message:e instanceof Error?e.message:`Failed to load file`})}),()=>{t=!0,n.abort()}},o=[e],t[1]=e,t[2]=a,t[3]=o),(0,Q.useEffect)(a,o),r}async function Px(e){if(!e.ok)throw Error(`Failed to load file (HTTP ${e.status})`);return e.text()}function Fx(e){let t=(0,$.c)(27),{src:n,fileName:r,extension:i}=e,a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),{resolvedTheme:s}=vr(),c=Nx(n),l=c.status===`loaded`?c.content:null,u,d;if(t[0]!==i||t[1]!==l||t[2]!==s?(u=()=>{if(!a.current||l===null)return;let e=Mx(i),t=s===`dark`?Ax:jx,n=[xs,...e?[e]:[],us.editable.of(!1),es.readOnly.of(!0),us.lineWrapping,t],r=new us({state:es.create({doc:l,extensions:n}),parent:a.current});return o.current=r,()=>{r.destroy(),o.current=null}},d=[l,i,s],t[0]=i,t[1]=l,t[2]=s,t[3]=u,t[4]=d):(u=t[3],d=t[4]),(0,Q.useEffect)(u,d),c.status===`loading`){let e;t[5]===r?e=t[6]:(e=(0,Z.jsxs)(`span`,{children:[`Loading `,r]}),t[5]=r,t[6]=e);let n;return t[7]!==i||t[8]!==r||t[9]!==e?(n=(0,Z.jsx)(`main`,{className:`flex h-full min-h-0 flex-col items-center justify-center bg-background text-muted-foreground text-sm`,"aria-label":r,"data-text-viewer":``,"data-text-viewer-state":`loading`,"data-text-viewer-extension":i,children:e}),t[7]=i,t[8]=r,t[9]=e,t[10]=n):n=t[10],n}if(c.status===`error`){let e;t[11]===r?e=t[12]:(e=(0,Z.jsxs)(`div`,{className:`font-medium text-sm`,children:[`Couldn't load `,r]}),t[11]=r,t[12]=e);let a;t[13]===c.message?a=t[14]:(a=(0,Z.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:c.message}),t[13]=c.message,t[14]=a);let o;t[15]===n?o=t[16]:(o=(0,Z.jsx)(`a`,{href:n,className:`mt-2 rounded-md border px-3 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground`,children:`Open file`}),t[15]=n,t[16]=o);let s;return t[17]!==i||t[18]!==r||t[19]!==e||t[20]!==a||t[21]!==o?(s=(0,Z.jsxs)(`main`,{className:`flex h-full min-h-0 flex-col items-center justify-center gap-2 bg-background p-4 text-center`,"aria-label":r,"data-text-viewer":``,"data-text-viewer-state":`error`,"data-text-viewer-extension":i,children:[e,a,o]}),t[17]=i,t[18]=r,t[19]=e,t[20]=a,t[21]=o,t[22]=s):s=t[22],s}let f;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(`div`,{ref:a,className:`min-h-0 flex-1 overflow-auto`}),t[23]=f):f=t[23];let p;return t[24]!==i||t[25]!==r?(p=(0,Z.jsx)(`main`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-label":r,"data-text-viewer":``,"data-text-viewer-state":`loaded`,"data-text-viewer-extension":i,children:f}),t[24]=i,t[25]=r,t[26]=p):p=t[26],p}function Ix(e){return Sr(`/api/asset?path=${encodeURIComponent(e)}`)}function Lx(e){return`/api/asset-text?path=${encodeURIComponent(e)}`}function Rx(e){let t=(0,$.c)(28),{assetPath:n,mediaKind:r}=e,[i,a]=(0,Q.useState)(!1),o;t[0]===n?o=t[1]:(o=Ix(n),t[0]=n,t[1]=o);let s=o,c;t[2]===n?c=t[3]:(c=n.split(`/`).pop()??n,t[2]=n,t[3]=c);let l=c,u,d,f;if(t[4]!==n||t[5]!==l||t[6]!==i||t[7]!==r||t[8]!==s){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=l.includes(`.`)?l.split(`.`).pop()??``:``;if(d=e.length>0?e.toUpperCase():`FILE`,u=i?`text`:r,u===`pdf`){let e;t[12]!==l||t[13]!==s?(e=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(Ce,{src:s,title:l,fillContainer:!0})}),t[12]=l,t[13]=s,t[14]=e):e=t[14];let n;t[15]!==l||t[16]!==e?(n=(0,Z.jsx)(`main`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-label":l,children:e}),t[15]=l,t[16]=e,t[17]=n):n=t[17],f=n;break bb0}if(u===`text`){let r;t[18]===n?r=t[19]:(r=Lx(n),t[18]=n,t[19]=r),f=(0,Z.jsx)(Fx,{src:r,fileName:l,extension:e.toLowerCase()},n);break bb0}}t[4]=n,t[5]=l,t[6]=i,t[7]=r,t[8]=s,t[9]=u,t[10]=d,t[11]=f}else u=t[9],d=t[10],f=t[11];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[20]!==u||t[21]!==d||t[22]!==l||t[23]!==s?(p=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:u===`image`?(0,Z.jsx)(Te,{src:s,alt:l,draggable:!1,slotClassName:`flex h-full w-full items-center justify-center`,className:`max-h-full max-w-full`}):u===`video`?(0,Z.jsx)(`video`,{src:s,controls:!0,className:`max-h-full max-w-full`}):u===`audio`?(0,Z.jsx)(`audio`,{src:s,controls:!0,className:`w-full max-w-md`}):(0,Z.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-3 text-center`,children:[(0,Z.jsx)(`div`,{className:`flex size-16 items-center justify-center rounded-md border bg-muted font-medium text-muted-foreground text-sm`,children:d}),(0,Z.jsx)(`div`,{className:`max-w-full break-words font-medium text-sm`,children:l}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,Z.jsx)(Y,{asChild:!0,variant:`outline`,size:`sm`,children:(0,Z.jsx)(`a`,{href:s,children:`Open file`})}),(0,Z.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>a(!0),"data-testid":`asset-preview-open-as-text`,children:`Open with built-in text editor`})]})]})}),t[20]=u,t[21]=d,t[22]=l,t[23]=s,t[24]=p):p=t[24];let m;return t[25]!==l||t[26]!==p?(m=(0,Z.jsx)(`main`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-label":l,children:p}),t[25]=l,t[26]=p,t[27]=m):m=t[27],m}function zx(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`div`,{className:`tiptap-editor pt-10`,role:`status`,"aria-busy":`true`,"aria-label":`Loading document`,children:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(Ma,{className:`h-9 w-2/5 mt-6 mb-5`}),(0,Z.jsx)(Ma,{className:`h-4 w-full`}),(0,Z.jsx)(Ma,{className:`h-4 w-3/4`})]})}),e[0]=t):t=e[0],t}var Bx={"claude-cowork":`claude`,"claude-code":`claude`,codex:`openai`,cursor:`cursor`};function Vx(e){let t=(0,$.c)(23),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({id:r,style:a,className:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{resolvedTheme:o}=vr(),s=Bx[r],c=s?(o===`dark`?nr[s]:void 0)??On[s]:void 0,l;t[5]!==c||t[6]!==a?(l=c?{...a,"--ok-brand-color":c}:a,t[5]=c,t[6]=a,t[7]=l):l=t[7];let u=l,d=c&&`[&_*]:![color:var(--ok-brand-color)]`,f;t[8]!==n||t[9]!==d?(f=mi(d,n),t[8]=n,t[9]=d,t[10]=f):f=t[10];let p=f;if(r===`claude-cowork`||r===`claude-code`){let e;return t[11]!==p||t[12]!==u||t[13]!==i?(e=(0,Z.jsx)(Oi,{style:u,className:p,...i}),t[11]=p,t[12]=u,t[13]=i,t[14]=e):e=t[14],e}if(r===`codex`){let e;return t[15]!==p||t[16]!==u||t[17]!==i?(e=(0,Z.jsx)(Di,{style:u,className:p,...i}),t[15]=p,t[16]=u,t[17]=i,t[18]=e):e=t[18],e}if(r===`cursor`){let e;return t[19]!==p||t[20]!==u||t[21]!==i?(e=(0,Z.jsx)(Pi,{style:u,className:p,...i}),t[19]=p,t[20]=u,t[21]=i,t[22]=e):e=t[22],e}return null}function Hx(e){let{installState:t}=e;return t.installed===null?`Detecting`:t.installed===!1?`Not installed`:null}function Ux(e){let{target:t,installState:n}=e;if(n.installed===null)return{enabled:!1,tooltip:null};if(n.installed===!1){let e=t.appBrandName??t.displayName;return{enabled:!1,tooltip:{message:`Requires ${e}.`,installAction:{label:`Install ${e} →`,url:t.installUrl},...t.hasWebFallback?{webFallback:{label:`Open in claude.ai →`,url:``}}:{}}}}return{enabled:!0,tooltip:null}}function Wx(e){return fr(e)}function Gx(e){return`Opened ${e} in your browser.`}var Kx=`claude.ai`;async function qx(e,t=$m){(await t(fr(e))).ok?X.success(Gx(Kx)):X.error(`Couldn't open ${Kx} in your browser.`)}function Jx(e){let t=(0,$.c)(73),{target:n,installState:r,isElectronHost:i,prompt:a,onSelect:o}=e,s=e.openExternal??$m,c=e.onWebFallbackSuccess??Xx,l=e.onWebFallbackError??Yx,u;t[0]!==r||t[1]!==i||t[2]!==n?(u=Ux({target:n,installState:r,isElectronHost:i}),t[0]=r,t[1]=i,t[2]=n,t[3]=u):u=t[3];let d=u,f;t[4]!==r||t[5]!==i||t[6]!==n?(f=Hx({target:n,installState:r,isElectronHost:i}),t[4]=r,t[5]=i,t[6]=n,t[7]=f):f=t[7];let p=f,m;t[8]!==s||t[9]!==d.tooltip?(m=()=>{d.tooltip&&s(d.tooltip.installAction.url)},t[8]=s,t[9]=d.tooltip,t[10]=m):m=t[10];let h=m,g;t[11]!==l||t[12]!==c||t[13]!==s||t[14]!==a||t[15]!==n?(g=()=>{(async()=>{let e=await s(Wx(a));e.ok?c(n):l(n,e.detail??e.reason)})()},t[11]=l,t[12]=c,t[13]=s,t[14]=a,t[15]=n,t[16]=g):g=t[16];let _=g;if(d.enabled){let e=`open-in-agent-item-${n.id}`,r=`Open with AI ${n.displayName}`,i;t[17]===n.id?i=t[18]:(i=(0,Z.jsx)(Vx,{id:n.id,"aria-hidden":`true`}),t[17]=n.id,t[18]=i);let a;t[19]===n.displayName?a=t[20]:(a=(0,Z.jsx)(`span`,{children:n.displayName}),t[19]=n.displayName,t[20]=a);let s;return t[21]!==o||t[22]!==e||t[23]!==r||t[24]!==i||t[25]!==a?(s=(0,Z.jsxs)(ya,{onSelect:o,"data-testid":e,"aria-label":r,children:[i,a]}),t[21]=o,t[22]=e,t[23]=r,t[24]=i,t[25]=a,t[26]=s):s=t[26],s}if(!d.tooltip){let e=p?`Open with AI ${n.displayName}, ${p}`:`Open with AI ${n.displayName}`,r=`open-in-agent-item-${n.id}`,i;t[27]===n.id?i=t[28]:(i=(0,Z.jsx)(Vx,{id:n.id,"aria-hidden":`true`}),t[27]=n.id,t[28]=i);let a;t[29]===n.displayName?a=t[30]:(a=(0,Z.jsx)(`span`,{className:`flex-1`,children:n.displayName}),t[29]=n.displayName,t[30]=a);let o;t[31]===p?o=t[32]:(o=p?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:p}):null,t[31]=p,t[32]=o);let s;return t[33]!==e||t[34]!==r||t[35]!==i||t[36]!==a||t[37]!==o?(s=(0,Z.jsxs)(ya,{disabled:!0,"data-testid":r,"aria-label":e,children:[i,a,o]}),t[33]=e,t[34]=r,t[35]=i,t[36]=a,t[37]=o,t[38]=s):s=t[38],s}let v=p?`Open with AI ${n.displayName}, ${p}`:`Open with AI ${n.displayName}`,y=`open-in-agent-item-${n.id}`,b;t[39]===n.id?b=t[40]:(b=(0,Z.jsx)(Vx,{id:n.id,"aria-hidden":`true`,className:`mr-2`}),t[39]=n.id,t[40]=b);let x;t[41]===n.displayName?x=t[42]:(x=(0,Z.jsx)(`span`,{className:`flex-1`,children:n.displayName}),t[41]=n.displayName,t[42]=x);let S;t[43]===p?S=t[44]:(S=p?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:p}):null,t[43]=p,t[44]=S);let C;t[45]!==v||t[46]!==y||t[47]!==b||t[48]!==x||t[49]!==S?(C=(0,Z.jsxs)(xa,{"data-testid":y,"data-row-disabled":``,"aria-label":v,children:[b,x,S]}),t[45]=v,t[46]=y,t[47]=b,t[48]=x,t[49]=S,t[50]=C):C=t[50];let w=`open-in-agent-submenu-${n.id}`,T=`open-in-agent-message-${n.id}`,E;t[51]!==d.tooltip.message||t[52]!==T?(E=(0,Z.jsx)(Qi,{className:`font-normal text-muted-foreground text-xs`,"data-testid":T,children:d.tooltip.message}),t[51]=d.tooltip.message,t[52]=T,t[53]=E):E=t[53];let D;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(na,{}),t[54]=D):D=t[54];let O=`open-in-agent-install-${n.id}`,k;t[55]===d.tooltip.installAction.label?k=t[56]:(k=(0,Z.jsx)(`span`,{children:d.tooltip.installAction.label}),t[55]=d.tooltip.installAction.label,t[56]=k);let A;t[57]!==h||t[58]!==O||t[59]!==k?(A=(0,Z.jsx)(ya,{onSelect:h,"data-testid":O,children:k}),t[57]=h,t[58]=O,t[59]=k,t[60]=A):A=t[60];let j;t[61]!==_||t[62]!==d.tooltip.webFallback||t[63]!==n.id?(j=d.tooltip.webFallback?(0,Z.jsxs)(ya,{onSelect:_,"data-testid":`open-in-agent-web-fallback-${n.id}`,"aria-label":`${d.tooltip.webFallback.label}, opens in browser with prompt pre-filled`,children:[(0,Z.jsx)(`span`,{className:`flex-1`,children:d.tooltip.webFallback.label}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`opens in browser with prompt pre-filled`})]}):null,t[61]=_,t[62]=d.tooltip.webFallback,t[63]=n.id,t[64]=j):j=t[64];let M;t[65]!==E||t[66]!==A||t[67]!==j||t[68]!==w?(M=(0,Z.jsxs)(ta,{className:`min-w-[260px]`,"data-testid":w,children:[E,D,A,j]}),t[65]=E,t[66]=A,t[67]=j,t[68]=w,t[69]=M):M=t[69];let N;return t[70]!==M||t[71]!==C?(N=(0,Z.jsxs)(Xa,{children:[C,M]}),t[70]=M,t[71]=C,t[72]=N):N=t[72],N}function Yx(){}function Xx(){}function Zx(e){let t=(0,$.c)(12),{className:n}=e,{states:r,refresh:i}=Oh(),{dispatch:a}=_h(),o=km(),s,c;if(t[0]!==n||t[1]!==a||t[2]!==i||t[3]!==r||t[4]!==o){let e=ah({workspace:o});t[7]===n?s=t[8]:(s=mi(`grid w-full max-w-5xl gap-4 sm:grid-cols-3`,n),t[7]=n,t[8]=s),c=xm.map(t=>{let n=r[t.id]?.installed,o=n===!0?`installed`:n===!1?`missing`:`pending`;return(0,Z.jsx)(Qx,{target:t,status:o,onOpen:o===`installed`&&e!==null?()=>{a(t.id,e)}:void 0,onInstall:()=>{sh(t),i()}},t.id)}),t[0]=n,t[1]=a,t[2]=i,t[3]=r,t[4]=o,t[5]=s,t[6]=c}else s=t[5],c=t[6];let l;return t[9]!==s||t[10]!==c?(l=(0,Z.jsx)(`div`,{className:s,children:c}),t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function Qx(e){let t=(0,$.c)(22),{target:n,status:r,onOpen:i,onInstall:a}=e,o=r===`installed`?i:r===`missing`?a:void 0,s=r===`pending`||r===`installed`&&i===void 0,c=r===`installed`?`Open`:r===`missing`?`Install`:`Checking`,l;t[0]===n.id?l=t[1]:(l=(0,Z.jsx)(Vx,{id:n.id,"aria-hidden":`true`,className:`size-4`}),t[0]=n.id,t[1]=l);let u;t[2]===n.displayName?u=t[3]:(u=(0,Z.jsx)(`h3`,{className:`text-sm font-medium leading-tight`,children:n.displayName}),t[2]=n.displayName,t[3]=u);let d;t[4]!==l||t[5]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center gap-2`,children:[l,u]}),t[4]=l,t[5]=u,t[6]=d):d=t[6];let f;t[7]===n.tagline?f=t[8]:(f=n.tagline?(0,Z.jsx)(`p`,{className:`text-1sm leading-relaxed text-muted-foreground`,children:n.tagline}):null,t[7]=n.tagline,t[8]=f);let p;t[9]!==d||t[10]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[d,f]}),t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===r?m=t[13]:(m=r===`missing`?(0,Z.jsx)(mo,{"aria-hidden":`true`,className:`size-3`}):null,t[12]=r,t[13]=m);let h;t[14]!==c||t[15]!==m?(h=(0,Z.jsxs)(`p`,{className:`mt-auto inline-flex items-center gap-1 pt-2 font-mono text-2xs uppercase tracking-wider text-muted-foreground`,children:[c,m]}),t[14]=c,t[15]=m,t[16]=h):h=t[16];let g;return t[17]!==s||t[18]!==o||t[19]!==p||t[20]!==h?(g=(0,Z.jsxs)(`button`,{type:`button`,onClick:o,disabled:s,className:`group flex h-full flex-col items-start gap-4 rounded-2xl border border-border/60 bg-card p-5 text-left transition-[border-color,box-shadow,transform] hover:border-border hover:shadow-sm focus-visible:border-ring focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 active:translate-y-px disabled:cursor-not-allowed disabled:opacity-60`,children:[p,h]}),t[17]=s,t[18]=o,t[19]=p,t[20]=h,t[21]=g):g=t[21],g}var $x=3100,eS=3;function tS(e,t,n){let r=n?.windowMs??600,i=n?.maxLevel??eS;if(e===0||t>=r)return 1;let a=e+1;return a>i?i:a}var nS={0:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},1:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},2:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},3:{count:16,startRadius:11,baseDistance:7,distanceVariance:3,sizeMin:.45,sizeMax:1.2,maxDelay:500,durationMin:1100,durationMax:2400}},rS=[`var(--color-azure-blue)`,`var(--color-sky-blue)`,`var(--color-violet-300)`,`var(--color-orange-light)`,`var(--color-crystal-blue)`,`var(--color-white-cream)`];function iS(e,t={}){let n=t.rng??Math.random,r=t.colors??rS,i=nS[e];if(i.count===0||r.length===0)return[];let a=[],o=Math.PI*2/i.count;for(let e=0;e<i.count;e++){let t=e*o+(n()-.5)*o*.7,s=i.baseDistance+(n()-.5)*2*i.distanceVariance,c=i.sizeMin+n()*(i.sizeMax-i.sizeMin),l=n()*i.maxDelay,u=i.durationMin+n()*(i.durationMax-i.durationMin),d=Math.floor(n()*r.length),f=Math.cos(t),p=Math.sin(t);a.push({id:e,dx:f*s,dy:p*s,originDx:f*i.startRadius,originDy:p*i.startRadius,size:c,color:r[d]??`currentColor`,delay:l,duration:u})}return a}var aS=1.8,oS=90,sS=16,cS=380,lS=.025,uS=.1,dS=.18,fS=400,pS=9.2736,mS=18.1799,hS=14.5244,gS={1:{halfWidth:1.5,apexLift:2.2},2:{halfWidth:1.4,apexLift:2.6},3:{halfWidth:1.25,apexLift:3}};function _S(e,t){let{halfWidth:n,apexLift:r}=gS[t];return`M${e-n} ${hS+.3} Q${e} ${hS-r}, ${e+n} ${hS+.3}`}function vS(e){let t=1.5,n=.3;return`M${e-t} ${hS-n} Q${e} ${hS+1.4}, ${e+t} ${hS-n}`}var yS=15,bS=15;function xS(e){return{fill:e.color,"--fx-tx":`${e.dx}px`,"--fx-ty":`${e.dy}px`,"--fx-delay":`${e.delay}ms`,"--fx-duration":`${e.duration}ms`}}function SS(e){let t=(0,$.c)(71),{size:n,className:r,trackMouse:i,variant:a,celebrateSignal:o}=e,s=n===void 0?48:n,c=i===void 0?!0:i,l=a===void 0?`default`:a,u=o===void 0?0:o,d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),p=(0,Q.useRef)(null),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m={x:0,y:0},t[0]=m):m=t[0];let h=(0,Q.useRef)(m),[g,_]=(0,Q.useState)(0),[v,y]=(0,Q.useState)(0),b;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(b=[],t[1]=b):b=t[1];let[x,S]=(0,Q.useState)(b),C=(0,Q.useRef)(0),w=(0,Q.useRef)(void 0),T=l===`sleeping`,E;t[2]!==g||t[3]!==T?(E=function(){if(T)return;let e=typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),t=C.current===0?1/0:e-C.current;C.current=e;let n=tS(g,t);_(n),y(ES),S(iS(n)),clearTimeout(w.current),w.current=setTimeout(()=>{_(0),S([])},$x)},t[2]=g,t[3]=T,t[4]=E):E=t[4];let D=E,O,k;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>()=>clearTimeout(w.current),k=[],t[5]=O,t[6]=k):(O=t[5],k=t[6]),(0,Q.useEffect)(O,k);let A,j;t[7]!==u||t[8]!==T?(A=()=>{u===0||T||(_(3),y(TS),S(iS(3)),clearTimeout(w.current),w.current=setTimeout(()=>{_(0),S([])},$x))},j=[u,T],t[7]=u,t[8]=T,t[9]=A,t[10]=j):(A=t[9],j=t[10]),(0,Q.useEffect)(A,j);let M,N;t[11]!==T||t[12]!==c?(M=()=>{if(!c||T||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let e=0,t=0,n=!1,r=0,i=0,a=0,o=0,s=0,l=function(){s===0&&(s=requestAnimationFrame(m))},u=function(r){e=r.clientX,t=r.clientY,n=!0,l()};function m(){s=0;let c=f.current,u=d.current;if(!c||!u){l();return}let m=n;n=!1;let g=c.getBoundingClientRect(),_=g.left+g.width/2,v=g.top+g.height*.48,y=e-_,b=t-v,x=Math.hypot(y,b),S=Math.max(-1,Math.min(1,y/cS)),C=Math.max(-1,Math.min(1,b/cS)),w=S*sS,T=-C*sS,E=0,D=0;if(x>=1){let e=Math.min(x/oS,1)*aS;E=y/x*e,D=b/x*e}let O=Math.abs(T-r)<.01&&Math.abs(w-i)<.01&&Math.abs(E-a)<.01&&Math.abs(D-o)<.01;if(!m&&O)return;l(),r+=(T-r)*uS,i+=(w-i)*uS,u.style.transform=`perspective(${fS}px) rotateX(${r.toFixed(3)}deg) rotateY(${i.toFixed(3)}deg)`,a+=(E-a)*dS,o+=(D-o)*dS;let k=i*lS,A=-r*lS,j=a+k,M=o+A;h.current.x=j,h.current.y=M,p.current?.setAttribute(`transform`,`translate(${j.toFixed(3)} ${M.toFixed(3)})`)}return document.addEventListener(`mousemove`,u,{passive:!0}),l(),()=>{document.removeEventListener(`mousemove`,u),s!==0&&cancelAnimationFrame(s),s=0,d.current&&(d.current.style.transform=``),h.current={x:0,y:0},p.current?.removeAttribute(`transform`)}},N=[c,T],t[11]=T,t[12]=c,t[13]=M,t[14]=N):(M=t[13],N=t[14]),(0,Q.useEffect)(M,N);let P;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>{let e=p.current;if(!e)return;let{x:t,y:n}=h.current;e.setAttribute(`transform`,`translate(${t.toFixed(3)} ${n.toFixed(3)})`)},t[15]=P):P=t[15],(0,Q.useLayoutEffect)(P);let F=g>0,I=F?g:1,L=F?`ok-blob-clicked-${g}`:null,R;t[16]===r?R=t[17]:(R=mi(`ok-blob-3d-wrapper`,r),t[16]=r,t[17]=R);let z=T?`cursor-default`:`cursor-pointer`,B=`body-${v}`,V=T&&`ok-blob-sleeping`,H;t[18]!==L||t[19]!==V?(H=mi(`ok-blob-group`,V,L),t[18]=L,t[19]=V,t[20]=H):H=t[20];let U;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Z.jsx)(`path`,{d:`M25.2339 6.78134C25.5199 7.35734 25.8179 8.47234 26.0179 9.07834C26.0189 9.08234 26.0209 9.08634 26.0219 9.09134C26.0229 9.09534 26.0249 9.10034 26.0259 9.10434C26.0539 9.19734 26.0949 9.29533 26.1519 9.41633C26.2919 9.71133 26.5269 10.1173 27.1299 11.1683C27.3259 11.4643 27.5209 11.7693 27.7119 12.0903C29.9739 15.1623 29.3259 20.1913 27.0469 22.9153C26.7779 23.2953 26.4869 23.6043 26.1889 23.8863C26.1519 23.9253 26.1129 23.9643 26.0729 24.0033C25.3159 24.7543 24.2949 25.4673 23.6129 25.8323C22.7469 26.2983 22.1349 26.5483 21.6299 26.7463C20.3649 27.3063 19.0609 27.7733 17.6569 28.0423C15.9649 28.3513 14.1939 28.4433 12.4569 28.1373C11.4779 27.9663 10.5119 27.6663 9.60891 27.2493C8.77491 26.8663 7.99192 26.3853 7.26992 25.8403C6.83592 25.5393 6.43893 25.2343 6.08093 24.9383C5.57893 24.5223 5.15993 24.1263 4.83493 23.7793C4.04993 22.9443 3.31593 21.8893 2.80893 21.0953C2.72593 20.9663 2.64792 20.8433 2.57592 20.7293C2.56192 20.7093 2.54793 20.6893 2.53393 20.6703C2.08593 20.0263 1.71892 19.3293 1.43792 18.5993C1.42892 18.5453 1.42093 18.4903 1.41293 18.4353C1.32093 17.7443 1.08292 16.9423 1.01092 15.6333C0.984921 15.0653 0.998928 14.4013 1.12393 13.6353C1.20693 13.1413 1.31993 12.9023 1.40893 12.7113C1.43593 12.6543 1.46193 12.6023 1.48593 12.5483C1.56793 12.3653 1.59392 12.1563 1.63592 11.9083C1.68992 11.5883 1.76992 11.1943 2.04592 10.7553C2.94392 9.37934 3.36792 8.81934 3.66592 8.33934C3.75592 8.20334 3.84292 8.08134 3.94192 7.96634C4.21592 7.64634 4.67693 7.29534 5.10293 7.05734C5.16693 7.02234 5.23093 6.98834 5.29193 6.95534C5.62993 6.77834 6.22592 6.30135 6.66992 5.92035C6.83692 5.77635 7.08193 5.60735 7.37393 5.40935C7.67393 5.20535 8.02593 4.96934 8.39193 4.70234C9.32093 4.02634 9.84091 3.69134 10.2599 3.42334C10.3799 3.34734 10.4919 3.27734 10.6049 3.20834C10.9609 2.98834 11.4149 2.73034 11.8869 2.48634C12.4519 2.19334 13.0469 1.92133 13.5089 1.72233C14.7399 1.30233 16.0539 1.01333 17.4169 1.00033C18.1169 0.991333 18.7939 1.16534 19.2389 1.43034C19.6869 1.69534 19.8689 2.00335 19.8039 2.23935C19.7379 2.47835 19.4399 2.63634 19.0109 2.74734C18.5789 2.85634 18.0469 2.92035 17.4889 2.96135C16.3639 3.04235 15.2399 3.36435 14.1499 3.80835C12.8199 4.35135 11.5379 5.07133 10.2719 5.84733C9.38691 6.39133 8.51192 6.97334 7.63592 7.56834C7.54492 7.63034 7.45492 7.69135 7.36492 7.75235C6.97392 8.06635 6.58293 8.38134 6.22293 8.66334C5.97893 8.85734 5.76793 9.04834 5.59393 9.21434C5.26893 9.52334 5.02393 9.74334 4.81893 9.93934C4.67793 10.0753 4.55793 10.2013 4.45593 10.3443C4.40093 10.4213 4.32992 10.5273 4.24792 10.6593C3.90492 11.1933 3.44493 12.1693 3.15393 13.1173C3.01893 13.5363 2.87991 14.0343 2.79391 14.5253C2.66591 15.2253 2.65594 15.9053 2.71994 16.2373C2.82794 16.8193 2.95593 17.4833 3.14093 18.0553C3.31293 18.6003 3.52991 19.0583 3.70791 19.2823C3.81591 19.4183 3.90394 19.5473 3.99594 19.6913C4.09394 19.8413 4.19191 20.0073 4.31091 20.2033C4.47891 20.4803 4.68592 20.8163 5.00192 21.2493C5.36492 21.7463 5.61793 22.1043 5.83493 22.4023C6.14493 22.8243 6.38591 23.1343 6.83691 23.5033C7.33891 23.9113 7.86593 24.3113 8.26693 24.6393C8.44893 24.7883 8.66993 24.9443 8.90493 25.0963C9.21593 25.2963 9.55192 25.4893 9.85592 25.6703C10.1059 25.8203 10.3059 25.9633 10.4869 26.0863C10.5429 26.1243 10.5979 26.1603 10.6519 26.1943C10.8699 26.2803 11.0929 26.3593 11.3159 26.4283C11.3539 26.4323 11.3949 26.4353 11.4369 26.4393C11.6509 26.4573 11.9089 26.4733 12.2209 26.5133C12.7169 26.5753 13.1399 26.6603 13.6019 26.7243C13.9589 26.7733 14.3409 26.8083 14.7729 26.7893C15.0729 26.7753 15.4069 26.7353 15.7389 26.6813C16.2349 26.6023 16.7179 26.4943 17.0569 26.4473C17.1499 26.4343 17.2359 26.4343 17.3209 26.4373C17.3489 26.4393 17.3799 26.4413 17.4109 26.4433C17.4119 26.4433 17.4119 26.4433 17.4129 26.4433C17.4199 26.4433 17.4279 26.4443 17.4349 26.4443C18.2329 26.2413 19.0259 25.9433 19.7959 25.5983C19.8609 25.5633 19.9259 25.5273 19.9899 25.4913C20.3059 25.3173 20.6049 25.1383 20.7869 24.9943C20.9829 24.8393 21.5189 24.5373 22.0579 24.1853C22.4109 23.9553 22.7649 23.7053 23.0369 23.4833C23.1949 23.3553 23.3689 23.2693 23.5479 23.1773C23.7129 23.0923 23.8809 23.0013 24.0349 22.8653C24.1109 22.7983 24.1869 22.7173 24.2639 22.6303C24.3309 22.5563 24.4039 22.4723 24.4759 22.3923C24.5459 22.3153 24.7199 22.1723 24.9139 21.9793C25.0079 21.8863 25.1059 21.7783 25.1909 21.6713C25.2199 21.6323 25.2489 21.5943 25.2769 21.5553C25.5919 21.0403 25.8779 20.5003 26.1019 19.9653C26.1299 19.8403 26.1379 19.7293 26.1279 19.6373C26.1199 19.5703 26.1029 19.5113 26.0839 19.4503C26.0599 19.3643 26.0329 19.2773 26.0239 19.1723C26.0169 19.0893 26.0309 19.0043 26.0629 18.9543C26.0779 18.9323 26.0969 18.9143 26.1129 18.8993C26.1329 18.8823 26.1499 18.8673 26.1569 18.8443C26.1609 18.8273 26.1579 18.8073 26.1529 18.7833C26.1459 18.7443 26.1369 18.6943 26.1539 18.6293C26.2189 18.3853 26.2869 18.1103 26.3319 17.8383C26.3829 17.5393 26.4049 17.2433 26.3949 17.0123C26.3849 16.7493 26.3909 16.3823 26.3469 16.0003C26.3179 15.7343 26.2659 15.4663 26.1979 15.2383C26.1319 15.0143 26.0219 14.7913 25.9039 14.5783C25.7629 14.3223 25.6119 14.0783 25.5169 13.8453C25.4969 13.7983 25.4999 13.7263 25.4999 13.6323C25.5009 13.5673 25.4999 13.4913 25.4919 13.4083C25.3239 13.1243 25.1459 12.8423 24.9589 12.5483C24.9479 12.5413 24.9369 12.5333 24.9249 12.5263C24.6689 12.3503 24.3139 12.1173 24.0769 11.5503C24.0179 11.4063 24.0069 11.2983 23.9969 11.1993C23.9859 11.1013 23.9799 11.0183 23.9289 10.9093C23.8709 10.7853 23.7759 10.6583 23.6709 10.4993C23.5849 10.3703 23.4899 10.2133 23.4199 10.0423C23.3819 9.95134 23.3509 9.85734 23.3329 9.75934C23.3299 9.74334 23.3269 9.72534 23.3229 9.70634C23.2899 9.52734 23.2439 9.26534 23.2409 8.98634C23.0209 8.24434 22.8339 7.48833 22.6519 6.77633C22.3429 5.57133 22.0519 4.54234 21.3329 3.95434C20.9839 3.65334 20.5689 3.35433 20.2459 3.05433C19.9259 2.75633 19.7449 2.47534 19.8019 2.23834C19.8639 2.00634 20.1589 1.82934 20.6659 1.80534C21.1699 1.78334 21.8699 1.93235 22.5209 2.39235C23.6159 3.14235 24.2029 4.38334 24.5599 5.35734C24.5829 5.40834 24.6049 5.46034 24.6259 5.51234C24.7849 5.89434 24.9529 6.22834 25.1199 6.55534C25.1579 6.63034 25.1969 6.70834 25.2339 6.78134Z`,className:`ok-blob-body`}),t[21]=U):U=t[21];let W=(F||T)&&`ok-blob-eye-hidden`,G;t[22]===W?G=t[23]:(G=mi(`ok-blob-eye`,W),t[22]=W,t[23]=G);let K;t[24]===G?K=t[25]:(K=(0,Z.jsx)(`ellipse`,{cx:pS,cy:hS,rx:1.2722,ry:1.9083,className:G}),t[24]=G,t[25]=K);let q=(F||T)&&`ok-blob-eye-hidden`,ee;t[26]===q?ee=t[27]:(ee=mi(`ok-blob-eye ok-blob-eye-right`,q),t[26]=q,t[27]=ee);let te;t[28]===ee?te=t[29]:(te=(0,Z.jsx)(`ellipse`,{cx:mS,cy:hS,rx:1.2722,ry:1.9083,className:ee}),t[28]=ee,t[29]=te);let ne;t[30]===I?ne=t[31]:(ne=_S(pS,I),t[30]=I,t[31]=ne);let re=(!F||T)&&`ok-blob-eye-hidden`,ie;t[32]===re?ie=t[33]:(ie=mi(`ok-blob-happy-eye`,re),t[32]=re,t[33]=ie);let ae;t[34]!==ne||t[35]!==ie?(ae=(0,Z.jsx)(`path`,{d:ne,strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:ie}),t[34]=ne,t[35]=ie,t[36]=ae):ae=t[36];let oe;t[37]===I?oe=t[38]:(oe=_S(mS,I),t[37]=I,t[38]=oe);let se=(!F||T)&&`ok-blob-eye-hidden`,ce;t[39]===se?ce=t[40]:(ce=mi(`ok-blob-happy-eye`,se),t[39]=se,t[40]=ce);let le;t[41]!==oe||t[42]!==ce?(le=(0,Z.jsx)(`path`,{d:oe,strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:ce}),t[41]=oe,t[42]=ce,t[43]=le):le=t[43];let J;t[44]===T?J=t[45]:(J=T?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`path`,{d:vS(pS),strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:`ok-blob-sleeping-eye`}),(0,Z.jsx)(`path`,{d:vS(mS),strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:`ok-blob-sleeping-eye`})]}):null,t[44]=T,t[45]=J);let ue;t[46]!==K||t[47]!==te||t[48]!==ae||t[49]!==le||t[50]!==J?(ue=(0,Z.jsxs)(`g`,{ref:p,children:[K,te,ae,le,J]}),t[46]=K,t[47]=te,t[48]=ae,t[49]=le,t[50]=J,t[51]=ue):ue=t[51];let de;t[52]!==B||t[53]!==H||t[54]!==ue?(de=(0,Z.jsxs)(`g`,{className:H,children:[U,ue]},B),t[52]=B,t[53]=H,t[54]=ue,t[55]=de):de=t[55];let fe;t[56]===T?fe=t[57]:(fe=T?(0,Z.jsxs)(`g`,{children:[(0,Z.jsx)(`text`,{x:21,y:7,className:`ok-blob-z ok-blob-z-1`,children:`z`}),(0,Z.jsx)(`text`,{x:26,y:2,className:`ok-blob-z ok-blob-z-2`,children:`z`})]}):null,t[56]=T,t[57]=fe);let pe;t[58]!==v||t[59]!==x?(pe=x.length>0&&(0,Z.jsx)(`g`,{children:x.map(CS)},`firework-${v}`),t[58]=v,t[59]=x,t[60]=pe):pe=t[60];let me;t[61]!==D||t[62]!==s||t[63]!==z||t[64]!==de||t[65]!==fe||t[66]!==pe?(me=(0,Z.jsxs)(`svg`,{ref:f,width:s,height:s,viewBox:`0 0 30 30`,fill:`none`,overflow:`visible`,xmlns:`http://www.w3.org/2000/svg`,className:z,"aria-hidden":`true`,onClick:D,onMouseDown:wS,children:[de,fe,pe]}),t[61]=D,t[62]=s,t[63]=z,t[64]=de,t[65]=fe,t[66]=pe,t[67]=me):me=t[67];let he;return t[68]!==R||t[69]!==me?(he=(0,Z.jsx)(`span`,{ref:d,className:R,children:me}),t[68]=R,t[69]=me,t[70]=he):he=t[70],he}function CS(e){return(0,Z.jsx)(`circle`,{cx:yS+e.originDx,cy:bS+e.originDy,r:e.size,className:`ok-blob-firework`,style:xS(e)},e.id)}function wS(e){return e.preventDefault()}function TS(e){return e+1}function ES(e){return e+1}function DS(e){let t=(0,$.c)(12),{title:n,subtitle:r,celebrateSignal:i}=e,a;t[0]===i?a=t[1]:(a=(0,Z.jsx)(SS,{size:64,celebrateSignal:i}),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,Z.jsx)(`h2`,{className:`text-2xl font-light tracking-tighter text-balance`,children:n}),t[2]=n,t[3]=o);let s;t[4]===r?s=t[5]:(s=r?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r}):null,t[4]=r,t[5]=s);let c;t[6]!==o||t[7]!==s?(c=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;return t[9]!==a||t[10]!==c?(l=(0,Z.jsxs)(`div`,{className:`flex items-center gap-4`,children:[a,c]}),t[9]=a,t[10]=c,t[11]=l):l=t[11],l}function OS(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=mi(`pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm bg-muted px-1 font-sans text-xs font-medium text-muted-foreground select-none in-data-[slot=tooltip-content]:bg-background/20 in-data-[slot=tooltip-content]:text-background dark:in-data-[slot=tooltip-content]:bg-background/10 [&_svg:not([class*='size-'])]:size-3`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`kbd`,{"data-slot":`kbd`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function kS(){let e=(0,$.c)(2),t=Dn()?`⌘ K`:`Ctrl K`,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(OS,{children:t}),e[0]=n):n=e[0];let r;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[n,` `,(0,Z.jsx)(`span`,{children:`Search`})]}),e[1]=r):r=e[1],r}var AS=`open-knowledge:create-top-level-file`;function jS(){window.dispatchEvent(new CustomEvent(AS))}function MS(e){let t=()=>e();return window.addEventListener(AS,t),()=>window.removeEventListener(AS,t)}function NS(){let e=(0,$.c)(14),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(void 0),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(0),l=(0,Q.useRef)(!1),u=(0,Q.useRef)(void 0),d,f;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{let e=!1,t=async function(){try{let t=await fetch(`/api/documents`),n=await t.json().catch(LS);if(e)return;let r=t.ok?li.safeParse(n):null;r?.success?(o(RS(r.data.documents)),l.current=!0):l.current||=(o(1),!0)}catch{!e&&!l.current&&(o(1),l.current=!0)}};t();let n=br(e=>{e.includes(`files`)&&t()});return()=>{e=!0,n(),clearTimeout(u.current)}},f=[],e[0]=d,e[1]=f):(d=e[0],f=e[1]),(0,Q.useEffect)(d,f);let p;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=function(){clearTimeout(u.current),u.current=setTimeout(()=>c(IS),500),fetch(`/api/documents`).then(async e=>{let t=await e.json().catch(FS);if(!e.ok)return;let n=li.safeParse(t);n.success&&o(RS(n.data.documents))}).catch(PS)},e[2]=p):p=e[2];let m=p,h=a!==null,g=a===0,_;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=function(e){n(e),e||i(void 0)},e[3]=_):_=e[3];let v=_,y;e[4]!==s||e[5]!==g||e[6]!==h?(y=h?g?(0,Z.jsx)(zS,{celebrateSignal:s,onPackSelect:e=>{i(e),n(!0)}}):(0,Z.jsx)(BS,{celebrateSignal:s,onAddStarterPack:()=>{n(!0)}}):null,e[4]=s,e[5]=g,e[6]=h,e[7]=y):y=e[7];let b;e[8]!==r||e[9]!==t?(b=(0,Z.jsx)(hm,{open:t,onOpenChange:v,onSeedApplied:m,initialPackId:r}),e[8]=r,e[9]=t,e[10]=b):b=e[10];let x;return e[11]!==y||e[12]!==b?(x=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center overflow-y-auto px-6 subtle-scrollbar`,children:[y,b]}),e[11]=y,e[12]=b,e[13]=x):x=e[13],x}function PS(){}function FS(){return null}function IS(e){return e+1}function LS(){return null}function RS(e){return ai(e).filter(e=>e.kind===`document`||e.kind===`folder`).length}function zS(e){let t=(0,$.c)(10),{celebrateSignal:n,onPackSelect:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(DS,{title:`Let's set up your project.`,subtitle:`Pick a starter pack to scaffold folders, templates, and AI-readable rules.`,celebrateSignal:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Z.jsx)(om,{onPackSelect:r}),t[2]=r,t[3]=a);let o;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsxs)(Y,{variant:`link`,className:`text-muted-foreground font-normal justify-end`,size:`sm`,onClick:jS,children:[`or start from scratch `,(0,Z.jsx)(Zi,{"aria-hidden":`true`,className:`size-3`})]}),t[4]=o):o=t[4];let s;t[5]===a?s=t[6]:(s=(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-3`,children:[a,o]}),t[5]=a,t[6]=s);let c;return t[7]!==i||t[8]!==s?(c=(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-10 py-12 max-w-5xl my-auto`,children:[i,s]}),t[7]=i,t[8]=s,t[9]=c):c=t[9],c}function BS(e){let t=(0,$.c)(12),{celebrateSignal:n,onAddStarterPack:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(DS,{title:`Open in your favorite AI editor.`,subtitle:`Select a file from the sidebar, or pick where to edit alongside your agent.`,celebrateSignal:n}),t[0]=n,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Zx,{}),t[2]=a):a=t[2];let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(ce,{"aria-hidden":`true`,className:`size-3`}),t[3]=o):o=t[3];let s;t[4]===r?s=t[5]:(s=(0,Z.jsxs)(Y,{onClick:r,variant:`link`,size:`xs`,className:`font-mono text-2xs uppercase tracking-wider text-muted-foreground font-normal hover:text-foreground hover:no-underline`,children:[o,`Add a starter pack`]}),t[4]=r,t[5]=s);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(kS,{}),t[6]=c):c=t[6];let l;t[7]===s?l=t[8]:(l=(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[a,(0,Z.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-4`,children:[s,c]})]}),t[7]=s,t[8]=l);let u;return t[9]!==i||t[10]!==l?(u=(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-10 py-12 max-w-5xl my-auto`,children:[i,l]}),t[9]=i,t[10]=l,t[11]=u):u=t[11],u}function VS(e){let t=(0,$.c)(74),{folderPath:n,state:r,onChange:i}=e,[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null);if(r.status===`idle`||r.status===`loading`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`section`,{className:`rounded-lg border bg-card p-4 space-y-3`,children:[(0,Z.jsx)(US,{}),(0,Z.jsx)(Ma,{className:`h-7 w-full`}),(0,Z.jsx)(Ma,{className:`h-7 w-full`}),(0,Z.jsx)(Ma,{className:`h-7 w-full`})]}),t[0]=e):e=t[0],e}if(r.status===`error`){let e;return t[1]===r.message?e=t[2]:(e=(0,Z.jsxs)(`section`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive`,role:`alert`,children:[`Failed to load folder defaults: `,r.message]}),t[1]=r.message,t[2]=e),e}let d;t[3]===r.data.folder.frontmatter_defaults?d=t[4]:(d=r.data.folder.frontmatter_defaults??{},t[3]=r.data.folder.frontmatter_defaults,t[4]=d);let f=d,p;t[5]===r.data.frontmatterLocal?p=t[6]:(p=r.data.frontmatterLocal??{},t[5]=r.data.frontmatterLocal,t[6]=p);let m=p,h=r.data.frontmatterSources,g;t[7]===r.data.folder.path?g=t[8]:(g=uo(r.data.folder.path),t[7]=r.data.folder.path,t[8]=g);let _=g,v,y,b,x,S,C,w,T,E,D,O,k,A;if(t[9]!==s||t[10]!==a||t[11]!==_||t[12]!==n||t[13]!==m||t[14]!==f||t[15]!==i||t[16]!==l||t[17]!==h){let e=Object.keys(f),r=async function(e,t){let r=await co(n,{[e]:t});if(!r.ok){X.error(`Save failed: ${r.error}`);return}i()},d=async function(e){let t=await co(n,{[e]:null});if(!t.ok){X.error(`Remove failed: ${t.error}`);return}i()},p=function(e,t){let n=f[e];r(e,Ji(n,t))},g;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(g=function(){c({name:``,type:`text`,value:``,error:null}),o(!1)},t[31]=g):g=t[31],b=g;let j;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(j=function(e){c(t=>{if(!t)return t;let n=e===`date`?new Date().toISOString().slice(0,10):ha[e];return{...t,type:e,value:n,error:null}})},t[32]=j):j=t[32],S=j;let M;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(M=function(e){c(t=>t&&{...t,value:e})},t[33]=M):M=t[33],C=M;let N;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(N=function(e){c(t=>t&&{...t,name:e,error:null})},t[34]=N):N=t[34],x=N;let P;t[35]!==s||t[36]!==n||t[37]!==f||t[38]!==i?(P=async function(){if(!s)return;let e=s.name.trim();if(!e){c({...s,error:`Name is required`});return}if(Object.hasOwn(f,e)){c({...s,error:`Key "${e}" already resolves here`});return}let t=await co(n,{[e]:s.value});if(!t.ok){c({...s,error:t.error});return}c(null),i()},t[35]=s,t[36]=n,t[37]=f,t[38]=i,t[39]=P):P=t[39],w=P;let F=function(e){u({key:e,draft:e,error:null})},I=function(e){u(t=>t&&{...t,draft:e,error:null})},L=async function(){if(!l)return;let e=l.draft.trim();if(!e){u({...l,error:`Name is required`});return}if(e===l.key){u(null);return}if(Object.hasOwn(f,e)){u({...l,error:`Key "${e}" already resolves here`});return}let t=f[l.key],r=await co(n,{[l.key]:null,[e]:t});if(!r.ok){u({...l,error:r.error});return}u(null),i()},R=function(){u(null)};A=`rounded-lg border bg-card`,y=Lo,D=!a,t[40]===Symbol.for(`react.memo_cache_sentinel`)?(O=e=>o(!e),t[40]=O):O=t[40];let z=`size-3 transition-transform ${a?``:`rotate-90`}`,B;t[41]===z?B=t[42]:(B=(0,Z.jsx)(No,{className:z,"aria-hidden":!0}),t[41]=z,t[42]=B);let V;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsx)(`span`,{children:`Folder defaults`}),t[43]=V):V=t[43];let H;t[44]===B?H=t[45]:(H=(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase font-mono tracking-wider text-muted-foreground`,children:[B,V]}),t[44]=B,t[45]=H);let U;t[46]===_?U=t[47]:(U=(0,Z.jsx)(`code`,{className:`text-xs text-muted-foreground font-mono cursor-text select-text`,onClick:HS,children:_}),t[46]=_,t[47]=U),t[48]!==H||t[49]!==U?(k=(0,Z.jsxs)(Io,{className:`flex w-full cursor-pointer items-center justify-between gap-2 px-3 py-2.5 data-[state=open]:border-b border-border`,children:[H,U]}),t[48]=H,t[49]=U,t[50]=k):k=t[50],v=Fo,T=`px-2 py-2`,E=e.length===0&&!s?(0,Z.jsx)(`p`,{className:`px-1 py-1 text-sm text-muted-foreground`,children:`No defaults declared. Add a property to set a value every doc in this folder inherits.`}):e.map(e=>{let t=f[e],n=Object.hasOwn(m,e);return(0,Z.jsx)(Wi,{keyName:e,value:t,declared:Ki(t,tr(t)),rename:n?{state:l?.key===e?l:null,onBegin:()=>F(e),onChangeDraft:I,onCommit:L,onCancel:R}:void 0,badge:n?null:(0,Z.jsx)(oo,{source:h[e]??``}),isInherited:!n,onCommit:t=>void r(e,t),onChangeType:t=>p(e,t),onRemove:n?()=>void d(e):void 0},e)}),t[9]=s,t[10]=a,t[11]=_,t[12]=n,t[13]=m,t[14]=f,t[15]=i,t[16]=l,t[17]=h,t[18]=v,t[19]=y,t[20]=b,t[21]=x,t[22]=S,t[23]=C,t[24]=w,t[25]=T,t[26]=E,t[27]=D,t[28]=O,t[29]=k,t[30]=A}else v=t[18],y=t[19],b=t[20],x=t[21],S=t[22],C=t[23],w=t[24],T=t[25],E=t[26],D=t[27],O=t[28],k=t[29],A=t[30];let j;t[51]!==s||t[52]!==b||t[53]!==x||t[54]!==S||t[55]!==C||t[56]!==w?(j=s?(0,Z.jsx)(pa,{draft:s,onChangeName:x,onChangeType:S,onChangeValue:C,onCommit:()=>void w(),onCancel:()=>c(null)}):(0,Z.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`add-property-trigger`,onClick:b,className:`mt-1 flex items-center gap-1.5 rounded px-2 py-1 font-medium text-sm hover:bg-muted/50 hover:text-foreground`,children:[(0,Z.jsx)(ce,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:`Add property`})]}),t[51]=s,t[52]=b,t[53]=x,t[54]=S,t[55]=C,t[56]=w,t[57]=j):j=t[57];let M;t[58]!==j||t[59]!==T||t[60]!==E?(M=(0,Z.jsxs)(`div`,{className:T,children:[E,j]}),t[58]=j,t[59]=T,t[60]=E,t[61]=M):M=t[61];let N;t[62]!==v||t[63]!==M?(N=(0,Z.jsx)(v,{children:M}),t[62]=v,t[63]=M,t[64]=N):N=t[64];let P;t[65]!==y||t[66]!==N||t[67]!==D||t[68]!==O||t[69]!==k?(P=(0,Z.jsxs)(y,{open:D,onOpenChange:O,children:[k,N]}),t[65]=y,t[66]=N,t[67]=D,t[68]=O,t[69]=k,t[70]=P):P=t[70];let F;return t[71]!==P||t[72]!==A?(F=(0,Z.jsx)(`section`,{className:A,children:P}),t[71]=P,t[72]=A,t[73]=F):F=t[73],F}function HS(e){return e.stopPropagation()}function US(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(lc,{className:`size-4 text-muted-foreground`,"aria-hidden":!0}),(0,Z.jsx)(`h2`,{className:`text-xs font-semibold uppercase font-mono tracking-wider text-muted-foreground`,children:`Folder defaults`})]}),e[0]=t):t=e[0],t}function WS(e){let t=e.split(`/`).pop();return t?`${e}/${t}`:null}function GS(e,t){let n=t.get(`${e}/index`);if(n)return n;let r=WS(e);if(r){let e=t.get(r);if(e)return e}return e.split(`/`).pop()??e}function KS(e,t,n){let r=n.get(e);return r&&r!==e?r:t}function qS(e,t){let n=`${e}/`,r=[...t.folderPaths].filter(e=>e.startsWith(n)).map(e=>({path:e,rel:e.slice(n.length)})).filter(e=>e.rel.length>0&&!e.rel.includes(`/`)).map(({path:e,rel:n})=>({kind:`folder`,path:e,name:n,title:GS(e,t.pageTitles)})),i=[...t.pages].filter(e=>e.startsWith(n)).map(e=>({docName:e,rel:e.slice(n.length)})).filter(e=>e.rel.length>0&&!e.rel.includes(`/`)).map(({docName:e,rel:n})=>{let r=t.pageMeta.get(e);return{kind:`file`,path:e,name:n,title:KS(e,n,t.pageTitles),size:r?.size??0,modified:r?.modified??``}}),a=[...r,...i].sort((e,t)=>e.kind===t.kind?e.title.localeCompare(t.title)||e.name.localeCompare(t.name):e.kind===`folder`?-1:1);return{title:GS(e,t.pageTitles),children:a}}function JS(e){let t=(0,$.c)(52),{folderPath:n,state:r,onChange:i,folderConfigHandle:a}=e,[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!1),g;t[0]===i?g=t[1]:(g=async function(e){p(!0);let t=await Da(e.source_folder,e.name);if(p(!1),!t.ok){X.error(`Delete failed: ${t.error}`);return}X.success(`Template "${e.name}" deleted`),l(null),i()},t[0]=i,t[1]=g);let _=g;if(r.status===`idle`||r.status===`loading`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`section`,{className:`rounded-lg border bg-card px-3 py-2.5 space-y-3`,children:[(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(`h2`,{className:`text-xs font-semibold uppercase font-mono tracking-wider text-muted-foreground`,children:`Templates available`})}),(0,Z.jsx)(Ma,{className:`h-12 w-full`}),(0,Z.jsx)(Ma,{className:`h-12 w-full`})]}),t[2]=e):e=t[2],e}if(r.status===`error`){let e;return t[3]===r.message?e=t[4]:(e=(0,Z.jsxs)(`section`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive`,role:`alert`,children:[`Failed to load templates: `,r.message]}),t[3]=r.message,t[4]=e),e}let v;t[5]===r.data.folder.templates_available?v=t[6]:(v=r.data.folder.templates_available??[],t[5]=r.data.folder.templates_available,t[6]=v);let y=v,b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(`h2`,{className:`text-xs font-semibold uppercase font-mono tracking-wider text-muted-foreground`,children:`Templates available`}),t[7]=b):b=t[7];let x;t[8]===y.length?x=t[9]:(x=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b,(0,Z.jsx)(Ge,{className:`text-xs`,variant:`secondary`,children:y.length})]}),t[8]=y.length,t[9]=x);let S;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsxs)(Y,{variant:`ghost`,className:`font-mono uppercase`,size:`sm`,onClick:()=>h(!0),children:[(0,Z.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0}),`New template`]}),t[10]=S):S=t[10];let C;t[11]===x?C=t[12]:(C=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-1`,children:[x,S]}),t[11]=x,t[12]=C);let w;t[13]===y?w=t[14]:(w=(0,Z.jsx)(`div`,{className:`px-3 py-2.5`,children:y.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No templates resolve here. Add one to seed new docs in this folder.`}):(0,Z.jsx)(`ul`,{className:`space-y-1`,children:y.map(e=>(0,Z.jsx)(XS,{template:e,onCreate:()=>d(e.name),onEdit:()=>s(e),onDelete:()=>l(e)},e.path))})}),t[13]=y,t[14]=w);let T;t[15]!==C||t[16]!==w?(T=(0,Z.jsxs)(`section`,{className:`rounded-lg border bg-card`,children:[C,w]}),t[15]=C,t[16]=w,t[17]=T):T=t[17];let E;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>{e||s(null)},t[18]=E):E=t[18];let D;t[19]!==o||t[20]!==n||t[21]!==i?(D=(0,Z.jsx)(Na,{folderPath:n,template:o,onOpenChange:E,onSaved:i}),t[19]=o,t[20]=n,t[21]=i,t[22]=D):D=t[22];let O=!!c,k;t[23]===f?k=t[24]:(k=e=>{!e&&!f&&l(null)},t[23]=f,t[24]=k);let A;t[25]!==c||t[26]!==f||t[27]!==_?(A=c&&(0,Z.jsx)(io,{itemName:`template "${c.name}"`,isSubmitting:f,onDelete:()=>_(c),customDescription:`This permanently removes ${c.path}. Agents that reference this template by name will fail until it's recreated or shadowed by an ancestor.${c.scope===`inherited`?`
|
|
28
28
|
|
|
29
|
-
This template lives at an ancestor folder — deleting affects every folder under that ancestor that does not shadow it locally.`:``}`}),t[25]=c,t[26]=f,t[27]=_,t[28]=A):A=t[28];let j;t[29]!==O||t[30]!==k||t[31]!==A?(j=(0,Z.jsx)(jo,{open:O,onOpenChange:k,children:A}),t[29]=O,t[30]=k,t[31]=A,t[32]=j):j=t[32];let M;t[33]===y?M=t[34]:(M=new Set(y.map(YS)),t[33]=y,t[34]=M);let N;t[35]!==n||t[36]!==m||t[37]!==i||t[38]!==M?(N=(0,Z.jsx)(Ca,{folderPath:n,existingNames:M,open:m,onOpenChange:h,onCreated:i}),t[35]=n,t[36]=m,t[37]=i,t[38]=M,t[39]=N):N=t[39];let P=u!==null,F;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>{e||d(null)},t[40]=F):F=t[40];let I=u??void 0,L;t[41]!==a||t[42]!==n||t[43]!==P||t[44]!==I?(L=(0,Z.jsx)(Hp,{open:P,onOpenChange:F,kind:`file`,initialDir:n,initialTemplate:I,folderConfig:a}),t[41]=a,t[42]=n,t[43]=P,t[44]=I,t[45]=L):L=t[45];let R;return t[46]!==D||t[47]!==j||t[48]!==N||t[49]!==L||t[50]!==T?(R=(0,Z.jsxs)(Z.Fragment,{children:[T,D,j,N,L]}),t[46]=D,t[47]=j,t[48]=N,t[49]=L,t[50]=T,t[51]=R):R=t[51],R}function YS(e){return e.name}function XS(e){let t=(0,$.c)(42),{template:n,onCreate:r,onEdit:i,onDelete:a}=e,o=n.title&&n.title!==n.name,s=n.title??n.name,c;t[0]===s?c=t[1]:(c=(0,Z.jsx)(`span`,{className:`font-medium truncate`,children:s}),t[0]=s,t[1]=c);let l;t[2]!==o||t[3]!==n.name?(l=o?(0,Z.jsx)(`code`,{className:`font-mono text-xs text-muted-foreground shrink-0`,children:n.name}):null,t[2]=o,t[3]=n.name,t[4]=l):l=t[4];let u;t[5]!==n.name||t[6]!==n.scope||t[7]!==n.source_folder?(u=n.scope===`inherited`?(0,Z.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,Z.jsx)(oo,{source:n.source_folder,target:`templates/${n.name}.md`})}):null,t[5]=n.name,t[6]=n.scope,t[7]=n.source_folder,t[8]=u):u=t[8];let d;t[9]!==c||t[10]!==l||t[11]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[c,l,u]}),t[9]=c,t[10]=l,t[11]=u,t[12]=d):d=t[12];let f;t[13]===n.description?f=t[14]:(f=n.description?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground truncate mt-0.5`,children:n.description}):null,t[13]=n.description,t[14]=f);let p;t[15]!==i||t[16]!==d||t[17]!==f?(p=(0,Z.jsxs)(`button`,{type:`button`,onClick:i,className:`min-w-0 flex-1 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm`,children:[d,f]}),t[15]=i,t[16]=d,t[17]=f,t[18]=p):p=t[18];let h=`Create note from ${s}`,g;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(oc,{className:`size-3.5`,"aria-hidden":!0}),t[19]=g):g=t[19];let _;t[20]!==r||t[21]!==h?(_=(0,Z.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`font-mono uppercase shrink-0 opacity-0 group-hover:opacity-100 focus-visible:opacity-100`,onClick:r,"aria-label":h,children:[g,`Create`]}),t[20]=r,t[21]=h,t[22]=_):_=t[22];let v=`Actions for ${s}`,y;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(oa,{className:`size-4`,"aria-hidden":!0}),t[23]=y):y=t[23];let b;t[24]===v?b=t[25]:(b=(0,Z.jsx)(ba,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon`,className:`size-7 shrink-0 opacity-0 group-hover:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100`,"aria-label":v,children:y})}),t[24]=v,t[25]=b);let x;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(m,{"aria-hidden":!0}),t[26]=x):x=t[26];let S;t[27]===i?S=t[28]:(S=(0,Z.jsxs)(ya,{onSelect:i,children:[x,`Edit`]}),t[27]=i,t[28]=S);let C;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(Ue,{"aria-hidden":!0}),t[29]=C):C=t[29];let w;t[30]===a?w=t[31]:(w=(0,Z.jsxs)(ya,{variant:`destructive`,onSelect:a,children:[C,`Delete`]}),t[30]=a,t[31]=w);let T;t[32]!==S||t[33]!==w?(T=(0,Z.jsxs)(_a,{align:`end`,children:[S,w]}),t[32]=S,t[33]=w,t[34]=T):T=t[34];let E;t[35]!==b||t[36]!==T?(E=(0,Z.jsxs)(va,{children:[b,T]}),t[35]=b,t[36]=T,t[37]=E):E=t[37];let D;return t[38]!==E||t[39]!==p||t[40]!==_?(D=(0,Z.jsxs)(`li`,{className:`group flex items-center gap-2 rounded-md px-2 py-2 hover:bg-muted/50 text-sm`,children:[p,_,E]}),t[38]=E,t[39]=p,t[40]=_,t[41]=D):D=t[41],D}function ZS(e){let t=(0,$.c)(14),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,containerClassName:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=mi(`relative w-full overflow-x-auto subtle-scrollbar`,r),t[4]=r,t[5]=a);let o;t[6]===n?o=t[7]:(o=mi(`w-full caption-bottom text-sm`,n),t[6]=n,t[7]=o);let s;t[8]!==i||t[9]!==o?(s=(0,Z.jsx)(`table`,{"data-slot":`table`,className:o,...i}),t[8]=i,t[9]=o,t[10]=s):s=t[10];let c;return t[11]!==a||t[12]!==s?(c=(0,Z.jsx)(`div`,{"data-slot":`table-container`,className:a,children:s}),t[11]=a,t[12]=s,t[13]=c):c=t[13],c}function QS(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=mi(`[&_tr]:border-b`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`thead`,{"data-slot":`table-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function $S(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=mi(`[&_tr:last-child]:border-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`tbody`,{"data-slot":`table-body`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function eC(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,noHover:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=(i===void 0?!1:i)&&`hover:bg-transparent`,o;t[4]!==n||t[5]!==a?(o=mi(`hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors`,a,n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==o?(s=(0,Z.jsx)(`tr`,{"data-slot":`table-row`,className:o,...r}),t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function tC(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,scope:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`col`:i,o;t[4]===n?o=t[5]:(o=mi(`font-mono uppercase text-xs text-muted-foreground h-10 px-4 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,n),t[4]=n,t[5]=o);let s;return t[6]!==r||t[7]!==a||t[8]!==o?(s=(0,Z.jsx)(`th`,{"data-slot":`table-head`,scope:a,className:o,...r}),t[6]=r,t[7]=a,t[8]=o,t[9]=s):s=t[9],s}function nC(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=mi(`py-3 px-4 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`td`,{"data-slot":`table-cell`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function rC(e){if(!e)return`—`;let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<30?`${a}d ago`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function iC(e,t,n){return[...e].sort((e,r)=>{if(e.kind!==r.kind)return e.kind===`folder`?-1:1;let i=0;switch(t){case`name`:i=e.title.localeCompare(r.title)||e.name.localeCompare(r.name);break;case`modified`:{let t=e.kind===`file`?e.modified:``,n=r.kind===`file`?r.modified:``;i=t.localeCompare(n);break}}return n===`asc`?i:-i})}function aC(e){let t=(0,$.c)(10),{label:n,sortKey:r,activeKey:i,activeDir:a,onSort:o}=e,s=i===r,c;t[0]!==o||t[1]!==r?(c=()=>o(r),t[0]=o,t[1]=r,t[2]=c):c=t[2];let l;t[3]!==a||t[4]!==s?(l=s?a===`asc`?(0,Z.jsx)(xe,{className:`ml-1 size-3`}):(0,Z.jsx)(Ee,{className:`ml-1 size-3`}):(0,Z.jsx)(zs,{className:`ml-1 size-3 text-muted-foreground/50`}),t[3]=a,t[4]=s,t[5]=l):l=t[5];let u;return t[6]!==n||t[7]!==c||t[8]!==l?(u=(0,Z.jsxs)(Y,{variant:`ghost`,size:`sm`,className:`-ml-3 h-8 uppercase font-mono`,onClick:c,children:[n,l]}),t[6]=n,t[7]=c,t[8]=l,t[9]=u):u=t[9],u}function oC(e){let t=(0,$.c)(81),{folderPath:n}=e,{folderPaths:r,loading:i,pages:a,pageTitles:o,pageMeta:s}=qr(),c=Aa(n),{state:l,refresh:u}=c,[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(`name`),[h,g]=(0,Q.useState)(`asc`);if(i){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Ma,{className:`size-5 rounded`}),(0,Z.jsx)(Ma,{className:`h-7 w-48`})]}),(0,Z.jsx)(Ma,{className:`h-9 w-20 rounded-md`})]}),t[0]=e):e=t[0];let n;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(Ma,{className:`h-4 w-16`}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start overflow-y-auto subtle-scrollbar`,role:`status`,"aria-busy":`true`,"aria-label":`Loading folder contents`,children:(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-8`,children:[e,(0,Z.jsxs)(`div`,{className:`rounded-lg border`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-4 border-b px-4 py-3`,children:[n,(0,Z.jsx)(`div`,{className:`ml-auto`,children:(0,Z.jsx)(Ma,{className:`h-4 w-20`})})]}),[`a`,`b`,`c`,`d`].map(lC)]})]})}),t[2]=r):r=t[2],r}let _,v,y,b,x,S,C,w,T,E;if(t[3]!==l||t[4]!==c||t[5]!==n||t[6]!==r||t[7]!==s||t[8]!==o||t[9]!==a||t[10]!==u||t[11]!==h||t[12]!==p){let e=qS(n,{pages:a,pageTitles:o,pageMeta:s,folderPaths:r}),i=iC(e.children,p,h),d;t[23]===p?d=t[24]:(d=function(e){e===p?g(cC):(m(e),g(`asc`))},t[23]=p,t[24]=d);let D=d;E=`flex min-h-0 flex-1 items-start overflow-y-auto subtle-scrollbar`,S=`mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-8`;let O;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(R,{className:`size-5 text-muted-foreground`}),t[25]=O):O=t[25];let k=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[O,(0,Z.jsx)(`h1`,{className:`text-2xl font-light tracking-tight`,children:e.title})]}),A;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsxs)(Y,{onClick:()=>f(!0),children:[(0,Z.jsx)(ce,{className:`size-4`}),`New`]}),t[26]=A):A=t[26],t[27]===k?C=t[28]:(C=(0,Z.jsx)(`div`,{className:`flex flex-col gap-6`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[k,A]})}),t[27]=k,t[28]=C),t[29]!==l||t[30]!==n||t[31]!==u?(w=(0,Z.jsx)(VS,{folderPath:n,state:l,onChange:u}),t[29]=l,t[30]=n,t[31]=u,t[32]=w):w=t[32],t[33]!==l||t[34]!==c||t[35]!==n||t[36]!==u?(T=(0,Z.jsx)(JS,{folderPath:n,state:l,onChange:u,folderConfigHandle:c}),t[33]=l,t[34]=c,t[35]=n,t[36]=u,t[37]=T):T=t[37],x=`rounded-lg border`,v=ZS;let j=p===`name`?h===`asc`?`ascending`:`descending`:`none`,M;t[38]!==D||t[39]!==h||t[40]!==p?(M=(0,Z.jsx)(aC,{label:`Name`,sortKey:`name`,activeKey:p,activeDir:h,onSort:D}),t[38]=D,t[39]=h,t[40]=p,t[41]=M):M=t[41];let N;t[42]!==j||t[43]!==M?(N=(0,Z.jsx)(tC,{"aria-sort":j,children:M}),t[42]=j,t[43]=M,t[44]=N):N=t[44];let P=p===`modified`?h===`asc`?`ascending`:`descending`:`none`,F;t[45]!==D||t[46]!==h||t[47]!==p?(F=(0,Z.jsx)(aC,{label:`Modified`,sortKey:`modified`,activeKey:p,activeDir:h,onSort:D}),t[45]=D,t[46]=h,t[47]=p,t[48]=F):F=t[48];let I;t[49]!==P||t[50]!==F?(I=(0,Z.jsx)(tC,{className:`w-32`,"aria-sort":P,children:F}),t[49]=P,t[50]=F,t[51]=I):I=t[51],t[52]!==N||t[53]!==I?(b=(0,Z.jsx)(QS,{children:(0,Z.jsxs)(eC,{children:[N,I]})}),t[52]=N,t[53]=I,t[54]=b):b=t[54],_=$S,y=i.length?i.map(sC):(0,Z.jsx)(eC,{children:(0,Z.jsx)(nC,{colSpan:2,className:`h-24 text-center text-muted-foreground`,children:`This folder is empty.`})}),t[3]=l,t[4]=c,t[5]=n,t[6]=r,t[7]=s,t[8]=o,t[9]=a,t[10]=u,t[11]=h,t[12]=p,t[13]=_,t[14]=v,t[15]=y,t[16]=b,t[17]=x,t[18]=S,t[19]=C,t[20]=w,t[21]=T,t[22]=E}else _=t[13],v=t[14],y=t[15],b=t[16],x=t[17],S=t[18],C=t[19],w=t[20],T=t[21],E=t[22];let D;t[55]!==_||t[56]!==y?(D=(0,Z.jsx)(_,{children:y}),t[55]=_,t[56]=y,t[57]=D):D=t[57];let O;t[58]!==v||t[59]!==b||t[60]!==D?(O=(0,Z.jsxs)(v,{children:[b,D]}),t[58]=v,t[59]=b,t[60]=D,t[61]=O):O=t[61];let k;t[62]!==O||t[63]!==x?(k=(0,Z.jsx)(`div`,{className:x,children:O}),t[62]=O,t[63]=x,t[64]=k):k=t[64];let A;t[65]!==k||t[66]!==S||t[67]!==C||t[68]!==w||t[69]!==T?(A=(0,Z.jsxs)(`div`,{className:S,children:[C,w,T,k]}),t[65]=k,t[66]=S,t[67]=C,t[68]=w,t[69]=T,t[70]=A):A=t[70];let j;t[71]!==A||t[72]!==E?(j=(0,Z.jsx)(`div`,{className:E,children:A}),t[71]=A,t[72]=E,t[73]=j):j=t[73];let M;t[74]!==d||t[75]!==c||t[76]!==n?(M=(0,Z.jsx)(Hp,{open:d,onOpenChange:f,kind:`file`,initialDir:n,folderConfig:c,suggestedName:`index`}),t[74]=d,t[75]=c,t[76]=n,t[77]=M):M=t[77];let N;return t[78]!==j||t[79]!==M?(N=(0,Z.jsxs)(Z.Fragment,{children:[j,M]}),t[78]=j,t[79]=M,t[80]=N):N=t[80],N}function sC(e){return(0,Z.jsxs)(eC,{children:[(0,Z.jsx)(nC,{children:(0,Z.jsxs)(`a`,{href:Tr(e.path),className:`flex items-center gap-2 rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[e.kind===`folder`?(0,Z.jsx)(dc,{className:`size-4 shrink-0 text-muted-foreground`}):(0,Z.jsx)(ae,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.title})]})}),(0,Z.jsx)(nC,{className:`text-muted-foreground`,children:e.kind===`file`?rC(e.modified):`—`})]},e.path)}function cC(e){return e===`asc`?`desc`:`asc`}function lC(e){return(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 border-b px-4 py-3 last:border-b-0`,children:[(0,Z.jsx)(Ma,{className:`size-4 rounded`}),(0,Z.jsx)(Ma,{className:`h-4 w-40`}),(0,Z.jsx)(`div`,{className:`ml-auto`,children:(0,Z.jsx)(Ma,{className:`h-4 w-16`})})]},e)}function uC(e){let t=(0,$.c)(7),{docName:n}=e,[r,i]=(0,Q.useState)(dC),a,o;if(t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>Pt(e=>{i(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})}),o=[],t[0]=a,t[1]=o):(a=t[0],o=t[1]),(0,Q.useEffect)(a,o),!r.has(n))return null;let s;t[2]===n?s=t[3]:(s=function(){We(n)?.abort(),i(e=>{if(!e.has(n))return e;let t=new Set(e);return t.delete(n),t})},t[2]=n,t[3]=s);let c=s,l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`span`,{children:`Still loading`}),t[4]=l):l=t[4];let u;return t[5]===c?u=t[6]:(u=(0,Z.jsxs)(`div`,{className:`absolute inset-x-0 bottom-8 z-20 flex justify-center text-xs text-muted-foreground`,children:[l,(0,Z.jsx)(Y,{variant:`link`,size:`sm`,className:`h-auto px-2 py-0 text-xs`,onClick:c,children:`Cancel`})]}),t[5]=c,t[6]=u),u}function dC(){return new Set}var fC=(0,Q.createContext)(null);function pC(e){let t=(0,$.c)(7),{children:n}=e,[r,i]=(0,Q.useState)(mC),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>{i(t=>{let n=new Map(t);return n.set(e,(t.get(e)??0)+1),n})},t[0]=a):a=t[0];let o=a,s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=e=>{i(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},t[1]=s):s=t[1];let c=s,l;t[2]===r?l=t[3]:(l={addPropertySignal:r,requestAddProperty:o,clearAddProperty:c},t[2]=r,t[3]=l);let u=l,d;return t[4]!==n||t[5]!==u?(d=(0,Z.jsx)(fC,{value:u,children:n}),t[4]=n,t[5]=u,t[6]=d):d=t[6],d}function mC(){return new Map}function hC(){let e=(0,Q.use)(fC);if(e===null)throw Error(`useProperties must be used within <PropertyProvider />`);return e}function gC(e){let t=null,n=()=>(t===null&&(t=e(),t.catch(()=>{})),t),r=(0,Q.lazy)(n);return r.preload=n,r}var _C=gC(()=>n(()=>import(`./SettingsDialogBody-alvj4xbx.js`).then(e=>({default:e.SettingsDialogBody})),__vite__mapDeps([42,1,33,2,34,35,20,36,37,38,39,19,3,6,7,4,10,9,40,43,8,14,21,11]),import.meta.url));function vC(e){let t=(0,$.c)(6),{error:n}=e,r=n instanceof Error&&/dynamically imported module|Failed to fetch/i.test(n.message)?`A newer version may have been deployed since this tab opened.`:`Something went wrong loading the settings panel.`,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`h3`,{id:`settings-body-error-title`,className:`font-heading text-base leading-none font-medium`,children:`Settings failed to load`}),t[0]=i):i=t[0];let a;t[1]===r?a=t[2]:(a=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[i,(0,Z.jsx)(`p`,{className:`max-w-xs text-sm text-muted-foreground`,children:r})]}),t[1]=r,t[2]=a);let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(Y,{variant:`default`,onClick:yC,children:`Reload`}),t[3]=o):o=t[3];let s;return t[4]===a?s=t[5]:(s=(0,Z.jsxs)(`div`,{role:`alert`,"aria-labelledby":`settings-body-error-title`,"data-slot":`settings-body-error-boundary`,className:`flex h-full flex-col items-center justify-center gap-5 p-8 text-center`,children:[a,o]}),t[4]=a,t[5]=s),s}function yC(){return window.location.reload()}function bC(e){let t=(0,$.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(O,{fallbackRender:SC,onError:xC,children:n}),t[0]=n,t[1]=r),r}function xC(e,t){console.error(`[SettingsDialogErrorBoundary] rendered fallback for Settings body`,e,t.componentStack)}function SC(e){return(0,Z.jsx)(vC,{...e})}function CC(e){let t=(0,$.c)(30),{open:n,onOpenChange:r}=e,{collabUrl:i}=ot(),{userBinding:a,userSynced:o,okignoreBinding:s,okignoreSynced:c}=Ga(),{desktopPresent:l}=Fa(),[u,d]=(0,Q.useState)(`preferences`),f,p;t[0]===n?(f=t[1],p=t[2]):(f=()=>{n&&d(`preferences`)},p=[n],t[0]=n,t[1]=f,t[2]=p),(0,Q.useEffect)(f,p);let m=i!==null,h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h={id:`user`,label:`User`,enabled:!0,items:[{id:`preferences`,label:`Preferences`}]},t[3]=h):h=t[3];let g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=[{id:`sync`,label:`Sync`},{id:`project-templates`,label:`Templates`},{id:`okignore`,label:`Ignore patterns`}],t[4]=g):g=t[4];let _;t[5]===m?_=t[6]:(_={id:`project`,label:`This project`,enabled:m,items:g},t[5]=m,t[6]=_);let v;t[7]===l?v=t[8]:(v={id:`integrations`,label:`Integrations`,enabled:!0,items:l?[{id:`claude-desktop`,label:`Claude Desktop`}]:[]},t[7]=l,t[8]=v);let y;t[9]!==_||t[10]!==v?(y=[h,_,v],t[9]=_,t[10]=v,t[11]=y):y=t[11];let b=y,x,S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(bo,{className:`sr-only`,children:`Settings`}),S=(0,Z.jsx)(vo,{className:`sr-only`,children:`Configure user, project, and integration settings.`}),t[12]=x,t[13]=S):(x=t[12],S=t[13]);let C;t[14]!==u||t[15]!==b?(C=(0,Z.jsx)(wC,{groups:b,activeId:u,onSelect:d}),t[14]=u,t[15]=b,t[16]=C):C=t[16];let w;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(EC,{}),t[17]=w):w=t[17];let T=o?a:null,E;t[18]!==u||t[19]!==s||t[20]!==c||t[21]!==T?(E=(0,Z.jsx)(`div`,{className:`min-h-0 overflow-y-auto overscroll-contain subtle-scrollbar p-6`,children:(0,Z.jsx)(bC,{children:(0,Z.jsx)(Q.Suspense,{fallback:w,children:(0,Z.jsx)(_C,{activeId:u,userBinding:T,okignoreBinding:s,okignoreSynced:c})})})}),t[18]=u,t[19]=s,t[20]=c,t[21]=T,t[22]=E):E=t[22];let D;t[23]!==C||t[24]!==E?(D=(0,Z.jsxs)(wo,{className:`grid h-[700px] max-h-[calc(100dvh-4rem)] w-[900px] max-w-[calc(100%-2rem)] grid-cols-[220px_1fr] gap-0 overflow-hidden p-0 sm:max-w-[900px]`,"data-testid":`settings-dialog`,children:[x,S,C,E]}),t[23]=C,t[24]=E,t[25]=D):D=t[25];let O;return t[26]!==r||t[27]!==n||t[28]!==D?(O=(0,Z.jsx)(jo,{open:n,onOpenChange:r,children:D}),t[26]=r,t[27]=n,t[28]=D,t[29]=O):O=t[29],O}function wC(e){let t=(0,$.c)(9),{groups:n,activeId:r,onSelect:i}=e,a;if(t[0]!==r||t[1]!==n||t[2]!==i){let e;t[4]!==r||t[5]!==i?(e=e=>(0,Z.jsx)(TC,{group:e,activeId:r,onSelect:i},e.id),t[4]=r,t[5]=i,t[6]=e):e=t[6],a=n.map(e),t[0]=r,t[1]=n,t[2]=i,t[3]=a}else a=t[3];let o;return t[7]===a?o=t[8]:(o=(0,Z.jsx)(`nav`,{"aria-label":`Settings sections`,className:`h-full overflow-y-auto overscroll-contain subtle-scrollbar border-r bg-muted/30 px-3 py-4`,children:a}),t[7]=a,t[8]=o),o}function TC(e){let t=(0,$.c)(28),{group:n,activeId:r,onSelect:i}=e;if(n.items.length===0)return null;let a=`settings-group-${n.id}`,o=`${a}-caption`,s=n.enabled?void 0:o,c=n.enabled?`text-muted-foreground/80`:`text-muted-foreground/50`,l;t[0]===c?l=t[1]:(l=mi(`mb-1 px-2 text-xs font-semibold uppercase tracking-wide font-mono`,c),t[0]=c,t[1]=l);let u;t[2]!==n.label||t[3]!==a||t[4]!==s||t[5]!==l?(u=(0,Z.jsx)(`h3`,{id:a,"aria-describedby":s,className:l,children:n.label}),t[2]=n.label,t[3]=a,t[4]=s,t[5]=l,t[6]=u):u=t[6];let d;t[7]!==o||t[8]!==n.enabled?(d=n.enabled?null:(0,Z.jsx)(`p`,{id:o,className:`mb-1 px-2 text-xs italic text-muted-foreground/60`,children:`Open a project to edit.`}),t[7]=o,t[8]=n.enabled,t[9]=d):d=t[9];let f;if(t[10]!==r||t[11]!==o||t[12]!==n.enabled||t[13]!==n.items||t[14]!==i){let e;t[16]!==r||t[17]!==o||t[18]!==n.enabled||t[19]!==i?(e=e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(`button`,{type:`button`,"aria-current":r===e.id?`page`:void 0,"aria-disabled":n.enabled?void 0:!0,"aria-describedby":n.enabled?void 0:o,tabIndex:n.enabled?0:-1,disabled:!n.enabled,onClick:()=>n.enabled&&i(e.id),"data-testid":`settings-sidebar-item-${e.id}`,className:mi(`w-full rounded px-2 py-1.5 text-left text-sm transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,`disabled:cursor-not-allowed disabled:opacity-50`,r===e.id&&n.enabled?`bg-accent text-accent-foreground`:`hover:bg-accent/50`),children:e.label})},e.id),t[16]=r,t[17]=o,t[18]=n.enabled,t[19]=i,t[20]=e):e=t[20],f=n.items.map(e),t[10]=r,t[11]=o,t[12]=n.enabled,t[13]=n.items,t[14]=i,t[15]=f}else f=t[15];let p;t[21]!==a||t[22]!==f?(p=(0,Z.jsx)(`ul`,{"aria-labelledby":a,className:`space-y-0.5`,children:f}),t[21]=a,t[22]=f,t[23]=p):p=t[23];let m;return t[24]!==u||t[25]!==d||t[26]!==p?(m=(0,Z.jsxs)(`div`,{className:`mb-4`,children:[u,d,p]}),t[24]=u,t[25]=d,t[26]=p,t[27]=m):m=t[27],m}function EC(){let e=(0,$.c)(4),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`span`,{className:`sr-only`,children:`Loading settings`}),n=(0,Z.jsx)(Ma,{className:`h-5 w-32`}),r=(0,Z.jsx)(Ma,{className:`h-4 w-64`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-busy":`true`,className:`space-y-3`,"data-testid":`settings-content-skeleton`,children:[t,n,r,(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Ma,{className:`h-9 w-full`}),(0,Z.jsx)(Ma,{className:`h-9 w-full`})]})]}),e[3]=i):i=e[3],i}function DC(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=mi(`flex h-full w-full aria-[orientation=vertical]:flex-col`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(xx,{"data-slot":`resizable-panel-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function OC(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)(wx,{"data-slot":`resizable-panel`,...n}),t[2]=n,t[3]=r),r}function kC(e){let t=(0,$.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({withHandle:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=mi(`relative flex w-px items-center justify-center bg-border ring-offset-background after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90`,n),t[4]=n,t[5]=a);let o;t[6]===i?o=t[7]:(o=i&&(0,Z.jsx)(`div`,{className:`z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border`}),t[6]=i,t[7]=o);let s;return t[8]!==r||t[9]!==a||t[10]!==o?(s=(0,Z.jsx)(Ox,{"data-slot":`resizable-handle`,className:a,...r,children:o}),t[8]=r,t[9]=a,t[10]=o,t[11]=s):s=t[11],s}function AC(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=mi(`group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`input-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var jC=Ti(`flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4`,{variants:{align:{"inline-start":`order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]`,"inline-end":`order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]`,"block-start":`order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2`,"block-end":`order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2`}},defaultVariants:{align:`inline-start`}});function MC(e){let t=(0,$.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,align:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`inline-start`:i,o;t[4]!==a||t[5]!==n?(o=mi(jC({align:a}),n),t[4]=a,t[5]=n,t[6]=o):o=t[6];let s;return t[7]!==a||t[8]!==r||t[9]!==o?(s=(0,Z.jsx)(`div`,{"data-slot":`input-group-addon`,"data-align":a,className:o,onMouseDown:NC,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function NC(e){e.target.closest(`button`)||(e.preventDefault(),e.currentTarget.parentElement?.querySelector(`input`)?.focus())}Ti(`flex items-center gap-2 text-sm shadow-none`,{variants:{size:{xs:`h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5`,sm:``,"icon-xs":`size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0`,"icon-sm":`size-8 p-0 has-[>svg]:p-0`}},defaultVariants:{size:`xs`}});function PC(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=mi(`flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`span`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function FC(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=mi(`flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Po,{"data-slot":`input-group-control`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function IC(e){let t=(0,$.c)(88),{findInputRef:n,query:r,replacement:i,replaceOpen:a,caseSensitive:o,wholeWord:s,current:c,total:l,onQueryChange:u,onReplacementChange:d,onReplaceOpenChange:f,onCaseSensitiveChange:p,onWholeWordChange:m,onNext:h,onPrevious:g,onReplaceCurrent:_,onReplaceAll:v,onClose:y}=e,b=r.length>0,x=l>0,S=b?x?`${c} / ${l}`:`No results`:``,C;t[0]!==y||t[1]!==h||t[2]!==g?(C=function(e){e.key===`Enter`?(e.preventDefault(),e.shiftKey?g():h()):e.key===`Escape`&&(e.preventDefault(),y())},t[0]=y,t[1]=h,t[2]=g,t[3]=C):C=t[3];let w=C,T;t[4]!==y||t[5]!==_?(T=function(e){e.key===`Enter`?(e.preventDefault(),_()):e.key===`Escape`&&(e.preventDefault(),y())},t[4]=y,t[5]=_,t[6]=T):T=t[6];let E=T,D;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(`label`,{className:`sr-only`,htmlFor:`ok-find-input`,children:`Find`}),t[7]=D):D=t[7];let O;t[8]===u?O=t[9]:(O=e=>u(e.target.value),t[8]=u,t[9]=O);let k;t[10]!==n||t[11]!==w||t[12]!==r||t[13]!==O?(k=(0,Z.jsx)(FC,{ref:n,id:`ok-find-input`,value:r,onChange:O,onKeyDown:w,placeholder:`Find`,autoComplete:`off`,spellCheck:!1,className:`h-7 px-2 text-sm`}),t[10]=n,t[11]=w,t[12]=r,t[13]=O,t[14]=k):k=t[14];let A;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(Gs,{"aria-hidden":`true`}),t[15]=A):A=t[15];let j;t[16]!==o||t[17]!==p?(j=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Uo,{type:`button`,variant:`segmented`,size:`sm`,"aria-label":`Match case`,pressed:o,onPressedChange:p,className:`size-6 min-w-6 px-0`,children:A})}),t[16]=o,t[17]=p,t[18]=j):j=t[18];let M;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(vn,{side:`bottom`,children:`Match case`}),t[19]=M):M=t[19];let N;t[20]===j?N=t[21]:(N=(0,Z.jsxs)(yn,{children:[j,M]}),t[20]=j,t[21]=N);let P;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(tl,{"aria-hidden":`true`}),t[22]=P):P=t[22];let I;t[23]!==m||t[24]!==s?(I=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Uo,{type:`button`,variant:`segmented`,size:`sm`,"aria-label":`Whole word`,pressed:s,onPressedChange:m,className:`size-6 min-w-6 px-0`,children:P})}),t[23]=m,t[24]=s,t[25]=I):I=t[25];let L;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsx)(vn,{side:`bottom`,children:`Whole word`}),t[26]=L):L=t[26];let R;t[27]===I?R=t[28]:(R=(0,Z.jsxs)(yn,{children:[I,L]}),t[27]=I,t[28]=R);let z;t[29]!==R||t[30]!==N?(z=(0,Z.jsxs)(MC,{align:`inline-end`,className:`gap-0.5`,children:[N,R]}),t[29]=R,t[30]=N,t[31]=z):z=t[31];let B;t[32]!==z||t[33]!==k?(B=(0,Z.jsxs)(AC,{className:`h-7 w-56 rounded-[min(var(--radius-md),12px)]`,children:[k,z]}),t[32]=z,t[33]=k,t[34]=B):B=t[34];let V;t[35]===S?V=t[36]:(V=(0,Z.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`min-w-14 px-1 text-right text-muted-foreground text-xs tabular-nums shrink-0`,children:S}),t[35]=S,t[36]=V);let H=!x,U;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Z.jsx)(F,{"data-icon":`inline-start`,"aria-hidden":`true`}),t[37]=U):U=t[37];let W;t[38]!==g||t[39]!==H?(W=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Previous match`,disabled:H,onClick:g,children:U})}),t[38]=g,t[39]=H,t[40]=W):W=t[40];let G;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,Z.jsx)(vn,{side:`bottom`,children:`Previous match`}),t[41]=G):G=t[41];let K;t[42]===W?K=t[43]:(K=(0,Z.jsxs)(yn,{children:[W,G]}),t[42]=W,t[43]=K);let q=!x,ee;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Z.jsx)(mt,{"data-icon":`inline-start`,"aria-hidden":`true`}),t[44]=ee):ee=t[44];let te;t[45]!==h||t[46]!==q?(te=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Next match`,disabled:q,onClick:h,children:ee})}),t[45]=h,t[46]=q,t[47]=te):te=t[47];let ne;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Z.jsx)(vn,{side:`bottom`,children:`Next match`}),t[48]=ne):ne=t[48];let re;t[49]===te?re=t[50]:(re=(0,Z.jsxs)(yn,{children:[te,ne]}),t[49]=te,t[50]=re);let ie=a?`secondary`:`ghost`,ae=a?`Hide replace`:`Show replace`,oe=a?`ok-replace-input`:void 0,se;t[51]!==f||t[52]!==a?(se=()=>f(!a),t[51]=f,t[52]=a,t[53]=se):se=t[53];let ce;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Z.jsx)(Ic,{"data-icon":`inline-start`,"aria-hidden":`true`}),t[54]=ce):ce=t[54];let le;t[55]!==a||t[56]!==ie||t[57]!==ae||t[58]!==oe||t[59]!==se?(le=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{type:`button`,variant:ie,size:`icon-sm`,"aria-label":ae,"aria-expanded":a,"aria-controls":oe,onClick:se,children:ce})}),t[55]=a,t[56]=ie,t[57]=ae,t[58]=oe,t[59]=se,t[60]=le):le=t[60];let J=a?`Hide replace`:`Show replace`,ue;t[61]===J?ue=t[62]:(ue=(0,Z.jsx)(vn,{side:`bottom`,children:J}),t[61]=J,t[62]=ue);let de;t[63]!==le||t[64]!==ue?(de=(0,Z.jsxs)(yn,{children:[le,ue]}),t[63]=le,t[64]=ue,t[65]=de):de=t[65];let fe;t[66]!==E||t[67]!==x||t[68]!==v||t[69]!==_||t[70]!==d||t[71]!==a||t[72]!==i?(fe=a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`label`,{className:`sr-only`,htmlFor:`ok-replace-input`,children:`Replace`}),(0,Z.jsx)(Po,{id:`ok-replace-input`,value:i,onChange:e=>d(e.target.value),onKeyDown:E,placeholder:`Replace`,autoComplete:`off`,spellCheck:!1,className:`h-7 w-48 rounded-[min(var(--radius-md),12px)] px-2 text-sm shadow-none focus-visible:ring-2`}),(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Replace current match`,disabled:!x,onClick:_,children:(0,Z.jsx)(Ic,{"data-icon":`inline-start`,"aria-hidden":`true`})})}),(0,Z.jsx)(vn,{side:`bottom`,children:`Replace current match`})]}),(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Replace all matches`,disabled:!x,onClick:v,children:(0,Z.jsx)(Fc,{"data-icon":`inline-start`,"aria-hidden":`true`})})}),(0,Z.jsx)(vn,{side:`bottom`,children:`Replace all matches`})]})]}):null,t[66]=E,t[67]=x,t[68]=v,t[69]=_,t[70]=d,t[71]=a,t[72]=i,t[73]=fe):fe=t[73];let pe;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Z.jsx)(_o,{"data-icon":`inline-start`,"aria-hidden":`true`}),t[74]=pe):pe=t[74];let me;t[75]===y?me=t[76]:(me=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Close find`,onClick:y,children:pe})}),t[75]=y,t[76]=me);let he;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,Z.jsx)(vn,{side:`bottom`,children:`Close`}),t[77]=he):he=t[77];let ge;t[78]===me?ge=t[79]:(ge=(0,Z.jsxs)(yn,{children:[me,he]}),t[78]=me,t[79]=ge);let _e;return t[80]!==B||t[81]!==V||t[82]!==K||t[83]!==re||t[84]!==de||t[85]!==fe||t[86]!==ge?(_e=(0,Z.jsxs)(`search`,{"data-testid":`find-replace-bar`,"aria-label":`Find and replace`,className:`pointer-events-auto flex max-w-[min(calc(100vw-1rem),720px)] touch-manipulation items-center gap-1 rounded-[calc(var(--radius)+2px)] border border-input bg-popover/95 p-1 text-popover-foreground shadow-md shadow-black/10 backdrop-blur`,children:[D,B,V,K,re,de,fe,ge]}),t[80]=B,t[81]=V,t[82]=K,t[83]=re,t[84]=de,t[85]=fe,t[86]=ge,t[87]=_e):_e=t[87],_e}var LC={current:0,total:0},RC=120,zC=100;function BC(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=()=>e?h(e):null,t[0]=e,t[1]=n),(0,Q.useSyncExternalStore)(de,n,VC)}function VC(){return null}function HC(e){if(!e||e.isDestroyed)return null;let{from:t,to:n,empty:r}=e.state.selection;if(r)return null;let i=e.state.doc.textBetween(t,n,`
|
|
29
|
+
This template lives at an ancestor folder — deleting affects every folder under that ancestor that does not shadow it locally.`:``}`}),t[25]=c,t[26]=f,t[27]=_,t[28]=A):A=t[28];let j;t[29]!==O||t[30]!==k||t[31]!==A?(j=(0,Z.jsx)(jo,{open:O,onOpenChange:k,children:A}),t[29]=O,t[30]=k,t[31]=A,t[32]=j):j=t[32];let M;t[33]===y?M=t[34]:(M=new Set(y.map(YS)),t[33]=y,t[34]=M);let N;t[35]!==n||t[36]!==m||t[37]!==i||t[38]!==M?(N=(0,Z.jsx)(Ca,{folderPath:n,existingNames:M,open:m,onOpenChange:h,onCreated:i}),t[35]=n,t[36]=m,t[37]=i,t[38]=M,t[39]=N):N=t[39];let P=u!==null,F;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>{e||d(null)},t[40]=F):F=t[40];let I=u??void 0,L;t[41]!==a||t[42]!==n||t[43]!==P||t[44]!==I?(L=(0,Z.jsx)(Hp,{open:P,onOpenChange:F,kind:`file`,initialDir:n,initialTemplate:I,folderConfig:a}),t[41]=a,t[42]=n,t[43]=P,t[44]=I,t[45]=L):L=t[45];let R;return t[46]!==D||t[47]!==j||t[48]!==N||t[49]!==L||t[50]!==T?(R=(0,Z.jsxs)(Z.Fragment,{children:[T,D,j,N,L]}),t[46]=D,t[47]=j,t[48]=N,t[49]=L,t[50]=T,t[51]=R):R=t[51],R}function YS(e){return e.name}function XS(e){let t=(0,$.c)(42),{template:n,onCreate:r,onEdit:i,onDelete:a}=e,o=n.title&&n.title!==n.name,s=n.title??n.name,c;t[0]===s?c=t[1]:(c=(0,Z.jsx)(`span`,{className:`font-medium truncate`,children:s}),t[0]=s,t[1]=c);let l;t[2]!==o||t[3]!==n.name?(l=o?(0,Z.jsx)(`code`,{className:`font-mono text-xs text-muted-foreground shrink-0`,children:n.name}):null,t[2]=o,t[3]=n.name,t[4]=l):l=t[4];let u;t[5]!==n.name||t[6]!==n.scope||t[7]!==n.source_folder?(u=n.scope===`inherited`?(0,Z.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,Z.jsx)(oo,{source:n.source_folder,target:`templates/${n.name}.md`})}):null,t[5]=n.name,t[6]=n.scope,t[7]=n.source_folder,t[8]=u):u=t[8];let d;t[9]!==c||t[10]!==l||t[11]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[c,l,u]}),t[9]=c,t[10]=l,t[11]=u,t[12]=d):d=t[12];let f;t[13]===n.description?f=t[14]:(f=n.description?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground truncate mt-0.5`,children:n.description}):null,t[13]=n.description,t[14]=f);let p;t[15]!==i||t[16]!==d||t[17]!==f?(p=(0,Z.jsxs)(`button`,{type:`button`,onClick:i,className:`min-w-0 flex-1 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm`,children:[d,f]}),t[15]=i,t[16]=d,t[17]=f,t[18]=p):p=t[18];let h=`Create note from ${s}`,g;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(oc,{className:`size-3.5`,"aria-hidden":!0}),t[19]=g):g=t[19];let _;t[20]!==r||t[21]!==h?(_=(0,Z.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`font-mono uppercase shrink-0 opacity-0 group-hover:opacity-100 focus-visible:opacity-100`,onClick:r,"aria-label":h,children:[g,`Create`]}),t[20]=r,t[21]=h,t[22]=_):_=t[22];let v=`Actions for ${s}`,y;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(oa,{className:`size-4`,"aria-hidden":!0}),t[23]=y):y=t[23];let b;t[24]===v?b=t[25]:(b=(0,Z.jsx)(ba,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon`,className:`size-7 shrink-0 opacity-0 group-hover:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100`,"aria-label":v,children:y})}),t[24]=v,t[25]=b);let x;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(m,{"aria-hidden":!0}),t[26]=x):x=t[26];let S;t[27]===i?S=t[28]:(S=(0,Z.jsxs)(ya,{onSelect:i,children:[x,`Edit`]}),t[27]=i,t[28]=S);let C;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(Ue,{"aria-hidden":!0}),t[29]=C):C=t[29];let w;t[30]===a?w=t[31]:(w=(0,Z.jsxs)(ya,{variant:`destructive`,onSelect:a,children:[C,`Delete`]}),t[30]=a,t[31]=w);let T;t[32]!==S||t[33]!==w?(T=(0,Z.jsxs)(_a,{align:`end`,children:[S,w]}),t[32]=S,t[33]=w,t[34]=T):T=t[34];let E;t[35]!==b||t[36]!==T?(E=(0,Z.jsxs)(va,{children:[b,T]}),t[35]=b,t[36]=T,t[37]=E):E=t[37];let D;return t[38]!==E||t[39]!==p||t[40]!==_?(D=(0,Z.jsxs)(`li`,{className:`group flex items-center gap-2 rounded-md px-2 py-2 hover:bg-muted/50 text-sm`,children:[p,_,E]}),t[38]=E,t[39]=p,t[40]=_,t[41]=D):D=t[41],D}function ZS(e){let t=(0,$.c)(14),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,containerClassName:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=mi(`relative w-full overflow-x-auto subtle-scrollbar`,r),t[4]=r,t[5]=a);let o;t[6]===n?o=t[7]:(o=mi(`w-full caption-bottom text-sm`,n),t[6]=n,t[7]=o);let s;t[8]!==i||t[9]!==o?(s=(0,Z.jsx)(`table`,{"data-slot":`table`,className:o,...i}),t[8]=i,t[9]=o,t[10]=s):s=t[10];let c;return t[11]!==a||t[12]!==s?(c=(0,Z.jsx)(`div`,{"data-slot":`table-container`,className:a,children:s}),t[11]=a,t[12]=s,t[13]=c):c=t[13],c}function QS(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=mi(`[&_tr]:border-b`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`thead`,{"data-slot":`table-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function $S(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=mi(`[&_tr:last-child]:border-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`tbody`,{"data-slot":`table-body`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function eC(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,noHover:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=(i===void 0?!1:i)&&`hover:bg-transparent`,o;t[4]!==n||t[5]!==a?(o=mi(`hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors`,a,n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==o?(s=(0,Z.jsx)(`tr`,{"data-slot":`table-row`,className:o,...r}),t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function tC(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,scope:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`col`:i,o;t[4]===n?o=t[5]:(o=mi(`font-mono uppercase text-xs text-muted-foreground h-10 px-4 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,n),t[4]=n,t[5]=o);let s;return t[6]!==r||t[7]!==a||t[8]!==o?(s=(0,Z.jsx)(`th`,{"data-slot":`table-head`,scope:a,className:o,...r}),t[6]=r,t[7]=a,t[8]=o,t[9]=s):s=t[9],s}function nC(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=mi(`py-3 px-4 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`td`,{"data-slot":`table-cell`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function rC(e){if(!e)return`—`;let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<30?`${a}d ago`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function iC(e,t,n){return[...e].sort((e,r)=>{if(e.kind!==r.kind)return e.kind===`folder`?-1:1;let i=0;switch(t){case`name`:i=e.title.localeCompare(r.title)||e.name.localeCompare(r.name);break;case`modified`:{let t=e.kind===`file`?e.modified:``,n=r.kind===`file`?r.modified:``;i=t.localeCompare(n);break}}return n===`asc`?i:-i})}function aC(e){let t=(0,$.c)(10),{label:n,sortKey:r,activeKey:i,activeDir:a,onSort:o}=e,s=i===r,c;t[0]!==o||t[1]!==r?(c=()=>o(r),t[0]=o,t[1]=r,t[2]=c):c=t[2];let l;t[3]!==a||t[4]!==s?(l=s?a===`asc`?(0,Z.jsx)(xe,{className:`ml-1 size-3`}):(0,Z.jsx)(Ee,{className:`ml-1 size-3`}):(0,Z.jsx)(zs,{className:`ml-1 size-3 text-muted-foreground/50`}),t[3]=a,t[4]=s,t[5]=l):l=t[5];let u;return t[6]!==n||t[7]!==c||t[8]!==l?(u=(0,Z.jsxs)(Y,{variant:`ghost`,size:`sm`,className:`-ml-3 h-8 uppercase font-mono`,onClick:c,children:[n,l]}),t[6]=n,t[7]=c,t[8]=l,t[9]=u):u=t[9],u}function oC(e){let t=(0,$.c)(81),{folderPath:n}=e,{folderPaths:r,loading:i,pages:a,pageTitles:o,pageMeta:s}=qr(),c=Aa(n),{state:l,refresh:u}=c,[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(`name`),[h,g]=(0,Q.useState)(`asc`);if(i){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Ma,{className:`size-5 rounded`}),(0,Z.jsx)(Ma,{className:`h-7 w-48`})]}),(0,Z.jsx)(Ma,{className:`h-9 w-20 rounded-md`})]}),t[0]=e):e=t[0];let n;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(Ma,{className:`h-4 w-16`}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start overflow-y-auto subtle-scrollbar`,role:`status`,"aria-busy":`true`,"aria-label":`Loading folder contents`,children:(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-8`,children:[e,(0,Z.jsxs)(`div`,{className:`rounded-lg border`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-4 border-b px-4 py-3`,children:[n,(0,Z.jsx)(`div`,{className:`ml-auto`,children:(0,Z.jsx)(Ma,{className:`h-4 w-20`})})]}),[`a`,`b`,`c`,`d`].map(lC)]})]})}),t[2]=r):r=t[2],r}let _,v,y,b,x,S,C,w,T,E;if(t[3]!==l||t[4]!==c||t[5]!==n||t[6]!==r||t[7]!==s||t[8]!==o||t[9]!==a||t[10]!==u||t[11]!==h||t[12]!==p){let e=qS(n,{pages:a,pageTitles:o,pageMeta:s,folderPaths:r}),i=iC(e.children,p,h),d;t[23]===p?d=t[24]:(d=function(e){e===p?g(cC):(m(e),g(`asc`))},t[23]=p,t[24]=d);let D=d;E=`flex min-h-0 flex-1 items-start overflow-y-auto subtle-scrollbar`,S=`mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-8`;let O;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(R,{className:`size-5 text-muted-foreground`}),t[25]=O):O=t[25];let k=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[O,(0,Z.jsx)(`h1`,{className:`text-2xl font-light tracking-tight`,children:e.title})]}),A;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsxs)(Y,{onClick:()=>f(!0),children:[(0,Z.jsx)(ce,{className:`size-4`}),`New`]}),t[26]=A):A=t[26],t[27]===k?C=t[28]:(C=(0,Z.jsx)(`div`,{className:`flex flex-col gap-6`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[k,A]})}),t[27]=k,t[28]=C),t[29]!==l||t[30]!==n||t[31]!==u?(w=(0,Z.jsx)(VS,{folderPath:n,state:l,onChange:u}),t[29]=l,t[30]=n,t[31]=u,t[32]=w):w=t[32],t[33]!==l||t[34]!==c||t[35]!==n||t[36]!==u?(T=(0,Z.jsx)(JS,{folderPath:n,state:l,onChange:u,folderConfigHandle:c}),t[33]=l,t[34]=c,t[35]=n,t[36]=u,t[37]=T):T=t[37],x=`rounded-lg border`,v=ZS;let j=p===`name`?h===`asc`?`ascending`:`descending`:`none`,M;t[38]!==D||t[39]!==h||t[40]!==p?(M=(0,Z.jsx)(aC,{label:`Name`,sortKey:`name`,activeKey:p,activeDir:h,onSort:D}),t[38]=D,t[39]=h,t[40]=p,t[41]=M):M=t[41];let N;t[42]!==j||t[43]!==M?(N=(0,Z.jsx)(tC,{"aria-sort":j,children:M}),t[42]=j,t[43]=M,t[44]=N):N=t[44];let P=p===`modified`?h===`asc`?`ascending`:`descending`:`none`,F;t[45]!==D||t[46]!==h||t[47]!==p?(F=(0,Z.jsx)(aC,{label:`Modified`,sortKey:`modified`,activeKey:p,activeDir:h,onSort:D}),t[45]=D,t[46]=h,t[47]=p,t[48]=F):F=t[48];let I;t[49]!==P||t[50]!==F?(I=(0,Z.jsx)(tC,{className:`w-32`,"aria-sort":P,children:F}),t[49]=P,t[50]=F,t[51]=I):I=t[51],t[52]!==N||t[53]!==I?(b=(0,Z.jsx)(QS,{children:(0,Z.jsxs)(eC,{children:[N,I]})}),t[52]=N,t[53]=I,t[54]=b):b=t[54],_=$S,y=i.length?i.map(sC):(0,Z.jsx)(eC,{children:(0,Z.jsx)(nC,{colSpan:2,className:`h-24 text-center text-muted-foreground`,children:`This folder is empty.`})}),t[3]=l,t[4]=c,t[5]=n,t[6]=r,t[7]=s,t[8]=o,t[9]=a,t[10]=u,t[11]=h,t[12]=p,t[13]=_,t[14]=v,t[15]=y,t[16]=b,t[17]=x,t[18]=S,t[19]=C,t[20]=w,t[21]=T,t[22]=E}else _=t[13],v=t[14],y=t[15],b=t[16],x=t[17],S=t[18],C=t[19],w=t[20],T=t[21],E=t[22];let D;t[55]!==_||t[56]!==y?(D=(0,Z.jsx)(_,{children:y}),t[55]=_,t[56]=y,t[57]=D):D=t[57];let O;t[58]!==v||t[59]!==b||t[60]!==D?(O=(0,Z.jsxs)(v,{children:[b,D]}),t[58]=v,t[59]=b,t[60]=D,t[61]=O):O=t[61];let k;t[62]!==O||t[63]!==x?(k=(0,Z.jsx)(`div`,{className:x,children:O}),t[62]=O,t[63]=x,t[64]=k):k=t[64];let A;t[65]!==k||t[66]!==S||t[67]!==C||t[68]!==w||t[69]!==T?(A=(0,Z.jsxs)(`div`,{className:S,children:[C,w,T,k]}),t[65]=k,t[66]=S,t[67]=C,t[68]=w,t[69]=T,t[70]=A):A=t[70];let j;t[71]!==A||t[72]!==E?(j=(0,Z.jsx)(`div`,{className:E,children:A}),t[71]=A,t[72]=E,t[73]=j):j=t[73];let M;t[74]!==d||t[75]!==c||t[76]!==n?(M=(0,Z.jsx)(Hp,{open:d,onOpenChange:f,kind:`file`,initialDir:n,folderConfig:c,suggestedName:`index`}),t[74]=d,t[75]=c,t[76]=n,t[77]=M):M=t[77];let N;return t[78]!==j||t[79]!==M?(N=(0,Z.jsxs)(Z.Fragment,{children:[j,M]}),t[78]=j,t[79]=M,t[80]=N):N=t[80],N}function sC(e){return(0,Z.jsxs)(eC,{children:[(0,Z.jsx)(nC,{children:(0,Z.jsxs)(`a`,{href:Tr(e.path),className:`flex items-center gap-2 rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[e.kind===`folder`?(0,Z.jsx)(dc,{className:`size-4 shrink-0 text-muted-foreground`}):(0,Z.jsx)(ae,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.title})]})}),(0,Z.jsx)(nC,{className:`text-muted-foreground`,children:e.kind===`file`?rC(e.modified):`—`})]},e.path)}function cC(e){return e===`asc`?`desc`:`asc`}function lC(e){return(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 border-b px-4 py-3 last:border-b-0`,children:[(0,Z.jsx)(Ma,{className:`size-4 rounded`}),(0,Z.jsx)(Ma,{className:`h-4 w-40`}),(0,Z.jsx)(`div`,{className:`ml-auto`,children:(0,Z.jsx)(Ma,{className:`h-4 w-16`})})]},e)}function uC(e){let t=(0,$.c)(7),{docName:n}=e,[r,i]=(0,Q.useState)(dC),a,o;if(t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>Pt(e=>{i(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})}),o=[],t[0]=a,t[1]=o):(a=t[0],o=t[1]),(0,Q.useEffect)(a,o),!r.has(n))return null;let s;t[2]===n?s=t[3]:(s=function(){We(n)?.abort(),i(e=>{if(!e.has(n))return e;let t=new Set(e);return t.delete(n),t})},t[2]=n,t[3]=s);let c=s,l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`span`,{children:`Still loading`}),t[4]=l):l=t[4];let u;return t[5]===c?u=t[6]:(u=(0,Z.jsxs)(`div`,{className:`absolute inset-x-0 bottom-8 z-20 flex justify-center text-xs text-muted-foreground`,children:[l,(0,Z.jsx)(Y,{variant:`link`,size:`sm`,className:`h-auto px-2 py-0 text-xs`,onClick:c,children:`Cancel`})]}),t[5]=c,t[6]=u),u}function dC(){return new Set}var fC=(0,Q.createContext)(null);function pC(e){let t=(0,$.c)(7),{children:n}=e,[r,i]=(0,Q.useState)(mC),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>{i(t=>{let n=new Map(t);return n.set(e,(t.get(e)??0)+1),n})},t[0]=a):a=t[0];let o=a,s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=e=>{i(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},t[1]=s):s=t[1];let c=s,l;t[2]===r?l=t[3]:(l={addPropertySignal:r,requestAddProperty:o,clearAddProperty:c},t[2]=r,t[3]=l);let u=l,d;return t[4]!==n||t[5]!==u?(d=(0,Z.jsx)(fC,{value:u,children:n}),t[4]=n,t[5]=u,t[6]=d):d=t[6],d}function mC(){return new Map}function hC(){let e=(0,Q.use)(fC);if(e===null)throw Error(`useProperties must be used within <PropertyProvider />`);return e}function gC(e){let t=null,n=()=>(t===null&&(t=e(),t.catch(()=>{})),t),r=(0,Q.lazy)(n);return r.preload=n,r}var _C=gC(()=>n(()=>import(`./SettingsDialogBody-8zs3jwhI.js`).then(e=>({default:e.SettingsDialogBody})),__vite__mapDeps([42,1,33,2,34,35,20,36,37,38,39,19,3,6,7,4,10,9,40,43,8,14,21,11]),import.meta.url));function vC(e){let t=(0,$.c)(6),{error:n}=e,r=n instanceof Error&&/dynamically imported module|Failed to fetch/i.test(n.message)?`A newer version may have been deployed since this tab opened.`:`Something went wrong loading the settings panel.`,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`h3`,{id:`settings-body-error-title`,className:`font-heading text-base leading-none font-medium`,children:`Settings failed to load`}),t[0]=i):i=t[0];let a;t[1]===r?a=t[2]:(a=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[i,(0,Z.jsx)(`p`,{className:`max-w-xs text-sm text-muted-foreground`,children:r})]}),t[1]=r,t[2]=a);let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(Y,{variant:`default`,onClick:yC,children:`Reload`}),t[3]=o):o=t[3];let s;return t[4]===a?s=t[5]:(s=(0,Z.jsxs)(`div`,{role:`alert`,"aria-labelledby":`settings-body-error-title`,"data-slot":`settings-body-error-boundary`,className:`flex h-full flex-col items-center justify-center gap-5 p-8 text-center`,children:[a,o]}),t[4]=a,t[5]=s),s}function yC(){return window.location.reload()}function bC(e){let t=(0,$.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(O,{fallbackRender:SC,onError:xC,children:n}),t[0]=n,t[1]=r),r}function xC(e,t){console.error(`[SettingsDialogErrorBoundary] rendered fallback for Settings body`,e,t.componentStack)}function SC(e){return(0,Z.jsx)(vC,{...e})}function CC(e){let t=(0,$.c)(30),{open:n,onOpenChange:r}=e,{collabUrl:i}=ot(),{userBinding:a,userSynced:o,okignoreBinding:s,okignoreSynced:c}=Ga(),{desktopPresent:l}=Fa(),[u,d]=(0,Q.useState)(`preferences`),f,p;t[0]===n?(f=t[1],p=t[2]):(f=()=>{n&&d(`preferences`)},p=[n],t[0]=n,t[1]=f,t[2]=p),(0,Q.useEffect)(f,p);let m=i!==null,h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h={id:`user`,label:`User`,enabled:!0,items:[{id:`preferences`,label:`Preferences`}]},t[3]=h):h=t[3];let g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=[{id:`sync`,label:`Sync`},{id:`project-templates`,label:`Templates`},{id:`okignore`,label:`Ignore patterns`}],t[4]=g):g=t[4];let _;t[5]===m?_=t[6]:(_={id:`project`,label:`This project`,enabled:m,items:g},t[5]=m,t[6]=_);let v;t[7]===l?v=t[8]:(v={id:`integrations`,label:`Integrations`,enabled:!0,items:l?[{id:`claude-desktop`,label:`Claude Desktop`}]:[]},t[7]=l,t[8]=v);let y;t[9]!==_||t[10]!==v?(y=[h,_,v],t[9]=_,t[10]=v,t[11]=y):y=t[11];let b=y,x,S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(bo,{className:`sr-only`,children:`Settings`}),S=(0,Z.jsx)(vo,{className:`sr-only`,children:`Configure user, project, and integration settings.`}),t[12]=x,t[13]=S):(x=t[12],S=t[13]);let C;t[14]!==u||t[15]!==b?(C=(0,Z.jsx)(wC,{groups:b,activeId:u,onSelect:d}),t[14]=u,t[15]=b,t[16]=C):C=t[16];let w;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(EC,{}),t[17]=w):w=t[17];let T=o?a:null,E;t[18]!==u||t[19]!==s||t[20]!==c||t[21]!==T?(E=(0,Z.jsx)(`div`,{className:`min-h-0 overflow-y-auto overscroll-contain subtle-scrollbar p-6`,children:(0,Z.jsx)(bC,{children:(0,Z.jsx)(Q.Suspense,{fallback:w,children:(0,Z.jsx)(_C,{activeId:u,userBinding:T,okignoreBinding:s,okignoreSynced:c})})})}),t[18]=u,t[19]=s,t[20]=c,t[21]=T,t[22]=E):E=t[22];let D;t[23]!==C||t[24]!==E?(D=(0,Z.jsxs)(wo,{className:`grid h-[700px] max-h-[calc(100dvh-4rem)] w-[900px] max-w-[calc(100%-2rem)] grid-cols-[220px_1fr] gap-0 overflow-hidden p-0 sm:max-w-[900px]`,"data-testid":`settings-dialog`,children:[x,S,C,E]}),t[23]=C,t[24]=E,t[25]=D):D=t[25];let O;return t[26]!==r||t[27]!==n||t[28]!==D?(O=(0,Z.jsx)(jo,{open:n,onOpenChange:r,children:D}),t[26]=r,t[27]=n,t[28]=D,t[29]=O):O=t[29],O}function wC(e){let t=(0,$.c)(9),{groups:n,activeId:r,onSelect:i}=e,a;if(t[0]!==r||t[1]!==n||t[2]!==i){let e;t[4]!==r||t[5]!==i?(e=e=>(0,Z.jsx)(TC,{group:e,activeId:r,onSelect:i},e.id),t[4]=r,t[5]=i,t[6]=e):e=t[6],a=n.map(e),t[0]=r,t[1]=n,t[2]=i,t[3]=a}else a=t[3];let o;return t[7]===a?o=t[8]:(o=(0,Z.jsx)(`nav`,{"aria-label":`Settings sections`,className:`h-full overflow-y-auto overscroll-contain subtle-scrollbar border-r bg-muted/30 px-3 py-4`,children:a}),t[7]=a,t[8]=o),o}function TC(e){let t=(0,$.c)(28),{group:n,activeId:r,onSelect:i}=e;if(n.items.length===0)return null;let a=`settings-group-${n.id}`,o=`${a}-caption`,s=n.enabled?void 0:o,c=n.enabled?`text-muted-foreground/80`:`text-muted-foreground/50`,l;t[0]===c?l=t[1]:(l=mi(`mb-1 px-2 text-xs font-semibold uppercase tracking-wide font-mono`,c),t[0]=c,t[1]=l);let u;t[2]!==n.label||t[3]!==a||t[4]!==s||t[5]!==l?(u=(0,Z.jsx)(`h3`,{id:a,"aria-describedby":s,className:l,children:n.label}),t[2]=n.label,t[3]=a,t[4]=s,t[5]=l,t[6]=u):u=t[6];let d;t[7]!==o||t[8]!==n.enabled?(d=n.enabled?null:(0,Z.jsx)(`p`,{id:o,className:`mb-1 px-2 text-xs italic text-muted-foreground/60`,children:`Open a project to edit.`}),t[7]=o,t[8]=n.enabled,t[9]=d):d=t[9];let f;if(t[10]!==r||t[11]!==o||t[12]!==n.enabled||t[13]!==n.items||t[14]!==i){let e;t[16]!==r||t[17]!==o||t[18]!==n.enabled||t[19]!==i?(e=e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(`button`,{type:`button`,"aria-current":r===e.id?`page`:void 0,"aria-disabled":n.enabled?void 0:!0,"aria-describedby":n.enabled?void 0:o,tabIndex:n.enabled?0:-1,disabled:!n.enabled,onClick:()=>n.enabled&&i(e.id),"data-testid":`settings-sidebar-item-${e.id}`,className:mi(`w-full rounded px-2 py-1.5 text-left text-sm transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,`disabled:cursor-not-allowed disabled:opacity-50`,r===e.id&&n.enabled?`bg-accent text-accent-foreground`:`hover:bg-accent/50`),children:e.label})},e.id),t[16]=r,t[17]=o,t[18]=n.enabled,t[19]=i,t[20]=e):e=t[20],f=n.items.map(e),t[10]=r,t[11]=o,t[12]=n.enabled,t[13]=n.items,t[14]=i,t[15]=f}else f=t[15];let p;t[21]!==a||t[22]!==f?(p=(0,Z.jsx)(`ul`,{"aria-labelledby":a,className:`space-y-0.5`,children:f}),t[21]=a,t[22]=f,t[23]=p):p=t[23];let m;return t[24]!==u||t[25]!==d||t[26]!==p?(m=(0,Z.jsxs)(`div`,{className:`mb-4`,children:[u,d,p]}),t[24]=u,t[25]=d,t[26]=p,t[27]=m):m=t[27],m}function EC(){let e=(0,$.c)(4),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`span`,{className:`sr-only`,children:`Loading settings`}),n=(0,Z.jsx)(Ma,{className:`h-5 w-32`}),r=(0,Z.jsx)(Ma,{className:`h-4 w-64`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-busy":`true`,className:`space-y-3`,"data-testid":`settings-content-skeleton`,children:[t,n,r,(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Ma,{className:`h-9 w-full`}),(0,Z.jsx)(Ma,{className:`h-9 w-full`})]})]}),e[3]=i):i=e[3],i}function DC(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=mi(`flex h-full w-full aria-[orientation=vertical]:flex-col`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(xx,{"data-slot":`resizable-panel-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function OC(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)(wx,{"data-slot":`resizable-panel`,...n}),t[2]=n,t[3]=r),r}function kC(e){let t=(0,$.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({withHandle:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=mi(`relative flex w-px items-center justify-center bg-border ring-offset-background after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90`,n),t[4]=n,t[5]=a);let o;t[6]===i?o=t[7]:(o=i&&(0,Z.jsx)(`div`,{className:`z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border`}),t[6]=i,t[7]=o);let s;return t[8]!==r||t[9]!==a||t[10]!==o?(s=(0,Z.jsx)(Ox,{"data-slot":`resizable-handle`,className:a,...r,children:o}),t[8]=r,t[9]=a,t[10]=o,t[11]=s):s=t[11],s}function AC(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=mi(`group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`input-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var jC=Ti(`flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4`,{variants:{align:{"inline-start":`order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]`,"inline-end":`order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]`,"block-start":`order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2`,"block-end":`order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2`}},defaultVariants:{align:`inline-start`}});function MC(e){let t=(0,$.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,align:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`inline-start`:i,o;t[4]!==a||t[5]!==n?(o=mi(jC({align:a}),n),t[4]=a,t[5]=n,t[6]=o):o=t[6];let s;return t[7]!==a||t[8]!==r||t[9]!==o?(s=(0,Z.jsx)(`div`,{"data-slot":`input-group-addon`,"data-align":a,className:o,onMouseDown:NC,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function NC(e){e.target.closest(`button`)||(e.preventDefault(),e.currentTarget.parentElement?.querySelector(`input`)?.focus())}Ti(`flex items-center gap-2 text-sm shadow-none`,{variants:{size:{xs:`h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5`,sm:``,"icon-xs":`size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0`,"icon-sm":`size-8 p-0 has-[>svg]:p-0`}},defaultVariants:{size:`xs`}});function PC(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=mi(`flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`span`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function FC(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=mi(`flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Po,{"data-slot":`input-group-control`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function IC(e){let t=(0,$.c)(88),{findInputRef:n,query:r,replacement:i,replaceOpen:a,caseSensitive:o,wholeWord:s,current:c,total:l,onQueryChange:u,onReplacementChange:d,onReplaceOpenChange:f,onCaseSensitiveChange:p,onWholeWordChange:m,onNext:h,onPrevious:g,onReplaceCurrent:_,onReplaceAll:v,onClose:y}=e,b=r.length>0,x=l>0,S=b?x?`${c} / ${l}`:`No results`:``,C;t[0]!==y||t[1]!==h||t[2]!==g?(C=function(e){e.key===`Enter`?(e.preventDefault(),e.shiftKey?g():h()):e.key===`Escape`&&(e.preventDefault(),y())},t[0]=y,t[1]=h,t[2]=g,t[3]=C):C=t[3];let w=C,T;t[4]!==y||t[5]!==_?(T=function(e){e.key===`Enter`?(e.preventDefault(),_()):e.key===`Escape`&&(e.preventDefault(),y())},t[4]=y,t[5]=_,t[6]=T):T=t[6];let E=T,D;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(`label`,{className:`sr-only`,htmlFor:`ok-find-input`,children:`Find`}),t[7]=D):D=t[7];let O;t[8]===u?O=t[9]:(O=e=>u(e.target.value),t[8]=u,t[9]=O);let k;t[10]!==n||t[11]!==w||t[12]!==r||t[13]!==O?(k=(0,Z.jsx)(FC,{ref:n,id:`ok-find-input`,value:r,onChange:O,onKeyDown:w,placeholder:`Find`,autoComplete:`off`,spellCheck:!1,className:`h-7 px-2 text-sm`}),t[10]=n,t[11]=w,t[12]=r,t[13]=O,t[14]=k):k=t[14];let A;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(Gs,{"aria-hidden":`true`}),t[15]=A):A=t[15];let j;t[16]!==o||t[17]!==p?(j=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Uo,{type:`button`,variant:`segmented`,size:`sm`,"aria-label":`Match case`,pressed:o,onPressedChange:p,className:`size-6 min-w-6 px-0`,children:A})}),t[16]=o,t[17]=p,t[18]=j):j=t[18];let M;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(vn,{side:`bottom`,children:`Match case`}),t[19]=M):M=t[19];let N;t[20]===j?N=t[21]:(N=(0,Z.jsxs)(yn,{children:[j,M]}),t[20]=j,t[21]=N);let P;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(tl,{"aria-hidden":`true`}),t[22]=P):P=t[22];let I;t[23]!==m||t[24]!==s?(I=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Uo,{type:`button`,variant:`segmented`,size:`sm`,"aria-label":`Whole word`,pressed:s,onPressedChange:m,className:`size-6 min-w-6 px-0`,children:P})}),t[23]=m,t[24]=s,t[25]=I):I=t[25];let L;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsx)(vn,{side:`bottom`,children:`Whole word`}),t[26]=L):L=t[26];let R;t[27]===I?R=t[28]:(R=(0,Z.jsxs)(yn,{children:[I,L]}),t[27]=I,t[28]=R);let z;t[29]!==R||t[30]!==N?(z=(0,Z.jsxs)(MC,{align:`inline-end`,className:`gap-0.5`,children:[N,R]}),t[29]=R,t[30]=N,t[31]=z):z=t[31];let B;t[32]!==z||t[33]!==k?(B=(0,Z.jsxs)(AC,{className:`h-7 w-56 rounded-[min(var(--radius-md),12px)]`,children:[k,z]}),t[32]=z,t[33]=k,t[34]=B):B=t[34];let V;t[35]===S?V=t[36]:(V=(0,Z.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`min-w-14 px-1 text-right text-muted-foreground text-xs tabular-nums shrink-0`,children:S}),t[35]=S,t[36]=V);let H=!x,U;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Z.jsx)(F,{"data-icon":`inline-start`,"aria-hidden":`true`}),t[37]=U):U=t[37];let W;t[38]!==g||t[39]!==H?(W=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Previous match`,disabled:H,onClick:g,children:U})}),t[38]=g,t[39]=H,t[40]=W):W=t[40];let G;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,Z.jsx)(vn,{side:`bottom`,children:`Previous match`}),t[41]=G):G=t[41];let K;t[42]===W?K=t[43]:(K=(0,Z.jsxs)(yn,{children:[W,G]}),t[42]=W,t[43]=K);let q=!x,ee;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Z.jsx)(mt,{"data-icon":`inline-start`,"aria-hidden":`true`}),t[44]=ee):ee=t[44];let te;t[45]!==h||t[46]!==q?(te=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Next match`,disabled:q,onClick:h,children:ee})}),t[45]=h,t[46]=q,t[47]=te):te=t[47];let ne;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Z.jsx)(vn,{side:`bottom`,children:`Next match`}),t[48]=ne):ne=t[48];let re;t[49]===te?re=t[50]:(re=(0,Z.jsxs)(yn,{children:[te,ne]}),t[49]=te,t[50]=re);let ie=a?`secondary`:`ghost`,ae=a?`Hide replace`:`Show replace`,oe=a?`ok-replace-input`:void 0,se;t[51]!==f||t[52]!==a?(se=()=>f(!a),t[51]=f,t[52]=a,t[53]=se):se=t[53];let ce;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Z.jsx)(Ic,{"data-icon":`inline-start`,"aria-hidden":`true`}),t[54]=ce):ce=t[54];let le;t[55]!==a||t[56]!==ie||t[57]!==ae||t[58]!==oe||t[59]!==se?(le=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{type:`button`,variant:ie,size:`icon-sm`,"aria-label":ae,"aria-expanded":a,"aria-controls":oe,onClick:se,children:ce})}),t[55]=a,t[56]=ie,t[57]=ae,t[58]=oe,t[59]=se,t[60]=le):le=t[60];let J=a?`Hide replace`:`Show replace`,ue;t[61]===J?ue=t[62]:(ue=(0,Z.jsx)(vn,{side:`bottom`,children:J}),t[61]=J,t[62]=ue);let de;t[63]!==le||t[64]!==ue?(de=(0,Z.jsxs)(yn,{children:[le,ue]}),t[63]=le,t[64]=ue,t[65]=de):de=t[65];let fe;t[66]!==E||t[67]!==x||t[68]!==v||t[69]!==_||t[70]!==d||t[71]!==a||t[72]!==i?(fe=a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`label`,{className:`sr-only`,htmlFor:`ok-replace-input`,children:`Replace`}),(0,Z.jsx)(Po,{id:`ok-replace-input`,value:i,onChange:e=>d(e.target.value),onKeyDown:E,placeholder:`Replace`,autoComplete:`off`,spellCheck:!1,className:`h-7 w-48 rounded-[min(var(--radius-md),12px)] px-2 text-sm shadow-none focus-visible:ring-2`}),(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Replace current match`,disabled:!x,onClick:_,children:(0,Z.jsx)(Ic,{"data-icon":`inline-start`,"aria-hidden":`true`})})}),(0,Z.jsx)(vn,{side:`bottom`,children:`Replace current match`})]}),(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Replace all matches`,disabled:!x,onClick:v,children:(0,Z.jsx)(Fc,{"data-icon":`inline-start`,"aria-hidden":`true`})})}),(0,Z.jsx)(vn,{side:`bottom`,children:`Replace all matches`})]})]}):null,t[66]=E,t[67]=x,t[68]=v,t[69]=_,t[70]=d,t[71]=a,t[72]=i,t[73]=fe):fe=t[73];let pe;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Z.jsx)(_o,{"data-icon":`inline-start`,"aria-hidden":`true`}),t[74]=pe):pe=t[74];let me;t[75]===y?me=t[76]:(me=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Close find`,onClick:y,children:pe})}),t[75]=y,t[76]=me);let he;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,Z.jsx)(vn,{side:`bottom`,children:`Close`}),t[77]=he):he=t[77];let ge;t[78]===me?ge=t[79]:(ge=(0,Z.jsxs)(yn,{children:[me,he]}),t[78]=me,t[79]=ge);let _e;return t[80]!==B||t[81]!==V||t[82]!==K||t[83]!==re||t[84]!==de||t[85]!==fe||t[86]!==ge?(_e=(0,Z.jsxs)(`search`,{"data-testid":`find-replace-bar`,"aria-label":`Find and replace`,className:`pointer-events-auto flex max-w-[min(calc(100vw-1rem),720px)] touch-manipulation items-center gap-1 rounded-[calc(var(--radius)+2px)] border border-input bg-popover/95 p-1 text-popover-foreground shadow-md shadow-black/10 backdrop-blur`,children:[D,B,V,K,re,de,fe,ge]}),t[80]=B,t[81]=V,t[82]=K,t[83]=re,t[84]=de,t[85]=fe,t[86]=ge,t[87]=_e):_e=t[87],_e}var LC={current:0,total:0},RC=120,zC=100;function BC(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=()=>e?h(e):null,t[0]=e,t[1]=n),(0,Q.useSyncExternalStore)(de,n,VC)}function VC(){return null}function HC(e){if(!e||e.isDestroyed)return null;let{from:t,to:n,empty:r}=e.state.selection;if(r)return null;let i=e.state.doc.textBetween(t,n,`
|
|
30
30
|
`,`
|
|
31
31
|
`).trim();return i.length===0||i.length>RC||i.includes(`
|
|
32
32
|
`)?null:i}function UC(e,t){return(Dn()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)&&!e.altKey&&e.key.toLocaleLowerCase()===t}function WC(e){let t=e.key.toLocaleLowerCase();return Dn()?e.metaKey&&e.altKey&&!e.ctrlKey&&t===`f`:e.ctrlKey&&!e.metaKey&&!e.altKey&&t===`h`}function GC(e){let t=st(e.state);return{current:t.matches.length===0?0:t.activeIndex+1,total:t.matches.length}}function KC(e,t){return e.current===t.current&&e.total===t.total}function qC(e,t,n){e&&!e.isDestroyed&&(e.commands.clearFindMatches(),e.commands.focus()),t(e=>({...e,open:!1,activeIndex:0})),n(LC)}function JC(e){!e||e.isDestroyed||typeof window>`u`||window.requestAnimationFrame(()=>{if(e.isDestroyed)return;let t=p(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 YC(e){let t=(0,$.c)(81),{activeDocName:n,isSourceMode:r}=e,i=BC(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)(LC),m,h;t[1]===n?(m=t[2],h=t[3]):(m=()=>{s.current!==n&&(s.current=n,d(ZC))},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(XC)},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(LC);return}if(!u.open||r){i.commands.clearFindMatches(),p(LC);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=GC(i);p(t=>KC(t,e)?t:e)},zC);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=st(i.state),t=GC(i);p(e=>KC(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=HC(i);d(n=>({...n,open:!0,replaceOpen:e,query:t??n.query,activeIndex:0}))},t=function(t){if(!(!n||r||t.defaultPrevented)){if(UC(t,`f`)){t.preventDefault(),u.open?qC(i,d,p):e(!1);return}if(WC(t)){t.preventDefault(),e(!0);return}if(UC(t,`g`)&&u.open){t.preventDefault(),(t.shiftKey?i?.commands.selectPreviousFindMatch():i?.commands.selectNextFindMatch())&&JC(i);return}t.key===`Escape`&&u.open&&(t.preventDefault(),qC(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=st(i.state),t=GC(i);p(e=>KC(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(){qC(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()&&JC(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()&&JC(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)&&JC(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)&&JC(i),N())},t[58]=j,t[59]=i,t[60]=u.replacement,t[61]=N,t[62]=H):H=t[62];let U=H;if(!u.open||!n||r)return null;let W,G,K,q,ee;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>d(t=>({...t,query:e,activeIndex:0})),G=e=>d(t=>({...t,replacement:e})),K=e=>d(t=>({...t,replaceOpen:e})),q=e=>d(t=>({...t,caseSensitive:e})),ee=e=>d(t=>({...t,wholeWord:e})),t[63]=W,t[64]=G,t[65]=K,t[66]=q,t[67]=ee):(W=t[63],G=t[64],K=t[65],q=t[66],ee=t[67]);let te;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?(te=(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)(IC,{findInputRef:a,query:u.query,replacement:u.replacement,replaceOpen:u.replaceOpen,caseSensitive:u.caseSensitive,wholeWord:u.wholeWord,current:f.current,total:f.total,onQueryChange:W,onReplacementChange:G,onReplaceOpenChange:K,onCaseSensitiveChange:q,onWholeWordChange:ee,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]=te):te=t[80],te}function XC(e){return{...e,open:!1,activeIndex:0}}function ZC(e){return{...e,activeIndex:0}}var QC=960,$C=1024;function ew(){let e=(0,$.c)(5),[t,n]=(0,Q.useState)(nw),[r,i]=(0,Q.useState)(tw),a,o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{let e=window.matchMedia(`(max-width: ${QC-1}px)`),t=window.matchMedia(`(max-width: ${$C-1}px)`),r=()=>{let r=e.matches;n(r?`sheet`:`panel`),i(!r&&t.matches)};return e.addEventListener(`change`,r),t.addEventListener(`change`,r),()=>{e.removeEventListener(`change`,r),t.removeEventListener(`change`,r)}},o=[],e[0]=a,e[1]=o):(a=e[0],o=e[1]),(0,Q.useEffect)(a,o);let s;return e[2]!==r||e[3]!==t?(s={layout:t,autoCollapse:r},e[2]=r,e[3]=t,e[4]=s):s=e[4],s}function tw(){return window.innerWidth>=QC&&window.innerWidth<$C}function nw(){return window.innerWidth<QC?`sheet`:`panel`}var rw={words:0,chars:0,tokens:0},iw=/[ -〿-ゟ゠-ヿ㐀-䶿一-鿿豈---ក-]/,aw=/[\p{L}\p{N}]/u,ow=new Set([`text`,`inlineCode`,`code`,`tag`]),sw=new Set([`html`,`definition`,`footnoteDefinition`,`yaml`,`toml`,`image`,`imageReference`,`mdxFlowExpression`,`mdxTextExpression`,`mdxjsEsm`,`rawMdxFallback`,`rawMdxFallbackMdast`]),cw=new Set([`paragraph`,`heading`,`blockquote`,`list`,`listItem`,`thematicBreak`,`table`,`tableRow`,`tableCell`,`mdxJsxFlowElement`,`commentBlock`]);function lw(e,t){if(!e)return;let n=e.type;if(!sw.has(n)){if(ow.has(n)){e.value&&(t.push(e.value),n===`code`&&t.push(`
|
|
33
33
|
`));return}if(n===`wikiLink`||n===`wikiLinkEmbed`){let n=e.data?.alias??e.value??``;n&&t.push(n);return}if(Array.isArray(e.children)){for(let n of e.children)lw(n,t);if(cw.has(n)&&t.length>0){let e=t[t.length-1];e&&!e.endsWith(`
|
|
34
34
|
`)&&t.push(`
|
|
35
|
-
`)}}}}function uw(e){try{let t=be().parseToMdast(e),n=[];return lw(t,n),n.join(``).trim()}catch(t){return console.warn(`[document-stats] mdast parse failed, falling back to raw text`,t),e.trim()}}function dw(e){if(!e)return 0;let t=0;for(let n of e.split(/\s+/))aw.test(n)&&t++;return t}function fw(e){let t=globalThis.Intl.Segmenter;if(!t)return dw(e);let n=new t(void 0,{granularity:`word`}),r=0;for(let t of n.segment(e))t.isWordLike&&r++;return r}function pw(e){let t=iw.test(e)?1.5:4;return Math.ceil(e.length/t)}function mw(e){if(!e)return{words:0,chars:0,tokens:0};let{body:t}=Cr(e);if(!t.trim())return{words:0,chars:0,tokens:0};let n=uw(t);return n?{words:iw.test(n)?fw(n):dw(n),chars:n.length,tokens:pw(n)}:{words:0,chars:0,tokens:0}}var hw=300;function gw(e,t){let n=(0,$.c)(4),[r,i]=(0,Q.useState)(rw),a,o;return n[0]!==t||n[1]!==e?(a=()=>{if(!e||!t){i(rw);return}let n=e.document.getText(`source`),r=!1,a=null,o=function(){r||i(mw(n.toString()))};o();let s=function(){a&&clearTimeout(a),a=setTimeout(o,hw)};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 _w(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`?vw: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 vw(e){return e===`synced`?`synced`:`connected`}var yw=oi;function bw(e,t={}){let n=j(e.componentName);return n.name===`*`?t.unregisteredSuffix?`${e.componentName} (unregistered)`:e.componentName:n.displayName??n.name}var xw=200,Sw=`Outside any block`;function Cw(e){let t=(0,$.c)(5),{editor:n}=e,r=De(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?ww(n,r):o.current?Sw:``,a.current=window.setTimeout(()=>{i.current&&(i.current.textContent=``,i.current.textContent=t),o.current=e,a.current=null},xw),()=>{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 ww(e,t){if(!t||t.ancestorChain.length===0)return``;let n=t.ancestorChain,r=n[n.length-1],i=bw(r,{unregisteredSuffix:!0});if(n.length===1)return`Selected: ${i}`;let a=n[n.length-2],o=bw(a);try{let t=e.state.doc.resolve(r.pos),n=t.index(t.depth),a=t.parent.childCount;return`Selected: ${i}, ${n+1} of ${a} in ${o}`}catch{return`Selected: ${i} in ${o}`}}function Tw(){let[e]=(0,Q.useState)(Ln);return e}function Ew({principal:e,identity:t}){return e&&e.source===`git-config`?{type:`human`,name:Dr(e.display_name),color:xr(e.id,qn),coeditor:t.coeditor,tabId:t.tabId,principalId:e.id}:e&&e.source===`synthesized`?{type:`human`,name:t.name,color:xr(e.id,qn),coeditor:t.coeditor,tabId:t.tabId}:{type:`human`,name:t.name,color:t.color,coeditor:t.coeditor,tabId:t.tabId}}function Dw(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 Ow=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&&Pn(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(ui(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(Jn(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(Tn(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(xn(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(Qn(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(En(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(mn(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(Xn(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=di(this.view,e.from,e.to),r={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof wn){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 Un){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():Dw(o.getBoundingClientRect(),s.getBoundingClientRect());r={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return r}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&Bn(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()}},kw=e=>new An({key:typeof e.pluginKey==`string`?new Ur(e.pluginKey):e.pluginKey,view:t=>new Ow({view:t,...e})});ri.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[kw({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 Aw=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 Fn(e,{textSerializers:Rn(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(ui(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(Jn(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(Tn(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(xn(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(Qn(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(En(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(mn(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(Xn(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=di(this.view,e.from,e.to);Bn({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()}},jw=e=>new An({key:typeof e.pluginKey==`string`?new Ur(e.pluginKey):e.pluginKey,view:t=>new Aw({view:t,...e})});ri.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?[jw({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 Mw(e,t){return e??new Ur(t)}var Nw=typeof window<`u`?Q.useLayoutEffect:Q.useEffect,Pw=new Set([`left`,`opacity`,`position`,`top`,`visibility`,`width`]),Fw=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(`.`)),Iw=new Set([`children`,`className`,`style`]),Lw=new Set([`tabIndex`]),Rw=new Set([`accessKey`,`autoCapitalize`,`contentEditable`,`contextMenu`,`dir`,`draggable`,`enterKeyHint`,`hidden`,`id`,`lang`,`nonce`,`role`,`slot`,`spellCheck`,`tabIndex`,`title`,`translate`]),zw={Blur:`focusout`,DoubleClick:`dblclick`,Focus:`focusin`,MouseEnter:`mouseenter`,MouseLeave:`mouseleave`};function Bw(e,t){return/^on[A-Z]/.test(e)&&typeof t==`function`}function Vw(e){return e.startsWith(`aria-`)||e.startsWith(`data-`),e}function Hw(e){return e.startsWith(`aria-`)||e.startsWith(`data-`)||Rw.has(e)}function Uw(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function Ww(e){let t=e.endsWith(`Capture`),n=(t?e.slice(0,-7):e).slice(2);return{eventName:zw[n]??n.toLowerCase(),options:t?{capture:!0}:void 0}}function Gw(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 Kw(e){return Lw.has(e)}function qw(e,t,n){if(t===`tabIndex`){e.tabIndex=Number(n);return}e[t]=n}function Jw(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 Yw(e,t){return typeof t!=`number`||t===0||e.startsWith(`--`)||Fw.has(e)?String(t):`${t}px`}function Xw(e,t){Pw.has(t)||e.style.removeProperty(Uw(t))}function Zw(e,t,n){Pw.has(t)||e.style.setProperty(Uw(t),Yw(t,n))}function Qw(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(r=>{if(Iw.has(r)||!Hw(r)||Bw(r,t[r])||Bw(r,n[r]))return;let i=t[r],a=n[r];if(i===a)return;let o=Vw(r);if(a==null||a===!1){Kw(r)&&Jw(e,r),e.removeAttribute(o);return}if(a===!0){Kw(r)&&qw(e,r,!0),e.setAttribute(o,``);return}if(Kw(r)){qw(e,r,a);return}e.setAttribute(o,String(a))})}function $w(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute(`class`)}}function eT(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){Xw(e,t);return}Zw(e,t,a)}})}function tT(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(!Bw(t,n))return;let{eventName:i,options:a}=Ww(t),o=t=>{n(Gw(e,t))};e.addEventListener(i,o,a),r.push({eventName:i,listener:o,options:a})}),r}function nT(e,t){let n=(0,Q.useRef)({}),r=(0,Q.useRef)([]);Nw(()=>{let i=n.current;return $w(e,i.className,t.className),eT(e,i.style,t.style),Qw(e,i,t),r.current=tT(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 rT=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)(Mw(e,`bubbleMenu`)).current;nT(d.current,l),typeof u==`function`?u(d.current):u&&(u.current=d.current);let{editor:p}=Ct(),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=kw({...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,Hs.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)(Mw(e,`floatingMenu`)).current;nT(u.current,c),typeof l==`function`?l(u.current):l&&(l.current=u.current);let{editor:f}=Ct(),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=jw({...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,Hs.createPortal)(s,u.current)});var iT=[{name:`paragraph`,label:`Text`,icon:Ac,isActive:e=>e.isActive(`paragraph`)&&!e.isActive(`list`),command:e=>e.chain().focus().setParagraph().run()},{name:`heading1`,label:`Heading 1`,icon:te,isActive:e=>e.isActive(`heading`,{level:1}),command:e=>e.chain().focus().toggleHeading({level:1}).run()},{name:`heading2`,label:`Heading 2`,icon:W,isActive:e=>e.isActive(`heading`,{level:2}),command:e=>e.chain().focus().toggleHeading({level:2}).run()},{name:`heading3`,label:`Heading 3`,icon:V,isActive:e=>e.isActive(`heading`,{level:3}),command:e=>e.chain().focus().toggleHeading({level:3}).run()},{name:`bulletList`,label:`Bullet List`,icon:v,isActive:e=>e.isActive(`list`,{ordered:!1})&&!e.isActive(`listItem`,{checked:!0})&&!e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleBulletList().run()},{name:`orderedList`,label:`Ordered List`,icon:K,isActive:e=>e.isActive(`list`,{ordered:!0}),command:e=>e.chain().focus().toggleOrderedList().run()},{name:`taskList`,label:`Task List`,icon:g,isActive:e=>e.isActive(`listItem`,{checked:!0})||e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleTaskList().run()},{name:`blockquote`,label:`Quote`,icon:jt,isActive:e=>e.isActive(`blockquote`),command:e=>e.chain().focus().toggleBlockquote().run()},{name:`codeBlock`,label:`Code Block`,icon:Uc,isActive:e=>e.isActive(`codeBlock`),command:e=>e.chain().focus().toggleCodeBlock().run()}];function aT(e){let t=(0,$.c)(18),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:oT},t[0]=n,t[1]=r);let{current:i,activeStates:a}=Re(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)(mt,{className:`size-3 opacity-50`}),t[6]=l):l=t[6];let u;t[7]!==s||t[8]!==c?(u=(0,Z.jsx)(ba,{asChild:!0,children:(0,Z.jsxs)(Y,{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=iT.map(e=>{let t=e.icon,r=a[e.name];return(0,Z.jsxs)(ya,{className:r?`bg-accent text-accent-foreground`:``,onSelect:()=>{e.command(n)},children:[(0,Z.jsx)(t,{className:`size-4`}),(0,Z.jsx)(`span`,{children:e.label})]},e.name)}),t[10]=a,t[11]=n,t[12]=d):d=t[12];let f;t[13]===d?f=t[14]:(f=(0,Z.jsx)(_a,{align:`start`,sideOffset:8,className:`w-44 max-h-(--radix-dropdown-menu-content-available-height) overflow-y-auto subtle-scrollbar`,children:d}),t[13]=d,t[14]=f);let p;return t[15]!==u||t[16]!==f?(p=(0,Z.jsxs)(va,{children:[u,f]}),t[15]=u,t[16]=f,t[17]=p):p=t[17],p}function oT(e){let t=Object.fromEntries(iT.map(t=>[t.name,t.isActive(e.editor)]));return{current:iT.find(e=>t[e.name])??iT[0],activeStates:t}}function sT(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 cT(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:re(typeof n.src==`string`?n.src:``)}function lT(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 uT(e){let t=(0,$.c)(10),{editor:n}=e,r;if(t[0]===n?r=t[1]:(r={editor:n,selector:dT},t[0]=n,t[1]=r),Re(r)===null)return null;let i;t[2]===n?i=t[3]:(i=e=>{e.preventDefault();let t=sT(n);t&&lT(t,cT(n))},t[2]=n,t[3]=i);let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(ua,{className:`size-3.5`}),t[4]=a):a=t[4];let o;t[5]===i?o=t[6]:(o=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,"aria-label":`Download file`,className:`text-accent-foreground`,onMouseDown:i,children:a})}),t[5]=i,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(vn,{side:`bottom`,sideOffset:8,children:`Download file`}),t[7]=s):s=t[7];let c;return t[8]===o?c=t[9]:(c=(0,Z.jsx)(`div`,{className:`flex items-center gap-0.5`,children:(0,Z.jsxs)(yn,{children:[o,s]})}),t[8]=o,t[9]=c),c}function dT(e){return sT(e.editor)}function fT(e){return sT(e)!==null}var pT=[{value:`left`,label:`Align left`,icon:Oe},{value:`center`,label:`Align center`,icon:Nt},{value:`right`,label:`Align right`,icon:Tt}];function mT(e){let t=e.state.selection.node;if(!t||t.type.name!==`jsxComponent`)return null;let n=t.attrs.componentName;if(n!==`img`&&n!==`CommonMarkImage`&&n!==`Embed`)return null;let r=(t.attrs.props??{}).align;return r===`left`||r===`right`||r===`center`?r:`center`}function hT(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:gT},t[0]=n,t[1]=r);let i=Re(r);if(i===null)return null;let a;t[2]!==i||t[3]!==n?(a=pT.map(e=>{let{value:t,label:r,icon:a}=e,o=i===t;return(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,"aria-label":r,"aria-pressed":o,className:o?`bg-accent text-primary`:`text-accent-foreground`,onMouseDown:e=>{e.preventDefault();let r=n.state.selection,i=r.node;if(!i||i.type.name!==`jsxComponent`)return;let a=String(i.attrs.componentName??``);if(a!==`img`&&a!==`CommonMarkImage`&&a!==`Embed`||i.attrs.kind!==`element`)return;let o=a===`CommonMarkImage`,s=r.from,c={...i.attrs.props??{},align:t},l=o?{...i.attrs,componentName:`img`,props:c,sourceDirty:!0}:{...i.attrs,props:c,sourceDirty:!0},u=n.state.tr.setNodeMarkup(s,null,l);u.setSelection(wn.create(u.doc,s)),He(n.view.nodeDOM(s),()=>{n.view.dispatch(u)})},children:(0,Z.jsx)(a,{className:`size-3.5`})})}),(0,Z.jsx)(vn,{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 gT(e){return mT(e.editor)}function _T(e){return mT(e)!==null}var vT=[{name:`bold`,icon:Vs,command:e=>e.chain().focus().toggleBold().run(),isActive:e=>e.isActive(`strong`),shortcut:`⌘ B`},{name:`italic`,icon:hc,command:e=>e.chain().focus().toggleItalic().run(),isActive:e=>e.isActive(`emphasis`),shortcut:`⌘ I`},{name:`underline`,icon:Zc,command:e=>e.chain().focus().toggleUnderline().run(),isActive:e=>e.isActive(`underline`),shortcut:`⌘ U`},{name:`strikethrough`,icon:qc,command:e=>e.chain().focus().toggleStrike().run(),isActive:e=>e.isActive(`strike`),shortcut:`⌘ ⇧ X`},{name:`code`,icon:Zs,command:e=>e.chain().focus().toggleCode().run(),isActive:e=>e.isActive(`code`),shortcut:`⌘ E`},{name:`highlight`,icon:mc,command:e=>e.chain().focus().toggleHighlight().run(),isActive:e=>e.isActive(`highlight`),shortcut:`⌘ ⇧ H`}];function yT(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:bT},t[0]=n,t[1]=r);let i=Re(r),a;t[2]!==i||t[3]!==n?(a=vT.map(e=>{let t=e.icon,r=i[e.name];return(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{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)(vn,{side:`bottom`,sideOffset:8,children:[(0,Z.jsx)(`span`,{className:`capitalize`,children:e.name}),(0,Z.jsx)(OS,{children:Dn()?e.shortcut:e.shortcut.replace(`⌘`,`Ctrl`)})]})]},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 bT(e){return Object.fromEntries(vT.map(t=>[t.name,t.isActive(e.editor)]))}function xT(e){let t=(0,$.c)(46),{editor:n}=e,[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),s=(0,Q.useRef)(null),c;t[0]===n?c=t[1]:(c=n.isActive(`link`),t[0]=n,t[1]=c);let l=c,u;t[2]===n?u=t[3]:(u=n.getAttributes(`link`).href??``,t[2]=n,t[3]=u);let d=u,f,p;t[4]===n?(f=t[5],p=t[6]):(f=()=>{let e=function(){n.state.selection.empty&&i(!1)};return n.on(`selectionUpdate`,e),()=>{n.off(`selectionUpdate`,e)}},p=[n],t[4]=n,t[5]=f,t[6]=p),(0,Q.useEffect)(f,p);let m,h;t[7]!==d||t[8]!==r?(m=()=>{r&&(o(d),requestAnimationFrame(()=>s.current?.focus()))},h=[r,d],t[7]=d,t[8]=r,t[9]=m,t[10]=h):(m=t[9],h=t[10]),(0,Q.useEffect)(m,h);let g;t[11]!==n||t[12]!==l||t[13]!==a?(g=function(){a.trim()?n.chain().focus().setLink({href:a.trim()}).run():l&&n.chain().focus().unsetLink().run(),i(!1)},t[11]=n,t[12]=l,t[13]=a,t[14]=g):g=t[14];let _=g,v;t[15]===n?v=t[16]:(v=function(){n.chain().focus().unsetLink().run(),i(!1)},t[15]=n,t[16]=v);let y=v,b;t[17]!==_||t[18]!==n?(b=function(e){e.key===`Enter`&&(e.preventDefault(),_()),e.key===`Escape`&&(e.preventDefault(),i(!1),n.chain().focus().run())},t[17]=_,t[18]=n,t[19]=b):b=t[19];let x=b;if(r){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=e=>o(e.target.value),t[20]=e):e=t[20];let n;t[21]!==x||t[22]!==a?(n=(0,Z.jsx)(`input`,{ref:s,type:`url`,placeholder:`Paste link`,value:a,onChange:e,onKeyDown:x,"aria-label":`Link URL`,className:`h-5 w-44 bg-transparent text-sm border-none outline-none placeholder:text-muted-foreground`}),t[21]=x,t[22]=a,t[23]=n):n=t[23];let r;t[24]===_?r=t[25]:(r=()=>{_()},t[24]=_,t[25]=r);let i;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(tc,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[26]=i):i=t[26];let c;t[27]===r?c=t[28]:(c=(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,"aria-label":`Apply link`,onClick:r,children:i}),t[27]=r,t[28]=c);let u;t[29]!==n||t[30]!==c?(u=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border bg-background px-2 py-1`,children:[n,c]}),t[29]=n,t[30]=c,t[31]=u):u=t[31];let f;t[32]!==d||t[33]!==l||t[34]!==y?(f=l&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,"aria-label":`Open link in new tab`,onMouseDown:e=>{e.preventDefault(),me(d)},children:(0,Z.jsx)(mo,{className:`size-3.5`})})}),(0,Z.jsx)(vn,{side:`bottom`,sideOffset:8,children:`Open link in new tab`})]}),(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,"aria-label":`Remove link`,onMouseDown:e=>{e.preventDefault(),y()},children:(0,Z.jsx)(Ue,{className:`size-3.5`})})}),(0,Z.jsx)(vn,{side:`bottom`,sideOffset:8,children:`Remove link`})]})]}),t[32]=d,t[33]=l,t[34]=y,t[35]=f):f=t[35];let p;return t[36]!==u||t[37]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[u,f]}),t[36]=u,t[37]=f,t[38]=p):p=t[38],p}let S=l?`bg-accent text-primary`:`text-accent-foreground`,C,w;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{e.preventDefault(),i(!0)},w=(0,Z.jsx)(vc,{className:`size-3.5`}),t[39]=C,t[40]=w):(C=t[39],w=t[40]);let T;t[41]===S?T=t[42]:(T=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,"aria-label":`Insert link`,className:S,onMouseDown:C,children:w})}),t[41]=S,t[42]=T);let E;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsxs)(vn,{side:`bottom`,sideOffset:8,children:[`Link`,(0,Z.jsx)(OS,{children:Dn()?`⌘ K`:`Ctrl K`})]}),t[43]=E):E=t[43];let D;return t[44]===T?D=t[45]:(D=(0,Z.jsxs)(yn,{children:[T,E]}),t[44]=T,t[45]=D),D}function ST({editor:e}){if(st(e.state).query||e.isActive(`codeBlock`))return!1;if(_T(e)||fT(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 CT(e){let t=(0,$.c)(22),{editor:n}=e,r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(0),o=(0,Q.useRef)(null),s;t[0]===n?s=t[1]:(s={editor:n,selector:OT},t[0]=n,t[1]=s);let c=Re(s),l;t[2]===n?l=t[3]:(l={editor:n,selector:DT},t[2]=n,t[3]=l);let u=Re(l),d;t[4]!==n.state||t[5]!==n.view?(d=()=>{try{let{from:e,to:t}=n.state.selection;return di(n.view,e,t)}catch{return new DOMRect}},t[4]=n.state,t[5]=n.view,t[6]=d):d=t[6];let f;if(t[7]!==n.view.dom||t[8]!==d){let e={getBoundingClientRect:d,contextElement:n.view.dom};f=()=>{let t=r.current;t&&(o.current?.(),o.current=Mn(e,t,()=>{Bn(e,t,{placement:`top`,strategy:`fixed`,middleware:[Tn(8),ui(),Jn({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(ET)}))},t[7]=n.view.dom,t[8]=d,t[9]=f}else f=t[9];let p=f,m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{o.current?.(),o.current=null,a(TT)},t[10]=m):m=t[10];let h=m,g;t[11]===p?g=t[12]:(g={onShow:p,onHide:h,strategy:`fixed`},t[11]=p,t[12]=g);let _;t[13]!==n||t[14]!==u||t[15]!==c||t[16]!==i?(_=c?(0,Z.jsx)(hT,{editor:n},`${i}-img-align`):u?(0,Z.jsx)(uT,{editor:n},`${i}-file`):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(aT,{editor:n}),(0,Z.jsx)(ro,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),(0,Z.jsx)(yT,{editor:n},i),(0,Z.jsx)(ro,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),(0,Z.jsx)(xT,{editor:n},`${i}-link`)]}),t[13]=n,t[14]=u,t[15]=c,t[16]=i,t[17]=_):_=t[17];let v;return t[18]!==n||t[19]!==g||t[20]!==_?(v=(0,Z.jsx)(rT,{ref:r,editor:n,"data-testid":`bubble-menu-bar`,appendTo:wT,shouldShow:ST,updateDelay:250,options:g,className:`z-50 flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:_}),t[18]=n,t[19]=g,t[20]=_,t[21]=v):v=t[21],v}function wT(){return document.body}function TT(e){return e+1}function ET(){}function DT(e){return fT(e.editor)}function OT(e){return _T(e.editor)}var kT=[{name:`addRowBefore`,icon:xe,label:`Add row above`,command:e=>e.chain().focus().addRowBefore().run()},{name:`addRowAfter`,icon:Ee,label:`Add row below`,command:e=>e.chain().focus().addRowAfter().run()},{name:`deleteRow`,icon:Ue,label:`Delete row`,command:e=>e.chain().focus().deleteRow().run()}],AT=[{name:`addColumnBefore`,icon:Mi,label:`Add column left`,command:e=>e.chain().focus().addColumnBefore().run()},{name:`addColumnAfter`,icon:Zi,label:`Add column right`,command:e=>e.chain().focus().addColumnAfter().run()},{name:`deleteColumn`,icon:Ue,label:`Delete column`,command:e=>e.chain().focus().deleteColumn().run()}],jT=[{name:`toggleHeaderRow`,icon:Jc,label:`Toggle header row`,command:e=>e.chain().focus().toggleHeaderRow().run()},{name:`toggleHeaderColumn`,icon:$s,label:`Toggle header column`,command:e=>e.chain().focus().toggleHeaderColumn().run()},{name:`deleteTable`,icon:fc,label:`Delete table`,command:e=>e.chain().focus().deleteTable().run()}];function MT({editor:e}){return st(e.state).query?!1:e.isActive(`table`)}function NT(e){let t=(0,$.c)(14),{action:n,editor:r}=e,i=n.icon,a;t[0]!==n||t[1]!==r?(a=e=>{e.preventDefault(),n.command(r)},t[0]=n,t[1]=r,t[2]=a):a=t[2];let o;t[3]===i?o=t[4]:(o=(0,Z.jsx)(i,{className:`size-3.5`}),t[3]=i,t[4]=o);let s;t[5]!==n.label||t[6]!==a||t[7]!==o?(s=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,"aria-label":n.label,className:`text-muted-foreground`,onMouseDown:a,children:o})}),t[5]=n.label,t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;t[9]===n.label?c=t[10]:(c=(0,Z.jsx)(vn,{side:`bottom`,sideOffset:8,children:n.label}),t[9]=n.label,t[10]=c);let l;return t[11]!==s||t[12]!==c?(l=(0,Z.jsxs)(yn,{children:[s,c]}),t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function PT(e){let t=(0,$.c)(13),{editor:n}=e,r;t[0]===n?r=t[1]:(r=kT.map(e=>(0,Z.jsx)(NT,{action:e,editor:n},e.name)),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(ro,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[2]=i):i=t[2];let a;t[3]===n?a=t[4]:(a=AT.map(e=>(0,Z.jsx)(NT,{action:e,editor:n},e.name)),t[3]=n,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(ro,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[5]=o):o=t[5];let s;t[6]===n?s=t[7]:(s=jT.map(e=>(0,Z.jsx)(NT,{action:e,editor:n},e.name)),t[6]=n,t[7]=s);let c;return t[8]!==n||t[9]!==r||t[10]!==a||t[11]!==s?(c=(0,Z.jsxs)(rT,{editor:n,"data-testid":`table-controls-menu`,shouldShow:MT,updateDelay:100,className:`flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:[r,i,a,o,s]}),t[8]=n,t[9]=r,t[10]=a,t[11]=s,t[12]=c):c=t[12],c}var FT=new WeakMap;function IT(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=Kn(e.color),n.textContent=e.name,t.append(n),t}var LT={state:`idle`,count:0,lastFiredAt:null,position:`append`,lastAgentId:null};function RT(){let e=new In({extensions:Ir});return{mdManager:e,text:C({mdManager:e}),html:_e({mdManager:e}),paste:pt({mdManager:e}),drop:P({mdManager:e})}}function zT(e){let{provider:t,placeholder:n,prebuiltMapping:r}=e;return[...ut.map(e=>e.name===`link`||e.name===`wikiLink`?e.configure({docName:t.configuration.name??``}):e),yw.configure({placeholder:n??`Type '/' for commands`,showOnlyCurrent:!0}),T.configure({document:t.document,...r?{ySyncOptions:{mapping:r}}:{}}),ri.create({name:`imageUploadDecoration`,addProseMirrorPlugins(){return[o]}}),ri.create({name:`collaborationCursor`,addProseMirrorPlugins(){let e=t.awareness;if(!e)throw Error(`[TiptapEditor] HocuspocusProvider has no awareness instance — cursor plugin cannot initialize`);return[N(e,{cursorBuilder:IT})]}})]}function BT(e){let{provider:t,clipboard:n,ctorStart:r}=e;return{onBeforeCreate:({editor:e})=>{FT.set(e,r)},onCreate:({editor:e})=>{n.html.setView(e.view);let r=FT.get(e);if(FT.delete(e),r==null)return;let i=performance.now();dt(`ok/editor/create-tiptap`,{docName:t.configuration.name??`unknown`,ytextLength:t.document.getText(`source`).length},{startTime:r,duration:Math.max(0,i-r)})},editorProps:{attributes:{class:`pt-4 pb-4 h-full`},clipboardTextParser:(e,t,r,i)=>{let a=n.mdManager.parse(e);return i.state.schema.nodeFromJSON(a).content},clipboardTextSerializer:(e,t)=>n.text(e,t),clipboardSerializer:n.html.serializer,handlePaste:(e,t)=>n.paste(e,t),handleDrop:(e,t)=>n.drop(e,t)},extensions:bf(zT(e))}}function VT(e){let{provider:t,placeholder:n,clipboard:r,ctorStart:i}=e,a=Or(zT({provider:t,placeholder:n,clipboard:r,ctorStart:i})),{doc:o,mapping:s}=ht(t.document.getXmlFragment(`default`),a);return{...BT({provider:t,placeholder:n,clipboard:r,ctorStart:i,prebuiltMapping:s}),content:o.toJSON(),element:null}}var HT=e=>{let t=(0,$.c)(21),{provider:n,placeholder:r,isSourceMode:i,portalTarget:a}=e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(LT),c=Tw(),{principal:l,activeDocName:u}=ot(),d=n.configuration.name??``,[f]=(0,Q.useState)(RT),p;t[0]!==f||t[1]!==r||t[2]!==n?(p=()=>()=>({editor:new _n(VT({provider:n,placeholder:r,clipboard:f,ctorStart:performance.now()})),ydoc:n.document,ytext:n.document.getText(`source`),provider:n}),t[0]=f,t[1]=r,t[2]=n,t[3]=p):p=t[3];let[m]=(0,Q.useState)(p),h,g;if(t[4]!==m||t[5]!==d||t[6]!==n.document){let e={viewCount:0,bytes:n.document.getText(`source`).length},r=Mt(d)??crypto.randomUUID();h=Q.use,g=Et({docName:d,mountId:r,construct:m,sizeStats:e}),t[4]=m,t[5]=d,t[6]=n.document,t[7]=h,t[8]=g}else h=t[7],g=t[8];let _=h(g),v=_.editor,y,b;t[9]===_?(y=t[10],b=t[11]):(y=()=>()=>{ft(_)},b=[_],t[9]=_,t[10]=y,t[11]=b),(0,Q.useEffect)(y,b);let x;return t[12]!==u||t[13]!==d||t[14]!==v||t[15]!==c||t[16]!==i||t[17]!==a||t[18]!==l||t[19]!==n?(x=(0,Z.jsx)(UT,{provider:n,isSourceMode:i,docName:d,activeDocName:u,identity:c,principal:l,editor:v,wrapperRef:o,flashStateRef:s,portalTarget:a}),t[12]=u,t[13]=d,t[14]=v,t[15]=c,t[16]=i,t[17]=a,t[18]=l,t[19]=n,t[20]=x):x=t[20],x},UT=e=>{let t=(0,$.c)(78),{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),m,h;t[0]===d?(m=t[1],h=t[2]):(m=()=>{let e=f.current;if(e)return e.appendChild(d),()=>{d.parentNode===e&&e.removeChild(d)}},h=[d],t[0]=d,t[1]=m,t[2]=h),(0,Q.useLayoutEffect)(m,h);let g;t[3]!==c||t[4]!==n.configuration.name?(g=()=>(xt(c,n.configuration.name??null),()=>{xt(c,null)}),t[3]=c,t[4]=n.configuration.name,t[5]=g):g=t[5];let _;t[6]!==c||t[7]!==n?(_=[c,n],t[6]=c,t[7]=n,t[8]=_):_=t[8],(0,Q.useEffect)(g,_);let v;t[9]!==c||t[10]!==n.configuration.name?(v=()=>{let e=n.configuration.name;if(e)return kt(e,c),()=>y(e,c)},t[9]=c,t[10]=n.configuration.name,t[11]=v):v=t[11];let b;t[12]!==c||t[13]!==n?(b=[c,n],t[12]=c,t[13]=n,t[14]=b):b=t[14],(0,Q.useEffect)(v,b);let x;t[15]!==c||t[16]!==n.configuration.name?(x=()=>{},t[15]=c,t[16]=n.configuration.name,t[17]=x):x=t[17];let S;t[18]!==c||t[19]!==n?(S=[c,n],t[18]=c,t[19]=n,t[20]=S):S=t[20],(0,Q.useEffect)(x,S);let C,T;t[21]===c?(C=t[22],T=t[23]):(T=()=>{let e=WT,t=null,n=()=>{if(t||c.isDestroyed)return;let n=p(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 p(c)?n():c.on(`create`,n),()=>{c.off(`create`,n),r()}},C=[c],t[21]=c,t[22]=C,t[23]=T),(0,Q.useEffect)(T,C);let E,D;t[24]!==u||t[25]!==n.document||t[26]!==l?(E=()=>{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)},Wn)};c(LT);let f=()=>{if(bn(e),!Sn(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`?Sn(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)}},D=[n.document,u,l],t[24]=u,t[25]=n.document,t[26]=l,t[27]=E,t[28]=D):(E=t[27],D=t[28]),(0,Q.useEffect)(E,D);let O,k;t[29]===n?(O=t[30],k=t[31]):(O=()=>{let e=function(){let e=window.location.hash,t=e.indexOf(`?`);return t<0?null:new URLSearchParams(e.slice(t+1)).get(`anchor`)},t=0,r,i=null;function a(){if(!i)return;let e=document.getElementById(i)??document.querySelector(`[data-mirror-source-id="${CSS.escape(i)}"]`);e?(e.scrollIntoView({behavior:`smooth`,block:`start`}),i=null,t=0):t<20?(t+=1,r=window.setTimeout(a,100)):(i=null,t=0)}let o=function(){let n=e();n&&(i=n,t=0,r!==void 0&&(clearTimeout(r),r=void 0),a())};return o(),n.on(`synced`,a),window.addEventListener(`hashchange`,o),()=>{r!==void 0&&clearTimeout(r),n.off(`synced`,a),window.removeEventListener(`hashchange`,o)}},k=[n],t[29]=n,t[30]=O,t[31]=k),(0,Q.useEffect)(O,k);let A,j;t[32]===c?(A=t[33],j=t[34]):(A=()=>{let e=function(e){let t=e.detail;if(!t||t.mode!==`wysiwyg`||c.isDestroyed)return;let n=p(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(Ss,e),()=>window.removeEventListener(Ss,e)},j=[c],t[32]=c,t[33]=A,t[34]=j),(0,Q.useEffect)(A,j);let M;t[35]!==a||t[36]!==i||t[37]!==o||t[38]!==r||t[39]!==s||t[40]!==n.awareness?(M=()=>{let e=n.awareness;if(e){if(i!==a){e.setLocalState(null);return}e.setLocalState({user:Ew({principal:s,identity:o}),mode:r?`source`:`wysiwyg`})}},t[35]=a,t[36]=i,t[37]=o,t[38]=r,t[39]=s,t[40]=n.awareness,t[41]=M):M=t[41];let N;t[42]!==a||t[43]!==i||t[44]!==o||t[45]!==r||t[46]!==s||t[47]!==n?(N=[n,i,a,o,s,r],t[42]=a,t[43]=i,t[44]=o,t[45]=r,t[46]=s,t[47]=n,t[48]=N):N=t[48],(0,Q.useEffect)(M,N);let P,F;t[49]!==c||t[50]!==r?(P=()=>(w(c,r),()=>{w(c,!1)}),F=[c,r],t[49]=c,t[50]=r,t[51]=P,t[52]=F):(P=t[51],F=t[52]),(0,Q.useEffect)(P,F);let I;t[53]!==c||t[54]!==r?(I=!r&&(0,Z.jsx)(CT,{editor:c}),t[53]=c,t[54]=r,t[55]=I):I=t[55];let R;t[56]!==c||t[57]!==r?(R=!r&&(0,Z.jsx)(PT,{editor:c}),t[56]=c,t[57]=r,t[58]=R):R=t[58];let z;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(`div`,{ref:f,style:{display:`contents`}}),t[59]=z):z=t[59];let B;t[60]===c?B=t[61]:(B=(0,Z.jsx)(Fe,{editor:c,className:`tiptap-editor-portal-content h-full`}),t[60]=c,t[61]=B);let V;t[62]!==d||t[63]!==B?(V=(0,Hs.createPortal)(B,d),t[62]=d,t[63]=B,t[64]=V):V=t[64];let H;t[65]===c?H=t[66]:(H=(0,Z.jsx)(Cw,{editor:c}),t[65]=c,t[66]=H);let U;t[67]===c?U=t[68]:(U=L(c),t[67]=c,t[68]=U);let W;t[69]===U.store?W=t[70]:(W=(0,Z.jsx)(ie,{store:U.store}),t[69]=U.store,t[70]=W);let G;return t[71]!==I||t[72]!==R||t[73]!==V||t[74]!==H||t[75]!==W||t[76]!==l?(G=(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:[I,R,z,V,H,W]}),t[71]=I,t[72]=R,t[73]=V,t[74]=H,t[75]=W,t[76]=l,t[77]=G):G=t[77],G};function WT(){return Dt()}function GT(e){let t=(0,$.c)(2),{docName:n,provider:r,children:i}=e;(0,Q.use)(St(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 KT=`__back-nav__`;function qT(e){return e instanceof Pe||e instanceof ct||e instanceof Ae||e instanceof qe||e instanceof vt||e instanceof Ke?e.docName:null}function JT(e){return e instanceof Pe?{title:`Couldn't load document`,summary:`"${e.docName}" took too long. Check your connection.`}:e instanceof ct?{title:`Connection dropped`,summary:`Lost connection to "${e.docName}".`}:e instanceof Ae?{title:`Document not found`,summary:`"${e.docName}" doesn't exist.`}:e instanceof qe?{title:`Couldn't open document`,summary:`Something went wrong opening "${e.docName}".`}:e instanceof vt?{title:`Server can't open documents`,summary:`This project's running server doesn't support live editing. Restart Open Knowledge to fix.`}:e instanceof Ke?{title:`Cancelled`,summary:`You cancelled loading "${e.docName}".`}:{title:`Unknown error`,summary:e instanceof Error&&e.message?e.message:`An unexpected error occurred.`}}function YT(e){let t=(0,$.c)(27),{error:n,resetErrorBoundary:r,activeDocName:i,previousDocName:a,onNavigateBack:o}=e,s;t[0]===n?s=t[1]:(s=JT(n),t[0]=n,t[1]=s);let{title:c,summary:l}=s,u=!!a&&!!o,d=(0,Q.useRef)(null),f,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{d.current?.focus()},p=[],t[2]=f,t[3]=p):(f=t[2],p=t[3]),(0,Q.useEffect)(f,p);let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(SS,{size:80,variant:`sleeping`}),t[4]=m):m=t[4];let h;t[5]===c?h=t[6]:(h=(0,Z.jsx)(`h2`,{id:`document-error-title`,className:`text-2xl font-light tracking-tighter text-balance`,children:c}),t[5]=c,t[6]=h);let g;t[7]===l?g=t[8]:(g=(0,Z.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:l}),t[7]=l,t[8]=g);let _;t[9]!==h||t[10]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[h,g]}),t[9]=h,t[10]=g,t[11]=_):_=t[11];let v;t[12]===r?v=t[13]:(v=(0,Z.jsx)(Y,{ref:d,variant:`default`,onClick:r,children:`Try again`}),t[12]=r,t[13]=v);let y;t[14]!==i||t[15]!==u||t[16]!==n||t[17]!==o||t[18]!==a||t[19]!==r?(y=u?(0,Z.jsx)(Y,{variant:`ghost`,className:`font-mono uppercase`,onClick:()=>{!a||!o||(et(qT(n)??i),o(a),r(KT))},children:`Go back`}):null,t[14]=i,t[15]=u,t[16]=n,t[17]=o,t[18]=a,t[19]=r,t[20]=y):y=t[20];let b;t[21]!==v||t[22]!==y?(b=(0,Z.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[v,y]}),t[21]=v,t[22]=y,t[23]=b):b=t[23];let x;return t[24]!==b||t[25]!==_?(x=(0,Z.jsxs)(`div`,{role:`alert`,"aria-labelledby":`document-error-title`,"data-slot":`document-error-boundary`,className:`flex h-full flex-col items-center justify-center gap-8 p-8 text-center`,children:[m,_,b]}),t[24]=b,t[25]=_,t[26]=x):x=t[26],x}function XT(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)(YT,{...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]===KT){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}: ${JT(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)(O,{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 ZT(e){let t=e.document.getText(`source`).toString(),{map:n,parseError:r}=Qr(t);return{map:n,keys:Pr(t),parseError:r}}function QT(e){let t=(0,$.c)(167),{provider:n}=e,[r,i]=(0,Q.useState)(null),a;t[0]===n?a=t[1]:(a=()=>ZT(n),t[0]=n,t[1]=a);let[o,s]=(0,Q.useState)(a),c,l;t[2]===n?(c=t[3],l=t[4]):(c=()=>{let e=Br(n);i(e),s(e.current());let t=e.subscribe(e=>{s(e)});return()=>{t(),e.dispose(),i(t=>t===e?null:t)}},l=[n],t[2]=n,t[3]=c,t[4]=l),(0,Q.useEffect)(c,l);let u=o.map,d=o.keys,f=o.parseError,[p,m]=(0,Q.useState)(!1),h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h={},t[5]=h):h=t[5];let[g,_]=(0,Q.useState)(h),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),S;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(S={},t[6]=S):S=t[6];let[C,w]=(0,Q.useState)(S),T;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(T={},t[7]=T):T=t[7];let[E,D]=(0,Q.useState)(T),O=n.configuration.name??``,k;t[8]===O?k=t[9]:(k=nE(O),t[8]=O,t[9]=k);let A=k,j;t[10]===O?j=t[11]:(j=eE(O),t[10]=O,t[11]=j);let M=Aa(A?null:j),N;t[12]!==M||t[13]!==A?(N=!A&&M.state.status===`ready`?M.state.data.folder.frontmatter_defaults??{}:{},t[12]=M,t[13]=A,t[14]=N):N=t[14];let P=N,F;t[15]!==M||t[16]!==A?(F=!A&&M.state.status===`ready`?M.state.data.frontmatterSources:{},t[15]=M,t[16]=A,t[17]=F):F=t[17];let I=F,L;t[18]===r?L=t[19]:(L=function(e){if(!r)return{ok:!1,error:`Connecting`};let t=r.patch(e);if(t.ok)return{ok:!0};if(t.error.code===`WRITE_ERROR`)return console.warn(`[PropertyPanel] binding write error:`,t.error.detail),{ok:!1,error:t.error.detail};let n=Ar(t.error);return{ok:!1,error:t.error.issues[0]?.message??`Invalid patch payload`,fieldErrors:Object.keys(n).length>0?n:void 0}},t[18]=r,t[19]=L);let R=L,z;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(z=function(e){w(t=>{if(!Object.hasOwn(t,e))return t;let n={...t};return delete n[e],n})},t[20]=z):z=t[20];let B=z,V;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(V=function(e,t){if(e.ok)return;let n=e.error??`Failed to update property`,r=e.fieldErrors??{};w(e=>{let i={...e};for(let e of t)i[e]=r[e]??n;return i}),D(e=>{let n={...e};for(let e of t)n[e]=(n[e]??0)+1;return n})},t[21]=V):V=t[21];let H=V,U;t[22]===R?U=t[23]:(U=function(e,t){B(e),H(R({[e]:t}),[e])},t[22]=R,t[23]=U);let W=U,G;t[24]===R?G=t[25]:(G=function(e){B(e),H(R({[e]:null}),[e])},t[24]=R,t[25]=G);let K=G,q;t[26]===r?q=t[27]:(q=function(e,t){if(!r)return{ok:!1,error:`Connecting`};if(e===t)return{ok:!0};let n=r.rename(e,t);if(n.ok)return{ok:!0};if(n.error.code===`WRITE_ERROR`)return{ok:!1,error:n.error.detail};let i=Ar(n.error);return{ok:!1,error:n.error.issues[0]?.message??`Failed to rename`,fieldErrors:Object.keys(i).length>0?i:void 0}},t[26]=r,t[27]=q);let ee=q,te;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(te=function(e,t){return`${e} ${t}`},t[28]=te):te=t[28];let ne=te,re;t[29]!==r||t[30]!==d?(re=function(e){if(!r)return;let t=String(e.active.id),n=e.over?String(e.over.id):null;if(!n||t===n)return;let i=d.map((e,t)=>ne(e,t)),a=i.indexOf(t),o=i.indexOf(n);if(a<0||o<0)return;let s=d.slice(),[c]=s.splice(a,1);if(!c)return;s.splice(o,0,c);let l=r.reorder(s);l.ok||console.warn(`[PropertyPanel] reorder failed:`,l.error)},t[29]=r,t[30]=d,t[31]=re):re=t[31];let ie=re,ae;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(ae={activationConstraint:{distance:4}},t[32]=ae):ae=t[32];let oe;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(oe={coordinateGetter:Ra},t[33]=oe):oe=t[33];let se=po(fa(ea,ae),fa(Xi,oe)),le;t[34]!==P||t[35]!==W||t[36]!==u?(le=function(e,t){let n=u[e]??rE(P[e]);if(n===void 0)return;_(n=>({...n,[e]:t}));let r=Ji(n,t);(!Object.hasOwn(u,e)||!$T(n,r))&&W(e,r)},t[34]=P,t[35]=W,t[36]=u,t[37]=le):le=t[37];let J=le,ue;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(ue=function(){y({name:``,type:`text`,value:``,error:null}),m(!1)},t[38]=ue):ue=t[38];let de=ue,{addPropertySignal:fe,clearAddProperty:pe}=hC(),me;t[39]!==fe||t[40]!==O?(me=fe.get(O)??0,t[39]=fe,t[40]=O,t[41]=me):me=t[41];let he=me,ge,_e;t[42]===he?(ge=t[43],_e=t[44]):(ge=()=>{he>0&&(y({name:``,type:`text`,value:``,error:null}),m(!1))},_e=[he],t[42]=he,t[43]=ge,t[44]=_e),(0,Q.useEffect)(ge,_e);let ve,ye;t[45]!==pe||t[46]!==O?(ve=()=>()=>pe(O),ye=[O,pe],t[45]=pe,t[46]=O,t[47]=ve,t[48]=ye):(ve=t[47],ye=t[48]),(0,Q.useEffect)(ve,ye);let be;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(be=function(e){y(t=>{if(!t)return t;let n=e===`date`?new Date().toISOString().slice(0,10):ha[e];return{...t,type:e,value:n,error:null}})},t[49]=be):be=t[49];let xe=be,Se;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(Se=function(e){y(t=>t&&{...t,value:e})},t[50]=Se):Se=t[50];let Ce=Se,we;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(we=function(e){y(t=>t&&{...t,name:e,error:null})},t[51]=we):we=t[51];let Te=we,Ee;t[52]!==v||t[53]!==R||t[54]!==u?(Ee=function(){if(!v)return;let e=v.name.trim();if(!e){y({...v,error:`Name is required`});return}if(e===`frontmatter`){y({...v,error:`"frontmatter" is a reserved property name`});return}if(Object.hasOwn(u,e)){y({...v,error:`Property "${e}" already exists`});return}let t=R({[e]:v.value});if(t.ok){y(null);return}let n=t.fieldErrors?.[e],r=t.error??`Failed to add property`;y({...v,error:n??r})},t[52]=v,t[53]=R,t[54]=u,t[55]=Ee):Ee=t[55];let De=Ee,Oe;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=function(){y(null)},t[56]=Oe):Oe=t[56];let ke=Oe,Ae;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=function(e){x({key:e,draft:e,error:null})},t[57]=Ae):Ae=t[57];let je=Ae,Me;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(Me=function(e){x(t=>t&&{...t,draft:e,error:null})},t[58]=Me):Me=t[58];let Ne=Me,Pe;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=function(){x(null)},t[59]=Pe):Pe=t[59];let Fe=Pe,Ie;t[60]!==u||t[61]!==ee||t[62]!==b?(Ie=function(){if(!b)return;let e=b.draft.trim();if(!e){x(null);return}if(e===b.key){x(null);return}if(e===`frontmatter`){x({...b,error:`"frontmatter" is a reserved property name`});return}if(Object.hasOwn(u,e)){x({...b,error:`Property "${e}" already exists`});return}let t=ee(b.key,e);if(t.ok){_(t=>{if(!Object.hasOwn(t,b.key))return t;let n={...t};return n[e]=n[b.key],delete n[b.key],n}),B(b.key),x(null);return}let n=t.fieldErrors?.[e]??t.fieldErrors?.[b.key]??t.error??`Failed to rename property`;x({...b,error:n})},t[60]=u,t[61]=ee,t[62]=b,t[63]=Ie):Ie=t[63];let Le=Ie,Re;t[64]!==u||t[65]!==d?(Re=d.length>0?d:Object.keys(u),t[64]=u,t[65]=d,t[66]=Re):Re=t[66];let ze=Re,Be;if(t[67]!==ze){Be=new Map;for(let e of ze)Be.set(e,(Be.get(e)??0)+1);t[67]=ze,t[68]=Be}else Be=t[68];let Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe;if(t[69]!==v||t[70]!==P||t[71]!==I||t[72]!==p||t[73]!==W||t[74]!==Le||t[75]!==Be||t[76]!==C||t[77]!==ie||t[78]!==u||t[79]!==g||t[80]!==f||t[81]!==K||t[82]!==b||t[83]!==ze||t[84]!==E||t[85]!==se||t[86]!==J){Qe=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Object.keys(P).filter(e=>!Object.hasOwn(u,e)).sort();if(ze.length===0&&e.length===0&&!v&&!f){Qe=null;break bb0}Xe=`property-panel editor-content-aligned pt-4 pb-4 text-sm`,Ze=`property-panel`,He=Lo,qe=!p,t[99]===Symbol.for(`react.memo_cache_sentinel`)?(Je=e=>m(!e),t[99]=Je):Je=t[99];let n=!p,r;t[100]===n?r=t[101]:(r=(0,Z.jsx)(No,{"data-expanded":n,className:`size-3.5 shrink-0 text-muted-foreground transition-transform duration-150 ease-out data-[expanded=true]:rotate-90`}),t[100]=n,t[101]=r);let i;t[102]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`span`,{children:`Properties`}),t[102]=i):i=t[102],t[103]===r?Ye=t[104]:(Ye=(0,Z.jsx)(Io,{asChild:!0,children:(0,Z.jsxs)(Y,{type:`button`,variant:`ghost`,className:`mb-1.5 flex h-auto w-fit bg-transparent! items-center gap-1 px-1 py-0.5 text-base font-medium text-foreground hover:bg-transparent hover:text-foreground`,children:[r,i]})}),t[103]=r,t[104]=Ye),Ve=Fo,Ue=`overflow-hidden data-[state=open]:animate-[collapsible-down_150ms_ease-out] data-[state=closed]:animate-[collapsible-up_150ms_ease-in]`,t[105]===f?We=t[106]:(We=f?(0,Z.jsxs)(`div`,{role:`alert`,"data-testid":`property-panel-yaml-error`,className:`mb-1 flex items-start gap-1.5 rounded border border-destructive/30 bg-destructive/5 px-2 py-1.5 text-[11px] text-destructive`,children:[(0,Z.jsx)(dr,{className:`size-3.5 shrink-0 mt-0.5`}),(0,Z.jsxs)(`div`,{children:[`Frontmatter YAML is malformed; fix in source mode to recover.`,(0,Z.jsx)(`span`,{className:`block text-[10px] opacity-80`,children:f})]})]}):null,t[105]=f,t[106]=We);let a;if(t[107]!==ze){let e;t[109]===Symbol.for(`react.memo_cache_sentinel`)?(e=(e,t)=>ne(e,t),t[109]=e):e=t[109],a=ze.map(e),t[107]=ze,t[108]=a}else a=t[108];let o;if(t[110]!==W||t[111]!==Le||t[112]!==Be||t[113]!==C||t[114]!==u||t[115]!==g||t[116]!==K||t[117]!==b||t[118]!==ze||t[119]!==E||t[120]!==J){let e;t[122]!==W||t[123]!==Le||t[124]!==Be||t[125]!==C||t[126]!==u||t[127]!==g||t[128]!==K||t[129]!==b||t[130]!==E||t[131]!==J?(e=(e,t)=>{let n=u[e];if(n===void 0)return null;let r=g[e]??tr(n),i=b?.key===e?b:null,a=(Be.get(e)??0)>1;return(0,Z.jsx)(Wi,{sortableId:ne(e,t),keyName:e,value:n,declared:r,error:C[e]??null,resetCounter:E[e]??0,isDuplicate:a,rename:{state:i,onBegin:()=>je(e),onChangeDraft:Ne,onCommit:Le,onCancel:Fe},onCommit:t=>W(e,t),onChangeType:t=>J(e,t),onRemove:()=>K(e)},`${e}-${t}`)},t[122]=W,t[123]=Le,t[124]=Be,t[125]=C,t[126]=u,t[127]=g,t[128]=K,t[129]=b,t[130]=E,t[131]=J,t[132]=e):e=t[132],o=ze.map(e),t[110]=W,t[111]=Le,t[112]=Be,t[113]=C,t[114]=u,t[115]=g,t[116]=K,t[117]=b,t[118]=ze,t[119]=E,t[120]=J,t[121]=o}else o=t[121];let s;t[133]!==a||t[134]!==o?(s=(0,Z.jsx)(sa,{items:a,strategy:aa,children:o}),t[133]=a,t[134]=o,t[135]=s):s=t[135],t[136]!==ie||t[137]!==se||t[138]!==s?(Ge=(0,Z.jsx)(la,{sensors:se,collisionDetection:ra,onDragEnd:ie,children:s}),t[136]=ie,t[137]=se,t[138]=s,t[139]=Ge):Ge=t[139];let c;t[140]!==P||t[141]!==I||t[142]!==W||t[143]!==C||t[144]!==E||t[145]!==J?(c=e=>{let t=P[e],n=rE(t),r=tr(n),i=I[e]??``;return(0,Z.jsx)(Wi,{keyName:e,value:n,declared:r,error:C[e]??null,resetCounter:E[e]??0,isInherited:!0,badge:(0,Z.jsx)(oo,{source:i}),onCommit:t=>W(e,t),onChangeType:t=>J(e,t)},`inherited-${e}`)},t[140]=P,t[141]=I,t[142]=W,t[143]=C,t[144]=E,t[145]=J,t[146]=c):c=t[146],Ke=e.map(c)}t[69]=v,t[70]=P,t[71]=I,t[72]=p,t[73]=W,t[74]=Le,t[75]=Be,t[76]=C,t[77]=ie,t[78]=u,t[79]=g,t[80]=f,t[81]=K,t[82]=b,t[83]=ze,t[84]=E,t[85]=se,t[86]=J,t[87]=Ve,t[88]=He,t[89]=Ue,t[90]=We,t[91]=Ge,t[92]=Ke,t[93]=qe,t[94]=Je,t[95]=Ye,t[96]=Xe,t[97]=Ze,t[98]=Qe}else Ve=t[87],He=t[88],Ue=t[89],We=t[90],Ge=t[91],Ke=t[92],qe=t[93],Je=t[94],Ye=t[95],Xe=t[96],Ze=t[97],Qe=t[98];if(Qe!==Symbol.for(`react.early_return_sentinel`))return Qe;let $e;t[147]!==v||t[148]!==De?($e=v?(0,Z.jsx)(pa,{draft:v,onChangeName:Te,onChangeType:xe,onChangeValue:Ce,onCommit:De,onCancel:ke}):(0,Z.jsxs)(`div`,{className:`mt-1 flex items-center gap-1`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-7 w-4 shrink-0`}),(0,Z.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`add-property-trigger`,onClick:de,"aria-label":`Add property`,className:`flex items-center gap-1.5 rounded px-2 py-1 font-medium text-sm hover:bg-muted/50 hover:text-foreground`,children:[(0,Z.jsx)(ce,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:`Add`})]})]}),t[147]=v,t[148]=De,t[149]=$e):$e=t[149];let et;t[150]!==Ve||t[151]!==Ue||t[152]!==We||t[153]!==Ge||t[154]!==Ke||t[155]!==$e?(et=(0,Z.jsxs)(Ve,{className:Ue,children:[We,Ge,Ke,$e]}),t[150]=Ve,t[151]=Ue,t[152]=We,t[153]=Ge,t[154]=Ke,t[155]=$e,t[156]=et):et=t[156];let tt;t[157]!==He||t[158]!==qe||t[159]!==Je||t[160]!==Ye||t[161]!==et?(tt=(0,Z.jsxs)(He,{open:qe,onOpenChange:Je,children:[Ye,et]}),t[157]=He,t[158]=qe,t[159]=Je,t[160]=Ye,t[161]=et,t[162]=tt):tt=t[162];let nt;return t[163]!==Xe||t[164]!==Ze||t[165]!==tt?(nt=(0,Z.jsx)(`div`,{className:Xe,"data-testid":Ze,children:tt}),t[163]=Xe,t[164]=Ze,t[165]=tt,t[166]=nt):nt=t[166],nt}function $T(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length?e.every((e,n)=>e===t[n]):!1:e===t}function eE(e){if(!e)return``;let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}var tE=/(^|\/)\.ok\/templates\//;function nE(e){return tE.test(e)}function rE(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`?e:Array.isArray(e)?e.map(e=>typeof e==`string`?e:JSON.stringify(e)):e==null?``:JSON.stringify(e)}var iE=it(`LARGE_DOC_CHAR_THRESHOLD`,5e5);function aE(e){let t=e.threshold??iE;return e.ytextLength>t?{renderSource:e.isSourceMode||e.visitedSource,renderVisual:!e.isSourceMode||e.visitedVisual,isLarge:!0}:{renderSource:!0,renderVisual:!0,isLarge:!1}}function oE(e){return e.hasEmittedFirstToggle||!e.isLarge?!1:e.renderSource&&e.renderVisual}var sE=it(`ACTIVITY_MOUNT_LIMIT`,3);function cE(){return n(()=>import(`./SourceEditor-CuJQDNNo.js`),__vite__mapDeps([44,1,33,2,34,35,20,36,37,38,39,19,3,6,7,4,10,9,40,45,22]),import.meta.url)}var lE=(0,Q.lazy)(async()=>({default:(await cE()).SourceEditor}));function uE(e,t,n){if(n<=0)return[];let r=e.filter(e=>!Be(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 dE(e,t){return t.kind===`idle`?null:t.kind===`failed`&&t.failedDocNames.includes(e)?{kind:`failed`,title:`Couldn't reconnect after server restart`,summary:t.reason===`clear-data-timeout`?`Local collaboration data for "${e}" could not be cleared in time. Reload to retry.`:`Local collaboration data for "${e}" could not be cleared. Reload to retry.`,actionLabel:`Reload`}:t.kind===`recovering`&&t.docNames.includes(e)?{kind:`recovering`,title:`Reconnecting after server restart`,summary:t.phase===`clearing-local-cache`?`Clearing local collaboration data for "${e}" before reconnecting.`:`Reopening "${e}" with a fresh local collaboration cache.`}:null}function fE(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(Ve,{name:`activity-pool`,children:(0,Z.jsx)(pE,{...e})}),t[0]=e,t[1]=n),n}function pE(e){let t=(0,$.c)(15),{activeDocName:n,isSourceMode:r,editorPlaceholder:i,previousDocName:a,onNavigateBack:o,onRecycle:s}=e,{poolEntries:c,serverRestartRecovery:l}=ot(),{pages:u,loading:d}=qr(),f=uE(c,n,sE),p=(0,Q.useRef)(``),m=f.map(mE).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)Ne(e);for(let e of i){let t=h.current.find(t=>t.docName===e)?.poolEventId;le(e,t&&t.length>0?t:crypto.randomUUID())}dt(`ok/activity/mount-list-change`,{active:n,mounted:t,evicted:r}),p.current=m,at(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)(yE,{entry:e,isActive:e.docName===n,isSourceMode:r,editorPlaceholder:i,isNewDoc:!d&&!u.has(e.docName),previousDocName:a,onNavigateBack:o,onRecycle:s,serverRestartRecovery:l},e.docName),t[3]=n,t[4]=i,t[5]=r,t[6]=d,t[7]=o,t[8]=s,t[9]=u,t[10]=a,t[11]=l,t[12]=v):v=t[12];let y=f.map(v),b;return t[13]===y?b=t[14]:(b=(0,Z.jsx)(Z.Fragment,{children:y}),t[13]=y,t[14]=b),b}function mE(e){return e.docName}function hE(e){let t=(0,$.c)(8),{isActive:n,children:r}=e,i=(0,Q.useRef)(null),a=(0,Q.useRef)(0),o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{let e=i.current;if(!e)return;let t=()=>{e.scrollTop>0&&(a.current=e.scrollTop)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},s=[],t[0]=o,t[1]=s):(o=t[0],s=t[1]),(0,Q.useEffect)(o,s);let c,l;t[2]===n?(c=t[3],l=t[4]):(c=()=>{if(!n)return;let e=i.current;if(!e)return;let t=a.current;if(t===0||(e.scrollTop=t,e.scrollTop===t))return;let r=!1,o=()=>{r||(r=!0,s.disconnect(),clearTimeout(c))},s=new ResizeObserver(()=>{r||!e||e.scrollHeight>t&&(e.scrollTop=t,e.scrollTop===t&&o())});s.observe(e);let c=setTimeout(o,500);return o},l=[n],t[2]=n,t[3]=c,t[4]=l),(0,Q.useLayoutEffect)(c,l);let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u={overflowAnchor:`auto`},t[5]=u):u=t[5];let d;return t[6]===r?d=t[7]:(d=(0,Z.jsx)(`div`,{ref:i,"data-testid":`editor-scroll-container`,className:`subtle-scrollbar h-full overflow-y-auto pt-14 scroll-pt-14`,style:u,children:r}),t[6]=r,t[7]=d),d}function gE(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)(zx,{}),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)(lE,{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 _E(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)(Pc,{className:`size-5`,"aria-hidden":`true`}):(0,Z.jsx)(ue,{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)(Y,{type:`button`,onClick:vE,children:[(0,Z.jsx)(Pc,{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 vE(){return window.location.reload()}function yE(e){let t=(0,$.c)(48),{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a,isNewDoc:o,previousDocName:s,onNavigateBack:c,onRecycle:l,serverRestartRecovery:u}=e,d;t[0]!==n.docName||t[1]!==u?(d=dE(n.docName,u),t[0]=n.docName,t[1]=u,t[2]=d):d=t[2];let f=d,p;t[3]===n.docName?p=t[4]:(p=()=>{let e=document.createElement(`div`);return e.setAttribute(`data-ok-editor-portal`,n.docName),e.style.display=`contents`,e},t[3]=n.docName,t[4]=p);let[m]=(0,Q.useState)(p),h=n.provider.document.getText(`source`).length,[g,_]=(0,Q.useState)(i),[v,y]=(0,Q.useState)(!i),b,x;t[5]!==i||t[6]!==g||t[7]!==v?(b=()=>{i&&!g?_(!0):!i&&!v&&y(!0)},x=[i,g,v],t[5]=i,t[6]=g,t[7]=v,t[8]=b,t[9]=x):(b=t[8],x=t[9]),(0,Q.useEffect)(b,x);let S=aE({ytextLength:h,isSourceMode:i,visitedSource:g,visitedVisual:v}),C=(0,Q.useRef)(``),w=`${S.isLarge}-${S.renderSource}-${S.renderVisual}`,T,E;t[10]!==n.docName||t[11]!==S.isLarge||t[12]!==S.renderSource||t[13]!==S.renderVisual||t[14]!==w||t[15]!==i||t[16]!==h?(T=()=>{C.current!==w&&(C.current=w,S.isLarge&&dt(`ok/activity/defer-mount`,{docName:n.docName,ytextLength:h,isSourceMode:i,renderSource:S.renderSource,renderVisual:S.renderVisual}))},E=[w,S.isLarge,S.renderSource,S.renderVisual,n.docName,h,i],t[10]=n.docName,t[11]=S.isLarge,t[12]=S.renderSource,t[13]=S.renderVisual,t[14]=w,t[15]=i,t[16]=h,t[17]=T,t[18]=E):(T=t[17],E=t[18]),(0,Q.useEffect)(T,E);let[D,O]=(0,Q.useState)(!1),k,A;t[19]!==n.docName||t[20]!==S.isLarge||t[21]!==S.renderSource||t[22]!==S.renderVisual||t[23]!==D||t[24]!==i||t[25]!==h?(k=()=>{oE({isLarge:S.isLarge,renderSource:S.renderSource,renderVisual:S.renderVisual,hasEmittedFirstToggle:D})&&(dt(`ok/cold/first-toggle`,{docName:n.docName,mountId:Mt(n.docName),ytextLength:h,modeEnteredFirst:i?`source`:`visual`}),O(!0))},A=[D,S.isLarge,S.renderSource,S.renderVisual,n.docName,h,i],t[19]=n.docName,t[20]=S.isLarge,t[21]=S.renderSource,t[22]=S.renderVisual,t[23]=D,t[24]=i,t[25]=h,t[26]=k,t[27]=A):(k=t[26],A=t[27]),(0,Q.useEffect)(k,A);let j=r?`visible`:`hidden`,M=`editor:${n.docName}`,N;t[28]!==a||t[29]!==n||t[30]!==S.renderSource||t[31]!==S.renderVisual||t[32]!==r||t[33]!==o||t[34]!==i||t[35]!==c||t[36]!==l||t[37]!==m||t[38]!==s||t[39]!==f?(N=f?(0,Z.jsx)(_E,{view:f}):(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(XT,{activeDocName:n.docName,previousDocName:s,onNavigateBack:c,onRecycle:l,children:(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(zx,{}),children:(0,Z.jsx)(GT,{docName:n.docName,provider:n.provider,children:(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[!i&&(0,Z.jsx)(QT,{provider:n.provider}),(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[S.renderSource?(0,Z.jsx)(`div`,{className:i?`h-full`:`ok-mode-hidden h-full`,children:(0,Z.jsx)(gE,{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a})}):null,S.renderVisual?(0,Z.jsx)(`div`,{className:i?`ok-mode-hidden h-full`:`h-full`,children:(0,Z.jsx)(HT,{provider:n.provider,placeholder:a,isSourceMode:i,portalTarget:m},`${n.docName}-${String(o)}`)}):null]})]})})})})}),t[28]=a,t[29]=n,t[30]=S.renderSource,t[31]=S.renderVisual,t[32]=r,t[33]=o,t[34]=i,t[35]=c,t[36]=l,t[37]=m,t[38]=s,t[39]=f,t[40]=N):N=t[40];let P;t[41]!==r||t[42]!==N?(P=(0,Z.jsx)(hE,{isActive:r,children:N}),t[41]=r,t[42]=N,t[43]=P):P=t[43];let F;return t[44]!==M||t[45]!==P||t[46]!==j?(F=(0,Z.jsx)(Q.Activity,{mode:j,name:M,children:P}),t[44]=M,t[45]=P,t[46]=j,t[47]=F):F=t[47],F}function bE(e){let t=(0,$.c)(27),{stats:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-full h-2 bg-linear-to-t from-background to-transparent`}),t[0]=r):r=t[0];let i;t[1]===n.words?i=t[2]:(i=n.words.toLocaleString(),t[1]=n.words,t[2]=i);let a;t[3]===i?a=t[4]:(a=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:i}),t[3]=i,t[4]=a);let o=n.words===1?`word`:`words`,s;t[5]!==a||t[6]!==o?(s=(0,Z.jsxs)(`span`,{children:[a,` `,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7];let c;t[8]===n.chars?c=t[9]:(c=n.chars.toLocaleString(),t[8]=n.chars,t[9]=c);let l;t[10]===c?l=t[11]:(l=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:c}),t[10]=c,t[11]=l);let u=n.chars===1?`char`:`chars`,d;t[12]!==l||t[13]!==u?(d=(0,Z.jsxs)(`span`,{children:[l,` `,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f=n.tokens>0?`~`:``,p;t[15]===n.tokens?p=t[16]:(p=n.tokens.toLocaleString(),t[15]=n.tokens,t[16]=p);let m;t[17]===p?m=t[18]:(m=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:p}),t[17]=p,t[18]=m);let h=n.tokens===1?`token`:`tokens`,g;t[19]!==f||t[20]!==m||t[21]!==h?(g=(0,Z.jsxs)(`span`,{children:[f,m,` `,h]}),t[19]=f,t[20]=m,t[21]=h,t[22]=g):g=t[22];let _;return t[23]!==g||t[24]!==s||t[25]!==d?(_=(0,Z.jsxs)(`section`,{"aria-label":`Document statistics`,className:`relative flex h-6 shrink-0 items-center justify-end gap-3 bg-background px-3 text-2xs text-muted-foreground`,children:[r,s,d,g]}),t[23]=g,t[24]=s,t[25]=d,t[26]=_):_=t[26],_}function xE(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=mi(n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`nav`,{"aria-label":`breadcrumb`,"data-slot":`breadcrumb`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function SE(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=mi(`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 CE(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=mi(`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 wE(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=mi(`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 TE(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=mi(`[&>svg]:size-3.5`,r),t[4]=r,t[5]=a);let o;t[6]===n?o=t[7]:(o=n??(0,Z.jsx)(No,{}),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}function EE(e){let t=(0,$.c)(18),{docName:n,className:r}=e;if(!n)return null;let i,a,o,s,c,l;if(t[0]!==r||t[1]!==n){l=Symbol.for(`react.early_return_sentinel`);bb0:{let{prefix:e}=wt(n,``);if(!e){l=null;break bb0}let u=e.replace(/\/$/,``).split(`/`).filter(Boolean);if(u.length===0){l=null;break bb0}a=xE,t[8]===r?c=t[9]:(c=mi(`flex min-w-0 items-center`,r),t[8]=r,t[9]=c),i=SE,o=`flex-nowrap gap-1 text-muted-foreground/70 text-xs`,s=u.map((e,t)=>{let n=u.slice(0,t+1).join(`/`);return(0,Z.jsxs)(Q.Fragment,{children:[t>0&&(0,Z.jsx)(TE,{className:`text-muted-foreground/70 [&>svg]:size-3`}),(0,Z.jsx)(CE,{className:`min-w-0`,children:(0,Z.jsx)(wE,{current:!1,className:`min-w-0 truncate font-normal text-muted-foreground/70`,title:e,children:e})})]},n)})}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}var DE={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`},OE=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`,...DE,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},kE=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)(OE,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},AE=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)(OE,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i};function jE(e){let t=(0,$.c)(42),{activeDocName:n,isSourceMode:r,sourceDisabled:i,onModeChange:a,showAddPropertyButton:o,onAddProperty:s,isPanelCollapsed:c,onTogglePanel:l}=e,u;t[0]===n?u=t[1]:(u=(0,Z.jsx)(`div`,{className:`pointer-events-auto flex min-w-0 items-end self-end`,children:(0,Z.jsx)(EE,{docName:n})}),t[0]=n,t[1]=u);let d=r?`source`:`wysiwyg`,f;t[2]===a?f=t[3]:(f=e=>{e&&a(e)},t[2]=a,t[3]=f);let p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(Vo,{value:`wysiwyg`,"aria-label":`Visual editor`,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,asChild:!0,children:(0,Z.jsx)(kr,{children:(0,Z.jsx)(AE,{className:`size-4`})})}),(0,Z.jsx)(vn,{side:`bottom`,children:`Visual`})]}),t[4]=p):p=t[4];let m;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(kE,{className:`size-4`}),t[5]=m):m=t[5];let h;t[6]===i?h=t[7]:(h=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(`div`,{children:(0,Z.jsx)(Vo,{value:`source`,"aria-label":`Markdown source`,disabled:i,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,children:m})})}),t[6]=i,t[7]=h);let g=i?`Source mode requires a live connection — your edits are saved and will appear when you reconnect.`:`Markdown`,_;t[8]===g?_=t[9]:(_=(0,Z.jsx)(vn,{side:`bottom`,children:g}),t[8]=g,t[9]=_);let v;t[10]!==h||t[11]!==_?(v=(0,Z.jsxs)(yn,{children:[h,_]}),t[10]=h,t[11]=_,t[12]=v):v=t[12];let y;t[13]!==d||t[14]!==f||t[15]!==v?(y=(0,Z.jsx)(`div`,{className:`pointer-events-auto flex justify-center`,children:(0,Z.jsxs)(Wo,{type:`single`,value:d,onValueChange:f,"aria-label":`Editor mode`,variant:`segmented`,size:`sm`,spacing:1,className:`shrink-0 data-[size=sm]:rounded-[10px] bg-muted p-0.5`,children:[p,v]})}),t[13]=d,t[14]=f,t[15]=v,t[16]=y):y=t[16];let b;t[17]!==s||t[18]!==o?(b=o&&(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(Y,{variant:`ghost`,size:`icon`,"aria-label":`Add properties`,onClick:s,"data-testid":`add-properties-button`,asChild:!0,children:(0,Z.jsx)(kr,{children:(0,Z.jsx)(bc,{})})}),(0,Z.jsx)(vn,{side:`bottom`,children:`Add properties`})]}),t[17]=s,t[18]=o,t[19]=b):b=t[19];let x=!c,S=c?`Show panel`:`Hide panel`,C;t[20]===c?C=t[21]:(C=(0,Z.jsx)(kr,{children:c?(0,Z.jsx)(Oc,{}):(0,Z.jsx)(Dc,{})}),t[20]=c,t[21]=C);let w;t[22]!==l||t[23]!==x||t[24]!==S||t[25]!==C?(w=(0,Z.jsx)(Y,{variant:`ghost`,size:`icon`,onClick:l,"aria-expanded":x,"aria-label":S,asChild:!0,children:C}),t[22]=l,t[23]=x,t[24]=S,t[25]=C,t[26]=w):w=t[26];let T=c?`Show panel`:`Hide panel`,E;t[27]===T?E=t[28]:(E=(0,Z.jsx)(vn,{side:`bottom`,children:T}),t[27]=T,t[28]=E);let D;t[29]!==w||t[30]!==E?(D=(0,Z.jsxs)(yn,{children:[w,E]}),t[29]=w,t[30]=E,t[31]=D):D=t[31];let O;t[32]!==b||t[33]!==D?(O=(0,Z.jsxs)(`div`,{className:`pointer-events-auto flex items-center justify-end gap-1`,children:[b,D]}),t[32]=b,t[33]=D,t[34]=O):O=t[34];let k;t[35]!==u||t[36]!==y||t[37]!==O?(k=(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:[u,y,O]})}),t[35]=u,t[36]=y,t[37]=O,t[38]=k):k=t[38];let A;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none h-2 bg-linear-to-b from-background to-transparent`}),t[39]=A):A=t[39];let j;return t[40]===k?j=t[41]:(j=(0,Z.jsxs)(`div`,{"data-testid":`editor-toolbar`,className:`pointer-events-none absolute inset-x-0 top-0 z-10`,children:[k,A]}),t[40]=k,t[41]=j),j}function ME(e){let{activeDocName:t,deferredActiveDocName:n,mountResolved:r,syncResolved:i}=e;return t===null||t===n?!1:!(r&&i)}var NE=(0,Q.lazy)(async()=>({default:(await n(()=>import(`./ActivityModeContent-fhFzM0sk.js`),__vite__mapDeps([32,1,2,33,34,35,20,36,37,38,39,19,3,6,7,4,10,9,40,41]),import.meta.url)).ActivityModeContent}));function PE(e){let t=(0,$.c)(5),n;t[0]===e?n=t[1]:(n=(0,Z.jsx)(IE,{...e}),t[0]=e,t[1]=n);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(FE,{}),t[2]=r):r=t[2];let i;return t[3]===n?i=t[4]:(i=(0,Z.jsx)(Ve,{name:`editor-area`,children:(0,Z.jsxs)(pC,{children:[n,r]})}),t[3]=n,t[4]=i),i}function FE(){let e=(0,$.c)(5),t=Em(),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)(CC,{open:t.open,onOpenChange:n}),e[2]=t.open,e[3]=n,e[4]=r):r=e[4],r}function IE(e){let t=(0,$.c)(104),{editorMode:n,onModeChange:r,activeTab:i,onActiveTabChange:a}=e,{activeDocName:o,activeProvider:s,activeTarget:c,recycleDocument:l,docPanelMode:u,docPanelAgentId:d,docPanelExpandSignal:f}=ot(),{openDocumentTransition:p}=gt(),{requestAddProperty:m}=hC(),h=gw(s,o),g=_w(s),_=g===`connected`||g===`synced`,v=(0,Q.useDeferredValue)(o),y=c?.kind===`missing`,b=!!o&&c?.kind!==`folder`,x=y?`Start writing to create this page`:void 0,S=Ex(),[C,w]=(0,Q.useState)(!1),{layout:T,autoCollapse:E}=ew(),D=T===`sheet`,[O,k]=(0,Q.useState)(!1),A=(0,Q.useRef)(!1),j,M;t[0]!==E||t[1]!==T||t[2]!==S?(j=()=>{if(T!==`panel`)return;let e=requestAnimationFrame(()=>{E?(A.current=!1,S.current?.collapse()):A.current||S.current?.expand()});return()=>cancelAnimationFrame(e)},M=[E,T,S],t[0]=E,t[1]=T,t[2]=S,t[3]=j,t[4]=M):(j=t[3],M=t[4]),(0,Q.useEffect)(j,M);let N,P;t[5]!==D||t[6]!==a||t[7]!==S?(N=()=>{let e=e=>{a(e),D?k(!0):(A.current=!1,S.current?.expand())},t=kp();return t&&e(t),jp(t=>{kp(),e(t)})},P=[D,a,S],t[5]=D,t[6]=a,t[7]=S,t[8]=N,t[9]=P):(N=t[8],P=t[9]),(0,Q.useEffect)(N,P);let F,I;t[10]!==f||t[11]!==D||t[12]!==S?(F=()=>{f!==0&&(D?k(!0):(A.current=!1,S.current?.expand()))},I=[f,D,S],t[10]=f,t[11]=D,t[12]=S,t[13]=F,t[14]=I):(F=t[13],I=t[14]),(0,Q.useEffect)(F,I);let L=(0,Q.useRef)(null),[R,z]=(0,Q.useState)(null),B,V;if(t[15]===o?(B=t[16],V=t[17]):(B=()=>{if(o&&o!==L.current){let e=L.current;L.current=o,z(e)}},V=[o],t[15]=o,t[16]=B,t[17]=V),(0,Q.useEffect)(B,V),c?.kind===`folder`){if(!(u===`agent`&&d!==null)){let e;return t[18]===c.folderPath?e=t[19]:(e=(0,Z.jsx)(oC,{folderPath:c.folderPath}),t[18]=c.folderPath,t[19]=e),e}let e;t[20]===c.folderPath?e=t[21]:(e=(0,Z.jsx)(OC,{minSize:`30%`,defaultSize:`75%`,children:(0,Z.jsx)(oC,{folderPath:c.folderPath})}),t[20]=c.folderPath,t[21]=e);let n;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(kC,{withHandle:!0}),t[22]=n):n=t[22];let r;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(OC,{defaultSize:`25%`,minSize:`300px`,maxSize:`40%`,className:`flex flex-col bg-muted/20`,children:(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(`div`,{role:`status`,"aria-busy":`true`,className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Loading agent activity`}),children:(0,Z.jsx)(NE,{showBackButton:!1})})}),t[23]=r):r=t[23];let i;return t[24]===e?i=t[25]:(i=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,Z.jsxs)(DC,{orientation:`horizontal`,children:[e,n,r]})}),t[24]=e,t[25]=i),i}if(c?.kind===`asset`){let e;return t[26]!==c.assetPath||t[27]!==c.mediaKind?(e=(0,Z.jsx)(Rx,{assetPath:c.assetPath,mediaKind:c.mediaKind},c.assetPath),t[26]=c.assetPath,t[27]=c.mediaKind,t[28]=e):e=t[28],e}if(!s||!o){if((typeof window<`u`?Rr(window.location.hash):null)!==null){let e;return t[29]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(zx,{}),t[29]=e):e=t[29],e}let e;return t[30]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(NS,{}),t[30]=e):e=t[30],e}let H=n===`source`,U=!_,W=D?!O:C,G;t[31]!==o||t[32]!==m?(G=function(){o&&m(o)},t[31]=o,t[32]=m,t[33]=G):G=t[33];let K=G,q;t[34]!==C||t[35]!==D||t[36]!==S?(q=function(){D?k(LE):C?(A.current=!1,S.current?.expand()):(A.current=!0,S.current?.collapse())},t[34]=C,t[35]=D,t[36]=S,t[37]=q):q=t[37];let ee=q,te=v??o,ne=R??void 0,re;t[38]===p?re=t[39]:(re=e=>{let t=Tr(e);window.location.hash===t?p(e):window.location.hash=t},t[38]=p,t[39]=re);let ie;t[40]!==x||t[41]!==H||t[42]!==l||t[43]!==te||t[44]!==ne||t[45]!==re?(ie=(0,Z.jsx)(fE,{activeDocName:te,isSourceMode:H,editorPlaceholder:x,previousDocName:ne,onNavigateBack:re,onRecycle:l}),t[40]=x,t[41]=H,t[42]=l,t[43]=te,t[44]=ne,t[45]=re,t[46]=ie):ie=t[46];let ae;t[47]!==o||t[48]!==H?(ae=(0,Z.jsx)(YC,{activeDocName:o,isSourceMode:H}),t[47]=o,t[48]=H,t[49]=ae):ae=t[49];let oe;t[50]!==o||t[51]!==v?(oe=ME({activeDocName:o,deferredActiveDocName:v,mountResolved:o!==null&&ke(o),syncResolved:o!==null&&Le(o)})?(0,Z.jsxs)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:[(0,Z.jsx)(zx,{}),o===null?null:(0,Z.jsx)(uC,{docName:o})]}):null,t[50]=o,t[51]=v,t[52]=oe):oe=t[52];let se;t[53]!==ie||t[54]!==ae||t[55]!==oe?(se=(0,Z.jsxs)(`div`,{className:`relative h-full`,children:[ie,ae,oe]}),t[53]=ie,t[54]=ae,t[55]=oe,t[56]=se):se=t[56];let ce=!H,le;t[57]!==o||t[58]!==W||t[59]!==H||t[60]!==r||t[61]!==K||t[62]!==U||t[63]!==ce||t[64]!==ee?(le=(0,Z.jsx)(jE,{activeDocName:o,isSourceMode:H,sourceDisabled:U,onModeChange:r,showAddPropertyButton:ce,onAddProperty:K,isPanelCollapsed:W,onTogglePanel:ee}),t[57]=o,t[58]=W,t[59]=H,t[60]=r,t[61]=K,t[62]=U,t[63]=ce,t[64]=ee,t[65]=le):le=t[65];let J;t[66]!==se||t[67]!==le?(J=(0,Z.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[se,le]}),t[66]=se,t[67]=le,t[68]=J):J=t[68];let ue;t[69]!==b||t[70]!==h?(ue=b&&(0,Z.jsx)(bE,{stats:h}),t[69]=b,t[70]=h,t[71]=ue):ue=t[71];let de;t[72]!==J||t[73]!==ue?(de=(0,Z.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[J,ue]}),t[72]=J,t[73]=ue,t[74]=de):de=t[74];let fe=de,pe=D?`100%`:`30%`,me=D?`100%`:`75%`,he;t[75]!==fe||t[76]!==pe||t[77]!==me?(he=(0,Z.jsx)(OC,{minSize:pe,defaultSize:me,children:fe}),t[75]=fe,t[76]=pe,t[77]=me,t[78]=he):he=t[78];let ge;t[79]===D?ge=t[80]:(ge=D?null:(0,Z.jsx)(kC,{withHandle:!0}),t[79]=D,t[80]=ge);let _e;t[81]!==o||t[82]!==i||t[83]!==u||t[84]!==D||t[85]!==H||t[86]!==a||t[87]!==S?(_e=D?null:(0,Z.jsx)(OC,{panelRef:S,defaultSize:`25%`,minSize:`300px`,maxSize:`40%`,collapsible:!0,collapsedSize:0,onResize:e=>w(e.asPercentage===0),className:`flex flex-col bg-muted/20`,children:(0,Z.jsx)(Ny,{docName:o,isSourceMode:H,activeTab:i,onActiveTabChange:a,mode:u})}),t[81]=o,t[82]=i,t[83]=u,t[84]=D,t[85]=H,t[86]=a,t[87]=S,t[88]=_e):_e=t[88];let ve;t[89]!==he||t[90]!==ge||t[91]!==_e?(ve=(0,Z.jsxs)(DC,{orientation:`horizontal`,children:[he,ge,_e]}),t[89]=he,t[90]=ge,t[91]=_e,t[92]=ve):ve=t[92];let ye;t[93]!==o||t[94]!==i||t[95]!==u||t[96]!==D||t[97]!==H||t[98]!==a||t[99]!==O?(ye=D?(0,Z.jsx)(Q_,{open:O,onOpenChange:k,children:(0,Z.jsxs)(tv,{side:`right`,className:`flex w-80 sm:w-96 flex-col gap-0 p-0`,children:[(0,Z.jsx)(nv,{className:`sr-only`,children:(0,Z.jsx)(rv,{children:`Document panel`})}),(0,Z.jsx)(Ny,{docName:o,isSourceMode:H,activeTab:i,onActiveTabChange:a,mode:u})]})}):null,t[93]=o,t[94]=i,t[95]=u,t[96]=D,t[97]=H,t[98]=a,t[99]=O,t[100]=ye):ye=t[100];let be;return t[101]!==ve||t[102]!==ye?(be=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[ve,ye]}),t[101]=ve,t[102]=ye,t[103]=be):be=t[103],be}function LE(e){return!e}var RE=1280;function zE(){let e=(0,$.c)(2),[t,n]=(0,Q.useState)(BE),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${RE-1}px)`),t=()=>{n(window.innerWidth<RE)};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 BE(){return window.innerWidth<RE}function VE(e){let t=e.endsWith(`rem`)?`rem`:`px`;return{value:Number.parseFloat(e),unit:t}}function HE(e){let{value:t,unit:n}=VE(e);return n===`rem`?t*16:t}function UE(e,t){return`${t===`rem`?e.toFixed(1):Math.round(e)}${t}`}var WE=3600*24*7;function GE(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?KE:m,O=g===void 0?WE:g,k=_===void 0?!1:_,A=(0,Q.useRef)(null),j=(0,Q.useRef)(0),M=(0,Q.useRef)(0),N=(0,Q.useRef)(!1),P=(0,Q.useRef)(!1),F=(0,Q.useRef)(null),I=(0,Q.useRef)(0),L=(0,Q.useRef)(!1),R=(0,Q.useRef)(0),z=(0,Q.useRef)(0),B=(0,Q.useRef)(null),V=(0,Q.useRef)(r),H=(0,Q.useRef)(y),U,W;t[0]===r?(U=t[1],W=t[2]):(U=()=>{V.current=r},W=[r],t[0]=r,t[1]=U,t[2]=W),(0,Q.useEffect)(U,W);let G,K;t[3]===y?(G=t[4],K=t[5]):(G=()=>{H.current=y},K=[y],t[3]=y,t[4]=G,t[5]=K),(0,Q.useEffect)(G,K);let q=HE(b),ee;t[6]===x?ee=t[7]:(ee=HE(x),t[6]=x,t[7]=ee);let te=ee,ne;t[8]!==E||t[9]!==k?(ne=function(e){P.current=!0,E&&(j.current=H.current?0:HE(V.current),M.current=e.clientX,I.current=e.clientX,F.current=null,L.current=!1,R.current=0,z.current=0,B.current=k&&A.current?A.current.getBoundingClientRect():null,e.preventDefault())},t[8]=E,t[9]=k,t[10]=ne):ne=t[10];let re=ne,ie,ae;t[11]!==w||t[12]!==v||t[13]!==C||t[14]!==S||t[15]!==T||t[16]!==k||t[17]!==te||t[18]!==q||t[19]!==i||t[20]!==a||t[21]!==D||t[22]!==O||t[23]!==h?(ie=()=>{let e=function(e){h&&(document.cookie=`${h}=${e}; path=/; max-age=${O}`)},t=function(e,t){return v===`left`?e<t:e>t},n=function(e,t,n,r){if(k&&r){let r=e.clientX-t;return v===`left`?n-r:n+r}return v===`left`?window.innerWidth-e.clientX:e.clientX},r=function(r){if(!P.current)return;let o=Math.abs(r.clientX-M.current);if(!N.current&&o>5&&(N.current=!0,D(!0)),N.current){let{unit:o}=VE(V.current),s=B.current;k&&A.current&&(s=A.current.getBoundingClientRect());let c=t(r.clientX,I.current)?`expand`:`collapse`;F.current!==c&&(F.current=c),z.current=Math.abs(r.clientX-I.current);let l=Date.now();if(L.current&&l-R.current>200&&(L.current=!1),!L.current){if(C&&a&&!H.current){let e=n(r,M.current,j.current,s),t=!1;if(w<=1)t=e<=q*w;else if(e<=q){let n=q*(w-1);t=q-e>=n}if(c===`collapse`&&t){a(),I.current=r.clientX,L.current=!0,R.current=l;return}}if(a&&H.current&&c===`expand`&&z.current>q*T){a();let t=n(r,M.current,j.current,s),c=Math.max(q,Math.min(te,t)),u=UE(o===`rem`?c/16:c,o);i(u),e(u),I.current=r.clientX,L.current=!0,R.current=l;return}}if(H.current)return;let u=n(r,M.current,j.current,s),d=Math.max(q,Math.min(te,u)),f=UE(o===`rem`?d/16:d,o);i(f),e(f)}},o=function(){P.current&&(!N.current&&a&&S&&a(),N.current=!1,P.current=!1,F.current=null,I.current=0,L.current=!1,R.current=0,z.current=0,B.current=null,D(!1))};return document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,o),()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,o)}},ae=[i,a,D,q,te,k,C,w,T,S,h,O,v],t[11]=w,t[12]=v,t[13]=C,t[14]=S,t[15]=T,t[16]=k,t[17]=te,t[18]=q,t[19]=i,t[20]=a,t[21]=D,t[22]=O,t[23]=h,t[24]=ie,t[25]=ae):(ie=t[24],ae=t[25]),(0,Q.useEffect)(ie,ae);let oe;return t[26]===re?oe=t[27]:(oe={dragRef:A,isDragging:N,handleMouseDown:re},t[26]=re,t[27]=oe),oe}function KE(){}var qE=`sidebar_state`,JE=3600*24*7,YE=`18rem`,XE=`3rem`,ZE=`\\`,QE=`app-file-sidebar`,$E=`14.625rem`,eD=`22rem`,tD=`sidebar_width`,nD=/^\d+(?:\.\d+)?(?:rem|px)$/,rD=Q.createContext(null);function iD(e){if(typeof document>`u`)return e;let t=document.cookie.split(`; `).find(e=>e.startsWith(`${tD}=`))?.split(`=`)[1];if(!t)return e;let n;try{n=decodeURIComponent(t)}catch{return e}return nD.test(n)?n:e}function aD(){let e=Q.use(rD);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function oD(e){let t=(0,$.c)(53),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({defaultOpen:c,open:i,onOpenChange:o,className:r,style:s,children:n,defaultWidth:l,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=c===void 0?!0:c,d=l===void 0?YE:l,f=zE(),p;t[9]===d?p=t[10]:(p=()=>iD(d),t[9]=d,t[10]=p);let[m,h]=Q.useState(p),[g,_]=Q.useState(!1),v=Q.useRef(g),[y,b]=Q.useState(!1),[x,S]=Q.useState(!1),[C,w]=Q.useState(u),T=i??C,E;t[11]!==T||t[12]!==o?(E=e=>{let t=typeof e==`function`?e(T):e;o?o(t):w(t),document.cookie=`${qE}=${t}; path=/; max-age=${JE}`},t[11]=T,t[12]=o,t[13]=E):E=t[13];let D=E,O;t[14]===D?O=t[15]:(O=function(){return window.innerWidth<1280?_(cD):D(sD)},t[14]=D,t[15]=O);let k=O,A;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(A=function(){window.innerWidth>=1280||v.current&&(window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||S(!0))},t[16]=A):A=t[16];let j=A,M;t[17]===g?M=t[18]:(M=()=>{v.current=g},t[17]=g,t[18]=M),Q.useLayoutEffect(M);let N,P;t[19]===k?(N=t[20],P=t[21]):(N=()=>{let e=e=>{e.key===ZE&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),k())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},P=[k],t[19]=k,t[20]=N,t[21]=P),Q.useEffect(N,P);let F,I;t[22]!==f||t[23]!==g?(F=()=>{if(!f||!g)return;let e=e=>{e.key===`Escape`&&(document.querySelector(`[data-state="open"][role="dialog"], [data-state="open"][role="alertdialog"], [data-state="open"][role="menu"], [data-state="open"][role="listbox"], [data-radix-popper-content-wrapper] [data-state="open"]`)||_(!1))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},I=[f,g],t[22]=f,t[23]=g,t[24]=F,t[25]=I):(F=t[24],I=t[25]),Q.useEffect(F,I);let L=Q.useRef(f),R,z;t[26]!==f||t[27]!==T?(R=()=>{!L.current&&f&&_(T),L.current=f},z=[f,T],t[26]=f,t[27]=T,t[28]=R,t[29]=z):(R=t[28],z=t[29]),Q.useEffect(R,z);let B=f?g?`expanded`:`collapsed`:T?`expanded`:`collapsed`,V;t[30]!==y||t[31]!==f||t[32]!==T||t[33]!==g||t[34]!==D||t[35]!==x||t[36]!==B||t[37]!==k||t[38]!==m?(V={state:B,open:T,setOpen:D,isMobile:f,openMobile:g,setOpenMobile:_,toggleSidebar:k,width:m,setWidth:h,isDraggingRail:y,setIsDraggingRail:b,showPushPulse:x,setShowPushPulse:S,notifySidebarFileSelected:j},t[30]=y,t[31]=f,t[32]=T,t[33]=g,t[34]=D,t[35]=x,t[36]=B,t[37]=k,t[38]=m,t[39]=V):V=t[39];let H;t[40]!==s||t[41]!==m?(H={"--sidebar-width":m,"--sidebar-width-icon":XE,...s},t[40]=s,t[41]=m,t[42]=H):H=t[42];let U=H,W;t[43]===r?W=t[44]:(W=mi(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),t[43]=r,t[44]=W);let G;t[45]!==n||t[46]!==a||t[47]!==U||t[48]!==W?(G=(0,Z.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:U,className:W,...a,children:n}),t[45]=n,t[46]=a,t[47]=U,t[48]=W,t[49]=G):G=t[49];let K;return t[50]!==V||t[51]!==G?(K=(0,Z.jsx)(rD.Provider,{value:V,children:G}),t[50]=V,t[51]=G,t[52]=K):K=t[52],K}function sD(e){return!e}function cD(e){return!e}function lD(e){let t=(0,$.c)(51),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({side:a,variant:o,collapsible:s,className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=a===void 0?`left`:a,l=o===void 0?`sidebar`:o,u=s===void 0?`offcanvas`:s,{isMobile:d,state:f,openMobile:p,isDraggingRail:m}=aD();if(u===`none`){let e;t[7]===r?e=t[8]:(e=mi(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),t[7]=r,t[8]=e);let a;return t[9]!==n||t[10]!==i||t[11]!==e||t[12]!==l?(a=(0,Z.jsx)(`div`,{"data-slot":`sidebar`,"data-variant":l,className:e,...i,children:n}),t[9]=n,t[10]=i,t[11]=e,t[12]=l,t[13]=a):a=t[13],a}if(d){let e=p?`expanded`:`collapsed`,a=l===`floating`||l===`inset`?`p-2`:``,o;t[14]!==r||t[15]!==a?(o=mi(`fixed inset-y-0 z-30 flex h-svh w-(--sidebar-width)`,`transition-transform duration-200 ease-linear motion-reduce:transition-none`,`data-[side=left]:left-0 data-[side=right]:right-0`,`group-data-[state=collapsed]:data-[side=left]:-translate-x-full`,`group-data-[state=collapsed]:data-[side=right]:translate-x-full`,a,r),t[14]=r,t[15]=a,t[16]=o):o=t[16];let s;t[17]===n?s=t[18]:(s=(0,Z.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border`,children:n}),t[17]=n,t[18]=s);let u;t[19]!==i||t[20]!==c||t[21]!==o||t[22]!==s?(u=(0,Z.jsx)(`nav`,{id:QE,"aria-label":`File sidebar`,"data-slot":`sidebar-container`,"data-side":c,className:o,...i,children:s}),t[19]=i,t[20]=c,t[21]=o,t[22]=s,t[23]=u):u=t[23];let d;return t[24]!==e||t[25]!==c||t[26]!==u||t[27]!==l?(d=(0,Z.jsx)(`div`,{className:`group peer text-sidebar-foreground`,"data-state":e,"data-variant":l,"data-side":c,"data-slot":`sidebar`,"data-mobile":`true`,children:u}),t[24]=e,t[25]=c,t[26]=u,t[27]=l,t[28]=d):d=t[28],d}let h=f===`collapsed`?u:``,g=l===`floating`||l===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,_;t[29]===g?_=t[30]:(_=mi(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,g,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`),t[29]=g,t[30]=_);let v;t[31]===_?v=t[32]:(v=(0,Z.jsx)(`div`,{"data-slot":`sidebar-gap`,className:_}),t[31]=_,t[32]=v);let y=l===`floating`||l===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,b;t[33]!==r||t[34]!==y?(b=mi(`fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex`,y,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`,r),t[33]=r,t[34]=y,t[35]=b):b=t[35];let x;t[36]===n?x=t[37]:(x=(0,Z.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border`,children:n}),t[36]=n,t[37]=x);let S;t[38]!==i||t[39]!==c||t[40]!==x||t[41]!==b?(S=(0,Z.jsx)(`nav`,{id:QE,"aria-label":`File sidebar`,"data-slot":`sidebar-container`,"data-side":c,className:b,...i,children:x}),t[38]=i,t[39]=c,t[40]=x,t[41]=b,t[42]=S):S=t[42];let C;return t[43]!==m||t[44]!==c||t[45]!==f||t[46]!==S||t[47]!==h||t[48]!==v||t[49]!==l?(C=(0,Z.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":f,"data-collapsible":h,"data-variant":l,"data-side":c,"data-slot":`sidebar`,"data-dragging":m,children:[v,S]}),t[43]=m,t[44]=c,t[45]=f,t[46]=S,t[47]=h,t[48]=v,t[49]=l,t[50]=C):C=t[50],C}function uD(e){let t=(0,$.c)(18),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,onClick:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let{toggleSidebar:a,state:o}=aD(),s=o===`expanded`,c=o===`expanded`?`Hide Files`:`Show Files`,l;t[4]===n?l=t[5]:(l=mi(n),t[4]=n,t[5]=l);let u;t[6]!==r||t[7]!==a?(u=e=>{r?.(e),a()},t[6]=r,t[7]=a,t[8]=u):u=t[8];let d;t[9]===o?d=t[10]:(d=o===`expanded`?(0,Z.jsx)(Ot,{}):(0,Z.jsx)(Ec,{}),t[9]=o,t[10]=d);let f;return t[11]!==i||t[12]!==s||t[13]!==c||t[14]!==l||t[15]!==u||t[16]!==d?(f=(0,Z.jsx)(Y,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon-sm`,"aria-expanded":s,"aria-controls":QE,"aria-label":c,className:l,onClick:u,...i,children:d}),t[11]=i,t[12]=s,t[13]=c,t[14]=l,t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function dD(e){let t=(0,$.c)(26),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:n,enableDrag:a,enableToggle:o,onMouseDown:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=a===void 0?!0:a,c=o===void 0?!0:o,{toggleSidebar:l,setWidth:u,state:d,width:f,setIsDraggingRail:p}=aD(),m=d===`collapsed`,h;t[6]!==s||t[7]!==c||t[8]!==p||t[9]!==u||t[10]!==m||t[11]!==l||t[12]!==f?(h={direction:`right`,enableDrag:s,enableToggle:c,onResize:u,onToggle:l,currentWidth:f,isCollapsed:m,minResizeWidth:$E,maxResizeWidth:eD,setIsDraggingRail:p,widthCookieName:tD,widthCookieMaxAge:JE},t[6]=s,t[7]=c,t[8]=p,t[9]=u,t[10]=m,t[11]=l,t[12]=f,t[13]=h):h=t[13];let{dragRef:g,handleMouseDown:_}=GE(h),v=d===`expanded`?`Hide Files`:`Show Files`,y;t[14]!==_||t[15]!==r?(y=e=>{r?.(e),e.defaultPrevented||_(e)},t[14]=_,t[15]=r,t[16]=y):y=t[16];let b=d===`expanded`?`Hide Files`:`Show Files`,x;t[17]===n?x=t[18]:(x=mi(`absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2`,`in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize`,`[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize`,`group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar`,`[[data-side=left][data-collapsible=offcanvas]_&]:-right-2`,`[[data-side=right][data-collapsible=offcanvas]_&]:-left-2`,`md:group-data-[variant=inset]:after:inset-y-5`,n),t[17]=n,t[18]=x);let S;return t[19]!==g||t[20]!==i||t[21]!==v||t[22]!==y||t[23]!==b||t[24]!==x?(S=(0,Z.jsx)(`button`,{ref:g,"data-sidebar":`rail`,"data-slot":`sidebar-rail`,"aria-label":v,tabIndex:-1,onMouseDown:y,title:b,className:x,...i}),t[19]=g,t[20]=i,t[21]=v,t[22]=y,t[23]=b,t[24]=x,t[25]=S):S=t[25],S}function fD(e){let t=(0,$.c)(21),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,onClick:i,onAnimationEnd:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{isMobile:o,openMobile:s,setOpenMobile:c,showPushPulse:l,setShowPushPulse:u}=aD(),d;t[5]!==o||t[6]!==i||t[7]!==s||t[8]!==c?(d=e=>{i?.(e),!e.defaultPrevented&&(!o||!s||e.target?.closest(`[data-sidebar="trigger"]`)||c(!1))},t[5]=o,t[6]=i,t[7]=s,t[8]=c,t[9]=d):d=t[9];let f=d,p;t[10]!==r||t[11]!==u?(p=e=>{r?.(e),e.animationName===`sidebar-push-pulse`&&u(!1)},t[10]=r,t[11]=u,t[12]=p):p=t[12];let m=p,h=l?``:void 0,g;t[13]===n?g=t[14]:(g=mi(`relative flex w-full flex-1 flex-col bg-background peer-data-[variant=inset]:m-2 peer-data-[variant=inset]:ml-0 peer-data-[variant=inset]:rounded-xl peer-data-[variant=inset]:shadow-sm peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2`,`transition-transform duration-200 ease-linear motion-reduce:transition-none`,`peer-data-[mobile=true]:peer-data-[state=expanded]:translate-x-(--sidebar-width)`,n),t[13]=n,t[14]=g);let _;return t[15]!==m||t[16]!==f||t[17]!==a||t[18]!==h||t[19]!==g?(_=(0,Z.jsx)(`main`,{"data-slot":`sidebar-inset`,"data-push-pulse":h,onClick:f,onAnimationEnd:m,className:g,...a}),t[15]=m,t[16]=f,t[17]=a,t[18]=h,t[19]=g,t[20]=_):_=t[20],_}function pD(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=mi(`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 mD(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=mi(`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 hD(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=mi(`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 gD(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=mi(`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 _D(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=mi(`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 vD=Ti(`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 yD(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?vi:`button`,{isMobile:m,state:h}=aD(),g;t[8]!==n||t[9]!==f||t[10]!==d?(g=mi(vD({variant:d,size:f}),n),t[8]=n,t[9]=f,t[10]=d,t[11]=g):g=t[11];let _;t[12]!==p||t[13]!==u||t[14]!==r||t[15]!==f||t[16]!==g?(_=(0,Z.jsx)(p,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":f,"data-active":u,className:g,...r}),t[12]=p,t[13]=u,t[14]=r,t[15]=f,t[16]=g,t[17]=_):_=t[17];let v=_;if(!c)return v;if(typeof c==`string`){let e;t[18]===c?e=t[19]:(e={children:c},t[18]=c,t[19]=e),c=e}let y;t[20]===v?y=t[21]:(y=(0,Z.jsx)(kr,{asChild:!0,children:v}),t[20]=v,t[21]=y);let b=h!==`collapsed`||m,x;t[22]!==b||t[23]!==c?(x=(0,Z.jsx)(vn,{side:`right`,align:`center`,hidden:b,...c}),t[22]=b,t[23]=c,t[24]=x):x=t[24];let S;return t[25]!==y||t[26]!==x?(S=(0,Z.jsxs)(yn,{children:[y,x]}),t[25]=y,t[26]=x,t[27]=S):S=t[27],S}function bD(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 xD(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 SD=1e3,CD=!1;function wD(e){return!!(e.localPrincipalId&&e.entryPrincipalId===e.localPrincipalId||!e.localPrincipalId&&e.entryClientId===e.localClientId)}function TD(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:Ri(i)?a=i:(a=void 0,CD||(CD=!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`&&(wD({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=xD(i),{current:c,crossDoc:l}=a?Ni(a,n,Date.now()):{current:[],crossDoc:[]},u=ED,d=c.map(u),f=l.map(u),p=[...s,...d],m=f;o(e=>bD(e.current,p)&&bD(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,SD);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 ED(e){let{agentId:t,entry:n}=e;return{kind:`agent`,agentId:t,presence:n}}var DD=`sync-status`;function OD(e,t){let n=(0,$.c)(4),r=(0,Q.useRef)(!1),i=(0,Q.useRef)(!1),a=(0,Q.useRef)(t),o,s;n[0]!==t||n[1]!==e?(o=()=>{a.current!==t&&(a.current=t,r.current=!1,i.current=!1),t&&(e===`synced`&&(r.current=!0),e===`disconnected`&&r.current?(i.current=!0,X.warning(`Connection lost — keep this tab open, your edits will sync when reconnected`,{id:DD,duration:1/0})):i.current&&e===`synced`&&(i.current=!1,X.success(`Reconnected`,{id:DD,duration:3e3})))},s=[e,t],n[0]=t,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),(0,Q.useEffect)(o,s)}var kD=4,AD=3,jD={Bird:Bs,Cat:Ks,Dog:rc,Fish:sc,Mouse:Nc,Rabbit:Mc,Shrimp:Vc,Snail:Hc,Squirrel:Gc,Turtle:Xc};Object.freeze(Object.keys(jD));function MD(e){if(typeof e.principalId==`string`&&e.principalId.length>0)return{kind:`initials`};let t=e.name.split(` `)[1];return t&&Object.hasOwn(jD,t)?{kind:`animal`,animal:t}:{kind:`initials`}}var ND={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function PD(e){let t=(0,$.c)(20),{user:n,mode:r,tabCount:i}=e,a=MD(n),o=a.kind===`animal`?jD[a.animal]:void 0,s;t[0]===n.name?s=t[1]:(s=cr(n.name),t[0]=n.name,t[1]=s);let c=s,l;t[2]===n.color?l=t[3]:(l=Kn(n.color),t[2]=n.color,t[3]=l);let u=l,d=i>1?`${n.name} · ${i} tabs`:n.name,f=i>1?`${n.name}, ${i} concurrent tabs`:n.name,p;t[4]===n.color?p=t[5]:(p={backgroundColor:n.color},t[4]=n.color,t[5]=p);let m;t[6]!==o||t[7]!==u||t[8]!==c?(m=o?(0,Z.jsx)(o,{size:18,color:u,strokeWidth:1.5}):(0,Z.jsx)(`span`,{className:`font-mono text-2xs font-semibold leading-none`,style:{color:u},children:c}),t[6]=o,t[7]=u,t[8]=c,t[9]=m):m=t[9];let h;t[10]!==f||t[11]!==r||t[12]!==p||t[13]!==m?(h=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(`div`,{"data-presence-badge":`human`,"data-presence-mode":r,role:`img`,"aria-label":f,className:`inline-flex size-7 shrink-0 cursor-default items-center justify-center rounded-full ring-2 ring-background`,style:p,children:m})}),t[10]=f,t[11]=r,t[12]=p,t[13]=m,t[14]=h):h=t[14];let g;t[15]===d?g=t[16]:(g=(0,Z.jsx)(vn,{children:d}),t[15]=d,t[16]=g);let _;return t[17]!==h||t[18]!==g?(_=(0,Z.jsxs)(yn,{children:[h,g]}),t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function FD(e){let t=ND[e.icon];return e.displayName||t||`Agent`}function ID(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 LD(e){let t=(0,$.c)(36),{participant:n,crossDoc:r,scoped:i,onClickAgent:a}=e,{presence:o,agentId:s}=n,c;t[0]===o?c=t[1]:(c=FD(o),t[0]=o,t[1]=c);let l=c,u=ID(o.mode),d=!r&&u,f=i?`ring-primary ring-offset-2 ring-offset-background`:`ring-background`,p=d&&!i?`ring-primary/40 animate-pulse`:``,m;t[2]!==f||t[3]!==p?(m=[`inline-flex size-7 shrink-0 items-center justify-center rounded-full ring-2 cursor-pointer`,f,p].filter(Boolean),t[2]=f,t[3]=p,t[4]=m):m=t[4];let h=m.join(` `),g=r?`true`:void 0,_=i?`true`:void 0,v;t[5]!==o.mode||t[6]!==g||t[7]!==_?(v={"data-presence-badge":`agent`,"data-presence-mode":o.mode,"data-presence-crossdoc":g,"data-presence-scoped":_},t[5]=o.mode,t[6]=g,t[7]=_,t[8]=v):v=t[8];let y=v,b=o.currentDoc&&o.currentDoc!==`(connected)`?o.currentDoc:null,x=r&&b?`Open activity panel for ${l}, editing ${b}`:`Open activity panel for ${l}`,S;t[9]===o.color?S=t[10]:(S={backgroundColor:o.color},t[9]=o.color,t[10]=S);let C;t[11]!==s||t[12]!==a?(C=()=>a(s),t[11]=s,t[12]=a,t[13]=C):C=t[13];let w;t[14]===o.icon?w=t[15]:(w=(0,Z.jsx)(Ii,{icon:o.icon,width:16,height:16,className:`text-white`}),t[14]=o.icon,t[15]=w);let T;t[16]!==x||t[17]!==y||t[18]!==h||t[19]!==w||t[20]!==S||t[21]!==C?(T=(0,Z.jsx)(`button`,{type:`button`,...y,"aria-label":x,className:h,style:S,onClick:C,children:w}),t[16]=x,t[17]=y,t[18]=h,t[19]=w,t[20]=S,t[21]=C,t[22]=T):T=t[22];let E=T,D;t[23]===E?D=t[24]:(D=(0,Z.jsx)(kr,{asChild:!0,children:E}),t[23]=E,t[24]=D);let O;t[25]===l?O=t[26]:(O=(0,Z.jsx)(`span`,{className:`font-medium`,children:l}),t[25]=l,t[26]=O);let k;t[27]!==r||t[28]!==b?(k=r&&b?(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`editing [[`,b,`]]`]}):null,t[27]=r,t[28]=b,t[29]=k):k=t[29];let A;t[30]!==O||t[31]!==k?(A=(0,Z.jsxs)(vn,{className:`flex flex-col gap-0.5`,children:[O,k]}),t[30]=O,t[31]=k,t[32]=A):A=t[32];let j;return t[33]!==D||t[34]!==A?(j=(0,Z.jsxs)(yn,{children:[D,A]}),t[33]=D,t[34]=A,t[35]=j):j=t[35],j}function RD(e){let t=(0,$.c)(18),{count:n,remainder:r,crossDoc:i,scopedAgentId:a,onClickAgent:o}=e,s=i?`true`:void 0,c=`${n} more ${i?`cross-doc `:``}${n===1?`participant`:`participants`}`,l;t[0]!==n||t[1]!==s||t[2]!==c?(l=(0,Z.jsx)(ne,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`presence-overflow`,"data-presence-crossdoc":s,className:`inline-flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-full bg-muted font-medium text-muted-foreground text-xs ring-2 ring-background hover:bg-muted/80`,"aria-label":c,children:[`+`,n]})}),t[0]=n,t[1]=s,t[2]=c,t[3]=l):l=t[3];let u;if(t[4]!==i||t[5]!==o||t[6]!==r||t[7]!==a){let e;t[9]!==i||t[10]!==o||t[11]!==a?(e=e=>e.kind===`human`?(0,Z.jsx)(PD,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(LD,{participant:e,crossDoc:i,scoped:a===e.agentId,onClickAgent:o},e.agentId),t[9]=i,t[10]=o,t[11]=a,t[12]=e):e=t[12],u=r.map(e),t[4]=i,t[5]=o,t[6]=r,t[7]=a,t[8]=u}else u=t[8];let d;t[13]===u?d=t[14]:(d=(0,Z.jsx)(G,{align:`end`,className:`w-auto max-w-xs p-2`,children:(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:u})}),t[13]=u,t[14]=d);let f;return t[15]!==l||t[16]!==d?(f=(0,Z.jsxs)(H,{children:[l,d]}),t[15]=l,t[16]=d,t[17]=f):f=t[17],f}function zD(e,t,n,r){return e.kind===`human`?(0,Z.jsx)(PD,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(LD,{participant:e,crossDoc:n,scoped:r===e.agentId,onClickAgent:t},e.agentId)}function BD(){let e=(0,$.c)(20),{activeProvider:t,activeDocName:n,systemProvider:r,openActivityPanel:i,docPanelMode:a,docPanelAgentId:o}=ot(),{current:s,crossDoc:c}=TD(t,r,n);if(OD(_w(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,kD),n;e[6]===s?n=e[7]:(n=s.slice(kD),e[6]=s,e[7]=n);let r=n,u=c.slice(0,AD),d;e[8]===c?d=e[9]:(d=c.slice(AD),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=>zD(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)(RD,{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=>zD(e,p,!0,m)),f.length>0?(0,Z.jsx)(RD,{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}var VD=`.md`,HD=/\.(md|mdx)$/i;function UD(e,t=VD){return`${e}${t}`}function WD(e){return cO(e).replace(HD,``)}function GD(e){return ti(e)?JD(e.path):Hn(e)?e.path:UD(e.docName,e.docExt)}function KD(e){let t=cO(e).match(HD);return t?`.${t[1].toLowerCase()}`:void 0}function qD(e){return cO(e)}function JD(e){let t=cO(e.trim());return t?`${t}/`:``}function YD(e){return e.endsWith(`/`)?qD(e):WD(e)}function XD(e){return e.map(GD)}function ZD(e){return[...e].sort().join(`\0`)}function QD(e){return ZD(XD(e))}function $D(e){let t=new Set;for(let n of e){if(ti(n)){let e=JD(n.path);e&&t.add(e)}let e=(ti(n)||Hn(n)?n.path:n.docName).split(`/`).filter(Boolean),r=ti(n)?e.length:e.length-1;for(let n=1;n<=r;n++)t.add(`${e.slice(0,n).join(`/`)}/`)}return[...t].sort()}function eO(e){if(!e)return[];let t=cO(e.replace(HD,``)).split(`/`).filter(Boolean),n=[],r=e.endsWith(`/`)?t.length:t.length-1;for(let e=1;e<=r;e++)n.push(`${t.slice(0,e).join(`/`)}/`);return n}function tO(e){let t=e.kind===`directory`,n=t?qD(e.path):WD(e.path),r=t?void 0:KD(e.path);return{kind:t?`folder`:`file`,name:cO(sO(e.path)).replace(HD,``),path:n,treePath:rO(e.path,t),docExt:r}}function nO(e){return e.kind===`directory`?qD(e.path):e.path}function rO(e,t){return t?JD(e):HD.test(e)?e:`${e}${VD}`}function iO(e,t,n){let r=JD(t),i=new Set(n);for(let t=0;t<100;t++){let n=t===0?``:` ${t+1}`;if(e===`file`){let e=`${r}Untitled${n}${VD}`;if(!i.has(e))return{addPath:e,renamePath:e};continue}let a=`${r}New Folder${n}/`;if(!i.has(a))return{addPath:a,renamePath:a}}throw Error(`Could not allocate a unique tree placeholder`)}function aO(e,t){return e===`file`?rO(t,!1):`${qD(t)}/index${VD}`}function oO(e,t){return t.kind===`root`||t.directoryPath==null?sO(e):`${t.directoryPath}${sO(e)}`}function sO(e){let t=cO(e),n=t.lastIndexOf(`/`),r=n===-1?t:t.slice(n+1);return e.endsWith(`/`)?`${r}/`:r}function cO(e){return e.endsWith(`/`)?e.slice(0,-1):e}function lO(e,t){return t.trim()}function uO(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function dO(e,t){let n=lO(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function fO(e,t,n=[]){if(t.length===0&&n.length===0)return e;let r=new Map(t.map(e=>[e.fromDocName,e.toDocName]));return e.map(e=>hn(e)?{...e,docName:r.get(e.docName)??e.docName}:ti(e)||Hn(e)?{...e,path:_O(e.path,n)}:e)}function pO(e,t,n){if(t.length===0&&!n)return e;let r=new Set(t);return e.filter(e=>hn(e)?!r.has(e.docName)&&!vO(e.docName,n):ti(e)||Hn(e)?!vO(e.path,n):!0)}function mO(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}function hO(e,t){return e.flatMap(e=>t===e.toDocName?[e.fromDocName]:[e.fromDocName,e.toDocName])}function gO(e,t){let n=e.kind===`folder`||e.docExt===void 0?e.path:UD(e.path,e.docExt);return nh(t.contentDir,n,t.pathSeparator)}function _O(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 vO(e,t){return!!t&&(e===t||e.startsWith(`${t}/`))}function yO(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)(nu,{"data-slot":`context-menu`,...n}),t[2]=n,t[3]=r),r}function bO(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=mi(`select-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(ru,{"data-slot":`context-menu-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function xO(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)(uu,{"data-slot":`context-menu-sub`,...n}),t[2]=n,t[3]=r),r}function SO(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=mi(`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)(iu,{children:(0,Z.jsx)(au,{"data-slot":`context-menu-content`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function CO(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=mi(`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)(ou,{"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 wO(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=mi(`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)(No,{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)(du,{"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 TO(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=mi(`z-50 min-w-32 origin-(--radix-context-menu-content-transform-origin) overflow-hidden rounded-lg border bg-popover p-1 text-popover-foreground shadow-lg 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)(fu,{"data-slot":`context-menu-sub-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function EO(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=mi(`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)(cu,{children:(0,Z.jsx)(go,{})})}),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)(su,{"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 DO(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=mi(`-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)(lu,{"data-slot":`context-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var OO=[`.md`,`.mdx`],kO=`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`,AO=`z-10 rounded-t-lg rounded-b-none border-border border-b-0 bg-background text-foreground`,jO=mi(AO,`bg-transparent hover:bg-muted focus-visible:bg-muted border-transparent hover:border-border focus-visible:border-border`),MO=`flex h-full min-w-0 flex-1 cursor-pointer items-center overflow-hidden px-3 text-left text-[13px] outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,NO=`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 focus-visible:opacity-100`;function PO(e){return mi(NO,e?`opacity-100`:`pointer-events-none opacity-0 group-focus-within:pointer-events-auto group-focus-within:opacity-100 group-hover:pointer-events-auto group-hover:opacity-100`)}function FO(e){return e.replace(/[^A-Za-z0-9_-]/g,`-`)}function IO(e){let t=Tr(e);window.location.hash!==t&&(window.location.hash=t)}function LO(e){Math.abs(e.deltaX)>=Math.abs(e.deltaY)||e.currentTarget.scrollWidth<=e.currentTarget.clientWidth||(e.preventDefault(),e.currentTarget.scrollLeft+=e.deltaY)}function RO(e,t){let n=[t,...OO].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 zO(e){let t=(0,$.c)(26),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({tabId:o,disabled:n,ref:r,style:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]!==n||t[7]!==o?(s={id:o,disabled:n},t[6]=n,t[7]=o,t[8]=s):s=t[8];let{attributes:c,listeners:l,setNodeRef:u,transform:d,transition:f,isDragging:p}=ia(s),m;t[9]===d?m=t[10]:(m=Ui.Transform.toString(d),t[9]=d,t[10]=m);let h=p?.5:i?.opacity,g=p?1:i?.zIndex,_;t[11]!==i||t[12]!==m||t[13]!==h||t[14]!==g||t[15]!==f?(_={...i,transform:m,transition:f,opacity:h,zIndex:g},t[11]=i,t[12]=m,t[13]=h,t[14]=g,t[15]=f,t[16]=_):_=t[16];let v=_,y;t[17]!==r||t[18]!==u?(y=function(e){u(e),typeof r==`function`?r(e):r&&`current`in r&&(r.current=e)},t[17]=r,t[18]=u,t[19]=y):y=t[19];let b=y,x;return t[20]!==c||t[21]!==b||t[22]!==l||t[23]!==a||t[24]!==v?(x=(0,Z.jsx)(`div`,{ref:b,style:v,...a,...c,...l}),t[20]=c,t[21]=b,t[22]=l,t[23]=a,t[24]=v,t[25]=x):x=t[25],x}function BO(e){let t=(0,$.c)(48),{children:n,closeTab:r,closeTabs:i,canPin:a,disabled:o,openTabs:s,pinTab:c,pinnedTabIds:l,tabId:u,unpinTab:d}=e,f=a===void 0?!0:a;if(o!==void 0&&o)return n;let p;t[0]!==f||t[1]!==l||t[2]!==u?(p=f&&l.includes(u),t[0]=f,t[1]=l,t[2]=u,t[3]=p):p=t[3];let m=p,h;if(t[4]!==s||t[5]!==l||t[6]!==u){let e;t[8]===u?e=t[9]:(e=e=>e!==u,t[8]=u,t[9]=e),h=je(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?(_=je(s,l),t[10]=s,t[11]=l,t[12]=_):_=t[12];let v=_,y=l.length?`Close all unpinned`:`Close all`,b;t[13]===n?b=t[14]:(b=(0,Z.jsx)(bO,{asChild:!0,children:n}),t[13]=n,t[14]=b);let x;t[15]!==r||t[16]!==u?(x=()=>r(u),t[15]=r,t[16]=u,t[17]=x):x=t[17];let S;t[18]!==m||t[19]!==x?(S=(0,Z.jsx)(CO,{disabled:m,onSelect:x,children:`Close`}),t[18]=m,t[19]=x,t[20]=S):S=t[20];let C=g.length===0,w;t[21]!==i||t[22]!==g?(w=()=>{i(g)},t[21]=i,t[22]=g,t[23]=w):w=t[23];let T;t[24]!==w||t[25]!==C?(T=(0,Z.jsx)(CO,{disabled:C,onSelect:w,children:`Close others`}),t[24]=w,t[25]=C,t[26]=T):T=t[26];let E=v.length===0,D;t[27]!==v||t[28]!==i?(D=()=>{i(v)},t[27]=v,t[28]=i,t[29]=D):D=t[29];let O;t[30]!==y||t[31]!==E||t[32]!==D?(O=(0,Z.jsx)(CO,{disabled:E,onSelect:D,children:y}),t[30]=y,t[31]=E,t[32]=D,t[33]=O):O=t[33];let k;t[34]!==f||t[35]!==m||t[36]!==c||t[37]!==u||t[38]!==d?(k=f&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(DO,{}),(0,Z.jsx)(CO,{onSelect:()=>m?d(u):c(u),children:m?`Unpin tab`:`Pin tab`})]}),t[34]=f,t[35]=m,t[36]=c,t[37]=u,t[38]=d,t[39]=k):k=t[39];let A;t[40]!==T||t[41]!==O||t[42]!==k||t[43]!==S?(A=(0,Z.jsxs)(SO,{className:`min-w-40`,children:[S,T,O,k]}),t[40]=T,t[41]=O,t[42]=k,t[43]=S,t[44]=A):A=t[44];let j;return t[45]!==A||t[46]!==b?(j=(0,Z.jsxs)(yO,{children:[b,A]}),t[45]=A,t[46]=b,t[47]=j):j=t[47],j}function VO(e){let t=(0,$.c)(14),{accessibleLabel:n,closeTab:r,isPinned:i,tabId:a,unpinTab:o}=e;if(i){let e=`Unpin ${n}`,r;t[0]!==a||t[1]!==o?(r=e=>{e.stopPropagation(),o(a)},t[0]=a,t[1]=o,t[2]=r):r=t[2];let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(jc,{"aria-hidden":`true`}),t[3]=i):i=t[3];let s;return t[4]!==e||t[5]!==r?(s=(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":e,className:`mr-1.5 text-primary! hover:bg-primary/10!`,onClick:r,children:i}),t[4]=e,t[5]=r,t[6]=s):s=t[6],s}let s=`Close ${n}`,c;t[7]!==r||t[8]!==a?(c=e=>{e.stopPropagation(),r(a)},t[7]=r,t[8]=a,t[9]=c):c=t[9];let l;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(_o,{"aria-hidden":`true`}),t[10]=l):l=t[10];let u;return t[11]!==s||t[12]!==c?(u=(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":s,className:`mr-1.5`,onClick:c,children:l}),t[11]=s,t[12]=c,t[13]=u):u=t[13],u}function HO(){let e=(0,$.c)(62),{activeDocName:t,activeTabId:n,activeNewTabId:r,activeTarget:i,activateTab:a,activateNewTab:o,closeAndClearForRename:s,closeNewTab:c,closeTab:u,closeTabs:d,getPoolActiveDocName:f,isNewTabActive:p,newTabIds:m,openNewTab:h,openTabs:g,pinTab:_,pinnedTabIds:v,remapTabsForRename:y,reorderTabs:b,unpinTab:x,visibleTabIds:S}=ot(),{pageMeta:C}=qr(),w=(0,Q.useRef)(null),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(!1),N=(0,Q.useRef)(null),P=(0,Q.useRef)(!1),F=(0,Q.useRef)(!1),I=(0,Q.useRef)(null),L=(0,Q.useRef)(t),R;e[0]!==n||e[1]!==t||e[2]!==i?(R=n??(i?nt(i):t?Je(t):null),e[0]=n,e[1]=t,e[2]=i,e[3]=R):R=e[3];let z=R,B;e[4]!==r||e[5]!==z||e[6]!==p||e[7]!==m||e[8]!==g?(B=p?`${r??`__new-tab__`}\u0000${g.join(`\0`)}\u0000${m.join(`\0`)}`:z?`${z}\u0000${g.join(`\0`)}`:``,e[4]=r,e[5]=z,e[6]=p,e[7]=m,e[8]=g,e[9]=B):B=e[9];let V=B,H,U;e[10]===t?(H=e[11],U=e[12]):(H=()=>{L.current=t},U=[t],e[10]=t,e[11]=H,e[12]=U),(0,Q.useEffect)(H,U);let W,G;e[13]===V?(W=e[14],G=e[15]):(W=()=>{V&&(w.current?.querySelector(`[data-active-tab="true"]`))?.scrollIntoView({block:`nearest`,inline:`nearest`})},G=[V],e[13]=V,e[14]=W,e[15]=G),(0,Q.useEffect)(W,G);let K,q;e[16]===T?(K=e[17],q=e[18]):(K=()=>{T&&(N.current?.focus(),N.current?.select())},q=[T],e[16]=T,e[17]=K,e[18]=q),(0,Q.useEffect)(K,q);let ee,te;e[19]!==g||e[20]!==T?(ee=()=>{!T||g.includes(T.tabId)||(F.current=!0,I.current=null,E(null),O(``),A(null),M(!1))},te=[g,T],e[19]=g,e[20]=T,e[21]=ee,e[22]=te):(ee=e[21],te=e[22]),(0,Q.useEffect)(ee,te);let ne=function(e,t){let n=t.split(`/`);F.current=!1,I.current=null,E({docName:t,tabId:e}),O(n[n.length-1]),A(null)},re=function(){F.current=!0,I.current=null,E(null),O(``),A(null),M(!1)},ie=async function(){if(F.current){F.current=!1;return}if(P.current)return;let e=T?.docName;if(!e){re();return}let t=lO(`file`,RO(D,C.get(e)?.docExt??`.md`)),n=e.split(`/`),r=n[n.length-1];if(t===r){re();return}if(t===I.current){N.current?.focus();return}if(!uO(t)){A(`Name can’t be empty, ".", "..", or contain / or \\`),N.current?.focus();return}let i=dO({kind:`file`,path:e,name:r},t);P.current=!0,M(!0),A(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(F.current){M(!1),P.current=!1;return}let r=await l(n,`Server error (HTTP ${n.status})`);if(!r.ok){A(r.title),M(!1),P.current=!1,I.current=t,N.current?.focus();return}let a=Ze(Zn,r.body,`rename-path:tab`,{renamed:[]}).renamed,o=L.current,c=mO(o,a),u=!0;try{let e=hO(a,f());await Promise.all(e.map(e=>s(e))),y(a),Fr([`files`,`backlinks`,`graph`])}catch(n){let r=n;u=!1,console.warn(`[EditorTabs] post-rename reconciliation failed`,{err:r,docName:e,newDocName:i,normalized:t}),X.error(`Rename succeeded but the tabstrip may be out of date — refresh to resync`)}F.current=!0,E(null),O(``),A(null),M(!1),P.current=!1,I.current=null,u&&c&&c!==o&&IO(c)}catch(n){console.warn(`[EditorTabs] rename failed`,{err:n,docName:e,newDocName:i,normalized:t}),A(`Network error — please try again`),M(!1),P.current=!1,I.current=t,N.current?.focus()}},ae=typeof window<`u`&&window.okDesktop!=null,oe;e[23]===m?oe=e[24]:(oe=new Set(m),e[23]=m,e[24]=oe);let se=oe,le;e[25]!==c||e[26]!==d||e[27]!==se?(le=function(e){let t=[],n=[];for(let r of e)se.has(r)?n.push(r):t.push(r);t.length>0&&d(t);for(let e of n)c(e)},e[25]=c,e[26]=d,e[27]=se,e[28]=le):le=e[28];let J=le,ue;e[29]===Symbol.for(`react.memo_cache_sentinel`)?(ue={activationConstraint:{distance:8}},e[29]=ue):ue=e[29];let de;e[30]===Symbol.for(`react.memo_cache_sentinel`)?(de={coordinateGetter:Ra},e[30]=de):de=e[30];let fe=po(fa(ea,ue),fa(Xi,de)),pe;e[31]!==b||e[32]!==S?(pe=function(e){let t=String(e.active.id),n=e.over?String(e.over.id):null;if(!n||t===n)return;let r=S.indexOf(t),i=S.indexOf(n);r<0||i<0||r===i||b(Ba([...S],r,i),t)},e[31]=b,e[32]=S,e[33]=pe):pe=e[33];let me=pe,he;e[34]===Symbol.for(`react.memo_cache_sentinel`)?(he=mi(`pl-2 flex h-12 min-w-0 touch-manipulation flex-1 items-end gap-1 overflow-x-auto overflow-y-hidden overscroll-x-contain scroll-fade-mask-x [scrollbar-width:none]`,ae&&`[-webkit-app-region:drag]`),e[34]=he):he=e[34];let ge=LO,_e=la,ve=ra,ye;e[35]===Symbol.for(`react.memo_cache_sentinel`)?(ye={container:typeof document<`u`?document.body:void 0},e[35]=ye):ye=e[35];let be=sa,xe;e[36]===S?xe=e[37]:(xe=[...S],e[36]=S,e[37]=xe);let Se=Vi,Ce=S.map(e=>{if(se.has(e)){let t=e===r;return(0,Z.jsx)(BO,{tabId:e,canPin:!1,openTabs:S,closeTab:c,closeTabs:J,pinTab:_,pinnedTabIds:v,unpinTab:x,children:(0,Z.jsxs)(zO,{tabId:e,"aria-current":t?`page`:void 0,"data-active-tab":t?`true`:void 0,className:mi(kO,t?AO:jO,ae&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),c(e))},onClick:t=>{t.target===t.currentTarget&&o(e)},children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Activate new tab`,className:MO,onClick:()=>o(e),children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:`New tab`})}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Close new tab`,className:PO(t),onClick:t=>{t.stopPropagation(),c(e)},children:(0,Z.jsx)(_o,{"aria-hidden":`true`,className:`size-3.5`})})]})},e)}let t=yt(e),n=e===z,i=v.includes(e);if(t.kind===`folder`){let{baseName:r,label:o,prefix:s}=wt(t.folderPath,`/`),c=`${s}${o}`;return(0,Z.jsx)(BO,{tabId:e,openTabs:S,closeTab:u,closeTabs:J,pinTab:_,pinnedTabIds:v,unpinTab:x,children:(0,Z.jsxs)(zO,{tabId:e,"aria-current":n?`page`:void 0,"data-active-tab":n?`true`:void 0,className:mi(kO,n?AO:jO,ae&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!i&&u(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":c,className:MO,onClick:()=>{a(e)},children:[s&&(0,Z.jsx)(`span`,{className:mi(`min-w-0 flex-1 truncate`,n&&`text-muted-foreground`),children:s}),(0,Z.jsxs)(`span`,{className:mi(`flex min-w-0 items-center`,s?`max-w-[70%] shrink-0`:`flex-1`),children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:r}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:`/`})]})]}),(0,Z.jsx)(VO,{accessibleLabel:c,closeTab:u,isPinned:i,tabId:e,unpinTab:x})]})},e)}if(t.kind===`asset`){let{baseName:r,label:o,prefix:s}=wt(t.assetPath,``),c=`${s}${o}`;return(0,Z.jsx)(BO,{tabId:e,openTabs:S,closeTab:u,closeTabs:J,pinTab:_,pinnedTabIds:v,unpinTab:x,children:(0,Z.jsxs)(zO,{tabId:e,"aria-current":n?`page`:void 0,"data-active-tab":n?`true`:void 0,className:mi(kO,n?AO:jO,ae&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!i&&u(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":c,className:MO,onClick:()=>{a(e)},children:[s?(0,Z.jsx)(`span`,{className:mi(`min-w-0 flex-1 truncate text-muted-foreground/60`,n&&`text-muted-foreground`),children:s}):null,(0,Z.jsx)(`span`,{className:mi(`min-w-0 truncate`,s?`max-w-[70%] shrink-0`:`flex-1`),children:r})]}),(0,Z.jsx)(VO,{accessibleLabel:c,closeTab:u,isPinned:i,tabId:e,unpinTab:x})]})},e)}let s=t.docName,l=C.get(s)?.docExt??`.md`,{baseName:d,extension:f,label:p,prefix:m}=wt(s,l),h=`${m}${p}`,g=l===`.md`||l===`.mdx`,y=T?.tabId===e,b=`editor-tab-rename-error-${FO(s)}`;return(0,Z.jsx)(BO,{disabled:y,tabId:e,openTabs:S,closeTab:u,closeTabs:J,pinTab:_,pinnedTabIds:v,unpinTab:x,children:(0,Z.jsx)(zO,{tabId:e,disabled:y,"aria-current":n?`page`:void 0,"data-active-tab":n?`true`:void 0,className:mi(kO,n?AO:jO,y&&k&&`border-destructive`,ae&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!i&&u(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:y?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(AC,{className:`h-full min-w-0 flex-1 rounded-none border-0 bg-transparent dark:bg-transparent`,children:[(0,Z.jsx)(FC,{ref:N,value:D,disabled:j,"aria-label":`Rename ${p}`,"aria-invalid":k?!0:void 0,"aria-describedby":k?b:void 0,"aria-busy":j||void 0,title:k??s,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=>{O(RO(e.target.value,l)),A(null),I.current=null},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),ie()):e.key===`Escape`&&(e.preventDefault(),re())},onBlur:ie}),(0,Z.jsx)(MC,{align:`inline-end`,"aria-hidden":`true`,className:`pr-2 text-xs`,children:(0,Z.jsx)(PC,{className:`text-muted-foreground/60 text-xs`,children:l})})]}),k?(0,Z.jsx)(`span`,{id:b,role:`alert`,className:`sr-only`,children:k}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":h,title:h,className:MO,onClick:()=>{a(e)},onDoubleClick:t=>{t.preventDefault(),t.stopPropagation(),ne(e,s)},children:(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:d}),!g&&(0,Z.jsx)(`span`,{className:`shrink-0`,children:f})]})}),(0,Z.jsx)(VO,{accessibleLabel:h,closeTab:u,isPinned:i,tabId:e,unpinTab:x})]})})},e)}),we;e[38]!==be||e[39]!==xe||e[40]!==Se||e[41]!==Ce?(we=(0,Z.jsx)(be,{items:xe,strategy:Se,children:Ce}),e[38]=be,e[39]=xe,e[40]=Se,e[41]=Ce,e[42]=we):we=e[42];let Te;e[43]!==_e||e[44]!==me||e[45]!==fe||e[46]!==ve||e[47]!==ye||e[48]!==we?(Te=(0,Z.jsx)(_e,{sensors:fe,collisionDetection:ve,onDragEnd:me,accessibility:ye,children:we}),e[43]=_e,e[44]=me,e[45]=fe,e[46]=ve,e[47]=ye,e[48]=we,e[49]=Te):Te=e[49];let Ee;e[50]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=mi(`first:mb-3 mb-1.5`,ae&&`[-webkit-app-region:no-drag]`),e[50]=Ee):Ee=e[50];let De;e[51]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,Z.jsx)(ce,{"aria-hidden":`true`}),e[51]=De):De=e[51];let Oe;e[52]===h?Oe=e[53]:(Oe=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{type:`button`,size:`icon-xs`,variant:`ghost`,"aria-label":`New tab`,className:Ee,onClick:h,children:De})}),e[52]=h,e[53]=Oe);let ke;e[54]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,Z.jsx)(vn,{children:`New tab`}),e[54]=ke):ke=e[54];let Ae;e[55]===Oe?Ae=e[56]:(Ae=(0,Z.jsxs)(yn,{children:[Oe,ke]}),e[55]=Oe,e[56]=Ae);let je;return e[57]!==he||e[58]!==ge||e[59]!==Te||e[60]!==Ae?(je=(0,Z.jsxs)(`div`,{ref:w,className:he,onWheel:ge,children:[Te,Ae]}),e[57]=he,e[58]=ge,e[59]=Te,e[60]=Ae,e[61]=je):je=e[61],je}function UO(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 WO(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 GO=[{label:`Documentation`,href:`https://openknowledge.ai/docs`,icon:we},{label:`GitHub`,href:`https://github.com/inkeep/open-knowledge`,icon:Sd},{label:`Website`,href:`https://openknowledge.ai/`,icon:Mr},{label:`Discord`,href:`https://go.inkeep.com/ok-discord`,icon:UO},{label:`Twitter`,href:`https://x.com/inkeep`,icon:WO}],KO=()=>{let e=(0,$.c)(5),[t,n]=(0,Q.useState)(!1),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(ne,{asChild:!0,children:(0,Z.jsxs)(Y,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[(0,Z.jsx)(ve,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Resources`})]})})}),(0,Z.jsx)(vn,{children:`Resources`})]}),e[0]=r):r=e[0];let i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs mb-1`,children:`Resources`}),e[1]=i):i=e[1];let a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsxs)(G,{align:`end`,className:`w-64 p-3`,children:[i,(0,Z.jsx)(`nav`,{"aria-label":`Resources`,children:(0,Z.jsx)(`ul`,{className:`space-y-0.5`,children:GO.map(qO)})})]}),e[2]=a):a=e[2];let o;return e[3]===t?o=e[4]:(o=(0,Z.jsxs)(H,{open:t,onOpenChange:n,children:[r,a]}),e[3]=t,e[4]=o),o};function qO(e){let{label:t,href:n,icon:r}=e;return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>Hi(e,n),onAuxClick:e=>Hi(e,n),className:`flex items-center gap-2.5 rounded-md px-2 py-1.5 text-sm text-muted-foreground transition-colors hover:bg-azure-900/5 dark:hover:bg-white/20 hover:text-primary`,children:[(0,Z.jsx)(r,{"aria-hidden":`true`,className:`size-4 shrink-0`}),t]})},n)}function JO(e){let t=(0,$.c)(60),{input:n}=e,{states:r,refresh:i}=Oh(),{dispatch:a}=_h(),[o,s]=(0,Q.useState)(!1),c=typeof window<`u`&&window.okDesktop!=null,l;t[0]===i?l=t[1]:(l=e=>{s(e),e&&i()},t[0]=i,t[1]=l);let u=l,d=n===null,f;t[2]===n?f=t[3]:(f=n!==null&&n.docContext!==null?$r(n.docContext.relativePath):``,t[2]=n,t[3]=f);let p=f,m;t[4]!==a||t[5]!==n?(m=e=>{n!==null&&a(e.id,n)},t[4]=a,t[5]=n,t[6]=m):m=t[6];let h=m,g,_,v,y,b,x,S,C,w,T,E,D;if(t[7]!==u||t[8]!==h||t[9]!==n||t[10]!==o||t[11]!==p||t[12]!==r||t[13]!==d){let e;t[26]===r?e=t[27]:(e=e=>r[e.id]?.installed===!0,t[26]=r,t[27]=e);let i=xm.filter(e);v=r[`claude-code`]?.installed===!0;let a;t[28]!==n||t[29]!==p?(a=()=>{n!==null&&qx(p)},t[28]=n,t[29]=p,t[30]=a):a=t[30],y=a,_=va,D=o,b=u;let s;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(Fi,{className:`size-4`}),t[31]=s):s=t[31];let l;t[32]===d?l=t[33]:(l=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(ba,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,"aria-label":`Open with AI`,disabled:d,className:`text-muted-foreground`,"data-testid":`open-in-agent-trigger`,children:s})})}),t[32]=d,t[33]=l);let f;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(vn,{children:`Open with AI`}),t[34]=f):f=t[34],t[35]===l?x=t[36]:(x=(0,Z.jsxs)(yn,{children:[l,f]}),t[35]=l,t[36]=x),g=_a,S=`end`,C=`min-w-[220px]`,w=`open-in-agent-menu`,t[37]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(Qi,{className:`font-mono font-normal tracking-wide uppercase text-muted-foreground text-xs`,children:`Open with AI`}),t[37]=T):T=t[37];let m;t[38]!==h||t[39]!==p||t[40]!==r?(m=e=>{let t=r[e.id];return(0,Z.jsx)(Jx,{target:e,installState:t,isElectronHost:c,prompt:p,onSelect:()=>h(e)},e.id)},t[38]=h,t[39]=p,t[40]=r,t[41]=m):m=t[41],E=i.map(m),t[7]=u,t[8]=h,t[9]=n,t[10]=o,t[11]=p,t[12]=r,t[13]=d,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S,t[21]=C,t[22]=w,t[23]=T,t[24]=E,t[25]=D}else g=t[14],_=t[15],v=t[16],y=t[17],b=t[18],x=t[19],S=t[20],C=t[21],w=t[22],T=t[23],E=t[24],D=t[25];let O;t[42]!==v||t[43]!==y||t[44]!==n?(O=v?null:(0,Z.jsxs)(ya,{onSelect:y,disabled:n===null,"data-testid":`open-in-agent-claude-web-fallback`,"aria-label":`Open in claude.ai, opens in browser with prompt pre-filled`,children:[(0,Z.jsx)(he,{className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:`Open in claude.ai →`}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`opens in browser`})]}),t[42]=v,t[43]=y,t[44]=n,t[45]=O):O=t[45];let k;t[46]!==g||t[47]!==O||t[48]!==S||t[49]!==C||t[50]!==w||t[51]!==T||t[52]!==E?(k=(0,Z.jsxs)(g,{align:S,className:C,"data-testid":w,children:[T,E,O]}),t[46]=g,t[47]=O,t[48]=S,t[49]=C,t[50]=w,t[51]=T,t[52]=E,t[53]=k):k=t[53];let A;return t[54]!==_||t[55]!==b||t[56]!==x||t[57]!==k||t[58]!==D?(A=(0,Z.jsxs)(_,{open:D,onOpenChange:b,children:[x,k]}),t[54]=_,t[55]=b,t[56]=x,t[57]=k,t[58]=D,t[59]=A):A=t[59],A}var YO=`/api/share/publish/owners`,XO=`/api/share/publish/name-check`,ZO=`/api/share/publish`,QO=/[A-Za-z0-9._-]/g;function $O(e){return(e.match(QO)?.join(``)??``).replace(/[-.]{2,}/g,e=>e[0]??`-`).replace(/^[-.]+/,``).replace(/[-.]+$/,``)}function ek(e){if(!e)return``;let t=e.replace(/[/\\]+$/g,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n<0?t:t.slice(n+1)}function tk(e){return`https://github.com/orgs/${encodeURIComponent(e)}/policies/applications`}function nk(e,t,n){switch(e){case`name-conflict`:return{banner:`${t}/${n} already exists. Pick a different name.`,next:{kind:`edit-name`}};case`saml-sso`:return{banner:`GitHub denied the request. You may need to authorize Open Knowledge for ${t} in your browser.`,next:{kind:`authorize-org`,authorizeUrl:tk(t)}};case`push-failed`:return{banner:`Created ${t}/${n}, push failed.`,next:{kind:`retry-push`}};case`auth-required`:return{banner:`GitHub sign-in expired. Sign in again to continue.`,next:{kind:`reauth`}};case`init-failed`:return{banner:`Couldn't prepare this project for publish.`,next:{kind:`edit-form`}};case`network`:return{banner:`Couldn't reach GitHub. Try again?`,next:{kind:`edit-form`}};case`no-project`:return{banner:`Open a project first.`,next:{kind:`edit-form`}}}}async function rk(e=fetch){let t=await e(YO,{method:`GET`});if(!t.ok)throw Error(`owners transport ${t.status}`);let n=await t.json(),r=kn.safeParse(n);if(!r.success)throw Error(`owners response shape mismatch`);return r.data}async function ik(e,t,n=fetch){let r=await n(`${XO}?owner=${encodeURIComponent(e)}&name=${encodeURIComponent(t)}`,{method:`GET`});if(!r.ok)throw Error(`name-check transport ${r.status}`);let i=await r.json(),a=Wr.safeParse(i);if(!a.success)throw Error(`name-check response shape mismatch`);return a.data}async function ak(e,t=fetch){let n=await t(ZO,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!n.ok)throw Error(`publish transport ${n.status}`);let r=await n.json(),i=rr.safeParse(r);if(!i.success)throw Error(`publish response shape mismatch`);return i.data}function ok(e,t,n){return e.ok?e.available?{kind:`available`}:{kind:`taken`,owner:t,name:n}:e.error===`auth-required`?{kind:`error`,banner:`GitHub sign-in expired. Sign in again to continue.`}:{kind:`error`,banner:`Couldn't reach GitHub. Try again?`}}function sk(e){return e.submitting||e.owner===null||e.sanitizedName.length===0?!1:e.nameCheck.kind===`available`}async function ck(e,t){await t.runShareAction({docName:e,hasRemote:!0,onClickWhenNoRemote:()=>{}},{clipboardWrite:t.clipboardWrite,toastSuccess:t.toastSuccess,toastError:t.toastError,logEvent:t.logEvent,fetchFn:t.fetchFn})}var lk=`/api/share/construct-url`,uk=`Could not construct share URL.`,dk=`Link ready but could not copy to clipboard.`;async function fk(e,t=fetch){let n=await t(lk,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({docPath:e})});if(!n.ok)throw Error(`construct-url transport ${n.status}`);let r=await n.json(),i=jn.safeParse(r);if(!i.success)throw Error(`construct-url response shape mismatch`);return i.data}function pk(e,t){switch(e){case`detached-head`:return`Switch to a branch to share.`;case`branch-not-on-origin`:return t?`Push ${t} to GitHub before sharing.`:`Push this branch to GitHub before sharing.`;case`non-github-remote`:return`Sharing supports GitHub remotes only.`;case`invalid-path`:return`Can't share this path.`;case`no-remote`:return`This project has no GitHub remote.`}}async function mk(e,t){if(!e.hasRemote)return e.onClickWhenNoRemote(),{kind:`opened-wizard`};let n=_r(e.docName),r;try{r=await fk(n,t.fetchFn)}catch{return t.toastError(uk),{kind:`transport-error`}}if(r.ok){try{await t.clipboardWrite(r.shareUrl)}catch{return t.toastError(dk),t.logEvent(`[share] action=link-construct result=clipboard-failed`),{kind:`clipboard-failed`,shareUrl:r.shareUrl}}return t.toastSuccess(`Link copied.`),t.logEvent(`[share] action=link-construct`),{kind:`copied`,shareUrl:r.shareUrl,branch:r.branch}}if(r.error===`no-remote`)return e.onClickWhenNoRemote(),{kind:`opened-wizard`};let i=r.branch;return t.toastError(pk(r.error,i)),{kind:`business-error`,error:r.error,branch:i}}var hk=500;function gk(e){let t=(0,$.c)(94),{open:n,onOpenChange:r}=e,i=km(),{activeDocName:a}=ot(),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(`private`),[v,y]=(0,Q.useState)(``),x;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x={kind:`idle`},t[0]=x):x=t[0];let[S,C]=(0,Q.useState)(x),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(!1),A=(0,Q.useRef)(null),j=(0,Q.useRef)(null),M=(0,Q.useRef)(null),N;t[1]===m?N=t[2]:(N=$O(m),t[1]=m,t[2]=N);let P=N,F=o?.find(e=>e.login===f)??null,I;t[3]===f?I=t[4]:(I=async function(){l(!0),d(null);try{let e=await rk();if(!e.ok){e.error===`auth-required`?(k(!0),d(`Sign in to GitHub to continue.`)):d(`Couldn't reach GitHub. Try again?`),l(!1);return}s(e.owners),e.owners.length>0&&f===``&&p(e.owners[0]?.login??``)}catch{d(`Couldn't reach GitHub. Try again?`)}l(!1)},t[3]=f,t[4]=I);let L=I,R;t[5]!==L||t[6]!==n||t[7]!==o||t[8]!==f||t[9]!==i?.contentDir?(R=()=>{n&&(C({kind:`idle`}),D(null),T(!1),d(null),h($O(ek(i?.contentDir??``))),_(`private`),y(``),o===null?L():f===``&&o.length>0&&p(o[0]?.login??``))},t[5]=L,t[6]=n,t[7]=o,t[8]=f,t[9]=i?.contentDir,t[10]=R):R=t[10];let z;t[11]===n?z=t[12]:(z=[n],t[11]=n,t[12]=z),(0,Q.useEffect)(R,z);let V,H;t[13]!==n||t[14]!==P||t[15]!==f?(V=()=>{if(n){if(A.current!==null&&clearTimeout(A.current),f===``||P===``){C({kind:`idle`});return}return C({kind:`pending`}),A.current=setTimeout(async()=>{let e=f,t=P;j.current=`${e}|${t}`,C({kind:`checking`});try{let n=await ik(e,t);if(j.current!==`${e}|${t}`)return;C(ok(n,e,t))}catch{if(j.current!==`${e}|${t}`)return;C({kind:`error`,banner:`Couldn't reach GitHub. Try again?`})}},hk),()=>{A.current!==null&&(clearTimeout(A.current),A.current=null)}}},H=[n,f,P],t[13]=n,t[14]=P,t[15]=f,t[16]=V,t[17]=H):(V=t[16],H=t[17]),(0,Q.useEffect)(V,H);let U;t[18]===L?U=t[19]:(U=function(){k(!1),d(null),L()},t[18]=L,t[19]=U);let W=U,G=async function(){if(sk({owner:F,sanitizedName:P,nameCheck:S,submitting:w})){T(!0),D(null);try{let e=await ak({owner:f,name:P,visibility:g,description:v.trim().length>0?v.trim():void 0});if(e.ok){r(!1),a?await ck(a,{runShareAction:mk,clipboardWrite:xk,toastSuccess:bk,toastError:yk,logEvent:vk}):X.success(`Published to ${e.ownerLogin}/${e.repoName}.`),T(!1);return}let t=nk(e.error,f,P);D({message:t.banner,next:t.next}),t.next.kind===`edit-name`?(M.current?.focus(),M.current?.select()):t.next.kind===`reauth`&&k(!0)}catch{D({message:`Couldn't reach GitHub. Try again?`,next:{kind:`edit-form`}})}T(!1)}},K;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(K=function(e){let t=window.okDesktop?.shell?.openExternal;t?t(e):window.open(e,`_blank`,`noopener`)},t[20]=K):K=t[20];let q=K,te;t[21]===r?te=t[22]:(te=function(){r(!1)},t[21]=r,t[22]=te);let ne=te,re=!sk({owner:F,sanitizedName:P,nameCheck:S,submitting:w}),ie;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Z.jsxs)(Ao,{children:[(0,Z.jsx)(bo,{children:`Publish to GitHub`}),(0,Z.jsx)(vo,{children:`Sharing a doc needs a GitHub repository. Create one for this project.`})]}),t[23]=ie):ie=t[23];let ae;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Z.jsx)(Go,{htmlFor:`publish-owner`,children:`Owner`}),t[24]=ae):ae=t[24];let oe;t[25]!==L||t[26]!==o||t[27]!==u||t[28]!==c||t[29]!==f?(oe=(0,Z.jsxs)(`fieldset`,{className:`flex flex-col gap-1.5`,children:[ae,c&&o===null?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Z.jsx)(ue,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),` Loading...`]}):u?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm text-destructive`,children:u}),(0,Z.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>L(),children:`Retry`})]}):(0,Z.jsxs)(Ye,{value:f,onValueChange:p,children:[(0,Z.jsx)(ee,{id:`publish-owner`,"data-testid":`publish-owner-trigger`,"aria-label":`Owner`,children:(0,Z.jsx)(b,{placeholder:`Pick an owner`})}),(0,Z.jsx)(B,{children:(o??[]).map(_k)})]})]}),t[25]=L,t[26]=o,t[27]=u,t[28]=c,t[29]=f,t[30]=oe):oe=t[30];let se;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Z.jsx)(Go,{htmlFor:`publish-name`,children:`Repository name`}),t[31]=se):se=t[31];let ce,le;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(ce=e=>h(e.target.value),le=()=>{j.current=null},t[32]=ce,t[33]=le):(ce=t[32],le=t[33]);let J;t[34]===m?J=t[35]:(J=(0,Z.jsx)(Po,{id:`publish-name`,ref:M,"data-testid":`publish-name`,value:m,onChange:ce,onBlur:le,placeholder:`my-knowledge-base`,autoComplete:`off`,spellCheck:!1}),t[34]=m,t[35]=J);let de;t[36]===P?de=t[37]:(de=P?(0,Z.jsxs)(Z.Fragment,{children:[`Will be created as `,(0,Z.jsx)(`code`,{className:`font-mono`,children:P})]}):`Pick a name`,t[36]=P,t[37]=de);let fe;t[38]===de?fe=t[39]:(fe=(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:de}),t[38]=de,t[39]=fe);let pe;t[40]===S?pe=t[41]:(pe=(0,Z.jsx)(Ck,{status:S}),t[40]=S,t[41]=pe);let me;t[42]!==fe||t[43]!==pe?(me=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs`,"aria-live":`polite`,children:[fe,pe]}),t[42]=fe,t[43]=pe,t[44]=me):me=t[44];let he;t[45]!==J||t[46]!==me?(he=(0,Z.jsxs)(`fieldset`,{className:`flex flex-col gap-1.5`,children:[se,J,me]}),t[45]=J,t[46]=me,t[47]=he):he=t[47];let ge;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,Z.jsx)(Go,{children:`Visibility`}),t[48]=ge):ge=t[48];let _e;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(_e=e=>_(e===`public`?`public`:`private`),t[49]=_e):_e=t[49];let ve;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,Z.jsx)(pm,{value:`private`,id:`publish-visibility-private`,"data-testid":`publish-visibility-private`}),t[50]=ve):ve=t[50];let ye;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,Z.jsxs)(Go,{htmlFor:`publish-visibility-private`,className:`flex cursor-pointer items-center gap-2 rounded-md border border-input p-2 text-sm font-normal has-data-checked:border-primary`,children:[ve,(0,Z.jsxs)(`span`,{children:[`Private`,(0,Z.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Only collaborators`})]})]}),t[51]=ye):ye=t[51];let be;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,Z.jsx)(pm,{value:`public`,id:`publish-visibility-public`,"data-testid":`publish-visibility-public`}),t[52]=be):be=t[52];let xe;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,Z.jsxs)(Go,{htmlFor:`publish-visibility-public`,className:`flex cursor-pointer items-center gap-2 rounded-md border border-input p-2 text-sm font-normal has-data-checked:border-primary`,children:[be,(0,Z.jsxs)(`span`,{children:[`Public`,(0,Z.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Anyone can see`})]})]}),t[53]=xe):xe=t[53];let Se;t[54]===g?Se=t[55]:(Se=(0,Z.jsxs)(`fieldset`,{className:`flex flex-col gap-1.5`,children:[ge,(0,Z.jsxs)(fm,{value:g,onValueChange:_e,className:`grid-cols-2`,"aria-label":`Visibility`,children:[ye,xe]})]}),t[54]=g,t[55]=Se);let Ce;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,Z.jsx)(Go,{htmlFor:`publish-description`,children:`Description (optional)`}),t[56]=Ce):Ce=t[56];let we;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(we=e=>y(e.target.value),t[57]=we):we=t[57];let Te;t[58]===v?Te=t[59]:(Te=(0,Z.jsxs)(`fieldset`,{className:`flex flex-col gap-1.5`,children:[Ce,(0,Z.jsx)(Cs,{id:`publish-description`,"data-testid":`publish-description`,rows:2,value:v,onChange:we,placeholder:`What is this knowledge base for?`})]}),t[58]=v,t[59]=Te);let Ee;t[60]!==E||t[61]!==q||t[62]!==G?(Ee=E&&(0,Z.jsx)(Sk,{banner:E,onAuthorize:q,onRetryPush:G}),t[60]=E,t[61]=q,t[62]=G,t[63]=Ee):Ee=t[63];let De;t[64]!==oe||t[65]!==he||t[66]!==Se||t[67]!==Te||t[68]!==Ee?(De=(0,Z.jsxs)(Do,{className:`flex flex-col gap-4`,children:[oe,he,Se,Te,Ee]}),t[64]=oe,t[65]=he,t[66]=Se,t[67]=Te,t[68]=Ee,t[69]=De):De=t[69];let Oe;t[70]===ne?Oe=t[71]:(Oe=(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,onClick:ne,children:`Cancel`}),t[70]=ne,t[71]=Oe);let ke;t[72]===w?ke=t[73]:(ke=w?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ue,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),` Publishing...`]}):`Publish & copy link`,t[72]=w,t[73]=ke);let Ae;t[74]!==G||t[75]!==re||t[76]!==ke?(Ae=(0,Z.jsx)(Y,{type:`button`,onClick:G,disabled:re,"data-testid":`publish-submit`,children:ke}),t[74]=G,t[75]=re,t[76]=ke,t[77]=Ae):Ae=t[77];let je;t[78]!==Oe||t[79]!==Ae?(je=(0,Z.jsxs)(Oo,{children:[Oe,Ae]}),t[78]=Oe,t[79]=Ae,t[80]=je):je=t[80];let Me;t[81]!==De||t[82]!==je?(Me=(0,Z.jsxs)(wo,{className:`sm:max-w-lg`,showCloseButton:!1,children:[ie,De,je]}),t[81]=De,t[82]=je,t[83]=Me):Me=t[83];let Ne;t[84]!==r||t[85]!==n||t[86]!==Me?(Ne=(0,Z.jsx)(jo,{open:n,onOpenChange:r,children:Me}),t[84]=r,t[85]=n,t[86]=Me,t[87]=Ne):Ne=t[87];let Pe;t[88]!==O||t[89]!==W?(Pe=(0,Z.jsx)(qu,{open:O,onOpenChange:k,onSuccess:W}),t[88]=O,t[89]=W,t[90]=Pe):Pe=t[90];let Fe;return t[91]!==Ne||t[92]!==Pe?(Fe=(0,Z.jsxs)(Z.Fragment,{children:[Ne,Pe]}),t[91]=Ne,t[92]=Pe,t[93]=Fe):Fe=t[93],Fe}function _k(e){return(0,Z.jsx)(U,{value:e.login,"data-testid":`publish-owner-option-${e.login}`,children:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e.avatarUrl?(0,Z.jsx)(`img`,{src:e.avatarUrl,alt:``,"aria-hidden":!0,className:`size-4 rounded-full`}):null,(0,Z.jsx)(`span`,{children:e.login}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.kind===`user`?`you`:`org`})]})},e.login)}function vk(e){return console.log(e)}function yk(e){return X.error(e)}function bk(e){return X.success(e)}function xk(e){return navigator.clipboard.writeText(e)}function Sk(e){let t=(0,$.c)(13),{banner:n,onAuthorize:r,onRetryPush:i}=e,a=n.next,o;t[0]===n.message?o=t[1]:(o=(0,Z.jsx)(`span`,{children:n.message}),t[0]=n.message,t[1]=o);let s;t[2]!==a.authorizeUrl||t[3]!==a.kind||t[4]!==r?(s=a.kind===`authorize-org`&&(0,Z.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,className:`self-start`,"data-testid":`publish-authorize-org`,onClick:()=>r(a.authorizeUrl),children:[`Authorize in browser `,(0,Z.jsx)(he,{className:`ml-1 size-3`,"aria-hidden":!0})]}),t[2]=a.authorizeUrl,t[3]=a.kind,t[4]=r,t[5]=s):s=t[5];let c;t[6]!==a.kind||t[7]!==i?(c=a.kind===`retry-push`&&(0,Z.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,className:`self-start`,"data-testid":`publish-retry-push`,onClick:i,children:`Retry push`}),t[6]=a.kind,t[7]=i,t[8]=c):c=t[8];let l;return t[9]!==o||t[10]!==s||t[11]!==c?(l=(0,Z.jsxs)(`div`,{role:`alert`,"data-testid":`publish-banner`,className:`flex flex-col gap-2 rounded-md border border-destructive/50 bg-destructive/5 p-3 text-sm`,children:[o,s,c]}),t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}function Ck(e){let t=(0,$.c)(10),{status:n}=e;if(n.kind===`available`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`span`,{"data-testid":`publish-name-check`,"data-status":`available`,className:`flex items-center gap-1 text-emerald-600 dark:text-emerald-400`,children:[(0,Z.jsx)(Xr,{className:`size-3.5`,"aria-hidden":!0}),` Available`]}),t[0]=e):e=t[0],e}if(n.kind===`taken`){let e;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(fe,{className:`size-3.5`,"aria-hidden":!0}),t[1]=e):e=t[1];let r;return t[2]!==n.name||t[3]!==n.owner?(r=(0,Z.jsxs)(`span`,{"data-testid":`publish-name-check`,"data-status":`taken`,className:`flex items-center gap-1 text-destructive`,children:[e,` `,n.owner,`/`,n.name,` already exists`]}),t[2]=n.name,t[3]=n.owner,t[4]=r):r=t[4],r}if(n.kind===`checking`||n.kind===`pending`){let e;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ue,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),t[5]=e):e=t[5];let r;return t[6]===n.kind?r=t[7]:(r=(0,Z.jsxs)(`span`,{"data-testid":`publish-name-check`,"data-status":n.kind,className:`flex items-center gap-1 text-muted-foreground`,children:[e,` Checking...`]}),t[6]=n.kind,t[7]=r),r}if(n.kind===`error`){let e;return t[8]===n.banner?e=t[9]:(e=(0,Z.jsx)(`span`,{"data-testid":`publish-name-check`,"data-status":`error`,className:`text-destructive`,children:n.banner}),t[8]=n.banner,t[9]=e),e}return null}var wk=50,Tk=()=>{let e=(0,$.c)(5),t=(0,Q.useRef)(null),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>{t.current===null&&(t.current=setTimeout(()=>{t.current=null,_C.preload()},wk))},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;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsxs)(Y,{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:()=>{a(),window.location.hash!==`#settings`&&(window.location.hash=Sm)},children:[(0,Z.jsx)(zc,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Settings`})]})}),(0,Z.jsx)(vn,{children:`Settings`})]}),e[4]=c):c=e[4],c};function Ek(e){let t=(0,$.c)(12),{onClickWhenNoRemote:n}=e,{activeDocName:r}=ot(),{status:i}=La(),[a,o]=(0,Q.useState)(!1);if(!r)return null;let s=i?.hasRemote===!0,c;t[0]!==r||t[1]!==a||t[2]!==s||t[3]!==n?(c=async function(){if(!a&&r){o(!0);try{await mk({docName:r,hasRemote:s,onClickWhenNoRemote:n},{clipboardWrite:Ak,toastSuccess:kk,toastError:Ok,logEvent:Dk})}catch{X.error(`Could not construct share URL.`)}o(!1)}},t[0]=r,t[1]=a,t[2]=s,t[3]=n,t[4]=c):c=t[4];let l=c,u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(Bc,{className:`size-3.5`,"aria-hidden":!0}),t[5]=u):u=t[5];let d;t[6]!==a||t[7]!==l?(d=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsxs)(Y,{variant:`ghost`,size:`sm`,"aria-label":`Share doc`,onClick:l,disabled:a,className:`gap-1.5 text-muted-foreground px-1.5`,"data-testid":`share-button`,children:[u,`Share`]})}),t[6]=a,t[7]=l,t[8]=d):d=t[8];let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(vn,{children:`Share`}),t[9]=f):f=t[9];let p;return t[10]===d?p=t[11]:(p=(0,Z.jsxs)(yn,{children:[d,f]}),t[10]=d,t[11]=p),p}function Dk(e){return console.log(e)}function Ok(e){return X.error(e)}function kk(e){return X.success(e)}function Ak(e){return navigator.clipboard.writeText(e)}function jk(e){if(!e)return`never`;let t=Date.now()-new Date(e).getTime();return t<6e4?`just now`:t<36e5?`${Math.floor(t/6e4)} min ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:new Date(e).toLocaleDateString()}async function Mk(e){await fetch(`/api/sync/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({op:e})})}function Nk(e){let t=(0,$.c)(9),{status:n}=e;switch(n.state){case`dormant`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Xs,{className:`size-3.5 text-muted-foreground`}),t[0]=e):e=t[0],e}case`idle`:{if(n.ahead>0||n.behind>0){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Pc,{className:`size-3.5 text-muted-foreground`}),t[1]=e):e=t[1],e}let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Xs,{className:`size-3.5 text-muted-foreground`}),t[2]=e):e=t[2],e}case`fetching`:case`pulling`:case`pushing`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Pc,{className:`size-3.5 text-muted-foreground animate-spin`}),t[3]=e):e=t[3],e}case`conflict`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(dr,{className:`size-3.5 text-amber-500`}),t[4]=e):e=t[4],e}case`offline`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ys,{className:`size-3.5 text-muted-foreground`}),t[5]=e):e=t[5],e}case`auth-error`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Sc,{className:`size-3.5 text-destructive`}),t[6]=e):e=t[6],e}case`disabled`:{let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(dr,{className:`size-3.5 text-amber-500`}),t[7]=e):e=t[7],e}default:{let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Xs,{className:`size-3.5 text-muted-foreground`}),t[8]=e):e=t[8],e}}}function Pk(e){switch(e.state){case`idle`:return e.ahead>0?`↑${e.ahead}`:e.behind>0?`↓${e.behind}`:``;case`fetching`:case`pulling`:case`pushing`:return``;case`conflict`:return e.conflictCount>0?`${e.conflictCount}`:``;case`offline`:return``;case`auth-error`:return``;default:return``}}function Fk(e){switch(e){case`dormant`:return`No git remote`;case`idle`:return`Synced`;case`fetching`:return`Fetching`;case`pulling`:return`Pulling`;case`pushing`:return`Pushing`;case`conflict`:return`Conflict`;case`offline`:return`Offline`;case`auth-error`:return`Sign in required`;case`disabled`:return`Sync disabled`;default:return e}}function Ik(e){switch(e){case`external-changes-pending`:return`External changes pending`;case`dirty-tree`:return`Working tree has uncommitted changes`;case`detached-head`:return`Detached HEAD — checkout a branch to resume`;case`auth-error`:return`Sign in required`;case`protected-branch`:return`Protected branch — cannot push`;default:return e}}function Lk(e){return e.syncEnabled?e.state===`idle`?e.ahead>0&&e.behind>0?`${e.ahead} ahead, ${e.behind} behind`:e.ahead>0?`${e.ahead} ahead`:e.behind>0?`${e.behind} behind`:`Synced`:e.state===`conflict`&&e.conflictCount>0?`${e.conflictCount} conflict${e.conflictCount===1?``:`s`}`:Fk(e.state):`Sync off`}function Rk(e){let t=(0,$.c)(76),{status:n,onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a}=e,{projectLocalConfig:o,projectLocalSynced:c}=Ga(),l=o?.autoSync?.enabled??!1,{confirmOpen:u,setConfirmOpen:d,onToggleRequest:f,onConfirm:p}=Sa(da()),m;t[0]===n?m=t[1]:(m=(0,Z.jsx)(Nk,{status:n}),t[0]=n,t[1]=m);let h;t[2]===n.state?h=t[3]:(h=Fk(n.state),t[2]=n.state,t[3]=h);let g;t[4]===h?g=t[5]:(g=(0,Z.jsx)(`span`,{className:`text-sm font-medium truncate`,children:h}),t[4]=h,t[5]=g);let _;t[6]!==m||t[7]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[m,g]}),t[6]=m,t[7]=g,t[8]=_):_=t[8];let v=!c,y=l?`Disable sync`:`Enable sync`,b;t[9]!==l||t[10]!==f||t[11]!==v||t[12]!==y?(b=(0,Z.jsx)(s,{checked:l,disabled:v,onCheckedChange:f,"aria-label":y}),t[9]=l,t[10]=f,t[11]=v,t[12]=y,t[13]=b):b=t[13];let x;t[14]!==_||t[15]!==b?(x=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[_,b]}),t[14]=_,t[15]=b,t[16]=x):x=t[16];let S;t[17]!==u||t[18]!==p||t[19]!==d?(S=(0,Z.jsx)(Ua,{open:u,onOpenChange:d,onConfirm:p}),t[17]=u,t[18]=p,t[19]=d,t[20]=S):S=t[20];let C;t[21]===n.error?C=t[22]:(C=n.error&&(0,Z.jsx)(`p`,{className:`text-xs text-destructive`,children:n.error}),t[21]=n.error,t[22]=C);let w;t[23]===n.pausedReason?w=t[24]:(w=n.pausedReason&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Ik(n.pausedReason)}),t[23]=n.pausedReason,t[24]=w);let T;t[25]===n.state?T=t[26]:(T=n.state===`conflict`&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-400`,children:`Sync paused — resolve conflicts to resume.`}),t[25]=n.state,t[26]=T);let E;t[27]!==l||t[28]!==n.lastSyncUtc||t[29]!==n.state?(E=l&&n.state!==`dormant`&&(0,Z.jsxs)(`div`,{children:[`Last synced: `,jk(n.lastSyncUtc)]}),t[27]=l,t[28]=n.lastSyncUtc,t[29]=n.state,t[30]=E):E=t[30];let D;t[31]===n.ahead?D=t[32]:(D=n.ahead>0&&(0,Z.jsxs)(`div`,{children:[n.ahead,` commit`,n.ahead===1?``:`s`,` ahead`]}),t[31]=n.ahead,t[32]=D);let O;t[33]===n.behind?O=t[34]:(O=n.behind>0&&(0,Z.jsxs)(`div`,{children:[n.behind,` commit`,n.behind===1?``:`s`,` behind`]}),t[33]=n.behind,t[34]=O);let k;t[35]===n.conflictCount?k=t[36]:(k=n.conflictCount>0&&(0,Z.jsxs)(`div`,{children:[n.conflictCount,` file`,n.conflictCount===1?``:`s`,` conflicted`]}),t[35]=n.conflictCount,t[36]=k);let A;t[37]===l?A=t[38]:(A=!l&&(0,Z.jsx)(`div`,{children:`Sync is off — your edits will not sync to the remote repository.`}),t[37]=l,t[38]=A);let j;t[39]!==E||t[40]!==D||t[41]!==O||t[42]!==k||t[43]!==A?(j=(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-0.5`,children:[E,D,O,k,A]}),t[39]=E,t[40]=D,t[41]=O,t[42]=k,t[43]=A,t[44]=j):j=t[44];let M;t[45]!==a||t[46]!==n.identityUnresolved?(M=n.identityUnresolved&&a&&(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed p-2`,children:[(0,Z.jsx)($c,{className:`size-3.5 mt-0.5 text-muted-foreground shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground leading-snug`,children:`Git identity isn't set — commits use a default author. Set yours so teammates see your name.`}),(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,className:`self-start`,onClick:a,children:`Set identity`})]})]}),t[45]=a,t[46]=n.identityUnresolved,t[47]=M):M=t[47];let N;t[48]!==l||t[49]!==n.state?(N=l&&n.state!==`dormant`&&n.state!==`disabled`&&n.state!==`auth-error`&&n.state!==`conflict`&&(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,onClick:Bk,children:`Sync now`}),t[48]=l,t[49]=n.state,t[50]=N):N=t[50];let P;t[51]!==l||t[52]!==r||t[53]!==n.state?(P=l&&n.state===`auth-error`&&(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,onClick:r,children:`Sign in`}),t[51]=l,t[52]=r,t[53]=n.state,t[54]=P):P=t[54];let F;t[55]!==l||t[56]!==n.state?(F=l&&n.state===`offline`&&(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,onClick:zk,children:`Retry`}),t[55]=l,t[56]=n.state,t[57]=F):F=t[57];let I;t[58]!==l||t[59]!==i||t[60]!==n.state?(I=l&&n.state===`conflict`&&i&&(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,onClick:i,children:`Review conflicts`}),t[58]=l,t[59]=i,t[60]=n.state,t[61]=I):I=t[61];let L;t[62]!==N||t[63]!==P||t[64]!==F||t[65]!==I?(L=(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1 pt-1`,children:[N,P,F,I]}),t[62]=N,t[63]=P,t[64]=F,t[65]=I,t[66]=L):L=t[66];let R;return t[67]!==C||t[68]!==w||t[69]!==T||t[70]!==j||t[71]!==M||t[72]!==L||t[73]!==x||t[74]!==S?(R=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[x,S,C,w,T,j,M,L]}),t[67]=C,t[68]=w,t[69]=T,t[70]=j,t[71]=M,t[72]=L,t[73]=x,t[74]=S,t[75]=R):R=t[75],R}function zk(){Mk(`sync`)}function Bk(){Mk(`sync`)}function Vk(e){let t=(0,$.c)(36),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a}=n,{status:o,fetchError:s}=La();if(!o){if(s){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":`Sync status unavailable`,disabled:!0,children:(0,Z.jsx)(Ys,{className:`size-3.5`})})}),t[2]=e):e=t[2];let n=s===`network`?`Sync status unavailable — server unreachable.`:`Sync status unavailable — server error.`,r;return t[3]===n?r=t[4]:(r=(0,Z.jsxs)(yn,{children:[e,(0,Z.jsx)(vn,{children:n})]}),t[3]=n,t[4]=r),r}return null}if(o.state===`dormant`&&!o.hasRemote||o.state===`disabled`&&!o.pausedReason)return null;let c;t[5]===o?c=t[6]:(c=Pk(o),t[5]=o,t[6]=c);let l=c,u=!!o.identityUnresolved,d;t[7]===o.state?d=t[8]:(d=Fk(o.state),t[7]=o.state,t[8]=d);let f=`Sync status: ${d}${u?` — git identity unset`:``}`,p;t[9]===o?p=t[10]:(p=(0,Z.jsx)(Nk,{status:o}),t[9]=o,t[10]=p);let m;t[11]===l?m=t[12]:(m=l&&(0,Z.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 text-[9px] leading-none font-medium bg-background border rounded-full px-0.5`,children:l}),t[11]=l,t[12]=m);let h;t[13]!==l||t[14]!==u?(h=!l&&u&&(0,Z.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 size-1.5 rounded-full bg-amber-500 ring-2 ring-background`,"aria-hidden":!0}),t[13]=l,t[14]=u,t[15]=h):h=t[15];let g;t[16]!==f||t[17]!==p||t[18]!==m||t[19]!==h?(g=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(ne,{asChild:!0,children:(0,Z.jsxs)(Y,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground relative`,"aria-label":f,children:[p,m,h]})})}),t[16]=f,t[17]=p,t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;t[21]===o?_=t[22]:(_=Lk(o),t[21]=o,t[22]=_);let v;t[23]===_?v=t[24]:(v=(0,Z.jsx)(vn,{children:_}),t[23]=_,t[24]=v);let y;t[25]!==v||t[26]!==g?(y=(0,Z.jsxs)(yn,{children:[g,v]}),t[25]=v,t[26]=g,t[27]=y):y=t[27];let b;t[28]!==i||t[29]!==a||t[30]!==r||t[31]!==o?(b=(0,Z.jsx)(G,{align:`end`,className:`w-64 p-3`,children:(0,Z.jsx)(Rk,{status:o,onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a})}),t[28]=i,t[29]=a,t[30]=r,t[31]=o,t[32]=b):b=t[32];let x;return t[33]!==y||t[34]!==b?(x=(0,Z.jsxs)(H,{children:[y,b]}),t[33]=y,t[34]=b,t[35]=x):x=t[35],x}function Hk(e){let t=(0,$.c)(45),{onSaveVersion:n,saving:r,onSignIn:i,onSetIdentity:a,onOpenConflictResolver:o}=e,{activeDocName:s,activeTarget:c}=ot(),{state:l}=aD(),u=km(),[d,f]=(0,Q.useState)(!1),p;bb0:{if(c===null){let e;t[0]===u?e=t[1]:(e=ah({workspace:u}),t[0]=u,t[1]=e),p=e;break bb0}if(c.kind===`folder`){if(!u){p=null;break bb0}let e;t[2]!==c.folderPath||t[3]!==u?(e=oh({folderAbsPath:nh(u.contentDir,c.folderPath,u.pathSeparator),folderRelativePath:c.folderPath,workspace:u}),t[2]=c.folderPath,t[3]=u,t[4]=e):e=t[4],p=e;break bb0}let e;t[5]!==s||t[6]!==u?(e=ih({docName:s,workspace:u}),t[5]=s,t[6]=u,t[7]=e):e=t[7],p=e}let m=p,h=typeof window<`u`&&window.okDesktop!=null,g=h&&l===`collapsed`&&`pl-[78px]`,_;t[8]===g?_=t[9]:(_=mi(`flex h-12 shrink-0 items-center bg-muted/35 shadow-[inset_0_-1px_0_var(--border)]`,h&&`[-webkit-app-region:drag]`,g,h&&`motion-safe:transition-[padding] motion-safe:duration-200 motion-safe:ease-linear`),t[8]=g,t[9]=_);let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(uD,{className:mi(`-ml-1 shrink-0 text-muted-foreground`,h&&`[-webkit-app-region:no-drag]`)})}),t[10]=v):v=t[10];let y=l===`expanded`?`Hide Files`:`Show Files`,b;t[11]===y?b=t[12]:(b=(0,Z.jsxs)(yn,{children:[v,(0,Z.jsx)(vn,{children:y})]}),t[11]=y,t[12]=b);let x,S;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(ro,{orientation:`vertical`,className:`mr-1 h-4 shrink-0 data-vertical:self-center`}),S=(0,Z.jsx)(HO,{}),t[13]=x,t[14]=S):(x=t[13],S=t[14]);let C;t[15]===b?C=t[16]:(C=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 px-3`,children:[b,x,S]}),t[15]=b,t[16]=C);let w;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(w=mi(`flex shrink-0 items-center justify-end gap-2 px-3`,h&&`[&>*]:[-webkit-app-region:no-drag]`),t[17]=w):w=t[17];let T;t[18]!==s||t[19]!==n||t[20]!==r?(T=s&&(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,"aria-label":`Checkpoint version`,onClick:n,disabled:r,className:`text-muted-foreground`,children:(0,Z.jsx)(Rc,{className:`size-3.5`})})}),(0,Z.jsx)(vn,{children:r?`Saving`:`Checkpoint version`})]}),t[18]=s,t[19]=n,t[20]=r,t[21]=T):T=t[21];let E;t[22]===m?E=t[23]:(E=(0,Z.jsx)(JO,{input:m}),t[22]=m,t[23]=E);let D;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(Ek,{onClickWhenNoRemote:()=>f(!0)}),t[24]=D):D=t[24];let O;t[25]===d?O=t[26]:(O=(0,Z.jsx)(gk,{open:d,onOpenChange:f}),t[25]=d,t[26]=O);let k;t[27]!==o||t[28]!==a||t[29]!==i?(k=(0,Z.jsx)(Vk,{onSignIn:i,onSetIdentity:a,onOpenConflictResolver:o}),t[27]=o,t[28]=a,t[29]=i,t[30]=k):k=t[30];let A,j,M,N,P;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(BD,{}),j=(0,Z.jsx)(ro,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),M=(0,Z.jsx)(Zu,{}),N=(0,Z.jsx)(Tk,{}),P=(0,Z.jsx)(KO,{}),t[31]=A,t[32]=j,t[33]=M,t[34]=N,t[35]=P):(A=t[31],j=t[32],M=t[33],N=t[34],P=t[35]);let F;t[36]!==T||t[37]!==E||t[38]!==O||t[39]!==k?(F=(0,Z.jsxs)(`div`,{className:w,children:[T,E,D,O,k,A,j,M,N,P]}),t[36]=T,t[37]=E,t[38]=O,t[39]=k,t[40]=F):F=t[40];let I;return t[41]!==F||t[42]!==_||t[43]!==C?(I=(0,Z.jsxs)(`header`,{className:_,children:[C,F]}),t[41]=F,t[42]=_,t[43]=C,t[44]=I):I=t[44],I}function Uk(){let e=(0,$.c)(32),[t,n]=ig(),[r,i]=(0,Q.useState)(t),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(`auth`),[d,f]=(0,Q.useState)(ky[0].id),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),_=Qa(),{projectLocalConfig:v,projectLocalSynced:y}=Ga(),{activeDocName:b}=ot(),x=!h&&_?.hasRemote===!0&&y===!0&&v!==null&&v.autoSync?.enabled===null,S,C;e[0]===b?(S=e[1],C=e[2]):(S=()=>{let e=function(e){let t=e.detail;t&&b&&bs(b,{kind:`raw-mdx`,detail:t}),i(`source`)};return window.addEventListener(Xh,e),()=>window.removeEventListener(Xh,e)},C=[b],e[0]=b,e[1]=S,e[2]=C),(0,Q.useEffect)(S,C);let w;e[3]===n?w=e[4]:(w=function(e){i(e),n(e)},e[3]=n,e[4]=w);let T=w,E;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(E=async function(){m(!0);try{let e=await fetch(`/api/save-version`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});e.ok?X.success(`Checkpoint saved`):(console.error(`[save-version] failed:`,await e.text()),X.error(`Checkpoint failed — try again`))}catch(e){console.error(`[save-version] failed:`,e),X.error(`Checkpoint failed — try again`)}m(!1)},e[5]=E):E=e[5];let D=E,O;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(sg,{onOpenResolver:()=>o(!0)}),e[6]=O):O=e[6];let k,A,j;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>{u(`auth`),c(!0)},A=()=>{u(`identity`),c(!0)},j=()=>o(!0),e[7]=k,e[8]=A,e[9]=j):(k=e[7],A=e[8],j=e[9]);let M;e[10]===p?M=e[11]:(M=(0,Z.jsx)(Hk,{onSaveVersion:D,saving:p,onSignIn:k,onSetIdentity:A,onOpenConflictResolver:j}),e[10]=p,e[11]=M);let N;e[12]!==d||e[13]!==r||e[14]!==T?(N=(0,Z.jsx)(PE,{editorMode:r,onModeChange:T,activeTab:d,onActiveTabChange:f}),e[12]=d,e[13]=r,e[14]=T,e[15]=N):N=e[15];let P;e[16]===a?P=e[17]:(P=(0,Z.jsx)(lv,{open:a,onOpenChange:o}),e[16]=a,e[17]=P);let F=l===`identity`,I;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>{c(!1)},e[18]=I):I=e[18];let L;e[19]!==s||e[20]!==F?(L=(0,Z.jsx)(qu,{open:s,onOpenChange:c,identityPrompt:F,onSuccess:I}),e[19]=s,e[20]=F,e[21]=L):L=e[21];let R;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>g(!0),e[22]=R):R=e[22];let z;e[23]===x?z=e[24]:(z=(0,Z.jsx)(ag,{open:x,onResolved:R}),e[23]=x,e[24]=z);let B;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Z.jsx)(qh,{}),e[25]=B):B=e[25];let V;return e[26]!==P||e[27]!==L||e[28]!==z||e[29]!==M||e[30]!==N?(V=(0,Z.jsxs)(Z.Fragment,{children:[O,M,N,P,L,z,B]}),e[26]=P,e[27]=L,e[28]=z,e[29]=M,e[30]=N,e[31]=V):V=e[31],V}var Wk=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
35
|
+
`)}}}}function uw(e){try{let t=be().parseToMdast(e),n=[];return lw(t,n),n.join(``).trim()}catch(t){return console.warn(`[document-stats] mdast parse failed, falling back to raw text`,t),e.trim()}}function dw(e){if(!e)return 0;let t=0;for(let n of e.split(/\s+/))aw.test(n)&&t++;return t}function fw(e){let t=globalThis.Intl.Segmenter;if(!t)return dw(e);let n=new t(void 0,{granularity:`word`}),r=0;for(let t of n.segment(e))t.isWordLike&&r++;return r}function pw(e){let t=iw.test(e)?1.5:4;return Math.ceil(e.length/t)}function mw(e){if(!e)return{words:0,chars:0,tokens:0};let{body:t}=Cr(e);if(!t.trim())return{words:0,chars:0,tokens:0};let n=uw(t);return n?{words:iw.test(n)?fw(n):dw(n),chars:n.length,tokens:pw(n)}:{words:0,chars:0,tokens:0}}var hw=300;function gw(e,t){let n=(0,$.c)(4),[r,i]=(0,Q.useState)(rw),a,o;return n[0]!==t||n[1]!==e?(a=()=>{if(!e||!t){i(rw);return}let n=e.document.getText(`source`),r=!1,a=null,o=function(){r||i(mw(n.toString()))};o();let s=function(){a&&clearTimeout(a),a=setTimeout(o,hw)};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 _w(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`?vw: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 vw(e){return e===`synced`?`synced`:`connected`}var yw=oi;function bw(e,t={}){let n=j(e.componentName);return n.name===`*`?t.unregisteredSuffix?`${e.componentName} (unregistered)`:e.componentName:n.displayName??n.name}var xw=200,Sw=`Outside any block`;function Cw(e){let t=(0,$.c)(5),{editor:n}=e,r=De(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?ww(n,r):o.current?Sw:``,a.current=window.setTimeout(()=>{i.current&&(i.current.textContent=``,i.current.textContent=t),o.current=e,a.current=null},xw),()=>{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 ww(e,t){if(!t||t.ancestorChain.length===0)return``;let n=t.ancestorChain,r=n[n.length-1],i=bw(r,{unregisteredSuffix:!0});if(n.length===1)return`Selected: ${i}`;let a=n[n.length-2],o=bw(a);try{let t=e.state.doc.resolve(r.pos),n=t.index(t.depth),a=t.parent.childCount;return`Selected: ${i}, ${n+1} of ${a} in ${o}`}catch{return`Selected: ${i} in ${o}`}}function Tw(){let[e]=(0,Q.useState)(Ln);return e}function Ew({principal:e,identity:t}){return e&&e.source===`git-config`?{type:`human`,name:Dr(e.display_name),color:xr(e.id,qn),coeditor:t.coeditor,tabId:t.tabId,principalId:e.id}:e&&e.source===`synthesized`?{type:`human`,name:t.name,color:xr(e.id,qn),coeditor:t.coeditor,tabId:t.tabId}:{type:`human`,name:t.name,color:t.color,coeditor:t.coeditor,tabId:t.tabId}}function Dw(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 Ow=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&&Pn(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(ui(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(Jn(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(Tn(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(xn(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(Qn(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(En(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(mn(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(Xn(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=di(this.view,e.from,e.to),r={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof wn){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 Un){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():Dw(o.getBoundingClientRect(),s.getBoundingClientRect());r={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return r}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&Bn(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()}},kw=e=>new An({key:typeof e.pluginKey==`string`?new Ur(e.pluginKey):e.pluginKey,view:t=>new Ow({view:t,...e})});ri.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[kw({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 Aw=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 Fn(e,{textSerializers:Rn(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(ui(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(Jn(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(Tn(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(xn(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(Qn(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(En(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(mn(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(Xn(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=di(this.view,e.from,e.to);Bn({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()}},jw=e=>new An({key:typeof e.pluginKey==`string`?new Ur(e.pluginKey):e.pluginKey,view:t=>new Aw({view:t,...e})});ri.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?[jw({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 Mw(e,t){return e??new Ur(t)}var Nw=typeof window<`u`?Q.useLayoutEffect:Q.useEffect,Pw=new Set([`left`,`opacity`,`position`,`top`,`visibility`,`width`]),Fw=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(`.`)),Iw=new Set([`children`,`className`,`style`]),Lw=new Set([`tabIndex`]),Rw=new Set([`accessKey`,`autoCapitalize`,`contentEditable`,`contextMenu`,`dir`,`draggable`,`enterKeyHint`,`hidden`,`id`,`lang`,`nonce`,`role`,`slot`,`spellCheck`,`tabIndex`,`title`,`translate`]),zw={Blur:`focusout`,DoubleClick:`dblclick`,Focus:`focusin`,MouseEnter:`mouseenter`,MouseLeave:`mouseleave`};function Bw(e,t){return/^on[A-Z]/.test(e)&&typeof t==`function`}function Vw(e){return e.startsWith(`aria-`)||e.startsWith(`data-`),e}function Hw(e){return e.startsWith(`aria-`)||e.startsWith(`data-`)||Rw.has(e)}function Uw(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function Ww(e){let t=e.endsWith(`Capture`),n=(t?e.slice(0,-7):e).slice(2);return{eventName:zw[n]??n.toLowerCase(),options:t?{capture:!0}:void 0}}function Gw(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 Kw(e){return Lw.has(e)}function qw(e,t,n){if(t===`tabIndex`){e.tabIndex=Number(n);return}e[t]=n}function Jw(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 Yw(e,t){return typeof t!=`number`||t===0||e.startsWith(`--`)||Fw.has(e)?String(t):`${t}px`}function Xw(e,t){Pw.has(t)||e.style.removeProperty(Uw(t))}function Zw(e,t,n){Pw.has(t)||e.style.setProperty(Uw(t),Yw(t,n))}function Qw(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(r=>{if(Iw.has(r)||!Hw(r)||Bw(r,t[r])||Bw(r,n[r]))return;let i=t[r],a=n[r];if(i===a)return;let o=Vw(r);if(a==null||a===!1){Kw(r)&&Jw(e,r),e.removeAttribute(o);return}if(a===!0){Kw(r)&&qw(e,r,!0),e.setAttribute(o,``);return}if(Kw(r)){qw(e,r,a);return}e.setAttribute(o,String(a))})}function $w(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute(`class`)}}function eT(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){Xw(e,t);return}Zw(e,t,a)}})}function tT(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(!Bw(t,n))return;let{eventName:i,options:a}=Ww(t),o=t=>{n(Gw(e,t))};e.addEventListener(i,o,a),r.push({eventName:i,listener:o,options:a})}),r}function nT(e,t){let n=(0,Q.useRef)({}),r=(0,Q.useRef)([]);Nw(()=>{let i=n.current;return $w(e,i.className,t.className),eT(e,i.style,t.style),Qw(e,i,t),r.current=tT(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 rT=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)(Mw(e,`bubbleMenu`)).current;nT(d.current,l),typeof u==`function`?u(d.current):u&&(u.current=d.current);let{editor:p}=Ct(),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=kw({...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,Hs.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)(Mw(e,`floatingMenu`)).current;nT(u.current,c),typeof l==`function`?l(u.current):l&&(l.current=u.current);let{editor:f}=Ct(),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=jw({...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,Hs.createPortal)(s,u.current)});var iT=[{name:`paragraph`,label:`Text`,icon:Ac,isActive:e=>e.isActive(`paragraph`)&&!e.isActive(`list`),command:e=>e.chain().focus().setParagraph().run()},{name:`heading1`,label:`Heading 1`,icon:te,isActive:e=>e.isActive(`heading`,{level:1}),command:e=>e.chain().focus().toggleHeading({level:1}).run()},{name:`heading2`,label:`Heading 2`,icon:W,isActive:e=>e.isActive(`heading`,{level:2}),command:e=>e.chain().focus().toggleHeading({level:2}).run()},{name:`heading3`,label:`Heading 3`,icon:V,isActive:e=>e.isActive(`heading`,{level:3}),command:e=>e.chain().focus().toggleHeading({level:3}).run()},{name:`bulletList`,label:`Bullet List`,icon:v,isActive:e=>e.isActive(`list`,{ordered:!1})&&!e.isActive(`listItem`,{checked:!0})&&!e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleBulletList().run()},{name:`orderedList`,label:`Ordered List`,icon:K,isActive:e=>e.isActive(`list`,{ordered:!0}),command:e=>e.chain().focus().toggleOrderedList().run()},{name:`taskList`,label:`Task List`,icon:g,isActive:e=>e.isActive(`listItem`,{checked:!0})||e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleTaskList().run()},{name:`blockquote`,label:`Quote`,icon:jt,isActive:e=>e.isActive(`blockquote`),command:e=>e.chain().focus().toggleBlockquote().run()},{name:`codeBlock`,label:`Code Block`,icon:Uc,isActive:e=>e.isActive(`codeBlock`),command:e=>e.chain().focus().toggleCodeBlock().run()}];function aT(e){let t=(0,$.c)(18),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:oT},t[0]=n,t[1]=r);let{current:i,activeStates:a}=Re(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)(mt,{className:`size-3 opacity-50`}),t[6]=l):l=t[6];let u;t[7]!==s||t[8]!==c?(u=(0,Z.jsx)(ba,{asChild:!0,children:(0,Z.jsxs)(Y,{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=iT.map(e=>{let t=e.icon,r=a[e.name];return(0,Z.jsxs)(ya,{className:r?`bg-accent text-accent-foreground`:``,onSelect:()=>{e.command(n)},children:[(0,Z.jsx)(t,{className:`size-4`}),(0,Z.jsx)(`span`,{children:e.label})]},e.name)}),t[10]=a,t[11]=n,t[12]=d):d=t[12];let f;t[13]===d?f=t[14]:(f=(0,Z.jsx)(_a,{align:`start`,sideOffset:8,className:`w-44 max-h-(--radix-dropdown-menu-content-available-height) overflow-y-auto subtle-scrollbar`,children:d}),t[13]=d,t[14]=f);let p;return t[15]!==u||t[16]!==f?(p=(0,Z.jsxs)(va,{children:[u,f]}),t[15]=u,t[16]=f,t[17]=p):p=t[17],p}function oT(e){let t=Object.fromEntries(iT.map(t=>[t.name,t.isActive(e.editor)]));return{current:iT.find(e=>t[e.name])??iT[0],activeStates:t}}function sT(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 cT(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:re(typeof n.src==`string`?n.src:``)}function lT(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 uT(e){let t=(0,$.c)(10),{editor:n}=e,r;if(t[0]===n?r=t[1]:(r={editor:n,selector:dT},t[0]=n,t[1]=r),Re(r)===null)return null;let i;t[2]===n?i=t[3]:(i=e=>{e.preventDefault();let t=sT(n);t&&lT(t,cT(n))},t[2]=n,t[3]=i);let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(ua,{className:`size-3.5`}),t[4]=a):a=t[4];let o;t[5]===i?o=t[6]:(o=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,"aria-label":`Download file`,className:`text-accent-foreground`,onMouseDown:i,children:a})}),t[5]=i,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(vn,{side:`bottom`,sideOffset:8,children:`Download file`}),t[7]=s):s=t[7];let c;return t[8]===o?c=t[9]:(c=(0,Z.jsx)(`div`,{className:`flex items-center gap-0.5`,children:(0,Z.jsxs)(yn,{children:[o,s]})}),t[8]=o,t[9]=c),c}function dT(e){return sT(e.editor)}function fT(e){return sT(e)!==null}var pT=[{value:`left`,label:`Align left`,icon:Oe},{value:`center`,label:`Align center`,icon:Nt},{value:`right`,label:`Align right`,icon:Tt}];function mT(e){let t=e.state.selection.node;if(!t||t.type.name!==`jsxComponent`)return null;let n=t.attrs.componentName;if(n!==`img`&&n!==`CommonMarkImage`&&n!==`Embed`)return null;let r=(t.attrs.props??{}).align;return r===`left`||r===`right`||r===`center`?r:`center`}function hT(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:gT},t[0]=n,t[1]=r);let i=Re(r);if(i===null)return null;let a;t[2]!==i||t[3]!==n?(a=pT.map(e=>{let{value:t,label:r,icon:a}=e,o=i===t;return(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,"aria-label":r,"aria-pressed":o,className:o?`bg-accent text-primary`:`text-accent-foreground`,onMouseDown:e=>{e.preventDefault();let r=n.state.selection,i=r.node;if(!i||i.type.name!==`jsxComponent`)return;let a=String(i.attrs.componentName??``);if(a!==`img`&&a!==`CommonMarkImage`&&a!==`Embed`||i.attrs.kind!==`element`)return;let o=a===`CommonMarkImage`,s=r.from,c={...i.attrs.props??{},align:t},l=o?{...i.attrs,componentName:`img`,props:c,sourceDirty:!0}:{...i.attrs,props:c,sourceDirty:!0},u=n.state.tr.setNodeMarkup(s,null,l);u.setSelection(wn.create(u.doc,s)),He(n.view.nodeDOM(s),()=>{n.view.dispatch(u)})},children:(0,Z.jsx)(a,{className:`size-3.5`})})}),(0,Z.jsx)(vn,{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 gT(e){return mT(e.editor)}function _T(e){return mT(e)!==null}var vT=[{name:`bold`,icon:Vs,command:e=>e.chain().focus().toggleBold().run(),isActive:e=>e.isActive(`strong`),shortcut:`⌘ B`},{name:`italic`,icon:hc,command:e=>e.chain().focus().toggleItalic().run(),isActive:e=>e.isActive(`emphasis`),shortcut:`⌘ I`},{name:`underline`,icon:Zc,command:e=>e.chain().focus().toggleUnderline().run(),isActive:e=>e.isActive(`underline`),shortcut:`⌘ U`},{name:`strikethrough`,icon:qc,command:e=>e.chain().focus().toggleStrike().run(),isActive:e=>e.isActive(`strike`),shortcut:`⌘ ⇧ X`},{name:`code`,icon:Zs,command:e=>e.chain().focus().toggleCode().run(),isActive:e=>e.isActive(`code`),shortcut:`⌘ E`},{name:`highlight`,icon:mc,command:e=>e.chain().focus().toggleHighlight().run(),isActive:e=>e.isActive(`highlight`),shortcut:`⌘ ⇧ H`}];function yT(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:bT},t[0]=n,t[1]=r);let i=Re(r),a;t[2]!==i||t[3]!==n?(a=vT.map(e=>{let t=e.icon,r=i[e.name];return(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{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)(vn,{side:`bottom`,sideOffset:8,children:[(0,Z.jsx)(`span`,{className:`capitalize`,children:e.name}),(0,Z.jsx)(OS,{children:Dn()?e.shortcut:e.shortcut.replace(`⌘`,`Ctrl`)})]})]},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 bT(e){return Object.fromEntries(vT.map(t=>[t.name,t.isActive(e.editor)]))}function xT(e){let t=(0,$.c)(46),{editor:n}=e,[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),s=(0,Q.useRef)(null),c;t[0]===n?c=t[1]:(c=n.isActive(`link`),t[0]=n,t[1]=c);let l=c,u;t[2]===n?u=t[3]:(u=n.getAttributes(`link`).href??``,t[2]=n,t[3]=u);let d=u,f,p;t[4]===n?(f=t[5],p=t[6]):(f=()=>{let e=function(){n.state.selection.empty&&i(!1)};return n.on(`selectionUpdate`,e),()=>{n.off(`selectionUpdate`,e)}},p=[n],t[4]=n,t[5]=f,t[6]=p),(0,Q.useEffect)(f,p);let m,h;t[7]!==d||t[8]!==r?(m=()=>{r&&(o(d),requestAnimationFrame(()=>s.current?.focus()))},h=[r,d],t[7]=d,t[8]=r,t[9]=m,t[10]=h):(m=t[9],h=t[10]),(0,Q.useEffect)(m,h);let g;t[11]!==n||t[12]!==l||t[13]!==a?(g=function(){a.trim()?n.chain().focus().setLink({href:a.trim()}).run():l&&n.chain().focus().unsetLink().run(),i(!1)},t[11]=n,t[12]=l,t[13]=a,t[14]=g):g=t[14];let _=g,v;t[15]===n?v=t[16]:(v=function(){n.chain().focus().unsetLink().run(),i(!1)},t[15]=n,t[16]=v);let y=v,b;t[17]!==_||t[18]!==n?(b=function(e){e.key===`Enter`&&(e.preventDefault(),_()),e.key===`Escape`&&(e.preventDefault(),i(!1),n.chain().focus().run())},t[17]=_,t[18]=n,t[19]=b):b=t[19];let x=b;if(r){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=e=>o(e.target.value),t[20]=e):e=t[20];let n;t[21]!==x||t[22]!==a?(n=(0,Z.jsx)(`input`,{ref:s,type:`url`,placeholder:`Paste link`,value:a,onChange:e,onKeyDown:x,"aria-label":`Link URL`,className:`h-5 w-44 bg-transparent text-sm border-none outline-none placeholder:text-muted-foreground`}),t[21]=x,t[22]=a,t[23]=n):n=t[23];let r;t[24]===_?r=t[25]:(r=()=>{_()},t[24]=_,t[25]=r);let i;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(tc,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[26]=i):i=t[26];let c;t[27]===r?c=t[28]:(c=(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,"aria-label":`Apply link`,onClick:r,children:i}),t[27]=r,t[28]=c);let u;t[29]!==n||t[30]!==c?(u=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border bg-background px-2 py-1`,children:[n,c]}),t[29]=n,t[30]=c,t[31]=u):u=t[31];let f;t[32]!==d||t[33]!==l||t[34]!==y?(f=l&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,"aria-label":`Open link in new tab`,onMouseDown:e=>{e.preventDefault(),me(d)},children:(0,Z.jsx)(mo,{className:`size-3.5`})})}),(0,Z.jsx)(vn,{side:`bottom`,sideOffset:8,children:`Open link in new tab`})]}),(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,"aria-label":`Remove link`,onMouseDown:e=>{e.preventDefault(),y()},children:(0,Z.jsx)(Ue,{className:`size-3.5`})})}),(0,Z.jsx)(vn,{side:`bottom`,sideOffset:8,children:`Remove link`})]})]}),t[32]=d,t[33]=l,t[34]=y,t[35]=f):f=t[35];let p;return t[36]!==u||t[37]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[u,f]}),t[36]=u,t[37]=f,t[38]=p):p=t[38],p}let S=l?`bg-accent text-primary`:`text-accent-foreground`,C,w;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{e.preventDefault(),i(!0)},w=(0,Z.jsx)(vc,{className:`size-3.5`}),t[39]=C,t[40]=w):(C=t[39],w=t[40]);let T;t[41]===S?T=t[42]:(T=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,"aria-label":`Insert link`,className:S,onMouseDown:C,children:w})}),t[41]=S,t[42]=T);let E;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsxs)(vn,{side:`bottom`,sideOffset:8,children:[`Link`,(0,Z.jsx)(OS,{children:Dn()?`⌘ K`:`Ctrl K`})]}),t[43]=E):E=t[43];let D;return t[44]===T?D=t[45]:(D=(0,Z.jsxs)(yn,{children:[T,E]}),t[44]=T,t[45]=D),D}function ST({editor:e}){if(st(e.state).query||e.isActive(`codeBlock`))return!1;if(_T(e)||fT(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 CT(e){let t=(0,$.c)(22),{editor:n}=e,r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(0),o=(0,Q.useRef)(null),s;t[0]===n?s=t[1]:(s={editor:n,selector:OT},t[0]=n,t[1]=s);let c=Re(s),l;t[2]===n?l=t[3]:(l={editor:n,selector:DT},t[2]=n,t[3]=l);let u=Re(l),d;t[4]!==n.state||t[5]!==n.view?(d=()=>{try{let{from:e,to:t}=n.state.selection;return di(n.view,e,t)}catch{return new DOMRect}},t[4]=n.state,t[5]=n.view,t[6]=d):d=t[6];let f;if(t[7]!==n.view.dom||t[8]!==d){let e={getBoundingClientRect:d,contextElement:n.view.dom};f=()=>{let t=r.current;t&&(o.current?.(),o.current=Mn(e,t,()=>{Bn(e,t,{placement:`top`,strategy:`fixed`,middleware:[Tn(8),ui(),Jn({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(ET)}))},t[7]=n.view.dom,t[8]=d,t[9]=f}else f=t[9];let p=f,m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{o.current?.(),o.current=null,a(TT)},t[10]=m):m=t[10];let h=m,g;t[11]===p?g=t[12]:(g={onShow:p,onHide:h,strategy:`fixed`},t[11]=p,t[12]=g);let _;t[13]!==n||t[14]!==u||t[15]!==c||t[16]!==i?(_=c?(0,Z.jsx)(hT,{editor:n},`${i}-img-align`):u?(0,Z.jsx)(uT,{editor:n},`${i}-file`):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(aT,{editor:n}),(0,Z.jsx)(ro,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),(0,Z.jsx)(yT,{editor:n},i),(0,Z.jsx)(ro,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),(0,Z.jsx)(xT,{editor:n},`${i}-link`)]}),t[13]=n,t[14]=u,t[15]=c,t[16]=i,t[17]=_):_=t[17];let v;return t[18]!==n||t[19]!==g||t[20]!==_?(v=(0,Z.jsx)(rT,{ref:r,editor:n,"data-testid":`bubble-menu-bar`,appendTo:wT,shouldShow:ST,updateDelay:250,options:g,className:`z-50 flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:_}),t[18]=n,t[19]=g,t[20]=_,t[21]=v):v=t[21],v}function wT(){return document.body}function TT(e){return e+1}function ET(){}function DT(e){return fT(e.editor)}function OT(e){return _T(e.editor)}var kT=[{name:`addRowBefore`,icon:xe,label:`Add row above`,command:e=>e.chain().focus().addRowBefore().run()},{name:`addRowAfter`,icon:Ee,label:`Add row below`,command:e=>e.chain().focus().addRowAfter().run()},{name:`deleteRow`,icon:Ue,label:`Delete row`,command:e=>e.chain().focus().deleteRow().run()}],AT=[{name:`addColumnBefore`,icon:Mi,label:`Add column left`,command:e=>e.chain().focus().addColumnBefore().run()},{name:`addColumnAfter`,icon:Zi,label:`Add column right`,command:e=>e.chain().focus().addColumnAfter().run()},{name:`deleteColumn`,icon:Ue,label:`Delete column`,command:e=>e.chain().focus().deleteColumn().run()}],jT=[{name:`toggleHeaderRow`,icon:Jc,label:`Toggle header row`,command:e=>e.chain().focus().toggleHeaderRow().run()},{name:`toggleHeaderColumn`,icon:$s,label:`Toggle header column`,command:e=>e.chain().focus().toggleHeaderColumn().run()},{name:`deleteTable`,icon:fc,label:`Delete table`,command:e=>e.chain().focus().deleteTable().run()}];function MT({editor:e}){return st(e.state).query?!1:e.isActive(`table`)}function NT(e){let t=(0,$.c)(14),{action:n,editor:r}=e,i=n.icon,a;t[0]!==n||t[1]!==r?(a=e=>{e.preventDefault(),n.command(r)},t[0]=n,t[1]=r,t[2]=a):a=t[2];let o;t[3]===i?o=t[4]:(o=(0,Z.jsx)(i,{className:`size-3.5`}),t[3]=i,t[4]=o);let s;t[5]!==n.label||t[6]!==a||t[7]!==o?(s=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,"aria-label":n.label,className:`text-muted-foreground`,onMouseDown:a,children:o})}),t[5]=n.label,t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;t[9]===n.label?c=t[10]:(c=(0,Z.jsx)(vn,{side:`bottom`,sideOffset:8,children:n.label}),t[9]=n.label,t[10]=c);let l;return t[11]!==s||t[12]!==c?(l=(0,Z.jsxs)(yn,{children:[s,c]}),t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function PT(e){let t=(0,$.c)(13),{editor:n}=e,r;t[0]===n?r=t[1]:(r=kT.map(e=>(0,Z.jsx)(NT,{action:e,editor:n},e.name)),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(ro,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[2]=i):i=t[2];let a;t[3]===n?a=t[4]:(a=AT.map(e=>(0,Z.jsx)(NT,{action:e,editor:n},e.name)),t[3]=n,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(ro,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[5]=o):o=t[5];let s;t[6]===n?s=t[7]:(s=jT.map(e=>(0,Z.jsx)(NT,{action:e,editor:n},e.name)),t[6]=n,t[7]=s);let c;return t[8]!==n||t[9]!==r||t[10]!==a||t[11]!==s?(c=(0,Z.jsxs)(rT,{editor:n,"data-testid":`table-controls-menu`,shouldShow:MT,updateDelay:100,className:`flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:[r,i,a,o,s]}),t[8]=n,t[9]=r,t[10]=a,t[11]=s,t[12]=c):c=t[12],c}var FT=new WeakMap;function IT(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=Kn(e.color),n.textContent=e.name,t.append(n),t}var LT={state:`idle`,count:0,lastFiredAt:null,position:`append`,lastAgentId:null};function RT(){let e=new In({extensions:Ir});return{mdManager:e,text:C({mdManager:e}),html:_e({mdManager:e}),paste:pt({mdManager:e}),drop:P({mdManager:e})}}function zT(e){let{provider:t,placeholder:n,prebuiltMapping:r}=e;return[...ut.map(e=>e.name===`link`||e.name===`wikiLink`?e.configure({docName:t.configuration.name??``}):e.name===`toggleHeadings`?e.configure({getDocName:()=>t.configuration.name??null}):e),yw.configure({placeholder:n??`Type '/' for commands`,showOnlyCurrent:!0}),T.configure({document:t.document,...r?{ySyncOptions:{mapping:r}}:{}}),ri.create({name:`imageUploadDecoration`,addProseMirrorPlugins(){return[o]}}),ri.create({name:`collaborationCursor`,addProseMirrorPlugins(){let e=t.awareness;if(!e)throw Error(`[TiptapEditor] HocuspocusProvider has no awareness instance — cursor plugin cannot initialize`);return[N(e,{cursorBuilder:IT})]}})]}function BT(e){let{provider:t,clipboard:n,ctorStart:r}=e;return{onBeforeCreate:({editor:e})=>{FT.set(e,r)},onCreate:({editor:e})=>{n.html.setView(e.view);let r=FT.get(e);if(FT.delete(e),r==null)return;let i=performance.now();dt(`ok/editor/create-tiptap`,{docName:t.configuration.name??`unknown`,ytextLength:t.document.getText(`source`).length},{startTime:r,duration:Math.max(0,i-r)})},editorProps:{attributes:{class:`pt-4 pb-4 h-full`},clipboardTextParser:(e,t,r,i)=>{let a=n.mdManager.parse(e);return i.state.schema.nodeFromJSON(a).content},clipboardTextSerializer:(e,t)=>n.text(e,t),clipboardSerializer:n.html.serializer,handlePaste:(e,t)=>n.paste(e,t),handleDrop:(e,t)=>n.drop(e,t)},extensions:bf(zT(e))}}function VT(e){let{provider:t,placeholder:n,clipboard:r,ctorStart:i}=e,a=Or(zT({provider:t,placeholder:n,clipboard:r,ctorStart:i})),{doc:o,mapping:s}=ht(t.document.getXmlFragment(`default`),a);return{...BT({provider:t,placeholder:n,clipboard:r,ctorStart:i,prebuiltMapping:s}),content:o.toJSON(),element:null}}var HT=e=>{let t=(0,$.c)(21),{provider:n,placeholder:r,isSourceMode:i,portalTarget:a}=e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(LT),c=Tw(),{principal:l,activeDocName:u}=ot(),d=n.configuration.name??``,[f]=(0,Q.useState)(RT),p;t[0]!==f||t[1]!==r||t[2]!==n?(p=()=>()=>({editor:new _n(VT({provider:n,placeholder:r,clipboard:f,ctorStart:performance.now()})),ydoc:n.document,ytext:n.document.getText(`source`),provider:n}),t[0]=f,t[1]=r,t[2]=n,t[3]=p):p=t[3];let[m]=(0,Q.useState)(p),h,g;if(t[4]!==m||t[5]!==d||t[6]!==n.document){let e={viewCount:0,bytes:n.document.getText(`source`).length},r=Mt(d)??crypto.randomUUID();h=Q.use,g=Et({docName:d,mountId:r,construct:m,sizeStats:e}),t[4]=m,t[5]=d,t[6]=n.document,t[7]=h,t[8]=g}else h=t[7],g=t[8];let _=h(g),v=_.editor,y,b;t[9]===_?(y=t[10],b=t[11]):(y=()=>()=>{ft(_)},b=[_],t[9]=_,t[10]=y,t[11]=b),(0,Q.useEffect)(y,b);let x;return t[12]!==u||t[13]!==d||t[14]!==v||t[15]!==c||t[16]!==i||t[17]!==a||t[18]!==l||t[19]!==n?(x=(0,Z.jsx)(UT,{provider:n,isSourceMode:i,docName:d,activeDocName:u,identity:c,principal:l,editor:v,wrapperRef:o,flashStateRef:s,portalTarget:a}),t[12]=u,t[13]=d,t[14]=v,t[15]=c,t[16]=i,t[17]=a,t[18]=l,t[19]=n,t[20]=x):x=t[20],x},UT=e=>{let t=(0,$.c)(78),{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),m,h;t[0]===d?(m=t[1],h=t[2]):(m=()=>{let e=f.current;if(e)return e.appendChild(d),()=>{d.parentNode===e&&e.removeChild(d)}},h=[d],t[0]=d,t[1]=m,t[2]=h),(0,Q.useLayoutEffect)(m,h);let g;t[3]!==c||t[4]!==n.configuration.name?(g=()=>(xt(c,n.configuration.name??null),()=>{xt(c,null)}),t[3]=c,t[4]=n.configuration.name,t[5]=g):g=t[5];let _;t[6]!==c||t[7]!==n?(_=[c,n],t[6]=c,t[7]=n,t[8]=_):_=t[8],(0,Q.useEffect)(g,_);let v;t[9]!==c||t[10]!==n.configuration.name?(v=()=>{let e=n.configuration.name;if(e)return kt(e,c),()=>y(e,c)},t[9]=c,t[10]=n.configuration.name,t[11]=v):v=t[11];let b;t[12]!==c||t[13]!==n?(b=[c,n],t[12]=c,t[13]=n,t[14]=b):b=t[14],(0,Q.useEffect)(v,b);let x;t[15]!==c||t[16]!==n.configuration.name?(x=()=>{},t[15]=c,t[16]=n.configuration.name,t[17]=x):x=t[17];let S;t[18]!==c||t[19]!==n?(S=[c,n],t[18]=c,t[19]=n,t[20]=S):S=t[20],(0,Q.useEffect)(x,S);let C,T;t[21]===c?(C=t[22],T=t[23]):(T=()=>{let e=WT,t=null,n=()=>{if(t||c.isDestroyed)return;let n=p(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 p(c)?n():c.on(`create`,n),()=>{c.off(`create`,n),r()}},C=[c],t[21]=c,t[22]=C,t[23]=T),(0,Q.useEffect)(T,C);let E,D;t[24]!==u||t[25]!==n.document||t[26]!==l?(E=()=>{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)},Wn)};c(LT);let f=()=>{if(bn(e),!Sn(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`?Sn(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)}},D=[n.document,u,l],t[24]=u,t[25]=n.document,t[26]=l,t[27]=E,t[28]=D):(E=t[27],D=t[28]),(0,Q.useEffect)(E,D);let O,k;t[29]===n?(O=t[30],k=t[31]):(O=()=>{let e=function(){let e=window.location.hash,t=e.indexOf(`?`);return t<0?null:new URLSearchParams(e.slice(t+1)).get(`anchor`)},t=0,r,i=null;function a(){if(!i)return;let e=document.getElementById(i)??document.querySelector(`[data-mirror-source-id="${CSS.escape(i)}"]`);e?(e.scrollIntoView({behavior:`smooth`,block:`start`}),i=null,t=0):t<20?(t+=1,r=window.setTimeout(a,100)):(i=null,t=0)}let o=function(){let n=e();n&&(i=n,t=0,r!==void 0&&(clearTimeout(r),r=void 0),a())};return o(),n.on(`synced`,a),window.addEventListener(`hashchange`,o),()=>{r!==void 0&&clearTimeout(r),n.off(`synced`,a),window.removeEventListener(`hashchange`,o)}},k=[n],t[29]=n,t[30]=O,t[31]=k),(0,Q.useEffect)(O,k);let A,j;t[32]===c?(A=t[33],j=t[34]):(A=()=>{let e=function(e){let t=e.detail;if(!t||t.mode!==`wysiwyg`||c.isDestroyed)return;let n=p(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(Ss,e),()=>window.removeEventListener(Ss,e)},j=[c],t[32]=c,t[33]=A,t[34]=j),(0,Q.useEffect)(A,j);let M;t[35]!==a||t[36]!==i||t[37]!==o||t[38]!==r||t[39]!==s||t[40]!==n.awareness?(M=()=>{let e=n.awareness;if(e){if(i!==a){e.setLocalState(null);return}e.setLocalState({user:Ew({principal:s,identity:o}),mode:r?`source`:`wysiwyg`})}},t[35]=a,t[36]=i,t[37]=o,t[38]=r,t[39]=s,t[40]=n.awareness,t[41]=M):M=t[41];let N;t[42]!==a||t[43]!==i||t[44]!==o||t[45]!==r||t[46]!==s||t[47]!==n?(N=[n,i,a,o,s,r],t[42]=a,t[43]=i,t[44]=o,t[45]=r,t[46]=s,t[47]=n,t[48]=N):N=t[48],(0,Q.useEffect)(M,N);let P,F;t[49]!==c||t[50]!==r?(P=()=>(w(c,r),()=>{w(c,!1)}),F=[c,r],t[49]=c,t[50]=r,t[51]=P,t[52]=F):(P=t[51],F=t[52]),(0,Q.useEffect)(P,F);let I;t[53]!==c||t[54]!==r?(I=!r&&(0,Z.jsx)(CT,{editor:c}),t[53]=c,t[54]=r,t[55]=I):I=t[55];let R;t[56]!==c||t[57]!==r?(R=!r&&(0,Z.jsx)(PT,{editor:c}),t[56]=c,t[57]=r,t[58]=R):R=t[58];let z;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(`div`,{ref:f,style:{display:`contents`}}),t[59]=z):z=t[59];let B;t[60]===c?B=t[61]:(B=(0,Z.jsx)(Fe,{editor:c,className:`tiptap-editor-portal-content h-full`}),t[60]=c,t[61]=B);let V;t[62]!==d||t[63]!==B?(V=(0,Hs.createPortal)(B,d),t[62]=d,t[63]=B,t[64]=V):V=t[64];let H;t[65]===c?H=t[66]:(H=(0,Z.jsx)(Cw,{editor:c}),t[65]=c,t[66]=H);let U;t[67]===c?U=t[68]:(U=L(c),t[67]=c,t[68]=U);let W;t[69]===U.store?W=t[70]:(W=(0,Z.jsx)(ie,{store:U.store}),t[69]=U.store,t[70]=W);let G;return t[71]!==I||t[72]!==R||t[73]!==V||t[74]!==H||t[75]!==W||t[76]!==l?(G=(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:[I,R,z,V,H,W]}),t[71]=I,t[72]=R,t[73]=V,t[74]=H,t[75]=W,t[76]=l,t[77]=G):G=t[77],G};function WT(){return Dt()}function GT(e){let t=(0,$.c)(2),{docName:n,provider:r,children:i}=e;(0,Q.use)(St(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 KT=`__back-nav__`;function qT(e){return e instanceof Pe||e instanceof ct||e instanceof Ae||e instanceof qe||e instanceof vt||e instanceof Ke?e.docName:null}function JT(e){return e instanceof Pe?{title:`Couldn't load document`,summary:`"${e.docName}" took too long. Check your connection.`}:e instanceof ct?{title:`Connection dropped`,summary:`Lost connection to "${e.docName}".`}:e instanceof Ae?{title:`Document not found`,summary:`"${e.docName}" doesn't exist.`}:e instanceof qe?{title:`Couldn't open document`,summary:`Something went wrong opening "${e.docName}".`}:e instanceof vt?{title:`Server can't open documents`,summary:`This project's running server doesn't support live editing. Restart Open Knowledge to fix.`}:e instanceof Ke?{title:`Cancelled`,summary:`You cancelled loading "${e.docName}".`}:{title:`Unknown error`,summary:e instanceof Error&&e.message?e.message:`An unexpected error occurred.`}}function YT(e){let t=(0,$.c)(27),{error:n,resetErrorBoundary:r,activeDocName:i,previousDocName:a,onNavigateBack:o}=e,s;t[0]===n?s=t[1]:(s=JT(n),t[0]=n,t[1]=s);let{title:c,summary:l}=s,u=!!a&&!!o,d=(0,Q.useRef)(null),f,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{d.current?.focus()},p=[],t[2]=f,t[3]=p):(f=t[2],p=t[3]),(0,Q.useEffect)(f,p);let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(SS,{size:80,variant:`sleeping`}),t[4]=m):m=t[4];let h;t[5]===c?h=t[6]:(h=(0,Z.jsx)(`h2`,{id:`document-error-title`,className:`text-2xl font-light tracking-tighter text-balance`,children:c}),t[5]=c,t[6]=h);let g;t[7]===l?g=t[8]:(g=(0,Z.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:l}),t[7]=l,t[8]=g);let _;t[9]!==h||t[10]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[h,g]}),t[9]=h,t[10]=g,t[11]=_):_=t[11];let v;t[12]===r?v=t[13]:(v=(0,Z.jsx)(Y,{ref:d,variant:`default`,onClick:r,children:`Try again`}),t[12]=r,t[13]=v);let y;t[14]!==i||t[15]!==u||t[16]!==n||t[17]!==o||t[18]!==a||t[19]!==r?(y=u?(0,Z.jsx)(Y,{variant:`ghost`,className:`font-mono uppercase`,onClick:()=>{!a||!o||(et(qT(n)??i),o(a),r(KT))},children:`Go back`}):null,t[14]=i,t[15]=u,t[16]=n,t[17]=o,t[18]=a,t[19]=r,t[20]=y):y=t[20];let b;t[21]!==v||t[22]!==y?(b=(0,Z.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[v,y]}),t[21]=v,t[22]=y,t[23]=b):b=t[23];let x;return t[24]!==b||t[25]!==_?(x=(0,Z.jsxs)(`div`,{role:`alert`,"aria-labelledby":`document-error-title`,"data-slot":`document-error-boundary`,className:`flex h-full flex-col items-center justify-center gap-8 p-8 text-center`,children:[m,_,b]}),t[24]=b,t[25]=_,t[26]=x):x=t[26],x}function XT(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)(YT,{...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]===KT){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}: ${JT(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)(O,{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 ZT(e){let t=e.document.getText(`source`).toString(),{map:n,parseError:r}=Qr(t);return{map:n,keys:Pr(t),parseError:r}}function QT(e){let t=(0,$.c)(167),{provider:n}=e,[r,i]=(0,Q.useState)(null),a;t[0]===n?a=t[1]:(a=()=>ZT(n),t[0]=n,t[1]=a);let[o,s]=(0,Q.useState)(a),c,l;t[2]===n?(c=t[3],l=t[4]):(c=()=>{let e=Br(n);i(e),s(e.current());let t=e.subscribe(e=>{s(e)});return()=>{t(),e.dispose(),i(t=>t===e?null:t)}},l=[n],t[2]=n,t[3]=c,t[4]=l),(0,Q.useEffect)(c,l);let u=o.map,d=o.keys,f=o.parseError,[p,m]=(0,Q.useState)(!1),h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h={},t[5]=h):h=t[5];let[g,_]=(0,Q.useState)(h),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),S;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(S={},t[6]=S):S=t[6];let[C,w]=(0,Q.useState)(S),T;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(T={},t[7]=T):T=t[7];let[E,D]=(0,Q.useState)(T),O=n.configuration.name??``,k;t[8]===O?k=t[9]:(k=nE(O),t[8]=O,t[9]=k);let A=k,j;t[10]===O?j=t[11]:(j=eE(O),t[10]=O,t[11]=j);let M=Aa(A?null:j),N;t[12]!==M||t[13]!==A?(N=!A&&M.state.status===`ready`?M.state.data.folder.frontmatter_defaults??{}:{},t[12]=M,t[13]=A,t[14]=N):N=t[14];let P=N,F;t[15]!==M||t[16]!==A?(F=!A&&M.state.status===`ready`?M.state.data.frontmatterSources:{},t[15]=M,t[16]=A,t[17]=F):F=t[17];let I=F,L;t[18]===r?L=t[19]:(L=function(e){if(!r)return{ok:!1,error:`Connecting`};let t=r.patch(e);if(t.ok)return{ok:!0};if(t.error.code===`WRITE_ERROR`)return console.warn(`[PropertyPanel] binding write error:`,t.error.detail),{ok:!1,error:t.error.detail};let n=Ar(t.error);return{ok:!1,error:t.error.issues[0]?.message??`Invalid patch payload`,fieldErrors:Object.keys(n).length>0?n:void 0}},t[18]=r,t[19]=L);let R=L,z;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(z=function(e){w(t=>{if(!Object.hasOwn(t,e))return t;let n={...t};return delete n[e],n})},t[20]=z):z=t[20];let B=z,V;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(V=function(e,t){if(e.ok)return;let n=e.error??`Failed to update property`,r=e.fieldErrors??{};w(e=>{let i={...e};for(let e of t)i[e]=r[e]??n;return i}),D(e=>{let n={...e};for(let e of t)n[e]=(n[e]??0)+1;return n})},t[21]=V):V=t[21];let H=V,U;t[22]===R?U=t[23]:(U=function(e,t){B(e),H(R({[e]:t}),[e])},t[22]=R,t[23]=U);let W=U,G;t[24]===R?G=t[25]:(G=function(e){B(e),H(R({[e]:null}),[e])},t[24]=R,t[25]=G);let K=G,q;t[26]===r?q=t[27]:(q=function(e,t){if(!r)return{ok:!1,error:`Connecting`};if(e===t)return{ok:!0};let n=r.rename(e,t);if(n.ok)return{ok:!0};if(n.error.code===`WRITE_ERROR`)return{ok:!1,error:n.error.detail};let i=Ar(n.error);return{ok:!1,error:n.error.issues[0]?.message??`Failed to rename`,fieldErrors:Object.keys(i).length>0?i:void 0}},t[26]=r,t[27]=q);let ee=q,te;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(te=function(e,t){return`${e} ${t}`},t[28]=te):te=t[28];let ne=te,re;t[29]!==r||t[30]!==d?(re=function(e){if(!r)return;let t=String(e.active.id),n=e.over?String(e.over.id):null;if(!n||t===n)return;let i=d.map((e,t)=>ne(e,t)),a=i.indexOf(t),o=i.indexOf(n);if(a<0||o<0)return;let s=d.slice(),[c]=s.splice(a,1);if(!c)return;s.splice(o,0,c);let l=r.reorder(s);l.ok||console.warn(`[PropertyPanel] reorder failed:`,l.error)},t[29]=r,t[30]=d,t[31]=re):re=t[31];let ie=re,ae;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(ae={activationConstraint:{distance:4}},t[32]=ae):ae=t[32];let oe;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(oe={coordinateGetter:Ra},t[33]=oe):oe=t[33];let se=po(fa(ea,ae),fa(Xi,oe)),le;t[34]!==P||t[35]!==W||t[36]!==u?(le=function(e,t){let n=u[e]??rE(P[e]);if(n===void 0)return;_(n=>({...n,[e]:t}));let r=Ji(n,t);(!Object.hasOwn(u,e)||!$T(n,r))&&W(e,r)},t[34]=P,t[35]=W,t[36]=u,t[37]=le):le=t[37];let J=le,ue;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(ue=function(){y({name:``,type:`text`,value:``,error:null}),m(!1)},t[38]=ue):ue=t[38];let de=ue,{addPropertySignal:fe,clearAddProperty:pe}=hC(),me;t[39]!==fe||t[40]!==O?(me=fe.get(O)??0,t[39]=fe,t[40]=O,t[41]=me):me=t[41];let he=me,ge,_e;t[42]===he?(ge=t[43],_e=t[44]):(ge=()=>{he>0&&(y({name:``,type:`text`,value:``,error:null}),m(!1))},_e=[he],t[42]=he,t[43]=ge,t[44]=_e),(0,Q.useEffect)(ge,_e);let ve,ye;t[45]!==pe||t[46]!==O?(ve=()=>()=>pe(O),ye=[O,pe],t[45]=pe,t[46]=O,t[47]=ve,t[48]=ye):(ve=t[47],ye=t[48]),(0,Q.useEffect)(ve,ye);let be;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(be=function(e){y(t=>{if(!t)return t;let n=e===`date`?new Date().toISOString().slice(0,10):ha[e];return{...t,type:e,value:n,error:null}})},t[49]=be):be=t[49];let xe=be,Se;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(Se=function(e){y(t=>t&&{...t,value:e})},t[50]=Se):Se=t[50];let Ce=Se,we;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(we=function(e){y(t=>t&&{...t,name:e,error:null})},t[51]=we):we=t[51];let Te=we,Ee;t[52]!==v||t[53]!==R||t[54]!==u?(Ee=function(){if(!v)return;let e=v.name.trim();if(!e){y({...v,error:`Name is required`});return}if(e===`frontmatter`){y({...v,error:`"frontmatter" is a reserved property name`});return}if(Object.hasOwn(u,e)){y({...v,error:`Property "${e}" already exists`});return}let t=R({[e]:v.value});if(t.ok){y(null);return}let n=t.fieldErrors?.[e],r=t.error??`Failed to add property`;y({...v,error:n??r})},t[52]=v,t[53]=R,t[54]=u,t[55]=Ee):Ee=t[55];let De=Ee,Oe;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=function(){y(null)},t[56]=Oe):Oe=t[56];let ke=Oe,Ae;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=function(e){x({key:e,draft:e,error:null})},t[57]=Ae):Ae=t[57];let je=Ae,Me;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(Me=function(e){x(t=>t&&{...t,draft:e,error:null})},t[58]=Me):Me=t[58];let Ne=Me,Pe;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=function(){x(null)},t[59]=Pe):Pe=t[59];let Fe=Pe,Ie;t[60]!==u||t[61]!==ee||t[62]!==b?(Ie=function(){if(!b)return;let e=b.draft.trim();if(!e){x(null);return}if(e===b.key){x(null);return}if(e===`frontmatter`){x({...b,error:`"frontmatter" is a reserved property name`});return}if(Object.hasOwn(u,e)){x({...b,error:`Property "${e}" already exists`});return}let t=ee(b.key,e);if(t.ok){_(t=>{if(!Object.hasOwn(t,b.key))return t;let n={...t};return n[e]=n[b.key],delete n[b.key],n}),B(b.key),x(null);return}let n=t.fieldErrors?.[e]??t.fieldErrors?.[b.key]??t.error??`Failed to rename property`;x({...b,error:n})},t[60]=u,t[61]=ee,t[62]=b,t[63]=Ie):Ie=t[63];let Le=Ie,Re;t[64]!==u||t[65]!==d?(Re=d.length>0?d:Object.keys(u),t[64]=u,t[65]=d,t[66]=Re):Re=t[66];let ze=Re,Be;if(t[67]!==ze){Be=new Map;for(let e of ze)Be.set(e,(Be.get(e)??0)+1);t[67]=ze,t[68]=Be}else Be=t[68];let Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe;if(t[69]!==v||t[70]!==P||t[71]!==I||t[72]!==p||t[73]!==W||t[74]!==Le||t[75]!==Be||t[76]!==C||t[77]!==ie||t[78]!==u||t[79]!==g||t[80]!==f||t[81]!==K||t[82]!==b||t[83]!==ze||t[84]!==E||t[85]!==se||t[86]!==J){Qe=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Object.keys(P).filter(e=>!Object.hasOwn(u,e)).sort();if(ze.length===0&&e.length===0&&!v&&!f){Qe=null;break bb0}Xe=`property-panel editor-content-aligned pt-4 pb-4 text-sm`,Ze=`property-panel`,He=Lo,qe=!p,t[99]===Symbol.for(`react.memo_cache_sentinel`)?(Je=e=>m(!e),t[99]=Je):Je=t[99];let n=!p,r;t[100]===n?r=t[101]:(r=(0,Z.jsx)(No,{"data-expanded":n,className:`size-3.5 shrink-0 text-muted-foreground transition-transform duration-150 ease-out data-[expanded=true]:rotate-90`}),t[100]=n,t[101]=r);let i;t[102]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`span`,{children:`Properties`}),t[102]=i):i=t[102],t[103]===r?Ye=t[104]:(Ye=(0,Z.jsx)(Io,{asChild:!0,children:(0,Z.jsxs)(Y,{type:`button`,variant:`ghost`,className:`mb-1.5 flex h-auto w-fit bg-transparent! items-center gap-1 px-1 py-0.5 text-base font-medium text-foreground hover:bg-transparent hover:text-foreground`,children:[r,i]})}),t[103]=r,t[104]=Ye),Ve=Fo,Ue=`overflow-hidden data-[state=open]:animate-[collapsible-down_150ms_ease-out] data-[state=closed]:animate-[collapsible-up_150ms_ease-in]`,t[105]===f?We=t[106]:(We=f?(0,Z.jsxs)(`div`,{role:`alert`,"data-testid":`property-panel-yaml-error`,className:`mb-1 flex items-start gap-1.5 rounded border border-destructive/30 bg-destructive/5 px-2 py-1.5 text-[11px] text-destructive`,children:[(0,Z.jsx)(dr,{className:`size-3.5 shrink-0 mt-0.5`}),(0,Z.jsxs)(`div`,{children:[`Frontmatter YAML is malformed; fix in source mode to recover.`,(0,Z.jsx)(`span`,{className:`block text-[10px] opacity-80`,children:f})]})]}):null,t[105]=f,t[106]=We);let a;if(t[107]!==ze){let e;t[109]===Symbol.for(`react.memo_cache_sentinel`)?(e=(e,t)=>ne(e,t),t[109]=e):e=t[109],a=ze.map(e),t[107]=ze,t[108]=a}else a=t[108];let o;if(t[110]!==W||t[111]!==Le||t[112]!==Be||t[113]!==C||t[114]!==u||t[115]!==g||t[116]!==K||t[117]!==b||t[118]!==ze||t[119]!==E||t[120]!==J){let e;t[122]!==W||t[123]!==Le||t[124]!==Be||t[125]!==C||t[126]!==u||t[127]!==g||t[128]!==K||t[129]!==b||t[130]!==E||t[131]!==J?(e=(e,t)=>{let n=u[e];if(n===void 0)return null;let r=g[e]??tr(n),i=b?.key===e?b:null,a=(Be.get(e)??0)>1;return(0,Z.jsx)(Wi,{sortableId:ne(e,t),keyName:e,value:n,declared:r,error:C[e]??null,resetCounter:E[e]??0,isDuplicate:a,rename:{state:i,onBegin:()=>je(e),onChangeDraft:Ne,onCommit:Le,onCancel:Fe},onCommit:t=>W(e,t),onChangeType:t=>J(e,t),onRemove:()=>K(e)},`${e}-${t}`)},t[122]=W,t[123]=Le,t[124]=Be,t[125]=C,t[126]=u,t[127]=g,t[128]=K,t[129]=b,t[130]=E,t[131]=J,t[132]=e):e=t[132],o=ze.map(e),t[110]=W,t[111]=Le,t[112]=Be,t[113]=C,t[114]=u,t[115]=g,t[116]=K,t[117]=b,t[118]=ze,t[119]=E,t[120]=J,t[121]=o}else o=t[121];let s;t[133]!==a||t[134]!==o?(s=(0,Z.jsx)(sa,{items:a,strategy:aa,children:o}),t[133]=a,t[134]=o,t[135]=s):s=t[135],t[136]!==ie||t[137]!==se||t[138]!==s?(Ge=(0,Z.jsx)(la,{sensors:se,collisionDetection:ra,onDragEnd:ie,children:s}),t[136]=ie,t[137]=se,t[138]=s,t[139]=Ge):Ge=t[139];let c;t[140]!==P||t[141]!==I||t[142]!==W||t[143]!==C||t[144]!==E||t[145]!==J?(c=e=>{let t=P[e],n=rE(t),r=tr(n),i=I[e]??``;return(0,Z.jsx)(Wi,{keyName:e,value:n,declared:r,error:C[e]??null,resetCounter:E[e]??0,isInherited:!0,badge:(0,Z.jsx)(oo,{source:i}),onCommit:t=>W(e,t),onChangeType:t=>J(e,t)},`inherited-${e}`)},t[140]=P,t[141]=I,t[142]=W,t[143]=C,t[144]=E,t[145]=J,t[146]=c):c=t[146],Ke=e.map(c)}t[69]=v,t[70]=P,t[71]=I,t[72]=p,t[73]=W,t[74]=Le,t[75]=Be,t[76]=C,t[77]=ie,t[78]=u,t[79]=g,t[80]=f,t[81]=K,t[82]=b,t[83]=ze,t[84]=E,t[85]=se,t[86]=J,t[87]=Ve,t[88]=He,t[89]=Ue,t[90]=We,t[91]=Ge,t[92]=Ke,t[93]=qe,t[94]=Je,t[95]=Ye,t[96]=Xe,t[97]=Ze,t[98]=Qe}else Ve=t[87],He=t[88],Ue=t[89],We=t[90],Ge=t[91],Ke=t[92],qe=t[93],Je=t[94],Ye=t[95],Xe=t[96],Ze=t[97],Qe=t[98];if(Qe!==Symbol.for(`react.early_return_sentinel`))return Qe;let $e;t[147]!==v||t[148]!==De?($e=v?(0,Z.jsx)(pa,{draft:v,onChangeName:Te,onChangeType:xe,onChangeValue:Ce,onCommit:De,onCancel:ke}):(0,Z.jsxs)(`div`,{className:`mt-1 flex items-center gap-1`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-7 w-4 shrink-0`}),(0,Z.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`add-property-trigger`,onClick:de,"aria-label":`Add property`,className:`flex items-center gap-1.5 rounded px-2 py-1 font-medium text-sm hover:bg-muted/50 hover:text-foreground`,children:[(0,Z.jsx)(ce,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:`Add`})]})]}),t[147]=v,t[148]=De,t[149]=$e):$e=t[149];let et;t[150]!==Ve||t[151]!==Ue||t[152]!==We||t[153]!==Ge||t[154]!==Ke||t[155]!==$e?(et=(0,Z.jsxs)(Ve,{className:Ue,children:[We,Ge,Ke,$e]}),t[150]=Ve,t[151]=Ue,t[152]=We,t[153]=Ge,t[154]=Ke,t[155]=$e,t[156]=et):et=t[156];let tt;t[157]!==He||t[158]!==qe||t[159]!==Je||t[160]!==Ye||t[161]!==et?(tt=(0,Z.jsxs)(He,{open:qe,onOpenChange:Je,children:[Ye,et]}),t[157]=He,t[158]=qe,t[159]=Je,t[160]=Ye,t[161]=et,t[162]=tt):tt=t[162];let nt;return t[163]!==Xe||t[164]!==Ze||t[165]!==tt?(nt=(0,Z.jsx)(`div`,{className:Xe,"data-testid":Ze,children:tt}),t[163]=Xe,t[164]=Ze,t[165]=tt,t[166]=nt):nt=t[166],nt}function $T(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length?e.every((e,n)=>e===t[n]):!1:e===t}function eE(e){if(!e)return``;let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}var tE=/(^|\/)\.ok\/templates\//;function nE(e){return tE.test(e)}function rE(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`?e:Array.isArray(e)?e.map(e=>typeof e==`string`?e:JSON.stringify(e)):e==null?``:JSON.stringify(e)}var iE=it(`LARGE_DOC_CHAR_THRESHOLD`,5e5);function aE(e){let t=e.threshold??iE;return e.ytextLength>t?{renderSource:e.isSourceMode||e.visitedSource,renderVisual:!e.isSourceMode||e.visitedVisual,isLarge:!0}:{renderSource:!0,renderVisual:!0,isLarge:!1}}function oE(e){return e.hasEmittedFirstToggle||!e.isLarge?!1:e.renderSource&&e.renderVisual}var sE=it(`ACTIVITY_MOUNT_LIMIT`,3);function cE(){return n(()=>import(`./SourceEditor-BCHJFeGa.js`),__vite__mapDeps([44,1,33,2,34,35,20,36,37,38,39,19,3,6,7,4,10,9,40,45,22]),import.meta.url)}var lE=(0,Q.lazy)(async()=>({default:(await cE()).SourceEditor}));function uE(e,t,n){if(n<=0)return[];let r=e.filter(e=>!Be(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 dE(e,t){return t.kind===`idle`?null:t.kind===`failed`&&t.failedDocNames.includes(e)?{kind:`failed`,title:`Couldn't reconnect after server restart`,summary:t.reason===`clear-data-timeout`?`Local collaboration data for "${e}" could not be cleared in time. Reload to retry.`:`Local collaboration data for "${e}" could not be cleared. Reload to retry.`,actionLabel:`Reload`}:t.kind===`recovering`&&t.docNames.includes(e)?{kind:`recovering`,title:`Reconnecting after server restart`,summary:t.phase===`clearing-local-cache`?`Clearing local collaboration data for "${e}" before reconnecting.`:`Reopening "${e}" with a fresh local collaboration cache.`}:null}function fE(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(Ve,{name:`activity-pool`,children:(0,Z.jsx)(pE,{...e})}),t[0]=e,t[1]=n),n}function pE(e){let t=(0,$.c)(15),{activeDocName:n,isSourceMode:r,editorPlaceholder:i,previousDocName:a,onNavigateBack:o,onRecycle:s}=e,{poolEntries:c,serverRestartRecovery:l}=ot(),{pages:u,loading:d}=qr(),f=uE(c,n,sE),p=(0,Q.useRef)(``),m=f.map(mE).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)Ne(e);for(let e of i){let t=h.current.find(t=>t.docName===e)?.poolEventId;le(e,t&&t.length>0?t:crypto.randomUUID())}dt(`ok/activity/mount-list-change`,{active:n,mounted:t,evicted:r}),p.current=m,at(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)(yE,{entry:e,isActive:e.docName===n,isSourceMode:r,editorPlaceholder:i,isNewDoc:!d&&!u.has(e.docName),previousDocName:a,onNavigateBack:o,onRecycle:s,serverRestartRecovery:l},e.docName),t[3]=n,t[4]=i,t[5]=r,t[6]=d,t[7]=o,t[8]=s,t[9]=u,t[10]=a,t[11]=l,t[12]=v):v=t[12];let y=f.map(v),b;return t[13]===y?b=t[14]:(b=(0,Z.jsx)(Z.Fragment,{children:y}),t[13]=y,t[14]=b),b}function mE(e){return e.docName}function hE(e){let t=(0,$.c)(8),{isActive:n,children:r}=e,i=(0,Q.useRef)(null),a=(0,Q.useRef)(0),o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{let e=i.current;if(!e)return;let t=()=>{e.scrollTop>0&&(a.current=e.scrollTop)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},s=[],t[0]=o,t[1]=s):(o=t[0],s=t[1]),(0,Q.useEffect)(o,s);let c,l;t[2]===n?(c=t[3],l=t[4]):(c=()=>{if(!n)return;let e=i.current;if(!e)return;let t=a.current;if(t===0||(e.scrollTop=t,e.scrollTop===t))return;let r=!1,o=()=>{r||(r=!0,s.disconnect(),clearTimeout(c))},s=new ResizeObserver(()=>{r||!e||e.scrollHeight>t&&(e.scrollTop=t,e.scrollTop===t&&o())});s.observe(e);let c=setTimeout(o,500);return o},l=[n],t[2]=n,t[3]=c,t[4]=l),(0,Q.useLayoutEffect)(c,l);let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u={overflowAnchor:`auto`},t[5]=u):u=t[5];let d;return t[6]===r?d=t[7]:(d=(0,Z.jsx)(`div`,{ref:i,"data-testid":`editor-scroll-container`,className:`subtle-scrollbar h-full overflow-y-auto pt-14 scroll-pt-14`,style:u,children:r}),t[6]=r,t[7]=d),d}function gE(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)(zx,{}),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)(lE,{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 _E(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)(Pc,{className:`size-5`,"aria-hidden":`true`}):(0,Z.jsx)(ue,{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)(Y,{type:`button`,onClick:vE,children:[(0,Z.jsx)(Pc,{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 vE(){return window.location.reload()}function yE(e){let t=(0,$.c)(48),{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a,isNewDoc:o,previousDocName:s,onNavigateBack:c,onRecycle:l,serverRestartRecovery:u}=e,d;t[0]!==n.docName||t[1]!==u?(d=dE(n.docName,u),t[0]=n.docName,t[1]=u,t[2]=d):d=t[2];let f=d,p;t[3]===n.docName?p=t[4]:(p=()=>{let e=document.createElement(`div`);return e.setAttribute(`data-ok-editor-portal`,n.docName),e.style.display=`contents`,e},t[3]=n.docName,t[4]=p);let[m]=(0,Q.useState)(p),h=n.provider.document.getText(`source`).length,[g,_]=(0,Q.useState)(i),[v,y]=(0,Q.useState)(!i),b,x;t[5]!==i||t[6]!==g||t[7]!==v?(b=()=>{i&&!g?_(!0):!i&&!v&&y(!0)},x=[i,g,v],t[5]=i,t[6]=g,t[7]=v,t[8]=b,t[9]=x):(b=t[8],x=t[9]),(0,Q.useEffect)(b,x);let S=aE({ytextLength:h,isSourceMode:i,visitedSource:g,visitedVisual:v}),C=(0,Q.useRef)(``),w=`${S.isLarge}-${S.renderSource}-${S.renderVisual}`,T,E;t[10]!==n.docName||t[11]!==S.isLarge||t[12]!==S.renderSource||t[13]!==S.renderVisual||t[14]!==w||t[15]!==i||t[16]!==h?(T=()=>{C.current!==w&&(C.current=w,S.isLarge&&dt(`ok/activity/defer-mount`,{docName:n.docName,ytextLength:h,isSourceMode:i,renderSource:S.renderSource,renderVisual:S.renderVisual}))},E=[w,S.isLarge,S.renderSource,S.renderVisual,n.docName,h,i],t[10]=n.docName,t[11]=S.isLarge,t[12]=S.renderSource,t[13]=S.renderVisual,t[14]=w,t[15]=i,t[16]=h,t[17]=T,t[18]=E):(T=t[17],E=t[18]),(0,Q.useEffect)(T,E);let[D,O]=(0,Q.useState)(!1),k,A;t[19]!==n.docName||t[20]!==S.isLarge||t[21]!==S.renderSource||t[22]!==S.renderVisual||t[23]!==D||t[24]!==i||t[25]!==h?(k=()=>{oE({isLarge:S.isLarge,renderSource:S.renderSource,renderVisual:S.renderVisual,hasEmittedFirstToggle:D})&&(dt(`ok/cold/first-toggle`,{docName:n.docName,mountId:Mt(n.docName),ytextLength:h,modeEnteredFirst:i?`source`:`visual`}),O(!0))},A=[D,S.isLarge,S.renderSource,S.renderVisual,n.docName,h,i],t[19]=n.docName,t[20]=S.isLarge,t[21]=S.renderSource,t[22]=S.renderVisual,t[23]=D,t[24]=i,t[25]=h,t[26]=k,t[27]=A):(k=t[26],A=t[27]),(0,Q.useEffect)(k,A);let j=r?`visible`:`hidden`,M=`editor:${n.docName}`,N;t[28]!==a||t[29]!==n||t[30]!==S.renderSource||t[31]!==S.renderVisual||t[32]!==r||t[33]!==o||t[34]!==i||t[35]!==c||t[36]!==l||t[37]!==m||t[38]!==s||t[39]!==f?(N=f?(0,Z.jsx)(_E,{view:f}):(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(XT,{activeDocName:n.docName,previousDocName:s,onNavigateBack:c,onRecycle:l,children:(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(zx,{}),children:(0,Z.jsx)(GT,{docName:n.docName,provider:n.provider,children:(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[!i&&(0,Z.jsx)(QT,{provider:n.provider}),(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[S.renderSource?(0,Z.jsx)(`div`,{className:i?`h-full`:`ok-mode-hidden h-full`,children:(0,Z.jsx)(gE,{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a})}):null,S.renderVisual?(0,Z.jsx)(`div`,{className:i?`ok-mode-hidden h-full`:`h-full`,children:(0,Z.jsx)(HT,{provider:n.provider,placeholder:a,isSourceMode:i,portalTarget:m},`${n.docName}-${String(o)}`)}):null]})]})})})})}),t[28]=a,t[29]=n,t[30]=S.renderSource,t[31]=S.renderVisual,t[32]=r,t[33]=o,t[34]=i,t[35]=c,t[36]=l,t[37]=m,t[38]=s,t[39]=f,t[40]=N):N=t[40];let P;t[41]!==r||t[42]!==N?(P=(0,Z.jsx)(hE,{isActive:r,children:N}),t[41]=r,t[42]=N,t[43]=P):P=t[43];let F;return t[44]!==M||t[45]!==P||t[46]!==j?(F=(0,Z.jsx)(Q.Activity,{mode:j,name:M,children:P}),t[44]=M,t[45]=P,t[46]=j,t[47]=F):F=t[47],F}function bE(e){let t=(0,$.c)(27),{stats:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-full h-2 bg-linear-to-t from-background to-transparent`}),t[0]=r):r=t[0];let i;t[1]===n.words?i=t[2]:(i=n.words.toLocaleString(),t[1]=n.words,t[2]=i);let a;t[3]===i?a=t[4]:(a=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:i}),t[3]=i,t[4]=a);let o=n.words===1?`word`:`words`,s;t[5]!==a||t[6]!==o?(s=(0,Z.jsxs)(`span`,{children:[a,` `,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7];let c;t[8]===n.chars?c=t[9]:(c=n.chars.toLocaleString(),t[8]=n.chars,t[9]=c);let l;t[10]===c?l=t[11]:(l=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:c}),t[10]=c,t[11]=l);let u=n.chars===1?`char`:`chars`,d;t[12]!==l||t[13]!==u?(d=(0,Z.jsxs)(`span`,{children:[l,` `,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f=n.tokens>0?`~`:``,p;t[15]===n.tokens?p=t[16]:(p=n.tokens.toLocaleString(),t[15]=n.tokens,t[16]=p);let m;t[17]===p?m=t[18]:(m=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:p}),t[17]=p,t[18]=m);let h=n.tokens===1?`token`:`tokens`,g;t[19]!==f||t[20]!==m||t[21]!==h?(g=(0,Z.jsxs)(`span`,{children:[f,m,` `,h]}),t[19]=f,t[20]=m,t[21]=h,t[22]=g):g=t[22];let _;return t[23]!==g||t[24]!==s||t[25]!==d?(_=(0,Z.jsxs)(`section`,{"aria-label":`Document statistics`,className:`relative flex h-6 shrink-0 items-center justify-end gap-3 bg-background px-3 text-2xs text-muted-foreground`,children:[r,s,d,g]}),t[23]=g,t[24]=s,t[25]=d,t[26]=_):_=t[26],_}function xE(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=mi(n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`nav`,{"aria-label":`breadcrumb`,"data-slot":`breadcrumb`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function SE(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=mi(`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 CE(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=mi(`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 wE(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=mi(`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 TE(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=mi(`[&>svg]:size-3.5`,r),t[4]=r,t[5]=a);let o;t[6]===n?o=t[7]:(o=n??(0,Z.jsx)(No,{}),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}function EE(e){let t=(0,$.c)(18),{docName:n,className:r}=e;if(!n)return null;let i,a,o,s,c,l;if(t[0]!==r||t[1]!==n){l=Symbol.for(`react.early_return_sentinel`);bb0:{let{prefix:e}=wt(n,``);if(!e){l=null;break bb0}let u=e.replace(/\/$/,``).split(`/`).filter(Boolean);if(u.length===0){l=null;break bb0}a=xE,t[8]===r?c=t[9]:(c=mi(`flex min-w-0 items-center`,r),t[8]=r,t[9]=c),i=SE,o=`flex-nowrap gap-1 text-muted-foreground/70 text-xs`,s=u.map((e,t)=>{let n=u.slice(0,t+1).join(`/`);return(0,Z.jsxs)(Q.Fragment,{children:[t>0&&(0,Z.jsx)(TE,{className:`text-muted-foreground/70 [&>svg]:size-3`}),(0,Z.jsx)(CE,{className:`min-w-0`,children:(0,Z.jsx)(wE,{current:!1,className:`min-w-0 truncate font-normal text-muted-foreground/70`,title:e,children:e})})]},n)})}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}var DE={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`},OE=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`,...DE,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},kE=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)(OE,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},AE=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)(OE,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i};function jE(e){let t=(0,$.c)(42),{activeDocName:n,isSourceMode:r,sourceDisabled:i,onModeChange:a,showAddPropertyButton:o,onAddProperty:s,isPanelCollapsed:c,onTogglePanel:l}=e,u;t[0]===n?u=t[1]:(u=(0,Z.jsx)(`div`,{className:`pointer-events-auto flex min-w-0 items-end self-end`,children:(0,Z.jsx)(EE,{docName:n})}),t[0]=n,t[1]=u);let d=r?`source`:`wysiwyg`,f;t[2]===a?f=t[3]:(f=e=>{e&&a(e)},t[2]=a,t[3]=f);let p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(Vo,{value:`wysiwyg`,"aria-label":`Visual editor`,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,asChild:!0,children:(0,Z.jsx)(kr,{children:(0,Z.jsx)(AE,{className:`size-4`})})}),(0,Z.jsx)(vn,{side:`bottom`,children:`Visual`})]}),t[4]=p):p=t[4];let m;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(kE,{className:`size-4`}),t[5]=m):m=t[5];let h;t[6]===i?h=t[7]:(h=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(`div`,{children:(0,Z.jsx)(Vo,{value:`source`,"aria-label":`Markdown source`,disabled:i,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,children:m})})}),t[6]=i,t[7]=h);let g=i?`Source mode requires a live connection — your edits are saved and will appear when you reconnect.`:`Markdown`,_;t[8]===g?_=t[9]:(_=(0,Z.jsx)(vn,{side:`bottom`,children:g}),t[8]=g,t[9]=_);let v;t[10]!==h||t[11]!==_?(v=(0,Z.jsxs)(yn,{children:[h,_]}),t[10]=h,t[11]=_,t[12]=v):v=t[12];let y;t[13]!==d||t[14]!==f||t[15]!==v?(y=(0,Z.jsx)(`div`,{className:`pointer-events-auto flex justify-center`,children:(0,Z.jsxs)(Wo,{type:`single`,value:d,onValueChange:f,"aria-label":`Editor mode`,variant:`segmented`,size:`sm`,spacing:1,className:`shrink-0 data-[size=sm]:rounded-[10px] bg-muted p-0.5`,children:[p,v]})}),t[13]=d,t[14]=f,t[15]=v,t[16]=y):y=t[16];let b;t[17]!==s||t[18]!==o?(b=o&&(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(Y,{variant:`ghost`,size:`icon`,"aria-label":`Add properties`,onClick:s,"data-testid":`add-properties-button`,asChild:!0,children:(0,Z.jsx)(kr,{children:(0,Z.jsx)(bc,{})})}),(0,Z.jsx)(vn,{side:`bottom`,children:`Add properties`})]}),t[17]=s,t[18]=o,t[19]=b):b=t[19];let x=!c,S=c?`Show panel`:`Hide panel`,C;t[20]===c?C=t[21]:(C=(0,Z.jsx)(kr,{children:c?(0,Z.jsx)(Oc,{}):(0,Z.jsx)(Dc,{})}),t[20]=c,t[21]=C);let w;t[22]!==l||t[23]!==x||t[24]!==S||t[25]!==C?(w=(0,Z.jsx)(Y,{variant:`ghost`,size:`icon`,onClick:l,"aria-expanded":x,"aria-label":S,asChild:!0,children:C}),t[22]=l,t[23]=x,t[24]=S,t[25]=C,t[26]=w):w=t[26];let T=c?`Show panel`:`Hide panel`,E;t[27]===T?E=t[28]:(E=(0,Z.jsx)(vn,{side:`bottom`,children:T}),t[27]=T,t[28]=E);let D;t[29]!==w||t[30]!==E?(D=(0,Z.jsxs)(yn,{children:[w,E]}),t[29]=w,t[30]=E,t[31]=D):D=t[31];let O;t[32]!==b||t[33]!==D?(O=(0,Z.jsxs)(`div`,{className:`pointer-events-auto flex items-center justify-end gap-1`,children:[b,D]}),t[32]=b,t[33]=D,t[34]=O):O=t[34];let k;t[35]!==u||t[36]!==y||t[37]!==O?(k=(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:[u,y,O]})}),t[35]=u,t[36]=y,t[37]=O,t[38]=k):k=t[38];let A;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none h-2 bg-linear-to-b from-background to-transparent`}),t[39]=A):A=t[39];let j;return t[40]===k?j=t[41]:(j=(0,Z.jsxs)(`div`,{"data-testid":`editor-toolbar`,className:`pointer-events-none absolute inset-x-0 top-0 z-10`,children:[k,A]}),t[40]=k,t[41]=j),j}function ME(e){let{activeDocName:t,deferredActiveDocName:n,mountResolved:r,syncResolved:i}=e;return t===null||t===n?!1:!(r&&i)}var NE=(0,Q.lazy)(async()=>({default:(await n(()=>import(`./ActivityModeContent-B8J4OFHO.js`),__vite__mapDeps([32,1,2,33,34,35,20,36,37,38,39,19,3,6,7,4,10,9,40,41]),import.meta.url)).ActivityModeContent}));function PE(e){let t=(0,$.c)(5),n;t[0]===e?n=t[1]:(n=(0,Z.jsx)(IE,{...e}),t[0]=e,t[1]=n);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(FE,{}),t[2]=r):r=t[2];let i;return t[3]===n?i=t[4]:(i=(0,Z.jsx)(Ve,{name:`editor-area`,children:(0,Z.jsxs)(pC,{children:[n,r]})}),t[3]=n,t[4]=i),i}function FE(){let e=(0,$.c)(5),t=Em(),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)(CC,{open:t.open,onOpenChange:n}),e[2]=t.open,e[3]=n,e[4]=r):r=e[4],r}function IE(e){let t=(0,$.c)(104),{editorMode:n,onModeChange:r,activeTab:i,onActiveTabChange:a}=e,{activeDocName:o,activeProvider:s,activeTarget:c,recycleDocument:l,docPanelMode:u,docPanelAgentId:d,docPanelExpandSignal:f}=ot(),{openDocumentTransition:p}=gt(),{requestAddProperty:m}=hC(),h=gw(s,o),g=_w(s),_=g===`connected`||g===`synced`,v=(0,Q.useDeferredValue)(o),y=c?.kind===`missing`,b=!!o&&c?.kind!==`folder`,x=y?`Start writing to create this page`:void 0,S=Ex(),[C,w]=(0,Q.useState)(!1),{layout:T,autoCollapse:E}=ew(),D=T===`sheet`,[O,k]=(0,Q.useState)(!1),A=(0,Q.useRef)(!1),j,M;t[0]!==E||t[1]!==T||t[2]!==S?(j=()=>{if(T!==`panel`)return;let e=requestAnimationFrame(()=>{E?(A.current=!1,S.current?.collapse()):A.current||S.current?.expand()});return()=>cancelAnimationFrame(e)},M=[E,T,S],t[0]=E,t[1]=T,t[2]=S,t[3]=j,t[4]=M):(j=t[3],M=t[4]),(0,Q.useEffect)(j,M);let N,P;t[5]!==D||t[6]!==a||t[7]!==S?(N=()=>{let e=e=>{a(e),D?k(!0):(A.current=!1,S.current?.expand())},t=kp();return t&&e(t),jp(t=>{kp(),e(t)})},P=[D,a,S],t[5]=D,t[6]=a,t[7]=S,t[8]=N,t[9]=P):(N=t[8],P=t[9]),(0,Q.useEffect)(N,P);let F,I;t[10]!==f||t[11]!==D||t[12]!==S?(F=()=>{f!==0&&(D?k(!0):(A.current=!1,S.current?.expand()))},I=[f,D,S],t[10]=f,t[11]=D,t[12]=S,t[13]=F,t[14]=I):(F=t[13],I=t[14]),(0,Q.useEffect)(F,I);let L=(0,Q.useRef)(null),[R,z]=(0,Q.useState)(null),B,V;if(t[15]===o?(B=t[16],V=t[17]):(B=()=>{if(o&&o!==L.current){let e=L.current;L.current=o,z(e)}},V=[o],t[15]=o,t[16]=B,t[17]=V),(0,Q.useEffect)(B,V),c?.kind===`folder`){if(!(u===`agent`&&d!==null)){let e;return t[18]===c.folderPath?e=t[19]:(e=(0,Z.jsx)(oC,{folderPath:c.folderPath}),t[18]=c.folderPath,t[19]=e),e}let e;t[20]===c.folderPath?e=t[21]:(e=(0,Z.jsx)(OC,{minSize:`30%`,defaultSize:`75%`,children:(0,Z.jsx)(oC,{folderPath:c.folderPath})}),t[20]=c.folderPath,t[21]=e);let n;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(kC,{withHandle:!0}),t[22]=n):n=t[22];let r;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(OC,{defaultSize:`25%`,minSize:`300px`,maxSize:`40%`,className:`flex flex-col bg-muted/20`,children:(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(`div`,{role:`status`,"aria-busy":`true`,className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Loading agent activity`}),children:(0,Z.jsx)(NE,{showBackButton:!1})})}),t[23]=r):r=t[23];let i;return t[24]===e?i=t[25]:(i=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,Z.jsxs)(DC,{orientation:`horizontal`,children:[e,n,r]})}),t[24]=e,t[25]=i),i}if(c?.kind===`asset`){let e;return t[26]!==c.assetPath||t[27]!==c.mediaKind?(e=(0,Z.jsx)(Rx,{assetPath:c.assetPath,mediaKind:c.mediaKind},c.assetPath),t[26]=c.assetPath,t[27]=c.mediaKind,t[28]=e):e=t[28],e}if(!s||!o){if((typeof window<`u`?Rr(window.location.hash):null)!==null){let e;return t[29]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(zx,{}),t[29]=e):e=t[29],e}let e;return t[30]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(NS,{}),t[30]=e):e=t[30],e}let H=n===`source`,U=!_,W=D?!O:C,G;t[31]!==o||t[32]!==m?(G=function(){o&&m(o)},t[31]=o,t[32]=m,t[33]=G):G=t[33];let K=G,q;t[34]!==C||t[35]!==D||t[36]!==S?(q=function(){D?k(LE):C?(A.current=!1,S.current?.expand()):(A.current=!0,S.current?.collapse())},t[34]=C,t[35]=D,t[36]=S,t[37]=q):q=t[37];let ee=q,te=v??o,ne=R??void 0,re;t[38]===p?re=t[39]:(re=e=>{let t=Tr(e);window.location.hash===t?p(e):window.location.hash=t},t[38]=p,t[39]=re);let ie;t[40]!==x||t[41]!==H||t[42]!==l||t[43]!==te||t[44]!==ne||t[45]!==re?(ie=(0,Z.jsx)(fE,{activeDocName:te,isSourceMode:H,editorPlaceholder:x,previousDocName:ne,onNavigateBack:re,onRecycle:l}),t[40]=x,t[41]=H,t[42]=l,t[43]=te,t[44]=ne,t[45]=re,t[46]=ie):ie=t[46];let ae;t[47]!==o||t[48]!==H?(ae=(0,Z.jsx)(YC,{activeDocName:o,isSourceMode:H}),t[47]=o,t[48]=H,t[49]=ae):ae=t[49];let oe;t[50]!==o||t[51]!==v?(oe=ME({activeDocName:o,deferredActiveDocName:v,mountResolved:o!==null&&ke(o),syncResolved:o!==null&&Le(o)})?(0,Z.jsxs)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:[(0,Z.jsx)(zx,{}),o===null?null:(0,Z.jsx)(uC,{docName:o})]}):null,t[50]=o,t[51]=v,t[52]=oe):oe=t[52];let se;t[53]!==ie||t[54]!==ae||t[55]!==oe?(se=(0,Z.jsxs)(`div`,{className:`relative h-full`,children:[ie,ae,oe]}),t[53]=ie,t[54]=ae,t[55]=oe,t[56]=se):se=t[56];let ce=!H,le;t[57]!==o||t[58]!==W||t[59]!==H||t[60]!==r||t[61]!==K||t[62]!==U||t[63]!==ce||t[64]!==ee?(le=(0,Z.jsx)(jE,{activeDocName:o,isSourceMode:H,sourceDisabled:U,onModeChange:r,showAddPropertyButton:ce,onAddProperty:K,isPanelCollapsed:W,onTogglePanel:ee}),t[57]=o,t[58]=W,t[59]=H,t[60]=r,t[61]=K,t[62]=U,t[63]=ce,t[64]=ee,t[65]=le):le=t[65];let J;t[66]!==se||t[67]!==le?(J=(0,Z.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[se,le]}),t[66]=se,t[67]=le,t[68]=J):J=t[68];let ue;t[69]!==b||t[70]!==h?(ue=b&&(0,Z.jsx)(bE,{stats:h}),t[69]=b,t[70]=h,t[71]=ue):ue=t[71];let de;t[72]!==J||t[73]!==ue?(de=(0,Z.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[J,ue]}),t[72]=J,t[73]=ue,t[74]=de):de=t[74];let fe=de,pe=D?`100%`:`30%`,me=D?`100%`:`75%`,he;t[75]!==fe||t[76]!==pe||t[77]!==me?(he=(0,Z.jsx)(OC,{minSize:pe,defaultSize:me,children:fe}),t[75]=fe,t[76]=pe,t[77]=me,t[78]=he):he=t[78];let ge;t[79]===D?ge=t[80]:(ge=D?null:(0,Z.jsx)(kC,{withHandle:!0}),t[79]=D,t[80]=ge);let _e;t[81]!==o||t[82]!==i||t[83]!==u||t[84]!==D||t[85]!==H||t[86]!==a||t[87]!==S?(_e=D?null:(0,Z.jsx)(OC,{panelRef:S,defaultSize:`25%`,minSize:`300px`,maxSize:`40%`,collapsible:!0,collapsedSize:0,onResize:e=>w(e.asPercentage===0),className:`flex flex-col bg-muted/20`,children:(0,Z.jsx)(Ny,{docName:o,isSourceMode:H,activeTab:i,onActiveTabChange:a,mode:u})}),t[81]=o,t[82]=i,t[83]=u,t[84]=D,t[85]=H,t[86]=a,t[87]=S,t[88]=_e):_e=t[88];let ve;t[89]!==he||t[90]!==ge||t[91]!==_e?(ve=(0,Z.jsxs)(DC,{orientation:`horizontal`,children:[he,ge,_e]}),t[89]=he,t[90]=ge,t[91]=_e,t[92]=ve):ve=t[92];let ye;t[93]!==o||t[94]!==i||t[95]!==u||t[96]!==D||t[97]!==H||t[98]!==a||t[99]!==O?(ye=D?(0,Z.jsx)(Q_,{open:O,onOpenChange:k,children:(0,Z.jsxs)(tv,{side:`right`,className:`flex w-80 sm:w-96 flex-col gap-0 p-0`,children:[(0,Z.jsx)(nv,{className:`sr-only`,children:(0,Z.jsx)(rv,{children:`Document panel`})}),(0,Z.jsx)(Ny,{docName:o,isSourceMode:H,activeTab:i,onActiveTabChange:a,mode:u})]})}):null,t[93]=o,t[94]=i,t[95]=u,t[96]=D,t[97]=H,t[98]=a,t[99]=O,t[100]=ye):ye=t[100];let be;return t[101]!==ve||t[102]!==ye?(be=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[ve,ye]}),t[101]=ve,t[102]=ye,t[103]=be):be=t[103],be}function LE(e){return!e}var RE=1280;function zE(){let e=(0,$.c)(2),[t,n]=(0,Q.useState)(BE),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${RE-1}px)`),t=()=>{n(window.innerWidth<RE)};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 BE(){return window.innerWidth<RE}function VE(e){let t=e.endsWith(`rem`)?`rem`:`px`;return{value:Number.parseFloat(e),unit:t}}function HE(e){let{value:t,unit:n}=VE(e);return n===`rem`?t*16:t}function UE(e,t){return`${t===`rem`?e.toFixed(1):Math.round(e)}${t}`}var WE=3600*24*7;function GE(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?KE:m,O=g===void 0?WE:g,k=_===void 0?!1:_,A=(0,Q.useRef)(null),j=(0,Q.useRef)(0),M=(0,Q.useRef)(0),N=(0,Q.useRef)(!1),P=(0,Q.useRef)(!1),F=(0,Q.useRef)(null),I=(0,Q.useRef)(0),L=(0,Q.useRef)(!1),R=(0,Q.useRef)(0),z=(0,Q.useRef)(0),B=(0,Q.useRef)(null),V=(0,Q.useRef)(r),H=(0,Q.useRef)(y),U,W;t[0]===r?(U=t[1],W=t[2]):(U=()=>{V.current=r},W=[r],t[0]=r,t[1]=U,t[2]=W),(0,Q.useEffect)(U,W);let G,K;t[3]===y?(G=t[4],K=t[5]):(G=()=>{H.current=y},K=[y],t[3]=y,t[4]=G,t[5]=K),(0,Q.useEffect)(G,K);let q=HE(b),ee;t[6]===x?ee=t[7]:(ee=HE(x),t[6]=x,t[7]=ee);let te=ee,ne;t[8]!==E||t[9]!==k?(ne=function(e){P.current=!0,E&&(j.current=H.current?0:HE(V.current),M.current=e.clientX,I.current=e.clientX,F.current=null,L.current=!1,R.current=0,z.current=0,B.current=k&&A.current?A.current.getBoundingClientRect():null,e.preventDefault())},t[8]=E,t[9]=k,t[10]=ne):ne=t[10];let re=ne,ie,ae;t[11]!==w||t[12]!==v||t[13]!==C||t[14]!==S||t[15]!==T||t[16]!==k||t[17]!==te||t[18]!==q||t[19]!==i||t[20]!==a||t[21]!==D||t[22]!==O||t[23]!==h?(ie=()=>{let e=function(e){h&&(document.cookie=`${h}=${e}; path=/; max-age=${O}`)},t=function(e,t){return v===`left`?e<t:e>t},n=function(e,t,n,r){if(k&&r){let r=e.clientX-t;return v===`left`?n-r:n+r}return v===`left`?window.innerWidth-e.clientX:e.clientX},r=function(r){if(!P.current)return;let o=Math.abs(r.clientX-M.current);if(!N.current&&o>5&&(N.current=!0,D(!0)),N.current){let{unit:o}=VE(V.current),s=B.current;k&&A.current&&(s=A.current.getBoundingClientRect());let c=t(r.clientX,I.current)?`expand`:`collapse`;F.current!==c&&(F.current=c),z.current=Math.abs(r.clientX-I.current);let l=Date.now();if(L.current&&l-R.current>200&&(L.current=!1),!L.current){if(C&&a&&!H.current){let e=n(r,M.current,j.current,s),t=!1;if(w<=1)t=e<=q*w;else if(e<=q){let n=q*(w-1);t=q-e>=n}if(c===`collapse`&&t){a(),I.current=r.clientX,L.current=!0,R.current=l;return}}if(a&&H.current&&c===`expand`&&z.current>q*T){a();let t=n(r,M.current,j.current,s),c=Math.max(q,Math.min(te,t)),u=UE(o===`rem`?c/16:c,o);i(u),e(u),I.current=r.clientX,L.current=!0,R.current=l;return}}if(H.current)return;let u=n(r,M.current,j.current,s),d=Math.max(q,Math.min(te,u)),f=UE(o===`rem`?d/16:d,o);i(f),e(f)}},o=function(){P.current&&(!N.current&&a&&S&&a(),N.current=!1,P.current=!1,F.current=null,I.current=0,L.current=!1,R.current=0,z.current=0,B.current=null,D(!1))};return document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,o),()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,o)}},ae=[i,a,D,q,te,k,C,w,T,S,h,O,v],t[11]=w,t[12]=v,t[13]=C,t[14]=S,t[15]=T,t[16]=k,t[17]=te,t[18]=q,t[19]=i,t[20]=a,t[21]=D,t[22]=O,t[23]=h,t[24]=ie,t[25]=ae):(ie=t[24],ae=t[25]),(0,Q.useEffect)(ie,ae);let oe;return t[26]===re?oe=t[27]:(oe={dragRef:A,isDragging:N,handleMouseDown:re},t[26]=re,t[27]=oe),oe}function KE(){}var qE=`sidebar_state`,JE=3600*24*7,YE=`18rem`,XE=`3rem`,ZE=`\\`,QE=`app-file-sidebar`,$E=`14.625rem`,eD=`22rem`,tD=`sidebar_width`,nD=/^\d+(?:\.\d+)?(?:rem|px)$/,rD=Q.createContext(null);function iD(e){if(typeof document>`u`)return e;let t=document.cookie.split(`; `).find(e=>e.startsWith(`${tD}=`))?.split(`=`)[1];if(!t)return e;let n;try{n=decodeURIComponent(t)}catch{return e}return nD.test(n)?n:e}function aD(){let e=Q.use(rD);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function oD(e){let t=(0,$.c)(53),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({defaultOpen:c,open:i,onOpenChange:o,className:r,style:s,children:n,defaultWidth:l,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=c===void 0?!0:c,d=l===void 0?YE:l,f=zE(),p;t[9]===d?p=t[10]:(p=()=>iD(d),t[9]=d,t[10]=p);let[m,h]=Q.useState(p),[g,_]=Q.useState(!1),v=Q.useRef(g),[y,b]=Q.useState(!1),[x,S]=Q.useState(!1),[C,w]=Q.useState(u),T=i??C,E;t[11]!==T||t[12]!==o?(E=e=>{let t=typeof e==`function`?e(T):e;o?o(t):w(t),document.cookie=`${qE}=${t}; path=/; max-age=${JE}`},t[11]=T,t[12]=o,t[13]=E):E=t[13];let D=E,O;t[14]===D?O=t[15]:(O=function(){return window.innerWidth<1280?_(cD):D(sD)},t[14]=D,t[15]=O);let k=O,A;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(A=function(){window.innerWidth>=1280||v.current&&(window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||S(!0))},t[16]=A):A=t[16];let j=A,M;t[17]===g?M=t[18]:(M=()=>{v.current=g},t[17]=g,t[18]=M),Q.useLayoutEffect(M);let N,P;t[19]===k?(N=t[20],P=t[21]):(N=()=>{let e=e=>{e.key===ZE&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),k())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},P=[k],t[19]=k,t[20]=N,t[21]=P),Q.useEffect(N,P);let F,I;t[22]!==f||t[23]!==g?(F=()=>{if(!f||!g)return;let e=e=>{e.key===`Escape`&&(document.querySelector(`[data-state="open"][role="dialog"], [data-state="open"][role="alertdialog"], [data-state="open"][role="menu"], [data-state="open"][role="listbox"], [data-radix-popper-content-wrapper] [data-state="open"]`)||_(!1))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},I=[f,g],t[22]=f,t[23]=g,t[24]=F,t[25]=I):(F=t[24],I=t[25]),Q.useEffect(F,I);let L=Q.useRef(f),R,z;t[26]!==f||t[27]!==T?(R=()=>{!L.current&&f&&_(T),L.current=f},z=[f,T],t[26]=f,t[27]=T,t[28]=R,t[29]=z):(R=t[28],z=t[29]),Q.useEffect(R,z);let B=f?g?`expanded`:`collapsed`:T?`expanded`:`collapsed`,V;t[30]!==y||t[31]!==f||t[32]!==T||t[33]!==g||t[34]!==D||t[35]!==x||t[36]!==B||t[37]!==k||t[38]!==m?(V={state:B,open:T,setOpen:D,isMobile:f,openMobile:g,setOpenMobile:_,toggleSidebar:k,width:m,setWidth:h,isDraggingRail:y,setIsDraggingRail:b,showPushPulse:x,setShowPushPulse:S,notifySidebarFileSelected:j},t[30]=y,t[31]=f,t[32]=T,t[33]=g,t[34]=D,t[35]=x,t[36]=B,t[37]=k,t[38]=m,t[39]=V):V=t[39];let H;t[40]!==s||t[41]!==m?(H={"--sidebar-width":m,"--sidebar-width-icon":XE,...s},t[40]=s,t[41]=m,t[42]=H):H=t[42];let U=H,W;t[43]===r?W=t[44]:(W=mi(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),t[43]=r,t[44]=W);let G;t[45]!==n||t[46]!==a||t[47]!==U||t[48]!==W?(G=(0,Z.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:U,className:W,...a,children:n}),t[45]=n,t[46]=a,t[47]=U,t[48]=W,t[49]=G):G=t[49];let K;return t[50]!==V||t[51]!==G?(K=(0,Z.jsx)(rD.Provider,{value:V,children:G}),t[50]=V,t[51]=G,t[52]=K):K=t[52],K}function sD(e){return!e}function cD(e){return!e}function lD(e){let t=(0,$.c)(51),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({side:a,variant:o,collapsible:s,className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=a===void 0?`left`:a,l=o===void 0?`sidebar`:o,u=s===void 0?`offcanvas`:s,{isMobile:d,state:f,openMobile:p,isDraggingRail:m}=aD();if(u===`none`){let e;t[7]===r?e=t[8]:(e=mi(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),t[7]=r,t[8]=e);let a;return t[9]!==n||t[10]!==i||t[11]!==e||t[12]!==l?(a=(0,Z.jsx)(`div`,{"data-slot":`sidebar`,"data-variant":l,className:e,...i,children:n}),t[9]=n,t[10]=i,t[11]=e,t[12]=l,t[13]=a):a=t[13],a}if(d){let e=p?`expanded`:`collapsed`,a=l===`floating`||l===`inset`?`p-2`:``,o;t[14]!==r||t[15]!==a?(o=mi(`fixed inset-y-0 z-30 flex h-svh w-(--sidebar-width)`,`transition-transform duration-200 ease-linear motion-reduce:transition-none`,`data-[side=left]:left-0 data-[side=right]:right-0`,`group-data-[state=collapsed]:data-[side=left]:-translate-x-full`,`group-data-[state=collapsed]:data-[side=right]:translate-x-full`,a,r),t[14]=r,t[15]=a,t[16]=o):o=t[16];let s;t[17]===n?s=t[18]:(s=(0,Z.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border`,children:n}),t[17]=n,t[18]=s);let u;t[19]!==i||t[20]!==c||t[21]!==o||t[22]!==s?(u=(0,Z.jsx)(`nav`,{id:QE,"aria-label":`File sidebar`,"data-slot":`sidebar-container`,"data-side":c,className:o,...i,children:s}),t[19]=i,t[20]=c,t[21]=o,t[22]=s,t[23]=u):u=t[23];let d;return t[24]!==e||t[25]!==c||t[26]!==u||t[27]!==l?(d=(0,Z.jsx)(`div`,{className:`group peer text-sidebar-foreground`,"data-state":e,"data-variant":l,"data-side":c,"data-slot":`sidebar`,"data-mobile":`true`,children:u}),t[24]=e,t[25]=c,t[26]=u,t[27]=l,t[28]=d):d=t[28],d}let h=f===`collapsed`?u:``,g=l===`floating`||l===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,_;t[29]===g?_=t[30]:(_=mi(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,g,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`),t[29]=g,t[30]=_);let v;t[31]===_?v=t[32]:(v=(0,Z.jsx)(`div`,{"data-slot":`sidebar-gap`,className:_}),t[31]=_,t[32]=v);let y=l===`floating`||l===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,b;t[33]!==r||t[34]!==y?(b=mi(`fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex`,y,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`,r),t[33]=r,t[34]=y,t[35]=b):b=t[35];let x;t[36]===n?x=t[37]:(x=(0,Z.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border`,children:n}),t[36]=n,t[37]=x);let S;t[38]!==i||t[39]!==c||t[40]!==x||t[41]!==b?(S=(0,Z.jsx)(`nav`,{id:QE,"aria-label":`File sidebar`,"data-slot":`sidebar-container`,"data-side":c,className:b,...i,children:x}),t[38]=i,t[39]=c,t[40]=x,t[41]=b,t[42]=S):S=t[42];let C;return t[43]!==m||t[44]!==c||t[45]!==f||t[46]!==S||t[47]!==h||t[48]!==v||t[49]!==l?(C=(0,Z.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":f,"data-collapsible":h,"data-variant":l,"data-side":c,"data-slot":`sidebar`,"data-dragging":m,children:[v,S]}),t[43]=m,t[44]=c,t[45]=f,t[46]=S,t[47]=h,t[48]=v,t[49]=l,t[50]=C):C=t[50],C}function uD(e){let t=(0,$.c)(18),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,onClick:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let{toggleSidebar:a,state:o}=aD(),s=o===`expanded`,c=o===`expanded`?`Hide Files`:`Show Files`,l;t[4]===n?l=t[5]:(l=mi(n),t[4]=n,t[5]=l);let u;t[6]!==r||t[7]!==a?(u=e=>{r?.(e),a()},t[6]=r,t[7]=a,t[8]=u):u=t[8];let d;t[9]===o?d=t[10]:(d=o===`expanded`?(0,Z.jsx)(Ot,{}):(0,Z.jsx)(Ec,{}),t[9]=o,t[10]=d);let f;return t[11]!==i||t[12]!==s||t[13]!==c||t[14]!==l||t[15]!==u||t[16]!==d?(f=(0,Z.jsx)(Y,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon-sm`,"aria-expanded":s,"aria-controls":QE,"aria-label":c,className:l,onClick:u,...i,children:d}),t[11]=i,t[12]=s,t[13]=c,t[14]=l,t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function dD(e){let t=(0,$.c)(26),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:n,enableDrag:a,enableToggle:o,onMouseDown:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=a===void 0?!0:a,c=o===void 0?!0:o,{toggleSidebar:l,setWidth:u,state:d,width:f,setIsDraggingRail:p}=aD(),m=d===`collapsed`,h;t[6]!==s||t[7]!==c||t[8]!==p||t[9]!==u||t[10]!==m||t[11]!==l||t[12]!==f?(h={direction:`right`,enableDrag:s,enableToggle:c,onResize:u,onToggle:l,currentWidth:f,isCollapsed:m,minResizeWidth:$E,maxResizeWidth:eD,setIsDraggingRail:p,widthCookieName:tD,widthCookieMaxAge:JE},t[6]=s,t[7]=c,t[8]=p,t[9]=u,t[10]=m,t[11]=l,t[12]=f,t[13]=h):h=t[13];let{dragRef:g,handleMouseDown:_}=GE(h),v=d===`expanded`?`Hide Files`:`Show Files`,y;t[14]!==_||t[15]!==r?(y=e=>{r?.(e),e.defaultPrevented||_(e)},t[14]=_,t[15]=r,t[16]=y):y=t[16];let b=d===`expanded`?`Hide Files`:`Show Files`,x;t[17]===n?x=t[18]:(x=mi(`absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2`,`in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize`,`[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize`,`group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar`,`[[data-side=left][data-collapsible=offcanvas]_&]:-right-2`,`[[data-side=right][data-collapsible=offcanvas]_&]:-left-2`,`md:group-data-[variant=inset]:after:inset-y-5`,n),t[17]=n,t[18]=x);let S;return t[19]!==g||t[20]!==i||t[21]!==v||t[22]!==y||t[23]!==b||t[24]!==x?(S=(0,Z.jsx)(`button`,{ref:g,"data-sidebar":`rail`,"data-slot":`sidebar-rail`,"aria-label":v,tabIndex:-1,onMouseDown:y,title:b,className:x,...i}),t[19]=g,t[20]=i,t[21]=v,t[22]=y,t[23]=b,t[24]=x,t[25]=S):S=t[25],S}function fD(e){let t=(0,$.c)(21),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,onClick:i,onAnimationEnd:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{isMobile:o,openMobile:s,setOpenMobile:c,showPushPulse:l,setShowPushPulse:u}=aD(),d;t[5]!==o||t[6]!==i||t[7]!==s||t[8]!==c?(d=e=>{i?.(e),!e.defaultPrevented&&(!o||!s||e.target?.closest(`[data-sidebar="trigger"]`)||c(!1))},t[5]=o,t[6]=i,t[7]=s,t[8]=c,t[9]=d):d=t[9];let f=d,p;t[10]!==r||t[11]!==u?(p=e=>{r?.(e),e.animationName===`sidebar-push-pulse`&&u(!1)},t[10]=r,t[11]=u,t[12]=p):p=t[12];let m=p,h=l?``:void 0,g;t[13]===n?g=t[14]:(g=mi(`relative flex w-full flex-1 flex-col bg-background peer-data-[variant=inset]:m-2 peer-data-[variant=inset]:ml-0 peer-data-[variant=inset]:rounded-xl peer-data-[variant=inset]:shadow-sm peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2`,`transition-transform duration-200 ease-linear motion-reduce:transition-none`,`peer-data-[mobile=true]:peer-data-[state=expanded]:translate-x-(--sidebar-width)`,n),t[13]=n,t[14]=g);let _;return t[15]!==m||t[16]!==f||t[17]!==a||t[18]!==h||t[19]!==g?(_=(0,Z.jsx)(`main`,{"data-slot":`sidebar-inset`,"data-push-pulse":h,onClick:f,onAnimationEnd:m,className:g,...a}),t[15]=m,t[16]=f,t[17]=a,t[18]=h,t[19]=g,t[20]=_):_=t[20],_}function pD(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=mi(`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 mD(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=mi(`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 hD(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=mi(`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 gD(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=mi(`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 _D(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=mi(`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 vD=Ti(`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 yD(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?vi:`button`,{isMobile:m,state:h}=aD(),g;t[8]!==n||t[9]!==f||t[10]!==d?(g=mi(vD({variant:d,size:f}),n),t[8]=n,t[9]=f,t[10]=d,t[11]=g):g=t[11];let _;t[12]!==p||t[13]!==u||t[14]!==r||t[15]!==f||t[16]!==g?(_=(0,Z.jsx)(p,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":f,"data-active":u,className:g,...r}),t[12]=p,t[13]=u,t[14]=r,t[15]=f,t[16]=g,t[17]=_):_=t[17];let v=_;if(!c)return v;if(typeof c==`string`){let e;t[18]===c?e=t[19]:(e={children:c},t[18]=c,t[19]=e),c=e}let y;t[20]===v?y=t[21]:(y=(0,Z.jsx)(kr,{asChild:!0,children:v}),t[20]=v,t[21]=y);let b=h!==`collapsed`||m,x;t[22]!==b||t[23]!==c?(x=(0,Z.jsx)(vn,{side:`right`,align:`center`,hidden:b,...c}),t[22]=b,t[23]=c,t[24]=x):x=t[24];let S;return t[25]!==y||t[26]!==x?(S=(0,Z.jsxs)(yn,{children:[y,x]}),t[25]=y,t[26]=x,t[27]=S):S=t[27],S}function bD(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 xD(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 SD=1e3,CD=!1;function wD(e){return!!(e.localPrincipalId&&e.entryPrincipalId===e.localPrincipalId||!e.localPrincipalId&&e.entryClientId===e.localClientId)}function TD(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:Ri(i)?a=i:(a=void 0,CD||(CD=!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`&&(wD({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=xD(i),{current:c,crossDoc:l}=a?Ni(a,n,Date.now()):{current:[],crossDoc:[]},u=ED,d=c.map(u),f=l.map(u),p=[...s,...d],m=f;o(e=>bD(e.current,p)&&bD(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,SD);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 ED(e){let{agentId:t,entry:n}=e;return{kind:`agent`,agentId:t,presence:n}}var DD=`sync-status`;function OD(e,t){let n=(0,$.c)(4),r=(0,Q.useRef)(!1),i=(0,Q.useRef)(!1),a=(0,Q.useRef)(t),o,s;n[0]!==t||n[1]!==e?(o=()=>{a.current!==t&&(a.current=t,r.current=!1,i.current=!1),t&&(e===`synced`&&(r.current=!0),e===`disconnected`&&r.current?(i.current=!0,X.warning(`Connection lost — keep this tab open, your edits will sync when reconnected`,{id:DD,duration:1/0})):i.current&&e===`synced`&&(i.current=!1,X.success(`Reconnected`,{id:DD,duration:3e3})))},s=[e,t],n[0]=t,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),(0,Q.useEffect)(o,s)}var kD=4,AD=3,jD={Bird:Bs,Cat:Ks,Dog:rc,Fish:sc,Mouse:Nc,Rabbit:Mc,Shrimp:Vc,Snail:Hc,Squirrel:Gc,Turtle:Xc};Object.freeze(Object.keys(jD));function MD(e){if(typeof e.principalId==`string`&&e.principalId.length>0)return{kind:`initials`};let t=e.name.split(` `)[1];return t&&Object.hasOwn(jD,t)?{kind:`animal`,animal:t}:{kind:`initials`}}var ND={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function PD(e){let t=(0,$.c)(20),{user:n,mode:r,tabCount:i}=e,a=MD(n),o=a.kind===`animal`?jD[a.animal]:void 0,s;t[0]===n.name?s=t[1]:(s=cr(n.name),t[0]=n.name,t[1]=s);let c=s,l;t[2]===n.color?l=t[3]:(l=Kn(n.color),t[2]=n.color,t[3]=l);let u=l,d=i>1?`${n.name} · ${i} tabs`:n.name,f=i>1?`${n.name}, ${i} concurrent tabs`:n.name,p;t[4]===n.color?p=t[5]:(p={backgroundColor:n.color},t[4]=n.color,t[5]=p);let m;t[6]!==o||t[7]!==u||t[8]!==c?(m=o?(0,Z.jsx)(o,{size:18,color:u,strokeWidth:1.5}):(0,Z.jsx)(`span`,{className:`font-mono text-2xs font-semibold leading-none`,style:{color:u},children:c}),t[6]=o,t[7]=u,t[8]=c,t[9]=m):m=t[9];let h;t[10]!==f||t[11]!==r||t[12]!==p||t[13]!==m?(h=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(`div`,{"data-presence-badge":`human`,"data-presence-mode":r,role:`img`,"aria-label":f,className:`inline-flex size-7 shrink-0 cursor-default items-center justify-center rounded-full ring-2 ring-background`,style:p,children:m})}),t[10]=f,t[11]=r,t[12]=p,t[13]=m,t[14]=h):h=t[14];let g;t[15]===d?g=t[16]:(g=(0,Z.jsx)(vn,{children:d}),t[15]=d,t[16]=g);let _;return t[17]!==h||t[18]!==g?(_=(0,Z.jsxs)(yn,{children:[h,g]}),t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function FD(e){let t=ND[e.icon];return e.displayName||t||`Agent`}function ID(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 LD(e){let t=(0,$.c)(36),{participant:n,crossDoc:r,scoped:i,onClickAgent:a}=e,{presence:o,agentId:s}=n,c;t[0]===o?c=t[1]:(c=FD(o),t[0]=o,t[1]=c);let l=c,u=ID(o.mode),d=!r&&u,f=i?`ring-primary ring-offset-2 ring-offset-background`:`ring-background`,p=d&&!i?`ring-primary/40 animate-pulse`:``,m;t[2]!==f||t[3]!==p?(m=[`inline-flex size-7 shrink-0 items-center justify-center rounded-full ring-2 cursor-pointer`,f,p].filter(Boolean),t[2]=f,t[3]=p,t[4]=m):m=t[4];let h=m.join(` `),g=r?`true`:void 0,_=i?`true`:void 0,v;t[5]!==o.mode||t[6]!==g||t[7]!==_?(v={"data-presence-badge":`agent`,"data-presence-mode":o.mode,"data-presence-crossdoc":g,"data-presence-scoped":_},t[5]=o.mode,t[6]=g,t[7]=_,t[8]=v):v=t[8];let y=v,b=o.currentDoc&&o.currentDoc!==`(connected)`?o.currentDoc:null,x=r&&b?`Open activity panel for ${l}, editing ${b}`:`Open activity panel for ${l}`,S;t[9]===o.color?S=t[10]:(S={backgroundColor:o.color},t[9]=o.color,t[10]=S);let C;t[11]!==s||t[12]!==a?(C=()=>a(s),t[11]=s,t[12]=a,t[13]=C):C=t[13];let w;t[14]===o.icon?w=t[15]:(w=(0,Z.jsx)(Ii,{icon:o.icon,width:16,height:16,className:`text-white`}),t[14]=o.icon,t[15]=w);let T;t[16]!==x||t[17]!==y||t[18]!==h||t[19]!==w||t[20]!==S||t[21]!==C?(T=(0,Z.jsx)(`button`,{type:`button`,...y,"aria-label":x,className:h,style:S,onClick:C,children:w}),t[16]=x,t[17]=y,t[18]=h,t[19]=w,t[20]=S,t[21]=C,t[22]=T):T=t[22];let E=T,D;t[23]===E?D=t[24]:(D=(0,Z.jsx)(kr,{asChild:!0,children:E}),t[23]=E,t[24]=D);let O;t[25]===l?O=t[26]:(O=(0,Z.jsx)(`span`,{className:`font-medium`,children:l}),t[25]=l,t[26]=O);let k;t[27]!==r||t[28]!==b?(k=r&&b?(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`editing [[`,b,`]]`]}):null,t[27]=r,t[28]=b,t[29]=k):k=t[29];let A;t[30]!==O||t[31]!==k?(A=(0,Z.jsxs)(vn,{className:`flex flex-col gap-0.5`,children:[O,k]}),t[30]=O,t[31]=k,t[32]=A):A=t[32];let j;return t[33]!==D||t[34]!==A?(j=(0,Z.jsxs)(yn,{children:[D,A]}),t[33]=D,t[34]=A,t[35]=j):j=t[35],j}function RD(e){let t=(0,$.c)(18),{count:n,remainder:r,crossDoc:i,scopedAgentId:a,onClickAgent:o}=e,s=i?`true`:void 0,c=`${n} more ${i?`cross-doc `:``}${n===1?`participant`:`participants`}`,l;t[0]!==n||t[1]!==s||t[2]!==c?(l=(0,Z.jsx)(ne,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`presence-overflow`,"data-presence-crossdoc":s,className:`inline-flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-full bg-muted font-medium text-muted-foreground text-xs ring-2 ring-background hover:bg-muted/80`,"aria-label":c,children:[`+`,n]})}),t[0]=n,t[1]=s,t[2]=c,t[3]=l):l=t[3];let u;if(t[4]!==i||t[5]!==o||t[6]!==r||t[7]!==a){let e;t[9]!==i||t[10]!==o||t[11]!==a?(e=e=>e.kind===`human`?(0,Z.jsx)(PD,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(LD,{participant:e,crossDoc:i,scoped:a===e.agentId,onClickAgent:o},e.agentId),t[9]=i,t[10]=o,t[11]=a,t[12]=e):e=t[12],u=r.map(e),t[4]=i,t[5]=o,t[6]=r,t[7]=a,t[8]=u}else u=t[8];let d;t[13]===u?d=t[14]:(d=(0,Z.jsx)(G,{align:`end`,className:`w-auto max-w-xs p-2`,children:(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:u})}),t[13]=u,t[14]=d);let f;return t[15]!==l||t[16]!==d?(f=(0,Z.jsxs)(H,{children:[l,d]}),t[15]=l,t[16]=d,t[17]=f):f=t[17],f}function zD(e,t,n,r){return e.kind===`human`?(0,Z.jsx)(PD,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(LD,{participant:e,crossDoc:n,scoped:r===e.agentId,onClickAgent:t},e.agentId)}function BD(){let e=(0,$.c)(20),{activeProvider:t,activeDocName:n,systemProvider:r,openActivityPanel:i,docPanelMode:a,docPanelAgentId:o}=ot(),{current:s,crossDoc:c}=TD(t,r,n);if(OD(_w(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,kD),n;e[6]===s?n=e[7]:(n=s.slice(kD),e[6]=s,e[7]=n);let r=n,u=c.slice(0,AD),d;e[8]===c?d=e[9]:(d=c.slice(AD),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=>zD(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)(RD,{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=>zD(e,p,!0,m)),f.length>0?(0,Z.jsx)(RD,{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}var VD=`.md`,HD=/\.(md|mdx)$/i;function UD(e,t=VD){return`${e}${t}`}function WD(e){return cO(e).replace(HD,``)}function GD(e){return ti(e)?JD(e.path):Hn(e)?e.path:UD(e.docName,e.docExt)}function KD(e){let t=cO(e).match(HD);return t?`.${t[1].toLowerCase()}`:void 0}function qD(e){return cO(e)}function JD(e){let t=cO(e.trim());return t?`${t}/`:``}function YD(e){return e.endsWith(`/`)?qD(e):WD(e)}function XD(e){return e.map(GD)}function ZD(e){return[...e].sort().join(`\0`)}function QD(e){return ZD(XD(e))}function $D(e){let t=new Set;for(let n of e){if(ti(n)){let e=JD(n.path);e&&t.add(e)}let e=(ti(n)||Hn(n)?n.path:n.docName).split(`/`).filter(Boolean),r=ti(n)?e.length:e.length-1;for(let n=1;n<=r;n++)t.add(`${e.slice(0,n).join(`/`)}/`)}return[...t].sort()}function eO(e){if(!e)return[];let t=cO(e.replace(HD,``)).split(`/`).filter(Boolean),n=[],r=e.endsWith(`/`)?t.length:t.length-1;for(let e=1;e<=r;e++)n.push(`${t.slice(0,e).join(`/`)}/`);return n}function tO(e){let t=e.kind===`directory`,n=t?qD(e.path):WD(e.path),r=t?void 0:KD(e.path);return{kind:t?`folder`:`file`,name:cO(sO(e.path)).replace(HD,``),path:n,treePath:rO(e.path,t),docExt:r}}function nO(e){return e.kind===`directory`?qD(e.path):e.path}function rO(e,t){return t?JD(e):HD.test(e)?e:`${e}${VD}`}function iO(e,t,n){let r=JD(t),i=new Set(n);for(let t=0;t<100;t++){let n=t===0?``:` ${t+1}`;if(e===`file`){let e=`${r}Untitled${n}${VD}`;if(!i.has(e))return{addPath:e,renamePath:e};continue}let a=`${r}New Folder${n}/`;if(!i.has(a))return{addPath:a,renamePath:a}}throw Error(`Could not allocate a unique tree placeholder`)}function aO(e,t){return e===`file`?rO(t,!1):`${qD(t)}/index${VD}`}function oO(e,t){return t.kind===`root`||t.directoryPath==null?sO(e):`${t.directoryPath}${sO(e)}`}function sO(e){let t=cO(e),n=t.lastIndexOf(`/`),r=n===-1?t:t.slice(n+1);return e.endsWith(`/`)?`${r}/`:r}function cO(e){return e.endsWith(`/`)?e.slice(0,-1):e}function lO(e,t){return t.trim()}function uO(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function dO(e,t){let n=lO(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function fO(e,t,n=[]){if(t.length===0&&n.length===0)return e;let r=new Map(t.map(e=>[e.fromDocName,e.toDocName]));return e.map(e=>hn(e)?{...e,docName:r.get(e.docName)??e.docName}:ti(e)||Hn(e)?{...e,path:_O(e.path,n)}:e)}function pO(e,t,n){if(t.length===0&&!n)return e;let r=new Set(t);return e.filter(e=>hn(e)?!r.has(e.docName)&&!vO(e.docName,n):ti(e)||Hn(e)?!vO(e.path,n):!0)}function mO(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}function hO(e,t){return e.flatMap(e=>t===e.toDocName?[e.fromDocName]:[e.fromDocName,e.toDocName])}function gO(e,t){let n=e.kind===`folder`||e.docExt===void 0?e.path:UD(e.path,e.docExt);return nh(t.contentDir,n,t.pathSeparator)}function _O(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 vO(e,t){return!!t&&(e===t||e.startsWith(`${t}/`))}function yO(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)(nu,{"data-slot":`context-menu`,...n}),t[2]=n,t[3]=r),r}function bO(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=mi(`select-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(ru,{"data-slot":`context-menu-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function xO(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)(uu,{"data-slot":`context-menu-sub`,...n}),t[2]=n,t[3]=r),r}function SO(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=mi(`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)(iu,{children:(0,Z.jsx)(au,{"data-slot":`context-menu-content`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function CO(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=mi(`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)(ou,{"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 wO(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=mi(`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)(No,{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)(du,{"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 TO(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=mi(`z-50 min-w-32 origin-(--radix-context-menu-content-transform-origin) overflow-hidden rounded-lg border bg-popover p-1 text-popover-foreground shadow-lg 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)(fu,{"data-slot":`context-menu-sub-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function EO(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=mi(`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)(cu,{children:(0,Z.jsx)(go,{})})}),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)(su,{"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 DO(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=mi(`-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)(lu,{"data-slot":`context-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var OO=[`.md`,`.mdx`],kO=`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`,AO=`z-10 rounded-t-lg rounded-b-none border-border border-b-0 bg-background text-foreground`,jO=mi(AO,`bg-transparent hover:bg-muted focus-visible:bg-muted border-transparent hover:border-border focus-visible:border-border`),MO=`flex h-full min-w-0 flex-1 cursor-pointer items-center overflow-hidden px-3 text-left text-[13px] outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,NO=`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 focus-visible:opacity-100`;function PO(e){return mi(NO,e?`opacity-100`:`pointer-events-none opacity-0 group-focus-within:pointer-events-auto group-focus-within:opacity-100 group-hover:pointer-events-auto group-hover:opacity-100`)}function FO(e){return e.replace(/[^A-Za-z0-9_-]/g,`-`)}function IO(e){let t=Tr(e);window.location.hash!==t&&(window.location.hash=t)}function LO(e){Math.abs(e.deltaX)>=Math.abs(e.deltaY)||e.currentTarget.scrollWidth<=e.currentTarget.clientWidth||(e.preventDefault(),e.currentTarget.scrollLeft+=e.deltaY)}function RO(e,t){let n=[t,...OO].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 zO(e){let t=(0,$.c)(26),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({tabId:o,disabled:n,ref:r,style:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]!==n||t[7]!==o?(s={id:o,disabled:n},t[6]=n,t[7]=o,t[8]=s):s=t[8];let{attributes:c,listeners:l,setNodeRef:u,transform:d,transition:f,isDragging:p}=ia(s),m;t[9]===d?m=t[10]:(m=Ui.Transform.toString(d),t[9]=d,t[10]=m);let h=p?.5:i?.opacity,g=p?1:i?.zIndex,_;t[11]!==i||t[12]!==m||t[13]!==h||t[14]!==g||t[15]!==f?(_={...i,transform:m,transition:f,opacity:h,zIndex:g},t[11]=i,t[12]=m,t[13]=h,t[14]=g,t[15]=f,t[16]=_):_=t[16];let v=_,y;t[17]!==r||t[18]!==u?(y=function(e){u(e),typeof r==`function`?r(e):r&&`current`in r&&(r.current=e)},t[17]=r,t[18]=u,t[19]=y):y=t[19];let b=y,x;return t[20]!==c||t[21]!==b||t[22]!==l||t[23]!==a||t[24]!==v?(x=(0,Z.jsx)(`div`,{ref:b,style:v,...a,...c,...l}),t[20]=c,t[21]=b,t[22]=l,t[23]=a,t[24]=v,t[25]=x):x=t[25],x}function BO(e){let t=(0,$.c)(48),{children:n,closeTab:r,closeTabs:i,canPin:a,disabled:o,openTabs:s,pinTab:c,pinnedTabIds:l,tabId:u,unpinTab:d}=e,f=a===void 0?!0:a;if(o!==void 0&&o)return n;let p;t[0]!==f||t[1]!==l||t[2]!==u?(p=f&&l.includes(u),t[0]=f,t[1]=l,t[2]=u,t[3]=p):p=t[3];let m=p,h;if(t[4]!==s||t[5]!==l||t[6]!==u){let e;t[8]===u?e=t[9]:(e=e=>e!==u,t[8]=u,t[9]=e),h=je(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?(_=je(s,l),t[10]=s,t[11]=l,t[12]=_):_=t[12];let v=_,y=l.length?`Close all unpinned`:`Close all`,b;t[13]===n?b=t[14]:(b=(0,Z.jsx)(bO,{asChild:!0,children:n}),t[13]=n,t[14]=b);let x;t[15]!==r||t[16]!==u?(x=()=>r(u),t[15]=r,t[16]=u,t[17]=x):x=t[17];let S;t[18]!==m||t[19]!==x?(S=(0,Z.jsx)(CO,{disabled:m,onSelect:x,children:`Close`}),t[18]=m,t[19]=x,t[20]=S):S=t[20];let C=g.length===0,w;t[21]!==i||t[22]!==g?(w=()=>{i(g)},t[21]=i,t[22]=g,t[23]=w):w=t[23];let T;t[24]!==w||t[25]!==C?(T=(0,Z.jsx)(CO,{disabled:C,onSelect:w,children:`Close others`}),t[24]=w,t[25]=C,t[26]=T):T=t[26];let E=v.length===0,D;t[27]!==v||t[28]!==i?(D=()=>{i(v)},t[27]=v,t[28]=i,t[29]=D):D=t[29];let O;t[30]!==y||t[31]!==E||t[32]!==D?(O=(0,Z.jsx)(CO,{disabled:E,onSelect:D,children:y}),t[30]=y,t[31]=E,t[32]=D,t[33]=O):O=t[33];let k;t[34]!==f||t[35]!==m||t[36]!==c||t[37]!==u||t[38]!==d?(k=f&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(DO,{}),(0,Z.jsx)(CO,{onSelect:()=>m?d(u):c(u),children:m?`Unpin tab`:`Pin tab`})]}),t[34]=f,t[35]=m,t[36]=c,t[37]=u,t[38]=d,t[39]=k):k=t[39];let A;t[40]!==T||t[41]!==O||t[42]!==k||t[43]!==S?(A=(0,Z.jsxs)(SO,{className:`min-w-40`,children:[S,T,O,k]}),t[40]=T,t[41]=O,t[42]=k,t[43]=S,t[44]=A):A=t[44];let j;return t[45]!==A||t[46]!==b?(j=(0,Z.jsxs)(yO,{children:[b,A]}),t[45]=A,t[46]=b,t[47]=j):j=t[47],j}function VO(e){let t=(0,$.c)(14),{accessibleLabel:n,closeTab:r,isPinned:i,tabId:a,unpinTab:o}=e;if(i){let e=`Unpin ${n}`,r;t[0]!==a||t[1]!==o?(r=e=>{e.stopPropagation(),o(a)},t[0]=a,t[1]=o,t[2]=r):r=t[2];let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(jc,{"aria-hidden":`true`}),t[3]=i):i=t[3];let s;return t[4]!==e||t[5]!==r?(s=(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":e,className:`mr-1.5 text-primary! hover:bg-primary/10!`,onClick:r,children:i}),t[4]=e,t[5]=r,t[6]=s):s=t[6],s}let s=`Close ${n}`,c;t[7]!==r||t[8]!==a?(c=e=>{e.stopPropagation(),r(a)},t[7]=r,t[8]=a,t[9]=c):c=t[9];let l;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(_o,{"aria-hidden":`true`}),t[10]=l):l=t[10];let u;return t[11]!==s||t[12]!==c?(u=(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":s,className:`mr-1.5`,onClick:c,children:l}),t[11]=s,t[12]=c,t[13]=u):u=t[13],u}function HO(){let e=(0,$.c)(62),{activeDocName:t,activeTabId:n,activeNewTabId:r,activeTarget:i,activateTab:a,activateNewTab:o,closeAndClearForRename:s,closeNewTab:c,closeTab:u,closeTabs:d,getPoolActiveDocName:f,isNewTabActive:p,newTabIds:m,openNewTab:h,openTabs:g,pinTab:_,pinnedTabIds:v,remapTabsForRename:y,reorderTabs:b,unpinTab:x,visibleTabIds:S}=ot(),{pageMeta:C}=qr(),w=(0,Q.useRef)(null),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(!1),N=(0,Q.useRef)(null),P=(0,Q.useRef)(!1),F=(0,Q.useRef)(!1),I=(0,Q.useRef)(null),L=(0,Q.useRef)(t),R;e[0]!==n||e[1]!==t||e[2]!==i?(R=n??(i?nt(i):t?Je(t):null),e[0]=n,e[1]=t,e[2]=i,e[3]=R):R=e[3];let z=R,B;e[4]!==r||e[5]!==z||e[6]!==p||e[7]!==m||e[8]!==g?(B=p?`${r??`__new-tab__`}\u0000${g.join(`\0`)}\u0000${m.join(`\0`)}`:z?`${z}\u0000${g.join(`\0`)}`:``,e[4]=r,e[5]=z,e[6]=p,e[7]=m,e[8]=g,e[9]=B):B=e[9];let V=B,H,U;e[10]===t?(H=e[11],U=e[12]):(H=()=>{L.current=t},U=[t],e[10]=t,e[11]=H,e[12]=U),(0,Q.useEffect)(H,U);let W,G;e[13]===V?(W=e[14],G=e[15]):(W=()=>{V&&(w.current?.querySelector(`[data-active-tab="true"]`))?.scrollIntoView({block:`nearest`,inline:`nearest`})},G=[V],e[13]=V,e[14]=W,e[15]=G),(0,Q.useEffect)(W,G);let K,q;e[16]===T?(K=e[17],q=e[18]):(K=()=>{T&&(N.current?.focus(),N.current?.select())},q=[T],e[16]=T,e[17]=K,e[18]=q),(0,Q.useEffect)(K,q);let ee,te;e[19]!==g||e[20]!==T?(ee=()=>{!T||g.includes(T.tabId)||(F.current=!0,I.current=null,E(null),O(``),A(null),M(!1))},te=[g,T],e[19]=g,e[20]=T,e[21]=ee,e[22]=te):(ee=e[21],te=e[22]),(0,Q.useEffect)(ee,te);let ne=function(e,t){let n=t.split(`/`);F.current=!1,I.current=null,E({docName:t,tabId:e}),O(n[n.length-1]),A(null)},re=function(){F.current=!0,I.current=null,E(null),O(``),A(null),M(!1)},ie=async function(){if(F.current){F.current=!1;return}if(P.current)return;let e=T?.docName;if(!e){re();return}let t=lO(`file`,RO(D,C.get(e)?.docExt??`.md`)),n=e.split(`/`),r=n[n.length-1];if(t===r){re();return}if(t===I.current){N.current?.focus();return}if(!uO(t)){A(`Name can’t be empty, ".", "..", or contain / or \\`),N.current?.focus();return}let i=dO({kind:`file`,path:e,name:r},t);P.current=!0,M(!0),A(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(F.current){M(!1),P.current=!1;return}let r=await l(n,`Server error (HTTP ${n.status})`);if(!r.ok){A(r.title),M(!1),P.current=!1,I.current=t,N.current?.focus();return}let a=Ze(Zn,r.body,`rename-path:tab`,{renamed:[]}).renamed,o=L.current,c=mO(o,a),u=!0;try{let e=hO(a,f());await Promise.all(e.map(e=>s(e))),y(a),Fr([`files`,`backlinks`,`graph`])}catch(n){let r=n;u=!1,console.warn(`[EditorTabs] post-rename reconciliation failed`,{err:r,docName:e,newDocName:i,normalized:t}),X.error(`Rename succeeded but the tabstrip may be out of date — refresh to resync`)}F.current=!0,E(null),O(``),A(null),M(!1),P.current=!1,I.current=null,u&&c&&c!==o&&IO(c)}catch(n){console.warn(`[EditorTabs] rename failed`,{err:n,docName:e,newDocName:i,normalized:t}),A(`Network error — please try again`),M(!1),P.current=!1,I.current=t,N.current?.focus()}},ae=typeof window<`u`&&window.okDesktop!=null,oe;e[23]===m?oe=e[24]:(oe=new Set(m),e[23]=m,e[24]=oe);let se=oe,le;e[25]!==c||e[26]!==d||e[27]!==se?(le=function(e){let t=[],n=[];for(let r of e)se.has(r)?n.push(r):t.push(r);t.length>0&&d(t);for(let e of n)c(e)},e[25]=c,e[26]=d,e[27]=se,e[28]=le):le=e[28];let J=le,ue;e[29]===Symbol.for(`react.memo_cache_sentinel`)?(ue={activationConstraint:{distance:8}},e[29]=ue):ue=e[29];let de;e[30]===Symbol.for(`react.memo_cache_sentinel`)?(de={coordinateGetter:Ra},e[30]=de):de=e[30];let fe=po(fa(ea,ue),fa(Xi,de)),pe;e[31]!==b||e[32]!==S?(pe=function(e){let t=String(e.active.id),n=e.over?String(e.over.id):null;if(!n||t===n)return;let r=S.indexOf(t),i=S.indexOf(n);r<0||i<0||r===i||b(Ba([...S],r,i),t)},e[31]=b,e[32]=S,e[33]=pe):pe=e[33];let me=pe,he;e[34]===Symbol.for(`react.memo_cache_sentinel`)?(he=mi(`pl-2 flex h-12 min-w-0 touch-manipulation flex-1 items-end gap-1 overflow-x-auto overflow-y-hidden overscroll-x-contain scroll-fade-mask-x [scrollbar-width:none]`,ae&&`[-webkit-app-region:drag]`),e[34]=he):he=e[34];let ge=LO,_e=la,ve=ra,ye;e[35]===Symbol.for(`react.memo_cache_sentinel`)?(ye={container:typeof document<`u`?document.body:void 0},e[35]=ye):ye=e[35];let be=sa,xe;e[36]===S?xe=e[37]:(xe=[...S],e[36]=S,e[37]=xe);let Se=Vi,Ce=S.map(e=>{if(se.has(e)){let t=e===r;return(0,Z.jsx)(BO,{tabId:e,canPin:!1,openTabs:S,closeTab:c,closeTabs:J,pinTab:_,pinnedTabIds:v,unpinTab:x,children:(0,Z.jsxs)(zO,{tabId:e,"aria-current":t?`page`:void 0,"data-active-tab":t?`true`:void 0,className:mi(kO,t?AO:jO,ae&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),c(e))},onClick:t=>{t.target===t.currentTarget&&o(e)},children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Activate new tab`,className:MO,onClick:()=>o(e),children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:`New tab`})}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Close new tab`,className:PO(t),onClick:t=>{t.stopPropagation(),c(e)},children:(0,Z.jsx)(_o,{"aria-hidden":`true`,className:`size-3.5`})})]})},e)}let t=yt(e),n=e===z,i=v.includes(e);if(t.kind===`folder`){let{baseName:r,label:o,prefix:s}=wt(t.folderPath,`/`),c=`${s}${o}`;return(0,Z.jsx)(BO,{tabId:e,openTabs:S,closeTab:u,closeTabs:J,pinTab:_,pinnedTabIds:v,unpinTab:x,children:(0,Z.jsxs)(zO,{tabId:e,"aria-current":n?`page`:void 0,"data-active-tab":n?`true`:void 0,className:mi(kO,n?AO:jO,ae&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!i&&u(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":c,className:MO,onClick:()=>{a(e)},children:[s&&(0,Z.jsx)(`span`,{className:mi(`min-w-0 flex-1 truncate`,n&&`text-muted-foreground`),children:s}),(0,Z.jsxs)(`span`,{className:mi(`flex min-w-0 items-center`,s?`max-w-[70%] shrink-0`:`flex-1`),children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:r}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:`/`})]})]}),(0,Z.jsx)(VO,{accessibleLabel:c,closeTab:u,isPinned:i,tabId:e,unpinTab:x})]})},e)}if(t.kind===`asset`){let{baseName:r,label:o,prefix:s}=wt(t.assetPath,``),c=`${s}${o}`;return(0,Z.jsx)(BO,{tabId:e,openTabs:S,closeTab:u,closeTabs:J,pinTab:_,pinnedTabIds:v,unpinTab:x,children:(0,Z.jsxs)(zO,{tabId:e,"aria-current":n?`page`:void 0,"data-active-tab":n?`true`:void 0,className:mi(kO,n?AO:jO,ae&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!i&&u(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":c,className:MO,onClick:()=>{a(e)},children:[s?(0,Z.jsx)(`span`,{className:mi(`min-w-0 flex-1 truncate text-muted-foreground/60`,n&&`text-muted-foreground`),children:s}):null,(0,Z.jsx)(`span`,{className:mi(`min-w-0 truncate`,s?`max-w-[70%] shrink-0`:`flex-1`),children:r})]}),(0,Z.jsx)(VO,{accessibleLabel:c,closeTab:u,isPinned:i,tabId:e,unpinTab:x})]})},e)}let s=t.docName,l=C.get(s)?.docExt??`.md`,{baseName:d,extension:f,label:p,prefix:m}=wt(s,l),h=`${m}${p}`,g=l===`.md`||l===`.mdx`,y=T?.tabId===e,b=`editor-tab-rename-error-${FO(s)}`;return(0,Z.jsx)(BO,{disabled:y,tabId:e,openTabs:S,closeTab:u,closeTabs:J,pinTab:_,pinnedTabIds:v,unpinTab:x,children:(0,Z.jsx)(zO,{tabId:e,disabled:y,"aria-current":n?`page`:void 0,"data-active-tab":n?`true`:void 0,className:mi(kO,n?AO:jO,y&&k&&`border-destructive`,ae&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!i&&u(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:y?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(AC,{className:`h-full min-w-0 flex-1 rounded-none border-0 bg-transparent dark:bg-transparent`,children:[(0,Z.jsx)(FC,{ref:N,value:D,disabled:j,"aria-label":`Rename ${p}`,"aria-invalid":k?!0:void 0,"aria-describedby":k?b:void 0,"aria-busy":j||void 0,title:k??s,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=>{O(RO(e.target.value,l)),A(null),I.current=null},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),ie()):e.key===`Escape`&&(e.preventDefault(),re())},onBlur:ie}),(0,Z.jsx)(MC,{align:`inline-end`,"aria-hidden":`true`,className:`pr-2 text-xs`,children:(0,Z.jsx)(PC,{className:`text-muted-foreground/60 text-xs`,children:l})})]}),k?(0,Z.jsx)(`span`,{id:b,role:`alert`,className:`sr-only`,children:k}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":h,title:h,className:MO,onClick:()=>{a(e)},onDoubleClick:t=>{t.preventDefault(),t.stopPropagation(),ne(e,s)},children:(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:d}),!g&&(0,Z.jsx)(`span`,{className:`shrink-0`,children:f})]})}),(0,Z.jsx)(VO,{accessibleLabel:h,closeTab:u,isPinned:i,tabId:e,unpinTab:x})]})})},e)}),we;e[38]!==be||e[39]!==xe||e[40]!==Se||e[41]!==Ce?(we=(0,Z.jsx)(be,{items:xe,strategy:Se,children:Ce}),e[38]=be,e[39]=xe,e[40]=Se,e[41]=Ce,e[42]=we):we=e[42];let Te;e[43]!==_e||e[44]!==me||e[45]!==fe||e[46]!==ve||e[47]!==ye||e[48]!==we?(Te=(0,Z.jsx)(_e,{sensors:fe,collisionDetection:ve,onDragEnd:me,accessibility:ye,children:we}),e[43]=_e,e[44]=me,e[45]=fe,e[46]=ve,e[47]=ye,e[48]=we,e[49]=Te):Te=e[49];let Ee;e[50]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=mi(`first:mb-3 mb-1.5`,ae&&`[-webkit-app-region:no-drag]`),e[50]=Ee):Ee=e[50];let De;e[51]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,Z.jsx)(ce,{"aria-hidden":`true`}),e[51]=De):De=e[51];let Oe;e[52]===h?Oe=e[53]:(Oe=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{type:`button`,size:`icon-xs`,variant:`ghost`,"aria-label":`New tab`,className:Ee,onClick:h,children:De})}),e[52]=h,e[53]=Oe);let ke;e[54]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,Z.jsx)(vn,{children:`New tab`}),e[54]=ke):ke=e[54];let Ae;e[55]===Oe?Ae=e[56]:(Ae=(0,Z.jsxs)(yn,{children:[Oe,ke]}),e[55]=Oe,e[56]=Ae);let je;return e[57]!==he||e[58]!==ge||e[59]!==Te||e[60]!==Ae?(je=(0,Z.jsxs)(`div`,{ref:w,className:he,onWheel:ge,children:[Te,Ae]}),e[57]=he,e[58]=ge,e[59]=Te,e[60]=Ae,e[61]=je):je=e[61],je}function UO(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 WO(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 GO=[{label:`Documentation`,href:`https://openknowledge.ai/docs`,icon:we},{label:`GitHub`,href:`https://github.com/inkeep/open-knowledge`,icon:Sd},{label:`Website`,href:`https://openknowledge.ai/`,icon:Mr},{label:`Discord`,href:`https://go.inkeep.com/ok-discord`,icon:UO},{label:`Twitter`,href:`https://x.com/inkeep`,icon:WO}],KO=()=>{let e=(0,$.c)(5),[t,n]=(0,Q.useState)(!1),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(ne,{asChild:!0,children:(0,Z.jsxs)(Y,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[(0,Z.jsx)(ve,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Resources`})]})})}),(0,Z.jsx)(vn,{children:`Resources`})]}),e[0]=r):r=e[0];let i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs mb-1`,children:`Resources`}),e[1]=i):i=e[1];let a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsxs)(G,{align:`end`,className:`w-64 p-3`,children:[i,(0,Z.jsx)(`nav`,{"aria-label":`Resources`,children:(0,Z.jsx)(`ul`,{className:`space-y-0.5`,children:GO.map(qO)})})]}),e[2]=a):a=e[2];let o;return e[3]===t?o=e[4]:(o=(0,Z.jsxs)(H,{open:t,onOpenChange:n,children:[r,a]}),e[3]=t,e[4]=o),o};function qO(e){let{label:t,href:n,icon:r}=e;return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>Hi(e,n),onAuxClick:e=>Hi(e,n),className:`flex items-center gap-2.5 rounded-md px-2 py-1.5 text-sm text-muted-foreground transition-colors hover:bg-azure-900/5 dark:hover:bg-white/20 hover:text-primary`,children:[(0,Z.jsx)(r,{"aria-hidden":`true`,className:`size-4 shrink-0`}),t]})},n)}function JO(e){let t=(0,$.c)(60),{input:n}=e,{states:r,refresh:i}=Oh(),{dispatch:a}=_h(),[o,s]=(0,Q.useState)(!1),c=typeof window<`u`&&window.okDesktop!=null,l;t[0]===i?l=t[1]:(l=e=>{s(e),e&&i()},t[0]=i,t[1]=l);let u=l,d=n===null,f;t[2]===n?f=t[3]:(f=n!==null&&n.docContext!==null?$r(n.docContext.relativePath):``,t[2]=n,t[3]=f);let p=f,m;t[4]!==a||t[5]!==n?(m=e=>{n!==null&&a(e.id,n)},t[4]=a,t[5]=n,t[6]=m):m=t[6];let h=m,g,_,v,y,b,x,S,C,w,T,E,D;if(t[7]!==u||t[8]!==h||t[9]!==n||t[10]!==o||t[11]!==p||t[12]!==r||t[13]!==d){let e;t[26]===r?e=t[27]:(e=e=>r[e.id]?.installed===!0,t[26]=r,t[27]=e);let i=xm.filter(e);v=r[`claude-code`]?.installed===!0;let a;t[28]!==n||t[29]!==p?(a=()=>{n!==null&&qx(p)},t[28]=n,t[29]=p,t[30]=a):a=t[30],y=a,_=va,D=o,b=u;let s;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(Fi,{className:`size-4`}),t[31]=s):s=t[31];let l;t[32]===d?l=t[33]:(l=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(ba,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,"aria-label":`Open with AI`,disabled:d,className:`text-muted-foreground`,"data-testid":`open-in-agent-trigger`,children:s})})}),t[32]=d,t[33]=l);let f;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(vn,{children:`Open with AI`}),t[34]=f):f=t[34],t[35]===l?x=t[36]:(x=(0,Z.jsxs)(yn,{children:[l,f]}),t[35]=l,t[36]=x),g=_a,S=`end`,C=`min-w-[220px]`,w=`open-in-agent-menu`,t[37]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(Qi,{className:`font-mono font-normal tracking-wide uppercase text-muted-foreground text-xs`,children:`Open with AI`}),t[37]=T):T=t[37];let m;t[38]!==h||t[39]!==p||t[40]!==r?(m=e=>{let t=r[e.id];return(0,Z.jsx)(Jx,{target:e,installState:t,isElectronHost:c,prompt:p,onSelect:()=>h(e)},e.id)},t[38]=h,t[39]=p,t[40]=r,t[41]=m):m=t[41],E=i.map(m),t[7]=u,t[8]=h,t[9]=n,t[10]=o,t[11]=p,t[12]=r,t[13]=d,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S,t[21]=C,t[22]=w,t[23]=T,t[24]=E,t[25]=D}else g=t[14],_=t[15],v=t[16],y=t[17],b=t[18],x=t[19],S=t[20],C=t[21],w=t[22],T=t[23],E=t[24],D=t[25];let O;t[42]!==v||t[43]!==y||t[44]!==n?(O=v?null:(0,Z.jsxs)(ya,{onSelect:y,disabled:n===null,"data-testid":`open-in-agent-claude-web-fallback`,"aria-label":`Open in claude.ai, opens in browser with prompt pre-filled`,children:[(0,Z.jsx)(he,{className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:`Open in claude.ai →`}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`opens in browser`})]}),t[42]=v,t[43]=y,t[44]=n,t[45]=O):O=t[45];let k;t[46]!==g||t[47]!==O||t[48]!==S||t[49]!==C||t[50]!==w||t[51]!==T||t[52]!==E?(k=(0,Z.jsxs)(g,{align:S,className:C,"data-testid":w,children:[T,E,O]}),t[46]=g,t[47]=O,t[48]=S,t[49]=C,t[50]=w,t[51]=T,t[52]=E,t[53]=k):k=t[53];let A;return t[54]!==_||t[55]!==b||t[56]!==x||t[57]!==k||t[58]!==D?(A=(0,Z.jsxs)(_,{open:D,onOpenChange:b,children:[x,k]}),t[54]=_,t[55]=b,t[56]=x,t[57]=k,t[58]=D,t[59]=A):A=t[59],A}var YO=`/api/share/publish/owners`,XO=`/api/share/publish/name-check`,ZO=`/api/share/publish`,QO=/[A-Za-z0-9._-]/g;function $O(e){return(e.match(QO)?.join(``)??``).replace(/[-.]{2,}/g,e=>e[0]??`-`).replace(/^[-.]+/,``).replace(/[-.]+$/,``)}function ek(e){if(!e)return``;let t=e.replace(/[/\\]+$/g,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n<0?t:t.slice(n+1)}function tk(e){return`https://github.com/orgs/${encodeURIComponent(e)}/policies/applications`}function nk(e,t,n){switch(e){case`name-conflict`:return{banner:`${t}/${n} already exists. Pick a different name.`,next:{kind:`edit-name`}};case`saml-sso`:return{banner:`GitHub denied the request. You may need to authorize Open Knowledge for ${t} in your browser.`,next:{kind:`authorize-org`,authorizeUrl:tk(t)}};case`push-failed`:return{banner:`Created ${t}/${n}, push failed.`,next:{kind:`retry-push`}};case`auth-required`:return{banner:`GitHub sign-in expired. Sign in again to continue.`,next:{kind:`reauth`}};case`init-failed`:return{banner:`Couldn't prepare this project for publish.`,next:{kind:`edit-form`}};case`network`:return{banner:`Couldn't reach GitHub. Try again?`,next:{kind:`edit-form`}};case`no-project`:return{banner:`Open a project first.`,next:{kind:`edit-form`}}}}async function rk(e=fetch){let t=await e(YO,{method:`GET`});if(!t.ok)throw Error(`owners transport ${t.status}`);let n=await t.json(),r=kn.safeParse(n);if(!r.success)throw Error(`owners response shape mismatch`);return r.data}async function ik(e,t,n=fetch){let r=await n(`${XO}?owner=${encodeURIComponent(e)}&name=${encodeURIComponent(t)}`,{method:`GET`});if(!r.ok)throw Error(`name-check transport ${r.status}`);let i=await r.json(),a=Wr.safeParse(i);if(!a.success)throw Error(`name-check response shape mismatch`);return a.data}async function ak(e,t=fetch){let n=await t(ZO,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!n.ok)throw Error(`publish transport ${n.status}`);let r=await n.json(),i=rr.safeParse(r);if(!i.success)throw Error(`publish response shape mismatch`);return i.data}function ok(e,t,n){return e.ok?e.available?{kind:`available`}:{kind:`taken`,owner:t,name:n}:e.error===`auth-required`?{kind:`error`,banner:`GitHub sign-in expired. Sign in again to continue.`}:{kind:`error`,banner:`Couldn't reach GitHub. Try again?`}}function sk(e){return e.submitting||e.owner===null||e.sanitizedName.length===0?!1:e.nameCheck.kind===`available`}async function ck(e,t){await t.runShareAction({docName:e,hasRemote:!0,onClickWhenNoRemote:()=>{}},{clipboardWrite:t.clipboardWrite,toastSuccess:t.toastSuccess,toastError:t.toastError,logEvent:t.logEvent,fetchFn:t.fetchFn})}var lk=`/api/share/construct-url`,uk=`Could not construct share URL.`,dk=`Link ready but could not copy to clipboard.`;async function fk(e,t=fetch){let n=await t(lk,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({docPath:e})});if(!n.ok)throw Error(`construct-url transport ${n.status}`);let r=await n.json(),i=jn.safeParse(r);if(!i.success)throw Error(`construct-url response shape mismatch`);return i.data}function pk(e,t){switch(e){case`detached-head`:return`Switch to a branch to share.`;case`branch-not-on-origin`:return t?`Push ${t} to GitHub before sharing.`:`Push this branch to GitHub before sharing.`;case`non-github-remote`:return`Sharing supports GitHub remotes only.`;case`invalid-path`:return`Can't share this path.`;case`no-remote`:return`This project has no GitHub remote.`}}async function mk(e,t){if(!e.hasRemote)return e.onClickWhenNoRemote(),{kind:`opened-wizard`};let n=_r(e.docName),r;try{r=await fk(n,t.fetchFn)}catch{return t.toastError(uk),{kind:`transport-error`}}if(r.ok){try{await t.clipboardWrite(r.shareUrl)}catch{return t.toastError(dk),t.logEvent(`[share] action=link-construct result=clipboard-failed`),{kind:`clipboard-failed`,shareUrl:r.shareUrl}}return t.toastSuccess(`Link copied.`),t.logEvent(`[share] action=link-construct`),{kind:`copied`,shareUrl:r.shareUrl,branch:r.branch}}if(r.error===`no-remote`)return e.onClickWhenNoRemote(),{kind:`opened-wizard`};let i=r.branch;return t.toastError(pk(r.error,i)),{kind:`business-error`,error:r.error,branch:i}}var hk=500;function gk(e){let t=(0,$.c)(94),{open:n,onOpenChange:r}=e,i=km(),{activeDocName:a}=ot(),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(`private`),[v,y]=(0,Q.useState)(``),x;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x={kind:`idle`},t[0]=x):x=t[0];let[S,C]=(0,Q.useState)(x),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(!1),A=(0,Q.useRef)(null),j=(0,Q.useRef)(null),M=(0,Q.useRef)(null),N;t[1]===m?N=t[2]:(N=$O(m),t[1]=m,t[2]=N);let P=N,F=o?.find(e=>e.login===f)??null,I;t[3]===f?I=t[4]:(I=async function(){l(!0),d(null);try{let e=await rk();if(!e.ok){e.error===`auth-required`?(k(!0),d(`Sign in to GitHub to continue.`)):d(`Couldn't reach GitHub. Try again?`),l(!1);return}s(e.owners),e.owners.length>0&&f===``&&p(e.owners[0]?.login??``)}catch{d(`Couldn't reach GitHub. Try again?`)}l(!1)},t[3]=f,t[4]=I);let L=I,R;t[5]!==L||t[6]!==n||t[7]!==o||t[8]!==f||t[9]!==i?.contentDir?(R=()=>{n&&(C({kind:`idle`}),D(null),T(!1),d(null),h($O(ek(i?.contentDir??``))),_(`private`),y(``),o===null?L():f===``&&o.length>0&&p(o[0]?.login??``))},t[5]=L,t[6]=n,t[7]=o,t[8]=f,t[9]=i?.contentDir,t[10]=R):R=t[10];let z;t[11]===n?z=t[12]:(z=[n],t[11]=n,t[12]=z),(0,Q.useEffect)(R,z);let V,H;t[13]!==n||t[14]!==P||t[15]!==f?(V=()=>{if(n){if(A.current!==null&&clearTimeout(A.current),f===``||P===``){C({kind:`idle`});return}return C({kind:`pending`}),A.current=setTimeout(async()=>{let e=f,t=P;j.current=`${e}|${t}`,C({kind:`checking`});try{let n=await ik(e,t);if(j.current!==`${e}|${t}`)return;C(ok(n,e,t))}catch{if(j.current!==`${e}|${t}`)return;C({kind:`error`,banner:`Couldn't reach GitHub. Try again?`})}},hk),()=>{A.current!==null&&(clearTimeout(A.current),A.current=null)}}},H=[n,f,P],t[13]=n,t[14]=P,t[15]=f,t[16]=V,t[17]=H):(V=t[16],H=t[17]),(0,Q.useEffect)(V,H);let U;t[18]===L?U=t[19]:(U=function(){k(!1),d(null),L()},t[18]=L,t[19]=U);let W=U,G=async function(){if(sk({owner:F,sanitizedName:P,nameCheck:S,submitting:w})){T(!0),D(null);try{let e=await ak({owner:f,name:P,visibility:g,description:v.trim().length>0?v.trim():void 0});if(e.ok){r(!1),a?await ck(a,{runShareAction:mk,clipboardWrite:xk,toastSuccess:bk,toastError:yk,logEvent:vk}):X.success(`Published to ${e.ownerLogin}/${e.repoName}.`),T(!1);return}let t=nk(e.error,f,P);D({message:t.banner,next:t.next}),t.next.kind===`edit-name`?(M.current?.focus(),M.current?.select()):t.next.kind===`reauth`&&k(!0)}catch{D({message:`Couldn't reach GitHub. Try again?`,next:{kind:`edit-form`}})}T(!1)}},K;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(K=function(e){let t=window.okDesktop?.shell?.openExternal;t?t(e):window.open(e,`_blank`,`noopener`)},t[20]=K):K=t[20];let q=K,te;t[21]===r?te=t[22]:(te=function(){r(!1)},t[21]=r,t[22]=te);let ne=te,re=!sk({owner:F,sanitizedName:P,nameCheck:S,submitting:w}),ie;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Z.jsxs)(Ao,{children:[(0,Z.jsx)(bo,{children:`Publish to GitHub`}),(0,Z.jsx)(vo,{children:`Sharing a doc needs a GitHub repository. Create one for this project.`})]}),t[23]=ie):ie=t[23];let ae;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Z.jsx)(Go,{htmlFor:`publish-owner`,children:`Owner`}),t[24]=ae):ae=t[24];let oe;t[25]!==L||t[26]!==o||t[27]!==u||t[28]!==c||t[29]!==f?(oe=(0,Z.jsxs)(`fieldset`,{className:`flex flex-col gap-1.5`,children:[ae,c&&o===null?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Z.jsx)(ue,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),` Loading...`]}):u?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm text-destructive`,children:u}),(0,Z.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>L(),children:`Retry`})]}):(0,Z.jsxs)(Ye,{value:f,onValueChange:p,children:[(0,Z.jsx)(ee,{id:`publish-owner`,"data-testid":`publish-owner-trigger`,"aria-label":`Owner`,children:(0,Z.jsx)(b,{placeholder:`Pick an owner`})}),(0,Z.jsx)(B,{children:(o??[]).map(_k)})]})]}),t[25]=L,t[26]=o,t[27]=u,t[28]=c,t[29]=f,t[30]=oe):oe=t[30];let se;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Z.jsx)(Go,{htmlFor:`publish-name`,children:`Repository name`}),t[31]=se):se=t[31];let ce,le;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(ce=e=>h(e.target.value),le=()=>{j.current=null},t[32]=ce,t[33]=le):(ce=t[32],le=t[33]);let J;t[34]===m?J=t[35]:(J=(0,Z.jsx)(Po,{id:`publish-name`,ref:M,"data-testid":`publish-name`,value:m,onChange:ce,onBlur:le,placeholder:`my-knowledge-base`,autoComplete:`off`,spellCheck:!1}),t[34]=m,t[35]=J);let de;t[36]===P?de=t[37]:(de=P?(0,Z.jsxs)(Z.Fragment,{children:[`Will be created as `,(0,Z.jsx)(`code`,{className:`font-mono`,children:P})]}):`Pick a name`,t[36]=P,t[37]=de);let fe;t[38]===de?fe=t[39]:(fe=(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:de}),t[38]=de,t[39]=fe);let pe;t[40]===S?pe=t[41]:(pe=(0,Z.jsx)(Ck,{status:S}),t[40]=S,t[41]=pe);let me;t[42]!==fe||t[43]!==pe?(me=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs`,"aria-live":`polite`,children:[fe,pe]}),t[42]=fe,t[43]=pe,t[44]=me):me=t[44];let he;t[45]!==J||t[46]!==me?(he=(0,Z.jsxs)(`fieldset`,{className:`flex flex-col gap-1.5`,children:[se,J,me]}),t[45]=J,t[46]=me,t[47]=he):he=t[47];let ge;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,Z.jsx)(Go,{children:`Visibility`}),t[48]=ge):ge=t[48];let _e;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(_e=e=>_(e===`public`?`public`:`private`),t[49]=_e):_e=t[49];let ve;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,Z.jsx)(pm,{value:`private`,id:`publish-visibility-private`,"data-testid":`publish-visibility-private`}),t[50]=ve):ve=t[50];let ye;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,Z.jsxs)(Go,{htmlFor:`publish-visibility-private`,className:`flex cursor-pointer items-center gap-2 rounded-md border border-input p-2 text-sm font-normal has-data-checked:border-primary`,children:[ve,(0,Z.jsxs)(`span`,{children:[`Private`,(0,Z.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Only collaborators`})]})]}),t[51]=ye):ye=t[51];let be;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,Z.jsx)(pm,{value:`public`,id:`publish-visibility-public`,"data-testid":`publish-visibility-public`}),t[52]=be):be=t[52];let xe;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,Z.jsxs)(Go,{htmlFor:`publish-visibility-public`,className:`flex cursor-pointer items-center gap-2 rounded-md border border-input p-2 text-sm font-normal has-data-checked:border-primary`,children:[be,(0,Z.jsxs)(`span`,{children:[`Public`,(0,Z.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Anyone can see`})]})]}),t[53]=xe):xe=t[53];let Se;t[54]===g?Se=t[55]:(Se=(0,Z.jsxs)(`fieldset`,{className:`flex flex-col gap-1.5`,children:[ge,(0,Z.jsxs)(fm,{value:g,onValueChange:_e,className:`grid-cols-2`,"aria-label":`Visibility`,children:[ye,xe]})]}),t[54]=g,t[55]=Se);let Ce;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,Z.jsx)(Go,{htmlFor:`publish-description`,children:`Description (optional)`}),t[56]=Ce):Ce=t[56];let we;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(we=e=>y(e.target.value),t[57]=we):we=t[57];let Te;t[58]===v?Te=t[59]:(Te=(0,Z.jsxs)(`fieldset`,{className:`flex flex-col gap-1.5`,children:[Ce,(0,Z.jsx)(Cs,{id:`publish-description`,"data-testid":`publish-description`,rows:2,value:v,onChange:we,placeholder:`What is this knowledge base for?`})]}),t[58]=v,t[59]=Te);let Ee;t[60]!==E||t[61]!==q||t[62]!==G?(Ee=E&&(0,Z.jsx)(Sk,{banner:E,onAuthorize:q,onRetryPush:G}),t[60]=E,t[61]=q,t[62]=G,t[63]=Ee):Ee=t[63];let De;t[64]!==oe||t[65]!==he||t[66]!==Se||t[67]!==Te||t[68]!==Ee?(De=(0,Z.jsxs)(Do,{className:`flex flex-col gap-4`,children:[oe,he,Se,Te,Ee]}),t[64]=oe,t[65]=he,t[66]=Se,t[67]=Te,t[68]=Ee,t[69]=De):De=t[69];let Oe;t[70]===ne?Oe=t[71]:(Oe=(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,onClick:ne,children:`Cancel`}),t[70]=ne,t[71]=Oe);let ke;t[72]===w?ke=t[73]:(ke=w?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ue,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),` Publishing...`]}):`Publish & copy link`,t[72]=w,t[73]=ke);let Ae;t[74]!==G||t[75]!==re||t[76]!==ke?(Ae=(0,Z.jsx)(Y,{type:`button`,onClick:G,disabled:re,"data-testid":`publish-submit`,children:ke}),t[74]=G,t[75]=re,t[76]=ke,t[77]=Ae):Ae=t[77];let je;t[78]!==Oe||t[79]!==Ae?(je=(0,Z.jsxs)(Oo,{children:[Oe,Ae]}),t[78]=Oe,t[79]=Ae,t[80]=je):je=t[80];let Me;t[81]!==De||t[82]!==je?(Me=(0,Z.jsxs)(wo,{className:`sm:max-w-lg`,showCloseButton:!1,children:[ie,De,je]}),t[81]=De,t[82]=je,t[83]=Me):Me=t[83];let Ne;t[84]!==r||t[85]!==n||t[86]!==Me?(Ne=(0,Z.jsx)(jo,{open:n,onOpenChange:r,children:Me}),t[84]=r,t[85]=n,t[86]=Me,t[87]=Ne):Ne=t[87];let Pe;t[88]!==O||t[89]!==W?(Pe=(0,Z.jsx)(qu,{open:O,onOpenChange:k,onSuccess:W}),t[88]=O,t[89]=W,t[90]=Pe):Pe=t[90];let Fe;return t[91]!==Ne||t[92]!==Pe?(Fe=(0,Z.jsxs)(Z.Fragment,{children:[Ne,Pe]}),t[91]=Ne,t[92]=Pe,t[93]=Fe):Fe=t[93],Fe}function _k(e){return(0,Z.jsx)(U,{value:e.login,"data-testid":`publish-owner-option-${e.login}`,children:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e.avatarUrl?(0,Z.jsx)(`img`,{src:e.avatarUrl,alt:``,"aria-hidden":!0,className:`size-4 rounded-full`}):null,(0,Z.jsx)(`span`,{children:e.login}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.kind===`user`?`you`:`org`})]})},e.login)}function vk(e){return console.log(e)}function yk(e){return X.error(e)}function bk(e){return X.success(e)}function xk(e){return navigator.clipboard.writeText(e)}function Sk(e){let t=(0,$.c)(13),{banner:n,onAuthorize:r,onRetryPush:i}=e,a=n.next,o;t[0]===n.message?o=t[1]:(o=(0,Z.jsx)(`span`,{children:n.message}),t[0]=n.message,t[1]=o);let s;t[2]!==a.authorizeUrl||t[3]!==a.kind||t[4]!==r?(s=a.kind===`authorize-org`&&(0,Z.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,className:`self-start`,"data-testid":`publish-authorize-org`,onClick:()=>r(a.authorizeUrl),children:[`Authorize in browser `,(0,Z.jsx)(he,{className:`ml-1 size-3`,"aria-hidden":!0})]}),t[2]=a.authorizeUrl,t[3]=a.kind,t[4]=r,t[5]=s):s=t[5];let c;t[6]!==a.kind||t[7]!==i?(c=a.kind===`retry-push`&&(0,Z.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,className:`self-start`,"data-testid":`publish-retry-push`,onClick:i,children:`Retry push`}),t[6]=a.kind,t[7]=i,t[8]=c):c=t[8];let l;return t[9]!==o||t[10]!==s||t[11]!==c?(l=(0,Z.jsxs)(`div`,{role:`alert`,"data-testid":`publish-banner`,className:`flex flex-col gap-2 rounded-md border border-destructive/50 bg-destructive/5 p-3 text-sm`,children:[o,s,c]}),t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}function Ck(e){let t=(0,$.c)(10),{status:n}=e;if(n.kind===`available`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`span`,{"data-testid":`publish-name-check`,"data-status":`available`,className:`flex items-center gap-1 text-emerald-600 dark:text-emerald-400`,children:[(0,Z.jsx)(Xr,{className:`size-3.5`,"aria-hidden":!0}),` Available`]}),t[0]=e):e=t[0],e}if(n.kind===`taken`){let e;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(fe,{className:`size-3.5`,"aria-hidden":!0}),t[1]=e):e=t[1];let r;return t[2]!==n.name||t[3]!==n.owner?(r=(0,Z.jsxs)(`span`,{"data-testid":`publish-name-check`,"data-status":`taken`,className:`flex items-center gap-1 text-destructive`,children:[e,` `,n.owner,`/`,n.name,` already exists`]}),t[2]=n.name,t[3]=n.owner,t[4]=r):r=t[4],r}if(n.kind===`checking`||n.kind===`pending`){let e;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ue,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),t[5]=e):e=t[5];let r;return t[6]===n.kind?r=t[7]:(r=(0,Z.jsxs)(`span`,{"data-testid":`publish-name-check`,"data-status":n.kind,className:`flex items-center gap-1 text-muted-foreground`,children:[e,` Checking...`]}),t[6]=n.kind,t[7]=r),r}if(n.kind===`error`){let e;return t[8]===n.banner?e=t[9]:(e=(0,Z.jsx)(`span`,{"data-testid":`publish-name-check`,"data-status":`error`,className:`text-destructive`,children:n.banner}),t[8]=n.banner,t[9]=e),e}return null}var wk=50,Tk=()=>{let e=(0,$.c)(5),t=(0,Q.useRef)(null),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>{t.current===null&&(t.current=setTimeout(()=>{t.current=null,_C.preload()},wk))},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;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsxs)(Y,{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:()=>{a(),window.location.hash!==`#settings`&&(window.location.hash=Sm)},children:[(0,Z.jsx)(zc,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Settings`})]})}),(0,Z.jsx)(vn,{children:`Settings`})]}),e[4]=c):c=e[4],c};function Ek(e){let t=(0,$.c)(12),{onClickWhenNoRemote:n}=e,{activeDocName:r}=ot(),{status:i}=La(),[a,o]=(0,Q.useState)(!1);if(!r)return null;let s=i?.hasRemote===!0,c;t[0]!==r||t[1]!==a||t[2]!==s||t[3]!==n?(c=async function(){if(!a&&r){o(!0);try{await mk({docName:r,hasRemote:s,onClickWhenNoRemote:n},{clipboardWrite:Ak,toastSuccess:kk,toastError:Ok,logEvent:Dk})}catch{X.error(`Could not construct share URL.`)}o(!1)}},t[0]=r,t[1]=a,t[2]=s,t[3]=n,t[4]=c):c=t[4];let l=c,u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(Bc,{className:`size-3.5`,"aria-hidden":!0}),t[5]=u):u=t[5];let d;t[6]!==a||t[7]!==l?(d=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsxs)(Y,{variant:`ghost`,size:`sm`,"aria-label":`Share doc`,onClick:l,disabled:a,className:`gap-1.5 text-muted-foreground px-1.5`,"data-testid":`share-button`,children:[u,`Share`]})}),t[6]=a,t[7]=l,t[8]=d):d=t[8];let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(vn,{children:`Share`}),t[9]=f):f=t[9];let p;return t[10]===d?p=t[11]:(p=(0,Z.jsxs)(yn,{children:[d,f]}),t[10]=d,t[11]=p),p}function Dk(e){return console.log(e)}function Ok(e){return X.error(e)}function kk(e){return X.success(e)}function Ak(e){return navigator.clipboard.writeText(e)}function jk(e){if(!e)return`never`;let t=Date.now()-new Date(e).getTime();return t<6e4?`just now`:t<36e5?`${Math.floor(t/6e4)} min ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:new Date(e).toLocaleDateString()}async function Mk(e){await fetch(`/api/sync/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({op:e})})}function Nk(e){let t=(0,$.c)(9),{status:n}=e;switch(n.state){case`dormant`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Xs,{className:`size-3.5 text-muted-foreground`}),t[0]=e):e=t[0],e}case`idle`:{if(n.ahead>0||n.behind>0){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Pc,{className:`size-3.5 text-muted-foreground`}),t[1]=e):e=t[1],e}let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Xs,{className:`size-3.5 text-muted-foreground`}),t[2]=e):e=t[2],e}case`fetching`:case`pulling`:case`pushing`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Pc,{className:`size-3.5 text-muted-foreground animate-spin`}),t[3]=e):e=t[3],e}case`conflict`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(dr,{className:`size-3.5 text-amber-500`}),t[4]=e):e=t[4],e}case`offline`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ys,{className:`size-3.5 text-muted-foreground`}),t[5]=e):e=t[5],e}case`auth-error`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Sc,{className:`size-3.5 text-destructive`}),t[6]=e):e=t[6],e}case`disabled`:{let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(dr,{className:`size-3.5 text-amber-500`}),t[7]=e):e=t[7],e}default:{let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Xs,{className:`size-3.5 text-muted-foreground`}),t[8]=e):e=t[8],e}}}function Pk(e){switch(e.state){case`idle`:return e.ahead>0?`↑${e.ahead}`:e.behind>0?`↓${e.behind}`:``;case`fetching`:case`pulling`:case`pushing`:return``;case`conflict`:return e.conflictCount>0?`${e.conflictCount}`:``;case`offline`:return``;case`auth-error`:return``;default:return``}}function Fk(e){switch(e){case`dormant`:return`No git remote`;case`idle`:return`Synced`;case`fetching`:return`Fetching`;case`pulling`:return`Pulling`;case`pushing`:return`Pushing`;case`conflict`:return`Conflict`;case`offline`:return`Offline`;case`auth-error`:return`Sign in required`;case`disabled`:return`Sync disabled`;default:return e}}function Ik(e){switch(e){case`external-changes-pending`:return`External changes pending`;case`dirty-tree`:return`Working tree has uncommitted changes`;case`detached-head`:return`Detached HEAD — checkout a branch to resume`;case`auth-error`:return`Sign in required`;case`protected-branch`:return`Protected branch — cannot push`;default:return e}}function Lk(e){return e.syncEnabled?e.state===`idle`?e.ahead>0&&e.behind>0?`${e.ahead} ahead, ${e.behind} behind`:e.ahead>0?`${e.ahead} ahead`:e.behind>0?`${e.behind} behind`:`Synced`:e.state===`conflict`&&e.conflictCount>0?`${e.conflictCount} conflict${e.conflictCount===1?``:`s`}`:Fk(e.state):`Sync off`}function Rk(e){let t=(0,$.c)(76),{status:n,onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a}=e,{projectLocalConfig:o,projectLocalSynced:c}=Ga(),l=o?.autoSync?.enabled??!1,{confirmOpen:u,setConfirmOpen:d,onToggleRequest:f,onConfirm:p}=Sa(da()),m;t[0]===n?m=t[1]:(m=(0,Z.jsx)(Nk,{status:n}),t[0]=n,t[1]=m);let h;t[2]===n.state?h=t[3]:(h=Fk(n.state),t[2]=n.state,t[3]=h);let g;t[4]===h?g=t[5]:(g=(0,Z.jsx)(`span`,{className:`text-sm font-medium truncate`,children:h}),t[4]=h,t[5]=g);let _;t[6]!==m||t[7]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[m,g]}),t[6]=m,t[7]=g,t[8]=_):_=t[8];let v=!c,y=l?`Disable sync`:`Enable sync`,b;t[9]!==l||t[10]!==f||t[11]!==v||t[12]!==y?(b=(0,Z.jsx)(s,{checked:l,disabled:v,onCheckedChange:f,"aria-label":y}),t[9]=l,t[10]=f,t[11]=v,t[12]=y,t[13]=b):b=t[13];let x;t[14]!==_||t[15]!==b?(x=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[_,b]}),t[14]=_,t[15]=b,t[16]=x):x=t[16];let S;t[17]!==u||t[18]!==p||t[19]!==d?(S=(0,Z.jsx)(Ua,{open:u,onOpenChange:d,onConfirm:p}),t[17]=u,t[18]=p,t[19]=d,t[20]=S):S=t[20];let C;t[21]===n.error?C=t[22]:(C=n.error&&(0,Z.jsx)(`p`,{className:`text-xs text-destructive`,children:n.error}),t[21]=n.error,t[22]=C);let w;t[23]===n.pausedReason?w=t[24]:(w=n.pausedReason&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Ik(n.pausedReason)}),t[23]=n.pausedReason,t[24]=w);let T;t[25]===n.state?T=t[26]:(T=n.state===`conflict`&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-400`,children:`Sync paused — resolve conflicts to resume.`}),t[25]=n.state,t[26]=T);let E;t[27]!==l||t[28]!==n.lastSyncUtc||t[29]!==n.state?(E=l&&n.state!==`dormant`&&(0,Z.jsxs)(`div`,{children:[`Last synced: `,jk(n.lastSyncUtc)]}),t[27]=l,t[28]=n.lastSyncUtc,t[29]=n.state,t[30]=E):E=t[30];let D;t[31]===n.ahead?D=t[32]:(D=n.ahead>0&&(0,Z.jsxs)(`div`,{children:[n.ahead,` commit`,n.ahead===1?``:`s`,` ahead`]}),t[31]=n.ahead,t[32]=D);let O;t[33]===n.behind?O=t[34]:(O=n.behind>0&&(0,Z.jsxs)(`div`,{children:[n.behind,` commit`,n.behind===1?``:`s`,` behind`]}),t[33]=n.behind,t[34]=O);let k;t[35]===n.conflictCount?k=t[36]:(k=n.conflictCount>0&&(0,Z.jsxs)(`div`,{children:[n.conflictCount,` file`,n.conflictCount===1?``:`s`,` conflicted`]}),t[35]=n.conflictCount,t[36]=k);let A;t[37]===l?A=t[38]:(A=!l&&(0,Z.jsx)(`div`,{children:`Sync is off — your edits will not sync to the remote repository.`}),t[37]=l,t[38]=A);let j;t[39]!==E||t[40]!==D||t[41]!==O||t[42]!==k||t[43]!==A?(j=(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-0.5`,children:[E,D,O,k,A]}),t[39]=E,t[40]=D,t[41]=O,t[42]=k,t[43]=A,t[44]=j):j=t[44];let M;t[45]!==a||t[46]!==n.identityUnresolved?(M=n.identityUnresolved&&a&&(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed p-2`,children:[(0,Z.jsx)($c,{className:`size-3.5 mt-0.5 text-muted-foreground shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground leading-snug`,children:`Git identity isn't set — commits use a default author. Set yours so teammates see your name.`}),(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,className:`self-start`,onClick:a,children:`Set identity`})]})]}),t[45]=a,t[46]=n.identityUnresolved,t[47]=M):M=t[47];let N;t[48]!==l||t[49]!==n.state?(N=l&&n.state!==`dormant`&&n.state!==`disabled`&&n.state!==`auth-error`&&n.state!==`conflict`&&(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,onClick:Bk,children:`Sync now`}),t[48]=l,t[49]=n.state,t[50]=N):N=t[50];let P;t[51]!==l||t[52]!==r||t[53]!==n.state?(P=l&&n.state===`auth-error`&&(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,onClick:r,children:`Sign in`}),t[51]=l,t[52]=r,t[53]=n.state,t[54]=P):P=t[54];let F;t[55]!==l||t[56]!==n.state?(F=l&&n.state===`offline`&&(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,onClick:zk,children:`Retry`}),t[55]=l,t[56]=n.state,t[57]=F):F=t[57];let I;t[58]!==l||t[59]!==i||t[60]!==n.state?(I=l&&n.state===`conflict`&&i&&(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,onClick:i,children:`Review conflicts`}),t[58]=l,t[59]=i,t[60]=n.state,t[61]=I):I=t[61];let L;t[62]!==N||t[63]!==P||t[64]!==F||t[65]!==I?(L=(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1 pt-1`,children:[N,P,F,I]}),t[62]=N,t[63]=P,t[64]=F,t[65]=I,t[66]=L):L=t[66];let R;return t[67]!==C||t[68]!==w||t[69]!==T||t[70]!==j||t[71]!==M||t[72]!==L||t[73]!==x||t[74]!==S?(R=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[x,S,C,w,T,j,M,L]}),t[67]=C,t[68]=w,t[69]=T,t[70]=j,t[71]=M,t[72]=L,t[73]=x,t[74]=S,t[75]=R):R=t[75],R}function zk(){Mk(`sync`)}function Bk(){Mk(`sync`)}function Vk(e){let t=(0,$.c)(36),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a}=n,{status:o,fetchError:s}=La();if(!o){if(s){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":`Sync status unavailable`,disabled:!0,children:(0,Z.jsx)(Ys,{className:`size-3.5`})})}),t[2]=e):e=t[2];let n=s===`network`?`Sync status unavailable — server unreachable.`:`Sync status unavailable — server error.`,r;return t[3]===n?r=t[4]:(r=(0,Z.jsxs)(yn,{children:[e,(0,Z.jsx)(vn,{children:n})]}),t[3]=n,t[4]=r),r}return null}if(o.state===`dormant`&&!o.hasRemote||o.state===`disabled`&&!o.pausedReason)return null;let c;t[5]===o?c=t[6]:(c=Pk(o),t[5]=o,t[6]=c);let l=c,u=!!o.identityUnresolved,d;t[7]===o.state?d=t[8]:(d=Fk(o.state),t[7]=o.state,t[8]=d);let f=`Sync status: ${d}${u?` — git identity unset`:``}`,p;t[9]===o?p=t[10]:(p=(0,Z.jsx)(Nk,{status:o}),t[9]=o,t[10]=p);let m;t[11]===l?m=t[12]:(m=l&&(0,Z.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 text-[9px] leading-none font-medium bg-background border rounded-full px-0.5`,children:l}),t[11]=l,t[12]=m);let h;t[13]!==l||t[14]!==u?(h=!l&&u&&(0,Z.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 size-1.5 rounded-full bg-amber-500 ring-2 ring-background`,"aria-hidden":!0}),t[13]=l,t[14]=u,t[15]=h):h=t[15];let g;t[16]!==f||t[17]!==p||t[18]!==m||t[19]!==h?(g=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(ne,{asChild:!0,children:(0,Z.jsxs)(Y,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground relative`,"aria-label":f,children:[p,m,h]})})}),t[16]=f,t[17]=p,t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;t[21]===o?_=t[22]:(_=Lk(o),t[21]=o,t[22]=_);let v;t[23]===_?v=t[24]:(v=(0,Z.jsx)(vn,{children:_}),t[23]=_,t[24]=v);let y;t[25]!==v||t[26]!==g?(y=(0,Z.jsxs)(yn,{children:[g,v]}),t[25]=v,t[26]=g,t[27]=y):y=t[27];let b;t[28]!==i||t[29]!==a||t[30]!==r||t[31]!==o?(b=(0,Z.jsx)(G,{align:`end`,className:`w-64 p-3`,children:(0,Z.jsx)(Rk,{status:o,onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a})}),t[28]=i,t[29]=a,t[30]=r,t[31]=o,t[32]=b):b=t[32];let x;return t[33]!==y||t[34]!==b?(x=(0,Z.jsxs)(H,{children:[y,b]}),t[33]=y,t[34]=b,t[35]=x):x=t[35],x}function Hk(e){let t=(0,$.c)(45),{onSaveVersion:n,saving:r,onSignIn:i,onSetIdentity:a,onOpenConflictResolver:o}=e,{activeDocName:s,activeTarget:c}=ot(),{state:l}=aD(),u=km(),[d,f]=(0,Q.useState)(!1),p;bb0:{if(c===null){let e;t[0]===u?e=t[1]:(e=ah({workspace:u}),t[0]=u,t[1]=e),p=e;break bb0}if(c.kind===`folder`){if(!u){p=null;break bb0}let e;t[2]!==c.folderPath||t[3]!==u?(e=oh({folderAbsPath:nh(u.contentDir,c.folderPath,u.pathSeparator),folderRelativePath:c.folderPath,workspace:u}),t[2]=c.folderPath,t[3]=u,t[4]=e):e=t[4],p=e;break bb0}let e;t[5]!==s||t[6]!==u?(e=ih({docName:s,workspace:u}),t[5]=s,t[6]=u,t[7]=e):e=t[7],p=e}let m=p,h=typeof window<`u`&&window.okDesktop!=null,g=h&&l===`collapsed`&&`pl-[78px]`,_;t[8]===g?_=t[9]:(_=mi(`flex h-12 shrink-0 items-center bg-muted/35 shadow-[inset_0_-1px_0_var(--border)]`,h&&`[-webkit-app-region:drag]`,g,h&&`motion-safe:transition-[padding] motion-safe:duration-200 motion-safe:ease-linear`),t[8]=g,t[9]=_);let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(uD,{className:mi(`-ml-1 shrink-0 text-muted-foreground`,h&&`[-webkit-app-region:no-drag]`)})}),t[10]=v):v=t[10];let y=l===`expanded`?`Hide Files`:`Show Files`,b;t[11]===y?b=t[12]:(b=(0,Z.jsxs)(yn,{children:[v,(0,Z.jsx)(vn,{children:y})]}),t[11]=y,t[12]=b);let x,S;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(ro,{orientation:`vertical`,className:`mr-1 h-4 shrink-0 data-vertical:self-center`}),S=(0,Z.jsx)(HO,{}),t[13]=x,t[14]=S):(x=t[13],S=t[14]);let C;t[15]===b?C=t[16]:(C=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 px-3`,children:[b,x,S]}),t[15]=b,t[16]=C);let w;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(w=mi(`flex shrink-0 items-center justify-end gap-2 px-3`,h&&`[&>*]:[-webkit-app-region:no-drag]`),t[17]=w):w=t[17];let T;t[18]!==s||t[19]!==n||t[20]!==r?(T=s&&(0,Z.jsxs)(yn,{children:[(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,"aria-label":`Checkpoint version`,onClick:n,disabled:r,className:`text-muted-foreground`,children:(0,Z.jsx)(Rc,{className:`size-3.5`})})}),(0,Z.jsx)(vn,{children:r?`Saving`:`Checkpoint version`})]}),t[18]=s,t[19]=n,t[20]=r,t[21]=T):T=t[21];let E;t[22]===m?E=t[23]:(E=(0,Z.jsx)(JO,{input:m}),t[22]=m,t[23]=E);let D;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(Ek,{onClickWhenNoRemote:()=>f(!0)}),t[24]=D):D=t[24];let O;t[25]===d?O=t[26]:(O=(0,Z.jsx)(gk,{open:d,onOpenChange:f}),t[25]=d,t[26]=O);let k;t[27]!==o||t[28]!==a||t[29]!==i?(k=(0,Z.jsx)(Vk,{onSignIn:i,onSetIdentity:a,onOpenConflictResolver:o}),t[27]=o,t[28]=a,t[29]=i,t[30]=k):k=t[30];let A,j,M,N,P;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(BD,{}),j=(0,Z.jsx)(ro,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),M=(0,Z.jsx)(Zu,{}),N=(0,Z.jsx)(Tk,{}),P=(0,Z.jsx)(KO,{}),t[31]=A,t[32]=j,t[33]=M,t[34]=N,t[35]=P):(A=t[31],j=t[32],M=t[33],N=t[34],P=t[35]);let F;t[36]!==T||t[37]!==E||t[38]!==O||t[39]!==k?(F=(0,Z.jsxs)(`div`,{className:w,children:[T,E,D,O,k,A,j,M,N,P]}),t[36]=T,t[37]=E,t[38]=O,t[39]=k,t[40]=F):F=t[40];let I;return t[41]!==F||t[42]!==_||t[43]!==C?(I=(0,Z.jsxs)(`header`,{className:_,children:[C,F]}),t[41]=F,t[42]=_,t[43]=C,t[44]=I):I=t[44],I}function Uk(){let e=(0,$.c)(32),[t,n]=ig(),[r,i]=(0,Q.useState)(t),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(`auth`),[d,f]=(0,Q.useState)(ky[0].id),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),_=Qa(),{projectLocalConfig:v,projectLocalSynced:y}=Ga(),{activeDocName:b}=ot(),x=!h&&_?.hasRemote===!0&&y===!0&&v!==null&&v.autoSync?.enabled===null,S,C;e[0]===b?(S=e[1],C=e[2]):(S=()=>{let e=function(e){let t=e.detail;t&&b&&bs(b,{kind:`raw-mdx`,detail:t}),i(`source`)};return window.addEventListener(Xh,e),()=>window.removeEventListener(Xh,e)},C=[b],e[0]=b,e[1]=S,e[2]=C),(0,Q.useEffect)(S,C);let w;e[3]===n?w=e[4]:(w=function(e){i(e),n(e)},e[3]=n,e[4]=w);let T=w,E;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(E=async function(){m(!0);try{let e=await fetch(`/api/save-version`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});e.ok?X.success(`Checkpoint saved`):(console.error(`[save-version] failed:`,await e.text()),X.error(`Checkpoint failed — try again`))}catch(e){console.error(`[save-version] failed:`,e),X.error(`Checkpoint failed — try again`)}m(!1)},e[5]=E):E=e[5];let D=E,O;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(sg,{onOpenResolver:()=>o(!0)}),e[6]=O):O=e[6];let k,A,j;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>{u(`auth`),c(!0)},A=()=>{u(`identity`),c(!0)},j=()=>o(!0),e[7]=k,e[8]=A,e[9]=j):(k=e[7],A=e[8],j=e[9]);let M;e[10]===p?M=e[11]:(M=(0,Z.jsx)(Hk,{onSaveVersion:D,saving:p,onSignIn:k,onSetIdentity:A,onOpenConflictResolver:j}),e[10]=p,e[11]=M);let N;e[12]!==d||e[13]!==r||e[14]!==T?(N=(0,Z.jsx)(PE,{editorMode:r,onModeChange:T,activeTab:d,onActiveTabChange:f}),e[12]=d,e[13]=r,e[14]=T,e[15]=N):N=e[15];let P;e[16]===a?P=e[17]:(P=(0,Z.jsx)(lv,{open:a,onOpenChange:o}),e[16]=a,e[17]=P);let F=l===`identity`,I;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>{c(!1)},e[18]=I):I=e[18];let L;e[19]!==s||e[20]!==F?(L=(0,Z.jsx)(qu,{open:s,onOpenChange:c,identityPrompt:F,onSuccess:I}),e[19]=s,e[20]=F,e[21]=L):L=e[21];let R;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>g(!0),e[22]=R):R=e[22];let z;e[23]===x?z=e[24]:(z=(0,Z.jsx)(ag,{open:x,onResolved:R}),e[23]=x,e[24]=z);let B;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Z.jsx)(qh,{}),e[25]=B):B=e[25];let V;return e[26]!==P||e[27]!==L||e[28]!==z||e[29]!==M||e[30]!==N?(V=(0,Z.jsxs)(Z.Fragment,{children:[O,M,N,P,L,z,B]}),e[26]=P,e[27]=L,e[28]=z,e[29]=M,e[30]=N,e[31]=V):V=e[31],V}var Wk=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
36
36
|
<symbol id="file-tree-icon-chevron" viewBox="0 0 16 16">
|
|
37
37
|
<path d="M3.47 5.47a.75.75 0 0 1 1.06 0L8 8.94l3.47-3.47a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 0 1 0-1.06" fill="currentcolor"/>
|
|
38
38
|
</symbol>
|
|
@@ -1915,4 +1915,4 @@ This template lives at an ancestor folder — deleting affects every folder unde
|
|
|
1915
1915
|
`;function wB(e){DB(e);let t=e.querySelector(`[data-item-rename-input]`);if(!t)return;let n=t.closest(`[data-item-section="content"]`),r=t.closest(`[data-type="item"]`);if(!n||!r)return;let i=r.dataset.itemPath??``;if(i.endsWith(`/`))return;let a=oB(i);a&&(OB(n,a),r.getAttribute(`data-ok-renaming`)!==a&&r.setAttribute(vB,a),TB(a),!t.hasAttribute(yB)&&(kB(t,a),t.setAttribute(yB,``)))}function TB(e){bB=e,xB!==null&&clearTimeout(xB),xB=setTimeout(EB,SB)}function EB(){bB=null,xB!==null&&(clearTimeout(xB),xB=null)}function DB(e){let t=e.querySelectorAll(`[${vB}]`);for(let e of t){if(e.querySelector(`[data-item-rename-input]`))continue;let t=e.getAttribute(vB);if(!t){e.removeAttribute(vB);continue}let n=e.dataset.itemPath??``;if(n.toLowerCase().endsWith(t.toLowerCase())){e.removeAttribute(vB);continue}let r=oB(n);r&&r.toLowerCase()!==t.toLowerCase()&&e.removeAttribute(vB)}if(bB===null)return;let n=e.querySelectorAll(`[data-type="item"][data-item-path]`),r=!1;for(let e of n){let t=e.dataset.itemPath??``;!t||t.endsWith(`/`)||oB(t)||(r=!0,e.getAttribute(`data-item-selected`)===`true`&&e.getAttribute(`data-ok-renaming`)!==bB&&e.setAttribute(vB,bB))}let i=!!e.querySelector(`[data-item-rename-input]`);!r&&!i&&EB()}function OB(e,t){let n=e.querySelector(`[${_B}]`);n||(n=e.ownerDocument.createElement(`span`),n.setAttribute(_B,``),n.setAttribute(`aria-hidden`,`true`),e.appendChild(n)),n.textContent!==t&&(n.textContent=t)}function kB(e,t){let n=e.value;if(!n.toLowerCase().endsWith(t.toLowerCase()))return;let r=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,`value`)?.set;if(!r)return;let i=n.slice(0,-t.length);r.call(e,i),e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.setSelectionRange(0,i.length)}function AB(e){return{selectedFilePath:e,selectedFolderPath:null,navigationPath:e}}function jB(e,t,n={}){if(!e)return AB(t);let r=ur(e);if(t&&r!==t)return AB(t);switch(e.kind){case`doc`:return AB(t??e.docName);case`folder`:case`folder-index`:return{selectedFilePath:null,selectedFolderPath:e.folderPath,navigationPath:e.folderPath};case`missing`:return t&&n.isKnownDocument?.(t)?AB(t):{selectedFilePath:null,selectedFolderPath:null,navigationPath:null};case`asset`:return{selectedFilePath:null,selectedFolderPath:null,navigationPath:null}}}function MB(e,t){if(!e)return{kind:`none`};let n=t.find(t=>GD(t)===e);if(n&&Hn(n))return{kind:`asset`,path:n.path,hash:Gr(n.path),mediaKind:n.mediaKind};let r=YD(e);return e.endsWith(`/`)?t.some(e=>ti(e)?e.path===r||e.path.startsWith(`${r}/`):(Hn(e)?e.path:e.docName).startsWith(`${r}/`))?{kind:`folder`,path:r}:{kind:`none`}:t.some(e=>hn(e)&&e.docName===r)?{kind:`document`,path:r}:{kind:`none`}}var NB=`You can restore this file from the Trash.`;function PB(e){let t=NB,n=`Move to Trash`,r=`Moving`;if(e.length===0)return{title:`Are you sure you want to delete the selected items?`,detail:t,listedTargets:null,confirmLabel:n,confirmLabelBusy:r};if(e.length===1){let i=e[0];return i?i.kind===`folder`?{title:`Are you sure you want to delete '${i.name}' and its contents?`,detail:t,listedTargets:null,confirmLabel:n,confirmLabelBusy:r}:{title:`Are you sure you want to delete '${i.name}'?`,detail:t,listedTargets:null,confirmLabel:n,confirmLabelBusy:r}:{title:`Are you sure you want to delete the selected item?`,detail:t,listedTargets:null,confirmLabel:n,confirmLabelBusy:r}}let i=e.some(e=>e.kind===`folder`),a=e.some(e=>e.kind===`file`);return i&&a?{title:`Are you sure you want to delete the following ${e.length} files/directories and their contents?`,detail:t,listedTargets:e,confirmLabel:n,confirmLabelBusy:r}:i?{title:`Are you sure you want to delete the following ${e.length} directories and their contents?`,detail:t,listedTargets:e,confirmLabel:n,confirmLabelBusy:r}:{title:`Are you sure you want to delete the following ${e.length} files?`,detail:t,listedTargets:e,confirmLabel:n,confirmLabelBusy:r}}function FB(e,t){return e===`web`?null:PB(t)}function IB(e){return e.kind===`folder`?`${e.name}/`:e.docExt?`${e.name}${e.docExt}`:e.name}var LB=[`not-found`,`permission-denied`,`system-error`,`path-escape`];function RB(e){return typeof e==`string`&&LB.includes(e)?e:`system-error`}var zB={"not-found":`File not found`,"permission-denied":`Permission denied`,"system-error":`System error`,"path-escape":`Path resolves outside project`};function BB(e){let t=zB[e.reason];return e.detail?`Reason: ${t} (${e.detail})`:`Reason: ${t}`}function VB(e){return e.kind===`folder`?`${e.name}/`:e.name}function HB(e){let t=(0,$.c)(33),{failedTargets:n,isSubmitting:r,onDeletePermanently:i,onRetry:a,onCancel:o}=e,s=n.length>1,c=n[0],l;t[0]!==n.length||t[1]!==s||t[2]!==c?(l=s?`${n.length} items could not be moved to the Trash. Do you want to permanently delete instead?`:c?`Could not move "${VB(c)}" to the Trash. Do you want to permanently delete instead?\n${BB(c)}`:`Do you want to permanently delete instead?`,t[0]=n.length,t[1]=s,t[2]=c,t[3]=l):l=t[3];let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(bo,{children:`Couldn't move to Trash`}),t[4]=d):d=t[4];let f;t[5]===u?f=t[6]:(f=(0,Z.jsxs)(Ao,{children:[d,(0,Z.jsx)(vo,{className:`whitespace-pre-wrap`,children:u})]}),t[5]=u,t[6]=f);let p;t[7]!==n||t[8]!==s?(p=s?(0,Z.jsx)(Do,{children:(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2 text-xs`,children:n.map(UB)})}):null,t[7]=n,t[8]=s,t[9]=p):p=t[9];let m;t[10]!==r||t[11]!==o?(m=(0,Z.jsx)(Y,{variant:`outline`,className:`font-mono uppercase`,onClick:o,disabled:r,"data-testid":`trash-failure-modal-cancel`,children:`Cancel`}),t[10]=r,t[11]=o,t[12]=m):m=t[12];let h;t[13]===r?h=t[14]:(h=r?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ue,{className:`size-4 animate-spin`}),` Retrying`]}):`Retry`,t[13]=r,t[14]=h);let g;t[15]!==r||t[16]!==a||t[17]!==h?(g=(0,Z.jsx)(Y,{variant:`outline`,className:`font-mono uppercase`,onClick:a,disabled:r,"data-testid":`trash-failure-modal-retry`,children:h}),t[15]=r,t[16]=a,t[17]=h,t[18]=g):g=t[18];let _;t[19]===r?_=t[20]:(_=r?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ue,{className:`size-4 animate-spin`}),` Deleting`]}):`Delete Permanently`,t[19]=r,t[20]=_);let v;t[21]!==r||t[22]!==i||t[23]!==_?(v=(0,Z.jsx)(Y,{variant:`destructive`,onClick:i,disabled:r,"data-testid":`trash-failure-modal-delete-permanently`,children:_}),t[21]=r,t[22]=i,t[23]=_,t[24]=v):v=t[24];let y;t[25]!==m||t[26]!==g||t[27]!==v?(y=(0,Z.jsxs)(Oo,{children:[m,g,v]}),t[25]=m,t[26]=g,t[27]=v,t[28]=y):y=t[28];let b;return t[29]!==y||t[30]!==f||t[31]!==p?(b=(0,Z.jsxs)(wo,{className:`sm:max-w-md`,children:[f,p,y]}),t[29]=y,t[30]=f,t[31]=p,t[32]=b):b=t[32],b}function UB(e){return(0,Z.jsxs)(`li`,{"data-testid":`trash-failure-modal-target`,children:[(0,Z.jsx)(`div`,{className:`font-mono text-foreground`,children:VB(e)}),(0,Z.jsx)(`div`,{className:`text-muted-foreground`,children:BB(e)})]},e.path)}function WB(e){return e?.isDirectory()?e:null}function GB(e,t){let n=t.getPath();for(let t of e.getSelectedPaths())t!==n&&e.getItem(t)?.deselect();t.isSelected()||t.select()}function KB(e,t,n,r){let i=(0,$.c)(6),a,o;i[0]!==n||i[1]!==t||i[2]!==e||i[3]!==r?(a=()=>{let i=()=>{queueMicrotask(()=>{r.current=!1})};if(r.current=!0,!t){for(let t of e.getSelectedPaths())e.getItem(t)?.deselect();i();return}let a=n?n.split(`\0`):[];for(let t of a){let n=WB(e.getItem(t));n&&!n.isExpanded()&&n.expand()}let o=e.getItem(t);if(!o){i();return}GB(e,o),o.focus(),i()},o=[n,t,e,r],i[0]=n,i[1]=t,i[2]=e,i[3]=r,i[4]=a,i[5]=o):(a=i[4],o=i[5]),(0,Q.useEffect)(a,o)}var qB={"not-found":`Terminal.app not found`,"spawn-error":`Could not launch Terminal`,timeout:`Terminal took too long to respond`,"path-escape":`Path resolves outside the project`,"ipc-error":`Lost connection to the main process`};async function JB(e,t){let n;try{n=await e.shell.openInTerminal(t)}catch(e){console.warn(`[shell] openInTerminal IPC threw`,{dirAbsPath:t,err:e}),X.error(`Could not open Terminal`,{description:qB[`ipc-error`]});return}n.ok||(console.warn(`[shell] openInTerminal failed`,{reason:n.reason,dirAbsPath:t}),X.error(`Could not open Terminal`,{description:qB[n.reason]}))}var YB=`open-knowledge:file-tree-menu-action-delete`,XB=`open-knowledge:file-tree-menu-action-rename`;function ZB(e){window.dispatchEvent(new CustomEvent(YB,{detail:{target:e}}))}function QB(e){let t=t=>{let n=t.detail;n?.target&&e(n.target)};return window.addEventListener(YB,t),()=>window.removeEventListener(YB,t)}function $B(e){window.dispatchEvent(new CustomEvent(XB,{detail:{target:e}}))}function eV(e){let t=t=>{let n=t.detail;n?.target&&e(n.target)};return window.addEventListener(XB,t),()=>window.removeEventListener(XB,t)}function tV(e){let t=!1,n=!1,r=!1;async function i(){if(!r){t=!0;try{await e()}finally{t=!1,r?n=!1:n&&(n=!1,i())}}}return{request(){if(!r){if(t){n=!0;return}i()}},dispose(){r=!0,n=!1}}}function nV(e){return e?`No workspace`:null}function rV(e){let t=(0,$.c)(39),{input:n,installStates:r,dispatch:i,webFallbackVisible:a}=e,o=a===void 0?!0:a,s=n===null,c;t[0]===s?c=t[1]:(c=nV(s),t[0]=s,t[1]=c);let l=c,u,d,f,p,m,h;if(t[2]!==i||t[3]!==l||t[4]!==n||t[5]!==s||t[6]!==r){let e;t[13]===r?e=t[14]:(e=e=>r[e.id]?.installed===!0,t[13]=r,t[14]=e);let a=xm.filter(e);f=r[`claude-code`]?.installed===!0;let o;t[15]===n?o=t[16]:(o=n!==null&&n.docContext!==null?$r(n.docContext.relativePath):``,t[15]=n,t[16]=o);let c=o,g;t[17]!==n||t[18]!==c?(g=()=>{n!==null&&qx(c)},t[17]=n,t[18]=c,t[19]=g):g=t[19],p=g,d=Xa,t[20]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsxs)(xa,{children:[(0,Z.jsx)(Fi,{"aria-hidden":`true`}),`Open with AI`]}),t[20]=h):h=t[20],u=ta;let _;t[21]!==i||t[22]!==l||t[23]!==n||t[24]!==s?(_=e=>{let t=!s,r=l?`Open with AI ${e.displayName}, ${l}`:`Open with AI ${e.displayName}`;return(0,Z.jsxs)(ya,{disabled:!t,onSelect:()=>{n&&i(e.id,n)},"data-testid":`file-tree-open-in-${e.id}`,"aria-label":r,children:[(0,Z.jsx)(Vx,{id:e.id,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:e.displayName}),l?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:l}):null]},e.id)},t[21]=i,t[22]=l,t[23]=n,t[24]=s,t[25]=_):_=t[25],m=a.map(_),t[2]=i,t[3]=l,t[4]=n,t[5]=s,t[6]=r,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m,t[12]=h}else u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12];let g;t[26]!==f||t[27]!==p||t[28]!==s||t[29]!==o?(g=o&&!f?(0,Z.jsxs)(ya,{onSelect:p,disabled:s,"data-testid":`file-tree-open-in-claude-web-fallback`,"aria-label":`Open in claude.ai, opens in browser with prompt pre-filled`,children:[(0,Z.jsx)(he,{className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:`Open in claude.ai →`}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`opens in browser`})]}):null,t[26]=f,t[27]=p,t[28]=s,t[29]=o,t[30]=g):g=t[30];let _;t[31]!==u||t[32]!==m||t[33]!==g?(_=(0,Z.jsxs)(u,{children:[m,g]}),t[31]=u,t[32]=m,t[33]=g,t[34]=_):_=t[34];let v;return t[35]!==d||t[36]!==h||t[37]!==_?(v=(0,Z.jsxs)(d,{children:[h,_]}),t[35]=d,t[36]=h,t[37]=_,t[38]=v):v=t[38],v}var iV=it(`HOVER_INTENT_MS`,80),aV=3,oV=20,sV=new Map,cV=new Set,lV=[],uV=new Map;function dV(e){for(uV.delete(e),uV.set(e,!0);uV.size>oV;){let e=uV.keys().next().value;if(e===void 0)break;uV.delete(e)}}function fV(e){cV.delete(e),mV()}function pV(e,t){let n=Date.now();dt(`ok/sidebar/prewarm-success`,{docName:e,t:n,poolEventId:t}),$e(e,t,n)}function mV(){for(;cV.size<aV&&lV.length>0;){let e=lV.shift();if(!e)break;if(!uV.has(e.docName)){cV.add(e.docName),dV(e.docName);try{let t=e.prewarm(e.docName);t&&pV(e.docName,t)}catch(t){dt(`ok/sidebar/prewarm-failed`,{docName:e.docName,message:t instanceof Error?t.message:String(t)})}finally{fV(e.docName)}}}}function hV(e,t){if(Be(e)||uV.has(e))return;let n=sV.get(e);n&&clearTimeout(n.timer);let r=setTimeout(()=>{if(sV.delete(e),cV.size>=aV){lV.push({docName:e,prewarm:t});return}dV(e),cV.add(e);try{let n=t(e);n&&pV(e,n)}catch(t){dt(`ok/sidebar/prewarm-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})}finally{fV(e)}},iV);sV.set(e,{timer:r,prewarm:t})}function gV(e){let t=sV.get(e);t&&(clearTimeout(t.timer),sV.delete(e))}var _V=/\.(md|mdx)$/i;function vV(e){if(window.location.hash===e)return;let{pathname:t,search:n}=window.location;window.history.replaceState(null,``,`${t}${n}${e}`)}function yV(e){let t=e.match(/^"(.+)" already exists\.$/);return t?t[1]:null}function bV(e){let t=e.match(_V);return t?t[0]:null}async function xV(e,t){try{await navigator.clipboard.writeText(e),X.success(`Copied ${t}`,{description:e})}catch(e){console.warn(`[FileTree] clipboard write failed:`,e),X.error(`Could not copy ${t}`)}}var SV=new Set([`agents`,`agent`,`claude`,`skill`]),CV=`ok-file-tree-link-decoration`,wV=`ok-file-tree-agent-decoration`;function TV(e){return e.map(([e,{key:t,...n}])=>`<${e} ${Object.entries(n).map(([e,t])=>`${e}="${t}"`).join(` `)} />`).join(``)}function EV(e,t){return`<symbol id="${e}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${TV(t)}</symbol>`}var DV=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
1916
1916
|
${EV(CV,c)}
|
|
1917
1917
|
${EV(wV,Ws)}
|
|
1918
|
-
</svg>`,OV=`${uB}\n${CB}`;function kV(e){return{...Sj({type:e===`dark`?`dark`:`light`,colors:{"sideBar.background":`var(--sidebar)`,"sideBar.foreground":`var(--sidebar-foreground)`,"sideBar.border":`var(--sidebar-border)`,"list.activeSelectionBackground":`var(--sidebar-accent)`,"list.activeSelectionForeground":`var(--sidebar-accent-foreground)`,"list.hoverBackground":`var(--sidebar-hover)`,focusBorder:`var(--color-primary)`,"input.background":`var(--input)`,"input.border":`var(--border)`}}),"--trees-font-family-override":`var(--font-sans)`,"--trees-font-size-override":`0.875rem`,"--trees-item-padding-x-override":`0.5rem`,"--trees-padding-inline-override":`0.5rem`,"--trees-border-radius-override":`0.375rem`,"--trees-selected-fg":`var(--color-primary)`,"--truncate-marker-fade-in-duration":`0s`,"--trees-file-icon-color-markdown":`light-dark(var(--color-gray-400), var(--color-gray-500))`,"--trees-file-icon-color-image":`light-dark(var(--color-gray-400), var(--color-gray-500))`,"--trees-fg-muted":`light-dark(var(--color-gray-400), var(--color-gray-500))`}}function AV(e){let t=e.split(`/`).pop()?.replace(/\.md$/i,``).toLowerCase();return!!t&&SV.has(t)}function jV(e){return e===`darwin`?`Reveal in Finder`:e===`win32`?`Reveal in File Explorer`:`Open Containing Folder`}function MV(e){let t=(0,$.c)(14),{item:n,workspace:r,onClose:i}=e,a=typeof window<`u`?window.okDesktop:void 0;if(!a)return null;let o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=jV(a.platform),t[0]=o):o=t[0];let s=o,c=r?null:`No workspace`,l=!r,u;t[1]!==n||t[2]!==i||t[3]!==r?(u=()=>{if(!r)return;i();let e=nh(r.contentDir,nO(n),r.pathSeparator);a.shell.showItemInFolder(e)},t[1]=n,t[2]=i,t[3]=r,t[4]=u):u=t[4];let d=c?`${s}, ${c}`:s,f,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(R,{"aria-hidden":`true`}),p=(0,Z.jsx)(`span`,{className:`flex-1`,children:s}),t[5]=f,t[6]=p):(f=t[5],p=t[6]);let m;t[7]===c?m=t[8]:(m=c?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:c}):null,t[7]=c,t[8]=m);let h;return t[9]!==l||t[10]!==u||t[11]!==d||t[12]!==m?(h=(0,Z.jsxs)(ya,{disabled:l,onSelect:u,"aria-label":d,children:[f,p,m]}),t[9]=l,t[10]=u,t[11]=d,t[12]=m,t[13]=h):h=t[13],h}function NV(e){let t=(0,$.c)(12),{dirAbsPath:n,onClose:r}=e,i=typeof window<`u`?window.okDesktop:void 0;if(!i)return null;let a=n===null?`No workspace`:null,o=n===null,s;t[0]!==n||t[1]!==r?(s=()=>{n!==null&&(r(),JB(i,n))},t[0]=n,t[1]=r,t[2]=s):s=t[2];let c=a?`Open in Terminal, ${a}`:`Open in Terminal`,l,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(Yc,{"aria-hidden":`true`}),u=(0,Z.jsx)(`span`,{className:`flex-1`,children:`Open in Terminal`}),t[3]=l,t[4]=u):(l=t[3],u=t[4]);let d;t[5]===a?d=t[6]:(d=a?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:a}):null,t[5]=a,t[6]=d);let f;return t[7]!==o||t[8]!==s||t[9]!==c||t[10]!==d?(f=(0,Z.jsxs)(ya,{disabled:o,onSelect:s,"aria-label":c,children:[l,u,d]}),t[7]=o,t[8]=s,t[9]=c,t[10]=d,t[11]=f):f=t[11],f}function PV(e){return tO({kind:e.endsWith(`/`)?`directory`:`file`,name:e,path:e})}function FV(e,t){return e!==t&&e.startsWith(t)}function IV(e,t){let n=[...new Set(e)].filter(e=>!t(e)),r=n.filter(e=>e.endsWith(`/`));return n.filter(e=>!r.some(t=>FV(e,t))).map(PV)}function LV(e,t){return e===t||e.startsWith(`${t}/`)}function RV(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable||e.closest(`[contenteditable="true"]`)!==null}function zV(e,t,n){let r=new Set,i=new Set;for(let a of e){if(a.kind===`file`){r.add(a.path);continue}i.add(a.path);for(let e of t)hn(e)&&e.docName.startsWith(`${a.path}/`)&&r.add(e.docName);for(let e of n){let t=qD(e);LV(t,a.path)&&i.add(t)}}return{docNames:r,folderPaths:i}}function BV(e,t){return e.kind===`file`?t.kind===`file`&&e.path===t.createdPath:LV(t.createdPath,e.path)}function VV(e){let t=(0,$.c)(75),{item:n,context:r,anyActionBusy:i,workspace:a,handoff:o,model:s,okignoreBinding:c,projectLocalBinding:l,mergedConfig:u,onStartCreating:f,onStartCreatingFromTemplate:p,onDelete:h,onExpandSubtree:g,onCollapseSubtree:_,folderTreePaths:v,isAsset:y,isAssetTreePath:b}=e,x,S,C,w,T,D,O,k;if(t[0]!==y||t[1]!==b||t[2]!==n||t[3]!==u?.appearance?.sidebar?.showAllFiles||t[4]!==u?.appearance?.sidebar?.showHiddenFiles||t[5]!==s||t[6]!==c||t[7]!==l){k=tO(n),w=n.kind===`directory`,x=!y&&c!==null,C=w?`Hide folder`:`Hide this file`,D=u?.appearance?.sidebar?.showHiddenFiles??!1,T=u?.appearance?.sidebar?.showAllFiles??!1,S=l!==null;let e=s.getSelectedPaths();O=e.includes(k.treePath)?IV(e,b):[],t[0]=y,t[1]=b,t[2]=n,t[3]=u?.appearance?.sidebar?.showAllFiles,t[4]=u?.appearance?.sidebar?.showHiddenFiles,t[5]=s,t[6]=c,t[7]=l,t[8]=x,t[9]=S,t[10]=C,t[11]=w,t[12]=T,t[13]=D,t[14]=O,t[15]=k}else x=t[8],S=t[9],C=t[10],w=t[11],T=t[12],D=t[13],O=t[14],k=t[15];let A=O,j;t[16]!==A||t[17]!==k?(j=A.length>1?A:[k],t[16]=A,t[17]=k,t[18]=j):j=t[18];let M=j,N=M.length>1?`Delete ${M.length} Items`:`Delete`,P,F,I;if(t[19]!==y||t[20]!==w||t[21]!==n||t[22]!==a){P=w&&a?nh(a.contentDir,nO(n),a.pathSeparator):null;let e;if(t[26]!==w||t[27]!==n||t[28]!==a){bb0:{if(!a||w){e=null;break bb0}let t=nO(n),r=t.lastIndexOf(`/`);if(r===-1){e=a.contentDir;break bb0}e=nh(a.contentDir,t.slice(0,r),a.pathSeparator)}t[26]=w,t[27]=n,t[28]=a,t[29]=e}else e=t[29];F=e,I=y?null:w?oh({folderAbsPath:P??``,folderRelativePath:nO(n),workspace:a}):ih({docName:WD(n.path),workspace:a}),t[19]=y,t[20]=w,t[21]=n,t[22]=a,t[23]=P,t[24]=F,t[25]=I}else P=t[23],F=t[24],I=t[25];let L=I,R;t[30]===r?R=t[31]:(R=()=>r.close({restoreFocus:!1}),t[30]=r,t[31]=R);let z=R,B;t[32]===r?B=t[33]:(B=()=>r.close(),t[32]=r,t[33]=B);let V=B,H;t[34]===l?H=t[35]:(H=e=>{if(l===null)return;let t=l.patch({appearance:{sidebar:{showHiddenFiles:e}}});t.ok||(console.warn(`[FileTree] showHiddenFiles toggle rejected:`,Nn(t.error)),X.error(`Could not update sidebar settings`,{description:Nn(t.error)}))},t[34]=l,t[35]=H);let U=H,W;t[36]===l?W=t[37]:(W=e=>{if(l===null)return;let t=l.patch({appearance:{sidebar:{showAllFiles:e}}});t.ok||(console.warn(`[FileTree] showAllFiles toggle rejected:`,Nn(t.error)),X.error(`Could not update sidebar settings`,{description:Nn(t.error)}))},t[36]=l,t[37]=W);let G=W,K=0,q=0;if(w){let e=JD(n.path);for(let t of v)(t===e||t.startsWith(e))&&(K++,WB(s.getItem(t))?.isExpanded()&&q++)}let ee=w&&q<K,te=w&&q>0,ne;t[38]===V?ne=t[39]:(ne=e=>{e||V()},t[38]=V,t[39]=ne);let re;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Z.jsx)(ba,{asChild:!0,children:(0,Z.jsx)(`span`,{"aria-hidden":`true`,"data-file-tree-context-menu-root":`true`,className:`block size-px`})}),t[40]=re):re=t[40];let ie;t[41]!==i||t[42]!==x||t[43]!==S||t[44]!==V||t[45]!==z||t[46]!==N||t[47]!==M||t[48]!==P||t[49]!==G||t[50]!==U||t[51]!==o||t[52]!==L||t[53]!==C||t[54]!==y||t[55]!==w||t[56]!==n||t[57]!==s||t[58]!==c||t[59]!==_||t[60]!==h||t[61]!==g||t[62]!==f||t[63]!==p||t[64]!==F||t[65]!==T||t[66]!==D||t[67]!==te||t[68]!==ee||t[69]!==k||t[70]!==a?(ie=(0,Z.jsx)(_a,{sideOffset:0,align:`start`,"data-file-tree-context-menu-root":`true`,className:`min-w-52`,children:w?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(ya,{disabled:i,onSelect:()=>{z(),f(`file`,qD(n.path))},children:[(0,Z.jsx)(Wc,{"aria-hidden":`true`}),`New File`]}),(0,Z.jsxs)(ya,{disabled:i,onSelect:()=>{z(),p(qD(n.path))},children:[(0,Z.jsx)(oc,{"aria-hidden":`true`}),`New from template`]}),(0,Z.jsxs)(ya,{disabled:i,onSelect:()=>{z(),f(`folder`,qD(n.path))},children:[(0,Z.jsx)(uc,{"aria-hidden":`true`}),`New Folder`]}),(0,Z.jsx)(na,{}),(0,Z.jsx)(MV,{item:n,workspace:a,onClose:V}),(0,Z.jsx)(rV,{input:L,installStates:o.installStates,isElectronHost:o.isElectronHost,dispatch:o.dispatch,webFallbackVisible:!1}),(0,Z.jsx)(NV,{dirAbsPath:P,onClose:V}),(0,Z.jsxs)(Xa,{children:[(0,Z.jsxs)(xa,{children:[(0,Z.jsx)(E,{"aria-hidden":`true`}),`Copy Path`]}),(0,Z.jsxs)(ta,{children:[(0,Z.jsx)(ya,{disabled:!a,onSelect:()=>{a&&(V(),xV(nh(a.contentDir,nO(n),a.pathSeparator),`full path`))},children:`Full Path`}),(0,Z.jsx)(ya,{onSelect:()=>{V(),xV(nO(n),`relative path`)},children:`Relative Path`})]})]}),(0,Z.jsx)(na,{}),(0,Z.jsx)($i,{checked:D,onCheckedChange:U,disabled:!S,"data-testid":`file-tree-menu-show-hidden-files`,children:`Show Hidden Files`}),(0,Z.jsx)($i,{checked:T,onCheckedChange:G,disabled:!S,"data-testid":`file-tree-menu-show-all-files`,children:`Show all files`}),ee||te?(0,Z.jsx)(na,{}):null,ee?(0,Z.jsxs)(ya,{onSelect:()=>{V(),g(n.path)},children:[(0,Z.jsx)(Qc,{"aria-hidden":`true`}),`Expand All`]}):null,te?(0,Z.jsxs)(ya,{onSelect:()=>{V(),_(n.path)},children:[(0,Z.jsx)(cc,{"aria-hidden":`true`}),`Collapse All`]}):null,(0,Z.jsx)(na,{}),(0,Z.jsxs)(ya,{disabled:i,onSelect:()=>{z(),s.startRenaming(n.path)},children:[(0,Z.jsx)(m,{"aria-hidden":`true`}),`Rename`]}),(0,Z.jsxs)(ya,{"data-testid":`file-tree-menu-hide`,disabled:!x,onSelect:()=>{if(!c)return;V();let e=gB(k),t=no(c.current()),n=Ka(t,e);if(n===t)return;c.patch(Ja(n));let r=k.path.split(`/`).pop()||k.path;X.success(`Hidden folder “${r}”`,{description:`Manage hidden files in Settings → Ignore patterns.`,duration:5e3})},children:[(0,Z.jsx)(d,{"aria-hidden":`true`}),C]}),(0,Z.jsxs)(ya,{variant:`destructive`,disabled:i,onSelect:()=>{V(),h(M)},children:[(0,Z.jsx)(Ue,{"aria-hidden":`true`}),N]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(MV,{item:n,workspace:a,onClose:V}),!y&&(0,Z.jsx)(rV,{input:L,installStates:o.installStates,isElectronHost:o.isElectronHost,dispatch:o.dispatch,webFallbackVisible:!0}),(0,Z.jsx)(NV,{dirAbsPath:F,onClose:V}),(0,Z.jsxs)(Xa,{children:[(0,Z.jsxs)(xa,{children:[(0,Z.jsx)(E,{"aria-hidden":`true`}),`Copy Path`]}),(0,Z.jsxs)(ta,{children:[(0,Z.jsx)(ya,{disabled:!a,onSelect:()=>{a&&(V(),xV(nh(a.contentDir,nO(n),a.pathSeparator),`full path`))},children:`Full Path`}),(0,Z.jsx)(ya,{onSelect:()=>{V(),xV(nO(n),`relative path`)},children:`Relative Path`})]})]}),y?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(na,{}),(0,Z.jsxs)(ya,{disabled:i,onSelect:()=>{z(),s.startRenaming(n.path)},children:[(0,Z.jsx)(m,{"aria-hidden":`true`}),`Rename`]}),(0,Z.jsxs)(ya,{"data-testid":`file-tree-menu-hide`,disabled:!x,onSelect:()=>{if(!c)return;V();let e=gB(k),t=no(c.current()),n=Ka(t,e);if(n===t)return;c.patch(Ja(n));let r=k.path.split(`/`).pop()||k.path;X.success(`Hidden “${r}”`,{description:`Manage hidden files in Settings → Ignore patterns.`,duration:5e3})},children:[(0,Z.jsx)(d,{"aria-hidden":`true`}),C]}),(0,Z.jsxs)(ya,{variant:`destructive`,disabled:i,onSelect:()=>{V(),h(M)},children:[(0,Z.jsx)(Ue,{"aria-hidden":`true`}),N]})]})]})}),t[41]=i,t[42]=x,t[43]=S,t[44]=V,t[45]=z,t[46]=N,t[47]=M,t[48]=P,t[49]=G,t[50]=U,t[51]=o,t[52]=L,t[53]=C,t[54]=y,t[55]=w,t[56]=n,t[57]=s,t[58]=c,t[59]=_,t[60]=h,t[61]=g,t[62]=f,t[63]=p,t[64]=F,t[65]=T,t[66]=D,t[67]=te,t[68]=ee,t[69]=k,t[70]=a,t[71]=ie):ie=t[71];let ae;return t[72]!==ie||t[73]!==ne?(ae=(0,Z.jsxs)(va,{open:!0,modal:!1,onOpenChange:ne,children:[re,ie]}),t[72]=ie,t[73]=ne,t[74]=ae):ae=t[74],ae}function HV(e){let t=(0,$.c)(226),{ref:n}=e,{activeDocName:r,activeTarget:i,closeTabs:a,closeDocument:o,closeAndClearForRename:s,getPoolActiveDocName:c,isNewTabActive:u,openTarget:d,prewarm:f,remapTabsForRename:p}=ot(),{notifySidebarFileSelected:m}=aD(),{resolvedTheme:h}=vr(),{addPage:g}=qr(),_;t[0]!==m||t[1]!==d?(_=function(e){d({kind:`doc`,target:e,docName:e},{tabBehavior:`replace-active`}),vV(Tr(e)),m()},t[0]=m,t[1]=d,t[2]=_):_=t[2];let v=_,y;t[3]!==m||t[4]!==d?(y=function(e){let t=or(e);d({kind:`folder`,target:e,folderPath:e},{tabBehavior:`replace-active`}),vV(t),m()},t[3]=m,t[4]=d,t[5]=y):y=t[5];let b=y,x;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(x=[],t[6]=x):x=t[6];let[S,C]=(0,Q.useState)(x),[w,T]=(0,Q.useState)(!0),[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(null),[M,N]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(null),[I,L]=(0,Q.useState)(null),R=(0,Q.useRef)(S),z;t[7]!==S||t[8]!==b||t[9]!==v||t[10]!==m||t[11]!==d?(z=function(e,t){let n=MB(e,t===void 0?S:t);if(n.kind===`none`){console.debug(`[FileTree] Dropped selection for unknown docName:`,YD(e));return}if(n.kind===`asset`){d({kind:`asset`,target:n.path,assetPath:n.path,mediaKind:n.mediaKind},{tabBehavior:`replace-active`}),vV(n.hash),m();return}if(n.kind===`folder`){b(n.path);return}v(n.path)},t[7]=S,t[8]=b,t[9]=v,t[10]=m,t[11]=d,t[12]=z):z=t[12];let B=z,V=(0,Q.useRef)(r),H;t[13]===S?H=t[14]:(H=new Set(S.filter(Hn).map(cH)),t[13]=S,t[14]=H);let U=H,W=(0,Q.useRef)(U),G;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(G=[],t[15]=G):G=t[15];let K=(0,Q.useRef)(G),q=(0,Q.useRef)(null),ee=(0,Q.useRef)(sH),te=(0,Q.useRef)(null),ne=(0,Q.useRef)(null),re=(0,Q.useRef)(!1),ie=(0,Q.useRef)(null),ae=(0,Q.useRef)(!1),oe=(0,Q.useRef)(!1),se=(0,Q.useRef)(null),ce=(0,Q.useRef)(null),le=(0,Q.useRef)(oH),J=(0,Q.useRef)(aH),ue=(0,Q.useRef)(iH),de=(0,Q.useRef)(rH),fe=(0,Q.useRef)(i),{selectedFilePath:pe,selectedFolderPath:me,navigationPath:he}=jB(i,u?null:r),ge=pe?UD(pe,S.find(e=>hn(e)&&e.docName===pe)?.docExt):me?JD(me):i?.kind===`asset`?i.assetPath:null,_e=Oh().states,{dispatch:ve}=_h(),ye;t[16]!==ve||t[17]!==_e?(ye={installStates:_e,isElectronHost:typeof window<`u`&&window.okDesktop!=null,dispatch:ve},t[16]=ve,t[17]=_e,t[18]=ye):ye=t[18];let be=ye,{okignoreBinding:xe,projectLocalBinding:Se,merged:Ce}=Ga(),we=Ce?.appearance?.sidebar?.showHiddenFiles??!1,Te=Ce?.appearance?.sidebar?.showAllFiles??!1,Ee;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=()=>ie.current===null,t[19]=Ee):Ee=t[19];let De=Ee,Oe;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=[],t[20]=Oe):Oe=t[20];let ke;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(ke={set:`complete`,spriteSheet:DV},t[21]=ke):ke=t[21];let Ae;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(Ae={contextMenu:{enabled:!0,triggerMode:`both`,buttonVisibility:`when-needed`}},t[22]=Ae):Ae=t[22];let je;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(je={canDrag:De,canDrop:De,onDropComplete:e=>de.current(e),onDropError:nH},t[23]=je):je=t[23];let Me;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(Me={paths:Oe,flattenEmptyDirectories:!1,initialExpansion:`closed`,fileTreeSearchMode:`hide-non-matches`,initialVisibleRowCount:18,stickyFolders:!0,icons:ke,unsafeCSS:OV,composition:Ae,dragAndDrop:je,renaming:{canRename:De,onRename:e=>J.current(e),onError:e=>ue.current(e)},onSelectionChange:e=>le.current(e),renderRowDecoration:e=>{let{item:t}=e;if(t.kind!==`file`)return null;let n=R.current.find(e=>hn(e)&&UD(e.docName,e.docExt)===t.path);return n?.isSymlink?{icon:CV,title:n.targetPath?`Symlink to ${n.targetPath}`:`Symlink`}:AV(t.path)?{icon:wV,title:`Agent configuration file`}:null}},t[24]=Me):Me=t[24];let{model:Ne}=aB(Me),Pe;t[25]===Ne?Pe=t[26]:(Pe=function(e){let t=Ne.getItem(e)??Ne.getItem(JD(e));return t?.isDirectory()?JD(qD(t.getPath())):e},t[25]=Ne,t[26]=Pe);let Fe=Pe,Le,Re;t[27]===S?(Le=t[28],Re=t[29]):(Re=XD(S),Le=ZD(Re),t[27]=S,t[28]=Le,t[29]=Re);let ze=Le,Be=(0,Q.useRef)(Re),Ve;t[30]===S?Ve=t[31]:(Ve=$D(S),t[30]=S,t[31]=Ve);let He=Ve,Ue=(0,Q.useRef)(He),We=me?eO(JD(me)).slice(0,-1):eO(ge??he),Ge=We.join(`\0`),Ke;if(t[32]!==Ne){let e=()=>{let e=new Set;for(let t of Ue.current)WB(Ne.getItem(t))?.isExpanded()&&e.add(t);return e};Ke=t=>{let n=new Set($D(t??R.current)),r=e();for(let e of K.current)r.add(e);return[...r].filter(e=>n.has(e))},t[32]=Ne,t[33]=Ke}else Ke=t[33];let qe=Ke,Je;t[34]!==qe||t[35]!==Ne?(Je=e=>{let t=XD(e??R.current);Ne.resetPaths(t,{initialExpandedPaths:qe(e)})},t[34]=qe,t[35]=Ne,t[36]=Je):Je=t[36];let Ye=Je,Xe;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=e=>{te.current=QD(e)},t[37]=Xe):Xe=t[37];let Qe=Xe,$e;t[38]===Symbol.for(`react.memo_cache_sentinel`)?($e=e=>W.current.has(e),t[38]=$e):$e=t[38];let et=$e,tt=function(e){let t=yV(e);if(!t||bV(t))return!1;let n=Ne.getFocusedPath()??Ne.getSelectedPaths()[0]??null;if(!n||n.endsWith(`/`)||et(n))return!1;let r=bV(n);if(!r)return!1;let i=JD(t);if(!Ue.current.includes(i))return!1;let a=`${t}${r}`;return Be.current.includes(a)?!1:(Ot({sourcePath:n,destinationPath:a,isFolder:!1}),Ne.move(n,a),!0)},nt;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(nt=e=>{let t=e??q.current;!t||q.current!==t||(t.disposeCommitListener(),q.current=null)},t[39]=nt):nt=t[39];let rt=nt,it;t[40]!==rt||t[41]!==o||t[42]!==a||t[43]!==Ye?(it=async function(e,t){let n=t===void 0?{}:t,r=n.updateUi??!0,i=n.restoreLocation??r;rt(e),r&&k(e.renamePath);try{let t=await fetch(`/api/delete-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:e.kind,path:e.createdPath})});if(!t.ok&&t.status!==404){let n=await l(t,`Failed to clean up pending ${e.kind}`);if(n.ok)return;let i=`${n.title} - ${e.kind} "${e.createdPath}" still exists on disk`;r?X.error(i):console.warn(`[FileTree] cleanup pending create failed: ${i}`),r&&(k(null),Ye());return}}catch(t){console.warn(`[FileTree] cleanup pending create failed:`,t),r&&X.error(`Network error - ${e.kind} "${e.createdPath}" still exists on disk`),r&&(k(null),Ye());return}r&&(e.kind===`file`?o(e.createdPath):a([lt(e.createdPath)],{force:!0})),r&&C(t=>{let n=pO(t,e.kind===`file`?[e.createdPath]:[],e.kind===`folder`?e.createdPath:void 0);return Qe(n),n}),Fr([`files`,`backlinks`,`graph`]),i&&(window.location.hash=e.previousHash),r&&k(null)},t[40]=rt,t[41]=o,t[42]=a,t[43]=Ye,t[44]=it):it=t[44];let at=it,st,ct;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(st=()=>()=>{let e=q.current;e&&ee.current(e,{restoreLocation:!1,updateUi:!1}).catch(tH)},ct=[],t[45]=st,t[46]=ct):(st=t[45],ct=t[46]),(0,Q.useEffect)(st,ct);let ut,dt;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(ut=()=>{let e=!0,t=tV(async function(){try{let t=oe.current,n=await l(await fetch(t?`/api/documents?showAll=true`:`/api/documents`),`Failed to load documents`);if(!e)return;if(!n.ok)D(n.title);else{let e=li.safeParse(n.body);if(!e.success)D(`Documents response did not match expected shape.`);else{let n=ae.current||t;C(ai(e.data.documents,n)),D(null)}}}catch(t){let n=t;e&&D(`Could not reach server`),console.warn(`[FileTree] fetch failed:`,n)}e&&T(!1)});se.current=()=>t.request(),t.request();let n=()=>{document.visibilityState===`visible`&&t.request()};window.addEventListener(`focus`,n),window.addEventListener(`visibilitychange`,n);let r=br(e=>{e.includes(`files`)&&t.request()});return()=>{e=!1,se.current=null,t.dispose(),window.removeEventListener(`focus`,n),window.removeEventListener(`visibilitychange`,n),r()}},dt=[],t[47]=ut,t[48]=dt):(ut=t[47],dt=t[48]),(0,Q.useEffect)(ut,dt);let ft=(0,Q.useRef)(!0),pt;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(pt=()=>{if(ft.current){ft.current=!1;return}se.current?.()},t[49]=pt):pt=t[49];let mt;t[50]===we?mt=t[51]:(mt=[we],t[50]=we,t[51]=mt),(0,Q.useEffect)(pt,mt);let ht=(0,Q.useRef)(!0),gt;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(gt=()=>{if(ht.current){ht.current=!1;return}se.current?.()},t[52]=gt):gt=t[52];let _t;t[53]===Te?_t=t[54]:(_t=[Te],t[53]=Te,t[54]=_t),(0,Q.useEffect)(gt,_t);let vt,yt;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(vt=()=>{let e=!0;return fetch(`/api/workspace`).then(async t=>{let n=await t.json();if(!e||!t.ok)return;let r=Ze(Kr,n,`workspace`,null);r&&L({contentDir:r.contentDir,pathSeparator:r.pathSeparator})}).catch(eH),()=>{e=!1}},yt=[],t[55]=vt,t[56]=yt):(vt=t[55],yt=t[56]),(0,Q.useEffect)(vt,yt);let bt;t[57]!==qe||t[58]!==Ne||t[59]!==ze?(bt=()=>{if(te.current===ze){te.current=null;return}Ne.resetPaths(Be.current,{initialExpandedPaths:qe()})},t[57]=qe,t[58]=Ne,t[59]=ze,t[60]=bt):bt=t[60];let xt;t[61]!==Ne||t[62]!==ze?(xt=[Ne,ze],t[61]=Ne,t[62]=ze,t[63]=xt):xt=t[63],(0,Q.useEffect)(bt,xt),KB(Ne,ge,Ge,re);let St,Ct;t[64]===Ne?(St=t[65],Ct=t[66]):(St=()=>Ne.subscribe(()=>{if(!Ne.isSearchOpen())for(let e of K.current){let t=WB(Ne.getItem(e));t&&!t.isExpanded()&&t.expand()}}),Ct=[Ne],t[64]=Ne,t[65]=St,t[66]=Ct),(0,Q.useEffect)(St,Ct);let wt,Tt;t[67]===Ne?(wt=t[68],Tt=t[69]):(wt=()=>Ne.onMutation(`remove`,e=>{let t=q.current;!t||e.path!==t.renamePath||ee.current(t)}),Tt=[Ne],t[67]=Ne,t[68]=wt,t[69]=Tt),(0,Q.useEffect)(wt,Tt);let Et;t[70]!==g||t[71]!==s||t[72]!==c||t[73]!==b||t[74]!==p?(Et=async(e,t,n)=>{let r=t===void 0?[]:t,i=n?.docName??V.current,a=mO(i,e),o=n?.folderPath??(fe.current?.kind===`folder`?fe.current.folderPath:null),l=o?Ie(o,r):null,u=hO(e,c());await Promise.all(u.map(e=>s(e)));for(let t of e)g(t.toDocName);p(e,r),C(t=>{let n=fO(t,e,r);return Qe(n),n}),o&&l&&l!==o?b(l):a&&a!==i&&(window.location.hash=Tr(a)),Fr([`files`,`backlinks`,`graph`])},t[70]=g,t[71]=s,t[72]=c,t[73]=b,t[74]=p,t[75]=Et):Et=t[75];let Dt=Et;async function Ot(e){let t=rO(e.sourcePath,e.isFolder);k(t),D(null);try{if(!e.isFolder&&et(t)){X.error(`Assets cannot be renamed from the sidebar`),queueMicrotask(()=>{Ye()}),rt(),k(null);return}let n=cB(e.sourcePath,e.destinationPath,e.isFolder);if(n.kind===`block`){X.error(`File extensions are managed automatically - please rename without changing the extension`),queueMicrotask(()=>{Ye()}),rt(),k(null);return}let r=rO(n.destinationPath,e.isFolder),i=e.isFolder?{kind:`folder`,fromPath:qD(t),toPath:qD(r)}:{kind:`file`,fromPath:WD(t),toPath:WD(r)},a={docName:V.current,folderPath:fe.current?.kind===`folder`?fe.current.folderPath:null},o=await l(await fetch(`/api/rename-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)}),`Failed to rename path`);if(!o.ok){X.error(o.title),D(o.title),Ye();let e=q.current;e&&e.renamePath===t?await at(e):rt(),k(null);return}let s=Ze(Zn,o.body,`rename-path`,{renamed:[]});try{await Dt(s.renamed,e.isFolder?[{fromPath:qD(t),toPath:qD(r)}]:[],a)}catch(e){console.warn(`[FileTree] post-rename reconciliation failed`,{err:e,sourceTreePath:t,destinationTreePath:r,renamedCount:s.renamed.length}),X.error(`Rename succeeded but the sidebar may be out of date — refresh to resync`)}rt(),k(null)}catch(e){console.warn(`[FileTree] rename failed:`,e),X.error(`Network error — please try again`),D(`Network error — please try again`),Ye();let n=q.current;n&&n.renamePath===t?await at(n):rt(),k(null)}}let kt;t[76]!==Dt||t[77]!==Ye?(kt=async function(e){let t=e.draggedPaths.map(t=>{let n=oO(t,e.target);return t===n?null:{sourcePath:t,destinationTreePath:n}}).filter($V);if(t.length!==0){if(t.some(e=>et(e.sourcePath))){X.error(`Assets cannot be moved from the sidebar`),Ye();return}k(t[0]?.sourcePath??null),D(null);try{let e=[],n=[],r={docName:V.current,folderPath:fe.current?.kind===`folder`?fe.current.folderPath:null};for(let r of t){let t=r.sourcePath.endsWith(`/`),i=t?{kind:`folder`,fromPath:qD(r.sourcePath),toPath:qD(r.destinationTreePath)}:{kind:`file`,fromPath:WD(r.sourcePath),toPath:WD(r.destinationTreePath)},a=await l(await fetch(`/api/rename-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)}),`Failed to move`);if(!a.ok){X.error(a.title),D(a.title),Ye(),k(null);return}let o=Ze(Zn,a.body,`rename-path:drop`,{renamed:[]});e=e.concat(o.renamed),t&&n.push({fromPath:qD(r.sourcePath),toPath:qD(r.destinationTreePath)})}try{await Dt(e,n,r)}catch(n){console.warn(`[FileTree] post-move reconciliation failed`,{err:n,operationCount:t.length,renamedCount:e.length}),X.error(`Move succeeded but the sidebar may be out of date — refresh to resync`)}k(null)}catch(e){console.warn(`[FileTree] move failed:`,e),X.error(`Network error — please try again`),Ye(),k(null)}}},t[76]=Dt,t[77]=Ye,t[78]=kt):kt=t[78];let At=kt,jt;t[79]===Symbol.for(`react.memo_cache_sentinel`)?(jt=function(e){F({parentDir:e})},t[79]=jt):jt=t[79];let Mt=jt,Nt;t[80]!==at||t[81]!==rt||t[82]!==Ne||t[83]!==b||t[84]!==v||t[85]!==Ye||t[86]!==Re?(Nt=async function(e,t){if(ie.current)return;let n=q.current;n&&rt(n);try{let n=iO(e,t,[...Re,...Ue.current]);k(n.renamePath),ie.current=n.renamePath;let r=window.location.hash,i;if(e===`file`){let e=aO(`file`,n.addPath),t=await l(await fetch(`/api/create-page`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})}),`Failed to create file`);if(!t.ok){X.error(t.title),D(t.title),k(null),ie.current=null;return}let r=WD(e),a=Ze(wr,t.body,`create-page`,{docName:r}).docName;i=a;let o=e.toLowerCase().endsWith(`.mdx`)?`.mdx`:`.md`;C(e=>{if(e.some(e=>hn(e)&&e.docName===a))return e;let t=[...e,{kind:`document`,docName:a,docExt:o,modified:new Date().toISOString(),size:0}];return Qe(t),t}),Fr([`files`,`backlinks`,`graph`]),v(a)}else{let e=qD(n.addPath),t=await l(await fetch(`/api/create-folder`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})}),`Failed to create folder`);if(!t.ok){X.error(t.title),D(t.title),k(null),ie.current=null;return}i=Ze(Lr,t.body,`create-folder`,{path:e}).path,C(e=>{if(e.some(e=>ti(e)&&e.path===i))return e;let t=[...e,{kind:`folder`,path:i,modified:new Date().toISOString(),size:0}];return Qe(t),t}),Fr([`files`]),b(i)}let a=!1,o=e=>{if(e.key!==`Enter`)return;let t=q.current;!t||t.renamePath!==n.renamePath||queueMicrotask(()=>rt(t))};document.addEventListener(`keydown`,o,!0),q.current={kind:e,renamePath:n.renamePath,createdPath:i,previousHash:r,disposeCommitListener:()=>{a||(a=!0,document.removeEventListener(`keydown`,o,!0))}},k(null),ie.current=null,Ne.add(n.addPath),Ne.startRenaming(n.renamePath,{removeIfCanceled:!0})}catch(e){console.warn(`[FileTree] create placeholder failed:`,e),X.error(`Could not start creating a new item`);let t=q.current;t?await at(t):rt(),k(null),ie.current=null,Ye()}},t[80]=at,t[81]=rt,t[82]=Ne,t[83]=b,t[84]=v,t[85]=Ye,t[86]=Re,t[87]=Nt):Nt=t[87];let Pt=Nt,Ft;t[88]===Ne?Ft=t[89]:(Ft=function(e){let t=JD(e);(0,Q.startTransition)(()=>{for(let e of Ue.current)if(e===t||e.startsWith(t)){let t=WB(Ne.getItem(e));t&&t.expand()}})},t[88]=Ne,t[89]=Ft);let It=Ft,Lt;t[90]===Ne?Lt=t[91]:(Lt=function(e){let t=JD(e),n=new Set(K.current);(0,Q.startTransition)(()=>{for(let e of[...Ue.current].reverse())if((e===t||e.startsWith(t))&&!n.has(e)){let t=WB(Ne.getItem(e));t&&t.collapse()}})},t[90]=Ne,t[91]=Lt);let Rt=Lt,zt;t[92]!==B||t[93]!==We||t[94]!==r||t[95]!==i||t[96]!==U||t[97]!==O||t[98]!==at||t[99]!==S||t[100]!==He||t[101]!==At||t[102]!==Ot||t[103]!==Fe||t[104]!==tt||t[105]!==Te||t[106]!==we||t[107]!==Re?(zt=()=>{R.current=S,V.current=r,fe.current=i,W.current=U,ie.current=O,ae.current=we,oe.current=Te,Be.current=Re,Ue.current=He,K.current=We,ee.current=at,le.current=e=>{if(re.current||e.length!==1)return;let t=e[0];t&&B(Fe(t),S)},ue.current=e=>{tt(e)||X.error(e)},J.current=Ot,de.current=At},t[92]=B,t[93]=We,t[94]=r,t[95]=i,t[96]=U,t[97]=O,t[98]=at,t[99]=S,t[100]=He,t[101]=At,t[102]=Ot,t[103]=Fe,t[104]=tt,t[105]=Te,t[106]=we,t[107]=Re,t[108]=zt):zt=t[108],(0,Q.useLayoutEffect)(zt);let Bt,Vt;t[109]===Ne?(Bt=t[110],Vt=t[111]):(Bt=()=>{let e=e=>{if(!(e.metaKey||e.ctrlKey)||e.altKey||e.key.toLowerCase()!==`a`||RV(e.target))return;let t=ce.current,n=e.target,r=document.activeElement,i=n instanceof Node&&t?.contains(n),a=r instanceof Node&&t?.contains(r);if(!i&&!a)return;let o=new Set([...Ue.current,...Be.current]);re.current=!0;for(let e of o)!e||W.current.has(e)||Ne.getItem(e)?.select();queueMicrotask(()=>{re.current=!1}),e.preventDefault(),e.stopPropagation()};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},Vt=[Ne],t[109]=Ne,t[110]=Bt,t[111]=Vt),(0,Q.useEffect)(Bt,Vt);let Ht,Ut;t[112]!==S.length||t[113]!==w?(Ht=()=>{if(w||S.length===0)return;let e=ce.current?.querySelector(tj)?.shadowRoot;if(!e)return;let t=QV,n=()=>{for(let n of e.querySelectorAll(`[data-item-path]`)){let e=n.dataset.itemPath;if(!e)continue;let r=t(e);n.title!==r&&(n.title=r)}let n=e.querySelector(`[data-type="context-menu-anchor"]`);if(n){let r=e.querySelector(`[data-item-context-hover="true"][data-item-path]`)?.dataset.itemPath,i=r?t(r):``;n.title!==i&&(n.title=i)}};n();let r=new MutationObserver(n);return r.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`data-item-path`,`data-item-context-hover`]}),()=>r.disconnect()},Ut=[w,S.length],t[112]=S.length,t[113]=w,t[114]=Ht,t[115]=Ut):(Ht=t[114],Ut=t[115]),(0,Q.useEffect)(Ht,Ut);let Wt,Gt;t[116]!==S.length||t[117]!==w?(Wt=()=>{if(w||S.length===0)return;let e=ce.current?.querySelector(tj)?.shadowRoot;if(!e)return;let t=()=>dB(e);t();let n=new MutationObserver(t);return n.observe(e,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:[`data-item-path`]}),()=>n.disconnect()},Gt=[w,S.length],t[116]=S.length,t[117]=w,t[118]=Wt,t[119]=Gt):(Wt=t[118],Gt=t[119]),(0,Q.useEffect)(Wt,Gt);let Kt,qt;t[120]!==S.length||t[121]!==w?(Kt=()=>{if(w||S.length===0)return;let e=ce.current?.querySelector(tj)?.shadowRoot;if(!e)return;let t=()=>wB(e);t();let n=new MutationObserver(t);return n.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`data-item-path`]}),()=>n.disconnect()},qt=[w,S.length],t[120]=S.length,t[121]=w,t[122]=Kt,t[123]=qt):(Kt=t[122],qt=t[123]),(0,Q.useEffect)(Kt,qt);let Jt;t[124]===Symbol.for(`react.memo_cache_sentinel`)?(Jt={folderCount:0,expandedCount:0},t[124]=Jt):Jt=t[124];let Yt=(0,Q.useRef)(Jt),Xt=(0,Q.useRef)(Pt),Zt=(0,Q.useRef)(Mt),Qt;t[125]===Pt?Qt=t[126]:(Qt=()=>{Xt.current=Pt,Zt.current=Mt},t[125]=Pt,t[126]=Qt),(0,Q.useEffect)(Qt);let $t,en;t[127]===Ne?($t=t[128],en=t[129]):($t=()=>({startCreating(e,t){Xt.current(e,t)},startCreatingFromTemplate(e){Zt.current(e)},expandAll(){(0,Q.startTransition)(()=>{for(let e of Ue.current){let t=WB(Ne.getItem(e));t&&t.expand()}})},collapseAll(){let e=new Set(K.current);(0,Q.startTransition)(()=>{for(let t of[...Ue.current].reverse()){if(e.has(t))continue;let n=WB(Ne.getItem(t));n&&n.collapse()}})},getFolderState(){let e=Ue.current,t=0;for(let n of e)WB(Ne.getItem(n))?.isExpanded()&&t++;let n=e.length,r=Yt.current;if(r.folderCount===n&&r.expandedCount===t)return r;let i={folderCount:n,expandedCount:t};return Yt.current=i,i},subscribe(e){return Ne.subscribe(e)}}),en=[Ne],t[127]=Ne,t[128]=$t,t[129]=en),(0,Q.useImperativeHandle)(n,$t,en);let tn;t[130]!==rt||t[131]!==s||t[132]!==a||t[133]!==Ne?(tn=async function(e,t,n){let r=zV(e,R.current,Ue.current),i=q.current;i&&e.some(e=>BV(e,i))&&(i.kind===`file`?r.docNames.add(i.createdPath):r.folderPaths.add(i.createdPath),rt(i));let o=new Set([...r.docNames,...t]),c=new Set([...r.folderPaths,...n]);a([...[...o].map(ZV),...[...c].map(XV)],{force:!0}),await Promise.all([...o].map(e=>s(e)));for(let t of e){let e=t.kind===`folder`?JD(t.path):UD(t.path,t.docExt);Ne.getItem(e)&&Ne.remove(e,t.kind===`folder`?{recursive:!0}:void 0)}C(e=>{let t=pO(e,[...o]);for(let e of c)t=pO(t,[],e);return Qe(t),t}),Fr([`files`,`backlinks`,`graph`])},t[130]=rt,t[131]=s,t[132]=a,t[133]=Ne,t[134]=tn):tn=t[134];let nn=tn,rn;t[135]===nn?rn=t[136]:(rn=async function(e){let t=[],n=[],r=[];for(let i of e){k(i.path);let e=await l(await fetch(`/api/delete-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:i.kind,path:i.path})}),`Failed to delete path`);if(!e.ok)return r.length>0&&await nn(r,t,n),X.error(e.title),!1;let a=Ze(ei,e.body,`delete-path`,{deletedDocNames:[]});t.push(...a.deletedDocNames),i.kind===`folder`&&n.push(i.path),r.push(i)}return await nn(r,t,n),!0},t[135]=nn,t[136]=rn);let an=rn,on;t[137]===Symbol.for(`react.memo_cache_sentinel`)?(on=async function(e,t,n){let r=[],i=[];for(let a of e){k(a.path);let e=gO(a,n),o=await t.shell.trashItem(e);o.ok?r.push(a):i.push({kind:a.kind,path:a.path,name:a.name,reason:RB(o.reason),detail:o.detail})}return{trashed:r,failed:i}},t[137]=on):on=t[137];let sn=on,cn;t[138]===Symbol.for(`react.memo_cache_sentinel`)?(cn=async function(e){let t=[],n=[],r=[];for(let i of e)try{let e=await l(await fetch(`/api/trash/cleanup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:i.kind,path:i.path})}),`Failed to clean up after trash`);if(!e.ok){console.warn(`[FileTree] trash-cleanup failed`,{target:`${i.kind}:${i.path}`,reason:e.title}),r.push({target:i,reason:e.title});continue}let a=Ze(ir,e.body,`trash-cleanup`,{deletedDocNames:[]});t.push(...a.deletedDocNames),i.kind===`folder`&&n.push(i.path)}catch(e){let t=e;console.warn(`[FileTree] trash-cleanup threw`,{target:`${i.kind}:${i.path}`,err:t}),r.push({target:i,reason:`Network error during cleanup`})}if(r.length>0){let e=r.length,t=e===1?`item`:`items`;X.error(`Server-side cleanup failed for ${e} ${t}`,{description:`The file is in your Trash; the file-watcher will reconcile.`})}return r.length===e.length&&e.length>0?null:{deletedDocNames:t,deletedFolderPaths:n}},t[138]=cn):cn=t[138];let ln=cn,un;t[139]!==nn||t[140]!==an||t[141]!==Ye||t[142]!==I?(un=async function(e){let t=e[0];if(!t)return;k(t.path),j(null);let n=typeof window<`u`?window.okDesktop:void 0;try{if(n&&I){let{trashed:t,failed:r}=await sn(e,n,I);if(t.length>0){let e=await ln(t);e?await nn(t,e.deletedDocNames,e.deletedFolderPaths):await nn(t,t.filter(YV).map(JV),t.filter(qV).map(KV))}r.length>0&&N({failed:r,originalTargets:[...e]}),k(null)}else{let t=await an(e);k(null),t||Ye()}}catch(e){let t=e,n=t instanceof Error?t.message:String(t);console.warn(`[FileTree] delete failed:`,t),X.error(`Could not complete delete`,{description:n}),k(null),Ye()}},t[139]=nn,t[140]=an,t[141]=Ye,t[142]=I,t[143]=un):un=t[143];let dn=un,fn;t[144]!==an||t[145]!==Ye||t[146]!==M?(fn=async function(){if(!M)return;let e=new Set(M.failed.map(GV)),t=M.originalTargets.filter(t=>e.has(`${t.kind}:${t.path}`));if(N(null),t.length!==0){k(t[0]?.path??null);try{let e=await an(t);k(null),e||Ye()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);console.warn(`[FileTree] hard-delete fallback failed:`,t),X.error(`Could not complete delete`,{description:n}),k(null),Ye()}}},t[144]=an,t[145]=Ye,t[146]=M,t[147]=fn):fn=t[147];let pn=fn,mn;t[148]!==dn||t[149]!==M?(mn=async function(){if(!M)return;let e=new Set(M.failed.map(WV)),t=M.originalTargets.filter(t=>e.has(`${t.kind}:${t.path}`));N(null),await dn(t)},t[148]=dn,t[149]=M,t[150]=mn):mn=t[150];let gn=mn,_n=(0,Q.useRef)(dn),vn;t[151]===dn?vn=t[152]:(vn=()=>{_n.current=dn},t[151]=dn,t[152]=vn),(0,Q.useEffect)(vn);let yn,bn;t[153]===Symbol.for(`react.memo_cache_sentinel`)?(yn=()=>QB(e=>{if(e.kind===`doc`||e.kind===`folder-index`){let t=e.docName,n=R.current.find(e=>hn(e)&&e.docName===t);_n.current([{kind:`file`,path:t,name:t.split(`/`).pop()??t,docExt:n?.docExt}]);return}if(e.kind===`folder`){_n.current([{kind:`folder`,path:e.folderPath,name:e.folderPath.split(`/`).pop()??e.folderPath}]);return}console.warn(JSON.stringify({event:`file-tree-menu-action-delete-unsupported-kind`,kind:e.kind}))}),bn=[],t[153]=yn,t[154]=bn):(yn=t[153],bn=t[154]),(0,Q.useEffect)(yn,bn);let xn,Sn;t[155]===Ne?(xn=t[156],Sn=t[157]):(xn=()=>eV(e=>{if(e.kind===`doc`||e.kind===`folder-index`){let t=e.docName,n=UD(t,R.current.find(e=>hn(e)&&e.docName===t)?.docExt);Ne.startRenaming(n);return}if(e.kind===`folder`){Ne.startRenaming(e.folderPath);return}console.warn(JSON.stringify({event:`file-tree-menu-action-rename-unsupported-kind`,kind:e.kind}))}),Sn=[Ne],t[155]=Ne,t[156]=xn,t[157]=Sn),(0,Q.useEffect)(xn,Sn);let Cn;t[158]===Symbol.for(`react.memo_cache_sentinel`)?(Cn=function(){let e=ne.current;e&&gV(e),ne.current=null},t[158]=Cn):Cn=t[158];let wn=Cn,Tn;t[159]===f?Tn=t[160]:(Tn=function(e){let t=lH(e.nativeEvent);if(!t||t.endsWith(`/`)){wn();return}let n=WD(t),r=R.current.find(e=>GD(e)===t);if(r&&Hn(r)){wn();return}ne.current!==n&&(wn(),ne.current=n,hV(n,e=>f(e)))},t[159]=f,t[160]=Tn);let En=Tn,Dn;t[161]!==B||t[162]!==Ne||t[163]!==b?(Dn=function(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=uH(e.nativeEvent);if(!t||t.getAttribute(`aria-selected`)!==`true`)return;let n=t.dataset.itemPath;if(!n)return;let r=t.dataset.itemType===`folder`?JD(n):n;if(Ne.getSelectedPaths().length!==1)return;if(t.dataset.itemType===`folder`){let e=qD(r);if(window.location.hash===or(e))return;queueMicrotask(()=>b(e));return}let i=WD(r);window.location.hash!==Tr(i)&&queueMicrotask(()=>B(r))},t[161]=B,t[162]=Ne,t[163]=b,t[164]=Dn):Dn=t[164];let On=Dn;if(w){let e;return t[165]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(fH,{}),t[165]=e):e=t[165],e}if(S.length===0){if(E){let e;return t[166]===E?e=t[167]:(e=(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-8`,children:(0,Z.jsx)(`span`,{className:`select-none text-sidebar-foreground/50 text-sm`,children:E})}),t[166]=E,t[167]=e),e}let e;t[168]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`span`,{className:`select-none text-sidebar-foreground/30 text-sm`,children:`No files yet.`}),t[168]=e):e=t[168];let n;return t[169]===Pt?n=t[170]:(n=(0,Z.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 py-8`,children:[e,(0,Z.jsx)(Y,{variant:`link`,size:`sm`,className:`font-mono uppercase`,onClick:()=>Pt(`file`,``),children:`Create your first file`})]}),t[169]=Pt,t[170]=n),n}let kn=O!==null,An=A?.targets[0]??null,jn;t[171]===E?jn=t[172]:(jn=E&&(0,Z.jsx)(`span`,{role:`alert`,className:`px-3 pb-1 text-destructive text-xs`,children:E}),t[171]=E,t[172]=jn);let Mn;t[173]===h?Mn=t[174]:(Mn=kV(h),t[173]=h,t[174]=Mn);let Nn;t[175]!==kn||t[176]!==U||t[177]!==Rt||t[178]!==It||t[179]!==He||t[180]!==be||t[181]!==Ce||t[182]!==Ne||t[183]!==xe||t[184]!==Se||t[185]!==Pt||t[186]!==I?(Nn=(e,t)=>(0,Z.jsx)(VV,{item:e,context:t,anyActionBusy:kn,workspace:I,handoff:be,model:Ne,okignoreBinding:xe,projectLocalBinding:Se,mergedConfig:Ce,onStartCreating:Pt,onStartCreatingFromTemplate:Mt,onDelete:e=>j({targets:e}),onExpandSubtree:It,onCollapseSubtree:Rt,folderTreePaths:He,isAsset:U.has(e.path),isAssetTreePath:et}),t[175]=kn,t[176]=U,t[177]=Rt,t[178]=It,t[179]=He,t[180]=be,t[181]=Ce,t[182]=Ne,t[183]=xe,t[184]=Se,t[185]=Pt,t[186]=I,t[187]=Nn):Nn=t[187];let Pn;t[188]!==On||t[189]!==En||t[190]!==Ne||t[191]!==jn||t[192]!==Mn||t[193]!==Nn?(Pn=(0,Z.jsx)(`div`,{ref:ce,className:`flex min-h-0 flex-1 flex-col`,children:(0,Z.jsx)(iB,{header:jn,model:Ne,style:Mn,onClickCapture:On,onMouseMove:En,onMouseLeave:wn,renderContextMenu:Nn})}),t[188]=On,t[189]=En,t[190]=Ne,t[191]=jn,t[192]=Mn,t[193]=Nn,t[194]=Pn):Pn=t[194];let Fn=!!A,In;t[195]===O?In=t[196]:(In=e=>{!e&&!O&&j(null)},t[195]=O,t[196]=In);let Ln;t[197]!==O||t[198]!==A||t[199]!==dn||t[200]!==An?(Ln=A&&An&&(0,Z.jsx)(io,{...(()=>{let e=FB(typeof window<`u`&&window.okDesktop!=null?`electron`:`web`,A.targets);return e?{customTitle:e.title,customDescription:``,customDetail:e.detail,customConfirmLabel:e.confirmLabel,customConfirmLabelBusy:e.confirmLabelBusy,children:e.listedTargets?(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1 font-mono text-foreground text-xs`,children:e.listedTargets.map(UV)}):null}:{itemName:A.targets.length===1?`${An.name}${An.kind===`file`?An.docExt??`.md`:`/`}`:void 0,customTitle:A.targets.length>1?`Delete selected items`:void 0,customDescription:A.targets.length>1?`Are you sure you want to delete ${A.targets.length} selected items? Folders and all files inside them will be deleted. This action cannot be undone.`:An.kind===`folder`?`Are you sure you want to delete ${An.name}/ and all files inside? This action cannot be undone.`:void 0}})(),isSubmitting:O!==null,onDelete:()=>dn(A.targets)}),t[197]=O,t[198]=A,t[199]=dn,t[200]=An,t[201]=Ln):Ln=t[201];let Rn;t[202]!==Fn||t[203]!==In||t[204]!==Ln?(Rn=(0,Z.jsx)(jo,{open:Fn,onOpenChange:In,children:Ln}),t[202]=Fn,t[203]=In,t[204]=Ln,t[205]=Rn):Rn=t[205];let zn=!!M,Bn;t[206]===O?Bn=t[207]:(Bn=e=>{!e&&!O&&N(null)},t[206]=O,t[207]=Bn);let Vn;t[208]!==O||t[209]!==pn||t[210]!==gn||t[211]!==M?(Vn=M&&(0,Z.jsx)(HB,{failedTargets:M.failed,isSubmitting:O!==null,onDeletePermanently:pn,onRetry:gn,onCancel:()=>N(null)}),t[208]=O,t[209]=pn,t[210]=gn,t[211]=M,t[212]=Vn):Vn=t[212];let Un;t[213]!==zn||t[214]!==Bn||t[215]!==Vn?(Un=(0,Z.jsx)(jo,{open:zn,onOpenChange:Bn,children:Vn}),t[213]=zn,t[214]=Bn,t[215]=Vn,t[216]=Un):Un=t[216];let Wn=P!==null,Gn;t[217]===Symbol.for(`react.memo_cache_sentinel`)?(Gn=e=>{e||F(null)},t[217]=Gn):Gn=t[217];let Kn=P?.parentDir??``,qn;t[218]!==Wn||t[219]!==Kn?(qn=(0,Z.jsx)(Hp,{open:Wn,onOpenChange:Gn,kind:`file`,initialDir:Kn}),t[218]=Wn,t[219]=Kn,t[220]=qn):qn=t[220];let Jn;return t[221]!==Pn||t[222]!==Rn||t[223]!==Un||t[224]!==qn?(Jn=(0,Z.jsxs)(Z.Fragment,{children:[Pn,Rn,Un,qn]}),t[221]=Pn,t[222]=Rn,t[223]=Un,t[224]=qn,t[225]=Jn):Jn=t[225],Jn}function UV(e){return(0,Z.jsx)(`li`,{"data-testid":`delete-target-row`,children:IB(e)},`${e.kind}:${e.path}`)}function WV(e){return`${e.kind}:${e.path}`}function GV(e){return`${e.kind}:${e.path}`}function KV(e){return e.path}function qV(e){return e.kind===`folder`}function JV(e){return e.path}function YV(e){return e.kind===`file`}function XV(e){return lt(e)}function ZV(e){return Je(e)}function QV(e){return e.endsWith(`/`)?e.slice(0,-1):e}function $V(e){return!!e}function eH(e){console.warn(`[FileTree] /api/workspace fetch failed:`,e)}function tH(e){console.warn(`[FileTree] unmount cleanup failed:`,e)}function nH(e){X.error(e)}function rH(){}function iH(e){return X.error(e)}function aH(){}function oH(){}async function sH(){}function cH(e){return GD(e)}function lH(e){return uH(e)?.dataset.itemPath??null}function uH(e){for(let t of e.composedPath())if(t instanceof HTMLElement&&t.dataset.itemPath)return t;return null}var dH=[`w-3/4`,`w-2/3`,`w-4/5`,`w-1/2`,`w-3/5`,`w-2/3`];function fH(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`div`,{className:`flex flex-1 flex-col gap-1 px-2 py-2`,role:`status`,"aria-busy":`true`,"aria-label":`Loading files`,children:dH.map(pH)}),e[0]=t):t=e[0],t}function pH(e,t){return(0,Z.jsxs)(`div`,{className:`flex h-6 items-center gap-2`,children:[(0,Z.jsx)(Ma,{className:`h-3 w-3 shrink-0 rounded-sm`}),(0,Z.jsx)(Ma,{className:`h-3 ${e}`})]},t)}function mH(e){return e?`No workspace`:null}function hH(e){let t=(0,$.c)(41),{input:n,installStates:r,dispatch:i,webFallbackVisible:a}=e,o=a===void 0?!0:a,s=n===null,c;t[0]===s?c=t[1]:(c=mH(s),t[0]=s,t[1]=c);let l=c,u,d,f,p,m,h,g;if(t[2]!==i||t[3]!==l||t[4]!==n||t[5]!==s||t[6]!==r||t[7]!==o){g=Symbol.for(`react.early_return_sentinel`);bb0:{let e;t[15]===r?e=t[16]:(e=e=>r[e.id]?.installed===!0,t[15]=r,t[16]=e);let a=xm.filter(e);f=r[`claude-code`]?.installed===!0;let c;t[17]===n?c=t[18]:(c=n!==null&&n.docContext!==null?$r(n.docContext.relativePath):``,t[17]=n,t[18]=c);let _=c,v;t[19]!==n||t[20]!==_?(v=()=>{n!==null&&qx(_)},t[19]=n,t[20]=_,t[21]=v):v=t[21],p=v;let y=o&&!f;if(a.length===0&&!y){g=null;break bb0}d=xO,t[22]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsxs)(wO,{children:[(0,Z.jsx)(Fi,{"aria-hidden":`true`}),`Open with AI`]}),t[22]=h):h=t[22],u=TO;let b;t[23]!==i||t[24]!==l||t[25]!==n||t[26]!==s?(b=e=>{let t=!s,r=l?`Open with AI ${e.displayName}, ${l}`:`Open with AI ${e.displayName}`;return(0,Z.jsxs)(CO,{disabled:!t,onSelect:()=>{n&&i(e.id,n)},"data-testid":`empty-space-open-in-${e.id}`,"aria-label":r,children:[(0,Z.jsx)(Vx,{id:e.id,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:e.displayName}),l?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:l}):null]},e.id)},t[23]=i,t[24]=l,t[25]=n,t[26]=s,t[27]=b):b=t[27],m=a.map(b)}t[2]=i,t[3]=l,t[4]=n,t[5]=s,t[6]=r,t[7]=o,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g}else u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14];if(g!==Symbol.for(`react.early_return_sentinel`))return g;let _;t[28]!==f||t[29]!==p||t[30]!==s||t[31]!==o?(_=o&&!f?(0,Z.jsxs)(CO,{onSelect:p,disabled:s,"data-testid":`empty-space-open-in-claude-web-fallback`,"aria-label":`Open in claude.ai, opens in browser with prompt pre-filled`,children:[(0,Z.jsx)(he,{className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:`Open in claude.ai →`}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`opens in browser`})]}):null,t[28]=f,t[29]=p,t[30]=s,t[31]=o,t[32]=_):_=t[32];let v;t[33]!==u||t[34]!==m||t[35]!==_?(v=(0,Z.jsxs)(u,{children:[m,_]}),t[33]=u,t[34]=m,t[35]=_,t[36]=v):v=t[36];let y;return t[37]!==d||t[38]!==h||t[39]!==v?(y=(0,Z.jsxs)(d,{children:[h,v]}),t[37]=d,t[38]=h,t[39]=v,t[40]=y):y=t[40],y}var gH=(e,t,n)=>il(e,t,n,`ProjectSwitcher`);function _H(e){let t=(0,$.c)(59),{bridge:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let[i,a]=(0,Q.useState)(r),[o,s]=(0,Q.useState)(!1),c;t[1]!==n.project||t[2]!==o?(c=()=>{if(!o)return;let e=!1;return gH(async()=>{let t=await n.project.listRecent();e||a(t)},`Failed to load recent projects.`),()=>{e=!0}},t[1]=n.project,t[2]=o,t[3]=c):c=t[3];let l;t[4]!==n||t[5]!==o?(l=[o,n],t[4]=n,t[5]=o,t[6]=l):l=t[6],(0,Q.useEffect)(c,l);let u;t[7]===n.project?u=t[8]:(u=e=>{s(!1),gH(()=>n.project.open({path:e,target:`new-window`,entryPoint:`recents`}),`Failed to open project.`)},t[7]=n.project,t[8]=u);let d=u,f;t[9]!==n.dialog||t[10]!==n.project?(f=()=>{s(!1),gH(async()=>{let e=await n.dialog.openFolder();e&&await n.project.open({path:e,target:`new-window`,entryPoint:`pick-existing`})},`Failed to open folder.`)},t[9]=n.dialog,t[10]=n.project,t[11]=f):f=t[11];let p=f,m;t[12]===n.navigator?m=t[13]:(m=()=>{s(!1),gH(()=>n.navigator.open(),`Failed to open Project Navigator.`)},t[12]=n.navigator,t[13]=m);let h=m,g=n.config.projectPath,_,v,y,b,x,S,C,w,T,E,D;if(t[14]!==n.config.projectName||t[15]!==g||t[16]!==o||t[17]!==d||t[18]!==i){let e;t[30]===g?e=t[31]:(e=e=>e.path!==g,t[30]=g,t[31]=e);let r=i.filter(e);v=va,S=o,C=s;let a;t[32]===n.config.projectName?a=t[33]:(a=(0,Z.jsx)(`span`,{className:`truncate`,children:n.config.projectName}),t[32]=n.config.projectName,t[33]=a);let c;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(qs,{"aria-hidden":`true`,className:`opacity-60`}),t[34]=c):c=t[34],t[35]===a?w=t[36]:(w=(0,Z.jsx)(ba,{asChild:!0,children:(0,Z.jsxs)(yD,{className:`justify-between text-sidebar-foreground/70`,"data-testid":`project-switcher-trigger`,title:`Open project menu`,children:[a,c]})}),t[35]=a,t[36]=w),_=_a,T=`start`,E=`top`,D=`min-w-[260px]`,y=`project-switcher-menu`,t[37]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(Qi,{className:`font-mono font-normal tracking-wide uppercase text-muted-foreground text-xs`,children:`Recent projects`}),t[37]=b):b=t[37],x=r.length===0?(0,Z.jsx)(Qi,{className:`font-normal text-muted-foreground text-xs`,children:`No other recent projects.`}):r.slice(0,10).map(e=>(0,Z.jsxs)(ya,{disabled:e.missing,onSelect:()=>d(e.path),className:`flex flex-col items-start gap-0.5`,"data-testid":`project-switcher-recent-${e.path}`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),(0,Z.jsxs)(`span`,{className:`max-w-[240px] truncate text-muted-foreground text-xs`,children:[e.path,e.missing?` (missing)`:``]})]},e.path)),t[14]=n.config.projectName,t[15]=g,t[16]=o,t[17]=d,t[18]=i,t[19]=_,t[20]=v,t[21]=y,t[22]=b,t[23]=x,t[24]=S,t[25]=C,t[26]=w,t[27]=T,t[28]=E,t[29]=D}else _=t[19],v=t[20],y=t[21],b=t[22],x=t[23],S=t[24],C=t[25],w=t[26],T=t[27],E=t[28],D=t[29];let O;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(na,{}),t[38]=O):O=t[38];let k;t[39]===p?k=t[40]:(k=(0,Z.jsx)(ya,{onSelect:p,"data-testid":`project-switcher-open-folder`,children:`Open folder`}),t[39]=p,t[40]=k);let A;t[41]===h?A=t[42]:(A=(0,Z.jsx)(ya,{onSelect:h,"data-testid":`project-switcher-switch-project`,children:`Switch Project`}),t[41]=h,t[42]=A);let j;t[43]!==_||t[44]!==y||t[45]!==b||t[46]!==x||t[47]!==k||t[48]!==A||t[49]!==T||t[50]!==E||t[51]!==D?(j=(0,Z.jsxs)(_,{align:T,side:E,className:D,"data-testid":y,children:[b,x,O,k,A]}),t[43]=_,t[44]=y,t[45]=b,t[46]=x,t[47]=k,t[48]=A,t[49]=T,t[50]=E,t[51]=D,t[52]=j):j=t[52];let M;return t[53]!==v||t[54]!==S||t[55]!==C||t[56]!==w||t[57]!==j?(M=(0,Z.jsxs)(v,{open:S,onOpenChange:C,children:[w,j]}),t[53]=v,t[54]=S,t[55]=C,t[56]=w,t[57]=j,t[58]=M):M=t[58],M}function vH(e,t){let n=e instanceof Error?e:Error(String(e));console.warn(JSON.stringify({event:`jsx-render-failure`,component:`sidebarSearchPill`,rawComponentName:`sidebarSearchPill`,error:String(n),stack:t.componentStack})),Hr(`sidebarSearchPill`)}function yH(e){let t=(0,$.c)(8),{onClick:n,className:r}=e,i;t[0]===r?i=t[1]:(i=mi(`rounded-lg h-9 w-full justify-start gap-2 px-3 font-normal text-muted-foreground`,r),t[0]=r,t[1]=i);let a,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Me,{"aria-hidden":`true`}),o=(0,Z.jsx)(`span`,{className:`flex-1 text-left text-sm`,children:`Search`}),t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(OS,{className:`text-foreground/70`,children:Dn()?`⌘ K`:`Ctrl K`}),t[4]=s):s=t[4];let c;return t[5]!==n||t[6]!==i?(c=(0,Z.jsxs)(Y,{variant:`outline`,onClick:n,"data-telemetry-event":`ok.sidebar.search_pill.click`,className:i,children:[a,o,s]}),t[5]=n,t[6]=i,t[7]=c):c=t[7],c}function bH(e){let t=(0,$.c)(33),{notice:n,onDismiss:r}=e,i=n.variant===`error`?`border-destructive/60`:`border-sidebar-border`,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(_o,{"aria-hidden":`true`,className:`size-3`}),t[0]=a):a=t[0];let o;t[1]===r?o=t[2]:(o=(0,Z.jsx)(Y,{variant:`ghost`,size:`icon`,className:`size-5 shrink-0 text-muted-foreground hover:text-sidebar-foreground`,"aria-label":`Dismiss notice`,onClick:r,children:a}),t[1]=r,t[2]=o);let s=o;if(n.secondaryAction){let e=`update-notice-${n.id}`,r=`flex flex-col gap-2 rounded-md border bg-sidebar-accent/30 px-2 py-2 text-xs text-muted-foreground ${i}`,a;t[3]===n.body?a=t[4]:(a=(0,Z.jsx)(`span`,{className:`flex-1 leading-snug`,children:n.body}),t[3]=n.body,t[4]=a);let o;t[5]!==s||t[6]!==a?(o=(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[a,s]}),t[5]=s,t[6]=a,t[7]=o):o=t[7];let c;t[8]===n.action?c=t[9]:(c=n.action?(0,Z.jsx)(`button`,{type:`button`,className:`shrink-0 text-xs font-medium underline underline-offset-2 decoration-muted-foreground/40 hover:text-sidebar-foreground hover:decoration-sidebar-foreground`,onClick:()=>{n.action?.onClick()},children:n.action.label}):null,t[8]=n.action,t[9]=c);let l;t[10]===n.secondaryAction?l=t[11]:(l=()=>{n.secondaryAction?.onClick()},t[10]=n.secondaryAction,t[11]=l);let u;t[12]!==n.secondaryAction.label||t[13]!==l?(u=(0,Z.jsx)(`button`,{type:`button`,className:`shrink-0 text-xs font-medium underline underline-offset-2 decoration-muted-foreground/40 hover:text-sidebar-foreground hover:decoration-sidebar-foreground`,onClick:l,children:n.secondaryAction.label}),t[12]=n.secondaryAction.label,t[13]=l,t[14]=u):u=t[14];let d;t[15]!==c||t[16]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex gap-3 pl-1`,children:[c,u]}),t[15]=c,t[16]=u,t[17]=d):d=t[17];let f;return t[18]!==d||t[19]!==e||t[20]!==r||t[21]!==o?(f=(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":e,className:r,children:[o,d]}),t[18]=d,t[19]=e,t[20]=r,t[21]=o,t[22]=f):f=t[22],f}let c=`update-notice-${n.id}`,l=`flex items-center gap-2 rounded-md border bg-sidebar-accent/30 px-2 py-1.5 text-xs text-muted-foreground ${i}`,u;t[23]===n.body?u=t[24]:(u=(0,Z.jsx)(`span`,{className:`flex-1 leading-snug`,children:n.body}),t[23]=n.body,t[24]=u);let d;t[25]===n.action?d=t[26]:(d=n.action?(0,Z.jsx)(`button`,{type:`button`,className:`shrink-0 text-xs font-medium underline underline-offset-2 decoration-muted-foreground/40 hover:text-sidebar-foreground hover:decoration-sidebar-foreground`,onClick:()=>{n.action?.onClick()},children:n.action.label}):null,t[25]=n.action,t[26]=d);let f;return t[27]!==s||t[28]!==c||t[29]!==l||t[30]!==u||t[31]!==d?(f=(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":c,className:l,children:[u,d,s]}),t[27]=s,t[28]=c,t[29]=l,t[30]=u,t[31]=d,t[32]=f):f=t[32],f}function xH(e){if(e.length===0)return null;let t=e[0];if(!t)return null;for(let n=1;n<e.length;n++){let r=e[n];r&&r.priority<t.priority&&(t=r)}return t}function SH(){let e=(0,$.c)(7),t=(0,Q.useSyncExternalStore)(qf,Kf,Kf),n;e[0]===t?n=e[1]:(n=xH(t),e[0]=t,e[1]=n);let r=n;if(!r)return null;let i;e[2]===r.id?i=e[3]:(i=()=>{Gf(r.id)},e[2]=r.id,e[3]=i);let a;return e[4]!==r||e[5]!==i?(a=(0,Z.jsx)(`div`,{"data-testid":`update-notices-list`,children:(0,Z.jsx)(bH,{notice:r,onDismiss:i})}),e[4]=r,e[5]=i,e[6]=a):a=e[6],a}function CH(e,t,n){return e?.kind===`doc`&&t||e?.kind===`folder-index`&&t?nh(n.contentDir,rh(t),n.pathSeparator):e?.kind===`folder`?nh(n.contentDir,e.folderPath,n.pathSeparator):n.contentDir}function wH(e,t,n){if((e?.kind===`doc`||e?.kind===`folder-index`)&&t){let e=t.lastIndexOf(`/`);return e<0?n.contentDir:nh(n.contentDir,t.slice(0,e),n.pathSeparator)}return e?.kind===`folder`?nh(n.contentDir,e.folderPath,n.pathSeparator):n.contentDir}function TH(e,t){return(e?.kind===`doc`||e?.kind===`folder-index`)&&t?rh(t):e?.kind===`folder`?e.folderPath:``}function EH(e,t,n){return e===null?ah({workspace:n}):e.kind===`folder`?n?oh({folderAbsPath:nh(n.contentDir,e.folderPath,n.pathSeparator),folderRelativePath:e.folderPath,workspace:n}):null:e.kind===`doc`||e.kind===`folder-index`?ih({docName:t,workspace:n}):null}var DH={folderCount:0,expandedCount:0},OH=`button, [role="button"], [role="menuitem"], input, textarea, select, a[href]`;function kH(e){return typeof Element>`u`||!(e instanceof Element)?!1:e.closest(OH)!==null}function AH(e){let t=(0,$.c)(2),{onOpenSearch:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(Ve,{name:`file-sidebar`,children:(0,Z.jsx)(MH,{onOpenSearch:n})}),t[0]=n,t[1]=r),r}var jH=e=>{let t=(0,$.c)(15),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({icon:n,label:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=(0,Z.jsx)(n,{"aria-hidden":`true`}),t[4]=n,t[5]=a);let o;t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,"aria-label":r,...i,children:a})}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9];let s;t[10]===r?s=t[11]:(s=(0,Z.jsx)(vn,{children:r}),t[10]=r,t[11]=s);let c;return t[12]!==o||t[13]!==s?(c=(0,Z.jsxs)(yn,{children:[o,s]}),t[12]=o,t[13]=s,t[14]=c):c=t[14],c};function MH(e){let t=(0,$.c)(164),{onOpenSearch:n}=e,[r,i]=(0,Q.useState)(null),{activeDocName:a,activeTarget:o}=ot(),s;t[0]!==a||t[1]!==o?(s=o?.kind===`folder`||o?.kind===`folder-index`?o.folderPath:sr(a),t[0]=a,t[1]=o,t[2]=s):s=t[2];let c=s,l=typeof window<`u`&&window.okDesktop!=null,{state:u}=aD(),d=u===`expanded`,f=l&&u===`collapsed`,[p,m]=(0,Q.useState)(DH),h,g;t[3]===r?(h=t[4],g=t[5]):(h=()=>{if(r!==null)return m(r.getFolderState()),r.subscribe(()=>{m(r.getFolderState())})},g=[r],t[3]=r,t[4]=h,t[5]=g),(0,Q.useEffect)(h,g);let _,v;t[6]===r?(_=t[7],v=t[8]):(_=()=>{if(r!==null)return MS(()=>{r.startCreating(`file`,``)})},v=[r],t[6]=r,t[7]=_,t[8]=v),(0,Q.useEffect)(_,v);let y=p.folderCount>0,b=y&&p.expandedCount===p.folderCount,x=p.expandedCount===0,S=Aa(``),C=S.state.status===`ready`?(S.state.data.folder.templates_available?.length??0)>0:!0,w=typeof window<`u`?window.okDesktop:void 0,T=km(),D=Oh().states,{dispatch:k}=_h(),A;t[9]===T?A=t[10]:(A=ah({workspace:T}),t[9]=T,t[10]=A);let j=A,{projectLocalBinding:M,merged:N}=Ga(),P=N?.appearance?.sidebar?.showHiddenFiles??!1,F=N?.appearance?.sidebar?.showAllFiles??!1,I=y&&!b,L=y&&!x,z=I||L,B=IH,V;t[11]!==r||t[12]!==T?(V=()=>{T&&r?.startCreating(`file`,``)},t[11]=r,t[12]=T,t[13]=V):V=t[13];let H=V,U;t[14]!==r||t[15]!==T?(U=()=>{T&&r?.startCreatingFromTemplate(``)},t[14]=r,t[15]=T,t[16]=U):U=t[16];let W=U,G;t[17]!==r||t[18]!==T?(G=()=>{T&&r?.startCreating(`folder`,``)},t[17]=r,t[18]=T,t[19]=G):G=t[19];let K=G,q;t[20]===T?q=t[21]:(q=()=>{!T||!w||w.shell.showItemInFolder(T.contentDir)},t[20]=T,t[21]=q);let ee=q,te;t[22]===T?te=t[23]:(te=()=>{!T||!w||JB(w,T.contentDir)},t[22]=T,t[23]=te);let ne=te,re;t[24]===T?re=t[25]:(re=async()=>{if(T)try{await navigator.clipboard.writeText(T.contentDir),X.success(`Copied full path`,{description:T.contentDir})}catch(e){console.warn(`[FileSidebar] clipboard write failed:`,e),X.error(`Could not copy full path`)}},t[24]=T,t[25]=re);let ie=re,ae;t[26]===M?ae=t[27]:(ae=e=>{if(M===null)return;let t=M.patch({appearance:{sidebar:{showHiddenFiles:e}}});t.ok||(console.warn(`[FileSidebar] showHiddenFiles toggle rejected:`,Nn(t.error)),X.error(`Could not update sidebar settings`,{description:Nn(t.error)}))},t[26]=M,t[27]=ae);let oe=ae,se;t[28]===M?se=t[29]:(se=e=>{if(M===null)return;let t=M.patch({appearance:{sidebar:{showAllFiles:e}}});t.ok||(console.warn(`[FileSidebar] showAllFiles toggle rejected:`,Nn(t.error)),X.error(`Could not update sidebar settings`,{description:Nn(t.error)}))},t[28]=M,t[29]=se);let ce=se,le;t[30]===r?le=t[31]:(le=()=>{r?.expandAll()},t[30]=r,t[31]=le);let J=le,ue;t[32]===r?ue=t[33]:(ue=()=>{r?.collapseAll()},t[32]=r,t[33]=ue);let de=ue,fe,pe;t[34]!==F||t[35]!==L||t[36]!==I||t[37]!==P?(fe=()=>{w&&w.editor.notifyViewMenuStateChanged({showHiddenFiles:P,showAllFiles:F,canExpandAll:I,canCollapseAll:L})},pe=[w,P,F,I,L],t[34]=F,t[35]=L,t[36]=I,t[37]=P,t[38]=fe,t[39]=pe):(fe=t[38],pe=t[39]),(0,Q.useEffect)(fe,pe);let me,he;t[40]!==a||t[41]!==o||t[42]!==k||t[43]!==D||t[44]!==c||t[45]!==M||t[46]!==F||t[47]!==P||t[48]!==r||t[49]!==T?(me=()=>{if(w)return w.onMenuAction(e=>{switch(e){case`new-doc`:if(!T||!r)return;r.startCreating(`file`,c);return;case`new-folder`:if(!T||!r)return;r.startCreating(`folder`,c);return;case`new-from-template`:if(!T||!r)return;r.startCreatingFromTemplate(c);return;case`rename`:if(!o)return;$B(o);return;case`move-to-trash`:if(!o)return;ZB(o);return;case`reveal-in-finder`:{if(!w||!T)return;let e=CH(o,a,T);w.shell.showItemInFolder(e);return}case`open-in-terminal`:if(!w||!T)return;JB(w,wH(o,a,T));return;case`send-to-ai`:{let e=xm.filter(e=>D[e.id]?.installed===!0);if(e.length===0){X.error(`No AI agents installed`);return}let t=EH(o,a,T);if(!t)return;let[n]=e;if(!n)return;k(n.id,t);return}case`copy-full-path`:{if(!T)return;let e=CH(o,a,T);navigator.clipboard.writeText(e).then(()=>X.success(`Copied full path`,{description:e})).catch(FH);return}case`copy-relative-path`:{let e=TH(o,a);if(e===``){X.error(`No file or folder selected`);return}navigator.clipboard.writeText(e).then(()=>X.success(`Copied relative path`,{description:e})).catch(PH);return}case`toggle-show-hidden-files`:{if(M===null)return;let e=M.patch({appearance:{sidebar:{showHiddenFiles:!P}}});e.ok||(console.warn(`[FileSidebar] toggle-show-hidden-files rejected:`,Nn(e.error)),X.error(`Could not update sidebar settings`,{description:Nn(e.error)}));return}case`toggle-show-all-files`:{if(M===null)return;let e=M.patch({appearance:{sidebar:{showAllFiles:!F}}});e.ok||(console.warn(`[FileSidebar] toggle-show-all-files rejected:`,Nn(e.error)),X.error(`Could not update sidebar settings`,{description:Nn(e.error)}));return}case`expand-all-tree`:r?.expandAll();return;case`collapse-all-tree`:r?.collapseAll();return;case`delete`:case`toggle-sidebar`:case`toggle-source`:case`save-version`:case`version-history`:case`focus-search`:case`focus-command-palette`:return}})},he=[w,r,T,o,a,c,M,P,F,D,k],t[40]=a,t[41]=o,t[42]=k,t[43]=D,t[44]=c,t[45]=M,t[46]=F,t[47]=P,t[48]=r,t[49]=T,t[50]=me,t[51]=he):(me=t[50],he=t[51]),(0,Q.useEffect)(me,he);let ge=f&&`opacity-0`,_e;t[52]===ge?_e=t[53]:(_e=mi(`flex-row h-12 items-center py-0 px-3`,l?`justify-end`:`justify-between`,l&&`motion-safe:transition-opacity motion-safe:duration-100 motion-safe:ease-out`,ge,l&&`[-webkit-app-region:drag]`),t[52]=ge,t[53]=_e);let ve;t[54]===d?ve=t[55]:(ve=d&&!l?(0,Z.jsx)(`span`,{className:`shrink-0 font-mono text-sm uppercase tracking-wider text-sidebar-foreground/50`,children:`Files`}):null,t[54]=d,t[55]=ve);let ye;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(ye=mi(`flex items-center gap-1`,l&&`[&>*]:[-webkit-app-region:no-drag]`),t[56]=ye):ye=t[56];let be;t[57]!==b||t[58]!==y||t[59]!==x||t[60]!==r?(be=y?(0,Z.jsxs)(va,{children:[(0,Z.jsx)(ba,{asChild:!0,children:(0,Z.jsx)(jH,{icon:yc,label:`Tree View Options`})}),(0,Z.jsxs)(_a,{align:`end`,children:[b?null:(0,Z.jsxs)(ya,{onSelect:()=>r?.expandAll(),children:[(0,Z.jsx)(Qc,{"aria-hidden":`true`}),`Expand All`]}),x?null:(0,Z.jsxs)(ya,{onSelect:()=>r?.collapseAll(),children:[(0,Z.jsx)(cc,{"aria-hidden":`true`}),`Collapse All`]})]})]}):null,t[57]=b,t[58]=y,t[59]=x,t[60]=r,t[61]=be):be=t[61];let xe;t[62]!==c||t[63]!==r?(xe=(0,Z.jsx)(jH,{icon:Wc,label:`New File`,onClick:()=>r?.startCreating(`file`,c)}),t[62]=c,t[63]=r,t[64]=xe):xe=t[64];let Se;t[65]!==C||t[66]!==c||t[67]!==r?(Se=C?(0,Z.jsx)(jH,{icon:oc,label:`New from template`,onClick:()=>r?.startCreatingFromTemplate(c)}):null,t[65]=C,t[66]=c,t[67]=r,t[68]=Se):Se=t[68];let Ce;t[69]!==c||t[70]!==r?(Ce=(0,Z.jsx)(jH,{icon:uc,label:`New Folder`,onClick:()=>r?.startCreating(`folder`,c)}),t[69]=c,t[70]=r,t[71]=Ce):Ce=t[71];let we;t[72]!==be||t[73]!==xe||t[74]!==Se||t[75]!==Ce?(we=(0,Z.jsxs)(`div`,{className:ye,children:[be,xe,Se,Ce]}),t[72]=be,t[73]=xe,t[74]=Se,t[75]=Ce,t[76]=we):we=t[76];let Te;t[77]!==_e||t[78]!==ve||t[79]!==we?(Te=(0,Z.jsxs)(pD,{className:_e,children:[ve,we]}),t[77]=_e,t[78]=ve,t[79]=we,t[80]=Te):Te=t[80];let Ee=f&&`opacity-0`,De;t[81]===Ee?De=t[82]:(De=mi(`px-2 pb-2`,l&&`[-webkit-app-region:no-drag]`,l&&`motion-safe:transition-opacity motion-safe:duration-100 motion-safe:ease-out`,Ee),t[81]=Ee,t[82]=De);let Oe;t[83]===u?Oe=t[84]:(Oe=[u],t[83]=u,t[84]=Oe);let ke;t[85]===n?ke=t[86]:(ke=(0,Z.jsx)(yH,{onClick:n}),t[85]=n,t[86]=ke);let Ae;t[87]!==Oe||t[88]!==ke?(Ae=(0,Z.jsx)(O,{fallbackRender:NH,onError:vH,resetKeys:Oe,children:ke}),t[87]=Oe,t[88]=ke,t[89]=Ae):Ae=t[89];let je;t[90]!==De||t[91]!==Ae?(je=(0,Z.jsx)(`div`,{className:De,children:Ae}),t[90]=De,t[91]=Ae,t[92]=je):je=t[92];let Me;t[93]===Symbol.for(`react.memo_cache_sentinel`)?(Me=(0,Z.jsx)(hD,{children:(0,Z.jsx)(HV,{ref:i})}),t[93]=Me):Me=t[93];let Ne,Pe;t[94]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=(0,Z.jsxs)(mD,{className:`px-0`,children:[typeof window<`u`&&window.okDesktop?(0,Z.jsx)(gD,{children:(0,Z.jsx)(_D,{children:(0,Z.jsx)(_H,{bridge:window.okDesktop})})}):null,(0,Z.jsx)(SH,{})]}),Pe=(0,Z.jsx)(dD,{enableToggle:!1}),t[94]=Ne,t[95]=Pe):(Ne=t[94],Pe=t[95]);let Fe;t[96]!==Te||t[97]!==je?(Fe=(0,Z.jsx)(bO,{asChild:!0,children:(0,Z.jsxs)(`div`,{className:`contents`,onContextMenu:B,children:[Te,je,Me,Ne,Pe]})}),t[96]=Te,t[97]=je,t[98]=Fe):Fe=t[98];let Ie=!T,Le;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(Le=(0,Z.jsx)(Wc,{"aria-hidden":`true`}),t[99]=Le):Le=t[99];let Re;t[100]!==H||t[101]!==Ie?(Re=(0,Z.jsxs)(CO,{disabled:Ie,onSelect:H,"data-testid":`empty-space-menu-new-file`,children:[Le,`New File`]}),t[100]=H,t[101]=Ie,t[102]=Re):Re=t[102];let ze=!T||!C,Be;t[103]===Symbol.for(`react.memo_cache_sentinel`)?(Be=(0,Z.jsx)(oc,{"aria-hidden":`true`}),t[103]=Be):Be=t[103];let Ve;t[104]!==W||t[105]!==ze?(Ve=(0,Z.jsxs)(CO,{disabled:ze,onSelect:W,"data-testid":`empty-space-menu-new-from-template`,children:[Be,`New from template`]}),t[104]=W,t[105]=ze,t[106]=Ve):Ve=t[106];let He=!T,Ue;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,Z.jsx)(uc,{"aria-hidden":`true`}),t[107]=Ue):Ue=t[107];let We;t[108]!==K||t[109]!==He?(We=(0,Z.jsxs)(CO,{disabled:He,onSelect:K,"data-testid":`empty-space-menu-new-folder`,children:[Ue,`New Folder`]}),t[108]=K,t[109]=He,t[110]=We):We=t[110];let Ge;t[111]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=(0,Z.jsx)(DO,{}),t[111]=Ge):Ge=t[111];let Ke;t[112]!==ee||t[113]!==T?(Ke=w?(0,Z.jsxs)(CO,{disabled:!T,onSelect:ee,"data-testid":`empty-space-menu-reveal-in-finder`,"aria-label":T?`Reveal in Finder`:`Reveal in Finder, No workspace`,children:[(0,Z.jsx)(R,{"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:`Reveal in Finder`}),T?null:(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`No workspace`})]}):null,t[112]=ee,t[113]=T,t[114]=Ke):Ke=t[114];let qe;t[115]!==k||t[116]!==j||t[117]!==D?(qe=(0,Z.jsx)(hH,{input:j,installStates:D,dispatch:k,webFallbackVisible:!1}),t[115]=k,t[116]=j,t[117]=D,t[118]=qe):qe=t[118];let Je;t[119]!==ne||t[120]!==T?(Je=w?(0,Z.jsxs)(CO,{disabled:!T,onSelect:ne,"data-testid":`empty-space-menu-open-in-terminal`,"aria-label":T?`Open in Terminal`:`Open in Terminal, No workspace`,children:[(0,Z.jsx)(Yc,{"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:`Open in Terminal`}),T?null:(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`No workspace`})]}):null,t[119]=ne,t[120]=T,t[121]=Je):Je=t[121];let Ye=!T,Xe=T?`Copy full path`:`Copy full path, No workspace`,Ze,Qe;t[122]===Symbol.for(`react.memo_cache_sentinel`)?(Ze=(0,Z.jsx)(E,{"aria-hidden":`true`}),Qe=(0,Z.jsx)(`span`,{className:`flex-1`,children:`Copy full path`}),t[122]=Ze,t[123]=Qe):(Ze=t[122],Qe=t[123]);let $e;t[124]===T?$e=t[125]:($e=T?null:(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`No workspace`}),t[124]=T,t[125]=$e);let et;t[126]!==ie||t[127]!==Ye||t[128]!==Xe||t[129]!==$e?(et=(0,Z.jsxs)(CO,{disabled:Ye,onSelect:ie,"data-testid":`empty-space-menu-copy-full-path`,"aria-label":Xe,children:[Ze,Qe,$e]}),t[126]=ie,t[127]=Ye,t[128]=Xe,t[129]=$e,t[130]=et):et=t[130];let tt;t[131]===Symbol.for(`react.memo_cache_sentinel`)?(tt=(0,Z.jsx)(DO,{}),t[131]=tt):tt=t[131];let nt=M===null,rt;t[132]!==oe||t[133]!==P||t[134]!==nt?(rt=(0,Z.jsx)(EO,{checked:P,onCheckedChange:oe,disabled:nt,"data-testid":`empty-space-menu-show-hidden-files`,children:`Show Hidden Files`}),t[132]=oe,t[133]=P,t[134]=nt,t[135]=rt):rt=t[135];let it=M===null,at;t[136]!==ce||t[137]!==F||t[138]!==it?(at=(0,Z.jsx)(EO,{checked:F,onCheckedChange:ce,disabled:it,"data-testid":`empty-space-menu-show-all-files`,children:`Show all files`}),t[136]=ce,t[137]=F,t[138]=it,t[139]=at):at=t[139];let st;t[140]===z?st=t[141]:(st=z?(0,Z.jsx)(DO,{}):null,t[140]=z,t[141]=st);let ct;t[142]!==J||t[143]!==I?(ct=I?(0,Z.jsxs)(CO,{onSelect:J,"data-testid":`empty-space-menu-expand-all`,children:[(0,Z.jsx)(Qc,{"aria-hidden":`true`}),`Expand all`]}):null,t[142]=J,t[143]=I,t[144]=ct):ct=t[144];let lt;t[145]!==de||t[146]!==L?(lt=L?(0,Z.jsxs)(CO,{onSelect:de,"data-testid":`empty-space-menu-collapse-all`,children:[(0,Z.jsx)(cc,{"aria-hidden":`true`}),`Collapse all`]}):null,t[145]=de,t[146]=L,t[147]=lt):lt=t[147];let ut;t[148]!==Re||t[149]!==Ve||t[150]!==We||t[151]!==Ke||t[152]!==qe||t[153]!==Je||t[154]!==et||t[155]!==rt||t[156]!==at||t[157]!==st||t[158]!==ct||t[159]!==lt?(ut=(0,Z.jsxs)(SO,{children:[Re,Ve,We,Ge,Ke,qe,Je,et,tt,rt,at,st,ct,lt]}),t[148]=Re,t[149]=Ve,t[150]=We,t[151]=Ke,t[152]=qe,t[153]=Je,t[154]=et,t[155]=rt,t[156]=at,t[157]=st,t[158]=ct,t[159]=lt,t[160]=ut):ut=t[160];let dt;return t[161]!==Fe||t[162]!==ut?(dt=(0,Z.jsx)(lD,{variant:`inset`,children:(0,Z.jsxs)(yO,{children:[Fe,ut]})}),t[161]=Fe,t[162]=ut,t[163]=dt):dt=t[163],dt}function NH(){return null}function PH(e){console.warn(`[FileSidebar] clipboard write failed:`,e),X.error(`Could not copy relative path`)}function FH(e){console.warn(`[FileSidebar] clipboard write failed:`,e),X.error(`Could not copy full path`)}function IH(e){kH(e.target)&&(e.preventDefault(),e.stopPropagation())}function LH(){let e=(0,$.c)(17),t=ln(),{collabUrl:n,setSystemProvider:r,updateServerInstanceId:i,onBranchSwitched:a,observeBranch:o,observeDiskAck:s,refreshServerInfo:c}=ot(),l;e[0]!==o||e[1]!==s||e[2]!==a||e[3]!==c||e[4]!==i?(l={updateServerInstanceId:i,onBranchSwitched:a,observeBranch:o,observeDiskAck:s,refreshServerInfo:c},e[0]=o,e[1]=s,e[2]=a,e[3]=c,e[4]=i,e[5]=l):l=e[5];let u=(0,Q.useRef)(l),d;e[6]!==o||e[7]!==s||e[8]!==a||e[9]!==c||e[10]!==i?(d=()=>{u.current={updateServerInstanceId:i,onBranchSwitched:a,observeBranch:o,observeDiskAck:s,refreshServerInfo:c}},e[6]=o,e[7]=s,e[8]=a,e[9]=c,e[10]=i,e[11]=d):d=e[11],(0,Q.useEffect)(d);let f,p;return e[12]!==n||e[13]!==t||e[14]!==r?(f=()=>{if(n===null)return;let e=new Se,i=new _t({url:n,name:$n,document:e,onStateless:e=>{let{payload:t}=e;_(t,{onServerInfo:e=>{u.current.updateServerInstanceId(e.serverInstanceId),e.currentBranch!==void 0&&u.current.observeBranch(e.currentBranch)},onBranchSwitched:e=>{u.current.onBranchSwitched(e.branch)},onDiskAck:e=>{u.current.observeDiskAck(e.docName,e.sv)},onDerivedView:UH,onConfigValidationRejected:HH,onConfigIgnoreNestedError:VH,onUnknown:BH})},onClose:zH,onDisconnect:RH}),a=br(e=>{(e.includes(`files`)||e.includes(`backlinks`))&&(t.invalidateQueries({queryKey:[`backlinks`]}),t.invalidateQueries({queryKey:[`forward-links`]})),(e.includes(`files`)||e.includes(`graph`))&&(t.invalidateQueries({queryKey:[`orphans`]}),t.invalidateQueries({queryKey:[`hubs`]}))}),o=q(()=>{u.current.refreshServerInfo()});i.on(`synced`,()=>{Fr([`files`,`backlinks`,`graph`]),o()});let s=new Set,c=()=>{if(i.awareness)for(let[e,t]of i.awareness.getStates().entries())s.has(e)||t.user?.type===`agent`&&(s.add(e),console.warn(`[agent-presence] observed stale AwarenessUser.type === 'agent' from clientID ${e} — probably a stale bundled client`))};return i.awareness?.on(`change`,c),r(i),()=>{a(),i.awareness?.off(`change`,c),r(null),i.destroy(),e.destroy()}},p=[t,n,r],e[12]=n,e[13]=t,e[14]=r,e[15]=f,e[16]=p):(f=e[15],p=e[16]),(0,Q.useEffect)(f,p),null}function RH(){console.warn(`[CC1] __system__ disconnected - derived views may be stale`)}function zH(e){let{event:t}=e;console.warn(`[CC1] __system__ connection closed:`,t.code,t.reason)}function BH(e){console.warn(`[CC1] Unparseable stateless payload, skipping:`,e.slice(0,100))}function VH(e){Za(e)}function HH(e){eo(e)}function UH(e){Fr([e.ch])}var WH=`#install-claude-desktop`;function GH(e){return e===`#settings`||e===WH}function KH(e,t,n){return[e,t,n].map(e=>[...e].sort().join(`\0`)).join(``)}function qH(){let e=(0,$.c)(20),{clearTarget:t,syncOpenTabsWithKnownTargets:n,tabSessionLoaded:r}=ot(),{openTargetTransition:i}=gt(),{assetPaths:a,folderPaths:o,loading:s,pages:c}=qr(),l=(0,Q.useRef)(null),u;e[0]!==a||e[1]!==o||e[2]!==c?(u=KH(c,o,a),e[0]=a,e[1]=o,e[2]=c,e[3]=u):u=e[3];let d=u,f,p;e[4]!==a||e[5]!==o||e[6]!==s||e[7]!==c||e[8]!==n||e[9]!==r||e[10]!==d?(f=()=>{s||!r||l.current===d||(l.current=d,n({pages:c,folderPaths:o,assetPaths:a}))},p=[a,o,s,c,n,r,d],e[4]=a,e[5]=o,e[6]=s,e[7]=c,e[8]=n,e[9]=r,e[10]=d,e[11]=f,e[12]=p):(f=e[11],p=e[12]),(0,Q.useEffect)(f,p);let m,h;return e[13]!==t||e[14]!==o||e[15]!==s||e[16]!==i||e[17]!==c?(m=()=>{e();function e(){if(GH(window.location.hash))return;let e=Jr(window.location.hash);if(e){let t=Er(e.split(`.`).pop()??``);dt(`ok/nav/hash-change`,{docName:null,kind:`asset`}),i({kind:`asset`,target:e,assetPath:e,mediaKind:t});return}let n=Rr(window.location.hash);if(!n){dt(`ok/nav/hash-change`,{docName:null,kind:`clear`}),t();return}if(s){dt(`ok/nav/hash-change`,{docName:n,kind:`deferred-loading`});return}let r=Yr(n,{pages:c,folderPaths:o});if(r.kind===`missing`&&/\/+$/.test(n.trim())){dt(`ok/nav/hash-change`,{docName:n,kind:`deferred-missing-folder`});return}let a=jr(r);dt(`ok/nav/hash-change`,{docName:n,kind:a.kind}),i(a)}return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},h=[t,o,s,i,c],e[13]=t,e[14]=o,e[15]=s,e[16]=i,e[17]=c,e[18]=m,e[19]=h):(m=e[18],h=e[19]),(0,Q.useEffect)(m,h),null}function JH(){let e=(0,$.c)(5),[t,n]=(0,Q.useState)(typeof window<`u`&&window.location.hash===WH),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=function(){window.location.hash===WH&&n(!0)};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Q.useEffect)(r,i);let a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=function(e){if(n(e),!e&&window.location.hash===WH){let{pathname:e,search:t}=window.location;window.history.replaceState(null,``,`${e}${t}`)}},e[2]=a):a=e[2];let o=a,s;return e[3]===t?s=e[4]:(s=(0,Z.jsx)(Ta,{open:t,onOpenChange:o}),e[3]=t,e[4]=s),s}function YH(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,Q.useEffect)(XH,t),null}function XH(){let e=function(e){let t=e.target;Cm({target:t,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,key:e.key})&&(e.preventDefault(),window.location.hash!==`#settings`&&(window.location.hash=Sm))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}function ZH(){let e=(0,$.c)(4),{activeTarget:t}=ot(),n=typeof window<`u`?window.okDesktop??null:null,r=t?.kind===`doc`||t?.kind===`folder`?t.kind:null,i=t?.kind===`doc`?t.docName:t?.kind===`folder`?t.folderPath:null,a,o;return e[0]!==i||e[1]!==r?(a=()=>{if(n){if(r===null){n.editor.notifyActiveTargetChanged({kind:null});return}i!==null&&n.editor.notifyActiveTargetChanged({kind:r,identifier:i})}},o=[n,r,i],e[0]=i,e[1]=r,e[2]=a,e[3]=o):(a=e[2],o=e[3]),(0,Q.useEffect)(a,o),null}function QH(){let e=(0,$.c)(8),{activeDocName:t,activeTarget:n}=ot(),[r,i]=(0,Q.useState)(!1),a;e[0]!==t||e[1]!==n?(a=n?.kind===`folder`?n.folderPath:sr(t),e[0]=t,e[1]=n,e[2]=a):a=e[2];let o=a,s,c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=function(e){let t=e.target;Bp({target:t,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,key:e.key})&&(e.preventDefault(),i(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},c=[],e[3]=s,e[4]=c):(s=e[3],c=e[4]),(0,Q.useEffect)(s,c);let l;return e[5]!==r||e[6]!==o?(l=(0,Z.jsx)(Hp,{open:r,onOpenChange:i,kind:`file`,initialDir:o}),e[5]=r,e[6]=o,e[7]=l):l=e[7],l}function $H(){let e=(0,$.c)(21),t=typeof window<`u`?window.okDesktop??null:null,n=typeof window<`u`&&window.okDesktop!=null,[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),l;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=t?ol({bridge:t,authQueryTransport:ul(),cloneTransport:gl(),openSignIn:()=>new Promise(e=>{c(()=>e),o(!0)})}):null,e[0]=l):l=e[0];let u=l,d;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(Gh,{}),e[1]=d):d=e[1];let f,p,m,h,g,_,v,y;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(LH,{}),p=(0,Z.jsx)(qH,{}),m=(0,Z.jsx)(ZH,{}),h=(0,Z.jsx)(QH,{}),g=(0,Z.jsx)(YH,{}),_=(0,Z.jsx)(JH,{}),v=(0,Z.jsx)(Td,{}),y=t&&u?(0,Z.jsx)(zd,{bridge:t,cloneController:u}):null,e[2]=f,e[3]=p,e[4]=m,e[5]=h,e[6]=g,e[7]=_,e[8]=v,e[9]=y):(f=e[2],p=e[3],m=e[4],h=e[5],g=e[6],_=e[7],v=e[8],y=e[9]);let b;e[10]!==a||e[11]!==s?(b=t?(0,Z.jsx)(qu,{open:a,onOpenChange:e=>{e||(o(!1),s?.(null),c(null))},onSuccess:e=>{s?.({authenticated:!0,host:`github.com`,login:e.login}),c(null)}}):null,e[10]=a,e[11]=s,e[12]=b):b=e[12];let x;e[13]===r?x=e[14]:(x=(0,Z.jsx)(Rh,{bridge:t,open:r,onOpenChange:i}),e[13]=r,e[14]=x);let S;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(S=n&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`editor-window-chrome-drag-strip`,className:`pointer-events-none fixed inset-x-0 top-0 z-50 h-2 [-webkit-app-region:drag]`}),e[15]=S):S=e[15];let C;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(AH,{onOpenSearch:()=>i(!0)}),e[16]=C):C=e[16];let w;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsxs)(oD,{className:`h-screen overflow-hidden`,children:[C,(0,Z.jsx)(fD,{className:`overflow-hidden h-[calc(100vh-var(--layout-inset-offset))]`,children:(0,Z.jsx)(Uk,{})})]}),e[17]=w):w=e[17];let T;return e[18]!==b||e[19]!==x?(T=(0,Z.jsx)(Ve,{name:`app`,children:(0,Z.jsx)(bt,{children:(0,Z.jsxs)(to,{children:[d,(0,Z.jsxs)(zr,{children:[f,p,m,h,g,_,v,y,b,x,S,w]})]})})}),e[18]=b,e[19]=x,e[20]=T):T=e[20],T}ws(),typeof window<`u`&&window.okDesktop?.config.apiOrigin&&Yd({apiOrigin:window.okDesktop.config.apiOrigin}),hf()&&xf(),Jf(),typeof window<`u`&&Qd({bridge:window.okDesktop}),typeof window<`u`&&Xo({bridge:window.okDesktop}),typeof window<`u`&&Ko({bridge:window.okDesktop}),typeof window<`u`&&tf({bridge:window.okDesktop}),typeof window<`u`&&Rd({bridge:window.okDesktop});var eU=new Ns({defaultOptions:{queries:{retry:1,staleTime:1e4}}}),tU=document.getElementById(`root`);if(!tU)throw Error(`Root element not found`);var nU=typeof window<`u`&&window.okDesktop?.config.mode===`navigator`;(0,Us.createRoot)(tU).render((0,Z.jsx)(Q.StrictMode,{children:(0,Z.jsx)(tn,{client:eU,children:(0,Z.jsxs)(pr,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,disableTransitionOnChange:!0,storageKey:`ok-theme-v1`,children:[(0,Z.jsx)(zn,{children:nU&&window.okDesktop?(0,Z.jsx)(Wd,{bridge:window.okDesktop}):(0,Z.jsx)($H,{})}),(0,Z.jsx)(Jd,{richColors:!0,closeButton:!0})]})})}));
|
|
1918
|
+
</svg>`,OV=`${uB}\n${CB}`;function kV(e){return{...Sj({type:e===`dark`?`dark`:`light`,colors:{"sideBar.background":`var(--sidebar)`,"sideBar.foreground":`var(--sidebar-foreground)`,"sideBar.border":`var(--sidebar-border)`,"list.activeSelectionBackground":`var(--sidebar-accent)`,"list.activeSelectionForeground":`var(--sidebar-accent-foreground)`,"list.hoverBackground":`var(--sidebar-hover)`,focusBorder:`var(--color-primary)`,"input.background":`var(--input)`,"input.border":`var(--border)`}}),"--trees-font-family-override":`var(--font-sans)`,"--trees-font-size-override":`0.875rem`,"--trees-item-padding-x-override":`0.5rem`,"--trees-padding-inline-override":`0.5rem`,"--trees-border-radius-override":`0.375rem`,"--trees-selected-fg":`var(--color-primary)`,"--truncate-marker-fade-in-duration":`0s`,"--trees-file-icon-color-markdown":`light-dark(var(--color-gray-400), var(--color-gray-500))`,"--trees-file-icon-color-image":`light-dark(var(--color-gray-400), var(--color-gray-500))`,"--trees-fg-muted":`light-dark(var(--color-gray-400), var(--color-gray-500))`}}function AV(e){let t=e.split(`/`).pop()?.replace(/\.md$/i,``).toLowerCase();return!!t&&SV.has(t)}function jV(e){return e===`darwin`?`Reveal in Finder`:e===`win32`?`Reveal in File Explorer`:`Open Containing Folder`}function MV(e){let t=(0,$.c)(14),{item:n,workspace:r,onClose:i}=e,a=typeof window<`u`?window.okDesktop:void 0;if(!a)return null;let o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=jV(a.platform),t[0]=o):o=t[0];let s=o,c=r?null:`No workspace`,l=!r,u;t[1]!==n||t[2]!==i||t[3]!==r?(u=()=>{if(!r)return;i();let e=nh(r.contentDir,nO(n),r.pathSeparator);a.shell.showItemInFolder(e)},t[1]=n,t[2]=i,t[3]=r,t[4]=u):u=t[4];let d=c?`${s}, ${c}`:s,f,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(R,{"aria-hidden":`true`}),p=(0,Z.jsx)(`span`,{className:`flex-1`,children:s}),t[5]=f,t[6]=p):(f=t[5],p=t[6]);let m;t[7]===c?m=t[8]:(m=c?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:c}):null,t[7]=c,t[8]=m);let h;return t[9]!==l||t[10]!==u||t[11]!==d||t[12]!==m?(h=(0,Z.jsxs)(ya,{disabled:l,onSelect:u,"aria-label":d,children:[f,p,m]}),t[9]=l,t[10]=u,t[11]=d,t[12]=m,t[13]=h):h=t[13],h}function NV(e){let t=(0,$.c)(12),{dirAbsPath:n,onClose:r}=e,i=typeof window<`u`?window.okDesktop:void 0;if(!i)return null;let a=n===null?`No workspace`:null,o=n===null,s;t[0]!==n||t[1]!==r?(s=()=>{n!==null&&(r(),JB(i,n))},t[0]=n,t[1]=r,t[2]=s):s=t[2];let c=a?`Open in Terminal, ${a}`:`Open in Terminal`,l,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(Yc,{"aria-hidden":`true`}),u=(0,Z.jsx)(`span`,{className:`flex-1`,children:`Open in Terminal`}),t[3]=l,t[4]=u):(l=t[3],u=t[4]);let d;t[5]===a?d=t[6]:(d=a?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:a}):null,t[5]=a,t[6]=d);let f;return t[7]!==o||t[8]!==s||t[9]!==c||t[10]!==d?(f=(0,Z.jsxs)(ya,{disabled:o,onSelect:s,"aria-label":c,children:[l,u,d]}),t[7]=o,t[8]=s,t[9]=c,t[10]=d,t[11]=f):f=t[11],f}function PV(e){return tO({kind:e.endsWith(`/`)?`directory`:`file`,name:e,path:e})}function FV(e,t){return e!==t&&e.startsWith(t)}function IV(e,t){let n=[...new Set(e)].filter(e=>!t(e)),r=n.filter(e=>e.endsWith(`/`));return n.filter(e=>!r.some(t=>FV(e,t))).map(PV)}function LV(e,t){return e===t||e.startsWith(`${t}/`)}function RV(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable||e.closest(`[contenteditable="true"]`)!==null}function zV(e,t,n){let r=new Set,i=new Set;for(let a of e){if(a.kind===`file`){r.add(a.path);continue}i.add(a.path);for(let e of t)hn(e)&&e.docName.startsWith(`${a.path}/`)&&r.add(e.docName);for(let e of n){let t=qD(e);LV(t,a.path)&&i.add(t)}}return{docNames:r,folderPaths:i}}function BV(e,t){return e.kind===`file`?t.kind===`file`&&e.path===t.createdPath:LV(t.createdPath,e.path)}function VV(e){let t=(0,$.c)(75),{item:n,context:r,anyActionBusy:i,workspace:a,handoff:o,model:s,okignoreBinding:c,projectLocalBinding:l,mergedConfig:u,onStartCreating:f,onStartCreatingFromTemplate:p,onDelete:h,onExpandSubtree:g,onCollapseSubtree:_,folderTreePaths:v,isAsset:y,isAssetTreePath:b}=e,x,S,C,w,T,D,O,k;if(t[0]!==y||t[1]!==b||t[2]!==n||t[3]!==u?.appearance?.sidebar?.showAllFiles||t[4]!==u?.appearance?.sidebar?.showHiddenFiles||t[5]!==s||t[6]!==c||t[7]!==l){k=tO(n),w=n.kind===`directory`,x=!y&&c!==null,C=w?`Hide folder`:`Hide this file`,D=u?.appearance?.sidebar?.showHiddenFiles??!1,T=u?.appearance?.sidebar?.showAllFiles??!1,S=l!==null;let e=s.getSelectedPaths();O=e.includes(k.treePath)?IV(e,b):[],t[0]=y,t[1]=b,t[2]=n,t[3]=u?.appearance?.sidebar?.showAllFiles,t[4]=u?.appearance?.sidebar?.showHiddenFiles,t[5]=s,t[6]=c,t[7]=l,t[8]=x,t[9]=S,t[10]=C,t[11]=w,t[12]=T,t[13]=D,t[14]=O,t[15]=k}else x=t[8],S=t[9],C=t[10],w=t[11],T=t[12],D=t[13],O=t[14],k=t[15];let A=O,j;t[16]!==A||t[17]!==k?(j=A.length>1?A:[k],t[16]=A,t[17]=k,t[18]=j):j=t[18];let M=j,N=M.length>1?`Delete ${M.length} Items`:`Delete`,P,F,I;if(t[19]!==y||t[20]!==w||t[21]!==n||t[22]!==a){P=w&&a?nh(a.contentDir,nO(n),a.pathSeparator):null;let e;if(t[26]!==w||t[27]!==n||t[28]!==a){bb0:{if(!a||w){e=null;break bb0}let t=nO(n),r=t.lastIndexOf(`/`);if(r===-1){e=a.contentDir;break bb0}e=nh(a.contentDir,t.slice(0,r),a.pathSeparator)}t[26]=w,t[27]=n,t[28]=a,t[29]=e}else e=t[29];F=e,I=y?null:w?oh({folderAbsPath:P??``,folderRelativePath:nO(n),workspace:a}):ih({docName:WD(n.path),workspace:a}),t[19]=y,t[20]=w,t[21]=n,t[22]=a,t[23]=P,t[24]=F,t[25]=I}else P=t[23],F=t[24],I=t[25];let L=I,R;t[30]===r?R=t[31]:(R=()=>r.close({restoreFocus:!1}),t[30]=r,t[31]=R);let z=R,B;t[32]===r?B=t[33]:(B=()=>r.close(),t[32]=r,t[33]=B);let V=B,H;t[34]===l?H=t[35]:(H=e=>{if(l===null)return;let t=l.patch({appearance:{sidebar:{showHiddenFiles:e}}});t.ok||(console.warn(`[FileTree] showHiddenFiles toggle rejected:`,Nn(t.error)),X.error(`Could not update sidebar settings`,{description:Nn(t.error)}))},t[34]=l,t[35]=H);let U=H,W;t[36]===l?W=t[37]:(W=e=>{if(l===null)return;let t=l.patch({appearance:{sidebar:{showAllFiles:e}}});t.ok||(console.warn(`[FileTree] showAllFiles toggle rejected:`,Nn(t.error)),X.error(`Could not update sidebar settings`,{description:Nn(t.error)}))},t[36]=l,t[37]=W);let G=W,K=0,q=0;if(w){let e=JD(n.path);for(let t of v)(t===e||t.startsWith(e))&&(K++,WB(s.getItem(t))?.isExpanded()&&q++)}let ee=w&&q<K,te=w&&q>0,ne;t[38]===V?ne=t[39]:(ne=e=>{e||V()},t[38]=V,t[39]=ne);let re;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Z.jsx)(ba,{asChild:!0,children:(0,Z.jsx)(`span`,{"aria-hidden":`true`,"data-file-tree-context-menu-root":`true`,className:`block size-px`})}),t[40]=re):re=t[40];let ie;t[41]!==i||t[42]!==x||t[43]!==S||t[44]!==V||t[45]!==z||t[46]!==N||t[47]!==M||t[48]!==P||t[49]!==G||t[50]!==U||t[51]!==o||t[52]!==L||t[53]!==C||t[54]!==y||t[55]!==w||t[56]!==n||t[57]!==s||t[58]!==c||t[59]!==_||t[60]!==h||t[61]!==g||t[62]!==f||t[63]!==p||t[64]!==F||t[65]!==T||t[66]!==D||t[67]!==te||t[68]!==ee||t[69]!==k||t[70]!==a?(ie=(0,Z.jsx)(_a,{sideOffset:0,align:`start`,"data-file-tree-context-menu-root":`true`,className:`min-w-52`,children:w?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(ya,{disabled:i,onSelect:()=>{z(),f(`file`,qD(n.path))},children:[(0,Z.jsx)(Wc,{"aria-hidden":`true`}),`New File`]}),(0,Z.jsxs)(ya,{disabled:i,onSelect:()=>{z(),p(qD(n.path))},children:[(0,Z.jsx)(oc,{"aria-hidden":`true`}),`New from template`]}),(0,Z.jsxs)(ya,{disabled:i,onSelect:()=>{z(),f(`folder`,qD(n.path))},children:[(0,Z.jsx)(uc,{"aria-hidden":`true`}),`New Folder`]}),(0,Z.jsx)(na,{}),(0,Z.jsx)(MV,{item:n,workspace:a,onClose:V}),(0,Z.jsx)(rV,{input:L,installStates:o.installStates,isElectronHost:o.isElectronHost,dispatch:o.dispatch,webFallbackVisible:!1}),(0,Z.jsx)(NV,{dirAbsPath:P,onClose:V}),(0,Z.jsxs)(Xa,{children:[(0,Z.jsxs)(xa,{children:[(0,Z.jsx)(E,{"aria-hidden":`true`}),`Copy Path`]}),(0,Z.jsxs)(ta,{children:[(0,Z.jsx)(ya,{disabled:!a,onSelect:()=>{a&&(V(),xV(nh(a.contentDir,nO(n),a.pathSeparator),`full path`))},children:`Full Path`}),(0,Z.jsx)(ya,{onSelect:()=>{V(),xV(nO(n),`relative path`)},children:`Relative Path`})]})]}),(0,Z.jsx)(na,{}),(0,Z.jsx)($i,{checked:D,onCheckedChange:U,disabled:!S,"data-testid":`file-tree-menu-show-hidden-files`,children:`Show Hidden Files`}),(0,Z.jsx)($i,{checked:T,onCheckedChange:G,disabled:!S,"data-testid":`file-tree-menu-show-all-files`,children:`Show all files`}),ee||te?(0,Z.jsx)(na,{}):null,ee?(0,Z.jsxs)(ya,{onSelect:()=>{V(),g(n.path)},children:[(0,Z.jsx)(Qc,{"aria-hidden":`true`}),`Expand All`]}):null,te?(0,Z.jsxs)(ya,{onSelect:()=>{V(),_(n.path)},children:[(0,Z.jsx)(cc,{"aria-hidden":`true`}),`Collapse All`]}):null,(0,Z.jsx)(na,{}),(0,Z.jsxs)(ya,{disabled:i,onSelect:()=>{z(),s.startRenaming(n.path)},children:[(0,Z.jsx)(m,{"aria-hidden":`true`}),`Rename`]}),(0,Z.jsxs)(ya,{"data-testid":`file-tree-menu-hide`,disabled:!x,onSelect:()=>{if(!c)return;V();let e=gB(k),t=no(c.current()),n=Ka(t,e);if(n===t)return;c.patch(Ja(n));let r=k.path.split(`/`).pop()||k.path;X.success(`Hidden folder “${r}”`,{description:`Manage hidden files in Settings → Ignore patterns.`,duration:5e3})},children:[(0,Z.jsx)(d,{"aria-hidden":`true`}),C]}),(0,Z.jsxs)(ya,{variant:`destructive`,disabled:i,onSelect:()=>{V(),h(M)},children:[(0,Z.jsx)(Ue,{"aria-hidden":`true`}),N]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(MV,{item:n,workspace:a,onClose:V}),!y&&(0,Z.jsx)(rV,{input:L,installStates:o.installStates,isElectronHost:o.isElectronHost,dispatch:o.dispatch,webFallbackVisible:!0}),(0,Z.jsx)(NV,{dirAbsPath:F,onClose:V}),(0,Z.jsxs)(Xa,{children:[(0,Z.jsxs)(xa,{children:[(0,Z.jsx)(E,{"aria-hidden":`true`}),`Copy Path`]}),(0,Z.jsxs)(ta,{children:[(0,Z.jsx)(ya,{disabled:!a,onSelect:()=>{a&&(V(),xV(nh(a.contentDir,nO(n),a.pathSeparator),`full path`))},children:`Full Path`}),(0,Z.jsx)(ya,{onSelect:()=>{V(),xV(nO(n),`relative path`)},children:`Relative Path`})]})]}),y?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(na,{}),(0,Z.jsxs)(ya,{disabled:i,onSelect:()=>{z(),s.startRenaming(n.path)},children:[(0,Z.jsx)(m,{"aria-hidden":`true`}),`Rename`]}),(0,Z.jsxs)(ya,{"data-testid":`file-tree-menu-hide`,disabled:!x,onSelect:()=>{if(!c)return;V();let e=gB(k),t=no(c.current()),n=Ka(t,e);if(n===t)return;c.patch(Ja(n));let r=k.path.split(`/`).pop()||k.path;X.success(`Hidden “${r}”`,{description:`Manage hidden files in Settings → Ignore patterns.`,duration:5e3})},children:[(0,Z.jsx)(d,{"aria-hidden":`true`}),C]}),(0,Z.jsxs)(ya,{variant:`destructive`,disabled:i,onSelect:()=>{V(),h(M)},children:[(0,Z.jsx)(Ue,{"aria-hidden":`true`}),N]})]})]})}),t[41]=i,t[42]=x,t[43]=S,t[44]=V,t[45]=z,t[46]=N,t[47]=M,t[48]=P,t[49]=G,t[50]=U,t[51]=o,t[52]=L,t[53]=C,t[54]=y,t[55]=w,t[56]=n,t[57]=s,t[58]=c,t[59]=_,t[60]=h,t[61]=g,t[62]=f,t[63]=p,t[64]=F,t[65]=T,t[66]=D,t[67]=te,t[68]=ee,t[69]=k,t[70]=a,t[71]=ie):ie=t[71];let ae;return t[72]!==ie||t[73]!==ne?(ae=(0,Z.jsxs)(va,{open:!0,modal:!1,onOpenChange:ne,children:[re,ie]}),t[72]=ie,t[73]=ne,t[74]=ae):ae=t[74],ae}function HV(e){let t=(0,$.c)(226),{ref:n}=e,{activeDocName:r,activeTarget:i,closeTabs:a,closeDocument:o,closeAndClearForRename:s,getPoolActiveDocName:c,isNewTabActive:u,openTarget:d,prewarm:f,remapTabsForRename:p}=ot(),{notifySidebarFileSelected:m}=aD(),{resolvedTheme:h}=vr(),{addPage:g}=qr(),_;t[0]!==m||t[1]!==d?(_=function(e){d({kind:`doc`,target:e,docName:e},{tabBehavior:`replace-active`}),vV(Tr(e)),m()},t[0]=m,t[1]=d,t[2]=_):_=t[2];let v=_,y;t[3]!==m||t[4]!==d?(y=function(e){let t=or(e);d({kind:`folder`,target:e,folderPath:e},{tabBehavior:`replace-active`}),vV(t),m()},t[3]=m,t[4]=d,t[5]=y):y=t[5];let b=y,x;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(x=[],t[6]=x):x=t[6];let[S,C]=(0,Q.useState)(x),[w,T]=(0,Q.useState)(!0),[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(null),[M,N]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(null),[I,L]=(0,Q.useState)(null),R=(0,Q.useRef)(S),z;t[7]!==S||t[8]!==b||t[9]!==v||t[10]!==m||t[11]!==d?(z=function(e,t){let n=MB(e,t===void 0?S:t);if(n.kind===`none`){console.debug(`[FileTree] Dropped selection for unknown docName:`,YD(e));return}if(n.kind===`asset`){d({kind:`asset`,target:n.path,assetPath:n.path,mediaKind:n.mediaKind},{tabBehavior:`replace-active`}),vV(n.hash),m();return}if(n.kind===`folder`){b(n.path);return}v(n.path)},t[7]=S,t[8]=b,t[9]=v,t[10]=m,t[11]=d,t[12]=z):z=t[12];let B=z,V=(0,Q.useRef)(r),H;t[13]===S?H=t[14]:(H=new Set(S.filter(Hn).map(cH)),t[13]=S,t[14]=H);let U=H,W=(0,Q.useRef)(U),G;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(G=[],t[15]=G):G=t[15];let K=(0,Q.useRef)(G),q=(0,Q.useRef)(null),ee=(0,Q.useRef)(sH),te=(0,Q.useRef)(null),ne=(0,Q.useRef)(null),re=(0,Q.useRef)(!1),ie=(0,Q.useRef)(null),ae=(0,Q.useRef)(!1),oe=(0,Q.useRef)(!1),se=(0,Q.useRef)(null),ce=(0,Q.useRef)(null),le=(0,Q.useRef)(oH),J=(0,Q.useRef)(aH),ue=(0,Q.useRef)(iH),de=(0,Q.useRef)(rH),fe=(0,Q.useRef)(i),{selectedFilePath:pe,selectedFolderPath:me,navigationPath:he}=jB(i,u?null:r),ge=pe?UD(pe,S.find(e=>hn(e)&&e.docName===pe)?.docExt):me?JD(me):i?.kind===`asset`?i.assetPath:null,_e=Oh().states,{dispatch:ve}=_h(),ye;t[16]!==ve||t[17]!==_e?(ye={installStates:_e,isElectronHost:typeof window<`u`&&window.okDesktop!=null,dispatch:ve},t[16]=ve,t[17]=_e,t[18]=ye):ye=t[18];let be=ye,{okignoreBinding:xe,projectLocalBinding:Se,merged:Ce}=Ga(),we=Ce?.appearance?.sidebar?.showHiddenFiles??!1,Te=Ce?.appearance?.sidebar?.showAllFiles??!1,Ee;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=()=>ie.current===null,t[19]=Ee):Ee=t[19];let De=Ee,Oe;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=[],t[20]=Oe):Oe=t[20];let ke;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(ke={set:`complete`,spriteSheet:DV},t[21]=ke):ke=t[21];let Ae;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(Ae={contextMenu:{enabled:!0,triggerMode:`both`,buttonVisibility:`when-needed`}},t[22]=Ae):Ae=t[22];let je;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(je={canDrag:De,canDrop:De,onDropComplete:e=>de.current(e),onDropError:nH},t[23]=je):je=t[23];let Me;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(Me={paths:Oe,flattenEmptyDirectories:!1,initialExpansion:`closed`,fileTreeSearchMode:`hide-non-matches`,initialVisibleRowCount:18,stickyFolders:!0,icons:ke,unsafeCSS:OV,composition:Ae,dragAndDrop:je,renaming:{canRename:De,onRename:e=>J.current(e),onError:e=>ue.current(e)},onSelectionChange:e=>le.current(e),renderRowDecoration:e=>{let{item:t}=e;if(t.kind!==`file`)return null;let n=R.current.find(e=>hn(e)&&UD(e.docName,e.docExt)===t.path);return n?.isSymlink?{icon:CV,title:n.targetPath?`Symlink to ${n.targetPath}`:`Symlink`}:AV(t.path)?{icon:wV,title:`Agent configuration file`}:null}},t[24]=Me):Me=t[24];let{model:Ne}=aB(Me),Pe;t[25]===Ne?Pe=t[26]:(Pe=function(e){let t=Ne.getItem(e)??Ne.getItem(JD(e));return t?.isDirectory()?JD(qD(t.getPath())):e},t[25]=Ne,t[26]=Pe);let Fe=Pe,Le,Re;t[27]===S?(Le=t[28],Re=t[29]):(Re=XD(S),Le=ZD(Re),t[27]=S,t[28]=Le,t[29]=Re);let ze=Le,Be=(0,Q.useRef)(Re),Ve;t[30]===S?Ve=t[31]:(Ve=$D(S),t[30]=S,t[31]=Ve);let He=Ve,Ue=(0,Q.useRef)(He),We=me?eO(JD(me)).slice(0,-1):eO(ge??he),Ge=We.join(`\0`),Ke;if(t[32]!==Ne){let e=()=>{let e=new Set;for(let t of Ue.current)WB(Ne.getItem(t))?.isExpanded()&&e.add(t);return e};Ke=t=>{let n=new Set($D(t??R.current)),r=e();for(let e of K.current)r.add(e);return[...r].filter(e=>n.has(e))},t[32]=Ne,t[33]=Ke}else Ke=t[33];let qe=Ke,Je;t[34]!==qe||t[35]!==Ne?(Je=e=>{let t=XD(e??R.current);Ne.resetPaths(t,{initialExpandedPaths:qe(e)})},t[34]=qe,t[35]=Ne,t[36]=Je):Je=t[36];let Ye=Je,Xe;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=e=>{te.current=QD(e)},t[37]=Xe):Xe=t[37];let Qe=Xe,$e;t[38]===Symbol.for(`react.memo_cache_sentinel`)?($e=e=>W.current.has(e),t[38]=$e):$e=t[38];let et=$e,tt=function(e){let t=yV(e);if(!t||bV(t))return!1;let n=Ne.getFocusedPath()??Ne.getSelectedPaths()[0]??null;if(!n||n.endsWith(`/`)||et(n))return!1;let r=bV(n);if(!r)return!1;let i=JD(t);if(!Ue.current.includes(i))return!1;let a=`${t}${r}`;return Be.current.includes(a)?!1:(Ot({sourcePath:n,destinationPath:a,isFolder:!1}),Ne.move(n,a),!0)},nt;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(nt=e=>{let t=e??q.current;!t||q.current!==t||(t.disposeCommitListener(),q.current=null)},t[39]=nt):nt=t[39];let rt=nt,it;t[40]!==rt||t[41]!==o||t[42]!==a||t[43]!==Ye?(it=async function(e,t){let n=t===void 0?{}:t,r=n.updateUi??!0,i=n.restoreLocation??r;rt(e),r&&k(e.renamePath);try{let t=await fetch(`/api/delete-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:e.kind,path:e.createdPath})});if(!t.ok&&t.status!==404){let n=await l(t,`Failed to clean up pending ${e.kind}`);if(n.ok)return;let i=`${n.title} - ${e.kind} "${e.createdPath}" still exists on disk`;r?X.error(i):console.warn(`[FileTree] cleanup pending create failed: ${i}`),r&&(k(null),Ye());return}}catch(t){console.warn(`[FileTree] cleanup pending create failed:`,t),r&&X.error(`Network error - ${e.kind} "${e.createdPath}" still exists on disk`),r&&(k(null),Ye());return}r&&(e.kind===`file`?o(e.createdPath):a([lt(e.createdPath)],{force:!0})),r&&C(t=>{let n=pO(t,e.kind===`file`?[e.createdPath]:[],e.kind===`folder`?e.createdPath:void 0);return Qe(n),n}),Fr([`files`,`backlinks`,`graph`]),i&&(window.location.hash=e.previousHash),r&&k(null)},t[40]=rt,t[41]=o,t[42]=a,t[43]=Ye,t[44]=it):it=t[44];let at=it,st,ct;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(st=()=>()=>{let e=q.current;e&&ee.current(e,{restoreLocation:!1,updateUi:!1}).catch(tH)},ct=[],t[45]=st,t[46]=ct):(st=t[45],ct=t[46]),(0,Q.useEffect)(st,ct);let ut,dt;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(ut=()=>{let e=!0,t=tV(async function(){try{let t=oe.current,n=await l(await fetch(t?`/api/documents?showAll=true`:`/api/documents`),`Failed to load documents`);if(!e)return;if(!n.ok)D(n.title);else{let e=li.safeParse(n.body);if(!e.success)D(`Documents response did not match expected shape.`);else{let n=ae.current||t;C(ai(e.data.documents,n)),D(null)}}}catch(t){let n=t;e&&D(`Could not reach server`),console.warn(`[FileTree] fetch failed:`,n)}e&&T(!1)});se.current=()=>t.request(),t.request();let n=()=>{document.visibilityState===`visible`&&t.request()};window.addEventListener(`focus`,n),window.addEventListener(`visibilitychange`,n);let r=br(e=>{e.includes(`files`)&&t.request()});return()=>{e=!1,se.current=null,t.dispose(),window.removeEventListener(`focus`,n),window.removeEventListener(`visibilitychange`,n),r()}},dt=[],t[47]=ut,t[48]=dt):(ut=t[47],dt=t[48]),(0,Q.useEffect)(ut,dt);let ft=(0,Q.useRef)(!0),pt;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(pt=()=>{if(ft.current){ft.current=!1;return}se.current?.()},t[49]=pt):pt=t[49];let mt;t[50]===we?mt=t[51]:(mt=[we],t[50]=we,t[51]=mt),(0,Q.useEffect)(pt,mt);let ht=(0,Q.useRef)(!0),gt;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(gt=()=>{if(ht.current){ht.current=!1;return}se.current?.()},t[52]=gt):gt=t[52];let _t;t[53]===Te?_t=t[54]:(_t=[Te],t[53]=Te,t[54]=_t),(0,Q.useEffect)(gt,_t);let vt,yt;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(vt=()=>{let e=!0;return fetch(`/api/workspace`).then(async t=>{let n=await t.json();if(!e||!t.ok)return;let r=Ze(Kr,n,`workspace`,null);r&&L({contentDir:r.contentDir,pathSeparator:r.pathSeparator})}).catch(eH),()=>{e=!1}},yt=[],t[55]=vt,t[56]=yt):(vt=t[55],yt=t[56]),(0,Q.useEffect)(vt,yt);let bt;t[57]!==qe||t[58]!==Ne||t[59]!==ze?(bt=()=>{if(te.current===ze){te.current=null;return}Ne.resetPaths(Be.current,{initialExpandedPaths:qe()})},t[57]=qe,t[58]=Ne,t[59]=ze,t[60]=bt):bt=t[60];let xt;t[61]!==Ne||t[62]!==ze?(xt=[Ne,ze],t[61]=Ne,t[62]=ze,t[63]=xt):xt=t[63],(0,Q.useEffect)(bt,xt),KB(Ne,ge,Ge,re);let St,Ct;t[64]===Ne?(St=t[65],Ct=t[66]):(St=()=>Ne.subscribe(()=>{if(!Ne.isSearchOpen())for(let e of K.current){let t=WB(Ne.getItem(e));t&&!t.isExpanded()&&t.expand()}}),Ct=[Ne],t[64]=Ne,t[65]=St,t[66]=Ct),(0,Q.useEffect)(St,Ct);let wt,Tt;t[67]===Ne?(wt=t[68],Tt=t[69]):(wt=()=>Ne.onMutation(`remove`,e=>{let t=q.current;!t||e.path!==t.renamePath||ee.current(t)}),Tt=[Ne],t[67]=Ne,t[68]=wt,t[69]=Tt),(0,Q.useEffect)(wt,Tt);let Et;t[70]!==g||t[71]!==s||t[72]!==c||t[73]!==b||t[74]!==p?(Et=async(e,t,n)=>{let r=t===void 0?[]:t,i=n?.docName??V.current,a=mO(i,e),o=n?.folderPath??(fe.current?.kind===`folder`?fe.current.folderPath:null),l=o?Ie(o,r):null,u=hO(e,c());await Promise.all(u.map(e=>s(e)));for(let t of e)g(t.toDocName);p(e,r),C(t=>{let n=fO(t,e,r);return Qe(n),n}),o&&l&&l!==o?b(l):a&&a!==i&&(window.location.hash=Tr(a)),Fr([`files`,`backlinks`,`graph`])},t[70]=g,t[71]=s,t[72]=c,t[73]=b,t[74]=p,t[75]=Et):Et=t[75];let Dt=Et;async function Ot(e){let t=rO(e.sourcePath,e.isFolder);k(t),D(null);try{if(!e.isFolder&&et(t)){X.error(`Assets cannot be renamed from the sidebar`),queueMicrotask(()=>{Ye()}),rt(),k(null);return}let n=cB(e.sourcePath,e.destinationPath,e.isFolder);if(n.kind===`block`){X.error(`File extensions are managed automatically - please rename without changing the extension`),queueMicrotask(()=>{Ye()}),rt(),k(null);return}let r=rO(n.destinationPath,e.isFolder),i=e.isFolder?{kind:`folder`,fromPath:qD(t),toPath:qD(r)}:{kind:`file`,fromPath:WD(t),toPath:WD(r)},a={docName:V.current,folderPath:fe.current?.kind===`folder`?fe.current.folderPath:null},o=await l(await fetch(`/api/rename-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)}),`Failed to rename path`);if(!o.ok){X.error(o.title),D(o.title),Ye();let e=q.current;e&&e.renamePath===t?await at(e):rt(),k(null);return}let s=Ze(Zn,o.body,`rename-path`,{renamed:[]});try{await Dt(s.renamed,e.isFolder?[{fromPath:qD(t),toPath:qD(r)}]:[],a)}catch(e){console.warn(`[FileTree] post-rename reconciliation failed`,{err:e,sourceTreePath:t,destinationTreePath:r,renamedCount:s.renamed.length}),X.error(`Rename succeeded but the sidebar may be out of date — refresh to resync`)}rt(),k(null)}catch(e){console.warn(`[FileTree] rename failed:`,e),X.error(`Network error — please try again`),D(`Network error — please try again`),Ye();let n=q.current;n&&n.renamePath===t?await at(n):rt(),k(null)}}let kt;t[76]!==Dt||t[77]!==Ye?(kt=async function(e){let t=e.draggedPaths.map(t=>{let n=oO(t,e.target);return t===n?null:{sourcePath:t,destinationTreePath:n}}).filter($V);if(t.length!==0){if(t.some(e=>et(e.sourcePath))){X.error(`Assets cannot be moved from the sidebar`),Ye();return}k(t[0]?.sourcePath??null),D(null);try{let e=[],n=[],r={docName:V.current,folderPath:fe.current?.kind===`folder`?fe.current.folderPath:null};for(let r of t){let t=r.sourcePath.endsWith(`/`),i=t?{kind:`folder`,fromPath:qD(r.sourcePath),toPath:qD(r.destinationTreePath)}:{kind:`file`,fromPath:WD(r.sourcePath),toPath:WD(r.destinationTreePath)},a=await l(await fetch(`/api/rename-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)}),`Failed to move`);if(!a.ok){X.error(a.title),D(a.title),Ye(),k(null);return}let o=Ze(Zn,a.body,`rename-path:drop`,{renamed:[]});e=e.concat(o.renamed),t&&n.push({fromPath:qD(r.sourcePath),toPath:qD(r.destinationTreePath)})}try{await Dt(e,n,r)}catch(n){console.warn(`[FileTree] post-move reconciliation failed`,{err:n,operationCount:t.length,renamedCount:e.length}),X.error(`Move succeeded but the sidebar may be out of date — refresh to resync`)}k(null)}catch(e){console.warn(`[FileTree] move failed:`,e),X.error(`Network error — please try again`),Ye(),k(null)}}},t[76]=Dt,t[77]=Ye,t[78]=kt):kt=t[78];let At=kt,jt;t[79]===Symbol.for(`react.memo_cache_sentinel`)?(jt=function(e){F({parentDir:e})},t[79]=jt):jt=t[79];let Mt=jt,Nt;t[80]!==at||t[81]!==rt||t[82]!==Ne||t[83]!==b||t[84]!==v||t[85]!==Ye||t[86]!==Re?(Nt=async function(e,t){if(ie.current)return;let n=q.current;n&&rt(n);try{let n=iO(e,t,[...Re,...Ue.current]);k(n.renamePath),ie.current=n.renamePath;let r=window.location.hash,i;if(e===`file`){let e=aO(`file`,n.addPath),t=await l(await fetch(`/api/create-page`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})}),`Failed to create file`);if(!t.ok){X.error(t.title),D(t.title),k(null),ie.current=null;return}let r=WD(e),a=Ze(wr,t.body,`create-page`,{docName:r}).docName;i=a;let o=e.toLowerCase().endsWith(`.mdx`)?`.mdx`:`.md`;C(e=>{if(e.some(e=>hn(e)&&e.docName===a))return e;let t=[...e,{kind:`document`,docName:a,docExt:o,modified:new Date().toISOString(),size:0}];return Qe(t),t}),Fr([`files`,`backlinks`,`graph`]),v(a)}else{let e=qD(n.addPath),t=await l(await fetch(`/api/create-folder`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})}),`Failed to create folder`);if(!t.ok){X.error(t.title),D(t.title),k(null),ie.current=null;return}i=Ze(Lr,t.body,`create-folder`,{path:e}).path,C(e=>{if(e.some(e=>ti(e)&&e.path===i))return e;let t=[...e,{kind:`folder`,path:i,modified:new Date().toISOString(),size:0}];return Qe(t),t}),Fr([`files`]),b(i)}let a=!1,o=e=>{if(e.key!==`Enter`)return;let t=q.current;!t||t.renamePath!==n.renamePath||queueMicrotask(()=>rt(t))};document.addEventListener(`keydown`,o,!0),q.current={kind:e,renamePath:n.renamePath,createdPath:i,previousHash:r,disposeCommitListener:()=>{a||(a=!0,document.removeEventListener(`keydown`,o,!0))}},k(null),ie.current=null,Ne.add(n.addPath),Ne.startRenaming(n.renamePath,{removeIfCanceled:!0})}catch(e){console.warn(`[FileTree] create placeholder failed:`,e),X.error(`Could not start creating a new item`);let t=q.current;t?await at(t):rt(),k(null),ie.current=null,Ye()}},t[80]=at,t[81]=rt,t[82]=Ne,t[83]=b,t[84]=v,t[85]=Ye,t[86]=Re,t[87]=Nt):Nt=t[87];let Pt=Nt,Ft;t[88]===Ne?Ft=t[89]:(Ft=function(e){let t=JD(e);(0,Q.startTransition)(()=>{for(let e of Ue.current)if(e===t||e.startsWith(t)){let t=WB(Ne.getItem(e));t&&t.expand()}})},t[88]=Ne,t[89]=Ft);let It=Ft,Lt;t[90]===Ne?Lt=t[91]:(Lt=function(e){let t=JD(e),n=new Set(K.current);(0,Q.startTransition)(()=>{for(let e of[...Ue.current].reverse())if((e===t||e.startsWith(t))&&!n.has(e)){let t=WB(Ne.getItem(e));t&&t.collapse()}})},t[90]=Ne,t[91]=Lt);let Rt=Lt,zt;t[92]!==B||t[93]!==We||t[94]!==r||t[95]!==i||t[96]!==U||t[97]!==O||t[98]!==at||t[99]!==S||t[100]!==He||t[101]!==At||t[102]!==Ot||t[103]!==Fe||t[104]!==tt||t[105]!==Te||t[106]!==we||t[107]!==Re?(zt=()=>{R.current=S,V.current=r,fe.current=i,W.current=U,ie.current=O,ae.current=we,oe.current=Te,Be.current=Re,Ue.current=He,K.current=We,ee.current=at,le.current=e=>{if(re.current||e.length!==1)return;let t=e[0];t&&B(Fe(t),S)},ue.current=e=>{tt(e)||X.error(e)},J.current=Ot,de.current=At},t[92]=B,t[93]=We,t[94]=r,t[95]=i,t[96]=U,t[97]=O,t[98]=at,t[99]=S,t[100]=He,t[101]=At,t[102]=Ot,t[103]=Fe,t[104]=tt,t[105]=Te,t[106]=we,t[107]=Re,t[108]=zt):zt=t[108],(0,Q.useLayoutEffect)(zt);let Bt,Vt;t[109]===Ne?(Bt=t[110],Vt=t[111]):(Bt=()=>{let e=e=>{if(!(e.metaKey||e.ctrlKey)||e.altKey||e.key.toLowerCase()!==`a`||RV(e.target))return;let t=ce.current,n=e.target,r=document.activeElement,i=n instanceof Node&&t?.contains(n),a=r instanceof Node&&t?.contains(r);if(!i&&!a)return;let o=new Set([...Ue.current,...Be.current]);re.current=!0;for(let e of o)!e||W.current.has(e)||Ne.getItem(e)?.select();queueMicrotask(()=>{re.current=!1}),e.preventDefault(),e.stopPropagation()};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},Vt=[Ne],t[109]=Ne,t[110]=Bt,t[111]=Vt),(0,Q.useEffect)(Bt,Vt);let Ht,Ut;t[112]!==S.length||t[113]!==w?(Ht=()=>{if(w||S.length===0)return;let e=ce.current?.querySelector(tj)?.shadowRoot;if(!e)return;let t=QV,n=()=>{for(let n of e.querySelectorAll(`[data-item-path]`)){let e=n.dataset.itemPath;if(!e)continue;let r=t(e);n.title!==r&&(n.title=r)}let n=e.querySelector(`[data-type="context-menu-anchor"]`);if(n){let r=e.querySelector(`[data-item-context-hover="true"][data-item-path]`)?.dataset.itemPath,i=r?t(r):``;n.title!==i&&(n.title=i)}};n();let r=new MutationObserver(n);return r.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`data-item-path`,`data-item-context-hover`]}),()=>r.disconnect()},Ut=[w,S.length],t[112]=S.length,t[113]=w,t[114]=Ht,t[115]=Ut):(Ht=t[114],Ut=t[115]),(0,Q.useEffect)(Ht,Ut);let Wt,Gt;t[116]!==S.length||t[117]!==w?(Wt=()=>{if(w||S.length===0)return;let e=ce.current?.querySelector(tj)?.shadowRoot;if(!e)return;let t=()=>dB(e);t();let n=new MutationObserver(t);return n.observe(e,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:[`data-item-path`]}),()=>n.disconnect()},Gt=[w,S.length],t[116]=S.length,t[117]=w,t[118]=Wt,t[119]=Gt):(Wt=t[118],Gt=t[119]),(0,Q.useEffect)(Wt,Gt);let Kt,qt;t[120]!==S.length||t[121]!==w?(Kt=()=>{if(w||S.length===0)return;let e=ce.current?.querySelector(tj)?.shadowRoot;if(!e)return;let t=()=>wB(e);t();let n=new MutationObserver(t);return n.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`data-item-path`]}),()=>n.disconnect()},qt=[w,S.length],t[120]=S.length,t[121]=w,t[122]=Kt,t[123]=qt):(Kt=t[122],qt=t[123]),(0,Q.useEffect)(Kt,qt);let Jt;t[124]===Symbol.for(`react.memo_cache_sentinel`)?(Jt={folderCount:0,expandedCount:0},t[124]=Jt):Jt=t[124];let Yt=(0,Q.useRef)(Jt),Xt=(0,Q.useRef)(Pt),Zt=(0,Q.useRef)(Mt),Qt;t[125]===Pt?Qt=t[126]:(Qt=()=>{Xt.current=Pt,Zt.current=Mt},t[125]=Pt,t[126]=Qt),(0,Q.useEffect)(Qt);let $t,en;t[127]===Ne?($t=t[128],en=t[129]):($t=()=>({startCreating(e,t){Xt.current(e,t)},startCreatingFromTemplate(e){Zt.current(e)},expandAll(){(0,Q.startTransition)(()=>{for(let e of Ue.current){let t=WB(Ne.getItem(e));t&&t.expand()}})},collapseAll(){let e=new Set(K.current);(0,Q.startTransition)(()=>{for(let t of[...Ue.current].reverse()){if(e.has(t))continue;let n=WB(Ne.getItem(t));n&&n.collapse()}})},getFolderState(){let e=Ue.current,t=0;for(let n of e)WB(Ne.getItem(n))?.isExpanded()&&t++;let n=e.length,r=Yt.current;if(r.folderCount===n&&r.expandedCount===t)return r;let i={folderCount:n,expandedCount:t};return Yt.current=i,i},subscribe(e){return Ne.subscribe(e)}}),en=[Ne],t[127]=Ne,t[128]=$t,t[129]=en),(0,Q.useImperativeHandle)(n,$t,en);let tn;t[130]!==rt||t[131]!==s||t[132]!==a||t[133]!==Ne?(tn=async function(e,t,n){let r=zV(e,R.current,Ue.current),i=q.current;i&&e.some(e=>BV(e,i))&&(i.kind===`file`?r.docNames.add(i.createdPath):r.folderPaths.add(i.createdPath),rt(i));let o=new Set([...r.docNames,...t]),c=new Set([...r.folderPaths,...n]);a([...[...o].map(ZV),...[...c].map(XV)],{force:!0}),await Promise.all([...o].map(e=>s(e)));for(let t of e){let e=t.kind===`folder`?JD(t.path):UD(t.path,t.docExt);Ne.getItem(e)&&Ne.remove(e,t.kind===`folder`?{recursive:!0}:void 0)}C(e=>{let t=pO(e,[...o]);for(let e of c)t=pO(t,[],e);return Qe(t),t}),Fr([`files`,`backlinks`,`graph`])},t[130]=rt,t[131]=s,t[132]=a,t[133]=Ne,t[134]=tn):tn=t[134];let nn=tn,rn;t[135]===nn?rn=t[136]:(rn=async function(e){let t=[],n=[],r=[];for(let i of e){k(i.path);let e=await l(await fetch(`/api/delete-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:i.kind,path:i.path})}),`Failed to delete path`);if(!e.ok)return r.length>0&&await nn(r,t,n),X.error(e.title),!1;let a=Ze(ei,e.body,`delete-path`,{deletedDocNames:[]});t.push(...a.deletedDocNames),i.kind===`folder`&&n.push(i.path),r.push(i)}return await nn(r,t,n),!0},t[135]=nn,t[136]=rn);let an=rn,on;t[137]===Symbol.for(`react.memo_cache_sentinel`)?(on=async function(e,t,n){let r=[],i=[];for(let a of e){k(a.path);let e=gO(a,n),o=await t.shell.trashItem(e);o.ok?r.push(a):i.push({kind:a.kind,path:a.path,name:a.name,reason:RB(o.reason),detail:o.detail})}return{trashed:r,failed:i}},t[137]=on):on=t[137];let sn=on,cn;t[138]===Symbol.for(`react.memo_cache_sentinel`)?(cn=async function(e){let t=[],n=[],r=[];for(let i of e)try{let e=await l(await fetch(`/api/trash/cleanup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:i.kind,path:i.path})}),`Failed to clean up after trash`);if(!e.ok){console.warn(`[FileTree] trash-cleanup failed`,{target:`${i.kind}:${i.path}`,reason:e.title}),r.push({target:i,reason:e.title});continue}let a=Ze(ir,e.body,`trash-cleanup`,{deletedDocNames:[]});t.push(...a.deletedDocNames),i.kind===`folder`&&n.push(i.path)}catch(e){let t=e;console.warn(`[FileTree] trash-cleanup threw`,{target:`${i.kind}:${i.path}`,err:t}),r.push({target:i,reason:`Network error during cleanup`})}if(r.length>0){let e=r.length,t=e===1?`item`:`items`;X.error(`Server-side cleanup failed for ${e} ${t}`,{description:`The file is in your Trash; the file-watcher will reconcile.`})}return r.length===e.length&&e.length>0?null:{deletedDocNames:t,deletedFolderPaths:n}},t[138]=cn):cn=t[138];let ln=cn,un;t[139]!==nn||t[140]!==an||t[141]!==Ye||t[142]!==I?(un=async function(e){let t=e[0];if(!t)return;k(t.path),j(null);let n=typeof window<`u`?window.okDesktop:void 0;try{if(n&&I){let{trashed:t,failed:r}=await sn(e,n,I);if(t.length>0){let e=await ln(t);e?await nn(t,e.deletedDocNames,e.deletedFolderPaths):await nn(t,t.filter(YV).map(JV),t.filter(qV).map(KV))}r.length>0&&N({failed:r,originalTargets:[...e]}),k(null)}else{let t=await an(e);k(null),t||Ye()}}catch(e){let t=e,n=t instanceof Error?t.message:String(t);console.warn(`[FileTree] delete failed:`,t),X.error(`Could not complete delete`,{description:n}),k(null),Ye()}},t[139]=nn,t[140]=an,t[141]=Ye,t[142]=I,t[143]=un):un=t[143];let dn=un,fn;t[144]!==an||t[145]!==Ye||t[146]!==M?(fn=async function(){if(!M)return;let e=new Set(M.failed.map(GV)),t=M.originalTargets.filter(t=>e.has(`${t.kind}:${t.path}`));if(N(null),t.length!==0){k(t[0]?.path??null);try{let e=await an(t);k(null),e||Ye()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);console.warn(`[FileTree] hard-delete fallback failed:`,t),X.error(`Could not complete delete`,{description:n}),k(null),Ye()}}},t[144]=an,t[145]=Ye,t[146]=M,t[147]=fn):fn=t[147];let pn=fn,mn;t[148]!==dn||t[149]!==M?(mn=async function(){if(!M)return;let e=new Set(M.failed.map(WV)),t=M.originalTargets.filter(t=>e.has(`${t.kind}:${t.path}`));N(null),await dn(t)},t[148]=dn,t[149]=M,t[150]=mn):mn=t[150];let gn=mn,_n=(0,Q.useRef)(dn),vn;t[151]===dn?vn=t[152]:(vn=()=>{_n.current=dn},t[151]=dn,t[152]=vn),(0,Q.useEffect)(vn);let yn,bn;t[153]===Symbol.for(`react.memo_cache_sentinel`)?(yn=()=>QB(e=>{if(e.kind===`doc`||e.kind===`folder-index`){let t=e.docName,n=R.current.find(e=>hn(e)&&e.docName===t);_n.current([{kind:`file`,path:t,name:t.split(`/`).pop()??t,docExt:n?.docExt}]);return}if(e.kind===`folder`){_n.current([{kind:`folder`,path:e.folderPath,name:e.folderPath.split(`/`).pop()??e.folderPath}]);return}console.warn(JSON.stringify({event:`file-tree-menu-action-delete-unsupported-kind`,kind:e.kind}))}),bn=[],t[153]=yn,t[154]=bn):(yn=t[153],bn=t[154]),(0,Q.useEffect)(yn,bn);let xn,Sn;t[155]===Ne?(xn=t[156],Sn=t[157]):(xn=()=>eV(e=>{if(e.kind===`doc`||e.kind===`folder-index`){let t=e.docName,n=UD(t,R.current.find(e=>hn(e)&&e.docName===t)?.docExt);Ne.startRenaming(n);return}if(e.kind===`folder`){Ne.startRenaming(e.folderPath);return}console.warn(JSON.stringify({event:`file-tree-menu-action-rename-unsupported-kind`,kind:e.kind}))}),Sn=[Ne],t[155]=Ne,t[156]=xn,t[157]=Sn),(0,Q.useEffect)(xn,Sn);let Cn;t[158]===Symbol.for(`react.memo_cache_sentinel`)?(Cn=function(){let e=ne.current;e&&gV(e),ne.current=null},t[158]=Cn):Cn=t[158];let wn=Cn,Tn;t[159]===f?Tn=t[160]:(Tn=function(e){let t=lH(e.nativeEvent);if(!t||t.endsWith(`/`)){wn();return}let n=WD(t),r=R.current.find(e=>GD(e)===t);if(r&&Hn(r)){wn();return}ne.current!==n&&(wn(),ne.current=n,hV(n,e=>f(e)))},t[159]=f,t[160]=Tn);let En=Tn,Dn;t[161]!==B||t[162]!==Ne||t[163]!==b?(Dn=function(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=uH(e.nativeEvent);if(!t||t.getAttribute(`aria-selected`)!==`true`)return;let n=t.dataset.itemPath;if(!n)return;let r=t.dataset.itemType===`folder`?JD(n):n;if(Ne.getSelectedPaths().length!==1)return;if(t.dataset.itemType===`folder`){let e=qD(r);if(window.location.hash===or(e))return;queueMicrotask(()=>b(e));return}let i=WD(r);window.location.hash!==Tr(i)&&queueMicrotask(()=>B(r))},t[161]=B,t[162]=Ne,t[163]=b,t[164]=Dn):Dn=t[164];let On=Dn;if(w){let e;return t[165]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(fH,{}),t[165]=e):e=t[165],e}if(S.length===0){if(E){let e;return t[166]===E?e=t[167]:(e=(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-8`,children:(0,Z.jsx)(`span`,{className:`select-none text-sidebar-foreground/50 text-sm`,children:E})}),t[166]=E,t[167]=e),e}let e;t[168]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`span`,{className:`select-none text-sidebar-foreground/30 text-sm`,children:`No files yet.`}),t[168]=e):e=t[168];let n;return t[169]===Pt?n=t[170]:(n=(0,Z.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 py-8`,children:[e,(0,Z.jsx)(Y,{variant:`link`,size:`sm`,className:`font-mono uppercase`,onClick:()=>Pt(`file`,``),children:`Create your first file`})]}),t[169]=Pt,t[170]=n),n}let kn=O!==null,An=A?.targets[0]??null,jn;t[171]===E?jn=t[172]:(jn=E&&(0,Z.jsx)(`span`,{role:`alert`,className:`px-3 pb-1 text-destructive text-xs`,children:E}),t[171]=E,t[172]=jn);let Mn;t[173]===h?Mn=t[174]:(Mn=kV(h),t[173]=h,t[174]=Mn);let Nn;t[175]!==kn||t[176]!==U||t[177]!==Rt||t[178]!==It||t[179]!==He||t[180]!==be||t[181]!==Ce||t[182]!==Ne||t[183]!==xe||t[184]!==Se||t[185]!==Pt||t[186]!==I?(Nn=(e,t)=>(0,Z.jsx)(VV,{item:e,context:t,anyActionBusy:kn,workspace:I,handoff:be,model:Ne,okignoreBinding:xe,projectLocalBinding:Se,mergedConfig:Ce,onStartCreating:Pt,onStartCreatingFromTemplate:Mt,onDelete:e=>j({targets:e}),onExpandSubtree:It,onCollapseSubtree:Rt,folderTreePaths:He,isAsset:U.has(e.path),isAssetTreePath:et}),t[175]=kn,t[176]=U,t[177]=Rt,t[178]=It,t[179]=He,t[180]=be,t[181]=Ce,t[182]=Ne,t[183]=xe,t[184]=Se,t[185]=Pt,t[186]=I,t[187]=Nn):Nn=t[187];let Pn;t[188]!==On||t[189]!==En||t[190]!==Ne||t[191]!==jn||t[192]!==Mn||t[193]!==Nn?(Pn=(0,Z.jsx)(`div`,{ref:ce,className:`flex min-h-0 flex-1 flex-col`,children:(0,Z.jsx)(iB,{header:jn,model:Ne,style:Mn,onClickCapture:On,onMouseMove:En,onMouseLeave:wn,renderContextMenu:Nn})}),t[188]=On,t[189]=En,t[190]=Ne,t[191]=jn,t[192]=Mn,t[193]=Nn,t[194]=Pn):Pn=t[194];let Fn=!!A,In;t[195]===O?In=t[196]:(In=e=>{!e&&!O&&j(null)},t[195]=O,t[196]=In);let Ln;t[197]!==O||t[198]!==A||t[199]!==dn||t[200]!==An?(Ln=A&&An&&(0,Z.jsx)(io,{...(()=>{let e=FB(typeof window<`u`&&window.okDesktop!=null?`electron`:`web`,A.targets);return e?{customTitle:e.title,customDescription:``,customDetail:e.detail,customConfirmLabel:e.confirmLabel,customConfirmLabelBusy:e.confirmLabelBusy,children:e.listedTargets?(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1 font-mono text-foreground text-xs`,children:e.listedTargets.map(UV)}):null}:{itemName:A.targets.length===1?`${An.name}${An.kind===`file`?An.docExt??`.md`:`/`}`:void 0,customTitle:A.targets.length>1?`Delete selected items`:void 0,customDescription:A.targets.length>1?`Are you sure you want to delete ${A.targets.length} selected items? Folders and all files inside them will be deleted. This action cannot be undone.`:An.kind===`folder`?`Are you sure you want to delete ${An.name}/ and all files inside? This action cannot be undone.`:void 0}})(),isSubmitting:O!==null,onDelete:()=>dn(A.targets)}),t[197]=O,t[198]=A,t[199]=dn,t[200]=An,t[201]=Ln):Ln=t[201];let Rn;t[202]!==Fn||t[203]!==In||t[204]!==Ln?(Rn=(0,Z.jsx)(jo,{open:Fn,onOpenChange:In,children:Ln}),t[202]=Fn,t[203]=In,t[204]=Ln,t[205]=Rn):Rn=t[205];let zn=!!M,Bn;t[206]===O?Bn=t[207]:(Bn=e=>{!e&&!O&&N(null)},t[206]=O,t[207]=Bn);let Vn;t[208]!==O||t[209]!==pn||t[210]!==gn||t[211]!==M?(Vn=M&&(0,Z.jsx)(HB,{failedTargets:M.failed,isSubmitting:O!==null,onDeletePermanently:pn,onRetry:gn,onCancel:()=>N(null)}),t[208]=O,t[209]=pn,t[210]=gn,t[211]=M,t[212]=Vn):Vn=t[212];let Un;t[213]!==zn||t[214]!==Bn||t[215]!==Vn?(Un=(0,Z.jsx)(jo,{open:zn,onOpenChange:Bn,children:Vn}),t[213]=zn,t[214]=Bn,t[215]=Vn,t[216]=Un):Un=t[216];let Wn=P!==null,Gn;t[217]===Symbol.for(`react.memo_cache_sentinel`)?(Gn=e=>{e||F(null)},t[217]=Gn):Gn=t[217];let Kn=P?.parentDir??``,qn;t[218]!==Wn||t[219]!==Kn?(qn=(0,Z.jsx)(Hp,{open:Wn,onOpenChange:Gn,kind:`file`,initialDir:Kn}),t[218]=Wn,t[219]=Kn,t[220]=qn):qn=t[220];let Jn;return t[221]!==Pn||t[222]!==Rn||t[223]!==Un||t[224]!==qn?(Jn=(0,Z.jsxs)(Z.Fragment,{children:[Pn,Rn,Un,qn]}),t[221]=Pn,t[222]=Rn,t[223]=Un,t[224]=qn,t[225]=Jn):Jn=t[225],Jn}function UV(e){return(0,Z.jsx)(`li`,{"data-testid":`delete-target-row`,children:IB(e)},`${e.kind}:${e.path}`)}function WV(e){return`${e.kind}:${e.path}`}function GV(e){return`${e.kind}:${e.path}`}function KV(e){return e.path}function qV(e){return e.kind===`folder`}function JV(e){return e.path}function YV(e){return e.kind===`file`}function XV(e){return lt(e)}function ZV(e){return Je(e)}function QV(e){return e.endsWith(`/`)?e.slice(0,-1):e}function $V(e){return!!e}function eH(e){console.warn(`[FileTree] /api/workspace fetch failed:`,e)}function tH(e){console.warn(`[FileTree] unmount cleanup failed:`,e)}function nH(e){X.error(e)}function rH(){}function iH(e){return X.error(e)}function aH(){}function oH(){}async function sH(){}function cH(e){return GD(e)}function lH(e){return uH(e)?.dataset.itemPath??null}function uH(e){for(let t of e.composedPath())if(t instanceof HTMLElement&&t.dataset.itemPath)return t;return null}var dH=[`w-3/4`,`w-2/3`,`w-4/5`,`w-1/2`,`w-3/5`,`w-2/3`];function fH(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`div`,{className:`flex flex-1 flex-col gap-1 px-2 py-2`,role:`status`,"aria-busy":`true`,"aria-label":`Loading files`,children:dH.map(pH)}),e[0]=t):t=e[0],t}function pH(e,t){return(0,Z.jsxs)(`div`,{className:`flex h-6 items-center gap-2`,children:[(0,Z.jsx)(Ma,{className:`h-3 w-3 shrink-0 rounded-sm`}),(0,Z.jsx)(Ma,{className:`h-3 ${e}`})]},t)}function mH(e){return e?`No workspace`:null}function hH(e){let t=(0,$.c)(41),{input:n,installStates:r,dispatch:i,webFallbackVisible:a}=e,o=a===void 0?!0:a,s=n===null,c;t[0]===s?c=t[1]:(c=mH(s),t[0]=s,t[1]=c);let l=c,u,d,f,p,m,h,g;if(t[2]!==i||t[3]!==l||t[4]!==n||t[5]!==s||t[6]!==r||t[7]!==o){g=Symbol.for(`react.early_return_sentinel`);bb0:{let e;t[15]===r?e=t[16]:(e=e=>r[e.id]?.installed===!0,t[15]=r,t[16]=e);let a=xm.filter(e);f=r[`claude-code`]?.installed===!0;let c;t[17]===n?c=t[18]:(c=n!==null&&n.docContext!==null?$r(n.docContext.relativePath):``,t[17]=n,t[18]=c);let _=c,v;t[19]!==n||t[20]!==_?(v=()=>{n!==null&&qx(_)},t[19]=n,t[20]=_,t[21]=v):v=t[21],p=v;let y=o&&!f;if(a.length===0&&!y){g=null;break bb0}d=xO,t[22]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsxs)(wO,{children:[(0,Z.jsx)(Fi,{"aria-hidden":`true`}),`Open with AI`]}),t[22]=h):h=t[22],u=TO;let b;t[23]!==i||t[24]!==l||t[25]!==n||t[26]!==s?(b=e=>{let t=!s,r=l?`Open with AI ${e.displayName}, ${l}`:`Open with AI ${e.displayName}`;return(0,Z.jsxs)(CO,{disabled:!t,onSelect:()=>{n&&i(e.id,n)},"data-testid":`empty-space-open-in-${e.id}`,"aria-label":r,children:[(0,Z.jsx)(Vx,{id:e.id,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:e.displayName}),l?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:l}):null]},e.id)},t[23]=i,t[24]=l,t[25]=n,t[26]=s,t[27]=b):b=t[27],m=a.map(b)}t[2]=i,t[3]=l,t[4]=n,t[5]=s,t[6]=r,t[7]=o,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g}else u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14];if(g!==Symbol.for(`react.early_return_sentinel`))return g;let _;t[28]!==f||t[29]!==p||t[30]!==s||t[31]!==o?(_=o&&!f?(0,Z.jsxs)(CO,{onSelect:p,disabled:s,"data-testid":`empty-space-open-in-claude-web-fallback`,"aria-label":`Open in claude.ai, opens in browser with prompt pre-filled`,children:[(0,Z.jsx)(he,{className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:`Open in claude.ai →`}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`opens in browser`})]}):null,t[28]=f,t[29]=p,t[30]=s,t[31]=o,t[32]=_):_=t[32];let v;t[33]!==u||t[34]!==m||t[35]!==_?(v=(0,Z.jsxs)(u,{children:[m,_]}),t[33]=u,t[34]=m,t[35]=_,t[36]=v):v=t[36];let y;return t[37]!==d||t[38]!==h||t[39]!==v?(y=(0,Z.jsxs)(d,{children:[h,v]}),t[37]=d,t[38]=h,t[39]=v,t[40]=y):y=t[40],y}var gH=(e,t,n)=>il(e,t,n,`ProjectSwitcher`);function _H(e){let t=(0,$.c)(59),{bridge:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let[i,a]=(0,Q.useState)(r),[o,s]=(0,Q.useState)(!1),c;t[1]!==n.project||t[2]!==o?(c=()=>{if(!o)return;let e=!1;return gH(async()=>{let t=await n.project.listRecent();e||a(t)},`Failed to load recent projects.`),()=>{e=!0}},t[1]=n.project,t[2]=o,t[3]=c):c=t[3];let l;t[4]!==n||t[5]!==o?(l=[o,n],t[4]=n,t[5]=o,t[6]=l):l=t[6],(0,Q.useEffect)(c,l);let u;t[7]===n.project?u=t[8]:(u=e=>{s(!1),gH(()=>n.project.open({path:e,target:`new-window`,entryPoint:`recents`}),`Failed to open project.`)},t[7]=n.project,t[8]=u);let d=u,f;t[9]!==n.dialog||t[10]!==n.project?(f=()=>{s(!1),gH(async()=>{let e=await n.dialog.openFolder();e&&await n.project.open({path:e,target:`new-window`,entryPoint:`pick-existing`})},`Failed to open folder.`)},t[9]=n.dialog,t[10]=n.project,t[11]=f):f=t[11];let p=f,m;t[12]===n.navigator?m=t[13]:(m=()=>{s(!1),gH(()=>n.navigator.open(),`Failed to open Project Navigator.`)},t[12]=n.navigator,t[13]=m);let h=m,g=n.config.projectPath,_,v,y,b,x,S,C,w,T,E,D;if(t[14]!==n.config.projectName||t[15]!==g||t[16]!==o||t[17]!==d||t[18]!==i){let e;t[30]===g?e=t[31]:(e=e=>e.path!==g,t[30]=g,t[31]=e);let r=i.filter(e);v=va,S=o,C=s;let a;t[32]===n.config.projectName?a=t[33]:(a=(0,Z.jsx)(`span`,{className:`truncate`,children:n.config.projectName}),t[32]=n.config.projectName,t[33]=a);let c;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(qs,{"aria-hidden":`true`,className:`opacity-60`}),t[34]=c):c=t[34],t[35]===a?w=t[36]:(w=(0,Z.jsx)(ba,{asChild:!0,children:(0,Z.jsxs)(yD,{className:`justify-between text-sidebar-foreground/70`,"data-testid":`project-switcher-trigger`,title:`Open project menu`,children:[a,c]})}),t[35]=a,t[36]=w),_=_a,T=`start`,E=`top`,D=`min-w-[260px]`,y=`project-switcher-menu`,t[37]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(Qi,{className:`font-mono font-normal tracking-wide uppercase text-muted-foreground text-xs`,children:`Recent projects`}),t[37]=b):b=t[37],x=r.length===0?(0,Z.jsx)(Qi,{className:`font-normal text-muted-foreground text-xs`,children:`No other recent projects.`}):r.slice(0,10).map(e=>(0,Z.jsxs)(ya,{disabled:e.missing,onSelect:()=>d(e.path),className:`flex flex-col items-start gap-0.5`,"data-testid":`project-switcher-recent-${e.path}`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),(0,Z.jsxs)(`span`,{className:`max-w-[240px] truncate text-muted-foreground text-xs`,children:[e.path,e.missing?` (missing)`:``]})]},e.path)),t[14]=n.config.projectName,t[15]=g,t[16]=o,t[17]=d,t[18]=i,t[19]=_,t[20]=v,t[21]=y,t[22]=b,t[23]=x,t[24]=S,t[25]=C,t[26]=w,t[27]=T,t[28]=E,t[29]=D}else _=t[19],v=t[20],y=t[21],b=t[22],x=t[23],S=t[24],C=t[25],w=t[26],T=t[27],E=t[28],D=t[29];let O;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(na,{}),t[38]=O):O=t[38];let k;t[39]===p?k=t[40]:(k=(0,Z.jsx)(ya,{onSelect:p,"data-testid":`project-switcher-open-folder`,children:`Open folder`}),t[39]=p,t[40]=k);let A;t[41]===h?A=t[42]:(A=(0,Z.jsx)(ya,{onSelect:h,"data-testid":`project-switcher-switch-project`,children:`Switch Project`}),t[41]=h,t[42]=A);let j;t[43]!==_||t[44]!==y||t[45]!==b||t[46]!==x||t[47]!==k||t[48]!==A||t[49]!==T||t[50]!==E||t[51]!==D?(j=(0,Z.jsxs)(_,{align:T,side:E,className:D,"data-testid":y,children:[b,x,O,k,A]}),t[43]=_,t[44]=y,t[45]=b,t[46]=x,t[47]=k,t[48]=A,t[49]=T,t[50]=E,t[51]=D,t[52]=j):j=t[52];let M;return t[53]!==v||t[54]!==S||t[55]!==C||t[56]!==w||t[57]!==j?(M=(0,Z.jsxs)(v,{open:S,onOpenChange:C,children:[w,j]}),t[53]=v,t[54]=S,t[55]=C,t[56]=w,t[57]=j,t[58]=M):M=t[58],M}function vH(e,t){let n=e instanceof Error?e:Error(String(e));console.warn(JSON.stringify({event:`jsx-render-failure`,component:`sidebarSearchPill`,rawComponentName:`sidebarSearchPill`,error:String(n),stack:t.componentStack})),Hr(`sidebarSearchPill`)}function yH(e){let t=(0,$.c)(8),{onClick:n,className:r}=e,i;t[0]===r?i=t[1]:(i=mi(`rounded-lg h-9 w-full justify-start gap-2 px-3 font-normal text-muted-foreground`,r),t[0]=r,t[1]=i);let a,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Me,{"aria-hidden":`true`}),o=(0,Z.jsx)(`span`,{className:`flex-1 text-left text-sm`,children:`Search`}),t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(OS,{className:`text-foreground/70`,children:Dn()?`⌘ K`:`Ctrl K`}),t[4]=s):s=t[4];let c;return t[5]!==n||t[6]!==i?(c=(0,Z.jsxs)(Y,{variant:`outline`,onClick:n,"data-telemetry-event":`ok.sidebar.search_pill.click`,className:i,children:[a,o,s]}),t[5]=n,t[6]=i,t[7]=c):c=t[7],c}function bH(e){let t=(0,$.c)(33),{notice:n,onDismiss:r}=e,i=n.variant===`error`?`border-destructive/60`:`border-sidebar-border`,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(_o,{"aria-hidden":`true`,className:`size-3`}),t[0]=a):a=t[0];let o;t[1]===r?o=t[2]:(o=(0,Z.jsx)(Y,{variant:`ghost`,size:`icon`,className:`size-5 shrink-0 text-muted-foreground hover:text-sidebar-foreground`,"aria-label":`Dismiss notice`,onClick:r,children:a}),t[1]=r,t[2]=o);let s=o;if(n.secondaryAction){let e=`update-notice-${n.id}`,r=`flex flex-col gap-2 rounded-md border bg-sidebar-accent/30 px-2 py-2 text-xs text-muted-foreground ${i}`,a;t[3]===n.body?a=t[4]:(a=(0,Z.jsx)(`span`,{className:`flex-1 leading-snug`,children:n.body}),t[3]=n.body,t[4]=a);let o;t[5]!==s||t[6]!==a?(o=(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[a,s]}),t[5]=s,t[6]=a,t[7]=o):o=t[7];let c;t[8]===n.action?c=t[9]:(c=n.action?(0,Z.jsx)(`button`,{type:`button`,className:`shrink-0 text-xs font-medium underline underline-offset-2 decoration-muted-foreground/40 hover:text-sidebar-foreground hover:decoration-sidebar-foreground`,onClick:()=>{n.action?.onClick()},children:n.action.label}):null,t[8]=n.action,t[9]=c);let l;t[10]===n.secondaryAction?l=t[11]:(l=()=>{n.secondaryAction?.onClick()},t[10]=n.secondaryAction,t[11]=l);let u;t[12]!==n.secondaryAction.label||t[13]!==l?(u=(0,Z.jsx)(`button`,{type:`button`,className:`shrink-0 text-xs font-medium underline underline-offset-2 decoration-muted-foreground/40 hover:text-sidebar-foreground hover:decoration-sidebar-foreground`,onClick:l,children:n.secondaryAction.label}),t[12]=n.secondaryAction.label,t[13]=l,t[14]=u):u=t[14];let d;t[15]!==c||t[16]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex gap-3 pl-1`,children:[c,u]}),t[15]=c,t[16]=u,t[17]=d):d=t[17];let f;return t[18]!==d||t[19]!==e||t[20]!==r||t[21]!==o?(f=(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":e,className:r,children:[o,d]}),t[18]=d,t[19]=e,t[20]=r,t[21]=o,t[22]=f):f=t[22],f}let c=`update-notice-${n.id}`,l=`flex items-center gap-2 rounded-md border bg-sidebar-accent/30 px-2 py-1.5 text-xs text-muted-foreground ${i}`,u;t[23]===n.body?u=t[24]:(u=(0,Z.jsx)(`span`,{className:`flex-1 leading-snug`,children:n.body}),t[23]=n.body,t[24]=u);let d;t[25]===n.action?d=t[26]:(d=n.action?(0,Z.jsx)(`button`,{type:`button`,className:`shrink-0 text-xs font-medium underline underline-offset-2 decoration-muted-foreground/40 hover:text-sidebar-foreground hover:decoration-sidebar-foreground`,onClick:()=>{n.action?.onClick()},children:n.action.label}):null,t[25]=n.action,t[26]=d);let f;return t[27]!==s||t[28]!==c||t[29]!==l||t[30]!==u||t[31]!==d?(f=(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":c,className:l,children:[u,d,s]}),t[27]=s,t[28]=c,t[29]=l,t[30]=u,t[31]=d,t[32]=f):f=t[32],f}function xH(e){if(e.length===0)return null;let t=e[0];if(!t)return null;for(let n=1;n<e.length;n++){let r=e[n];r&&r.priority<t.priority&&(t=r)}return t}function SH(){let e=(0,$.c)(7),t=(0,Q.useSyncExternalStore)(qf,Kf,Kf),n;e[0]===t?n=e[1]:(n=xH(t),e[0]=t,e[1]=n);let r=n;if(!r)return null;let i;e[2]===r.id?i=e[3]:(i=()=>{Gf(r.id)},e[2]=r.id,e[3]=i);let a;return e[4]!==r||e[5]!==i?(a=(0,Z.jsx)(`div`,{"data-testid":`update-notices-list`,children:(0,Z.jsx)(bH,{notice:r,onDismiss:i})}),e[4]=r,e[5]=i,e[6]=a):a=e[6],a}function CH(e,t,n){return e?.kind===`doc`&&t||e?.kind===`folder-index`&&t?nh(n.contentDir,rh(t),n.pathSeparator):e?.kind===`folder`?nh(n.contentDir,e.folderPath,n.pathSeparator):n.contentDir}function wH(e,t,n){if((e?.kind===`doc`||e?.kind===`folder-index`)&&t){let e=t.lastIndexOf(`/`);return e<0?n.contentDir:nh(n.contentDir,t.slice(0,e),n.pathSeparator)}return e?.kind===`folder`?nh(n.contentDir,e.folderPath,n.pathSeparator):n.contentDir}function TH(e,t){return(e?.kind===`doc`||e?.kind===`folder-index`)&&t?rh(t):e?.kind===`folder`?e.folderPath:``}function EH(e,t,n){return e===null?ah({workspace:n}):e.kind===`folder`?n?oh({folderAbsPath:nh(n.contentDir,e.folderPath,n.pathSeparator),folderRelativePath:e.folderPath,workspace:n}):null:e.kind===`doc`||e.kind===`folder-index`?ih({docName:t,workspace:n}):null}var DH={folderCount:0,expandedCount:0},OH=`button, [role="button"], [role="menuitem"], input, textarea, select, a[href]`;function kH(e){return typeof Element>`u`||!(e instanceof Element)?!1:e.closest(OH)!==null}function AH(e){let t=(0,$.c)(2),{onOpenSearch:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(Ve,{name:`file-sidebar`,children:(0,Z.jsx)(MH,{onOpenSearch:n})}),t[0]=n,t[1]=r),r}var jH=e=>{let t=(0,$.c)(15),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({icon:n,label:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=(0,Z.jsx)(n,{"aria-hidden":`true`}),t[4]=n,t[5]=a);let o;t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,Z.jsx)(kr,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,"aria-label":r,...i,children:a})}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9];let s;t[10]===r?s=t[11]:(s=(0,Z.jsx)(vn,{children:r}),t[10]=r,t[11]=s);let c;return t[12]!==o||t[13]!==s?(c=(0,Z.jsxs)(yn,{children:[o,s]}),t[12]=o,t[13]=s,t[14]=c):c=t[14],c};function MH(e){let t=(0,$.c)(164),{onOpenSearch:n}=e,[r,i]=(0,Q.useState)(null),{activeDocName:a,activeTarget:o}=ot(),s;t[0]!==a||t[1]!==o?(s=o?.kind===`folder`||o?.kind===`folder-index`?o.folderPath:sr(a),t[0]=a,t[1]=o,t[2]=s):s=t[2];let c=s,l=typeof window<`u`&&window.okDesktop!=null,{state:u}=aD(),d=u===`expanded`,f=l&&u===`collapsed`,[p,m]=(0,Q.useState)(DH),h,g;t[3]===r?(h=t[4],g=t[5]):(h=()=>{if(r!==null)return m(r.getFolderState()),r.subscribe(()=>{m(r.getFolderState())})},g=[r],t[3]=r,t[4]=h,t[5]=g),(0,Q.useEffect)(h,g);let _,v;t[6]===r?(_=t[7],v=t[8]):(_=()=>{if(r!==null)return MS(()=>{r.startCreating(`file`,``)})},v=[r],t[6]=r,t[7]=_,t[8]=v),(0,Q.useEffect)(_,v);let y=p.folderCount>0,b=y&&p.expandedCount===p.folderCount,x=p.expandedCount===0,S=Aa(``),C=S.state.status===`ready`?(S.state.data.folder.templates_available?.length??0)>0:!0,w=typeof window<`u`?window.okDesktop:void 0,T=km(),D=Oh().states,{dispatch:k}=_h(),A;t[9]===T?A=t[10]:(A=ah({workspace:T}),t[9]=T,t[10]=A);let j=A,{projectLocalBinding:M,merged:N}=Ga(),P=N?.appearance?.sidebar?.showHiddenFiles??!1,F=N?.appearance?.sidebar?.showAllFiles??!1,I=y&&!b,L=y&&!x,z=I||L,B=IH,V;t[11]!==r||t[12]!==T?(V=()=>{T&&r?.startCreating(`file`,``)},t[11]=r,t[12]=T,t[13]=V):V=t[13];let H=V,U;t[14]!==r||t[15]!==T?(U=()=>{T&&r?.startCreatingFromTemplate(``)},t[14]=r,t[15]=T,t[16]=U):U=t[16];let W=U,G;t[17]!==r||t[18]!==T?(G=()=>{T&&r?.startCreating(`folder`,``)},t[17]=r,t[18]=T,t[19]=G):G=t[19];let K=G,q;t[20]===T?q=t[21]:(q=()=>{!T||!w||w.shell.showItemInFolder(T.contentDir)},t[20]=T,t[21]=q);let ee=q,te;t[22]===T?te=t[23]:(te=()=>{!T||!w||JB(w,T.contentDir)},t[22]=T,t[23]=te);let ne=te,re;t[24]===T?re=t[25]:(re=async()=>{if(T)try{await navigator.clipboard.writeText(T.contentDir),X.success(`Copied full path`,{description:T.contentDir})}catch(e){console.warn(`[FileSidebar] clipboard write failed:`,e),X.error(`Could not copy full path`)}},t[24]=T,t[25]=re);let ie=re,ae;t[26]===M?ae=t[27]:(ae=e=>{if(M===null)return;let t=M.patch({appearance:{sidebar:{showHiddenFiles:e}}});t.ok||(console.warn(`[FileSidebar] showHiddenFiles toggle rejected:`,Nn(t.error)),X.error(`Could not update sidebar settings`,{description:Nn(t.error)}))},t[26]=M,t[27]=ae);let oe=ae,se;t[28]===M?se=t[29]:(se=e=>{if(M===null)return;let t=M.patch({appearance:{sidebar:{showAllFiles:e}}});t.ok||(console.warn(`[FileSidebar] showAllFiles toggle rejected:`,Nn(t.error)),X.error(`Could not update sidebar settings`,{description:Nn(t.error)}))},t[28]=M,t[29]=se);let ce=se,le;t[30]===r?le=t[31]:(le=()=>{r?.expandAll()},t[30]=r,t[31]=le);let J=le,ue;t[32]===r?ue=t[33]:(ue=()=>{r?.collapseAll()},t[32]=r,t[33]=ue);let de=ue,fe,pe;t[34]!==F||t[35]!==L||t[36]!==I||t[37]!==P?(fe=()=>{w&&w.editor.notifyViewMenuStateChanged({showHiddenFiles:P,showAllFiles:F,canExpandAll:I,canCollapseAll:L})},pe=[w,P,F,I,L],t[34]=F,t[35]=L,t[36]=I,t[37]=P,t[38]=fe,t[39]=pe):(fe=t[38],pe=t[39]),(0,Q.useEffect)(fe,pe);let me,he;t[40]!==a||t[41]!==o||t[42]!==k||t[43]!==D||t[44]!==c||t[45]!==M||t[46]!==F||t[47]!==P||t[48]!==r||t[49]!==T?(me=()=>{if(w)return w.onMenuAction(e=>{switch(e){case`new-doc`:if(!T||!r)return;r.startCreating(`file`,c);return;case`new-folder`:if(!T||!r)return;r.startCreating(`folder`,c);return;case`new-from-template`:if(!T||!r)return;r.startCreatingFromTemplate(c);return;case`rename`:if(!o)return;$B(o);return;case`move-to-trash`:if(!o)return;ZB(o);return;case`reveal-in-finder`:{if(!w||!T)return;let e=CH(o,a,T);w.shell.showItemInFolder(e);return}case`open-in-terminal`:if(!w||!T)return;JB(w,wH(o,a,T));return;case`send-to-ai`:{let e=xm.filter(e=>D[e.id]?.installed===!0);if(e.length===0){X.error(`No AI agents installed`);return}let t=EH(o,a,T);if(!t)return;let[n]=e;if(!n)return;k(n.id,t);return}case`copy-full-path`:{if(!T)return;let e=CH(o,a,T);navigator.clipboard.writeText(e).then(()=>X.success(`Copied full path`,{description:e})).catch(FH);return}case`copy-relative-path`:{let e=TH(o,a);if(e===``){X.error(`No file or folder selected`);return}navigator.clipboard.writeText(e).then(()=>X.success(`Copied relative path`,{description:e})).catch(PH);return}case`toggle-show-hidden-files`:{if(M===null)return;let e=M.patch({appearance:{sidebar:{showHiddenFiles:!P}}});e.ok||(console.warn(`[FileSidebar] toggle-show-hidden-files rejected:`,Nn(e.error)),X.error(`Could not update sidebar settings`,{description:Nn(e.error)}));return}case`toggle-show-all-files`:{if(M===null)return;let e=M.patch({appearance:{sidebar:{showAllFiles:!F}}});e.ok||(console.warn(`[FileSidebar] toggle-show-all-files rejected:`,Nn(e.error)),X.error(`Could not update sidebar settings`,{description:Nn(e.error)}));return}case`expand-all-tree`:r?.expandAll();return;case`collapse-all-tree`:r?.collapseAll();return;case`delete`:case`toggle-sidebar`:case`toggle-source`:case`save-version`:case`version-history`:case`focus-search`:case`focus-command-palette`:return}})},he=[w,r,T,o,a,c,M,P,F,D,k],t[40]=a,t[41]=o,t[42]=k,t[43]=D,t[44]=c,t[45]=M,t[46]=F,t[47]=P,t[48]=r,t[49]=T,t[50]=me,t[51]=he):(me=t[50],he=t[51]),(0,Q.useEffect)(me,he);let ge=f&&`opacity-0`,_e;t[52]===ge?_e=t[53]:(_e=mi(`flex-row h-12 items-center py-0 px-3`,l?`justify-end`:`justify-between`,l&&`motion-safe:transition-opacity motion-safe:duration-100 motion-safe:ease-out`,ge,l&&`[-webkit-app-region:drag]`),t[52]=ge,t[53]=_e);let ve;t[54]===d?ve=t[55]:(ve=d&&!l?(0,Z.jsx)(`span`,{className:`shrink-0 font-mono text-sm uppercase tracking-wider text-sidebar-foreground/50`,children:`Files`}):null,t[54]=d,t[55]=ve);let ye;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(ye=mi(`flex items-center gap-1`,l&&`[&>*]:[-webkit-app-region:no-drag]`),t[56]=ye):ye=t[56];let be;t[57]!==b||t[58]!==y||t[59]!==x||t[60]!==r?(be=y?(0,Z.jsxs)(va,{children:[(0,Z.jsx)(ba,{asChild:!0,children:(0,Z.jsx)(jH,{icon:yc,label:`Tree View Options`})}),(0,Z.jsxs)(_a,{align:`end`,children:[b?null:(0,Z.jsxs)(ya,{onSelect:()=>r?.expandAll(),children:[(0,Z.jsx)(Qc,{"aria-hidden":`true`}),`Expand All`]}),x?null:(0,Z.jsxs)(ya,{onSelect:()=>r?.collapseAll(),children:[(0,Z.jsx)(cc,{"aria-hidden":`true`}),`Collapse All`]})]})]}):null,t[57]=b,t[58]=y,t[59]=x,t[60]=r,t[61]=be):be=t[61];let xe;t[62]!==c||t[63]!==r?(xe=(0,Z.jsx)(jH,{icon:Wc,label:`New File`,onClick:()=>r?.startCreating(`file`,c)}),t[62]=c,t[63]=r,t[64]=xe):xe=t[64];let Se;t[65]!==C||t[66]!==c||t[67]!==r?(Se=C?(0,Z.jsx)(jH,{icon:oc,label:`New from template`,onClick:()=>r?.startCreatingFromTemplate(c)}):null,t[65]=C,t[66]=c,t[67]=r,t[68]=Se):Se=t[68];let Ce;t[69]!==c||t[70]!==r?(Ce=(0,Z.jsx)(jH,{icon:uc,label:`New Folder`,onClick:()=>r?.startCreating(`folder`,c)}),t[69]=c,t[70]=r,t[71]=Ce):Ce=t[71];let we;t[72]!==be||t[73]!==xe||t[74]!==Se||t[75]!==Ce?(we=(0,Z.jsxs)(`div`,{className:ye,children:[be,xe,Se,Ce]}),t[72]=be,t[73]=xe,t[74]=Se,t[75]=Ce,t[76]=we):we=t[76];let Te;t[77]!==_e||t[78]!==ve||t[79]!==we?(Te=(0,Z.jsxs)(pD,{className:_e,children:[ve,we]}),t[77]=_e,t[78]=ve,t[79]=we,t[80]=Te):Te=t[80];let Ee=f&&`opacity-0`,De;t[81]===Ee?De=t[82]:(De=mi(`px-2 pb-2`,l&&`[-webkit-app-region:no-drag]`,l&&`motion-safe:transition-opacity motion-safe:duration-100 motion-safe:ease-out`,Ee),t[81]=Ee,t[82]=De);let Oe;t[83]===u?Oe=t[84]:(Oe=[u],t[83]=u,t[84]=Oe);let ke;t[85]===n?ke=t[86]:(ke=(0,Z.jsx)(yH,{onClick:n}),t[85]=n,t[86]=ke);let Ae;t[87]!==Oe||t[88]!==ke?(Ae=(0,Z.jsx)(O,{fallbackRender:NH,onError:vH,resetKeys:Oe,children:ke}),t[87]=Oe,t[88]=ke,t[89]=Ae):Ae=t[89];let je;t[90]!==De||t[91]!==Ae?(je=(0,Z.jsx)(`div`,{className:De,children:Ae}),t[90]=De,t[91]=Ae,t[92]=je):je=t[92];let Me;t[93]===Symbol.for(`react.memo_cache_sentinel`)?(Me=(0,Z.jsx)(hD,{children:(0,Z.jsx)(HV,{ref:i})}),t[93]=Me):Me=t[93];let Ne,Pe;t[94]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=(0,Z.jsxs)(mD,{className:`px-0`,children:[(0,Z.jsx)(SH,{}),typeof window<`u`&&window.okDesktop?(0,Z.jsx)(gD,{children:(0,Z.jsx)(_D,{children:(0,Z.jsx)(_H,{bridge:window.okDesktop})})}):null]}),Pe=(0,Z.jsx)(dD,{enableToggle:!1}),t[94]=Ne,t[95]=Pe):(Ne=t[94],Pe=t[95]);let Fe;t[96]!==Te||t[97]!==je?(Fe=(0,Z.jsx)(bO,{asChild:!0,children:(0,Z.jsxs)(`div`,{className:`contents`,onContextMenu:B,children:[Te,je,Me,Ne,Pe]})}),t[96]=Te,t[97]=je,t[98]=Fe):Fe=t[98];let Ie=!T,Le;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(Le=(0,Z.jsx)(Wc,{"aria-hidden":`true`}),t[99]=Le):Le=t[99];let Re;t[100]!==H||t[101]!==Ie?(Re=(0,Z.jsxs)(CO,{disabled:Ie,onSelect:H,"data-testid":`empty-space-menu-new-file`,children:[Le,`New File`]}),t[100]=H,t[101]=Ie,t[102]=Re):Re=t[102];let ze=!T||!C,Be;t[103]===Symbol.for(`react.memo_cache_sentinel`)?(Be=(0,Z.jsx)(oc,{"aria-hidden":`true`}),t[103]=Be):Be=t[103];let Ve;t[104]!==W||t[105]!==ze?(Ve=(0,Z.jsxs)(CO,{disabled:ze,onSelect:W,"data-testid":`empty-space-menu-new-from-template`,children:[Be,`New from template`]}),t[104]=W,t[105]=ze,t[106]=Ve):Ve=t[106];let He=!T,Ue;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,Z.jsx)(uc,{"aria-hidden":`true`}),t[107]=Ue):Ue=t[107];let We;t[108]!==K||t[109]!==He?(We=(0,Z.jsxs)(CO,{disabled:He,onSelect:K,"data-testid":`empty-space-menu-new-folder`,children:[Ue,`New Folder`]}),t[108]=K,t[109]=He,t[110]=We):We=t[110];let Ge;t[111]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=(0,Z.jsx)(DO,{}),t[111]=Ge):Ge=t[111];let Ke;t[112]!==ee||t[113]!==T?(Ke=w?(0,Z.jsxs)(CO,{disabled:!T,onSelect:ee,"data-testid":`empty-space-menu-reveal-in-finder`,"aria-label":T?`Reveal in Finder`:`Reveal in Finder, No workspace`,children:[(0,Z.jsx)(R,{"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:`Reveal in Finder`}),T?null:(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`No workspace`})]}):null,t[112]=ee,t[113]=T,t[114]=Ke):Ke=t[114];let qe;t[115]!==k||t[116]!==j||t[117]!==D?(qe=(0,Z.jsx)(hH,{input:j,installStates:D,dispatch:k,webFallbackVisible:!1}),t[115]=k,t[116]=j,t[117]=D,t[118]=qe):qe=t[118];let Je;t[119]!==ne||t[120]!==T?(Je=w?(0,Z.jsxs)(CO,{disabled:!T,onSelect:ne,"data-testid":`empty-space-menu-open-in-terminal`,"aria-label":T?`Open in Terminal`:`Open in Terminal, No workspace`,children:[(0,Z.jsx)(Yc,{"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:`Open in Terminal`}),T?null:(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`No workspace`})]}):null,t[119]=ne,t[120]=T,t[121]=Je):Je=t[121];let Ye=!T,Xe=T?`Copy full path`:`Copy full path, No workspace`,Ze,Qe;t[122]===Symbol.for(`react.memo_cache_sentinel`)?(Ze=(0,Z.jsx)(E,{"aria-hidden":`true`}),Qe=(0,Z.jsx)(`span`,{className:`flex-1`,children:`Copy full path`}),t[122]=Ze,t[123]=Qe):(Ze=t[122],Qe=t[123]);let $e;t[124]===T?$e=t[125]:($e=T?null:(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`No workspace`}),t[124]=T,t[125]=$e);let et;t[126]!==ie||t[127]!==Ye||t[128]!==Xe||t[129]!==$e?(et=(0,Z.jsxs)(CO,{disabled:Ye,onSelect:ie,"data-testid":`empty-space-menu-copy-full-path`,"aria-label":Xe,children:[Ze,Qe,$e]}),t[126]=ie,t[127]=Ye,t[128]=Xe,t[129]=$e,t[130]=et):et=t[130];let tt;t[131]===Symbol.for(`react.memo_cache_sentinel`)?(tt=(0,Z.jsx)(DO,{}),t[131]=tt):tt=t[131];let nt=M===null,rt;t[132]!==oe||t[133]!==P||t[134]!==nt?(rt=(0,Z.jsx)(EO,{checked:P,onCheckedChange:oe,disabled:nt,"data-testid":`empty-space-menu-show-hidden-files`,children:`Show Hidden Files`}),t[132]=oe,t[133]=P,t[134]=nt,t[135]=rt):rt=t[135];let it=M===null,at;t[136]!==ce||t[137]!==F||t[138]!==it?(at=(0,Z.jsx)(EO,{checked:F,onCheckedChange:ce,disabled:it,"data-testid":`empty-space-menu-show-all-files`,children:`Show all files`}),t[136]=ce,t[137]=F,t[138]=it,t[139]=at):at=t[139];let st;t[140]===z?st=t[141]:(st=z?(0,Z.jsx)(DO,{}):null,t[140]=z,t[141]=st);let ct;t[142]!==J||t[143]!==I?(ct=I?(0,Z.jsxs)(CO,{onSelect:J,"data-testid":`empty-space-menu-expand-all`,children:[(0,Z.jsx)(Qc,{"aria-hidden":`true`}),`Expand all`]}):null,t[142]=J,t[143]=I,t[144]=ct):ct=t[144];let lt;t[145]!==de||t[146]!==L?(lt=L?(0,Z.jsxs)(CO,{onSelect:de,"data-testid":`empty-space-menu-collapse-all`,children:[(0,Z.jsx)(cc,{"aria-hidden":`true`}),`Collapse all`]}):null,t[145]=de,t[146]=L,t[147]=lt):lt=t[147];let ut;t[148]!==Re||t[149]!==Ve||t[150]!==We||t[151]!==Ke||t[152]!==qe||t[153]!==Je||t[154]!==et||t[155]!==rt||t[156]!==at||t[157]!==st||t[158]!==ct||t[159]!==lt?(ut=(0,Z.jsxs)(SO,{children:[Re,Ve,We,Ge,Ke,qe,Je,et,tt,rt,at,st,ct,lt]}),t[148]=Re,t[149]=Ve,t[150]=We,t[151]=Ke,t[152]=qe,t[153]=Je,t[154]=et,t[155]=rt,t[156]=at,t[157]=st,t[158]=ct,t[159]=lt,t[160]=ut):ut=t[160];let dt;return t[161]!==Fe||t[162]!==ut?(dt=(0,Z.jsx)(lD,{variant:`inset`,children:(0,Z.jsxs)(yO,{children:[Fe,ut]})}),t[161]=Fe,t[162]=ut,t[163]=dt):dt=t[163],dt}function NH(){return null}function PH(e){console.warn(`[FileSidebar] clipboard write failed:`,e),X.error(`Could not copy relative path`)}function FH(e){console.warn(`[FileSidebar] clipboard write failed:`,e),X.error(`Could not copy full path`)}function IH(e){kH(e.target)&&(e.preventDefault(),e.stopPropagation())}function LH(){let e=(0,$.c)(17),t=ln(),{collabUrl:n,setSystemProvider:r,updateServerInstanceId:i,onBranchSwitched:a,observeBranch:o,observeDiskAck:s,refreshServerInfo:c}=ot(),l;e[0]!==o||e[1]!==s||e[2]!==a||e[3]!==c||e[4]!==i?(l={updateServerInstanceId:i,onBranchSwitched:a,observeBranch:o,observeDiskAck:s,refreshServerInfo:c},e[0]=o,e[1]=s,e[2]=a,e[3]=c,e[4]=i,e[5]=l):l=e[5];let u=(0,Q.useRef)(l),d;e[6]!==o||e[7]!==s||e[8]!==a||e[9]!==c||e[10]!==i?(d=()=>{u.current={updateServerInstanceId:i,onBranchSwitched:a,observeBranch:o,observeDiskAck:s,refreshServerInfo:c}},e[6]=o,e[7]=s,e[8]=a,e[9]=c,e[10]=i,e[11]=d):d=e[11],(0,Q.useEffect)(d);let f,p;return e[12]!==n||e[13]!==t||e[14]!==r?(f=()=>{if(n===null)return;let e=new Se,i=new _t({url:n,name:$n,document:e,onStateless:e=>{let{payload:t}=e;_(t,{onServerInfo:e=>{u.current.updateServerInstanceId(e.serverInstanceId),e.currentBranch!==void 0&&u.current.observeBranch(e.currentBranch)},onBranchSwitched:e=>{u.current.onBranchSwitched(e.branch)},onDiskAck:e=>{u.current.observeDiskAck(e.docName,e.sv)},onDerivedView:UH,onConfigValidationRejected:HH,onConfigIgnoreNestedError:VH,onUnknown:BH})},onClose:zH,onDisconnect:RH}),a=br(e=>{(e.includes(`files`)||e.includes(`backlinks`))&&(t.invalidateQueries({queryKey:[`backlinks`]}),t.invalidateQueries({queryKey:[`forward-links`]})),(e.includes(`files`)||e.includes(`graph`))&&(t.invalidateQueries({queryKey:[`orphans`]}),t.invalidateQueries({queryKey:[`hubs`]}))}),o=q(()=>{u.current.refreshServerInfo()});i.on(`synced`,()=>{Fr([`files`,`backlinks`,`graph`]),o()});let s=new Set,c=()=>{if(i.awareness)for(let[e,t]of i.awareness.getStates().entries())s.has(e)||t.user?.type===`agent`&&(s.add(e),console.warn(`[agent-presence] observed stale AwarenessUser.type === 'agent' from clientID ${e} — probably a stale bundled client`))};return i.awareness?.on(`change`,c),r(i),()=>{a(),i.awareness?.off(`change`,c),r(null),i.destroy(),e.destroy()}},p=[t,n,r],e[12]=n,e[13]=t,e[14]=r,e[15]=f,e[16]=p):(f=e[15],p=e[16]),(0,Q.useEffect)(f,p),null}function RH(){console.warn(`[CC1] __system__ disconnected - derived views may be stale`)}function zH(e){let{event:t}=e;console.warn(`[CC1] __system__ connection closed:`,t.code,t.reason)}function BH(e){console.warn(`[CC1] Unparseable stateless payload, skipping:`,e.slice(0,100))}function VH(e){Za(e)}function HH(e){eo(e)}function UH(e){Fr([e.ch])}var WH=`#install-claude-desktop`;function GH(e){return e===`#settings`||e===WH}function KH(e,t,n){return[e,t,n].map(e=>[...e].sort().join(`\0`)).join(``)}function qH(){let e=(0,$.c)(20),{clearTarget:t,syncOpenTabsWithKnownTargets:n,tabSessionLoaded:r}=ot(),{openTargetTransition:i}=gt(),{assetPaths:a,folderPaths:o,loading:s,pages:c}=qr(),l=(0,Q.useRef)(null),u;e[0]!==a||e[1]!==o||e[2]!==c?(u=KH(c,o,a),e[0]=a,e[1]=o,e[2]=c,e[3]=u):u=e[3];let d=u,f,p;e[4]!==a||e[5]!==o||e[6]!==s||e[7]!==c||e[8]!==n||e[9]!==r||e[10]!==d?(f=()=>{s||!r||l.current===d||(l.current=d,n({pages:c,folderPaths:o,assetPaths:a}))},p=[a,o,s,c,n,r,d],e[4]=a,e[5]=o,e[6]=s,e[7]=c,e[8]=n,e[9]=r,e[10]=d,e[11]=f,e[12]=p):(f=e[11],p=e[12]),(0,Q.useEffect)(f,p);let m,h;return e[13]!==t||e[14]!==o||e[15]!==s||e[16]!==i||e[17]!==c?(m=()=>{e();function e(){if(GH(window.location.hash))return;let e=Jr(window.location.hash);if(e){let t=Er(e.split(`.`).pop()??``);dt(`ok/nav/hash-change`,{docName:null,kind:`asset`}),i({kind:`asset`,target:e,assetPath:e,mediaKind:t});return}let n=Rr(window.location.hash);if(!n){dt(`ok/nav/hash-change`,{docName:null,kind:`clear`}),t();return}if(s){dt(`ok/nav/hash-change`,{docName:n,kind:`deferred-loading`});return}let r=Yr(n,{pages:c,folderPaths:o});if(r.kind===`missing`&&/\/+$/.test(n.trim())){dt(`ok/nav/hash-change`,{docName:n,kind:`deferred-missing-folder`});return}let a=jr(r);dt(`ok/nav/hash-change`,{docName:n,kind:a.kind}),i(a)}return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},h=[t,o,s,i,c],e[13]=t,e[14]=o,e[15]=s,e[16]=i,e[17]=c,e[18]=m,e[19]=h):(m=e[18],h=e[19]),(0,Q.useEffect)(m,h),null}function JH(){let e=(0,$.c)(5),[t,n]=(0,Q.useState)(typeof window<`u`&&window.location.hash===WH),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=function(){window.location.hash===WH&&n(!0)};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Q.useEffect)(r,i);let a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=function(e){if(n(e),!e&&window.location.hash===WH){let{pathname:e,search:t}=window.location;window.history.replaceState(null,``,`${e}${t}`)}},e[2]=a):a=e[2];let o=a,s;return e[3]===t?s=e[4]:(s=(0,Z.jsx)(Ta,{open:t,onOpenChange:o}),e[3]=t,e[4]=s),s}function YH(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,Q.useEffect)(XH,t),null}function XH(){let e=function(e){let t=e.target;Cm({target:t,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,key:e.key})&&(e.preventDefault(),window.location.hash!==`#settings`&&(window.location.hash=Sm))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}function ZH(){let e=(0,$.c)(4),{activeTarget:t}=ot(),n=typeof window<`u`?window.okDesktop??null:null,r=t?.kind===`doc`||t?.kind===`folder`?t.kind:null,i=t?.kind===`doc`?t.docName:t?.kind===`folder`?t.folderPath:null,a,o;return e[0]!==i||e[1]!==r?(a=()=>{if(n){if(r===null){n.editor.notifyActiveTargetChanged({kind:null});return}i!==null&&n.editor.notifyActiveTargetChanged({kind:r,identifier:i})}},o=[n,r,i],e[0]=i,e[1]=r,e[2]=a,e[3]=o):(a=e[2],o=e[3]),(0,Q.useEffect)(a,o),null}function QH(){let e=(0,$.c)(8),{activeDocName:t,activeTarget:n}=ot(),[r,i]=(0,Q.useState)(!1),a;e[0]!==t||e[1]!==n?(a=n?.kind===`folder`?n.folderPath:sr(t),e[0]=t,e[1]=n,e[2]=a):a=e[2];let o=a,s,c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=function(e){let t=e.target;Bp({target:t,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,key:e.key})&&(e.preventDefault(),i(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},c=[],e[3]=s,e[4]=c):(s=e[3],c=e[4]),(0,Q.useEffect)(s,c);let l;return e[5]!==r||e[6]!==o?(l=(0,Z.jsx)(Hp,{open:r,onOpenChange:i,kind:`file`,initialDir:o}),e[5]=r,e[6]=o,e[7]=l):l=e[7],l}function $H(){let e=(0,$.c)(21),t=typeof window<`u`?window.okDesktop??null:null,n=typeof window<`u`&&window.okDesktop!=null,[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),l;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=t?ol({bridge:t,authQueryTransport:ul(),cloneTransport:gl(),openSignIn:()=>new Promise(e=>{c(()=>e),o(!0)})}):null,e[0]=l):l=e[0];let u=l,d;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(Gh,{}),e[1]=d):d=e[1];let f,p,m,h,g,_,v,y;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(LH,{}),p=(0,Z.jsx)(qH,{}),m=(0,Z.jsx)(ZH,{}),h=(0,Z.jsx)(QH,{}),g=(0,Z.jsx)(YH,{}),_=(0,Z.jsx)(JH,{}),v=(0,Z.jsx)(Td,{}),y=t&&u?(0,Z.jsx)(zd,{bridge:t,cloneController:u}):null,e[2]=f,e[3]=p,e[4]=m,e[5]=h,e[6]=g,e[7]=_,e[8]=v,e[9]=y):(f=e[2],p=e[3],m=e[4],h=e[5],g=e[6],_=e[7],v=e[8],y=e[9]);let b;e[10]!==a||e[11]!==s?(b=t?(0,Z.jsx)(qu,{open:a,onOpenChange:e=>{e||(o(!1),s?.(null),c(null))},onSuccess:e=>{s?.({authenticated:!0,host:`github.com`,login:e.login}),c(null)}}):null,e[10]=a,e[11]=s,e[12]=b):b=e[12];let x;e[13]===r?x=e[14]:(x=(0,Z.jsx)(Rh,{bridge:t,open:r,onOpenChange:i}),e[13]=r,e[14]=x);let S;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(S=n&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`editor-window-chrome-drag-strip`,className:`pointer-events-none fixed inset-x-0 top-0 z-50 h-2 [-webkit-app-region:drag]`}),e[15]=S):S=e[15];let C;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(AH,{onOpenSearch:()=>i(!0)}),e[16]=C):C=e[16];let w;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsxs)(oD,{className:`h-screen overflow-hidden`,children:[C,(0,Z.jsx)(fD,{className:`overflow-hidden h-[calc(100vh-var(--layout-inset-offset))]`,children:(0,Z.jsx)(Uk,{})})]}),e[17]=w):w=e[17];let T;return e[18]!==b||e[19]!==x?(T=(0,Z.jsx)(Ve,{name:`app`,children:(0,Z.jsx)(bt,{children:(0,Z.jsxs)(to,{children:[d,(0,Z.jsxs)(zr,{children:[f,p,m,h,g,_,v,y,b,x,S,w]})]})})}),e[18]=b,e[19]=x,e[20]=T):T=e[20],T}ws(),typeof window<`u`&&window.okDesktop?.config.apiOrigin&&Yd({apiOrigin:window.okDesktop.config.apiOrigin}),hf()&&xf(),Jf(),typeof window<`u`&&Qd({bridge:window.okDesktop}),typeof window<`u`&&Xo({bridge:window.okDesktop}),typeof window<`u`&&Ko({bridge:window.okDesktop}),typeof window<`u`&&tf({bridge:window.okDesktop}),typeof window<`u`&&Rd({bridge:window.okDesktop});var eU=new Ns({defaultOptions:{queries:{retry:1,staleTime:1e4}}}),tU=document.getElementById(`root`);if(!tU)throw Error(`Root element not found`);var nU=typeof window<`u`&&window.okDesktop?.config.mode===`navigator`;(0,Us.createRoot)(tU).render((0,Z.jsx)(Q.StrictMode,{children:(0,Z.jsx)(tn,{client:eU,children:(0,Z.jsxs)(pr,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,disableTransitionOnChange:!0,storageKey:`ok-theme-v1`,children:[(0,Z.jsx)(zn,{children:nU&&window.okDesktop?(0,Z.jsx)(Wd,{bridge:window.okDesktop}):(0,Z.jsx)($H,{})}),(0,Z.jsx)(Jd,{richColors:!0,closeButton:!0})]})})}));
|