lantern-harness 0.1.9 → 0.1.11

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 (181) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/README.md +6 -6
  3. package/builtin/session/lh-fs.mjs +32 -14
  4. package/dist/500.html +258 -22
  5. package/dist/_astro/Base.Bgxs1QQl.css +1 -0
  6. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.CvbRi7Tl.js +1 -0
  7. package/dist/_astro/CaseExecBoard.Dttqp0wg.js +1 -0
  8. package/dist/_astro/CaseGenerateApp.DqW_nWMc.js +9 -0
  9. package/dist/_astro/CasesLibrary.8aMUUGp_.js +1 -0
  10. package/dist/_astro/ChatApp.BLxf0h1d.js +219 -0
  11. package/dist/_astro/ColumnResize.BEkEW7qw.js +1 -0
  12. package/dist/_astro/{ConfirmDialog.CBVsDJ8f.js → ConfirmDialog.BZzZWDci.js} +1 -1
  13. package/dist/_astro/{DashboardBoard.DCtfrrJz.js → DashboardBoard.CkSbhEDI.js} +3 -3
  14. package/dist/_astro/DatePicker.Bkl71M49.js +1 -0
  15. package/dist/_astro/DocsFileBrowser.MKVCfZrE.js +1 -0
  16. package/dist/_astro/DocsPager.DJY4foYL.js +1 -0
  17. package/dist/_astro/{DrawerField.CWMLhcPX.js → DrawerField.CHRg77LG.js} +1 -1
  18. package/dist/_astro/{ExcelFieldTags.B_XMwNNx.js → ExcelFieldTags.DXMeaDa5.js} +4 -4
  19. package/dist/_astro/KnowledgeLibrary.B-p1aoQN.js +1 -0
  20. package/dist/_astro/NamePromptDialog.Wa9O530a.js +1 -0
  21. package/dist/_astro/NavLibraries.C6LImMO_.js +1 -0
  22. package/dist/_astro/OverflowHint.D6v4Uj2N.js +1 -0
  23. package/dist/_astro/PluginsPage.-97n3x2U.js +39 -0
  24. package/dist/_astro/PluginsPage.DkmRPfbU.js +1 -0
  25. package/dist/_astro/PmBugsBoard.CMT4-eoB.js +1 -0
  26. package/dist/_astro/PmIterationsBoard.BQM_dzdZ.js +1 -0
  27. package/dist/_astro/PmProjectDetail.CzU80pat.js +1 -0
  28. package/dist/_astro/PmProjectsBoard.Cxsa7SYQ.js +1 -0
  29. package/dist/_astro/PmRequirementsBoard.4_JMDDN0.js +1 -0
  30. package/dist/_astro/PmRequirementsBoard.B8HL07cw.js +1 -0
  31. package/dist/_astro/PmShared.Ca2Ao7v_.js +1 -0
  32. package/dist/_astro/PromptsLibrary.C9BcIxKK.js +1 -0
  33. package/dist/_astro/ReportsPage.Fh5DRKLT.js +1 -0
  34. package/dist/_astro/RequirementsLibrary.CBkuWE8X.js +1 -0
  35. package/dist/_astro/SearchableSelect.DnjoSslK.js +1 -0
  36. package/dist/_astro/SelectDropdown.CuuDHa8s.js +1 -0
  37. package/dist/_astro/SettingsDialog.CVB5Gtk4.js +1 -0
  38. package/dist/_astro/SlideOverDrawer.B7B5Wu8I.js +1 -0
  39. package/dist/_astro/{SpaceSwitcher.CI3KDBOA.js → SpaceSwitcher.BVQLt_tL.js} +2 -2
  40. package/dist/_astro/TagSelect.CuN5RdF4.js +1 -0
  41. package/dist/_astro/TasksBoard.Bu-fpIZ7.js +1 -0
  42. package/dist/_astro/TemplatesLibrary.DSylQGlN.js +1 -0
  43. package/dist/_astro/TestStatsBoard.CPyKW4wc.js +1 -0
  44. package/dist/_astro/Toast.R8_2OWRX.js +1 -0
  45. package/dist/_astro/TodosBoard.8kvRTEW-.js +1 -0
  46. package/dist/_astro/UiAutoBoard.DFTiDqCp.js +9 -0
  47. package/dist/_astro/active-element-history.CED-m1Zp.js +1 -0
  48. package/dist/_astro/app-config.BUPzGl9f.js +1 -0
  49. package/dist/_astro/{client.Be_SakrB.js → client.BHNTqLjv.js} +3 -3
  50. package/dist/_astro/dialog.BAPTk9a_.js +1 -0
  51. package/dist/_astro/hydrate-cache.BXX604Bw.js +1 -0
  52. package/dist/_astro/{i18n.B52gLzii.js → i18n.BGPnP1Bg.js} +1 -1
  53. package/dist/_astro/index.astro_astro_type_script_index_0_lang.LPL9mPQY.js +1 -0
  54. package/dist/_astro/jsx-runtime.DUg_B_vD.js +1 -0
  55. package/dist/_astro/{lib.DJNDi_Ht.js → lib.CgXLzMMd.js} +15 -15
  56. package/dist/_astro/listbox.C96OCanh.js +1 -0
  57. package/dist/_astro/markdown-client.DRva7DS9.js +58 -0
  58. package/dist/_astro/menu.IPWdRoNM.js +1 -0
  59. package/dist/_astro/{open-docs-in-session.Xg3OSOfc.js → open-docs-in-session.CyFNgh1I.js} +1 -1
  60. package/dist/_astro/{plugins.BDZqJNOy.js → plugins.C2BMfzv1.js} +1 -1
  61. package/dist/_astro/{pm.Bl3hz9fF.js → pm.CagBA-ht.js} +2 -2
  62. package/dist/_astro/{portal.Cm9XlIPf.js → portal.C0hAhXDF.js} +2 -2
  63. package/dist/_astro/prompts-meta.Bua-j14I.js +2 -0
  64. package/dist/_astro/react-dom.DLW9pGCF.js +1 -0
  65. package/dist/_astro/{react-dom.CqAxpHMt.js → react.Blvh0GOs.js} +1 -1
  66. package/dist/_astro/report-prompt.CAfZ6RIo.js +1 -0
  67. package/dist/_astro/{settings.C6NWuiFO.js → settings.Ceefeil5.js} +2 -2
  68. package/dist/_astro/{spaces-client.k_ciWMai.js → spaces-client.BocUabwy.js} +1 -1
  69. package/dist/_astro/ui-auto-prompt.CX8fju7r.js +3 -0
  70. package/dist/_astro/ui-auto.BmC9JJ_X.js +1 -0
  71. package/dist/_astro/update.CtF8vsag.js +1 -0
  72. package/dist/_astro/use-text-value.DBQvHeNl.js +1 -0
  73. package/dist/_astro/use-tree-walker.DFU2AaAP.js +1 -0
  74. package/dist/_astro/useListAnim.BoerpmsB.js +1 -0
  75. package/dist/_astro/{view-prefs.Dyu_lmN2.js → view-prefs.BEAZRcxF.js} +1 -1
  76. package/dist/case-exec/index.html +458 -22
  77. package/dist/cases/generate/index.html +258 -22
  78. package/dist/cases/library/index.html +458 -22
  79. package/dist/dashboard/index.html +458 -22
  80. package/dist/docs/changelog/index.html +373 -23
  81. package/dist/docs/install/index.html +258 -22
  82. package/dist/docs/manual/index.html +314 -35
  83. package/dist/index.html +2 -281
  84. package/dist/knowledge/index.html +458 -22
  85. package/dist/knowledge//345/212/237/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/347/274/226/345/206/231/350/247/204/350/214/203/index.html +258 -22
  86. package/dist/plugins/index.html +258 -22
  87. package/dist/pm/bugs/index.html +458 -22
  88. package/dist/pm/iterations/index.html +458 -22
  89. package/dist/pm/projects/detail/index.html +458 -22
  90. package/dist/pm/projects/index.html +458 -22
  91. package/dist/pm/requirements/index.html +458 -22
  92. package/dist/prompts/index.html +458 -22
  93. package/dist/reports/index.html +458 -22
  94. package/dist/requirements/index.html +458 -22
  95. package/dist/tasks/index.html +458 -22
  96. package/dist/templates/index.html +458 -22
  97. package/dist/templates//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +258 -22
  98. package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +258 -22
  99. package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +258 -22
  100. package/dist/templates//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +258 -22
  101. package/dist/templates//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +258 -22
  102. package/dist/test-automation/index.html +717 -0
  103. package/dist/test-stats/index.html +458 -22
  104. package/dist/todos/index.html +458 -22
  105. package/dist/workbench/index.html +517 -0
  106. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +80 -43
  107. package/lh-plugins/lh-project-docs.mjs +14 -0
  108. package/lh-plugins/lh-uiauto.mjs +1445 -386
  109. package/lh-plugins/plugin-prompts.mjs +200 -0
  110. package/lh-plugins/storage-domain.mjs +6 -0
  111. package/lh-plugins/uiauto-adapters/index.mjs +57 -0
  112. package/lh-plugins/uiauto-adapters/playwright.mjs +215 -0
  113. package/lh-plugins/uiauto-adapters/pytest.mjs +151 -0
  114. package/lh-plugins/uiauto-adapters/selenium.mjs +163 -0
  115. package/lh-plugins/uiauto-adapters/shared.mjs +371 -0
  116. package/lh-plugins/uiauto-adapters/tasks.mjs +369 -0
  117. package/lh-plugins/uiauto-explorer/apps.mjs +332 -0
  118. package/lh-plugins/uiauto-explorer/diff.mjs +159 -0
  119. package/lh-plugins/uiauto-explorer/emit-files.mjs +506 -0
  120. package/lh-plugins/uiauto-explorer/emit-python.mjs +160 -0
  121. package/lh-plugins/uiauto-explorer/emit-ts.mjs +118 -0
  122. package/lh-plugins/uiauto-explorer/emit.mjs +15 -0
  123. package/lh-plugins/uiauto-explorer/ir.mjs +114 -0
  124. package/lh-plugins/uiauto-explorer/locators.mjs +267 -0
  125. package/lh-plugins/uiauto-explorer/merge.mjs +235 -0
  126. package/lh-plugins/uiauto-explorer/plan.mjs +165 -0
  127. package/lh-plugins/uiauto-explorer/runner.mjs +370 -0
  128. package/lh-plugins/uiauto-explorer/sessions.mjs +1373 -0
  129. package/lh-plugins/uiauto-explorer/snapshot.mjs +492 -0
  130. package/lh-plugins/uiauto-prompt.mjs +122 -0
  131. package/lh-plugins/uiauto-report.mjs +111 -0
  132. package/package.json +1 -1
  133. package/dist/_astro/Base.4X_wsSoR.css +0 -1
  134. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.Dy7fJoxu.js +0 -1
  135. package/dist/_astro/CaseExecBoard.DKdfW5fM.js +0 -1
  136. package/dist/_astro/CaseGenerateApp.Bm8AyH9s.js +0 -9
  137. package/dist/_astro/CasesLibrary.CvVJZ74h.js +0 -1
  138. package/dist/_astro/ChatApp.BS-wLBRa.js +0 -276
  139. package/dist/_astro/ColumnResize.Bs6GL3DJ.js +0 -1
  140. package/dist/_astro/DatePicker.CMfX7F6z.js +0 -1
  141. package/dist/_astro/DocsFileBrowser.BtRoZ787.js +0 -1
  142. package/dist/_astro/DocsPager.C20ue_JZ.js +0 -1
  143. package/dist/_astro/KnowledgeLibrary.CV4DyStj.js +0 -1
  144. package/dist/_astro/NamePromptDialog.Dl5kSnQI.js +0 -1
  145. package/dist/_astro/NavLibraries.DmD2lZBZ.js +0 -1
  146. package/dist/_astro/OverflowHint.lzmplP5j.js +0 -1
  147. package/dist/_astro/PluginsPage.B59AMDrB.js +0 -1
  148. package/dist/_astro/PluginsPage.BEAPymNL.js +0 -39
  149. package/dist/_astro/PmBugsBoard.CPEyBp0l.js +0 -1
  150. package/dist/_astro/PmIterationsBoard.zCeLpcBo.js +0 -1
  151. package/dist/_astro/PmProjectDetail.ejIam5sD.js +0 -1
  152. package/dist/_astro/PmProjectsBoard.DbXzir8o.js +0 -1
  153. package/dist/_astro/PmRequirementsBoard.CynewRfv.js +0 -1
  154. package/dist/_astro/PmRequirementsBoard.D9eUMJWI.js +0 -1
  155. package/dist/_astro/PmShared.BxTHKdjY.js +0 -1
  156. package/dist/_astro/PromptsLibrary.Bkruu80b.js +0 -1
  157. package/dist/_astro/ReportsPage.BoBQshMQ.js +0 -1
  158. package/dist/_astro/RequirementsLibrary.BC0A8qdk.js +0 -1
  159. package/dist/_astro/SearchableSelect.CXa1hiDd.js +0 -1
  160. package/dist/_astro/SelectDropdown.Buv7rQJ_.js +0 -1
  161. package/dist/_astro/SettingsDialog.Dc-9QNJI.js +0 -1
  162. package/dist/_astro/SlideOverDrawer.TPbGEoWn.js +0 -1
  163. package/dist/_astro/TagSelect.u8DTop7v.js +0 -1
  164. package/dist/_astro/TasksBoard.Bb--oVV8.js +0 -1
  165. package/dist/_astro/TemplatesLibrary.D1wZq94E.js +0 -1
  166. package/dist/_astro/TestStatsBoard.DlVezlXl.js +0 -1
  167. package/dist/_astro/TodosBoard.S84wqcWY.js +0 -1
  168. package/dist/_astro/UiAutoBoard.BKp9ifxg.js +0 -1
  169. package/dist/_astro/active-element-history.CeefGkFQ.js +0 -1
  170. package/dist/_astro/app-config.DUyozIL9.js +0 -1
  171. package/dist/_astro/dialog.DXHznyjD.js +0 -1
  172. package/dist/_astro/jsx-runtime.BUXbF_vF.js +0 -1
  173. package/dist/_astro/listbox.Di-t5U37.js +0 -1
  174. package/dist/_astro/menu.Bkluqxic.js +0 -1
  175. package/dist/_astro/prompts-meta.F4wwkjUA.js +0 -2
  176. package/dist/_astro/report-prompt.Cmw4XzfY.js +0 -1
  177. package/dist/_astro/update.Bl_HfSe6.js +0 -1
  178. package/dist/_astro/use-text-value.BuY0Cm1z.js +0 -1
  179. package/dist/_astro/use-tree-walker.CfTHFX43.js +0 -1
  180. package/dist/_astro/useListAnim.CpGB1cft.js +0 -1
  181. package/dist/ui-automation/index.html +0 -281
@@ -1 +0,0 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.DUyozIL9.js";import{a as r,o as i,r as a}from"./plugins.BDZqJNOy.js";import{t as o}from"./jsx-runtime.BUXbF_vF.js";import{t as s}from"./ConfirmDialog.CBVsDJ8f.js";import{n as c,t as ee}from"./DocsPager.C20ue_JZ.js";import{a as te,c as ne,f as l,h as u,i as re,l as ie,m as ae,n as oe,o as d,p as se,r as ce,s as f,t as le,u as ue}from"./project-docs.Cd2gKPKh.js";import{n as de}from"./doc-roots.DAJP9Svr.js";import{t as fe}from"./useListAnim.CpGB1cft.js";import{t as p}from"./NamePromptDialog.Dl5kSnQI.js";var m=e(t(),1),h=o(),pe=5;function g({className:e=`w-4 h-4`,open:t=!1}){return(0,h.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,h.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}):(0,h.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function _({className:e=`w-3 h-3`}){return(0,h.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,h.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,h.jsx)(`path`,{d:`m15 5 4 4`})]})}function v({className:e=`w-3 h-3`}){return(0,h.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,h.jsx)(`path`,{d:`M3 6h18`}),(0,h.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,h.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,h.jsx)(`path`,{d:`M10 11v6`}),(0,h.jsx)(`path`,{d:`M14 11v6`})]})}function y({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,h.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,h.jsx)(g,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,h.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,h.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,h.jsx)(`div`,{className:`tw-collapse-inner`,children:e.children.map(e=>(0,h.jsx)(y,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function me(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function b(){let[e,t]=(0,m.useState)(()=>a(`requirements`)),[o,b]=(0,m.useState)(!1),[x,he]=(0,m.useState)(null),[S,ge]=(0,m.useState)([]),[_e,ve]=(0,m.useState)(0),[C,w]=(0,m.useState)(`.`),[T,E]=(0,m.useState)([]),[ye,D]=(0,m.useState)({}),[O,be]=(0,m.useState)(!0),[k,A]=(0,m.useState)(null),[j,M]=(0,m.useState)(!1),[N,P]=(0,m.useState)(null),[F,I]=(0,m.useState)(!1),[L,R]=(0,m.useState)(null),[z,B]=(0,m.useState)(null),[xe,V]=(0,m.useState)(1),[H,Se]=c(pe),[Ce,U]=(0,m.useState)(null),W=(0,m.useRef)(null),{cls:we,play:G}=fe(),K=(0,m.useCallback)(async()=>{let e=await re(`requirements`);ge(e.tree),ve(e.totalFiles)},[]),q=(0,m.useCallback)(async(e=C)=>{A(null);try{let[t]=await Promise.all([f(`requirements`,e),K()]);E(t.entries),w(t.path)}catch(e){A(e instanceof Error?e.message:String(e))}},[C,K]);(0,m.useEffect)(()=>{let e=r(e=>t(!!e.requirements));return n().then(()=>{t(a(`requirements`)),b(!0)}),e},[]),(0,m.useEffect)(()=>{o&&e&&(async()=>{let e=await ce(`requirements`);if(he(e),e)try{let[e]=await Promise.all([f(`requirements`,`.`),K()]);E(e.entries),w(e.path)}catch(e){A(e instanceof Error?e.message:String(e))}})()},[o,e,K]);function Te(){be(e=>!e),D({})}async function J(e){G(),w(e),V(1),P(null),U(null),A(null);try{let t=await f(`requirements`,e);E(t.entries)}catch(e){A(e instanceof Error?e.message:String(e))}}async function Ee(e){I(!1),M(!0),A(null);try{await ne(`requirements`,C,e),await q(C)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}async function De(e){if(e.type===`file`){M(!0),A(null);try{await ie(`requirements`,e.path)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}async function Oe(e){if(e?.length){M(!0),A(null);try{for(let t of Array.from(e))await u(`requirements`,C,t);await q(C)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1),W.current&&(W.current.value=``)}}}function ke(e){let t=te(S,e.path),n=t?.fileCount??0,r=t?le(t):0;R({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function Ae(e){R({name:e.name,path:e.path,isDir:!1})}function Y(e,t){B({...e,isDir:t})}async function je(){let e=L;if(e&&(R(null),!e.blocked)){M(!0),A(null);try{await oe(`requirements`,e.path),N&&d(N.path,e.path)&&P(null);let t=d(C,e.path)?ue(e.path):C;await q(t)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}async function Me(e){let t=z;if(t&&(B(null),e!==t.name)){M(!0),A(null);try{let n=await ae(`requirements`,t.path,e);await q(se(C,t.path,n))}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}let Ne=(()=>{if(!L)return``;if(!L.isDir)return`删除文件「${L.name}」?将移入系统废纸篓,可随时找回。`;if(L.blocked){let e=[];return L.files&&e.push(`${L.files} 个文件`),L.dirs&&e.push(`${L.dirs} 个子文件夹`),`文件夹「${L.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${L.name}」?将移入系统废纸篓。`})();async function Pe(e){if(e.type!==`file`)return;let t=e.name.toLowerCase();if(!t.endsWith(`.md`)&&!t.endsWith(`.txt`))A(`仅 .md / .txt 支持就地预览;docx 请双击用本机程序打开。`);else{M(!0),A(null);try{let t=await l(`requirements`,e.path);P({path:t.path,content:t.content})}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}if(!o)return(0,h.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,h.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,h.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`requirements`)});if(x===null)return(0,h.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,h.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!x)return(0,h.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`需求文档库需要本地文档服务,当前未就绪。`});let X=T.filter(e=>e.type===`file`),Z=T.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/H)),$=Math.min(xe,Q),Fe=X.slice(($-1)*H,$*H);function Ie(e){G(),Se(e),V(1)}return(0,h.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,h.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,h.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,h.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,h.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>I(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,h.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1`,children:[(0,h.jsx)(`div`,{className:`group flex items-center rounded-md ${C===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{J(`.`),Te()},"aria-expanded":O,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${C===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,h.jsx)(g,{open:O,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部需求`}),(0,h.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,_e,`)`]})]})}),(0,h.jsx)(`div`,{className:`tw-collapse ${O?`is-open`:``}`,children:(0,h.jsx)(`div`,{className:`tw-collapse-inner`,children:S.map(e=>(0,h.jsx)(y,{node:e,depth:0,activePath:C,expanded:ye,globalOpen:O,onToggle:e=>D(t=>({...t,[e]:!(t[e]??O)})),onSelect:e=>void J(e)},e.path))})})]})]}),(0,h.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,h.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,h.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,h.jsx)(`span`,{className:`text-stone-400`,children:de(`requirements`)}),C===`.`?``:C]}),(0,h.jsx)(`input`,{ref:W,type:`file`,multiple:!0,accept:`.md,.txt,.docx,text/plain,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document`,className:`hidden`,onChange:e=>void Oe(e.target.files)}),(0,h.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>W.current?.click(),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`上传文件`})]}),k?(0,h.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:k}):null,(0,h.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,h.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,h.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void J(e.path),children:[(0,h.jsx)(g,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,h.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,h.jsx)(_,{className:`w-3.5 h-3.5`})}),(0,h.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`删除 ${e.name}`,onClick:()=>ke({name:e.name,path:e.path}),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,h.jsx)(v,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,h.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加需求文档(.md / .txt / .docx)`}):(0,h.jsx)(`ul`,{className:`${we}space-y-1`,children:Fe.map(e=>{let t=Ce===e.path;return(0,h.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors ${t?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,onClick:()=>{U(e.path),Pe(e)},onDoubleClick:t=>{t.preventDefault(),De(e)},children:[(0,h.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,h.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:me(e.size)})]}),(0,h.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,h.jsx)(_,{className:`w-3.5 h-3.5`})}),(0,h.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`删除 ${e.name}`,onClick:()=>Ae(e),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,h.jsx)(v,{className:`w-3.5 h-3.5`})})]},e.path)})})]}),N?(0,h.jsxs)(`div`,{className:`rounded-lg border border-stone-200 overflow-hidden`,children:[(0,h.jsxs)(`div`,{className:`px-3 py-2 bg-stone-50 border-b border-stone-200 flex items-center justify-between`,children:[(0,h.jsx)(`span`,{className:`text-xs text-stone-500 truncate`,children:N.path}),(0,h.jsx)(`button`,{type:`button`,className:`text-xs text-stone-500 hover:text-stone-800`,onClick:()=>P(null),children:`关闭预览`})]}),(0,h.jsx)(`pre`,{className:`max-h-80 overflow-auto p-4 text-xs leading-5 text-stone-700 whitespace-pre-wrap bg-white`,children:N.content})]}):null]}),X.length>0?(0,h.jsx)(ee,{page:$,totalPages:Q,pageSize:H,busy:j,onPage:e=>{G(),V(e)},onPageSize:Ie}):null]}),(0,h.jsx)(p,{open:F,title:`新建文件夹`,onClose:()=>I(!1),onConfirm:e=>void Ee(e)}),(0,h.jsx)(p,{open:z!=null,title:z?.isDir?`重命名文件夹`:`重命名文件`,label:z?.isDir?`文件夹名称`:`文件名称`,initialValue:z?.name??``,lockExtension:z!=null&&!z.isDir,confirmLabel:`保存`,onClose:()=>B(null),onConfirm:e=>void Me(e)}),(0,h.jsx)(s,{open:L!=null,title:L?.blocked?`无法删除文件夹`:L?.isDir?`删除文件夹`:`删除需求文件`,message:Ne,confirmLabel:L?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!L?.blocked,hideCancel:!!L?.blocked,onClose:()=>R(null),onConfirm:()=>void je()})]})}export{b as default};
@@ -1 +0,0 @@
1
- import{c as e,n as t,t as n}from"./react-dom.CqAxpHMt.js";import{G as r,J as i,K as a,p as o,q as s,r as c,t as l,u}from"./app-config.DUyozIL9.js";import{C as d,D as f,E as p,S as m,T as h,_ as g,a as _,c as v,f as y,g as b,h as x,i as S,l as C,m as w,n as T,o as E,p as D,r as O,s as k,u as A,v as j,w as M,x as ee,y as N}from"./use-text-value.BuY0Cm1z.js";import{$ as te,A as ne,B as P,F as re,J as ie,K as F,L as I,M as L,N as ae,P as oe,V as se,_t as R,c as ce,d as le,dt as z,et as B,f as ue,ft as de,h as fe,ht as pe,it as V,k as me,lt as he,m as ge,mt as _e,n as ve,nt as ye,o as be,p as xe,pt as H,rt as Se,s as Ce,st as U,u as we,ut as Te,v as Ee,x as De}from"./portal.Cm9XlIPf.js";import{a as Oe,c as ke,l as Ae,o as je,s as Me,u as Ne}from"./listbox.Di-t5U37.js";import{n as Pe,r as Fe,t as Ie}from"./active-element-history.CeefGkFQ.js";import{t as Le}from"./use-tree-walker.CfTHFX43.js";import{t as Re}from"./jsx-runtime.BUXbF_vF.js";var W=e(t(),1),G=e(n(),1);function ze(e){return typeof e==`object`?e.key:e}function Be(e,t){let n=e.length;return new Proxy(e,{get(e,r,i){if(typeof r==`string`){let i=r.charCodeAt(0);if(i>=48&&i<=57){let i=+r;if(Number.isInteger(i)&&i>=0&&i<n){let n=e[i];if(typeof n!=`object`){let r=t[i*2];n=e[i]={index:i,key:n,start:r,size:t[i*2+1],end:r+t[i*2+1],lane:0}}return n}}if(r===`length`)return n}return Reflect.get(e,r,i)}})}function K(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return(o.length!==r.length||o.some((e,t)=>r[t]!==e))&&(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1),i}return o.updateDeps=e=>{r=e},o}function Ve(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var q=(e,t)=>Math.abs(e-t)<1.01,He=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})},Ue,We=()=>{if(Ue!==void 0)return Ue;if(typeof navigator>`u`)return Ue=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Ue=!0;let e=navigator.maxTouchPoints;return Ue=navigator.platform===`MacIntel`&&e!==void 0&&e>0},Ge=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Ke=e=>e,qe=e=>{let t=e.overscan*Math.max(e.lanes??1,1),n=Math.max(e.startIndex-t,0),r=Math.min(e.endIndex+t,e.count-1)-n+1,i=Array(r);for(let e=0;e<r;e++)i[e]=n+e;return i},Je=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(Ge(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(Ge(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Ye={passive:!0},Xe=typeof window>`u`||`onscrollend`in window,Ze=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&Xe,o=0,s=a?null:He(i,()=>t(n(r),!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,Ye),a&&r.addEventListener(`scrollend`,u,Ye),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},Qe=(e,t)=>Ze(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),$e=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},et=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},tt=(e,t)=>e===`smooth`?t?`smoothLanded`:`smooth`:`instant`,nt=e=>e?.phase===`smooth`||e?.phase===`smoothLanded`,rt=e=>e.phase===`smooth`||e.phase===`smoothFinishing`;function it(e,t,n,r){if(t===0)return!1;let i=r(0),a=new Set,o=0;for(;o<e;){let e=n(o);if(e===i)break;a.add(e),o++}let s=e-o;if(s===0||s>=t)return!1;for(let e=0;e<s;e++)if(r(e)!==n(o+e))return!1;for(let e=s;e<t;e++)if(a.has(r(e)))return!1;return!0}var at=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this._clampedAdjustment=null,this.elementsCache=new Map,this._resizeBatch=null,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{let t=()=>{let t={sync:!1};this._resizeBatch=t;try{e.forEach(n)}finally{this._resizeBatch=null,t.notify&&(this.notify(t.sync),this._retryClampedAdjustment())}};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})),n=e=>{let t=e.target,n=this.indexFromElement(t);if(t.isConnected)this.isIndexInRange(n)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this));else{this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}}};return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Ke,rangeExtractor:qe,onChange:()=>{},measureElement:$e,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=this._singleLaneMeasurements?.items??s,l=e=>ze(c[e]),u=e>0?l(0):null,d=e>0?l(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==u||t.getItemKey(o-1)!==d)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>0&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==d)&&(o>e||it(e,o,l,t.getItemKey))&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:a,getItemKey:c}=this.options,l=0;for(;l<a&&c(l)!==e;)l++;if(l<a){let e=n[l];if(e){let n=Math.max(0,e.start+t);!i&&n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=K(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._clampedAdjustment=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5?e=this._intendedScrollOffset:this.scrollState?.index!=null&&!rt(this.scrollState)&&!q(e,this.scrollState.lastTargetOffset)&&!q(e,this.getScrollStateTarget(this.scrollState))&&(this._clampedAdjustment===null||Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5)&&(this.scrollState=null),this._intendedScrollOffset=null,this.scrollState&&(this.scrollState.writtenOffset=null),this._clampedAdjustment!==null&&Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null),this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,We()&&this.targetWindow!=null&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,Ye),e.addEventListener(`touchend`,n,Ye),e.addEventListener(`touchcancel`,n,Ye),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),e.removeEventListener(`touchcancel`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(We()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):nt(this.scrollState)&&!q(this.getScrollOffset()-i,this.scrollState.lastTargetOffset)||this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}this._retryClampedAdjustment()},this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;let{target:e,maxAtWrite:t}=this._clampedAdjustment,n=this.getMaxScrollOffset();n>t+.5&&(this._clampedAdjustment=e>n+.5?{target:e,maxAtWrite:n}:null,this._scrollToOffset(e,{adjustments:void 0,behavior:void 0}))},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=K(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=K(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._singleLaneMeasurements?.flat;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e}let o=u===0?Array(e):this._singleLaneMeasurements.items.slice(),c;if(u===0)c=t+n;else{let e=u-1;c=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t);o[t]=e;let n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=c,a[t*2+1]=i,c+=i+s}this._singleLaneMeasurements={flat:a,items:o};let d=Be(o,a);return this.measurementsCache=d,d}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=K(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=ct(e,t,n,r,r===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=K(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t,this.options.lanes]},(e,t,n,r,i,a)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n,lanes:a}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!nt(this.scrollState))return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),e.isConnected&&(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{var n;if(!this.isIndexInRange(e))return;this._resizeBatch?.sync&&this.getMeasurements();let r,i,a,o=this._singleLaneMeasurements?.flat;if(this.options.lanes===1&&o!=null)a=this.options.getItemKey(e),i=o[e*2],r=o[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;a=t.key,i=t.start,r=t.size}let s=this.itemSizeCache.get(a)??r,c=t-s;if(c!==0){let o=this.options.anchorTo===`end`&&!nt(this.scrollState)&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,l=o?this.getTotalSize():0,u=this.getScrollOffset()+this.scrollAdjustments,d=this.itemSizeCache.has(a)?i+s<=u&&this.scrollDirection!==`backward`:i<u,f=!nt(this.scrollState)&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?d:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:a,start:i,size:r,end:i+r,lane:0},c,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(a,t),this.itemSizeCacheVersion++;let p=this.scrollState?.writtenOffset!=null&&!q(this.scrollState.writtenOffset,this.getScrollOffset()+this.scrollAdjustments),m=!1;if(p||(o?m=this.applyScrollAdjustment(this.getTotalSize()-l):f&&(m=this.applyScrollAdjustment(c))),this._resizeBatch){this._resizeBatch.notify=!0,(n=this._resizeBatch).sync||(n.sync=m);return}this.notify(m),this._retryClampedAdjustment()}},this.getVirtualItems=K(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._singleLaneMeasurements?.flat,r=this.options.lanes===1&&n!=null;return Ve(t[ot(0,t.length-1,r?e=>n[e*2]:e=>Ve(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1){let e=this.getMaxScrollOffset(),n=e-this.options.paddingEnd+this.options.scrollPaddingEnd;return[Math.max(Math.min(n,e),0),t]}let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0;let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,startedAt:i,lastTargetOffset:r,stableFrames:0,phase:tt(n,!1)},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,startedAt:o,lastTargetOffset:i,stableFrames:0,phase:tt(n,q(i,this.getScrollOffset()))},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getOffsetForAlignment((this.scrollState?.writtenOffset??this.getScrollOffset())+e,`start`),r=this.now();this.scrollState={index:null,align:`start`,startedAt:r,lastTargetOffset:n,stableFrames:0,phase:tt(t,!1)},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this._iosDeferredAdjustment=0;let t=Math.max(this.getMaxScrollOffset(),0);this.scrollState={index:this.options.count-1,align:`end`,toEnd:!0,startedAt:this.now(),lastTargetOffset:t,stableFrames:0,phase:tt(e,q(t,this.getScrollOffset()))},this._scrollToOffset(t,{adjustments:void 0,behavior:e}),this.scheduleScrollReconcile()}else this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.cancelScroll=()=>{this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._singleLaneMeasurements?.flat;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.scrollState&&(this.scrollState.writtenOffset=n===`smooth`?null:this._intendedScrollOffset),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){if(e===0)return!1;if(We()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded))return this.scrollState?.index??(this._iosDeferredAdjustment+=e),!1;{let n=this.getScrollOffset()+this.scrollAdjustments+e,r=this.scrollElement,i=r!==null&&(`scrollHeight`in r||`document`in r)?this.getMaxScrollOffset():null;return this._clampedAdjustment=i!==null&&n>i+.5?{target:n,maxAtWrite:i}:null,this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0}}scheduleScrollReconcile(){this.targetWindow?this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}):this.scrollState=null}getScrollStateTarget(e){let t=e.toEnd?[Math.max(this.getMaxScrollOffset(),0)]:e.index==null?void 0:this.getOffsetForIndex(e.index,e.align);return t?t[0]:e.lastTargetOffset}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}this.getMeasurements();let e=this.getScrollStateTarget(this.scrollState),t=this.scrollState.index==null?1:this.options.useAnimationFrameWithResizeObserver?3:2,n=e!==this.scrollState.lastTargetOffset;if(!n&&q(e,this.getScrollOffset())){if(this.scrollState.phase===`smooth`?this.scrollState.phase=`smoothLanded`:this.scrollState.phase===`smoothFinishing`&&(this.scrollState.phase=`instant`),this.scrollState.stableFrames++,this.scrollState.stableFrames>=t){this.getScrollOffset()!==e&&this._scrollToOffset(e,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let t=this.getSize()||600,n=Math.abs(e-this.getScrollOffset()),r=nt(this.scrollState)&&n>t;this.scrollState.lastTargetOffset=e,r?this.scrollState.phase=`smooth`:this.scrollState.phase===`smooth`?this.scrollState.phase=`smoothFinishing`:this.scrollState.phase===`smoothLanded`&&(this.scrollState.phase=`instant`),this._scrollToOffset(e,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},ot=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function st(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function ct(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=st(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=ot(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var lt=typeof document<`u`?W.useLayoutEffect:W.useEffect;function ut({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=W.useReducer(e=>e+1,0)[1],a=W.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=W.useRef(!1),s=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},c=(e,t,n)=>{let r=a.current,i=!!e.options.horizontal,o=t.start-e.options.scrollMargin;r.lastPositions.get(n)!==o&&(r.lastPositions.set(n,o),r.mode===`transform`?n.style.transform=i?`translate3d(${o}px, 0, 0)`:`translate3d(0, ${o}px, 0)`:n.style[i?`left`:`top`]=`${o}px`)},l=e=>{let t=a.current;if(t.enabled&&t.container){s(e);for(let t of e.getVirtualItems()){let n=e.elementsCache.get(t.key);n&&c(e,t,n)}}},u={...r,onChange:(t,n)=>{var s;let c=a.current,u=!0;if(c.enabled){l(t);let e=t.range,n=c.prevRange;u=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,u&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}u&&(e&&n&&!o.current?(0,G.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[d]=W.useState(()=>{let e=new at(u),t=e.measureElement;return e.measureElement=n=>{o.current=!0;try{t(n)}finally{o.current=!1}let r=a.current;if(n!==null&&r.enabled&&r.container){let t=e.measurementsCache[e.indexFromElement(n)];t&&c(e,t,n)}},Object.assign(e,{containerRef:t=>{let n=a.current;n.container=t,n.lastSize=null,t!==null&&l(e)}})});return d.setOptions(u),lt(()=>d._didMount(),[]),lt(()=>(s(d),d._willUpdate())),lt(()=>{l(d)}),d}function dt(e){return ut({observeElementRect:Je,observeElementOffset:Qe,scrollToFn:et,...e})}function ft(e){let t=(0,W.useRef)({value:``,selectionStart:null,selectionEnd:null});return Fe(e,`blur`,e=>{let n=e.target;F(n)&&(t.current={value:n.value,selectionStart:n.selectionStart,selectionEnd:n.selectionEnd})}),z(()=>{if(!R(e)&&F(e)&&e.isConnected){if(e.focus({preventScroll:!0}),e.value!==t.current.value)e.setSelectionRange(e.value.length,e.value.length);else{let{selectionStart:n,selectionEnd:r}=t.current;n!==null&&r!==null&&e.setSelectionRange(n,r)}t.current={value:``,selectionStart:null,selectionEnd:null}}})}var pt=Object.defineProperty,mt=(e,t,n)=>t in e?pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ht=(e,t,n)=>(mt(e,typeof t==`symbol`?t:t+``,n),n),J=(e=>(e[e.Open=0]=`Open`,e[e.Closed=1]=`Closed`,e))(J||{}),Y=(e=>(e[e.Single=0]=`Single`,e[e.Multi=1]=`Multi`,e))(Y||{}),X=(e=>(e[e.Pointer=0]=`Pointer`,e[e.Focus=1]=`Focus`,e[e.Other=2]=`Other`,e))(X||{}),gt=(e=>(e[e.OpenCombobox=0]=`OpenCombobox`,e[e.CloseCombobox=1]=`CloseCombobox`,e[e.GoToOption=2]=`GoToOption`,e[e.SetTyping=3]=`SetTyping`,e[e.RegisterOption=4]=`RegisterOption`,e[e.UnregisterOption=5]=`UnregisterOption`,e[e.DefaultToFirstOption=6]=`DefaultToFirstOption`,e[e.SetActivationTrigger=7]=`SetActivationTrigger`,e[e.UpdateVirtualConfiguration=8]=`UpdateVirtualConfiguration`,e[e.SetInputElement=9]=`SetInputElement`,e[e.SetButtonElement=10]=`SetButtonElement`,e[e.SetOptionsElement=11]=`SetOptionsElement`,e[e.MarkInputAsMoved=12]=`MarkInputAsMoved`,e))(gt||{});function _t(e,t=e=>e){let n=e.activeOptionIndex===null?null:e.options[e.activeOptionIndex],r=t(e.options.slice()),i=r.length>0&&r[0].dataRef.current.order!==null?r.sort((e,t)=>e.dataRef.current.order-t.dataRef.current.order):De(r,e=>e.dataRef.current.domRef.current),a=n?i.indexOf(n):null;return a===-1&&(a=null),{options:i,activeOptionIndex:a}}var vt={1(e){var t;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===1)return e;let n=e.inputElement?O.Tracked(T(e.inputElement)):e.inputPositionState;return{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,inputPositionState:n,__demoMode:!1}},0(e){var t,n;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===0)return e;if((n=e.dataRef.current)!=null&&n.value){let t=e.dataRef.current.calculateIndex(e.dataRef.current.value);if(t!==-1)return{...e,activeOptionIndex:t,comboboxState:0,__demoMode:!1,inputPositionState:O.Idle}}return{...e,comboboxState:0,inputPositionState:O.Idle,__demoMode:!1}},3(e,t){return e.isTyping===t.isTyping?e:{...e,isTyping:t.isTyping}},2(e,t){var n,r;if((n=e.dataRef.current)!=null&&n.disabled||e.optionsElement&&!((r=e.dataRef.current)!=null&&r.optionsPropsRef.current.static)&&e.comboboxState===1)return e;if(e.virtual){let{options:n,disabled:r}=e.virtual,i=t.focus===_.Specific?t.idx:E(t,{resolveItems:()=>n,resolveActiveIndex:()=>e.activeOptionIndex??n.findIndex(e=>!r(e))??null,resolveDisabled:r,resolveId(){throw Error(`Function not implemented.`)}}),a=t.trigger??2;return e.activeOptionIndex===i&&e.activationTrigger===a?e:{...e,activeOptionIndex:i,activationTrigger:a,isTyping:!1,__demoMode:!1}}let i=_t(e);if(i.activeOptionIndex===null){let e=i.options.findIndex(e=>!e.dataRef.current.disabled);e!==-1&&(i.activeOptionIndex=e)}let a=t.focus===_.Specific?t.idx:E(t,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:e=>e.id,resolveDisabled:e=>e.dataRef.current.disabled}),o=t.trigger??2;return e.activeOptionIndex===a&&e.activationTrigger===o?e:{...e,...i,isTyping:!1,activeOptionIndex:a,activationTrigger:o,__demoMode:!1}},4:(e,t)=>{var n,r,i,a;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:[...e.options,t.payload]};let o=t.payload,s=_t(e,e=>(e.push(o),e));e.activeOptionIndex===null&&(i=(r=e.dataRef.current).isSelected)!=null&&i.call(r,t.payload.dataRef.current.value)&&(s.activeOptionIndex=s.options.indexOf(o));let c={...e,...s,activationTrigger:2};return(a=e.dataRef.current)!=null&&a.__demoMode&&e.dataRef.current.value===void 0&&(c.activeOptionIndex=0),c},5:(e,t)=>{var n;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:e.options.filter(e=>e.id!==t.id)};let r=_t(e,e=>{let n=e.findIndex(e=>e.id===t.id);return n!==-1&&e.splice(n,1),e});return{...e,...r,activationTrigger:2}},6:(e,t)=>e.defaultToFirstOption===t.value?e:{...e,defaultToFirstOption:t.value},7:(e,t)=>e.activationTrigger===t.trigger?e:{...e,activationTrigger:t.trigger},8:(e,t)=>{if(e.virtual===null)return{...e,virtual:{options:t.options,disabled:t.disabled??(()=>!1)}};if(e.virtual.options===t.options&&e.virtual.disabled===t.disabled)return e;let n=e.activeOptionIndex;if(e.activeOptionIndex!==null){let r=t.options.indexOf(e.virtual.options[e.activeOptionIndex]);n=r===-1?null:r}return{...e,activeOptionIndex:n,virtual:{options:t.options,disabled:t.disabled??(()=>!1)}}},9:(e,t)=>e.inputElement===t.element?e:{...e,inputElement:t.element},10:(e,t)=>e.buttonElement===t.element?e:{...e,buttonElement:t.element},11:(e,t)=>e.optionsElement===t.element?e:{...e,optionsElement:t.element},12(e){return e.inputPositionState.kind===`Tracked`?{...e,inputPositionState:O.Moved}:e}},yt=class e extends re{constructor(e){super(e),ht(this,`actions`,{onChange:e=>{let{onChange:t,compare:n,mode:r,value:i}=this.state.dataRef.current;return U(r,{0:()=>t?.(e),1:()=>{let r=i.slice(),a=r.findIndex(t=>n(t,e));return a===-1?r.push(e):r.splice(a,1),t?.(r)}})},registerOption:(e,t)=>(this.send({type:4,payload:{id:e,dataRef:t}}),()=>{this.state.activeOptionIndex===this.state.dataRef.current.calculateIndex(t.current.value)&&this.send({type:6,value:!0}),this.send({type:5,id:e})}),goToOption:(e,t)=>(this.send({type:6,value:!1}),this.send({type:2,...e,trigger:t})),setIsTyping:e=>{this.send({type:3,isTyping:e})},closeCombobox:()=>{var e,t;this.send({type:1}),this.send({type:6,value:!1}),(t=(e=this.state.dataRef.current).onClose)==null||t.call(e)},openCombobox:()=>{this.send({type:0}),this.send({type:6,value:!0})},setActivationTrigger:e=>{this.send({type:7,trigger:e})},selectActiveOption:()=>{let e=this.selectors.activeOptionIndex(this.state);if(e!==null){if(this.actions.setIsTyping(!1),this.state.virtual)this.actions.onChange(this.state.virtual.options[e]);else{let{dataRef:t}=this.state.options[e];this.actions.onChange(t.current.value)}this.actions.goToOption({focus:_.Specific,idx:e})}},setInputElement:e=>{this.send({type:9,element:e})},setButtonElement:e=>{this.send({type:10,element:e})},setOptionsElement:e=>{this.send({type:11,element:e})}}),ht(this,`selectors`,{activeDescendantId:e=>{let t=this.selectors.activeOptionIndex(e);if(t!==null)return e.virtual?e.options.find(n=>!n.dataRef.current.disabled&&e.dataRef.current.compare(n.dataRef.current.value,e.virtual.options[t]))?.id:e.options[t]?.id},activeOptionIndex:e=>{if(e.defaultToFirstOption&&e.activeOptionIndex===null&&(e.virtual?e.virtual.options.length>0:e.options.length>0)){if(e.virtual){let{options:t,disabled:n}=e.virtual,r=t.findIndex(e=>{var t;return!((t=n?.(e))!=null&&t)});if(r!==-1)return r}let t=e.options.findIndex(e=>!e.dataRef.current.disabled);if(t!==-1)return t}return e.activeOptionIndex},activeOption:e=>{let t=this.selectors.activeOptionIndex(e);return t===null?null:e.virtual?e.virtual.options[t??0]:e.options[t]?.dataRef.current.value??null},isActive:(e,t,n)=>{let r=this.selectors.activeOptionIndex(e);return r===null?!1:e.virtual?r===e.dataRef.current.calculateIndex(t):e.options[r]?.id===n},shouldScrollIntoView:(e,t,n)=>!(e.virtual||e.__demoMode||e.comboboxState!==0||e.activationTrigger===0||!this.selectors.isActive(e,t,n)),didInputMove(e){return e.inputPositionState.kind===`Moved`}});{let e=this.state.id,t=oe.get(null);this.disposables.add(t.on(ae.Push,n=>{!t.selectors.isTop(n,e)&&this.state.comboboxState===0&&this.actions.closeCombobox()})),this.on(0,()=>t.actions.push(e)),this.on(1,()=>t.actions.pop(e))}this.disposables.group(e=>{this.on(1,t=>{t.inputElement&&(e.dispose(),e.add(S(t.inputElement,t.inputPositionState,()=>{this.send({type:12})})))})})}static new({id:t,virtual:n=null,__demoMode:r=!1}){return new e({id:t,dataRef:{current:{}},comboboxState:+!r,isTyping:!1,options:[],virtual:n?{options:n.options,disabled:n.disabled??(()=>!1)}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:r,inputPositionState:O.Idle})}reduce(e,t){return U(t.type,vt,e,t)}},bt=(0,W.createContext)(null);function xt(e){let t=(0,W.useContext)(bt);if(t===null){let t=Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,St),t}return t}function St({id:e,virtual:t=null,__demoMode:n=!1}){let r=(0,W.useMemo)(()=>yt.new({id:e,virtual:t,__demoMode:n}),[]);return be(()=>r.dispose()),r}var Ct=(0,W.createContext)(null);Ct.displayName=`ComboboxDataContext`;function Z(e){let t=(0,W.useContext)(Ct);if(t===null){let t=Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,Z),t}return t}var wt=(0,W.createContext)(null);function Tt(e){let t=xt(`VirtualProvider`),{options:n}=Z(`VirtualProvider`).virtual,r=L(t,e=>e.optionsElement),[i,a]=(0,W.useMemo)(()=>{let e=r;if(!e)return[0,0];let t=window.getComputedStyle(e);return[parseFloat(t.paddingBlockStart||t.paddingTop),parseFloat(t.paddingBlockEnd||t.paddingBottom)]},[r]),o=dt({enabled:n.length!==0,scrollPaddingStart:i,scrollPaddingEnd:a,count:n.length,estimateSize(){return 40},getScrollElement(){return t.state.optionsElement},overscan:12}),[s,c]=(0,W.useState)(0);H(()=>{c(e=>e+1)},[n]);let l=o.getVirtualItems(),u=L(t,e=>e.activationTrigger===X.Pointer),d=L(t,t.selectors.activeOptionIndex);return l.length===0?null:W.createElement(wt.Provider,{value:o},W.createElement(`div`,{style:{position:`relative`,width:`100%`,height:`${o.getTotalSize()}px`},ref:e=>{e&&(u||d!==null&&n.length>d&&o.scrollToIndex(d))}},l.map(t=>W.createElement(W.Fragment,{key:t.key},W.cloneElement(e.children?.call(e,{...e.slot,option:n[t.index]}),{key:`${s}-${t.key}`,"data-index":t.index,"aria-setsize":n.length,"aria-posinset":t.index+1,style:{position:`absolute`,top:0,left:0,transform:`translateY(${t.start}px)`,overflowAnchor:`none`}})))))}var Et=W.Fragment;function Dt(e,t){let n=(0,te.useId)(),r=he(),{value:i,defaultValue:a,onChange:o,form:s,name:c,by:l,invalid:u=!1,disabled:d=r||!1,onClose:f,__demoMode:p=!1,multiple:h=!1,immediate:g=!1,virtual:_=null,nullable:v,...y}=e,b=Ae(a),[x=h?[]:void 0,S]=Ne(i,o,b),C=St({id:n,virtual:_,__demoMode:p}),w=(0,W.useRef)({static:!1,hold:!1}),T=Me(l),E=z(e=>_?l===null?_.options.indexOf(e):_.options.findIndex(t=>T(t,e)):C.state.options.findIndex(t=>T(t.dataRef.current.value,e))),D=(0,W.useCallback)(e=>U(j.mode,{[Y.Multi]:()=>x.some(t=>T(t,e)),[Y.Single]:()=>T(x,e)}),[x]),O=L(C,e=>e.virtual),A=z(()=>f?.()),j=(0,W.useMemo)(()=>({__demoMode:p,immediate:g,optionsPropsRef:w,value:x,defaultValue:b,disabled:d,invalid:u,mode:h?Y.Multi:Y.Single,virtual:_?O:null,onChange:S,isSelected:D,calculateIndex:E,compare:T,onClose:A}),[p,g,w,x,b,d,u,h,_,O,S,D,E,T,A]);H(()=>{_&&C.send({type:gt.UpdateVirtualConfiguration,options:_.options,disabled:_.disabled??null})},[_,_?.options,_?.disabled]),H(()=>{C.state.dataRef.current=j},[j]);let[M,ee,N,ne]=L(C,e=>[e.comboboxState,e.buttonElement,e.inputElement,e.optionsElement]),P=oe.get(null),re=L(P,(0,W.useCallback)(e=>P.selectors.isTop(e,n),[P,n]));fe(re,[ee,N,ne],()=>C.actions.closeCombobox());let ie=L(C,C.selectors.activeOptionIndex),F=L(C,C.selectors.activeOption),I=Te({open:M===J.Open,disabled:d,invalid:u,activeIndex:ie,activeOption:F,value:x}),[ae,se]=m(),R=t===null?{}:{ref:t},le=(0,W.useCallback)(()=>{if(b!==void 0)return S?.(b)},[S,b]),B=ye();return W.createElement(se,{value:ae,props:{htmlFor:N?.id},slot:{open:M===J.Open,disabled:d}},W.createElement(k,null,W.createElement(Ct.Provider,{value:j},W.createElement(bt.Provider,{value:C},W.createElement(Ce,{value:U(M,{[J.Open]:ce.Open,[J.Closed]:ce.Closed})},c!=null&&W.createElement(ke,{disabled:d,data:x==null?{}:{[c]:x},form:s,onReset:le}),B({ourProps:R,theirProps:y,slot:I,defaultTag:Et,name:`Combobox`}))))))}var Ot=`input`;function kt(e,t){let n=xt(`Combobox.Input`),r=Z(`Combobox.Input`),i=(0,te.useId)(),a=M(),{id:o=a||`headlessui-combobox-input-${i}`,onChange:s,displayValue:c,disabled:l=r.disabled||!1,autoFocus:u=!1,type:d=`text`,...m}=e,h=(0,W.useRef)(null),g=se(h,t,v(),n.actions.setInputElement),[y,b]=L(n,e=>[e.comboboxState,e.isTyping]),x=_e(),S=z(()=>{n.actions.onChange(null),n.state.optionsElement&&(n.state.optionsElement.scrollTop=0),n.actions.goToOption({focus:_.Nothing})}),C=(0,W.useMemo)(()=>typeof c==`function`&&r.value!==void 0?c(r.value)??``:typeof r.value==`string`?r.value:``,[r.value,c]);Pe(([e,t],[r,i])=>{if(n.state.isTyping)return;let a=h.current;a&&((i===J.Open&&t===J.Closed||e!==r)&&(a.value=e),requestAnimationFrame(()=>{if(n.state.isTyping||!a||R(a))return;let{selectionStart:e,selectionEnd:t}=a;Math.abs((t??0)-(e??0))===0&&e===0&&a.setSelectionRange(a.value.length,a.value.length)}))},[C,y,b]),Pe(([e],[t])=>{if(e===J.Open&&t===J.Closed){if(n.state.isTyping)return;let e=h.current;if(!e)return;let t=e.value,{selectionStart:r,selectionEnd:i,selectionDirection:a}=e;e.value=``,e.value=t,a===null?e.setSelectionRange(r,i):e.setSelectionRange(r,i,a)}},[y]);let w=(0,W.useRef)(!1),T=z(()=>{w.current=!0}),E=z(()=>{x.nextFrame(()=>{w.current=!1})}),D=z(e=>{switch(n.actions.setIsTyping(!0),e.key){case I.Enter:if(n.state.comboboxState!==J.Open||w.current)return;if(e.preventDefault(),e.stopPropagation(),n.selectors.activeOptionIndex(n.state)===null){n.actions.closeCombobox();return}n.actions.selectActiveOption(),r.mode===Y.Single&&n.actions.closeCombobox();break;case I.ArrowDown:return e.preventDefault(),e.stopPropagation(),U(n.state.comboboxState,{[J.Open]:()=>n.actions.goToOption({focus:_.Next}),[J.Closed]:()=>n.actions.openCombobox()});case I.ArrowUp:return e.preventDefault(),e.stopPropagation(),U(n.state.comboboxState,{[J.Open]:()=>n.actions.goToOption({focus:_.Previous}),[J.Closed]:()=>{(0,G.flushSync)(()=>n.actions.openCombobox()),r.value||n.actions.goToOption({focus:_.Last})}});case I.Home:if(n.state.comboboxState===J.Closed||e.shiftKey)break;return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:_.First});case I.PageUp:return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:_.First});case I.End:if(n.state.comboboxState===J.Closed||e.shiftKey)break;return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:_.Last});case I.PageDown:return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:_.Last});case I.Escape:return n.state.comboboxState===J.Open?(e.preventDefault(),n.state.optionsElement&&!r.optionsPropsRef.current.static&&e.stopPropagation(),r.mode===Y.Single&&r.value===null&&S(),n.actions.closeCombobox()):void 0;case I.Tab:if(n.actions.setIsTyping(!1),n.state.comboboxState!==J.Open)return;r.mode===Y.Single&&n.state.activationTrigger!==X.Focus&&n.actions.selectActiveOption(),n.actions.closeCombobox()}}),O=z(e=>{s?.(e),r.mode===Y.Single&&e.target.value===``&&S(),n.actions.openCombobox()}),k=z(e=>{var t,i;let a=e.relatedTarget??Ie.find(t=>t!==e.currentTarget);if(!((t=n.state.optionsElement)!=null&&t.contains(a))&&!((i=n.state.buttonElement)!=null&&i.contains(a))&&n.state.comboboxState===J.Open)return e.preventDefault(),r.mode===Y.Single&&r.value===null&&S(),n.actions.closeCombobox()}),A=z(e=>{var t,i;let a=e.relatedTarget??Ie.find(t=>t!==e.currentTarget);(t=n.state.buttonElement)!=null&&t.contains(a)||(i=n.state.optionsElement)!=null&&i.contains(a)||r.disabled||r.immediate&&n.state.comboboxState!==J.Open&&x.microTask(()=>{(0,G.flushSync)(()=>n.actions.openCombobox()),n.actions.setActivationTrigger(X.Focus)})}),j=ee(),N=P(),{isFocused:ne,focusProps:re}=f({autoFocus:u}),{isHovered:ie,hoverProps:F}=p({isDisabled:l}),ae=L(n,e=>e.optionsElement),oe=Te({open:y===J.Open,disabled:l,invalid:r.invalid,hover:ie,focus:ne,autofocus:u}),ce=Se({ref:g,id:o,role:`combobox`,type:d,"aria-controls":ae?.id,"aria-expanded":y===J.Open,"aria-activedescendant":L(n,n.selectors.activeDescendantId),"aria-labelledby":j,"aria-describedby":N,"aria-autocomplete":`list`,defaultValue:e.defaultValue??(r.defaultValue===void 0?null:c?.(r.defaultValue))??r.defaultValue,disabled:l||void 0,autoFocus:u,onCompositionStart:T,onCompositionEnd:E,onKeyDown:D,onChange:O,onFocus:A,onBlur:k},re,F);return ye()({ourProps:ce,theirProps:m,slot:oe,defaultTag:Ot,name:`Combobox.Input`})}var At=`button`;function jt(e,t){let n=xt(`Combobox.Button`),r=Z(`Combobox.Button`),[i,a]=(0,W.useState)(null),o=se(t,a,n.actions.setButtonElement),s=(0,te.useId)(),{id:c=`headlessui-combobox-button-${s}`,disabled:l=r.disabled||!1,autoFocus:u=!1,...d}=e,[m,v,y]=L(n,e=>[e.comboboxState,e.inputElement,e.optionsElement]),S=ft(v),C=m===J.Open;x(C,{trigger:i,action:(0,W.useCallback)(e=>{if(i!=null&&i.contains(e.target)||v!=null&&v.contains(e.target))return b.Ignore;let t=e.target.closest(`[role="option"]:not([data-disabled])`);return ie(t)?b.Select(t):y!=null&&y.contains(e.target)?b.Ignore:b.Close},[i,v,y]),close:n.actions.closeCombobox,select:n.actions.selectActiveOption});let T=z(e=>{switch(e.key){case I.Space:case I.Enter:e.preventDefault(),e.stopPropagation(),n.state.comboboxState===J.Closed&&(0,G.flushSync)(()=>n.actions.openCombobox()),S();return;case I.ArrowDown:e.preventDefault(),e.stopPropagation(),n.state.comboboxState===J.Closed&&((0,G.flushSync)(()=>n.actions.openCombobox()),n.state.dataRef.current.value||n.actions.goToOption({focus:_.First})),S();return;case I.ArrowUp:e.preventDefault(),e.stopPropagation(),n.state.comboboxState===J.Closed&&((0,G.flushSync)(()=>n.actions.openCombobox()),n.state.dataRef.current.value||n.actions.goToOption({focus:_.Last})),S();return;case I.Escape:if(n.state.comboboxState!==J.Open)return;e.preventDefault(),n.state.optionsElement&&!r.optionsPropsRef.current.static&&e.stopPropagation(),(0,G.flushSync)(()=>n.actions.closeCombobox()),S();return;default:return}}),E=g(()=>{n.state.comboboxState===J.Open?n.actions.closeCombobox():n.actions.openCombobox(),S()}),D=ee([c]),{isFocusVisible:O,focusProps:k}=f({autoFocus:u}),{isHovered:A,hoverProps:j}=p({isDisabled:l}),{pressed:M,pressProps:N}=h({disabled:l}),ne=Te({open:m===J.Open,active:M||m===J.Open,disabled:l,invalid:r.invalid,value:r.value,hover:A,focus:O}),P=Se({ref:o,id:c,type:w(e,i),tabIndex:-1,"aria-haspopup":`listbox`,"aria-controls":y?.id,"aria-expanded":m===J.Open,"aria-labelledby":D,disabled:l||void 0,autoFocus:u,onKeyDown:T},E,k,j,N);return ye()({ourProps:P,theirProps:d,slot:ne,defaultTag:At,name:`Combobox.Button`})}var Mt=`div`,Nt=B.RenderStrategy|B.Static;function Pt(e,t){let n=(0,te.useId)(),{id:r=`headlessui-combobox-options-${n}`,hold:i=!1,anchor:a,portal:o=!1,modal:s=!0,transition:c=!1,...l}=e,u=xt(`Combobox.Options`),d=Z(`Combobox.Options`),f=y(a);f&&(o=!0);let[p,m]=C(f),[h,g]=(0,W.useState)(null),_=A(),v=se(t,f?p:null,u.actions.setOptionsElement,g),[b,x,S,w,T]=L(u,e=>[e.comboboxState,e.inputElement,e.buttonElement,e.optionsElement,e.activationTrigger]),E=ge(x||S),D=ge(w),O=we(),[k,j]=le(c,h,O===null?b===J.Open:(O&ce.Open)===ce.Open);me(k,x,u.actions.closeCombobox);let M=!d.__demoMode&&s&&b===J.Open;xe(M,D);let P=!d.__demoMode&&s&&b===J.Open;ne(P,{allowed:(0,W.useCallback)(()=>[x,S,w],[x,S,w])});let re=!L(u,u.selectors.didInputMove)&&k;H(()=>{d.optionsPropsRef.current.static=e.static??!1},[d.optionsPropsRef,e.static]),H(()=>{d.optionsPropsRef.current.hold=i},[d.optionsPropsRef,i]),Le(b===J.Open,{container:w,accept(e){return e.getAttribute(`role`)===`option`?NodeFilter.FILTER_REJECT:e.hasAttribute(`role`)?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(e){e.setAttribute(`role`,`none`)}});let ie=ee([S?.id]),F=Te({open:b===J.Open,option:void 0}),I=z(()=>{u.actions.setActivationTrigger(X.Pointer)}),ae=z(e=>{e.preventDefault(),u.actions.setActivationTrigger(X.Pointer)}),oe=Se(f?_():{},{"aria-labelledby":ie,role:`listbox`,"aria-multiselectable":d.mode===Y.Multi||void 0,id:r,ref:v,style:{...l.style,...m,"--input-width":N(k,x,!0).width,"--button-width":N(k,S,!0).width},onWheel:T===X.Pointer?void 0:I,onMouseDown:ae,...ue(j)}),R=k&&b===J.Closed&&!e.static,B=je(R,d.virtual?.options),de=je(R,d.value),fe=(0,W.useCallback)(e=>d.compare(de,e),[d.compare,de]),pe=(0,W.useMemo)(()=>{if(!d.virtual)return d;if(B===void 0)throw Error("Missing `options` in virtual mode");return B===d.virtual.options?d:{...d,virtual:{...d.virtual,options:B}}},[d,B,d.virtual?.options]);d.virtual&&Object.assign(l,{children:W.createElement(Ct.Provider,{value:pe},W.createElement(Tt,{slot:F},l.children))});let V=ye(),he=(0,W.useMemo)(()=>d.mode===Y.Multi?d:{...d,isSelected:fe},[d,fe]);return W.createElement(ve,{enabled:o?e.static||k:!1,ownerDocument:E},W.createElement(Ct.Provider,{value:he},V({ourProps:oe,theirProps:{...l,children:W.createElement(Oe,{freeze:R},typeof l.children==`function`?l.children?.call(l,F):l.children)},slot:F,defaultTag:Mt,features:Nt,visible:re,name:`Combobox.Options`})))}var Ft=`div`;function It(e,t){var n;let r=Z(`Combobox.Option`),i=xt(`Combobox.Option`),a=(0,te.useId)(),{id:o=`headlessui-combobox-option-${a}`,value:s,disabled:c=((n=r.virtual)?.disabled)?.call(n,s)??!1,order:l=null,...u}=e,[d]=L(i,e=>[e.inputElement]),f=ft(d),p=L(i,(0,W.useCallback)(e=>i.selectors.isActive(e,s,o),[s,o])),m=r.isSelected(s),h=(0,W.useRef)(null),g=de({disabled:c,value:s,domRef:h,order:l}),v=(0,W.useContext)(wt),y=se(t,h,v?v.measureElement:null),b=z(()=>{i.actions.setIsTyping(!1),i.actions.onChange(s)});H(()=>i.actions.registerOption(o,g),[g,o]);let x=L(i,(0,W.useCallback)(e=>i.selectors.shouldScrollIntoView(e,s,o),[s,o]));H(()=>{if(x)return pe().requestAnimationFrame(()=>{var e,t;(t=(e=h.current)?.scrollIntoView)==null||t.call(e,{block:`nearest`})})},[x,h]);let S=z(e=>{e.preventDefault(),e.button===j.Left&&(c||(b(),Ee()||requestAnimationFrame(()=>f()),r.mode===Y.Single&&i.actions.closeCombobox()))}),C=z(()=>{if(c)return i.actions.goToOption({focus:_.Nothing});let e=r.calculateIndex(s);i.actions.goToOption({focus:_.Specific,idx:e})}),w=D(),T=z(e=>w.update(e)),E=z(e=>{if(!w.wasMoved(e)||c||p&&i.state.activationTrigger===X.Pointer)return;let t=r.calculateIndex(s);i.actions.goToOption({focus:_.Specific,idx:t},X.Pointer)}),O=z(e=>{w.wasMoved(e)&&(c||p&&(r.optionsPropsRef.current.hold||i.state.activationTrigger===X.Pointer&&i.actions.goToOption({focus:_.Nothing})))}),k=Te({active:p,focus:p,selected:m,disabled:c}),A={id:o,ref:y,role:`option`,tabIndex:c===!0?void 0:-1,"aria-disabled":c===!0||void 0,"aria-selected":m,disabled:void 0,onMouseDown:S,onFocus:C,onPointerEnter:T,onMouseEnter:T,onPointerMove:E,onMouseMove:E,onPointerLeave:O,onMouseLeave:O};return ye()({ourProps:A,theirProps:u,slot:k,defaultTag:Ft,name:`Combobox.Option`})}var Lt=V(Dt),Rt=V(jt),zt=V(kt),Bt=d,Vt=V(Pt),Ht=V(It),Ut=Object.assign(Lt,{Input:zt,Button:Rt,Label:Bt,Options:Vt,Option:Ht});r.map(e=>({value:e.id,label:e.label,casesFolder:e.casesFolder,templateFolder:e.templateFolder}));function Q(){let e=c().caseTypes;return e?.length?e.map(e=>({...e})):r.map(e=>({...e}))}function Wt(e){let t=Q();return t.find(t=>t.id===e)??t[0]??r[0]}function Gt(e){let t=i(e);return u({caseTypes:t}),l(),t}function Kt(e){let t=e.trim();if(!t)throw Error(`类型名称不能为空`);if(t.length>40)throw Error(`类型名称过长(最多 40 字)`);let n=Q();if(n.some(e=>e.label===t))throw Error(`已存在「${t}」`);let r=a(t),i={id:s(),label:t,...r};return Gt([...n,i]),i}function qt(e,t){let n=t.trim();if(!n)throw Error(`类型名称不能为空`);if(n.length>40)throw Error(`类型名称过长(最多 40 字)`);let r=Q(),i=r.findIndex(t=>t.id===e);if(i<0)throw Error(`类型不存在`);if(r.some(t=>t.id!==e&&t.label===n))throw Error(`已存在「${n}」`);let o=a(n),s={...r[i],label:n,...o},c=[...r];return c[i]=s,Gt(c),s}function Jt(e){let t=Q();if(t.length<=1)throw Error(`至少保留一个用例类型`);if(!t.some(t=>t.id===e))throw Error(`类型不存在`);return Gt(t.filter(t=>t.id!==e))}var Yt=`/__tb_case_sessions`,Xt=`tw.case.sessions.v1`,Zt=!1;function Qt(){return`csess_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function $t(e){if(typeof e==`string`&&e.trim()){let t=e.trim();return Q().some(e=>e.id===t),t}return Q()[0]?.id??`functional`}function en(e){if(!e||!Array.isArray(e.sessions))return{sessions:[],activeId:``};let t=e.sessions.filter(e=>e&&typeof e==`object`&&e.id).map(e=>({...e,caseType:$t(e.caseType)})),n=typeof e.activeId==`string`?e.activeId:``;return t.length&&!t.some(e=>e.id===n)&&(n=t[0].id),t.length||(n=``),{sessions:t,activeId:n}}function tn(){try{let e=localStorage.getItem(o(Xt));return e?en(JSON.parse(e)):{sessions:[],activeId:``}}catch{return{sessions:[],activeId:``}}}function nn(e){try{localStorage.setItem(o(Xt),JSON.stringify(e))}catch{}}async function rn(){try{let e=await fetch(Yt,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json();Zt=!0;let n=en(t.store);return nn(n),n}}catch{}return Zt=!1,tn()}function an(){return tn()}async function on(e){if(nn(e),Zt)try{await fetch(Yt,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({store:e})})}catch{}}function sn(e){nn(e),on(e)}function cn(e){let t=Date.now(),n={id:Qt(),title:e.title?.trim()||`用例生成`,createdAt:t,updatedAt:t,caseType:e.caseType,outputFormat:e.outputFormat,reqPaths:e.reqPaths,templateId:e.templateId,templateTitle:e.templateTitle,promptPath:e.promptPath,knowledgePaths:e.knowledgePaths?.length?[...e.knowledgePaths]:void 0,messages:[]};return sn({sessions:[n,...tn().sessions],activeId:n.id}),n}function ln(e,t){let n=tn(),r=n.sessions.map(n=>n.id===e?{...n,...t,updatedAt:Date.now()}:n),i={...n,sessions:r};return sn(i),i}var $=Re();function un({options:e,values:t,onChange:n,placeholder:r=`选择…`,disabled:i=!1}){let[a,o]=(0,W.useState)(!1),s=(0,W.useRef)(null);(0,W.useEffect)(()=>{if(!a)return;function e(e){s.current?.contains(e.target)||o(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]);let c=e.filter(e=>t.includes(e.value)).map(e=>e.label),l=i||c.length===0?r:c.length<=2?c.join(`、`):`已选 ${c.length} 项`;function u(e){t.includes(e)?n(t.filter(t=>t!==e)):n([...t,e])}return(0,$.jsxs)(`div`,{className:`relative mt-1`,ref:s,children:[(0,$.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>o(e=>!e),className:i?`w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-stone-50 px-3 text-sm text-left text-stone-400 cursor-not-allowed`:`w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-white px-3 text-sm text-left text-stone-800 outline-none hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30`,children:[(0,$.jsx)(`span`,{className:`truncate ${i||c.length?``:`text-stone-400`}`,children:l}),(0,$.jsx)(`svg`,{className:`w-4 h-4 text-stone-400 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,$.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})]}),a?(0,$.jsx)(`div`,{className:`tw-select-menu tw-popover-anim absolute z-80 mt-1 max-h-56 w-full overflow-auto rounded-lg p-1 shadow-lg ring-1 ring-stone-200`,children:e.length===0?(0,$.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`暂无可选项`}):e.map(e=>{let n=t.includes(e.value);return(0,$.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-3 py-2 text-sm text-stone-700 cursor-pointer hover:bg-stone-50`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>u(e.value),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]},e.value)})}):null]})}function dn({options:e,value:t,onChange:n,placeholder:r=`搜索并选择…`,disabled:i=!1,allowEmpty:a=!0,emptyLabel:o=`不选择`}){let[s,c]=(0,W.useState)(``),l=(0,W.useMemo)(()=>{let t=s.trim().toLowerCase();return t?e.filter(e=>e.label.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)):e},[e,s]),u=e.find(e=>e.value===t)??null;return i?(0,$.jsx)(`div`,{className:`relative mt-1`,children:(0,$.jsxs)(`button`,{type:`button`,disabled:!0,className:`w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-stone-50 px-3 text-sm text-left text-stone-400 cursor-not-allowed`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:r}),(0,$.jsx)(`svg`,{className:`w-4 h-4 text-stone-400 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,$.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})]})}):(0,$.jsx)(Ut,{value:u,onChange:e=>{n(e?.value??``),c(``)},immediate:!0,children:(0,$.jsxs)(`div`,{className:`relative mt-1`,children:[(0,$.jsx)(zt,{className:`w-full h-9 rounded-lg border border-stone-200 bg-white px-3 pr-8 text-sm outline-none cursor-text placeholder:text-stone-400 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6]`,displayValue:e=>e?.label??``,onChange:e=>c(e.target.value),placeholder:r}),(0,$.jsx)(Rt,{className:`absolute inset-y-0 right-0 flex items-center pr-2 text-stone-400 cursor-pointer`,children:(0,$.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,$.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})}),(0,$.jsxs)(Vt,{transition:!0,anchor:{to:`bottom start`,gap:4},className:`tw-select-menu tw-menu-anim z-80 max-h-56 w-(--input-width) overflow-auto rounded-lg p-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:[a?(0,$.jsx)(Ht,{value:null,className:`cursor-pointer select-none rounded-md px-3 py-2 text-sm text-stone-400 data-[focus]:bg-stone-50`,children:o}):null,l.length===0?(0,$.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`无匹配项`}):l.map(e=>(0,$.jsx)(Ht,{value:e,className:`cursor-pointer select-none rounded-md px-3 py-2 text-sm text-stone-700 data-[focus]:bg-stone-50 data-[selected]:font-medium`,children:e.label},e.value))]})]})})}export{an as a,Kt as c,Jt as d,qt as f,rn as i,Wt as l,un as n,sn as o,cn as r,ln as s,dn as t,Q as u};
@@ -1 +0,0 @@
1
- import{i as e,n as t,r as n,t as r}from"./listbox.Di-t5U37.js";import{t as i}from"./jsx-runtime.BUXbF_vF.js";var a=i();function o({className:e=`w-4 h-4 text-stone-400 shrink-0`}){return(0,a.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,a.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})}function s(){return(0,a.jsx)(`svg`,{className:`w-4 h-4 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":!0,children:(0,a.jsx)(`path`,{fillRule:`evenodd`,d:`M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z`,clipRule:`evenodd`})})}function c({options:i,value:c,onChange:l,disabled:u=!1,className:d=``,compact:f=!1,ariaLabel:p,showCheck:m=!1,centerContent:h=!1,unstyled:g=!1,triggerClassName:_=``,hideChevron:v=!1,flat:y=!1,menuMinWidth:b,menuMatchTrigger:x=!0,renderTrigger:S,renderOptionPrefix:C}){let w=i.find(e=>e.value===c),T=h?`relative justify-center`:`justify-between`,E=h?`w-4 h-4 text-stone-400 shrink-0 absolute right-2.5`:void 0,D=g?`w-full flex items-center cursor-pointer outline-none disabled:cursor-not-allowed`:f?`w-full h-8 flex items-center gap-1.5 rounded-lg border border-stone-300 bg-white px-2.5 text-sm text-left text-stone-700 outline-none cursor-pointer hover:border-stone-400 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`:y?`w-full h-9 flex items-center gap-2 rounded-lg border border-stone-200 bg-white px-2.5 text-sm text-left text-stone-700 outline-none cursor-pointer hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`:`w-full h-9 flex items-center gap-2 rounded-lg border border-stone-200 bg-white px-3 text-sm text-left text-stone-800 outline-none cursor-pointer hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`;return(0,a.jsx)(n,{value:c,onChange:l,disabled:u,children:(0,a.jsxs)(`div`,{className:`relative ${g?``:f?`inline-block`:y?``:`mt-1`} ${d}`,children:[(0,a.jsxs)(e,{"aria-label":p,className:`${D} ${T} ${_}`,children:[S?S(w):(0,a.jsx)(`span`,{className:`truncate`,children:w?.label??c}),v?null:(0,a.jsx)(o,{className:E})]}),(0,a.jsx)(r,{transition:!0,anchor:{to:`bottom start`,gap:4,padding:12},style:!x&&b?{minWidth:b}:void 0,className:`tw-select-menu tw-menu-anim z-80 max-h-64 space-y-1 overflow-auto rounded-lg p-1 pb-2 shadow-lg ring-1 ring-stone-200 [--anchor-max-height:16rem] focus:outline-none ${x?`w-max min-w-(--button-width)`:`w-max min-w-[150px] max-w-[320px]`}`,children:i.map(e=>(0,a.jsxs)(t,{value:e.value,className:`group cursor-pointer select-none flex items-center gap-2 rounded-md px-3 py-2 text-sm leading-5 data-[focus]:bg-stone-50 data-[selected]:bg-(--tw-accent-soft) ${m?`text-stone-700 data-[selected]:text-stone-900`:`data-[selected]:text-(--tw-accent) data-[selected]:font-medium`} ${h&&!m&&!C?`justify-center px-2`:``}`,children:[m?(0,a.jsx)(`span`,{className:`w-4 shrink-0 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100`,children:(0,a.jsx)(s,{})}):C?(0,a.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:C(e)}):null,(0,a.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label})]},e.value))})]})})}export{c as t};
@@ -1 +0,0 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{a as n,i as r,n as i,s as ee}from"./app-config.DUyozIL9.js";import{i as te,n as ne,r as re,t as ie}from"./listbox.Di-t5U37.js";import{a as ae,o as oe}from"./dialog.DXHznyjD.js";import{t as a}from"./jsx-runtime.BUXbF_vF.js";import{t as se}from"./ConfirmDialog.CBVsDJ8f.js";import{i as ce}from"./llm.BZEzE0x2.js";import{_ as le,a as ue,c as de,d as fe,g as pe,h as me,i as he,l as o,n as s,o as ge,r as _e,s as ve,t as ye,u as be,v as xe}from"./settings.C6NWuiFO.js";import{n as c}from"./i18n.B52gLzii.js";import{n as Se,r as Ce,t as l}from"./update.Bl_HfSe6.js";var u=e(t(),1),d=a();function we(e){try{return new URL(e).host}catch{return``}}var Te=[{value:`zh-CN`,label:`中文`},{value:`en`,label:`English`}],f=`w-full px-3 py-2 text-sm border border-stone-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-[#4176e6]/35 focus:border-[#4176e6] transition-colors`,p=`inline-flex items-center gap-1.5 h-9 min-w-30 px-3 rounded-lg bg-stone-100 text-sm text-stone-700 hover:bg-stone-200/80 transition-colors outline-none focus:outline-none`;function Ee({className:e=`w-3.5 h-3.5`}){return(0,d.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:(0,d.jsx)(`path`,{d:`M6 8l4 4 4-4`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function De({className:e=`w-4 h-4`}){return(0,d.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,d.jsx)(`path`,{d:`M5 10.5l3.5 3.5L15 6.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function Oe({className:e=`w-4 h-4`}){return(0,d.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,d.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,d.jsx)(`path`,{d:`M12 1v2M12 21v2M4.2 4.2l1.4 1.4M18.4 18.4l1.4 1.4M1 12h2M21 12h2M4.2 19.8l1.4-1.4M18.4 5.6l1.4-1.4`})]})}function ke({className:e=`w-4 h-4`}){return(0,d.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,d.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,d.jsx)(`path`,{d:`M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5`}),(0,d.jsx)(`path`,{d:`M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]})}function Ae({kind:e}){let t=`w-5 h-5`;return e===`sun`?(0,d.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,d.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,d.jsx)(`path`,{d:`M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`})]}):e===`moon`?(0,d.jsx)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,d.jsx)(`path`,{d:`M21 14.5A8.5 8.5 0 1 1 9.5 3a7 7 0 0 0 11.5 11.5z`})}):(0,d.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,d.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`12`,rx:`2`}),(0,d.jsx)(`path`,{d:`M8 20h8M12 16v4`})]})}function m({title:e,description:t,control:n}){return(0,d.jsxs)(`div`,{className:`flex items-center gap-4 py-4 border-b border-stone-100 last:border-b-0`,children:[(0,d.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,d.jsx)(`div`,{className:`text-sm font-medium text-stone-800`,children:e}),t?(0,d.jsx)(`div`,{className:`mt-0.5 text-xs text-stone-400 leading-5`,children:t}):null]}),(0,d.jsx)(`div`,{className:`shrink-0`,children:n})]})}function h({value:e,options:t,onChange:n}){let r=t.find(t=>t.value===e)?.label??e;return(0,d.jsxs)(re,{value:e,onChange:n,children:[(0,d.jsxs)(te,{className:p,children:[(0,d.jsx)(`span`,{className:`flex-1 text-left truncate`,children:r}),(0,d.jsx)(Ee,{className:`w-3.5 h-3.5 text-stone-400 shrink-0`})]}),(0,d.jsx)(ie,{transition:!0,anchor:{to:`bottom end`,gap:6},className:`tw-select-menu tw-menu-anim z-60 min-w-40 rounded-xl py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:t.map(e=>(0,d.jsxs)(ne,{value:e.value,className:`group cursor-pointer select-none flex items-center justify-between gap-3 px-3 py-2 text-sm text-stone-700 data-[focus]:bg-stone-50 data-[selected]:text-stone-900`,children:[(0,d.jsx)(`span`,{children:e.label}),(0,d.jsx)(De,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0`})]},e.value))})]})}function g(){let[e,t]=(0,u.useState)(!1),[a,p]=(0,u.useState)(`general`),[g,je]=(0,u.useState)([]),[Me,_]=(0,u.useState)(``),[v,y]=(0,u.useState)(null),[b,x]=(0,u.useState)(``),[Ne,Pe]=(0,u.useState)(`DeepSeek`),[S,C]=(0,u.useState)(``),[w,T]=(0,u.useState)(``),[E,D]=(0,u.useState)(``),[O,Fe]=(0,u.useState)([]),[k,A]=(0,u.useState)(`idle`),[Ie,j]=(0,u.useState)(!1),[Le,M]=(0,u.useState)(`readonly`),[Re,ze]=(0,u.useState)(!1),[Be,N]=(0,u.useState)(!1),[Ve,P]=(0,u.useState)(null),[F,I]=(0,u.useState)({language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``}),[He,L]=(0,u.useState)(`14`),Ue=(0,u.useRef)(0),[R,We]=(0,u.useState)(null),[z,Ge]=(0,u.useState)(!1),[Ke,qe]=(0,u.useState)(!1),[Je,B]=(0,u.useState)(!1),[Ye,V]=(0,u.useState)(``),H=(0,u.useRef)(null),U=(0,u.useRef)(!1),W=v!==null,G=F.language,K=g.find(e=>e.id===Me),q=(K?.name||``).trim(),J=R?.status??null,Xe=J?.phase===`done`&&!!J.to&&J.to===R?.current&&Ce!==R?.current&&Date.now()-Date.parse(J.finishedAt||``)<864e5,Ze=J?.phase===`failed`?J.error:``,Y=Je||J?.phase===`installing`||J?.phase===`restarting`,Qe=(J?.to||R?.latest||``).replace(/^v/,``),X=Ze||Ye,$e=R?.checkedAt&&!Y?new Date(R.checkedAt).toLocaleTimeString():``,et=z?``:Y?J?.phase===`restarting`?c(`settings.updateRestarting`,void 0,G):c(`settings.updateInstalling`,{v:Qe},G):X?`${c(`settings.updateFailed`,void 0,G)}:${X}`:Xe?c(`settings.updateDone`,{v:J?.to||``},G):R?.mode===`dev`&&R?.hasUpdate?c(`settings.updateDevMode`,void 0,G):R?.error?`${c(`settings.updateUnavailable`,void 0,G)}:${R.error}`:R?.hasUpdate?R.mode===`npx`?c(`settings.updateNpxHint`,void 0,G):``:R?`${c(`settings.updateLatest`,void 0,G)}${$e?` · ${c(`settings.updateCheckedAt`,{time:$e},G)}`:``}`:Ke?c(`settings.updateUnavailable`,void 0,G):``,tt=q||(G===`en`?`No model`:`未配置`),nt=q?K?.model?.trim()?`${q} · ${K.model.trim()}`:q:G===`en`?`No model configured`:`未配置模型`;function rt(e=`general`){p(e),r().then(()=>{it(),t(!0)})}function it(){ze(n()),je(de()),_(ue()),N(!!o()),I(ve()),_e(ve()),M(ge()),y(null)}function Z(){H.current!==null&&(window.clearInterval(H.current),H.current=null)}async function at(e=!0){Ge(!0);try{let t=await l(e);t&&(We(t),V(``))}finally{Ge(!1),qe(!0)}}function ot(e){Z();let t=Date.now()+18e4;H.current=window.setInterval(async()=>{if(!U.current){U.current=!0;try{let n=await l(!0);if(n){We(n);let t=n.status;if(t?.phase===`failed`){Z(),B(!1),V(t.error||c(`settings.updateFailed`,void 0,G));return}if(t?.phase===`done`||e&&n.current!==e){Z(),B(!1);return}}Date.now()>t&&(Z(),B(!1),V(c(`settings.updateTimeout`,void 0,G)))}finally{U.current=!1}}},1500)}async function st(){let e=R?.latest||``;V(``),B(!0);let t=R?.current||Ce,n=await Se(e||void 0);n.ok?ot(t):(B(!1),V(n.error||c(`settings.updateFailed`,void 0,G)))}function ct(e){if(!e){let e=ee();y(e),x(`DeepSeek`),Pe(`DeepSeek`),C(`https://api.deepseek.com/v1`),T(``),D(``),Fe([]),A(`idle`),j(!1);return}y(e.id),x(e.name),C(e.baseURL);let t=e.apiKey?.trim()||(e.id===ue()?i().trim():``)||``;T(t),D(e.model),Fe(e.availableModels??[]),A(e.availableModels?.length?`ok`:`idle`),Pe(s.find(t=>t.baseURL===e.baseURL)?.label??`自定义`),j(!1)}(0,u.useEffect)(()=>{r().then(()=>it());let e=e=>{let n=e.detail;p(n?.tab===`model`?`model`:`general`),r().then(()=>{it(),t(!0)})};window.addEventListener(ye,e);let n=fe(e=>I(e)),i=be(e=>M(e));return()=>{window.removeEventListener(ye,e),n(),i()}},[]),(0,u.useEffect)(()=>{if(e)return(async()=>{let e=await l(!1);if(qe(!0),!e)return;We(e);let t=e.status;(t?.phase===`installing`||t?.phase===`restarting`)&&(B(!0),ot(t.from||e.current))})(),Z},[e]),(0,u.useEffect)(()=>{if(!e||a!==`model`||!W)return;let t=S.trim(),n=w.trim();if(!t||!n){A(e=>e===`ok`?`ok`:`idle`);return}A(`loading`);let r=++Ue.current,i=setTimeout(()=>{ce(t,n).then(e=>{r===Ue.current&&(Fe(e),A(`ok`))}).catch(()=>{r===Ue.current&&A(`fail`)})},800);return()=>clearTimeout(i)},[e,a,W,S,w]);function lt(e){Pe(e);let t=s.find(t=>t.label===e);t&&(t.baseURL&&C(t.baseURL),(!b.trim()||s.some(e=>e.label===b))&&x(t.label)),D(``)}function Q(e){I(pe(e))}(0,u.useEffect)(()=>{L(String(F.sessionFontSize))},[F.sessionFontSize]);function ut(){let e=Number(He);if(!He.trim()||!Number.isFinite(e)){L(String(F.sessionFontSize));return}let t=pe({sessionFontSize:Math.round(e)});I(t),L(String(t.sessionFontSize))}let dt=!!(b.trim()&&S.trim()&&w.trim()&&E.trim()),$=O.length>0;function ft(){if(!dt||!v)return;let e=xe({id:v,name:b.trim(),baseURL:S.trim(),apiKey:w.trim(),model:E.trim(),availableModels:$?O:void 0},{activate:!0});je(e),_(v),y(null),N(!!o())}function pt(e){P(e)}function mt(){let e=Ve;if(!e)return;P(null);let t=he(e);je(t),_(ue()),v===e&&y(null),N(!!o())}function ht(e){le(e),_(e),N(!!o())}let gt=[{value:`readonly`,label:c(`settings.access.readonly`,void 0,G)},{value:`readwrite`,label:c(`settings.access.readwrite`,void 0,G)},{value:`full`,label:c(`settings.access.full`,void 0,G)}],_t=[{value:`concise`,label:c(`settings.step.concise`,void 0,G)},{value:`standard`,label:c(`settings.step.standard`,void 0,G)},{value:`detailed`,label:c(`settings.step.detailed`,void 0,G)},{value:`full`,label:c(`settings.step.full`,void 0,G)}],vt=[{value:`queue`,label:c(`settings.busySend.queue`,void 0,G)},{value:`interrupt`,label:c(`settings.busySend.interrupt`,void 0,G)}],yt=[{value:`light`,label:c(`settings.appear.light`,void 0,G),icon:`sun`},{value:`dark`,label:c(`settings.appear.dark`,void 0,G),icon:`moon`},{value:`system`,label:c(`settings.appear.system`,void 0,G),icon:`monitor`}],bt=[{id:`general`,label:c(`settings.general`,void 0,G),icon:(0,d.jsx)(Oe,{})},{id:`model`,label:c(`settings.model`,void 0,G),icon:(0,d.jsx)(ke,{})}],xt=a===`general`?c(`settings.general`,void 0,G):W?g.some(e=>e.id===v)?c(`settings.editProvider`,void 0,G):c(`settings.addProviderTitle`,void 0,G):c(`settings.model`,void 0,G);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`tw-nav-foot-row`,children:[(0,d.jsxs)(`button`,{type:`button`,onClick:()=>rt(`general`),className:`tw-nav-settings-btn`,"data-hint":Be?`设置(已配置模型)`:`设置`,children:[(0,d.jsxs)(`svg`,{className:`tw-nav-ico w-4.5 h-4.5 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":`true`,children:[(0,d.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,d.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9c.2.6.7 1 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z`})]}),(0,d.jsx)(`span`,{"data-i18n":`nav.settings`,children:c(`nav.settings`,void 0,G)})]}),(0,d.jsxs)(`button`,{type:`button`,className:`tw-nav-provider-chip${q?``:` is-empty`}`,"data-hint":nt,onClick:()=>rt(`model`),children:[(0,d.jsx)(`span`,{className:`tw-nav-provider-dot`,"aria-hidden":`true`}),(0,d.jsx)(`span`,{className:`tw-nav-provider-name`,children:tt})]})]}),(0,d.jsx)(ae,{show:e,children:(0,d.jsxs)(`div`,{className:`fixed inset-0 z-110 flex items-center justify-center p-4`,children:[(0,d.jsx)(oe,{children:(0,d.jsx)(`div`,{className:`tw-dialog-backdrop-anim absolute inset-0 bg-stone-950/45`,onClick:()=>t(!1),"aria-hidden":`true`})}),(0,d.jsx)(oe,{children:(0,d.jsxs)(`div`,{className:`tw-settings-dialog tw-dialog-panel-anim relative bg-white rounded-2xl shadow-2xl w-full max-w-3xl h-[min(92vh,720px)] overflow-hidden flex flex-col`,children:[(0,d.jsxs)(`div`,{className:`shrink-0 h-12 px-4 flex items-center justify-between border-b border-stone-100 bg-white`,children:[(0,d.jsx)(`h2`,{className:`text-sm font-semibold text-stone-800 truncate pr-3`,children:xt}),(0,d.jsx)(`button`,{type:`button`,"aria-label":c(`settings.close`,void 0,G),onClick:()=>t(!1),className:`w-8 h-8 inline-flex items-center justify-center rounded-lg text-stone-400 hover:text-stone-700 hover:bg-stone-100 transition-colors`,children:(0,d.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,d.jsx)(`path`,{d:`M5 5l10 10M15 5L5 15`,strokeLinecap:`round`})})})]}),(0,d.jsxs)(`div`,{className:`flex-1 min-h-0 flex`,children:[(0,d.jsx)(`aside`,{className:`w-38 shrink-0 border-r border-stone-100 bg-[#f4f5f7] py-3 px-2 space-y-0.5`,children:bt.map(e=>{let t=a===e.id;return(0,d.jsxs)(`button`,{type:`button`,onClick:()=>{p(e.id),e.id===`model`&&y(null)},className:`w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-sm transition-colors ${t?`bg-[#e8f0fe] text-[#4176e6] font-medium`:`text-stone-600 hover:bg-white/70 hover:text-stone-800`}`,children:[(0,d.jsx)(`span`,{className:t?`text-[#4176e6]`:`text-stone-400`,children:e.icon}),e.label]},e.id)})}),(0,d.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0 bg-white`,children:a===`general`?(0,d.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,d.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-1`,children:[(0,d.jsx)(m,{title:c(`settings.access`,void 0,G),description:c(`settings.accessDesc`,void 0,G),control:(0,d.jsx)(h,{value:Le,options:gt,onChange:e=>{M(e),me(e)}})}),(0,d.jsx)(m,{title:c(`settings.language`,void 0,G),control:(0,d.jsx)(h,{value:F.language,options:Te,onChange:e=>Q({language:e})})}),(0,d.jsxs)(`div`,{className:`py-4 border-b border-stone-100`,children:[(0,d.jsx)(`div`,{className:`text-sm font-medium text-stone-800 mb-3`,children:c(`settings.appearance`,void 0,G)}),(0,d.jsx)(`div`,{className:`grid grid-cols-3 gap-2.5`,children:yt.map(e=>{let t=F.appearance===e.value;return(0,d.jsxs)(`button`,{type:`button`,onClick:()=>Q({appearance:e.value}),className:`flex flex-col items-center justify-center gap-2 h-19 rounded-xl border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] text-[#4176e6] ring-1 ring-[#4176e6]/30`:`border-stone-200 text-stone-500 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,d.jsx)(Ae,{kind:e.icon}),(0,d.jsx)(`span`,{className:`text-xs font-medium`,children:e.label})]},e.value)})})]}),(0,d.jsx)(m,{title:c(`settings.fontSize`,void 0,G),description:c(`settings.fontSizeDesc`,void 0,G),control:(0,d.jsxs)(`div`,{className:`inline-flex items-center gap-1.5`,children:[(0,d.jsx)(`input`,{type:`number`,min:12,max:22,value:He,onChange:e=>L(e.target.value),onBlur:ut,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},className:`w-14 h-9 px-2 text-sm text-center rounded-lg bg-stone-100 border-0 outline-none focus:ring-2 focus:ring-[#4176e6]/30`}),(0,d.jsx)(`span`,{className:`text-sm text-stone-400`,children:`px`})]})}),(0,d.jsx)(m,{title:c(`settings.toolSteps`,void 0,G),description:c(`settings.toolStepsDesc`,void 0,G),control:(0,d.jsx)(h,{value:F.toolStepDetail,options:_t,onChange:e=>Q({toolStepDetail:e})})}),(0,d.jsx)(m,{title:c(`settings.busySend`,void 0,G),description:c(`settings.busySendDesc`,void 0,G),control:(0,d.jsx)(h,{value:F.busySendBehavior,options:vt,onChange:e=>Q({busySendBehavior:e})})}),(0,d.jsx)(m,{title:c(`settings.subagentModel`,void 0,G),description:c(`settings.subagentModelDesc`,void 0,G),control:(0,d.jsx)(h,{value:F.subagentModel?.trim()?F.subagentModel:`inherit`,options:[{value:`inherit`,label:c(`settings.subagentModel.inherit`,void 0,G)},...Array.from(new Set([...K?.availableModels??[],...K?.model?[K.model]:[]])).filter(Boolean).map(e=>({value:e,label:e}))],onChange:e=>Q({subagentModel:e===`inherit`?``:e})})})]}),(0,d.jsxs)(`div`,{className:`shrink-0 px-6 py-3 border-t border-stone-100`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,d.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2`,children:[(0,d.jsx)(`span`,{className:`text-sm text-stone-700 whitespace-nowrap`,children:c(`settings.platformVersion`,void 0,G)}),(0,d.jsxs)(`span`,{className:`text-sm tabular-nums text-stone-500`,children:[`v`,Ce]}),R?.hasUpdate&&!Y&&!Xe?(0,d.jsx)(`span`,{className:`inline-flex items-center h-[18px] px-1.5 rounded-full bg-[#edf3fe] text-[11px] font-medium text-[#4176e6] tabular-nums whitespace-nowrap`,children:`${c(`settings.updateAvailable`,void 0,G)} v${(R.latest||``).replace(/^v/,``)}`}):null]}),(0,d.jsx)(`div`,{className:`shrink-0 flex items-center gap-2`,children:Y?(0,d.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-lg text-xs text-stone-500 bg-stone-100 whitespace-nowrap`,children:[(0,d.jsx)(`span`,{className:`w-3 h-3 rounded-full border-2 border-stone-300 border-t-[#4176e6] animate-spin`}),c(`settings.updateWorking`,void 0,G)]}):Xe?(0,d.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`h-8 px-3 rounded-lg text-xs font-medium text-[#4176e6] bg-[#edf3fe] hover:bg-[#e2ecfd] whitespace-nowrap`,children:c(`settings.updateReload`,void 0,G)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`button`,{type:`button`,disabled:z,onClick:()=>void at(!0),className:`inline-flex items-center justify-center min-w-[76px] h-8 px-3 rounded-lg text-xs font-medium text-stone-600 bg-stone-100 hover:bg-stone-200 disabled:opacity-70 disabled:cursor-default whitespace-nowrap`,children:z?(0,d.jsxs)(d.Fragment,{children:[c(`settings.updateChecking`,void 0,G),(0,d.jsxs)(`span`,{className:`tw-dots`,"aria-hidden":`true`,children:[(0,d.jsx)(`i`,{}),(0,d.jsx)(`i`,{}),(0,d.jsx)(`i`,{})]})]}):c(`settings.updateCheck`,void 0,G)}),R?.hasUpdate?(0,d.jsx)(`button`,{type:`button`,disabled:R.mode===`dev`,onClick:()=>void st(),className:`h-8 px-3 rounded-lg text-xs font-semibold text-white bg-[#4176e6] hover:bg-[#3566d6] disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap`,children:c(`settings.updateNow`,void 0,G)}):null]})})]}),et?(0,d.jsx)(`div`,{className:`mt-1 text-[11px] leading-relaxed ${X?`text-red-500`:`text-stone-400`}`,children:et}):null,X&&R?.logPath?(0,d.jsx)(`div`,{className:`mt-0.5 text-[11px] leading-relaxed text-stone-400 break-all`,children:c(`settings.updateLog`,{path:R.logPath},G)}):null]})]}):W?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`shrink-0 px-5 pt-3 pb-2 flex items-center gap-2 border-b border-stone-100`,children:(0,d.jsx)(`button`,{type:`button`,onClick:()=>y(null),className:`text-sm text-stone-500 hover:text-stone-800`,children:c(`settings.back`,void 0,G)})}),(0,d.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:c(`settings.displayName`,void 0,G)}),(0,d.jsx)(`input`,{type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:`DeepSeek`,className:f})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:c(`settings.preset`,void 0,G)}),(0,d.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:s.map(e=>{let t=Ne===e.label;return(0,d.jsxs)(`button`,{type:`button`,onClick:()=>lt(e.label),className:`text-left px-3 py-2 rounded-lg border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] ring-1 ring-[#4176e6]/30`:`border-stone-200 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,d.jsx)(`div`,{className:`text-sm ${t?`text-[#3565c7] font-medium`:`text-stone-700`}`,children:e.label}),(0,d.jsx)(`div`,{className:`text-[11px] text-stone-400 truncate`,children:e.baseURL?we(e.baseURL):`OpenAI compatible`})]},e.label)})})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:c(`settings.baseUrl`,void 0,G)}),(0,d.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:`https://api.deepseek.com/v1`,className:f})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:c(`settings.apiKey`,void 0,G)}),(0,d.jsxs)(`div`,{className:`relative`,children:[(0,d.jsx)(`input`,{type:Ie?`text`:`password`,value:w,onChange:e=>T(e.target.value),placeholder:`sk-...`,className:`${f} pr-14`}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>j(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-[11px] text-stone-400 hover:text-stone-600 px-1.5 py-1`,children:Ie?G===`en`?`Hide`:`隐藏`:G===`en`?`Show`:`显示`})]}),Re?(0,d.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-5`,children:c(`settings.keyHint`,void 0,G)}):null]}),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,d.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:c(`settings.modelField`,void 0,G)}),k===`loading`&&(0,d.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:c(`settings.recognizing`,void 0,G)}),$&&k===`ok`&&(0,d.jsx)(`span`,{className:`text-[11px] text-emerald-600`,children:c(`settings.recognized`,{n:O.length},G)}),k===`fail`&&!$&&(0,d.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:c(`settings.recognizeFail`,void 0,G)}),k===`fail`&&$&&(0,d.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:c(`settings.recognizeKeep`,void 0,G)})]}),$?(0,d.jsxs)(re,{value:E,onChange:D,children:[(0,d.jsxs)(te,{className:`${f} flex items-center justify-between text-left hover:border-stone-400 cursor-pointer`,children:[(0,d.jsx)(`span`,{className:`truncate text-stone-800`,children:E||(G===`en`?`Select a model`:`请选择模型`)}),(0,d.jsx)(Ee,{className:`w-4 h-4 shrink-0 ml-2 text-stone-400`})]}),(0,d.jsx)(ie,{transition:!0,anchor:{to:`bottom start`,gap:6},className:`tw-select-menu tw-menu-anim z-60 w-(--button-width) max-h-60 overflow-auto rounded-lg py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:O.map(e=>(0,d.jsxs)(ne,{value:e,className:`group cursor-pointer select-none flex items-center justify-between px-3 py-2 text-sm text-stone-700 data-[focus]:bg-[#edf3fe] data-[selected]:text-[#3565c7] data-[selected]:font-medium`,children:[(0,d.jsx)(`span`,{className:`truncate`,children:e}),(0,d.jsx)(De,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0 ml-2`})]},e))})]}):(0,d.jsx)(`input`,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:c(`settings.modelPlaceholder`,void 0,G),className:f})]})]}),(0,d.jsxs)(`div`,{className:`shrink-0 px-5 py-3.5 bg-stone-50 border-t border-stone-100 flex justify-end gap-2`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>y(null),className:`px-3.5 py-1.5 text-sm text-stone-600 hover:bg-stone-200/60 rounded-lg`,children:c(`settings.cancel`,void 0,G)}),(0,d.jsx)(`button`,{type:`button`,onClick:ft,disabled:!dt,className:`px-3.5 py-1.5 text-sm font-medium text-white bg-[#4176e6] hover:bg-[#3565c7] rounded-lg disabled:opacity-40 disabled:cursor-not-allowed`,children:c(`settings.save`,void 0,G)})]})]}):(0,d.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-5 bg-[#f4f5f7]`,children:[(0,d.jsx)(`p`,{className:`text-sm text-stone-500`,children:c(`settings.modelIntro`,void 0,G)}),(0,d.jsxs)(`div`,{className:`mt-5 space-y-2.5`,children:[g.map(e=>{let t=!!(e.apiKey?.trim()&&e.baseURL.trim()&&e.model.trim()),n=e.id===Me;return(0,d.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-stone-200/90 bg-white px-4 py-3.5 shadow-[0_1px_0_rgba(15,23,42,0.02)]`,children:[(0,d.jsxs)(`button`,{type:`button`,"data-hint":n?G===`en`?`Active`:`当前使用`:G===`en`?`Set active`:`设为当前`,onClick:()=>ht(e.id),className:`flex-1 min-w-0 flex items-center gap-2 text-left`,children:[(0,d.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:e.name}),t?(0,d.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 bg-emerald-500`}):null]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>ct(e),className:`h-8 px-3 text-sm text-stone-700 rounded-lg border border-stone-200 bg-white hover:bg-stone-50`,children:c(`settings.edit`,void 0,G)}),g.length>1?(0,d.jsx)(`button`,{type:`button`,onClick:()=>pt(e.id),className:`h-8 px-3 text-sm text-red-600 rounded-lg hover:bg-red-50`,children:c(`settings.delete`,void 0,G)}):null]})]},e.id)}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>ct(null),className:`w-full h-12 rounded-xl border border-dashed border-stone-300 bg-white/60 text-sm text-stone-600 hover:border-[#4176e6] hover:text-[#4176e6] hover:bg-[#edf3fe]/50 transition-colors`,children:c(`settings.addProvider`,void 0,G)})]})]})})]})]})})]})}),(0,d.jsx)(se,{open:Ve!=null,title:c(`settings.delete`,void 0,G),message:c(`settings.deleteConfirm`,void 0,G),confirmLabel:c(`settings.delete`,void 0,G),cancelLabel:G===`en`?`Cancel`:`取消`,danger:!0,onClose:()=>P(null),onConfirm:mt})]})}export{g as default};
@@ -1 +0,0 @@
1
- import{c as e,n as t,t as n}from"./react-dom.CqAxpHMt.js";import{t as r}from"./jsx-runtime.BUXbF_vF.js";var i=e(t(),1),a=e(n(),1),o=r(),s=220;function c({open:e,onClose:t,title:n,closeAriaLabel:r=`关闭面板`,children:c,footer:l}){let[u,d]=(0,i.useState)(e),[f,p]=(0,i.useState)(!1);if((0,i.useEffect)(()=>{if(e){d(!0);let e=window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>p(!0))});return()=>window.cancelAnimationFrame(e)}p(!1);let t=window.setTimeout(()=>d(!1),s);return()=>window.clearTimeout(t)},[e]),(0,i.useEffect)(()=>{if(!e)return;function n(e){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),t())}return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e,t]),!u)return null;let m=(0,o.jsxs)(`div`,{className:`fixed inset-0 z-60 flex justify-end`,role:`dialog`,"aria-modal":`true`,children:[(0,o.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-stone-900/30 transition-opacity duration-200 ease-out ${f?`opacity-100`:`opacity-0`}`,"aria-label":r,onClick:t}),(0,o.jsxs)(`aside`,{className:`tw-slide-over relative w-full max-w-md h-full shadow-2xl border-l border-stone-200 flex flex-col transition-transform duration-200 ease-out will-change-transform ${f?`translate-x-0`:`translate-x-full`}`,children:[(0,o.jsxs)(`header`,{className:`shrink-0 h-12 px-4 border-b border-stone-100 flex items-center gap-2`,children:[(0,o.jsx)(`h2`,{className:`tw-slide-over-title text-sm font-semibold text-stone-800 flex-1`,children:n}),(0,o.jsx)(`button`,{type:`button`,onClick:t,className:`tw-icon-btn w-8 h-8 rounded-lg`,"data-hint":`关闭(Esc)`,children:`✕`})]}),(0,o.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 space-y-4`,children:c}),l]})]});return typeof document>`u`?m:(0,a.createPortal)(m,document.body)}export{c as t};
@@ -1 +0,0 @@
1
- import{c as e,n as t,t as n}from"./react-dom.CqAxpHMt.js";import{t as r}from"./jsx-runtime.BUXbF_vF.js";var i=e(t(),1),a=e(n(),1),o=r(),s=[{key:`blue`,className:`bg-[#d6e8ff] text-[#245bcc]`},{key:`orange`,className:`bg-[#ffe4c8] text-[#9a5b00]`},{key:`teal`,className:`bg-[#ccf1f0] text-[#0f6b6a]`},{key:`yellow`,className:`bg-[#fff3c4] text-[#7a5c00]`},{key:`green`,className:`bg-[#d3f5dd] text-[#1b6b38]`},{key:`pink`,className:`bg-[#ffd9de] text-[#a12a3a]`},{key:`purple`,className:`bg-[#e6ddff] text-[#5b3bb3]`},{key:`gray`,className:`bg-stone-100 text-stone-600`}];function c(e){let t=0;for(let n of e)t=t*31+(n.codePointAt(0)??0)>>>0;return s[t%s.length]}function l(e){let t=c(e.label),n=e.hint!==!1&&!e.wrap;return(0,o.jsxs)(`span`,{"data-tag-tone":t.key,className:`tw-tag-pill inline-flex max-w-full min-w-0 items-center gap-1 rounded px-1.5 py-0.5 text-xs font-medium ${e.muted?`bg-stone-100 text-stone-500`:t.className}`,children:[(0,o.jsx)(`span`,{className:e.wrap?`min-w-0 break-words whitespace-normal`:`truncate`,"data-hint":n?e.label:void 0,"data-hint-fit":n?``:void 0,children:e.label}),e.onRemove?(0,o.jsx)(`span`,{role:`button`,tabIndex:-1,"aria-label":`移除 ${e.label}`,onClick:t=>{t.stopPropagation(),e.onRemove?.()},className:`-mr-0.5 flex h-3.5 w-3.5 shrink-0 cursor-pointer items-center justify-center rounded-sm opacity-60 hover:bg-black/10 hover:opacity-100`,children:`×`}):null]})}function u(e){let{options:t,selected:n,creatable:r,query:a}=e,s=a.trim(),c=(0,i.useMemo)(()=>{let e=s.toLowerCase();return e?t.filter(t=>t.toLowerCase().includes(e)):[...t]},[t,s]),u=r&&s.length>0&&!t.includes(s);return(0,o.jsxs)(`div`,{className:`flex max-h-72 flex-col`,children:[(0,o.jsx)(`div`,{className:`p-1 pb-0`,children:(0,o.jsx)(`input`,{autoFocus:!0,value:a,onChange:t=>e.onQuery(t.target.value),onKeyDown:t=>{if(t.key===`Escape`){t.preventDefault(),t.stopPropagation(),e.onQuery(``),e.onClear();return}if(t.key!==`Enter`)return;if(t.preventDefault(),u){e.onPick(s);return}let n=c[0];n&&e.onPick(n)},placeholder:`查找或创建选项`,className:`h-8 w-full rounded-md border border-stone-200 bg-white px-2 text-sm text-stone-800 outline-none placeholder:text-stone-400 focus:border-[#3370ff]`})}),(0,o.jsxs)(`div`,{className:`mt-1 min-h-0 flex-1 overflow-auto p-1`,children:[u?(0,o.jsxs)(`button`,{type:`button`,onClick:()=>e.onPick(s),className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-stone-500 hover:bg-stone-50`,children:[(0,o.jsx)(`span`,{className:`text-stone-400`,children:`+`}),(0,o.jsxs)(`span`,{className:`truncate`,children:[`创建「`,s,`」`]})]}):null,c.map(t=>{let r=n.includes(t);return(0,o.jsxs)(`button`,{type:`button`,onClick:()=>e.onPick(t),className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left hover:bg-stone-50 ${r?`bg-stone-50`:``}`,children:[(0,o.jsx)(l,{label:t,wrap:!0}),r?(0,o.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-[#3370ff]`,children:`✓`}):null]},t)}),c.length===0&&!u?(0,o.jsx)(`div`,{className:`px-2 py-2 text-sm text-stone-400`,children:`无匹配项`}):null]})]})}function d(){let e=(0,i.useRef)(null),t=(0,i.useRef)(null),[n,r]=(0,i.useState)(!1),[a,o]=(0,i.useState)(``),[s,c]=(0,i.useState)({left:0,top:0,width:220,openUp:!1});(0,i.useEffect)(()=>{if(!n)return;let i=n=>{let i=n.target;e.current?.contains(i)||t.current?.contains(i)||(r(!1),o(``))},a=e=>{e.target instanceof Node&&t.current?.contains(e.target)||(r(!1),o(``))},s=()=>r(!1);return document.addEventListener(`mousedown`,i,!0),window.addEventListener(`scroll`,a,!0),window.addEventListener(`resize`,s),()=>{document.removeEventListener(`mousedown`,i,!0),window.removeEventListener(`scroll`,a,!0),window.removeEventListener(`resize`,s)}},[n]);function l(){if(n){r(!1),o(``);return}let t=e.current;if(!t)return;let i=t.getBoundingClientRect(),a=Math.max(i.width,240),s=Math.min(i.left,Math.max(8,window.innerWidth-a-8)),l=i.bottom+4,u=l+280>window.innerHeight&&i.top>280;c({left:s,top:u?i.top-4:l,width:a,openUp:u}),o(``),r(!0)}return{triggerRef:e,panelRef:t,open:n,setOpen:r,query:a,setQuery:o,anchor:s,toggle:l}}function f(e){return(0,o.jsx)(`div`,{role:`button`,tabIndex:0,"aria-label":e.ariaLabel,"aria-expanded":e.open,onClick:e.onClick,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e.onClick())},className:`flex w-full cursor-pointer items-center gap-1 rounded-md border border-transparent text-sm transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:outline-none ${e.compact?`min-h-8 px-1.5 py-1`:`min-h-9 px-2 py-1`}`,children:e.children})}function p(e){let t=d(),{value:n,onChange:r}=e;function i(e){r(e),t.setOpen(!1),t.setQuery(``)}let s=t.open&&typeof document<`u`?(0,a.createPortal)((0,o.jsxs)(`div`,{ref:t.panelRef,className:`tw-select-menu tw-popover-anim fixed z-[1000] rounded-lg p-1 shadow-lg ring-1 ring-stone-200`,style:{left:t.anchor.left,width:t.anchor.width,...t.anchor.openUp?{bottom:window.innerHeight-t.anchor.top}:{top:t.anchor.top}},children:[(0,o.jsx)(u,{options:e.options,selected:n?[n]:[],creatable:e.creatable!==!1,query:t.query,onQuery:t.setQuery,onPick:i,onClear:()=>t.setOpen(!1)}),n?(0,o.jsx)(`button`,{type:`button`,onClick:()=>i(``),className:`mt-1 w-full rounded-md border-t border-stone-100 px-2 py-1.5 text-left text-xs text-stone-400 hover:bg-stone-50 hover:text-stone-600`,children:`清除选择`}):null]}),document.body):null;return(0,o.jsxs)(`div`,{ref:t.triggerRef,className:e.className,children:[(0,o.jsxs)(f,{ariaLabel:e.ariaLabel,compact:e.compact,open:t.open,onClick:()=>{e.disabled||t.toggle()},children:[(0,o.jsx)(`span`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-1`,children:n?(0,o.jsx)(l,{label:n,onRemove:()=>{r(``)}}):(0,o.jsx)(`span`,{className:`truncate text-stone-300`,children:e.placeholder??`查找或创建选项`})}),(0,o.jsx)(`svg`,{className:`h-3.5 w-3.5 shrink-0 text-stone-400`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`,children:(0,o.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})]}),s]})}export{p as t};
@@ -1 +0,0 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.DUyozIL9.js";import{a as r,o as i,r as a}from"./plugins.BDZqJNOy.js";import{a as o,n as s,o as c,r as l}from"./view-prefs.Dyu_lmN2.js";import{i as u,n as d,r as f,t as p}from"./dialog.DXHznyjD.js";import{t as m}from"./jsx-runtime.BUXbF_vF.js";import{t as h}from"./ConfirmDialog.CBVsDJ8f.js";import{n as g,t as _}from"./ColumnResize.Bs6GL3DJ.js";import{t as v}from"./DatePicker.CMfX7F6z.js";import{t as y}from"./SelectDropdown.Buv7rQJ_.js";import{A as b,C as x,D as S,P as ee,a as C,b as w,c as T,f as te,g as E,h as ne,i as D,m as O,n as k,o as re,p as ie,r as ae,s as oe,t as A,u as se}from"./tasks.otRBFydq.js";import{a as j,l as M,n as N,o as P,r as F,s as I,t as L}from"./DrawerField.CWMLhcPX.js";var R=e(t(),1),z=m(),ce=8e3,B=[{key:`title`,min:200},{key:`status`,width:104,min:80},{key:`priority`,width:104,min:88},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`cycle`,width:76,min:60},{key:`todos`,width:84,min:68},{key:`progress`,width:132,min:104},{key:`note`,width:140,min:88},{key:`action`,width:56,min:52}],le={pool:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,closed:`bg-stone-100 text-stone-400`,cancelled:`bg-stone-100 text-stone-400 line-through`},ue={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},V={pending:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},H={pool:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,closed:`bg-stone-300`,cancelled:`bg-stone-300`},U={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},de=ae.map(e=>({value:e,label:D[e]})),fe=[{value:``,label:`未设置`},...A.map(e=>({value:e,label:k[e]}))],pe=[{value:`all`,label:`全部优先级`},...A.map(e=>({value:e,label:k[e]}))],me=[{value:`all`,label:`全部`},{value:`pool`,label:`任务池`},{value:`in_progress`,label:`进行中`},{value:`done`,label:`已完成`},{value:`closed`,label:`已关闭`},{value:`cancelled`,label:`已取消`}],he=[`all`,`pool`,`in_progress`,`done`,`closed`,`cancelled`],ge=`tasks.status-tab`,_e=`tasks.priority-filter`,ve=`tasks.search`,ye=pe.map(e=>e.value);function W(e){return(0,z.jsxs)(`div`,{"data-tone":e.tone,className:`tw-stat-card flex min-w-0 flex-col gap-1 rounded-xl border px-4 py-3 ${e.tone===`urgent`?`border-red-100 bg-red-50/60`:`border-stone-200 bg-white`}`,children:[(0,z.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums ${e.tone===`urgent`?`text-[#c02a26]`:`text-stone-900`}`,children:e.value}),(0,z.jsx)(`span`,{className:`truncate text-xs text-stone-500`,children:e.label})]})}function be(e){let{open:t,task:n,todos:r,onClose:i,onSaved:a}=e,[o,s]=(0,R.useState)({title:``}),[c,l]=(0,R.useState)(``),[m,h]=(0,R.useState)(!1);(0,R.useEffect)(()=>{t&&(l(``),h(!1),s(n?{title:n.title,status:n.status,priority:n.priority,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pool`,priority:``,startDate:b(),dueDate:b()}))},[t,n]);function g(e){s(t=>({...t,...e}))}let _=O({startDate:o.startDate??``,dueDate:o.dueDate??``}),y=n?r.filter(e=>e.taskId===n.id):[],S=y.filter(e=>e.status===`done`).length,ee=y.length?Math.round(S/y.length*100):0;async function T(){let e=(o.title??``).trim();if(!e)l(`请填写任务名称`);else if(o.startDate&&o.dueDate&&o.dueDate<o.startDate)l(`截止日期不能早于开始日期`);else{h(!0),l(``);try{n?await E(n.id,o):await C([{...o,title:e}],{mode:`manual`}),await a(),i()}catch(e){l(e instanceof Error?e.message:String(e))}finally{h(!1)}}}return(0,z.jsxs)(f,{open:t,onClose:i,transition:!0,className:`relative z-100`,children:[(0,z.jsx)(p,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,z.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,z.jsxs)(u,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,z.jsx)(d,{className:`text-base font-semibold text-stone-900`,children:n?`任务详情`:`新建任务`}),(0,z.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,z.jsx)(N,{icon:(0,z.jsx)(M,{}),label:`任务名称`,children:(0,z.jsx)(`input`,{autoFocus:!0,value:o.title,onChange:e=>g({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())},placeholder:`请输入内容`,className:L})}),(0,z.jsx)(N,{icon:(0,z.jsx)(I,{}),label:`任务状态`,children:(0,z.jsx)(F,{ariaLabel:`任务状态`,menuMinWidth:140,options:de,value:o.status??`pool`,onChange:e=>g({status:e}),label:D[o.status??`pool`],optionDotClassName:e=>H[e]})}),(0,z.jsx)(N,{icon:(0,z.jsx)(I,{}),label:`紧急程度`,children:(0,z.jsx)(F,{ariaLabel:`紧急程度`,menuMinWidth:140,options:fe,value:o.priority??``,onChange:e=>g({priority:e}),label:o.priority?k[o.priority]:`未设置`,optionDotClassName:e=>U[e]})}),(0,z.jsx)(N,{icon:(0,z.jsx)(j,{}),label:`开始日期`,children:(0,z.jsx)(v,{value:o.startDate??``,onChange:e=>g({startDate:e}),className:`${L} tabular-nums`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(j,{}),label:`截止日期`,children:(0,z.jsx)(v,{value:o.dueDate??``,onChange:e=>g({dueDate:e}),className:`${L} tabular-nums`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(P,{}),label:`任务周期`,children:(0,z.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:_===null?`—`:`${_} 天`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(P,{}),label:`待办进度`,children:(0,z.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:y.length?`${S}/${y.length} · ${ee}%`:`还没有关联待办`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(M,{}),label:`备注`,children:(0,z.jsx)(`textarea`,{value:o.note??``,onChange:e=>g({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),n&&y.length?(0,z.jsxs)(`div`,{className:`mx-6 mt-2 rounded-lg border border-stone-100 bg-stone-50/60 px-3 py-2`,children:[(0,z.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-stone-500`,children:`关联待办`}),(0,z.jsx)(`ul`,{className:`space-y-1.5`,children:y.map(e=>{let t=x(e,b());return(0,z.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-stone-700`,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,z.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${V[t]}`,children:w[t]})]},e.id)})})]}):null,c?(0,z.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:c}):null]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:i,disabled:m,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void T(),disabled:m,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:m?`保存中…`:n?`保存`:`新建`})]})]})})]})}function xe(){let[e,t]=(0,R.useState)(!1),[u,d]=(0,R.useState)(!0),[f,p]=(0,R.useState)(!0),[m,b]=(0,R.useState)(null),[x,C]=(0,R.useState)([]),[w,ae]=(0,R.useState)([]),[A,j]=(0,R.useState)(null),[M,N]=(0,R.useState)(!1),[P,F]=(0,R.useState)(()=>l(ve)),[I,L]=(0,R.useState)(()=>s(ge,he,`all`)),[V,xe]=(0,R.useState)(()=>s(_e,ye,`all`)),[Se,G]=(0,R.useState)(null),[K,q]=(0,R.useState)(null);function Ce(e){o(ge,e),L(e)}function we(e){c(ve,e),F(e)}function Te(e){o(_e,e),xe(e)}let J=(0,R.useRef)(!0),Y=g(`lh:tasks:cols:v1`,B);(0,R.useEffect)(()=>(J.current=!0,()=>{J.current=!1}),[]);let X=(0,R.useCallback)(async()=>{try{let[e,t]=await Promise.all([se(),f?S().catch(()=>[]):Promise.resolve([])]);if(!J.current)return;C(e),ae(t),j(null)}catch(e){if(!J.current)return;j(e instanceof Error?e.message:String(e))}},[f]);(0,R.useEffect)(()=>{let e=r(e=>{d(!!e.tasks),p(!!e.todos)});return n().then(()=>{d(a(`tasks`)),p(a(`todos`)),t(!0)}),e},[]),(0,R.useEffect)(()=>{e&&u&&(async()=>{let e=await oe();J.current&&(e?(await X(),J.current&&b(!0)):b(!1))})()},[e,u,X]),(0,R.useEffect)(()=>{if(m!==!0)return;let e=window.setInterval(()=>void X(),ce),t=()=>void X();return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[m,X]);let Ee=(0,R.useMemo)(()=>ne(w),[w]),Z=(0,R.useMemo)(()=>ie(x),[x]),De=(0,R.useMemo)(()=>T(x,{status:I,priority:V,keyword:P}),[x,I,V,P]),Q=(0,R.useMemo)(()=>te(De),[De]);async function $(e,t){C(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await E(e,t);if(!J.current)return;C(t=>t.map(t=>t.id===e?n:t)),j(null)}catch(e){j(e instanceof Error?e.message:String(e)),await X()}}async function Oe(){let e=K;if(e){q(null),N(!0);try{await re([e.id]),await Promise.all(w.filter(t=>t.taskId===e.id).map(e=>ee(e.id,{taskId:``,linkedTask:``}).catch(()=>null))),await X()}catch(e){j(e instanceof Error?e.message:String(e))}finally{J.current&&N(!1)}}}return e?u?m===null?(0,z.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接任务服务`,children:(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,z.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):m?(0,z.jsxs)(`section`,{className:`flex min-h-0 flex-col gap-4`,children:[(0,z.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-7`,children:[(0,z.jsx)(W,{label:`全部任务`,value:Z.total}),(0,z.jsx)(W,{label:`任务池`,value:Z.pool}),(0,z.jsx)(W,{label:`进行中`,value:Z.in_progress}),(0,z.jsx)(W,{label:`已完成`,value:Z.done}),(0,z.jsx)(W,{label:`已关闭`,value:Z.closed}),(0,z.jsx)(W,{label:`已取消`,value:Z.cancelled}),(0,z.jsx)(W,{label:`需要紧急`,value:Z.urgent,tone:`urgent`})]}),(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-4 py-3`,children:[(0,z.jsx)(`input`,{value:P,onChange:e=>we(e.target.value),placeholder:`搜索任务…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,z.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-stone-100/80 p-0.5`,children:me.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>Ce(e.value),className:`h-8 rounded-md px-3 text-sm transition-colors ${I===e.value?`bg-white font-medium text-stone-900 shadow-sm`:`text-stone-600 hover:text-stone-900`}`,children:e.label},e.value))}),(0,z.jsx)(y,{flat:!0,className:`w-[136px]`,ariaLabel:`优先级筛选`,options:pe,value:V,onChange:e=>Te(e)}),(0,z.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>void X(),"aria-label":`刷新`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-800`,children:(0,z.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,z.jsx)(`path`,{d:`M21 12a9 9 0 1 1-3-6.7`}),(0,z.jsx)(`path`,{d:`M21 4v5h-5`})]})}),(0,z.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>G({task:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建任务`})]})]}),A?(0,z.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1`,children:A}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>j(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,z.jsxs)(`table`,{className:`tw-task-table w-full table-fixed border-collapse text-sm`,style:Y.tableStyle,children:[(0,z.jsx)(`colgroup`,{children:B.map(e=>(0,z.jsx)(`col`,{style:Y.widthOf(e.key)?{width:Y.widthOf(e.key)}:void 0},e.key))}),(0,z.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,z.jsxs)(`tr`,{children:[(0,z.jsxs)(`th`,{className:`relative px-3 py-2 text-left font-medium whitespace-nowrap`,children:[`任务描述`,(0,z.jsx)(_,{...Y.resizeProps(0)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务状态`,(0,z.jsx)(_,{...Y.resizeProps(1)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,z.jsx)(_,{...Y.resizeProps(2)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,z.jsx)(_,{...Y.resizeProps(3)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,z.jsx)(_,{...Y.resizeProps(4)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务周期`,(0,z.jsx)(_,{...Y.resizeProps(5)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办数量`,(0,z.jsx)(_,{...Y.resizeProps(6)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`完成进度`,(0,z.jsx)(_,{...Y.resizeProps(7)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,z.jsx)(_,{...Y.resizeProps(8)})]}),(0,z.jsx)(`th`,{className:`px-1 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,z.jsxs)(`tbody`,{children:[Q.map(e=>{let t=O(e),n=Ee[e.id]??{total:0,done:0,percent:0};return(0,z.jsxs)(`tr`,{className:`group/row border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,z.jsx)(`td`,{className:`px-3 py-1 align-middle`,children:(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.source===`ai`?(0,z.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,children:`AI`}):null,(0,z.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),className:`min-w-0 truncate rounded-md px-1.5 py-1 text-left text-sm text-stone-800 hover:bg-stone-100`,children:e.title})]})}),(0,z.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,z.jsx)(y,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`任务状态`,menuMinWidth:120,options:de,value:e.status,onChange:t=>void $(e.id,{status:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${le[e.status]}`,renderTrigger:()=>(0,z.jsx)(`span`,{className:`w-full truncate text-center`,children:D[e.status]}),renderOptionPrefix:e=>(0,z.jsx)(`span`,{className:`h-2 w-2 rounded-full ${H[e.value]}`})})}),(0,z.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,z.jsx)(y,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:fe,value:e.priority,onChange:t=>void $(e.id,{priority:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${ue[e.priority]}`,renderTrigger:()=>(0,z.jsx)(`span`,{className:`w-full truncate text-center`,children:e.priority?k[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,z.jsx)(`span`,{className:`h-2 w-2 rounded-full ${U[e.value]}`})})}),(0,z.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,z.jsx)(v,{value:e.startDate,onChange:t=>void $(e.id,{startDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,z.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,z.jsx)(v,{value:e.dueDate,onChange:t=>void $(e.id,{dueDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,z.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:t===null?`—`:`${t} 天`}),(0,z.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-500 tabular-nums`,children:f?n.total?`${n.total} 条`:`0`:(0,z.jsx)(`span`,{className:`whitespace-nowrap text-stone-400`,children:`待办事项未启用`})}),(0,z.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:f?(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,z.jsx)(`span`,{className:`block h-full rounded-full bg-[#3370ff] transition-[width]`,style:{width:`${n.percent}%`}})}),(0,z.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs text-stone-500 tabular-nums`,children:[n.percent,`%`]})]}):(0,z.jsx)(`span`,{className:`whitespace-nowrap text-xs text-stone-400`,children:`待办事项未启用`})}),(0,z.jsx)(`td`,{className:`truncate px-2 py-1 align-middle text-xs text-stone-500`,children:e.note||`—`}),(0,z.jsx)(`td`,{className:`px-1 py-1 text-right align-middle`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,z.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,z.jsx)(`path`,{d:`M14 4h6v6`}),(0,z.jsx)(`path`,{d:`M20 4 13 11`}),(0,z.jsx)(`path`,{d:`M10 20H4v-6`}),(0,z.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,z.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>q(e),"aria-label":`删除 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 focus:text-red-600 disabled:opacity-40`,children:(0,z.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,z.jsx)(`path`,{d:`M3 6h18`}),(0,z.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,z.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,z.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),Q.length===0?(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:10,className:`px-3 py-16 text-center text-sm text-stone-400`,children:x.length===0?`还没有任务`:`没有匹配的任务,试试调整搜索或筛选`})}):null]})]})}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,z.jsxs)(`span`,{children:[`共 `,Q.length,` 条`]}),(0,z.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`任务下关联的待办可直接在「待办事项」里维护`})]})]}),(0,z.jsx)(be,{open:Se!==null,task:Se?.task??null,todos:w,onClose:()=>G(null),onSaved:X}),(0,z.jsx)(h,{open:K!=null,title:`删除任务`,message:`删除「${K?.title??``}」?已关联的待办会保留,但不再挂在该任务下。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>q(null),onConfirm:()=>void Oe()})]}):(0,z.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`任务管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,z.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`tasks`)}):(0,z.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,z.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{xe as default};
@@ -1 +0,0 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.DUyozIL9.js";import{a as r,o as i,r as a}from"./plugins.BDZqJNOy.js";import{t as o}from"./jsx-runtime.BUXbF_vF.js";import{t as s}from"./ConfirmDialog.CBVsDJ8f.js";import{n as c,t as ee}from"./DocsPager.C20ue_JZ.js";import{a as l,i as u,r as d,t as te}from"./ExcelFieldTags.B_XMwNNx.js";import{a as ne,c as re,d as f,f as p,h as ie,i as ae,l as oe,m as se,n as ce,o as le,p as ue,r as de,s as m,t as fe,u as pe}from"./project-docs.Cd2gKPKh.js";import{n as me}from"./doc-roots.DAJP9Svr.js";import{t as he}from"./useListAnim.CpGB1cft.js";import{t as h}from"./NamePromptDialog.Dl5kSnQI.js";var g=e(t(),1),_=o(),v=5;async function ge(e){let t=e.name.toLowerCase();try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await f(`templates`,e.path);if(t.encoding===`base64`&&t.contentBase64)return l(t.contentBase64).headers}else if(t.endsWith(`.csv`)){let t=await p(`templates`,e.path);return d(t.content).headers}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await p(`templates`,e.path);return u(t.content).headers}}catch{}return[]}function y({className:e=`w-4 h-4`,open:t=!1}){return(0,_.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,_.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}):(0,_.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function b({className:e=`w-3 h-3`}){return(0,_.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,_.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,_.jsx)(`path`,{d:`m15 5 4 4`})]})}function x({className:e=`w-3 h-3`}){return(0,_.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,_.jsx)(`path`,{d:`M3 6h18`}),(0,_.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,_.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,_.jsx)(`path`,{d:`M10 11v6`}),(0,_.jsx)(`path`,{d:`M14 11v6`})]})}function S({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,_.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,_.jsx)(y,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,_.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,_.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,_.jsx)(`div`,{className:`tw-collapse-inner`,children:e.children.map(e=>(0,_.jsx)(S,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function _e(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function C(){let[e,t]=(0,g.useState)(()=>a(`templates`)),[o,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)([]),[C,ve]=(0,g.useState)(0),[w,T]=(0,g.useState)(`.`),[E,D]=(0,g.useState)([]),[ye,be]=(0,g.useState)({}),[xe,O]=(0,g.useState)({}),[k,Se]=(0,g.useState)(!0),[A,j]=(0,g.useState)(null),[M,N]=(0,g.useState)(!1),[Ce,P]=(0,g.useState)(!1),[F,I]=(0,g.useState)(null),[L,R]=(0,g.useState)(null),[z,B]=(0,g.useState)(1),[V,we]=c(v),[Te,H]=(0,g.useState)(null),U=(0,g.useRef)(null),{cls:Ee,play:W}=he(),G=(0,g.useCallback)(async e=>{let t={};await Promise.all(e.map(async e=>{let n=await ge(e);n.length&&(t[e.path]=n)})),be(t)},[]),K=(0,g.useCallback)(async()=>{let e=await ae(`templates`);p(e.tree),ve(e.totalFiles)},[]),q=(0,g.useCallback)(async(e=w)=>{j(null);try{let[t]=await Promise.all([m(`templates`,e),K()]);D(t.entries),T(t.path);let n=t.entries.filter(e=>e.type===`file`);await G(n)}catch(e){j(e instanceof Error?e.message:String(e))}},[w,G,K]);(0,g.useEffect)(()=>{let e=r(e=>t(!!e.templates));return n().then(()=>{t(a(`templates`)),l(!0)}),e},[]),(0,g.useEffect)(()=>{o&&e&&(async()=>{let e=await de(`templates`);if(d(e),e)try{let[e]=await Promise.all([m(`templates`,`.`),K()]);D(e.entries),T(e.path),await G(e.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}})()},[o,e,G,K]);function De(){Se(e=>!e),O({})}async function J(e){W(),T(e),B(1),H(null),j(null);try{let t=await m(`templates`,e);D(t.entries),await G(t.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}}async function Oe(e){P(!1),N(!0),j(null);try{await re(`templates`,w,e),await q(w)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}async function ke(e){if(e?.length){N(!0),j(null);try{for(let t of Array.from(e))await ie(`templates`,w,t);await q(w)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1),U.current&&(U.current.value=``)}}}async function Ae(e){if(e.type===`file`){N(!0),j(null);try{await oe(`templates`,e.path)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}function je(e){let t=ne(f,e.path),n=t?.fileCount??0,r=t?fe(t):0;I({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function Me(e){I({name:e.name,path:e.path,isDir:!1})}function Y(e,t){R({...e,isDir:t})}async function Ne(){let e=F;if(e&&(I(null),!e.blocked)){N(!0),j(null);try{await ce(`templates`,e.path);let t=le(w,e.path)?pe(e.path):w;await q(t)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}async function Pe(e){let t=L;if(t&&(R(null),e!==t.name)){N(!0),j(null);try{let n=await se(`templates`,t.path,e);await q(ue(w,t.path,n))}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}let Fe=(()=>{if(!F)return``;if(!F.isDir)return`删除文件「${F.name}」?将移入系统废纸篓,可随时找回。`;if(F.blocked){let e=[];return F.files&&e.push(`${F.files} 个文件`),F.dirs&&e.push(`${F.dirs} 个子文件夹`),`文件夹「${F.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${F.name}」?将移入系统废纸篓。`})();if(!o)return(0,_.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,_.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,_.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`templates`)});if(u===null)return(0,_.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,_.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!u)return(0,_.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`模板库需要本地文档服务,当前未就绪。`});let X=E.filter(e=>e.type===`file`),Z=E.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/V)),$=Math.min(z,Q),Ie=X.slice(($-1)*V,$*V);function Le(e){W(),we(e),B(1)}return(0,_.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,_.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,_.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,_.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>P(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1`,children:[(0,_.jsx)(`div`,{className:`group flex items-center rounded-md ${w===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{J(`.`),De()},"aria-expanded":k,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${w===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,_.jsx)(y,{open:k,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部模板`}),(0,_.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,C,`)`]})]})}),(0,_.jsx)(`div`,{className:`tw-collapse ${k?`is-open`:``}`,children:(0,_.jsx)(`div`,{className:`tw-collapse-inner`,children:f.map(e=>(0,_.jsx)(S,{node:e,depth:0,activePath:w,expanded:xe,globalOpen:k,onToggle:e=>O(t=>({...t,[e]:!(t[e]??k)})),onSelect:e=>void J(e)},e.path))})})]})]}),(0,_.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,_.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,_.jsx)(`span`,{className:`text-stone-400`,children:me(`templates`)}),w===`.`?``:w]}),(0,_.jsx)(`input`,{ref:U,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,className:`hidden`,onChange:e=>void ke(e.target.files)}),(0,_.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>U.current?.click(),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`上传文件`})]}),A?(0,_.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:A}):null,(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,_.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,_.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void J(e.path),children:[(0,_.jsx)(y,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,_.jsx)(b,{className:`w-3.5 h-3.5`})}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>je({name:e.name,path:e.path}),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,_.jsx)(x,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,_.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加模板(.md / .xlsx / .docx 等)`}):(0,_.jsx)(`ul`,{className:`${Ee}space-y-1`,children:Ie.map(e=>{let t=ye[e.path]??[],n=Te===e.path;return(0,_.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2 rounded-lg border transition-colors ${n?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,disabled:M,onClick:()=>H(e.path),onDoubleClick:()=>void Ae(e),children:[(0,_.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,_.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:_e(e.size)}),t.length>0?(0,_.jsx)(te,{fields:t}):null]}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40 shrink-0 mt-0.5`,children:(0,_.jsx)(b,{className:`w-3.5 h-3.5`})}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Me(e),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40 shrink-0 mt-0.5`,children:(0,_.jsx)(x,{className:`w-3.5 h-3.5`})})]},e.path)})})]})]}),X.length>0?(0,_.jsx)(ee,{page:$,totalPages:Q,pageSize:V,busy:M,onPage:e=>{W(),B(e)},onPageSize:Le}):null]}),(0,_.jsx)(h,{open:Ce,title:`新建文件夹`,onClose:()=>P(!1),onConfirm:e=>void Oe(e)}),(0,_.jsx)(h,{open:L!=null,title:L?.isDir?`重命名文件夹`:`重命名文件`,label:L?.isDir?`文件夹名称`:`文件名称`,initialValue:L?.name??``,lockExtension:L!=null&&!L.isDir,confirmLabel:`保存`,onClose:()=>R(null),onConfirm:e=>void Pe(e)}),(0,_.jsx)(s,{open:F!=null,title:F?.blocked?`无法删除文件夹`:F?.isDir?`删除文件夹`:`删除模板`,message:Fe,confirmLabel:F?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!F?.blocked,hideCancel:!!F?.blocked,onClose:()=>I(null),onConfirm:()=>void Ne()})]})}export{C as default};
@@ -1 +0,0 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.DUyozIL9.js";import{a as r,o as i,r as a}from"./plugins.BDZqJNOy.js";import{o,r as ee}from"./view-prefs.Dyu_lmN2.js";import{t as s}from"./jsx-runtime.BUXbF_vF.js";import{t as c}from"./ConfirmDialog.CBVsDJ8f.js";import{n as te,t as l}from"./ColumnResize.Bs6GL3DJ.js";import{t as ne}from"./DatePicker.CMfX7F6z.js";import{n as re,t as ie}from"./DocsPager.C20ue_JZ.js";import{t as ae}from"./TagSelect.u8DTop7v.js";import{a as oe,c as u,i as d,l as f,n as se,o as ce,r as le,s as ue,t as de,u as fe}from"./test-stats.MEm3K2rB.js";var p=e(t(),1),m=s(),h=8e3,g=600,_=20,pe=`tw.test-stats.page-size.v1`,v=`test-stats.search`,y=[{key:`select`,width:32,min:28},{key:`index`,width:44,min:36},{key:`date`,width:140,min:120},{key:`dimensions`,min:240},{key:`count`,width:120,min:90},{key:`action`,width:64,min:56}],b=`h-8 w-full min-w-0 rounded-md border border-transparent bg-transparent px-1.5 text-center text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300 tabular-nums`,x=(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M3 6h18`}),(0,m.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,m.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,m.jsx)(`path`,{d:`M10 11v6M14 11v6`})]});function me(e){let[t,n]=(0,p.useState)(e.value?String(e.value):``),r=(0,p.useRef)(e.value),i=(0,p.useRef)(e.onCommit);i.current=e.onCommit,(0,p.useEffect)(()=>{e.value!==r.current&&(r.current=e.value,n(e.value?String(e.value):``))},[e.value]),(0,p.useEffect)(()=>{let e=t?u(t):0;if(e===r.current)return;let n=window.setTimeout(()=>{r.current=e,i.current(e)},g);return()=>window.clearTimeout(n)},[t]);function a(){let e=t?u(t):0;e!==r.current&&(r.current=e,i.current(e))}return(0,m.jsx)(`input`,{type:`text`,inputMode:`numeric`,"aria-label":e.ariaLabel,value:t,placeholder:e.placeholder??`0`,onChange:e=>n(e.target.value.replace(/[^\d]/g,``)),onBlur:a,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),t.currentTarget.blur()):t.key===`Escape`&&(t.preventDefault(),r.current=e.value,n(e.value?String(e.value):``),t.currentTarget.blur())},className:b})}function S(){let[e,t]=(0,p.useState)(!1),[s,u]=(0,p.useState)(!0),[g,b]=(0,p.useState)(null),[S,C]=(0,p.useState)([]),[w,T]=(0,p.useState)([]),[E,D]=(0,p.useState)(null),[O,k]=(0,p.useState)(!1),[A,j]=(0,p.useState)(()=>ee(v)),[M,N]=(0,p.useState)({}),[P,F]=(0,p.useState)(1),[I,L]=re(_,pe),[R,z]=(0,p.useState)(null),[B,V]=(0,p.useState)(null);function H(e){o(v,e),j(e),F(1)}let U=(0,p.useRef)(!0),W=(0,p.useRef)(!1),G=te(`lh:test-stats:cols:v1`,y);(0,p.useEffect)(()=>(U.current=!0,()=>{U.current=!1}),[]);let K=(0,p.useCallback)(async()=>{try{let e=await oe();if(!U.current)return;C(e.items),T(e.dimensions),N(t=>{let n=new Set(e.items.map(e=>e.id)),r=!1,i={};for(let[e,a]of Object.entries(t))a&&(n.has(e)?i[e]=!0:r=!0);return r?i:t}),D(null)}catch(e){if(!U.current)return;D(e instanceof Error?e.message:String(e))}},[]);(0,p.useEffect)(()=>{let e=r(e=>u(!!e.testStats));return n().then(()=>{u(a(`testStats`)),t(!0)}),e},[]),(0,p.useEffect)(()=>{e&&s&&(async()=>{let e=await le();U.current&&(e?(await K(),U.current&&b(!0)):b(!1))})()},[e,s,K]),(0,p.useEffect)(()=>{if(g!==!0)return;let e=window.setInterval(()=>{W.current||K()},h),t=()=>{W.current||K()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[g,K]);let he=f(),q=(0,p.useMemo)(()=>ce(d(S,{keyword:A})),[S,A]),J=(0,p.useMemo)(()=>ue(S),[S]),Y=Math.max(1,Math.ceil(q.length/I)),X=Math.min(P,Y),Z=(0,p.useMemo)(()=>q.slice((X-1)*I,X*I),[q,X,I]),Q=(0,p.useMemo)(()=>S.filter(e=>M[e.id]),[S,M]),ge=Z.length>0&&Z.every(e=>M[e.id]);(0,p.useEffect)(()=>{if(!R)return;let e=q.findIndex(e=>e.id===R);if(e<0)return;F(Math.floor(e/I)+1);let t=window.setTimeout(()=>z(null),2e3);return()=>window.clearTimeout(t)},[R,q,I]);async function _e(){if(!O){k(!0),D(null),H(``);try{let e=await de([{date:he,dimensions:[],count:0}],{mode:`manual`});if(!U.current)return;let t=e.items[0];if(e.dimensions.length&&T(e.dimensions),await K(),!U.current||!t)return;z(t.id)}catch(e){U.current&&D(e instanceof Error?e.message:String(e))}finally{U.current&&k(!1)}}}async function $(e,t){C(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let{item:n,dimensions:r}=await fe(e,t);if(!U.current)return;C(t=>t.map(t=>t.id===e?n:t)),r.length&&T(r),D(null)}catch(e){if(!U.current)return;D(e instanceof Error?e.message:String(e)),await K()}}async function ve(){let e=B;if(e&&e.length!==0){V(null),k(!0);try{if(await se(e.map(e=>e.id)),!U.current)return;N({}),D(null),await K()}catch(e){U.current&&D(e instanceof Error?e.message:String(e))}finally{U.current&&k(!1)}}}return e?s?g===null?(0,m.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接测试统计服务`,children:(0,m.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):g?(0,m.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,m.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,m.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,m.jsx)(`span`,{className:`font-medium text-stone-800`,children:J.records}),` 条`,(0,m.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 覆盖 `,J.dimensions,` 个维度 · 数量合计 `,J.total,Q.length?` · 已选 ${Q.length} 条`:``]})]}),(0,m.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,m.jsx)(`input`,{value:A,onChange:e=>H(e.target.value),placeholder:`搜索日期 / 维度…`,className:`h-9 w-44 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,m.jsx)(`button`,{type:`button`,disabled:O||Q.length===0,onClick:()=>V(Q),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,m.jsx)(`button`,{type:`button`,disabled:O,onClick:()=>void _e(),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 添加记录`})]})]}),E?(0,m.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,m.jsx)(`span`,{className:`min-w-0 flex-1`,children:E}),(0,m.jsx)(`button`,{type:`button`,onClick:()=>D(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,m.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{W.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{W.current=!!document.activeElement?.closest(`.tw-data-table`)},0)},children:(0,m.jsxs)(`table`,{className:`tw-data-table w-full table-fixed border-collapse text-sm`,style:G.tableStyle,children:[(0,m.jsx)(`colgroup`,{children:y.map(e=>(0,m.jsx)(`col`,{style:G.widthOf(e.key)?{width:G.widthOf(e.key)}:void 0},e.key))}),(0,m.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,m.jsxs)(`tr`,{children:[(0,m.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,children:(0,m.jsx)(`input`,{type:`checkbox`,"aria-label":`全选本页记录`,checked:ge,disabled:Z.length===0,onChange:e=>{let t=e.target.checked;N(e=>{let n={...e};for(let e of Z)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,m.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,"aria-label":`行号`}),(0,m.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`当前日期`,(0,m.jsx)(l,{...G.resizeProps(2)})]}),(0,m.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`测试统计维度`,(0,m.jsx)(l,{...G.resizeProps(3)})]}),(0,m.jsxs)(`th`,{className:`relative px-2 py-2 text-center font-medium whitespace-nowrap`,children:[`统计数量`,(0,m.jsx)(l,{...G.resizeProps(4)})]}),(0,m.jsx)(`th`,{className:`px-1 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,m.jsxs)(`tbody`,{children:[q.length===0?(0,m.jsx)(`tr`,{className:`border-t border-stone-100`,children:(0,m.jsx)(`td`,{colSpan:6,className:`px-4 py-14 text-center text-sm text-stone-400`,children:`还没有测试统计记录,点右上角「+ 添加记录」开始。`})}):null,Z.map((e,t)=>(0,m.jsxs)(`tr`,{className:`group/row border-t border-stone-100 ${e.id===R?`tw-new-row`:`hover:bg-[#f7f8fa]`}`,children:[(0,m.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,m.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.date} ${e.dimensions.join(`/`)}`,checked:!!M[e.id],onChange:t=>N(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,m.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:(X-1)*I+t+1}),(0,m.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,m.jsx)(ne,{value:e.date,onChange:t=>void $(e.id,{date:t}),placeholder:`选择日期`,className:`h-8 w-full rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,m.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,m.jsx)(ae,{compact:!0,ariaLabel:`测试统计维度`,options:w,value:e.dimensions[0]??``,onChange:t=>void $(e.id,{dimensions:t?[t]:[]}),placeholder:`选择或创建维度`})}),(0,m.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,m.jsx)(me,{value:e.count,ariaLabel:`统计数量`,onCommit:t=>void $(e.id,{count:t})})}),(0,m.jsx)(`td`,{className:`px-1 py-1 text-center align-middle`,children:(0,m.jsx)(`button`,{type:`button`,disabled:O,onClick:()=>V([e]),"aria-label":`删除 ${e.date} 的记录`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 focus:text-red-600 disabled:opacity-40`,children:x})})]},e.id))]})]})}),q.length>0?(0,m.jsx)(ie,{page:X,totalPages:Y,pageSize:I,busy:O,onPage:F,onPageSize:e=>{L(e),F(1)}}):(0,m.jsx)(`div`,{className:`pb-1`}),(0,m.jsx)(c,{open:B!==null,title:`删除测试统计`,message:B&&B.length>1?`确定删除选中的 ${B.length} 条记录吗?删除后不可恢复。`:`确定删除 ${B?.[0]?.date??``} 的这条记录吗?删除后不可恢复。`,confirmLabel:`删除`,danger:!0,onClose:()=>V(null),onConfirm:()=>void ve()})]}):(0,m.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`测试统计需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,m.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`testStats`)}):(0,m.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,m.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{S as default};
@@ -1 +0,0 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.DUyozIL9.js";import{a as r,o as i,r as a}from"./plugins.BDZqJNOy.js";import{a as o,n as s,o as c,r as ee}from"./view-prefs.Dyu_lmN2.js";import{i as l,n as te,r as u,t as ne}from"./dialog.DXHznyjD.js";import{t as d}from"./jsx-runtime.BUXbF_vF.js";import{t as f}from"./ConfirmDialog.CBVsDJ8f.js";import{n as p,t as m}from"./ColumnResize.Bs6GL3DJ.js";import{n as re,t as h}from"./DatePicker.CMfX7F6z.js";import{t as g}from"./SelectDropdown.Buv7rQJ_.js";import{A as _,C as v,D as ie,E as ae,M as oe,N as se,P as y,S as b,T as ce,_ as x,b as S,g as le,j as ue,k as de,n as C,u as fe,v as w,w as pe,x as me,y as T}from"./tasks.otRBFydq.js";import{a as E,c as D,i as he,l as O,n as k,o as A,r as j,s as M,t as N}from"./DrawerField.CWMLhcPX.js";var P=e(t(),1),F=d(),ge=8e3,_e=[{key:`select`,width:32,min:28},{key:`index`,width:36,min:28},{key:`title`,min:160},{key:`status`,width:104,min:76},{key:`task`,width:156,min:96},{key:`priority`,width:104,min:84},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`end`,width:108,min:88},{key:`cycle`,width:64,min:52},{key:`remain`,width:86,min:64},{key:`note`,width:160,min:100},{key:`action`,width:80,min:64}],ve=[`title`,`status`,`priority`,`linkedTask`,`startDate`,`dueDate`,`note`],ye={in_progress:`bg-[#3370ff] text-white`,pending:`bg-stone-400 text-white`,done:`bg-[#34c724] text-white`,cancelled:`bg-stone-300 text-stone-600`,overdue:`bg-[#f54a45] text-white`},be={in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,pending:`bg-stone-100 text-stone-600`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},I={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},xe={pending:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,overdue:`bg-[#f54a45]`,cancelled:`bg-stone-300`},Se={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},L={status:`按状态分组`,priority:`按紧急程度分组`,none:`不分组`},Ce=[`status`,`priority`,`none`],we=`todos.group-by`,Te=[`in_progress`,`pending`,`done`,`overdue`,`cancelled`],Ee=T.map(e=>({value:e,label:S[e]})),De=[{value:``,label:`未设置`},...x.map(e=>({value:e,label:w[e]}))],Oe=Object.keys(L).map(e=>({value:e,label:L[e]})),ke=[{value:`all`,label:`全部紧急程度`},...x.map(e=>({value:e,label:w[e]}))],Ae=ke.map(e=>e.value),je=`todos.priority-filter`,Me=`todos.search`,Ne=`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300`;function Pe(e){let{value:t,placeholder:n,muted:r,autoFocus:i,onChange:a,onCommit:o,onCancel:s}=e;return(0,F.jsx)(`input`,{type:`text`,value:t,placeholder:n,autoFocus:i,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.blur()):e.key===`Escape`&&(e.preventDefault(),s(),e.currentTarget.blur())},className:`${Ne} ${r&&!t?`text-stone-300`:``}`})}function Fe(e){let{value:t,onChange:n,onCommit:r,onCancel:i}=e,[a,o]=(0,P.useState)(!1);return a?(0,F.jsx)(Pe,{value:t,placeholder:`—`,autoFocus:!0,onChange:n,onCommit:()=>{o(!1),r()},onCancel:()=>{o(!1),i()}}):(0,F.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`block h-8 w-full min-w-0 truncate rounded-md border border-transparent px-1.5 text-left text-sm leading-8 text-stone-700 transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:outline-none`,children:t||(0,F.jsx)(`span`,{className:`text-stone-300`,children:`—`})})}function Ie(e){return(0,F.jsx)(h,{value:e.value,onChange:e.onChange,placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}function Le(e){let{open:t,item:n,preset:r,tasks:i,tasksOn:a,onClose:o,onSaved:s}=e,[c,ee]=(0,P.useState)({title:``}),[d,f]=(0,P.useState)(``),[p,m]=(0,P.useState)(!1),[v,ie]=(0,P.useState)(!0);(0,P.useEffect)(()=>{t&&(f(``),m(!1),ie(!0),ee(n?{title:n.title,status:n.status,priority:n.priority,linkedTask:n.linkedTask,taskId:n.taskId,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pending`,priority:``,startDate:_(),dueDate:_(),...r}))},[t,n,r]);let oe=[{value:``,label:`不关联`},...i.filter(e=>e.status!==`closed`&&e.status!==`cancelled`||e.id===n?.taskId).map(e=>({value:e.id,label:e.title}))];function b(e){ee(t=>({...t,...e}))}let ce=ue({startDate:c.startDate??``,dueDate:c.dueDate??``}),x=se({dueDate:c.dueDate??``}),le=ae(c.status??`pending`),de=le?re((n&&ae(n.status)?n.taskEndDate:``)||_()):``,fe=x===null?``:c.status===`done`?`已完成`:c.status===`cancelled`?`已取消`:x<0?`逾期 ${Math.abs(x)} 天`:x===0?`今天截止`:`${x} 天`;async function pe(){let e=(c.title??``).trim();if(!e)f(`请填写待办名称`);else if(c.startDate&&c.dueDate&&c.dueDate<c.startDate)f(`截止日期不能早于开始日期`);else{m(!0),f(``);try{let t={...c,title:e};n?await y(n.id,t):await me([t],{mode:`manual`}),await s(),o()}catch(e){f(e instanceof Error?e.message:String(e))}finally{m(!1)}}}return(0,F.jsxs)(u,{open:t,onClose:o,transition:!0,className:`relative z-100`,children:[(0,F.jsx)(ne,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,F.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,F.jsxs)(l,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,F.jsx)(te,{className:`text-base font-semibold text-stone-900`,children:n?`待办详情`:`新建待办`}),(0,F.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,F.jsx)(k,{icon:(0,F.jsx)(O,{}),label:`待办名称`,children:(0,F.jsx)(`input`,{autoFocus:!0,value:c.title,onChange:e=>b({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),pe())},placeholder:`请输入内容`,className:N})}),(0,F.jsx)(k,{icon:(0,F.jsx)(M,{}),label:`待办状态`,children:(0,F.jsx)(j,{ariaLabel:`待办状态`,menuMinWidth:140,options:Ee,value:c.status??`pending`,onChange:e=>b({status:e}),label:S[c.status??`pending`],optionDotClassName:e=>xe[e]})}),(0,F.jsxs)(`button`,{type:`button`,onClick:()=>ie(e=>!e),"aria-expanded":v,className:`flex w-full items-center gap-2 px-6 py-2 text-left text-sm text-stone-600 hover:bg-stone-50`,children:[(0,F.jsx)(`span`,{className:`flex h-4 w-4 items-center justify-center text-stone-400`,children:(0,F.jsx)(D,{})}),(0,F.jsx)(`span`,{children:`任务详情`}),(0,F.jsx)(`span`,{className:`text-stone-400`,children:(0,F.jsx)(he,{open:v})})]}),v?(0,F.jsxs)(`div`,{className:`ml-[42px] border-l border-stone-100 pl-1`,children:[(0,F.jsx)(k,{icon:(0,F.jsx)(D,{}),label:`所属任务`,children:a?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(g,{flat:!0,ariaLabel:`所属任务`,menuMinWidth:220,options:oe,value:c.taskId??``,onChange:e=>{let t=i.find(t=>t.id===e);b({taskId:e,linkedTask:t?.title??``,...t?{priority:t.priority}:{}})},renderTrigger:()=>(0,F.jsx)(`span`,{className:`truncate ${c.taskId||c.linkedTask?`text-stone-800`:`text-stone-400`}`,children:c.taskId?i.find(e=>e.id===c.taskId)?.title??``:c.linkedTask||`请选择任务`})}),i.length===0?(0,F.jsx)(`p`,{className:`mt-1 px-2 text-xs text-stone-400`,children:`任务管理里还没有任务,可到「任务管理」新建后再关联。`}):null]}):(0,F.jsx)(`div`,{className:`flex h-9 items-center rounded-md bg-stone-50 px-2 text-sm text-stone-400`,children:(0,F.jsx)(`span`,{className:`truncate`,children:c.linkedTask?`${c.linkedTask}(任务管理插件未启用)`:`任务管理插件未启用,无法关联任务`})})}),(0,F.jsx)(k,{icon:(0,F.jsx)(M,{}),label:`重要紧急程度`,children:(()=>{let e=c.taskId?i.find(e=>e.id===c.taskId):void 0;return e?(0,F.jsxs)(`div`,{className:`flex h-9 items-center gap-2 px-2 text-sm`,children:[(0,F.jsx)(`span`,{className:e.priority?`text-stone-800`:`text-stone-400`,children:e.priority?C[e.priority]:`任务未设置`}),(0,F.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`跟随所属任务`})]}):(0,F.jsx)(j,{ariaLabel:`重要紧急程度`,menuMinWidth:140,options:De,value:c.priority??``,onChange:e=>b({priority:e}),label:c.priority?w[c.priority]:`未设置`,optionDotClassName:e=>Se[e]})})()}),(0,F.jsx)(k,{icon:(0,F.jsx)(E,{}),label:`结束日期`,children:(0,F.jsxs)(`div`,{className:`flex h-9 items-center px-2 text-sm tabular-nums`,"aria-readonly":`true`,children:[de?(0,F.jsx)(`span`,{className:`text-stone-800`,children:de}):(0,F.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`}),(0,F.jsx)(`span`,{className:`ml-2 text-[11px] text-stone-400`,children:le?`按完成日期自动记录`:`状态为已完成 / 已取消时自动记录`})]})})]}):null,(0,F.jsx)(k,{icon:(0,F.jsx)(E,{}),label:`开始日期`,children:(0,F.jsx)(h,{value:c.startDate??``,onChange:e=>b({startDate:e}),className:`${N} tabular-nums`})}),(0,F.jsx)(k,{icon:(0,F.jsx)(E,{}),label:`截止日期`,children:(0,F.jsx)(h,{value:c.dueDate??``,onChange:e=>b({dueDate:e}),className:`${N} tabular-nums`})}),(0,F.jsx)(k,{icon:(0,F.jsx)(A,{}),label:`待办周期`,children:(0,F.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:ce===null?`—`:`${ce} 天`})}),(0,F.jsx)(k,{icon:(0,F.jsx)(A,{}),label:`剩余天数`,children:(0,F.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:fe||`—`})}),(0,F.jsx)(k,{icon:(0,F.jsx)(O,{}),label:`备注`,children:(0,F.jsx)(`textarea`,{value:c.note??``,onChange:e=>b({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),d?(0,F.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:d}):null]}),(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:o,disabled:p,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>void pe(),disabled:p,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:p?`保存中…`:n?`保存`:`新建`})]})]})})]})}function R(){let[e,t]=(0,P.useState)(!1),[l,te]=(0,P.useState)(!0),[u,ne]=(0,P.useState)(null),[d,C]=(0,P.useState)([]),[T,E]=(0,P.useState)([]),[D,he]=(0,P.useState)(!1),[O,k]=(0,P.useState)(null),[A,j]=(0,P.useState)(!1),[M,N]=(0,P.useState)(()=>ee(Me)),[L,Ne]=(0,P.useState)(()=>s(je,Ae,`all`)),[R,Re]=(0,P.useState)(()=>s(we,Ce,`status`)),[ze,Be]=(0,P.useState)({}),[z,Ve]=(0,P.useState)({});function He(e){o(we,e),Re(e)}function Ue(e){o(je,e),Ne(e)}function We(e){c(Me,e),N(e)}let[Ge,Ke]=(0,P.useState)({}),[B,V]=(0,P.useState)(null),[H,U]=(0,P.useState)(null),[qe,Je]=(0,P.useState)(!1),[Ye,Xe]=(0,P.useState)(null),W=(0,P.useRef)(!0),Ze=(0,P.useRef)(!1),Qe=(0,P.useRef)(!1),G=p(`lh:todos:cols:v1`,_e),$e=B!==null,K=(0,P.useRef)(B);K.current=B;let et=(0,P.useRef)(!1),tt=(0,P.useRef)(async()=>{});tt.current=ct,(0,P.useEffect)(()=>(W.current=!0,()=>{W.current=!1}),[]),(0,P.useEffect)(()=>{if(!$e)return;let e=e=>{let t=e.target;if(!(t instanceof Element)||t.closest(`.tw-new-row`)||t.closest(`.tw-date-panel`)||t.closest(`.tw-select-menu`))return;let n=K.current;if(!n)return;if(n.title.trim()){tt.current();return}let r=_();!n.note.trim()&&!n.taskId&&n.status===n.baseStatus&&n.priority===n.basePriority&&n.startDate===r&&n.dueDate===r&&V(null)};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[$e]);let q=(0,P.useCallback)(async()=>{try{let[e,t]=await Promise.all([ie(),D?fe().catch(()=>[]):Promise.resolve([])]);if(!W.current)return;let n=t;if(!Ze.current&&D){Ze.current=!0;let r=new Set(e.filter(e=>e.status===`pending`||e.status===`in_progress`).map(e=>e.taskId).filter(Boolean)),i=t.filter(e=>r.has(e.id)&&(e.status===`pool`||e.status===`done`));if(i.length){let e=await Promise.all(i.map(e=>le(e.id,{status:`in_progress`}).catch(()=>null))),r=new Map(e.filter(e=>!!e).map(e=>[e.id,e]));n=t.map(e=>r.get(e.id)??e)}}C(e),E(n),k(null)}catch(e){if(!W.current)return;k(e instanceof Error?e.message:String(e))}},[D]);(0,P.useEffect)(()=>{let e=r(e=>{te(!!e.todos),he(!!e.tasks)});return n().then(()=>{te(a(`todos`)),he(a(`tasks`)),t(!0)}),e},[]),(0,P.useEffect)(()=>{e&&l&&(async()=>{let e=await pe();W.current&&(e?(await q(),W.current&&ne(!0)):ne(!1))})()},[e,l,q]),(0,P.useEffect)(()=>{if(u!==!0)return;let e=window.setInterval(()=>{Qe.current||q()},ge),t=()=>{Qe.current||q()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[u,q]),(0,P.useEffect)(()=>{if(!D||u!==!0||T.length===0)return;let e=d.filter(e=>!e.taskId&&e.linkedTask.trim());if(!e.length)return;let t=!1;return(async()=>{let n=[];for(let t of e){let e=T.find(e=>e.title.trim()===t.linkedTask.trim());if(e)try{n.push(await y(t.id,{taskId:e.id}))}catch{}}!t&&n.length&&C(e=>e.map(e=>n.find(t=>t.id===e.id)??e))})(),()=>{t=!0}},[D,u,d,T]);function nt(e,t,n){Ke(r=>({...r,[e]:{...r[e],[t]:n}}))}function J(e){Ke(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})}let rt=(0,P.useMemo)(()=>[{value:``,label:`不关联`},...T.filter(e=>e.status!==`closed`&&e.status!==`cancelled`).map(e=>({value:e.id,label:e.title}))],[T]);function Y(e){return e.taskId?T.find(t=>t.id===e.taskId)?.title??e.linkedTask:e.linkedTask}function it(e){return e.taskId?T.find(t=>t.id===e.taskId):void 0}function at(e){let t=it(e);return t?t.priority:e.priority}async function X(e,t){C(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await y(e,t);if(!W.current)return;C(t=>t.map(t=>t.id===e?n:t)),k(null),t.taskId&&await q()}catch(e){k(e instanceof Error?e.message:String(e)),await q()}}async function ot(e){let t=Ge[e],n=d.find(t=>t.id===e);if(!t||!n)return;let r={},i=n;for(let e of ve){let n=t[e];n!==void 0&&String(i[e]??``)!==String(n)&&(r[e]=n)}if(!Object.keys(r).length)J(e);else if(typeof r.title==`string`&&!r.title.trim())k(`待办名称不能为空`),J(e);else try{let t=await y(e,r);if(!W.current)return;C(n=>n.map(n=>n.id===e?t:n)),Ke(t=>{let n=t[e];if(!n)return t;let i={...n};for(let e of Object.keys(r))String(i[e]??``)===String(r[e]??``)&&delete i[e];if(!Object.keys(i).length){let n={...t};return delete n[e],n}return{...t,[e]:i}}),k(null)}catch(t){k(t instanceof Error?t.message:String(t)),J(e)}}function st(e){let t=e.newStatus??`pending`,n=e.newPriority??``;V({groupKey:e.key,title:``,status:t,priority:n,taskId:``,startDate:_(),dueDate:_(),note:``,baseStatus:t,basePriority:n}),Be(t=>({...t,[e.key]:!1}))}async function ct(){let e=K.current;if(!e||et.current)return;let t=e.title.trim();if(t){et.current=!0,Je(!0);try{let n=T.find(t=>t.id===e.taskId);await me([{title:t,status:e.status,priority:e.priority,taskId:e.taskId,linkedTask:n?.title??``,startDate:e.startDate,dueDate:e.dueDate,note:e.note}],{mode:`manual`}),K.current===e&&V(null),k(null),await q()}catch(e){k(e instanceof Error?e.message:String(e))}finally{et.current=!1,W.current&&Je(!1)}}}async function lt(){let e=H;if(e){U(null),j(!0),k(null);try{await b(e.map(e=>e.id)),Ve({}),await q()}catch(e){k(e instanceof Error?e.message:String(e))}finally{W.current&&j(!1)}}}let Z=_(),ut=(0,P.useMemo)(()=>d.map(e=>{let t=e.taskId?T.find(t=>t.id===e.taskId):void 0;return t?{...e,priority:t.priority}:e}),[d,T]),dt=(0,P.useMemo)(()=>ce(ut,{status:`all`,priority:L,keyword:M,today:Z}),[ut,L,M,Z]),Q=(0,P.useMemo)(()=>de(dt),[dt]),ft=(0,P.useMemo)(()=>R===`none`?[{key:`all`,label:`全部待办`,pill:`bg-stone-500 text-white`,items:Q}]:R===`priority`?[...x,``].map(e=>({key:`priority:${e||`none`}`,label:e?w[e]:`未设置`,pill:e?I[e]:`bg-stone-300 text-stone-600`,items:Q.filter(t=>t.priority===e),newPriority:e})):Te.map(e=>({key:`status:${e}`,label:S[e],pill:ye[e],items:Q.filter(t=>v(t,Z)===e),newStatus:e===`overdue`?`pending`:e})),[R,Q,Z]).filter(e=>e.items.length>0||B?.groupKey===e.key&&!!B),pt=Object.keys(z).filter(e=>z[e]),$=(0,P.useMemo)(()=>{let e={total:d.length,pending:0,in_progress:0,done:0,overdue:0};for(let t of d){let n=v(t,Z);n===`overdue`?e.overdue+=1:n===`pending`?e.pending+=1:n===`in_progress`?e.in_progress+=1:n===`done`&&(e.done+=1)}return e},[d,Z]);return e?l?u===null?(0,F.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接待办服务`,children:(0,F.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,F.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):u?(0,F.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,F.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,F.jsx)(`span`,{className:`font-medium text-stone-800`,children:$.total}),` 条`,(0,F.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 待开始 `,$.pending,` · 进行中 `,$.in_progress,` · 已完成 `,$.done,$.overdue?` · 已延期 ${$.overdue}`:``]})]}),(0,F.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`input`,{value:M,onChange:e=>We(e.target.value),placeholder:`搜索待办…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,F.jsx)(g,{flat:!0,className:`w-[132px]`,ariaLabel:`分组方式`,options:Oe,value:R,onChange:e=>He(e)}),(0,F.jsx)(g,{flat:!0,className:`w-[136px]`,ariaLabel:`紧急程度筛选`,options:ke,value:L,onChange:e=>Ue(e)}),(0,F.jsx)(`button`,{type:`button`,disabled:A||pt.length===0,onClick:()=>U(d.filter(e=>z[e.id])),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,F.jsx)(`button`,{type:`button`,disabled:A,onClick:()=>Xe({item:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建待办`})]})]}),O?(0,F.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,F.jsx)(`span`,{className:`min-w-0 flex-1`,children:O}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>k(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,F.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{Qe.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{Qe.current=!!document.activeElement?.closest(`.tw-todo-table`)},0)},children:(0,F.jsxs)(`table`,{className:`tw-todo-table w-full table-fixed border-collapse text-sm`,style:G.tableStyle,children:[(0,F.jsx)(`colgroup`,{children:_e.map(e=>(0,F.jsx)(`col`,{style:G.widthOf(e.key)?{width:G.widthOf(e.key)}:void 0},e.key))}),(0,F.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,children:(0,F.jsx)(`input`,{type:`checkbox`,"aria-label":`全选可见待办`,checked:Q.length>0&&Q.every(e=>z[e.id]),onChange:e=>{let t=e.target.checked;Ve(e=>{let n={...e};for(let e of Q)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,F.jsx)(`th`,{className:`px-1 py-2 text-left font-medium`,"aria-label":`行号`}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办名称`,(0,F.jsx)(m,{...G.resizeProps(2)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办状态`,(0,F.jsx)(m,{...G.resizeProps(3)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属任务`,(0,F.jsx)(m,{...G.resizeProps(4)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,F.jsx)(m,{...G.resizeProps(5)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,F.jsx)(m,{...G.resizeProps(6)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,F.jsx)(m,{...G.resizeProps(7)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`结束日期`,(0,F.jsx)(m,{...G.resizeProps(8)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`周期`,(0,F.jsx)(m,{...G.resizeProps(9)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`剩余`,(0,F.jsx)(m,{...G.resizeProps(10)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,F.jsx)(m,{...G.resizeProps(11)})]}),(0,F.jsx)(`th`,{className:`px-1 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),ft.map(e=>{let t=ze[e.key]===!0;return(0,F.jsxs)(`tbody`,{children:[(0,F.jsx)(`tr`,{className:`border-t border-stone-100 bg-white`,children:(0,F.jsx)(`td`,{colSpan:13,className:`px-2 py-0 pt-3 pb-1.5`,children:(0,F.jsxs)(`button`,{type:`button`,onClick:()=>Be(n=>({...n,[e.key]:!t})),className:`flex items-center gap-2 rounded-md px-1 py-0.5 text-left hover:bg-stone-50`,"aria-expanded":!t,children:[(0,F.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`12`,height:`12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`text-stone-400 transition-transform ${t?`-rotate-90`:``}`,children:(0,F.jsx)(`path`,{d:`m6 9 6 6 6-6`})}),(0,F.jsx)(`span`,{className:`rounded-md px-2 py-0.5 text-xs font-medium ${e.pill}`,children:e.label}),(0,F.jsxs)(`span`,{className:`text-xs text-stone-400 tabular-nums`,children:[e.items.length,` 条记录`]})]})})}),t?null:e.items.map((e,t)=>{let n=Ge[e.id]??{},r={...e,...n},i=v(r,Z),a=ue(r),o=se(r,Z),s=o===null?`—`:r.status===`done`?`已完成`:r.status===`cancelled`?`已取消`:o<0?`逾期 ${Math.abs(o)} 天`:o===0?`今天截止`:`${o} 天`;return(0,F.jsxs)(`tr`,{className:`group/row border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,F.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.title}`,checked:!!z[e.id],onChange:t=>Ve(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:t+1}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[e.source===`ai`?(0,F.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,title:`AI 记录`,children:`AI`}):null,(0,F.jsx)(Pe,{value:r.title,placeholder:`输入待办名称`,onChange:t=>nt(e.id,`title`,t),onCommit:()=>void ot(e.id),onCancel:()=>J(e.id)})]})}),(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(g,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Ee,value:e.status,onChange:t=>void X(e.id,{status:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${be[i]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`w-full truncate text-center`,children:S[i]}),renderOptionPrefix:e=>(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${xe[e.value]}`})})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:D?(0,F.jsx)(g,{unstyled:!0,ariaLabel:`所属任务`,menuMinWidth:220,options:rt,value:r.taskId,onChange:t=>{let n=T.find(e=>e.id===t);X(e.id,{taskId:t,linkedTask:n?.title??``,...n?{priority:n.priority}:{}})},triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`truncate ${Y(r)?`text-stone-800`:`text-stone-300`}`,children:Y(r)||`未关联`})}):(0,F.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:Y(r)?`${Y(r)} · 插件未启用`:`任务管理插件未启用`})}),(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:it(r)?(0,F.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`flex h-7 w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${I[at(r)]??`text-stone-300`}`,children:at(r)?w[at(r)]:`未设置`}):(0,F.jsx)(g,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:De,value:e.priority,onChange:t=>void X(e.id,{priority:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${I[e.priority]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`w-full truncate text-center`,children:e.priority?w[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Se[e.value]}`})})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Ie,{value:r.startDate,onChange:t=>void X(e.id,{startDate:t})})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Ie,{value:r.dueDate,onChange:t=>void X(e.id,{dueDate:t})})}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:oe(r)?(0,F.jsx)(`span`,{className:`text-stone-500`,children:re(oe(r))}):(0,F.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:a===null?`—`:`${a} 天`}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums ${o!==null&&o<0&&i!==`done`&&i!==`cancelled`?`font-medium text-[#c02a26]`:`text-stone-500`}`,children:s}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Fe,{value:r.note,onChange:t=>nt(e.id,`note`,t),onCommit:()=>void ot(e.id),onCancel:()=>J(e.id)})}),(0,F.jsx)(`td`,{className:`px-1 py-1 text-right align-middle`,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>Xe({item:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,F.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,F.jsx)(`path`,{d:`M14 4h6v6`}),(0,F.jsx)(`path`,{d:`M20 4 13 11`}),(0,F.jsx)(`path`,{d:`M10 20H4v-6`}),(0,F.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,F.jsx)(`button`,{type:`button`,disabled:A,onClick:()=>U([e]),"aria-label":`删除 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 focus:text-red-600 disabled:opacity-40`,children:(0,F.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,F.jsx)(`path`,{d:`M3 6h18`}),(0,F.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,F.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,F.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),t?null:B?.groupKey===e.key?(0,F.jsxs)(`tr`,{className:`tw-new-row border-t border-stone-100`,children:[(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:e.items.length+1}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(`input`,{autoFocus:!0,value:B.title,disabled:qe,placeholder:`输入待办名称,回车或点空白处保存`,onChange:e=>V(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),ct()):e.key===`Escape`&&(e.preventDefault(),V(null))},className:`h-8 w-full truncate rounded-md border border-[#3370ff]/40 bg-white px-2 text-sm text-stone-800 outline-none focus:border-[#3370ff]`})}),(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(g,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Ee,value:B.status,onChange:e=>V(t=>t&&{...t,status:e}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${be[B.status]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`w-full truncate text-center`,children:S[B.status]})})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:D?(0,F.jsx)(g,{unstyled:!0,ariaLabel:`所属任务`,menuMinWidth:220,options:rt,value:B.taskId,onChange:e=>V(t=>{if(!t)return t;let n=T.find(t=>t.id===e);return{...t,taskId:e,...n?{priority:n.priority}:{}}}),triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>{let e=T.find(e=>e.id===B.taskId);return(0,F.jsx)(`span`,{className:`truncate ${e?`text-stone-800`:`text-stone-300`}`,children:e?.title||`未关联`})}}):(0,F.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:`任务管理插件未启用`})}),(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(()=>{let e=T.find(e=>e.id===B.taskId);return e?(0,F.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`flex h-7 w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${I[e.priority]??`text-stone-300`}`,children:e.priority?w[e.priority]:`未设置`}):(0,F.jsx)(g,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:De,value:B.priority,onChange:e=>V(t=>t&&{...t,priority:e}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${I[B.priority]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`w-full truncate text-center`,children:B.priority?w[B.priority]:`未设置`})})})()}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(h,{value:B.startDate,onChange:e=>V(t=>t&&{...t,startDate:e}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(h,{value:B.dueDate,onChange:e=>V(t=>t&&{...t,dueDate:e}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:ae(B.status)?(0,F.jsx)(`span`,{className:`text-stone-500`,children:re(_())}):(0,F.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(`input`,{value:B.note,disabled:qe,placeholder:`—`,onChange:e=>V(t=>t&&{...t,note:e.target.value}),className:`h-8 w-full truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors placeholder:text-stone-300 hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`})]}):(0,F.jsxs)(`tr`,{className:`border-t border-stone-100`,children:[(0,F.jsx)(`td`,{className:`px-2 py-0.5`}),(0,F.jsx)(`td`,{className:`px-1 py-0.5`}),(0,F.jsx)(`td`,{className:`px-1 py-0.5`,colSpan:11,children:(0,F.jsxs)(`button`,{type:`button`,disabled:qe,onClick:()=>st(e),className:`flex items-center gap-1 rounded px-1 py-0.5 text-xs text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-40`,children:[(0,F.jsx)(`span`,{className:`text-sm leading-none`,children:`+`}),`新增记录`]})})]})]},e.key)}),ft.length===0?(0,F.jsx)(`tbody`,{children:(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:13,className:`px-3 py-16 text-center text-sm text-stone-400`,children:d.length===0?`还没有待办`:`没有匹配的待办,试试调整搜索或筛选`})})}):null]})}),(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,F.jsxs)(`span`,{children:[`共 `,Q.length,` 条`,pt.length?` · 已选 ${pt.length}`:``]}),(0,F.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`点击单元格直接编辑,回车或点空白处保存`})]}),(0,F.jsx)(Le,{open:Ye!==null,item:Ye?.item??null,preset:Ye?.preset,tasks:T,tasksOn:D,onClose:()=>Xe(null),onSaved:q}),(0,F.jsx)(f,{open:H!=null,title:H&&H.length>1?`批量删除`:`删除待办`,message:H&&H.length>1?`确认删除已选中的 ${H.length} 条待办?此操作不可恢复。`:`删除「${H?.[0]?.title??``}」?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>U(null),onConfirm:()=>void lt()})]}):(0,F.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`待办事项需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,F.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`todos`)}):(0,F.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,F.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,F.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{R as default};
@@ -1 +0,0 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{o as n,r}from"./view-prefs.Dyu_lmN2.js";import{t as i}from"./jsx-runtime.BUXbF_vF.js";import{t as a}from"./ConfirmDialog.CBVsDJ8f.js";import{t as o}from"./SelectDropdown.Buv7rQJ_.js";import{O as ee,S as s,d as c,g as l,l as u,m as d,u as te,x as ne}from"./PmShared.BxTHKdjY.js";var f=e(t(),1),re=`/__tb_uiauto`,p={running:{label:`运行中`,tone:`blue`},passed:{label:`通过`,tone:`green`},failed:{label:`失败`,tone:`red`},cancelled:{label:`已取消`,tone:`gray`},error:{label:`错误`,tone:`red`},interrupted:{label:`已中断`,tone:`amber`}};function ie(e){return e!==`running`}function ae(e){if(!Number.isFinite(e)||e<=0)return`—`;if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;let n=Math.floor(t/60),r=Math.round(t%60);return n<60?`${n}m ${r}s`:`${Math.floor(n/60)}h ${n%60}m`}function oe(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(`zh-CN`,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hour12:!1}):`—`}function se(e){if(!e)return`全量`;let t=[];return e.file&&t.push(e.file),e.grep&&t.push(`grep: ${e.grep}`),e.project&&t.push(e.project),e.headed&&t.push(`headed`),e.workers>0&&t.push(`workers=${e.workers}`),e.lastFailed&&t.push(`--last-failed`),t.length?t.join(` · `):`全量`}function ce(e){let t=[`共 ${e.total}`,`通过 ${e.passed}`,`失败 ${e.failed}`,`跳过 ${e.skipped}`];return e.flaky>0&&t.push(`不稳定 ${e.flaky}`),t.join(` · `)}async function m(e,t){let n=await fetch(`${re}${e}`,{...t,headers:t?.body===void 0?void 0:{"Content-Type":`application/json`,...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok||r.ok===!1)throw Error(r.error||`HTTP ${n.status}`);return r}async function le(){return(await m(`/projects`)).projects}async function ue(){return(await m(`/pick-directory`,{method:`POST`})).dir}async function de(e,t=``){return(await m(`/projects`,{method:`POST`,body:JSON.stringify({dir:e,name:t})})).project}async function fe(e){return(await m(`/projects`,{method:`PATCH`,body:JSON.stringify(e)})).project}async function pe(e){await m(`/projects?id=${encodeURIComponent(e)}`,{method:`DELETE`})}async function h(e,t=``,n=1){return m(`/tree?${new URLSearchParams({projectId:e,path:t,depth:String(n)}).toString()}`)}async function me(e,t){return m(`/file?${new URLSearchParams({projectId:e,path:t}).toString()}`)}async function he(e,t={}){return(await m(`/run`,{method:`POST`,body:JSON.stringify({projectId:e,...t})})).run}async function ge(e){await m(`/stop`,{method:`POST`,body:JSON.stringify({runId:e})})}async function _e(e,t=0){return m(`/run?${new URLSearchParams({id:e,offset:String(t)}).toString()}`)}async function ve(e){return(await m(`/runs?projectId=${encodeURIComponent(e)}`)).runs}async function ye(e){await m(`/run?id=${encodeURIComponent(e)}`,{method:`DELETE`})}var g=i(),be=`flex h-7 w-full items-center gap-1.5 rounded-md pr-2 text-left text-xs text-stone-700 hover:bg-stone-100`;function xe({open:e}){return(0,g.jsx)(`svg`,{viewBox:`0 0 20 20`,width:`12`,height:`12`,fill:`currentColor`,className:`shrink-0 text-stone-400 transition-transform ${e?`rotate-90`:``}`,"aria-hidden":`true`,children:(0,g.jsx)(`path`,{fillRule:`evenodd`,d:`M7.21 5.23a.75.75 0 0 1 1.06-.02l4.5 4.25a.75.75 0 0 1 0 1.08l-4.5 4.25a.75.75 0 1 1-1.04-1.08L10.67 10 7.19 6.29a.75.75 0 0 1 .02-1.06Z`,clipRule:`evenodd`})})}function _({open:e}){return(0,g.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`shrink-0 ${e?`text-[#3370ff]`:`text-stone-400`}`,"aria-hidden":`true`,children:(0,g.jsx)(`path`,{d:`M3 7.5A2.5 2.5 0 0 1 5.5 5h3.2l2 2h7.8A2.5 2.5 0 0 1 21 9.5v7A2.5 2.5 0 0 1 18.5 19h-13A2.5 2.5 0 0 1 3 16.5Z`})})}function v(){return(0,g.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`shrink-0 text-stone-400`,"aria-hidden":`true`,children:[(0,g.jsx)(`path`,{d:`M7 3.5h6.5L18 8v12.5H7Z`}),(0,g.jsx)(`path`,{d:`M13.5 3.5V8H18`})]})}function Se({projectId:e,selectedPath:t,onOpenFile:n}){let[r,i]=(0,f.useState)({}),[a,o]=(0,f.useState)(()=>new Set),[ee,s]=(0,f.useState)(()=>new Set),[c,l]=(0,f.useState)(``),u=(0,f.useCallback)(async t=>{s(e=>new Set(e).add(t));try{let n=await h(e,t,1);i(e=>({...e,[t]:n.entries})),n.truncated&&l(`目录条目过多,仅显示前 2000 项`)}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(e=>{let n=new Set(e);return n.delete(t),n})}},[e]);(0,f.useEffect)(()=>{i({}),o(new Set),l(``),u(``)},[e,u]);let d=e=>{o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),r[e]||u(e)),n})},te=(e,i)=>(r[e]??[]).map(e=>{let r=e.type===`dir`,o=a.has(e.path),s=8+i*14;return r?(0,g.jsxs)(`div`,{children:[(0,g.jsxs)(`button`,{type:`button`,className:be,style:{paddingLeft:s},onClick:()=>d(e.path),"aria-expanded":o,children:[(0,g.jsx)(xe,{open:o}),(0,g.jsx)(_,{open:o}),(0,g.jsx)(`span`,{className:`truncate`,children:e.name}),ee.has(e.path)?(0,g.jsx)(`span`,{className:`ml-auto text-[10px] text-stone-400`,children:`…`}):null]}),o?te(e.path,i+1):null]},e.path):(0,g.jsxs)(`button`,{type:`button`,className:`${be} ${t===e.path?`bg-[#e1eaff] text-[#1f4ec2]`:``}`,style:{paddingLeft:s+14},onClick:()=>n(e.path),children:[(0,g.jsx)(v,{}),(0,g.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)});return(0,g.jsxs)(`div`,{className:`min-h-0 overflow-auto py-1`,children:[c?(0,g.jsx)(`p`,{className:`px-2 py-1 text-[11px] text-red-500`,children:c}):null,r[``]===void 0?(0,g.jsx)(`p`,{className:`px-2 py-1 text-xs text-stone-400`,children:`加载中…`}):r[``]?.length?te(``,0):(0,g.jsx)(`p`,{className:`px-2 py-1 text-xs text-stone-400`,children:`目录为空`})]})}var Ce=[{value:`run`,label:`运行`},{value:`history`,label:`历史`},{value:`files`,label:`目录`}],y=`ui-auto.project`,we=1e3,Te=[{value:`0`,label:`默认并发`},{value:`1`,label:`1`},{value:`2`,label:`2`},{value:`4`,label:`4`},{value:`8`,label:`8`}],Ee=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-[#4176e6] px-3 text-sm font-medium text-white transition-colors hover:bg-[#3566d0] disabled:cursor-not-allowed disabled:opacity-50`,b=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-lg border border-stone-200 px-3 text-sm text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-40`,De=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-lg border border-red-200 px-3 text-sm text-red-600 transition-colors hover:bg-red-50 disabled:cursor-not-allowed disabled:opacity-40`,Oe=`h-8 rounded-lg border border-stone-200 bg-white px-2.5 text-sm text-stone-700 outline-none transition-colors focus:border-[#3370ff]`;function ke(e){if(!e.exists)return`bg-stone-300`;if(e.runningRunId)return`bg-[#3370ff] animate-pulse`;switch(e.lastStatus){case`passed`:return`bg-green-500`;case`failed`:case`error`:return`bg-red-500`;case`cancelled`:case`interrupted`:return`bg-amber-400`;default:return`bg-stone-300`}}function Ae(e){return e.exists?e.runningRunId?`运行中…`:e.lastRunAt?`${e.lastStatus?p[e.lastStatus].label:``} · ${oe(e.lastRunAt)}`:`尚未运行`:`目录不存在,需重新选择`}function x(){let{ready:e,on:t}=ee(`uiAuto`),[i,re]=(0,f.useState)([]),[m,h]=(0,f.useState)(()=>r(y)),[be,xe]=(0,f.useState)(!0),[_,v]=(0,f.useState)(``),[x,S]=(0,f.useState)(`run`),[C,w]=(0,f.useState)([]),[T,E]=(0,f.useState)(null),[D,O]=(0,f.useState)(``),[je,k]=(0,f.useState)(!1),[A,j]=(0,f.useState)(!0),[M,N]=(0,f.useState)(!1),P=(0,f.useRef)(0),F=(0,f.useRef)(null),I=(0,f.useRef)(!0),[L,R]=(0,f.useState)(``),[z,B]=(0,f.useState)(``),[V,Me]=(0,f.useState)(``),[H,Ne]=(0,f.useState)(!1),[U,Pe]=(0,f.useState)(`0`),[W,G]=(0,f.useState)(!1),[K,Fe]=(0,f.useState)(null),[q,Ie]=(0,f.useState)(null),[Le,Re]=(0,f.useState)(``),[J,ze]=(0,f.useState)(null),[Be,Ve]=(0,f.useState)(!1),[He,Ue]=(0,f.useState)(()=>Date.now()),Y=(0,f.useMemo)(()=>i.find(e=>e.id===m)??null,[i,m]),We=(0,f.useMemo)(()=>i.map(e=>({value:e.id,label:e.name})),[i]),Ge=(0,f.useMemo)(()=>{let e=Y?.projectNames??[],t=e.length?e:C.flatMap(e=>e.projectNames??[]);return[...new Set(t)]},[Y,C]),Ke=(0,f.useMemo)(()=>[{value:``,label:`全部项目`},...Ge.map(e=>({value:e,label:e}))],[Ge]),X=(0,f.useCallback)(async()=>{let e=await le();return re(e),e},[]),Z=(0,f.useCallback)(async e=>{let t=await ve(e);return w(t),t},[]),qe=(0,f.useCallback)(async e=>{let t=await _e(e,0);E(t.run),O(t.log),k(t.stopping),P.current=t.nextOffset,I.current=!0,j(!0)},[]);(0,f.useEffect)(()=>{if(!t)return;let e=!0;return xe(!0),X().catch(t=>{e&&v(t instanceof Error?t.message:String(t))}).finally(()=>{e&&xe(!1)}),()=>{e=!1}},[t,X]),(0,f.useEffect)(()=>{if(!i.length||i.some(e=>e.id===m))return;let e=i[0].id;h(e),n(y,e)},[i,m]),(0,f.useEffect)(()=>{if(!t||!m){w([]),E(null),O(``);return}let e=!0;return w([]),E(null),O(``),k(!1),ze(null),Re(``),R(``),B(``),Me(``),G(!1),P.current=0,Z(m).then(t=>{if(!e)return;let n=t.find(e=>e.status===`running`)??t[0];n&&qe(n.id).catch(()=>void 0)}).catch(t=>{e&&v(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[t,m,Z,qe]);let Je=(0,f.useCallback)(async()=>{await X().catch(()=>null),m&&await Z(m).catch(()=>null)},[X,Z,m]),Q=T?.id??``,$=T?.status===`running`;(0,f.useEffect)(()=>{if(!Q||!$)return;let e=!0,t=async()=>{try{let t=await _e(Q,P.current);if(!e)return;t.reset?O(t.log):t.log&&O(e=>e+t.log),P.current=t.nextOffset,k(t.stopping),E(t.run),ie(t.run.status)&&Je()}catch{}},n=window.setInterval(()=>void t(),we);return()=>{e=!1,window.clearInterval(n)}},[Q,$,Je]),(0,f.useEffect)(()=>{if(!$)return;let e=window.setInterval(()=>Ue(Date.now()),1e3);return()=>window.clearInterval(e)},[$]),(0,f.useEffect)(()=>{let e=F.current;e&&A&&I.current&&(e.scrollTop=e.scrollHeight)},[D,A]);let Ye=()=>{let e=F.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<40;I.current=t,j(e=>e===t?e:t)},Xe=(0,f.useCallback)(async(e={})=>{if(m){v(``),N(!0);try{let t=await he(m,{file:L||void 0,grep:z.trim()||void 0,project:V||void 0,headed:H,workers:Number(U)||0,lastFailed:W,...e});E(t),O(``),k(!1),P.current=0,I.current=!0,j(!0),S(`run`),await Z(m).catch(()=>null),await X().catch(()=>null)}catch(e){v(e instanceof Error?e.message:String(e))}finally{N(!1)}}},[m,L,z,V,H,U,W,Z,X]),Ze=async()=>{v(``),N(!0);try{let e=await ue();if(!e)return;let t=await de(e);await X(),h(t.id),n(y,t.id)}catch(e){v(e instanceof Error?e.message:String(e))}finally{N(!1)}},Qe=async e=>{v(``),N(!0);try{let t=await ue();if(!t)return;await fe({id:e.id,dir:t}),await X()}catch(e){v(e instanceof Error?e.message:String(e))}finally{N(!1)}},$e=async()=>{if(T){v(``);try{await ge(T.id),k(!0)}catch(e){v(e instanceof Error?e.message:String(e))}}},et=()=>{R(``),B(``),G(!0),Xe({lastFailed:!0,file:``,grep:``})},tt=async e=>{if(m){Re(e),Ve(!0),v(``);try{ze(await me(m,e))}catch(e){ze(null),v(e instanceof Error?e.message:String(e))}finally{Ve(!1)}}},nt=async()=>{if(q){v(``);try{await ye(q.id),T?.id===q.id&&(E(null),O(``)),m&&await Z(m),await X().catch(()=>null)}catch(e){v(e instanceof Error?e.message:String(e))}finally{Ie(null)}}};if(!e)return(0,g.jsx)(l,{label:`加载自动化测试…`});if(!t)return(0,g.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`该插件未启用,到「我的插件」里打开「自动化测试」就能挂载 Playwright 项目。`});if(!be&&i.length===0)return(0,g.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[_?(0,g.jsx)(c,{message:_,onClose:()=>v(``)}):null,(0,g.jsx)(te,{icon:`folder`,title:`还没有挂载项目`,hint:`选择已有的 Playwright 项目目录,插件只负责运行与查看,不会修改项目文件。`,action:(0,g.jsxs)(`button`,{type:`button`,className:Ee,onClick:()=>void Ze(),disabled:M,children:[(0,g.jsx)(d,{name:`plus`,size:14}),`选择项目目录`]})})]});let rt=T?$?Math.max(0,He-Date.parse(T.startedAt)):T.durationMs:0;return(0,g.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[_?(0,g.jsx)(c,{message:_,onClose:()=>v(``)}):null,(0,g.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-4 py-3`,children:[Y?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${ke(Y)}`}),(0,g.jsx)(o,{options:We,value:Y.id,onChange:e=>{h(e),n(y,e)},compact:!0,className:`w-52`,ariaLabel:`切换项目`}),(0,g.jsx)(`span`,{className:`max-w-[300px] min-w-0 truncate text-xs text-stone-400`,children:Y.dir}),(0,g.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`· `,Ae(Y)]}),Y.lastStatus?(0,g.jsx)(s,{tone:p[Y.lastStatus].tone,children:p[Y.lastStatus].label}):null,Y.playwrightInstalled?null:(0,g.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:`未检测到本地 Playwright`})]}):(0,g.jsx)(`span`,{className:`text-sm text-stone-500`,children:`加载中…`}),(0,g.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,g.jsxs)(`button`,{type:`button`,className:b,onClick:()=>void Ze(),disabled:M,children:[(0,g.jsx)(d,{name:`plus`,size:13}),`添加项目`]}),Y?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`button`,{type:`button`,className:b,onClick:()=>void Qe(Y),disabled:M,children:[(0,g.jsx)(d,{name:`folder`,size:13}),`重选目录`]}),(0,g.jsxs)(`button`,{type:`button`,className:De,onClick:()=>Fe(Y),children:[(0,g.jsx)(d,{name:`trash`,size:13}),`移出`]})]}):null]})]}),Y?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`div`,{className:`shrink-0 px-4 pt-3`,children:(0,g.jsx)(ne,{tabs:x===`history`?Ce.map(e=>e.value===`history`?{...e,count:C.length}:e):Ce,value:x,onChange:S,ariaLabel:`自动化测试视图`})}),x===`run`?(0,g.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-4`,children:[(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,g.jsx)(o,{options:[{value:``,label:`全部用例`},...Y.specFiles.map(e=>({value:e,label:e}))],value:L,onChange:R,compact:!0,className:`w-56`,ariaLabel:`指定测试文件`}),(0,g.jsx)(`input`,{className:`${Oe} w-44`,value:z,onChange:e=>B(e.target.value),placeholder:`grep 用例名`,"aria-label":`grep`}),(0,g.jsx)(o,{options:Ke,value:V,onChange:Me,compact:!0,className:`w-40`,ariaLabel:`Playwright 项目`}),(0,g.jsx)(o,{options:Te,value:U,onChange:Pe,compact:!0,className:`w-28`,ariaLabel:`并发数`}),(0,g.jsxs)(`label`,{className:`flex h-8 items-center gap-1.5 text-xs text-stone-600`,children:[(0,g.jsx)(`input`,{type:`checkbox`,className:`h-3.5 w-3.5 accent-[#3370ff]`,checked:H,onChange:e=>Ne(e.target.checked)}),`headed`]}),(0,g.jsxs)(`label`,{className:`flex h-8 items-center gap-1.5 text-xs text-stone-600`,children:[(0,g.jsx)(`input`,{type:`checkbox`,className:`h-3.5 w-3.5 accent-[#3370ff]`,checked:W,onChange:e=>G(e.target.checked)}),`仅上次失败`]}),$?(0,g.jsx)(`button`,{type:`button`,className:De,onClick:()=>void $e(),disabled:je,children:je?`停止中…`:`停止`}):(0,g.jsxs)(`button`,{type:`button`,className:Ee,onClick:()=>void Xe(),disabled:M||!Y.exists,children:[(0,g.jsx)(d,{name:`play`,size:14}),M?`启动中…`:`运行`]})]}),Y.exists?null:(0,g.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-700`,children:`项目目录已不存在(换机器或被移动过):点右上角「重选目录」,记录与历史报告不会丢。`}),T?(0,g.jsxs)(`div`,{className:`rounded-lg border border-stone-200 bg-stone-50/60 px-3 py-2.5`,children:[(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-stone-600`,children:[(0,g.jsx)(s,{tone:p[T.status].tone,children:p[T.status].label}),(0,g.jsxs)(`span`,{className:`tabular-nums`,children:[`耗时 `,ae(rt)]}),T.status===`running`?null:(0,g.jsx)(`span`,{className:`tabular-nums`,children:ce(T)}),(0,g.jsx)(`span`,{className:`text-stone-400`,children:se(T.args)}),(0,g.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[T.reportUrl&&T.status!==`running`?(0,g.jsx)(`a`,{className:b,href:T.reportUrl,target:`_blank`,rel:`noreferrer`,children:`查看报告`}):null,T.failed>0&&T.status!==`running`?(0,g.jsx)(`button`,{type:`button`,className:b,onClick:et,disabled:M||!Y.exists,children:`重跑失败用例`}):null]})]}),T.error?(0,g.jsx)(`pre`,{className:`mt-2 max-h-24 overflow-auto whitespace-pre-wrap break-all rounded bg-red-50 px-2 py-1.5 text-[11px] leading-relaxed text-red-600`,children:T.error}):null]}):null,(0,g.jsxs)(`div`,{className:`flex min-h-[220px] flex-1 flex-col overflow-hidden rounded-lg border border-stone-200`,children:[(0,g.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-stone-100 bg-stone-50 px-3 text-xs text-stone-500`,children:[(0,g.jsx)(`span`,{children:`运行日志`}),$?(0,g.jsx)(`span`,{className:`text-[#3370ff]`,children:`实时`}):null,D?(0,g.jsxs)(`span`,{className:`tabular-nums text-stone-400`,children:[D.length,` 字符`]}):null,(0,g.jsxs)(`label`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,g.jsx)(`input`,{type:`checkbox`,className:`h-3.5 w-3.5 accent-[#3370ff]`,checked:A,onChange:e=>{j(e.target.checked),I.current=e.target.checked}}),`自动滚动`]})]}),(0,g.jsx)(`pre`,{ref:F,onScroll:Ye,className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-all bg-white p-3 font-mono text-[12px] leading-relaxed text-stone-700`,children:D||`运行后这里会显示 Playwright 的实时输出…`})]})]}):null,x===`history`?(0,g.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:C.length===0?(0,g.jsx)(u,{children:`还没有运行记录`}):(0,g.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{className:`border-b border-stone-200 text-left text-xs text-stone-400`,children:[(0,g.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`开始时间`}),(0,g.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`结果`}),(0,g.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`用例`}),(0,g.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`耗时`}),(0,g.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`参数`}),(0,g.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`操作`})]})}),(0,g.jsx)(`tbody`,{children:C.map(e=>(0,g.jsxs)(`tr`,{className:`border-b border-stone-100 last:border-0`,children:[(0,g.jsx)(`td`,{className:`whitespace-nowrap px-2 py-2 text-xs text-stone-600`,children:oe(e.startedAt)}),(0,g.jsx)(`td`,{className:`px-2 py-2`,children:(0,g.jsx)(s,{tone:p[e.status].tone,children:p[e.status].label})}),(0,g.jsx)(`td`,{className:`whitespace-nowrap px-2 py-2 text-xs tabular-nums text-stone-600`,children:e.total?`${e.passed}/${e.total} 通过${e.failed?` · ${e.failed} 失败`:``}`:`—`}),(0,g.jsx)(`td`,{className:`whitespace-nowrap px-2 py-2 text-xs tabular-nums text-stone-600`,children:ae(e.durationMs)}),(0,g.jsx)(`td`,{className:`max-w-[240px] truncate px-2 py-2 text-xs text-stone-500`,children:se(e.args)}),(0,g.jsxs)(`td`,{className:`whitespace-nowrap px-2 py-2 text-right`,children:[(0,g.jsx)(`button`,{type:`button`,className:`text-xs text-[#3370ff] hover:underline`,onClick:()=>{S(`run`),qe(e.id).catch(e=>v(String(e)))},children:`日志`}),e.reportUrl?(0,g.jsx)(`a`,{className:`ml-3 text-xs text-[#3370ff] hover:underline`,href:e.reportUrl,target:`_blank`,rel:`noreferrer`,children:`报告`}):null,(0,g.jsx)(`button`,{type:`button`,className:`ml-3 text-xs text-red-500 hover:underline`,onClick:()=>Ie(e),children:`删除`})]})]},e.id))})]})}):null,x===`files`?(0,g.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[220px_minmax(0,1fr)] overflow-hidden`,children:[(0,g.jsx)(`div`,{className:`min-h-0 overflow-auto border-r border-stone-100`,children:(0,g.jsx)(Se,{projectId:Y.id,selectedPath:Le,onOpenFile:e=>void tt(e)})}),(0,g.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col overflow-hidden`,children:[(0,g.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-stone-100 px-3`,children:[(0,g.jsx)(`span`,{className:`truncate font-mono text-xs text-stone-600`,children:J?.path||Le||`未选择文件`}),J?(0,g.jsxs)(`span`,{className:`ml-auto shrink-0 text-[11px] text-stone-400`,children:[J.size,` B`,J.truncated?` · 仅预览前 256KB`:``]}):null]}),(0,g.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:Be?(0,g.jsx)(`p`,{className:`p-3 text-xs text-stone-400`,children:`加载中…`}):J?J.binary?(0,g.jsx)(`p`,{className:`p-3 text-xs text-stone-400`,children:`二进制文件,不支持预览`}):(0,g.jsx)(`pre`,{className:`whitespace-pre p-3 font-mono text-[12px] leading-relaxed text-stone-700`,children:J.content}):(0,g.jsx)(`p`,{className:`p-3 text-xs text-stone-400`,children:`从左侧选择文件查看内容`})})]})]}):null]}):null,(0,g.jsx)(a,{open:!!K,title:`移出项目`,message:`确定把「${K?.name??``}」移出挂载列表吗?\n只删除挂载记录,项目文件与历史报告都保留。`,confirmLabel:`移出`,danger:`outline`,onClose:()=>Fe(null),onConfirm:()=>{let e=K;Fe(null),e&&pe(e.id).then(async()=>{let t=await X();if(e.id===m){let e=t[0]?.id??``;h(e),n(y,e)}}).catch(e=>v(e instanceof Error?e.message:String(e)))}}),(0,g.jsx)(a,{open:!!q,title:`删除运行记录`,message:`会同时删除该次运行的 HTML 报告与原始日志,确定删除吗?`,confirmLabel:`删除`,danger:`solid`,onClose:()=>Ie(null),onConfirm:()=>void nt()})]})}export{x as default};
@@ -1 +0,0 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{G as n,b as r,dt as i,ft as a}from"./portal.Cm9XlIPf.js";var o=e(t(),1);function s(e,t,n,r){let i=a(n);(0,o.useEffect)(()=>{e??=window;function n(e){i.current(e)}return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)},[e,t,r])}function c(e,t){let n=(0,o.useRef)([]),r=i(e);(0,o.useEffect)(()=>{let e=[...n.current];for(let[i,a]of t.entries())if(n.current[i]!==a){let i=r(t,e);return n.current=t,i}},[r,...t])}function l(e){function t(){document.readyState!==`loading`&&(e(),document.removeEventListener(`DOMContentLoaded`,t))}typeof window<`u`&&typeof document<`u`&&(document.addEventListener(`DOMContentLoaded`,t),t())}var u=[];l(()=>{function e(e){if(!n(e.target)||e.target===document.body||u[0]===e.target)return;let t=e.target;t=t.closest(r),u.unshift(t??e.target),u=u.filter(e=>e!=null&&e.isConnected),u.splice(10)}window.addEventListener(`click`,e,{capture:!0}),window.addEventListener(`mousedown`,e,{capture:!0}),window.addEventListener(`focus`,e,{capture:!0}),document.body.addEventListener(`click`,e,{capture:!0}),document.body.addEventListener(`mousedown`,e,{capture:!0}),document.body.addEventListener(`focus`,e,{capture:!0})});export{c as n,s as r,u as t};
@@ -1 +0,0 @@
1
- var e=[{id:`functional`,label:`功能测试`,casesFolder:`功能测试`,templateFolder:`功能测试用例`},{id:`api`,label:`接口测试`,casesFolder:`接口测试`,templateFolder:`接口测试用例`},{id:`performance`,label:`性能测试`,casesFolder:`性能测试`,templateFolder:`性能测试用例`},{id:`automation`,label:`自动化测试`,casesFolder:`自动化测试`,templateFolder:`自动化测试用例`}];function t(){return`ct_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function n(e){let t=e.trim()||`未命名类型`;return{casesFolder:t,templateFolder:`${t}用例`}}function r(e){if(!e||typeof e!=`object`)return null;let r=e,i=String(r.label??``).trim();if(!i)return null;let a=String(r.id??``).trim()||t(),o=n(i);return{id:a,label:i,casesFolder:typeof r.casesFolder==`string`&&r.casesFolder.trim()?r.casesFolder.trim():o.casesFolder,templateFolder:typeof r.templateFolder==`string`&&r.templateFolder.trim()?r.templateFolder.trim():o.templateFolder}}function i(t){if(!Array.isArray(t))return e.map(e=>({...e}));let n=[],i=new Set;for(let e of t){let t=r(e);t&&!i.has(t.id)&&(i.add(t.id),n.push(t))}return n.length?n:e.map(e=>({...e}))}function a(){return t()}var o=[`测试规范`,`方法论`,`环境约定`];function s(e){if(!Array.isArray(e))return[...o];let t=[],n=new Set;for(let r of e){let e=String(r??``).trim();!e||e.length>40||n.has(e)||(n.add(e),t.push(e))}return t.length?t:[...o]}var c=[{id:`case`,label:`用例生成提示词`,hint:`用于编写「用例生成」提示词:指导模型按需求与模板输出可入库用例;须约束 JSON 结构、字段对齐模板、步骤换行与覆盖策略,不要限定固定用例条数。`},{id:`general`,label:`通用提示词`,hint:`用于编写通用测试/工作台提示词:角色、输出风格与约束清晰,可直接作为系统或任务提示词使用。`}];function l(){return`pk_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function u(e){return`生成「${e.trim()||`自定义`}」类提示词:角色、输出风格与约束清晰,可直接作为系统或任务提示词使用。`}function d(e){if(!e||typeof e!=`object`)return null;let t=e,n=String(t.label??``).trim();if(!n)return null;let r=String(t.id??``).trim()||l(),i=typeof t.hint==`string`&&t.hint.trim()?t.hint.trim():u(n);return r===`case`&&i.includes(`「测试用例生成」`)&&(i=c[0].hint),{id:r,label:n,hint:i}}function f(e){if(!Array.isArray(e))return c.map(e=>({...e}));let t=[],n=new Set;for(let r of e){let e=d(r);e&&!n.has(e.id)&&(n.add(e.id),t.push(e))}return t.length?t:c.map(e=>({...e}))}function ee(){return l()}var p=[{id:`dashboard`,href:`dashboard/`,i18n:`nav.dashboard`,plugin:`dashboard`,match:`dashboard`},{id:`tasks`,href:`tasks/`,i18n:`nav.tasks`,plugin:`tasks`,match:`tasks`},{id:`todos`,href:`todos/`,i18n:`nav.todos`,plugin:`todos`,match:`todos`},{id:`projects`,href:`pm/projects/`,i18n:`nav.projects`,plugin:`projects`,match:`pm/projects`},{id:`iterations`,href:`pm/iterations/`,i18n:`nav.iterations`,plugin:`iterations`,match:`pm/iterations`},{id:`pmRequirements`,href:`pm/requirements/`,i18n:`nav.requirementsMgmt`,plugin:`pmRequirements`,match:`pm/requirements`},{id:`bugs`,href:`pm/bugs/`,i18n:`nav.bugs`,plugin:`bugs`,match:`pm/bugs`},{id:`reports`,href:`reports/`,i18n:`nav.reports`,plugin:`reports`,match:`reports`},{id:`testStats`,href:`test-stats/`,i18n:`nav.testStats`,plugin:`testStats`,match:`test-stats`},{id:`caseExec`,href:`case-exec/`,i18n:`nav.caseExec`,plugin:`caseExec`,match:`case-exec`},{id:`uiAuto`,href:`ui-automation/`,i18n:`nav.uiAuto`,plugin:`uiAuto`,match:`ui-automation`},{id:`cases`,href:`cases/library/`,i18n:`nav.caseManage`,plugin:`cases`,match:`cases`},{id:`prompts`,href:`prompts/`,i18n:`nav.prompts`,plugin:`prompts`,match:`prompts`},{id:`knowledgeLib`,href:`knowledge/`,i18n:`nav.knowledge`,plugin:`knowledgeLib`,match:`knowledge`},{id:`requirements`,href:`requirements/`,i18n:`nav.requirements`,plugin:`requirements`,match:`requirements`},{id:`templates`,href:`templates/`,i18n:`nav.templates`,plugin:`templates`,match:`templates`}],m=[],te=[`prompts`];function h(e){return te.includes(e)}var g=[`check`,`pencil`,`book`,`fileText`,`layers`,`list`,`folder`,`star`,`database`,`target`,`code`,`flask`,`home`,`clipboard`,`bug`,`calendar`,`chart`,`globe`,`link`,`users`,`terminal`,`tag`,`flag`,`zap`,`dashboard`],_={dashboard:`dashboard`,tasks:`clipboard`,todos:`list`,projects:`folder`,iterations:`calendar`,pmRequirements:`fileText`,bugs:`bug`,reports:`fileText`,testStats:`chart`,caseExec:`target`,uiAuto:`terminal`,cases:`check`,prompts:`pencil`,knowledgeLib:`book`,requirements:`fileText`,templates:`layers`};function ne(e){return typeof e==`string`&&g.includes(e)}function v(e){let t={..._};if(!e||typeof e!=`object`||Array.isArray(e))return t;for(let n of p){let r=e[n.id];ne(r)&&(t[n.id]=r)}return t}var y=new Set(p.map(e=>e.id));function b(e){return typeof e==`string`&&y.has(e)}function re(e){return p.find(t=>t.id===e)}function ie(e,t=`/`){let n=t.replace(/\/$/,``),r=(n&&e.startsWith(n)?e.slice(n.length):e).replace(/^\/+/,``);return r?p.filter(e=>r===e.match||r.startsWith(`${e.match}/`)).sort((e,t)=>t.match.length-e.match.length)[0]??null:null}function x(e){return`item:${e}`}function S(e){return`group:${e}`}function C(){return`ng_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function w(){return m.map(e=>({id:e.id,name:e.name,items:[...e.items]}))}function T(e,t=!0){if(e==null||!Array.isArray(e))return t?w():[];let n=new Set,r=[],i=new Set;for(let t of e){if(!t||typeof t!=`object`)continue;let e=t,a=String(e.name??``).trim();if(!a)continue;let o=String(e.id??``).trim()||C();i.has(o)&&(o=C());let s=[];if(Array.isArray(e.items))for(let t of e.items)b(t)&&!n.has(t)&&(n.add(t),s.push(t));let c=String(e.parentId??``).trim()||void 0;i.add(o),r.push({id:o,name:a,items:s,parentId:c})}let a=new Set(r.map(e=>e.id)),o=r.map(e=>{let t=e.parentId;return(!t||t===e.id||!a.has(t))&&(t=void 0),t?{...e,parentId:t}:{id:e.id,name:e.name,items:e.items}}),s=new Map(o.map(e=>[e.id,e])),c=o.map(e=>{if(!e.parentId)return e;let t=s.get(e.parentId);if(t?.parentId){let n=t.parentId;return n&&n!==e.id&&a.has(n)?{...e,parentId:n}:{id:e.id,name:e.name,items:e.items}}return e}),l=new Set(c.map(e=>e.parentId).filter(e=>!!e));return c.filter(e=>e.items.length>0||l.has(e.id))}function E(e,t){let n=t.name.trim(),r=t.items.filter((e,t,n)=>b(e)&&n.indexOf(e)===t);if(!n||!r.length)return{groups:e,id:t.id?.trim()||``};let i=t.id?.trim()||C(),a=e.find(e=>e.id===i),o=t.parentId===void 0?a?.parentId:t.parentId.trim()||void 0;if(o===i&&(o=void 0),o){let t=e.find(e=>e.id===o);t?t.parentId&&(o=t.parentId):o=void 0}let s=new Set(r),c=e.filter(e=>e.id!==i).map(e=>({...e,items:e.items.filter(e=>!s.has(e))}));return c.push(o?{id:i,name:n,items:r,parentId:o}:{id:i,name:n,items:r}),{groups:T(c),id:i}}function ae(e,t){return e.filter(e=>e.parentId===t).map(e=>e.id)}function D(e,t){return e.filter(e=>e.parentId===t)}function oe(e,t){let n=e.find(e=>e.id===t);if(!n)return e;let r=e.filter(e=>e.id!==t);return n.parentId?r.map(e=>e.id===n.parentId?{...e,items:[...e.items,...n.items]}:e.parentId===t?{...e,parentId:n.parentId}:e):r.map(e=>e.parentId===t?{id:e.id,name:e.name,items:e.items}:e)}function se(e,t,n){let r=e.find(e=>e.id===t);return!r||!b(n)||r.items.includes(n)?e:E(e,{id:r.id,name:r.name,items:[...r.items,n]}).groups}function ce(e,t){let n=e.find(e=>e.items.includes(t))??null;return n?{groups:e.map(e=>e.id===n.id?{...e,items:e.items.filter(e=>e!==t)}:e).filter(e=>e.items.length>0),owner:n}:{groups:e,owner:null}}function le(e,t,n,r){let i=x(t),a=S(n.id),o=r.some(e=>e.id===n.id),s=e.indexOf(a),c=e.filter(e=>e!==i&&(o||e!==a)),l=s<0?c.length:o?s+1:s;return c.splice(l,0,i),k(c,r)}function ue(e){let t=new Map(e.map(e=>[e.id,e])),n=new Map;for(let r of e){let e=r.parentId?t.get(r.parentId)??r:r;for(let t of r.items)n.set(t,e)}let r=new Set,i=[];for(let e of p){let t=n.get(e.id);if(t){if(r.has(t.id))continue;r.add(t.id),i.push({type:`group`,group:t})}else i.push({type:`item`,id:e.id})}return i}function O(e){let t=new Map;for(let n of e){if(!n.parentId)continue;let e=t.get(n.parentId);e?e.push(n):t.set(n.parentId,[n])}let n=[],r=new Set,i=e=>{if(!r.has(e.id)){r.add(e.id),n.push(S(e.id));for(let n of t.get(e.id)??[])i(n)}};for(let t of ue(e))t.type===`item`?n.push(x(t.id)):i(t.group);for(let t of e)i(t);return n}function de(e){let t=new Set,n=new Set;for(let r of e){n.add(S(r.id));for(let e of r.items)t.add(e)}for(let e of p)t.has(e.id)||n.add(x(e.id));return n}function k(e,t){let n=de(t),r=[],i=new Set;if(Array.isArray(e))for(let t of e)typeof t==`string`&&n.has(t)&&!i.has(t)&&(i.add(t),r.push(t));for(let e of O(t))i.has(e)||r.push(e);return r}function fe(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Set(e.flatMap(e=>e.items)),i=k(t,e),a=[];for(let e of i)if(e.startsWith(`group:`)){let t=n.get(e.slice(6));t&&!t.parentId&&a.push({type:`group`,group:t})}else if(e.startsWith(`item:`)){let t=e.slice(5);b(t)&&!r.has(t)&&a.push({type:`item`,id:t})}return a}function pe(e,t,n){let r=t.find(e=>e.id===n);if(!r)return k(e,t);let i=new Set(r.items.map(e=>x(e))),a=S(n);if(r.parentId){let n=e.filter(e=>e!==a),i=S(r.parentId),o=n.indexOf(i),s=[...n];return o<0?s.push(a):s.splice(o+1,0,a),k(s,t)}let o=[...e],s=o.length;for(let e=0;e<o.length;e++){let t=o[e];if(t===a||i.has(t)){s=o.slice(0,e).filter(e=>e!==a&&!i.has(e)).length;break}}let c=o.filter(e=>e!==a&&!i.has(e));return c.splice(s,0,a),k(c,t)}function me(e,t,n){let r=D(e,t);if(!n?.length||r.length<2)return r;let i=new Map;return n.forEach((e,t)=>{i.has(e)||i.set(e,t)}),r.map((e,t)=>({group:e,i:t,at:i.get(S(e.id))})).sort((e,t)=>{let n=e.at??1/0,r=t.at??1/0;return n===r?e.i-t.i:n-r}).map(e=>e.group)}function he(e,t,n,r){let i=new Map(t.map(e=>[e.id,e])),a=r.filter(e=>i.get(e)?.parentId===n),o=new Set(a.map(S)),s=e.filter(e=>!o.has(e)),c=S(n),l=s.indexOf(c),u=a.map(S),d=[...s];return l<0?d.push(...u):d.splice(l+1,0,...u),k(d,t)}function ge(e,t){if(!e.startsWith(`group:`))return!1;let n=e.slice(6);return t.some(e=>e.id===n&&!!e.parentId)}function _e(e,t,n,r=[]){if(t.parentId)return k(e,n);let i=S(t.id),a=[...r.map(e=>S(e)),...t.items.map(e=>x(e))],o=e.filter(e=>e!==i);return o.push(...a),k(o,n)}function ve(e,t,n){let r=e.indexOf(t),i=e.indexOf(n);if(r<0||i<0||r===i)return[...e];let a=[...e],[o]=a.splice(r,1);return o===void 0?[...e]:(a.splice(i,0,o),a)}var A=`tw.space.active-id`,ye=`tw.spaces.list.v1`;function j(e,t){try{return(e===`local`?localStorage:sessionStorage).getItem(t)?.trim()||``}catch{return``}}function M(e,t,n){try{(e===`local`?localStorage:sessionStorage).setItem(t,n)}catch{}}function N(e){let t=String(e||``).trim();t&&(M(`session`,A,t),M(`local`,A,t))}function P(){let e=j(`session`,A);if(e)return e;let t=j(`local`,A);if(t)return t;try{let e=sessionStorage.getItem(ye);if(!e)return``;let t=JSON.parse(e);return String(t?.activeId||``).trim()}catch{return``}}function F(e){let t=P();return t?`${e}::${t}`:e}var I=`/__tb_config`,L=`tw.app.config.v1`,R=`tw.app.apikey.v1`,z=`tw.app.model.v1`,B=!1,V=null,H=``,U=!1,be={language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``};function W(){return`p_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function xe(e){if(!e||typeof e!=`object`)return null;let t=String(e.name??``).trim()||`未命名提供商`,n=String(e.baseURL??``).trim(),r=String(e.model??``).trim();return{id:String(e.id??``).trim()||W(),name:t,baseURL:n,model:r,apiKey:typeof e.apiKey==`string`&&e.apiKey.trim()?e.apiKey.trim():void 0,availableModels:Array.isArray(e.availableModels)?e.availableModels.filter(e=>typeof e==`string`):void 0}}function Se(e){let t=typeof e.baseURL==`string`?e.baseURL.trim():``,n=typeof e.model==`string`?e.model.trim():``;return!t&&!n&&!e.apiKey?[]:[{id:W(),name:`默认`,baseURL:t||`https://api.deepseek.com/v1`,model:n,apiKey:typeof e.apiKey==`string`&&e.apiKey.trim()?e.apiKey.trim():void 0,availableModels:Array.isArray(e.availableModels)?e.availableModels.filter(e=>typeof e==`string`):void 0}]}function G(e){let t=e?.reasoningEffort===`low`||e?.reasoningEffort===`high`||e?.reasoningEffort===`max`?e.reasoningEffort:`high`,n=[];Array.isArray(e?.providers)&&e.providers.length?n=e.providers.map(e=>xe(e)).filter(e=>!!e):e&&(e.baseURL||e.model||e.apiKey)&&(n=Se(e));let r=typeof e?.activeId==`string`?e.activeId:``;return n.length&&!n.some(e=>e.id===r)&&(r=n[0].id),n.length||(r=``),{activeId:r,reasoningEffort:t,providers:n}}function K(){return{version:1,model:{activeId:``,reasoningEffort:`high`,providers:[]},access:`readonly`,general:{...be},plugins:{cases:!1,caseGen:!1,prompts:!0,promptGen:!1,knowledgeLib:!1,knowledgeGen:!1,requirements:!1,templates:!1,knowledge:!1,memory:!1,pluginDev:!1,todos:!1,tasks:!1,projects:!1,iterations:!1,pmRequirements:!1,bugs:!1,reports:!1,testStats:!1,caseExec:!1,dashboard:!1},caseTypes:e.map(e=>({...e})),promptKinds:c.map(e=>({...e})),knowledgeCategories:[...o],navGroups:m.map(e=>({...e,items:[...e.items]})),navIcons:{..._},navOrder:O(m)}}function q(e){let t=K();if(!e||typeof e!=`object`)return t;let n=e.general&&typeof e.general==`object`?e.general:{},r={...t.plugins,...e.plugins??{}},a=T(e.navGroups);return{version:typeof e.version==`number`?e.version:1,model:G(e.model),access:e.access===`readwrite`||e.access===`full`||e.access===`readonly`?e.access:`readonly`,general:{language:n.language===`en`?`en`:`zh-CN`,appearance:n.appearance===`light`||n.appearance===`dark`||n.appearance===`system`?n.appearance:`system`,sessionFontSize:typeof n.sessionFontSize==`number`&&n.sessionFontSize>=12&&n.sessionFontSize<=22?Math.round(n.sessionFontSize):14,toolStepDetail:n.toolStepDetail===`concise`||n.toolStepDetail===`standard`||n.toolStepDetail===`detailed`||n.toolStepDetail===`full`?n.toolStepDetail:`standard`,busySendBehavior:n.busySendBehavior===`interrupt`?`interrupt`:`queue`,subagentModel:typeof n.subagentModel==`string`?n.subagentModel.trim():``},plugins:r,caseTypes:i(e.caseTypes),promptKinds:f(e.promptKinds),knowledgeCategories:s(e.knowledgeCategories),navGroups:a,navIcons:v(e.navIcons),navOrder:k(e.navOrder,a)}}function Ce(){try{let e=localStorage.getItem(z);if(e)return G(JSON.parse(e))}catch{}try{let e=localStorage.getItem(F(L));if(e){let t=JSON.parse(e);if(t?.model)return G(t.model)}}catch{}return null}function we(e){try{localStorage.setItem(z,JSON.stringify(e))}catch{}}function J(){try{let e=localStorage.getItem(F(L)),t=Ce();if(!e)return t?q({...K(),model:t}):null;let n=q(JSON.parse(e));return t&&(n.model=t),n}catch{return null}}function Y(e){try{let{model:t,...n}=e;localStorage.setItem(F(L),JSON.stringify(n)),we(t)}catch{}}function Te(){try{return localStorage.getItem(R)?.trim()||localStorage.getItem(F(R))?.trim()||``}catch{return``}}function Ee(e){try{e?localStorage.setItem(R,e):localStorage.removeItem(R),localStorage.removeItem(F(R))}catch{}}function De(){try{let e=K(),t=!1,n=localStorage.getItem(`tw-llm-settings`);if(n){let r=JSON.parse(n);e.model=G({providers:[{id:W(),name:r.name||`默认`,baseURL:r.baseURL||``,model:r.model||``,apiKey:r.apiKey,availableModels:r.availableModels}],reasoningEffort:r.reasoningEffort}),e.model.providers[0]&&(e.model.activeId=e.model.providers[0].id),t=!0}let r=localStorage.getItem(`tw-access-level`);(r===`readonly`||r===`readwrite`||r===`full`)&&(e.access=r,t=!0);let i=localStorage.getItem(`tw.general.prefs.v1`);i&&(e.general=q({general:JSON.parse(i)}).general,t=!0);let a=localStorage.getItem(`tw.plugins.enabled.v1`);if(a){let n=JSON.parse(a);e.plugins={...e.plugins,...n},t=!0}return t?e:null}catch{return null}}function X(e){let t=e.model.providers;return t.length?t.find(t=>t.id===e.model.activeId)??t[0]??null:null}function Oe(){return B}function ke(){return V||Z(),V??K()}function Z(){if(!U&&(U=!0,typeof window<`u`))try{let e=J();e&&(V=e)}catch{}}function Ae(){return H}function je(){return[...V?.model.providers??[]]}async function Me(){try{let e=await fetch(I,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json();V=q(t.config);let n=X(V),r=String(t.apiKey??``).trim();return H=r||n?.apiKey?.trim()||``,r&&n&&!n.apiKey&&(H=r),B=!0,Y(V),V}}catch{}B=!1;let e=J();return e||=De()??K(),V=e,H=X(e)?.apiKey?.trim()||Te(),Y(V),V}var Q=null;async function $(e){if(Y(e),B)try{await fetch(I,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({config:e})})}catch{}}function Ne(e){let t=V??K(),n=q({...t,...e,model:e.model?{...t.model,...e.model,providers:e.model.providers??t.model.providers}:t.model,general:{...t.general,...e.general??{}},plugins:{...t.plugins,...e.plugins??{}},caseTypes:e.caseTypes??t.caseTypes,promptKinds:e.promptKinds??t.promptKinds,knowledgeCategories:e.knowledgeCategories??t.knowledgeCategories,navGroups:e.navGroups??t.navGroups,navIcons:e.navIcons??t.navIcons,navOrder:e.navOrder??t.navOrder});return V=n,H=X(n)?.apiKey?.trim()||``,Q&&clearTimeout(Q),Q=setTimeout(()=>{Q=null,$(n)},280),n}function Pe(){return Q&&=(clearTimeout(Q),null),$(V??K())}function Fe(e){if(H=e.trim(),B||Ee(H),!V)return;let t=V.model.providers.map(e=>e.id===V.model.activeId?{...e,apiKey:H||void 0}:e);V=q({...V,model:{...V.model,providers:t}})}function Ie(){let e=V;if(!e)return null;let t=X(e);if(!t?.baseURL?.trim()||!t.model?.trim())return null;let n=(t.apiKey||H).trim();return n?{baseURL:t.baseURL.trim(),apiKey:n,model:t.model.trim(),reasoningEffort:e.model.reasoningEffort,availableModels:t.availableModels}:null}function Le(){return W()}export{he as A,u as B,h as C,T as D,ie as E,ce as F,e as G,f as H,oe as I,i as J,n as K,ve as L,_e as M,pe as N,v as O,me as P,E as R,ge as S,D as T,o as U,ee as V,s as W,se as _,Oe as a,re as b,Fe as c,P as d,N as f,g,p as h,Me as i,le as j,k,Ie as l,_ as m,Ae as n,je as o,F as p,a as q,ke as r,Le as s,Pe as t,Ne as u,fe as v,x as w,S as x,ae as y,c as z};