@nextclaw/ui 0.6.7 → 0.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/assets/{ChannelsList-Dz8AGmaQ.js → ChannelsList-DACqpUYZ.js} +1 -1
- package/dist/assets/ChatPage-iji0RkTR.js +34 -0
- package/dist/assets/{DocBrowser-CkKvzF7m.js → DocBrowser-D7mjKkGe.js} +1 -1
- package/dist/assets/{LogoBadge-C_ygxoGB.js → LogoBadge-BlDT-g9R.js} +1 -1
- package/dist/assets/{MarketplacePage-DEvRs-Jc.js → MarketplacePage-CZq3jVgg.js} +3 -3
- package/dist/assets/{ModelConfig-BGfliN2Z.js → ModelConfig-DwRU5qrw.js} +1 -1
- package/dist/assets/{ProvidersList-BHLGLSvs.js → ProvidersList-DFxN3pjx.js} +1 -1
- package/dist/assets/{RuntimeConfig-Clltld_h.js → RuntimeConfig-C7BRLGSC.js} +1 -1
- package/dist/assets/{SecretsConfig-CaJLf7oJ.js → SecretsConfig-D5xZh7VF.js} +1 -1
- package/dist/assets/{SessionsConfig-3QF7K9wm.js → SessionsConfig-ovpj_otA.js} +1 -1
- package/dist/assets/{card-DXo3NsaB.js → card-Bf4CtrW8.js} +1 -1
- package/dist/assets/index-C_DhisNo.css +1 -0
- package/dist/assets/{index-CGo5Vnh0.js → index-dKTqKCJo.js} +5 -5
- package/dist/assets/{input-CzTldMKo.js → input-CaKJyoWZ.js} +1 -1
- package/dist/assets/{label-De__vsU7.js → label-BaXSWTKI.js} +1 -1
- package/dist/assets/{page-layout-BOgLC2tK.js → page-layout-DA6PFRtQ.js} +1 -1
- package/dist/assets/{session-run-status-DQVCDxTb.js → session-run-status-CllIZxNf.js} +1 -1
- package/dist/assets/{switch-pMrS4heA.js → switch-Cvd5wZs-.js} +1 -1
- package/dist/assets/{tabs-custom-DhOxWfCb.js → tabs-custom-0PybLkXs.js} +1 -1
- package/dist/assets/{useConfirmDialog-CseKBGh5.js → useConfirmDialog-DdtpSju1.js} +2 -2
- package/dist/assets/{vendor-D33xZtEC.js → vendor-C--HHaLf.js} +1 -1
- package/dist/index.html +3 -3
- package/package.json +1 -1
- package/src/api/types.ts +22 -4
- package/src/components/chat/ChatInputBar.tsx +341 -24
- package/src/components/chat/ChatPage.tsx +13 -5
- package/src/components/chat/useChatStreamController.ts +18 -3
- package/src/components/marketplace/MarketplacePage.tsx +48 -44
- package/src/lib/i18n.ts +11 -1
- package/dist/assets/ChatPage-BXDyt7BL.js +0 -34
- package/dist/assets/index-DcxYzrFm.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,j as t,z as oe,aW as ae,aX as ne,ax as U,a0 as ie,v as le,aY as ce,a1 as de,aw as ue,aZ as me}from"./vendor-
|
|
1
|
+
import{r as s,j as t,z as oe,aW as ae,aX as ne,ax as U,a0 as ie,v as le,aY as ce,a1 as de,aw as ue,aZ as me}from"./vendor-C--HHaLf.js";import{R as we,D as Y,t as i,c as X,V as xe}from"./index-dKTqKCJo.js";function pe(){const{isOpen:T,mode:g,tabs:F,activeTabId:N,currentTab:x,currentUrl:l,navVersion:p,close:A,toggleMode:I,goBack:$,goForward:O,canGoBack:V,canGoForward:_,navigate:y,syncUrl:S,setActiveTab:G,closeTab:H,openNewTab:Z}=we(),[k,j]=s.useState(""),[E,C]=s.useState(!1),[q,h]=s.useState(!1),[d,D]=s.useState(()=>({x:Math.max(40,window.innerWidth-520),y:80})),[n,B]=s.useState({w:480,h:600}),[L,J]=s.useState(420),u=s.useRef(null),m=s.useRef(null),b=s.useRef(null),z=s.useRef(null),W=s.useRef(p),a=(x==null?void 0:x.kind)==="docs";s.useEffect(()=>{if(!a){j("");return}try{const e=new URL(l);j(e.pathname)}catch{j(l)}},[l,N,a]),s.useEffect(()=>{var e;if(a){if(p!==W.current){W.current=p;return}if((e=z.current)!=null&&e.contentWindow)try{const r=new URL(l).pathname;z.current.contentWindow.postMessage({type:"docs-navigate",path:r},"*")}catch{}}},[l,p,a]),s.useEffect(()=>{g==="floating"&&D(e=>({x:Math.max(40,window.innerWidth-n.w-40),y:e.y}))},[g,n.w]),s.useEffect(()=>{const e=r=>{var o;a&&((o=r.data)==null?void 0:o.type)==="docs-route-change"&&typeof r.data.url=="string"&&S(r.data.url)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[S,a]);const K=s.useCallback(e=>{if(e.preventDefault(),!a)return;const r=k.trim();r&&(r.startsWith("/")?y(`${Y}${r}`):r.startsWith("http")?y(r):y(`${Y}/${r}`))},[k,y,a]),Q=s.useCallback(e=>{g==="floating"&&(C(!0),u.current={startX:e.clientX,startY:e.clientY,startPosX:d.x,startPosY:d.y})},[g,d]);s.useEffect(()=>{if(!E)return;const e=o=>{u.current&&D({x:u.current.startPosX+(o.clientX-u.current.startX),y:u.current.startPosY+(o.clientY-u.current.startY)})},r=()=>{C(!1),u.current=null};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",r),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",r)}},[E]);const R=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0);const r=e.currentTarget.dataset.axis;m.current={startX:e.clientX,startY:e.clientY,startW:n.w,startH:n.h};const o=w=>{m.current&&B(v=>({w:r==="y"?v.w:Math.max(360,m.current.startW+(w.clientX-m.current.startX)),h:r==="x"?v.h:Math.max(400,m.current.startH+(w.clientY-m.current.startY))}))},f=()=>{h(!1),m.current=null,window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",f)};window.addEventListener("mousemove",o),window.addEventListener("mouseup",f)},[n]),ee=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0),b.current={startX:e.clientX,startW:L};const r=f=>{if(!b.current)return;const w=b.current.startX-f.clientX;J(Math.max(320,Math.min(860,b.current.startW+w)))},o=()=>{h(!1),b.current=null,window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)},[L]),te=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0);const r=e.clientX,o=n.w,f=d.x,w=re=>{const se=r-re.clientX,P=Math.max(360,o+se);B(M=>({...M,w:P})),D(M=>({...M,x:f-(P-o)}))},v=()=>{h(!1),window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",v)};window.addEventListener("mousemove",w),window.addEventListener("mouseup",v)},[n.w,d.x]);if(!T)return null;const c=g==="docked";return t.jsxs("div",{className:X("flex flex-col bg-white overflow-hidden relative",c?"h-full border-l border-gray-200 shrink-0":"rounded-2xl shadow-2xl border border-gray-200"),style:c?{width:L}:{position:"fixed",left:d.x,top:d.y,width:n.w,height:n.h,zIndex:9999},children:[c&&t.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:ee}),t.jsxs("div",{className:X("flex items-center justify-between px-4 py-2.5 bg-gray-50 border-b border-gray-200 shrink-0 select-none",!c&&"cursor-grab active:cursor-grabbing"),onMouseDown:c?void 0:Q,children:[t.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[t.jsx(oe,{className:"w-4 h-4 text-primary shrink-0"}),t.jsx("span",{className:"text-sm font-semibold text-gray-900 truncate",children:i("docBrowserTitle")})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:I,className:"hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors",title:c?i("docBrowserFloatMode"):i("docBrowserDockMode"),children:c?t.jsx(ae,{className:"w-3.5 h-3.5"}):t.jsx(ne,{className:"w-3.5 h-3.5"})}),t.jsx("button",{onClick:A,className:"hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors",title:i("docBrowserClose"),children:t.jsx(U,{className:"w-3.5 h-3.5"})})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-2 bg-white border-b border-gray-100 overflow-x-auto custom-scrollbar",children:[F.map(e=>{const r=e.id===N;return t.jsxs("div",{className:X("inline-flex items-center gap-1 h-7 px-1.5 rounded-lg text-xs border max-w-[220px] shrink-0 transition-colors",r?"bg-blue-50 border-blue-300 text-blue-700":"bg-gray-50 border-gray-200 text-gray-600 hover:bg-gray-100"),children:[t.jsx("button",{type:"button",onClick:()=>G(e.id),className:"truncate text-left px-1",title:e.title,children:e.title||i("docBrowserTabUntitled")}),t.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),H(e.id)},className:"rounded p-0.5 hover:bg-black/10","aria-label":i("docBrowserCloseTab"),children:t.jsx(U,{className:"w-3 h-3"})})]},e.id)}),t.jsx("button",{onClick:()=>Z(void 0,{kind:"docs",title:"Docs"}),className:"inline-flex items-center justify-center w-7 h-7 rounded-lg border border-gray-200 bg-white text-gray-600 hover:bg-gray-100 shrink-0",title:i("docBrowserNewTab"),children:t.jsx(ie,{className:"w-3.5 h-3.5"})})]}),a&&t.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2 bg-white border-b border-gray-100 shrink-0",children:[t.jsx("button",{onClick:$,disabled:!V,className:"p-1.5 rounded-md hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-600 transition-colors",children:t.jsx(le,{className:"w-4 h-4"})}),t.jsx("button",{onClick:O,disabled:!_,className:"p-1.5 rounded-md hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-600 transition-colors",children:t.jsx(ce,{className:"w-4 h-4"})}),t.jsxs("form",{onSubmit:K,className:"flex-1 relative",children:[t.jsx(de,{className:"w-3.5 h-3.5 absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),t.jsx("input",{type:"text",value:k,onChange:e=>j(e.target.value),placeholder:i("docBrowserSearchPlaceholder"),className:"w-full h-8 pl-8 pr-3 rounded-lg bg-gray-50 border border-gray-200 text-xs text-gray-700 focus:outline-none focus:ring-1 focus:ring-primary/30 focus:border-primary/40 transition-colors placeholder:text-gray-400"})]})]}),t.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[t.jsx("iframe",{ref:z,src:l,className:"absolute inset-0 w-full h-full border-0",title:(x==null?void 0:x.title)||"NextClaw Docs",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms",allow:"clipboard-read; clipboard-write"},`${N}:${p}`),(q||E)&&t.jsx("div",{className:"absolute inset-0 z-10"})]}),a&&xe(l)&&t.jsx("div",{className:"flex items-center justify-between px-4 py-2 bg-gray-50 border-t border-gray-200 shrink-0",children:t.jsxs("a",{href:l,target:"_blank",rel:"noopener noreferrer","data-doc-external":!0,className:"flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover font-medium transition-colors",children:[i("docBrowserOpenExternal"),t.jsx(ue,{className:"w-3 h-3"})]})}),!c&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:te}),t.jsx("div",{className:"absolute top-0 right-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:R,"data-axis":"x"}),t.jsx("div",{className:"absolute bottom-0 left-0 h-1.5 w-full cursor-ns-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:R,"data-axis":"y"}),t.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-se-resize z-30 flex items-center justify-center text-gray-300 hover:text-gray-500 transition-colors",onMouseDown:R,children:t.jsx(me,{className:"w-3 h-3 rotate-[-45deg]"})})]})]})}export{pe as DocBrowser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,r as i}from"./vendor-
|
|
1
|
+
import{j as e,r as i}from"./vendor-C--HHaLf.js";import{c as r}from"./index-dKTqKCJo.js";const c={active:{dot:"bg-emerald-500",text:"text-emerald-600",bg:"bg-emerald-50"},ready:{dot:"bg-emerald-500",text:"text-emerald-600",bg:"bg-emerald-50"},inactive:{dot:"bg-gray-300",text:"text-gray-400",bg:"bg-gray-100/80"},setup:{dot:"bg-gray-300",text:"text-gray-400",bg:"bg-gray-100/80"},warning:{dot:"bg-amber-400",text:"text-amber-600",bg:"bg-amber-50"}};function h({status:a,label:l,className:n}){const t=c[a];return e.jsxs("div",{className:r("inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full px-2 py-0.5",t.bg,n),children:[e.jsx("span",{className:r("h-1.5 w-1.5 rounded-full",t.dot)}),e.jsx("span",{className:r("text-[11px] font-medium",t.text),children:l})]})}const b="grid min-h-0 grid-cols-1 gap-5 xl:grid-cols-[340px_minmax(0,1fr)]",p="flex min-h-[520px] min-h-0 min-w-0 flex-col overflow-hidden rounded-2xl border border-gray-200/70 bg-white shadow-card xl:h-[calc(100vh-180px)] xl:min-h-[600px] xl:max-h-[860px]",f="flex min-h-[520px] min-h-0 min-w-0 flex-col overflow-hidden rounded-2xl border border-gray-200/70 bg-white shadow-card xl:h-[calc(100vh-180px)] xl:min-h-[600px] xl:max-h-[860px]",u="flex min-h-[520px] min-w-0 items-center justify-center overflow-hidden rounded-2xl border border-gray-200/70 bg-white px-6 text-center xl:h-[calc(100vh-180px)] xl:min-h-[600px] xl:max-h-[860px]";function w({name:a,src:l,className:n,imgClassName:t,fallback:s}){const[o,x]=i.useState(!1),d=!!l&&!o;return e.jsx("div",{className:r("inline-flex shrink-0 items-center justify-center overflow-hidden",n),children:d?e.jsx("img",{src:l,alt:`${a} logo`,className:r("block h-6 w-6 object-contain",t),onError:()=>x(!0),draggable:!1}):s??e.jsx("span",{className:"text-lg font-bold uppercase",children:a.slice(0,1)})})}export{u as C,w as L,h as S,f as a,b,p as c};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{u as Pe,a as je,b as Ie,d as G,r as c,j as r,af as Ve,ad as Je,ae as Ye,ag as Ne,aj as We,ah as Xe,ai as O,ak as Ee,al as Ze,am as et,as as tt,at,aR as nt,aS as st,au as rt,aF as ot,aG as lt,aT as it}from"./vendor-D33xZtEC.js";import{Q as F,t as d,c as Re,i as ct,R as ut,S as dt,e as pt,f as mt,g as gt,h as Te}from"./index-CGo5Vnh0.js";import{T as ft}from"./tabs-custom-DhOxWfCb.js";import{P as Me,u as xt}from"./useConfirmDialog-CseKBGh5.js";import{P as ht,a as yt}from"./page-layout-BOgLC2tK.js";function V(e){return e==="plugin"?"plugins":"skills"}async function bt(e){var o,i;const t=new URLSearchParams,a=V(e.type);(o=e.q)!=null&&o.trim()&&t.set("q",e.q.trim()),(i=e.tag)!=null&&i.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))));const n=t.toString(),s=await F.get(n?`/api/marketplace/${a}/items?${n}`:`/api/marketplace/${a}/items`);if(!s.ok)throw new Error(s.error.message);return s.data}async function kt(e){const t=await F.get(`/api/marketplace/skills/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function vt(e){const t=await F.get(`/api/marketplace/plugins/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function wt(e){const t=V(e.type),a=await F.post(`/api/marketplace/${t}/install`,e);if(!a.ok)throw new Error(a.error.message);return a.data}async function Tt(e){const t=V(e),a=await F.get(`/api/marketplace/${t}/installed`);if(!a.ok)throw new Error(a.error.message);return a.data}async function St(e){const t=V(e.type),a=await F.post(`/api/marketplace/${t}/manage`,e);if(!a.ok)throw new Error(a.error.message);return a.data}function Ct(e){return Pe({queryKey:["marketplace-items",e],queryFn:()=>bt(e),staleTime:15e3})}function Pt(e){return Pe({queryKey:["marketplace-installed",e],queryFn:()=>Tt(e),staleTime:1e4})}function jt(){const e=je();return Ie({mutationFn:t=>wt(t),onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-installed",t.type]}),e.refetchQueries({queryKey:["marketplace-installed",t.type],type:"active"}),e.refetchQueries({queryKey:["marketplace-items"],type:"active"});const a=t.type==="plugin"?d("marketplaceInstallSuccessPlugin"):d("marketplaceInstallSuccessSkill");G.success(t.message||a)},onError:t=>{G.error(t.message||d("marketplaceInstallFailed"))}})}function It(){const e=je();return Ie({mutationFn:t=>St(t),onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-installed",t.type]}),e.invalidateQueries({queryKey:["marketplace-items"]}),e.refetchQueries({queryKey:["marketplace-installed",t.type],type:"active"}),e.refetchQueries({queryKey:["marketplace-items"],type:"active"});const a=t.action==="enable"?d("marketplaceEnableSuccess"):t.action==="disable"?d("marketplaceDisableSuccess"):d("marketplaceUninstallSuccess");G.success(t.message||a)},onError:t=>{G.error(t.message||d("marketplaceOperationFailed"))}})}var[J]=et("Tooltip",[Ee]),Y=Ee(),Le="TooltipProvider",Nt=700,te="tooltip.open",[Et,se]=J(Le),De=e=>{const{__scopeTooltip:t,delayDuration:a=Nt,skipDelayDuration:n=300,disableHoverableContent:s=!1,children:o}=e,i=c.useRef(!0),g=c.useRef(!1),u=c.useRef(0);return c.useEffect(()=>{const h=u.current;return()=>window.clearTimeout(h)},[]),r.jsx(Et,{scope:t,isOpenDelayedRef:i,delayDuration:a,onOpen:c.useCallback(()=>{window.clearTimeout(u.current),i.current=!1},[]),onClose:c.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>i.current=!0,n)},[n]),isPointerInTransitRef:g,onPointerInTransitChange:c.useCallback(h=>{g.current=h},[]),disableHoverableContent:s,children:o})};De.displayName=Le;var H="Tooltip",[Rt,K]=J(H),$e=e=>{const{__scopeTooltip:t,children:a,open:n,defaultOpen:s,onOpenChange:o,disableHoverableContent:i,delayDuration:g}=e,u=se(H,e.__scopeTooltip),h=Y(t),[p,y]=c.useState(null),v=Ve(),x=c.useRef(0),w=i??u.disableHoverableContent,f=g??u.delayDuration,S=c.useRef(!1),[I,C]=Je({prop:n,defaultProp:s??!1,onChange:T=>{T?(u.onOpen(),document.dispatchEvent(new CustomEvent(te))):u.onClose(),o==null||o(T)},caller:H}),E=c.useMemo(()=>I?S.current?"delayed-open":"instant-open":"closed",[I]),P=c.useCallback(()=>{window.clearTimeout(x.current),x.current=0,S.current=!1,C(!0)},[C]),R=c.useCallback(()=>{window.clearTimeout(x.current),x.current=0,C(!1)},[C]),D=c.useCallback(()=>{window.clearTimeout(x.current),x.current=window.setTimeout(()=>{S.current=!0,C(!0),x.current=0},f)},[f,C]);return c.useEffect(()=>()=>{x.current&&(window.clearTimeout(x.current),x.current=0)},[]),r.jsx(Ye,{...h,children:r.jsx(Rt,{scope:t,contentId:v,open:I,stateAttribute:E,trigger:p,onTriggerChange:y,onTriggerEnter:c.useCallback(()=>{u.isOpenDelayedRef.current?D():P()},[u.isOpenDelayedRef,D,P]),onTriggerLeave:c.useCallback(()=>{w?R():(window.clearTimeout(x.current),x.current=0)},[R,w]),onOpen:P,onClose:R,disableHoverableContent:w,children:a})})};$e.displayName=H;var ae="TooltipTrigger",_e=c.forwardRef((e,t)=>{const{__scopeTooltip:a,...n}=e,s=K(ae,a),o=se(ae,a),i=Y(a),g=c.useRef(null),u=Ne(t,g,s.onTriggerChange),h=c.useRef(!1),p=c.useRef(!1),y=c.useCallback(()=>h.current=!1,[]);return c.useEffect(()=>()=>document.removeEventListener("pointerup",y),[y]),r.jsx(We,{asChild:!0,...i,children:r.jsx(Xe.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...n,ref:u,onPointerMove:O(e.onPointerMove,v=>{v.pointerType!=="touch"&&!p.current&&!o.isPointerInTransitRef.current&&(s.onTriggerEnter(),p.current=!0)}),onPointerLeave:O(e.onPointerLeave,()=>{s.onTriggerLeave(),p.current=!1}),onPointerDown:O(e.onPointerDown,()=>{s.open&&s.onClose(),h.current=!0,document.addEventListener("pointerup",y,{once:!0})}),onFocus:O(e.onFocus,()=>{h.current||s.onOpen()}),onBlur:O(e.onBlur,s.onClose),onClick:O(e.onClick,s.onClose)})})});_e.displayName=ae;var re="TooltipPortal",[Mt,Lt]=J(re,{forceMount:void 0}),Oe=e=>{const{__scopeTooltip:t,forceMount:a,children:n,container:s}=e,o=K(re,t);return r.jsx(Mt,{scope:t,forceMount:a,children:r.jsx(Me,{present:a||o.open,children:r.jsx(Ze,{asChild:!0,container:s,children:n})})})};Oe.displayName=re;var U="TooltipContent",Ae=c.forwardRef((e,t)=>{const a=Lt(U,e.__scopeTooltip),{forceMount:n=a.forceMount,side:s="top",...o}=e,i=K(U,e.__scopeTooltip);return r.jsx(Me,{present:n||i.open,children:i.disableHoverableContent?r.jsx(Ue,{side:s,...o,ref:t}):r.jsx(Dt,{side:s,...o,ref:t})})}),Dt=c.forwardRef((e,t)=>{const a=K(U,e.__scopeTooltip),n=se(U,e.__scopeTooltip),s=c.useRef(null),o=Ne(t,s),[i,g]=c.useState(null),{trigger:u,onClose:h}=a,p=s.current,{onPointerInTransitChange:y}=n,v=c.useCallback(()=>{g(null),y(!1)},[y]),x=c.useCallback((w,f)=>{const S=w.currentTarget,I={x:w.clientX,y:w.clientY},C=Ut(I,S.getBoundingClientRect()),E=Ft(I,C),P=zt(f.getBoundingClientRect()),R=Ht([...E,...P]);g(R),y(!0)},[y]);return c.useEffect(()=>()=>v(),[v]),c.useEffect(()=>{if(u&&p){const w=S=>x(S,p),f=S=>x(S,u);return u.addEventListener("pointerleave",w),p.addEventListener("pointerleave",f),()=>{u.removeEventListener("pointerleave",w),p.removeEventListener("pointerleave",f)}}},[u,p,x,v]),c.useEffect(()=>{if(i){const w=f=>{const S=f.target,I={x:f.clientX,y:f.clientY},C=(u==null?void 0:u.contains(S))||(p==null?void 0:p.contains(S)),E=!qt(I,i);C?v():E&&(v(),h())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[u,p,i,h,v]),r.jsx(Ue,{...e,ref:o})}),[$t,_t]=J(H,{isInside:!1}),Ot=st("TooltipContent"),Ue=c.forwardRef((e,t)=>{const{__scopeTooltip:a,children:n,"aria-label":s,onEscapeKeyDown:o,onPointerDownOutside:i,...g}=e,u=K(U,a),h=Y(a),{onClose:p}=u;return c.useEffect(()=>(document.addEventListener(te,p),()=>document.removeEventListener(te,p)),[p]),c.useEffect(()=>{if(u.trigger){const y=v=>{const x=v.target;x!=null&&x.contains(u.trigger)&&p()};return window.addEventListener("scroll",y,{capture:!0}),()=>window.removeEventListener("scroll",y,{capture:!0})}},[u.trigger,p]),r.jsx(tt,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:y=>y.preventDefault(),onDismiss:p,children:r.jsxs(at,{"data-state":u.stateAttribute,...h,...g,ref:t,style:{...g.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:[r.jsx(Ot,{children:n}),r.jsx($t,{scope:a,isInside:!0,children:r.jsx(nt,{id:u.contentId,role:"tooltip",children:s||n})})]})})});Ae.displayName=U;var Fe="TooltipArrow",At=c.forwardRef((e,t)=>{const{__scopeTooltip:a,...n}=e,s=Y(a);return _t(Fe,a).isInside?null:r.jsx(rt,{...s,...n,ref:t})});At.displayName=Fe;function Ut(e,t){const a=Math.abs(t.top-e.y),n=Math.abs(t.bottom-e.y),s=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(a,n,s,o)){case o:return"left";case s:return"right";case a:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function Ft(e,t,a=5){const n=[];switch(t){case"top":n.push({x:e.x-a,y:e.y+a},{x:e.x+a,y:e.y+a});break;case"bottom":n.push({x:e.x-a,y:e.y-a},{x:e.x+a,y:e.y-a});break;case"left":n.push({x:e.x+a,y:e.y-a},{x:e.x+a,y:e.y+a});break;case"right":n.push({x:e.x-a,y:e.y-a},{x:e.x-a,y:e.y+a});break}return n}function zt(e){const{top:t,right:a,bottom:n,left:s}=e;return[{x:s,y:t},{x:a,y:t},{x:a,y:n},{x:s,y:n}]}function qt(e,t){const{x:a,y:n}=e;let s=!1;for(let o=0,i=t.length-1;o<t.length;i=o++){const g=t[o],u=t[i],h=g.x,p=g.y,y=u.x,v=u.y;p>n!=v>n&&a<(y-h)*(n-p)/(v-p)+h&&(s=!s)}return s}function Ht(e){const t=e.slice();return t.sort((a,n)=>a.x<n.x?-1:a.x>n.x?1:a.y<n.y?-1:a.y>n.y?1:0),Kt(t)}function Kt(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n<e.length;n++){const s=e[n];for(;t.length>=2;){const o=t[t.length-1],i=t[t.length-2];if((o.x-i.x)*(s.y-i.y)>=(o.y-i.y)*(s.x-i.x))t.pop();else break}t.push(s)}t.pop();const a=[];for(let n=e.length-1;n>=0;n--){const s=e[n];for(;a.length>=2;){const o=a[a.length-1],i=a[a.length-2];if((o.x-i.x)*(s.y-i.y)>=(o.y-i.y)*(s.x-i.x))a.pop();else break}a.push(s)}return a.pop(),t.length===1&&a.length===1&&t[0].x===a[0].x&&t[0].y===a[0].y?t:t.concat(a)}var Bt=De,Qt=$e,Gt=_e,Vt=Oe,ze=Ae;const Jt=Bt,X=Qt,Z=Gt,Q=c.forwardRef(({className:e,sideOffset:t=4,...a},n)=>r.jsx(Vt,{children:r.jsx(ze,{ref:n,sideOffset:t,className:Re("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),...a})}));Q.displayName=ze.displayName;const Yt=12;function ne(e){return(e??"").trim().toLowerCase()}function A(e,t){const a=ne(t);return a.length>0?`${e}:${a}`:""}function Wt(e){const t=new Map;for(const a of e){const n=[a.install.spec,a.slug,a.id];for(const s of n){const o=A(a.type,s);!o||t.has(o)||t.set(o,a)}}return t}function Xt(e){const t=new Map;for(const a of e){const n=[a.spec,a.id,a.label];for(const s of n){const o=A(a.type,s);!o||t.has(o)||t.set(o,a)}}return t}function Se(e,t){const a=[e.install.spec,e.slug,e.id];for(const n of a){const s=A(e.type,n);if(!s)continue;const o=t.get(s);if(o)return o}}function Zt(e,t){const a=t.get(A(e.type,e.spec));if(a)return a;const n=t.get(A(e.type,e.id));return n||t.get(A(e.type,e.label))}function ea(e){const t=e.trim().toLowerCase().replace(/_/g,"-"),a=t.split("-")[0],n=[t,a,"en"];return Array.from(new Set(n.filter(Boolean)))}function ee(e){return e.trim().toLowerCase().replace(/_/g,"-")}function oe(e,t,a){var n;if(e){const s=Object.entries(e).map(([o,i])=>({locale:ee(o),text:typeof i=="string"?i.trim():""})).filter(o=>o.text.length>0);if(s.length>0){const o=new Map(s.map(i=>[i.locale,i.text]));for(const i of a){const g=ee(i),u=o.get(g);if(u)return u}for(const i of a){const g=ee(i).split("-")[0];if(!g)continue;const u=s.find(h=>h.locale===g||h.locale.startsWith(`${g}-`));if(u)return u.text}return((n=s[0])==null?void 0:n.text)??""}}return(t==null?void 0:t.trim())??""}function ta(e,t,a,n){const s=ne(a);if(!s)return!0;const o=oe(t==null?void 0:t.summaryI18n,t==null?void 0:t.summary,n);return[e.id,e.spec,e.label,t==null?void 0:t.name,t==null?void 0:t.slug,t==null?void 0:t.summary,o,...(t==null?void 0:t.tags)??[]].map(g=>ne(g)).filter(Boolean).some(g=>g.includes(s))}function aa(e){const 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"];let a=0;for(let n=0;n<e.length;n++)a=e.charCodeAt(n)+((a<<5)-a);return t[Math.abs(a)%t.length]}function na({name:e,fallback:t}){const a=e||t,n=a.substring(0,2).toUpperCase(),s=aa(a);return r.jsx("div",{className:Re("flex items-center justify-center w-10 h-10 rounded-xl text-white font-semibold text-sm shrink-0",s),children:n})}function N(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function q(e){var g,u,h,p;const t=((g=e.metadataRaw)==null?void 0:g.trim())||"-",a=((u=e.contentRaw)==null?void 0:u.trim())||"-",n=(h=e.summary)==null?void 0:h.trim(),s=(p=e.description)==null?void 0:p.trim(),o=!!s&&s!==n,i=`<!doctype html>
|
|
1
|
+
import{u as Pe,a as je,b as Ie,d as G,r as c,j as s,af as Ve,ad as Je,ae as Ye,aj as Ne,ag as We,ak as Xe,al as O,ah as Ee,ai as Ze,am as et,as as tt,at,aR as nt,aS as st,au as rt,aF as ot,aG as lt,aT as it}from"./vendor-C--HHaLf.js";import{Q as F,t as d,c as Re,i as ct,R as ut,S as dt,e as pt,f as mt,g as gt,h as Te}from"./index-dKTqKCJo.js";import{T as ft}from"./tabs-custom-0PybLkXs.js";import{P as Me,u as xt}from"./useConfirmDialog-DdtpSju1.js";import{P as ht,a as yt}from"./page-layout-DA6PFRtQ.js";function V(e){return e==="plugin"?"plugins":"skills"}async function bt(e){var o,i;const t=new URLSearchParams,a=V(e.type);(o=e.q)!=null&&o.trim()&&t.set("q",e.q.trim()),(i=e.tag)!=null&&i.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))));const n=t.toString(),r=await F.get(n?`/api/marketplace/${a}/items?${n}`:`/api/marketplace/${a}/items`);if(!r.ok)throw new Error(r.error.message);return r.data}async function kt(e){const t=await F.get(`/api/marketplace/skills/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function vt(e){const t=await F.get(`/api/marketplace/plugins/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function wt(e){const t=V(e.type),a=await F.post(`/api/marketplace/${t}/install`,e);if(!a.ok)throw new Error(a.error.message);return a.data}async function Tt(e){const t=V(e),a=await F.get(`/api/marketplace/${t}/installed`);if(!a.ok)throw new Error(a.error.message);return a.data}async function St(e){const t=V(e.type),a=await F.post(`/api/marketplace/${t}/manage`,e);if(!a.ok)throw new Error(a.error.message);return a.data}function Ct(e){return Pe({queryKey:["marketplace-items",e],queryFn:()=>bt(e),staleTime:15e3})}function Pt(e){return Pe({queryKey:["marketplace-installed",e],queryFn:()=>Tt(e),staleTime:1e4})}function jt(){const e=je();return Ie({mutationFn:t=>wt(t),onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-installed",t.type]}),e.refetchQueries({queryKey:["marketplace-installed",t.type],type:"active"}),e.refetchQueries({queryKey:["marketplace-items"],type:"active"});const a=t.type==="plugin"?d("marketplaceInstallSuccessPlugin"):d("marketplaceInstallSuccessSkill");G.success(t.message||a)},onError:t=>{G.error(t.message||d("marketplaceInstallFailed"))}})}function It(){const e=je();return Ie({mutationFn:t=>St(t),onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-installed",t.type]}),e.invalidateQueries({queryKey:["marketplace-items"]}),e.refetchQueries({queryKey:["marketplace-installed",t.type],type:"active"}),e.refetchQueries({queryKey:["marketplace-items"],type:"active"});const a=t.action==="enable"?d("marketplaceEnableSuccess"):t.action==="disable"?d("marketplaceDisableSuccess"):d("marketplaceUninstallSuccess");G.success(t.message||a)},onError:t=>{G.error(t.message||d("marketplaceOperationFailed"))}})}var[J]=et("Tooltip",[Ee]),Y=Ee(),Le="TooltipProvider",Nt=700,te="tooltip.open",[Et,se]=J(Le),De=e=>{const{__scopeTooltip:t,delayDuration:a=Nt,skipDelayDuration:n=300,disableHoverableContent:r=!1,children:o}=e,i=c.useRef(!0),g=c.useRef(!1),u=c.useRef(0);return c.useEffect(()=>{const h=u.current;return()=>window.clearTimeout(h)},[]),s.jsx(Et,{scope:t,isOpenDelayedRef:i,delayDuration:a,onOpen:c.useCallback(()=>{window.clearTimeout(u.current),i.current=!1},[]),onClose:c.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>i.current=!0,n)},[n]),isPointerInTransitRef:g,onPointerInTransitChange:c.useCallback(h=>{g.current=h},[]),disableHoverableContent:r,children:o})};De.displayName=Le;var H="Tooltip",[Rt,K]=J(H),$e=e=>{const{__scopeTooltip:t,children:a,open:n,defaultOpen:r,onOpenChange:o,disableHoverableContent:i,delayDuration:g}=e,u=se(H,e.__scopeTooltip),h=Y(t),[p,y]=c.useState(null),v=Ve(),x=c.useRef(0),w=i??u.disableHoverableContent,f=g??u.delayDuration,S=c.useRef(!1),[I,C]=Je({prop:n,defaultProp:r??!1,onChange:T=>{T?(u.onOpen(),document.dispatchEvent(new CustomEvent(te))):u.onClose(),o==null||o(T)},caller:H}),E=c.useMemo(()=>I?S.current?"delayed-open":"instant-open":"closed",[I]),P=c.useCallback(()=>{window.clearTimeout(x.current),x.current=0,S.current=!1,C(!0)},[C]),R=c.useCallback(()=>{window.clearTimeout(x.current),x.current=0,C(!1)},[C]),D=c.useCallback(()=>{window.clearTimeout(x.current),x.current=window.setTimeout(()=>{S.current=!0,C(!0),x.current=0},f)},[f,C]);return c.useEffect(()=>()=>{x.current&&(window.clearTimeout(x.current),x.current=0)},[]),s.jsx(Ye,{...h,children:s.jsx(Rt,{scope:t,contentId:v,open:I,stateAttribute:E,trigger:p,onTriggerChange:y,onTriggerEnter:c.useCallback(()=>{u.isOpenDelayedRef.current?D():P()},[u.isOpenDelayedRef,D,P]),onTriggerLeave:c.useCallback(()=>{w?R():(window.clearTimeout(x.current),x.current=0)},[R,w]),onOpen:P,onClose:R,disableHoverableContent:w,children:a})})};$e.displayName=H;var ae="TooltipTrigger",_e=c.forwardRef((e,t)=>{const{__scopeTooltip:a,...n}=e,r=K(ae,a),o=se(ae,a),i=Y(a),g=c.useRef(null),u=Ne(t,g,r.onTriggerChange),h=c.useRef(!1),p=c.useRef(!1),y=c.useCallback(()=>h.current=!1,[]);return c.useEffect(()=>()=>document.removeEventListener("pointerup",y),[y]),s.jsx(We,{asChild:!0,...i,children:s.jsx(Xe.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...n,ref:u,onPointerMove:O(e.onPointerMove,v=>{v.pointerType!=="touch"&&!p.current&&!o.isPointerInTransitRef.current&&(r.onTriggerEnter(),p.current=!0)}),onPointerLeave:O(e.onPointerLeave,()=>{r.onTriggerLeave(),p.current=!1}),onPointerDown:O(e.onPointerDown,()=>{r.open&&r.onClose(),h.current=!0,document.addEventListener("pointerup",y,{once:!0})}),onFocus:O(e.onFocus,()=>{h.current||r.onOpen()}),onBlur:O(e.onBlur,r.onClose),onClick:O(e.onClick,r.onClose)})})});_e.displayName=ae;var re="TooltipPortal",[Mt,Lt]=J(re,{forceMount:void 0}),Oe=e=>{const{__scopeTooltip:t,forceMount:a,children:n,container:r}=e,o=K(re,t);return s.jsx(Mt,{scope:t,forceMount:a,children:s.jsx(Me,{present:a||o.open,children:s.jsx(Ze,{asChild:!0,container:r,children:n})})})};Oe.displayName=re;var U="TooltipContent",Ae=c.forwardRef((e,t)=>{const a=Lt(U,e.__scopeTooltip),{forceMount:n=a.forceMount,side:r="top",...o}=e,i=K(U,e.__scopeTooltip);return s.jsx(Me,{present:n||i.open,children:i.disableHoverableContent?s.jsx(Ue,{side:r,...o,ref:t}):s.jsx(Dt,{side:r,...o,ref:t})})}),Dt=c.forwardRef((e,t)=>{const a=K(U,e.__scopeTooltip),n=se(U,e.__scopeTooltip),r=c.useRef(null),o=Ne(t,r),[i,g]=c.useState(null),{trigger:u,onClose:h}=a,p=r.current,{onPointerInTransitChange:y}=n,v=c.useCallback(()=>{g(null),y(!1)},[y]),x=c.useCallback((w,f)=>{const S=w.currentTarget,I={x:w.clientX,y:w.clientY},C=Ut(I,S.getBoundingClientRect()),E=Ft(I,C),P=zt(f.getBoundingClientRect()),R=Ht([...E,...P]);g(R),y(!0)},[y]);return c.useEffect(()=>()=>v(),[v]),c.useEffect(()=>{if(u&&p){const w=S=>x(S,p),f=S=>x(S,u);return u.addEventListener("pointerleave",w),p.addEventListener("pointerleave",f),()=>{u.removeEventListener("pointerleave",w),p.removeEventListener("pointerleave",f)}}},[u,p,x,v]),c.useEffect(()=>{if(i){const w=f=>{const S=f.target,I={x:f.clientX,y:f.clientY},C=(u==null?void 0:u.contains(S))||(p==null?void 0:p.contains(S)),E=!qt(I,i);C?v():E&&(v(),h())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[u,p,i,h,v]),s.jsx(Ue,{...e,ref:o})}),[$t,_t]=J(H,{isInside:!1}),Ot=st("TooltipContent"),Ue=c.forwardRef((e,t)=>{const{__scopeTooltip:a,children:n,"aria-label":r,onEscapeKeyDown:o,onPointerDownOutside:i,...g}=e,u=K(U,a),h=Y(a),{onClose:p}=u;return c.useEffect(()=>(document.addEventListener(te,p),()=>document.removeEventListener(te,p)),[p]),c.useEffect(()=>{if(u.trigger){const y=v=>{const x=v.target;x!=null&&x.contains(u.trigger)&&p()};return window.addEventListener("scroll",y,{capture:!0}),()=>window.removeEventListener("scroll",y,{capture:!0})}},[u.trigger,p]),s.jsx(tt,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:y=>y.preventDefault(),onDismiss:p,children:s.jsxs(at,{"data-state":u.stateAttribute,...h,...g,ref:t,style:{...g.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:[s.jsx(Ot,{children:n}),s.jsx($t,{scope:a,isInside:!0,children:s.jsx(nt,{id:u.contentId,role:"tooltip",children:r||n})})]})})});Ae.displayName=U;var Fe="TooltipArrow",At=c.forwardRef((e,t)=>{const{__scopeTooltip:a,...n}=e,r=Y(a);return _t(Fe,a).isInside?null:s.jsx(rt,{...r,...n,ref:t})});At.displayName=Fe;function Ut(e,t){const a=Math.abs(t.top-e.y),n=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(a,n,r,o)){case o:return"left";case r:return"right";case a:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function Ft(e,t,a=5){const n=[];switch(t){case"top":n.push({x:e.x-a,y:e.y+a},{x:e.x+a,y:e.y+a});break;case"bottom":n.push({x:e.x-a,y:e.y-a},{x:e.x+a,y:e.y-a});break;case"left":n.push({x:e.x+a,y:e.y-a},{x:e.x+a,y:e.y+a});break;case"right":n.push({x:e.x-a,y:e.y-a},{x:e.x-a,y:e.y+a});break}return n}function zt(e){const{top:t,right:a,bottom:n,left:r}=e;return[{x:r,y:t},{x:a,y:t},{x:a,y:n},{x:r,y:n}]}function qt(e,t){const{x:a,y:n}=e;let r=!1;for(let o=0,i=t.length-1;o<t.length;i=o++){const g=t[o],u=t[i],h=g.x,p=g.y,y=u.x,v=u.y;p>n!=v>n&&a<(y-h)*(n-p)/(v-p)+h&&(r=!r)}return r}function Ht(e){const t=e.slice();return t.sort((a,n)=>a.x<n.x?-1:a.x>n.x?1:a.y<n.y?-1:a.y>n.y?1:0),Kt(t)}function Kt(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n<e.length;n++){const r=e[n];for(;t.length>=2;){const o=t[t.length-1],i=t[t.length-2];if((o.x-i.x)*(r.y-i.y)>=(o.y-i.y)*(r.x-i.x))t.pop();else break}t.push(r)}t.pop();const a=[];for(let n=e.length-1;n>=0;n--){const r=e[n];for(;a.length>=2;){const o=a[a.length-1],i=a[a.length-2];if((o.x-i.x)*(r.y-i.y)>=(o.y-i.y)*(r.x-i.x))a.pop();else break}a.push(r)}return a.pop(),t.length===1&&a.length===1&&t[0].x===a[0].x&&t[0].y===a[0].y?t:t.concat(a)}var Bt=De,Qt=$e,Gt=_e,Vt=Oe,ze=Ae;const Jt=Bt,X=Qt,Z=Gt,Q=c.forwardRef(({className:e,sideOffset:t=4,...a},n)=>s.jsx(Vt,{children:s.jsx(ze,{ref:n,sideOffset:t,className:Re("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),...a})}));Q.displayName=ze.displayName;const Yt=12;function ne(e){return(e??"").trim().toLowerCase()}function A(e,t){const a=ne(t);return a.length>0?`${e}:${a}`:""}function Wt(e){const t=new Map;for(const a of e){const n=[a.install.spec,a.slug,a.id];for(const r of n){const o=A(a.type,r);!o||t.has(o)||t.set(o,a)}}return t}function Xt(e){const t=new Map;for(const a of e){const n=[a.spec,a.id,a.label];for(const r of n){const o=A(a.type,r);!o||t.has(o)||t.set(o,a)}}return t}function Se(e,t){const a=[e.install.spec,e.slug,e.id];for(const n of a){const r=A(e.type,n);if(!r)continue;const o=t.get(r);if(o)return o}}function Zt(e,t){const a=t.get(A(e.type,e.spec));if(a)return a;const n=t.get(A(e.type,e.id));return n||t.get(A(e.type,e.label))}function ea(e){const t=e.trim().toLowerCase().replace(/_/g,"-"),a=t.split("-")[0],n=[t,a,"en"];return Array.from(new Set(n.filter(Boolean)))}function ee(e){return e.trim().toLowerCase().replace(/_/g,"-")}function oe(e,t,a){var n;if(e){const r=Object.entries(e).map(([o,i])=>({locale:ee(o),text:typeof i=="string"?i.trim():""})).filter(o=>o.text.length>0);if(r.length>0){const o=new Map(r.map(i=>[i.locale,i.text]));for(const i of a){const g=ee(i),u=o.get(g);if(u)return u}for(const i of a){const g=ee(i).split("-")[0];if(!g)continue;const u=r.find(h=>h.locale===g||h.locale.startsWith(`${g}-`));if(u)return u.text}return((n=r[0])==null?void 0:n.text)??""}}return(t==null?void 0:t.trim())??""}function ta(e,t,a,n){const r=ne(a);if(!r)return!0;const o=oe(t==null?void 0:t.summaryI18n,t==null?void 0:t.summary,n);return[e.id,e.spec,e.label,t==null?void 0:t.name,t==null?void 0:t.slug,t==null?void 0:t.summary,o,...(t==null?void 0:t.tags)??[]].map(g=>ne(g)).filter(Boolean).some(g=>g.includes(r))}function aa(e){const 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"];let a=0;for(let n=0;n<e.length;n++)a=e.charCodeAt(n)+((a<<5)-a);return t[Math.abs(a)%t.length]}function na({name:e,fallback:t}){const a=e||t,n=a.substring(0,2).toUpperCase(),r=aa(a);return s.jsx("div",{className:Re("flex items-center justify-center w-10 h-10 rounded-xl text-white font-semibold text-sm shrink-0",r),children:n})}function N(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function q(e){var g,u,h,p;const t=((g=e.metadataRaw)==null?void 0:g.trim())||"-",a=((u=e.contentRaw)==null?void 0:u.trim())||"-",n=(h=e.summary)==null?void 0:h.trim(),r=(p=e.description)==null?void 0:p.trim(),o=!!r&&r!==n,i=`<!doctype html>
|
|
2
2
|
<html>
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8" />
|
|
@@ -29,7 +29,7 @@ import{u as Pe,a as je,b as Ie,d as G,r as c,j as r,af as Ve,ad as Je,ae as Ye,a
|
|
|
29
29
|
<h1>${N(e.title)}</h1>
|
|
30
30
|
<div class="meta">${N(e.typeLabel)} · ${N(e.spec)}${e.author?` · ${N(e.author)}`:""}</div>
|
|
31
31
|
${n?`<p class="summary">${N(n)}</p>`:""}
|
|
32
|
-
${o?`<p class="summary">${N(
|
|
32
|
+
${o?`<p class="summary">${N(r)}</p>`:""}
|
|
33
33
|
${e.tags&&e.tags.length>0?`<div class="tags">${e.tags.map(y=>`<span class="tag">${N(y)}</span>`).join("")}</div>`:""}
|
|
34
34
|
${e.sourceUrl?`<p class="meta" style="margin-top:12px;">${N(e.sourceLabel??"Source")}: <a class="source" href="${N(e.sourceUrl)}" target="_blank" rel="noopener noreferrer">${N(e.sourceUrl)}</a></p>`:""}
|
|
35
35
|
</section>
|
|
@@ -46,4 +46,4 @@ import{u as Pe,a as je,b as Ie,d as G,r as c,j as r,af as Ve,ad as Je,ae as Ye,a
|
|
|
46
46
|
</section>
|
|
47
47
|
</main>
|
|
48
48
|
</body>
|
|
49
|
-
</html>`;return`data:text/html;charset=utf-8,${encodeURIComponent(i)}`}function sa(e){return r.jsx("div",{className:"mb-4",children:r.jsxs("div",{className:"flex gap-3 items-center",children:[r.jsxs("div",{className:"flex-1 min-w-0 relative",children:[r.jsx(it,{className:"h-4 w-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2"}),r.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"&&r.jsxs(dt,{value:e.sort,onValueChange:t=>e.onSortChange(t),children:[r.jsx(pt,{className:"h-9 w-[150px] shrink-0 rounded-lg",children:r.jsx(mt,{})}),r.jsxs(gt,{children:[r.jsx(Te,{value:"relevance",children:d("marketplaceSortRelevance")}),r.jsx(Te,{value:"updated",children:d("marketplaceSortUpdated")})]})]})]})})}function Ce(e){var I,C,E,P,R,D;const t=e.record,a=(t==null?void 0:t.type)==="plugin"?t:void 0,n=((I=e.item)==null?void 0:I.type)??(t==null?void 0:t.type),s=((C=e.item)==null?void 0:C.name)??(t==null?void 0:t.label)??(t==null?void 0:t.id)??(t==null?void 0:t.spec)??d("marketplaceUnknownItem"),o=oe((E=e.item)==null?void 0:E.summaryI18n,(P=e.item)==null?void 0:P.summary,e.localeFallbacks)||(t?d("marketplaceInstalledLocalSummary"):""),i=((R=e.item)==null?void 0:R.install.spec)??(t==null?void 0:t.spec)??"",g=(t==null?void 0:t.id)||(t==null?void 0:t.spec),u=!!g&&e.manageState.isPending&&e.manageState.targetId===g,h=!!a,p=(t==null?void 0:t.type)==="plugin"&&t.origin!=="bundled",y=(t==null?void 0:t.type)==="skill"&&t.source==="workspace",v=!!(p||y),x=t?t.enabled===!1||t.runtimeStatus==="disabled":!1,w=(D=e.item)==null?void 0:D.install.spec,f=typeof w=="string"&&e.installState.installingSpecs.has(w),S=n==="plugin"?d("marketplaceTypePlugin"):n==="skill"?d("marketplaceTypeSkill"):d("marketplaceTypeExtension");return r.jsxs("article",{onClick:e.onOpen,className:"group bg-white border border-gray-200/40 hover:border-blue-300/80 rounded-2xl px-5 py-4 hover:shadow-md shadow-sm transition-all flex items-start gap-3.5 justify-between cursor-pointer",children:[r.jsxs("div",{className:"flex gap-3 min-w-0 flex-1 h-full items-start",children:[r.jsx(na,{name:s,fallback:i||d("marketplaceTypeExtension")}),r.jsx("div",{className:"min-w-0 flex-1 flex flex-col justify-center h-full",children:r.jsxs(Jt,{delayDuration:400,children:[r.jsxs(X,{children:[r.jsx(Z,{asChild:!0,children:r.jsx("div",{className:"text-[14px] font-semibold text-gray-900 truncate leading-tight",children:s})}),r.jsx(Q,{className:"max-w-[300px] text-xs",children:s})]}),r.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 mb-1.5",children:[r.jsx("span",{className:"text-[11px] text-gray-500 font-medium",children:S}),i&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-[10px] text-gray-300",children:"•"}),r.jsxs(X,{children:[r.jsx(Z,{asChild:!0,children:r.jsx("span",{className:"text-[11px] text-gray-400 truncate max-w-full font-mono",children:i})}),r.jsx(Q,{className:"max-w-[300px] text-xs font-mono break-all",children:i})]})]})]}),r.jsxs(X,{children:[r.jsx(Z,{asChild:!0,children:r.jsx("p",{className:"text-[12px] text-gray-500/90 line-clamp-1 transition-colors leading-relaxed text-left",children:o})}),o&&r.jsx(Q,{className:"max-w-[400px] text-xs leading-relaxed",children:o})]})]})})]}),r.jsxs("div",{className:"shrink-0 flex items-center h-full",children:[e.item&&!t&&r.jsx("button",{onClick:T=>{T.stopPropagation(),e.onInstall(e.item)},disabled:f,className:"inline-flex items-center gap-1.5 h-8 px-4 rounded-xl text-xs font-medium bg-primary text-white hover:bg-primary-600 disabled:opacity-50 transition-colors",children:f?d("marketplaceInstalling"):d("marketplaceInstall")}),a&&h&&r.jsx("button",{disabled:e.manageState.isPending,onClick:T=>{T.stopPropagation(),e.onManage(x?"enable":"disable",a)},className:"inline-flex items-center h-8 px-4 rounded-xl text-xs font-medium border border-gray-200/80 text-gray-600 bg-white hover:bg-gray-50 hover:border-gray-300 disabled:opacity-50 transition-colors",children:u&&e.manageState.action!=="uninstall"?e.manageState.action==="enable"?d("marketplaceEnabling"):d("marketplaceDisabling"):x?d("marketplaceEnable"):d("marketplaceDisable")}),t&&v&&r.jsx("button",{disabled:e.manageState.isPending,onClick:T=>{T.stopPropagation(),e.onManage("uninstall",t)},className:"inline-flex items-center h-8 px-4 rounded-xl text-xs font-medium border border-rose-100 text-rose-500 bg-white hover:bg-rose-50 hover:border-rose-200 disabled:opacity-50 transition-colors",children:u&&e.manageState.action==="uninstall"?d("marketplaceRemoving"):d("marketplaceUninstall")})]})]})}function ra(e){return r.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2",children:[r.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:d("prev")}),r.jsx("div",{className:"text-sm text-gray-600 min-w-20 text-center",children:e.totalPages===0?"0 / 0":`${e.page} / ${e.totalPages}`}),r.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:d("next")})]})}function oa(e={}){var fe,xe,he,ye,be,ke,ve,we;const t=ot(),a=lt(),{language:n}=ct(),s=ut(),o=e.forcedType,i=c.useMemo(()=>o==="plugins"||o==="skills"?o:a.type==="plugins"||a.type==="skills"?a.type:null,[o,a.type]);c.useEffect(()=>{o||i||t("/marketplace/plugins",{replace:!0})},[o,i,t]);const g=i==="skills"?"skill":"plugin",u=c.useMemo(()=>ea(n),[n]),p=g==="plugin"?{pageTitle:"marketplacePluginsPageTitle",pageDescription:"marketplacePluginsPageDescription",tabMarketplace:"marketplaceTabMarketplacePlugins",tabInstalled:"marketplaceTabInstalledPlugins",searchPlaceholder:"marketplaceSearchPlaceholderPlugins",sectionCatalog:"marketplaceSectionPlugins",sectionInstalled:"marketplaceSectionInstalledPlugins",errorLoadData:"marketplaceErrorLoadingPluginsData",errorLoadInstalled:"marketplaceErrorLoadingInstalledPlugins",emptyData:"marketplaceNoPlugins",emptyInstalled:"marketplaceNoInstalledPlugins",installedCountSuffix:"marketplaceInstalledPluginsCountSuffix"}:{pageTitle:"marketplaceSkillsPageTitle",pageDescription:"marketplaceSkillsPageDescription",tabMarketplace:"marketplaceTabMarketplaceSkills",tabInstalled:"marketplaceTabInstalledSkills",searchPlaceholder:"marketplaceSearchPlaceholderSkills",sectionCatalog:"marketplaceSectionSkills",sectionInstalled:"marketplaceSectionInstalledSkills",errorLoadData:"marketplaceErrorLoadingSkillsData",errorLoadInstalled:"marketplaceErrorLoadingInstalledSkills",emptyData:"marketplaceNoSkills",emptyInstalled:"marketplaceNoInstalledSkills",installedCountSuffix:"marketplaceInstalledSkillsCountSuffix"},[y,v]=c.useState(""),[x,w]=c.useState(""),[f,S]=c.useState("all"),[I,C]=c.useState("relevance"),[E,P]=c.useState(1),[R,D]=c.useState(new Set);c.useEffect(()=>{const l=setTimeout(()=>{P(1),w(y.trim())},250);return()=>clearTimeout(l)},[y]),c.useEffect(()=>{P(1)},[g]);const T=Pt(g),M=Ct({q:x||void 0,type:g,sort:I,page:E,pageSize:Yt}),qe=jt(),$=It(),{confirm:He,ConfirmDialog:Ke}=xt(),B=c.useMemo(()=>{var l;return((l=T.data)==null?void 0:l.records)??[]},[(fe=T.data)==null?void 0:fe.records]),_=c.useMemo(()=>{var l;return((l=M.data)==null?void 0:l.items)??[]},[(xe=M.data)==null?void 0:xe.items]),le=c.useMemo(()=>Wt(_),[_]),ie=c.useMemo(()=>Xt(B),[B]),z=c.useMemo(()=>{const l=B.filter(m=>m.type===g).map(m=>({key:`${m.type}:${m.spec}:${m.id??""}`,record:m,item:Zt(m,le)})).filter(m=>ta(m.record,m.item,x,u));return l.sort((m,k)=>{const j=m.record.installedAt?Date.parse(m.record.installedAt):Number.NaN,b=k.record.installedAt?Date.parse(k.record.installedAt):Number.NaN,L=!Number.isNaN(j),Ge=!Number.isNaN(b);return L&&Ge&&j!==b?b-j:m.record.spec.localeCompare(k.record.spec)}),l},[B,g,le,x,u]),ce=f==="installed"?z.length:((he=M.data)==null?void 0:he.total)??0,W=f==="installed"?1:((ye=M.data)==null?void 0:ye.totalPages)??0,Be=c.useMemo(()=>f==="installed"?T.isLoading?d("loading"):`${z.length} ${d(p.installedCountSuffix)}`:M.data?`${_.length} / ${ce}`:d("loading"),[f,T.isLoading,z.length,M.data,_.length,ce,p.installedCountSuffix]),ue={installingSpecs:R},de={isPending:$.isPending,targetId:((be=$.variables)==null?void 0:be.id)||((ke=$.variables)==null?void 0:ke.spec),action:(ve=$.variables)==null?void 0:ve.action},Qe=[{id:"all",label:d(p.tabMarketplace)},{id:"installed",label:d(p.tabInstalled),count:((we=T.data)==null?void 0:we.total)??0}],pe=async l=>{const m=l.install.spec;if(!R.has(m)){D(k=>{const j=new Set(k);return j.add(m),j});try{await qe.mutateAsync({type:l.type,spec:m,kind:l.install.kind,...l.type==="skill"?{skill:l.slug,installPath:`skills/${l.slug}`}:{}})}catch{}finally{D(k=>{if(!k.has(m))return k;const j=new Set(k);return j.delete(m),j})}}},me=async(l,m)=>{if($.isPending)return;const k=m.id||m.spec;k&&(l==="uninstall"&&!await He({title:`${d("marketplaceUninstallTitle")} ${k}?`,description:d("marketplaceUninstallDescription"),confirmLabel:d("marketplaceUninstall"),variant:"destructive"})||$.mutate({type:m.type,action:l,id:k,spec:m.spec}))},ge=async(l,m)=>{const k=(l==null?void 0:l.name)??(m==null?void 0:m.label)??(m==null?void 0:m.id)??(m==null?void 0:m.spec)??d("marketplaceUnknownItem");if(!l){const b=q({title:k,typeLabel:(m==null?void 0:m.type)==="plugin"?d("marketplaceTypePlugin"):d("marketplaceTypeSkill"),spec:(m==null?void 0:m.spec)??"-",summary:d("marketplaceInstalledLocalSummary"),metadataRaw:JSON.stringify(m??{},null,2),contentRaw:"-"});s.open(b,{newTab:!0,title:k,kind:"content"});return}const j=oe(l.summaryI18n,l.summary,u);if(l.type==="skill"){try{const b=await kt(l.slug),L=q({title:k,typeLabel:d("marketplaceTypeSkill"),spec:l.install.spec,summary:j,metadataRaw:b.metadataRaw,contentRaw:b.bodyRaw||b.raw,sourceUrl:b.sourceUrl,sourceLabel:`Source (${b.source})`,tags:l.tags,author:l.author});s.open(L,{newTab:!0,title:k,kind:"content"})}catch(b){const L=q({title:k,typeLabel:d("marketplaceTypeSkill"),spec:l.install.spec,summary:j,metadataRaw:JSON.stringify({error:b instanceof Error?b.message:String(b)},null,2),contentRaw:d("marketplaceOperationFailed")});s.open(L,{newTab:!0,title:k,kind:"content"})}return}try{const b=await vt(l.slug),L=q({title:k,typeLabel:d("marketplaceTypePlugin"),spec:l.install.spec,summary:j,metadataRaw:b.metadataRaw,contentRaw:b.bodyRaw||b.raw||l.summary,sourceUrl:b.sourceUrl,sourceLabel:`Source (${b.source})`,tags:l.tags,author:l.author});s.open(L,{newTab:!0,title:k,kind:"content"})}catch(b){const L=q({title:k,typeLabel:d("marketplaceTypePlugin"),spec:l.install.spec,summary:j,metadataRaw:JSON.stringify({error:b instanceof Error?b.message:String(b)},null,2),contentRaw:"-"});s.open(L,{newTab:!0,title:k,kind:"content"})}};return r.jsxs(ht,{children:[r.jsx(yt,{title:d(p.pageTitle),description:d(p.pageDescription)}),r.jsx(ft,{tabs:Qe,activeTab:f,onChange:l=>{S(l),P(1)},className:"mb-4"}),r.jsx(sa,{scope:f,searchText:y,searchPlaceholder:d(p.searchPlaceholder),sort:I,onSearchTextChange:v,onSortChange:l=>{P(1),C(l)}}),r.jsxs("section",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h3",{className:"text-[14px] font-semibold text-gray-900",children:f==="installed"?d(p.sectionInstalled):d(p.sectionCatalog)}),r.jsx("span",{className:"text-[12px] text-gray-500",children:Be})]}),f==="all"&&M.isError&&r.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[d(p.errorLoadData),": ",M.error.message]}),f==="installed"&&T.isError&&r.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[d(p.errorLoadInstalled),": ",T.error.message]}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 2xl:grid-cols-3 gap-3",children:[f==="all"&&_.map(l=>r.jsx(Ce,{item:l,record:Se(l,ie),localeFallbacks:u,installState:ue,manageState:de,onOpen:()=>void ge(l,Se(l,ie)),onInstall:pe,onManage:me},l.id)),f==="installed"&&z.map(l=>r.jsx(Ce,{item:l.item,record:l.record,localeFallbacks:u,installState:ue,manageState:de,onOpen:()=>void ge(l.item,l.record),onInstall:pe,onManage:me},l.key))]}),f==="all"&&!M.isLoading&&!M.isError&&_.length===0&&r.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:d(p.emptyData)}),f==="installed"&&!T.isLoading&&!T.isError&&z.length===0&&r.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:d(p.emptyInstalled)})]}),f==="all"&&r.jsx(ra,{page:E,totalPages:W,busy:M.isFetching,onPrev:()=>P(l=>Math.max(1,l-1)),onNext:()=>P(l=>W>0?Math.min(W,l+1):l+1)}),r.jsx(Ke,{})]})}const pa=Object.freeze(Object.defineProperty({__proto__:null,MarketplacePage:oa},Symbol.toStringTag,{value:"Module"}));export{oa as M,Jt as T,X as a,Z as b,Q as c,pa as d,Pt as u};
|
|
49
|
+
</html>`;return`data:text/html;charset=utf-8,${encodeURIComponent(i)}`}function sa(e){return s.jsx("div",{className:"mb-4",children:s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsxs("div",{className:"flex-1 min-w-0 relative",children:[s.jsx(it,{className:"h-4 w-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2"}),s.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"&&s.jsxs(dt,{value:e.sort,onValueChange:t=>e.onSortChange(t),children:[s.jsx(pt,{className:"h-9 w-[150px] shrink-0 rounded-lg",children:s.jsx(mt,{})}),s.jsxs(gt,{children:[s.jsx(Te,{value:"relevance",children:d("marketplaceSortRelevance")}),s.jsx(Te,{value:"updated",children:d("marketplaceSortUpdated")})]})]})]})})}function Ce(e){var I,C,E,P,R,D;const t=e.record,a=(t==null?void 0:t.type)==="plugin"?t:void 0,n=((I=e.item)==null?void 0:I.type)??(t==null?void 0:t.type),r=((C=e.item)==null?void 0:C.name)??(t==null?void 0:t.label)??(t==null?void 0:t.id)??(t==null?void 0:t.spec)??d("marketplaceUnknownItem"),o=oe((E=e.item)==null?void 0:E.summaryI18n,(P=e.item)==null?void 0:P.summary,e.localeFallbacks)||(t?d("marketplaceInstalledLocalSummary"):""),i=((R=e.item)==null?void 0:R.install.spec)??(t==null?void 0:t.spec)??"",g=(t==null?void 0:t.id)||(t==null?void 0:t.spec),u=!!g&&e.manageState.isPending&&e.manageState.targetId===g,h=!!a,p=(t==null?void 0:t.type)==="plugin"&&t.origin!=="bundled",y=(t==null?void 0:t.type)==="skill"&&t.source==="workspace",v=!!(p||y),x=t?t.enabled===!1||t.runtimeStatus==="disabled":!1,w=(D=e.item)==null?void 0:D.install.spec,f=typeof w=="string"&&e.installState.installingSpecs.has(w),S=n==="plugin"?d("marketplaceTypePlugin"):n==="skill"?d("marketplaceTypeSkill"):d("marketplaceTypeExtension");return s.jsxs("article",{onClick:e.onOpen,className:"group bg-white border border-gray-200/40 hover:border-blue-300/80 rounded-2xl px-5 py-4 hover:shadow-md shadow-sm transition-all flex items-start gap-3.5 justify-between cursor-pointer",children:[s.jsxs("div",{className:"flex gap-3 min-w-0 flex-1 h-full items-start",children:[s.jsx(na,{name:r,fallback:i||d("marketplaceTypeExtension")}),s.jsx("div",{className:"min-w-0 flex-1 flex flex-col justify-center h-full",children:s.jsxs(Jt,{delayDuration:400,children:[s.jsxs(X,{children:[s.jsx(Z,{asChild:!0,children:s.jsx("div",{className:"text-[14px] font-semibold text-gray-900 truncate leading-tight",children:r})}),s.jsx(Q,{className:"max-w-[300px] text-xs",children:r})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 mb-1.5",children:[s.jsx("span",{className:"text-[11px] text-gray-500 font-medium",children:S}),i&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-[10px] text-gray-300",children:"•"}),s.jsxs(X,{children:[s.jsx(Z,{asChild:!0,children:s.jsx("span",{className:"text-[11px] text-gray-400 truncate max-w-full font-mono",children:i})}),s.jsx(Q,{className:"max-w-[300px] text-xs font-mono break-all",children:i})]})]})]}),s.jsxs(X,{children:[s.jsx(Z,{asChild:!0,children:s.jsx("p",{className:"text-[12px] text-gray-500/90 line-clamp-1 transition-colors leading-relaxed text-left",children:o})}),o&&s.jsx(Q,{className:"max-w-[400px] text-xs leading-relaxed",children:o})]})]})})]}),s.jsxs("div",{className:"shrink-0 flex items-center h-full",children:[e.item&&!t&&s.jsx("button",{onClick:T=>{T.stopPropagation(),e.onInstall(e.item)},disabled:f,className:"inline-flex items-center gap-1.5 h-8 px-4 rounded-xl text-xs font-medium bg-primary text-white hover:bg-primary-600 disabled:opacity-50 transition-colors",children:f?d("marketplaceInstalling"):d("marketplaceInstall")}),a&&h&&s.jsx("button",{disabled:e.manageState.isPending,onClick:T=>{T.stopPropagation(),e.onManage(x?"enable":"disable",a)},className:"inline-flex items-center h-8 px-4 rounded-xl text-xs font-medium border border-gray-200/80 text-gray-600 bg-white hover:bg-gray-50 hover:border-gray-300 disabled:opacity-50 transition-colors",children:u&&e.manageState.action!=="uninstall"?e.manageState.action==="enable"?d("marketplaceEnabling"):d("marketplaceDisabling"):x?d("marketplaceEnable"):d("marketplaceDisable")}),t&&v&&s.jsx("button",{disabled:e.manageState.isPending,onClick:T=>{T.stopPropagation(),e.onManage("uninstall",t)},className:"inline-flex items-center h-8 px-4 rounded-xl text-xs font-medium border border-rose-100 text-rose-500 bg-white hover:bg-rose-50 hover:border-rose-200 disabled:opacity-50 transition-colors",children:u&&e.manageState.action==="uninstall"?d("marketplaceRemoving"):d("marketplaceUninstall")})]})]})}function ra(e){return s.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2",children:[s.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:d("prev")}),s.jsx("div",{className:"text-sm text-gray-600 min-w-20 text-center",children:e.totalPages===0?"0 / 0":`${e.page} / ${e.totalPages}`}),s.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:d("next")})]})}function oa(e={}){var fe,xe,he,ye,be,ke,ve,we;const t=ot(),a=lt(),{language:n}=ct(),r=ut(),o=e.forcedType,i=c.useMemo(()=>o==="plugins"||o==="skills"?o:a.type==="plugins"||a.type==="skills"?a.type:null,[o,a.type]);c.useEffect(()=>{o||i||t("/marketplace/plugins",{replace:!0})},[o,i,t]);const g=i==="skills"?"skill":"plugin",u=c.useMemo(()=>ea(n),[n]),p=g==="plugin"?{pageTitle:"marketplacePluginsPageTitle",pageDescription:"marketplacePluginsPageDescription",tabMarketplace:"marketplaceTabMarketplacePlugins",tabInstalled:"marketplaceTabInstalledPlugins",searchPlaceholder:"marketplaceSearchPlaceholderPlugins",sectionCatalog:"marketplaceSectionPlugins",sectionInstalled:"marketplaceSectionInstalledPlugins",errorLoadData:"marketplaceErrorLoadingPluginsData",errorLoadInstalled:"marketplaceErrorLoadingInstalledPlugins",emptyData:"marketplaceNoPlugins",emptyInstalled:"marketplaceNoInstalledPlugins",installedCountSuffix:"marketplaceInstalledPluginsCountSuffix"}:{pageTitle:"marketplaceSkillsPageTitle",pageDescription:"marketplaceSkillsPageDescription",tabMarketplace:"marketplaceTabMarketplaceSkills",tabInstalled:"marketplaceTabInstalledSkills",searchPlaceholder:"marketplaceSearchPlaceholderSkills",sectionCatalog:"marketplaceSectionSkills",sectionInstalled:"marketplaceSectionInstalledSkills",errorLoadData:"marketplaceErrorLoadingSkillsData",errorLoadInstalled:"marketplaceErrorLoadingInstalledSkills",emptyData:"marketplaceNoSkills",emptyInstalled:"marketplaceNoInstalledSkills",installedCountSuffix:"marketplaceInstalledSkillsCountSuffix"},[y,v]=c.useState(""),[x,w]=c.useState(""),[f,S]=c.useState("all"),[I,C]=c.useState("relevance"),[E,P]=c.useState(1),[R,D]=c.useState(new Set);c.useEffect(()=>{const l=setTimeout(()=>{P(1),w(y.trim())},250);return()=>clearTimeout(l)},[y]),c.useEffect(()=>{P(1)},[g]);const T=Pt(g),M=Ct({q:x||void 0,type:g,sort:I,page:E,pageSize:Yt}),qe=jt(),$=It(),{confirm:He,ConfirmDialog:Ke}=xt(),B=c.useMemo(()=>{var l;return((l=T.data)==null?void 0:l.records)??[]},[(fe=T.data)==null?void 0:fe.records]),_=c.useMemo(()=>{var l;return((l=M.data)==null?void 0:l.items)??[]},[(xe=M.data)==null?void 0:xe.items]),le=c.useMemo(()=>Wt(_),[_]),ie=c.useMemo(()=>Xt(B),[B]),z=c.useMemo(()=>{const l=B.filter(m=>m.type===g).map(m=>({key:`${m.type}:${m.spec}:${m.id??""}`,record:m,item:Zt(m,le)})).filter(m=>ta(m.record,m.item,x,u));return l.sort((m,k)=>{const j=m.record.installedAt?Date.parse(m.record.installedAt):Number.NaN,b=k.record.installedAt?Date.parse(k.record.installedAt):Number.NaN,L=!Number.isNaN(j),Ge=!Number.isNaN(b);return L&&Ge&&j!==b?b-j:m.record.spec.localeCompare(k.record.spec)}),l},[B,g,le,x,u]),ce=f==="installed"?z.length:((he=M.data)==null?void 0:he.total)??0,W=f==="installed"?1:((ye=M.data)==null?void 0:ye.totalPages)??0,Be=c.useMemo(()=>f==="installed"?T.isLoading?d("loading"):`${z.length} ${d(p.installedCountSuffix)}`:M.data?`${_.length} / ${ce}`:d("loading"),[f,T.isLoading,z.length,M.data,_.length,ce,p.installedCountSuffix]),ue={installingSpecs:R},de={isPending:$.isPending,targetId:((be=$.variables)==null?void 0:be.id)||((ke=$.variables)==null?void 0:ke.spec),action:(ve=$.variables)==null?void 0:ve.action},Qe=[{id:"all",label:d(p.tabMarketplace)},{id:"installed",label:d(p.tabInstalled),count:((we=T.data)==null?void 0:we.total)??0}],pe=async l=>{const m=l.install.spec;if(!R.has(m)){D(k=>{const j=new Set(k);return j.add(m),j});try{await qe.mutateAsync({type:l.type,spec:m,kind:l.install.kind,...l.type==="skill"?{skill:l.slug,installPath:`skills/${l.slug}`}:{}})}catch{}finally{D(k=>{if(!k.has(m))return k;const j=new Set(k);return j.delete(m),j})}}},me=async(l,m)=>{if($.isPending)return;const k=m.id||m.spec;k&&(l==="uninstall"&&!await He({title:`${d("marketplaceUninstallTitle")} ${k}?`,description:d("marketplaceUninstallDescription"),confirmLabel:d("marketplaceUninstall"),variant:"destructive"})||$.mutate({type:m.type,action:l,id:k,spec:m.spec}))},ge=async(l,m)=>{const k=(l==null?void 0:l.name)??(m==null?void 0:m.label)??(m==null?void 0:m.id)??(m==null?void 0:m.spec)??d("marketplaceUnknownItem");if(!l){const b=q({title:k,typeLabel:(m==null?void 0:m.type)==="plugin"?d("marketplaceTypePlugin"):d("marketplaceTypeSkill"),spec:(m==null?void 0:m.spec)??"-",summary:d("marketplaceInstalledLocalSummary"),metadataRaw:JSON.stringify(m??{},null,2),contentRaw:"-"});r.open(b,{newTab:!0,title:k,kind:"content"});return}const j=oe(l.summaryI18n,l.summary,u);if(l.type==="skill"){try{const b=await kt(l.slug),L=q({title:k,typeLabel:d("marketplaceTypeSkill"),spec:l.install.spec,summary:j,metadataRaw:b.metadataRaw,contentRaw:b.bodyRaw||b.raw,sourceUrl:b.sourceUrl,sourceLabel:`Source (${b.source})`,tags:l.tags,author:l.author});r.open(L,{newTab:!0,title:k,kind:"content"})}catch(b){const L=q({title:k,typeLabel:d("marketplaceTypeSkill"),spec:l.install.spec,summary:j,metadataRaw:JSON.stringify({error:b instanceof Error?b.message:String(b)},null,2),contentRaw:d("marketplaceOperationFailed")});r.open(L,{newTab:!0,title:k,kind:"content"})}return}try{const b=await vt(l.slug),L=q({title:k,typeLabel:d("marketplaceTypePlugin"),spec:l.install.spec,summary:j,metadataRaw:b.metadataRaw,contentRaw:b.bodyRaw||b.raw||l.summary,sourceUrl:b.sourceUrl,sourceLabel:`Source (${b.source})`,tags:l.tags,author:l.author});r.open(L,{newTab:!0,title:k,kind:"content"})}catch(b){const L=q({title:k,typeLabel:d("marketplaceTypePlugin"),spec:l.install.spec,summary:j,metadataRaw:JSON.stringify({error:b instanceof Error?b.message:String(b)},null,2),contentRaw:"-"});r.open(L,{newTab:!0,title:k,kind:"content"})}};return s.jsxs(ht,{className:"flex h-full min-h-0 flex-col pb-0",children:[s.jsx(yt,{title:d(p.pageTitle),description:d(p.pageDescription)}),s.jsx(ft,{tabs:Qe,activeTab:f,onChange:l=>{S(l),P(1)},className:"mb-4"}),s.jsx(sa,{scope:f,searchText:y,searchPlaceholder:d(p.searchPlaceholder),sort:I,onSearchTextChange:v,onSortChange:l=>{P(1),C(l)}}),s.jsxs("section",{className:"flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-[14px] font-semibold text-gray-900",children:f==="installed"?d(p.sectionInstalled):d(p.sectionCatalog)}),s.jsx("span",{className:"text-[12px] text-gray-500",children:Be})]}),f==="all"&&M.isError&&s.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[d(p.errorLoadData),": ",M.error.message]}),f==="installed"&&T.isError&&s.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[d(p.errorLoadInstalled),": ",T.error.message]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto custom-scrollbar pr-1",children:[s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 2xl:grid-cols-3 gap-3",children:[f==="all"&&_.map(l=>s.jsx(Ce,{item:l,record:Se(l,ie),localeFallbacks:u,installState:ue,manageState:de,onOpen:()=>void ge(l,Se(l,ie)),onInstall:pe,onManage:me},l.id)),f==="installed"&&z.map(l=>s.jsx(Ce,{item:l.item,record:l.record,localeFallbacks:u,installState:ue,manageState:de,onOpen:()=>void ge(l.item,l.record),onInstall:pe,onManage:me},l.key))]}),f==="all"&&!M.isLoading&&!M.isError&&_.length===0&&s.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:d(p.emptyData)}),f==="installed"&&!T.isLoading&&!T.isError&&z.length===0&&s.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:d(p.emptyInstalled)})]})]}),f==="all"&&s.jsx("div",{className:"shrink-0",children:s.jsx(ra,{page:E,totalPages:W,busy:M.isFetching,onPrev:()=>P(l=>Math.max(1,l-1)),onNext:()=>P(l=>W>0?Math.min(W,l+1):l+1)})}),s.jsx(Ke,{})]})}const pa=Object.freeze(Object.defineProperty({__proto__:null,MarketplacePage:oa},Symbol.toStringTag,{value:"Module"}));export{oa as M,Jt as T,X as a,Z as b,Q as c,pa as d,Pt as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,r as i,Y,k as B,p as q,z as G,Z as K,_ as Z}from"./vendor-
|
|
1
|
+
import{j as e,r as i,Y,k as B,p as q,z as G,Z as K,_ as Z}from"./vendor-C--HHaLf.js";import{P as $,a as J,B as Q}from"./page-layout-DA6PFRtQ.js";import{C as U}from"./card-Bf4CtrW8.js";import{I as A}from"./input-CaKJyoWZ.js";import{L as _}from"./label-BaXSWTKI.js";import{c as L,u as X,a as H,b as ee,d as se,t as c,S as te,e as ae,f as le,g as re,h as ne,D as oe}from"./index-dKTqKCJo.js";import{h as R}from"./config-hints-CApS3K_7.js";import{b as ie,f as ce,t as T,c as de}from"./provider-models-y4mUDcGF.js";function h({className:o,...l}){return e.jsx("div",{className:L("animate-pulse rounded-md bg-slate-200",o),...l})}function me(o){const l=new Set;for(const u of o){const m=u.trim();m.length>0&&l.add(m)}return[...l]}function xe({id:o,value:l,onChange:u,options:m,placeholder:N,className:w,inputClassName:y,emptyText:b,createText:f,maxItems:v=Number.POSITIVE_INFINITY,onEnter:M}){const[C,r]=i.useState(!1),d=i.useMemo(()=>me(m),[m]),a=l.trim().toLowerCase(),g=i.useMemo(()=>{const s=d.map((x,j)=>({option:x,index:j}));a.length>0&&s.sort((x,j)=>{const S=x.option.toLowerCase(),k=j.option.toLowerCase(),D=S===a?0:S.startsWith(a)?1:S.includes(a)?2:3,I=k===a?0:k.startsWith(a)?1:k.includes(a)?2:3;return D!==I?D-I:x.index-j.index});const p=s.map(x=>x.option);return Number.isFinite(v)?p.slice(0,Math.max(1,v)):p},[d,a,v]),n=l.trim().length>0&&d.some(s=>s===l.trim());return e.jsxs("div",{className:L("relative",w),onBlur:()=>{setTimeout(()=>r(!1),120)},children:[e.jsx(A,{id:o,value:l,onFocus:()=>r(!0),onChange:s=>{u(s.target.value),C||r(!0)},onKeyDown:s=>{s.key==="Enter"&&(M&&(s.preventDefault(),M()),r(!1))},placeholder:N,className:L("pr-10",y)}),e.jsx("button",{type:"button",onMouseDown:s=>s.preventDefault(),onClick:()=>r(s=>!s),className:"absolute inset-y-0 right-0 inline-flex w-10 items-center justify-center text-gray-400 hover:text-gray-600","aria-label":"toggle model options",children:e.jsx(Y,{className:"h-4 w-4"})}),C&&e.jsx("div",{className:"absolute z-20 mt-1 w-full overflow-hidden rounded-xl border border-gray-200 bg-white shadow-lg",children:e.jsxs("div",{className:"max-h-60 overflow-y-auto py-1",children:[!n&&l.trim().length>0&&e.jsxs("button",{type:"button",onMouseDown:s=>s.preventDefault(),onClick:()=>{u(l.trim()),r(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50",children:[e.jsx(B,{className:"h-4 w-4 text-transparent"}),e.jsx("span",{className:"truncate text-gray-700",children:f?f.replace("{value}",l.trim()):l.trim()})]}),g.map(s=>e.jsxs("button",{type:"button",onMouseDown:p=>p.preventDefault(),onClick:()=>{u(s),r(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50",children:[e.jsx(B,{className:L("h-4 w-4",s===l.trim()?"text-primary":"text-transparent")}),e.jsx("span",{className:"truncate text-gray-700",children:s})]},s)),g.length===0&&l.trim().length===0&&e.jsx("div",{className:"px-3 py-2 text-sm text-gray-500",children:b??"No models available"})]})})]})}function ye(){const{data:o,isLoading:l}=X(),{data:u}=H(),{data:m}=ee(),N=se(),[w,y]=i.useState(""),[b,f]=i.useState(""),[v,M]=i.useState(""),C=m==null?void 0:m.uiHints,r=R("agents.defaults.model",C),d=R("agents.defaults.workspace",C),a=i.useMemo(()=>ie({meta:u,config:o}),[o,u]),g=i.useMemo(()=>new Map(a.map(t=>[t.name,t])),[a]),n=g.get(w)??a[0],s=(n==null?void 0:n.name)??"",p=i.useMemo(()=>(n==null?void 0:n.aliases)??[],[n]),x=i.useMemo(()=>(n==null?void 0:n.models)??[],[n]);i.useEffect(()=>{w||a.length===0||y(a[0].name)},[w,a]),i.useEffect(()=>{var E,F,z;if(!((E=o==null?void 0:o.agents)!=null&&E.defaults))return;const t=(o.agents.defaults.model||"").trim(),P=ce(t,a)??((F=a[0])==null?void 0:F.name)??"",W=((z=g.get(P))==null?void 0:z.aliases)??[];y(P),f(T(t,W)),M(o.agents.defaults.workspace||"")},[o,a,g]);const j=i.useMemo(()=>{const t=new Set;for(const O of x){const P=O.trim();P&&t.add(P)}return[...t]},[x]),S=i.useMemo(()=>{const t=T(b,p);return t?de((n==null?void 0:n.prefix)??"",t):""},[b,n,p]),k=c("modelIdentifierHelp")||(r==null?void 0:r.help)||"",D=t=>{y(t),f("")},I=t=>{f(T(t,p))},V=t=>{t.preventDefault(),N.mutate({model:S})};return l?e.jsxs("div",{className:"max-w-2xl space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{className:"h-8 w-32"}),e.jsx(h,{className:"h-4 w-48"})]}),e.jsxs(U,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx(h,{className:"h-12 w-12 rounded-xl"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{className:"h-5 w-24"}),e.jsx(h,{className:"h-3 w-32"})]})]}),e.jsx(h,{className:"h-4 w-20 mb-2"}),e.jsx(h,{className:"h-10 w-full rounded-xl"})]}),e.jsxs(U,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsx(h,{className:"h-5 w-24 mb-2"}),e.jsx(h,{className:"h-10 w-full rounded-xl"})]})]}):e.jsxs($,{children:[e.jsx(J,{title:c("modelPageTitle"),description:c("modelPageDescription")}),e.jsxs("form",{onSubmit:V,className:"space-y-8",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"p-8 rounded-2xl bg-white border border-gray-200 shadow-card",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white",children:e.jsx(q,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:c("defaultModel")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_,{htmlFor:"model",className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(r==null?void 0:r.label)??"Model Name"}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("div",{className:"sm:w-[38%] sm:min-w-[170px]",children:e.jsxs(te,{value:s,onValueChange:D,children:[e.jsx(ae,{className:"h-10 w-full rounded-xl",children:e.jsx(le,{placeholder:c("providersSelectPlaceholder")})}),e.jsx(re,{children:a.map(t=>e.jsx(ne,{value:t.name,children:t.displayName},t.name))})]})}),e.jsx("span",{className:"hidden h-10 items-center justify-center leading-none text-lg font-semibold text-gray-300 sm:inline-flex",children:"/"}),e.jsx(xe,{id:"model",value:b,onChange:I,options:j,placeholder:(r==null?void 0:r.placeholder)??"gpt-5.1",className:"sm:flex-1",inputClassName:"h-10 rounded-xl",emptyText:c("modelPickerNoOptions"),createText:c("modelPickerUseCustom")},s)]}),e.jsx("p",{className:"text-xs text-gray-400",children:k}),e.jsx("p",{className:"text-xs text-gray-500",children:c("modelInputCustomHint")}),e.jsxs("a",{href:`${oe}/guide/model-selection`,className:"inline-flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover transition-colors",children:[e.jsx(G,{className:"h-3.5 w-3.5"}),c("channelsGuideTitle")]})]})]}),e.jsxs("div",{className:"p-8 rounded-2xl bg-white border border-gray-200 shadow-card",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white",children:e.jsx(K,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:c("workspace")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_,{htmlFor:"workspace",className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(d==null?void 0:d.label)??"Default Path"}),e.jsx(A,{id:"workspace",value:v,onChange:t=>M(t.target.value),placeholder:(d==null?void 0:d.placeholder)??"/path/to/workspace",className:"rounded-xl"})]})]})]}),e.jsx("div",{className:"flex justify-end pt-4",children:e.jsx(Q,{type:"submit",disabled:N.isPending,size:"lg",children:N.isPending?e.jsx(Z,{className:"h-5 w-5 animate-spin"}):c("saveChanges")})})]})]})}export{ye as ModelConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as e,aH as Ge,aI as Qe,aB as $e,a0 as ye,a as Ue,d as B,ax as Ie,aJ as Ve,C as Ye,aK as Je,a1 as Xe,K as Ze}from"./vendor-D33xZtEC.js";import{c as te,t,u as Le,a as Te,b as Be,z as es,A as ss,C as ts,E as as,F as rs,G as ns,H as is,S as ls,e as os,f as cs,g as ds,h as us,I as ms}from"./index-CGo5Vnh0.js";import{B as k,P as xs,a as hs}from"./page-layout-BOgLC2tK.js";import{I as R}from"./input-CzTldMKo.js";import{L as O}from"./label-De__vsU7.js";import{C as ps,a as fs,S as Ke,b as ys,c as gs,L as js}from"./LogoBadge-C_ygxoGB.js";import{h as ee}from"./config-hints-CApS3K_7.js";import{T as bs}from"./tabs-custom-DhOxWfCb.js";function vs({maskedValue:s,isSet:r,className:i,value:l,onChange:y,placeholder:w,...g}){const[u,f]=c.useState(!1),[j,b]=c.useState(!1),E=typeof l=="string"&&l.length>0,D=r&&!E&&!j;return e.jsxs("div",{className:"relative",children:[D?e.jsx("div",{onClick:()=>b(!0),className:te("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",i),children:"••••••••••••"}):e.jsx(R,{type:u?"text":"password",className:te("pr-12",i),value:l,onChange:y,onBlur:()=>{E||b(!1)},placeholder:w,autoFocus:j,...g}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:(r||E)&&e.jsx(k,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>f(!u),children:u?e.jsx(Ge,{className:"h-4 w-4"}):e.jsx(Qe,{className:"h-4 w-4"})})})]})}function ws({value:s,onChange:r,className:i}){const l=s?Object.entries(s):[],y=(u,f,j)=>{const b=[...l];b[u]=[f,j],r(Object.fromEntries(b))},w=()=>{r({...s,"":""})},g=u=>{const f=l.filter((j,b)=>b!==u);r(Object.fromEntries(f))};return e.jsxs("div",{className:te("space-y-2",i),children:[l.map(([u,f],j)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(R,{type:"text",value:u,onChange:b=>y(j,b.target.value,f),placeholder:t("headerName"),className:"flex-1"}),e.jsx(R,{type:"text",value:f,onChange:b=>y(j,u,b.target.value),placeholder:t("headerValue"),className:"flex-1"}),e.jsx(k,{type:"button",variant:"ghost",size:"icon",onClick:()=>g(j),children:e.jsx($e,{className:"h-4 w-4 text-red-500"})})]},j)),e.jsxs(k,{type:"button",variant:"outline",size:"sm",onClick:w,children:[e.jsx(ye,{className:"h-4 w-4 mr-2"}),t("add")]})]})}const Ns={displayName:"",apiKeySet:!1,apiBase:null,extraHeaders:null,wireApi:null,models:[]};function se(s){if(!s)return null;const r=Object.entries(s).map(([i,l])=>[i.trim(),l]).filter(([i])=>i.length>0);return r.length===0?null:Object.fromEntries(r)}function ke(s,r){const i=se(s),l=se(r);if(i===null&&l===null)return!0;if(!i||!l)return!1;const y=Object.entries(i).sort(([g],[u])=>g.localeCompare(u)),w=Object.entries(l).sort(([g],[u])=>g.localeCompare(u));return y.length!==w.length?!1:y.every(([g,u],f)=>g===w[f][0]&&u===w[f][1])}function pe(s){if(!s||s.length===0)return[];const r=new Set;for(const i of s){const l=i.trim();l&&r.add(l)}return[...r]}function Cs(s,r){const i=s.trim();if(!i||!r.trim())return i;const l=`${r.trim()}/`;return i.startsWith(l)?i.slice(l.length):i}function oe(s,r){let i=s.trim();if(!i)return"";for(const l of r){const y=l.trim();y&&(i=Cs(i,y))}return i.trim()}function fe(s,r){return s.length!==r.length?!1:s.every((i,l)=>i===r[l])}function As(s,r){const i=[...s];for(const l of r)i.includes(l)||i.push(l);return i}function Ps(s,r){return r.length===0?s:r.every(l=>!s.includes(l))?As(s,r):r}function Ss(s,r){return fe(s,r)?[]:s}function Es({providerName:s,onProviderDeleted:r}){var Se,Ee,De,Me;const i=Ue(),{data:l}=Le(),{data:y}=Te(),{data:w}=Be(),g=es(),u=ss(),f=ts(),j=as(),b=rs(),E=ns(),[D,Q]=c.useState(""),[z,M]=c.useState(""),[K,U]=c.useState(null),[o,h]=c.useState("auto"),[v,N]=c.useState([]),[$,C]=c.useState(""),[I,_]=c.useState(""),[V,ae]=c.useState(!1),[ce,re]=c.useState(!1),[ne,F]=c.useState(null),[ge,P]=c.useState(""),ie=c.useRef(null),n=y==null?void 0:y.providers.find(a=>a.name===s),S=(s?l==null?void 0:l.providers[s]:null)??Ns,le=w==null?void 0:w.uiHints,H=!!(n!=null&&n.isCustom),W=s?ee(`providers.${s}.apiKey`,le):void 0,L=s?ee(`providers.${s}.apiBase`,le):void 0,de=s?ee(`providers.${s}.extraHeaders`,le):void 0,ue=s?ee(`providers.${s}.wireApi`,le):void 0,je=(n==null?void 0:n.displayName)||s||"",q=(S.displayName||"").trim()||je,Fe=I.trim()||q||s||t("providersSelectPlaceholder"),be=(n==null?void 0:n.modelPrefix)||s||"",G=c.useMemo(()=>pe([be,s||""]),[be,s]),me=(n==null?void 0:n.defaultApiBase)||"",Y=S.apiBase||me,xe=se(S.extraHeaders||null),J=S.wireApi||(n==null?void 0:n.defaultWireApi)||"auto",he=c.useMemo(()=>pe(((n==null?void 0:n.defaultModels)??[]).map(a=>oe(a,G))),[n==null?void 0:n.defaultModels,G]),ve=c.useMemo(()=>pe((S.models??[]).map(a=>oe(a,G))),[S.models,G]),X=c.useMemo(()=>Ps(he,ve),[he,ve]),we=is(),ze=((Se=n==null?void 0:n.apiBaseHelp)==null?void 0:Se[we])||((Ee=n==null?void 0:n.apiBaseHelp)==null?void 0:Ee.en)||(L==null?void 0:L.help)||t("providerApiBaseHelp"),p=n==null?void 0:n.auth,Ne=((De=p==null?void 0:p.note)==null?void 0:De[we])||((Me=p==null?void 0:p.note)==null?void 0:Me.en)||(p==null?void 0:p.displayName)||"",A=c.useCallback(()=>{ie.current!==null&&(window.clearTimeout(ie.current),ie.current=null)},[]),Ce=c.useCallback((a,d)=>{A(),ie.current=window.setTimeout(()=>{(async()=>{if(s)try{const x=await b.mutateAsync({provider:s,data:{sessionId:a}});if(x.status==="pending"){P(t("providerAuthWaitingBrowser")),Ce(a,x.nextPollMs??d);return}if(x.status==="authorized"){F(null),A(),P(t("providerAuthCompleted")),B.success(t("providerAuthCompleted")),i.invalidateQueries({queryKey:["config"]}),i.invalidateQueries({queryKey:["config-meta"]});return}F(null),A(),P(x.message||`Authorization ${x.status}.`),B.error(x.message||`Authorization ${x.status}.`)}catch(x){F(null),A();const m=x instanceof Error?x.message:String(x);P(m),B.error(`Authorization failed: ${m}`)}})()},Math.max(1e3,d))},[A,b,s,i]);c.useEffect(()=>{if(!s){Q(""),M(""),U(null),h("auto"),N([]),C(""),_(""),F(null),P(""),A();return}Q(""),M(Y),U(S.extraHeaders||null),h(J),N(X),C(""),_(q),F(null),P(""),A()},[s,Y,S.extraHeaders,J,X,q,A]),c.useEffect(()=>()=>A(),[A]);const Ae=c.useMemo(()=>{if(!s)return!1;const a=D.trim().length>0,d=z.trim()!==Y.trim(),x=!ke(K,xe),m=n!=null&&n.supportsWireApi?o!==J:!1,T=!fe(v,X),Z=H?I.trim()!==q:!1;return a||d||x||m||T||Z},[s,H,I,q,D,z,Y,K,xe,n==null?void 0:n.supportsWireApi,o,J,v,X]),Pe=()=>{const a=oe($,G);if(a){if(v.includes(a)){C("");return}N(d=>[...d,a]),C("")}},_e=a=>{if(a.preventDefault(),!s)return;const d={},x=D.trim(),m=z.trim(),T=se(K),Z=I.trim();H&&Z!==q&&(d.displayName=Z.length>0?Z:null),x.length>0&&(d.apiKey=x),m!==Y.trim()&&(d.apiBase=m.length>0&&m!==me?m:null),ke(T,xe)||(d.extraHeaders=T),n!=null&&n.supportsWireApi&&o!==J&&(d.wireApi=o),fe(v,X)||(d.models=Ss(v,he)),g.mutate({provider:s,data:d})},Oe=async()=>{if(!s)return;const a=v.find(m=>m.trim().length>0)??"",d=oe(a,G),x={apiBase:z.trim(),extraHeaders:se(K),model:d||null};D.trim().length>0&&(x.apiKey=D.trim()),n!=null&&n.supportsWireApi&&(x.wireApi=o);try{const m=await f.mutateAsync({provider:s,data:x});if(m.success){B.success(`${t("providerTestConnectionSuccess")} (${m.latencyMs}ms)`);return}const T=[`provider=${m.provider}`,`latency=${m.latencyMs}ms`];m.model&&T.push(`model=${m.model}`),B.error(`${t("providerTestConnectionFailed")}: ${m.message} | ${T.join(" | ")}`)}catch(m){const T=m instanceof Error?m.message:String(m);B.error(`${t("providerTestConnectionFailed")}: ${T}`)}},Re=async()=>{if(!(!s||!H||!window.confirm(t("providerDeleteConfirm"))))try{await u.mutateAsync({provider:s}),r==null||r(s)}catch{}},He=async()=>{if(!(!s||(p==null?void 0:p.kind)!=="device_code"))try{P("");const a=await j.mutateAsync({provider:s});if(!a.sessionId||!a.verificationUri)throw new Error(t("providerAuthStartFailed"));F(a.sessionId),P(`${t("providerAuthOpenPrompt")}${a.userCode}${t("providerAuthOpenPromptSuffix")}`),window.open(a.verificationUri,"_blank","noopener,noreferrer"),Ce(a.sessionId,a.intervalMs)}catch(a){const d=a instanceof Error?a.message:String(a);F(null),A(),P(d),B.error(`${t("providerAuthStartFailed")}: ${d}`)}},We=async()=>{if(!(!s||(p==null?void 0:p.kind)!=="device_code"))try{A(),F(null);const a=await E.mutateAsync({provider:s}),d=a.expiresAt?` (expires: ${a.expiresAt})`:"";P(`${t("providerAuthImportStatusPrefix")}${d}`),B.success(t("providerAuthImportSuccess")),i.invalidateQueries({queryKey:["config"]}),i.invalidateQueries({queryKey:["config-meta"]})}catch(a){const d=a instanceof Error?a.message:String(a);P(d),B.error(`${t("providerAuthImportFailed")}: ${d}`)}};if(!s||!n)return e.jsx("div",{className:ps,children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:t("providersSelectTitle")}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:t("providersSelectDescription")})]})});const qe=S.apiKeySet?t("statusReady"):t("statusSetup");return e.jsxs("div",{className:fs,children:[e.jsx("div",{className:"border-b border-gray-100 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"truncate text-lg font-semibold text-gray-900",children:Fe}),e.jsxs("div",{className:"flex items-center gap-3",children:[H&&e.jsx("button",{type:"button",onClick:Re,disabled:u.isPending,className:"text-gray-400 hover:text-red-500 transition-colors",title:t("providerDelete"),children:e.jsx($e,{className:"h-4 w-4"})}),e.jsx(Ke,{status:S.apiKeySet?"ready":"setup",label:qe})]})]})}),e.jsxs("form",{onSubmit:_e,className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5",children:[H&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"providerDisplayName",className:"text-sm font-medium text-gray-900",children:t("providerDisplayName")}),e.jsx(R,{id:"providerDisplayName",type:"text",value:I,onChange:a=>_(a.target.value),placeholder:je||t("providerDisplayNamePlaceholder"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:t("providerDisplayNameHelpShort")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"apiKey",className:"text-sm font-medium text-gray-900",children:(W==null?void 0:W.label)??t("apiKey")}),e.jsx(vs,{id:"apiKey",value:D,isSet:S.apiKeySet,onChange:a=>Q(a.target.value),placeholder:(W==null?void 0:W.placeholder)??t("enterApiKey"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:t("leaveBlankToKeepUnchanged")})]}),(p==null?void 0:p.kind)==="device_code"&&e.jsxs("div",{className:"space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3",children:[e.jsx(O,{className:"text-sm font-medium text-gray-900",children:p.displayName||t("providerAuthSectionTitle")}),Ne?e.jsx("p",{className:"text-xs text-gray-600",children:Ne}):null,e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(k,{type:"button",variant:"outline",size:"sm",onClick:He,disabled:j.isPending||!!ne,children:j.isPending?t("providerAuthStarting"):ne?t("providerAuthAuthorizing"):t("providerAuthAuthorizeInBrowser")}),p.supportsCliImport?e.jsx(k,{type:"button",variant:"outline",size:"sm",onClick:We,disabled:E.isPending,children:E.isPending?t("providerAuthImporting"):t("providerAuthImportFromCli")}):null,ne?e.jsxs("span",{className:"text-xs text-gray-500",children:[t("providerAuthSessionLabel"),": ",ne.slice(0,8),"…"]}):null]}),ge?e.jsx("p",{className:"text-xs text-gray-600",children:ge}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"apiBase",className:"text-sm font-medium text-gray-900",children:(L==null?void 0:L.label)??t("apiBase")}),e.jsx(R,{id:"apiBase",type:"text",value:z,onChange:a=>M(a.target.value),placeholder:me||(L==null?void 0:L.placeholder)||"https://api.example.com",className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:ze})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(O,{className:"text-sm font-medium text-gray-900",children:t("providerModelsTitle")}),!ce&&e.jsxs("button",{type:"button",onClick:()=>re(!0),className:"text-xs text-primary hover:text-primary/80 font-medium flex items-center gap-1",children:[e.jsx(ye,{className:"h-3 w-3"}),t("providerAddModel")]})]}),ce&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{value:$,onChange:a=>C(a.target.value),onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),Pe()),a.key==="Escape"&&(re(!1),C(""))},placeholder:t("providerModelInputPlaceholder"),className:"flex-1 rounded-xl",autoFocus:!0}),e.jsx(k,{type:"button",size:"sm",onClick:Pe,disabled:$.trim().length===0,children:t("add")}),e.jsx(k,{type:"button",size:"sm",variant:"ghost",onClick:()=>{re(!1),C("")},children:e.jsx(Ie,{className:"h-4 w-4"})})]}),v.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center",children:[e.jsx("p",{className:"text-sm text-gray-500",children:t("providerModelsEmptyShort")}),!ce&&e.jsx("button",{type:"button",onClick:()=>re(!0),className:"mt-2 text-sm text-primary hover:text-primary/80 font-medium",children:t("providerAddFirstModel")})]}):e.jsx("div",{className:"flex flex-wrap gap-2",children:v.map(a=>e.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:[e.jsx("span",{className:"max-w-[180px] truncate text-sm text-gray-800 sm:max-w-[240px]",children:a}),e.jsx("button",{type:"button",onClick:()=>N(d=>d.filter(x=>x!==a)),className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 transition-opacity hover:bg-gray-100 hover:text-gray-600 opacity-100 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100","aria-label":t("remove"),children:e.jsx(Ie,{className:"h-3 w-3"})})]},a))})]}),e.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>ae(!V),className:"flex w-full items-center justify-between text-sm text-gray-600 hover:text-gray-900 transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Ve,{className:"h-3.5 w-3.5"}),t("providerAdvancedSettings")]}),e.jsx(Ye,{className:`h-4 w-4 transition-transform ${V?"rotate-180":""}`})]}),V&&e.jsxs("div",{className:"mt-4 space-y-5",children:[n.supportsWireApi&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"wireApi",className:"text-sm font-medium text-gray-900",children:(ue==null?void 0:ue.label)??t("wireApi")}),e.jsxs(ls,{value:o,onValueChange:a=>h(a),children:[e.jsx(os,{className:"rounded-xl",children:e.jsx(cs,{})}),e.jsx(ds,{children:(n.wireApiOptions||["auto","chat","responses"]).map(a=>e.jsx(us,{value:a,children:a==="chat"?t("wireApiChat"):a==="responses"?t("wireApiResponses"):t("wireApiAuto")},a))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{className:"text-sm font-medium text-gray-900",children:(de==null?void 0:de.label)??t("extraHeaders")}),e.jsx(ws,{value:K,onChange:U}),e.jsx("p",{className:"text-xs text-gray-500",children:t("providerExtraHeadersHelpShort")})]})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-100 px-6 py-4",children:[e.jsxs(k,{type:"button",variant:"outline",size:"sm",onClick:Oe,disabled:f.isPending,children:[e.jsx(Je,{className:"mr-1.5 h-4 w-4"}),f.isPending?t("providerTestingConnection"):t("providerTestConnection")]}),e.jsx(k,{type:"submit",disabled:g.isPending||!Ae,children:g.isPending?t("saving"):Ae?t("save"):t("unchanged")})]})]})]})}function Ds(s){if(!s)return null;try{const r=new URL(s),i=r.pathname&&r.pathname!=="/"?r.pathname:"";return`${r.host}${i}`}catch{return s.replace(/^https?:\/\//,"")}}function _s(){const{data:s}=Le(),{data:r}=Te(),{data:i}=Be(),l=ms(),[y,w]=c.useState("installed"),[g,u]=c.useState(),[f,j]=c.useState(""),b=i==null?void 0:i.uiHints,E=(r==null?void 0:r.providers)??[],D=(s==null?void 0:s.providers)??{},Q=E.filter(o=>{var h;return(h=D[o.name])==null?void 0:h.apiKeySet}).length,z=[{id:"installed",label:t("providersTabConfigured"),count:Q},{id:"all",label:t("providersTabAll"),count:E.length}],M=c.useMemo(()=>{const o=(r==null?void 0:r.providers)??[],h=(s==null?void 0:s.providers)??{},v=f.trim().toLowerCase();return o.filter(N=>{var $;return y==="installed"?!!(($=h[N.name])!=null&&$.apiKeySet):!0}).filter(N=>{var I,_;return v?(((_=(I=h[N.name])==null?void 0:I.displayName)==null?void 0:_.trim())||N.displayName||N.name).toLowerCase().includes(v)||N.name.toLowerCase().includes(v):!0})},[r,s,y,f]);c.useEffect(()=>{if(M.length===0){u(void 0);return}M.some(h=>h.name===g)||u(M[0].name)},[M,g]);const K=g,U=async()=>{try{const o=await l.mutateAsync({data:{}});w("all"),j(""),u(o.name)}catch{}};return!s||!r?e.jsx("div",{className:"p-8",children:t("providersLoading")}):e.jsxs(xs,{children:[e.jsx(hs,{title:t("providersPageTitle"),description:t("providersPageDescription")}),e.jsxs("div",{className:ys,children:[e.jsxs("section",{className:gs,children:[e.jsxs("div",{className:"border-b border-gray-100 px-4 pt-4 pb-3 space-y-3",children:[e.jsx(bs,{tabs:z,activeTab:y,onChange:w,className:"mb-0"}),e.jsxs(k,{type:"button",variant:"outline",className:"w-full justify-center",onClick:U,disabled:l.isPending,children:[e.jsx(ye,{className:"mr-2 h-4 w-4"}),l.isPending?t("saving"):t("providerAddCustom")]})]}),e.jsx("div",{className:"border-b border-gray-100 px-4 py-3",children:e.jsxs("div",{className:"relative",children:[e.jsx(Xe,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx(R,{value:f,onChange:o=>j(o.target.value),placeholder:t("providersFilterPlaceholder"),className:"h-10 rounded-xl pl-9"})]})}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto p-3",children:[M.map(o=>{var ae;const h=s.providers[o.name],v=!!(h!=null&&h.apiKeySet),N=K===o.name,$=((ae=h==null?void 0:h.displayName)==null?void 0:ae.trim())||o.displayName||o.name,C=ee(`providers.${o.name}`,b),I=(h==null?void 0:h.apiBase)||o.defaultApiBase||"",V=Ds(I)||(C==null?void 0:C.help)||t("providersDefaultDescription");return e.jsx("button",{type:"button",onClick:()=>u(o.name),className:te("w-full rounded-xl border p-2.5 text-left transition-all",N?"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:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(js,{name:o.name,src:o.logo?`/logos/${o.logo}`:null,className:te("h-10 w-10 rounded-lg border",v?"border-primary/30 bg-white":"border-gray-200/70 bg-white"),imgClassName:"h-5 w-5 object-contain",fallback:e.jsx("span",{className:"text-sm font-semibold uppercase text-gray-500",children:o.name[0]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:$}),e.jsx("p",{className:"line-clamp-1 text-[11px] text-gray-500",children:V})]})]}),e.jsx(Ke,{status:v?"ready":"setup",label:v?t("statusReady"):t("statusSetup"),className:"min-w-[56px] justify-center"})]})},o.name)}),M.length===0&&e.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:[e.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-white",children:e.jsx(Ze,{className:"h-5 w-5 text-gray-300"})}),e.jsx("p",{className:"text-sm font-medium text-gray-700",children:t("providersNoMatch")})]})]})]}),e.jsx(Es,{providerName:K,onProviderDeleted:o=>{o===g&&u(void 0)}})]})]})}export{_s as ProvidersList};
|
|
1
|
+
import{r as c,j as e,aH as Ge,aI as Qe,aB as $e,a0 as ye,a as Ue,d as B,ax as Ie,aJ as Ve,C as Ye,aK as Je,a1 as Xe,K as Ze}from"./vendor-C--HHaLf.js";import{c as te,t,u as Le,a as Te,b as Be,z as es,A as ss,C as ts,E as as,F as rs,G as ns,H as is,S as ls,e as os,f as cs,g as ds,h as us,I as ms}from"./index-dKTqKCJo.js";import{B as k,P as xs,a as hs}from"./page-layout-DA6PFRtQ.js";import{I as R}from"./input-CaKJyoWZ.js";import{L as O}from"./label-BaXSWTKI.js";import{C as ps,a as fs,S as Ke,b as ys,c as gs,L as js}from"./LogoBadge-BlDT-g9R.js";import{h as ee}from"./config-hints-CApS3K_7.js";import{T as bs}from"./tabs-custom-0PybLkXs.js";function vs({maskedValue:s,isSet:r,className:i,value:l,onChange:y,placeholder:w,...g}){const[u,f]=c.useState(!1),[j,b]=c.useState(!1),E=typeof l=="string"&&l.length>0,D=r&&!E&&!j;return e.jsxs("div",{className:"relative",children:[D?e.jsx("div",{onClick:()=>b(!0),className:te("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",i),children:"••••••••••••"}):e.jsx(R,{type:u?"text":"password",className:te("pr-12",i),value:l,onChange:y,onBlur:()=>{E||b(!1)},placeholder:w,autoFocus:j,...g}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:(r||E)&&e.jsx(k,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>f(!u),children:u?e.jsx(Ge,{className:"h-4 w-4"}):e.jsx(Qe,{className:"h-4 w-4"})})})]})}function ws({value:s,onChange:r,className:i}){const l=s?Object.entries(s):[],y=(u,f,j)=>{const b=[...l];b[u]=[f,j],r(Object.fromEntries(b))},w=()=>{r({...s,"":""})},g=u=>{const f=l.filter((j,b)=>b!==u);r(Object.fromEntries(f))};return e.jsxs("div",{className:te("space-y-2",i),children:[l.map(([u,f],j)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(R,{type:"text",value:u,onChange:b=>y(j,b.target.value,f),placeholder:t("headerName"),className:"flex-1"}),e.jsx(R,{type:"text",value:f,onChange:b=>y(j,u,b.target.value),placeholder:t("headerValue"),className:"flex-1"}),e.jsx(k,{type:"button",variant:"ghost",size:"icon",onClick:()=>g(j),children:e.jsx($e,{className:"h-4 w-4 text-red-500"})})]},j)),e.jsxs(k,{type:"button",variant:"outline",size:"sm",onClick:w,children:[e.jsx(ye,{className:"h-4 w-4 mr-2"}),t("add")]})]})}const Ns={displayName:"",apiKeySet:!1,apiBase:null,extraHeaders:null,wireApi:null,models:[]};function se(s){if(!s)return null;const r=Object.entries(s).map(([i,l])=>[i.trim(),l]).filter(([i])=>i.length>0);return r.length===0?null:Object.fromEntries(r)}function ke(s,r){const i=se(s),l=se(r);if(i===null&&l===null)return!0;if(!i||!l)return!1;const y=Object.entries(i).sort(([g],[u])=>g.localeCompare(u)),w=Object.entries(l).sort(([g],[u])=>g.localeCompare(u));return y.length!==w.length?!1:y.every(([g,u],f)=>g===w[f][0]&&u===w[f][1])}function pe(s){if(!s||s.length===0)return[];const r=new Set;for(const i of s){const l=i.trim();l&&r.add(l)}return[...r]}function Cs(s,r){const i=s.trim();if(!i||!r.trim())return i;const l=`${r.trim()}/`;return i.startsWith(l)?i.slice(l.length):i}function oe(s,r){let i=s.trim();if(!i)return"";for(const l of r){const y=l.trim();y&&(i=Cs(i,y))}return i.trim()}function fe(s,r){return s.length!==r.length?!1:s.every((i,l)=>i===r[l])}function As(s,r){const i=[...s];for(const l of r)i.includes(l)||i.push(l);return i}function Ps(s,r){return r.length===0?s:r.every(l=>!s.includes(l))?As(s,r):r}function Ss(s,r){return fe(s,r)?[]:s}function Es({providerName:s,onProviderDeleted:r}){var Se,Ee,De,Me;const i=Ue(),{data:l}=Le(),{data:y}=Te(),{data:w}=Be(),g=es(),u=ss(),f=ts(),j=as(),b=rs(),E=ns(),[D,Q]=c.useState(""),[z,M]=c.useState(""),[K,U]=c.useState(null),[o,h]=c.useState("auto"),[v,N]=c.useState([]),[$,C]=c.useState(""),[I,_]=c.useState(""),[V,ae]=c.useState(!1),[ce,re]=c.useState(!1),[ne,F]=c.useState(null),[ge,P]=c.useState(""),ie=c.useRef(null),n=y==null?void 0:y.providers.find(a=>a.name===s),S=(s?l==null?void 0:l.providers[s]:null)??Ns,le=w==null?void 0:w.uiHints,H=!!(n!=null&&n.isCustom),W=s?ee(`providers.${s}.apiKey`,le):void 0,L=s?ee(`providers.${s}.apiBase`,le):void 0,de=s?ee(`providers.${s}.extraHeaders`,le):void 0,ue=s?ee(`providers.${s}.wireApi`,le):void 0,je=(n==null?void 0:n.displayName)||s||"",q=(S.displayName||"").trim()||je,Fe=I.trim()||q||s||t("providersSelectPlaceholder"),be=(n==null?void 0:n.modelPrefix)||s||"",G=c.useMemo(()=>pe([be,s||""]),[be,s]),me=(n==null?void 0:n.defaultApiBase)||"",Y=S.apiBase||me,xe=se(S.extraHeaders||null),J=S.wireApi||(n==null?void 0:n.defaultWireApi)||"auto",he=c.useMemo(()=>pe(((n==null?void 0:n.defaultModels)??[]).map(a=>oe(a,G))),[n==null?void 0:n.defaultModels,G]),ve=c.useMemo(()=>pe((S.models??[]).map(a=>oe(a,G))),[S.models,G]),X=c.useMemo(()=>Ps(he,ve),[he,ve]),we=is(),ze=((Se=n==null?void 0:n.apiBaseHelp)==null?void 0:Se[we])||((Ee=n==null?void 0:n.apiBaseHelp)==null?void 0:Ee.en)||(L==null?void 0:L.help)||t("providerApiBaseHelp"),p=n==null?void 0:n.auth,Ne=((De=p==null?void 0:p.note)==null?void 0:De[we])||((Me=p==null?void 0:p.note)==null?void 0:Me.en)||(p==null?void 0:p.displayName)||"",A=c.useCallback(()=>{ie.current!==null&&(window.clearTimeout(ie.current),ie.current=null)},[]),Ce=c.useCallback((a,d)=>{A(),ie.current=window.setTimeout(()=>{(async()=>{if(s)try{const x=await b.mutateAsync({provider:s,data:{sessionId:a}});if(x.status==="pending"){P(t("providerAuthWaitingBrowser")),Ce(a,x.nextPollMs??d);return}if(x.status==="authorized"){F(null),A(),P(t("providerAuthCompleted")),B.success(t("providerAuthCompleted")),i.invalidateQueries({queryKey:["config"]}),i.invalidateQueries({queryKey:["config-meta"]});return}F(null),A(),P(x.message||`Authorization ${x.status}.`),B.error(x.message||`Authorization ${x.status}.`)}catch(x){F(null),A();const m=x instanceof Error?x.message:String(x);P(m),B.error(`Authorization failed: ${m}`)}})()},Math.max(1e3,d))},[A,b,s,i]);c.useEffect(()=>{if(!s){Q(""),M(""),U(null),h("auto"),N([]),C(""),_(""),F(null),P(""),A();return}Q(""),M(Y),U(S.extraHeaders||null),h(J),N(X),C(""),_(q),F(null),P(""),A()},[s,Y,S.extraHeaders,J,X,q,A]),c.useEffect(()=>()=>A(),[A]);const Ae=c.useMemo(()=>{if(!s)return!1;const a=D.trim().length>0,d=z.trim()!==Y.trim(),x=!ke(K,xe),m=n!=null&&n.supportsWireApi?o!==J:!1,T=!fe(v,X),Z=H?I.trim()!==q:!1;return a||d||x||m||T||Z},[s,H,I,q,D,z,Y,K,xe,n==null?void 0:n.supportsWireApi,o,J,v,X]),Pe=()=>{const a=oe($,G);if(a){if(v.includes(a)){C("");return}N(d=>[...d,a]),C("")}},_e=a=>{if(a.preventDefault(),!s)return;const d={},x=D.trim(),m=z.trim(),T=se(K),Z=I.trim();H&&Z!==q&&(d.displayName=Z.length>0?Z:null),x.length>0&&(d.apiKey=x),m!==Y.trim()&&(d.apiBase=m.length>0&&m!==me?m:null),ke(T,xe)||(d.extraHeaders=T),n!=null&&n.supportsWireApi&&o!==J&&(d.wireApi=o),fe(v,X)||(d.models=Ss(v,he)),g.mutate({provider:s,data:d})},Oe=async()=>{if(!s)return;const a=v.find(m=>m.trim().length>0)??"",d=oe(a,G),x={apiBase:z.trim(),extraHeaders:se(K),model:d||null};D.trim().length>0&&(x.apiKey=D.trim()),n!=null&&n.supportsWireApi&&(x.wireApi=o);try{const m=await f.mutateAsync({provider:s,data:x});if(m.success){B.success(`${t("providerTestConnectionSuccess")} (${m.latencyMs}ms)`);return}const T=[`provider=${m.provider}`,`latency=${m.latencyMs}ms`];m.model&&T.push(`model=${m.model}`),B.error(`${t("providerTestConnectionFailed")}: ${m.message} | ${T.join(" | ")}`)}catch(m){const T=m instanceof Error?m.message:String(m);B.error(`${t("providerTestConnectionFailed")}: ${T}`)}},Re=async()=>{if(!(!s||!H||!window.confirm(t("providerDeleteConfirm"))))try{await u.mutateAsync({provider:s}),r==null||r(s)}catch{}},He=async()=>{if(!(!s||(p==null?void 0:p.kind)!=="device_code"))try{P("");const a=await j.mutateAsync({provider:s});if(!a.sessionId||!a.verificationUri)throw new Error(t("providerAuthStartFailed"));F(a.sessionId),P(`${t("providerAuthOpenPrompt")}${a.userCode}${t("providerAuthOpenPromptSuffix")}`),window.open(a.verificationUri,"_blank","noopener,noreferrer"),Ce(a.sessionId,a.intervalMs)}catch(a){const d=a instanceof Error?a.message:String(a);F(null),A(),P(d),B.error(`${t("providerAuthStartFailed")}: ${d}`)}},We=async()=>{if(!(!s||(p==null?void 0:p.kind)!=="device_code"))try{A(),F(null);const a=await E.mutateAsync({provider:s}),d=a.expiresAt?` (expires: ${a.expiresAt})`:"";P(`${t("providerAuthImportStatusPrefix")}${d}`),B.success(t("providerAuthImportSuccess")),i.invalidateQueries({queryKey:["config"]}),i.invalidateQueries({queryKey:["config-meta"]})}catch(a){const d=a instanceof Error?a.message:String(a);P(d),B.error(`${t("providerAuthImportFailed")}: ${d}`)}};if(!s||!n)return e.jsx("div",{className:ps,children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:t("providersSelectTitle")}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:t("providersSelectDescription")})]})});const qe=S.apiKeySet?t("statusReady"):t("statusSetup");return e.jsxs("div",{className:fs,children:[e.jsx("div",{className:"border-b border-gray-100 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"truncate text-lg font-semibold text-gray-900",children:Fe}),e.jsxs("div",{className:"flex items-center gap-3",children:[H&&e.jsx("button",{type:"button",onClick:Re,disabled:u.isPending,className:"text-gray-400 hover:text-red-500 transition-colors",title:t("providerDelete"),children:e.jsx($e,{className:"h-4 w-4"})}),e.jsx(Ke,{status:S.apiKeySet?"ready":"setup",label:qe})]})]})}),e.jsxs("form",{onSubmit:_e,className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5",children:[H&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"providerDisplayName",className:"text-sm font-medium text-gray-900",children:t("providerDisplayName")}),e.jsx(R,{id:"providerDisplayName",type:"text",value:I,onChange:a=>_(a.target.value),placeholder:je||t("providerDisplayNamePlaceholder"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:t("providerDisplayNameHelpShort")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"apiKey",className:"text-sm font-medium text-gray-900",children:(W==null?void 0:W.label)??t("apiKey")}),e.jsx(vs,{id:"apiKey",value:D,isSet:S.apiKeySet,onChange:a=>Q(a.target.value),placeholder:(W==null?void 0:W.placeholder)??t("enterApiKey"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:t("leaveBlankToKeepUnchanged")})]}),(p==null?void 0:p.kind)==="device_code"&&e.jsxs("div",{className:"space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3",children:[e.jsx(O,{className:"text-sm font-medium text-gray-900",children:p.displayName||t("providerAuthSectionTitle")}),Ne?e.jsx("p",{className:"text-xs text-gray-600",children:Ne}):null,e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(k,{type:"button",variant:"outline",size:"sm",onClick:He,disabled:j.isPending||!!ne,children:j.isPending?t("providerAuthStarting"):ne?t("providerAuthAuthorizing"):t("providerAuthAuthorizeInBrowser")}),p.supportsCliImport?e.jsx(k,{type:"button",variant:"outline",size:"sm",onClick:We,disabled:E.isPending,children:E.isPending?t("providerAuthImporting"):t("providerAuthImportFromCli")}):null,ne?e.jsxs("span",{className:"text-xs text-gray-500",children:[t("providerAuthSessionLabel"),": ",ne.slice(0,8),"…"]}):null]}),ge?e.jsx("p",{className:"text-xs text-gray-600",children:ge}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"apiBase",className:"text-sm font-medium text-gray-900",children:(L==null?void 0:L.label)??t("apiBase")}),e.jsx(R,{id:"apiBase",type:"text",value:z,onChange:a=>M(a.target.value),placeholder:me||(L==null?void 0:L.placeholder)||"https://api.example.com",className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:ze})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(O,{className:"text-sm font-medium text-gray-900",children:t("providerModelsTitle")}),!ce&&e.jsxs("button",{type:"button",onClick:()=>re(!0),className:"text-xs text-primary hover:text-primary/80 font-medium flex items-center gap-1",children:[e.jsx(ye,{className:"h-3 w-3"}),t("providerAddModel")]})]}),ce&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{value:$,onChange:a=>C(a.target.value),onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),Pe()),a.key==="Escape"&&(re(!1),C(""))},placeholder:t("providerModelInputPlaceholder"),className:"flex-1 rounded-xl",autoFocus:!0}),e.jsx(k,{type:"button",size:"sm",onClick:Pe,disabled:$.trim().length===0,children:t("add")}),e.jsx(k,{type:"button",size:"sm",variant:"ghost",onClick:()=>{re(!1),C("")},children:e.jsx(Ie,{className:"h-4 w-4"})})]}),v.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center",children:[e.jsx("p",{className:"text-sm text-gray-500",children:t("providerModelsEmptyShort")}),!ce&&e.jsx("button",{type:"button",onClick:()=>re(!0),className:"mt-2 text-sm text-primary hover:text-primary/80 font-medium",children:t("providerAddFirstModel")})]}):e.jsx("div",{className:"flex flex-wrap gap-2",children:v.map(a=>e.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:[e.jsx("span",{className:"max-w-[180px] truncate text-sm text-gray-800 sm:max-w-[240px]",children:a}),e.jsx("button",{type:"button",onClick:()=>N(d=>d.filter(x=>x!==a)),className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 transition-opacity hover:bg-gray-100 hover:text-gray-600 opacity-100 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100","aria-label":t("remove"),children:e.jsx(Ie,{className:"h-3 w-3"})})]},a))})]}),e.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>ae(!V),className:"flex w-full items-center justify-between text-sm text-gray-600 hover:text-gray-900 transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Ve,{className:"h-3.5 w-3.5"}),t("providerAdvancedSettings")]}),e.jsx(Ye,{className:`h-4 w-4 transition-transform ${V?"rotate-180":""}`})]}),V&&e.jsxs("div",{className:"mt-4 space-y-5",children:[n.supportsWireApi&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"wireApi",className:"text-sm font-medium text-gray-900",children:(ue==null?void 0:ue.label)??t("wireApi")}),e.jsxs(ls,{value:o,onValueChange:a=>h(a),children:[e.jsx(os,{className:"rounded-xl",children:e.jsx(cs,{})}),e.jsx(ds,{children:(n.wireApiOptions||["auto","chat","responses"]).map(a=>e.jsx(us,{value:a,children:a==="chat"?t("wireApiChat"):a==="responses"?t("wireApiResponses"):t("wireApiAuto")},a))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{className:"text-sm font-medium text-gray-900",children:(de==null?void 0:de.label)??t("extraHeaders")}),e.jsx(ws,{value:K,onChange:U}),e.jsx("p",{className:"text-xs text-gray-500",children:t("providerExtraHeadersHelpShort")})]})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-100 px-6 py-4",children:[e.jsxs(k,{type:"button",variant:"outline",size:"sm",onClick:Oe,disabled:f.isPending,children:[e.jsx(Je,{className:"mr-1.5 h-4 w-4"}),f.isPending?t("providerTestingConnection"):t("providerTestConnection")]}),e.jsx(k,{type:"submit",disabled:g.isPending||!Ae,children:g.isPending?t("saving"):Ae?t("save"):t("unchanged")})]})]})]})}function Ds(s){if(!s)return null;try{const r=new URL(s),i=r.pathname&&r.pathname!=="/"?r.pathname:"";return`${r.host}${i}`}catch{return s.replace(/^https?:\/\//,"")}}function _s(){const{data:s}=Le(),{data:r}=Te(),{data:i}=Be(),l=ms(),[y,w]=c.useState("installed"),[g,u]=c.useState(),[f,j]=c.useState(""),b=i==null?void 0:i.uiHints,E=(r==null?void 0:r.providers)??[],D=(s==null?void 0:s.providers)??{},Q=E.filter(o=>{var h;return(h=D[o.name])==null?void 0:h.apiKeySet}).length,z=[{id:"installed",label:t("providersTabConfigured"),count:Q},{id:"all",label:t("providersTabAll"),count:E.length}],M=c.useMemo(()=>{const o=(r==null?void 0:r.providers)??[],h=(s==null?void 0:s.providers)??{},v=f.trim().toLowerCase();return o.filter(N=>{var $;return y==="installed"?!!(($=h[N.name])!=null&&$.apiKeySet):!0}).filter(N=>{var I,_;return v?(((_=(I=h[N.name])==null?void 0:I.displayName)==null?void 0:_.trim())||N.displayName||N.name).toLowerCase().includes(v)||N.name.toLowerCase().includes(v):!0})},[r,s,y,f]);c.useEffect(()=>{if(M.length===0){u(void 0);return}M.some(h=>h.name===g)||u(M[0].name)},[M,g]);const K=g,U=async()=>{try{const o=await l.mutateAsync({data:{}});w("all"),j(""),u(o.name)}catch{}};return!s||!r?e.jsx("div",{className:"p-8",children:t("providersLoading")}):e.jsxs(xs,{children:[e.jsx(hs,{title:t("providersPageTitle"),description:t("providersPageDescription")}),e.jsxs("div",{className:ys,children:[e.jsxs("section",{className:gs,children:[e.jsxs("div",{className:"border-b border-gray-100 px-4 pt-4 pb-3 space-y-3",children:[e.jsx(bs,{tabs:z,activeTab:y,onChange:w,className:"mb-0"}),e.jsxs(k,{type:"button",variant:"outline",className:"w-full justify-center",onClick:U,disabled:l.isPending,children:[e.jsx(ye,{className:"mr-2 h-4 w-4"}),l.isPending?t("saving"):t("providerAddCustom")]})]}),e.jsx("div",{className:"border-b border-gray-100 px-4 py-3",children:e.jsxs("div",{className:"relative",children:[e.jsx(Xe,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx(R,{value:f,onChange:o=>j(o.target.value),placeholder:t("providersFilterPlaceholder"),className:"h-10 rounded-xl pl-9"})]})}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto p-3",children:[M.map(o=>{var ae;const h=s.providers[o.name],v=!!(h!=null&&h.apiKeySet),N=K===o.name,$=((ae=h==null?void 0:h.displayName)==null?void 0:ae.trim())||o.displayName||o.name,C=ee(`providers.${o.name}`,b),I=(h==null?void 0:h.apiBase)||o.defaultApiBase||"",V=Ds(I)||(C==null?void 0:C.help)||t("providersDefaultDescription");return e.jsx("button",{type:"button",onClick:()=>u(o.name),className:te("w-full rounded-xl border p-2.5 text-left transition-all",N?"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:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(js,{name:o.name,src:o.logo?`/logos/${o.logo}`:null,className:te("h-10 w-10 rounded-lg border",v?"border-primary/30 bg-white":"border-gray-200/70 bg-white"),imgClassName:"h-5 w-5 object-contain",fallback:e.jsx("span",{className:"text-sm font-semibold uppercase text-gray-500",children:o.name[0]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:$}),e.jsx("p",{className:"line-clamp-1 text-[11px] text-gray-500",children:V})]})]}),e.jsx(Ke,{status:v?"ready":"setup",label:v?t("statusReady"):t("statusSetup"),className:"min-w-[56px] justify-center"})]})},o.name)}),M.length===0&&e.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:[e.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-white",children:e.jsx(Ze,{className:"h-5 w-5 text-gray-300"})}),e.jsx("p",{className:"text-sm font-medium text-gray-700",children:t("providersNoMatch")})]})]})]}),e.jsx(Es,{providerName:K,onProviderDeleted:o=>{o===g&&u(void 0)}})]})]})}export{_s as ProvidersList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as p,j as e,aB as ee,a0 as ae,aO as de,d as se}from"./vendor-
|
|
1
|
+
import{r as p,j as e,aB as ee,a0 as ae,aO as de,d as se}from"./vendor-C--HHaLf.js";import{u as me,b as he,M as ue,t,S as te,e as re,f as ne,g as le,h as S}from"./index-dKTqKCJo.js";import{P as pe,a as xe,B as w}from"./page-layout-DA6PFRtQ.js";import{C as R,b as $,c as z,d as D,a as L}from"./card-Bf4CtrW8.js";import{I as i}from"./input-CaKJyoWZ.js";import{S as ge}from"./switch-Cvd5wZs-.js";import{h as x}from"./config-hints-CApS3K_7.js";const je=[{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 fe(){return{id:"",default:!1,workspace:"",model:"",engine:"",contextTokens:void 0,maxToolIterations:void 0}}function ve(){return{agentId:"",match:{channel:"",accountId:""}}}function ce(d){const b=d.trim();if(!b)return;const j=Number.parseInt(b,10);return Number.isFinite(j)?j:void 0}function Se(){const{data:d,isLoading:b}=me(),{data:j}=he(),A=ue(),[_,N]=p.useState([]),[q,E]=p.useState([]),[K,F]=p.useState("per-channel-peer"),[V,U]=p.useState(0),[G,J]=p.useState(2e5),[Q,W]=p.useState("native");p.useEffect(()=>{var a,r,n;d&&(N((d.agents.list??[]).map(s=>({id:s.id??"",default:!!s.default,workspace:s.workspace??"",model:s.model??"",engine:s.engine??"",contextTokens:s.contextTokens,maxToolIterations:s.maxToolIterations}))),E((d.bindings??[]).map(s=>{var c,l,o;return{agentId:s.agentId??"",match:{channel:((c=s.match)==null?void 0:c.channel)??"",accountId:((l=s.match)==null?void 0:l.accountId)??"",peer:(o=s.match)!=null&&o.peer?{kind:s.match.peer.kind,id:s.match.peer.id}:void 0}}})),F(((a=d.session)==null?void 0:a.dmScope)??"per-channel-peer"),U(((n=(r=d.session)==null?void 0:r.agentToAgent)==null?void 0:n.maxPingPongTurns)??0),J(d.agents.defaults.contextTokens??2e5),W(d.agents.defaults.engine??"native"))},[d]);const u=j==null?void 0:j.uiHints,h=x("session.dmScope",u),f=x("session.agentToAgent.maxPingPongTurns",u),v=x("agents.defaults.contextTokens",u),I=x("agents.defaults.engine",u),O=x("agents.list.*.contextTokens",u),B=x("agents.list.*.engine",u),y=x("agents.list",u),k=x("bindings",u),oe=p.useMemo(()=>{const a=new Set(["main"]);return _.forEach(r=>{const n=r.id.trim();n&&a.add(n)}),a},[_]),g=(a,r)=>{N(n=>n.map((s,c)=>c===a?{...s,...r}:s))},T=(a,r)=>{E(n=>n.map((s,c)=>c===a?r:s))},ie=()=>{try{const a=_.map((s,c)=>{var m,C,P;const l=s.id.trim();if(!l)throw new Error(t("agentIdRequiredError").replace("{index}",String(c)));const o={id:l};return s.default&&(o.default=!0),(m=s.workspace)!=null&&m.trim()&&(o.workspace=s.workspace.trim()),(C=s.model)!=null&&C.trim()&&(o.model=s.model.trim()),(P=s.engine)!=null&&P.trim()&&(o.engine=s.engine.trim()),typeof s.contextTokens=="number"&&(o.contextTokens=Math.max(1e3,s.contextTokens)),typeof s.maxToolIterations=="number"&&(o.maxToolIterations=s.maxToolIterations),o}),r=a.map(s=>s.id).filter((s,c,l)=>l.indexOf(s)!==c);if(r.length>0){se.error(`${t("duplicateAgentId")}: ${r[0]}`);return}const n=q.map((s,c)=>{var X,Y,Z,H;const l=s.agentId.trim(),o=s.match.channel.trim(),m=((X=s.match.accountId)==null?void 0:X.trim())??"",C=(Y=s.match.peer)==null?void 0:Y.kind,P=((H=(Z=s.match.peer)==null?void 0:Z.id)==null?void 0:H.trim())??"";if(!l)throw new Error(t("bindingAgentIdRequired").replace("{index}",String(c)));if(!oe.has(l))throw new Error(`${t("bindingAgentIdNotFound").replace("{index}",String(c))}: ${l}`);if(!o)throw new Error(t("bindingChannelRequired").replace("{index}",String(c)));const M={agentId:l,match:{channel:o}};if(m&&(M.match.accountId=m),C){if(!P)throw new Error(t("bindingPeerIdRequired").replace("{index}",String(c)));M.match.peer={kind:C,id:P}}return M});A.mutate({data:{agents:{defaults:{contextTokens:Math.max(1e3,G),engine:Q.trim()||"native"},list:a},bindings:n,session:{dmScope:K,agentToAgent:{maxPingPongTurns:Math.min(5,Math.max(0,V))}}}})}catch(a){const r=a instanceof Error?a.message:String(a);se.error(r)}};return b||!d?e.jsx("div",{className:"p-8 text-gray-400",children:t("runtimeLoading")}):e.jsxs(pe,{className:"space-y-6",children:[e.jsx(xe,{title:t("runtimePageTitle"),description:t("runtimePageDescription")}),e.jsxs(R,{children:[e.jsxs($,{children:[e.jsx(z,{children:(h==null?void 0:h.label)??t("dmScope")}),e.jsx(D,{children:(h==null?void 0:h.help)??t("dmScopeHelp")})]}),e.jsxs(L,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(v==null?void 0:v.label)??t("defaultContextTokens")}),e.jsx(i,{type:"number",min:1e3,step:1e3,value:G,onChange:a=>J(Math.max(1e3,Number.parseInt(a.target.value,10)||1e3))}),e.jsx("p",{className:"text-xs text-gray-500",children:(v==null?void 0:v.help)??t("defaultContextTokensHelp")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(I==null?void 0:I.label)??t("defaultEngine")}),e.jsx(i,{value:Q,onChange:a=>W(a.target.value),placeholder:t("defaultEnginePlaceholder")}),e.jsx("p",{className:"text-xs text-gray-500",children:(I==null?void 0:I.help)??t("defaultEngineHelp")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(h==null?void 0:h.label)??t("dmScope")}),e.jsxs(te,{value:K,onValueChange:a=>F(a),children:[e.jsx(re,{children:e.jsx(ne,{})}),e.jsx(le,{children:je.map(a=>e.jsx(S,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(f==null?void 0:f.label)??t("maxPingPongTurns")}),e.jsx(i,{type:"number",min:0,max:5,value:V,onChange:a=>U(Math.max(0,Number.parseInt(a.target.value,10)||0))}),e.jsx("p",{className:"text-xs text-gray-500",children:(f==null?void 0:f.help)??t("maxPingPongTurnsHelp")})]})]})]}),e.jsxs(R,{children:[e.jsxs($,{children:[e.jsx(z,{children:(y==null?void 0:y.label)??t("agentList")}),e.jsx(D,{children:(y==null?void 0:y.help)??t("agentListHelp")})]}),e.jsxs(L,{className:"space-y-3",children:[_.map((a,r)=>e.jsxs("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(i,{value:a.id,onChange:n=>g(r,{id:n.target.value}),placeholder:t("agentIdPlaceholder")}),e.jsx(i,{value:a.workspace??"",onChange:n=>g(r,{workspace:n.target.value}),placeholder:t("workspaceOverridePlaceholder")}),e.jsx(i,{value:a.model??"",onChange:n=>g(r,{model:n.target.value}),placeholder:t("modelOverridePlaceholder")}),e.jsx(i,{value:a.engine??"",onChange:n=>g(r,{engine:n.target.value}),placeholder:(B==null?void 0:B.label)??t("engineOverridePlaceholder")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsx(i,{type:"number",min:1e3,step:1e3,value:a.contextTokens??"",onChange:n=>g(r,{contextTokens:ce(n.target.value)}),placeholder:(O==null?void 0:O.label)??t("contextTokensPlaceholder")}),e.jsx(i,{type:"number",min:1,value:a.maxToolIterations??"",onChange:n=>g(r,{maxToolIterations:ce(n.target.value)}),placeholder:t("maxToolsPlaceholder")})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[e.jsx(ge,{checked:!!a.default,onCheckedChange:n=>{if(!n){g(r,{default:!1});return}N(s=>s.map((c,l)=>({...c,default:l===r})))}}),e.jsx("span",{children:t("defaultAgent")})]}),e.jsxs(w,{type:"button",variant:"outline",size:"sm",onClick:()=>N(n=>n.filter((s,c)=>c!==r)),children:[e.jsx(ee,{className:"h-4 w-4 mr-1"}),t("remove")]})]})]},`${r}-${a.id}`)),e.jsxs(w,{type:"button",variant:"outline",onClick:()=>N(a=>[...a,fe()]),children:[e.jsx(ae,{className:"h-4 w-4 mr-2"}),t("addAgent")]})]})]}),e.jsxs(R,{children:[e.jsxs($,{children:[e.jsx(z,{children:(k==null?void 0:k.label)??t("bindings")}),e.jsx(D,{children:(k==null?void 0:k.help)??t("bindingsHelp")})]}),e.jsxs(L,{className:"space-y-3",children:[q.map((a,r)=>{var s,c;const n=((s=a.match.peer)==null?void 0:s.kind)??"";return e.jsxs("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[e.jsx(i,{value:a.agentId,onChange:l=>T(r,{...a,agentId:l.target.value}),placeholder:t("targetAgentIdPlaceholder")}),e.jsx(i,{value:a.match.channel,onChange:l=>T(r,{...a,match:{...a.match,channel:l.target.value}}),placeholder:t("channelPlaceholder")}),e.jsx(i,{value:a.match.accountId??"",onChange:l=>T(r,{...a,match:{...a.match,accountId:l.target.value}}),placeholder:t("accountIdOptionalPlaceholder")}),e.jsxs(te,{value:n||"__none__",onValueChange:l=>{var m;const o=l==="__none__"?"":l;if(!o){T(r,{...a,match:{...a.match,peer:void 0}});return}T(r,{...a,match:{...a.match,peer:{kind:o,id:((m=a.match.peer)==null?void 0:m.id)??""}}})},children:[e.jsx(re,{children:e.jsx(ne,{})}),e.jsxs(le,{children:[e.jsx(S,{value:"__none__",children:t("peerKindOptional")}),e.jsx(S,{value:"direct",children:"direct"}),e.jsx(S,{value:"group",children:"group"}),e.jsx(S,{value:"channel",children:"channel"})]})]}),e.jsx(i,{value:((c=a.match.peer)==null?void 0:c.id)??"",onChange:l=>T(r,{...a,match:{...a.match,peer:n?{kind:n,id:l.target.value}:void 0}}),placeholder:t("peerIdPlaceholder")})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(w,{type:"button",variant:"outline",size:"sm",onClick:()=>E(l=>l.filter((o,m)=>m!==r)),children:[e.jsx(ee,{className:"h-4 w-4 mr-1"}),t("remove")]})})]},`${r}-${a.agentId}`)}),e.jsxs(w,{type:"button",variant:"outline",onClick:()=>E(a=>[...a,ve()]),children:[e.jsx(ae,{className:"h-4 w-4 mr-2"}),t("addBinding")]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(w,{type:"button",onClick:ie,disabled:A.isPending,children:[e.jsx(de,{className:"h-4 w-4 mr-2"}),A.isPending?t("saving"):t("saveRuntimeSettings")]})})]})}export{Se as RuntimeConfig};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as u,j as e,aB as H,a0 as L,aO as G,d as J}from"./vendor-
|
|
1
|
+
import{r as u,j as e,aB as H,a0 as L,aO as G,d as J}from"./vendor-C--HHaLf.js";import{u as K,P as Q,t as a,S as x,e as m,f as p,g as j,h as o}from"./index-dKTqKCJo.js";import{P as W,a as X,B as _}from"./page-layout-DA6PFRtQ.js";import{C as R,b as T,c as M,d as O,a as A}from"./card-Bf4CtrW8.js";import{I as h}from"./input-CaKJyoWZ.js";import{L as k}from"./label-BaXSWTKI.js";import{S as Y}from"./switch-Cvd5wZs-.js";const U=["env","file","exec"];function b(n=""){return{alias:n,source:"env",prefix:"",path:"",command:"",argsText:"",cwd:"",timeoutMs:5e3}}function Z(){return{path:"",source:"env",provider:"",id:""}}function ee(n,l){return l.source==="env"?{...b(n),source:"env",prefix:l.prefix??""}:l.source==="file"?{...b(n),source:"file",path:l.path}:{...b(n),source:"exec",command:l.command,argsText:(l.args??[]).join(`
|
|
2
2
|
`),cwd:l.cwd??"",timeoutMs:l.timeoutMs??5e3}}function se(n){return n.source==="env"?{source:"env",...n.prefix.trim()?{prefix:n.prefix.trim()}:{}}:n.source==="file"?{source:"file",path:n.path.trim(),format:"json"}:{source:"exec",command:n.command.trim(),args:n.argsText.split(`
|
|
3
3
|
`).map(l=>l.trim()).filter(Boolean),...n.cwd.trim()?{cwd:n.cwd.trim()}:{},timeoutMs:Math.max(1,Math.trunc(n.timeoutMs||5e3))}}function oe(){const{data:n,isLoading:l}=K(),N=Q(),[D,y]=u.useState(!0),[I,E]=u.useState(""),[V,S]=u.useState(""),[B,$]=u.useState(""),[C,f]=u.useState([]),[F,v]=u.useState([]);u.useEffect(()=>{const s=n==null?void 0:n.secrets;if(!s){y(!0),E(""),S(""),$(""),f([]),v([]);return}y(!!s.enabled),E(s.defaults.env??""),S(s.defaults.file??""),$(s.defaults.exec??"");const t=Object.entries(s.providers).map(([c,i])=>ee(c,i)),r=Object.entries(s.refs).map(([c,i])=>({path:c,source:i.source,provider:i.provider??"",id:i.id}));f(t),v(r)},[n==null?void 0:n.secrets]);const w=u.useMemo(()=>{const s=C.map(t=>t.alias.trim()).filter(Boolean);return Array.from(new Set(s))},[C]),d=(s,t)=>{f(r=>r.map((c,i)=>i===s?{...c,...t}:c))},P=(s,t)=>{v(r=>r.map((c,i)=>i===s?{...c,...t}:c))},z=()=>{try{const s={};for(const[r,c]of C.entries()){const i=c.alias.trim();if(!i)throw new Error(`${a("providerAlias")} #${r+1} ${a("isRequired")}`);if(s[i])throw new Error(`${a("providerAlias")}: ${i} (${a("duplicate")})`);if(c.source==="file"&&!c.path.trim())throw new Error(`${a("secretFilePath")} #${r+1} ${a("isRequired")}`);if(c.source==="exec"&&!c.command.trim())throw new Error(`${a("secretExecCommand")} #${r+1} ${a("isRequired")}`);s[i]=se(c)}const t={};for(const[r,c]of F.entries()){const i=c.path.trim(),q=c.id.trim();if(!i)throw new Error(`${a("secretConfigPath")} #${r+1} ${a("isRequired")}`);if(!q)throw new Error(`${a("secretId")} #${r+1} ${a("isRequired")}`);const g=c.provider.trim();if(g&&!s[g])throw new Error(`${a("secretProviderAlias")}: ${g} ${a("notFound")}`);t[i]={source:c.source,...g?{provider:g}:{},id:q}}N.mutate({data:{enabled:D,defaults:{env:I.trim()||null,file:V.trim()||null,exec:B.trim()||null},providers:s,refs:t}})}catch(s){const t=s instanceof Error?s.message:String(s);J.error(t)}};return l?e.jsx("div",{className:"p-8 text-gray-400",children:a("loading")}):e.jsxs(W,{className:"space-y-6",children:[e.jsx(X,{title:a("secretsPageTitle"),description:a("secretsPageDescription")}),e.jsxs(R,{children:[e.jsxs(T,{children:[e.jsx(M,{children:a("secrets")}),e.jsx(O,{children:a("secretsEnabledHelp")})]}),e.jsxs(A,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-gray-200 p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-800",children:a("enabled")}),e.jsx("p",{className:"text-xs text-gray-500",children:a("secretsEnabledHelp")})]}),e.jsx(Y,{checked:D,onCheckedChange:y})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:a("defaultEnvProvider")}),e.jsxs(x,{value:I||"__none__",onValueChange:s=>E(s==="__none__"?"":s),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("noneOption")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:a("defaultFileProvider")}),e.jsxs(x,{value:V||"__none__",onValueChange:s=>S(s==="__none__"?"":s),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("noneOption")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:a("defaultExecProvider")}),e.jsxs(x,{value:B||"__none__",onValueChange:s=>$(s==="__none__"?"":s),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("noneOption")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]})]})]})]}),e.jsxs(R,{children:[e.jsxs(T,{children:[e.jsx(M,{children:a("secretProvidersTitle")}),e.jsx(O,{children:a("secretProvidersDescription")})]}),e.jsxs(A,{className:"space-y-3",children:[C.map((s,t)=>e.jsxs("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsx(h,{value:s.alias,onChange:r=>d(t,{alias:r.target.value}),placeholder:a("providerAlias")}),e.jsxs(x,{value:s.source,onValueChange:r=>d(t,{source:r}),children:[e.jsx(m,{children:e.jsx(p,{})}),e.jsx(j,{children:U.map(r=>e.jsx(o,{value:r,children:r},r))})]}),e.jsxs(_,{type:"button",variant:"outline",onClick:()=>f(r=>r.filter((c,i)=>i!==t)),children:[e.jsx(H,{className:"h-4 w-4 mr-2"}),a("removeProvider")]})]}),s.source==="env"&&e.jsx(h,{value:s.prefix,onChange:r=>d(t,{prefix:r.target.value}),placeholder:a("envPrefix")}),s.source==="file"&&e.jsx(h,{value:s.path,onChange:r=>d(t,{path:r.target.value}),placeholder:a("secretFilePath")}),s.source==="exec"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{value:s.command,onChange:r=>d(t,{command:r.target.value}),placeholder:a("secretExecCommand")}),e.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:s.argsText,onChange:r=>d(t,{argsText:r.target.value}),placeholder:a("secretExecArgs")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsx(h,{value:s.cwd,onChange:r=>d(t,{cwd:r.target.value}),placeholder:a("secretExecCwd")}),e.jsx(h,{type:"number",min:1,value:s.timeoutMs,onChange:r=>d(t,{timeoutMs:Number.parseInt(r.target.value,10)||5e3}),placeholder:a("secretExecTimeoutMs")})]})]})]},`provider-${t}`)),e.jsxs(_,{type:"button",variant:"outline",onClick:()=>f(s=>[...s,b()]),children:[e.jsx(L,{className:"h-4 w-4 mr-2"}),a("addSecretProvider")]})]})]}),e.jsxs(R,{children:[e.jsxs(T,{children:[e.jsx(M,{children:a("secretRefsTitle")}),e.jsx(O,{children:a("secretRefsDescription")})]}),e.jsxs(A,{className:"space-y-3",children:[F.map((s,t)=>e.jsx("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(h,{value:s.path,onChange:r=>P(t,{path:r.target.value}),placeholder:a("secretConfigPath")}),e.jsx(h,{value:s.id,onChange:r=>P(t,{id:r.target.value}),placeholder:a("secretId")}),e.jsxs(x,{value:s.source,onValueChange:r=>P(t,{source:r}),children:[e.jsx(m,{children:e.jsx(p,{})}),e.jsx(j,{children:U.map(r=>e.jsx(o,{value:r,children:r},r))})]}),e.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-2",children:[e.jsxs(x,{value:s.provider||"__none__",onValueChange:r=>P(t,{provider:r==="__none__"?"":r}),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("secretProviderAlias")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(r=>e.jsx(o,{value:r,children:r},r))]})]}),e.jsx(_,{type:"button",variant:"outline",onClick:()=>v(r=>r.filter((c,i)=>i!==t)),children:e.jsx(H,{className:"h-4 w-4"})})]})]})},`ref-${t}`)),e.jsxs(_,{type:"button",variant:"outline",onClick:()=>v(s=>[...s,Z()]),children:[e.jsx(L,{className:"h-4 w-4 mr-2"}),a("addSecretRef")]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(_,{type:"button",onClick:z,disabled:N.isPending,children:[e.jsx(G,{className:"h-4 w-4 mr-2"}),N.isPending?a("saving"):a("save")]})})]})}export{oe as SecretsConfig};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r,j as e,aC as I,a1 as J,aP as T,aM as X,w as Z,M as U,aQ as ee,a4 as se,a5 as te}from"./vendor-
|
|
1
|
+
import{r,j as e,aC as I,a1 as J,aP as T,aM as X,w as Z,M as U,aQ as ee,a4 as se,a5 as te}from"./vendor-C--HHaLf.js";import{u as ae}from"./useConfirmDialog-DdtpSju1.js";import{r as re,y as ne,w as le,N as ie,x as oe,t,c as i,S as de,e as ce,f as xe,g as me,h as Q,O as ue,k as he}from"./index-dKTqKCJo.js";import{P as ge,a as fe,B as f}from"./page-layout-DA6PFRtQ.js";import{I as k}from"./input-CaKJyoWZ.js";import{d as ye,f as pe,S as be,e as je}from"./session-run-status-CllIZxNf.js";const y="__unknown_channel__";function ve(a){return he(a)}function j(a){const l=a.indexOf(":");return l<=0?y:a.slice(0,l).trim()||y}function C(a){return a===y?t("sessionsUnknownChannel"):a}function Ne({session:a,channel:l,runStatus:d,isSelected:x,onSelect:n}){const p=C(l),m=a.label||a.key.split(":").pop()||a.key;return e.jsxs("button",{onClick:n,className:i("w-full text-left p-3.5 rounded-xl transition-all duration-200 outline-none focus:outline-none focus:ring-0 group",x?"bg-brand-50 border border-brand-100/50":"bg-transparent border border-transparent hover:bg-gray-50/80"),children:[e.jsxs("div",{className:"flex items-start justify-between mb-1.5",children:[e.jsx("div",{className:i("font-semibold truncate pr-2 flex-1 text-sm",x?"text-brand-800":"text-gray-900"),children:m}),e.jsx("div",{className:i("text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 capitalize",x?"bg-white text-brand-600 shadow-[0_1px_2px_rgba(0,0,0,0.02)]":"bg-gray-100 text-gray-500"),children:p})]}),e.jsxs("div",{className:i("flex items-center text-xs justify-between mt-2 font-medium",x?"text-brand-600/80":"text-gray-400"),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:d?e.jsx(be,{status:d}):null}),e.jsx(ee,{className:"w-3.5 h-3.5 opacity-70"}),e.jsx("span",{className:"truncate max-w-[100px]",children:ue(a.updatedAt)})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(U,{className:"w-3.5 h-3.5 opacity-70"}),e.jsx("span",{children:a.messageCount})]})]})]})}function we({message:a}){const l=a.role.toLowerCase()==="user",d=je(a.content).trim();return e.jsx("div",{className:i("flex w-full mb-6",l?"justify-end":"justify-start"),children:e.jsxs("div",{className:i("max-w-[85%] rounded-[1.25rem] p-5 flex gap-3 text-sm",l?"bg-primary text-white rounded-tr-sm":"bg-gray-50 text-gray-800 rounded-tl-sm border border-gray-100/50"),children:[e.jsx("div",{className:"shrink-0 pt-0.5",children:l?e.jsx(se,{className:"w-4 h-4 text-primary-100"}):e.jsx(te,{className:"w-4 h-4 text-gray-400"})}),e.jsxs("div",{className:"flex-1 space-y-1 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4 mb-2",children:[e.jsx("span",{className:i("font-semibold text-xs",l?"text-primary-50":"text-gray-900 capitalize"),children:a.role}),e.jsx("span",{className:i("text-[10px]",l?"text-primary-200":"text-gray-400"),children:ve(a.timestamp)})]}),e.jsx("div",{className:"whitespace-pre-wrap break-words leading-relaxed text-[15px]",children:d||"-"})]})]})})}function _e(){var B,E,K,R;const[a,l]=r.useState(""),[d]=r.useState(100),[x]=r.useState(0),[n,p]=r.useState(null),[m,q]=r.useState("all"),[M,v]=r.useState(""),[L,N]=r.useState(""),[w,S]=r.useState(!1),F=r.useMemo(()=>({q:a.trim()||void 0,limit:d,activeMinutes:x}),[a,d,x]),g=re(F),D=ne({states:["queued","running"],limit:200}),u=le(n,200),b=ie(),_=oe(),{confirm:P,ConfirmDialog:O}=ae(),c=r.useMemo(()=>{var s;return((s=g.data)==null?void 0:s.sessions)??[]},[(B=g.data)==null?void 0:B.sessions]),z=r.useMemo(()=>{var s;return ye(((s=D.data)==null?void 0:s.runs)??[])},[(E=D.data)==null?void 0:E.runs]),V=r.useMemo(()=>pe(z),[z]),o=r.useMemo(()=>c.find(s=>s.key===n),[c,n]),$=r.useMemo(()=>{const s=new Set;for(const h of c)s.add(j(h.key));return Array.from(s).sort((h,A)=>h===y?1:A===y?-1:h.localeCompare(A))},[c]),H=r.useMemo(()=>m==="all"?c:c.filter(s=>j(s.key)===m),[c,m]);r.useEffect(()=>{o?(v(o.label||""),N(o.preferredModel||"")):(v(""),N("")),S(!1)},[o]);const W=()=>{n&&(b.mutate({key:n,data:{label:M.trim()||null,preferredModel:L.trim()||null}}),S(!1))},Y=async()=>{if(!n)return;await P({title:t("sessionsClearHistory")+"?",variant:"destructive",confirmLabel:t("sessionsClearHistory")})&&b.mutate({key:n,data:{clearHistory:!0}})},G=async()=>{if(!n)return;await P({title:t("sessionsDeleteConfirm")+"?",variant:"destructive",confirmLabel:t("sessionsDeleteConfirm")})&&_.mutate({key:n},{onSuccess:()=>p(null)})};return e.jsxs(ge,{fullHeight:!0,children:[e.jsx(fe,{title:t("sessionsPageTitle"),description:t("sessionsPageDescription")}),e.jsxs("div",{className:"flex-1 flex gap-6 min-h-0 relative",children:[e.jsxs("div",{className:"w-[320px] flex flex-col shrink-0 bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-4 border-b border-gray-100 bg-white z-10 shrink-0 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:[c.length," ",t("sessionsListTitle")]}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100",onClick:()=>g.refetch(),children:e.jsx(I,{className:i("h-3.5 w-3.5",g.isFetching&&"animate-spin")})})]}),e.jsxs(de,{value:m,onValueChange:q,children:[e.jsx(ce,{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:e.jsx(xe,{placeholder:t("sessionsAllChannels")})}),e.jsxs(me,{className:"rounded-xl shadow-lg border-gray-100 max-w-[280px]",children:[e.jsx(Q,{value:"all",className:"rounded-lg text-xs",children:t("sessionsAllChannels")}),$.map(s=>e.jsx(Q,{value:s,className:"rounded-lg text-xs truncate pr-6",children:C(s)},s))]})]}),e.jsxs("div",{className:"relative w-full",children:[e.jsx(J,{className:"h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400"}),e.jsx(k,{value:a,onChange:s=>l(s.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"})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-1 pb-10 custom-scrollbar relative",children:g.isLoading?e.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:t("sessionsLoading")}):H.length===0?e.jsxs("div",{className:"text-sm text-gray-400 p-4 text-center border-2 border-dashed border-gray-100 rounded-xl mt-4",children:[e.jsx(T,{className:"w-8 h-8 mx-auto mb-2 text-gray-300"}),t("sessionsEmpty")]}):H.map(s=>e.jsx(Ne,{session:s,channel:j(s.key),runStatus:V.get(s.key),isSelected:n===s.key,onSelect:()=>p(s.key)},s.key))})]}),e.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:[(b.isPending||_.isPending)&&e.jsx("div",{className:"absolute top-0 left-0 w-full h-1 bg-primary/20 overflow-hidden z-20",children:e.jsx("div",{className:"h-full bg-primary animate-pulse w-1/3 rounded-r-full"})}),n&&o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shrink-0 border-b border-gray-100 bg-white px-8 py-5 z-10 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.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:e.jsx(X,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-1.5",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 tracking-tight",children:o.label||o.key.split(":").pop()||o.key}),e.jsx("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500 uppercase tracking-widest",children:C(j(o.key))})]}),e.jsx("div",{className:"text-xs text-gray-500 font-mono break-all line-clamp-1 opacity-70",title:n,children:n})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>S(!w),className:i("h-8.5 rounded-lg shadow-none border-gray-200 transition-all text-xs font-semibold",w?"bg-gray-100 text-gray-900":"hover:bg-gray-50 hover:text-gray-900"),children:[e.jsx(Z,{className:"w-3.5 h-3.5 mr-1.5"}),t("sessionsMetadata")]}),e.jsx(f,{variant:"outline",size:"sm",onClick:Y,className:"h-8.5 rounded-lg shadow-none hover:bg-gray-50 hover:text-gray-900 border-gray-200 text-xs font-semibold text-gray-500",children:t("sessionsClearHistory")}),e.jsx(f,{variant:"outline",size:"sm",onClick:G,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")})]})]}),w&&e.jsxs("div",{className:"flex items-center gap-3 bg-gray-50/50 p-3 rounded-lg border border-gray-100 animate-slide-in",children:[e.jsx(k,{placeholder:t("sessionsLabelPlaceholder"),value:M,onChange:s=>v(s.target.value),className:"h-8 text-sm bg-white"}),e.jsx(k,{placeholder:t("sessionsModelPlaceholder"),value:L,onChange:s=>N(s.target.value),className:"h-8 text-sm bg-white"}),e.jsx(f,{size:"sm",onClick:W,className:"h-8 px-4 shrink-0 shadow-none",disabled:b.isPending,children:t("sessionsSaveMeta")})]})]}),e.jsxs("div",{className:`flex-1 overflow-y-auto p-6 relative
|
|
2
2
|
[&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:bg-gray-300/80 [&::-webkit-scrollbar-thumb]:rounded-full`,children:[u.isLoading&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-50/50 backdrop-blur-sm z-10",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 animate-pulse",children:[e.jsx(I,{className:"w-6 h-6 text-primary animate-spin"}),e.jsx("span",{className:"text-sm font-medium text-gray-500",children:t("sessionsHistoryLoading")})]})}),u.error&&e.jsx("div",{className:"text-center p-6 bg-red-50 rounded-xl text-red-600 border border-red-100 text-sm",children:u.error.message}),!u.isLoading&&((K=u.data)==null?void 0:K.messages.length)===0&&e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(U,{className:"w-12 h-12 mb-3 text-gray-300"}),e.jsx("p",{className:"text-sm",children:t("sessionsEmpty")})]}),e.jsx("div",{className:"max-w-3xl mx-auto",children:(((R=u.data)==null?void 0:R.messages)??[]).map((s,h)=>e.jsx(we,{message:s},`${s.timestamp}-${h}`))})]})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-gray-400 p-8 h-full bg-white",children:[e.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:e.jsx(T,{className:"h-8 w-8 text-gray-300 -rotate-3"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900 mb-2",children:t("sessionsNoSelectionTitle")}),e.jsx("p",{className:"text-sm text-center max-w-sm leading-relaxed",children:t("sessionsNoSelectionDescription")})]})]})]}),e.jsx(O,{})]})}export{_e as SessionsConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,j as t}from"./vendor-
|
|
1
|
+
import{r as s,j as t}from"./vendor-C--HHaLf.js";import{c as d}from"./index-dKTqKCJo.js";const i=s.forwardRef(({className:a,hover:e=!0,...r},o)=>t.jsx("div",{ref:o,className:d("rounded-2xl border border-gray-200/50 bg-white text-card-foreground shadow-card transition-all duration-base",e&&"hover:shadow-card-hover hover:border-gray-200",a),...r}));i.displayName="Card";const c=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("flex flex-col space-y-1.5 p-6",a),...e}));c.displayName="CardHeader";const l=s.forwardRef(({className:a,...e},r)=>t.jsx("h3",{ref:r,className:d("text-[15px] font-semibold leading-tight tracking-tight text-gray-900",a),...e}));l.displayName="CardTitle";const n=s.forwardRef(({className:a,...e},r)=>t.jsx("p",{ref:r,className:d("text-[13px] text-gray-400 leading-relaxed",a),...e}));n.displayName="CardDescription";const p=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("p-6 pt-0",a),...e}));p.displayName="CardContent";const x=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("flex items-center justify-between p-6 pt-0",a),...e}));x.displayName="CardFooter";export{i as C,p as a,c as b,l as c,n as d};
|