@deepseekcode/cli 1.0.23 → 1.0.24

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 (28) hide show
  1. package/dist/cli.js +1095 -1074
  2. package/package.json +2 -2
  3. package/web/dist/assets/{AutomationView-BbLzZ7Db.js → AutomationView-MOGwMs0s.js} +1 -1
  4. package/web/dist/assets/{ChannelConfigView-CjcMwBSL.js → ChannelConfigView-CHWC4ETy.js} +1 -1
  5. package/web/dist/assets/{ConnectorsView-CTFoG0sF.js → ConnectorsView-DaP_wB0W.js} +1 -1
  6. package/web/dist/assets/{FileTreeView-_N5eobgO.js → FileTreeView-N64-Dser.js} +1 -1
  7. package/web/dist/assets/{HookConfigView-DM6IVFGm.js → HookConfigView-DsZDeVFi.js} +1 -1
  8. package/web/dist/assets/ModelsView-C1cE2wMN.js +2 -0
  9. package/web/dist/assets/PluginsView-CsSjjfrn.js +1 -0
  10. package/web/dist/assets/SessionGrid-Bg-UTI2P.js +37 -0
  11. package/web/dist/assets/{SettingsPanel-D9kr-sFj.js → SettingsPanel-pZbjabYJ.js} +3 -3
  12. package/web/dist/assets/{SkillsView-CS0XvZ4N.js → SkillsView-BrQY_vgT.js} +1 -1
  13. package/web/dist/assets/{TemplatesTab-Pwfjxer7.js → TemplatesTab-DSfCryw2.js} +1 -1
  14. package/web/dist/assets/{TerminalView-C__4-QSL.js → TerminalView-Drr72DaP.js} +1 -1
  15. package/web/dist/assets/{ToolsView-Y5MpTnXY.js → ToolsView-ByqbKwqW.js} +1 -1
  16. package/web/dist/assets/{icons-BXecaLRH.js → icons-B9mi2ie6.js} +114 -104
  17. package/web/dist/assets/index-DCj9TkXV.css +1 -0
  18. package/web/dist/assets/index-PcXINYWS.js +68 -0
  19. package/web/dist/assets/{markdown-BASfeONY.js → markdown-BrFQfawv.js} +1 -1
  20. package/web/dist/assets/{panels-Bod3sKnK.js → panels-BX-TtLOU.js} +1 -1
  21. package/web/dist/assets/{react-vendor-7At16BnY.js → react-vendor-CiRFOYk_.js} +1 -1
  22. package/web/dist/assets/{state-D4zgKwQs.js → state-BcoCffxz.js} +1 -1
  23. package/web/dist/index.html +7 -7
  24. package/web/dist/assets/ModelsView-CPm2WAbG.js +0 -2
  25. package/web/dist/assets/PluginsView-D9pzIe-R.js +0 -1
  26. package/web/dist/assets/SessionGrid-C-Z-kzmG.js +0 -35
  27. package/web/dist/assets/index-CFxV9r1K.css +0 -1
  28. package/web/dist/assets/index-CcPIw0Dj.js +0 -68
@@ -1,4 +1,4 @@
1
- import{g as Dt,c as Yn}from"./icons-BXecaLRH.js";var nn={exports:{}},Re={};/**
1
+ import{g as Dt,c as Yn}from"./icons-B9mi2ie6.js";var nn={exports:{}},Re={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.js
4
4
  *
@@ -1 +1 @@
1
- import{a as f,R as hn}from"./icons-BXecaLRH.js";const we=f.createContext(null);we.displayName="PanelGroupContext";const k={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},$e=10,ne=f.useLayoutEffect,Fe=hn.useId,zn=typeof Fe=="function"?Fe:()=>null;let yn=0;function Ne(e=null){const n=zn(),t=f.useRef(e||n||null);return t.current===null&&(t.current=""+yn++),e??t.current}function Je({children:e,className:n="",collapsedSize:t,collapsible:r,defaultSize:i,forwardedRef:o,id:l,maxSize:s,minSize:a,onCollapse:h,onExpand:w,onResize:p,order:u,style:v,tagName:z="div",...C}){const E=f.useContext(we);if(E===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:b,expandPanel:L,getPanelSize:M,getPanelStyle:$,groupId:O,isPanelCollapsed:R,reevaluatePanelConstraints:P,registerPanel:K,resizePanel:J,unregisterPanel:F}=E,G=Ne(l),D=f.useRef({callbacks:{onCollapse:h,onExpand:w,onResize:p},constraints:{collapsedSize:t,collapsible:r,defaultSize:i,maxSize:s,minSize:a},id:G,idIsFromProps:l!==void 0,order:u});f.useRef({didLogMissingDefaultSizeWarning:!1}),ne(()=>{const{callbacks:_,constraints:N}=D.current,B={...N};D.current.id=G,D.current.idIsFromProps=l!==void 0,D.current.order=u,_.onCollapse=h,_.onExpand=w,_.onResize=p,N.collapsedSize=t,N.collapsible=r,N.defaultSize=i,N.maxSize=s,N.minSize=a,(B.collapsedSize!==N.collapsedSize||B.collapsible!==N.collapsible||B.maxSize!==N.maxSize||B.minSize!==N.minSize)&&P(D.current,B)}),ne(()=>{const _=D.current;return K(_),()=>{F(_)}},[u,G,K,F]),f.useImperativeHandle(o,()=>({collapse:()=>{b(D.current)},expand:_=>{L(D.current,_)},getId(){return G},getSize(){return M(D.current)},isCollapsed(){return R(D.current)},isExpanded(){return!R(D.current)},resize:_=>{J(D.current,_)}}),[b,L,M,R,G,J]);const Z=$(D.current,i);return f.createElement(z,{...C,children:e,className:n,id:G,style:{...Z,...v},[k.groupId]:O,[k.panel]:"",[k.panelCollapsible]:r||void 0,[k.panelId]:G,[k.panelSize]:parseFloat(""+Z.flexGrow).toFixed(1)})}const xn=f.forwardRef((e,n)=>f.createElement(Je,{...e,forwardedRef:n}));Je.displayName="Panel";xn.displayName="forwardRef(Panel)";let He=null,Se=-1,Y=null;function vn(e,n){if(n){const t=(n&en)!==0,r=(n&nn)!==0,i=(n&tn)!==0,o=(n&rn)!==0;if(t)return i?"se-resize":o?"ne-resize":"e-resize";if(r)return i?"sw-resize":o?"nw-resize":"w-resize";if(i)return"s-resize";if(o)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function Sn(){Y!==null&&(document.head.removeChild(Y),He=null,Y=null,Se=-1)}function Le(e,n){var t,r;const i=vn(e,n);if(He!==i){if(He=i,Y===null&&(Y=document.createElement("style"),document.head.appendChild(Y)),Se>=0){var o;(o=Y.sheet)===null||o===void 0||o.removeRule(Se)}Se=(t=(r=Y.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${i} !important;}`))!==null&&t!==void 0?t:-1}}function je(e){return e.type==="keydown"}function Ye(e){return e.type.startsWith("pointer")}function Ze(e){return e.type.startsWith("mouse")}function Ee(e){if(Ye(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Ze(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function bn(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Pn(e,n,t){return e.x<n.x+n.width&&e.x+e.width>n.x&&e.y<n.y+n.height&&e.y+e.height>n.y}function wn(e,n){if(e===n)throw new Error("Cannot compare node with itself");const t={a:Ue(e),b:Ue(n)};let r;for(;t.a.at(-1)===t.b.at(-1);)e=t.a.pop(),n=t.b.pop(),r=e;x(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:Ke(We(t.a)),b:Ke(We(t.b))};if(i.a===i.b){const o=r.childNodes,l={a:t.a.at(-1),b:t.b.at(-1)};let s=o.length;for(;s--;){const a=o[s];if(a===l.a)return 1;if(a===l.b)return-1}}return Math.sign(i.a-i.b)}const En=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Cn(e){var n;const t=getComputedStyle((n=Qe(e))!==null&&n!==void 0?n:e).display;return t==="flex"||t==="inline-flex"}function In(e){const n=getComputedStyle(e);return!!(n.position==="fixed"||n.zIndex!=="auto"&&(n.position!=="static"||Cn(e))||+n.opacity<1||"transform"in n&&n.transform!=="none"||"webkitTransform"in n&&n.webkitTransform!=="none"||"mixBlendMode"in n&&n.mixBlendMode!=="normal"||"filter"in n&&n.filter!=="none"||"webkitFilter"in n&&n.webkitFilter!=="none"||"isolation"in n&&n.isolation==="isolate"||En.test(n.willChange)||n.webkitOverflowScrolling==="touch")}function We(e){let n=e.length;for(;n--;){const t=e[n];if(x(t,"Missing node"),In(t))return t}return null}function Ke(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Ue(e){const n=[];for(;e;)n.push(e),e=Qe(e);return n}function Qe(e){const{parentNode:n}=e;return n&&n instanceof ShadowRoot?n.host:n}const en=1,nn=2,tn=4,rn=8,Rn=bn()==="coarse";let V=[],se=!1,ee=new Map,Ce=new Map;const he=new Set;function Ln(e,n,t,r,i){var o;const{ownerDocument:l}=n,s={direction:t,element:n,hitAreaMargins:r,setResizeHandlerState:i},a=(o=ee.get(l))!==null&&o!==void 0?o:0;return ee.set(l,a+1),he.add(s),be(),function(){var w;Ce.delete(e),he.delete(s);const p=(w=ee.get(l))!==null&&w!==void 0?w:1;if(ee.set(l,p-1),be(),p===1&&ee.delete(l),V.includes(s)){const u=V.indexOf(s);u>=0&&V.splice(u,1),Ge(),i("up",!0,null)}}}function An(e){const{target:n}=e,{x:t,y:r}=Ee(e);se=!0,_e({target:n,x:t,y:r}),be(),V.length>0&&(Pe("down",e),e.preventDefault(),on(n)||e.stopImmediatePropagation())}function Ae(e){const{x:n,y:t}=Ee(e);if(se&&e.buttons===0&&(se=!1,Pe("up",e)),!se){const{target:r}=e;_e({target:r,x:n,y:t})}Pe("move",e),Ge(),V.length>0&&e.preventDefault()}function ke(e){const{target:n}=e,{x:t,y:r}=Ee(e);Ce.clear(),se=!1,V.length>0&&(e.preventDefault(),on(n)||e.stopImmediatePropagation()),Pe("up",e),_e({target:n,x:t,y:r}),Ge(),be()}function on(e){let n=e;for(;n;){if(n.hasAttribute(k.resizeHandle))return!0;n=n.parentElement}return!1}function _e({target:e,x:n,y:t}){V.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),he.forEach(i=>{const{element:o,hitAreaMargins:l}=i,s=o.getBoundingClientRect(),{bottom:a,left:h,right:w,top:p}=s,u=Rn?l.coarse:l.fine;if(n>=h-u&&n<=w+u&&t>=p-u&&t<=a+u){if(r!==null&&document.contains(r)&&o!==r&&!o.contains(r)&&!r.contains(o)&&wn(r,o)>0){let z=r,C=!1;for(;z&&!z.contains(o);){if(Pn(z.getBoundingClientRect(),s)){C=!0;break}z=z.parentElement}if(C)return}V.push(i)}})}function De(e,n){Ce.set(e,n)}function Ge(){let e=!1,n=!1;V.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:n=!0});let t=0;Ce.forEach(r=>{t|=r}),e&&n?Le("intersection",t):e?Le("horizontal",t):n?Le("vertical",t):Sn()}let Me=new AbortController;function be(){Me.abort(),Me=new AbortController;const e={capture:!0,signal:Me.signal};he.size&&(se?(V.length>0&&ee.forEach((n,t)=>{const{body:r}=t;n>0&&(r.addEventListener("contextmenu",ke,e),r.addEventListener("pointerleave",Ae,e),r.addEventListener("pointermove",Ae,e))}),window.addEventListener("pointerup",ke,e),window.addEventListener("pointercancel",ke,e)):ee.forEach((n,t)=>{const{body:r}=t;n>0&&(r.addEventListener("pointerdown",An,e),r.addEventListener("pointermove",Ae,e))}))}function Pe(e,n){he.forEach(t=>{const{setResizeHandlerState:r}=t,i=V.includes(t);r(e,i,n)})}function kn(){const[e,n]=f.useState(0);return f.useCallback(()=>n(t=>t+1),[])}function x(e,n){if(!e)throw console.error(n),Error(n)}function te(e,n,t=$e){return e.toFixed(t)===n.toFixed(t)?0:e>n?1:-1}function j(e,n,t=$e){return te(e,n,t)===0}function W(e,n,t){return te(e,n,t)===0}function Dn(e,n,t){if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++){const i=e[r],o=n[r];if(!W(i,o,t))return!1}return!0}function le({panelConstraints:e,panelIndex:n,size:t}){const r=e[n];x(r!=null,`Panel constraints not found for index ${n}`);let{collapsedSize:i=0,collapsible:o,maxSize:l=100,minSize:s=0}=r;if(te(t,s)<0)if(o){const a=(i+s)/2;te(t,a)<0?t=i:t=s}else t=s;return t=Math.min(l,t),t=parseFloat(t.toFixed($e)),t}function ge({delta:e,initialLayout:n,panelConstraints:t,pivotIndices:r,prevLayout:i,trigger:o}){if(W(e,0))return n;const l=[...n],[s,a]=r;x(s!=null,"Invalid first pivot index"),x(a!=null,"Invalid second pivot index");let h=0;if(o==="keyboard"){{const p=e<0?a:s,u=t[p];x(u,`Panel constraints not found for index ${p}`);const{collapsedSize:v=0,collapsible:z,minSize:C=0}=u;if(z){const E=n[p];if(x(E!=null,`Previous layout not found for panel index ${p}`),W(E,v)){const b=C-E;te(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}{const p=e<0?s:a,u=t[p];x(u,`No panel constraints found for index ${p}`);const{collapsedSize:v=0,collapsible:z,minSize:C=0}=u;if(z){const E=n[p];if(x(E!=null,`Previous layout not found for panel index ${p}`),W(E,C)){const b=E-v;te(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}}{const p=e<0?1:-1;let u=e<0?a:s,v=0;for(;;){const C=n[u];x(C!=null,`Previous layout not found for panel index ${u}`);const b=le({panelConstraints:t,panelIndex:u,size:100})-C;if(v+=b,u+=p,u<0||u>=t.length)break}const z=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-z:z}{let u=e<0?s:a;for(;u>=0&&u<t.length;){const v=Math.abs(e)-Math.abs(h),z=n[u];x(z!=null,`Previous layout not found for panel index ${u}`);const C=z-v,E=le({panelConstraints:t,panelIndex:u,size:C});if(!W(z,E)&&(h+=z-E,l[u]=E,h.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?u--:u++}}if(Dn(i,l))return i;{const p=e<0?a:s,u=n[p];x(u!=null,`Previous layout not found for panel index ${p}`);const v=u+h,z=le({panelConstraints:t,panelIndex:p,size:v});if(l[p]=z,!W(z,v)){let C=v-z,b=e<0?a:s;for(;b>=0&&b<t.length;){const L=l[b];x(L!=null,`Previous layout not found for panel index ${b}`);const M=L+C,$=le({panelConstraints:t,panelIndex:b,size:M});if(W(L,$)||(C-=$-L,l[b]=$),W(C,0))break;e>0?b--:b++}}}const w=l.reduce((p,u)=>u+p,0);return W(w,100)?l:i}function Mn({layout:e,panelsArray:n,pivotIndices:t}){let r=0,i=100,o=0,l=0;const s=t[0];x(s!=null,"No pivot index found"),n.forEach((p,u)=>{const{constraints:v}=p,{maxSize:z=100,minSize:C=0}=v;u===s?(r=C,i=z):(o+=C,l+=z)});const a=Math.min(i,100-o),h=Math.max(r,100-l),w=e[s];return{valueMax:a,valueMin:h,valueNow:w}}function ze(e,n=document){return Array.from(n.querySelectorAll(`[${k.resizeHandleId}][data-panel-group-id="${e}"]`))}function ln(e,n,t=document){const i=ze(e,t).findIndex(o=>o.getAttribute(k.resizeHandleId)===n);return i??null}function sn(e,n,t){const r=ln(e,n,t);return r!=null?[r,r+1]:[-1,-1]}function an(e,n=document){var t;if(n instanceof HTMLElement&&(n==null||(t=n.dataset)===null||t===void 0?void 0:t.panelGroupId)==e)return n;const r=n.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return r||null}function Ie(e,n=document){const t=n.querySelector(`[${k.resizeHandleId}="${e}"]`);return t||null}function Hn(e,n,t,r=document){var i,o,l,s;const a=Ie(n,r),h=ze(e,r),w=a?h.indexOf(a):-1,p=(i=(o=t[w])===null||o===void 0?void 0:o.id)!==null&&i!==void 0?i:null,u=(l=(s=t[w+1])===null||s===void 0?void 0:s.id)!==null&&l!==void 0?l:null;return[p,u]}function $n({committedValuesRef:e,eagerValuesRef:n,groupId:t,layout:r,panelDataArray:i,panelGroupElement:o,setLayout:l}){f.useRef({didWarnAboutMissingResizeHandle:!1}),ne(()=>{if(!o)return;const s=ze(t,o);for(let a=0;a<i.length-1;a++){const{valueMax:h,valueMin:w,valueNow:p}=Mn({layout:r,panelsArray:i,pivotIndices:[a,a+1]}),u=s[a];if(u!=null){const v=i[a];x(v,`No panel data found for index "${a}"`),u.setAttribute("aria-controls",v.id),u.setAttribute("aria-valuemax",""+Math.round(h)),u.setAttribute("aria-valuemin",""+Math.round(w)),u.setAttribute("aria-valuenow",p!=null?""+Math.round(p):"")}}return()=>{s.forEach((a,h)=>{a.removeAttribute("aria-controls"),a.removeAttribute("aria-valuemax"),a.removeAttribute("aria-valuemin"),a.removeAttribute("aria-valuenow")})}},[t,r,i,o]),f.useEffect(()=>{if(!o)return;const s=n.current;x(s,"Eager values not found");const{panelDataArray:a}=s,h=an(t,o);x(h!=null,`No group found for id "${t}"`);const w=ze(t,o);x(w,`No resize handles found for group id "${t}"`);const p=w.map(u=>{const v=u.getAttribute(k.resizeHandleId);x(v,"Resize handle element has no handle id attribute");const[z,C]=Hn(t,v,a,o);if(z==null||C==null)return()=>{};const E=b=>{if(!b.defaultPrevented)switch(b.key){case"Enter":{b.preventDefault();const L=a.findIndex(M=>M.id===z);if(L>=0){const M=a[L];x(M,`No panel data found for index ${L}`);const $=r[L],{collapsedSize:O=0,collapsible:R,minSize:P=0}=M.constraints;if($!=null&&R){const K=ge({delta:W($,O)?P-O:O-$,initialLayout:r,panelConstraints:a.map(J=>J.constraints),pivotIndices:sn(t,v,o),prevLayout:r,trigger:"keyboard"});r!==K&&l(K)}}break}}};return u.addEventListener("keydown",E),()=>{u.removeEventListener("keydown",E)}});return()=>{p.forEach(u=>u())}},[o,e,n,t,r,i,l])}function Ve(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function un(e,n){const t=e==="horizontal",{x:r,y:i}=Ee(n);return t?r:i}function Nn(e,n,t,r,i){const o=t==="horizontal",l=Ie(n,i);x(l,`No resize handle element found for id "${n}"`);const s=l.getAttribute(k.groupId);x(s,"Resize handle element has no group id attribute");let{initialCursorPosition:a}=r;const h=un(t,e),w=an(s,i);x(w,`No group element found for id "${s}"`);const p=w.getBoundingClientRect(),u=o?p.width:p.height;return(h-a)/u*100}function _n(e,n,t,r,i,o){if(je(e)){const l=t==="horizontal";let s=0;e.shiftKey?s=100:i!=null?s=i:s=10;let a=0;switch(e.key){case"ArrowDown":a=l?0:s;break;case"ArrowLeft":a=l?-s:0;break;case"ArrowRight":a=l?s:0;break;case"ArrowUp":a=l?0:-s;break;case"End":a=100;break;case"Home":a=-100;break}return a}else return r==null?0:Nn(e,n,t,r,o)}function Gn({panelDataArray:e}){const n=Array(e.length),t=e.map(o=>o.constraints);let r=0,i=100;for(let o=0;o<e.length;o++){const l=t[o];x(l,`Panel constraints not found for index ${o}`);const{defaultSize:s}=l;s!=null&&(r++,n[o]=s,i-=s)}for(let o=0;o<e.length;o++){const l=t[o];x(l,`Panel constraints not found for index ${o}`);const{defaultSize:s}=l;if(s!=null)continue;const a=e.length-r,h=i/a;r++,n[o]=h,i-=h}return n}function oe(e,n,t){n.forEach((r,i)=>{const o=e[i];x(o,`Panel data not found for index ${i}`);const{callbacks:l,constraints:s,id:a}=o,{collapsedSize:h=0,collapsible:w}=s,p=t[a];if(p==null||r!==p){t[a]=r;const{onCollapse:u,onExpand:v,onResize:z}=l;z&&z(r,p),w&&(u||v)&&(v&&(p==null||j(p,h))&&!j(r,h)&&v(),u&&(p==null||!j(p,h))&&j(r,h)&&u())}})}function ve(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!=n[t])return!1;return!0}function Bn({defaultSize:e,dragState:n,layout:t,panelData:r,panelIndex:i,precision:o=3}){const l=t[i];let s;return l==null?s=e!=null?e.toPrecision(o):"1":r.length===1?s="1":s=l.toPrecision(o),{flexBasis:0,flexGrow:s,flexShrink:1,overflow:"hidden",pointerEvents:n!==null?"none":void 0}}function Tn(e,n=10){let t=null;return(...i)=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{e(...i)},n)}}function Oe(e){try{if(typeof localStorage<"u")e.getItem=n=>localStorage.getItem(n),e.setItem=(n,t)=>{localStorage.setItem(n,t)};else throw new Error("localStorage not supported in this environment")}catch(n){console.error(n),e.getItem=()=>null,e.setItem=()=>{}}}function cn(e){return`react-resizable-panels:${e}`}function fn(e){return e.map(n=>{const{constraints:t,id:r,idIsFromProps:i,order:o}=n;return i?r:o?`${o}:${JSON.stringify(t)}`:JSON.stringify(t)}).sort((n,t)=>n.localeCompare(t)).join(",")}function dn(e,n){try{const t=cn(e),r=n.getItem(t);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function Fn(e,n,t){var r,i;const o=(r=dn(e,t))!==null&&r!==void 0?r:{},l=fn(n);return(i=o[l])!==null&&i!==void 0?i:null}function Wn(e,n,t,r,i){var o;const l=cn(e),s=fn(n),a=(o=dn(e,i))!==null&&o!==void 0?o:{};a[s]={expandToSizes:Object.fromEntries(t.entries()),layout:r};try{i.setItem(l,JSON.stringify(a))}catch(h){console.error(h)}}function qe({layout:e,panelConstraints:n}){const t=[...e],r=t.reduce((o,l)=>o+l,0);if(t.length!==n.length)throw Error(`Invalid ${n.length} panel layout: ${t.map(o=>`${o}%`).join(", ")}`);if(!W(r,100)&&t.length>0)for(let o=0;o<n.length;o++){const l=t[o];x(l!=null,`No layout data found for index ${o}`);const s=100/r*l;t[o]=s}let i=0;for(let o=0;o<n.length;o++){const l=t[o];x(l!=null,`No layout data found for index ${o}`);const s=le({panelConstraints:n,panelIndex:o,size:l});l!=s&&(i+=l-s,t[o]=s)}if(!W(i,0))for(let o=0;o<n.length;o++){const l=t[o];x(l!=null,`No layout data found for index ${o}`);const s=l+i,a=le({panelConstraints:n,panelIndex:o,size:s});if(l!==a&&(i-=a-l,t[o]=a,W(i,0)))break}return t}const Kn=100,me={getItem:e=>(Oe(me),me.getItem(e)),setItem:(e,n)=>{Oe(me),me.setItem(e,n)}},Xe={};function pn({autoSaveId:e=null,children:n,className:t="",direction:r,forwardedRef:i,id:o=null,onLayout:l=null,keyboardResizeBy:s=null,storage:a=me,style:h,tagName:w="div",...p}){const u=Ne(o),v=f.useRef(null),[z,C]=f.useState(null),[E,b]=f.useState([]),L=kn(),M=f.useRef({}),$=f.useRef(new Map),O=f.useRef(0),R=f.useRef({autoSaveId:e,direction:r,dragState:z,id:u,keyboardResizeBy:s,onLayout:l,storage:a}),P=f.useRef({layout:E,panelDataArray:[],panelDataArrayChanged:!1});f.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),f.useImperativeHandle(i,()=>({getId:()=>R.current.id,getLayout:()=>{const{layout:c}=P.current;return c},setLayout:c=>{const{onLayout:m}=R.current,{layout:S,panelDataArray:g}=P.current,d=qe({layout:c,panelConstraints:g.map(y=>y.constraints)});Ve(S,d)||(b(d),P.current.layout=d,m&&m(d),oe(g,d,M.current))}}),[]),ne(()=>{R.current.autoSaveId=e,R.current.direction=r,R.current.dragState=z,R.current.id=u,R.current.onLayout=l,R.current.storage=a}),$n({committedValuesRef:R,eagerValuesRef:P,groupId:u,layout:E,panelDataArray:P.current.panelDataArray,setLayout:b,panelGroupElement:v.current}),f.useEffect(()=>{const{panelDataArray:c}=P.current;if(e){if(E.length===0||E.length!==c.length)return;let m=Xe[e];m==null&&(m=Tn(Wn,Kn),Xe[e]=m);const S=[...c],g=new Map($.current);m(e,S,g,E,a)}},[e,E,a]),f.useEffect(()=>{});const K=f.useCallback(c=>{const{onLayout:m}=R.current,{layout:S,panelDataArray:g}=P.current;if(c.constraints.collapsible){const d=g.map(q=>q.constraints),{collapsedSize:y=0,panelSize:I,pivotIndices:H}=Q(g,c,S);if(x(I!=null,`Panel size not found for panel "${c.id}"`),!j(I,y)){$.current.set(c.id,I);const X=ie(g,c)===g.length-1?I-y:y-I,A=ge({delta:X,initialLayout:S,panelConstraints:d,pivotIndices:H,prevLayout:S,trigger:"imperative-api"});ve(S,A)||(b(A),P.current.layout=A,m&&m(A),oe(g,A,M.current))}}},[]),J=f.useCallback((c,m)=>{const{onLayout:S}=R.current,{layout:g,panelDataArray:d}=P.current;if(c.constraints.collapsible){const y=d.map(U=>U.constraints),{collapsedSize:I=0,panelSize:H=0,minSize:q=0,pivotIndices:X}=Q(d,c,g),A=m??q;if(j(H,I)){const U=$.current.get(c.id),de=U!=null&&U>=A?U:A,Re=ie(d,c)===d.length-1?H-de:de-H,T=ge({delta:Re,initialLayout:g,panelConstraints:y,pivotIndices:X,prevLayout:g,trigger:"imperative-api"});ve(g,T)||(b(T),P.current.layout=T,S&&S(T),oe(d,T,M.current))}}},[]),F=f.useCallback(c=>{const{layout:m,panelDataArray:S}=P.current,{panelSize:g}=Q(S,c,m);return x(g!=null,`Panel size not found for panel "${c.id}"`),g},[]),G=f.useCallback((c,m)=>{const{panelDataArray:S}=P.current,g=ie(S,c);return Bn({defaultSize:m,dragState:z,layout:E,panelData:S,panelIndex:g})},[z,E]),D=f.useCallback(c=>{const{layout:m,panelDataArray:S}=P.current,{collapsedSize:g=0,collapsible:d,panelSize:y}=Q(S,c,m);return x(y!=null,`Panel size not found for panel "${c.id}"`),d===!0&&j(y,g)},[]),Z=f.useCallback(c=>{const{layout:m,panelDataArray:S}=P.current,{collapsedSize:g=0,collapsible:d,panelSize:y}=Q(S,c,m);return x(y!=null,`Panel size not found for panel "${c.id}"`),!d||te(y,g)>0},[]),_=f.useCallback(c=>{const{panelDataArray:m}=P.current;m.push(c),m.sort((S,g)=>{const d=S.order,y=g.order;return d==null&&y==null?0:d==null?-1:y==null?1:d-y}),P.current.panelDataArrayChanged=!0,L()},[L]);ne(()=>{if(P.current.panelDataArrayChanged){P.current.panelDataArrayChanged=!1;const{autoSaveId:c,onLayout:m,storage:S}=R.current,{layout:g,panelDataArray:d}=P.current;let y=null;if(c){const H=Fn(c,d,S);H&&($.current=new Map(Object.entries(H.expandToSizes)),y=H.layout)}y==null&&(y=Gn({panelDataArray:d}));const I=qe({layout:y,panelConstraints:d.map(H=>H.constraints)});Ve(g,I)||(b(I),P.current.layout=I,m&&m(I),oe(d,I,M.current))}}),ne(()=>{const c=P.current;return()=>{c.layout=[]}},[]);const N=f.useCallback(c=>{let m=!1;const S=v.current;return S&&window.getComputedStyle(S,null).getPropertyValue("direction")==="rtl"&&(m=!0),function(d){d.preventDefault();const y=v.current;if(!y)return()=>null;const{direction:I,dragState:H,id:q,keyboardResizeBy:X,onLayout:A}=R.current,{layout:U,panelDataArray:de}=P.current,{initialLayout:xe}=H??{},Re=sn(q,c,y);let T=_n(d,c,I,H,X,y);const Be=I==="horizontal";Be&&m&&(T=-T);const gn=de.map(mn=>mn.constraints),pe=ge({delta:T,initialLayout:xe??U,panelConstraints:gn,pivotIndices:Re,prevLayout:U,trigger:je(d)?"keyboard":"mouse-or-touch"}),Te=!ve(U,pe);(Ye(d)||Ze(d))&&O.current!=T&&(O.current=T,!Te&&T!==0?Be?De(c,T<0?en:nn):De(c,T<0?tn:rn):De(c,0)),Te&&(b(pe),P.current.layout=pe,A&&A(pe),oe(de,pe,M.current))}},[]),B=f.useCallback((c,m)=>{const{onLayout:S}=R.current,{layout:g,panelDataArray:d}=P.current,y=d.map(U=>U.constraints),{panelSize:I,pivotIndices:H}=Q(d,c,g);x(I!=null,`Panel size not found for panel "${c.id}"`);const X=ie(d,c)===d.length-1?I-m:m-I,A=ge({delta:X,initialLayout:g,panelConstraints:y,pivotIndices:H,prevLayout:g,trigger:"imperative-api"});ve(g,A)||(b(A),P.current.layout=A,S&&S(A),oe(d,A,M.current))},[]),ae=f.useCallback((c,m)=>{const{layout:S,panelDataArray:g}=P.current,{collapsedSize:d=0,collapsible:y}=m,{collapsedSize:I=0,collapsible:H,maxSize:q=100,minSize:X=0}=c.constraints,{panelSize:A}=Q(g,c,S);A!=null&&(y&&H&&j(A,d)?j(d,I)||B(c,I):A<X?B(c,X):A>q&&B(c,q))},[B]),ue=f.useCallback((c,m)=>{const{direction:S}=R.current,{layout:g}=P.current;if(!v.current)return;const d=Ie(c,v.current);x(d,`Drag handle element not found for id "${c}"`);const y=un(S,m);C({dragHandleId:c,dragHandleRect:d.getBoundingClientRect(),initialCursorPosition:y,initialLayout:g})},[]),ce=f.useCallback(()=>{C(null)},[]),ye=f.useCallback(c=>{const{panelDataArray:m}=P.current,S=ie(m,c);S>=0&&(m.splice(S,1),delete M.current[c.id],P.current.panelDataArrayChanged=!0,L())},[L]),re=f.useMemo(()=>({collapsePanel:K,direction:r,dragState:z,expandPanel:J,getPanelSize:F,getPanelStyle:G,groupId:u,isPanelCollapsed:D,isPanelExpanded:Z,reevaluatePanelConstraints:ae,registerPanel:_,registerResizeHandle:N,resizePanel:B,startDragging:ue,stopDragging:ce,unregisterPanel:ye,panelGroupElement:v.current}),[K,z,r,J,F,G,u,D,Z,ae,_,N,B,ue,ce,ye]),fe={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return f.createElement(we.Provider,{value:re},f.createElement(w,{...p,children:n,className:t,id:o,ref:v,style:{...fe,...h},[k.group]:"",[k.groupDirection]:r,[k.groupId]:u}))}const Un=f.forwardRef((e,n)=>f.createElement(pn,{...e,forwardedRef:n}));pn.displayName="PanelGroup";Un.displayName="forwardRef(PanelGroup)";function ie(e,n){return e.findIndex(t=>t===n||t.id===n.id)}function Q(e,n,t){const r=ie(e,n),o=r===e.length-1?[r-1,r]:[r,r+1],l=t[r];return{...n.constraints,panelSize:l,pivotIndices:o}}function Vn({disabled:e,handleId:n,resizeHandler:t,panelGroupElement:r}){f.useEffect(()=>{if(e||t==null||r==null)return;const i=Ie(n,r);if(i==null)return;const o=l=>{if(!l.defaultPrevented)switch(l.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{l.preventDefault(),t(l);break}case"F6":{l.preventDefault();const s=i.getAttribute(k.groupId);x(s,`No group element found for id "${s}"`);const a=ze(s,r),h=ln(s,n,r);x(h!==null,`No resize element found for id "${n}"`);const w=l.shiftKey?h>0?h-1:a.length-1:h+1<a.length?h+1:0;a[w].focus();break}}};return i.addEventListener("keydown",o),()=>{i.removeEventListener("keydown",o)}},[r,e,n,t])}function On({children:e=null,className:n="",disabled:t=!1,hitAreaMargins:r,id:i,onBlur:o,onClick:l,onDragging:s,onFocus:a,onPointerDown:h,onPointerUp:w,style:p={},tabIndex:u=0,tagName:v="div",...z}){var C,E;const b=f.useRef(null),L=f.useRef({onClick:l,onDragging:s,onPointerDown:h,onPointerUp:w});f.useEffect(()=>{L.current.onClick=l,L.current.onDragging=s,L.current.onPointerDown=h,L.current.onPointerUp=w});const M=f.useContext(we);if(M===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:$,groupId:O,registerResizeHandle:R,startDragging:P,stopDragging:K,panelGroupElement:J}=M,F=Ne(i),[G,D]=f.useState("inactive"),[Z,_]=f.useState(!1),[N,B]=f.useState(null),ae=f.useRef({state:G});ne(()=>{ae.current.state=G}),f.useEffect(()=>{if(t)B(null);else{const re=R(F);B(()=>re)}},[t,F,R]);const ue=(C=r==null?void 0:r.coarse)!==null&&C!==void 0?C:15,ce=(E=r==null?void 0:r.fine)!==null&&E!==void 0?E:5;f.useEffect(()=>{if(t||N==null)return;const re=b.current;x(re,"Element ref not attached");let fe=!1;return Ln(F,re,$,{coarse:ue,fine:ce},(m,S,g)=>{if(!S){D("inactive");return}switch(m){case"down":{D("drag"),fe=!1,x(g,'Expected event to be defined for "down" action'),P(F,g);const{onDragging:d,onPointerDown:y}=L.current;d==null||d(!0),y==null||y();break}case"move":{const{state:d}=ae.current;fe=!0,d!=="drag"&&D("hover"),x(g,'Expected event to be defined for "move" action'),N(g);break}case"up":{D("hover"),K();const{onClick:d,onDragging:y,onPointerUp:I}=L.current;y==null||y(!1),I==null||I(),fe||d==null||d();break}}})},[ue,$,t,ce,R,F,N,P,K]),Vn({disabled:t,handleId:F,resizeHandler:N,panelGroupElement:J});const ye={touchAction:"none",userSelect:"none"};return f.createElement(v,{...z,children:e,className:n,id:i,onBlur:()=>{_(!1),o==null||o()},onFocus:()=>{_(!0),a==null||a()},ref:b,role:"separator",style:{...ye,...p},tabIndex:u,[k.groupDirection]:$,[k.groupId]:O,[k.resizeHandle]:"",[k.resizeHandleActive]:G==="drag"?"pointer":Z?"keyboard":void 0,[k.resizeHandleEnabled]:!t,[k.resizeHandleId]:F,[k.resizeHandleState]:G})}On.displayName="PanelResizeHandle";export{Un as P,xn as a,On as b};
1
+ import{a as f,R as hn}from"./icons-B9mi2ie6.js";const we=f.createContext(null);we.displayName="PanelGroupContext";const k={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},$e=10,ne=f.useLayoutEffect,Fe=hn.useId,zn=typeof Fe=="function"?Fe:()=>null;let yn=0;function Ne(e=null){const n=zn(),t=f.useRef(e||n||null);return t.current===null&&(t.current=""+yn++),e??t.current}function Je({children:e,className:n="",collapsedSize:t,collapsible:r,defaultSize:i,forwardedRef:o,id:l,maxSize:s,minSize:a,onCollapse:h,onExpand:w,onResize:p,order:u,style:v,tagName:z="div",...C}){const E=f.useContext(we);if(E===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:b,expandPanel:L,getPanelSize:M,getPanelStyle:$,groupId:O,isPanelCollapsed:R,reevaluatePanelConstraints:P,registerPanel:K,resizePanel:J,unregisterPanel:F}=E,G=Ne(l),D=f.useRef({callbacks:{onCollapse:h,onExpand:w,onResize:p},constraints:{collapsedSize:t,collapsible:r,defaultSize:i,maxSize:s,minSize:a},id:G,idIsFromProps:l!==void 0,order:u});f.useRef({didLogMissingDefaultSizeWarning:!1}),ne(()=>{const{callbacks:_,constraints:N}=D.current,B={...N};D.current.id=G,D.current.idIsFromProps=l!==void 0,D.current.order=u,_.onCollapse=h,_.onExpand=w,_.onResize=p,N.collapsedSize=t,N.collapsible=r,N.defaultSize=i,N.maxSize=s,N.minSize=a,(B.collapsedSize!==N.collapsedSize||B.collapsible!==N.collapsible||B.maxSize!==N.maxSize||B.minSize!==N.minSize)&&P(D.current,B)}),ne(()=>{const _=D.current;return K(_),()=>{F(_)}},[u,G,K,F]),f.useImperativeHandle(o,()=>({collapse:()=>{b(D.current)},expand:_=>{L(D.current,_)},getId(){return G},getSize(){return M(D.current)},isCollapsed(){return R(D.current)},isExpanded(){return!R(D.current)},resize:_=>{J(D.current,_)}}),[b,L,M,R,G,J]);const Z=$(D.current,i);return f.createElement(z,{...C,children:e,className:n,id:G,style:{...Z,...v},[k.groupId]:O,[k.panel]:"",[k.panelCollapsible]:r||void 0,[k.panelId]:G,[k.panelSize]:parseFloat(""+Z.flexGrow).toFixed(1)})}const xn=f.forwardRef((e,n)=>f.createElement(Je,{...e,forwardedRef:n}));Je.displayName="Panel";xn.displayName="forwardRef(Panel)";let He=null,Se=-1,Y=null;function vn(e,n){if(n){const t=(n&en)!==0,r=(n&nn)!==0,i=(n&tn)!==0,o=(n&rn)!==0;if(t)return i?"se-resize":o?"ne-resize":"e-resize";if(r)return i?"sw-resize":o?"nw-resize":"w-resize";if(i)return"s-resize";if(o)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function Sn(){Y!==null&&(document.head.removeChild(Y),He=null,Y=null,Se=-1)}function Le(e,n){var t,r;const i=vn(e,n);if(He!==i){if(He=i,Y===null&&(Y=document.createElement("style"),document.head.appendChild(Y)),Se>=0){var o;(o=Y.sheet)===null||o===void 0||o.removeRule(Se)}Se=(t=(r=Y.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${i} !important;}`))!==null&&t!==void 0?t:-1}}function je(e){return e.type==="keydown"}function Ye(e){return e.type.startsWith("pointer")}function Ze(e){return e.type.startsWith("mouse")}function Ee(e){if(Ye(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Ze(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function bn(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Pn(e,n,t){return e.x<n.x+n.width&&e.x+e.width>n.x&&e.y<n.y+n.height&&e.y+e.height>n.y}function wn(e,n){if(e===n)throw new Error("Cannot compare node with itself");const t={a:Ue(e),b:Ue(n)};let r;for(;t.a.at(-1)===t.b.at(-1);)e=t.a.pop(),n=t.b.pop(),r=e;x(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:Ke(We(t.a)),b:Ke(We(t.b))};if(i.a===i.b){const o=r.childNodes,l={a:t.a.at(-1),b:t.b.at(-1)};let s=o.length;for(;s--;){const a=o[s];if(a===l.a)return 1;if(a===l.b)return-1}}return Math.sign(i.a-i.b)}const En=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Cn(e){var n;const t=getComputedStyle((n=Qe(e))!==null&&n!==void 0?n:e).display;return t==="flex"||t==="inline-flex"}function In(e){const n=getComputedStyle(e);return!!(n.position==="fixed"||n.zIndex!=="auto"&&(n.position!=="static"||Cn(e))||+n.opacity<1||"transform"in n&&n.transform!=="none"||"webkitTransform"in n&&n.webkitTransform!=="none"||"mixBlendMode"in n&&n.mixBlendMode!=="normal"||"filter"in n&&n.filter!=="none"||"webkitFilter"in n&&n.webkitFilter!=="none"||"isolation"in n&&n.isolation==="isolate"||En.test(n.willChange)||n.webkitOverflowScrolling==="touch")}function We(e){let n=e.length;for(;n--;){const t=e[n];if(x(t,"Missing node"),In(t))return t}return null}function Ke(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Ue(e){const n=[];for(;e;)n.push(e),e=Qe(e);return n}function Qe(e){const{parentNode:n}=e;return n&&n instanceof ShadowRoot?n.host:n}const en=1,nn=2,tn=4,rn=8,Rn=bn()==="coarse";let V=[],se=!1,ee=new Map,Ce=new Map;const he=new Set;function Ln(e,n,t,r,i){var o;const{ownerDocument:l}=n,s={direction:t,element:n,hitAreaMargins:r,setResizeHandlerState:i},a=(o=ee.get(l))!==null&&o!==void 0?o:0;return ee.set(l,a+1),he.add(s),be(),function(){var w;Ce.delete(e),he.delete(s);const p=(w=ee.get(l))!==null&&w!==void 0?w:1;if(ee.set(l,p-1),be(),p===1&&ee.delete(l),V.includes(s)){const u=V.indexOf(s);u>=0&&V.splice(u,1),Ge(),i("up",!0,null)}}}function An(e){const{target:n}=e,{x:t,y:r}=Ee(e);se=!0,_e({target:n,x:t,y:r}),be(),V.length>0&&(Pe("down",e),e.preventDefault(),on(n)||e.stopImmediatePropagation())}function Ae(e){const{x:n,y:t}=Ee(e);if(se&&e.buttons===0&&(se=!1,Pe("up",e)),!se){const{target:r}=e;_e({target:r,x:n,y:t})}Pe("move",e),Ge(),V.length>0&&e.preventDefault()}function ke(e){const{target:n}=e,{x:t,y:r}=Ee(e);Ce.clear(),se=!1,V.length>0&&(e.preventDefault(),on(n)||e.stopImmediatePropagation()),Pe("up",e),_e({target:n,x:t,y:r}),Ge(),be()}function on(e){let n=e;for(;n;){if(n.hasAttribute(k.resizeHandle))return!0;n=n.parentElement}return!1}function _e({target:e,x:n,y:t}){V.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),he.forEach(i=>{const{element:o,hitAreaMargins:l}=i,s=o.getBoundingClientRect(),{bottom:a,left:h,right:w,top:p}=s,u=Rn?l.coarse:l.fine;if(n>=h-u&&n<=w+u&&t>=p-u&&t<=a+u){if(r!==null&&document.contains(r)&&o!==r&&!o.contains(r)&&!r.contains(o)&&wn(r,o)>0){let z=r,C=!1;for(;z&&!z.contains(o);){if(Pn(z.getBoundingClientRect(),s)){C=!0;break}z=z.parentElement}if(C)return}V.push(i)}})}function De(e,n){Ce.set(e,n)}function Ge(){let e=!1,n=!1;V.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:n=!0});let t=0;Ce.forEach(r=>{t|=r}),e&&n?Le("intersection",t):e?Le("horizontal",t):n?Le("vertical",t):Sn()}let Me=new AbortController;function be(){Me.abort(),Me=new AbortController;const e={capture:!0,signal:Me.signal};he.size&&(se?(V.length>0&&ee.forEach((n,t)=>{const{body:r}=t;n>0&&(r.addEventListener("contextmenu",ke,e),r.addEventListener("pointerleave",Ae,e),r.addEventListener("pointermove",Ae,e))}),window.addEventListener("pointerup",ke,e),window.addEventListener("pointercancel",ke,e)):ee.forEach((n,t)=>{const{body:r}=t;n>0&&(r.addEventListener("pointerdown",An,e),r.addEventListener("pointermove",Ae,e))}))}function Pe(e,n){he.forEach(t=>{const{setResizeHandlerState:r}=t,i=V.includes(t);r(e,i,n)})}function kn(){const[e,n]=f.useState(0);return f.useCallback(()=>n(t=>t+1),[])}function x(e,n){if(!e)throw console.error(n),Error(n)}function te(e,n,t=$e){return e.toFixed(t)===n.toFixed(t)?0:e>n?1:-1}function j(e,n,t=$e){return te(e,n,t)===0}function W(e,n,t){return te(e,n,t)===0}function Dn(e,n,t){if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++){const i=e[r],o=n[r];if(!W(i,o,t))return!1}return!0}function le({panelConstraints:e,panelIndex:n,size:t}){const r=e[n];x(r!=null,`Panel constraints not found for index ${n}`);let{collapsedSize:i=0,collapsible:o,maxSize:l=100,minSize:s=0}=r;if(te(t,s)<0)if(o){const a=(i+s)/2;te(t,a)<0?t=i:t=s}else t=s;return t=Math.min(l,t),t=parseFloat(t.toFixed($e)),t}function ge({delta:e,initialLayout:n,panelConstraints:t,pivotIndices:r,prevLayout:i,trigger:o}){if(W(e,0))return n;const l=[...n],[s,a]=r;x(s!=null,"Invalid first pivot index"),x(a!=null,"Invalid second pivot index");let h=0;if(o==="keyboard"){{const p=e<0?a:s,u=t[p];x(u,`Panel constraints not found for index ${p}`);const{collapsedSize:v=0,collapsible:z,minSize:C=0}=u;if(z){const E=n[p];if(x(E!=null,`Previous layout not found for panel index ${p}`),W(E,v)){const b=C-E;te(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}{const p=e<0?s:a,u=t[p];x(u,`No panel constraints found for index ${p}`);const{collapsedSize:v=0,collapsible:z,minSize:C=0}=u;if(z){const E=n[p];if(x(E!=null,`Previous layout not found for panel index ${p}`),W(E,C)){const b=E-v;te(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}}{const p=e<0?1:-1;let u=e<0?a:s,v=0;for(;;){const C=n[u];x(C!=null,`Previous layout not found for panel index ${u}`);const b=le({panelConstraints:t,panelIndex:u,size:100})-C;if(v+=b,u+=p,u<0||u>=t.length)break}const z=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-z:z}{let u=e<0?s:a;for(;u>=0&&u<t.length;){const v=Math.abs(e)-Math.abs(h),z=n[u];x(z!=null,`Previous layout not found for panel index ${u}`);const C=z-v,E=le({panelConstraints:t,panelIndex:u,size:C});if(!W(z,E)&&(h+=z-E,l[u]=E,h.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?u--:u++}}if(Dn(i,l))return i;{const p=e<0?a:s,u=n[p];x(u!=null,`Previous layout not found for panel index ${p}`);const v=u+h,z=le({panelConstraints:t,panelIndex:p,size:v});if(l[p]=z,!W(z,v)){let C=v-z,b=e<0?a:s;for(;b>=0&&b<t.length;){const L=l[b];x(L!=null,`Previous layout not found for panel index ${b}`);const M=L+C,$=le({panelConstraints:t,panelIndex:b,size:M});if(W(L,$)||(C-=$-L,l[b]=$),W(C,0))break;e>0?b--:b++}}}const w=l.reduce((p,u)=>u+p,0);return W(w,100)?l:i}function Mn({layout:e,panelsArray:n,pivotIndices:t}){let r=0,i=100,o=0,l=0;const s=t[0];x(s!=null,"No pivot index found"),n.forEach((p,u)=>{const{constraints:v}=p,{maxSize:z=100,minSize:C=0}=v;u===s?(r=C,i=z):(o+=C,l+=z)});const a=Math.min(i,100-o),h=Math.max(r,100-l),w=e[s];return{valueMax:a,valueMin:h,valueNow:w}}function ze(e,n=document){return Array.from(n.querySelectorAll(`[${k.resizeHandleId}][data-panel-group-id="${e}"]`))}function ln(e,n,t=document){const i=ze(e,t).findIndex(o=>o.getAttribute(k.resizeHandleId)===n);return i??null}function sn(e,n,t){const r=ln(e,n,t);return r!=null?[r,r+1]:[-1,-1]}function an(e,n=document){var t;if(n instanceof HTMLElement&&(n==null||(t=n.dataset)===null||t===void 0?void 0:t.panelGroupId)==e)return n;const r=n.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return r||null}function Ie(e,n=document){const t=n.querySelector(`[${k.resizeHandleId}="${e}"]`);return t||null}function Hn(e,n,t,r=document){var i,o,l,s;const a=Ie(n,r),h=ze(e,r),w=a?h.indexOf(a):-1,p=(i=(o=t[w])===null||o===void 0?void 0:o.id)!==null&&i!==void 0?i:null,u=(l=(s=t[w+1])===null||s===void 0?void 0:s.id)!==null&&l!==void 0?l:null;return[p,u]}function $n({committedValuesRef:e,eagerValuesRef:n,groupId:t,layout:r,panelDataArray:i,panelGroupElement:o,setLayout:l}){f.useRef({didWarnAboutMissingResizeHandle:!1}),ne(()=>{if(!o)return;const s=ze(t,o);for(let a=0;a<i.length-1;a++){const{valueMax:h,valueMin:w,valueNow:p}=Mn({layout:r,panelsArray:i,pivotIndices:[a,a+1]}),u=s[a];if(u!=null){const v=i[a];x(v,`No panel data found for index "${a}"`),u.setAttribute("aria-controls",v.id),u.setAttribute("aria-valuemax",""+Math.round(h)),u.setAttribute("aria-valuemin",""+Math.round(w)),u.setAttribute("aria-valuenow",p!=null?""+Math.round(p):"")}}return()=>{s.forEach((a,h)=>{a.removeAttribute("aria-controls"),a.removeAttribute("aria-valuemax"),a.removeAttribute("aria-valuemin"),a.removeAttribute("aria-valuenow")})}},[t,r,i,o]),f.useEffect(()=>{if(!o)return;const s=n.current;x(s,"Eager values not found");const{panelDataArray:a}=s,h=an(t,o);x(h!=null,`No group found for id "${t}"`);const w=ze(t,o);x(w,`No resize handles found for group id "${t}"`);const p=w.map(u=>{const v=u.getAttribute(k.resizeHandleId);x(v,"Resize handle element has no handle id attribute");const[z,C]=Hn(t,v,a,o);if(z==null||C==null)return()=>{};const E=b=>{if(!b.defaultPrevented)switch(b.key){case"Enter":{b.preventDefault();const L=a.findIndex(M=>M.id===z);if(L>=0){const M=a[L];x(M,`No panel data found for index ${L}`);const $=r[L],{collapsedSize:O=0,collapsible:R,minSize:P=0}=M.constraints;if($!=null&&R){const K=ge({delta:W($,O)?P-O:O-$,initialLayout:r,panelConstraints:a.map(J=>J.constraints),pivotIndices:sn(t,v,o),prevLayout:r,trigger:"keyboard"});r!==K&&l(K)}}break}}};return u.addEventListener("keydown",E),()=>{u.removeEventListener("keydown",E)}});return()=>{p.forEach(u=>u())}},[o,e,n,t,r,i,l])}function Ve(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function un(e,n){const t=e==="horizontal",{x:r,y:i}=Ee(n);return t?r:i}function Nn(e,n,t,r,i){const o=t==="horizontal",l=Ie(n,i);x(l,`No resize handle element found for id "${n}"`);const s=l.getAttribute(k.groupId);x(s,"Resize handle element has no group id attribute");let{initialCursorPosition:a}=r;const h=un(t,e),w=an(s,i);x(w,`No group element found for id "${s}"`);const p=w.getBoundingClientRect(),u=o?p.width:p.height;return(h-a)/u*100}function _n(e,n,t,r,i,o){if(je(e)){const l=t==="horizontal";let s=0;e.shiftKey?s=100:i!=null?s=i:s=10;let a=0;switch(e.key){case"ArrowDown":a=l?0:s;break;case"ArrowLeft":a=l?-s:0;break;case"ArrowRight":a=l?s:0;break;case"ArrowUp":a=l?0:-s;break;case"End":a=100;break;case"Home":a=-100;break}return a}else return r==null?0:Nn(e,n,t,r,o)}function Gn({panelDataArray:e}){const n=Array(e.length),t=e.map(o=>o.constraints);let r=0,i=100;for(let o=0;o<e.length;o++){const l=t[o];x(l,`Panel constraints not found for index ${o}`);const{defaultSize:s}=l;s!=null&&(r++,n[o]=s,i-=s)}for(let o=0;o<e.length;o++){const l=t[o];x(l,`Panel constraints not found for index ${o}`);const{defaultSize:s}=l;if(s!=null)continue;const a=e.length-r,h=i/a;r++,n[o]=h,i-=h}return n}function oe(e,n,t){n.forEach((r,i)=>{const o=e[i];x(o,`Panel data not found for index ${i}`);const{callbacks:l,constraints:s,id:a}=o,{collapsedSize:h=0,collapsible:w}=s,p=t[a];if(p==null||r!==p){t[a]=r;const{onCollapse:u,onExpand:v,onResize:z}=l;z&&z(r,p),w&&(u||v)&&(v&&(p==null||j(p,h))&&!j(r,h)&&v(),u&&(p==null||!j(p,h))&&j(r,h)&&u())}})}function ve(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!=n[t])return!1;return!0}function Bn({defaultSize:e,dragState:n,layout:t,panelData:r,panelIndex:i,precision:o=3}){const l=t[i];let s;return l==null?s=e!=null?e.toPrecision(o):"1":r.length===1?s="1":s=l.toPrecision(o),{flexBasis:0,flexGrow:s,flexShrink:1,overflow:"hidden",pointerEvents:n!==null?"none":void 0}}function Tn(e,n=10){let t=null;return(...i)=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{e(...i)},n)}}function Oe(e){try{if(typeof localStorage<"u")e.getItem=n=>localStorage.getItem(n),e.setItem=(n,t)=>{localStorage.setItem(n,t)};else throw new Error("localStorage not supported in this environment")}catch(n){console.error(n),e.getItem=()=>null,e.setItem=()=>{}}}function cn(e){return`react-resizable-panels:${e}`}function fn(e){return e.map(n=>{const{constraints:t,id:r,idIsFromProps:i,order:o}=n;return i?r:o?`${o}:${JSON.stringify(t)}`:JSON.stringify(t)}).sort((n,t)=>n.localeCompare(t)).join(",")}function dn(e,n){try{const t=cn(e),r=n.getItem(t);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function Fn(e,n,t){var r,i;const o=(r=dn(e,t))!==null&&r!==void 0?r:{},l=fn(n);return(i=o[l])!==null&&i!==void 0?i:null}function Wn(e,n,t,r,i){var o;const l=cn(e),s=fn(n),a=(o=dn(e,i))!==null&&o!==void 0?o:{};a[s]={expandToSizes:Object.fromEntries(t.entries()),layout:r};try{i.setItem(l,JSON.stringify(a))}catch(h){console.error(h)}}function qe({layout:e,panelConstraints:n}){const t=[...e],r=t.reduce((o,l)=>o+l,0);if(t.length!==n.length)throw Error(`Invalid ${n.length} panel layout: ${t.map(o=>`${o}%`).join(", ")}`);if(!W(r,100)&&t.length>0)for(let o=0;o<n.length;o++){const l=t[o];x(l!=null,`No layout data found for index ${o}`);const s=100/r*l;t[o]=s}let i=0;for(let o=0;o<n.length;o++){const l=t[o];x(l!=null,`No layout data found for index ${o}`);const s=le({panelConstraints:n,panelIndex:o,size:l});l!=s&&(i+=l-s,t[o]=s)}if(!W(i,0))for(let o=0;o<n.length;o++){const l=t[o];x(l!=null,`No layout data found for index ${o}`);const s=l+i,a=le({panelConstraints:n,panelIndex:o,size:s});if(l!==a&&(i-=a-l,t[o]=a,W(i,0)))break}return t}const Kn=100,me={getItem:e=>(Oe(me),me.getItem(e)),setItem:(e,n)=>{Oe(me),me.setItem(e,n)}},Xe={};function pn({autoSaveId:e=null,children:n,className:t="",direction:r,forwardedRef:i,id:o=null,onLayout:l=null,keyboardResizeBy:s=null,storage:a=me,style:h,tagName:w="div",...p}){const u=Ne(o),v=f.useRef(null),[z,C]=f.useState(null),[E,b]=f.useState([]),L=kn(),M=f.useRef({}),$=f.useRef(new Map),O=f.useRef(0),R=f.useRef({autoSaveId:e,direction:r,dragState:z,id:u,keyboardResizeBy:s,onLayout:l,storage:a}),P=f.useRef({layout:E,panelDataArray:[],panelDataArrayChanged:!1});f.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),f.useImperativeHandle(i,()=>({getId:()=>R.current.id,getLayout:()=>{const{layout:c}=P.current;return c},setLayout:c=>{const{onLayout:m}=R.current,{layout:S,panelDataArray:g}=P.current,d=qe({layout:c,panelConstraints:g.map(y=>y.constraints)});Ve(S,d)||(b(d),P.current.layout=d,m&&m(d),oe(g,d,M.current))}}),[]),ne(()=>{R.current.autoSaveId=e,R.current.direction=r,R.current.dragState=z,R.current.id=u,R.current.onLayout=l,R.current.storage=a}),$n({committedValuesRef:R,eagerValuesRef:P,groupId:u,layout:E,panelDataArray:P.current.panelDataArray,setLayout:b,panelGroupElement:v.current}),f.useEffect(()=>{const{panelDataArray:c}=P.current;if(e){if(E.length===0||E.length!==c.length)return;let m=Xe[e];m==null&&(m=Tn(Wn,Kn),Xe[e]=m);const S=[...c],g=new Map($.current);m(e,S,g,E,a)}},[e,E,a]),f.useEffect(()=>{});const K=f.useCallback(c=>{const{onLayout:m}=R.current,{layout:S,panelDataArray:g}=P.current;if(c.constraints.collapsible){const d=g.map(q=>q.constraints),{collapsedSize:y=0,panelSize:I,pivotIndices:H}=Q(g,c,S);if(x(I!=null,`Panel size not found for panel "${c.id}"`),!j(I,y)){$.current.set(c.id,I);const X=ie(g,c)===g.length-1?I-y:y-I,A=ge({delta:X,initialLayout:S,panelConstraints:d,pivotIndices:H,prevLayout:S,trigger:"imperative-api"});ve(S,A)||(b(A),P.current.layout=A,m&&m(A),oe(g,A,M.current))}}},[]),J=f.useCallback((c,m)=>{const{onLayout:S}=R.current,{layout:g,panelDataArray:d}=P.current;if(c.constraints.collapsible){const y=d.map(U=>U.constraints),{collapsedSize:I=0,panelSize:H=0,minSize:q=0,pivotIndices:X}=Q(d,c,g),A=m??q;if(j(H,I)){const U=$.current.get(c.id),de=U!=null&&U>=A?U:A,Re=ie(d,c)===d.length-1?H-de:de-H,T=ge({delta:Re,initialLayout:g,panelConstraints:y,pivotIndices:X,prevLayout:g,trigger:"imperative-api"});ve(g,T)||(b(T),P.current.layout=T,S&&S(T),oe(d,T,M.current))}}},[]),F=f.useCallback(c=>{const{layout:m,panelDataArray:S}=P.current,{panelSize:g}=Q(S,c,m);return x(g!=null,`Panel size not found for panel "${c.id}"`),g},[]),G=f.useCallback((c,m)=>{const{panelDataArray:S}=P.current,g=ie(S,c);return Bn({defaultSize:m,dragState:z,layout:E,panelData:S,panelIndex:g})},[z,E]),D=f.useCallback(c=>{const{layout:m,panelDataArray:S}=P.current,{collapsedSize:g=0,collapsible:d,panelSize:y}=Q(S,c,m);return x(y!=null,`Panel size not found for panel "${c.id}"`),d===!0&&j(y,g)},[]),Z=f.useCallback(c=>{const{layout:m,panelDataArray:S}=P.current,{collapsedSize:g=0,collapsible:d,panelSize:y}=Q(S,c,m);return x(y!=null,`Panel size not found for panel "${c.id}"`),!d||te(y,g)>0},[]),_=f.useCallback(c=>{const{panelDataArray:m}=P.current;m.push(c),m.sort((S,g)=>{const d=S.order,y=g.order;return d==null&&y==null?0:d==null?-1:y==null?1:d-y}),P.current.panelDataArrayChanged=!0,L()},[L]);ne(()=>{if(P.current.panelDataArrayChanged){P.current.panelDataArrayChanged=!1;const{autoSaveId:c,onLayout:m,storage:S}=R.current,{layout:g,panelDataArray:d}=P.current;let y=null;if(c){const H=Fn(c,d,S);H&&($.current=new Map(Object.entries(H.expandToSizes)),y=H.layout)}y==null&&(y=Gn({panelDataArray:d}));const I=qe({layout:y,panelConstraints:d.map(H=>H.constraints)});Ve(g,I)||(b(I),P.current.layout=I,m&&m(I),oe(d,I,M.current))}}),ne(()=>{const c=P.current;return()=>{c.layout=[]}},[]);const N=f.useCallback(c=>{let m=!1;const S=v.current;return S&&window.getComputedStyle(S,null).getPropertyValue("direction")==="rtl"&&(m=!0),function(d){d.preventDefault();const y=v.current;if(!y)return()=>null;const{direction:I,dragState:H,id:q,keyboardResizeBy:X,onLayout:A}=R.current,{layout:U,panelDataArray:de}=P.current,{initialLayout:xe}=H??{},Re=sn(q,c,y);let T=_n(d,c,I,H,X,y);const Be=I==="horizontal";Be&&m&&(T=-T);const gn=de.map(mn=>mn.constraints),pe=ge({delta:T,initialLayout:xe??U,panelConstraints:gn,pivotIndices:Re,prevLayout:U,trigger:je(d)?"keyboard":"mouse-or-touch"}),Te=!ve(U,pe);(Ye(d)||Ze(d))&&O.current!=T&&(O.current=T,!Te&&T!==0?Be?De(c,T<0?en:nn):De(c,T<0?tn:rn):De(c,0)),Te&&(b(pe),P.current.layout=pe,A&&A(pe),oe(de,pe,M.current))}},[]),B=f.useCallback((c,m)=>{const{onLayout:S}=R.current,{layout:g,panelDataArray:d}=P.current,y=d.map(U=>U.constraints),{panelSize:I,pivotIndices:H}=Q(d,c,g);x(I!=null,`Panel size not found for panel "${c.id}"`);const X=ie(d,c)===d.length-1?I-m:m-I,A=ge({delta:X,initialLayout:g,panelConstraints:y,pivotIndices:H,prevLayout:g,trigger:"imperative-api"});ve(g,A)||(b(A),P.current.layout=A,S&&S(A),oe(d,A,M.current))},[]),ae=f.useCallback((c,m)=>{const{layout:S,panelDataArray:g}=P.current,{collapsedSize:d=0,collapsible:y}=m,{collapsedSize:I=0,collapsible:H,maxSize:q=100,minSize:X=0}=c.constraints,{panelSize:A}=Q(g,c,S);A!=null&&(y&&H&&j(A,d)?j(d,I)||B(c,I):A<X?B(c,X):A>q&&B(c,q))},[B]),ue=f.useCallback((c,m)=>{const{direction:S}=R.current,{layout:g}=P.current;if(!v.current)return;const d=Ie(c,v.current);x(d,`Drag handle element not found for id "${c}"`);const y=un(S,m);C({dragHandleId:c,dragHandleRect:d.getBoundingClientRect(),initialCursorPosition:y,initialLayout:g})},[]),ce=f.useCallback(()=>{C(null)},[]),ye=f.useCallback(c=>{const{panelDataArray:m}=P.current,S=ie(m,c);S>=0&&(m.splice(S,1),delete M.current[c.id],P.current.panelDataArrayChanged=!0,L())},[L]),re=f.useMemo(()=>({collapsePanel:K,direction:r,dragState:z,expandPanel:J,getPanelSize:F,getPanelStyle:G,groupId:u,isPanelCollapsed:D,isPanelExpanded:Z,reevaluatePanelConstraints:ae,registerPanel:_,registerResizeHandle:N,resizePanel:B,startDragging:ue,stopDragging:ce,unregisterPanel:ye,panelGroupElement:v.current}),[K,z,r,J,F,G,u,D,Z,ae,_,N,B,ue,ce,ye]),fe={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return f.createElement(we.Provider,{value:re},f.createElement(w,{...p,children:n,className:t,id:o,ref:v,style:{...fe,...h},[k.group]:"",[k.groupDirection]:r,[k.groupId]:u}))}const Un=f.forwardRef((e,n)=>f.createElement(pn,{...e,forwardedRef:n}));pn.displayName="PanelGroup";Un.displayName="forwardRef(PanelGroup)";function ie(e,n){return e.findIndex(t=>t===n||t.id===n.id)}function Q(e,n,t){const r=ie(e,n),o=r===e.length-1?[r-1,r]:[r,r+1],l=t[r];return{...n.constraints,panelSize:l,pivotIndices:o}}function Vn({disabled:e,handleId:n,resizeHandler:t,panelGroupElement:r}){f.useEffect(()=>{if(e||t==null||r==null)return;const i=Ie(n,r);if(i==null)return;const o=l=>{if(!l.defaultPrevented)switch(l.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{l.preventDefault(),t(l);break}case"F6":{l.preventDefault();const s=i.getAttribute(k.groupId);x(s,`No group element found for id "${s}"`);const a=ze(s,r),h=ln(s,n,r);x(h!==null,`No resize element found for id "${n}"`);const w=l.shiftKey?h>0?h-1:a.length-1:h+1<a.length?h+1:0;a[w].focus();break}}};return i.addEventListener("keydown",o),()=>{i.removeEventListener("keydown",o)}},[r,e,n,t])}function On({children:e=null,className:n="",disabled:t=!1,hitAreaMargins:r,id:i,onBlur:o,onClick:l,onDragging:s,onFocus:a,onPointerDown:h,onPointerUp:w,style:p={},tabIndex:u=0,tagName:v="div",...z}){var C,E;const b=f.useRef(null),L=f.useRef({onClick:l,onDragging:s,onPointerDown:h,onPointerUp:w});f.useEffect(()=>{L.current.onClick=l,L.current.onDragging=s,L.current.onPointerDown=h,L.current.onPointerUp=w});const M=f.useContext(we);if(M===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:$,groupId:O,registerResizeHandle:R,startDragging:P,stopDragging:K,panelGroupElement:J}=M,F=Ne(i),[G,D]=f.useState("inactive"),[Z,_]=f.useState(!1),[N,B]=f.useState(null),ae=f.useRef({state:G});ne(()=>{ae.current.state=G}),f.useEffect(()=>{if(t)B(null);else{const re=R(F);B(()=>re)}},[t,F,R]);const ue=(C=r==null?void 0:r.coarse)!==null&&C!==void 0?C:15,ce=(E=r==null?void 0:r.fine)!==null&&E!==void 0?E:5;f.useEffect(()=>{if(t||N==null)return;const re=b.current;x(re,"Element ref not attached");let fe=!1;return Ln(F,re,$,{coarse:ue,fine:ce},(m,S,g)=>{if(!S){D("inactive");return}switch(m){case"down":{D("drag"),fe=!1,x(g,'Expected event to be defined for "down" action'),P(F,g);const{onDragging:d,onPointerDown:y}=L.current;d==null||d(!0),y==null||y();break}case"move":{const{state:d}=ae.current;fe=!0,d!=="drag"&&D("hover"),x(g,'Expected event to be defined for "move" action'),N(g);break}case"up":{D("hover"),K();const{onClick:d,onDragging:y,onPointerUp:I}=L.current;y==null||y(!1),I==null||I(),fe||d==null||d();break}}})},[ue,$,t,ce,R,F,N,P,K]),Vn({disabled:t,handleId:F,resizeHandler:N,panelGroupElement:J});const ye={touchAction:"none",userSelect:"none"};return f.createElement(v,{...z,children:e,className:n,id:i,onBlur:()=>{_(!1),o==null||o()},onFocus:()=>{_(!0),a==null||a()},ref:b,role:"separator",style:{...ye,...p},tabIndex:u,[k.groupDirection]:$,[k.groupId]:O,[k.resizeHandle]:"",[k.resizeHandleActive]:G==="drag"?"pointer":Z?"keyboard":void 0,[k.resizeHandleEnabled]:!t,[k.resizeHandleId]:F,[k.resizeHandleState]:G})}On.displayName="PanelResizeHandle";export{Un as P,xn as a,On as b};
@@ -1,4 +1,4 @@
1
- import{r as O}from"./icons-BXecaLRH.js";var y={exports:{}},n={};/**
1
+ import{r as O}from"./icons-B9mi2ie6.js";var y={exports:{}},n={};/**
2
2
  * @license React
3
3
  * react-dom.production.js
4
4
  *
@@ -1,4 +1,4 @@
1
- import{r as A,g as U,W as F}from"./icons-BXecaLRH.js";var _={exports:{}},g={};/**
1
+ import{r as A,g as U,W as F}from"./icons-B9mi2ie6.js";var _={exports:{}},g={};/**
2
2
  * @license React
3
3
  * use-sync-external-store-shim.production.js
4
4
  *
@@ -12,13 +12,13 @@
12
12
  <meta name="theme-color" content="#0d1117" />
13
13
  <meta name="color-scheme" content="dark light" />
14
14
  <title>DeepSeekCode Web</title>
15
- <script type="module" crossorigin src="/assets/index-CcPIw0Dj.js"></script>
16
- <link rel="modulepreload" crossorigin href="/assets/icons-BXecaLRH.js">
17
- <link rel="modulepreload" crossorigin href="/assets/markdown-BASfeONY.js">
18
- <link rel="modulepreload" crossorigin href="/assets/react-vendor-7At16BnY.js">
19
- <link rel="modulepreload" crossorigin href="/assets/state-D4zgKwQs.js">
20
- <link rel="modulepreload" crossorigin href="/assets/panels-Bod3sKnK.js">
21
- <link rel="stylesheet" crossorigin href="/assets/index-CFxV9r1K.css">
15
+ <script type="module" crossorigin src="/assets/index-PcXINYWS.js"></script>
16
+ <link rel="modulepreload" crossorigin href="/assets/icons-B9mi2ie6.js">
17
+ <link rel="modulepreload" crossorigin href="/assets/markdown-BrFQfawv.js">
18
+ <link rel="modulepreload" crossorigin href="/assets/react-vendor-CiRFOYk_.js">
19
+ <link rel="modulepreload" crossorigin href="/assets/state-BcoCffxz.js">
20
+ <link rel="modulepreload" crossorigin href="/assets/panels-BX-TtLOU.js">
21
+ <link rel="stylesheet" crossorigin href="/assets/index-DCj9TkXV.css">
22
22
  </head>
23
23
  <body>
24
24
  <div id="root"></div>
@@ -1,2 +0,0 @@
1
- import{j as t}from"./markdown-BASfeONY.js";import{a as r,h as oe,a1 as Dt,z as fe,aa as G,X as et,ap as Mt,C as ve,aq as tt,ar as $t,as as Et,ae as zt,ag as Lt,at as Rt,au as Ut,D as Ft,av as st,_ as Ot,aw as _t}from"./icons-BXecaLRH.js";import{a as p,t as P,M as ye,P as Bt}from"./index-CcPIw0Dj.js";import"./react-vendor-7At16BnY.js";import"./state-D4zgKwQs.js";import"./panels-Bod3sKnK.js";function Gt(){const[y,m]=r.useState([]),[I,f]=r.useState("1.0"),[ie,x]=r.useState(!0),[ue,H]=r.useState(!0),[Y,$]=r.useState(null),j=r.useCallback(async()=>{H(!0),$(null);try{const v=await p.providers.presets();v.success&&v.data?(m(Array.isArray(v.data.providers)?v.data.providers:[]),f(v.data.version||"1.0"),x(v.data.customSupported!==!1)):$(v.error||"获取 Provider 列表失败")}catch(v){$(v instanceof Error?v.message:"未知错误")}finally{H(!1)}},[]);return r.useEffect(()=>{j()},[j]),{presets:y,loading:ue,error:Y,version:I,customSupported:ie,reload:j}}const je={provider:"",modelId:"",modelName:"",apiKey:""},Ht={providerKey:"",apiKeys:"",modelIds:"",baseUrl:"",apiType:"",setDefault:!1},Yt=Bt,qt={"openai-chat-completions":"OpenAI Chat","openai-completions":"OpenAI Compatible","openai-responses":"OpenAI Responses","anthropic-messages":"Anthropic Messages"};function Vt(y){const m=y.toLowerCase();return m.includes("/anthropic")||m.includes("/coding")||m.includes("/claude")||m.includes("/messages")?"anthropic-messages":m.includes("/responses")?"openai-responses":"openai-completions"}const at={deepseek:10,moonshotai:20,"moonshotai-cn":21,"kimi-for-coding":22,zhipuai:30,zai:31,"alibaba-cn":40,alibaba:41,minimax:50,"minimax-cn":51,moark:60,siliconflow:70,"siliconflow-cn":71,"stepfun-ai":80,stepfun:81,modelscope:90,openai:100,anthropic:110,google:120,"google-vertex":121,meta:130,mistral:140,groq:150,xai:160,cohere:170,openrouter:180,huggingface:190};function ts(){var Be,Ge,He,Ye,qe,Ve,Qe,We,Xe,Je;const{presets:y,loading:m,reload:I}=Gt(),[f,ie]=r.useState([]),[x,ue]=r.useState(null),[H,Y]=r.useState(!0),[$,j]=r.useState(null),[v,ke]=r.useState(null),[lt,q]=r.useState(!1),[k,V]=r.useState(null),[N,S]=r.useState(je),[Ne,we]=r.useState(!1),[Ce,U]=r.useState(null),[n,nt]=r.useState(null),[ot,E]=r.useState(!1),[Pe,F]=r.useState("select"),[g,z]=r.useState(null),[i,w]=r.useState(Ht),[Ie,Se]=r.useState(!1),[Ke,K]=r.useState(null),[ct,xe]=r.useState(!1),[Q,Te]=r.useState(!1),[O,W]=r.useState(""),[Ae,De]=r.useState({}),[pe,Me]=r.useState(!1),[X,_]=r.useState([]),[J,T]=r.useState(new Set),[$e,L]=r.useState(null),[Z,me]=r.useState(""),A=r.useCallback(async()=>{try{const e=await p.config.provider.get();e.success&&e.data&&nt(e.data)}catch{}},[]),b=r.useCallback(async()=>{Y(!0),j(null);try{const[e,s]=await Promise.all([p.models.list(),p.system.status()]);if(await A(),e.success&&e.data&&Array.isArray(e.data.models)&&ie(e.data.models),s.success&&s.data){const a=s.data.models||{total:0,online:0,offline:0};ue({overallStatus:a.offline===0?"healthy":a.online>0?"degraded":"unhealthy",healthRate:a.total>0?a.online/a.total:0,healthyInstances:a.online,totalInstances:a.total,totalRequests:0})}}catch{j("加载模型失败")}finally{Y(!1)}},[A]);r.useEffect(()=>{b()},[b]),r.useEffect(()=>{const e=()=>{b(),A()};return window.addEventListener("models-updated",e),()=>window.removeEventListener("models-updated",e)},[b,A]);const D=r.useCallback(e=>`${e.provider}:${e.id}`,[]),dt=r.useCallback(e=>Ae[D(e)]||{inputTokens:0,outputTokens:0},[D,Ae]),Ee=r.useCallback((e,s,a)=>{const l=D(e);De(c=>{var o,d;return{...c,[l]:{inputTokens:s==="inputTokens"?a:((o=c[l])==null?void 0:o.inputTokens)||0,outputTokens:s==="outputTokens"?a:((d=c[l])==null?void 0:d.outputTokens)||0}}})},[D]),it=r.useCallback(e=>{De(s=>({...s,[D(e)]:{inputTokens:0,outputTokens:0}}))},[D]),M=r.useMemo(()=>{const e=[...y];return e.find(s=>s.key==="custom")||e.push({key:"custom",name:"Custom",baseUrl:"",apiType:"openai-completions",defaultModel:"",isCustom:!0}),e},[y]),ee=r.useMemo(()=>[...M].sort((e,s)=>{if(e.isCustom)return-1;if(s.isCustom)return 1;const a=at[e.key],l=at[s.key];return a!==void 0&&l!==void 0?a-l:a!==void 0?-1:l!==void 0?1:e.name.localeCompare(s.name)}),[M]),ze=r.useMemo(()=>{const e=O.trim().toLowerCase();return e?ee.filter(s=>s.name.toLowerCase().includes(e)||s.key.toLowerCase().includes(e)||(s.defaultModel||"").toLowerCase().includes(e)||(s.baseUrl||"").toLowerCase().includes(e)||(s.models||[]).some(a=>String(a).toLowerCase().includes(e))):ee},[ee,O]),C=r.useMemo(()=>{var l,c,o,d;const e=(n==null?void 0:n.providers)||{},s=new Set(M.map(u=>u.key)),a=Object.entries(e).filter(([u])=>!s.has(u));if(a.length!==0)return{keys:a.map(([u])=>u),modelCount:a.reduce((u,[,le])=>u+(le.modelCount||0),0),hasApiKey:a.some(([,u])=>u.hasApiKey),baseUrl:((c=(l=a.find(([,u])=>u.baseUrl))==null?void 0:l[1])==null?void 0:c.baseUrl)||"",apiType:((d=(o=a.find(([,u])=>u.apiType))==null?void 0:o[1])==null?void 0:d.apiType)||"openai-completions"}},[n,M]),Le=r.useCallback(e=>{var o,d;const s=(o=n==null?void 0:n.providers)==null?void 0:o[e.key],a=f.filter(u=>u.provider===e.key).map(u=>u.id),l=((d=e.models)==null?void 0:d.slice(0,3).join(", "))||e.defaultModel,c=a.length>0?a.join(", "):l;z(e.key),w({providerKey:e.key,apiKeys:"",modelIds:c,baseUrl:(s==null?void 0:s.baseUrl)||e.baseUrl,apiType:(s==null?void 0:s.apiType)||e.apiType,setDefault:(n==null?void 0:n.defaultProvider)!==e.key}),F("form"),E(!0),K(null),xe(!1),_([]),T(new Set),L(null),me("")},[f,n]),be=r.useCallback(()=>{var l,c;z("custom");const e=(l=C==null?void 0:C.keys)==null?void 0:l[0],s=e?(c=n==null?void 0:n.providers)==null?void 0:c[e]:void 0,a=e?f.filter(o=>o.provider===e).map(o=>o.id).join(", "):"";w({providerKey:e||"",apiKeys:"",modelIds:a,baseUrl:(s==null?void 0:s.baseUrl)||"",apiType:(s==null?void 0:s.apiType)||"openai-completions",setDefault:!(n!=null&&n.configured)}),F("form"),E(!0),K(null),xe(!1),_([]),T(new Set),L(null),me("")},[n,C,f]),ut=r.useCallback(async()=>{var s;const e=i.baseUrl;if(!e){L("请先填写 Base URL");return}Me(!0),L(null),_([]),T(new Set);try{const a=(i.apiKeys||"").split(/\r?\n|,/).map(o=>o.trim()).filter(Boolean)[0]||"",l=a.replace(/[^\x00-\xFF]/g,"");l!==a&&P.warning("API Key 包含非法字符,已自动过滤");const c=await p.models.fetch(e,l);if(c.success&&((s=c.data)!=null&&s.models)){_(c.data.models);const o=new Set(i.modelIds.split(",").map(d=>d.trim()).filter(Boolean));T(o),P.success(`获取到 ${c.data.models.length} 个模型`)}else L(c.error||"获取模型列表失败,请检查 Base URL 和 API Key")}catch(a){L(a instanceof Error?a.message:"请求失败")}finally{Me(!1)}},[i.baseUrl,i.apiKeys,i.modelIds]),xt=r.useCallback(e=>{const s=new Set(J);s.has(e)?s.delete(e):s.add(e),T(s),w(a=>({...a,modelIds:Array.from(s).join(", ")}))},[J]),[pt,Re]=r.useState(!1),[he,Ue]=r.useState(""),[Fe,te]=r.useState([]),[mt,Oe]=r.useState(!1),[_e,se]=r.useState(null),[ae,bt]=r.useState(!1),[re,ht]=r.useState(!0),gt=r.useCallback(()=>{Ue(""),te([]),se(null),Re(!0),B("",{reason:!1,tool:!0})},[]),B=r.useCallback(async(e,s)=>{Oe(!0),se(null);try{const a=await p.models.catalogSearch({q:e,reasoning:(s==null?void 0:s.reason)??!1,toolCall:(s==null?void 0:s.tool)??!0,limit:30});a.success&&a.data?te(a.data.hits||[]):(se(a.error||"目录搜索失败"),te([]))}catch(a){se(a instanceof Error?a.message:"请求失败"),te([])}finally{Oe(!1)}},[]),ft=r.useCallback(e=>{w(s=>{const a=s.modelIds.split(",").map(l=>l.trim()).filter(Boolean);return a.includes(e.model.id)?s:{...s,modelIds:[...a,e.model.id].join(", ")}}),P.success(`已添加 ${e.model.id}`)},[]),[ge,vt]=r.useState(null),yt=r.useCallback(e=>{Ue(e),ge&&clearTimeout(ge),vt(setTimeout(()=>{B(e,{reason:ae,tool:re})},300))},[ge,ae,re,B]),jt=async e=>{const s=f.find(o=>o.id===e);if(!s)return;const a=s.enabled!==!1,l=s.name||e,c=o=>a&&/default model/i.test(o);try{const o=await p.models.toggle(s.provider,e);if(o.success){await b();return}const d=o.error||"";c(d)?P.error(`“${l}” 是默认模型,无法直接禁用。请先在「Provider 配置」中更换默认模型,再进行禁用。`):P.error(d||"操作失败,请重试")}catch(o){const d=o instanceof Error?o.message:"";c(d)?P.error(`“${l}” 是默认模型,无法直接禁用。请先在「Provider 配置」中更换默认模型,再进行禁用。`):P.error(d||"操作失败,请重试")}},kt=async e=>{ke(e);try{await p.models.test(e),await b()}finally{ke(null)}},Nt=async(e,s)=>{if(confirm(`确定要删除模型 "${s}" 吗?此操作不可撤销。`))try{(await p.models.delete(e,s)).success&&await b()}catch{}},wt=e=>{V({provider:e.provider,modelId:e.id}),S({provider:e.provider,modelId:e.id,modelName:e.name,apiKey:""}),U(null),q(!0)},Ct=async()=>{var u,le;const e=M.find(h=>h.key===g)||null,s=g==="custom"?i.providerKey.trim():(e==null?void 0:e.key)||"";if(!s){K("请先输入 Provider 名称");return}const a=(i.apiKeys||"").split(/\r?\n|,/).map(h=>h.trim()).filter(Boolean),l=!!((le=(u=n==null?void 0:n.providers)==null?void 0:u[s])!=null&&le.hasApiKey);if(a.length===0&&!l){K("请至少输入一把 API Key");return}const c=e||{baseUrl:"",apiType:"openai-completions",defaultModel:""},o=a.map(h=>h.replace(/[^\x00-\xFF]/g,"")).filter(Boolean),d={provider:s,name:s,baseUrl:i.baseUrl||c.baseUrl,apiType:i.apiType||Vt(i.baseUrl||c.baseUrl)||c.apiType,models:(i.modelIds||c.defaultModel||"").split(",").map((h,Tt)=>{const ne=h.trim().split("|").map(At=>At.trim()).filter(Boolean),Ze=ne[0]||"";return{id:Ze,name:ne[1]||Ze,aliases:ne.length>2?ne.slice(2):void 0,enabled:!0,priority:10+Tt}}).filter(h=>h.id.length>0)};o.length>0&&(d.apiKeys=o),(!(n!=null&&n.configured)||i.setDefault)&&(d.setDefault=!0),Se(!0),K(null);try{const h=await p.config.provider.save(d);h.success?(E(!1),F("select"),z(null),await A(),await b()):K(h.error||"保存失败")}catch(h){K(h instanceof Error?h.message:"未知错误")}finally{Se(!1)}},Pt=async e=>{if(confirm(`确定要移除 "${e}" 的配置吗?这将删除其 API Key 和模型。`))try{await p.config.provider.delete(e),await A(),await b()}catch{}},It=async()=>{if(k){if(!N.provider.trim()||!N.modelId.trim()){U("提供商名称和模型 ID 不能为空");return}we(!0),U(null);try{const e={name:N.modelName.trim()||N.modelId.trim(),...N.apiKey.trim()?{apiKey:N.apiKey.trim()}:{}},s=await p.models.update(k.provider,k.modelId,{model:e});s.success?(q(!1),V(null),S(je),await b()):U(s.error||"保存失败")}catch(e){U(e instanceof Error?e.message:"未知错误")}finally{we(!1)}}},St=e=>{switch(e){case"online":return"text-accent-green";case"offline":return"text-dark-muted";case"error":return"text-accent-red";default:return"text-dark-muted"}},Kt=e=>{switch(e){case"online":return t.jsx(_t,{size:14});case"offline":return t.jsx(st,{size:14});case"error":return t.jsx(Ot,{size:14});default:return t.jsx(st,{size:14})}},R=r.useMemo(()=>M.find(e=>e.key===g)||null,[g,M]);return H?t.jsx("div",{className:"flex h-64 items-center justify-center text-dark-muted",children:"加载中..."}):$?t.jsx("div",{className:"flex h-64 items-center justify-center text-accent-red",children:$}):t.jsxs("div",{className:"p-6 space-y-6 flex-1 min-h-0 overflow-y-auto custom-scrollbar",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h2",{className:"text-base font-semibold",children:"Provider 配置"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{onClick:async()=>{try{await p.providers.refresh(),P.success("Provider 列表已刷新"),Te(!0),await I(),setTimeout(()=>{I()},3e3)}catch{P.error("刷新失败,请稍后重试")}},className:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs border border-dark-border rounded hover:bg-dark-hover",title:"从远端刷新 Provider 列表",children:[t.jsx(oe,{size:12}),"刷新列表"]}),t.jsxs("button",{onClick:()=>{Q&&W(""),Te(e=>!e)},className:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs bg-accent-blue text-white rounded hover:opacity-90",children:[Q?t.jsx(Dt,{size:12}):t.jsx(fe,{size:12}),Q?"收起":"新增 Provider"]})]})]}),Q&&t.jsxs("div",{children:[t.jsxs("div",{className:"relative mb-3 max-w-md",children:[t.jsx(G,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-dark-muted"}),t.jsx("input",{value:O,onChange:e=>W(e.target.value),className:"w-full pl-8 pr-8 py-1.5 text-xs bg-dark-bg border border-dark-border rounded focus:outline-none focus:border-accent-blue",placeholder:"搜索 Provider 名称 / 模型..."}),O&&t.jsx("button",{onClick:()=>W(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-dark-muted hover:text-white",title:"清除","aria-label":"清除搜索",children:t.jsx(et,{size:13})})]}),t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-3 max-h-[420px] overflow-y-auto custom-scrollbar pr-1",children:m?t.jsxs("div",{className:"col-span-full flex items-center justify-center py-4 text-dark-muted text-sm",children:[t.jsx(Mt,{size:14,className:"mr-2 animate-spin"}),"加载 Provider 列表..."]}):ze.length===0?t.jsxs("div",{className:"col-span-full border border-accent-red/30 bg-accent-red/10 rounded-lg p-4 text-center",children:[t.jsx("div",{className:"text-sm text-accent-red font-medium mb-1",children:"未找到匹配的 Provider"}),t.jsxs("div",{className:"text-xs text-dark-muted mb-3",children:["没有与「",O,"」匹配的 Provider,请检查拼写或改用完整列表"]}),t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsxs("button",{onClick:()=>W(""),className:"inline-flex items-center gap-1 px-2.5 py-1 text-xs border border-dark-border rounded hover:bg-dark-hover",children:[t.jsx(et,{size:12}),"清除搜索"]}),t.jsxs("button",{onClick:be,className:"inline-flex items-center gap-1 px-2.5 py-1 text-xs bg-accent-blue text-white rounded hover:opacity-90",children:[t.jsx(fe,{size:12}),"添加自定义 Provider"]})]})]}):ze.map(e=>{var o,d;const s=e.key==="custom",a=s?C:(o=n==null?void 0:n.providers)==null?void 0:o[e.key],l=a==null?void 0:a.hasApiKey,c=s?!!(n!=null&&n.defaultProvider)&&((C==null?void 0:C.keys)||[]).includes(n.defaultProvider):(n==null?void 0:n.defaultProvider)===e.key;return t.jsxs("div",{className:`text-left p-3 rounded-lg border transition-colors relative ${l?"border-accent-green/30 bg-dark-surface hover:border-accent-green/50":"border-dark-border bg-dark-surface hover:border-dark-hover"}`,children:[t.jsxs("div",{onClick:()=>e.key==="custom"?be():Le(e),className:"cursor-pointer",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"text-sm font-medium",children:e.name}),l&&t.jsx(ve,{size:14,className:"text-accent-green"})]}),t.jsxs("div",{className:"text-[10px] text-dark-muted space-y-0.5",children:[t.jsx("div",{className:"truncate",children:s?(a==null?void 0:a.baseUrl)||"自定义地址":e.baseUrl||"自定义地址"}),t.jsx("div",{className:"truncate",children:s&&C?`${C.keys.join(", ")}`:e.defaultModel||"无默认模型"}),t.jsxs("div",{children:[a?`${a.modelCount} 已配置`:`${((d=e.models)==null?void 0:d.length)||0} 可用`,e.models&&e.models.length>0&&!a&&t.jsx("span",{className:"text-accent-blue",children:" ✓"})]})]}),c&&t.jsx("div",{className:"mt-1 text-[10px] text-accent-blue",children:"默认 Provider"})]}),l&&e.key!=="custom"&&t.jsx("button",{onClick:u=>{u.stopPropagation(),Pt(e.key)},className:"absolute top-1.5 right-1.5 p-1 rounded text-dark-muted hover:bg-accent-red/10 hover:text-accent-red transition-colors",title:"删除 Provider","aria-label":`删除 ${e.name}`,children:t.jsx(tt,{size:13})})]},e.key)})})]})]}),x&&t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsx(ce,{title:"总体状态",value:x.totalInstances===0?"未配置":x.overallStatus==="healthy"?"健康":x.overallStatus==="degraded"?"降级":"异常",color:x.totalInstances===0?"blue":x.overallStatus==="healthy"?"green":x.overallStatus==="degraded"?"yellow":"red"}),t.jsx(ce,{title:"健康率",value:x.totalInstances===0?"N/A":`${(x.healthRate*100).toFixed(0)}%`,color:x.totalInstances===0?"blue":x.healthRate>.8?"green":x.healthRate>.5?"yellow":"red"}),t.jsx(ce,{title:"在线实例",value:x.totalInstances===0?"无":`${x.healthyInstances}/${x.totalInstances}`,color:x.healthyInstances>0?"green":"red"}),t.jsx(ce,{title:"总请求数",value:x.totalRequests>0?x.totalRequests.toLocaleString():"0",color:"blue"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"flex items-center justify-between mb-3",children:t.jsx("h3",{className:"text-sm font-medium",children:"已配置模型"})}),t.jsxs("div",{className:"space-y-2 max-h-[480px] overflow-y-auto custom-scrollbar pr-1",children:[f.map(e=>{const s=dt(e),a=s.inputTokens+s.outputTokens;return t.jsx("div",{className:`bg-dark-surface border rounded-lg p-3 ${e.status==="online"?"border-accent-green":"border-dark-border opacity-70"}`,children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[t.jsx("span",{className:St(e.status),children:Kt(e.status)}),t.jsx("span",{className:"font-medium text-sm",children:e.name}),t.jsx("span",{className:"text-[10px] text-dark-muted px-1.5 py-0.5 bg-dark-bg rounded",children:e.provider}),e.apiType&&t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${e.apiType==="anthropic-messages"?"bg-accent-purple/20 text-accent-purple":"bg-accent-blue/20 text-accent-blue"}`,children:e.apiType==="anthropic-messages"?"Anthropic":"OpenAI"}),e.isGlobalDefault&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-green/20 text-accent-green font-medium",children:"全局默认"}),e.isPlanDefault&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-blue/20 text-accent-blue font-medium",children:"Plan 默认"}),e.isActDefault&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-yellow/20 text-accent-yellow font-medium",children:"Act 默认"}),e.isGoalDefault&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-purple/20 text-accent-purple font-medium",children:"Goal 默认"})]}),t.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 text-xs",children:[t.jsx(de,{label:"负载",value:`${e.load}/${e.maxLoad}`}),t.jsx(de,{label:"Token",value:`${e.tokens}/${e.maxTokens}`}),t.jsx(de,{label:"输入价格",value:`$${e.price.input}/1K`}),t.jsx(de,{label:"输出价格",value:`$${e.price.output}/1K`})]}),t.jsxs("div",{className:"mt-3 grid grid-cols-1 sm:grid-cols-4 gap-3 items-end",children:[t.jsx(rt,{label:"输入 token",value:s.inputTokens,onChange:l=>Ee(e,"inputTokens",l)}),t.jsx(rt,{label:"输出 token",value:s.outputTokens,onChange:l=>Ee(e,"outputTokens",l)}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] text-dark-muted mb-1",children:"总 token"}),t.jsx("div",{className:"px-3 py-2 rounded border border-dark-border bg-dark-bg text-sm font-mono",children:a.toLocaleString()})]}),t.jsxs("button",{onClick:()=>it(e),className:"inline-flex items-center justify-center gap-1.5 px-3 py-2 rounded border border-dark-border text-sm text-dark-muted hover:bg-dark-hover",children:[t.jsx($t,{size:13}),"重置"]})]})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[!e.isGlobalDefault&&e.enabled!==!1&&t.jsx("button",{onClick:async()=>{try{await p.models.setDefaults({global:`${e.provider}:${e.id}`}),await b()}catch(l){j(l instanceof Error?l.message:"设置全局默认失败")}},className:"px-2 py-1 rounded text-[10px] border border-accent-green/30 text-accent-green hover:bg-accent-green/10",title:"设为全局默认",children:"全局默认"}),!e.isPlanDefault&&e.enabled!==!1&&t.jsx("button",{onClick:async()=>{try{await p.models.setDefaults({plan:`${e.provider}:${e.id}`}),await b()}catch(l){j(l instanceof Error?l.message:"设置 Plan 默认失败")}},className:"px-2 py-1 rounded text-[10px] border border-accent-blue/30 text-accent-blue hover:bg-accent-blue/10",title:"设为 Plan 默认",children:"Plan 默认"}),!e.isActDefault&&e.enabled!==!1&&t.jsx("button",{onClick:async()=>{try{await p.models.setDefaults({act:`${e.provider}:${e.id}`}),await b()}catch(l){j(l instanceof Error?l.message:"设置 Act 默认失败")}},className:"px-2 py-1 rounded text-[10px] border border-accent-yellow/30 text-accent-yellow hover:bg-accent-yellow/10",title:"设为 Act 默认",children:"Act 默认"}),!e.isGoalDefault&&e.enabled!==!1&&t.jsx("button",{onClick:async()=>{try{await p.models.setDefaults({goal:`${e.provider}:${e.id}`}),await b()}catch(l){j(l instanceof Error?l.message:"设置 Goal 默认失败")}},className:"px-2 py-1 rounded text-[10px] border border-accent-purple/30 text-accent-purple hover:bg-accent-purple/10",title:"设为 Goal 默认",children:"Goal 默认"}),t.jsx("button",{onClick:()=>wt(e),className:"p-1.5 rounded hover:bg-accent-blue/10 text-dark-muted hover:text-accent-blue",title:"编辑模型",children:t.jsx(Et,{size:13})}),t.jsx("button",{onClick:()=>Nt(e.provider,e.id),className:"p-1.5 rounded hover:bg-accent-red/10 text-dark-muted hover:text-accent-red",title:"删除模型",children:t.jsx(tt,{size:13})}),t.jsx("button",{onClick:()=>kt(e.id),disabled:v===e.id,className:"p-1.5 rounded hover:bg-dark-hover disabled:opacity-50",title:"刷新",children:t.jsx(oe,{size:13,className:v===e.id?"animate-spin":""})}),t.jsx("button",{onClick:()=>jt(e.id),className:`px-2 py-0.5 rounded text-xs transition-colors ${e.status==="online"?"bg-accent-red/20 text-accent-red hover:bg-accent-red/30":"bg-accent-green/20 text-accent-green hover:bg-accent-green/30"}`,children:e.status==="online"?"禁用":"启用"})]})]})},D(e))}),f.length===0&&t.jsxs("div",{className:"text-center text-dark-muted py-6",children:[t.jsx(zt,{size:36,className:"mx-auto mb-2 opacity-40"}),t.jsx("p",{className:"text-sm",children:"暂无模型,请先在上方配置 Provider"})]})]})]}),t.jsx(ye,{isOpen:ot,onClose:()=>{E(!1),F("select"),z(null)},title:Pe==="select"?"选择 Provider":(R==null?void 0:R.name)||"Provider 配置",size:"xl",children:Pe==="select"?t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[ee.filter(e=>e.key!=="custom").map(e=>t.jsxs("button",{onClick:()=>Le(e),className:"text-left p-3 rounded-lg border border-dark-border bg-dark-bg hover:border-accent-blue transition-colors",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx(ve,{size:14,className:"text-accent-blue"}),t.jsx("span",{className:"text-sm font-medium",children:e.name})]}),t.jsx("div",{className:"text-xs text-dark-muted",children:e.defaultModel})]},e.key)),t.jsxs("button",{onClick:be,className:"text-left p-3 rounded-lg border border-dashed border-dark-border bg-dark-bg hover:border-accent-blue transition-colors",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx(Lt,{size:14,className:"text-accent-blue"}),t.jsx("span",{className:"text-sm font-medium",children:"自定义 Provider"})]}),t.jsx("div",{className:"text-xs text-dark-muted",children:"手动填写 Provider 名称、Base URL 和模型 ID"})]})]})}):t.jsxs("div",{className:"space-y-3",children:[g==="custom"&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:"Provider 名称 *"}),t.jsx("input",{value:i.providerKey,onChange:e=>w(s=>({...s,providerKey:e.target.value})),className:"w-full px-3 py-2 bg-dark-bg border border-dark-border rounded text-sm focus:outline-none focus:border-accent-blue",placeholder:"例如: my-provider"})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm text-dark-muted mb-1",children:["API Keys",(Ge=(Be=n==null?void 0:n.providers)==null?void 0:Be[g==="custom"?i.providerKey.trim():g||""])!=null&&Ge.hasApiKey?"":" *",t.jsxs("span",{className:"text-dark-muted/60 text-xs",children:["(每行一把,可多把",(Ye=(He=n==null?void 0:n.providers)==null?void 0:He[g==="custom"?i.providerKey.trim():g||""])!=null&&Ye.hasApiKey?",留空则保留已保存的 Key":"",")"]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("textarea",{rows:3,value:i.apiKeys,onChange:e=>w(s=>({...s,apiKeys:e.target.value})),className:"w-full px-3 py-2 pr-10 bg-dark-bg border border-dark-border rounded text-sm focus:outline-none focus:border-accent-blue resize-y custom-scrollbar",placeholder:`每行输入一把 API Key
2
- 支持多把(运行时取第一把,其余备用)`}),t.jsx("button",{onClick:()=>xe(e=>!e),className:"absolute right-2 top-2 text-dark-muted hover:text-white",children:ct?t.jsx(Rt,{size:14}):t.jsx(Ut,{size:14})})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:"模型 ID"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{value:i.modelIds,onChange:e=>{const s=e.target.value;w(a=>({...a,modelIds:s})),T(()=>{const a=new Set;for(const l of s.split(",")){const c=l.trim().split("|")[0].trim();c&&X.some(o=>o.id===c)&&a.add(c)}return a})},className:"flex-1 px-3 py-2 bg-dark-bg border border-dark-border rounded text-sm focus:outline-none focus:border-accent-blue",placeholder:(R==null?void 0:R.defaultModel)||"gpt-4o, deepseek-chat (格式: id|名称|别名)"}),t.jsxs("button",{onClick:ut,disabled:pe||!i.baseUrl,className:"inline-flex items-center gap-1 px-3 py-2 rounded text-sm border border-accent-blue/30 text-accent-blue hover:bg-accent-blue/10 disabled:opacity-50 whitespace-nowrap",title:"从 API 获取模型列表",children:[pe?t.jsx(oe,{size:13,className:"animate-spin"}):t.jsx(Ft,{size:13}),pe?"获取中...":"获取模型列表"]}),t.jsxs("button",{onClick:gt,className:"inline-flex items-center gap-1 px-3 py-2 rounded text-sm border border-accent-green/30 text-accent-green hover:bg-accent-green/10 whitespace-nowrap",title:"搜索 models.dev 全厂商模型目录(含 context/价格/能力元数据)",children:[t.jsx(G,{size:13}),"目录搜索"]})]}),$e&&t.jsx("div",{className:"mt-1 text-xs text-accent-red",children:$e}),X.length>0&&t.jsxs("div",{className:"mt-2 border border-dark-border rounded-lg bg-dark-bg p-2",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("span",{className:"text-xs text-dark-muted",children:["已获取 ",t.jsx("strong",{className:"text-dark-text",children:X.length})," 个模型, 已选 ",t.jsx("strong",{className:"text-accent-blue",children:J.size})," 个",t.jsx("span",{className:"text-accent-blue/70",children:"(勾选即自动应用到「模型 ID」输入框)"})]}),t.jsx("button",{onClick:()=>{_([]),T(new Set)},className:"px-2 py-0.5 text-[10px] border border-dark-border rounded hover:bg-dark-hover",children:"关闭"})]}),t.jsxs("div",{className:"relative mb-2",children:[t.jsx(G,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-dark-muted"}),t.jsx("input",{value:Z,onChange:e=>me(e.target.value),className:"w-full pl-7 pr-2 py-1 text-xs bg-dark-bg border border-dark-border rounded focus:outline-none focus:border-accent-blue",placeholder:"搜索模型..."})]}),t.jsx("div",{className:"max-h-48 overflow-y-auto custom-scrollbar grid grid-cols-2 sm:grid-cols-3 gap-1",children:X.filter(e=>!Z||e.id.toLowerCase().includes(Z.toLowerCase())||e.name.toLowerCase().includes(Z.toLowerCase())).map(e=>{const s=J.has(e.id);return t.jsxs("div",{role:"checkbox","aria-checked":s,tabIndex:-1,onMouseDown:a=>a.preventDefault(),onClick:()=>xt(e.id),className:`flex items-center gap-1.5 px-2 py-1 rounded cursor-pointer text-xs transition-colors select-none ${s?"bg-accent-blue/20 text-accent-blue border border-accent-blue/30":"hover:bg-dark-hover border border-transparent"}`,children:[s?t.jsx(ve,{size:10}):t.jsx("div",{className:"w-2.5 h-2.5 rounded border border-dark-border"}),t.jsx("span",{className:"truncate",children:e.id})]},e.id)})})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:"Base URL"}),t.jsx("input",{value:i.baseUrl,onChange:e=>w(s=>({...s,baseUrl:e.target.value})),className:"w-full px-3 py-2 bg-dark-bg border border-dark-border rounded text-sm focus:outline-none focus:border-accent-blue",placeholder:"https://api.example.com/v1"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:"API 类型"}),t.jsxs("select",{value:i.apiType,onChange:e=>w(s=>({...s,apiType:e.target.value})),className:"w-full px-3 py-2 bg-dark-bg border border-dark-border rounded text-sm focus:outline-none focus:border-accent-blue",children:[t.jsx("option",{value:"",children:"自动探测(推荐)"}),Yt.map(e=>t.jsx("option",{value:e,children:qt[e]},e))]}),t.jsx("div",{className:"text-[11px] text-dark-muted/60 mt-1",children:"默认 OpenAI 兼容;Anthropic/Claude 类网关(URL 含 /anthropic、/coding)自动切 Anthropic Messages。"})]}),t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:i.setDefault,onChange:e=>w(s=>({...s,setDefault:e.target.checked})),className:"accent-accent-blue"}),t.jsx("span",{className:"text-sm text-dark-muted",children:"设为默认 Provider"})]}),Ke&&t.jsx("div",{className:"text-sm text-accent-red",children:Ke}),t.jsxs("div",{className:"flex justify-between gap-2 pt-2",children:[t.jsx("div",{children:g&&g!=="custom"&&((Ve=(qe=n==null?void 0:n.providers)==null?void 0:qe[g])==null?void 0:Ve.hasApiKey)&&t.jsx("button",{onClick:async()=>{if(confirm(`确定要删除 "${g}" 的配置吗?`))try{await p.config.provider.delete(g),E(!1),z(null),await A(),await b()}catch{}},className:"px-4 py-2 rounded border border-accent-red/30 text-accent-red hover:bg-accent-red/10 transition-colors text-sm",children:"删除 Provider"})}),t.jsx("button",{onClick:()=>{F("select"),z(null),E(!1)},className:"px-4 py-2 rounded border border-dark-border hover:bg-dark-hover transition-colors text-sm",children:"取消"}),t.jsx("button",{onClick:Ct,disabled:Ie,className:"px-4 py-2 bg-accent-blue text-white rounded hover:bg-accent-blue/80 transition-colors text-sm disabled:opacity-50",children:Ie?"保存中...":"保存"})]})]})}),t.jsx(ye,{isOpen:pt,onClose:()=>Re(!1),title:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(G,{size:15,className:"text-accent-green"}),"models.dev 模型目录搜索"]}),size:"2xl",children:t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("div",{className:"relative flex-1",children:[t.jsx(G,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-dark-muted"}),t.jsx("input",{value:he,onChange:e=>yt(e.target.value),className:"w-full pl-9 pr-3 py-2 bg-dark-bg border border-dark-border rounded text-sm focus:outline-none focus:border-accent-green",placeholder:"搜索全厂商模型,如 gpt-4o / deepseek / claude ...(匹配模型 id / 名称 / 厂商)",autoFocus:!0})]}),t.jsxs("label",{className:"inline-flex items-center gap-1.5 text-xs text-dark-muted whitespace-nowrap cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:re,onChange:e=>{const s=e.target.checked;ht(s),B(he,{reason:ae,tool:s})},className:"accent-accent-green"}),"仅工具调用"]}),t.jsxs("label",{className:"inline-flex items-center gap-1.5 text-xs text-dark-muted whitespace-nowrap cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:ae,onChange:e=>{const s=e.target.checked;bt(s),B(he,{reason:s,tool:re})},className:"accent-accent-green"}),"仅推理模型"]})]}),_e&&t.jsx("div",{className:"text-xs text-accent-red bg-accent-red/10 p-2 rounded",children:_e}),mt?t.jsxs("div",{className:"flex items-center justify-center py-10 text-dark-muted",children:[t.jsx(oe,{size:18,className:"animate-spin mr-2"})," 搜索中..."]}):t.jsx("div",{className:"max-h-96 overflow-y-auto custom-scrollbar border border-dark-border rounded-lg divide-y divide-dark-border",children:Fe.length===0?t.jsx("div",{className:"py-10 text-center text-dark-muted text-sm",children:"无匹配模型,换个关键词试试"}):Fe.map(e=>{var s,a,l;return t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 hover:bg-dark-hover",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium text-dark-text truncate",children:e.model.name||e.model.id}),t.jsx("code",{className:"text-[10px] px-1.5 py-0.5 bg-dark-bg border border-dark-border rounded text-dark-muted truncate",children:e.model.id}),e.model.reasoning&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-accent-yellow/10 text-accent-yellow rounded",children:"推理"}),e.model.tool_call&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-accent-blue/10 text-accent-blue rounded",children:"工具"}),e.model.attachment&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-accent-green/10 text-accent-green rounded",children:"多模态"})]}),t.jsxs("div",{className:"text-[11px] text-dark-muted mt-0.5",children:[e.providerName,(s=e.model.limit)!=null&&s.context?` · 上下文 ${(e.model.limit.context/1e3).toFixed(0)}K`:"",(a=e.model.limit)!=null&&a.output?` · 输出 ${(e.model.limit.output/1e3).toFixed(0)}K`:"",((l=e.model.cost)==null?void 0:l.input)!==void 0?` · $${e.model.cost.input}/M in / $${e.model.cost.output}/M out`:""]})]}),t.jsxs("button",{onClick:()=>ft(e),className:"shrink-0 inline-flex items-center gap-1 px-2.5 py-1 text-xs border border-accent-green/30 text-accent-green rounded hover:bg-accent-green/10 whitespace-nowrap",title:"添加到模型 ID 输入框",children:[t.jsx(fe,{size:12})," 添加"]})]},`${e.providerId}:${e.model.id}`)})}),t.jsx("div",{className:"text-[11px] text-dark-muted/60",children:"数据源:models.dev 模型目录(内置快照,离线可用)。点击「添加」将模型 ID 写入「模型 ID」输入框。"})]})}),t.jsx(ye,{isOpen:lt,onClose:()=>{q(!1),V(null)},title:"编辑模型",size:"lg",children:t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:"提供商名称 *"}),t.jsx("input",{value:N.provider,onChange:e=>S(s=>({...s,provider:e.target.value})),disabled:!!k,className:"w-full px-3 py-2 bg-dark-bg border border-dark-border rounded text-sm focus:outline-none focus:border-accent-blue disabled:opacity-50",placeholder:"例如: openai, deepseek"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:"模型 ID *"}),t.jsx("input",{value:N.modelId,onChange:e=>S(s=>({...s,modelId:e.target.value})),disabled:!!k,className:"w-full px-3 py-2 bg-dark-bg border border-dark-border rounded text-sm focus:outline-none focus:border-accent-blue disabled:opacity-50",placeholder:"例如: gpt-4o, deepseek-chat"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:"模型名称"}),t.jsx("input",{value:N.modelName,onChange:e=>S(s=>({...s,modelName:e.target.value})),className:"w-full px-3 py-2 bg-dark-bg border border-dark-border rounded text-sm focus:outline-none focus:border-accent-blue",placeholder:"留空则使用模型 ID"})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm text-dark-muted mb-1",children:["API Key",k&&((We=(Qe=n==null?void 0:n.providers)==null?void 0:Qe[k.provider])==null?void 0:We.hasApiKey)&&t.jsx("span",{className:"text-accent-green/80 text-xs ml-1",children:"已配置(留空则保持不变)"})]}),t.jsx("input",{type:"password",value:N.apiKey,onChange:e=>S(s=>({...s,apiKey:e.target.value})),className:"w-full px-3 py-2 bg-dark-bg border border-dark-border rounded text-sm focus:outline-none focus:border-accent-blue",placeholder:k&&((Je=(Xe=n==null?void 0:n.providers)==null?void 0:Xe[k.provider])!=null&&Je.hasApiKey)?"留空保持当前 API Key":"输入新的 API Key"})]}),Ce&&t.jsx("div",{className:"text-sm text-accent-red bg-accent-red/10 p-2 rounded",children:Ce}),t.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[t.jsx("button",{onClick:()=>{q(!1),V(null),S(je)},className:"px-4 py-2 rounded border border-dark-border hover:bg-dark-hover transition-colors text-sm",children:"取消"}),t.jsx("button",{onClick:It,disabled:Ne,className:"px-4 py-2 bg-accent-blue text-white rounded hover:bg-accent-blue/80 transition-colors text-sm disabled:opacity-50",children:Ne?"保存中...":"保存"})]})]})})]})}function ce({title:y,value:m,color:I}){const f={green:"bg-accent-green/10 text-accent-green",yellow:"bg-accent-yellow/10 text-accent-yellow",red:"bg-accent-red/10 text-accent-red",blue:"bg-accent-blue/10 text-accent-blue"};return t.jsxs("div",{className:`${f[I]} rounded-lg p-3`,children:[t.jsx("div",{className:"text-xs opacity-70",children:y}),t.jsx("div",{className:"text-xl font-semibold",children:m})]})}function de({label:y,value:m}){return t.jsxs("div",{children:[t.jsx("div",{className:"text-dark-muted",children:y}),t.jsx("div",{children:m})]})}function rt({label:y,value:m,onChange:I}){return t.jsxs("div",{children:[t.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:y}),t.jsx("input",{type:"number",min:"0",value:m,onChange:f=>I(parseInt(f.target.value,10)||0),className:"w-full px-3 py-2 rounded border border-dark-border bg-dark-bg text-sm focus:outline-none focus:border-accent-blue"})]})}export{ts as ModelsView,ts as default};
@@ -1 +0,0 @@
1
- import{j as t}from"./markdown-BASfeONY.js";import{a as s,aj as xe,h as ue,aa as me,X as Z,_ as be,aA as J,bb as pe,b8 as he,aq as ge,D as W,y as ke,K as ve}from"./icons-BXecaLRH.js";import{c as fe,g as u,C as je}from"./index-CcPIw0Dj.js";import"./react-vendor-7At16BnY.js";import"./state-D4zgKwQs.js";import"./panels-Bod3sKnK.js";const I=12,ye="other";function Ne(d){return d==="wired"?"bg-emerald-500/15 text-emerald-400 border-emerald-500/30":d==="pending"||d==="pending_wiring"?"bg-amber-500/15 text-amber-400 border-amber-500/30":"bg-dark-hover text-dark-muted border-dark-border"}function ee(d){var n;return((n=d.category)==null?void 0:n.trim())||ye}function Ce(d,n){const v=n.trim().toLowerCase();return v?[d.id,d.name,d.description,d.category,...d.tags??[]].filter(w=>typeof w=="string").join(" ").toLowerCase().includes(v):!0}function Ae(){const{t:d}=fe(),[n,v]=s.useState("installed"),[m,w]=s.useState([]),[R,te]=s.useState([]),[T,re]=s.useState(null),[f,L]=s.useState(!0),[S,O]=s.useState(null),[i,U]=s.useState(null),[$,V]=s.useState(null),[j,_]=s.useState(null),[y,P]=s.useState(null),[q,B]=s.useState(null),[b,D]=s.useState(""),[o,se]=s.useState(null),[c,z]=s.useState(1),x=s.useCallback((e,r)=>{_({kind:e,text:r}),window.setTimeout(()=>_(null),4e3)},[]),p=s.useCallback(async()=>{L(!0),O(null);const[e,r]=await Promise.all([u.get("/api/plugins"),u.get("/api/plugins/market")]);e.success&&e.data?(w(e.data.plugins),re(e.data.schemaVersion??null)):O(e.error??"Failed to load plugins"),r.success&&r.data&&te(r.data.plugins),L(!1)},[]);s.useEffect(()=>{p()},[p]);const M=s.useMemo(()=>m.filter(e=>e.installable!==!0),[m]),h=s.useMemo(()=>[...m.filter(e=>e.installable===!0),...R.filter(e=>!m.some(r=>r.id===e.id||r.marketId===e.id))],[m,R]),N=s.useCallback(e=>e.filter(r=>o&&ee(r)!==o?!1:Ce(r,b)),[o,b]),g=s.useMemo(()=>N(M),[N,M]),k=s.useMemo(()=>N(h),[N,h]),F=s.useMemo(()=>{const e=new Set;for(const r of h)e.add(ee(r));return["all",...Array.from(e).sort()]},[h]),G=e=>Math.max(1,Math.ceil(e/I)),H=(e,r)=>e.slice((r-1)*I,r*I),A=G(g.length),E=G(k.length),ae=s.useMemo(()=>H(g,Math.min(c,A)),[g,c,A]),de=s.useMemo(()=>H(k,Math.min(c,E)),[k,c,E]);s.useEffect(()=>{z(1)},[n,b,o]);const ne=b.trim().length>0||o!==null,C=s.useCallback(async(e,r,l)=>{U(e),V(r);try{const a=await l();a&&a.success===!1?x("err",String(a.error??"Request failed")):(x("ok",`${r} ${e} ✓`),await p())}catch(a){x("err",a instanceof Error?a.message:String(a))}finally{U(null),V(null)}},[p,x]),K=(e,r)=>C(e,r?"installed+activated":"installed",()=>u.post("/api/plugins/install",{id:e,activate:r})),le=e=>C(e,"activated",()=>u.post(`/api/plugins/${encodeURIComponent(e)}/activate`)),ie=e=>C(e,"deactivated",()=>u.post(`/api/plugins/${encodeURIComponent(e)}/deactivate`)),oe=e=>C(e,"uninstalled",()=>u.delete(`/api/plugins/${encodeURIComponent(e)}`)),ce=async e=>{B(e);try{const r=await u.post(`/api/plugins/l2/provider/${encodeURIComponent(e)}`);r.success&&r.data?(x("ok",`Provider ${r.data.applied} applied to config ✓`),await p()):x("err",r.error??"Apply failed")}catch(r){x("err",r instanceof Error?r.message:String(r))}finally{B(null)}},Q=e=>{const r=e==="bundled"?"bg-blue-500/15 text-blue-400 border-blue-500/30":e==="npm"?"bg-purple-500/15 text-purple-400 border-purple-500/30":e==="local"?"bg-cyan-500/15 text-cyan-400 border-cyan-500/30":"bg-dark-hover text-dark-muted border-dark-border";return t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[11px] border ${r}`,children:e})},X=(e,r)=>r>1?t.jsxs("div",{className:"flex items-center justify-center gap-3 pt-3 pb-1 select-none",children:[t.jsxs("button",{onClick:()=>z(l=>Math.max(1,l-1)),disabled:c<=1,className:"flex items-center gap-1 px-2 py-1 rounded border border-dark-border bg-dark-hover text-dark-muted text-[11px] hover:text-dark-text disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:[t.jsx(ke,{size:12})," 上一页"]}),t.jsxs("span",{className:"text-[11px] text-dark-muted",children:["第 ",Math.min(c,r)," / ",r," 页 · 共 ",e," 条"]}),t.jsxs("button",{onClick:()=>z(l=>Math.min(r,l+1)),disabled:c>=r,className:"flex items-center gap-1 px-2 py-1 rounded border border-dark-border bg-dark-hover text-dark-muted text-[11px] hover:text-dark-text disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:["下一页 ",t.jsx(ve,{size:12})]})]}):null,Y=e=>t.jsx("div",{className:"mt-8 text-center text-[12px] text-dark-muted",children:ne?"无匹配插件":e});return t.jsxs("div",{className:"h-full flex flex-col min-h-0 bg-dark-bg",children:[t.jsxs("div",{className:"h-11 flex items-center gap-2 px-3 border-b border-dark-border bg-dark-bg shrink-0 select-none",children:[t.jsx(xe,{size:15,className:"text-accent-blue"}),t.jsx("span",{className:"truncate text-[13px] font-medium text-dark-text",children:d("nav.plugins")}),T!==null&&t.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] bg-dark-hover text-dark-muted border border-dark-border",children:["schema v",T]}),t.jsx("div",{className:"flex-1"}),t.jsx("button",{onClick:()=>void p(),className:"p-1.5 rounded hover:bg-dark-hover text-dark-muted hover:text-dark-text transition-colors",title:"Refresh",children:t.jsx(ue,{size:14,className:f?"animate-spin":""})})]}),t.jsx("div",{className:"flex items-center gap-1 px-3 pt-2 shrink-0",children:["installed","available"].map(e=>t.jsx("button",{onClick:()=>v(e),className:`px-3 py-1.5 rounded-t text-[12px] transition-colors ${n===e?"bg-dark-surface text-accent-blue border border-b-0 border-dark-border":"text-dark-muted hover:text-dark-text"}`,children:e==="installed"?`已安装 (${M.length})`:`可安装 (${h.length})`},e))}),t.jsxs("div",{className:"shrink-0 px-3 pt-2 pb-1 space-y-2 bg-dark-bg",children:[t.jsxs("div",{className:"relative",children:[t.jsx(me,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-dark-muted pointer-events-none"}),t.jsx("input",{value:b,onChange:e=>D(e.target.value),placeholder:"搜索插件(名称 / id / 描述 / 标签)",className:"w-full pl-8 pr-8 py-1.5 rounded bg-dark-hover border border-dark-border text-[12px] text-dark-text placeholder-dark-muted outline-none focus:border-accent-blue/50 transition-colors"}),b&&t.jsx("button",{onClick:()=>D(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-0.5 rounded text-dark-muted hover:text-dark-text transition-colors",title:"清除",children:t.jsx(Z,{size:12})})]}),n==="available"&&F.length>2&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:F.map(e=>t.jsx("button",{onClick:()=>se(e==="all"?null:e),className:`px-2 py-0.5 rounded-full text-[11px] border transition-colors ${e==="all"&&o===null||o===e?"bg-accent-blue/20 text-accent-blue border-accent-blue/40":"bg-dark-hover text-dark-muted border-dark-border hover:text-dark-text"}`,children:e==="all"?"全部":e},e))})]}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-3 pb-4",children:[S&&t.jsxs("div",{className:"mt-3 flex items-center gap-2 px-3 py-2 rounded bg-red-500/10 border border-red-500/30 text-red-400 text-[12px]",children:[t.jsx(be,{size:14})," ",S]}),f&&!S&&t.jsx("div",{className:"mt-10 flex justify-center",children:t.jsx("div",{className:"w-5 h-5 border-2 border-accent-blue border-t-transparent rounded-full animate-spin"})}),!f&&n==="installed"&&t.jsxs("div",{className:"mt-3 space-y-2",children:[g.length===0&&Y("暂无插件 — 到「可安装」页从市场安装"),ae.map(e=>{const r=e.l2??[],l=e.status==="active";return t.jsxs("div",{className:"rounded-lg border border-dark-border bg-dark-surface p-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-[13px] font-medium text-dark-text truncate",children:e.name||e.id}),e.version&&t.jsx("span",{className:"text-[11px] text-dark-muted shrink-0",children:e.version}),Q(e.source),t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[11px] border shrink-0 ${l?"bg-emerald-500/15 text-emerald-400 border-emerald-500/30":"bg-dark-hover text-dark-muted border-dark-border"}`,children:l?"active":"installed"}),e.httpMounted&&t.jsx("span",{className:"px-1.5 py-0.5 rounded text-[11px] bg-emerald-500/15 text-emerald-400 border border-emerald-500/30 shrink-0",children:"http mounted"}),t.jsx("div",{className:"flex-1"}),t.jsx("span",{className:"text-[11px] text-dark-muted font-mono shrink-0",children:e.id})]}),e.description&&t.jsx("p",{className:"mt-1 text-[12px] text-dark-muted",children:e.description}),r.length>0&&t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[r.map(a=>t.jsxs("span",{title:a.note||a.id,className:`px-1.5 py-0.5 rounded text-[11px] border cursor-help ${Ne(a.status)}`,children:[a.kind," · ",a.status,a.status==="wired"&&t.jsx(J,{size:10,className:"inline ml-0.5"})]},`${a.kind}-${a.id}`)),r.filter(a=>a.kind==="provider"&&a.status==="wired").map(a=>t.jsx("button",{disabled:q===a.id,onClick:()=>void ce(a.id),className:"px-1.5 py-0.5 rounded text-[11px] border border-accent-blue/40 text-accent-blue hover:bg-accent-blue/10 disabled:opacity-50 transition-colors",title:"把插件 provider preset 写入 ProviderConfigStore(用户授权)",children:q===a.id?"applying…":"apply provider"},`apply-${a.id}`))]}),t.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[l?t.jsxs("button",{onClick:()=>void ie(e.id),disabled:i===e.id,className:"flex items-center gap-1 px-2 py-1 rounded bg-amber-500/15 border border-amber-500/30 text-amber-400 text-[11px] hover:bg-amber-500/25 disabled:opacity-50 transition-colors",children:[t.jsx(pe,{size:11})," ",i===e.id?`${$}…`:"停用"]}):t.jsxs("button",{onClick:()=>void le(e.id),disabled:i===e.id,className:"flex items-center gap-1 px-2 py-1 rounded bg-emerald-500/15 border border-emerald-500/30 text-emerald-400 text-[11px] hover:bg-emerald-500/25 disabled:opacity-50 transition-colors",children:[t.jsx(he,{size:11})," ",i===e.id?`${$}…`:"激活"]}),t.jsxs("button",{onClick:()=>P(e.id),disabled:i===e.id,className:"flex items-center gap-1 px-2 py-1 rounded bg-dark-hover border border-dark-border text-dark-muted text-[11px] hover:text-red-400 hover:border-red-500/40 disabled:opacity-50 transition-colors",children:[t.jsx(ge,{size:11})," 卸载"]})]})]},e.id)}),X(g.length,A)]}),!f&&n==="available"&&t.jsxs("div",{className:"mt-3 space-y-2",children:[k.length===0&&Y("市场暂无可用插件"),de.map(e=>t.jsxs("div",{className:"rounded-lg border border-dark-border bg-dark-surface p-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-[13px] font-medium text-dark-text truncate",children:e.name||e.id}),e.version&&t.jsx("span",{className:"text-[11px] text-dark-muted shrink-0",children:e.version}),Q(e.source),e.category&&t.jsx("span",{className:"px-1.5 py-0.5 rounded text-[11px] bg-dark-hover text-dark-muted border border-dark-border shrink-0",children:e.category}),t.jsx("div",{className:"flex-1"}),t.jsx("span",{className:"text-[11px] text-dark-muted font-mono shrink-0",children:e.id})]}),e.description&&t.jsx("p",{className:"mt-1 text-[12px] text-dark-muted",children:e.description}),t.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[t.jsxs("button",{onClick:()=>void K(e.id,!0),disabled:i===e.id,className:"flex items-center gap-1 px-2 py-1 rounded bg-accent-blue/20 border border-accent-blue/40 text-accent-blue text-[11px] hover:bg-accent-blue/30 disabled:opacity-50 transition-colors",children:[t.jsx(W,{size:11})," ",i===e.id?`${$}…`:"安装并激活"]}),t.jsxs("button",{onClick:()=>void K(e.id,!1),disabled:i===e.id,className:"flex items-center gap-1 px-2 py-1 rounded bg-dark-hover border border-dark-border text-dark-muted text-[11px] hover:text-dark-text disabled:opacity-50 transition-colors",children:[t.jsx(W,{size:11})," 仅安装"]})]})]},e.id)),X(k.length,E)]})]}),j&&t.jsxs("div",{className:`fixed bottom-4 right-4 z-50 flex items-center gap-2 px-3 py-2 rounded-lg border text-[12px] shadow-lg ${j.kind==="ok"?"bg-emerald-500/15 border-emerald-500/30 text-emerald-400":"bg-red-500/15 border-red-500/30 text-red-400"}`,children:[j.kind==="ok"?t.jsx(J,{size:13}):t.jsx(Z,{size:13})," ",j.text]}),t.jsx(je,{isOpen:y!==null,title:"卸载插件",message:`确定要卸载 ${y} 吗?插件文件将被删除(bundled 除外)。`,onConfirm:()=>{y&&oe(y),P(null)},onClose:()=>P(null)})]})}export{Ae as PluginsView};