@deepseekcode/cli 1.0.29 → 1.0.31

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 (33) hide show
  1. package/README.md +159 -99
  2. package/dist/cli.js +1504 -1477
  3. package/package.json +2 -2
  4. package/web/dist/assets/AutomationView-InguWZFs.js +1 -0
  5. package/web/dist/assets/{ChannelConfigView-DG4_15oh.js → ChannelConfigView-egYtlZj-.js} +3 -3
  6. package/web/dist/assets/ConnectorsView-5Ii67NnU.js +1 -0
  7. package/web/dist/assets/{FileTreeView-DPA2dhx_.js → FileTreeView-BT45_XVy.js} +1 -1
  8. package/web/dist/assets/{HookConfigView-BJnvqm3N.js → HookConfigView-DYF8WoqD.js} +1 -1
  9. package/web/dist/assets/ModelsView-C_hShQeY.js +1 -0
  10. package/web/dist/assets/{PluginsView-DxIWxsB-.js → PluginsView-CFAStd5I.js} +1 -1
  11. package/web/dist/assets/SessionGrid-BGpz0-op.css +1 -0
  12. package/web/dist/assets/SessionGrid-aZvfkGsH.js +42 -0
  13. package/web/dist/assets/SettingsPanel-DpXhjWLN.js +4 -0
  14. package/web/dist/assets/{SkillsView-Cpr_kpor.js → SkillsView-DqLfpF41.js} +1 -1
  15. package/web/dist/assets/{TemplatesTab-Cvyxqayr.js → TemplatesTab-CQy-UXLH.js} +1 -1
  16. package/web/dist/assets/{TerminalView-DTN8hmcS.js → TerminalView-DFjhMeyT.js} +1 -1
  17. package/web/dist/assets/{ThreeScene-CukEnQe-.js → ThreeScene-Zhjwe9nT.js} +1 -1
  18. package/web/dist/assets/{ToolsView-D_FET-NB.js → ToolsView-D3HqxE7K.js} +1 -1
  19. package/web/dist/assets/{icons-Cu8fYt4q.js → icons-Di-qMB6n.js} +124 -109
  20. package/web/dist/assets/index-BbLAiXis.css +1 -0
  21. package/web/dist/assets/index-CWqFf5l2.js +484 -0
  22. package/web/dist/assets/{markdown-Bym7wmT0.js → markdown-D-c9V8Xq.js} +1 -1
  23. package/web/dist/assets/{panels-BEKHl5l-.js → panels-CpHTincc.js} +1 -1
  24. package/web/dist/assets/{react-vendor-D76F8wnc.js → react-vendor-DU8XgZt2.js} +1 -1
  25. package/web/dist/assets/{state-CZakZ3-m.js → state-D2vcUGVk.js} +1 -1
  26. package/web/dist/index.html +7 -7
  27. package/web/dist/assets/AutomationView-BJSLQ2Ka.js +0 -1
  28. package/web/dist/assets/ConnectorsView-ByedXSa-.js +0 -1
  29. package/web/dist/assets/ModelsView-BBbmRxwR.js +0 -1
  30. package/web/dist/assets/SessionGrid-D-1XpCZg.js +0 -39
  31. package/web/dist/assets/SettingsPanel-ivpxRR6O.js +0 -4
  32. package/web/dist/assets/index-C7rIgpwO.js +0 -484
  33. package/web/dist/assets/index-CYAcRfnc.css +0 -1
@@ -1,4 +1,4 @@
1
- import{g as Dt,c as Yn}from"./icons-Cu8fYt4q.js";var nn={exports:{}},Re={};/**
1
+ import{g as Dt,c as Yn}from"./icons-Di-qMB6n.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-Cu8fYt4q.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-Di-qMB6n.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-Cu8fYt4q.js";var y={exports:{}},n={};/**
1
+ import{r as O}from"./icons-Di-qMB6n.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-Cu8fYt4q.js";var _={exports:{}},g={};/**
1
+ import{r as A,g as U,W as F}from"./icons-Di-qMB6n.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-C7rIgpwO.js"></script>
16
- <link rel="modulepreload" crossorigin href="/assets/icons-Cu8fYt4q.js">
17
- <link rel="modulepreload" crossorigin href="/assets/markdown-Bym7wmT0.js">
18
- <link rel="modulepreload" crossorigin href="/assets/react-vendor-D76F8wnc.js">
19
- <link rel="modulepreload" crossorigin href="/assets/state-CZakZ3-m.js">
20
- <link rel="modulepreload" crossorigin href="/assets/panels-BEKHl5l-.js">
21
- <link rel="stylesheet" crossorigin href="/assets/index-CYAcRfnc.css">
15
+ <script type="module" crossorigin src="/assets/index-CWqFf5l2.js"></script>
16
+ <link rel="modulepreload" crossorigin href="/assets/icons-Di-qMB6n.js">
17
+ <link rel="modulepreload" crossorigin href="/assets/markdown-D-c9V8Xq.js">
18
+ <link rel="modulepreload" crossorigin href="/assets/react-vendor-DU8XgZt2.js">
19
+ <link rel="modulepreload" crossorigin href="/assets/state-D2vcUGVk.js">
20
+ <link rel="modulepreload" crossorigin href="/assets/panels-CpHTincc.js">
21
+ <link rel="stylesheet" crossorigin href="/assets/index-BbLAiXis.css">
22
22
  </head>
23
23
  <body>
24
24
  <div id="root"></div>
@@ -1 +0,0 @@
1
- import{j as e}from"./markdown-Bym7wmT0.js";import{a as n,ak as v,h as $,z as D,$ as O,bf as I,f as L,aq as J,aO as U,X}from"./icons-Cu8fYt4q.js";import{u as q,X as B}from"./index-C7rIgpwO.js";import"./react-vendor-D76F8wnc.js";import"./state-CZakZ3-m.js";import"./panels-BEKHl5l-.js";function Q(){const{t:a}=q(),{automations:r,runsByAutomation:d,fetchAutomations:o,createAutomation:N,deleteAutomation:y,toggleAutomation:w,runAutomation:C,fetchRuns:A,error:l}=B(),[S,x]=n.useState(!1),[m,z]=n.useState(null),[u,p]=n.useState(""),[h,b]=n.useState(""),[i,g]=n.useState("0 9 * * *"),[f,j]=n.useState("");n.useEffect(()=>{o()},[o]);const P=async t=>{const s=f.trim();if(!s)return;const[c,...T]=s.split(/\s+/),k=T.join(" ");c&&k&&(await fetch(`/api/automations/${encodeURIComponent(t)}/permissions`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tool:c,target:k})})).ok&&(j(""),await o())},E=async(t,s)=>{(await fetch(`/api/automations/${encodeURIComponent(t)}/permissions`,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({entry:s})})).ok&&await o()},R=async t=>{const s=m===t?null:t;z(s),s&&await A(t)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(v,{size:20,className:"text-accent-blue"}),a("automation.title"),e.jsxs("span",{className:"text-xs text-dark-muted font-normal",children:["(",r.length,")"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>void o(),className:"p-2 rounded-lg hover:bg-dark-hover text-dark-muted",title:a("automation.refresh"),children:e.jsx($,{size:16})}),e.jsxs("button",{onClick:()=>x(t=>!t),className:"flex items-center gap-1 px-3 py-1.5 rounded-lg bg-accent-blue/20 text-accent-blue hover:bg-accent-blue/30 text-sm font-medium",children:[e.jsx(D,{size:16})," ",a("automation.new")]})]})]}),l&&e.jsxs("div",{className:"mb-3 p-3 rounded-lg bg-accent-red/10 text-accent-red text-sm flex items-center gap-2",children:[e.jsx(O,{size:16})," ",l]}),S&&e.jsxs("div",{className:"mb-4 rounded-lg border border-dark-border bg-dark-surface p-4 space-y-3",children:[e.jsx("input",{value:u,onChange:t=>p(t.target.value),placeholder:a("automation.namePlaceholder"),className:"w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue"}),e.jsx("textarea",{value:h,onChange:t=>b(t.target.value),placeholder:a("automation.instructionsPlaceholder"),rows:3,className:"w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue resize-none"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:i,onChange:t=>g(t.target.value),placeholder:a("automation.cronPlaceholder"),className:"flex-1 px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue"}),e.jsx("button",{onClick:async()=>{await N({name:u,instructions:h,schedule:{kind:"cron",cron:i}})&&(p(""),b(""),x(!1))},className:"px-4 py-2 rounded-lg bg-accent-blue text-white text-sm font-medium hover:bg-accent-blue/80",children:a("automation.create")})]}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:[["0 9 * * *",a("automation.cronDaily9")],["0 9 * * 1-5",a("automation.cronWeekday9")],["*/30 * * * *",a("automation.cronEvery30Min")]].map(([t,s])=>e.jsxs("button",{onClick:()=>g(t),className:`px-2 py-1 rounded text-xs ${i===t?"bg-accent-blue/20 text-accent-blue":"bg-dark-hover text-dark-muted hover:text-dark-text"}`,children:[s," (",t,")"]},t))})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2",children:[r.length===0&&e.jsx("p",{className:"text-dark-muted text-center py-8",children:a("automation.empty")}),r.map(t=>e.jsxs("div",{className:"rounded-lg border border-dark-border bg-dark-surface",children:[e.jsxs("div",{className:"flex items-center justify-between p-3",children:[e.jsxs("button",{onClick:()=>void R(t.id),className:"flex items-center gap-2 min-w-0 text-left",children:[e.jsx(v,{size:16,className:"text-accent-blue shrink-0"}),e.jsx("span",{className:"font-medium text-sm truncate",children:t.name}),e.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded shrink-0 ${t.status==="enabled"?"bg-accent-green/20 text-accent-green":"bg-dark-hover text-dark-muted"}`,children:t.status})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsxs("span",{className:"text-xs text-dark-muted hidden lg:inline mr-1",children:[t.schedule.kind==="cron"?t.schedule.cron:t.schedule.fireAt,t.nextRunAt?` · ${new Date(t.nextRunAt).toLocaleString()}`:""]}),e.jsx("button",{onClick:()=>void w(t.id,t.status!=="enabled"),className:"p-1.5 rounded-lg hover:bg-dark-hover text-dark-muted",title:t.status==="enabled"?a("automation.disable"):a("automation.enable"),children:e.jsx(I,{size:15})}),e.jsx("button",{onClick:()=>void C(t.id),className:"p-1.5 rounded-lg hover:bg-dark-hover text-accent-green",title:a("automation.runNow"),children:e.jsx(L,{size:15})}),e.jsx("button",{onClick:()=>void y(t.id),className:"p-1.5 rounded-lg hover:bg-dark-hover text-accent-red",title:a("automation.delete"),children:e.jsx(J,{size:15})})]})]}),m===t.id&&e.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t border-dark-border pt-3",children:[e.jsx("p",{className:"text-xs text-dark-muted whitespace-pre-wrap",children:t.instructions}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-semibold text-dark-muted mb-1 flex items-center gap-1",children:[e.jsx(U,{size:12})," ",a("automation.historyTitle")]}),(d[t.id]||[]).length===0&&e.jsx("p",{className:"text-xs text-dark-muted",children:a("automation.noRuns")}),(d[t.id]||[]).slice(0,10).map(s=>e.jsxs("div",{className:"flex items-center gap-2 text-xs py-1",children:[e.jsx("span",{className:`px-1.5 py-0.5 rounded ${s.status==="ok"?"bg-accent-green/20 text-accent-green":s.status==="error"?"bg-accent-red/20 text-accent-red":"bg-accent-yellow/20 text-accent-yellow"}`,children:s.status}),e.jsx("span",{className:"text-dark-muted",children:new Date(s.startedAt).toLocaleString()}),e.jsxs("span",{className:"text-dark-muted truncate flex-1",children:["#",s.id.slice(0,8)," · ",s.trigger]})]},s.id))]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-semibold text-dark-muted mb-1",children:a("automation.permissionsTitle")}),t.permissions.length===0&&e.jsx("p",{className:"text-xs text-dark-muted",children:a("automation.permissionsEmpty")}),e.jsx("div",{className:"flex flex-wrap gap-1 mb-1",children:t.permissions.map(s=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded bg-accent-blue/10 text-accent-blue text-xs",children:[s,e.jsx("button",{onClick:()=>void E(t.id,s),className:"hover:text-accent-red",children:e.jsx(X,{size:12})})]},s))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:f,onChange:s=>j(s.target.value),placeholder:a("automation.permissionPlaceholder"),className:"flex-1 px-2 py-1.5 rounded-lg bg-dark-bg border border-dark-border text-xs focus:outline-none focus:border-accent-blue"}),e.jsx("button",{onClick:()=>void P(t.id),className:"px-3 py-1.5 rounded-lg bg-dark-hover text-dark-muted hover:text-dark-text text-xs",children:a("automation.add")})]})]})]})]},t.id))]})]})}export{Q as AutomationView};
@@ -1 +0,0 @@
1
- import{j as s}from"./markdown-Bym7wmT0.js";import{a as d,L as w,$ as A,aj as F,z as ae,h as ne,af as le,O as R,aQ as q,be as K,a1 as oe,aV as V,E as de,aq as ce,D as O,l as ie}from"./icons-Cu8fYt4q.js";import{u as me,a as f}from"./index-C7rIgpwO.js";import"./react-vendor-D76F8wnc.js";import"./state-CZakZ3-m.js";import"./panels-BEKHl5l-.js";const ue={"code-intelligence":"🧠 代码智能",filesystem:"📂 文件系统",databases:"🗄️ 数据库","browser-automation":"🌐 浏览器自动化","knowledge-memory":"🧠 知识/记忆","search-web":"🔎 搜索/网页","cloud-platforms":"☁️ 云平台",communication:"💬 通讯","developer-tools":"🛠️ 开发者工具",security:"🔒 安全","test-demo":"🧪 测试/Demo",other:"📦 其他"};function je(){const{t:r}=me(),[u,x]=d.useState([]),[D,C]=d.useState(!0),[E,S]=d.useState(null),[j,p]=d.useState({}),[z,m]=d.useState(null),[v,H]=d.useState(""),[b,$]=d.useState(null),[k,Q]=d.useState("all"),[U,g]=d.useState(null),[Y,L]=d.useState({}),[G,N]=d.useState(!1),[l,i]=d.useState({name:"",command:"",args:"",env:"",transport:"stdio",url:"",headers:""}),M=()=>i({name:"",command:"",args:"",env:"",transport:"stdio",url:"",headers:""}),T=e=>Object.fromEntries(e.split(",").map(t=>t.trim()).filter(Boolean).map(t=>{const n=t.indexOf("=");return n>0?[t.slice(0,n).trim(),t.slice(n+1).trim()]:[t,""]})),I=async()=>{const e=l.transport!=="stdio";if(!l.name.trim()||!e&&!l.command.trim()||e&&!l.url.trim()){m(r("connectors.customFormRequired"));return}p(t=>({...t,__add:!0})),m(null);try{const t=await f.connectors.addCustom({name:l.name.trim(),command:e?void 0:l.command.trim(),args:e?void 0:l.args.split(/\s+/).filter(Boolean),env:T(l.env),url:e?l.url.trim():void 0,transport:e?l.transport:void 0,headers:e?T(l.headers):void 0});t.success&&t.data?(x(n=>[...n,t.data]),N(!1),M()):m(t.error||"添加失败")}catch(t){m(t instanceof Error?t.message:String(t))}finally{p(t=>({...t,__add:!1}))}},W=async e=>{p(t=>({...t,[e.id]:!0}));try{const t=await f.connectors.removeCustom(e.id);t.success?x(n=>n.filter(a=>a.id!==e.id)):m(t.error||"删除失败")}finally{p(t=>({...t,[e.id]:!1}))}},y=async()=>{var t;C(!0),S(null);const e=await f.connectors.list();e.success&&Array.isArray((t=e.data)==null?void 0:t.connectors)?x(e.data.connectors):S(e.error||"加载连接器失败"),C(!1)};d.useEffect(()=>{y()},[]);const B=(e,t,n,a)=>{m(n||null),x(o=>o.map(c=>c.id===e?{...c,enabled:!!a,status:"error"}:c))},P=async(e,t,n)=>{m(null),p(a=>({...a,[e.id]:!0})),x(a=>a.map(o=>o.id===e.id?{...o,enabled:t,status:t?"connecting":"installed"}:o));try{const a=await f.connectors.toggle(e.id,t,n);a.success&&a.data?x(o=>o.map(c=>c.id===e.id?a.data:c)):B(e.id,void 0,a.error||`切换 ${e.name} 失败`,!t)}catch(a){B(e.id,void 0,a instanceof Error?a.message:String(a),!t)}finally{p(a=>({...a,[e.id]:!1}))}},Z=e=>{var t,n;if(!e.enabled&&((t=e.requiresEnv)!=null&&t.length)&&((n=e.missingEnv)!=null&&n.length)){g(e.id);return}g(null),P(e,!e.enabled)},J=(e,t)=>{g(null),L(n=>({...n,[e.id]:{}})),P(e,!0,t)},X=e=>{const t="inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium";if(!e.installed)return s.jsxs("span",{className:`${t} bg-dark-hover text-dark-muted`,children:[s.jsx(O,{size:12}),r("connectors.notInstalled")]});switch(e.status){case"ready":return s.jsxs("span",{className:`${t} bg-accent-green/15 text-accent-green`,children:[s.jsx(ie,{size:12}),r("connectors.ready")]});case"connecting":return s.jsxs("span",{className:`${t} bg-accent-blue/15 text-accent-blue`,children:[s.jsx(w,{size:12,className:"animate-spin"}),r("connectors.connecting")]});case"error":return s.jsxs("span",{className:`${t} bg-accent-red/15 text-accent-red`,children:[s.jsx(A,{size:12}),r("connectors.error")]});case"disabled":return s.jsx("span",{className:`${t} bg-dark-hover text-dark-muted`,children:r("connectors.disabled")});default:return s.jsx("span",{className:`${t} bg-dark-hover text-dark-muted`,children:r("connectors.installed")})}},h=u.filter(e=>k==="all"||e.kind===k),_=h.filter(e=>{if(v){const t=v.toLowerCase();if(![e.name,e.id,e.description,e.category??"",e.kind,...e.languages??[]].join(" ").toLowerCase().includes(t))return!1}return!(b&&e.category!==b)}).sort((e,t)=>e.enabled!==t.enabled?e.enabled?-1:1:e.name.localeCompare(t.name)),ee=[...new Set(h.map(e=>e.category).filter(Boolean))];if(D)return s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"text-center",children:[s.jsx(w,{size:32,className:"animate-spin mx-auto mb-2 text-accent-blue"}),s.jsx("p",{className:"text-dark-muted",children:r("common.loading")})]})});if(E)return s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"text-center",children:[s.jsx(A,{size:32,className:"mx-auto mb-2 text-accent-red"}),s.jsx("p",{className:"text-accent-red mb-4",children:E}),s.jsx("button",{onClick:()=>void y(),className:"px-4 py-2 bg-accent-blue text-white rounded-lg",children:r("common.retry")})]})});const se=e=>{const t=Y[e.id]??{},n=(a,o)=>L(c=>({...c,[e.id]:{...c[e.id]??{},[a]:o}}));return s.jsxs("div",{className:"mt-3 pt-3 border-t border-dark-border",children:[s.jsxs("div",{className:"text-xs text-dark-muted mb-2 flex items-center gap-1",children:[s.jsx(V,{size:12}),r("connectors.needCredentials")]}),s.jsx("div",{className:"space-y-2",children:(e.requiresEnv??[]).map(a=>s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:a.label}),s.jsx("input",{type:a.secret?"password":"text",value:t[a.key]??"",onChange:o=>n(a.key,o.target.value),placeholder:a.key,className:"w-full px-3 py-1.5 bg-dark-bg border border-dark-border rounded-lg text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]},a.key))}),s.jsxs("div",{className:"flex gap-2 mt-2",children:[s.jsx("button",{onClick:()=>void J(e,t),className:"px-3 py-1.5 bg-accent-blue text-white rounded-lg text-sm",children:r("connectors.connect")}),s.jsx("button",{onClick:()=>g(null),className:"px-3 py-1.5 bg-dark-surface border border-dark-border rounded-lg text-sm",children:r("common.cancel")})]})]})},te=e=>{var a,o,c;const t=!!j[e.id],n=U===e.id;return s.jsxs("div",{className:`bg-dark-surface border border-dark-border rounded-lg p-4 transition-opacity ${e.enabled?"":"opacity-80"}`,children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[s.jsx("span",{className:`mt-0.5 shrink-0 px-2 py-1 rounded-md text-[11px] font-semibold uppercase ${e.kind==="lsp"?"bg-accent-purple/15 text-accent-purple":"bg-accent-green/15 text-accent-green"}`,children:e.kind==="lsp"?"LSP":"MCP"}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"font-medium text-sm truncate",children:e.name}),e.custom?s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-purple/15 text-accent-purple",children:r("connectors.custom")}):null,e.official?s.jsxs("span",{title:"Official",className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-yellow/15 text-accent-yellow",children:["🎖️ ",r("connectors.official")]}):null,e.scope==="cloud"?s.jsxs("span",{title:"Cloud",className:"inline-flex items-center gap-0.5 text-[10px] px-1.5 py-0.5 rounded bg-accent-blue/15 text-accent-blue",children:[s.jsx(q,{size:9}),r("connectors.cloud")]}):s.jsxs("span",{title:"Local",className:"inline-flex items-center gap-0.5 text-[10px] px-1.5 py-0.5 rounded bg-dark-hover text-dark-muted",children:[s.jsx(K,{size:9}),r("connectors.local")]}),e.language?s.jsx("span",{className:"text-[10px]",children:e.language}):null,X(e)]}),s.jsx("p",{className:"text-xs text-dark-muted mt-1 line-clamp-2",children:e.description}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[11px] text-dark-muted flex-wrap",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(K,{size:11}),s.jsx("code",{className:"text-[10px]",children:e.installHint})]}),e.transport&&e.transport!=="stdio"?s.jsxs("span",{className:"inline-flex items-center gap-1 text-accent-blue",children:[s.jsx(q,{size:11}),e.transport==="sse"?"SSE":"Streamable HTTP"]}):null,(a=e.languages)!=null&&a.length?s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(oe,{size:11}),e.languages.join(", ")]}):null,e.kind==="mcp"&&e.toolCount!==void 0?s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(F,{size:11}),r("connectors.toolCount",{count:e.toolCount})]}):null,(o=e.requiresEnv)!=null&&o.length?s.jsxs("span",{className:"inline-flex items-center gap-1 text-accent-yellow",children:[s.jsx(V,{size:11}),(c=e.missingEnv)!=null&&c.length?`${e.missingEnv.join(", ")} ${r("connectors.missing")}`:r("connectors.envConfigured")]}):null,e.docsUrl?s.jsxs("a",{href:e.docsUrl,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 hover:text-accent-blue",onClick:re=>re.stopPropagation(),children:[s.jsx(de,{size:11}),r("connectors.docs")]}):null]}),e.error?s.jsx("p",{className:"text-[11px] text-accent-red mt-1",children:e.error}):null]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.custom?s.jsx("button",{onClick:()=>void W(e),disabled:t,title:r("connectors.removeCustom"),className:"p-1.5 rounded-lg text-dark-muted hover:text-accent-red hover:bg-accent-red/10 transition-colors disabled:opacity-40",children:s.jsx(ce,{size:14})}):null,!e.installed&&e.enabled?s.jsxs("span",{className:"text-[11px] text-accent-blue flex items-center gap-1",children:[s.jsx(O,{size:11,className:"animate-pulse"}),r("connectors.installing")]}):null,s.jsx("button",{role:"switch","aria-checked":e.enabled,disabled:t,onClick:()=>Z(e),className:`relative w-12 h-6 rounded-full transition-colors disabled:opacity-50 ${e.enabled?"bg-accent-green":"bg-dark-border"}`,children:s.jsx("span",{className:`absolute top-1 w-4 h-4 bg-white rounded-full transition-transform ${e.enabled?"left-7":"left-1"}`})})]})]}),n?se(e):null]},e.id)};return s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[s.jsx(F,{size:20}),r("nav.connectors"),s.jsxs("span",{className:"text-sm font-normal text-dark-muted",children:["· ",u.filter(e=>e.enabled).length,"/",u.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>N(e=>!e),className:"flex items-center gap-2 px-3 py-1.5 bg-accent-blue text-white rounded hover:bg-accent-blue/90 transition-colors",children:[s.jsx(ae,{size:14}),r("connectors.addCustom")]}),s.jsxs("button",{onClick:()=>void y(),className:"flex items-center gap-2 px-3 py-1.5 bg-dark-surface border border-dark-border rounded hover:bg-dark-hover transition-colors",children:[s.jsx(ne,{size:14}),r("common.refresh")]})]})]}),G?s.jsxs("div",{className:"mb-4 p-4 bg-dark-surface border border-dark-border rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[s.jsx(le,{size:15,className:"text-accent-purple"}),r("connectors.customTitle")]}),s.jsx("div",{className:"flex gap-1",children:[["stdio","🖥️ "+r("connectors.customLocal")],["http","🌐 HTTP"],["sse","📡 SSE"]].map(([e,t])=>s.jsx("button",{onClick:()=>i(n=>({...n,transport:e})),className:`px-3 py-1.5 rounded-lg text-xs transition-colors ${l.transport===e?"bg-accent-blue text-white":"bg-dark-bg border border-dark-border hover:bg-dark-hover"}`,children:t},e))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:r("connectors.customName")}),s.jsx("input",{value:l.name,onChange:e=>i(t=>({...t,name:e.target.value})),placeholder:"my-server",className:"w-full px-3 py-1.5 bg-dark-bg border border-dark-border rounded-lg text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]}),l.transport==="stdio"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:r("connectors.customCommand")}),s.jsx("input",{value:l.command,onChange:e=>i(t=>({...t,command:e.target.value})),placeholder:"npx -y @some/mcp-server",className:"w-full px-3 py-1.5 bg-dark-bg border border-dark-border rounded-lg text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:r("connectors.customArgs")}),s.jsx("input",{value:l.args,onChange:e=>i(t=>({...t,args:e.target.value})),placeholder:"--arg value",className:"w-full px-3 py-1.5 bg-dark-bg border border-dark-border rounded-lg text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]})]}):s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:r("connectors.customUrl")}),s.jsx("input",{value:l.url,onChange:e=>i(t=>({...t,url:e.target.value})),placeholder:"https://mcp.example.com/mcp",className:"w-full px-3 py-1.5 bg-dark-bg border border-dark-border rounded-lg text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]}),l.transport==="stdio"?s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:r("connectors.customEnv")}),s.jsx("input",{value:l.env,onChange:e=>i(t=>({...t,env:e.target.value})),placeholder:"KEY=value, KEY2=value2",className:"w-full px-3 py-1.5 bg-dark-bg border border-dark-border rounded-lg text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]}):s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:r("connectors.customHeaders")}),s.jsx("input",{value:l.headers,onChange:e=>i(t=>({...t,headers:e.target.value})),placeholder:"Authorization=Bearer xxx",className:"w-full px-3 py-1.5 bg-dark-bg border border-dark-border rounded-lg text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]})]}),s.jsxs("div",{className:"flex gap-2 mt-3",children:[s.jsx("button",{onClick:()=>void I(),disabled:!!j.__add,className:"px-3 py-1.5 bg-accent-blue text-white rounded-lg text-sm disabled:opacity-50",children:j.__add?s.jsx(w,{size:14,className:"animate-spin"}):r("connectors.add")}),s.jsx("button",{onClick:()=>N(!1),className:"px-3 py-1.5 bg-dark-surface border border-dark-border rounded-lg text-sm",children:r("common.cancel")})]})]}):null,s.jsx("div",{className:"flex gap-1 mb-3",children:[["all",`${r("connectors.all")} (${u.length})`],["lsp",`LSP (${u.filter(e=>e.kind==="lsp").length})`],["mcp",`MCP (${u.filter(e=>e.kind==="mcp").length})`]].map(([e,t])=>s.jsx("button",{onClick:()=>Q(e),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${k===e?"bg-accent-blue text-white":"bg-dark-surface border border-dark-border hover:bg-dark-hover"}`,children:t},e))}),s.jsx("div",{className:"flex gap-3 mb-3",children:s.jsxs("div",{className:"flex-1 relative",children:[s.jsx(R,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-dark-muted"}),s.jsx("input",{type:"text",value:v,onChange:e=>H(e.target.value),placeholder:r("connectors.searchPlaceholder"),className:"w-full pl-10 pr-4 py-2 bg-dark-surface border border-dark-border rounded-lg text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]})}),s.jsxs("div",{className:"flex gap-1 mb-4 flex-wrap",children:[s.jsxs("button",{onClick:()=>$(null),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${b?"bg-dark-surface border border-dark-border hover:bg-dark-hover":"bg-accent-blue text-white"}`,children:[r("connectors.all")," ",s.jsxs("span",{className:"opacity-70 text-xs",children:["(",h.length,")"]})]}),ee.map(e=>{const t=h.filter(n=>n.category===e).length;return s.jsxs("button",{onClick:()=>$(b===e?null:e),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${b===e?"bg-accent-blue text-white":"bg-dark-surface border border-dark-border hover:bg-dark-hover"}`,children:[ue[e]??e," ",s.jsxs("span",{className:"opacity-70 text-xs",children:["(",t,")"]})]},e)})]}),z?s.jsx("div",{className:"mb-4 px-3 py-2 bg-accent-red/10 border border-accent-red/30 rounded-lg text-accent-red text-sm",children:z}):null,s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar",children:_.length===0?s.jsxs("div",{className:"text-center text-dark-muted text-sm py-10",children:[s.jsx(R,{size:24,className:"mx-auto mb-2 opacity-50"}),r("connectors.noResults")]}):s.jsx("div",{className:"space-y-2",children:_.map(te)})})]})}export{je as ConnectorsView};
@@ -1 +0,0 @@
1
- import{j as e}from"./markdown-Bym7wmT0.js";import{a as o,h as te,a2 as Hs,z as Me,O as ae,X as cs,ap as qs,C as be,aq as Ie,ar as is,as as _s,ae as Vs,ag as Ws,at as Ys,au as Qs,D as Js,aj as Xs,av as us,$ as Zs,aw as et}from"./icons-Cu8fYt4q.js";import{a as h,u as st,t as T,M as ms,P as tt}from"./index-C7rIgpwO.js";import"./react-vendor-D76F8wnc.js";import"./state-CZakZ3-m.js";import"./panels-BEKHl5l-.js";function at(){const[y,b]=o.useState([]),[C,t]=o.useState("1.0"),[P,je]=o.useState(!0),[f,le]=o.useState(!0),[ke,W]=o.useState(null),Y=o.useCallback(async()=>{le(!0),W(null);try{const g=await h.providers.presets();g.success&&g.data?(b(Array.isArray(g.data.providers)?g.data.providers:[]),t(g.data.version||"1.0"),je(g.data.customSupported!==!1)):W(g.error||"获取 Provider 列表失败")}catch(g){W(g instanceof Error?g.message:"未知错误")}finally{le(!1)}},[]);return o.useEffect(()=>{Y()},[Y]),{presets:y,loading:f,error:ke,version:C,customSupported:P,reload:Y}}const lt={providerKey:"",apiKeys:"",modelIds:"",baseUrl:"",apiType:"",fullPath:!1,setDefault:!1,modelOverrides:{}},ps=tt,fe={"openai-chat-completions":"OpenAI Chat","openai-completions":"OpenAI Compatible","openai-responses":"OpenAI Responses","anthropic-messages":"Anthropic Messages","codex-responses":"Codex (本机登录)","claude-code":"Claude Code (本机登录)"};function J(y){return y.trim().split("|")[0].trim()}function rt(y){const b=y.toLowerCase();return b.startsWith("claude-code://")||b.includes("/backend-api/codex")?b.startsWith("claude-code://")?"claude-code":"codex-responses":b.includes("/anthropic")||b.includes("/coding")||b.includes("/claude")||b.includes("/messages")?"anthropic-messages":b.includes("/responses")?"openai-responses":"openai-completions"}function Ue(y){if(!y)return{};const b={};for(const C of y.models){const t={};C.apiType&&C.apiType!==y.apiType&&(t.apiType=C.apiType),C.baseUrl&&(t.baseUrl=C.baseUrl),Object.keys(t).length>0&&(b[C.id]=t)}return b}const ge={"opencode-free":5,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 mt(){var ss,ts,as,ls,rs,os;const{presets:y,loading:b,reload:C}=at(),{t}=st(),[P,je]=o.useState([]),[f,le]=o.useState(null),[ke,W]=o.useState(!0),[Y,g]=o.useState(null),[Ae,Ke]=o.useState(null),[n,hs]=o.useState(null),[M,bs]=o.useState([]),[fs,G]=o.useState(!1),[Ee,H]=o.useState("select"),[D,R]=o.useState(null),[m,j]=o.useState(lt),[gs,E]=o.useState(""),[$e,Fe]=o.useState(!1),[ze,$]=o.useState(null),[vs,X]=o.useState(!1),[re,Le]=o.useState(!1),[Z,oe]=o.useState(""),[Re,Oe]=o.useState({}),[Ne,Be]=o.useState(!1),[F,q]=o.useState([]),[ne,I]=o.useState(new Set),[Ge,O]=o.useState(null),[de,ee]=o.useState(""),[we,He]=o.useState(!1),[ce,B]=o.useState(null),_=o.useCallback(async()=>{try{const s=await h.config.provider.get();s.success&&s.data&&(hs(s.data),bs(Array.isArray(s.data.entries)?s.data.entries:[]))}catch{}},[]),k=o.useCallback(async()=>{W(!0),g(null);try{const[s,a]=await Promise.all([h.models.list(),h.system.status()]);if(await _(),s.success&&s.data&&Array.isArray(s.data.models)&&je(s.data.models),a.success&&a.data){const l=a.data.models||{total:0,online:0,offline:0};le({overallStatus:l.offline===0?"healthy":l.online>0?"degraded":"unhealthy",healthRate:l.total>0?l.online/l.total:0,healthyInstances:l.online,totalInstances:l.total,totalRequests:0})}}catch{g(t("models.loadFailed"))}finally{W(!1)}},[_,t]);o.useEffect(()=>{k()},[k]),o.useEffect(()=>{const s=()=>{k(),_()};return window.addEventListener("models-updated",s),()=>window.removeEventListener("models-updated",s)},[k,_]);const U=o.useCallback(s=>`${s.provider}:${s.id}`,[]),ys=o.useCallback(s=>Re[U(s)]||{inputTokens:0,outputTokens:0},[U,Re]),qe=o.useCallback((s,a,l)=>{const c=U(s);Oe(r=>{var d,i;return{...r,[c]:{inputTokens:a==="inputTokens"?l:((d=r[c])==null?void 0:d.inputTokens)||0,outputTokens:a==="outputTokens"?l:((i=r[c])==null?void 0:i.outputTokens)||0}}})},[U]),js=o.useCallback(s=>{Oe(a=>({...a,[U(s)]:{inputTokens:0,outputTokens:0}}))},[U]),z=o.useMemo(()=>{const s=[...y];return s.find(a=>a.key==="custom")||s.push({key:"custom",name:"Custom",baseUrl:"",apiType:"openai-completions",defaultModel:"",isCustom:!0}),s},[y]),ie=o.useMemo(()=>[...z].sort((s,a)=>{if(s.isCustom)return-1;if(a.isCustom)return 1;const l=ge[s.key],c=ge[a.key];return l!==void 0&&c!==void 0?l-c:l!==void 0?-1:c!==void 0?1:s.name.localeCompare(a.name)}),[z]),_e=o.useMemo(()=>{const s=Z.trim().toLowerCase();return s?ie.filter(a=>a.name.toLowerCase().includes(s)||a.key.toLowerCase().includes(s)||(a.defaultModel||"").toLowerCase().includes(s)||(a.baseUrl||"").toLowerCase().includes(s)||(a.models||[]).some(l=>String(l).toLowerCase().includes(s))):ie},[ie,Z]),L=o.useMemo(()=>{var c,r,d,i;const s=(n==null?void 0:n.providers)||{},a=new Set(z.map(u=>u.key)),l=Object.entries(s).filter(([u])=>!a.has(u));if(l.length!==0)return{keys:l.map(([u])=>u),modelCount:l.reduce((u,[,v])=>u+(v.modelCount||0),0),hasApiKey:l.some(([,u])=>u.hasApiKey),baseUrl:((r=(c=l.find(([,u])=>u.baseUrl))==null?void 0:c[1])==null?void 0:r.baseUrl)||"",apiType:((i=(d=l.find(([,u])=>u.apiType))==null?void 0:d[1])==null?void 0:i.apiType)||"openai-completions"}},[n,z]),V=D==="custom"?m.providerKey.trim():D||"",Ce=o.useMemo(()=>V?P.filter(s=>s.provider===V):[],[P,V]),ks=o.useMemo(()=>{const s=new Map;for(const l of P)s.has(l.provider)||s.set(l.provider,[]),s.get(l.provider).push(l);for(const l of M)s.has(l.key)||s.set(l.key,[]);const a=[...s.keys()];return a.sort((l,c)=>{const r=ge[l],d=ge[c];return r!==void 0&&d!==void 0?r-d:r!==void 0?-1:d!==void 0?1:l.localeCompare(c)}),a.map(l=>({provider:l,models:s.get(l)||[]}))},[P,M]),Ve=o.useCallback(s=>{var i,u;const a=(i=n==null?void 0:n.providers)==null?void 0:i[s.key],l=M.find(v=>v.key===s.key),c=P.filter(v=>v.provider===s.key).map(v=>v.id),r=((u=s.models)==null?void 0:u.slice(0,3).join(", "))||s.defaultModel,d=c.length>0?c.join(", "):r;R(s.key),E(""),j({providerKey:s.key,apiKeys:"",modelIds:d,baseUrl:(a==null?void 0:a.baseUrl)||s.baseUrl,apiType:(a==null?void 0:a.apiType)||s.apiType,fullPath:(a==null?void 0:a.fullPath)===!0,setDefault:(n==null?void 0:n.defaultProvider)!==s.key,modelOverrides:Ue(l)}),H("form"),G(!0),$(null),X(!1),q([]),I(new Set),O(null),ee("")},[P,n,M]),Ns=o.useCallback(s=>{var r;const a=(r=n==null?void 0:n.providers)==null?void 0:r[s],l=M.find(d=>d.key===s),c=P.filter(d=>d.provider===s).map(d=>d.id).join(", ");R("custom"),E(s),j({providerKey:s,apiKeys:"",modelIds:c,baseUrl:(a==null?void 0:a.baseUrl)||"",apiType:(a==null?void 0:a.apiType)||"",fullPath:(a==null?void 0:a.fullPath)===!0,setDefault:(n==null?void 0:n.defaultProvider)!==s,modelOverrides:Ue(l)}),$(null),X(!1),q([]),I(new Set),O(null),ee("")},[n,P,M]),Pe=o.useCallback(()=>{R("custom"),E(""),j({providerKey:"",apiKeys:"",modelIds:"",baseUrl:"",apiType:"",fullPath:!1,setDefault:!(n!=null&&n.configured),modelOverrides:{}}),H("form"),G(!0),$(null),X(!1),q([]),I(new Set),O(null),ee("")},[n]),ws=o.useCallback(async()=>{var a;const s=m.baseUrl;if(!s){O(t("models.baseUrlRequired"));return}Be(!0),O(null),q([]),I(new Set);try{const l=(m.apiKeys||"").split(/\r?\n|,/).map(d=>d.trim()).filter(Boolean)[0]||"",c=l.replace(/[^\x00-\xFF]/g,"");c!==l&&T.warning(t("models.apiKeySanitized"));const r=await h.models.fetch(s,c,m.fullPath===!0);if(r.success&&((a=r.data)!=null&&a.models)){const d=r.data.models;q(d);const i=new Set(d.map(w=>w.id)),u=m.modelIds.split(",").map(w=>w.trim()).filter(Boolean),v=u.filter(w=>i.has(w.split("|")[0].trim())),p=u.filter(w=>!i.has(w.split("|")[0].trim()));if(I(new Set(v.map(w=>w.split("|")[0].trim()))),p.length>0){const w=p.map(S=>S.split("|")[0].trim());j(S=>({...S,modelIds:v.join(", ")})),T.warning(t("models.autoRemovedMissingModels",{models:w.join(", ")}))}T.success(t("models.fetchedCount",{n:d.length}))}else O(r.error||t("models.fetchFailed"))}catch(l){O(l instanceof Error?l.message:t("models.requestFailed"))}finally{Be(!1)}},[m.baseUrl,m.apiKeys,m.modelIds,t]),Cs=o.useCallback(async()=>{var a,l;const s=m.baseUrl;if(!s){B({ok:!1,message:t("models.baseUrlRequired")});return}He(!0),B(null);try{const c=(m.apiKeys||"").split(/\r?\n|,/).map(i=>i.trim()).filter(Boolean)[0]||"",r=c.replace(/[^\x00-\xFF]/g,"");r!==c&&T.warning(t("models.apiKeySanitized"));const d=await h.providers.testConnection(s,r);if(d.success&&((a=d.data)!=null&&a.reachable)){const i=d.data,u={};i.resolvedBaseUrl&&i.resolvedBaseUrl!==m.baseUrl&&(u.baseUrl=i.resolvedBaseUrl),i.detectedApiType&&m.apiType===""&&(u.apiType=i.detectedApiType),Object.keys(u).length>0&&j(w=>({...w,...u}));const v=[];u.baseUrl&&v.push(t("models.baseUrlAutoCompleted",{url:u.baseUrl})),u.apiType&&v.push(t("models.apiTypeAutoSelected",{type:fe[u.apiType]}));const p=i.message||t("models.connectionSuccess");B({ok:!0,message:v.length>0?t("models.connectionSuccessWithHints",{message:p,hints:v.join(t("models.hintJoiner"))}):p})}else B({ok:!1,message:((l=d.data)==null?void 0:l.message)||d.error||t("models.connectionFailed")})}catch(c){B({ok:!1,message:c instanceof Error?c.message:t("models.requestFailed")})}finally{He(!1)}},[m.baseUrl,m.apiKeys,m.apiType,t]),Ps=o.useCallback(s=>{const a=new Set(ne);a.has(s)?a.delete(s):a.add(s),I(a),j(l=>({...l,modelIds:Array.from(a).join(", ")}))},[ne]),Ts=o.useCallback(s=>{const a=m.modelIds.split(",").map(d=>d.trim()).filter(Boolean),c=a.some(d=>J(d)===s.id)?a.filter(d=>J(d)!==s.id):[...a,s.name&&s.name!==s.id?`${s.id}|${s.name}`:s.id];j(d=>({...d,modelIds:c.join(", ")}));const r=new Set(F.map(d=>d.id));I(new Set(c.map(J).filter(d=>r.has(d))))},[m.modelIds,F]),[Ds,We]=o.useState(!1),[Te,Ye]=o.useState(""),[Qe,ue]=o.useState([]),[Ss,Je]=o.useState(!1),[Xe,me]=o.useState(null),[pe,Ms]=o.useState(!1),[xe,Is]=o.useState(!0),Us=o.useCallback(()=>{Ye(""),ue([]),me(null),We(!0),se("",{reason:!1,tool:!0})},[]),se=o.useCallback(async(s,a)=>{Je(!0),me(null);try{const l=await h.models.catalogSearch({q:s,reasoning:(a==null?void 0:a.reason)??!1,toolCall:(a==null?void 0:a.tool)??!0,limit:30});l.success&&l.data?ue(l.data.hits||[]):(me(l.error||t("models.catalogSearchFailed")),ue([]))}catch(l){me(l instanceof Error?l.message:t("models.requestFailed")),ue([])}finally{Je(!1)}},[t]),As=o.useCallback(s=>{j(a=>{const l=a.modelIds.split(",").map(c=>c.trim()).filter(Boolean);return l.includes(s.model.id)?a:{...a,modelIds:[...l,s.model.id].join(", ")}}),T.success(t("models.addedModel",{id:s.model.id}))},[t]),[De,Ks]=o.useState(null),Es=o.useCallback(s=>{Ye(s),De&&clearTimeout(De),Ks(setTimeout(()=>{se(s,{reason:pe,tool:xe})},300))},[De,pe,xe,se]),$s=async s=>{const a=s.provider,l=s.id,c=s.enabled!==!1,r=s.name||l,d=i=>c&&/default model/i.test(i);try{const i=await h.models.toggle(a,l);if(i.success){await k();return}const u=i.error||"";d(u)?T.error(t("models.defaultModelDisableBlocked",{name:r})):T.error(u||t("models.operationFailed"))}catch(i){const u=i instanceof Error?i.message:"";d(u)?T.error(t("models.defaultModelDisableBlocked",{name:r})):T.error(u||t("models.operationFailed"))}},Fs=async s=>{const a=U(s);Ke(a);try{await h.models.test(s.id),await k()}finally{Ke(null)}},zs=async(s,a)=>{if(confirm(t("models.deleteModelConfirm",{id:a})))try{(await h.models.delete(s,a)).success&&await k()}catch{}},Ze=o.useCallback(s=>{var d;const a=M.find(i=>i.key===s),l=z.find(i=>i.key===s),c=!l||l.isCustom,r=(d=n==null?void 0:n.providers)==null?void 0:d[s];R(c?"custom":s),E(c?s:""),j({providerKey:s,apiKeys:"",modelIds:(a==null?void 0:a.models.map(i=>i.name&&i.name!==i.id?`${i.id}|${i.name}`:i.id).join(", "))||"",baseUrl:(a==null?void 0:a.baseUrl)||(r==null?void 0:r.baseUrl)||(l==null?void 0:l.baseUrl)||"",apiType:(a==null?void 0:a.apiType)||(r==null?void 0:r.apiType)||(l==null?void 0:l.apiType)||"",fullPath:(a==null?void 0:a.fullPath)===!0||(r==null?void 0:r.fullPath)===!0,setDefault:(n==null?void 0:n.defaultProvider)!==s,modelOverrides:Ue(a)}),H("form"),G(!0),$(null),X(!1),q([]),I(new Set),O(null),ee("")},[M,z,n]),Ls=s=>{Ze(s.provider)},Rs=async()=>{var ns,ds;const s=z.find(x=>x.key===D)||null,a=D==="custom"?m.providerKey.trim():(s==null?void 0:s.key)||"";if(!a){$(t("models.providerNameRequired"));return}const l=(m.apiKeys||"").split(/\r?\n|,/).map(x=>x.trim()).filter(Boolean),c=!!((ds=(ns=n==null?void 0:n.providers)==null?void 0:ns[a])!=null&&ds.hasApiKey);if(l.length===0&&!c){$(t("models.apiKeyRequired"));return}const r=s||{baseUrl:"",apiType:"openai-completions",defaultModel:""},d=l.map(x=>x.replace(/[^\x00-\xFF]/g,"")).filter(Boolean),i=F.length>0?new Set(F.map(x=>x.id)):null,u=(m.modelIds||r.defaultModel||"").split(",").map(x=>x.trim()).filter(Boolean),v=i?u.filter(x=>i.has(x.split("|")[0].trim())):u,p=i?u.filter(x=>!i.has(x.split("|")[0].trim())):[];p.length>0&&T.warning(t("models.autoSkippedMissingModels",{models:p.map(x=>x.split("|")[0].trim()).join(", ")}));const w=v.map(J).filter(Boolean),S=new Set;for(const x of P)x.provider!==a||w.includes(x.id)||(x.isGlobalDefault&&S.add("global"),x.isActDefault&&S.add("act"),x.isPlanDefault&&S.add("plan"),x.isGoalDefault&&S.add("goal"));const Se={provider:a,name:a,baseUrl:m.baseUrl||r.baseUrl,fullPath:m.fullPath===!0,apiType:m.apiType||rt(m.baseUrl||r.baseUrl)||r.apiType,models:v.map((x,he)=>{const A=x.trim().split("|").map(Gs=>Gs.trim()).filter(Boolean),K=A[0]||"",N=m.modelOverrides[K];return{id:K,name:A[1]||K,aliases:A.length>2?A.slice(2):void 0,enabled:!0,priority:10+he,...N!=null&&N.apiType?{apiType:N.apiType}:{},...N!=null&&N.baseUrl?{baseUrl:N.baseUrl}:{}}}).filter(x=>x.id.length>0)};d.length>0&&(Se.apiKeys=d),(!(n!=null&&n.configured)||m.setDefault)&&(Se.setDefault=!0),Fe(!0),$(null);try{const x=await h.config.provider.save(Se);if(x.success){if(S.size>0){const he=w[0]||"",A={};if(he){const K=`${a}:${he}`;for(const N of S)A[N]=K}else{const K=P.find(N=>N.provider!==a);for(const N of S)N==="plan"||N==="goal"?A[N]=null:K&&(A[N]=`${K.provider}:${K.id}`)}Object.keys(A).length>0&&(await h.models.setDefaults(A)).success&&T.success(t("models.defaultsAutoUpdated"))}G(!1),H("select"),R(null),E(""),await _(),await k()}else $(x.error||t("models.saveFailed"))}catch(x){$(x instanceof Error?x.message:t("models.unknownError"))}finally{Fe(!1)}},es=async s=>{if(confirm(t("models.removeConfirm",{providerKey:s})))try{await h.config.provider.delete(s),await _(),await k()}catch{}},Os=s=>{switch(s){case"online":return"text-accent-green";case"offline":return"text-dark-muted";case"error":return"text-accent-red";default:return"text-dark-muted"}},Bs=s=>{switch(s){case"online":return e.jsx(et,{size:14});case"offline":return e.jsx(us,{size:14});case"error":return e.jsx(Zs,{size:14});default:return e.jsx(us,{size:14})}},Q=o.useMemo(()=>z.find(s=>s.key===D)||null,[D,z]);return ke?e.jsx("div",{className:"flex h-64 items-center justify-center text-dark-muted",children:t("models.loading")}):Y?e.jsx("div",{className:"flex h-64 items-center justify-center text-accent-red",children:Y}):e.jsx("div",{className:"ui-page flex-1 min-h-0",children:e.jsxs("div",{className:"ui-page-inner space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h2",{className:"text-base font-semibold",children:t("models.providerConfig")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:async()=>{try{await h.providers.refresh(),T.success(t("models.providerListRefreshed")),Le(!0),await C(),setTimeout(()=>{C()},3e3)}catch{T.error(t("models.refreshFailed"))}},className:"btn btn-secondary px-3 py-2 text-xs",title:t("models.refreshListTitle"),children:[e.jsx(te,{size:12}),t("models.refreshList")]}),e.jsxs("button",{onClick:()=>{re&&oe(""),Le(s=>!s)},className:"btn btn-accent px-3 py-2 text-xs",children:[re?e.jsx(Hs,{size:12}):e.jsx(Me,{size:12}),t(re?"models.collapse":"models.addProvider")]})]})]}),re&&e.jsxs("div",{children:[e.jsxs("div",{className:"relative mb-3 max-w-md",children:[e.jsx(ae,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-dark-muted"}),e.jsx("input",{value:Z,onChange:s=>oe(s.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:t("models.providerSearchPlaceholder")}),Z&&e.jsx("button",{onClick:()=>oe(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-dark-muted hover:text-white",title:t("models.clear"),"aria-label":t("models.clearSearch"),children:e.jsx(cs,{size:13})})]}),e.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:b?e.jsxs("div",{className:"col-span-full flex items-center justify-center py-4 text-dark-muted text-sm",children:[e.jsx(qs,{size:14,className:"mr-2 animate-spin"}),t("models.loadingProviders")]}):_e.length===0?e.jsxs("div",{className:"col-span-full border border-accent-red/30 bg-accent-red/10 rounded-lg p-4 text-center",children:[e.jsx("div",{className:"text-sm text-accent-red font-medium mb-1",children:t("models.noMatchingProviders")}),e.jsx("div",{className:"text-xs text-dark-muted mb-3",children:t("models.noMatchingProvidersHint",{query:Z})}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsxs("button",{onClick:()=>oe(""),className:"inline-flex items-center gap-1 px-2.5 py-1 text-xs border border-dark-border rounded hover:bg-dark-hover",children:[e.jsx(cs,{size:12}),t("models.clearSearch")]}),e.jsxs("button",{onClick:Pe,className:"inline-flex items-center gap-1 px-2.5 py-1 text-xs bg-accent-blue text-white rounded hover:opacity-90",children:[e.jsx(Me,{size:12}),t("models.addCustomProvider")]})]})]}):_e.map(s=>{var d,i;const a=s.key==="custom",l=a?L:(d=n==null?void 0:n.providers)==null?void 0:d[s.key],c=l==null?void 0:l.hasApiKey,r=a?!!(n!=null&&n.defaultProvider)&&((L==null?void 0:L.keys)||[]).includes(n.defaultProvider):(n==null?void 0:n.defaultProvider)===s.key;return e.jsxs("div",{className:`ui-card-interactive text-left p-4 relative ${c?"border-accent-green/30 bg-dark-surface hover:border-accent-green/50":"border-dark-border bg-dark-surface hover:border-dark-hover"}`,children:[e.jsxs("div",{onClick:()=>s.key==="custom"?Pe():Ve(s),className:"cursor-pointer",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-sm font-medium",children:s.name}),c&&e.jsx(be,{size:14,className:"text-accent-green"})]}),e.jsxs("div",{className:"text-[10px] text-dark-muted space-y-0.5",children:[e.jsx("div",{className:"truncate",children:a?(l==null?void 0:l.baseUrl)||t("models.customBaseUrl"):s.baseUrl||t("models.customBaseUrl")}),e.jsx("div",{className:"truncate",children:a&&L?`${L.keys.join(", ")}`:s.defaultModel||t("models.noDefaultModel")}),e.jsxs("div",{children:[l?t("models.configuredCount",{n:l.modelCount}):t("models.availableCount",{n:((i=s.models)==null?void 0:i.length)||0}),s.models&&s.models.length>0&&!l&&e.jsx("span",{className:"text-accent-blue",children:" ✓"})]})]}),r&&e.jsx("div",{className:"mt-1 text-[10px] text-accent-blue",children:t("models.defaultProviderBadge")})]}),c&&s.key!=="custom"&&e.jsx("button",{onClick:u=>{u.stopPropagation(),es(s.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:t("models.deleteProvider"),"aria-label":t("models.deleteProviderNamed",{name:s.name}),children:e.jsx(Ie,{size:13})})]},s.key)})})]})]}),f&&e.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[e.jsx(ve,{title:t("models.overallStatus"),value:f.totalInstances===0?t("models.notConfigured"):f.overallStatus==="healthy"?t("models.healthy"):f.overallStatus==="degraded"?t("models.degraded"):t("models.abnormal"),color:f.totalInstances===0?"blue":f.overallStatus==="healthy"?"green":f.overallStatus==="degraded"?"yellow":"red"}),e.jsx(ve,{title:t("models.healthRate"),value:f.totalInstances===0?"N/A":`${(f.healthRate*100).toFixed(0)}%`,color:f.totalInstances===0?"blue":f.healthRate>.8?"green":f.healthRate>.5?"yellow":"red"}),e.jsx(ve,{title:t("models.onlineInstances"),value:f.totalInstances===0?t("models.none"):`${f.healthyInstances}/${f.totalInstances}`,color:f.healthyInstances>0?"green":"red"}),e.jsx(ve,{title:t("models.totalRequests"),value:f.totalRequests>0?f.totalRequests.toLocaleString():"0",color:"blue"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx("h3",{className:"text-sm font-medium",children:t("models.configuredModels")})}),e.jsxs("div",{className:"space-y-4 max-h-[640px] overflow-y-auto custom-scrollbar pr-1",children:[ks.map(s=>{var c;const a=M.find(r=>r.key===s.provider),l=(c=n==null?void 0:n.providers)==null?void 0:c[s.provider];return e.jsxs("div",{className:"rounded-lg border border-dark-border overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2 bg-dark-bg border-b border-dark-border",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[e.jsx("span",{className:"text-xs font-semibold whitespace-nowrap text-accent-purple",children:s.provider}),(n==null?void 0:n.defaultProvider)===s.provider&&e.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-accent-blue/20 text-accent-blue whitespace-nowrap",children:t("models.defaultShort")}),e.jsx("span",{className:"text-[10px] text-dark-muted truncate",children:(l==null?void 0:l.baseUrl)||(a==null?void 0:a.baseUrl)||""}),e.jsx("span",{className:"text-[10px] text-dark-muted whitespace-nowrap",children:(a==null?void 0:a.apiType)||(l==null?void 0:l.apiType)||""}),l!=null&&l.hasApiKey||a!=null&&a.hasApiKey?e.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-accent-green/20 text-accent-green whitespace-nowrap",children:t("models.hasKey")}):e.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-accent-red/20 text-accent-red whitespace-nowrap",children:t("models.noKey")})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>Ze(s.provider),className:"p-1.5 rounded hover:bg-accent-blue/10 text-dark-muted hover:text-accent-blue",title:t("models.editProviderNamed",{name:s.provider}),children:e.jsx(is,{size:13})}),e.jsx("button",{onClick:()=>es(s.provider),className:"p-1.5 rounded hover:bg-accent-red/10 text-dark-muted hover:text-accent-red",title:t("models.deleteProviderNamed",{name:s.provider}),children:e.jsx(Ie,{size:13})})]})]}),e.jsxs("div",{className:"space-y-2 p-2 bg-dark-surface/40",children:[s.models.map(r=>{const d=ys(r),i=d.inputTokens+d.outputTokens,u=a==null?void 0:a.models.find(p=>p.id===r.id),v=!!(u!=null&&u.apiType&&u.apiType!==(a==null?void 0:a.apiType));return e.jsx("div",{className:`bg-dark-surface border rounded-lg p-3 ${r.status==="online"?"border-accent-green":"border-dark-border"} ${r.enabled===!1?"opacity-60":""}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[e.jsx("span",{className:Os(r.status),children:Bs(r.status)}),e.jsx("span",{className:"font-medium text-sm text-accent-blue",children:r.name}),e.jsx("span",{className:"text-[10px] text-accent-purple px-1.5 py-0.5 bg-accent-purple/10 rounded",children:r.provider}),r.apiType&&e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${r.apiType==="anthropic-messages"||r.apiType==="openai-responses"?"bg-accent-purple/20 text-accent-purple":"bg-accent-blue/20 text-accent-blue"}`,children:fe[r.apiType]||r.apiType}),v&&e.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-accent-yellow/20 text-accent-yellow font-medium",title:t("models.overrideTitle"),children:t("models.overrideBadge")}),r.isGlobalDefault&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-green/20 text-accent-green font-medium",children:t("chat.globalDefault")}),r.isPlanDefault&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-blue/20 text-accent-blue font-medium",children:t("chat.planDefault")}),r.isActDefault&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-yellow/20 text-accent-yellow font-medium",children:t("chat.actDefault")}),r.isGoalDefault&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-purple/20 text-accent-purple font-medium",children:t("chat.goalDefault")})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 text-xs",children:[e.jsx(ye,{label:t("models.loadLabel"),value:`${r.load}/${r.maxLoad}`}),e.jsx(ye,{label:"Token",value:`${r.tokens}/${r.maxTokens}`}),e.jsx(ye,{label:t("models.inputPrice"),value:`$${r.price.input}/1K`}),e.jsx(ye,{label:t("models.outputPrice"),value:`$${r.price.output}/1K`})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-1 sm:grid-cols-4 gap-3 items-end",children:[e.jsx(xs,{label:t("models.inputTokensLabel"),value:d.inputTokens,onChange:p=>qe(r,"inputTokens",p)}),e.jsx(xs,{label:t("models.outputTokensLabel"),value:d.outputTokens,onChange:p=>qe(r,"outputTokens",p)}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] text-dark-muted mb-1",children:t("models.totalTokensLabel")}),e.jsx("div",{className:"px-3 py-2 rounded border border-dark-border bg-dark-bg text-sm font-mono",children:i.toLocaleString()})]}),e.jsxs("button",{onClick:()=>js(r),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:[e.jsx(_s,{size:13}),t("models.reset")]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[!r.isGlobalDefault&&r.enabled!==!1&&e.jsx("button",{onClick:async()=>{try{await h.models.setDefaults({global:`${r.provider}:${r.id}`}),await k()}catch(p){g(p instanceof Error?p.message:t("models.setGlobalDefaultFailed"))}},className:"px-2 py-1 rounded text-[10px] border border-accent-green/30 text-accent-green hover:bg-accent-green/10",title:t("models.setGlobalDefaultTitle"),children:t("chat.globalDefault")}),!r.isPlanDefault&&r.enabled!==!1&&e.jsx("button",{onClick:async()=>{try{await h.models.setDefaults({plan:`${r.provider}:${r.id}`}),await k()}catch(p){g(p instanceof Error?p.message:t("models.setPlanDefaultFailed"))}},className:"px-2 py-1 rounded text-[10px] border border-accent-blue/30 text-accent-blue hover:bg-accent-blue/10",title:t("models.setPlanDefaultTitle"),children:t("chat.planDefault")}),r.isPlanDefault&&e.jsx("button",{onClick:async()=>{try{await h.models.setDefaults({plan:null}),await k()}catch(p){g(p instanceof Error?p.message:t("models.unsetPlanDefaultFailed"))}},className:"px-2 py-1 rounded text-[10px] border border-dark-border text-dark-muted hover:bg-dark-hover",title:t("models.unsetPlanDefaultTitle"),children:t("models.unsetPlanDefault")}),!r.isActDefault&&r.enabled!==!1&&e.jsx("button",{onClick:async()=>{try{await h.models.setDefaults({act:`${r.provider}:${r.id}`}),await k()}catch(p){g(p instanceof Error?p.message:t("models.setActDefaultFailed"))}},className:"px-2 py-1 rounded text-[10px] border border-accent-yellow/30 text-accent-yellow hover:bg-accent-yellow/10",title:t("models.setActDefaultTitle"),children:t("chat.actDefault")}),r.isActDefault&&e.jsx("button",{onClick:async()=>{try{await h.models.setDefaults({act:null}),await k()}catch(p){g(p instanceof Error?p.message:t("models.unsetActDefaultFailed"))}},className:"px-2 py-1 rounded text-[10px] border border-dark-border text-dark-muted hover:bg-dark-hover",title:t("models.unsetActDefaultTitle"),children:t("models.unsetActDefault")}),!r.isGoalDefault&&r.enabled!==!1&&e.jsx("button",{onClick:async()=>{try{await h.models.setDefaults({goal:`${r.provider}:${r.id}`}),await k()}catch(p){g(p instanceof Error?p.message:t("models.setGoalDefaultFailed"))}},className:"px-2 py-1 rounded text-[10px] border border-accent-purple/30 text-accent-purple hover:bg-accent-purple/10",title:t("models.setGoalDefaultTitle"),children:t("chat.goalDefault")}),r.isGoalDefault&&e.jsx("button",{onClick:async()=>{try{await h.models.setDefaults({goal:null}),await k()}catch(p){g(p instanceof Error?p.message:t("models.unsetGoalDefaultFailed"))}},className:"px-2 py-1 rounded text-[10px] border border-dark-border text-dark-muted hover:bg-dark-hover",title:t("models.unsetGoalDefaultTitle"),children:t("models.unsetGoalDefault")}),e.jsx("button",{onClick:()=>Ls(r),className:"p-1.5 rounded hover:bg-accent-blue/10 text-dark-muted hover:text-accent-blue",title:t("models.editModel"),children:e.jsx(is,{size:13})}),e.jsx("button",{onClick:()=>zs(r.provider,r.id),className:"p-1.5 rounded hover:bg-accent-red/10 text-dark-muted hover:text-accent-red",title:t("models.deleteModel"),children:e.jsx(Ie,{size:13})}),e.jsx("button",{onClick:()=>Fs(r),disabled:Ae===U(r),className:"p-1.5 rounded hover:bg-dark-hover disabled:opacity-50",title:t("models.refresh"),children:e.jsx(te,{size:13,className:Ae===U(r)?"animate-spin":""})}),e.jsx("button",{onClick:()=>$s(r),className:`px-2 py-0.5 rounded text-xs transition-colors ${r.enabled===!1?"bg-accent-green/20 text-accent-green hover:bg-accent-green/30":"bg-accent-red/20 text-accent-red hover:bg-accent-red/30"}`,children:r.enabled===!1?t("models.enable"):t("models.disable")})]})]})},U(r))}),s.models.length===0&&e.jsx("div",{className:"text-center text-[11px] text-dark-muted py-3",children:t("models.noModelsInProvider")})]})]},s.provider)}),P.length===0&&M.length===0&&e.jsxs("div",{className:"text-center text-dark-muted py-6",children:[e.jsx(Vs,{size:36,className:"mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:t("models.emptyHint")})]})]})]}),e.jsx(ms,{isOpen:fs,onClose:()=>{G(!1),H("select"),R(null),E("")},title:Ee==="select"?t("chat.selectProvider"):(Q==null?void 0:Q.name)||t("models.providerConfig"),size:"xl",children:Ee==="select"?e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[ie.filter(s=>s.key!=="custom").map(s=>e.jsxs("button",{onClick:()=>Ve(s),className:"text-left p-3 rounded-lg border border-dark-border bg-dark-bg hover:border-accent-blue transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(be,{size:14,className:"text-accent-blue"}),e.jsx("span",{className:"text-sm font-medium",children:s.name})]}),e.jsx("div",{className:"text-xs text-dark-muted",children:s.defaultModel})]},s.key)),e.jsxs("button",{onClick:Pe,className:"text-left p-3 rounded-lg border border-dashed border-dark-border bg-dark-bg hover:border-accent-blue transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ws,{size:14,className:"text-accent-blue"}),e.jsx("span",{className:"text-sm font-medium",children:t("models.customProvider")})]}),e.jsx("div",{className:"text-xs text-dark-muted",children:t("models.customProviderDesc")})]})]})}):e.jsxs("div",{className:"space-y-3",children:[D==="custom"&&e.jsxs("div",{className:"space-y-3",children:[L&&L.keys.length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:t("models.editExistingConfig")}),e.jsxs("select",{value:gs,onChange:s=>{const a=s.target.value;a?Ns(a):(E(""),j(l=>({...l,providerKey:"",modelIds:"",baseUrl:"",apiType:"",apiKeys:""})))},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:[e.jsx("option",{value:"",children:t("models.newCustomProviderOption")}),L.keys.map(s=>e.jsx("option",{value:s,children:s},s))]}),e.jsx("div",{className:"text-[11px] text-dark-muted/60 mt-1",children:t("models.editExistingConfigHint")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:t("models.providerNameLabel")}),e.jsx("input",{value:m.providerKey,onChange:s=>j(a=>({...a,providerKey:s.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:t("models.providerNamePlaceholder")})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm text-dark-muted mb-1",children:["API Keys",(ts=(ss=n==null?void 0:n.providers)==null?void 0:ss[D==="custom"?m.providerKey.trim():D||""])!=null&&ts.hasApiKey?"":" *",e.jsx("span",{className:"text-dark-muted/60 text-xs",children:(ls=(as=n==null?void 0:n.providers)==null?void 0:as[D==="custom"?m.providerKey.trim():D||""])!=null&&ls.hasApiKey?t("models.apiKeysHintConfigured"):t("models.apiKeysHintNew")})]}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{rows:3,value:m.apiKeys,onChange:s=>j(a=>({...a,apiKeys:s.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:t("models.apiKeyMultiPlaceholder")}),e.jsx("button",{onClick:()=>X(s=>!s),className:"absolute right-2 top-2 text-dark-muted hover:text-white",children:vs?e.jsx(Ys,{size:14}):e.jsx(Qs,{size:14})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:t("models.modelIdLabel")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:m.modelIds,onChange:s=>{const a=s.target.value;j(l=>({...l,modelIds:a})),I(()=>{const l=new Set;for(const c of a.split(",")){const r=c.trim().split("|")[0].trim();r&&F.some(d=>d.id===r)&&l.add(r)}return l})},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:(Q==null?void 0:Q.defaultModel)||t("models.modelIdPlaceholder")}),e.jsxs("button",{onClick:ws,disabled:Ne||!m.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:t("models.fetchModelsTitle"),children:[Ne?e.jsx(te,{size:13,className:"animate-spin"}):e.jsx(Js,{size:13}),t(Ne?"models.fetchingModels":"models.fetchModels")]}),e.jsxs("button",{onClick:Cs,disabled:we||!m.baseUrl,className:"inline-flex items-center gap-1 px-3 py-2 rounded text-sm border border-accent-yellow/30 text-accent-yellow hover:bg-accent-yellow/10 disabled:opacity-50 whitespace-nowrap",title:t("models.testConnectionTitle"),children:[we?e.jsx(te,{size:13,className:"animate-spin"}):e.jsx(Xs,{size:13}),t(we?"models.testingConnection":"models.testConnection")]}),e.jsxs("button",{onClick:Us,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:t("models.catalogSearchTitle"),children:[e.jsx(ae,{size:13}),t("models.catalogSearch")]})]}),ce&&e.jsxs("div",{className:`mt-1 text-xs ${ce.ok?"text-accent-green":"text-accent-red"}`,children:[ce.ok?"✓ ":"✗ ",ce.message]}),Ge&&e.jsx("div",{className:"mt-1 text-xs text-accent-red",children:Ge}),F.length===0&&Ce.length>0&&e.jsxs("div",{className:"mt-2 border border-dark-border rounded-lg bg-dark-bg p-2",children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsxs("span",{className:"text-xs text-dark-muted",children:[t("models.configuredPanelPrefix"),e.jsx("strong",{className:"text-dark-text",children:Ce.length}),t("models.configuredPanelSuffix"),e.jsx("span",{className:"text-accent-green/70",children:t("models.configuredPanelHint")})]})}),e.jsx("div",{className:"max-h-48 overflow-y-auto custom-scrollbar grid grid-cols-2 sm:grid-cols-3 gap-1",children:Ce.map(s=>{const a=m.modelIds.split(",").map(J).filter(Boolean).includes(s.id);return e.jsxs("div",{role:"checkbox","aria-checked":a,tabIndex:-1,onMouseDown:l=>l.preventDefault(),onClick:()=>Ts(s),className:`flex items-center gap-1.5 px-2 py-1 rounded cursor-pointer text-xs transition-colors select-none ${a?"bg-accent-green/20 text-accent-green border border-accent-green/30":"hover:bg-dark-hover border border-transparent"}`,children:[a?e.jsx(be,{size:10}):e.jsx("div",{className:"w-2.5 h-2.5 rounded border border-dark-border"}),e.jsx("span",{className:"truncate",children:s.name||s.id}),s.isGlobalDefault&&e.jsx("span",{className:"text-[9px] px-1 rounded bg-accent-green/20 shrink-0",children:t("models.globalShort")}),s.isPlanDefault&&e.jsx("span",{className:"text-[9px] px-1 rounded bg-accent-blue/20 shrink-0",children:"Plan"}),s.isActDefault&&e.jsx("span",{className:"text-[9px] px-1 rounded bg-accent-yellow/20 shrink-0",children:"Act"}),s.isGoalDefault&&e.jsx("span",{className:"text-[9px] px-1 rounded bg-accent-purple/20 shrink-0",children:"Goal"})]},s.id)})})]}),F.length>0&&e.jsxs("div",{className:"mt-2 border border-dark-border rounded-lg bg-dark-bg p-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-xs text-dark-muted",children:[t("models.fetchedPanelPrefix"),e.jsx("strong",{className:"text-dark-text",children:F.length}),t("models.fetchedPanelMiddle"),e.jsx("strong",{className:"text-accent-blue",children:ne.size}),t("models.fetchedPanelSuffix"),e.jsx("span",{className:"text-accent-blue/70",children:t("models.fetchedPanelHint")})]}),e.jsx("button",{onClick:()=>{q([]),I(new Set)},className:"px-2 py-0.5 text-[10px] border border-dark-border rounded hover:bg-dark-hover",children:t("models.close")})]}),e.jsxs("div",{className:"relative mb-2",children:[e.jsx(ae,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-dark-muted"}),e.jsx("input",{value:de,onChange:s=>ee(s.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("models.modelSearchPlaceholder")})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto custom-scrollbar grid grid-cols-2 sm:grid-cols-3 gap-1",children:F.filter(s=>!de||s.id.toLowerCase().includes(de.toLowerCase())||s.name.toLowerCase().includes(de.toLowerCase())).map(s=>{const a=ne.has(s.id);return e.jsxs("div",{role:"checkbox","aria-checked":a,tabIndex:-1,onMouseDown:l=>l.preventDefault(),onClick:()=>Ps(s.id),className:`flex items-center gap-1.5 px-2 py-1 rounded cursor-pointer text-xs transition-colors select-none ${a?"bg-accent-blue/20 text-accent-blue border border-accent-blue/30":"hover:bg-dark-hover border border-transparent"}`,children:[a?e.jsx(be,{size:10}):e.jsx("div",{className:"w-2.5 h-2.5 rounded border border-dark-border"}),e.jsx("span",{className:"truncate",children:s.id})]},s.id)})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:"Base URL"}),e.jsx("input",{value:m.baseUrl,onChange:s=>{j(a=>({...a,baseUrl:s.target.value})),B(null)},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"}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none mt-2",children:[e.jsx("button",{type:"button",role:"switch","aria-checked":m.fullPath,onClick:()=>{j(s=>({...s,fullPath:!s.fullPath})),B(null)},className:`relative w-9 h-5 rounded-full transition-colors shrink-0 ${m.fullPath?"bg-accent-green":"bg-dark-border"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0 w-4 h-4 rounded-full bg-white shadow transition-transform ${m.fullPath?"translate-x-[18px]":"translate-x-0.5"}`})}),e.jsx("span",{className:"text-sm text-dark-muted",children:t("models.fullPathLabel")})]}),e.jsx("div",{className:"text-[11px] text-dark-muted/60 mt-1",children:t("models.fullPathHint")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:t("models.apiTypeLabel")}),e.jsxs("select",{value:m.apiType,onChange:s=>{j(a=>({...a,apiType:s.target.value})),B(null)},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:[e.jsx("option",{value:"",children:t("models.apiTypeAutoDetect")}),ps.map(s=>e.jsx("option",{value:s,children:fe[s]},s))]}),e.jsx("div",{className:"text-[11px] text-dark-muted/60 mt-1",children:t("models.apiTypeHint")})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm text-dark-muted mb-1",children:[t("models.modelApiTypeLabel"),e.jsx("span",{className:"text-dark-muted/60 text-xs",children:t("models.modelApiTypeHint")})]}),e.jsx("div",{className:"border border-dark-border rounded-lg divide-y divide-dark-border max-h-40 overflow-y-auto custom-scrollbar",children:(()=>{const s=m.modelIds.split(",").map(J).filter(Boolean);return s.length===0?e.jsx("div",{className:"px-3 py-2 text-xs text-dark-muted",children:t("models.modelApiTypeEmpty")}):s.map(a=>{var l;return e.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-1.5",children:[e.jsx("span",{className:"text-xs truncate min-w-0",children:a}),e.jsxs("select",{value:((l=m.modelOverrides[a])==null?void 0:l.apiType)||"",onChange:c=>j(r=>({...r,modelOverrides:{...r.modelOverrides,[a]:{...r.modelOverrides[a]||{},apiType:c.target.value}}})),className:"w-52 px-2 py-1 text-xs bg-dark-bg border border-dark-border rounded focus:outline-none focus:border-accent-blue",children:[e.jsx("option",{value:"",children:"继承 Provider(默认)"}),ps.map(c=>e.jsx("option",{value:c,children:fe[c]},c))]})]},a)})})()})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:m.setDefault,onChange:s=>j(a=>({...a,setDefault:s.target.checked})),className:"accent-accent-blue"}),e.jsx("span",{className:"text-sm text-dark-muted",children:t("models.setDefaultProvider")})]}),ze&&e.jsx("div",{className:"text-sm text-accent-red",children:ze}),e.jsxs("div",{className:"flex justify-between gap-2 pt-2",children:[e.jsx("div",{children:V&&((os=(rs=n==null?void 0:n.providers)==null?void 0:rs[V])==null?void 0:os.hasApiKey)&&e.jsx("button",{onClick:async()=>{if(confirm(t("models.deleteProviderConfirm",{key:V})))try{await h.config.provider.delete(V),G(!1),H("select"),R(null),E(""),await _(),await k()}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:t("models.deleteProvider")})}),e.jsx("button",{onClick:()=>{H("select"),R(null),E(""),G(!1)},className:"px-4 py-2 rounded border border-dark-border hover:bg-dark-hover transition-colors text-sm",children:t("common.cancel")}),e.jsx("button",{onClick:Rs,disabled:$e,className:"px-4 py-2 bg-accent-blue text-white rounded hover:bg-accent-blue/80 transition-colors text-sm disabled:opacity-50",children:t($e?"common.saving":"common.save")})]})]})}),e.jsx(ms,{isOpen:Ds,onClose:()=>We(!1),title:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ae,{size:15,className:"text-accent-green"}),t("models.catalogTitle")]}),size:"2xl",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ae,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-dark-muted"}),e.jsx("input",{value:Te,onChange:s=>Es(s.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:t("models.catalogSearchPlaceholder"),autoFocus:!0})]}),e.jsxs("label",{className:"inline-flex items-center gap-1.5 text-xs text-dark-muted whitespace-nowrap cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:xe,onChange:s=>{const a=s.target.checked;Is(a),se(Te,{reason:pe,tool:a})},className:"accent-accent-green"}),t("models.catalogOnlyToolCall")]}),e.jsxs("label",{className:"inline-flex items-center gap-1.5 text-xs text-dark-muted whitespace-nowrap cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:pe,onChange:s=>{const a=s.target.checked;Ms(a),se(Te,{reason:a,tool:xe})},className:"accent-accent-green"}),t("models.catalogOnlyReasoning")]})]}),Xe&&e.jsx("div",{className:"text-xs text-accent-red bg-accent-red/10 p-2 rounded",children:Xe}),Ss?e.jsxs("div",{className:"flex items-center justify-center py-10 text-dark-muted",children:[e.jsx(te,{size:18,className:"animate-spin mr-2"})," ",t("models.searching")]}):e.jsx("div",{className:"max-h-96 overflow-y-auto custom-scrollbar border border-dark-border rounded-lg divide-y divide-dark-border",children:Qe.length===0?e.jsx("div",{className:"py-10 text-center text-dark-muted text-sm",children:t("models.catalogNoResults")}):Qe.map(s=>{var a,l,c;return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 hover:bg-dark-hover",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-dark-text truncate",children:s.model.name||s.model.id}),e.jsx("code",{className:"text-[10px] px-1.5 py-0.5 bg-dark-bg border border-dark-border rounded text-dark-muted truncate",children:s.model.id}),s.model.reasoning&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-accent-yellow/10 text-accent-yellow rounded",children:t("models.badgeReasoning")}),s.model.tool_call&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-accent-blue/10 text-accent-blue rounded",children:t("models.badgeToolCall")}),s.model.attachment&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-accent-green/10 text-accent-green rounded",children:t("models.badgeMultimodal")})]}),e.jsxs("div",{className:"text-[11px] text-dark-muted mt-0.5",children:[s.providerName,(a=s.model.limit)!=null&&a.context?` · ${t("models.ctxLimit",{k:(s.model.limit.context/1e3).toFixed(0)})}`:"",(l=s.model.limit)!=null&&l.output?` · ${t("models.outLimit",{k:(s.model.limit.output/1e3).toFixed(0)})}`:"",((c=s.model.cost)==null?void 0:c.input)!==void 0?` · $${s.model.cost.input}/M in / $${s.model.cost.output}/M out`:""]})]}),e.jsxs("button",{onClick:()=>As(s),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:t("models.catalogAddTitle"),children:[e.jsx(Me,{size:12})," ",t("models.add")]})]},`${s.providerId}:${s.model.id}`)})}),e.jsx("div",{className:"text-[11px] text-dark-muted/60",children:t("models.catalogSourceHint")})]})})]})})}function ve({title:y,value:b,color:C}){const t={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 e.jsxs("div",{className:`${t[C]} rounded-lg p-3`,children:[e.jsx("div",{className:"text-xs opacity-70",children:y}),e.jsx("div",{className:"text-xl font-semibold",children:b})]})}function ye({label:y,value:b}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-dark-muted",children:y}),e.jsx("div",{children:b})]})}function xs({label:y,value:b,onChange:C}){return e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:y}),e.jsx("input",{type:"number",min:"0",value:b,onChange:t=>C(parseInt(t.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{mt as ModelsView,mt as default};