nextclaw 0.17.3 → 0.17.4
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.
- package/package.json +8 -8
- package/ui-dist/assets/{ChannelsList-uKmkpD25.js → ChannelsList-DZWam3Ob.js} +1 -1
- package/ui-dist/assets/{ChatPage-CslhBPfT.js → ChatPage-YBL7iJ1X.js} +27 -27
- package/ui-dist/assets/{MarketplacePage-DE0QjYVv.js → MarketplacePage-2tWWgwAb.js} +1 -1
- package/ui-dist/assets/MarketplacePage-BorWJftJ.js +1 -0
- package/ui-dist/assets/{McpMarketplacePage-CeLvv1xy.js → McpMarketplacePage-N-fB4HID.js} +1 -1
- package/ui-dist/assets/{ModelConfig-D1JtGtQv.js → ModelConfig-DvsBTUiE.js} +1 -1
- package/ui-dist/assets/{ProviderScopedModelInput-SAJH6nkC.js → ProviderScopedModelInput-D9woCARc.js} +1 -1
- package/ui-dist/assets/{ProvidersList-1rKi3aQT.js → ProvidersList-D-qPGgC4.js} +1 -1
- package/ui-dist/assets/{RemoteAccessPage-bIAKxDky.js → RemoteAccessPage-COnjm8_x.js} +1 -1
- package/ui-dist/assets/{RuntimeConfig-BTk9319O.js → RuntimeConfig-BHpqcaHm.js} +1 -1
- package/ui-dist/assets/{SearchConfig-EjeszXbv.js → SearchConfig-DIT6M65Q.js} +1 -1
- package/ui-dist/assets/{SecretsConfig-cnAXvREZ.js → SecretsConfig-Cefg1LFJ.js} +1 -1
- package/ui-dist/assets/{SessionsConfig-BIXiDaK2.js → SessionsConfig-BZnmVTIu.js} +1 -1
- package/ui-dist/assets/{index-8XNPYwJu.js → index-DHmCjcxq.js} +2 -2
- package/ui-dist/assets/{security-config-CGazBahs.js → security-config-DEgOD4VX.js} +1 -1
- package/ui-dist/assets/{useConfirmDialog-D6HxybcM.js → useConfirmDialog-CuQqiPx7.js} +1 -1
- package/ui-dist/index.html +1 -1
- package/ui-dist/assets/MarketplacePage-BZQW70ti.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,p as r,u as i}from"./i18n-hM3v-3YG.js";import{c as a,n as o,r as s,u as c}from"./dist-RWNFhxvR.js";import{c as l,s as u}from"./chunk-JZWAC4HX-CxfKRD7X.js";import{t as d}from"./useMutation-DBTWPbTg.js";import{B as f,C as p,E as m,F as h,G as g,I as _,N as v,R as y,S as b,T as x,U as S,W as C,a as w,i as T,n as ee,r as E,t as D,w as te,x as ne,z as re}from"./select-DF-AUoie.js";import{t as ie}from"./dist-B6VMuIQN.js";import{t as O}from"./createLucideIcon-C7MmdIX3.js";import{i as ae}from"./DocBrowserContext-DN5tjUoS.js";import{r as oe}from"./index-8XNPYwJu.js";import{n as se,t as ce}from"./page-layout-Z1klaUFW.js";import{t as le}from"./useConfirmDialog-D6HxybcM.js";import{t as ue}from"./tabs-custom-CLksZ2bO.js";import{t as k}from"./skeleton-B0mmt1vo.js";import{r as A,t as de}from"./marketplace-localization-CxSTG9wr.js";var j=O(`PackageSearch`,[[`path`,{d:`M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14`,key:`e7tb2h`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`12`,key:`a4e8g8`}],[`circle`,{cx:`18.5`,cy:`15.5`,r:`2.5`,key:`b5zd12`}],[`path`,{d:`M20.27 17.27 22 19`,key:`1l4muz`}]]),M=e(n(),1),N=r(),[P,F]=S(`Tooltip`,[m]),I=m(),L=`TooltipProvider`,fe=700,R=`tooltip.open`,[z,B]=P(L),V=e=>{let{__scopeTooltip:t,delayDuration:n=fe,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=M.useRef(!0),s=M.useRef(!1),c=M.useRef(0);return M.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,N.jsx)(z,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:M.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:M.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:M.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};V.displayName=L;var H=`Tooltip`,[pe,U]=P(H),W=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=B(H,e.__scopeTooltip),l=I(t),[u,d]=M.useState(null),p=f(),m=M.useRef(0),h=o??c.disableHoverableContent,g=s??c.delayDuration,_=M.useRef(!1),[v,y]=re({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(R))):c.onClose(),a?.(e)},caller:H}),b=M.useMemo(()=>v?_.current?`delayed-open`:`instant-open`:`closed`,[v]),S=M.useCallback(()=>{window.clearTimeout(m.current),m.current=0,_.current=!1,y(!0)},[y]),C=M.useCallback(()=>{window.clearTimeout(m.current),m.current=0,y(!1)},[y]),w=M.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{_.current=!0,y(!0),m.current=0},g)},[g,y]);return M.useEffect(()=>()=>{m.current&&=(window.clearTimeout(m.current),0)},[]),(0,N.jsx)(x,{...l,children:(0,N.jsx)(pe,{scope:t,contentId:p,open:v,stateAttribute:b,trigger:u,onTriggerChange:d,onTriggerEnter:M.useCallback(()=>{c.isOpenDelayedRef.current?w():S()},[c.isOpenDelayedRef,w,S]),onTriggerLeave:M.useCallback(()=>{h?C():(window.clearTimeout(m.current),m.current=0)},[C,h]),onOpen:S,onClose:C,disableHoverableContent:h,children:n})})};W.displayName=H;var G=`TooltipTrigger`,me=M.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=U(G,n),a=B(G,n),o=I(n),s=C(t,M.useRef(null),i.onTriggerChange),c=M.useRef(!1),l=M.useRef(!1),u=M.useCallback(()=>c.current=!1,[]);return M.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,N.jsx)(b,{asChild:!0,...o,children:(0,N.jsx)(_.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:g(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:g(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:g(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:g(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:g(e.onBlur,i.onClose),onClick:g(e.onClick,i.onClose)})})});me.displayName=G;var he=`TooltipPortal`,[ge,_e]=P(he,{forceMount:void 0}),ve=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=U(he,t);return(0,N.jsx)(ge,{scope:t,forceMount:n,children:(0,N.jsx)(ie,{present:n||a.open,children:(0,N.jsx)(v,{asChild:!0,container:i,children:r})})})};ve.displayName=he;var K=`TooltipContent`,ye=M.forwardRef((e,t)=>{let n=_e(K,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=U(K,e.__scopeTooltip);return(0,N.jsx)(ie,{present:r||o.open,children:o.disableHoverableContent?(0,N.jsx)(we,{side:i,...a,ref:t}):(0,N.jsx)(be,{side:i,...a,ref:t})})}),be=M.forwardRef((e,t)=>{let n=U(K,e.__scopeTooltip),r=B(K,e.__scopeTooltip),i=M.useRef(null),a=C(t,i),[o,s]=M.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=M.useCallback(()=>{s(null),d(!1)},[d]),p=M.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Oe(r,De(r,n.getBoundingClientRect())),a=ke(t.getBoundingClientRect());s(je([...i,...a])),d(!0)},[d]);return M.useEffect(()=>()=>f(),[f]),M.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),M.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Ae(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,N.jsx)(we,{...e,ref:a})}),[xe,Se]=P(H,{isInside:!1}),Ce=y(`TooltipContent`),we=M.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=U(K,n),l=I(n),{onClose:u}=c;return M.useEffect(()=>(document.addEventListener(R,u),()=>document.removeEventListener(R,u)),[u]),M.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,N.jsx)(h,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,N.jsxs)(te,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,N.jsx)(Ce,{children:r}),(0,N.jsx)(xe,{scope:n,isInside:!0,children:(0,N.jsx)(ne,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});ye.displayName=K;var Te=`TooltipArrow`,Ee=M.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=I(n);return Se(Te,n).isInside?null:(0,N.jsx)(p,{...i,...r,ref:t})});Ee.displayName=Te;function De(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function Oe(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function ke(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function Ae(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function je(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),Me(t)}function Me(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Ne=V,Pe=W,Fe=me,Ie=ve,Le=ye,Re=Ne,q=Pe,J=Fe,Y=M.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,N.jsx)(Ie,{children:(0,N.jsx)(Le,{ref:r,sideOffset:t,className:i(`z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));Y.displayName=Le.displayName;function X(e){return e===`plugin`?`plugins`:e===`skill`?`skills`:`mcp`}async function ze(e){let t=new URLSearchParams,n=X(e.type);e.q?.trim()&&t.set(`q`,e.q.trim()),e.tag?.trim()&&t.set(`tag`,e.tag.trim()),e.sort&&t.set(`sort`,e.sort),typeof e.page==`number`&&Number.isFinite(e.page)&&t.set(`page`,String(Math.max(1,Math.trunc(e.page)))),typeof e.pageSize==`number`&&Number.isFinite(e.pageSize)&&t.set(`pageSize`,String(Math.max(1,Math.trunc(e.pageSize))));let r=t.toString(),i=await s.get(r?`/api/marketplace/${n}/items?${r}`:`/api/marketplace/${n}/items`);if(!i.ok)throw Error(i.error.message);return i.data}async function Be(e){let t=await s.get(`/api/marketplace/skills/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw Error(t.error.message);return t.data}async function Ve(e){let t=await s.get(`/api/marketplace/plugins/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw Error(t.error.message);return t.data}async function He(e){let t=X(e.type),n=await s.post(`/api/marketplace/${t}/install`,e);if(!n.ok)throw Error(n.error.message);return n.data}async function Ue(e){let t=X(e),n=await s.get(`/api/marketplace/${t}/installed`);if(!n.ok)throw Error(n.error.message);return n.data}async function We(e){let t=X(e.type),n=await s.post(`/api/marketplace/${t}/manage`,e);if(!n.ok)throw Error(n.error.message);return n.data}function Ge(e){return Array.from(new Set(e.map(e=>e.spec).filter(Boolean)))}function Ke(e){let t=new Date().toISOString();return e.result.type===`skill`?{type:`skill`,spec:e.result.spec,id:e.request.skill??e.result.spec,label:e.request.skill??e.result.name??e.result.spec,source:`workspace`,installPath:e.request.installPath,installedAt:t}:{type:e.result.type,spec:e.result.spec,id:e.result.name??e.result.spec,label:e.result.name??e.result.spec,source:`marketplace`,origin:`marketplace`,enabled:e.request.enabled??!0,runtimeStatus:e.request.enabled===!1?`disabled`:`ready`,installedAt:t}}function qe(e,t){return!!(t.spec&&e.spec===t.spec||t.id&&e.id===t.id)}function Je(e,t){return t??{type:e,total:0,specs:[],records:[]}}function Ye(e){let t=Je(e.result.type,e.view),n=Ke(e),r=t.records.findIndex(e=>qe(e,{id:n.id,spec:n.spec})),i=[...t.records];return r>=0?i[r]={...i[r],...n}:i.unshift(n),{...t,type:e.result.type,records:i,specs:Ge(i),total:i.length}}function Xe(e){let t=Je(e.result.type,e.view);if(e.result.action===`uninstall`||e.result.action===`remove`){let n=t.records.filter(t=>!qe(t,{id:e.result.id,spec:e.request.spec}));return{...t,records:n,specs:Ge(n),total:n.length}}let n=t.records.map(t=>qe(t,{id:e.result.id,spec:e.request.spec})?e.result.action===`disable`?{...t,enabled:!1,runtimeStatus:`disabled`}:{...t,enabled:!0,runtimeStatus:`ready`}:t);return{...t,records:n,specs:Ge(n),total:n.length}}function Ze(e){return a({queryKey:[`marketplace-items`,e],queryFn:()=>ze(e),placeholderData:(t,n)=>{let r=n?.queryKey?.[1];if(!(!r||typeof r!=`object`||!r))return(`type`in r?r.type:void 0)===e.type?t:void 0},staleTime:15e3})}function Qe(e){return a({queryKey:[`marketplace-installed`,e],queryFn:()=>Ue(e),staleTime:1e4})}function $e(){let e=c();return d({mutationFn:e=>He(e),onSuccess:(n,r)=>{e.setQueryData([`marketplace-installed`,n.type],e=>Ye({view:e,request:r,result:n})),e.invalidateQueries({queryKey:[`marketplace-installed`,n.type],refetchType:`inactive`}),n.type===`plugin`&&e.invalidateQueries({queryKey:[`ncp-session-types`]});let i=n.type===`plugin`?t(`marketplaceInstallSuccessPlugin`):t(`marketplaceInstallSuccessSkill`);o.success(n.message||i)},onError:e=>{o.error(e.message||t(`marketplaceInstallFailed`))}})}function et(){let e=c();return d({mutationFn:e=>We(e),onSuccess:(n,r)=>{e.setQueryData([`marketplace-installed`,n.type],e=>Xe({view:e,request:r,result:n})),e.invalidateQueries({queryKey:[`marketplace-installed`,n.type],refetchType:`inactive`}),n.type===`plugin`&&e.invalidateQueries({queryKey:[`ncp-session-types`]});let i=n.action===`enable`?t(`marketplaceEnableSuccess`):n.action===`disable`?t(`marketplaceDisableSuccess`):t(`marketplaceUninstallSuccess`);o.success(n.message||i)},onError:e=>{o.error(e.message||t(`marketplaceOperationFailed`))}})}function tt(e){return(0,N.jsx)(`div`,{className:`mb-4`,children:(0,N.jsxs)(`div`,{className:`flex gap-3 items-center`,children:[(0,N.jsxs)(`div`,{className:`flex-1 min-w-0 relative`,children:[(0,N.jsx)(j,{className:`h-4 w-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2`}),(0,N.jsx)(`input`,{value:e.searchText,onChange:t=>e.onSearchTextChange(t.target.value),placeholder:e.searchPlaceholder,className:`w-full h-9 border border-gray-200/80 rounded-xl pl-9 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40`})]}),e.scope===`all`&&(0,N.jsxs)(D,{value:e.sort,onValueChange:t=>e.onSortChange(t),children:[(0,N.jsx)(T,{className:`h-9 w-[150px] shrink-0 rounded-lg`,children:(0,N.jsx)(w,{})}),(0,N.jsxs)(ee,{children:[(0,N.jsx)(E,{value:`relevance`,children:t(`marketplaceSortRelevance`)}),(0,N.jsx)(E,{value:`updated`,children:t(`marketplaceSortUpdated`)})]})]})]})})}function nt(e){return(0,N.jsx)(N.Fragment,{children:Array.from({length:e.count},(e,t)=>(0,N.jsx)(`article`,{className:`rounded-2xl border border-gray-200/40 bg-white px-5 py-4 shadow-sm`,children:(0,N.jsxs)(`div`,{className:`flex items-start gap-3.5 justify-between`,children:[(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 gap-3`,children:[(0,N.jsx)(k,{className:`h-10 w-10 shrink-0 rounded-xl`}),(0,N.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2 pt-0.5`,children:[(0,N.jsx)(k,{className:`h-4 w-32 max-w-[70%]`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(k,{className:`h-3 w-12`}),(0,N.jsx)(k,{className:`h-3 w-24`})]}),(0,N.jsx)(k,{className:`h-3 w-full`})]})]}),(0,N.jsx)(k,{className:`h-8 w-20 shrink-0 rounded-xl`})]})},`marketplace-skeleton-${t}`))})}function rt(e){return(0,N.jsxs)(`div`,{className:`mt-4 flex items-center justify-end gap-2`,children:[(0,N.jsx)(`button`,{className:`h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40`,onClick:e.onPrev,disabled:e.page<=1||e.busy,children:t(`prev`)}),(0,N.jsx)(`div`,{className:`text-sm text-gray-600 min-w-20 text-center`,children:e.totalPages===0?`0 / 0`:`${e.page} / ${e.totalPages}`}),(0,N.jsx)(`button`,{className:`h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40`,onClick:e.onNext,disabled:e.totalPages===0||e.page>=e.totalPages||e.busy,children:t(`next`)})]})}var it=12,at=it;function ot(e){return(e??``).trim().toLowerCase()}function Z(e,t){let n=ot(t);return n.length>0?`${e}:${n}`:``}function st(e){let t=new Map;for(let n of e){let e=[n.install.spec,n.slug,n.id];for(let r of e){let e=Z(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function ct(e){let t=new Map;for(let n of e){let e=[n.spec,n.id,n.label];for(let r of e){let e=Z(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function lt(e,t){let n=[e.install.spec,e.slug,e.id];for(let r of n){let n=Z(e.type,r);if(!n)continue;let i=t.get(n);if(i)return i}}function ut(e,t){return t.get(Z(e.type,e.spec))||t.get(Z(e.type,e.id))||t.get(Z(e.type,e.label))}function dt(e,t,n,r){let i=ot(n);if(!i)return!0;let a=A(t?.summaryI18n,t?.summary,r);return[e.id,e.spec,e.label,t?.name,t?.slug,t?.summary,a,...t?.tags??[]].map(e=>ot(e)).filter(Boolean).some(e=>e.includes(i))}function ft(e){let t=[`bg-amber-600`,`bg-orange-500`,`bg-yellow-600`,`bg-emerald-600`,`bg-teal-600`,`bg-cyan-600`,`bg-stone-600`,`bg-rose-500`,`bg-violet-500`],n=0;for(let t=0;t<e.length;t++)n=e.charCodeAt(t)+((n<<5)-n);return t[Math.abs(n)%t.length]}function pt({name:e,fallback:t}){let n=e||t,r=n.substring(0,2).toUpperCase();return(0,N.jsx)(`div`,{className:i(`flex items-center justify-center w-10 h-10 rounded-xl text-white font-semibold text-sm shrink-0`,ft(n)),children:r})}function Q(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function $(e){let t=e.metadataRaw?.trim()||`-`,n=e.contentRaw?.trim()||`-`,r=e.summary?.trim(),i=e.description?.trim(),a=!!i&&i!==r,o=`<!doctype html>
|
|
1
|
+
import{_ as e,i as t,m as n,p as r,u as i}from"./i18n-hM3v-3YG.js";import{c as a,n as o,r as s,u as c}from"./dist-RWNFhxvR.js";import{c as l,s as u}from"./chunk-JZWAC4HX-CxfKRD7X.js";import{t as d}from"./useMutation-DBTWPbTg.js";import{B as f,C as p,E as m,F as h,G as g,I as _,N as v,R as y,S as b,T as x,U as S,W as C,a as w,i as T,n as ee,r as E,t as D,w as te,x as ne,z as re}from"./select-DF-AUoie.js";import{t as ie}from"./dist-B6VMuIQN.js";import{t as O}from"./createLucideIcon-C7MmdIX3.js";import{i as ae}from"./DocBrowserContext-DN5tjUoS.js";import{r as oe}from"./index-DHmCjcxq.js";import{n as se,t as ce}from"./page-layout-Z1klaUFW.js";import{t as le}from"./useConfirmDialog-CuQqiPx7.js";import{t as ue}from"./tabs-custom-CLksZ2bO.js";import{t as k}from"./skeleton-B0mmt1vo.js";import{r as A,t as de}from"./marketplace-localization-CxSTG9wr.js";var j=O(`PackageSearch`,[[`path`,{d:`M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14`,key:`e7tb2h`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`12`,key:`a4e8g8`}],[`circle`,{cx:`18.5`,cy:`15.5`,r:`2.5`,key:`b5zd12`}],[`path`,{d:`M20.27 17.27 22 19`,key:`1l4muz`}]]),M=e(n(),1),N=r(),[P,F]=S(`Tooltip`,[m]),I=m(),L=`TooltipProvider`,fe=700,R=`tooltip.open`,[z,B]=P(L),V=e=>{let{__scopeTooltip:t,delayDuration:n=fe,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=M.useRef(!0),s=M.useRef(!1),c=M.useRef(0);return M.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,N.jsx)(z,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:M.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:M.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:M.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};V.displayName=L;var H=`Tooltip`,[pe,U]=P(H),W=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=B(H,e.__scopeTooltip),l=I(t),[u,d]=M.useState(null),p=f(),m=M.useRef(0),h=o??c.disableHoverableContent,g=s??c.delayDuration,_=M.useRef(!1),[v,y]=re({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(R))):c.onClose(),a?.(e)},caller:H}),b=M.useMemo(()=>v?_.current?`delayed-open`:`instant-open`:`closed`,[v]),S=M.useCallback(()=>{window.clearTimeout(m.current),m.current=0,_.current=!1,y(!0)},[y]),C=M.useCallback(()=>{window.clearTimeout(m.current),m.current=0,y(!1)},[y]),w=M.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{_.current=!0,y(!0),m.current=0},g)},[g,y]);return M.useEffect(()=>()=>{m.current&&=(window.clearTimeout(m.current),0)},[]),(0,N.jsx)(x,{...l,children:(0,N.jsx)(pe,{scope:t,contentId:p,open:v,stateAttribute:b,trigger:u,onTriggerChange:d,onTriggerEnter:M.useCallback(()=>{c.isOpenDelayedRef.current?w():S()},[c.isOpenDelayedRef,w,S]),onTriggerLeave:M.useCallback(()=>{h?C():(window.clearTimeout(m.current),m.current=0)},[C,h]),onOpen:S,onClose:C,disableHoverableContent:h,children:n})})};W.displayName=H;var G=`TooltipTrigger`,me=M.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=U(G,n),a=B(G,n),o=I(n),s=C(t,M.useRef(null),i.onTriggerChange),c=M.useRef(!1),l=M.useRef(!1),u=M.useCallback(()=>c.current=!1,[]);return M.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,N.jsx)(b,{asChild:!0,...o,children:(0,N.jsx)(_.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:g(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:g(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:g(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:g(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:g(e.onBlur,i.onClose),onClick:g(e.onClick,i.onClose)})})});me.displayName=G;var he=`TooltipPortal`,[ge,_e]=P(he,{forceMount:void 0}),ve=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=U(he,t);return(0,N.jsx)(ge,{scope:t,forceMount:n,children:(0,N.jsx)(ie,{present:n||a.open,children:(0,N.jsx)(v,{asChild:!0,container:i,children:r})})})};ve.displayName=he;var K=`TooltipContent`,ye=M.forwardRef((e,t)=>{let n=_e(K,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=U(K,e.__scopeTooltip);return(0,N.jsx)(ie,{present:r||o.open,children:o.disableHoverableContent?(0,N.jsx)(we,{side:i,...a,ref:t}):(0,N.jsx)(be,{side:i,...a,ref:t})})}),be=M.forwardRef((e,t)=>{let n=U(K,e.__scopeTooltip),r=B(K,e.__scopeTooltip),i=M.useRef(null),a=C(t,i),[o,s]=M.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=M.useCallback(()=>{s(null),d(!1)},[d]),p=M.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Oe(r,De(r,n.getBoundingClientRect())),a=ke(t.getBoundingClientRect());s(je([...i,...a])),d(!0)},[d]);return M.useEffect(()=>()=>f(),[f]),M.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),M.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Ae(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,N.jsx)(we,{...e,ref:a})}),[xe,Se]=P(H,{isInside:!1}),Ce=y(`TooltipContent`),we=M.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=U(K,n),l=I(n),{onClose:u}=c;return M.useEffect(()=>(document.addEventListener(R,u),()=>document.removeEventListener(R,u)),[u]),M.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,N.jsx)(h,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,N.jsxs)(te,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,N.jsx)(Ce,{children:r}),(0,N.jsx)(xe,{scope:n,isInside:!0,children:(0,N.jsx)(ne,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});ye.displayName=K;var Te=`TooltipArrow`,Ee=M.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=I(n);return Se(Te,n).isInside?null:(0,N.jsx)(p,{...i,...r,ref:t})});Ee.displayName=Te;function De(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function Oe(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function ke(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function Ae(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function je(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),Me(t)}function Me(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Ne=V,Pe=W,Fe=me,Ie=ve,Le=ye,Re=Ne,q=Pe,J=Fe,Y=M.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,N.jsx)(Ie,{children:(0,N.jsx)(Le,{ref:r,sideOffset:t,className:i(`z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));Y.displayName=Le.displayName;function X(e){return e===`plugin`?`plugins`:e===`skill`?`skills`:`mcp`}async function ze(e){let t=new URLSearchParams,n=X(e.type);e.q?.trim()&&t.set(`q`,e.q.trim()),e.tag?.trim()&&t.set(`tag`,e.tag.trim()),e.sort&&t.set(`sort`,e.sort),typeof e.page==`number`&&Number.isFinite(e.page)&&t.set(`page`,String(Math.max(1,Math.trunc(e.page)))),typeof e.pageSize==`number`&&Number.isFinite(e.pageSize)&&t.set(`pageSize`,String(Math.max(1,Math.trunc(e.pageSize))));let r=t.toString(),i=await s.get(r?`/api/marketplace/${n}/items?${r}`:`/api/marketplace/${n}/items`);if(!i.ok)throw Error(i.error.message);return i.data}async function Be(e){let t=await s.get(`/api/marketplace/skills/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw Error(t.error.message);return t.data}async function Ve(e){let t=await s.get(`/api/marketplace/plugins/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw Error(t.error.message);return t.data}async function He(e){let t=X(e.type),n=await s.post(`/api/marketplace/${t}/install`,e);if(!n.ok)throw Error(n.error.message);return n.data}async function Ue(e){let t=X(e),n=await s.get(`/api/marketplace/${t}/installed`);if(!n.ok)throw Error(n.error.message);return n.data}async function We(e){let t=X(e.type),n=await s.post(`/api/marketplace/${t}/manage`,e);if(!n.ok)throw Error(n.error.message);return n.data}function Ge(e){return Array.from(new Set(e.map(e=>e.spec).filter(Boolean)))}function Ke(e){let t=new Date().toISOString();return e.result.type===`skill`?{type:`skill`,spec:e.result.spec,id:e.request.skill??e.result.spec,label:e.request.skill??e.result.name??e.result.spec,source:`workspace`,installPath:e.request.installPath,installedAt:t}:{type:e.result.type,spec:e.result.spec,id:e.result.name??e.result.spec,label:e.result.name??e.result.spec,source:`marketplace`,origin:`marketplace`,enabled:e.request.enabled??!0,runtimeStatus:e.request.enabled===!1?`disabled`:`ready`,installedAt:t}}function qe(e,t){return!!(t.spec&&e.spec===t.spec||t.id&&e.id===t.id)}function Je(e,t){return t??{type:e,total:0,specs:[],records:[]}}function Ye(e){let t=Je(e.result.type,e.view),n=Ke(e),r=t.records.findIndex(e=>qe(e,{id:n.id,spec:n.spec})),i=[...t.records];return r>=0?i[r]={...i[r],...n}:i.unshift(n),{...t,type:e.result.type,records:i,specs:Ge(i),total:i.length}}function Xe(e){let t=Je(e.result.type,e.view);if(e.result.action===`uninstall`||e.result.action===`remove`){let n=t.records.filter(t=>!qe(t,{id:e.result.id,spec:e.request.spec}));return{...t,records:n,specs:Ge(n),total:n.length}}let n=t.records.map(t=>qe(t,{id:e.result.id,spec:e.request.spec})?e.result.action===`disable`?{...t,enabled:!1,runtimeStatus:`disabled`}:{...t,enabled:!0,runtimeStatus:`ready`}:t);return{...t,records:n,specs:Ge(n),total:n.length}}function Ze(e){return a({queryKey:[`marketplace-items`,e],queryFn:()=>ze(e),placeholderData:(t,n)=>{let r=n?.queryKey?.[1];if(!(!r||typeof r!=`object`||!r))return(`type`in r?r.type:void 0)===e.type?t:void 0},staleTime:15e3})}function Qe(e){return a({queryKey:[`marketplace-installed`,e],queryFn:()=>Ue(e),staleTime:1e4})}function $e(){let e=c();return d({mutationFn:e=>He(e),onSuccess:(n,r)=>{e.setQueryData([`marketplace-installed`,n.type],e=>Ye({view:e,request:r,result:n})),e.invalidateQueries({queryKey:[`marketplace-installed`,n.type],refetchType:`inactive`}),n.type===`plugin`&&e.invalidateQueries({queryKey:[`ncp-session-types`]});let i=n.type===`plugin`?t(`marketplaceInstallSuccessPlugin`):t(`marketplaceInstallSuccessSkill`);o.success(n.message||i)},onError:e=>{o.error(e.message||t(`marketplaceInstallFailed`))}})}function et(){let e=c();return d({mutationFn:e=>We(e),onSuccess:(n,r)=>{e.setQueryData([`marketplace-installed`,n.type],e=>Xe({view:e,request:r,result:n})),e.invalidateQueries({queryKey:[`marketplace-installed`,n.type],refetchType:`inactive`}),n.type===`plugin`&&e.invalidateQueries({queryKey:[`ncp-session-types`]});let i=n.action===`enable`?t(`marketplaceEnableSuccess`):n.action===`disable`?t(`marketplaceDisableSuccess`):t(`marketplaceUninstallSuccess`);o.success(n.message||i)},onError:e=>{o.error(e.message||t(`marketplaceOperationFailed`))}})}function tt(e){return(0,N.jsx)(`div`,{className:`mb-4`,children:(0,N.jsxs)(`div`,{className:`flex gap-3 items-center`,children:[(0,N.jsxs)(`div`,{className:`flex-1 min-w-0 relative`,children:[(0,N.jsx)(j,{className:`h-4 w-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2`}),(0,N.jsx)(`input`,{value:e.searchText,onChange:t=>e.onSearchTextChange(t.target.value),placeholder:e.searchPlaceholder,className:`w-full h-9 border border-gray-200/80 rounded-xl pl-9 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40`})]}),e.scope===`all`&&(0,N.jsxs)(D,{value:e.sort,onValueChange:t=>e.onSortChange(t),children:[(0,N.jsx)(T,{className:`h-9 w-[150px] shrink-0 rounded-lg`,children:(0,N.jsx)(w,{})}),(0,N.jsxs)(ee,{children:[(0,N.jsx)(E,{value:`relevance`,children:t(`marketplaceSortRelevance`)}),(0,N.jsx)(E,{value:`updated`,children:t(`marketplaceSortUpdated`)})]})]})]})})}function nt(e){return(0,N.jsx)(N.Fragment,{children:Array.from({length:e.count},(e,t)=>(0,N.jsx)(`article`,{className:`rounded-2xl border border-gray-200/40 bg-white px-5 py-4 shadow-sm`,children:(0,N.jsxs)(`div`,{className:`flex items-start gap-3.5 justify-between`,children:[(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 gap-3`,children:[(0,N.jsx)(k,{className:`h-10 w-10 shrink-0 rounded-xl`}),(0,N.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2 pt-0.5`,children:[(0,N.jsx)(k,{className:`h-4 w-32 max-w-[70%]`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(k,{className:`h-3 w-12`}),(0,N.jsx)(k,{className:`h-3 w-24`})]}),(0,N.jsx)(k,{className:`h-3 w-full`})]})]}),(0,N.jsx)(k,{className:`h-8 w-20 shrink-0 rounded-xl`})]})},`marketplace-skeleton-${t}`))})}function rt(e){return(0,N.jsxs)(`div`,{className:`mt-4 flex items-center justify-end gap-2`,children:[(0,N.jsx)(`button`,{className:`h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40`,onClick:e.onPrev,disabled:e.page<=1||e.busy,children:t(`prev`)}),(0,N.jsx)(`div`,{className:`text-sm text-gray-600 min-w-20 text-center`,children:e.totalPages===0?`0 / 0`:`${e.page} / ${e.totalPages}`}),(0,N.jsx)(`button`,{className:`h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40`,onClick:e.onNext,disabled:e.totalPages===0||e.page>=e.totalPages||e.busy,children:t(`next`)})]})}var it=12,at=it;function ot(e){return(e??``).trim().toLowerCase()}function Z(e,t){let n=ot(t);return n.length>0?`${e}:${n}`:``}function st(e){let t=new Map;for(let n of e){let e=[n.install.spec,n.slug,n.id];for(let r of e){let e=Z(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function ct(e){let t=new Map;for(let n of e){let e=[n.spec,n.id,n.label];for(let r of e){let e=Z(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function lt(e,t){let n=[e.install.spec,e.slug,e.id];for(let r of n){let n=Z(e.type,r);if(!n)continue;let i=t.get(n);if(i)return i}}function ut(e,t){return t.get(Z(e.type,e.spec))||t.get(Z(e.type,e.id))||t.get(Z(e.type,e.label))}function dt(e,t,n,r){let i=ot(n);if(!i)return!0;let a=A(t?.summaryI18n,t?.summary,r);return[e.id,e.spec,e.label,t?.name,t?.slug,t?.summary,a,...t?.tags??[]].map(e=>ot(e)).filter(Boolean).some(e=>e.includes(i))}function ft(e){let t=[`bg-amber-600`,`bg-orange-500`,`bg-yellow-600`,`bg-emerald-600`,`bg-teal-600`,`bg-cyan-600`,`bg-stone-600`,`bg-rose-500`,`bg-violet-500`],n=0;for(let t=0;t<e.length;t++)n=e.charCodeAt(t)+((n<<5)-n);return t[Math.abs(n)%t.length]}function pt({name:e,fallback:t}){let n=e||t,r=n.substring(0,2).toUpperCase();return(0,N.jsx)(`div`,{className:i(`flex items-center justify-center w-10 h-10 rounded-xl text-white font-semibold text-sm shrink-0`,ft(n)),children:r})}function Q(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function $(e){let t=e.metadataRaw?.trim()||`-`,n=e.contentRaw?.trim()||`-`,r=e.summary?.trim(),i=e.description?.trim(),a=!!i&&i!==r,o=`<!doctype html>
|
|
2
2
|
<html>
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8" />
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./MarketplacePage-2tWWgwAb.js";export{e as MarketplacePage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,p as r,u as i}from"./i18n-hM3v-3YG.js";import{c as a,n as o,o as s,r as c,u as l}from"./dist-RWNFhxvR.js";import{t as u}from"./useMutation-DBTWPbTg.js";import{a as d,i as f,n as ee,r as p,t as m}from"./select-DF-AUoie.js";import{i as h}from"./DocBrowserContext-DN5tjUoS.js";import{W as g,at as _,et as v,it as y,nt as b,r as te,rt as x,tt as S}from"./index-
|
|
1
|
+
import{_ as e,i as t,m as n,p as r,u as i}from"./i18n-hM3v-3YG.js";import{c as a,n as o,o as s,r as c,u as l}from"./dist-RWNFhxvR.js";import{t as u}from"./useMutation-DBTWPbTg.js";import{a as d,i as f,n as ee,r as p,t as m}from"./select-DF-AUoie.js";import{i as h}from"./DocBrowserContext-DN5tjUoS.js";import{W as g,at as _,et as v,it as y,nt as b,r as te,rt as x,tt as S}from"./index-DHmCjcxq.js";import{n as C,t as w}from"./page-layout-Z1klaUFW.js";import{t as ne}from"./useConfirmDialog-CuQqiPx7.js";import{t as re}from"./tabs-custom-CLksZ2bO.js";import{t as T}from"./skeleton-B0mmt1vo.js";import{n as E,r as D,t as ie}from"./marketplace-localization-CxSTG9wr.js";import{t as O}from"./switch-D7JF_RZ-.js";var k=e(n(),1);async function A(e){let t=new URLSearchParams;e.q?.trim()&&t.set(`q`,e.q.trim()),e.tag?.trim()&&t.set(`tag`,e.tag.trim()),e.sort&&t.set(`sort`,e.sort),typeof e.page==`number`&&Number.isFinite(e.page)&&t.set(`page`,String(Math.max(1,Math.trunc(e.page)))),typeof e.pageSize==`number`&&Number.isFinite(e.pageSize)&&t.set(`pageSize`,String(Math.max(1,Math.trunc(e.pageSize))));let n=t.toString(),r=await c.get(n?`/api/marketplace/mcp/items?${n}`:`/api/marketplace/mcp/items`);if(!r.ok)throw Error(r.error.message);return r.data}async function j(){let e=await c.get(`/api/marketplace/mcp/installed`);if(!e.ok)throw Error(e.error.message);return e.data}async function ae(e){let t=await c.get(`/api/marketplace/mcp/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw Error(t.error.message);return t.data}async function M(e){let t=await c.post(`/api/marketplace/mcp/install`,{type:`mcp`,...e});if(!t.ok)throw Error(t.error.message);return t.data}async function N(e){let t=await c.post(`/api/marketplace/mcp/manage`,{type:`mcp`,...e});if(!t.ok)throw Error(t.error.message);return t.data}async function P(e){let t=await c.post(`/api/marketplace/mcp/doctor`,{name:e});if(!t.ok)throw Error(t.error.message);return t.data}function F(e){return a({queryKey:[`marketplace-mcp-items`,e],queryFn:()=>A(e),staleTime:15e3})}function I(){return a({queryKey:[`marketplace-mcp-installed`],queryFn:()=>j(),staleTime:1e4})}function L(){let e=l();return u({mutationFn:M,onSuccess:n=>{e.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}),o.success(n.message||t(`marketplaceInstallSuccessMcp`))},onError:e=>{o.error(e.message||t(`marketplaceInstallFailed`))}})}function R(){let e=l();return u({mutationFn:N,onSuccess:n=>{e.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}),o.success(n.message||t(`marketplaceMcpManageSuccess`))},onError:e=>{o.error(e.message||t(`marketplaceOperationFailed`))}})}var z=r(),B=12;function V(e){return(e??``).trim().toLowerCase()}function H(e){let t=new Map;for(let n of e){let e=[n.catalogSlug,n.spec,n.id,n.label];for(let r of e){let e=V(r);!e||t.has(e)||t.set(e,n)}}return t}function U(e,t){let n=[e.slug,e.install.spec,e.id,e.name];for(let e of n){let n=V(e);if(!n)continue;let r=t.get(n);if(r)return r}}function W(e,t,n,r,i){let a=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),o=`<!doctype html>
|
|
2
2
|
<html>
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8" />
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,p as r}from"./i18n-hM3v-3YG.js";import{o as i}from"./dist-RWNFhxvR.js";import{t as a}from"./book-open-DvWqOode.js";import{a as o,n as s,t as c}from"./ProviderScopedModelInput-
|
|
1
|
+
import{_ as e,i as t,m as n,p as r}from"./i18n-hM3v-3YG.js";import{o as i}from"./dist-RWNFhxvR.js";import{t as a}from"./book-open-DvWqOode.js";import{a as o,n as s,t as c}from"./ProviderScopedModelInput-D9woCARc.js";import{t as l}from"./loader-circle-C8cpaL0w.js";import{t as u}from"./DocBrowserContext-DN5tjUoS.js";import{D as d,G as f,W as p,c as m,ct as h,l as g,u as _}from"./index-DHmCjcxq.js";import{t as v}from"./label-CHJ1ATds.js";import{n as y,t as b}from"./page-layout-Z1klaUFW.js";import{t as x}from"./skeleton-B0mmt1vo.js";import{t as S}from"./config-hints-WtpHP_DW.js";var C=e(n(),1),w=r(),T=`provider/model`;function E(){let{data:e,isLoading:n}=m(),{data:r}=g(),{data:E}=_(),D=d(),[O,k]=(0,C.useState)(``),[A,j]=(0,C.useState)(``),M=E?.uiHints,N=S(`agents.defaults.model`,M),P=S(`agents.defaults.workspace`,M),F=(0,C.useMemo)(()=>s({meta:r,config:e,onlyConfigured:!0}),[e,r]);(0,C.useEffect)(()=>{e?.agents?.defaults&&(k((e.agents.defaults.model||``).trim()),j(e.agents.defaults.workspace||``))},[e]);let I=t(`modelIdentifierHelp`)||N?.help||``;return n?(0,w.jsxs)(`div`,{className:`max-w-2xl space-y-6`,children:[(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(x,{className:`h-8 w-32`}),(0,w.jsx)(x,{className:`h-4 w-48`})]}),(0,w.jsxs)(f,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-4 mb-6`,children:[(0,w.jsx)(x,{className:`h-12 w-12 rounded-xl`}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(x,{className:`h-5 w-24`}),(0,w.jsx)(x,{className:`h-3 w-32`})]})]}),(0,w.jsx)(x,{className:`h-4 w-20 mb-2`}),(0,w.jsx)(x,{className:`h-10 w-full rounded-xl`})]}),(0,w.jsxs)(f,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,w.jsx)(x,{className:`h-5 w-24 mb-2`}),(0,w.jsx)(x,{className:`h-10 w-full rounded-xl`})]})]}):(0,w.jsxs)(y,{children:[(0,w.jsx)(b,{title:t(`modelPageTitle`),description:t(`modelPageDescription`)}),(0,w.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),D.mutate({model:O,workspace:A})},className:`space-y-8`,children:[(0,w.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-8`,children:[(0,w.jsxs)(`div`,{className:`p-8 rounded-2xl bg-white border border-gray-200 shadow-card`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-4 mb-8`,children:[(0,w.jsx)(`div`,{className:`h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white`,children:(0,w.jsx)(h,{className:`h-5 w-5`})}),(0,w.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:t(`defaultModel`)})]}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(v,{htmlFor:`model`,className:`text-xs font-semibold text-gray-500 uppercase tracking-wider`,children:N?.label??`Model Name`}),(0,w.jsx)(c,{id:`model`,value:O,onChange:k,providerCatalog:F,modelPlaceholder:N?.placeholder??T}),(0,w.jsx)(`p`,{className:`text-xs text-gray-400`,children:I}),(0,w.jsxs)(`a`,{href:`${u}/guide/model-selection`,className:`inline-flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover transition-colors`,children:[(0,w.jsx)(a,{className:`h-3.5 w-3.5`}),t(`channelsGuideTitle`)]})]})]}),(0,w.jsxs)(`div`,{className:`p-8 rounded-2xl bg-white border border-gray-200 shadow-card`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-4 mb-8`,children:[(0,w.jsx)(`div`,{className:`h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white`,children:(0,w.jsx)(o,{className:`h-5 w-5`})}),(0,w.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:t(`workspace`)})]}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(v,{htmlFor:`workspace`,className:`text-xs font-semibold text-gray-500 uppercase tracking-wider`,children:P?.label??`Default Path`}),(0,w.jsx)(p,{id:`workspace`,value:A,onChange:e=>j(e.target.value),placeholder:P?.placeholder??`/path/to/workspace`,className:`rounded-xl`})]})]})]}),(0,w.jsx)(`div`,{className:`flex justify-end pt-4`,children:(0,w.jsx)(i,{type:`submit`,disabled:D.isPending,size:`lg`,children:D.isPending?(0,w.jsx)(l,{className:`h-5 w-5 animate-spin`}):t(`saveChanges`)})})]})]})}export{E as ModelConfig};
|
package/ui-dist/assets/{ProviderScopedModelInput-SAJH6nkC.js → ProviderScopedModelInput-D9woCARc.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,p as r,u as i}from"./i18n-hM3v-3YG.js";import{a,i as o,k as s,n as c,r as l,t as u}from"./select-DF-AUoie.js";import{t as d}from"./createLucideIcon-C7MmdIX3.js";import{W as f}from"./index-
|
|
1
|
+
import{_ as e,i as t,m as n,p as r,u as i}from"./i18n-hM3v-3YG.js";import{a,i as o,k as s,n as c,r as l,t as u}from"./select-DF-AUoie.js";import{t as d}from"./createLucideIcon-C7MmdIX3.js";import{W as f}from"./index-DHmCjcxq.js";var p=d(`ChevronsUpDown`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),m=d(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),h=e(n(),1),g=r();function _(e){let t=new Set;for(let n of e){let e=n.trim();e.length>0&&t.add(e)}return[...t]}function v({id:e,value:t,onChange:n,options:r,disabled:a=!1,placeholder:o,className:c,inputClassName:l,emptyText:u,createText:d,maxItems:m=1/0,onEnter:v}){let[y,b]=(0,h.useState)(!1);(0,h.useEffect)(()=>{a&&y&&b(!1)},[a,y]);let x=(0,h.useMemo)(()=>_(r),[r]),S=t.trim().toLowerCase(),C=(0,h.useMemo)(()=>{let e=x.map((e,t)=>({option:e,index:t}));S.length>0&&e.sort((e,t)=>{let n=e.option.toLowerCase(),r=t.option.toLowerCase(),i=n===S?0:n.startsWith(S)?1:n.includes(S)?2:3,a=r===S?0:r.startsWith(S)?1:r.includes(S)?2:3;return i===a?e.index-t.index:i-a});let t=e.map(e=>e.option);return Number.isFinite(m)?t.slice(0,Math.max(1,m)):t},[x,S,m]),w=t.trim().length>0&&x.some(e=>e===t.trim());return(0,g.jsxs)(`div`,{className:i(`relative`,c),onBlur:()=>{setTimeout(()=>b(!1),120)},children:[(0,g.jsx)(f,{id:e,value:t,disabled:a,onFocus:()=>{a||b(!0)},onChange:e=>{n(e.target.value),!y&&!a&&b(!0)},onKeyDown:e=>{e.key===`Enter`&&(v&&(e.preventDefault(),v()),b(!1))},placeholder:o,className:i(`pr-10`,l)}),(0,g.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>b(e=>!e),disabled:a,className:i(`absolute inset-y-0 right-0 inline-flex w-10 items-center justify-center`,a?`cursor-not-allowed text-gray-300`:`text-gray-400 hover:text-gray-600`),"aria-label":`toggle model options`,children:(0,g.jsx)(p,{className:`h-4 w-4`})}),y&&!a&&(0,g.jsx)(`div`,{className:`absolute z-20 mt-1 w-full overflow-hidden rounded-xl border border-gray-200 bg-white shadow-lg`,children:(0,g.jsxs)(`div`,{className:`max-h-60 overflow-y-auto py-1`,children:[!w&&t.trim().length>0&&(0,g.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n(t.trim()),b(!1)},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,g.jsx)(s,{className:`h-4 w-4 text-transparent`}),(0,g.jsx)(`span`,{className:`truncate text-gray-700`,children:d?d.replace(`{value}`,t.trim()):t.trim()})]}),C.map(e=>(0,g.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n(e),b(!1)},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,g.jsx)(s,{className:i(`h-4 w-4`,e===t.trim()?`text-primary`:`text-transparent`)}),(0,g.jsx)(`span`,{className:`truncate text-gray-700`,children:e})]},e)),C.length===0&&t.trim().length===0&&(0,g.jsx)(`div`,{className:`px-3 py-2 text-sm text-gray-500`,children:u??`No models available`})]})})]})}var y=new Set([`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`]);function b(e){if(!e||e.length===0)return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function x(e,t){let n=e.trim(),r=t.trim();if(!n||!r)return n;let i=`${r}/`;return n.startsWith(i)?n.slice(i.length):n}function S(e,t){let n=e.trim();if(!n)return``;for(let e of t)n=x(n,e);return n.trim()}function C(e,t){let n=t.trim(),r=e.trim();return n?r?`${r}/${n}`:n:``}function w(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t&&y.has(t)?t:null}function T(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=w(n);!e||t.includes(e)||t.push(e)}return t}function E(e,t){if(!e)return{};let n={};for(let[r,i]of Object.entries(e)){let e=S(r,t);if(!e)continue;let a=T(i?.supported);if(a.length===0)continue;let o=w(i?.default);n[e]=o&&a.includes(o)?{supported:a,default:o}:{supported:a}}return n}function D(e,t,n){let r=S(t,n);return r?e[r]??null:null}function O(e,t){let n=e.trim();if(!n)return null;let r=null;for(let e of t)for(let t of e.aliases){let i=t.trim();i&&(n===i||n.startsWith(`${i}/`))&&(!r||i.length>r.score)&&(r={name:e.name,score:i.length})}if(r)return r.name;for(let e of t){let t=S(n,e.aliases);if(t&&b(e.models??[]).some(e=>e===t))return e.name}return null}function k(e){return e?e.enabled!==!1&&e.apiKeySet===!0:!1}function A(e){let{meta:t,config:n,onlyConfigured:r=!1}=e,i=(t?.providers??[]).map(e=>{let t=n?.providers?.[e.name],r=(e.modelPrefix||e.name||``).trim(),i=b([e.modelPrefix||``,e.name||``]),a=b((e.defaultModels??[]).map(e=>S(e,i))),o=b((t?.models??[]).map(e=>S(e,i))),s=b([...a,...o]),c=E(t?.modelThinking,i),l=t?.displayName?.trim(),u=k(t);return{name:e.name,displayName:l||e.displayName||e.name,prefix:r,aliases:i,models:s,modelThinking:c,configured:u}});return r?i.filter(e=>e.configured&&e.models.length>0):i}var j=`provider/model`;function M(e){let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function N({id:e,value:n,onChange:r,providerCatalog:i,disabled:s=!1,providerPlaceholder:d,modelPlaceholder:p,className:m}){let[_,y]=(0,h.useState)(``),[b,x]=(0,h.useState)(``),w=i.length>0,T=p??j,E=(0,h.useMemo)(()=>new Map(i.map(e=>[e.name,e])),[i]),D=E.get(_),k=(0,h.useMemo)(()=>D?.aliases??[],[D]),A=(0,h.useMemo)(()=>M(D?.models??[]),[D]);return(0,h.useEffect)(()=>{let e=n.trim();if(!w){y(``),x(e);return}let t=O(e,i)??``,r=E.get(t)?.aliases??[];y(t),x(t?S(e,r):e)},[w,i,E,n]),w?(0,g.jsxs)(`div`,{className:m,children:[(0,g.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,g.jsx)(`div`,{className:`sm:w-[38%] sm:min-w-[170px]`,children:(0,g.jsxs)(u,{value:_,onValueChange:e=>{y(e),x(``),r(``)},disabled:s,children:[(0,g.jsx)(o,{className:`h-10 w-full rounded-xl`,children:(0,g.jsx)(a,{placeholder:d??t(`providersSelectPlaceholder`)})}),(0,g.jsx)(c,{children:i.map(e=>(0,g.jsx)(l,{value:e.name,children:e.displayName},e.name))})]})}),(0,g.jsx)(`span`,{className:`hidden h-10 items-center justify-center leading-none text-lg font-semibold text-gray-300 sm:inline-flex`,children:`/`}),(0,g.jsx)(v,{id:e,value:b,onChange:e=>{if(!D){let t=e.trim();x(t),r(t);return}let t=S(e,k);x(t),r(t?C(D.prefix,t):``)},options:A,disabled:s||!_,placeholder:T,className:`sm:flex-1`,inputClassName:`h-10 rounded-xl`,emptyText:t(`modelPickerNoOptions`),createText:t(`modelPickerUseCustom`)},_)]}),(0,g.jsx)(`p`,{className:`mt-2 text-xs text-gray-500`,children:t(`modelInputCustomHint`)})]}):(0,g.jsxs)(`div`,{className:m,children:[(0,g.jsxs)(`div`,{className:`rounded-2xl border border-amber-200 bg-amber-50/70 px-4 py-3`,children:[(0,g.jsx)(`p`,{className:`text-sm font-semibold text-amber-950`,children:t(`providersEmptyTitle`)}),(0,g.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-amber-900`,children:t(`providersEmptyDescription`)})]}),(0,g.jsx)(f,{id:e,value:n,disabled:s,onChange:e=>r(e.target.value),placeholder:T,className:`mt-3 h-10 rounded-xl`}),(0,g.jsx)(`p`,{className:`mt-2 text-xs text-gray-500`,children:t(`modelInputCustomHint`)})]})}export{m as a,D as i,A as n,C as r,N as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,o as r,p as i,u as a}from"./i18n-hM3v-3YG.js";import{n as o,o as s,u as c}from"./dist-RWNFhxvR.js";import{O as l,a as u,i as d,n as f,r as p,t as m}from"./select-DF-AUoie.js";import{t as h}from"./createLucideIcon-C7MmdIX3.js";import{t as g}from"./plus-CrkO1kob.js";import{t as _}from"./search-EX-Papzl.js";import{t as v}from"./trash-2-VV8jvziy.js";import{t as y}from"./x-B4sxJkGY.js";import{C as b,W as x,_ as ee,c as te,d as S,h as ne,k as re,l as ie,mt as ae,u as oe,w as se,x as ce}from"./index-8XNPYwJu.js";import{n as C,r as le,t as w}from"./popover-xWbqMnIN.js";import{t as ue}from"./LogoBadge-DDS1sU_U.js";import{t as T}from"./label-CHJ1ATds.js";import{n as E,t as de}from"./page-layout-Z1klaUFW.js";import{t as D}from"./tabs-custom-CLksZ2bO.js";import{t as O}from"./status-dot-Bq_8Ojvv.js";import{t as k}from"./config-hints-WtpHP_DW.js";import{i as A,n as fe,r as j,t as pe}from"./config-layout-LQ10ozRC.js";import{t as me}from"./switch-D7JF_RZ-.js";var he=h(`CircleDotDashed`,[[`path`,{d:`M10.1 2.18a9.93 9.93 0 0 1 3.8 0`,key:`1qdqn0`}],[`path`,{d:`M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7`,key:`1bq7p6`}],[`path`,{d:`M21.82 10.1a9.93 9.93 0 0 1 0 3.8`,key:`1rlaqf`}],[`path`,{d:`M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69`,key:`1xk03u`}],[`path`,{d:`M13.9 21.82a9.94 9.94 0 0 1-3.8 0`,key:`l7re25`}],[`path`,{d:`M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7`,key:`1v18p6`}],[`path`,{d:`M2.18 13.9a9.93 9.93 0 0 1 0-3.8`,key:`xdo6bj`}],[`path`,{d:`M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69`,key:`1jjmaz`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),M=h(`EyeOff`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),N=h(`Eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),ge=h(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),P=e(n(),1),F=i();function _e({isSet:e,className:t,value:n,onChange:r,placeholder:i,...o}){let[c,l]=(0,P.useState)(!1),[u,d]=(0,P.useState)(!1),f=typeof n==`string`&&n.length>0;return(0,F.jsxs)(`div`,{className:`relative`,children:[e&&!f&&!u?(0,F.jsx)(`div`,{onClick:()=>d(!0),className:a(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-500 cursor-text items-center pr-12`,t),children:`••••••••••••`}):(0,F.jsx)(x,{type:c?`text`:`password`,className:a(`pr-12`,t),value:n,onChange:r,onBlur:()=>{f||d(!1)},placeholder:i,autoFocus:u,...o}),(0,F.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(e||f)&&(0,F.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>l(!c),children:c?(0,F.jsx)(M,{className:`h-4 w-4`}):(0,F.jsx)(N,{className:`h-4 w-4`})})})]})}function ve({value:e,onChange:n,className:r}){let i=e?Object.entries(e):[],o=(e,t,r)=>{let a=[...i];a[e]=[t,r],n(Object.fromEntries(a))},c=()=>{n({...e,"":``})},l=e=>{let t=i.filter((t,n)=>n!==e);n(Object.fromEntries(t))};return(0,F.jsxs)(`div`,{className:a(`space-y-2`,r),children:[i.map(([e,n],r)=>(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsx)(x,{type:`text`,value:e,onChange:e=>o(r,e.target.value,n),placeholder:t(`headerName`),className:`flex-1`}),(0,F.jsx)(x,{type:`text`,value:n,onChange:t=>o(r,e,t.target.value),placeholder:t(`headerValue`),className:`flex-1`}),(0,F.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>l(r),children:(0,F.jsx)(v,{className:`h-4 w-4 text-red-500`})})]},r)),(0,F.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:c,children:[(0,F.jsx)(g,{className:`h-4 w-4 mr-2`}),t(`add`)]})]})}function ye(e){let{value:t,onChange:n,options:r}=e;return(0,F.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,F.jsx)(`button`,{type:`button`,onClick:()=>n(e.value),"aria-pressed":r,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${r?`border-primary bg-primary text-white shadow-sm`:`border-gray-200 bg-white text-gray-700 hover:border-primary/40 hover:text-primary`}`,children:e.label},e.value)})})}function be(e){let{showAdvanced:n,onShowAdvancedChange:r,supportsWireApi:i,wireApiLabel:a,wireApi:o,onWireApiChange:s,shouldUseWireApiPills:c,wireApiSelectOptions:h,extraHeadersLabel:g,extraHeaders:_,onExtraHeadersChange:v}=e;return(0,F.jsxs)(`div`,{className:`border-t border-gray-100 pt-4`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>r(!n),className:`flex w-full items-center justify-between text-sm text-gray-600 transition-colors hover:text-gray-900`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(ge,{className:`h-3.5 w-3.5`}),t(`providerAdvancedSettings`)]}),(0,F.jsx)(l,{className:`h-4 w-4 transition-transform ${n?`rotate-180`:``}`})]}),n?(0,F.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[i?(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(T,{htmlFor:`wireApi`,className:`text-sm font-medium text-gray-900`,children:a}),c?(0,F.jsx)(ye,{value:o,onChange:e=>s(e),options:h}):(0,F.jsxs)(m,{value:o,onValueChange:e=>s(e),children:[(0,F.jsx)(d,{className:`rounded-xl`,children:(0,F.jsx)(u,{})}),(0,F.jsx)(f,{children:h.map(e=>(0,F.jsx)(p,{value:e.value,children:e.label},e.value))})]})]}):null,(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(T,{className:`text-sm font-medium text-gray-900`,children:g}),(0,F.jsx)(ve,{value:_,onChange:v}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerExtraHeadersHelpShort`)})]})]}):null]})}function xe(e){let{providerAuth:n,providerAuthNote:r,providerAuthMethodOptions:i,providerAuthMethodsCount:a,selectedAuthMethodHint:o,shouldUseAuthMethodPills:c,resolvedAuthMethodId:l,onAuthMethodChange:h,onStartProviderAuth:g,onImportProviderAuthFromCli:_,startPending:v,importPending:y,authSessionId:b,authStatusMessage:x}=e;return n?.kind===`device_code`?(0,F.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3`,children:[(0,F.jsx)(T,{className:`text-sm font-medium text-gray-900`,children:n.displayName||t(`providerAuthSectionTitle`)}),r?(0,F.jsx)(`p`,{className:`text-xs text-gray-600`,children:r}):null,a>1?(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(T,{className:`text-xs font-medium text-gray-700`,children:t(`providerAuthMethodLabel`)}),c?(0,F.jsx)(ye,{value:l,onChange:h,options:i}):(0,F.jsxs)(m,{value:l,onValueChange:h,children:[(0,F.jsx)(d,{className:`h-8 rounded-lg bg-white`,children:(0,F.jsx)(u,{placeholder:t(`providerAuthMethodPlaceholder`)})}),(0,F.jsx)(f,{children:i.map(e=>(0,F.jsx)(p,{value:e.value,children:e.label},e.value))})]}),o?(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:o}):null]}):null,(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:g,disabled:v||!!b,children:t(v?`providerAuthStarting`:b?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),n.supportsCliImport?(0,F.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:_,disabled:y,children:t(y?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,b?(0,F.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[t(`providerAuthSessionLabel`),`: `,b.slice(0,8),`…`]}):null]}),x?(0,F.jsx)(`p`,{className:`text-xs text-gray-600`,children:x}):null]}):null}function Se(e){return(0,F.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-gray-200 bg-gray-50 px-4 py-3`,children:[(0,F.jsx)(T,{className:`text-sm font-medium text-gray-900`,children:t(`enabled`)}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`span`,{className:`text-xs text-gray-500`,children:e.enabled?t(`enabled`):t(`disabled`)}),(0,F.jsx)(me,{checked:e.enabled,onCheckedChange:e.onChange})]})]})}var Ce={enabled:!0,displayName:``,apiKeySet:!1,apiKeyMasked:void 0,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelThinking:{}},we=[`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`],Te=new Set(we);function I(e){if(!e)return null;let t=Object.entries(e).map(([e,t])=>[e.trim(),t]).filter(([e])=>e.length>0);return t.length===0?null:Object.fromEntries(t)}function Ee(e,t){let n=I(e),r=I(t);if(n===null&&r===null)return!0;if(!n||!r)return!1;let i=Object.entries(n).sort(([e],[t])=>e.localeCompare(t)),a=Object.entries(r).sort(([e],[t])=>e.localeCompare(t));return i.length===a.length?i.every(([e,t],n)=>e===a[n][0]&&t===a[n][1]):!1}function De(e){if(!e||e.length===0)return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function Oe(e,t){let n=e.trim();if(!n||!t.trim())return n;let r=`${t.trim()}/`;return n.startsWith(r)?n.slice(r.length):n}function L(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=Oe(n,t))}return n.trim()}function ke(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function Ae(e,t){let n=[...e];for(let e of t)n.includes(e)||n.push(e);return n}function je(e,t){return t.length===0?e:t.every(t=>!e.includes(t))?Ae(e,t):t}function Me(e,t){return ke(e,t)?[]:e}function Ne(e,t,n){t!==n&&(e.enabled=t)}function R(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t&&Te.has(t)?t:null}function Pe(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=R(n);!e||t.includes(e)||t.push(e)}return t}function Fe(e,t){if(!e)return{};let n={};for(let[r,i]of Object.entries(e)){let e=L(r,t);if(!e)continue;let a=Pe(i?.supported);if(a.length===0)continue;let o=R(i?.default);n[e]=o&&a.includes(o)?{supported:a,default:o}:{supported:a}}return n}function Ie(e,t){let n=new Set(t.map(e=>e.trim()).filter(Boolean)),r={};for(let[t,i]of Object.entries(e)){if(!n.has(t))continue;let e=Pe(i.supported);if(e.length===0)continue;let a=R(i.default);r[t]=a&&e.includes(a)?{supported:e,default:a}:{supported:e}}return r}function Le(e,t){let n=Object.keys(e).sort(),r=Object.keys(t).sort();if(n.length!==r.length)return!1;for(let i=0;i<n.length;i+=1){let a=n[i];if(a!==r[i])return!1;let o=e[a],s=t[a];if(!o||!s||!ke([...o.supported].sort(),[...s.supported].sort())||(o.default??null)!==(s.default??null))return!1}return!0}function Re(e){return t(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function ze(e){let{providerName:t,methods:n,defaultMethodId:r,language:i}=e;if(n.length===0)return``;let a=new Map;for(let e of n){let t=e.id.trim();t&&a.set(t.toLowerCase(),t)}let o=(...e)=>{for(let t of e){let e=a.get(t.toLowerCase());if(e)return e}},s=r?.trim();if(t===`minimax-portal`){if(i===`zh`)return o(`cn`,`china-mainland`)??o(s??``)??n[0]?.id??``;if(i===`en`)return o(`global`,`intl`,`international`)??o(s??``)??n[0]?.id??``}if(s){let e=o(s);if(e)return e}return i===`zh`?o(`cn`)??n[0]?.id??``:i===`en`?o(`global`)??n[0]?.id??``:n[0]?.id??``}function Be(e){return e.required&&e.hasDefault&&e.optionCount>1&&e.optionCount<=3}function Ve(e){let{models:n,modelThinking:r,modelDraft:i,showModelInput:a,onModelDraftChange:o,onShowModelInputChange:c,onAddModel:l,onRemoveModel:h,onToggleModelThinkingLevel:_,onSetModelThinkingDefault:v,thinkingLevels:b,formatThinkingLevelLabel:ee}=e;return(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(T,{className:`text-sm font-medium text-gray-900`,children:t(`providerModelsTitle`)}),a?null:(0,F.jsxs)(`button`,{type:`button`,onClick:()=>c(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,F.jsx)(g,{className:`h-3 w-3`}),t(`providerAddModel`)]})]}),a?(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(x,{value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l()),e.key===`Escape`&&(c(!1),o(``))},placeholder:t(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,F.jsx)(s,{type:`button`,size:`sm`,onClick:l,disabled:i.trim().length===0,children:t(`add`)}),(0,F.jsx)(s,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{c(!1),o(``)},children:(0,F.jsx)(y,{className:`h-4 w-4`})})]}):null,n.length===0?(0,F.jsxs)(`div`,{className:`rounded-xl border border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center`,children:[(0,F.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`providerModelsEmptyShort`)}),a?null:(0,F.jsx)(`button`,{type:`button`,onClick:()=>c(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:t(`providerAddFirstModel`)})]}):(0,F.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:n.map(e=>{let n=r[e],i=n?.supported??[],a=n?.default??null;return(0,F.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-1 rounded-full border border-gray-200 bg-white px-3 py-1.5`,children:[(0,F.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-gray-800 sm:max-w-[220px]`,children:e}),(0,F.jsxs)(w,{children:[(0,F.jsx)(le,{asChild:!0,children:(0,F.jsx)(`button`,{type:`button`,className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":t(`providerModelThinkingTitle`),title:t(`providerModelThinkingTitle`),children:(0,F.jsx)(ge,{className:`h-3 w-3`})})}),(0,F.jsxs)(C,{className:`w-80 space-y-3`,children:[(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsx)(`p`,{className:`text-xs font-semibold text-gray-800`,children:t(`providerModelThinkingTitle`)}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerModelThinkingHint`)})]}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:b.map(t=>(0,F.jsx)(`button`,{type:`button`,onClick:()=>_(e,t),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${i.includes(t)?`border-primary bg-primary text-white`:`border-gray-200 bg-white text-gray-600 hover:border-primary/40 hover:text-primary`}`,children:ee(t)},t))}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(T,{className:`text-xs font-medium text-gray-700`,children:t(`providerModelThinkingDefault`)}),(0,F.jsxs)(m,{value:a??`__none__`,onValueChange:t=>v(e,t===`__none__`?null:t),disabled:i.length===0,children:[(0,F.jsx)(d,{className:`h-8 rounded-lg bg-white text-xs`,children:(0,F.jsx)(u,{})}),(0,F.jsxs)(f,{children:[(0,F.jsx)(p,{value:`__none__`,children:t(`providerModelThinkingDefaultNone`)}),i.map(e=>(0,F.jsx)(p,{value:e,children:ee(e)},e))]})]}),i.length===0?(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>h(e),className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":t(`remove`),children:(0,F.jsx)(y,{className:`h-3 w-3`})})]},e)})})]})}function He(e){return e.enabled?(0,F.jsx)(O,{status:e.apiKeySet?`ready`:`setup`,label:e.apiKeySet?t(`statusReady`):t(`statusSetup`),className:e.className}):(0,F.jsx)(O,{status:`inactive`,label:t(`disabled`),className:e.className})}function z({providerName:e,onProviderDeleted:n}){let i=c(),{data:a}=te(),{data:l}=ie(),{data:u}=oe(),d=re(),f=ne(),p=se(),m=b(),h=ce(),g=ee(),[_,y]=(0,P.useState)(``),[S,ae]=(0,P.useState)(!0),[C,le]=(0,P.useState)(``),[w,ue]=(0,P.useState)(null),[E,de]=(0,P.useState)(`auto`),[D,O]=(0,P.useState)([]),[A,j]=(0,P.useState)({}),[me,M]=(0,P.useState)(``),[N,ge]=(0,P.useState)(``),[ve,ye]=(0,P.useState)(!1),[Te,Oe]=(0,P.useState)(!1),[Ae,R]=(0,P.useState)(null),[Pe,z]=(0,P.useState)(``),[Ue,We]=(0,P.useState)(``),Ge=(0,P.useRef)(null),B=l?.providers.find(t=>t.name===e),V=(e?a?.providers[e]:null)??Ce,Ke=u?.uiHints,H=!!B?.isCustom,qe=e?k(`providers.${e}.apiKey`,Ke):void 0,Je=e?k(`providers.${e}.apiBase`,Ke):void 0,Ye=e?k(`providers.${e}.extraHeaders`,Ke):void 0,Xe=e?k(`providers.${e}.wireApi`,Ke):void 0,Ze=B?.displayName||e||``,U=(V.displayName||``).trim()||Ze,W=V.enabled!==!1,Qe=N.trim()||U||e||t(`providersSelectPlaceholder`),$e=B?.modelPrefix||e||``,G=(0,P.useMemo)(()=>De([$e,e||``]),[$e,e]),et=B?.defaultApiBase||``,K=V.apiBase||et,tt=I(V.extraHeaders||null),q=V.wireApi||B?.defaultWireApi||`auto`,nt=(0,P.useMemo)(()=>De((B?.defaultModels??[]).map(e=>L(e,G))),[B?.defaultModels,G]),rt=(0,P.useMemo)(()=>De((V.models??[]).map(e=>L(e,G))),[V.models,G]),J=(0,P.useMemo)(()=>je(nt,rt),[nt,rt]),Y=(0,P.useMemo)(()=>Ie(Fe(V.modelThinking,G),J),[J,G,V.modelThinking]),X=r(),it=B?.apiBaseHelp?.[X]||B?.apiBaseHelp?.en||Je?.help||t(`providerApiBaseHelp`),Z=B?.auth,Q=(0,P.useMemo)(()=>Z?.methods??[],[Z?.methods]),at=(0,P.useMemo)(()=>Q.map(e=>({value:e.id,label:e.label?.[X]||e.label?.en||e.id})),[Q,X]),ot=(0,P.useMemo)(()=>ze({providerName:e,methods:Q,defaultMethodId:Z?.defaultMethodId,language:X}),[e,Z?.defaultMethodId,Q,X]),st=(0,P.useMemo)(()=>{if(!Q.length)return``;let e=Ue.trim();return e&&Q.some(t=>t.id===e)?e:ot||Q[0]?.id||``},[Ue,ot,Q]),ct=(0,P.useMemo)(()=>Q.find(e=>e.id===st),[Q,st]),lt=ct?.hint?.[X]||ct?.hint?.en||``,ut=Be({required:Z?.kind===`device_code`,hasDefault:!!Z?.defaultMethodId?.trim(),optionCount:Q.length}),dt=Z?.note?.[X]||Z?.note?.en||Z?.displayName||``,ft=(B?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:t(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)})),pt=Be({required:!!B?.supportsWireApi,hasDefault:typeof B?.defaultWireApi==`string`&&B.defaultWireApi.length>0,optionCount:ft.length}),$=(0,P.useCallback)(()=>{Ge.current!==null&&(window.clearTimeout(Ge.current),Ge.current=null)},[]),mt=(0,P.useCallback)((n,r)=>{$(),Ge.current=window.setTimeout(()=>{(async()=>{if(e)try{let a=await h.mutateAsync({provider:e,data:{sessionId:n}});if(a.status===`pending`){z(t(`providerAuthWaitingBrowser`)),mt(n,a.nextPollMs??r);return}if(a.status===`authorized`){R(null),$(),z(t(`providerAuthCompleted`)),o.success(t(`providerAuthCompleted`)),i.invalidateQueries({queryKey:[`config`]}),i.invalidateQueries({queryKey:[`config-meta`]});return}R(null),$(),z(a.message||`Authorization ${a.status}.`),o.error(a.message||`Authorization ${a.status}.`)}catch(e){R(null),$();let t=e instanceof Error?e.message:String(e);z(t),o.error(`Authorization failed: ${t}`)}})()},Math.max(1e3,r))},[$,h,e,i]);(0,P.useEffect)(()=>{if(!e){y(``),ae(!0),le(``),ue(null),de(`auto`),O([]),j({}),M(``),ge(``),R(null),z(``),We(``),$();return}y(``),ae(W),le(K),ue(V.extraHeaders||null),de(q),O(J),j(Y),M(``),ge(U),R(null),z(``),We(ot),$()},[e,K,W,V.extraHeaders,q,J,Y,U,ot,$]),(0,P.useEffect)(()=>()=>$(),[$]),(0,P.useEffect)(()=>{j(e=>Ie(e,D))},[D]);let ht=(0,P.useMemo)(()=>{if(!e)return!1;let t=_.trim().length>0,n=C.trim()!==K.trim(),r=!Ee(w,tt),i=B?.supportsWireApi?E!==q:!1,a=!ke(D,J),o=!Le(A,Y),s=H?N.trim()!==U:!1;return t||S!==W||n||r||i||a||o||s},[e,H,N,U,_,S,W,C,K,w,tt,B?.supportsWireApi,E,q,D,J,A,Y]);return!e||!B?(0,F.jsx)(`div`,{className:fe,children:(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:t(`providersSelectTitle`)}),(0,F.jsx)(`p`,{className:`mt-2 text-sm text-gray-500`,children:t(`providersSelectDescription`)})]})}):(0,F.jsxs)(`div`,{className:pe,children:[(0,F.jsx)(`div`,{className:`border-b border-gray-100 px-6 py-4`,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`truncate text-lg font-semibold text-gray-900`,children:Qe}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[H&&(0,F.jsx)(`button`,{type:`button`,onClick:async()=>{if(!(!e||!H)&&window.confirm(t(`providerDeleteConfirm`)))try{await f.mutateAsync({provider:e}),n?.(e)}catch{}},disabled:f.isPending,className:`text-gray-400 hover:text-red-500 transition-colors`,title:t(`providerDelete`),children:(0,F.jsx)(v,{className:`h-4 w-4`})}),(0,F.jsx)(He,{enabled:W,apiKeySet:V.apiKeySet})]})]})}),(0,F.jsxs)(`form`,{onSubmit:t=>{if(t.preventDefault(),!e)return;let n={},r=_.trim(),i=C.trim(),a=I(w),o=N.trim();H&&o!==U&&(n.displayName=o.length>0?o:null),r.length>0&&(n.apiKey=r),Ne(n,S,W),i!==K.trim()&&(n.apiBase=i.length>0&&i!==et?i:null),Ee(a,tt)||(n.extraHeaders=a),B?.supportsWireApi&&E!==q&&(n.wireApi=E),ke(D,J)||(n.models=Me(D,nt)),Le(A,Y)||(n.modelThinking=Ie(A,D)),d.mutate({provider:e,data:n})},className:`flex min-h-0 flex-1 flex-col`,children:[(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5`,children:[(0,F.jsx)(Se,{enabled:S,onChange:ae}),H&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(T,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-gray-900`,children:t(`providerDisplayName`)}),(0,F.jsx)(x,{id:`providerDisplayName`,type:`text`,value:N,onChange:e=>ge(e.target.value),placeholder:Ze||t(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerDisplayNameHelpShort`)})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(T,{htmlFor:`apiKey`,className:`text-sm font-medium text-gray-900`,children:qe?.label??t(`apiKey`)}),(0,F.jsx)(_e,{id:`apiKey`,value:_,isSet:V.apiKeySet,onChange:e=>y(e.target.value),placeholder:qe?.placeholder??t(`enterApiKey`),className:`rounded-xl`}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`leaveBlankToKeepUnchanged`)})]}),(0,F.jsx)(xe,{providerAuth:Z,providerAuthNote:dt,providerAuthMethodOptions:at,providerAuthMethodsCount:Q.length,selectedAuthMethodHint:lt,shouldUseAuthMethodPills:ut,resolvedAuthMethodId:st,onAuthMethodChange:We,onStartProviderAuth:async()=>{if(!(!e||Z?.kind!==`device_code`))try{z(``);let n=await m.mutateAsync({provider:e,data:st?{methodId:st}:{}});if(!n.sessionId||!n.verificationUri)throw Error(t(`providerAuthStartFailed`));R(n.sessionId),z(`${t(`providerAuthOpenPrompt`)}${n.userCode}${t(`providerAuthOpenPromptSuffix`)}`),window.open(n.verificationUri,`_blank`,`noopener,noreferrer`),mt(n.sessionId,n.intervalMs)}catch(e){let n=e instanceof Error?e.message:String(e);R(null),$(),z(n),o.error(`${t(`providerAuthStartFailed`)}: ${n}`)}},onImportProviderAuthFromCli:async()=>{if(!(!e||Z?.kind!==`device_code`))try{$(),R(null);let n=await g.mutateAsync({provider:e}),r=n.expiresAt?` (expires: ${n.expiresAt})`:``;z(`${t(`providerAuthImportStatusPrefix`)}${r}`),o.success(t(`providerAuthImportSuccess`)),i.invalidateQueries({queryKey:[`config`]}),i.invalidateQueries({queryKey:[`config-meta`]})}catch(e){let n=e instanceof Error?e.message:String(e);z(n),o.error(`${t(`providerAuthImportFailed`)}: ${n}`)}},startPending:m.isPending,importPending:g.isPending,authSessionId:Ae,authStatusMessage:Pe}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(T,{htmlFor:`apiBase`,className:`text-sm font-medium text-gray-900`,children:Je?.label??t(`apiBase`)}),(0,F.jsx)(x,{id:`apiBase`,type:`text`,value:C,onChange:e=>le(e.target.value),placeholder:et||Je?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:it})]}),(0,F.jsx)(Ve,{models:D,modelThinking:A,modelDraft:me,showModelInput:Te,onModelDraftChange:M,onShowModelInputChange:Oe,onAddModel:()=>{let e=L(me,G);if(e){if(D.includes(e)){M(``);return}O(t=>[...t,e]),M(``)}},onRemoveModel:e=>{O(t=>t.filter(t=>t!==e)),j(t=>{let n={...t};return delete n[e],n})},onToggleModelThinkingLevel:(e,t)=>{j(n=>{let r=n[e],i=r?.supported??[],a=i.includes(t)?i.filter(e=>e!==t):we.filter(e=>e===t||i.includes(e));if(a.length===0){let t={...n};return delete t[e],t}let o=r?.default&&a.includes(r.default)?r.default:void 0;return{...n,[e]:o?{supported:a,default:o}:{supported:a}}})},onSetModelThinkingDefault:(e,t)=>{j(n=>{let r=n[e];return!r||r.supported.length===0||t&&!r.supported.includes(t)?n:{...n,[e]:t?{supported:r.supported,default:t}:{supported:r.supported}}})},thinkingLevels:we,formatThinkingLevelLabel:Re}),(0,F.jsx)(be,{showAdvanced:ve,onShowAdvancedChange:ye,supportsWireApi:!!B.supportsWireApi,wireApiLabel:Xe?.label??t(`wireApi`),wireApi:E,onWireApiChange:de,shouldUseWireApiPills:pt,wireApiSelectOptions:ft,extraHeadersLabel:Ye?.label??t(`extraHeaders`),extraHeaders:w,onExtraHeadersChange:ue})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-100 px-6 py-4`,children:[(0,F.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:async()=>{if(!e)return;let n=L(D.find(e=>e.trim().length>0)??``,G),r={apiBase:C.trim(),extraHeaders:I(w),model:n||null};_.trim().length>0&&(r.apiKey=_.trim()),B?.supportsWireApi&&(r.wireApi=E);try{let n=await p.mutateAsync({provider:e,data:r});if(n.success){o.success(`${t(`providerTestConnectionSuccess`)} (${n.latencyMs}ms)`);return}let i=[`provider=${n.provider}`,`latency=${n.latencyMs}ms`];n.model&&i.push(`model=${n.model}`),o.error(`${t(`providerTestConnectionFailed`)}: ${n.message} | ${i.join(` | `)}`)}catch(e){let n=e instanceof Error?e.message:String(e);o.error(`${t(`providerTestConnectionFailed`)}: ${n}`)}},disabled:p.isPending,children:[(0,F.jsx)(he,{className:`mr-1.5 h-4 w-4`}),p.isPending?t(`providerTestingConnection`):t(`providerTestConnection`)]}),(0,F.jsx)(s,{type:`submit`,disabled:d.isPending||!ht,children:d.isPending?t(`saving`):t(ht?`save`:`unchanged`)})]})]})]})}function Ue(e){if(!e)return null;try{let t=new URL(e),n=t.pathname&&t.pathname!==`/`?t.pathname:``;return`${t.host}${n}`}catch{return e.replace(/^https?:\/\//,``)}}function We(){let{data:e}=te(),{data:n}=ie(),{data:r}=oe(),i=S(),[o,c]=(0,P.useState)(`installed`),[l,u]=(0,P.useState)(),[d,f]=(0,P.useState)(``),p=r?.uiHints,m=n?.providers??[],h=e?.providers??{},v=m.filter(e=>{let t=h[e.name];return t?.enabled!==!1&&t?.apiKeySet}).length,y=[{id:`installed`,label:t(`providersTabConfigured`),count:v},{id:`all`,label:t(`providersTabAll`),count:m.length}],b=(0,P.useMemo)(()=>{let t=n?.providers??[],r=e?.providers??{},i=d.trim().toLowerCase();return t.filter(e=>{if(o===`installed`){let t=r[e.name];return!!(t?.enabled!==!1&&t?.apiKeySet)}return!0}).filter(e=>i?(r[e.name]?.displayName?.trim()||e.displayName||e.name).toLowerCase().includes(i)||e.name.toLowerCase().includes(i):!0)},[n,e,o,d]);(0,P.useEffect)(()=>{if(b.length===0){u(void 0);return}b.some(e=>e.name===l)||u(b[0].name)},[b,l]);let ee=l;return!e||!n?(0,F.jsx)(`div`,{className:`p-8`,children:t(`providersLoading`)}):(0,F.jsxs)(E,{children:[(0,F.jsx)(de,{title:t(`providersPageTitle`),description:t(`providersPageDescription`)}),(0,F.jsxs)(`div`,{className:A,children:[(0,F.jsxs)(`section`,{className:j,children:[(0,F.jsxs)(`div`,{className:`border-b border-gray-100 px-4 pt-4 pb-3 space-y-3`,children:[(0,F.jsx)(D,{tabs:y,activeTab:o,onChange:c,className:`mb-0`}),(0,F.jsxs)(s,{type:`button`,variant:`outline`,className:`w-full justify-center`,onClick:async()=>{try{let e=await i.mutateAsync({data:{}});c(`all`),f(``),u(e.name)}catch{}},disabled:i.isPending,children:[(0,F.jsx)(g,{className:`mr-2 h-4 w-4`}),i.isPending?t(`saving`):t(`providerAddCustom`)]})]}),(0,F.jsx)(`div`,{className:`border-b border-gray-100 px-4 py-3`,children:(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(_,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,F.jsx)(x,{value:d,onChange:e=>f(e.target.value),placeholder:t(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-3`,children:[b.map(n=>{let r=e.providers[n.name],i=r?.enabled!==!1,o=!!(i&&r?.apiKeySet),s=ee===n.name,c=r?.displayName?.trim()||n.displayName||n.name,l=k(`providers.${n.name}`,p),d=Ue(r?.apiBase||n.defaultApiBase||``)||l?.help||t(`providersDefaultDescription`);return(0,F.jsx)(`button`,{type:`button`,onClick:()=>u(n.name),className:a(`w-full rounded-xl border p-2.5 text-left transition-all`,s?`border-primary/30 bg-primary-50/40 shadow-sm`:`border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70`),children:(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,F.jsx)(ue,{name:n.name,src:n.logo?`/logos/${n.logo}`:null,className:a(`h-10 w-10 rounded-lg border`,o?`border-primary/30 bg-white`:`border-gray-200/70 bg-white`),imgClassName:`h-5 w-5 object-contain`,fallback:(0,F.jsx)(`span`,{className:`text-sm font-semibold uppercase text-gray-500`,children:n.name[0]})}),(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:c}),(0,F.jsx)(`p`,{className:`line-clamp-1 text-[11px] text-gray-500`,children:d})]})]}),(0,F.jsx)(O,{status:i?o?`ready`:`setup`:`inactive`,label:t(i?o?`statusReady`:`statusSetup`:`disabled`),className:`min-w-[56px] justify-center`})]})},n.name)}),b.length===0&&(0,F.jsxs)(`div`,{className:`flex h-full min-h-[220px] flex-col items-center justify-center rounded-xl border border-dashed border-gray-200 bg-gray-50/70 py-10 text-center`,children:[(0,F.jsx)(`div`,{className:`mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-white`,children:(0,F.jsx)(ae,{className:`h-5 w-5 text-gray-300`})}),(0,F.jsx)(`p`,{className:`text-sm font-medium text-gray-700`,children:t(`providersNoMatch`)})]})]})]}),(0,F.jsx)(z,{providerName:ee,onProviderDeleted:e=>{e===l&&u(void 0)}})]})]})}export{We as ProvidersList};
|
|
1
|
+
import{_ as e,i as t,m as n,o as r,p as i,u as a}from"./i18n-hM3v-3YG.js";import{n as o,o as s,u as c}from"./dist-RWNFhxvR.js";import{O as l,a as u,i as d,n as f,r as p,t as m}from"./select-DF-AUoie.js";import{t as h}from"./createLucideIcon-C7MmdIX3.js";import{t as g}from"./plus-CrkO1kob.js";import{t as _}from"./search-EX-Papzl.js";import{t as v}from"./trash-2-VV8jvziy.js";import{t as y}from"./x-B4sxJkGY.js";import{C as b,W as x,_ as ee,c as te,d as S,h as ne,k as re,l as ie,mt as ae,u as oe,w as se,x as ce}from"./index-DHmCjcxq.js";import{n as C,r as le,t as w}from"./popover-xWbqMnIN.js";import{t as ue}from"./LogoBadge-DDS1sU_U.js";import{t as T}from"./label-CHJ1ATds.js";import{n as E,t as de}from"./page-layout-Z1klaUFW.js";import{t as D}from"./tabs-custom-CLksZ2bO.js";import{t as O}from"./status-dot-Bq_8Ojvv.js";import{t as k}from"./config-hints-WtpHP_DW.js";import{i as A,n as fe,r as j,t as pe}from"./config-layout-LQ10ozRC.js";import{t as me}from"./switch-D7JF_RZ-.js";var he=h(`CircleDotDashed`,[[`path`,{d:`M10.1 2.18a9.93 9.93 0 0 1 3.8 0`,key:`1qdqn0`}],[`path`,{d:`M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7`,key:`1bq7p6`}],[`path`,{d:`M21.82 10.1a9.93 9.93 0 0 1 0 3.8`,key:`1rlaqf`}],[`path`,{d:`M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69`,key:`1xk03u`}],[`path`,{d:`M13.9 21.82a9.94 9.94 0 0 1-3.8 0`,key:`l7re25`}],[`path`,{d:`M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7`,key:`1v18p6`}],[`path`,{d:`M2.18 13.9a9.93 9.93 0 0 1 0-3.8`,key:`xdo6bj`}],[`path`,{d:`M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69`,key:`1jjmaz`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),M=h(`EyeOff`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),N=h(`Eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),ge=h(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),P=e(n(),1),F=i();function _e({isSet:e,className:t,value:n,onChange:r,placeholder:i,...o}){let[c,l]=(0,P.useState)(!1),[u,d]=(0,P.useState)(!1),f=typeof n==`string`&&n.length>0;return(0,F.jsxs)(`div`,{className:`relative`,children:[e&&!f&&!u?(0,F.jsx)(`div`,{onClick:()=>d(!0),className:a(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-500 cursor-text items-center pr-12`,t),children:`••••••••••••`}):(0,F.jsx)(x,{type:c?`text`:`password`,className:a(`pr-12`,t),value:n,onChange:r,onBlur:()=>{f||d(!1)},placeholder:i,autoFocus:u,...o}),(0,F.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(e||f)&&(0,F.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>l(!c),children:c?(0,F.jsx)(M,{className:`h-4 w-4`}):(0,F.jsx)(N,{className:`h-4 w-4`})})})]})}function ve({value:e,onChange:n,className:r}){let i=e?Object.entries(e):[],o=(e,t,r)=>{let a=[...i];a[e]=[t,r],n(Object.fromEntries(a))},c=()=>{n({...e,"":``})},l=e=>{let t=i.filter((t,n)=>n!==e);n(Object.fromEntries(t))};return(0,F.jsxs)(`div`,{className:a(`space-y-2`,r),children:[i.map(([e,n],r)=>(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsx)(x,{type:`text`,value:e,onChange:e=>o(r,e.target.value,n),placeholder:t(`headerName`),className:`flex-1`}),(0,F.jsx)(x,{type:`text`,value:n,onChange:t=>o(r,e,t.target.value),placeholder:t(`headerValue`),className:`flex-1`}),(0,F.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>l(r),children:(0,F.jsx)(v,{className:`h-4 w-4 text-red-500`})})]},r)),(0,F.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:c,children:[(0,F.jsx)(g,{className:`h-4 w-4 mr-2`}),t(`add`)]})]})}function ye(e){let{value:t,onChange:n,options:r}=e;return(0,F.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,F.jsx)(`button`,{type:`button`,onClick:()=>n(e.value),"aria-pressed":r,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${r?`border-primary bg-primary text-white shadow-sm`:`border-gray-200 bg-white text-gray-700 hover:border-primary/40 hover:text-primary`}`,children:e.label},e.value)})})}function be(e){let{showAdvanced:n,onShowAdvancedChange:r,supportsWireApi:i,wireApiLabel:a,wireApi:o,onWireApiChange:s,shouldUseWireApiPills:c,wireApiSelectOptions:h,extraHeadersLabel:g,extraHeaders:_,onExtraHeadersChange:v}=e;return(0,F.jsxs)(`div`,{className:`border-t border-gray-100 pt-4`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>r(!n),className:`flex w-full items-center justify-between text-sm text-gray-600 transition-colors hover:text-gray-900`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(ge,{className:`h-3.5 w-3.5`}),t(`providerAdvancedSettings`)]}),(0,F.jsx)(l,{className:`h-4 w-4 transition-transform ${n?`rotate-180`:``}`})]}),n?(0,F.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[i?(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(T,{htmlFor:`wireApi`,className:`text-sm font-medium text-gray-900`,children:a}),c?(0,F.jsx)(ye,{value:o,onChange:e=>s(e),options:h}):(0,F.jsxs)(m,{value:o,onValueChange:e=>s(e),children:[(0,F.jsx)(d,{className:`rounded-xl`,children:(0,F.jsx)(u,{})}),(0,F.jsx)(f,{children:h.map(e=>(0,F.jsx)(p,{value:e.value,children:e.label},e.value))})]})]}):null,(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(T,{className:`text-sm font-medium text-gray-900`,children:g}),(0,F.jsx)(ve,{value:_,onChange:v}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerExtraHeadersHelpShort`)})]})]}):null]})}function xe(e){let{providerAuth:n,providerAuthNote:r,providerAuthMethodOptions:i,providerAuthMethodsCount:a,selectedAuthMethodHint:o,shouldUseAuthMethodPills:c,resolvedAuthMethodId:l,onAuthMethodChange:h,onStartProviderAuth:g,onImportProviderAuthFromCli:_,startPending:v,importPending:y,authSessionId:b,authStatusMessage:x}=e;return n?.kind===`device_code`?(0,F.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3`,children:[(0,F.jsx)(T,{className:`text-sm font-medium text-gray-900`,children:n.displayName||t(`providerAuthSectionTitle`)}),r?(0,F.jsx)(`p`,{className:`text-xs text-gray-600`,children:r}):null,a>1?(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(T,{className:`text-xs font-medium text-gray-700`,children:t(`providerAuthMethodLabel`)}),c?(0,F.jsx)(ye,{value:l,onChange:h,options:i}):(0,F.jsxs)(m,{value:l,onValueChange:h,children:[(0,F.jsx)(d,{className:`h-8 rounded-lg bg-white`,children:(0,F.jsx)(u,{placeholder:t(`providerAuthMethodPlaceholder`)})}),(0,F.jsx)(f,{children:i.map(e=>(0,F.jsx)(p,{value:e.value,children:e.label},e.value))})]}),o?(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:o}):null]}):null,(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:g,disabled:v||!!b,children:t(v?`providerAuthStarting`:b?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),n.supportsCliImport?(0,F.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:_,disabled:y,children:t(y?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,b?(0,F.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[t(`providerAuthSessionLabel`),`: `,b.slice(0,8),`…`]}):null]}),x?(0,F.jsx)(`p`,{className:`text-xs text-gray-600`,children:x}):null]}):null}function Se(e){return(0,F.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-gray-200 bg-gray-50 px-4 py-3`,children:[(0,F.jsx)(T,{className:`text-sm font-medium text-gray-900`,children:t(`enabled`)}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`span`,{className:`text-xs text-gray-500`,children:e.enabled?t(`enabled`):t(`disabled`)}),(0,F.jsx)(me,{checked:e.enabled,onCheckedChange:e.onChange})]})]})}var Ce={enabled:!0,displayName:``,apiKeySet:!1,apiKeyMasked:void 0,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelThinking:{}},we=[`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`],Te=new Set(we);function I(e){if(!e)return null;let t=Object.entries(e).map(([e,t])=>[e.trim(),t]).filter(([e])=>e.length>0);return t.length===0?null:Object.fromEntries(t)}function Ee(e,t){let n=I(e),r=I(t);if(n===null&&r===null)return!0;if(!n||!r)return!1;let i=Object.entries(n).sort(([e],[t])=>e.localeCompare(t)),a=Object.entries(r).sort(([e],[t])=>e.localeCompare(t));return i.length===a.length?i.every(([e,t],n)=>e===a[n][0]&&t===a[n][1]):!1}function De(e){if(!e||e.length===0)return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function Oe(e,t){let n=e.trim();if(!n||!t.trim())return n;let r=`${t.trim()}/`;return n.startsWith(r)?n.slice(r.length):n}function L(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=Oe(n,t))}return n.trim()}function ke(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function Ae(e,t){let n=[...e];for(let e of t)n.includes(e)||n.push(e);return n}function je(e,t){return t.length===0?e:t.every(t=>!e.includes(t))?Ae(e,t):t}function Me(e,t){return ke(e,t)?[]:e}function Ne(e,t,n){t!==n&&(e.enabled=t)}function R(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t&&Te.has(t)?t:null}function Pe(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=R(n);!e||t.includes(e)||t.push(e)}return t}function Fe(e,t){if(!e)return{};let n={};for(let[r,i]of Object.entries(e)){let e=L(r,t);if(!e)continue;let a=Pe(i?.supported);if(a.length===0)continue;let o=R(i?.default);n[e]=o&&a.includes(o)?{supported:a,default:o}:{supported:a}}return n}function Ie(e,t){let n=new Set(t.map(e=>e.trim()).filter(Boolean)),r={};for(let[t,i]of Object.entries(e)){if(!n.has(t))continue;let e=Pe(i.supported);if(e.length===0)continue;let a=R(i.default);r[t]=a&&e.includes(a)?{supported:e,default:a}:{supported:e}}return r}function Le(e,t){let n=Object.keys(e).sort(),r=Object.keys(t).sort();if(n.length!==r.length)return!1;for(let i=0;i<n.length;i+=1){let a=n[i];if(a!==r[i])return!1;let o=e[a],s=t[a];if(!o||!s||!ke([...o.supported].sort(),[...s.supported].sort())||(o.default??null)!==(s.default??null))return!1}return!0}function Re(e){return t(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function ze(e){let{providerName:t,methods:n,defaultMethodId:r,language:i}=e;if(n.length===0)return``;let a=new Map;for(let e of n){let t=e.id.trim();t&&a.set(t.toLowerCase(),t)}let o=(...e)=>{for(let t of e){let e=a.get(t.toLowerCase());if(e)return e}},s=r?.trim();if(t===`minimax-portal`){if(i===`zh`)return o(`cn`,`china-mainland`)??o(s??``)??n[0]?.id??``;if(i===`en`)return o(`global`,`intl`,`international`)??o(s??``)??n[0]?.id??``}if(s){let e=o(s);if(e)return e}return i===`zh`?o(`cn`)??n[0]?.id??``:i===`en`?o(`global`)??n[0]?.id??``:n[0]?.id??``}function Be(e){return e.required&&e.hasDefault&&e.optionCount>1&&e.optionCount<=3}function Ve(e){let{models:n,modelThinking:r,modelDraft:i,showModelInput:a,onModelDraftChange:o,onShowModelInputChange:c,onAddModel:l,onRemoveModel:h,onToggleModelThinkingLevel:_,onSetModelThinkingDefault:v,thinkingLevels:b,formatThinkingLevelLabel:ee}=e;return(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(T,{className:`text-sm font-medium text-gray-900`,children:t(`providerModelsTitle`)}),a?null:(0,F.jsxs)(`button`,{type:`button`,onClick:()=>c(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,F.jsx)(g,{className:`h-3 w-3`}),t(`providerAddModel`)]})]}),a?(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(x,{value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l()),e.key===`Escape`&&(c(!1),o(``))},placeholder:t(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,F.jsx)(s,{type:`button`,size:`sm`,onClick:l,disabled:i.trim().length===0,children:t(`add`)}),(0,F.jsx)(s,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{c(!1),o(``)},children:(0,F.jsx)(y,{className:`h-4 w-4`})})]}):null,n.length===0?(0,F.jsxs)(`div`,{className:`rounded-xl border border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center`,children:[(0,F.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`providerModelsEmptyShort`)}),a?null:(0,F.jsx)(`button`,{type:`button`,onClick:()=>c(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:t(`providerAddFirstModel`)})]}):(0,F.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:n.map(e=>{let n=r[e],i=n?.supported??[],a=n?.default??null;return(0,F.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-1 rounded-full border border-gray-200 bg-white px-3 py-1.5`,children:[(0,F.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-gray-800 sm:max-w-[220px]`,children:e}),(0,F.jsxs)(w,{children:[(0,F.jsx)(le,{asChild:!0,children:(0,F.jsx)(`button`,{type:`button`,className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":t(`providerModelThinkingTitle`),title:t(`providerModelThinkingTitle`),children:(0,F.jsx)(ge,{className:`h-3 w-3`})})}),(0,F.jsxs)(C,{className:`w-80 space-y-3`,children:[(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsx)(`p`,{className:`text-xs font-semibold text-gray-800`,children:t(`providerModelThinkingTitle`)}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerModelThinkingHint`)})]}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:b.map(t=>(0,F.jsx)(`button`,{type:`button`,onClick:()=>_(e,t),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${i.includes(t)?`border-primary bg-primary text-white`:`border-gray-200 bg-white text-gray-600 hover:border-primary/40 hover:text-primary`}`,children:ee(t)},t))}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(T,{className:`text-xs font-medium text-gray-700`,children:t(`providerModelThinkingDefault`)}),(0,F.jsxs)(m,{value:a??`__none__`,onValueChange:t=>v(e,t===`__none__`?null:t),disabled:i.length===0,children:[(0,F.jsx)(d,{className:`h-8 rounded-lg bg-white text-xs`,children:(0,F.jsx)(u,{})}),(0,F.jsxs)(f,{children:[(0,F.jsx)(p,{value:`__none__`,children:t(`providerModelThinkingDefaultNone`)}),i.map(e=>(0,F.jsx)(p,{value:e,children:ee(e)},e))]})]}),i.length===0?(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>h(e),className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":t(`remove`),children:(0,F.jsx)(y,{className:`h-3 w-3`})})]},e)})})]})}function He(e){return e.enabled?(0,F.jsx)(O,{status:e.apiKeySet?`ready`:`setup`,label:e.apiKeySet?t(`statusReady`):t(`statusSetup`),className:e.className}):(0,F.jsx)(O,{status:`inactive`,label:t(`disabled`),className:e.className})}function z({providerName:e,onProviderDeleted:n}){let i=c(),{data:a}=te(),{data:l}=ie(),{data:u}=oe(),d=re(),f=ne(),p=se(),m=b(),h=ce(),g=ee(),[_,y]=(0,P.useState)(``),[S,ae]=(0,P.useState)(!0),[C,le]=(0,P.useState)(``),[w,ue]=(0,P.useState)(null),[E,de]=(0,P.useState)(`auto`),[D,O]=(0,P.useState)([]),[A,j]=(0,P.useState)({}),[me,M]=(0,P.useState)(``),[N,ge]=(0,P.useState)(``),[ve,ye]=(0,P.useState)(!1),[Te,Oe]=(0,P.useState)(!1),[Ae,R]=(0,P.useState)(null),[Pe,z]=(0,P.useState)(``),[Ue,We]=(0,P.useState)(``),Ge=(0,P.useRef)(null),B=l?.providers.find(t=>t.name===e),V=(e?a?.providers[e]:null)??Ce,Ke=u?.uiHints,H=!!B?.isCustom,qe=e?k(`providers.${e}.apiKey`,Ke):void 0,Je=e?k(`providers.${e}.apiBase`,Ke):void 0,Ye=e?k(`providers.${e}.extraHeaders`,Ke):void 0,Xe=e?k(`providers.${e}.wireApi`,Ke):void 0,Ze=B?.displayName||e||``,U=(V.displayName||``).trim()||Ze,W=V.enabled!==!1,Qe=N.trim()||U||e||t(`providersSelectPlaceholder`),$e=B?.modelPrefix||e||``,G=(0,P.useMemo)(()=>De([$e,e||``]),[$e,e]),et=B?.defaultApiBase||``,K=V.apiBase||et,tt=I(V.extraHeaders||null),q=V.wireApi||B?.defaultWireApi||`auto`,nt=(0,P.useMemo)(()=>De((B?.defaultModels??[]).map(e=>L(e,G))),[B?.defaultModels,G]),rt=(0,P.useMemo)(()=>De((V.models??[]).map(e=>L(e,G))),[V.models,G]),J=(0,P.useMemo)(()=>je(nt,rt),[nt,rt]),Y=(0,P.useMemo)(()=>Ie(Fe(V.modelThinking,G),J),[J,G,V.modelThinking]),X=r(),it=B?.apiBaseHelp?.[X]||B?.apiBaseHelp?.en||Je?.help||t(`providerApiBaseHelp`),Z=B?.auth,Q=(0,P.useMemo)(()=>Z?.methods??[],[Z?.methods]),at=(0,P.useMemo)(()=>Q.map(e=>({value:e.id,label:e.label?.[X]||e.label?.en||e.id})),[Q,X]),ot=(0,P.useMemo)(()=>ze({providerName:e,methods:Q,defaultMethodId:Z?.defaultMethodId,language:X}),[e,Z?.defaultMethodId,Q,X]),st=(0,P.useMemo)(()=>{if(!Q.length)return``;let e=Ue.trim();return e&&Q.some(t=>t.id===e)?e:ot||Q[0]?.id||``},[Ue,ot,Q]),ct=(0,P.useMemo)(()=>Q.find(e=>e.id===st),[Q,st]),lt=ct?.hint?.[X]||ct?.hint?.en||``,ut=Be({required:Z?.kind===`device_code`,hasDefault:!!Z?.defaultMethodId?.trim(),optionCount:Q.length}),dt=Z?.note?.[X]||Z?.note?.en||Z?.displayName||``,ft=(B?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:t(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)})),pt=Be({required:!!B?.supportsWireApi,hasDefault:typeof B?.defaultWireApi==`string`&&B.defaultWireApi.length>0,optionCount:ft.length}),$=(0,P.useCallback)(()=>{Ge.current!==null&&(window.clearTimeout(Ge.current),Ge.current=null)},[]),mt=(0,P.useCallback)((n,r)=>{$(),Ge.current=window.setTimeout(()=>{(async()=>{if(e)try{let a=await h.mutateAsync({provider:e,data:{sessionId:n}});if(a.status===`pending`){z(t(`providerAuthWaitingBrowser`)),mt(n,a.nextPollMs??r);return}if(a.status===`authorized`){R(null),$(),z(t(`providerAuthCompleted`)),o.success(t(`providerAuthCompleted`)),i.invalidateQueries({queryKey:[`config`]}),i.invalidateQueries({queryKey:[`config-meta`]});return}R(null),$(),z(a.message||`Authorization ${a.status}.`),o.error(a.message||`Authorization ${a.status}.`)}catch(e){R(null),$();let t=e instanceof Error?e.message:String(e);z(t),o.error(`Authorization failed: ${t}`)}})()},Math.max(1e3,r))},[$,h,e,i]);(0,P.useEffect)(()=>{if(!e){y(``),ae(!0),le(``),ue(null),de(`auto`),O([]),j({}),M(``),ge(``),R(null),z(``),We(``),$();return}y(``),ae(W),le(K),ue(V.extraHeaders||null),de(q),O(J),j(Y),M(``),ge(U),R(null),z(``),We(ot),$()},[e,K,W,V.extraHeaders,q,J,Y,U,ot,$]),(0,P.useEffect)(()=>()=>$(),[$]),(0,P.useEffect)(()=>{j(e=>Ie(e,D))},[D]);let ht=(0,P.useMemo)(()=>{if(!e)return!1;let t=_.trim().length>0,n=C.trim()!==K.trim(),r=!Ee(w,tt),i=B?.supportsWireApi?E!==q:!1,a=!ke(D,J),o=!Le(A,Y),s=H?N.trim()!==U:!1;return t||S!==W||n||r||i||a||o||s},[e,H,N,U,_,S,W,C,K,w,tt,B?.supportsWireApi,E,q,D,J,A,Y]);return!e||!B?(0,F.jsx)(`div`,{className:fe,children:(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:t(`providersSelectTitle`)}),(0,F.jsx)(`p`,{className:`mt-2 text-sm text-gray-500`,children:t(`providersSelectDescription`)})]})}):(0,F.jsxs)(`div`,{className:pe,children:[(0,F.jsx)(`div`,{className:`border-b border-gray-100 px-6 py-4`,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`truncate text-lg font-semibold text-gray-900`,children:Qe}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[H&&(0,F.jsx)(`button`,{type:`button`,onClick:async()=>{if(!(!e||!H)&&window.confirm(t(`providerDeleteConfirm`)))try{await f.mutateAsync({provider:e}),n?.(e)}catch{}},disabled:f.isPending,className:`text-gray-400 hover:text-red-500 transition-colors`,title:t(`providerDelete`),children:(0,F.jsx)(v,{className:`h-4 w-4`})}),(0,F.jsx)(He,{enabled:W,apiKeySet:V.apiKeySet})]})]})}),(0,F.jsxs)(`form`,{onSubmit:t=>{if(t.preventDefault(),!e)return;let n={},r=_.trim(),i=C.trim(),a=I(w),o=N.trim();H&&o!==U&&(n.displayName=o.length>0?o:null),r.length>0&&(n.apiKey=r),Ne(n,S,W),i!==K.trim()&&(n.apiBase=i.length>0&&i!==et?i:null),Ee(a,tt)||(n.extraHeaders=a),B?.supportsWireApi&&E!==q&&(n.wireApi=E),ke(D,J)||(n.models=Me(D,nt)),Le(A,Y)||(n.modelThinking=Ie(A,D)),d.mutate({provider:e,data:n})},className:`flex min-h-0 flex-1 flex-col`,children:[(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5`,children:[(0,F.jsx)(Se,{enabled:S,onChange:ae}),H&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(T,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-gray-900`,children:t(`providerDisplayName`)}),(0,F.jsx)(x,{id:`providerDisplayName`,type:`text`,value:N,onChange:e=>ge(e.target.value),placeholder:Ze||t(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerDisplayNameHelpShort`)})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(T,{htmlFor:`apiKey`,className:`text-sm font-medium text-gray-900`,children:qe?.label??t(`apiKey`)}),(0,F.jsx)(_e,{id:`apiKey`,value:_,isSet:V.apiKeySet,onChange:e=>y(e.target.value),placeholder:qe?.placeholder??t(`enterApiKey`),className:`rounded-xl`}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`leaveBlankToKeepUnchanged`)})]}),(0,F.jsx)(xe,{providerAuth:Z,providerAuthNote:dt,providerAuthMethodOptions:at,providerAuthMethodsCount:Q.length,selectedAuthMethodHint:lt,shouldUseAuthMethodPills:ut,resolvedAuthMethodId:st,onAuthMethodChange:We,onStartProviderAuth:async()=>{if(!(!e||Z?.kind!==`device_code`))try{z(``);let n=await m.mutateAsync({provider:e,data:st?{methodId:st}:{}});if(!n.sessionId||!n.verificationUri)throw Error(t(`providerAuthStartFailed`));R(n.sessionId),z(`${t(`providerAuthOpenPrompt`)}${n.userCode}${t(`providerAuthOpenPromptSuffix`)}`),window.open(n.verificationUri,`_blank`,`noopener,noreferrer`),mt(n.sessionId,n.intervalMs)}catch(e){let n=e instanceof Error?e.message:String(e);R(null),$(),z(n),o.error(`${t(`providerAuthStartFailed`)}: ${n}`)}},onImportProviderAuthFromCli:async()=>{if(!(!e||Z?.kind!==`device_code`))try{$(),R(null);let n=await g.mutateAsync({provider:e}),r=n.expiresAt?` (expires: ${n.expiresAt})`:``;z(`${t(`providerAuthImportStatusPrefix`)}${r}`),o.success(t(`providerAuthImportSuccess`)),i.invalidateQueries({queryKey:[`config`]}),i.invalidateQueries({queryKey:[`config-meta`]})}catch(e){let n=e instanceof Error?e.message:String(e);z(n),o.error(`${t(`providerAuthImportFailed`)}: ${n}`)}},startPending:m.isPending,importPending:g.isPending,authSessionId:Ae,authStatusMessage:Pe}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(T,{htmlFor:`apiBase`,className:`text-sm font-medium text-gray-900`,children:Je?.label??t(`apiBase`)}),(0,F.jsx)(x,{id:`apiBase`,type:`text`,value:C,onChange:e=>le(e.target.value),placeholder:et||Je?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:it})]}),(0,F.jsx)(Ve,{models:D,modelThinking:A,modelDraft:me,showModelInput:Te,onModelDraftChange:M,onShowModelInputChange:Oe,onAddModel:()=>{let e=L(me,G);if(e){if(D.includes(e)){M(``);return}O(t=>[...t,e]),M(``)}},onRemoveModel:e=>{O(t=>t.filter(t=>t!==e)),j(t=>{let n={...t};return delete n[e],n})},onToggleModelThinkingLevel:(e,t)=>{j(n=>{let r=n[e],i=r?.supported??[],a=i.includes(t)?i.filter(e=>e!==t):we.filter(e=>e===t||i.includes(e));if(a.length===0){let t={...n};return delete t[e],t}let o=r?.default&&a.includes(r.default)?r.default:void 0;return{...n,[e]:o?{supported:a,default:o}:{supported:a}}})},onSetModelThinkingDefault:(e,t)=>{j(n=>{let r=n[e];return!r||r.supported.length===0||t&&!r.supported.includes(t)?n:{...n,[e]:t?{supported:r.supported,default:t}:{supported:r.supported}}})},thinkingLevels:we,formatThinkingLevelLabel:Re}),(0,F.jsx)(be,{showAdvanced:ve,onShowAdvancedChange:ye,supportsWireApi:!!B.supportsWireApi,wireApiLabel:Xe?.label??t(`wireApi`),wireApi:E,onWireApiChange:de,shouldUseWireApiPills:pt,wireApiSelectOptions:ft,extraHeadersLabel:Ye?.label??t(`extraHeaders`),extraHeaders:w,onExtraHeadersChange:ue})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-100 px-6 py-4`,children:[(0,F.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:async()=>{if(!e)return;let n=L(D.find(e=>e.trim().length>0)??``,G),r={apiBase:C.trim(),extraHeaders:I(w),model:n||null};_.trim().length>0&&(r.apiKey=_.trim()),B?.supportsWireApi&&(r.wireApi=E);try{let n=await p.mutateAsync({provider:e,data:r});if(n.success){o.success(`${t(`providerTestConnectionSuccess`)} (${n.latencyMs}ms)`);return}let i=[`provider=${n.provider}`,`latency=${n.latencyMs}ms`];n.model&&i.push(`model=${n.model}`),o.error(`${t(`providerTestConnectionFailed`)}: ${n.message} | ${i.join(` | `)}`)}catch(e){let n=e instanceof Error?e.message:String(e);o.error(`${t(`providerTestConnectionFailed`)}: ${n}`)}},disabled:p.isPending,children:[(0,F.jsx)(he,{className:`mr-1.5 h-4 w-4`}),p.isPending?t(`providerTestingConnection`):t(`providerTestConnection`)]}),(0,F.jsx)(s,{type:`submit`,disabled:d.isPending||!ht,children:d.isPending?t(`saving`):t(ht?`save`:`unchanged`)})]})]})]})}function Ue(e){if(!e)return null;try{let t=new URL(e),n=t.pathname&&t.pathname!==`/`?t.pathname:``;return`${t.host}${n}`}catch{return e.replace(/^https?:\/\//,``)}}function We(){let{data:e}=te(),{data:n}=ie(),{data:r}=oe(),i=S(),[o,c]=(0,P.useState)(`installed`),[l,u]=(0,P.useState)(),[d,f]=(0,P.useState)(``),p=r?.uiHints,m=n?.providers??[],h=e?.providers??{},v=m.filter(e=>{let t=h[e.name];return t?.enabled!==!1&&t?.apiKeySet}).length,y=[{id:`installed`,label:t(`providersTabConfigured`),count:v},{id:`all`,label:t(`providersTabAll`),count:m.length}],b=(0,P.useMemo)(()=>{let t=n?.providers??[],r=e?.providers??{},i=d.trim().toLowerCase();return t.filter(e=>{if(o===`installed`){let t=r[e.name];return!!(t?.enabled!==!1&&t?.apiKeySet)}return!0}).filter(e=>i?(r[e.name]?.displayName?.trim()||e.displayName||e.name).toLowerCase().includes(i)||e.name.toLowerCase().includes(i):!0)},[n,e,o,d]);(0,P.useEffect)(()=>{if(b.length===0){u(void 0);return}b.some(e=>e.name===l)||u(b[0].name)},[b,l]);let ee=l;return!e||!n?(0,F.jsx)(`div`,{className:`p-8`,children:t(`providersLoading`)}):(0,F.jsxs)(E,{children:[(0,F.jsx)(de,{title:t(`providersPageTitle`),description:t(`providersPageDescription`)}),(0,F.jsxs)(`div`,{className:A,children:[(0,F.jsxs)(`section`,{className:j,children:[(0,F.jsxs)(`div`,{className:`border-b border-gray-100 px-4 pt-4 pb-3 space-y-3`,children:[(0,F.jsx)(D,{tabs:y,activeTab:o,onChange:c,className:`mb-0`}),(0,F.jsxs)(s,{type:`button`,variant:`outline`,className:`w-full justify-center`,onClick:async()=>{try{let e=await i.mutateAsync({data:{}});c(`all`),f(``),u(e.name)}catch{}},disabled:i.isPending,children:[(0,F.jsx)(g,{className:`mr-2 h-4 w-4`}),i.isPending?t(`saving`):t(`providerAddCustom`)]})]}),(0,F.jsx)(`div`,{className:`border-b border-gray-100 px-4 py-3`,children:(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(_,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,F.jsx)(x,{value:d,onChange:e=>f(e.target.value),placeholder:t(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-3`,children:[b.map(n=>{let r=e.providers[n.name],i=r?.enabled!==!1,o=!!(i&&r?.apiKeySet),s=ee===n.name,c=r?.displayName?.trim()||n.displayName||n.name,l=k(`providers.${n.name}`,p),d=Ue(r?.apiBase||n.defaultApiBase||``)||l?.help||t(`providersDefaultDescription`);return(0,F.jsx)(`button`,{type:`button`,onClick:()=>u(n.name),className:a(`w-full rounded-xl border p-2.5 text-left transition-all`,s?`border-primary/30 bg-primary-50/40 shadow-sm`:`border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70`),children:(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,F.jsx)(ue,{name:n.name,src:n.logo?`/logos/${n.logo}`:null,className:a(`h-10 w-10 rounded-lg border`,o?`border-primary/30 bg-white`:`border-gray-200/70 bg-white`),imgClassName:`h-5 w-5 object-contain`,fallback:(0,F.jsx)(`span`,{className:`text-sm font-semibold uppercase text-gray-500`,children:n.name[0]})}),(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:c}),(0,F.jsx)(`p`,{className:`line-clamp-1 text-[11px] text-gray-500`,children:d})]})]}),(0,F.jsx)(O,{status:i?o?`ready`:`setup`:`inactive`,label:t(i?o?`statusReady`:`statusSetup`:`disabled`),className:`min-w-[56px] justify-center`})]})},n.name)}),b.length===0&&(0,F.jsxs)(`div`,{className:`flex h-full min-h-[220px] flex-col items-center justify-center rounded-xl border border-dashed border-gray-200 bg-gray-50/70 py-10 text-center`,children:[(0,F.jsx)(`div`,{className:`mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-white`,children:(0,F.jsx)(ae,{className:`h-5 w-5 text-gray-300`})}),(0,F.jsx)(`p`,{className:`text-sm font-medium text-gray-700`,children:t(`providersNoMatch`)})]})]})]}),(0,F.jsx)(z,{providerName:ee,onProviderDeleted:e=>{e===l&&u(void 0)}})]})]})}export{We as ProvidersList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,n as r,p as i}from"./i18n-hM3v-3YG.js";import{o as a}from"./dist-RWNFhxvR.js";import{t as o}from"./createLucideIcon-C7MmdIX3.js";import{t as s}from"./refresh-ccw-JQh1lwq-.js";import{$ as c,G as l,J as u,K as d,Q as f,X as p,Y as m,Z as h,q as g,st as _}from"./index-
|
|
1
|
+
import{_ as e,i as t,m as n,n as r,p as i}from"./i18n-hM3v-3YG.js";import{o as a}from"./dist-RWNFhxvR.js";import{t as o}from"./createLucideIcon-C7MmdIX3.js";import{t as s}from"./refresh-ccw-JQh1lwq-.js";import{$ as c,G as l,J as u,K as d,Q as f,X as p,Y as m,Z as h,q as g,st as _}from"./index-DHmCjcxq.js";import{n as v,t as y}from"./page-layout-Z1klaUFW.js";import{t as b}from"./status-dot-Bq_8Ojvv.js";var x=o(`Laptop`,[[`path`,{d:`M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16`,key:`tarvll`}]]),S=[/invalid or expired token/i,/missing bearer token/i,/token expired/i,/token is invalid/i,/run "nextclaw login"/i,/browser sign-in again/i];function C(e){return e?.runtime?.lastError?.trim()||``}function w(e){let n=t(`remoteStatusIssueDetailGeneric`),r=C(e);return r?`${n} (${r})`:n}function T(e){if(!e?.settings.enabled)return!1;let t=C(e);return S.some(e=>e.test(t))}function E(e){return T(e)?{hero:{badgeStatus:`warning`,badgeLabel:t(`remoteStateReauthorizationRequired`),title:t(`remoteStatusReauthorizationTitle`),description:t(`remoteStatusReauthorizationDescription`)},primaryAction:{kind:`reauthorize`,label:t(`remoteReauthorizeNow`),showRefreshIcon:!1},issueHint:{title:t(`remoteStatusRecoveryTitle`),body:t(`remoteStatusReauthorizationHint`)},shouldShowIssueHint:!0,requiresReauthorization:!0}:e?.account.loggedIn?e.settings.enabled?e.service.running?e.runtime?.state===`connected`?{hero:{badgeStatus:`ready`,badgeLabel:t(`statusReady`),title:t(`remoteStatusReadyTitle`),description:t(`remoteStatusReadyDescription`)},primaryAction:{kind:`repair`,label:t(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:e.runtime?.state===`connecting`?{hero:{badgeStatus:`active`,badgeLabel:t(`connecting`),title:t(`remoteStatusConnectingTitle`),description:t(`remoteStatusConnectingDescription`)},primaryAction:{kind:`repair`,label:t(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:t(`remoteStateDisconnected`),title:t(`remoteStatusIssueTitle`),description:t(`remoteStatusIssueDescription`)},primaryAction:{kind:`repair`,label:t(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:t(`remoteStatusRecoveryTitle`),body:w(e)},shouldShowIssueHint:!!(e.settings.enabled&&e.account.loggedIn),requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:t(`remoteServiceStopped`),title:t(`remoteStatusNeedsServiceTitle`),description:t(`remoteStatusNeedsServiceDescription`)},primaryAction:{kind:`repair`,label:t(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:t(`remoteStatusRecoveryTitle`),body:t(`remoteStatusIssueDetailServiceStopped`)},shouldShowIssueHint:!0,requiresReauthorization:!1}:{hero:{badgeStatus:`inactive`,badgeLabel:t(`statusInactive`),title:t(`remoteStatusNeedsEnable`),description:t(`remoteStatusNeedsEnableDescription`)},primaryAction:{kind:`enable`,label:t(`remoteEnableNow`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`setup`,badgeLabel:t(`statusSetup`),title:t(`remoteStatusNeedsSignIn`),description:t(`remoteStatusNeedsSignInDescription`)},primaryAction:{kind:`sign-in-enable`,label:t(`remoteSignInAndEnable`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}}var D=e(n(),1),O=i();function k(e){let{label:t,muted:n,value:r}=e;return(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,O.jsx)(`span`,{className:`text-gray-500`,children:t}),(0,O.jsx)(`span`,{className:n?`text-right text-gray-500`:`text-right text-gray-900`,children:r==null||r===``?`-`:String(r)})]})}function A(){let e=p(),n=f(),i=n.data,o=h(e=>e.actionLabel),S=(0,D.useMemo)(()=>E(i),[i]),C=!!o,w=i?.runtime?.deviceName?.trim()||i?.settings.deviceName?.trim()||t(`remoteDeviceNameAuto`),T=!!(i?.account.loggedIn&&c(i)),{hero:A,issueHint:j}=S;return(0,D.useEffect)(()=>{e.remoteAccessManager.syncStatus(i)},[e,i]),n.isLoading&&!i?(0,O.jsx)(`div`,{className:`p-8 text-gray-400`,children:t(`remoteLoading`)}):(0,O.jsxs)(v,{className:`space-y-6`,children:[(0,O.jsx)(y,{title:t(`remotePageTitle`),description:t(`remotePageDescription`)}),(0,O.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-[1.2fr_0.8fr]`,children:[(0,O.jsxs)(l,{children:[(0,O.jsxs)(u,{className:`space-y-4`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,O.jsx)(m,{children:A.title}),(0,O.jsx)(b,{status:A.badgeStatus,label:A.badgeLabel})]}),(0,O.jsx)(g,{children:A.description})]}),(0,O.jsxs)(d,{className:`space-y-5`,children:[(0,O.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-gray-50 px-4 py-3`,children:[(0,O.jsx)(k,{label:t(`remoteSignedInAccount`),value:i?.account.email}),(0,O.jsx)(k,{label:t(`remoteDeviceName`),value:w}),(0,O.jsx)(k,{label:t(`remoteConnectionStatus`),value:A.badgeLabel}),(0,O.jsx)(k,{label:t(`remoteLastConnectedAt`),value:i?.runtime?.lastConnectedAt?r(i.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[S.primaryAction?(0,O.jsxs)(a,{onClick:()=>{if(S.primaryAction?.kind===`reauthorize`){e.remoteAccessManager.reauthorizeRemoteAccess(i);return}if(S.primaryAction?.kind===`repair`){e.remoteAccessManager.repairRemoteAccess(i);return}e.remoteAccessManager.enableRemoteAccess(i)},disabled:C,children:[S.primaryAction.showRefreshIcon?(0,O.jsx)(s,{className:`mr-2 h-4 w-4`}):null,o||S.primaryAction.label]}):null,(0,O.jsxs)(a,{variant:`outline`,onClick:()=>void e.accountManager.openNextClawWeb(),disabled:C||!T,children:[(0,O.jsx)(_,{className:`mr-2 h-4 w-4`}),t(`remoteOpenDeviceList`)]}),i?.settings.enabled?(0,O.jsx)(a,{variant:`outline`,onClick:()=>void e.remoteAccessManager.disableRemoteAccess(i),disabled:C,children:t(`remoteDisable`)}):null]}),S.shouldShowIssueHint&&j?(0,O.jsxs)(`div`,{className:`rounded-2xl border border-amber-200 bg-amber-50 px-4 py-3`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium text-amber-900`,children:j.title}),(0,O.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-amber-800`,children:j.body})]}):null,(0,O.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`remoteOpenWebHint`)})]})]}),(0,O.jsxs)(l,{children:[(0,O.jsxs)(u,{children:[(0,O.jsxs)(m,{className:`flex items-center gap-2`,children:[(0,O.jsx)(x,{className:`h-4 w-4 text-primary`}),t(`remoteDeviceSectionTitle`)]}),(0,O.jsx)(g,{children:t(`remoteDeviceSectionDescription`)})]}),(0,O.jsxs)(d,{className:`space-y-5`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,O.jsx)(b,{status:i?.account.loggedIn?`ready`:`inactive`,label:i?.account.loggedIn?t(`remoteAccountConnected`):t(`remoteAccountNotConnected`)}),(0,O.jsx)(b,{status:i?.settings.enabled?`active`:`inactive`,label:i?.settings.enabled?t(`remoteEnabled`):t(`remoteStateDisabled`)}),(0,O.jsx)(b,{status:i?.service.running?`active`:`inactive`,label:i?.service.running?t(`remoteServiceRunning`):t(`remoteServiceStopped`)})]}),(0,O.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-gray-50 px-4 py-3`,children:[(0,O.jsx)(k,{label:t(`remoteDeviceName`),value:w}),(0,O.jsx)(k,{label:t(`remoteConnectionStatus`),value:A.badgeLabel}),(0,O.jsx)(k,{label:t(`remoteLastConnectedAt`),value:i?.runtime?.lastConnectedAt?r(i.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,O.jsx)(`div`,{className:`rounded-2xl border border-dashed border-gray-200 bg-gray-50 px-4 py-3 text-sm text-gray-600`,children:i?.account.loggedIn?t(`remoteOpenWebHint`):t(`remoteStatusNeedsSignInDescription`)})]})]})]})]})}export{A as RemoteAccessPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,p as r}from"./i18n-hM3v-3YG.js";import{n as i,o as a}from"./dist-RWNFhxvR.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-DF-AUoie.js";import{t as d}from"./plus-CrkO1kob.js";import{t as ee}from"./save-4VRlzkii.js";import{t as f}from"./trash-2-VV8jvziy.js";import{A as p,G as m,J as h,K as g,W as _,Y as v,c as y,q as b,u as x}from"./index-
|
|
1
|
+
import{_ as e,i as t,m as n,p as r}from"./i18n-hM3v-3YG.js";import{n as i,o as a}from"./dist-RWNFhxvR.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-DF-AUoie.js";import{t as d}from"./plus-CrkO1kob.js";import{t as ee}from"./save-4VRlzkii.js";import{t as f}from"./trash-2-VV8jvziy.js";import{A as p,G as m,J as h,K as g,W as _,Y as v,c as y,q as b,u as x}from"./index-DHmCjcxq.js";import{n as S,t as C}from"./page-layout-Z1klaUFW.js";import{t as w}from"./config-hints-WtpHP_DW.js";import{t as te}from"./switch-D7JF_RZ-.js";var T=e(n(),1);function E(){return{id:``,default:!1,workspace:``,model:``,runtime:``,contextTokens:void 0,maxToolIterations:void 0}}function D(){return{agentId:``,match:{channel:``,accountId:``}}}function O(e){return{id:e.id??``,default:!!e.default,displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,workspace:e.workspace??``,model:e.model??``,runtime:e.runtime??e.engine??``,contextTokens:e.contextTokens,maxToolIterations:e.maxToolIterations}}function k(e){return{agentId:e.agentId??``,match:{channel:e.match?.channel??``,accountId:e.match?.accountId??``,peer:e.match?.peer?{kind:e.match.peer.kind,id:e.match.peer.id}:void 0}}}function A(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isFinite(n)?n:void 0}function j(e){let t={id:e.id.trim()};e.default&&(t.default=!0),e.displayName?.trim()&&(t.displayName=e.displayName.trim()),e.description?.trim()&&(t.description=e.description.trim()),e.avatar?.trim()&&(t.avatar=e.avatar.trim()),e.workspace?.trim()&&(t.workspace=e.workspace.trim()),e.model?.trim()&&(t.model=e.model.trim());let n=e.runtime?.trim()??e.engine?.trim();return n&&(t.engine=n),typeof e.contextTokens==`number`&&(t.contextTokens=Math.max(1e3,e.contextTokens)),typeof e.maxToolIterations==`number`&&(t.maxToolIterations=e.maxToolIterations),t}var M=r(),N=[{value:`main`,label:`main`},{value:`per-peer`,label:`per-peer`},{value:`per-channel-peer`,label:`per-channel-peer`},{value:`per-account-channel-peer`,label:`per-account-channel-peer`}];function P(){let{data:e,isLoading:n}=y(),{data:r}=x(),P=p(),[F,I]=(0,T.useState)([]),[L,R]=(0,T.useState)([]),[z,B]=(0,T.useState)(`per-channel-peer`),[V,H]=(0,T.useState)(2e5),[U,W]=(0,T.useState)(`native`);(0,T.useEffect)(()=>{e&&(I((e.agents.list??[]).map(O)),R((e.bindings??[]).map(k)),B(e.session?.dmScope??`per-channel-peer`),H(e.agents.defaults.contextTokens??2e5),W(e.agents.defaults.engine??`native`))},[e]);let G=r?.uiHints,K=w(`session.dmScope`,G),q=w(`agents.defaults.contextTokens`,G),J=w(`agents.defaults.engine`,G),Y=w(`agents.list.*.contextTokens`,G),ne=w(`agents.list.*.engine`,G),X=w(`agents.list`,G),Z=w(`bindings`,G),re=(0,T.useMemo)(()=>{let e=new Set([`main`]);return F.forEach(t=>{let n=t.id.trim();n&&e.add(n)}),e},[F]),Q=(e,t)=>{I(n=>n.map((n,r)=>r===e?{...n,...t}:n))},$=(e,t)=>{R(n=>n.map((n,r)=>r===e?t:n))};return n||!e?(0,M.jsx)(`div`,{className:`p-8 text-gray-400`,children:t(`runtimeLoading`)}):(0,M.jsxs)(S,{className:`space-y-6`,children:[(0,M.jsx)(C,{title:t(`runtimePageTitle`),description:t(`runtimePageDescription`)}),(0,M.jsxs)(m,{children:[(0,M.jsxs)(h,{children:[(0,M.jsx)(v,{children:K?.label??t(`dmScope`)}),(0,M.jsx)(b,{children:K?.help??t(`dmScopeHelp`)})]}),(0,M.jsxs)(g,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:q?.label??t(`defaultContextTokens`)}),(0,M.jsx)(_,{type:`number`,min:1e3,step:1e3,value:V,onChange:e=>H(Math.max(1e3,Number.parseInt(e.target.value,10)||1e3))}),(0,M.jsx)(`p`,{className:`text-xs text-gray-500`,children:q?.help??t(`defaultContextTokensHelp`)})]}),(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:J?.label??t(`defaultEngine`)}),(0,M.jsx)(_,{value:U,onChange:e=>W(e.target.value),placeholder:t(`defaultEnginePlaceholder`)}),(0,M.jsx)(`p`,{className:`text-xs text-gray-500`,children:J?.help??t(`defaultEngineHelp`)})]}),(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:K?.label??t(`dmScope`)}),(0,M.jsxs)(u,{value:z,onValueChange:e=>B(e),children:[(0,M.jsx)(s,{children:(0,M.jsx)(o,{})}),(0,M.jsx)(c,{children:N.map(e=>(0,M.jsx)(l,{value:e.value,children:e.label},e.value))})]})]})]})]}),(0,M.jsxs)(m,{children:[(0,M.jsxs)(h,{children:[(0,M.jsx)(v,{children:X?.label??t(`agentList`)}),(0,M.jsx)(b,{children:X?.help??t(`agentListHelp`)})]}),(0,M.jsxs)(g,{className:`space-y-3`,children:[F.map((e,n)=>(0,M.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,M.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,M.jsx)(_,{value:e.id,onChange:e=>Q(n,{id:e.target.value}),placeholder:t(`agentIdPlaceholder`)}),(0,M.jsx)(_,{value:e.workspace??``,onChange:e=>Q(n,{workspace:e.target.value}),placeholder:t(`workspaceOverridePlaceholder`)}),(0,M.jsx)(_,{value:e.model??``,onChange:e=>Q(n,{model:e.target.value}),placeholder:t(`modelOverridePlaceholder`)}),(0,M.jsx)(_,{value:e.runtime??e.engine??``,onChange:e=>Q(n,{runtime:e.target.value}),placeholder:ne?.label??t(`engineOverridePlaceholder`)}),(0,M.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2`,children:[(0,M.jsx)(_,{type:`number`,min:1e3,step:1e3,value:e.contextTokens??``,onChange:e=>Q(n,{contextTokens:A(e.target.value)}),placeholder:Y?.label??t(`contextTokensPlaceholder`)}),(0,M.jsx)(_,{type:`number`,min:1,value:e.maxToolIterations??``,onChange:e=>Q(n,{maxToolIterations:A(e.target.value)}),placeholder:t(`maxToolsPlaceholder`)})]})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600`,children:[(0,M.jsx)(te,{checked:!!e.default,onCheckedChange:e=>{if(!e){Q(n,{default:!1});return}I(e=>e.map((e,t)=>({...e,default:t===n})))}}),(0,M.jsx)(`span`,{children:t(`defaultAgent`)})]}),(0,M.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>I(e=>e.filter((e,t)=>t!==n)),children:[(0,M.jsx)(f,{className:`h-4 w-4 mr-1`}),t(`remove`)]})]})]},`${n}-${e.id}`)),(0,M.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>I(e=>[...e,E()]),children:[(0,M.jsx)(d,{className:`h-4 w-4 mr-2`}),t(`addAgent`)]})]})]}),(0,M.jsxs)(m,{children:[(0,M.jsxs)(h,{children:[(0,M.jsx)(v,{children:Z?.label??t(`bindings`)}),(0,M.jsx)(b,{children:Z?.help??t(`bindingsHelp`)})]}),(0,M.jsxs)(g,{className:`space-y-3`,children:[L.map((e,n)=>{let r=e.match.peer?.kind??``;return(0,M.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,M.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:[(0,M.jsx)(_,{value:e.agentId,onChange:t=>$(n,{...e,agentId:t.target.value}),placeholder:t(`targetAgentIdPlaceholder`)}),(0,M.jsx)(_,{value:e.match.channel,onChange:t=>$(n,{...e,match:{...e.match,channel:t.target.value}}),placeholder:t(`channelPlaceholder`)}),(0,M.jsx)(_,{value:e.match.accountId??``,onChange:t=>$(n,{...e,match:{...e.match,accountId:t.target.value}}),placeholder:t(`accountIdOptionalPlaceholder`)}),(0,M.jsxs)(u,{value:r||`__none__`,onValueChange:t=>{let r=t===`__none__`?``:t;if(!r){$(n,{...e,match:{...e.match,peer:void 0}});return}$(n,{...e,match:{...e.match,peer:{kind:r,id:e.match.peer?.id??``}}})},children:[(0,M.jsx)(s,{children:(0,M.jsx)(o,{})}),(0,M.jsxs)(c,{children:[(0,M.jsx)(l,{value:`__none__`,children:t(`peerKindOptional`)}),(0,M.jsx)(l,{value:`direct`,children:`direct`}),(0,M.jsx)(l,{value:`group`,children:`group`}),(0,M.jsx)(l,{value:`channel`,children:`channel`})]})]}),(0,M.jsx)(_,{value:e.match.peer?.id??``,onChange:t=>$(n,{...e,match:{...e.match,peer:r?{kind:r,id:t.target.value}:void 0}}),placeholder:t(`peerIdPlaceholder`)})]}),(0,M.jsx)(`div`,{className:`flex justify-end`,children:(0,M.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>R(e=>e.filter((e,t)=>t!==n)),children:[(0,M.jsx)(f,{className:`h-4 w-4 mr-1`}),t(`remove`)]})})]},`${n}-${e.agentId}`)}),(0,M.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>R(e=>[...e,D()]),children:[(0,M.jsx)(d,{className:`h-4 w-4 mr-2`}),t(`addBinding`)]})]})]}),(0,M.jsx)(`div`,{className:`flex justify-end`,children:(0,M.jsxs)(a,{type:`button`,onClick:()=>{try{let e=F.map((e,n)=>{if(!e.id.trim())throw Error(t(`agentIdRequiredError`).replace(`{index}`,String(n)));return j(e)}),n=e.map(e=>e.id).filter((e,t,n)=>n.indexOf(e)!==t);if(n.length>0){i.error(`${t(`duplicateAgentId`)}: ${n[0]}`);return}let r=L.map((e,n)=>{let r=e.agentId.trim(),i=e.match.channel.trim(),a=e.match.accountId?.trim()??``,o=e.match.peer?.kind,s=e.match.peer?.id?.trim()??``;if(!r)throw Error(t(`bindingAgentIdRequired`).replace(`{index}`,String(n)));if(!re.has(r))throw Error(`${t(`bindingAgentIdNotFound`).replace(`{index}`,String(n))}: ${r}`);if(!i)throw Error(t(`bindingChannelRequired`).replace(`{index}`,String(n)));let c={agentId:r,match:{channel:i}};if(a&&(c.match.accountId=a),o){if(!s)throw Error(t(`bindingPeerIdRequired`).replace(`{index}`,String(n)));c.match.peer={kind:o,id:s}}return c});P.mutate({data:{agents:{defaults:{contextTokens:Math.max(1e3,V),engine:U.trim()||`native`},list:e},bindings:r,session:{dmScope:z}}})}catch(e){let t=e instanceof Error?e.message:String(e);i.error(t)}},disabled:P.isPending,children:[(0,M.jsx)(ee,{className:`h-4 w-4 mr-2`}),P.isPending?t(`saving`):t(`saveRuntimeSettings`)]})})]})}export{P as RuntimeConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,p as r,u as i}from"./i18n-hM3v-3YG.js";import{o as a}from"./dist-RWNFhxvR.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-DF-AUoie.js";import{t as d}from"./external-link-U86Acd1t.js";import{t as f}from"./search-EX-Papzl.js";import{W as p,c as m,j as h,l as g,mt as _}from"./index-8XNPYwJu.js";import{t as v}from"./label-CHJ1ATds.js";import{n as y,t as ee}from"./page-layout-Z1klaUFW.js";import{i as te,r as ne,t as re}from"./config-layout-LQ10ozRC.js";var b=e(n(),1),x=r(),S=[{value:`noLimit`,label:`searchFreshnessNoLimit`},{value:`oneDay`,label:`searchFreshnessOneDay`},{value:`oneWeek`,label:`searchFreshnessOneWeek`},{value:`oneMonth`,label:`searchFreshnessOneMonth`},{value:`oneYear`,label:`searchFreshnessOneYear`}],C=[{value:`basic`,label:`searchDepthBasic`},{value:`advanced`,label:`searchDepthAdvanced`}],ie={bocha:`searchProviderBochaDescription`,tavily:`searchProviderTavilyDescription`,brave:`searchProviderBraveDescription`};function ae({apiKey:e,apiKeyMasked:n,baseUrl:r,summary:i,freshness:f,docsUrl:m,onApiKeyChange:h,onBaseUrlChange:g,onSummaryChange:_,onFreshnessChange:y}){return(0,x.jsxs)(`div`,{className:`space-y-4`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`apiKey`)}),(0,x.jsx)(p,{type:`password`,value:e,onChange:e=>h(e.target.value),placeholder:n||t(`enterApiKey`),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`searchProviderBaseUrl`)}),(0,x.jsx)(p,{value:r,onChange:e=>g(e.target.value),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`searchProviderSummary`)}),(0,x.jsxs)(u,{value:i?`true`:`false`,onValueChange:e=>_(e===`true`),children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsxs)(c,{children:[(0,x.jsx)(l,{value:`true`,children:t(`enabled`)}),(0,x.jsx)(l,{value:`false`,children:t(`disabled`)})]})]})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`searchProviderFreshness`)}),(0,x.jsxs)(u,{value:f,onValueChange:y,children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsx)(c,{children:S.map(e=>(0,x.jsx)(l,{value:e.value,children:t(e.label)},e.value))})]})]})]}),(0,x.jsx)(`div`,{className:`space-y-2`,children:(0,x.jsx)(`a`,{href:m??`https://open.bocha.cn`,target:`_blank`,rel:`noreferrer`,children:(0,x.jsxs)(a,{type:`button`,variant:`outline`,className:`rounded-xl`,children:[(0,x.jsx)(d,{className:`mr-2 h-4 w-4`}),t(`searchProviderOpenDocs`)]})})})]})}function w({apiKey:e,apiKeyMasked:n,baseUrl:r,searchDepth:i,includeAnswer:f,docsUrl:m,onApiKeyChange:h,onBaseUrlChange:g,onSearchDepthChange:_,onIncludeAnswerChange:y}){return(0,x.jsxs)(`div`,{className:`space-y-4`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`apiKey`)}),(0,x.jsx)(p,{type:`password`,value:e,onChange:e=>h(e.target.value),placeholder:n||t(`enterApiKey`),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`searchProviderBaseUrl`)}),(0,x.jsx)(p,{value:r,onChange:e=>g(e.target.value),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`searchProviderSearchDepth`)}),(0,x.jsxs)(u,{value:i,onValueChange:e=>_(e),children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsx)(c,{children:C.map(e=>(0,x.jsx)(l,{value:e.value,children:t(e.label)},e.value))})]})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`searchProviderIncludeAnswer`)}),(0,x.jsxs)(u,{value:f?`true`:`false`,onValueChange:e=>y(e===`true`),children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsxs)(c,{children:[(0,x.jsx)(l,{value:`true`,children:t(`enabled`)}),(0,x.jsx)(l,{value:`false`,children:t(`disabled`)})]})]})]})]}),m?(0,x.jsx)(`div`,{className:`space-y-2`,children:(0,x.jsx)(`a`,{href:m,target:`_blank`,rel:`noreferrer`,children:(0,x.jsxs)(a,{type:`button`,variant:`outline`,className:`rounded-xl`,children:[(0,x.jsx)(d,{className:`mr-2 h-4 w-4`}),t(`searchProviderOpenDocs`)]})})}):null]})}function oe({apiKey:e,apiKeyMasked:n,baseUrl:r,onApiKeyChange:i,onBaseUrlChange:a}){return(0,x.jsxs)(`div`,{className:`space-y-4`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`apiKey`)}),(0,x.jsx)(p,{type:`password`,value:e,onChange:e=>i(e.target.value),placeholder:n||t(`enterApiKey`),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`searchProviderBaseUrl`)}),(0,x.jsx)(p,{value:r,onChange:e=>a(e.target.value),className:`rounded-xl`})]})]})}function T(){let{data:e}=m(),{data:n}=g(),r=h(),d=(0,b.useMemo)(()=>n?.search??[],[n]),S=e?.search,[C,T]=(0,b.useState)(`bocha`),[E,D]=(0,b.useState)(`bocha`),[O,k]=(0,b.useState)([`bocha`]),[A,j]=(0,b.useState)(`10`),[M,se]=(0,b.useState)(``),[N,P]=(0,b.useState)(`https://api.bocha.cn/v1/web-search`),[F,I]=(0,b.useState)(!0),[L,R]=(0,b.useState)(`noLimit`),[z,ce]=(0,b.useState)(``),[B,V]=(0,b.useState)(`https://api.tavily.com/search`),[H,U]=(0,b.useState)(`basic`),[W,G]=(0,b.useState)(!1),[K,le]=(0,b.useState)(``),[q,J]=(0,b.useState)(`https://api.search.brave.com/res/v1/web/search`);(0,b.useEffect)(()=>{S&&(T(S.provider),D(S.provider),k(S.enabledProviders),j(String(S.defaults.maxResults)),P(S.providers.bocha.baseUrl),I(!!S.providers.bocha.summary),R(S.providers.bocha.freshness??`noLimit`),V(S.providers.tavily.baseUrl),U(S.providers.tavily.searchDepth??`basic`),G(!!S.providers.tavily.includeAnswer),J(S.providers.brave.baseUrl))},[S]);let Y=(0,b.useMemo)(()=>d.find(e=>e.name===C),[d,C]),X=S?.providers[C],Z=O.includes(C),Q=X?.docsUrl??Y?.docsUrl,ue=t(Z?`searchProviderDeactivate`:`searchProviderActivate`),$=(e=O,t=E)=>({provider:t,enabledProviders:e,defaults:{maxResults:Number(A)||10},providers:{bocha:{apiKey:M||void 0,baseUrl:N,summary:F,freshness:L},tavily:{apiKey:z||void 0,baseUrl:B,searchDepth:H,includeAnswer:W},brave:{apiKey:K||void 0,baseUrl:q}}});return!S||d.length===0?(0,x.jsx)(`div`,{className:`p-8`,children:t(`loading`)}):(0,x.jsxs)(y,{children:[(0,x.jsx)(ee,{title:t(`searchPageTitle`),description:t(`searchPageDescription`)}),(0,x.jsxs)(`div`,{className:te,children:[(0,x.jsxs)(`section`,{className:ne,children:[(0,x.jsx)(`div`,{className:`border-b border-gray-100 px-4 py-4`,children:(0,x.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-gray-500`,children:t(`searchChannels`)})}),(0,x.jsx)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-3`,children:d.map(e=>{let n=S.providers[e.name],r=O.includes(e.name);return(0,x.jsx)(`button`,{type:`button`,onClick:()=>T(e.name),className:i(`w-full rounded-xl border p-3 text-left transition-all`,C===e.name?`border-primary/30 bg-primary-50/40 shadow-sm`:`border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70`),children:(0,x.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.displayName}),(0,x.jsx)(`p`,{className:`line-clamp-2 text-[11px] text-gray-500`,children:t(ie[e.name])})]}),(0,x.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[(0,x.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600`,children:n.apiKeySet?t(`searchStatusConfigured`):t(`searchStatusNeedsSetup`)}),r?(0,x.jsx)(`span`,{className:`rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700`,children:t(`searchProviderActivated`)}):null]})]})},e.name)})})]}),(0,x.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),r.mutate({data:$()})},className:i(re,`p-6`),children:!Y||!X?(0,x.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:t(`searchNoProviderSelected`)}):(0,x.jsxs)(`div`,{className:`space-y-6 overflow-y-auto`,children:[(0,x.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white`,children:(0,x.jsx)(f,{className:`h-5 w-5`})}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900`,children:Y.displayName}),(0,x.jsx)(`p`,{className:`text-sm text-gray-500`,children:Y.description})]})]}),(0,x.jsx)(a,{type:`button`,variant:Z?`secondary`:`outline`,className:`rounded-xl`,onClick:()=>{let e=Z?O.filter(e=>e!==C):[...O,C];k(e),r.mutate({data:$(e)})},children:ue})]}),(0,x.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`searchActiveProvider`)}),(0,x.jsxs)(u,{value:E,onValueChange:e=>{D(e)},children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsx)(c,{children:d.map(e=>(0,x.jsx)(l,{value:e.name,children:e.displayName},e.name))})]})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`searchDefaultMaxResults`)}),(0,x.jsx)(p,{value:A,onChange:e=>j(e.target.value),inputMode:`numeric`,className:`rounded-xl`})]})]}),C===`bocha`?(0,x.jsx)(ae,{apiKey:M,apiKeyMasked:S.providers.bocha.apiKeyMasked,baseUrl:N,summary:F,freshness:L,docsUrl:Q,onApiKeyChange:se,onBaseUrlChange:P,onSummaryChange:I,onFreshnessChange:R}):C===`tavily`?(0,x.jsx)(w,{apiKey:z,apiKeyMasked:S.providers.tavily.apiKeyMasked,baseUrl:B,searchDepth:H,includeAnswer:W,docsUrl:Q,onApiKeyChange:ce,onBaseUrlChange:V,onSearchDepthChange:U,onIncludeAnswerChange:G}):(0,x.jsx)(oe,{apiKey:K,apiKeyMasked:S.providers.brave.apiKeyMasked,baseUrl:q,onApiKeyChange:le,onBaseUrlChange:J}),(0,x.jsx)(`div`,{className:`flex justify-end`,children:(0,x.jsxs)(a,{type:`submit`,disabled:r.isPending,children:[(0,x.jsx)(_,{className:`mr-2 h-4 w-4`}),r.isPending?t(`saving`):t(`saveChanges`)]})})]})})]})]})}export{T as SearchConfig};
|
|
1
|
+
import{_ as e,i as t,m as n,p as r,u as i}from"./i18n-hM3v-3YG.js";import{o as a}from"./dist-RWNFhxvR.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-DF-AUoie.js";import{t as d}from"./external-link-U86Acd1t.js";import{t as f}from"./search-EX-Papzl.js";import{W as p,c as m,j as h,l as g,mt as _}from"./index-DHmCjcxq.js";import{t as v}from"./label-CHJ1ATds.js";import{n as y,t as ee}from"./page-layout-Z1klaUFW.js";import{i as te,r as ne,t as re}from"./config-layout-LQ10ozRC.js";var b=e(n(),1),x=r(),S=[{value:`noLimit`,label:`searchFreshnessNoLimit`},{value:`oneDay`,label:`searchFreshnessOneDay`},{value:`oneWeek`,label:`searchFreshnessOneWeek`},{value:`oneMonth`,label:`searchFreshnessOneMonth`},{value:`oneYear`,label:`searchFreshnessOneYear`}],C=[{value:`basic`,label:`searchDepthBasic`},{value:`advanced`,label:`searchDepthAdvanced`}],ie={bocha:`searchProviderBochaDescription`,tavily:`searchProviderTavilyDescription`,brave:`searchProviderBraveDescription`};function ae({apiKey:e,apiKeyMasked:n,baseUrl:r,summary:i,freshness:f,docsUrl:m,onApiKeyChange:h,onBaseUrlChange:g,onSummaryChange:_,onFreshnessChange:y}){return(0,x.jsxs)(`div`,{className:`space-y-4`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`apiKey`)}),(0,x.jsx)(p,{type:`password`,value:e,onChange:e=>h(e.target.value),placeholder:n||t(`enterApiKey`),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`searchProviderBaseUrl`)}),(0,x.jsx)(p,{value:r,onChange:e=>g(e.target.value),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`searchProviderSummary`)}),(0,x.jsxs)(u,{value:i?`true`:`false`,onValueChange:e=>_(e===`true`),children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsxs)(c,{children:[(0,x.jsx)(l,{value:`true`,children:t(`enabled`)}),(0,x.jsx)(l,{value:`false`,children:t(`disabled`)})]})]})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`searchProviderFreshness`)}),(0,x.jsxs)(u,{value:f,onValueChange:y,children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsx)(c,{children:S.map(e=>(0,x.jsx)(l,{value:e.value,children:t(e.label)},e.value))})]})]})]}),(0,x.jsx)(`div`,{className:`space-y-2`,children:(0,x.jsx)(`a`,{href:m??`https://open.bocha.cn`,target:`_blank`,rel:`noreferrer`,children:(0,x.jsxs)(a,{type:`button`,variant:`outline`,className:`rounded-xl`,children:[(0,x.jsx)(d,{className:`mr-2 h-4 w-4`}),t(`searchProviderOpenDocs`)]})})})]})}function w({apiKey:e,apiKeyMasked:n,baseUrl:r,searchDepth:i,includeAnswer:f,docsUrl:m,onApiKeyChange:h,onBaseUrlChange:g,onSearchDepthChange:_,onIncludeAnswerChange:y}){return(0,x.jsxs)(`div`,{className:`space-y-4`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`apiKey`)}),(0,x.jsx)(p,{type:`password`,value:e,onChange:e=>h(e.target.value),placeholder:n||t(`enterApiKey`),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`searchProviderBaseUrl`)}),(0,x.jsx)(p,{value:r,onChange:e=>g(e.target.value),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`searchProviderSearchDepth`)}),(0,x.jsxs)(u,{value:i,onValueChange:e=>_(e),children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsx)(c,{children:C.map(e=>(0,x.jsx)(l,{value:e.value,children:t(e.label)},e.value))})]})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`searchProviderIncludeAnswer`)}),(0,x.jsxs)(u,{value:f?`true`:`false`,onValueChange:e=>y(e===`true`),children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsxs)(c,{children:[(0,x.jsx)(l,{value:`true`,children:t(`enabled`)}),(0,x.jsx)(l,{value:`false`,children:t(`disabled`)})]})]})]})]}),m?(0,x.jsx)(`div`,{className:`space-y-2`,children:(0,x.jsx)(`a`,{href:m,target:`_blank`,rel:`noreferrer`,children:(0,x.jsxs)(a,{type:`button`,variant:`outline`,className:`rounded-xl`,children:[(0,x.jsx)(d,{className:`mr-2 h-4 w-4`}),t(`searchProviderOpenDocs`)]})})}):null]})}function oe({apiKey:e,apiKeyMasked:n,baseUrl:r,onApiKeyChange:i,onBaseUrlChange:a}){return(0,x.jsxs)(`div`,{className:`space-y-4`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`apiKey`)}),(0,x.jsx)(p,{type:`password`,value:e,onChange:e=>i(e.target.value),placeholder:n||t(`enterApiKey`),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`searchProviderBaseUrl`)}),(0,x.jsx)(p,{value:r,onChange:e=>a(e.target.value),className:`rounded-xl`})]})]})}function T(){let{data:e}=m(),{data:n}=g(),r=h(),d=(0,b.useMemo)(()=>n?.search??[],[n]),S=e?.search,[C,T]=(0,b.useState)(`bocha`),[E,D]=(0,b.useState)(`bocha`),[O,k]=(0,b.useState)([`bocha`]),[A,j]=(0,b.useState)(`10`),[M,se]=(0,b.useState)(``),[N,P]=(0,b.useState)(`https://api.bocha.cn/v1/web-search`),[F,I]=(0,b.useState)(!0),[L,R]=(0,b.useState)(`noLimit`),[z,ce]=(0,b.useState)(``),[B,V]=(0,b.useState)(`https://api.tavily.com/search`),[H,U]=(0,b.useState)(`basic`),[W,G]=(0,b.useState)(!1),[K,le]=(0,b.useState)(``),[q,J]=(0,b.useState)(`https://api.search.brave.com/res/v1/web/search`);(0,b.useEffect)(()=>{S&&(T(S.provider),D(S.provider),k(S.enabledProviders),j(String(S.defaults.maxResults)),P(S.providers.bocha.baseUrl),I(!!S.providers.bocha.summary),R(S.providers.bocha.freshness??`noLimit`),V(S.providers.tavily.baseUrl),U(S.providers.tavily.searchDepth??`basic`),G(!!S.providers.tavily.includeAnswer),J(S.providers.brave.baseUrl))},[S]);let Y=(0,b.useMemo)(()=>d.find(e=>e.name===C),[d,C]),X=S?.providers[C],Z=O.includes(C),Q=X?.docsUrl??Y?.docsUrl,ue=t(Z?`searchProviderDeactivate`:`searchProviderActivate`),$=(e=O,t=E)=>({provider:t,enabledProviders:e,defaults:{maxResults:Number(A)||10},providers:{bocha:{apiKey:M||void 0,baseUrl:N,summary:F,freshness:L},tavily:{apiKey:z||void 0,baseUrl:B,searchDepth:H,includeAnswer:W},brave:{apiKey:K||void 0,baseUrl:q}}});return!S||d.length===0?(0,x.jsx)(`div`,{className:`p-8`,children:t(`loading`)}):(0,x.jsxs)(y,{children:[(0,x.jsx)(ee,{title:t(`searchPageTitle`),description:t(`searchPageDescription`)}),(0,x.jsxs)(`div`,{className:te,children:[(0,x.jsxs)(`section`,{className:ne,children:[(0,x.jsx)(`div`,{className:`border-b border-gray-100 px-4 py-4`,children:(0,x.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-gray-500`,children:t(`searchChannels`)})}),(0,x.jsx)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-3`,children:d.map(e=>{let n=S.providers[e.name],r=O.includes(e.name);return(0,x.jsx)(`button`,{type:`button`,onClick:()=>T(e.name),className:i(`w-full rounded-xl border p-3 text-left transition-all`,C===e.name?`border-primary/30 bg-primary-50/40 shadow-sm`:`border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70`),children:(0,x.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.displayName}),(0,x.jsx)(`p`,{className:`line-clamp-2 text-[11px] text-gray-500`,children:t(ie[e.name])})]}),(0,x.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[(0,x.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600`,children:n.apiKeySet?t(`searchStatusConfigured`):t(`searchStatusNeedsSetup`)}),r?(0,x.jsx)(`span`,{className:`rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700`,children:t(`searchProviderActivated`)}):null]})]})},e.name)})})]}),(0,x.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),r.mutate({data:$()})},className:i(re,`p-6`),children:!Y||!X?(0,x.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:t(`searchNoProviderSelected`)}):(0,x.jsxs)(`div`,{className:`space-y-6 overflow-y-auto`,children:[(0,x.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white`,children:(0,x.jsx)(f,{className:`h-5 w-5`})}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900`,children:Y.displayName}),(0,x.jsx)(`p`,{className:`text-sm text-gray-500`,children:Y.description})]})]}),(0,x.jsx)(a,{type:`button`,variant:Z?`secondary`:`outline`,className:`rounded-xl`,onClick:()=>{let e=Z?O.filter(e=>e!==C):[...O,C];k(e),r.mutate({data:$(e)})},children:ue})]}),(0,x.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`searchActiveProvider`)}),(0,x.jsxs)(u,{value:E,onValueChange:e=>{D(e)},children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsx)(c,{children:d.map(e=>(0,x.jsx)(l,{value:e.name,children:e.displayName},e.name))})]})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(v,{children:t(`searchDefaultMaxResults`)}),(0,x.jsx)(p,{value:A,onChange:e=>j(e.target.value),inputMode:`numeric`,className:`rounded-xl`})]})]}),C===`bocha`?(0,x.jsx)(ae,{apiKey:M,apiKeyMasked:S.providers.bocha.apiKeyMasked,baseUrl:N,summary:F,freshness:L,docsUrl:Q,onApiKeyChange:se,onBaseUrlChange:P,onSummaryChange:I,onFreshnessChange:R}):C===`tavily`?(0,x.jsx)(w,{apiKey:z,apiKeyMasked:S.providers.tavily.apiKeyMasked,baseUrl:B,searchDepth:H,includeAnswer:W,docsUrl:Q,onApiKeyChange:ce,onBaseUrlChange:V,onSearchDepthChange:U,onIncludeAnswerChange:G}):(0,x.jsx)(oe,{apiKey:K,apiKeyMasked:S.providers.brave.apiKeyMasked,baseUrl:q,onApiKeyChange:le,onBaseUrlChange:J}),(0,x.jsx)(`div`,{className:`flex justify-end`,children:(0,x.jsxs)(a,{type:`submit`,disabled:r.isPending,children:[(0,x.jsx)(_,{className:`mr-2 h-4 w-4`}),r.isPending?t(`saving`):t(`saveChanges`)]})})]})})]})]})}export{T as SearchConfig};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,p as r}from"./i18n-hM3v-3YG.js";import{n as i,o as a}from"./dist-RWNFhxvR.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-DF-AUoie.js";import{t as d}from"./plus-CrkO1kob.js";import{t as f}from"./save-4VRlzkii.js";import{t as p}from"./trash-2-VV8jvziy.js";import{G as m,J as h,K as g,M as _,W as v,Y as y,c as b,q as x}from"./index-
|
|
1
|
+
import{_ as e,i as t,m as n,p as r}from"./i18n-hM3v-3YG.js";import{n as i,o as a}from"./dist-RWNFhxvR.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-DF-AUoie.js";import{t as d}from"./plus-CrkO1kob.js";import{t as f}from"./save-4VRlzkii.js";import{t as p}from"./trash-2-VV8jvziy.js";import{G as m,J as h,K as g,M as _,W as v,Y as y,c as b,q as x}from"./index-DHmCjcxq.js";import{t as S}from"./label-CHJ1ATds.js";import{n as C,t as w}from"./page-layout-Z1klaUFW.js";import{t as T}from"./switch-D7JF_RZ-.js";var E=e(n(),1),D=r(),O=[`env`,`file`,`exec`];function k(e=``){return{alias:e,source:`env`,prefix:``,path:``,command:``,argsText:``,cwd:``,timeoutMs:5e3}}function A(){return{path:``,source:`env`,provider:``,id:``}}function j(e,t){return t.source===`env`?{...k(e),source:`env`,prefix:t.prefix??``}:t.source===`file`?{...k(e),source:`file`,path:t.path}:{...k(e),source:`exec`,command:t.command,argsText:(t.args??[]).join(`
|
|
2
2
|
`),cwd:t.cwd??``,timeoutMs:t.timeoutMs??5e3}}function M(e){return e.source===`env`?{source:`env`,...e.prefix.trim()?{prefix:e.prefix.trim()}:{}}:e.source===`file`?{source:`file`,path:e.path.trim(),format:`json`}:{source:`exec`,command:e.command.trim(),args:e.argsText.split(`
|
|
3
3
|
`).map(e=>e.trim()).filter(Boolean),...e.cwd.trim()?{cwd:e.cwd.trim()}:{},timeoutMs:Math.max(1,Math.trunc(e.timeoutMs||5e3))}}function N(){let{data:e,isLoading:n}=b(),r=_(),[N,P]=(0,E.useState)(!0),[F,I]=(0,E.useState)(``),[L,R]=(0,E.useState)(``),[z,B]=(0,E.useState)(``),[V,H]=(0,E.useState)([]),[U,W]=(0,E.useState)([]);(0,E.useEffect)(()=>{let t=e?.secrets;if(!t){P(!0),I(``),R(``),B(``),H([]),W([]);return}P(!!t.enabled),I(t.defaults.env??``),R(t.defaults.file??``),B(t.defaults.exec??``);let n=Object.entries(t.providers).map(([e,t])=>j(e,t)),r=Object.entries(t.refs).map(([e,t])=>({path:e,source:t.source,provider:t.provider??``,id:t.id}));H(n),W(r)},[e?.secrets]);let G=(0,E.useMemo)(()=>{let e=V.map(e=>e.alias.trim()).filter(Boolean);return Array.from(new Set(e))},[V]),K=(e,t)=>{H(n=>n.map((n,r)=>r===e?{...n,...t}:n))},q=(e,t)=>{W(n=>n.map((n,r)=>r===e?{...n,...t}:n))};return n?(0,D.jsx)(`div`,{className:`p-8 text-gray-400`,children:t(`loading`)}):(0,D.jsxs)(C,{className:`space-y-6`,children:[(0,D.jsx)(w,{title:t(`secretsPageTitle`),description:t(`secretsPageDescription`)}),(0,D.jsxs)(m,{children:[(0,D.jsxs)(h,{children:[(0,D.jsx)(y,{children:t(`secrets`)}),(0,D.jsx)(x,{children:t(`secretsEnabledHelp`)})]}),(0,D.jsxs)(g,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-gray-200 p-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`p`,{className:`text-sm font-medium text-gray-800`,children:t(`enabled`)}),(0,D.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`secretsEnabledHelp`)})]}),(0,D.jsx)(T,{checked:N,onCheckedChange:P})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(S,{children:t(`defaultEnvProvider`)}),(0,D.jsxs)(u,{value:F||`__none__`,onValueChange:e=>I(e===`__none__`?``:e),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`noneOption`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]})]}),(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(S,{children:t(`defaultFileProvider`)}),(0,D.jsxs)(u,{value:L||`__none__`,onValueChange:e=>R(e===`__none__`?``:e),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`noneOption`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]})]}),(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(S,{children:t(`defaultExecProvider`)}),(0,D.jsxs)(u,{value:z||`__none__`,onValueChange:e=>B(e===`__none__`?``:e),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`noneOption`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]})]})]})]})]}),(0,D.jsxs)(m,{children:[(0,D.jsxs)(h,{children:[(0,D.jsx)(y,{children:t(`secretProvidersTitle`)}),(0,D.jsx)(x,{children:t(`secretProvidersDescription`)})]}),(0,D.jsxs)(g,{className:`space-y-3`,children:[V.map((e,n)=>(0,D.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,D.jsx)(v,{value:e.alias,onChange:e=>K(n,{alias:e.target.value}),placeholder:t(`providerAlias`)}),(0,D.jsxs)(u,{value:e.source,onValueChange:e=>K(n,{source:e}),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{})}),(0,D.jsx)(c,{children:O.map(e=>(0,D.jsx)(l,{value:e,children:e},e))})]}),(0,D.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>H(e=>e.filter((e,t)=>t!==n)),children:[(0,D.jsx)(p,{className:`h-4 w-4 mr-2`}),t(`removeProvider`)]})]}),e.source===`env`&&(0,D.jsx)(v,{value:e.prefix,onChange:e=>K(n,{prefix:e.target.value}),placeholder:t(`envPrefix`)}),e.source===`file`&&(0,D.jsx)(v,{value:e.path,onChange:e=>K(n,{path:e.target.value}),placeholder:t(`secretFilePath`)}),e.source===`exec`&&(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(v,{value:e.command,onChange:e=>K(n,{command:e.target.value}),placeholder:t(`secretExecCommand`)}),(0,D.jsx)(`textarea`,{className:`min-h-[84px] w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono`,value:e.argsText,onChange:e=>K(n,{argsText:e.target.value}),placeholder:t(`secretExecArgs`)}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2`,children:[(0,D.jsx)(v,{value:e.cwd,onChange:e=>K(n,{cwd:e.target.value}),placeholder:t(`secretExecCwd`)}),(0,D.jsx)(v,{type:`number`,min:1,value:e.timeoutMs,onChange:e=>K(n,{timeoutMs:Number.parseInt(e.target.value,10)||5e3}),placeholder:t(`secretExecTimeoutMs`)})]})]})]},`provider-${n}`)),(0,D.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>H(e=>[...e,k()]),children:[(0,D.jsx)(d,{className:`h-4 w-4 mr-2`}),t(`addSecretProvider`)]})]})]}),(0,D.jsxs)(m,{children:[(0,D.jsxs)(h,{children:[(0,D.jsx)(y,{children:t(`secretRefsTitle`)}),(0,D.jsx)(x,{children:t(`secretRefsDescription`)})]}),(0,D.jsxs)(g,{className:`space-y-3`,children:[U.map((e,n)=>(0,D.jsx)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,D.jsx)(v,{value:e.path,onChange:e=>q(n,{path:e.target.value}),placeholder:t(`secretConfigPath`)}),(0,D.jsx)(v,{value:e.id,onChange:e=>q(n,{id:e.target.value}),placeholder:t(`secretId`)}),(0,D.jsxs)(u,{value:e.source,onValueChange:e=>q(n,{source:e}),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{})}),(0,D.jsx)(c,{children:O.map(e=>(0,D.jsx)(l,{value:e,children:e},e))})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2`,children:[(0,D.jsxs)(u,{value:e.provider||`__none__`,onValueChange:e=>q(n,{provider:e===`__none__`?``:e}),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`secretProviderAlias`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]}),(0,D.jsx)(a,{type:`button`,variant:`outline`,onClick:()=>W(e=>e.filter((e,t)=>t!==n)),children:(0,D.jsx)(p,{className:`h-4 w-4`})})]})]})},`ref-${n}`)),(0,D.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>W(e=>[...e,A()]),children:[(0,D.jsx)(d,{className:`h-4 w-4 mr-2`}),t(`addSecretRef`)]})]})]}),(0,D.jsx)(`div`,{className:`flex justify-end`,children:(0,D.jsxs)(a,{type:`button`,onClick:()=>{try{let e={};for(let[n,r]of V.entries()){let i=r.alias.trim();if(!i)throw Error(`${t(`providerAlias`)} #${n+1} ${t(`isRequired`)}`);if(e[i])throw Error(`${t(`providerAlias`)}: ${i} (${t(`duplicate`)})`);if(r.source===`file`&&!r.path.trim())throw Error(`${t(`secretFilePath`)} #${n+1} ${t(`isRequired`)}`);if(r.source===`exec`&&!r.command.trim())throw Error(`${t(`secretExecCommand`)} #${n+1} ${t(`isRequired`)}`);e[i]=M(r)}let n={};for(let[r,i]of U.entries()){let a=i.path.trim(),o=i.id.trim();if(!a)throw Error(`${t(`secretConfigPath`)} #${r+1} ${t(`isRequired`)}`);if(!o)throw Error(`${t(`secretId`)} #${r+1} ${t(`isRequired`)}`);let s=i.provider.trim();if(s&&!e[s])throw Error(`${t(`secretProviderAlias`)}: ${s} ${t(`notFound`)}`);n[a]={source:i.source,...s?{provider:s}:{},id:o}}r.mutate({data:{enabled:N,defaults:{env:F.trim()||null,file:L.trim()||null,exec:z.trim()||null},providers:e,refs:n}})}catch(e){let t=e instanceof Error?e.message:String(e);i.error(t)}},disabled:r.isPending,children:[(0,D.jsx)(f,{className:`h-4 w-4 mr-2`}),r.isPending?t(`saving`):t(`save`)]})})]})}export{N as SecretsConfig};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,n as r,p as i,t as a,u as o}from"./i18n-hM3v-3YG.js";import{o as s}from"./dist-RWNFhxvR.js";import{a as c,i as l,n as ee,r as u,t as d}from"./select-DF-AUoie.js";import{t as f}from"./createLucideIcon-C7MmdIX3.js";import{t as p}from"./hash-D-OVfV3Z.js";import{d as m,i as h,l as g,n as _,t as v,u as y}from"./chat-session-display-D4bYa0b8.js";import{t as b}from"./search-EX-Papzl.js";import{O as x,W as S,b as C,ft as w,gt as T,lt as te,m as ne,v as E}from"./index-
|
|
1
|
+
import{_ as e,i as t,m as n,n as r,p as i,t as a,u as o}from"./i18n-hM3v-3YG.js";import{o as s}from"./dist-RWNFhxvR.js";import{a as c,i as l,n as ee,r as u,t as d}from"./select-DF-AUoie.js";import{t as f}from"./createLucideIcon-C7MmdIX3.js";import{t as p}from"./hash-D-OVfV3Z.js";import{d as m,i as h,l as g,n as _,t as v,u as y}from"./chat-session-display-D4bYa0b8.js";import{t as b}from"./search-EX-Papzl.js";import{O as x,W as S,b as C,ft as w,gt as T,lt as te,m as ne,v as E}from"./index-DHmCjcxq.js";import{n as D,t as O}from"./page-layout-Z1klaUFW.js";import{t as k}from"./useConfirmDialog-CuQqiPx7.js";var A=f(`Clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]),j=f(`Inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]),M=e(n(),1),N=i(),P=`__unknown_channel__`;function F(e){return r(e)}function I(e){let t=e.indexOf(`:`);return t<=0?P:e.slice(0,t).trim()||P}function L(e){return e===P?t(`sessionsUnknownChannel`):e}function R(e){return e===`service`?`system`:e===`tool`?`tool`:e}function z(e){let t=[];for(let n of e.parts){if(n.type===`text`||n.type===`rich-text`||n.type===`reasoning`){t.push(n.text);continue}if(n.type===`tool-invocation`){let e=n.toolName?.trim()?`[${n.toolName.trim()}]`:`[tool]`;if(n.state===`result`&&typeof n.result==`string`&&n.result.trim()){t.push(`${e} ${n.result.trim()}`);continue}t.push(e)}}return t.join(`
|
|
2
2
|
`).trim()}function B({session:e,summary:t,channel:n,isSelected:r,onSelect:i}){let s=L(n),c=v(e);return(0,N.jsxs)(`button`,{onClick:i,className:o(`w-full text-left p-3.5 rounded-xl transition-all duration-200 outline-none focus:outline-none focus:ring-0 group`,r?`bg-brand-50 border border-brand-100/50`:`bg-transparent border border-transparent hover:bg-gray-50/80`),children:[(0,N.jsxs)(`div`,{className:`flex items-start justify-between mb-1.5`,children:[(0,N.jsx)(`div`,{className:o(`font-semibold truncate pr-2 flex-1 text-sm`,r?`text-brand-800`:`text-gray-900`),children:c}),(0,N.jsx)(`div`,{className:o(`text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 capitalize`,r?`bg-white text-brand-600 shadow-[0_1px_2px_rgba(0,0,0,0.02)]`:`bg-gray-100 text-gray-500`),children:s})]}),(0,N.jsxs)(`div`,{className:o(`flex items-center text-xs justify-between mt-2 font-medium`,r?`text-brand-600/80`:`text-gray-400`),children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,N.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center`,children:t.status===`running`?(0,N.jsx)(g,{status:`running`}):null}),(0,N.jsx)(A,{className:`w-3.5 h-3.5 opacity-70`}),(0,N.jsx)(`span`,{className:`truncate max-w-[100px]`,children:a(t.updatedAt)})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(w,{className:`w-3.5 h-3.5 opacity-70`}),(0,N.jsx)(`span`,{children:t.messageCount})]})]})]})}function V({message:e}){let t=R(e.role),n=t===`user`,r=z(e);return(0,N.jsx)(`div`,{className:o(`flex w-full mb-6`,n?`justify-end`:`justify-start`),children:(0,N.jsxs)(`div`,{className:o(`max-w-[85%] rounded-[1.25rem] p-5 flex gap-3 text-sm`,n?`bg-primary text-white rounded-tr-sm`:`bg-gray-50 text-gray-800 rounded-tl-sm border border-gray-100/50`),children:[(0,N.jsx)(`div`,{className:`shrink-0 pt-0.5`,children:n?(0,N.jsx)(y,{className:`w-4 h-4 text-primary-100`}):(0,N.jsx)(T,{className:`w-4 h-4 text-gray-400`})}),(0,N.jsxs)(`div`,{className:`flex-1 space-y-1 overflow-x-hidden`,children:[(0,N.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 mb-2`,children:[(0,N.jsx)(`span`,{className:o(`font-semibold text-xs capitalize`,n?`text-primary-50`:`text-gray-900`),children:t}),(0,N.jsx)(`span`,{className:o(`text-[10px]`,n?`text-primary-200`:`text-gray-400`),children:F(e.timestamp)})]}),(0,N.jsx)(`div`,{className:`whitespace-pre-wrap break-words leading-relaxed text-[15px]`,children:r||`-`})]})]})})}function H(){let[e,n]=(0,M.useState)(``),[r]=(0,M.useState)(100),[i,a]=(0,M.useState)(null),[f,y]=(0,M.useState)(`all`),[T,A]=(0,M.useState)(``),[F,R]=(0,M.useState)(``),[z,H]=(0,M.useState)(!1),U=C({limit:r}),W=E(i,300),G=x(),K=ne(),{confirm:q,ConfirmDialog:re}=k(),J=(0,M.useMemo)(()=>U.data?.sessions??[],[U.data?.sessions]),Y=(0,M.useMemo)(()=>h(J),[J]),X=(0,M.useMemo)(()=>new Map(J.map(e=>[e.sessionId,e])),[J]),Z=(0,M.useMemo)(()=>Y.filter(t=>f!==`all`&&I(t.key)!==f?!1:_(t,e)),[e,f,Y]),Q=(0,M.useMemo)(()=>Y.find(e=>e.key===i)??null,[i,Y]),$=(0,M.useMemo)(()=>i?X.get(i)??null:null,[i,X]),ie=(0,M.useMemo)(()=>{let e=new Set;for(let t of Y)e.add(I(t.key));return Array.from(e).sort((e,t)=>e===P?1:t===P?-1:e.localeCompare(t))},[Y]);return(0,M.useEffect)(()=>{i&&!X.has(i)&&a(null)},[i,X]),(0,M.useEffect)(()=>{Q?(A(Q.label||``),R(Q.preferredModel||``)):(A(``),R(``)),H(!1)},[Q]),(0,N.jsxs)(D,{fullHeight:!0,children:[(0,N.jsx)(O,{title:t(`sessionsPageTitle`),description:t(`sessionsPageDescription`)}),(0,N.jsxs)(`div`,{className:`flex-1 flex gap-6 min-h-0 relative`,children:[(0,N.jsxs)(`div`,{className:`w-[320px] flex flex-col shrink-0 bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden`,children:[(0,N.jsxs)(`div`,{className:`px-4 py-4 border-b border-gray-100 bg-white z-10 shrink-0 space-y-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsxs)(`span`,{className:`text-[11px] font-semibold text-gray-400 uppercase tracking-wider`,children:[Y.length,` `,t(`sessionsListTitle`)]}),(0,N.jsx)(s,{variant:`ghost`,size:`icon`,className:`h-7 w-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100`,onClick:()=>U.refetch(),children:(0,N.jsx)(m,{className:o(`h-3.5 w-3.5`,U.isFetching&&`animate-spin`)})})]}),(0,N.jsxs)(d,{value:f,onValueChange:y,children:[(0,N.jsx)(l,{className:`w-full h-8.5 rounded-lg bg-gray-50/50 hover:bg-gray-100 border-gray-200 focus:ring-0 shadow-none text-xs font-medium text-gray-700`,children:(0,N.jsx)(c,{placeholder:t(`sessionsAllChannels`)})}),(0,N.jsxs)(ee,{className:`rounded-xl shadow-lg border-gray-100 max-w-[280px]`,children:[(0,N.jsx)(u,{value:`all`,className:`rounded-lg text-xs`,children:t(`sessionsAllChannels`)}),ie.map(e=>(0,N.jsx)(u,{value:e,className:`rounded-lg text-xs truncate pr-6`,children:L(e)},e))]})]}),(0,N.jsxs)(`div`,{className:`relative w-full`,children:[(0,N.jsx)(b,{className:`h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400`}),(0,N.jsx)(S,{value:e,onChange:e=>n(e.target.value),placeholder:t(`sessionsSearchPlaceholder`),className:`pl-8 h-8.5 rounded-lg bg-gray-50/50 border-gray-200 focus-visible:bg-white text-xs`})]})]}),(0,N.jsx)(`div`,{className:`flex-1 overflow-y-auto p-3 space-y-1 pb-10 custom-scrollbar relative`,children:U.isLoading?(0,N.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:t(`sessionsLoading`)}):Z.length===0?(0,N.jsxs)(`div`,{className:`text-sm text-gray-400 p-4 text-center border-2 border-dashed border-gray-100 rounded-xl mt-4`,children:[(0,N.jsx)(j,{className:`w-8 h-8 mx-auto mb-2 text-gray-300`}),t(`sessionsEmpty`)]}):Z.map(e=>{let t=X.get(e.key);return t?(0,N.jsx)(B,{session:e,summary:t,channel:I(e.key),isSelected:i===e.key,onSelect:()=>a(e.key)},e.key):null})})]}),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col overflow-hidden relative bg-white rounded-2xl shadow-sm border border-gray-200`,children:[(G.isPending||K.isPending)&&(0,N.jsx)(`div`,{className:`absolute top-0 left-0 w-full h-1 bg-primary/20 overflow-hidden z-20`,children:(0,N.jsx)(`div`,{className:`h-full bg-primary animate-pulse w-1/3 rounded-r-full`})}),i&&Q&&$?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`shrink-0 border-b border-gray-100 bg-white px-8 py-5 z-10 space-y-4`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,N.jsx)(`div`,{className:`h-12 w-12 rounded-[14px] bg-gray-50 border border-gray-100 flex items-center justify-center text-gray-400 shrink-0`,children:(0,N.jsx)(p,{className:`h-6 w-6`})}),(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2.5 mb-1.5`,children:[(0,N.jsx)(`h3`,{className:`text-lg font-bold text-gray-900 tracking-tight`,children:v(Q)}),(0,N.jsx)(`span`,{className:`text-[10px] font-bold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500 uppercase tracking-widest`,children:L(I(Q.key))}),$.status===`running`?(0,N.jsx)(g,{status:`running`,className:`h-4 w-4`}):null]}),(0,N.jsx)(`div`,{className:`text-xs text-gray-500 font-mono break-all line-clamp-1 opacity-70`,title:i,children:i})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,N.jsxs)(s,{variant:`outline`,size:`sm`,onClick:()=>H(!z),className:o(`h-8.5 rounded-lg shadow-none border-gray-200 transition-all text-xs font-semibold`,z?`bg-gray-100 text-gray-900`:`hover:bg-gray-50 hover:text-gray-900`),children:[(0,N.jsx)(te,{className:`w-3.5 h-3.5 mr-1.5`}),t(`sessionsMetadata`)]}),(0,N.jsx)(s,{variant:`outline`,size:`sm`,onClick:async()=>{i&&await q({title:t(`sessionsDeleteConfirm`)+`?`,variant:`destructive`,confirmLabel:t(`sessionsDeleteConfirm`)})&&K.mutate({sessionId:i},{onSuccess:()=>a(null)})},className:`h-8.5 rounded-lg shadow-none hover:bg-red-50 hover:text-red-600 hover:border-red-200 border-gray-200 text-xs font-semibold text-red-500`,children:t(`delete`)})]})]}),z&&(0,N.jsxs)(`div`,{className:`flex items-center gap-3 bg-gray-50/50 p-3 rounded-lg border border-gray-100 animate-slide-in`,children:[(0,N.jsx)(S,{placeholder:t(`sessionsLabelPlaceholder`),value:T,onChange:e=>A(e.target.value),className:`h-8 text-sm bg-white`}),(0,N.jsx)(S,{placeholder:t(`sessionsModelPlaceholder`),value:F,onChange:e=>R(e.target.value),className:`h-8 text-sm bg-white`}),(0,N.jsx)(s,{size:`sm`,onClick:()=>{i&&(G.mutate({sessionId:i,data:{label:T.trim()||null,preferredModel:F.trim()||null}}),H(!1))},className:`h-8 px-4 shrink-0 shadow-none`,disabled:G.isPending,children:t(`sessionsSaveMeta`)})]})]}),(0,N.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6 relative [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:bg-gray-300/80 [&::-webkit-scrollbar-thumb]:rounded-full`,children:[W.isLoading&&(0,N.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-gray-50/50 backdrop-blur-sm z-10`,children:(0,N.jsxs)(`div`,{className:`flex flex-col items-center gap-3 animate-pulse`,children:[(0,N.jsx)(m,{className:`w-6 h-6 text-primary animate-spin`}),(0,N.jsx)(`span`,{className:`text-sm font-medium text-gray-500`,children:t(`sessionsHistoryLoading`)})]})}),W.error&&(0,N.jsx)(`div`,{className:`text-center p-6 bg-red-50 rounded-xl text-red-600 border border-red-100 text-sm`,children:W.error.message}),!W.isLoading&&W.data?.messages.length===0&&(0,N.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-gray-400`,children:[(0,N.jsx)(w,{className:`w-12 h-12 mb-3 text-gray-300`}),(0,N.jsx)(`p`,{className:`text-sm`,children:t(`sessionsEmpty`)})]}),(0,N.jsx)(`div`,{className:`max-w-3xl mx-auto`,children:(W.data?.messages??[]).map(e=>(0,N.jsx)(V,{message:e},e.id))})]})]}):(0,N.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-gray-400 p-8 h-full bg-white`,children:[(0,N.jsx)(`div`,{className:`w-20 h-20 bg-gray-50 rounded-3xl flex items-center justify-center mb-6 border border-gray-100 shadow-[0_2px_8px_-2px_rgba(0,0,0,0.02)] rotate-3`,children:(0,N.jsx)(j,{className:`h-8 w-8 text-gray-300 -rotate-3`})}),(0,N.jsx)(`h3`,{className:`text-lg font-bold text-gray-900 mb-2`,children:t(`sessionsNoSelectionTitle`)}),(0,N.jsx)(`p`,{className:`text-sm text-center max-w-sm leading-relaxed`,children:t(`sessionsNoSelectionDescription`)})]})]})]}),(0,N.jsx)(re,{})]})}export{H as SessionsConfig};
|