opencami 1.6.0 → 1.7.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 (57) hide show
  1. package/README.md +48 -31
  2. package/dist/client/assets/{CSPContext-Bq8j4nl9.js → CSPContext-a-MQmQQt.js} +1 -1
  3. package/dist/client/assets/{DirectionContext-BdX86BHP.js → DirectionContext-DRcND-Cm.js} +1 -1
  4. package/dist/client/assets/_sessionKey-BAmpzUOP.js +23 -0
  5. package/dist/client/assets/agents-BkeWu_3a.js +2 -0
  6. package/dist/client/assets/{agents-screen-DwIY8hze.js → agents-screen-Cb76bcxn.js} +1 -1
  7. package/dist/client/assets/bots-CyJwr-JU.js +2 -0
  8. package/dist/client/assets/{bots-screen-c78I920d.js → bots-screen-CzNjLsQH.js} +1 -1
  9. package/dist/client/assets/{button-Dg7VFQQn.js → button-DNC5N25i.js} +1 -1
  10. package/dist/client/assets/{composite-DBl8R3ae.js → composite-Bliqcmg4.js} +1 -1
  11. package/dist/client/assets/{connect-NYvOqiBJ.js → connect-BX1MWO82.js} +1 -1
  12. package/dist/client/assets/{file-explorer-screen-BSMbs0vi.js → file-explorer-screen-CpY1O_ag.js} +1 -1
  13. package/dist/client/assets/files-HiN5rXWq.js +2 -0
  14. package/dist/client/assets/{index-CMATW8VA.js → index-BlC2sH55.js} +1 -1
  15. package/dist/client/assets/{index-rOIRO-8E.js → index-Dg0mbvtv.js} +1 -1
  16. package/dist/client/assets/{keyboard-shortcuts-dialog-BTGWdJMl.js → keyboard-shortcuts-dialog-C2Hq19LN.js} +1 -1
  17. package/dist/client/assets/{main-B_dlfHME.js → main-CEuT8-Qi.js} +14 -5
  18. package/dist/client/assets/{markdown-BVzT7z4x.js → markdown-DKD6ZLRJ.js} +1 -1
  19. package/dist/client/assets/memory-lhzf-8Q4.js +2 -0
  20. package/dist/client/assets/{memory-screen-C-Z9o31m.js → memory-screen-Zq9qfnJK.js} +1 -1
  21. package/dist/client/assets/{menu-DHNgWk_8.js → menu-47ooFeSm.js} +1 -1
  22. package/dist/client/assets/{opencami-logo-BQQETnJG.js → opencami-logo-DA69yVKc.js} +1 -1
  23. package/dist/client/assets/{owner-CpRnf1fI.js → owner-CFRNz_Tp.js} +1 -1
  24. package/dist/client/assets/{popupStateMapping-BRPDXnjv.js → popupStateMapping-D5k-jOeY.js} +1 -1
  25. package/dist/client/assets/{proxy-BcUh9kMA.js → proxy-Cawf6X0W.js} +1 -1
  26. package/dist/client/assets/{react-irH8OzhB.js → react-K9goXsVv.js} +1 -1
  27. package/dist/client/assets/{search-dialog-B96zx_ng.js → search-dialog-C5Yae9rb.js} +1 -1
  28. package/dist/client/assets/{session-export-dialog-DPuHnhgv.js → session-export-dialog-CBeTfbll.js} +1 -1
  29. package/dist/client/assets/settings-dialog-CoeG9M1b.js +1 -0
  30. package/dist/client/assets/skills-BEkw619A.js +2 -0
  31. package/dist/client/assets/{skills-panel-WDUfIwnI.js → skills-panel-DFL-3BRH.js} +1 -1
  32. package/dist/client/assets/styles-D4EBtWYc.css +1 -0
  33. package/dist/client/assets/{switch-DPocNFRG.js → switch-DAFvLxNX.js} +1 -1
  34. package/dist/client/assets/{tabs-B0cro1hL.js → tabs-B2Y_7MvG.js} +1 -1
  35. package/dist/client/assets/{tooltip-Dg9fy-vT.js → tooltip-D57Pal0B.js} +1 -1
  36. package/dist/client/assets/{use-file-explorer-state-DzT0bksg.js → use-file-explorer-state-DppKEjcl.js} +1 -1
  37. package/dist/client/assets/{useButton-Cbl_9oFG.js → useButton-DVAfkehQ.js} +1 -1
  38. package/dist/client/assets/{useCompositeItem-BDAzTxVe.js → useCompositeItem-CzdGhGcj.js} +1 -1
  39. package/dist/client/assets/{useControlled-Dscz_s4f.js → useControlled-Cl9XA2_f.js} +1 -1
  40. package/dist/client/assets/{useMutation-B1FlDsNN.js → useMutation-C5bTdeC1.js} +1 -1
  41. package/dist/client/assets/{visuallyHidden-ONmQ-0U2.js → visuallyHidden-CO3ZD5AQ.js} +1 -1
  42. package/dist/server/assets/{_sessionKey-B0ZlLAjH.js → _sessionKey-BBG3ZUlo.js} +279 -27
  43. package/dist/server/assets/{_tanstack-start-manifest_v-D5UVTs1o.js → _tanstack-start-manifest_v-DmMFarHb.js} +1 -1
  44. package/dist/server/assets/{index-CiUjUD0t.js → index-BgMPaOsU.js} +1 -1
  45. package/dist/server/assets/{router-Uuagl6O7.js → router-Bl2uabfY.js} +38 -9
  46. package/dist/server/assets/{search-dialog-DZTS5SEi.js → search-dialog-BtSQW9SR.js} +2 -2
  47. package/dist/server/assets/{settings-dialog-CSYDj2qm.js → settings-dialog-D3fOAswX.js} +11 -4
  48. package/dist/server/server.js +2 -2
  49. package/package.json +1 -1
  50. package/dist/client/assets/_sessionKey-DsjnpErt.js +0 -14
  51. package/dist/client/assets/agents-DwxKcpP6.js +0 -2
  52. package/dist/client/assets/bots-CRlm-3-d.js +0 -2
  53. package/dist/client/assets/files-BJbMx0_w.js +0 -2
  54. package/dist/client/assets/memory-S3Yws6a5.js +0 -2
  55. package/dist/client/assets/settings-dialog-DZcRCaPj.js +0 -1
  56. package/dist/client/assets/skills-YZe3I63y.js +0 -2
  57. package/dist/client/assets/styles-Bwo-K6Y4.css +0 -1
@@ -1 +1 @@
1
- import{j as e,r,L as se,u as L}from"./main-B_dlfHME.js";import{u as ie}from"./visuallyHidden-ONmQ-0U2.js";import{K as be,c as h,b as ne,B as k,H as j,I as ye,r as ve,L as je,M as we,N as Ne,O as Ce,Q as ke,W as ae,Y as re,Z as ce,_ as De,$ as Se,k as Ee,a0 as Fe,a1 as ze,a2 as de,a3 as ue,a4 as Me,a5 as Re,a6 as Te,a7 as Le,a8 as Ke,a9 as $e,n as ee,aa as Ue,V as Ie}from"./button-Dg7VFQQn.js";import{T as P,a as W,b as B,c as O,s as Ae,d as Pe,g as te}from"./tooltip-Dg9fy-vT.js";import{u as F,D as Q,a as _,b as V,c as H,d as G}from"./use-file-explorer-state-DzT0bksg.js";import{m as E,A}from"./proxy-BcUh9kMA.js";import{M as We,a as Be,b as Oe,c as le}from"./menu-DHNgWk_8.js";import{u as K}from"./useMutation-B1FlDsNN.js";import"./popupStateMapping-BRPDXnjv.js";import"./useButton-Cbl_9oFG.js";import"./owner-CpRnf1fI.js";import"./DirectionContext-BdX86BHP.js";import"./composite-DBl8R3ae.js";import"./react-irH8OzhB.js";import"./useCompositeItem-BDAzTxVe.js";function qe({className:i}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"80",height:"80",viewBox:"0 0 80 80",fill:"none",className:i,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 r.useMemo(()=>typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function _e({isCollapsed:i,onToggleCollapse:s,onSelectAction:n}){const{navigateTo:a,currentPath:o}=F(),c=Qe(),t=r.useMemo(()=>({duration:c?0:.15,ease:i?"easeIn":"easeOut"}),[i,c]),l=r.useCallback(d=>{a(d)},[a]),m=r.useCallback((d,C)=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),C())},[]),v=r.useMemo(()=>[{path:"/",icon:be,label:"Home",id:"home"}],[]),y=r.useMemo(()=>({className:"border-r border-primary-200 h-full overflow-hidden bg-primary-100 flex flex-col"}),[]),f=48,u=300;return e.jsxs(E.aside,{initial:!1,animate:{width:c?i?f:u:void 0},style:{width:c?void 0:i?f:u},transition:t,className:y.className,role:"navigation","aria-label":"File explorer navigation",children:[e.jsxs(E.div,{layout:!0,transition:{layout:t},className:h("flex items-center h-12 px-2 justify-between"),children:[e.jsx(A,{initial:!1,children:i?null:e.jsx(E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,children:e.jsxs(se,{to:"/new",className:h(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(qe,{className:"size-5 rounded-sm","aria-hidden":"true"}),e.jsx("span",{children:"WebClaw"})]})})}),e.jsx(P,{children:e.jsxs(W,{children:[e.jsx(B,{onClick:s,onKeyDown:d=>m(d,s),render:e.jsx(k,{size:"icon-sm",variant:"ghost","aria-label":i?"Expand sidebar":"Collapse sidebar",className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:e.jsx(j,{icon:ye,size:20,strokeWidth:1.5,"aria-hidden":"true"})})}),e.jsx(O,{side:"right",children:i?"Expand sidebar":"Collapse sidebar"})]})})]}),e.jsx("div",{className:"px-2 mb-4",children:e.jsx(E.div,{layout:!0,transition:{layout:t},className:"w-full",children:e.jsx(P,{children:e.jsxs(W,{children:[e.jsx(B,{asChild:!0,children:e.jsxs(se,{to:"/chat/$sessionKey",params:{sessionKey:"main"},className:h(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:n,children:[e.jsx(j,{icon:ve,size:20,strokeWidth:1.5,className:"min-w-5","aria-hidden":"true"}),e.jsx(A,{initial:!1,mode:"wait",children:i?null:e.jsx(E.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,className:"overflow-hidden whitespace-nowrap",children:"Back to Chat"})})]})}),i?e.jsx(O,{side:"right",children:"Back to Chat"}):null]})})})}),e.jsx("div",{className:"flex-1 min-h-0 relative overflow-hidden",children:e.jsx(A,{initial:!1,children:i?e.jsx(E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,className:"px-2 space-y-1",children:v.map(d=>e.jsx(P,{children:e.jsxs(W,{children:[e.jsx(B,{onClick:()=>l(d.path),onKeyDown:C=>m(C,()=>l(d.path)),render:e.jsx(k,{size:"icon-sm",variant:"ghost","aria-current":o===d.path?"page":void 0,"aria-label":`Navigate to ${d.label}`,className:h("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(j,{icon:d.icon,size:20,strokeWidth:1.5,"aria-hidden":"true"})})}),e.jsx(O,{side:"right",children:d.label})]})},d.id))},"collapsed-content"):e.jsx(E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,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:v.map(d=>e.jsx("div",{role:"listitem",children:e.jsxs(k,{variant:"ghost",size:"sm",onClick:()=>l(d.path),onKeyDown:C=>m(C,()=>l(d.path)),"aria-current":o===d.path?"page":void 0,className:h("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(j,{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(E.div,{layout:!0,transition:{layout:t},className:"w-full",children:e.jsx(P,{children:e.jsxs(W,{children:[e.jsx(B,{asChild:!0,children:e.jsxs(k,{variant:"ghost",size:i?"icon-sm":"sm",className:h(i?"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(j,{icon:je,size:20,strokeWidth:1.5,className:"min-w-5","aria-hidden":"true"}),e.jsx(A,{initial:!1,mode:"wait",children:i?null:e.jsx(E.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,className:"overflow-hidden whitespace-nowrap",children:"Settings"})})]})}),i?e.jsx(O,{side:"right",children:"Settings"}):null]})})})})]})}function Ve(i,s){return i.isCollapsed===s.isCollapsed}const He=r.memo(_e,Ve);function Ge({path:i}){const{navigateTo:s}=F(),n=i==="/"?[]:i.split("/").filter(Boolean),a=[{name:"Home",path:"/"},...n.map((t,l)=>({name:t,path:"/"+n.slice(0,l+1).join("/")}))],o=r.useCallback(t=>{s(t)},[s]),c=r.useCallback((t,l)=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),s(l))},[s]);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:a.map((t,l)=>e.jsxs("li",{className:"flex items-center gap-1",children:[l>0?e.jsx(j,{icon:we,size:16,strokeWidth:1.5,className:"text-primary-400","aria-hidden":"true"}):null,e.jsxs("button",{type:"button",onClick:()=>o(t.path),onKeyDown:m=>c(m,t.path),"aria-current":l===a.length-1?"page":void 0,className:h("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===a.length-1?"text-primary-900 font-medium":"text-primary-600"),children:[l===0?e.jsx(j,{icon:Ne,size:16,strokeWidth:1.5,"aria-hidden":"true"}):null,e.jsx("span",{className:"whitespace-nowrap",children:t.name})]})]},t.path))})})}const Z=[{label:"Name",value:"name"},{label:"Size",value:"size"},{label:"Modified",value:"modified"}];function Je({onUpload:i,onCreateFolder:s}){const{viewMode:n,sortBy:a,sortAsc:o,setViewMode:c,setSortBy:t,toggleSort:l}=F(),m=r.useCallback(()=>{c("list")},[c]),v=r.useCallback(()=>{c("grid")},[c]),y=r.useCallback(u=>{t(u)},[t]),f=r.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(k,{size:"sm",variant:n==="list"?"default":"ghost",onClick:m,onKeyDown:u=>f(u,m),"aria-label":"Switch to list view","aria-pressed":n==="list",className:h("rounded-none border-0","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:e.jsx(j,{icon:Ce,size:18,strokeWidth:1.5,"aria-hidden":"true"})}),e.jsx(k,{size:"sm",variant:n==="grid"?"default":"ghost",onClick:v,onKeyDown:u=>f(u,v),"aria-label":"Switch to grid view","aria-pressed":n==="grid",className:h("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(j,{icon:ke,size:18,strokeWidth:1.5,"aria-hidden":"true"})})]}),e.jsxs(We,{children:[e.jsx(Be,{render:e.jsxs(k,{variant:"ghost",size:"sm",className:h("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===a)?.label}, ${o?"ascending":"descending"}`,children:[e.jsxs("span",{children:["Sort: ",Z.find(u=>u.value===a)?.label]}),e.jsx(j,{icon:o?ae:re,size:16,strokeWidth:1.5,"aria-hidden":"true"})]})}),e.jsxs(Oe,{side:"bottom",align:"start",children:[Z.map(u=>e.jsx(le,{onClick:()=>y(u.value),className:h(a===u.value&&"bg-primary-100 text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),"aria-current":a===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(j,{icon:o?re:ae,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(k,{variant:"ghost",size:"sm",onClick:i,onKeyDown:u=>f(u,i),className:h("gap-2","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Upload files",children:[e.jsx(j,{icon:ce,size:18,strokeWidth:1.5,"aria-hidden":"true"}),e.jsx("span",{children:"Upload"})]}),e.jsxs(k,{variant:"ghost",size:"sm",onClick:s,onKeyDown:u=>f(u,s),className:h("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(j,{icon:De,size:18,strokeWidth:1.5,"aria-hidden":"true"}),e.jsx("span",{children:"New Folder"})]})]})]})}const z={all:["files"],listing:i=>["files","listing",i],content:i=>["files","content",i]};function Xe(i){return ie({queryKey:z.content(i||""),queryFn:async({signal:s})=>{const n=await fetch(`/api/files/read?path=${encodeURIComponent(i)}`,{signal:s});if(!n.ok){const a=await n.json().catch(()=>({error:"Failed to read file"}));throw new Error(a.error||"Failed to read file")}return n.json()},enabled:!!i,staleTime:30*1e3,gcTime:300*1e3})}function Ye(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),K({mutationFn:async({path:n,content:a})=>{s.current?.abort();const o=new AbortController;s.current=o;const c=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,content:a}),signal:o.signal});if(!c.ok){const t=await c.json().catch(()=>({error:"Failed to save file"}));throw new Error(t.error||"Failed to save file")}return c.json()},onSuccess:(n,a)=>{i.invalidateQueries({queryKey:z.content(a.path)});const o=a.path.split("/").slice(0,-1).join("/")||"/";i.invalidateQueries({queryKey:z.listing(o)})}})}function Ze(i){return ie({queryKey:z.listing(i),queryFn:async({signal:s})=>{const n=await fetch(`/api/files/list?path=${encodeURIComponent(i)}`,{signal:s});if(!n.ok){const a=await n.text();throw new Error(`Failed to load files: ${a}`)}return n.json()},staleTime:300*1e3,gcTime:600*1e3,retry:3})}function ei(){const i=new Set,s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort(),i.forEach(n=>URL.revokeObjectURL(n)),i.clear()},[]),K({mutationFn:async n=>{s.current?.abort();const a=new AbortController;s.current=a;const o=await fetch(`/api/files/download?path=${encodeURIComponent(n)}`,{signal:a.signal});if(!o.ok){const v=await o.text();throw new Error(`Download failed: ${v}`)}const c=await o.blob(),t=window.URL.createObjectURL(c);i.add(t);const l=n.split("/").pop()||"download",m=document.createElement("a");m.href=t,m.download=l,document.body.appendChild(m),m.click(),document.body.removeChild(m),setTimeout(()=>{i.has(t)&&(URL.revokeObjectURL(t),i.delete(t))},100)},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Download failed:",n)}})}function ii(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),K({mutationFn:async({files:n,path:a})=>{s.current?.abort();const o=new AbortController;s.current=o;const c=[];for(let t=0;t<n.length;t++){const l=new FormData;l.append("path",a),l.append("file",n[t]);const m=await fetch("/api/files/upload",{method:"POST",body:l,signal:o.signal});if(!m.ok){const v=await m.text();throw new Error(`Upload failed for ${n[t].name}: ${v}`)}c.push(await m.json())}return c},onSuccess:(n,a)=>{i.invalidateQueries({queryKey:z.listing(a.path)})},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Upload failed:",n)}})}function si(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),K({mutationFn:async n=>{s.current?.abort();const a=new AbortController;s.current=a;const o=await fetch(`/api/files/delete?path=${encodeURIComponent(n)}`,{method:"DELETE",signal:a.signal});if(!o.ok){const c=await o.text();throw new Error(`Delete failed: ${c}`)}return o.json()},onSuccess:(n,a)=>{const o=a.split("/").slice(0,-1).join("/")||"/";i.invalidateQueries({queryKey:z.listing(o)})},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Delete failed:",n)}})}function ni(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),K({mutationFn:async({path:n,name:a})=>{s.current?.abort();const o=new AbortController;s.current=o;const c=await fetch("/api/files/mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:`${n}/${a}`}),signal:o.signal});if(!c.ok){const t=await c.text();throw new Error(`Create folder failed: ${t}`)}return c.json()},onSuccess:(n,a)=>{i.invalidateQueries({queryKey:z.listing(a.path)})},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Create folder failed:",n)}})}function ai(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),K({mutationFn:async({oldPath:n,newName:a})=>{s.current?.abort();const o=new AbortController;s.current=o;const t=`${n.split("/").slice(0,-1).join("/")}/${a}`,l=await fetch("/api/files/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({src:n,dst:t}),signal:o.signal});if(!l.ok){const m=await l.text();throw new Error(`Rename failed: ${m}`)}return l.json()},onSuccess:(n,a)=>{const o=a.oldPath.split("/").slice(0,-1).join("/")||"/";i.invalidateQueries({queryKey:z.listing(o)})},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Rename failed:",n)}})}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 me({item:i,children:s,onOpenFile:n}){const[a,o]=r.useState(!1),[c,t]=r.useState({x:0,y:0}),[l,m]=r.useState(!1),[v,y]=r.useState(!1),[f,u]=r.useState(i.name),[d,C]=r.useState(""),N=r.useRef(null),{navigateTo:w}=F(),p=ei(),x=si(),D=ai(),M=r.useCallback(b=>{switch(b){case"open":i.isDir&&w(i.path);break;case"edit":n&&n(i.path);break;case"download":i.isDir||p.mutate(i.path);break;case"rename":u(i.name),C(""),m(!0);break;case"delete":y(!0);break}},[i,p,w]),X=r.useCallback(b=>{b.preventDefault(),b.stopPropagation(),t({x:b.clientX,y:b.clientY}),o(!0)},[]),$=r.useCallback(async()=>{if(!f||f===i.name){m(!1);return}C("");try{await D.mutateAsync({oldPath:i.path,newName:f.trim()}),m(!1)}catch(b){const T=b instanceof Error?b.message:"Failed to rename";C(T)}},[f,i,D]),U=r.useCallback(async()=>{try{await x.mutateAsync(i.path),y(!1)}catch(b){console.error("Delete failed:",b)}},[i.path,x]),Y=r.useCallback(b=>{b.key==="Enter"?(b.preventDefault(),$()):b.key==="Escape"&&(b.preventDefault(),m(!1))},[$]),g=r.useCallback(b=>{u(b.target.value),d&&C("")},[d]);r.useEffect(()=>{if(l&&N.current){const b=N.current;if(b.focus(),!i.isDir&&i.extension){const T=i.name.replace(new RegExp(`\\.${i.extension}$`),"");b.setSelectionRange(0,T.length)}else b.select()}},[l,i]);const S=f.trim().length>0&&!/[<>:"/\\|?*]/.test(f)&&!f.includes("..")&&f!==i.name,R=()=>p.isPending?"Downloading…":"Download",fe=()=>D.isPending?"Renaming…":"Rename",he=()=>x.isPending?"Deleting…":"Delete";r.useEffect(()=>{if(!a)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)}},[a]);const I=r.useCallback(b=>{o(!1),M(b)},[M]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{onContextMenu:X,children:s}),a?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:[i.isDir?e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("open"),className:h("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(j,{icon:Se,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Open"]}):null,i.isDir?null:e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("download"),disabled:p.isPending,className:h("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(j,{icon:Ee,size:16,strokeWidth:1.5,"aria-hidden":"true"}),R()]}),!i.isDir&&ri.has(i.extension.toLowerCase())?e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("edit"),className:h("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(j,{icon:Fe,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Edit"]}):null,e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("rename"),className:h("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(j,{icon:ze,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Rename"]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("delete"),className:h("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(j,{icon:de,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Delete"]})]})}):null,e.jsx(Q,{open:l,onOpenChange:m,children:e.jsx(_,{children:e.jsxs("div",{className:"p-6",children:[e.jsxs(V,{className:"mb-2",children:["Rename ",i.isDir?"Folder":"File"]}),e.jsxs(H,{className:"mb-4",children:['Enter a new name for "',i.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:[i.isDir?"Folder":"File"," Name"]}),e.jsx("input",{id:"rename-input",ref:N,type:"text",value:f,onChange:g,onKeyDown:Y,autoFocus:!0,spellCheck:!1,"aria-describedby":d?"rename-error":void 0,"aria-invalid":d?"true":"false",className:h("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]}),D.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:D.isPending,className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(k,{onClick:$,disabled:!S||D.isPending,className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",(!S||D.isPending)&&"opacity-50 cursor-not-allowed"),children:fe()})]})]})})}),e.jsx(Q,{open:v,onOpenChange:y,children:e.jsx(_,{children:e.jsxs("div",{className:"p-6",children:[e.jsxs(V,{className:"mb-2",children:["Delete ",i.isDir?"Folder":"File"]}),e.jsxs(H,{className:"mb-4",children:['Are you sure you want to delete "',i.name,'"?',i.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:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(k,{variant:"destructive",onClick:U,disabled:x.isPending,className:h("focus-visible:ring-2 focus-visible:ring-red-300 focus-visible:outline-none","touch-manipulation",x.isPending&&"opacity-50 cursor-not-allowed"),children:he()})]})]})})})]})}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 J(i){if(i===0)return"0 B";const s=1024,n=["B","KB","MB","GB","TB"],a=Math.floor(Math.log(i)/Math.log(s));return parseFloat((i/Math.pow(s,a)).toFixed(1))+" "+n[a]}function q(i){const s=new Date(i),a=new Date().getTime()-s.getTime(),o=Math.floor(a/1e3),c=Math.floor(o/60),t=Math.floor(c/60),l=Math.floor(t/24);return l>7?s.toLocaleDateString():l>0?l===1?"yesterday":`${l} days ago`:t>0?t===1?"1 hour ago":`${t} hours ago`:c>0?c===1?"1 minute ago":`${c} minutes ago`:"just now"}function pe(i){if(i.isDir)return ue;const s=i.extension.toLowerCase();return["jpg","jpeg","png","gif","webp","svg","bmp"].includes(s)?Me:["mp4","avi","mkv","mov","wmv","flv","webm"].includes(s)?Re:["mp3","wav","flac","aac","ogg","m4a"].includes(s)?Te:["zip","rar","7z","tar","gz","bz2"].includes(s)?Le:["txt","md","log","json","xml","yaml","yml"].includes(s)?Ke:["js","ts","jsx","tsx","py","java","cpp","c","h","css","html","php","rb","go","rs"].includes(s)?$e:ee}function li(i,s,n){return r.useMemo(()=>[...i].sort((o,c)=>{if(o.isDir&&!c.isDir)return-1;if(!o.isDir&&c.isDir)return 1;let t=0;switch(s){case"name":t=o.name.localeCompare(c.name);break;case"size":t=o.size-c.size;break;case"modified":t=new Date(o.modified).getTime()-new Date(c.modified).getTime();break;default:t=o.name.localeCompare(c.name)}return n?t:-t}),[i,s,n])}function oi(){return r.useMemo(()=>typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function ci({viewMode:i}){const s=i==="grid"?12:8;return i==="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:s},(n,a)=>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"})]},a))}):e.jsx("div",{className:"divide-y divide-primary-200","aria-busy":"true","aria-label":"Loading files",children:Array.from({length:s},(n,a)=>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"})]},a))})}const di=r.memo(function({item:s,isSelected:n,onClick:a,onDoubleClick:o,onKeyDown:c,onOpenFile:t,reduceMotion:l}){const m=r.useCallback(()=>{a(s)},[a,s]),v=r.useCallback(()=>{o(s)},[o,s]),y=r.useCallback(d=>{c(d,s)},[c,s]),f=()=>s.isDir?`${s.name}, folder`:`${s.name}, ${s.extension} file, ${J(s.size)}, modified ${q(s.modified)}`,u=e.jsxs(E.button,{type:"button",whileHover:l?{}:{scale:1.02},whileTap:l?{}:{scale:.98},transition:{duration:l?0:.15},onClick:m,onDoubleClick:v,onKeyDown:y,"aria-label":f(),className:h("flex flex-col items-center p-3 rounded-lg w-full border border-transparent","transition-all duration-150 ease-out","hover:bg-primary-50 hover:border-primary-100 focus-visible:bg-primary-50","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",n&&"bg-primary-100 border-primary-200"),children:[e.jsx(j,{icon:pe(s),size:40,strokeWidth:1,className:h("mb-2",s.isDir?"text-sky-500":"text-primary-500"),"aria-hidden":"true"}),e.jsx("span",{className:"text-[11px] text-center text-primary-900 font-medium truncate w-full min-w-0",children:s.name}),s.isDir?null:e.jsx("span",{className:"text-[10px] text-primary-400 mt-0.5 tabular-nums",children:J(s.size)})]});return e.jsx(me,{item:s,onOpenFile:t,children:u})}),ui=r.memo(function({item:s,isSelected:n,onClick:a,onDoubleClick:o,onKeyDown:c,onOpenFile:t,reduceMotion:l}){const m=r.useCallback(()=>{a(s)},[a,s]),v=r.useCallback(()=>{o(s)},[o,s]),y=r.useCallback(d=>{c(d,s)},[c,s]),f=()=>s.isDir?`${s.name}, folder, modified ${q(s.modified)}`:`${s.name}, ${s.extension} file, ${J(s.size)}, modified ${q(s.modified)}`,u=e.jsxs(E.button,{type:"button",whileHover:l?{}:{backgroundColor:"rgb(248 250 252)"},transition:{duration:l?0:.15},onClick:m,onDoubleClick:v,onKeyDown:y,"aria-label":f(),className:h("w-full grid grid-cols-[auto_1fr_auto_auto] gap-4 px-4 py-2.5 text-left","transition-all duration-150 ease-out","hover:bg-primary-50 focus-visible:bg-primary-50","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",n&&"bg-primary-100"),children:[e.jsx(j,{icon:pe(s),size:18,strokeWidth:1.5,className:h("mt-0.5 shrink-0",s.isDir?"text-sky-500":"text-primary-500"),"aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("span",{className:"text-[13px] text-primary-900 font-medium truncate block",children:s.name})}),e.jsx("div",{className:"text-xs text-primary-500 text-right w-16 tabular-nums shrink-0",children:s.isDir?"—":J(s.size)}),e.jsx("div",{className:"text-xs text-primary-500 text-right w-20 tabular-nums shrink-0",children:q(s.modified)})]});return e.jsx(me,{item:s,onOpenFile:t,children:u})}),mi=e.jsx("div",{className:"flex items-center justify-center h-full py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-lg bg-primary-50 mb-3",children:e.jsx(j,{icon:ue,size:24,strokeWidth:1.5,className:"text-primary-400","aria-hidden":"true"})}),e.jsx("p",{className:"text-sm text-primary-500",children:"This folder is empty"}),e.jsx("p",{className:"text-xs text-primary-400 mt-1",children:"Upload files or create a new folder to get started"})]})});function pi({listing:i,loading:s,onOpenFile:n}){const{viewMode:a,sortBy:o,sortAsc:c,selectedFiles:t,navigateTo:l,toggleFileSelection:m}=F(),[v,y]=r.useState(0),f=r.useRef(null),u=oi(),d=li(i?.items||[],o,c),C=r.useCallback(p=>{m(p.path)},[m]),N=r.useCallback(p=>{p.isDir?l(p.path):n&&ti.has(p.extension.toLowerCase())&&n(p.path)},[l,n]),w=r.useCallback((p,x)=>{p.key==="Enter"?(p.preventDefault(),x.isDir?l(x.path):m(x.path)):p.key===" "&&(p.preventDefault(),m(x.path))},[l,m]);return r.useEffect(()=>{const p=x=>{if(d.length)switch(x.key){case"ArrowDown":x.preventDefault(),y(D=>Math.min(D+1,d.length-1));break;case"ArrowUp":x.preventDefault(),y(D=>Math.max(D-1,0));break;case"Home":x.preventDefault(),y(0);break;case"End":x.preventDefault(),y(d.length-1);break}};if(f.current)return f.current.addEventListener("keydown",p),()=>{f.current?.removeEventListener("keydown",p)}},[d.length]),s?e.jsx(ci,{viewMode:a}):i?d.length===0?mi:a==="grid"?e.jsx("div",{ref:f,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((p,x)=>e.jsx("div",{role:"gridcell",children:e.jsx(di,{item:p,isSelected:t.has(p.path),onClick:C,onDoubleClick:N,onKeyDown:w,onOpenFile:n,reduceMotion:u})},p.path))}):e.jsx("div",{ref:f,className:"overflow-y-auto",role:"table","aria-label":"Files list",tabIndex:0,children:e.jsxs("div",{className:"divide-y divide-primary-100",children:[e.jsxs("div",{className:"grid grid-cols-[auto_1fr_auto_auto] gap-4 px-4 py-2 text-xs font-medium text-primary-400 uppercase tracking-wider bg-primary-50/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",role:"columnheader",children:"Size"}),e.jsx("div",{className:"w-20 text-right",role:"columnheader",children:"Modified"})]}),d.map((p,x)=>e.jsx("div",{role:"row",children:e.jsx(ui,{item:p,isSelected:t.has(p.path),onClick:C,onDoubleClick:N,onKeyDown:w,onOpenFile:n,reduceMotion:u})},p.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(i){if(i===0)return"0 B";const s=1024,n=["B","KB","MB","GB"],a=Math.floor(Math.log(i)/Math.log(s));return parseFloat((i/Math.pow(s,a)).toFixed(1))+" "+n[a]}function fi({open:i,onOpenChange:s,currentPath:n}){const[a,o]=r.useState([]),[c,t]=r.useState(!1),[l,m]=r.useState("idle"),v=r.useRef(null),y=ii(),f=r.useCallback(()=>{o([]),m("idle"),v.current&&(v.current.value="")},[]),u=r.useCallback(g=>{if(!g)return;const S=Array.from(g).map(R=>({file:R,id:Math.random().toString(36).substr(2,9)}));o(R=>[...R,...S])},[]),d=r.useCallback(g=>{u(g.target.files)},[u]),C=r.useCallback(g=>{g.preventDefault(),t(!1),u(g.dataTransfer.files)},[u]),N=r.useCallback(g=>{g.preventDefault(),t(!0)},[]),w=r.useCallback(g=>{g.preventDefault(),t(!1)},[]),p=r.useCallback(g=>{o(S=>S.filter(R=>R.id!==g))},[]),x=r.useCallback(()=>{v.current?.click()},[]),D=r.useCallback(g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),x())},[x]),M=r.useCallback(async()=>{if(a.length===0)return;const g=new DataTransfer;a.forEach(({file:S})=>{g.items.add(S)}),m("uploading");try{await y.mutateAsync({files:g.files,path:n}),m("success"),f(),s(!1)}catch(S){m("error"),console.error("Upload failed:",S)}},[a,n,y,f,s]),X=r.useCallback(g=>{g||f(),s(g)},[f,s]),$=a.reduce((g,{file:S})=>g+S.size,0),U=a.length,Y=()=>y.isPending||l==="uploading"?"Uploading…":U===0?"Upload":U===1?"Upload 1 File":`Upload ${U} Files`;return e.jsx(Q,{open:i,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 ",n==="/"?"root directory":n]}),e.jsxs("div",{onDrop:C,onDragOver:N,onDragLeave:w,onClick:x,onKeyDown:D,tabIndex:0,role:"button","aria-label":"Drop files here or click to choose files",className:h("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(j,{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(k,{variant:"outline",className:h("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(j,{icon:ee,size:18,strokeWidth:1.5,"aria-hidden":"true"}),e.jsx("span",{children:"Choose Files"})]}),e.jsx("input",{ref:v,type:"file",multiple:!0,onChange:d,className:"hidden","aria-hidden":"true"})]}),e.jsx(A,{children:a.length>0?e.jsxs(E.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 (",a.length,")"]}),e.jsx("div",{className:"max-h-32 overflow-y-auto border border-primary-200 rounded-lg",children:a.map(({file:g,id:S})=>e.jsxs(E.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(j,{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(k,{size:"icon-sm",variant:"ghost",onClick:()=>p(S),className:h("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(j,{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($)]})]}):null}),y.isPending||l==="uploading"?e.jsxs(E.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:y.isPending||l==="uploading",className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(k,{onClick:M,disabled:a.length===0||y.isPending||l==="uploading",className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:Y()})]})]})})})}function hi({open:i,onOpenChange:s,currentPath:n}){const[a,o]=r.useState(""),[c,t]=r.useState(""),l=ni(),m=r.useCallback(async()=>{if(a.trim()){t("");try{await l.mutateAsync({path:n,name:a.trim()}),o(""),s(!1)}catch(p){const x=p instanceof Error?p.message:"Failed to create folder";t(x),console.error("Create folder failed:",p)}}},[a,n,l,s]),v=r.useCallback(p=>{p||(o(""),t("")),s(p)},[s]),y=r.useCallback(p=>{p.key==="Enter"&&(p.preventDefault(),m())},[m]),f=r.useCallback(p=>{const x=p.target.value;o(x),c&&t("")},[c]),u=a.trim().length>0&&!/[<>:"/\\|?*]/.test(a)&&!a.includes(".."),d=()=>l.isPending?"Creating…":"Create Folder",N=a.trim()?a.includes("..")?'Folder name cannot contain ".."':/[<>:"/\\|?*]/.test(a)?'Invalid characters: < > : " / \\ | ? *':"":"",w=c||N;return e.jsx(Q,{open:i,onOpenChange:v,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 ",n==="/"?"root directory":n]}),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:a,onChange:f,onKeyDown:y,placeholder:"Enter folder name",autoComplete:"off",spellCheck:!1,autoFocus:!0,"aria-describedby":w?"folder-name-error":void 0,"aria-invalid":w?"true":"false",className:h("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",w?"border-red-300 focus-visible:ring-red-300":"border-primary-200 focus:border-primary-300")}),w?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:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(k,{onClick:m,disabled:!u||l.isPending,className:h("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&&a.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:i,onClose:s}){const n=Xe(i),a=Ye(),o=r.useRef(null),[c,t]=r.useState(null),[l,m]=r.useState(!1);r.useEffect(()=>{n.data&&c===null&&t(n.data.content)},[n.data,c]);const v=r.useMemo(()=>n.data?xi[n.data.extension.toLowerCase()]||n.data.extension.toUpperCase():"",[n.data]),y=r.useCallback(N=>{t(N.target.value),m(N.target.value!==n.data?.content)},[n.data]),f=r.useCallback(async()=>{if(c!==null)try{await a.mutateAsync({path:i,content:c}),m(!1)}catch{}},[i,c,a]),u=r.useCallback(()=>{l&&!window.confirm("You have unsaved changes. Discard them?")||s()},[l,s]);r.useEffect(()=>{const N=w=>{(w.ctrlKey||w.metaKey)&&w.key==="s"&&(w.preventDefault(),l&&f()),w.key==="Escape"&&u()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[f,u,l]);const d=r.useCallback(N=>{if(N.key==="Tab"){N.preventDefault();const w=N.currentTarget,p=w.selectionStart,x=w.selectionEnd,D=w.value,M=D.substring(0,p)+" "+D.substring(x);t(M),m(M!==n.data?.content),requestAnimationFrame(()=>{w.selectionStart=w.selectionEnd=p+2})}},[n.data]),C=i.split("/").pop()||i;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:C}),v?e.jsx("span",{className:"text-xs text-primary-500 bg-primary-100 px-2 py-0.5 rounded-full shrink-0",children:v}):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,a.isError?e.jsx("span",{className:"text-xs text-red-600",children:a.error.message}):null]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(k,{size:"sm",variant:"default",onClick:f,disabled:!l||a.isPending,className:h((!l||a.isPending)&&"opacity-50 cursor-not-allowed"),children:[e.jsx(j,{icon:Ue,size:16,strokeWidth:1.5,"aria-hidden":"true"}),a.isPending?"Saving…":"Save"]}),e.jsx(k,{size:"icon-sm",variant:"ghost",onClick:u,"aria-label":"Close editor",children:e.jsx(j,{icon:Ie,size:20,strokeWidth:1.5,"aria-hidden":"true"})})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.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…"})}):n.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:n.error instanceof Error?n.error.message:"Failed to load file"}),e.jsx(k,{size:"sm",variant:"secondary",onClick:()=>{n.refetch()},children:"Retry"})]})}):e.jsx("textarea",{ref:o,value:c??"",onChange:y,onKeyDown:d,spellCheck:!1,autoFocus:!0,className:h("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")})}),n.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:i}),e.jsx("span",{children:bi(n.data.size)})]}):null]})}function bi(i){return i<1024?`${i} B`:i<1024*1024?`${(i/1024).toFixed(1)} KB`:`${(i/(1024*1024)).toFixed(1)} MB`}function Li(){const i=L(),{currentPath:s,editingFile:n}=F(),[a,o]=r.useState(!1),[c,t]=r.useState(!1),l=Ze(s),v=ie({queryKey:Pe,queryFn:function(){return te(i)},initialData:function(){return te(i)},staleTime:1/0}).data?.isSidebarCollapsed??!1,y=r.useCallback(()=>{Ae(i,function(x){return{...x,isSidebarCollapsed:!x.isSidebarCollapsed}})},[i]),f=r.useCallback(()=>{o(!0)},[]),u=r.useCallback(()=>{t(!0)},[]),d=r.useCallback(p=>{F.getState().openInEditor(p)},[]),C=r.useCallback(()=>{F.getState().closeEditor()},[]),N=r.useMemo(()=>({display:"flex",flexDirection:"column",height:"100%",minHeight:0}),[]),w=e.jsx(He,{isCollapsed:v,onToggleCollapse:y,onSelectAction:()=>{}});return e.jsxs("div",{className:"h-screen bg-surface text-primary-900",children:[e.jsxs("div",{className:h("h-full overflow-hidden grid grid-cols-[auto_1fr]"),children:[w,e.jsxs("main",{"aria-label":"File explorer",style:N,children:[e.jsxs("header",{className:"border-b border-primary-100 px-4 py-3",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(Ge,{path:s})}),e.jsx(Je,{onUpload:f,onCreateFolder:u})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto",children:[e.jsx(pi,{listing:l.data,loading:l.isLoading,onOpenFile:d}),l.isError?e.jsxs("div",{className:"p-4 text-center","aria-live":"polite",children:[e.jsx("p",{className:"text-red-600 text-sm",children:l.error instanceof Error?l.error.message:"Failed to load files"}),e.jsx("button",{onClick:()=>{l.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(fi,{open:a,onOpenChange:o,currentPath:s}),e.jsx(hi,{open:c,onOpenChange:t,currentPath:s})]})]}),n?e.jsx(gi,{filePath:n,onClose:C}):null]})}export{Li as FileExplorerScreen};
1
+ import{j as e,r,L as se,u as L}from"./main-CEuT8-Qi.js";import{u as ie}from"./visuallyHidden-CO3ZD5AQ.js";import{K as be,c as h,b as ne,B as k,H as j,I as ye,r as ve,L as je,M as we,N as Ne,O as Ce,Q as ke,W as ae,Y as re,Z as ce,_ as De,$ as Se,k as Ee,a0 as Fe,a1 as ze,a2 as de,a3 as ue,a4 as Me,a5 as Re,a6 as Te,a7 as Le,a8 as Ke,a9 as $e,n as ee,aa as Ue,V as Ie}from"./button-DNC5N25i.js";import{T as P,a as W,b as B,c as O,s as Ae,d as Pe,g as te}from"./tooltip-D57Pal0B.js";import{u as F,D as Q,a as _,b as V,c as H,d as G}from"./use-file-explorer-state-DppKEjcl.js";import{m as E,A}from"./proxy-Cawf6X0W.js";import{M as We,a as Be,b as Oe,c as le}from"./menu-47ooFeSm.js";import{u as K}from"./useMutation-C5bTdeC1.js";import"./popupStateMapping-D5k-jOeY.js";import"./useButton-DVAfkehQ.js";import"./owner-CFRNz_Tp.js";import"./DirectionContext-DRcND-Cm.js";import"./composite-Bliqcmg4.js";import"./react-K9goXsVv.js";import"./useCompositeItem-CzdGhGcj.js";function qe({className:i}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"80",height:"80",viewBox:"0 0 80 80",fill:"none",className:i,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 r.useMemo(()=>typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function _e({isCollapsed:i,onToggleCollapse:s,onSelectAction:n}){const{navigateTo:a,currentPath:o}=F(),c=Qe(),t=r.useMemo(()=>({duration:c?0:.15,ease:i?"easeIn":"easeOut"}),[i,c]),l=r.useCallback(d=>{a(d)},[a]),m=r.useCallback((d,C)=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),C())},[]),v=r.useMemo(()=>[{path:"/",icon:be,label:"Home",id:"home"}],[]),y=r.useMemo(()=>({className:"border-r border-primary-200 h-full overflow-hidden bg-primary-100 flex flex-col"}),[]),f=48,u=300;return e.jsxs(E.aside,{initial:!1,animate:{width:c?i?f:u:void 0},style:{width:c?void 0:i?f:u},transition:t,className:y.className,role:"navigation","aria-label":"File explorer navigation",children:[e.jsxs(E.div,{layout:!0,transition:{layout:t},className:h("flex items-center h-12 px-2 justify-between"),children:[e.jsx(A,{initial:!1,children:i?null:e.jsx(E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,children:e.jsxs(se,{to:"/new",className:h(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(qe,{className:"size-5 rounded-sm","aria-hidden":"true"}),e.jsx("span",{children:"WebClaw"})]})})}),e.jsx(P,{children:e.jsxs(W,{children:[e.jsx(B,{onClick:s,onKeyDown:d=>m(d,s),render:e.jsx(k,{size:"icon-sm",variant:"ghost","aria-label":i?"Expand sidebar":"Collapse sidebar",className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:e.jsx(j,{icon:ye,size:20,strokeWidth:1.5,"aria-hidden":"true"})})}),e.jsx(O,{side:"right",children:i?"Expand sidebar":"Collapse sidebar"})]})})]}),e.jsx("div",{className:"px-2 mb-4",children:e.jsx(E.div,{layout:!0,transition:{layout:t},className:"w-full",children:e.jsx(P,{children:e.jsxs(W,{children:[e.jsx(B,{asChild:!0,children:e.jsxs(se,{to:"/chat/$sessionKey",params:{sessionKey:"main"},className:h(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:n,children:[e.jsx(j,{icon:ve,size:20,strokeWidth:1.5,className:"min-w-5","aria-hidden":"true"}),e.jsx(A,{initial:!1,mode:"wait",children:i?null:e.jsx(E.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,className:"overflow-hidden whitespace-nowrap",children:"Back to Chat"})})]})}),i?e.jsx(O,{side:"right",children:"Back to Chat"}):null]})})})}),e.jsx("div",{className:"flex-1 min-h-0 relative overflow-hidden",children:e.jsx(A,{initial:!1,children:i?e.jsx(E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,className:"px-2 space-y-1",children:v.map(d=>e.jsx(P,{children:e.jsxs(W,{children:[e.jsx(B,{onClick:()=>l(d.path),onKeyDown:C=>m(C,()=>l(d.path)),render:e.jsx(k,{size:"icon-sm",variant:"ghost","aria-current":o===d.path?"page":void 0,"aria-label":`Navigate to ${d.label}`,className:h("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(j,{icon:d.icon,size:20,strokeWidth:1.5,"aria-hidden":"true"})})}),e.jsx(O,{side:"right",children:d.label})]})},d.id))},"collapsed-content"):e.jsx(E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,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:v.map(d=>e.jsx("div",{role:"listitem",children:e.jsxs(k,{variant:"ghost",size:"sm",onClick:()=>l(d.path),onKeyDown:C=>m(C,()=>l(d.path)),"aria-current":o===d.path?"page":void 0,className:h("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(j,{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(E.div,{layout:!0,transition:{layout:t},className:"w-full",children:e.jsx(P,{children:e.jsxs(W,{children:[e.jsx(B,{asChild:!0,children:e.jsxs(k,{variant:"ghost",size:i?"icon-sm":"sm",className:h(i?"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(j,{icon:je,size:20,strokeWidth:1.5,className:"min-w-5","aria-hidden":"true"}),e.jsx(A,{initial:!1,mode:"wait",children:i?null:e.jsx(E.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,className:"overflow-hidden whitespace-nowrap",children:"Settings"})})]})}),i?e.jsx(O,{side:"right",children:"Settings"}):null]})})})})]})}function Ve(i,s){return i.isCollapsed===s.isCollapsed}const He=r.memo(_e,Ve);function Ge({path:i}){const{navigateTo:s}=F(),n=i==="/"?[]:i.split("/").filter(Boolean),a=[{name:"Home",path:"/"},...n.map((t,l)=>({name:t,path:"/"+n.slice(0,l+1).join("/")}))],o=r.useCallback(t=>{s(t)},[s]),c=r.useCallback((t,l)=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),s(l))},[s]);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:a.map((t,l)=>e.jsxs("li",{className:"flex items-center gap-1",children:[l>0?e.jsx(j,{icon:we,size:16,strokeWidth:1.5,className:"text-primary-400","aria-hidden":"true"}):null,e.jsxs("button",{type:"button",onClick:()=>o(t.path),onKeyDown:m=>c(m,t.path),"aria-current":l===a.length-1?"page":void 0,className:h("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===a.length-1?"text-primary-900 font-medium":"text-primary-600"),children:[l===0?e.jsx(j,{icon:Ne,size:16,strokeWidth:1.5,"aria-hidden":"true"}):null,e.jsx("span",{className:"whitespace-nowrap",children:t.name})]})]},t.path))})})}const Z=[{label:"Name",value:"name"},{label:"Size",value:"size"},{label:"Modified",value:"modified"}];function Je({onUpload:i,onCreateFolder:s}){const{viewMode:n,sortBy:a,sortAsc:o,setViewMode:c,setSortBy:t,toggleSort:l}=F(),m=r.useCallback(()=>{c("list")},[c]),v=r.useCallback(()=>{c("grid")},[c]),y=r.useCallback(u=>{t(u)},[t]),f=r.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(k,{size:"sm",variant:n==="list"?"default":"ghost",onClick:m,onKeyDown:u=>f(u,m),"aria-label":"Switch to list view","aria-pressed":n==="list",className:h("rounded-none border-0","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:e.jsx(j,{icon:Ce,size:18,strokeWidth:1.5,"aria-hidden":"true"})}),e.jsx(k,{size:"sm",variant:n==="grid"?"default":"ghost",onClick:v,onKeyDown:u=>f(u,v),"aria-label":"Switch to grid view","aria-pressed":n==="grid",className:h("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(j,{icon:ke,size:18,strokeWidth:1.5,"aria-hidden":"true"})})]}),e.jsxs(We,{children:[e.jsx(Be,{render:e.jsxs(k,{variant:"ghost",size:"sm",className:h("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===a)?.label}, ${o?"ascending":"descending"}`,children:[e.jsxs("span",{children:["Sort: ",Z.find(u=>u.value===a)?.label]}),e.jsx(j,{icon:o?ae:re,size:16,strokeWidth:1.5,"aria-hidden":"true"})]})}),e.jsxs(Oe,{side:"bottom",align:"start",children:[Z.map(u=>e.jsx(le,{onClick:()=>y(u.value),className:h(a===u.value&&"bg-primary-100 text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),"aria-current":a===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(j,{icon:o?re:ae,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(k,{variant:"ghost",size:"sm",onClick:i,onKeyDown:u=>f(u,i),className:h("gap-2","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Upload files",children:[e.jsx(j,{icon:ce,size:18,strokeWidth:1.5,"aria-hidden":"true"}),e.jsx("span",{children:"Upload"})]}),e.jsxs(k,{variant:"ghost",size:"sm",onClick:s,onKeyDown:u=>f(u,s),className:h("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(j,{icon:De,size:18,strokeWidth:1.5,"aria-hidden":"true"}),e.jsx("span",{children:"New Folder"})]})]})]})}const z={all:["files"],listing:i=>["files","listing",i],content:i=>["files","content",i]};function Xe(i){return ie({queryKey:z.content(i||""),queryFn:async({signal:s})=>{const n=await fetch(`/api/files/read?path=${encodeURIComponent(i)}`,{signal:s});if(!n.ok){const a=await n.json().catch(()=>({error:"Failed to read file"}));throw new Error(a.error||"Failed to read file")}return n.json()},enabled:!!i,staleTime:30*1e3,gcTime:300*1e3})}function Ye(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),K({mutationFn:async({path:n,content:a})=>{s.current?.abort();const o=new AbortController;s.current=o;const c=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,content:a}),signal:o.signal});if(!c.ok){const t=await c.json().catch(()=>({error:"Failed to save file"}));throw new Error(t.error||"Failed to save file")}return c.json()},onSuccess:(n,a)=>{i.invalidateQueries({queryKey:z.content(a.path)});const o=a.path.split("/").slice(0,-1).join("/")||"/";i.invalidateQueries({queryKey:z.listing(o)})}})}function Ze(i){return ie({queryKey:z.listing(i),queryFn:async({signal:s})=>{const n=await fetch(`/api/files/list?path=${encodeURIComponent(i)}`,{signal:s});if(!n.ok){const a=await n.text();throw new Error(`Failed to load files: ${a}`)}return n.json()},staleTime:300*1e3,gcTime:600*1e3,retry:3})}function ei(){const i=new Set,s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort(),i.forEach(n=>URL.revokeObjectURL(n)),i.clear()},[]),K({mutationFn:async n=>{s.current?.abort();const a=new AbortController;s.current=a;const o=await fetch(`/api/files/download?path=${encodeURIComponent(n)}`,{signal:a.signal});if(!o.ok){const v=await o.text();throw new Error(`Download failed: ${v}`)}const c=await o.blob(),t=window.URL.createObjectURL(c);i.add(t);const l=n.split("/").pop()||"download",m=document.createElement("a");m.href=t,m.download=l,document.body.appendChild(m),m.click(),document.body.removeChild(m),setTimeout(()=>{i.has(t)&&(URL.revokeObjectURL(t),i.delete(t))},100)},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Download failed:",n)}})}function ii(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),K({mutationFn:async({files:n,path:a})=>{s.current?.abort();const o=new AbortController;s.current=o;const c=[];for(let t=0;t<n.length;t++){const l=new FormData;l.append("path",a),l.append("file",n[t]);const m=await fetch("/api/files/upload",{method:"POST",body:l,signal:o.signal});if(!m.ok){const v=await m.text();throw new Error(`Upload failed for ${n[t].name}: ${v}`)}c.push(await m.json())}return c},onSuccess:(n,a)=>{i.invalidateQueries({queryKey:z.listing(a.path)})},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Upload failed:",n)}})}function si(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),K({mutationFn:async n=>{s.current?.abort();const a=new AbortController;s.current=a;const o=await fetch(`/api/files/delete?path=${encodeURIComponent(n)}`,{method:"DELETE",signal:a.signal});if(!o.ok){const c=await o.text();throw new Error(`Delete failed: ${c}`)}return o.json()},onSuccess:(n,a)=>{const o=a.split("/").slice(0,-1).join("/")||"/";i.invalidateQueries({queryKey:z.listing(o)})},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Delete failed:",n)}})}function ni(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),K({mutationFn:async({path:n,name:a})=>{s.current?.abort();const o=new AbortController;s.current=o;const c=await fetch("/api/files/mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:`${n}/${a}`}),signal:o.signal});if(!c.ok){const t=await c.text();throw new Error(`Create folder failed: ${t}`)}return c.json()},onSuccess:(n,a)=>{i.invalidateQueries({queryKey:z.listing(a.path)})},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Create folder failed:",n)}})}function ai(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),K({mutationFn:async({oldPath:n,newName:a})=>{s.current?.abort();const o=new AbortController;s.current=o;const t=`${n.split("/").slice(0,-1).join("/")}/${a}`,l=await fetch("/api/files/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({src:n,dst:t}),signal:o.signal});if(!l.ok){const m=await l.text();throw new Error(`Rename failed: ${m}`)}return l.json()},onSuccess:(n,a)=>{const o=a.oldPath.split("/").slice(0,-1).join("/")||"/";i.invalidateQueries({queryKey:z.listing(o)})},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Rename failed:",n)}})}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 me({item:i,children:s,onOpenFile:n}){const[a,o]=r.useState(!1),[c,t]=r.useState({x:0,y:0}),[l,m]=r.useState(!1),[v,y]=r.useState(!1),[f,u]=r.useState(i.name),[d,C]=r.useState(""),N=r.useRef(null),{navigateTo:w}=F(),p=ei(),x=si(),D=ai(),M=r.useCallback(b=>{switch(b){case"open":i.isDir&&w(i.path);break;case"edit":n&&n(i.path);break;case"download":i.isDir||p.mutate(i.path);break;case"rename":u(i.name),C(""),m(!0);break;case"delete":y(!0);break}},[i,p,w]),X=r.useCallback(b=>{b.preventDefault(),b.stopPropagation(),t({x:b.clientX,y:b.clientY}),o(!0)},[]),$=r.useCallback(async()=>{if(!f||f===i.name){m(!1);return}C("");try{await D.mutateAsync({oldPath:i.path,newName:f.trim()}),m(!1)}catch(b){const T=b instanceof Error?b.message:"Failed to rename";C(T)}},[f,i,D]),U=r.useCallback(async()=>{try{await x.mutateAsync(i.path),y(!1)}catch(b){console.error("Delete failed:",b)}},[i.path,x]),Y=r.useCallback(b=>{b.key==="Enter"?(b.preventDefault(),$()):b.key==="Escape"&&(b.preventDefault(),m(!1))},[$]),g=r.useCallback(b=>{u(b.target.value),d&&C("")},[d]);r.useEffect(()=>{if(l&&N.current){const b=N.current;if(b.focus(),!i.isDir&&i.extension){const T=i.name.replace(new RegExp(`\\.${i.extension}$`),"");b.setSelectionRange(0,T.length)}else b.select()}},[l,i]);const S=f.trim().length>0&&!/[<>:"/\\|?*]/.test(f)&&!f.includes("..")&&f!==i.name,R=()=>p.isPending?"Downloading…":"Download",fe=()=>D.isPending?"Renaming…":"Rename",he=()=>x.isPending?"Deleting…":"Delete";r.useEffect(()=>{if(!a)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)}},[a]);const I=r.useCallback(b=>{o(!1),M(b)},[M]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{onContextMenu:X,children:s}),a?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:[i.isDir?e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("open"),className:h("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(j,{icon:Se,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Open"]}):null,i.isDir?null:e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("download"),disabled:p.isPending,className:h("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(j,{icon:Ee,size:16,strokeWidth:1.5,"aria-hidden":"true"}),R()]}),!i.isDir&&ri.has(i.extension.toLowerCase())?e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("edit"),className:h("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(j,{icon:Fe,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Edit"]}):null,e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("rename"),className:h("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(j,{icon:ze,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Rename"]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("delete"),className:h("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(j,{icon:de,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Delete"]})]})}):null,e.jsx(Q,{open:l,onOpenChange:m,children:e.jsx(_,{children:e.jsxs("div",{className:"p-6",children:[e.jsxs(V,{className:"mb-2",children:["Rename ",i.isDir?"Folder":"File"]}),e.jsxs(H,{className:"mb-4",children:['Enter a new name for "',i.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:[i.isDir?"Folder":"File"," Name"]}),e.jsx("input",{id:"rename-input",ref:N,type:"text",value:f,onChange:g,onKeyDown:Y,autoFocus:!0,spellCheck:!1,"aria-describedby":d?"rename-error":void 0,"aria-invalid":d?"true":"false",className:h("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]}),D.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:D.isPending,className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(k,{onClick:$,disabled:!S||D.isPending,className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",(!S||D.isPending)&&"opacity-50 cursor-not-allowed"),children:fe()})]})]})})}),e.jsx(Q,{open:v,onOpenChange:y,children:e.jsx(_,{children:e.jsxs("div",{className:"p-6",children:[e.jsxs(V,{className:"mb-2",children:["Delete ",i.isDir?"Folder":"File"]}),e.jsxs(H,{className:"mb-4",children:['Are you sure you want to delete "',i.name,'"?',i.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:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(k,{variant:"destructive",onClick:U,disabled:x.isPending,className:h("focus-visible:ring-2 focus-visible:ring-red-300 focus-visible:outline-none","touch-manipulation",x.isPending&&"opacity-50 cursor-not-allowed"),children:he()})]})]})})})]})}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 J(i){if(i===0)return"0 B";const s=1024,n=["B","KB","MB","GB","TB"],a=Math.floor(Math.log(i)/Math.log(s));return parseFloat((i/Math.pow(s,a)).toFixed(1))+" "+n[a]}function q(i){const s=new Date(i),a=new Date().getTime()-s.getTime(),o=Math.floor(a/1e3),c=Math.floor(o/60),t=Math.floor(c/60),l=Math.floor(t/24);return l>7?s.toLocaleDateString():l>0?l===1?"yesterday":`${l} days ago`:t>0?t===1?"1 hour ago":`${t} hours ago`:c>0?c===1?"1 minute ago":`${c} minutes ago`:"just now"}function pe(i){if(i.isDir)return ue;const s=i.extension.toLowerCase();return["jpg","jpeg","png","gif","webp","svg","bmp"].includes(s)?Me:["mp4","avi","mkv","mov","wmv","flv","webm"].includes(s)?Re:["mp3","wav","flac","aac","ogg","m4a"].includes(s)?Te:["zip","rar","7z","tar","gz","bz2"].includes(s)?Le:["txt","md","log","json","xml","yaml","yml"].includes(s)?Ke:["js","ts","jsx","tsx","py","java","cpp","c","h","css","html","php","rb","go","rs"].includes(s)?$e:ee}function li(i,s,n){return r.useMemo(()=>[...i].sort((o,c)=>{if(o.isDir&&!c.isDir)return-1;if(!o.isDir&&c.isDir)return 1;let t=0;switch(s){case"name":t=o.name.localeCompare(c.name);break;case"size":t=o.size-c.size;break;case"modified":t=new Date(o.modified).getTime()-new Date(c.modified).getTime();break;default:t=o.name.localeCompare(c.name)}return n?t:-t}),[i,s,n])}function oi(){return r.useMemo(()=>typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function ci({viewMode:i}){const s=i==="grid"?12:8;return i==="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:s},(n,a)=>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"})]},a))}):e.jsx("div",{className:"divide-y divide-primary-200","aria-busy":"true","aria-label":"Loading files",children:Array.from({length:s},(n,a)=>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"})]},a))})}const di=r.memo(function({item:s,isSelected:n,onClick:a,onDoubleClick:o,onKeyDown:c,onOpenFile:t,reduceMotion:l}){const m=r.useCallback(()=>{a(s)},[a,s]),v=r.useCallback(()=>{o(s)},[o,s]),y=r.useCallback(d=>{c(d,s)},[c,s]),f=()=>s.isDir?`${s.name}, folder`:`${s.name}, ${s.extension} file, ${J(s.size)}, modified ${q(s.modified)}`,u=e.jsxs(E.button,{type:"button",whileHover:l?{}:{scale:1.02},whileTap:l?{}:{scale:.98},transition:{duration:l?0:.15},onClick:m,onDoubleClick:v,onKeyDown:y,"aria-label":f(),className:h("flex flex-col items-center p-3 rounded-lg w-full border border-transparent","transition-all duration-150 ease-out","hover:bg-primary-50 hover:border-primary-100 focus-visible:bg-primary-50","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",n&&"bg-primary-100 border-primary-200"),children:[e.jsx(j,{icon:pe(s),size:40,strokeWidth:1,className:h("mb-2",s.isDir?"text-sky-500":"text-primary-500"),"aria-hidden":"true"}),e.jsx("span",{className:"text-[11px] text-center text-primary-900 font-medium truncate w-full min-w-0",children:s.name}),s.isDir?null:e.jsx("span",{className:"text-[10px] text-primary-400 mt-0.5 tabular-nums",children:J(s.size)})]});return e.jsx(me,{item:s,onOpenFile:t,children:u})}),ui=r.memo(function({item:s,isSelected:n,onClick:a,onDoubleClick:o,onKeyDown:c,onOpenFile:t,reduceMotion:l}){const m=r.useCallback(()=>{a(s)},[a,s]),v=r.useCallback(()=>{o(s)},[o,s]),y=r.useCallback(d=>{c(d,s)},[c,s]),f=()=>s.isDir?`${s.name}, folder, modified ${q(s.modified)}`:`${s.name}, ${s.extension} file, ${J(s.size)}, modified ${q(s.modified)}`,u=e.jsxs(E.button,{type:"button",whileHover:l?{}:{backgroundColor:"rgb(248 250 252)"},transition:{duration:l?0:.15},onClick:m,onDoubleClick:v,onKeyDown:y,"aria-label":f(),className:h("w-full grid grid-cols-[auto_1fr_auto_auto] gap-4 px-4 py-2.5 text-left","transition-all duration-150 ease-out","hover:bg-primary-50 focus-visible:bg-primary-50","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",n&&"bg-primary-100"),children:[e.jsx(j,{icon:pe(s),size:18,strokeWidth:1.5,className:h("mt-0.5 shrink-0",s.isDir?"text-sky-500":"text-primary-500"),"aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("span",{className:"text-[13px] text-primary-900 font-medium truncate block",children:s.name})}),e.jsx("div",{className:"text-xs text-primary-500 text-right w-16 tabular-nums shrink-0",children:s.isDir?"—":J(s.size)}),e.jsx("div",{className:"text-xs text-primary-500 text-right w-20 tabular-nums shrink-0",children:q(s.modified)})]});return e.jsx(me,{item:s,onOpenFile:t,children:u})}),mi=e.jsx("div",{className:"flex items-center justify-center h-full py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-lg bg-primary-50 mb-3",children:e.jsx(j,{icon:ue,size:24,strokeWidth:1.5,className:"text-primary-400","aria-hidden":"true"})}),e.jsx("p",{className:"text-sm text-primary-500",children:"This folder is empty"}),e.jsx("p",{className:"text-xs text-primary-400 mt-1",children:"Upload files or create a new folder to get started"})]})});function pi({listing:i,loading:s,onOpenFile:n}){const{viewMode:a,sortBy:o,sortAsc:c,selectedFiles:t,navigateTo:l,toggleFileSelection:m}=F(),[v,y]=r.useState(0),f=r.useRef(null),u=oi(),d=li(i?.items||[],o,c),C=r.useCallback(p=>{m(p.path)},[m]),N=r.useCallback(p=>{p.isDir?l(p.path):n&&ti.has(p.extension.toLowerCase())&&n(p.path)},[l,n]),w=r.useCallback((p,x)=>{p.key==="Enter"?(p.preventDefault(),x.isDir?l(x.path):m(x.path)):p.key===" "&&(p.preventDefault(),m(x.path))},[l,m]);return r.useEffect(()=>{const p=x=>{if(d.length)switch(x.key){case"ArrowDown":x.preventDefault(),y(D=>Math.min(D+1,d.length-1));break;case"ArrowUp":x.preventDefault(),y(D=>Math.max(D-1,0));break;case"Home":x.preventDefault(),y(0);break;case"End":x.preventDefault(),y(d.length-1);break}};if(f.current)return f.current.addEventListener("keydown",p),()=>{f.current?.removeEventListener("keydown",p)}},[d.length]),s?e.jsx(ci,{viewMode:a}):i?d.length===0?mi:a==="grid"?e.jsx("div",{ref:f,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((p,x)=>e.jsx("div",{role:"gridcell",children:e.jsx(di,{item:p,isSelected:t.has(p.path),onClick:C,onDoubleClick:N,onKeyDown:w,onOpenFile:n,reduceMotion:u})},p.path))}):e.jsx("div",{ref:f,className:"overflow-y-auto",role:"table","aria-label":"Files list",tabIndex:0,children:e.jsxs("div",{className:"divide-y divide-primary-100",children:[e.jsxs("div",{className:"grid grid-cols-[auto_1fr_auto_auto] gap-4 px-4 py-2 text-xs font-medium text-primary-400 uppercase tracking-wider bg-primary-50/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",role:"columnheader",children:"Size"}),e.jsx("div",{className:"w-20 text-right",role:"columnheader",children:"Modified"})]}),d.map((p,x)=>e.jsx("div",{role:"row",children:e.jsx(ui,{item:p,isSelected:t.has(p.path),onClick:C,onDoubleClick:N,onKeyDown:w,onOpenFile:n,reduceMotion:u})},p.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(i){if(i===0)return"0 B";const s=1024,n=["B","KB","MB","GB"],a=Math.floor(Math.log(i)/Math.log(s));return parseFloat((i/Math.pow(s,a)).toFixed(1))+" "+n[a]}function fi({open:i,onOpenChange:s,currentPath:n}){const[a,o]=r.useState([]),[c,t]=r.useState(!1),[l,m]=r.useState("idle"),v=r.useRef(null),y=ii(),f=r.useCallback(()=>{o([]),m("idle"),v.current&&(v.current.value="")},[]),u=r.useCallback(g=>{if(!g)return;const S=Array.from(g).map(R=>({file:R,id:Math.random().toString(36).substr(2,9)}));o(R=>[...R,...S])},[]),d=r.useCallback(g=>{u(g.target.files)},[u]),C=r.useCallback(g=>{g.preventDefault(),t(!1),u(g.dataTransfer.files)},[u]),N=r.useCallback(g=>{g.preventDefault(),t(!0)},[]),w=r.useCallback(g=>{g.preventDefault(),t(!1)},[]),p=r.useCallback(g=>{o(S=>S.filter(R=>R.id!==g))},[]),x=r.useCallback(()=>{v.current?.click()},[]),D=r.useCallback(g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),x())},[x]),M=r.useCallback(async()=>{if(a.length===0)return;const g=new DataTransfer;a.forEach(({file:S})=>{g.items.add(S)}),m("uploading");try{await y.mutateAsync({files:g.files,path:n}),m("success"),f(),s(!1)}catch(S){m("error"),console.error("Upload failed:",S)}},[a,n,y,f,s]),X=r.useCallback(g=>{g||f(),s(g)},[f,s]),$=a.reduce((g,{file:S})=>g+S.size,0),U=a.length,Y=()=>y.isPending||l==="uploading"?"Uploading…":U===0?"Upload":U===1?"Upload 1 File":`Upload ${U} Files`;return e.jsx(Q,{open:i,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 ",n==="/"?"root directory":n]}),e.jsxs("div",{onDrop:C,onDragOver:N,onDragLeave:w,onClick:x,onKeyDown:D,tabIndex:0,role:"button","aria-label":"Drop files here or click to choose files",className:h("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(j,{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(k,{variant:"outline",className:h("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(j,{icon:ee,size:18,strokeWidth:1.5,"aria-hidden":"true"}),e.jsx("span",{children:"Choose Files"})]}),e.jsx("input",{ref:v,type:"file",multiple:!0,onChange:d,className:"hidden","aria-hidden":"true"})]}),e.jsx(A,{children:a.length>0?e.jsxs(E.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 (",a.length,")"]}),e.jsx("div",{className:"max-h-32 overflow-y-auto border border-primary-200 rounded-lg",children:a.map(({file:g,id:S})=>e.jsxs(E.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(j,{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(k,{size:"icon-sm",variant:"ghost",onClick:()=>p(S),className:h("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(j,{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($)]})]}):null}),y.isPending||l==="uploading"?e.jsxs(E.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:y.isPending||l==="uploading",className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(k,{onClick:M,disabled:a.length===0||y.isPending||l==="uploading",className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:Y()})]})]})})})}function hi({open:i,onOpenChange:s,currentPath:n}){const[a,o]=r.useState(""),[c,t]=r.useState(""),l=ni(),m=r.useCallback(async()=>{if(a.trim()){t("");try{await l.mutateAsync({path:n,name:a.trim()}),o(""),s(!1)}catch(p){const x=p instanceof Error?p.message:"Failed to create folder";t(x),console.error("Create folder failed:",p)}}},[a,n,l,s]),v=r.useCallback(p=>{p||(o(""),t("")),s(p)},[s]),y=r.useCallback(p=>{p.key==="Enter"&&(p.preventDefault(),m())},[m]),f=r.useCallback(p=>{const x=p.target.value;o(x),c&&t("")},[c]),u=a.trim().length>0&&!/[<>:"/\\|?*]/.test(a)&&!a.includes(".."),d=()=>l.isPending?"Creating…":"Create Folder",N=a.trim()?a.includes("..")?'Folder name cannot contain ".."':/[<>:"/\\|?*]/.test(a)?'Invalid characters: < > : " / \\ | ? *':"":"",w=c||N;return e.jsx(Q,{open:i,onOpenChange:v,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 ",n==="/"?"root directory":n]}),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:a,onChange:f,onKeyDown:y,placeholder:"Enter folder name",autoComplete:"off",spellCheck:!1,autoFocus:!0,"aria-describedby":w?"folder-name-error":void 0,"aria-invalid":w?"true":"false",className:h("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",w?"border-red-300 focus-visible:ring-red-300":"border-primary-200 focus:border-primary-300")}),w?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:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(k,{onClick:m,disabled:!u||l.isPending,className:h("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&&a.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:i,onClose:s}){const n=Xe(i),a=Ye(),o=r.useRef(null),[c,t]=r.useState(null),[l,m]=r.useState(!1);r.useEffect(()=>{n.data&&c===null&&t(n.data.content)},[n.data,c]);const v=r.useMemo(()=>n.data?xi[n.data.extension.toLowerCase()]||n.data.extension.toUpperCase():"",[n.data]),y=r.useCallback(N=>{t(N.target.value),m(N.target.value!==n.data?.content)},[n.data]),f=r.useCallback(async()=>{if(c!==null)try{await a.mutateAsync({path:i,content:c}),m(!1)}catch{}},[i,c,a]),u=r.useCallback(()=>{l&&!window.confirm("You have unsaved changes. Discard them?")||s()},[l,s]);r.useEffect(()=>{const N=w=>{(w.ctrlKey||w.metaKey)&&w.key==="s"&&(w.preventDefault(),l&&f()),w.key==="Escape"&&u()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[f,u,l]);const d=r.useCallback(N=>{if(N.key==="Tab"){N.preventDefault();const w=N.currentTarget,p=w.selectionStart,x=w.selectionEnd,D=w.value,M=D.substring(0,p)+" "+D.substring(x);t(M),m(M!==n.data?.content),requestAnimationFrame(()=>{w.selectionStart=w.selectionEnd=p+2})}},[n.data]),C=i.split("/").pop()||i;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:C}),v?e.jsx("span",{className:"text-xs text-primary-500 bg-primary-100 px-2 py-0.5 rounded-full shrink-0",children:v}):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,a.isError?e.jsx("span",{className:"text-xs text-red-600",children:a.error.message}):null]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(k,{size:"sm",variant:"default",onClick:f,disabled:!l||a.isPending,className:h((!l||a.isPending)&&"opacity-50 cursor-not-allowed"),children:[e.jsx(j,{icon:Ue,size:16,strokeWidth:1.5,"aria-hidden":"true"}),a.isPending?"Saving…":"Save"]}),e.jsx(k,{size:"icon-sm",variant:"ghost",onClick:u,"aria-label":"Close editor",children:e.jsx(j,{icon:Ie,size:20,strokeWidth:1.5,"aria-hidden":"true"})})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.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…"})}):n.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:n.error instanceof Error?n.error.message:"Failed to load file"}),e.jsx(k,{size:"sm",variant:"secondary",onClick:()=>{n.refetch()},children:"Retry"})]})}):e.jsx("textarea",{ref:o,value:c??"",onChange:y,onKeyDown:d,spellCheck:!1,autoFocus:!0,className:h("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")})}),n.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:i}),e.jsx("span",{children:bi(n.data.size)})]}):null]})}function bi(i){return i<1024?`${i} B`:i<1024*1024?`${(i/1024).toFixed(1)} KB`:`${(i/(1024*1024)).toFixed(1)} MB`}function Li(){const i=L(),{currentPath:s,editingFile:n}=F(),[a,o]=r.useState(!1),[c,t]=r.useState(!1),l=Ze(s),v=ie({queryKey:Pe,queryFn:function(){return te(i)},initialData:function(){return te(i)},staleTime:1/0}).data?.isSidebarCollapsed??!1,y=r.useCallback(()=>{Ae(i,function(x){return{...x,isSidebarCollapsed:!x.isSidebarCollapsed}})},[i]),f=r.useCallback(()=>{o(!0)},[]),u=r.useCallback(()=>{t(!0)},[]),d=r.useCallback(p=>{F.getState().openInEditor(p)},[]),C=r.useCallback(()=>{F.getState().closeEditor()},[]),N=r.useMemo(()=>({display:"flex",flexDirection:"column",height:"100%",minHeight:0}),[]),w=e.jsx(He,{isCollapsed:v,onToggleCollapse:y,onSelectAction:()=>{}});return e.jsxs("div",{className:"h-screen bg-surface text-primary-900",children:[e.jsxs("div",{className:h("h-full overflow-hidden grid grid-cols-[auto_1fr]"),children:[w,e.jsxs("main",{"aria-label":"File explorer",style:N,children:[e.jsxs("header",{className:"border-b border-primary-100 px-4 py-3",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(Ge,{path:s})}),e.jsx(Je,{onUpload:f,onCreateFolder:u})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto",children:[e.jsx(pi,{listing:l.data,loading:l.isLoading,onOpenFile:d}),l.isError?e.jsxs("div",{className:"p-4 text-center","aria-live":"polite",children:[e.jsx("p",{className:"text-red-600 text-sm",children:l.error instanceof Error?l.error.message:"Failed to load files"}),e.jsx("button",{onClick:()=>{l.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(fi,{open:a,onOpenChange:o,currentPath:s}),e.jsx(hi,{open:c,onOpenChange:t,currentPath:s})]})]}),n?e.jsx(gi,{filePath:n,onClose:C}):null]})}export{Li as FileExplorerScreen};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/file-explorer-screen-CpY1O_ag.js","assets/main-CEuT8-Qi.js","assets/visuallyHidden-CO3ZD5AQ.js","assets/button-DNC5N25i.js","assets/tooltip-D57Pal0B.js","assets/popupStateMapping-D5k-jOeY.js","assets/useButton-DVAfkehQ.js","assets/owner-CFRNz_Tp.js","assets/DirectionContext-DRcND-Cm.js","assets/use-file-explorer-state-DppKEjcl.js","assets/composite-Bliqcmg4.js","assets/react-K9goXsVv.js","assets/proxy-Cawf6X0W.js","assets/menu-47ooFeSm.js","assets/useCompositeItem-CzdGhGcj.js","assets/useMutation-C5bTdeC1.js"])))=>i.map(i=>d[i]);
2
+ import{j as e,r,_ as s}from"./main-CEuT8-Qi.js";const n=r.lazy(()=>s(()=>import("./file-explorer-screen-CpY1O_ag.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])).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,3 +1,3 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/cpp-B-lmv-kZ.js","assets/regexp-CDVJQ6XC.js","assets/c-BIGW1oBm.js","assets/sql-BLtJtn59.js","assets/graphql-ChdNCCLP.js","assets/javascript-wDzz0qaB.js","assets/typescript-BPQ3VLAy.js","assets/jsx-g9-lgVsj.js","assets/tsx-COt5Ahok.js","assets/html-GMplVEZG.js","assets/css-DPfMkruS.js","assets/php-CDn_0X-4.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/json-Cp-IABpG.js","assets/ruby-FDmvQDUv.js","assets/shell-DfDnw5Jg.js","assets/yaml-Buea-lGh.js","assets/core-BrHBc0Zp.js","assets/index-T4TOjvD0.js"])))=>i.map(i=>d[i]);
2
- import{r as _,j as u,_ as r}from"./main-B_dlfHME.js";import{H as k,n as J,B as C,F as q,X as z,x as U,c as T}from"./button-Dg7VFQQn.js";import{c as G}from"./react-irH8OzhB.js";function X(e,s){let t;try{t=e()}catch{return}return{getItem:i=>{var a;const p=f=>f===null?null:JSON.parse(f,void 0),c=(a=t.getItem(i))!=null?a:null;return c instanceof Promise?c.then(p):p(c)},setItem:(i,a)=>t.setItem(i,JSON.stringify(a,void 0)),removeItem:i=>t.removeItem(i)}}const D=e=>s=>{try{const t=e(s);return t instanceof Promise?t:{then(n){return D(n)(t)},catch(n){return this}}}catch(t){return{then(n){return this},catch(n){return D(n)(t)}}}},$=(e,s)=>(t,n,i)=>{let a={storage:X(()=>window.localStorage),partialize:o=>o,version:0,merge:(o,g)=>({...g,...o}),...s},p=!1,c=0;const f=new Set,E=new Set;let m=a.storage;if(!m)return e((...o)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),t(...o)},n,i);const L=()=>{const o=a.partialize({...n()});return m.setItem(a.name,{state:o,version:a.version})},P=i.setState;i.setState=(o,g)=>(P(o,g),L());const x=e((...o)=>(t(...o),L()),n,i);i.getInitialState=()=>x;let d;const b=()=>{var o,g;if(!m)return;const w=++c;p=!1,f.forEach(l=>{var h;return l((h=n())!=null?h:x)});const y=((g=a.onRehydrateStorage)==null?void 0:g.call(a,(o=n())!=null?o:x))||void 0;return D(m.getItem.bind(m))(a.name).then(l=>{if(l)if(typeof l.version=="number"&&l.version!==a.version){if(a.migrate){const h=a.migrate(l.state,l.version);return h instanceof Promise?h.then(I=>[!0,I]):[!0,h]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,l.state];return[!1,void 0]}).then(l=>{var h;if(w!==c)return;const[I,R]=l;if(d=a.merge(R,(h=n())!=null?h:x),t(d,!0),I)return L()}).then(()=>{w===c&&(y?.(d,void 0),d=n(),p=!0,E.forEach(l=>l(d)))}).catch(l=>{w===c&&y?.(void 0,l)})};return i.persist={setOptions:o=>{a={...a,...o},o.storage&&(m=o.storage)},clearStorage:()=>{m?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>b(),hasHydrated:()=>p,onHydrate:o=>(f.add(o),()=>{f.delete(o)}),onFinishHydration:o=>(E.add(o),()=>{E.delete(o)})},a.skipHydration||b(),d||x},Q=$,O=G()(Q(e=>({settings:{showToolMessages:!0,showReasoningBlocks:!0,showSearchSources:!0,inlineFilePreview:!1,theme:"system",fontFamily:"system",density:"comfortable",accentColor:"green",chatWidth:"wide",sidebarWidth:"normal",bubbleStyle:"default"},updateSettings:s=>e(t=>({settings:{...t.settings,...s}}))}),{name:"chat-settings",merge:(e,s)=>{const t=e;return{...s,...t,settings:{...s.settings,...t?.settings??{}}}}}));function ue(){const e=O(t=>t.settings),s=O(t=>t.updateSettings);return{settings:e,updateSettings:s}}function Y(){const e=O(n=>n.settings.theme),[s,t]=_.useState(!1);return _.useEffect(()=>{if(typeof window>"u")return;const n=window.matchMedia("(prefers-color-scheme: dark)");t(n.matches);function i(a){t(a.matches)}return n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[]),_.useMemo(()=>e==="dark"?"dark":e==="light"||e==="frost-light"?"light":e==="frost-dark"||s?"dark":"light",[e,s])}const K=new Set(["bash","c","cpp","csharp","css","diff","dockerfile","go","graphql","html","java","javascript","json","jsx","kotlin","markdown","php","python","regexp","ruby","rust","shell","sql","swift","toml","typescript","tsx","xml","yaml"]),Z={js:"javascript",ts:"typescript",tsx:"tsx",jsx:"jsx",typescriptreact:"tsx",javascriptreact:"jsx",react:"jsx",sh:"bash",shell:"bash",yml:"yaml",md:"markdown",txt:"text"};function H(e){const t=e.trim().toLowerCase().replace(/^language-/,"").replace(/^\[|\]$/g,"").split(/[\s,]+/)[0]||"text";return Z[t]??t}function ee(e){const s=H(e);return K.has(s)?s:"text"}function te(e){return{bash:"Bash",python:"Python",javascript:"JavaScript",typescript:"TypeScript",tsx:"TSX",jsx:"JSX",json:"JSON",html:"HTML",css:"CSS",sql:"SQL",yaml:"YAML",markdown:"Markdown",text:"Plain Text"}[e]||e.charAt(0).toUpperCase()+e.slice(1)}const re={bash:()=>r(()=>import("./shell-DfDnw5Jg.js").then(e=>e.b),[]).then(e=>e.default),c:()=>r(()=>import("./c-BIGW1oBm.js"),[]).then(e=>e.default),cpp:()=>r(()=>import("./cpp-B-lmv-kZ.js"),__vite__mapDeps([0,1,2,3])).then(e=>e.default),csharp:()=>r(()=>import("./csharp-K5feNrxe.js"),[]).then(e=>e.default),css:()=>r(()=>import("./css-DPfMkruS.js"),[]).then(e=>e.default),diff:()=>r(()=>import("./diff-D97Zzqfu.js"),[]).then(e=>e.default),dockerfile:()=>r(()=>import("./dockerfile-BcOcwvcX.js"),[]).then(e=>e.default),go:()=>r(()=>import("./go-Dn2_MT6a.js"),[]).then(e=>e.default),graphql:()=>r(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([4,5,6,7,8])).then(e=>e.default),html:()=>r(()=>import("./html-GMplVEZG.js"),__vite__mapDeps([9,5,10])).then(e=>e.default),java:()=>r(()=>import("./java-CylS5w8V.js"),[]).then(e=>e.default),javascript:()=>r(()=>import("./javascript-wDzz0qaB.js"),[]).then(e=>e.default),json:()=>r(()=>import("./json-Cp-IABpG.js"),[]).then(e=>e.default),jsx:()=>r(()=>import("./jsx-g9-lgVsj.js"),[]).then(e=>e.default),kotlin:()=>r(()=>import("./kotlin-BdnUsdx6.js"),[]).then(e=>e.default),markdown:()=>r(()=>import("./markdown-Cvjx9yec.js"),[]).then(e=>e.default),php:()=>r(()=>import("./php-CDn_0X-4.js"),__vite__mapDeps([11,9,5,10,12,13,3,14])).then(e=>e.default),python:()=>r(()=>import("./python-B6aJPvgy.js"),[]).then(e=>e.default),regexp:()=>r(()=>import("./regexp-CDVJQ6XC.js"),[]).then(e=>e.default),ruby:()=>r(()=>import("./ruby-FDmvQDUv.js"),__vite__mapDeps([15,9,5,10,12,13,3,4,6,7,8,0,1,2,16,17])).then(e=>e.default),rust:()=>r(()=>import("./rust-B1yitclQ.js"),[]).then(e=>e.default),shell:()=>r(()=>import("./shell-DfDnw5Jg.js").then(e=>e.a),[]).then(e=>e.default),sql:()=>r(()=>import("./sql-BLtJtn59.js"),[]).then(e=>e.default),swift:()=>r(()=>import("./swift-Dg5xB15N.js"),[]).then(e=>e.default),toml:()=>r(()=>import("./toml-vGWfd6FD.js"),[]).then(e=>e.default),typescript:()=>r(()=>import("./typescript-BPQ3VLAy.js"),[]).then(e=>e.default),tsx:()=>r(()=>import("./tsx-COt5Ahok.js"),[]).then(e=>e.default),xml:()=>r(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([12,13])).then(e=>e.default),yaml:()=>r(()=>import("./yaml-Buea-lGh.js"),[]).then(e=>e.default)},ne={sh:"bash",zsh:"bash",js:"javascript",ts:"typescript",py:"python",rb:"ruby",rs:"rust",cs:"csharp","c++":"cpp",yml:"yaml",md:"markdown",docker:"dockerfile"};let j=null;const N=new Set;async function se(){if(!j){const[{createHighlighterCore:e},{createJavaScriptRegexEngine:s},t,n]=await Promise.all([r(()=>import("./core-BrHBc0Zp.js"),__vite__mapDeps([18,19])),r(()=>import("./engine-javascript-PwbX1GN8.js"),[]),r(()=>import("./vitesse-dark-D0r3Knsf.js"),[]).then(i=>i.default),r(()=>import("./vitesse-light-CVO1_9PV.js"),[]).then(i=>i.default)]);j=e({themes:[t,n],langs:[],engine:s()})}return j}async function ae(e,s){const t=ne[s]||s;if(N.has(t))return t;const n=re[t];if(!n)return"text";try{const i=await n();return await e.loadLanguage(i),N.add(t),t}catch{return"text"}}function ce({content:e,ariaLabel:s,language:t="text",filename:n,className:i}){const a=Y(),[p,c]=_.useState(!1),[f,E]=_.useState(null),[m,L]=_.useState("text"),[P,x]=_.useState(),[d,b]=_.useState(!1),o=_.useMemo(()=>e,[e]),g=H(t||"text"),w=a==="dark"?"vitesse-dark":"vitesse-light";_.useEffect(()=>{let v=!0;async function S(){try{const A=await se();if(!v)return;const F=ee(g),V=await ae(A,F);if(!v)return;const W=A.codeToHtml(e,{lang:V,theme:w});if(v){L(V),E(W);const B=A.getTheme(w);x(B.bg)}}catch{v&&E(null)}}return S(),()=>{v=!1}},[e,g,w]),_.useEffect(()=>{if(typeof window>"u")return;const v=window.localStorage.getItem("opencami-code-wrap");b(v==="1")},[]);function y(){b(v=>{const S=!v;return typeof window<"u"&&window.localStorage.setItem("opencami-code-wrap",S?"1":"0"),S})}async function l(){try{await navigator.clipboard.writeText(e),c(!0),window.setTimeout(()=>c(!1),1600)}catch{c(!1)}}const R=!(e.replace(/\n$/,"").split(`
2
+ import{r as _,j as u,_ as r}from"./main-CEuT8-Qi.js";import{H as k,n as J,B as C,F as q,X as z,x as U,c as T}from"./button-DNC5N25i.js";import{c as G}from"./react-K9goXsVv.js";function X(e,s){let t;try{t=e()}catch{return}return{getItem:i=>{var a;const p=f=>f===null?null:JSON.parse(f,void 0),c=(a=t.getItem(i))!=null?a:null;return c instanceof Promise?c.then(p):p(c)},setItem:(i,a)=>t.setItem(i,JSON.stringify(a,void 0)),removeItem:i=>t.removeItem(i)}}const D=e=>s=>{try{const t=e(s);return t instanceof Promise?t:{then(n){return D(n)(t)},catch(n){return this}}}catch(t){return{then(n){return this},catch(n){return D(n)(t)}}}},$=(e,s)=>(t,n,i)=>{let a={storage:X(()=>window.localStorage),partialize:o=>o,version:0,merge:(o,g)=>({...g,...o}),...s},p=!1,c=0;const f=new Set,E=new Set;let m=a.storage;if(!m)return e((...o)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),t(...o)},n,i);const L=()=>{const o=a.partialize({...n()});return m.setItem(a.name,{state:o,version:a.version})},P=i.setState;i.setState=(o,g)=>(P(o,g),L());const x=e((...o)=>(t(...o),L()),n,i);i.getInitialState=()=>x;let d;const b=()=>{var o,g;if(!m)return;const w=++c;p=!1,f.forEach(l=>{var h;return l((h=n())!=null?h:x)});const y=((g=a.onRehydrateStorage)==null?void 0:g.call(a,(o=n())!=null?o:x))||void 0;return D(m.getItem.bind(m))(a.name).then(l=>{if(l)if(typeof l.version=="number"&&l.version!==a.version){if(a.migrate){const h=a.migrate(l.state,l.version);return h instanceof Promise?h.then(I=>[!0,I]):[!0,h]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,l.state];return[!1,void 0]}).then(l=>{var h;if(w!==c)return;const[I,R]=l;if(d=a.merge(R,(h=n())!=null?h:x),t(d,!0),I)return L()}).then(()=>{w===c&&(y?.(d,void 0),d=n(),p=!0,E.forEach(l=>l(d)))}).catch(l=>{w===c&&y?.(void 0,l)})};return i.persist={setOptions:o=>{a={...a,...o},o.storage&&(m=o.storage)},clearStorage:()=>{m?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>b(),hasHydrated:()=>p,onHydrate:o=>(f.add(o),()=>{f.delete(o)}),onFinishHydration:o=>(E.add(o),()=>{E.delete(o)})},a.skipHydration||b(),d||x},Q=$,O=G()(Q(e=>({settings:{showToolMessages:!0,showReasoningBlocks:!0,showSearchSources:!0,inlineFilePreview:!1,theme:"system",fontFamily:"system",density:"comfortable",accentColor:"green",chatWidth:"wide",sidebarWidth:"normal",bubbleStyle:"default"},updateSettings:s=>e(t=>({settings:{...t.settings,...s}}))}),{name:"chat-settings",merge:(e,s)=>{const t=e;return{...s,...t,settings:{...s.settings,...t?.settings??{}}}}}));function ue(){const e=O(t=>t.settings),s=O(t=>t.updateSettings);return{settings:e,updateSettings:s}}function Y(){const e=O(n=>n.settings.theme),[s,t]=_.useState(!1);return _.useEffect(()=>{if(typeof window>"u")return;const n=window.matchMedia("(prefers-color-scheme: dark)");t(n.matches);function i(a){t(a.matches)}return n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[]),_.useMemo(()=>e==="dark"?"dark":e==="light"||e==="frost-light"?"light":e==="frost-dark"||s?"dark":"light",[e,s])}const K=new Set(["bash","c","cpp","csharp","css","diff","dockerfile","go","graphql","html","java","javascript","json","jsx","kotlin","markdown","php","python","regexp","ruby","rust","shell","sql","swift","toml","typescript","tsx","xml","yaml"]),Z={js:"javascript",ts:"typescript",tsx:"tsx",jsx:"jsx",typescriptreact:"tsx",javascriptreact:"jsx",react:"jsx",sh:"bash",shell:"bash",yml:"yaml",md:"markdown",txt:"text"};function H(e){const t=e.trim().toLowerCase().replace(/^language-/,"").replace(/^\[|\]$/g,"").split(/[\s,]+/)[0]||"text";return Z[t]??t}function ee(e){const s=H(e);return K.has(s)?s:"text"}function te(e){return{bash:"Bash",python:"Python",javascript:"JavaScript",typescript:"TypeScript",tsx:"TSX",jsx:"JSX",json:"JSON",html:"HTML",css:"CSS",sql:"SQL",yaml:"YAML",markdown:"Markdown",text:"Plain Text"}[e]||e.charAt(0).toUpperCase()+e.slice(1)}const re={bash:()=>r(()=>import("./shell-DfDnw5Jg.js").then(e=>e.b),[]).then(e=>e.default),c:()=>r(()=>import("./c-BIGW1oBm.js"),[]).then(e=>e.default),cpp:()=>r(()=>import("./cpp-B-lmv-kZ.js"),__vite__mapDeps([0,1,2,3])).then(e=>e.default),csharp:()=>r(()=>import("./csharp-K5feNrxe.js"),[]).then(e=>e.default),css:()=>r(()=>import("./css-DPfMkruS.js"),[]).then(e=>e.default),diff:()=>r(()=>import("./diff-D97Zzqfu.js"),[]).then(e=>e.default),dockerfile:()=>r(()=>import("./dockerfile-BcOcwvcX.js"),[]).then(e=>e.default),go:()=>r(()=>import("./go-Dn2_MT6a.js"),[]).then(e=>e.default),graphql:()=>r(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([4,5,6,7,8])).then(e=>e.default),html:()=>r(()=>import("./html-GMplVEZG.js"),__vite__mapDeps([9,5,10])).then(e=>e.default),java:()=>r(()=>import("./java-CylS5w8V.js"),[]).then(e=>e.default),javascript:()=>r(()=>import("./javascript-wDzz0qaB.js"),[]).then(e=>e.default),json:()=>r(()=>import("./json-Cp-IABpG.js"),[]).then(e=>e.default),jsx:()=>r(()=>import("./jsx-g9-lgVsj.js"),[]).then(e=>e.default),kotlin:()=>r(()=>import("./kotlin-BdnUsdx6.js"),[]).then(e=>e.default),markdown:()=>r(()=>import("./markdown-Cvjx9yec.js"),[]).then(e=>e.default),php:()=>r(()=>import("./php-CDn_0X-4.js"),__vite__mapDeps([11,9,5,10,12,13,3,14])).then(e=>e.default),python:()=>r(()=>import("./python-B6aJPvgy.js"),[]).then(e=>e.default),regexp:()=>r(()=>import("./regexp-CDVJQ6XC.js"),[]).then(e=>e.default),ruby:()=>r(()=>import("./ruby-FDmvQDUv.js"),__vite__mapDeps([15,9,5,10,12,13,3,4,6,7,8,0,1,2,16,17])).then(e=>e.default),rust:()=>r(()=>import("./rust-B1yitclQ.js"),[]).then(e=>e.default),shell:()=>r(()=>import("./shell-DfDnw5Jg.js").then(e=>e.a),[]).then(e=>e.default),sql:()=>r(()=>import("./sql-BLtJtn59.js"),[]).then(e=>e.default),swift:()=>r(()=>import("./swift-Dg5xB15N.js"),[]).then(e=>e.default),toml:()=>r(()=>import("./toml-vGWfd6FD.js"),[]).then(e=>e.default),typescript:()=>r(()=>import("./typescript-BPQ3VLAy.js"),[]).then(e=>e.default),tsx:()=>r(()=>import("./tsx-COt5Ahok.js"),[]).then(e=>e.default),xml:()=>r(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([12,13])).then(e=>e.default),yaml:()=>r(()=>import("./yaml-Buea-lGh.js"),[]).then(e=>e.default)},ne={sh:"bash",zsh:"bash",js:"javascript",ts:"typescript",py:"python",rb:"ruby",rs:"rust",cs:"csharp","c++":"cpp",yml:"yaml",md:"markdown",docker:"dockerfile"};let j=null;const N=new Set;async function se(){if(!j){const[{createHighlighterCore:e},{createJavaScriptRegexEngine:s},t,n]=await Promise.all([r(()=>import("./core-BrHBc0Zp.js"),__vite__mapDeps([18,19])),r(()=>import("./engine-javascript-PwbX1GN8.js"),[]),r(()=>import("./vitesse-dark-D0r3Knsf.js"),[]).then(i=>i.default),r(()=>import("./vitesse-light-CVO1_9PV.js"),[]).then(i=>i.default)]);j=e({themes:[t,n],langs:[],engine:s()})}return j}async function ae(e,s){const t=ne[s]||s;if(N.has(t))return t;const n=re[t];if(!n)return"text";try{const i=await n();return await e.loadLanguage(i),N.add(t),t}catch{return"text"}}function ce({content:e,ariaLabel:s,language:t="text",filename:n,className:i}){const a=Y(),[p,c]=_.useState(!1),[f,E]=_.useState(null),[m,L]=_.useState("text"),[P,x]=_.useState(),[d,b]=_.useState(!1),o=_.useMemo(()=>e,[e]),g=H(t||"text"),w=a==="dark"?"vitesse-dark":"vitesse-light";_.useEffect(()=>{let v=!0;async function S(){try{const A=await se();if(!v)return;const F=ee(g),V=await ae(A,F);if(!v)return;const W=A.codeToHtml(e,{lang:V,theme:w});if(v){L(V),E(W);const B=A.getTheme(w);x(B.bg)}}catch{v&&E(null)}}return S(),()=>{v=!1}},[e,g,w]),_.useEffect(()=>{if(typeof window>"u")return;const v=window.localStorage.getItem("opencami-code-wrap");b(v==="1")},[]);function y(){b(v=>{const S=!v;return typeof window<"u"&&window.localStorage.setItem("opencami-code-wrap",S?"1":"0"),S})}async function l(){try{await navigator.clipboard.writeText(e),c(!0),window.setTimeout(()=>c(!1),1600)}catch{c(!1)}}const R=!(e.replace(/\n$/,"").split(`
3
3
  `).length<=1),M=te(m);return u.jsxs("div",{className:T("code-block group relative w-full min-w-0 max-w-full overflow-hidden rounded-lg border border-primary-200",i),children:[u.jsxs("div",{className:T("flex items-center justify-between px-3 pt-2"),style:{backgroundColor:P},children:[u.jsx("span",{className:"text-xs font-medium text-primary-500 flex items-center gap-1.5 min-w-0",children:n?u.jsxs(u.Fragment,{children:[u.jsx(k,{icon:J,size:14,strokeWidth:1.8}),u.jsx("span",{className:"truncate",children:n})]}):M}),u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs(C,{variant:"ghost","aria-label":d?"Disable wrap":"Enable wrap",className:"h-auto px-0 text-xs font-medium text-primary-500 hover:text-primary-800 hover:bg-transparent",onClick:y,children:[u.jsx(k,{icon:q,size:14,strokeWidth:1.8}),d?"No wrap":"Wrap"]}),u.jsxs(C,{variant:"ghost","aria-label":s??"Copy code",className:"h-auto px-0 text-xs font-medium text-primary-500 hover:text-primary-800 hover:bg-transparent",onClick:()=>{l().catch(()=>{})},children:[u.jsx(k,{icon:p?z:U,size:14,strokeWidth:1.8}),p?"Copied":"Copy"]})]})]}),f?u.jsx("div",{className:T("w-full min-w-0 max-w-full text-sm text-primary-900 overflow-x-hidden [&>pre]:w-full [&>pre]:min-w-0 [&>pre]:max-w-full [&>pre]:px-3 [&>pre]:py-3",d?"[&>pre]:whitespace-pre-wrap [&>pre]:break-words [&_.line]:whitespace-pre-wrap [&_.line]:break-words":"overflow-x-auto [&>pre]:whitespace-pre [&>pre]:overflow-x-auto",R&&"[&>pre]:[counter-reset:line] [&_.line]:before:content-[counter(line)] [&_.line]:before:[counter-increment:line] [&_.line]:before:inline-block [&_.line]:before:w-8 [&_.line]:before:mr-4 [&_.line]:before:text-right [&_.line]:before:select-none [&_.line]:before:text-primary-500/60"),dangerouslySetInnerHTML:{__html:f}}):u.jsx("pre",{className:T("w-full min-w-0 max-w-full text-sm px-3 py-3 overflow-x-auto",d?"whitespace-pre-wrap break-words":"whitespace-pre overflow-x-auto"),children:u.jsx("code",{className:"block",children:o})})]})}export{ce as C,Q as p,ee as r,ue as u};
@@ -1 +1 @@
1
- import{R as t,r as s,j as a}from"./main-B_dlfHME.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-CEuT8-Qi.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 +1 @@
1
- import{j as e}from"./main-B_dlfHME.js";import{D as l,a as c,b as p,c as d,d as m}from"./use-file-explorer-state-DzT0bksg.js";import{B as x}from"./button-Dg7VFQQn.js";import"./useButton-Cbl_9oFG.js";import"./owner-CpRnf1fI.js";import"./popupStateMapping-BRPDXnjv.js";import"./visuallyHidden-ONmQ-0U2.js";import"./composite-DBl8R3ae.js";import"./react-irH8OzhB.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 v({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(p,{className:"mb-2",children:"Keyboard Shortcuts"}),e.jsx(d,{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{v as KeyboardShortcutsDialog};
1
+ import{j as e}from"./main-CEuT8-Qi.js";import{D as l,a as c,b as p,c as d,d as m}from"./use-file-explorer-state-DppKEjcl.js";import{B as x}from"./button-DNC5N25i.js";import"./useButton-DVAfkehQ.js";import"./owner-CFRNz_Tp.js";import"./popupStateMapping-D5k-jOeY.js";import"./visuallyHidden-CO3ZD5AQ.js";import"./composite-Bliqcmg4.js";import"./react-K9goXsVv.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 v({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(p,{className:"mb-2",children:"Keyboard Shortcuts"}),e.jsx(d,{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{v as KeyboardShortcutsDialog};