opencami 1.2.0 → 1.3.0

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.
Files changed (34) hide show
  1. package/README.md +2 -0
  2. package/dist/client/assets/_sessionKey-CaDTbjXx.js +97 -0
  3. package/dist/client/assets/{agents-BiadNAEz.js → agents-CGtqdyBi.js} +2 -2
  4. package/dist/client/assets/{agents-screen-C5TPJbry.js → agents-screen-DzIMcmHe.js} +1 -1
  5. package/dist/client/assets/button-BcnCTjUT.js +1 -0
  6. package/dist/client/assets/{connect-DlVsi-ya.js → connect-B8sfEQyb.js} +1 -1
  7. package/dist/client/assets/{file-explorer-screen-B0hwrjdF.js → file-explorer-screen-hjggspl-.js} +1 -1
  8. package/dist/client/assets/{files-dkr2U72N.js → files-BHXmS1J5.js} +2 -2
  9. package/dist/client/assets/{index-D1Et4XlM.js → index-BfhiL2JN.js} +1 -1
  10. package/dist/client/assets/{index-CwoJpeG1.js → index-CxJ4zG_W.js} +1 -1
  11. package/dist/client/assets/{keyboard-shortcuts-dialog-zdnAmDiH.js → keyboard-shortcuts-dialog-DEknElTu.js} +1 -1
  12. package/dist/client/assets/{main-DOBfHXDF.js → main-BlX7CS2-.js} +3 -3
  13. package/dist/client/assets/{opencami-logo-Bxp_4d3X.js → opencami-logo-5KynvViW.js} +1 -1
  14. package/dist/client/assets/{react-DD8SkMJn.js → react-ONC2UaeC.js} +1 -1
  15. package/dist/client/assets/{search-dialog-Ck1AQreu.js → search-dialog-40gW31ca.js} +1 -1
  16. package/dist/client/assets/{session-export-dialog-Bh3zH4nZ.js → session-export-dialog-DSRWU2YO.js} +1 -1
  17. package/dist/client/assets/settings-dialog-AsvYzSBc.js +1 -0
  18. package/dist/client/assets/styles-BGTCU8mq.css +1 -0
  19. package/dist/client/assets/{switch-BoGcWcnr.js → switch-dAvZcYA-.js} +1 -1
  20. package/dist/client/assets/{use-file-explorer-state-B5JLNsSa.js → use-file-explorer-state-C6lX-h0n.js} +1 -1
  21. package/dist/client/assets/{useButton-csSB2uQJ.js → useButton-DhneLsMA.js} +1 -1
  22. package/dist/server/assets/{_sessionKey-DQwkBUS7.js → _sessionKey-ZF1_Jqbt.js} +206 -29
  23. package/dist/server/assets/{_tanstack-start-manifest_v-cW8K1Mnv.js → _tanstack-start-manifest_v-C2FijMus.js} +1 -1
  24. package/dist/server/assets/{index-BwD7ufHE.js → index-CTTNe_Sf.js} +1 -1
  25. package/dist/server/assets/{router-5qObg5aX.js → router-D5D0udHV.js} +33 -25
  26. package/dist/server/assets/{search-dialog-BE2ZBkj0.js → search-dialog-C8Oy-FBs.js} +2 -2
  27. package/dist/server/assets/settings-dialog-CQFuAt9B.js +820 -0
  28. package/dist/server/server.js +2 -2
  29. package/package.json +1 -1
  30. package/dist/client/assets/_sessionKey-xUqdePGW.js +0 -97
  31. package/dist/client/assets/button-seqh98ae.js +0 -1
  32. package/dist/client/assets/settings-dialog-CvUsgnnZ.js +0 -1
  33. package/dist/client/assets/styles-DogPvrGY.css +0 -1
  34. package/dist/server/assets/settings-dialog-BBQcU55J.js +0 -731
@@ -1 +1 @@
1
- import{j as e,r as t,L as se,u as L}from"./main-DOBfHXDF.js";import{p as F,q as I,r as B,s as W,v as A,w as q,x as ie,y as be,z as ve,B as ae}from"./useButton-csSB2uQJ.js";import{y as ye,c as f,j as ne,B as D,H as y,I as je,z as we,m as Ne,l as ke,C as Ce,n as De,E as Se,F as te,p as re,G as ce,K as Fe,L as Ee,N as ze,U as Me,O as Te,R as de,P as ue,Y as Le,Z as Re,_ as Ke,$ as Ue,a0 as $e,a1 as Pe,S as ee,a2 as Ie,V as Be}from"./button-seqh98ae.js";import{r as R,M as We,n as Ae,o as qe,p as le,q as K,D as Q,a as _,b as V,c as H,d as G}from"./use-file-explorer-state-B5JLNsSa.js";import"./react-DD8SkMJn.js";function Oe({className:s}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"80",height:"80",viewBox:"0 0 80 80",fill:"none",className:s,children:[e.jsx("rect",{width:"80",height:"80",fill:"currentColor",className:"text-transparent"}),e.jsx("path",{d:"M61.9624 45.5729C62.5862 44.3371 63.0907 43.3377 63.4782 41.9826C69.8221 28.8286 70.5847 14.0975 67.1723 4.32469C65.8317 0.249835 62.7688 0.254311 62.6374 3.58605C61.355 12.189 58.9061 17.6275 57.1756 21.0554C52.8087 29.7058 45.9949 37.7278 39.3706 42.7305C28.6217 50.8021 25.0716 44.614 24.3711 37.8823C23.8822 32.1203 24.7206 25.5721 26.24 18.2889C27.102 15.3261 24.3944 13.9592 22.5223 16.4122C20.4062 19.3487 18.5586 22.4209 17.1838 25.7318C12.9928 33.4462 10.3896 45.3332 11.4505 57.6273C12.2296 63.5357 13.1688 68.4057 14.1079 73.2757C15.2695 79.0941 19.1598 79.5073 24.3117 78.0088C39.7921 74.0789 54.143 58.872 59.7093 49.1011C60.7255 48.0229 61.3494 46.7872 61.9624 45.5729Z",fill:"currentColor",className:"text-primary-950"})]})}function Qe(){return t.useMemo(()=>typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function _e({isCollapsed:s,onToggleCollapse:i,onSelectAction:a}){const{navigateTo:n,currentPath:o}=R(),c=Qe(),r=t.useMemo(()=>({duration:c?0:.15,ease:s?"easeIn":"easeOut"}),[s,c]),l=t.useCallback(d=>{n(d)},[n]),p=t.useCallback((d,k)=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),k())},[]),w=t.useMemo(()=>[{path:"/",icon:ye,label:"Home",id:"home"}],[]),v=t.useMemo(()=>({className:"border-r border-primary-200 h-full overflow-hidden bg-primary-100 flex flex-col"}),[]),h=48,u=300;return e.jsxs(F.aside,{initial:!1,animate:{width:c?s?h:u:void 0},style:{width:c?void 0:s?h:u},transition:r,className:v.className,role:"navigation","aria-label":"File explorer navigation",children:[e.jsxs(F.div,{layout:!0,transition:{layout:r},className:f("flex items-center h-12 px-2 justify-between"),children:[e.jsx(I,{initial:!1,children:s?null:e.jsx(F.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:r,children:e.jsxs(se,{to:"/new",className:f(ne({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:[e.jsx(Oe,{className:"size-5 rounded-sm","aria-hidden":"true"}),e.jsx("span",{children:"WebClaw"})]})})}),e.jsx(B,{children:e.jsxs(W,{children:[e.jsx(A,{onClick:i,onKeyDown:d=>p(d,i),render:e.jsx(D,{size:"icon-sm",variant:"ghost","aria-label":s?"Expand sidebar":"Collapse sidebar",className:f("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:e.jsx(y,{icon:je,size:20,strokeWidth:1.5,"aria-hidden":"true"})})}),e.jsx(q,{side:"right",children:s?"Expand sidebar":"Collapse sidebar"})]})})]}),e.jsx("div",{className:"px-2 mb-4",children:e.jsx(F.div,{layout:!0,transition:{layout:r},className:"w-full",children:e.jsx(B,{children:e.jsxs(W,{children:[e.jsx(A,{asChild:!0,children:e.jsxs(se,{to:"/chat/$sessionKey",params:{sessionKey:"main"},className:f(ne({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),onClick:a,children:[e.jsx(y,{icon:we,size:20,strokeWidth:1.5,className:"min-w-5","aria-hidden":"true"}),e.jsx(I,{initial:!1,mode:"wait",children:s?null:e.jsx(F.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:r,className:"overflow-hidden whitespace-nowrap",children:"Back to Chat"})})]})}),s?e.jsx(q,{side:"right",children:"Back to Chat"}):null]})})})}),e.jsx("div",{className:"flex-1 min-h-0 relative overflow-hidden",children:e.jsx(I,{initial:!1,children:s?e.jsx(F.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:r,className:"px-2 space-y-1",children:w.map(d=>e.jsx(B,{children:e.jsxs(W,{children:[e.jsx(A,{onClick:()=>l(d.path),onKeyDown:k=>p(k,()=>l(d.path)),render:e.jsx(D,{size:"icon-sm",variant:"ghost","aria-current":o===d.path?"page":void 0,"aria-label":`Navigate to ${d.label}`,className:f("w-full text-primary-600 hover:text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",o===d.path&&"bg-primary-200 text-primary-900"),children:e.jsx(y,{icon:d.icon,size:20,strokeWidth:1.5,"aria-hidden":"true"})})}),e.jsx(q,{side:"right",children:d.label})]})},d.id))},"collapsed-content"):e.jsx(F.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:r,className:"absolute inset-0 pt-0 flex flex-col w-[300px] min-h-0",children:e.jsxs("div",{className:"flex-1 min-h-0 px-2",children:[e.jsx("div",{className:"mb-4",children:e.jsx("h2",{className:"text-sm font-medium text-primary-700 mb-3 px-1.5",children:"Quick Access"})}),e.jsx("nav",{className:"space-y-1",role:"list","aria-label":"Quick access folders",children:w.map(d=>e.jsx("div",{role:"listitem",children:e.jsxs(D,{variant:"ghost",size:"sm",onClick:()=>l(d.path),onKeyDown:k=>p(k,()=>l(d.path)),"aria-current":o===d.path?"page":void 0,className:f("w-full pl-1.5 justify-start text-primary-600 hover:text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",o===d.path&&"bg-primary-200 text-primary-900 font-medium"),"aria-label":`Navigate to ${d.label}`,children:[e.jsx(y,{icon:d.icon,size:20,strokeWidth:1.5,className:"min-w-5","aria-hidden":"true"}),e.jsx("span",{className:"overflow-hidden whitespace-nowrap min-w-0 truncate",children:d.label})]})},d.id))})]})},"content")})}),e.jsx("div",{className:"px-2 py-3 border-t border-primary-200 bg-primary-100",children:e.jsx(F.div,{layout:!0,transition:{layout:r},className:"w-full",children:e.jsx(B,{children:e.jsxs(W,{children:[e.jsx(A,{asChild:!0,children:e.jsxs(D,{variant:"ghost",size:s?"icon-sm":"sm",className:f(s?"w-full":"w-full justify-start pl-1.5","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Settings",children:[e.jsx(y,{icon:Ne,size:20,strokeWidth:1.5,className:"min-w-5","aria-hidden":"true"}),e.jsx(I,{initial:!1,mode:"wait",children:s?null:e.jsx(F.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:r,className:"overflow-hidden whitespace-nowrap",children:"Settings"})})]})}),s?e.jsx(q,{side:"right",children:"Settings"}):null]})})})})]})}function Ve(s,i){return s.isCollapsed===i.isCollapsed}const He=t.memo(_e,Ve);function Ge({path:s}){const{navigateTo:i}=R(),a=s==="/"?[]:s.split("/").filter(Boolean),n=[{name:"Home",path:"/"},...a.map((r,l)=>({name:r,path:"/"+a.slice(0,l+1).join("/")}))],o=t.useCallback(r=>{i(r)},[i]),c=t.useCallback((r,l)=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),i(l))},[i]);return e.jsx("nav",{"aria-label":"File navigation",className:"text-sm text-primary-600",children:e.jsx("ol",{className:"flex items-center gap-1",children:n.map((r,l)=>e.jsxs("li",{className:"flex items-center gap-1",children:[l>0?e.jsx(y,{icon:ke,size:16,strokeWidth:1.5,className:"text-primary-400","aria-hidden":"true"}):null,e.jsxs("button",{type:"button",onClick:()=>o(r.path),onKeyDown:p=>c(p,r.path),"aria-current":l===n.length-1?"page":void 0,className:f("flex items-center gap-1.5 rounded-md px-2 py-1","transition-colors duration-150 ease-out","hover:bg-primary-100 hover:text-primary-900","focus-visible:bg-primary-100 focus-visible:text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",l===n.length-1?"text-primary-900 font-medium":"text-primary-600"),children:[l===0?e.jsx(y,{icon:Ce,size:16,strokeWidth:1.5,"aria-hidden":"true"}):null,e.jsx("span",{className:"whitespace-nowrap",children:r.name})]})]},r.path))})})}const Z=[{label:"Name",value:"name"},{label:"Size",value:"size"},{label:"Modified",value:"modified"}];function Je({onUpload:s,onCreateFolder:i}){const{viewMode:a,sortBy:n,sortAsc:o,setViewMode:c,setSortBy:r,toggleSort:l}=R(),p=t.useCallback(()=>{c("list")},[c]),w=t.useCallback(()=>{c("grid")},[c]),v=t.useCallback(u=>{r(u)},[r]),h=t.useCallback((u,d)=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),d())},[]);return e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center border border-primary-200 rounded-lg overflow-hidden",role:"group","aria-label":"View mode",children:[e.jsx(D,{size:"sm",variant:a==="list"?"default":"ghost",onClick:p,onKeyDown:u=>h(u,p),"aria-label":"Switch to list view","aria-pressed":a==="list",className:f("rounded-none border-0","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:e.jsx(y,{icon:De,size:18,strokeWidth:1.5,"aria-hidden":"true"})}),e.jsx(D,{size:"sm",variant:a==="grid"?"default":"ghost",onClick:w,onKeyDown:u=>h(u,w),"aria-label":"Switch to grid view","aria-pressed":a==="grid",className:f("rounded-none border-0 border-l border-primary-200","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:e.jsx(y,{icon:Se,size:18,strokeWidth:1.5,"aria-hidden":"true"})})]}),e.jsxs(We,{children:[e.jsx(Ae,{render:e.jsxs(D,{variant:"ghost",size:"sm",className:f("gap-1","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":`Sort by ${Z.find(u=>u.value===n)?.label}, ${o?"ascending":"descending"}`,children:[e.jsxs("span",{children:["Sort: ",Z.find(u=>u.value===n)?.label]}),e.jsx(y,{icon:o?te:re,size:16,strokeWidth:1.5,"aria-hidden":"true"})]})}),e.jsxs(qe,{side:"bottom",align:"start",children:[Z.map(u=>e.jsx(le,{onClick:()=>v(u.value),className:f(n===u.value&&"bg-primary-100 text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),"aria-current":n===u.value?"true":"false",children:u.label},u.value)),e.jsxs(le,{onClick:l,className:"focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none",children:[e.jsx(y,{icon:o?re:te,size:16,strokeWidth:1.5,"aria-hidden":"true"}),o?"Sort Descending":"Sort Ascending"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(D,{variant:"ghost",size:"sm",onClick:s,onKeyDown:u=>h(u,s),className:f("gap-2","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Upload files",children:[e.jsx(y,{icon:ce,size:18,strokeWidth:1.5,"aria-hidden":"true"}),e.jsx("span",{children:"Upload"})]}),e.jsxs(D,{variant:"ghost",size:"sm",onClick:i,onKeyDown:u=>h(u,i),className:f("gap-2","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Create new folder",children:[e.jsx(y,{icon:Fe,size:18,strokeWidth:1.5,"aria-hidden":"true"}),e.jsx("span",{children:"New Folder"})]})]})]})}const E={all:["files"],listing:s=>["files","listing",s],content:s=>["files","content",s]};function Xe(s){return ie({queryKey:E.content(s||""),queryFn:async()=>{const i=await fetch(`/api/files/read?path=${encodeURIComponent(s)}`);if(!i.ok){const a=await i.json().catch(()=>({error:"Failed to read file"}));throw new Error(a.error||"Failed to read file")}return i.json()},enabled:!!s,staleTime:30*1e3,gcTime:300*1e3})}function Ye(){const s=L();return K({mutationFn:async({path:i,content:a})=>{const n=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:i,content:a})});if(!n.ok){const o=await n.json().catch(()=>({error:"Failed to save file"}));throw new Error(o.error||"Failed to save file")}return n.json()},onSuccess:(i,a)=>{s.invalidateQueries({queryKey:E.content(a.path)});const n=a.path.split("/").slice(0,-1).join("/")||"/";s.invalidateQueries({queryKey:E.listing(n)})}})}function Ze(s){return ie({queryKey:E.listing(s),queryFn:async()=>{const i=await fetch(`/api/files/list?path=${encodeURIComponent(s)}`);if(!i.ok){const a=await i.text();throw new Error(`Failed to load files: ${a}`)}return i.json()},staleTime:300*1e3,gcTime:600*1e3,retry:3,onError:i=>{console.error("Failed to load file listing:",i)}})}function ei(){const s=new Set;return t.useEffect(()=>()=>{s.forEach(i=>URL.revokeObjectURL(i)),s.clear()},[]),K({mutationFn:async i=>{const a=await fetch(`/api/files/download?path=${encodeURIComponent(i)}`);if(!a.ok){const l=await a.text();throw new Error(`Download failed: ${l}`)}const n=await a.blob(),o=window.URL.createObjectURL(n);s.add(o);const c=i.split("/").pop()||"download",r=document.createElement("a");r.href=o,r.download=c,document.body.appendChild(r),r.click(),document.body.removeChild(r),setTimeout(()=>{s.has(o)&&(URL.revokeObjectURL(o),s.delete(o))},100)},onError:i=>{console.error("Download failed:",i)}})}function ii(){const s=L();return K({mutationFn:async({files:i,path:a})=>{const n=[];for(let o=0;o<i.length;o++){const c=new FormData;c.append("path",a),c.append("file",i[o]);const r=await fetch("/api/files/upload",{method:"POST",body:c});if(!r.ok){const l=await r.text();throw new Error(`Upload failed for ${i[o].name}: ${l}`)}n.push(await r.json())}return n},onSuccess:(i,a)=>{s.invalidateQueries({queryKey:E.listing(a.path)})},onError:i=>{console.error("Upload failed:",i)}})}function si(){const s=L();return K({mutationFn:async i=>{const a=await fetch(`/api/files/delete?path=${encodeURIComponent(i)}`,{method:"DELETE"});if(!a.ok){const n=await a.text();throw new Error(`Delete failed: ${n}`)}return a.json()},onSuccess:(i,a)=>{const n=a.split("/").slice(0,-1).join("/")||"/";s.invalidateQueries({queryKey:E.listing(n)})},onError:i=>{console.error("Delete failed:",i)}})}function ai(){const s=L();return K({mutationFn:async({path:i,name:a})=>{const n=await fetch("/api/files/mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:`${i}/${a}`})});if(!n.ok){const o=await n.text();throw new Error(`Create folder failed: ${o}`)}return n.json()},onSuccess:(i,a)=>{s.invalidateQueries({queryKey:E.listing(a.path)})},onError:i=>{console.error("Create folder failed:",i)}})}function ni(){const s=L();return K({mutationFn:async({oldPath:i,newName:a})=>{const o=`${i.split("/").slice(0,-1).join("/")}/${a}`,c=await fetch("/api/files/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({src:i,dst:o})});if(!c.ok){const r=await c.text();throw new Error(`Rename failed: ${r}`)}return c.json()},onSuccess:(i,a)=>{const n=a.oldPath.split("/").slice(0,-1).join("/")||"/";s.invalidateQueries({queryKey:E.listing(n)})},onError:i=>{console.error("Rename failed:",i)}})}const ti=new Set(["txt","md","log","json","xml","yaml","yml","csv","ini","conf","cfg","js","ts","jsx","tsx","py","java","cpp","c","h","css","html","htm","php","rb","go","rs","sh","bash","zsh","toml","env","gitignore","dockerfile","makefile","sql","graphql","svelte","vue","scss","less"]);function me({item:s,children:i,onOpenFile:a}){const[n,o]=t.useState(!1),[c,r]=t.useState({x:0,y:0}),[l,p]=t.useState(!1),[w,v]=t.useState(!1),[h,u]=t.useState(s.name),[d,k]=t.useState(""),N=t.useRef(null),{navigateTo:j}=R(),m=ei(),x=si(),C=ni(),z=t.useCallback(b=>{switch(b){case"open":s.isDir&&j(s.path);break;case"edit":a&&a(s.path);break;case"download":s.isDir||m.mutate(s.path);break;case"rename":u(s.name),k(""),p(!0);break;case"delete":v(!0);break}},[s,m,j]),X=t.useCallback(b=>{b.preventDefault(),b.stopPropagation(),r({x:b.clientX,y:b.clientY}),o(!0)},[]),U=t.useCallback(async()=>{if(!h||h===s.name){p(!1);return}k("");try{await C.mutateAsync({oldPath:s.path,newName:h.trim()}),p(!1)}catch(b){const T=b instanceof Error?b.message:"Failed to rename";k(T)}},[h,s,C]),$=t.useCallback(async()=>{try{await x.mutateAsync(s.path),v(!1)}catch(b){console.error("Delete failed:",b)}},[s.path,x]),Y=t.useCallback(b=>{b.key==="Enter"?(b.preventDefault(),U()):b.key==="Escape"&&(b.preventDefault(),p(!1))},[U]),g=t.useCallback(b=>{u(b.target.value),d&&k("")},[d]);t.useEffect(()=>{if(l&&N.current){const b=N.current;if(b.focus(),!s.isDir&&s.extension){const T=s.name.replace(new RegExp(`\\.${s.extension}$`),"");b.setSelectionRange(0,T.length)}else b.select()}},[l,s]);const S=h.trim().length>0&&!/[<>:"/\\|?*]/.test(h)&&!h.includes("..")&&h!==s.name,M=()=>m.isPending?"Downloading…":"Download",he=()=>C.isPending?"Renaming…":"Rename",fe=()=>x.isPending?"Deleting…":"Delete";t.useEffect(()=>{if(!n)return;const b=()=>o(!1),T=ge=>{ge.key==="Escape"&&o(!1)},xe=setTimeout(()=>{document.addEventListener("click",b),document.addEventListener("contextmenu",b),document.addEventListener("keydown",T)},0);return()=>{clearTimeout(xe),document.removeEventListener("click",b),document.removeEventListener("contextmenu",b),document.removeEventListener("keydown",T)}},[n]);const P=t.useCallback(b=>{o(!1),z(b)},[z]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{onContextMenu:X,children:i}),n?e.jsx("div",{className:"fixed inset-0 z-50","aria-modal":"true",role:"dialog",children:e.jsxs("div",{className:"fixed min-w-[140px] rounded-lg bg-primary-50 p-1 text-sm text-primary-900 shadow-lg outline outline-primary-900/10 z-50",style:{left:c.x,top:c.y},role:"menu",onClick:b=>b.stopPropagation(),children:[s.isDir?e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>P("open"),className:f("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-primary-900","hover:bg-primary-100 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),children:[e.jsx(y,{icon:Ee,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Open"]}):null,s.isDir?null:e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>P("download"),disabled:m.isPending,className:f("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-primary-900","hover:bg-primary-100 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),children:[e.jsx(y,{icon:ze,size:16,strokeWidth:1.5,"aria-hidden":"true"}),M()]}),!s.isDir&&ti.has(s.extension.toLowerCase())?e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>P("edit"),className:f("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-primary-900","hover:bg-primary-100 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),children:[e.jsx(y,{icon:Me,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Edit"]}):null,e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>P("rename"),className:f("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-primary-900","hover:bg-primary-100 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),children:[e.jsx(y,{icon:Te,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Rename"]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>P("delete"),className:f("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm","text-red-600 hover:bg-red-50 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-red-300 focus-visible:outline-none"),children:[e.jsx(y,{icon:de,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Delete"]})]})}):null,e.jsx(Q,{open:l,onOpenChange:p,children:e.jsx(_,{children:e.jsxs("div",{className:"p-6",children:[e.jsxs(V,{className:"mb-2",children:["Rename ",s.isDir?"Folder":"File"]}),e.jsxs(H,{className:"mb-4",children:['Enter a new name for "',s.name,'"']}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("label",{htmlFor:"rename-input",className:"block text-sm font-medium text-primary-900 mb-2",children:[s.isDir?"Folder":"File"," Name"]}),e.jsx("input",{id:"rename-input",ref:N,type:"text",value:h,onChange:g,onKeyDown:Y,autoFocus:!0,spellCheck:!1,"aria-describedby":d?"rename-error":void 0,"aria-invalid":d?"true":"false",className:f("w-full px-3 py-2 border rounded-lg","transition-colors duration-150 ease-out","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",d?"border-red-300 focus-visible:ring-red-300":"border-primary-200 focus:border-primary-300")}),d?e.jsx("p",{id:"rename-error",className:"text-sm text-red-600 mt-1",role:"alert","aria-live":"polite",children:d}):null]}),C.isPending?e.jsx("div",{className:"mb-4 p-3 bg-primary-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-primary-600",children:"Renaming…"})}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{disabled:C.isPending,className:f("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(D,{onClick:U,disabled:!S||C.isPending,className:f("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",(!S||C.isPending)&&"opacity-50 cursor-not-allowed"),children:he()})]})]})})}),e.jsx(Q,{open:w,onOpenChange:v,children:e.jsx(_,{children:e.jsxs("div",{className:"p-6",children:[e.jsxs(V,{className:"mb-2",children:["Delete ",s.isDir?"Folder":"File"]}),e.jsxs(H,{className:"mb-4",children:['Are you sure you want to delete "',s.name,'"?',s.isDir?" This will delete the folder and all its contents.":""," ","This action cannot be undone."]}),x.isPending?e.jsx("div",{className:"mb-4 p-3 bg-red-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-red-700",children:"Deleting…"})}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{disabled:x.isPending,className:f("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(D,{variant:"destructive",onClick:$,disabled:x.isPending,className:f("focus-visible:ring-2 focus-visible:ring-red-300 focus-visible:outline-none","touch-manipulation",x.isPending&&"opacity-50 cursor-not-allowed"),children:fe()})]})]})})})]})}const ri=new Set(["txt","md","log","json","xml","yaml","yml","csv","ini","conf","cfg","js","ts","jsx","tsx","py","java","cpp","c","h","css","html","htm","php","rb","go","rs","sh","bash","zsh","toml","env","gitignore","dockerfile","makefile","sql","graphql","svelte","vue","scss","less"]);function J(s){if(s===0)return"0 B";const i=1024,a=["B","KB","MB","GB","TB"],n=Math.floor(Math.log(s)/Math.log(i));return parseFloat((s/Math.pow(i,n)).toFixed(1))+" "+a[n]}function O(s){const i=new Date(s),n=new Date().getTime()-i.getTime(),o=Math.floor(n/1e3),c=Math.floor(o/60),r=Math.floor(c/60),l=Math.floor(r/24);return l>7?i.toLocaleDateString():l>0?l===1?"yesterday":`${l} days ago`:r>0?r===1?"1 hour ago":`${r} hours ago`:c>0?c===1?"1 minute ago":`${c} minutes ago`:"just now"}function pe(s){if(s.isDir)return ue;const i=s.extension.toLowerCase();return["jpg","jpeg","png","gif","webp","svg","bmp"].includes(i)?Le:["mp4","avi","mkv","mov","wmv","flv","webm"].includes(i)?Re:["mp3","wav","flac","aac","ogg","m4a"].includes(i)?Ke:["zip","rar","7z","tar","gz","bz2"].includes(i)?Ue:["txt","md","log","json","xml","yaml","yml"].includes(i)?$e:["js","ts","jsx","tsx","py","java","cpp","c","h","css","html","php","rb","go","rs"].includes(i)?Pe:ee}function li(s,i,a){return t.useMemo(()=>[...s].sort((o,c)=>{if(o.isDir&&!c.isDir)return-1;if(!o.isDir&&c.isDir)return 1;let r=0;switch(i){case"name":r=o.name.localeCompare(c.name);break;case"size":r=o.size-c.size;break;case"modified":r=new Date(o.modified).getTime()-new Date(c.modified).getTime();break;default:r=o.name.localeCompare(c.name)}return a?r:-r}),[s,i,a])}function oi(){return t.useMemo(()=>typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function ci({viewMode:s}){const i=s==="grid"?12:8;return s==="grid"?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8 gap-3 p-4","aria-busy":"true","aria-label":"Loading files",children:Array.from({length:i},(a,n)=>e.jsxs("div",{className:"flex flex-col items-center p-3 rounded-lg",children:[e.jsx("div",{className:"w-12 h-12 bg-primary-200 rounded animate-pulse mb-2"}),e.jsx("div",{className:"w-16 h-4 bg-primary-200 rounded animate-pulse"})]},n))}):e.jsx("div",{className:"divide-y divide-primary-200","aria-busy":"true","aria-label":"Loading files",children:Array.from({length:i},(a,n)=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e.jsx("div",{className:"w-6 h-6 bg-primary-200 rounded animate-pulse"}),e.jsx("div",{className:"flex-1 min-w-0 h-4 bg-primary-200 rounded animate-pulse"}),e.jsx("div",{className:"w-16 h-4 bg-primary-200 rounded animate-pulse"}),e.jsx("div",{className:"w-20 h-4 bg-primary-200 rounded animate-pulse"})]},n))})}const di=t.memo(function({item:i,isSelected:a,onClick:n,onDoubleClick:o,onKeyDown:c,onOpenFile:r,reduceMotion:l}){const p=t.useCallback(()=>{n(i)},[n,i]),w=t.useCallback(()=>{o(i)},[o,i]),v=t.useCallback(d=>{c(d,i)},[c,i]),h=()=>i.isDir?`${i.name}, folder`:`${i.name}, ${i.extension} file, ${J(i.size)}, modified ${O(i.modified)}`,u=e.jsxs(F.button,{type:"button",whileHover:l?{}:{scale:1.02},whileTap:l?{}:{scale:.98},transition:{duration:l?0:.1},onClick:p,onDoubleClick:w,onKeyDown:v,"aria-label":h(),className:f("flex flex-col items-center p-3 rounded-lg w-full","transition-colors duration-150 ease-out","hover:bg-primary-100 focus-visible:bg-primary-100","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",a&&"bg-primary-200"),children:[e.jsx(y,{icon:pe(i),size:48,strokeWidth:1,className:f("mb-2",i.isDir?"text-blue-500":"text-primary-600"),"aria-hidden":"true"}),e.jsx("span",{className:"text-xs text-center text-primary-900 font-medium truncate w-full min-w-0",children:i.name}),i.isDir?null:e.jsx("span",{className:"text-xs text-primary-500 mt-1 tabular-nums",children:J(i.size)})]});return e.jsx(me,{item:i,onOpenFile:r,children:u})}),ui=t.memo(function({item:i,isSelected:a,onClick:n,onDoubleClick:o,onKeyDown:c,onOpenFile:r,reduceMotion:l}){const p=t.useCallback(()=>{n(i)},[n,i]),w=t.useCallback(()=>{o(i)},[o,i]),v=t.useCallback(d=>{c(d,i)},[c,i]),h=()=>i.isDir?`${i.name}, folder, modified ${O(i.modified)}`:`${i.name}, ${i.extension} file, ${J(i.size)}, modified ${O(i.modified)}`,u=e.jsxs(F.button,{type:"button",whileHover:l?{}:{backgroundColor:"rgb(248 250 252)"},transition:{duration:l?0:.1},onClick:p,onDoubleClick:w,onKeyDown:v,"aria-label":h(),className:f("w-full grid grid-cols-[auto_1fr_auto_auto] gap-4 px-4 py-3 text-left","transition-colors duration-150 ease-out","hover:bg-primary-100 focus-visible:bg-primary-100","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",a&&"bg-primary-200"),children:[e.jsx(y,{icon:pe(i),size:20,strokeWidth:1.5,className:f("mt-0.5 shrink-0",i.isDir?"text-blue-500":"text-primary-600"),"aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("span",{className:"text-primary-900 font-medium truncate block",children:i.name})}),e.jsx("div",{className:"text-sm text-primary-600 text-right w-16 tabular-nums shrink-0",children:i.isDir?"—":J(i.size)}),e.jsx("div",{className:"text-sm text-primary-600 text-right w-20 tabular-nums shrink-0",children:O(i.modified)})]});return e.jsx(me,{item:i,onOpenFile:r,children:u})}),mi=e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(y,{icon:ue,size:48,strokeWidth:1,className:"mx-auto text-primary-400 mb-3","aria-hidden":"true"}),e.jsx("p",{className:"text-primary-600 font-medium",children:"This folder is empty"}),e.jsx("p",{className:"text-sm text-primary-500 mt-1",children:"Upload files or create a new folder to get started"})]})});function pi({listing:s,loading:i,onOpenFile:a}){const{viewMode:n,sortBy:o,sortAsc:c,selectedFiles:r,navigateTo:l,toggleFileSelection:p}=R(),[w,v]=t.useState(0),h=t.useRef(null),u=oi(),d=li(s?.items||[],o,c),k=t.useCallback(m=>{p(m.path)},[p]),N=t.useCallback(m=>{m.isDir?l(m.path):a&&ri.has(m.extension.toLowerCase())&&a(m.path)},[l,a]),j=t.useCallback((m,x)=>{m.key==="Enter"?(m.preventDefault(),x.isDir?l(x.path):p(x.path)):m.key===" "&&(m.preventDefault(),p(x.path))},[l,p]);return t.useEffect(()=>{const m=x=>{if(d.length)switch(x.key){case"ArrowDown":x.preventDefault(),v(C=>Math.min(C+1,d.length-1));break;case"ArrowUp":x.preventDefault(),v(C=>Math.max(C-1,0));break;case"Home":x.preventDefault(),v(0);break;case"End":x.preventDefault(),v(d.length-1);break}};if(h.current)return h.current.addEventListener("keydown",m),()=>{h.current?.removeEventListener("keydown",m)}},[d.length]),i?e.jsx(ci,{viewMode:n}):s?d.length===0?mi:n==="grid"?e.jsx("div",{ref:h,className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8 gap-3 p-4 overflow-y-auto",role:"grid","aria-label":"Files grid",tabIndex:0,children:d.map((m,x)=>e.jsx("div",{role:"gridcell",children:e.jsx(di,{item:m,isSelected:r.has(m.path),onClick:k,onDoubleClick:N,onKeyDown:j,onOpenFile:a,reduceMotion:u})},m.path))}):e.jsx("div",{ref:h,className:"overflow-y-auto",role:"table","aria-label":"Files list",tabIndex:0,children:e.jsxs("div",{className:"divide-y divide-primary-200",children:[e.jsxs("div",{className:"grid grid-cols-[auto_1fr_auto_auto] gap-4 px-4 py-2 text-sm font-medium text-primary-600 bg-primary-50",role:"row",children:[e.jsx("div",{className:"w-6",role:"columnheader","aria-label":"File type"}),e.jsx("div",{role:"columnheader",children:"Name"}),e.jsx("div",{className:"w-16 text-right tabular-nums",role:"columnheader",children:"Size"}),e.jsx("div",{className:"w-20 text-right tabular-nums",role:"columnheader",children:"Modified"})]}),d.map((m,x)=>e.jsx("div",{role:"row",children:e.jsx(ui,{item:m,isSelected:r.has(m.path),onClick:k,onDoubleClick:N,onKeyDown:j,onOpenFile:a,reduceMotion:u})},m.path))]})}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("p",{className:"text-primary-500",children:"No listing available"})})}function oe(s){if(s===0)return"0 B";const i=1024,a=["B","KB","MB","GB"],n=Math.floor(Math.log(s)/Math.log(i));return parseFloat((s/Math.pow(i,n)).toFixed(1))+" "+a[n]}function hi({open:s,onOpenChange:i,currentPath:a}){const[n,o]=t.useState([]),[c,r]=t.useState(!1),[l,p]=t.useState("idle"),w=t.useRef(null),v=ii(),h=t.useCallback(()=>{o([]),p("idle"),w.current&&(w.current.value="")},[]),u=t.useCallback(g=>{if(!g)return;const S=Array.from(g).map(M=>({file:M,id:Math.random().toString(36).substr(2,9)}));o(M=>[...M,...S])},[]),d=t.useCallback(g=>{u(g.target.files)},[u]),k=t.useCallback(g=>{g.preventDefault(),r(!1),u(g.dataTransfer.files)},[u]),N=t.useCallback(g=>{g.preventDefault(),r(!0)},[]),j=t.useCallback(g=>{g.preventDefault(),r(!1)},[]),m=t.useCallback(g=>{o(S=>S.filter(M=>M.id!==g))},[]),x=t.useCallback(()=>{w.current?.click()},[]),C=t.useCallback(g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),x())},[x]),z=t.useCallback(async()=>{if(n.length===0)return;const g=new DataTransfer;n.forEach(({file:S})=>{g.items.add(S)}),p("uploading");try{await v.mutateAsync({files:g.files,path:a}),p("success"),h(),i(!1)}catch(S){p("error"),console.error("Upload failed:",S)}},[n,a,v,h,i]),X=t.useCallback(g=>{g||h(),i(g)},[h,i]),U=n.reduce((g,{file:S})=>g+S.size,0),$=n.length,Y=()=>v.isPending||l==="uploading"?"Uploading…":$===0?"Upload":$===1?"Upload 1 File":`Upload ${$} Files`;return e.jsx(Q,{open:s,onOpenChange:X,children:e.jsx(_,{className:"w-[min(500px,92vw)]",children:e.jsxs("div",{className:"p-6",children:[e.jsx(V,{className:"mb-2",children:"Upload Files"}),e.jsxs(H,{className:"mb-6",children:["Upload files to ",a==="/"?"root directory":a]}),e.jsxs("div",{onDrop:k,onDragOver:N,onDragLeave:j,onClick:x,onKeyDown:C,tabIndex:0,role:"button","aria-label":"Drop files here or click to choose files",className:f("border-2 border-dashed rounded-lg p-8 text-center cursor-pointer","transition-colors duration-150 ease-out","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",c?"border-primary-400 bg-primary-50":"border-primary-200 hover:border-primary-300 hover:bg-primary-50"),children:[e.jsx(y,{icon:ce,size:48,strokeWidth:1,className:"mx-auto text-primary-400 mb-4","aria-hidden":"true"}),e.jsx("p",{className:"text-primary-600 font-medium mb-2",children:"Drag and drop files here"}),e.jsx("p",{className:"text-sm text-primary-500 mb-4",children:"or"}),e.jsxs(D,{variant:"outline",className:f("gap-2","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Choose files from computer",children:[e.jsx(y,{icon:ee,size:18,strokeWidth:1.5,"aria-hidden":"true"}),e.jsx("span",{children:"Choose Files"})]}),e.jsx("input",{ref:w,type:"file",multiple:!0,onChange:d,className:"hidden","aria-hidden":"true"})]}),e.jsx(I,{children:n.length>0?e.jsxs(F.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mt-6",children:[e.jsxs("h4",{className:"text-sm font-medium text-primary-900 mb-3",children:["Selected Files (",n.length,")"]}),e.jsx("div",{className:"max-h-32 overflow-y-auto border border-primary-200 rounded-lg",children:n.map(({file:g,id:S})=>e.jsxs(F.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},exit:{opacity:0,x:10},className:"flex items-center justify-between p-2 border-b border-primary-100 last:border-b-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(y,{icon:ee,size:16,strokeWidth:1.5,className:"text-primary-600 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"text-sm text-primary-900 truncate min-w-0",children:g.name}),e.jsx("span",{className:"text-xs text-primary-500 shrink-0 tabular-nums",children:oe(g.size)})]}),e.jsx(D,{size:"icon-sm",variant:"ghost",onClick:()=>m(S),className:f("text-primary-500 hover:text-red-600 shrink-0","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":`Remove ${g.name} from upload list`,children:e.jsx(y,{icon:de,size:14,strokeWidth:1.5,"aria-hidden":"true"})})]},S))}),e.jsxs("p",{className:"text-xs text-primary-600 mt-2 tabular-nums",children:["Total size: ",oe(U)]})]}):null}),v.isPending||l==="uploading"?e.jsxs(F.div,{initial:{opacity:0},animate:{opacity:1},className:"mt-4 p-3 bg-primary-50 rounded-lg","aria-live":"polite",children:[e.jsx("p",{className:"text-sm text-primary-600 mb-2",children:"Uploading files…"}),e.jsx("div",{className:"bg-primary-200 rounded-full h-2",role:"progressbar","aria-label":"Upload progress",children:e.jsx("div",{className:"bg-primary-600 h-2 rounded-full w-1/2 animate-pulse"})})]}):null,l==="success"?e.jsx("div",{className:"mt-4 p-3 bg-green-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-green-700",children:"Files uploaded successfully!"})}):null,l==="error"?e.jsx("div",{className:"mt-4 p-3 bg-red-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-red-700",children:"Upload failed. Please try again."})}):null,e.jsxs("div",{className:"flex justify-end gap-2 mt-6",children:[e.jsx(G,{disabled:v.isPending||l==="uploading",className:f("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(D,{onClick:z,disabled:n.length===0||v.isPending||l==="uploading",className:f("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:Y()})]})]})})})}function fi({open:s,onOpenChange:i,currentPath:a}){const[n,o]=t.useState(""),[c,r]=t.useState(""),l=ai(),p=t.useCallback(async()=>{if(n.trim()){r("");try{await l.mutateAsync({path:a,name:n.trim()}),o(""),i(!1)}catch(m){const x=m instanceof Error?m.message:"Failed to create folder";r(x),console.error("Create folder failed:",m)}}},[n,a,l,i]),w=t.useCallback(m=>{m||(o(""),r("")),i(m)},[i]),v=t.useCallback(m=>{m.key==="Enter"&&(m.preventDefault(),p())},[p]),h=t.useCallback(m=>{const x=m.target.value;o(x),c&&r("")},[c]),u=n.trim().length>0&&!/[<>:"/\\|?*]/.test(n)&&!n.includes(".."),d=()=>l.isPending?"Creating…":"Create Folder",N=n.trim()?n.includes("..")?'Folder name cannot contain ".."':/[<>:"/\\|?*]/.test(n)?'Invalid characters: < > : " / \\ | ? *':"":"",j=c||N;return e.jsx(Q,{open:s,onOpenChange:w,children:e.jsx(_,{children:e.jsxs("div",{className:"p-6",children:[e.jsx(V,{className:"mb-2",children:"Create New Folder"}),e.jsxs(H,{className:"mb-4",children:["Create a new folder in ",a==="/"?"root directory":a]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{htmlFor:"folder-name",className:"block text-sm font-medium text-primary-900 mb-2",children:"Folder Name"}),e.jsx("input",{id:"folder-name",type:"text",value:n,onChange:h,onKeyDown:v,placeholder:"Enter folder name",autoComplete:"off",spellCheck:!1,autoFocus:!0,"aria-describedby":j?"folder-name-error":void 0,"aria-invalid":j?"true":"false",className:f("w-full px-3 py-2 border rounded-lg","transition-colors duration-150 ease-out","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",j?"border-red-300 focus-visible:ring-red-300":"border-primary-200 focus:border-primary-300")}),j?e.jsx("p",{id:"folder-name-error",className:"text-sm text-red-600 mt-1",role:"alert","aria-live":"polite",children:c||N}):null]}),l.isPending?e.jsx("div",{className:"mb-4 p-3 bg-primary-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-primary-600",children:"Creating folder…"})}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{disabled:l.isPending,className:f("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(D,{onClick:p,disabled:!u||l.isPending,className:f("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",(!u||l.isPending)&&"opacity-50 cursor-not-allowed"),"aria-describedby":u?void 0:"create-button-help",children:d()})]}),!u&&n.length>0?e.jsx("p",{id:"create-button-help",className:"text-xs text-primary-500 mt-2",children:"Please enter a valid folder name"}):null]})})})}const xi={js:"JavaScript",ts:"TypeScript",jsx:"JSX",tsx:"TSX",py:"Python",json:"JSON",yaml:"YAML",yml:"YAML",md:"Markdown",html:"HTML",css:"CSS",scss:"SCSS",sh:"Shell",bash:"Bash",sql:"SQL",xml:"XML",toml:"TOML",ini:"INI",conf:"Config",cfg:"Config",env:"Env",txt:"Text",log:"Log",csv:"CSV",go:"Go",rs:"Rust",rb:"Ruby",php:"PHP",java:"Java",c:"C",cpp:"C++",h:"Header",dockerfile:"Dockerfile",makefile:"Makefile",graphql:"GraphQL",svelte:"Svelte",vue:"Vue"};function gi({filePath:s,onClose:i}){const a=Xe(s),n=Ye(),o=t.useRef(null),[c,r]=t.useState(null),[l,p]=t.useState(!1);t.useEffect(()=>{a.data&&c===null&&r(a.data.content)},[a.data,c]);const w=t.useMemo(()=>a.data?xi[a.data.extension.toLowerCase()]||a.data.extension.toUpperCase():"",[a.data]),v=t.useCallback(N=>{r(N.target.value),p(N.target.value!==a.data?.content)},[a.data]),h=t.useCallback(async()=>{if(c!==null)try{await n.mutateAsync({path:s,content:c}),p(!1)}catch{}},[s,c,n]),u=t.useCallback(()=>{l&&!window.confirm("You have unsaved changes. Discard them?")||i()},[l,i]);t.useEffect(()=>{const N=j=>{(j.ctrlKey||j.metaKey)&&j.key==="s"&&(j.preventDefault(),l&&h()),j.key==="Escape"&&u()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[h,u,l]);const d=t.useCallback(N=>{if(N.key==="Tab"){N.preventDefault();const j=N.currentTarget,m=j.selectionStart,x=j.selectionEnd,C=j.value,z=C.substring(0,m)+" "+C.substring(x);r(z),p(z!==a.data?.content),requestAnimationFrame(()=>{j.selectionStart=j.selectionEnd=m+2})}},[a.data]),k=s.split("/").pop()||s;return e.jsxs("div",{className:"fixed inset-0 z-50 bg-surface flex flex-col",children:[e.jsxs("header",{className:"flex items-center justify-between px-4 py-2 border-b border-primary-200 bg-primary-50",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("h2",{className:"text-sm font-semibold text-primary-900 truncate",children:k}),w?e.jsx("span",{className:"text-xs text-primary-500 bg-primary-100 px-2 py-0.5 rounded-full shrink-0",children:w}):null,l?e.jsx("span",{className:"text-xs text-amber-600 bg-amber-50 px-2 py-0.5 rounded-full shrink-0",children:"Unsaved"}):null,n.isError?e.jsx("span",{className:"text-xs text-red-600",children:n.error.message}):null]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(D,{size:"sm",variant:"default",onClick:h,disabled:!l||n.isPending,className:f((!l||n.isPending)&&"opacity-50 cursor-not-allowed"),children:[e.jsx(y,{icon:Ie,size:16,strokeWidth:1.5,"aria-hidden":"true"}),n.isPending?"Saving…":"Save"]}),e.jsx(D,{size:"icon-sm",variant:"ghost",onClick:u,"aria-label":"Close editor",children:e.jsx(y,{icon:Be,size:20,strokeWidth:1.5,"aria-hidden":"true"})})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:a.isLoading?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("p",{className:"text-primary-500 text-sm",children:"Loading file…"})}):a.isError?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-red-600 text-sm mb-2",children:a.error instanceof Error?a.error.message:"Failed to load file"}),e.jsx(D,{size:"sm",variant:"secondary",onClick:()=>{a.refetch()},children:"Retry"})]})}):e.jsx("textarea",{ref:o,value:c??"",onChange:v,onKeyDown:d,spellCheck:!1,autoFocus:!0,className:f("w-full h-full p-4 resize-none","bg-primary-950 text-primary-100","font-mono text-sm leading-relaxed","focus:outline-none","selection:bg-blue-800/50")})}),a.data?e.jsxs("footer",{className:"flex items-center justify-between px-4 py-1 border-t border-primary-200 bg-primary-50 text-xs text-primary-500",children:[e.jsx("span",{children:s}),e.jsx("span",{children:bi(a.data.size)})]}):null]})}function bi(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function ki(){const s=L(),{currentPath:i}=R(),[a,n]=t.useState(!1),[o,c]=t.useState(!1),[r,l]=t.useState(null),p=Ze(i),v=ie({queryKey:ve,queryFn:function(){return ae(s)},initialData:function(){return ae(s)},staleTime:1/0}).data?.isSidebarCollapsed??!1,h=t.useCallback(()=>{be(s,function(C){return{...C,isSidebarCollapsed:!C.isSidebarCollapsed}})},[s]),u=t.useCallback(()=>{n(!0)},[]),d=t.useCallback(()=>{c(!0)},[]),k=t.useCallback(x=>{l(x)},[]),N=t.useCallback(()=>{l(null)},[]),j=t.useMemo(()=>({display:"flex",flexDirection:"column",height:"100%",minHeight:0}),[]),m=e.jsx(He,{isCollapsed:v,onToggleCollapse:h,onSelectAction:()=>{}});return e.jsxs("div",{className:"h-screen bg-surface text-primary-900",children:[e.jsxs("div",{className:f("h-full overflow-hidden grid grid-cols-[auto_1fr]"),children:[m,e.jsxs("main",{"aria-label":"File explorer",style:j,children:[e.jsxs("header",{className:"border-b border-primary-200 px-4 py-3",children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsx(Ge,{path:i})}),e.jsx(Je,{onUpload:u,onCreateFolder:d})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto",children:[e.jsx(pi,{listing:p.data,loading:p.isLoading,onOpenFile:k}),p.isError?e.jsxs("div",{className:"p-4 text-center","aria-live":"polite",children:[e.jsx("p",{className:"text-red-600 text-sm",children:p.error instanceof Error?p.error.message:"Failed to load files"}),e.jsx("button",{onClick:()=>{p.refetch()},className:"mt-2 text-sm text-primary-600 hover:text-primary-900 underline focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none rounded-sm",children:"Retry"})]}):null]}),e.jsx(hi,{open:a,onOpenChange:n,currentPath:i}),e.jsx(fi,{open:o,onOpenChange:c,currentPath:i})]})]}),r?e.jsx(gi,{filePath:r,onClose:N}):null]})}export{ki as FileExplorerScreen};
1
+ import{j as e,r as t,L as se,u as L}from"./main-BlX7CS2-.js";import{p as F,q as I,r as B,s as W,v as A,w as q,x as ie,y as be,z as ve,B as ae}from"./useButton-DhneLsMA.js";import{y as ye,c as f,j as ne,B as D,H as y,I as je,z as we,m as Ne,l as ke,C as Ce,n as De,E as Se,F as te,p as re,G as ce,K as Fe,L as Ee,N as ze,U as Me,O as Te,R as de,P as ue,Y as Le,Z as Re,_ as Ke,$ as Ue,a0 as $e,a1 as Pe,S as ee,a2 as Ie,V as Be}from"./button-BcnCTjUT.js";import{r as R,M as We,n as Ae,o as qe,p as le,q as K,D as Q,a as _,b as V,c as H,d as G}from"./use-file-explorer-state-C6lX-h0n.js";import"./react-ONC2UaeC.js";function Oe({className:s}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"80",height:"80",viewBox:"0 0 80 80",fill:"none",className:s,children:[e.jsx("rect",{width:"80",height:"80",fill:"currentColor",className:"text-transparent"}),e.jsx("path",{d:"M61.9624 45.5729C62.5862 44.3371 63.0907 43.3377 63.4782 41.9826C69.8221 28.8286 70.5847 14.0975 67.1723 4.32469C65.8317 0.249835 62.7688 0.254311 62.6374 3.58605C61.355 12.189 58.9061 17.6275 57.1756 21.0554C52.8087 29.7058 45.9949 37.7278 39.3706 42.7305C28.6217 50.8021 25.0716 44.614 24.3711 37.8823C23.8822 32.1203 24.7206 25.5721 26.24 18.2889C27.102 15.3261 24.3944 13.9592 22.5223 16.4122C20.4062 19.3487 18.5586 22.4209 17.1838 25.7318C12.9928 33.4462 10.3896 45.3332 11.4505 57.6273C12.2296 63.5357 13.1688 68.4057 14.1079 73.2757C15.2695 79.0941 19.1598 79.5073 24.3117 78.0088C39.7921 74.0789 54.143 58.872 59.7093 49.1011C60.7255 48.0229 61.3494 46.7872 61.9624 45.5729Z",fill:"currentColor",className:"text-primary-950"})]})}function Qe(){return t.useMemo(()=>typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function _e({isCollapsed:s,onToggleCollapse:i,onSelectAction:a}){const{navigateTo:n,currentPath:o}=R(),c=Qe(),r=t.useMemo(()=>({duration:c?0:.15,ease:s?"easeIn":"easeOut"}),[s,c]),l=t.useCallback(d=>{n(d)},[n]),p=t.useCallback((d,k)=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),k())},[]),w=t.useMemo(()=>[{path:"/",icon:ye,label:"Home",id:"home"}],[]),v=t.useMemo(()=>({className:"border-r border-primary-200 h-full overflow-hidden bg-primary-100 flex flex-col"}),[]),h=48,u=300;return e.jsxs(F.aside,{initial:!1,animate:{width:c?s?h:u:void 0},style:{width:c?void 0:s?h:u},transition:r,className:v.className,role:"navigation","aria-label":"File explorer navigation",children:[e.jsxs(F.div,{layout:!0,transition:{layout:r},className:f("flex items-center h-12 px-2 justify-between"),children:[e.jsx(I,{initial:!1,children:s?null:e.jsx(F.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:r,children:e.jsxs(se,{to:"/new",className:f(ne({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:[e.jsx(Oe,{className:"size-5 rounded-sm","aria-hidden":"true"}),e.jsx("span",{children:"WebClaw"})]})})}),e.jsx(B,{children:e.jsxs(W,{children:[e.jsx(A,{onClick:i,onKeyDown:d=>p(d,i),render:e.jsx(D,{size:"icon-sm",variant:"ghost","aria-label":s?"Expand sidebar":"Collapse sidebar",className:f("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:e.jsx(y,{icon:je,size:20,strokeWidth:1.5,"aria-hidden":"true"})})}),e.jsx(q,{side:"right",children:s?"Expand sidebar":"Collapse sidebar"})]})})]}),e.jsx("div",{className:"px-2 mb-4",children:e.jsx(F.div,{layout:!0,transition:{layout:r},className:"w-full",children:e.jsx(B,{children:e.jsxs(W,{children:[e.jsx(A,{asChild:!0,children:e.jsxs(se,{to:"/chat/$sessionKey",params:{sessionKey:"main"},className:f(ne({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),onClick:a,children:[e.jsx(y,{icon:we,size:20,strokeWidth:1.5,className:"min-w-5","aria-hidden":"true"}),e.jsx(I,{initial:!1,mode:"wait",children:s?null:e.jsx(F.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:r,className:"overflow-hidden whitespace-nowrap",children:"Back to Chat"})})]})}),s?e.jsx(q,{side:"right",children:"Back to Chat"}):null]})})})}),e.jsx("div",{className:"flex-1 min-h-0 relative overflow-hidden",children:e.jsx(I,{initial:!1,children:s?e.jsx(F.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:r,className:"px-2 space-y-1",children:w.map(d=>e.jsx(B,{children:e.jsxs(W,{children:[e.jsx(A,{onClick:()=>l(d.path),onKeyDown:k=>p(k,()=>l(d.path)),render:e.jsx(D,{size:"icon-sm",variant:"ghost","aria-current":o===d.path?"page":void 0,"aria-label":`Navigate to ${d.label}`,className:f("w-full text-primary-600 hover:text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",o===d.path&&"bg-primary-200 text-primary-900"),children:e.jsx(y,{icon:d.icon,size:20,strokeWidth:1.5,"aria-hidden":"true"})})}),e.jsx(q,{side:"right",children:d.label})]})},d.id))},"collapsed-content"):e.jsx(F.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:r,className:"absolute inset-0 pt-0 flex flex-col w-[300px] min-h-0",children:e.jsxs("div",{className:"flex-1 min-h-0 px-2",children:[e.jsx("div",{className:"mb-4",children:e.jsx("h2",{className:"text-sm font-medium text-primary-700 mb-3 px-1.5",children:"Quick Access"})}),e.jsx("nav",{className:"space-y-1",role:"list","aria-label":"Quick access folders",children:w.map(d=>e.jsx("div",{role:"listitem",children:e.jsxs(D,{variant:"ghost",size:"sm",onClick:()=>l(d.path),onKeyDown:k=>p(k,()=>l(d.path)),"aria-current":o===d.path?"page":void 0,className:f("w-full pl-1.5 justify-start text-primary-600 hover:text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",o===d.path&&"bg-primary-200 text-primary-900 font-medium"),"aria-label":`Navigate to ${d.label}`,children:[e.jsx(y,{icon:d.icon,size:20,strokeWidth:1.5,className:"min-w-5","aria-hidden":"true"}),e.jsx("span",{className:"overflow-hidden whitespace-nowrap min-w-0 truncate",children:d.label})]})},d.id))})]})},"content")})}),e.jsx("div",{className:"px-2 py-3 border-t border-primary-200 bg-primary-100",children:e.jsx(F.div,{layout:!0,transition:{layout:r},className:"w-full",children:e.jsx(B,{children:e.jsxs(W,{children:[e.jsx(A,{asChild:!0,children:e.jsxs(D,{variant:"ghost",size:s?"icon-sm":"sm",className:f(s?"w-full":"w-full justify-start pl-1.5","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Settings",children:[e.jsx(y,{icon:Ne,size:20,strokeWidth:1.5,className:"min-w-5","aria-hidden":"true"}),e.jsx(I,{initial:!1,mode:"wait",children:s?null:e.jsx(F.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:r,className:"overflow-hidden whitespace-nowrap",children:"Settings"})})]})}),s?e.jsx(q,{side:"right",children:"Settings"}):null]})})})})]})}function Ve(s,i){return s.isCollapsed===i.isCollapsed}const He=t.memo(_e,Ve);function Ge({path:s}){const{navigateTo:i}=R(),a=s==="/"?[]:s.split("/").filter(Boolean),n=[{name:"Home",path:"/"},...a.map((r,l)=>({name:r,path:"/"+a.slice(0,l+1).join("/")}))],o=t.useCallback(r=>{i(r)},[i]),c=t.useCallback((r,l)=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),i(l))},[i]);return e.jsx("nav",{"aria-label":"File navigation",className:"text-sm text-primary-600",children:e.jsx("ol",{className:"flex items-center gap-1",children:n.map((r,l)=>e.jsxs("li",{className:"flex items-center gap-1",children:[l>0?e.jsx(y,{icon:ke,size:16,strokeWidth:1.5,className:"text-primary-400","aria-hidden":"true"}):null,e.jsxs("button",{type:"button",onClick:()=>o(r.path),onKeyDown:p=>c(p,r.path),"aria-current":l===n.length-1?"page":void 0,className:f("flex items-center gap-1.5 rounded-md px-2 py-1","transition-colors duration-150 ease-out","hover:bg-primary-100 hover:text-primary-900","focus-visible:bg-primary-100 focus-visible:text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",l===n.length-1?"text-primary-900 font-medium":"text-primary-600"),children:[l===0?e.jsx(y,{icon:Ce,size:16,strokeWidth:1.5,"aria-hidden":"true"}):null,e.jsx("span",{className:"whitespace-nowrap",children:r.name})]})]},r.path))})})}const Z=[{label:"Name",value:"name"},{label:"Size",value:"size"},{label:"Modified",value:"modified"}];function Je({onUpload:s,onCreateFolder:i}){const{viewMode:a,sortBy:n,sortAsc:o,setViewMode:c,setSortBy:r,toggleSort:l}=R(),p=t.useCallback(()=>{c("list")},[c]),w=t.useCallback(()=>{c("grid")},[c]),v=t.useCallback(u=>{r(u)},[r]),h=t.useCallback((u,d)=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),d())},[]);return e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center border border-primary-200 rounded-lg overflow-hidden",role:"group","aria-label":"View mode",children:[e.jsx(D,{size:"sm",variant:a==="list"?"default":"ghost",onClick:p,onKeyDown:u=>h(u,p),"aria-label":"Switch to list view","aria-pressed":a==="list",className:f("rounded-none border-0","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:e.jsx(y,{icon:De,size:18,strokeWidth:1.5,"aria-hidden":"true"})}),e.jsx(D,{size:"sm",variant:a==="grid"?"default":"ghost",onClick:w,onKeyDown:u=>h(u,w),"aria-label":"Switch to grid view","aria-pressed":a==="grid",className:f("rounded-none border-0 border-l border-primary-200","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:e.jsx(y,{icon:Se,size:18,strokeWidth:1.5,"aria-hidden":"true"})})]}),e.jsxs(We,{children:[e.jsx(Ae,{render:e.jsxs(D,{variant:"ghost",size:"sm",className:f("gap-1","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":`Sort by ${Z.find(u=>u.value===n)?.label}, ${o?"ascending":"descending"}`,children:[e.jsxs("span",{children:["Sort: ",Z.find(u=>u.value===n)?.label]}),e.jsx(y,{icon:o?te:re,size:16,strokeWidth:1.5,"aria-hidden":"true"})]})}),e.jsxs(qe,{side:"bottom",align:"start",children:[Z.map(u=>e.jsx(le,{onClick:()=>v(u.value),className:f(n===u.value&&"bg-primary-100 text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),"aria-current":n===u.value?"true":"false",children:u.label},u.value)),e.jsxs(le,{onClick:l,className:"focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none",children:[e.jsx(y,{icon:o?re:te,size:16,strokeWidth:1.5,"aria-hidden":"true"}),o?"Sort Descending":"Sort Ascending"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(D,{variant:"ghost",size:"sm",onClick:s,onKeyDown:u=>h(u,s),className:f("gap-2","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Upload files",children:[e.jsx(y,{icon:ce,size:18,strokeWidth:1.5,"aria-hidden":"true"}),e.jsx("span",{children:"Upload"})]}),e.jsxs(D,{variant:"ghost",size:"sm",onClick:i,onKeyDown:u=>h(u,i),className:f("gap-2","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Create new folder",children:[e.jsx(y,{icon:Fe,size:18,strokeWidth:1.5,"aria-hidden":"true"}),e.jsx("span",{children:"New Folder"})]})]})]})}const E={all:["files"],listing:s=>["files","listing",s],content:s=>["files","content",s]};function Xe(s){return ie({queryKey:E.content(s||""),queryFn:async()=>{const i=await fetch(`/api/files/read?path=${encodeURIComponent(s)}`);if(!i.ok){const a=await i.json().catch(()=>({error:"Failed to read file"}));throw new Error(a.error||"Failed to read file")}return i.json()},enabled:!!s,staleTime:30*1e3,gcTime:300*1e3})}function Ye(){const s=L();return K({mutationFn:async({path:i,content:a})=>{const n=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:i,content:a})});if(!n.ok){const o=await n.json().catch(()=>({error:"Failed to save file"}));throw new Error(o.error||"Failed to save file")}return n.json()},onSuccess:(i,a)=>{s.invalidateQueries({queryKey:E.content(a.path)});const n=a.path.split("/").slice(0,-1).join("/")||"/";s.invalidateQueries({queryKey:E.listing(n)})}})}function Ze(s){return ie({queryKey:E.listing(s),queryFn:async()=>{const i=await fetch(`/api/files/list?path=${encodeURIComponent(s)}`);if(!i.ok){const a=await i.text();throw new Error(`Failed to load files: ${a}`)}return i.json()},staleTime:300*1e3,gcTime:600*1e3,retry:3,onError:i=>{console.error("Failed to load file listing:",i)}})}function ei(){const s=new Set;return t.useEffect(()=>()=>{s.forEach(i=>URL.revokeObjectURL(i)),s.clear()},[]),K({mutationFn:async i=>{const a=await fetch(`/api/files/download?path=${encodeURIComponent(i)}`);if(!a.ok){const l=await a.text();throw new Error(`Download failed: ${l}`)}const n=await a.blob(),o=window.URL.createObjectURL(n);s.add(o);const c=i.split("/").pop()||"download",r=document.createElement("a");r.href=o,r.download=c,document.body.appendChild(r),r.click(),document.body.removeChild(r),setTimeout(()=>{s.has(o)&&(URL.revokeObjectURL(o),s.delete(o))},100)},onError:i=>{console.error("Download failed:",i)}})}function ii(){const s=L();return K({mutationFn:async({files:i,path:a})=>{const n=[];for(let o=0;o<i.length;o++){const c=new FormData;c.append("path",a),c.append("file",i[o]);const r=await fetch("/api/files/upload",{method:"POST",body:c});if(!r.ok){const l=await r.text();throw new Error(`Upload failed for ${i[o].name}: ${l}`)}n.push(await r.json())}return n},onSuccess:(i,a)=>{s.invalidateQueries({queryKey:E.listing(a.path)})},onError:i=>{console.error("Upload failed:",i)}})}function si(){const s=L();return K({mutationFn:async i=>{const a=await fetch(`/api/files/delete?path=${encodeURIComponent(i)}`,{method:"DELETE"});if(!a.ok){const n=await a.text();throw new Error(`Delete failed: ${n}`)}return a.json()},onSuccess:(i,a)=>{const n=a.split("/").slice(0,-1).join("/")||"/";s.invalidateQueries({queryKey:E.listing(n)})},onError:i=>{console.error("Delete failed:",i)}})}function ai(){const s=L();return K({mutationFn:async({path:i,name:a})=>{const n=await fetch("/api/files/mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:`${i}/${a}`})});if(!n.ok){const o=await n.text();throw new Error(`Create folder failed: ${o}`)}return n.json()},onSuccess:(i,a)=>{s.invalidateQueries({queryKey:E.listing(a.path)})},onError:i=>{console.error("Create folder failed:",i)}})}function ni(){const s=L();return K({mutationFn:async({oldPath:i,newName:a})=>{const o=`${i.split("/").slice(0,-1).join("/")}/${a}`,c=await fetch("/api/files/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({src:i,dst:o})});if(!c.ok){const r=await c.text();throw new Error(`Rename failed: ${r}`)}return c.json()},onSuccess:(i,a)=>{const n=a.oldPath.split("/").slice(0,-1).join("/")||"/";s.invalidateQueries({queryKey:E.listing(n)})},onError:i=>{console.error("Rename failed:",i)}})}const ti=new Set(["txt","md","log","json","xml","yaml","yml","csv","ini","conf","cfg","js","ts","jsx","tsx","py","java","cpp","c","h","css","html","htm","php","rb","go","rs","sh","bash","zsh","toml","env","gitignore","dockerfile","makefile","sql","graphql","svelte","vue","scss","less"]);function me({item:s,children:i,onOpenFile:a}){const[n,o]=t.useState(!1),[c,r]=t.useState({x:0,y:0}),[l,p]=t.useState(!1),[w,v]=t.useState(!1),[h,u]=t.useState(s.name),[d,k]=t.useState(""),N=t.useRef(null),{navigateTo:j}=R(),m=ei(),x=si(),C=ni(),z=t.useCallback(b=>{switch(b){case"open":s.isDir&&j(s.path);break;case"edit":a&&a(s.path);break;case"download":s.isDir||m.mutate(s.path);break;case"rename":u(s.name),k(""),p(!0);break;case"delete":v(!0);break}},[s,m,j]),X=t.useCallback(b=>{b.preventDefault(),b.stopPropagation(),r({x:b.clientX,y:b.clientY}),o(!0)},[]),U=t.useCallback(async()=>{if(!h||h===s.name){p(!1);return}k("");try{await C.mutateAsync({oldPath:s.path,newName:h.trim()}),p(!1)}catch(b){const T=b instanceof Error?b.message:"Failed to rename";k(T)}},[h,s,C]),$=t.useCallback(async()=>{try{await x.mutateAsync(s.path),v(!1)}catch(b){console.error("Delete failed:",b)}},[s.path,x]),Y=t.useCallback(b=>{b.key==="Enter"?(b.preventDefault(),U()):b.key==="Escape"&&(b.preventDefault(),p(!1))},[U]),g=t.useCallback(b=>{u(b.target.value),d&&k("")},[d]);t.useEffect(()=>{if(l&&N.current){const b=N.current;if(b.focus(),!s.isDir&&s.extension){const T=s.name.replace(new RegExp(`\\.${s.extension}$`),"");b.setSelectionRange(0,T.length)}else b.select()}},[l,s]);const S=h.trim().length>0&&!/[<>:"/\\|?*]/.test(h)&&!h.includes("..")&&h!==s.name,M=()=>m.isPending?"Downloading…":"Download",he=()=>C.isPending?"Renaming…":"Rename",fe=()=>x.isPending?"Deleting…":"Delete";t.useEffect(()=>{if(!n)return;const b=()=>o(!1),T=ge=>{ge.key==="Escape"&&o(!1)},xe=setTimeout(()=>{document.addEventListener("click",b),document.addEventListener("contextmenu",b),document.addEventListener("keydown",T)},0);return()=>{clearTimeout(xe),document.removeEventListener("click",b),document.removeEventListener("contextmenu",b),document.removeEventListener("keydown",T)}},[n]);const P=t.useCallback(b=>{o(!1),z(b)},[z]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{onContextMenu:X,children:i}),n?e.jsx("div",{className:"fixed inset-0 z-50","aria-modal":"true",role:"dialog",children:e.jsxs("div",{className:"fixed min-w-[140px] rounded-lg bg-primary-50 p-1 text-sm text-primary-900 shadow-lg outline outline-primary-900/10 z-50",style:{left:c.x,top:c.y},role:"menu",onClick:b=>b.stopPropagation(),children:[s.isDir?e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>P("open"),className:f("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-primary-900","hover:bg-primary-100 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),children:[e.jsx(y,{icon:Ee,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Open"]}):null,s.isDir?null:e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>P("download"),disabled:m.isPending,className:f("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-primary-900","hover:bg-primary-100 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),children:[e.jsx(y,{icon:ze,size:16,strokeWidth:1.5,"aria-hidden":"true"}),M()]}),!s.isDir&&ti.has(s.extension.toLowerCase())?e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>P("edit"),className:f("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-primary-900","hover:bg-primary-100 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),children:[e.jsx(y,{icon:Me,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Edit"]}):null,e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>P("rename"),className:f("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-primary-900","hover:bg-primary-100 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),children:[e.jsx(y,{icon:Te,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Rename"]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>P("delete"),className:f("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm","text-red-600 hover:bg-red-50 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-red-300 focus-visible:outline-none"),children:[e.jsx(y,{icon:de,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Delete"]})]})}):null,e.jsx(Q,{open:l,onOpenChange:p,children:e.jsx(_,{children:e.jsxs("div",{className:"p-6",children:[e.jsxs(V,{className:"mb-2",children:["Rename ",s.isDir?"Folder":"File"]}),e.jsxs(H,{className:"mb-4",children:['Enter a new name for "',s.name,'"']}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("label",{htmlFor:"rename-input",className:"block text-sm font-medium text-primary-900 mb-2",children:[s.isDir?"Folder":"File"," Name"]}),e.jsx("input",{id:"rename-input",ref:N,type:"text",value:h,onChange:g,onKeyDown:Y,autoFocus:!0,spellCheck:!1,"aria-describedby":d?"rename-error":void 0,"aria-invalid":d?"true":"false",className:f("w-full px-3 py-2 border rounded-lg","transition-colors duration-150 ease-out","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",d?"border-red-300 focus-visible:ring-red-300":"border-primary-200 focus:border-primary-300")}),d?e.jsx("p",{id:"rename-error",className:"text-sm text-red-600 mt-1",role:"alert","aria-live":"polite",children:d}):null]}),C.isPending?e.jsx("div",{className:"mb-4 p-3 bg-primary-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-primary-600",children:"Renaming…"})}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{disabled:C.isPending,className:f("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(D,{onClick:U,disabled:!S||C.isPending,className:f("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",(!S||C.isPending)&&"opacity-50 cursor-not-allowed"),children:he()})]})]})})}),e.jsx(Q,{open:w,onOpenChange:v,children:e.jsx(_,{children:e.jsxs("div",{className:"p-6",children:[e.jsxs(V,{className:"mb-2",children:["Delete ",s.isDir?"Folder":"File"]}),e.jsxs(H,{className:"mb-4",children:['Are you sure you want to delete "',s.name,'"?',s.isDir?" This will delete the folder and all its contents.":""," ","This action cannot be undone."]}),x.isPending?e.jsx("div",{className:"mb-4 p-3 bg-red-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-red-700",children:"Deleting…"})}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{disabled:x.isPending,className:f("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(D,{variant:"destructive",onClick:$,disabled:x.isPending,className:f("focus-visible:ring-2 focus-visible:ring-red-300 focus-visible:outline-none","touch-manipulation",x.isPending&&"opacity-50 cursor-not-allowed"),children:fe()})]})]})})})]})}const ri=new Set(["txt","md","log","json","xml","yaml","yml","csv","ini","conf","cfg","js","ts","jsx","tsx","py","java","cpp","c","h","css","html","htm","php","rb","go","rs","sh","bash","zsh","toml","env","gitignore","dockerfile","makefile","sql","graphql","svelte","vue","scss","less"]);function J(s){if(s===0)return"0 B";const i=1024,a=["B","KB","MB","GB","TB"],n=Math.floor(Math.log(s)/Math.log(i));return parseFloat((s/Math.pow(i,n)).toFixed(1))+" "+a[n]}function O(s){const i=new Date(s),n=new Date().getTime()-i.getTime(),o=Math.floor(n/1e3),c=Math.floor(o/60),r=Math.floor(c/60),l=Math.floor(r/24);return l>7?i.toLocaleDateString():l>0?l===1?"yesterday":`${l} days ago`:r>0?r===1?"1 hour ago":`${r} hours ago`:c>0?c===1?"1 minute ago":`${c} minutes ago`:"just now"}function pe(s){if(s.isDir)return ue;const i=s.extension.toLowerCase();return["jpg","jpeg","png","gif","webp","svg","bmp"].includes(i)?Le:["mp4","avi","mkv","mov","wmv","flv","webm"].includes(i)?Re:["mp3","wav","flac","aac","ogg","m4a"].includes(i)?Ke:["zip","rar","7z","tar","gz","bz2"].includes(i)?Ue:["txt","md","log","json","xml","yaml","yml"].includes(i)?$e:["js","ts","jsx","tsx","py","java","cpp","c","h","css","html","php","rb","go","rs"].includes(i)?Pe:ee}function li(s,i,a){return t.useMemo(()=>[...s].sort((o,c)=>{if(o.isDir&&!c.isDir)return-1;if(!o.isDir&&c.isDir)return 1;let r=0;switch(i){case"name":r=o.name.localeCompare(c.name);break;case"size":r=o.size-c.size;break;case"modified":r=new Date(o.modified).getTime()-new Date(c.modified).getTime();break;default:r=o.name.localeCompare(c.name)}return a?r:-r}),[s,i,a])}function oi(){return t.useMemo(()=>typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function ci({viewMode:s}){const i=s==="grid"?12:8;return s==="grid"?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8 gap-3 p-4","aria-busy":"true","aria-label":"Loading files",children:Array.from({length:i},(a,n)=>e.jsxs("div",{className:"flex flex-col items-center p-3 rounded-lg",children:[e.jsx("div",{className:"w-12 h-12 bg-primary-200 rounded animate-pulse mb-2"}),e.jsx("div",{className:"w-16 h-4 bg-primary-200 rounded animate-pulse"})]},n))}):e.jsx("div",{className:"divide-y divide-primary-200","aria-busy":"true","aria-label":"Loading files",children:Array.from({length:i},(a,n)=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e.jsx("div",{className:"w-6 h-6 bg-primary-200 rounded animate-pulse"}),e.jsx("div",{className:"flex-1 min-w-0 h-4 bg-primary-200 rounded animate-pulse"}),e.jsx("div",{className:"w-16 h-4 bg-primary-200 rounded animate-pulse"}),e.jsx("div",{className:"w-20 h-4 bg-primary-200 rounded animate-pulse"})]},n))})}const di=t.memo(function({item:i,isSelected:a,onClick:n,onDoubleClick:o,onKeyDown:c,onOpenFile:r,reduceMotion:l}){const p=t.useCallback(()=>{n(i)},[n,i]),w=t.useCallback(()=>{o(i)},[o,i]),v=t.useCallback(d=>{c(d,i)},[c,i]),h=()=>i.isDir?`${i.name}, folder`:`${i.name}, ${i.extension} file, ${J(i.size)}, modified ${O(i.modified)}`,u=e.jsxs(F.button,{type:"button",whileHover:l?{}:{scale:1.02},whileTap:l?{}:{scale:.98},transition:{duration:l?0:.1},onClick:p,onDoubleClick:w,onKeyDown:v,"aria-label":h(),className:f("flex flex-col items-center p-3 rounded-lg w-full","transition-colors duration-150 ease-out","hover:bg-primary-100 focus-visible:bg-primary-100","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",a&&"bg-primary-200"),children:[e.jsx(y,{icon:pe(i),size:48,strokeWidth:1,className:f("mb-2",i.isDir?"text-blue-500":"text-primary-600"),"aria-hidden":"true"}),e.jsx("span",{className:"text-xs text-center text-primary-900 font-medium truncate w-full min-w-0",children:i.name}),i.isDir?null:e.jsx("span",{className:"text-xs text-primary-500 mt-1 tabular-nums",children:J(i.size)})]});return e.jsx(me,{item:i,onOpenFile:r,children:u})}),ui=t.memo(function({item:i,isSelected:a,onClick:n,onDoubleClick:o,onKeyDown:c,onOpenFile:r,reduceMotion:l}){const p=t.useCallback(()=>{n(i)},[n,i]),w=t.useCallback(()=>{o(i)},[o,i]),v=t.useCallback(d=>{c(d,i)},[c,i]),h=()=>i.isDir?`${i.name}, folder, modified ${O(i.modified)}`:`${i.name}, ${i.extension} file, ${J(i.size)}, modified ${O(i.modified)}`,u=e.jsxs(F.button,{type:"button",whileHover:l?{}:{backgroundColor:"rgb(248 250 252)"},transition:{duration:l?0:.1},onClick:p,onDoubleClick:w,onKeyDown:v,"aria-label":h(),className:f("w-full grid grid-cols-[auto_1fr_auto_auto] gap-4 px-4 py-3 text-left","transition-colors duration-150 ease-out","hover:bg-primary-100 focus-visible:bg-primary-100","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",a&&"bg-primary-200"),children:[e.jsx(y,{icon:pe(i),size:20,strokeWidth:1.5,className:f("mt-0.5 shrink-0",i.isDir?"text-blue-500":"text-primary-600"),"aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("span",{className:"text-primary-900 font-medium truncate block",children:i.name})}),e.jsx("div",{className:"text-sm text-primary-600 text-right w-16 tabular-nums shrink-0",children:i.isDir?"—":J(i.size)}),e.jsx("div",{className:"text-sm text-primary-600 text-right w-20 tabular-nums shrink-0",children:O(i.modified)})]});return e.jsx(me,{item:i,onOpenFile:r,children:u})}),mi=e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(y,{icon:ue,size:48,strokeWidth:1,className:"mx-auto text-primary-400 mb-3","aria-hidden":"true"}),e.jsx("p",{className:"text-primary-600 font-medium",children:"This folder is empty"}),e.jsx("p",{className:"text-sm text-primary-500 mt-1",children:"Upload files or create a new folder to get started"})]})});function pi({listing:s,loading:i,onOpenFile:a}){const{viewMode:n,sortBy:o,sortAsc:c,selectedFiles:r,navigateTo:l,toggleFileSelection:p}=R(),[w,v]=t.useState(0),h=t.useRef(null),u=oi(),d=li(s?.items||[],o,c),k=t.useCallback(m=>{p(m.path)},[p]),N=t.useCallback(m=>{m.isDir?l(m.path):a&&ri.has(m.extension.toLowerCase())&&a(m.path)},[l,a]),j=t.useCallback((m,x)=>{m.key==="Enter"?(m.preventDefault(),x.isDir?l(x.path):p(x.path)):m.key===" "&&(m.preventDefault(),p(x.path))},[l,p]);return t.useEffect(()=>{const m=x=>{if(d.length)switch(x.key){case"ArrowDown":x.preventDefault(),v(C=>Math.min(C+1,d.length-1));break;case"ArrowUp":x.preventDefault(),v(C=>Math.max(C-1,0));break;case"Home":x.preventDefault(),v(0);break;case"End":x.preventDefault(),v(d.length-1);break}};if(h.current)return h.current.addEventListener("keydown",m),()=>{h.current?.removeEventListener("keydown",m)}},[d.length]),i?e.jsx(ci,{viewMode:n}):s?d.length===0?mi:n==="grid"?e.jsx("div",{ref:h,className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8 gap-3 p-4 overflow-y-auto",role:"grid","aria-label":"Files grid",tabIndex:0,children:d.map((m,x)=>e.jsx("div",{role:"gridcell",children:e.jsx(di,{item:m,isSelected:r.has(m.path),onClick:k,onDoubleClick:N,onKeyDown:j,onOpenFile:a,reduceMotion:u})},m.path))}):e.jsx("div",{ref:h,className:"overflow-y-auto",role:"table","aria-label":"Files list",tabIndex:0,children:e.jsxs("div",{className:"divide-y divide-primary-200",children:[e.jsxs("div",{className:"grid grid-cols-[auto_1fr_auto_auto] gap-4 px-4 py-2 text-sm font-medium text-primary-600 bg-primary-50",role:"row",children:[e.jsx("div",{className:"w-6",role:"columnheader","aria-label":"File type"}),e.jsx("div",{role:"columnheader",children:"Name"}),e.jsx("div",{className:"w-16 text-right tabular-nums",role:"columnheader",children:"Size"}),e.jsx("div",{className:"w-20 text-right tabular-nums",role:"columnheader",children:"Modified"})]}),d.map((m,x)=>e.jsx("div",{role:"row",children:e.jsx(ui,{item:m,isSelected:r.has(m.path),onClick:k,onDoubleClick:N,onKeyDown:j,onOpenFile:a,reduceMotion:u})},m.path))]})}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("p",{className:"text-primary-500",children:"No listing available"})})}function oe(s){if(s===0)return"0 B";const i=1024,a=["B","KB","MB","GB"],n=Math.floor(Math.log(s)/Math.log(i));return parseFloat((s/Math.pow(i,n)).toFixed(1))+" "+a[n]}function hi({open:s,onOpenChange:i,currentPath:a}){const[n,o]=t.useState([]),[c,r]=t.useState(!1),[l,p]=t.useState("idle"),w=t.useRef(null),v=ii(),h=t.useCallback(()=>{o([]),p("idle"),w.current&&(w.current.value="")},[]),u=t.useCallback(g=>{if(!g)return;const S=Array.from(g).map(M=>({file:M,id:Math.random().toString(36).substr(2,9)}));o(M=>[...M,...S])},[]),d=t.useCallback(g=>{u(g.target.files)},[u]),k=t.useCallback(g=>{g.preventDefault(),r(!1),u(g.dataTransfer.files)},[u]),N=t.useCallback(g=>{g.preventDefault(),r(!0)},[]),j=t.useCallback(g=>{g.preventDefault(),r(!1)},[]),m=t.useCallback(g=>{o(S=>S.filter(M=>M.id!==g))},[]),x=t.useCallback(()=>{w.current?.click()},[]),C=t.useCallback(g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),x())},[x]),z=t.useCallback(async()=>{if(n.length===0)return;const g=new DataTransfer;n.forEach(({file:S})=>{g.items.add(S)}),p("uploading");try{await v.mutateAsync({files:g.files,path:a}),p("success"),h(),i(!1)}catch(S){p("error"),console.error("Upload failed:",S)}},[n,a,v,h,i]),X=t.useCallback(g=>{g||h(),i(g)},[h,i]),U=n.reduce((g,{file:S})=>g+S.size,0),$=n.length,Y=()=>v.isPending||l==="uploading"?"Uploading…":$===0?"Upload":$===1?"Upload 1 File":`Upload ${$} Files`;return e.jsx(Q,{open:s,onOpenChange:X,children:e.jsx(_,{className:"w-[min(500px,92vw)]",children:e.jsxs("div",{className:"p-6",children:[e.jsx(V,{className:"mb-2",children:"Upload Files"}),e.jsxs(H,{className:"mb-6",children:["Upload files to ",a==="/"?"root directory":a]}),e.jsxs("div",{onDrop:k,onDragOver:N,onDragLeave:j,onClick:x,onKeyDown:C,tabIndex:0,role:"button","aria-label":"Drop files here or click to choose files",className:f("border-2 border-dashed rounded-lg p-8 text-center cursor-pointer","transition-colors duration-150 ease-out","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",c?"border-primary-400 bg-primary-50":"border-primary-200 hover:border-primary-300 hover:bg-primary-50"),children:[e.jsx(y,{icon:ce,size:48,strokeWidth:1,className:"mx-auto text-primary-400 mb-4","aria-hidden":"true"}),e.jsx("p",{className:"text-primary-600 font-medium mb-2",children:"Drag and drop files here"}),e.jsx("p",{className:"text-sm text-primary-500 mb-4",children:"or"}),e.jsxs(D,{variant:"outline",className:f("gap-2","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Choose files from computer",children:[e.jsx(y,{icon:ee,size:18,strokeWidth:1.5,"aria-hidden":"true"}),e.jsx("span",{children:"Choose Files"})]}),e.jsx("input",{ref:w,type:"file",multiple:!0,onChange:d,className:"hidden","aria-hidden":"true"})]}),e.jsx(I,{children:n.length>0?e.jsxs(F.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mt-6",children:[e.jsxs("h4",{className:"text-sm font-medium text-primary-900 mb-3",children:["Selected Files (",n.length,")"]}),e.jsx("div",{className:"max-h-32 overflow-y-auto border border-primary-200 rounded-lg",children:n.map(({file:g,id:S})=>e.jsxs(F.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},exit:{opacity:0,x:10},className:"flex items-center justify-between p-2 border-b border-primary-100 last:border-b-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(y,{icon:ee,size:16,strokeWidth:1.5,className:"text-primary-600 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"text-sm text-primary-900 truncate min-w-0",children:g.name}),e.jsx("span",{className:"text-xs text-primary-500 shrink-0 tabular-nums",children:oe(g.size)})]}),e.jsx(D,{size:"icon-sm",variant:"ghost",onClick:()=>m(S),className:f("text-primary-500 hover:text-red-600 shrink-0","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":`Remove ${g.name} from upload list`,children:e.jsx(y,{icon:de,size:14,strokeWidth:1.5,"aria-hidden":"true"})})]},S))}),e.jsxs("p",{className:"text-xs text-primary-600 mt-2 tabular-nums",children:["Total size: ",oe(U)]})]}):null}),v.isPending||l==="uploading"?e.jsxs(F.div,{initial:{opacity:0},animate:{opacity:1},className:"mt-4 p-3 bg-primary-50 rounded-lg","aria-live":"polite",children:[e.jsx("p",{className:"text-sm text-primary-600 mb-2",children:"Uploading files…"}),e.jsx("div",{className:"bg-primary-200 rounded-full h-2",role:"progressbar","aria-label":"Upload progress",children:e.jsx("div",{className:"bg-primary-600 h-2 rounded-full w-1/2 animate-pulse"})})]}):null,l==="success"?e.jsx("div",{className:"mt-4 p-3 bg-green-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-green-700",children:"Files uploaded successfully!"})}):null,l==="error"?e.jsx("div",{className:"mt-4 p-3 bg-red-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-red-700",children:"Upload failed. Please try again."})}):null,e.jsxs("div",{className:"flex justify-end gap-2 mt-6",children:[e.jsx(G,{disabled:v.isPending||l==="uploading",className:f("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(D,{onClick:z,disabled:n.length===0||v.isPending||l==="uploading",className:f("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:Y()})]})]})})})}function fi({open:s,onOpenChange:i,currentPath:a}){const[n,o]=t.useState(""),[c,r]=t.useState(""),l=ai(),p=t.useCallback(async()=>{if(n.trim()){r("");try{await l.mutateAsync({path:a,name:n.trim()}),o(""),i(!1)}catch(m){const x=m instanceof Error?m.message:"Failed to create folder";r(x),console.error("Create folder failed:",m)}}},[n,a,l,i]),w=t.useCallback(m=>{m||(o(""),r("")),i(m)},[i]),v=t.useCallback(m=>{m.key==="Enter"&&(m.preventDefault(),p())},[p]),h=t.useCallback(m=>{const x=m.target.value;o(x),c&&r("")},[c]),u=n.trim().length>0&&!/[<>:"/\\|?*]/.test(n)&&!n.includes(".."),d=()=>l.isPending?"Creating…":"Create Folder",N=n.trim()?n.includes("..")?'Folder name cannot contain ".."':/[<>:"/\\|?*]/.test(n)?'Invalid characters: < > : " / \\ | ? *':"":"",j=c||N;return e.jsx(Q,{open:s,onOpenChange:w,children:e.jsx(_,{children:e.jsxs("div",{className:"p-6",children:[e.jsx(V,{className:"mb-2",children:"Create New Folder"}),e.jsxs(H,{className:"mb-4",children:["Create a new folder in ",a==="/"?"root directory":a]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{htmlFor:"folder-name",className:"block text-sm font-medium text-primary-900 mb-2",children:"Folder Name"}),e.jsx("input",{id:"folder-name",type:"text",value:n,onChange:h,onKeyDown:v,placeholder:"Enter folder name",autoComplete:"off",spellCheck:!1,autoFocus:!0,"aria-describedby":j?"folder-name-error":void 0,"aria-invalid":j?"true":"false",className:f("w-full px-3 py-2 border rounded-lg","transition-colors duration-150 ease-out","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",j?"border-red-300 focus-visible:ring-red-300":"border-primary-200 focus:border-primary-300")}),j?e.jsx("p",{id:"folder-name-error",className:"text-sm text-red-600 mt-1",role:"alert","aria-live":"polite",children:c||N}):null]}),l.isPending?e.jsx("div",{className:"mb-4 p-3 bg-primary-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-primary-600",children:"Creating folder…"})}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{disabled:l.isPending,className:f("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(D,{onClick:p,disabled:!u||l.isPending,className:f("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",(!u||l.isPending)&&"opacity-50 cursor-not-allowed"),"aria-describedby":u?void 0:"create-button-help",children:d()})]}),!u&&n.length>0?e.jsx("p",{id:"create-button-help",className:"text-xs text-primary-500 mt-2",children:"Please enter a valid folder name"}):null]})})})}const xi={js:"JavaScript",ts:"TypeScript",jsx:"JSX",tsx:"TSX",py:"Python",json:"JSON",yaml:"YAML",yml:"YAML",md:"Markdown",html:"HTML",css:"CSS",scss:"SCSS",sh:"Shell",bash:"Bash",sql:"SQL",xml:"XML",toml:"TOML",ini:"INI",conf:"Config",cfg:"Config",env:"Env",txt:"Text",log:"Log",csv:"CSV",go:"Go",rs:"Rust",rb:"Ruby",php:"PHP",java:"Java",c:"C",cpp:"C++",h:"Header",dockerfile:"Dockerfile",makefile:"Makefile",graphql:"GraphQL",svelte:"Svelte",vue:"Vue"};function gi({filePath:s,onClose:i}){const a=Xe(s),n=Ye(),o=t.useRef(null),[c,r]=t.useState(null),[l,p]=t.useState(!1);t.useEffect(()=>{a.data&&c===null&&r(a.data.content)},[a.data,c]);const w=t.useMemo(()=>a.data?xi[a.data.extension.toLowerCase()]||a.data.extension.toUpperCase():"",[a.data]),v=t.useCallback(N=>{r(N.target.value),p(N.target.value!==a.data?.content)},[a.data]),h=t.useCallback(async()=>{if(c!==null)try{await n.mutateAsync({path:s,content:c}),p(!1)}catch{}},[s,c,n]),u=t.useCallback(()=>{l&&!window.confirm("You have unsaved changes. Discard them?")||i()},[l,i]);t.useEffect(()=>{const N=j=>{(j.ctrlKey||j.metaKey)&&j.key==="s"&&(j.preventDefault(),l&&h()),j.key==="Escape"&&u()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[h,u,l]);const d=t.useCallback(N=>{if(N.key==="Tab"){N.preventDefault();const j=N.currentTarget,m=j.selectionStart,x=j.selectionEnd,C=j.value,z=C.substring(0,m)+" "+C.substring(x);r(z),p(z!==a.data?.content),requestAnimationFrame(()=>{j.selectionStart=j.selectionEnd=m+2})}},[a.data]),k=s.split("/").pop()||s;return e.jsxs("div",{className:"fixed inset-0 z-50 bg-surface flex flex-col",children:[e.jsxs("header",{className:"flex items-center justify-between px-4 py-2 border-b border-primary-200 bg-primary-50",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("h2",{className:"text-sm font-semibold text-primary-900 truncate",children:k}),w?e.jsx("span",{className:"text-xs text-primary-500 bg-primary-100 px-2 py-0.5 rounded-full shrink-0",children:w}):null,l?e.jsx("span",{className:"text-xs text-amber-600 bg-amber-50 px-2 py-0.5 rounded-full shrink-0",children:"Unsaved"}):null,n.isError?e.jsx("span",{className:"text-xs text-red-600",children:n.error.message}):null]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(D,{size:"sm",variant:"default",onClick:h,disabled:!l||n.isPending,className:f((!l||n.isPending)&&"opacity-50 cursor-not-allowed"),children:[e.jsx(y,{icon:Ie,size:16,strokeWidth:1.5,"aria-hidden":"true"}),n.isPending?"Saving…":"Save"]}),e.jsx(D,{size:"icon-sm",variant:"ghost",onClick:u,"aria-label":"Close editor",children:e.jsx(y,{icon:Be,size:20,strokeWidth:1.5,"aria-hidden":"true"})})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:a.isLoading?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("p",{className:"text-primary-500 text-sm",children:"Loading file…"})}):a.isError?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-red-600 text-sm mb-2",children:a.error instanceof Error?a.error.message:"Failed to load file"}),e.jsx(D,{size:"sm",variant:"secondary",onClick:()=>{a.refetch()},children:"Retry"})]})}):e.jsx("textarea",{ref:o,value:c??"",onChange:v,onKeyDown:d,spellCheck:!1,autoFocus:!0,className:f("w-full h-full p-4 resize-none","bg-primary-950 text-primary-100","font-mono text-sm leading-relaxed","focus:outline-none","selection:bg-blue-800/50")})}),a.data?e.jsxs("footer",{className:"flex items-center justify-between px-4 py-1 border-t border-primary-200 bg-primary-50 text-xs text-primary-500",children:[e.jsx("span",{children:s}),e.jsx("span",{children:bi(a.data.size)})]}):null]})}function bi(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function ki(){const s=L(),{currentPath:i}=R(),[a,n]=t.useState(!1),[o,c]=t.useState(!1),[r,l]=t.useState(null),p=Ze(i),v=ie({queryKey:ve,queryFn:function(){return ae(s)},initialData:function(){return ae(s)},staleTime:1/0}).data?.isSidebarCollapsed??!1,h=t.useCallback(()=>{be(s,function(C){return{...C,isSidebarCollapsed:!C.isSidebarCollapsed}})},[s]),u=t.useCallback(()=>{n(!0)},[]),d=t.useCallback(()=>{c(!0)},[]),k=t.useCallback(x=>{l(x)},[]),N=t.useCallback(()=>{l(null)},[]),j=t.useMemo(()=>({display:"flex",flexDirection:"column",height:"100%",minHeight:0}),[]),m=e.jsx(He,{isCollapsed:v,onToggleCollapse:h,onSelectAction:()=>{}});return e.jsxs("div",{className:"h-screen bg-surface text-primary-900",children:[e.jsxs("div",{className:f("h-full overflow-hidden grid grid-cols-[auto_1fr]"),children:[m,e.jsxs("main",{"aria-label":"File explorer",style:j,children:[e.jsxs("header",{className:"border-b border-primary-200 px-4 py-3",children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsx(Ge,{path:i})}),e.jsx(Je,{onUpload:u,onCreateFolder:d})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto",children:[e.jsx(pi,{listing:p.data,loading:p.isLoading,onOpenFile:k}),p.isError?e.jsxs("div",{className:"p-4 text-center","aria-live":"polite",children:[e.jsx("p",{className:"text-red-600 text-sm",children:p.error instanceof Error?p.error.message:"Failed to load files"}),e.jsx("button",{onClick:()=>{p.refetch()},className:"mt-2 text-sm text-primary-600 hover:text-primary-900 underline focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none rounded-sm",children:"Retry"})]}):null]}),e.jsx(hi,{open:a,onOpenChange:n,currentPath:i}),e.jsx(fi,{open:o,onOpenChange:c,currentPath:i})]})]}),r?e.jsx(gi,{filePath:r,onClose:N}):null]})}export{ki as FileExplorerScreen};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/file-explorer-screen-B0hwrjdF.js","assets/main-DOBfHXDF.js","assets/useButton-csSB2uQJ.js","assets/button-seqh98ae.js","assets/use-file-explorer-state-B5JLNsSa.js","assets/react-DD8SkMJn.js"])))=>i.map(i=>d[i]);
2
- import{j as e,r,_ as s}from"./main-DOBfHXDF.js";const n=r.lazy(()=>s(()=>import("./file-explorer-screen-B0hwrjdF.js"),__vite__mapDeps([0,1,2,3,4,5])).then(t=>({default:t.FileExplorerScreen})));function o(){return e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"flex h-screen items-center justify-center text-primary-500 text-sm",children:"Loading…"}),children:e.jsx(n,{})})}export{o as component};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/file-explorer-screen-hjggspl-.js","assets/main-BlX7CS2-.js","assets/useButton-DhneLsMA.js","assets/button-BcnCTjUT.js","assets/use-file-explorer-state-C6lX-h0n.js","assets/react-ONC2UaeC.js"])))=>i.map(i=>d[i]);
2
+ import{j as e,r,_ as s}from"./main-BlX7CS2-.js";const n=r.lazy(()=>s(()=>import("./file-explorer-screen-hjggspl-.js"),__vite__mapDeps([0,1,2,3,4,5])).then(t=>({default:t.FileExplorerScreen})));function o(){return e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"flex h-screen items-center justify-center text-primary-500 text-sm",children:"Loading…"}),children:e.jsx(n,{})})}export{o as component};
@@ -1 +1 @@
1
- import{R as t,r as s,j as a}from"./main-DOBfHXDF.js";function n(){const e=t.useNavigate();return s.useEffect(()=>{e({to:"/chat/$sessionKey",params:{sessionKey:"main"},replace:!0})},[e]),a.jsx("div",{className:"h-screen flex items-center justify-center text-primary-600",children:"Loading…"})}export{n as component};
1
+ import{R as t,r as s,j as a}from"./main-BlX7CS2-.js";function n(){const e=t.useNavigate();return s.useEffect(()=>{e({to:"/chat/$sessionKey",params:{sessionKey:"main"},replace:!0})},[e]),a.jsx("div",{className:"h-screen flex items-center justify-center text-primary-600",children:"Loading…"})}export{n as component};
@@ -1,4 +1,4 @@
1
- import{r as H,j as K}from"./main-DOBfHXDF.js";import{B as yi,H as ki,X as wi,x as xi,c as Ue}from"./button-seqh98ae.js";import{c as $i}from"./react-DD8SkMJn.js";let S=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function vi(n){return Yn(n)}function Yn(n){return Array.isArray(n)?Ci(n):n instanceof RegExp?n:typeof n=="object"?ji(n):n}function Ci(n){let e=[];for(let t=0,a=n.length;t<a;t++)e[t]=Yn(n[t]);return e}function ji(n){let e={};for(let t in n)e[t]=Yn(n[t]);return e}function aa(n,...e){return e.forEach(t=>{for(let a in t)n[a]=t[a]}),n}function ia(n){const e=~n.lastIndexOf("/")||~n.lastIndexOf("\\");return e===0?n:~e===n.length-1?ia(n.substring(0,n.length-1)):n.substr(~e+1)}var bn=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Le=class{static hasCaptures(n){return n===null?!1:(bn.lastIndex=0,bn.test(n))}static replaceCaptures(n,e,t){return n.replace(bn,(a,i,r,s)=>{let o=t[parseInt(i||r,10)];if(o){let c=e.substring(o.start,o.end);for(;c[0]===".";)c=c.substring(1);switch(s){case"downcase":return c.toLowerCase();case"upcase":return c.toUpperCase();default:return c}}else return a})}};function ra(n,e){return n<e?-1:n>e?1:0}function sa(n,e){if(n===null&&e===null)return 0;if(!n)return-1;if(!e)return 1;let t=n.length,a=e.length;if(t===a){for(let i=0;i<t;i++){let r=ra(n[i],e[i]);if(r!==0)return r}return 0}return t-a}function gt(n){return!!(/^#[0-9a-f]{6}$/i.test(n)||/^#[0-9a-f]{8}$/i.test(n)||/^#[0-9a-f]{3}$/i.test(n)||/^#[0-9a-f]{4}$/i.test(n))}function oa(n){return n.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var ca=class{constructor(n){this.fn=n}cache=new Map;get(n){if(this.cache.has(n))return this.cache.get(n);const e=this.fn(n);return this.cache.set(n,e),e}},Xe=class{constructor(n,e,t){this._colorMap=n,this._defaults=e,this._root=t}static createFromRawTheme(n,e){return this.createFromParsedTheme(qi(n),e)}static createFromParsedTheme(n,e){return zi(n,e)}_cachedMatchRoot=new ca(n=>this._root.match(n));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(n){if(n===null)return this._defaults;const e=n.scopeName,a=this._cachedMatchRoot.get(e).find(i=>Ai(n.parent,i.parentScopes));return a?new pa(a.fontStyle,a.foreground,a.background):null}},gn=class De{constructor(e,t){this.parent=e,this.scopeName=t}static push(e,t){for(const a of t)e=new De(e,a);return e}static from(...e){let t=null;for(let a=0;a<e.length;a++)t=new De(t,e[a]);return t}push(e){return new De(this,e)}getSegments(){let e=this;const t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(" ")}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){const t=[];let a=this;for(;a&&a!==e;)t.push(a.scopeName),a=a.parent;return a===e?t.reverse():void 0}};function Ai(n,e){if(e.length===0)return!0;for(let t=0;t<e.length;t++){let a=e[t],i=!1;if(a===">"){if(t===e.length-1)return!1;a=e[++t],i=!0}for(;n&&!Ei(n.scopeName,a);){if(i)return!1;n=n.parent}if(!n)return!1;n=n.parent}return!0}function Ei(n,e){return e===n||n.startsWith(e)&&n[e.length]==="."}var pa=class{constructor(n,e,t){this.fontStyle=n,this.foregroundId=e,this.backgroundId=t}};function qi(n){if(!n)return[];if(!n.settings||!Array.isArray(n.settings))return[];let e=n.settings,t=[],a=0;for(let i=0,r=e.length;i<r;i++){let s=e[i];if(!s.settings)continue;let o;if(typeof s.scope=="string"){let m=s.scope;m=m.replace(/^[,]+/,""),m=m.replace(/[,]+$/,""),o=m.split(",")}else Array.isArray(s.scope)?o=s.scope:o=[""];let c=-1;if(typeof s.settings.fontStyle=="string"){c=0;let m=s.settings.fontStyle.split(" ");for(let u=0,b=m.length;u<b;u++)switch(m[u]){case"italic":c=c|1;break;case"bold":c=c|2;break;case"underline":c=c|4;break;case"strikethrough":c=c|8;break}}let p=null;typeof s.settings.foreground=="string"&&gt(s.settings.foreground)&&(p=s.settings.foreground);let l=null;typeof s.settings.background=="string"&&gt(s.settings.background)&&(l=s.settings.background);for(let m=0,u=o.length;m<u;m++){let d=o[m].trim().split(" "),y=d[d.length-1],g=null;d.length>1&&(g=d.slice(0,d.length-1),g.reverse()),t[a++]=new Fi(y,g,i,c,p,l)}}return t}var Fi=class{constructor(n,e,t,a,i,r){this.scope=n,this.parentScopes=e,this.index=t,this.fontStyle=a,this.foreground=i,this.background=r}},Z=(n=>(n[n.NotSet=-1]="NotSet",n[n.None=0]="None",n[n.Italic=1]="Italic",n[n.Bold=2]="Bold",n[n.Underline=4]="Underline",n[n.Strikethrough=8]="Strikethrough",n))(Z||{});function zi(n,e){n.sort((c,p)=>{let l=ra(c.scope,p.scope);return l!==0||(l=sa(c.parentScopes,p.parentScopes),l!==0)?l:c.index-p.index});let t=0,a="#000000",i="#ffffff";for(;n.length>=1&&n[0].scope==="";){let c=n.shift();c.fontStyle!==-1&&(t=c.fontStyle),c.foreground!==null&&(a=c.foreground),c.background!==null&&(i=c.background)}let r=new Si(e),s=new pa(t,r.getId(a),r.getId(i)),o=new Ti(new qn(0,null,-1,0,0),[]);for(let c=0,p=n.length;c<p;c++){let l=n[c];o.insert(0,l.scope,l.parentScopes,l.fontStyle,r.getId(l.foreground),r.getId(l.background))}return new Xe(r,s,o)}var Si=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(n){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(n)){this._isFrozen=!0;for(let e=0,t=n.length;e<t;e++)this._color2id[n[e]]=e,this._id2color[e]=n[e]}else this._isFrozen=!1}getId(n){if(n===null)return 0;n=n.toUpperCase();let e=this._color2id[n];if(e)return e;if(this._isFrozen)throw new Error(`Missing color in color map - ${n}`);return e=++this._lastColorId,this._color2id[n]=e,this._id2color[e]=n,e}getColorMap(){return this._id2color.slice(0)}},Ni=Object.freeze([]),qn=class la{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,a,i,r){this.scopeDepth=e,this.parentScopes=t||Ni,this.fontStyle=a,this.foreground=i,this.background=r}clone(){return new la(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let a=0,i=e.length;a<i;a++)t[a]=e[a].clone();return t}acceptOverwrite(e,t,a,i){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),a!==0&&(this.foreground=a),i!==0&&(this.background=i)}},Ti=class Fn{constructor(e,t=[],a={}){this._mainRule=e,this._children=a,this._rulesWithParentScopes=t}_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let a=0,i=0;for(;e.parentScopes[a]===">"&&a++,t.parentScopes[i]===">"&&i++,!(a>=e.parentScopes.length||i>=t.parentScopes.length);){const r=t.parentScopes[i].length-e.parentScopes[a].length;if(r!==0)return r;a++,i++}return t.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let a=e.indexOf("."),i,r;if(a===-1?(i=e,r=""):(i=e.substring(0,a),r=e.substring(a+1)),this._children.hasOwnProperty(i))return this._children[i].match(r)}const t=this._rulesWithParentScopes.concat(this._mainRule);return t.sort(Fn._cmpBySpecificity),t}insert(e,t,a,i,r,s){if(t===""){this._doInsertHere(e,a,i,r,s);return}let o=t.indexOf("."),c,p;o===-1?(c=t,p=""):(c=t.substring(0,o),p=t.substring(o+1));let l;this._children.hasOwnProperty(c)?l=this._children[c]:(l=new Fn(this._mainRule.clone(),qn.cloneArr(this._rulesWithParentScopes)),this._children[c]=l),l.insert(e+1,p,a,i,r,s)}_doInsertHere(e,t,a,i,r){if(t===null){this._mainRule.acceptOverwrite(e,a,i,r);return}for(let s=0,o=this._rulesWithParentScopes.length;s<o;s++){let c=this._rulesWithParentScopes[s];if(sa(c.parentScopes,t)===0){c.acceptOverwrite(e,a,i,r);return}}a===-1&&(a=this._mainRule.fontStyle),i===0&&(i=this._mainRule.foreground),r===0&&(r=this._mainRule.background),this._rulesWithParentScopes.push(new qn(e,t,a,i,r))}},_e=class U{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){const t=U.getLanguageId(e),a=U.getTokenType(e),i=U.getFontStyle(e),r=U.getForeground(e),s=U.getBackground(e);console.log({languageId:t,tokenType:a,fontStyle:i,foreground:r,background:s})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!==0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(e,t,a,i,r,s,o){let c=U.getLanguageId(e),p=U.getTokenType(e),l=U.containsBalancedBrackets(e)?1:0,m=U.getFontStyle(e),u=U.getForeground(e),b=U.getBackground(e);return t!==0&&(c=t),a!==8&&(p=a),i!==null&&(l=i?1:0),r!==-1&&(m=r),s!==0&&(u=s),o!==0&&(b=o),(c<<0|p<<8|l<<10|m<<11|u<<15|b<<24)>>>0}};function Ve(n,e){const t=[],a=Zi(n);let i=a.next();for(;i!==null;){let c=0;if(i.length===2&&i.charAt(1)===":"){switch(i.charAt(0)){case"R":c=1;break;case"L":c=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=a.next()}let p=s();if(t.push({matcher:p,priority:c}),i!==",")break;i=a.next()}return t;function r(){if(i==="-"){i=a.next();const c=r();return p=>!!c&&!c(p)}if(i==="("){i=a.next();const c=o();return i===")"&&(i=a.next()),c}if(_t(i)){const c=[];do c.push(i),i=a.next();while(_t(i));return p=>e(c,p)}return null}function s(){const c=[];let p=r();for(;p;)c.push(p),p=r();return l=>c.every(m=>m(l))}function o(){const c=[];let p=s();for(;p&&(c.push(p),i==="|"||i===",");){do i=a.next();while(i==="|"||i===",");p=s()}return l=>c.some(m=>m(l))}}function _t(n){return!!n&&!!n.match(/[\w\.:]+/)}function Zi(n){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,t=e.exec(n);return{next:()=>{if(!t)return null;const a=t[0];return t=e.exec(n),a}}}function ma(n){typeof n.dispose=="function"&&n.dispose()}var Ae=class{constructor(n){this.scopeName=n}toKey(){return this.scopeName}},Ii=class{constructor(n,e){this.scopeName=n,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},Ri=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(n){const e=n.toKey();this._seenReferenceKeys.has(e)||(this._seenReferenceKeys.add(e),this._references.push(n))}},Ui=class{constructor(n,e){this.repo=n,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Ae(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const n=this.Q;this.Q=[];const e=new Ri;for(const t of n)Li(t,this.initialScopeName,this.repo,e);for(const t of e.references)if(t instanceof Ae){if(this.seenFullScopeRequests.has(t.scopeName))continue;this.seenFullScopeRequests.add(t.scopeName),this.Q.push(t)}else{if(this.seenFullScopeRequests.has(t.scopeName)||this.seenPartialScopeRequests.has(t.toKey()))continue;this.seenPartialScopeRequests.add(t.toKey()),this.Q.push(t)}}};function Li(n,e,t,a){const i=t.lookup(n.scopeName);if(!i){if(n.scopeName===e)throw new Error(`No grammar provided for <${e}>`);return}const r=t.lookup(e);n instanceof Ae?Be({baseGrammar:r,selfGrammar:i},a):zn(n.ruleName,{baseGrammar:r,selfGrammar:i,repository:i.repository},a);const s=t.injections(n.scopeName);if(s)for(const o of s)a.add(new Ae(o))}function zn(n,e,t){if(e.repository&&e.repository[n]){const a=e.repository[n];Ye([a],e,t)}}function Be(n,e){n.selfGrammar.patterns&&Array.isArray(n.selfGrammar.patterns)&&Ye(n.selfGrammar.patterns,{...n,repository:n.selfGrammar.repository},e),n.selfGrammar.injections&&Ye(Object.values(n.selfGrammar.injections),{...n,repository:n.selfGrammar.repository},e)}function Ye(n,e,t){for(const a of n){if(t.visitedRule.has(a))continue;t.visitedRule.add(a);const i=a.repository?aa({},e.repository,a.repository):e.repository;Array.isArray(a.patterns)&&Ye(a.patterns,{...e,repository:i},t);const r=a.include;if(!r)continue;const s=ua(r);switch(s.kind){case 0:Be({...e,selfGrammar:e.baseGrammar},t);break;case 1:Be(e,t);break;case 2:zn(s.ruleName,{...e,repository:i},t);break;case 3:case 4:const o=s.scopeName===e.selfGrammar.scopeName?e.selfGrammar:s.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(o){const c={baseGrammar:e.baseGrammar,selfGrammar:o,repository:i};s.kind===4?zn(s.ruleName,c,t):Be(c,t)}else s.kind===4?t.add(new Ii(s.scopeName,s.ruleName)):t.add(new Ae(s.scopeName));break}}}var Wi=class{kind=0},Oi=class{kind=1},Pi=class{constructor(n){this.ruleName=n}kind=2},Gi=class{constructor(n){this.scopeName=n}kind=3},Mi=class{constructor(n,e){this.scopeName=n,this.ruleName=e}kind=4};function ua(n){if(n==="$base")return new Wi;if(n==="$self")return new Oi;const e=n.indexOf("#");if(e===-1)return new Gi(n);if(e===0)return new Pi(n.substring(1));{const t=n.substring(0,e),a=n.substring(e+1);return new Mi(t,a)}}var Di=/\\(\d+)/,ht=/\\(\d+)/g,Bi=-1,da=-2;var Se=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(n,e,t,a){this.$location=n,this.id=e,this._name=t||null,this._nameIsCapturing=Le.hasCaptures(this._name),this._contentName=a||null,this._contentNameIsCapturing=Le.hasCaptures(this._contentName)}get debugName(){const n=this.$location?`${ia(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${n}`}getName(n,e){return!this._nameIsCapturing||this._name===null||n===null||e===null?this._name:Le.replaceCaptures(this._name,n,e)}getContentName(n,e){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Le.replaceCaptures(this._contentName,n,e)}},Hi=class extends Se{retokenizeCapturedWithRuleId;constructor(n,e,t,a,i){super(n,e,t,a),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(n,e){throw new Error("Not supported!")}compile(n,e){throw new Error("Not supported!")}compileAG(n,e,t,a){throw new Error("Not supported!")}},Xi=class extends Se{_match;captures;_cachedCompiledPatterns;constructor(n,e,t,a,i){super(n,e,t,null),this._match=new Ee(a,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(n,e){e.push(this._match)}compile(n,e){return this._getCachedCompiledPatterns(n).compile(n)}compileAG(n,e,t,a){return this._getCachedCompiledPatterns(n).compileAG(n,t,a)}_getCachedCompiledPatterns(n){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new qe,this.collectPatterns(n,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},ft=class extends Se{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(n,e,t,a,i){super(n,e,t,a),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(n,e){for(const t of this.patterns)n.getRule(t).collectPatterns(n,e)}compile(n,e){return this._getCachedCompiledPatterns(n).compile(n)}compileAG(n,e,t,a){return this._getCachedCompiledPatterns(n).compileAG(n,t,a)}_getCachedCompiledPatterns(n){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new qe,this.collectPatterns(n,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Sn=class extends Se{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(n,e,t,a,i,r,s,o,c,p){super(n,e,t,a),this._begin=new Ee(i,this.id),this.beginCaptures=r,this._end=new Ee(s||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=o,this.applyEndPatternLast=c||!1,this.patterns=p.patterns,this.hasMissingPatterns=p.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(n,e){return this._end.resolveBackReferences(n,e)}collectPatterns(n,e){e.push(this._begin)}compile(n,e){return this._getCachedCompiledPatterns(n,e).compile(n)}compileAG(n,e,t,a){return this._getCachedCompiledPatterns(n,e).compileAG(n,t,a)}_getCachedCompiledPatterns(n,e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new qe;for(const t of this.patterns)n.getRule(t).collectPatterns(n,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,e):this._cachedCompiledPatterns.setSource(0,e)),this._cachedCompiledPatterns}},Ke=class extends Se{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(n,e,t,a,i,r,s,o,c){super(n,e,t,a),this._begin=new Ee(i,this.id),this.beginCaptures=r,this.whileCaptures=o,this._while=new Ee(s,da),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(n,e){return this._while.resolveBackReferences(n,e)}collectPatterns(n,e){e.push(this._begin)}compile(n,e){return this._getCachedCompiledPatterns(n).compile(n)}compileAG(n,e,t,a){return this._getCachedCompiledPatterns(n).compileAG(n,t,a)}_getCachedCompiledPatterns(n){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new qe;for(const e of this.patterns)n.getRule(e).collectPatterns(n,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(n,e){return this._getCachedCompiledWhilePatterns(n,e).compile(n)}compileWhileAG(n,e,t,a){return this._getCachedCompiledWhilePatterns(n,e).compileAG(n,t,a)}_getCachedCompiledWhilePatterns(n,e){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new qe,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,e||"￿"),this._cachedCompiledWhilePatterns}},ba=class T{static createCaptureRule(e,t,a,i,r){return e.registerRule(s=>new Hi(t,s,a,i,r))}static getCompiledRuleId(e,t,a){return e.id||t.registerRule(i=>{if(e.id=i,e.match)return new Xi(e.$vscodeTextmateLocation,e.id,e.name,e.match,T._compileCaptures(e.captures,t,a));if(typeof e.begin>"u"){e.repository&&(a=aa({},a,e.repository));let r=e.patterns;return typeof r>"u"&&e.include&&(r=[{include:e.include}]),new ft(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,T._compilePatterns(r,t,a))}return e.while?new Ke(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,T._compileCaptures(e.beginCaptures||e.captures,t,a),e.while,T._compileCaptures(e.whileCaptures||e.captures,t,a),T._compilePatterns(e.patterns,t,a)):new Sn(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,T._compileCaptures(e.beginCaptures||e.captures,t,a),e.end,T._compileCaptures(e.endCaptures||e.captures,t,a),e.applyEndPatternLast,T._compilePatterns(e.patterns,t,a))}),e.id}static _compileCaptures(e,t,a){let i=[];if(e){let r=0;for(const s in e){if(s==="$vscodeTextmateLocation")continue;const o=parseInt(s,10);o>r&&(r=o)}for(let s=0;s<=r;s++)i[s]=null;for(const s in e){if(s==="$vscodeTextmateLocation")continue;const o=parseInt(s,10);let c=0;e[s].patterns&&(c=T.getCompiledRuleId(e[s],t,a)),i[o]=T.createCaptureRule(t,e[s].$vscodeTextmateLocation,e[s].name,e[s].contentName,c)}}return i}static _compilePatterns(e,t,a){let i=[];if(e)for(let r=0,s=e.length;r<s;r++){const o=e[r];let c=-1;if(o.include){const p=ua(o.include);switch(p.kind){case 0:case 1:c=T.getCompiledRuleId(a[o.include],t,a);break;case 2:let l=a[p.ruleName];l&&(c=T.getCompiledRuleId(l,t,a));break;case 3:case 4:const m=p.scopeName,u=p.kind===4?p.ruleName:null,b=t.getExternalGrammar(m,a);if(b)if(u){let d=b.repository[u];d&&(c=T.getCompiledRuleId(d,t,b.repository))}else c=T.getCompiledRuleId(b.repository.$self,t,b.repository);break}}else c=T.getCompiledRuleId(o,t,a);if(c!==-1){const p=t.getRule(c);let l=!1;if((p instanceof ft||p instanceof Sn||p instanceof Ke)&&p.hasMissingPatterns&&p.patterns.length===0&&(l=!0),l)continue;i.push(c)}}return{patterns:i,hasMissingPatterns:(e?e.length:0)!==i.length}}},Ee=class ga{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&typeof e=="string"){const a=e.length;let i=0,r=[],s=!1;for(let o=0;o<a;o++)if(e.charAt(o)==="\\"&&o+1<a){const p=e.charAt(o+1);p==="z"?(r.push(e.substring(i,o)),r.push("$(?!\\n)(?<!\\n)"),i=o+2):(p==="A"||p==="G")&&(s=!0),o++}this.hasAnchor=s,i===0?this.source=e:(r.push(e.substring(i,a)),this.source=r.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=t,typeof this.source=="string"?this.hasBackReferences=Di.test(this.source):this.hasBackReferences=!1}clone(){return new ga(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let a=t.map(i=>e.substring(i.start,i.end));return ht.lastIndex=0,this.source.replace(ht,(i,r)=>oa(a[parseInt(r,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let e=[],t=[],a=[],i=[],r,s,o,c;for(r=0,s=this.source.length;r<s;r++)o=this.source.charAt(r),e[r]=o,t[r]=o,a[r]=o,i[r]=o,o==="\\"&&r+1<s&&(c=this.source.charAt(r+1),c==="A"?(e[r+1]="￿",t[r+1]="￿",a[r+1]="A",i[r+1]="A"):c==="G"?(e[r+1]="￿",t[r+1]="G",a[r+1]="￿",i[r+1]="G"):(e[r+1]=c,t[r+1]=c,a[r+1]=c,i[r+1]=c),r++);return{A0_G0:e.join(""),A0_G1:t.join(""),A1_G0:a.join(""),A1_G1:i.join("")}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},qe=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(n){this._items.push(n),this._hasAnchors=this._hasAnchors||n.hasAnchor}unshift(n){this._items.unshift(n),this._hasAnchors=this._hasAnchors||n.hasAnchor}length(){return this._items.length}setSource(n,e){this._items[n].source!==e&&(this._disposeCaches(),this._items[n].setSource(e))}compile(n){if(!this._cached){let e=this._items.map(t=>t.source);this._cached=new yt(n,e,this._items.map(t=>t.ruleId))}return this._cached}compileAG(n,e,t){return this._hasAnchors?e?t?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(n,e,t)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(n,e,t)),this._anchorCache.A1_G0):t?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(n,e,t)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(n,e,t)),this._anchorCache.A0_G0):this.compile(n)}_resolveAnchors(n,e,t){let a=this._items.map(i=>i.resolveAnchors(e,t));return new yt(n,a,this._items.map(i=>i.ruleId))}},yt=class{constructor(n,e,t){this.regExps=e,this.rules=t,this.scanner=n.createOnigScanner(e)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const n=[];for(let e=0,t=this.rules.length;e<t;e++)n.push(" - "+this.rules[e]+": "+this.regExps[e]);return n.join(`
1
+ import{r as H,j as K}from"./main-BlX7CS2-.js";import{B as yi,H as ki,X as wi,x as xi,c as Ue}from"./button-BcnCTjUT.js";import{c as $i}from"./react-ONC2UaeC.js";let S=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function vi(n){return Yn(n)}function Yn(n){return Array.isArray(n)?Ci(n):n instanceof RegExp?n:typeof n=="object"?ji(n):n}function Ci(n){let e=[];for(let t=0,a=n.length;t<a;t++)e[t]=Yn(n[t]);return e}function ji(n){let e={};for(let t in n)e[t]=Yn(n[t]);return e}function aa(n,...e){return e.forEach(t=>{for(let a in t)n[a]=t[a]}),n}function ia(n){const e=~n.lastIndexOf("/")||~n.lastIndexOf("\\");return e===0?n:~e===n.length-1?ia(n.substring(0,n.length-1)):n.substr(~e+1)}var bn=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Le=class{static hasCaptures(n){return n===null?!1:(bn.lastIndex=0,bn.test(n))}static replaceCaptures(n,e,t){return n.replace(bn,(a,i,r,s)=>{let o=t[parseInt(i||r,10)];if(o){let c=e.substring(o.start,o.end);for(;c[0]===".";)c=c.substring(1);switch(s){case"downcase":return c.toLowerCase();case"upcase":return c.toUpperCase();default:return c}}else return a})}};function ra(n,e){return n<e?-1:n>e?1:0}function sa(n,e){if(n===null&&e===null)return 0;if(!n)return-1;if(!e)return 1;let t=n.length,a=e.length;if(t===a){for(let i=0;i<t;i++){let r=ra(n[i],e[i]);if(r!==0)return r}return 0}return t-a}function gt(n){return!!(/^#[0-9a-f]{6}$/i.test(n)||/^#[0-9a-f]{8}$/i.test(n)||/^#[0-9a-f]{3}$/i.test(n)||/^#[0-9a-f]{4}$/i.test(n))}function oa(n){return n.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var ca=class{constructor(n){this.fn=n}cache=new Map;get(n){if(this.cache.has(n))return this.cache.get(n);const e=this.fn(n);return this.cache.set(n,e),e}},Xe=class{constructor(n,e,t){this._colorMap=n,this._defaults=e,this._root=t}static createFromRawTheme(n,e){return this.createFromParsedTheme(qi(n),e)}static createFromParsedTheme(n,e){return zi(n,e)}_cachedMatchRoot=new ca(n=>this._root.match(n));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(n){if(n===null)return this._defaults;const e=n.scopeName,a=this._cachedMatchRoot.get(e).find(i=>Ai(n.parent,i.parentScopes));return a?new pa(a.fontStyle,a.foreground,a.background):null}},gn=class De{constructor(e,t){this.parent=e,this.scopeName=t}static push(e,t){for(const a of t)e=new De(e,a);return e}static from(...e){let t=null;for(let a=0;a<e.length;a++)t=new De(t,e[a]);return t}push(e){return new De(this,e)}getSegments(){let e=this;const t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(" ")}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){const t=[];let a=this;for(;a&&a!==e;)t.push(a.scopeName),a=a.parent;return a===e?t.reverse():void 0}};function Ai(n,e){if(e.length===0)return!0;for(let t=0;t<e.length;t++){let a=e[t],i=!1;if(a===">"){if(t===e.length-1)return!1;a=e[++t],i=!0}for(;n&&!Ei(n.scopeName,a);){if(i)return!1;n=n.parent}if(!n)return!1;n=n.parent}return!0}function Ei(n,e){return e===n||n.startsWith(e)&&n[e.length]==="."}var pa=class{constructor(n,e,t){this.fontStyle=n,this.foregroundId=e,this.backgroundId=t}};function qi(n){if(!n)return[];if(!n.settings||!Array.isArray(n.settings))return[];let e=n.settings,t=[],a=0;for(let i=0,r=e.length;i<r;i++){let s=e[i];if(!s.settings)continue;let o;if(typeof s.scope=="string"){let m=s.scope;m=m.replace(/^[,]+/,""),m=m.replace(/[,]+$/,""),o=m.split(",")}else Array.isArray(s.scope)?o=s.scope:o=[""];let c=-1;if(typeof s.settings.fontStyle=="string"){c=0;let m=s.settings.fontStyle.split(" ");for(let u=0,b=m.length;u<b;u++)switch(m[u]){case"italic":c=c|1;break;case"bold":c=c|2;break;case"underline":c=c|4;break;case"strikethrough":c=c|8;break}}let p=null;typeof s.settings.foreground=="string"&&gt(s.settings.foreground)&&(p=s.settings.foreground);let l=null;typeof s.settings.background=="string"&&gt(s.settings.background)&&(l=s.settings.background);for(let m=0,u=o.length;m<u;m++){let d=o[m].trim().split(" "),y=d[d.length-1],g=null;d.length>1&&(g=d.slice(0,d.length-1),g.reverse()),t[a++]=new Fi(y,g,i,c,p,l)}}return t}var Fi=class{constructor(n,e,t,a,i,r){this.scope=n,this.parentScopes=e,this.index=t,this.fontStyle=a,this.foreground=i,this.background=r}},Z=(n=>(n[n.NotSet=-1]="NotSet",n[n.None=0]="None",n[n.Italic=1]="Italic",n[n.Bold=2]="Bold",n[n.Underline=4]="Underline",n[n.Strikethrough=8]="Strikethrough",n))(Z||{});function zi(n,e){n.sort((c,p)=>{let l=ra(c.scope,p.scope);return l!==0||(l=sa(c.parentScopes,p.parentScopes),l!==0)?l:c.index-p.index});let t=0,a="#000000",i="#ffffff";for(;n.length>=1&&n[0].scope==="";){let c=n.shift();c.fontStyle!==-1&&(t=c.fontStyle),c.foreground!==null&&(a=c.foreground),c.background!==null&&(i=c.background)}let r=new Si(e),s=new pa(t,r.getId(a),r.getId(i)),o=new Ti(new qn(0,null,-1,0,0),[]);for(let c=0,p=n.length;c<p;c++){let l=n[c];o.insert(0,l.scope,l.parentScopes,l.fontStyle,r.getId(l.foreground),r.getId(l.background))}return new Xe(r,s,o)}var Si=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(n){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(n)){this._isFrozen=!0;for(let e=0,t=n.length;e<t;e++)this._color2id[n[e]]=e,this._id2color[e]=n[e]}else this._isFrozen=!1}getId(n){if(n===null)return 0;n=n.toUpperCase();let e=this._color2id[n];if(e)return e;if(this._isFrozen)throw new Error(`Missing color in color map - ${n}`);return e=++this._lastColorId,this._color2id[n]=e,this._id2color[e]=n,e}getColorMap(){return this._id2color.slice(0)}},Ni=Object.freeze([]),qn=class la{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,a,i,r){this.scopeDepth=e,this.parentScopes=t||Ni,this.fontStyle=a,this.foreground=i,this.background=r}clone(){return new la(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let a=0,i=e.length;a<i;a++)t[a]=e[a].clone();return t}acceptOverwrite(e,t,a,i){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),a!==0&&(this.foreground=a),i!==0&&(this.background=i)}},Ti=class Fn{constructor(e,t=[],a={}){this._mainRule=e,this._children=a,this._rulesWithParentScopes=t}_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let a=0,i=0;for(;e.parentScopes[a]===">"&&a++,t.parentScopes[i]===">"&&i++,!(a>=e.parentScopes.length||i>=t.parentScopes.length);){const r=t.parentScopes[i].length-e.parentScopes[a].length;if(r!==0)return r;a++,i++}return t.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let a=e.indexOf("."),i,r;if(a===-1?(i=e,r=""):(i=e.substring(0,a),r=e.substring(a+1)),this._children.hasOwnProperty(i))return this._children[i].match(r)}const t=this._rulesWithParentScopes.concat(this._mainRule);return t.sort(Fn._cmpBySpecificity),t}insert(e,t,a,i,r,s){if(t===""){this._doInsertHere(e,a,i,r,s);return}let o=t.indexOf("."),c,p;o===-1?(c=t,p=""):(c=t.substring(0,o),p=t.substring(o+1));let l;this._children.hasOwnProperty(c)?l=this._children[c]:(l=new Fn(this._mainRule.clone(),qn.cloneArr(this._rulesWithParentScopes)),this._children[c]=l),l.insert(e+1,p,a,i,r,s)}_doInsertHere(e,t,a,i,r){if(t===null){this._mainRule.acceptOverwrite(e,a,i,r);return}for(let s=0,o=this._rulesWithParentScopes.length;s<o;s++){let c=this._rulesWithParentScopes[s];if(sa(c.parentScopes,t)===0){c.acceptOverwrite(e,a,i,r);return}}a===-1&&(a=this._mainRule.fontStyle),i===0&&(i=this._mainRule.foreground),r===0&&(r=this._mainRule.background),this._rulesWithParentScopes.push(new qn(e,t,a,i,r))}},_e=class U{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){const t=U.getLanguageId(e),a=U.getTokenType(e),i=U.getFontStyle(e),r=U.getForeground(e),s=U.getBackground(e);console.log({languageId:t,tokenType:a,fontStyle:i,foreground:r,background:s})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!==0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(e,t,a,i,r,s,o){let c=U.getLanguageId(e),p=U.getTokenType(e),l=U.containsBalancedBrackets(e)?1:0,m=U.getFontStyle(e),u=U.getForeground(e),b=U.getBackground(e);return t!==0&&(c=t),a!==8&&(p=a),i!==null&&(l=i?1:0),r!==-1&&(m=r),s!==0&&(u=s),o!==0&&(b=o),(c<<0|p<<8|l<<10|m<<11|u<<15|b<<24)>>>0}};function Ve(n,e){const t=[],a=Zi(n);let i=a.next();for(;i!==null;){let c=0;if(i.length===2&&i.charAt(1)===":"){switch(i.charAt(0)){case"R":c=1;break;case"L":c=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=a.next()}let p=s();if(t.push({matcher:p,priority:c}),i!==",")break;i=a.next()}return t;function r(){if(i==="-"){i=a.next();const c=r();return p=>!!c&&!c(p)}if(i==="("){i=a.next();const c=o();return i===")"&&(i=a.next()),c}if(_t(i)){const c=[];do c.push(i),i=a.next();while(_t(i));return p=>e(c,p)}return null}function s(){const c=[];let p=r();for(;p;)c.push(p),p=r();return l=>c.every(m=>m(l))}function o(){const c=[];let p=s();for(;p&&(c.push(p),i==="|"||i===",");){do i=a.next();while(i==="|"||i===",");p=s()}return l=>c.some(m=>m(l))}}function _t(n){return!!n&&!!n.match(/[\w\.:]+/)}function Zi(n){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,t=e.exec(n);return{next:()=>{if(!t)return null;const a=t[0];return t=e.exec(n),a}}}function ma(n){typeof n.dispose=="function"&&n.dispose()}var Ae=class{constructor(n){this.scopeName=n}toKey(){return this.scopeName}},Ii=class{constructor(n,e){this.scopeName=n,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},Ri=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(n){const e=n.toKey();this._seenReferenceKeys.has(e)||(this._seenReferenceKeys.add(e),this._references.push(n))}},Ui=class{constructor(n,e){this.repo=n,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Ae(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const n=this.Q;this.Q=[];const e=new Ri;for(const t of n)Li(t,this.initialScopeName,this.repo,e);for(const t of e.references)if(t instanceof Ae){if(this.seenFullScopeRequests.has(t.scopeName))continue;this.seenFullScopeRequests.add(t.scopeName),this.Q.push(t)}else{if(this.seenFullScopeRequests.has(t.scopeName)||this.seenPartialScopeRequests.has(t.toKey()))continue;this.seenPartialScopeRequests.add(t.toKey()),this.Q.push(t)}}};function Li(n,e,t,a){const i=t.lookup(n.scopeName);if(!i){if(n.scopeName===e)throw new Error(`No grammar provided for <${e}>`);return}const r=t.lookup(e);n instanceof Ae?Be({baseGrammar:r,selfGrammar:i},a):zn(n.ruleName,{baseGrammar:r,selfGrammar:i,repository:i.repository},a);const s=t.injections(n.scopeName);if(s)for(const o of s)a.add(new Ae(o))}function zn(n,e,t){if(e.repository&&e.repository[n]){const a=e.repository[n];Ye([a],e,t)}}function Be(n,e){n.selfGrammar.patterns&&Array.isArray(n.selfGrammar.patterns)&&Ye(n.selfGrammar.patterns,{...n,repository:n.selfGrammar.repository},e),n.selfGrammar.injections&&Ye(Object.values(n.selfGrammar.injections),{...n,repository:n.selfGrammar.repository},e)}function Ye(n,e,t){for(const a of n){if(t.visitedRule.has(a))continue;t.visitedRule.add(a);const i=a.repository?aa({},e.repository,a.repository):e.repository;Array.isArray(a.patterns)&&Ye(a.patterns,{...e,repository:i},t);const r=a.include;if(!r)continue;const s=ua(r);switch(s.kind){case 0:Be({...e,selfGrammar:e.baseGrammar},t);break;case 1:Be(e,t);break;case 2:zn(s.ruleName,{...e,repository:i},t);break;case 3:case 4:const o=s.scopeName===e.selfGrammar.scopeName?e.selfGrammar:s.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(o){const c={baseGrammar:e.baseGrammar,selfGrammar:o,repository:i};s.kind===4?zn(s.ruleName,c,t):Be(c,t)}else s.kind===4?t.add(new Ii(s.scopeName,s.ruleName)):t.add(new Ae(s.scopeName));break}}}var Wi=class{kind=0},Oi=class{kind=1},Pi=class{constructor(n){this.ruleName=n}kind=2},Gi=class{constructor(n){this.scopeName=n}kind=3},Mi=class{constructor(n,e){this.scopeName=n,this.ruleName=e}kind=4};function ua(n){if(n==="$base")return new Wi;if(n==="$self")return new Oi;const e=n.indexOf("#");if(e===-1)return new Gi(n);if(e===0)return new Pi(n.substring(1));{const t=n.substring(0,e),a=n.substring(e+1);return new Mi(t,a)}}var Di=/\\(\d+)/,ht=/\\(\d+)/g,Bi=-1,da=-2;var Se=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(n,e,t,a){this.$location=n,this.id=e,this._name=t||null,this._nameIsCapturing=Le.hasCaptures(this._name),this._contentName=a||null,this._contentNameIsCapturing=Le.hasCaptures(this._contentName)}get debugName(){const n=this.$location?`${ia(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${n}`}getName(n,e){return!this._nameIsCapturing||this._name===null||n===null||e===null?this._name:Le.replaceCaptures(this._name,n,e)}getContentName(n,e){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Le.replaceCaptures(this._contentName,n,e)}},Hi=class extends Se{retokenizeCapturedWithRuleId;constructor(n,e,t,a,i){super(n,e,t,a),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(n,e){throw new Error("Not supported!")}compile(n,e){throw new Error("Not supported!")}compileAG(n,e,t,a){throw new Error("Not supported!")}},Xi=class extends Se{_match;captures;_cachedCompiledPatterns;constructor(n,e,t,a,i){super(n,e,t,null),this._match=new Ee(a,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(n,e){e.push(this._match)}compile(n,e){return this._getCachedCompiledPatterns(n).compile(n)}compileAG(n,e,t,a){return this._getCachedCompiledPatterns(n).compileAG(n,t,a)}_getCachedCompiledPatterns(n){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new qe,this.collectPatterns(n,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},ft=class extends Se{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(n,e,t,a,i){super(n,e,t,a),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(n,e){for(const t of this.patterns)n.getRule(t).collectPatterns(n,e)}compile(n,e){return this._getCachedCompiledPatterns(n).compile(n)}compileAG(n,e,t,a){return this._getCachedCompiledPatterns(n).compileAG(n,t,a)}_getCachedCompiledPatterns(n){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new qe,this.collectPatterns(n,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Sn=class extends Se{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(n,e,t,a,i,r,s,o,c,p){super(n,e,t,a),this._begin=new Ee(i,this.id),this.beginCaptures=r,this._end=new Ee(s||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=o,this.applyEndPatternLast=c||!1,this.patterns=p.patterns,this.hasMissingPatterns=p.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(n,e){return this._end.resolveBackReferences(n,e)}collectPatterns(n,e){e.push(this._begin)}compile(n,e){return this._getCachedCompiledPatterns(n,e).compile(n)}compileAG(n,e,t,a){return this._getCachedCompiledPatterns(n,e).compileAG(n,t,a)}_getCachedCompiledPatterns(n,e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new qe;for(const t of this.patterns)n.getRule(t).collectPatterns(n,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,e):this._cachedCompiledPatterns.setSource(0,e)),this._cachedCompiledPatterns}},Ke=class extends Se{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(n,e,t,a,i,r,s,o,c){super(n,e,t,a),this._begin=new Ee(i,this.id),this.beginCaptures=r,this.whileCaptures=o,this._while=new Ee(s,da),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(n,e){return this._while.resolveBackReferences(n,e)}collectPatterns(n,e){e.push(this._begin)}compile(n,e){return this._getCachedCompiledPatterns(n).compile(n)}compileAG(n,e,t,a){return this._getCachedCompiledPatterns(n).compileAG(n,t,a)}_getCachedCompiledPatterns(n){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new qe;for(const e of this.patterns)n.getRule(e).collectPatterns(n,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(n,e){return this._getCachedCompiledWhilePatterns(n,e).compile(n)}compileWhileAG(n,e,t,a){return this._getCachedCompiledWhilePatterns(n,e).compileAG(n,t,a)}_getCachedCompiledWhilePatterns(n,e){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new qe,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,e||"￿"),this._cachedCompiledWhilePatterns}},ba=class T{static createCaptureRule(e,t,a,i,r){return e.registerRule(s=>new Hi(t,s,a,i,r))}static getCompiledRuleId(e,t,a){return e.id||t.registerRule(i=>{if(e.id=i,e.match)return new Xi(e.$vscodeTextmateLocation,e.id,e.name,e.match,T._compileCaptures(e.captures,t,a));if(typeof e.begin>"u"){e.repository&&(a=aa({},a,e.repository));let r=e.patterns;return typeof r>"u"&&e.include&&(r=[{include:e.include}]),new ft(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,T._compilePatterns(r,t,a))}return e.while?new Ke(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,T._compileCaptures(e.beginCaptures||e.captures,t,a),e.while,T._compileCaptures(e.whileCaptures||e.captures,t,a),T._compilePatterns(e.patterns,t,a)):new Sn(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,T._compileCaptures(e.beginCaptures||e.captures,t,a),e.end,T._compileCaptures(e.endCaptures||e.captures,t,a),e.applyEndPatternLast,T._compilePatterns(e.patterns,t,a))}),e.id}static _compileCaptures(e,t,a){let i=[];if(e){let r=0;for(const s in e){if(s==="$vscodeTextmateLocation")continue;const o=parseInt(s,10);o>r&&(r=o)}for(let s=0;s<=r;s++)i[s]=null;for(const s in e){if(s==="$vscodeTextmateLocation")continue;const o=parseInt(s,10);let c=0;e[s].patterns&&(c=T.getCompiledRuleId(e[s],t,a)),i[o]=T.createCaptureRule(t,e[s].$vscodeTextmateLocation,e[s].name,e[s].contentName,c)}}return i}static _compilePatterns(e,t,a){let i=[];if(e)for(let r=0,s=e.length;r<s;r++){const o=e[r];let c=-1;if(o.include){const p=ua(o.include);switch(p.kind){case 0:case 1:c=T.getCompiledRuleId(a[o.include],t,a);break;case 2:let l=a[p.ruleName];l&&(c=T.getCompiledRuleId(l,t,a));break;case 3:case 4:const m=p.scopeName,u=p.kind===4?p.ruleName:null,b=t.getExternalGrammar(m,a);if(b)if(u){let d=b.repository[u];d&&(c=T.getCompiledRuleId(d,t,b.repository))}else c=T.getCompiledRuleId(b.repository.$self,t,b.repository);break}}else c=T.getCompiledRuleId(o,t,a);if(c!==-1){const p=t.getRule(c);let l=!1;if((p instanceof ft||p instanceof Sn||p instanceof Ke)&&p.hasMissingPatterns&&p.patterns.length===0&&(l=!0),l)continue;i.push(c)}}return{patterns:i,hasMissingPatterns:(e?e.length:0)!==i.length}}},Ee=class ga{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&typeof e=="string"){const a=e.length;let i=0,r=[],s=!1;for(let o=0;o<a;o++)if(e.charAt(o)==="\\"&&o+1<a){const p=e.charAt(o+1);p==="z"?(r.push(e.substring(i,o)),r.push("$(?!\\n)(?<!\\n)"),i=o+2):(p==="A"||p==="G")&&(s=!0),o++}this.hasAnchor=s,i===0?this.source=e:(r.push(e.substring(i,a)),this.source=r.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=t,typeof this.source=="string"?this.hasBackReferences=Di.test(this.source):this.hasBackReferences=!1}clone(){return new ga(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let a=t.map(i=>e.substring(i.start,i.end));return ht.lastIndex=0,this.source.replace(ht,(i,r)=>oa(a[parseInt(r,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let e=[],t=[],a=[],i=[],r,s,o,c;for(r=0,s=this.source.length;r<s;r++)o=this.source.charAt(r),e[r]=o,t[r]=o,a[r]=o,i[r]=o,o==="\\"&&r+1<s&&(c=this.source.charAt(r+1),c==="A"?(e[r+1]="￿",t[r+1]="￿",a[r+1]="A",i[r+1]="A"):c==="G"?(e[r+1]="￿",t[r+1]="G",a[r+1]="￿",i[r+1]="G"):(e[r+1]=c,t[r+1]=c,a[r+1]=c,i[r+1]=c),r++);return{A0_G0:e.join(""),A0_G1:t.join(""),A1_G0:a.join(""),A1_G1:i.join("")}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},qe=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(n){this._items.push(n),this._hasAnchors=this._hasAnchors||n.hasAnchor}unshift(n){this._items.unshift(n),this._hasAnchors=this._hasAnchors||n.hasAnchor}length(){return this._items.length}setSource(n,e){this._items[n].source!==e&&(this._disposeCaches(),this._items[n].setSource(e))}compile(n){if(!this._cached){let e=this._items.map(t=>t.source);this._cached=new yt(n,e,this._items.map(t=>t.ruleId))}return this._cached}compileAG(n,e,t){return this._hasAnchors?e?t?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(n,e,t)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(n,e,t)),this._anchorCache.A1_G0):t?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(n,e,t)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(n,e,t)),this._anchorCache.A0_G0):this.compile(n)}_resolveAnchors(n,e,t){let a=this._items.map(i=>i.resolveAnchors(e,t));return new yt(n,a,this._items.map(i=>i.ruleId))}},yt=class{constructor(n,e,t){this.regExps=e,this.rules=t,this.scanner=n.createOnigScanner(e)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const n=[];for(let e=0,t=this.rules.length;e<t;e++)n.push(" - "+this.rules[e]+": "+this.regExps[e]);return n.join(`
2
2
  `)}findNextMatchSync(n,e,t){const a=this.scanner.findNextMatchSync(n,e,t);return a?{ruleId:this.rules[a.index],captureIndices:a.captureIndices}:null}},_n=class{constructor(n,e){this.languageId=n,this.tokenType=e}},Vi=class Nn{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,t){this._defaultAttributes=new _n(e,8),this._embeddedLanguagesMatcher=new Yi(Object.entries(t||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(e){return e===null?Nn._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(e)}static _NULL_SCOPE_METADATA=new _n(0,0);_getBasicScopeAttributes=new ca(e=>{const t=this._scopeToLanguage(e),a=this._toStandardTokenType(e);return new _n(t,a)});_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(e){const t=e.match(Nn.STANDARD_TOKEN_TYPE_REGEXP);if(!t)return 8;switch(t[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},Yi=class{values;scopesRegExp;constructor(n){if(n.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(n);const e=n.map(([t,a])=>oa(t));e.sort(),e.reverse(),this.scopesRegExp=new RegExp(`^((${e.join(")|(")}))($|\\.)`,"")}}match(n){if(!this.scopesRegExp)return;const e=n.match(this.scopesRegExp);if(e)return this.values.get(e[1])}},kt=class{constructor(n,e){this.stack=n,this.stoppedEarly=e}};function _a(n,e,t,a,i,r,s,o){const c=e.content.length;let p=!1,l=-1;if(s){const b=Ki(n,e,t,a,i,r);i=b.stack,a=b.linePos,t=b.isFirstLine,l=b.anchorPosition}const m=Date.now();for(;!p;){if(o!==0&&Date.now()-m>o)return new kt(i,!0);u()}return new kt(i,!1);function u(){const b=Ji(n,e,t,a,i,l);if(!b){r.produce(i,c),p=!0;return}const d=b.captureIndices,y=b.matchedRuleId,g=d&&d.length>0?d[0].end>a:!1;if(y===Bi){const _=i.getRule(n);r.produce(i,d[0].start),i=i.withContentNameScopesList(i.nameScopesList),ve(n,e,t,i,r,_.endCaptures,d),r.produce(i,d[0].end);const k=i;if(i=i.parent,l=k.getAnchorPos(),!g&&k.getEnterPos()===a){i=k,r.produce(i,c),p=!0;return}}else{const _=n.getRule(y);r.produce(i,d[0].start);const k=i,f=_.getName(e.content,d),w=i.contentNameScopesList.pushAttributed(f,n);if(i=i.push(y,a,l,d[0].end===c,null,w,w),_ instanceof Sn){const x=_;ve(n,e,t,i,r,x.beginCaptures,d),r.produce(i,d[0].end),l=d[0].end;const j=x.getContentName(e.content,d),z=w.pushAttributed(j,n);if(i=i.withContentNameScopesList(z),x.endHasBackReferences&&(i=i.withEndRule(x.getEndWithResolvedBackReferences(e.content,d))),!g&&k.hasSameRuleAs(i)){i=i.pop(),r.produce(i,c),p=!0;return}}else if(_ instanceof Ke){const x=_;ve(n,e,t,i,r,x.beginCaptures,d),r.produce(i,d[0].end),l=d[0].end;const j=x.getContentName(e.content,d),z=w.pushAttributed(j,n);if(i=i.withContentNameScopesList(z),x.whileHasBackReferences&&(i=i.withEndRule(x.getWhileWithResolvedBackReferences(e.content,d))),!g&&k.hasSameRuleAs(i)){i=i.pop(),r.produce(i,c),p=!0;return}}else if(ve(n,e,t,i,r,_.captures,d),r.produce(i,d[0].end),i=i.pop(),!g){i=i.safePop(),r.produce(i,c),p=!0;return}}d[0].end>a&&(a=d[0].end,t=!1)}}function Ki(n,e,t,a,i,r){let s=i.beginRuleCapturedEOL?0:-1;const o=[];for(let c=i;c;c=c.pop()){const p=c.getRule(n);p instanceof Ke&&o.push({rule:p,stack:c})}for(let c=o.pop();c;c=o.pop()){const{ruleScanner:p,findOptions:l}=nr(c.rule,n,c.stack.endRule,t,a===s),m=p.findNextMatchSync(e,a,l);if(m){if(m.ruleId!==da){i=c.stack.pop();break}m.captureIndices&&m.captureIndices.length&&(r.produce(c.stack,m.captureIndices[0].start),ve(n,e,t,c.stack,r,c.rule.whileCaptures,m.captureIndices),r.produce(c.stack,m.captureIndices[0].end),s=m.captureIndices[0].end,m.captureIndices[0].end>a&&(a=m.captureIndices[0].end,t=!1))}else{i=c.stack.pop();break}}return{stack:i,linePos:a,anchorPosition:s,isFirstLine:t}}function Ji(n,e,t,a,i,r){const s=Qi(n,e,t,a,i,r),o=n.getInjections();if(o.length===0)return s;const c=er(o,n,e,t,a,i,r);if(!c)return s;if(!s)return c;const p=s.captureIndices[0].start,l=c.captureIndices[0].start;return l<p||c.priorityMatch&&l===p?c:s}function Qi(n,e,t,a,i,r){const s=i.getRule(n),{ruleScanner:o,findOptions:c}=ha(s,n,i.endRule,t,a===r),p=o.findNextMatchSync(e,a,c);return p?{captureIndices:p.captureIndices,matchedRuleId:p.ruleId}:null}function er(n,e,t,a,i,r,s){let o=Number.MAX_VALUE,c=null,p,l=0;const m=r.contentNameScopesList.getScopeNames();for(let u=0,b=n.length;u<b;u++){const d=n[u];if(!d.matcher(m))continue;const y=e.getRule(d.ruleId),{ruleScanner:g,findOptions:_}=ha(y,e,null,a,i===s),k=g.findNextMatchSync(t,i,_);if(!k)continue;const f=k.captureIndices[0].start;if(!(f>=o)&&(o=f,c=k.captureIndices,p=k.ruleId,l=d.priority,o===i))break}return c?{priorityMatch:l===-1,captureIndices:c,matchedRuleId:p}:null}function ha(n,e,t,a,i){return{ruleScanner:n.compileAG(e,t,a,i),findOptions:0}}function nr(n,e,t,a,i){return{ruleScanner:n.compileWhileAG(e,t,a,i),findOptions:0}}function ve(n,e,t,a,i,r,s){if(r.length===0)return;const o=e.content,c=Math.min(r.length,s.length),p=[],l=s[0].end;for(let m=0;m<c;m++){const u=r[m];if(u===null)continue;const b=s[m];if(b.length===0)continue;if(b.start>l)break;for(;p.length>0&&p[p.length-1].endPos<=b.start;)i.produceFromScopes(p[p.length-1].scopes,p[p.length-1].endPos),p.pop();if(p.length>0?i.produceFromScopes(p[p.length-1].scopes,b.start):i.produce(a,b.start),u.retokenizeCapturedWithRuleId){const y=u.getName(o,s),g=a.contentNameScopesList.pushAttributed(y,n),_=u.getContentName(o,s),k=g.pushAttributed(_,n),f=a.push(u.retokenizeCapturedWithRuleId,b.start,-1,!1,null,g,k),w=n.createOnigString(o.substring(0,b.end));_a(n,w,t&&b.start===0,b.start,f,i,!1,0),ma(w);continue}const d=u.getName(o,s);if(d!==null){const g=(p.length>0?p[p.length-1].scopes:a.contentNameScopesList).pushAttributed(d,n);p.push(new tr(g,b.end))}}for(;p.length>0;)i.produceFromScopes(p[p.length-1].scopes,p[p.length-1].endPos),p.pop()}var tr=class{scopes;endPos;constructor(n,e){this.scopes=n,this.endPos=e}};function ar(n,e,t,a,i,r,s,o){return new rr(n,e,t,a,i,r,s,o)}function wt(n,e,t,a,i){const r=Ve(e,Je),s=ba.getCompiledRuleId(t,a,i.repository);for(const o of r)n.push({debugSelector:e,matcher:o.matcher,ruleId:s,grammar:i,priority:o.priority})}function Je(n,e){if(e.length<n.length)return!1;let t=0;return n.every(a=>{for(let i=t;i<e.length;i++)if(ir(e[i],a))return t=i+1,!0;return!1})}function ir(n,e){if(!n)return!1;if(n===e)return!0;const t=e.length;return n.length>t&&n.substr(0,t)===e&&n[t]==="."}var rr=class{constructor(n,e,t,a,i,r,s,o){if(this._rootScopeName=n,this.balancedBracketSelectors=r,this._onigLib=o,this._basicScopeAttributesProvider=new Vi(t,a),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=s,this._grammar=xt(e,null),this._injections=null,this._tokenTypeMatchers=[],i)for(const c of Object.keys(i)){const p=Ve(c,Je);for(const l of p)this._tokenTypeMatchers.push({matcher:l.matcher,type:i[c]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(const n of this._ruleId2desc)n&&n.dispose()}createOnigScanner(n){return this._onigLib.createOnigScanner(n)}createOnigString(n){return this._onigLib.createOnigString(n)}getMetadataForScope(n){return this._basicScopeAttributesProvider.getBasicScopeAttributes(n)}_collectInjections(){const n={lookup:i=>i===this._rootScopeName?this._grammar:this.getExternalGrammar(i),injections:i=>this._grammarRepository.injections(i)},e=[],t=this._rootScopeName,a=n.lookup(t);if(a){const i=a.injections;if(i)for(let s in i)wt(e,s,i[s],this,a);const r=this._grammarRepository.injections(t);r&&r.forEach(s=>{const o=this.getExternalGrammar(s);if(o){const c=o.injectionSelector;c&&wt(e,c,o,this,o)}})}return e.sort((i,r)=>i.priority-r.priority),e}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(n){const e=++this._lastRuleId,t=n(e);return this._ruleId2desc[e]=t,t}getRule(n){return this._ruleId2desc[n]}getExternalGrammar(n,e){if(this._includedGrammars[n])return this._includedGrammars[n];if(this._grammarRepository){const t=this._grammarRepository.lookup(n);if(t)return this._includedGrammars[n]=xt(t,e&&e.$base),this._includedGrammars[n]}}tokenizeLine(n,e,t=0){const a=this._tokenize(n,e,!1,t);return{tokens:a.lineTokens.getResult(a.ruleStack,a.lineLength),ruleStack:a.ruleStack,stoppedEarly:a.stoppedEarly}}tokenizeLine2(n,e,t=0){const a=this._tokenize(n,e,!0,t);return{tokens:a.lineTokens.getBinaryResult(a.ruleStack,a.lineLength),ruleStack:a.ruleStack,stoppedEarly:a.stoppedEarly}}_tokenize(n,e,t,a){this._rootId===-1&&(this._rootId=ba.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let i;if(!e||e===Tn.NULL){i=!0;const p=this._basicScopeAttributesProvider.getDefaultAttributes(),l=this.themeProvider.getDefaults(),m=_e.set(0,p.languageId,p.tokenType,null,l.fontStyle,l.foregroundId,l.backgroundId),u=this.getRule(this._rootId).getName(null,null);let b;u?b=Ce.createRootAndLookUpScopeName(u,m,this):b=Ce.createRoot("unknown",m),e=new Tn(null,this._rootId,-1,-1,!1,null,b,b)}else i=!1,e.reset();n=n+`
3
3
  `;const r=this.createOnigString(n),s=r.content.length,o=new or(t,n,this._tokenTypeMatchers,this.balancedBracketSelectors),c=_a(this,r,i,0,e,o,!0,a);return ma(r),{lineLength:s,lineTokens:o,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function xt(n,e){return n=vi(n),n.repository=n.repository||{},n.repository.$self={$vscodeTextmateLocation:n.$vscodeTextmateLocation,patterns:n.patterns,name:n.scopeName},n.repository.$base=e||n.repository.$self,n}var Ce=class P{constructor(e,t,a){this.parent=e,this.scopePath=t,this.tokenAttributes=a}static fromExtension(e,t){let a=e,i=e?.scopePath??null;for(const r of t)i=gn.push(i,r.scopeNames),a=new P(a,i,r.encodedTokenAttributes);return a}static createRoot(e,t){return new P(null,new gn(null,e),t)}static createRootAndLookUpScopeName(e,t,a){const i=a.getMetadataForScope(e),r=new gn(null,e),s=a.themeProvider.themeMatch(r),o=P.mergeAttributes(t,i,s);return new P(null,r,o)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(e){return P.equals(this,e)}static equals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}while(!0)}static mergeAttributes(e,t,a){let i=-1,r=0,s=0;return a!==null&&(i=a.fontStyle,r=a.foregroundId,s=a.backgroundId),_e.set(e,t.languageId,t.tokenType,null,i,r,s)}pushAttributed(e,t){if(e===null)return this;if(e.indexOf(" ")===-1)return P._pushAttributed(this,e,t);const a=e.split(/ /g);let i=this;for(const r of a)i=P._pushAttributed(i,r,t);return i}static _pushAttributed(e,t,a){const i=a.getMetadataForScope(t),r=e.scopePath.push(t),s=a.themeProvider.themeMatch(r),o=P.mergeAttributes(e.tokenAttributes,i,s);return new P(e,r,o)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){const t=[];let a=this;for(;a&&a!==e;)t.push({encodedTokenAttributes:a.tokenAttributes,scopeNames:a.scopePath.getExtensionIfDefined(a.parent?.scopePath??null)}),a=a.parent;return a===e?t.reverse():void 0}},Tn=class te{constructor(e,t,a,i,r,s,o,c){this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=r,this.endRule=s,this.nameScopesList=o,this.contentNameScopesList=c,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=a,this._anchorPos=i}_stackElementBrand=void 0;static NULL=new te(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(e){return e===null?!1:te._equals(this,e)}static _equals(e,t){return e===t?!0:this._structuralEquals(e,t)?Ce.equals(e.contentNameScopesList,t.contentNameScopesList):!1}static _structuralEquals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){te._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(e,t,a,i,r,s,o){return new te(this,e,t,a,i,r,s,o)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){const e=[];return this._writeString(e,0),"["+e.join(",")+"]"}_writeString(e,t){return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(e){return this.endRule===e?this:new te(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,e,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(e,t){const a=Ce.fromExtension(e?.nameScopesList??null,t.nameScopesList);return new te(e,t.ruleId,t.enterPos??-1,t.anchorPos??-1,t.beginRuleCapturedEOL,t.endRule,a,Ce.fromExtension(a,t.contentNameScopesList))}},sr=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(n,e){this.balancedBracketScopes=n.flatMap(t=>t==="*"?(this.allowAny=!0,[]):Ve(t,Je).map(a=>a.matcher)),this.unbalancedBracketScopes=e.flatMap(t=>Ve(t,Je).map(a=>a.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(n){for(const e of this.unbalancedBracketScopes)if(e(n))return!1;for(const e of this.balancedBracketScopes)if(e(n))return!0;return this.allowAny}},or=class{constructor(n,e,t,a){this.balancedBracketSelectors=a,this._emitBinaryTokens=n,this._tokenTypeOverrides=t,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(n,e){this.produceFromScopes(n.contentNameScopesList,e)}produceFromScopes(n,e){if(this._lastTokenEndIndex>=e)return;if(this._emitBinaryTokens){let a=n?.tokenAttributes??0,i=!1;if(this.balancedBracketSelectors?.matchesAlways&&(i=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const r=n?.getScopeNames()??[];for(const s of this._tokenTypeOverrides)s.matcher(r)&&(a=_e.set(a,0,s.type,null,-1,0,0));this.balancedBracketSelectors&&(i=this.balancedBracketSelectors.match(r))}if(i&&(a=_e.set(a,0,8,i,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===a){this._lastTokenEndIndex=e;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(a),this._lastTokenEndIndex=e;return}const t=n?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:e,scopes:t}),this._lastTokenEndIndex=e}getResult(n,e){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===e-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(n,e),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(n,e){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===e-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(n,e),this._binaryTokens[this._binaryTokens.length-2]=0);const t=new Uint32Array(this._binaryTokens.length);for(let a=0,i=this._binaryTokens.length;a<i;a++)t[a]=this._binaryTokens[a];return t}},cr=class{constructor(n,e){this._onigLib=e,this._theme=n}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(const n of this._grammars.values())n.dispose()}setTheme(n){this._theme=n}getColorMap(){return this._theme.getColorMap()}addGrammar(n,e){this._rawGrammars.set(n.scopeName,n),e&&this._injectionGrammars.set(n.scopeName,e)}lookup(n){return this._rawGrammars.get(n)}injections(n){return this._injectionGrammars.get(n)}getDefaults(){return this._theme.getDefaults()}themeMatch(n){return this._theme.match(n)}grammarForScopeName(n,e,t,a,i){if(!this._grammars.has(n)){let r=this._rawGrammars.get(n);if(!r)return null;this._grammars.set(n,ar(n,r,e,t,a,i,this,this._onigLib))}return this._grammars.get(n)}},pr=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new cr(Xe.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(Xe.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,a){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:a})}loadGrammarWithConfiguration(e,t,a){return this._loadGrammar(e,t,a.embeddedLanguages,a.tokenTypes,new sr(a.balancedBracketSelectors||[],a.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,a,i,r){const s=new Ui(this._syncRegistry,e);for(;s.Q.length>0;)s.Q.map(o=>this._loadSingleGrammar(o.scopeName)),s.processQueue();return this._grammarForScopeName(e,t,a,i,r)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){const t=this._options.loadGrammar(e);if(t){const a=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,a)}}addGrammar(e,t=[],a=0,i=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,a,i)}_grammarForScopeName(e,t=0,a=null,i=null,r=null){return this._syncRegistry.grammarForScopeName(e,t,a,i,r)}},Zn=Tn.NULL;const lr=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class Ne{constructor(e,t,a){this.normal=t,this.property=e,a&&(this.space=a)}}Ne.prototype.normal={};Ne.prototype.property={};Ne.prototype.space=void 0;function fa(n,e){const t={},a={};for(const i of n)Object.assign(t,i.property),Object.assign(a,i.normal);return new Ne(t,a,e)}function In(n){return n.toLowerCase()}class I{constructor(e,t){this.attribute=t,this.property=e}}I.prototype.attribute="";I.prototype.booleanish=!1;I.prototype.boolean=!1;I.prototype.commaOrSpaceSeparated=!1;I.prototype.commaSeparated=!1;I.prototype.defined=!1;I.prototype.mustUseProperty=!1;I.prototype.number=!1;I.prototype.overloadedBoolean=!1;I.prototype.property="";I.prototype.spaceSeparated=!1;I.prototype.space=void 0;let mr=0;const v=oe(),E=oe(),Rn=oe(),h=oe(),C=oe(),be=oe(),R=oe();function oe(){return 2**++mr}const Un=Object.freeze(Object.defineProperty({__proto__:null,boolean:v,booleanish:E,commaOrSpaceSeparated:R,commaSeparated:be,number:h,overloadedBoolean:Rn,spaceSeparated:C},Symbol.toStringTag,{value:"Module"})),hn=Object.keys(Un);class Kn extends I{constructor(e,t,a,i){let r=-1;if(super(e,t),$t(this,"space",i),typeof a=="number")for(;++r<hn.length;){const s=hn[r];$t(this,hn[r],(a&Un[s])===Un[s])}}}Kn.prototype.defined=!0;function $t(n,e,t){t&&(n[e]=t)}function he(n){const e={},t={};for(const[a,i]of Object.entries(n.properties)){const r=new Kn(a,n.transform(n.attributes||{},a),i,n.space);n.mustUseProperty&&n.mustUseProperty.includes(a)&&(r.mustUseProperty=!0),e[a]=r,t[In(a)]=a,t[In(r.attribute)]=a}return new Ne(e,t,n.space)}const ya=he({properties:{ariaActiveDescendant:null,ariaAtomic:E,ariaAutoComplete:null,ariaBusy:E,ariaChecked:E,ariaColCount:h,ariaColIndex:h,ariaColSpan:h,ariaControls:C,ariaCurrent:null,ariaDescribedBy:C,ariaDetails:null,ariaDisabled:E,ariaDropEffect:C,ariaErrorMessage:null,ariaExpanded:E,ariaFlowTo:C,ariaGrabbed:E,ariaHasPopup:null,ariaHidden:E,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:C,ariaLevel:h,ariaLive:null,ariaModal:E,ariaMultiLine:E,ariaMultiSelectable:E,ariaOrientation:null,ariaOwns:C,ariaPlaceholder:null,ariaPosInSet:h,ariaPressed:E,ariaReadOnly:E,ariaRelevant:null,ariaRequired:E,ariaRoleDescription:C,ariaRowCount:h,ariaRowIndex:h,ariaRowSpan:h,ariaSelected:E,ariaSetSize:h,ariaSort:null,ariaValueMax:h,ariaValueMin:h,ariaValueNow:h,ariaValueText:null,role:null},transform(n,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function ka(n,e){return e in n?n[e]:e}function wa(n,e){return ka(n,e.toLowerCase())}const ur=he({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:be,acceptCharset:C,accessKey:C,action:null,allow:null,allowFullScreen:v,allowPaymentRequest:v,allowUserMedia:v,alt:null,as:null,async:v,autoCapitalize:null,autoComplete:C,autoFocus:v,autoPlay:v,blocking:C,capture:null,charSet:null,checked:v,cite:null,className:C,cols:h,colSpan:null,content:null,contentEditable:E,controls:v,controlsList:C,coords:h|be,crossOrigin:null,data:null,dateTime:null,decoding:null,default:v,defer:v,dir:null,dirName:null,disabled:v,download:Rn,draggable:E,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:v,formTarget:null,headers:C,height:h,hidden:Rn,high:h,href:null,hrefLang:null,htmlFor:C,httpEquiv:C,id:null,imageSizes:null,imageSrcSet:null,inert:v,inputMode:null,integrity:null,is:null,isMap:v,itemId:null,itemProp:C,itemRef:C,itemScope:v,itemType:C,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:v,low:h,manifest:null,max:null,maxLength:h,media:null,method:null,min:null,minLength:h,multiple:v,muted:v,name:null,nonce:null,noModule:v,noValidate:v,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:v,optimum:h,pattern:null,ping:C,placeholder:null,playsInline:v,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:v,referrerPolicy:null,rel:C,required:v,reversed:v,rows:h,rowSpan:h,sandbox:C,scope:null,scoped:v,seamless:v,selected:v,shadowRootClonable:v,shadowRootDelegatesFocus:v,shadowRootMode:null,shape:null,size:h,sizes:null,slot:null,span:h,spellCheck:E,src:null,srcDoc:null,srcLang:null,srcSet:null,start:h,step:null,style:null,tabIndex:h,target:null,title:null,translate:null,type:null,typeMustMatch:v,useMap:null,value:E,width:h,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:C,axis:null,background:null,bgColor:null,border:h,borderColor:null,bottomMargin:h,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:v,declare:v,event:null,face:null,frame:null,frameBorder:null,hSpace:h,leftMargin:h,link:null,longDesc:null,lowSrc:null,marginHeight:h,marginWidth:h,noResize:v,noHref:v,noShade:v,noWrap:v,object:null,profile:null,prompt:null,rev:null,rightMargin:h,rules:null,scheme:null,scrolling:E,standby:null,summary:null,text:null,topMargin:h,valueType:null,version:null,vAlign:null,vLink:null,vSpace:h,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:v,disableRemotePlayback:v,prefix:null,property:null,results:h,security:null,unselectable:null},space:"html",transform:wa}),dr=he({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:R,accentHeight:h,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:h,amplitude:h,arabicForm:null,ascent:h,attributeName:null,attributeType:null,azimuth:h,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:h,by:null,calcMode:null,capHeight:h,className:C,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:h,diffuseConstant:h,direction:null,display:null,dur:null,divisor:h,dominantBaseline:null,download:v,dx:null,dy:null,edgeMode:null,editable:null,elevation:h,enableBackground:null,end:null,event:null,exponent:h,externalResourcesRequired:null,fill:null,fillOpacity:h,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:be,g2:be,glyphName:be,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:h,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:h,horizOriginX:h,horizOriginY:h,id:null,ideographic:h,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:h,k:h,k1:h,k2:h,k3:h,k4:h,kernelMatrix:R,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:h,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:h,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:h,overlineThickness:h,paintOrder:null,panose1:null,path:null,pathLength:h,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:C,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:h,pointsAtY:h,pointsAtZ:h,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:R,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:R,rev:R,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:R,requiredFeatures:R,requiredFonts:R,requiredFormats:R,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:h,specularExponent:h,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:h,strikethroughThickness:h,string:null,stroke:null,strokeDashArray:R,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:h,strokeOpacity:h,strokeWidth:null,style:null,surfaceScale:h,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:R,tabIndex:h,tableValues:null,target:null,targetX:h,targetY:h,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:R,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:h,underlineThickness:h,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:h,values:null,vAlphabetic:h,vMathematical:h,vectorEffect:null,vHanging:h,vIdeographic:h,version:null,vertAdvY:h,vertOriginX:h,vertOriginY:h,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:h,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:ka}),xa=he({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(n,e){return"xlink:"+e.slice(5).toLowerCase()}}),$a=he({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:wa}),va=he({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(n,e){return"xml:"+e.slice(3).toLowerCase()}}),br=/[A-Z]/g,vt=/-[a-z]/g,gr=/^data[-\w.:]+$/i;function _r(n,e){const t=In(e);let a=e,i=I;if(t in n.normal)return n.property[n.normal[t]];if(t.length>4&&t.slice(0,4)==="data"&&gr.test(e)){if(e.charAt(4)==="-"){const r=e.slice(5).replace(vt,fr);a="data"+r.charAt(0).toUpperCase()+r.slice(1)}else{const r=e.slice(4);if(!vt.test(r)){let s=r.replace(br,hr);s.charAt(0)!=="-"&&(s="-"+s),e="data"+s}}i=Kn}return new i(a,e)}function hr(n){return"-"+n.toLowerCase()}function fr(n){return n.charAt(1).toUpperCase()}const yr=fa([ya,ur,xa,$a,va],"html"),Ca=fa([ya,dr,xa,$a,va],"svg"),Ct={}.hasOwnProperty;function kr(n,e){const t=e||{};function a(i,...r){let s=a.invalid;const o=a.handlers;if(i&&Ct.call(i,n)){const c=String(i[n]);s=Ct.call(o,c)?o[c]:a.unknown}if(s)return s.call(this,i,...r)}return a.handlers=t.handlers||{},a.invalid=t.invalid,a.unknown=t.unknown,a}const wr=/["&'<>`]/g,xr=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,$r=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,vr=/[|\\{}()[\]^$+*?.]/g,jt=new WeakMap;function Cr(n,e){if(n=n.replace(e.subset?jr(e.subset):wr,a),e.subset||e.escapeOnly)return n;return n.replace(xr,t).replace($r,a);function t(i,r,s){return e.format((i.charCodeAt(0)-55296)*1024+i.charCodeAt(1)-56320+65536,s.charCodeAt(r+2),e)}function a(i,r,s){return e.format(i.charCodeAt(0),s.charCodeAt(r+1),e)}}function jr(n){let e=jt.get(n);return e||(e=Ar(n),jt.set(n,e)),e}function Ar(n){const e=[];let t=-1;for(;++t<n.length;)e.push(n[t].replace(vr,"\\$&"));return new RegExp("(?:"+e.join("|")+")","g")}const Er=/[\dA-Fa-f]/;function qr(n,e,t){const a="&#x"+n.toString(16).toUpperCase();return t&&e&&!Er.test(String.fromCharCode(e))?a:a+";"}const Fr=/\d/;function zr(n,e,t){const a="&#"+String(n);return t&&e&&!Fr.test(String.fromCharCode(e))?a:a+";"}const Sr=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"],fn={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"},Nr=["cent","copy","divide","gt","lt","not","para","times"],ja={}.hasOwnProperty,Ln={};let We;for(We in fn)ja.call(fn,We)&&(Ln[fn[We]]=We);const Tr=/[^\dA-Za-z]/;function Zr(n,e,t,a){const i=String.fromCharCode(n);if(ja.call(Ln,i)){const r=Ln[i],s="&"+r;return t&&Sr.includes(r)&&!Nr.includes(r)&&(!a||e&&e!==61&&Tr.test(String.fromCharCode(e)))?s:s+";"}return""}function Ir(n,e,t){let a=qr(n,e,t.omitOptionalSemicolons),i;if((t.useNamedReferences||t.useShortestReferences)&&(i=Zr(n,e,t.omitOptionalSemicolons,t.attribute)),(t.useShortestReferences||!i)&&t.useShortestReferences){const r=zr(n,e,t.omitOptionalSemicolons);r.length<a.length&&(a=r)}return i&&(!t.useShortestReferences||i.length<a.length)?i:a}function ge(n,e){return Cr(n,Object.assign({format:Ir},e))}const Rr=/^>|^->|<!--|-->|--!>|<!-$/g,Ur=[">"],Lr=["<",">"];function Wr(n,e,t,a){return a.settings.bogusComments?"<?"+ge(n.value,Object.assign({},a.settings.characterReferences,{subset:Ur}))+">":"<!--"+n.value.replace(Rr,i)+"-->";function i(r){return ge(r,Object.assign({},a.settings.characterReferences,{subset:Lr}))}}function Or(n,e,t,a){return"<!"+(a.settings.upperDoctype?"DOCTYPE":"doctype")+(a.settings.tightDoctype?"":" ")+"html>"}function At(n,e){const t=String(n);if(typeof e!="string")throw new TypeError("Expected character");let a=0,i=t.indexOf(e);for(;i!==-1;)a++,i=t.indexOf(e,i+e.length);return a}function Pr(n,e){const t=e||{};return(n[n.length-1]===""?[...n,""]:n).join((t.padRight?" ":"")+","+(t.padLeft===!1?"":" ")).trim()}function Gr(n){return n.join(" ").trim()}const Mr=/[ \t\n\f\r]/g;function Jn(n){return typeof n=="object"?n.type==="text"?Et(n.value):!1:Et(n)}function Et(n){return n.replace(Mr,"")===""}const F=Ea(1),Aa=Ea(-1),Dr=[];function Ea(n){return e;function e(t,a,i){const r=t?t.children:Dr;let s=(a||0)+n,o=r[s];if(!i)for(;o&&Jn(o);)s+=n,o=r[s];return o}}const Br={}.hasOwnProperty;function qa(n){return e;function e(t,a,i){return Br.call(n,t.tagName)&&n[t.tagName](t,a,i)}}const Qn=qa({body:Xr,caption:yn,colgroup:yn,dd:Jr,dt:Kr,head:yn,html:Hr,li:Yr,optgroup:Qr,option:es,p:Vr,rp:qt,rt:qt,tbody:ts,td:Ft,tfoot:as,th:Ft,thead:ns,tr:is});function yn(n,e,t){const a=F(t,e,!0);return!a||a.type!=="comment"&&!(a.type==="text"&&Jn(a.value.charAt(0)))}function Hr(n,e,t){const a=F(t,e);return!a||a.type!=="comment"}function Xr(n,e,t){const a=F(t,e);return!a||a.type!=="comment"}function Vr(n,e,t){const a=F(t,e);return a?a.type==="element"&&(a.tagName==="address"||a.tagName==="article"||a.tagName==="aside"||a.tagName==="blockquote"||a.tagName==="details"||a.tagName==="div"||a.tagName==="dl"||a.tagName==="fieldset"||a.tagName==="figcaption"||a.tagName==="figure"||a.tagName==="footer"||a.tagName==="form"||a.tagName==="h1"||a.tagName==="h2"||a.tagName==="h3"||a.tagName==="h4"||a.tagName==="h5"||a.tagName==="h6"||a.tagName==="header"||a.tagName==="hgroup"||a.tagName==="hr"||a.tagName==="main"||a.tagName==="menu"||a.tagName==="nav"||a.tagName==="ol"||a.tagName==="p"||a.tagName==="pre"||a.tagName==="section"||a.tagName==="table"||a.tagName==="ul"):!t||!(t.type==="element"&&(t.tagName==="a"||t.tagName==="audio"||t.tagName==="del"||t.tagName==="ins"||t.tagName==="map"||t.tagName==="noscript"||t.tagName==="video"))}function Yr(n,e,t){const a=F(t,e);return!a||a.type==="element"&&a.tagName==="li"}function Kr(n,e,t){const a=F(t,e);return!!(a&&a.type==="element"&&(a.tagName==="dt"||a.tagName==="dd"))}function Jr(n,e,t){const a=F(t,e);return!a||a.type==="element"&&(a.tagName==="dt"||a.tagName==="dd")}function qt(n,e,t){const a=F(t,e);return!a||a.type==="element"&&(a.tagName==="rp"||a.tagName==="rt")}function Qr(n,e,t){const a=F(t,e);return!a||a.type==="element"&&a.tagName==="optgroup"}function es(n,e,t){const a=F(t,e);return!a||a.type==="element"&&(a.tagName==="option"||a.tagName==="optgroup")}function ns(n,e,t){const a=F(t,e);return!!(a&&a.type==="element"&&(a.tagName==="tbody"||a.tagName==="tfoot"))}function ts(n,e,t){const a=F(t,e);return!a||a.type==="element"&&(a.tagName==="tbody"||a.tagName==="tfoot")}function as(n,e,t){return!F(t,e)}function is(n,e,t){const a=F(t,e);return!a||a.type==="element"&&a.tagName==="tr"}function Ft(n,e,t){const a=F(t,e);return!a||a.type==="element"&&(a.tagName==="td"||a.tagName==="th")}const rs=qa({body:cs,colgroup:ps,head:os,html:ss,tbody:ls});function ss(n){const e=F(n,-1);return!e||e.type!=="comment"}function os(n){const e=new Set;for(const a of n.children)if(a.type==="element"&&(a.tagName==="base"||a.tagName==="title")){if(e.has(a.tagName))return!1;e.add(a.tagName)}const t=n.children[0];return!t||t.type==="element"}function cs(n){const e=F(n,-1,!0);return!e||e.type!=="comment"&&!(e.type==="text"&&Jn(e.value.charAt(0)))&&!(e.type==="element"&&(e.tagName==="meta"||e.tagName==="link"||e.tagName==="script"||e.tagName==="style"||e.tagName==="template"))}function ps(n,e,t){const a=Aa(t,e),i=F(n,-1,!0);return t&&a&&a.type==="element"&&a.tagName==="colgroup"&&Qn(a,t.children.indexOf(a),t)?!1:!!(i&&i.type==="element"&&i.tagName==="col")}function ls(n,e,t){const a=Aa(t,e),i=F(n,-1);return t&&a&&a.type==="element"&&(a.tagName==="thead"||a.tagName==="tbody")&&Qn(a,t.children.indexOf(a),t)?!1:!!(i&&i.type==="element"&&i.tagName==="tr")}const Oe={name:[[`
4
4
  \f\r &/=>`.split(""),`
@@ -1 +1 @@
1
- import{j as e}from"./main-DOBfHXDF.js";import{D as l,a as c,b as d,c as p,d as m}from"./use-file-explorer-state-B5JLNsSa.js";import{B as x}from"./button-seqh98ae.js";import"./useButton-csSB2uQJ.js";import"./react-DD8SkMJn.js";const s=typeof navigator<"u"&&navigator.platform.toUpperCase().indexOf("MAC")>=0,h=[{keys:[s?"⌘":"Ctrl","K"],description:"Start a new chat"},{keys:[s?"⌘":"Ctrl","F"],description:"Search current conversation"},{keys:[s?"⌘":"Ctrl","Shift","F"],description:"Search all conversations"},{keys:[s?"⌘":"Ctrl","/"],description:"Focus message input"},{keys:["Esc"],description:"Close dialogs / Clear focus"},{keys:[s?"⌘":"Ctrl","Shift","C"],description:"Copy last response"},{keys:["?"],description:"Show this help dialog"}];function g({open:t,onOpenChange:a}){return e.jsx(l,{open:t,onOpenChange:a,children:e.jsx(c,{className:"w-[min(500px,92vw)]",children:e.jsxs("div",{className:"p-6",children:[e.jsx(d,{className:"mb-2",children:"Keyboard Shortcuts"}),e.jsx(p,{className:"mb-6",children:"Speed up your workflow with these keyboard shortcuts"}),e.jsx("div",{className:"space-y-3",children:h.map((r,o)=>e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-primary-100 last:border-0",children:[e.jsx("span",{className:"text-sm text-primary-700",children:r.description}),e.jsx("div",{className:"flex items-center gap-1",children:r.keys.map((n,i)=>e.jsxs("span",{className:"inline-flex items-center",children:[e.jsx("kbd",{className:"px-2 py-1 text-xs font-semibold text-primary-800 bg-primary-100 border border-primary-200 rounded",children:n}),i<r.keys.length-1&&e.jsx("span",{className:"mx-1 text-primary-400",children:"+"})]},i))})]},o))}),e.jsx("div",{className:"mt-6 flex justify-end",children:e.jsx(m,{children:e.jsx(x,{variant:"outline",children:"Close"})})})]})})})}export{g as KeyboardShortcutsDialog};
1
+ import{j as e}from"./main-BlX7CS2-.js";import{D as l,a as c,b as d,c as p,d as m}from"./use-file-explorer-state-C6lX-h0n.js";import{B as x}from"./button-BcnCTjUT.js";import"./useButton-DhneLsMA.js";import"./react-ONC2UaeC.js";const s=typeof navigator<"u"&&navigator.platform.toUpperCase().indexOf("MAC")>=0,h=[{keys:[s?"⌘":"Ctrl","K"],description:"Start a new chat"},{keys:[s?"⌘":"Ctrl","F"],description:"Search current conversation"},{keys:[s?"⌘":"Ctrl","Shift","F"],description:"Search all conversations"},{keys:[s?"⌘":"Ctrl","/"],description:"Focus message input"},{keys:["Esc"],description:"Close dialogs / Clear focus"},{keys:[s?"⌘":"Ctrl","Shift","C"],description:"Copy last response"},{keys:["?"],description:"Show this help dialog"}];function g({open:t,onOpenChange:a}){return e.jsx(l,{open:t,onOpenChange:a,children:e.jsx(c,{className:"w-[min(500px,92vw)]",children:e.jsxs("div",{className:"p-6",children:[e.jsx(d,{className:"mb-2",children:"Keyboard Shortcuts"}),e.jsx(p,{className:"mb-6",children:"Speed up your workflow with these keyboard shortcuts"}),e.jsx("div",{className:"space-y-3",children:h.map((r,o)=>e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-primary-100 last:border-0",children:[e.jsx("span",{className:"text-sm text-primary-700",children:r.description}),e.jsx("div",{className:"flex items-center gap-1",children:r.keys.map((n,i)=>e.jsxs("span",{className:"inline-flex items-center",children:[e.jsx("kbd",{className:"px-2 py-1 text-xs font-semibold text-primary-800 bg-primary-100 border border-primary-200 rounded",children:n}),i<r.keys.length-1&&e.jsx("span",{className:"mx-1 text-primary-400",children:"+"})]},i))})]},o))}),e.jsx("div",{className:"mt-6 flex justify-end",children:e.jsx(m,{children:e.jsx(x,{variant:"outline",children:"Close"})})})]})})})}export{g as KeyboardShortcutsDialog};