lantern-harness 0.1.43 → 0.1.45

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 (153) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +1 -1
  3. package/builtin/session/lh-nav-groups.mjs +18 -4
  4. package/dist/500.html +61 -5
  5. package/dist/_astro/Base.Bkt1lrgu.css +1 -0
  6. package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.Chv7r8_9.js → Base.astro_astro_type_script_index_0_lang.UKTVQqk7.js} +1 -1
  7. package/dist/_astro/{CaseExecBoard.DUMjSunb.js → CaseExecBoard.DICluCbK.js} +1 -1
  8. package/dist/_astro/{CaseGenerateApp.DtuOyQuv.js → CaseGenerateApp.Be3h5XPG.js} +1 -1
  9. package/dist/_astro/{CasesLibrary.B9o_jvXb.js → CasesLibrary.Buys7Cy-.js} +3 -3
  10. package/dist/_astro/ChatApp.D3BheKci.js +227 -0
  11. package/dist/_astro/ConfirmDialog.DrrPf1MB.js +1 -0
  12. package/dist/_astro/{DashboardBoard.DEvgMoqo.js → DashboardBoard.Qvf8o4v1.js} +1 -1
  13. package/dist/_astro/{DocsFileBrowser.D66pN9rp.js → DocsFileBrowser.DwKBffbM.js} +1 -1
  14. package/dist/_astro/{DocsPager.ceBEecmd.js → DocsPager.Duf4I68E.js} +1 -1
  15. package/dist/_astro/{DrawerField.CWpOf3L_.js → DrawerField.BH3p4Q4D.js} +1 -1
  16. package/dist/_astro/{KnowledgeLibrary.DYqE2mRi.js → KnowledgeLibrary.MDpMqeOd.js} +1 -1
  17. package/dist/_astro/{LifeKrTasksBoard.B7UiEutA.js → LifeKrTasksBoard.DsvW_S66.js} +1 -1
  18. package/dist/_astro/{LifeKrTodosBoard.VL7HdhNY.js → LifeKrTodosBoard.D2KTqvg1.js} +1 -1
  19. package/dist/_astro/{LifeObjectivesBoard.lLBPOHEZ.js → LifeObjectivesBoard.B0cDK934.js} +1 -1
  20. package/dist/_astro/{LifePlanTypeSelect.CdKQmlEK.js → LifePlanTypeSelect.BELDvMWU.js} +1 -1
  21. package/dist/_astro/{LifeReviewsBoard.AjO4SbsR.js → LifeReviewsBoard.BPXeVpg1.js} +1 -1
  22. package/dist/_astro/{LifeShared.CtdsQI43.js → LifeShared.tnT7aQON.js} +1 -1
  23. package/dist/_astro/{LifeStagesBoard.Dl-kTZ6K.js → LifeStagesBoard.CZftLR9K.js} +1 -1
  24. package/dist/_astro/{LifeYearCycleSelect.BILJOKXK.js → LifeYearCycleSelect.Bw2eRbSm.js} +1 -1
  25. package/dist/_astro/{LifeYearPlansBoard.BzJmi7Hw.js → LifeYearPlansBoard.DB-RJFEl.js} +1 -1
  26. package/dist/_astro/{MultiSelectDropdown.y8JMbCxO.js → MultiSelectDropdown.CBC7aNOv.js} +1 -1
  27. package/dist/_astro/NavLibraries.DdQYsZbe.js +1 -0
  28. package/dist/_astro/OverflowHint.CHZeFfUj.js +1 -0
  29. package/dist/_astro/{PluginsPage.D2OrUGY3.js → PluginsPage.C1JnInH4.js} +1 -1
  30. package/dist/_astro/PluginsPage.C3eEwy3K.js +1 -0
  31. package/dist/_astro/{PmBugsBoard.BynUocbE.js → PmBugsBoard.CGpXUTPu.js} +1 -1
  32. package/dist/_astro/{PmIterationsBoard.CvFblvfX.js → PmIterationsBoard.BaKiFIam.js} +1 -1
  33. package/dist/_astro/{PmProjectDetail.Dlm6flwk.js → PmProjectDetail.DneFVBpy.js} +1 -1
  34. package/dist/_astro/{PmProjectsBoard.B5vaWuax.js → PmProjectsBoard.BxoMF9gK.js} +1 -1
  35. package/dist/_astro/PmRequirementsBoard.-SI8VZXI.js +1 -0
  36. package/dist/_astro/{PmRequirementsBoard.piRWjiYA.js → PmRequirementsBoard.DsK6RF7Q.js} +1 -1
  37. package/dist/_astro/PmShared.BK8kWRSV.js +1 -0
  38. package/dist/_astro/{PromptMountDialog.DYojFMok.js → PromptMountDialog.mrTx3U5T.js} +1 -1
  39. package/dist/_astro/PromptsLibrary.B_SUf47p.js +1 -0
  40. package/dist/_astro/{ReportsPage.B-xhGVEU.js → ReportsPage.B9lGg1_s.js} +1 -1
  41. package/dist/_astro/{ReqAnalysisBoard.B3sAOuAq.js → ReqAnalysisBoard.CIZKnCQH.js} +1 -1
  42. package/dist/_astro/{RequirementsLibrary.BGys7DeN.js → RequirementsLibrary.cJc-bnGQ.js} +1 -1
  43. package/dist/_astro/{SearchableSelect.DFZBUFIs.js → SearchableSelect.SyLRS-Jj.js} +1 -1
  44. package/dist/_astro/SelectDropdown.T3CKHaLt.js +1 -0
  45. package/dist/_astro/{SettingsDialog.CEyjZuxq.js → SettingsDialog.DYdtCvLc.js} +1 -1
  46. package/dist/_astro/{SpaceSwitcher.DJqvw5Lw.js → SpaceSwitcher.C47_S1g9.js} +1 -1
  47. package/dist/_astro/{TableFieldConfig.D0v9S2g3.js → TableFieldConfig.C7O-mL-p.js} +1 -1
  48. package/dist/_astro/{TasksBoard.DZ9LLl_c.js → TasksBoard.BUEg2BYk.js} +1 -1
  49. package/dist/_astro/{TemplatesLibrary.iyj_kFMO.js → TemplatesLibrary.BLVIphXO.js} +1 -1
  50. package/dist/_astro/{TestReportsLibrary.B6pf0d7W.js → TestReportsLibrary.DVq30Jae.js} +1 -1
  51. package/dist/_astro/{TestStatsBoard.DS_2bqWI.js → TestStatsBoard.-5BWQ6bI.js} +1 -1
  52. package/dist/_astro/{TodosBoard.CYAVDD1W.js → TodosBoard.DI_lTp2e.js} +1 -1
  53. package/dist/_astro/UiAutoBoard.ChFdgv7s.js +2 -0
  54. package/dist/_astro/UiAutoEnvPanel.B50q4kYb.js +19 -0
  55. package/dist/_astro/UiAutoGenerationDialog.CLkFAHrm.js +1 -0
  56. package/dist/_astro/UiAutoProjectsPage.DCsDeN5d.js +3 -0
  57. package/dist/_astro/app-config.DkyjuL-S.js +1 -0
  58. package/dist/_astro/app-version.Cy-5oZO2.js +1 -0
  59. package/dist/_astro/{bash-tools.CfNj2sh0.js → bash-tools.D9HCzC_7.js} +1 -1
  60. package/dist/_astro/{case-gen-run.nrr97yK3.js → case-gen-run.BklG1H8k.js} +1 -1
  61. package/dist/_astro/{case-types.B51yDRdf.js → case-types.DlFkbZJN.js} +1 -1
  62. package/dist/_astro/composer-draft.llpvz3MW.js +1 -0
  63. package/dist/_astro/composer-task.DRi5tAJs.js +5 -0
  64. package/dist/_astro/{hydrate-cache.CoD1FB3T.js → hydrate-cache.B15Nrpq0.js} +1 -1
  65. package/dist/_astro/i18n.D_aOCHSN.js +7 -0
  66. package/dist/_astro/{open-docs-in-session.DJtuI1C4.js → open-docs-in-session.CRiZT022.js} +1 -1
  67. package/dist/_astro/plugins.BRvXWHLe.js +1 -0
  68. package/dist/_astro/prompts-meta.BUGutlsk.js +2 -0
  69. package/dist/_astro/{req-analysis.qmyv5cBw.js → req-analysis.B12_MGMQ.js} +1 -1
  70. package/dist/_astro/{settings.CYERib3l.js → settings.38J2uD5M.js} +2 -2
  71. package/dist/_astro/{spaces-client.DvIgFink.js → spaces-client.DV04tRyD.js} +1 -1
  72. package/dist/_astro/{story-review.2UUlN3p-.js → story-review.D2W5tEOY.js} +1 -1
  73. package/dist/_astro/{test-reports.DPQ-FMsQ.js → test-reports.CuIjlEyK.js} +1 -1
  74. package/dist/_astro/ui-auto-prompt.H9_yhau9.js +9 -0
  75. package/dist/_astro/ui-auto.DMv940x4.js +1 -0
  76. package/dist/_astro/{view-prefs.GnvelRDj.js → view-prefs.DhdLZjGh.js} +1 -1
  77. package/dist/case-exec/index.html +62 -6
  78. package/dist/cases/generate/index.html +62 -6
  79. package/dist/cases/library/index.html +62 -6
  80. package/dist/dashboard/index.html +62 -6
  81. package/dist/docs/changelog/index.html +138 -50
  82. package/dist/docs/install/index.html +61 -5
  83. package/dist/docs/manual/index.html +129 -21
  84. package/dist/knowledge/index.html +62 -6
  85. package/dist/life/kr-tasks/index.html +62 -6
  86. package/dist/life/kr-todos/index.html +62 -6
  87. package/dist/life/objectives/index.html +62 -6
  88. package/dist/life/reviews/index.html +62 -6
  89. package/dist/life/stages/index.html +62 -6
  90. package/dist/life/year-plans/index.html +62 -6
  91. package/dist/plugins/index.html +62 -6
  92. package/dist/pm/bugs/index.html +62 -6
  93. package/dist/pm/iterations/index.html +62 -6
  94. package/dist/pm/projects/detail/index.html +62 -6
  95. package/dist/pm/projects/index.html +62 -6
  96. package/dist/pm/requirements/index.html +62 -6
  97. package/dist/prompts/index.html +62 -6
  98. package/dist/reports/index.html +62 -6
  99. package/dist/requirement-analysis/index.html +62 -6
  100. package/dist/requirements/index.html +62 -6
  101. package/dist/tasks/index.html +62 -6
  102. package/dist/templates/index.html +62 -6
  103. package/dist/test-automation/index.html +63 -7
  104. package/dist/test-automation/projects/index.html +980 -0
  105. package/dist/test-reports/index.html +62 -6
  106. package/dist/test-stats/index.html +62 -6
  107. package/dist/todos/index.html +62 -6
  108. package/dist/workbench/index.html +62 -6
  109. package/docs//345/205/250/345/261/200/346/217/222/344/273/266.md +1 -1
  110. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +107 -63
  111. package/lh-plugins/lh-uiauto.mjs +2502 -51
  112. package/lh-plugins/plugin-prompts.mjs +62 -2
  113. package/lh-plugins/storage-domain.mjs +17 -4
  114. package/lh-plugins/uiauto-adapters/playwright.mjs +29 -14
  115. package/lh-plugins/uiauto-adapters/tasks.mjs +8 -2
  116. package/lh-plugins/uiauto-env.mjs +669 -0
  117. package/lh-plugins/uiauto-explorer/apps.mjs +4 -5
  118. package/lh-plugins/uiauto-explorer/emit-files.mjs +32 -9
  119. package/lh-plugins/uiauto-explorer/emit-ts.mjs +13 -2
  120. package/lh-plugins/uiauto-explorer/ir.mjs +20 -0
  121. package/lh-plugins/uiauto-explorer/sessions.mjs +36 -0
  122. package/lh-plugins/uiauto-node.mjs +327 -0
  123. package/lh-plugins/uiauto-pm.mjs +178 -0
  124. package/lh-plugins/uiauto-prompt.mjs +228 -18
  125. package/lh-plugins/uiauto-report.mjs +16 -0
  126. package/lh-plugins/uiauto-scaffold/audit.mjs +356 -0
  127. package/lh-plugins/uiauto-scaffold/index.mjs +25 -0
  128. package/lh-plugins/uiauto-scaffold/library.mjs +508 -0
  129. package/lh-plugins/uiauto-scaffold/manifest.mjs +83 -0
  130. package/lh-plugins/uiauto-scaffold/render.mjs +133 -0
  131. package/lh-plugins/uiauto-scaffold/templates/playwright-ts.json +225 -0
  132. package/lh-plugins/uiauto-scaffold/templates/playwright-ts.mjs +46 -0
  133. package/package.json +1 -1
  134. package/dist/_astro/Base.BnVp5Mf8.css +0 -1
  135. package/dist/_astro/ChatApp.CKPGFibd.js +0 -227
  136. package/dist/_astro/ConfirmDialog.D5qXeML0.js +0 -1
  137. package/dist/_astro/NavLibraries.BnaL-km5.js +0 -1
  138. package/dist/_astro/OverflowHint.pvo2Xc8R.js +0 -1
  139. package/dist/_astro/PluginsPage.CMW4hEFr.js +0 -1
  140. package/dist/_astro/PmRequirementsBoard.B8KTeso8.js +0 -1
  141. package/dist/_astro/PmShared.86HEsdd_.js +0 -1
  142. package/dist/_astro/PromptsLibrary.GpNbBTj1.js +0 -1
  143. package/dist/_astro/SelectDropdown.Dmk5n225.js +0 -1
  144. package/dist/_astro/SlideOverDrawer.C1IVOc_8.js +0 -1
  145. package/dist/_astro/UiAutoBoard.DSsiMfx2.js +0 -9
  146. package/dist/_astro/app-config.DwpFFa5D.js +0 -1
  147. package/dist/_astro/app-version.Dabxyva-.js +0 -1
  148. package/dist/_astro/composer-task.DJmluzPT.js +0 -5
  149. package/dist/_astro/i18n.vo2aElR9.js +0 -7
  150. package/dist/_astro/plugins.BmKRnp4a.js +0 -1
  151. package/dist/_astro/prompts-meta.bF2q5SUy.js +0 -2
  152. package/dist/_astro/ui-auto-prompt.COBTt5Gd.js +0 -4
  153. package/dist/_astro/ui-auto.BmC9JJ_X.js +0 -1
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,n as r,r as i,t as a}from"./dialog.DZHZCe_T.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";var s=e(t(),1),c=o();function l({open:e,title:t=`确认`,message:o,confirmLabel:l=`确定`,cancelLabel:u=`取消`,danger:d=!1,hideCancel:f=!1,onClose:p,onConfirm:m}){let h=(0,s.useRef)({title:t,message:o,confirmLabel:l,cancelLabel:u,danger:d,hideCancel:f});e&&(h.current={title:t,message:o,confirmLabel:l,cancelLabel:u,danger:d,hideCancel:f});let g=e?{title:t,message:o,confirmLabel:l,cancelLabel:u,danger:d,hideCancel:f}:h.current,_=g.danger===!0||g.danger===`solid`?`solid`:g.danger===`outline`?`outline`:null;return(0,c.jsxs)(i,{open:e,onClose:p,className:`relative z-110`,children:[(0,c.jsx)(a,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,c.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,c.jsxs)(n,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim relative w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,c.jsx)(`button`,{type:`button`,onClick:p,className:`tw-confirm-cancel absolute top-3.5 right-3.5 w-7 h-7 flex items-center justify-center rounded-md text-stone-400 hover:bg-stone-100 hover:text-stone-700 transition-colors`,"aria-label":`关闭`,children:`✕`}),(0,c.jsx)(r,{className:`tw-confirm-title pr-8 text-base font-semibold text-stone-900`,children:g.title}),(0,c.jsx)(`p`,{className:`tw-confirm-msg mt-3 text-sm text-stone-600 leading-relaxed whitespace-pre-wrap`,children:g.message}),(0,c.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[g.hideCancel?null:(0,c.jsx)(`button`,{type:`button`,onClick:p,className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100 transition-colors`,children:g.cancelLabel}),(0,c.jsx)(`button`,{type:`button`,onClick:m,className:_===`outline`?`h-8 px-3 text-sm rounded-lg border border-red-300 text-red-600 bg-transparent hover:bg-red-50 transition-colors`:_===`solid`?`h-8 px-3 text-sm rounded-lg text-white bg-red-600 hover:bg-red-700 transition-colors`:`h-8 px-3 text-sm rounded-lg text-white bg-[#4176e6] hover:bg-[#3566d0] transition-colors`,children:g.confirmLabel})]})]})})]})}export{l as t};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{A as n,C as r,D as i,F as a,I as o,L as s,M as c,N as l,O as u,P as d,R as f,S as p,T as m,_ as h,a as g,b as _,g as v,h as y,i as b,j as x,k as S,m as C,p as w,r as T,t as E,u as D,v as ee,w as te,x as ne,y as re}from"./app-config.DwpFFa5D.js";import{a as O,i as k,o as ie}from"./plugins.BmKRnp4a.js";import{t as A}from"./react-dom.DLW9pGCF.js";import{i as j,n as M,r as N,t as P}from"./dialog.DZHZCe_T.js";import{t as F}from"./jsx-runtime.DUg_B_vD.js";import{t as ae}from"./ConfirmDialog.D5qXeML0.js";import{showToast as I}from"./Toast.BO2NFckG.js";import{n as L}from"./i18n.vo2aElR9.js";import{n as oe}from"./hydrate-cache.CoD1FB3T.js";var R=e(t(),1),z=e(A(),1),B=`/__tb_nav/groups`;function se(){return T().navGroups}function ce(){return u(T().navIcons)}function le(e,t){let n={...ce(),[e]:t};return D({navIcons:n}),E(),n}function ue(){return T().navOrder}function de(e,t){let n=i(e),r=S(t,n);return D({navGroups:n,navOrder:r}),E(),{groups:n,order:r}}function V(e,t){return JSON.stringify(e)===JSON.stringify(t)}async function fe(e){if(!g())return null;try{let t=await fetch(B,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({groups:e}),signal:AbortSignal.timeout(4e3)});if(!t.ok)return null;let n=await t.json();return{groups:i(n.groups,!1),warnings:Array.isArray(n.warnings)?n.warnings.filter(e=>typeof e==`string`):[]}}catch{return null}}async function pe(){if(!g())return;let e=T(),t=null;try{let e=await fetch(B,{signal:AbortSignal.timeout(4e3)});e.ok&&(t=await e.json())}catch{return}if(!t)return;if(t.scanned){let n=i(t.groups,!1),r=S(e.navOrder,n);(!V(n,e.navGroups)||!V(r,e.navOrder))&&(D({navGroups:n,navOrder:r}),E());return}if(!e.navGroups.length)return;let n=await fe(e.navGroups);n&&!V(n.groups,e.navGroups)&&(D({navGroups:n.groups,navOrder:S(e.navOrder,n.groups)}),E())}function H(e,t,n){let[r,i]=(0,R.useState)(null),a=(0,R.useRef)(null),o=(0,R.useRef)(e);o.current=e;let c=(0,R.useRef)(t);c.current=t;let l=(0,R.useRef)(n);l.current=n;function u(e,t){if(t.button!==0)return;t.preventDefault(),t.stopPropagation();let n=a.current;if(!n)return;i(e);let r=e=>{let t=[...n.querySelectorAll(`[data-sort-key]`)];for(let n of t){let t=n.getBoundingClientRect();if(e>=t.top&&e<=t.bottom)return n.dataset.sortKey}return null},u=t=>{let n=r(t.clientY);if(!n||n===e)return;let i=s(o.current,e,n);i.join(`|`)!==o.current.join(`|`)&&(o.current=i,c.current(i))},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d),i(null),l.current?.()};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)}return{listRef:a,dragId:r,onPointerDown:u}}var U=F(),W=`/`;function me(e){return`${W.endsWith(`/`)?W:`${W}/`}${e.replace(/^\//,``)}`}function G(e,t){let n=W.replace(/\/$/,``),r=e.slice(n.length).replace(/^\/+/,``);return r===t||r.startsWith(`${t}/`)}function K(e){return[`tw-nav-item`,e?`is-active font-medium`:``].filter(Boolean).join(` `)}function he(e){return w(`tw.nav.groupOpen.${e}`)}function ge(){return w(`tw.nav.docsOpen`)}function _e(e,t){try{let t=localStorage.getItem(he(e));if(t===`1`)return!0;if(t===`0`)return!1;if(e===`docs`){let e=localStorage.getItem(ge());if(e===`1`)return!0;if(e===`0`)return!1}}catch{}return t}function q(e,t){try{localStorage.setItem(he(e),t?`1`:`0`),e===`docs`&&localStorage.setItem(ge(),t?`1`:`0`)}catch{}}function J(e){return e.id===`docs`&&(e.name===`文档库`||e.name===`Documents`)?L(`nav.docs`):e.name.replace(/ \(\d+\)$/,``).replace(/ \(分组\)$/,``).trim()||e.name}function ve(e){return e.type===`group`?J(e.group):L(_(e.id).i18n)}function Y(e){return e.type===`item`?te(e.id):ne(e.group.id)}function ye(){let[e,t]=(0,R.useState)(()=>window.location.pathname);return(0,R.useEffect)(()=>{let e=()=>t(window.location.pathname);return document.addEventListener(`astro:page-load`,e),document.addEventListener(`astro:after-swap`,e),window.addEventListener(`popstate`,e),()=>{document.removeEventListener(`astro:page-load`,e),document.removeEventListener(`astro:after-swap`,e),window.removeEventListener(`popstate`,e)}},[]),e}function X({children:e}){return(0,U.jsx)(`svg`,{className:`tw-nav-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:e})}function Z({id:e,icon:t}){return(0,U.jsx)(X,{children:Q[t??C[e]]})}var Q={dashboard:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,U.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,U.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1.5`}),(0,U.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`,rx:`1.5`})]}),check:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M9 11l3 3L22 4`}),(0,U.jsx)(`path`,{d:`M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11`})]}),pencil:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M12 20h9`}),(0,U.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`})]}),book:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 0 1 6.5 17H20`}),(0,U.jsx)(`path`,{d:`M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z`})]}),fileText:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M14 3v5h5`}),(0,U.jsx)(`path`,{d:`M6 2h8l6 6v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z`}),(0,U.jsx)(`path`,{d:`M8 13h8`}),(0,U.jsx)(`path`,{d:`M8 17h6`})]}),layers:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M12 3 3 8l9 5 9-5-9-5z`}),(0,U.jsx)(`path`,{d:`m3 13 9 5 9-5`})]}),list:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M8 6h13`}),(0,U.jsx)(`path`,{d:`M8 12h13`}),(0,U.jsx)(`path`,{d:`M8 18h13`}),(0,U.jsx)(`path`,{d:`M3 6h.01`}),(0,U.jsx)(`path`,{d:`M3 12h.01`}),(0,U.jsx)(`path`,{d:`M3 18h.01`})]}),folder:(0,U.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`}),star:(0,U.jsx)(`path`,{d:`m12 3 2.1 5.9L20 11l-5 4.3 1.7 6.2-5.7-3.9-5.7 3.9L7 15.3 2 11l5.9-2.1L12 3z`}),database:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`ellipse`,{cx:`12`,cy:`6`,rx:`8`,ry:`3`}),(0,U.jsx)(`path`,{d:`M4 6v6c0 1.7 3.6 3 8 3s8-1.3 8-3V6`}),(0,U.jsx)(`path`,{d:`M4 12v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]}),target:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8`}),(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`})]}),code:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`m8 8-4 4 4 4`}),(0,U.jsx)(`path`,{d:`m16 8 4 4-4 4`})]}),flask:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M9 3h6`}),(0,U.jsx)(`path`,{d:`M10 3v6l-5 8a2 2 0 0 0 1.7 3h10.6a2 2 0 0 0 1.7-3l-5-8V3`}),(0,U.jsx)(`path`,{d:`M7.5 14h9`})]}),home:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M3 10.5 12 3l9 7.5`}),(0,U.jsx)(`path`,{d:`M5 9.5V20h14V9.5`})]}),clipboard:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M9 4h6v3H9z`}),(0,U.jsx)(`path`,{d:`M8 4H6a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-2`})]}),bug:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`14`,r:`5`}),(0,U.jsx)(`path`,{d:`M9 6l2 2`}),(0,U.jsx)(`path`,{d:`M15 6l-2 2`}),(0,U.jsx)(`path`,{d:`M7 11H4`}),(0,U.jsx)(`path`,{d:`M20 11h-3`}),(0,U.jsx)(`path`,{d:`M7 17H4`}),(0,U.jsx)(`path`,{d:`M20 17h-3`})]}),calendar:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`rect`,{x:`3`,y:`5`,width:`18`,height:`16`,rx:`2`}),(0,U.jsx)(`path`,{d:`M8 3v4`}),(0,U.jsx)(`path`,{d:`M16 3v4`}),(0,U.jsx)(`path`,{d:`M3 10h18`})]}),chart:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M4 20V10`}),(0,U.jsx)(`path`,{d:`M10 20V4`}),(0,U.jsx)(`path`,{d:`M16 20v-7`}),(0,U.jsx)(`path`,{d:`M2 20h20`})]}),globe:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,U.jsx)(`path`,{d:`M3 12h18`}),(0,U.jsx)(`path`,{d:`M12 3c2.5 2.5 4 5.7 4 9s-1.5 6.5-4 9c-2.5-2.5-4-5.7-4-9s1.5-6.5 4-9z`})]}),link:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M10 13a4 4 0 0 0 5.7 0l2.3-2.3a4 4 0 0 0-5.7-5.7L11 6.3`}),(0,U.jsx)(`path`,{d:`M14 11a4 4 0 0 0-5.7 0L6 13.3a4 4 0 0 0 5.7 5.7L13 17.7`})]}),users:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`9`,cy:`8`,r:`3.5`}),(0,U.jsx)(`path`,{d:`M2.5 20a6.5 6.5 0 0 1 13 0`}),(0,U.jsx)(`path`,{d:`M16 5.5a3.5 3.5 0 0 1 0 7`}),(0,U.jsx)(`path`,{d:`M18 20a6 6 0 0 0-2-4.5`})]}),terminal:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`m5 8 4 4-4 4`}),(0,U.jsx)(`path`,{d:`M13 16h6`})]}),tag:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M20.6 13.4 13.4 20.6a2 2 0 0 1-2.8 0l-7.2-7.2a2 2 0 0 1-.6-1.4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 1.4.6l6.2 6.2a2 2 0 0 1 0 2.6z`}),(0,U.jsx)(`circle`,{cx:`8`,cy:`8`,r:`1.2`})]}),flag:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M5 21V4`}),(0,U.jsx)(`path`,{d:`M5 5h11l-2 4 2 4H5z`})]}),zap:(0,U.jsx)(`path`,{d:`M13 2 4 14h6l-1 8 9-12h-6l1-8z`}),search:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,U.jsx)(`path`,{d:`m20 20-3.5-3.5`})]}),settings:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,U.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 0 0 .3 1.9l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-2.1-.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-1.5 1.7 1.7 0 0 0-1.9.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.9 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 1.7 1.7 0 0 0-.3-1.9l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.9.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.9-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.9V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z`})]}),bell:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M18 8a6 6 0 1 0-12 0c0 5-2 6-2 6h16s-2-1-2-6`}),(0,U.jsx)(`path`,{d:`M10.3 20a2 2 0 0 0 3.4 0`})]}),clock:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,U.jsx)(`path`,{d:`M12 7v5l3.5 2`})]}),mail:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`rect`,{x:`3`,y:`5`,width:`18`,height:`14`,rx:`2`}),(0,U.jsx)(`path`,{d:`m3.5 7 8.5 6 8.5-6`})]}),message:(0,U.jsx)(`path`,{d:`M21 12a8 8 0 0 1-8 8H8l-5 3 1.4-4.6A8 8 0 1 1 21 12z`}),image:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`16`,rx:`2`}),(0,U.jsx)(`circle`,{cx:`8.5`,cy:`9.5`,r:`1.5`}),(0,U.jsx)(`path`,{d:`m4 17 5-5 3.5 3.5L16 11l4 4.5`})]}),video:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`rect`,{x:`3`,y:`6`,width:`12`,height:`12`,rx:`2`}),(0,U.jsx)(`path`,{d:`m15 11 6-3.5v9L15 13`})]}),download:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M12 3v12`}),(0,U.jsx)(`path`,{d:`m7 10 5 5 5-5`}),(0,U.jsx)(`path`,{d:`M4 20h16`})]}),upload:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M12 16V4`}),(0,U.jsx)(`path`,{d:`m7 9 5-5 5 5`}),(0,U.jsx)(`path`,{d:`M4 20h16`})]}),plus:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M12 5v14`}),(0,U.jsx)(`path`,{d:`M5 12h14`})]}),trash:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M4 7h16`}),(0,U.jsx)(`path`,{d:`M9 7V4h6v3`}),(0,U.jsx)(`path`,{d:`M6 7l1 13h10l1-13`}),(0,U.jsx)(`path`,{d:`M10 11v6M14 11v6`})]}),lock:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`rect`,{x:`4`,y:`10`,width:`16`,height:`11`,rx:`2`}),(0,U.jsx)(`path`,{d:`M8 10V7a4 4 0 0 1 8 0v3`})]}),shield:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M12 3l7 3v6c0 4.2-2.9 7.5-7 9-4.1-1.5-7-4.8-7-9V6l7-3z`}),(0,U.jsx)(`path`,{d:`m9 12 2 2 4-4`})]}),key:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`8`,cy:`12`,r:`4`}),(0,U.jsx)(`path`,{d:`M12 12h9`}),(0,U.jsx)(`path`,{d:`M17 12v4M20 12v3`})]}),cloud:(0,U.jsx)(`path`,{d:`M7 18h10a4 4 0 0 0 .5-8 6 6 0 0 0-11.4 1.5A3.5 3.5 0 0 0 7 18z`}),box:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`m12 3 8 4.5v9L12 21l-8-4.5v-9L12 3z`}),(0,U.jsx)(`path`,{d:`m4 7.5 8 4.5 8-4.5`}),(0,U.jsx)(`path`,{d:`M12 12v9`})]}),filter:(0,U.jsx)(`path`,{d:`M3 5h18l-7 8v6l-4 2v-8L3 5z`}),grid:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`rect`,{x:`4`,y:`4`,width:`6.5`,height:`6.5`,rx:`1`}),(0,U.jsx)(`rect`,{x:`13.5`,y:`4`,width:`6.5`,height:`6.5`,rx:`1`}),(0,U.jsx)(`rect`,{x:`4`,y:`13.5`,width:`6.5`,height:`6.5`,rx:`1`}),(0,U.jsx)(`rect`,{x:`13.5`,y:`13.5`,width:`6.5`,height:`6.5`,rx:`1`})]}),pin:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M12 21v-7`}),(0,U.jsx)(`path`,{d:`M8 4h8l-1 6 3 3H6l3-3-1-6z`})]}),sparkle:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`m12 3 1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3z`}),(0,U.jsx)(`path`,{d:`M18 16.5 18.7 18.3 20.5 19 18.7 19.7 18 21.5 17.3 19.7 15.5 19 17.3 18.3 18 16.5z`})]}),rocket:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M13.5 4.5c3-2 5.5-1.5 5.5-1.5s.5 2.5-1.5 5.5c-1.6 2.4-4.5 5-6.5 6.5l-3.5-3.5c1.5-2 4.1-4.9 6-7z`}),(0,U.jsx)(`path`,{d:`M8 12 5 13l-2 4 5-1`}),(0,U.jsx)(`path`,{d:`M12 16l-1 3 4-2 1-3`}),(0,U.jsx)(`circle`,{cx:`15`,cy:`9`,r:`1.2`})]}),eye:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M2.5 12S6 6 12 6s9.5 6 9.5 6-3.5 6-9.5 6-9.5-6-9.5-6z`}),(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`2.8`})]}),bookmark:(0,U.jsx)(`path`,{d:`M7 3h10a1 1 0 0 1 1 1v17l-6-4-6 4V4a1 1 0 0 1 1-1z`}),archive:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`4`,rx:`1`}),(0,U.jsx)(`path`,{d:`M5 8v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8`}),(0,U.jsx)(`path`,{d:`M10 12h4`})]}),refresh:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M20 12a8 8 0 1 1-2.4-5.7`}),(0,U.jsx)(`path`,{d:`M20 4v5h-5`})]}),play:(0,U.jsx)(`path`,{d:`M8 5v14l11-7L8 5z`}),map:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`m3 6 6-2 6 2 6-2v14l-6 2-6-2-6 2V6z`}),(0,U.jsx)(`path`,{d:`M9 4v14M15 6v14`})]}),activity:(0,U.jsx)(`path`,{d:`M3 12h4l3-7 4 14 3-7h4`}),cpu:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`rect`,{x:`7`,y:`7`,width:`10`,height:`10`,rx:`2`}),(0,U.jsx)(`path`,{d:`M10 3v4M14 3v4M10 17v4M14 17v4M3 10h4M3 14h4M17 10h4M17 14h4`})]}),briefcase:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`rect`,{x:`3`,y:`8`,width:`18`,height:`12`,rx:`2`}),(0,U.jsx)(`path`,{d:`M9 8V5h6v3`}),(0,U.jsx)(`path`,{d:`M3 13h18`})]}),presentation:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`12`,rx:`2`}),(0,U.jsx)(`path`,{d:`M12 16v4`}),(0,U.jsx)(`path`,{d:`m8 22 4-4 4 4`}),(0,U.jsx)(`path`,{d:`M8 8h8M8 12h5`})]}),copy:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`rect`,{x:`8`,y:`8`,width:`12`,height:`12`,rx:`2`}),(0,U.jsx)(`path`,{d:`M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2`})]}),save:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z`}),(0,U.jsx)(`path`,{d:`M7 3v6h9`}),(0,U.jsx)(`path`,{d:`M8 21v-6h8v6`})]})};function be(){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`svg`,{className:`tw-nav-ico tw-nav-ico--closed`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,U.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`})}),(0,U.jsx)(`svg`,{className:`tw-nav-ico tw-nav-ico--open`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,U.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`})})]})}function xe(){return(0,U.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:[(0,U.jsx)(`path`,{d:`M21 4H14`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M10 4H3`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M21 12H12`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M8 12H3`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M21 20H16`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M12 20H3`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M14 2v4`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M8 10v4`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M16 18v4`,strokeLinecap:`round`})]})}function Se(){return(0,U.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,U.jsx)(`path`,{d:`M12 8v8`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M8 12h8`,strokeLinecap:`round`})]})}function Ce(){return(0,U.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,children:[(0,U.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.7`}),(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.7`}),(0,U.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.7`})]})}function we(){return(0,U.jsx)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,U.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 Te(){return(0,U.jsxs)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,U.jsx)(`path`,{d:`M9 6H5a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h4`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M16 8l4 4-4 4`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`path`,{d:`M20 12H9`,strokeLinecap:`round`})]})}function Ee(){return(0,U.jsxs)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,U.jsx)(`circle`,{cx:`8.5`,cy:`8.5`,r:`4.5`}),(0,U.jsx)(`rect`,{x:`12`,y:`12`,width:`9`,height:`9`,rx:`2`})]})}function De(){return(0,U.jsxs)(X,{children:[(0,U.jsx)(`path`,{d:`M8 6v12`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M5 9l3-3 3 3`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`path`,{d:`M16 18V6`,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M13 15l3 3 3-3`,strokeLinecap:`round`,strokeLinejoin:`round`})]})}function Oe(){return(0,U.jsxs)(`svg`,{className:`tw-nav-drag-grip`,viewBox:`0 0 20 20`,"aria-hidden":!0,children:[(0,U.jsx)(`circle`,{cx:`7`,cy:`5`,r:`1.25`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`13`,cy:`5`,r:`1.25`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`7`,cy:`10`,r:`1.25`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`13`,cy:`10`,r:`1.25`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`7`,cy:`15`,r:`1.25`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`13`,cy:`15`,r:`1.25`,fill:`currentColor`})]})}function $(e,t){if(r(e))return!1;let n=_(e).plugin;return!n||t[n]!==!1}function ke({id:e,icon:t,pathname:n,actionOpen:r,onMenu:i}){let a=_(e),o=G(n,a.match);return(0,U.jsxs)(`div`,{className:[K(o),r?`is-action-open`:``].filter(Boolean).join(` `),"data-plugin-nav":a.plugin,children:[(0,U.jsxs)(`a`,{href:me(a.href),className:`tw-nav-item-main`,children:[(0,U.jsx)(Z,{id:e,icon:t}),(0,U.jsx)(`span`,{className:`tw-nav-label`,children:L(a.i18n)})]}),(0,U.jsx)(`button`,{type:`button`,className:`tw-nav-hover-btn`,"aria-label":L(`nav.more`),onClick:e=>{e.preventDefault(),e.stopPropagation(),i(e.currentTarget)},children:(0,U.jsx)(Ce,{})})]})}function Ae(e,t,n){return e.items.some(e=>{if(r(e))return!1;let t=_(e).plugin;return(!t||k(t))&&G(n,_(e).match)})?!0:m(t,e.id).some(e=>Ae(e,t,n))}function je(e,t){return e.items.some(e=>{if(r(e))return!1;let t=_(e).plugin;return!t||k(t)})?!0:m(t,e.id).some(e=>je(e,t))}function Me({group:e,groups:t,order:n,icons:i,pathname:a,openItem:o,openGroupId:s,onMenu:c,onItemMenu:l}){let u=e.items.filter(e=>{if(r(e))return!1;let t=_(e).plugin;return!t||k(t)}),f=d(t,e.id,n),p=Ae(e,t,a),[m,h]=(0,R.useState)(()=>_e(e.id,!0)),[g,v]=(0,R.useState)(!1),y=(0,R.useRef)(null),b=(0,R.useRef)(null),x=(0,R.useRef)(null);if((0,R.useEffect)(()=>S,[]),!je(e,t))return null;function S(){x.current&&y.current&&y.current.removeEventListener(`transitionend`,x.current),x.current=null,b.current!==null&&(window.clearTimeout(b.current),b.current=null)}function C(){S(),q(e.id,!0),v(!1),h(!0)}function w(t){if(t.preventDefault(),!m||g){C();return}v(!0),q(e.id,!1);let n=y.current,r=!1,i=()=>{r||(r=!0,S(),h(!1),v(!1))},a=e=>{e.target===n&&e.propertyName===`grid-template-rows`&&i()};S(),x.current=a,n?.addEventListener(`transitionend`,a),b.current=window.setTimeout(i,360)}return(0,U.jsxs)(`details`,{className:`tw-nav-details ${g?`is-closing`:``}`,open:m||g,"data-nav-group":e.id,children:[(0,U.jsxs)(`summary`,{className:[`tw-nav-item tw-nav-summary`,p?`is-branch-active`:``,s===e.id?`is-action-open`:``].filter(Boolean).join(` `),onClick:w,children:[(0,U.jsx)(be,{}),(0,U.jsx)(`span`,{className:`tw-nav-label min-w-0 flex-1 truncate`,children:J(e)}),(0,U.jsx)(`button`,{type:`button`,className:`tw-nav-hover-btn`,"aria-label":L(`nav.groupActions`),onClick:t=>{t.preventDefault(),t.stopPropagation(),c(e,t.currentTarget)},children:(0,U.jsx)(xe,{})}),(0,U.jsx)(`svg`,{className:`tw-nav-chevron opacity-70`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,U.jsx)(`path`,{d:`M7 5l6 5-6 5`,strokeLinecap:`round`,strokeLinejoin:`round`})})]}),(0,U.jsx)(`div`,{className:`tw-nav-subtree-anim`,ref:y,children:(0,U.jsxs)(`div`,{className:`tw-nav-subtree`,children:[u.map(e=>(0,U.jsx)(ke,{id:e,icon:i[e],pathname:a,actionOpen:o===e,onMenu:t=>l(e,t)},e)),f.map(e=>(0,U.jsx)(Me,{group:e,groups:t,order:n,icons:i,pathname:a,openItem:o,openGroupId:s,onMenu:c,onItemMenu:l},e.id))]})})]})}function Ne({open:e,draft:t,groups:n,plugins:r,icons:i,onClose:a,onSave:o,onDelete:s}){let[c,l]=(0,R.useState)(``),[u,d]=(0,R.useState)([]),[f,p]=(0,R.useState)(``),m=(0,R.useRef)(null),h=new Set(n.filter(e=>e.id!==t?.id).flatMap(e=>e.items)),g=y.filter(e=>$(e.id,r)&&(!h.has(e.id)||u.includes(e.id))),_=H(u,d);(0,R.useEffect)(()=>{if(!e||!t)return;l(t.name),d(t.items.filter(e=>$(e,r))),p(``);let n=window.setTimeout(()=>{m.current?.focus(),m.current?.select()},50);return()=>window.clearTimeout(n)},[e,t,r]);function v(e){d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function b(){let e=c.trim();if(!e){p(L(`nav.groupNameRequired`));return}if(!u.length){p(L(`nav.groupItemsRequired`));return}let n=(t?.items??[]).filter(e=>!$(e,r));o({id:t?.id,name:e,items:[...n,...u],parentId:t?.parentId})}let x=[...u.map(e=>g.find(t=>t.id===e)).filter(e=>!!e),...g.filter(e=>!u.includes(e.id))];return(0,U.jsxs)(N,{open:e,onClose:a,className:`relative z-110`,children:[(0,U.jsx)(P,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":!0}),(0,U.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,U.jsxs)(j,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,U.jsx)(M,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:t?.id?L(`nav.editGroupTitle`):t?.parentId?L(`nav.addSubgroup`):L(`nav.createGroup`)}),(0,U.jsxs)(`label`,{className:`tw-confirm-msg mt-4 block text-xs font-medium text-stone-500`,children:[L(`nav.groupName`),(0,U.jsx)(`input`,{ref:m,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),b())},className:`mt-1.5 w-full h-9 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6]`})]}),(0,U.jsxs)(`div`,{className:`mt-4`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:L(`nav.groupItems`)}),(0,U.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:L(`nav.groupItemsHint`)}),(0,U.jsxs)(`div`,{ref:_.listRef,className:`mt-2 max-h-52 overflow-auto rounded-lg border border-stone-200 p-1`,children:[x.map(e=>{let t=u.includes(e.id);return(0,U.jsxs)(`label`,{"data-sort-key":t?e.id:void 0,className:[`flex items-center gap-2 rounded-md px-3 py-2 text-sm text-stone-700 cursor-pointer hover:bg-stone-50`,t?`tw-nav-drag-row`:``,_.dragId===e.id?`is-dragging`:``].filter(Boolean).join(` `),onPointerDown:t?t=>{t.target.closest(`input`)||_.onPointerDown(e.id,t)}:void 0,children:[t?(0,U.jsx)(Oe,{}):(0,U.jsx)(`span`,{className:`tw-nav-drag-grip`}),(0,U.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>v(e.id),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40`}),(0,U.jsx)(`span`,{className:`tw-nav-editor-ico`,children:(0,U.jsx)(Z,{id:e.id,icon:i[e.id]})}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:L(e.i18n)})]},e.id)}),x.length?null:(0,U.jsx)(`div`,{className:`px-3 py-4 text-center text-[12px] text-stone-400`,children:L(`nav.noAddableItems`)})]})]}),f?(0,U.jsx)(`p`,{className:`mt-2 text-[12px] text-red-600`,children:f}):null,(0,U.jsxs)(`div`,{className:`mt-5 flex items-center gap-2`,children:[t?.id&&s?(0,U.jsx)(`button`,{type:`button`,onClick:s,className:`h-8 px-3 text-sm rounded-lg border border-red-200 text-red-600 hover:bg-red-50`,children:L(`nav.deleteGroup`)}):null,(0,U.jsx)(`div`,{className:`flex-1`}),(0,U.jsx)(`button`,{type:`button`,onClick:a,className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100`,children:L(`nav.groupCancel`)}),(0,U.jsx)(`button`,{type:`button`,onClick:b,className:`h-8 px-3 text-sm rounded-lg text-white bg-[#4176e6] hover:bg-[#3566d0]`,children:L(`nav.groupSave`)})]})]})})]})}function Pe({ids:e,labelOf:t,onChange:n,onEnd:r,indent:i}){let a=H(e,n,r);return(0,U.jsx)(`div`,{ref:a.listRef,className:`flex flex-col`,children:e.map(e=>(0,U.jsxs)(`div`,{"data-sort-key":e,className:[`tw-nav-drag-row px-3 py-2 text-sm text-stone-700 hover:bg-stone-50`,i?`tw-nav-drag-row--nested`:``,a.dragId===e?`is-dragging`:``].filter(Boolean).join(` `),onPointerDown:t=>a.onPointerDown(e,t),children:[(0,U.jsx)(Oe,{}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t(e)})]},e))})}function Fe({open:e,focusGroupId:t,nodes:n,groups:r,order:i,visible:a,onClose:o,onCommit:s,onChildCommit:c}){let l=e=>!a||a(e),u=e=>e.items.some(l)||r.filter(t=>t.parentId===e.id).some(e=>u(e)),f=n.filter(e=>e.type===`item`?l(e.id):u(e.group)),[p,m]=(0,R.useState)(()=>f.map(Y)),[h,g]=(0,R.useState)(()=>Object.fromEntries(r.map(e=>[e.id,[...e.items]]))),[v,y]=(0,R.useState)([]),b=(0,R.useRef)(p);b.current=p;let x=(0,R.useRef)(h);x.current=h;let S=(0,R.useRef)(r);S.current=r;let C=(0,R.useRef)(i);C.current=i;let w=(0,R.useRef)(f);w.current=f;let T=(0,R.useRef)(v);T.current=v;let E=()=>{let e=S.current.map(e=>({...e,items:x.current[e.id]??e.items}));s(b.current,e)},D=()=>{t&&c(t,T.current)};(0,R.useEffect)(()=>{if(!e)return;let n=w.current.map(Y);b.current=n,m(n);let r=Object.fromEntries(S.current.map(e=>[e.id,[...e.items]]));x.current=r,g(r);let i=t?d(S.current,t,C.current).map(e=>e.id):[];T.current=i,y(i)},[e,t]);let ee=e=>{b.current=e,m(e)},te=e=>{T.current=e,y(e)},ne=(e,t)=>{let n=(x.current[e]??[]).filter(e=>!l(e)),r={...x.current,[e]:t.length?[...t,...n]:n};x.current=r,g(r)},re=new Map(f.map(e=>[Y(e),ve(e)])),O=t?r.find(e=>e.id===t):void 0,k=O?(h[O.id]??O.items).filter(l):[],ie=O?d(r,O.id,i):[],A=v.length?v:ie.map(e=>e.id);return(0,U.jsxs)(N,{open:e,onClose:o,className:`relative z-110`,children:[(0,U.jsx)(P,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":!0}),(0,U.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,U.jsxs)(j,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,U.jsx)(M,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:L(`nav.sortMenuTitle`)}),(0,U.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:L(`nav.sortHint`)}),(0,U.jsx)(`div`,{className:`mt-4 max-h-80 overflow-auto rounded-lg border border-stone-200 p-1`,children:O?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Pe,{ids:k,labelOf:e=>L(_(e).i18n),onChange:e=>ne(O.id,e),onEnd:E,indent:!0}),A.length?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`mt-1 border-t border-stone-100 px-3 pb-1 pt-2 text-[11px] font-medium text-stone-400`,children:L(`nav.subgroups`)}),(0,U.jsx)(Pe,{ids:A,labelOf:e=>{let t=r.find(t=>t.id===e);return t?J(t):e},onChange:te,onEnd:D,indent:!0})]}):null]}):(0,U.jsx)(Pe,{ids:p,labelOf:e=>re.get(e)??e,onChange:ee,onEnd:E})})]})})]})}function Ie(e,t){let n=[];for(let r of e.filter(e=>!e.parentId)){n.push({group:r,indent:!1});for(let i of d(e,r.id,t))n.push({group:i,indent:!0})}return n}function Le(){return(0,U.jsx)(`svg`,{className:`tw-nav-group-pop-arrow`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,U.jsx)(`path`,{d:`M7 5l5 5-5 5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}var Re=120;function ze(){let[e,t]=(0,R.useState)(null),n=(0,R.useRef)(null),r=(0,R.useCallback)(()=>{n.current!==null&&(window.clearTimeout(n.current),n.current=null)},[]),i=(0,R.useCallback)(e=>{r(),t({value:e,closing:!1})},[r]),a=(0,R.useCallback)(()=>{r(),t(e=>e&&!e.closing?{...e,closing:!0}:e),n.current=window.setTimeout(()=>{n.current=null,t(null)},Re)},[r]),o=(0,R.useCallback)(()=>{r(),t(null)},[r]);return(0,R.useEffect)(()=>r,[r]),{value:e?.value??null,closing:!!e?.closing,open:i,close:a,closeNow:o}}function Be(e,t){return{onMouseOver:()=>e?.(),onMouseOut:e=>{let n=e.relatedTarget;n&&e.currentTarget.contains(n)||t?.()}}}function Ve({anchor:e,current:t,itemId:n,closing:r,onPick:i,onHoverEnter:a,onHoverLeave:o}){let s=(0,R.useRef)(null),[c,l]=(0,R.useState)({top:e.top,left:e.right+8});return(0,R.useEffect)(()=>{let t=s.current;if(!t)return;let n=t.offsetWidth,r=t.offsetHeight,i=e.right+8,a=e.top-6;i+n>window.innerWidth-8&&(i=Math.max(8,e.left-n-6)),a+r>window.innerHeight-8&&(a=Math.max(8,window.innerHeight-r-8)),a<8&&(a=8),l({top:a,left:i})},[e]),(0,z.createPortal)((0,U.jsxs)(`div`,{ref:s,className:[`tw-nav-group-pop`,`tw-nav-icon-pop`,r?`is-closing`:``].filter(Boolean).join(` `),style:{top:c.top,left:c.left},...Be(a,o),children:[(0,U.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:L(`nav.chooseIcon`)}),(0,U.jsx)(`div`,{className:`tw-nav-icon-grid`,children:v.map(e=>(0,U.jsx)(`button`,{type:`button`,className:[`tw-nav-icon-cell`,t===e?`is-current`:``].filter(Boolean).join(` `),onClick:()=>i(e),children:(0,U.jsx)(Z,{id:n,icon:e})},e))})]}),document.body)}function He({rect:e,closing:t=!1,onClose:n,onHoverEnter:r,onHoverLeave:i,children:a}){let o=(0,R.useRef)(null),[s,c]=(0,R.useState)({top:e.top,left:e.right+6});return(0,R.useEffect)(()=>{let t=o.current;if(!t)return;let n=t.offsetWidth,r=t.offsetHeight,i=e.right+6,a=e.top;i+n>window.innerWidth-8&&(i=Math.max(8,e.left-n-6)),a+r>window.innerHeight-8&&(a=Math.max(8,window.innerHeight-r-8)),c({top:a,left:i})},[e]),(0,R.useEffect)(()=>{let e=e=>{let t=e.target;o.current?.contains(t)||t?.closest?.(`.tw-nav-icon-pop`)||t?.closest?.(`.tw-nav-hover-btn`)||n()},t=e=>{e.key===`Escape`&&n()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),window.addEventListener(`resize`,n),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t),window.removeEventListener(`resize`,n)}},[n]),(0,z.createPortal)((0,U.jsx)(`div`,{ref:o,className:[`tw-nav-group-pop`,t?`is-closing`:``].filter(Boolean).join(` `),style:{top:s.top,left:s.left},...Be(r,i),children:a}),document.body)}function Ue(){let e=ye(),[t,r]=(0,R.useState)(()=>se()),[i,s]=(0,R.useState)(()=>ce()),[u,d]=(0,R.useState)(()=>ue()),[m,g]=(0,R.useState)(()=>O()),[v,y]=(0,R.useState)(null),[S,C]=(0,R.useState)(!1),[w,T]=(0,R.useState)(null),[E,D]=(0,R.useState)(!1),[te,ne]=(0,R.useState)(null),k=ze(),A=ze(),j=k.value,M=A.value,N=(0,R.useRef)(null);(0,R.useEffect)(()=>()=>{N.current!==null&&window.clearTimeout(N.current)},[]);function P(e){ne(e),D(!0)}function F(e){y(e),C(!0)}function z(){C(!1),T(null)}(0,R.useEffect)(()=>{let e=!0,t=ie(e=>{g({...e})});return b().then(async()=>{e&&(await pe(),e&&(r(se()),d(ue()),s(ce()),g(O())))}),()=>{e=!1,t()}},[]);let B=ee(t,u);(0,R.useEffect)(()=>{let e=window.setTimeout(()=>{let e=document.querySelector(`.tw-nav-libraries > astro-island`);e&&e.querySelector(`.tw-nav-item-main`)&&oe(`nav`,e.innerHTML)},400);return()=>window.clearTimeout(e)});function V(e,t){let n=de(e,t);r(n.groups),d(n.order),fe(n.groups).then(e=>{if(!e||(e.warnings.length&&I(`分组已保存,但${e.warnings[0]}`,`error`),JSON.stringify(e.groups)===JSON.stringify(n.groups)))return;let t=de(e.groups,n.order);r(t.groups),d(t.order)})}function H(){W(),A.close(),k.close()}function W(){N.current!==null&&(window.clearTimeout(N.current),N.current=null)}function me(){W(),N.current=window.setTimeout(()=>{N.current=null,A.close()},220)}function G(e,t){W(),A.open({itemId:e,rect:t.getBoundingClientRect()})}function K(e,t){j?.kind===`itemMenu`&&j.itemId===e?H():(A.closeNow(),k.open({kind:`itemMenu`,itemId:e,rect:t.getBoundingClientRect()}))}function he(e,t){j?.kind===`groupMenu`&&j.group.id===e.id?H():(A.closeNow(),k.open({kind:`groupMenu`,group:e,rect:t.getBoundingClientRect()}))}function ge(e,n){V(h(t,e,n),u),H();let r=t.find(t=>t.id===e);I(`已加入分组「${r?J(r):``}」`,`success`)}function _e(e){let{groups:n,owner:r}=a(t,e);V(n,r?x(u,e,r,n):u),H(),I(`已移出分组`,`success`)}let q=j?.kind===`assign`||j?.kind===`itemMenu`?j.itemId:void 0,ve=j?.kind===`groupMenu`?j.group.id:void 0,Y=j?.kind===`itemMenu`?j:null,X=j?.kind===`groupMenu`?j:null,Z=j?.kind===`assign`?j:null,Q=Y?t.find(e=>e.items.includes(Y.itemId))??null:null;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`tw-nav-ready`,"aria-hidden":`true`}),B.map(n=>n.type===`item`?$(n.id,m)?(0,U.jsx)(ke,{id:n.id,icon:i[n.id],pathname:e,actionOpen:q===n.id,onMenu:e=>K(n.id,e)},n.id):null:(0,U.jsx)(Me,{group:n.group,groups:t,order:u,icons:i,pathname:e,openItem:q,openGroupId:ve,onMenu:he,onItemMenu:K},n.group.id)),Y?(0,U.jsxs)(He,{rect:Y.rect,closing:k.closing,onClose:H,onHoverEnter:W,onHoverLeave:me,children:[(0,U.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:L(_(Y.itemId).i18n)}),(0,U.jsxs)(`div`,{className:`tw-nav-group-pop-list`,onMouseOver:e=>{let t=e.target.closest(`.tw-nav-group-pop-item`);t&&t.getAttribute(`data-submenu`)!==`icons`&&(W(),A.close())},children:[Q?(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item is-leave`,onClick:()=>_e(Y.itemId),children:[(0,U.jsx)(Te,{}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.leaveGroup`)})]}):null,(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>k.open({kind:`assign`,itemId:Y.itemId,rect:Y.rect}),children:[(0,U.jsx)(we,{}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.assignGroup`)})]}),Q?null:(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=Y.itemId;H(),F({name:``,items:[e]})},children:[(0,U.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,U.jsx)(Se,{})}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.addToGroup`)})]}),(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=Q?.id??null;H(),P(e)},children:[(0,U.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,U.jsx)(De,{})}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.sortMenu`)})]}),(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,"data-submenu":`icons`,onMouseEnter:e=>G(Y.itemId,e.currentTarget),onClick:e=>G(Y.itemId,e.currentTarget),children:[(0,U.jsx)(Ee,{}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.chooseIcon`)}),(0,U.jsx)(Le,{})]})]})]}):null,M&&Y&&M.itemId===Y.itemId?(0,U.jsx)(Ve,{anchor:M.rect,itemId:M.itemId,current:i[M.itemId],closing:A.closing,onHoverEnter:W,onHoverLeave:me,onPick:e=>{s(le(M.itemId,e)),H(),I(`已更换图标`,`success`)}}):null,X?(0,U.jsxs)(He,{rect:X.rect,closing:k.closing,onClose:H,children:[(0,U.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:J(X.group)}),(0,U.jsxs)(`div`,{className:`tw-nav-group-pop-list`,children:[X.group.parentId?null:(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item is-create`,onClick:()=>{let e=X.group.id;H(),F({name:``,items:[],parentId:e})},children:[(0,U.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,U.jsx)(Se,{})}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.addSubgroup`)})]}),(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=X.group;H(),P(e.parentId??null)},children:[(0,U.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,U.jsx)(De,{})}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.sortMenu`)})]}),(0,U.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=X.group;H(),F({id:e.id,name:e.name,items:[...e.items],parentId:e.parentId})},children:[(0,U.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,U.jsx)(xe,{})}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:L(`nav.editGroupTitle`)})]})]})]}):null,Z?(0,U.jsxs)(He,{rect:Z.rect,closing:k.closing,onClose:H,children:[(0,U.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:L(`nav.assignGroup`)}),(0,U.jsx)(`div`,{className:`tw-nav-group-pop-list`,children:(()=>{let e=t.find(e=>e.items.includes(Z.itemId))?.id??null,n=Ie(t,u).filter(({group:t})=>t.id!==e);return n.length?n.map(({group:e,indent:t})=>(0,U.jsxs)(`button`,{type:`button`,className:[`tw-nav-group-pop-item`,t?`is-child`:``].filter(Boolean).join(` `),onClick:()=>ge(e.id,Z.itemId),children:[(0,U.jsx)(we,{}),(0,U.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:J(e)})]},e.id)):(0,U.jsx)(`div`,{className:`tw-nav-group-pop-empty`,children:L(e?`nav.noOtherGroups`:`nav.noGroups`)})})()})]}):null,(0,U.jsx)(Ne,{open:S&&!w,draft:v,groups:t,plugins:m,icons:i,onClose:z,onSave:e=>{let n=!t.some(t=>t.id===e.id),r=f(t,e);V(r.groups,l(u,r.groups,r.id));let i=r.groups.find(e=>e.id===r.id);I(n?`已新增分组「${i?J(i):e.name}」`:`已保存分组`,`success`),z()},onDelete:v?.id?()=>T(v.id):void 0}),(0,U.jsx)(Fe,{open:E,focusGroupId:te,nodes:B,groups:t,order:u,visible:e=>$(e,m),onClose:()=>D(!1),onCommit:(e,t)=>{let n=u.filter(e=>p(e,t));V(t,[...e,...n.filter(t=>!e.includes(t))])},onChildCommit:(e,r)=>V(t,n(u,t,e,r))}),(0,U.jsx)(ae,{open:!!w,title:L(`nav.deleteGroup`),message:t.find(e=>e.id===w)?.parentId?L(`nav.deleteSubgroupMsg`):L(`nav.deleteGroupMsg`),confirmLabel:L(`nav.deleteGroup`),cancelLabel:L(`nav.groupCancel`),danger:`outline`,onClose:()=>T(null),onConfirm:()=>{if(w){let e=t.find(e=>e.id===w),n=re(t,w),r=o(t,w);V(r,e?c(u,e,r,n):u),e&&I(`已删除分组「${J(e)}」`,`success`)}z()}})]})}export{Ue as default};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./react-dom.DLW9pGCF.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";var i=e(t(),1),a=e(n(),1),o=r(),s=80,c=420,l=14,u=150;function d({text:e,className:t,disabled:n=!1,matchAnchorWidth:r=!1,clamp:d=`x`}){let f=(0,i.useRef)(null),[p,m]=(0,i.useState)(!1),[h,g]=(0,i.useState)(!1),[_,v]=(0,i.useState)(!1),[y,b]=(0,i.useState)(!1),[x,S]=(0,i.useState)(null);(0,i.useLayoutEffect)(()=>{let e=f.current;if(!e)return;let t=()=>m(d!==`y`&&e.scrollWidth>e.clientWidth+1||d!==`x`&&e.scrollHeight>e.clientHeight+1);t();let n=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return n?.observe(e),window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t)}},[e,d]),(0,i.useLayoutEffect)(()=>{(n||!p)&&g(!1)},[n,p]),(0,i.useLayoutEffect)(()=>{if(h){v(!0);let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>b(!0))});return()=>{cancelAnimationFrame(t),e&&cancelAnimationFrame(e)}}b(!1);let e=window.setTimeout(()=>v(!1),u);return()=>window.clearTimeout(e)},[h]);let C=(0,i.useCallback)(()=>{let e=f.current;if(!e)return;let t=e.getBoundingClientRect(),n=(r?e.closest(`[data-hint-width]`)??e:e).getBoundingClientRect(),i=r?n.width:t.width,a=Math.min(Math.max(i,160),c),o=t.bottom+72>window.innerHeight-8,s=o?t.top-6:t.bottom+6,u=r?n.left:t.left,d=Math.max(8,Math.min(u,Math.max(8,window.innerWidth-a-8))),p=Math.max(l,Math.min(t.left+t.width/2-d,a-l));S(e=>e&&e.top===s&&e.left===d&&e.maxWidth===a&&e.openUp===o&&e.arrowLeft===p?e:{top:s,left:d,maxWidth:a,openUp:o,arrowLeft:p})},[r]);return(0,i.useLayoutEffect)(()=>{_?C():S(null)}),(0,i.useLayoutEffect)(()=>{if(!_)return;let e=()=>C();return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[_,C]),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{ref:f,className:t,onMouseEnter:()=>{p&&!n&&g(!0)},onMouseLeave:()=>g(!1),children:e}),_&&x&&typeof document<`u`?(0,a.createPortal)((0,o.jsxs)(`div`,{role:`tooltip`,"data-closed":y?void 0:``,className:`tw-tooltip tw-tooltip-anim ${x.openUp?`is-up`:`is-down`} pointer-events-none fixed rounded-md px-2 py-1 text-[12px] leading-5 break-all text-stone-700 shadow-lg`,style:{zIndex:s,top:x.top,left:x.left,maxWidth:x.maxWidth,...r?{width:x.maxWidth}:null},children:[(0,o.jsx)(`span`,{"aria-hidden":`true`,className:`tw-tooltip-arrow ${x.openUp?`is-up`:`is-down`} absolute h-2 w-2`,style:{left:x.arrowLeft,...x.openUp?{bottom:-5}:{top:-5},transform:`translateX(-50%) rotate(45deg)`}}),(0,o.jsx)(`span`,{className:`whitespace-pre-wrap`,children:e})]}),document.body):null]})}export{d as t};
@@ -1 +0,0 @@
1
- export{t as default}from"./PluginsPage.D2OrUGY3.js";
@@ -1 +0,0 @@
1
- export{t as default}from"./PmRequirementsBoard.piRWjiYA.js";
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.DwpFFa5D.js";import{i as r,o as i}from"./plugins.BmKRnp4a.js";import{n as a,o,r as s,s as c}from"./view-prefs.GnvelRDj.js";import{t as l}from"./react-dom.DLW9pGCF.js";import{t as u}from"./jsx-runtime.DUg_B_vD.js";import{t as d}from"./OverflowHint.pvo2Xc8R.js";import{t as f}from"./SelectDropdown.Dmk5n225.js";import{_ as p,v as m,y as h}from"./pm.BXmOiFfW.js";import{t as g}from"./SlideOverDrawer.C1IVOc_8.js";var _=e(t(),1),v=e(l(),1),y=u(),b=8e3;function x(e,t,n){let[r,i]=(0,_.useState)(()=>a(e,t,n));return[r,(0,_.useCallback)(t=>{i(t),o(e,t)},[e])]}function S(e,t=``){let[n,r]=(0,_.useState)(()=>s(e)||t);return[n,(0,_.useCallback)(n=>{r(n),c(e,n===t?``:n)},[e,t])]}function C(e){let[t,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(()=>r(e));return(0,_.useEffect)(()=>{let t=!0,o=i(()=>s(r(e)));return n().then(()=>{t&&(s(r(e)),a(!0))}),()=>{t=!1,o()}},[e]),{ready:t,on:o}}var w=(0,_.createContext)(null);function T(e){let[t,n]=(0,_.useState)(p),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(!0),[s,c]=(0,_.useState)(``),l=(0,_.useRef)(!0),u=(0,_.useCallback)(async(e=!1)=>{e||o(!0);try{let e=await h();return l.current?(n(e),i(!0),c(``),e):null}catch(e){return l.current&&c(e instanceof Error?e.message:String(e)),null}finally{l.current&&!e&&o(!1)}},[]);return(0,_.useEffect)(()=>{if(!e){o(!1);return}l.current=!0;let t=null;return(async()=>{let e=await m();l.current&&(e?(await u(),l.current&&(i(!0),t=window.setInterval(()=>void u(!0),b))):(i(!1),o(!1)))})(),()=>{l.current=!1,t!==null&&window.clearInterval(t)}},[e,u]),{store:t,live:r,loading:a,error:s,setError:c,reload:u}}function E({children:e}){let t=T(!0);return(0,y.jsx)(w.Provider,{value:t,children:e})}function D(){let e=(0,_.useContext)(w),t=T(e===null);return e??t}var O={gray:`bg-stone-100 text-stone-600`,blue:`bg-[#e1eaff] text-[#1f4ec2]`,amber:`bg-[#fff1e3] text-[#a85b00]`,yellow:`bg-[#fff7d6] text-[#8a6100]`,red:`bg-[#fee4e3] text-[#c02a26]`,purple:`bg-[#efe7ff] text-[#5b32b4]`,green:`bg-[#d9f5d2] text-[#1d7a12]`,muted:`bg-stone-100 text-stone-400`},k={planning:`blue`,in_progress:`amber`,archived:`gray`},A={planning:`blue`,in_progress:`amber`,done:`green`},j={urgent:`red`,high:`amber`,medium:`yellow`,low:`gray`},M={pending:`gray`,todo:`blue`,in_progress:`blue`,testing:`purple`,done:`green`,cancelled:`muted`},N={critical:`red`,major:`amber`,minor:`yellow`,trivial:`gray`},P={pending:`gray`,todo:`blue`,fixed:`amber`,verifying:`purple`,passed:`green`,cancelled:`muted`},F={gray:`#a8a29e`,blue:`#3370ff`,amber:`#f59e0b`,yellow:`#eab308`,red:`#ef4444`,purple:`#8b5cf6`,green:`#22c55e`,muted:`#d6d3d1`};function I({tone:e}){return(0,y.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:F[e]}})}function ee({tone:e,children:t}){return(0,y.jsx)(`span`,{className:`inline-flex h-6 shrink-0 items-center rounded-md px-2 text-xs font-medium ${O[e]}`,children:t})}var L={plus:[`M12 5v14`,`M5 12h14`],more:[],chevronRight:[`m9 5 7 7-7 7`],chevronDown:[`m5 9 7 7 7-7`],arrowLeft:[`M19 12H5`,`m11 18-6-6 6-6`],pencil:[`M12 20h9`,`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`],trash:[`M3 6h18`,`M8 6V4h8v2`,`M19 6l-1 14H6L5 6`,`M10 11v6`,`M14 11v6`],copy:[`M9 9.5A1.5 1.5 0 0 1 10.5 8h7A1.5 1.5 0 0 1 19 9.5v7A1.5 1.5 0 0 1 17.5 18h-7A1.5 1.5 0 0 1 9 16.5Z`,`M5 15V5.5A1.5 1.5 0 0 1 6.5 4H15`],check:[`m4.5 12.5 5 5 10-11`],play:[`M8 5.5v13l11-6.5Z`],search:[`M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14Z`,`m20 20-3.6-3.6`],folder:[`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`],calendar:[`M4 7.5A2.5 2.5 0 0 1 6.5 5h11A2.5 2.5 0 0 1 20 7.5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2Z`,`M8 3v4`,`M16 3v4`,`M4 10h16`],file:[`M7 3.5h6.5L18 8v12.5H7Z`,`M13.5 3.5V8H18`,`M10 12.5h5`,`M10 16h5`],bug:[`M8.5 9.5h7V14a3.5 3.5 0 0 1-7 0Z`,`M9.5 6.2 12 8l2.5-1.8`,`M4.5 13H8.5`,`M15.5 13h4`,`M6 18.5l2-2`,`M18 18.5l-2-2`]};function R({name:e,size:t=16,className:n=``}){return e===`more`?(0,y.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`currentColor`,"aria-hidden":`true`,className:n,children:[(0,y.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.6`}),(0,y.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.6`}),(0,y.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.6`})]}):(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:n,children:L[e].map(e=>(0,y.jsx)(`path`,{d:e},e))})}function z({tabs:e,value:t,onChange:n,ariaLabel:r}){return(0,y.jsx)(`div`,{className:`tw-pm-tabs`,role:`tablist`,"aria-label":r,children:e.map(e=>(0,y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.value,onClick:()=>n(e.value),className:`tw-pm-tab`,children:[e.label,typeof e.count==`number`?(0,y.jsx)(`span`,{className:`tw-pm-tab-count`,children:e.count}):null]},e.value))})}function B({options:e,value:t,onChange:n,ariaLabel:r}){return(0,y.jsx)(`div`,{className:`tw-pm-pills`,role:`group`,"aria-label":r,children:e.map(e=>(0,y.jsx)(`button`,{type:`button`,"aria-pressed":t===e.value,onClick:()=>n(e.value),children:e.label},e.value))})}function V({icon:e,title:t,hint:n,action:r}){return(0,y.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-4 py-20 text-center`,children:[(0,y.jsx)(`span`,{className:`tw-pm-tile mb-4 flex h-16 w-16 items-center justify-center rounded-2xl`,children:(0,y.jsx)(R,{name:e,size:30})}),(0,y.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:t}),(0,y.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:n}),r?(0,y.jsx)(`div`,{className:`mt-4`,children:r}):null]})}function H(e){return`/pm/projects/detail/?id=${encodeURIComponent(e)}`}var U=`h-9 w-full rounded-md border border-transparent bg-transparent px-2 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`,W=`min-h-[72px] w-full resize-y rounded-md border border-stone-200 bg-white px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`;function G(e){return(0,y.jsx)(f,{flat:!0,menuMatchTrigger:!0,ariaLabel:e.ariaLabel,options:e.options,value:e.value,onChange:e.onChange,disabled:e.disabled,renderOptionPrefix:e.renderOptionPrefix})}function K({page:e,totalPages:t,busy:n=!1,onPage:r}){let i=`h-7 shrink-0 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-40`;return(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-center gap-2 pt-3`,children:[(0,y.jsx)(`button`,{type:`button`,className:i,disabled:n||e<=1,onClick:()=>r(e-1),children:`上一页`}),(0,y.jsxs)(`span`,{className:`px-2 text-xs tabular-nums text-stone-400`,children:[e,` / `,t]}),(0,y.jsx)(`button`,{type:`button`,className:i,disabled:n||e>=t,onClick:()=>r(e+1),children:`下一页`})]})}function q({label:e}){return(0,y.jsx)(`div`,{className:`flex min-h-[240px] items-center justify-center rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":e,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}function J({children:e}){return(0,y.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:e})}function Y({children:e}){return(0,y.jsx)(`div`,{className:`px-4 py-16 text-center text-sm text-stone-400`,children:e})}function X({open:e,title:t,busy:n,submitLabel:r,onClose:i,onSubmit:a,children:o}){return(0,y.jsx)(g,{open:e,onClose:i,title:t,footer:(0,y.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-stone-100 px-2 py-3`,children:[(0,y.jsx)(`button`,{type:`button`,onClick:i,className:`h-8 rounded-lg border border-stone-200 px-3 text-sm text-stone-600 hover:bg-stone-100`,children:`取消`}),(0,y.jsx)(`button`,{type:`button`,disabled:n,onClick:a,className:`h-8 rounded-lg bg-[#3370ff] px-3 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:r})]}),children:o})}function Z({label:e,required:t,children:n}){return(0,y.jsxs)(`div`,{className:`flex items-start gap-3 px-2 py-2`,children:[(0,y.jsx)(`div`,{className:`flex h-9 w-[88px] shrink-0 items-center text-sm text-stone-600`,children:(0,y.jsxs)(`span`,{className:`truncate`,children:[e,t?(0,y.jsx)(`span`,{className:`ml-0.5 text-red-500`,children:`*`}):null]})}),(0,y.jsx)(`div`,{className:`min-w-0 flex-1 [&>div]:mt-0`,children:n})]})}var Q=180;function $({file:e,onClose:t}){let n=!!e,[r,i]=(0,_.useState)(n),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(e);return(0,_.useEffect)(()=>{if(e){c(e),i(!0);let t=window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>o(!0))});return()=>window.cancelAnimationFrame(t)}o(!1);let t=window.setTimeout(()=>{i(!1),c(null)},Q);return()=>window.clearTimeout(t)},[e]),(0,_.useEffect)(()=>{if(!n)return;function e(e){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),t())}return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n,t]),!r||!s?null:(0,v.createPortal)((0,y.jsxs)(`div`,{"data-pm-image-preview":``,className:`fixed inset-0 z-[70] flex items-center justify-center p-6 sm:p-10`,role:`dialog`,"aria-modal":`true`,"aria-label":s.name,onClick:t,children:[(0,y.jsx)(`div`,{className:`absolute inset-0 bg-stone-900/70 transition-opacity duration-[180ms] ease-out ${a?`opacity-100`:`opacity-0`}`,"aria-hidden":`true`}),(0,y.jsx)(`img`,{src:s.url,alt:s.name,className:`relative max-h-full max-w-full rounded-lg bg-white object-contain shadow-2xl transition-[opacity,scale] duration-[180ms] ease-out ${a?`scale-100 opacity-100`:`scale-95 opacity-0`}`,onClick:e=>e.stopPropagation()}),(0,y.jsx)(`button`,{type:`button`,"aria-label":`关闭预览`,onClick:t,className:`absolute right-4 top-4 flex h-9 w-9 items-center justify-center rounded-full bg-white/90 text-lg text-stone-600 shadow-md transition-opacity duration-[180ms] ease-out hover:bg-white hover:text-stone-900 ${a?`opacity-100`:`opacity-0`}`,children:`✕`})]}),document.body)}function te({message:e,onClose:t}){return(0,y.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,y.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,y.jsx)(`button`,{type:`button`,onClick:t,"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:`✕`})]})}function ne(e){let t=(e??``).trim();if(!t)return`—`;let n=Date.parse(t);if(!Number.isFinite(n)){let e=t.slice(0,10);return/^\d{4}-\d{2}-\d{2}$/.test(e)?e.replace(/-/g,`/`):`—`}let r=new Date(n);return`${r.getFullYear()}/${String(r.getMonth()+1).padStart(2,`0`)}/${String(r.getDate()).padStart(2,`0`)} ${String(r.getHours()).padStart(2,`0`)}:${String(r.getMinutes()).padStart(2,`0`)}`}function re({text:e,onClick:t}){let n=(0,y.jsx)(d,{text:e,className:`block min-w-0 truncate text-sm text-stone-800 group-hover/pm-title:text-[#3370ff]`});return t?(0,y.jsx)(`button`,{type:`button`,onClick:t,className:`group/pm-title block min-w-0 max-w-full text-left`,children:n}):n}export{C as A,re as C,H as D,ne as E,x as O,ee as S,M as T,J as _,W as a,E as b,X as c,te as d,Z as f,q as g,$ as h,U as i,D as j,S as k,Y as l,R as m,P as n,k as o,B as p,A as r,I as s,N as t,V as u,K as v,j as w,z as x,G as y};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,p as r}from"./app-config.DwpFFa5D.js";import{a as i,i as a,n as o,o as s,s as c}from"./plugins.BmKRnp4a.js";import{t as l}from"./jsx-runtime.DUg_B_vD.js";import{t as ee}from"./ConfirmDialog.D5qXeML0.js";import{m as u}from"./PmShared.86HEsdd_.js";import{showToast as d}from"./Toast.BO2NFckG.js";import{i as te}from"./case-types.B51yDRdf.js";import{c as f,d as p,h as ne,n as m,p as re,r as ie,u as ae,v as oe}from"./project-docs.CCjtiFjB.js";import{a as se,at as ce,c as le}from"./req-analysis.qmyv5cBw.js";import{n as ue}from"./doc-roots.CO3IBiY6.js";import{a as h,c as g,d as de,i as _,l as v,o as y,s as b,u as x}from"./prompts-meta.bF2q5SUy.js";import{i as fe,n as pe,r as me,t as he}from"./DocsFileBrowser.D66pN9rp.js";import{d as ge,t as _e}from"./open-docs-in-session.DJtuI1C4.js";import{F as ve,I as ye,i as be,r as xe}from"./case-review.TdDs1WFM.js";import{t as S}from"./NamePromptDialog.Csfnh5eM.js";import{i as Se}from"./report-prompt.B9C4cv84.js";import{g as Ce,s as we}from"./ui-auto.BmC9JJ_X.js";import{f as Te,s as Ee,t as De,y as Oe}from"./story-review.2UUlN3p-.js";import{o as ke,t as Ae}from"./test-reports.DPQ-FMsQ.js";var C=e(t(),1),w=`tw.prompts.mounted.v1`;function je(){try{let e=sessionStorage.getItem(r(w));if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t))typeof e==`string`&&typeof r==`string`&&(n[e]=r);return n}catch{return{}}}function Me(e){try{sessionStorage.setItem(r(w),JSON.stringify(e))}catch{}}var T=l(),Ne=10;async function E(e=`.`){let{entries:t}=await f(`prompts`,e),n=[];for(let e of t)e.type===`file`?n.push(e):n.push(...await E(e.path));return n}function Pe({path:e,enabled:t,mounted:n}){let r=x(e,n);if(!r)return(0,T.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`未关联`});if(r===`system`)return(0,T.jsx)(`span`,{className:`text-[11px] text-stone-600`,children:`系统默认`});let i=o(r)?.name??r,a=t[r]===!0,s=y(e,n);return(0,T.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,T.jsx)(`span`,{className:`truncate text-[11px] text-stone-600`,children:i}),s&&a?(0,T.jsx)(`span`,{className:`shrink-0 rounded bg-(--tw-accent-soft) px-1 text-[10px] text-(--tw-accent)`,children:`引用中`}):null]})}function D(){let e=me(`prompts`),[t,r]=(0,C.useState)(!1),[l,f]=(0,C.useState)(!0),[y,w]=(0,C.useState)(e?!0:null),[D,Fe]=(0,C.useState)(()=>e??[]),[O,k]=(0,C.useState)(null),[A,j]=(0,C.useState)(!1),[M,N]=(0,C.useState)({}),[P,F]=(0,C.useState)(null),[I,L]=(0,C.useState)(()=>i()),[R,Ie]=(0,C.useState)(()=>je()),[z,B]=(0,C.useState)(null),[V,H]=(0,C.useState)(null),[U,W]=(0,C.useState)(``),G=pe(D,Ne,`prompts`),K=(0,C.useRef)(!1),q=(0,C.useRef)(!1),J=(0,C.useRef)(!1),Le=(0,C.useRef)(!1),Re=(0,C.useRef)(!1),Y=(0,C.useCallback)(async()=>{k(null);try{let e=await E(`.`);Fe(e),fe(`prompts`,e)}catch(e){k(e instanceof Error?e.message:String(e))}},[]);(0,C.useEffect)(()=>{if(!y||I.reqAnalysis!==!0||K.current)return;let e=new Set(D.map(e=>e.name));e.has(`需求分析提示词.md`)&&e.has(`原文结构提示词.md`)||(K.current=!0,ce(!0).then(()=>Y()).catch(()=>void 0))},[y,I.reqAnalysis,D,Y]),(0,C.useEffect)(()=>{y&&I.storyReview===!0&&!q.current&&(D.some(e=>e.name===`用户故事审查提示词.md`)||(q.current=!0,Ee(!0).then(()=>Y()).catch(()=>void 0)))},[y,I.storyReview,D,Y]),(0,C.useEffect)(()=>{y&&I.testPoints===!0&&!J.current&&(D.some(e=>e.name===`测试点生成提示词.md`)||(J.current=!0,Oe(!0).then(()=>Y()).catch(()=>void 0)))},[y,I.testPoints,D,Y]),(0,C.useEffect)(()=>{y&&I.caseReview===!0&&!Le.current&&(D.some(e=>e.name===`用例质量评审提示词.md`)||(Le.current=!0,ye(!0).then(()=>Y()).catch(()=>void 0)))},[y,I.caseReview,D,Y]),(0,C.useEffect)(()=>{y&&I.caseBlindspot===!0&&!Re.current&&(D.some(e=>e.name===`场景遗漏补全提示词.md`)||(Re.current=!0,ve(!0).then(()=>Y()).catch(()=>void 0)))},[y,I.caseBlindspot,D,Y]),(0,C.useEffect)(()=>{let e=s(e=>{f(!!e.prompts),L(e)});return n().then(()=>{f(a(`prompts`)),L(i()),r(!0)}),e},[]),(0,C.useEffect)(()=>{t&&l&&(async()=>{await ie(`prompts`)?(await ge().catch(()=>null),await Y(),w(!0)):w(!1)})()},[t,l,Y]);let X=(0,C.useCallback)(async()=>{let e=await we(),t=a(`reports`),n=a(`testReports`),r=t?await Se().catch(()=>null):null;Ie(i=>{let a={};if(e)for(let t of e)a[g(t)]=`uiAuto`;else for(let[e,t]of Object.entries(i))t===`uiAuto`&&(a[e]=t);if(t){if(r?.promptFile)a[g(r.promptFile)]=`reports`;else for(let[e,t]of Object.entries(i))t===`reports`&&(a[e]=t)}if(n){let e=ke();for(let t of Ae){let n=(e[t.id]??t.defaultPrompt).trim();n&&(a[g(n)]=`testReports`)}}if(I.reqAnalysis&&(a[g(se)]=`reqAnalysis`,a[g(le)]=`reqAnalysis`),I.storyReview&&(a[g(De)]=`storyReview`),I.testPoints&&(a[g(Te)]=`testPoints`),I.caseReview&&(a[g(be)]=`caseReview`),I.caseBlindspot&&(a[g(xe)]=`caseBlindspot`),I.caseGen)for(let e of te()){let t=(e.promptPath??``).trim();t&&(a[g(t)]=`caseGen`)}return Me(a),a})},[I.reqAnalysis,I.storyReview,I.testPoints,I.caseReview,I.caseBlindspot,I.caseGen]);(0,C.useEffect)(()=>{if(!t||!l)return;X();let e=()=>{document.visibilityState===`visible`&&X()};document.addEventListener(`visibilitychange`,e);let n=Ce(()=>void X());return()=>{document.removeEventListener(`visibilitychange`,e),n()}},[t,l,I.uiAuto,I.reports,I.testReports,I.reqAnalysis,I.storyReview,I.testPoints,I.caseReview,I.caseBlindspot,I.caseGen,X]);let Z=(0,C.useMemo)(()=>Object.keys(M).filter(e=>M[e]),[M]),Q=(0,C.useCallback)(e=>{let t=x(e,R);return!t||t===`system`||de(e)?``:I[t]===!0?t:``},[R,I]);async function ze(e){j(!0),k(null);try{await ae(`prompts`,e.path)}catch(e){k(e instanceof Error?e.message:String(e))}finally{j(!1)}}async function Be(e){j(!0),k(null);try{await _e(`prompts`,e)}catch(e){k(e instanceof Error?e.message:String(e)),j(!1)}}function Ve(e){if(b(e.path)){k(`默认提示词不可删除`);return}if(_(e.path,I)){k(v(e.path,I));return}let t=Q(e.path);if(t){let e=o(t)?.name??t;k(`这份提示词正被「${e}」的项目挂载,先在那里换一份再删除`)}else F({kind:`one`,entry:e})}function He(e){if(b(e.path)){k(`默认提示词不可改名`);return}if(_(e.path,I)){k(v(e.path,I));return}let t=Q(e.path);if(t){let e=o(t)?.name??t;k(`这份提示词正被「${e}」的项目挂载,先在那里换一份再改名`)}else B(e),W(``)}function Ue(e){H(e),W(``)}async function We(){let e=P;if(e){F(null),j(!0),k(null);try{if(e.kind===`one`)await m(`prompts`,e.entry.path);else{let t=0;for(let n of e.paths)b(n)||_(n,I)||Q(n)?t+=1:await m(`prompts`,n);t&&k(`有 ${t} 个提示词仍被插件或项目引用,已跳过;先解除引用再删。`),N({})}await Y(),d(e.kind===`one`?`已删除「${e.entry.name}」`:`已删除 ${e.paths.length} 个提示词`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);k(t),d(`删除失败:${t}`,`error`)}finally{j(!1)}}}function Ge(){a(`promptGen`)?window.location.href=`/workbench/?plugin=promptGen`:k(c(`promptGen`))}let $=(0,C.useCallback)((e,t,n=``)=>{let r=(e===`.`?t:`${e}/${t}`).toLowerCase(),i=D.find(e=>e.path.toLowerCase()===r&&e.path.toLowerCase()!==n.toLowerCase());return i?i.name:``},[D]);async function Ke(e){let t=z;if(!t)return;let n=e.trim();if(!n||n===t.name){B(null),W(``);return}let r=$(p(t.path),n,t.path);if(r)W(`已存在同名文件「${r}」,换个名字再试`);else{j(!0),W(``);try{await ne(`prompts`,t.path,n),B(null),await Y(),d(`已重命名为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);W(t),d(`重命名失败:${t}`,`error`)}finally{j(!1)}}}async function qe(e){let t=V;if(!t)return;let n=e.trim();if(!n)return;let r=$(p(t.path),n);if(r)W(`已存在同名文件「${r}」,换个名字再试`);else{j(!0),W(``);try{let{content:e}=await re(`prompts`,t.path);await oe(`prompts`,p(t.path)===`.`?n:`${p(t.path)}/${n}`,e),H(null),await Y(),d(`已复制为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);W(t),d(`复制失败:${t}`,`error`)}finally{j(!1)}}}let Je=P?.kind===`one`?`删除「${P.entry.name}」?将从 ${ue(`prompts`)} 中移除。`:P?.kind===`batch`?`确认删除已选中的 ${P.paths.length} 个提示词?此操作不可恢复。`:``;return t?l?y===null?(0,T.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,T.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):y?(0,T.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,children:[(0,T.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,T.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[G.query.trim()?(0,T.jsxs)(T.Fragment,{children:[`匹配 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-800`,children:G.filtered.length}),` 个`,(0,T.jsxs)(`span`,{className:`text-stone-400`,children:[` · 共 `,D.length]})]}):(0,T.jsxs)(T.Fragment,{children:[`共 `,(0,T.jsx)(`span`,{className:`font-medium text-stone-800`,children:D.length}),` 个提示词`]}),Z.length>0?(0,T.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,Z.length]}):null]}),(0,T.jsx)(`button`,{type:`button`,disabled:A||Z.length===0,onClick:()=>F({kind:`batch`,paths:Z}),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-red-600 border border-red-200 rounded-lg hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,T.jsx)(`button`,{type:`button`,disabled:A,onClick:Ge,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:`生成提示词`})]}),O?(0,T.jsx)(`div`,{className:`shrink-0 mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:O}):null,(0,T.jsx)(he,{resizeKey:`docs:prompts:cols:v1`,files:D,filtered:G.filtered,pageFiles:G.pageFiles,query:G.query,onQuery:G.setQuery,sortBy:G.sortBy,onSortBy:G.setSortBy,page:G.page,totalPages:G.totalPages,pageSize:G.pageSize,onPage:G.setPage,onPageSize:G.setPageSize,busy:A,emptyText:`暂无提示词,点击「生成提示词」前往我的工作台。`,searchPlaceholder:`搜索文件名或路径…`,selectable:e=>!h(e.path,I)&&!Q(e.path),selected:M,onToggleRow:e=>N(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>N(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void ze(e),extraColumn:{header:`关联插件`,render:e=>(0,T.jsx)(Pe,{path:e.path,enabled:I,mounted:R})},renderNameAction:e=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`button`,{type:`button`,disabled:A,"aria-label":`重命名 ${e.name}`,onClick:()=>He(e),className:`inline-flex h-6 w-6 items-center justify-center rounded text-stone-400 transition-colors hover:bg-[#e8f0fe] hover:text-[#4176e6] disabled:opacity-40`,children:(0,T.jsx)(u,{name:`pencil`,size:12})}),(0,T.jsx)(`button`,{type:`button`,disabled:A,"aria-label":`复制 ${e.name}`,onClick:()=>Ue(e),className:`inline-flex h-6 w-6 items-center justify-center rounded text-stone-400 transition-colors hover:bg-[#e8f0fe] hover:text-[#4176e6] disabled:opacity-40`,children:(0,T.jsx)(u,{name:`copy`,size:12})})]}),renderActions:e=>{let t=h(e.path,I)||!!Q(e.path);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`button`,{type:`button`,disabled:A,onClick:()=>void Be(e),className:`cursor-pointer whitespace-nowrap rounded bg-[#4176e6] px-2 py-1 text-xs text-white hover:bg-[#3565c7] disabled:opacity-40`,children:`在会话中打开`}),(0,T.jsx)(`button`,{type:`button`,disabled:A||t,"aria-label":`删除 ${e.name}`,onClick:()=>Ve(e),className:`tw-icon-danger inline-flex h-6 w-6 items-center justify-center rounded`,children:(0,T.jsx)(u,{name:`trash`,size:12})})]})}}),(0,T.jsx)(S,{open:z!=null,title:`重命名提示词`,label:`文件名称`,initialValue:z?.name??``,lockExtension:!0,confirmLabel:`保存`,error:U,onClose:()=>{B(null),W(``)},onConfirm:e=>void Ke(e)}),(0,T.jsx)(S,{open:V!=null,title:`复制提示词`,label:`新文件名称`,initialValue:V?V.name.replace(/(\.[^.]+)?$/,e=>`(副本)${e}`):``,lockExtension:!0,confirmLabel:`复制`,error:U,onClose:()=>{H(null),W(``)},onConfirm:e=>void qe(e)}),(0,T.jsx)(ee,{open:P!=null,title:P?.kind===`batch`?`批量删除`:`删除提示词`,message:Je,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>F(null),onConfirm:()=>void We()})]}):(0,T.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:`提示词管理需要本地文档服务,当前未就绪。`}):(0,T.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:c(`prompts`)}):(0,T.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,T.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,T.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{D as default};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,n as r,r as i,t as a}from"./listbox.DNxAJmEo.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./OverflowHint.pvo2Xc8R.js";var c=e(t(),1),l=o();function u({value:e,onChange:t,placeholder:n,ariaLabel:r,onEnterCreate:i}){let a=(0,c.useRef)(null);return(0,c.useEffect)(()=>{let e=a.current;if(!e)return;e.focus();let t=requestAnimationFrame(()=>e.focus());return()=>cancelAnimationFrame(t)},[]),(0,l.jsx)(`div`,{className:`shrink-0 border-b border-stone-100 bg-white px-1.5 py-1.5`,children:(0,l.jsxs)(`div`,{className:`relative`,children:[(0,l.jsxs)(`svg`,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-stone-400`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,l.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,l.jsx)(`path`,{d:`m16.5 16.5 4 4`})]}),(0,l.jsx)(`input`,{ref:a,value:e,onChange:e=>t(e.target.value),onKeyDown:t=>{if(t.key===`Enter`&&i){let n=e.trim();if(n){t.preventDefault(),t.stopPropagation(),i(n);return}}[`Escape`,`Enter`,`ArrowDown`,`ArrowUp`].includes(t.key)||t.stopPropagation()},placeholder:n,"aria-label":r,spellCheck:!1,className:`h-8 w-full rounded-md border border-stone-200 bg-stone-50 pl-7 pr-2 text-sm text-stone-700 outline-none transition-colors placeholder:text-stone-400 focus:border-[#4176e6]`})]})})}function d(){return(0,l.jsx)(`svg`,{className:`w-4 h-4 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":!0,children:(0,l.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 f({options:e,value:t,onChange:o,disabled:f=!1,className:p=``,compact:m=!1,ariaLabel:h,showCheck:g=!1,centerContent:_=!1,unstyled:v=!1,fitContent:y=!1,triggerClassName:b=``,hideChevron:x=!0,flat:S=!1,menuMinWidth:C,menuMatchTrigger:w=!0,renderTrigger:T,renderOptionPrefix:E,renderOptionAction:D,searchable:O=!1,searchPlaceholder:k=`搜索…`,onSearchCreate:A,triggerTitle:j,hideTriggerHint:M=!1,dimWhenOpen:N=!1}){let P=e.find(e=>e.value===t),[F,I]=(0,c.useState)(``),L=(0,c.useMemo)(()=>{let t=F.trim().toLowerCase();return t?e.filter(e=>e.label.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)):e},[e,F]),R=(0,c.useMemo)(()=>{if(!A)return``;let t=F.trim();return!t||e.some(e=>e.label===t)?``:t},[A,e,F]),z=_?`justify-center`:`justify-start`,B=v?y?`inline-flex !w-auto max-w-full min-w-0 items-center overflow-hidden cursor-pointer outline-none disabled:cursor-not-allowed`:`flex w-full min-w-0 items-center overflow-hidden cursor-pointer outline-none disabled:cursor-not-allowed`:m?`tw-field-trigger w-full min-w-0 h-8 flex items-center gap-1.5 overflow-hidden 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`:S?`tw-field-trigger w-full min-w-0 h-9 flex items-center gap-2 overflow-hidden 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`:`tw-field-trigger w-full min-w-0 h-9 flex items-center gap-2 overflow-hidden 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,l.jsx)(i,{value:t,onChange:e=>{I(``),o(e)},disabled:f,children:({open:i})=>(0,l.jsxs)(`div`,{className:`relative ${v?y?`inline-block max-w-full min-w-0 align-middle`:`block w-full min-w-0`:m?`inline-block`:S?``:`mt-1`} ${p}`,children:[(0,l.jsx)(n,{"aria-label":h,onClick:()=>{O&&I(``)},className:`${B} ${z} ${b} ${N&&i?`text-stone-400`:``}`,children:T?T(P,{open:i}):(0,l.jsx)(s,{text:j??P?.label??t,className:`block min-w-0 flex-1 basis-0 truncate`,disabled:M})}),(0,l.jsxs)(a,{transition:!0,anchor:{to:`bottom start`,gap:4,padding:12},style:w?{width:`max(12rem, var(--button-width, 12rem))`,minWidth:`max(12rem, var(--button-width, 12rem))`}:{width:`min(280px, max(12rem, var(--button-width, 12rem)))`,maxWidth:280,minWidth:C||150},className:`tw-select-menu tw-menu-anim z-[200] flex max-h-64 min-w-0 flex-col overflow-hidden rounded-lg shadow-lg ring-1 ring-stone-200 [--anchor-max-height:16rem] focus:outline-none ${w?`w-[max(12rem,var(--button-width,12rem))]`:`w-[min(280px,max(12rem,var(--button-width,12rem)))] max-w-[280px]`}`,children:[O?(0,l.jsx)(u,{value:F,onChange:I,placeholder:k,ariaLabel:h?`${h}搜索`:`搜索选项`,onEnterCreate:A?async t=>{let n=e.find(e=>e.label===t);return n?(I(``),o(n.value),!0):(await A(t),I(``),!0)}:void 0}):null,(0,l.jsxs)(`div`,{className:`min-h-0 w-full min-w-0 flex-1 space-y-1 overflow-x-hidden overflow-y-auto p-1 pb-2`,children:[R?(0,l.jsx)(`div`,{className:`min-w-0 px-3 py-1.5 text-xs text-stone-400`,children:(0,l.jsx)(s,{text:`回车新增「${R}」`,className:`block w-full truncate`})}):null,O&&L.length===0&&!R?(0,l.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`无匹配项`}):null,L.map(e=>(0,l.jsxs)(r,{value:e.value,disabled:e.disabled,className:`group flex w-full min-w-0 max-w-full select-none items-center gap-2 overflow-hidden rounded-md px-3 py-2 text-sm leading-5 data-[focus]:bg-stone-50 data-[selected]:bg-(--tw-accent-soft) ${e.disabled?`cursor-not-allowed text-stone-300 data-[focus]:bg-transparent data-[selected]:bg-transparent data-[selected]:font-normal`:`cursor-pointer`} ${g?`text-stone-700 data-[selected]:text-stone-900`:`data-[selected]:text-(--tw-accent) data-[selected]:font-medium`} ${e.muted?`text-stone-400 data-[selected]:text-stone-500`:``} ${_&&!g&&!E?`justify-center px-2`:``}`,children:[g?(0,l.jsx)(`span`,{className:`w-4 shrink-0 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100`,children:(0,l.jsx)(d,{})}):E?(0,l.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:E(e)}):null,(0,l.jsxs)(`span`,{className:`min-w-0 flex-1 basis-0 overflow-hidden`,children:[(0,l.jsx)(s,{text:e.label,className:`block w-full truncate`}),e.secondary?(0,l.jsx)(s,{text:e.secondary,className:`mt-0.5 block w-full truncate font-mono text-[10px] font-normal leading-4 text-stone-400`}):null]}),D?(0,l.jsx)(`span`,{className:`ml-0.5 flex shrink-0 items-center`,onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),e.preventDefault()},children:D(e)}):null]},e.value))]})]})]})})}export{f as t};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./react-dom.DLW9pGCF.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";var i=e(t(),1),a=e(n(),1),o=r(),s=280;function c({open:e,onClose:t,title:n,closeAriaLabel:r=`关闭面板`,widthClass:c=`max-w-md`,escDisabled:l=!1,bodyClassName:u,children:d,footer:f}){let[p,m]=(0,i.useState)(e),[h,g]=(0,i.useState)(!1);if((0,i.useEffect)(()=>{if(e){m(!0);let e=window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>g(!0))});return()=>window.cancelAnimationFrame(e)}g(!1);let t=window.setTimeout(()=>m(!1),s);return()=>window.clearTimeout(t)},[e]),(0,i.useEffect)(()=>{if(!e||l)return;function n(e){e.key===`Escape`&&(document.querySelector(`[aria-haspopup="listbox"][aria-expanded="true"]`)||document.querySelector(`[data-pm-image-preview]`)||(e.preventDefault(),e.stopPropagation(),t()))}return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e,t,l]),!p)return null;let _=(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-[280ms] ease-out ${h?`opacity-100`:`opacity-0`}`,"aria-label":r,onClick:t}),(0,o.jsxs)(`aside`,{className:`tw-slide-over relative w-full ${c} h-full shadow-2xl border-l border-stone-200 flex flex-col transition-[translate] duration-[280ms] ease-[cubic-bezier(0.32,0.72,0,1)] will-change-[translate] ${h?`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 ${u??`space-y-4`}`.trim(),children:d}),f]})]});return typeof document>`u`?_:(0,a.createPortal)(_,document.body)}export{c as t};
@@ -1,9 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.DwpFFa5D.js";import{a as r,r as i,s as a,t as o}from"./view-prefs.GnvelRDj.js";import{i as s,n as c,r as l,t as u}from"./dialog.DZHZCe_T.js";import{i as ee,n as d,r as te,t as f}from"./menu.Dnrpz489.js";import{t as ne}from"./jsx-runtime.DUg_B_vD.js";import{t as re}from"./ConfirmDialog.D5qXeML0.js";import{t as p}from"./OverflowHint.pvo2Xc8R.js";import{t as ie}from"./SelectDropdown.Dmk5n225.js";import{A as m,S as ae,d as oe,g as se,l as h,m as g}from"./PmShared.86HEsdd_.js";import{showToast as ce}from"./Toast.BO2NFckG.js";import{c as le}from"./project-docs.CCjtiFjB.js";import{m as ue,p as de,u as fe}from"./settings.CYERib3l.js";import{s as pe}from"./llm.DN5S1KBK.js";import{u as me}from"./prompts-meta.bF2q5SUy.js";import{t as he}from"./markdown-client.BS19nLL3.js";import{a as _,n as ge,r as v,t as _e}from"./ui-auto-prompt.COBTt5Gd.js";import{S as ve,_ as ye,a as be,b as xe,c as Se,d as Ce,f as we,h as Te,i as Ee,l as De,m as Oe,n as y,o as b,p as ke,r as Ae,t as x,u as je,v as S,x as Me,y as Ne}from"./ui-auto.BmC9JJ_X.js";import{t as Pe}from"./PromptMountDialog.DYojFMok.js";import{t as Fe}from"./hydrate-cache.CoD1FB3T.js";var C=e(t(),1),Ie=`${y}/agent`;async function w(e,t){let n=await fetch(`${Ie}${e}`,{...t,headers:{"Content-Type":`application/json`,...t?.headers??{}}}),r=await n.text(),i=null;try{i=r?JSON.parse(r):null}catch{i=null}if(!n.ok){let e=(i&&typeof i==`object`&&`error`in i?String(i.error):``)||r.slice(0,300)||`请求失败(${n.status})`;throw Error(e)}return i??{}}async function Le(e){return w(`/prepare`,{method:`POST`,body:JSON.stringify(e)})}async function Re(e,t){return w(`/open`,{method:`POST`,body:JSON.stringify({sessionId:e,url:t})})}async function T(e,t={}){return w(`/snapshot`,{method:`POST`,body:JSON.stringify({sessionId:e,...t})})}async function E(e,t){return w(`/action`,{method:`POST`,body:JSON.stringify({sessionId:e,...t})})}async function D(e,t={}){return w(`/wait`,{method:`POST`,body:JSON.stringify({sessionId:e,...t})})}async function ze(e){return w(`/console`,{method:`POST`,body:JSON.stringify({sessionId:e})})}async function Be(e){return w(`/network`,{method:`POST`,body:JSON.stringify({sessionId:e})})}async function Ve(e,t,n){return w(`/probe`,{method:`POST`,body:JSON.stringify({sessionId:e,ref:t,stepId:n})})}async function He(e,t){return w(`/screenshot`,{method:`POST`,body:JSON.stringify({sessionId:e,label:t})})}async function Ue(e){await w(`/close`,{method:`POST`,body:JSON.stringify({sessionId:e})})}async function O(e){return w(`/save`,{method:`POST`,body:JSON.stringify(e)})}async function We(e,t,n={}){return w(`/emit`,{method:`POST`,body:JSON.stringify({ir:e,target:t,...n})})}async function k(e,t,n){return w(`/verify`,{method:`POST`,body:JSON.stringify({sessionId:e,ir:t,target:n,timeoutMs:18e4})})}async function Ge(e){return w(`/write`,{method:`POST`,body:JSON.stringify(e)})}async function Ke(e){return w(`/sessions?projectId=${encodeURIComponent(e)}`)}async function A(e){return w(`/session?id=${encodeURIComponent(e)}`)}async function qe(e,t){return w(`/debug`,{method:`POST`,body:JSON.stringify({sessionId:e,mode:t})})}async function Je(e){return w(`/debug/stop`,{method:`POST`,body:JSON.stringify({sessionId:e})})}async function Ye(e){return w(`/changes?sessionId=${encodeURIComponent(e)}`)}async function Xe(e){return w(`/reveal`,{method:`POST`,body:JSON.stringify(e)})}var j=null;async function Ze(e=!1){return(!j||e)&&(j=w(`/apps`).then(e=>({apps:e.apps??[],defaultId:e.defaultId??``})).catch(e=>{throw j=null,e})),j}async function Qe(e,t){return w(`/run-file`,{method:`POST`,body:JSON.stringify({sessionId:e,path:t,timeoutMs:18e4})})}async function $e(e){return w(`/draft/clean`,{method:`POST`,body:JSON.stringify({sessionId:e})})}var M={type:`string`,description:`快照里的 ref,例如 d1-e12。页面导航后会失效。`},et={type:`function`,function:{name:`ui_plan_steps`,description:`提交整份步骤计划(人可读的动作 + 目标描述,不含定位器)。这一步只做测试设计,不会打开浏览器。`,parameters:{type:`object`,properties:{title:{type:`string`,description:`用例标题,中文即可`},steps:{type:`array`,description:`按执行顺序排列的计划步骤`,items:{type:`object`,properties:{action:{type:`string`,enum:[`goto`,`click`,`fill`,`select`,`press`,`hover`,`expect`,`expectUrl`,`wait`],description:`测试动作;不要写「截图」——截图是探索时给人看的,不是测试步骤`},target:{type:`string`,description:`给人看的目标描述,例如「右上角的登录按钮」「用户名输入框」`},value:{type:`string`,description:"输入内容 / 选项;账号密码等占位数据写成 ${ENV_NAME}"},url:{type:`string`,description:`goto / expectUrl 的地址,相对路径即可`},note:{type:`string`,description:`补充说明,例如断言什么结果`}},required:[`action`,`target`]}}},required:[`steps`]}}},tt=[et],nt=[et,{type:`function`,function:{name:`ui_browser_open`,description:`在浏览器里打开一个地址(相对地址会用 baseURL 拼接),返回页面快照。`,parameters:{type:`object`,properties:{url:{type:`string`,description:`绝对地址或 / 开头的相对地址`}},required:[`url`]}}},{type:`function`,function:{name:`ui_browser_snapshot`,description:`重新获取当前页面快照。页面变化较大、或 ref 不确定时用。`,parameters:{type:`object`,properties:{depth:{type:`number`,description:`快照深度,默认 6,越大越啰嗦`},targetRef:{type:`string`,description:`只看某个元素的子树`}}}}},{type:`function`,function:{name:`ui_browser_click`,description:`点击一个元素。成功后会自动返回新快照。`,parameters:{type:`object`,properties:{ref:M,note:{type:`string`,description:`这一步在做什么`}},required:[`ref`]}}},{type:`function`,function:{name:`ui_browser_fill`,description:`填写输入框(会先清空已有内容)。`,parameters:{type:`object`,properties:{ref:M,text:{type:`string`,description:"要填入的内容;占位数据用 ${ENV_NAME} 表示环境变量"},note:{type:`string`}},required:[`ref`,`text`]}}},{type:`function`,function:{name:`ui_browser_select`,description:`选择下拉框选项(按 value 或可见文本)。`,parameters:{type:`object`,properties:{ref:M,value:{type:`string`},note:{type:`string`}},required:[`ref`,`value`]}}},{type:`function`,function:{name:`ui_browser_press`,description:`按一个键,例如 Enter / Tab / Escape。`,parameters:{type:`object`,properties:{key:{type:`string`},ref:{type:`string`}},required:[`key`]}}},{type:`function`,function:{name:`ui_browser_hover`,description:`悬停到元素上(用于展开菜单)。`,parameters:{type:`object`,properties:{ref:M,note:{type:`string`}},required:[`ref`]}}},{type:`function`,function:{name:`ui_browser_back`,description:`浏览器后退一步。`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`ui_browser_wait`,description:`等待:给 text 时等到页面出现该文案(比死等毫秒可靠),否则等待指定毫秒。返回等待后的快照。`,parameters:{type:`object`,properties:{text:{type:`string`,description:`要等待出现的可见文案`},ms:{type:`number`,description:`没有 text 时等待的毫秒数`},timeout:{type:`number`,description:`等待 text 的超时毫秒数,默认 15000`}}}}},{type:`function`,function:{name:`ui_browser_screenshot`,description:`截一张当前页面图,给用户看(模型看不到图片内容)。`,parameters:{type:`object`,properties:{label:{type:`string`,description:`截图标签,例如 after-login`}}}}},{type:`function`,function:{name:`ui_browser_console`,description:`读取浏览器控制台里的 error / warning / pageerror(排查偶发失败用)。`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`ui_browser_network`,description:`读取最近的失败请求(状态码 ≥ 400 或请求失败),用来判断是不是接口挂了。`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`ui_locator_probe`,description:`把一个 ref 转成可写进脚本的定位器,并校验唯一性。写步骤之前,对每个要操作的元素都调用一次。`,parameters:{type:`object`,properties:{ref:M,stepId:{type:`string`,description:`可选:左侧计划里的步骤 id(如 p2)。传了会把定位器回填到该步骤。`}},required:[`ref`]}}},{type:`function`,function:{name:`ui_test_set_steps`,description:`提交 / 替换整份测试步骤(IR)。每次提交都会刷新右侧代码预览。先探索、再提交,不要凭想象写定位器。`,parameters:{type:`object`,properties:{title:{type:`string`,description:`用例标题,中文即可`},steps:{type:`array`,description:`按执行顺序排列的步骤`,items:{type:`object`,properties:{action:{type:`string`,enum:[`goto`,`click`,`fill`,`select`,`press`,`hover`,`expect`,`expectUrl`,`wait`,`screenshot`]},locator:{type:`object`,description:`定位器。首选 ui_locator_probe 给出的 recommended,不要自己拼长 CSS`,properties:{kind:{type:`string`,enum:[`testid`,`role`,`label`,`placeholder`,`text`,`attr`,`css`]},role:{type:`string`},name:{type:`string`},value:{type:`string`},attr:{type:`string`},exact:{type:`boolean`},nth:{type:`number`,description:`同名元素有多个时取第几个(0 = 第一个)。用 ui_locator_probe 返回的 nth,不要自己猜`}},required:[`kind`]},url:{type:`string`},value:{type:`string`,description:`输入内容 / 选项值 / 截图名`},key:{type:`string`},text:{type:`string`,description:`expect 时要断言的文本`},state:{type:`string`,enum:[`visible`,`hidden`]},ms:{type:`number`},note:{type:`string`},planStepId:{type:`string`,description:`可选:对应左侧计划步骤 id,便于逐条勾掉计划`}},required:[`action`]}}},required:[`steps`]}}},{type:`function`,function:{name:`ui_test_get_steps`,description:`读取当前已提交的步骤,改之前先看一眼。`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`ui_test_verify`,description:`在临时目录试跑当前步骤对应的脚本,返回是否通过和日志尾部。`,parameters:{type:`object`,properties:{}}}}],rt=`浏览器已被关闭,这一轮探索已结束`;function it(e){if(!e||!e.includes(`error`))return!1;let t;try{t=JSON.parse(e)}catch{return!1}if(!t||typeof t!=`object`)return!1;let n=String(t.error??``);return n.includes(`浏览器已被关闭`)||n.includes(`浏览器进程已退出`)||n.includes(`Target page, context or browser has been closed`)}var N=(e,t)=>e.length>t?`${e.slice(0,t)}…(已截断)`:e;async function at(e,t,n){let r={};try{r=JSON.parse(t||`{}`)}catch{return JSON.stringify({error:`工具参数不是合法 JSON`})}let i=n.sessionId,a=e=>typeof r[e]==`string`?String(r[e]):``;try{if(e===`ui_plan_steps`){let e=Array.isArray(r.steps)?r.steps:[];if(!e.length){let e=await A(i).then(e=>e.session.plan??[]).catch(()=>[]);return JSON.stringify({ok:!0,stepCount:e.length,plan:e.map(e=>({id:e.id,action:e.action,target:e.target})),note:`没有提交新步骤,计划保持不变。`})}let t=(await O({sessionId:i,title:a(`title`)||void 0,plan:e,mergePlan:!0})).session.plan??[];return n.onPlan?.(t),JSON.stringify({ok:!0,stepCount:t.length,plan:t.map(e=>({id:e.id,action:e.action,target:e.target})),note:`计划已保存,用户可以在左侧调整。接下来开始探索:逐个 probe 并回填定位器。`})}if(e===`ui_browser_open`){let e=await Re(i,a(`url`));return JSON.stringify({url:e.url,title:e.title,elements:e.count,truncated:e.truncated,snapshot:N(e.snapshot,12e3)})}if(e===`ui_browser_snapshot`){let e=await T(i,{depth:Number(r.depth)||void 0,targetRef:a(`targetRef`)||void 0});return JSON.stringify({url:e.url,title:e.title,elements:e.count,truncated:e.truncated,snapshot:N(e.snapshot,12e3)})}if(e===`ui_browser_click`||e===`ui_browser_fill`||e===`ui_browser_select`||e===`ui_browser_hover`){let t=await E(i,{action:e.replace(`ui_browser_`,``),ref:a(`ref`),text:a(`text`),value:a(`value`),note:a(`note`)});return JSON.stringify({ok:!0,action:t.action,url:t.url,snapshot:N(t.snapshot,9e3)})}if(e===`ui_browser_press`){let e=await E(i,{action:`press`,ref:a(`ref`),key:a(`key`)});return JSON.stringify({ok:!0,url:e.url,snapshot:N(e.snapshot,9e3)})}if(e===`ui_browser_back`){let e=await E(i,{action:`back`});return JSON.stringify({ok:!0,url:e.url,snapshot:N(e.snapshot,9e3)})}if(e===`ui_browser_wait`){let e=await D(i,{text:a(`text`)||void 0,ms:Number(r.ms)||void 0,timeout:Number(r.timeout)||void 0});return JSON.stringify({ok:!0,action:e.action,url:e.url,snapshot:N(e.snapshot,9e3)})}if(e===`ui_browser_screenshot`){let e=await He(i,a(`label`)||`snapshot`);return n.onShot?.(e.url),JSON.stringify({ok:!0,url:e.url,note:`截图已显示在面板里;你看不到图片内容,需要判断结构请用快照。`})}if(e===`ui_browser_console`){let e=(await ze(i)).messages??[];return JSON.stringify(e.length?{count:e.length,messages:e.slice(-20)}:{count:0})}if(e===`ui_browser_network`){let e=(await Be(i)).requests??[];return JSON.stringify(e.length?{count:e.length,requests:e.slice(-20)}:{count:0})}if(e===`ui_locator_probe`){let e=a(`ref`);if(!e)return JSON.stringify({error:`缺少 ref`});let t=a(`stepId`),r=await Ve(i,e,t||void 0);return t&&r.plan&&n.onPlan?.(r.plan),JSON.stringify({ref:r.ref,element:r.element,confidence:r.confidence,recommended:r.recommended,fragile:!!r.fragile,warning:r.warning??``,candidates:r.candidates.slice(0,3),boundStep:r.planStep?{id:r.planStep.id,status:r.planStep.status}:void 0,note:r.confidence===`high`?`定位器唯一且指向同一元素,可以写进步骤`:r.recommended?`能用但不稳:${r.warning||`同名元素较多`}。照抄 recommended(含 nth),并补一条结果断言`:`没有唯一候选:换一个更具体的元素,或改成对结果文案的 expect`})}if(e===`ui_test_set_steps`){let e=Array.isArray(r.steps)?r.steps:[],t={title:a(`title`)||`未命名流程`,target:n.target,steps:e},o=await O({sessionId:i,title:t.title,ir:t}),s=o.session.ir??t,c=t.steps.length-s.steps.length;return n.onIr?.(s),n.onCode?.(o.code,o.suggestedPath),JSON.stringify({ok:!0,title:s.title,stepCount:s.steps.length,previewPath:o.suggestedPath,note:c?`步骤已保存,但有 ${c} 步被丢掉(动作不支持或没带 locator)。用 ui_test_get_steps 核对后重新提交;不要自己试跑,试跑由用户确认代码后手动发起。`:`步骤已保存,右侧代码预览已刷新。不要自己试跑:试跑由用户确认代码后手动发起。`})}if(e===`ui_test_get_steps`){let e=await A(i);return JSON.stringify({title:e.session.ir?.title??``,steps:e.session.ir?.steps??[],suggestedPath:e.suggestedPath})}if(e===`ui_test_verify`){let e=await k(i),t=String(e.log??``);return typeof e.code==`string`&&n.onCode?.(e.code,e.suggestedPath??``),JSON.stringify({passed:!!e.passed,exitCode:e.exitCode??null,timedOut:!!e.timedOut,durationMs:e.durationMs??0,draftPath:e.draftPath??``,tracePath:e.tracePath??``,log:N(t.slice(-4e3),4e3),note:e.passed?`试跑通过。草稿留在 .lantern-ai 里,用户可以直接看 trace / 用 Playwright UI 调试,确认后再写入项目。`:`试跑失败:只改步骤 IR(定位器 / 等待 / 断言)。草稿和 trace 会保留,用户能打开看现场;如果是功能本身不符合预期,不要为了跑绿改断言。`})}return JSON.stringify({error:`未知工具:${e}`})}catch(e){return JSON.stringify({error:e instanceof Error?e.message:String(e)})}}function ot(e){return e?.length?e.map((e,t)=>{let n=[`${t+1}. [${e.id}] ${e.action}`];return e.target&&n.push(`目标:${e.target}`),e.url&&n.push(`url=${e.url}`),e.value&&n.push(`值=${e.value}`),e.locator&&n.push(`已绑定 ${st(e.locator)}`),n.join(` · `)}).join(`
2
- `):``}function st(e){if(!e)return``;let t=Number.isInteger(e.nth)?` nth=${e.nth}`:``;return e.kind===`role`?`role=${e.role??``}${e.name?` name="${e.name}"`:``}${t}`:e.kind===`attr`?`[${e.attr}="${e.value??``}"]${t}`:e.kind===`testid`?`testid=${e.value??``}${t}`:`${e.kind}="${e.value??e.name??``}"${t}`}function ct(e){return e===`python`?`Python + pytest + playwright.sync_api`:`TypeScript + @playwright/test`}function lt(e,t){return e.replaceAll(`{{project}}`,t.project).replaceAll(`{{dir}}`,t.dir).replaceAll(`{{language}}`,t.language).replaceAll(`{{plan}}`,t.plan)}function ut(e,t,n,r,i){let a=ot(n);if(r?.trim()){let n=lt(r.trim(),{project:e.name,dir:e.dir,language:ct(t),plan:a||`如果还没有计划:先调用 ui_plan_steps 列出计划,再开始探索。`}),o=String(i??``).trim();return o?`${n}\n\n${o}`:n}return[`你是 UI 自动化测试工程师:用浏览器把流程点一遍,确认元素能唯一定位,再提交步骤。`,`项目:${e.name}(${e.dir}),目标语言:${ct(t)}。`,`ref 导航后失效要重新 snapshot;每个元素先用 ui_locator_probe 拿唯一定位器,再用 ui_test_set_steps 提交。`,"探索阶段不要自己试跑;至少一条 expect 断言用户可见的结果;账号等占位值写成 ${ENV_NAME}。",a?`\n${a}`:``,`最后用中文简短汇报。`].filter(Boolean).join(`
3
- `)}function dt(e,t,n){return n?.trim()?lt(n.trim(),{project:e.name,dir:e.dir,language:ct(t),plan:``}):[`你是测试设计师:只把需求拆成「动作 + 目标描述」的步骤计划,不打开浏览器、不写定位器。`,`项目:${e.name}(${e.dir}),目标语言:${ct(t)}。`,`只调用一次 ui_plan_steps;4~12 步,覆盖打开页面、前置、核心操作与至少一条结果断言。`,"账号密码等写成 ${ENV_NAME}。"].join(`
4
- `)}function ft(e,t,n){return[`需求 / 流程:`,e.trim(),``,t?`起始地址(baseURL):${t}`:`起始地址:从需求里判断,用相对路径。`,`目标语言:${n===`python`?`Python (pytest)`:`TypeScript`}`,``,`请给出步骤计划。`].join(`
5
- `)}function pt(e,t,n,r){return[`要自动化的流程 / 需求:`,e.trim(),``,t?`起始地址(baseURL):${t}`:`起始地址:从需求里判断,用相对路径。`,`目标语言:${n===`python`?`Python (pytest)`:`TypeScript`}`,r?.length?`
6
- 已确认的步骤计划(按顺序执行,probe 时带上 stepId):
7
- `+ot(r):``,``,`请开始:打开页面、探索并确认元素、提交步骤。`].filter(Boolean).join(`
8
- `)}var P=ne(),mt=`ui-auto.openapp`,ht={finder:`#3b82f6`,terminal:`#334155`,editor:`#64748b`};function gt({app:e,size:t=16}){let[n,r]=(0,C.useState)(!1);return!e.iconUrl||n?e.kind===`finder`?(0,P.jsx)(`svg`,{className:`shrink-0 text-[#3b82f6]`,width:t,height:t,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`,children:(0,P.jsx)(`path`,{d:`M2 5.5A1.5 1.5 0 013.5 4h4l1.5 2h7.5A1.5 1.5 0 0118 7.5v7A1.5 1.5 0 0116.5 16h-13A1.5 1.5 0 012 14.5v-9z`})}):e.kind===`terminal`?(0,P.jsxs)(`svg`,{className:`shrink-0 text-stone-700`,width:t,height:t,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,"aria-hidden":`true`,children:[(0,P.jsx)(`rect`,{x:`2.5`,y:`3.5`,width:`15`,height:`13`,rx:`2`}),(0,P.jsx)(`path`,{d:`M6 8l2.5 2L6 12M10.5 12.5h3.5`,strokeLinecap:`round`,strokeLinejoin:`round`})]}):(0,P.jsx)(`span`,{className:`flex shrink-0 items-center justify-center rounded-[4px] text-[9px] font-semibold text-white`,style:{width:t,height:t,backgroundColor:ht[e.kind]??`#94a3b8`},"aria-hidden":`true`,children:e.label.slice(0,1).toUpperCase()}):(0,P.jsx)(`img`,{src:e.iconUrl,alt:``,width:t,height:t,className:`shrink-0 rounded-[4px] object-contain`,onError:()=>r(!0)})}function _t({onOpen:e,disabled:t=!1,compact:n=!1}){let[r,o]=(0,C.useState)([]),[s,c]=(0,C.useState)(``),[l,u]=(0,C.useState)(()=>i(mt)),[ne,re]=(0,C.useState)(!1);(0,C.useEffect)(()=>{let e=!0;return Ze().then(t=>{e&&(o(t.apps),c(t.defaultId))}).catch(()=>void 0).finally(()=>{e&&re(!0)}),()=>{e=!1}},[]);let p=r.find(e=>e.id===l)??r.find(e=>e.id===s),ie=r.length>0,m=t||!ie,ae=t=>{t&&(u(t.id),a(mt,t.id),e(t))};return(0,P.jsxs)(`div`,{className:`inline-flex shrink-0 overflow-hidden rounded-lg border border-stone-200 bg-white ${n?`h-7`:`h-8`} ${m?`opacity-50`:``}`,children:[(0,P.jsx)(`button`,{type:`button`,className:`flex items-center px-1.5 transition-colors enabled:hover:bg-stone-50 disabled:cursor-not-allowed`,onClick:()=>{ie&&e(p??null)},disabled:m,"aria-label":p?`用 ${p.label} 打开`:`打开方式`,children:p?(0,P.jsx)(gt,{app:p,size:n?14:16}):(0,P.jsx)(`span`,{className:`px-1 text-[11px] text-stone-400`,children:ne?`无可用应用`:`加载中`})}),(0,P.jsx)(`span`,{className:`my-1 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,P.jsxs)(te,{as:`div`,className:`relative flex`,children:[(0,P.jsx)(f,{type:`button`,className:`flex w-7 items-center justify-center text-stone-400 transition-colors enabled:hover:bg-stone-50 enabled:hover:text-stone-600 disabled:cursor-not-allowed`,disabled:m,"aria-label":`选择打开方式`,children:(0,P.jsx)(`svg`,{className:`h-3.5 w-3.5`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`,children:(0,P.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,P.jsxs)(ee,{anchor:{to:`bottom end`,gap:4,padding:12},transition:!0,className:`tw-select-menu tw-menu-anim z-80 w-max min-w-[180px] space-y-0.5 rounded-lg p-1 pb-2 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:[r.map(e=>{let t=e.id===(l||s);return(0,P.jsx)(d,{children:(0,P.jsxs)(`button`,{type:`button`,className:`flex w-full select-none items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm ${t?`bg-(--tw-accent-soft) font-medium text-(--tw-accent)`:`text-stone-700 data-[focus]:bg-stone-50`}`,onClick:()=>ae(e),children:[(0,P.jsx)(gt,{app:e,size:18}),(0,P.jsx)(`span`,{className:`truncate`,children:e.label}),e.id===s?(0,P.jsx)(`span`,{className:`ml-auto shrink-0 pl-3 text-[11px] text-stone-400`,children:`默认`}):null]})},e.id)}),r.length?null:(0,P.jsx)(`div`,{className:`px-2.5 py-2 text-xs text-stone-400`,children:`没有探测到可用应用`})]})]})]})}var vt=`bg-[var(--tw-surface-panel)] border-[var(--tw-border)]`,F=`divide-[var(--tw-border)]`,I=`border-[var(--tw-border)]`,yt=`text-[var(--tw-label-primary)]`,L=`text-[var(--tw-label-secondary)]`,R=`text-[var(--tw-label-tertiary)]`,z=`hover:bg-[var(--tw-session-hover-bg)]`,B=`h-8 min-w-0 rounded-lg border ${I} bg-[var(--tw-surface-recessed)] px-2.5 text-xs ${yt} outline-none transition-colors placeholder:text-[var(--tw-label-tertiary)] focus:border-[#3370ff]`,V=`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`,H=`shrink-0 rounded px-1.5 py-0.5 text-[11px] ${R} transition-colors`;function bt({open:e,projectName:t,detected:n,customTasks:r,hiddenCount:i,editedCount:a,error:o,onClose:ee,onAdd:d,onRemove:te,onEdit:f,onHide:ne,onReset:re,onRescan:p}){let[ie,m]=(0,C.useState)(``),[ae,oe]=(0,C.useState)(``),[se,h]=(0,C.useState)(!1),[ce,le]=(0,C.useState)(!1),[ue,de]=(0,C.useState)(``),[fe,pe]=(0,C.useState)(``),[me,he]=(0,C.useState)(``),[_,ge]=(0,C.useState)(``);(0,C.useEffect)(()=>{e&&(m(``),oe(``),h(!1),le(!1),de(``),pe(``))},[e]);let v=async()=>{let e=ae.trim();if(e&&!se){h(!0);try{await d(ie.trim(),e),m(``),oe(``)}finally{h(!1)}}},_e=async()=>{if(!ce){le(!0);try{await p(),de(new Date().toLocaleTimeString(`zh-CN`,{hour12:!1}))}finally{le(!1)}}},ve=e=>{pe(e.id),he(e.edited?e.display:``),ge(e.command)},ye=async()=>{if(!fe)return;let e=fe;pe(``),await f(e,me,_)};return(0,P.jsxs)(l,{open:e,onClose:ee,className:`relative z-110`,children:[(0,P.jsx)(u,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,P.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,P.jsxs)(s,{transition:!0,className:`tw-dialog-panel-anim relative flex max-h-[80vh] w-full max-w-2xl flex-col overflow-hidden rounded-xl border shadow-xl ${vt}`,children:[(0,P.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b px-5 py-4 ${I}`,children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(c,{className:`text-base font-semibold ${yt}`,children:`运行配置`}),(0,P.jsxs)(`p`,{className:`mt-1 truncate text-xs leading-relaxed ${R}`,children:[t,` · 命令在该项目目录下用 shell 执行,支持引号与 &&`]})]}),(0,P.jsx)(`button`,{type:`button`,onClick:ee,className:`tw-confirm-cancel -mr-1 -mt-1 flex h-7 w-7 shrink-0 items-center justify-center rounded-md ${R} transition-colors hover:bg-[var(--tw-session-hover-bg)] hover:text-[var(--tw-label-primary)]`,"aria-label":`关闭`,children:`✕`})]}),(0,P.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[(0,P.jsxs)(`section`,{className:`border-b px-5 py-4 ${I}`,children:[(0,P.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,P.jsx)(`span`,{className:`text-xs font-medium ${L}`,children:`自定义命令`}),(0,P.jsxs)(`span`,{className:`text-[11px] ${R}`,children:[r.length,` 条`]})]}),r.length?(0,P.jsx)(`ul`,{className:`mt-2 divide-y rounded-lg border ${F} ${I}`,children:r.map(e=>(0,P.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 px-2.5 py-1.5`,children:[(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate ${L}`,children:e.name?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`text-xs`,children:e.name}),(0,P.jsx)(`span`,{className:`ml-1.5 font-mono text-[11px] ${R}`,children:e.command})]}):(0,P.jsx)(`span`,{className:`font-mono text-[11px] ${L}`,children:e.command})}),(0,P.jsx)(`button`,{type:`button`,className:`${H} hover:bg-red-50 hover:text-red-600`,onClick:()=>void te(e.id),children:`删除`})]},e.id))}):(0,P.jsx)(`p`,{className:`mt-2 rounded-lg border border-dashed px-2.5 py-2 text-[11px] ${I} ${R}`,children:`还没有自定义命令。名称可以不填,不填时下拉里直接显示命令。`}),(0,P.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(`input`,{className:`${B} w-28 shrink-0`,value:ie,onChange:e=>m(e.target.value),placeholder:`名称(可选)`,"aria-label":`运行任务名称`}),(0,P.jsx)(`input`,{className:`${B} flex-1 font-mono`,value:ae,onChange:e=>oe(e.target.value),onKeyDown:e=>{e.key===`Enter`&&v()},placeholder:`npm run test:smoke`,"aria-label":`运行命令`,spellCheck:!1}),(0,P.jsxs)(`button`,{type:`button`,className:V,onClick:()=>void v(),disabled:!ae.trim()||se,children:[(0,P.jsx)(g,{name:`plus`,size:13}),`添加`]})]})]}),(0,P.jsxs)(`section`,{className:`px-5 py-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`text-xs font-medium ${L}`,children:`自动发现`}),(0,P.jsxs)(`span`,{className:`text-[11px] ${R}`,children:[n.length,` 条`,ue?` · ${ue} 已扫描`:` · 挂载时扫描项目配置`]}),i||a?(0,P.jsxs)(`span`,{className:`text-[11px] ${R}`,children:[`已改 `,a,` · 已删 `,i]}):null,(0,P.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[i||a?(0,P.jsx)(`button`,{type:`button`,className:`${H} hover:bg-[var(--tw-session-hover-bg)] hover:text-[#4176e6]`,onClick:()=>void re(),children:`恢复默认`}):null,(0,P.jsxs)(`button`,{type:`button`,className:`${H} inline-flex items-center gap-1 hover:bg-[var(--tw-session-hover-bg)] hover:text-[var(--tw-label-primary)] disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void _e(),disabled:ce,children:[(0,P.jsxs)(`svg`,{className:`h-3 w-3 shrink-0 ${ce?`animate-spin`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,P.jsx)(`path`,{d:`M21 12a9 9 0 1 1-2.6-6.4`}),(0,P.jsx)(`path`,{d:`M21 4v5h-5`})]}),ce?`扫描中…`:`重新扫描`]})]})]}),n.length?(0,P.jsx)(`ul`,{className:`mt-2 divide-y rounded-lg border ${F} ${I}`,children:n.map(e=>fe===e.id?(0,P.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-2 px-2.5 py-2`,children:[(0,P.jsx)(`input`,{className:`${B} w-28 shrink-0`,value:me,onChange:e=>he(e.target.value),placeholder:`名称(留空用原名称)`,"aria-label":`修改名称 ${e.id}`}),(0,P.jsx)(`input`,{className:`${B} flex-1 font-mono`,value:_,onChange:e=>ge(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ye(),e.key===`Escape`&&pe(``)},placeholder:`命令`,"aria-label":`修改命令 ${e.id}`,spellCheck:!1}),(0,P.jsx)(`button`,{type:`button`,className:`h-8 shrink-0 rounded-lg bg-[#4176e6] px-2.5 text-xs text-white transition-colors hover:bg-[#3566d0]`,onClick:()=>void ye(),children:`保存`}),(0,P.jsx)(`button`,{type:`button`,className:`h-8 shrink-0 rounded-lg border px-2.5 text-xs ${I} ${L} transition-colors hover:bg-[var(--tw-session-hover-bg)]`,onClick:()=>pe(``),children:`取消`})]},e.id):(0,P.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 px-2.5 py-1.5 ${z}`,children:[(0,P.jsx)(`span`,{className:`w-24 shrink-0 truncate text-xs ${L}`,children:e.display||e.command}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] ${R}`,children:e.command}),e.edited?(0,P.jsx)(`span`,{className:`shrink-0 rounded bg-amber-500/15 px-1.5 py-0.5 text-[10px] text-amber-600`,children:`已改`}):e.hint?(0,P.jsx)(`span`,{className:`hidden max-w-[170px] shrink-0 truncate text-[11px] sm:block ${R}`,children:e.hint}):null,(0,P.jsxs)(`span`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,P.jsx)(`button`,{type:`button`,className:`${H} hover:bg-[var(--tw-session-hover-bg)] hover:text-[var(--tw-label-primary)]`,onClick:()=>ve(e),children:`修改`}),(0,P.jsx)(`button`,{type:`button`,className:`${H} hover:bg-red-50 hover:text-red-600`,onClick:()=>void ne(e.id),children:`删除`})]})]},e.id))}):(0,P.jsx)(`p`,{className:`mt-2 rounded-lg border border-dashed px-2.5 py-2 text-[11px] ${I} ${R}`,children:`没扫到可复用命令(项目里没有测试脚本 / Makefile 目标 / marker),只保留全量运行。`}),(0,P.jsx)(`p`,{className:`mt-2 text-[11px] leading-relaxed ${R}`,children:`扫描来源:package.json 的 scripts、Makefile 目标、pytest markers、Maven profiles。改过的命令按原样用 shell 执行,不再追加框架参数。`})]})]}),o?(0,P.jsx)(`p`,{className:`shrink-0 border-t px-5 py-2 text-[11px] text-red-600 ${I}`,children:o}):null]})})]})}function U(e){return e.kind===`create`?{label:`新增`,className:`bg-emerald-50 text-emerald-600`}:e.kind===`merge`?{label:`追加`,className:`bg-sky-50 text-sky-600`}:{label:`修改`,className:`bg-amber-50 text-amber-600`}}function xt({changes:e,git:t,draft:n,loading:r,onReveal:i,onRefresh:a}){let[o,s]=(0,C.useState)(``),c=(0,C.useMemo)(()=>e.find(e=>e.path===o)??e[0]??null,[o,e]);return(0,P.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-stone-100 px-3 py-1`,children:[(0,P.jsxs)(`span`,{className:`shrink-0 text-[11px] text-stone-500`,children:[`本次写入 `,(0,P.jsx)(`span`,{className:`font-medium text-stone-700`,children:e.length}),` 个文件`]}),n?.draftRoot?(0,P.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[10px] text-stone-400`,children:n.draftRoot}):null,(0,P.jsxs)(`button`,{type:`button`,className:`ml-auto flex shrink-0 items-center gap-1 whitespace-nowrap text-[11px] text-[#3370ff] hover:underline disabled:opacity-40`,onClick:a,disabled:r,children:[`刷新`,(0,P.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-full border border-[#3370ff]/30 border-t-[#3370ff] ${r?`animate-spin`:`opacity-0`}`})]})]}),e.length===0?(0,P.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-1 px-4 text-center`,children:(0,P.jsx)(`p`,{className:`text-[11px] leading-relaxed text-stone-400`,children:`还没有写入项目。试跑通过后点「写入项目」,这里会出现精确到行的改动内容。`})}):(0,P.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,P.jsxs)(`div`,{className:`flex w-60 shrink-0 flex-col overflow-auto border-r border-stone-100`,children:[(0,P.jsx)(`div`,{className:`shrink-0`,children:e.map(e=>{let t=U(e),n=c?.path===e.path;return(0,P.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 px-2.5 py-1.5 text-left text-[11px] transition-colors ${n?`bg-[#f2f6ff]`:`hover:bg-stone-50`}`,onClick:()=>s(e.path),children:[(0,P.jsx)(`span`,{className:`shrink-0 rounded px-1 text-[10px] leading-4 ${t.className}`,children:t.label}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-stone-700`,children:e.path}),(0,P.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] text-emerald-600`,children:[`+`,e.added]}),(0,P.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] text-red-500`,children:[`-`,e.removed]})]},e.path)})}),t?.ok&&t.entries.length?(0,P.jsxs)(`details`,{className:`mt-auto shrink-0 border-t border-stone-100 px-2.5 py-1.5`,children:[(0,P.jsxs)(`summary`,{className:`cursor-pointer list-none text-[11px] text-stone-500`,children:[`项目工作区其它改动 `,t.entries.length,t.truncated?`(截断)`:``]}),(0,P.jsx)(`ul`,{className:`mt-1 space-y-0.5`,children:t.entries.map(e=>(0,P.jsxs)(`li`,{className:`flex items-center gap-1.5 font-mono text-[10px] text-stone-500`,children:[(0,P.jsx)(`span`,{className:`w-4 shrink-0 text-[#3370ff]`,children:e.code}),(0,P.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left hover:underline`,onClick:()=>i(e.path),children:e.path})]},`${e.code}-${e.path}`))})]}):null]}),c?(0,P.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-stone-100 px-3 py-1`,children:[(0,P.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] text-stone-600`,children:c.path}),(0,P.jsx)(`button`,{type:`button`,className:`ml-auto shrink-0 text-[11px] text-[#3370ff] hover:underline`,onClick:()=>i(c.path),children:`打开文件`}),(0,P.jsx)(`button`,{type:`button`,className:`shrink-0 text-[11px] text-[#3370ff] hover:underline`,onClick:()=>{let e=c.path.lastIndexOf(`/`);i(e===-1?``:c.path.slice(0,e))},children:`打开目录`})]}),(0,P.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto bg-stone-50/40`,children:[c.truncated?(0,P.jsx)(`p`,{className:`px-3 py-2 text-[11px] text-stone-500`,children:c.message}):null,(c.hunks??[]).map((e,t)=>(0,P.jsxs)(`div`,{className:`border-b border-stone-100`,children:[(0,P.jsxs)(`div`,{className:`bg-stone-100/70 px-3 py-0.5 font-mono text-[10px] text-stone-500`,children:[`@@ -`,e.oldStart,`,`,e.oldLines,` +`,e.newStart,`,`,e.newLines,` @@`]}),(0,P.jsx)(`div`,{className:`py-1`,children:(()=>{let t=e.oldStart,n=e.newStart;return e.lines.map((e,r)=>{let i=e.type===`add`?`+`:e.type===`del`?`-`:` `,a=e.type===`add`?``:t,o=e.type===`del`?``:n;return e.type!==`add`&&(t+=1),e.type!==`del`&&(n+=1),(0,P.jsxs)(`div`,{className:`flex gap-2 px-2 font-mono text-[11px] leading-5 ${e.type===`add`?`bg-emerald-50 text-emerald-800`:e.type===`del`?`bg-red-50 text-red-700`:`text-stone-600`}`,children:[(0,P.jsx)(`span`,{className:`w-8 shrink-0 select-none text-right text-[10px] text-stone-400`,children:a}),(0,P.jsx)(`span`,{className:`w-8 shrink-0 select-none text-right text-[10px] text-stone-400`,children:o}),(0,P.jsx)(`span`,{className:`w-2 shrink-0 select-none text-stone-400`,children:i}),(0,P.jsx)(`span`,{className:`whitespace-pre`,children:e.text||` `})]},r)})})()})]},`${c.path}-${t}`)),!c.truncated&&(c.hunks??[]).length===0?(0,P.jsx)(`p`,{className:`px-3 py-2 text-[11px] text-stone-400`,children:`内容没有变化`}):null]})]}):null]})]})}var St=[{value:`goto`,label:`打开页面`},{value:`click`,label:`点击`},{value:`fill`,label:`填写`},{value:`select`,label:`选择`},{value:`press`,label:`按键`},{value:`hover`,label:`悬停`},{value:`expect`,label:`断言元素`},{value:`expectUrl`,label:`断言地址`},{value:`wait`,label:`等待`}],W=`h-7 w-full rounded-md border border-stone-200 bg-white px-2 text-[11px] text-stone-700 outline-none transition-colors focus:border-[#3370ff]`,Ct={pending:{label:`待绑定`,className:`bg-stone-100 text-stone-500`},bound:{label:`已绑定`,className:`bg-emerald-50 text-emerald-600`},done:{label:`已完成`,className:`bg-emerald-50 text-emerald-600`},failed:{label:`没绑上`,className:`bg-red-50 text-red-600`}};function wt(e){let t=new Set(e.map(e=>e.id)),n=e.length+1;for(;t.has(`p${n}`);)n+=1;return`p${n}`}function Tt({plan:e,disabled:t,onChange:n}){let r=(t,r)=>{n(e.map(e=>e.id===t?{...e,...r}:e))},i=(t,r)=>{let i=t+r;if(i<0||i>=e.length)return;let a=e.slice(),[o]=a.splice(t,1);a.splice(i,0,o),n(a)},a=t=>n(e.filter(e=>e.id!==t)),o=()=>n([...e,{id:wt(e),action:`click`,target:``,status:`pending`}]),s=e.filter(e=>e.status===`bound`||e.status===`done`).length;return(0,P.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between px-1 pb-1.5`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,P.jsx)(`span`,{className:`text-xs font-medium text-stone-600`,children:`步骤计划`}),e.length?(0,P.jsxs)(`span`,{className:`text-[11px] text-stone-400`,children:[s,`/`,e.length,` 已绑定`]}):null]}),(0,P.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,P.jsx)(`button`,{type:`button`,className:`text-[11px] text-[#3370ff] hover:underline disabled:opacity-40`,onClick:o,disabled:t||e.length>=40,children:`+ 添加`})})]}),(0,P.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-1.5 overflow-auto px-0.5`,children:[e.length===0?(0,P.jsxs)(`p`,{className:`rounded-lg border border-dashed border-stone-200 px-3 py-6 text-center text-[11px] leading-relaxed text-stone-400`,children:[`还没有步骤。`,(0,P.jsx)(`br`,{}),`输入需求后点「生成步骤」,这里会出来一份可以手动调整的计划。`]}):null,e.map((n,o)=>{let s=Ct[n.status]??Ct.pending,c=n.action===`fill`||n.action===`select`||n.action===`press`;return(0,P.jsxs)(`div`,{className:`rounded-lg border border-stone-200 bg-white px-2 py-1.5`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(`span`,{className:`w-4 shrink-0 text-center font-mono text-[10px] text-stone-400`,children:o+1}),(0,P.jsx)(`div`,{className:`w-[88px] shrink-0`,children:(0,P.jsx)(ie,{options:St,value:n.action,onChange:e=>r(n.id,{action:e}),disabled:t,unstyled:!0,ariaLabel:`步骤动作`,triggerClassName:`flex h-6 w-full items-center gap-1 rounded-md border border-stone-200 bg-white px-1 text-[10px] text-stone-600 outline-none transition-colors hover:border-stone-300 focus:border-[#3370ff] disabled:cursor-not-allowed disabled:opacity-50`,menuMinWidth:120})}),(0,P.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${s.className}`,children:s.label}),(0,P.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[(0,P.jsx)(`button`,{type:`button`,className:`px-1 text-[11px] text-stone-400 hover:text-stone-700 disabled:opacity-30`,onClick:()=>i(o,-1),disabled:t||o===0,"aria-label":`上移`,children:`↑`}),(0,P.jsx)(`button`,{type:`button`,className:`px-1 text-[11px] text-stone-400 hover:text-stone-700 disabled:opacity-30`,onClick:()=>i(o,1),disabled:t||o===e.length-1,"aria-label":`下移`,children:`↓`}),(0,P.jsx)(`button`,{type:`button`,className:`tw-icon-danger px-1 text-[11px]`,onClick:()=>a(n.id),disabled:t,"aria-label":`删除`,children:`×`})]})]}),(0,P.jsx)(`input`,{className:`${W} mt-1`,value:n.target,disabled:t,placeholder:n.action===`goto`?`打开哪个页面`:`目标描述,例如「登录按钮」`,onChange:e=>r(n.id,{target:e.target.value}),spellCheck:!1}),n.action===`goto`||n.action===`expectUrl`?(0,P.jsx)(`input`,{className:`${W} mt-1 font-mono`,value:n.url??``,disabled:t,placeholder:`/login`,onChange:e=>r(n.id,{url:e.target.value}),spellCheck:!1}):null,c?(0,P.jsx)(`input`,{className:`${W} mt-1 font-mono`,value:n.value??``,disabled:t,placeholder:n.action===`press`?`Enter`:"输入值 / 选项(${ENV} 占位)",onChange:e=>r(n.id,{value:e.target.value}),spellCheck:!1}):null,n.locator?(0,P.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-emerald-700`,children:st(n.locator)}):null,n.warning?(0,P.jsx)(`p`,{className:`mt-0.5 text-[10px] leading-4 text-amber-600`,children:n.warning}):null]},n.id)})]})]})}var Et=`inline-flex h-8 shrink-0 select-none items-center gap-1.5 whitespace-nowrap rounded-lg px-3 text-sm outline-none transition-[background-color,border-color,color,box-shadow,opacity,transform] duration-150 motion-safe:active:translate-y-px focus-visible:ring-2 focus-visible:ring-[#4176e6]/35 disabled:cursor-not-allowed disabled:motion-safe:active:translate-y-0`,G=`${Et} font-medium text-white shadow-[0_1px_2px_rgba(23,43,99,0.12),inset_0_1px_0_rgba(255,255,255,0.18)] bg-[#4176e6] hover:bg-[#3566d0] active:bg-[#2f5cbd] active:shadow-none disabled:opacity-40 disabled:shadow-none disabled:hover:bg-[#4176e6] disabled:active:bg-[#4176e6]`,Dt=`${Et} border border-stone-200 text-stone-600 hover:border-stone-300 hover:bg-stone-50 disabled:opacity-40`,Ot=`${Et} border border-red-200 bg-red-50 text-red-600 hover:opacity-90 active:opacity-80`,kt=`inline-flex h-7 select-none items-center gap-1.5 whitespace-nowrap rounded-md px-2 text-xs outline-none transition-[background-color,color,box-shadow,opacity,transform] duration-150 motion-safe:active:translate-y-px focus-visible:ring-2 focus-visible:ring-[#4176e6]/30 disabled:cursor-not-allowed disabled:motion-safe:active:translate-y-0`,At=`${kt} text-stone-600 hover:bg-stone-100 disabled:opacity-40`,jt=`${kt} bg-(--tw-accent-soft) text-[#4176e6]`,Mt=`text-[11px] text-[#3370ff] hover:underline disabled:opacity-40 disabled:no-underline`,Nt=`h-8 w-full rounded-lg border border-stone-200 bg-white px-2.5 text-xs text-stone-700 outline-none transition-colors focus:border-[#3370ff]`,Pt=3,Ft=`ui-auto.gen.panel`,It=160,Lt=260,Rt=36,zt=60,Bt=`ui-auto.gen.side`,Vt=330,Ht=560,Ut=380,Wt=`ui-auto.gen.top`,Gt=`ui-auto.gen.bottom`,Kt=`ui-auto.gen.target`,qt=72,Jt=420,Yt=qt,Xt=`ui-auto.gen.reqheight`,Zt=[{value:`activity`,label:`探索活动`},{value:`code`,label:`代码`},{value:`changes`,label:`变更`}],Qt=[{value:`console`,label:`控制台`},{value:`network`,label:`网络`},{value:`run`,label:`试跑`}];function $t(e,t,n){let r=i(e);return t.includes(r)?r:n}var en=`ui-auto.requirement`;function tn(){let e=o(en,``);return typeof e==`string`&&e?e:i(en,``)}function nn(e,t,n,r){let a=Number(i(e));return!Number.isFinite(a)||a<t?r:Math.min(a,n)}function rn(e,t){let n=i(e);return n===`1`||n!==`0`&&t}var an=[{value:`1`,label:`有头(可围观)`},{value:`0`,label:`无头(更快)`}];function on(e,t){let n=t.some(e=>e.endsWith(`.py`)),r=t.some(e=>/\.(ts|js|mjs|cjs|tsx|jsx)$/.test(e));return e===`pytest`||n&&!r?{options:[{value:`python`,label:`Python`}],fallback:`python`}:{options:[{value:`ts`,label:`TypeScript`},{value:`python`,label:`Python`}],fallback:`ts`}}var sn=new Set([`goto`,`click`,`fill`,`select`,`press`,`hover`,`expect`,`expectUrl`,`wait`]);function cn(e){return e.filter(e=>sn.has(e.action))}function ln(e,t){if(!t.length)return e;let n=new Map(t.map(e=>[e.id,e])),r=e.map(e=>{let t=n.get(e.id);return t?{...e,status:t.status,locator:t.locator,warning:t.warning}:e});for(let n of t)e.some(e=>e.id===n.id)||r.push(n);return cn(r)}function un(e,t){if(!t)return``;if(e!==`ui_browser_fill`&&e!==`ui_browser_select`)return t.slice(0,240);try{let e=JSON.parse(t);for(let t of[`text`,`value`]){let n=e[t];typeof n==`string`&&!n.startsWith("${")&&(e[t]=n.replace(/[\s\S]/g,`•`))}return JSON.stringify(e).slice(0,240)}catch{return t.slice(0,240)}}function dn(e){window.dispatchEvent(new CustomEvent(`lantern:uiauto-changed`,{detail:{count:e}}))}function fn(e){return e.split(`/`).pop()||e}function pn(e){let t=e.split(`/`);return t.pop(),t.join(`/`)||`.`}function mn(e){return e===`page`?{label:`页面`,className:`bg-sky-50 text-sky-600`}:e===`fixture`?{label:`登录态`,className:`bg-violet-50 text-violet-600`}:{label:`用例`,className:`bg-emerald-50 text-emerald-600`}}function hn({project:e,promptFile:t,onError:o}){let[s,c]=(0,C.useState)(null),l=(0,C.useCallback)(async()=>v(t),[t]),u=(0,C.useCallback)(async()=>{let e=await l();return!e.plan.trim()&&!e.agent.trim()?(ce(`没有读到「提示词管理」里的「${e.file||`Playwright提示词.md`}」。本平台提示词以提示词管理为准,请先在「提示词管理」里写好(需包含「## 规划阶段」「## 探索阶段」)再生成。`,`error`),null):e},[l]),ee=(0,C.useMemo)(()=>on(e.framework,e.specFiles??[]),[e.framework,e.specFiles]),[d,te]=(0,C.useState)(()=>{let{options:t,fallback:n}=on(e.framework,e.specFiles??[]),r=i(Kt);return t.some(e=>e.value===r)?r:n}),[f,ne]=(0,C.useState)(tn),re=`ui-auto.baseurl.${e.id}`,[p,m]=(0,C.useState)(()=>e.baseURL||i(re)||e.detectedBaseURL||i(`ui-auto.baseurl`)||`http://localhost:5173`),[ae,oe]=(0,C.useState)(e.detectedBaseURL||``),se=`ui-auto.storage.${e.id}`,[h,g]=(0,C.useState)(()=>e.storageState||e.detectedStorageState||i(se)||``),[le,me]=(0,C.useState)(e.detectedStorageState||``),[_,ge]=(0,C.useState)(()=>rn(`ui-auto.headed`,!0)),[_e,ye]=(0,C.useState)(()=>nn(Xt,qt,Jt,Yt)),[be,xe]=(0,C.useState)(!1),Se=(0,C.useRef)(null),[Ce,we]=(0,C.useState)(()=>rn(`ui-auto.gen.address`,!1)),[Te,Ee]=(0,C.useState)(()=>rn(`ui-auto.gen.accept`,!1)),[De,Oe]=(0,C.useState)(!0),[y,b]=(0,C.useState)(`idle`),[ke,Ae]=(0,C.useState)([]),[x,je]=(0,C.useState)(null),[S,Me]=(0,C.useState)([]),[Ne,Pe]=(0,C.useState)(!1),[Ie,w]=(0,C.useState)(!1),[Re,T]=(0,C.useState)(``),[E,D]=(0,C.useState)(``),[Ve,He]=(0,C.useState)([]),[j,Ze]=(0,C.useState)(()=>i(`ui-auto.gen.file.${e.id}`)),[M,et]=(0,C.useState)(()=>rn(`ui-auto.gen.force`,!1)),[N,ot]=(0,C.useState)([]),[st,ct]=(0,C.useState)(()=>{let e=Number(i(Bt));return!Number.isFinite(e)||e<Vt?Ut:Math.min(e,Ht)}),lt=(0,C.useRef)(null),[mt,ht]=(0,C.useState)(``),[gt,vt]=(0,C.useState)(``),[F,I]=(0,C.useState)(``),[yt,L]=(0,C.useState)(``),[R,z]=(0,C.useState)(null),[B,V]=(0,C.useState)(0),[H,bt]=(0,C.useState)(()=>$t(Gt,Qt.map(e=>e.value),`run`)),[U,St]=(0,C.useState)(()=>$t(Wt,Zt.map(e=>e.value),`activity`)),[W,Ct]=(0,C.useState)(()=>{let e=Number(i(Ft));return!Number.isFinite(e)||e<Rt||e<=zt?Lt:Math.min(e,640)}),[wt,Et]=(0,C.useState)(()=>i(Ft)===`closed`),[kt,sn]=(0,C.useState)(!1),hn=(0,C.useRef)(null),[bn,xn]=(0,C.useState)([]),[Sn,Cn]=(0,C.useState)([]),[wn,Tn]=(0,C.useState)([]),[En,Dn]=(0,C.useState)(null),[K,q]=(0,C.useState)(null),[On,kn]=(0,C.useState)(!1),[J,An]=(0,C.useState)(null),[jn,Mn]=(0,C.useState)(!1),[Nn,Pn]=(0,C.useState)(``),[Y,Fn]=(0,C.useState)(null),[In,Ln]=(0,C.useState)(!1),Rn=(0,C.useRef)(null),X=(0,C.useRef)(``),zn=(0,C.useRef)(0),Bn=(0,C.useRef)([]),Vn=(0,C.useRef)(null),Hn=(0,C.useRef)(null),Un=(0,C.useRef)(null),Wn=(0,C.useRef)([]);(0,C.useEffect)(()=>{Wn.current=S},[S]);let[Gn,Kn]=(0,C.useState)(!1);(0,C.useEffect)(()=>{let e=!0;n().then(()=>{e&&c(fe())});let t=de(()=>c(fe()));return()=>{e=!1,t()}},[]);let Z=(0,C.useCallback)(e=>{zn.current+=1;let t=zn.current;return Ae(n=>[...n,{...e,id:t,at:e.at??new Date().toISOString()}]),t},[]),qn=(0,C.useRef)(null),Jn=(0,C.useRef)(``);(0,C.useEffect)(()=>{let e=X.current;if(!e)return;let t=ke.map(({kind:e,name:t,detail:n,status:r,at:i})=>({kind:e,name:t,detail:n,status:r,at:i})),n=JSON.stringify(t);n!==Jn.current&&(Jn.current=n,qn.current&&window.clearTimeout(qn.current),qn.current=window.setTimeout(()=>{O({sessionId:e,activity:t}).catch(()=>void 0)},600))},[ke]),(0,C.useEffect)(()=>{r(en,f)},[f]),(0,C.useEffect)(()=>{a(re,p),a(`ui-auto.baseurl`,p)},[re,p]);let Yn=(0,C.useRef)(null),Xn=(0,C.useRef)(p);(0,C.useEffect)(()=>{p!==Xn.current&&(Xn.current=p,Yn.current&&window.clearTimeout(Yn.current),Yn.current=window.setTimeout(()=>{ve({id:e.id,baseURL:p}).then(e=>oe(e.detectedBaseURL||``)).catch(()=>void 0)},600))},[p,e.id]),(0,C.useEffect)(()=>{a(se,h)},[se,h]);let Zn=(0,C.useRef)(null),Qn=(0,C.useRef)(h);(0,C.useEffect)(()=>{h!==Qn.current&&(Qn.current=h,Zn.current&&window.clearTimeout(Zn.current),Zn.current=window.setTimeout(()=>{ve({id:e.id,storageState:h}).then(e=>me(e.detectedStorageState||``)).catch(()=>void 0)},600))},[h,e.id]),(0,C.useEffect)(()=>{a(`ui-auto.headed`,_?`1`:`0`)},[_]),(0,C.useEffect)(()=>{a(`ui-auto.gen.force`,M?`1`:`0`)},[M]),(0,C.useEffect)(()=>{a(`ui-auto.gen.address`,Ce?`1`:`0`)},[Ce]),(0,C.useEffect)(()=>{a(`ui-auto.gen.accept`,Te?`1`:`0`)},[Te]),(0,C.useEffect)(()=>{j&&a(`ui-auto.gen.file.${e.id}`,j)},[j,e.id]),(0,C.useEffect)(()=>{be||a(Xt,String(_e))},[_e,be]);let $n=(0,C.useCallback)(e=>{St(e),a(Wt,e)},[]),er=(0,C.useCallback)(e=>{bt(e),a(Gt,e),wt&&(Et(!1),a(Ft,String(W)))},[wt,W]),tr=(0,C.useCallback)(()=>{Et(e=>{let t=!e;return a(Ft,t?`closed`:String(W)),t})},[W]),nr=(0,C.useCallback)(async()=>{if(!X.current)Tn([]),Dn(null),q(null);else{kn(!0);try{let e=await Ye(X.current);Tn(e.changes),Dn(e.git),q(e.draft),e.changes.length&&dn(e.changes.length)}catch{}finally{kn(!1)}}},[]),rr=(0,C.useCallback)(async(e,t,n=``)=>{if(!e?.steps?.length)return He([]),[];try{let r=await We(e,t,{testDir:n.includes(`/`)?n.replace(/\/[^/]+$/,``):`tests`});return He(r.files),Ze(e=>r.files.some(t=>t.path===e)?e:r.files[0]?.path??``),r.files}catch{return[]}},[]),ir=(0,C.useCallback)(async()=>{if(!X.current)return[];w(!0);try{let e=await A(X.current);return T(e.code),D(e.suggestedPath),await rr(e.session.ir,e.session.target===`python`?`python`:`ts`,e.suggestedPath)}catch{return[]}finally{w(!1)}},[rr]);(0,C.useEffect)(()=>{let t=!0;return je(null),X.current=``,Me([]),T(``),z(null),vt(``),Ae([]),Tn([]),Dn(null),q(null),An(null),Pn(``),Fn(null),Oe(!0),Ke(e.id).then(async n=>{if(!t)return;let r=n.sessions[0];if(!r){let t=e.baseURL||e.detectedBaseURL||``;Xn.current=t,m(t),oe(e.detectedBaseURL||``);let n=e.storageState||e.detectedStorageState||``;Qn.current=n,g(n),me(e.detectedStorageState||``);return}let a=await A(r.id);if(!t)return;je(a.session),X.current=a.session.id,Me(cn(a.session.plan??[])),T(a.code),D(a.suggestedPath),He([]),Ze(i(`ui-auto.gen.file.${e.id}`)),rr(a.session.ir,a.session.target===`python`?`python`:`ts`,a.suggestedPath),te(a.session.target===`python`?`python`:`ts`);let o=e.baseURL||a.session.baseURL||e.detectedBaseURL||``;Xn.current=o,m(o),oe(e.detectedBaseURL||``);let s=e.storageState||a.session.storageState||e.detectedStorageState||``;if(Qn.current=s,g(s),me(e.detectedStorageState||``),ne(e=>a.session.source||e),q(a.draft??null),Tn(a.changes??[]),a.session.lastVerify&&z({passed:a.session.lastVerify.passed,exitCode:a.session.lastVerify.exitCode,durationMs:a.session.lastVerify.durationMs,log:a.session.lastVerify.log}),Array.isArray(a.session.activity)&&a.session.activity.length){let e=a.session.activity.map(e=>{zn.current+=1;let t=e.status===`running`?`failed`:e.status;return{id:zn.current,kind:e.kind===`tool`||e.kind===`error`?e.kind:`info`,name:e.name,detail:e.detail,status:t,at:e.at}});Jn.current=JSON.stringify(e.map(({kind:e,name:t,detail:n,status:r,at:i})=>({kind:e,name:t,detail:n,status:r,at:i}))),Ae(e)}a.session.savedPath&&$n(`changes`),L(`已载入上次生成的草稿`),await nr()}).catch(()=>void 0).finally(()=>{t&&Oe(!1)}),()=>{t=!1}},[e.id,nr,rr,$n]),(0,C.useEffect)(()=>{let{options:t,fallback:n}=on(e.framework,e.specFiles??[]);t.some(e=>e.value===d)||te(n)},[e.framework,e.specFiles,d]),(0,C.useEffect)(()=>{Vn.current?.scrollTo({top:Vn.current.scrollHeight})},[ke]),(0,C.useEffect)(()=>()=>{Hn.current?.release(),Rn.current?.abort(),Un.current&&window.clearTimeout(Un.current),X.current&&(Je(X.current).catch(()=>void 0),Ue(X.current).catch(()=>void 0))},[]),(0,C.useEffect)(()=>{if(!x?.id)return;let e=x.id;H===`console`?ze(e).then(e=>xn(e.messages??[])).catch(()=>xn([])):H===`network`&&Be(e).then(e=>Cn(e.requests??[])).catch(()=>Cn([]))},[H,x?.id]);let Q=y!==`idle`,ar=y===`exploring`||y===`verifying`||y===`repairing`,or=Q||!f.trim()||!S.length,sr=x?.status===`explored`||x?.status===`verified`||x?.status===`written`||x?.status===`failed`,cr=Q||!sr||!x?.ir?.steps?.length,lr=(0,C.useCallback)(()=>({sessionId:X.current,target:d,onPlan:e=>Me(t=>ln(t,e)),onShot:e=>ht(e),onCode:(e,t)=>{T(e),D(t)},onIr:e=>{Z({kind:`info`,name:`提交步骤`,detail:`${e.title} · ${e.steps.length} 步`,status:`done`})}}),[Z,d]),ur=(0,C.useCallback)(async(e,t)=>{if(!s)throw ue(`model`),Error(`请先配置模型`);let n=lr();for await(let r of pe(s,e,t,{tools:nt,maxToolRounds:40,runTool:async(e,t)=>{Hn.current&&await Hn.current.promise;let r=await at(e,t,n);if(it(r)){for(let e of Bn.current.splice(0))Ae(t=>t.map(t=>t.id===e?{...t,status:`failed`}:t));throw Error(rt)}return r}}))if(r.type===`tool`){if(r.status===`running`){let e=Z({kind:`tool`,name:r.name,detail:un(r.name,r.args??``),status:`running`});Bn.current.push(e)}else{let e=Bn.current.pop();Ae(t=>t.map(t=>t.id===e?{...t,status:`done`,detail:(r.result??``).slice(0,240)}:t))}}else r.type===`content`&&vt(e=>e+r.delta)},[Z,s,lr]),dr=(0,C.useCallback)(async(t=!1)=>{let n=await Le({projectId:e.id,sessionId:X.current||void 0,title:f.trim().split(/\r?\n/)[0]?.slice(0,60)||`未命名流程`,target:d,baseURL:p,storageState:h,source:f.trim(),headed:_,reset:t,plan:Wn.current.length?Wn.current:void 0});return X.current=n.session.id,je(n.session),D(n.suggestedPath),q(n.draft),t&&(T(``),He([]),z(null),Tn([]),An(null),Fn(null)),n.session.storageState&&g(n.session.storageState),n},[p,_,e.id,f,h,d]),fr=(0,C.useCallback)(async(t,n)=>{if(!s)throw ue(`model`),Error(`请先配置模型`);let r=lr(),i=await l(),a=[{role:`system`,content:dt(e,d,i.plan)},{role:`user`,content:ft(t,p,d)}];for await(let e of pe(s,a,n,{tools:tt,maxToolRounds:2,runTool:async(e,t)=>at(e,t,r)}))e.type===`tool`&&e.status===`running`?Z({kind:`info`,name:`规划步骤`,detail:`只做测试设计,不打开浏览器`,status:`done`}):e.type===`content`&&vt(t=>t+e.delta);let o=cn((await A(X.current)).session.plan??[]);return Me(o),o},[p,l,e,Z,s,d,lr]),pr=(0,C.useCallback)(async()=>{let e=f.trim();if(!e||Q)return;if(!s){I(`还没有配置模型,请先在设置里填好 API Key`),ue(`model`);return}if(!await u())return;r(en,e),a(`ui-auto.baseurl`,p),a(se,h),a(`ui-auto.headed`,_?`1`:`0`);let t=new AbortController;Rn.current=t,I(``),L(``),vt(``),b(`planning`);try{await dr(!0);let n=await fr(e,t.signal);L(n.length?`已生成 ${n.length} 步计划,可以手动调整后再探索`:`没有得到步骤,补充需求后再试`)}catch(e){if(t.signal.aborted)L(`已停止`);else{let t=e instanceof Error?e.message:String(e);I(t),o?.(t),Z({kind:`error`,name:`规划失败`,detail:t,status:`failed`})}}finally{Rn.current=null,b(`idle`)}},[p,Q,dr,_,o,fr,Z,u,f,s,h]),mr=(0,C.useCallback)(async(e,t)=>{let n=e;for(let e=0;e<=Pt;e+=1){V(e),b(`verifying`),er(`run`);let r=Z({kind:`info`,name:e?`第 ${e} 次修复后试跑`:`试跑`,detail:`写进 .lantern-ai 草稿并执行,失败保留现场`,status:`running`}),i=await k(X.current);if(z(i),An(null),typeof i.code==`string`&&T(i.code),Ae(e=>e.map(e=>e.id===r?{...e,status:i.passed?`done`:`failed`,detail:i.passed?`通过 · ${Math.round((i.durationMs??0)/100)/10}s`:(i.log??i.error??``).slice(-800)}:e)),nr(),ir(),i.passed)return Z({kind:`info`,name:`试跑通过`,detail:`${Math.round((i.durationMs??0)/100)/10}s · 草稿在 ${i.draftPath??``}`,status:`done`}),L(`试跑通过,可以打开草稿 / trace 调试,确认后写入项目`),je(e=>e&&{...e,status:`verified`}),b(`idle`),!0;if(e===Pt)break;b(`repairing`),n=[...n,{role:`user`,content:[`第 ${e+1} 次试跑失败(exitCode=${i.exitCode??`?`})。日志尾部:`,"```",(i.log??i.error??``).slice(-3500),"```",`请先调用 ui_test_get_steps 看当前步骤,只修改步骤 IR(定位器 / 等待 / 断言),再 ui_test_verify 重跑。`,`如果是页面行为本身不符合需求,不要为了跑绿改断言,直接在回答里说明疑似缺陷。`].join(`
9
- `)}],await ur(n,t)}return L(`自动修复 ${Pt} 轮仍未通过,请看试跑日志 / 打开 trace`),b(`idle`),!1},[er,Z,nr,ir,ur]),hr=(0,C.useCallback)(async()=>{let t=f.trim();if(!t||Q)return;if(!s){I(`还没有配置模型,请先在设置里填好 API Key`),ue(`model`);return}if(!await u())return;r(en,t),a(`ui-auto.baseurl`,p),a(se,h),a(`ui-auto.headed`,_?`1`:`0`);let n=new AbortController;Rn.current=n,I(``),L(``),T(``),z(null),ht(``),V(0),He([]),ot([]),Fn(null),An(null),Pn(``),vt(e=>e.trim()?`${e.trimEnd()}\n\n---\n\n`:e),$n(`activity`),b(`exploring`);let i=``;try{let r=await dr(!0);i=r.session.id,Z({kind:`info`,name:`探索开始`,detail:`${_?`有头`:`无头`}浏览器 · ${e.name}`,status:`done`});let a=S;if(a.length||(Z({kind:`info`,name:`先规划步骤`,detail:`还没有计划,先做一次测试设计`,status:`done`}),a=await fr(t,n.signal)),!a.length){L(`没有得到步骤计划,请补充需求后重试`),b(`idle`);return}await O({sessionId:r.session.id,plan:a});let o=await l(),s=[{role:`system`,content:ut(e,d,a,o.agent,o.code)},{role:`user`,content:pt(t,p,d,a)}];await ur(s,n.signal);let c=await A(r.session.id);if(c.code&&(T(c.code),D(c.suggestedPath)),Me(e=>ln(e,c.session.plan??[])),!(c.session.ir?.steps?.length??0)){Z({kind:`error`,name:`没有提交步骤`,detail:`探索结束了,但这轮没有可用的步骤 IR,代码与试跑保持为空`,status:`failed`}),L(`AI 没有提交步骤,请补充需求后重试`),await O({sessionId:r.session.id,status:`draft`}).catch(()=>void 0);return}let u=await rr(c.session.ir,d,c.suggestedPath);Z({kind:`info`,name:`生成代码`,detail:u.length?`按步骤出了 ${u.length} 个文件(用例 / 页面对象 / 登录态)`:`步骤已就绪,代码页可点「重新出码」`,status:`done`}),await O({sessionId:r.session.id,status:`explored`}).catch(()=>void 0),je({...c.session,status:`explored`}),q(c.draft??null),Tn(c.changes??[]),L(`探索完成,可以点「生成代码」出码;出码后会进入代码页`)}catch(e){if(n.signal.aborted)L(`已停止`);else if(e instanceof Error&&e.message===`浏览器已被关闭,这一轮探索已结束`)L(`浏览器已关闭,这一轮探索结束;重新点「开始探索」会新开一个浏览器`),Z({kind:`error`,name:`浏览器已关闭`,detail:`窗口被关闭,AI 停止操作;已提交的步骤与计划保留`,status:`failed`});else{let t=e instanceof Error?e.message:String(e);I(t),o?.(t),Z({kind:`error`,name:`生成中断`,detail:t,status:`failed`})}i&&await O({sessionId:i,status:`draft`}).catch(()=>void 0)}finally{Hn.current?.release(),Hn.current=null,Kn(!1),Rn.current=null,b(`idle`),nr()}},[p,Q,dr,$n,_,l,o,S,fr,e,Z,nr,rr,u,f,ur,s,h,d]),gr=(0,C.useCallback)(()=>{Hn.current?.release(),Hn.current=null,Kn(!1),Rn.current?.abort(),X.current&&(Je(X.current).catch(()=>void 0),Ue(X.current).catch(()=>void 0))},[]),_r=(0,C.useCallback)(()=>{if(Hn.current){Hn.current.release(),Hn.current=null,Kn(!1),Z({kind:`info`,name:`继续探索`,detail:`已手动完成登录 / 验证码`,status:`done`});return}let e=()=>{},t=new Promise(t=>{e=t});Hn.current={promise:t,release:e},Kn(!0),Z({kind:`info`,name:`暂停`,detail:`请在打开的浏览器窗口里完成登录,完成后点「我已登录,继续」`,status:`running`})},[Z]),vr=(0,C.useRef)(S.length);(0,C.useEffect)(()=>{vr.current=S.length},[S.length]);let yr=(0,C.useCallback)(e=>{if(Me(e),!X.current)return;let t=e.length!==vr.current;vr.current=e.length,t&&Fe(`ui-auto`);let n=()=>{let t=X.current;t&&(Pe(!0),O({sessionId:t,plan:e,allowEmptyPlan:!0}).catch(()=>void 0).finally(()=>Pe(!1)))};Un.current&&window.clearTimeout(Un.current),t?n():Un.current=window.setTimeout(n,400)},[]),$=(0,C.useMemo)(()=>Ve.length?Ve:Re?[{path:E||(d===`python`?`tests/test_ai_generated.py`:`tests/ai-generated.spec.ts`),content:Re,language:d,role:`spec`}]:[],[Re,Ve,E,d]),br=(0,C.useMemo)(()=>$.find(e=>e.path===j)??$[0]??null,[j,$]),xr=(0,C.useCallback)((e,t)=>{He(n=>n.map(n=>n.path===e?{...n,path:t}:n)),Ze(t)},[]),Sr=(0,C.useCallback)(async()=>{if(X.current&&$.length){I(``),ot([]);try{let e=await Ge({sessionId:X.current,files:$.map(e=>({path:e.path,content:e.content,role:e.role})),force:M});if(!e.ok){I(e.error??`写入失败`),ot((e.conflicts??[]).map(e=>e.path));return}let t=e.savedPaths?.length??e.paths?.length??1,n=e.summary?.merged??0,r=e.summary?.created??0,i=e.summary?.unchanged??0,a=[r?`新建 ${r}`:``,n?`合并 ${n}`:``,i?`无变化 ${i}`:``].filter(Boolean).join(`、`);L(`已写入 ${t} 个文件${a?`(${a})`:``}${e.path?`,主用例 ${e.path}`:``},可以按项目配置验收`),je(t=>t&&{...t,status:`written`,savedPath:e.path,savedPaths:e.savedPaths}),et(!1),await nr(),$n(`changes`)}catch(e){I(e instanceof Error?e.message:String(e))}}},[M,$n,nr,$]),Cr=(0,C.useCallback)(async()=>{if(X.current&&!In){Ln(!0),I(``),Fn(null);try{let e=await Qe(X.current,x?.savedPath||$.find(e=>e.role===`spec`)?.path||E);Fn(e),Z({kind:`info`,name:`按项目配置验收`,detail:e.ok?e.passed?`通过`:e.excluded?`被 testMatch 排除,没跑起来`:`失败(exit ${e.exitCode??`?`})`:e.error??`失败`,status:e.ok&&e.passed?`done`:`failed`})}catch(e){I(e instanceof Error?e.message:String(e))}finally{Ln(!1)}}},[In,Z,x?.savedPath,E,$]),wr=(0,C.useCallback)(async()=>{if(!X.current||y!==`idle`)return;if(!x?.ir?.steps?.length){I(`还没有步骤,先「开始探索」把流程跑一遍`);return}let t=new AbortController;Rn.current=t,I(``);try{if(!s){b(`verifying`),er(`run`);let e=Z({kind:`info`,name:`试跑`,detail:`在 .lantern-ai 草稿里执行(未配置模型,不做自动修复)`,status:`running`}),t=await k(X.current);z(t),An(null),typeof t.code==`string`&&T(t.code),Ae(n=>n.map(n=>n.id===e?{...n,status:t.passed?`done`:`failed`,detail:t.passed?`通过 · ${Math.round((t.durationMs??0)/100)/10}s`:(t.log??t.error??``).slice(-800)}:n)),L(t.passed?`试跑通过`:`试跑失败,草稿与 trace 已保留`),await nr(),await ir();return}let n=await l(),r=[{role:`system`,content:ut(e,d,S,n.agent,n.code)},{role:`user`,content:pt(f.trim()||x?.source||``,p,d,S)}];await mr(r,t.signal)}catch(e){t.signal.aborted?L(`已停止`):I(e instanceof Error?e.message:String(e))}finally{Rn.current=null,b(`idle`);let e=X.current;e&&A(e).then(e=>je(e.session)).catch(()=>void 0)}},[p,er,l,y,S,e,Z,nr,ir,f,mr,x?.ir?.steps?.length,x?.source,s,d]),Tr=(0,C.useCallback)(async e=>{if(X.current&&!jn){Mn(!0),I(``);try{let t=await qe(X.current,e);An(t),t.url&&Pn(t.url),t.ok?e===`headed`&&typeof t.tracePath==`string`&&t.tracePath&&q(e=>e&&{...e,tracePath:t.tracePath??``}):I(t.error??`调试启动失败`),Z({kind:`info`,name:e===`ui`?`Playwright UI`:`调试运行`,detail:t.ok?t.url||`exit ${t.exitCode??`?`} · ${t.tracePath||`无 trace`}`:t.error??`失败`,status:t.ok&&t.passed!==!1?`done`:`failed`})}catch(e){I(e instanceof Error?e.message:String(e))}finally{Mn(!1)}}},[jn,Z]),Er=(0,C.useCallback)(async()=>{X.current&&(await Je(X.current).catch(()=>void 0),Pn(``),An(null))},[]),Dr=(0,C.useCallback)(async()=>{if(Q||!X.current)return;I(``);let e=await ir();$n(`code`),L(e.length?`已生成 ${e.length} 个文件,确认后到「试跑」里执行`:`当前没有可出码的步骤,先「开始探索」把流程跑一遍`)},[Q,$n,ir]),Or=(0,C.useCallback)(async e=>{if(X.current)try{await Xe({sessionId:X.current,path:e})}catch(e){I(e instanceof Error?e.message:String(e))}},[]),kr=(0,C.useCallback)(async()=>{if(X.current){Mn(!0);try{let e=await $e(X.current);q(e.draft),An(null),z(null),Pn(``),L(`草稿已清理`)}catch(e){I(e instanceof Error?e.message:String(e))}finally{Mn(!1)}}},[]),Ar=(0,C.useCallback)(async e=>{if(te(e),a(Kt,e),X.current)try{let t=await O({sessionId:X.current,target:e});T(t.code),D(t.suggestedPath),await rr(x?.ir??null,e,t.suggestedPath)}catch(e){I(e instanceof Error?e.message:String(e))}},[rr,x?.ir]),jr=(0,C.useCallback)(()=>{let e=br?.content??Re;e&&navigator.clipboard.writeText(e).then(()=>L(`已复制当前文件`)).catch(()=>I(`复制失败,请手动选中`))},[br?.content,Re]),Mr=(0,C.useMemo)(()=>Gn?`已暂停:请在浏览器窗口里完成登录,然后点「我已登录,继续」`:y===`planning`?`AI 正在拆解步骤计划…`:y===`exploring`?`AI 正在操作浏览器…`:y===`verifying`?`正在草稿里试跑生成的脚本…`:y===`repairing`?`试跑失败,正在修复(第 ${B} 轮)…`:``,[Gn,y,B]),Nr=y===`planning`,Pr=Ie,Fr=x?x.status===`verified`?`试跑通过`:x.status===`written`?`已写入项目`:x.status===`explored`?`已探索`:x.status===`failed`?`试跑失败`:`草稿`:``,Ir=J?.tracePath||K?.tracePath||R?.tracePath||``,Lr=J?.draftPath||R?.draftPath||``,Rr=!!(K?.hasSteps||(x?.ir?.steps?.length??0));return(0,P.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden bg-stone-50/40`,"aria-busy":De?`true`:void 0,children:[(0,P.jsxs)(`aside`,{className:`flex min-h-0 min-w-0 shrink-0 flex-col gap-2 overflow-hidden bg-white px-2.5 py-2`,style:{width:st},children:[(0,P.jsxs)(`div`,{className:`flex min-h-[104px] shrink flex-col`,children:[(0,P.jsx)(`div`,{className:`mb-1 flex items-center`,children:(0,P.jsx)(`label`,{htmlFor:`ui-gen-req`,className:`text-xs font-medium text-stone-600`,children:`需求 / 步骤`})}),(0,P.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden rounded-lg border border-stone-200 bg-white transition-colors focus-within:border-[#3370ff] ${be?``:`transition-[height] duration-150`}`,style:{flexBasis:_e},children:(0,P.jsx)(`textarea`,{id:`ui-gen-req`,className:`block h-full w-full resize-none bg-transparent px-2.5 py-2 text-xs leading-relaxed text-stone-700 outline-none`,value:f,onChange:e=>ne(e.target.value),placeholder:`例:登录后进入商品列表,把第一个商品加入购物车,断言购物车出现该商品`,spellCheck:!1})}),(0,P.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":`调整需求框高度`,title:`拖动调整高度,双击恢复默认`,className:`group mt-1 flex h-2 cursor-row-resize touch-none items-center justify-center`,onPointerDown:e=>{Se.current={startY:e.clientY,startHeight:_e},xe(!0),e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{let t=Se.current;if(!t)return;let n=Math.max(qt,Math.min(Jt,Math.round(window.innerHeight*.45)));ye(Math.min(n,Math.max(qt,t.startHeight+(e.clientY-t.startY))))},onPointerUp:e=>{Se.current&&(Se.current=null,xe(!1),e.currentTarget.releasePointerCapture(e.pointerId))},onDoubleClick:()=>ye(Yt),onPointerCancel:()=>{Se.current=null,xe(!1)},children:(0,P.jsx)(`span`,{className:`h-[3px] w-8 rounded-full transition-colors ${be?`bg-[#4176e6]/70`:`bg-stone-200 group-hover:bg-[#4176e6]/50`}`})})]}),(0,P.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-2`,children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`span`,{className:`mb-1 block text-[11px] text-stone-500`,children:`目标语言`}),(0,P.jsx)(ie,{options:ee.options,value:d,onChange:e=>void Ar(e),compact:!0,ariaLabel:`目标语言`,className:`w-full`})]}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`span`,{className:`mb-1 block text-[11px] text-stone-500`,children:`浏览器`}),(0,P.jsx)(ie,{options:an,value:_?`1`:`0`,onChange:e=>ge(e===`1`),compact:!0,ariaLabel:`浏览器`,className:`w-full`})]})]}),(0,P.jsxs)(`details`,{className:`shrink-0 rounded-lg border border-stone-200 px-2 py-1.5`,open:Ce,onToggle:e=>we(e.currentTarget.open),children:[(0,P.jsx)(`summary`,{className:`cursor-pointer list-none text-[11px] text-stone-500`,children:`地址与登录态`}),(0,P.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,P.jsx)(`input`,{id:`ui-gen-base`,className:`${Nt} font-mono`,value:p,onChange:e=>m(e.target.value),placeholder:`http://localhost:5173`,spellCheck:!1,"aria-label":`起始地址`}),ae?(0,P.jsxs)(`p`,{className:`text-[10px] leading-4 text-stone-400`,children:[`项目配置里读到:`,(0,P.jsx)(`button`,{type:`button`,className:`ml-1 font-mono text-[#3370ff] hover:underline`,onClick:()=>m(ae),disabled:p===ae,children:ae})]}):null,(0,P.jsx)(`input`,{id:`ui-gen-storage`,className:`${Nt} font-mono`,value:h,onChange:e=>g(e.target.value),placeholder:`登录态文件,留空自动检测;填 - 不用`,spellCheck:!1,"aria-label":`登录态文件`}),le?(0,P.jsxs)(`p`,{className:`text-[10px] leading-4 text-stone-400`,children:[`项目里找到:`,(0,P.jsx)(`button`,{type:`button`,className:`ml-1 font-mono text-[#3370ff] hover:underline`,onClick:()=>g(le),disabled:h===le,children:le})]}):h===`-`?(0,P.jsx)(`p`,{className:`text-[10px] leading-4 text-stone-400`,children:`按未登录身份跑,不加载 cookie`}):h?(0,P.jsx)(`p`,{className:`text-[10px] leading-4 text-stone-400`,children:`项目里没找到这个文件,跑之前会再确认一次;找不到就按未登录身份跑`}):(0,P.jsx)(`p`,{className:`text-[10px] leading-4 text-stone-400`,children:`项目里没找到登录态文件:会以未登录身份打开,探索中可以点「手动登录」`})]})]}),(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,P.jsxs)(`div`,{className:`inline-flex h-8 items-center rounded-lg border border-stone-200 bg-white p-0.5`,children:[(0,P.jsxs)(`button`,{type:`button`,className:Nr?jt:At,onClick:()=>void pr(),disabled:Q||!f.trim(),"aria-busy":Nr||void 0,children:[Nr?(0,P.jsx)(vn,{}):(0,P.jsx)(yn,{name:`steps`}),(0,P.jsx)(`span`,{className:`min-w-[52px] text-center`,children:Nr?`规划中…`:`生成步骤`})]}),(0,P.jsx)(`span`,{className:`mx-0.5 h-4 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,P.jsxs)(`button`,{type:`button`,className:Pr?jt:At,onClick:()=>void Dr(),disabled:cr,"aria-busy":Pr||void 0,children:[Pr?(0,P.jsx)(vn,{}):(0,P.jsx)(yn,{name:`code`}),(0,P.jsx)(`span`,{className:`min-w-[52px] text-center`,children:Pr?`出码中…`:`生成代码`})]})]}),(0,P.jsx)(`div`,{className:`ml-auto flex items-center gap-2`,children:(0,P.jsx)(`button`,{type:`button`,className:`${ar?Ot:G} min-w-[104px] justify-center`,onClick:()=>ar?gr():void hr(),disabled:!ar&&or,"aria-busy":ar||void 0,children:ar?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(vn,{}),`停止`]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(yn,{name:`play`}),`开始探索`]})})})]}),!S.length&&!Q&&!De?(0,P.jsx)(`p`,{className:`shrink-0 text-[11px] leading-relaxed text-stone-400`,children:`先「生成步骤」,确认计划后就能开始探索`}):null,(0,P.jsxs)(`div`,{className:`max-h-[96px] shrink-0 space-y-1 overflow-y-auto`,children:[Mr||Ne||y===`exploring`&&_?(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[Mr?(0,P.jsx)(`p`,{className:`text-[11px] text-[#4176e6]`,children:Mr}):null,Ne?(0,P.jsx)(`p`,{className:`text-[10px] text-stone-400`,children:`保存中…`}):null,y===`exploring`&&_?(0,P.jsx)(`button`,{type:`button`,className:`text-[11px] font-medium text-[#4176e6] underline-offset-2 hover:underline`,onClick:_r,children:Gn?`我已登录,继续`:`手动登录`}):null]}):null,F?(0,P.jsx)(`p`,{className:`rounded-lg bg-red-50 px-3 py-2 text-[11px] leading-relaxed break-words text-red-600`,children:F}):null,yt?(0,P.jsx)(`p`,{className:`rounded-lg bg-emerald-50 px-3 py-2 text-[11px] leading-relaxed break-words text-emerald-700`,children:yt}):null]}),(0,P.jsx)(`div`,{className:`flex min-h-[150px] min-w-0 flex-1 flex-col`,children:De?(0,P.jsx)(_n,{}):(0,P.jsx)(Tt,{plan:S,disabled:Q,onChange:yr})})]}),(0,P.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`调整左栏宽度`,className:`w-1 shrink-0 cursor-col-resize touch-none bg-stone-200/70 transition-colors hover:bg-[#4176e6]/40`,onPointerDown:e=>{lt.current={startX:e.clientX,startWidth:st},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{let t=lt.current;t&&ct(Math.min(Ht,Math.max(Vt,t.startWidth+(e.clientX-t.startX))))},onPointerUp:e=>{lt.current&&(lt.current=null,e.currentTarget.releasePointerCapture(e.pointerId),a(Bt,String(st)))},onPointerCancel:()=>{lt.current=null}}),(0,P.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,P.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-white`,children:[(0,P.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-1 border-b border-stone-100 px-3`,children:[Zt.map(e=>(0,P.jsx)(`button`,{type:`button`,className:`rounded px-2 py-0.5 text-[11px] transition-colors ${U===e.value?`bg-[#f2f6ff] text-[#3370ff]`:`text-stone-500 hover:bg-stone-50`}`,onClick:()=>$n(e.value),children:e.value===`changes`&&wn.length?`${e.label} ${wn.length}`:e.label},e.value)),(0,P.jsxs)(`div`,{className:`ml-auto flex min-w-0 shrink items-center gap-2`,children:[U===`activity`&&ke.length?(0,P.jsx)(`button`,{type:`button`,className:`shrink-0 text-[10px] text-stone-400 transition-colors hover:text-red-500`,onClick:()=>{Ae([]),X.current&&O({sessionId:X.current,activity:[],replaceActivity:!0}).catch(()=>void 0)},children:`清除活动日志`}):null,x?(0,P.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 text-[10px] text-stone-400`,children:[(0,P.jsx)(`span`,{className:`shrink-0`,children:`会话`}),(0,P.jsx)(`span`,{className:`truncate font-mono`,children:x.id})]}):null]})]}),(0,P.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[U===`activity`?(0,P.jsx)(`div`,{ref:Vn,className:`min-h-0 flex-1 overflow-auto px-3 py-2`,children:De?(0,P.jsx)(gn,{rows:4}):(0,P.jsxs)(P.Fragment,{children:[ke.length===0?(0,P.jsx)(`p`,{className:`py-6 text-center text-xs leading-relaxed text-stone-400`,children:`生成时这里会显示每一步操作与探测结果`}):(0,P.jsx)(`ul`,{className:`space-y-1.5`,children:ke.map(e=>(0,P.jsx)(`li`,{className:`text-[11px] leading-relaxed`,children:(0,P.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,P.jsx)(`span`,{className:`mt-1 h-1.5 w-1.5 shrink-0 rounded-full ${e.status===`running`?`animate-pulse bg-[#4176e6]`:e.status===`failed`?`bg-red-500`:`bg-emerald-500`}`}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`span`,{className:`font-mono text-stone-700`,children:e.name}),e.detail?(0,P.jsx)(`pre`,{className:`mt-0.5 max-h-24 overflow-hidden whitespace-pre-wrap break-all text-[11px] text-stone-400`,children:e.detail}):null]})]})},e.id))}),gt?(0,P.jsx)(`div`,{className:`chat-md prose prose-sm prose-stone mt-3 max-w-none border-t border-stone-100 pt-2 text-stone-600`,style:{fontSize:11,lineHeight:1.7},onClick:e=>{let t=e.target;if(!t.closest(`[data-copy-code]`))return;let n=t.closest(`.code-block`)?.querySelector(`code`);n&&navigator.clipboard?.writeText(n.textContent??``).then(()=>ce(`已复制`,`success`),()=>ce(`复制失败`,`error`))},dangerouslySetInnerHTML:{__html:he(gt)}}):null]})}):null,U===`code`?De?(0,P.jsx)(gn,{rows:5}):$.length?(0,P.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,P.jsxs)(`div`,{className:`flex w-56 shrink-0 flex-col border-r border-stone-100`,children:[(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-stone-100 px-2.5 py-1.5`,children:[(0,P.jsxs)(`span`,{className:`text-[11px] font-medium text-stone-600`,children:[`待写入 `,$.length,` 个文件`]}),(0,P.jsx)(`button`,{type:`button`,className:`ml-auto rounded px-1 text-[11px] text-stone-400 hover:bg-stone-50 hover:text-stone-600`,onClick:()=>void ir(),disabled:!x?.ir||Ie,children:Ie?`出码中…`:`重新出码`})]}),(0,P.jsx)(`ul`,{className:`min-h-0 flex-1 overflow-auto p-1`,children:$.map(e=>{let t=br?.path===e.path;return(0,P.jsx)(`li`,{children:(0,P.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-1.5 rounded-md px-1.5 py-1 text-left transition-colors ${t?`bg-[#f2f6ff]`:`hover:bg-stone-50`}`,onClick:()=>Ze(e.path),children:[(0,P.jsx)(`span`,{className:`mt-0.5 shrink-0 rounded px-1 py-px text-[10px] leading-4 ${mn(e.role).className}`,children:mn(e.role).label}),(0,P.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-stone-700`,children:fn(e.path)}),(0,P.jsx)(`span`,{className:`block truncate font-mono text-[10px] leading-4 text-stone-400`,children:pn(e.path)})]})]})},e.path)})}),(0,P.jsxs)(`div`,{className:`shrink-0 space-y-1.5 border-t border-stone-100 px-2.5 py-2`,children:[(0,P.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[11px] text-stone-500`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:M,onChange:e=>et(e.target.checked)}),`整文件覆盖(默认与已有文件合并)`]}),(0,P.jsxs)(`button`,{type:`button`,className:`${G} w-full justify-center`,onClick:()=>void Sr(),disabled:Q||!$.length,children:[`写入 `,$.length,` 个文件`]})]})]}),(0,P.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-stone-100 px-3 py-1.5`,children:[(0,P.jsx)(`span`,{className:`shrink-0 rounded bg-stone-100 px-1.5 py-0.5 text-[10px] text-stone-500`,children:d===`python`?`pytest`:`Playwright Test`}),(0,P.jsx)(`input`,{className:`${Nt} min-w-[180px] flex-1 font-mono`,value:br?.path??``,onChange:e=>{br&&xr(br.path,e.target.value)},placeholder:E||`tests/xxx.spec.ts`,spellCheck:!1,"aria-label":`写入路径`}),(0,P.jsx)(`button`,{type:`button`,className:Dt,onClick:jr,children:`复制`}),(0,P.jsx)(_t,{compact:!0,disabled:!br||!x?.savedPaths?.length,onOpen:e=>{br&&Xe({sessionId:X.current,path:br.path,app:e?.id}).catch(e=>I(e instanceof Error?e.message:String(e)))}})]}),N.length?(0,P.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-amber-100 bg-amber-50 px-3 py-1.5 text-[11px] text-amber-700`,children:[(0,P.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[`这些文件已存在:`,N.join(`、`)]}),(0,P.jsx)(`button`,{type:`button`,className:`shrink-0 rounded border border-amber-300 px-1.5 py-0.5 text-amber-800 hover:bg-amber-100`,onClick:()=>{et(!0),ot([])},children:`勾选覆盖`})]}):null,(0,P.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre px-3 py-2 font-mono text-[11px] leading-relaxed text-stone-700`,children:br?.content||`生成后这里显示要写入的文件`})]})]}):(0,P.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs leading-relaxed text-stone-400`,children:`生成步骤并试跑后,这里会列出要写入项目的 spec、页面对象与登录态文件`}):null,U===`changes`?De?(0,P.jsx)(gn,{rows:4}):(0,P.jsx)(xt,{changes:wn,git:En,draft:K,loading:On,onReveal:e=>void Or(e),onRefresh:()=>void nr()}):null]}),mt&&U===`activity`?(0,P.jsx)(`div`,{className:`shrink-0 border-t border-stone-100 p-2`,children:(0,P.jsx)(`img`,{src:mt,alt:`最近一步截图`,className:`max-h-52 w-full rounded-md border border-stone-100 object-contain`})}):null]}),(0,P.jsxs)(`section`,{className:`relative flex shrink-0 flex-col overflow-hidden border-t border-stone-200 bg-white ${kt?``:`transition-[height] duration-200 ease-out`}`,style:{height:wt?Rt:W},children:[wt?null:(0,P.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":`调整底部面板高度`,className:`h-1 shrink-0 cursor-row-resize touch-none bg-stone-100 transition-colors hover:bg-[#4176e6]/40`,onPointerDown:e=>{hn.current={startY:e.clientY,startHeight:W},sn(!0),e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{let t=hn.current;if(!t)return;let n=Math.max(It,Math.round(window.innerHeight*.65));Ct(Math.min(n,Math.max(Rt,t.startHeight+(t.startY-e.clientY))))},onPointerUp:e=>{let t=hn.current;if(!t)return;hn.current=null,sn(!1),e.currentTarget.releasePointerCapture(e.pointerId);let n=Math.max(It,Math.round(window.innerHeight*.65)),r=Math.min(n,Math.max(Rt,t.startHeight+(t.startY-e.clientY)));r<=zt?(Ct(Math.max(It,t.startHeight)),Et(!0),a(Ft,`closed`)):(Ct(r),a(Ft,String(r)))},onPointerCancel:()=>{hn.current=null,sn(!1)}}),(0,P.jsxs)(`div`,{className:`relative flex h-9 shrink-0 items-center gap-1 border-b border-stone-100 px-2`,children:[Qt.map(e=>(0,P.jsx)(`button`,{type:`button`,className:`rounded px-2 py-0.5 text-[11px] transition-colors ${H===e.value?`bg-[#f2f6ff] text-[#3370ff]`:`text-stone-500 hover:bg-stone-50`}`,onClick:()=>er(e.value),children:e.label},e.value)),(0,P.jsx)(`span`,{className:`ml-2 min-w-0 truncate text-[10px] text-stone-400`,children:Fr}),(0,P.jsx)(`button`,{type:`button`,"aria-label":wt?`展开底部面板`:`收起底部面板`,"aria-expanded":!wt,className:`group absolute left-1/2 top-1/2 flex h-6 w-20 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 focus-visible:ring-2 focus-visible:ring-[#4176e6]/30 focus-visible:outline-none`,onClick:tr,children:(0,P.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4 transition-transform duration-200 ${wt?`rotate-180`:``}`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,P.jsx)(`path`,{d:`m6 9 6 6 6-6`})})})]}),wt?null:(0,P.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[H===`console`?(0,P.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-3 py-2`,children:bn.length?(0,P.jsx)(`ul`,{className:`space-y-1 font-mono text-[11px]`,children:bn.slice(-80).map((e,t)=>(0,P.jsxs)(`li`,{className:e.type===`error`?`text-red-600`:`text-stone-600`,children:[(0,P.jsxs)(`span`,{className:`mr-1 text-stone-400`,children:[`[`,e.type,`]`]}),e.text]},t))}):(0,P.jsx)(`p`,{className:`py-6 text-center text-xs text-stone-400`,children:`暂无控制台错误 / 警告`})}):null,H===`network`?(0,P.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-3 py-2`,children:Sn.length?(0,P.jsx)(`ul`,{className:`space-y-1 font-mono text-[11px]`,children:Sn.slice(-80).map((e,t)=>(0,P.jsxs)(`li`,{className:`text-stone-600`,children:[(0,P.jsx)(`span`,{className:`mr-1 text-red-500`,children:e.status}),(0,P.jsx)(`span`,{className:`mr-1 text-stone-400`,children:e.method}),(0,P.jsx)(`span`,{className:`break-all`,children:e.url})]},t))}):(0,P.jsx)(`p`,{className:`py-6 text-center text-xs text-stone-400`,children:`暂无失败请求`})}):null,H===`run`?(0,P.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,P.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b border-stone-100 px-3 py-1.5`,children:[(0,P.jsx)(`span`,{className:`text-[11px] text-stone-500`,children:`最近一次试跑`}),(0,P.jsx)(`span`,{className:`text-[11px] font-medium ${R?R.passed?`text-emerald-600`:`text-red-600`:`text-stone-400`}`,children:R?R.passed?`通过`:`失败(exit ${R.exitCode??`?`})`:`未试跑`}),(0,P.jsxs)(`span`,{className:`text-[11px] tabular-nums text-stone-400`,children:[`耗时 `,Math.round((R?.durationMs??0)/100)/10,`s`,R?.timedOut?` · 超时`:``]}),(0,P.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`button`,{type:`button`,className:G,onClick:()=>void wr(),disabled:Q||!Rr,children:y===`verifying`?`试跑中…`:R?`重新试跑`:`试跑`}),(0,P.jsx)(`button`,{type:`button`,className:Dt,onClick:()=>void Tr(`headed`),disabled:jn||!Rr,children:`调试运行`}),(0,P.jsx)(`button`,{type:`button`,className:Dt,onClick:()=>void Tr(`ui`),disabled:jn||!Rr||d===`python`,children:`Playwright UI`}),Nn?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`a`,{className:Mt,href:Nn,target:`_blank`,rel:`noreferrer`,children:[`打开 `,Nn]}),(0,P.jsx)(`button`,{type:`button`,className:Mt,onClick:()=>void Er(),children:`结束 UI`})]}):null]})]}),(0,P.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,P.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-all bg-stone-50/40 px-3 py-2 font-mono text-[11px] leading-relaxed text-stone-700`,children:R?.log||(R?`试跑没有输出`:`试跑后这里显示日志;失败时草稿与 trace 会保留,方便回看现场。`)}),(0,P.jsxs)(`div`,{className:`w-64 shrink-0 space-y-2 overflow-auto border-l border-stone-100 p-2`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-[11px] text-stone-500`,children:`草稿工作区`}),(0,P.jsx)(`p`,{className:`mt-1 break-all font-mono text-[10px] leading-4 text-stone-500`,children:K?.draftRoot||`还没有草稿,试跑后生成`}),(0,P.jsx)(`p`,{className:`break-all font-mono text-[10px] leading-4 text-stone-400`,children:Lr?`用例:${Lr}`:``}),(0,P.jsx)(`p`,{className:`break-all font-mono text-[10px] leading-4 text-stone-400`,children:Ir?`trace:${Ir}`:``}),(0,P.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,P.jsx)(`button`,{type:`button`,className:Mt,onClick:()=>void Or(Lr||K?.draftDir||``),disabled:!Lr&&!K?.draftDir,children:`打开草稿`}),(0,P.jsx)(`button`,{type:`button`,className:Mt,onClick:()=>void Or(K?.draftRoot??``),disabled:!K?.exists,children:`打开目录`}),(0,P.jsx)(`button`,{type:`button`,className:Mt,onClick:()=>void Or(Ir),disabled:!Ir,children:`打开 trace`}),(0,P.jsx)(`button`,{type:`button`,className:`${Mt} text-stone-400`,onClick:()=>void kr(),disabled:jn||!K?.exists,children:`清理草稿`})]})]}),(0,P.jsxs)(`details`,{className:`rounded-lg border border-stone-200 px-2 py-1.5`,open:Te,onToggle:e=>Ee(e.currentTarget.open),children:[(0,P.jsx)(`summary`,{className:`cursor-pointer list-none text-[11px] text-stone-500`,children:`写入后验收`}),(0,P.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between gap-2`,children:[(0,P.jsx)(`p`,{className:`text-[10px] leading-4 text-stone-400`,children:`用项目自己的配置跑正式文件`}),(0,P.jsx)(`button`,{type:`button`,className:Dt,onClick:()=>void Cr(),disabled:In||!(x?.savedPath||$.find(e=>e.role===`spec`)?.path),children:In?`验收中…`:`开始验收`})]}),Y?(0,P.jsxs)(`div`,{className:`mt-1.5`,children:[(0,P.jsx)(`p`,{className:`text-[11px] font-medium ${Y.passed?`text-emerald-600`:`text-red-600`}`,children:Y.ok?Y.passed?`验收通过`:Y.excluded?`没被项目配置识别为用例`:`失败(exit ${Y.exitCode??`?`})`:Y.error??`失败`}),Y.note?(0,P.jsx)(`p`,{className:`mt-0.5 text-[11px] leading-4 text-amber-600`,children:Y.note}):null,Y.log?(0,P.jsx)(`pre`,{className:`mt-1 max-h-40 overflow-auto whitespace-pre-wrap rounded bg-stone-50 p-2 font-mono text-[10px] leading-4 text-stone-600`,children:Y.log}):null]}):null]}),J?(0,P.jsxs)(`div`,{className:`rounded-lg border border-stone-200 px-2 py-1.5`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,P.jsx)(`span`,{className:`text-[11px] text-stone-500`,children:J.mode===`ui`?`Playwright UI`:`调试运行`}),(0,P.jsx)(`span`,{className:`text-[11px] ${J.ok&&J.passed!==!1?`text-emerald-600`:`text-red-600`}`,children:J.ok?J.mode===`ui`?J.ready?`已启动`:`启动较慢`:J.passed?`通过`:`失败(exit ${J.exitCode??`?`})`:J.error??`失败`})]}),J.url?(0,P.jsx)(`p`,{className:`mt-1 break-all font-mono text-[10px] text-stone-500`,children:J.url}):null,J.log?(0,P.jsx)(`pre`,{className:`mt-1 max-h-40 overflow-auto whitespace-pre-wrap rounded bg-stone-50 p-2 font-mono text-[10px] leading-4 text-stone-600`,children:J.log}):null]}):null]})]})]}):null]})]})]})]})}function gn({rows:e=3}){return(0,P.jsx)(`div`,{className:`space-y-2 p-3`,"aria-hidden":`true`,children:Array.from({length:e}).map((e,t)=>(0,P.jsx)(`div`,{className:`h-3 animate-pulse rounded bg-stone-100`,style:{width:`${Math.max(40,92-t*14)}%`}},t))})}function _n(){return(0,P.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-1.5`,"aria-hidden":`true`,children:[0,1,2].map(e=>(0,P.jsx)(`div`,{className:`h-16 animate-pulse rounded-lg bg-stone-50`},e))})}function vn(){return(0,P.jsxs)(`svg`,{className:`h-3.5 w-3.5 shrink-0 animate-spin`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:[(0,P.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,stroke:`currentColor`,strokeWidth:`2`,opacity:`0.25`}),(0,P.jsx)(`path`,{d:`M14 8a6 6 0 0 0-6-6`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`})]})}function yn({name:e}){let t={width:14,height:14,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.7,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`};return e===`play`?(0,P.jsx)(`svg`,{...t,fill:`currentColor`,stroke:`none`,children:(0,P.jsx)(`path`,{d:`M8 5.5v13l11-6.5Z`})}):e===`code`?(0,P.jsxs)(`svg`,{...t,children:[(0,P.jsx)(`path`,{d:`m9 8-4 4 4 4`}),(0,P.jsx)(`path`,{d:`m15 8 4 4-4 4`})]}):(0,P.jsxs)(`svg`,{...t,children:[(0,P.jsx)(`path`,{d:`M4 7h10`}),(0,P.jsx)(`path`,{d:`M4 12h7`}),(0,P.jsx)(`path`,{d:`M4 17h10`}),(0,P.jsx)(`path`,{d:`M17 12h3`}),(0,P.jsx)(`path`,{d:`m18 10 2 2-2 2`})]})}function bn(e){if(e.kind===`full`)return`全量运行`;let t=e.display?.trim()??``;return!t||t===e.command?e.label||e.command:`${t}(${e.command})`}var xn=[{value:`run`,label:`运行`},{value:`generate`,label:`生成`},{value:`history`,label:`历史`}],Sn=`ui-auto.project`,Cn=`ui-auto.tab`,wn=`ui-auto.task`,Tn=e=>`ui-auto.log-scroll.${e}`,En=e=>`${wn}.${e}`,Dn=1e3,K=`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`,q=`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`,On=`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`;function kn(){let{ready:e,on:t}=m(`uiAuto`),[n,s]=(0,C.useState)([]),[c,l]=(0,C.useState)([]),[u,ne]=(0,C.useState)(()=>i(Sn)),[ue,de]=(0,C.useState)(!0),[fe,pe]=(0,C.useState)(!0),[he,v]=(0,C.useState)(``),[y,Fe]=(0,C.useState)(()=>i(Cn)===`history`?`history`:i(Cn)===`generate`?`generate`:`run`),[Ie,w]=(0,C.useState)(()=>i(wn)||`full`),[Le,Re]=(0,C.useState)(!1),[T,E]=(0,C.useState)(``),[D,ze]=(0,C.useState)([]),[Be,Ve]=(0,C.useState)(!1),[He,Ue]=(0,C.useState)(!1),[O,We]=(0,C.useState)([]),[k,Ge]=(0,C.useState)(null),[Ke,A]=(0,C.useState)(``),[qe,Je]=(0,C.useState)(!1),[Ye,j]=(0,C.useState)(!1),Ze=(0,C.useRef)(0),Qe=(0,C.useRef)(null),$e=(0,C.useRef)(!0),M=(0,C.useRef)(null),et=(0,C.useRef)(0),[tt,nt]=(0,C.useState)(!1),[rt,it]=(0,C.useState)(``),[N,at]=(0,C.useState)(null),[ot,st]=(0,C.useState)(``),[ct,lt]=(0,C.useState)(!1),[ut,dt]=(0,C.useState)(null),[ft,pt]=(0,C.useState)(null),[mt,ht]=(0,C.useState)(!1),[gt,vt]=(0,C.useState)(()=>Date.now()),F=(0,C.useMemo)(()=>n.find(e=>e.id===u)??null,[n,u]),I=(0,C.useMemo)(()=>{let e=F?.promptFile??``;return e&&D.some(t=>t.value===e)?e:_e},[F?.promptFile,D]),yt=(0,C.useMemo)(()=>{if(!F||!Be)return!1;let e=(F.promptFile??``).trim();return!e||!D.some(t=>t.value===e)},[F,Be,D]),L=(0,C.useMemo)(()=>n.map(e=>({value:e.id,label:e.name,secondary:e.dir.replace(/^\/Users\/[^/]+/,`~`)})),[n]),R=(0,C.useCallback)(e=>{Fe(e),a(Cn,e)},[]),z=(0,C.useCallback)(async()=>{let e=async t=>{let{entries:n}=await le(`prompts`,t),r=t===`.`?``:`${t}/`,i=n.filter(e=>e.type===`file`&&/\.md$/i.test(e.name)).map(e=>`${r}${e.name}`),a=await Promise.all(n.filter(e=>e.type===`dir`).map(t=>e(`${r}${t.name}`)));return[...i,...a.flat()]},t=(await e(`.`)).filter(e=>{let t=me(e);return!t||t===`uiAuto`}).sort().map(e=>({value:e,label:e}));return ze(t),t},[]);(0,C.useEffect)(()=>{if(!t)return;z().catch(()=>void 0).finally(()=>Ve(!0));let e=()=>{document.visibilityState===`visible`&&z().catch(()=>void 0)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[t,z]);let B=(0,C.useCallback)(async()=>{let e=await Se();return s(e.projects),e.frameworks.length&&l(e.frameworks),e.projects},[]),V=(0,C.useCallback)(async e=>{let t=await je(e);return We(t),t},[]),H=(0,C.useRef)(``);H.current=k?.id??``;let U=(0,C.useCallback)(()=>{let e=Qe.current,t=H.current;if(!e||!t)return;let n=e.scrollHeight-e.scrollTop-e.clientHeight<40;r(Tn(t),{top:e.scrollTop,stick:n})},[]),xt=(0,C.useCallback)(async e=>{U();let t=await De(e,0);Ge(t.run),A(t.log),Je(t.stopping),Ze.current=t.nextOffset;let n=o(Tn(e),null),r=n&&typeof n.top==`number`&&!n.stick?n:null;M.current=r,$e.current=!r},[U]);(0,C.useEffect)(()=>{if(!t)return;let e=!0;return _(!0).catch(()=>void 0),de(!0),B().catch(t=>{e&&v(t instanceof Error?t.message:String(t))}).finally(()=>{e&&de(!1)}),()=>{e=!1}},[t,B]),(0,C.useEffect)(()=>{if(!n.length||n.some(e=>e.id===u))return;let e=n[0].id;ne(e),a(Sn,e)},[n,u]),(0,C.useEffect)(()=>{if(!t||!u){We([]),Ge(null),A(``),t&&pe(!1);return}let e=!0;return We([]),Ge(null),A(``),Je(!1),Ze.current=0,M.current=null,w(i(En(u))||`full`),V(u).then(t=>{if(!e)return;let n=t.find(e=>e.status===`running`)??t[0];n&&xt(n.id).catch(()=>void 0)}).catch(t=>{e&&v(t instanceof Error?t.message:String(t))}).finally(()=>{e&&pe(!1)}),()=>{e=!1}},[t,u,V,xt]);let St=(0,C.useCallback)(async()=>{await B().catch(()=>null),u&&await V(u).catch(()=>null)},[B,V,u]),W=(0,C.useMemo)(()=>F?.runTasks??[],[F?.runTasks]),Ct=(0,C.useMemo)(()=>W.find(e=>e.id===Ie)??W[0]??null,[W,Ie]),wt=(0,C.useMemo)(()=>[...W.length?W.map(e=>({value:e.id,label:bn(e)})):[{value:`full`,label:`全量运行`}]],[W]),Tt=k?.status??``,Et=k?.id??``,G=k?.status===`running`;(0,C.useEffect)(()=>{if(!Et||!G)return;let e=!0,t=async()=>{try{let t=await De(Et,Ze.current);if(!e)return;t.reset?A(t.log):t.log&&A(e=>e+t.log),Ze.current=t.nextOffset,Je(t.stopping),Ge(t.run),Oe(t.run.status)&&St()}catch{}},n=window.setInterval(()=>void t(),Dn);return()=>{e=!1,window.clearInterval(n)}},[Et,G,St]),(0,C.useEffect)(()=>{if(!G)return;let e=window.setInterval(()=>vt(Date.now()),1e3);return()=>window.clearInterval(e)},[G]),(0,C.useEffect)(()=>{if(G)return;let e=window.setInterval(()=>{document.visibilityState===`visible`&&(B().catch(()=>null),u&&V(u).catch(()=>null))},15e3);return()=>window.clearInterval(e)},[G,u,B,V]),(0,C.useEffect)(()=>{let e=Qe.current;if(!e)return;let t=M.current;t?(M.current=null,e.scrollTop=t.top):$e.current&&(e.scrollTop=e.scrollHeight)},[Ke]),(0,C.useEffect)(()=>{let e=()=>U(),t=()=>{document.visibilityState===`hidden`&&U()};return window.addEventListener(`pagehide`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`pagehide`,e),document.removeEventListener(`visibilitychange`,t),window.clearTimeout(et.current)}},[U]);let Dt=()=>{let e=Qe.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<40;$e.current=t,window.clearTimeout(et.current),et.current=window.setTimeout(()=>U(),200)},Ot=(0,C.useCallback)(async(e={})=>{if(u){v(``),j(!0);try{let t=await Ne(u,{taskId:Ct?.id??`full`,...e});Ge(t),A(``),Je(!1),Ze.current=0,M.current=null,$e.current=!0,R(`run`),await V(u).catch(()=>null),await B().catch(()=>null)}catch(e){v(e instanceof Error?e.message:String(e))}finally{j(!1)}}},[u,Ct,V,B,R]),kt=(e=null)=>{v(``),st(``),at(e),it(e?.dir??``),nt(!0)},At=()=>{ct||nt(!1)},jt=(0,C.useCallback)(e=>{F&&Xe({projectId:F.id,path:e.path,app:e.app}).catch(e=>v(e instanceof Error?e.message:String(e)))},[F]),Mt=async()=>{lt(!0),st(``);try{let e=await ye();e&&it(e)}catch(e){st(`${e instanceof Error?e.message:String(e)}(可在下方直接填写目录路径)`)}finally{lt(!1)}},Nt=async e=>{if(F){E(``);try{let t=await ve({id:F.id,customTasks:e.customTasks?.map(({id:e,name:t,command:n})=>({id:e,name:t,command:n})),taskOverrides:e.taskOverrides,hiddenTasks:e.hiddenTasks});s(e=>e.map(e=>e.id===t.id?t:e)),(t.runTasks??[]).some(e=>e.id===Ie)||(w(`full`),a(En(t.id),`full`))}catch(e){E(e instanceof Error?e.message:String(e))}}},Pt=e=>Nt({customTasks:e}),Ft=(0,C.useCallback)(async e=>{if(!F)return;let t=F.id;s(n=>n.map(n=>n.id===t?{...n,promptFile:e}:n));try{let n=await ve({id:t,promptFile:e});s(e=>e.map(e=>e.id===n.id?n:e)),Ue(!1),Te(),ce(e?`已挂载「${e}」`:`已取消挂载`,`success`)}catch(e){throw await B().catch(()=>void 0),e}},[F,B]),It=(0,C.useCallback)(async e=>{await _(!0).catch(()=>void 0);let t=await ge(e,_e);return await z(),t},[z]),Lt=async(e,t,n)=>{if(!F)return;let r=(F.taskOverrides??[]).filter(t=>t.id!==e),i={id:e,name:t.trim(),command:n.trim()};(i.name||i.command)&&r.push(i),await Nt({taskOverrides:r})},Rt=async e=>{F&&await Nt({taskOverrides:(F.taskOverrides??[]).filter(t=>t.id!==e),hiddenTasks:[...new Set([...F.hiddenTasks??[],e])]})},zt=async()=>{await Nt({taskOverrides:[],hiddenTasks:[]})},Bt=async(e,t)=>{if(!F)return;let n=t.trim();n?await Pt([...F.customTasks??[],{id:``,name:e,command:n}]):E(`先填要执行的命令`)},Vt=async e=>{F&&await Pt((F.customTasks??[]).filter(t=>t.id!==e))},Ht=async()=>{let e=rt.trim();if(!e)st(`请先选择或填写项目目录`);else{j(!0),st(``);try{let t;t=N?(await ve({id:N.id,dir:e})).id:(await Ae(e)).id,await B(),ne(t),a(Sn,t),R(`run`),nt(!1),at(null),it(``)}catch(t){let r=t instanceof Error?t.message:String(t),i=n.find(t=>t.dir===e);if(i&&/已经添加/.test(r)){ne(i.id),a(Sn,i.id),R(`run`),nt(!1),it(``);return}st(r)}finally{j(!1)}}},Ut=async()=>{if(k){v(``);try{await xe(k.id),Je(!0)}catch(e){v(e instanceof Error?e.message:String(e))}}},Wt=()=>{Ct?.failureFlags?Ot({lastFailed:!0}):v(`当前运行任务不支持只跑失败用例,切到「全量运行」或 pytest 任务再试`)},Gt=async()=>{if(ft){v(``);try{await Ee(ft.id),k?.id===ft.id&&(Ge(null),A(``)),u&&await V(u),await B().catch(()=>null)}catch(e){v(e instanceof Error?e.message:String(e))}finally{pt(null)}}};if(!e||fe)return(0,P.jsx)(`div`,{className:`tw-hydrate-pending h-full w-full`,children:(0,P.jsx)(se,{label:`加载自动化测试…`})});if(!t)return(0,P.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 / pytest / Selenium 项目。`});let Kt=(0,P.jsxs)(`div`,{className:`border-b border-stone-100 bg-stone-50/60 px-4 py-3`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`text-xs font-medium text-stone-700`,children:N?`重新指定项目目录`:`挂载项目`}),(0,P.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`自动识别 Playwright / pytest / Selenium,只读取与运行,不改项目文件`})]}),(0,P.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`input`,{className:`h-8 min-w-[260px] flex-1 rounded-lg border border-stone-200 bg-white px-2.5 font-mono text-xs text-stone-700 outline-none transition-colors focus:border-[#3370ff]`,value:rt,onChange:e=>it(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Ht()},placeholder:`/path/to/your-test-project`,"aria-label":`项目目录`,spellCheck:!1}),(0,P.jsxs)(`button`,{type:`button`,className:q,onClick:()=>void Mt(),disabled:ct,children:[(0,P.jsx)(g,{name:`folder`,size:13}),ct?`选择中…`:`浏览…`]}),(0,P.jsx)(`button`,{type:`button`,className:K,onClick:()=>void Ht(),disabled:Ye||ct||!rt.trim(),children:Ye?`挂载中…`:N?`保存目录`:`挂载`})]}),ot?(0,P.jsx)(`p`,{className:`mt-2 rounded-lg bg-red-50 px-3 py-2 text-[11px] leading-relaxed text-red-600`,children:ot}):null]}),qt=k?G?Math.max(0,gt-Date.parse(k.startedAt)):k.durationMs:0,Jt=tt||!n.length;return(0,P.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-white`,children:[he?(0,P.jsx)(oe,{message:he,onClose:()=>v(``)}):null,(0,P.jsxs)(`header`,{className:`relative z-20 flex h-12 shrink-0 items-center gap-3 border-b border-stone-200 px-4`,children:[(0,P.jsx)(`h1`,{className:`shrink-0 text-sm font-semibold text-stone-800`,children:`自动化测试`}),(0,P.jsx)(`span`,{className:`h-4 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),F?(0,P.jsx)(`div`,{role:`tablist`,"aria-label":`自动化测试视图`,className:`flex h-full shrink-0 items-stretch`,children:xn.map(e=>{let t=e.value===`history`?O.length:0,n=y===e.value;return(0,P.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n,onClick:()=>R(e.value),className:`relative flex h-full items-center gap-1.5 border-b-2 px-2.5 text-[13px] transition-colors ${n?`border-[#3370ff] font-medium text-stone-900`:`border-transparent text-stone-500 hover:text-stone-800`}`,children:[e.label,t?(0,P.jsx)(`span`,{className:`rounded-full px-1.5 text-[11px] leading-4 tabular-nums ${n?`bg-[#eaf1ff] text-[#3370ff]`:`bg-stone-100 text-stone-400`}`,children:t}):null]},e.value)})}):(0,P.jsx)(`span`,{className:`truncate text-[11px] text-stone-400`,children:ue?`正在读取挂载列表…`:`还没有挂载项目`}),(0,P.jsxs)(`div`,{className:`ml-auto flex min-w-0 shrink-0 items-center gap-2`,children:[F?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{type:`button`,className:`flex h-8 w-40 min-w-0 items-center rounded-lg border bg-white px-2.5 text-left transition-colors hover:border-stone-300 focus:border-[#4176e6] focus:outline-none focus-visible:ring-2 focus-visible:ring-[#4176e6]/30 ${yt?`border-amber-300 text-amber-700`:`border-stone-200`}`,onClick:()=>Ue(!0),"aria-label":`挂载提示词`,children:(0,P.jsx)(p,{text:yt?`未挂载提示词 · 点击挂载`:I,className:`min-w-0 flex-1 truncate text-sm ${yt?`text-amber-700`:`text-stone-700`}`})}),(0,P.jsx)(ie,{options:L,value:F.id,onChange:e=>{ne(e),a(Sn,e)},compact:!0,className:`w-48`,ariaLabel:`切换项目`,triggerClassName:F.exists?``:`text-amber-700`,hideTriggerHint:!0,renderOptionAction:e=>{let t=n.find(t=>t.id===e.value);return t?(0,P.jsx)(`button`,{type:`button`,disabled:Ye,"aria-label":`移出 ${t.name}`,className:`tw-icon-danger rounded p-1 opacity-0 transition-opacity focus-visible:opacity-100 group-hover:opacity-100 disabled:opacity-0 disabled:group-hover:opacity-40`,onClick:()=>dt(t),children:(0,P.jsx)(g,{name:`trash`,size:13})}):null}}),F.frameworkReady?(0,P.jsx)(`span`,{className:`shrink-0 whitespace-nowrap text-[11px] text-stone-500`,children:[c.find(e=>e.id===F.framework)?.label||F.framework,F.kind?ke(F.kind):``].filter(Boolean).join(` · `)}):(0,P.jsx)(`span`,{className:`shrink-0 whitespace-nowrap text-[11px] text-amber-600`,children:`运行环境未就绪`}),(0,P.jsx)(_t,{onOpen:e=>jt({path:``,app:e?.id}),disabled:!F.exists})]}):null,(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`${q} ${tt?`border-[#4176e6] bg-[#f2f6ff] text-[#3566d0] hover:bg-[#eaf1ff]`:``}`,onClick:()=>tt?At():kt(null),disabled:Ye||ct,"aria-expanded":tt,children:[(0,P.jsx)(g,{name:`plus`,size:13}),`挂载`]}),F?(0,P.jsxs)(te,{as:`div`,className:`relative shrink-0`,children:[(0,P.jsx)(f,{type:`button`,className:`flex h-8 w-8 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-700`,"aria-label":`更多操作`,children:(0,P.jsx)(g,{name:`more`,size:16})}),(0,P.jsxs)(ee,{anchor:{to:`bottom end`,gap:4,padding:12},transition:!0,className:`tw-select-menu tw-menu-anim z-80 w-max min-w-[168px] space-y-0.5 rounded-lg p-1 pb-2 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:[(0,P.jsx)(d,{children:(0,P.jsx)(`button`,{type:`button`,className:`flex w-full items-center rounded-md px-2.5 py-1.5 text-left text-sm text-stone-700 data-[focus]:bg-stone-50`,onClick:()=>{(navigator.clipboard?.writeText(F.dir))?.then(()=>ht(!0)).catch(()=>void 0),window.setTimeout(()=>ht(!1),1200)},children:mt?`已复制路径`:`复制项目路径`})}),(0,P.jsx)(d,{children:(0,P.jsx)(`button`,{type:`button`,className:`flex w-full items-center rounded-md px-2.5 py-1.5 text-left text-sm text-stone-700 data-[focus]:bg-stone-50`,onClick:()=>kt(F),children:`重新指定目录`})}),(0,P.jsx)(`div`,{className:`my-1 h-px bg-stone-100`,"aria-hidden":`true`}),(0,P.jsx)(d,{children:(0,P.jsx)(`button`,{type:`button`,className:`flex w-full items-center rounded-md px-2.5 py-1.5 text-left text-sm text-red-600 data-[focus]:bg-red-50`,onClick:()=>dt(F),children:`移出项目`})})]})]}):null]})]})]}),!F&&!ue?(0,P.jsx)(`p`,{className:`shrink-0 border-b border-stone-100 bg-stone-50/60 px-4 py-1.5 text-[11px] text-stone-500`,children:`还没有挂载项目。点右上角「挂载」选一个 Playwright / pytest / Selenium 目录,自动识别框架。`}):null,(0,P.jsx)(`div`,{className:`grid shrink-0 transition-[grid-template-rows,opacity] duration-200 ease-out ${Jt?`grid-rows-[1fr] opacity-100`:`grid-rows-[0fr] opacity-0`}`,"aria-hidden":!Jt,children:(0,P.jsx)(`div`,{className:`overflow-hidden`,inert:!Jt,children:Kt})}),(0,P.jsx)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:(0,P.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:F?yt?(0,P.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 px-6 py-10 text-center`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium text-stone-700`,children:`这个项目还没有挂载提示词`}),(0,P.jsx)(`p`,{className:`max-w-md text-xs leading-relaxed text-stone-500`,children:y===`run`?`挂载后才能运行用例:运行前的规划与命令都由提示词驱动,缺了它跑出来的结果不可信。`:y===`generate`?`挂载后才能生成:规划、探索、生成代码三段都按提示词里的要求执行。`:`历史记录里是已经跑完的结果,挂载提示词后可以重新跑同一条用例。`}),(0,P.jsx)(`button`,{type:`button`,className:`${K} mt-1`,onClick:()=>Ue(!0),children:`挂载提示词`}),(0,P.jsx)(`p`,{className:`text-[11px] text-stone-400`,children:`一份提示词可同时挂给多个项目;也可以先去「提示词管理」新建一份`})]}):(0,P.jsxs)(P.Fragment,{children:[y===`run`?(0,P.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`text-xs text-stone-400`,children:`运行任务`}),(0,P.jsx)(ie,{options:wt,value:Ct?.id??`full`,onChange:e=>{w(e),F&&a(En(F.id),e)},compact:!0,className:`w-60`,ariaLabel:`运行任务`}),(0,P.jsxs)(`button`,{type:`button`,className:q,onClick:()=>{E(``),Re(!0)},disabled:Ye,"aria-label":`运行配置`,children:[(0,P.jsxs)(`svg`,{className:`h-3.5 w-3.5 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,P.jsx)(`path`,{d:`M4 7h10M18 7h2M4 17h4M12 17h8`}),(0,P.jsx)(`circle`,{cx:`16`,cy:`7`,r:`2`}),(0,P.jsx)(`circle`,{cx:`10`,cy:`17`,r:`2`})]}),`配置`]}),(0,P.jsx)(`div`,{className:`ml-auto flex items-center gap-2`,children:G?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`button`,{type:`button`,className:`${K} cursor-default`,disabled:!0,children:[(0,P.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-white/90`}),`运行中…`]}),(0,P.jsx)(`button`,{type:`button`,className:On,onClick:()=>void Ut(),disabled:qe,children:qe?`停止中…`:`停止`})]}):(0,P.jsxs)(`button`,{type:`button`,className:K,onClick:()=>void Ot(),disabled:Ye||!F.exists,children:[(0,P.jsx)(g,{name:`play`,size:14}),Ye?`启动中…`:Tt?`重新运行`:`运行`]})})]}),F.exists?F.frameworkReady?null:(0,P.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-700`,children:F.readyHint||`运行环境未就绪,先按项目要求安装依赖后再运行。`}):(0,P.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 rounded-lg bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-700`,children:[`项目目录已不存在(换机器或被移动过),记录与历史报告不会丢。`,(0,P.jsx)(`button`,{type:`button`,className:`font-medium text-amber-800 underline underline-offset-2 hover:text-amber-900`,onClick:()=>kt(F),children:`重新指定目录`})]}),k?(0,P.jsxs)(`div`,{className:`rounded-lg border border-stone-200 bg-stone-50/60 px-3 py-2.5`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-stone-600`,children:[(0,P.jsx)(ae,{tone:x[k.status].tone,children:x[k.status].label}),(0,P.jsxs)(`span`,{className:`tabular-nums`,children:[`耗时 `,we(qt)]}),k.status===`running`?null:(0,P.jsx)(`span`,{className:`tabular-nums`,children:Me(k)}),(0,P.jsx)(`span`,{className:k.command?`max-w-[360px] truncate font-mono text-[11px] text-stone-400`:`text-stone-400`,children:k.command?b(k.command):be(k.args,k.framework)}),k.reportRel?(0,P.jsxs)(`span`,{className:`max-w-[320px] truncate font-mono text-[11px] text-stone-400`,children:[`存储:`,k.reportRel.replace(/\/[^/]+$/,``)]}):null,(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[k.reportUrl&&k.status!==`running`?(0,P.jsx)(`a`,{className:q,href:k.reportUrl,target:`_blank`,rel:`noreferrer`,children:`查看报告`}):null,k.failed>0&&k.status!==`running`?(0,P.jsx)(`button`,{type:`button`,className:q,onClick:Wt,disabled:Ye||!F.exists,children:`重跑失败用例`}):null]})]}),k.error?(0,P.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:k.error}):null]}):null,(0,P.jsxs)(`div`,{className:`flex min-h-[220px] flex-1 flex-col overflow-hidden rounded-lg border border-stone-200`,children:[(0,P.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,P.jsx)(`span`,{children:`运行日志`}),G?(0,P.jsx)(`span`,{className:`text-[#3370ff]`,children:`实时`}):null,Ke?(0,P.jsxs)(`span`,{className:`tabular-nums text-stone-400`,children:[Ke.length,` 字符`]}):null]}),(0,P.jsx)(`pre`,{ref:Qe,onScroll:Dt,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:Ke||`运行后这里会显示实时输出…`})]})]}):null,y===`generate`?(0,P.jsx)(hn,{project:F,promptFile:I,onError:v},F.id):null,y===`history`?(0,P.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:O.length===0?(0,P.jsx)(h,{children:`还没有运行记录`}):(0,P.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-stone-200 text-left text-xs text-stone-400`,children:[(0,P.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`开始时间`}),(0,P.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`框架`}),(0,P.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`结果`}),(0,P.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`用例`}),(0,P.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`耗时`}),(0,P.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`参数`}),(0,P.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`操作`})]})}),(0,P.jsx)(`tbody`,{children:O.map(e=>(0,P.jsxs)(`tr`,{className:`border-b border-stone-100 last:border-0`,children:[(0,P.jsx)(`td`,{className:`whitespace-nowrap px-2 py-2 text-xs text-stone-600`,children:Ce(e.startedAt)}),(0,P.jsx)(`td`,{className:`whitespace-nowrap px-2 py-2 text-xs text-stone-500`,children:c.find(t=>t.id===e.framework)?.label??e.framework}),(0,P.jsx)(`td`,{className:`px-2 py-2`,children:(0,P.jsx)(ae,{tone:x[e.status].tone,children:x[e.status].label})}),(0,P.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,P.jsx)(`td`,{className:`whitespace-nowrap px-2 py-2 text-xs tabular-nums text-stone-600`,children:we(e.durationMs)}),(0,P.jsx)(`td`,{className:`max-w-[240px] truncate px-2 py-2 text-xs text-stone-500`,children:e.command?b(e.command):be(e.args,e.framework)}),(0,P.jsxs)(`td`,{className:`whitespace-nowrap px-2 py-2 text-right`,children:[(0,P.jsx)(`button`,{type:`button`,className:`text-xs text-[#3370ff] hover:underline`,onClick:()=>{R(`run`),xt(e.id).catch(e=>v(String(e)))},children:`日志`}),e.reportUrl?(0,P.jsx)(`a`,{className:`ml-3 text-xs text-[#3370ff] hover:underline`,href:e.reportUrl,target:`_blank`,rel:`noreferrer`,children:`报告`}):null,(0,P.jsx)(`button`,{type:`button`,className:`ml-3 text-xs text-red-500 hover:underline`,onClick:()=>pt(e),children:`删除`})]})]},e.id))})]})}):null]}):(0,P.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-1 px-6 py-10 text-center`,children:[(0,P.jsx)(`p`,{className:`text-sm text-stone-500`,children:`挂载一个项目后就能在这里运行用例`}),(0,P.jsx)(`p`,{className:`text-xs text-stone-400`,children:`移出项目只删除挂载记录,项目文件与历史报告都保留`})]})})}),(0,P.jsx)(Pe,{open:He,prompts:D.map(e=>e.value),value:F?.promptFile&&D.some(e=>e.value===F.promptFile)?F.promptFile:``,force:yt,onClose:()=>Ue(!1),onMount:Ft,onCreate:It}),(0,P.jsx)(bt,{open:Le,projectName:F?.name??``,detected:W.filter(e=>!e.custom&&e.kind!==`full`),customTasks:F?.customTasks??[],hiddenCount:F?.hiddenTasks?.length??0,editedCount:(F?.taskOverrides??[]).length,error:T,onClose:()=>{Re(!1),E(``)},onAdd:(e,t)=>Bt(e,t),onRemove:e=>Vt(e),onEdit:(e,t,n)=>Lt(e,t,n),onHide:e=>Rt(e),onReset:()=>zt(),onRescan:()=>B().then(()=>void 0)}),(0,P.jsx)(re,{open:!!ut,title:`移出项目`,message:`确定把「${ut?.name??``}」移出挂载列表吗?\n只删除挂载记录,项目文件与历史报告都保留;该项目挂载的提示词也会自动取消引用。`,confirmLabel:`移出`,danger:`outline`,onClose:()=>dt(null),onConfirm:()=>{let e=ut;dt(null),e&&S(e.id).then(async()=>{let t=await B();if(e.id===u){let e=t[0]?.id??``;ne(e),a(Sn,e)}Te()}).catch(e=>v(e instanceof Error?e.message:String(e)))}}),(0,P.jsx)(re,{open:!!ft,title:`删除运行记录`,message:`会同时删除该次运行的 HTML 报告与原始日志,确定删除吗?`,confirmLabel:`删除`,danger:`solid`,onClose:()=>pt(null),onConfirm:()=>void Gt()})]})}export{kn as default};
@@ -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,...typeof r.promptPath==`string`&&r.promptPath.trim()?{promptPath:r.promptPath.trim()}:{}}}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:`lifeKrTodos`,href:`life/kr-todos/`,i18n:`nav.lifeKrTodos`,plugin:`life`,match:`life/kr-todos`},{id:`lifeKrTasks`,href:`life/kr-tasks/`,i18n:`nav.lifeKrTasks`,plugin:`life`,match:`life/kr-tasks`},{id:`lifeObjectives`,href:`life/objectives/`,i18n:`nav.lifeObjectives`,plugin:`life`,match:`life/objectives`},{id:`lifeReviews`,href:`life/reviews/`,i18n:`nav.lifeReviews`,plugin:`life`,match:`life/reviews`},{id:`lifeYearPlans`,href:`life/year-plans/`,i18n:`nav.lifeYearPlans`,plugin:`life`,match:`life/year-plans`},{id:`lifeStages`,href:`life/stages/`,i18n:`nav.lifeStages`,plugin:`life`,match:`life/stages`},{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:`test-automation/`,i18n:`nav.uiAuto`,plugin:`uiAuto`,match:`test-automation`},{id:`reqAnalysis`,href:`requirement-analysis/`,i18n:`nav.reqAnalysis`,plugin:`reqAnalysis`,match:`requirement-analysis`},{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`},{id:`testReports`,href:`test-reports/`,i18n:`nav.testReports`,plugin:`testReports`,match:`test-reports`}],m=[],te=[`prompts`];function ne(e){return te.includes(e)}var h=`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.search.settings.bell.clock.mail.message.image.video.download.upload.plus.trash.lock.shield.key.cloud.box.filter.grid.pin.sparkle.rocket.eye.bookmark.archive.refresh.play.map.activity.cpu.briefcase.presentation.copy.save`.split(`.`),g={dashboard:`dashboard`,tasks:`clipboard`,todos:`list`,lifeKrTodos:`list`,lifeKrTasks:`clipboard`,lifeObjectives:`target`,lifeReviews:`fileText`,lifeYearPlans:`calendar`,lifeStages:`flag`,projects:`folder`,iterations:`calendar`,pmRequirements:`fileText`,bugs:`bug`,reports:`fileText`,testStats:`chart`,caseExec:`target`,uiAuto:`terminal`,reqAnalysis:`fileText`,cases:`check`,prompts:`pencil`,knowledgeLib:`book`,requirements:`fileText`,templates:`layers`,testReports:`fileText`};function re(e){return typeof e==`string`&&h.includes(e)}function _(e){let t={...g};if(!e||typeof e!=`object`||Array.isArray(e))return t;for(let n of p){let r=e[n.id];re(r)&&(t[n.id]=r)}return t}var v=new Set(p.map(e=>e.id));function y(e){return typeof e==`string`&&v.has(e)}function ie(e){return p.find(t=>t.id===e)}function ae(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 b(e){return`item:${e}`}function x(e){return`group:${e}`}function S(){return`ng_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function C(){return m.map(e=>({id:e.id,name:e.name,items:[...e.items]}))}function w(e,t=!0){if(e==null||!Array.isArray(e))return t?C():[];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()||S();i.has(o)&&(o=S());let s=[];if(Array.isArray(e.items))for(let t of e.items)y(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 T(e,t){let n=t.name.trim(),r=t.items.filter((e,t,n)=>y(e)&&n.indexOf(e)===t);if(!n||!r.length)return{groups:e,id:t.id?.trim()||``};let i=t.id?.trim()||S(),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:w(c),id:i}}function oe(e,t){return e.filter(e=>e.parentId===t).map(e=>e.id)}function E(e,t){return e.filter(e=>e.parentId===t)}function se(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 ce(e,t,n){let r=e.find(e=>e.id===t);return!r||!y(n)||r.items.includes(n)?e:T(e,{id:r.id,name:r.name,items:[...r.items,n]}).groups}function le(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 ue(e,t,n,r){let i=b(t),a=x(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),O(c,r)}function de(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 D(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(x(e.id));for(let n of t.get(e.id)??[])i(n)}};for(let t of de(e))t.type===`item`?n.push(b(t.id)):i(t.group);for(let t of e)i(t);return n}function fe(e){let t=new Set,n=new Set;for(let r of e){n.add(x(r.id));for(let e of r.items)t.add(e)}for(let e of p)t.has(e.id)||n.add(b(e.id));return n}function O(e,t){let n=fe(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 D(t))i.has(e)||r.push(e);return r}function pe(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Set(e.flatMap(e=>e.items)),i=O(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);y(t)&&!r.has(t)&&a.push({type:`item`,id:t})}return a}function me(e,t,n){let r=t.find(e=>e.id===n);if(!r)return O(e,t);let i=new Set(r.items.map(e=>b(e))),a=x(n);if(r.parentId){let n=e.filter(e=>e!==a),i=x(r.parentId),o=n.indexOf(i),s=[...n];return o<0?s.push(a):s.splice(o+1,0,a),O(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),O(c,t)}function he(e,t,n){let r=E(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(x(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 ge(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(x)),s=e.filter(e=>!o.has(e)),c=x(n),l=s.indexOf(c),u=a.map(x),d=[...s];return l<0?d.push(...u):d.splice(l+1,0,...u),O(d,t)}function _e(e,t){if(!e.startsWith(`group:`))return!1;let n=e.slice(6);return t.some(e=>e.id===n&&!!e.parentId)}function ve(e,t,n,r=[]){if(t.parentId)return O(e,n);let i=x(t.id),a=[...r.map(e=>x(e)),...t.items.map(e=>b(e))],o=e.filter(e=>e!==i);return o.push(...a),O(o,n)}function ye(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 k=`tw.space.active-id`,be=`tw.spaces.list.v1`;function A(e,t){try{return(e===`local`?localStorage:sessionStorage).getItem(t)?.trim()||``}catch{return``}}function j(e,t,n){try{(e===`local`?localStorage:sessionStorage).setItem(t,n)}catch{}}function M(e){let t=String(e||``).trim();t&&(j(`session`,k,t),j(`local`,k,t))}function N(){let e=A(`session`,k);if(e)return e;let t=A(`local`,k);if(t)return t;try{let e=sessionStorage.getItem(be);if(!e)return``;let t=JSON.parse(e);return String(t?.activeId||``).trim()}catch{return``}}function P(e){let t=N();return t?`${e}::${t}`:e}var F=`/__tb_config`,I=`tw.app.config.v1`,L=`tw.app.apikey.v1`,R=`tw.app.model.v1`,z=!1,B=null,V=``,H=``,U=!1,xe={language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``,allowPrivateWebFetch:!1};function W(){return`p_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function Se(e){if(!e||typeof e!=`object`)return null;let t=String(e.name??``).trim()||`未命名提供商`,n=String(e.baseURL??``).trim(),r=String(e.model??``).trim(),i=String(e.id??``).trim()||W(),a=typeof e.contextWindow==`number`&&Number.isFinite(e.contextWindow)&&e.contextWindow>0?Math.floor(e.contextWindow):void 0;return{id:i,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,contextWindow:a,supportsTools:e.supportsTools!==!1,supportsVision:e.supportsVision===!0}}function Ce(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=>Se(e)).filter(e=>!!e):e&&(e.baseURL||e.model||e.apiKey)&&(n=Ce(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:{...xe},plugins:{cases:!1,caseGen:!1,prompts:!0,promptGen:!1,knowledgeLib:!1,knowledgeGen:!1,requirements:!1,templates:!1,testReports:!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:{...g},navOrder:D(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=w(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():``,allowPrivateWebFetch:n.allowPrivateWebFetch===!0},plugins:r,caseTypes:i(e.caseTypes),promptKinds:f(e.promptKinds),knowledgeCategories:s(e.knowledgeCategories),navGroups:a,navIcons:_(e.navIcons),navOrder:O(e.navOrder,a)}}function we(){try{let e=localStorage.getItem(R);if(e)return G(JSON.parse(e))}catch{}try{let e=localStorage.getItem(P(I));if(e){let t=JSON.parse(e);if(t?.model)return G(t.model)}}catch{}return null}function Te(e){try{localStorage.setItem(R,JSON.stringify(e))}catch{}}function J(){try{let e=localStorage.getItem(P(I)),t=we();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(P(I),JSON.stringify(n)),Te(t)}catch{}}function Ee(){try{return localStorage.getItem(L)?.trim()||localStorage.getItem(P(L))?.trim()||``}catch{return``}}function De(e){try{e?localStorage.setItem(L,e):localStorage.removeItem(L),localStorage.removeItem(P(L))}catch{}}function Oe(){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 ke(){return z}function Z(){return B||Ae(),B??K()}function Ae(){if(!U&&(U=!0,typeof window<`u`))try{let e=J();e&&(B=e)}catch{}}function je(){return V}function Me(){return[...B?.model.providers??[]]}async function Ne(){try{let e=await fetch(F,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json();B=q(t.config),H=String(t.configTarget??``).trim();let n=X(B),r=String(t.apiKey??``).trim();return V=r||n?.apiKey?.trim()||``,r&&n&&!n.apiKey&&(V=r),z=!0,Y(B),B}}catch{}z=!1,H=``;let e=J();return e||=Oe()??K(),B=e,V=X(e)?.apiKey?.trim()||Ee(),Y(B),B}var Q=null;async function $(e){if(Y(e),z)try{await fetch(F,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({config:e,configTarget:H}),keepalive:!0})}catch{}}function Pe(e){let t=B??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 B=n,V=X(n)?.apiKey?.trim()||``,Q&&clearTimeout(Q),Q=setTimeout(()=>{Q=null,$(n)},280),n}function Fe(){return Q&&=(clearTimeout(Q),null),$(B??K())}function Ie(e){if(V=e.trim(),z||De(V),!B)return;let t=B.model.providers.map(e=>e.id===B.model.activeId?{...e,apiKey:V||void 0}:e);B=q({...B,model:{...B.model,providers:t}})}function Le(){let e=B;if(!e)return null;let t=X(e);if(!t?.baseURL?.trim()||!t.model?.trim())return null;let n=(t.apiKey||V).trim();return n?{baseURL:t.baseURL.trim(),apiKey:n,model:t.model.trim(),reasoningEffort:e.model.reasoningEffort,availableModels:t.availableModels}:null}function Re(){return W()}export{ge as A,u as B,ne as C,w as D,ae as E,le as F,e as G,f as H,se as I,i as J,n as K,ye as L,ve as M,me as N,_ as O,he as P,T as R,_e as S,E as T,o as U,ee as V,s as W,ce as _,ke as a,ie as b,Ie as c,N as d,M as f,h as g,p as h,Ne as i,ue as j,O as k,Le as l,g as m,je as n,Me as o,P as p,a as q,Z as r,Re as s,Fe as t,Pe as u,pe as v,b as w,x,oe as y,c as z};
@@ -1 +0,0 @@
1
- var e=`0.1.43`;export{e as t};
@@ -1,5 +0,0 @@
1
- var e=`lantern:composer-draft`;function t(){if(typeof window>`u`)return{};try{let t=window.sessionStorage.getItem(e);if(!t)return{};let n=JSON.parse(t);return n&&typeof n==`object`?n:{}}catch{return{}}}function n(t){if(typeof window<`u`)try{window.sessionStorage.setItem(e,JSON.stringify(t))}catch{}}function r(e){return e?t()[e]?.input??``:``}function i(e,r){if(!e)return;let i=t(),a=r??``;if(a.trim())i[e]={input:a,at:Date.now()};else{if(!i[e])return;delete i[e]}n(i)}function a(e){e&&i(e,``)}var o=`lantern:composer-task`;function s(){if(typeof window>`u`)return{};try{let e=window.sessionStorage.getItem(o);if(!e)return{};let t=JSON.parse(e);return t&&typeof t==`object`?t:{}}catch{return{}}}function c(e){if(typeof window<`u`)try{window.sessionStorage.setItem(o,JSON.stringify(e))}catch{}}function l(e){if(!e)return[];let t=s()[e];return Array.isArray(t)?t.filter(e=>e&&e.id&&typeof e.body==`string`&&e.body.trim()):[]}function u(e,t){if(!e)return;let n=s(),r=t.filter(e=>e.id&&e.body.trim());r.length?n[e]=r:delete n[e],c(n)}function d(e,t){e&&u(e,[...l(e).filter(e=>e.id!==t.id),t])}function f(e,t){e&&u(e,l(e).filter(e=>e.id!==t))}function p(e){return e.map(e=>e.body.trim()).filter(Boolean).join(`
2
-
3
- ---
4
-
5
- `)}export{u as a,i as c,f as i,p as n,a as o,l as r,r as s,d as t};