@nextclaw/ui 0.5.42 → 0.5.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/assets/{ChannelsList-D1TDjZD6.js → ChannelsList-DhDnNnNj.js} +1 -1
  3. package/dist/assets/{ChatPage-DpqxbP_M.js → ChatPage-BDOAFhwZ.js} +12 -12
  4. package/dist/assets/{CronConfig-bxrnSSbp.js → CronConfig-BZ5BLWnK.js} +1 -1
  5. package/dist/assets/{DocBrowser-YLb5sMWS.js → DocBrowser-Cx6JqAqa.js} +1 -1
  6. package/dist/assets/{MarketplacePage-CTrpdj82.js → MarketplacePage-DSeYw-SZ.js} +1 -1
  7. package/dist/assets/{ModelConfig-tc0NiAb4.js → ModelConfig-CG7bFj_f.js} +1 -1
  8. package/dist/assets/{ProvidersList-CALeNCLF.js → ProvidersList-Dk95S5TU.js} +1 -1
  9. package/dist/assets/{RuntimeConfig-1hfJQMOn.js → RuntimeConfig-Bc8HKXWd.js} +1 -1
  10. package/dist/assets/{SecretsConfig-B5czvrZv.js → SecretsConfig-DV_eZgHa.js} +1 -1
  11. package/dist/assets/{SessionsConfig-BXSaq5p7.js → SessionsConfig-V9wA7zfR.js} +1 -1
  12. package/dist/assets/{card-CAvcgkiT.js → card-AxFsy7YF.js} +1 -1
  13. package/dist/assets/{index-CL28Z9YZ.js → index-CT15pXtn.js} +2 -2
  14. package/dist/assets/{label-BlmIivGH.js → label-Chdg0Pzh.js} +1 -1
  15. package/dist/assets/{logos-BoshQeun.js → logos-csBmIIFU.js} +1 -1
  16. package/dist/assets/{page-layout-Cu4Yj2Q_.js → page-layout-COKsFqhi.js} +1 -1
  17. package/dist/assets/{switch-C5wm6PbF.js → switch-BVQzjvsB.js} +1 -1
  18. package/dist/assets/{tabs-custom-B4CXzsVy.js → tabs-custom-BYQWSGw3.js} +1 -1
  19. package/dist/assets/{useConfig-Uy1hlToJ.js → useConfig-C9yQu_4f.js} +1 -1
  20. package/dist/assets/{useConfirmDialog-BUK2K_01.js → useConfirmDialog-8zI-gypg.js} +1 -1
  21. package/dist/index.html +1 -1
  22. package/package.json +1 -1
  23. package/src/components/chat/ChatPage.tsx +27 -2
@@ -1 +1 @@
1
- import{r as x,j as e,a5 as j,A as D,ao as L,ap as R,a8 as k}from"./vendor-CHxMoJ93.js";import{u as E}from"./useConfirmDialog-BUK2K_01.js";import{o as M,p as P,q as T,r as J,I as A}from"./useConfig-Uy1hlToJ.js";import{P as F,a as z,B as o}from"./page-layout-Cu4Yj2Q_.js";import{c as p,t,S as q,a as B,b as I,d as Q,e as f,g as y}from"./index-CL28Z9YZ.js";import{C as H,d as V}from"./card-CAvcgkiT.js";function g(s){return y(s??void 0)}function O(s){return typeof s!="number"||!Number.isFinite(s)?"-":y(new Date(s))}function G(s){if(typeof s!="number"||!Number.isFinite(s))return"-";const r=Math.round(s/1e3);if(r<60)return`${r}s`;const n=Math.round(r/60);if(n<60)return`${n}m`;const c=Math.round(n/60);return c<24?`${c}h`:`${Math.round(c/24)}d`}function K(s){const r=s.schedule;return r.kind==="cron"?r.expr?`cron ${r.expr}`:"cron":r.kind==="every"?`every ${G(r.everyMs)}`:r.kind==="at"?`at ${O(r.atMs)}`:"-"}function U(s){if(!s.payload.deliver)return"-";const r=s.payload.channel??"-",n=s.payload.to??"-";return`${r}:${n}`}function W(s,r){const n=r.trim().toLowerCase();return n?[s.id,s.name,s.payload.message,s.payload.channel??"",s.payload.to??""].join(" ").toLowerCase().includes(n):!0}function X(s,r){return r==="all"?!0:r==="enabled"?s.enabled:!s.enabled}function se(){var h;const[s,r]=x.useState(""),[n,c]=x.useState("all"),i=M({all:!0}),v=P(),N=T(),w=J(),{confirm:m,ConfirmDialog:C}=E(),u=x.useMemo(()=>{var l;return(((l=i.data)==null?void 0:l.jobs)??[]).filter(d=>W(d,s)).filter(d=>X(d,n))},[i.data,s,n]),b=async a=>{await m({title:`${t("cronDeleteConfirm")}?`,description:a.name?`${a.name} (${a.id})`:a.id,variant:"destructive",confirmLabel:t("delete")})&&v.mutate({id:a.id})},S=async a=>{const l=!a.enabled;await m({title:l?`${t("cronEnableConfirm")}?`:`${t("cronDisableConfirm")}?`,description:a.name?`${a.name} (${a.id})`:a.id,variant:l?"default":"destructive",confirmLabel:l?t("cronEnable"):t("cronDisable")})&&N.mutate({id:a.id,enabled:l})},$=async a=>{const l=!a.enabled;await m({title:l?`${t("cronRunForceConfirm")}?`:`${t("cronRunConfirm")}?`,description:a.name?`${a.name} (${a.id})`:a.id,confirmLabel:t("cronRunNow")})&&w.mutate({id:a.id,force:l})};return e.jsxs(F,{fullHeight:!0,children:[e.jsx(z,{title:t("cronPageTitle"),description:t("cronPageDescription"),actions:e.jsx(o,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100",onClick:()=>i.refetch(),children:e.jsx(j,{className:p("h-4 w-4",i.isFetching&&"animate-spin")})})}),e.jsx("div",{className:"mb-6",children:e.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[e.jsxs("div",{className:"relative flex-1 min-w-[240px]",children:[e.jsx(A,{value:s,onChange:a=>r(a.target.value),placeholder:t("cronSearchPlaceholder"),className:"pl-9"}),e.jsx(D,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"})]}),e.jsx("div",{className:"min-w-[180px]",children:e.jsxs(q,{value:n,onValueChange:a=>c(a),children:[e.jsx(B,{className:"w-full",children:e.jsx(I,{placeholder:t("cronStatusLabel")})}),e.jsxs(Q,{children:[e.jsx(f,{value:"all",children:t("cronStatusAll")}),e.jsx(f,{value:"enabled",children:t("cronStatusEnabled")}),e.jsx(f,{value:"disabled",children:t("cronStatusDisabled")})]})]})}),e.jsxs("div",{className:"text-xs text-gray-500 ml-auto",children:[t("cronTotalLabel"),": ",((h=i.data)==null?void 0:h.total)??0," / ",u.length]})]})}),e.jsx("div",{className:"flex-1 overflow-auto custom-scrollbar",children:i.isLoading?e.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:t("cronLoading")}):u.length===0?e.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:t("cronEmpty")}):e.jsx("div",{className:"space-y-4",children:u.map(a=>e.jsx(H,{className:"border border-gray-200",children:e.jsx(V,{className:"pt-5 pb-5",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-[220px] flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-900",children:a.name||a.id}),e.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500",children:a.id}),e.jsx("span",{className:p("text-[10px] font-semibold px-2 py-0.5 rounded-full",a.enabled?"bg-emerald-50 text-emerald-700":"bg-gray-100 text-gray-500"),children:a.enabled?t("enabled"):t("disabled")}),a.deleteAfterRun&&e.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full bg-amber-50 text-amber-700",children:t("cronOneShot")})]}),e.jsxs("div",{className:"mt-2 text-xs text-gray-500",children:[t("cronScheduleLabel"),": ",K(a)]}),e.jsx("div",{className:"mt-2 text-sm text-gray-700 whitespace-pre-wrap break-words",children:a.payload.message}),e.jsxs("div",{className:"mt-2 text-xs text-gray-500",children:[t("cronDeliverTo"),": ",U(a)]})]}),e.jsxs("div",{className:"min-w-[220px] text-xs text-gray-500 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-gray-700",children:[t("cronNextRun"),":"]})," ",g(a.state.nextRunAt)]}),e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-gray-700",children:[t("cronLastRun"),":"]})," ",g(a.state.lastRunAt)]}),e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-gray-700",children:[t("cronLastStatus"),":"]})," ",a.state.lastStatus??"-"]}),a.state.lastError&&e.jsx("div",{className:"text-[11px] text-red-500 break-words",children:a.state.lastError})]}),e.jsxs("div",{className:"flex items-start gap-2 flex-wrap justify-end",children:[e.jsxs(o,{variant:"subtle",size:"sm",onClick:()=>$(a),className:"gap-1",children:[e.jsx(L,{className:"h-3.5 w-3.5"}),t("cronRunNow")]}),e.jsxs(o,{variant:a.enabled?"outline":"primary",size:"sm",onClick:()=>S(a),className:"gap-1",children:[e.jsx(R,{className:"h-3.5 w-3.5"}),a.enabled?t("cronDisable"):t("cronEnable")]}),e.jsxs(o,{variant:"destructive",size:"sm",onClick:()=>b(a),className:"gap-1",children:[e.jsx(k,{className:"h-3.5 w-3.5"}),t("delete")]})]})]})})},a.id))})}),e.jsx(C,{})]})}export{se as CronConfig};
1
+ import{r as x,j as e,a5 as j,A as D,ao as L,ap as R,a8 as k}from"./vendor-CHxMoJ93.js";import{u as E}from"./useConfirmDialog-8zI-gypg.js";import{o as M,p as P,q as T,r as J,I as A}from"./useConfig-C9yQu_4f.js";import{P as F,a as z,B as o}from"./page-layout-COKsFqhi.js";import{c as p,t,S as q,a as B,b as I,d as Q,e as f,g as y}from"./index-CT15pXtn.js";import{C as H,d as V}from"./card-AxFsy7YF.js";function g(s){return y(s??void 0)}function O(s){return typeof s!="number"||!Number.isFinite(s)?"-":y(new Date(s))}function G(s){if(typeof s!="number"||!Number.isFinite(s))return"-";const r=Math.round(s/1e3);if(r<60)return`${r}s`;const n=Math.round(r/60);if(n<60)return`${n}m`;const c=Math.round(n/60);return c<24?`${c}h`:`${Math.round(c/24)}d`}function K(s){const r=s.schedule;return r.kind==="cron"?r.expr?`cron ${r.expr}`:"cron":r.kind==="every"?`every ${G(r.everyMs)}`:r.kind==="at"?`at ${O(r.atMs)}`:"-"}function U(s){if(!s.payload.deliver)return"-";const r=s.payload.channel??"-",n=s.payload.to??"-";return`${r}:${n}`}function W(s,r){const n=r.trim().toLowerCase();return n?[s.id,s.name,s.payload.message,s.payload.channel??"",s.payload.to??""].join(" ").toLowerCase().includes(n):!0}function X(s,r){return r==="all"?!0:r==="enabled"?s.enabled:!s.enabled}function se(){var h;const[s,r]=x.useState(""),[n,c]=x.useState("all"),i=M({all:!0}),v=P(),N=T(),w=J(),{confirm:m,ConfirmDialog:C}=E(),u=x.useMemo(()=>{var l;return(((l=i.data)==null?void 0:l.jobs)??[]).filter(d=>W(d,s)).filter(d=>X(d,n))},[i.data,s,n]),b=async a=>{await m({title:`${t("cronDeleteConfirm")}?`,description:a.name?`${a.name} (${a.id})`:a.id,variant:"destructive",confirmLabel:t("delete")})&&v.mutate({id:a.id})},S=async a=>{const l=!a.enabled;await m({title:l?`${t("cronEnableConfirm")}?`:`${t("cronDisableConfirm")}?`,description:a.name?`${a.name} (${a.id})`:a.id,variant:l?"default":"destructive",confirmLabel:l?t("cronEnable"):t("cronDisable")})&&N.mutate({id:a.id,enabled:l})},$=async a=>{const l=!a.enabled;await m({title:l?`${t("cronRunForceConfirm")}?`:`${t("cronRunConfirm")}?`,description:a.name?`${a.name} (${a.id})`:a.id,confirmLabel:t("cronRunNow")})&&w.mutate({id:a.id,force:l})};return e.jsxs(F,{fullHeight:!0,children:[e.jsx(z,{title:t("cronPageTitle"),description:t("cronPageDescription"),actions:e.jsx(o,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100",onClick:()=>i.refetch(),children:e.jsx(j,{className:p("h-4 w-4",i.isFetching&&"animate-spin")})})}),e.jsx("div",{className:"mb-6",children:e.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[e.jsxs("div",{className:"relative flex-1 min-w-[240px]",children:[e.jsx(A,{value:s,onChange:a=>r(a.target.value),placeholder:t("cronSearchPlaceholder"),className:"pl-9"}),e.jsx(D,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"})]}),e.jsx("div",{className:"min-w-[180px]",children:e.jsxs(q,{value:n,onValueChange:a=>c(a),children:[e.jsx(B,{className:"w-full",children:e.jsx(I,{placeholder:t("cronStatusLabel")})}),e.jsxs(Q,{children:[e.jsx(f,{value:"all",children:t("cronStatusAll")}),e.jsx(f,{value:"enabled",children:t("cronStatusEnabled")}),e.jsx(f,{value:"disabled",children:t("cronStatusDisabled")})]})]})}),e.jsxs("div",{className:"text-xs text-gray-500 ml-auto",children:[t("cronTotalLabel"),": ",((h=i.data)==null?void 0:h.total)??0," / ",u.length]})]})}),e.jsx("div",{className:"flex-1 overflow-auto custom-scrollbar",children:i.isLoading?e.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:t("cronLoading")}):u.length===0?e.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:t("cronEmpty")}):e.jsx("div",{className:"space-y-4",children:u.map(a=>e.jsx(H,{className:"border border-gray-200",children:e.jsx(V,{className:"pt-5 pb-5",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-[220px] flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-900",children:a.name||a.id}),e.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500",children:a.id}),e.jsx("span",{className:p("text-[10px] font-semibold px-2 py-0.5 rounded-full",a.enabled?"bg-emerald-50 text-emerald-700":"bg-gray-100 text-gray-500"),children:a.enabled?t("enabled"):t("disabled")}),a.deleteAfterRun&&e.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full bg-amber-50 text-amber-700",children:t("cronOneShot")})]}),e.jsxs("div",{className:"mt-2 text-xs text-gray-500",children:[t("cronScheduleLabel"),": ",K(a)]}),e.jsx("div",{className:"mt-2 text-sm text-gray-700 whitespace-pre-wrap break-words",children:a.payload.message}),e.jsxs("div",{className:"mt-2 text-xs text-gray-500",children:[t("cronDeliverTo"),": ",U(a)]})]}),e.jsxs("div",{className:"min-w-[220px] text-xs text-gray-500 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-gray-700",children:[t("cronNextRun"),":"]})," ",g(a.state.nextRunAt)]}),e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-gray-700",children:[t("cronLastRun"),":"]})," ",g(a.state.lastRunAt)]}),e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-gray-700",children:[t("cronLastStatus"),":"]})," ",a.state.lastStatus??"-"]}),a.state.lastError&&e.jsx("div",{className:"text-[11px] text-red-500 break-words",children:a.state.lastError})]}),e.jsxs("div",{className:"flex items-start gap-2 flex-wrap justify-end",children:[e.jsxs(o,{variant:"subtle",size:"sm",onClick:()=>$(a),className:"gap-1",children:[e.jsx(L,{className:"h-3.5 w-3.5"}),t("cronRunNow")]}),e.jsxs(o,{variant:a.enabled?"outline":"primary",size:"sm",onClick:()=>S(a),className:"gap-1",children:[e.jsx(R,{className:"h-3.5 w-3.5"}),a.enabled?t("cronDisable"):t("cronEnable")]}),e.jsxs(o,{variant:"destructive",size:"sm",onClick:()=>b(a),className:"gap-1",children:[e.jsx(k,{className:"h-3.5 w-3.5"}),t("delete")]})]})]})})},a.id))})}),e.jsx(C,{})]})}export{se as CronConfig};
@@ -1 +1 @@
1
- import{r as s,j as t,s as oe,aS as ae,aT as ne,ac as P,a6 as ie,aU as le,aV as ce,a0 as de,ak as ue,aW as me}from"./vendor-CHxMoJ93.js";import{k as we,D as Y,t as i,c as S,l as xe}from"./index-CL28Z9YZ.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:X,setActiveTab:G,closeTab:H,openNewTab:q}=we(),[k,j]=s.useState(""),[E,C]=s.useState(!1),[J,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,K]=s.useState(420),u=s.useRef(null),m=s.useRef(null),b=s.useRef(null),z=s.useRef(null),U=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!==U.current){U.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"&&X(r.data.url)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[X,a]);const Q=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]),Z=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 M=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;K(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,W=Math.max(360,o+se);B(R=>({...R,w:W})),D(R=>({...R,x:f-(W-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:S("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:S("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:Z,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(P,{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:S("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(P,{className:"w-3 h-3"})})]},e.id)}),t.jsx("button",{onClick:()=>q(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:Q,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}`),(J||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:M,"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:M,"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:M,children:t.jsx(me,{className:"w-3 h-3 rotate-[-45deg]"})})]})]})}export{pe as DocBrowser};
1
+ import{r as s,j as t,s as oe,aS as ae,aT as ne,ac as P,a6 as ie,aU as le,aV as ce,a0 as de,ak as ue,aW as me}from"./vendor-CHxMoJ93.js";import{k as we,D as Y,t as i,c as S,l as xe}from"./index-CT15pXtn.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:X,setActiveTab:G,closeTab:H,openNewTab:q}=we(),[k,j]=s.useState(""),[E,C]=s.useState(!1),[J,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,K]=s.useState(420),u=s.useRef(null),m=s.useRef(null),b=s.useRef(null),z=s.useRef(null),U=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!==U.current){U.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"&&X(r.data.url)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[X,a]);const Q=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]),Z=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 M=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;K(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,W=Math.max(360,o+se);B(R=>({...R,w:W})),D(R=>({...R,x:f-(W-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:S("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:S("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:Z,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(P,{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:S("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(P,{className:"w-3 h-3"})})]},e.id)}),t.jsx("button",{onClick:()=>q(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:Q,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}`),(J||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:M,"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:M,"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:M,children:t.jsx(me,{className:"w-3 h-3 rotate-[-45deg]"})})]})]})}export{pe as DocBrowser};
@@ -1,4 +1,4 @@
1
- import{r as u,j as s,at as Qe,au as Ge,av as Ve,aw as Ce,ax as Je,ay as Ye,az as O,aA as Pe,aB as We,aC as Xe,aD as Ze,aE as et,aF as tt,aG as at,aH as nt,aq as je,ar as Ie,as as Ne,af as Q,aI as st,aJ as rt,aK as ot}from"./vendor-CHxMoJ93.js";import{j as U,c as Ee,t as d,u as lt,k as it,S as ct,a as ut,b as dt,d as pt,e as we}from"./index-CL28Z9YZ.js";import{T as mt}from"./tabs-custom-B4CXzsVy.js";import{P as Re,u as gt}from"./useConfirmDialog-BUK2K_01.js";import{P as ft,a as xt}from"./page-layout-Cu4Yj2Q_.js";function G(e){return e==="plugin"?"plugins":"skills"}async function ht(e){var o,c;const t=new URLSearchParams,a=G(e.type);(o=e.q)!=null&&o.trim()&&t.set("q",e.q.trim()),(c=e.tag)!=null&&c.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 U.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 yt(e){const t=await U.get(`/api/marketplace/skills/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function bt(e){const t=await U.get(`/api/marketplace/plugins/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function kt(e){const t=G(e.type),a=await U.post(`/api/marketplace/${t}/install`,e);if(!a.ok)throw new Error(a.error.message);return a.data}async function vt(e){const t=G(e),a=await U.get(`/api/marketplace/${t}/installed`);if(!a.ok)throw new Error(a.error.message);return a.data}async function wt(e){const t=G(e.type),a=await U.post(`/api/marketplace/${t}/manage`,e);if(!a.ok)throw new Error(a.error.message);return a.data}var[V]=Xe("Tooltip",[Pe]),J=Pe(),Me="TooltipProvider",Tt=700,ee="tooltip.open",[St,ne]=V(Me),Le=e=>{const{__scopeTooltip:t,delayDuration:a=Tt,skipDelayDuration:n=300,disableHoverableContent:r=!1,children:o}=e,c=u.useRef(!0),f=u.useRef(!1),i=u.useRef(0);return u.useEffect(()=>{const x=i.current;return()=>window.clearTimeout(x)},[]),s.jsx(St,{scope:t,isOpenDelayedRef:c,delayDuration:a,onOpen:u.useCallback(()=>{window.clearTimeout(i.current),c.current=!1},[]),onClose:u.useCallback(()=>{window.clearTimeout(i.current),i.current=window.setTimeout(()=>c.current=!0,n)},[n]),isPointerInTransitRef:f,onPointerInTransitChange:u.useCallback(x=>{f.current=x},[]),disableHoverableContent:r,children:o})};Le.displayName=Me;var q="Tooltip",[Ct,H]=V(q),De=e=>{const{__scopeTooltip:t,children:a,open:n,defaultOpen:r,onOpenChange:o,disableHoverableContent:c,delayDuration:f}=e,i=ne(q,e.__scopeTooltip),x=J(t),[g,h]=u.useState(null),v=Qe(),m=u.useRef(0),w=c??i.disableHoverableContent,S=f??i.delayDuration,P=u.useRef(!1),[I,k]=Ge({prop:n,defaultProp:r??!1,onChange:M=>{M?(i.onOpen(),document.dispatchEvent(new CustomEvent(ee))):i.onClose(),o==null||o(M)},caller:q}),E=u.useMemo(()=>I?P.current?"delayed-open":"instant-open":"closed",[I]),R=u.useCallback(()=>{window.clearTimeout(m.current),m.current=0,P.current=!1,k(!0)},[k]),T=u.useCallback(()=>{window.clearTimeout(m.current),m.current=0,k(!1)},[k]),C=u.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{P.current=!0,k(!0),m.current=0},S)},[S,k]);return u.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),s.jsx(Ve,{...x,children:s.jsx(Ct,{scope:t,contentId:v,open:I,stateAttribute:E,trigger:g,onTriggerChange:h,onTriggerEnter:u.useCallback(()=>{i.isOpenDelayedRef.current?C():R()},[i.isOpenDelayedRef,C,R]),onTriggerLeave:u.useCallback(()=>{w?T():(window.clearTimeout(m.current),m.current=0)},[T,w]),onOpen:R,onClose:T,disableHoverableContent:w,children:a})})};De.displayName=q;var te="TooltipTrigger",$e=u.forwardRef((e,t)=>{const{__scopeTooltip:a,...n}=e,r=H(te,a),o=ne(te,a),c=J(a),f=u.useRef(null),i=Ce(t,f,r.onTriggerChange),x=u.useRef(!1),g=u.useRef(!1),h=u.useCallback(()=>x.current=!1,[]);return u.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),s.jsx(Je,{asChild:!0,...c,children:s.jsx(Ye.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...n,ref:i,onPointerMove:O(e.onPointerMove,v=>{v.pointerType!=="touch"&&!g.current&&!o.isPointerInTransitRef.current&&(r.onTriggerEnter(),g.current=!0)}),onPointerLeave:O(e.onPointerLeave,()=>{r.onTriggerLeave(),g.current=!1}),onPointerDown:O(e.onPointerDown,()=>{r.open&&r.onClose(),x.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:O(e.onFocus,()=>{x.current||r.onOpen()}),onBlur:O(e.onBlur,r.onClose),onClick:O(e.onClick,r.onClose)})})});$e.displayName=te;var se="TooltipPortal",[Pt,jt]=V(se,{forceMount:void 0}),Oe=e=>{const{__scopeTooltip:t,forceMount:a,children:n,container:r}=e,o=H(se,t);return s.jsx(Pt,{scope:t,forceMount:a,children:s.jsx(Re,{present:a||o.open,children:s.jsx(We,{asChild:!0,container:r,children:n})})})};Oe.displayName=se;var A="TooltipContent",_e=u.forwardRef((e,t)=>{const a=jt(A,e.__scopeTooltip),{forceMount:n=a.forceMount,side:r="top",...o}=e,c=H(A,e.__scopeTooltip);return s.jsx(Re,{present:n||c.open,children:c.disableHoverableContent?s.jsx(Ae,{side:r,...o,ref:t}):s.jsx(It,{side:r,...o,ref:t})})}),It=u.forwardRef((e,t)=>{const a=H(A,e.__scopeTooltip),n=ne(A,e.__scopeTooltip),r=u.useRef(null),o=Ce(t,r),[c,f]=u.useState(null),{trigger:i,onClose:x}=a,g=r.current,{onPointerInTransitChange:h}=n,v=u.useCallback(()=>{f(null),h(!1)},[h]),m=u.useCallback((w,S)=>{const P=w.currentTarget,I={x:w.clientX,y:w.clientY},k=Lt(I,P.getBoundingClientRect()),E=Dt(I,k),R=$t(S.getBoundingClientRect()),T=_t([...E,...R]);f(T),h(!0)},[h]);return u.useEffect(()=>()=>v(),[v]),u.useEffect(()=>{if(i&&g){const w=P=>m(P,g),S=P=>m(P,i);return i.addEventListener("pointerleave",w),g.addEventListener("pointerleave",S),()=>{i.removeEventListener("pointerleave",w),g.removeEventListener("pointerleave",S)}}},[i,g,m,v]),u.useEffect(()=>{if(c){const w=S=>{const P=S.target,I={x:S.clientX,y:S.clientY},k=(i==null?void 0:i.contains(P))||(g==null?void 0:g.contains(P)),E=!Ot(I,c);k?v():E&&(v(),x())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[i,g,c,x,v]),s.jsx(Ae,{...e,ref:o})}),[Nt,Et]=V(q,{isInside:!1}),Rt=at("TooltipContent"),Ae=u.forwardRef((e,t)=>{const{__scopeTooltip:a,children:n,"aria-label":r,onEscapeKeyDown:o,onPointerDownOutside:c,...f}=e,i=H(A,a),x=J(a),{onClose:g}=i;return u.useEffect(()=>(document.addEventListener(ee,g),()=>document.removeEventListener(ee,g)),[g]),u.useEffect(()=>{if(i.trigger){const h=v=>{const m=v.target;m!=null&&m.contains(i.trigger)&&g()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[i.trigger,g]),s.jsx(Ze,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:c,onFocusOutside:h=>h.preventDefault(),onDismiss:g,children:s.jsxs(et,{"data-state":i.stateAttribute,...x,...f,ref:t,style:{...f.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(Rt,{children:n}),s.jsx(Nt,{scope:a,isInside:!0,children:s.jsx(tt,{id:i.contentId,role:"tooltip",children:r||n})})]})})});_e.displayName=A;var Ue="TooltipArrow",Mt=u.forwardRef((e,t)=>{const{__scopeTooltip:a,...n}=e,r=J(a);return Et(Ue,a).isInside?null:s.jsx(nt,{...r,...n,ref:t})});Mt.displayName=Ue;function Lt(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 Dt(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 $t(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 Ot(e,t){const{x:a,y:n}=e;let r=!1;for(let o=0,c=t.length-1;o<t.length;c=o++){const f=t[o],i=t[c],x=f.x,g=f.y,h=i.x,v=i.y;g>n!=v>n&&a<(h-x)*(n-g)/(v-g)+x&&(r=!r)}return r}function _t(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),At(t)}function At(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],c=t[t.length-2];if((o.x-c.x)*(r.y-c.y)>=(o.y-c.y)*(r.x-c.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],c=a[a.length-2];if((o.x-c.x)*(r.y-c.y)>=(o.y-c.y)*(r.x-c.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 Ut=Le,Ft=De,zt=$e,qt=Oe,Fe=_e;const Ht=Ut,W=Ft,X=zt,B=u.forwardRef(({className:e,sideOffset:t=4,...a},n)=>s.jsx(qt,{children:s.jsx(Fe,{ref:n,sideOffset:t,className:Ee("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})}));B.displayName=Fe.displayName;function Kt(e){return je({queryKey:["marketplace-items",e],queryFn:()=>ht(e),staleTime:15e3})}function Bt(e){return je({queryKey:["marketplace-installed",e],queryFn:()=>vt(e),staleTime:1e4})}function Qt(){const e=Ie();return Ne({mutationFn:t=>kt(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");Q.success(t.message||a)},onError:t=>{Q.error(t.message||d("marketplaceInstallFailed"))}})}function Gt(){const e=Ie();return Ne({mutationFn:t=>wt(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");Q.success(t.message||a)},onError:t=>{Q.error(t.message||d("marketplaceOperationFailed"))}})}const Vt=12;function ae(e){return(e??"").trim().toLowerCase()}function _(e,t){const a=ae(t);return a.length>0?`${e}:${a}`:""}function Jt(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.type,r);!o||t.has(o)||t.set(o,a)}}return t}function Yt(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.type,r);!o||t.has(o)||t.set(o,a)}}return t}function Te(e,t){const a=[e.install.spec,e.slug,e.id];for(const n of a){const r=_(e.type,n);if(!r)continue;const o=t.get(r);if(o)return o}}function Wt(e,t){const a=t.get(_(e.type,e.spec));if(a)return a;const n=t.get(_(e.type,e.id));return n||t.get(_(e.type,e.label))}function Xt(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 Z(e){return e.trim().toLowerCase().replace(/_/g,"-")}function re(e,t,a){var n;if(e){const r=Object.entries(e).map(([o,c])=>({locale:Z(o),text:typeof c=="string"?c.trim():""})).filter(o=>o.text.length>0);if(r.length>0){const o=new Map(r.map(c=>[c.locale,c.text]));for(const c of a){const f=Z(c),i=o.get(f);if(i)return i}for(const c of a){const f=Z(c).split("-")[0];if(!f)continue;const i=r.find(x=>x.locale===f||x.locale.startsWith(`${f}-`));if(i)return i.text}return((n=r[0])==null?void 0:n.text)??""}}return(t==null?void 0:t.trim())??""}function Zt(e,t,a,n){const r=ae(a);if(!r)return!0;const o=re(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(f=>ae(f)).filter(Boolean).some(f=>f.includes(r))}function ea(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 ta({name:e,fallback:t}){const a=e||t,n=a.substring(0,2).toUpperCase(),r=ea(a);return s.jsx("div",{className:Ee("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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function z(e){var f,i,x,g;const t=((f=e.metadataRaw)==null?void 0:f.trim())||"-",a=((i=e.contentRaw)==null?void 0:i.trim())||"-",n=(x=e.summary)==null?void 0:x.trim(),r=(g=e.description)==null?void 0:g.trim(),o=!!r&&r!==n,c=`<!doctype html>
1
+ import{r as u,j as s,at as Qe,au as Ge,av as Ve,aw as Ce,ax as Je,ay as Ye,az as O,aA as Pe,aB as We,aC as Xe,aD as Ze,aE as et,aF as tt,aG as at,aH as nt,aq as je,ar as Ie,as as Ne,af as Q,aI as st,aJ as rt,aK as ot}from"./vendor-CHxMoJ93.js";import{j as U,c as Ee,t as d,u as lt,k as it,S as ct,a as ut,b as dt,d as pt,e as we}from"./index-CT15pXtn.js";import{T as mt}from"./tabs-custom-BYQWSGw3.js";import{P as Re,u as gt}from"./useConfirmDialog-8zI-gypg.js";import{P as ft,a as xt}from"./page-layout-COKsFqhi.js";function G(e){return e==="plugin"?"plugins":"skills"}async function ht(e){var o,c;const t=new URLSearchParams,a=G(e.type);(o=e.q)!=null&&o.trim()&&t.set("q",e.q.trim()),(c=e.tag)!=null&&c.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 U.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 yt(e){const t=await U.get(`/api/marketplace/skills/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function bt(e){const t=await U.get(`/api/marketplace/plugins/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function kt(e){const t=G(e.type),a=await U.post(`/api/marketplace/${t}/install`,e);if(!a.ok)throw new Error(a.error.message);return a.data}async function vt(e){const t=G(e),a=await U.get(`/api/marketplace/${t}/installed`);if(!a.ok)throw new Error(a.error.message);return a.data}async function wt(e){const t=G(e.type),a=await U.post(`/api/marketplace/${t}/manage`,e);if(!a.ok)throw new Error(a.error.message);return a.data}var[V]=Xe("Tooltip",[Pe]),J=Pe(),Me="TooltipProvider",Tt=700,ee="tooltip.open",[St,ne]=V(Me),Le=e=>{const{__scopeTooltip:t,delayDuration:a=Tt,skipDelayDuration:n=300,disableHoverableContent:r=!1,children:o}=e,c=u.useRef(!0),f=u.useRef(!1),i=u.useRef(0);return u.useEffect(()=>{const x=i.current;return()=>window.clearTimeout(x)},[]),s.jsx(St,{scope:t,isOpenDelayedRef:c,delayDuration:a,onOpen:u.useCallback(()=>{window.clearTimeout(i.current),c.current=!1},[]),onClose:u.useCallback(()=>{window.clearTimeout(i.current),i.current=window.setTimeout(()=>c.current=!0,n)},[n]),isPointerInTransitRef:f,onPointerInTransitChange:u.useCallback(x=>{f.current=x},[]),disableHoverableContent:r,children:o})};Le.displayName=Me;var q="Tooltip",[Ct,H]=V(q),De=e=>{const{__scopeTooltip:t,children:a,open:n,defaultOpen:r,onOpenChange:o,disableHoverableContent:c,delayDuration:f}=e,i=ne(q,e.__scopeTooltip),x=J(t),[g,h]=u.useState(null),v=Qe(),m=u.useRef(0),w=c??i.disableHoverableContent,S=f??i.delayDuration,P=u.useRef(!1),[I,k]=Ge({prop:n,defaultProp:r??!1,onChange:M=>{M?(i.onOpen(),document.dispatchEvent(new CustomEvent(ee))):i.onClose(),o==null||o(M)},caller:q}),E=u.useMemo(()=>I?P.current?"delayed-open":"instant-open":"closed",[I]),R=u.useCallback(()=>{window.clearTimeout(m.current),m.current=0,P.current=!1,k(!0)},[k]),T=u.useCallback(()=>{window.clearTimeout(m.current),m.current=0,k(!1)},[k]),C=u.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{P.current=!0,k(!0),m.current=0},S)},[S,k]);return u.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),s.jsx(Ve,{...x,children:s.jsx(Ct,{scope:t,contentId:v,open:I,stateAttribute:E,trigger:g,onTriggerChange:h,onTriggerEnter:u.useCallback(()=>{i.isOpenDelayedRef.current?C():R()},[i.isOpenDelayedRef,C,R]),onTriggerLeave:u.useCallback(()=>{w?T():(window.clearTimeout(m.current),m.current=0)},[T,w]),onOpen:R,onClose:T,disableHoverableContent:w,children:a})})};De.displayName=q;var te="TooltipTrigger",$e=u.forwardRef((e,t)=>{const{__scopeTooltip:a,...n}=e,r=H(te,a),o=ne(te,a),c=J(a),f=u.useRef(null),i=Ce(t,f,r.onTriggerChange),x=u.useRef(!1),g=u.useRef(!1),h=u.useCallback(()=>x.current=!1,[]);return u.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),s.jsx(Je,{asChild:!0,...c,children:s.jsx(Ye.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...n,ref:i,onPointerMove:O(e.onPointerMove,v=>{v.pointerType!=="touch"&&!g.current&&!o.isPointerInTransitRef.current&&(r.onTriggerEnter(),g.current=!0)}),onPointerLeave:O(e.onPointerLeave,()=>{r.onTriggerLeave(),g.current=!1}),onPointerDown:O(e.onPointerDown,()=>{r.open&&r.onClose(),x.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:O(e.onFocus,()=>{x.current||r.onOpen()}),onBlur:O(e.onBlur,r.onClose),onClick:O(e.onClick,r.onClose)})})});$e.displayName=te;var se="TooltipPortal",[Pt,jt]=V(se,{forceMount:void 0}),Oe=e=>{const{__scopeTooltip:t,forceMount:a,children:n,container:r}=e,o=H(se,t);return s.jsx(Pt,{scope:t,forceMount:a,children:s.jsx(Re,{present:a||o.open,children:s.jsx(We,{asChild:!0,container:r,children:n})})})};Oe.displayName=se;var A="TooltipContent",_e=u.forwardRef((e,t)=>{const a=jt(A,e.__scopeTooltip),{forceMount:n=a.forceMount,side:r="top",...o}=e,c=H(A,e.__scopeTooltip);return s.jsx(Re,{present:n||c.open,children:c.disableHoverableContent?s.jsx(Ae,{side:r,...o,ref:t}):s.jsx(It,{side:r,...o,ref:t})})}),It=u.forwardRef((e,t)=>{const a=H(A,e.__scopeTooltip),n=ne(A,e.__scopeTooltip),r=u.useRef(null),o=Ce(t,r),[c,f]=u.useState(null),{trigger:i,onClose:x}=a,g=r.current,{onPointerInTransitChange:h}=n,v=u.useCallback(()=>{f(null),h(!1)},[h]),m=u.useCallback((w,S)=>{const P=w.currentTarget,I={x:w.clientX,y:w.clientY},k=Lt(I,P.getBoundingClientRect()),E=Dt(I,k),R=$t(S.getBoundingClientRect()),T=_t([...E,...R]);f(T),h(!0)},[h]);return u.useEffect(()=>()=>v(),[v]),u.useEffect(()=>{if(i&&g){const w=P=>m(P,g),S=P=>m(P,i);return i.addEventListener("pointerleave",w),g.addEventListener("pointerleave",S),()=>{i.removeEventListener("pointerleave",w),g.removeEventListener("pointerleave",S)}}},[i,g,m,v]),u.useEffect(()=>{if(c){const w=S=>{const P=S.target,I={x:S.clientX,y:S.clientY},k=(i==null?void 0:i.contains(P))||(g==null?void 0:g.contains(P)),E=!Ot(I,c);k?v():E&&(v(),x())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[i,g,c,x,v]),s.jsx(Ae,{...e,ref:o})}),[Nt,Et]=V(q,{isInside:!1}),Rt=at("TooltipContent"),Ae=u.forwardRef((e,t)=>{const{__scopeTooltip:a,children:n,"aria-label":r,onEscapeKeyDown:o,onPointerDownOutside:c,...f}=e,i=H(A,a),x=J(a),{onClose:g}=i;return u.useEffect(()=>(document.addEventListener(ee,g),()=>document.removeEventListener(ee,g)),[g]),u.useEffect(()=>{if(i.trigger){const h=v=>{const m=v.target;m!=null&&m.contains(i.trigger)&&g()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[i.trigger,g]),s.jsx(Ze,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:c,onFocusOutside:h=>h.preventDefault(),onDismiss:g,children:s.jsxs(et,{"data-state":i.stateAttribute,...x,...f,ref:t,style:{...f.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(Rt,{children:n}),s.jsx(Nt,{scope:a,isInside:!0,children:s.jsx(tt,{id:i.contentId,role:"tooltip",children:r||n})})]})})});_e.displayName=A;var Ue="TooltipArrow",Mt=u.forwardRef((e,t)=>{const{__scopeTooltip:a,...n}=e,r=J(a);return Et(Ue,a).isInside?null:s.jsx(nt,{...r,...n,ref:t})});Mt.displayName=Ue;function Lt(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 Dt(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 $t(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 Ot(e,t){const{x:a,y:n}=e;let r=!1;for(let o=0,c=t.length-1;o<t.length;c=o++){const f=t[o],i=t[c],x=f.x,g=f.y,h=i.x,v=i.y;g>n!=v>n&&a<(h-x)*(n-g)/(v-g)+x&&(r=!r)}return r}function _t(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),At(t)}function At(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],c=t[t.length-2];if((o.x-c.x)*(r.y-c.y)>=(o.y-c.y)*(r.x-c.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],c=a[a.length-2];if((o.x-c.x)*(r.y-c.y)>=(o.y-c.y)*(r.x-c.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 Ut=Le,Ft=De,zt=$e,qt=Oe,Fe=_e;const Ht=Ut,W=Ft,X=zt,B=u.forwardRef(({className:e,sideOffset:t=4,...a},n)=>s.jsx(qt,{children:s.jsx(Fe,{ref:n,sideOffset:t,className:Ee("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})}));B.displayName=Fe.displayName;function Kt(e){return je({queryKey:["marketplace-items",e],queryFn:()=>ht(e),staleTime:15e3})}function Bt(e){return je({queryKey:["marketplace-installed",e],queryFn:()=>vt(e),staleTime:1e4})}function Qt(){const e=Ie();return Ne({mutationFn:t=>kt(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");Q.success(t.message||a)},onError:t=>{Q.error(t.message||d("marketplaceInstallFailed"))}})}function Gt(){const e=Ie();return Ne({mutationFn:t=>wt(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");Q.success(t.message||a)},onError:t=>{Q.error(t.message||d("marketplaceOperationFailed"))}})}const Vt=12;function ae(e){return(e??"").trim().toLowerCase()}function _(e,t){const a=ae(t);return a.length>0?`${e}:${a}`:""}function Jt(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.type,r);!o||t.has(o)||t.set(o,a)}}return t}function Yt(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.type,r);!o||t.has(o)||t.set(o,a)}}return t}function Te(e,t){const a=[e.install.spec,e.slug,e.id];for(const n of a){const r=_(e.type,n);if(!r)continue;const o=t.get(r);if(o)return o}}function Wt(e,t){const a=t.get(_(e.type,e.spec));if(a)return a;const n=t.get(_(e.type,e.id));return n||t.get(_(e.type,e.label))}function Xt(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 Z(e){return e.trim().toLowerCase().replace(/_/g,"-")}function re(e,t,a){var n;if(e){const r=Object.entries(e).map(([o,c])=>({locale:Z(o),text:typeof c=="string"?c.trim():""})).filter(o=>o.text.length>0);if(r.length>0){const o=new Map(r.map(c=>[c.locale,c.text]));for(const c of a){const f=Z(c),i=o.get(f);if(i)return i}for(const c of a){const f=Z(c).split("-")[0];if(!f)continue;const i=r.find(x=>x.locale===f||x.locale.startsWith(`${f}-`));if(i)return i.text}return((n=r[0])==null?void 0:n.text)??""}}return(t==null?void 0:t.trim())??""}function Zt(e,t,a,n){const r=ae(a);if(!r)return!0;const o=re(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(f=>ae(f)).filter(Boolean).some(f=>f.includes(r))}function ea(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 ta({name:e,fallback:t}){const a=e||t,n=a.substring(0,2).toUpperCase(),r=ea(a);return s.jsx("div",{className:Ee("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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function z(e){var f,i,x,g;const t=((f=e.metadataRaw)==null?void 0:f.trim())||"-",a=((i=e.contentRaw)==null?void 0:i.trim())||"-",n=(x=e.summary)==null?void 0:x.trim(),r=(g=e.description)==null?void 0:g.trim(),o=!!r&&r!==n,c=`<!doctype html>
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="utf-8" />
@@ -1 +1 @@
1
- import{j as e,r as c,F as ee,g as J,m as se,s as te,J as ae,O as re,U as ne}from"./vendor-CHxMoJ93.js";import{P as le,a as oe,B as ie}from"./page-layout-Cu4Yj2Q_.js";import{C as K}from"./card-CAvcgkiT.js";import{I as Y,u as ce,a as de,b as me,c as xe}from"./useConfig-Uy1hlToJ.js";import{L as $}from"./label-BlmIivGH.js";import{c as B,t as d,S as ue,a as he,b as fe,d as pe,e as ge,D as Ne,f as je}from"./index-CL28Z9YZ.js";import{h as A}from"./config-hints-CApS3K_7.js";function u({className:a,...n}){return e.jsx("div",{className:B("animate-pulse rounded-md bg-slate-200",a),...n})}function ye(a){const n=new Set;for(const r of a){const l=r.trim();l.length>0&&n.add(l)}return[...n]}function we({id:a,value:n,onChange:r,options:l,placeholder:m,className:N,inputClassName:x,emptyText:C,createText:b,maxItems:S=Number.POSITIVE_INFINITY,onEnter:k}){const[v,h]=c.useState(!1),j=c.useMemo(()=>ye(l),[l]),i=n.trim().toLowerCase(),f=c.useMemo(()=>{const t=j.map((o,y)=>({option:o,index:y}));i.length>0&&t.sort((o,y)=>{const w=o.option.toLowerCase(),M=y.option.toLowerCase(),T=w===i?0:w.startsWith(i)?1:w.includes(i)?2:3,I=M===i?0:M.startsWith(i)?1:M.includes(i)?2:3;return T!==I?T-I:o.index-y.index});const g=t.map(o=>o.option);return Number.isFinite(S)?g.slice(0,Math.max(1,S)):g},[j,i,S]),P=n.trim().length>0&&j.some(t=>t===n.trim());return e.jsxs("div",{className:B("relative",N),onBlur:()=>{setTimeout(()=>h(!1),120)},children:[e.jsx(Y,{id:a,value:n,onFocus:()=>h(!0),onChange:t=>{r(t.target.value),v||h(!0)},onKeyDown:t=>{t.key==="Enter"&&(k&&(t.preventDefault(),k()),h(!1))},placeholder:m,className:B("pr-10",x)}),e.jsx("button",{type:"button",onMouseDown:t=>t.preventDefault(),onClick:()=>h(t=>!t),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(ee,{className:"h-4 w-4"})}),v&&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:[!P&&n.trim().length>0&&e.jsxs("button",{type:"button",onMouseDown:t=>t.preventDefault(),onClick:()=>{r(n.trim()),h(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50",children:[e.jsx(J,{className:"h-4 w-4 text-transparent"}),e.jsx("span",{className:"truncate text-gray-700",children:b?b.replace("{value}",n.trim()):n.trim()})]}),f.map(t=>e.jsxs("button",{type:"button",onMouseDown:g=>g.preventDefault(),onClick:()=>{r(t),h(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50",children:[e.jsx(J,{className:B("h-4 w-4",t===n.trim()?"text-primary":"text-transparent")}),e.jsx("span",{className:"truncate text-gray-700",children:t})]},t)),f.length===0&&n.trim().length===0&&e.jsx("div",{className:"px-3 py-2 text-sm text-gray-500",children:C??"No models available"})]})})]})}function z(a){if(!a||a.length===0)return[];const n=new Set;for(const r of a){const l=r.trim();l&&n.add(l)}return[...n]}function be(a,n){const r=a.trim(),l=n.trim();if(!r||!l)return r;const m=`${l}/`;return r.startsWith(m)?r.slice(m.length):r}function D(a,n){let r=a.trim();if(!r)return"";for(const l of n)r=be(r,l);return r.trim()}function ve(a,n){const r=a.trim();if(!r)return null;let l=null;for(const m of n)for(const N of m.aliases){const x=N.trim();x&&(r===x||r.startsWith(`${x}/`))&&(!l||x.length>l.score)&&(l={name:m.name,score:x.length})}return(l==null?void 0:l.name)??null}function Ie(){const{data:a,isLoading:n}=ce(),{data:r}=de(),{data:l}=me(),m=xe(),[N,x]=c.useState(""),[C,b]=c.useState(""),[S,k]=c.useState(""),[v,h]=c.useState(8192),j=l==null?void 0:l.uiHints,i=A("agents.defaults.model",j),f=A("agents.defaults.workspace",j),P=A("agents.defaults.maxTokens",j),t=c.useMemo(()=>((r==null?void 0:r.providers)??[]).map(s=>{var R,V,_,q,G;const L=(s.modelPrefix||s.name||"").trim(),p=z([s.modelPrefix||"",s.name||""]),U=z((s.defaultModels??[]).map(W=>D(W,p))),O=z((((V=(R=a==null?void 0:a.providers)==null?void 0:R[s.name])==null?void 0:V.models)??[]).map(W=>D(W,p))),F=z([...U,...O]),E=(G=(q=(_=a==null?void 0:a.providers)==null?void 0:_[s.name])==null?void 0:q.displayName)==null?void 0:G.trim();return{name:s.name,displayName:E||s.displayName||s.name,prefix:L,aliases:p,models:F}}),[r,a]),g=c.useMemo(()=>new Map(t.map(s=>[s.name,s])),[t]),o=g.get(N)??t[0],y=(o==null?void 0:o.name)??"",w=c.useMemo(()=>(o==null?void 0:o.aliases)??[],[o]),M=c.useMemo(()=>(o==null?void 0:o.models)??[],[o]);c.useEffect(()=>{N||t.length===0||x(t[0].name)},[N,t]),c.useEffect(()=>{var O,F,E;if(!((O=a==null?void 0:a.agents)!=null&&O.defaults))return;const s=(a.agents.defaults.model||"").trim(),p=ve(s,t)??((F=t[0])==null?void 0:F.name)??"",U=((E=g.get(p))==null?void 0:E.aliases)??[];x(p),b(D(s,U)),k(a.agents.defaults.workspace||""),h(a.agents.defaults.maxTokens||8192)},[a,t,g]);const T=c.useMemo(()=>{const s=new Set;for(const L of M){const p=L.trim();p&&s.add(p)}return[...s]},[M]),I=c.useMemo(()=>{const s=D(C,w);return s?!o||!o.prefix?s:`${o.prefix}/${s}`:""},[C,o,w]),Q=(i==null?void 0:i.help)??"",X=s=>{x(s),b("")},Z=s=>{b(D(s,w))},H=s=>{s.preventDefault(),m.mutate({model:I,maxTokens:v})};return n?e.jsxs("div",{className:"max-w-2xl space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{className:"h-8 w-32"}),e.jsx(u,{className:"h-4 w-48"})]}),e.jsxs(K,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx(u,{className:"h-12 w-12 rounded-xl"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{className:"h-5 w-24"}),e.jsx(u,{className:"h-3 w-32"})]})]}),e.jsx(u,{className:"h-4 w-20 mb-2"}),e.jsx(u,{className:"h-10 w-full rounded-xl"})]}),e.jsxs(K,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsx(u,{className:"h-5 w-24 mb-2"}),e.jsx(u,{className:"h-3 w-40 mb-6"}),e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx(u,{className:"h-4 w-28 mb-3"}),e.jsx(u,{className:"h-2 w-full rounded-full"})]})})]})]}):e.jsxs(le,{children:[e.jsx(oe,{title:d("modelPageTitle"),description:d("modelPageDescription")}),e.jsxs("form",{onSubmit:H,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(se,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:d("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:(i==null?void 0:i.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(ue,{value:y,onValueChange:X,children:[e.jsx(he,{className:"h-10 w-full rounded-xl",children:e.jsx(fe,{placeholder:d("providersSelectPlaceholder")})}),e.jsx(pe,{children:t.map(s=>e.jsx(ge,{value:s.name,children:s.displayName},s.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(we,{id:"model",value:C,onChange:Z,options:T,placeholder:(i==null?void 0:i.placeholder)??"gpt-5.1",className:"sm:flex-1",inputClassName:"h-10 rounded-xl",emptyText:d("modelPickerNoOptions"),createText:d("modelPickerUseCustom")},y)]}),e.jsx("p",{className:"text-xs text-gray-400",children:Q}),e.jsx("p",{className:"text-xs text-gray-500",children:d("modelInputCustomHint")}),e.jsxs("a",{href:`${Ne}/guide/model-selection`,className:"inline-flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover transition-colors",children:[e.jsx(te,{className:"h-3.5 w-3.5"}),d("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(ae,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:d("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:(f==null?void 0:f.label)??"Default Path"}),e.jsx(Y,{id:"workspace",value:S,onChange:s=>k(s.target.value),placeholder:(f==null?void 0:f.placeholder)??"/path/to/workspace",className:"rounded-xl"})]})]})]}),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-10",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white",children:e.jsx(re,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:d("generationParameters")})]}),e.jsx("div",{className:"grid grid-cols-1 gap-12",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx($,{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(P==null?void 0:P.label)??d("maxTokens")}),e.jsx("span",{className:"text-sm font-semibold text-gray-900",children:je(v)})]}),e.jsx("input",{type:"range",min:"1000",max:"32000",step:"1000",value:v,onChange:s=>h(parseInt(s.target.value)),className:"w-full h-1 bg-gray-200 rounded-full appearance-none cursor-pointer accent-primary"})]})})]}),e.jsx("div",{className:"flex justify-end pt-4",children:e.jsx(ie,{type:"submit",disabled:m.isPending,size:"lg",children:m.isPending?e.jsx(ne,{className:"h-5 w-5 animate-spin"}):d("saveChanges")})})]})]})}export{Ie as ModelConfig};
1
+ import{j as e,r as c,F as ee,g as J,m as se,s as te,J as ae,O as re,U as ne}from"./vendor-CHxMoJ93.js";import{P as le,a as oe,B as ie}from"./page-layout-COKsFqhi.js";import{C as K}from"./card-AxFsy7YF.js";import{I as Y,u as ce,a as de,b as me,c as xe}from"./useConfig-C9yQu_4f.js";import{L as $}from"./label-Chdg0Pzh.js";import{c as B,t as d,S as ue,a as he,b as fe,d as pe,e as ge,D as Ne,f as je}from"./index-CT15pXtn.js";import{h as A}from"./config-hints-CApS3K_7.js";function u({className:a,...n}){return e.jsx("div",{className:B("animate-pulse rounded-md bg-slate-200",a),...n})}function ye(a){const n=new Set;for(const r of a){const l=r.trim();l.length>0&&n.add(l)}return[...n]}function we({id:a,value:n,onChange:r,options:l,placeholder:m,className:N,inputClassName:x,emptyText:C,createText:b,maxItems:S=Number.POSITIVE_INFINITY,onEnter:k}){const[v,h]=c.useState(!1),j=c.useMemo(()=>ye(l),[l]),i=n.trim().toLowerCase(),f=c.useMemo(()=>{const t=j.map((o,y)=>({option:o,index:y}));i.length>0&&t.sort((o,y)=>{const w=o.option.toLowerCase(),M=y.option.toLowerCase(),T=w===i?0:w.startsWith(i)?1:w.includes(i)?2:3,I=M===i?0:M.startsWith(i)?1:M.includes(i)?2:3;return T!==I?T-I:o.index-y.index});const g=t.map(o=>o.option);return Number.isFinite(S)?g.slice(0,Math.max(1,S)):g},[j,i,S]),P=n.trim().length>0&&j.some(t=>t===n.trim());return e.jsxs("div",{className:B("relative",N),onBlur:()=>{setTimeout(()=>h(!1),120)},children:[e.jsx(Y,{id:a,value:n,onFocus:()=>h(!0),onChange:t=>{r(t.target.value),v||h(!0)},onKeyDown:t=>{t.key==="Enter"&&(k&&(t.preventDefault(),k()),h(!1))},placeholder:m,className:B("pr-10",x)}),e.jsx("button",{type:"button",onMouseDown:t=>t.preventDefault(),onClick:()=>h(t=>!t),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(ee,{className:"h-4 w-4"})}),v&&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:[!P&&n.trim().length>0&&e.jsxs("button",{type:"button",onMouseDown:t=>t.preventDefault(),onClick:()=>{r(n.trim()),h(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50",children:[e.jsx(J,{className:"h-4 w-4 text-transparent"}),e.jsx("span",{className:"truncate text-gray-700",children:b?b.replace("{value}",n.trim()):n.trim()})]}),f.map(t=>e.jsxs("button",{type:"button",onMouseDown:g=>g.preventDefault(),onClick:()=>{r(t),h(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50",children:[e.jsx(J,{className:B("h-4 w-4",t===n.trim()?"text-primary":"text-transparent")}),e.jsx("span",{className:"truncate text-gray-700",children:t})]},t)),f.length===0&&n.trim().length===0&&e.jsx("div",{className:"px-3 py-2 text-sm text-gray-500",children:C??"No models available"})]})})]})}function z(a){if(!a||a.length===0)return[];const n=new Set;for(const r of a){const l=r.trim();l&&n.add(l)}return[...n]}function be(a,n){const r=a.trim(),l=n.trim();if(!r||!l)return r;const m=`${l}/`;return r.startsWith(m)?r.slice(m.length):r}function D(a,n){let r=a.trim();if(!r)return"";for(const l of n)r=be(r,l);return r.trim()}function ve(a,n){const r=a.trim();if(!r)return null;let l=null;for(const m of n)for(const N of m.aliases){const x=N.trim();x&&(r===x||r.startsWith(`${x}/`))&&(!l||x.length>l.score)&&(l={name:m.name,score:x.length})}return(l==null?void 0:l.name)??null}function Ie(){const{data:a,isLoading:n}=ce(),{data:r}=de(),{data:l}=me(),m=xe(),[N,x]=c.useState(""),[C,b]=c.useState(""),[S,k]=c.useState(""),[v,h]=c.useState(8192),j=l==null?void 0:l.uiHints,i=A("agents.defaults.model",j),f=A("agents.defaults.workspace",j),P=A("agents.defaults.maxTokens",j),t=c.useMemo(()=>((r==null?void 0:r.providers)??[]).map(s=>{var R,V,_,q,G;const L=(s.modelPrefix||s.name||"").trim(),p=z([s.modelPrefix||"",s.name||""]),U=z((s.defaultModels??[]).map(W=>D(W,p))),O=z((((V=(R=a==null?void 0:a.providers)==null?void 0:R[s.name])==null?void 0:V.models)??[]).map(W=>D(W,p))),F=z([...U,...O]),E=(G=(q=(_=a==null?void 0:a.providers)==null?void 0:_[s.name])==null?void 0:q.displayName)==null?void 0:G.trim();return{name:s.name,displayName:E||s.displayName||s.name,prefix:L,aliases:p,models:F}}),[r,a]),g=c.useMemo(()=>new Map(t.map(s=>[s.name,s])),[t]),o=g.get(N)??t[0],y=(o==null?void 0:o.name)??"",w=c.useMemo(()=>(o==null?void 0:o.aliases)??[],[o]),M=c.useMemo(()=>(o==null?void 0:o.models)??[],[o]);c.useEffect(()=>{N||t.length===0||x(t[0].name)},[N,t]),c.useEffect(()=>{var O,F,E;if(!((O=a==null?void 0:a.agents)!=null&&O.defaults))return;const s=(a.agents.defaults.model||"").trim(),p=ve(s,t)??((F=t[0])==null?void 0:F.name)??"",U=((E=g.get(p))==null?void 0:E.aliases)??[];x(p),b(D(s,U)),k(a.agents.defaults.workspace||""),h(a.agents.defaults.maxTokens||8192)},[a,t,g]);const T=c.useMemo(()=>{const s=new Set;for(const L of M){const p=L.trim();p&&s.add(p)}return[...s]},[M]),I=c.useMemo(()=>{const s=D(C,w);return s?!o||!o.prefix?s:`${o.prefix}/${s}`:""},[C,o,w]),Q=(i==null?void 0:i.help)??"",X=s=>{x(s),b("")},Z=s=>{b(D(s,w))},H=s=>{s.preventDefault(),m.mutate({model:I,maxTokens:v})};return n?e.jsxs("div",{className:"max-w-2xl space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{className:"h-8 w-32"}),e.jsx(u,{className:"h-4 w-48"})]}),e.jsxs(K,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx(u,{className:"h-12 w-12 rounded-xl"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{className:"h-5 w-24"}),e.jsx(u,{className:"h-3 w-32"})]})]}),e.jsx(u,{className:"h-4 w-20 mb-2"}),e.jsx(u,{className:"h-10 w-full rounded-xl"})]}),e.jsxs(K,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsx(u,{className:"h-5 w-24 mb-2"}),e.jsx(u,{className:"h-3 w-40 mb-6"}),e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx(u,{className:"h-4 w-28 mb-3"}),e.jsx(u,{className:"h-2 w-full rounded-full"})]})})]})]}):e.jsxs(le,{children:[e.jsx(oe,{title:d("modelPageTitle"),description:d("modelPageDescription")}),e.jsxs("form",{onSubmit:H,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(se,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:d("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:(i==null?void 0:i.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(ue,{value:y,onValueChange:X,children:[e.jsx(he,{className:"h-10 w-full rounded-xl",children:e.jsx(fe,{placeholder:d("providersSelectPlaceholder")})}),e.jsx(pe,{children:t.map(s=>e.jsx(ge,{value:s.name,children:s.displayName},s.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(we,{id:"model",value:C,onChange:Z,options:T,placeholder:(i==null?void 0:i.placeholder)??"gpt-5.1",className:"sm:flex-1",inputClassName:"h-10 rounded-xl",emptyText:d("modelPickerNoOptions"),createText:d("modelPickerUseCustom")},y)]}),e.jsx("p",{className:"text-xs text-gray-400",children:Q}),e.jsx("p",{className:"text-xs text-gray-500",children:d("modelInputCustomHint")}),e.jsxs("a",{href:`${Ne}/guide/model-selection`,className:"inline-flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover transition-colors",children:[e.jsx(te,{className:"h-3.5 w-3.5"}),d("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(ae,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:d("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:(f==null?void 0:f.label)??"Default Path"}),e.jsx(Y,{id:"workspace",value:S,onChange:s=>k(s.target.value),placeholder:(f==null?void 0:f.placeholder)??"/path/to/workspace",className:"rounded-xl"})]})]})]}),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-10",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white",children:e.jsx(re,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:d("generationParameters")})]}),e.jsx("div",{className:"grid grid-cols-1 gap-12",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx($,{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(P==null?void 0:P.label)??d("maxTokens")}),e.jsx("span",{className:"text-sm font-semibold text-gray-900",children:je(v)})]}),e.jsx("input",{type:"range",min:"1000",max:"32000",step:"1000",value:v,onChange:s=>h(parseInt(s.target.value)),className:"w-full h-1 bg-gray-200 rounded-full appearance-none cursor-pointer accent-primary"})]})})]}),e.jsx("div",{className:"flex justify-end pt-4",children:e.jsx(ie,{type:"submit",disabled:m.isPending,size:"lg",children:m.isPending?e.jsx(ne,{className:"h-5 w-5 animate-spin"}):d("saveChanges")})})]})]})}export{Ie as ModelConfig};
@@ -1 +1 @@
1
- import{r as x,j as e,aa as Ce,ab as Pe,a8 as pe,a6 as ie,ac as xe,ad as Se,C as De,ae as Ee,af as re,a0 as Me,K as Le}from"./vendor-CHxMoJ93.js";import{I as K,u as ye,a as fe,b as ge,g as ke,h as Be,i as Te,j as Ke}from"./useConfig-Uy1hlToJ.js";import{B as T,P as Ie,a as $e}from"./page-layout-Cu4Yj2Q_.js";import{L as z}from"./label-BlmIivGH.js";import{c as X,t,S as Fe,a as _e,b as Oe,d as Re,e as ze}from"./index-CL28Z9YZ.js";import{C as He,a as We,S as je,b as Ge,c as Ve,L as Ue,g as qe}from"./logos-BoshQeun.js";import{h as q}from"./config-hints-CApS3K_7.js";import{T as Qe}from"./tabs-custom-B4CXzsVy.js";function Xe({maskedValue:s,isSet:a,className:r,value:i,onChange:y,placeholder:b,...f}){const[c,u]=x.useState(!1),[g,p]=x.useState(!1),A=typeof i=="string"&&i.length>0,S=a&&!A&&!g;return e.jsxs("div",{className:"relative",children:[S?e.jsx("div",{onClick:()=>p(!0),className:X("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",r),children:"••••••••••••"}):e.jsx(K,{type:c?"text":"password",className:X("pr-12",r),value:i,onChange:y,onBlur:()=>{A||p(!1)},placeholder:b,autoFocus:g,...f}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:(a||A)&&e.jsx(T,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>u(!c),children:c?e.jsx(Ce,{className:"h-4 w-4"}):e.jsx(Pe,{className:"h-4 w-4"})})})]})}function Ye({value:s,onChange:a,className:r}){const i=s?Object.entries(s):[],y=(c,u,g)=>{const p=[...i];p[c]=[u,g],a(Object.fromEntries(p))},b=()=>{a({...s,"":""})},f=c=>{const u=i.filter((g,p)=>p!==c);a(Object.fromEntries(u))};return e.jsxs("div",{className:X("space-y-2",r),children:[i.map(([c,u],g)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{type:"text",value:c,onChange:p=>y(g,p.target.value,u),placeholder:t("headerName"),className:"flex-1"}),e.jsx(K,{type:"text",value:u,onChange:p=>y(g,c,p.target.value),placeholder:t("headerValue"),className:"flex-1"}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>f(g),children:e.jsx(pe,{className:"h-4 w-4 text-red-500"})})]},g)),e.jsxs(T,{type:"button",variant:"outline",size:"sm",onClick:b,children:[e.jsx(ie,{className:"h-4 w-4 mr-2"}),t("add")]})]})}function Q(s){if(!s)return null;const a=Object.entries(s).map(([r,i])=>[r.trim(),i]).filter(([r])=>r.length>0);return a.length===0?null:Object.fromEntries(a)}function he(s,a){const r=Q(s),i=Q(a);if(r===null&&i===null)return!0;if(!r||!i)return!1;const y=Object.entries(r).sort(([f],[c])=>f.localeCompare(c)),b=Object.entries(i).sort(([f],[c])=>f.localeCompare(c));return y.length!==b.length?!1:y.every(([f,c],u)=>f===b[u][0]&&c===b[u][1])}function ne(s){if(!s||s.length===0)return[];const a=new Set;for(const r of s){const i=r.trim();i&&a.add(i)}return[...a]}function Je(s,a){const r=s.trim();if(!r||!a.trim())return r;const i=`${a.trim()}/`;return r.startsWith(i)?r.slice(i.length):r}function J(s,a){let r=s.trim();if(!r)return"";for(const i of a){const y=i.trim();y&&(r=Je(r,y))}return r.trim()}function le(s,a){return s.length!==a.length?!1:s.every((r,i)=>r===a[i])}function Ze(s,a){const r=[...s];for(const i of a)r.includes(i)||r.push(i);return r}function es(s,a){return a.length===0?s:a.every(i=>!s.includes(i))?Ze(s,a):a}function ss(s,a){return le(s,a)?[]:s}function ts({providerName:s,onProviderDeleted:a}){const{data:r}=ye(),{data:i}=fe(),{data:y}=ge(),b=ke(),f=Be(),c=Te(),[u,g]=x.useState(""),[p,A]=x.useState(""),[S,H]=x.useState(null),[L,C]=x.useState("auto"),[w,I]=x.useState([]),[d,m]=x.useState(""),[N,v]=x.useState(""),[D,$]=x.useState(!1),[k,B]=x.useState(!1),l=i==null?void 0:i.providers.find(n=>n.name===s),o=s?r==null?void 0:r.providers[s]:null,Y=y==null?void 0:y.uiHints,F=!!(l!=null&&l.isCustom),_=s?q(`providers.${s}.apiKey`,Y):void 0,E=s?q(`providers.${s}.apiBase`,Y):void 0,Z=s?q(`providers.${s}.extraHeaders`,Y):void 0,ee=s?q(`providers.${s}.wireApi`,Y):void 0,oe=(l==null?void 0:l.displayName)||s||"",O=((o==null?void 0:o.displayName)||"").trim()||oe,be=N.trim()||O||s||t("providersSelectPlaceholder"),ce=(l==null?void 0:l.modelPrefix)||s||"",R=x.useMemo(()=>ne([ce,s||""]),[ce,s]),se=(l==null?void 0:l.defaultApiBase)||"",W=(o==null?void 0:o.apiBase)||se,te=Q((o==null?void 0:o.extraHeaders)||null),G=(o==null?void 0:o.wireApi)||(l==null?void 0:l.defaultWireApi)||"auto",ae=x.useMemo(()=>ne(((l==null?void 0:l.defaultModels)??[]).map(n=>J(n,R))),[l==null?void 0:l.defaultModels,R]),de=x.useMemo(()=>ne(((o==null?void 0:o.models)??[]).map(n=>J(n,R))),[o==null?void 0:o.models,R]),V=x.useMemo(()=>es(ae,de),[ae,de]);s==="minimax"?t("providerApiBaseHelpMinimax"):E!=null&&E.help||t("providerApiBaseHelp"),x.useEffect(()=>{if(!s){g(""),A(""),H(null),C("auto"),I([]),m(""),v("");return}g(""),A(W),H((o==null?void 0:o.extraHeaders)||null),C(G),I(V),m(""),v(O)},[s,W,o==null?void 0:o.extraHeaders,G,V,O]);const me=x.useMemo(()=>{if(!s)return!1;const n=u.trim().length>0,j=p.trim()!==W.trim(),P=!he(S,te),h=l!=null&&l.supportsWireApi?L!==G:!1,M=!le(w,V),U=F?N.trim()!==O:!1;return n||j||P||h||M||U},[s,F,N,O,u,p,W,S,te,l==null?void 0:l.supportsWireApi,L,G,w,V]),ue=()=>{const n=J(d,R);if(n){if(w.includes(n)){m("");return}I(j=>[...j,n]),m("")}},Ne=n=>{if(n.preventDefault(),!s)return;const j={},P=u.trim(),h=p.trim(),M=Q(S),U=N.trim();F&&U!==O&&(j.displayName=U.length>0?U:null),P.length>0&&(j.apiKey=P),h!==W.trim()&&(j.apiBase=h.length>0&&h!==se?h:null),he(M,te)||(j.extraHeaders=M),l!=null&&l.supportsWireApi&&L!==G&&(j.wireApi=L),le(w,V)||(j.models=ss(w,ae)),b.mutate({provider:s,data:j})},ve=async()=>{if(!s)return;const n=w.find(h=>h.trim().length>0)??"",j=J(n,R),P={apiBase:p.trim(),extraHeaders:Q(S),model:j||null};u.trim().length>0&&(P.apiKey=u.trim()),l!=null&&l.supportsWireApi&&(P.wireApi=L);try{const h=await c.mutateAsync({provider:s,data:P});if(h.success){re.success(`${t("providerTestConnectionSuccess")} (${h.latencyMs}ms)`);return}const M=[`provider=${h.provider}`,`latency=${h.latencyMs}ms`];h.model&&M.push(`model=${h.model}`),re.error(`${t("providerTestConnectionFailed")}: ${h.message} | ${M.join(" | ")}`)}catch(h){const M=h instanceof Error?h.message:String(h);re.error(`${t("providerTestConnectionFailed")}: ${M}`)}},we=async()=>{if(!(!s||!F||!window.confirm(t("providerDeleteConfirm"))))try{await f.mutateAsync({provider:s}),a==null||a(s)}catch{}};if(!s||!l||!o)return e.jsx("div",{className:He,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 Ae=o.apiKeySet?t("statusReady"):t("statusSetup");return e.jsxs("div",{className:We,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:be}),e.jsxs("div",{className:"flex items-center gap-3",children:[F&&e.jsx("button",{type:"button",onClick:we,disabled:f.isPending,className:"text-gray-400 hover:text-red-500 transition-colors",title:t("providerDelete"),children:e.jsx(pe,{className:"h-4 w-4"})}),e.jsx(je,{status:o.apiKeySet?"ready":"setup",label:Ae})]})]})}),e.jsxs("form",{onSubmit:Ne,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:[F&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"providerDisplayName",className:"text-sm font-medium text-gray-900",children:t("providerDisplayName")}),e.jsx(K,{id:"providerDisplayName",type:"text",value:N,onChange:n=>v(n.target.value),placeholder:oe||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(z,{htmlFor:"apiKey",className:"text-sm font-medium text-gray-900",children:(_==null?void 0:_.label)??t("apiKey")}),e.jsx(Xe,{id:"apiKey",value:u,isSet:o.apiKeySet,onChange:n=>g(n.target.value),placeholder:(_==null?void 0:_.placeholder)??t("enterApiKey"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:t("leaveBlankToKeepUnchanged")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"apiBase",className:"text-sm font-medium text-gray-900",children:(E==null?void 0:E.label)??t("apiBase")}),e.jsx(K,{id:"apiBase",type:"text",value:p,onChange:n=>A(n.target.value),placeholder:se||(E==null?void 0:E.placeholder)||"https://api.example.com",className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:t("providerApiBaseHelpShort")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(z,{className:"text-sm font-medium text-gray-900",children:t("providerModelsTitle")}),!k&&e.jsxs("button",{type:"button",onClick:()=>B(!0),className:"text-xs text-primary hover:text-primary/80 font-medium flex items-center gap-1",children:[e.jsx(ie,{className:"h-3 w-3"}),t("providerAddModel")]})]}),k&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{value:d,onChange:n=>m(n.target.value),onKeyDown:n=>{n.key==="Enter"&&(n.preventDefault(),ue()),n.key==="Escape"&&(B(!1),m(""))},placeholder:t("providerModelInputPlaceholder"),className:"flex-1 rounded-xl",autoFocus:!0}),e.jsx(T,{type:"button",size:"sm",onClick:ue,disabled:d.trim().length===0,children:t("add")}),e.jsx(T,{type:"button",size:"sm",variant:"ghost",onClick:()=>{B(!1),m("")},children:e.jsx(xe,{className:"h-4 w-4"})})]}),w.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")}),!k&&e.jsx("button",{type:"button",onClick:()=>B(!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:w.map(n=>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:n}),e.jsx("button",{type:"button",onClick:()=>I(j=>j.filter(P=>P!==n)),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(xe,{className:"h-3 w-3"})})]},n))})]}),e.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>$(!D),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(Se,{className:"h-3.5 w-3.5"}),t("providerAdvancedSettings")]}),e.jsx(De,{className:`h-4 w-4 transition-transform ${D?"rotate-180":""}`})]}),D&&e.jsxs("div",{className:"mt-4 space-y-5",children:[l.supportsWireApi&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"wireApi",className:"text-sm font-medium text-gray-900",children:(ee==null?void 0:ee.label)??t("wireApi")}),e.jsxs(Fe,{value:L,onValueChange:n=>C(n),children:[e.jsx(_e,{className:"rounded-xl",children:e.jsx(Oe,{})}),e.jsx(Re,{children:(l.wireApiOptions||["auto","chat","responses"]).map(n=>e.jsx(ze,{value:n,children:n==="chat"?t("wireApiChat"):n==="responses"?t("wireApiResponses"):t("wireApiAuto")},n))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{className:"text-sm font-medium text-gray-900",children:(Z==null?void 0:Z.label)??t("extraHeaders")}),e.jsx(Ye,{value:S,onChange:H}),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(T,{type:"button",variant:"outline",size:"sm",onClick:ve,disabled:c.isPending,children:[e.jsx(Ee,{className:"mr-1.5 h-4 w-4"}),c.isPending?t("providerTestingConnection"):t("providerTestConnection")]}),e.jsx(T,{type:"submit",disabled:b.isPending||!me,children:b.isPending?t("saving"):me?t("save"):t("unchanged")})]})]})]})}function as(s){if(!s)return null;try{const a=new URL(s),r=a.pathname&&a.pathname!=="/"?a.pathname:"";return`${a.host}${r}`}catch{return s.replace(/^https?:\/\//,"")}}function xs(){const{data:s}=ye(),{data:a}=fe(),{data:r}=ge(),i=Ke(),[y,b]=x.useState("installed"),[f,c]=x.useState(),[u,g]=x.useState(""),p=r==null?void 0:r.uiHints,A=(a==null?void 0:a.providers)??[],S=(s==null?void 0:s.providers)??{},H=A.filter(d=>{var m;return(m=S[d.name])==null?void 0:m.apiKeySet}).length,L=[{id:"installed",label:t("providersTabConfigured"),count:H},{id:"all",label:t("providersTabAll"),count:A.length}],C=x.useMemo(()=>{const d=(a==null?void 0:a.providers)??[],m=(s==null?void 0:s.providers)??{},N=u.trim().toLowerCase();return d.filter(v=>{var D;return y==="installed"?!!((D=m[v.name])!=null&&D.apiKeySet):!0}).filter(v=>{var k,B;return N?(((B=(k=m[v.name])==null?void 0:k.displayName)==null?void 0:B.trim())||v.displayName||v.name).toLowerCase().includes(N)||v.name.toLowerCase().includes(N):!0})},[a,s,y,u]);x.useEffect(()=>{if(C.length===0){c(void 0);return}C.some(m=>m.name===f)||c(C[0].name)},[C,f]);const w=f,I=async()=>{try{const d=await i.mutateAsync({data:{}});b("all"),g(""),c(d.name)}catch{}};return!s||!a?e.jsx("div",{className:"p-8",children:t("providersLoading")}):e.jsxs(Ie,{children:[e.jsx($e,{title:t("providersPageTitle"),description:t("providersPageDescription")}),e.jsxs("div",{className:Ge,children:[e.jsxs("section",{className:Ve,children:[e.jsxs("div",{className:"border-b border-gray-100 px-4 pt-4 pb-3 space-y-3",children:[e.jsx(Qe,{tabs:L,activeTab:y,onChange:b,className:"mb-0"}),e.jsxs(T,{type:"button",variant:"outline",className:"w-full justify-center",onClick:I,disabled:i.isPending,children:[e.jsx(ie,{className:"mr-2 h-4 w-4"}),i.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(Me,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx(K,{value:u,onChange:d=>g(d.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:[C.map(d=>{var o;const m=s.providers[d.name],N=!!(m!=null&&m.apiKeySet),v=w===d.name,D=((o=m==null?void 0:m.displayName)==null?void 0:o.trim())||d.displayName||d.name,$=q(`providers.${d.name}`,p),k=(m==null?void 0:m.apiBase)||d.defaultApiBase||"",l=as(k)||($==null?void 0:$.help)||t("providersDefaultDescription");return e.jsx("button",{type:"button",onClick:()=>c(d.name),className:X("w-full rounded-xl border p-2.5 text-left transition-all",v?"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(Ue,{name:d.name,src:qe(d.name),className:X("h-10 w-10 rounded-lg border",N?"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:d.name[0]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:D}),e.jsx("p",{className:"line-clamp-1 text-[11px] text-gray-500",children:l})]})]}),e.jsx(je,{status:N?"ready":"setup",label:N?t("statusReady"):t("statusSetup"),className:"min-w-[56px] justify-center"})]})},d.name)}),C.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(Le,{className:"h-5 w-5 text-gray-300"})}),e.jsx("p",{className:"text-sm font-medium text-gray-700",children:t("providersNoMatch")})]})]})]}),e.jsx(ts,{providerName:w,onProviderDeleted:d=>{d===f&&c(void 0)}})]})]})}export{xs as ProvidersList};
1
+ import{r as x,j as e,aa as Ce,ab as Pe,a8 as pe,a6 as ie,ac as xe,ad as Se,C as De,ae as Ee,af as re,a0 as Me,K as Le}from"./vendor-CHxMoJ93.js";import{I as K,u as ye,a as fe,b as ge,g as ke,h as Be,i as Te,j as Ke}from"./useConfig-C9yQu_4f.js";import{B as T,P as Ie,a as $e}from"./page-layout-COKsFqhi.js";import{L as z}from"./label-Chdg0Pzh.js";import{c as X,t,S as Fe,a as _e,b as Oe,d as Re,e as ze}from"./index-CT15pXtn.js";import{C as He,a as We,S as je,b as Ge,c as Ve,L as Ue,g as qe}from"./logos-csBmIIFU.js";import{h as q}from"./config-hints-CApS3K_7.js";import{T as Qe}from"./tabs-custom-BYQWSGw3.js";function Xe({maskedValue:s,isSet:a,className:r,value:i,onChange:y,placeholder:b,...f}){const[c,u]=x.useState(!1),[g,p]=x.useState(!1),A=typeof i=="string"&&i.length>0,S=a&&!A&&!g;return e.jsxs("div",{className:"relative",children:[S?e.jsx("div",{onClick:()=>p(!0),className:X("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",r),children:"••••••••••••"}):e.jsx(K,{type:c?"text":"password",className:X("pr-12",r),value:i,onChange:y,onBlur:()=>{A||p(!1)},placeholder:b,autoFocus:g,...f}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:(a||A)&&e.jsx(T,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>u(!c),children:c?e.jsx(Ce,{className:"h-4 w-4"}):e.jsx(Pe,{className:"h-4 w-4"})})})]})}function Ye({value:s,onChange:a,className:r}){const i=s?Object.entries(s):[],y=(c,u,g)=>{const p=[...i];p[c]=[u,g],a(Object.fromEntries(p))},b=()=>{a({...s,"":""})},f=c=>{const u=i.filter((g,p)=>p!==c);a(Object.fromEntries(u))};return e.jsxs("div",{className:X("space-y-2",r),children:[i.map(([c,u],g)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{type:"text",value:c,onChange:p=>y(g,p.target.value,u),placeholder:t("headerName"),className:"flex-1"}),e.jsx(K,{type:"text",value:u,onChange:p=>y(g,c,p.target.value),placeholder:t("headerValue"),className:"flex-1"}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>f(g),children:e.jsx(pe,{className:"h-4 w-4 text-red-500"})})]},g)),e.jsxs(T,{type:"button",variant:"outline",size:"sm",onClick:b,children:[e.jsx(ie,{className:"h-4 w-4 mr-2"}),t("add")]})]})}function Q(s){if(!s)return null;const a=Object.entries(s).map(([r,i])=>[r.trim(),i]).filter(([r])=>r.length>0);return a.length===0?null:Object.fromEntries(a)}function he(s,a){const r=Q(s),i=Q(a);if(r===null&&i===null)return!0;if(!r||!i)return!1;const y=Object.entries(r).sort(([f],[c])=>f.localeCompare(c)),b=Object.entries(i).sort(([f],[c])=>f.localeCompare(c));return y.length!==b.length?!1:y.every(([f,c],u)=>f===b[u][0]&&c===b[u][1])}function ne(s){if(!s||s.length===0)return[];const a=new Set;for(const r of s){const i=r.trim();i&&a.add(i)}return[...a]}function Je(s,a){const r=s.trim();if(!r||!a.trim())return r;const i=`${a.trim()}/`;return r.startsWith(i)?r.slice(i.length):r}function J(s,a){let r=s.trim();if(!r)return"";for(const i of a){const y=i.trim();y&&(r=Je(r,y))}return r.trim()}function le(s,a){return s.length!==a.length?!1:s.every((r,i)=>r===a[i])}function Ze(s,a){const r=[...s];for(const i of a)r.includes(i)||r.push(i);return r}function es(s,a){return a.length===0?s:a.every(i=>!s.includes(i))?Ze(s,a):a}function ss(s,a){return le(s,a)?[]:s}function ts({providerName:s,onProviderDeleted:a}){const{data:r}=ye(),{data:i}=fe(),{data:y}=ge(),b=ke(),f=Be(),c=Te(),[u,g]=x.useState(""),[p,A]=x.useState(""),[S,H]=x.useState(null),[L,C]=x.useState("auto"),[w,I]=x.useState([]),[d,m]=x.useState(""),[N,v]=x.useState(""),[D,$]=x.useState(!1),[k,B]=x.useState(!1),l=i==null?void 0:i.providers.find(n=>n.name===s),o=s?r==null?void 0:r.providers[s]:null,Y=y==null?void 0:y.uiHints,F=!!(l!=null&&l.isCustom),_=s?q(`providers.${s}.apiKey`,Y):void 0,E=s?q(`providers.${s}.apiBase`,Y):void 0,Z=s?q(`providers.${s}.extraHeaders`,Y):void 0,ee=s?q(`providers.${s}.wireApi`,Y):void 0,oe=(l==null?void 0:l.displayName)||s||"",O=((o==null?void 0:o.displayName)||"").trim()||oe,be=N.trim()||O||s||t("providersSelectPlaceholder"),ce=(l==null?void 0:l.modelPrefix)||s||"",R=x.useMemo(()=>ne([ce,s||""]),[ce,s]),se=(l==null?void 0:l.defaultApiBase)||"",W=(o==null?void 0:o.apiBase)||se,te=Q((o==null?void 0:o.extraHeaders)||null),G=(o==null?void 0:o.wireApi)||(l==null?void 0:l.defaultWireApi)||"auto",ae=x.useMemo(()=>ne(((l==null?void 0:l.defaultModels)??[]).map(n=>J(n,R))),[l==null?void 0:l.defaultModels,R]),de=x.useMemo(()=>ne(((o==null?void 0:o.models)??[]).map(n=>J(n,R))),[o==null?void 0:o.models,R]),V=x.useMemo(()=>es(ae,de),[ae,de]);s==="minimax"?t("providerApiBaseHelpMinimax"):E!=null&&E.help||t("providerApiBaseHelp"),x.useEffect(()=>{if(!s){g(""),A(""),H(null),C("auto"),I([]),m(""),v("");return}g(""),A(W),H((o==null?void 0:o.extraHeaders)||null),C(G),I(V),m(""),v(O)},[s,W,o==null?void 0:o.extraHeaders,G,V,O]);const me=x.useMemo(()=>{if(!s)return!1;const n=u.trim().length>0,j=p.trim()!==W.trim(),P=!he(S,te),h=l!=null&&l.supportsWireApi?L!==G:!1,M=!le(w,V),U=F?N.trim()!==O:!1;return n||j||P||h||M||U},[s,F,N,O,u,p,W,S,te,l==null?void 0:l.supportsWireApi,L,G,w,V]),ue=()=>{const n=J(d,R);if(n){if(w.includes(n)){m("");return}I(j=>[...j,n]),m("")}},Ne=n=>{if(n.preventDefault(),!s)return;const j={},P=u.trim(),h=p.trim(),M=Q(S),U=N.trim();F&&U!==O&&(j.displayName=U.length>0?U:null),P.length>0&&(j.apiKey=P),h!==W.trim()&&(j.apiBase=h.length>0&&h!==se?h:null),he(M,te)||(j.extraHeaders=M),l!=null&&l.supportsWireApi&&L!==G&&(j.wireApi=L),le(w,V)||(j.models=ss(w,ae)),b.mutate({provider:s,data:j})},ve=async()=>{if(!s)return;const n=w.find(h=>h.trim().length>0)??"",j=J(n,R),P={apiBase:p.trim(),extraHeaders:Q(S),model:j||null};u.trim().length>0&&(P.apiKey=u.trim()),l!=null&&l.supportsWireApi&&(P.wireApi=L);try{const h=await c.mutateAsync({provider:s,data:P});if(h.success){re.success(`${t("providerTestConnectionSuccess")} (${h.latencyMs}ms)`);return}const M=[`provider=${h.provider}`,`latency=${h.latencyMs}ms`];h.model&&M.push(`model=${h.model}`),re.error(`${t("providerTestConnectionFailed")}: ${h.message} | ${M.join(" | ")}`)}catch(h){const M=h instanceof Error?h.message:String(h);re.error(`${t("providerTestConnectionFailed")}: ${M}`)}},we=async()=>{if(!(!s||!F||!window.confirm(t("providerDeleteConfirm"))))try{await f.mutateAsync({provider:s}),a==null||a(s)}catch{}};if(!s||!l||!o)return e.jsx("div",{className:He,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 Ae=o.apiKeySet?t("statusReady"):t("statusSetup");return e.jsxs("div",{className:We,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:be}),e.jsxs("div",{className:"flex items-center gap-3",children:[F&&e.jsx("button",{type:"button",onClick:we,disabled:f.isPending,className:"text-gray-400 hover:text-red-500 transition-colors",title:t("providerDelete"),children:e.jsx(pe,{className:"h-4 w-4"})}),e.jsx(je,{status:o.apiKeySet?"ready":"setup",label:Ae})]})]})}),e.jsxs("form",{onSubmit:Ne,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:[F&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"providerDisplayName",className:"text-sm font-medium text-gray-900",children:t("providerDisplayName")}),e.jsx(K,{id:"providerDisplayName",type:"text",value:N,onChange:n=>v(n.target.value),placeholder:oe||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(z,{htmlFor:"apiKey",className:"text-sm font-medium text-gray-900",children:(_==null?void 0:_.label)??t("apiKey")}),e.jsx(Xe,{id:"apiKey",value:u,isSet:o.apiKeySet,onChange:n=>g(n.target.value),placeholder:(_==null?void 0:_.placeholder)??t("enterApiKey"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:t("leaveBlankToKeepUnchanged")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"apiBase",className:"text-sm font-medium text-gray-900",children:(E==null?void 0:E.label)??t("apiBase")}),e.jsx(K,{id:"apiBase",type:"text",value:p,onChange:n=>A(n.target.value),placeholder:se||(E==null?void 0:E.placeholder)||"https://api.example.com",className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:t("providerApiBaseHelpShort")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(z,{className:"text-sm font-medium text-gray-900",children:t("providerModelsTitle")}),!k&&e.jsxs("button",{type:"button",onClick:()=>B(!0),className:"text-xs text-primary hover:text-primary/80 font-medium flex items-center gap-1",children:[e.jsx(ie,{className:"h-3 w-3"}),t("providerAddModel")]})]}),k&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{value:d,onChange:n=>m(n.target.value),onKeyDown:n=>{n.key==="Enter"&&(n.preventDefault(),ue()),n.key==="Escape"&&(B(!1),m(""))},placeholder:t("providerModelInputPlaceholder"),className:"flex-1 rounded-xl",autoFocus:!0}),e.jsx(T,{type:"button",size:"sm",onClick:ue,disabled:d.trim().length===0,children:t("add")}),e.jsx(T,{type:"button",size:"sm",variant:"ghost",onClick:()=>{B(!1),m("")},children:e.jsx(xe,{className:"h-4 w-4"})})]}),w.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")}),!k&&e.jsx("button",{type:"button",onClick:()=>B(!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:w.map(n=>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:n}),e.jsx("button",{type:"button",onClick:()=>I(j=>j.filter(P=>P!==n)),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(xe,{className:"h-3 w-3"})})]},n))})]}),e.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>$(!D),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(Se,{className:"h-3.5 w-3.5"}),t("providerAdvancedSettings")]}),e.jsx(De,{className:`h-4 w-4 transition-transform ${D?"rotate-180":""}`})]}),D&&e.jsxs("div",{className:"mt-4 space-y-5",children:[l.supportsWireApi&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"wireApi",className:"text-sm font-medium text-gray-900",children:(ee==null?void 0:ee.label)??t("wireApi")}),e.jsxs(Fe,{value:L,onValueChange:n=>C(n),children:[e.jsx(_e,{className:"rounded-xl",children:e.jsx(Oe,{})}),e.jsx(Re,{children:(l.wireApiOptions||["auto","chat","responses"]).map(n=>e.jsx(ze,{value:n,children:n==="chat"?t("wireApiChat"):n==="responses"?t("wireApiResponses"):t("wireApiAuto")},n))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{className:"text-sm font-medium text-gray-900",children:(Z==null?void 0:Z.label)??t("extraHeaders")}),e.jsx(Ye,{value:S,onChange:H}),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(T,{type:"button",variant:"outline",size:"sm",onClick:ve,disabled:c.isPending,children:[e.jsx(Ee,{className:"mr-1.5 h-4 w-4"}),c.isPending?t("providerTestingConnection"):t("providerTestConnection")]}),e.jsx(T,{type:"submit",disabled:b.isPending||!me,children:b.isPending?t("saving"):me?t("save"):t("unchanged")})]})]})]})}function as(s){if(!s)return null;try{const a=new URL(s),r=a.pathname&&a.pathname!=="/"?a.pathname:"";return`${a.host}${r}`}catch{return s.replace(/^https?:\/\//,"")}}function xs(){const{data:s}=ye(),{data:a}=fe(),{data:r}=ge(),i=Ke(),[y,b]=x.useState("installed"),[f,c]=x.useState(),[u,g]=x.useState(""),p=r==null?void 0:r.uiHints,A=(a==null?void 0:a.providers)??[],S=(s==null?void 0:s.providers)??{},H=A.filter(d=>{var m;return(m=S[d.name])==null?void 0:m.apiKeySet}).length,L=[{id:"installed",label:t("providersTabConfigured"),count:H},{id:"all",label:t("providersTabAll"),count:A.length}],C=x.useMemo(()=>{const d=(a==null?void 0:a.providers)??[],m=(s==null?void 0:s.providers)??{},N=u.trim().toLowerCase();return d.filter(v=>{var D;return y==="installed"?!!((D=m[v.name])!=null&&D.apiKeySet):!0}).filter(v=>{var k,B;return N?(((B=(k=m[v.name])==null?void 0:k.displayName)==null?void 0:B.trim())||v.displayName||v.name).toLowerCase().includes(N)||v.name.toLowerCase().includes(N):!0})},[a,s,y,u]);x.useEffect(()=>{if(C.length===0){c(void 0);return}C.some(m=>m.name===f)||c(C[0].name)},[C,f]);const w=f,I=async()=>{try{const d=await i.mutateAsync({data:{}});b("all"),g(""),c(d.name)}catch{}};return!s||!a?e.jsx("div",{className:"p-8",children:t("providersLoading")}):e.jsxs(Ie,{children:[e.jsx($e,{title:t("providersPageTitle"),description:t("providersPageDescription")}),e.jsxs("div",{className:Ge,children:[e.jsxs("section",{className:Ve,children:[e.jsxs("div",{className:"border-b border-gray-100 px-4 pt-4 pb-3 space-y-3",children:[e.jsx(Qe,{tabs:L,activeTab:y,onChange:b,className:"mb-0"}),e.jsxs(T,{type:"button",variant:"outline",className:"w-full justify-center",onClick:I,disabled:i.isPending,children:[e.jsx(ie,{className:"mr-2 h-4 w-4"}),i.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(Me,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx(K,{value:u,onChange:d=>g(d.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:[C.map(d=>{var o;const m=s.providers[d.name],N=!!(m!=null&&m.apiKeySet),v=w===d.name,D=((o=m==null?void 0:m.displayName)==null?void 0:o.trim())||d.displayName||d.name,$=q(`providers.${d.name}`,p),k=(m==null?void 0:m.apiBase)||d.defaultApiBase||"",l=as(k)||($==null?void 0:$.help)||t("providersDefaultDescription");return e.jsx("button",{type:"button",onClick:()=>c(d.name),className:X("w-full rounded-xl border p-2.5 text-left transition-all",v?"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(Ue,{name:d.name,src:qe(d.name),className:X("h-10 w-10 rounded-lg border",N?"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:d.name[0]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:D}),e.jsx("p",{className:"line-clamp-1 text-[11px] text-gray-500",children:l})]})]}),e.jsx(je,{status:N?"ready":"setup",label:N?t("statusReady"):t("statusSetup"),className:"min-w-[56px] justify-center"})]})},d.name)}),C.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(Le,{className:"h-5 w-5 text-gray-300"})}),e.jsx("p",{className:"text-sm font-medium text-gray-700",children:t("providersNoMatch")})]})]})]}),e.jsx(ts,{providerName:w,onProviderDeleted:d=>{d===f&&c(void 0)}})]})]})}export{xs as ProvidersList};
@@ -1 +1 @@
1
- import{r as p,j as e,a8 as Y,a6 as Z,al as le,af as H}from"./vendor-CHxMoJ93.js";import{u as oe,b as ce,m as de,I as d}from"./useConfig-Uy1hlToJ.js";import{P as ie,a as me,B as N}from"./page-layout-Cu4Yj2Q_.js";import{C as B,a as M,b as O,c as R,d as $}from"./card-CAvcgkiT.js";import{S as he}from"./switch-C5wm6PbF.js";import{t,S as ee,a as ae,b as se,d as te,e as P}from"./index-CL28Z9YZ.js";import{h as I}from"./config-hints-CApS3K_7.js";const ue=[{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 pe(){return{id:"",default:!1,workspace:"",model:"",maxTokens:void 0,contextTokens:void 0,maxToolIterations:void 0}}function xe(){return{agentId:"",match:{channel:"",accountId:""}}}function z(i){const w=i.trim();if(!w)return;const x=Number.parseInt(w,10);return Number.isFinite(x)?x:void 0}function ye(){const{data:i,isLoading:w}=oe(),{data:x}=ce(),_=de(),[S,y]=p.useState([]),[D,b]=p.useState([]),[L,q]=p.useState("per-channel-peer"),[K,F]=p.useState(0),[V,U]=p.useState(2e5);p.useEffect(()=>{var a,r,n;i&&(y((i.agents.list??[]).map(s=>({id:s.id??"",default:!!s.default,workspace:s.workspace??"",model:s.model??"",maxTokens:s.maxTokens,contextTokens:s.contextTokens,maxToolIterations:s.maxToolIterations}))),b((i.bindings??[]).map(s=>{var o,l,c;return{agentId:s.agentId??"",match:{channel:((o=s.match)==null?void 0:o.channel)??"",accountId:((l=s.match)==null?void 0:l.accountId)??"",peer:(c=s.match)!=null&&c.peer?{kind:s.match.peer.kind,id:s.match.peer.id}:void 0}}})),q(((a=i.session)==null?void 0:a.dmScope)??"per-channel-peer"),F(((n=(r=i.session)==null?void 0:r.agentToAgent)==null?void 0:n.maxPingPongTurns)??0),U(i.agents.defaults.contextTokens??2e5))},[i]);const g=x==null?void 0:x.uiHints,h=I("session.dmScope",g),j=I("session.agentToAgent.maxPingPongTurns",g),f=I("agents.defaults.contextTokens",g),A=I("agents.list.*.contextTokens",g),v=I("agents.list",g),k=I("bindings",g),re=p.useMemo(()=>{const a=new Set(["main"]);return S.forEach(r=>{const n=r.id.trim();n&&a.add(n)}),a},[S]),u=(a,r)=>{y(n=>n.map((s,o)=>o===a?{...s,...r}:s))},T=(a,r)=>{b(n=>n.map((s,o)=>o===a?r:s))},ne=()=>{try{const a=S.map((s,o)=>{var m,C;const l=s.id.trim();if(!l)throw new Error(t("agentIdRequiredError").replace("{index}",String(o)));const c={id:l};return s.default&&(c.default=!0),(m=s.workspace)!=null&&m.trim()&&(c.workspace=s.workspace.trim()),(C=s.model)!=null&&C.trim()&&(c.model=s.model.trim()),typeof s.maxTokens=="number"&&(c.maxTokens=s.maxTokens),typeof s.contextTokens=="number"&&(c.contextTokens=Math.max(1e3,s.contextTokens)),typeof s.maxToolIterations=="number"&&(c.maxToolIterations=s.maxToolIterations),c}),r=a.map(s=>s.id).filter((s,o,l)=>l.indexOf(s)!==o);if(r.length>0){H.error(`${t("duplicateAgentId")}: ${r[0]}`);return}const n=D.map((s,o)=>{var J,Q,W,X;const l=s.agentId.trim(),c=s.match.channel.trim(),m=((J=s.match.accountId)==null?void 0:J.trim())??"",C=(Q=s.match.peer)==null?void 0:Q.kind,G=((X=(W=s.match.peer)==null?void 0:W.id)==null?void 0:X.trim())??"";if(!l)throw new Error(t("bindingAgentIdRequired").replace("{index}",String(o)));if(!re.has(l))throw new Error(`${t("bindingAgentIdNotFound").replace("{index}",String(o))}: ${l}`);if(!c)throw new Error(t("bindingChannelRequired").replace("{index}",String(o)));const E={agentId:l,match:{channel:c}};if(m&&(E.match.accountId=m),C){if(!G)throw new Error(t("bindingPeerIdRequired").replace("{index}",String(o)));E.match.peer={kind:C,id:G}}return E});_.mutate({data:{agents:{defaults:{contextTokens:Math.max(1e3,V)},list:a},bindings:n,session:{dmScope:L,agentToAgent:{maxPingPongTurns:Math.min(5,Math.max(0,K))}}}})}catch(a){const r=a instanceof Error?a.message:String(a);H.error(r)}};return w||!i?e.jsx("div",{className:"p-8 text-gray-400",children:t("runtimeLoading")}):e.jsxs(ie,{className:"space-y-6",children:[e.jsx(me,{title:t("runtimePageTitle"),description:t("runtimePageDescription")}),e.jsxs(B,{children:[e.jsxs(M,{children:[e.jsx(O,{children:(h==null?void 0:h.label)??t("dmScope")}),e.jsx(R,{children:(h==null?void 0:h.help)??t("dmScopeHelp")})]}),e.jsxs($,{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:(f==null?void 0:f.label)??t("defaultContextTokens")}),e.jsx(d,{type:"number",min:1e3,step:1e3,value:V,onChange:a=>U(Math.max(1e3,Number.parseInt(a.target.value,10)||1e3))}),e.jsx("p",{className:"text-xs text-gray-500",children:(f==null?void 0:f.help)??t("defaultContextTokensHelp")})]}),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(ee,{value:L,onValueChange:a=>q(a),children:[e.jsx(ae,{children:e.jsx(se,{})}),e.jsx(te,{children:ue.map(a=>e.jsx(P,{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:(j==null?void 0:j.label)??t("maxPingPongTurns")}),e.jsx(d,{type:"number",min:0,max:5,value:K,onChange:a=>F(Math.max(0,Number.parseInt(a.target.value,10)||0))}),e.jsx("p",{className:"text-xs text-gray-500",children:(j==null?void 0:j.help)??t("maxPingPongTurnsHelp")})]})]})]}),e.jsxs(B,{children:[e.jsxs(M,{children:[e.jsx(O,{children:(v==null?void 0:v.label)??t("agentList")}),e.jsx(R,{children:(v==null?void 0:v.help)??t("agentListHelp")})]}),e.jsxs($,{className:"space-y-3",children:[S.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(d,{value:a.id,onChange:n=>u(r,{id:n.target.value}),placeholder:t("agentIdPlaceholder")}),e.jsx(d,{value:a.workspace??"",onChange:n=>u(r,{workspace:n.target.value}),placeholder:t("workspaceOverridePlaceholder")}),e.jsx(d,{value:a.model??"",onChange:n=>u(r,{model:n.target.value}),placeholder:t("modelOverridePlaceholder")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:[e.jsx(d,{type:"number",min:1,value:a.maxTokens??"",onChange:n=>u(r,{maxTokens:z(n.target.value)}),placeholder:t("maxTokensPlaceholder")}),e.jsx(d,{type:"number",min:1e3,step:1e3,value:a.contextTokens??"",onChange:n=>u(r,{contextTokens:z(n.target.value)}),placeholder:(A==null?void 0:A.label)??t("contextTokensPlaceholder")}),e.jsx(d,{type:"number",min:1,value:a.maxToolIterations??"",onChange:n=>u(r,{maxToolIterations:z(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(he,{checked:!!a.default,onCheckedChange:n=>{if(!n){u(r,{default:!1});return}y(s=>s.map((o,l)=>({...o,default:l===r})))}}),e.jsx("span",{children:t("defaultAgent")})]}),e.jsxs(N,{type:"button",variant:"outline",size:"sm",onClick:()=>y(n=>n.filter((s,o)=>o!==r)),children:[e.jsx(Y,{className:"h-4 w-4 mr-1"}),t("remove")]})]})]},`${r}-${a.id}`)),e.jsxs(N,{type:"button",variant:"outline",onClick:()=>y(a=>[...a,pe()]),children:[e.jsx(Z,{className:"h-4 w-4 mr-2"}),t("addAgent")]})]})]}),e.jsxs(B,{children:[e.jsxs(M,{children:[e.jsx(O,{children:(k==null?void 0:k.label)??t("bindings")}),e.jsx(R,{children:(k==null?void 0:k.help)??t("bindingsHelp")})]}),e.jsxs($,{className:"space-y-3",children:[D.map((a,r)=>{var s,o;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(d,{value:a.agentId,onChange:l=>T(r,{...a,agentId:l.target.value}),placeholder:t("targetAgentIdPlaceholder")}),e.jsx(d,{value:a.match.channel,onChange:l=>T(r,{...a,match:{...a.match,channel:l.target.value}}),placeholder:t("channelPlaceholder")}),e.jsx(d,{value:a.match.accountId??"",onChange:l=>T(r,{...a,match:{...a.match,accountId:l.target.value}}),placeholder:t("accountIdOptionalPlaceholder")}),e.jsxs(ee,{value:n||"__none__",onValueChange:l=>{var m;const c=l==="__none__"?"":l;if(!c){T(r,{...a,match:{...a.match,peer:void 0}});return}T(r,{...a,match:{...a.match,peer:{kind:c,id:((m=a.match.peer)==null?void 0:m.id)??""}}})},children:[e.jsx(ae,{children:e.jsx(se,{})}),e.jsxs(te,{children:[e.jsx(P,{value:"__none__",children:t("peerKindOptional")}),e.jsx(P,{value:"direct",children:"direct"}),e.jsx(P,{value:"group",children:"group"}),e.jsx(P,{value:"channel",children:"channel"})]})]}),e.jsx(d,{value:((o=a.match.peer)==null?void 0:o.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(N,{type:"button",variant:"outline",size:"sm",onClick:()=>b(l=>l.filter((c,m)=>m!==r)),children:[e.jsx(Y,{className:"h-4 w-4 mr-1"}),t("remove")]})})]},`${r}-${a.agentId}`)}),e.jsxs(N,{type:"button",variant:"outline",onClick:()=>b(a=>[...a,xe()]),children:[e.jsx(Z,{className:"h-4 w-4 mr-2"}),t("addBinding")]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(N,{type:"button",onClick:ne,disabled:_.isPending,children:[e.jsx(le,{className:"h-4 w-4 mr-2"}),_.isPending?t("saving"):t("saveRuntimeSettings")]})})]})}export{ye as RuntimeConfig};
1
+ import{r as p,j as e,a8 as Y,a6 as Z,al as le,af as H}from"./vendor-CHxMoJ93.js";import{u as oe,b as ce,m as de,I as d}from"./useConfig-C9yQu_4f.js";import{P as ie,a as me,B as N}from"./page-layout-COKsFqhi.js";import{C as B,a as M,b as O,c as R,d as $}from"./card-AxFsy7YF.js";import{S as he}from"./switch-BVQzjvsB.js";import{t,S as ee,a as ae,b as se,d as te,e as P}from"./index-CT15pXtn.js";import{h as I}from"./config-hints-CApS3K_7.js";const ue=[{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 pe(){return{id:"",default:!1,workspace:"",model:"",maxTokens:void 0,contextTokens:void 0,maxToolIterations:void 0}}function xe(){return{agentId:"",match:{channel:"",accountId:""}}}function z(i){const w=i.trim();if(!w)return;const x=Number.parseInt(w,10);return Number.isFinite(x)?x:void 0}function ye(){const{data:i,isLoading:w}=oe(),{data:x}=ce(),_=de(),[S,y]=p.useState([]),[D,b]=p.useState([]),[L,q]=p.useState("per-channel-peer"),[K,F]=p.useState(0),[V,U]=p.useState(2e5);p.useEffect(()=>{var a,r,n;i&&(y((i.agents.list??[]).map(s=>({id:s.id??"",default:!!s.default,workspace:s.workspace??"",model:s.model??"",maxTokens:s.maxTokens,contextTokens:s.contextTokens,maxToolIterations:s.maxToolIterations}))),b((i.bindings??[]).map(s=>{var o,l,c;return{agentId:s.agentId??"",match:{channel:((o=s.match)==null?void 0:o.channel)??"",accountId:((l=s.match)==null?void 0:l.accountId)??"",peer:(c=s.match)!=null&&c.peer?{kind:s.match.peer.kind,id:s.match.peer.id}:void 0}}})),q(((a=i.session)==null?void 0:a.dmScope)??"per-channel-peer"),F(((n=(r=i.session)==null?void 0:r.agentToAgent)==null?void 0:n.maxPingPongTurns)??0),U(i.agents.defaults.contextTokens??2e5))},[i]);const g=x==null?void 0:x.uiHints,h=I("session.dmScope",g),j=I("session.agentToAgent.maxPingPongTurns",g),f=I("agents.defaults.contextTokens",g),A=I("agents.list.*.contextTokens",g),v=I("agents.list",g),k=I("bindings",g),re=p.useMemo(()=>{const a=new Set(["main"]);return S.forEach(r=>{const n=r.id.trim();n&&a.add(n)}),a},[S]),u=(a,r)=>{y(n=>n.map((s,o)=>o===a?{...s,...r}:s))},T=(a,r)=>{b(n=>n.map((s,o)=>o===a?r:s))},ne=()=>{try{const a=S.map((s,o)=>{var m,C;const l=s.id.trim();if(!l)throw new Error(t("agentIdRequiredError").replace("{index}",String(o)));const c={id:l};return s.default&&(c.default=!0),(m=s.workspace)!=null&&m.trim()&&(c.workspace=s.workspace.trim()),(C=s.model)!=null&&C.trim()&&(c.model=s.model.trim()),typeof s.maxTokens=="number"&&(c.maxTokens=s.maxTokens),typeof s.contextTokens=="number"&&(c.contextTokens=Math.max(1e3,s.contextTokens)),typeof s.maxToolIterations=="number"&&(c.maxToolIterations=s.maxToolIterations),c}),r=a.map(s=>s.id).filter((s,o,l)=>l.indexOf(s)!==o);if(r.length>0){H.error(`${t("duplicateAgentId")}: ${r[0]}`);return}const n=D.map((s,o)=>{var J,Q,W,X;const l=s.agentId.trim(),c=s.match.channel.trim(),m=((J=s.match.accountId)==null?void 0:J.trim())??"",C=(Q=s.match.peer)==null?void 0:Q.kind,G=((X=(W=s.match.peer)==null?void 0:W.id)==null?void 0:X.trim())??"";if(!l)throw new Error(t("bindingAgentIdRequired").replace("{index}",String(o)));if(!re.has(l))throw new Error(`${t("bindingAgentIdNotFound").replace("{index}",String(o))}: ${l}`);if(!c)throw new Error(t("bindingChannelRequired").replace("{index}",String(o)));const E={agentId:l,match:{channel:c}};if(m&&(E.match.accountId=m),C){if(!G)throw new Error(t("bindingPeerIdRequired").replace("{index}",String(o)));E.match.peer={kind:C,id:G}}return E});_.mutate({data:{agents:{defaults:{contextTokens:Math.max(1e3,V)},list:a},bindings:n,session:{dmScope:L,agentToAgent:{maxPingPongTurns:Math.min(5,Math.max(0,K))}}}})}catch(a){const r=a instanceof Error?a.message:String(a);H.error(r)}};return w||!i?e.jsx("div",{className:"p-8 text-gray-400",children:t("runtimeLoading")}):e.jsxs(ie,{className:"space-y-6",children:[e.jsx(me,{title:t("runtimePageTitle"),description:t("runtimePageDescription")}),e.jsxs(B,{children:[e.jsxs(M,{children:[e.jsx(O,{children:(h==null?void 0:h.label)??t("dmScope")}),e.jsx(R,{children:(h==null?void 0:h.help)??t("dmScopeHelp")})]}),e.jsxs($,{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:(f==null?void 0:f.label)??t("defaultContextTokens")}),e.jsx(d,{type:"number",min:1e3,step:1e3,value:V,onChange:a=>U(Math.max(1e3,Number.parseInt(a.target.value,10)||1e3))}),e.jsx("p",{className:"text-xs text-gray-500",children:(f==null?void 0:f.help)??t("defaultContextTokensHelp")})]}),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(ee,{value:L,onValueChange:a=>q(a),children:[e.jsx(ae,{children:e.jsx(se,{})}),e.jsx(te,{children:ue.map(a=>e.jsx(P,{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:(j==null?void 0:j.label)??t("maxPingPongTurns")}),e.jsx(d,{type:"number",min:0,max:5,value:K,onChange:a=>F(Math.max(0,Number.parseInt(a.target.value,10)||0))}),e.jsx("p",{className:"text-xs text-gray-500",children:(j==null?void 0:j.help)??t("maxPingPongTurnsHelp")})]})]})]}),e.jsxs(B,{children:[e.jsxs(M,{children:[e.jsx(O,{children:(v==null?void 0:v.label)??t("agentList")}),e.jsx(R,{children:(v==null?void 0:v.help)??t("agentListHelp")})]}),e.jsxs($,{className:"space-y-3",children:[S.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(d,{value:a.id,onChange:n=>u(r,{id:n.target.value}),placeholder:t("agentIdPlaceholder")}),e.jsx(d,{value:a.workspace??"",onChange:n=>u(r,{workspace:n.target.value}),placeholder:t("workspaceOverridePlaceholder")}),e.jsx(d,{value:a.model??"",onChange:n=>u(r,{model:n.target.value}),placeholder:t("modelOverridePlaceholder")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:[e.jsx(d,{type:"number",min:1,value:a.maxTokens??"",onChange:n=>u(r,{maxTokens:z(n.target.value)}),placeholder:t("maxTokensPlaceholder")}),e.jsx(d,{type:"number",min:1e3,step:1e3,value:a.contextTokens??"",onChange:n=>u(r,{contextTokens:z(n.target.value)}),placeholder:(A==null?void 0:A.label)??t("contextTokensPlaceholder")}),e.jsx(d,{type:"number",min:1,value:a.maxToolIterations??"",onChange:n=>u(r,{maxToolIterations:z(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(he,{checked:!!a.default,onCheckedChange:n=>{if(!n){u(r,{default:!1});return}y(s=>s.map((o,l)=>({...o,default:l===r})))}}),e.jsx("span",{children:t("defaultAgent")})]}),e.jsxs(N,{type:"button",variant:"outline",size:"sm",onClick:()=>y(n=>n.filter((s,o)=>o!==r)),children:[e.jsx(Y,{className:"h-4 w-4 mr-1"}),t("remove")]})]})]},`${r}-${a.id}`)),e.jsxs(N,{type:"button",variant:"outline",onClick:()=>y(a=>[...a,pe()]),children:[e.jsx(Z,{className:"h-4 w-4 mr-2"}),t("addAgent")]})]})]}),e.jsxs(B,{children:[e.jsxs(M,{children:[e.jsx(O,{children:(k==null?void 0:k.label)??t("bindings")}),e.jsx(R,{children:(k==null?void 0:k.help)??t("bindingsHelp")})]}),e.jsxs($,{className:"space-y-3",children:[D.map((a,r)=>{var s,o;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(d,{value:a.agentId,onChange:l=>T(r,{...a,agentId:l.target.value}),placeholder:t("targetAgentIdPlaceholder")}),e.jsx(d,{value:a.match.channel,onChange:l=>T(r,{...a,match:{...a.match,channel:l.target.value}}),placeholder:t("channelPlaceholder")}),e.jsx(d,{value:a.match.accountId??"",onChange:l=>T(r,{...a,match:{...a.match,accountId:l.target.value}}),placeholder:t("accountIdOptionalPlaceholder")}),e.jsxs(ee,{value:n||"__none__",onValueChange:l=>{var m;const c=l==="__none__"?"":l;if(!c){T(r,{...a,match:{...a.match,peer:void 0}});return}T(r,{...a,match:{...a.match,peer:{kind:c,id:((m=a.match.peer)==null?void 0:m.id)??""}}})},children:[e.jsx(ae,{children:e.jsx(se,{})}),e.jsxs(te,{children:[e.jsx(P,{value:"__none__",children:t("peerKindOptional")}),e.jsx(P,{value:"direct",children:"direct"}),e.jsx(P,{value:"group",children:"group"}),e.jsx(P,{value:"channel",children:"channel"})]})]}),e.jsx(d,{value:((o=a.match.peer)==null?void 0:o.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(N,{type:"button",variant:"outline",size:"sm",onClick:()=>b(l=>l.filter((c,m)=>m!==r)),children:[e.jsx(Y,{className:"h-4 w-4 mr-1"}),t("remove")]})})]},`${r}-${a.agentId}`)}),e.jsxs(N,{type:"button",variant:"outline",onClick:()=>b(a=>[...a,xe()]),children:[e.jsx(Z,{className:"h-4 w-4 mr-2"}),t("addBinding")]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(N,{type:"button",onClick:ne,disabled:_.isPending,children:[e.jsx(le,{className:"h-4 w-4 mr-2"}),_.isPending?t("saving"):t("saveRuntimeSettings")]})})]})}export{ye as RuntimeConfig};
@@ -1,3 +1,3 @@
1
- import{r as u,j as e,a8 as H,a6 as L,al as G,af as J}from"./vendor-CHxMoJ93.js";import{u as K,t as Q,I as h}from"./useConfig-Uy1hlToJ.js";import{P as W,a as X,B as _}from"./page-layout-Cu4Yj2Q_.js";import{C as R,a as T,b as M,c as O,d as A}from"./card-CAvcgkiT.js";import{L as k}from"./label-BlmIivGH.js";import{t as a,S as x,a as m,b as p,d as j,e as o}from"./index-CL28Z9YZ.js";import{S as Y}from"./switch-C5wm6PbF.js";const U=["env","file","exec"];function N(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"?{...N(n),source:"env",prefix:l.prefix??""}:l.source==="file"?{...N(n),source:"file",path:l.path}:{...N(n),source:"exec",command:l.command,argsText:(l.args??[]).join(`
1
+ import{r as u,j as e,a8 as H,a6 as L,al as G,af as J}from"./vendor-CHxMoJ93.js";import{u as K,t as Q,I as h}from"./useConfig-C9yQu_4f.js";import{P as W,a as X,B as _}from"./page-layout-COKsFqhi.js";import{C as R,a as T,b as M,c as O,d as A}from"./card-AxFsy7YF.js";import{L as k}from"./label-Chdg0Pzh.js";import{t as a,S as x,a as m,b as p,d as j,e as o}from"./index-CT15pXtn.js";import{S as Y}from"./switch-BVQzjvsB.js";const U=["env","file","exec"];function N(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"?{...N(n),source:"env",prefix:l.prefix??""}:l.source==="file"?{...N(n),source:"file",path:l.path}:{...N(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(),P=Q(),[D,y]=u.useState(!0),[I,E]=u.useState(""),[V,S]=u.useState(""),[F,$]=u.useState(""),[C,f]=u.useState([]),[q,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))},b=(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 q.entries()){const i=c.path.trim(),B=c.id.trim();if(!i)throw new Error(`${a("secretConfigPath")} #${r+1} ${a("isRequired")}`);if(!B)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:B}}P.mutate({data:{enabled:D,defaults:{env:I.trim()||null,file:V.trim()||null,exec:F.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:F||"__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,N()]),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:[q.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=>b(t,{path:r.target.value}),placeholder:a("secretConfigPath")}),e.jsx(h,{value:s.id,onChange:r=>b(t,{id:r.target.value}),placeholder:a("secretId")}),e.jsxs(x,{value:s.source,onValueChange:r=>b(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=>b(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:P.isPending,children:[e.jsx(G,{className:"h-4 w-4 mr-2"}),P.isPending?a("saving"):a("save")]})})]})}export{oe as SecretsConfig};
@@ -1,2 +1,2 @@
1
- import{r as l,j as e,a5 as T,a0 as Y,am as A,ah as $,aj as W,M as U,an as X,X as G,Y as J}from"./vendor-CHxMoJ93.js";import{u as Z}from"./useConfirmDialog-BUK2K_01.js";import{d as ee,e as se,n as te,f as ae,I as S}from"./useConfig-Uy1hlToJ.js";import{P as re,a as le,B as g}from"./page-layout-Cu4Yj2Q_.js";import{t,c as o,S as ne,a as ie,b as oe,d as de,e as K,i as ce,g as xe}from"./index-CL28Z9YZ.js";import{e as me}from"./chat-message-D0s61C4e.js";const u="__unknown_channel__";function he(a){return xe(a)}function j(a){const n=a.indexOf(":");return n<=0?u:a.slice(0,n).trim()||u}function C(a){return a===u?t("sessionsUnknownChannel"):a}function ge({session:a,channel:n,isSelected:i,onSelect:f}){const r=C(n),p=a.label||a.key.split(":").pop()||a.key;return e.jsxs("button",{onClick:f,className:o("w-full text-left p-3.5 rounded-xl transition-all duration-200 outline-none focus:outline-none focus:ring-0 group",i?"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:o("font-semibold truncate pr-2 flex-1 text-sm",i?"text-brand-800":"text-gray-900"),children:p}),e.jsx("div",{className:o("text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 capitalize",i?"bg-white text-brand-600 shadow-[0_1px_2px_rgba(0,0,0,0.02)]":"bg-gray-100 text-gray-500"),children:r})]}),e.jsxs("div",{className:o("flex items-center text-xs justify-between mt-2 font-medium",i?"text-brand-600/80":"text-gray-400"),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(X,{className:"w-3.5 h-3.5 opacity-70"}),e.jsx("span",{className:"truncate max-w-[100px]",children:ce(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 ue({message:a}){const n=a.role.toLowerCase()==="user",i=me(a.content).trim();return e.jsx("div",{className:o("flex w-full mb-6",n?"justify-end":"justify-start"),children:e.jsxs("div",{className:o("max-w-[85%] rounded-[1.25rem] p-5 flex gap-3 text-sm",n?"bg-primary text-white rounded-tr-sm":"bg-gray-50 text-gray-800 rounded-tl-sm border border-gray-100/50"),children:[e.jsx("div",{className:"shrink-0 pt-0.5",children:n?e.jsx(G,{className:"w-4 h-4 text-primary-100"}):e.jsx(J,{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:o("font-semibold text-xs",n?"text-primary-50":"text-gray-900 capitalize"),children:a.role}),e.jsx("span",{className:o("text-[10px]",n?"text-primary-200":"text-gray-400"),children:he(a.timestamp)})]}),e.jsx("div",{className:"whitespace-pre-wrap break-words leading-relaxed text-[15px]",children:i||"-"})]})]})})}function Ne(){var z,H,E;const[a,n]=l.useState(""),[i]=l.useState(100),[f]=l.useState(0),[r,p]=l.useState(null),[y,B]=l.useState("all"),[M,v]=l.useState(""),[L,N]=l.useState(""),[w,k]=l.useState(!1),F=l.useMemo(()=>({q:a.trim()||void 0,limit:i,activeMinutes:f}),[a,i,f]),h=ee(F),x=se(r,200),b=te(),D=ae(),{confirm:_,ConfirmDialog:Q}=Z(),c=l.useMemo(()=>{var s;return((s=h.data)==null?void 0:s.sessions)??[]},[(z=h.data)==null?void 0:z.sessions]),d=l.useMemo(()=>c.find(s=>s.key===r),[c,r]),q=l.useMemo(()=>{const s=new Set;for(const m of c)s.add(j(m.key));return Array.from(s).sort((m,I)=>m===u?1:I===u?-1:m.localeCompare(I))},[c]),P=l.useMemo(()=>y==="all"?c:c.filter(s=>j(s.key)===y),[c,y]);l.useEffect(()=>{d?(v(d.label||""),N(d.preferredModel||"")):(v(""),N("")),k(!1)},[d]);const O=()=>{r&&(b.mutate({key:r,data:{label:M.trim()||null,preferredModel:L.trim()||null}}),k(!1))},R=async()=>{if(!r)return;await _({title:t("sessionsClearHistory")+"?",variant:"destructive",confirmLabel:t("sessionsClearHistory")})&&b.mutate({key:r,data:{clearHistory:!0}})},V=async()=>{if(!r)return;await _({title:t("sessionsDeleteConfirm")+"?",variant:"destructive",confirmLabel:t("sessionsDeleteConfirm")})&&D.mutate({key:r},{onSuccess:()=>p(null)})};return e.jsxs(re,{fullHeight:!0,children:[e.jsx(le,{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(g,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100",onClick:()=>h.refetch(),children:e.jsx(T,{className:o("h-3.5 w-3.5",h.isFetching&&"animate-spin")})})]}),e.jsxs(ne,{value:y,onValueChange:B,children:[e.jsx(ie,{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(oe,{placeholder:t("sessionsAllChannels")})}),e.jsxs(de,{className:"rounded-xl shadow-lg border-gray-100 max-w-[280px]",children:[e.jsx(K,{value:"all",className:"rounded-lg text-xs",children:t("sessionsAllChannels")}),q.map(s=>e.jsx(K,{value:s,className:"rounded-lg text-xs truncate pr-6",children:C(s)},s))]})]}),e.jsxs("div",{className:"relative w-full",children:[e.jsx(Y,{className:"h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400"}),e.jsx(S,{value:a,onChange:s=>n(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:h.isLoading?e.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:t("sessionsLoading")}):P.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(A,{className:"w-8 h-8 mx-auto mb-2 text-gray-300"}),t("sessionsEmpty")]}):P.map(s=>e.jsx(ge,{session:s,channel:j(s.key),isSelected:r===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||D.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"})}),r&&d?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($,{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:d.label||d.key.split(":").pop()||d.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(d.key))})]}),e.jsx("div",{className:"text-xs text-gray-500 font-mono break-all line-clamp-1 opacity-70",title:r,children:r})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>k(!w),className:o("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(W,{className:"w-3.5 h-3.5 mr-1.5"}),t("sessionsMetadata")]}),e.jsx(g,{variant:"outline",size:"sm",onClick:R,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(g,{variant:"outline",size:"sm",onClick:V,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(S,{placeholder:t("sessionsLabelPlaceholder"),value:M,onChange:s=>v(s.target.value),className:"h-8 text-sm bg-white"}),e.jsx(S,{placeholder:t("sessionsModelPlaceholder"),value:L,onChange:s=>N(s.target.value),className:"h-8 text-sm bg-white"}),e.jsx(g,{size:"sm",onClick:O,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
1
+ import{r as l,j as e,a5 as T,a0 as Y,am as A,ah as $,aj as W,M as U,an as X,X as G,Y as J}from"./vendor-CHxMoJ93.js";import{u as Z}from"./useConfirmDialog-8zI-gypg.js";import{d as ee,e as se,n as te,f as ae,I as S}from"./useConfig-C9yQu_4f.js";import{P as re,a as le,B as g}from"./page-layout-COKsFqhi.js";import{t,c as o,S as ne,a as ie,b as oe,d as de,e as K,i as ce,g as xe}from"./index-CT15pXtn.js";import{e as me}from"./chat-message-D0s61C4e.js";const u="__unknown_channel__";function he(a){return xe(a)}function j(a){const n=a.indexOf(":");return n<=0?u:a.slice(0,n).trim()||u}function C(a){return a===u?t("sessionsUnknownChannel"):a}function ge({session:a,channel:n,isSelected:i,onSelect:f}){const r=C(n),p=a.label||a.key.split(":").pop()||a.key;return e.jsxs("button",{onClick:f,className:o("w-full text-left p-3.5 rounded-xl transition-all duration-200 outline-none focus:outline-none focus:ring-0 group",i?"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:o("font-semibold truncate pr-2 flex-1 text-sm",i?"text-brand-800":"text-gray-900"),children:p}),e.jsx("div",{className:o("text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 capitalize",i?"bg-white text-brand-600 shadow-[0_1px_2px_rgba(0,0,0,0.02)]":"bg-gray-100 text-gray-500"),children:r})]}),e.jsxs("div",{className:o("flex items-center text-xs justify-between mt-2 font-medium",i?"text-brand-600/80":"text-gray-400"),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(X,{className:"w-3.5 h-3.5 opacity-70"}),e.jsx("span",{className:"truncate max-w-[100px]",children:ce(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 ue({message:a}){const n=a.role.toLowerCase()==="user",i=me(a.content).trim();return e.jsx("div",{className:o("flex w-full mb-6",n?"justify-end":"justify-start"),children:e.jsxs("div",{className:o("max-w-[85%] rounded-[1.25rem] p-5 flex gap-3 text-sm",n?"bg-primary text-white rounded-tr-sm":"bg-gray-50 text-gray-800 rounded-tl-sm border border-gray-100/50"),children:[e.jsx("div",{className:"shrink-0 pt-0.5",children:n?e.jsx(G,{className:"w-4 h-4 text-primary-100"}):e.jsx(J,{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:o("font-semibold text-xs",n?"text-primary-50":"text-gray-900 capitalize"),children:a.role}),e.jsx("span",{className:o("text-[10px]",n?"text-primary-200":"text-gray-400"),children:he(a.timestamp)})]}),e.jsx("div",{className:"whitespace-pre-wrap break-words leading-relaxed text-[15px]",children:i||"-"})]})]})})}function Ne(){var z,H,E;const[a,n]=l.useState(""),[i]=l.useState(100),[f]=l.useState(0),[r,p]=l.useState(null),[y,B]=l.useState("all"),[M,v]=l.useState(""),[L,N]=l.useState(""),[w,k]=l.useState(!1),F=l.useMemo(()=>({q:a.trim()||void 0,limit:i,activeMinutes:f}),[a,i,f]),h=ee(F),x=se(r,200),b=te(),D=ae(),{confirm:_,ConfirmDialog:Q}=Z(),c=l.useMemo(()=>{var s;return((s=h.data)==null?void 0:s.sessions)??[]},[(z=h.data)==null?void 0:z.sessions]),d=l.useMemo(()=>c.find(s=>s.key===r),[c,r]),q=l.useMemo(()=>{const s=new Set;for(const m of c)s.add(j(m.key));return Array.from(s).sort((m,I)=>m===u?1:I===u?-1:m.localeCompare(I))},[c]),P=l.useMemo(()=>y==="all"?c:c.filter(s=>j(s.key)===y),[c,y]);l.useEffect(()=>{d?(v(d.label||""),N(d.preferredModel||"")):(v(""),N("")),k(!1)},[d]);const O=()=>{r&&(b.mutate({key:r,data:{label:M.trim()||null,preferredModel:L.trim()||null}}),k(!1))},R=async()=>{if(!r)return;await _({title:t("sessionsClearHistory")+"?",variant:"destructive",confirmLabel:t("sessionsClearHistory")})&&b.mutate({key:r,data:{clearHistory:!0}})},V=async()=>{if(!r)return;await _({title:t("sessionsDeleteConfirm")+"?",variant:"destructive",confirmLabel:t("sessionsDeleteConfirm")})&&D.mutate({key:r},{onSuccess:()=>p(null)})};return e.jsxs(re,{fullHeight:!0,children:[e.jsx(le,{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(g,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100",onClick:()=>h.refetch(),children:e.jsx(T,{className:o("h-3.5 w-3.5",h.isFetching&&"animate-spin")})})]}),e.jsxs(ne,{value:y,onValueChange:B,children:[e.jsx(ie,{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(oe,{placeholder:t("sessionsAllChannels")})}),e.jsxs(de,{className:"rounded-xl shadow-lg border-gray-100 max-w-[280px]",children:[e.jsx(K,{value:"all",className:"rounded-lg text-xs",children:t("sessionsAllChannels")}),q.map(s=>e.jsx(K,{value:s,className:"rounded-lg text-xs truncate pr-6",children:C(s)},s))]})]}),e.jsxs("div",{className:"relative w-full",children:[e.jsx(Y,{className:"h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400"}),e.jsx(S,{value:a,onChange:s=>n(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:h.isLoading?e.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:t("sessionsLoading")}):P.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(A,{className:"w-8 h-8 mx-auto mb-2 text-gray-300"}),t("sessionsEmpty")]}):P.map(s=>e.jsx(ge,{session:s,channel:j(s.key),isSelected:r===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||D.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"})}),r&&d?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($,{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:d.label||d.key.split(":").pop()||d.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(d.key))})]}),e.jsx("div",{className:"text-xs text-gray-500 font-mono break-all line-clamp-1 opacity-70",title:r,children:r})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>k(!w),className:o("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(W,{className:"w-3.5 h-3.5 mr-1.5"}),t("sessionsMetadata")]}),e.jsx(g,{variant:"outline",size:"sm",onClick:R,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(g,{variant:"outline",size:"sm",onClick:V,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(S,{placeholder:t("sessionsLabelPlaceholder"),value:M,onChange:s=>v(s.target.value),className:"h-8 text-sm bg-white"}),e.jsx(S,{placeholder:t("sessionsModelPlaceholder"),value:L,onChange:s=>N(s.target.value),className:"h-8 text-sm bg-white"}),e.jsx(g,{size:"sm",onClick:O,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:[x.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(T,{className:"w-6 h-6 text-primary animate-spin"}),e.jsx("span",{className:"text-sm font-medium text-gray-500",children:t("sessionsHistoryLoading")})]})}),x.error&&e.jsx("div",{className:"text-center p-6 bg-red-50 rounded-xl text-red-600 border border-red-100 text-sm",children:x.error.message}),!x.isLoading&&((H=x.data)==null?void 0:H.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:(((E=x.data)==null?void 0:E.messages)??[]).map((s,m)=>e.jsx(ue,{message:s},`${s.timestamp}-${m}`))})]})]}):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(A,{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(Q,{})]})}export{Ne as SessionsConfig};
@@ -1 +1 @@
1
- import{r as s,j as t}from"./vendor-CHxMoJ93.js";import{c as d}from"./index-CL28Z9YZ.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,c as a,l as b,n as c,p as d};
1
+ import{r as s,j as t}from"./vendor-CHxMoJ93.js";import{c as d}from"./index-CT15pXtn.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,c as a,l as b,n as c,p as d};