vibelet 1.2.243 → 1.2.245

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 (124) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/inventory-scan-worker.cjs +1 -1
  3. package/dist/remoteDirect/manifest.json +12 -12
  4. package/dist/runtime-version.cjs +1 -1
  5. package/dist/web/assets/App-D4fBMWn7.js +2 -0
  6. package/dist/web/assets/{App-6Cciblyj.css → App-DHnygrdE.css} +1 -1
  7. package/dist/web/assets/BrowserControlPanel-CX9UdOEA.js +1 -0
  8. package/dist/web/assets/{ChatPane-Crhr0Lkx.js → ChatPane-wtVFANO0.js} +2 -2
  9. package/dist/web/assets/{ChipGroup-DAB6dZFc.js → ChipGroup-C16Et4Xc.js} +1 -1
  10. package/dist/web/assets/{ComposerMenus-D7iN4bup.js → ComposerMenus-B9EpF3L_.js} +1 -1
  11. package/dist/web/assets/{DiffDrawer-BR7NrEmt.js → DiffDrawer-DTg5YChv.js} +1 -1
  12. package/dist/web/assets/{FilesControlPanel-B8w2_BRT.js → FilesControlPanel-Bx9RohXk.js} +1 -1
  13. package/dist/web/assets/{GlobalPendingDialog-psYp4FyT.js → GlobalPendingDialog-p1vvgOHs.js} +1 -1
  14. package/dist/web/assets/{ImageViewer-CKqlB_9p.js → ImageViewer--pLWLE6p.js} +1 -1
  15. package/dist/web/assets/{LanguageSettingsPanel-eEfHrFPA.js → LanguageSettingsPanel-COinfVCx.js} +1 -1
  16. package/dist/web/assets/MarkdownModePanel-DGxuHxiO.js +1 -0
  17. package/dist/web/assets/{MessageImage-L_caj_Dp.js → MessageImage-DyqY_ZJd.js} +1 -1
  18. package/dist/web/assets/{NewSessionDialog-D6GYUsxw.js → NewSessionDialog-CGMida8H.js} +1 -1
  19. package/dist/web/assets/{NotificationSettingsPanel-8cC0qcjz.js → NotificationSettingsPanel-CrkHAKw9.js} +1 -1
  20. package/dist/web/assets/{PanelFind-CtB-fTaM.js → PanelFind-Cx5K--7K.js} +1 -1
  21. package/dist/web/assets/RemoteLifeOSBlock-CzC-ut2z.js +2 -0
  22. package/dist/web/assets/RemoteLifeOSBlock-D7P9Ftlh.css +1 -0
  23. package/dist/web/assets/{RemoteWorkspaceSettings-BLk7MUa8.js → RemoteWorkspaceSettings--n8qxL-O.js} +1 -1
  24. package/dist/web/assets/{SessionTerminalPanel-D_5c6lMk.js → SessionTerminalPanel-D59JkdsC.js} +2 -2
  25. package/dist/web/assets/{SpeechInputSettingsPanel-Bm1UPHiL.js → SpeechInputSettingsPanel-rrdMQRnO.js} +1 -1
  26. package/dist/web/assets/{ThemeSettingsPanel-Tym9Xy1v.js → ThemeSettingsPanel-JMc98Dpj.js} +1 -1
  27. package/dist/web/assets/{__vite-browser-external-2447137e-Ck9f6uYD.js → __vite-browser-external-2447137e-DYOQzEuf.js} +1 -1
  28. package/dist/web/assets/{abnfDiagram-VRR7QNED-BPSMtotk.js → abnfDiagram-VRR7QNED-CiGRuhk-.js} +1 -1
  29. package/dist/web/assets/{arc-CFHn4jAK.js → arc-Uf6y3fQG.js} +1 -1
  30. package/dist/web/assets/{architectureDiagram-ZJ3FMSHR-DoIyc6P-.js → architectureDiagram-ZJ3FMSHR-Cx57d0-g.js} +1 -1
  31. package/dist/web/assets/{arrow-left-B_J8dbJk.js → arrow-left-CTbegMaU.js} +1 -1
  32. package/dist/web/assets/{arrow-right-B0Zthy7B.js → arrow-right-BQXADod1.js} +1 -1
  33. package/dist/web/assets/{blockDiagram-677ZJIJ3-BOarVZs5.js → blockDiagram-677ZJIJ3-DfDpv9OM.js} +1 -1
  34. package/dist/web/assets/{c4Diagram-LMCZKHZV-CDoawQWV.js → c4Diagram-LMCZKHZV-_ILjwxFf.js} +1 -1
  35. package/dist/web/assets/channel-Dk15gdNy.js +1 -0
  36. package/dist/web/assets/chevron-up-GZB6oy0t.js +1 -0
  37. package/dist/web/assets/{chunk-2Q5K7J3B-CkVdI1_G.js → chunk-2Q5K7J3B-CY59UbU-.js} +1 -1
  38. package/dist/web/assets/{chunk-32BRIVSS-lfRflIJE.js → chunk-32BRIVSS-BSCYWxge.js} +1 -1
  39. package/dist/web/assets/{chunk-5VM5RSS4-ChvW640o.js → chunk-5VM5RSS4-DAMZXj9y.js} +1 -1
  40. package/dist/web/assets/{chunk-EX3LRPZG-LUlAwMu1.js → chunk-EX3LRPZG-D2G4irvr.js} +1 -1
  41. package/dist/web/assets/{chunk-JWPE2WC7-CZAbFhxm.js → chunk-JWPE2WC7-BcR5muoN.js} +1 -1
  42. package/dist/web/assets/{chunk-MOJQB5TN-zbABsF-T.js → chunk-MOJQB5TN-DBf8Vf6T.js} +1 -1
  43. package/dist/web/assets/{chunk-RYQCIY6F-DO7-HDJp.js → chunk-RYQCIY6F-C3X0k4Wk.js} +1 -1
  44. package/dist/web/assets/{chunk-V7JOEXUC-CZZpLt5o.js → chunk-V7JOEXUC-CPO1U4G8.js} +1 -1
  45. package/dist/web/assets/{chunk-VR4S4FIN-CPVLI9Cz.js → chunk-VR4S4FIN-D9BlrMdk.js} +1 -1
  46. package/dist/web/assets/{chunk-XXDRQBXY-dA96ajoY.js → chunk-XXDRQBXY-DUhbXvUs.js} +1 -1
  47. package/dist/web/assets/classDiagram-OUVF2IWQ-CN2WsgwT.js +1 -0
  48. package/dist/web/assets/classDiagram-v2-EOCWNBFH-CN2WsgwT.js +1 -0
  49. package/dist/web/assets/{collectMessageImages-BHZAEp7l.js → collectMessageImages-DdrSxaMf.js} +1 -1
  50. package/dist/web/assets/{cose-bilkent-JH36ORCC-DkTAw3T7.js → cose-bilkent-JH36ORCC-B3c5J7br.js} +1 -1
  51. package/dist/web/assets/{cynefin-VYW2F7L2-CPV5HP8b.js → cynefin-VYW2F7L2-DwrXi0XX.js} +1 -1
  52. package/dist/web/assets/{cynefinDiagram-TSTJHNR4-BjqGh-JY.js → cynefinDiagram-TSTJHNR4-5t6NkjVv.js} +1 -1
  53. package/dist/web/assets/{dagre-VKFMJZFB-CqPOtH9L.js → dagre-VKFMJZFB-CE6g1IOo.js} +1 -1
  54. package/dist/web/assets/{diagram-FQU43EPY-51RTvAnu.js → diagram-FQU43EPY-CN3Kybbf.js} +1 -1
  55. package/dist/web/assets/{diagram-G47NLZAW-B5GqRCH2.js → diagram-G47NLZAW-Djc-xY18.js} +1 -1
  56. package/dist/web/assets/{diagram-NH7WQ7WH-BYUwty2D.js → diagram-NH7WQ7WH-dgr5u2-y.js} +1 -1
  57. package/dist/web/assets/{diagram-OA4YK3LP-C6yJt9W8.js → diagram-OA4YK3LP-Bna9UWZO.js} +1 -1
  58. package/dist/web/assets/{diagram-WEI45ONY-Cc9-k4zE.js → diagram-WEI45ONY-MFmmaGwd.js} +1 -1
  59. package/dist/web/assets/{ebnfDiagram-CCIWWBDH-DCzmtavH.js → ebnfDiagram-CCIWWBDH-C4vnTICq.js} +1 -1
  60. package/dist/web/assets/{erDiagram-Q63AITRT-ZjDc6wjK.js → erDiagram-Q63AITRT-OHs8hKkP.js} +1 -1
  61. package/dist/web/assets/{file-editor-FileCodeEditor-ynS8wc-T.js → file-editor-FileCodeEditor-CjIOJIPi.js} +1 -1
  62. package/dist/web/assets/{file-editor-ObsidianCodeEditor-BGsVxYpf.js → file-editor-ObsidianCodeEditor-DqGk6x5n.js} +1 -1
  63. package/dist/web/assets/{file-editor-ObsidianFileEditor-DCya_kV_.js → file-editor-ObsidianFileEditor-Bw_Rpzie.js} +1 -1
  64. package/dist/web/assets/{flowDiagram-23GEKE2U-JOT3y9OZ.js → flowDiagram-23GEKE2U-CgkejrIU.js} +1 -1
  65. package/dist/web/assets/{folder-plus-Dv3mIoot.js → folder-plus-BBvp5bBk.js} +1 -1
  66. package/dist/web/assets/{ganttDiagram-NO4QXBWP-BwMM9lRV.js → ganttDiagram-NO4QXBWP-C93UiqA8.js} +1 -1
  67. package/dist/web/assets/{gitGraphDiagram-IHSO6WYX-Ca0Kjref.js → gitGraphDiagram-IHSO6WYX-dNRNMuEa.js} +1 -1
  68. package/dist/web/assets/highlighted-body-TPN3WLV5-DnHFC22F.js +1 -0
  69. package/dist/web/assets/{imageViewerCopy-BBW9Oggj.js → imageViewerCopy-CZ0PxllY.js} +1 -1
  70. package/dist/web/assets/index-C6NKSiG-.js +2 -0
  71. package/dist/web/assets/{index-CtwbNx5m.js → index-C_U23Las.js} +1 -1
  72. package/dist/web/assets/{index-B5px1ls4.js → index-CvmmrrPC.js} +1 -1
  73. package/dist/web/assets/{index-ofOCAr04.js → index-D5vqn_ed.js} +1 -1
  74. package/dist/web/assets/index-Df0b_mNb.css +1 -0
  75. package/dist/web/assets/infoDiagram-FWYZ7A6U-CW-qN7ME.js +1 -0
  76. package/dist/web/assets/{ishikawaDiagram-FXEZZL3T-DJix30qW.js → ishikawaDiagram-FXEZZL3T-B7qgG7qy.js} +1 -1
  77. package/dist/web/assets/{journeyDiagram-5HDEW3XC-CIDtc9NL.js → journeyDiagram-5HDEW3XC-fC2VOxfE.js} +1 -1
  78. package/dist/web/assets/{kanban-definition-HUTT4EX6-kNtL91_Y.js → kanban-definition-HUTT4EX6-CgRDoaWP.js} +1 -1
  79. package/dist/web/assets/{key-round-CBNFW_Qp.js → key-round-DZyIHeFg.js} +1 -1
  80. package/dist/web/assets/{linear-Pl-iycWx.js → linear-B_EbvSwc.js} +1 -1
  81. package/dist/web/assets/{mermaid-O7DHMXV3-Bq_tcKDI.js → mermaid-O7DHMXV3-B-4H0Z-Q.js} +2 -2
  82. package/dist/web/assets/{mermaid.core-DKLhQHMi.js → mermaid.core-CMBPtXgs.js} +2 -2
  83. package/dist/web/assets/{mic-BHRmNhFG.js → mic-DOgSBjqM.js} +1 -1
  84. package/dist/web/assets/{mindmap-definition-LN4V7U3C-EdtXTVq3.js → mindmap-definition-LN4V7U3C-XM1lxVqO.js} +1 -1
  85. package/dist/web/assets/{pegDiagram-2B236MQR-CcQiWdRU.js → pegDiagram-2B236MQR-DYUFpdXI.js} +1 -1
  86. package/dist/web/assets/{pieDiagram-ENE6RG2P-B9OftxL2.js → pieDiagram-ENE6RG2P-aBVH0JdT.js} +1 -1
  87. package/dist/web/assets/{quadrantDiagram-ABIIQ3AL-DNzteO4O.js → quadrantDiagram-ABIIQ3AL-Bry3howh.js} +1 -1
  88. package/dist/web/assets/{railroadDiagram-RFXS5EU6-DETkFxdL.js → railroadDiagram-RFXS5EU6-B_X-RKS6.js} +1 -1
  89. package/dist/web/assets/{requirementDiagram-TGXJPOKE-Bc2ygXJE.js → requirementDiagram-TGXJPOKE-DSYrODnH.js} +1 -1
  90. package/dist/web/assets/{sankeyDiagram-HTMAVEWB-ued5WJdO.js → sankeyDiagram-HTMAVEWB-DgTgUObg.js} +1 -1
  91. package/dist/web/assets/{sequenceDiagram-DBY2YBRQ-CB9W7GEK.js → sequenceDiagram-DBY2YBRQ-C0hrYifi.js} +1 -1
  92. package/dist/web/assets/{shield-check-BHYK9iHQ.js → shield-check-B5zclKcP.js} +1 -1
  93. package/dist/web/assets/{sizeCapture-X5ZJPWSS-BlYVWgJQ.js → sizeCapture-X5ZJPWSS-KnPlIyQA.js} +1 -1
  94. package/dist/web/assets/{stateDiagram-2N3HPSRC-BuBfZ-Ll.js → stateDiagram-2N3HPSRC-DP7NULIr.js} +1 -1
  95. package/dist/web/assets/stateDiagram-v2-6OUMAXLB-BhpeOEvI.js +1 -0
  96. package/dist/web/assets/{swimlanes-5IMT3BWC-DymXACYM.js → swimlanes-5IMT3BWC-Dg7S6oxH.js} +2 -2
  97. package/dist/web/assets/swimlanesDiagram-G3AALYLV-DPHGi19a.js +1 -0
  98. package/dist/web/assets/{timeline-definition-FHXFAJF6-Doqvtw8A.js → timeline-definition-FHXFAJF6-CLINYAku.js} +1 -1
  99. package/dist/web/assets/useComposerCompletion-vV_zliKO.js +1 -0
  100. package/dist/web/assets/{useMessageImage-CkBgO2_p.js → useMessageImage-Bxcjzr5o.js} +1 -1
  101. package/dist/web/assets/{vennDiagram-L72KCM5P-BTDdTQn0.js → vennDiagram-L72KCM5P-ysQvQnRc.js} +1 -1
  102. package/dist/web/assets/{wardleyDiagram-EHGQE667-DJVmxdj7.js → wardleyDiagram-EHGQE667-DjkDlqix.js} +1 -1
  103. package/dist/web/assets/{xychartDiagram-FW5EYKEG-D1C4pPp4.js → xychartDiagram-FW5EYKEG-DHT8vikr.js} +1 -1
  104. package/dist/web/assets/{zap-DsMffYum.js → zap-CGGziZzC.js} +1 -1
  105. package/dist/web/index.html +2 -2
  106. package/dist/web/obsidian-editor-assets.json +1 -1
  107. package/package.json +7 -7
  108. package/dist/web/assets/App-DHM2JpIe.js +0 -2
  109. package/dist/web/assets/BrowserControlPanel-CvtVx3Hr.js +0 -1
  110. package/dist/web/assets/MarkdownModePanel-R_z8H9hQ.js +0 -1
  111. package/dist/web/assets/RemoteLifeOSBlock-CwM5U04N.js +0 -2
  112. package/dist/web/assets/RemoteLifeOSBlock-DVhFsnY2.css +0 -1
  113. package/dist/web/assets/channel-bz5uCtjG.js +0 -1
  114. package/dist/web/assets/chevron-up-BvhbPeN2.js +0 -1
  115. package/dist/web/assets/classDiagram-OUVF2IWQ-DWTcdIri.js +0 -1
  116. package/dist/web/assets/classDiagram-v2-EOCWNBFH-DWTcdIri.js +0 -1
  117. package/dist/web/assets/highlighted-body-TPN3WLV5-VkAb1QUw.js +0 -1
  118. package/dist/web/assets/index-B0hzMPwQ.css +0 -1
  119. package/dist/web/assets/index-CTpWXHK5.js +0 -2
  120. package/dist/web/assets/infoDiagram-FWYZ7A6U-FmG41IWW.js +0 -1
  121. package/dist/web/assets/stateDiagram-v2-6OUMAXLB-BVWYwLt9.js +0 -1
  122. package/dist/web/assets/swimlanesDiagram-G3AALYLV-BxIeu7lf.js +0 -1
  123. package/dist/web/assets/useComposerCompletion-f1any5m7.js +0 -1
  124. package/dist/web/logo.svg +0 -1
@@ -1 +1 @@
1
- import{b as e,d as s,r as t,j as n,u as a}from"./index-CTpWXHK5.js";import{g as i,b as l}from"./git-actions-DHCQ17VG.js";import{b as d,c as r,e as c,p as o,l as f,g as u,h,X as p,i as m}from"./App-DHM2JpIe.js";function g({client:a,sessionId:d,scope:r,files:c}){const o=i[e(s().language)],[f,u]=t.useState("idle"),[h,p]=t.useState(""),m=t.useRef(!1),g=async e=>{if(!m.current&&c?.length){m.current=!0,u("sending");try{await a.request({action:"session.send",id:a.makeId("git_commit"),sessionId:d,clientMessageId:a.makeId("git_commit_message"),message:l(r,c,e)}),u("sent")}catch(s){p(s instanceof Error?s.message:String(s)),u("error"),m.current=!1}}};return n.jsxs("div",{className:"diff-commit-actions",children:[n.jsxs("span",{children:[o.scope," · ",c?.length??0]}),n.jsxs("div",{children:[n.jsx("button",{type:"button",disabled:!c?.length||"sending"===f||"sent"===f,onClick:()=>{g(!1)},children:o.commit}),n.jsx("button",{type:"button",disabled:!c?.length||"sending"===f||"sent"===f,onClick:()=>{g(!0)},children:o.push})]}),"sent"===f?n.jsx("p",{role:"status",children:o.submitted}):null,"error"===f?n.jsxs("p",{role:"alert",children:[o.failed,": ",h]}):null]})}function x(e){return e.slice(e.lastIndexOf("/")+1)}function b({files:e,selectedPath:s,onSelect:a,t:i}){const[l,o]=t.useState(!0),[f,u]=t.useState(()=>new Set),h=t.useMemo(()=>function(e){const s=new Map;for(const n of e){const e=n.path.slice(0,Math.max(0,n.path.lastIndexOf("/"))),t=s.get(e)??[];t.push(n),s.set(e,t)}const t=(e,s)=>e<s?-1:e>s?1:0;return[...s].sort(([e],[s])=>t(e,s)).map(([e,s])=>({path:e,files:s.sort((e,s)=>t(e.path,s.path))}))}(e),[e]),p=e=>n.jsxs("button",{type:"button",className:`diff-file diff-file-${e.status} ${s===e.path?"active":""}`,"aria-pressed":s===e.path,"aria-label":e.path,onClick:()=>a(e.path),children:[n.jsx("span",{className:`diff-status diff-status-${e.status}`,children:e.status}),n.jsx("span",{className:"diff-file-path",title:e.oldPath?`${e.oldPath} → ${e.path}`:e.path,children:l?x(e.path):e.path}),n.jsxs("span",{className:"diff-file-stats",children:[e.binary?n.jsx("span",{className:"diff-binary",children:"bin"}):null,!e.binary&&e.additions>0?n.jsxs("span",{className:"diff-add",children:["+",e.additions]}):null,!e.binary&&e.deletions>0?n.jsxs("span",{className:"diff-del",children:["-",e.deletions]}):null]})]},e.path);return n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"diff-group-toggle",children:[n.jsx("input",{type:"checkbox",checked:l,onChange:e=>o(e.target.checked)}),i.groupByFolder]}),l?h.map(e=>{const s=!f.has(e.path);return n.jsxs("div",{className:"diff-folder",children:[n.jsxs("button",{type:"button",className:"diff-folder-heading","aria-expanded":s,onClick:()=>u(s=>{const t=new Set(s);return t.has(e.path)?t.delete(e.path):t.add(e.path),t}),children:[s?n.jsx(d,{"aria-hidden":"true"}):n.jsx(r,{"aria-hidden":"true"}),n.jsx(c,{"aria-hidden":"true"}),n.jsx("span",{className:"diff-folder-path",title:e.path||".",children:e.path||"."}),n.jsx("span",{className:"diff-folder-count",children:e.files.length})]}),s&&e.files.map(p)]},e.path)}):e.map(p)]})}function j({patch:e,truncated:s,truncatedLabel:a,loadingLabel:i}){const l=t.useMemo(()=>function(e){let s=0,t=0;return e.split("\n").map(e=>{const n=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(e);return n?(s=Number(n[1]),t=Number(n[2]),{text:e,kind:"hunk",oldLine:"",newLine:"",sign:""}):e.startsWith("diff ")||e.startsWith("index ")||e.startsWith("---")||e.startsWith("+++")||!s&&!t?{text:e,kind:"header",oldLine:"",newLine:"",sign:""}:e.startsWith("+")?{text:e.slice(1),kind:"add",oldLine:"",newLine:String(t++),sign:"+"}:e.startsWith("-")?{text:e.slice(1),kind:"del",oldLine:String(s++),newLine:"",sign:"−"}:e.startsWith(" ")?{text:e.slice(1),kind:"ctx",oldLine:String(s++),newLine:String(t++),sign:""}:{text:e,kind:"header",oldLine:"",newLine:"",sign:""}})}(e),[e]),[d,r]=t.useState(400),c=t.useRef(null);return t.useEffect(()=>{r(400)},[e]),t.useEffect(()=>{const e=c.current;if(!e)return;const s=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&r(e=>e+400)},{root:e.closest(".diff-patch"),rootMargin:"200px"});return s.observe(e),()=>s.disconnect()},[d,l.length]),n.jsxs("div",{className:"diff-patch-view",children:[l.slice(0,d).map((e,s)=>n.jsxs("div",{className:`diff-line ${e.kind}`,children:[n.jsx("span",{className:"diff-line-number","aria-hidden":"true",children:e.oldLine}),n.jsx("span",{className:"diff-line-number","aria-hidden":"true",children:e.newLine}),n.jsx("span",{className:"diff-line-sign","aria-hidden":"true",children:e.sign}),n.jsx("span",{className:"diff-line-text",children:e.text||" "})]},s)),d<l.length&&n.jsx("div",{ref:c,className:"diff-more",role:"status",children:i}),s&&n.jsx("p",{className:"diff-empty",children:a})]})}const w={loading:!1,files:null,error:null};function N({client:e,sessionId:s,cwd:i,sessionTitle:l,t:d,onClose:r,onDock:c,dockLabel:x,presentation:N="drawer",initialScope:v="unstaged",initialPath:k}){const y=t.useId(),L=t.useRef(null),[S,C]=t.useState(!1),I=t.useRef(void 0),E=t.useCallback(()=>{void 0===I.current&&("workspace"===N||window.matchMedia("(prefers-reduced-motion: reduce)").matches?r():(C(!0),I.current=window.setTimeout(r,180)))},[r,N]);t.useEffect(()=>()=>window.clearTimeout(I.current),[]);const P=a(E,L,"drawer"===N),$=o(e,{sessionId:s,cwd:i},v),[M,W]=t.useState(v),[D,R]=t.useState({unstaged:w,staged:w,[v]:{...w,files:$.data?.files??null}}),[F,T]=t.useState(k??$.data?.files[0]?.path??null),[X,Y]=t.useState($.patches.get(k??$.data?.files[0]?.path??"")?.data??null),[O,_]=t.useState(!1),[q,B]=t.useState(null),A=function(e){const s=t.useRef(void 0);return t.useEffect(()=>()=>s.current?.(),[]),{"data-dock-draggable":!!e,onPointerDown:t=>{if(!e||0!==t.button||t.target.closest("button"))return;s.current?.();const n=t.currentTarget,a=t.clientX,i=t.clientY,l=document.querySelector(".workspace-documents");if(!l)return;let d=!1;const r=(e,s)=>{const t=l.getBoundingClientRect();return e>=t.left&&e<=t.right&&s>=t.top&&s<=t.bottom},c=e=>{Math.hypot(e.clientX-a,e.clientY-i)<6&&!d||(d=!0,document.body.classList.add("dock-dragging"),l.classList.toggle("dock-drop-target",r(e.clientX,e.clientY)))},o=()=>{document.body.classList.remove("dock-dragging"),l.classList.remove("dock-drop-target"),window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",o),n.hasPointerCapture(t.pointerId)&&n.releasePointerCapture(t.pointerId),s.current=void 0},f=s=>{const t=d&&r(s.clientX,s.clientY);o(),t&&e()};s.current=o,n.setPointerCapture(t.pointerId),window.addEventListener("pointermove",c),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",o),t.preventDefault()}}}("drawer"===N&&c?()=>c({scope:M,path:F}):void 0),U=D[M],z=t.useCallback(async t=>{R(e=>({...e,[t]:{loading:!0,files:e[t].files,error:null}}));try{const n=await f(e,{sessionId:s,cwd:i},t);R(e=>({...e,[t]:{loading:!1,files:n.files,error:null}}))}catch(n){R(e=>({...e,[t]:{loading:!1,files:null,error:n instanceof Error?n.message:String(n)}}))}},[e,s,i]);t.useEffect(()=>{z(M)},[M,z]),t.useEffect(()=>{const e=U.files;e&&(e.length?T(s=>e.some(e=>e.path===s)?s:e[0].path):T(null))},[U.files]),t.useEffect(()=>{if(!F)return Y(null),void B(null);let t=!1;const n=o(e,{sessionId:s,cwd:i},M).patches.get(F)?.data;return Y(e=>n??(e?.path===F?e:null)),_(!n&&X?.path!==F),B(null),u(e,{sessionId:s,cwd:i},M,F).then(e=>{t||(Y(e),_(!1))}).catch(e=>{t||(B(e instanceof Error?e.message:String(e)),_(!1))}),()=>{t=!0}},[e,s,i,M,F,U.files]);const G=t.useMemo(()=>{const e=e=>e?e.reduce((e,s)=>({adds:e.adds+s.additions,dels:e.dels+s.deletions,count:e.count+1}),{adds:0,dels:0,count:0}):{adds:0,dels:0,count:0};return{unstaged:e(D.unstaged.files),staged:e(D.staged.files)}},[D]);return n.jsxs("div",{"aria-labelledby":y,"aria-modal":"drawer"===N||void 0,className:`diff-drawer ${"workspace"===N?"diff-workspace":""} ${S?"closing":""}`,ref:P,role:"drawer"===N?"dialog":"region",tabIndex:-1,children:["drawer"===N&&n.jsx("div",{className:"diff-drawer-backdrop",onClick:E,"aria-hidden":"true"}),n.jsxs("div",{className:"diff-drawer-panel",children:[n.jsxs("header",{className:"diff-drawer-header",...A,children:[c&&"drawer"===N&&n.jsx("button",{type:"button",className:"icon-button","aria-label":x,title:x,onClick:()=>c({scope:M,path:F}),children:n.jsx(h,{})}),n.jsxs("div",{children:[n.jsx("strong",{id:y,children:d.changes}),n.jsx("span",{children:l})]}),n.jsx("button",{"aria-label":d.closeChanges,className:"icon-button",onClick:E,ref:L,type:"button",title:d.closeChanges,children:n.jsx(p,{"aria-hidden":"true"})})]}),n.jsx("div",{className:"diff-tabs",role:"tablist",children:["unstaged","staged"].map(e=>{const s=G[e],t=M===e;return n.jsxs("button",{type:"button",role:"tab","aria-selected":t,className:"diff-tab "+(t?"active":""),onClick:()=>{e!==M&&(T(null),Y(null),B(null),W(e))},children:[n.jsx("span",{className:"diff-tab-label",children:"unstaged"===e?d.workingChanges:d.stagedChanges}),s.count>0?n.jsxs("span",{className:"diff-tab-meta",children:[n.jsxs("span",{className:"diff-add",children:["+",s.adds]}),n.jsxs("span",{className:"diff-del",children:["-",s.dels]})]}):null]},e)})}),n.jsx(g,{client:e,sessionId:s,scope:M,files:U.files}),n.jsxs("div",{className:"diff-body",children:[n.jsxs("aside",{className:"diff-files","aria-label":d.changedFiles,children:[U.loading&&!U.files?n.jsx("p",{className:"diff-empty",children:d.loading}):null,U.error?n.jsx("p",{className:"diff-empty diff-error",children:U.error}):null,U.files&&0===U.files.length?n.jsx("p",{className:"diff-empty",children:d.noChanges}):null,U.files&&U.files.length>0&&n.jsx(b,{files:U.files,selectedPath:F,onSelect:T,t:d})]}),n.jsx("section",{className:"diff-patch","aria-label":d.fileDiff,children:F?O?n.jsx("p",{className:"diff-empty",children:d.loadingPatch}):q?n.jsx("p",{className:"diff-empty diff-error",children:q}):X?.binary?n.jsx("p",{className:"diff-empty",children:d.binaryDiffUnavailable}):X?n.jsx(j,{patch:X.patch,truncated:X.truncated,truncatedLabel:d.patchTruncated,loadingLabel:d.loadingPatch},`${M}:${F}`):null:n.jsxs("div",{className:"diff-empty",children:[n.jsx(m,{"aria-hidden":"true"}),n.jsx("p",{children:d.selectFileForDiff})]})})]})]})]})}export{N as DiffDrawer};
1
+ import{b as e,d as s,r as t,j as n,u as a}from"./index-C6NKSiG-.js";import{g as i,b as l}from"./git-actions-DHCQ17VG.js";import{b as d,c as r,e as c,p as o,l as f,g as u,h,X as p,i as m}from"./App-D4fBMWn7.js";function g({client:a,sessionId:d,scope:r,files:c}){const o=i[e(s().language)],[f,u]=t.useState("idle"),[h,p]=t.useState(""),m=t.useRef(!1),g=async e=>{if(!m.current&&c?.length){m.current=!0,u("sending");try{await a.request({action:"session.send",id:a.makeId("git_commit"),sessionId:d,clientMessageId:a.makeId("git_commit_message"),message:l(r,c,e)}),u("sent")}catch(s){p(s instanceof Error?s.message:String(s)),u("error"),m.current=!1}}};return n.jsxs("div",{className:"diff-commit-actions",children:[n.jsxs("span",{children:[o.scope," · ",c?.length??0]}),n.jsxs("div",{children:[n.jsx("button",{type:"button",disabled:!c?.length||"sending"===f||"sent"===f,onClick:()=>{g(!1)},children:o.commit}),n.jsx("button",{type:"button",disabled:!c?.length||"sending"===f||"sent"===f,onClick:()=>{g(!0)},children:o.push})]}),"sent"===f?n.jsx("p",{role:"status",children:o.submitted}):null,"error"===f?n.jsxs("p",{role:"alert",children:[o.failed,": ",h]}):null]})}function x(e){return e.slice(e.lastIndexOf("/")+1)}function b({files:e,selectedPath:s,onSelect:a,t:i}){const[l,o]=t.useState(!0),[f,u]=t.useState(()=>new Set),h=t.useMemo(()=>function(e){const s=new Map;for(const n of e){const e=n.path.slice(0,Math.max(0,n.path.lastIndexOf("/"))),t=s.get(e)??[];t.push(n),s.set(e,t)}const t=(e,s)=>e<s?-1:e>s?1:0;return[...s].sort(([e],[s])=>t(e,s)).map(([e,s])=>({path:e,files:s.sort((e,s)=>t(e.path,s.path))}))}(e),[e]),p=e=>n.jsxs("button",{type:"button",className:`diff-file diff-file-${e.status} ${s===e.path?"active":""}`,"aria-pressed":s===e.path,"aria-label":e.path,onClick:()=>a(e.path),children:[n.jsx("span",{className:`diff-status diff-status-${e.status}`,children:e.status}),n.jsx("span",{className:"diff-file-path",title:e.oldPath?`${e.oldPath} → ${e.path}`:e.path,children:l?x(e.path):e.path}),n.jsxs("span",{className:"diff-file-stats",children:[e.binary?n.jsx("span",{className:"diff-binary",children:"bin"}):null,!e.binary&&e.additions>0?n.jsxs("span",{className:"diff-add",children:["+",e.additions]}):null,!e.binary&&e.deletions>0?n.jsxs("span",{className:"diff-del",children:["-",e.deletions]}):null]})]},e.path);return n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"diff-group-toggle",children:[n.jsx("input",{type:"checkbox",checked:l,onChange:e=>o(e.target.checked)}),i.groupByFolder]}),l?h.map(e=>{const s=!f.has(e.path);return n.jsxs("div",{className:"diff-folder",children:[n.jsxs("button",{type:"button",className:"diff-folder-heading","aria-expanded":s,onClick:()=>u(s=>{const t=new Set(s);return t.has(e.path)?t.delete(e.path):t.add(e.path),t}),children:[s?n.jsx(d,{"aria-hidden":"true"}):n.jsx(r,{"aria-hidden":"true"}),n.jsx(c,{"aria-hidden":"true"}),n.jsx("span",{className:"diff-folder-path",title:e.path||".",children:e.path||"."}),n.jsx("span",{className:"diff-folder-count",children:e.files.length})]}),s&&e.files.map(p)]},e.path)}):e.map(p)]})}function j({patch:e,truncated:s,truncatedLabel:a,loadingLabel:i}){const l=t.useMemo(()=>function(e){let s=0,t=0;return e.split("\n").map(e=>{const n=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(e);return n?(s=Number(n[1]),t=Number(n[2]),{text:e,kind:"hunk",oldLine:"",newLine:"",sign:""}):e.startsWith("diff ")||e.startsWith("index ")||e.startsWith("---")||e.startsWith("+++")||!s&&!t?{text:e,kind:"header",oldLine:"",newLine:"",sign:""}:e.startsWith("+")?{text:e.slice(1),kind:"add",oldLine:"",newLine:String(t++),sign:"+"}:e.startsWith("-")?{text:e.slice(1),kind:"del",oldLine:String(s++),newLine:"",sign:"−"}:e.startsWith(" ")?{text:e.slice(1),kind:"ctx",oldLine:String(s++),newLine:String(t++),sign:""}:{text:e,kind:"header",oldLine:"",newLine:"",sign:""}})}(e),[e]),[d,r]=t.useState(400),c=t.useRef(null);return t.useEffect(()=>{r(400)},[e]),t.useEffect(()=>{const e=c.current;if(!e)return;const s=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&r(e=>e+400)},{root:e.closest(".diff-patch"),rootMargin:"200px"});return s.observe(e),()=>s.disconnect()},[d,l.length]),n.jsxs("div",{className:"diff-patch-view",children:[l.slice(0,d).map((e,s)=>n.jsxs("div",{className:`diff-line ${e.kind}`,children:[n.jsx("span",{className:"diff-line-number","aria-hidden":"true",children:e.oldLine}),n.jsx("span",{className:"diff-line-number","aria-hidden":"true",children:e.newLine}),n.jsx("span",{className:"diff-line-sign","aria-hidden":"true",children:e.sign}),n.jsx("span",{className:"diff-line-text",children:e.text||" "})]},s)),d<l.length&&n.jsx("div",{ref:c,className:"diff-more",role:"status",children:i}),s&&n.jsx("p",{className:"diff-empty",children:a})]})}const w={loading:!1,files:null,error:null};function N({client:e,sessionId:s,cwd:i,sessionTitle:l,t:d,onClose:r,onDock:c,dockLabel:x,presentation:N="drawer",initialScope:v="unstaged",initialPath:k}){const y=t.useId(),L=t.useRef(null),[S,C]=t.useState(!1),I=t.useRef(void 0),E=t.useCallback(()=>{void 0===I.current&&("workspace"===N||window.matchMedia("(prefers-reduced-motion: reduce)").matches?r():(C(!0),I.current=window.setTimeout(r,180)))},[r,N]);t.useEffect(()=>()=>window.clearTimeout(I.current),[]);const P=a(E,L,"drawer"===N),$=o(e,{sessionId:s,cwd:i},v),[M,W]=t.useState(v),[D,R]=t.useState({unstaged:w,staged:w,[v]:{...w,files:$.data?.files??null}}),[F,T]=t.useState(k??$.data?.files[0]?.path??null),[X,Y]=t.useState($.patches.get(k??$.data?.files[0]?.path??"")?.data??null),[O,_]=t.useState(!1),[q,B]=t.useState(null),A=function(e){const s=t.useRef(void 0);return t.useEffect(()=>()=>s.current?.(),[]),{"data-dock-draggable":!!e,onPointerDown:t=>{if(!e||0!==t.button||t.target.closest("button"))return;s.current?.();const n=t.currentTarget,a=t.clientX,i=t.clientY,l=document.querySelector(".workspace-documents");if(!l)return;let d=!1;const r=(e,s)=>{const t=l.getBoundingClientRect();return e>=t.left&&e<=t.right&&s>=t.top&&s<=t.bottom},c=e=>{Math.hypot(e.clientX-a,e.clientY-i)<6&&!d||(d=!0,document.body.classList.add("dock-dragging"),l.classList.toggle("dock-drop-target",r(e.clientX,e.clientY)))},o=()=>{document.body.classList.remove("dock-dragging"),l.classList.remove("dock-drop-target"),window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",o),n.hasPointerCapture(t.pointerId)&&n.releasePointerCapture(t.pointerId),s.current=void 0},f=s=>{const t=d&&r(s.clientX,s.clientY);o(),t&&e()};s.current=o,n.setPointerCapture(t.pointerId),window.addEventListener("pointermove",c),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",o),t.preventDefault()}}}("drawer"===N&&c?()=>c({scope:M,path:F}):void 0),U=D[M],z=t.useCallback(async t=>{R(e=>({...e,[t]:{loading:!0,files:e[t].files,error:null}}));try{const n=await f(e,{sessionId:s,cwd:i},t);R(e=>({...e,[t]:{loading:!1,files:n.files,error:null}}))}catch(n){R(e=>({...e,[t]:{loading:!1,files:null,error:n instanceof Error?n.message:String(n)}}))}},[e,s,i]);t.useEffect(()=>{z(M)},[M,z]),t.useEffect(()=>{const e=U.files;e&&(e.length?T(s=>e.some(e=>e.path===s)?s:e[0].path):T(null))},[U.files]),t.useEffect(()=>{if(!F)return Y(null),void B(null);let t=!1;const n=o(e,{sessionId:s,cwd:i},M).patches.get(F)?.data;return Y(e=>n??(e?.path===F?e:null)),_(!n&&X?.path!==F),B(null),u(e,{sessionId:s,cwd:i},M,F).then(e=>{t||(Y(e),_(!1))}).catch(e=>{t||(B(e instanceof Error?e.message:String(e)),_(!1))}),()=>{t=!0}},[e,s,i,M,F,U.files]);const G=t.useMemo(()=>{const e=e=>e?e.reduce((e,s)=>({adds:e.adds+s.additions,dels:e.dels+s.deletions,count:e.count+1}),{adds:0,dels:0,count:0}):{adds:0,dels:0,count:0};return{unstaged:e(D.unstaged.files),staged:e(D.staged.files)}},[D]);return n.jsxs("div",{"aria-labelledby":y,"aria-modal":"drawer"===N||void 0,className:`diff-drawer ${"workspace"===N?"diff-workspace":""} ${S?"closing":""}`,ref:P,role:"drawer"===N?"dialog":"region",tabIndex:-1,children:["drawer"===N&&n.jsx("div",{className:"diff-drawer-backdrop",onClick:E,"aria-hidden":"true"}),n.jsxs("div",{className:"diff-drawer-panel",children:[n.jsxs("header",{className:"diff-drawer-header",...A,children:[c&&"drawer"===N&&n.jsx("button",{type:"button",className:"icon-button","aria-label":x,title:x,onClick:()=>c({scope:M,path:F}),children:n.jsx(h,{})}),n.jsxs("div",{children:[n.jsx("strong",{id:y,children:d.changes}),n.jsx("span",{children:l})]}),n.jsx("button",{"aria-label":d.closeChanges,className:"icon-button",onClick:E,ref:L,type:"button",title:d.closeChanges,children:n.jsx(p,{"aria-hidden":"true"})})]}),n.jsx("div",{className:"diff-tabs",role:"tablist",children:["unstaged","staged"].map(e=>{const s=G[e],t=M===e;return n.jsxs("button",{type:"button",role:"tab","aria-selected":t,className:"diff-tab "+(t?"active":""),onClick:()=>{e!==M&&(T(null),Y(null),B(null),W(e))},children:[n.jsx("span",{className:"diff-tab-label",children:"unstaged"===e?d.workingChanges:d.stagedChanges}),s.count>0?n.jsxs("span",{className:"diff-tab-meta",children:[n.jsxs("span",{className:"diff-add",children:["+",s.adds]}),n.jsxs("span",{className:"diff-del",children:["-",s.dels]})]}):null]},e)})}),n.jsx(g,{client:e,sessionId:s,scope:M,files:U.files}),n.jsxs("div",{className:"diff-body",children:[n.jsxs("aside",{className:"diff-files","aria-label":d.changedFiles,children:[U.loading&&!U.files?n.jsx("p",{className:"diff-empty",children:d.loading}):null,U.error?n.jsx("p",{className:"diff-empty diff-error",children:U.error}):null,U.files&&0===U.files.length?n.jsx("p",{className:"diff-empty",children:d.noChanges}):null,U.files&&U.files.length>0&&n.jsx(b,{files:U.files,selectedPath:F,onSelect:T,t:d})]}),n.jsx("section",{className:"diff-patch","aria-label":d.fileDiff,children:F?O?n.jsx("p",{className:"diff-empty",children:d.loadingPatch}):q?n.jsx("p",{className:"diff-empty diff-error",children:q}):X?.binary?n.jsx("p",{className:"diff-empty",children:d.binaryDiffUnavailable}):X?n.jsx(j,{patch:X.patch,truncated:X.truncated,truncatedLabel:d.patchTruncated,loadingLabel:d.loadingPatch},`${M}:${F}`):null:n.jsxs("div",{className:"diff-empty",children:[n.jsx(m,{"aria-hidden":"true"}),n.jsx("p",{children:d.selectFileForDiff})]})})]})]})]})}export{N as DiffDrawer};
@@ -1 +1 @@
1
- import{c as e,j as t,f as r,r as n,E as a,u as o,b as s,d as i}from"./index-CTpWXHK5.js";import{X as l,D as c,E as d,a as u,H as p,I as h,T as m,J as y,K as f,j as g,w as x,M as b,f as v,z as w,N as j,O as k,Q as D,U as E,L as C,q as N,b as _,c as S,x as M,e as F,i as L}from"./App-DHM2JpIe.js";import{A as T}from"./arrow-left-B_J8dbJk.js";import{F as R}from"./folder-plus-Dv3mIoot.js";import{A}from"./__vite-browser-external-2447137e-Ck9f6uYD.js";const P=e("clipboard-paste",[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]]),O=e("file-code-corner",[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]]),I=e("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),q=e("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]),K=e("scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);function B({ops:e,onOpen:r,root:o}){const s=n.useRef(null),i=e.menu,l=d();n.useLayoutEffect(()=>{const t=s.current,r=document.activeElement,n=t.getBoundingClientRect();t.style.left=`${Math.max(8,Math.min(i.x,innerWidth-n.width-8))}px`,t.style.top=`${Math.max(8,Math.min(i.y,innerHeight-n.height-8))}px`,t.querySelector("button:not(:disabled)")?.focus();const a=r=>{t.contains(r.target)||e.setMenu(null)},o=()=>e.setMenu(null);return document.addEventListener("pointerdown",a),document.addEventListener("scroll",o,!0),window.addEventListener("resize",o),()=>{document.removeEventListener("pointerdown",a),document.removeEventListener("scroll",o,!0),window.removeEventListener("resize",o),t.contains(document.activeElement)&&r?.focus()}},[]);const y=t=>{e.setMenu(null),t()};return t.jsxs("div",{ref:s,role:"menu","aria-label":e.strings.open,className:"session-context-menu file-tree-menu",style:{left:i.x,top:i.y},onKeyDown:t=>{t.stopPropagation();const r=Array.from(s.current.querySelectorAll("button:not(:disabled)")),n=r.indexOf(document.activeElement);["ArrowUp","ArrowDown","Home","End","Escape","Tab"].includes(t.key)&&t.preventDefault(),"Escape"!==t.key&&"Tab"!==t.key||e.setMenu(null),"ArrowDown"===t.key&&r[(n+1)%r.length]?.focus(),"ArrowUp"===t.key&&r[(n-1+r.length)%r.length]?.focus(),"Home"===t.key&&r[0]?.focus(),"End"===t.key&&r.at(-1)?.focus()},onContextMenu:e=>e.preventDefault(),children:[!i.directory&&t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>y(r),children:[t.jsx(a,{}),e.strings.open]}),!i.directory&&t.jsx(c,{path:i.path,cwd:o,daemonId:l?.daemonId,menu:!0,onComplete:()=>e.setMenu(null)}),i.path!==o&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>e.copy(i,!1),children:[t.jsx(u,{}),e.strings.copy,t.jsx("kbd",{children:p("mod+c")})]}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>e.copy(i,!0),children:[t.jsx(K,{}),e.strings.cut,t.jsx("kbd",{children:p("mod+x")})]})]}),t.jsxs("button",{type:"button",role:"menuitem",disabled:!e.canPaste,onClick:()=>y(()=>{e.paste(i)}),children:[t.jsx(P,{}),e.strings.paste,t.jsx("kbd",{children:p("mod+v")})]}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>y(()=>{e.copyPath(i)}),children:[t.jsx(q,{}),e.strings.copyPath]}),i.path!==o&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"context-menu-separator"}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>e.startRename(i),children:[t.jsx(h,{}),e.strings.rename,t.jsx("kbd",{children:"F2"})]}),t.jsxs("button",{type:"button",role:"menuitem",className:"danger",onClick:()=>y(()=>e.setDeleting(i)),children:[t.jsx(m,{}),e.strings.delete]})]})]})}function H({ops:e}){const r=o(()=>{e.busy||e.setDeleting(null)});return t.jsx("div",{className:"app-confirmation-layer",children:t.jsxs("div",{ref:r,className:"app-confirmation file-tree-delete-dialog",role:"dialog","aria-modal":"true","aria-label":e.strings.confirmDelete,tabIndex:-1,children:[t.jsx("h2",{children:e.strings.confirmDelete}),t.jsx("p",{children:e.deleting?.path}),t.jsx("p",{children:e.strings.deleteHint}),e.error&&t.jsx("p",{role:"alert",children:e.error}),t.jsxs("footer",{children:[t.jsx("button",{type:"button",disabled:e.busy,onClick:()=>e.setDeleting(null),children:e.strings.cancel}),t.jsx("button",{type:"button",className:"destructive",disabled:e.busy,onClick:()=>{e.deleteItem()},children:e.strings.delete})]})]})})}function U({ops:e,root:n,onOpen:a}){return t.jsxs(t.Fragment,{children:[e.menu&&r.createPortal(t.jsx(B,{ops:e,root:n,onOpen:a}),document.body),e.deleting&&r.createPortal(t.jsx(H,{ops:e}),document.body),e.error&&!e.deleting&&t.jsxs("div",{className:"file-tree-notice",role:"alert",children:[t.jsx("span",{children:e.error}),t.jsx("button",{type:"button",title:e.strings.dismiss,"aria-label":e.strings.dismiss,onClick:()=>e.setError(""),children:t.jsx(l,{})})]}),e.undo&&t.jsxs("div",{className:"file-tree-notice",role:"status",children:[t.jsx("span",{children:e.strings.deleted}),t.jsx("button",{type:"button",disabled:e.busy,onClick:()=>{e.restore()},children:e.strings.undo}),t.jsx("button",{type:"button",title:e.strings.dismiss,"aria-label":e.strings.dismiss,onClick:()=>e.setUndo(null),children:t.jsx(l,{})})]})]})}function z(e){return[...e].sort((e,t)=>Number(t.isDirectory)-Number(e.isDirectory)||e.name.localeCompare(t.name,void 0,{numeric:!0,sensitivity:"base"}))}const V={copy:"Copy",cut:"Cut",paste:"Paste",copyPath:"Copy path",backDirectory:"Back to previous directory",editPath:"Edit directory path",rename:"Rename",delete:"Delete",cancel:"Cancel",confirmDelete:"Delete this item?",deleteHint:"You can undo this deletion after it finishes.",deleted:"Deleted",undo:"Undo",dismiss:"Dismiss",name:"Name",open:"Open",errors:{destination_exists:"An item with this name already exists.",recursive_destination:"Choose a different folder.",outside_root:"Choose a destination inside this folder.",protected_path:"This location is protected.",invalid_operation:"Enter a valid file name.",unsaved_changes:"Save the open file changes first.",daemon_update_required:"Update Vibelet on the connected computer to enable file operations.",ENOENT:"The file or folder no longer exists. Refresh the tree.",EACCES:"Permission denied.",EXDEV:"Moving between disks is unavailable. Copy the item first.",operation_failed:"File operation failed.",source_cleanup_failed:"A recovery copy was saved, but the original could not be fully removed. Check file permissions before retrying.",refresh_failed:"The operation succeeded, but the file tree could not refresh. Refresh it to see the changes."}},G={copy:"复制",cut:"剪切",paste:"粘贴",copyPath:"复制路径",backDirectory:"返回上一个目录",editPath:"修改目录路径",rename:"重命名",delete:"删除",cancel:"取消",confirmDelete:"删除这个项目?",deleteHint:"删除完成后可以撤销。",deleted:"已删除",undo:"撤销",dismiss:"关闭",name:"名称",open:"打开",errors:{destination_exists:"已有同名文件或文件夹,请换一个名称。",recursive_destination:"不能移动或复制到自身目录中。",outside_root:"请选择当前文件夹内的目标目录。",protected_path:"不能操作这个受保护的位置。",invalid_operation:"请输入有效的文件名。",unsaved_changes:"请先保存已打开文件的修改。",daemon_update_required:"请更新被连接电脑上的 Vibelet,以启用文件操作。",ENOENT:"文件或文件夹已不存在,请刷新文件树。",EACCES:"没有操作权限。",EXDEV:"暂不支持跨磁盘移动,请先复制。",operation_failed:"文件操作失败。",source_cleanup_failed:"已保存恢复副本,但原文件未能完整移除。请检查文件权限后再重试。",refresh_failed:"操作已成功,但文件树刷新失败,请刷新查看结果。"}},X={copy:"複製",cut:"剪下",paste:"貼上",copyPath:"複製路徑",backDirectory:"返回上一個目錄",editPath:"修改目錄路徑",rename:"重新命名",delete:"刪除",cancel:"取消",confirmDelete:"刪除這個項目?",deleteHint:"刪除完成後可以復原。",deleted:"已刪除",undo:"復原",dismiss:"關閉",name:"名稱",open:"開啟",errors:{destination_exists:"已有同名檔案或資料夾,請換一個名稱。",recursive_destination:"不能移動或複製到自身目錄中。",outside_root:"請選擇目前資料夾內的目標目錄。",protected_path:"不能操作這個受保護的位置。",invalid_operation:"請輸入有效的檔案名稱。",unsaved_changes:"請先儲存已開啟檔案的修改。",daemon_update_required:"請更新被連接電腦上的 Vibelet,以啟用檔案操作。",ENOENT:"檔案或資料夾已不存在,請重新整理檔案樹。",EACCES:"沒有操作權限。",EXDEV:"暫不支援跨磁碟移動,請先複製。",operation_failed:"檔案操作失敗。",source_cleanup_failed:"已儲存復原副本,但原檔案未能完整移除。請檢查檔案權限後再重試。",refresh_failed:"操作已成功,但檔案樹重新整理失敗,請重新整理查看結果。"}};let J=null,W=null;const $="application/x-vibelet-file",Y="vibelet:file-clipboard";function Q({client:e,onRefreshDirectory:r,canGoBackDirectory:a,onGoBackDirectory:o,cwd:l,entries:c,error:d,loaded:u,loading:p,path:m,selectedPath:P,revealRequest:q,t:K,onListDirectory:B,onLoadChildren:H,onNewFolder:Q,onOpenRemoteFile:Z}){const ee=y(),te=JSON.stringify([ee?.scopeKey??"default",m]),re=function(e,t,r){const a=y(),o=JSON.stringify([a?.scopeKey??"default",e]),[s,i]=f(o,()=>new Set),[l,c]=f(o,()=>({})),[d,u]=f(o,()=>new Set),[p,h]=f(o,()=>({})),m=n.useRef(0),g=n.useRef(new Set);n.useEffect(()=>(b(),()=>{m.current++}),[e,o]);const x=async(e,t)=>{if(!g.current.has(e)){g.current.add(e),u(t=>new Set(t).add(e)),h(t=>{const r={...t};return delete r[e],r});try{const n=await r(e);m.current===t&&c(t=>({...t,[e]:z(n)}))}catch{m.current===t&&h(t=>({...t,[e]:"unavailable"}))}finally{m.current===t&&(g.current.delete(e),u(t=>{const r=new Set(t);return r.delete(e),r}))}}},b=async()=>{const e=++m.current;g.current.clear(),u(new Set),h({}),c(e=>Object.fromEntries(Object.entries(e).filter(([e])=>s.has(e)))),await Promise.all([...s].map(t=>x(t,e)))};return{refresh:b,expanded:s,children:l,loading:d,errors:p,collapse:e=>i(t=>{const r=new Set(t);return r.delete(e),r}),expand:async e=>{i(t=>new Set(t).add(e)),l[e]&&!p[e]||await x(e,m.current)}}}(m,0,H),ne=function(e,t){const r=y()?.scopeKey,a=function(){const e=s(i().language);return"en"===e?V:"zh-TW"===e?X:G}(),[o,l]=n.useState(null),[c,d]=n.useState(null),[u,p]=n.useState(""),[h,f]=n.useState(null),[C,N]=n.useState(null),[_,S]=n.useState(""),M=e=>{e&&S(""),f(e)},[F,L]=n.useState(!1),T=n.useRef(!1),R=n.useRef(0),[A,P]=n.useState(null),[,O]=n.useState(0),I=g(),q=I?.daemonId;n.useEffect(()=>{const e=()=>O(e=>e+1);return window.addEventListener(Y,e),()=>window.removeEventListener(Y,e)},[]),n.useEffect(()=>(R.current++,T.current=!1,L(!1),l(null),d(null),M(null),N(null),S(""),P(null),()=>{R.current++}),[e,t,q,r]);const K=e=>{const t=e instanceof Error?e.message:"operation_failed";S(a.errors[t]??a.errors.operation_failed)},H=async r=>{if(!I||T.current)return null;const n=R.current,o=()=>R.current===n&&g()?.daemonId===q;T.current=!0,L(!0),S("");try{const n=await E({...r,root:e,cwd:t},I);if(o()){"delete"===n.action&&N(n);try{await(async()=>{B(m),await re.refresh()})()}catch{o()&&S(a.errors.refresh_failed)}}return{current:o()}}catch(s){return o()&&K(s),null}finally{R.current===n&&(T.current=!1,L(!1))}},U=(r,n)=>{q&&(J={target:r,cut:n,daemonId:q,root:e,cwd:t},window.dispatchEvent(new Event(Y)),l(null),S(""))},z=t=>t.directory?t.path:j(t.path)??e,Q=Boolean(J&&J.daemonId===q),Z=async e=>{const r=J;Q&&r&&await H({action:r.cut?"move":"copy",path:r.target.path,sourceRoot:r.root,sourceCwd:r.cwd,target:w(z(e),v(r.target.path)),autoRename:!r.cut&&b(z(e),t)===b(j(r.target.path)??r.root,r.cwd)})&&r.cut&&J===r&&(J=null,window.dispatchEvent(new Event(Y)))},ee=(e,t,r)=>{T.current||l({...e,x:t,y:r})},te=e=>{d(e),p(v(e.path)),l(null),S("")},ne=r=>{if(!W||W.daemonId!==q||W.root!==e||W.cwd!==t||T.current)return!1;const n=b(W.target.path,t),a=b(r,t);return a!==n&&!a.startsWith(`${n}/`)&&b(j(W.target.path)??e,t)!==a};return{strings:a,menu:o,setMenu:l,rename:c,setRename:d,name:u,setName:p,deleting:h,setDeleting:M,error:_,setError:S,busy:F,undo:C,setUndo:N,canPaste:Q,copy:U,paste:Z,key:(e,t)=>{if(e.target!==e.currentTarget)return!1;if(k(e)&&["c","x","v"].includes(e.key.toLowerCase()))return e.preventDefault(),"v"===e.key.toLowerCase()?Z(t):U(t,"x"===e.key.toLowerCase()),!0;if("F2"===e.key)return e.preventDefault(),te(t),!0;if("Delete"===e.key||D()&&k(e)&&"Backspace"===e.key)return e.preventDefault(),M(t),!0;if("ContextMenu"===e.key||e.shiftKey&&"F10"===e.key){e.preventDefault();const r=e.currentTarget.getBoundingClientRect();return ee(t,r.left+20,r.top+24),!0}return!1},startRename:te,commitRename:async()=>{if(!c)return;const t=u.trim();t&&!/[/\\\x00]/.test(t)&&"."!==t&&".."!==t?t!==v(c.path)?(await H({action:"move",path:c.path,target:w(j(c.path)??e,t)}))?.current&&d(null):d(null):K(new Error("invalid_operation"))},openMenu:ee,copyPath:async e=>{const r=R.current;try{await x(b(e.path,t))}catch(n){R.current===r&&K(n)}},deleteItem:async()=>{h&&(await H({action:"delete",path:h.path}))?.current&&M(null)},restore:async()=>{C&&(await H({action:"restore",path:C.path,recoveryId:C.recoveryId}))?.current&&N(null)},isCut:e=>Boolean(J?.cut&&J.daemonId===q&&J.target.path===e),dropTarget:A,dragStart:(r,n)=>{q&&!T.current?(W={target:n,cut:!0,daemonId:q,root:e,cwd:t},r.dataTransfer.setData($,n.path),r.dataTransfer.effectAllowed="copyMove",l(null)):r.preventDefault()},dragEnd:()=>{W=null,P(null)},dragOver:(e,t)=>{e.dataTransfer.types.includes($)&&ne(t)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=e.altKey?"copy":"move",P(t))},dragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||P(null)},drop:(e,t)=>{e.preventDefault(),e.stopPropagation(),P(null),e.dataTransfer.types.includes($)&&ne(t)&&W&&H({action:e.altKey?"copy":"move",path:W.target.path,target:w(t,v(W.target.path))})}}}(m,l),ae=n.useRef(null),[oe,se]=f(te,!0);!function(e,t,r,a,o){const s=n.useRef(o);s.current=o;const i=JSON.stringify(t.slice().sort());n.useEffect(()=>{if(e?.isConnected)return function(e,t,r,n){const a=e.makeId("directory-watch");let o,s=!1,i=!1,l=!1;const c=async()=>{if(l=!0,!i&&!s){i=!0;try{for(;l&&!s&&e.isConnected;)l=!1,await n().catch(()=>{})}finally{i=!1}}},d=async()=>{let n=2e3;if(e.supportsDirectoryWatch&&t.length<=256)try{(await e.request({action:"dirs.watch",id:a,paths:t,cwd:r},{timeoutMs:5e3})).unavailable.length||(n=3e4)}catch{}s||(c(),o=setTimeout(()=>{d()},n))},u=e.onMessage(e=>{"dirs.changed"===e.type&&e.watchId===a&&c()}),p=()=>{c()};window.addEventListener("focus",p);const h=()=>{s||(s=!0,o&&clearTimeout(o),u(),m(),window.removeEventListener("focus",p),e.supportsDirectoryWatch&&e.send({action:"dirs.watch",id:e.makeId("directory-unwatch"),paths:[]}))},m=e.onClose(h);return d(),h}(e,JSON.parse(i),r,()=>s.current())},[e,i,r,a])}(e,function(e,t,r,n){const a=[e],o=(e,t)=>{for(const s of t){const t=w(e,s.name);s.isDirectory&&r.has(t)&&(a.push(t),o(t,n[t]??[]))}};return o(e,t),a}(m,oe?c:[],re.expanded,re.children),l,te,async()=>{await Promise.all([r?.(),re.refresh()])});const[ie,le]=n.useState(!1),[ce,de]=n.useState(m),[ue,pe]=n.useState(P),[he,me]=n.useState();n.useEffect(()=>{de(m),le(!1)},[m,te]),n.useEffect(()=>me(void 0),[m,c]),n.useEffect(()=>{pe(P)},[P]);const ye=n.useRef(void 0);n.useEffect(()=>{if(!q||ye.current===q||p)return;se(!0);const e=Array.from(ae.current?.querySelectorAll('[role="treeitem"]')??[]).find(e=>e.dataset.path===q.path);if(!e)return;pe(q.path);const t=requestAnimationFrame(()=>{e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest"}),ye.current=q});return()=>cancelAnimationFrame(t)},[q,p,c,oe,se]);const fe=(e,t)=>{e.isDirectory?re.expanded.has(t)?re.collapse(t):re.expand(t):(pe(t),Z(t,l))},ge=e=>e?.focus(),xe=z(c),be=(e,r,n)=>e.map((a,o)=>{const s=w(r,a.name),i=re.expanded.has(s),l=a.isDirectory?i?M:F:function(e){return/\.(png|jpe?g|gif|webp|svg|ico)$/i.test(e)?I:/\.(tsx?|jsx?|json|css|html|py|rs|go|swift|ya?ml|sh)$/i.test(e)?O:L}(a.name);return t.jsxs("div",{role:"treeitem","aria-label":a.name,"aria-level":n+1,"aria-posinset":o+1,"aria-setsize":e.length,"aria-expanded":a.isDirectory?i:void 0,"aria-selected":ue===s,"aria-busy":re.loading.has(s)||void 0,"data-path":s,className:"explorer-tree-item",tabIndex:he===s||!he&&0===n&&0===o?0:-1,onFocus:e=>{e.target===e.currentTarget&&me(s)},onKeyDown:e=>((e,t,r)=>{if(e.stopPropagation(),ne.key(e,{path:r,directory:t.isDirectory}))return;if(e.target instanceof HTMLInputElement)return;const n=Array.from(ae.current?.querySelectorAll('[role="treeitem"]')??[]),a=n.indexOf(e.currentTarget);["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","Enter"," "].includes(e.key)&&e.preventDefault(),"ArrowUp"===e.key&&ge(n[Math.max(0,a-1)]),"ArrowDown"===e.key&&ge(n[Math.min(n.length-1,a+1)]),"Home"===e.key&&ge(n[0]),"End"===e.key&&ge(n.at(-1)),"ArrowRight"===e.key&&t.isDirectory&&(!re.expanded.has(r)||re.errors[r]?re.expand(r):ge(e.currentTarget.querySelector('[role="treeitem"]'))),"ArrowLeft"===e.key&&(t.isDirectory&&re.expanded.has(r)?re.collapse(r):ge(e.currentTarget.parentElement?.closest('[role="treeitem"]'))),"Enter"!==e.key&&" "!==e.key||fe(t,r)})(e,a,s),children:[t.jsxs("div",{className:"explorer-tree-row",draggable:!ne.busy&&ne.rename?.path!==s,"data-cut":ne.isCut(s)||void 0,"data-drop":ne.dropTarget===s||void 0,onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),ge(e.currentTarget.parentElement),ne.openMenu({path:s,directory:a.isDirectory},e.clientX,e.clientY)},onDragStart:e=>ne.dragStart(e,{path:s,directory:a.isDirectory}),onDragEnd:ne.dragEnd,onDragOver:e=>a.isDirectory&&ne.dragOver(e,s),onDragLeave:ne.dragLeave,onDrop:e=>a.isDirectory&&ne.drop(e,s),style:{paddingLeft:8+14*n},title:s,onClick:e=>{ge(e.currentTarget.parentElement),fe(a,s)},children:[t.jsx("span",{className:"explorer-chevron","aria-hidden":"true",children:a.isDirectory&&(re.loading.has(s)?t.jsx(C,{className:"explorer-spinner"}):i?t.jsx(_,{}):t.jsx(S,{}))}),t.jsx(l,{className:a.isDirectory?"explorer-folder-icon":"explorer-file-icon","aria-hidden":"true"}),t.jsx("span",{className:"explorer-entry-name",children:ne.rename?.path===s?t.jsx("input",{className:"explorer-rename","aria-label":ne.strings.name,autoFocus:!0,value:ne.name,disabled:ne.busy,onFocus:e=>e.target.select(),onClick:e=>e.stopPropagation(),onChange:e=>ne.setName(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.nativeEvent.isComposing||229===e.keyCode||("Enter"===e.key&&(e.preventDefault(),ne.commitRename()),"Escape"===e.key&&(e.preventDefault(),ne.setRename(null)))}}):a.name})]}),a.isDirectory&&i&&t.jsxs("div",{role:"group",className:"explorer-tree-group",style:{"--tree-guide-left":14+14*n+"px"},children:[re.children[s]?be(re.children[s],s,n+1):null,re.errors[s]&&t.jsx("button",{className:"explorer-retry",type:"button",onClick:()=>{re.expand(s)},children:K.retry}),0===re.children[s]?.length&&t.jsx("p",{className:"explorer-empty",style:{paddingLeft:36+14*n},children:K.noFilesInDirectory})]})]},s)});return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"explorer-heading",children:[t.jsx("h2",{children:K.fileTree}),t.jsxs("div",{className:"explorer-actions",children:[t.jsx("button",{className:"icon-button",title:ne.strings.backDirectory,"aria-label":ne.strings.backDirectory,disabled:!a||p,onClick:o,type:"button",children:t.jsx(T,{"aria-hidden":"true"})}),t.jsx("button",{className:"icon-button",title:ne.strings.editPath,"aria-label":ne.strings.editPath,"aria-expanded":ie,onClick:()=>{de("."===m?l:m),le(e=>!e)},type:"button",children:t.jsx(h,{"aria-hidden":"true"})}),t.jsx("button",{className:"icon-button",title:K.newFolder,"aria-label":K.newFolder,onClick:Q,type:"button",children:t.jsx(R,{"aria-hidden":"true"})}),t.jsx("button",{className:"icon-button",title:K.refreshFiles,"aria-label":K.refreshFiles,disabled:p,onClick:()=>{B(m),re.refresh()},type:"button",children:p?t.jsx(C,{className:"explorer-spinner","aria-hidden":"true"}):t.jsx(N,{"aria-hidden":"true"})}),t.jsx("button",{className:"icon-button",title:K.parentFolder,"aria-label":K.parentFolder,disabled:!j(m),onClick:()=>B(j(m)??m),type:"button",children:t.jsx(A,{"aria-hidden":"true"})})]})]}),t.jsxs("button",{type:"button",className:"explorer-root-path",onContextMenu:e=>{e.preventDefault(),ne.openMenu({path:m,directory:!0},e.clientX,e.clientY)},onDragOver:e=>ne.dragOver(e,m),onDragLeave:ne.dragLeave,onDrop:e=>ne.drop(e,m),"data-drop":ne.dropTarget===m||void 0,title:"."===m?l:m,"aria-expanded":oe,onClick:()=>{se(e=>!e),le(!1)},children:[oe?t.jsx(_,{"aria-hidden":"true"}):t.jsx(S,{"aria-hidden":"true"}),oe?t.jsx(M,{"aria-hidden":"true"}):t.jsx(F,{"aria-hidden":"true"}),t.jsx("span",{children:v("."===m?l:m)||m})]}),ie&&t.jsx("form",{className:"explorer-path-form",onSubmit:e=>{e.preventDefault(),ce.trim()&&(B(ce.trim()),le(!1))},children:t.jsx("input",{autoFocus:!0,"aria-label":K.path,value:ce,onChange:e=>de(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||229===e.keyCode?"Enter"===e.key&&e.preventDefault():"Escape"===e.key&&le(!1)}})}),d&&t.jsx("p",{className:"empty-copy",role:"alert",children:d}),p&&t.jsx("p",{className:"explorer-empty",role:"status",children:K.loadingFiles}),oe&&t.jsx("div",{ref:ae,role:"tree","aria-label":K.fileTree,className:"explorer-tree","aria-busy":p||ne.busy,"data-drop":ne.dropTarget===m||void 0,onContextMenu:e=>{e.preventDefault(),ne.openMenu({path:m,directory:!0},e.clientX,e.clientY)},onDragOver:e=>ne.dragOver(e,m),onDragLeave:ne.dragLeave,onDrop:e=>ne.drop(e,m),children:be(xe,m,0)}),t.jsx(U,{ops:ne,root:m,onOpen:()=>ne.menu&&Z(ne.menu.path,l)}),oe&&u&&!p&&!d&&0===c.length&&t.jsx("p",{className:"explorer-empty",children:K.noFilesInDirectory})]})}function Z({client:e,watch:r=!0,onRefreshDirectory:n,canGoBackDirectory:a,onGoBackDirectory:o,busy:s,onLoadChildren:i,cwd:l,directory:c,newDirName:u,remoteFile:p,t:h,onCreateDirectory:m,onListDirectory:g,onNewDirNameChange:x,onOpenRemoteFile:b}){const v=d(),w=y(),[j,k]=f(w?.scopeKey??"default",!1);return t.jsx(t.Fragment,{children:t.jsxs("section",{className:"control-section files-explorer",children:[t.jsx(Q,{client:r?e:null,onRefreshDirectory:n,canGoBackDirectory:a,onGoBackDirectory:o,cwd:l,revealRequest:v?.request,selectedPath:p?.path,onLoadChildren:i,onNewFolder:()=>k(e=>!e),entries:c.entries,error:c.error,loaded:c.loaded,loading:c.loading,path:c.path,t:h,onListDirectory:g,onOpenRemoteFile:b}),j&&t.jsxs("div",{className:"field-row file-tree-create",children:[t.jsx("input",{value:u,onChange:e=>x(e.target.value),placeholder:h.newFolder,"aria-label":h.newFolder,autoFocus:!0,onKeyDown:e=>{"Escape"===e.key&&(k(!1),x("")),"Enter"===e.key&&u.trim()&&!s&&m()}}),t.jsxs("button",{className:"icon-text-button",onClick:m,type:"button",disabled:s||!u.trim(),children:[t.jsx(F,{"aria-hidden":"true"}),h.create]})]})]})})}export{Z as FilesControlPanel};
1
+ import{c as e,j as t,f as r,r as n,E as a,u as o,b as s,d as i}from"./index-C6NKSiG-.js";import{X as l,D as c,H as d,a as u,I as p,J as h,T as m,K as y,M as f,j as g,w as x,N as b,f as v,z as w,O as j,Q as k,U as D,W as E,L as C,q as N,b as _,c as S,x as M,e as F,i as L}from"./App-D4fBMWn7.js";import{A as T}from"./arrow-left-CTbegMaU.js";import{F as R}from"./folder-plus-BBvp5bBk.js";import{A}from"./__vite-browser-external-2447137e-DYOQzEuf.js";const P=e("clipboard-paste",[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]]),O=e("file-code-corner",[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]]),I=e("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),q=e("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]),K=e("scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);function B({ops:e,onOpen:r,root:o}){const s=n.useRef(null),i=e.menu,l=d();n.useLayoutEffect(()=>{const t=s.current,r=document.activeElement,n=t.getBoundingClientRect();t.style.left=`${Math.max(8,Math.min(i.x,innerWidth-n.width-8))}px`,t.style.top=`${Math.max(8,Math.min(i.y,innerHeight-n.height-8))}px`,t.querySelector("button:not(:disabled)")?.focus();const a=r=>{t.contains(r.target)||e.setMenu(null)},o=()=>e.setMenu(null);return document.addEventListener("pointerdown",a),document.addEventListener("scroll",o,!0),window.addEventListener("resize",o),()=>{document.removeEventListener("pointerdown",a),document.removeEventListener("scroll",o,!0),window.removeEventListener("resize",o),t.contains(document.activeElement)&&r?.focus()}},[]);const y=t=>{e.setMenu(null),t()};return t.jsxs("div",{ref:s,role:"menu","aria-label":e.strings.open,className:"session-context-menu file-tree-menu",style:{left:i.x,top:i.y},onKeyDown:t=>{t.stopPropagation();const r=Array.from(s.current.querySelectorAll("button:not(:disabled)")),n=r.indexOf(document.activeElement);["ArrowUp","ArrowDown","Home","End","Escape","Tab"].includes(t.key)&&t.preventDefault(),"Escape"!==t.key&&"Tab"!==t.key||e.setMenu(null),"ArrowDown"===t.key&&r[(n+1)%r.length]?.focus(),"ArrowUp"===t.key&&r[(n-1+r.length)%r.length]?.focus(),"Home"===t.key&&r[0]?.focus(),"End"===t.key&&r.at(-1)?.focus()},onContextMenu:e=>e.preventDefault(),children:[!i.directory&&t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>y(r),children:[t.jsx(a,{}),e.strings.open]}),!i.directory&&t.jsx(c,{path:i.path,cwd:o,daemonId:l?.daemonId,menu:!0,onComplete:()=>e.setMenu(null)}),i.path!==o&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>e.copy(i,!1),children:[t.jsx(u,{}),e.strings.copy,t.jsx("kbd",{children:p("mod+c")})]}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>e.copy(i,!0),children:[t.jsx(K,{}),e.strings.cut,t.jsx("kbd",{children:p("mod+x")})]})]}),t.jsxs("button",{type:"button",role:"menuitem",disabled:!e.canPaste,onClick:()=>y(()=>{e.paste(i)}),children:[t.jsx(P,{}),e.strings.paste,t.jsx("kbd",{children:p("mod+v")})]}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>y(()=>{e.copyPath(i)}),children:[t.jsx(q,{}),e.strings.copyPath]}),i.path!==o&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"context-menu-separator"}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>e.startRename(i),children:[t.jsx(h,{}),e.strings.rename,t.jsx("kbd",{children:"F2"})]}),t.jsxs("button",{type:"button",role:"menuitem",className:"danger",onClick:()=>y(()=>e.setDeleting(i)),children:[t.jsx(m,{}),e.strings.delete]})]})]})}function H({ops:e}){const r=o(()=>{e.busy||e.setDeleting(null)});return t.jsx("div",{className:"app-confirmation-layer",children:t.jsxs("div",{ref:r,className:"app-confirmation file-tree-delete-dialog",role:"dialog","aria-modal":"true","aria-label":e.strings.confirmDelete,tabIndex:-1,children:[t.jsx("h2",{children:e.strings.confirmDelete}),t.jsx("p",{children:e.deleting?.path}),t.jsx("p",{children:e.strings.deleteHint}),e.error&&t.jsx("p",{role:"alert",children:e.error}),t.jsxs("footer",{children:[t.jsx("button",{type:"button",disabled:e.busy,onClick:()=>e.setDeleting(null),children:e.strings.cancel}),t.jsx("button",{type:"button",className:"destructive",disabled:e.busy,onClick:()=>{e.deleteItem()},children:e.strings.delete})]})]})})}function U({ops:e,root:n,onOpen:a}){return t.jsxs(t.Fragment,{children:[e.menu&&r.createPortal(t.jsx(B,{ops:e,root:n,onOpen:a}),document.body),e.deleting&&r.createPortal(t.jsx(H,{ops:e}),document.body),e.error&&!e.deleting&&t.jsxs("div",{className:"file-tree-notice",role:"alert",children:[t.jsx("span",{children:e.error}),t.jsx("button",{type:"button",title:e.strings.dismiss,"aria-label":e.strings.dismiss,onClick:()=>e.setError(""),children:t.jsx(l,{})})]}),e.undo&&t.jsxs("div",{className:"file-tree-notice",role:"status",children:[t.jsx("span",{children:e.strings.deleted}),t.jsx("button",{type:"button",disabled:e.busy,onClick:()=>{e.restore()},children:e.strings.undo}),t.jsx("button",{type:"button",title:e.strings.dismiss,"aria-label":e.strings.dismiss,onClick:()=>e.setUndo(null),children:t.jsx(l,{})})]})]})}function z(e){return[...e].sort((e,t)=>Number(t.isDirectory)-Number(e.isDirectory)||e.name.localeCompare(t.name,void 0,{numeric:!0,sensitivity:"base"}))}const V={copy:"Copy",cut:"Cut",paste:"Paste",copyPath:"Copy path",backDirectory:"Back to previous directory",editPath:"Edit directory path",rename:"Rename",delete:"Delete",cancel:"Cancel",confirmDelete:"Delete this item?",deleteHint:"You can undo this deletion after it finishes.",deleted:"Deleted",undo:"Undo",dismiss:"Dismiss",name:"Name",open:"Open",errors:{destination_exists:"An item with this name already exists.",recursive_destination:"Choose a different folder.",outside_root:"Choose a destination inside this folder.",protected_path:"This location is protected.",invalid_operation:"Enter a valid file name.",unsaved_changes:"Save the open file changes first.",daemon_update_required:"Update Vibelet on the connected computer to enable file operations.",ENOENT:"The file or folder no longer exists. Refresh the tree.",EACCES:"Permission denied.",EXDEV:"Moving between disks is unavailable. Copy the item first.",operation_failed:"File operation failed.",source_cleanup_failed:"A recovery copy was saved, but the original could not be fully removed. Check file permissions before retrying.",refresh_failed:"The operation succeeded, but the file tree could not refresh. Refresh it to see the changes."}},G={copy:"复制",cut:"剪切",paste:"粘贴",copyPath:"复制路径",backDirectory:"返回上一个目录",editPath:"修改目录路径",rename:"重命名",delete:"删除",cancel:"取消",confirmDelete:"删除这个项目?",deleteHint:"删除完成后可以撤销。",deleted:"已删除",undo:"撤销",dismiss:"关闭",name:"名称",open:"打开",errors:{destination_exists:"已有同名文件或文件夹,请换一个名称。",recursive_destination:"不能移动或复制到自身目录中。",outside_root:"请选择当前文件夹内的目标目录。",protected_path:"不能操作这个受保护的位置。",invalid_operation:"请输入有效的文件名。",unsaved_changes:"请先保存已打开文件的修改。",daemon_update_required:"请更新被连接电脑上的 Vibelet,以启用文件操作。",ENOENT:"文件或文件夹已不存在,请刷新文件树。",EACCES:"没有操作权限。",EXDEV:"暂不支持跨磁盘移动,请先复制。",operation_failed:"文件操作失败。",source_cleanup_failed:"已保存恢复副本,但原文件未能完整移除。请检查文件权限后再重试。",refresh_failed:"操作已成功,但文件树刷新失败,请刷新查看结果。"}},W={copy:"複製",cut:"剪下",paste:"貼上",copyPath:"複製路徑",backDirectory:"返回上一個目錄",editPath:"修改目錄路徑",rename:"重新命名",delete:"刪除",cancel:"取消",confirmDelete:"刪除這個項目?",deleteHint:"刪除完成後可以復原。",deleted:"已刪除",undo:"復原",dismiss:"關閉",name:"名稱",open:"開啟",errors:{destination_exists:"已有同名檔案或資料夾,請換一個名稱。",recursive_destination:"不能移動或複製到自身目錄中。",outside_root:"請選擇目前資料夾內的目標目錄。",protected_path:"不能操作這個受保護的位置。",invalid_operation:"請輸入有效的檔案名稱。",unsaved_changes:"請先儲存已開啟檔案的修改。",daemon_update_required:"請更新被連接電腦上的 Vibelet,以啟用檔案操作。",ENOENT:"檔案或資料夾已不存在,請重新整理檔案樹。",EACCES:"沒有操作權限。",EXDEV:"暫不支援跨磁碟移動,請先複製。",operation_failed:"檔案操作失敗。",source_cleanup_failed:"已儲存復原副本,但原檔案未能完整移除。請檢查檔案權限後再重試。",refresh_failed:"操作已成功,但檔案樹重新整理失敗,請重新整理查看結果。"}};let X=null,J=null;const $="application/x-vibelet-file",Y="vibelet:file-clipboard";function Q({client:e,onRefreshDirectory:r,canGoBackDirectory:a,onGoBackDirectory:o,cwd:l,entries:c,error:d,loaded:u,loading:p,path:m,selectedPath:P,revealRequest:q,t:K,onListDirectory:B,onLoadChildren:H,onNewFolder:Q,onOpenRemoteFile:Z}){const ee=y(),te=JSON.stringify([ee?.scopeKey??"default",m]),re=function(e,t,r){const a=y(),o=JSON.stringify([a?.scopeKey??"default",e]),[s,i]=f(o,()=>new Set),[l,c]=f(o,()=>({})),[d,u]=f(o,()=>new Set),[p,h]=f(o,()=>({})),m=n.useRef(0),g=n.useRef(new Set);n.useEffect(()=>(b(),()=>{m.current++}),[e,o]);const x=async(e,t)=>{if(!g.current.has(e)){g.current.add(e),u(t=>new Set(t).add(e)),h(t=>{const r={...t};return delete r[e],r});try{const n=await r(e);m.current===t&&c(t=>({...t,[e]:z(n)}))}catch{m.current===t&&h(t=>({...t,[e]:"unavailable"}))}finally{m.current===t&&(g.current.delete(e),u(t=>{const r=new Set(t);return r.delete(e),r}))}}},b=async()=>{const e=++m.current;g.current.clear(),u(new Set),h({}),c(e=>Object.fromEntries(Object.entries(e).filter(([e])=>s.has(e)))),await Promise.all([...s].map(t=>x(t,e)))};return{refresh:b,expanded:s,children:l,loading:d,errors:p,collapse:e=>i(t=>{const r=new Set(t);return r.delete(e),r}),expand:async e=>{i(t=>new Set(t).add(e)),l[e]&&!p[e]||await x(e,m.current)}}}(m,0,H),ne=function(e,t){const r=y()?.scopeKey,a=function(){const e=s(i().language);return"en"===e?V:"zh-TW"===e?W:G}(),[o,l]=n.useState(null),[c,d]=n.useState(null),[u,p]=n.useState(""),[h,f]=n.useState(null),[C,N]=n.useState(null),[_,S]=n.useState(""),M=e=>{e&&S(""),f(e)},[F,L]=n.useState(!1),T=n.useRef(!1),R=n.useRef(0),[A,P]=n.useState(null),[,O]=n.useState(0),I=g(),q=I?.daemonId;n.useEffect(()=>{const e=()=>O(e=>e+1);return window.addEventListener(Y,e),()=>window.removeEventListener(Y,e)},[]),n.useEffect(()=>(R.current++,T.current=!1,L(!1),l(null),d(null),M(null),N(null),S(""),P(null),()=>{R.current++}),[e,t,q,r]);const K=e=>{const t=e instanceof Error?e.message:"operation_failed";S(a.errors[t]??a.errors.operation_failed)},H=async r=>{if(!I||T.current)return null;const n=R.current,o=()=>R.current===n&&g()?.daemonId===q;T.current=!0,L(!0),S("");try{const n=await E({...r,root:e,cwd:t},I);if(o()){"delete"===n.action&&N(n);try{await(async()=>{B(m),await re.refresh()})()}catch{o()&&S(a.errors.refresh_failed)}}return{current:o()}}catch(s){return o()&&K(s),null}finally{R.current===n&&(T.current=!1,L(!1))}},U=(r,n)=>{q&&(X={target:r,cut:n,daemonId:q,root:e,cwd:t},window.dispatchEvent(new Event(Y)),l(null),S(""))},z=t=>t.directory?t.path:j(t.path)??e,Q=Boolean(X&&X.daemonId===q),Z=async e=>{const r=X;Q&&r&&await H({action:r.cut?"move":"copy",path:r.target.path,sourceRoot:r.root,sourceCwd:r.cwd,target:w(z(e),v(r.target.path)),autoRename:!r.cut&&b(z(e),t)===b(j(r.target.path)??r.root,r.cwd)})&&r.cut&&X===r&&(X=null,window.dispatchEvent(new Event(Y)))},ee=(e,t,r)=>{T.current||l({...e,x:t,y:r})},te=e=>{d(e),p(v(e.path)),l(null),S("")},ne=r=>{if(!J||J.daemonId!==q||J.root!==e||J.cwd!==t||T.current)return!1;const n=b(J.target.path,t),a=b(r,t);return a!==n&&!a.startsWith(`${n}/`)&&b(j(J.target.path)??e,t)!==a};return{strings:a,menu:o,setMenu:l,rename:c,setRename:d,name:u,setName:p,deleting:h,setDeleting:M,error:_,setError:S,busy:F,undo:C,setUndo:N,canPaste:Q,copy:U,paste:Z,key:(e,t)=>{if(e.target!==e.currentTarget)return!1;if(k(e)&&["c","x","v"].includes(e.key.toLowerCase()))return e.preventDefault(),"v"===e.key.toLowerCase()?Z(t):U(t,"x"===e.key.toLowerCase()),!0;if("F2"===e.key)return e.preventDefault(),te(t),!0;if("Delete"===e.key||D()&&k(e)&&"Backspace"===e.key)return e.preventDefault(),M(t),!0;if("ContextMenu"===e.key||e.shiftKey&&"F10"===e.key){e.preventDefault();const r=e.currentTarget.getBoundingClientRect();return ee(t,r.left+20,r.top+24),!0}return!1},startRename:te,commitRename:async()=>{if(!c)return;const t=u.trim();t&&!/[/\\\x00]/.test(t)&&"."!==t&&".."!==t?t!==v(c.path)?(await H({action:"move",path:c.path,target:w(j(c.path)??e,t)}))?.current&&d(null):d(null):K(new Error("invalid_operation"))},openMenu:ee,copyPath:async e=>{const r=R.current;try{await x(b(e.path,t))}catch(n){R.current===r&&K(n)}},deleteItem:async()=>{h&&(await H({action:"delete",path:h.path}))?.current&&M(null)},restore:async()=>{C&&(await H({action:"restore",path:C.path,recoveryId:C.recoveryId}))?.current&&N(null)},isCut:e=>Boolean(X?.cut&&X.daemonId===q&&X.target.path===e),dropTarget:A,dragStart:(r,n)=>{q&&!T.current?(J={target:n,cut:!0,daemonId:q,root:e,cwd:t},r.dataTransfer.setData($,n.path),r.dataTransfer.effectAllowed="copyMove",l(null)):r.preventDefault()},dragEnd:()=>{J=null,P(null)},dragOver:(e,t)=>{e.dataTransfer.types.includes($)&&ne(t)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=e.altKey?"copy":"move",P(t))},dragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||P(null)},drop:(e,t)=>{e.preventDefault(),e.stopPropagation(),P(null),e.dataTransfer.types.includes($)&&ne(t)&&J&&H({action:e.altKey?"copy":"move",path:J.target.path,target:w(t,v(J.target.path))})}}}(m,l),ae=n.useRef(null),[oe,se]=f(te,!0);!function(e,t,r,a,o){const s=n.useRef(o);s.current=o;const i=JSON.stringify(t.slice().sort());n.useEffect(()=>{if(e?.isConnected)return function(e,t,r,n){const a=e.makeId("directory-watch");let o,s=!1,i=!1,l=!1;const c=async()=>{if(l=!0,!i&&!s){i=!0;try{for(;l&&!s&&e.isConnected;)l=!1,await n().catch(()=>{})}finally{i=!1}}},d=async()=>{let n=2e3;if(e.supportsDirectoryWatch&&t.length<=256)try{(await e.request({action:"dirs.watch",id:a,paths:t,cwd:r},{timeoutMs:5e3})).unavailable.length||(n=3e4)}catch{}s||(c(),o=setTimeout(()=>{d()},n))},u=e.onMessage(e=>{"dirs.changed"===e.type&&e.watchId===a&&c()}),p=()=>{c()};window.addEventListener("focus",p);const h=()=>{s||(s=!0,o&&clearTimeout(o),u(),m(),window.removeEventListener("focus",p),e.supportsDirectoryWatch&&e.send({action:"dirs.watch",id:e.makeId("directory-unwatch"),paths:[]}))},m=e.onClose(h);return d(),h}(e,JSON.parse(i),r,()=>s.current())},[e,i,r,a])}(e,function(e,t,r,n){const a=[e],o=(e,t)=>{for(const s of t){const t=w(e,s.name);s.isDirectory&&r.has(t)&&(a.push(t),o(t,n[t]??[]))}};return o(e,t),a}(m,oe?c:[],re.expanded,re.children),l,te,async()=>{await Promise.all([r?.(),re.refresh()])});const[ie,le]=n.useState(!1),[ce,de]=n.useState(m),[ue,pe]=n.useState(P),[he,me]=n.useState();n.useEffect(()=>{de(m),le(!1)},[m,te]),n.useEffect(()=>me(void 0),[m,c]),n.useEffect(()=>{pe(P)},[P]);const ye=n.useRef(void 0);n.useEffect(()=>{if(!q||ye.current===q||p)return;se(!0);const e=Array.from(ae.current?.querySelectorAll('[role="treeitem"]')??[]).find(e=>e.dataset.path===q.path);if(!e)return;pe(q.path);const t=requestAnimationFrame(()=>{e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest"}),ye.current=q});return()=>cancelAnimationFrame(t)},[q,p,c,oe,se]);const fe=(e,t)=>{e.isDirectory?re.expanded.has(t)?re.collapse(t):re.expand(t):(pe(t),Z(t,l))},ge=e=>e?.focus(),xe=z(c),be=(e,r,n)=>e.map((a,o)=>{const s=w(r,a.name),i=re.expanded.has(s),l=a.isDirectory?i?M:F:function(e){return/\.(png|jpe?g|gif|webp|svg|ico)$/i.test(e)?I:/\.(tsx?|jsx?|json|css|html|py|rs|go|swift|ya?ml|sh)$/i.test(e)?O:L}(a.name);return t.jsxs("div",{role:"treeitem","aria-label":a.name,"aria-level":n+1,"aria-posinset":o+1,"aria-setsize":e.length,"aria-expanded":a.isDirectory?i:void 0,"aria-selected":ue===s,"aria-busy":re.loading.has(s)||void 0,"data-path":s,className:"explorer-tree-item",tabIndex:he===s||!he&&0===n&&0===o?0:-1,onFocus:e=>{e.target===e.currentTarget&&me(s)},onKeyDown:e=>((e,t,r)=>{if(e.stopPropagation(),ne.key(e,{path:r,directory:t.isDirectory}))return;if(e.target instanceof HTMLInputElement)return;const n=Array.from(ae.current?.querySelectorAll('[role="treeitem"]')??[]),a=n.indexOf(e.currentTarget);["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","Enter"," "].includes(e.key)&&e.preventDefault(),"ArrowUp"===e.key&&ge(n[Math.max(0,a-1)]),"ArrowDown"===e.key&&ge(n[Math.min(n.length-1,a+1)]),"Home"===e.key&&ge(n[0]),"End"===e.key&&ge(n.at(-1)),"ArrowRight"===e.key&&t.isDirectory&&(!re.expanded.has(r)||re.errors[r]?re.expand(r):ge(e.currentTarget.querySelector('[role="treeitem"]'))),"ArrowLeft"===e.key&&(t.isDirectory&&re.expanded.has(r)?re.collapse(r):ge(e.currentTarget.parentElement?.closest('[role="treeitem"]'))),"Enter"!==e.key&&" "!==e.key||fe(t,r)})(e,a,s),children:[t.jsxs("div",{className:"explorer-tree-row",draggable:!ne.busy&&ne.rename?.path!==s,"data-cut":ne.isCut(s)||void 0,"data-drop":ne.dropTarget===s||void 0,onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),ge(e.currentTarget.parentElement),ne.openMenu({path:s,directory:a.isDirectory},e.clientX,e.clientY)},onDragStart:e=>ne.dragStart(e,{path:s,directory:a.isDirectory}),onDragEnd:ne.dragEnd,onDragOver:e=>a.isDirectory&&ne.dragOver(e,s),onDragLeave:ne.dragLeave,onDrop:e=>a.isDirectory&&ne.drop(e,s),style:{paddingLeft:8+14*n},title:s,onClick:e=>{ge(e.currentTarget.parentElement),fe(a,s)},children:[t.jsx("span",{className:"explorer-chevron","aria-hidden":"true",children:a.isDirectory&&(re.loading.has(s)?t.jsx(C,{className:"explorer-spinner"}):i?t.jsx(_,{}):t.jsx(S,{}))}),t.jsx(l,{className:a.isDirectory?"explorer-folder-icon":"explorer-file-icon","aria-hidden":"true"}),t.jsx("span",{className:"explorer-entry-name",children:ne.rename?.path===s?t.jsx("input",{className:"explorer-rename","aria-label":ne.strings.name,autoFocus:!0,value:ne.name,disabled:ne.busy,onFocus:e=>e.target.select(),onClick:e=>e.stopPropagation(),onChange:e=>ne.setName(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.nativeEvent.isComposing||229===e.keyCode||("Enter"===e.key&&(e.preventDefault(),ne.commitRename()),"Escape"===e.key&&(e.preventDefault(),ne.setRename(null)))}}):a.name})]}),a.isDirectory&&i&&t.jsxs("div",{role:"group",className:"explorer-tree-group",style:{"--tree-guide-left":14+14*n+"px"},children:[re.children[s]?be(re.children[s],s,n+1):null,re.errors[s]&&t.jsx("button",{className:"explorer-retry",type:"button",onClick:()=>{re.expand(s)},children:K.retry}),0===re.children[s]?.length&&t.jsx("p",{className:"explorer-empty",style:{paddingLeft:36+14*n},children:K.noFilesInDirectory})]})]},s)});return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"explorer-heading",children:[t.jsx("h2",{children:K.fileTree}),t.jsxs("div",{className:"explorer-actions",children:[t.jsx("button",{className:"icon-button",title:ne.strings.backDirectory,"aria-label":ne.strings.backDirectory,disabled:!a||p,onClick:o,type:"button",children:t.jsx(T,{"aria-hidden":"true"})}),t.jsx("button",{className:"icon-button",title:ne.strings.editPath,"aria-label":ne.strings.editPath,"aria-expanded":ie,onClick:()=>{de("."===m?l:m),le(e=>!e)},type:"button",children:t.jsx(h,{"aria-hidden":"true"})}),t.jsx("button",{className:"icon-button",title:K.newFolder,"aria-label":K.newFolder,onClick:Q,type:"button",children:t.jsx(R,{"aria-hidden":"true"})}),t.jsx("button",{className:"icon-button",title:K.refreshFiles,"aria-label":K.refreshFiles,disabled:p,onClick:()=>{B(m),re.refresh()},type:"button",children:p?t.jsx(C,{className:"explorer-spinner","aria-hidden":"true"}):t.jsx(N,{"aria-hidden":"true"})}),t.jsx("button",{className:"icon-button",title:K.parentFolder,"aria-label":K.parentFolder,disabled:!j(m),onClick:()=>B(j(m)??m),type:"button",children:t.jsx(A,{"aria-hidden":"true"})})]})]}),t.jsxs("button",{type:"button",className:"explorer-root-path",onContextMenu:e=>{e.preventDefault(),ne.openMenu({path:m,directory:!0},e.clientX,e.clientY)},onDragOver:e=>ne.dragOver(e,m),onDragLeave:ne.dragLeave,onDrop:e=>ne.drop(e,m),"data-drop":ne.dropTarget===m||void 0,title:"."===m?l:m,"aria-expanded":oe,onClick:()=>{se(e=>!e),le(!1)},children:[oe?t.jsx(_,{"aria-hidden":"true"}):t.jsx(S,{"aria-hidden":"true"}),oe?t.jsx(M,{"aria-hidden":"true"}):t.jsx(F,{"aria-hidden":"true"}),t.jsx("span",{children:v("."===m?l:m)||m})]}),ie&&t.jsx("form",{className:"explorer-path-form",onSubmit:e=>{e.preventDefault(),ce.trim()&&(B(ce.trim()),le(!1))},children:t.jsx("input",{autoFocus:!0,"aria-label":K.path,value:ce,onChange:e=>de(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||229===e.keyCode?"Enter"===e.key&&e.preventDefault():"Escape"===e.key&&le(!1)}})}),d&&t.jsx("p",{className:"empty-copy",role:"alert",children:d}),p&&t.jsx("p",{className:"explorer-empty",role:"status",children:K.loadingFiles}),oe&&t.jsx("div",{ref:ae,role:"tree","aria-label":K.fileTree,className:"explorer-tree","aria-busy":p||ne.busy,"data-drop":ne.dropTarget===m||void 0,onContextMenu:e=>{e.preventDefault(),ne.openMenu({path:m,directory:!0},e.clientX,e.clientY)},onDragOver:e=>ne.dragOver(e,m),onDragLeave:ne.dragLeave,onDrop:e=>ne.drop(e,m),children:be(xe,m,0)}),t.jsx(U,{ops:ne,root:m,onOpen:()=>ne.menu&&Z(ne.menu.path,l)}),oe&&u&&!p&&!d&&0===c.length&&t.jsx("p",{className:"explorer-empty",children:K.noFilesInDirectory})]})}function Z({client:e,watch:r=!0,onRefreshDirectory:n,canGoBackDirectory:a,onGoBackDirectory:o,busy:s,onLoadChildren:i,cwd:l,directory:c,newDirName:u,remoteFile:p,t:h,onCreateDirectory:m,onListDirectory:g,onNewDirNameChange:x,onOpenRemoteFile:b}){const v=d(),w=y(),[j,k]=f(w?.scopeKey??"default",!1);return t.jsx(t.Fragment,{children:t.jsxs("section",{className:"control-section files-explorer",children:[t.jsx(Q,{client:r?e:null,onRefreshDirectory:n,canGoBackDirectory:a,onGoBackDirectory:o,cwd:l,revealRequest:v?.request,selectedPath:p?.path,onLoadChildren:i,onNewFolder:()=>k(e=>!e),entries:c.entries,error:c.error,loaded:c.loaded,loading:c.loading,path:c.path,t:h,onListDirectory:g,onOpenRemoteFile:b}),j&&t.jsxs("div",{className:"field-row file-tree-create",children:[t.jsx("input",{value:u,onChange:e=>x(e.target.value),placeholder:h.newFolder,"aria-label":h.newFolder,autoFocus:!0,onKeyDown:e=>{"Escape"===e.key&&(k(!1),x("")),"Enter"===e.key&&u.trim()&&!s&&m()}}),t.jsxs("button",{className:"icon-text-button",onClick:m,type:"button",disabled:s||!u.trim(),children:[t.jsx(F,{"aria-hidden":"true"}),h.create]})]})]})})}export{Z as FilesControlPanel};
@@ -1 +1 @@
1
- import{j as e,r as s,u as n,f as i,t}from"./index-CTpWXHK5.js";/* empty css */import{d as l,X as a,C as d}from"./App-DHM2JpIe.js";import{S as o}from"./shield-check-BHYK9iHQ.js";import{K as r}from"./key-round-CBNFW_Qp.js";function c({activeApproval:s,activeQuestion:n,busy:i,questionAnswers:t,t:c,onCancelQuestion:u,onQuestionChoice:p,onRespondApproval:h,onRespondQuestion:j}){const x=Boolean(s||n);return e.jsxs(e.Fragment,{children:[x?null:e.jsxs("section",{className:"control-section",children:[e.jsx("h2",{children:c.pendingActions}),e.jsx("p",{className:"empty-copy",children:c.noPendingActions})]}),s?e.jsxs("section",{className:"attention-panel",children:[e.jsxs("div",{className:"attention-head",children:[e.jsx(o,{"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("h2",{children:c.approvalRequired}),e.jsx("p",{children:s.toolName})]})]}),e.jsx("p",{children:s.description}),"string"==typeof s.input?.command&&e.jsx("pre",{children:s.input.command}),e.jsxs("details",{className:"interaction-details",children:[e.jsx("summary",{children:c.interactionDetails}),e.jsx("pre",{children:l(s.input)})]},s.requestId),e.jsxs("div",{className:"attention-actions approval-actions",children:[e.jsxs("button",{type:"button",className:"danger-button",onClick:()=>h(!1),disabled:i,children:[e.jsx(a,{"aria-hidden":"true"}),c.deny]}),e.jsxs("button",{type:"button",className:"approve-button",onClick:()=>h(!0),disabled:i,children:[e.jsx(d,{"aria-hidden":"true"}),c.approve]})]})]}):null,n?e.jsxs("section",{className:"attention-panel",children:[e.jsxs("div",{className:"attention-head",children:[e.jsx(r,{"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("h2",{children:c.inputNeeded}),e.jsx("p",{children:c.notificationQuestionCount(n.questions.length)})]})]}),n.questions.map(s=>e.jsxs("div",{className:"question-block",children:[e.jsx("strong",{children:s.question}),e.jsx("div",{className:"choice-list",children:s.options.map(n=>{const i=(t[s.id]??[]).includes(n.label);return e.jsxs("button",{className:i?"selected":"","aria-pressed":i,onClick:()=>p(s.id,n.label,s.multiSelect),type:"button",children:[e.jsx("span",{children:n.label}),n.description?e.jsx("small",{children:n.description}):null]},n.label)})})]},s.id)),e.jsxs("div",{className:"attention-actions",children:[e.jsxs("button",{type:"button",className:"danger-button",onClick:u,disabled:i,children:[e.jsx(a,{"aria-hidden":"true"}),c.cancel]}),e.jsxs("button",{type:"button",className:"approve-button",onClick:j,disabled:i||n.questions.some(e=>!t[e.id]?.length),children:[e.jsx(d,{"aria-hidden":"true"}),c.submit]})]})]}):null]})}function u(l){const{activeApproval:d,activeQuestion:o,pendingCount:r,requestKey:u,sessions:p,t:h,errorText:j}=l,[x,m]=s.useState(null),[b,g]=s.useState(!1),v=b||r>0&&x!==u,N=()=>{m(u),g(!1)};s.useEffect(()=>{r>0&&g(!1);const e=()=>{m(null),g(0===r)};return window.addEventListener("vibelet.pending.open",e),()=>window.removeEventListener("vibelet.pending.open",e)},[r]);const y=n(N,void 0,v),q=s=>{const n=p.find(e=>e.sessionId===s);return e.jsxs("dl",{className:"global-pending-session-context",children:[e.jsxs("div",{children:[e.jsx("dt",{children:h.session}),e.jsx("dd",{className:"global-pending-session",children:n?t(n):s})]}),e.jsxs("div",{children:[e.jsx("dt",{children:h.workingDirectory}),e.jsx("dd",{className:"global-pending-directory",children:n?.cwd||h.unknown})]})]})};return v?i.createPortal(e.jsxs("div",{className:"global-pending-layer",children:[e.jsx("div",{className:"global-pending-backdrop","aria-hidden":"true",onClick:N}),e.jsxs("div",{className:"global-pending-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"global-pending-title",tabIndex:-1,ref:y,children:[e.jsxs("header",{className:"global-pending-header",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"global-pending-title",children:h.pendingActions}),e.jsx("p",{"aria-live":"polite",children:h.pendingActionCount(r)})]}),e.jsxs("div",{className:"global-pending-header-actions",children:[e.jsx("button",{className:"global-pending-clear",type:"button",disabled:0===r,onClick:l.onClearRequests,children:h.clearPendingRequests}),e.jsx("button",{className:"icon-button",type:"button","aria-label":h.close,title:h.close,onClick:N,children:e.jsx(a,{"aria-hidden":"true"})})]})]}),e.jsxs("div",{className:"global-pending-content",children:[0===r&&e.jsx("p",{className:"empty-copy",children:h.noPendingActions}),d&&e.jsxs("section",{"data-pending-session":d.sessionId,children:[e.jsxs("div",{className:"global-pending-session-row",children:[q(d.sessionId),e.jsx("button",{type:"button","aria-label":h.dismissPendingRequest,title:h.dismissPendingRequest,onClick:()=>l.onDismissRequest("approval",d.sessionId,d.requestId),children:e.jsx(a,{"aria-hidden":"true"})})]}),e.jsx(c,{...l,activeQuestion:null})]}),o&&e.jsxs("section",{"data-pending-session":o.sessionId,children:[e.jsxs("div",{className:"global-pending-session-row",children:[q(o.sessionId),e.jsx("button",{type:"button","aria-label":h.dismissPendingRequest,title:h.dismissPendingRequest,onClick:()=>l.onDismissRequest("question",o.sessionId,o.requestId),children:e.jsx(a,{"aria-hidden":"true"})})]}),e.jsx(c,{...l,activeApproval:null})]}),j&&e.jsx("p",{role:"alert",className:"global-pending-error",children:j})]})]})]}),document.body):null}export{u as default};
1
+ import{j as e,r as s,u as n,f as i,t}from"./index-C6NKSiG-.js";/* empty css */import{d as l,X as a,C as d}from"./App-D4fBMWn7.js";import{S as o}from"./shield-check-B5zclKcP.js";import{K as r}from"./key-round-DZyIHeFg.js";function c({activeApproval:s,activeQuestion:n,busy:i,questionAnswers:t,t:c,onCancelQuestion:u,onQuestionChoice:p,onRespondApproval:h,onRespondQuestion:j}){const x=Boolean(s||n);return e.jsxs(e.Fragment,{children:[x?null:e.jsxs("section",{className:"control-section",children:[e.jsx("h2",{children:c.pendingActions}),e.jsx("p",{className:"empty-copy",children:c.noPendingActions})]}),s?e.jsxs("section",{className:"attention-panel",children:[e.jsxs("div",{className:"attention-head",children:[e.jsx(o,{"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("h2",{children:c.approvalRequired}),e.jsx("p",{children:s.toolName})]})]}),e.jsx("p",{children:s.description}),"string"==typeof s.input?.command&&e.jsx("pre",{children:s.input.command}),e.jsxs("details",{className:"interaction-details",children:[e.jsx("summary",{children:c.interactionDetails}),e.jsx("pre",{children:l(s.input)})]},s.requestId),e.jsxs("div",{className:"attention-actions approval-actions",children:[e.jsxs("button",{type:"button",className:"danger-button",onClick:()=>h(!1),disabled:i,children:[e.jsx(a,{"aria-hidden":"true"}),c.deny]}),e.jsxs("button",{type:"button",className:"approve-button",onClick:()=>h(!0),disabled:i,children:[e.jsx(d,{"aria-hidden":"true"}),c.approve]})]})]}):null,n?e.jsxs("section",{className:"attention-panel",children:[e.jsxs("div",{className:"attention-head",children:[e.jsx(r,{"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("h2",{children:c.inputNeeded}),e.jsx("p",{children:c.notificationQuestionCount(n.questions.length)})]})]}),n.questions.map(s=>e.jsxs("div",{className:"question-block",children:[e.jsx("strong",{children:s.question}),e.jsx("div",{className:"choice-list",children:s.options.map(n=>{const i=(t[s.id]??[]).includes(n.label);return e.jsxs("button",{className:i?"selected":"","aria-pressed":i,onClick:()=>p(s.id,n.label,s.multiSelect),type:"button",children:[e.jsx("span",{children:n.label}),n.description?e.jsx("small",{children:n.description}):null]},n.label)})})]},s.id)),e.jsxs("div",{className:"attention-actions",children:[e.jsxs("button",{type:"button",className:"danger-button",onClick:u,disabled:i,children:[e.jsx(a,{"aria-hidden":"true"}),c.cancel]}),e.jsxs("button",{type:"button",className:"approve-button",onClick:j,disabled:i||n.questions.some(e=>!t[e.id]?.length),children:[e.jsx(d,{"aria-hidden":"true"}),c.submit]})]})]}):null]})}function u(l){const{activeApproval:d,activeQuestion:o,pendingCount:r,requestKey:u,sessions:p,t:h,errorText:j}=l,[x,m]=s.useState(null),[b,g]=s.useState(!1),v=b||r>0&&x!==u,N=()=>{m(u),g(!1)};s.useEffect(()=>{r>0&&g(!1);const e=()=>{m(null),g(0===r)};return window.addEventListener("vibelet.pending.open",e),()=>window.removeEventListener("vibelet.pending.open",e)},[r]);const y=n(N,void 0,v),q=s=>{const n=p.find(e=>e.sessionId===s);return e.jsxs("dl",{className:"global-pending-session-context",children:[e.jsxs("div",{children:[e.jsx("dt",{children:h.session}),e.jsx("dd",{className:"global-pending-session",children:n?t(n):s})]}),e.jsxs("div",{children:[e.jsx("dt",{children:h.workingDirectory}),e.jsx("dd",{className:"global-pending-directory",children:n?.cwd||h.unknown})]})]})};return v?i.createPortal(e.jsxs("div",{className:"global-pending-layer",children:[e.jsx("div",{className:"global-pending-backdrop","aria-hidden":"true",onClick:N}),e.jsxs("div",{className:"global-pending-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"global-pending-title",tabIndex:-1,ref:y,children:[e.jsxs("header",{className:"global-pending-header",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"global-pending-title",children:h.pendingActions}),e.jsx("p",{"aria-live":"polite",children:h.pendingActionCount(r)})]}),e.jsxs("div",{className:"global-pending-header-actions",children:[e.jsx("button",{className:"global-pending-clear",type:"button",disabled:0===r,onClick:l.onClearRequests,children:h.clearPendingRequests}),e.jsx("button",{className:"icon-button",type:"button","aria-label":h.close,title:h.close,onClick:N,children:e.jsx(a,{"aria-hidden":"true"})})]})]}),e.jsxs("div",{className:"global-pending-content",children:[0===r&&e.jsx("p",{className:"empty-copy",children:h.noPendingActions}),d&&e.jsxs("section",{"data-pending-session":d.sessionId,children:[e.jsxs("div",{className:"global-pending-session-row",children:[q(d.sessionId),e.jsx("button",{type:"button","aria-label":h.dismissPendingRequest,title:h.dismissPendingRequest,onClick:()=>l.onDismissRequest("approval",d.sessionId,d.requestId),children:e.jsx(a,{"aria-hidden":"true"})})]}),e.jsx(c,{...l,activeQuestion:null})]}),o&&e.jsxs("section",{"data-pending-session":o.sessionId,children:[e.jsxs("div",{className:"global-pending-session-row",children:[q(o.sessionId),e.jsx("button",{type:"button","aria-label":h.dismissPendingRequest,title:h.dismissPendingRequest,onClick:()=>l.onDismissRequest("question",o.sessionId,o.requestId),children:e.jsx(a,{"aria-hidden":"true"})})]}),e.jsx(c,{...l,activeApproval:null})]}),j&&e.jsx("p",{role:"alert",className:"global-pending-error",children:j})]})]})]}),document.body):null}export{u as default};
@@ -1 +1 @@
1
- import{c as e,r as a,b as s,d as r,u as t,f as i,j as o}from"./index-CTpWXHK5.js";import{i as l,w as n}from"./imageViewerCopy-BBW9Oggj.js";import{f as c,Z as d,L as m,a as p,X as g}from"./App-DHM2JpIe.js";import{u,b as f,I as h}from"./useMessageImage-CkBgO2_p.js";import{A as j}from"./arrow-right-B0Zthy7B.js";import{A as x}from"./arrow-left-B_J8dbJk.js";const w=e("file-image",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);function v({request:e,onClose:v}){const[y,b]=a.useState(e.index),[k,N]=a.useState("idle"),A=e.images[y],{url:M,error:C,fail:E}=u(A.src,A.cwd,null),I=f(A.src),L=A.alt||c(I??A.src),z=s(r().language),B=l(z),D=t(v);a.useEffect(()=>{const e=document.getElementById("vibelet-workspace"),a=e?.inert;return e&&(e.inert=!0),()=>{e&&(e.inert=Boolean(a))}},[]),a.useEffect(()=>N("idle"),[y]);const P=a=>b(s=>Math.max(0,Math.min(e.images.length-1,s+a))),R=(e,a,s,r=!1)=>o.jsx("button",{type:"button",className:"icon-button",title:e,"aria-label":e,onClick:s,disabled:r,children:a});return i.createPortal(o.jsx("div",{className:"image-viewer-backdrop",onClick:e=>{e.target===e.currentTarget&&v()},children:o.jsxs("div",{ref:D,className:"image-viewer",role:"dialog","aria-modal":"true","aria-label":B.title,tabIndex:-1,onKeyDown:e=>{"ArrowLeft"!==e.key&&"ArrowRight"!==e.key||(e.preventDefault(),e.stopPropagation(),P("ArrowLeft"===e.key?-1:1))},children:[o.jsxs("header",{className:"image-viewer-toolbar",children:[o.jsx("span",{className:"image-viewer-caption",title:L,children:L}),o.jsxs("span",{className:"image-viewer-count","aria-live":"polite",children:[y+1," / ",e.images.length]}),R(B.copy,o.jsx(p,{}),()=>{(async()=>{if(M)try{await n(M),N("copied")}catch{N("failed")}})()},!M||C),R(B.open,o.jsx(w,{}),()=>{v(),e.onOpen(I??A.src,A.cwd)}),R(B.close,o.jsx(g,{}),v)]}),o.jsxs("div",{className:"image-viewer-stage",children:[R(B.previous,o.jsx(x,{}),()=>P(-1),0===y),o.jsx("div",{className:"image-viewer-content",children:C?o.jsxs("p",{role:"status",children:[o.jsx(h,{}),B.unavailable]}):M?o.jsx(d,{src:M,alt:L,onError:E,keyboardRoot:D},`${y}:${A.src}`):o.jsx(m,{className:"session-running-icon","aria-label":B.title})}),R(B.next,o.jsx(j,{}),()=>P(1),y===e.images.length-1)]}),o.jsx("div",{className:"image-viewer-status",role:"status",children:"copied"===k?B.copied:"failed"===k?B.failed:""})]})}),document.body)}export{v as default};
1
+ import{c as e,r as a,b as s,d as r,u as t,f as i,j as o}from"./index-C6NKSiG-.js";import{i as l,w as n}from"./imageViewerCopy-CZ0PxllY.js";import{f as c,Z as d,L as m,a as p,X as g}from"./App-D4fBMWn7.js";import{u,b as f,I as h}from"./useMessageImage-Bxcjzr5o.js";import{A as j}from"./arrow-right-BQXADod1.js";import{A as x}from"./arrow-left-CTbegMaU.js";const w=e("file-image",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);function v({request:e,onClose:v}){const[y,b]=a.useState(e.index),[k,N]=a.useState("idle"),A=e.images[y],{url:M,error:C,fail:E}=u(A.src,A.cwd,null),I=f(A.src),L=A.alt||c(I??A.src),z=s(r().language),B=l(z),D=t(v);a.useEffect(()=>{const e=document.getElementById("vibelet-workspace"),a=e?.inert;return e&&(e.inert=!0),()=>{e&&(e.inert=Boolean(a))}},[]),a.useEffect(()=>N("idle"),[y]);const P=a=>b(s=>Math.max(0,Math.min(e.images.length-1,s+a))),R=(e,a,s,r=!1)=>o.jsx("button",{type:"button",className:"icon-button",title:e,"aria-label":e,onClick:s,disabled:r,children:a});return i.createPortal(o.jsx("div",{className:"image-viewer-backdrop",onClick:e=>{e.target===e.currentTarget&&v()},children:o.jsxs("div",{ref:D,className:"image-viewer",role:"dialog","aria-modal":"true","aria-label":B.title,tabIndex:-1,onKeyDown:e=>{"ArrowLeft"!==e.key&&"ArrowRight"!==e.key||(e.preventDefault(),e.stopPropagation(),P("ArrowLeft"===e.key?-1:1))},children:[o.jsxs("header",{className:"image-viewer-toolbar",children:[o.jsx("span",{className:"image-viewer-caption",title:L,children:L}),o.jsxs("span",{className:"image-viewer-count","aria-live":"polite",children:[y+1," / ",e.images.length]}),R(B.copy,o.jsx(p,{}),()=>{(async()=>{if(M)try{await n(M),N("copied")}catch{N("failed")}})()},!M||C),R(B.open,o.jsx(w,{}),()=>{v(),e.onOpen(I??A.src,A.cwd)}),R(B.close,o.jsx(g,{}),v)]}),o.jsxs("div",{className:"image-viewer-stage",children:[R(B.previous,o.jsx(x,{}),()=>P(-1),0===y),o.jsx("div",{className:"image-viewer-content",children:C?o.jsxs("p",{role:"status",children:[o.jsx(h,{}),B.unavailable]}):M?o.jsx(d,{src:M,alt:L,onError:E,keyboardRoot:D},`${y}:${A.src}`):o.jsx(m,{className:"session-running-icon","aria-label":B.title})}),R(B.next,o.jsx(j,{}),()=>P(1),y===e.images.length-1)]}),o.jsx("div",{className:"image-viewer-status",role:"status",children:"copied"===k?B.copied:"failed"===k?B.failed:""})]})}),document.body)}export{v as default};
@@ -1 +1 @@
1
- import{j as e}from"./index-CTpWXHK5.js";import{C as a}from"./ChipGroup-DAB6dZFc.js";import{F as l}from"./App-DHM2JpIe.js";function s({language:s,t:n,onLanguageChange:i,showFeedback:o=!0}){return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"control-section compact-section",children:[e.jsx("h2",{children:n.language}),e.jsxs("label",{className:"field",children:[e.jsx("span",{children:n.displayLanguage}),e.jsx(a,{ariaLabel:n.displayLanguage,options:[{value:"system",label:n.followSystem},{value:"en",label:n.english},{value:"zh",label:n.chinese},{value:"zh-TW",label:n.traditionalChinese}],value:s,onChange:e=>i(e)})]})]}),o&&e.jsx(l,{language:s})]})}export{s as LanguageSettingsPanel};
1
+ import{j as e}from"./index-C6NKSiG-.js";import{C as a}from"./ChipGroup-C16Et4Xc.js";import{F as l}from"./App-D4fBMWn7.js";function s({language:s,t:n,onLanguageChange:i,showFeedback:o=!0}){return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"control-section compact-section",children:[e.jsx("h2",{children:n.language}),e.jsxs("label",{className:"field",children:[e.jsx("span",{children:n.displayLanguage}),e.jsx(a,{ariaLabel:n.displayLanguage,options:[{value:"system",label:n.followSystem},{value:"en",label:n.english},{value:"zh",label:n.chinese},{value:"zh-TW",label:n.traditionalChinese}],value:s,onChange:e=>i(e)})]})]}),o&&e.jsx(l,{language:s})]})}export{s as LanguageSettingsPanel};
@@ -0,0 +1 @@
1
+ import{r as e,j as r}from"./index-C6NKSiG-.js";import{E as s}from"./App-D4fBMWn7.js";function a({text:a,labels:i={read:"浏览",live:"编辑",edit:"可视化编辑",source:"源码"},loadingText:d="Loading…",readOnly:l,modes:o=["read","live","edit","source"],initialMode:t="read",renderVisual:n,renderCode:c}){const[u,m]=e.useState(t),[x,j]=e.useState("source"===t||"live"===t),p="source"===u||"live"===u;return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"segmented editor-mode-tabs",role:"group","aria-label":"Markdown 模式",children:o.filter(e=>!l||"read"===e||"source"===e).map(e=>r.jsx("button",{type:"button","aria-pressed":u===e,className:u===e?"selected":"",onClick:()=>{m(e),"source"!==e&&"live"!==e||j(!0)},children:i[e]},e))}),r.jsx("div",{className:"file-editor-surface",hidden:p,children:r.jsx(e.Suspense,{fallback:r.jsx(s,{label:d}),children:n("read"===u||Boolean(l))})}),x&&r.jsx("div",{className:"file-editor-surface",hidden:!p,children:r.jsx(e.Suspense,{fallback:r.jsx("pre",{className:"remote-editor",children:a}),children:c("live"===u)})})]})}export{a as MarkdownModePanel};
@@ -1 +1 @@
1
- import{k as a,b as s,d as e,j as r}from"./index-CTpWXHK5.js";import{f as i,L as n,o as l}from"./App-DHM2JpIe.js";import{b as t,u as o,I as c}from"./useMessageImage-CkBgO2_p.js";function d({src:d,alt:m,cwd:p,onOpen:g,gallery:u}){const x=t(d),{url:j,error:f,fail:h}=o(d,p),w=a[s(e().language)],b=m||i(x??d);return r.jsx("button",{className:"message-image-preview","data-image-src":d,"data-image-cwd":p,type:"button",title:x??d,"aria-label":`${w.preview}: ${b}`,onClick:async a=>{a.preventDefault(),a.stopPropagation();const s=await(u?.())??[{src:d,alt:b,cwd:p}],e=s.findIndex(a=>a.src===d||x&&t(a.src)===x);l({images:e<0?[{src:d,alt:b,cwd:p}]:s,index:Math.max(0,e),onOpen:g})},children:f?r.jsxs("span",{className:"message-image-placeholder",children:[r.jsx(c,{"aria-hidden":"true"}),b," · ",w.fileOpenFailed]}):j?r.jsx("img",{src:j,alt:b,loading:"lazy",onError:h}):r.jsxs("span",{className:"message-image-placeholder",children:[r.jsx(n,{className:"session-running-icon","aria-hidden":"true"}),b]})})}export{d as M};
1
+ import{k as a,b as s,d as e,j as r}from"./index-C6NKSiG-.js";import{f as i,L as n,o as l}from"./App-D4fBMWn7.js";import{b as t,u as o,I as c}from"./useMessageImage-Bxcjzr5o.js";function d({src:d,alt:m,cwd:p,onOpen:g,gallery:u}){const x=t(d),{url:j,error:f,fail:h}=o(d,p),w=a[s(e().language)],b=m||i(x??d);return r.jsx("button",{className:"message-image-preview","data-image-src":d,"data-image-cwd":p,type:"button",title:x??d,"aria-label":`${w.preview}: ${b}`,onClick:async a=>{a.preventDefault(),a.stopPropagation();const s=await(u?.())??[{src:d,alt:b,cwd:p}],e=s.findIndex(a=>a.src===d||x&&t(a.src)===x);l({images:e<0?[{src:d,alt:b,cwd:p}]:s,index:Math.max(0,e),onOpen:g})},children:f?r.jsxs("span",{className:"message-image-placeholder",children:[r.jsx(c,{"aria-hidden":"true"}),b," · ",w.fileOpenFailed]}):j?r.jsx("img",{src:j,alt:b,loading:"lazy",onError:h}):r.jsxs("span",{className:"message-image-placeholder",children:[r.jsx(n,{className:"session-running-icon","aria-hidden":"true"}),b]})})}export{d as M};
@@ -1 +1 @@
1
- import{c as e,r as t,i as s,h as n,j as a,u as o,f as r}from"./index-CTpWXHK5.js";import{s as i,u as l,C as c,a as d,b as u,c as p,d as f,e as m,f as h,g as w,G as g,h as v,S as y,i as b}from"./useComposerCompletion-f1any5m7.js";import{x,y as j,z as k,X as S}from"./App-DHM2JpIe.js";import{C}from"./ComposerMenus-D7iN4bup.js";import{S as M}from"./shield-check-BHYK9iHQ.js";import{C as D,Z as N}from"./zap-DsMffYum.js";import{F as E}from"./folder-plus-Dv3mIoot.js";import{A as I}from"./__vite-browser-external-2447137e-Ck9f6uYD.js";import"./useMessageImage-CkBgO2_p.js";import"./MessageImage-L_caj_Dp.js";import"./chevron-up-BvhbPeN2.js";const T=e("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]),K=e("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),A=e("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),L="vibelet.web.recentCreations";function R(e){try{const t=JSON.parse(s().getItem(L)||"{}")[e];return Array.isArray(t)?t.filter(e=>"string"==typeof e.cwd&&["claude","codex"].includes(e.agent)&&Number.isFinite(e.createdAt)).slice(0,8):[]}catch{return[]}}const F="vibelet.web.initialMessageHistory";function O(){try{const e=JSON.parse(s().getItem(F)||"[]");return Array.isArray(e)?[...new Set(e.filter(e=>"string"==typeof e).map(e=>e.trim()).filter(Boolean))].slice(0,20):[]}catch{return[]}}const B="vibelet.web.newSessionCreateShortcut";function q({cwd:e,connected:s,load:n,t:o}){const[r,i]=t.useState();t.useEffect(()=>{if(!e||!s)return;let t=!1,a=!1;const o=()=>{a||"hidden"===document.visibilityState||(a=!0,n(e).then(s=>{t||i({cwd:e,data:s})}).catch(s=>{t||i({cwd:e,error:s instanceof Error?s.message:String(s)})}).finally(()=>{a=!1}))},r=window.setTimeout(o,250),l=window.setInterval(o,5e3);return window.addEventListener("focus",o),()=>{t=!0,window.clearTimeout(r),window.clearInterval(l),window.removeEventListener("focus",o)}},[e,s,n]);const l=s&&r?.cwd===e?r.data:void 0,c=l?.branches[e],d=l?.diffStats[e];return a.jsx("div",{className:"new-session-git",role:"status",title:r?.cwd===e?r.error:void 0,children:c||d?a.jsxs(a.Fragment,{children:[a.jsx(K,{size:14,"aria-hidden":"true"}),a.jsx("span",{className:"new-session-git-branch",title:c||"HEAD",children:c||"HEAD"}),d&&(d.additions>0||d.deletions>0)&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"diff-add",children:["+",d.additions]}),a.jsxs("span",{className:"diff-del",children:["−",d.deletions]})]})]}):s&&e&&r?.cwd!==e?o.loading:" "})}function z({recent:e,chinese:t,onSelectRecent:s}){return a.jsxs("div",{className:"new-session-history",children:[" ",a.jsx(C,{icon:x,label:t?"最近创建":"Recent creations",menuLabel:t?"最近创建":"Recent creations",align:"right",value:"",options:e.length?e.map((e,t)=>({value:String(t),label:e.cwd,description:"claude"===e.agent?"Claude":"Codex"})):[{value:"",label:t?"暂无创建记录":"No recent creations",disabled:!0}],onSelect:t=>{const n=e[Number(t)];n&&s(n)}})]})}function P({chinese:e,onSelectMessage:s}){const[n]=t.useState(O);return a.jsxs("div",{className:"new-session-history",children:[" ",a.jsx(C,{icon:A,label:e?"消息历史":"Message history",menuLabel:e?"消息历史":"Message history",align:"right",value:"",options:n.length?n.map((e,t)=>({value:String(t),label:e})):[{value:"",label:e?"暂无消息历史":"No message history",disabled:!0}],onSelect:e=>{const t=n[Number(e)];t&&s(t)}})]})}function J({client:e,cwd:s="",agent:n="codex",controls:o,submit:r,draft:i,textareaRef:f,onOpen:m,onChange:h,onKeyDown:w,connected:g,chinese:v,files:y,t:b}){const x=t.useRef(null),j=t.useRef(null),[k,S]=t.useState([]),[C,M]=t.useState(""),[D,N]=t.useState(0);t.useEffect(()=>{let t=!1;if(S([]),M(""),!e||!g)return;const n=setTimeout(()=>{e.request({action:"skills.list",id:e.makeId("skills"),cwd:s.trim()||void 0}).then(e=>{t||S(e.skills??[])}).catch(e=>{t||M(b.resourceLoadFailed(b.skills,e instanceof Error?e.message:String(e)))})},200);return()=>{t=!0,clearTimeout(n)}},[e,g,s,D,b]);const E=l({draft:i,onChange:h,textareaRef:f??j,agent:n,skills:k,onRefreshSkills:()=>N(e=>e+1),t:b});return a.jsxs("div",{className:"new-session-message","aria-busy":y.uploadBusy,onDragOver:e=>{e.dataTransfer.types.includes("Files")&&e.preventDefault()},onDrop:e=>{e.dataTransfer.files.length&&(e.preventDefault(),g&&y.upload(e.dataTransfer.files))},children:[a.jsxs("div",{className:"new-session-field-heading",children:[a.jsx("label",{htmlFor:"new-session-initial-message",children:v?"初始消息(可选)":"Initial message (optional)"}),a.jsx(P,{chinese:v,onSelectMessage:h})]}),a.jsxs("div",{className:"new-session-message-box",children:[E.popovers,a.jsx(c,{id:"new-session-initial-message",textareaRef:f??j,value:i,onValueChange:h,...E.textareaProps,onKeyDown:e=>{E.handleKeyDown(e)||w(e)},rows:3,onPaste:e=>{g&&e.clipboardData.files.length&&(e.preventDefault(),y.upload(e.clipboardData.files))}}),a.jsx("input",{ref:x,type:"file",hidden:!0,multiple:!0,onChange:e=>{y.upload(e.currentTarget.files),e.currentTarget.value=""}}),a.jsx(d,{onOpen:m,attachments:y.attachments,uploadBusy:y.uploadBusy,onRemove:y.remove,t:b}),a.jsx(u,{leading:a.jsx(p,{t:b,toolsDisabled:!g||y.uploadBusy,onUpload:()=>x.current?.click(),onSkills:E.handleOpenSkills,onCommands:E.handleOpenCommands}),controls:o,submit:r})]}),y.uploadBusy&&a.jsx("small",{role:"status",children:b.uploading}),C&&a.jsx("p",{role:"alert",children:C}),y.error&&a.jsx("p",{role:"alert",children:y.error})]})}function H(e){const{t}=e,s="desktop"===n().kind,o=f(t),r=m(t),i=h(e.models,t),l=i.find(t=>t.value===e.model)?.label??(e.model||t.defaultOption);return a.jsxs("div",{className:"new-session-options composer-control-strip "+(s?"new-session-desktop-options":""),children:[a.jsx("div",{className:"composer-permission "+("autoApprove"===e.approvalMode?"full-access":""),children:a.jsx(C,{icon:M,label:o.find(t=>t.value===e.approvalMode)?.label??t.approvalMode,menuLabel:t.approvalMode,value:e.approvalMode,onSelect:e.onApprovalModeChange,options:o,wide:!0,blendBackground:!0})}),s?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"composer-toolbar-spacer"}),a.jsx(w,{...e,modelLabel:l,modelOptions:i,effortLabel:r.find(t=>t.value===e.effort)?.label??t.effort,effortOptions:r})]}):a.jsxs(a.Fragment,{children:[a.jsx(C,{icon:D,label:l,menuLabel:t.model,value:e.model,onSelect:e.onModelChange,options:i}),a.jsx(C,{icon:N,label:e.fastMode?t.fast:t.normal,menuLabel:t.fastMode,value:e.fastMode?"on":"off",onSelect:t=>e.onFastModeChange("on"===t),selected:e.fastMode,options:[{value:"off",label:t.normal,description:t.standardExecution,icon:g},{value:"on",label:t.fast,description:t.preferFasterResponses,icon:N}]})]})]})}function U(e){const{t:l,device:c,onClose:d,onListDirectories:u}=e,p="New session"!==l.newSession,[f,m]=t.useState(e.cwd),[h,w]=t.useState(e.agent),[g,C]=t.useState(e.approvalMode),[M,D]=t.useState(e.model),[N,K]=t.useState(e.effort),[A,P]=t.useState(e.fastMode),[U,G]=t.useState(""),V=function(e,s){const[n,a]=t.useState([]),[o,r]=t.useState(!1),[i,l]=t.useState(""),c=t.useRef(new Set);return t.useEffect(()=>()=>{for(const e of c.current)e.abort();c.current.clear()},[]),{attachments:n,uploadBusy:o,error:i,upload:async t=>{if(!t?.length||!e)return;const n=new AbortController;c.current.add(n),r(!0),l("");try{for(const o of Array.from(t)){const t=await j(o,e.pairToken,n.signal,s);if(n.signal.aborted)return;a(e=>[...e,t])}}catch(o){n.signal.aborted||l(o instanceof Error?o.message:String(o))}finally{c.current.delete(n)&&r(c.current.size>0)}},remove:e=>a(t=>t.filter(t=>t.path!==e))}}(e.pairing,l),[W,$]=t.useState([]),_=v(e.client,h,f.trim(),void 0,M,W,l),[Z,Q]=t.useState("");t.useEffect(()=>{let t=!1;return $([]),Q(""),e.onListModels(h).then(e=>{t||$(e)}).catch(()=>{t||Q(p?"模型加载失败,请重新选择代理重试。":"Models unavailable. Select the agent again to retry.")}),()=>{t=!0}},[h,e.onListModels,p]);const[X,Y]=t.useState([]),[ee,te]=t.useState(-1),[se,ne]=t.useState(!1),[ae,oe]=t.useState(""),[re,ie]=t.useState(!1),[le,ce]=t.useState(!1),[de,ue]=t.useState(null),pe=function(e){const s=t.useRef(null),n=JSON.stringify([e.cwd.trim(),e.agent,e.approvalMode,e.model.trim(),e.fastMode]);return t.useEffect(()=>{const t=e.client;if(!e.enabled||"codex"!==e.agent||!e.cwd.trim()||!t?.isConnected)return;let a;const o=setTimeout(()=>{a={id:t.makeId("prewarm"),key:n,client:t,taken:!1},s.current=a,t.request({action:"session.prewarm",id:t.makeId("prewarm-request"),preparationId:a.id,cwd:e.cwd.trim(),approvalMode:e.approvalMode,model:e.model.trim()||void 0,fastMode:e.fastMode}).catch(()=>{})},300);return()=>{clearTimeout(o),a&&(s.current===a&&(s.current=null),a.taken||t.request({action:"session.prewarm.cancel",id:t.makeId("prewarm-cancel"),preparationId:a.id}).catch(()=>{}))}},[n,e.client,e.enabled]),()=>{const t=s.current;if(t&&t.key===n&&t.client===e.client)return t.taken=!0,t.id}}({client:e.client,enabled:e.connected&&!se&&!le&&null===de,cwd:f,agent:h,approvalMode:g,model:M,fastMode:A}),fe=t.useRef(null),me=t.useRef(null),he=o(d,me),[we]=t.useState(()=>R(c));t.useEffect(()=>{if(Y([]),te(-1),oe(""),!se||!e.connected)return;let t=!1;const s=/^(?:[a-z]:[\\/]|\\\\)/i.test(f)?f.replaceAll("\\","/"):f,n=s.lastIndexOf("/"),a=n<0?".":s.slice(0,n+1)||"/",o=s.slice(n+1).toLowerCase(),r=window.setTimeout(()=>{ie(!0),u(a).then(e=>{t||Y(e.filter(e=>e.isDirectory&&e.name.toLowerCase().startsWith(o)).map(e=>k(a,e.name)).slice(0,12))}).catch(e=>{t||oe(String(e instanceof Error?e.message:e))}).finally(()=>{t||ie(!1)})},180);return()=>{t=!0,window.clearTimeout(r),ie(!1)}},[f,se,e.connected,u]);const ge=e=>{m(e+(e.endsWith("/")?"":"/")),fe.current?.focus()},ve=async()=>{if(de?.trim()&&!/[/\\]/.test(de)&&![".",".."].includes(de.trim())&&!le&&e.connected){ce(!0),oe("");try{const t=k(f,de.trim());await e.onCreateDirectory(t),m(t),ue(null),me.current?.focus()}catch(t){oe(String(t))}finally{ce(!1)}}},ye=()=>{f.trim()&&e.connected&&!le&&!V.uploadBusy&&(e.onCreate(f.trim(),h,{draft:U,approvalMode:g,model:M,effort:N,fastMode:A,attachments:V.attachments,preparationId:pe()}),function(e){const t=e.trim();if(t)try{s().setItem(F,JSON.stringify([t,...O().filter(e=>e!==t)].slice(0,20)))}catch{}}(U),function(e,t){try{const n=JSON.parse(s().getItem(L)||"{}");n[e]=[t,...R(e).filter(e=>e.cwd!==t.cwd||e.agent!==t.agent)].slice(0,8),s().setItem(L,JSON.stringify(n))}catch{}}(c,{cwd:f.trim(),agent:h,createdAt:Date.now()}),d())},be=function(e){const a="desktop"===n().kind,[o,r]=t.useState(()=>{try{const e=s().getItem(B);return"modEnter"===e||"shiftEnter"===e?e:"enter"}catch{return"enter"}});return{enabled:a,shortcut:o,update:e=>{r(e);try{s().setItem(B,e)}catch{}},onKeyDown:t=>{a&&!t.defaultPrevented&&"Enter"===t.key&&(t.nativeEvent.isComposing||229===t.keyCode?t.preventDefault():i(o,t)?(t.preventDefault(),t.repeat||e()):"INPUT"===t.currentTarget.tagName&&t.preventDefault())}}}(ye);return r.createPortal(a.jsxs("div",{className:"new-session-layer",children:[a.jsx("div",{className:"new-session-backdrop",onClick:d}),a.jsxs("div",{className:"new-session-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"new-session-title",ref:he,tabIndex:-1,children:[a.jsxs("header",{children:[a.jsx("h2",{id:"new-session-title",children:l.newSession}),a.jsx("button",{type:"button",className:"icon-button","aria-label":l.close,title:l.close,onClick:d,children:a.jsx(S,{})})]}),a.jsxs("form",{onSubmit:e=>{e.preventDefault(),ye()},children:[a.jsx("div",{className:"new-session-agents",children:["claude","codex"].map(e=>a.jsxs("button",{type:"button","aria-pressed":h===e,onClick:()=>{w(e),D("")},children:[a.jsx(T,{size:18}),"claude"===e?"Claude":"Codex"]},e))}),a.jsxs("div",{className:"new-session-path-field",onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||ne(!1)},children:[a.jsxs("div",{className:"new-session-field",children:[a.jsxs("div",{className:"new-session-field-heading",children:[a.jsx("label",{htmlFor:"new-session-cwd",children:l.workingDirectory}),a.jsx(z,{recent:we,chinese:p,onSelectRecent:e=>{m(e.cwd),w(e.agent),D("")}})]}),a.jsxs("div",{className:"new-session-path-row",children:[a.jsx("input",{id:"new-session-cwd",ref:fe,value:f,"aria-label":l.workingDirectory,role:"combobox","aria-autocomplete":"list",spellCheck:!1,"aria-expanded":se&&e.connected,"aria-controls":"new-session-paths","aria-activedescendant":ee>=0?`new-session-path-${ee}`:void 0,onFocus:()=>ne(!0),onChange:e=>m(e.target.value),onKeyDown:e=>{if(e.nativeEvent.isComposing||229===e.keyCode)be.onKeyDown(e);else{if(!("desktop"!==n().kind||"Tab"!==e.key||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey))return e.preventDefault(),ee>=0&&X[ee]&&ge(X[ee]),void me.current?.focus();!X.length||"ArrowDown"!==e.key&&"ArrowUp"!==e.key?("Enter"===e.key||"Tab"===e.key)&&ee>=0&&X[ee]&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),ge(X[ee])):(e.preventDefault(),te(t=>t<0?"ArrowDown"===e.key?0:X.length-1:(t+("ArrowDown"===e.key?1:-1)+X.length)%X.length)),be.onKeyDown(e)}}}),a.jsx("button",{type:"button",className:"icon-button","aria-label":l.browseDirectories,title:l.browseDirectories,onMouseDown:e=>e.preventDefault(),onClick:()=>(ge(f||e.cwd||"/"),void ne(!0)),children:a.jsx(x,{})})]})]}),se&&e.connected&&a.jsxs("div",{className:"new-session-paths",children:[a.jsx("div",{id:"new-session-paths",role:"listbox","aria-label":l.browseDirectories,children:X.map((e,t)=>a.jsxs("button",{type:"button",id:`new-session-path-${t}`,role:"option","aria-selected":ee===t,onMouseDown:e=>e.preventDefault(),onClick:()=>ge(e),title:e,children:[a.jsx(x,{size:14}),e]},e))}),a.jsxs("button",{type:"button",className:"new-session-folder-action",disabled:!f.trim()||le,onMouseDown:e=>e.preventDefault(),onClick:()=>{ne(!1),ue("")},children:[a.jsx(E,{size:14}),p?"新建文件夹":"New folder"]})]}),a.jsx("div",{className:"new-session-path-status",children:re||ae||Z?a.jsx("small",{role:ae||Z?"alert":"status",children:ae||Z||l.loadingDirectories}):a.jsx(q,{cwd:f.trim(),connected:e.connected,load:e.onLoadGitMetadata,t:l})}),null!==de&&a.jsxs("div",{className:"new-session-path-row new-session-folder-form",children:[a.jsx("input",{autoFocus:!0,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),e.nativeEvent.isComposing||ve()),"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),ue(null),fe.current?.focus())},"aria-label":p?"文件夹名称":"Folder name",value:de,onChange:e=>ue(e.target.value)}),a.jsx("button",{type:"button",disabled:le||!de.trim()||/[/\\]/.test(de),onClick:()=>{ve()},children:p?"创建文件夹":"Create folder"}),a.jsx("button",{type:"button",onClick:()=>ue(null),children:l.close})]})]}),a.jsx(J,{client:e.client,cwd:f,agent:h,controls:a.jsx(H,{t:l,models:_,approvalMode:g,onApprovalModeChange:C,model:M,onModelChange:D,effort:N,onEffortChange:K,fastMode:A,onFastModeChange:P}),submit:a.jsxs("div",{className:"submit-button-group",children:[" ",be.enabled&&a.jsx(y,{shortcut:be.shortcut,onChange:be.update,action:"create",t:l}),a.jsx(b,{type:"submit","aria-label":l.newSession,title:l.newSession,disabled:!e.connected||!f.trim()||le||V.uploadBusy,children:a.jsx(I,{"aria-hidden":"true"})})]}),textareaRef:me,onOpen:t=>e.onOpenRemoteFile(t,f),draft:U,onChange:G,onKeyDown:e=>{if(!("desktop"!==n().kind||"Tab"!==e.key||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey))return e.preventDefault(),void fe.current?.focus();be.onKeyDown(e)},connected:e.connected,chinese:p,files:V,t:l}),!e.connected&&a.jsx("p",{role:"status",children:p?"请先连接设备,再创建会话。":"Connect a device before creating a session."}),a.jsxs("footer",{children:[a.jsx("p",{className:"new-session-create-hint",children:p?"创建后自动发送初始消息":"The initial message is sent after creation"}),"desktop"!==n().kind&&a.jsx("button",{type:"button",onClick:d,children:p?"取消":"Cancel"})]})]})]})]}),document.body)}export{U as default};
1
+ import{c as e,r as t,i as s,h as n,j as a,u as o,f as r}from"./index-C6NKSiG-.js";import{s as i,u as l,C as c,a as d,b as u,c as p,d as f,e as m,f as h,g as w,G as g,h as v,S as y,i as b}from"./useComposerCompletion-vV_zliKO.js";import{x,y as j,z as k,X as S}from"./App-D4fBMWn7.js";import{C}from"./ComposerMenus-B9EpF3L_.js";import{S as M}from"./shield-check-B5zclKcP.js";import{C as D,Z as N}from"./zap-CGGziZzC.js";import{F as E}from"./folder-plus-BBvp5bBk.js";import{A as I}from"./__vite-browser-external-2447137e-DYOQzEuf.js";import"./useMessageImage-Bxcjzr5o.js";import"./MessageImage-DyqY_ZJd.js";import"./chevron-up-GZB6oy0t.js";const T=e("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]),K=e("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),A=e("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),L="vibelet.web.recentCreations";function R(e){try{const t=JSON.parse(s().getItem(L)||"{}")[e];return Array.isArray(t)?t.filter(e=>"string"==typeof e.cwd&&["claude","codex"].includes(e.agent)&&Number.isFinite(e.createdAt)).slice(0,8):[]}catch{return[]}}const F="vibelet.web.initialMessageHistory";function O(){try{const e=JSON.parse(s().getItem(F)||"[]");return Array.isArray(e)?[...new Set(e.filter(e=>"string"==typeof e).map(e=>e.trim()).filter(Boolean))].slice(0,20):[]}catch{return[]}}const B="vibelet.web.newSessionCreateShortcut";function q({cwd:e,connected:s,load:n,t:o}){const[r,i]=t.useState();t.useEffect(()=>{if(!e||!s)return;let t=!1,a=!1;const o=()=>{a||"hidden"===document.visibilityState||(a=!0,n(e).then(s=>{t||i({cwd:e,data:s})}).catch(s=>{t||i({cwd:e,error:s instanceof Error?s.message:String(s)})}).finally(()=>{a=!1}))},r=window.setTimeout(o,250),l=window.setInterval(o,5e3);return window.addEventListener("focus",o),()=>{t=!0,window.clearTimeout(r),window.clearInterval(l),window.removeEventListener("focus",o)}},[e,s,n]);const l=s&&r?.cwd===e?r.data:void 0,c=l?.branches[e],d=l?.diffStats[e];return a.jsx("div",{className:"new-session-git",role:"status",title:r?.cwd===e?r.error:void 0,children:c||d?a.jsxs(a.Fragment,{children:[a.jsx(K,{size:14,"aria-hidden":"true"}),a.jsx("span",{className:"new-session-git-branch",title:c||"HEAD",children:c||"HEAD"}),d&&(d.additions>0||d.deletions>0)&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"diff-add",children:["+",d.additions]}),a.jsxs("span",{className:"diff-del",children:["−",d.deletions]})]})]}):s&&e&&r?.cwd!==e?o.loading:" "})}function z({recent:e,chinese:t,onSelectRecent:s}){return a.jsxs("div",{className:"new-session-history",children:[" ",a.jsx(C,{icon:x,label:t?"最近创建":"Recent creations",menuLabel:t?"最近创建":"Recent creations",align:"right",value:"",options:e.length?e.map((e,t)=>({value:String(t),label:e.cwd,description:"claude"===e.agent?"Claude":"Codex"})):[{value:"",label:t?"暂无创建记录":"No recent creations",disabled:!0}],onSelect:t=>{const n=e[Number(t)];n&&s(n)}})]})}function P({chinese:e,onSelectMessage:s}){const[n]=t.useState(O);return a.jsxs("div",{className:"new-session-history",children:[" ",a.jsx(C,{icon:A,label:e?"消息历史":"Message history",menuLabel:e?"消息历史":"Message history",align:"right",value:"",options:n.length?n.map((e,t)=>({value:String(t),label:e})):[{value:"",label:e?"暂无消息历史":"No message history",disabled:!0}],onSelect:e=>{const t=n[Number(e)];t&&s(t)}})]})}function J({client:e,cwd:s="",agent:n="codex",controls:o,submit:r,draft:i,textareaRef:f,onOpen:m,onChange:h,onKeyDown:w,connected:g,chinese:v,files:y,t:b}){const x=t.useRef(null),j=t.useRef(null),[k,S]=t.useState([]),[C,M]=t.useState(""),[D,N]=t.useState(0);t.useEffect(()=>{let t=!1;if(S([]),M(""),!e||!g)return;const n=setTimeout(()=>{e.request({action:"skills.list",id:e.makeId("skills"),cwd:s.trim()||void 0}).then(e=>{t||S(e.skills??[])}).catch(e=>{t||M(b.resourceLoadFailed(b.skills,e instanceof Error?e.message:String(e)))})},200);return()=>{t=!0,clearTimeout(n)}},[e,g,s,D,b]);const E=l({draft:i,onChange:h,textareaRef:f??j,agent:n,skills:k,onRefreshSkills:()=>N(e=>e+1),t:b});return a.jsxs("div",{className:"new-session-message","aria-busy":y.uploadBusy,onDragOver:e=>{e.dataTransfer.types.includes("Files")&&e.preventDefault()},onDrop:e=>{e.dataTransfer.files.length&&(e.preventDefault(),g&&y.upload(e.dataTransfer.files))},children:[a.jsxs("div",{className:"new-session-field-heading",children:[a.jsx("label",{htmlFor:"new-session-initial-message",children:v?"初始消息(可选)":"Initial message (optional)"}),a.jsx(P,{chinese:v,onSelectMessage:h})]}),a.jsxs("div",{className:"new-session-message-box",children:[E.popovers,a.jsx(c,{id:"new-session-initial-message",textareaRef:f??j,value:i,onValueChange:h,...E.textareaProps,onKeyDown:e=>{E.handleKeyDown(e)||w(e)},rows:3,onPaste:e=>{g&&e.clipboardData.files.length&&(e.preventDefault(),y.upload(e.clipboardData.files))}}),a.jsx("input",{ref:x,type:"file",hidden:!0,multiple:!0,onChange:e=>{y.upload(e.currentTarget.files),e.currentTarget.value=""}}),a.jsx(d,{onOpen:m,attachments:y.attachments,uploadBusy:y.uploadBusy,onRemove:y.remove,t:b}),a.jsx(u,{leading:a.jsx(p,{t:b,toolsDisabled:!g||y.uploadBusy,onUpload:()=>x.current?.click(),onSkills:E.handleOpenSkills,onCommands:E.handleOpenCommands}),controls:o,submit:r})]}),y.uploadBusy&&a.jsx("small",{role:"status",children:b.uploading}),C&&a.jsx("p",{role:"alert",children:C}),y.error&&a.jsx("p",{role:"alert",children:y.error})]})}function H(e){const{t}=e,s="desktop"===n().kind,o=f(t),r=m(t),i=h(e.models,t),l=i.find(t=>t.value===e.model)?.label??(e.model||t.defaultOption);return a.jsxs("div",{className:"new-session-options composer-control-strip "+(s?"new-session-desktop-options":""),children:[a.jsx("div",{className:"composer-permission "+("autoApprove"===e.approvalMode?"full-access":""),children:a.jsx(C,{icon:M,label:o.find(t=>t.value===e.approvalMode)?.label??t.approvalMode,menuLabel:t.approvalMode,value:e.approvalMode,onSelect:e.onApprovalModeChange,options:o,wide:!0,blendBackground:!0})}),s?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"composer-toolbar-spacer"}),a.jsx(w,{...e,modelLabel:l,modelOptions:i,effortLabel:r.find(t=>t.value===e.effort)?.label??t.effort,effortOptions:r})]}):a.jsxs(a.Fragment,{children:[a.jsx(C,{icon:D,label:l,menuLabel:t.model,value:e.model,onSelect:e.onModelChange,options:i}),a.jsx(C,{icon:N,label:e.fastMode?t.fast:t.normal,menuLabel:t.fastMode,value:e.fastMode?"on":"off",onSelect:t=>e.onFastModeChange("on"===t),selected:e.fastMode,options:[{value:"off",label:t.normal,description:t.standardExecution,icon:g},{value:"on",label:t.fast,description:t.preferFasterResponses,icon:N}]})]})]})}function U(e){const{t:l,device:c,onClose:d,onListDirectories:u}=e,p="New session"!==l.newSession,[f,m]=t.useState(e.cwd),[h,w]=t.useState(e.agent),[g,C]=t.useState(e.approvalMode),[M,D]=t.useState(e.model),[N,K]=t.useState(e.effort),[A,P]=t.useState(e.fastMode),[U,G]=t.useState(""),V=function(e,s){const[n,a]=t.useState([]),[o,r]=t.useState(!1),[i,l]=t.useState(""),c=t.useRef(new Set);return t.useEffect(()=>()=>{for(const e of c.current)e.abort();c.current.clear()},[]),{attachments:n,uploadBusy:o,error:i,upload:async t=>{if(!t?.length||!e)return;const n=new AbortController;c.current.add(n),r(!0),l("");try{for(const o of Array.from(t)){const t=await j(o,e.pairToken,n.signal,s);if(n.signal.aborted)return;a(e=>[...e,t])}}catch(o){n.signal.aborted||l(o instanceof Error?o.message:String(o))}finally{c.current.delete(n)&&r(c.current.size>0)}},remove:e=>a(t=>t.filter(t=>t.path!==e))}}(e.pairing,l),[W,$]=t.useState([]),_=v(e.client,h,f.trim(),void 0,M,W,l),[Z,Q]=t.useState("");t.useEffect(()=>{let t=!1;return $([]),Q(""),e.onListModels(h).then(e=>{t||$(e)}).catch(()=>{t||Q(p?"模型加载失败,请重新选择代理重试。":"Models unavailable. Select the agent again to retry.")}),()=>{t=!0}},[h,e.onListModels,p]);const[X,Y]=t.useState([]),[ee,te]=t.useState(-1),[se,ne]=t.useState(!1),[ae,oe]=t.useState(""),[re,ie]=t.useState(!1),[le,ce]=t.useState(!1),[de,ue]=t.useState(null),pe=function(e){const s=t.useRef(null),n=JSON.stringify([e.cwd.trim(),e.agent,e.approvalMode,e.model.trim(),e.fastMode]);return t.useEffect(()=>{const t=e.client;if(!e.enabled||"codex"!==e.agent||!e.cwd.trim()||!t?.isConnected)return;let a;const o=setTimeout(()=>{a={id:t.makeId("prewarm"),key:n,client:t,taken:!1},s.current=a,t.request({action:"session.prewarm",id:t.makeId("prewarm-request"),preparationId:a.id,cwd:e.cwd.trim(),approvalMode:e.approvalMode,model:e.model.trim()||void 0,fastMode:e.fastMode}).catch(()=>{})},300);return()=>{clearTimeout(o),a&&(s.current===a&&(s.current=null),a.taken||t.request({action:"session.prewarm.cancel",id:t.makeId("prewarm-cancel"),preparationId:a.id}).catch(()=>{}))}},[n,e.client,e.enabled]),()=>{const t=s.current;if(t&&t.key===n&&t.client===e.client)return t.taken=!0,t.id}}({client:e.client,enabled:e.connected&&!se&&!le&&null===de,cwd:f,agent:h,approvalMode:g,model:M,fastMode:A}),fe=t.useRef(null),me=t.useRef(null),he=o(d,me),[we]=t.useState(()=>R(c));t.useEffect(()=>{if(Y([]),te(-1),oe(""),!se||!e.connected)return;let t=!1;const s=/^(?:[a-z]:[\\/]|\\\\)/i.test(f)?f.replaceAll("\\","/"):f,n=s.lastIndexOf("/"),a=n<0?".":s.slice(0,n+1)||"/",o=s.slice(n+1).toLowerCase(),r=window.setTimeout(()=>{ie(!0),u(a).then(e=>{t||Y(e.filter(e=>e.isDirectory&&e.name.toLowerCase().startsWith(o)).map(e=>k(a,e.name)).slice(0,12))}).catch(e=>{t||oe(String(e instanceof Error?e.message:e))}).finally(()=>{t||ie(!1)})},180);return()=>{t=!0,window.clearTimeout(r),ie(!1)}},[f,se,e.connected,u]);const ge=e=>{m(e+(e.endsWith("/")?"":"/")),fe.current?.focus()},ve=async()=>{if(de?.trim()&&!/[/\\]/.test(de)&&![".",".."].includes(de.trim())&&!le&&e.connected){ce(!0),oe("");try{const t=k(f,de.trim());await e.onCreateDirectory(t),m(t),ue(null),me.current?.focus()}catch(t){oe(String(t))}finally{ce(!1)}}},ye=()=>{f.trim()&&e.connected&&!le&&!V.uploadBusy&&(e.onCreate(f.trim(),h,{draft:U,approvalMode:g,model:M,effort:N,fastMode:A,attachments:V.attachments,preparationId:pe()}),function(e){const t=e.trim();if(t)try{s().setItem(F,JSON.stringify([t,...O().filter(e=>e!==t)].slice(0,20)))}catch{}}(U),function(e,t){try{const n=JSON.parse(s().getItem(L)||"{}");n[e]=[t,...R(e).filter(e=>e.cwd!==t.cwd||e.agent!==t.agent)].slice(0,8),s().setItem(L,JSON.stringify(n))}catch{}}(c,{cwd:f.trim(),agent:h,createdAt:Date.now()}),d())},be=function(e){const a="desktop"===n().kind,[o,r]=t.useState(()=>{try{const e=s().getItem(B);return"modEnter"===e||"shiftEnter"===e?e:"enter"}catch{return"enter"}});return{enabled:a,shortcut:o,update:e=>{r(e);try{s().setItem(B,e)}catch{}},onKeyDown:t=>{a&&!t.defaultPrevented&&"Enter"===t.key&&(t.nativeEvent.isComposing||229===t.keyCode?t.preventDefault():i(o,t)?(t.preventDefault(),t.repeat||e()):"INPUT"===t.currentTarget.tagName&&t.preventDefault())}}}(ye);return r.createPortal(a.jsxs("div",{className:"new-session-layer",children:[a.jsx("div",{className:"new-session-backdrop",onClick:d}),a.jsxs("div",{className:"new-session-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"new-session-title",ref:he,tabIndex:-1,children:[a.jsxs("header",{children:[a.jsx("h2",{id:"new-session-title",children:l.newSession}),a.jsx("button",{type:"button",className:"icon-button","aria-label":l.close,title:l.close,onClick:d,children:a.jsx(S,{})})]}),a.jsxs("form",{onSubmit:e=>{e.preventDefault(),ye()},children:[a.jsx("div",{className:"new-session-agents",children:["claude","codex"].map(e=>a.jsxs("button",{type:"button","aria-pressed":h===e,onClick:()=>{w(e),D("")},children:[a.jsx(T,{size:18}),"claude"===e?"Claude":"Codex"]},e))}),a.jsxs("div",{className:"new-session-path-field",onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||ne(!1)},children:[a.jsxs("div",{className:"new-session-field",children:[a.jsxs("div",{className:"new-session-field-heading",children:[a.jsx("label",{htmlFor:"new-session-cwd",children:l.workingDirectory}),a.jsx(z,{recent:we,chinese:p,onSelectRecent:e=>{m(e.cwd),w(e.agent),D("")}})]}),a.jsxs("div",{className:"new-session-path-row",children:[a.jsx("input",{id:"new-session-cwd",ref:fe,value:f,"aria-label":l.workingDirectory,role:"combobox","aria-autocomplete":"list",spellCheck:!1,"aria-expanded":se&&e.connected,"aria-controls":"new-session-paths","aria-activedescendant":ee>=0?`new-session-path-${ee}`:void 0,onFocus:()=>ne(!0),onChange:e=>m(e.target.value),onKeyDown:e=>{if(e.nativeEvent.isComposing||229===e.keyCode)be.onKeyDown(e);else{if(!("desktop"!==n().kind||"Tab"!==e.key||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey))return e.preventDefault(),ee>=0&&X[ee]&&ge(X[ee]),void me.current?.focus();!X.length||"ArrowDown"!==e.key&&"ArrowUp"!==e.key?("Enter"===e.key||"Tab"===e.key)&&ee>=0&&X[ee]&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),ge(X[ee])):(e.preventDefault(),te(t=>t<0?"ArrowDown"===e.key?0:X.length-1:(t+("ArrowDown"===e.key?1:-1)+X.length)%X.length)),be.onKeyDown(e)}}}),a.jsx("button",{type:"button",className:"icon-button","aria-label":l.browseDirectories,title:l.browseDirectories,onMouseDown:e=>e.preventDefault(),onClick:()=>(ge(f||e.cwd||"/"),void ne(!0)),children:a.jsx(x,{})})]})]}),se&&e.connected&&a.jsxs("div",{className:"new-session-paths",children:[a.jsx("div",{id:"new-session-paths",role:"listbox","aria-label":l.browseDirectories,children:X.map((e,t)=>a.jsxs("button",{type:"button",id:`new-session-path-${t}`,role:"option","aria-selected":ee===t,onMouseDown:e=>e.preventDefault(),onClick:()=>ge(e),title:e,children:[a.jsx(x,{size:14}),e]},e))}),a.jsxs("button",{type:"button",className:"new-session-folder-action",disabled:!f.trim()||le,onMouseDown:e=>e.preventDefault(),onClick:()=>{ne(!1),ue("")},children:[a.jsx(E,{size:14}),p?"新建文件夹":"New folder"]})]}),a.jsx("div",{className:"new-session-path-status",children:re||ae||Z?a.jsx("small",{role:ae||Z?"alert":"status",children:ae||Z||l.loadingDirectories}):a.jsx(q,{cwd:f.trim(),connected:e.connected,load:e.onLoadGitMetadata,t:l})}),null!==de&&a.jsxs("div",{className:"new-session-path-row new-session-folder-form",children:[a.jsx("input",{autoFocus:!0,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),e.nativeEvent.isComposing||ve()),"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),ue(null),fe.current?.focus())},"aria-label":p?"文件夹名称":"Folder name",value:de,onChange:e=>ue(e.target.value)}),a.jsx("button",{type:"button",disabled:le||!de.trim()||/[/\\]/.test(de),onClick:()=>{ve()},children:p?"创建文件夹":"Create folder"}),a.jsx("button",{type:"button",onClick:()=>ue(null),children:l.close})]})]}),a.jsx(J,{client:e.client,cwd:f,agent:h,controls:a.jsx(H,{t:l,models:_,approvalMode:g,onApprovalModeChange:C,model:M,onModelChange:D,effort:N,onEffortChange:K,fastMode:A,onFastModeChange:P}),submit:a.jsxs("div",{className:"submit-button-group",children:[" ",be.enabled&&a.jsx(y,{shortcut:be.shortcut,onChange:be.update,action:"create",t:l}),a.jsx(b,{type:"submit","aria-label":l.newSession,title:l.newSession,disabled:!e.connected||!f.trim()||le||V.uploadBusy,children:a.jsx(I,{"aria-hidden":"true"})})]}),textareaRef:me,onOpen:t=>e.onOpenRemoteFile(t,f),draft:U,onChange:G,onKeyDown:e=>{if(!("desktop"!==n().kind||"Tab"!==e.key||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey))return e.preventDefault(),void fe.current?.focus();be.onKeyDown(e)},connected:e.connected,chinese:p,files:V,t:l}),!e.connected&&a.jsx("p",{role:"status",children:p?"请先连接设备,再创建会话。":"Connect a device before creating a session."}),a.jsxs("footer",{children:[a.jsx("p",{className:"new-session-create-hint",children:p?"创建后自动发送初始消息":"The initial message is sent after creation"}),"desktop"!==n().kind&&a.jsx("button",{type:"button",onClick:d,children:p?"取消":"Cancel"})]})]})]})]}),document.body)}export{U as default};
@@ -1 +1 @@
1
- import{j as e}from"./index-CTpWXHK5.js";import{B as s}from"./App-DHM2JpIe.js";function i({notificationsBlocked:i,permission:n,settings:t,t:c,onToggleEnabled:o}){return e.jsxs("section",{className:"control-section compact-section",children:[e.jsx("h2",{children:c.notifications}),e.jsxs("label",{className:"toggle-field notification-toggle "+(i?"disabled":""),children:[e.jsxs("span",{children:[e.jsx(s,{"aria-hidden":"true"}),c.browserAlerts]}),e.jsx("input",{type:"checkbox",role:"switch","aria-checked":t.enabled&&!i&&"granted"===n,className:"settings-switch",checked:t.enabled&&!i&&"granted"===n,disabled:i,onChange:e=>o(e.target.checked)})]}),i?e.jsx("p",{className:"empty-copy",children:c.notificationsBlocked}):null]})}export{i as NotificationSettingsPanel};
1
+ import{j as e}from"./index-C6NKSiG-.js";import{B as s}from"./App-D4fBMWn7.js";function i({notificationsBlocked:i,permission:n,settings:t,t:c,onToggleEnabled:o}){return e.jsxs("section",{className:"control-section compact-section",children:[e.jsx("h2",{children:c.notifications}),e.jsxs("label",{className:"toggle-field notification-toggle "+(i?"disabled":""),children:[e.jsxs("span",{children:[e.jsx(s,{"aria-hidden":"true"}),c.browserAlerts]}),e.jsx("input",{type:"checkbox",role:"switch","aria-checked":t.enabled&&!i&&"granted"===n,className:"settings-switch",checked:t.enabled&&!i&&"granted"===n,disabled:i,onChange:e=>o(e.target.checked)})]}),i?e.jsx("p",{className:"empty-copy",children:c.notificationsBlocked}):null]})}export{i as NotificationSettingsPanel};
@@ -1 +1 @@
1
- import{r as e,j as t}from"./index-CTpWXHK5.js";import{s as r,A as n,X as a}from"./App-DHM2JpIe.js";import{A as s}from"./__vite-browser-external-2447137e-Ck9f6uYD.js";function i({panel:i,search:l,visible:o,t:c}){const[u,f]=e.useState(!1),[d,b]=e.useState(""),[p,v]=e.useState({active:0,total:0}),x=e.useRef(null),h=e.useRef(0),j="浏览器"===c.browser?"查找":"瀏覽器"===c.browser?"尋找":"Find",m="浏览器"===c.browser?"上一个匹配项":"瀏覽器"===c.browser?"上一個匹配項":"Previous match",w="浏览器"===c.browser?"下一个匹配项":"瀏覽器"===c.browser?"下一個匹配項":"Next match",y=(e,t=!0,r=!1)=>{const n=++h.current;if(!e)return l.current?.clear(),void v({active:0,total:0});l.current?.find(e,t,r,e=>{h.current===n&&v(e)})},E=()=>{h.current++,f(!1),l.current?.clear(),l.current?.focus?.()};return e.useEffect(()=>{const e=i.current,t=e=>{if(!o||!l.current)return;const t=e.detail;"searchMessages"===t?(f(!0),y(d),requestAnimationFrame(()=>{x.current?.focus(),x.current?.select()})):u&&y(d,"findPrevious"!==t,!0)};return e?.addEventListener("vibelet.panel.find",t),()=>e?.removeEventListener("vibelet.panel.find",t)},[o,u,d]),e.useEffect(()=>()=>{h.current++,l.current?.clear()},[]),u?t.jsxs("div",{className:"panel-find",role:"search","aria-label":j,children:[t.jsx("input",{ref:x,"aria-label":j,placeholder:j,value:d,onChange:e=>{b(e.target.value),y(e.target.value)},onKeyDown:e=>{e.nativeEvent.isComposing||("Enter"===e.key&&(e.preventDefault(),y(d,!e.shiftKey,!0)),"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),E()))}}),t.jsxs("span",{"aria-live":"polite",children:[p.active," / ",p.total]}),t.jsx("button",{type:"button","aria-label":m,title:r(m,"findPrevious"),disabled:!p.total,onClick:()=>y(d,!1,!0),children:t.jsx(s,{})}),t.jsx("button",{type:"button","aria-label":w,title:r(w,"findNext"),disabled:!p.total,onClick:()=>y(d,!0,!0),children:t.jsx(n,{})}),t.jsx("button",{type:"button","aria-label":c.close,title:c.close,onClick:E,children:t.jsx(a,{})})]}):null}export{i as P};
1
+ import{r as e,j as t}from"./index-C6NKSiG-.js";import{s as r,A as n,X as a}from"./App-D4fBMWn7.js";import{A as s}from"./__vite-browser-external-2447137e-DYOQzEuf.js";function i({panel:i,search:l,visible:o,t:c}){const[u,f]=e.useState(!1),[d,b]=e.useState(""),[p,v]=e.useState({active:0,total:0}),x=e.useRef(null),h=e.useRef(0),j="浏览器"===c.browser?"查找":"瀏覽器"===c.browser?"尋找":"Find",m="浏览器"===c.browser?"上一个匹配项":"瀏覽器"===c.browser?"上一個匹配項":"Previous match",w="浏览器"===c.browser?"下一个匹配项":"瀏覽器"===c.browser?"下一個匹配項":"Next match",y=(e,t=!0,r=!1)=>{const n=++h.current;if(!e)return l.current?.clear(),void v({active:0,total:0});l.current?.find(e,t,r,e=>{h.current===n&&v(e)})},E=()=>{h.current++,f(!1),l.current?.clear(),l.current?.focus?.()};return e.useEffect(()=>{const e=i.current,t=e=>{if(!o||!l.current)return;const t=e.detail;"searchMessages"===t?(f(!0),y(d),requestAnimationFrame(()=>{x.current?.focus(),x.current?.select()})):u&&y(d,"findPrevious"!==t,!0)};return e?.addEventListener("vibelet.panel.find",t),()=>e?.removeEventListener("vibelet.panel.find",t)},[o,u,d]),e.useEffect(()=>()=>{h.current++,l.current?.clear()},[]),u?t.jsxs("div",{className:"panel-find",role:"search","aria-label":j,children:[t.jsx("input",{ref:x,"aria-label":j,placeholder:j,value:d,onChange:e=>{b(e.target.value),y(e.target.value)},onKeyDown:e=>{e.nativeEvent.isComposing||("Enter"===e.key&&(e.preventDefault(),y(d,!e.shiftKey,!0)),"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),E()))}}),t.jsxs("span",{"aria-live":"polite",children:[p.active," / ",p.total]}),t.jsx("button",{type:"button","aria-label":m,title:r(m,"findPrevious"),disabled:!p.total,onClick:()=>y(d,!1,!0),children:t.jsx(s,{})}),t.jsx("button",{type:"button","aria-label":w,title:r(w,"findNext"),disabled:!p.total,onClick:()=>y(d,!0,!0),children:t.jsx(n,{})}),t.jsx("button",{type:"button","aria-label":c.close,title:c.close,onClick:E,children:t.jsx(a,{})})]}):null}export{i as P};