lantern-harness 0.1.5 → 0.1.6

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 (105) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +6 -6
  3. package/builtin/session/lh-nav-groups.mjs +3 -0
  4. package/cli/server.mjs +2 -0
  5. package/config/app.defaults.json +4 -0
  6. package/dist/500.html +17 -3
  7. package/dist/_astro/Base.DGaLtzMo.css +1 -0
  8. package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.BY4OccDH.js → Base.astro_astro_type_script_index_0_lang.uhTNjhRY.js} +1 -1
  9. package/dist/_astro/CaseExecBoard.FJ1Y9b4e.js +1 -0
  10. package/dist/_astro/{CaseGenerateApp.CGAvw04r.js → CaseGenerateApp.CT2n4VOf.js} +1 -1
  11. package/dist/_astro/{CasesLibrary.Bz6ol7zL.js → CasesLibrary.BjrehOiI.js} +1 -1
  12. package/dist/_astro/ChatApp.Dqfx4FcI.js +276 -0
  13. package/dist/_astro/DashboardBoard.wILBO_CD.js +5 -0
  14. package/dist/_astro/{DocsFileBrowser.CBXAmRPO.js → DocsFileBrowser.D32MgVAR.js} +1 -1
  15. package/dist/_astro/{DocsPager.CPwAnvW_.js → DocsPager.BARD7JvD.js} +1 -1
  16. package/dist/_astro/DrawerField.CWMLhcPX.js +1 -0
  17. package/dist/_astro/{KnowledgeLibrary._QhB3GHk.js → KnowledgeLibrary.C-Sg2R6B.js} +1 -1
  18. package/dist/_astro/NavLibraries.BzInZVDf.js +1 -0
  19. package/dist/_astro/PluginsPage.CS1GaJtR.js +1 -0
  20. package/dist/_astro/PluginsPage.CVyua_fb.js +39 -0
  21. package/dist/_astro/PmBugsBoard.BXUu0kNL.js +1 -0
  22. package/dist/_astro/PmIterationsBoard.Deso1uyK.js +1 -0
  23. package/dist/_astro/PmProjectDetail.CtQdpGes.js +1 -0
  24. package/dist/_astro/PmProjectsBoard.MM4vxneK.js +1 -0
  25. package/dist/_astro/PmRequirementsBoard.62ONLCH5.js +1 -0
  26. package/dist/_astro/PmRequirementsBoard.SLVDgspp.js +1 -0
  27. package/dist/_astro/PmShared.CwCmF-kI.js +1 -0
  28. package/dist/_astro/{PromptsLibrary.BLPVH34I.js → PromptsLibrary.Z1DQBrFL.js} +1 -1
  29. package/dist/_astro/{ReportsPage.DMk4sUqZ.js → ReportsPage.CGpIPPr9.js} +1 -1
  30. package/dist/_astro/{RequirementsLibrary.CyYBiauz.js → RequirementsLibrary.D8078xLd.js} +1 -1
  31. package/dist/_astro/{SearchableSelect.yFomIhKQ.js → SearchableSelect.BTJoZC_a.js} +1 -1
  32. package/dist/_astro/SelectDropdown.Buv7rQJ_.js +1 -0
  33. package/dist/_astro/{SettingsDialog.DrVaJAbf.js → SettingsDialog.BA57gp90.js} +1 -1
  34. package/dist/_astro/SlideOverDrawer.TPbGEoWn.js +1 -0
  35. package/dist/_astro/SpaceSwitcher.DZ8b_85M.js +7 -0
  36. package/dist/_astro/TasksBoard.CL-sNPZN.js +1 -0
  37. package/dist/_astro/{TemplatesLibrary.DV_MUASP.js → TemplatesLibrary.d6uIe7I-.js} +1 -1
  38. package/dist/_astro/TestStatsBoard.CSdXWc4Q.js +1 -0
  39. package/dist/_astro/TodosBoard.nl23X5Gi.js +1 -0
  40. package/dist/_astro/app-config.huKxSIlN.js +1 -0
  41. package/dist/_astro/case-exec.BipZCK6G.js +1 -0
  42. package/dist/_astro/i18n.Bbh04ngD.js +7 -0
  43. package/dist/_astro/{open-docs-in-session.D7Hxuu0K.js → open-docs-in-session.B5cUxqHi.js} +1 -1
  44. package/dist/_astro/plugins.DaDJq-mn.js +1 -0
  45. package/dist/_astro/pm.CpFmMslU.js +4 -0
  46. package/dist/_astro/{settings.1aF-h9sh.js → settings.CMK4PEak.js} +2 -2
  47. package/dist/_astro/spaces-client.CoQfaOIO.js +1 -0
  48. package/dist/_astro/tasks.otRBFydq.js +1 -0
  49. package/dist/_astro/{test-stats.BIHEJz5c.js → test-stats.MEm3K2rB.js} +1 -1
  50. package/dist/_astro/{view-prefs.DHPN5Yq6.js → view-prefs.Dhdh8Z5a.js} +1 -1
  51. package/dist/case-exec/index.html +18 -4
  52. package/dist/cases/generate/index.html +18 -4
  53. package/dist/cases/library/index.html +18 -4
  54. package/dist/dashboard/index.html +18 -4
  55. package/dist/docs/changelog/index.html +60 -5
  56. package/dist/docs/install/index.html +17 -3
  57. package/dist/docs/manual/index.html +89 -26
  58. package/dist/index.html +18 -4
  59. package/dist/knowledge/index.html +18 -4
  60. package/dist/knowledge//345/212/237/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/347/274/226/345/206/231/350/247/204/350/214/203/index.html +17 -3
  61. package/dist/plugins/index.html +18 -4
  62. package/dist/pm/bugs/index.html +281 -0
  63. package/dist/pm/iterations/index.html +281 -0
  64. package/dist/pm/projects/detail/index.html +281 -0
  65. package/dist/pm/projects/index.html +281 -0
  66. package/dist/pm/requirements/index.html +281 -0
  67. package/dist/prompts/index.html +18 -4
  68. package/dist/reports/index.html +18 -4
  69. package/dist/requirements/index.html +18 -4
  70. package/dist/tasks/index.html +18 -4
  71. package/dist/templates/index.html +18 -4
  72. package/dist/templates//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +17 -3
  73. package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +17 -3
  74. package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +17 -3
  75. package/dist/templates//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +17 -3
  76. package/dist/templates//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +17 -3
  77. package/dist/test-stats/index.html +18 -4
  78. package/dist/todos/index.html +18 -4
  79. package/docs//345/205/250/345/261/200/346/217/222/344/273/266.md +1 -1
  80. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +71 -41
  81. package/lh-plugins/lh-memory.mjs +1 -3
  82. package/lh-plugins/lh-pm.mjs +949 -0
  83. package/lh-plugins/lh-reports.mjs +12 -12
  84. package/lh-plugins/lh-stats.mjs +6 -2
  85. package/lh-plugins/lh-tasks.mjs +5 -7
  86. package/lh-plugins/lh-todos.mjs +35 -8
  87. package/package.json +1 -1
  88. package/dist/_astro/Base.CVuoZiOB.css +0 -1
  89. package/dist/_astro/CaseExecBoard.GIKQ6ccZ.js +0 -1
  90. package/dist/_astro/ChatApp.DZtDZRst.js +0 -273
  91. package/dist/_astro/DashboardBoard.CiTrVBqY.js +0 -5
  92. package/dist/_astro/DrawerField.KANqQwFl.js +0 -1
  93. package/dist/_astro/NavLibraries.fxwcz0b0.js +0 -1
  94. package/dist/_astro/PluginsPage.BfG3nVYJ.js +0 -1
  95. package/dist/_astro/PluginsPage.n_0T_ww4.js +0 -39
  96. package/dist/_astro/SelectDropdown.flhHcwyd.js +0 -1
  97. package/dist/_astro/SpaceSwitcher.C84a-OBd.js +0 -7
  98. package/dist/_astro/TasksBoard.Dwva6gEQ.js +0 -1
  99. package/dist/_astro/TestStatsBoard.Cl6mBowv.js +0 -1
  100. package/dist/_astro/TodosBoard.BTl5qvQt.js +0 -1
  101. package/dist/_astro/app-config.BAFE-Tim.js +0 -1
  102. package/dist/_astro/case-exec.HjGrOY_O.js +0 -1
  103. package/dist/_astro/i18n.DFwWWvim.js +0 -7
  104. package/dist/_astro/plugins.BHRarX88.js +0 -1
  105. package/dist/_astro/tasks.hIKi1ek-.js +0 -1
@@ -1 +1 @@
1
- import{c as e,n as t,t as n}from"./react-dom.CqAxpHMt.js";import{G as r,K as i,W as a,p as o,q as s,r as c,t as l,u}from"./app-config.BAFE-Tim.js";import{C as d,D as f,E as p,S as m,T as h,_ as g,a as _,c as v,f as y,g as b,h as x,i as S,l as C,m as w,n as T,o as E,p as D,r as O,s as k,u as A,v as j,w as M,x as ee,y as N}from"./use-text-value.BuY0Cm1z.js";import{$ as te,A as ne,B as P,F as re,J as ie,K as F,L as I,M as L,N as ae,P as oe,V as se,_t as R,c as ce,d as le,dt as z,et as B,f as ue,ft as de,h as fe,ht as pe,it as V,k as me,lt as he,m as ge,mt as _e,n as ve,nt as ye,o as be,p as xe,pt as H,rt as Se,s as Ce,st as U,u as we,ut as Te,v as Ee,x as De}from"./portal.Cm9XlIPf.js";import{a as Oe,c as ke,l as Ae,o as je,s as Me,u as Ne}from"./listbox.Di-t5U37.js";import{n as Pe,r as Fe,t as Ie}from"./active-element-history.CeefGkFQ.js";import{t as Le}from"./use-tree-walker.CfTHFX43.js";import{t as Re}from"./jsx-runtime.BUXbF_vF.js";var W=e(t(),1),G=e(n(),1);function ze(e){return typeof e==`object`?e.key:e}function Be(e,t){let n=e.length;return new Proxy(e,{get(e,r,i){if(typeof r==`string`){let i=r.charCodeAt(0);if(i>=48&&i<=57){let i=+r;if(Number.isInteger(i)&&i>=0&&i<n){let n=e[i];if(typeof n!=`object`){let r=t[i*2];n=e[i]={index:i,key:n,start:r,size:t[i*2+1],end:r+t[i*2+1],lane:0}}return n}}if(r===`length`)return n}return Reflect.get(e,r,i)}})}function K(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return(o.length!==r.length||o.some((e,t)=>r[t]!==e))&&(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1),i}return o.updateDeps=e=>{r=e},o}function Ve(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var q=(e,t)=>Math.abs(e-t)<1.01,He=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})},Ue,We=()=>{if(Ue!==void 0)return Ue;if(typeof navigator>`u`)return Ue=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Ue=!0;let e=navigator.maxTouchPoints;return Ue=navigator.platform===`MacIntel`&&e!==void 0&&e>0},Ge=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Ke=e=>e,qe=e=>{let t=e.overscan*Math.max(e.lanes??1,1),n=Math.max(e.startIndex-t,0),r=Math.min(e.endIndex+t,e.count-1)-n+1,i=Array(r);for(let e=0;e<r;e++)i[e]=n+e;return i},Je=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(Ge(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(Ge(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Ye={passive:!0},Xe=typeof window>`u`||`onscrollend`in window,Ze=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&Xe,o=0,s=a?null:He(i,()=>t(n(r),!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,Ye),a&&r.addEventListener(`scrollend`,u,Ye),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},Qe=(e,t)=>Ze(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),$e=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},et=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},tt=(e,t)=>e===`smooth`?t?`smoothLanded`:`smooth`:`instant`,nt=e=>e?.phase===`smooth`||e?.phase===`smoothLanded`,rt=e=>e.phase===`smooth`||e.phase===`smoothFinishing`;function it(e,t,n,r){if(t===0)return!1;let i=r(0),a=new Set,o=0;for(;o<e;){let e=n(o);if(e===i)break;a.add(e),o++}let s=e-o;if(s===0||s>=t)return!1;for(let e=0;e<s;e++)if(r(e)!==n(o+e))return!1;for(let e=s;e<t;e++)if(a.has(r(e)))return!1;return!0}var at=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this._clampedAdjustment=null,this.elementsCache=new Map,this._resizeBatch=null,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{let t=()=>{let t={sync:!1};this._resizeBatch=t;try{e.forEach(n)}finally{this._resizeBatch=null,t.notify&&(this.notify(t.sync),this._retryClampedAdjustment())}};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})),n=e=>{let t=e.target,n=this.indexFromElement(t);if(t.isConnected)this.isIndexInRange(n)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this));else{this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}}};return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Ke,rangeExtractor:qe,onChange:()=>{},measureElement:$e,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=this._singleLaneMeasurements?.items??s,l=e=>ze(c[e]),u=e>0?l(0):null,d=e>0?l(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==u||t.getItemKey(o-1)!==d)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>0&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==d)&&(o>e||it(e,o,l,t.getItemKey))&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:a,getItemKey:c}=this.options,l=0;for(;l<a&&c(l)!==e;)l++;if(l<a){let e=n[l];if(e){let n=Math.max(0,e.start+t);!i&&n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=K(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._clampedAdjustment=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5?e=this._intendedScrollOffset:this.scrollState?.index!=null&&!rt(this.scrollState)&&!q(e,this.scrollState.lastTargetOffset)&&!q(e,this.getScrollStateTarget(this.scrollState))&&(this._clampedAdjustment===null||Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5)&&(this.scrollState=null),this._intendedScrollOffset=null,this.scrollState&&(this.scrollState.writtenOffset=null),this._clampedAdjustment!==null&&Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null),this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,We()&&this.targetWindow!=null&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,Ye),e.addEventListener(`touchend`,n,Ye),e.addEventListener(`touchcancel`,n,Ye),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),e.removeEventListener(`touchcancel`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(We()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):nt(this.scrollState)&&!q(this.getScrollOffset()-i,this.scrollState.lastTargetOffset)||this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}this._retryClampedAdjustment()},this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;let{target:e,maxAtWrite:t}=this._clampedAdjustment,n=this.getMaxScrollOffset();n>t+.5&&(this._clampedAdjustment=e>n+.5?{target:e,maxAtWrite:n}:null,this._scrollToOffset(e,{adjustments:void 0,behavior:void 0}))},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=K(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=K(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._singleLaneMeasurements?.flat;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e}let o=u===0?Array(e):this._singleLaneMeasurements.items.slice(),c;if(u===0)c=t+n;else{let e=u-1;c=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t);o[t]=e;let n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=c,a[t*2+1]=i,c+=i+s}this._singleLaneMeasurements={flat:a,items:o};let d=Be(o,a);return this.measurementsCache=d,d}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=K(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=ct(e,t,n,r,r===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=K(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t,this.options.lanes]},(e,t,n,r,i,a)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n,lanes:a}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!nt(this.scrollState))return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),e.isConnected&&(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{var n;if(!this.isIndexInRange(e))return;this._resizeBatch?.sync&&this.getMeasurements();let r,i,a,o=this._singleLaneMeasurements?.flat;if(this.options.lanes===1&&o!=null)a=this.options.getItemKey(e),i=o[e*2],r=o[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;a=t.key,i=t.start,r=t.size}let s=this.itemSizeCache.get(a)??r,c=t-s;if(c!==0){let o=this.options.anchorTo===`end`&&!nt(this.scrollState)&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,l=o?this.getTotalSize():0,u=this.getScrollOffset()+this.scrollAdjustments,d=this.itemSizeCache.has(a)?i+s<=u&&this.scrollDirection!==`backward`:i<u,f=!nt(this.scrollState)&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?d:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:a,start:i,size:r,end:i+r,lane:0},c,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(a,t),this.itemSizeCacheVersion++;let p=this.scrollState?.writtenOffset!=null&&!q(this.scrollState.writtenOffset,this.getScrollOffset()+this.scrollAdjustments),m=!1;if(p||(o?m=this.applyScrollAdjustment(this.getTotalSize()-l):f&&(m=this.applyScrollAdjustment(c))),this._resizeBatch){this._resizeBatch.notify=!0,(n=this._resizeBatch).sync||(n.sync=m);return}this.notify(m),this._retryClampedAdjustment()}},this.getVirtualItems=K(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._singleLaneMeasurements?.flat,r=this.options.lanes===1&&n!=null;return Ve(t[ot(0,t.length-1,r?e=>n[e*2]:e=>Ve(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1){let e=this.getMaxScrollOffset(),n=e-this.options.paddingEnd+this.options.scrollPaddingEnd;return[Math.max(Math.min(n,e),0),t]}let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0;let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,startedAt:i,lastTargetOffset:r,stableFrames:0,phase:tt(n,!1)},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,startedAt:o,lastTargetOffset:i,stableFrames:0,phase:tt(n,q(i,this.getScrollOffset()))},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getOffsetForAlignment((this.scrollState?.writtenOffset??this.getScrollOffset())+e,`start`),r=this.now();this.scrollState={index:null,align:`start`,startedAt:r,lastTargetOffset:n,stableFrames:0,phase:tt(t,!1)},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this._iosDeferredAdjustment=0;let t=Math.max(this.getMaxScrollOffset(),0);this.scrollState={index:this.options.count-1,align:`end`,toEnd:!0,startedAt:this.now(),lastTargetOffset:t,stableFrames:0,phase:tt(e,q(t,this.getScrollOffset()))},this._scrollToOffset(t,{adjustments:void 0,behavior:e}),this.scheduleScrollReconcile()}else this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.cancelScroll=()=>{this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._singleLaneMeasurements?.flat;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.scrollState&&(this.scrollState.writtenOffset=n===`smooth`?null:this._intendedScrollOffset),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){if(e===0)return!1;if(We()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded))return this.scrollState?.index??(this._iosDeferredAdjustment+=e),!1;{let n=this.getScrollOffset()+this.scrollAdjustments+e,r=this.scrollElement,i=r!==null&&(`scrollHeight`in r||`document`in r)?this.getMaxScrollOffset():null;return this._clampedAdjustment=i!==null&&n>i+.5?{target:n,maxAtWrite:i}:null,this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0}}scheduleScrollReconcile(){this.targetWindow?this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}):this.scrollState=null}getScrollStateTarget(e){let t=e.toEnd?[Math.max(this.getMaxScrollOffset(),0)]:e.index==null?void 0:this.getOffsetForIndex(e.index,e.align);return t?t[0]:e.lastTargetOffset}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}this.getMeasurements();let e=this.getScrollStateTarget(this.scrollState),t=this.scrollState.index==null?1:this.options.useAnimationFrameWithResizeObserver?3:2,n=e!==this.scrollState.lastTargetOffset;if(!n&&q(e,this.getScrollOffset())){if(this.scrollState.phase===`smooth`?this.scrollState.phase=`smoothLanded`:this.scrollState.phase===`smoothFinishing`&&(this.scrollState.phase=`instant`),this.scrollState.stableFrames++,this.scrollState.stableFrames>=t){this.getScrollOffset()!==e&&this._scrollToOffset(e,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let t=this.getSize()||600,n=Math.abs(e-this.getScrollOffset()),r=nt(this.scrollState)&&n>t;this.scrollState.lastTargetOffset=e,r?this.scrollState.phase=`smooth`:this.scrollState.phase===`smooth`?this.scrollState.phase=`smoothFinishing`:this.scrollState.phase===`smoothLanded`&&(this.scrollState.phase=`instant`),this._scrollToOffset(e,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},ot=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function st(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function ct(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=st(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=ot(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var lt=typeof document<`u`?W.useLayoutEffect:W.useEffect;function ut({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=W.useReducer(e=>e+1,0)[1],a=W.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=W.useRef(!1),s=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},c=(e,t,n)=>{let r=a.current,i=!!e.options.horizontal,o=t.start-e.options.scrollMargin;r.lastPositions.get(n)!==o&&(r.lastPositions.set(n,o),r.mode===`transform`?n.style.transform=i?`translate3d(${o}px, 0, 0)`:`translate3d(0, ${o}px, 0)`:n.style[i?`left`:`top`]=`${o}px`)},l=e=>{let t=a.current;if(t.enabled&&t.container){s(e);for(let t of e.getVirtualItems()){let n=e.elementsCache.get(t.key);n&&c(e,t,n)}}},u={...r,onChange:(t,n)=>{var s;let c=a.current,u=!0;if(c.enabled){l(t);let e=t.range,n=c.prevRange;u=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,u&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}u&&(e&&n&&!o.current?(0,G.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[d]=W.useState(()=>{let e=new at(u),t=e.measureElement;return e.measureElement=n=>{o.current=!0;try{t(n)}finally{o.current=!1}let r=a.current;if(n!==null&&r.enabled&&r.container){let t=e.measurementsCache[e.indexFromElement(n)];t&&c(e,t,n)}},Object.assign(e,{containerRef:t=>{let n=a.current;n.container=t,n.lastSize=null,t!==null&&l(e)}})});return d.setOptions(u),lt(()=>d._didMount(),[]),lt(()=>(s(d),d._willUpdate())),lt(()=>{l(d)}),d}function dt(e){return ut({observeElementRect:Je,observeElementOffset:Qe,scrollToFn:et,...e})}function ft(e){let t=(0,W.useRef)({value:``,selectionStart:null,selectionEnd:null});return Fe(e,`blur`,e=>{let n=e.target;F(n)&&(t.current={value:n.value,selectionStart:n.selectionStart,selectionEnd:n.selectionEnd})}),z(()=>{if(!R(e)&&F(e)&&e.isConnected){if(e.focus({preventScroll:!0}),e.value!==t.current.value)e.setSelectionRange(e.value.length,e.value.length);else{let{selectionStart:n,selectionEnd:r}=t.current;n!==null&&r!==null&&e.setSelectionRange(n,r)}t.current={value:``,selectionStart:null,selectionEnd:null}}})}var pt=Object.defineProperty,mt=(e,t,n)=>t in e?pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ht=(e,t,n)=>(mt(e,typeof t==`symbol`?t:t+``,n),n),J=(e=>(e[e.Open=0]=`Open`,e[e.Closed=1]=`Closed`,e))(J||{}),Y=(e=>(e[e.Single=0]=`Single`,e[e.Multi=1]=`Multi`,e))(Y||{}),X=(e=>(e[e.Pointer=0]=`Pointer`,e[e.Focus=1]=`Focus`,e[e.Other=2]=`Other`,e))(X||{}),gt=(e=>(e[e.OpenCombobox=0]=`OpenCombobox`,e[e.CloseCombobox=1]=`CloseCombobox`,e[e.GoToOption=2]=`GoToOption`,e[e.SetTyping=3]=`SetTyping`,e[e.RegisterOption=4]=`RegisterOption`,e[e.UnregisterOption=5]=`UnregisterOption`,e[e.DefaultToFirstOption=6]=`DefaultToFirstOption`,e[e.SetActivationTrigger=7]=`SetActivationTrigger`,e[e.UpdateVirtualConfiguration=8]=`UpdateVirtualConfiguration`,e[e.SetInputElement=9]=`SetInputElement`,e[e.SetButtonElement=10]=`SetButtonElement`,e[e.SetOptionsElement=11]=`SetOptionsElement`,e[e.MarkInputAsMoved=12]=`MarkInputAsMoved`,e))(gt||{});function _t(e,t=e=>e){let n=e.activeOptionIndex===null?null:e.options[e.activeOptionIndex],r=t(e.options.slice()),i=r.length>0&&r[0].dataRef.current.order!==null?r.sort((e,t)=>e.dataRef.current.order-t.dataRef.current.order):De(r,e=>e.dataRef.current.domRef.current),a=n?i.indexOf(n):null;return a===-1&&(a=null),{options:i,activeOptionIndex:a}}var vt={1(e){var t;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===1)return e;let n=e.inputElement?O.Tracked(T(e.inputElement)):e.inputPositionState;return{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,inputPositionState:n,__demoMode:!1}},0(e){var t,n;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===0)return e;if((n=e.dataRef.current)!=null&&n.value){let t=e.dataRef.current.calculateIndex(e.dataRef.current.value);if(t!==-1)return{...e,activeOptionIndex:t,comboboxState:0,__demoMode:!1,inputPositionState:O.Idle}}return{...e,comboboxState:0,inputPositionState:O.Idle,__demoMode:!1}},3(e,t){return e.isTyping===t.isTyping?e:{...e,isTyping:t.isTyping}},2(e,t){var n,r;if((n=e.dataRef.current)!=null&&n.disabled||e.optionsElement&&!((r=e.dataRef.current)!=null&&r.optionsPropsRef.current.static)&&e.comboboxState===1)return e;if(e.virtual){let{options:n,disabled:r}=e.virtual,i=t.focus===_.Specific?t.idx:E(t,{resolveItems:()=>n,resolveActiveIndex:()=>e.activeOptionIndex??n.findIndex(e=>!r(e))??null,resolveDisabled:r,resolveId(){throw Error(`Function not implemented.`)}}),a=t.trigger??2;return e.activeOptionIndex===i&&e.activationTrigger===a?e:{...e,activeOptionIndex:i,activationTrigger:a,isTyping:!1,__demoMode:!1}}let i=_t(e);if(i.activeOptionIndex===null){let e=i.options.findIndex(e=>!e.dataRef.current.disabled);e!==-1&&(i.activeOptionIndex=e)}let a=t.focus===_.Specific?t.idx:E(t,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:e=>e.id,resolveDisabled:e=>e.dataRef.current.disabled}),o=t.trigger??2;return e.activeOptionIndex===a&&e.activationTrigger===o?e:{...e,...i,isTyping:!1,activeOptionIndex:a,activationTrigger:o,__demoMode:!1}},4:(e,t)=>{var n,r,i,a;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:[...e.options,t.payload]};let o=t.payload,s=_t(e,e=>(e.push(o),e));e.activeOptionIndex===null&&(i=(r=e.dataRef.current).isSelected)!=null&&i.call(r,t.payload.dataRef.current.value)&&(s.activeOptionIndex=s.options.indexOf(o));let c={...e,...s,activationTrigger:2};return(a=e.dataRef.current)!=null&&a.__demoMode&&e.dataRef.current.value===void 0&&(c.activeOptionIndex=0),c},5:(e,t)=>{var n;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:e.options.filter(e=>e.id!==t.id)};let r=_t(e,e=>{let n=e.findIndex(e=>e.id===t.id);return n!==-1&&e.splice(n,1),e});return{...e,...r,activationTrigger:2}},6:(e,t)=>e.defaultToFirstOption===t.value?e:{...e,defaultToFirstOption:t.value},7:(e,t)=>e.activationTrigger===t.trigger?e:{...e,activationTrigger:t.trigger},8:(e,t)=>{if(e.virtual===null)return{...e,virtual:{options:t.options,disabled:t.disabled??(()=>!1)}};if(e.virtual.options===t.options&&e.virtual.disabled===t.disabled)return e;let n=e.activeOptionIndex;if(e.activeOptionIndex!==null){let r=t.options.indexOf(e.virtual.options[e.activeOptionIndex]);n=r===-1?null:r}return{...e,activeOptionIndex:n,virtual:{options:t.options,disabled:t.disabled??(()=>!1)}}},9:(e,t)=>e.inputElement===t.element?e:{...e,inputElement:t.element},10:(e,t)=>e.buttonElement===t.element?e:{...e,buttonElement:t.element},11:(e,t)=>e.optionsElement===t.element?e:{...e,optionsElement:t.element},12(e){return e.inputPositionState.kind===`Tracked`?{...e,inputPositionState:O.Moved}:e}},yt=class e extends re{constructor(e){super(e),ht(this,`actions`,{onChange:e=>{let{onChange:t,compare:n,mode:r,value:i}=this.state.dataRef.current;return U(r,{0:()=>t?.(e),1:()=>{let r=i.slice(),a=r.findIndex(t=>n(t,e));return a===-1?r.push(e):r.splice(a,1),t?.(r)}})},registerOption:(e,t)=>(this.send({type:4,payload:{id:e,dataRef:t}}),()=>{this.state.activeOptionIndex===this.state.dataRef.current.calculateIndex(t.current.value)&&this.send({type:6,value:!0}),this.send({type:5,id:e})}),goToOption:(e,t)=>(this.send({type:6,value:!1}),this.send({type:2,...e,trigger:t})),setIsTyping:e=>{this.send({type:3,isTyping:e})},closeCombobox:()=>{var e,t;this.send({type:1}),this.send({type:6,value:!1}),(t=(e=this.state.dataRef.current).onClose)==null||t.call(e)},openCombobox:()=>{this.send({type:0}),this.send({type:6,value:!0})},setActivationTrigger:e=>{this.send({type:7,trigger:e})},selectActiveOption:()=>{let e=this.selectors.activeOptionIndex(this.state);if(e!==null){if(this.actions.setIsTyping(!1),this.state.virtual)this.actions.onChange(this.state.virtual.options[e]);else{let{dataRef:t}=this.state.options[e];this.actions.onChange(t.current.value)}this.actions.goToOption({focus:_.Specific,idx:e})}},setInputElement:e=>{this.send({type:9,element:e})},setButtonElement:e=>{this.send({type:10,element:e})},setOptionsElement:e=>{this.send({type:11,element:e})}}),ht(this,`selectors`,{activeDescendantId:e=>{let t=this.selectors.activeOptionIndex(e);if(t!==null)return e.virtual?e.options.find(n=>!n.dataRef.current.disabled&&e.dataRef.current.compare(n.dataRef.current.value,e.virtual.options[t]))?.id:e.options[t]?.id},activeOptionIndex:e=>{if(e.defaultToFirstOption&&e.activeOptionIndex===null&&(e.virtual?e.virtual.options.length>0:e.options.length>0)){if(e.virtual){let{options:t,disabled:n}=e.virtual,r=t.findIndex(e=>{var t;return!((t=n?.(e))!=null&&t)});if(r!==-1)return r}let t=e.options.findIndex(e=>!e.dataRef.current.disabled);if(t!==-1)return t}return e.activeOptionIndex},activeOption:e=>{let t=this.selectors.activeOptionIndex(e);return t===null?null:e.virtual?e.virtual.options[t??0]:e.options[t]?.dataRef.current.value??null},isActive:(e,t,n)=>{let r=this.selectors.activeOptionIndex(e);return r===null?!1:e.virtual?r===e.dataRef.current.calculateIndex(t):e.options[r]?.id===n},shouldScrollIntoView:(e,t,n)=>!(e.virtual||e.__demoMode||e.comboboxState!==0||e.activationTrigger===0||!this.selectors.isActive(e,t,n)),didInputMove(e){return e.inputPositionState.kind===`Moved`}});{let e=this.state.id,t=oe.get(null);this.disposables.add(t.on(ae.Push,n=>{!t.selectors.isTop(n,e)&&this.state.comboboxState===0&&this.actions.closeCombobox()})),this.on(0,()=>t.actions.push(e)),this.on(1,()=>t.actions.pop(e))}this.disposables.group(e=>{this.on(1,t=>{t.inputElement&&(e.dispose(),e.add(S(t.inputElement,t.inputPositionState,()=>{this.send({type:12})})))})})}static new({id:t,virtual:n=null,__demoMode:r=!1}){return new e({id:t,dataRef:{current:{}},comboboxState:+!r,isTyping:!1,options:[],virtual:n?{options:n.options,disabled:n.disabled??(()=>!1)}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:r,inputPositionState:O.Idle})}reduce(e,t){return U(t.type,vt,e,t)}},bt=(0,W.createContext)(null);function xt(e){let t=(0,W.useContext)(bt);if(t===null){let t=Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,St),t}return t}function St({id:e,virtual:t=null,__demoMode:n=!1}){let r=(0,W.useMemo)(()=>yt.new({id:e,virtual:t,__demoMode:n}),[]);return be(()=>r.dispose()),r}var Ct=(0,W.createContext)(null);Ct.displayName=`ComboboxDataContext`;function Z(e){let t=(0,W.useContext)(Ct);if(t===null){let t=Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,Z),t}return t}var wt=(0,W.createContext)(null);function Tt(e){let t=xt(`VirtualProvider`),{options:n}=Z(`VirtualProvider`).virtual,r=L(t,e=>e.optionsElement),[i,a]=(0,W.useMemo)(()=>{let e=r;if(!e)return[0,0];let t=window.getComputedStyle(e);return[parseFloat(t.paddingBlockStart||t.paddingTop),parseFloat(t.paddingBlockEnd||t.paddingBottom)]},[r]),o=dt({enabled:n.length!==0,scrollPaddingStart:i,scrollPaddingEnd:a,count:n.length,estimateSize(){return 40},getScrollElement(){return t.state.optionsElement},overscan:12}),[s,c]=(0,W.useState)(0);H(()=>{c(e=>e+1)},[n]);let l=o.getVirtualItems(),u=L(t,e=>e.activationTrigger===X.Pointer),d=L(t,t.selectors.activeOptionIndex);return l.length===0?null:W.createElement(wt.Provider,{value:o},W.createElement(`div`,{style:{position:`relative`,width:`100%`,height:`${o.getTotalSize()}px`},ref:e=>{e&&(u||d!==null&&n.length>d&&o.scrollToIndex(d))}},l.map(t=>W.createElement(W.Fragment,{key:t.key},W.cloneElement(e.children?.call(e,{...e.slot,option:n[t.index]}),{key:`${s}-${t.key}`,"data-index":t.index,"aria-setsize":n.length,"aria-posinset":t.index+1,style:{position:`absolute`,top:0,left:0,transform:`translateY(${t.start}px)`,overflowAnchor:`none`}})))))}var Et=W.Fragment;function Dt(e,t){let n=(0,te.useId)(),r=he(),{value:i,defaultValue:a,onChange:o,form:s,name:c,by:l,invalid:u=!1,disabled:d=r||!1,onClose:f,__demoMode:p=!1,multiple:h=!1,immediate:g=!1,virtual:_=null,nullable:v,...y}=e,b=Ae(a),[x=h?[]:void 0,S]=Ne(i,o,b),C=St({id:n,virtual:_,__demoMode:p}),w=(0,W.useRef)({static:!1,hold:!1}),T=Me(l),E=z(e=>_?l===null?_.options.indexOf(e):_.options.findIndex(t=>T(t,e)):C.state.options.findIndex(t=>T(t.dataRef.current.value,e))),D=(0,W.useCallback)(e=>U(j.mode,{[Y.Multi]:()=>x.some(t=>T(t,e)),[Y.Single]:()=>T(x,e)}),[x]),O=L(C,e=>e.virtual),A=z(()=>f?.()),j=(0,W.useMemo)(()=>({__demoMode:p,immediate:g,optionsPropsRef:w,value:x,defaultValue:b,disabled:d,invalid:u,mode:h?Y.Multi:Y.Single,virtual:_?O:null,onChange:S,isSelected:D,calculateIndex:E,compare:T,onClose:A}),[p,g,w,x,b,d,u,h,_,O,S,D,E,T,A]);H(()=>{_&&C.send({type:gt.UpdateVirtualConfiguration,options:_.options,disabled:_.disabled??null})},[_,_?.options,_?.disabled]),H(()=>{C.state.dataRef.current=j},[j]);let[M,ee,N,ne]=L(C,e=>[e.comboboxState,e.buttonElement,e.inputElement,e.optionsElement]),P=oe.get(null),re=L(P,(0,W.useCallback)(e=>P.selectors.isTop(e,n),[P,n]));fe(re,[ee,N,ne],()=>C.actions.closeCombobox());let ie=L(C,C.selectors.activeOptionIndex),F=L(C,C.selectors.activeOption),I=Te({open:M===J.Open,disabled:d,invalid:u,activeIndex:ie,activeOption:F,value:x}),[ae,se]=m(),R=t===null?{}:{ref:t},le=(0,W.useCallback)(()=>{if(b!==void 0)return S?.(b)},[S,b]),B=ye();return W.createElement(se,{value:ae,props:{htmlFor:N?.id},slot:{open:M===J.Open,disabled:d}},W.createElement(k,null,W.createElement(Ct.Provider,{value:j},W.createElement(bt.Provider,{value:C},W.createElement(Ce,{value:U(M,{[J.Open]:ce.Open,[J.Closed]:ce.Closed})},c!=null&&W.createElement(ke,{disabled:d,data:x==null?{}:{[c]:x},form:s,onReset:le}),B({ourProps:R,theirProps:y,slot:I,defaultTag:Et,name:`Combobox`}))))))}var Ot=`input`;function kt(e,t){let n=xt(`Combobox.Input`),r=Z(`Combobox.Input`),i=(0,te.useId)(),a=M(),{id:o=a||`headlessui-combobox-input-${i}`,onChange:s,displayValue:c,disabled:l=r.disabled||!1,autoFocus:u=!1,type:d=`text`,...m}=e,h=(0,W.useRef)(null),g=se(h,t,v(),n.actions.setInputElement),[y,b]=L(n,e=>[e.comboboxState,e.isTyping]),x=_e(),S=z(()=>{n.actions.onChange(null),n.state.optionsElement&&(n.state.optionsElement.scrollTop=0),n.actions.goToOption({focus:_.Nothing})}),C=(0,W.useMemo)(()=>typeof c==`function`&&r.value!==void 0?c(r.value)??``:typeof r.value==`string`?r.value:``,[r.value,c]);Pe(([e,t],[r,i])=>{if(n.state.isTyping)return;let a=h.current;a&&((i===J.Open&&t===J.Closed||e!==r)&&(a.value=e),requestAnimationFrame(()=>{if(n.state.isTyping||!a||R(a))return;let{selectionStart:e,selectionEnd:t}=a;Math.abs((t??0)-(e??0))===0&&e===0&&a.setSelectionRange(a.value.length,a.value.length)}))},[C,y,b]),Pe(([e],[t])=>{if(e===J.Open&&t===J.Closed){if(n.state.isTyping)return;let e=h.current;if(!e)return;let t=e.value,{selectionStart:r,selectionEnd:i,selectionDirection:a}=e;e.value=``,e.value=t,a===null?e.setSelectionRange(r,i):e.setSelectionRange(r,i,a)}},[y]);let w=(0,W.useRef)(!1),T=z(()=>{w.current=!0}),E=z(()=>{x.nextFrame(()=>{w.current=!1})}),D=z(e=>{switch(n.actions.setIsTyping(!0),e.key){case I.Enter:if(n.state.comboboxState!==J.Open||w.current)return;if(e.preventDefault(),e.stopPropagation(),n.selectors.activeOptionIndex(n.state)===null){n.actions.closeCombobox();return}n.actions.selectActiveOption(),r.mode===Y.Single&&n.actions.closeCombobox();break;case I.ArrowDown:return e.preventDefault(),e.stopPropagation(),U(n.state.comboboxState,{[J.Open]:()=>n.actions.goToOption({focus:_.Next}),[J.Closed]:()=>n.actions.openCombobox()});case I.ArrowUp:return e.preventDefault(),e.stopPropagation(),U(n.state.comboboxState,{[J.Open]:()=>n.actions.goToOption({focus:_.Previous}),[J.Closed]:()=>{(0,G.flushSync)(()=>n.actions.openCombobox()),r.value||n.actions.goToOption({focus:_.Last})}});case I.Home:if(n.state.comboboxState===J.Closed||e.shiftKey)break;return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:_.First});case I.PageUp:return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:_.First});case I.End:if(n.state.comboboxState===J.Closed||e.shiftKey)break;return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:_.Last});case I.PageDown:return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:_.Last});case I.Escape:return n.state.comboboxState===J.Open?(e.preventDefault(),n.state.optionsElement&&!r.optionsPropsRef.current.static&&e.stopPropagation(),r.mode===Y.Single&&r.value===null&&S(),n.actions.closeCombobox()):void 0;case I.Tab:if(n.actions.setIsTyping(!1),n.state.comboboxState!==J.Open)return;r.mode===Y.Single&&n.state.activationTrigger!==X.Focus&&n.actions.selectActiveOption(),n.actions.closeCombobox()}}),O=z(e=>{s?.(e),r.mode===Y.Single&&e.target.value===``&&S(),n.actions.openCombobox()}),k=z(e=>{var t,i;let a=e.relatedTarget??Ie.find(t=>t!==e.currentTarget);if(!((t=n.state.optionsElement)!=null&&t.contains(a))&&!((i=n.state.buttonElement)!=null&&i.contains(a))&&n.state.comboboxState===J.Open)return e.preventDefault(),r.mode===Y.Single&&r.value===null&&S(),n.actions.closeCombobox()}),A=z(e=>{var t,i;let a=e.relatedTarget??Ie.find(t=>t!==e.currentTarget);(t=n.state.buttonElement)!=null&&t.contains(a)||(i=n.state.optionsElement)!=null&&i.contains(a)||r.disabled||r.immediate&&n.state.comboboxState!==J.Open&&x.microTask(()=>{(0,G.flushSync)(()=>n.actions.openCombobox()),n.actions.setActivationTrigger(X.Focus)})}),j=ee(),N=P(),{isFocused:ne,focusProps:re}=f({autoFocus:u}),{isHovered:ie,hoverProps:F}=p({isDisabled:l}),ae=L(n,e=>e.optionsElement),oe=Te({open:y===J.Open,disabled:l,invalid:r.invalid,hover:ie,focus:ne,autofocus:u}),ce=Se({ref:g,id:o,role:`combobox`,type:d,"aria-controls":ae?.id,"aria-expanded":y===J.Open,"aria-activedescendant":L(n,n.selectors.activeDescendantId),"aria-labelledby":j,"aria-describedby":N,"aria-autocomplete":`list`,defaultValue:e.defaultValue??(r.defaultValue===void 0?null:c?.(r.defaultValue))??r.defaultValue,disabled:l||void 0,autoFocus:u,onCompositionStart:T,onCompositionEnd:E,onKeyDown:D,onChange:O,onFocus:A,onBlur:k},re,F);return ye()({ourProps:ce,theirProps:m,slot:oe,defaultTag:Ot,name:`Combobox.Input`})}var At=`button`;function jt(e,t){let n=xt(`Combobox.Button`),r=Z(`Combobox.Button`),[i,a]=(0,W.useState)(null),o=se(t,a,n.actions.setButtonElement),s=(0,te.useId)(),{id:c=`headlessui-combobox-button-${s}`,disabled:l=r.disabled||!1,autoFocus:u=!1,...d}=e,[m,v,y]=L(n,e=>[e.comboboxState,e.inputElement,e.optionsElement]),S=ft(v),C=m===J.Open;x(C,{trigger:i,action:(0,W.useCallback)(e=>{if(i!=null&&i.contains(e.target)||v!=null&&v.contains(e.target))return b.Ignore;let t=e.target.closest(`[role="option"]:not([data-disabled])`);return ie(t)?b.Select(t):y!=null&&y.contains(e.target)?b.Ignore:b.Close},[i,v,y]),close:n.actions.closeCombobox,select:n.actions.selectActiveOption});let T=z(e=>{switch(e.key){case I.Space:case I.Enter:e.preventDefault(),e.stopPropagation(),n.state.comboboxState===J.Closed&&(0,G.flushSync)(()=>n.actions.openCombobox()),S();return;case I.ArrowDown:e.preventDefault(),e.stopPropagation(),n.state.comboboxState===J.Closed&&((0,G.flushSync)(()=>n.actions.openCombobox()),n.state.dataRef.current.value||n.actions.goToOption({focus:_.First})),S();return;case I.ArrowUp:e.preventDefault(),e.stopPropagation(),n.state.comboboxState===J.Closed&&((0,G.flushSync)(()=>n.actions.openCombobox()),n.state.dataRef.current.value||n.actions.goToOption({focus:_.Last})),S();return;case I.Escape:if(n.state.comboboxState!==J.Open)return;e.preventDefault(),n.state.optionsElement&&!r.optionsPropsRef.current.static&&e.stopPropagation(),(0,G.flushSync)(()=>n.actions.closeCombobox()),S();return;default:return}}),E=g(()=>{n.state.comboboxState===J.Open?n.actions.closeCombobox():n.actions.openCombobox(),S()}),D=ee([c]),{isFocusVisible:O,focusProps:k}=f({autoFocus:u}),{isHovered:A,hoverProps:j}=p({isDisabled:l}),{pressed:M,pressProps:N}=h({disabled:l}),ne=Te({open:m===J.Open,active:M||m===J.Open,disabled:l,invalid:r.invalid,value:r.value,hover:A,focus:O}),P=Se({ref:o,id:c,type:w(e,i),tabIndex:-1,"aria-haspopup":`listbox`,"aria-controls":y?.id,"aria-expanded":m===J.Open,"aria-labelledby":D,disabled:l||void 0,autoFocus:u,onKeyDown:T},E,k,j,N);return ye()({ourProps:P,theirProps:d,slot:ne,defaultTag:At,name:`Combobox.Button`})}var Mt=`div`,Nt=B.RenderStrategy|B.Static;function Pt(e,t){let n=(0,te.useId)(),{id:r=`headlessui-combobox-options-${n}`,hold:i=!1,anchor:a,portal:o=!1,modal:s=!0,transition:c=!1,...l}=e,u=xt(`Combobox.Options`),d=Z(`Combobox.Options`),f=y(a);f&&(o=!0);let[p,m]=C(f),[h,g]=(0,W.useState)(null),_=A(),v=se(t,f?p:null,u.actions.setOptionsElement,g),[b,x,S,w,T]=L(u,e=>[e.comboboxState,e.inputElement,e.buttonElement,e.optionsElement,e.activationTrigger]),E=ge(x||S),D=ge(w),O=we(),[k,j]=le(c,h,O===null?b===J.Open:(O&ce.Open)===ce.Open);me(k,x,u.actions.closeCombobox);let M=!d.__demoMode&&s&&b===J.Open;xe(M,D);let P=!d.__demoMode&&s&&b===J.Open;ne(P,{allowed:(0,W.useCallback)(()=>[x,S,w],[x,S,w])});let re=!L(u,u.selectors.didInputMove)&&k;H(()=>{d.optionsPropsRef.current.static=e.static??!1},[d.optionsPropsRef,e.static]),H(()=>{d.optionsPropsRef.current.hold=i},[d.optionsPropsRef,i]),Le(b===J.Open,{container:w,accept(e){return e.getAttribute(`role`)===`option`?NodeFilter.FILTER_REJECT:e.hasAttribute(`role`)?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(e){e.setAttribute(`role`,`none`)}});let ie=ee([S?.id]),F=Te({open:b===J.Open,option:void 0}),I=z(()=>{u.actions.setActivationTrigger(X.Pointer)}),ae=z(e=>{e.preventDefault(),u.actions.setActivationTrigger(X.Pointer)}),oe=Se(f?_():{},{"aria-labelledby":ie,role:`listbox`,"aria-multiselectable":d.mode===Y.Multi||void 0,id:r,ref:v,style:{...l.style,...m,"--input-width":N(k,x,!0).width,"--button-width":N(k,S,!0).width},onWheel:T===X.Pointer?void 0:I,onMouseDown:ae,...ue(j)}),R=k&&b===J.Closed&&!e.static,B=je(R,d.virtual?.options),de=je(R,d.value),fe=(0,W.useCallback)(e=>d.compare(de,e),[d.compare,de]),pe=(0,W.useMemo)(()=>{if(!d.virtual)return d;if(B===void 0)throw Error("Missing `options` in virtual mode");return B===d.virtual.options?d:{...d,virtual:{...d.virtual,options:B}}},[d,B,d.virtual?.options]);d.virtual&&Object.assign(l,{children:W.createElement(Ct.Provider,{value:pe},W.createElement(Tt,{slot:F},l.children))});let V=ye(),he=(0,W.useMemo)(()=>d.mode===Y.Multi?d:{...d,isSelected:fe},[d,fe]);return W.createElement(ve,{enabled:o?e.static||k:!1,ownerDocument:E},W.createElement(Ct.Provider,{value:he},V({ourProps:oe,theirProps:{...l,children:W.createElement(Oe,{freeze:R},typeof l.children==`function`?l.children?.call(l,F):l.children)},slot:F,defaultTag:Mt,features:Nt,visible:re,name:`Combobox.Options`})))}var Ft=`div`;function It(e,t){var n;let r=Z(`Combobox.Option`),i=xt(`Combobox.Option`),a=(0,te.useId)(),{id:o=`headlessui-combobox-option-${a}`,value:s,disabled:c=((n=r.virtual)?.disabled)?.call(n,s)??!1,order:l=null,...u}=e,[d]=L(i,e=>[e.inputElement]),f=ft(d),p=L(i,(0,W.useCallback)(e=>i.selectors.isActive(e,s,o),[s,o])),m=r.isSelected(s),h=(0,W.useRef)(null),g=de({disabled:c,value:s,domRef:h,order:l}),v=(0,W.useContext)(wt),y=se(t,h,v?v.measureElement:null),b=z(()=>{i.actions.setIsTyping(!1),i.actions.onChange(s)});H(()=>i.actions.registerOption(o,g),[g,o]);let x=L(i,(0,W.useCallback)(e=>i.selectors.shouldScrollIntoView(e,s,o),[s,o]));H(()=>{if(x)return pe().requestAnimationFrame(()=>{var e,t;(t=(e=h.current)?.scrollIntoView)==null||t.call(e,{block:`nearest`})})},[x,h]);let S=z(e=>{e.preventDefault(),e.button===j.Left&&(c||(b(),Ee()||requestAnimationFrame(()=>f()),r.mode===Y.Single&&i.actions.closeCombobox()))}),C=z(()=>{if(c)return i.actions.goToOption({focus:_.Nothing});let e=r.calculateIndex(s);i.actions.goToOption({focus:_.Specific,idx:e})}),w=D(),T=z(e=>w.update(e)),E=z(e=>{if(!w.wasMoved(e)||c||p&&i.state.activationTrigger===X.Pointer)return;let t=r.calculateIndex(s);i.actions.goToOption({focus:_.Specific,idx:t},X.Pointer)}),O=z(e=>{w.wasMoved(e)&&(c||p&&(r.optionsPropsRef.current.hold||i.state.activationTrigger===X.Pointer&&i.actions.goToOption({focus:_.Nothing})))}),k=Te({active:p,focus:p,selected:m,disabled:c}),A={id:o,ref:y,role:`option`,tabIndex:c===!0?void 0:-1,"aria-disabled":c===!0||void 0,"aria-selected":m,disabled:void 0,onMouseDown:S,onFocus:C,onPointerEnter:T,onMouseEnter:T,onPointerMove:E,onMouseMove:E,onPointerLeave:O,onMouseLeave:O};return ye()({ourProps:A,theirProps:u,slot:k,defaultTag:Ft,name:`Combobox.Option`})}var Lt=V(Dt),Rt=V(jt),zt=V(kt),Bt=d,Vt=V(Pt),Ht=V(It),Ut=Object.assign(Lt,{Input:zt,Button:Rt,Label:Bt,Options:Vt,Option:Ht});a.map(e=>({value:e.id,label:e.label,casesFolder:e.casesFolder,templateFolder:e.templateFolder}));function Q(){let e=c().caseTypes;return e?.length?e.map(e=>({...e})):a.map(e=>({...e}))}function Wt(e){let t=Q();return t.find(t=>t.id===e)??t[0]??a[0]}function Gt(e){let t=s(e);return u({caseTypes:t}),l(),t}function Kt(e){let t=e.trim();if(!t)throw Error(`类型名称不能为空`);if(t.length>40)throw Error(`类型名称过长(最多 40 字)`);let n=Q();if(n.some(e=>e.label===t))throw Error(`已存在「${t}」`);let a=r(t),o={id:i(),label:t,...a};return Gt([...n,o]),o}function qt(e,t){let n=t.trim();if(!n)throw Error(`类型名称不能为空`);if(n.length>40)throw Error(`类型名称过长(最多 40 字)`);let i=Q(),a=i.findIndex(t=>t.id===e);if(a<0)throw Error(`类型不存在`);if(i.some(t=>t.id!==e&&t.label===n))throw Error(`已存在「${n}」`);let o=r(n),s={...i[a],label:n,...o},c=[...i];return c[a]=s,Gt(c),s}function Jt(e){let t=Q();if(t.length<=1)throw Error(`至少保留一个用例类型`);if(!t.some(t=>t.id===e))throw Error(`类型不存在`);return Gt(t.filter(t=>t.id!==e))}var Yt=`/__tb_case_sessions`,Xt=`tw.case.sessions.v1`,Zt=!1;function Qt(){return`csess_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function $t(e){if(typeof e==`string`&&e.trim()){let t=e.trim();return Q().some(e=>e.id===t),t}return Q()[0]?.id??`functional`}function en(e){if(!e||!Array.isArray(e.sessions))return{sessions:[],activeId:``};let t=e.sessions.filter(e=>e&&typeof e==`object`&&e.id).map(e=>({...e,caseType:$t(e.caseType)})),n=typeof e.activeId==`string`?e.activeId:``;return t.length&&!t.some(e=>e.id===n)&&(n=t[0].id),t.length||(n=``),{sessions:t,activeId:n}}function tn(){try{let e=localStorage.getItem(o(Xt));return e?en(JSON.parse(e)):{sessions:[],activeId:``}}catch{return{sessions:[],activeId:``}}}function nn(e){try{localStorage.setItem(o(Xt),JSON.stringify(e))}catch{}}async function rn(){try{let e=await fetch(Yt,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json();Zt=!0;let n=en(t.store);return nn(n),n}}catch{}return Zt=!1,tn()}function an(){return tn()}async function on(e){if(nn(e),Zt)try{await fetch(Yt,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({store:e})})}catch{}}function sn(e){nn(e),on(e)}function cn(e){let t=Date.now(),n={id:Qt(),title:e.title?.trim()||`用例生成`,createdAt:t,updatedAt:t,caseType:e.caseType,outputFormat:e.outputFormat,reqPaths:e.reqPaths,templateId:e.templateId,templateTitle:e.templateTitle,promptPath:e.promptPath,knowledgePaths:e.knowledgePaths?.length?[...e.knowledgePaths]:void 0,messages:[]};return sn({sessions:[n,...tn().sessions],activeId:n.id}),n}function ln(e,t){let n=tn(),r=n.sessions.map(n=>n.id===e?{...n,...t,updatedAt:Date.now()}:n),i={...n,sessions:r};return sn(i),i}var $=Re();function un({options:e,values:t,onChange:n,placeholder:r=`选择…`,disabled:i=!1}){let[a,o]=(0,W.useState)(!1),s=(0,W.useRef)(null);(0,W.useEffect)(()=>{if(!a)return;function e(e){s.current?.contains(e.target)||o(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]);let c=e.filter(e=>t.includes(e.value)).map(e=>e.label),l=i||c.length===0?r:c.length<=2?c.join(`、`):`已选 ${c.length} 项`;function u(e){t.includes(e)?n(t.filter(t=>t!==e)):n([...t,e])}return(0,$.jsxs)(`div`,{className:`relative mt-1`,ref:s,children:[(0,$.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>o(e=>!e),className:i?`w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-stone-50 px-3 text-sm text-left text-stone-400 cursor-not-allowed`:`w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-white px-3 text-sm text-left text-stone-800 outline-none hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30`,children:[(0,$.jsx)(`span`,{className:`truncate ${i||c.length?``:`text-stone-400`}`,children:l}),(0,$.jsx)(`svg`,{className:`w-4 h-4 text-stone-400 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,$.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})]}),a?(0,$.jsx)(`div`,{className:`tw-select-menu tw-popover-anim absolute z-80 mt-1 max-h-56 w-full overflow-auto rounded-lg p-1 shadow-lg ring-1 ring-stone-200`,children:e.length===0?(0,$.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`暂无可选项`}):e.map(e=>{let n=t.includes(e.value);return(0,$.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-3 py-2 text-sm text-stone-700 cursor-pointer hover:bg-stone-50`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>u(e.value),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]},e.value)})}):null]})}function dn({options:e,value:t,onChange:n,placeholder:r=`搜索并选择…`,disabled:i=!1,allowEmpty:a=!0,emptyLabel:o=`不选择`}){let[s,c]=(0,W.useState)(``),l=(0,W.useMemo)(()=>{let t=s.trim().toLowerCase();return t?e.filter(e=>e.label.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)):e},[e,s]),u=e.find(e=>e.value===t)??null;return i?(0,$.jsx)(`div`,{className:`relative mt-1`,children:(0,$.jsxs)(`button`,{type:`button`,disabled:!0,className:`w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-stone-50 px-3 text-sm text-left text-stone-400 cursor-not-allowed`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:r}),(0,$.jsx)(`svg`,{className:`w-4 h-4 text-stone-400 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,$.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})]})}):(0,$.jsx)(Ut,{value:u,onChange:e=>{n(e?.value??``),c(``)},immediate:!0,children:(0,$.jsxs)(`div`,{className:`relative mt-1`,children:[(0,$.jsx)(zt,{className:`w-full h-9 rounded-lg border border-stone-200 bg-white px-3 pr-8 text-sm outline-none cursor-text placeholder:text-stone-400 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6]`,displayValue:e=>e?.label??``,onChange:e=>c(e.target.value),placeholder:r}),(0,$.jsx)(Rt,{className:`absolute inset-y-0 right-0 flex items-center pr-2 text-stone-400 cursor-pointer`,children:(0,$.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,$.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})}),(0,$.jsxs)(Vt,{transition:!0,anchor:{to:`bottom start`,gap:4},className:`tw-select-menu tw-menu-anim z-80 max-h-56 w-(--input-width) overflow-auto rounded-lg p-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:[a?(0,$.jsx)(Ht,{value:null,className:`cursor-pointer select-none rounded-md px-3 py-2 text-sm text-stone-400 data-[focus]:bg-stone-50`,children:o}):null,l.length===0?(0,$.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`无匹配项`}):l.map(e=>(0,$.jsx)(Ht,{value:e,className:`cursor-pointer select-none rounded-md px-3 py-2 text-sm text-stone-700 data-[focus]:bg-stone-50 data-[selected]:font-medium`,children:e.label},e.value))]})]})})}export{an as a,Kt as c,Jt as d,qt as f,rn as i,Wt as l,un as n,sn as o,cn as r,ln as s,dn as t,Q as u};
1
+ import{c as e,n as t,t as n}from"./react-dom.CqAxpHMt.js";import{G as r,K as i,W as a,p as o,q as s,r as c,t as l,u}from"./app-config.huKxSIlN.js";import{C as d,D as f,E as p,S as m,T as h,_ as g,a as _,c as v,f as y,g as b,h as x,i as S,l as C,m as w,n as T,o as E,p as D,r as O,s as k,u as A,v as j,w as M,x as ee,y as N}from"./use-text-value.BuY0Cm1z.js";import{$ as te,A as ne,B as P,F as re,J as ie,K as F,L as I,M as L,N as ae,P as oe,V as se,_t as R,c as ce,d as le,dt as z,et as B,f as ue,ft as de,h as fe,ht as pe,it as V,k as me,lt as he,m as ge,mt as _e,n as ve,nt as ye,o as be,p as xe,pt as H,rt as Se,s as Ce,st as U,u as we,ut as Te,v as Ee,x as De}from"./portal.Cm9XlIPf.js";import{a as Oe,c as ke,l as Ae,o as je,s as Me,u as Ne}from"./listbox.Di-t5U37.js";import{n as Pe,r as Fe,t as Ie}from"./active-element-history.CeefGkFQ.js";import{t as Le}from"./use-tree-walker.CfTHFX43.js";import{t as Re}from"./jsx-runtime.BUXbF_vF.js";var W=e(t(),1),G=e(n(),1);function ze(e){return typeof e==`object`?e.key:e}function Be(e,t){let n=e.length;return new Proxy(e,{get(e,r,i){if(typeof r==`string`){let i=r.charCodeAt(0);if(i>=48&&i<=57){let i=+r;if(Number.isInteger(i)&&i>=0&&i<n){let n=e[i];if(typeof n!=`object`){let r=t[i*2];n=e[i]={index:i,key:n,start:r,size:t[i*2+1],end:r+t[i*2+1],lane:0}}return n}}if(r===`length`)return n}return Reflect.get(e,r,i)}})}function K(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return(o.length!==r.length||o.some((e,t)=>r[t]!==e))&&(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1),i}return o.updateDeps=e=>{r=e},o}function Ve(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var q=(e,t)=>Math.abs(e-t)<1.01,He=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})},Ue,We=()=>{if(Ue!==void 0)return Ue;if(typeof navigator>`u`)return Ue=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Ue=!0;let e=navigator.maxTouchPoints;return Ue=navigator.platform===`MacIntel`&&e!==void 0&&e>0},Ge=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Ke=e=>e,qe=e=>{let t=e.overscan*Math.max(e.lanes??1,1),n=Math.max(e.startIndex-t,0),r=Math.min(e.endIndex+t,e.count-1)-n+1,i=Array(r);for(let e=0;e<r;e++)i[e]=n+e;return i},Je=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(Ge(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(Ge(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Ye={passive:!0},Xe=typeof window>`u`||`onscrollend`in window,Ze=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&Xe,o=0,s=a?null:He(i,()=>t(n(r),!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,Ye),a&&r.addEventListener(`scrollend`,u,Ye),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},Qe=(e,t)=>Ze(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),$e=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},et=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},tt=(e,t)=>e===`smooth`?t?`smoothLanded`:`smooth`:`instant`,nt=e=>e?.phase===`smooth`||e?.phase===`smoothLanded`,rt=e=>e.phase===`smooth`||e.phase===`smoothFinishing`;function it(e,t,n,r){if(t===0)return!1;let i=r(0),a=new Set,o=0;for(;o<e;){let e=n(o);if(e===i)break;a.add(e),o++}let s=e-o;if(s===0||s>=t)return!1;for(let e=0;e<s;e++)if(r(e)!==n(o+e))return!1;for(let e=s;e<t;e++)if(a.has(r(e)))return!1;return!0}var at=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this._clampedAdjustment=null,this.elementsCache=new Map,this._resizeBatch=null,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{let t=()=>{let t={sync:!1};this._resizeBatch=t;try{e.forEach(n)}finally{this._resizeBatch=null,t.notify&&(this.notify(t.sync),this._retryClampedAdjustment())}};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})),n=e=>{let t=e.target,n=this.indexFromElement(t);if(t.isConnected)this.isIndexInRange(n)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this));else{this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}}};return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Ke,rangeExtractor:qe,onChange:()=>{},measureElement:$e,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=this._singleLaneMeasurements?.items??s,l=e=>ze(c[e]),u=e>0?l(0):null,d=e>0?l(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==u||t.getItemKey(o-1)!==d)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>0&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==d)&&(o>e||it(e,o,l,t.getItemKey))&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:a,getItemKey:c}=this.options,l=0;for(;l<a&&c(l)!==e;)l++;if(l<a){let e=n[l];if(e){let n=Math.max(0,e.start+t);!i&&n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=K(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._clampedAdjustment=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5?e=this._intendedScrollOffset:this.scrollState?.index!=null&&!rt(this.scrollState)&&!q(e,this.scrollState.lastTargetOffset)&&!q(e,this.getScrollStateTarget(this.scrollState))&&(this._clampedAdjustment===null||Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5)&&(this.scrollState=null),this._intendedScrollOffset=null,this.scrollState&&(this.scrollState.writtenOffset=null),this._clampedAdjustment!==null&&Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null),this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,We()&&this.targetWindow!=null&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,Ye),e.addEventListener(`touchend`,n,Ye),e.addEventListener(`touchcancel`,n,Ye),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),e.removeEventListener(`touchcancel`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(We()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):nt(this.scrollState)&&!q(this.getScrollOffset()-i,this.scrollState.lastTargetOffset)||this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}this._retryClampedAdjustment()},this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;let{target:e,maxAtWrite:t}=this._clampedAdjustment,n=this.getMaxScrollOffset();n>t+.5&&(this._clampedAdjustment=e>n+.5?{target:e,maxAtWrite:n}:null,this._scrollToOffset(e,{adjustments:void 0,behavior:void 0}))},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=K(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=K(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._singleLaneMeasurements?.flat;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e}let o=u===0?Array(e):this._singleLaneMeasurements.items.slice(),c;if(u===0)c=t+n;else{let e=u-1;c=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t);o[t]=e;let n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=c,a[t*2+1]=i,c+=i+s}this._singleLaneMeasurements={flat:a,items:o};let d=Be(o,a);return this.measurementsCache=d,d}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=K(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=ct(e,t,n,r,r===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=K(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t,this.options.lanes]},(e,t,n,r,i,a)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n,lanes:a}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!nt(this.scrollState))return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),e.isConnected&&(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{var n;if(!this.isIndexInRange(e))return;this._resizeBatch?.sync&&this.getMeasurements();let r,i,a,o=this._singleLaneMeasurements?.flat;if(this.options.lanes===1&&o!=null)a=this.options.getItemKey(e),i=o[e*2],r=o[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;a=t.key,i=t.start,r=t.size}let s=this.itemSizeCache.get(a)??r,c=t-s;if(c!==0){let o=this.options.anchorTo===`end`&&!nt(this.scrollState)&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,l=o?this.getTotalSize():0,u=this.getScrollOffset()+this.scrollAdjustments,d=this.itemSizeCache.has(a)?i+s<=u&&this.scrollDirection!==`backward`:i<u,f=!nt(this.scrollState)&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?d:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:a,start:i,size:r,end:i+r,lane:0},c,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(a,t),this.itemSizeCacheVersion++;let p=this.scrollState?.writtenOffset!=null&&!q(this.scrollState.writtenOffset,this.getScrollOffset()+this.scrollAdjustments),m=!1;if(p||(o?m=this.applyScrollAdjustment(this.getTotalSize()-l):f&&(m=this.applyScrollAdjustment(c))),this._resizeBatch){this._resizeBatch.notify=!0,(n=this._resizeBatch).sync||(n.sync=m);return}this.notify(m),this._retryClampedAdjustment()}},this.getVirtualItems=K(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._singleLaneMeasurements?.flat,r=this.options.lanes===1&&n!=null;return Ve(t[ot(0,t.length-1,r?e=>n[e*2]:e=>Ve(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1){let e=this.getMaxScrollOffset(),n=e-this.options.paddingEnd+this.options.scrollPaddingEnd;return[Math.max(Math.min(n,e),0),t]}let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0;let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,startedAt:i,lastTargetOffset:r,stableFrames:0,phase:tt(n,!1)},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,startedAt:o,lastTargetOffset:i,stableFrames:0,phase:tt(n,q(i,this.getScrollOffset()))},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getOffsetForAlignment((this.scrollState?.writtenOffset??this.getScrollOffset())+e,`start`),r=this.now();this.scrollState={index:null,align:`start`,startedAt:r,lastTargetOffset:n,stableFrames:0,phase:tt(t,!1)},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this._iosDeferredAdjustment=0;let t=Math.max(this.getMaxScrollOffset(),0);this.scrollState={index:this.options.count-1,align:`end`,toEnd:!0,startedAt:this.now(),lastTargetOffset:t,stableFrames:0,phase:tt(e,q(t,this.getScrollOffset()))},this._scrollToOffset(t,{adjustments:void 0,behavior:e}),this.scheduleScrollReconcile()}else this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.cancelScroll=()=>{this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._singleLaneMeasurements?.flat;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.scrollState&&(this.scrollState.writtenOffset=n===`smooth`?null:this._intendedScrollOffset),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){if(e===0)return!1;if(We()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded))return this.scrollState?.index??(this._iosDeferredAdjustment+=e),!1;{let n=this.getScrollOffset()+this.scrollAdjustments+e,r=this.scrollElement,i=r!==null&&(`scrollHeight`in r||`document`in r)?this.getMaxScrollOffset():null;return this._clampedAdjustment=i!==null&&n>i+.5?{target:n,maxAtWrite:i}:null,this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0}}scheduleScrollReconcile(){this.targetWindow?this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}):this.scrollState=null}getScrollStateTarget(e){let t=e.toEnd?[Math.max(this.getMaxScrollOffset(),0)]:e.index==null?void 0:this.getOffsetForIndex(e.index,e.align);return t?t[0]:e.lastTargetOffset}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}this.getMeasurements();let e=this.getScrollStateTarget(this.scrollState),t=this.scrollState.index==null?1:this.options.useAnimationFrameWithResizeObserver?3:2,n=e!==this.scrollState.lastTargetOffset;if(!n&&q(e,this.getScrollOffset())){if(this.scrollState.phase===`smooth`?this.scrollState.phase=`smoothLanded`:this.scrollState.phase===`smoothFinishing`&&(this.scrollState.phase=`instant`),this.scrollState.stableFrames++,this.scrollState.stableFrames>=t){this.getScrollOffset()!==e&&this._scrollToOffset(e,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let t=this.getSize()||600,n=Math.abs(e-this.getScrollOffset()),r=nt(this.scrollState)&&n>t;this.scrollState.lastTargetOffset=e,r?this.scrollState.phase=`smooth`:this.scrollState.phase===`smooth`?this.scrollState.phase=`smoothFinishing`:this.scrollState.phase===`smoothLanded`&&(this.scrollState.phase=`instant`),this._scrollToOffset(e,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},ot=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function st(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function ct(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=st(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=ot(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var lt=typeof document<`u`?W.useLayoutEffect:W.useEffect;function ut({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=W.useReducer(e=>e+1,0)[1],a=W.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=W.useRef(!1),s=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},c=(e,t,n)=>{let r=a.current,i=!!e.options.horizontal,o=t.start-e.options.scrollMargin;r.lastPositions.get(n)!==o&&(r.lastPositions.set(n,o),r.mode===`transform`?n.style.transform=i?`translate3d(${o}px, 0, 0)`:`translate3d(0, ${o}px, 0)`:n.style[i?`left`:`top`]=`${o}px`)},l=e=>{let t=a.current;if(t.enabled&&t.container){s(e);for(let t of e.getVirtualItems()){let n=e.elementsCache.get(t.key);n&&c(e,t,n)}}},u={...r,onChange:(t,n)=>{var s;let c=a.current,u=!0;if(c.enabled){l(t);let e=t.range,n=c.prevRange;u=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,u&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}u&&(e&&n&&!o.current?(0,G.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[d]=W.useState(()=>{let e=new at(u),t=e.measureElement;return e.measureElement=n=>{o.current=!0;try{t(n)}finally{o.current=!1}let r=a.current;if(n!==null&&r.enabled&&r.container){let t=e.measurementsCache[e.indexFromElement(n)];t&&c(e,t,n)}},Object.assign(e,{containerRef:t=>{let n=a.current;n.container=t,n.lastSize=null,t!==null&&l(e)}})});return d.setOptions(u),lt(()=>d._didMount(),[]),lt(()=>(s(d),d._willUpdate())),lt(()=>{l(d)}),d}function dt(e){return ut({observeElementRect:Je,observeElementOffset:Qe,scrollToFn:et,...e})}function ft(e){let t=(0,W.useRef)({value:``,selectionStart:null,selectionEnd:null});return Fe(e,`blur`,e=>{let n=e.target;F(n)&&(t.current={value:n.value,selectionStart:n.selectionStart,selectionEnd:n.selectionEnd})}),z(()=>{if(!R(e)&&F(e)&&e.isConnected){if(e.focus({preventScroll:!0}),e.value!==t.current.value)e.setSelectionRange(e.value.length,e.value.length);else{let{selectionStart:n,selectionEnd:r}=t.current;n!==null&&r!==null&&e.setSelectionRange(n,r)}t.current={value:``,selectionStart:null,selectionEnd:null}}})}var pt=Object.defineProperty,mt=(e,t,n)=>t in e?pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ht=(e,t,n)=>(mt(e,typeof t==`symbol`?t:t+``,n),n),J=(e=>(e[e.Open=0]=`Open`,e[e.Closed=1]=`Closed`,e))(J||{}),Y=(e=>(e[e.Single=0]=`Single`,e[e.Multi=1]=`Multi`,e))(Y||{}),X=(e=>(e[e.Pointer=0]=`Pointer`,e[e.Focus=1]=`Focus`,e[e.Other=2]=`Other`,e))(X||{}),gt=(e=>(e[e.OpenCombobox=0]=`OpenCombobox`,e[e.CloseCombobox=1]=`CloseCombobox`,e[e.GoToOption=2]=`GoToOption`,e[e.SetTyping=3]=`SetTyping`,e[e.RegisterOption=4]=`RegisterOption`,e[e.UnregisterOption=5]=`UnregisterOption`,e[e.DefaultToFirstOption=6]=`DefaultToFirstOption`,e[e.SetActivationTrigger=7]=`SetActivationTrigger`,e[e.UpdateVirtualConfiguration=8]=`UpdateVirtualConfiguration`,e[e.SetInputElement=9]=`SetInputElement`,e[e.SetButtonElement=10]=`SetButtonElement`,e[e.SetOptionsElement=11]=`SetOptionsElement`,e[e.MarkInputAsMoved=12]=`MarkInputAsMoved`,e))(gt||{});function _t(e,t=e=>e){let n=e.activeOptionIndex===null?null:e.options[e.activeOptionIndex],r=t(e.options.slice()),i=r.length>0&&r[0].dataRef.current.order!==null?r.sort((e,t)=>e.dataRef.current.order-t.dataRef.current.order):De(r,e=>e.dataRef.current.domRef.current),a=n?i.indexOf(n):null;return a===-1&&(a=null),{options:i,activeOptionIndex:a}}var vt={1(e){var t;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===1)return e;let n=e.inputElement?O.Tracked(T(e.inputElement)):e.inputPositionState;return{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,inputPositionState:n,__demoMode:!1}},0(e){var t,n;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===0)return e;if((n=e.dataRef.current)!=null&&n.value){let t=e.dataRef.current.calculateIndex(e.dataRef.current.value);if(t!==-1)return{...e,activeOptionIndex:t,comboboxState:0,__demoMode:!1,inputPositionState:O.Idle}}return{...e,comboboxState:0,inputPositionState:O.Idle,__demoMode:!1}},3(e,t){return e.isTyping===t.isTyping?e:{...e,isTyping:t.isTyping}},2(e,t){var n,r;if((n=e.dataRef.current)!=null&&n.disabled||e.optionsElement&&!((r=e.dataRef.current)!=null&&r.optionsPropsRef.current.static)&&e.comboboxState===1)return e;if(e.virtual){let{options:n,disabled:r}=e.virtual,i=t.focus===_.Specific?t.idx:E(t,{resolveItems:()=>n,resolveActiveIndex:()=>e.activeOptionIndex??n.findIndex(e=>!r(e))??null,resolveDisabled:r,resolveId(){throw Error(`Function not implemented.`)}}),a=t.trigger??2;return e.activeOptionIndex===i&&e.activationTrigger===a?e:{...e,activeOptionIndex:i,activationTrigger:a,isTyping:!1,__demoMode:!1}}let i=_t(e);if(i.activeOptionIndex===null){let e=i.options.findIndex(e=>!e.dataRef.current.disabled);e!==-1&&(i.activeOptionIndex=e)}let a=t.focus===_.Specific?t.idx:E(t,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:e=>e.id,resolveDisabled:e=>e.dataRef.current.disabled}),o=t.trigger??2;return e.activeOptionIndex===a&&e.activationTrigger===o?e:{...e,...i,isTyping:!1,activeOptionIndex:a,activationTrigger:o,__demoMode:!1}},4:(e,t)=>{var n,r,i,a;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:[...e.options,t.payload]};let o=t.payload,s=_t(e,e=>(e.push(o),e));e.activeOptionIndex===null&&(i=(r=e.dataRef.current).isSelected)!=null&&i.call(r,t.payload.dataRef.current.value)&&(s.activeOptionIndex=s.options.indexOf(o));let c={...e,...s,activationTrigger:2};return(a=e.dataRef.current)!=null&&a.__demoMode&&e.dataRef.current.value===void 0&&(c.activeOptionIndex=0),c},5:(e,t)=>{var n;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:e.options.filter(e=>e.id!==t.id)};let r=_t(e,e=>{let n=e.findIndex(e=>e.id===t.id);return n!==-1&&e.splice(n,1),e});return{...e,...r,activationTrigger:2}},6:(e,t)=>e.defaultToFirstOption===t.value?e:{...e,defaultToFirstOption:t.value},7:(e,t)=>e.activationTrigger===t.trigger?e:{...e,activationTrigger:t.trigger},8:(e,t)=>{if(e.virtual===null)return{...e,virtual:{options:t.options,disabled:t.disabled??(()=>!1)}};if(e.virtual.options===t.options&&e.virtual.disabled===t.disabled)return e;let n=e.activeOptionIndex;if(e.activeOptionIndex!==null){let r=t.options.indexOf(e.virtual.options[e.activeOptionIndex]);n=r===-1?null:r}return{...e,activeOptionIndex:n,virtual:{options:t.options,disabled:t.disabled??(()=>!1)}}},9:(e,t)=>e.inputElement===t.element?e:{...e,inputElement:t.element},10:(e,t)=>e.buttonElement===t.element?e:{...e,buttonElement:t.element},11:(e,t)=>e.optionsElement===t.element?e:{...e,optionsElement:t.element},12(e){return e.inputPositionState.kind===`Tracked`?{...e,inputPositionState:O.Moved}:e}},yt=class e extends re{constructor(e){super(e),ht(this,`actions`,{onChange:e=>{let{onChange:t,compare:n,mode:r,value:i}=this.state.dataRef.current;return U(r,{0:()=>t?.(e),1:()=>{let r=i.slice(),a=r.findIndex(t=>n(t,e));return a===-1?r.push(e):r.splice(a,1),t?.(r)}})},registerOption:(e,t)=>(this.send({type:4,payload:{id:e,dataRef:t}}),()=>{this.state.activeOptionIndex===this.state.dataRef.current.calculateIndex(t.current.value)&&this.send({type:6,value:!0}),this.send({type:5,id:e})}),goToOption:(e,t)=>(this.send({type:6,value:!1}),this.send({type:2,...e,trigger:t})),setIsTyping:e=>{this.send({type:3,isTyping:e})},closeCombobox:()=>{var e,t;this.send({type:1}),this.send({type:6,value:!1}),(t=(e=this.state.dataRef.current).onClose)==null||t.call(e)},openCombobox:()=>{this.send({type:0}),this.send({type:6,value:!0})},setActivationTrigger:e=>{this.send({type:7,trigger:e})},selectActiveOption:()=>{let e=this.selectors.activeOptionIndex(this.state);if(e!==null){if(this.actions.setIsTyping(!1),this.state.virtual)this.actions.onChange(this.state.virtual.options[e]);else{let{dataRef:t}=this.state.options[e];this.actions.onChange(t.current.value)}this.actions.goToOption({focus:_.Specific,idx:e})}},setInputElement:e=>{this.send({type:9,element:e})},setButtonElement:e=>{this.send({type:10,element:e})},setOptionsElement:e=>{this.send({type:11,element:e})}}),ht(this,`selectors`,{activeDescendantId:e=>{let t=this.selectors.activeOptionIndex(e);if(t!==null)return e.virtual?e.options.find(n=>!n.dataRef.current.disabled&&e.dataRef.current.compare(n.dataRef.current.value,e.virtual.options[t]))?.id:e.options[t]?.id},activeOptionIndex:e=>{if(e.defaultToFirstOption&&e.activeOptionIndex===null&&(e.virtual?e.virtual.options.length>0:e.options.length>0)){if(e.virtual){let{options:t,disabled:n}=e.virtual,r=t.findIndex(e=>{var t;return!((t=n?.(e))!=null&&t)});if(r!==-1)return r}let t=e.options.findIndex(e=>!e.dataRef.current.disabled);if(t!==-1)return t}return e.activeOptionIndex},activeOption:e=>{let t=this.selectors.activeOptionIndex(e);return t===null?null:e.virtual?e.virtual.options[t??0]:e.options[t]?.dataRef.current.value??null},isActive:(e,t,n)=>{let r=this.selectors.activeOptionIndex(e);return r===null?!1:e.virtual?r===e.dataRef.current.calculateIndex(t):e.options[r]?.id===n},shouldScrollIntoView:(e,t,n)=>!(e.virtual||e.__demoMode||e.comboboxState!==0||e.activationTrigger===0||!this.selectors.isActive(e,t,n)),didInputMove(e){return e.inputPositionState.kind===`Moved`}});{let e=this.state.id,t=oe.get(null);this.disposables.add(t.on(ae.Push,n=>{!t.selectors.isTop(n,e)&&this.state.comboboxState===0&&this.actions.closeCombobox()})),this.on(0,()=>t.actions.push(e)),this.on(1,()=>t.actions.pop(e))}this.disposables.group(e=>{this.on(1,t=>{t.inputElement&&(e.dispose(),e.add(S(t.inputElement,t.inputPositionState,()=>{this.send({type:12})})))})})}static new({id:t,virtual:n=null,__demoMode:r=!1}){return new e({id:t,dataRef:{current:{}},comboboxState:+!r,isTyping:!1,options:[],virtual:n?{options:n.options,disabled:n.disabled??(()=>!1)}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:r,inputPositionState:O.Idle})}reduce(e,t){return U(t.type,vt,e,t)}},bt=(0,W.createContext)(null);function xt(e){let t=(0,W.useContext)(bt);if(t===null){let t=Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,St),t}return t}function St({id:e,virtual:t=null,__demoMode:n=!1}){let r=(0,W.useMemo)(()=>yt.new({id:e,virtual:t,__demoMode:n}),[]);return be(()=>r.dispose()),r}var Ct=(0,W.createContext)(null);Ct.displayName=`ComboboxDataContext`;function Z(e){let t=(0,W.useContext)(Ct);if(t===null){let t=Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,Z),t}return t}var wt=(0,W.createContext)(null);function Tt(e){let t=xt(`VirtualProvider`),{options:n}=Z(`VirtualProvider`).virtual,r=L(t,e=>e.optionsElement),[i,a]=(0,W.useMemo)(()=>{let e=r;if(!e)return[0,0];let t=window.getComputedStyle(e);return[parseFloat(t.paddingBlockStart||t.paddingTop),parseFloat(t.paddingBlockEnd||t.paddingBottom)]},[r]),o=dt({enabled:n.length!==0,scrollPaddingStart:i,scrollPaddingEnd:a,count:n.length,estimateSize(){return 40},getScrollElement(){return t.state.optionsElement},overscan:12}),[s,c]=(0,W.useState)(0);H(()=>{c(e=>e+1)},[n]);let l=o.getVirtualItems(),u=L(t,e=>e.activationTrigger===X.Pointer),d=L(t,t.selectors.activeOptionIndex);return l.length===0?null:W.createElement(wt.Provider,{value:o},W.createElement(`div`,{style:{position:`relative`,width:`100%`,height:`${o.getTotalSize()}px`},ref:e=>{e&&(u||d!==null&&n.length>d&&o.scrollToIndex(d))}},l.map(t=>W.createElement(W.Fragment,{key:t.key},W.cloneElement(e.children?.call(e,{...e.slot,option:n[t.index]}),{key:`${s}-${t.key}`,"data-index":t.index,"aria-setsize":n.length,"aria-posinset":t.index+1,style:{position:`absolute`,top:0,left:0,transform:`translateY(${t.start}px)`,overflowAnchor:`none`}})))))}var Et=W.Fragment;function Dt(e,t){let n=(0,te.useId)(),r=he(),{value:i,defaultValue:a,onChange:o,form:s,name:c,by:l,invalid:u=!1,disabled:d=r||!1,onClose:f,__demoMode:p=!1,multiple:h=!1,immediate:g=!1,virtual:_=null,nullable:v,...y}=e,b=Ae(a),[x=h?[]:void 0,S]=Ne(i,o,b),C=St({id:n,virtual:_,__demoMode:p}),w=(0,W.useRef)({static:!1,hold:!1}),T=Me(l),E=z(e=>_?l===null?_.options.indexOf(e):_.options.findIndex(t=>T(t,e)):C.state.options.findIndex(t=>T(t.dataRef.current.value,e))),D=(0,W.useCallback)(e=>U(j.mode,{[Y.Multi]:()=>x.some(t=>T(t,e)),[Y.Single]:()=>T(x,e)}),[x]),O=L(C,e=>e.virtual),A=z(()=>f?.()),j=(0,W.useMemo)(()=>({__demoMode:p,immediate:g,optionsPropsRef:w,value:x,defaultValue:b,disabled:d,invalid:u,mode:h?Y.Multi:Y.Single,virtual:_?O:null,onChange:S,isSelected:D,calculateIndex:E,compare:T,onClose:A}),[p,g,w,x,b,d,u,h,_,O,S,D,E,T,A]);H(()=>{_&&C.send({type:gt.UpdateVirtualConfiguration,options:_.options,disabled:_.disabled??null})},[_,_?.options,_?.disabled]),H(()=>{C.state.dataRef.current=j},[j]);let[M,ee,N,ne]=L(C,e=>[e.comboboxState,e.buttonElement,e.inputElement,e.optionsElement]),P=oe.get(null),re=L(P,(0,W.useCallback)(e=>P.selectors.isTop(e,n),[P,n]));fe(re,[ee,N,ne],()=>C.actions.closeCombobox());let ie=L(C,C.selectors.activeOptionIndex),F=L(C,C.selectors.activeOption),I=Te({open:M===J.Open,disabled:d,invalid:u,activeIndex:ie,activeOption:F,value:x}),[ae,se]=m(),R=t===null?{}:{ref:t},le=(0,W.useCallback)(()=>{if(b!==void 0)return S?.(b)},[S,b]),B=ye();return W.createElement(se,{value:ae,props:{htmlFor:N?.id},slot:{open:M===J.Open,disabled:d}},W.createElement(k,null,W.createElement(Ct.Provider,{value:j},W.createElement(bt.Provider,{value:C},W.createElement(Ce,{value:U(M,{[J.Open]:ce.Open,[J.Closed]:ce.Closed})},c!=null&&W.createElement(ke,{disabled:d,data:x==null?{}:{[c]:x},form:s,onReset:le}),B({ourProps:R,theirProps:y,slot:I,defaultTag:Et,name:`Combobox`}))))))}var Ot=`input`;function kt(e,t){let n=xt(`Combobox.Input`),r=Z(`Combobox.Input`),i=(0,te.useId)(),a=M(),{id:o=a||`headlessui-combobox-input-${i}`,onChange:s,displayValue:c,disabled:l=r.disabled||!1,autoFocus:u=!1,type:d=`text`,...m}=e,h=(0,W.useRef)(null),g=se(h,t,v(),n.actions.setInputElement),[y,b]=L(n,e=>[e.comboboxState,e.isTyping]),x=_e(),S=z(()=>{n.actions.onChange(null),n.state.optionsElement&&(n.state.optionsElement.scrollTop=0),n.actions.goToOption({focus:_.Nothing})}),C=(0,W.useMemo)(()=>typeof c==`function`&&r.value!==void 0?c(r.value)??``:typeof r.value==`string`?r.value:``,[r.value,c]);Pe(([e,t],[r,i])=>{if(n.state.isTyping)return;let a=h.current;a&&((i===J.Open&&t===J.Closed||e!==r)&&(a.value=e),requestAnimationFrame(()=>{if(n.state.isTyping||!a||R(a))return;let{selectionStart:e,selectionEnd:t}=a;Math.abs((t??0)-(e??0))===0&&e===0&&a.setSelectionRange(a.value.length,a.value.length)}))},[C,y,b]),Pe(([e],[t])=>{if(e===J.Open&&t===J.Closed){if(n.state.isTyping)return;let e=h.current;if(!e)return;let t=e.value,{selectionStart:r,selectionEnd:i,selectionDirection:a}=e;e.value=``,e.value=t,a===null?e.setSelectionRange(r,i):e.setSelectionRange(r,i,a)}},[y]);let w=(0,W.useRef)(!1),T=z(()=>{w.current=!0}),E=z(()=>{x.nextFrame(()=>{w.current=!1})}),D=z(e=>{switch(n.actions.setIsTyping(!0),e.key){case I.Enter:if(n.state.comboboxState!==J.Open||w.current)return;if(e.preventDefault(),e.stopPropagation(),n.selectors.activeOptionIndex(n.state)===null){n.actions.closeCombobox();return}n.actions.selectActiveOption(),r.mode===Y.Single&&n.actions.closeCombobox();break;case I.ArrowDown:return e.preventDefault(),e.stopPropagation(),U(n.state.comboboxState,{[J.Open]:()=>n.actions.goToOption({focus:_.Next}),[J.Closed]:()=>n.actions.openCombobox()});case I.ArrowUp:return e.preventDefault(),e.stopPropagation(),U(n.state.comboboxState,{[J.Open]:()=>n.actions.goToOption({focus:_.Previous}),[J.Closed]:()=>{(0,G.flushSync)(()=>n.actions.openCombobox()),r.value||n.actions.goToOption({focus:_.Last})}});case I.Home:if(n.state.comboboxState===J.Closed||e.shiftKey)break;return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:_.First});case I.PageUp:return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:_.First});case I.End:if(n.state.comboboxState===J.Closed||e.shiftKey)break;return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:_.Last});case I.PageDown:return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:_.Last});case I.Escape:return n.state.comboboxState===J.Open?(e.preventDefault(),n.state.optionsElement&&!r.optionsPropsRef.current.static&&e.stopPropagation(),r.mode===Y.Single&&r.value===null&&S(),n.actions.closeCombobox()):void 0;case I.Tab:if(n.actions.setIsTyping(!1),n.state.comboboxState!==J.Open)return;r.mode===Y.Single&&n.state.activationTrigger!==X.Focus&&n.actions.selectActiveOption(),n.actions.closeCombobox()}}),O=z(e=>{s?.(e),r.mode===Y.Single&&e.target.value===``&&S(),n.actions.openCombobox()}),k=z(e=>{var t,i;let a=e.relatedTarget??Ie.find(t=>t!==e.currentTarget);if(!((t=n.state.optionsElement)!=null&&t.contains(a))&&!((i=n.state.buttonElement)!=null&&i.contains(a))&&n.state.comboboxState===J.Open)return e.preventDefault(),r.mode===Y.Single&&r.value===null&&S(),n.actions.closeCombobox()}),A=z(e=>{var t,i;let a=e.relatedTarget??Ie.find(t=>t!==e.currentTarget);(t=n.state.buttonElement)!=null&&t.contains(a)||(i=n.state.optionsElement)!=null&&i.contains(a)||r.disabled||r.immediate&&n.state.comboboxState!==J.Open&&x.microTask(()=>{(0,G.flushSync)(()=>n.actions.openCombobox()),n.actions.setActivationTrigger(X.Focus)})}),j=ee(),N=P(),{isFocused:ne,focusProps:re}=f({autoFocus:u}),{isHovered:ie,hoverProps:F}=p({isDisabled:l}),ae=L(n,e=>e.optionsElement),oe=Te({open:y===J.Open,disabled:l,invalid:r.invalid,hover:ie,focus:ne,autofocus:u}),ce=Se({ref:g,id:o,role:`combobox`,type:d,"aria-controls":ae?.id,"aria-expanded":y===J.Open,"aria-activedescendant":L(n,n.selectors.activeDescendantId),"aria-labelledby":j,"aria-describedby":N,"aria-autocomplete":`list`,defaultValue:e.defaultValue??(r.defaultValue===void 0?null:c?.(r.defaultValue))??r.defaultValue,disabled:l||void 0,autoFocus:u,onCompositionStart:T,onCompositionEnd:E,onKeyDown:D,onChange:O,onFocus:A,onBlur:k},re,F);return ye()({ourProps:ce,theirProps:m,slot:oe,defaultTag:Ot,name:`Combobox.Input`})}var At=`button`;function jt(e,t){let n=xt(`Combobox.Button`),r=Z(`Combobox.Button`),[i,a]=(0,W.useState)(null),o=se(t,a,n.actions.setButtonElement),s=(0,te.useId)(),{id:c=`headlessui-combobox-button-${s}`,disabled:l=r.disabled||!1,autoFocus:u=!1,...d}=e,[m,v,y]=L(n,e=>[e.comboboxState,e.inputElement,e.optionsElement]),S=ft(v),C=m===J.Open;x(C,{trigger:i,action:(0,W.useCallback)(e=>{if(i!=null&&i.contains(e.target)||v!=null&&v.contains(e.target))return b.Ignore;let t=e.target.closest(`[role="option"]:not([data-disabled])`);return ie(t)?b.Select(t):y!=null&&y.contains(e.target)?b.Ignore:b.Close},[i,v,y]),close:n.actions.closeCombobox,select:n.actions.selectActiveOption});let T=z(e=>{switch(e.key){case I.Space:case I.Enter:e.preventDefault(),e.stopPropagation(),n.state.comboboxState===J.Closed&&(0,G.flushSync)(()=>n.actions.openCombobox()),S();return;case I.ArrowDown:e.preventDefault(),e.stopPropagation(),n.state.comboboxState===J.Closed&&((0,G.flushSync)(()=>n.actions.openCombobox()),n.state.dataRef.current.value||n.actions.goToOption({focus:_.First})),S();return;case I.ArrowUp:e.preventDefault(),e.stopPropagation(),n.state.comboboxState===J.Closed&&((0,G.flushSync)(()=>n.actions.openCombobox()),n.state.dataRef.current.value||n.actions.goToOption({focus:_.Last})),S();return;case I.Escape:if(n.state.comboboxState!==J.Open)return;e.preventDefault(),n.state.optionsElement&&!r.optionsPropsRef.current.static&&e.stopPropagation(),(0,G.flushSync)(()=>n.actions.closeCombobox()),S();return;default:return}}),E=g(()=>{n.state.comboboxState===J.Open?n.actions.closeCombobox():n.actions.openCombobox(),S()}),D=ee([c]),{isFocusVisible:O,focusProps:k}=f({autoFocus:u}),{isHovered:A,hoverProps:j}=p({isDisabled:l}),{pressed:M,pressProps:N}=h({disabled:l}),ne=Te({open:m===J.Open,active:M||m===J.Open,disabled:l,invalid:r.invalid,value:r.value,hover:A,focus:O}),P=Se({ref:o,id:c,type:w(e,i),tabIndex:-1,"aria-haspopup":`listbox`,"aria-controls":y?.id,"aria-expanded":m===J.Open,"aria-labelledby":D,disabled:l||void 0,autoFocus:u,onKeyDown:T},E,k,j,N);return ye()({ourProps:P,theirProps:d,slot:ne,defaultTag:At,name:`Combobox.Button`})}var Mt=`div`,Nt=B.RenderStrategy|B.Static;function Pt(e,t){let n=(0,te.useId)(),{id:r=`headlessui-combobox-options-${n}`,hold:i=!1,anchor:a,portal:o=!1,modal:s=!0,transition:c=!1,...l}=e,u=xt(`Combobox.Options`),d=Z(`Combobox.Options`),f=y(a);f&&(o=!0);let[p,m]=C(f),[h,g]=(0,W.useState)(null),_=A(),v=se(t,f?p:null,u.actions.setOptionsElement,g),[b,x,S,w,T]=L(u,e=>[e.comboboxState,e.inputElement,e.buttonElement,e.optionsElement,e.activationTrigger]),E=ge(x||S),D=ge(w),O=we(),[k,j]=le(c,h,O===null?b===J.Open:(O&ce.Open)===ce.Open);me(k,x,u.actions.closeCombobox);let M=!d.__demoMode&&s&&b===J.Open;xe(M,D);let P=!d.__demoMode&&s&&b===J.Open;ne(P,{allowed:(0,W.useCallback)(()=>[x,S,w],[x,S,w])});let re=!L(u,u.selectors.didInputMove)&&k;H(()=>{d.optionsPropsRef.current.static=e.static??!1},[d.optionsPropsRef,e.static]),H(()=>{d.optionsPropsRef.current.hold=i},[d.optionsPropsRef,i]),Le(b===J.Open,{container:w,accept(e){return e.getAttribute(`role`)===`option`?NodeFilter.FILTER_REJECT:e.hasAttribute(`role`)?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(e){e.setAttribute(`role`,`none`)}});let ie=ee([S?.id]),F=Te({open:b===J.Open,option:void 0}),I=z(()=>{u.actions.setActivationTrigger(X.Pointer)}),ae=z(e=>{e.preventDefault(),u.actions.setActivationTrigger(X.Pointer)}),oe=Se(f?_():{},{"aria-labelledby":ie,role:`listbox`,"aria-multiselectable":d.mode===Y.Multi||void 0,id:r,ref:v,style:{...l.style,...m,"--input-width":N(k,x,!0).width,"--button-width":N(k,S,!0).width},onWheel:T===X.Pointer?void 0:I,onMouseDown:ae,...ue(j)}),R=k&&b===J.Closed&&!e.static,B=je(R,d.virtual?.options),de=je(R,d.value),fe=(0,W.useCallback)(e=>d.compare(de,e),[d.compare,de]),pe=(0,W.useMemo)(()=>{if(!d.virtual)return d;if(B===void 0)throw Error("Missing `options` in virtual mode");return B===d.virtual.options?d:{...d,virtual:{...d.virtual,options:B}}},[d,B,d.virtual?.options]);d.virtual&&Object.assign(l,{children:W.createElement(Ct.Provider,{value:pe},W.createElement(Tt,{slot:F},l.children))});let V=ye(),he=(0,W.useMemo)(()=>d.mode===Y.Multi?d:{...d,isSelected:fe},[d,fe]);return W.createElement(ve,{enabled:o?e.static||k:!1,ownerDocument:E},W.createElement(Ct.Provider,{value:he},V({ourProps:oe,theirProps:{...l,children:W.createElement(Oe,{freeze:R},typeof l.children==`function`?l.children?.call(l,F):l.children)},slot:F,defaultTag:Mt,features:Nt,visible:re,name:`Combobox.Options`})))}var Ft=`div`;function It(e,t){var n;let r=Z(`Combobox.Option`),i=xt(`Combobox.Option`),a=(0,te.useId)(),{id:o=`headlessui-combobox-option-${a}`,value:s,disabled:c=((n=r.virtual)?.disabled)?.call(n,s)??!1,order:l=null,...u}=e,[d]=L(i,e=>[e.inputElement]),f=ft(d),p=L(i,(0,W.useCallback)(e=>i.selectors.isActive(e,s,o),[s,o])),m=r.isSelected(s),h=(0,W.useRef)(null),g=de({disabled:c,value:s,domRef:h,order:l}),v=(0,W.useContext)(wt),y=se(t,h,v?v.measureElement:null),b=z(()=>{i.actions.setIsTyping(!1),i.actions.onChange(s)});H(()=>i.actions.registerOption(o,g),[g,o]);let x=L(i,(0,W.useCallback)(e=>i.selectors.shouldScrollIntoView(e,s,o),[s,o]));H(()=>{if(x)return pe().requestAnimationFrame(()=>{var e,t;(t=(e=h.current)?.scrollIntoView)==null||t.call(e,{block:`nearest`})})},[x,h]);let S=z(e=>{e.preventDefault(),e.button===j.Left&&(c||(b(),Ee()||requestAnimationFrame(()=>f()),r.mode===Y.Single&&i.actions.closeCombobox()))}),C=z(()=>{if(c)return i.actions.goToOption({focus:_.Nothing});let e=r.calculateIndex(s);i.actions.goToOption({focus:_.Specific,idx:e})}),w=D(),T=z(e=>w.update(e)),E=z(e=>{if(!w.wasMoved(e)||c||p&&i.state.activationTrigger===X.Pointer)return;let t=r.calculateIndex(s);i.actions.goToOption({focus:_.Specific,idx:t},X.Pointer)}),O=z(e=>{w.wasMoved(e)&&(c||p&&(r.optionsPropsRef.current.hold||i.state.activationTrigger===X.Pointer&&i.actions.goToOption({focus:_.Nothing})))}),k=Te({active:p,focus:p,selected:m,disabled:c}),A={id:o,ref:y,role:`option`,tabIndex:c===!0?void 0:-1,"aria-disabled":c===!0||void 0,"aria-selected":m,disabled:void 0,onMouseDown:S,onFocus:C,onPointerEnter:T,onMouseEnter:T,onPointerMove:E,onMouseMove:E,onPointerLeave:O,onMouseLeave:O};return ye()({ourProps:A,theirProps:u,slot:k,defaultTag:Ft,name:`Combobox.Option`})}var Lt=V(Dt),Rt=V(jt),zt=V(kt),Bt=d,Vt=V(Pt),Ht=V(It),Ut=Object.assign(Lt,{Input:zt,Button:Rt,Label:Bt,Options:Vt,Option:Ht});a.map(e=>({value:e.id,label:e.label,casesFolder:e.casesFolder,templateFolder:e.templateFolder}));function Q(){let e=c().caseTypes;return e?.length?e.map(e=>({...e})):a.map(e=>({...e}))}function Wt(e){let t=Q();return t.find(t=>t.id===e)??t[0]??a[0]}function Gt(e){let t=s(e);return u({caseTypes:t}),l(),t}function Kt(e){let t=e.trim();if(!t)throw Error(`类型名称不能为空`);if(t.length>40)throw Error(`类型名称过长(最多 40 字)`);let n=Q();if(n.some(e=>e.label===t))throw Error(`已存在「${t}」`);let a=r(t),o={id:i(),label:t,...a};return Gt([...n,o]),o}function qt(e,t){let n=t.trim();if(!n)throw Error(`类型名称不能为空`);if(n.length>40)throw Error(`类型名称过长(最多 40 字)`);let i=Q(),a=i.findIndex(t=>t.id===e);if(a<0)throw Error(`类型不存在`);if(i.some(t=>t.id!==e&&t.label===n))throw Error(`已存在「${n}」`);let o=r(n),s={...i[a],label:n,...o},c=[...i];return c[a]=s,Gt(c),s}function Jt(e){let t=Q();if(t.length<=1)throw Error(`至少保留一个用例类型`);if(!t.some(t=>t.id===e))throw Error(`类型不存在`);return Gt(t.filter(t=>t.id!==e))}var Yt=`/__tb_case_sessions`,Xt=`tw.case.sessions.v1`,Zt=!1;function Qt(){return`csess_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function $t(e){if(typeof e==`string`&&e.trim()){let t=e.trim();return Q().some(e=>e.id===t),t}return Q()[0]?.id??`functional`}function en(e){if(!e||!Array.isArray(e.sessions))return{sessions:[],activeId:``};let t=e.sessions.filter(e=>e&&typeof e==`object`&&e.id).map(e=>({...e,caseType:$t(e.caseType)})),n=typeof e.activeId==`string`?e.activeId:``;return t.length&&!t.some(e=>e.id===n)&&(n=t[0].id),t.length||(n=``),{sessions:t,activeId:n}}function tn(){try{let e=localStorage.getItem(o(Xt));return e?en(JSON.parse(e)):{sessions:[],activeId:``}}catch{return{sessions:[],activeId:``}}}function nn(e){try{localStorage.setItem(o(Xt),JSON.stringify(e))}catch{}}async function rn(){try{let e=await fetch(Yt,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json();Zt=!0;let n=en(t.store);return nn(n),n}}catch{}return Zt=!1,tn()}function an(){return tn()}async function on(e){if(nn(e),Zt)try{await fetch(Yt,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({store:e})})}catch{}}function sn(e){nn(e),on(e)}function cn(e){let t=Date.now(),n={id:Qt(),title:e.title?.trim()||`用例生成`,createdAt:t,updatedAt:t,caseType:e.caseType,outputFormat:e.outputFormat,reqPaths:e.reqPaths,templateId:e.templateId,templateTitle:e.templateTitle,promptPath:e.promptPath,knowledgePaths:e.knowledgePaths?.length?[...e.knowledgePaths]:void 0,messages:[]};return sn({sessions:[n,...tn().sessions],activeId:n.id}),n}function ln(e,t){let n=tn(),r=n.sessions.map(n=>n.id===e?{...n,...t,updatedAt:Date.now()}:n),i={...n,sessions:r};return sn(i),i}var $=Re();function un({options:e,values:t,onChange:n,placeholder:r=`选择…`,disabled:i=!1}){let[a,o]=(0,W.useState)(!1),s=(0,W.useRef)(null);(0,W.useEffect)(()=>{if(!a)return;function e(e){s.current?.contains(e.target)||o(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]);let c=e.filter(e=>t.includes(e.value)).map(e=>e.label),l=i||c.length===0?r:c.length<=2?c.join(`、`):`已选 ${c.length} 项`;function u(e){t.includes(e)?n(t.filter(t=>t!==e)):n([...t,e])}return(0,$.jsxs)(`div`,{className:`relative mt-1`,ref:s,children:[(0,$.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>o(e=>!e),className:i?`w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-stone-50 px-3 text-sm text-left text-stone-400 cursor-not-allowed`:`w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-white px-3 text-sm text-left text-stone-800 outline-none hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30`,children:[(0,$.jsx)(`span`,{className:`truncate ${i||c.length?``:`text-stone-400`}`,children:l}),(0,$.jsx)(`svg`,{className:`w-4 h-4 text-stone-400 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,$.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})]}),a?(0,$.jsx)(`div`,{className:`tw-select-menu tw-popover-anim absolute z-80 mt-1 max-h-56 w-full overflow-auto rounded-lg p-1 shadow-lg ring-1 ring-stone-200`,children:e.length===0?(0,$.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`暂无可选项`}):e.map(e=>{let n=t.includes(e.value);return(0,$.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-3 py-2 text-sm text-stone-700 cursor-pointer hover:bg-stone-50`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>u(e.value),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]},e.value)})}):null]})}function dn({options:e,value:t,onChange:n,placeholder:r=`搜索并选择…`,disabled:i=!1,allowEmpty:a=!0,emptyLabel:o=`不选择`}){let[s,c]=(0,W.useState)(``),l=(0,W.useMemo)(()=>{let t=s.trim().toLowerCase();return t?e.filter(e=>e.label.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)):e},[e,s]),u=e.find(e=>e.value===t)??null;return i?(0,$.jsx)(`div`,{className:`relative mt-1`,children:(0,$.jsxs)(`button`,{type:`button`,disabled:!0,className:`w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-stone-50 px-3 text-sm text-left text-stone-400 cursor-not-allowed`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:r}),(0,$.jsx)(`svg`,{className:`w-4 h-4 text-stone-400 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,$.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})]})}):(0,$.jsx)(Ut,{value:u,onChange:e=>{n(e?.value??``),c(``)},immediate:!0,children:(0,$.jsxs)(`div`,{className:`relative mt-1`,children:[(0,$.jsx)(zt,{className:`w-full h-9 rounded-lg border border-stone-200 bg-white px-3 pr-8 text-sm outline-none cursor-text placeholder:text-stone-400 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6]`,displayValue:e=>e?.label??``,onChange:e=>c(e.target.value),placeholder:r}),(0,$.jsx)(Rt,{className:`absolute inset-y-0 right-0 flex items-center pr-2 text-stone-400 cursor-pointer`,children:(0,$.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,$.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})}),(0,$.jsxs)(Vt,{transition:!0,anchor:{to:`bottom start`,gap:4},className:`tw-select-menu tw-menu-anim z-80 max-h-56 w-(--input-width) overflow-auto rounded-lg p-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:[a?(0,$.jsx)(Ht,{value:null,className:`cursor-pointer select-none rounded-md px-3 py-2 text-sm text-stone-400 data-[focus]:bg-stone-50`,children:o}):null,l.length===0?(0,$.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`无匹配项`}):l.map(e=>(0,$.jsx)(Ht,{value:e,className:`cursor-pointer select-none rounded-md px-3 py-2 text-sm text-stone-700 data-[focus]:bg-stone-50 data-[selected]:font-medium`,children:e.label},e.value))]})]})})}export{an as a,Kt as c,Jt as d,qt as f,rn as i,Wt as l,un as n,sn as o,cn as r,ln as s,dn as t,Q as u};
@@ -0,0 +1 @@
1
+ import{i as e,n as t,r as n,t as r}from"./listbox.Di-t5U37.js";import{t as i}from"./jsx-runtime.BUXbF_vF.js";var a=i();function o({className:e=`w-4 h-4 text-stone-400 shrink-0`}){return(0,a.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,a.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})}function s(){return(0,a.jsx)(`svg`,{className:`w-4 h-4 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":!0,children:(0,a.jsx)(`path`,{fillRule:`evenodd`,d:`M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z`,clipRule:`evenodd`})})}function c({options:i,value:c,onChange:l,disabled:u=!1,className:d=``,compact:f=!1,ariaLabel:p,showCheck:m=!1,centerContent:h=!1,unstyled:g=!1,triggerClassName:_=``,hideChevron:v=!1,flat:y=!1,menuMinWidth:b,menuMatchTrigger:x=!0,renderTrigger:S,renderOptionPrefix:C}){let w=i.find(e=>e.value===c),T=h?`relative justify-center`:`justify-between`,E=h?`w-4 h-4 text-stone-400 shrink-0 absolute right-2.5`:void 0,D=g?`w-full flex items-center cursor-pointer outline-none disabled:cursor-not-allowed`:f?`w-full h-8 flex items-center gap-1.5 rounded-lg border border-stone-300 bg-white px-2.5 text-sm text-left text-stone-700 outline-none cursor-pointer hover:border-stone-400 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`:y?`w-full h-9 flex items-center gap-2 rounded-lg border border-stone-200 bg-white px-2.5 text-sm text-left text-stone-700 outline-none cursor-pointer hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`:`w-full h-9 flex items-center gap-2 rounded-lg border border-stone-200 bg-white px-3 text-sm text-left text-stone-800 outline-none cursor-pointer hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`;return(0,a.jsx)(n,{value:c,onChange:l,disabled:u,children:(0,a.jsxs)(`div`,{className:`relative ${g?``:f?`inline-block`:y?``:`mt-1`} ${d}`,children:[(0,a.jsxs)(e,{"aria-label":p,className:`${D} ${T} ${_}`,children:[S?S(w):(0,a.jsx)(`span`,{className:`truncate`,children:w?.label??c}),v?null:(0,a.jsx)(o,{className:E})]}),(0,a.jsx)(r,{transition:!0,anchor:{to:`bottom start`,gap:4,padding:12},style:!x&&b?{minWidth:b}:void 0,className:`tw-select-menu tw-menu-anim z-80 max-h-64 space-y-1 overflow-auto rounded-lg p-1 pb-2 shadow-lg ring-1 ring-stone-200 [--anchor-max-height:16rem] focus:outline-none ${x?`w-max min-w-(--button-width)`:`w-max min-w-[150px] max-w-[320px]`}`,children:i.map(e=>(0,a.jsxs)(t,{value:e.value,className:`group cursor-pointer select-none flex items-center gap-2 rounded-md px-3 py-2 text-sm leading-5 data-[focus]:bg-stone-50 data-[selected]:bg-(--tw-accent-soft) ${m?`text-stone-700 data-[selected]:text-stone-900`:`data-[selected]:text-(--tw-accent) data-[selected]:font-medium`} ${h&&!m&&!C?`justify-center px-2`:``}`,children:[m?(0,a.jsx)(`span`,{className:`w-4 shrink-0 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100`,children:(0,a.jsx)(s,{})}):C?(0,a.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:C(e)}):null,(0,a.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label})]},e.value))})]})})}export{c as t};
@@ -1 +1 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{a as n,i as r,n as i,s as ee}from"./app-config.BAFE-Tim.js";import{i as a,n as te,r as ne,t as re}from"./listbox.Di-t5U37.js";import{a as ie,o as ae}from"./dialog.DXHznyjD.js";import{t as o}from"./jsx-runtime.BUXbF_vF.js";import{t as oe}from"./ConfirmDialog.CBVsDJ8f.js";import{i as se}from"./llm.BZEzE0x2.js";import{_ as ce,a as s,c as le,d as ue,g as c,h as de,i as fe,l,n as u,o as pe,r as me,s as he,t as ge,u as _e,v as ve}from"./settings.1aF-h9sh.js";import{n as d}from"./i18n.DFwWWvim.js";var f=e(t(),1),ye=`0.1.5`,p=o();function be(e){try{return new URL(e).host}catch{return``}}var xe=[{value:`zh-CN`,label:`中文`},{value:`en`,label:`English`}],m=`w-full px-3 py-2 text-sm border border-stone-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-[#4176e6]/35 focus:border-[#4176e6] transition-colors`,h=`inline-flex items-center gap-1.5 h-9 min-w-30 px-3 rounded-lg bg-stone-100 text-sm text-stone-700 hover:bg-stone-200/80 transition-colors outline-none focus:outline-none`;function Se({className:e=`w-3.5 h-3.5`}){return(0,p.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:(0,p.jsx)(`path`,{d:`M6 8l4 4 4-4`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function g({className:e=`w-4 h-4`}){return(0,p.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,p.jsx)(`path`,{d:`M5 10.5l3.5 3.5L15 6.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function Ce({className:e=`w-4 h-4`}){return(0,p.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,p.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,p.jsx)(`path`,{d:`M12 1v2M12 21v2M4.2 4.2l1.4 1.4M18.4 18.4l1.4 1.4M1 12h2M21 12h2M4.2 19.8l1.4-1.4M18.4 5.6l1.4-1.4`})]})}function we({className:e=`w-4 h-4`}){return(0,p.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,p.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,p.jsx)(`path`,{d:`M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5`}),(0,p.jsx)(`path`,{d:`M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]})}function Te({kind:e}){let t=`w-5 h-5`;return e===`sun`?(0,p.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,p.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,p.jsx)(`path`,{d:`M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`})]}):e===`moon`?(0,p.jsx)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,p.jsx)(`path`,{d:`M21 14.5A8.5 8.5 0 1 1 9.5 3a7 7 0 0 0 11.5 11.5z`})}):(0,p.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,p.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`12`,rx:`2`}),(0,p.jsx)(`path`,{d:`M8 20h8M12 16v4`})]})}function _({title:e,description:t,control:n}){return(0,p.jsxs)(`div`,{className:`flex items-center gap-4 py-4 border-b border-stone-100 last:border-b-0`,children:[(0,p.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,p.jsx)(`div`,{className:`text-sm font-medium text-stone-800`,children:e}),t?(0,p.jsx)(`div`,{className:`mt-0.5 text-xs text-stone-400 leading-5`,children:t}):null]}),(0,p.jsx)(`div`,{className:`shrink-0`,children:n})]})}function v({value:e,options:t,onChange:n}){let r=t.find(t=>t.value===e)?.label??e;return(0,p.jsxs)(ne,{value:e,onChange:n,children:[(0,p.jsxs)(a,{className:h,children:[(0,p.jsx)(`span`,{className:`flex-1 text-left truncate`,children:r}),(0,p.jsx)(Se,{className:`w-3.5 h-3.5 text-stone-400 shrink-0`})]}),(0,p.jsx)(re,{transition:!0,anchor:{to:`bottom end`,gap:6},className:`tw-select-menu tw-menu-anim z-60 min-w-40 rounded-xl py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:t.map(e=>(0,p.jsxs)(te,{value:e.value,className:`group cursor-pointer select-none flex items-center justify-between gap-3 px-3 py-2 text-sm text-stone-700 data-[focus]:bg-stone-50 data-[selected]:text-stone-900`,children:[(0,p.jsx)(`span`,{children:e.label}),(0,p.jsx)(g,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0`})]},e.value))})]})}function y(){let[e,t]=(0,f.useState)(!1),[o,h]=(0,f.useState)(`general`),[y,b]=(0,f.useState)([]),[x,S]=(0,f.useState)(``),[C,w]=(0,f.useState)(null),[T,E]=(0,f.useState)(``),[Ee,D]=(0,f.useState)(`DeepSeek`),[O,k]=(0,f.useState)(``),[A,j]=(0,f.useState)(``),[M,N]=(0,f.useState)(``),[P,F]=(0,f.useState)([]),[I,L]=(0,f.useState)(`idle`),[De,R]=(0,f.useState)(!1),[Oe,z]=(0,f.useState)(`readonly`),[ke,Ae]=(0,f.useState)(!1),[je,B]=(0,f.useState)(!1),[Me,V]=(0,f.useState)(null),[H,U]=(0,f.useState)({language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``}),[W,G]=(0,f.useState)(`14`),K=(0,f.useRef)(0),q=C!==null,J=H.language,Y=y.find(e=>e.id===x),X=(Y?.name||``).trim(),Ne=X||(J===`en`?`No model`:`未配置`),Pe=X?Y?.model?.trim()?`${X} · ${Y.model.trim()}`:X:J===`en`?`No model configured`:`未配置模型`;function Fe(e=`general`){h(e),r().then(()=>{Z(),t(!0)})}function Z(){Ae(n()),b(le()),S(s()),B(!!l()),U(he()),me(he()),z(pe()),w(null)}function Ie(e){if(!e){let e=ee();w(e),E(`DeepSeek`),D(`DeepSeek`),k(`https://api.deepseek.com/v1`),j(``),N(``),F([]),L(`idle`),R(!1);return}w(e.id),E(e.name),k(e.baseURL);let t=e.apiKey?.trim()||(e.id===s()?i().trim():``)||``;j(t),N(e.model),F(e.availableModels??[]),L(e.availableModels?.length?`ok`:`idle`),D(u.find(t=>t.baseURL===e.baseURL)?.label??`自定义`),R(!1)}(0,f.useEffect)(()=>{r().then(()=>Z());let e=e=>{let n=e.detail;h(n?.tab===`model`?`model`:`general`),r().then(()=>{Z(),t(!0)})};window.addEventListener(ge,e);let n=ue(e=>U(e)),i=_e(e=>z(e));return()=>{window.removeEventListener(ge,e),n(),i()}},[]),(0,f.useEffect)(()=>{if(!e||o!==`model`||!q)return;let t=O.trim(),n=A.trim();if(!t||!n){L(e=>e===`ok`?`ok`:`idle`);return}L(`loading`);let r=++K.current,i=setTimeout(()=>{se(t,n).then(e=>{r===K.current&&(F(e),L(`ok`))}).catch(()=>{r===K.current&&L(`fail`)})},800);return()=>clearTimeout(i)},[e,o,q,O,A]);function Le(e){D(e);let t=u.find(t=>t.label===e);t&&(t.baseURL&&k(t.baseURL),(!T.trim()||u.some(e=>e.label===T))&&E(t.label)),N(``)}function Q(e){U(c(e))}(0,f.useEffect)(()=>{G(String(H.sessionFontSize))},[H.sessionFontSize]);function Re(){let e=Number(W);if(!W.trim()||!Number.isFinite(e)){G(String(H.sessionFontSize));return}let t=c({sessionFontSize:Math.round(e)});U(t),G(String(t.sessionFontSize))}let ze=!!(T.trim()&&O.trim()&&A.trim()&&M.trim()),$=P.length>0;function Be(){if(!ze||!C)return;let e=ve({id:C,name:T.trim(),baseURL:O.trim(),apiKey:A.trim(),model:M.trim(),availableModels:$?P:void 0},{activate:!0});b(e),S(C),w(null),B(!!l())}function Ve(e){V(e)}function He(){let e=Me;if(!e)return;V(null);let t=fe(e);b(t),S(s()),C===e&&w(null),B(!!l())}function Ue(e){ce(e),S(e),B(!!l())}let We=[{value:`readonly`,label:d(`settings.access.readonly`,void 0,J)},{value:`readwrite`,label:d(`settings.access.readwrite`,void 0,J)},{value:`full`,label:d(`settings.access.full`,void 0,J)}],Ge=[{value:`concise`,label:d(`settings.step.concise`,void 0,J)},{value:`standard`,label:d(`settings.step.standard`,void 0,J)},{value:`detailed`,label:d(`settings.step.detailed`,void 0,J)},{value:`full`,label:d(`settings.step.full`,void 0,J)}],Ke=[{value:`queue`,label:d(`settings.busySend.queue`,void 0,J)},{value:`interrupt`,label:d(`settings.busySend.interrupt`,void 0,J)}],qe=[{value:`light`,label:d(`settings.appear.light`,void 0,J),icon:`sun`},{value:`dark`,label:d(`settings.appear.dark`,void 0,J),icon:`moon`},{value:`system`,label:d(`settings.appear.system`,void 0,J),icon:`monitor`}],Je=[{id:`general`,label:d(`settings.general`,void 0,J),icon:(0,p.jsx)(Ce,{})},{id:`model`,label:d(`settings.model`,void 0,J),icon:(0,p.jsx)(we,{})}],Ye=o===`general`?d(`settings.general`,void 0,J):q?y.some(e=>e.id===C)?d(`settings.editProvider`,void 0,J):d(`settings.addProviderTitle`,void 0,J):d(`settings.model`,void 0,J);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`tw-nav-foot-row`,children:[(0,p.jsxs)(`button`,{type:`button`,onClick:()=>Fe(`general`),className:`tw-nav-settings-btn`,"data-hint":je?`设置(已配置模型)`:`设置`,children:[(0,p.jsxs)(`svg`,{className:`tw-nav-ico w-4.5 h-4.5 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":`true`,children:[(0,p.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,p.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9c.2.6.7 1 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z`})]}),(0,p.jsx)(`span`,{"data-i18n":`nav.settings`,children:d(`nav.settings`,void 0,J)})]}),(0,p.jsxs)(`button`,{type:`button`,className:`tw-nav-provider-chip${X?``:` is-empty`}`,"data-hint":Pe,onClick:()=>Fe(`model`),children:[(0,p.jsx)(`span`,{className:`tw-nav-provider-dot`,"aria-hidden":`true`}),(0,p.jsx)(`span`,{className:`tw-nav-provider-name`,children:Ne})]})]}),(0,p.jsx)(ie,{show:e,children:(0,p.jsxs)(`div`,{className:`fixed inset-0 z-110 flex items-center justify-center p-4`,children:[(0,p.jsx)(ae,{children:(0,p.jsx)(`div`,{className:`tw-dialog-backdrop-anim absolute inset-0 bg-stone-950/45`,onClick:()=>t(!1),"aria-hidden":`true`})}),(0,p.jsx)(ae,{children:(0,p.jsxs)(`div`,{className:`tw-settings-dialog tw-dialog-panel-anim relative bg-white rounded-2xl shadow-2xl w-full max-w-3xl h-[min(92vh,720px)] overflow-hidden flex flex-col`,children:[(0,p.jsxs)(`div`,{className:`shrink-0 h-12 px-4 flex items-center justify-between border-b border-stone-100 bg-white`,children:[(0,p.jsx)(`h2`,{className:`text-sm font-semibold text-stone-800 truncate pr-3`,children:Ye}),(0,p.jsx)(`button`,{type:`button`,"aria-label":d(`settings.close`,void 0,J),onClick:()=>t(!1),className:`w-8 h-8 inline-flex items-center justify-center rounded-lg text-stone-400 hover:text-stone-700 hover:bg-stone-100 transition-colors`,children:(0,p.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,p.jsx)(`path`,{d:`M5 5l10 10M15 5L5 15`,strokeLinecap:`round`})})})]}),(0,p.jsxs)(`div`,{className:`flex-1 min-h-0 flex`,children:[(0,p.jsx)(`aside`,{className:`w-38 shrink-0 border-r border-stone-100 bg-[#f4f5f7] py-3 px-2 space-y-0.5`,children:Je.map(e=>{let t=o===e.id;return(0,p.jsxs)(`button`,{type:`button`,onClick:()=>{h(e.id),e.id===`model`&&w(null)},className:`w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-sm transition-colors ${t?`bg-[#e8f0fe] text-[#4176e6] font-medium`:`text-stone-600 hover:bg-white/70 hover:text-stone-800`}`,children:[(0,p.jsx)(`span`,{className:t?`text-[#4176e6]`:`text-stone-400`,children:e.icon}),e.label]},e.id)})}),(0,p.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0 bg-white`,children:o===`general`?(0,p.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,p.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-1`,children:[(0,p.jsx)(_,{title:d(`settings.access`,void 0,J),description:d(`settings.accessDesc`,void 0,J),control:(0,p.jsx)(v,{value:Oe,options:We,onChange:e=>{z(e),de(e)}})}),(0,p.jsx)(_,{title:d(`settings.language`,void 0,J),control:(0,p.jsx)(v,{value:H.language,options:xe,onChange:e=>Q({language:e})})}),(0,p.jsxs)(`div`,{className:`py-4 border-b border-stone-100`,children:[(0,p.jsx)(`div`,{className:`text-sm font-medium text-stone-800 mb-3`,children:d(`settings.appearance`,void 0,J)}),(0,p.jsx)(`div`,{className:`grid grid-cols-3 gap-2.5`,children:qe.map(e=>{let t=H.appearance===e.value;return(0,p.jsxs)(`button`,{type:`button`,onClick:()=>Q({appearance:e.value}),className:`flex flex-col items-center justify-center gap-2 h-19 rounded-xl border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] text-[#4176e6] ring-1 ring-[#4176e6]/30`:`border-stone-200 text-stone-500 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,p.jsx)(Te,{kind:e.icon}),(0,p.jsx)(`span`,{className:`text-xs font-medium`,children:e.label})]},e.value)})})]}),(0,p.jsx)(_,{title:d(`settings.fontSize`,void 0,J),description:d(`settings.fontSizeDesc`,void 0,J),control:(0,p.jsxs)(`div`,{className:`inline-flex items-center gap-1.5`,children:[(0,p.jsx)(`input`,{type:`number`,min:12,max:22,value:W,onChange:e=>G(e.target.value),onBlur:Re,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},className:`w-14 h-9 px-2 text-sm text-center rounded-lg bg-stone-100 border-0 outline-none focus:ring-2 focus:ring-[#4176e6]/30`}),(0,p.jsx)(`span`,{className:`text-sm text-stone-400`,children:`px`})]})}),(0,p.jsx)(_,{title:d(`settings.toolSteps`,void 0,J),description:d(`settings.toolStepsDesc`,void 0,J),control:(0,p.jsx)(v,{value:H.toolStepDetail,options:Ge,onChange:e=>Q({toolStepDetail:e})})}),(0,p.jsx)(_,{title:d(`settings.busySend`,void 0,J),description:d(`settings.busySendDesc`,void 0,J),control:(0,p.jsx)(v,{value:H.busySendBehavior,options:Ke,onChange:e=>Q({busySendBehavior:e})})}),(0,p.jsx)(_,{title:d(`settings.subagentModel`,void 0,J),description:d(`settings.subagentModelDesc`,void 0,J),control:(0,p.jsx)(v,{value:H.subagentModel?.trim()?H.subagentModel:`inherit`,options:[{value:`inherit`,label:d(`settings.subagentModel.inherit`,void 0,J)},...Array.from(new Set([...Y?.availableModels??[],...Y?.model?[Y.model]:[]])).filter(Boolean).map(e=>({value:e,label:e}))],onChange:e=>Q({subagentModel:e===`inherit`?``:e})})})]}),(0,p.jsxs)(`div`,{className:`shrink-0 px-6 py-3 border-t border-stone-100 flex items-center justify-between text-[11px] text-stone-400`,children:[(0,p.jsx)(`span`,{children:d(`settings.platformVersion`,void 0,J)}),(0,p.jsxs)(`span`,{className:`tabular-nums text-stone-500`,children:[`v`,ye]})]})]}):q?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`shrink-0 px-5 pt-3 pb-2 flex items-center gap-2 border-b border-stone-100`,children:(0,p.jsx)(`button`,{type:`button`,onClick:()=>w(null),className:`text-sm text-stone-500 hover:text-stone-800`,children:d(`settings.back`,void 0,J)})}),(0,p.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:d(`settings.displayName`,void 0,J)}),(0,p.jsx)(`input`,{type:`text`,value:T,onChange:e=>E(e.target.value),placeholder:`DeepSeek`,className:m})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:d(`settings.preset`,void 0,J)}),(0,p.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:u.map(e=>{let t=Ee===e.label;return(0,p.jsxs)(`button`,{type:`button`,onClick:()=>Le(e.label),className:`text-left px-3 py-2 rounded-lg border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] ring-1 ring-[#4176e6]/30`:`border-stone-200 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,p.jsx)(`div`,{className:`text-sm ${t?`text-[#3565c7] font-medium`:`text-stone-700`}`,children:e.label}),(0,p.jsx)(`div`,{className:`text-[11px] text-stone-400 truncate`,children:e.baseURL?be(e.baseURL):`OpenAI compatible`})]},e.label)})})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:d(`settings.baseUrl`,void 0,J)}),(0,p.jsx)(`input`,{type:`text`,value:O,onChange:e=>k(e.target.value),placeholder:`https://api.deepseek.com/v1`,className:m})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:d(`settings.apiKey`,void 0,J)}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(`input`,{type:De?`text`:`password`,value:A,onChange:e=>j(e.target.value),placeholder:`sk-...`,className:`${m} pr-14`}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>R(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-[11px] text-stone-400 hover:text-stone-600 px-1.5 py-1`,children:De?J===`en`?`Hide`:`隐藏`:J===`en`?`Show`:`显示`})]}),ke?(0,p.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-5`,children:d(`settings.keyHint`,void 0,J)}):null]}),(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,p.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:d(`settings.modelField`,void 0,J)}),I===`loading`&&(0,p.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:d(`settings.recognizing`,void 0,J)}),$&&I===`ok`&&(0,p.jsx)(`span`,{className:`text-[11px] text-emerald-600`,children:d(`settings.recognized`,{n:P.length},J)}),I===`fail`&&!$&&(0,p.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:d(`settings.recognizeFail`,void 0,J)}),I===`fail`&&$&&(0,p.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:d(`settings.recognizeKeep`,void 0,J)})]}),$?(0,p.jsxs)(ne,{value:M,onChange:N,children:[(0,p.jsxs)(a,{className:`${m} flex items-center justify-between text-left hover:border-stone-400 cursor-pointer`,children:[(0,p.jsx)(`span`,{className:`truncate text-stone-800`,children:M||(J===`en`?`Select a model`:`请选择模型`)}),(0,p.jsx)(Se,{className:`w-4 h-4 shrink-0 ml-2 text-stone-400`})]}),(0,p.jsx)(re,{transition:!0,anchor:{to:`bottom start`,gap:6},className:`tw-select-menu tw-menu-anim z-60 w-(--button-width) max-h-60 overflow-auto rounded-lg py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:P.map(e=>(0,p.jsxs)(te,{value:e,className:`group cursor-pointer select-none flex items-center justify-between px-3 py-2 text-sm text-stone-700 data-[focus]:bg-[#edf3fe] data-[selected]:text-[#3565c7] data-[selected]:font-medium`,children:[(0,p.jsx)(`span`,{className:`truncate`,children:e}),(0,p.jsx)(g,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0 ml-2`})]},e))})]}):(0,p.jsx)(`input`,{type:`text`,value:M,onChange:e=>N(e.target.value),placeholder:d(`settings.modelPlaceholder`,void 0,J),className:m})]})]}),(0,p.jsxs)(`div`,{className:`shrink-0 px-5 py-3.5 bg-stone-50 border-t border-stone-100 flex justify-end gap-2`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:()=>w(null),className:`px-3.5 py-1.5 text-sm text-stone-600 hover:bg-stone-200/60 rounded-lg`,children:d(`settings.cancel`,void 0,J)}),(0,p.jsx)(`button`,{type:`button`,onClick:Be,disabled:!ze,className:`px-3.5 py-1.5 text-sm font-medium text-white bg-[#4176e6] hover:bg-[#3565c7] rounded-lg disabled:opacity-40 disabled:cursor-not-allowed`,children:d(`settings.save`,void 0,J)})]})]}):(0,p.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-5 bg-[#f4f5f7]`,children:[(0,p.jsx)(`p`,{className:`text-sm text-stone-500`,children:d(`settings.modelIntro`,void 0,J)}),(0,p.jsxs)(`div`,{className:`mt-5 space-y-2.5`,children:[y.map(e=>{let t=!!(e.apiKey?.trim()&&e.baseURL.trim()&&e.model.trim()),n=e.id===x;return(0,p.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-stone-200/90 bg-white px-4 py-3.5 shadow-[0_1px_0_rgba(15,23,42,0.02)]`,children:[(0,p.jsxs)(`button`,{type:`button`,"data-hint":n?J===`en`?`Active`:`当前使用`:J===`en`?`Set active`:`设为当前`,onClick:()=>Ue(e.id),className:`flex-1 min-w-0 flex items-center gap-2 text-left`,children:[(0,p.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:e.name}),t?(0,p.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 bg-emerald-500`}):null]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:()=>Ie(e),className:`h-8 px-3 text-sm text-stone-700 rounded-lg border border-stone-200 bg-white hover:bg-stone-50`,children:d(`settings.edit`,void 0,J)}),y.length>1?(0,p.jsx)(`button`,{type:`button`,onClick:()=>Ve(e.id),className:`h-8 px-3 text-sm text-red-600 rounded-lg hover:bg-red-50`,children:d(`settings.delete`,void 0,J)}):null]})]},e.id)}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>Ie(null),className:`w-full h-12 rounded-xl border border-dashed border-stone-300 bg-white/60 text-sm text-stone-600 hover:border-[#4176e6] hover:text-[#4176e6] hover:bg-[#edf3fe]/50 transition-colors`,children:d(`settings.addProvider`,void 0,J)})]})]})})]})]})})]})}),(0,p.jsx)(oe,{open:Me!=null,title:d(`settings.delete`,void 0,J),message:d(`settings.deleteConfirm`,void 0,J),confirmLabel:d(`settings.delete`,void 0,J),cancelLabel:J===`en`?`Cancel`:`取消`,danger:!0,onClose:()=>V(null),onConfirm:He})]})}export{y as default};
1
+ import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{a as n,i as r,n as i,s as ee}from"./app-config.huKxSIlN.js";import{i as a,n as te,r as ne,t as re}from"./listbox.Di-t5U37.js";import{a as ie,o as ae}from"./dialog.DXHznyjD.js";import{t as o}from"./jsx-runtime.BUXbF_vF.js";import{t as oe}from"./ConfirmDialog.CBVsDJ8f.js";import{i as se}from"./llm.BZEzE0x2.js";import{_ as ce,a as s,c as le,d as ue,g as c,h as de,i as fe,l,n as u,o as pe,r as me,s as he,t as ge,u as _e,v as ve}from"./settings.CMK4PEak.js";import{n as d}from"./i18n.Bbh04ngD.js";var f=e(t(),1),ye=`0.1.6`,p=o();function be(e){try{return new URL(e).host}catch{return``}}var xe=[{value:`zh-CN`,label:`中文`},{value:`en`,label:`English`}],m=`w-full px-3 py-2 text-sm border border-stone-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-[#4176e6]/35 focus:border-[#4176e6] transition-colors`,h=`inline-flex items-center gap-1.5 h-9 min-w-30 px-3 rounded-lg bg-stone-100 text-sm text-stone-700 hover:bg-stone-200/80 transition-colors outline-none focus:outline-none`;function Se({className:e=`w-3.5 h-3.5`}){return(0,p.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:(0,p.jsx)(`path`,{d:`M6 8l4 4 4-4`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function g({className:e=`w-4 h-4`}){return(0,p.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,p.jsx)(`path`,{d:`M5 10.5l3.5 3.5L15 6.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function Ce({className:e=`w-4 h-4`}){return(0,p.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,p.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,p.jsx)(`path`,{d:`M12 1v2M12 21v2M4.2 4.2l1.4 1.4M18.4 18.4l1.4 1.4M1 12h2M21 12h2M4.2 19.8l1.4-1.4M18.4 5.6l1.4-1.4`})]})}function we({className:e=`w-4 h-4`}){return(0,p.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,p.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,p.jsx)(`path`,{d:`M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5`}),(0,p.jsx)(`path`,{d:`M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]})}function Te({kind:e}){let t=`w-5 h-5`;return e===`sun`?(0,p.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,p.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,p.jsx)(`path`,{d:`M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`})]}):e===`moon`?(0,p.jsx)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,p.jsx)(`path`,{d:`M21 14.5A8.5 8.5 0 1 1 9.5 3a7 7 0 0 0 11.5 11.5z`})}):(0,p.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,p.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`12`,rx:`2`}),(0,p.jsx)(`path`,{d:`M8 20h8M12 16v4`})]})}function _({title:e,description:t,control:n}){return(0,p.jsxs)(`div`,{className:`flex items-center gap-4 py-4 border-b border-stone-100 last:border-b-0`,children:[(0,p.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,p.jsx)(`div`,{className:`text-sm font-medium text-stone-800`,children:e}),t?(0,p.jsx)(`div`,{className:`mt-0.5 text-xs text-stone-400 leading-5`,children:t}):null]}),(0,p.jsx)(`div`,{className:`shrink-0`,children:n})]})}function v({value:e,options:t,onChange:n}){let r=t.find(t=>t.value===e)?.label??e;return(0,p.jsxs)(ne,{value:e,onChange:n,children:[(0,p.jsxs)(a,{className:h,children:[(0,p.jsx)(`span`,{className:`flex-1 text-left truncate`,children:r}),(0,p.jsx)(Se,{className:`w-3.5 h-3.5 text-stone-400 shrink-0`})]}),(0,p.jsx)(re,{transition:!0,anchor:{to:`bottom end`,gap:6},className:`tw-select-menu tw-menu-anim z-60 min-w-40 rounded-xl py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:t.map(e=>(0,p.jsxs)(te,{value:e.value,className:`group cursor-pointer select-none flex items-center justify-between gap-3 px-3 py-2 text-sm text-stone-700 data-[focus]:bg-stone-50 data-[selected]:text-stone-900`,children:[(0,p.jsx)(`span`,{children:e.label}),(0,p.jsx)(g,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0`})]},e.value))})]})}function y(){let[e,t]=(0,f.useState)(!1),[o,h]=(0,f.useState)(`general`),[y,b]=(0,f.useState)([]),[x,S]=(0,f.useState)(``),[C,w]=(0,f.useState)(null),[T,E]=(0,f.useState)(``),[Ee,D]=(0,f.useState)(`DeepSeek`),[O,k]=(0,f.useState)(``),[A,j]=(0,f.useState)(``),[M,N]=(0,f.useState)(``),[P,F]=(0,f.useState)([]),[I,L]=(0,f.useState)(`idle`),[De,R]=(0,f.useState)(!1),[Oe,z]=(0,f.useState)(`readonly`),[ke,Ae]=(0,f.useState)(!1),[je,B]=(0,f.useState)(!1),[Me,V]=(0,f.useState)(null),[H,U]=(0,f.useState)({language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``}),[W,G]=(0,f.useState)(`14`),K=(0,f.useRef)(0),q=C!==null,J=H.language,Y=y.find(e=>e.id===x),X=(Y?.name||``).trim(),Ne=X||(J===`en`?`No model`:`未配置`),Pe=X?Y?.model?.trim()?`${X} · ${Y.model.trim()}`:X:J===`en`?`No model configured`:`未配置模型`;function Fe(e=`general`){h(e),r().then(()=>{Z(),t(!0)})}function Z(){Ae(n()),b(le()),S(s()),B(!!l()),U(he()),me(he()),z(pe()),w(null)}function Ie(e){if(!e){let e=ee();w(e),E(`DeepSeek`),D(`DeepSeek`),k(`https://api.deepseek.com/v1`),j(``),N(``),F([]),L(`idle`),R(!1);return}w(e.id),E(e.name),k(e.baseURL);let t=e.apiKey?.trim()||(e.id===s()?i().trim():``)||``;j(t),N(e.model),F(e.availableModels??[]),L(e.availableModels?.length?`ok`:`idle`),D(u.find(t=>t.baseURL===e.baseURL)?.label??`自定义`),R(!1)}(0,f.useEffect)(()=>{r().then(()=>Z());let e=e=>{let n=e.detail;h(n?.tab===`model`?`model`:`general`),r().then(()=>{Z(),t(!0)})};window.addEventListener(ge,e);let n=ue(e=>U(e)),i=_e(e=>z(e));return()=>{window.removeEventListener(ge,e),n(),i()}},[]),(0,f.useEffect)(()=>{if(!e||o!==`model`||!q)return;let t=O.trim(),n=A.trim();if(!t||!n){L(e=>e===`ok`?`ok`:`idle`);return}L(`loading`);let r=++K.current,i=setTimeout(()=>{se(t,n).then(e=>{r===K.current&&(F(e),L(`ok`))}).catch(()=>{r===K.current&&L(`fail`)})},800);return()=>clearTimeout(i)},[e,o,q,O,A]);function Le(e){D(e);let t=u.find(t=>t.label===e);t&&(t.baseURL&&k(t.baseURL),(!T.trim()||u.some(e=>e.label===T))&&E(t.label)),N(``)}function Q(e){U(c(e))}(0,f.useEffect)(()=>{G(String(H.sessionFontSize))},[H.sessionFontSize]);function Re(){let e=Number(W);if(!W.trim()||!Number.isFinite(e)){G(String(H.sessionFontSize));return}let t=c({sessionFontSize:Math.round(e)});U(t),G(String(t.sessionFontSize))}let ze=!!(T.trim()&&O.trim()&&A.trim()&&M.trim()),$=P.length>0;function Be(){if(!ze||!C)return;let e=ve({id:C,name:T.trim(),baseURL:O.trim(),apiKey:A.trim(),model:M.trim(),availableModels:$?P:void 0},{activate:!0});b(e),S(C),w(null),B(!!l())}function Ve(e){V(e)}function He(){let e=Me;if(!e)return;V(null);let t=fe(e);b(t),S(s()),C===e&&w(null),B(!!l())}function Ue(e){ce(e),S(e),B(!!l())}let We=[{value:`readonly`,label:d(`settings.access.readonly`,void 0,J)},{value:`readwrite`,label:d(`settings.access.readwrite`,void 0,J)},{value:`full`,label:d(`settings.access.full`,void 0,J)}],Ge=[{value:`concise`,label:d(`settings.step.concise`,void 0,J)},{value:`standard`,label:d(`settings.step.standard`,void 0,J)},{value:`detailed`,label:d(`settings.step.detailed`,void 0,J)},{value:`full`,label:d(`settings.step.full`,void 0,J)}],Ke=[{value:`queue`,label:d(`settings.busySend.queue`,void 0,J)},{value:`interrupt`,label:d(`settings.busySend.interrupt`,void 0,J)}],qe=[{value:`light`,label:d(`settings.appear.light`,void 0,J),icon:`sun`},{value:`dark`,label:d(`settings.appear.dark`,void 0,J),icon:`moon`},{value:`system`,label:d(`settings.appear.system`,void 0,J),icon:`monitor`}],Je=[{id:`general`,label:d(`settings.general`,void 0,J),icon:(0,p.jsx)(Ce,{})},{id:`model`,label:d(`settings.model`,void 0,J),icon:(0,p.jsx)(we,{})}],Ye=o===`general`?d(`settings.general`,void 0,J):q?y.some(e=>e.id===C)?d(`settings.editProvider`,void 0,J):d(`settings.addProviderTitle`,void 0,J):d(`settings.model`,void 0,J);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`tw-nav-foot-row`,children:[(0,p.jsxs)(`button`,{type:`button`,onClick:()=>Fe(`general`),className:`tw-nav-settings-btn`,"data-hint":je?`设置(已配置模型)`:`设置`,children:[(0,p.jsxs)(`svg`,{className:`tw-nav-ico w-4.5 h-4.5 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":`true`,children:[(0,p.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,p.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9c.2.6.7 1 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z`})]}),(0,p.jsx)(`span`,{"data-i18n":`nav.settings`,children:d(`nav.settings`,void 0,J)})]}),(0,p.jsxs)(`button`,{type:`button`,className:`tw-nav-provider-chip${X?``:` is-empty`}`,"data-hint":Pe,onClick:()=>Fe(`model`),children:[(0,p.jsx)(`span`,{className:`tw-nav-provider-dot`,"aria-hidden":`true`}),(0,p.jsx)(`span`,{className:`tw-nav-provider-name`,children:Ne})]})]}),(0,p.jsx)(ie,{show:e,children:(0,p.jsxs)(`div`,{className:`fixed inset-0 z-110 flex items-center justify-center p-4`,children:[(0,p.jsx)(ae,{children:(0,p.jsx)(`div`,{className:`tw-dialog-backdrop-anim absolute inset-0 bg-stone-950/45`,onClick:()=>t(!1),"aria-hidden":`true`})}),(0,p.jsx)(ae,{children:(0,p.jsxs)(`div`,{className:`tw-settings-dialog tw-dialog-panel-anim relative bg-white rounded-2xl shadow-2xl w-full max-w-3xl h-[min(92vh,720px)] overflow-hidden flex flex-col`,children:[(0,p.jsxs)(`div`,{className:`shrink-0 h-12 px-4 flex items-center justify-between border-b border-stone-100 bg-white`,children:[(0,p.jsx)(`h2`,{className:`text-sm font-semibold text-stone-800 truncate pr-3`,children:Ye}),(0,p.jsx)(`button`,{type:`button`,"aria-label":d(`settings.close`,void 0,J),onClick:()=>t(!1),className:`w-8 h-8 inline-flex items-center justify-center rounded-lg text-stone-400 hover:text-stone-700 hover:bg-stone-100 transition-colors`,children:(0,p.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,p.jsx)(`path`,{d:`M5 5l10 10M15 5L5 15`,strokeLinecap:`round`})})})]}),(0,p.jsxs)(`div`,{className:`flex-1 min-h-0 flex`,children:[(0,p.jsx)(`aside`,{className:`w-38 shrink-0 border-r border-stone-100 bg-[#f4f5f7] py-3 px-2 space-y-0.5`,children:Je.map(e=>{let t=o===e.id;return(0,p.jsxs)(`button`,{type:`button`,onClick:()=>{h(e.id),e.id===`model`&&w(null)},className:`w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-sm transition-colors ${t?`bg-[#e8f0fe] text-[#4176e6] font-medium`:`text-stone-600 hover:bg-white/70 hover:text-stone-800`}`,children:[(0,p.jsx)(`span`,{className:t?`text-[#4176e6]`:`text-stone-400`,children:e.icon}),e.label]},e.id)})}),(0,p.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0 bg-white`,children:o===`general`?(0,p.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,p.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-1`,children:[(0,p.jsx)(_,{title:d(`settings.access`,void 0,J),description:d(`settings.accessDesc`,void 0,J),control:(0,p.jsx)(v,{value:Oe,options:We,onChange:e=>{z(e),de(e)}})}),(0,p.jsx)(_,{title:d(`settings.language`,void 0,J),control:(0,p.jsx)(v,{value:H.language,options:xe,onChange:e=>Q({language:e})})}),(0,p.jsxs)(`div`,{className:`py-4 border-b border-stone-100`,children:[(0,p.jsx)(`div`,{className:`text-sm font-medium text-stone-800 mb-3`,children:d(`settings.appearance`,void 0,J)}),(0,p.jsx)(`div`,{className:`grid grid-cols-3 gap-2.5`,children:qe.map(e=>{let t=H.appearance===e.value;return(0,p.jsxs)(`button`,{type:`button`,onClick:()=>Q({appearance:e.value}),className:`flex flex-col items-center justify-center gap-2 h-19 rounded-xl border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] text-[#4176e6] ring-1 ring-[#4176e6]/30`:`border-stone-200 text-stone-500 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,p.jsx)(Te,{kind:e.icon}),(0,p.jsx)(`span`,{className:`text-xs font-medium`,children:e.label})]},e.value)})})]}),(0,p.jsx)(_,{title:d(`settings.fontSize`,void 0,J),description:d(`settings.fontSizeDesc`,void 0,J),control:(0,p.jsxs)(`div`,{className:`inline-flex items-center gap-1.5`,children:[(0,p.jsx)(`input`,{type:`number`,min:12,max:22,value:W,onChange:e=>G(e.target.value),onBlur:Re,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},className:`w-14 h-9 px-2 text-sm text-center rounded-lg bg-stone-100 border-0 outline-none focus:ring-2 focus:ring-[#4176e6]/30`}),(0,p.jsx)(`span`,{className:`text-sm text-stone-400`,children:`px`})]})}),(0,p.jsx)(_,{title:d(`settings.toolSteps`,void 0,J),description:d(`settings.toolStepsDesc`,void 0,J),control:(0,p.jsx)(v,{value:H.toolStepDetail,options:Ge,onChange:e=>Q({toolStepDetail:e})})}),(0,p.jsx)(_,{title:d(`settings.busySend`,void 0,J),description:d(`settings.busySendDesc`,void 0,J),control:(0,p.jsx)(v,{value:H.busySendBehavior,options:Ke,onChange:e=>Q({busySendBehavior:e})})}),(0,p.jsx)(_,{title:d(`settings.subagentModel`,void 0,J),description:d(`settings.subagentModelDesc`,void 0,J),control:(0,p.jsx)(v,{value:H.subagentModel?.trim()?H.subagentModel:`inherit`,options:[{value:`inherit`,label:d(`settings.subagentModel.inherit`,void 0,J)},...Array.from(new Set([...Y?.availableModels??[],...Y?.model?[Y.model]:[]])).filter(Boolean).map(e=>({value:e,label:e}))],onChange:e=>Q({subagentModel:e===`inherit`?``:e})})})]}),(0,p.jsxs)(`div`,{className:`shrink-0 px-6 py-3 border-t border-stone-100 flex items-center justify-between text-[11px] text-stone-400`,children:[(0,p.jsx)(`span`,{children:d(`settings.platformVersion`,void 0,J)}),(0,p.jsxs)(`span`,{className:`tabular-nums text-stone-500`,children:[`v`,ye]})]})]}):q?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`shrink-0 px-5 pt-3 pb-2 flex items-center gap-2 border-b border-stone-100`,children:(0,p.jsx)(`button`,{type:`button`,onClick:()=>w(null),className:`text-sm text-stone-500 hover:text-stone-800`,children:d(`settings.back`,void 0,J)})}),(0,p.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:d(`settings.displayName`,void 0,J)}),(0,p.jsx)(`input`,{type:`text`,value:T,onChange:e=>E(e.target.value),placeholder:`DeepSeek`,className:m})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:d(`settings.preset`,void 0,J)}),(0,p.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:u.map(e=>{let t=Ee===e.label;return(0,p.jsxs)(`button`,{type:`button`,onClick:()=>Le(e.label),className:`text-left px-3 py-2 rounded-lg border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] ring-1 ring-[#4176e6]/30`:`border-stone-200 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,p.jsx)(`div`,{className:`text-sm ${t?`text-[#3565c7] font-medium`:`text-stone-700`}`,children:e.label}),(0,p.jsx)(`div`,{className:`text-[11px] text-stone-400 truncate`,children:e.baseURL?be(e.baseURL):`OpenAI compatible`})]},e.label)})})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:d(`settings.baseUrl`,void 0,J)}),(0,p.jsx)(`input`,{type:`text`,value:O,onChange:e=>k(e.target.value),placeholder:`https://api.deepseek.com/v1`,className:m})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:d(`settings.apiKey`,void 0,J)}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(`input`,{type:De?`text`:`password`,value:A,onChange:e=>j(e.target.value),placeholder:`sk-...`,className:`${m} pr-14`}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>R(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-[11px] text-stone-400 hover:text-stone-600 px-1.5 py-1`,children:De?J===`en`?`Hide`:`隐藏`:J===`en`?`Show`:`显示`})]}),ke?(0,p.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-5`,children:d(`settings.keyHint`,void 0,J)}):null]}),(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,p.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:d(`settings.modelField`,void 0,J)}),I===`loading`&&(0,p.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:d(`settings.recognizing`,void 0,J)}),$&&I===`ok`&&(0,p.jsx)(`span`,{className:`text-[11px] text-emerald-600`,children:d(`settings.recognized`,{n:P.length},J)}),I===`fail`&&!$&&(0,p.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:d(`settings.recognizeFail`,void 0,J)}),I===`fail`&&$&&(0,p.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:d(`settings.recognizeKeep`,void 0,J)})]}),$?(0,p.jsxs)(ne,{value:M,onChange:N,children:[(0,p.jsxs)(a,{className:`${m} flex items-center justify-between text-left hover:border-stone-400 cursor-pointer`,children:[(0,p.jsx)(`span`,{className:`truncate text-stone-800`,children:M||(J===`en`?`Select a model`:`请选择模型`)}),(0,p.jsx)(Se,{className:`w-4 h-4 shrink-0 ml-2 text-stone-400`})]}),(0,p.jsx)(re,{transition:!0,anchor:{to:`bottom start`,gap:6},className:`tw-select-menu tw-menu-anim z-60 w-(--button-width) max-h-60 overflow-auto rounded-lg py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:P.map(e=>(0,p.jsxs)(te,{value:e,className:`group cursor-pointer select-none flex items-center justify-between px-3 py-2 text-sm text-stone-700 data-[focus]:bg-[#edf3fe] data-[selected]:text-[#3565c7] data-[selected]:font-medium`,children:[(0,p.jsx)(`span`,{className:`truncate`,children:e}),(0,p.jsx)(g,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0 ml-2`})]},e))})]}):(0,p.jsx)(`input`,{type:`text`,value:M,onChange:e=>N(e.target.value),placeholder:d(`settings.modelPlaceholder`,void 0,J),className:m})]})]}),(0,p.jsxs)(`div`,{className:`shrink-0 px-5 py-3.5 bg-stone-50 border-t border-stone-100 flex justify-end gap-2`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:()=>w(null),className:`px-3.5 py-1.5 text-sm text-stone-600 hover:bg-stone-200/60 rounded-lg`,children:d(`settings.cancel`,void 0,J)}),(0,p.jsx)(`button`,{type:`button`,onClick:Be,disabled:!ze,className:`px-3.5 py-1.5 text-sm font-medium text-white bg-[#4176e6] hover:bg-[#3565c7] rounded-lg disabled:opacity-40 disabled:cursor-not-allowed`,children:d(`settings.save`,void 0,J)})]})]}):(0,p.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-5 bg-[#f4f5f7]`,children:[(0,p.jsx)(`p`,{className:`text-sm text-stone-500`,children:d(`settings.modelIntro`,void 0,J)}),(0,p.jsxs)(`div`,{className:`mt-5 space-y-2.5`,children:[y.map(e=>{let t=!!(e.apiKey?.trim()&&e.baseURL.trim()&&e.model.trim()),n=e.id===x;return(0,p.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-stone-200/90 bg-white px-4 py-3.5 shadow-[0_1px_0_rgba(15,23,42,0.02)]`,children:[(0,p.jsxs)(`button`,{type:`button`,"data-hint":n?J===`en`?`Active`:`当前使用`:J===`en`?`Set active`:`设为当前`,onClick:()=>Ue(e.id),className:`flex-1 min-w-0 flex items-center gap-2 text-left`,children:[(0,p.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:e.name}),t?(0,p.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 bg-emerald-500`}):null]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:()=>Ie(e),className:`h-8 px-3 text-sm text-stone-700 rounded-lg border border-stone-200 bg-white hover:bg-stone-50`,children:d(`settings.edit`,void 0,J)}),y.length>1?(0,p.jsx)(`button`,{type:`button`,onClick:()=>Ve(e.id),className:`h-8 px-3 text-sm text-red-600 rounded-lg hover:bg-red-50`,children:d(`settings.delete`,void 0,J)}):null]})]},e.id)}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>Ie(null),className:`w-full h-12 rounded-xl border border-dashed border-stone-300 bg-white/60 text-sm text-stone-600 hover:border-[#4176e6] hover:text-[#4176e6] hover:bg-[#edf3fe]/50 transition-colors`,children:d(`settings.addProvider`,void 0,J)})]})]})})]})]})})]})}),(0,p.jsx)(oe,{open:Me!=null,title:d(`settings.delete`,void 0,J),message:d(`settings.deleteConfirm`,void 0,J),confirmLabel:d(`settings.delete`,void 0,J),cancelLabel:J===`en`?`Cancel`:`取消`,danger:!0,onClose:()=>V(null),onConfirm:He})]})}export{y as default};
@@ -0,0 +1 @@
1
+ import{c as e,n as t,t as n}from"./react-dom.CqAxpHMt.js";import{t as r}from"./jsx-runtime.BUXbF_vF.js";var i=e(t(),1),a=e(n(),1),o=r(),s=220;function c({open:e,onClose:t,title:n,closeAriaLabel:r=`关闭面板`,children:c,footer:l}){let[u,d]=(0,i.useState)(e),[f,p]=(0,i.useState)(!1);if((0,i.useEffect)(()=>{if(e){d(!0);let e=window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>p(!0))});return()=>window.cancelAnimationFrame(e)}p(!1);let t=window.setTimeout(()=>d(!1),s);return()=>window.clearTimeout(t)},[e]),(0,i.useEffect)(()=>{if(!e)return;function n(e){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),t())}return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e,t]),!u)return null;let m=(0,o.jsxs)(`div`,{className:`fixed inset-0 z-60 flex justify-end`,role:`dialog`,"aria-modal":`true`,children:[(0,o.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-stone-900/30 transition-opacity duration-200 ease-out ${f?`opacity-100`:`opacity-0`}`,"aria-label":r,onClick:t}),(0,o.jsxs)(`aside`,{className:`tw-slide-over relative w-full max-w-md h-full shadow-2xl border-l border-stone-200 flex flex-col transition-transform duration-200 ease-out will-change-transform ${f?`translate-x-0`:`translate-x-full`}`,children:[(0,o.jsxs)(`header`,{className:`shrink-0 h-12 px-4 border-b border-stone-100 flex items-center gap-2`,children:[(0,o.jsx)(`h2`,{className:`tw-slide-over-title text-sm font-semibold text-stone-800 flex-1`,children:n}),(0,o.jsx)(`button`,{type:`button`,onClick:t,className:`tw-icon-btn w-8 h-8 rounded-lg`,"data-hint":`关闭(Esc)`,children:`✕`})]}),(0,o.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 space-y-4`,children:c}),l]})]});return typeof document>`u`?m:(0,a.createPortal)(m,document.body)}export{c as t};
@@ -0,0 +1,7 @@
1
+ import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{f as n,i as r}from"./app-config.huKxSIlN.js";import{i,n as a,r as o,t as s}from"./dialog.DXHznyjD.js";import{i as c,n as l,r as ee,t as u}from"./menu.Bkluqxic.js";import{t as d}from"./jsx-runtime.BUXbF_vF.js";import{t as f}from"./ConfirmDialog.CBVsDJ8f.js";import{n as p}from"./llm.BZEzE0x2.js";import{f as m}from"./project-docs.Cd2gKPKh.js";import{t as h}from"./prompts-meta.F4wwkjUA.js";import{l as te}from"./settings.CMK4PEak.js";import{n as g}from"./i18n.Bbh04ngD.js";import{a as _,c as ne,d as re,f as v,i as y,l as ie,m as ae,n as oe,o as b,p as se,r as ce,s as le,t as ue,u as de}from"./spaces-client.CoQfaOIO.js";var x=e(t(),1),fe=`你是提示词作者。根据用户对这个数据空间的要求,写一份「默认提示词」正文(Markdown 纯文本,不要用代码围栏)。
2
+ 这份提示词将作为 Lantern Harness 该空间里 AI 助手的默认人设与回答原则。
3
+ 要求:
4
+ - 用「你是…」起头设定角色;
5
+ - 紧扣用户描述的领域与工作方式;
6
+ - 写几条简洁的回答原则(问什么答什么、先结论);
7
+ - 只输出提示词正文,不要解释、不要标题。`;function pe(e){let t=String(e??``).replace(/^\uFEFF/,``).trim(),n=/^```(?:markdown|md|text)?\s*\n([\s\S]*?)\n```$/i.exec(t);return n&&(t=n[1].trim()),t}var S=d();function me(e){return e instanceof DOMException&&e.name===`AbortError`||e instanceof Error&&e.name===`AbortError`}function he({hint:e,children:t}){return e?(0,S.jsx)(`span`,{className:`inline-flex cursor-help`,"data-hint":e,"data-hint-always":``,children:t}):t}function ge(e){let{value:t,onChange:n,onGenerate:r,onStop:i,generating:a,disabled:o}=e,s=(0,x.useRef)(null);(0,x.useLayoutEffect)(()=>{let e=s.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,96)}px`)},[t]);let c=!!t.trim()&&!a&&!o;return(0,S.jsxs)(`div`,{className:`tw-space-prompt-composer pt-1 rounded-lg bg-white border border-stone-200 outline-none transition-colors focus-within:ring-2 focus-within:ring-[#4176e6]/30 focus-within:border-[#4176e6]`,children:[(0,S.jsx)(`textarea`,{ref:s,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing){if(e.preventDefault(),a){i();return}c&&r()}},placeholder:g(`space.promptBriefPlaceholder`),rows:1,disabled:o,className:`block w-full min-h-6 pl-3.5 pr-2 pt-0.5 pb-0 text-sm leading-5 text-stone-800 bg-transparent resize-none focus:outline-none placeholder:text-stone-400 disabled:opacity-60`}),(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-2 px-3 pb-2 pt-1`,children:[(0,S.jsx)(`span`,{className:`flex-1`}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>a?i():r(),disabled:!a&&!c,"aria-label":g(a?`space.promptStop`:`space.promptGenerate`),className:`w-7 h-7 shrink-0 rounded-full flex items-center justify-center outline-none transition-colors ${a?`bg-stone-200 text-stone-700 hover:bg-stone-300`:`bg-[#4176e6] text-white hover:bg-[#3565c7] disabled:bg-[#a9c3ef] disabled:cursor-not-allowed`}`,children:a?(0,S.jsx)(`span`,{className:`w-2.5 h-2.5 bg-current rounded-xs`}):(0,S.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:`w-4 h-4`,"aria-hidden":!0,children:[(0,S.jsx)(`path`,{d:`m5 12 7-7 7 7`}),(0,S.jsx)(`path`,{d:`M12 19V5`})]})})]})]})}function _e(e){return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2 mb-1.5`,children:[(0,S.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:g(`space.promptBodyLabel`)}),(0,S.jsx)(`span`,{className:`text-[11px] text-stone-400 font-mono truncate`,children:h})]}),(0,S.jsx)(`textarea`,{value:e.value,onChange:t=>e.onChange(t.target.value),placeholder:g(`space.promptBodyPlaceholder`),rows:8,disabled:e.disabled,className:`w-full min-h-36 px-3 py-2 text-sm leading-relaxed rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors resize-y font-[inherit]`}),(0,S.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-snug`,children:e.hint??g(`space.promptHint`)})]})}function C({open:e,onClose:t,onListChanged:c}){let[l,ee]=(0,x.useState)(null),[u,d]=(0,x.useState)(null),[v,C]=(0,x.useState)(``),[w,T]=(0,x.useState)(``),[E,D]=(0,x.useState)(!1),[O,k]=(0,x.useState)(``),[A,ve]=(0,x.useState)(``),[ye,j]=(0,x.useState)(``),[M,N]=(0,x.useState)(null),[P,F]=(0,x.useState)(``),[I,L]=(0,x.useState)(``),[be,R]=(0,x.useState)(``),[z,xe]=(0,x.useState)(!1),[Se,B]=(0,x.useState)(!1),[V,H]=(0,x.useState)(null),[U,W]=(0,x.useState)(null),[Ce,we]=(0,x.useState)(``),[G,K]=(0,x.useState)([]),[Te,q]=(0,x.useState)({}),Ee=(0,x.useRef)(null),De=(0,x.useRef)(null),Oe=(0,x.useRef)(null),J=(0,x.useRef)(null),[ke,Ae]=(0,x.useState)(null),Y=(0,x.useCallback)(async(e=!1)=>{e&&d(`stats`);let t=await re({stats:e});e&&d(null),t?(ee(t),c?.(t)):C(`无法读取数据空间列表(本地服务未运行?)`)},[c]),je=(0,x.useRef)(Y);(0,x.useEffect)(()=>{je.current=Y},[Y]);function X(){J.current?.abort()}(0,x.useEffect)(()=>{e?(C(``),T(``),D(!1),N(null),je.current(!1)):(X(),D(!1),N(null),Ae(null))},[e]);async function Me(e){if(ke||u!==null)return;let t=(e===`create`?A:I).trim();if(!t){C(g(`space.promptNeedReq`));return}C(``);let n=new AbortController;J.current=n,Ae(e);try{await r();let i=te();if(!i?.apiKey?.trim()||!i.model?.trim()||!i.baseURL?.trim()){C(g(`space.promptNeedModel`));return}let a=(e===`create`?O:P).trim(),o=await p(i,[{role:`system`,content:fe},{role:`user`,content:(a?`空间名称:${a}\n\n`:``)+`用户要求:\n${t}`}],n.signal);if(n.signal.aborted)return;let s=pe(o);if(!s){C(g(`space.promptGenEmpty`));return}e===`create`?j(s):R(s)}catch(e){if(me(e)||n.signal.aborted)return;C(e instanceof Error?e.message:String(e))}finally{J.current===n&&(J.current=null),Ae(null)}}function Ne(){X(),C(``),T(``),k(``),ve(``),j(``),D(!0),requestAnimationFrame(()=>De.current?.scrollIntoView({block:`nearest`}))}async function Pe(){if(u!==null)return;let e=O.trim();if(!e){C(g(`space.needName`));return}X();let t=ye.trim(),r=A.trim();d(`create`),C(``);let i=await oe(e,{switch:!0,...t?{systemPrompt:t}:{},...r?{promptBrief:r}:{}});if(d(null),!i.ok){C(i.error||g(`space.create`)+` 失败`);return}let a=i.space?.id;a&&n(a),window.location.reload()}async function Fe(e){X(),C(``),T(``),N(e),F(e.name),L(``),B(!1),R(``),xe(!0),requestAnimationFrame(()=>Oe.current?.scrollIntoView({block:`nearest`}));let t=await ne(e.id),n=``,r=``;if(t.ok)n=t.brief??``,r=t.systemPrompt??``;else if(e.isActive)try{r=(await m(`prompts`,h)).content.trim()}catch{}if(xe(!1),!t.ok&&!r){N(null),C(t.error||g(`space.detailFailed`));return}t.space&&F(t.space.name),R(r);let i=!n.trim()&&!!r;L(i?r:n),B(i)}async function Ie(){if(!M||u!==null)return;let e=P.trim();if(!e){C(g(`space.needName`));return}X(),d(`update`),C(``);let t=await ae(M.id,{name:e,...Se?{}:{brief:I},systemPrompt:be});if(d(null),!t.ok){C(t.error||g(`space.updateFailed`));return}let n=!!(t.space&&t.space.name!==M.name),r=M.isActive;N(null),T(g(`space.updated`,{name:t.space?.name??e})),n&&r?window.location.reload():await Y(!1)}async function Le(e){if(e.isActive||u!==null)return;d(`update`),C(``);let t=await se(e.id);d(null),t.ok?window.location.reload():C(t.error||`切换失败`)}async function Re(){if(!U)return;let e=Ce.trim();if(!e)return;d(`copy`),C(``);let t=await ue(U.id,e);d(null),t.ok?(W(null),T(`已复制为「${t.space?.name}」`),await Y(!1)):C(t.error||`复制失败`)}async function ze(e,t){d(`delete`),C(``);let r=await ce(e.id,t);d(null),r.ok?(H(null),e.isActive?(n(`public`),window.location.reload()):(T(r.warning?r.warning:r.purged?`已删除「${e.name}」及其数据`:`已从列表移除「${e.name}」(数据保留在磁盘)`),await Y(!1))):C(r.error||`删除失败`)}async function Be(){d(`discover`),C(``),T(``),K([]);let e=await y();if(d(null),!e.ok){C(e.error||`扫描失败`);return}let t=e.added?.length??0,n=e.backfilled?.length??0,r=e.skipped?.length??0,i=e.candidates??[],a=[];t?a.push(g(`space.discoverAdded`,{n:t})):i.length||a.push(g(`space.discoverNone`)),n&&a.push(g(`space.discoverBackfilled`,{n})),r&&a.push(g(`space.discoverSkipped`,{n:r})),T(a.join(`;`)),K(i),q(Object.fromEntries(i.map(e=>[e.path,e.hasContent===!0]))),await Y(!1)}async function Ve(){let e=G.filter(e=>Te[e.path]).map(e=>e.path);if(!e.length){K([]),T(g(`space.candidatesIgnored`));return}d(`discover`),C(``);let t=await y(e);if(d(null),!t.ok){C(t.error||`纳入失败`);return}K([]);let n=t.added?.length??0,r=t.skipped??[],i=[n?g(`space.candidatesAdopted`,{n}):g(`space.candidatesIgnored`)];r.length&&i.push(g(`space.candidatesRejected`,{names:r.map(e=>e.reason).join(`、`)})),T(i.join(`;`)),await Y(!1)}async function He(e){let t=e.target.files?.[0];if(e.target.value=``,!t)return;d(`import`),C(``);let n=await de(t);d(null),n.ok?(T(`已导入为「${n.space?.name}」`),await Y(!1)):C(n.error||`导入失败`)}let Z=l?.spaces??[],Ue=new Map(Z.map((e,t)=>[e.id,t])),We=e=>e.isPublic?0:e.isActive?1:2,Ge=[...Z].sort((e,t)=>We(e)-We(t)||(Ue.get(e.id)??0)-(Ue.get(t.id)??0)),Q=l?.baseRoot,$=u!==null,Ke=ke===`create`,qe=ke===`edit`;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(o,{open:e,onClose:t,transition:!0,className:`relative z-95`,children:[(0,S.jsx)(s,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,S.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,S.jsxs)(i,{transition:!0,className:`tw-dialog-panel-anim tw-space-dialog w-full max-w-4xl rounded-xl shadow-xl border border-stone-200 bg-white flex flex-col h-[86vh]`,children:[(0,S.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-5 pt-4 pb-3 border-b border-stone-200`,children:[(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(a,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:g(`space.manageTitle`)}),(0,S.jsx)(`p`,{className:`mt-1 text-xs text-stone-500 leading-relaxed`,children:g(`space.manageDesc`)})]}),(0,S.jsx)(`div`,{className:`shrink-0 flex items-center gap-2`,children:(0,S.jsx)(`button`,{type:`button`,onClick:t,className:`tw-confirm-cancel 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,S.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4`,children:[v?(0,S.jsxs)(`div`,{className:`mb-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700 flex items-start gap-2`,children:[(0,S.jsx)(`span`,{className:`flex-1 min-w-0`,children:v}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>C(``),className:`shrink-0 w-5 h-5 -mr-0.5 flex items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,"aria-label":`关闭`,children:`✕`})]}):null,w?(0,S.jsxs)(`div`,{className:`mb-3 rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs text-emerald-700 flex items-start gap-2`,children:[(0,S.jsx)(`span`,{className:`flex-1 min-w-0`,children:w}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>T(``),className:`shrink-0 w-5 h-5 -mr-0.5 flex items-center justify-center rounded text-emerald-700/70 hover:bg-emerald-100 hover:text-emerald-900`,"aria-label":`关闭`,children:`✕`})]}):null,G.length?(0,S.jsxs)(`div`,{className:`mb-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2.5`,children:[(0,S.jsx)(`div`,{className:`text-xs font-medium text-amber-800`,children:g(`space.candidatesTitle`,{n:G.length})}),(0,S.jsx)(`p`,{className:`mt-1 text-[11px] leading-snug text-amber-700/90`,children:g(`space.candidatesHint`)}),(0,S.jsx)(`div`,{className:`mt-2 max-h-44 overflow-auto rounded-md border border-amber-200/70 bg-white divide-y divide-stone-100`,children:G.map(e=>(0,S.jsxs)(`label`,{className:`flex items-start gap-2 px-2.5 py-1.5 cursor-pointer hover:bg-stone-50`,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:Te[e.path]===!0,onChange:t=>q(n=>({...n,[e.path]:t.target.checked})),className:`mt-0.5 accent-[#4176e6]`}),(0,S.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,S.jsx)(`span`,{className:`block text-xs text-stone-800 truncate`,children:e.name}),(0,S.jsx)(`span`,{className:`block text-[10px] text-stone-400 truncate font-mono`,children:Q?b(e.path,Q):e.path})]})]},e.path))}),(0,S.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>q(Object.fromEntries(G.map(e=>[e.path,!0]))),className:`text-[11px] text-[#4176e6] hover:underline`,children:g(`space.candidatesSelectAll`)}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>q({}),className:`text-[11px] text-stone-500 hover:underline`,children:g(`space.candidatesClear`)}),(0,S.jsx)(`span`,{className:`flex-1`}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>{K([]),q({}),T(g(`space.candidatesIgnored`))},className:`px-2.5 py-1 text-[11px] rounded-md border border-stone-200 text-stone-600 hover:bg-stone-50`,children:g(`space.candidatesIgnore`)}),(0,S.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Ve(),className:`px-2.5 py-1 text-[11px] rounded-md bg-[#4176e6] text-white hover:bg-[#3565c7] disabled:opacity-40`,children:g(`space.candidatesAdopt`)})]})]}):null,E?(0,S.jsxs)(`div`,{ref:De,children:[(0,S.jsxs)(`div`,{className:`mb-2`,children:[(0,S.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:g(`space.newTitle`)}),(0,S.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-stone-400`,children:g(`space.newDesc`)})]}),(0,S.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,S.jsx)(`input`,{autoFocus:!0,value:O,onChange:e=>k(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),Pe())},placeholder:g(`space.namePlaceholder`),className:`w-full h-9 px-3 text-sm rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors`})}),l?(0,S.jsx)(`div`,{className:`mt-1.5 text-[11px] text-stone-400 truncate`,children:(0,S.jsx)(`code`,{children:b(l.dataRoot,l.baseRoot)})}):null,(0,S.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-stone-200`,children:[(0,S.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-1.5`,children:g(`space.promptBriefLabel`)}),(0,S.jsx)(ge,{value:A,onChange:ve,onGenerate:()=>void Me(`create`),onStop:X,generating:Ke,disabled:$}),(0,S.jsxs)(`div`,{className:`mt-1.5 flex items-start gap-3`,children:[(0,S.jsx)(`p`,{className:`flex-1 min-w-0 text-[11px] text-stone-400 leading-snug`,children:g(`space.promptHint`)}),Ke?(0,S.jsxs)(`p`,{className:`tw-busy-status shrink-0`,"aria-live":`polite`,children:[g(`space.promptGeneratingStatus`),(0,S.jsx)(`span`,{className:`tw-busy-ellipsis`,"aria-hidden":!0})]}):null]}),(0,S.jsx)(_e,{value:ye,onChange:j,disabled:$})]})]}):M?(0,S.jsxs)(`div`,{ref:Oe,children:[(0,S.jsxs)(`div`,{className:`mb-2`,children:[(0,S.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:g(`space.editTitle`)}),(0,S.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-stone-400 font-mono truncate`,children:Q?b(M.path,Q):M.path})]}),(0,S.jsxs)(`label`,{className:`block text-xs font-medium text-stone-500`,children:[g(`space.nameLabel`),(0,S.jsx)(`input`,{autoFocus:!0,value:P,disabled:z||M.isPublic===!0,onChange:e=>F(e.target.value),className:`mt-1.5 w-full h-9 px-3 text-sm rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors disabled:bg-stone-50 disabled:text-stone-400`})]}),M.isPublic?(0,S.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:g(`space.publicNameLocked`)}):null,(0,S.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-stone-200`,children:[(0,S.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-1.5`,children:g(`space.promptBriefLabel`)}),(0,S.jsx)(ge,{value:I,onChange:e=>{L(e),B(!1)},onGenerate:()=>void Me(`edit`),onStop:X,generating:qe,disabled:$||z}),(0,S.jsxs)(`div`,{className:`mt-1.5 flex items-start gap-3`,children:[(0,S.jsx)(`p`,{className:`flex-1 min-w-0 text-[11px] text-stone-400 leading-snug`,children:g(`space.promptBriefHint`)}),qe?(0,S.jsxs)(`p`,{className:`tw-busy-status shrink-0`,"aria-live":`polite`,children:[g(`space.promptGeneratingStatus`),(0,S.jsx)(`span`,{className:`tw-busy-ellipsis`,"aria-hidden":!0})]}):null]}),(0,S.jsx)(_e,{value:be,onChange:R,disabled:$||z,hint:g(`space.promptEditHint`)}),z?(0,S.jsx)(`p`,{className:`mt-2 text-[11px] text-stone-400`,children:g(`space.loading`)}):null]})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,S.jsxs)(`div`,{className:`text-xs font-medium text-stone-500`,children:[g(`space.listTitle`),Z.length?(0,S.jsx)(`span`,{className:`ml-1.5 text-[11px] text-stone-400 tabular-nums`,children:Z.length}):null]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>Ee.current?.click(),className:`text-xs text-[#4176e6] hover:underline disabled:opacity-40`,children:u===`import`?`…`:g(`space.import`)}),(0,S.jsx)(`input`,{ref:Ee,type:`file`,accept:`.zip,application/zip`,className:`hidden`,onChange:e=>void He(e)}),(0,S.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Be(),"data-hint":g(`space.discoverTitle`),"data-hint-always":``,className:`text-xs text-[#4176e6] hover:underline disabled:opacity-40`,children:g(u===`discover`?`space.discovering`:`space.discover`)}),(0,S.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Y(!0),"data-hint":g(`space.sizeTitle`),"data-hint-always":``,className:`text-xs text-[#4176e6] hover:underline disabled:opacity-40`,children:g(u===`stats`?`space.sizing`:`space.size`)})]})]}),(0,S.jsx)(`div`,{className:`rounded-lg border border-stone-200 divide-y divide-stone-100 overflow-hidden`,children:Z.length===0?(0,S.jsx)(`div`,{className:`px-3 py-8 text-center text-xs text-stone-400`,children:g(`space.empty`)}):Ge.map(e=>(0,S.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5`,children:[(0,S.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,S.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:_(e)}),e.isPublic?(0,S.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-stone-100 text-stone-500`,children:g(`space.builtin`)}):null,e.isActive?(0,S.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-[#4176e6]/10 text-[#3565c7]`,children:g(`space.activeTag`)}):null,e.exists?null:(0,S.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-amber-50 text-amber-600`,children:g(`space.missing`)}),e.bytes==null?null:(0,S.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-stone-100 text-stone-500 tabular-nums`,children:ie(e.bytes)})]}),(0,S.jsx)(`div`,{className:`mt-0.5 text-[11px] text-stone-400 truncate cursor-help hover:text-stone-500`,"data-hint":Q?b(e.path,Q):e.path,"data-hint-always":``,children:Q?b(e.path,Q):e.path})]}),(0,S.jsxs)(`div`,{className:`shrink-0 flex flex-wrap justify-end items-center gap-1`,children:[!e.isActive&&e.exists?(0,S.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Le(e),className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:g(`space.switch`)}):null,(0,S.jsx)(`button`,{type:`button`,disabled:$||!e.exists,onClick:()=>void Fe(e),className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:g(`space.edit`)}),(0,S.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>{W(e),we(`${e.name}-copy`)},className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:g(`space.copy`)}),(0,S.jsx)(`a`,{href:le(e.id,`content`),"data-hint":g(`space.exportContentTitle`),"data-hint-always":``,className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 inline-flex items-center transition-colors`,children:g(`space.exportContent`)}),(0,S.jsx)(`a`,{href:le(e.id,`full`),"data-hint":g(`space.exportFullTitle`),"data-hint-always":``,className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 inline-flex items-center transition-colors`,children:g(`space.exportFull`)}),(0,S.jsx)(he,{hint:e.removable?void 0:g(`space.publicLocked`),children:(0,S.jsx)(`button`,{type:`button`,disabled:!e.removable||$,onClick:()=>H({kind:`remove`,space:e}),className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed disabled:pointer-events-none transition-colors`,children:g(`space.removeList`)})}),(0,S.jsx)(he,{hint:e.removable?void 0:g(`space.publicLocked`),children:(0,S.jsx)(`button`,{type:`button`,disabled:!e.removable||$,onClick:()=>H({kind:`delete`,space:e}),className:`h-7 px-2 text-xs rounded-md border border-red-200 text-red-600 hover:bg-red-50 disabled:opacity-30 disabled:cursor-not-allowed disabled:pointer-events-none transition-colors`,children:g(`space.deleteDisk`)})})]})]},e.id))})]})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-3 border-t border-stone-200`,children:[(0,S.jsx)(`button`,{type:`button`,disabled:$||E||M!==null,onClick:()=>{!E&&M===null&&Ne()},className:`h-8 px-3 text-xs font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-[#4176e6] transition-colors`,children:g(`space.addNew`)}),(0,S.jsx)(`span`,{className:`flex-1`}),E||M?(0,S.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>{X(),D(!1),N(null)},className:`tw-confirm-cancel h-8 px-4 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-40 transition-colors`,children:g(`space.cancel`)}):null,E?(0,S.jsx)(`button`,{type:`button`,disabled:!O.trim()||$,onClick:()=>void Pe(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:u===`create`?`…`:g(`space.create`)}):M?(0,S.jsx)(`button`,{type:`button`,disabled:!P.trim()||$||z,onClick:()=>void Ie(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:u===`update`?`…`:g(`space.save`)}):null]})]})})]}),(0,S.jsxs)(o,{open:U!==null,onClose:()=>W(null),transition:!0,className:`relative z-96`,children:[(0,S.jsx)(s,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,S.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,S.jsxs)(i,{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,S.jsx)(a,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:g(`space.confirmCopyTitle`)}),(0,S.jsx)(`p`,{className:`tw-confirm-msg mt-3 text-sm text-stone-600 leading-relaxed`,children:g(`space.confirmCopyMsg`,{name:U?.name??``})}),(0,S.jsxs)(`label`,{className:`mt-3 block text-xs font-medium text-stone-500`,children:[g(`space.copyName`),(0,S.jsx)(`input`,{autoFocus:!0,value:Ce,onChange:e=>we(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),Re())},className:`mt-1.5 w-full h-9 px-3 text-sm rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors`})]}),(0,S.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>W(null),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(`space.cancel`)}),(0,S.jsx)(`button`,{type:`button`,disabled:!Ce.trim()||$,onClick:()=>void Re(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:u===`copy`?`…`:g(`space.copy`)})]})]})})]}),(0,S.jsx)(f,{open:V?.kind===`remove`,title:g(`space.confirmRemoveTitle`),message:V?.kind===`remove`?g(`space.confirmRemoveMsg`,{name:V.space.name,path:V.space.path}):``,confirmLabel:g(`space.removeList`),onClose:()=>H(null),onConfirm:()=>{V?.kind===`remove`&&ze(V.space,!1)}}),(0,S.jsx)(f,{open:V?.kind===`delete`,title:g(`space.confirmDeleteTitle`),message:V?.kind===`delete`?g(`space.confirmDeleteMsg`,{name:V.space.name,path:V.space.path}):``,confirmLabel:g(`space.deleteDisk`),danger:`solid`,onClose:()=>H(null),onConfirm:()=>{V?.kind===`delete`&&ze(V.space,!0)}})]})}var w=`tw.spaces.list.v1`;function T(){try{let e=sessionStorage.getItem(w);if(!e)return null;let t=JSON.parse(e);return t&&Array.isArray(t.spaces)?t:null}catch{return null}}function E(e){try{sessionStorage.setItem(w,JSON.stringify(e))}catch{}}function D(e){try{e?document.documentElement.dataset.spaceService=`none`:delete document.documentElement.dataset.spaceService}catch{}}function O(){let e=T(),[t,n]=(0,x.useState)(e!==null),[r,i]=(0,x.useState)(e!==null),[a,o]=(0,x.useState)(e),[s,d]=(0,x.useState)(!1),[f,p]=(0,x.useState)(!1),[m,h]=(0,x.useState)(``);(0,x.useEffect)(()=>{let e=!0;return(async()=>{let t=await v();if(!e)return;if(i(!0),!t){n(!1),D(!0);return}D(!1),n(!0);let r=await re();e&&r&&(o(r),E(r))})(),()=>{e=!1}},[]);async function te(e){if(e===a?.activeId)return;p(!0),h(``);let t=await se(e);t.ok?(a&&E({...a,activeId:e,spaces:a.spaces.map(t=>({...t,isActive:t.id===e}))}),window.location.reload()):(p(!1),h(t.error||`切换失败`))}if(!r)return null;if(!t)return(0,S.jsx)(`div`,{className:`tw-nav-space`,children:(0,S.jsxs)(`div`,{className:`tw-nav-space-btn tw-nav-space-btn--off`,children:[(0,S.jsx)(`span`,{className:`tw-nav-space-ico`,"aria-hidden":`true`,children:(0,S.jsx)(k,{})}),(0,S.jsxs)(`span`,{className:`tw-nav-space-text`,children:[(0,S.jsx)(`span`,{className:`tw-nav-space-cap`,children:g(`space.offlineCap`)}),(0,S.jsx)(`span`,{className:`tw-nav-space-name`,children:g(`space.offline`)})]})]})});let ne=a?.spaces.find(e=>e.isActive),y=(a?.spaces??[]).filter(e=>!e.isActive);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`tw-nav-space`,children:(0,S.jsxs)(ee,{as:`div`,className:`tw-nav-space-menu`,children:[(0,S.jsxs)(u,{className:`tw-nav-space-btn`,"data-hint":g(`space.label`),children:[(0,S.jsx)(`span`,{className:`tw-nav-space-ico`,"aria-hidden":`true`,children:(0,S.jsx)(k,{})}),(0,S.jsxs)(`span`,{className:`tw-nav-space-text`,children:[(0,S.jsx)(`span`,{className:`tw-nav-space-cap`,children:g(`space.current`)}),(0,S.jsx)(`span`,{className:`tw-nav-space-name`,children:f?g(`space.switching`):ne?_(ne):`—`})]}),(0,S.jsx)(`svg`,{className:`tw-nav-space-caret`,viewBox:`0 0 24 24`,width:`13`,height:`13`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,S.jsx)(`path`,{d:`m6 9 6 6 6-6`})})]}),(0,S.jsxs)(c,{transition:!0,anchor:{to:`bottom start`,gap:`0.375rem`},className:`tw-nav-space-pop tw-menu-anim`,children:[m?(0,S.jsx)(`div`,{className:`tw-nav-space-err`,role:`alert`,children:m}):null,(0,S.jsx)(`div`,{className:`tw-nav-space-group`,children:g(`space.others`)}),y.length===0?(0,S.jsx)(`p`,{className:`tw-nav-space-hint`,children:g(`space.othersEmpty`)}):y.map(e=>(0,S.jsx)(l,{children:(0,S.jsxs)(`button`,{type:`button`,className:`tw-nav-space-item`,disabled:f,onClick:()=>void te(e.id),children:[(0,S.jsx)(`span`,{className:`tw-nav-space-item-main`,children:(0,S.jsx)(`span`,{className:`tw-nav-space-item-name`,"data-hint":_(e),children:_(e)})}),(0,S.jsx)(`svg`,{className:`tw-nav-space-item-go`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,S.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]})},e.id)),(0,S.jsx)(`div`,{className:`tw-nav-space-sep`}),(0,S.jsx)(l,{children:(0,S.jsxs)(`button`,{type:`button`,className:`tw-nav-space-item tw-nav-space-item--manage`,onClick:()=>d(!0),children:[(0,S.jsx)(`span`,{className:`tw-nav-space-item-ico`,"aria-hidden":`true`,children:(0,S.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,S.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,S.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9c.2.6.7 1 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z`})]})}),(0,S.jsx)(`span`,{className:`tw-nav-space-item-main`,children:(0,S.jsx)(`span`,{className:`tw-nav-space-item-name`,children:g(`space.manage`)})}),(0,S.jsx)(`svg`,{className:`tw-nav-space-item-go`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,S.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]})})]})]})}),(0,S.jsx)(C,{open:s,onClose:()=>d(!1),onListChanged:e=>{o(e),E(e)}})]})}function k(){return(0,S.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`15`,height:`15`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,S.jsx)(`path`,{d:`M3 7.5 12 3l9 4.5-9 4.5-9-4.5Z`}),(0,S.jsx)(`path`,{d:`m3 12.5 9 4.5 9-4.5`}),(0,S.jsx)(`path`,{d:`m3 17 9 4.5 9-4.5`})]})}export{O as default};
@@ -0,0 +1 @@
1
+ import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.huKxSIlN.js";import{a as r,o as i,r as a}from"./plugins.DaDJq-mn.js";import{a as o,n as s,o as c,r as l}from"./view-prefs.Dhdh8Z5a.js";import{i as u,n as d,r as f,t as p}from"./dialog.DXHznyjD.js";import{t as m}from"./jsx-runtime.BUXbF_vF.js";import{t as h}from"./ConfirmDialog.CBVsDJ8f.js";import{n as g,t as _}from"./ColumnResize.Bs6GL3DJ.js";import{t as v}from"./DatePicker.CMfX7F6z.js";import{t as y}from"./SelectDropdown.Buv7rQJ_.js";import{A as b,C as x,D as S,P as ee,a as C,b as w,c as T,f as te,g as E,h as ne,i as D,m as O,n as k,o as re,p as ie,r as ae,s as oe,t as A,u as se}from"./tasks.otRBFydq.js";import{a as j,l as M,n as N,o as P,r as F,s as I,t as L}from"./DrawerField.CWMLhcPX.js";var R=e(t(),1),z=m(),ce=8e3,B=[{key:`title`,min:200},{key:`status`,width:104,min:80},{key:`priority`,width:104,min:88},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`cycle`,width:76,min:60},{key:`todos`,width:84,min:68},{key:`progress`,width:132,min:104},{key:`note`,width:140,min:88},{key:`action`,width:56,min:52}],le={pool:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,closed:`bg-stone-100 text-stone-400`,cancelled:`bg-stone-100 text-stone-400 line-through`},ue={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},V={pending:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},H={pool:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,closed:`bg-stone-300`,cancelled:`bg-stone-300`},U={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},de=ae.map(e=>({value:e,label:D[e]})),fe=[{value:``,label:`未设置`},...A.map(e=>({value:e,label:k[e]}))],pe=[{value:`all`,label:`全部优先级`},...A.map(e=>({value:e,label:k[e]}))],me=[{value:`all`,label:`全部`},{value:`pool`,label:`任务池`},{value:`in_progress`,label:`进行中`},{value:`done`,label:`已完成`},{value:`closed`,label:`已关闭`},{value:`cancelled`,label:`已取消`}],he=[`all`,`pool`,`in_progress`,`done`,`closed`,`cancelled`],ge=`tasks.status-tab`,_e=`tasks.priority-filter`,ve=`tasks.search`,ye=pe.map(e=>e.value);function W(e){return(0,z.jsxs)(`div`,{"data-tone":e.tone,className:`tw-stat-card flex min-w-0 flex-col gap-1 rounded-xl border px-4 py-3 ${e.tone===`urgent`?`border-red-100 bg-red-50/60`:`border-stone-200 bg-white`}`,children:[(0,z.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums ${e.tone===`urgent`?`text-[#c02a26]`:`text-stone-900`}`,children:e.value}),(0,z.jsx)(`span`,{className:`truncate text-xs text-stone-500`,children:e.label})]})}function be(e){let{open:t,task:n,todos:r,onClose:i,onSaved:a}=e,[o,s]=(0,R.useState)({title:``}),[c,l]=(0,R.useState)(``),[m,h]=(0,R.useState)(!1);(0,R.useEffect)(()=>{t&&(l(``),h(!1),s(n?{title:n.title,status:n.status,priority:n.priority,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pool`,priority:``,startDate:b(),dueDate:b()}))},[t,n]);function g(e){s(t=>({...t,...e}))}let _=O({startDate:o.startDate??``,dueDate:o.dueDate??``}),y=n?r.filter(e=>e.taskId===n.id):[],S=y.filter(e=>e.status===`done`).length,ee=y.length?Math.round(S/y.length*100):0;async function T(){let e=(o.title??``).trim();if(!e)l(`请填写任务名称`);else if(o.startDate&&o.dueDate&&o.dueDate<o.startDate)l(`截止日期不能早于开始日期`);else{h(!0),l(``);try{n?await E(n.id,o):await C([{...o,title:e}],{mode:`manual`}),await a(),i()}catch(e){l(e instanceof Error?e.message:String(e))}finally{h(!1)}}}return(0,z.jsxs)(f,{open:t,onClose:i,transition:!0,className:`relative z-100`,children:[(0,z.jsx)(p,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,z.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,z.jsxs)(u,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,z.jsx)(d,{className:`text-base font-semibold text-stone-900`,children:n?`任务详情`:`新建任务`}),(0,z.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,z.jsx)(N,{icon:(0,z.jsx)(M,{}),label:`任务名称`,children:(0,z.jsx)(`input`,{autoFocus:!0,value:o.title,onChange:e=>g({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())},placeholder:`请输入内容`,className:L})}),(0,z.jsx)(N,{icon:(0,z.jsx)(I,{}),label:`任务状态`,children:(0,z.jsx)(F,{ariaLabel:`任务状态`,menuMinWidth:140,options:de,value:o.status??`pool`,onChange:e=>g({status:e}),label:D[o.status??`pool`],optionDotClassName:e=>H[e]})}),(0,z.jsx)(N,{icon:(0,z.jsx)(I,{}),label:`紧急程度`,children:(0,z.jsx)(F,{ariaLabel:`紧急程度`,menuMinWidth:140,options:fe,value:o.priority??``,onChange:e=>g({priority:e}),label:o.priority?k[o.priority]:`未设置`,optionDotClassName:e=>U[e]})}),(0,z.jsx)(N,{icon:(0,z.jsx)(j,{}),label:`开始日期`,children:(0,z.jsx)(v,{value:o.startDate??``,onChange:e=>g({startDate:e}),className:`${L} tabular-nums`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(j,{}),label:`截止日期`,children:(0,z.jsx)(v,{value:o.dueDate??``,onChange:e=>g({dueDate:e}),className:`${L} tabular-nums`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(P,{}),label:`任务周期`,children:(0,z.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:_===null?`—`:`${_} 天`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(P,{}),label:`待办进度`,children:(0,z.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:y.length?`${S}/${y.length} · ${ee}%`:`还没有关联待办`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(M,{}),label:`备注`,children:(0,z.jsx)(`textarea`,{value:o.note??``,onChange:e=>g({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),n&&y.length?(0,z.jsxs)(`div`,{className:`mx-6 mt-2 rounded-lg border border-stone-100 bg-stone-50/60 px-3 py-2`,children:[(0,z.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-stone-500`,children:`关联待办`}),(0,z.jsx)(`ul`,{className:`space-y-1.5`,children:y.map(e=>{let t=x(e,b());return(0,z.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-stone-700`,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,z.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${V[t]}`,children:w[t]})]},e.id)})})]}):null,c?(0,z.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:c}):null]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:i,disabled:m,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void T(),disabled:m,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:m?`保存中…`:n?`保存`:`新建`})]})]})})]})}function xe(){let[e,t]=(0,R.useState)(!1),[u,d]=(0,R.useState)(!0),[f,p]=(0,R.useState)(!0),[m,b]=(0,R.useState)(null),[x,C]=(0,R.useState)([]),[w,ae]=(0,R.useState)([]),[A,j]=(0,R.useState)(null),[M,N]=(0,R.useState)(!1),[P,F]=(0,R.useState)(()=>l(ve)),[I,L]=(0,R.useState)(()=>s(ge,he,`all`)),[V,xe]=(0,R.useState)(()=>s(_e,ye,`all`)),[Se,G]=(0,R.useState)(null),[K,q]=(0,R.useState)(null);function Ce(e){o(ge,e),L(e)}function we(e){c(ve,e),F(e)}function Te(e){o(_e,e),xe(e)}let J=(0,R.useRef)(!0),Y=g(`lh:tasks:cols:v1`,B);(0,R.useEffect)(()=>(J.current=!0,()=>{J.current=!1}),[]);let X=(0,R.useCallback)(async()=>{try{let[e,t]=await Promise.all([se(),f?S().catch(()=>[]):Promise.resolve([])]);if(!J.current)return;C(e),ae(t),j(null)}catch(e){if(!J.current)return;j(e instanceof Error?e.message:String(e))}},[f]);(0,R.useEffect)(()=>{let e=r(e=>{d(!!e.tasks),p(!!e.todos)});return n().then(()=>{d(a(`tasks`)),p(a(`todos`)),t(!0)}),e},[]),(0,R.useEffect)(()=>{e&&u&&(async()=>{let e=await oe();J.current&&(e?(await X(),J.current&&b(!0)):b(!1))})()},[e,u,X]),(0,R.useEffect)(()=>{if(m!==!0)return;let e=window.setInterval(()=>void X(),ce),t=()=>void X();return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[m,X]);let Ee=(0,R.useMemo)(()=>ne(w),[w]),Z=(0,R.useMemo)(()=>ie(x),[x]),De=(0,R.useMemo)(()=>T(x,{status:I,priority:V,keyword:P}),[x,I,V,P]),Q=(0,R.useMemo)(()=>te(De),[De]);async function $(e,t){C(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await E(e,t);if(!J.current)return;C(t=>t.map(t=>t.id===e?n:t)),j(null)}catch(e){j(e instanceof Error?e.message:String(e)),await X()}}async function Oe(){let e=K;if(e){q(null),N(!0);try{await re([e.id]),await Promise.all(w.filter(t=>t.taskId===e.id).map(e=>ee(e.id,{taskId:``,linkedTask:``}).catch(()=>null))),await X()}catch(e){j(e instanceof Error?e.message:String(e))}finally{J.current&&N(!1)}}}return e?u?m===null?(0,z.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接任务服务`,children:(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,z.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):m?(0,z.jsxs)(`section`,{className:`flex min-h-0 flex-col gap-4`,children:[(0,z.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-7`,children:[(0,z.jsx)(W,{label:`全部任务`,value:Z.total}),(0,z.jsx)(W,{label:`任务池`,value:Z.pool}),(0,z.jsx)(W,{label:`进行中`,value:Z.in_progress}),(0,z.jsx)(W,{label:`已完成`,value:Z.done}),(0,z.jsx)(W,{label:`已关闭`,value:Z.closed}),(0,z.jsx)(W,{label:`已取消`,value:Z.cancelled}),(0,z.jsx)(W,{label:`需要紧急`,value:Z.urgent,tone:`urgent`})]}),(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-4 py-3`,children:[(0,z.jsx)(`input`,{value:P,onChange:e=>we(e.target.value),placeholder:`搜索任务…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,z.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-stone-100/80 p-0.5`,children:me.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>Ce(e.value),className:`h-8 rounded-md px-3 text-sm transition-colors ${I===e.value?`bg-white font-medium text-stone-900 shadow-sm`:`text-stone-600 hover:text-stone-900`}`,children:e.label},e.value))}),(0,z.jsx)(y,{flat:!0,className:`w-[136px]`,ariaLabel:`优先级筛选`,options:pe,value:V,onChange:e=>Te(e)}),(0,z.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>void X(),"aria-label":`刷新`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-800`,children:(0,z.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,z.jsx)(`path`,{d:`M21 12a9 9 0 1 1-3-6.7`}),(0,z.jsx)(`path`,{d:`M21 4v5h-5`})]})}),(0,z.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>G({task:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建任务`})]})]}),A?(0,z.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1`,children:A}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>j(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,z.jsxs)(`table`,{className:`tw-task-table w-full table-fixed border-collapse text-sm`,style:Y.tableStyle,children:[(0,z.jsx)(`colgroup`,{children:B.map(e=>(0,z.jsx)(`col`,{style:Y.widthOf(e.key)?{width:Y.widthOf(e.key)}:void 0},e.key))}),(0,z.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,z.jsxs)(`tr`,{children:[(0,z.jsxs)(`th`,{className:`relative px-3 py-2 text-left font-medium whitespace-nowrap`,children:[`任务描述`,(0,z.jsx)(_,{...Y.resizeProps(0)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务状态`,(0,z.jsx)(_,{...Y.resizeProps(1)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,z.jsx)(_,{...Y.resizeProps(2)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,z.jsx)(_,{...Y.resizeProps(3)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,z.jsx)(_,{...Y.resizeProps(4)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务周期`,(0,z.jsx)(_,{...Y.resizeProps(5)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办数量`,(0,z.jsx)(_,{...Y.resizeProps(6)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`完成进度`,(0,z.jsx)(_,{...Y.resizeProps(7)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,z.jsx)(_,{...Y.resizeProps(8)})]}),(0,z.jsx)(`th`,{className:`px-1 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,z.jsxs)(`tbody`,{children:[Q.map(e=>{let t=O(e),n=Ee[e.id]??{total:0,done:0,percent:0};return(0,z.jsxs)(`tr`,{className:`group/row border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,z.jsx)(`td`,{className:`px-3 py-1 align-middle`,children:(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.source===`ai`?(0,z.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,children:`AI`}):null,(0,z.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),className:`min-w-0 truncate rounded-md px-1.5 py-1 text-left text-sm text-stone-800 hover:bg-stone-100`,children:e.title})]})}),(0,z.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,z.jsx)(y,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`任务状态`,menuMinWidth:120,options:de,value:e.status,onChange:t=>void $(e.id,{status:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${le[e.status]}`,renderTrigger:()=>(0,z.jsx)(`span`,{className:`w-full truncate text-center`,children:D[e.status]}),renderOptionPrefix:e=>(0,z.jsx)(`span`,{className:`h-2 w-2 rounded-full ${H[e.value]}`})})}),(0,z.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,z.jsx)(y,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:fe,value:e.priority,onChange:t=>void $(e.id,{priority:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${ue[e.priority]}`,renderTrigger:()=>(0,z.jsx)(`span`,{className:`w-full truncate text-center`,children:e.priority?k[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,z.jsx)(`span`,{className:`h-2 w-2 rounded-full ${U[e.value]}`})})}),(0,z.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,z.jsx)(v,{value:e.startDate,onChange:t=>void $(e.id,{startDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,z.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,z.jsx)(v,{value:e.dueDate,onChange:t=>void $(e.id,{dueDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,z.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:t===null?`—`:`${t} 天`}),(0,z.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-500 tabular-nums`,children:f?n.total?`${n.total} 条`:`0`:(0,z.jsx)(`span`,{className:`whitespace-nowrap text-stone-400`,children:`待办事项未启用`})}),(0,z.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:f?(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,z.jsx)(`span`,{className:`block h-full rounded-full bg-[#3370ff] transition-[width]`,style:{width:`${n.percent}%`}})}),(0,z.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs text-stone-500 tabular-nums`,children:[n.percent,`%`]})]}):(0,z.jsx)(`span`,{className:`whitespace-nowrap text-xs text-stone-400`,children:`待办事项未启用`})}),(0,z.jsx)(`td`,{className:`truncate px-2 py-1 align-middle text-xs text-stone-500`,children:e.note||`—`}),(0,z.jsx)(`td`,{className:`px-1 py-1 text-right align-middle`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,z.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,z.jsx)(`path`,{d:`M14 4h6v6`}),(0,z.jsx)(`path`,{d:`M20 4 13 11`}),(0,z.jsx)(`path`,{d:`M10 20H4v-6`}),(0,z.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,z.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>q(e),"aria-label":`删除 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 focus:text-red-600 disabled:opacity-40`,children:(0,z.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,z.jsx)(`path`,{d:`M3 6h18`}),(0,z.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,z.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,z.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),Q.length===0?(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:10,className:`px-3 py-16 text-center text-sm text-stone-400`,children:x.length===0?`还没有任务`:`没有匹配的任务,试试调整搜索或筛选`})}):null]})]})}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,z.jsxs)(`span`,{children:[`共 `,Q.length,` 条`]}),(0,z.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`任务下关联的待办可直接在「待办事项」里维护`})]})]}),(0,z.jsx)(be,{open:Se!==null,task:Se?.task??null,todos:w,onClose:()=>G(null),onSaved:X}),(0,z.jsx)(h,{open:K!=null,title:`删除任务`,message:`删除「${K?.title??``}」?已关联的待办会保留,但不再挂在该任务下。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>q(null),onConfirm:()=>void Oe()})]}):(0,z.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`任务管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,z.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`tasks`)}):(0,z.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,z.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{xe as default};