lantern-harness 0.1.8 → 0.1.9

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 (90) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +2 -2
  3. package/cli/server.mjs +2 -0
  4. package/config/app.defaults.json +1 -0
  5. package/dist/500.html +3 -3
  6. package/dist/_astro/Base.4X_wsSoR.css +1 -0
  7. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.Dy7fJoxu.js +1 -0
  8. package/dist/_astro/{CaseExecBoard.BAV4EE3o.js → CaseExecBoard.DKdfW5fM.js} +1 -1
  9. package/dist/_astro/{CaseGenerateApp.Bz4ryNJG.js → CaseGenerateApp.Bm8AyH9s.js} +1 -1
  10. package/dist/_astro/{CasesLibrary.BPifyHUA.js → CasesLibrary.CvVJZ74h.js} +1 -1
  11. package/dist/_astro/{ChatApp.DLo31SYZ.js → ChatApp.BS-wLBRa.js} +3 -3
  12. package/dist/_astro/{DashboardBoard.Bd3eUPwZ.js → DashboardBoard.DCtfrrJz.js} +1 -1
  13. package/dist/_astro/{DocsFileBrowser.D3cKurQE.js → DocsFileBrowser.BtRoZ787.js} +1 -1
  14. package/dist/_astro/{DocsPager.rzu4mnzw.js → DocsPager.C20ue_JZ.js} +1 -1
  15. package/dist/_astro/{KnowledgeLibrary.B0sO4QR1.js → KnowledgeLibrary.CV4DyStj.js} +1 -1
  16. package/dist/_astro/{NavLibraries.Cvg3wery.js → NavLibraries.DmD2lZBZ.js} +1 -1
  17. package/dist/_astro/PluginsPage.B59AMDrB.js +1 -0
  18. package/dist/_astro/{PluginsPage.DIltPILi.js → PluginsPage.BEAPymNL.js} +1 -1
  19. package/dist/_astro/PmBugsBoard.CPEyBp0l.js +1 -0
  20. package/dist/_astro/PmIterationsBoard.zCeLpcBo.js +1 -0
  21. package/dist/_astro/{PmProjectDetail.DqDoIg8a.js → PmProjectDetail.ejIam5sD.js} +1 -1
  22. package/dist/_astro/{PmProjectsBoard.nOC1Hugt.js → PmProjectsBoard.DbXzir8o.js} +1 -1
  23. package/dist/_astro/PmRequirementsBoard.CynewRfv.js +1 -0
  24. package/dist/_astro/PmRequirementsBoard.D9eUMJWI.js +1 -0
  25. package/dist/_astro/{PmShared.CZnXaUq-.js → PmShared.BxTHKdjY.js} +1 -1
  26. package/dist/_astro/{PromptsLibrary.DU9EuSim.js → PromptsLibrary.Bkruu80b.js} +1 -1
  27. package/dist/_astro/{ReportsPage.Cr88iz8c.js → ReportsPage.BoBQshMQ.js} +1 -1
  28. package/dist/_astro/{RequirementsLibrary.BwriF8F0.js → RequirementsLibrary.BC0A8qdk.js} +1 -1
  29. package/dist/_astro/{SearchableSelect.Ctg8V1Z1.js → SearchableSelect.CXa1hiDd.js} +1 -1
  30. package/dist/_astro/SettingsDialog.Dc-9QNJI.js +1 -0
  31. package/dist/_astro/{SpaceSwitcher.BEJo5KFi.js → SpaceSwitcher.CI3KDBOA.js} +1 -1
  32. package/dist/_astro/{TasksBoard.BZi_GBPG.js → TasksBoard.Bb--oVV8.js} +1 -1
  33. package/dist/_astro/{TemplatesLibrary.T4K9jUex.js → TemplatesLibrary.D1wZq94E.js} +1 -1
  34. package/dist/_astro/{TestStatsBoard.Dd1Kcmx6.js → TestStatsBoard.DlVezlXl.js} +1 -1
  35. package/dist/_astro/{TodosBoard.C4yd_JFb.js → TodosBoard.S84wqcWY.js} +1 -1
  36. package/dist/_astro/UiAutoBoard.BKp9ifxg.js +1 -0
  37. package/dist/_astro/app-config.DUyozIL9.js +1 -0
  38. package/dist/_astro/i18n.B52gLzii.js +7 -0
  39. package/dist/_astro/{open-docs-in-session.B0ZdZNj2.js → open-docs-in-session.Xg3OSOfc.js} +1 -1
  40. package/dist/_astro/{plugins.D5ypJIXn.js → plugins.BDZqJNOy.js} +1 -1
  41. package/dist/_astro/{pm.BsnTv63L.js → pm.Bl3hz9fF.js} +4 -4
  42. package/dist/_astro/{settings.CnDCvwnQ.js → settings.C6NWuiFO.js} +2 -2
  43. package/dist/_astro/{spaces-client.Cai2tHEI.js → spaces-client.k_ciWMai.js} +1 -1
  44. package/dist/_astro/update.Bl_HfSe6.js +1 -0
  45. package/dist/_astro/{view-prefs.HCowOWXL.js → view-prefs.Dyu_lmN2.js} +1 -1
  46. package/dist/case-exec/index.html +4 -4
  47. package/dist/cases/generate/index.html +4 -4
  48. package/dist/cases/library/index.html +4 -4
  49. package/dist/dashboard/index.html +4 -4
  50. package/dist/docs/changelog/index.html +26 -4
  51. package/dist/docs/install/index.html +3 -3
  52. package/dist/docs/manual/index.html +24 -6
  53. package/dist/index.html +4 -4
  54. package/dist/knowledge/index.html +4 -4
  55. 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 +3 -3
  56. package/dist/plugins/index.html +4 -4
  57. package/dist/pm/bugs/index.html +4 -4
  58. package/dist/pm/iterations/index.html +4 -4
  59. package/dist/pm/projects/detail/index.html +4 -4
  60. package/dist/pm/projects/index.html +4 -4
  61. package/dist/pm/requirements/index.html +4 -4
  62. package/dist/prompts/index.html +4 -4
  63. package/dist/reports/index.html +4 -4
  64. package/dist/requirements/index.html +4 -4
  65. package/dist/tasks/index.html +4 -4
  66. package/dist/templates/index.html +4 -4
  67. 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 +3 -3
  68. 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 +3 -3
  69. 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 +3 -3
  70. 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 +3 -3
  71. 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 +3 -3
  72. package/dist/test-stats/index.html +4 -4
  73. package/dist/todos/index.html +4 -4
  74. package/dist/ui-automation/index.html +281 -0
  75. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +17 -3
  76. package/lh-plugins/lh-uiauto.mjs +1237 -0
  77. package/lh-plugins/storage-domain.mjs +7 -0
  78. package/lh-plugins/uiauto-argv-guard.cjs +41 -0
  79. package/package.json +1 -1
  80. package/dist/_astro/Base.DjIEQkT7.css +0 -1
  81. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.D0snmAJ_.js +0 -1
  82. package/dist/_astro/PluginsPage.uvmSuXzi.js +0 -1
  83. package/dist/_astro/PmBugsBoard.CiaIhCHv.js +0 -1
  84. package/dist/_astro/PmIterationsBoard.H67QwKFw.js +0 -1
  85. package/dist/_astro/PmRequirementsBoard.BPjZ7khP.js +0 -1
  86. package/dist/_astro/PmRequirementsBoard.CanxvcKg.js +0 -1
  87. package/dist/_astro/SettingsDialog.DEgsVfaL.js +0 -1
  88. package/dist/_astro/app-config.DKMxjv3g.js +0 -1
  89. package/dist/_astro/i18n.BXeGGutk.js +0 -7
  90. package/dist/_astro/update.DXCPfU4a.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,J as i,K as a,p as o,q as s,r as c,t as l,u}from"./app-config.DKMxjv3g.js";import{C as d,D as f,E as p,S as m,T as h,_ as g,a as _,c as v,f as y,g as b,h as x,i as S,l as C,m as w,n as T,o as E,p as D,r as O,s as k,u as A,v as j,w as M,x as ee,y as N}from"./use-text-value.BuY0Cm1z.js";import{$ as te,A as ne,B as P,F as re,J as ie,K as F,L as I,M as L,N as ae,P as oe,V as se,_t as R,c as ce,d as le,dt as z,et as B,f as ue,ft as de,h as fe,ht as pe,it as V,k as me,lt as he,m as ge,mt as _e,n as ve,nt as ye,o as be,p as xe,pt as H,rt as Se,s as Ce,st as U,u as we,ut as Te,v as Ee,x as De}from"./portal.Cm9XlIPf.js";import{a as Oe,c as ke,l as Ae,o as je,s as Me,u as Ne}from"./listbox.Di-t5U37.js";import{n as Pe,r as Fe,t as Ie}from"./active-element-history.CeefGkFQ.js";import{t as Le}from"./use-tree-walker.CfTHFX43.js";import{t as Re}from"./jsx-runtime.BUXbF_vF.js";var W=e(t(),1),G=e(n(),1);function ze(e){return typeof e==`object`?e.key:e}function Be(e,t){let n=e.length;return new Proxy(e,{get(e,r,i){if(typeof r==`string`){let i=r.charCodeAt(0);if(i>=48&&i<=57){let i=+r;if(Number.isInteger(i)&&i>=0&&i<n){let n=e[i];if(typeof n!=`object`){let r=t[i*2];n=e[i]={index:i,key:n,start:r,size:t[i*2+1],end:r+t[i*2+1],lane:0}}return n}}if(r===`length`)return n}return Reflect.get(e,r,i)}})}function K(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return(o.length!==r.length||o.some((e,t)=>r[t]!==e))&&(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1),i}return o.updateDeps=e=>{r=e},o}function Ve(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var q=(e,t)=>Math.abs(e-t)<1.01,He=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})},Ue,We=()=>{if(Ue!==void 0)return Ue;if(typeof navigator>`u`)return Ue=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Ue=!0;let e=navigator.maxTouchPoints;return Ue=navigator.platform===`MacIntel`&&e!==void 0&&e>0},Ge=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Ke=e=>e,qe=e=>{let t=e.overscan*Math.max(e.lanes??1,1),n=Math.max(e.startIndex-t,0),r=Math.min(e.endIndex+t,e.count-1)-n+1,i=Array(r);for(let e=0;e<r;e++)i[e]=n+e;return i},Je=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(Ge(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(Ge(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Ye={passive:!0},Xe=typeof window>`u`||`onscrollend`in window,Ze=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&Xe,o=0,s=a?null:He(i,()=>t(n(r),!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,Ye),a&&r.addEventListener(`scrollend`,u,Ye),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},Qe=(e,t)=>Ze(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),$e=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},et=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},tt=(e,t)=>e===`smooth`?t?`smoothLanded`:`smooth`:`instant`,nt=e=>e?.phase===`smooth`||e?.phase===`smoothLanded`,rt=e=>e.phase===`smooth`||e.phase===`smoothFinishing`;function it(e,t,n,r){if(t===0)return!1;let i=r(0),a=new Set,o=0;for(;o<e;){let e=n(o);if(e===i)break;a.add(e),o++}let s=e-o;if(s===0||s>=t)return!1;for(let e=0;e<s;e++)if(r(e)!==n(o+e))return!1;for(let e=s;e<t;e++)if(a.has(r(e)))return!1;return!0}var at=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this._clampedAdjustment=null,this.elementsCache=new Map,this._resizeBatch=null,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{let t=()=>{let t={sync:!1};this._resizeBatch=t;try{e.forEach(n)}finally{this._resizeBatch=null,t.notify&&(this.notify(t.sync),this._retryClampedAdjustment())}};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})),n=e=>{let t=e.target,n=this.indexFromElement(t);if(t.isConnected)this.isIndexInRange(n)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this));else{this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}}};return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Ke,rangeExtractor:qe,onChange:()=>{},measureElement:$e,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=this._singleLaneMeasurements?.items??s,l=e=>ze(c[e]),u=e>0?l(0):null,d=e>0?l(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==u||t.getItemKey(o-1)!==d)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>0&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==d)&&(o>e||it(e,o,l,t.getItemKey))&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:a,getItemKey:c}=this.options,l=0;for(;l<a&&c(l)!==e;)l++;if(l<a){let e=n[l];if(e){let n=Math.max(0,e.start+t);!i&&n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=K(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._clampedAdjustment=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5?e=this._intendedScrollOffset:this.scrollState?.index!=null&&!rt(this.scrollState)&&!q(e,this.scrollState.lastTargetOffset)&&!q(e,this.getScrollStateTarget(this.scrollState))&&(this._clampedAdjustment===null||Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5)&&(this.scrollState=null),this._intendedScrollOffset=null,this.scrollState&&(this.scrollState.writtenOffset=null),this._clampedAdjustment!==null&&Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null),this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,We()&&this.targetWindow!=null&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,Ye),e.addEventListener(`touchend`,n,Ye),e.addEventListener(`touchcancel`,n,Ye),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),e.removeEventListener(`touchcancel`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(We()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):nt(this.scrollState)&&!q(this.getScrollOffset()-i,this.scrollState.lastTargetOffset)||this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}this._retryClampedAdjustment()},this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;let{target:e,maxAtWrite:t}=this._clampedAdjustment,n=this.getMaxScrollOffset();n>t+.5&&(this._clampedAdjustment=e>n+.5?{target:e,maxAtWrite:n}:null,this._scrollToOffset(e,{adjustments:void 0,behavior:void 0}))},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=K(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=K(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._singleLaneMeasurements?.flat;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e}let o=u===0?Array(e):this._singleLaneMeasurements.items.slice(),c;if(u===0)c=t+n;else{let e=u-1;c=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t);o[t]=e;let n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=c,a[t*2+1]=i,c+=i+s}this._singleLaneMeasurements={flat:a,items:o};let d=Be(o,a);return this.measurementsCache=d,d}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=K(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=ct(e,t,n,r,r===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=K(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t,this.options.lanes]},(e,t,n,r,i,a)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n,lanes:a}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!nt(this.scrollState))return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),e.isConnected&&(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{var n;if(!this.isIndexInRange(e))return;this._resizeBatch?.sync&&this.getMeasurements();let r,i,a,o=this._singleLaneMeasurements?.flat;if(this.options.lanes===1&&o!=null)a=this.options.getItemKey(e),i=o[e*2],r=o[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;a=t.key,i=t.start,r=t.size}let s=this.itemSizeCache.get(a)??r,c=t-s;if(c!==0){let o=this.options.anchorTo===`end`&&!nt(this.scrollState)&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,l=o?this.getTotalSize():0,u=this.getScrollOffset()+this.scrollAdjustments,d=this.itemSizeCache.has(a)?i+s<=u&&this.scrollDirection!==`backward`:i<u,f=!nt(this.scrollState)&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?d:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:a,start:i,size:r,end:i+r,lane:0},c,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(a,t),this.itemSizeCacheVersion++;let p=this.scrollState?.writtenOffset!=null&&!q(this.scrollState.writtenOffset,this.getScrollOffset()+this.scrollAdjustments),m=!1;if(p||(o?m=this.applyScrollAdjustment(this.getTotalSize()-l):f&&(m=this.applyScrollAdjustment(c))),this._resizeBatch){this._resizeBatch.notify=!0,(n=this._resizeBatch).sync||(n.sync=m);return}this.notify(m),this._retryClampedAdjustment()}},this.getVirtualItems=K(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._singleLaneMeasurements?.flat,r=this.options.lanes===1&&n!=null;return Ve(t[ot(0,t.length-1,r?e=>n[e*2]:e=>Ve(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1){let e=this.getMaxScrollOffset(),n=e-this.options.paddingEnd+this.options.scrollPaddingEnd;return[Math.max(Math.min(n,e),0),t]}let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0;let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,startedAt:i,lastTargetOffset:r,stableFrames:0,phase:tt(n,!1)},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,startedAt:o,lastTargetOffset:i,stableFrames:0,phase:tt(n,q(i,this.getScrollOffset()))},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getOffsetForAlignment((this.scrollState?.writtenOffset??this.getScrollOffset())+e,`start`),r=this.now();this.scrollState={index:null,align:`start`,startedAt:r,lastTargetOffset:n,stableFrames:0,phase:tt(t,!1)},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this._iosDeferredAdjustment=0;let t=Math.max(this.getMaxScrollOffset(),0);this.scrollState={index:this.options.count-1,align:`end`,toEnd:!0,startedAt:this.now(),lastTargetOffset:t,stableFrames:0,phase:tt(e,q(t,this.getScrollOffset()))},this._scrollToOffset(t,{adjustments:void 0,behavior:e}),this.scheduleScrollReconcile()}else this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.cancelScroll=()=>{this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._singleLaneMeasurements?.flat;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.scrollState&&(this.scrollState.writtenOffset=n===`smooth`?null:this._intendedScrollOffset),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){if(e===0)return!1;if(We()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded))return this.scrollState?.index??(this._iosDeferredAdjustment+=e),!1;{let n=this.getScrollOffset()+this.scrollAdjustments+e,r=this.scrollElement,i=r!==null&&(`scrollHeight`in r||`document`in r)?this.getMaxScrollOffset():null;return this._clampedAdjustment=i!==null&&n>i+.5?{target:n,maxAtWrite:i}:null,this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0}}scheduleScrollReconcile(){this.targetWindow?this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}):this.scrollState=null}getScrollStateTarget(e){let t=e.toEnd?[Math.max(this.getMaxScrollOffset(),0)]:e.index==null?void 0:this.getOffsetForIndex(e.index,e.align);return t?t[0]:e.lastTargetOffset}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}this.getMeasurements();let e=this.getScrollStateTarget(this.scrollState),t=this.scrollState.index==null?1:this.options.useAnimationFrameWithResizeObserver?3:2,n=e!==this.scrollState.lastTargetOffset;if(!n&&q(e,this.getScrollOffset())){if(this.scrollState.phase===`smooth`?this.scrollState.phase=`smoothLanded`:this.scrollState.phase===`smoothFinishing`&&(this.scrollState.phase=`instant`),this.scrollState.stableFrames++,this.scrollState.stableFrames>=t){this.getScrollOffset()!==e&&this._scrollToOffset(e,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let t=this.getSize()||600,n=Math.abs(e-this.getScrollOffset()),r=nt(this.scrollState)&&n>t;this.scrollState.lastTargetOffset=e,r?this.scrollState.phase=`smooth`:this.scrollState.phase===`smooth`?this.scrollState.phase=`smoothFinishing`:this.scrollState.phase===`smoothLanded`&&(this.scrollState.phase=`instant`),this._scrollToOffset(e,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},ot=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function st(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function ct(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=st(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=ot(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var lt=typeof document<`u`?W.useLayoutEffect:W.useEffect;function ut({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=W.useReducer(e=>e+1,0)[1],a=W.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=W.useRef(!1),s=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},c=(e,t,n)=>{let r=a.current,i=!!e.options.horizontal,o=t.start-e.options.scrollMargin;r.lastPositions.get(n)!==o&&(r.lastPositions.set(n,o),r.mode===`transform`?n.style.transform=i?`translate3d(${o}px, 0, 0)`:`translate3d(0, ${o}px, 0)`:n.style[i?`left`:`top`]=`${o}px`)},l=e=>{let t=a.current;if(t.enabled&&t.container){s(e);for(let t of e.getVirtualItems()){let n=e.elementsCache.get(t.key);n&&c(e,t,n)}}},u={...r,onChange:(t,n)=>{var s;let c=a.current,u=!0;if(c.enabled){l(t);let e=t.range,n=c.prevRange;u=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,u&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}u&&(e&&n&&!o.current?(0,G.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[d]=W.useState(()=>{let e=new at(u),t=e.measureElement;return e.measureElement=n=>{o.current=!0;try{t(n)}finally{o.current=!1}let r=a.current;if(n!==null&&r.enabled&&r.container){let t=e.measurementsCache[e.indexFromElement(n)];t&&c(e,t,n)}},Object.assign(e,{containerRef:t=>{let n=a.current;n.container=t,n.lastSize=null,t!==null&&l(e)}})});return d.setOptions(u),lt(()=>d._didMount(),[]),lt(()=>(s(d),d._willUpdate())),lt(()=>{l(d)}),d}function dt(e){return ut({observeElementRect:Je,observeElementOffset:Qe,scrollToFn:et,...e})}function ft(e){let t=(0,W.useRef)({value:``,selectionStart:null,selectionEnd:null});return Fe(e,`blur`,e=>{let n=e.target;F(n)&&(t.current={value:n.value,selectionStart:n.selectionStart,selectionEnd:n.selectionEnd})}),z(()=>{if(!R(e)&&F(e)&&e.isConnected){if(e.focus({preventScroll:!0}),e.value!==t.current.value)e.setSelectionRange(e.value.length,e.value.length);else{let{selectionStart:n,selectionEnd:r}=t.current;n!==null&&r!==null&&e.setSelectionRange(n,r)}t.current={value:``,selectionStart:null,selectionEnd:null}}})}var pt=Object.defineProperty,mt=(e,t,n)=>t in e?pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ht=(e,t,n)=>(mt(e,typeof t==`symbol`?t:t+``,n),n),J=(e=>(e[e.Open=0]=`Open`,e[e.Closed=1]=`Closed`,e))(J||{}),Y=(e=>(e[e.Single=0]=`Single`,e[e.Multi=1]=`Multi`,e))(Y||{}),X=(e=>(e[e.Pointer=0]=`Pointer`,e[e.Focus=1]=`Focus`,e[e.Other=2]=`Other`,e))(X||{}),gt=(e=>(e[e.OpenCombobox=0]=`OpenCombobox`,e[e.CloseCombobox=1]=`CloseCombobox`,e[e.GoToOption=2]=`GoToOption`,e[e.SetTyping=3]=`SetTyping`,e[e.RegisterOption=4]=`RegisterOption`,e[e.UnregisterOption=5]=`UnregisterOption`,e[e.DefaultToFirstOption=6]=`DefaultToFirstOption`,e[e.SetActivationTrigger=7]=`SetActivationTrigger`,e[e.UpdateVirtualConfiguration=8]=`UpdateVirtualConfiguration`,e[e.SetInputElement=9]=`SetInputElement`,e[e.SetButtonElement=10]=`SetButtonElement`,e[e.SetOptionsElement=11]=`SetOptionsElement`,e[e.MarkInputAsMoved=12]=`MarkInputAsMoved`,e))(gt||{});function _t(e,t=e=>e){let n=e.activeOptionIndex===null?null:e.options[e.activeOptionIndex],r=t(e.options.slice()),i=r.length>0&&r[0].dataRef.current.order!==null?r.sort((e,t)=>e.dataRef.current.order-t.dataRef.current.order):De(r,e=>e.dataRef.current.domRef.current),a=n?i.indexOf(n):null;return a===-1&&(a=null),{options:i,activeOptionIndex:a}}var vt={1(e){var t;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===1)return e;let n=e.inputElement?O.Tracked(T(e.inputElement)):e.inputPositionState;return{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,inputPositionState:n,__demoMode:!1}},0(e){var t,n;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===0)return e;if((n=e.dataRef.current)!=null&&n.value){let t=e.dataRef.current.calculateIndex(e.dataRef.current.value);if(t!==-1)return{...e,activeOptionIndex:t,comboboxState:0,__demoMode:!1,inputPositionState:O.Idle}}return{...e,comboboxState:0,inputPositionState:O.Idle,__demoMode:!1}},3(e,t){return e.isTyping===t.isTyping?e:{...e,isTyping:t.isTyping}},2(e,t){var n,r;if((n=e.dataRef.current)!=null&&n.disabled||e.optionsElement&&!((r=e.dataRef.current)!=null&&r.optionsPropsRef.current.static)&&e.comboboxState===1)return e;if(e.virtual){let{options:n,disabled:r}=e.virtual,i=t.focus===_.Specific?t.idx:E(t,{resolveItems:()=>n,resolveActiveIndex:()=>e.activeOptionIndex??n.findIndex(e=>!r(e))??null,resolveDisabled:r,resolveId(){throw Error(`Function not implemented.`)}}),a=t.trigger??2;return e.activeOptionIndex===i&&e.activationTrigger===a?e:{...e,activeOptionIndex:i,activationTrigger:a,isTyping:!1,__demoMode:!1}}let i=_t(e);if(i.activeOptionIndex===null){let e=i.options.findIndex(e=>!e.dataRef.current.disabled);e!==-1&&(i.activeOptionIndex=e)}let a=t.focus===_.Specific?t.idx:E(t,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:e=>e.id,resolveDisabled:e=>e.dataRef.current.disabled}),o=t.trigger??2;return e.activeOptionIndex===a&&e.activationTrigger===o?e:{...e,...i,isTyping:!1,activeOptionIndex:a,activationTrigger:o,__demoMode:!1}},4:(e,t)=>{var n,r,i,a;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:[...e.options,t.payload]};let o=t.payload,s=_t(e,e=>(e.push(o),e));e.activeOptionIndex===null&&(i=(r=e.dataRef.current).isSelected)!=null&&i.call(r,t.payload.dataRef.current.value)&&(s.activeOptionIndex=s.options.indexOf(o));let c={...e,...s,activationTrigger:2};return(a=e.dataRef.current)!=null&&a.__demoMode&&e.dataRef.current.value===void 0&&(c.activeOptionIndex=0),c},5:(e,t)=>{var n;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:e.options.filter(e=>e.id!==t.id)};let r=_t(e,e=>{let n=e.findIndex(e=>e.id===t.id);return n!==-1&&e.splice(n,1),e});return{...e,...r,activationTrigger:2}},6:(e,t)=>e.defaultToFirstOption===t.value?e:{...e,defaultToFirstOption:t.value},7:(e,t)=>e.activationTrigger===t.trigger?e:{...e,activationTrigger:t.trigger},8:(e,t)=>{if(e.virtual===null)return{...e,virtual:{options:t.options,disabled:t.disabled??(()=>!1)}};if(e.virtual.options===t.options&&e.virtual.disabled===t.disabled)return e;let n=e.activeOptionIndex;if(e.activeOptionIndex!==null){let r=t.options.indexOf(e.virtual.options[e.activeOptionIndex]);n=r===-1?null:r}return{...e,activeOptionIndex:n,virtual:{options:t.options,disabled:t.disabled??(()=>!1)}}},9:(e,t)=>e.inputElement===t.element?e:{...e,inputElement:t.element},10:(e,t)=>e.buttonElement===t.element?e:{...e,buttonElement:t.element},11:(e,t)=>e.optionsElement===t.element?e:{...e,optionsElement:t.element},12(e){return e.inputPositionState.kind===`Tracked`?{...e,inputPositionState:O.Moved}:e}},yt=class e extends re{constructor(e){super(e),ht(this,`actions`,{onChange:e=>{let{onChange:t,compare:n,mode:r,value:i}=this.state.dataRef.current;return U(r,{0:()=>t?.(e),1:()=>{let r=i.slice(),a=r.findIndex(t=>n(t,e));return a===-1?r.push(e):r.splice(a,1),t?.(r)}})},registerOption:(e,t)=>(this.send({type:4,payload:{id:e,dataRef:t}}),()=>{this.state.activeOptionIndex===this.state.dataRef.current.calculateIndex(t.current.value)&&this.send({type:6,value:!0}),this.send({type:5,id:e})}),goToOption:(e,t)=>(this.send({type:6,value:!1}),this.send({type:2,...e,trigger:t})),setIsTyping:e=>{this.send({type:3,isTyping:e})},closeCombobox:()=>{var e,t;this.send({type:1}),this.send({type:6,value:!1}),(t=(e=this.state.dataRef.current).onClose)==null||t.call(e)},openCombobox:()=>{this.send({type:0}),this.send({type:6,value:!0})},setActivationTrigger:e=>{this.send({type:7,trigger:e})},selectActiveOption:()=>{let e=this.selectors.activeOptionIndex(this.state);if(e!==null){if(this.actions.setIsTyping(!1),this.state.virtual)this.actions.onChange(this.state.virtual.options[e]);else{let{dataRef:t}=this.state.options[e];this.actions.onChange(t.current.value)}this.actions.goToOption({focus:_.Specific,idx:e})}},setInputElement:e=>{this.send({type:9,element:e})},setButtonElement:e=>{this.send({type:10,element:e})},setOptionsElement:e=>{this.send({type:11,element:e})}}),ht(this,`selectors`,{activeDescendantId:e=>{let t=this.selectors.activeOptionIndex(e);if(t!==null)return e.virtual?e.options.find(n=>!n.dataRef.current.disabled&&e.dataRef.current.compare(n.dataRef.current.value,e.virtual.options[t]))?.id:e.options[t]?.id},activeOptionIndex:e=>{if(e.defaultToFirstOption&&e.activeOptionIndex===null&&(e.virtual?e.virtual.options.length>0:e.options.length>0)){if(e.virtual){let{options:t,disabled:n}=e.virtual,r=t.findIndex(e=>{var t;return!((t=n?.(e))!=null&&t)});if(r!==-1)return r}let t=e.options.findIndex(e=>!e.dataRef.current.disabled);if(t!==-1)return t}return e.activeOptionIndex},activeOption:e=>{let t=this.selectors.activeOptionIndex(e);return t===null?null:e.virtual?e.virtual.options[t??0]:e.options[t]?.dataRef.current.value??null},isActive:(e,t,n)=>{let r=this.selectors.activeOptionIndex(e);return r===null?!1:e.virtual?r===e.dataRef.current.calculateIndex(t):e.options[r]?.id===n},shouldScrollIntoView:(e,t,n)=>!(e.virtual||e.__demoMode||e.comboboxState!==0||e.activationTrigger===0||!this.selectors.isActive(e,t,n)),didInputMove(e){return e.inputPositionState.kind===`Moved`}});{let e=this.state.id,t=oe.get(null);this.disposables.add(t.on(ae.Push,n=>{!t.selectors.isTop(n,e)&&this.state.comboboxState===0&&this.actions.closeCombobox()})),this.on(0,()=>t.actions.push(e)),this.on(1,()=>t.actions.pop(e))}this.disposables.group(e=>{this.on(1,t=>{t.inputElement&&(e.dispose(),e.add(S(t.inputElement,t.inputPositionState,()=>{this.send({type:12})})))})})}static new({id:t,virtual:n=null,__demoMode:r=!1}){return new e({id:t,dataRef:{current:{}},comboboxState:+!r,isTyping:!1,options:[],virtual:n?{options:n.options,disabled:n.disabled??(()=>!1)}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:r,inputPositionState:O.Idle})}reduce(e,t){return U(t.type,vt,e,t)}},bt=(0,W.createContext)(null);function xt(e){let t=(0,W.useContext)(bt);if(t===null){let t=Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,St),t}return t}function St({id:e,virtual:t=null,__demoMode:n=!1}){let r=(0,W.useMemo)(()=>yt.new({id:e,virtual:t,__demoMode:n}),[]);return be(()=>r.dispose()),r}var Ct=(0,W.createContext)(null);Ct.displayName=`ComboboxDataContext`;function Z(e){let t=(0,W.useContext)(Ct);if(t===null){let t=Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,Z),t}return t}var wt=(0,W.createContext)(null);function Tt(e){let t=xt(`VirtualProvider`),{options:n}=Z(`VirtualProvider`).virtual,r=L(t,e=>e.optionsElement),[i,a]=(0,W.useMemo)(()=>{let e=r;if(!e)return[0,0];let t=window.getComputedStyle(e);return[parseFloat(t.paddingBlockStart||t.paddingTop),parseFloat(t.paddingBlockEnd||t.paddingBottom)]},[r]),o=dt({enabled:n.length!==0,scrollPaddingStart:i,scrollPaddingEnd:a,count:n.length,estimateSize(){return 40},getScrollElement(){return t.state.optionsElement},overscan:12}),[s,c]=(0,W.useState)(0);H(()=>{c(e=>e+1)},[n]);let l=o.getVirtualItems(),u=L(t,e=>e.activationTrigger===X.Pointer),d=L(t,t.selectors.activeOptionIndex);return l.length===0?null:W.createElement(wt.Provider,{value:o},W.createElement(`div`,{style:{position:`relative`,width:`100%`,height:`${o.getTotalSize()}px`},ref:e=>{e&&(u||d!==null&&n.length>d&&o.scrollToIndex(d))}},l.map(t=>W.createElement(W.Fragment,{key:t.key},W.cloneElement(e.children?.call(e,{...e.slot,option:n[t.index]}),{key:`${s}-${t.key}`,"data-index":t.index,"aria-setsize":n.length,"aria-posinset":t.index+1,style:{position:`absolute`,top:0,left:0,transform:`translateY(${t.start}px)`,overflowAnchor:`none`}})))))}var Et=W.Fragment;function Dt(e,t){let n=(0,te.useId)(),r=he(),{value:i,defaultValue:a,onChange:o,form:s,name:c,by:l,invalid:u=!1,disabled:d=r||!1,onClose:f,__demoMode:p=!1,multiple:h=!1,immediate:g=!1,virtual:_=null,nullable:v,...y}=e,b=Ae(a),[x=h?[]:void 0,S]=Ne(i,o,b),C=St({id:n,virtual:_,__demoMode:p}),w=(0,W.useRef)({static:!1,hold:!1}),T=Me(l),E=z(e=>_?l===null?_.options.indexOf(e):_.options.findIndex(t=>T(t,e)):C.state.options.findIndex(t=>T(t.dataRef.current.value,e))),D=(0,W.useCallback)(e=>U(j.mode,{[Y.Multi]:()=>x.some(t=>T(t,e)),[Y.Single]:()=>T(x,e)}),[x]),O=L(C,e=>e.virtual),A=z(()=>f?.()),j=(0,W.useMemo)(()=>({__demoMode:p,immediate:g,optionsPropsRef:w,value:x,defaultValue:b,disabled:d,invalid:u,mode:h?Y.Multi:Y.Single,virtual:_?O:null,onChange:S,isSelected:D,calculateIndex:E,compare:T,onClose:A}),[p,g,w,x,b,d,u,h,_,O,S,D,E,T,A]);H(()=>{_&&C.send({type:gt.UpdateVirtualConfiguration,options:_.options,disabled:_.disabled??null})},[_,_?.options,_?.disabled]),H(()=>{C.state.dataRef.current=j},[j]);let[M,ee,N,ne]=L(C,e=>[e.comboboxState,e.buttonElement,e.inputElement,e.optionsElement]),P=oe.get(null),re=L(P,(0,W.useCallback)(e=>P.selectors.isTop(e,n),[P,n]));fe(re,[ee,N,ne],()=>C.actions.closeCombobox());let ie=L(C,C.selectors.activeOptionIndex),F=L(C,C.selectors.activeOption),I=Te({open:M===J.Open,disabled:d,invalid:u,activeIndex:ie,activeOption:F,value:x}),[ae,se]=m(),R=t===null?{}:{ref:t},le=(0,W.useCallback)(()=>{if(b!==void 0)return S?.(b)},[S,b]),B=ye();return W.createElement(se,{value:ae,props:{htmlFor:N?.id},slot:{open:M===J.Open,disabled:d}},W.createElement(k,null,W.createElement(Ct.Provider,{value:j},W.createElement(bt.Provider,{value:C},W.createElement(Ce,{value:U(M,{[J.Open]:ce.Open,[J.Closed]:ce.Closed})},c!=null&&W.createElement(ke,{disabled:d,data:x==null?{}:{[c]:x},form:s,onReset:le}),B({ourProps:R,theirProps:y,slot:I,defaultTag:Et,name:`Combobox`}))))))}var Ot=`input`;function kt(e,t){let n=xt(`Combobox.Input`),r=Z(`Combobox.Input`),i=(0,te.useId)(),a=M(),{id:o=a||`headlessui-combobox-input-${i}`,onChange:s,displayValue:c,disabled:l=r.disabled||!1,autoFocus:u=!1,type:d=`text`,...m}=e,h=(0,W.useRef)(null),g=se(h,t,v(),n.actions.setInputElement),[y,b]=L(n,e=>[e.comboboxState,e.isTyping]),x=_e(),S=z(()=>{n.actions.onChange(null),n.state.optionsElement&&(n.state.optionsElement.scrollTop=0),n.actions.goToOption({focus:_.Nothing})}),C=(0,W.useMemo)(()=>typeof c==`function`&&r.value!==void 0?c(r.value)??``:typeof r.value==`string`?r.value:``,[r.value,c]);Pe(([e,t],[r,i])=>{if(n.state.isTyping)return;let a=h.current;a&&((i===J.Open&&t===J.Closed||e!==r)&&(a.value=e),requestAnimationFrame(()=>{if(n.state.isTyping||!a||R(a))return;let{selectionStart:e,selectionEnd:t}=a;Math.abs((t??0)-(e??0))===0&&e===0&&a.setSelectionRange(a.value.length,a.value.length)}))},[C,y,b]),Pe(([e],[t])=>{if(e===J.Open&&t===J.Closed){if(n.state.isTyping)return;let e=h.current;if(!e)return;let t=e.value,{selectionStart:r,selectionEnd:i,selectionDirection:a}=e;e.value=``,e.value=t,a===null?e.setSelectionRange(r,i):e.setSelectionRange(r,i,a)}},[y]);let w=(0,W.useRef)(!1),T=z(()=>{w.current=!0}),E=z(()=>{x.nextFrame(()=>{w.current=!1})}),D=z(e=>{switch(n.actions.setIsTyping(!0),e.key){case I.Enter:if(n.state.comboboxState!==J.Open||w.current)return;if(e.preventDefault(),e.stopPropagation(),n.selectors.activeOptionIndex(n.state)===null){n.actions.closeCombobox();return}n.actions.selectActiveOption(),r.mode===Y.Single&&n.actions.closeCombobox();break;case I.ArrowDown:return e.preventDefault(),e.stopPropagation(),U(n.state.comboboxState,{[J.Open]:()=>n.actions.goToOption({focus:_.Next}),[J.Closed]:()=>n.actions.openCombobox()});case I.ArrowUp:return e.preventDefault(),e.stopPropagation(),U(n.state.comboboxState,{[J.Open]:()=>n.actions.goToOption({focus:_.Previous}),[J.Closed]:()=>{(0,G.flushSync)(()=>n.actions.openCombobox()),r.value||n.actions.goToOption({focus:_.Last})}});case I.Home:if(n.state.comboboxState===J.Closed||e.shiftKey)break;return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:_.First});case I.PageUp:return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:_.First});case I.End:if(n.state.comboboxState===J.Closed||e.shiftKey)break;return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:_.Last});case I.PageDown:return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:_.Last});case I.Escape:return n.state.comboboxState===J.Open?(e.preventDefault(),n.state.optionsElement&&!r.optionsPropsRef.current.static&&e.stopPropagation(),r.mode===Y.Single&&r.value===null&&S(),n.actions.closeCombobox()):void 0;case I.Tab:if(n.actions.setIsTyping(!1),n.state.comboboxState!==J.Open)return;r.mode===Y.Single&&n.state.activationTrigger!==X.Focus&&n.actions.selectActiveOption(),n.actions.closeCombobox()}}),O=z(e=>{s?.(e),r.mode===Y.Single&&e.target.value===``&&S(),n.actions.openCombobox()}),k=z(e=>{var t,i;let a=e.relatedTarget??Ie.find(t=>t!==e.currentTarget);if(!((t=n.state.optionsElement)!=null&&t.contains(a))&&!((i=n.state.buttonElement)!=null&&i.contains(a))&&n.state.comboboxState===J.Open)return e.preventDefault(),r.mode===Y.Single&&r.value===null&&S(),n.actions.closeCombobox()}),A=z(e=>{var t,i;let a=e.relatedTarget??Ie.find(t=>t!==e.currentTarget);(t=n.state.buttonElement)!=null&&t.contains(a)||(i=n.state.optionsElement)!=null&&i.contains(a)||r.disabled||r.immediate&&n.state.comboboxState!==J.Open&&x.microTask(()=>{(0,G.flushSync)(()=>n.actions.openCombobox()),n.actions.setActivationTrigger(X.Focus)})}),j=ee(),N=P(),{isFocused:ne,focusProps:re}=f({autoFocus:u}),{isHovered:ie,hoverProps:F}=p({isDisabled:l}),ae=L(n,e=>e.optionsElement),oe=Te({open:y===J.Open,disabled:l,invalid:r.invalid,hover:ie,focus:ne,autofocus:u}),ce=Se({ref:g,id:o,role:`combobox`,type:d,"aria-controls":ae?.id,"aria-expanded":y===J.Open,"aria-activedescendant":L(n,n.selectors.activeDescendantId),"aria-labelledby":j,"aria-describedby":N,"aria-autocomplete":`list`,defaultValue:e.defaultValue??(r.defaultValue===void 0?null:c?.(r.defaultValue))??r.defaultValue,disabled:l||void 0,autoFocus:u,onCompositionStart:T,onCompositionEnd:E,onKeyDown:D,onChange:O,onFocus:A,onBlur:k},re,F);return ye()({ourProps:ce,theirProps:m,slot:oe,defaultTag:Ot,name:`Combobox.Input`})}var At=`button`;function jt(e,t){let n=xt(`Combobox.Button`),r=Z(`Combobox.Button`),[i,a]=(0,W.useState)(null),o=se(t,a,n.actions.setButtonElement),s=(0,te.useId)(),{id:c=`headlessui-combobox-button-${s}`,disabled:l=r.disabled||!1,autoFocus:u=!1,...d}=e,[m,v,y]=L(n,e=>[e.comboboxState,e.inputElement,e.optionsElement]),S=ft(v),C=m===J.Open;x(C,{trigger:i,action:(0,W.useCallback)(e=>{if(i!=null&&i.contains(e.target)||v!=null&&v.contains(e.target))return b.Ignore;let t=e.target.closest(`[role="option"]:not([data-disabled])`);return ie(t)?b.Select(t):y!=null&&y.contains(e.target)?b.Ignore:b.Close},[i,v,y]),close:n.actions.closeCombobox,select:n.actions.selectActiveOption});let T=z(e=>{switch(e.key){case I.Space:case I.Enter:e.preventDefault(),e.stopPropagation(),n.state.comboboxState===J.Closed&&(0,G.flushSync)(()=>n.actions.openCombobox()),S();return;case I.ArrowDown:e.preventDefault(),e.stopPropagation(),n.state.comboboxState===J.Closed&&((0,G.flushSync)(()=>n.actions.openCombobox()),n.state.dataRef.current.value||n.actions.goToOption({focus:_.First})),S();return;case I.ArrowUp:e.preventDefault(),e.stopPropagation(),n.state.comboboxState===J.Closed&&((0,G.flushSync)(()=>n.actions.openCombobox()),n.state.dataRef.current.value||n.actions.goToOption({focus:_.Last})),S();return;case I.Escape:if(n.state.comboboxState!==J.Open)return;e.preventDefault(),n.state.optionsElement&&!r.optionsPropsRef.current.static&&e.stopPropagation(),(0,G.flushSync)(()=>n.actions.closeCombobox()),S();return;default:return}}),E=g(()=>{n.state.comboboxState===J.Open?n.actions.closeCombobox():n.actions.openCombobox(),S()}),D=ee([c]),{isFocusVisible:O,focusProps:k}=f({autoFocus:u}),{isHovered:A,hoverProps:j}=p({isDisabled:l}),{pressed:M,pressProps:N}=h({disabled:l}),ne=Te({open:m===J.Open,active:M||m===J.Open,disabled:l,invalid:r.invalid,value:r.value,hover:A,focus:O}),P=Se({ref:o,id:c,type:w(e,i),tabIndex:-1,"aria-haspopup":`listbox`,"aria-controls":y?.id,"aria-expanded":m===J.Open,"aria-labelledby":D,disabled:l||void 0,autoFocus:u,onKeyDown:T},E,k,j,N);return ye()({ourProps:P,theirProps:d,slot:ne,defaultTag:At,name:`Combobox.Button`})}var Mt=`div`,Nt=B.RenderStrategy|B.Static;function Pt(e,t){let n=(0,te.useId)(),{id:r=`headlessui-combobox-options-${n}`,hold:i=!1,anchor:a,portal:o=!1,modal:s=!0,transition:c=!1,...l}=e,u=xt(`Combobox.Options`),d=Z(`Combobox.Options`),f=y(a);f&&(o=!0);let[p,m]=C(f),[h,g]=(0,W.useState)(null),_=A(),v=se(t,f?p:null,u.actions.setOptionsElement,g),[b,x,S,w,T]=L(u,e=>[e.comboboxState,e.inputElement,e.buttonElement,e.optionsElement,e.activationTrigger]),E=ge(x||S),D=ge(w),O=we(),[k,j]=le(c,h,O===null?b===J.Open:(O&ce.Open)===ce.Open);me(k,x,u.actions.closeCombobox);let M=!d.__demoMode&&s&&b===J.Open;xe(M,D);let P=!d.__demoMode&&s&&b===J.Open;ne(P,{allowed:(0,W.useCallback)(()=>[x,S,w],[x,S,w])});let re=!L(u,u.selectors.didInputMove)&&k;H(()=>{d.optionsPropsRef.current.static=e.static??!1},[d.optionsPropsRef,e.static]),H(()=>{d.optionsPropsRef.current.hold=i},[d.optionsPropsRef,i]),Le(b===J.Open,{container:w,accept(e){return e.getAttribute(`role`)===`option`?NodeFilter.FILTER_REJECT:e.hasAttribute(`role`)?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(e){e.setAttribute(`role`,`none`)}});let ie=ee([S?.id]),F=Te({open:b===J.Open,option:void 0}),I=z(()=>{u.actions.setActivationTrigger(X.Pointer)}),ae=z(e=>{e.preventDefault(),u.actions.setActivationTrigger(X.Pointer)}),oe=Se(f?_():{},{"aria-labelledby":ie,role:`listbox`,"aria-multiselectable":d.mode===Y.Multi||void 0,id:r,ref:v,style:{...l.style,...m,"--input-width":N(k,x,!0).width,"--button-width":N(k,S,!0).width},onWheel:T===X.Pointer?void 0:I,onMouseDown:ae,...ue(j)}),R=k&&b===J.Closed&&!e.static,B=je(R,d.virtual?.options),de=je(R,d.value),fe=(0,W.useCallback)(e=>d.compare(de,e),[d.compare,de]),pe=(0,W.useMemo)(()=>{if(!d.virtual)return d;if(B===void 0)throw Error("Missing `options` in virtual mode");return B===d.virtual.options?d:{...d,virtual:{...d.virtual,options:B}}},[d,B,d.virtual?.options]);d.virtual&&Object.assign(l,{children:W.createElement(Ct.Provider,{value:pe},W.createElement(Tt,{slot:F},l.children))});let V=ye(),he=(0,W.useMemo)(()=>d.mode===Y.Multi?d:{...d,isSelected:fe},[d,fe]);return W.createElement(ve,{enabled:o?e.static||k:!1,ownerDocument:E},W.createElement(Ct.Provider,{value:he},V({ourProps:oe,theirProps:{...l,children:W.createElement(Oe,{freeze:R},typeof l.children==`function`?l.children?.call(l,F):l.children)},slot:F,defaultTag:Mt,features:Nt,visible:re,name:`Combobox.Options`})))}var Ft=`div`;function It(e,t){var n;let r=Z(`Combobox.Option`),i=xt(`Combobox.Option`),a=(0,te.useId)(),{id:o=`headlessui-combobox-option-${a}`,value:s,disabled:c=((n=r.virtual)?.disabled)?.call(n,s)??!1,order:l=null,...u}=e,[d]=L(i,e=>[e.inputElement]),f=ft(d),p=L(i,(0,W.useCallback)(e=>i.selectors.isActive(e,s,o),[s,o])),m=r.isSelected(s),h=(0,W.useRef)(null),g=de({disabled:c,value:s,domRef:h,order:l}),v=(0,W.useContext)(wt),y=se(t,h,v?v.measureElement:null),b=z(()=>{i.actions.setIsTyping(!1),i.actions.onChange(s)});H(()=>i.actions.registerOption(o,g),[g,o]);let x=L(i,(0,W.useCallback)(e=>i.selectors.shouldScrollIntoView(e,s,o),[s,o]));H(()=>{if(x)return pe().requestAnimationFrame(()=>{var e,t;(t=(e=h.current)?.scrollIntoView)==null||t.call(e,{block:`nearest`})})},[x,h]);let S=z(e=>{e.preventDefault(),e.button===j.Left&&(c||(b(),Ee()||requestAnimationFrame(()=>f()),r.mode===Y.Single&&i.actions.closeCombobox()))}),C=z(()=>{if(c)return i.actions.goToOption({focus:_.Nothing});let e=r.calculateIndex(s);i.actions.goToOption({focus:_.Specific,idx:e})}),w=D(),T=z(e=>w.update(e)),E=z(e=>{if(!w.wasMoved(e)||c||p&&i.state.activationTrigger===X.Pointer)return;let t=r.calculateIndex(s);i.actions.goToOption({focus:_.Specific,idx:t},X.Pointer)}),O=z(e=>{w.wasMoved(e)&&(c||p&&(r.optionsPropsRef.current.hold||i.state.activationTrigger===X.Pointer&&i.actions.goToOption({focus:_.Nothing})))}),k=Te({active:p,focus:p,selected:m,disabled:c}),A={id:o,ref:y,role:`option`,tabIndex:c===!0?void 0:-1,"aria-disabled":c===!0||void 0,"aria-selected":m,disabled:void 0,onMouseDown:S,onFocus:C,onPointerEnter:T,onMouseEnter:T,onPointerMove:E,onMouseMove:E,onPointerLeave:O,onMouseLeave:O};return ye()({ourProps:A,theirProps:u,slot:k,defaultTag:Ft,name:`Combobox.Option`})}var Lt=V(Dt),Rt=V(jt),zt=V(kt),Bt=d,Vt=V(Pt),Ht=V(It),Ut=Object.assign(Lt,{Input:zt,Button:Rt,Label:Bt,Options:Vt,Option:Ht});r.map(e=>({value:e.id,label:e.label,casesFolder:e.casesFolder,templateFolder:e.templateFolder}));function Q(){let e=c().caseTypes;return e?.length?e.map(e=>({...e})):r.map(e=>({...e}))}function Wt(e){let t=Q();return t.find(t=>t.id===e)??t[0]??r[0]}function Gt(e){let t=i(e);return u({caseTypes:t}),l(),t}function Kt(e){let t=e.trim();if(!t)throw Error(`类型名称不能为空`);if(t.length>40)throw Error(`类型名称过长(最多 40 字)`);let n=Q();if(n.some(e=>e.label===t))throw Error(`已存在「${t}」`);let r=a(t),i={id:s(),label:t,...r};return Gt([...n,i]),i}function qt(e,t){let n=t.trim();if(!n)throw Error(`类型名称不能为空`);if(n.length>40)throw Error(`类型名称过长(最多 40 字)`);let r=Q(),i=r.findIndex(t=>t.id===e);if(i<0)throw Error(`类型不存在`);if(r.some(t=>t.id!==e&&t.label===n))throw Error(`已存在「${n}」`);let o=a(n),s={...r[i],label:n,...o},c=[...r];return c[i]=s,Gt(c),s}function Jt(e){let t=Q();if(t.length<=1)throw Error(`至少保留一个用例类型`);if(!t.some(t=>t.id===e))throw Error(`类型不存在`);return Gt(t.filter(t=>t.id!==e))}var Yt=`/__tb_case_sessions`,Xt=`tw.case.sessions.v1`,Zt=!1;function Qt(){return`csess_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function $t(e){if(typeof e==`string`&&e.trim()){let t=e.trim();return Q().some(e=>e.id===t),t}return Q()[0]?.id??`functional`}function en(e){if(!e||!Array.isArray(e.sessions))return{sessions:[],activeId:``};let t=e.sessions.filter(e=>e&&typeof e==`object`&&e.id).map(e=>({...e,caseType:$t(e.caseType)})),n=typeof e.activeId==`string`?e.activeId:``;return t.length&&!t.some(e=>e.id===n)&&(n=t[0].id),t.length||(n=``),{sessions:t,activeId:n}}function tn(){try{let e=localStorage.getItem(o(Xt));return e?en(JSON.parse(e)):{sessions:[],activeId:``}}catch{return{sessions:[],activeId:``}}}function nn(e){try{localStorage.setItem(o(Xt),JSON.stringify(e))}catch{}}async function rn(){try{let e=await fetch(Yt,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json();Zt=!0;let n=en(t.store);return nn(n),n}}catch{}return Zt=!1,tn()}function an(){return tn()}async function on(e){if(nn(e),Zt)try{await fetch(Yt,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({store:e})})}catch{}}function sn(e){nn(e),on(e)}function cn(e){let t=Date.now(),n={id:Qt(),title:e.title?.trim()||`用例生成`,createdAt:t,updatedAt:t,caseType:e.caseType,outputFormat:e.outputFormat,reqPaths:e.reqPaths,templateId:e.templateId,templateTitle:e.templateTitle,promptPath:e.promptPath,knowledgePaths:e.knowledgePaths?.length?[...e.knowledgePaths]:void 0,messages:[]};return sn({sessions:[n,...tn().sessions],activeId:n.id}),n}function ln(e,t){let n=tn(),r=n.sessions.map(n=>n.id===e?{...n,...t,updatedAt:Date.now()}:n),i={...n,sessions:r};return sn(i),i}var $=Re();function un({options:e,values:t,onChange:n,placeholder:r=`选择…`,disabled:i=!1}){let[a,o]=(0,W.useState)(!1),s=(0,W.useRef)(null);(0,W.useEffect)(()=>{if(!a)return;function e(e){s.current?.contains(e.target)||o(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]);let c=e.filter(e=>t.includes(e.value)).map(e=>e.label),l=i||c.length===0?r:c.length<=2?c.join(`、`):`已选 ${c.length} 项`;function u(e){t.includes(e)?n(t.filter(t=>t!==e)):n([...t,e])}return(0,$.jsxs)(`div`,{className:`relative mt-1`,ref:s,children:[(0,$.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>o(e=>!e),className:i?`w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-stone-50 px-3 text-sm text-left text-stone-400 cursor-not-allowed`:`w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-white px-3 text-sm text-left text-stone-800 outline-none hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30`,children:[(0,$.jsx)(`span`,{className:`truncate ${i||c.length?``:`text-stone-400`}`,children:l}),(0,$.jsx)(`svg`,{className:`w-4 h-4 text-stone-400 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,$.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})]}),a?(0,$.jsx)(`div`,{className:`tw-select-menu tw-popover-anim absolute z-80 mt-1 max-h-56 w-full overflow-auto rounded-lg p-1 shadow-lg ring-1 ring-stone-200`,children:e.length===0?(0,$.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`暂无可选项`}):e.map(e=>{let n=t.includes(e.value);return(0,$.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-3 py-2 text-sm text-stone-700 cursor-pointer hover:bg-stone-50`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>u(e.value),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]},e.value)})}):null]})}function dn({options:e,value:t,onChange:n,placeholder:r=`搜索并选择…`,disabled:i=!1,allowEmpty:a=!0,emptyLabel:o=`不选择`}){let[s,c]=(0,W.useState)(``),l=(0,W.useMemo)(()=>{let t=s.trim().toLowerCase();return t?e.filter(e=>e.label.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)):e},[e,s]),u=e.find(e=>e.value===t)??null;return i?(0,$.jsx)(`div`,{className:`relative mt-1`,children:(0,$.jsxs)(`button`,{type:`button`,disabled:!0,className:`w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-stone-50 px-3 text-sm text-left text-stone-400 cursor-not-allowed`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:r}),(0,$.jsx)(`svg`,{className:`w-4 h-4 text-stone-400 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,$.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})]})}):(0,$.jsx)(Ut,{value:u,onChange:e=>{n(e?.value??``),c(``)},immediate:!0,children:(0,$.jsxs)(`div`,{className:`relative mt-1`,children:[(0,$.jsx)(zt,{className:`w-full h-9 rounded-lg border border-stone-200 bg-white px-3 pr-8 text-sm outline-none cursor-text placeholder:text-stone-400 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6]`,displayValue:e=>e?.label??``,onChange:e=>c(e.target.value),placeholder:r}),(0,$.jsx)(Rt,{className:`absolute inset-y-0 right-0 flex items-center pr-2 text-stone-400 cursor-pointer`,children:(0,$.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,$.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})}),(0,$.jsxs)(Vt,{transition:!0,anchor:{to:`bottom start`,gap:4},className:`tw-select-menu tw-menu-anim z-80 max-h-56 w-(--input-width) overflow-auto rounded-lg p-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:[a?(0,$.jsx)(Ht,{value:null,className:`cursor-pointer select-none rounded-md px-3 py-2 text-sm text-stone-400 data-[focus]:bg-stone-50`,children:o}):null,l.length===0?(0,$.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`无匹配项`}):l.map(e=>(0,$.jsx)(Ht,{value:e,className:`cursor-pointer select-none rounded-md px-3 py-2 text-sm text-stone-700 data-[focus]:bg-stone-50 data-[selected]:font-medium`,children:e.label},e.value))]})]})})}export{an as a,Kt as c,Jt as d,qt as f,rn as i,Wt as l,un as n,sn as o,cn as r,ln as s,dn as t,Q as u};
1
+ import{c as e,n as t,t as n}from"./react-dom.CqAxpHMt.js";import{G as r,J as i,K as a,p as o,q as s,r as c,t as l,u}from"./app-config.DUyozIL9.js";import{C as d,D as f,E as p,S as m,T as h,_ as g,a as _,c as v,f as y,g as b,h as x,i as S,l as C,m as w,n as T,o as E,p as D,r as O,s as k,u as A,v as j,w as M,x as ee,y as N}from"./use-text-value.BuY0Cm1z.js";import{$ as te,A as ne,B as P,F as re,J as ie,K as F,L as I,M as L,N as ae,P as oe,V as se,_t as R,c as ce,d as le,dt as z,et as B,f as ue,ft as de,h as fe,ht as pe,it as V,k as me,lt as he,m as ge,mt as _e,n as ve,nt as ye,o as be,p as xe,pt as H,rt as Se,s as Ce,st as U,u as we,ut as Te,v as Ee,x as De}from"./portal.Cm9XlIPf.js";import{a as Oe,c as ke,l as Ae,o as je,s as Me,u as Ne}from"./listbox.Di-t5U37.js";import{n as Pe,r as Fe,t as Ie}from"./active-element-history.CeefGkFQ.js";import{t as Le}from"./use-tree-walker.CfTHFX43.js";import{t as Re}from"./jsx-runtime.BUXbF_vF.js";var W=e(t(),1),G=e(n(),1);function ze(e){return typeof e==`object`?e.key:e}function Be(e,t){let n=e.length;return new Proxy(e,{get(e,r,i){if(typeof r==`string`){let i=r.charCodeAt(0);if(i>=48&&i<=57){let i=+r;if(Number.isInteger(i)&&i>=0&&i<n){let n=e[i];if(typeof n!=`object`){let r=t[i*2];n=e[i]={index:i,key:n,start:r,size:t[i*2+1],end:r+t[i*2+1],lane:0}}return n}}if(r===`length`)return n}return Reflect.get(e,r,i)}})}function K(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return(o.length!==r.length||o.some((e,t)=>r[t]!==e))&&(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1),i}return o.updateDeps=e=>{r=e},o}function Ve(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var q=(e,t)=>Math.abs(e-t)<1.01,He=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})},Ue,We=()=>{if(Ue!==void 0)return Ue;if(typeof navigator>`u`)return Ue=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Ue=!0;let e=navigator.maxTouchPoints;return Ue=navigator.platform===`MacIntel`&&e!==void 0&&e>0},Ge=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Ke=e=>e,qe=e=>{let t=e.overscan*Math.max(e.lanes??1,1),n=Math.max(e.startIndex-t,0),r=Math.min(e.endIndex+t,e.count-1)-n+1,i=Array(r);for(let e=0;e<r;e++)i[e]=n+e;return i},Je=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(Ge(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(Ge(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Ye={passive:!0},Xe=typeof window>`u`||`onscrollend`in window,Ze=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&Xe,o=0,s=a?null:He(i,()=>t(n(r),!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,Ye),a&&r.addEventListener(`scrollend`,u,Ye),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},Qe=(e,t)=>Ze(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),$e=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},et=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},tt=(e,t)=>e===`smooth`?t?`smoothLanded`:`smooth`:`instant`,nt=e=>e?.phase===`smooth`||e?.phase===`smoothLanded`,rt=e=>e.phase===`smooth`||e.phase===`smoothFinishing`;function it(e,t,n,r){if(t===0)return!1;let i=r(0),a=new Set,o=0;for(;o<e;){let e=n(o);if(e===i)break;a.add(e),o++}let s=e-o;if(s===0||s>=t)return!1;for(let e=0;e<s;e++)if(r(e)!==n(o+e))return!1;for(let e=s;e<t;e++)if(a.has(r(e)))return!1;return!0}var at=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this._clampedAdjustment=null,this.elementsCache=new Map,this._resizeBatch=null,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{let t=()=>{let t={sync:!1};this._resizeBatch=t;try{e.forEach(n)}finally{this._resizeBatch=null,t.notify&&(this.notify(t.sync),this._retryClampedAdjustment())}};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})),n=e=>{let t=e.target,n=this.indexFromElement(t);if(t.isConnected)this.isIndexInRange(n)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this));else{this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}}};return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Ke,rangeExtractor:qe,onChange:()=>{},measureElement:$e,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=this._singleLaneMeasurements?.items??s,l=e=>ze(c[e]),u=e>0?l(0):null,d=e>0?l(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==u||t.getItemKey(o-1)!==d)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>0&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==d)&&(o>e||it(e,o,l,t.getItemKey))&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:a,getItemKey:c}=this.options,l=0;for(;l<a&&c(l)!==e;)l++;if(l<a){let e=n[l];if(e){let n=Math.max(0,e.start+t);!i&&n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=K(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._clampedAdjustment=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5?e=this._intendedScrollOffset:this.scrollState?.index!=null&&!rt(this.scrollState)&&!q(e,this.scrollState.lastTargetOffset)&&!q(e,this.getScrollStateTarget(this.scrollState))&&(this._clampedAdjustment===null||Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5)&&(this.scrollState=null),this._intendedScrollOffset=null,this.scrollState&&(this.scrollState.writtenOffset=null),this._clampedAdjustment!==null&&Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null),this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,We()&&this.targetWindow!=null&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,Ye),e.addEventListener(`touchend`,n,Ye),e.addEventListener(`touchcancel`,n,Ye),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),e.removeEventListener(`touchcancel`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(We()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):nt(this.scrollState)&&!q(this.getScrollOffset()-i,this.scrollState.lastTargetOffset)||this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}this._retryClampedAdjustment()},this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;let{target:e,maxAtWrite:t}=this._clampedAdjustment,n=this.getMaxScrollOffset();n>t+.5&&(this._clampedAdjustment=e>n+.5?{target:e,maxAtWrite:n}:null,this._scrollToOffset(e,{adjustments:void 0,behavior:void 0}))},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=K(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=K(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._singleLaneMeasurements?.flat;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e}let o=u===0?Array(e):this._singleLaneMeasurements.items.slice(),c;if(u===0)c=t+n;else{let e=u-1;c=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t);o[t]=e;let n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=c,a[t*2+1]=i,c+=i+s}this._singleLaneMeasurements={flat:a,items:o};let d=Be(o,a);return this.measurementsCache=d,d}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=K(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=ct(e,t,n,r,r===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=K(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t,this.options.lanes]},(e,t,n,r,i,a)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n,lanes:a}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!nt(this.scrollState))return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),e.isConnected&&(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{var n;if(!this.isIndexInRange(e))return;this._resizeBatch?.sync&&this.getMeasurements();let r,i,a,o=this._singleLaneMeasurements?.flat;if(this.options.lanes===1&&o!=null)a=this.options.getItemKey(e),i=o[e*2],r=o[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;a=t.key,i=t.start,r=t.size}let s=this.itemSizeCache.get(a)??r,c=t-s;if(c!==0){let o=this.options.anchorTo===`end`&&!nt(this.scrollState)&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,l=o?this.getTotalSize():0,u=this.getScrollOffset()+this.scrollAdjustments,d=this.itemSizeCache.has(a)?i+s<=u&&this.scrollDirection!==`backward`:i<u,f=!nt(this.scrollState)&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?d:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:a,start:i,size:r,end:i+r,lane:0},c,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(a,t),this.itemSizeCacheVersion++;let p=this.scrollState?.writtenOffset!=null&&!q(this.scrollState.writtenOffset,this.getScrollOffset()+this.scrollAdjustments),m=!1;if(p||(o?m=this.applyScrollAdjustment(this.getTotalSize()-l):f&&(m=this.applyScrollAdjustment(c))),this._resizeBatch){this._resizeBatch.notify=!0,(n=this._resizeBatch).sync||(n.sync=m);return}this.notify(m),this._retryClampedAdjustment()}},this.getVirtualItems=K(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._singleLaneMeasurements?.flat,r=this.options.lanes===1&&n!=null;return Ve(t[ot(0,t.length-1,r?e=>n[e*2]:e=>Ve(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1){let e=this.getMaxScrollOffset(),n=e-this.options.paddingEnd+this.options.scrollPaddingEnd;return[Math.max(Math.min(n,e),0),t]}let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0;let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,startedAt:i,lastTargetOffset:r,stableFrames:0,phase:tt(n,!1)},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,startedAt:o,lastTargetOffset:i,stableFrames:0,phase:tt(n,q(i,this.getScrollOffset()))},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getOffsetForAlignment((this.scrollState?.writtenOffset??this.getScrollOffset())+e,`start`),r=this.now();this.scrollState={index:null,align:`start`,startedAt:r,lastTargetOffset:n,stableFrames:0,phase:tt(t,!1)},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this._iosDeferredAdjustment=0;let t=Math.max(this.getMaxScrollOffset(),0);this.scrollState={index:this.options.count-1,align:`end`,toEnd:!0,startedAt:this.now(),lastTargetOffset:t,stableFrames:0,phase:tt(e,q(t,this.getScrollOffset()))},this._scrollToOffset(t,{adjustments:void 0,behavior:e}),this.scheduleScrollReconcile()}else this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.cancelScroll=()=>{this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._singleLaneMeasurements?.flat;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.scrollState&&(this.scrollState.writtenOffset=n===`smooth`?null:this._intendedScrollOffset),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){if(e===0)return!1;if(We()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded))return this.scrollState?.index??(this._iosDeferredAdjustment+=e),!1;{let n=this.getScrollOffset()+this.scrollAdjustments+e,r=this.scrollElement,i=r!==null&&(`scrollHeight`in r||`document`in r)?this.getMaxScrollOffset():null;return this._clampedAdjustment=i!==null&&n>i+.5?{target:n,maxAtWrite:i}:null,this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0}}scheduleScrollReconcile(){this.targetWindow?this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}):this.scrollState=null}getScrollStateTarget(e){let t=e.toEnd?[Math.max(this.getMaxScrollOffset(),0)]:e.index==null?void 0:this.getOffsetForIndex(e.index,e.align);return t?t[0]:e.lastTargetOffset}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}this.getMeasurements();let e=this.getScrollStateTarget(this.scrollState),t=this.scrollState.index==null?1:this.options.useAnimationFrameWithResizeObserver?3:2,n=e!==this.scrollState.lastTargetOffset;if(!n&&q(e,this.getScrollOffset())){if(this.scrollState.phase===`smooth`?this.scrollState.phase=`smoothLanded`:this.scrollState.phase===`smoothFinishing`&&(this.scrollState.phase=`instant`),this.scrollState.stableFrames++,this.scrollState.stableFrames>=t){this.getScrollOffset()!==e&&this._scrollToOffset(e,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let t=this.getSize()||600,n=Math.abs(e-this.getScrollOffset()),r=nt(this.scrollState)&&n>t;this.scrollState.lastTargetOffset=e,r?this.scrollState.phase=`smooth`:this.scrollState.phase===`smooth`?this.scrollState.phase=`smoothFinishing`:this.scrollState.phase===`smoothLanded`&&(this.scrollState.phase=`instant`),this._scrollToOffset(e,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},ot=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function st(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function ct(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=st(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=ot(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var lt=typeof document<`u`?W.useLayoutEffect:W.useEffect;function ut({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=W.useReducer(e=>e+1,0)[1],a=W.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=W.useRef(!1),s=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},c=(e,t,n)=>{let r=a.current,i=!!e.options.horizontal,o=t.start-e.options.scrollMargin;r.lastPositions.get(n)!==o&&(r.lastPositions.set(n,o),r.mode===`transform`?n.style.transform=i?`translate3d(${o}px, 0, 0)`:`translate3d(0, ${o}px, 0)`:n.style[i?`left`:`top`]=`${o}px`)},l=e=>{let t=a.current;if(t.enabled&&t.container){s(e);for(let t of e.getVirtualItems()){let n=e.elementsCache.get(t.key);n&&c(e,t,n)}}},u={...r,onChange:(t,n)=>{var s;let c=a.current,u=!0;if(c.enabled){l(t);let e=t.range,n=c.prevRange;u=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,u&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}u&&(e&&n&&!o.current?(0,G.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[d]=W.useState(()=>{let e=new at(u),t=e.measureElement;return e.measureElement=n=>{o.current=!0;try{t(n)}finally{o.current=!1}let r=a.current;if(n!==null&&r.enabled&&r.container){let t=e.measurementsCache[e.indexFromElement(n)];t&&c(e,t,n)}},Object.assign(e,{containerRef:t=>{let n=a.current;n.container=t,n.lastSize=null,t!==null&&l(e)}})});return d.setOptions(u),lt(()=>d._didMount(),[]),lt(()=>(s(d),d._willUpdate())),lt(()=>{l(d)}),d}function dt(e){return ut({observeElementRect:Je,observeElementOffset:Qe,scrollToFn:et,...e})}function ft(e){let t=(0,W.useRef)({value:``,selectionStart:null,selectionEnd:null});return Fe(e,`blur`,e=>{let n=e.target;F(n)&&(t.current={value:n.value,selectionStart:n.selectionStart,selectionEnd:n.selectionEnd})}),z(()=>{if(!R(e)&&F(e)&&e.isConnected){if(e.focus({preventScroll:!0}),e.value!==t.current.value)e.setSelectionRange(e.value.length,e.value.length);else{let{selectionStart:n,selectionEnd:r}=t.current;n!==null&&r!==null&&e.setSelectionRange(n,r)}t.current={value:``,selectionStart:null,selectionEnd:null}}})}var pt=Object.defineProperty,mt=(e,t,n)=>t in e?pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ht=(e,t,n)=>(mt(e,typeof t==`symbol`?t:t+``,n),n),J=(e=>(e[e.Open=0]=`Open`,e[e.Closed=1]=`Closed`,e))(J||{}),Y=(e=>(e[e.Single=0]=`Single`,e[e.Multi=1]=`Multi`,e))(Y||{}),X=(e=>(e[e.Pointer=0]=`Pointer`,e[e.Focus=1]=`Focus`,e[e.Other=2]=`Other`,e))(X||{}),gt=(e=>(e[e.OpenCombobox=0]=`OpenCombobox`,e[e.CloseCombobox=1]=`CloseCombobox`,e[e.GoToOption=2]=`GoToOption`,e[e.SetTyping=3]=`SetTyping`,e[e.RegisterOption=4]=`RegisterOption`,e[e.UnregisterOption=5]=`UnregisterOption`,e[e.DefaultToFirstOption=6]=`DefaultToFirstOption`,e[e.SetActivationTrigger=7]=`SetActivationTrigger`,e[e.UpdateVirtualConfiguration=8]=`UpdateVirtualConfiguration`,e[e.SetInputElement=9]=`SetInputElement`,e[e.SetButtonElement=10]=`SetButtonElement`,e[e.SetOptionsElement=11]=`SetOptionsElement`,e[e.MarkInputAsMoved=12]=`MarkInputAsMoved`,e))(gt||{});function _t(e,t=e=>e){let n=e.activeOptionIndex===null?null:e.options[e.activeOptionIndex],r=t(e.options.slice()),i=r.length>0&&r[0].dataRef.current.order!==null?r.sort((e,t)=>e.dataRef.current.order-t.dataRef.current.order):De(r,e=>e.dataRef.current.domRef.current),a=n?i.indexOf(n):null;return a===-1&&(a=null),{options:i,activeOptionIndex:a}}var vt={1(e){var t;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===1)return e;let n=e.inputElement?O.Tracked(T(e.inputElement)):e.inputPositionState;return{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,inputPositionState:n,__demoMode:!1}},0(e){var t,n;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===0)return e;if((n=e.dataRef.current)!=null&&n.value){let t=e.dataRef.current.calculateIndex(e.dataRef.current.value);if(t!==-1)return{...e,activeOptionIndex:t,comboboxState:0,__demoMode:!1,inputPositionState:O.Idle}}return{...e,comboboxState:0,inputPositionState:O.Idle,__demoMode:!1}},3(e,t){return e.isTyping===t.isTyping?e:{...e,isTyping:t.isTyping}},2(e,t){var n,r;if((n=e.dataRef.current)!=null&&n.disabled||e.optionsElement&&!((r=e.dataRef.current)!=null&&r.optionsPropsRef.current.static)&&e.comboboxState===1)return e;if(e.virtual){let{options:n,disabled:r}=e.virtual,i=t.focus===_.Specific?t.idx:E(t,{resolveItems:()=>n,resolveActiveIndex:()=>e.activeOptionIndex??n.findIndex(e=>!r(e))??null,resolveDisabled:r,resolveId(){throw Error(`Function not implemented.`)}}),a=t.trigger??2;return e.activeOptionIndex===i&&e.activationTrigger===a?e:{...e,activeOptionIndex:i,activationTrigger:a,isTyping:!1,__demoMode:!1}}let i=_t(e);if(i.activeOptionIndex===null){let e=i.options.findIndex(e=>!e.dataRef.current.disabled);e!==-1&&(i.activeOptionIndex=e)}let a=t.focus===_.Specific?t.idx:E(t,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:e=>e.id,resolveDisabled:e=>e.dataRef.current.disabled}),o=t.trigger??2;return e.activeOptionIndex===a&&e.activationTrigger===o?e:{...e,...i,isTyping:!1,activeOptionIndex:a,activationTrigger:o,__demoMode:!1}},4:(e,t)=>{var n,r,i,a;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:[...e.options,t.payload]};let o=t.payload,s=_t(e,e=>(e.push(o),e));e.activeOptionIndex===null&&(i=(r=e.dataRef.current).isSelected)!=null&&i.call(r,t.payload.dataRef.current.value)&&(s.activeOptionIndex=s.options.indexOf(o));let c={...e,...s,activationTrigger:2};return(a=e.dataRef.current)!=null&&a.__demoMode&&e.dataRef.current.value===void 0&&(c.activeOptionIndex=0),c},5:(e,t)=>{var n;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:e.options.filter(e=>e.id!==t.id)};let r=_t(e,e=>{let n=e.findIndex(e=>e.id===t.id);return n!==-1&&e.splice(n,1),e});return{...e,...r,activationTrigger:2}},6:(e,t)=>e.defaultToFirstOption===t.value?e:{...e,defaultToFirstOption:t.value},7:(e,t)=>e.activationTrigger===t.trigger?e:{...e,activationTrigger:t.trigger},8:(e,t)=>{if(e.virtual===null)return{...e,virtual:{options:t.options,disabled:t.disabled??(()=>!1)}};if(e.virtual.options===t.options&&e.virtual.disabled===t.disabled)return e;let n=e.activeOptionIndex;if(e.activeOptionIndex!==null){let r=t.options.indexOf(e.virtual.options[e.activeOptionIndex]);n=r===-1?null:r}return{...e,activeOptionIndex:n,virtual:{options:t.options,disabled:t.disabled??(()=>!1)}}},9:(e,t)=>e.inputElement===t.element?e:{...e,inputElement:t.element},10:(e,t)=>e.buttonElement===t.element?e:{...e,buttonElement:t.element},11:(e,t)=>e.optionsElement===t.element?e:{...e,optionsElement:t.element},12(e){return e.inputPositionState.kind===`Tracked`?{...e,inputPositionState:O.Moved}:e}},yt=class e extends re{constructor(e){super(e),ht(this,`actions`,{onChange:e=>{let{onChange:t,compare:n,mode:r,value:i}=this.state.dataRef.current;return U(r,{0:()=>t?.(e),1:()=>{let r=i.slice(),a=r.findIndex(t=>n(t,e));return a===-1?r.push(e):r.splice(a,1),t?.(r)}})},registerOption:(e,t)=>(this.send({type:4,payload:{id:e,dataRef:t}}),()=>{this.state.activeOptionIndex===this.state.dataRef.current.calculateIndex(t.current.value)&&this.send({type:6,value:!0}),this.send({type:5,id:e})}),goToOption:(e,t)=>(this.send({type:6,value:!1}),this.send({type:2,...e,trigger:t})),setIsTyping:e=>{this.send({type:3,isTyping:e})},closeCombobox:()=>{var e,t;this.send({type:1}),this.send({type:6,value:!1}),(t=(e=this.state.dataRef.current).onClose)==null||t.call(e)},openCombobox:()=>{this.send({type:0}),this.send({type:6,value:!0})},setActivationTrigger:e=>{this.send({type:7,trigger:e})},selectActiveOption:()=>{let e=this.selectors.activeOptionIndex(this.state);if(e!==null){if(this.actions.setIsTyping(!1),this.state.virtual)this.actions.onChange(this.state.virtual.options[e]);else{let{dataRef:t}=this.state.options[e];this.actions.onChange(t.current.value)}this.actions.goToOption({focus:_.Specific,idx:e})}},setInputElement:e=>{this.send({type:9,element:e})},setButtonElement:e=>{this.send({type:10,element:e})},setOptionsElement:e=>{this.send({type:11,element:e})}}),ht(this,`selectors`,{activeDescendantId:e=>{let t=this.selectors.activeOptionIndex(e);if(t!==null)return e.virtual?e.options.find(n=>!n.dataRef.current.disabled&&e.dataRef.current.compare(n.dataRef.current.value,e.virtual.options[t]))?.id:e.options[t]?.id},activeOptionIndex:e=>{if(e.defaultToFirstOption&&e.activeOptionIndex===null&&(e.virtual?e.virtual.options.length>0:e.options.length>0)){if(e.virtual){let{options:t,disabled:n}=e.virtual,r=t.findIndex(e=>{var t;return!((t=n?.(e))!=null&&t)});if(r!==-1)return r}let t=e.options.findIndex(e=>!e.dataRef.current.disabled);if(t!==-1)return t}return e.activeOptionIndex},activeOption:e=>{let t=this.selectors.activeOptionIndex(e);return t===null?null:e.virtual?e.virtual.options[t??0]:e.options[t]?.dataRef.current.value??null},isActive:(e,t,n)=>{let r=this.selectors.activeOptionIndex(e);return r===null?!1:e.virtual?r===e.dataRef.current.calculateIndex(t):e.options[r]?.id===n},shouldScrollIntoView:(e,t,n)=>!(e.virtual||e.__demoMode||e.comboboxState!==0||e.activationTrigger===0||!this.selectors.isActive(e,t,n)),didInputMove(e){return e.inputPositionState.kind===`Moved`}});{let e=this.state.id,t=oe.get(null);this.disposables.add(t.on(ae.Push,n=>{!t.selectors.isTop(n,e)&&this.state.comboboxState===0&&this.actions.closeCombobox()})),this.on(0,()=>t.actions.push(e)),this.on(1,()=>t.actions.pop(e))}this.disposables.group(e=>{this.on(1,t=>{t.inputElement&&(e.dispose(),e.add(S(t.inputElement,t.inputPositionState,()=>{this.send({type:12})})))})})}static new({id:t,virtual:n=null,__demoMode:r=!1}){return new e({id:t,dataRef:{current:{}},comboboxState:+!r,isTyping:!1,options:[],virtual:n?{options:n.options,disabled:n.disabled??(()=>!1)}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:r,inputPositionState:O.Idle})}reduce(e,t){return U(t.type,vt,e,t)}},bt=(0,W.createContext)(null);function xt(e){let t=(0,W.useContext)(bt);if(t===null){let t=Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,St),t}return t}function St({id:e,virtual:t=null,__demoMode:n=!1}){let r=(0,W.useMemo)(()=>yt.new({id:e,virtual:t,__demoMode:n}),[]);return be(()=>r.dispose()),r}var Ct=(0,W.createContext)(null);Ct.displayName=`ComboboxDataContext`;function Z(e){let t=(0,W.useContext)(Ct);if(t===null){let t=Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,Z),t}return t}var wt=(0,W.createContext)(null);function Tt(e){let t=xt(`VirtualProvider`),{options:n}=Z(`VirtualProvider`).virtual,r=L(t,e=>e.optionsElement),[i,a]=(0,W.useMemo)(()=>{let e=r;if(!e)return[0,0];let t=window.getComputedStyle(e);return[parseFloat(t.paddingBlockStart||t.paddingTop),parseFloat(t.paddingBlockEnd||t.paddingBottom)]},[r]),o=dt({enabled:n.length!==0,scrollPaddingStart:i,scrollPaddingEnd:a,count:n.length,estimateSize(){return 40},getScrollElement(){return t.state.optionsElement},overscan:12}),[s,c]=(0,W.useState)(0);H(()=>{c(e=>e+1)},[n]);let l=o.getVirtualItems(),u=L(t,e=>e.activationTrigger===X.Pointer),d=L(t,t.selectors.activeOptionIndex);return l.length===0?null:W.createElement(wt.Provider,{value:o},W.createElement(`div`,{style:{position:`relative`,width:`100%`,height:`${o.getTotalSize()}px`},ref:e=>{e&&(u||d!==null&&n.length>d&&o.scrollToIndex(d))}},l.map(t=>W.createElement(W.Fragment,{key:t.key},W.cloneElement(e.children?.call(e,{...e.slot,option:n[t.index]}),{key:`${s}-${t.key}`,"data-index":t.index,"aria-setsize":n.length,"aria-posinset":t.index+1,style:{position:`absolute`,top:0,left:0,transform:`translateY(${t.start}px)`,overflowAnchor:`none`}})))))}var Et=W.Fragment;function Dt(e,t){let n=(0,te.useId)(),r=he(),{value:i,defaultValue:a,onChange:o,form:s,name:c,by:l,invalid:u=!1,disabled:d=r||!1,onClose:f,__demoMode:p=!1,multiple:h=!1,immediate:g=!1,virtual:_=null,nullable:v,...y}=e,b=Ae(a),[x=h?[]:void 0,S]=Ne(i,o,b),C=St({id:n,virtual:_,__demoMode:p}),w=(0,W.useRef)({static:!1,hold:!1}),T=Me(l),E=z(e=>_?l===null?_.options.indexOf(e):_.options.findIndex(t=>T(t,e)):C.state.options.findIndex(t=>T(t.dataRef.current.value,e))),D=(0,W.useCallback)(e=>U(j.mode,{[Y.Multi]:()=>x.some(t=>T(t,e)),[Y.Single]:()=>T(x,e)}),[x]),O=L(C,e=>e.virtual),A=z(()=>f?.()),j=(0,W.useMemo)(()=>({__demoMode:p,immediate:g,optionsPropsRef:w,value:x,defaultValue:b,disabled:d,invalid:u,mode:h?Y.Multi:Y.Single,virtual:_?O:null,onChange:S,isSelected:D,calculateIndex:E,compare:T,onClose:A}),[p,g,w,x,b,d,u,h,_,O,S,D,E,T,A]);H(()=>{_&&C.send({type:gt.UpdateVirtualConfiguration,options:_.options,disabled:_.disabled??null})},[_,_?.options,_?.disabled]),H(()=>{C.state.dataRef.current=j},[j]);let[M,ee,N,ne]=L(C,e=>[e.comboboxState,e.buttonElement,e.inputElement,e.optionsElement]),P=oe.get(null),re=L(P,(0,W.useCallback)(e=>P.selectors.isTop(e,n),[P,n]));fe(re,[ee,N,ne],()=>C.actions.closeCombobox());let ie=L(C,C.selectors.activeOptionIndex),F=L(C,C.selectors.activeOption),I=Te({open:M===J.Open,disabled:d,invalid:u,activeIndex:ie,activeOption:F,value:x}),[ae,se]=m(),R=t===null?{}:{ref:t},le=(0,W.useCallback)(()=>{if(b!==void 0)return S?.(b)},[S,b]),B=ye();return W.createElement(se,{value:ae,props:{htmlFor:N?.id},slot:{open:M===J.Open,disabled:d}},W.createElement(k,null,W.createElement(Ct.Provider,{value:j},W.createElement(bt.Provider,{value:C},W.createElement(Ce,{value:U(M,{[J.Open]:ce.Open,[J.Closed]:ce.Closed})},c!=null&&W.createElement(ke,{disabled:d,data:x==null?{}:{[c]:x},form:s,onReset:le}),B({ourProps:R,theirProps:y,slot:I,defaultTag:Et,name:`Combobox`}))))))}var Ot=`input`;function kt(e,t){let n=xt(`Combobox.Input`),r=Z(`Combobox.Input`),i=(0,te.useId)(),a=M(),{id:o=a||`headlessui-combobox-input-${i}`,onChange:s,displayValue:c,disabled:l=r.disabled||!1,autoFocus:u=!1,type:d=`text`,...m}=e,h=(0,W.useRef)(null),g=se(h,t,v(),n.actions.setInputElement),[y,b]=L(n,e=>[e.comboboxState,e.isTyping]),x=_e(),S=z(()=>{n.actions.onChange(null),n.state.optionsElement&&(n.state.optionsElement.scrollTop=0),n.actions.goToOption({focus:_.Nothing})}),C=(0,W.useMemo)(()=>typeof c==`function`&&r.value!==void 0?c(r.value)??``:typeof r.value==`string`?r.value:``,[r.value,c]);Pe(([e,t],[r,i])=>{if(n.state.isTyping)return;let a=h.current;a&&((i===J.Open&&t===J.Closed||e!==r)&&(a.value=e),requestAnimationFrame(()=>{if(n.state.isTyping||!a||R(a))return;let{selectionStart:e,selectionEnd:t}=a;Math.abs((t??0)-(e??0))===0&&e===0&&a.setSelectionRange(a.value.length,a.value.length)}))},[C,y,b]),Pe(([e],[t])=>{if(e===J.Open&&t===J.Closed){if(n.state.isTyping)return;let e=h.current;if(!e)return;let t=e.value,{selectionStart:r,selectionEnd:i,selectionDirection:a}=e;e.value=``,e.value=t,a===null?e.setSelectionRange(r,i):e.setSelectionRange(r,i,a)}},[y]);let w=(0,W.useRef)(!1),T=z(()=>{w.current=!0}),E=z(()=>{x.nextFrame(()=>{w.current=!1})}),D=z(e=>{switch(n.actions.setIsTyping(!0),e.key){case I.Enter:if(n.state.comboboxState!==J.Open||w.current)return;if(e.preventDefault(),e.stopPropagation(),n.selectors.activeOptionIndex(n.state)===null){n.actions.closeCombobox();return}n.actions.selectActiveOption(),r.mode===Y.Single&&n.actions.closeCombobox();break;case I.ArrowDown:return e.preventDefault(),e.stopPropagation(),U(n.state.comboboxState,{[J.Open]:()=>n.actions.goToOption({focus:_.Next}),[J.Closed]:()=>n.actions.openCombobox()});case I.ArrowUp:return e.preventDefault(),e.stopPropagation(),U(n.state.comboboxState,{[J.Open]:()=>n.actions.goToOption({focus:_.Previous}),[J.Closed]:()=>{(0,G.flushSync)(()=>n.actions.openCombobox()),r.value||n.actions.goToOption({focus:_.Last})}});case I.Home:if(n.state.comboboxState===J.Closed||e.shiftKey)break;return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:_.First});case I.PageUp:return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:_.First});case I.End:if(n.state.comboboxState===J.Closed||e.shiftKey)break;return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:_.Last});case I.PageDown:return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:_.Last});case I.Escape:return n.state.comboboxState===J.Open?(e.preventDefault(),n.state.optionsElement&&!r.optionsPropsRef.current.static&&e.stopPropagation(),r.mode===Y.Single&&r.value===null&&S(),n.actions.closeCombobox()):void 0;case I.Tab:if(n.actions.setIsTyping(!1),n.state.comboboxState!==J.Open)return;r.mode===Y.Single&&n.state.activationTrigger!==X.Focus&&n.actions.selectActiveOption(),n.actions.closeCombobox()}}),O=z(e=>{s?.(e),r.mode===Y.Single&&e.target.value===``&&S(),n.actions.openCombobox()}),k=z(e=>{var t,i;let a=e.relatedTarget??Ie.find(t=>t!==e.currentTarget);if(!((t=n.state.optionsElement)!=null&&t.contains(a))&&!((i=n.state.buttonElement)!=null&&i.contains(a))&&n.state.comboboxState===J.Open)return e.preventDefault(),r.mode===Y.Single&&r.value===null&&S(),n.actions.closeCombobox()}),A=z(e=>{var t,i;let a=e.relatedTarget??Ie.find(t=>t!==e.currentTarget);(t=n.state.buttonElement)!=null&&t.contains(a)||(i=n.state.optionsElement)!=null&&i.contains(a)||r.disabled||r.immediate&&n.state.comboboxState!==J.Open&&x.microTask(()=>{(0,G.flushSync)(()=>n.actions.openCombobox()),n.actions.setActivationTrigger(X.Focus)})}),j=ee(),N=P(),{isFocused:ne,focusProps:re}=f({autoFocus:u}),{isHovered:ie,hoverProps:F}=p({isDisabled:l}),ae=L(n,e=>e.optionsElement),oe=Te({open:y===J.Open,disabled:l,invalid:r.invalid,hover:ie,focus:ne,autofocus:u}),ce=Se({ref:g,id:o,role:`combobox`,type:d,"aria-controls":ae?.id,"aria-expanded":y===J.Open,"aria-activedescendant":L(n,n.selectors.activeDescendantId),"aria-labelledby":j,"aria-describedby":N,"aria-autocomplete":`list`,defaultValue:e.defaultValue??(r.defaultValue===void 0?null:c?.(r.defaultValue))??r.defaultValue,disabled:l||void 0,autoFocus:u,onCompositionStart:T,onCompositionEnd:E,onKeyDown:D,onChange:O,onFocus:A,onBlur:k},re,F);return ye()({ourProps:ce,theirProps:m,slot:oe,defaultTag:Ot,name:`Combobox.Input`})}var At=`button`;function jt(e,t){let n=xt(`Combobox.Button`),r=Z(`Combobox.Button`),[i,a]=(0,W.useState)(null),o=se(t,a,n.actions.setButtonElement),s=(0,te.useId)(),{id:c=`headlessui-combobox-button-${s}`,disabled:l=r.disabled||!1,autoFocus:u=!1,...d}=e,[m,v,y]=L(n,e=>[e.comboboxState,e.inputElement,e.optionsElement]),S=ft(v),C=m===J.Open;x(C,{trigger:i,action:(0,W.useCallback)(e=>{if(i!=null&&i.contains(e.target)||v!=null&&v.contains(e.target))return b.Ignore;let t=e.target.closest(`[role="option"]:not([data-disabled])`);return ie(t)?b.Select(t):y!=null&&y.contains(e.target)?b.Ignore:b.Close},[i,v,y]),close:n.actions.closeCombobox,select:n.actions.selectActiveOption});let T=z(e=>{switch(e.key){case I.Space:case I.Enter:e.preventDefault(),e.stopPropagation(),n.state.comboboxState===J.Closed&&(0,G.flushSync)(()=>n.actions.openCombobox()),S();return;case I.ArrowDown:e.preventDefault(),e.stopPropagation(),n.state.comboboxState===J.Closed&&((0,G.flushSync)(()=>n.actions.openCombobox()),n.state.dataRef.current.value||n.actions.goToOption({focus:_.First})),S();return;case I.ArrowUp:e.preventDefault(),e.stopPropagation(),n.state.comboboxState===J.Closed&&((0,G.flushSync)(()=>n.actions.openCombobox()),n.state.dataRef.current.value||n.actions.goToOption({focus:_.Last})),S();return;case I.Escape:if(n.state.comboboxState!==J.Open)return;e.preventDefault(),n.state.optionsElement&&!r.optionsPropsRef.current.static&&e.stopPropagation(),(0,G.flushSync)(()=>n.actions.closeCombobox()),S();return;default:return}}),E=g(()=>{n.state.comboboxState===J.Open?n.actions.closeCombobox():n.actions.openCombobox(),S()}),D=ee([c]),{isFocusVisible:O,focusProps:k}=f({autoFocus:u}),{isHovered:A,hoverProps:j}=p({isDisabled:l}),{pressed:M,pressProps:N}=h({disabled:l}),ne=Te({open:m===J.Open,active:M||m===J.Open,disabled:l,invalid:r.invalid,value:r.value,hover:A,focus:O}),P=Se({ref:o,id:c,type:w(e,i),tabIndex:-1,"aria-haspopup":`listbox`,"aria-controls":y?.id,"aria-expanded":m===J.Open,"aria-labelledby":D,disabled:l||void 0,autoFocus:u,onKeyDown:T},E,k,j,N);return ye()({ourProps:P,theirProps:d,slot:ne,defaultTag:At,name:`Combobox.Button`})}var Mt=`div`,Nt=B.RenderStrategy|B.Static;function Pt(e,t){let n=(0,te.useId)(),{id:r=`headlessui-combobox-options-${n}`,hold:i=!1,anchor:a,portal:o=!1,modal:s=!0,transition:c=!1,...l}=e,u=xt(`Combobox.Options`),d=Z(`Combobox.Options`),f=y(a);f&&(o=!0);let[p,m]=C(f),[h,g]=(0,W.useState)(null),_=A(),v=se(t,f?p:null,u.actions.setOptionsElement,g),[b,x,S,w,T]=L(u,e=>[e.comboboxState,e.inputElement,e.buttonElement,e.optionsElement,e.activationTrigger]),E=ge(x||S),D=ge(w),O=we(),[k,j]=le(c,h,O===null?b===J.Open:(O&ce.Open)===ce.Open);me(k,x,u.actions.closeCombobox);let M=!d.__demoMode&&s&&b===J.Open;xe(M,D);let P=!d.__demoMode&&s&&b===J.Open;ne(P,{allowed:(0,W.useCallback)(()=>[x,S,w],[x,S,w])});let re=!L(u,u.selectors.didInputMove)&&k;H(()=>{d.optionsPropsRef.current.static=e.static??!1},[d.optionsPropsRef,e.static]),H(()=>{d.optionsPropsRef.current.hold=i},[d.optionsPropsRef,i]),Le(b===J.Open,{container:w,accept(e){return e.getAttribute(`role`)===`option`?NodeFilter.FILTER_REJECT:e.hasAttribute(`role`)?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(e){e.setAttribute(`role`,`none`)}});let ie=ee([S?.id]),F=Te({open:b===J.Open,option:void 0}),I=z(()=>{u.actions.setActivationTrigger(X.Pointer)}),ae=z(e=>{e.preventDefault(),u.actions.setActivationTrigger(X.Pointer)}),oe=Se(f?_():{},{"aria-labelledby":ie,role:`listbox`,"aria-multiselectable":d.mode===Y.Multi||void 0,id:r,ref:v,style:{...l.style,...m,"--input-width":N(k,x,!0).width,"--button-width":N(k,S,!0).width},onWheel:T===X.Pointer?void 0:I,onMouseDown:ae,...ue(j)}),R=k&&b===J.Closed&&!e.static,B=je(R,d.virtual?.options),de=je(R,d.value),fe=(0,W.useCallback)(e=>d.compare(de,e),[d.compare,de]),pe=(0,W.useMemo)(()=>{if(!d.virtual)return d;if(B===void 0)throw Error("Missing `options` in virtual mode");return B===d.virtual.options?d:{...d,virtual:{...d.virtual,options:B}}},[d,B,d.virtual?.options]);d.virtual&&Object.assign(l,{children:W.createElement(Ct.Provider,{value:pe},W.createElement(Tt,{slot:F},l.children))});let V=ye(),he=(0,W.useMemo)(()=>d.mode===Y.Multi?d:{...d,isSelected:fe},[d,fe]);return W.createElement(ve,{enabled:o?e.static||k:!1,ownerDocument:E},W.createElement(Ct.Provider,{value:he},V({ourProps:oe,theirProps:{...l,children:W.createElement(Oe,{freeze:R},typeof l.children==`function`?l.children?.call(l,F):l.children)},slot:F,defaultTag:Mt,features:Nt,visible:re,name:`Combobox.Options`})))}var Ft=`div`;function It(e,t){var n;let r=Z(`Combobox.Option`),i=xt(`Combobox.Option`),a=(0,te.useId)(),{id:o=`headlessui-combobox-option-${a}`,value:s,disabled:c=((n=r.virtual)?.disabled)?.call(n,s)??!1,order:l=null,...u}=e,[d]=L(i,e=>[e.inputElement]),f=ft(d),p=L(i,(0,W.useCallback)(e=>i.selectors.isActive(e,s,o),[s,o])),m=r.isSelected(s),h=(0,W.useRef)(null),g=de({disabled:c,value:s,domRef:h,order:l}),v=(0,W.useContext)(wt),y=se(t,h,v?v.measureElement:null),b=z(()=>{i.actions.setIsTyping(!1),i.actions.onChange(s)});H(()=>i.actions.registerOption(o,g),[g,o]);let x=L(i,(0,W.useCallback)(e=>i.selectors.shouldScrollIntoView(e,s,o),[s,o]));H(()=>{if(x)return pe().requestAnimationFrame(()=>{var e,t;(t=(e=h.current)?.scrollIntoView)==null||t.call(e,{block:`nearest`})})},[x,h]);let S=z(e=>{e.preventDefault(),e.button===j.Left&&(c||(b(),Ee()||requestAnimationFrame(()=>f()),r.mode===Y.Single&&i.actions.closeCombobox()))}),C=z(()=>{if(c)return i.actions.goToOption({focus:_.Nothing});let e=r.calculateIndex(s);i.actions.goToOption({focus:_.Specific,idx:e})}),w=D(),T=z(e=>w.update(e)),E=z(e=>{if(!w.wasMoved(e)||c||p&&i.state.activationTrigger===X.Pointer)return;let t=r.calculateIndex(s);i.actions.goToOption({focus:_.Specific,idx:t},X.Pointer)}),O=z(e=>{w.wasMoved(e)&&(c||p&&(r.optionsPropsRef.current.hold||i.state.activationTrigger===X.Pointer&&i.actions.goToOption({focus:_.Nothing})))}),k=Te({active:p,focus:p,selected:m,disabled:c}),A={id:o,ref:y,role:`option`,tabIndex:c===!0?void 0:-1,"aria-disabled":c===!0||void 0,"aria-selected":m,disabled:void 0,onMouseDown:S,onFocus:C,onPointerEnter:T,onMouseEnter:T,onPointerMove:E,onMouseMove:E,onPointerLeave:O,onMouseLeave:O};return ye()({ourProps:A,theirProps:u,slot:k,defaultTag:Ft,name:`Combobox.Option`})}var Lt=V(Dt),Rt=V(jt),zt=V(kt),Bt=d,Vt=V(Pt),Ht=V(It),Ut=Object.assign(Lt,{Input:zt,Button:Rt,Label:Bt,Options:Vt,Option:Ht});r.map(e=>({value:e.id,label:e.label,casesFolder:e.casesFolder,templateFolder:e.templateFolder}));function Q(){let e=c().caseTypes;return e?.length?e.map(e=>({...e})):r.map(e=>({...e}))}function Wt(e){let t=Q();return t.find(t=>t.id===e)??t[0]??r[0]}function Gt(e){let t=i(e);return u({caseTypes:t}),l(),t}function Kt(e){let t=e.trim();if(!t)throw Error(`类型名称不能为空`);if(t.length>40)throw Error(`类型名称过长(最多 40 字)`);let n=Q();if(n.some(e=>e.label===t))throw Error(`已存在「${t}」`);let r=a(t),i={id:s(),label:t,...r};return Gt([...n,i]),i}function qt(e,t){let n=t.trim();if(!n)throw Error(`类型名称不能为空`);if(n.length>40)throw Error(`类型名称过长(最多 40 字)`);let r=Q(),i=r.findIndex(t=>t.id===e);if(i<0)throw Error(`类型不存在`);if(r.some(t=>t.id!==e&&t.label===n))throw Error(`已存在「${n}」`);let o=a(n),s={...r[i],label:n,...o},c=[...r];return c[i]=s,Gt(c),s}function Jt(e){let t=Q();if(t.length<=1)throw Error(`至少保留一个用例类型`);if(!t.some(t=>t.id===e))throw Error(`类型不存在`);return Gt(t.filter(t=>t.id!==e))}var Yt=`/__tb_case_sessions`,Xt=`tw.case.sessions.v1`,Zt=!1;function Qt(){return`csess_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function $t(e){if(typeof e==`string`&&e.trim()){let t=e.trim();return Q().some(e=>e.id===t),t}return Q()[0]?.id??`functional`}function en(e){if(!e||!Array.isArray(e.sessions))return{sessions:[],activeId:``};let t=e.sessions.filter(e=>e&&typeof e==`object`&&e.id).map(e=>({...e,caseType:$t(e.caseType)})),n=typeof e.activeId==`string`?e.activeId:``;return t.length&&!t.some(e=>e.id===n)&&(n=t[0].id),t.length||(n=``),{sessions:t,activeId:n}}function tn(){try{let e=localStorage.getItem(o(Xt));return e?en(JSON.parse(e)):{sessions:[],activeId:``}}catch{return{sessions:[],activeId:``}}}function nn(e){try{localStorage.setItem(o(Xt),JSON.stringify(e))}catch{}}async function rn(){try{let e=await fetch(Yt,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json();Zt=!0;let n=en(t.store);return nn(n),n}}catch{}return Zt=!1,tn()}function an(){return tn()}async function on(e){if(nn(e),Zt)try{await fetch(Yt,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({store:e})})}catch{}}function sn(e){nn(e),on(e)}function cn(e){let t=Date.now(),n={id:Qt(),title:e.title?.trim()||`用例生成`,createdAt:t,updatedAt:t,caseType:e.caseType,outputFormat:e.outputFormat,reqPaths:e.reqPaths,templateId:e.templateId,templateTitle:e.templateTitle,promptPath:e.promptPath,knowledgePaths:e.knowledgePaths?.length?[...e.knowledgePaths]:void 0,messages:[]};return sn({sessions:[n,...tn().sessions],activeId:n.id}),n}function ln(e,t){let n=tn(),r=n.sessions.map(n=>n.id===e?{...n,...t,updatedAt:Date.now()}:n),i={...n,sessions:r};return sn(i),i}var $=Re();function un({options:e,values:t,onChange:n,placeholder:r=`选择…`,disabled:i=!1}){let[a,o]=(0,W.useState)(!1),s=(0,W.useRef)(null);(0,W.useEffect)(()=>{if(!a)return;function e(e){s.current?.contains(e.target)||o(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]);let c=e.filter(e=>t.includes(e.value)).map(e=>e.label),l=i||c.length===0?r:c.length<=2?c.join(`、`):`已选 ${c.length} 项`;function u(e){t.includes(e)?n(t.filter(t=>t!==e)):n([...t,e])}return(0,$.jsxs)(`div`,{className:`relative mt-1`,ref:s,children:[(0,$.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>o(e=>!e),className:i?`w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-stone-50 px-3 text-sm text-left text-stone-400 cursor-not-allowed`:`w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-white px-3 text-sm text-left text-stone-800 outline-none hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30`,children:[(0,$.jsx)(`span`,{className:`truncate ${i||c.length?``:`text-stone-400`}`,children:l}),(0,$.jsx)(`svg`,{className:`w-4 h-4 text-stone-400 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,$.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})]}),a?(0,$.jsx)(`div`,{className:`tw-select-menu tw-popover-anim absolute z-80 mt-1 max-h-56 w-full overflow-auto rounded-lg p-1 shadow-lg ring-1 ring-stone-200`,children:e.length===0?(0,$.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`暂无可选项`}):e.map(e=>{let n=t.includes(e.value);return(0,$.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-3 py-2 text-sm text-stone-700 cursor-pointer hover:bg-stone-50`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>u(e.value),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]},e.value)})}):null]})}function dn({options:e,value:t,onChange:n,placeholder:r=`搜索并选择…`,disabled:i=!1,allowEmpty:a=!0,emptyLabel:o=`不选择`}){let[s,c]=(0,W.useState)(``),l=(0,W.useMemo)(()=>{let t=s.trim().toLowerCase();return t?e.filter(e=>e.label.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)):e},[e,s]),u=e.find(e=>e.value===t)??null;return i?(0,$.jsx)(`div`,{className:`relative mt-1`,children:(0,$.jsxs)(`button`,{type:`button`,disabled:!0,className:`w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-stone-50 px-3 text-sm text-left text-stone-400 cursor-not-allowed`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:r}),(0,$.jsx)(`svg`,{className:`w-4 h-4 text-stone-400 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,$.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})]})}):(0,$.jsx)(Ut,{value:u,onChange:e=>{n(e?.value??``),c(``)},immediate:!0,children:(0,$.jsxs)(`div`,{className:`relative mt-1`,children:[(0,$.jsx)(zt,{className:`w-full h-9 rounded-lg border border-stone-200 bg-white px-3 pr-8 text-sm outline-none cursor-text placeholder:text-stone-400 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6]`,displayValue:e=>e?.label??``,onChange:e=>c(e.target.value),placeholder:r}),(0,$.jsx)(Rt,{className:`absolute inset-y-0 right-0 flex items-center pr-2 text-stone-400 cursor-pointer`,children:(0,$.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,$.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})}),(0,$.jsxs)(Vt,{transition:!0,anchor:{to:`bottom start`,gap:4},className:`tw-select-menu tw-menu-anim z-80 max-h-56 w-(--input-width) overflow-auto rounded-lg p-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:[a?(0,$.jsx)(Ht,{value:null,className:`cursor-pointer select-none rounded-md px-3 py-2 text-sm text-stone-400 data-[focus]:bg-stone-50`,children:o}):null,l.length===0?(0,$.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`无匹配项`}):l.map(e=>(0,$.jsx)(Ht,{value:e,className:`cursor-pointer select-none rounded-md px-3 py-2 text-sm text-stone-700 data-[focus]:bg-stone-50 data-[selected]:font-medium`,children:e.label},e.value))]})]})})}export{an as a,Kt as c,Jt as d,qt as f,rn as i,Wt as l,un as n,sn as o,cn as r,ln as s,dn as t,Q as u};
@@ -0,0 +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.DUyozIL9.js";import{i as te,n as ne,r as re,t as ie}from"./listbox.Di-t5U37.js";import{a as ae,o as oe}from"./dialog.DXHznyjD.js";import{t as a}from"./jsx-runtime.BUXbF_vF.js";import{t as se}from"./ConfirmDialog.CBVsDJ8f.js";import{i as ce}from"./llm.BZEzE0x2.js";import{_ as le,a as ue,c as de,d as fe,g as pe,h as me,i as he,l as o,n as s,o as ge,r as _e,s as ve,t as ye,u as be,v as xe}from"./settings.C6NWuiFO.js";import{n as c}from"./i18n.B52gLzii.js";import{n as Se,r as Ce,t as l}from"./update.Bl_HfSe6.js";var u=e(t(),1),d=a();function we(e){try{return new URL(e).host}catch{return``}}var Te=[{value:`zh-CN`,label:`中文`},{value:`en`,label:`English`}],f=`w-full px-3 py-2 text-sm border border-stone-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-[#4176e6]/35 focus:border-[#4176e6] transition-colors`,p=`inline-flex items-center gap-1.5 h-9 min-w-30 px-3 rounded-lg bg-stone-100 text-sm text-stone-700 hover:bg-stone-200/80 transition-colors outline-none focus:outline-none`;function Ee({className:e=`w-3.5 h-3.5`}){return(0,d.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:(0,d.jsx)(`path`,{d:`M6 8l4 4 4-4`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function De({className:e=`w-4 h-4`}){return(0,d.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,d.jsx)(`path`,{d:`M5 10.5l3.5 3.5L15 6.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function Oe({className:e=`w-4 h-4`}){return(0,d.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,d.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,d.jsx)(`path`,{d:`M12 1v2M12 21v2M4.2 4.2l1.4 1.4M18.4 18.4l1.4 1.4M1 12h2M21 12h2M4.2 19.8l1.4-1.4M18.4 5.6l1.4-1.4`})]})}function ke({className:e=`w-4 h-4`}){return(0,d.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,d.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,d.jsx)(`path`,{d:`M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5`}),(0,d.jsx)(`path`,{d:`M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]})}function Ae({kind:e}){let t=`w-5 h-5`;return e===`sun`?(0,d.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,d.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,d.jsx)(`path`,{d:`M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`})]}):e===`moon`?(0,d.jsx)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,d.jsx)(`path`,{d:`M21 14.5A8.5 8.5 0 1 1 9.5 3a7 7 0 0 0 11.5 11.5z`})}):(0,d.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,d.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`12`,rx:`2`}),(0,d.jsx)(`path`,{d:`M8 20h8M12 16v4`})]})}function m({title:e,description:t,control:n}){return(0,d.jsxs)(`div`,{className:`flex items-center gap-4 py-4 border-b border-stone-100 last:border-b-0`,children:[(0,d.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,d.jsx)(`div`,{className:`text-sm font-medium text-stone-800`,children:e}),t?(0,d.jsx)(`div`,{className:`mt-0.5 text-xs text-stone-400 leading-5`,children:t}):null]}),(0,d.jsx)(`div`,{className:`shrink-0`,children:n})]})}function h({value:e,options:t,onChange:n}){let r=t.find(t=>t.value===e)?.label??e;return(0,d.jsxs)(re,{value:e,onChange:n,children:[(0,d.jsxs)(te,{className:p,children:[(0,d.jsx)(`span`,{className:`flex-1 text-left truncate`,children:r}),(0,d.jsx)(Ee,{className:`w-3.5 h-3.5 text-stone-400 shrink-0`})]}),(0,d.jsx)(ie,{transition:!0,anchor:{to:`bottom end`,gap:6},className:`tw-select-menu tw-menu-anim z-60 min-w-40 rounded-xl py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:t.map(e=>(0,d.jsxs)(ne,{value:e.value,className:`group cursor-pointer select-none flex items-center justify-between gap-3 px-3 py-2 text-sm text-stone-700 data-[focus]:bg-stone-50 data-[selected]:text-stone-900`,children:[(0,d.jsx)(`span`,{children:e.label}),(0,d.jsx)(De,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0`})]},e.value))})]})}function g(){let[e,t]=(0,u.useState)(!1),[a,p]=(0,u.useState)(`general`),[g,je]=(0,u.useState)([]),[Me,_]=(0,u.useState)(``),[v,y]=(0,u.useState)(null),[b,x]=(0,u.useState)(``),[Ne,Pe]=(0,u.useState)(`DeepSeek`),[S,C]=(0,u.useState)(``),[w,T]=(0,u.useState)(``),[E,D]=(0,u.useState)(``),[O,Fe]=(0,u.useState)([]),[k,A]=(0,u.useState)(`idle`),[Ie,j]=(0,u.useState)(!1),[Le,M]=(0,u.useState)(`readonly`),[Re,ze]=(0,u.useState)(!1),[Be,N]=(0,u.useState)(!1),[Ve,P]=(0,u.useState)(null),[F,I]=(0,u.useState)({language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``}),[He,L]=(0,u.useState)(`14`),Ue=(0,u.useRef)(0),[R,We]=(0,u.useState)(null),[z,Ge]=(0,u.useState)(!1),[Ke,qe]=(0,u.useState)(!1),[Je,B]=(0,u.useState)(!1),[Ye,V]=(0,u.useState)(``),H=(0,u.useRef)(null),U=(0,u.useRef)(!1),W=v!==null,G=F.language,K=g.find(e=>e.id===Me),q=(K?.name||``).trim(),J=R?.status??null,Xe=J?.phase===`done`&&!!J.to&&J.to===R?.current&&Ce!==R?.current&&Date.now()-Date.parse(J.finishedAt||``)<864e5,Ze=J?.phase===`failed`?J.error:``,Y=Je||J?.phase===`installing`||J?.phase===`restarting`,Qe=(J?.to||R?.latest||``).replace(/^v/,``),X=Ze||Ye,$e=R?.checkedAt&&!Y?new Date(R.checkedAt).toLocaleTimeString():``,et=z?``:Y?J?.phase===`restarting`?c(`settings.updateRestarting`,void 0,G):c(`settings.updateInstalling`,{v:Qe},G):X?`${c(`settings.updateFailed`,void 0,G)}:${X}`:Xe?c(`settings.updateDone`,{v:J?.to||``},G):R?.mode===`dev`&&R?.hasUpdate?c(`settings.updateDevMode`,void 0,G):R?.error?`${c(`settings.updateUnavailable`,void 0,G)}:${R.error}`:R?.hasUpdate?R.mode===`npx`?c(`settings.updateNpxHint`,void 0,G):``:R?`${c(`settings.updateLatest`,void 0,G)}${$e?` · ${c(`settings.updateCheckedAt`,{time:$e},G)}`:``}`:Ke?c(`settings.updateUnavailable`,void 0,G):``,tt=q||(G===`en`?`No model`:`未配置`),nt=q?K?.model?.trim()?`${q} · ${K.model.trim()}`:q:G===`en`?`No model configured`:`未配置模型`;function rt(e=`general`){p(e),r().then(()=>{it(),t(!0)})}function it(){ze(n()),je(de()),_(ue()),N(!!o()),I(ve()),_e(ve()),M(ge()),y(null)}function Z(){H.current!==null&&(window.clearInterval(H.current),H.current=null)}async function at(e=!0){Ge(!0);try{let t=await l(e);t&&(We(t),V(``))}finally{Ge(!1),qe(!0)}}function ot(e){Z();let t=Date.now()+18e4;H.current=window.setInterval(async()=>{if(!U.current){U.current=!0;try{let n=await l(!0);if(n){We(n);let t=n.status;if(t?.phase===`failed`){Z(),B(!1),V(t.error||c(`settings.updateFailed`,void 0,G));return}if(t?.phase===`done`||e&&n.current!==e){Z(),B(!1);return}}Date.now()>t&&(Z(),B(!1),V(c(`settings.updateTimeout`,void 0,G)))}finally{U.current=!1}}},1500)}async function st(){let e=R?.latest||``;V(``),B(!0);let t=R?.current||Ce,n=await Se(e||void 0);n.ok?ot(t):(B(!1),V(n.error||c(`settings.updateFailed`,void 0,G)))}function ct(e){if(!e){let e=ee();y(e),x(`DeepSeek`),Pe(`DeepSeek`),C(`https://api.deepseek.com/v1`),T(``),D(``),Fe([]),A(`idle`),j(!1);return}y(e.id),x(e.name),C(e.baseURL);let t=e.apiKey?.trim()||(e.id===ue()?i().trim():``)||``;T(t),D(e.model),Fe(e.availableModels??[]),A(e.availableModels?.length?`ok`:`idle`),Pe(s.find(t=>t.baseURL===e.baseURL)?.label??`自定义`),j(!1)}(0,u.useEffect)(()=>{r().then(()=>it());let e=e=>{let n=e.detail;p(n?.tab===`model`?`model`:`general`),r().then(()=>{it(),t(!0)})};window.addEventListener(ye,e);let n=fe(e=>I(e)),i=be(e=>M(e));return()=>{window.removeEventListener(ye,e),n(),i()}},[]),(0,u.useEffect)(()=>{if(e)return(async()=>{let e=await l(!1);if(qe(!0),!e)return;We(e);let t=e.status;(t?.phase===`installing`||t?.phase===`restarting`)&&(B(!0),ot(t.from||e.current))})(),Z},[e]),(0,u.useEffect)(()=>{if(!e||a!==`model`||!W)return;let t=S.trim(),n=w.trim();if(!t||!n){A(e=>e===`ok`?`ok`:`idle`);return}A(`loading`);let r=++Ue.current,i=setTimeout(()=>{ce(t,n).then(e=>{r===Ue.current&&(Fe(e),A(`ok`))}).catch(()=>{r===Ue.current&&A(`fail`)})},800);return()=>clearTimeout(i)},[e,a,W,S,w]);function lt(e){Pe(e);let t=s.find(t=>t.label===e);t&&(t.baseURL&&C(t.baseURL),(!b.trim()||s.some(e=>e.label===b))&&x(t.label)),D(``)}function Q(e){I(pe(e))}(0,u.useEffect)(()=>{L(String(F.sessionFontSize))},[F.sessionFontSize]);function ut(){let e=Number(He);if(!He.trim()||!Number.isFinite(e)){L(String(F.sessionFontSize));return}let t=pe({sessionFontSize:Math.round(e)});I(t),L(String(t.sessionFontSize))}let dt=!!(b.trim()&&S.trim()&&w.trim()&&E.trim()),$=O.length>0;function ft(){if(!dt||!v)return;let e=xe({id:v,name:b.trim(),baseURL:S.trim(),apiKey:w.trim(),model:E.trim(),availableModels:$?O:void 0},{activate:!0});je(e),_(v),y(null),N(!!o())}function pt(e){P(e)}function mt(){let e=Ve;if(!e)return;P(null);let t=he(e);je(t),_(ue()),v===e&&y(null),N(!!o())}function ht(e){le(e),_(e),N(!!o())}let gt=[{value:`readonly`,label:c(`settings.access.readonly`,void 0,G)},{value:`readwrite`,label:c(`settings.access.readwrite`,void 0,G)},{value:`full`,label:c(`settings.access.full`,void 0,G)}],_t=[{value:`concise`,label:c(`settings.step.concise`,void 0,G)},{value:`standard`,label:c(`settings.step.standard`,void 0,G)},{value:`detailed`,label:c(`settings.step.detailed`,void 0,G)},{value:`full`,label:c(`settings.step.full`,void 0,G)}],vt=[{value:`queue`,label:c(`settings.busySend.queue`,void 0,G)},{value:`interrupt`,label:c(`settings.busySend.interrupt`,void 0,G)}],yt=[{value:`light`,label:c(`settings.appear.light`,void 0,G),icon:`sun`},{value:`dark`,label:c(`settings.appear.dark`,void 0,G),icon:`moon`},{value:`system`,label:c(`settings.appear.system`,void 0,G),icon:`monitor`}],bt=[{id:`general`,label:c(`settings.general`,void 0,G),icon:(0,d.jsx)(Oe,{})},{id:`model`,label:c(`settings.model`,void 0,G),icon:(0,d.jsx)(ke,{})}],xt=a===`general`?c(`settings.general`,void 0,G):W?g.some(e=>e.id===v)?c(`settings.editProvider`,void 0,G):c(`settings.addProviderTitle`,void 0,G):c(`settings.model`,void 0,G);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`tw-nav-foot-row`,children:[(0,d.jsxs)(`button`,{type:`button`,onClick:()=>rt(`general`),className:`tw-nav-settings-btn`,"data-hint":Be?`设置(已配置模型)`:`设置`,children:[(0,d.jsxs)(`svg`,{className:`tw-nav-ico w-4.5 h-4.5 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":`true`,children:[(0,d.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,d.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9c.2.6.7 1 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z`})]}),(0,d.jsx)(`span`,{"data-i18n":`nav.settings`,children:c(`nav.settings`,void 0,G)})]}),(0,d.jsxs)(`button`,{type:`button`,className:`tw-nav-provider-chip${q?``:` is-empty`}`,"data-hint":nt,onClick:()=>rt(`model`),children:[(0,d.jsx)(`span`,{className:`tw-nav-provider-dot`,"aria-hidden":`true`}),(0,d.jsx)(`span`,{className:`tw-nav-provider-name`,children:tt})]})]}),(0,d.jsx)(ae,{show:e,children:(0,d.jsxs)(`div`,{className:`fixed inset-0 z-110 flex items-center justify-center p-4`,children:[(0,d.jsx)(oe,{children:(0,d.jsx)(`div`,{className:`tw-dialog-backdrop-anim absolute inset-0 bg-stone-950/45`,onClick:()=>t(!1),"aria-hidden":`true`})}),(0,d.jsx)(oe,{children:(0,d.jsxs)(`div`,{className:`tw-settings-dialog tw-dialog-panel-anim relative bg-white rounded-2xl shadow-2xl w-full max-w-3xl h-[min(92vh,720px)] overflow-hidden flex flex-col`,children:[(0,d.jsxs)(`div`,{className:`shrink-0 h-12 px-4 flex items-center justify-between border-b border-stone-100 bg-white`,children:[(0,d.jsx)(`h2`,{className:`text-sm font-semibold text-stone-800 truncate pr-3`,children:xt}),(0,d.jsx)(`button`,{type:`button`,"aria-label":c(`settings.close`,void 0,G),onClick:()=>t(!1),className:`w-8 h-8 inline-flex items-center justify-center rounded-lg text-stone-400 hover:text-stone-700 hover:bg-stone-100 transition-colors`,children:(0,d.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,d.jsx)(`path`,{d:`M5 5l10 10M15 5L5 15`,strokeLinecap:`round`})})})]}),(0,d.jsxs)(`div`,{className:`flex-1 min-h-0 flex`,children:[(0,d.jsx)(`aside`,{className:`w-38 shrink-0 border-r border-stone-100 bg-[#f4f5f7] py-3 px-2 space-y-0.5`,children:bt.map(e=>{let t=a===e.id;return(0,d.jsxs)(`button`,{type:`button`,onClick:()=>{p(e.id),e.id===`model`&&y(null)},className:`w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-sm transition-colors ${t?`bg-[#e8f0fe] text-[#4176e6] font-medium`:`text-stone-600 hover:bg-white/70 hover:text-stone-800`}`,children:[(0,d.jsx)(`span`,{className:t?`text-[#4176e6]`:`text-stone-400`,children:e.icon}),e.label]},e.id)})}),(0,d.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0 bg-white`,children:a===`general`?(0,d.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,d.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-1`,children:[(0,d.jsx)(m,{title:c(`settings.access`,void 0,G),description:c(`settings.accessDesc`,void 0,G),control:(0,d.jsx)(h,{value:Le,options:gt,onChange:e=>{M(e),me(e)}})}),(0,d.jsx)(m,{title:c(`settings.language`,void 0,G),control:(0,d.jsx)(h,{value:F.language,options:Te,onChange:e=>Q({language:e})})}),(0,d.jsxs)(`div`,{className:`py-4 border-b border-stone-100`,children:[(0,d.jsx)(`div`,{className:`text-sm font-medium text-stone-800 mb-3`,children:c(`settings.appearance`,void 0,G)}),(0,d.jsx)(`div`,{className:`grid grid-cols-3 gap-2.5`,children:yt.map(e=>{let t=F.appearance===e.value;return(0,d.jsxs)(`button`,{type:`button`,onClick:()=>Q({appearance:e.value}),className:`flex flex-col items-center justify-center gap-2 h-19 rounded-xl border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] text-[#4176e6] ring-1 ring-[#4176e6]/30`:`border-stone-200 text-stone-500 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,d.jsx)(Ae,{kind:e.icon}),(0,d.jsx)(`span`,{className:`text-xs font-medium`,children:e.label})]},e.value)})})]}),(0,d.jsx)(m,{title:c(`settings.fontSize`,void 0,G),description:c(`settings.fontSizeDesc`,void 0,G),control:(0,d.jsxs)(`div`,{className:`inline-flex items-center gap-1.5`,children:[(0,d.jsx)(`input`,{type:`number`,min:12,max:22,value:He,onChange:e=>L(e.target.value),onBlur:ut,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},className:`w-14 h-9 px-2 text-sm text-center rounded-lg bg-stone-100 border-0 outline-none focus:ring-2 focus:ring-[#4176e6]/30`}),(0,d.jsx)(`span`,{className:`text-sm text-stone-400`,children:`px`})]})}),(0,d.jsx)(m,{title:c(`settings.toolSteps`,void 0,G),description:c(`settings.toolStepsDesc`,void 0,G),control:(0,d.jsx)(h,{value:F.toolStepDetail,options:_t,onChange:e=>Q({toolStepDetail:e})})}),(0,d.jsx)(m,{title:c(`settings.busySend`,void 0,G),description:c(`settings.busySendDesc`,void 0,G),control:(0,d.jsx)(h,{value:F.busySendBehavior,options:vt,onChange:e=>Q({busySendBehavior:e})})}),(0,d.jsx)(m,{title:c(`settings.subagentModel`,void 0,G),description:c(`settings.subagentModelDesc`,void 0,G),control:(0,d.jsx)(h,{value:F.subagentModel?.trim()?F.subagentModel:`inherit`,options:[{value:`inherit`,label:c(`settings.subagentModel.inherit`,void 0,G)},...Array.from(new Set([...K?.availableModels??[],...K?.model?[K.model]:[]])).filter(Boolean).map(e=>({value:e,label:e}))],onChange:e=>Q({subagentModel:e===`inherit`?``:e})})})]}),(0,d.jsxs)(`div`,{className:`shrink-0 px-6 py-3 border-t border-stone-100`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,d.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2`,children:[(0,d.jsx)(`span`,{className:`text-sm text-stone-700 whitespace-nowrap`,children:c(`settings.platformVersion`,void 0,G)}),(0,d.jsxs)(`span`,{className:`text-sm tabular-nums text-stone-500`,children:[`v`,Ce]}),R?.hasUpdate&&!Y&&!Xe?(0,d.jsx)(`span`,{className:`inline-flex items-center h-[18px] px-1.5 rounded-full bg-[#edf3fe] text-[11px] font-medium text-[#4176e6] tabular-nums whitespace-nowrap`,children:`${c(`settings.updateAvailable`,void 0,G)} v${(R.latest||``).replace(/^v/,``)}`}):null]}),(0,d.jsx)(`div`,{className:`shrink-0 flex items-center gap-2`,children:Y?(0,d.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-lg text-xs text-stone-500 bg-stone-100 whitespace-nowrap`,children:[(0,d.jsx)(`span`,{className:`w-3 h-3 rounded-full border-2 border-stone-300 border-t-[#4176e6] animate-spin`}),c(`settings.updateWorking`,void 0,G)]}):Xe?(0,d.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`h-8 px-3 rounded-lg text-xs font-medium text-[#4176e6] bg-[#edf3fe] hover:bg-[#e2ecfd] whitespace-nowrap`,children:c(`settings.updateReload`,void 0,G)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`button`,{type:`button`,disabled:z,onClick:()=>void at(!0),className:`inline-flex items-center justify-center min-w-[76px] h-8 px-3 rounded-lg text-xs font-medium text-stone-600 bg-stone-100 hover:bg-stone-200 disabled:opacity-70 disabled:cursor-default whitespace-nowrap`,children:z?(0,d.jsxs)(d.Fragment,{children:[c(`settings.updateChecking`,void 0,G),(0,d.jsxs)(`span`,{className:`tw-dots`,"aria-hidden":`true`,children:[(0,d.jsx)(`i`,{}),(0,d.jsx)(`i`,{}),(0,d.jsx)(`i`,{})]})]}):c(`settings.updateCheck`,void 0,G)}),R?.hasUpdate?(0,d.jsx)(`button`,{type:`button`,disabled:R.mode===`dev`,onClick:()=>void st(),className:`h-8 px-3 rounded-lg text-xs font-semibold text-white bg-[#4176e6] hover:bg-[#3566d6] disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap`,children:c(`settings.updateNow`,void 0,G)}):null]})})]}),et?(0,d.jsx)(`div`,{className:`mt-1 text-[11px] leading-relaxed ${X?`text-red-500`:`text-stone-400`}`,children:et}):null,X&&R?.logPath?(0,d.jsx)(`div`,{className:`mt-0.5 text-[11px] leading-relaxed text-stone-400 break-all`,children:c(`settings.updateLog`,{path:R.logPath},G)}):null]})]}):W?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`shrink-0 px-5 pt-3 pb-2 flex items-center gap-2 border-b border-stone-100`,children:(0,d.jsx)(`button`,{type:`button`,onClick:()=>y(null),className:`text-sm text-stone-500 hover:text-stone-800`,children:c(`settings.back`,void 0,G)})}),(0,d.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:c(`settings.displayName`,void 0,G)}),(0,d.jsx)(`input`,{type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:`DeepSeek`,className:f})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:c(`settings.preset`,void 0,G)}),(0,d.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:s.map(e=>{let t=Ne===e.label;return(0,d.jsxs)(`button`,{type:`button`,onClick:()=>lt(e.label),className:`text-left px-3 py-2 rounded-lg border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] ring-1 ring-[#4176e6]/30`:`border-stone-200 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,d.jsx)(`div`,{className:`text-sm ${t?`text-[#3565c7] font-medium`:`text-stone-700`}`,children:e.label}),(0,d.jsx)(`div`,{className:`text-[11px] text-stone-400 truncate`,children:e.baseURL?we(e.baseURL):`OpenAI compatible`})]},e.label)})})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:c(`settings.baseUrl`,void 0,G)}),(0,d.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:`https://api.deepseek.com/v1`,className:f})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:c(`settings.apiKey`,void 0,G)}),(0,d.jsxs)(`div`,{className:`relative`,children:[(0,d.jsx)(`input`,{type:Ie?`text`:`password`,value:w,onChange:e=>T(e.target.value),placeholder:`sk-...`,className:`${f} pr-14`}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>j(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-[11px] text-stone-400 hover:text-stone-600 px-1.5 py-1`,children:Ie?G===`en`?`Hide`:`隐藏`:G===`en`?`Show`:`显示`})]}),Re?(0,d.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-5`,children:c(`settings.keyHint`,void 0,G)}):null]}),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,d.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:c(`settings.modelField`,void 0,G)}),k===`loading`&&(0,d.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:c(`settings.recognizing`,void 0,G)}),$&&k===`ok`&&(0,d.jsx)(`span`,{className:`text-[11px] text-emerald-600`,children:c(`settings.recognized`,{n:O.length},G)}),k===`fail`&&!$&&(0,d.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:c(`settings.recognizeFail`,void 0,G)}),k===`fail`&&$&&(0,d.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:c(`settings.recognizeKeep`,void 0,G)})]}),$?(0,d.jsxs)(re,{value:E,onChange:D,children:[(0,d.jsxs)(te,{className:`${f} flex items-center justify-between text-left hover:border-stone-400 cursor-pointer`,children:[(0,d.jsx)(`span`,{className:`truncate text-stone-800`,children:E||(G===`en`?`Select a model`:`请选择模型`)}),(0,d.jsx)(Ee,{className:`w-4 h-4 shrink-0 ml-2 text-stone-400`})]}),(0,d.jsx)(ie,{transition:!0,anchor:{to:`bottom start`,gap:6},className:`tw-select-menu tw-menu-anim z-60 w-(--button-width) max-h-60 overflow-auto rounded-lg py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:O.map(e=>(0,d.jsxs)(ne,{value:e,className:`group cursor-pointer select-none flex items-center justify-between px-3 py-2 text-sm text-stone-700 data-[focus]:bg-[#edf3fe] data-[selected]:text-[#3565c7] data-[selected]:font-medium`,children:[(0,d.jsx)(`span`,{className:`truncate`,children:e}),(0,d.jsx)(De,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0 ml-2`})]},e))})]}):(0,d.jsx)(`input`,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:c(`settings.modelPlaceholder`,void 0,G),className:f})]})]}),(0,d.jsxs)(`div`,{className:`shrink-0 px-5 py-3.5 bg-stone-50 border-t border-stone-100 flex justify-end gap-2`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>y(null),className:`px-3.5 py-1.5 text-sm text-stone-600 hover:bg-stone-200/60 rounded-lg`,children:c(`settings.cancel`,void 0,G)}),(0,d.jsx)(`button`,{type:`button`,onClick:ft,disabled:!dt,className:`px-3.5 py-1.5 text-sm font-medium text-white bg-[#4176e6] hover:bg-[#3565c7] rounded-lg disabled:opacity-40 disabled:cursor-not-allowed`,children:c(`settings.save`,void 0,G)})]})]}):(0,d.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-5 bg-[#f4f5f7]`,children:[(0,d.jsx)(`p`,{className:`text-sm text-stone-500`,children:c(`settings.modelIntro`,void 0,G)}),(0,d.jsxs)(`div`,{className:`mt-5 space-y-2.5`,children:[g.map(e=>{let t=!!(e.apiKey?.trim()&&e.baseURL.trim()&&e.model.trim()),n=e.id===Me;return(0,d.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-stone-200/90 bg-white px-4 py-3.5 shadow-[0_1px_0_rgba(15,23,42,0.02)]`,children:[(0,d.jsxs)(`button`,{type:`button`,"data-hint":n?G===`en`?`Active`:`当前使用`:G===`en`?`Set active`:`设为当前`,onClick:()=>ht(e.id),className:`flex-1 min-w-0 flex items-center gap-2 text-left`,children:[(0,d.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:e.name}),t?(0,d.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 bg-emerald-500`}):null]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>ct(e),className:`h-8 px-3 text-sm text-stone-700 rounded-lg border border-stone-200 bg-white hover:bg-stone-50`,children:c(`settings.edit`,void 0,G)}),g.length>1?(0,d.jsx)(`button`,{type:`button`,onClick:()=>pt(e.id),className:`h-8 px-3 text-sm text-red-600 rounded-lg hover:bg-red-50`,children:c(`settings.delete`,void 0,G)}):null]})]},e.id)}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>ct(null),className:`w-full h-12 rounded-xl border border-dashed border-stone-300 bg-white/60 text-sm text-stone-600 hover:border-[#4176e6] hover:text-[#4176e6] hover:bg-[#edf3fe]/50 transition-colors`,children:c(`settings.addProvider`,void 0,G)})]})]})})]})]})})]})}),(0,d.jsx)(se,{open:Ve!=null,title:c(`settings.delete`,void 0,G),message:c(`settings.deleteConfirm`,void 0,G),confirmLabel:c(`settings.delete`,void 0,G),cancelLabel:G===`en`?`Cancel`:`取消`,danger:!0,onClose:()=>P(null),onConfirm:mt})]})}export{g as default};
@@ -1,4 +1,4 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{E as n,f as r,i}from"./app-config.DKMxjv3g.js";import{s as a}from"./plugins.D5ypJIXn.js";import{i as o,n as s,r as c,t as l}from"./dialog.DXHznyjD.js";import{i as ee,n as u,r as d,t as f}from"./menu.Bkluqxic.js";import{t as p}from"./jsx-runtime.BUXbF_vF.js";import{t as m}from"./ConfirmDialog.CBVsDJ8f.js";import{n as h}from"./llm.BZEzE0x2.js";import{f as te}from"./project-docs.Cd2gKPKh.js";import{t as g}from"./prompts-meta.F4wwkjUA.js";import{l as _}from"./settings.CnDCvwnQ.js";import{n as v}from"./i18n.BXeGGutk.js";import{a as y,c as ne,d as re,f as b,i as ie,l as ae,m as oe,n as se,o as x,p as ce,r as le,s as ue,t as de,u as fe}from"./spaces-client.Cai2tHEI.js";var S=e(t(),1),pe=`你是提示词作者。根据用户对这个数据空间的要求,写一份「默认提示词」正文(Markdown 纯文本,不要用代码围栏)。
1
+ import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{E as n,f as r,i}from"./app-config.DUyozIL9.js";import{s as a}from"./plugins.BDZqJNOy.js";import{i as o,n as s,r as c,t as l}from"./dialog.DXHznyjD.js";import{i as ee,n as u,r as d,t as f}from"./menu.Bkluqxic.js";import{t as p}from"./jsx-runtime.BUXbF_vF.js";import{t as m}from"./ConfirmDialog.CBVsDJ8f.js";import{n as h}from"./llm.BZEzE0x2.js";import{f as te}from"./project-docs.Cd2gKPKh.js";import{t as g}from"./prompts-meta.F4wwkjUA.js";import{l as _}from"./settings.C6NWuiFO.js";import{n as v}from"./i18n.B52gLzii.js";import{a as y,c as ne,d as re,f as b,i as ie,l as ae,m as oe,n as se,o as x,p as ce,r as le,s as ue,t as de,u as fe}from"./spaces-client.k_ciWMai.js";var S=e(t(),1),pe=`你是提示词作者。根据用户对这个数据空间的要求,写一份「默认提示词」正文(Markdown 纯文本,不要用代码围栏)。
2
2
  这份提示词将作为 Lantern Harness 该空间里 AI 助手的默认人设与回答原则。
3
3
  要求:
4
4
  - 用「你是…」起头设定角色;
@@ -1 +1 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.DKMxjv3g.js";import{a as r,o as i,r as a}from"./plugins.D5ypJIXn.js";import{a as o,n as s,o as c,r as l}from"./view-prefs.HCowOWXL.js";import{i as u,n as d,r as f,t as p}from"./dialog.DXHznyjD.js";import{t as m}from"./jsx-runtime.BUXbF_vF.js";import{t as h}from"./ConfirmDialog.CBVsDJ8f.js";import{n as g,t as _}from"./ColumnResize.Bs6GL3DJ.js";import{t as v}from"./DatePicker.CMfX7F6z.js";import{t as y}from"./SelectDropdown.Buv7rQJ_.js";import{A as b,C as x,D as S,P as ee,a as C,b as w,c as T,f as te,g as E,h as ne,i as D,m as O,n as k,o as re,p as ie,r as ae,s as oe,t as A,u as se}from"./tasks.otRBFydq.js";import{a as j,l as M,n as N,o as P,r as F,s as I,t as L}from"./DrawerField.CWMLhcPX.js";var R=e(t(),1),z=m(),ce=8e3,B=[{key:`title`,min:200},{key:`status`,width:104,min:80},{key:`priority`,width:104,min:88},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`cycle`,width:76,min:60},{key:`todos`,width:84,min:68},{key:`progress`,width:132,min:104},{key:`note`,width:140,min:88},{key:`action`,width:56,min:52}],le={pool:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,closed:`bg-stone-100 text-stone-400`,cancelled:`bg-stone-100 text-stone-400 line-through`},ue={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},V={pending:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},H={pool:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,closed:`bg-stone-300`,cancelled:`bg-stone-300`},U={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},de=ae.map(e=>({value:e,label:D[e]})),fe=[{value:``,label:`未设置`},...A.map(e=>({value:e,label:k[e]}))],pe=[{value:`all`,label:`全部优先级`},...A.map(e=>({value:e,label:k[e]}))],me=[{value:`all`,label:`全部`},{value:`pool`,label:`任务池`},{value:`in_progress`,label:`进行中`},{value:`done`,label:`已完成`},{value:`closed`,label:`已关闭`},{value:`cancelled`,label:`已取消`}],he=[`all`,`pool`,`in_progress`,`done`,`closed`,`cancelled`],ge=`tasks.status-tab`,_e=`tasks.priority-filter`,ve=`tasks.search`,ye=pe.map(e=>e.value);function W(e){return(0,z.jsxs)(`div`,{"data-tone":e.tone,className:`tw-stat-card flex min-w-0 flex-col gap-1 rounded-xl border px-4 py-3 ${e.tone===`urgent`?`border-red-100 bg-red-50/60`:`border-stone-200 bg-white`}`,children:[(0,z.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums ${e.tone===`urgent`?`text-[#c02a26]`:`text-stone-900`}`,children:e.value}),(0,z.jsx)(`span`,{className:`truncate text-xs text-stone-500`,children:e.label})]})}function be(e){let{open:t,task:n,todos:r,onClose:i,onSaved:a}=e,[o,s]=(0,R.useState)({title:``}),[c,l]=(0,R.useState)(``),[m,h]=(0,R.useState)(!1);(0,R.useEffect)(()=>{t&&(l(``),h(!1),s(n?{title:n.title,status:n.status,priority:n.priority,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pool`,priority:``,startDate:b(),dueDate:b()}))},[t,n]);function g(e){s(t=>({...t,...e}))}let _=O({startDate:o.startDate??``,dueDate:o.dueDate??``}),y=n?r.filter(e=>e.taskId===n.id):[],S=y.filter(e=>e.status===`done`).length,ee=y.length?Math.round(S/y.length*100):0;async function T(){let e=(o.title??``).trim();if(!e)l(`请填写任务名称`);else if(o.startDate&&o.dueDate&&o.dueDate<o.startDate)l(`截止日期不能早于开始日期`);else{h(!0),l(``);try{n?await E(n.id,o):await C([{...o,title:e}],{mode:`manual`}),await a(),i()}catch(e){l(e instanceof Error?e.message:String(e))}finally{h(!1)}}}return(0,z.jsxs)(f,{open:t,onClose:i,transition:!0,className:`relative z-100`,children:[(0,z.jsx)(p,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,z.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,z.jsxs)(u,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,z.jsx)(d,{className:`text-base font-semibold text-stone-900`,children:n?`任务详情`:`新建任务`}),(0,z.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,z.jsx)(N,{icon:(0,z.jsx)(M,{}),label:`任务名称`,children:(0,z.jsx)(`input`,{autoFocus:!0,value:o.title,onChange:e=>g({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())},placeholder:`请输入内容`,className:L})}),(0,z.jsx)(N,{icon:(0,z.jsx)(I,{}),label:`任务状态`,children:(0,z.jsx)(F,{ariaLabel:`任务状态`,menuMinWidth:140,options:de,value:o.status??`pool`,onChange:e=>g({status:e}),label:D[o.status??`pool`],optionDotClassName:e=>H[e]})}),(0,z.jsx)(N,{icon:(0,z.jsx)(I,{}),label:`紧急程度`,children:(0,z.jsx)(F,{ariaLabel:`紧急程度`,menuMinWidth:140,options:fe,value:o.priority??``,onChange:e=>g({priority:e}),label:o.priority?k[o.priority]:`未设置`,optionDotClassName:e=>U[e]})}),(0,z.jsx)(N,{icon:(0,z.jsx)(j,{}),label:`开始日期`,children:(0,z.jsx)(v,{value:o.startDate??``,onChange:e=>g({startDate:e}),className:`${L} tabular-nums`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(j,{}),label:`截止日期`,children:(0,z.jsx)(v,{value:o.dueDate??``,onChange:e=>g({dueDate:e}),className:`${L} tabular-nums`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(P,{}),label:`任务周期`,children:(0,z.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:_===null?`—`:`${_} 天`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(P,{}),label:`待办进度`,children:(0,z.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:y.length?`${S}/${y.length} · ${ee}%`:`还没有关联待办`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(M,{}),label:`备注`,children:(0,z.jsx)(`textarea`,{value:o.note??``,onChange:e=>g({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),n&&y.length?(0,z.jsxs)(`div`,{className:`mx-6 mt-2 rounded-lg border border-stone-100 bg-stone-50/60 px-3 py-2`,children:[(0,z.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-stone-500`,children:`关联待办`}),(0,z.jsx)(`ul`,{className:`space-y-1.5`,children:y.map(e=>{let t=x(e,b());return(0,z.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-stone-700`,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,z.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${V[t]}`,children:w[t]})]},e.id)})})]}):null,c?(0,z.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:c}):null]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:i,disabled:m,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void T(),disabled:m,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:m?`保存中…`:n?`保存`:`新建`})]})]})})]})}function xe(){let[e,t]=(0,R.useState)(!1),[u,d]=(0,R.useState)(!0),[f,p]=(0,R.useState)(!0),[m,b]=(0,R.useState)(null),[x,C]=(0,R.useState)([]),[w,ae]=(0,R.useState)([]),[A,j]=(0,R.useState)(null),[M,N]=(0,R.useState)(!1),[P,F]=(0,R.useState)(()=>l(ve)),[I,L]=(0,R.useState)(()=>s(ge,he,`all`)),[V,xe]=(0,R.useState)(()=>s(_e,ye,`all`)),[Se,G]=(0,R.useState)(null),[K,q]=(0,R.useState)(null);function Ce(e){o(ge,e),L(e)}function we(e){c(ve,e),F(e)}function Te(e){o(_e,e),xe(e)}let J=(0,R.useRef)(!0),Y=g(`lh:tasks:cols:v1`,B);(0,R.useEffect)(()=>(J.current=!0,()=>{J.current=!1}),[]);let X=(0,R.useCallback)(async()=>{try{let[e,t]=await Promise.all([se(),f?S().catch(()=>[]):Promise.resolve([])]);if(!J.current)return;C(e),ae(t),j(null)}catch(e){if(!J.current)return;j(e instanceof Error?e.message:String(e))}},[f]);(0,R.useEffect)(()=>{let e=r(e=>{d(!!e.tasks),p(!!e.todos)});return n().then(()=>{d(a(`tasks`)),p(a(`todos`)),t(!0)}),e},[]),(0,R.useEffect)(()=>{e&&u&&(async()=>{let e=await oe();J.current&&(e?(await X(),J.current&&b(!0)):b(!1))})()},[e,u,X]),(0,R.useEffect)(()=>{if(m!==!0)return;let e=window.setInterval(()=>void X(),ce),t=()=>void X();return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[m,X]);let Ee=(0,R.useMemo)(()=>ne(w),[w]),Z=(0,R.useMemo)(()=>ie(x),[x]),De=(0,R.useMemo)(()=>T(x,{status:I,priority:V,keyword:P}),[x,I,V,P]),Q=(0,R.useMemo)(()=>te(De),[De]);async function $(e,t){C(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await E(e,t);if(!J.current)return;C(t=>t.map(t=>t.id===e?n:t)),j(null)}catch(e){j(e instanceof Error?e.message:String(e)),await X()}}async function Oe(){let e=K;if(e){q(null),N(!0);try{await re([e.id]),await Promise.all(w.filter(t=>t.taskId===e.id).map(e=>ee(e.id,{taskId:``,linkedTask:``}).catch(()=>null))),await X()}catch(e){j(e instanceof Error?e.message:String(e))}finally{J.current&&N(!1)}}}return e?u?m===null?(0,z.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接任务服务`,children:(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,z.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):m?(0,z.jsxs)(`section`,{className:`flex min-h-0 flex-col gap-4`,children:[(0,z.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-7`,children:[(0,z.jsx)(W,{label:`全部任务`,value:Z.total}),(0,z.jsx)(W,{label:`任务池`,value:Z.pool}),(0,z.jsx)(W,{label:`进行中`,value:Z.in_progress}),(0,z.jsx)(W,{label:`已完成`,value:Z.done}),(0,z.jsx)(W,{label:`已关闭`,value:Z.closed}),(0,z.jsx)(W,{label:`已取消`,value:Z.cancelled}),(0,z.jsx)(W,{label:`需要紧急`,value:Z.urgent,tone:`urgent`})]}),(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-4 py-3`,children:[(0,z.jsx)(`input`,{value:P,onChange:e=>we(e.target.value),placeholder:`搜索任务…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,z.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-stone-100/80 p-0.5`,children:me.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>Ce(e.value),className:`h-8 rounded-md px-3 text-sm transition-colors ${I===e.value?`bg-white font-medium text-stone-900 shadow-sm`:`text-stone-600 hover:text-stone-900`}`,children:e.label},e.value))}),(0,z.jsx)(y,{flat:!0,className:`w-[136px]`,ariaLabel:`优先级筛选`,options:pe,value:V,onChange:e=>Te(e)}),(0,z.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>void X(),"aria-label":`刷新`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-800`,children:(0,z.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,z.jsx)(`path`,{d:`M21 12a9 9 0 1 1-3-6.7`}),(0,z.jsx)(`path`,{d:`M21 4v5h-5`})]})}),(0,z.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>G({task:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建任务`})]})]}),A?(0,z.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1`,children:A}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>j(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,z.jsxs)(`table`,{className:`tw-task-table w-full table-fixed border-collapse text-sm`,style:Y.tableStyle,children:[(0,z.jsx)(`colgroup`,{children:B.map(e=>(0,z.jsx)(`col`,{style:Y.widthOf(e.key)?{width:Y.widthOf(e.key)}:void 0},e.key))}),(0,z.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,z.jsxs)(`tr`,{children:[(0,z.jsxs)(`th`,{className:`relative px-3 py-2 text-left font-medium whitespace-nowrap`,children:[`任务描述`,(0,z.jsx)(_,{...Y.resizeProps(0)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务状态`,(0,z.jsx)(_,{...Y.resizeProps(1)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,z.jsx)(_,{...Y.resizeProps(2)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,z.jsx)(_,{...Y.resizeProps(3)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,z.jsx)(_,{...Y.resizeProps(4)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务周期`,(0,z.jsx)(_,{...Y.resizeProps(5)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办数量`,(0,z.jsx)(_,{...Y.resizeProps(6)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`完成进度`,(0,z.jsx)(_,{...Y.resizeProps(7)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,z.jsx)(_,{...Y.resizeProps(8)})]}),(0,z.jsx)(`th`,{className:`px-1 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,z.jsxs)(`tbody`,{children:[Q.map(e=>{let t=O(e),n=Ee[e.id]??{total:0,done:0,percent:0};return(0,z.jsxs)(`tr`,{className:`group/row border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,z.jsx)(`td`,{className:`px-3 py-1 align-middle`,children:(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.source===`ai`?(0,z.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,children:`AI`}):null,(0,z.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),className:`min-w-0 truncate rounded-md px-1.5 py-1 text-left text-sm text-stone-800 hover:bg-stone-100`,children:e.title})]})}),(0,z.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,z.jsx)(y,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`任务状态`,menuMinWidth:120,options:de,value:e.status,onChange:t=>void $(e.id,{status:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${le[e.status]}`,renderTrigger:()=>(0,z.jsx)(`span`,{className:`w-full truncate text-center`,children:D[e.status]}),renderOptionPrefix:e=>(0,z.jsx)(`span`,{className:`h-2 w-2 rounded-full ${H[e.value]}`})})}),(0,z.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,z.jsx)(y,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:fe,value:e.priority,onChange:t=>void $(e.id,{priority:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${ue[e.priority]}`,renderTrigger:()=>(0,z.jsx)(`span`,{className:`w-full truncate text-center`,children:e.priority?k[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,z.jsx)(`span`,{className:`h-2 w-2 rounded-full ${U[e.value]}`})})}),(0,z.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,z.jsx)(v,{value:e.startDate,onChange:t=>void $(e.id,{startDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,z.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,z.jsx)(v,{value:e.dueDate,onChange:t=>void $(e.id,{dueDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,z.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:t===null?`—`:`${t} 天`}),(0,z.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-500 tabular-nums`,children:f?n.total?`${n.total} 条`:`0`:(0,z.jsx)(`span`,{className:`whitespace-nowrap text-stone-400`,children:`待办事项未启用`})}),(0,z.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:f?(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,z.jsx)(`span`,{className:`block h-full rounded-full bg-[#3370ff] transition-[width]`,style:{width:`${n.percent}%`}})}),(0,z.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs text-stone-500 tabular-nums`,children:[n.percent,`%`]})]}):(0,z.jsx)(`span`,{className:`whitespace-nowrap text-xs text-stone-400`,children:`待办事项未启用`})}),(0,z.jsx)(`td`,{className:`truncate px-2 py-1 align-middle text-xs text-stone-500`,children:e.note||`—`}),(0,z.jsx)(`td`,{className:`px-1 py-1 text-right align-middle`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,z.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,z.jsx)(`path`,{d:`M14 4h6v6`}),(0,z.jsx)(`path`,{d:`M20 4 13 11`}),(0,z.jsx)(`path`,{d:`M10 20H4v-6`}),(0,z.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,z.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>q(e),"aria-label":`删除 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 focus:text-red-600 disabled:opacity-40`,children:(0,z.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,z.jsx)(`path`,{d:`M3 6h18`}),(0,z.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,z.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,z.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),Q.length===0?(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:10,className:`px-3 py-16 text-center text-sm text-stone-400`,children:x.length===0?`还没有任务`:`没有匹配的任务,试试调整搜索或筛选`})}):null]})]})}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,z.jsxs)(`span`,{children:[`共 `,Q.length,` 条`]}),(0,z.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`任务下关联的待办可直接在「待办事项」里维护`})]})]}),(0,z.jsx)(be,{open:Se!==null,task:Se?.task??null,todos:w,onClose:()=>G(null),onSaved:X}),(0,z.jsx)(h,{open:K!=null,title:`删除任务`,message:`删除「${K?.title??``}」?已关联的待办会保留,但不再挂在该任务下。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>q(null),onConfirm:()=>void Oe()})]}):(0,z.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`任务管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,z.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`tasks`)}):(0,z.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,z.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{xe as default};
1
+ import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.DUyozIL9.js";import{a as r,o as i,r as a}from"./plugins.BDZqJNOy.js";import{a as o,n as s,o as c,r as l}from"./view-prefs.Dyu_lmN2.js";import{i as u,n as d,r as f,t as p}from"./dialog.DXHznyjD.js";import{t as m}from"./jsx-runtime.BUXbF_vF.js";import{t as h}from"./ConfirmDialog.CBVsDJ8f.js";import{n as g,t as _}from"./ColumnResize.Bs6GL3DJ.js";import{t as v}from"./DatePicker.CMfX7F6z.js";import{t as y}from"./SelectDropdown.Buv7rQJ_.js";import{A as b,C as x,D as S,P as ee,a as C,b as w,c as T,f as te,g as E,h as ne,i as D,m as O,n as k,o as re,p as ie,r as ae,s as oe,t as A,u as se}from"./tasks.otRBFydq.js";import{a as j,l as M,n as N,o as P,r as F,s as I,t as L}from"./DrawerField.CWMLhcPX.js";var R=e(t(),1),z=m(),ce=8e3,B=[{key:`title`,min:200},{key:`status`,width:104,min:80},{key:`priority`,width:104,min:88},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`cycle`,width:76,min:60},{key:`todos`,width:84,min:68},{key:`progress`,width:132,min:104},{key:`note`,width:140,min:88},{key:`action`,width:56,min:52}],le={pool:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,closed:`bg-stone-100 text-stone-400`,cancelled:`bg-stone-100 text-stone-400 line-through`},ue={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},V={pending:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},H={pool:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,closed:`bg-stone-300`,cancelled:`bg-stone-300`},U={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},de=ae.map(e=>({value:e,label:D[e]})),fe=[{value:``,label:`未设置`},...A.map(e=>({value:e,label:k[e]}))],pe=[{value:`all`,label:`全部优先级`},...A.map(e=>({value:e,label:k[e]}))],me=[{value:`all`,label:`全部`},{value:`pool`,label:`任务池`},{value:`in_progress`,label:`进行中`},{value:`done`,label:`已完成`},{value:`closed`,label:`已关闭`},{value:`cancelled`,label:`已取消`}],he=[`all`,`pool`,`in_progress`,`done`,`closed`,`cancelled`],ge=`tasks.status-tab`,_e=`tasks.priority-filter`,ve=`tasks.search`,ye=pe.map(e=>e.value);function W(e){return(0,z.jsxs)(`div`,{"data-tone":e.tone,className:`tw-stat-card flex min-w-0 flex-col gap-1 rounded-xl border px-4 py-3 ${e.tone===`urgent`?`border-red-100 bg-red-50/60`:`border-stone-200 bg-white`}`,children:[(0,z.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums ${e.tone===`urgent`?`text-[#c02a26]`:`text-stone-900`}`,children:e.value}),(0,z.jsx)(`span`,{className:`truncate text-xs text-stone-500`,children:e.label})]})}function be(e){let{open:t,task:n,todos:r,onClose:i,onSaved:a}=e,[o,s]=(0,R.useState)({title:``}),[c,l]=(0,R.useState)(``),[m,h]=(0,R.useState)(!1);(0,R.useEffect)(()=>{t&&(l(``),h(!1),s(n?{title:n.title,status:n.status,priority:n.priority,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pool`,priority:``,startDate:b(),dueDate:b()}))},[t,n]);function g(e){s(t=>({...t,...e}))}let _=O({startDate:o.startDate??``,dueDate:o.dueDate??``}),y=n?r.filter(e=>e.taskId===n.id):[],S=y.filter(e=>e.status===`done`).length,ee=y.length?Math.round(S/y.length*100):0;async function T(){let e=(o.title??``).trim();if(!e)l(`请填写任务名称`);else if(o.startDate&&o.dueDate&&o.dueDate<o.startDate)l(`截止日期不能早于开始日期`);else{h(!0),l(``);try{n?await E(n.id,o):await C([{...o,title:e}],{mode:`manual`}),await a(),i()}catch(e){l(e instanceof Error?e.message:String(e))}finally{h(!1)}}}return(0,z.jsxs)(f,{open:t,onClose:i,transition:!0,className:`relative z-100`,children:[(0,z.jsx)(p,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,z.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,z.jsxs)(u,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,z.jsx)(d,{className:`text-base font-semibold text-stone-900`,children:n?`任务详情`:`新建任务`}),(0,z.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,z.jsx)(N,{icon:(0,z.jsx)(M,{}),label:`任务名称`,children:(0,z.jsx)(`input`,{autoFocus:!0,value:o.title,onChange:e=>g({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())},placeholder:`请输入内容`,className:L})}),(0,z.jsx)(N,{icon:(0,z.jsx)(I,{}),label:`任务状态`,children:(0,z.jsx)(F,{ariaLabel:`任务状态`,menuMinWidth:140,options:de,value:o.status??`pool`,onChange:e=>g({status:e}),label:D[o.status??`pool`],optionDotClassName:e=>H[e]})}),(0,z.jsx)(N,{icon:(0,z.jsx)(I,{}),label:`紧急程度`,children:(0,z.jsx)(F,{ariaLabel:`紧急程度`,menuMinWidth:140,options:fe,value:o.priority??``,onChange:e=>g({priority:e}),label:o.priority?k[o.priority]:`未设置`,optionDotClassName:e=>U[e]})}),(0,z.jsx)(N,{icon:(0,z.jsx)(j,{}),label:`开始日期`,children:(0,z.jsx)(v,{value:o.startDate??``,onChange:e=>g({startDate:e}),className:`${L} tabular-nums`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(j,{}),label:`截止日期`,children:(0,z.jsx)(v,{value:o.dueDate??``,onChange:e=>g({dueDate:e}),className:`${L} tabular-nums`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(P,{}),label:`任务周期`,children:(0,z.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:_===null?`—`:`${_} 天`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(P,{}),label:`待办进度`,children:(0,z.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:y.length?`${S}/${y.length} · ${ee}%`:`还没有关联待办`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(M,{}),label:`备注`,children:(0,z.jsx)(`textarea`,{value:o.note??``,onChange:e=>g({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),n&&y.length?(0,z.jsxs)(`div`,{className:`mx-6 mt-2 rounded-lg border border-stone-100 bg-stone-50/60 px-3 py-2`,children:[(0,z.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-stone-500`,children:`关联待办`}),(0,z.jsx)(`ul`,{className:`space-y-1.5`,children:y.map(e=>{let t=x(e,b());return(0,z.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-stone-700`,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,z.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${V[t]}`,children:w[t]})]},e.id)})})]}):null,c?(0,z.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:c}):null]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:i,disabled:m,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void T(),disabled:m,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:m?`保存中…`:n?`保存`:`新建`})]})]})})]})}function xe(){let[e,t]=(0,R.useState)(!1),[u,d]=(0,R.useState)(!0),[f,p]=(0,R.useState)(!0),[m,b]=(0,R.useState)(null),[x,C]=(0,R.useState)([]),[w,ae]=(0,R.useState)([]),[A,j]=(0,R.useState)(null),[M,N]=(0,R.useState)(!1),[P,F]=(0,R.useState)(()=>l(ve)),[I,L]=(0,R.useState)(()=>s(ge,he,`all`)),[V,xe]=(0,R.useState)(()=>s(_e,ye,`all`)),[Se,G]=(0,R.useState)(null),[K,q]=(0,R.useState)(null);function Ce(e){o(ge,e),L(e)}function we(e){c(ve,e),F(e)}function Te(e){o(_e,e),xe(e)}let J=(0,R.useRef)(!0),Y=g(`lh:tasks:cols:v1`,B);(0,R.useEffect)(()=>(J.current=!0,()=>{J.current=!1}),[]);let X=(0,R.useCallback)(async()=>{try{let[e,t]=await Promise.all([se(),f?S().catch(()=>[]):Promise.resolve([])]);if(!J.current)return;C(e),ae(t),j(null)}catch(e){if(!J.current)return;j(e instanceof Error?e.message:String(e))}},[f]);(0,R.useEffect)(()=>{let e=r(e=>{d(!!e.tasks),p(!!e.todos)});return n().then(()=>{d(a(`tasks`)),p(a(`todos`)),t(!0)}),e},[]),(0,R.useEffect)(()=>{e&&u&&(async()=>{let e=await oe();J.current&&(e?(await X(),J.current&&b(!0)):b(!1))})()},[e,u,X]),(0,R.useEffect)(()=>{if(m!==!0)return;let e=window.setInterval(()=>void X(),ce),t=()=>void X();return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[m,X]);let Ee=(0,R.useMemo)(()=>ne(w),[w]),Z=(0,R.useMemo)(()=>ie(x),[x]),De=(0,R.useMemo)(()=>T(x,{status:I,priority:V,keyword:P}),[x,I,V,P]),Q=(0,R.useMemo)(()=>te(De),[De]);async function $(e,t){C(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await E(e,t);if(!J.current)return;C(t=>t.map(t=>t.id===e?n:t)),j(null)}catch(e){j(e instanceof Error?e.message:String(e)),await X()}}async function Oe(){let e=K;if(e){q(null),N(!0);try{await re([e.id]),await Promise.all(w.filter(t=>t.taskId===e.id).map(e=>ee(e.id,{taskId:``,linkedTask:``}).catch(()=>null))),await X()}catch(e){j(e instanceof Error?e.message:String(e))}finally{J.current&&N(!1)}}}return e?u?m===null?(0,z.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接任务服务`,children:(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,z.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):m?(0,z.jsxs)(`section`,{className:`flex min-h-0 flex-col gap-4`,children:[(0,z.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-7`,children:[(0,z.jsx)(W,{label:`全部任务`,value:Z.total}),(0,z.jsx)(W,{label:`任务池`,value:Z.pool}),(0,z.jsx)(W,{label:`进行中`,value:Z.in_progress}),(0,z.jsx)(W,{label:`已完成`,value:Z.done}),(0,z.jsx)(W,{label:`已关闭`,value:Z.closed}),(0,z.jsx)(W,{label:`已取消`,value:Z.cancelled}),(0,z.jsx)(W,{label:`需要紧急`,value:Z.urgent,tone:`urgent`})]}),(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-4 py-3`,children:[(0,z.jsx)(`input`,{value:P,onChange:e=>we(e.target.value),placeholder:`搜索任务…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,z.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-stone-100/80 p-0.5`,children:me.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>Ce(e.value),className:`h-8 rounded-md px-3 text-sm transition-colors ${I===e.value?`bg-white font-medium text-stone-900 shadow-sm`:`text-stone-600 hover:text-stone-900`}`,children:e.label},e.value))}),(0,z.jsx)(y,{flat:!0,className:`w-[136px]`,ariaLabel:`优先级筛选`,options:pe,value:V,onChange:e=>Te(e)}),(0,z.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>void X(),"aria-label":`刷新`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-800`,children:(0,z.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,z.jsx)(`path`,{d:`M21 12a9 9 0 1 1-3-6.7`}),(0,z.jsx)(`path`,{d:`M21 4v5h-5`})]})}),(0,z.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>G({task:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建任务`})]})]}),A?(0,z.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1`,children:A}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>j(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,z.jsxs)(`table`,{className:`tw-task-table w-full table-fixed border-collapse text-sm`,style:Y.tableStyle,children:[(0,z.jsx)(`colgroup`,{children:B.map(e=>(0,z.jsx)(`col`,{style:Y.widthOf(e.key)?{width:Y.widthOf(e.key)}:void 0},e.key))}),(0,z.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,z.jsxs)(`tr`,{children:[(0,z.jsxs)(`th`,{className:`relative px-3 py-2 text-left font-medium whitespace-nowrap`,children:[`任务描述`,(0,z.jsx)(_,{...Y.resizeProps(0)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务状态`,(0,z.jsx)(_,{...Y.resizeProps(1)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,z.jsx)(_,{...Y.resizeProps(2)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,z.jsx)(_,{...Y.resizeProps(3)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,z.jsx)(_,{...Y.resizeProps(4)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务周期`,(0,z.jsx)(_,{...Y.resizeProps(5)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办数量`,(0,z.jsx)(_,{...Y.resizeProps(6)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`完成进度`,(0,z.jsx)(_,{...Y.resizeProps(7)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,z.jsx)(_,{...Y.resizeProps(8)})]}),(0,z.jsx)(`th`,{className:`px-1 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,z.jsxs)(`tbody`,{children:[Q.map(e=>{let t=O(e),n=Ee[e.id]??{total:0,done:0,percent:0};return(0,z.jsxs)(`tr`,{className:`group/row border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,z.jsx)(`td`,{className:`px-3 py-1 align-middle`,children:(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.source===`ai`?(0,z.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,children:`AI`}):null,(0,z.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),className:`min-w-0 truncate rounded-md px-1.5 py-1 text-left text-sm text-stone-800 hover:bg-stone-100`,children:e.title})]})}),(0,z.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,z.jsx)(y,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`任务状态`,menuMinWidth:120,options:de,value:e.status,onChange:t=>void $(e.id,{status:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${le[e.status]}`,renderTrigger:()=>(0,z.jsx)(`span`,{className:`w-full truncate text-center`,children:D[e.status]}),renderOptionPrefix:e=>(0,z.jsx)(`span`,{className:`h-2 w-2 rounded-full ${H[e.value]}`})})}),(0,z.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,z.jsx)(y,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:fe,value:e.priority,onChange:t=>void $(e.id,{priority:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${ue[e.priority]}`,renderTrigger:()=>(0,z.jsx)(`span`,{className:`w-full truncate text-center`,children:e.priority?k[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,z.jsx)(`span`,{className:`h-2 w-2 rounded-full ${U[e.value]}`})})}),(0,z.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,z.jsx)(v,{value:e.startDate,onChange:t=>void $(e.id,{startDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,z.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,z.jsx)(v,{value:e.dueDate,onChange:t=>void $(e.id,{dueDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,z.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:t===null?`—`:`${t} 天`}),(0,z.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-500 tabular-nums`,children:f?n.total?`${n.total} 条`:`0`:(0,z.jsx)(`span`,{className:`whitespace-nowrap text-stone-400`,children:`待办事项未启用`})}),(0,z.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:f?(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,z.jsx)(`span`,{className:`block h-full rounded-full bg-[#3370ff] transition-[width]`,style:{width:`${n.percent}%`}})}),(0,z.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs text-stone-500 tabular-nums`,children:[n.percent,`%`]})]}):(0,z.jsx)(`span`,{className:`whitespace-nowrap text-xs text-stone-400`,children:`待办事项未启用`})}),(0,z.jsx)(`td`,{className:`truncate px-2 py-1 align-middle text-xs text-stone-500`,children:e.note||`—`}),(0,z.jsx)(`td`,{className:`px-1 py-1 text-right align-middle`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,z.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,z.jsx)(`path`,{d:`M14 4h6v6`}),(0,z.jsx)(`path`,{d:`M20 4 13 11`}),(0,z.jsx)(`path`,{d:`M10 20H4v-6`}),(0,z.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,z.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>q(e),"aria-label":`删除 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 focus:text-red-600 disabled:opacity-40`,children:(0,z.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,z.jsx)(`path`,{d:`M3 6h18`}),(0,z.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,z.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,z.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),Q.length===0?(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:10,className:`px-3 py-16 text-center text-sm text-stone-400`,children:x.length===0?`还没有任务`:`没有匹配的任务,试试调整搜索或筛选`})}):null]})]})}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,z.jsxs)(`span`,{children:[`共 `,Q.length,` 条`]}),(0,z.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`任务下关联的待办可直接在「待办事项」里维护`})]})]}),(0,z.jsx)(be,{open:Se!==null,task:Se?.task??null,todos:w,onClose:()=>G(null),onSaved:X}),(0,z.jsx)(h,{open:K!=null,title:`删除任务`,message:`删除「${K?.title??``}」?已关联的待办会保留,但不再挂在该任务下。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>q(null),onConfirm:()=>void Oe()})]}):(0,z.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`任务管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,z.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`tasks`)}):(0,z.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,z.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{xe as default};
@@ -1 +1 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.DKMxjv3g.js";import{a as r,o as i,r as a}from"./plugins.D5ypJIXn.js";import{t as o}from"./jsx-runtime.BUXbF_vF.js";import{t as s}from"./ConfirmDialog.CBVsDJ8f.js";import{n as c,t as ee}from"./DocsPager.rzu4mnzw.js";import{a as l,i as u,r as d,t as te}from"./ExcelFieldTags.B_XMwNNx.js";import{a as ne,c as re,d as f,f as p,h as ie,i as ae,l as oe,m as se,n as ce,o as le,p as ue,r as de,s as m,t as fe,u as pe}from"./project-docs.Cd2gKPKh.js";import{n as me}from"./doc-roots.DAJP9Svr.js";import{t as he}from"./useListAnim.CpGB1cft.js";import{t as h}from"./NamePromptDialog.Dl5kSnQI.js";var g=e(t(),1),_=o(),v=5;async function ge(e){let t=e.name.toLowerCase();try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await f(`templates`,e.path);if(t.encoding===`base64`&&t.contentBase64)return l(t.contentBase64).headers}else if(t.endsWith(`.csv`)){let t=await p(`templates`,e.path);return d(t.content).headers}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await p(`templates`,e.path);return u(t.content).headers}}catch{}return[]}function y({className:e=`w-4 h-4`,open:t=!1}){return(0,_.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,_.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}):(0,_.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function b({className:e=`w-3 h-3`}){return(0,_.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,_.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,_.jsx)(`path`,{d:`m15 5 4 4`})]})}function x({className:e=`w-3 h-3`}){return(0,_.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,_.jsx)(`path`,{d:`M3 6h18`}),(0,_.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,_.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,_.jsx)(`path`,{d:`M10 11v6`}),(0,_.jsx)(`path`,{d:`M14 11v6`})]})}function S({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,_.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,_.jsx)(y,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,_.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,_.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,_.jsx)(`div`,{className:`tw-collapse-inner`,children:e.children.map(e=>(0,_.jsx)(S,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function _e(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function C(){let[e,t]=(0,g.useState)(()=>a(`templates`)),[o,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)([]),[C,ve]=(0,g.useState)(0),[w,T]=(0,g.useState)(`.`),[E,D]=(0,g.useState)([]),[ye,be]=(0,g.useState)({}),[xe,O]=(0,g.useState)({}),[k,Se]=(0,g.useState)(!0),[A,j]=(0,g.useState)(null),[M,N]=(0,g.useState)(!1),[Ce,P]=(0,g.useState)(!1),[F,I]=(0,g.useState)(null),[L,R]=(0,g.useState)(null),[z,B]=(0,g.useState)(1),[V,we]=c(v),[Te,H]=(0,g.useState)(null),U=(0,g.useRef)(null),{cls:Ee,play:W}=he(),G=(0,g.useCallback)(async e=>{let t={};await Promise.all(e.map(async e=>{let n=await ge(e);n.length&&(t[e.path]=n)})),be(t)},[]),K=(0,g.useCallback)(async()=>{let e=await ae(`templates`);p(e.tree),ve(e.totalFiles)},[]),q=(0,g.useCallback)(async(e=w)=>{j(null);try{let[t]=await Promise.all([m(`templates`,e),K()]);D(t.entries),T(t.path);let n=t.entries.filter(e=>e.type===`file`);await G(n)}catch(e){j(e instanceof Error?e.message:String(e))}},[w,G,K]);(0,g.useEffect)(()=>{let e=r(e=>t(!!e.templates));return n().then(()=>{t(a(`templates`)),l(!0)}),e},[]),(0,g.useEffect)(()=>{o&&e&&(async()=>{let e=await de(`templates`);if(d(e),e)try{let[e]=await Promise.all([m(`templates`,`.`),K()]);D(e.entries),T(e.path),await G(e.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}})()},[o,e,G,K]);function De(){Se(e=>!e),O({})}async function J(e){W(),T(e),B(1),H(null),j(null);try{let t=await m(`templates`,e);D(t.entries),await G(t.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}}async function Oe(e){P(!1),N(!0),j(null);try{await re(`templates`,w,e),await q(w)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}async function ke(e){if(e?.length){N(!0),j(null);try{for(let t of Array.from(e))await ie(`templates`,w,t);await q(w)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1),U.current&&(U.current.value=``)}}}async function Ae(e){if(e.type===`file`){N(!0),j(null);try{await oe(`templates`,e.path)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}function je(e){let t=ne(f,e.path),n=t?.fileCount??0,r=t?fe(t):0;I({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function Me(e){I({name:e.name,path:e.path,isDir:!1})}function Y(e,t){R({...e,isDir:t})}async function Ne(){let e=F;if(e&&(I(null),!e.blocked)){N(!0),j(null);try{await ce(`templates`,e.path);let t=le(w,e.path)?pe(e.path):w;await q(t)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}async function Pe(e){let t=L;if(t&&(R(null),e!==t.name)){N(!0),j(null);try{let n=await se(`templates`,t.path,e);await q(ue(w,t.path,n))}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}let Fe=(()=>{if(!F)return``;if(!F.isDir)return`删除文件「${F.name}」?将移入系统废纸篓,可随时找回。`;if(F.blocked){let e=[];return F.files&&e.push(`${F.files} 个文件`),F.dirs&&e.push(`${F.dirs} 个子文件夹`),`文件夹「${F.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${F.name}」?将移入系统废纸篓。`})();if(!o)return(0,_.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,_.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,_.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`templates`)});if(u===null)return(0,_.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,_.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!u)return(0,_.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`模板库需要本地文档服务,当前未就绪。`});let X=E.filter(e=>e.type===`file`),Z=E.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/V)),$=Math.min(z,Q),Ie=X.slice(($-1)*V,$*V);function Le(e){W(),we(e),B(1)}return(0,_.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,_.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,_.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,_.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>P(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1`,children:[(0,_.jsx)(`div`,{className:`group flex items-center rounded-md ${w===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{J(`.`),De()},"aria-expanded":k,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${w===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,_.jsx)(y,{open:k,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部模板`}),(0,_.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,C,`)`]})]})}),(0,_.jsx)(`div`,{className:`tw-collapse ${k?`is-open`:``}`,children:(0,_.jsx)(`div`,{className:`tw-collapse-inner`,children:f.map(e=>(0,_.jsx)(S,{node:e,depth:0,activePath:w,expanded:xe,globalOpen:k,onToggle:e=>O(t=>({...t,[e]:!(t[e]??k)})),onSelect:e=>void J(e)},e.path))})})]})]}),(0,_.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,_.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,_.jsx)(`span`,{className:`text-stone-400`,children:me(`templates`)}),w===`.`?``:w]}),(0,_.jsx)(`input`,{ref:U,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,className:`hidden`,onChange:e=>void ke(e.target.files)}),(0,_.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>U.current?.click(),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`上传文件`})]}),A?(0,_.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:A}):null,(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,_.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,_.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void J(e.path),children:[(0,_.jsx)(y,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,_.jsx)(b,{className:`w-3.5 h-3.5`})}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>je({name:e.name,path:e.path}),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,_.jsx)(x,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,_.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加模板(.md / .xlsx / .docx 等)`}):(0,_.jsx)(`ul`,{className:`${Ee}space-y-1`,children:Ie.map(e=>{let t=ye[e.path]??[],n=Te===e.path;return(0,_.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2 rounded-lg border transition-colors ${n?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,disabled:M,onClick:()=>H(e.path),onDoubleClick:()=>void Ae(e),children:[(0,_.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,_.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:_e(e.size)}),t.length>0?(0,_.jsx)(te,{fields:t}):null]}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40 shrink-0 mt-0.5`,children:(0,_.jsx)(b,{className:`w-3.5 h-3.5`})}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Me(e),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40 shrink-0 mt-0.5`,children:(0,_.jsx)(x,{className:`w-3.5 h-3.5`})})]},e.path)})})]})]}),X.length>0?(0,_.jsx)(ee,{page:$,totalPages:Q,pageSize:V,busy:M,onPage:e=>{W(),B(e)},onPageSize:Le}):null]}),(0,_.jsx)(h,{open:Ce,title:`新建文件夹`,onClose:()=>P(!1),onConfirm:e=>void Oe(e)}),(0,_.jsx)(h,{open:L!=null,title:L?.isDir?`重命名文件夹`:`重命名文件`,label:L?.isDir?`文件夹名称`:`文件名称`,initialValue:L?.name??``,lockExtension:L!=null&&!L.isDir,confirmLabel:`保存`,onClose:()=>R(null),onConfirm:e=>void Pe(e)}),(0,_.jsx)(s,{open:F!=null,title:F?.blocked?`无法删除文件夹`:F?.isDir?`删除文件夹`:`删除模板`,message:Fe,confirmLabel:F?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!F?.blocked,hideCancel:!!F?.blocked,onClose:()=>I(null),onConfirm:()=>void Ne()})]})}export{C as default};
1
+ import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.DUyozIL9.js";import{a as r,o as i,r as a}from"./plugins.BDZqJNOy.js";import{t as o}from"./jsx-runtime.BUXbF_vF.js";import{t as s}from"./ConfirmDialog.CBVsDJ8f.js";import{n as c,t as ee}from"./DocsPager.C20ue_JZ.js";import{a as l,i as u,r as d,t as te}from"./ExcelFieldTags.B_XMwNNx.js";import{a as ne,c as re,d as f,f as p,h as ie,i as ae,l as oe,m as se,n as ce,o as le,p as ue,r as de,s as m,t as fe,u as pe}from"./project-docs.Cd2gKPKh.js";import{n as me}from"./doc-roots.DAJP9Svr.js";import{t as he}from"./useListAnim.CpGB1cft.js";import{t as h}from"./NamePromptDialog.Dl5kSnQI.js";var g=e(t(),1),_=o(),v=5;async function ge(e){let t=e.name.toLowerCase();try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await f(`templates`,e.path);if(t.encoding===`base64`&&t.contentBase64)return l(t.contentBase64).headers}else if(t.endsWith(`.csv`)){let t=await p(`templates`,e.path);return d(t.content).headers}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await p(`templates`,e.path);return u(t.content).headers}}catch{}return[]}function y({className:e=`w-4 h-4`,open:t=!1}){return(0,_.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,_.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}):(0,_.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function b({className:e=`w-3 h-3`}){return(0,_.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,_.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,_.jsx)(`path`,{d:`m15 5 4 4`})]})}function x({className:e=`w-3 h-3`}){return(0,_.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,_.jsx)(`path`,{d:`M3 6h18`}),(0,_.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,_.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,_.jsx)(`path`,{d:`M10 11v6`}),(0,_.jsx)(`path`,{d:`M14 11v6`})]})}function S({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,_.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,_.jsx)(y,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,_.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,_.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,_.jsx)(`div`,{className:`tw-collapse-inner`,children:e.children.map(e=>(0,_.jsx)(S,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function _e(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function C(){let[e,t]=(0,g.useState)(()=>a(`templates`)),[o,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)([]),[C,ve]=(0,g.useState)(0),[w,T]=(0,g.useState)(`.`),[E,D]=(0,g.useState)([]),[ye,be]=(0,g.useState)({}),[xe,O]=(0,g.useState)({}),[k,Se]=(0,g.useState)(!0),[A,j]=(0,g.useState)(null),[M,N]=(0,g.useState)(!1),[Ce,P]=(0,g.useState)(!1),[F,I]=(0,g.useState)(null),[L,R]=(0,g.useState)(null),[z,B]=(0,g.useState)(1),[V,we]=c(v),[Te,H]=(0,g.useState)(null),U=(0,g.useRef)(null),{cls:Ee,play:W}=he(),G=(0,g.useCallback)(async e=>{let t={};await Promise.all(e.map(async e=>{let n=await ge(e);n.length&&(t[e.path]=n)})),be(t)},[]),K=(0,g.useCallback)(async()=>{let e=await ae(`templates`);p(e.tree),ve(e.totalFiles)},[]),q=(0,g.useCallback)(async(e=w)=>{j(null);try{let[t]=await Promise.all([m(`templates`,e),K()]);D(t.entries),T(t.path);let n=t.entries.filter(e=>e.type===`file`);await G(n)}catch(e){j(e instanceof Error?e.message:String(e))}},[w,G,K]);(0,g.useEffect)(()=>{let e=r(e=>t(!!e.templates));return n().then(()=>{t(a(`templates`)),l(!0)}),e},[]),(0,g.useEffect)(()=>{o&&e&&(async()=>{let e=await de(`templates`);if(d(e),e)try{let[e]=await Promise.all([m(`templates`,`.`),K()]);D(e.entries),T(e.path),await G(e.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}})()},[o,e,G,K]);function De(){Se(e=>!e),O({})}async function J(e){W(),T(e),B(1),H(null),j(null);try{let t=await m(`templates`,e);D(t.entries),await G(t.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}}async function Oe(e){P(!1),N(!0),j(null);try{await re(`templates`,w,e),await q(w)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}async function ke(e){if(e?.length){N(!0),j(null);try{for(let t of Array.from(e))await ie(`templates`,w,t);await q(w)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1),U.current&&(U.current.value=``)}}}async function Ae(e){if(e.type===`file`){N(!0),j(null);try{await oe(`templates`,e.path)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}function je(e){let t=ne(f,e.path),n=t?.fileCount??0,r=t?fe(t):0;I({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function Me(e){I({name:e.name,path:e.path,isDir:!1})}function Y(e,t){R({...e,isDir:t})}async function Ne(){let e=F;if(e&&(I(null),!e.blocked)){N(!0),j(null);try{await ce(`templates`,e.path);let t=le(w,e.path)?pe(e.path):w;await q(t)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}async function Pe(e){let t=L;if(t&&(R(null),e!==t.name)){N(!0),j(null);try{let n=await se(`templates`,t.path,e);await q(ue(w,t.path,n))}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}let Fe=(()=>{if(!F)return``;if(!F.isDir)return`删除文件「${F.name}」?将移入系统废纸篓,可随时找回。`;if(F.blocked){let e=[];return F.files&&e.push(`${F.files} 个文件`),F.dirs&&e.push(`${F.dirs} 个子文件夹`),`文件夹「${F.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${F.name}」?将移入系统废纸篓。`})();if(!o)return(0,_.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,_.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,_.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`templates`)});if(u===null)return(0,_.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,_.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!u)return(0,_.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`模板库需要本地文档服务,当前未就绪。`});let X=E.filter(e=>e.type===`file`),Z=E.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/V)),$=Math.min(z,Q),Ie=X.slice(($-1)*V,$*V);function Le(e){W(),we(e),B(1)}return(0,_.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,_.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,_.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,_.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>P(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1`,children:[(0,_.jsx)(`div`,{className:`group flex items-center rounded-md ${w===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{J(`.`),De()},"aria-expanded":k,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${w===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,_.jsx)(y,{open:k,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部模板`}),(0,_.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,C,`)`]})]})}),(0,_.jsx)(`div`,{className:`tw-collapse ${k?`is-open`:``}`,children:(0,_.jsx)(`div`,{className:`tw-collapse-inner`,children:f.map(e=>(0,_.jsx)(S,{node:e,depth:0,activePath:w,expanded:xe,globalOpen:k,onToggle:e=>O(t=>({...t,[e]:!(t[e]??k)})),onSelect:e=>void J(e)},e.path))})})]})]}),(0,_.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,_.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,_.jsx)(`span`,{className:`text-stone-400`,children:me(`templates`)}),w===`.`?``:w]}),(0,_.jsx)(`input`,{ref:U,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,className:`hidden`,onChange:e=>void ke(e.target.files)}),(0,_.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>U.current?.click(),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`上传文件`})]}),A?(0,_.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:A}):null,(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,_.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,_.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void J(e.path),children:[(0,_.jsx)(y,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,_.jsx)(b,{className:`w-3.5 h-3.5`})}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>je({name:e.name,path:e.path}),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,_.jsx)(x,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,_.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加模板(.md / .xlsx / .docx 等)`}):(0,_.jsx)(`ul`,{className:`${Ee}space-y-1`,children:Ie.map(e=>{let t=ye[e.path]??[],n=Te===e.path;return(0,_.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2 rounded-lg border transition-colors ${n?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,disabled:M,onClick:()=>H(e.path),onDoubleClick:()=>void Ae(e),children:[(0,_.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,_.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:_e(e.size)}),t.length>0?(0,_.jsx)(te,{fields:t}):null]}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40 shrink-0 mt-0.5`,children:(0,_.jsx)(b,{className:`w-3.5 h-3.5`})}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Me(e),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40 shrink-0 mt-0.5`,children:(0,_.jsx)(x,{className:`w-3.5 h-3.5`})})]},e.path)})})]})]}),X.length>0?(0,_.jsx)(ee,{page:$,totalPages:Q,pageSize:V,busy:M,onPage:e=>{W(),B(e)},onPageSize:Le}):null]}),(0,_.jsx)(h,{open:Ce,title:`新建文件夹`,onClose:()=>P(!1),onConfirm:e=>void Oe(e)}),(0,_.jsx)(h,{open:L!=null,title:L?.isDir?`重命名文件夹`:`重命名文件`,label:L?.isDir?`文件夹名称`:`文件名称`,initialValue:L?.name??``,lockExtension:L!=null&&!L.isDir,confirmLabel:`保存`,onClose:()=>R(null),onConfirm:e=>void Pe(e)}),(0,_.jsx)(s,{open:F!=null,title:F?.blocked?`无法删除文件夹`:F?.isDir?`删除文件夹`:`删除模板`,message:Fe,confirmLabel:F?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!F?.blocked,hideCancel:!!F?.blocked,onClose:()=>I(null),onConfirm:()=>void Ne()})]})}export{C as default};
@@ -1 +1 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.DKMxjv3g.js";import{a as r,o as i,r as a}from"./plugins.D5ypJIXn.js";import{o,r as ee}from"./view-prefs.HCowOWXL.js";import{t as s}from"./jsx-runtime.BUXbF_vF.js";import{t as c}from"./ConfirmDialog.CBVsDJ8f.js";import{n as te,t as l}from"./ColumnResize.Bs6GL3DJ.js";import{t as ne}from"./DatePicker.CMfX7F6z.js";import{n as re,t as ie}from"./DocsPager.rzu4mnzw.js";import{t as ae}from"./TagSelect.u8DTop7v.js";import{a as oe,c as u,i as d,l as f,n as se,o as ce,r as le,s as ue,t as de,u as fe}from"./test-stats.MEm3K2rB.js";var p=e(t(),1),m=s(),h=8e3,g=600,_=20,pe=`tw.test-stats.page-size.v1`,v=`test-stats.search`,y=[{key:`select`,width:32,min:28},{key:`index`,width:44,min:36},{key:`date`,width:140,min:120},{key:`dimensions`,min:240},{key:`count`,width:120,min:90},{key:`action`,width:64,min:56}],b=`h-8 w-full min-w-0 rounded-md border border-transparent bg-transparent px-1.5 text-center text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300 tabular-nums`,x=(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M3 6h18`}),(0,m.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,m.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,m.jsx)(`path`,{d:`M10 11v6M14 11v6`})]});function me(e){let[t,n]=(0,p.useState)(e.value?String(e.value):``),r=(0,p.useRef)(e.value),i=(0,p.useRef)(e.onCommit);i.current=e.onCommit,(0,p.useEffect)(()=>{e.value!==r.current&&(r.current=e.value,n(e.value?String(e.value):``))},[e.value]),(0,p.useEffect)(()=>{let e=t?u(t):0;if(e===r.current)return;let n=window.setTimeout(()=>{r.current=e,i.current(e)},g);return()=>window.clearTimeout(n)},[t]);function a(){let e=t?u(t):0;e!==r.current&&(r.current=e,i.current(e))}return(0,m.jsx)(`input`,{type:`text`,inputMode:`numeric`,"aria-label":e.ariaLabel,value:t,placeholder:e.placeholder??`0`,onChange:e=>n(e.target.value.replace(/[^\d]/g,``)),onBlur:a,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),t.currentTarget.blur()):t.key===`Escape`&&(t.preventDefault(),r.current=e.value,n(e.value?String(e.value):``),t.currentTarget.blur())},className:b})}function S(){let[e,t]=(0,p.useState)(!1),[s,u]=(0,p.useState)(!0),[g,b]=(0,p.useState)(null),[S,C]=(0,p.useState)([]),[w,T]=(0,p.useState)([]),[E,D]=(0,p.useState)(null),[O,k]=(0,p.useState)(!1),[A,j]=(0,p.useState)(()=>ee(v)),[M,N]=(0,p.useState)({}),[P,F]=(0,p.useState)(1),[I,L]=re(_,pe),[R,z]=(0,p.useState)(null),[B,V]=(0,p.useState)(null);function H(e){o(v,e),j(e),F(1)}let U=(0,p.useRef)(!0),W=(0,p.useRef)(!1),G=te(`lh:test-stats:cols:v1`,y);(0,p.useEffect)(()=>(U.current=!0,()=>{U.current=!1}),[]);let K=(0,p.useCallback)(async()=>{try{let e=await oe();if(!U.current)return;C(e.items),T(e.dimensions),N(t=>{let n=new Set(e.items.map(e=>e.id)),r=!1,i={};for(let[e,a]of Object.entries(t))a&&(n.has(e)?i[e]=!0:r=!0);return r?i:t}),D(null)}catch(e){if(!U.current)return;D(e instanceof Error?e.message:String(e))}},[]);(0,p.useEffect)(()=>{let e=r(e=>u(!!e.testStats));return n().then(()=>{u(a(`testStats`)),t(!0)}),e},[]),(0,p.useEffect)(()=>{e&&s&&(async()=>{let e=await le();U.current&&(e?(await K(),U.current&&b(!0)):b(!1))})()},[e,s,K]),(0,p.useEffect)(()=>{if(g!==!0)return;let e=window.setInterval(()=>{W.current||K()},h),t=()=>{W.current||K()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[g,K]);let he=f(),q=(0,p.useMemo)(()=>ce(d(S,{keyword:A})),[S,A]),J=(0,p.useMemo)(()=>ue(S),[S]),Y=Math.max(1,Math.ceil(q.length/I)),X=Math.min(P,Y),Z=(0,p.useMemo)(()=>q.slice((X-1)*I,X*I),[q,X,I]),Q=(0,p.useMemo)(()=>S.filter(e=>M[e.id]),[S,M]),ge=Z.length>0&&Z.every(e=>M[e.id]);(0,p.useEffect)(()=>{if(!R)return;let e=q.findIndex(e=>e.id===R);if(e<0)return;F(Math.floor(e/I)+1);let t=window.setTimeout(()=>z(null),2e3);return()=>window.clearTimeout(t)},[R,q,I]);async function _e(){if(!O){k(!0),D(null),H(``);try{let e=await de([{date:he,dimensions:[],count:0}],{mode:`manual`});if(!U.current)return;let t=e.items[0];if(e.dimensions.length&&T(e.dimensions),await K(),!U.current||!t)return;z(t.id)}catch(e){U.current&&D(e instanceof Error?e.message:String(e))}finally{U.current&&k(!1)}}}async function $(e,t){C(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let{item:n,dimensions:r}=await fe(e,t);if(!U.current)return;C(t=>t.map(t=>t.id===e?n:t)),r.length&&T(r),D(null)}catch(e){if(!U.current)return;D(e instanceof Error?e.message:String(e)),await K()}}async function ve(){let e=B;if(e&&e.length!==0){V(null),k(!0);try{if(await se(e.map(e=>e.id)),!U.current)return;N({}),D(null),await K()}catch(e){U.current&&D(e instanceof Error?e.message:String(e))}finally{U.current&&k(!1)}}}return e?s?g===null?(0,m.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接测试统计服务`,children:(0,m.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):g?(0,m.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,m.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,m.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,m.jsx)(`span`,{className:`font-medium text-stone-800`,children:J.records}),` 条`,(0,m.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 覆盖 `,J.dimensions,` 个维度 · 数量合计 `,J.total,Q.length?` · 已选 ${Q.length} 条`:``]})]}),(0,m.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,m.jsx)(`input`,{value:A,onChange:e=>H(e.target.value),placeholder:`搜索日期 / 维度…`,className:`h-9 w-44 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,m.jsx)(`button`,{type:`button`,disabled:O||Q.length===0,onClick:()=>V(Q),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,m.jsx)(`button`,{type:`button`,disabled:O,onClick:()=>void _e(),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 添加记录`})]})]}),E?(0,m.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,m.jsx)(`span`,{className:`min-w-0 flex-1`,children:E}),(0,m.jsx)(`button`,{type:`button`,onClick:()=>D(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,m.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{W.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{W.current=!!document.activeElement?.closest(`.tw-data-table`)},0)},children:(0,m.jsxs)(`table`,{className:`tw-data-table w-full table-fixed border-collapse text-sm`,style:G.tableStyle,children:[(0,m.jsx)(`colgroup`,{children:y.map(e=>(0,m.jsx)(`col`,{style:G.widthOf(e.key)?{width:G.widthOf(e.key)}:void 0},e.key))}),(0,m.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,m.jsxs)(`tr`,{children:[(0,m.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,children:(0,m.jsx)(`input`,{type:`checkbox`,"aria-label":`全选本页记录`,checked:ge,disabled:Z.length===0,onChange:e=>{let t=e.target.checked;N(e=>{let n={...e};for(let e of Z)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,m.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,"aria-label":`行号`}),(0,m.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`当前日期`,(0,m.jsx)(l,{...G.resizeProps(2)})]}),(0,m.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`测试统计维度`,(0,m.jsx)(l,{...G.resizeProps(3)})]}),(0,m.jsxs)(`th`,{className:`relative px-2 py-2 text-center font-medium whitespace-nowrap`,children:[`统计数量`,(0,m.jsx)(l,{...G.resizeProps(4)})]}),(0,m.jsx)(`th`,{className:`px-1 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,m.jsxs)(`tbody`,{children:[q.length===0?(0,m.jsx)(`tr`,{className:`border-t border-stone-100`,children:(0,m.jsx)(`td`,{colSpan:6,className:`px-4 py-14 text-center text-sm text-stone-400`,children:`还没有测试统计记录,点右上角「+ 添加记录」开始。`})}):null,Z.map((e,t)=>(0,m.jsxs)(`tr`,{className:`group/row border-t border-stone-100 ${e.id===R?`tw-new-row`:`hover:bg-[#f7f8fa]`}`,children:[(0,m.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,m.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.date} ${e.dimensions.join(`/`)}`,checked:!!M[e.id],onChange:t=>N(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,m.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:(X-1)*I+t+1}),(0,m.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,m.jsx)(ne,{value:e.date,onChange:t=>void $(e.id,{date:t}),placeholder:`选择日期`,className:`h-8 w-full rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,m.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,m.jsx)(ae,{compact:!0,ariaLabel:`测试统计维度`,options:w,value:e.dimensions[0]??``,onChange:t=>void $(e.id,{dimensions:t?[t]:[]}),placeholder:`选择或创建维度`})}),(0,m.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,m.jsx)(me,{value:e.count,ariaLabel:`统计数量`,onCommit:t=>void $(e.id,{count:t})})}),(0,m.jsx)(`td`,{className:`px-1 py-1 text-center align-middle`,children:(0,m.jsx)(`button`,{type:`button`,disabled:O,onClick:()=>V([e]),"aria-label":`删除 ${e.date} 的记录`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 focus:text-red-600 disabled:opacity-40`,children:x})})]},e.id))]})]})}),q.length>0?(0,m.jsx)(ie,{page:X,totalPages:Y,pageSize:I,busy:O,onPage:F,onPageSize:e=>{L(e),F(1)}}):(0,m.jsx)(`div`,{className:`pb-1`}),(0,m.jsx)(c,{open:B!==null,title:`删除测试统计`,message:B&&B.length>1?`确定删除选中的 ${B.length} 条记录吗?删除后不可恢复。`:`确定删除 ${B?.[0]?.date??``} 的这条记录吗?删除后不可恢复。`,confirmLabel:`删除`,danger:!0,onClose:()=>V(null),onConfirm:()=>void ve()})]}):(0,m.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`测试统计需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,m.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`testStats`)}):(0,m.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,m.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{S as default};
1
+ import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.DUyozIL9.js";import{a as r,o as i,r as a}from"./plugins.BDZqJNOy.js";import{o,r as ee}from"./view-prefs.Dyu_lmN2.js";import{t as s}from"./jsx-runtime.BUXbF_vF.js";import{t as c}from"./ConfirmDialog.CBVsDJ8f.js";import{n as te,t as l}from"./ColumnResize.Bs6GL3DJ.js";import{t as ne}from"./DatePicker.CMfX7F6z.js";import{n as re,t as ie}from"./DocsPager.C20ue_JZ.js";import{t as ae}from"./TagSelect.u8DTop7v.js";import{a as oe,c as u,i as d,l as f,n as se,o as ce,r as le,s as ue,t as de,u as fe}from"./test-stats.MEm3K2rB.js";var p=e(t(),1),m=s(),h=8e3,g=600,_=20,pe=`tw.test-stats.page-size.v1`,v=`test-stats.search`,y=[{key:`select`,width:32,min:28},{key:`index`,width:44,min:36},{key:`date`,width:140,min:120},{key:`dimensions`,min:240},{key:`count`,width:120,min:90},{key:`action`,width:64,min:56}],b=`h-8 w-full min-w-0 rounded-md border border-transparent bg-transparent px-1.5 text-center text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300 tabular-nums`,x=(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M3 6h18`}),(0,m.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,m.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,m.jsx)(`path`,{d:`M10 11v6M14 11v6`})]});function me(e){let[t,n]=(0,p.useState)(e.value?String(e.value):``),r=(0,p.useRef)(e.value),i=(0,p.useRef)(e.onCommit);i.current=e.onCommit,(0,p.useEffect)(()=>{e.value!==r.current&&(r.current=e.value,n(e.value?String(e.value):``))},[e.value]),(0,p.useEffect)(()=>{let e=t?u(t):0;if(e===r.current)return;let n=window.setTimeout(()=>{r.current=e,i.current(e)},g);return()=>window.clearTimeout(n)},[t]);function a(){let e=t?u(t):0;e!==r.current&&(r.current=e,i.current(e))}return(0,m.jsx)(`input`,{type:`text`,inputMode:`numeric`,"aria-label":e.ariaLabel,value:t,placeholder:e.placeholder??`0`,onChange:e=>n(e.target.value.replace(/[^\d]/g,``)),onBlur:a,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),t.currentTarget.blur()):t.key===`Escape`&&(t.preventDefault(),r.current=e.value,n(e.value?String(e.value):``),t.currentTarget.blur())},className:b})}function S(){let[e,t]=(0,p.useState)(!1),[s,u]=(0,p.useState)(!0),[g,b]=(0,p.useState)(null),[S,C]=(0,p.useState)([]),[w,T]=(0,p.useState)([]),[E,D]=(0,p.useState)(null),[O,k]=(0,p.useState)(!1),[A,j]=(0,p.useState)(()=>ee(v)),[M,N]=(0,p.useState)({}),[P,F]=(0,p.useState)(1),[I,L]=re(_,pe),[R,z]=(0,p.useState)(null),[B,V]=(0,p.useState)(null);function H(e){o(v,e),j(e),F(1)}let U=(0,p.useRef)(!0),W=(0,p.useRef)(!1),G=te(`lh:test-stats:cols:v1`,y);(0,p.useEffect)(()=>(U.current=!0,()=>{U.current=!1}),[]);let K=(0,p.useCallback)(async()=>{try{let e=await oe();if(!U.current)return;C(e.items),T(e.dimensions),N(t=>{let n=new Set(e.items.map(e=>e.id)),r=!1,i={};for(let[e,a]of Object.entries(t))a&&(n.has(e)?i[e]=!0:r=!0);return r?i:t}),D(null)}catch(e){if(!U.current)return;D(e instanceof Error?e.message:String(e))}},[]);(0,p.useEffect)(()=>{let e=r(e=>u(!!e.testStats));return n().then(()=>{u(a(`testStats`)),t(!0)}),e},[]),(0,p.useEffect)(()=>{e&&s&&(async()=>{let e=await le();U.current&&(e?(await K(),U.current&&b(!0)):b(!1))})()},[e,s,K]),(0,p.useEffect)(()=>{if(g!==!0)return;let e=window.setInterval(()=>{W.current||K()},h),t=()=>{W.current||K()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[g,K]);let he=f(),q=(0,p.useMemo)(()=>ce(d(S,{keyword:A})),[S,A]),J=(0,p.useMemo)(()=>ue(S),[S]),Y=Math.max(1,Math.ceil(q.length/I)),X=Math.min(P,Y),Z=(0,p.useMemo)(()=>q.slice((X-1)*I,X*I),[q,X,I]),Q=(0,p.useMemo)(()=>S.filter(e=>M[e.id]),[S,M]),ge=Z.length>0&&Z.every(e=>M[e.id]);(0,p.useEffect)(()=>{if(!R)return;let e=q.findIndex(e=>e.id===R);if(e<0)return;F(Math.floor(e/I)+1);let t=window.setTimeout(()=>z(null),2e3);return()=>window.clearTimeout(t)},[R,q,I]);async function _e(){if(!O){k(!0),D(null),H(``);try{let e=await de([{date:he,dimensions:[],count:0}],{mode:`manual`});if(!U.current)return;let t=e.items[0];if(e.dimensions.length&&T(e.dimensions),await K(),!U.current||!t)return;z(t.id)}catch(e){U.current&&D(e instanceof Error?e.message:String(e))}finally{U.current&&k(!1)}}}async function $(e,t){C(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let{item:n,dimensions:r}=await fe(e,t);if(!U.current)return;C(t=>t.map(t=>t.id===e?n:t)),r.length&&T(r),D(null)}catch(e){if(!U.current)return;D(e instanceof Error?e.message:String(e)),await K()}}async function ve(){let e=B;if(e&&e.length!==0){V(null),k(!0);try{if(await se(e.map(e=>e.id)),!U.current)return;N({}),D(null),await K()}catch(e){U.current&&D(e instanceof Error?e.message:String(e))}finally{U.current&&k(!1)}}}return e?s?g===null?(0,m.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接测试统计服务`,children:(0,m.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):g?(0,m.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,m.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,m.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,m.jsx)(`span`,{className:`font-medium text-stone-800`,children:J.records}),` 条`,(0,m.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 覆盖 `,J.dimensions,` 个维度 · 数量合计 `,J.total,Q.length?` · 已选 ${Q.length} 条`:``]})]}),(0,m.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,m.jsx)(`input`,{value:A,onChange:e=>H(e.target.value),placeholder:`搜索日期 / 维度…`,className:`h-9 w-44 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,m.jsx)(`button`,{type:`button`,disabled:O||Q.length===0,onClick:()=>V(Q),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,m.jsx)(`button`,{type:`button`,disabled:O,onClick:()=>void _e(),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 添加记录`})]})]}),E?(0,m.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,m.jsx)(`span`,{className:`min-w-0 flex-1`,children:E}),(0,m.jsx)(`button`,{type:`button`,onClick:()=>D(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,m.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{W.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{W.current=!!document.activeElement?.closest(`.tw-data-table`)},0)},children:(0,m.jsxs)(`table`,{className:`tw-data-table w-full table-fixed border-collapse text-sm`,style:G.tableStyle,children:[(0,m.jsx)(`colgroup`,{children:y.map(e=>(0,m.jsx)(`col`,{style:G.widthOf(e.key)?{width:G.widthOf(e.key)}:void 0},e.key))}),(0,m.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,m.jsxs)(`tr`,{children:[(0,m.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,children:(0,m.jsx)(`input`,{type:`checkbox`,"aria-label":`全选本页记录`,checked:ge,disabled:Z.length===0,onChange:e=>{let t=e.target.checked;N(e=>{let n={...e};for(let e of Z)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,m.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,"aria-label":`行号`}),(0,m.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`当前日期`,(0,m.jsx)(l,{...G.resizeProps(2)})]}),(0,m.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`测试统计维度`,(0,m.jsx)(l,{...G.resizeProps(3)})]}),(0,m.jsxs)(`th`,{className:`relative px-2 py-2 text-center font-medium whitespace-nowrap`,children:[`统计数量`,(0,m.jsx)(l,{...G.resizeProps(4)})]}),(0,m.jsx)(`th`,{className:`px-1 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,m.jsxs)(`tbody`,{children:[q.length===0?(0,m.jsx)(`tr`,{className:`border-t border-stone-100`,children:(0,m.jsx)(`td`,{colSpan:6,className:`px-4 py-14 text-center text-sm text-stone-400`,children:`还没有测试统计记录,点右上角「+ 添加记录」开始。`})}):null,Z.map((e,t)=>(0,m.jsxs)(`tr`,{className:`group/row border-t border-stone-100 ${e.id===R?`tw-new-row`:`hover:bg-[#f7f8fa]`}`,children:[(0,m.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,m.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.date} ${e.dimensions.join(`/`)}`,checked:!!M[e.id],onChange:t=>N(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,m.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:(X-1)*I+t+1}),(0,m.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,m.jsx)(ne,{value:e.date,onChange:t=>void $(e.id,{date:t}),placeholder:`选择日期`,className:`h-8 w-full rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,m.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,m.jsx)(ae,{compact:!0,ariaLabel:`测试统计维度`,options:w,value:e.dimensions[0]??``,onChange:t=>void $(e.id,{dimensions:t?[t]:[]}),placeholder:`选择或创建维度`})}),(0,m.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,m.jsx)(me,{value:e.count,ariaLabel:`统计数量`,onCommit:t=>void $(e.id,{count:t})})}),(0,m.jsx)(`td`,{className:`px-1 py-1 text-center align-middle`,children:(0,m.jsx)(`button`,{type:`button`,disabled:O,onClick:()=>V([e]),"aria-label":`删除 ${e.date} 的记录`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 focus:text-red-600 disabled:opacity-40`,children:x})})]},e.id))]})]})}),q.length>0?(0,m.jsx)(ie,{page:X,totalPages:Y,pageSize:I,busy:O,onPage:F,onPageSize:e=>{L(e),F(1)}}):(0,m.jsx)(`div`,{className:`pb-1`}),(0,m.jsx)(c,{open:B!==null,title:`删除测试统计`,message:B&&B.length>1?`确定删除选中的 ${B.length} 条记录吗?删除后不可恢复。`:`确定删除 ${B?.[0]?.date??``} 的这条记录吗?删除后不可恢复。`,confirmLabel:`删除`,danger:!0,onClose:()=>V(null),onConfirm:()=>void ve()})]}):(0,m.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`测试统计需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,m.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`testStats`)}):(0,m.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,m.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{S as default};