@nextclaw/ui 0.5.24 → 0.5.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/assets/{ChannelsList-CAuBEcOr.js → ChannelsList-C2h4dVWt.js} +1 -1
- package/dist/assets/{ChatPage-Bxs3X5OC.js → ChatPage-B4xQTj78.js} +14 -14
- package/dist/assets/{CronConfig-jOEPCnpf.js → CronConfig-CtiTohyP.js} +1 -1
- package/dist/assets/{DocBrowser-wov_cBSN.js → DocBrowser-BDOIcX3y.js} +1 -1
- package/dist/assets/{MarketplacePage-Cob6DGoO.js → MarketplacePage-BPc8FmE5.js} +1 -1
- package/dist/assets/{ModelConfig-C_Y3UDYr.js → ModelConfig-pX1wV-UJ.js} +1 -1
- package/dist/assets/{ProvidersList-6A6N2eDT.js → ProvidersList-BJTtF6S5.js} +1 -1
- package/dist/assets/{RuntimeConfig-B3k_dMdJ.js → RuntimeConfig-BqN1F3nP.js} +1 -1
- package/dist/assets/{SecretsConfig-BeCRCCEW.js → SecretsConfig-CkqJq4s6.js} +1 -1
- package/dist/assets/{SessionsConfig-M32Qm7cL.js → SessionsConfig-ti41bz9T.js} +1 -1
- package/dist/assets/{action-link-DsAjsb68.js → action-link-C4fhtxYl.js} +1 -1
- package/dist/assets/{card-uTj7-9XS.js → card-C0sHz144.js} +1 -1
- package/dist/assets/chat-message-Jxa8JFA_.js +9 -0
- package/dist/assets/{dialog-FRtXcCmk.js → dialog-CJMXeCpK.js} +1 -1
- package/dist/assets/index-BTE5dHqH.js +2 -0
- package/dist/assets/{label-DAhEgM6-.js → label-DeI2vCVA.js} +1 -1
- package/dist/assets/{page-layout-DMpNQawS.js → page-layout-C_pPVkYP.js} +1 -1
- package/dist/assets/{switch-D8lSFzq4.js → switch-_UxC2xoH.js} +1 -1
- package/dist/assets/{tabs-custom-CsFrOXUS.js → tabs-custom-DgryVfGt.js} +1 -1
- package/dist/assets/{useConfig-Cjlx5C-1.js → useConfig-DDPQwvDe.js} +1 -1
- package/dist/assets/{useConfirmDialog-D3eI0Hfj.js → useConfirmDialog-DqTlJNqa.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/components/chat/ChatPage.tsx +79 -28
- package/src/lib/chat-message.ts +72 -3
- package/src/lib/i18n.ts +3 -0
- package/dist/assets/chat-message-DZV2Z5oc.js +0 -5
- package/dist/assets/index-Dw8Ss2WH.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as x,j as e,a4 as j,A as D,ao as L,ap as R,a7 as k}from"./vendor-H2M3a_4Z.js";import{u as E}from"./useConfirmDialog-
|
|
1
|
+
import{r as x,j as e,a4 as j,A as D,ao as L,ap as R,a7 as k}from"./vendor-H2M3a_4Z.js";import{u as E}from"./useConfirmDialog-DqTlJNqa.js";import{l as M,m as P,n as T,o as J,I as A}from"./useConfig-DDPQwvDe.js";import{P as F,a as z,B as o}from"./page-layout-C_pPVkYP.js";import{c as p,t,S as B,b as I,d as Q,e as q,g as f,a as y}from"./index-BTE5dHqH.js";import{C as H,d as V}from"./card-C0sHz144.js";import"./dialog-CJMXeCpK.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 re(){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(B,{value:n,onValueChange:a=>c(a),children:[e.jsx(I,{className:"w-full",children:e.jsx(Q,{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{re as CronConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,j as t,s as J,aS as K,aT as Q,ac as Z,aU as ee,ak as te,_ as re,aj as se,aV as oe}from"./vendor-H2M3a_4Z.js";import{j as ae,D as W,t as x,c as C}from"./index-
|
|
1
|
+
import{r as s,j as t,s as J,aS as K,aT as Q,ac as Z,aU as ee,ak as te,_ as re,aj as se,aV as oe}from"./vendor-H2M3a_4Z.js";import{j as ae,D as W,t as x,c as C}from"./index-BTE5dHqH.js";function ce(){const{isOpen:U,mode:h,currentUrl:i,navVersion:f,close:B,toggleMode:P,goBack:Y,goForward:F,canGoBack:I,canGoForward:O,navigate:v,syncUrl:z}=ae(),[b,y]=s.useState(""),[j,M]=s.useState(!1),[_,m]=s.useState(!1),[l,N]=s.useState(()=>({x:Math.max(40,window.innerWidth-520),y:80})),[a,R]=s.useState({w:480,h:600}),[E,A]=s.useState(420),c=s.useRef(null),d=s.useRef(null),p=s.useRef(null),k=s.useRef(null),S=s.useRef(f);s.useEffect(()=>{try{const e=new URL(i);y(e.pathname)}catch{y(i)}},[i]),s.useEffect(()=>{var e;if(f!==S.current){S.current=f;return}if((e=k.current)!=null&&e.contentWindow)try{const r=new URL(i).pathname;k.current.contentWindow.postMessage({type:"docs-navigate",path:r},"*")}catch{}},[i,f]),s.useEffect(()=>{h==="floating"&&N(e=>({x:Math.max(40,window.innerWidth-a.w-40),y:e.y}))},[h,a.w]),s.useEffect(()=>{const e=r=>{var o;((o=r.data)==null?void 0:o.type)==="docs-route-change"&&typeof r.data.url=="string"&&z(r.data.url)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[z]);const T=s.useCallback(e=>{e.preventDefault();const r=b.trim();r&&(r.startsWith("/")?v(`${W}${r}`):r.startsWith("http")?v(r):v(`${W}/${r}`))},[b,v]),V=s.useCallback(e=>{h==="floating"&&(M(!0),c.current={startX:e.clientX,startY:e.clientY,startPosX:l.x,startPosY:l.y})},[h,l]);s.useEffect(()=>{if(!j)return;const e=o=>{c.current&&N({x:c.current.startPosX+(o.clientX-c.current.startX),y:c.current.startPosY+(o.clientY-c.current.startY)})},r=()=>{M(!1),c.current=null};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",r),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",r)}},[j]);const L=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),m(!0);const r=e.currentTarget.dataset.axis;d.current={startX:e.clientX,startY:e.clientY,startW:a.w,startH:a.h};const o=u=>{d.current&&R(g=>({w:r==="y"?g.w:Math.max(360,d.current.startW+(u.clientX-d.current.startX)),h:r==="x"?g.h:Math.max(400,d.current.startH+(u.clientY-d.current.startY))}))},w=()=>{m(!1),d.current=null,window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",w)};window.addEventListener("mousemove",o),window.addEventListener("mouseup",w)},[a]),$=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),m(!0),p.current={startX:e.clientX,startW:E};const r=w=>{if(!p.current)return;const u=p.current.startX-w.clientX;A(Math.max(320,Math.min(800,p.current.startW+u)))},o=()=>{m(!1),p.current=null,window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)},[E]),G=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),m(!0);const r=e.clientX,o=a.w,w=l.x,u=H=>{const q=r-H.clientX,X=Math.max(360,o+q);R(D=>({...D,w:X})),N(D=>({...D,x:w-(X-o)}))},g=()=>{m(!1),window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",g)};window.addEventListener("mousemove",u),window.addEventListener("mouseup",g)},[a.w,l.x]);if(!U)return null;const n=h==="docked";return t.jsxs("div",{className:C("flex flex-col bg-white overflow-hidden relative",n?"h-full border-l border-gray-200 shrink-0":"rounded-2xl shadow-2xl border border-gray-200"),style:n?{width:E}:{position:"fixed",left:l.x,top:l.y,width:a.w,height:a.h,zIndex:9999},children:[n&&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:$}),t.jsxs("div",{className:C("flex items-center justify-between px-4 py-2.5 bg-gray-50 border-b border-gray-200 shrink-0 select-none",!n&&"cursor-grab active:cursor-grabbing"),onMouseDown:n?void 0:V,children:[t.jsxs("div",{className:"flex items-center gap-2.5",children:[t.jsx(J,{className:"w-4 h-4 text-primary"}),t.jsx("span",{className:"text-sm font-semibold text-gray-900",children:x("docBrowserTitle")})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:P,className:"hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors",title:n?x("docBrowserFloatMode"):x("docBrowserDockMode"),children:n?t.jsx(K,{className:"w-3.5 h-3.5"}):t.jsx(Q,{className:"w-3.5 h-3.5"})}),t.jsx("button",{onClick:B,className:"hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors",title:x("docBrowserClose"),children:t.jsx(Z,{className:"w-3.5 h-3.5"})})]})]}),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:Y,disabled:!I,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(ee,{className:"w-4 h-4"})}),t.jsx("button",{onClick:F,disabled:!O,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(te,{className:"w-4 h-4"})}),t.jsxs("form",{onSubmit:T,className:"flex-1 relative",children:[t.jsx(re,{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:b,onChange:e=>y(e.target.value),placeholder:x("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:k,src:i,className:"absolute inset-0 w-full h-full border-0",title:"NextClaw Documentation",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms",allow:"clipboard-read; clipboard-write"},f),(_||j)&&t.jsx("div",{className:"absolute inset-0 z-10"})]}),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:i,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:[x("docBrowserOpenExternal"),t.jsx(se,{className:"w-3 h-3"})]})}),!n&&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:G}),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:L,"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:L,"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:L,children:t.jsx(oe,{className:"w-3 h-3 rotate-[-45deg]"})})]})]})}export{ce as DocBrowser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,j as s,at as Oe,au as $e,av as Fe,aw as xe,ax as qe,ay as He,az as E,aA as he,aB as Ke,aC as Ue,aD as ze,aE as Qe,aF as Be,aG as Ge,aH as Ve,aq as ye,ar as be,as as ke,ae as q,aI as Ye,aJ as Xe,aK as Je}from"./vendor-H2M3a_4Z.js";import{c as ve,i as H,t as c,S as We,b as Ze,d as et,e as tt,g as ge}from"./index-Dw8Ss2WH.js";import{T as at}from"./tabs-custom-CsFrOXUS.js";import{P as Te}from"./dialog-FRtXcCmk.js";import{u as nt}from"./useConfirmDialog-D3eI0Hfj.js";import{P as st,a as rt}from"./page-layout-DMpNQawS.js";var[K]=Ue("Tooltip",[he]),U=he(),Ce="TooltipProvider",lt=700,Y="tooltip.open",[ot,W]=K(Ce),Se=e=>{const{__scopeTooltip:t,delayDuration:a=lt,skipDelayDuration:n=300,disableHoverableContent:l=!1,children:r}=e,u=o.useRef(!0),b=o.useRef(!1),d=o.useRef(0);return o.useEffect(()=>{const x=d.current;return()=>window.clearTimeout(x)},[]),s.jsx(ot,{scope:t,isOpenDelayedRef:u,delayDuration:a,onOpen:o.useCallback(()=>{window.clearTimeout(d.current),u.current=!1},[]),onClose:o.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>u.current=!0,n)},[n]),isPointerInTransitRef:b,onPointerInTransitChange:o.useCallback(x=>{b.current=x},[]),disableHoverableContent:l,children:r})};Se.displayName=Ce;var L="Tooltip",[it,A]=K(L),Pe=e=>{const{__scopeTooltip:t,children:a,open:n,defaultOpen:l,onOpenChange:r,disableHoverableContent:u,delayDuration:b}=e,d=W(L,e.__scopeTooltip),x=U(t),[i,h]=o.useState(null),k=Oe(),m=o.useRef(0),T=u??d.disableHoverableContent,y=b??d.delayDuration,C=o.useRef(!1),[P,f]=$e({prop:n,defaultProp:l??!1,onChange:O=>{O?(d.onOpen(),document.dispatchEvent(new CustomEvent(Y))):d.onClose(),r==null||r(O)},caller:L}),v=o.useMemo(()=>P?C.current?"delayed-open":"instant-open":"closed",[P]),j=o.useCallback(()=>{window.clearTimeout(m.current),m.current=0,C.current=!1,f(!0)},[f]),S=o.useCallback(()=>{window.clearTimeout(m.current),m.current=0,f(!1)},[f]),_=o.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{C.current=!0,f(!0),m.current=0},y)},[y,f]);return o.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),s.jsx(Fe,{...x,children:s.jsx(it,{scope:t,contentId:k,open:P,stateAttribute:v,trigger:i,onTriggerChange:h,onTriggerEnter:o.useCallback(()=>{d.isOpenDelayedRef.current?_():j()},[d.isOpenDelayedRef,_,j]),onTriggerLeave:o.useCallback(()=>{T?S():(window.clearTimeout(m.current),m.current=0)},[S,T]),onOpen:j,onClose:S,disableHoverableContent:T,children:a})})};Pe.displayName=L;var X="TooltipTrigger",we=o.forwardRef((e,t)=>{const{__scopeTooltip:a,...n}=e,l=A(X,a),r=W(X,a),u=U(a),b=o.useRef(null),d=xe(t,b,l.onTriggerChange),x=o.useRef(!1),i=o.useRef(!1),h=o.useCallback(()=>x.current=!1,[]);return o.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),s.jsx(qe,{asChild:!0,...u,children:s.jsx(He.button,{"aria-describedby":l.open?l.contentId:void 0,"data-state":l.stateAttribute,...n,ref:d,onPointerMove:E(e.onPointerMove,k=>{k.pointerType!=="touch"&&!i.current&&!r.isPointerInTransitRef.current&&(l.onTriggerEnter(),i.current=!0)}),onPointerLeave:E(e.onPointerLeave,()=>{l.onTriggerLeave(),i.current=!1}),onPointerDown:E(e.onPointerDown,()=>{l.open&&l.onClose(),x.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:E(e.onFocus,()=>{x.current||l.onOpen()}),onBlur:E(e.onBlur,l.onClose),onClick:E(e.onClick,l.onClose)})})});we.displayName=X;var Z="TooltipPortal",[ct,ut]=K(Z,{forceMount:void 0}),je=e=>{const{__scopeTooltip:t,forceMount:a,children:n,container:l}=e,r=A(Z,t);return s.jsx(ct,{scope:t,forceMount:a,children:s.jsx(Te,{present:a||r.open,children:s.jsx(Ke,{asChild:!0,container:l,children:n})})})};je.displayName=Z;var R="TooltipContent",Ie=o.forwardRef((e,t)=>{const a=ut(R,e.__scopeTooltip),{forceMount:n=a.forceMount,side:l="top",...r}=e,u=A(R,e.__scopeTooltip);return s.jsx(Te,{present:n||u.open,children:u.disableHoverableContent?s.jsx(Ne,{side:l,...r,ref:t}):s.jsx(dt,{side:l,...r,ref:t})})}),dt=o.forwardRef((e,t)=>{const a=A(R,e.__scopeTooltip),n=W(R,e.__scopeTooltip),l=o.useRef(null),r=xe(t,l),[u,b]=o.useState(null),{trigger:d,onClose:x}=a,i=l.current,{onPointerInTransitChange:h}=n,k=o.useCallback(()=>{b(null),h(!1)},[h]),m=o.useCallback((T,y)=>{const C=T.currentTarget,P={x:T.clientX,y:T.clientY},f=xt(P,C.getBoundingClientRect()),v=ht(P,f),j=yt(y.getBoundingClientRect()),S=kt([...v,...j]);b(S),h(!0)},[h]);return o.useEffect(()=>()=>k(),[k]),o.useEffect(()=>{if(d&&i){const T=C=>m(C,i),y=C=>m(C,d);return d.addEventListener("pointerleave",T),i.addEventListener("pointerleave",y),()=>{d.removeEventListener("pointerleave",T),i.removeEventListener("pointerleave",y)}}},[d,i,m,k]),o.useEffect(()=>{if(u){const T=y=>{const C=y.target,P={x:y.clientX,y:y.clientY},f=(d==null?void 0:d.contains(C))||(i==null?void 0:i.contains(C)),v=!bt(P,u);f?k():v&&(k(),x())};return document.addEventListener("pointermove",T),()=>document.removeEventListener("pointermove",T)}},[d,i,u,x,k]),s.jsx(Ne,{...e,ref:r})}),[pt,mt]=K(L,{isInside:!1}),gt=Ge("TooltipContent"),Ne=o.forwardRef((e,t)=>{const{__scopeTooltip:a,children:n,"aria-label":l,onEscapeKeyDown:r,onPointerDownOutside:u,...b}=e,d=A(R,a),x=U(a),{onClose:i}=d;return o.useEffect(()=>(document.addEventListener(Y,i),()=>document.removeEventListener(Y,i)),[i]),o.useEffect(()=>{if(d.trigger){const h=k=>{const m=k.target;m!=null&&m.contains(d.trigger)&&i()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[d.trigger,i]),s.jsx(ze,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:r,onPointerDownOutside:u,onFocusOutside:h=>h.preventDefault(),onDismiss:i,children:s.jsxs(Qe,{"data-state":d.stateAttribute,...x,...b,ref:t,style:{...b.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(gt,{children:n}),s.jsx(pt,{scope:a,isInside:!0,children:s.jsx(Be,{id:d.contentId,role:"tooltip",children:l||n})})]})})});Ie.displayName=R;var Ee="TooltipArrow",ft=o.forwardRef((e,t)=>{const{__scopeTooltip:a,...n}=e,l=U(a);return mt(Ee,a).isInside?null:s.jsx(Ve,{...l,...n,ref:t})});ft.displayName=Ee;function xt(e,t){const a=Math.abs(t.top-e.y),n=Math.abs(t.bottom-e.y),l=Math.abs(t.right-e.x),r=Math.abs(t.left-e.x);switch(Math.min(a,n,l,r)){case r:return"left";case l:return"right";case a:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function ht(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 yt(e){const{top:t,right:a,bottom:n,left:l}=e;return[{x:l,y:t},{x:a,y:t},{x:a,y:n},{x:l,y:n}]}function bt(e,t){const{x:a,y:n}=e;let l=!1;for(let r=0,u=t.length-1;r<t.length;u=r++){const b=t[r],d=t[u],x=b.x,i=b.y,h=d.x,k=d.y;i>n!=k>n&&a<(h-x)*(n-i)/(k-i)+x&&(l=!l)}return l}function kt(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),vt(t)}function vt(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n<e.length;n++){const l=e[n];for(;t.length>=2;){const r=t[t.length-1],u=t[t.length-2];if((r.x-u.x)*(l.y-u.y)>=(r.y-u.y)*(l.x-u.x))t.pop();else break}t.push(l)}t.pop();const a=[];for(let n=e.length-1;n>=0;n--){const l=e[n];for(;a.length>=2;){const r=a[a.length-1],u=a[a.length-2];if((r.x-u.x)*(l.y-u.y)>=(r.y-u.y)*(l.x-u.x))a.pop();else break}a.push(l)}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 Tt=Se,Ct=Pe,St=we,Pt=je,Me=Ie;const wt=Tt,G=Ct,V=St,F=o.forwardRef(({className:e,sideOffset:t=4,...a},n)=>s.jsx(Pt,{children:s.jsx(Me,{ref:n,sideOffset:t,className:ve("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})}));F.displayName=Me.displayName;function z(e){return e==="plugin"?"plugins":"skills"}async function jt(e){var r,u;const t=new URLSearchParams,a=z(e.type);(r=e.q)!=null&&r.trim()&&t.set("q",e.q.trim()),(u=e.tag)!=null&&u.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(),l=await H.get(n?`/api/marketplace/${a}/items?${n}`:`/api/marketplace/${a}/items`);if(!l.ok)throw new Error(l.error.message);return l.data}async function It(e){const t=z(e.type),a=await H.post(`/api/marketplace/${t}/install`,e);if(!a.ok)throw new Error(a.error.message);return a.data}async function Nt(e){const t=z(e),a=await H.get(`/api/marketplace/${t}/installed`);if(!a.ok)throw new Error(a.error.message);return a.data}async function Et(e){const t=z(e.type),a=await H.post(`/api/marketplace/${t}/manage`,e);if(!a.ok)throw new Error(a.error.message);return a.data}function Mt(e){return ye({queryKey:["marketplace-items",e],queryFn:()=>jt(e),staleTime:15e3})}function Rt(e){return ye({queryKey:["marketplace-installed",e],queryFn:()=>Nt(e),staleTime:1e4})}function Dt(){const e=be();return ke({mutationFn:t=>It(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"?c("marketplaceInstallSuccessPlugin"):c("marketplaceInstallSuccessSkill");q.success(t.message||a)},onError:t=>{q.error(t.message||c("marketplaceInstallFailed"))}})}function Lt(){const e=be();return ke({mutationFn:t=>Et(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"?c("marketplaceEnableSuccess"):t.action==="disable"?c("marketplaceDisableSuccess"):c("marketplaceUninstallSuccess");q.success(t.message||a)},onError:t=>{q.error(t.message||c("marketplaceOperationFailed"))}})}const At=12;function J(e){return(e??"").trim().toLowerCase()}function M(e,t){const a=J(t);return a.length>0?`${e}:${a}`:""}function _t(e){const t=new Map;for(const a of e){const n=[a.install.spec,a.slug,a.id];for(const l of n){const r=M(a.type,l);!r||t.has(r)||t.set(r,a)}}return t}function Ot(e){const t=new Map;for(const a of e){const n=[a.spec,a.id,a.label];for(const l of n){const r=M(a.type,l);!r||t.has(r)||t.set(r,a)}}return t}function $t(e,t){const a=[e.install.spec,e.slug,e.id];for(const n of a){const l=M(e.type,n);if(!l)continue;const r=t.get(l);if(r)return r}}function Ft(e,t){const a=t.get(M(e.type,e.spec));if(a)return a;const n=t.get(M(e.type,e.id));return n||t.get(M(e.type,e.label))}function qt(e,t,a){const n=J(a);return n?[e.id,e.spec,e.label,t==null?void 0:t.name,t==null?void 0:t.slug,t==null?void 0:t.summary,...(t==null?void 0:t.tags)??[]].map(r=>J(r)).filter(Boolean).some(r=>r.includes(n)):!0}function Ht(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 Kt({name:e,fallback:t}){const a=e||t,n=a.substring(0,2).toUpperCase(),l=Ht(a);return s.jsx("div",{className:ve("flex items-center justify-center w-10 h-10 rounded-xl text-white font-semibold text-sm shrink-0",l),children:n})}function Ut(e){return s.jsx("div",{className:"mb-4",children:s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsxs("div",{className:"flex-1 min-w-0 relative",children:[s.jsx(Je,{className:"h-4 w-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2"}),s.jsx("input",{value:e.searchText,onChange:t=>e.onSearchTextChange(t.target.value),placeholder:e.searchPlaceholder,className:"w-full h-9 border border-gray-200/80 rounded-xl pl-9 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40"})]}),e.scope==="all"&&s.jsxs(We,{value:e.sort,onValueChange:t=>e.onSortChange(t),children:[s.jsx(Ze,{className:"h-9 w-[150px] shrink-0 rounded-lg",children:s.jsx(et,{})}),s.jsxs(tt,{children:[s.jsx(ge,{value:"relevance",children:c("marketplaceSortRelevance")}),s.jsx(ge,{value:"updated",children:c("marketplaceSortUpdated")})]})]})]})})}function fe(e){var P,f,v,j,S;const t=e.record,a=(t==null?void 0:t.type)==="plugin"?t:void 0,n=((P=e.item)==null?void 0:P.type)??(t==null?void 0:t.type),l=((f=e.item)==null?void 0:f.name)??(t==null?void 0:t.label)??(t==null?void 0:t.id)??(t==null?void 0:t.spec)??c("marketplaceUnknownItem"),r=((v=e.item)==null?void 0:v.summary)??(t?c("marketplaceInstalledLocalSummary"):""),u=((j=e.item)==null?void 0:j.install.spec)??(t==null?void 0:t.spec)??"",b=(t==null?void 0:t.id)||(t==null?void 0:t.spec),d=!!b&&e.manageState.isPending&&e.manageState.targetId===b,x=!!a,i=(t==null?void 0:t.type)==="plugin"&&t.origin!=="bundled",h=(t==null?void 0:t.type)==="skill"&&t.source==="workspace",k=!!(i||h),m=t?t.enabled===!1||t.runtimeStatus==="disabled":!1,T=(S=e.item)==null?void 0:S.install.spec,y=typeof T=="string"&&e.installState.installingSpecs.has(T),C=n==="plugin"?c("marketplaceTypePlugin"):n==="skill"?c("marketplaceTypeSkill"):c("marketplaceTypeExtension");return s.jsxs("article",{className:"group bg-white border border-gray-200/40 hover:border-gray-200/80 rounded-2xl px-5 py-4 hover:shadow-md shadow-sm transition-all flex items-start gap-3.5 justify-between cursor-default",children:[s.jsxs("div",{className:"flex gap-3 min-w-0 flex-1 h-full items-start",children:[s.jsx(Kt,{name:l,fallback:u||c("marketplaceTypeExtension")}),s.jsx("div",{className:"min-w-0 flex-1 flex flex-col justify-center h-full",children:s.jsxs(wt,{delayDuration:400,children:[s.jsxs(G,{children:[s.jsx(V,{asChild:!0,children:s.jsx("div",{className:"text-[14px] font-semibold text-gray-900 truncate leading-tight cursor-default",children:l})}),s.jsx(F,{className:"max-w-[300px] text-xs",children:l})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 mb-1.5",children:[s.jsx("span",{className:"text-[11px] text-gray-500 font-medium",children:C}),u&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-[10px] text-gray-300",children:"•"}),s.jsxs(G,{children:[s.jsx(V,{asChild:!0,children:s.jsx("span",{className:"text-[11px] text-gray-400 truncate max-w-full font-mono cursor-default",children:u})}),s.jsx(F,{className:"max-w-[300px] text-xs font-mono break-all",children:u})]})]})]}),s.jsxs(G,{children:[s.jsx(V,{asChild:!0,children:s.jsx("p",{className:"text-[12px] text-gray-500/90 line-clamp-1 transition-colors leading-relaxed text-left cursor-default",children:r})}),r&&s.jsx(F,{className:"max-w-[400px] text-xs leading-relaxed",children:r})]})]})})]}),s.jsxs("div",{className:"shrink-0 flex items-center h-full",children:[e.item&&!t&&s.jsx("button",{onClick:()=>e.onInstall(e.item),disabled:y,className:"inline-flex items-center gap-1.5 h-8 px-4 rounded-xl text-xs font-medium bg-primary text-white hover:bg-primary-600 disabled:opacity-50 transition-colors",children:y?c("marketplaceInstalling"):c("marketplaceInstall")}),a&&x&&s.jsx("button",{disabled:e.manageState.isPending,onClick:()=>e.onManage(m?"enable":"disable",a),className:"inline-flex items-center h-8 px-4 rounded-xl text-xs font-medium border border-gray-200/80 text-gray-600 bg-white hover:bg-gray-50 hover:border-gray-300 disabled:opacity-50 transition-colors",children:d&&e.manageState.action!=="uninstall"?e.manageState.action==="enable"?c("marketplaceEnabling"):c("marketplaceDisabling"):m?c("marketplaceEnable"):c("marketplaceDisable")}),t&&k&&s.jsx("button",{disabled:e.manageState.isPending,onClick:()=>e.onManage("uninstall",t),className:"inline-flex items-center h-8 px-4 rounded-xl text-xs font-medium border border-rose-100 text-rose-500 bg-white hover:bg-rose-50 hover:border-rose-200 disabled:opacity-50 transition-colors",children:d&&e.manageState.action==="uninstall"?c("marketplaceRemoving"):c("marketplaceUninstall")})]})]})}function zt(e){return s.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2",children:[s.jsx("button",{className:"h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40",onClick:e.onPrev,disabled:e.page<=1||e.busy,children:c("prev")}),s.jsx("div",{className:"text-sm text-gray-600 min-w-20 text-center",children:e.totalPages===0?"0 / 0":`${e.page} / ${e.totalPages}`}),s.jsx("button",{className:"h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40",onClick:e.onNext,disabled:e.totalPages===0||e.page>=e.totalPages||e.busy,children:c("next")})]})}function Jt(){var le,oe,ie,ce,ue,de,pe,me;const e=Ye(),t=Xe(),a=o.useMemo(()=>t.type==="plugins"||t.type==="skills"?t.type:null,[t.type]);o.useEffect(()=>{a||e("/marketplace/plugins",{replace:!0})},[a,e]);const n=a==="skills"?"skill":"plugin",r=n==="plugin"?{pageTitle:"marketplacePluginsPageTitle",pageDescription:"marketplacePluginsPageDescription",tabMarketplace:"marketplaceTabMarketplacePlugins",tabInstalled:"marketplaceTabInstalledPlugins",searchPlaceholder:"marketplaceSearchPlaceholderPlugins",sectionCatalog:"marketplaceSectionPlugins",sectionInstalled:"marketplaceSectionInstalledPlugins",errorLoadData:"marketplaceErrorLoadingPluginsData",errorLoadInstalled:"marketplaceErrorLoadingInstalledPlugins",emptyData:"marketplaceNoPlugins",emptyInstalled:"marketplaceNoInstalledPlugins",installedCountSuffix:"marketplaceInstalledPluginsCountSuffix"}:{pageTitle:"marketplaceSkillsPageTitle",pageDescription:"marketplaceSkillsPageDescription",tabMarketplace:"marketplaceTabMarketplaceSkills",tabInstalled:"marketplaceTabInstalledSkills",searchPlaceholder:"marketplaceSearchPlaceholderSkills",sectionCatalog:"marketplaceSectionSkills",sectionInstalled:"marketplaceSectionInstalledSkills",errorLoadData:"marketplaceErrorLoadingSkillsData",errorLoadInstalled:"marketplaceErrorLoadingInstalledSkills",emptyData:"marketplaceNoSkills",emptyInstalled:"marketplaceNoInstalledSkills",installedCountSuffix:"marketplaceInstalledSkillsCountSuffix"},[u,b]=o.useState(""),[d,x]=o.useState(""),[i,h]=o.useState("all"),[k,m]=o.useState("relevance"),[T,y]=o.useState(1),[C,P]=o.useState(new Set);o.useEffect(()=>{const p=setTimeout(()=>{y(1),x(u.trim())},250);return()=>clearTimeout(p)},[u]),o.useEffect(()=>{y(1)},[n]);const f=Rt(n),v=Mt({q:d||void 0,type:n,sort:k,page:T,pageSize:At}),j=Dt(),S=Lt(),{confirm:_,ConfirmDialog:O}=nt(),$=o.useMemo(()=>{var p;return((p=f.data)==null?void 0:p.records)??[]},[(le=f.data)==null?void 0:le.records]),N=o.useMemo(()=>{var p;return((p=v.data)==null?void 0:p.items)??[]},[(oe=v.data)==null?void 0:oe.items]),ee=o.useMemo(()=>_t(N),[N]),Re=o.useMemo(()=>Ot($),[$]),D=o.useMemo(()=>{const p=$.filter(g=>g.type===n).map(g=>({key:`${g.type}:${g.spec}:${g.id??""}`,record:g,item:Ft(g,ee)})).filter(g=>qt(g.record,g.item,d));return p.sort((g,w)=>{const I=g.record.installedAt?Date.parse(g.record.installedAt):Number.NaN,B=w.record.installedAt?Date.parse(w.record.installedAt):Number.NaN,Ae=!Number.isNaN(I),_e=!Number.isNaN(B);return Ae&&_e&&I!==B?B-I:g.record.spec.localeCompare(w.record.spec)}),p},[$,n,ee,d]),te=i==="installed"?D.length:((ie=v.data)==null?void 0:ie.total)??0,Q=i==="installed"?1:((ce=v.data)==null?void 0:ce.totalPages)??0,De=o.useMemo(()=>i==="installed"?f.isLoading?c("loading"):`${D.length} ${c(r.installedCountSuffix)}`:v.data?`${N.length} / ${te}`:c("loading"),[i,f.isLoading,D.length,v.data,N.length,te,r.installedCountSuffix]),ae={installingSpecs:C},ne={isPending:S.isPending,targetId:((ue=S.variables)==null?void 0:ue.id)||((de=S.variables)==null?void 0:de.spec),action:(pe=S.variables)==null?void 0:pe.action},Le=[{id:"all",label:c(r.tabMarketplace)},{id:"installed",label:c(r.tabInstalled),count:((me=f.data)==null?void 0:me.total)??0}],se=async p=>{const g=p.install.spec;if(!C.has(g)){P(w=>{const I=new Set(w);return I.add(g),I});try{await j.mutateAsync({type:p.type,spec:g,kind:p.install.kind,...p.type==="skill"?{skill:p.slug,installPath:`skills/${p.slug}`}:{}})}catch{}finally{P(w=>{if(!w.has(g))return w;const I=new Set(w);return I.delete(g),I})}}},re=async(p,g)=>{if(S.isPending)return;const w=g.id||g.spec;w&&(p==="uninstall"&&!await _({title:`${c("marketplaceUninstallTitle")} ${w}?`,description:c("marketplaceUninstallDescription"),confirmLabel:c("marketplaceUninstall"),variant:"destructive"})||S.mutate({type:g.type,action:p,id:w,spec:g.spec}))};return s.jsxs(st,{children:[s.jsx(rt,{title:c(r.pageTitle),description:c(r.pageDescription)}),s.jsx(at,{tabs:Le,activeTab:i,onChange:p=>{h(p),y(1)},className:"mb-4"}),s.jsx(Ut,{scope:i,searchText:u,searchPlaceholder:c(r.searchPlaceholder),sort:k,onSearchTextChange:b,onSortChange:p=>{y(1),m(p)}}),s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-[14px] font-semibold text-gray-900",children:i==="installed"?c(r.sectionInstalled):c(r.sectionCatalog)}),s.jsx("span",{className:"text-[12px] text-gray-500",children:De})]}),i==="all"&&v.isError&&s.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[c(r.errorLoadData),": ",v.error.message]}),i==="installed"&&f.isError&&s.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[c(r.errorLoadInstalled),": ",f.error.message]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 2xl:grid-cols-3 gap-3",children:[i==="all"&&N.map(p=>s.jsx(fe,{item:p,record:$t(p,Re),installState:ae,manageState:ne,onInstall:se,onManage:re},p.id)),i==="installed"&&D.map(p=>s.jsx(fe,{item:p.item,record:p.record,installState:ae,manageState:ne,onInstall:se,onManage:re},p.key))]}),i==="all"&&!v.isLoading&&!v.isError&&N.length===0&&s.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:c(r.emptyData)}),i==="installed"&&!f.isLoading&&!f.isError&&D.length===0&&s.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:c(r.emptyInstalled)})]}),i==="all"&&s.jsx(zt,{page:T,totalPages:Q,busy:v.isFetching,onPrev:()=>y(p=>Math.max(1,p-1)),onNext:()=>y(p=>Q>0?Math.min(Q,p+1):p+1)}),s.jsx(O,{})]})}export{Jt as MarketplacePage};
|
|
1
|
+
import{r as o,j as s,at as Oe,au as $e,av as Fe,aw as xe,ax as qe,ay as He,az as E,aA as he,aB as Ke,aC as Ue,aD as ze,aE as Qe,aF as Be,aG as Ge,aH as Ve,aq as ye,ar as be,as as ke,ae as q,aI as Ye,aJ as Xe,aK as Je}from"./vendor-H2M3a_4Z.js";import{c as ve,i as H,t as c,S as We,b as Ze,d as et,e as tt,g as ge}from"./index-BTE5dHqH.js";import{T as at}from"./tabs-custom-DgryVfGt.js";import{P as Te}from"./dialog-CJMXeCpK.js";import{u as nt}from"./useConfirmDialog-DqTlJNqa.js";import{P as st,a as rt}from"./page-layout-C_pPVkYP.js";var[K]=Ue("Tooltip",[he]),U=he(),Ce="TooltipProvider",lt=700,Y="tooltip.open",[ot,W]=K(Ce),Se=e=>{const{__scopeTooltip:t,delayDuration:a=lt,skipDelayDuration:n=300,disableHoverableContent:l=!1,children:r}=e,u=o.useRef(!0),b=o.useRef(!1),d=o.useRef(0);return o.useEffect(()=>{const x=d.current;return()=>window.clearTimeout(x)},[]),s.jsx(ot,{scope:t,isOpenDelayedRef:u,delayDuration:a,onOpen:o.useCallback(()=>{window.clearTimeout(d.current),u.current=!1},[]),onClose:o.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>u.current=!0,n)},[n]),isPointerInTransitRef:b,onPointerInTransitChange:o.useCallback(x=>{b.current=x},[]),disableHoverableContent:l,children:r})};Se.displayName=Ce;var L="Tooltip",[it,A]=K(L),Pe=e=>{const{__scopeTooltip:t,children:a,open:n,defaultOpen:l,onOpenChange:r,disableHoverableContent:u,delayDuration:b}=e,d=W(L,e.__scopeTooltip),x=U(t),[i,h]=o.useState(null),k=Oe(),m=o.useRef(0),T=u??d.disableHoverableContent,y=b??d.delayDuration,C=o.useRef(!1),[P,f]=$e({prop:n,defaultProp:l??!1,onChange:O=>{O?(d.onOpen(),document.dispatchEvent(new CustomEvent(Y))):d.onClose(),r==null||r(O)},caller:L}),v=o.useMemo(()=>P?C.current?"delayed-open":"instant-open":"closed",[P]),j=o.useCallback(()=>{window.clearTimeout(m.current),m.current=0,C.current=!1,f(!0)},[f]),S=o.useCallback(()=>{window.clearTimeout(m.current),m.current=0,f(!1)},[f]),_=o.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{C.current=!0,f(!0),m.current=0},y)},[y,f]);return o.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),s.jsx(Fe,{...x,children:s.jsx(it,{scope:t,contentId:k,open:P,stateAttribute:v,trigger:i,onTriggerChange:h,onTriggerEnter:o.useCallback(()=>{d.isOpenDelayedRef.current?_():j()},[d.isOpenDelayedRef,_,j]),onTriggerLeave:o.useCallback(()=>{T?S():(window.clearTimeout(m.current),m.current=0)},[S,T]),onOpen:j,onClose:S,disableHoverableContent:T,children:a})})};Pe.displayName=L;var X="TooltipTrigger",we=o.forwardRef((e,t)=>{const{__scopeTooltip:a,...n}=e,l=A(X,a),r=W(X,a),u=U(a),b=o.useRef(null),d=xe(t,b,l.onTriggerChange),x=o.useRef(!1),i=o.useRef(!1),h=o.useCallback(()=>x.current=!1,[]);return o.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),s.jsx(qe,{asChild:!0,...u,children:s.jsx(He.button,{"aria-describedby":l.open?l.contentId:void 0,"data-state":l.stateAttribute,...n,ref:d,onPointerMove:E(e.onPointerMove,k=>{k.pointerType!=="touch"&&!i.current&&!r.isPointerInTransitRef.current&&(l.onTriggerEnter(),i.current=!0)}),onPointerLeave:E(e.onPointerLeave,()=>{l.onTriggerLeave(),i.current=!1}),onPointerDown:E(e.onPointerDown,()=>{l.open&&l.onClose(),x.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:E(e.onFocus,()=>{x.current||l.onOpen()}),onBlur:E(e.onBlur,l.onClose),onClick:E(e.onClick,l.onClose)})})});we.displayName=X;var Z="TooltipPortal",[ct,ut]=K(Z,{forceMount:void 0}),je=e=>{const{__scopeTooltip:t,forceMount:a,children:n,container:l}=e,r=A(Z,t);return s.jsx(ct,{scope:t,forceMount:a,children:s.jsx(Te,{present:a||r.open,children:s.jsx(Ke,{asChild:!0,container:l,children:n})})})};je.displayName=Z;var R="TooltipContent",Ie=o.forwardRef((e,t)=>{const a=ut(R,e.__scopeTooltip),{forceMount:n=a.forceMount,side:l="top",...r}=e,u=A(R,e.__scopeTooltip);return s.jsx(Te,{present:n||u.open,children:u.disableHoverableContent?s.jsx(Ne,{side:l,...r,ref:t}):s.jsx(dt,{side:l,...r,ref:t})})}),dt=o.forwardRef((e,t)=>{const a=A(R,e.__scopeTooltip),n=W(R,e.__scopeTooltip),l=o.useRef(null),r=xe(t,l),[u,b]=o.useState(null),{trigger:d,onClose:x}=a,i=l.current,{onPointerInTransitChange:h}=n,k=o.useCallback(()=>{b(null),h(!1)},[h]),m=o.useCallback((T,y)=>{const C=T.currentTarget,P={x:T.clientX,y:T.clientY},f=xt(P,C.getBoundingClientRect()),v=ht(P,f),j=yt(y.getBoundingClientRect()),S=kt([...v,...j]);b(S),h(!0)},[h]);return o.useEffect(()=>()=>k(),[k]),o.useEffect(()=>{if(d&&i){const T=C=>m(C,i),y=C=>m(C,d);return d.addEventListener("pointerleave",T),i.addEventListener("pointerleave",y),()=>{d.removeEventListener("pointerleave",T),i.removeEventListener("pointerleave",y)}}},[d,i,m,k]),o.useEffect(()=>{if(u){const T=y=>{const C=y.target,P={x:y.clientX,y:y.clientY},f=(d==null?void 0:d.contains(C))||(i==null?void 0:i.contains(C)),v=!bt(P,u);f?k():v&&(k(),x())};return document.addEventListener("pointermove",T),()=>document.removeEventListener("pointermove",T)}},[d,i,u,x,k]),s.jsx(Ne,{...e,ref:r})}),[pt,mt]=K(L,{isInside:!1}),gt=Ge("TooltipContent"),Ne=o.forwardRef((e,t)=>{const{__scopeTooltip:a,children:n,"aria-label":l,onEscapeKeyDown:r,onPointerDownOutside:u,...b}=e,d=A(R,a),x=U(a),{onClose:i}=d;return o.useEffect(()=>(document.addEventListener(Y,i),()=>document.removeEventListener(Y,i)),[i]),o.useEffect(()=>{if(d.trigger){const h=k=>{const m=k.target;m!=null&&m.contains(d.trigger)&&i()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[d.trigger,i]),s.jsx(ze,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:r,onPointerDownOutside:u,onFocusOutside:h=>h.preventDefault(),onDismiss:i,children:s.jsxs(Qe,{"data-state":d.stateAttribute,...x,...b,ref:t,style:{...b.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(gt,{children:n}),s.jsx(pt,{scope:a,isInside:!0,children:s.jsx(Be,{id:d.contentId,role:"tooltip",children:l||n})})]})})});Ie.displayName=R;var Ee="TooltipArrow",ft=o.forwardRef((e,t)=>{const{__scopeTooltip:a,...n}=e,l=U(a);return mt(Ee,a).isInside?null:s.jsx(Ve,{...l,...n,ref:t})});ft.displayName=Ee;function xt(e,t){const a=Math.abs(t.top-e.y),n=Math.abs(t.bottom-e.y),l=Math.abs(t.right-e.x),r=Math.abs(t.left-e.x);switch(Math.min(a,n,l,r)){case r:return"left";case l:return"right";case a:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function ht(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 yt(e){const{top:t,right:a,bottom:n,left:l}=e;return[{x:l,y:t},{x:a,y:t},{x:a,y:n},{x:l,y:n}]}function bt(e,t){const{x:a,y:n}=e;let l=!1;for(let r=0,u=t.length-1;r<t.length;u=r++){const b=t[r],d=t[u],x=b.x,i=b.y,h=d.x,k=d.y;i>n!=k>n&&a<(h-x)*(n-i)/(k-i)+x&&(l=!l)}return l}function kt(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),vt(t)}function vt(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n<e.length;n++){const l=e[n];for(;t.length>=2;){const r=t[t.length-1],u=t[t.length-2];if((r.x-u.x)*(l.y-u.y)>=(r.y-u.y)*(l.x-u.x))t.pop();else break}t.push(l)}t.pop();const a=[];for(let n=e.length-1;n>=0;n--){const l=e[n];for(;a.length>=2;){const r=a[a.length-1],u=a[a.length-2];if((r.x-u.x)*(l.y-u.y)>=(r.y-u.y)*(l.x-u.x))a.pop();else break}a.push(l)}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 Tt=Se,Ct=Pe,St=we,Pt=je,Me=Ie;const wt=Tt,G=Ct,V=St,F=o.forwardRef(({className:e,sideOffset:t=4,...a},n)=>s.jsx(Pt,{children:s.jsx(Me,{ref:n,sideOffset:t,className:ve("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})}));F.displayName=Me.displayName;function z(e){return e==="plugin"?"plugins":"skills"}async function jt(e){var r,u;const t=new URLSearchParams,a=z(e.type);(r=e.q)!=null&&r.trim()&&t.set("q",e.q.trim()),(u=e.tag)!=null&&u.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(),l=await H.get(n?`/api/marketplace/${a}/items?${n}`:`/api/marketplace/${a}/items`);if(!l.ok)throw new Error(l.error.message);return l.data}async function It(e){const t=z(e.type),a=await H.post(`/api/marketplace/${t}/install`,e);if(!a.ok)throw new Error(a.error.message);return a.data}async function Nt(e){const t=z(e),a=await H.get(`/api/marketplace/${t}/installed`);if(!a.ok)throw new Error(a.error.message);return a.data}async function Et(e){const t=z(e.type),a=await H.post(`/api/marketplace/${t}/manage`,e);if(!a.ok)throw new Error(a.error.message);return a.data}function Mt(e){return ye({queryKey:["marketplace-items",e],queryFn:()=>jt(e),staleTime:15e3})}function Rt(e){return ye({queryKey:["marketplace-installed",e],queryFn:()=>Nt(e),staleTime:1e4})}function Dt(){const e=be();return ke({mutationFn:t=>It(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"?c("marketplaceInstallSuccessPlugin"):c("marketplaceInstallSuccessSkill");q.success(t.message||a)},onError:t=>{q.error(t.message||c("marketplaceInstallFailed"))}})}function Lt(){const e=be();return ke({mutationFn:t=>Et(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"?c("marketplaceEnableSuccess"):t.action==="disable"?c("marketplaceDisableSuccess"):c("marketplaceUninstallSuccess");q.success(t.message||a)},onError:t=>{q.error(t.message||c("marketplaceOperationFailed"))}})}const At=12;function J(e){return(e??"").trim().toLowerCase()}function M(e,t){const a=J(t);return a.length>0?`${e}:${a}`:""}function _t(e){const t=new Map;for(const a of e){const n=[a.install.spec,a.slug,a.id];for(const l of n){const r=M(a.type,l);!r||t.has(r)||t.set(r,a)}}return t}function Ot(e){const t=new Map;for(const a of e){const n=[a.spec,a.id,a.label];for(const l of n){const r=M(a.type,l);!r||t.has(r)||t.set(r,a)}}return t}function $t(e,t){const a=[e.install.spec,e.slug,e.id];for(const n of a){const l=M(e.type,n);if(!l)continue;const r=t.get(l);if(r)return r}}function Ft(e,t){const a=t.get(M(e.type,e.spec));if(a)return a;const n=t.get(M(e.type,e.id));return n||t.get(M(e.type,e.label))}function qt(e,t,a){const n=J(a);return n?[e.id,e.spec,e.label,t==null?void 0:t.name,t==null?void 0:t.slug,t==null?void 0:t.summary,...(t==null?void 0:t.tags)??[]].map(r=>J(r)).filter(Boolean).some(r=>r.includes(n)):!0}function Ht(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 Kt({name:e,fallback:t}){const a=e||t,n=a.substring(0,2).toUpperCase(),l=Ht(a);return s.jsx("div",{className:ve("flex items-center justify-center w-10 h-10 rounded-xl text-white font-semibold text-sm shrink-0",l),children:n})}function Ut(e){return s.jsx("div",{className:"mb-4",children:s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsxs("div",{className:"flex-1 min-w-0 relative",children:[s.jsx(Je,{className:"h-4 w-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2"}),s.jsx("input",{value:e.searchText,onChange:t=>e.onSearchTextChange(t.target.value),placeholder:e.searchPlaceholder,className:"w-full h-9 border border-gray-200/80 rounded-xl pl-9 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40"})]}),e.scope==="all"&&s.jsxs(We,{value:e.sort,onValueChange:t=>e.onSortChange(t),children:[s.jsx(Ze,{className:"h-9 w-[150px] shrink-0 rounded-lg",children:s.jsx(et,{})}),s.jsxs(tt,{children:[s.jsx(ge,{value:"relevance",children:c("marketplaceSortRelevance")}),s.jsx(ge,{value:"updated",children:c("marketplaceSortUpdated")})]})]})]})})}function fe(e){var P,f,v,j,S;const t=e.record,a=(t==null?void 0:t.type)==="plugin"?t:void 0,n=((P=e.item)==null?void 0:P.type)??(t==null?void 0:t.type),l=((f=e.item)==null?void 0:f.name)??(t==null?void 0:t.label)??(t==null?void 0:t.id)??(t==null?void 0:t.spec)??c("marketplaceUnknownItem"),r=((v=e.item)==null?void 0:v.summary)??(t?c("marketplaceInstalledLocalSummary"):""),u=((j=e.item)==null?void 0:j.install.spec)??(t==null?void 0:t.spec)??"",b=(t==null?void 0:t.id)||(t==null?void 0:t.spec),d=!!b&&e.manageState.isPending&&e.manageState.targetId===b,x=!!a,i=(t==null?void 0:t.type)==="plugin"&&t.origin!=="bundled",h=(t==null?void 0:t.type)==="skill"&&t.source==="workspace",k=!!(i||h),m=t?t.enabled===!1||t.runtimeStatus==="disabled":!1,T=(S=e.item)==null?void 0:S.install.spec,y=typeof T=="string"&&e.installState.installingSpecs.has(T),C=n==="plugin"?c("marketplaceTypePlugin"):n==="skill"?c("marketplaceTypeSkill"):c("marketplaceTypeExtension");return s.jsxs("article",{className:"group bg-white border border-gray-200/40 hover:border-gray-200/80 rounded-2xl px-5 py-4 hover:shadow-md shadow-sm transition-all flex items-start gap-3.5 justify-between cursor-default",children:[s.jsxs("div",{className:"flex gap-3 min-w-0 flex-1 h-full items-start",children:[s.jsx(Kt,{name:l,fallback:u||c("marketplaceTypeExtension")}),s.jsx("div",{className:"min-w-0 flex-1 flex flex-col justify-center h-full",children:s.jsxs(wt,{delayDuration:400,children:[s.jsxs(G,{children:[s.jsx(V,{asChild:!0,children:s.jsx("div",{className:"text-[14px] font-semibold text-gray-900 truncate leading-tight cursor-default",children:l})}),s.jsx(F,{className:"max-w-[300px] text-xs",children:l})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 mb-1.5",children:[s.jsx("span",{className:"text-[11px] text-gray-500 font-medium",children:C}),u&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-[10px] text-gray-300",children:"•"}),s.jsxs(G,{children:[s.jsx(V,{asChild:!0,children:s.jsx("span",{className:"text-[11px] text-gray-400 truncate max-w-full font-mono cursor-default",children:u})}),s.jsx(F,{className:"max-w-[300px] text-xs font-mono break-all",children:u})]})]})]}),s.jsxs(G,{children:[s.jsx(V,{asChild:!0,children:s.jsx("p",{className:"text-[12px] text-gray-500/90 line-clamp-1 transition-colors leading-relaxed text-left cursor-default",children:r})}),r&&s.jsx(F,{className:"max-w-[400px] text-xs leading-relaxed",children:r})]})]})})]}),s.jsxs("div",{className:"shrink-0 flex items-center h-full",children:[e.item&&!t&&s.jsx("button",{onClick:()=>e.onInstall(e.item),disabled:y,className:"inline-flex items-center gap-1.5 h-8 px-4 rounded-xl text-xs font-medium bg-primary text-white hover:bg-primary-600 disabled:opacity-50 transition-colors",children:y?c("marketplaceInstalling"):c("marketplaceInstall")}),a&&x&&s.jsx("button",{disabled:e.manageState.isPending,onClick:()=>e.onManage(m?"enable":"disable",a),className:"inline-flex items-center h-8 px-4 rounded-xl text-xs font-medium border border-gray-200/80 text-gray-600 bg-white hover:bg-gray-50 hover:border-gray-300 disabled:opacity-50 transition-colors",children:d&&e.manageState.action!=="uninstall"?e.manageState.action==="enable"?c("marketplaceEnabling"):c("marketplaceDisabling"):m?c("marketplaceEnable"):c("marketplaceDisable")}),t&&k&&s.jsx("button",{disabled:e.manageState.isPending,onClick:()=>e.onManage("uninstall",t),className:"inline-flex items-center h-8 px-4 rounded-xl text-xs font-medium border border-rose-100 text-rose-500 bg-white hover:bg-rose-50 hover:border-rose-200 disabled:opacity-50 transition-colors",children:d&&e.manageState.action==="uninstall"?c("marketplaceRemoving"):c("marketplaceUninstall")})]})]})}function zt(e){return s.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2",children:[s.jsx("button",{className:"h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40",onClick:e.onPrev,disabled:e.page<=1||e.busy,children:c("prev")}),s.jsx("div",{className:"text-sm text-gray-600 min-w-20 text-center",children:e.totalPages===0?"0 / 0":`${e.page} / ${e.totalPages}`}),s.jsx("button",{className:"h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40",onClick:e.onNext,disabled:e.totalPages===0||e.page>=e.totalPages||e.busy,children:c("next")})]})}function Jt(){var le,oe,ie,ce,ue,de,pe,me;const e=Ye(),t=Xe(),a=o.useMemo(()=>t.type==="plugins"||t.type==="skills"?t.type:null,[t.type]);o.useEffect(()=>{a||e("/marketplace/plugins",{replace:!0})},[a,e]);const n=a==="skills"?"skill":"plugin",r=n==="plugin"?{pageTitle:"marketplacePluginsPageTitle",pageDescription:"marketplacePluginsPageDescription",tabMarketplace:"marketplaceTabMarketplacePlugins",tabInstalled:"marketplaceTabInstalledPlugins",searchPlaceholder:"marketplaceSearchPlaceholderPlugins",sectionCatalog:"marketplaceSectionPlugins",sectionInstalled:"marketplaceSectionInstalledPlugins",errorLoadData:"marketplaceErrorLoadingPluginsData",errorLoadInstalled:"marketplaceErrorLoadingInstalledPlugins",emptyData:"marketplaceNoPlugins",emptyInstalled:"marketplaceNoInstalledPlugins",installedCountSuffix:"marketplaceInstalledPluginsCountSuffix"}:{pageTitle:"marketplaceSkillsPageTitle",pageDescription:"marketplaceSkillsPageDescription",tabMarketplace:"marketplaceTabMarketplaceSkills",tabInstalled:"marketplaceTabInstalledSkills",searchPlaceholder:"marketplaceSearchPlaceholderSkills",sectionCatalog:"marketplaceSectionSkills",sectionInstalled:"marketplaceSectionInstalledSkills",errorLoadData:"marketplaceErrorLoadingSkillsData",errorLoadInstalled:"marketplaceErrorLoadingInstalledSkills",emptyData:"marketplaceNoSkills",emptyInstalled:"marketplaceNoInstalledSkills",installedCountSuffix:"marketplaceInstalledSkillsCountSuffix"},[u,b]=o.useState(""),[d,x]=o.useState(""),[i,h]=o.useState("all"),[k,m]=o.useState("relevance"),[T,y]=o.useState(1),[C,P]=o.useState(new Set);o.useEffect(()=>{const p=setTimeout(()=>{y(1),x(u.trim())},250);return()=>clearTimeout(p)},[u]),o.useEffect(()=>{y(1)},[n]);const f=Rt(n),v=Mt({q:d||void 0,type:n,sort:k,page:T,pageSize:At}),j=Dt(),S=Lt(),{confirm:_,ConfirmDialog:O}=nt(),$=o.useMemo(()=>{var p;return((p=f.data)==null?void 0:p.records)??[]},[(le=f.data)==null?void 0:le.records]),N=o.useMemo(()=>{var p;return((p=v.data)==null?void 0:p.items)??[]},[(oe=v.data)==null?void 0:oe.items]),ee=o.useMemo(()=>_t(N),[N]),Re=o.useMemo(()=>Ot($),[$]),D=o.useMemo(()=>{const p=$.filter(g=>g.type===n).map(g=>({key:`${g.type}:${g.spec}:${g.id??""}`,record:g,item:Ft(g,ee)})).filter(g=>qt(g.record,g.item,d));return p.sort((g,w)=>{const I=g.record.installedAt?Date.parse(g.record.installedAt):Number.NaN,B=w.record.installedAt?Date.parse(w.record.installedAt):Number.NaN,Ae=!Number.isNaN(I),_e=!Number.isNaN(B);return Ae&&_e&&I!==B?B-I:g.record.spec.localeCompare(w.record.spec)}),p},[$,n,ee,d]),te=i==="installed"?D.length:((ie=v.data)==null?void 0:ie.total)??0,Q=i==="installed"?1:((ce=v.data)==null?void 0:ce.totalPages)??0,De=o.useMemo(()=>i==="installed"?f.isLoading?c("loading"):`${D.length} ${c(r.installedCountSuffix)}`:v.data?`${N.length} / ${te}`:c("loading"),[i,f.isLoading,D.length,v.data,N.length,te,r.installedCountSuffix]),ae={installingSpecs:C},ne={isPending:S.isPending,targetId:((ue=S.variables)==null?void 0:ue.id)||((de=S.variables)==null?void 0:de.spec),action:(pe=S.variables)==null?void 0:pe.action},Le=[{id:"all",label:c(r.tabMarketplace)},{id:"installed",label:c(r.tabInstalled),count:((me=f.data)==null?void 0:me.total)??0}],se=async p=>{const g=p.install.spec;if(!C.has(g)){P(w=>{const I=new Set(w);return I.add(g),I});try{await j.mutateAsync({type:p.type,spec:g,kind:p.install.kind,...p.type==="skill"?{skill:p.slug,installPath:`skills/${p.slug}`}:{}})}catch{}finally{P(w=>{if(!w.has(g))return w;const I=new Set(w);return I.delete(g),I})}}},re=async(p,g)=>{if(S.isPending)return;const w=g.id||g.spec;w&&(p==="uninstall"&&!await _({title:`${c("marketplaceUninstallTitle")} ${w}?`,description:c("marketplaceUninstallDescription"),confirmLabel:c("marketplaceUninstall"),variant:"destructive"})||S.mutate({type:g.type,action:p,id:w,spec:g.spec}))};return s.jsxs(st,{children:[s.jsx(rt,{title:c(r.pageTitle),description:c(r.pageDescription)}),s.jsx(at,{tabs:Le,activeTab:i,onChange:p=>{h(p),y(1)},className:"mb-4"}),s.jsx(Ut,{scope:i,searchText:u,searchPlaceholder:c(r.searchPlaceholder),sort:k,onSearchTextChange:b,onSortChange:p=>{y(1),m(p)}}),s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-[14px] font-semibold text-gray-900",children:i==="installed"?c(r.sectionInstalled):c(r.sectionCatalog)}),s.jsx("span",{className:"text-[12px] text-gray-500",children:De})]}),i==="all"&&v.isError&&s.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[c(r.errorLoadData),": ",v.error.message]}),i==="installed"&&f.isError&&s.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[c(r.errorLoadInstalled),": ",f.error.message]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 2xl:grid-cols-3 gap-3",children:[i==="all"&&N.map(p=>s.jsx(fe,{item:p,record:$t(p,Re),installState:ae,manageState:ne,onInstall:se,onManage:re},p.id)),i==="installed"&&D.map(p=>s.jsx(fe,{item:p.item,record:p.record,installState:ae,manageState:ne,onInstall:se,onManage:re},p.key))]}),i==="all"&&!v.isLoading&&!v.isError&&N.length===0&&s.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:c(r.emptyData)}),i==="installed"&&!f.isLoading&&!f.isError&&D.length===0&&s.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:c(r.emptyInstalled)})]}),i==="all"&&s.jsx(zt,{page:T,totalPages:Q,busy:v.isFetching,onPrev:()=>y(p=>Math.max(1,p-1)),onNext:()=>y(p=>Q>0?Math.min(Q,p+1):p+1)}),s.jsx(O,{})]})}export{Jt as MarketplacePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,r as c,m as M,F as k,J as C,O as P}from"./vendor-H2M3a_4Z.js";import{P as S,a as F,B as L}from"./page-layout-
|
|
1
|
+
import{j as e,r as c,m as M,F as k,J as C,O as P}from"./vendor-H2M3a_4Z.js";import{P as S,a as F,B as L}from"./page-layout-C_pPVkYP.js";import{C as b}from"./card-C0sHz144.js";import{u as T,a as E,b as D,I as w}from"./useConfig-DDPQwvDe.js";import{L as p}from"./label-DeI2vCVA.js";import{c as I,t,f as B}from"./index-BTE5dHqH.js";import{h as u}from"./config-hints-CApS3K_7.js";function s({className:l,...i}){return e.jsx("div",{className:I("animate-pulse rounded-md bg-slate-200",l),...i})}function q(){const{data:l,isLoading:i}=T(),{data:n}=E(),o=D(),[g,j]=c.useState(""),[y,f]=c.useState(""),[m,N]=c.useState(8192),x=n==null?void 0:n.uiHints,r=u("agents.defaults.model",x),d=u("agents.defaults.workspace",x),h=u("agents.defaults.maxTokens",x);c.useEffect(()=>{var a;(a=l==null?void 0:l.agents)!=null&&a.defaults&&(j(l.agents.defaults.model||""),f(l.agents.defaults.workspace||""),N(l.agents.defaults.maxTokens||8192))},[l]);const v=a=>{a.preventDefault(),o.mutate({model:g,maxTokens:m})};return i?e.jsxs("div",{className:"max-w-2xl space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(s,{className:"h-8 w-32"}),e.jsx(s,{className:"h-4 w-48"})]}),e.jsxs(b,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx(s,{className:"h-12 w-12 rounded-xl"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s,{className:"h-5 w-24"}),e.jsx(s,{className:"h-3 w-32"})]})]}),e.jsx(s,{className:"h-4 w-20 mb-2"}),e.jsx(s,{className:"h-10 w-full rounded-xl"})]}),e.jsxs(b,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsx(s,{className:"h-5 w-24 mb-2"}),e.jsx(s,{className:"h-3 w-40 mb-6"}),e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx(s,{className:"h-4 w-28 mb-3"}),e.jsx(s,{className:"h-2 w-full rounded-full"})]})})]})]}):e.jsxs(S,{children:[e.jsx(F,{title:t("modelPageTitle"),description:t("modelPageDescription")}),e.jsxs("form",{onSubmit:v,className:"space-y-8",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"p-8 rounded-2xl bg-white border border-gray-200 shadow-card",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white",children:e.jsx(M,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:t("defaultModel")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"model",className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(r==null?void 0:r.label)??"Model Name"}),e.jsx(w,{id:"model",value:g,onChange:a=>j(a.target.value),placeholder:(r==null?void 0:r.placeholder)??"minimax/MiniMax-M2.1",className:"h-12 px-4 rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-400",children:(r==null?void 0:r.help)??"Examples: minimax/MiniMax-M2.5 · minimax/MiniMax-M2.1 · openrouter/anthropic/claude-3.5-sonnet · openrouter/openai/gpt-4o-mini"})]})]}),e.jsxs("div",{className:"p-8 rounded-2xl bg-white border border-gray-200 shadow-card",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white",children:e.jsx(k,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:t("workspace")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"workspace",className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(d==null?void 0:d.label)??"Default Path"}),e.jsx(w,{id:"workspace",value:y,onChange:a=>f(a.target.value),placeholder:(d==null?void 0:d.placeholder)??"/path/to/workspace",className:"h-12 px-4 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(C,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:t("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(p,{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(h==null?void 0:h.label)??t("maxTokens")}),e.jsx("span",{className:"text-sm font-semibold text-gray-900",children:B(m)})]}),e.jsx("input",{type:"range",min:"1000",max:"32000",step:"1000",value:m,onChange:a=>N(parseInt(a.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(L,{type:"submit",disabled:o.isPending,size:"lg",children:o.isPending?e.jsx(P,{className:"h-5 w-5 animate-spin"}):t("saveChanges")})})]})]})}export{q as ModelConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as v,j as e,a9 as I,aa as R,a7 as V,a5 as z,K as k,a0 as H,ab as B}from"./vendor-H2M3a_4Z.js";import{I as E,u as L,f as F,a as O,g as U}from"./useConfig-
|
|
1
|
+
import{r as v,j as e,a9 as I,aa as R,a7 as V,a5 as z,K as k,a0 as H,ab as B}from"./vendor-H2M3a_4Z.js";import{I as E,u as L,f as F,a as O,g as U}from"./useConfig-DDPQwvDe.js";import{t as s,c as S,u as W,S as G,b as _,d as q,e as J,g as Q}from"./index-BTE5dHqH.js";import{D as X,a as Y,b as Z,c as ee,d as se,e as ae}from"./dialog-CJMXeCpK.js";import{B as A,P as te,a as re}from"./page-layout-C_pPVkYP.js";import{L as P}from"./label-DeI2vCVA.js";import{h as w}from"./config-hints-CApS3K_7.js";import{T as ie}from"./tabs-custom-DgryVfGt.js";import{C as le,a as ne,L as oe,g as ce,S as de,b as xe,c as me,A as pe}from"./action-link-C4fhtxYl.js";function he({maskedValue:l,isSet:n,className:m,...p}){const[x,g]=v.useState(!1);return e.jsxs("div",{className:"relative",children:[e.jsx(E,{type:x?"text":"password",className:S("pr-20",m),placeholder:n?`${s("apiKeySet")} (${s("unchanged")})`:"",...p}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:(n||l)&&e.jsx(A,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>g(!x),children:x?e.jsx(I,{className:"h-4 w-4"}):e.jsx(R,{className:"h-4 w-4"})})})]})}function ue({value:l,onChange:n,className:m}){const p=l?Object.entries(l):[],x=(h,o,a)=>{const r=[...p];r[h]=[o,a],n(Object.fromEntries(r))},g=()=>{n({...l,"":""})},f=h=>{const o=p.filter((a,r)=>r!==h);n(Object.fromEntries(o))};return e.jsxs("div",{className:S("space-y-2",m),children:[p.map(([h,o],a)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(E,{type:"text",value:h,onChange:r=>x(a,r.target.value,o),placeholder:s("headerName"),className:"flex-1"}),e.jsx(E,{type:"text",value:o,onChange:r=>x(a,h,r.target.value),placeholder:s("headerValue"),className:"flex-1"}),e.jsx(A,{type:"button",variant:"ghost",size:"icon",onClick:()=>f(a),children:e.jsx(V,{className:"h-4 w-4 text-red-500"})})]},a)),e.jsxs(A,{type:"button",variant:"outline",size:"sm",onClick:g,children:[e.jsx(z,{className:"h-4 w-4 mr-2"}),s("add")]})]})}function ge(){const{providerModal:l,closeProviderModal:n}=W(),{data:m}=L(),{data:p}=F(),{data:x}=O(),g=U(),[f,h]=v.useState(""),[o,a]=v.useState(""),[r,j]=v.useState(null),[y,C]=v.useState("auto"),c=l.provider,t=p==null?void 0:p.providers.find(i=>i.name===c),d=c?m==null?void 0:m.providers[c]:null,K=x==null?void 0:x.uiHints,N=c?w(`providers.${c}.apiKey`,K):void 0,u=c?w(`providers.${c}.apiBase`,K):void 0,D=c?w(`providers.${c}.extraHeaders`,K):void 0,T=c?w(`providers.${c}.wireApi`,K):void 0;v.useEffect(()=>{if(d){a(d.apiBase||(t==null?void 0:t.defaultApiBase)||""),j(d.extraHeaders||null),h("");const i=d.wireApi||(t==null?void 0:t.defaultWireApi)||"auto";C(i)}},[d,t]);const $=i=>{i.preventDefault();const b={};if(f!==""&&(b.apiKey=f),o&&o!==(t==null?void 0:t.defaultApiBase)&&(b.apiBase=o),r&&Object.keys(r).length>0&&(b.extraHeaders=r),t!=null&&t.supportsWireApi){const M=(d==null?void 0:d.wireApi)||t.defaultWireApi||"auto";y!==M&&(b.wireApi=y)}c&&g.mutate({provider:c,data:b},{onSuccess:()=>n()})};return e.jsx(X,{open:l.open,onOpenChange:n,children:e.jsxs(Y,{className:"sm:max-w-[500px]",children:[e.jsx(Z,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center",children:e.jsx(k,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx(ee,{children:(t==null?void 0:t.displayName)||c}),e.jsx(se,{children:s("providerFormDescription")})]})]})}),e.jsxs("form",{onSubmit:$,className:"flex flex-col pt-2",children:[e.jsxs("div",{className:"space-y-5 max-h-[60vh] overflow-y-auto pr-1",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(P,{htmlFor:"apiKey",className:"text-sm font-medium text-gray-900 flex items-center gap-2",children:[e.jsx(k,{className:"h-3.5 w-3.5 text-gray-500"}),(N==null?void 0:N.label)??s("apiKey")]}),e.jsx(he,{id:"apiKey",value:f,isSet:d==null?void 0:d.apiKeySet,onChange:i=>h(i.target.value),placeholder:d!=null&&d.apiKeySet?s("apiKeySet"):(N==null?void 0:N.placeholder)??s("enterApiKey"),className:"rounded-xl"})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(P,{htmlFor:"apiBase",className:"text-sm font-medium text-gray-900 flex items-center gap-2",children:[e.jsx(H,{className:"h-3.5 w-3.5 text-gray-500"}),(u==null?void 0:u.label)??s("apiBase")]}),e.jsx(E,{id:"apiBase",type:"text",value:o,onChange:i=>a(i.target.value),placeholder:(t==null?void 0:t.defaultApiBase)||(u==null?void 0:u.placeholder)||"https://api.example.com",className:"rounded-xl"}),(u==null?void 0:u.help)&&e.jsx("p",{className:"text-xs text-gray-500",children:u.help})]}),(t==null?void 0:t.supportsWireApi)&&e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(P,{htmlFor:"wireApi",className:"text-sm font-medium text-gray-900 flex items-center gap-2",children:[e.jsx(B,{className:"h-3.5 w-3.5 text-gray-500"}),(T==null?void 0:T.label)??s("wireApi")]}),e.jsxs(G,{value:y,onValueChange:i=>C(i),children:[e.jsx(_,{className:"rounded-xl",children:e.jsx(q,{})}),e.jsx(J,{children:(t.wireApiOptions||["auto","chat","responses"]).map(i=>e.jsx(Q,{value:i,children:i==="chat"?s("wireApiChat"):i==="responses"?s("wireApiResponses"):s("wireApiAuto")},i))})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(P,{className:"text-sm font-medium text-gray-900 flex items-center gap-2",children:[e.jsx(B,{className:"h-3.5 w-3.5 text-gray-500"}),(D==null?void 0:D.label)??s("extraHeaders")]}),e.jsx(ue,{value:r,onChange:j})]})]}),e.jsxs(ae,{className:"pt-4 flex-shrink-0",children:[e.jsx(A,{type:"button",variant:"outline",onClick:n,children:s("cancel")}),e.jsx(A,{type:"submit",disabled:g.isPending,children:g.isPending?s("saving"):s("save")})]})]})]})})}function Ke(){const{data:l}=L(),{data:n}=F(),{data:m}=O(),{openProviderModal:p}=W(),[x,g]=v.useState("installed"),f=m==null?void 0:m.uiHints;if(!l||!n)return e.jsx("div",{className:"p-8",children:s("providersLoading")});const h=[{id:"installed",label:s("providersTabConfigured"),count:l.providers?Object.keys(l.providers).filter(a=>l.providers[a].apiKeySet).length:0},{id:"all",label:s("providersTabAll"),count:n.providers.length}],o=x==="installed"?n.providers.filter(a=>{var r;return(r=l.providers[a.name])==null?void 0:r.apiKeySet}):n.providers;return e.jsxs(te,{children:[e.jsx(re,{title:s("providersPageTitle")}),e.jsx(ie,{tabs:h,activeTab:x,onChange:g}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:o.map(a=>{const r=l.providers[a.name],j=r==null?void 0:r.apiKeySet,y=w(`providers.${a.name}`,f),C=(y==null?void 0:y.help)||s("providersDefaultDescription");return e.jsxs(le,{onClick:()=>p(a.name),children:[e.jsxs(ne,{children:[e.jsx(oe,{name:a.name,src:ce(a.name),className:S("h-11 w-11 rounded-xl border transition-all",j?"bg-white border-primary/30":"bg-white border-gray-200/60 group-hover:border-gray-300"),imgClassName:"h-6 w-6",fallback:e.jsx("span",{className:S("text-base font-semibold uppercase",j?"text-gray-800":"text-gray-400"),children:a.name[0]})}),e.jsx(de,{status:j?"ready":"setup",label:j?s("statusReady"):s("statusSetup")})]}),e.jsx(xe,{title:a.displayName||a.name,description:C}),e.jsx(me,{children:e.jsx(pe,{label:j?s("actionConfigure"):s("actionAddProvider")})})]},a.name)})}),o.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"h-14 w-14 flex items-center justify-center rounded-xl bg-gray-100/80 mb-4",children:e.jsx(k,{className:"h-6 w-6 text-gray-300"})}),e.jsx("h3",{className:"text-[14px] font-semibold text-gray-900 mb-1.5",children:s("providersEmptyTitle")}),e.jsx("p",{className:"text-[13px] text-gray-400 max-w-sm",children:s("providersEmptyDescription")})]}),e.jsx(ge,{})]})}export{Ke as ProvidersList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as p,j as e,a7 as Y,a5 as Z,al as le,ae as H}from"./vendor-H2M3a_4Z.js";import{u as oe,a as ce,j as de,I as d}from"./useConfig-
|
|
1
|
+
import{r as p,j as e,a7 as Y,a5 as Z,al as le,ae as H}from"./vendor-H2M3a_4Z.js";import{u as oe,a as ce,j as de,I as d}from"./useConfig-DDPQwvDe.js";import{P as ie,a as me,B as N}from"./page-layout-C_pPVkYP.js";import{C as B,a as M,b as O,c as R,d as $}from"./card-C0sHz144.js";import{S as he}from"./switch-_UxC2xoH.js";import{t,S as ee,b as ae,d as se,e as te,g as P}from"./index-BTE5dHqH.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,a7 as H,a5 as L,al as G,ae as J}from"./vendor-H2M3a_4Z.js";import{u as K,p as Q,I as h}from"./useConfig-
|
|
1
|
+
import{r as u,j as e,a7 as H,a5 as L,al as G,ae as J}from"./vendor-H2M3a_4Z.js";import{u as K,p as Q,I as h}from"./useConfig-DDPQwvDe.js";import{P as W,a as X,B as _}from"./page-layout-C_pPVkYP.js";import{C as R,a as T,b as M,c as O,d as A}from"./card-C0sHz144.js";import{L as k}from"./label-DeI2vCVA.js";import{t as a,S as x,b as m,d as p,e as j,g as o}from"./index-BTE5dHqH.js";import{S as Y}from"./switch-_UxC2xoH.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,a4 as T,_ as W,am as A,ab as $,ag as X,M as U,an as Y,W as G,X as J}from"./vendor-H2M3a_4Z.js";import{u as Z}from"./useConfirmDialog-
|
|
1
|
+
import{r as l,j as e,a4 as T,_ as W,am as A,ab as $,ag as X,M as U,an as Y,W as G,X as J}from"./vendor-H2M3a_4Z.js";import{u as Z}from"./useConfirmDialog-DqTlJNqa.js";import{c as ee,d as se,k as te,e as ae,I as S}from"./useConfig-DDPQwvDe.js";import{P as re,a as le,B as g}from"./page-layout-C_pPVkYP.js";import{t,c as o,S as ne,b as ie,d as oe,e as de,g as K,h as ce,a as xe}from"./index-BTE5dHqH.js";import{e as me}from"./chat-message-Jxa8JFA_.js";import"./dialog-CJMXeCpK.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(Y,{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 we(){var z,H,E;const[a,n]=l.useState(""),[i]=l.useState(100),[f]=l.useState(0),[r,p]=l.useState(null),[b,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),y=te(),_=ae(),{confirm:D,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(()=>b==="all"?c:c.filter(s=>j(s.key)===b),[c,b]);l.useEffect(()=>{d?(v(d.label||""),N(d.preferredModel||"")):(v(""),N("")),k(!1)},[d]);const O=()=>{r&&(y.mutate({key:r,data:{label:M.trim()||null,preferredModel:L.trim()||null}}),k(!1))},R=async()=>{if(!r)return;await D({title:t("sessionsClearHistory")+"?",variant:"destructive",confirmLabel:t("sessionsClearHistory")})&&y.mutate({key:r,data:{clearHistory:!0}})},V=async()=>{if(!r)return;await D({title:t("sessionsDeleteConfirm")+"?",variant:"destructive",confirmLabel:t("sessionsDeleteConfirm")})&&_.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:b,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(W,{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:[(y.isPending||_.isPending)&&e.jsx("div",{className:"absolute top-0 left-0 w-full h-1 bg-primary/20 overflow-hidden z-20",children:e.jsx("div",{className:"h-full bg-primary animate-pulse w-1/3 rounded-r-full"})}),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(X,{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:y.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{we as SessionsConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as d,j as s,ak as m}from"./vendor-H2M3a_4Z.js";import{c as r}from"./index-
|
|
1
|
+
import{r as d,j as s,ak as m}from"./vendor-H2M3a_4Z.js";import{c as r}from"./index-BTE5dHqH.js";function v({name:e,src:t,className:a,imgClassName:o,fallback:i}){const[g,l]=d.useState(!1),c=!!t&&!g;return s.jsx("div",{className:r("flex items-center justify-center",a),children:c?s.jsx("img",{src:t,alt:`${e} logo`,className:r("h-6 w-6 object-contain",o),onError:()=>l(!0),draggable:!1}):i??s.jsx("span",{className:"text-lg font-bold uppercase",children:e.slice(0,1)})})}const x={openrouter:"openrouter.svg",aihubmix:"aihubmix.png",anthropic:"anthropic.svg",openai:"openai.svg",gemini:"gemini.svg",deepseek:"deepseek.png",zhipu:"zhipu.svg",dashscope:"dashscope.png",moonshot:"moonshot.png",minimax:"minimax.svg",vllm:"vllm.svg",groq:"groq.svg"},u={telegram:"telegram.svg",slack:"slack.svg",discord:"discord.svg",whatsapp:"whatsapp.svg",qq:"qq.svg",feishu:"feishu.svg",dingtalk:"dingtalk.svg",wecom:"wecom.svg",mochat:"mochat.svg",email:"email.svg"};function n(e,t){const a=t.toLowerCase(),o=e[a];return o?`/logos/${o}`:null}function b(e){return n(x,e)}function y(e){return n(u,e)}function j({children:e,onClick:t,className:a}){return s.jsx("div",{onClick:t,className:r("group relative flex flex-col p-6 rounded-2xl border border-gray-200/50 bg-white shadow-card","transition-all duration-base cursor-pointer","hover:shadow-card-hover hover:border-gray-200",a),children:e})}function w({children:e,className:t}){return s.jsx("div",{className:r("flex items-start justify-between mb-4",t),children:e})}function N({title:e,description:t,className:a}){return s.jsxs("div",{className:r("flex-1",a),children:[s.jsx("h3",{className:"text-[14px] font-bold text-gray-900 mb-0.5",children:e}),t&&s.jsx("p",{className:"text-[12px] text-gray-400 leading-relaxed line-clamp-2",children:t})]})}function C({children:e,className:t}){return s.jsx("div",{className:r("mt-4 pt-3 flex items-center justify-between",t),children:e})}const p={active:{dot:"bg-emerald-500",text:"text-emerald-600",bg:"bg-emerald-50"},ready:{dot:"bg-emerald-500",text:"text-emerald-600",bg:"bg-emerald-50"},inactive:{dot:"bg-gray-300",text:"text-gray-400",bg:"bg-gray-100/80"},setup:{dot:"bg-gray-300",text:"text-gray-400",bg:"bg-gray-100/80"},warning:{dot:"bg-amber-400",text:"text-amber-600",bg:"bg-amber-50"}};function L({status:e,label:t,className:a}){const o=p[e];return s.jsxs("div",{className:r("flex items-center gap-1.5 px-2 py-0.5 rounded-full",o.bg,a),children:[s.jsx("span",{className:r("h-1.5 w-1.5 rounded-full",o.dot)}),s.jsx("span",{className:r("text-[11px] font-medium",o.text),children:t})]})}function k({label:e,className:t,onClick:a}){return s.jsxs("span",{onClick:a,className:r("inline-flex items-center gap-1 text-[13px] font-medium text-gray-600 hover:text-primary transition-colors cursor-pointer group/action",t),children:[e,s.jsx(m,{className:"h-3 w-3 transition-transform group-hover/action:translate-x-0.5"})]})}export{k as A,j as C,v as L,L as S,w as a,N as b,C as c,y as d,b as g};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,j as t}from"./vendor-H2M3a_4Z.js";import{c as d}from"./index-
|
|
1
|
+
import{r as s,j as t}from"./vendor-H2M3a_4Z.js";import{c as d}from"./index-BTE5dHqH.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};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const A=["cmd","command","query","q","path","url","to","channel","agentId","sessionKey"];function m(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function d(t,n=2400){return t.length<=n?t:`${t.slice(0,n)}
|
|
2
|
+
…`}function _(t){if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(t==null)return"";try{return d(JSON.stringify(t,null,2))}catch{return String(t)}}function T(t){if(m(t))return t;if(typeof t!="string")return null;const n=t.trim();if(!n.startsWith("{")&&!n.startsWith("["))return null;try{const o=JSON.parse(n);return m(o)?o:null}catch{return null}}function M(t){const n=T(t);if(!n){const e=_(t).trim();return e?d(e,120):void 0}const o=[];for(const e of A){const i=n[e];if(typeof i=="string"&&i.trim()?o.push(`${e}: ${i.trim()}`):(typeof i=="number"||typeof i=="boolean")&&o.push(`${e}: ${String(i)}`),o.length>=2)break}return o.length>0?o.join(" · "):d(_(n),140)}function y(t){return typeof t!="string"||!t.trim()?"tool":t.trim()}function g(t){return Array.isArray(t.tool_calls)&&t.tool_calls.length>0}function b(t,n){const o=p(t).trim(),e=p(n).trim();return o?e?`${o}
|
|
3
|
+
|
|
4
|
+
${e}`:o:e}function $(t,n){const o=typeof t=="string"?t.trim():"",e=typeof n=="string"?n.trim():"";return o?e?`${o}
|
|
5
|
+
|
|
6
|
+
${e}`:o:e||void 0}function f(t){const n=t.role.toLowerCase().trim();return n==="user"?"user":n==="assistant"?"assistant":n==="system"?"system":n==="tool"||n==="tool_result"||n==="toolresult"||n==="function"||typeof t.tool_call_id=="string"||Array.isArray(t.tool_calls)||typeof t.name=="string"?"tool":"other"}function p(t){if(typeof t=="string")return t;if(Array.isArray(t)){const n=[];for(const o of t){if(typeof o=="string"){n.push(o);continue}if(m(o)){if(typeof o.text=="string"){n.push(o.text);continue}typeof o.content=="string"&&n.push(o.content)}}if(n.length>0)return n.join(`
|
|
7
|
+
`)}return _(t)}function I(t){var i;const n=[],o=Array.isArray(t.tool_calls)?t.tool_calls:[];for(const l of o){if(!m(l))continue;const r=m(l.function)?l.function:null,c=y((r==null?void 0:r.name)??l.name),s=(r==null?void 0:r.arguments)??l.arguments,u=typeof l.result_text=="string"?l.result_text.trim():"",a=l.has_result===!0||typeof l.result_text=="string";n.push({kind:"call",name:c,detail:M(s),callId:typeof l.id=="string"?l.id:void 0,text:u,hasResult:a})}if(f(t)==="tool"||typeof t.tool_call_id=="string"){const l=p(t.content).trim();n.push({kind:"result",name:y(t.name??((i=n[0])==null?void 0:i.name)),text:l,callId:typeof t.tool_call_id=="string"?t.tool_call_id:void 0,hasResult:!0})}return n}function C(t){return{...t,tool_calls:Array.isArray(t.tool_calls)?t.tool_calls.map(n=>m(n)?{...n}:n):t.tool_calls}}function R(t){const n=t.map(C),o=new Map;for(const r of n){if(f(r)!=="tool"||typeof r.tool_call_id!="string"||!r.tool_call_id.trim())continue;const c=r.tool_call_id.trim(),s=p(r.content).trim(),u=o.get(c)??{texts:[]};typeof r.name=="string"&&r.name.trim()&&(u.name=r.name.trim()),u.texts.push(s),o.set(c,u)}const e=new Set;for(const r of n){if(f(r)!=="assistant"||!g(r))continue;const c=Array.isArray(r.tool_calls)?r.tool_calls:[];r.tool_calls=c.map(s=>{if(!m(s)||typeof s.id!="string")return s;const u=o.get(s.id);return u?(e.add(s.id),{...s,result_text:u.texts.filter(Boolean).join(`
|
|
8
|
+
|
|
9
|
+
`),has_result:!0,result_name:u.name}):s})}const i=n.filter(r=>f(r)!=="tool"||typeof r.tool_call_id!="string"||!r.tool_call_id.trim()?!0:!e.has(r.tool_call_id.trim())),l=[];for(let r=0;r<i.length;r+=1){const c=i[r];if(f(c)!=="assistant"||!g(c)){l.push(c);continue}let s=c,u=r+1;for(;u<i.length;){const a=i[u];if(f(a)!=="assistant"||g(a)||typeof a.tool_call_id=="string")break;const h=p(a.content).trim(),x=typeof a.reasoning_content=="string"&&a.reasoning_content.trim();if(!h&&!x)break;s={...s,content:b(s.content,a.content),reasoning_content:$(s.reasoning_content,a.reasoning_content),timestamp:a.timestamp},u+=1}l.push(s),r=u-1}return l}function S(t){const n=[];let o=0;for(let e=0;e<t.length;e+=1){const i=t[e],l=f(i),r=Date.parse(i.timestamp),c=Number.isFinite(r)?r:Date.now(),s=n[n.length-1];if(s&&s.role===l&&Math.abs(c-o)<=12e4){s.messages.push(i),s.timestamp=i.timestamp,o=c;continue}n.push({key:`${i.timestamp}-${e}-${l}`,role:l,messages:[i],timestamp:i.timestamp}),o=c}return n}export{I as a,R as c,p as e,S as g};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as i,aw as C,aL as I,au as ee,j as s,at as A,aB as te,ay as D,az as v,aC as ne,aM as oe,aN as ae,aO as re,aP as se,aD as ie,aQ as ce,aR as le,ac as de}from"./vendor-H2M3a_4Z.js";import{c as x}from"./index-
|
|
1
|
+
import{r as i,aw as C,aL as I,au as ee,j as s,at as A,aB as te,ay as D,az as v,aC as ne,aM as oe,aN as ae,aO as re,aP as se,aD as ie,aQ as ce,aR as le,ac as de}from"./vendor-H2M3a_4Z.js";import{c as x}from"./index-BTE5dHqH.js";function ue(e,t){return i.useReducer((n,o)=>t[n][o]??n,e)}var E=e=>{const{present:t,children:n}=e,o=fe(t),a=typeof n=="function"?n({present:o.isPresent}):i.Children.only(n),r=C(o.ref,ge(a));return typeof n=="function"||o.isPresent?i.cloneElement(a,{ref:r}):null};E.displayName="Presence";function fe(e){const[t,n]=i.useState(),o=i.useRef(null),a=i.useRef(e),r=i.useRef("none"),c=e?"mounted":"unmounted",[d,u]=ue(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return i.useEffect(()=>{const l=R(o.current);r.current=d==="mounted"?l:"none"},[d]),I(()=>{const l=o.current,g=a.current;if(g!==e){const y=r.current,p=R(l);e?u("MOUNT"):p==="none"||(l==null?void 0:l.display)==="none"?u("UNMOUNT"):u(g&&y!==p?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,u]),I(()=>{if(t){let l;const g=t.ownerDocument.defaultView??window,m=p=>{const Z=R(o.current).includes(CSS.escape(p.animationName));if(p.target===t&&Z&&(u("ANIMATION_END"),!a.current)){const J=t.style.animationFillMode;t.style.animationFillMode="forwards",l=g.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=J)})}},y=p=>{p.target===t&&(r.current=R(o.current))};return t.addEventListener("animationstart",y),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{g.clearTimeout(l),t.removeEventListener("animationstart",y),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:i.useCallback(l=>{o.current=l?getComputedStyle(l):null,n(l)},[])}}function R(e){return(e==null?void 0:e.animationName)||"none"}function ge(e){var o,a;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var O="Dialog",[M]=ne(O),[me,f]=M(O),w=e=>{const{__scopeDialog:t,children:n,open:o,defaultOpen:a,onOpenChange:r,modal:c=!0}=e,d=i.useRef(null),u=i.useRef(null),[l,g]=ee({prop:o,defaultProp:a??!1,onChange:r,caller:O});return s.jsx(me,{scope:t,triggerRef:d,contentRef:u,contentId:A(),titleId:A(),descriptionId:A(),open:l,onOpenChange:g,onOpenToggle:i.useCallback(()=>g(m=>!m),[g]),modal:c,children:n})};w.displayName=O;var T="DialogTrigger",pe=i.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,a=f(T,n),r=C(t,a.triggerRef);return s.jsx(D.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":b(a.open),...o,ref:r,onClick:v(e.onClick,a.onOpenToggle)})});pe.displayName=T;var P="DialogPortal",[Ne,j]=M(P,{forceMount:void 0}),S=e=>{const{__scopeDialog:t,forceMount:n,children:o,container:a}=e,r=f(P,t);return s.jsx(Ne,{scope:t,forceMount:n,children:i.Children.map(o,c=>s.jsx(E,{present:n||r.open,children:s.jsx(te,{asChild:!0,container:a,children:c})}))})};S.displayName=P;var h="DialogOverlay",F=i.forwardRef((e,t)=>{const n=j(h,e.__scopeDialog),{forceMount:o=n.forceMount,...a}=e,r=f(h,e.__scopeDialog);return r.modal?s.jsx(E,{present:o||r.open,children:s.jsx(ve,{...a,ref:t})}):null});F.displayName=h;var xe=ce("DialogOverlay.RemoveScroll"),ve=i.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,a=f(h,n);return s.jsx(ae,{as:xe,allowPinchZoom:!0,shards:[a.contentRef],children:s.jsx(D.div,{"data-state":b(a.open),...o,ref:t,style:{pointerEvents:"auto",...o.style}})})}),N="DialogContent",W=i.forwardRef((e,t)=>{const n=j(N,e.__scopeDialog),{forceMount:o=n.forceMount,...a}=e,r=f(N,e.__scopeDialog);return s.jsx(E,{present:o||r.open,children:r.modal?s.jsx(De,{...a,ref:t}):s.jsx(ye,{...a,ref:t})})});W.displayName=N;var De=i.forwardRef((e,t)=>{const n=f(N,e.__scopeDialog),o=i.useRef(null),a=C(t,n.contentRef,o);return i.useEffect(()=>{const r=o.current;if(r)return oe(r)},[]),s.jsx(L,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:v(e.onCloseAutoFocus,r=>{var c;r.preventDefault(),(c=n.triggerRef.current)==null||c.focus()}),onPointerDownOutside:v(e.onPointerDownOutside,r=>{const c=r.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0;(c.button===2||d)&&r.preventDefault()}),onFocusOutside:v(e.onFocusOutside,r=>r.preventDefault())})}),ye=i.forwardRef((e,t)=>{const n=f(N,e.__scopeDialog),o=i.useRef(!1),a=i.useRef(!1);return s.jsx(L,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{var c,d;(c=e.onCloseAutoFocus)==null||c.call(e,r),r.defaultPrevented||(o.current||(d=n.triggerRef.current)==null||d.focus(),r.preventDefault()),o.current=!1,a.current=!1},onInteractOutside:r=>{var u,l;(u=e.onInteractOutside)==null||u.call(e,r),r.defaultPrevented||(o.current=!0,r.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const c=r.target;((l=n.triggerRef.current)==null?void 0:l.contains(c))&&r.preventDefault(),r.detail.originalEvent.type==="focusin"&&a.current&&r.preventDefault()}})}),L=i.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:r,...c}=e,d=f(N,n),u=i.useRef(null),l=C(t,u);return re(),s.jsxs(s.Fragment,{children:[s.jsx(se,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:a,onUnmountAutoFocus:r,children:s.jsx(ie,{role:"dialog",id:d.contentId,"aria-describedby":d.descriptionId,"aria-labelledby":d.titleId,"data-state":b(d.open),...c,ref:l,onDismiss:()=>d.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(Re,{titleId:d.titleId}),s.jsx(Ce,{contentRef:u,descriptionId:d.descriptionId})]})]})}),_="DialogTitle",k=i.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,a=f(_,n);return s.jsx(D.h2,{id:a.titleId,...o,ref:t})});k.displayName=_;var U="DialogDescription",$=i.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,a=f(U,n);return s.jsx(D.p,{id:a.descriptionId,...o,ref:t})});$.displayName=U;var G="DialogClose",z=i.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,a=f(G,n);return s.jsx(D.button,{type:"button",...o,ref:t,onClick:v(e.onClick,()=>a.onOpenChange(!1))})});z.displayName=G;function b(e){return e?"open":"closed"}var B="DialogTitleWarning",[Se,H]=le(B,{contentName:N,titleName:_,docsSlug:"dialog"}),Re=({titleId:e})=>{const t=H(B),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
2
2
|
|
|
3
3
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
4
4
|
|