nextclaw 0.8.24 → 0.8.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/package.json +2 -2
  2. package/ui-dist/assets/ChannelsList-Cz3uXqRf.js +1 -0
  3. package/ui-dist/assets/{CronConfig-9YgJQTmP.js → CronConfig-Cp52VzLN.js} +1 -1
  4. package/ui-dist/assets/{DocBrowser-CBY75a92.js → DocBrowser-f4DlcaoQ.js} +1 -1
  5. package/ui-dist/assets/MarketplacePage-lqsZ93qA.js +1 -0
  6. package/ui-dist/assets/{ModelConfig-CBmc0ERp.js → ModelConfig-Drz5yiFE.js} +1 -1
  7. package/ui-dist/assets/{ProvidersList-CZfmOr6_.js → ProvidersList-BYuBSHLz.js} +1 -1
  8. package/ui-dist/assets/{RuntimeConfig-DX6nI_b5.js → RuntimeConfig-24TfpNpu.js} +1 -1
  9. package/ui-dist/assets/SessionsConfig-Da9p8YBD.js +2 -0
  10. package/ui-dist/assets/{action-link-DNRpMv1A.js → action-link-7uv6J28y.js} +1 -1
  11. package/ui-dist/assets/{card-KMt_4CgV.js → card-D-XgwaXI.js} +1 -1
  12. package/ui-dist/assets/{dialog-CqY6jnQm.js → dialog-yW7kJ2ni.js} +2 -2
  13. package/ui-dist/assets/index-C8ImW-Sf.js +2 -0
  14. package/ui-dist/assets/{label-C7WCjHWk.js → label-DR4VTdER.js} +1 -1
  15. package/ui-dist/assets/{page-layout-CMuYE4DA.js → page-layout-fYkwpvEI.js} +1 -1
  16. package/ui-dist/assets/{switch-DQmUTN4L.js → switch-Z8BKkE23.js} +1 -1
  17. package/ui-dist/assets/{tabs-custom-C5xYS25o.js → tabs-custom-C-Ex-MdR.js} +1 -1
  18. package/ui-dist/assets/{useConfig-Bv2DQ4BE.js → useConfig-BC17j2tK.js} +1 -1
  19. package/ui-dist/assets/{useConfirmDialog-BOcIsqiA.js → useConfirmDialog-Bydoiiwm.js} +1 -1
  20. package/ui-dist/assets/{vendor-Dkx07DIh.js → vendor-Bhv7yx8z.js} +64 -59
  21. package/ui-dist/index.html +2 -2
  22. package/ui-dist/assets/ChannelsList-DHBUkGsA.js +0 -1
  23. package/ui-dist/assets/MarketplacePage-Dw_0TLNd.js +0 -1
  24. package/ui-dist/assets/SessionsConfig-wH-647_6.js +0 -2
  25. package/ui-dist/assets/index-CVOQiX2_.js +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextclaw",
3
- "version": "0.8.24",
3
+ "version": "0.8.26",
4
4
  "description": "Lightweight personal AI assistant with CLI, multi-provider routing, and channel integrations.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -39,7 +39,7 @@
39
39
  "chokidar": "^3.6.0",
40
40
  "commander": "^12.1.0",
41
41
  "@nextclaw/core": "^0.6.32",
42
- "@nextclaw/server": "^0.5.11",
42
+ "@nextclaw/server": "^0.5.12",
43
43
  "@nextclaw/openclaw-compat": "^0.1.26"
44
44
  },
45
45
  "devDependencies": {
@@ -0,0 +1 @@
1
+ import{r as v,j as a,_ as ae,a0 as S,a1 as M,a2 as N,X as te,Y as ne,Z as le,a3 as se,a4 as oe,M as H,a5 as re,a6 as ce,a7 as ie}from"./vendor-Bhv7yx8z.js";import{u as _,a as q,e as me,f as pe,I as D,c as de}from"./useConfig-BC17j2tK.js";import{t as e,c as G,u as J,S as be,a as ue,b as ye,d as ge,e as xe}from"./index-C8ImW-Sf.js";import{D as he,a as fe,b as we,c as je,d as ve,e as ke}from"./dialog-yW7kJ2ni.js";import{B as F,P as Ce,a as Pe}from"./page-layout-fYkwpvEI.js";import{L as Ne}from"./label-DR4VTdER.js";import{S as Se}from"./switch-Z8BKkE23.js";import{h as T}from"./config-hints-CApS3K_7.js";import{T as Ie}from"./tabs-custom-C-Ex-MdR.js";import{C as De,a as Fe,L as Te,d as Me,S as Ae,b as Le,c as Ue,A as Ee}from"./action-link-7uv6J28y.js";function Be({value:n,onChange:d,className:i,placeholder:m=""}){const[c,g]=v.useState(""),b=u=>{u.key==="Enter"&&c.trim()?(u.preventDefault(),d([...n,c.trim()]),g("")):u.key==="Backspace"&&!c&&n.length>0&&d(n.slice(0,-1))},f=u=>{d(n.filter((o,y)=>y!==u))};return a.jsxs("div",{className:G("flex flex-wrap gap-2 p-2 border rounded-md min-h-[42px]",i),children:[n.map((u,o)=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-primary text-primary-foreground rounded text-sm",children:[u,a.jsx("button",{type:"button",onClick:()=>f(o),className:"hover:text-red-300 transition-colors",children:a.jsx(ae,{className:"h-3 w-3"})})]},o)),a.jsx("input",{type:"text",value:c,onChange:u=>g(u.target.value),onKeyDown:b,className:"flex-1 outline-none min-w-[100px] bg-transparent text-sm",placeholder:m||e("enterTag")})]})}const U=[{value:"pairing",label:"pairing"},{value:"allowlist",label:"allowlist"},{value:"open",label:"open"},{value:"disabled",label:"disabled"}],E=[{value:"open",label:"open"},{value:"allowlist",label:"allowlist"},{value:"disabled",label:"disabled"}],Oe=[{value:"off",label:"off"},{value:"partial",label:"partial"},{value:"block",label:"block"},{value:"progress",label:"progress"}],$e=n=>n.includes("token")||n.includes("secret")||n.includes("password")?a.jsx(te,{className:"h-3.5 w-3.5 text-gray-500"}):n.includes("url")||n.includes("host")?a.jsx(ne,{className:"h-3.5 w-3.5 text-gray-500"}):n.includes("email")||n.includes("mail")?a.jsx(M,{className:"h-3.5 w-3.5 text-gray-500"}):n.includes("id")||n.includes("from")?a.jsx(le,{className:"h-3.5 w-3.5 text-gray-500"}):n==="enabled"||n==="consentGranted"?a.jsx(se,{className:"h-3.5 w-3.5 text-gray-500"}):a.jsx(oe,{className:"h-3.5 w-3.5 text-gray-500"});function B(){return{telegram:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"token",type:"password",label:e("botToken")},{name:"allowFrom",type:"tags",label:e("allowFrom")},{name:"proxy",type:"text",label:e("proxy")},{name:"accountId",type:"text",label:e("accountId")},{name:"dmPolicy",type:"select",label:e("dmPolicy"),options:U},{name:"groupPolicy",type:"select",label:e("groupPolicy"),options:E},{name:"groupAllowFrom",type:"tags",label:e("groupAllowFrom")},{name:"requireMention",type:"boolean",label:e("requireMention")},{name:"mentionPatterns",type:"tags",label:e("mentionPatterns")},{name:"groups",type:"json",label:e("groupRulesJson")}],discord:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"token",type:"password",label:e("botToken")},{name:"allowBots",type:"boolean",label:e("allowBotMessages")},{name:"allowFrom",type:"tags",label:e("allowFrom")},{name:"gatewayUrl",type:"text",label:e("gatewayUrl")},{name:"intents",type:"number",label:e("intents")},{name:"proxy",type:"text",label:e("proxy")},{name:"mediaMaxMb",type:"number",label:e("attachmentMaxSizeMb")},{name:"streaming",type:"select",label:e("streamingMode"),options:Oe},{name:"draftChunk",type:"json",label:e("draftChunkingJson")},{name:"textChunkLimit",type:"number",label:e("textChunkLimit")},{name:"accountId",type:"text",label:e("accountId")},{name:"dmPolicy",type:"select",label:e("dmPolicy"),options:U},{name:"groupPolicy",type:"select",label:e("groupPolicy"),options:E},{name:"groupAllowFrom",type:"tags",label:e("groupAllowFrom")},{name:"requireMention",type:"boolean",label:e("requireMention")},{name:"mentionPatterns",type:"tags",label:e("mentionPatterns")},{name:"groups",type:"json",label:e("groupRulesJson")}],whatsapp:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"bridgeUrl",type:"text",label:e("bridgeUrl")},{name:"allowFrom",type:"tags",label:e("allowFrom")}],feishu:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"appId",type:"text",label:e("appId")},{name:"appSecret",type:"password",label:e("appSecret")},{name:"encryptKey",type:"password",label:e("encryptKey")},{name:"verificationToken",type:"password",label:e("verificationToken")},{name:"allowFrom",type:"tags",label:e("allowFrom")}],dingtalk:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"clientId",type:"text",label:e("clientId")},{name:"clientSecret",type:"password",label:e("clientSecret")},{name:"allowFrom",type:"tags",label:e("allowFrom")}],wecom:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"corpId",type:"text",label:e("corpId")},{name:"agentId",type:"text",label:e("agentId")},{name:"secret",type:"password",label:e("secret")},{name:"token",type:"password",label:e("token")},{name:"callbackPort",type:"number",label:e("callbackPort")},{name:"callbackPath",type:"text",label:e("callbackPath")},{name:"allowFrom",type:"tags",label:e("allowFrom")}],slack:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"mode",type:"text",label:e("mode")},{name:"webhookPath",type:"text",label:e("webhookPath")},{name:"allowBots",type:"boolean",label:e("allowBotMessages")},{name:"botToken",type:"password",label:e("botToken")},{name:"appToken",type:"password",label:e("appToken")}],email:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"consentGranted",type:"boolean",label:e("consentGranted")},{name:"imapHost",type:"text",label:e("imapHost")},{name:"imapPort",type:"number",label:e("imapPort")},{name:"imapUsername",type:"text",label:e("imapUsername")},{name:"imapPassword",type:"password",label:e("imapPassword")},{name:"fromAddress",type:"email",label:e("fromAddress")}],mochat:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"baseUrl",type:"text",label:e("baseUrl")},{name:"clawToken",type:"password",label:e("clawToken")},{name:"agentUserId",type:"text",label:e("agentUserId")},{name:"allowFrom",type:"tags",label:e("allowFrom")}],qq:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"appId",type:"text",label:e("appId")},{name:"secret",type:"password",label:e("appSecret")},{name:"markdownSupport",type:"boolean",label:e("markdownSupport")},{name:"allowFrom",type:"tags",label:e("allowFrom")}]}}const O={telegram:S,slack:S,email:M,default:S},$={telegram:"from-primary-300 to-primary-600",slack:"from-primary-200 to-primary-500",email:"from-primary-100 to-primary-400",default:"from-gray-300 to-gray-500"};function I(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function K(n,d){const i={...n};for(const[m,c]of Object.entries(d)){const g=i[m];if(I(g)&&I(c)){i[m]=K(g,c);continue}i[m]=c}return i}function Re(n,d){const i=n.split("."),m={};let c=m;for(let g=0;g<i.length-1;g+=1){const b=i[g];c[b]={},c=c[b]}return c[i[i.length-1]]=d,m}function He(){var A,L;const{channelModal:n,closeChannelModal:d}=J(),{data:i}=_(),{data:m}=q(),c=me(),g=pe(),[b,f]=v.useState({}),[u,o]=v.useState({}),[y,x]=v.useState(null),l=n.channel,w=l?i==null?void 0:i.channels[l]:null,k=l?B()[l]??[]:[],C=m==null?void 0:m.uiHints,P=l?`channels.${l}`:null,Y=((A=m==null?void 0:m.actions)==null?void 0:A.filter(t=>t.scope===P))??[],z=l&&(((L=T(`channels.${l}`,C))==null?void 0:L.label)??l);v.useEffect(()=>{if(w){f({...w});const t={};(l?B()[l]??[]:[]).filter(r=>r.type==="json").forEach(r=>{const h=w[r.name];t[r.name]=JSON.stringify(h??{},null,2)}),o(t)}else f({}),o({})},[w,l]);const j=(t,s)=>{f(r=>({...r,[t]:s}))},V=t=>{if(t.preventDefault(),!l)return;const s={...b};for(const r of k){if(r.type!=="json")continue;const h=u[r.name]??"";try{s[r.name]=h.trim()?JSON.parse(h):{}}catch{N.error(`${e("invalidJson")}: ${r.name}`);return}}c.mutate({channel:l,data:s},{onSuccess:()=>d()})},X=t=>{if(!t||!l)return;const s=t.channels;if(!I(s))return;const r=s[l];I(r)&&f(h=>K(h,r))},W=async t=>{if(!(!l||!P)){x(t.id);try{let s={...b};t.saveBeforeRun&&(s={...s,...t.savePatch??{}},f(s),await c.mutateAsync({channel:l,data:s}));const r=await g.mutateAsync({actionId:t.id,data:{scope:P,draftConfig:Re(P,s)}});X(r.patch),r.ok?N.success(r.message||e("success")):N.error(r.message||e("error"))}catch(s){const r=s instanceof Error?s.message:String(s);N.error(`${e("error")}: ${r}`)}finally{x(null)}}},Z=O[l||""]||O.default,Q=$[l||""]||$.default;return a.jsx(he,{open:n.open,onOpenChange:d,children:a.jsxs(fe,{className:"sm:max-w-[550px] max-h-[85vh] overflow-hidden flex flex-col",children:[a.jsx(we,{children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`h-10 w-10 rounded-xl bg-gradient-to-br ${Q} flex items-center justify-center`,children:a.jsx(Z,{className:"h-5 w-5 text-white"})}),a.jsxs("div",{children:[a.jsx(je,{className:"capitalize",children:z}),a.jsx(ve,{children:e("configureMessageChannelParameters")})]})]})}),a.jsxs("form",{onSubmit:V,className:"flex flex-col flex-1 overflow-hidden",children:[a.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar py-2 pr-2 space-y-5",children:k.map(t=>{const s=l?T(`channels.${l}.${t.name}`,C):void 0,r=(s==null?void 0:s.label)??t.label,h=s==null?void 0:s.placeholder;return a.jsxs("div",{className:"space-y-2.5",children:[a.jsxs(Ne,{htmlFor:t.name,className:"text-sm font-medium text-gray-900 flex items-center gap-2",children:[$e(t.name),r]}),t.type==="boolean"&&a.jsxs("div",{className:"flex items-center justify-between p-3 rounded-xl bg-gray-50",children:[a.jsx("span",{className:"text-sm text-gray-500",children:b[t.name]?e("enabled"):e("disabled")}),a.jsx(Se,{id:t.name,checked:b[t.name]||!1,onCheckedChange:p=>j(t.name,p),className:"data-[state=checked]:bg-emerald-500"})]}),(t.type==="text"||t.type==="email")&&a.jsx(D,{id:t.name,type:t.type,value:b[t.name]||"",onChange:p=>j(t.name,p.target.value),placeholder:h,className:"rounded-xl"}),t.type==="password"&&a.jsx(D,{id:t.name,type:"password",value:b[t.name]||"",onChange:p=>j(t.name,p.target.value),placeholder:h??e("leaveBlankToKeepUnchanged"),className:"rounded-xl"}),t.type==="number"&&a.jsx(D,{id:t.name,type:"number",value:b[t.name]||0,onChange:p=>j(t.name,parseInt(p.target.value)||0),placeholder:h,className:"rounded-xl"}),t.type==="tags"&&a.jsx(Be,{value:b[t.name]||[],onChange:p=>j(t.name,p)}),t.type==="select"&&a.jsxs(be,{value:b[t.name]||"",onValueChange:p=>j(t.name,p),children:[a.jsx(ue,{className:"rounded-xl",children:a.jsx(ye,{})}),a.jsx(ge,{children:(t.options??[]).map(p=>a.jsx(xe,{value:p.value,children:p.label},p.value))})]}),t.type==="json"&&a.jsx("textarea",{id:t.name,value:u[t.name]??"{}",onChange:p=>o(ee=>({...ee,[t.name]:p.target.value})),className:"min-h-[120px] w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono"})]},t.name)})}),a.jsxs(ke,{className:"pt-4 flex-shrink-0",children:[a.jsx(F,{type:"button",variant:"outline",onClick:d,children:e("cancel")}),a.jsx(F,{type:"submit",disabled:c.isPending||!!y,children:c.isPending?e("saving"):e("save")}),Y.filter(t=>t.trigger==="manual").map(t=>a.jsx(F,{type:"button",onClick:()=>W(t),disabled:c.isPending||!!y,variant:"secondary",children:y===t.id?e("connecting"):t.title},t.id))]})]})]})})}const R={telegram:S,slack:ce,email:M,webhook:re,default:H},_e={telegram:"channelDescTelegram",slack:"channelDescSlack",email:"channelDescEmail",webhook:"channelDescWebhook",discord:"channelDescDiscord",feishu:"channelDescFeishu"};function Qe(){const{data:n}=_(),{data:d}=de(),{data:i}=q(),{openChannelModal:m}=J(),[c,g]=v.useState("active"),b=i==null?void 0:i.uiHints;if(!n||!d)return a.jsx("div",{className:"p-8 text-gray-400",children:e("channelsLoading")});const f=[{id:"active",label:e("channelsTabEnabled"),count:d.channels.filter(o=>{var y;return(y=n.channels[o.name])==null?void 0:y.enabled}).length},{id:"all",label:e("channelsTabAll"),count:d.channels.length}],u=d.channels.filter(o=>{var x;const y=((x=n.channels[o.name])==null?void 0:x.enabled)||!1;return c==="all"||y});return a.jsxs(Ce,{children:[a.jsx(Pe,{title:e("channelsPageTitle")}),a.jsx(Ie,{tabs:f,activeTab:c,onChange:g}),a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:u.map(o=>{const y=n.channels[o.name],x=(y==null?void 0:y.enabled)||!1,l=R[o.name]||R.default,w=T(`channels.${o.name}`,b),k=(w==null?void 0:w.help)||e(_e[o.name]||"channelDescriptionDefault");return a.jsxs(De,{onClick:()=>m(o.name),children:[a.jsxs(Fe,{children:[a.jsx(Te,{name:o.name,src:Me(o.name),className:G("h-11 w-11 rounded-xl border transition-all",x?"bg-white border-primary/30":"bg-white border-gray-200/60 group-hover:border-gray-300"),imgClassName:"h-5 w-5",fallback:a.jsx(l,{className:"h-5 w-5"})}),a.jsx(Ae,{status:x?"active":"inactive",label:x?e("statusActive"):e("statusInactive")})]}),a.jsx(Le,{title:o.displayName||o.name,description:k}),a.jsxs(Ue,{children:[a.jsx(Ee,{label:x?e("actionConfigure"):e("actionEnable")}),o.tutorialUrl&&a.jsx("a",{href:o.tutorialUrl,target:"_blank",rel:"noreferrer",onClick:C=>C.stopPropagation(),className:"flex items-center justify-center h-6 w-6 rounded-md text-gray-300 hover:text-gray-500 hover:bg-gray-100/60 transition-colors",title:e("channelsGuideTitle"),children:a.jsx(ie,{className:"h-3.5 w-3.5"})})]})]},o.name)})}),u.length===0&&a.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[a.jsx("div",{className:"h-14 w-14 flex items-center justify-center rounded-xl bg-gray-100/80 mb-4",children:a.jsx(H,{className:"h-6 w-6 text-gray-300"})}),a.jsx("h3",{className:"text-[14px] font-semibold text-gray-900 mb-1.5",children:e("channelsEmptyTitle")}),a.jsx("p",{className:"text-[13px] text-gray-400 max-w-sm",children:e("channelsEmptyDescription")})]}),a.jsx(He,{})]})}export{Qe as ChannelsList};
@@ -1 +1 @@
1
- import{r as x,j as e,a9 as j,A as D,af as L,ag as R,O as k}from"./vendor-Dkx07DIh.js";import{u as E}from"./useConfirmDialog-BOcIsqiA.js";import{l as M,m as P,n as T,o as J,I as A}from"./useConfig-Bv2DQ4BE.js";import{P as F,a as z,B as o}from"./page-layout-CMuYE4DA.js";import{c as p,t,S as B,a as I,b as Q,d as q,e as f,h as y}from"./index-CVOQiX2_.js";import{C as H,d as O}from"./card-KMt_4CgV.js";import"./dialog-CqY6jnQm.js";function g(s){return y(s??void 0)}function V(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 ${V(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(O,{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
+ import{r as x,j as e,aa as j,A as D,ag as L,ah as R,U as k}from"./vendor-Bhv7yx8z.js";import{u as E}from"./useConfirmDialog-Bydoiiwm.js";import{l as M,m as P,n as T,o as J,I as A}from"./useConfig-BC17j2tK.js";import{P as F,a as z,B as o}from"./page-layout-fYkwpvEI.js";import{c as p,t,S as B,a as I,b as Q,d as q,e as f,h as y}from"./index-C8ImW-Sf.js";import{C as H,d as V}from"./card-D-XgwaXI.js";import"./dialog-yW7kJ2ni.js";function g(s){return y(s??void 0)}function O(s){return typeof s!="number"||!Number.isFinite(s)?"-":y(new Date(s))}function U(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 G(s){const r=s.schedule;return r.kind==="cron"?r.expr?`cron ${r.expr}`:"cron":r.kind==="every"?`every ${U(r.everyMs)}`:r.kind==="at"?`at ${O(r.atMs)}`:"-"}function K(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"),": ",G(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"),": ",K(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,B as K,aJ as Z,aK as q,Z as Q,aL as ee,a7 as te,aa as re,a6 as se,aM as oe}from"./vendor-Dkx07DIh.js";import{j as ae,D as W,t as x,c as B}from"./index-CVOQiX2_.js";function ce(){const{isOpen:C,mode:h,currentUrl:i,navVersion:f,close:P,toggleMode:U,goBack:Y,goForward:F,canGoBack:I,canGoForward:O,navigate:v,syncUrl:M}=ae(),[b,y]=s.useState(""),[j,z]=s.useState(!1),[A,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,_]=s.useState(420),c=s.useRef(null),d=s.useRef(null),p=s.useRef(null),L=s.useRef(null),X=s.useRef(f);s.useEffect(()=>{try{const e=new URL(i);y(e.pathname)}catch{y(i)}},[i]),s.useEffect(()=>{var e;if(f!==X.current){X.current=f;return}if((e=L.current)!=null&&e.contentWindow)try{const r=new URL(i).pathname;L.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"&&M(r.data.url)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[M]);const $=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]),G=s.useCallback(e=>{h==="floating"&&(z(!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=()=>{z(!1),c.current=null};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",r),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",r)}},[j]);const k=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]),T=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;_(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]),V=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),m(!0);const r=e.clientX,o=a.w,w=l.x,u=H=>{const J=r-H.clientX,S=Math.max(360,o+J);R(D=>({...D,w:S})),N(D=>({...D,x:w-(S-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(!C)return null;const n=h==="docked";return t.jsxs("div",{className:B("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}),t.jsxs("div",{className:B("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:G,children:[t.jsxs("div",{className:"flex items-center gap-2.5",children:[t.jsx(K,{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:U,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(Z,{className:"w-3.5 h-3.5"}):t.jsx(q,{className:"w-3.5 h-3.5"})}),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:x("docBrowserClose"),children:t.jsx(Q,{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:$,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:L,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),(A||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:V}),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:k,"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:k,"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:k,children:t.jsx(oe,{className:"w-3 h-3 rotate-[-45deg]"})})]})]})}export{ce as DocBrowser};
1
+ import{r as s,j as t,q as K,aK as J,aL as Q,_ as Z,aM as ee,a8 as te,ab as re,a7 as se,aN as oe}from"./vendor-Bhv7yx8z.js";import{j as ae,D as W,t as x,c as C}from"./index-C8ImW-Sf.js";function ce(){const{isOpen:B,mode:h,currentUrl:i,navVersion:f,close:P,toggleMode:U,goBack:Y,goForward:F,canGoBack:I,canGoForward:O,navigate:v,syncUrl:M}=ae(),[b,y]=s.useState(""),[j,z]=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),L=s.useRef(null),X=s.useRef(f);s.useEffect(()=>{try{const e=new URL(i);y(e.pathname)}catch{y(i)}},[i]),s.useEffect(()=>{var e;if(f!==X.current){X.current=f;return}if((e=L.current)!=null&&e.contentWindow)try{const r=new URL(i).pathname;L.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"&&M(r.data.url)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[M]);const $=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]),G=s.useCallback(e=>{h==="floating"&&(z(!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=()=>{z(!1),c.current=null};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",r),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",r)}},[j]);const k=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]),T=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]),V=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,S=Math.max(360,o+q);R(D=>({...D,w:S})),N(D=>({...D,x:w-(S-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(!B)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}),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:G,children:[t.jsxs("div",{className:"flex items-center gap-2.5",children:[t.jsx(K,{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:U,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(J,{className:"w-3.5 h-3.5"}):t.jsx(Q,{className:"w-3.5 h-3.5"})}),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: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:$,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:L,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:V}),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:k,"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:k,"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:k,children:t.jsx(oe,{className:"w-3 h-3 rotate-[-45deg]"})})]})]})}export{ce as DocBrowser};
@@ -0,0 +1 @@
1
+ import{r as o,j as s,al as _e,am as Oe,an as $e,ao as fe,ap as Fe,aq as qe,ar as E,as as xe,at as He,au as Ke,av as Ue,aw as ze,ax as Qe,ay as Be,az as Ge,ai as he,aj as ye,ak as be,a2 as $,aA as Ve,aB as Ye,aC as Xe}from"./vendor-Bhv7yx8z.js";import{c as ve,i as F,t as c,S as We,a as Ze,b as Je,d as et,e as me}from"./index-C8ImW-Sf.js";import{T as tt}from"./tabs-custom-C-Ex-MdR.js";import{P as ke}from"./dialog-yW7kJ2ni.js";import{u as at}from"./useConfirmDialog-Bydoiiwm.js";import{P as nt,a as st}from"./page-layout-fYkwpvEI.js";var[q]=Ke("Tooltip",[xe]),H=xe(),Te="TooltipProvider",rt=700,G="tooltip.open",[lt,X]=q(Te),Ce=e=>{const{__scopeTooltip:t,delayDuration:a=rt,skipDelayDuration:n=300,disableHoverableContent:l=!1,children:r}=e,d=o.useRef(!0),y=o.useRef(!1),u=o.useRef(0);return o.useEffect(()=>{const x=u.current;return()=>window.clearTimeout(x)},[]),s.jsx(lt,{scope:t,isOpenDelayedRef:d,delayDuration:a,onOpen:o.useCallback(()=>{window.clearTimeout(u.current),d.current=!1},[]),onClose:o.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>d.current=!0,n)},[n]),isPointerInTransitRef:y,onPointerInTransitChange:o.useCallback(x=>{y.current=x},[]),disableHoverableContent:l,children:r})};Ce.displayName=Te;var L="Tooltip",[ot,A]=q(L),Pe=e=>{const{__scopeTooltip:t,children:a,open:n,defaultOpen:l,onOpenChange:r,disableHoverableContent:d,delayDuration:y}=e,u=X(L,e.__scopeTooltip),x=H(t),[i,h]=o.useState(null),b=_e(),m=o.useRef(0),T=d??u.disableHoverableContent,v=y??u.delayDuration,g=o.useRef(!1),[f,C]=Oe({prop:n,defaultProp:l??!1,onChange:S=>{S?(u.onOpen(),document.dispatchEvent(new CustomEvent(G))):u.onClose(),r==null||r(S)},caller:L}),P=o.useMemo(()=>f?g.current?"delayed-open":"instant-open":"closed",[f]),w=o.useCallback(()=>{window.clearTimeout(m.current),m.current=0,g.current=!1,C(!0)},[C]),j=o.useCallback(()=>{window.clearTimeout(m.current),m.current=0,C(!1)},[C]),N=o.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{g.current=!0,C(!0),m.current=0},v)},[v,C]);return o.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),s.jsx($e,{...x,children:s.jsx(ot,{scope:t,contentId:b,open:f,stateAttribute:P,trigger:i,onTriggerChange:h,onTriggerEnter:o.useCallback(()=>{u.isOpenDelayedRef.current?N():w()},[u.isOpenDelayedRef,N,w]),onTriggerLeave:o.useCallback(()=>{T?j():(window.clearTimeout(m.current),m.current=0)},[j,T]),onOpen:w,onClose:j,disableHoverableContent:T,children:a})})};Pe.displayName=L;var V="TooltipTrigger",Se=o.forwardRef((e,t)=>{const{__scopeTooltip:a,...n}=e,l=A(V,a),r=X(V,a),d=H(a),y=o.useRef(null),u=fe(t,y,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(Fe,{asChild:!0,...d,children:s.jsx(qe.button,{"aria-describedby":l.open?l.contentId:void 0,"data-state":l.stateAttribute,...n,ref:u,onPointerMove:E(e.onPointerMove,b=>{b.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)})})});Se.displayName=V;var W="TooltipPortal",[it,ct]=q(W,{forceMount:void 0}),we=e=>{const{__scopeTooltip:t,forceMount:a,children:n,container:l}=e,r=A(W,t);return s.jsx(it,{scope:t,forceMount:a,children:s.jsx(ke,{present:a||r.open,children:s.jsx(He,{asChild:!0,container:l,children:n})})})};we.displayName=W;var R="TooltipContent",je=o.forwardRef((e,t)=>{const a=ct(R,e.__scopeTooltip),{forceMount:n=a.forceMount,side:l="top",...r}=e,d=A(R,e.__scopeTooltip);return s.jsx(ke,{present:n||d.open,children:d.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=X(R,e.__scopeTooltip),l=o.useRef(null),r=fe(t,l),[d,y]=o.useState(null),{trigger:u,onClose:x}=a,i=l.current,{onPointerInTransitChange:h}=n,b=o.useCallback(()=>{y(null),h(!1)},[h]),m=o.useCallback((T,v)=>{const g=T.currentTarget,f={x:T.clientX,y:T.clientY},C=ft(f,g.getBoundingClientRect()),P=xt(f,C),w=ht(v.getBoundingClientRect()),j=bt([...P,...w]);y(j),h(!0)},[h]);return o.useEffect(()=>()=>b(),[b]),o.useEffect(()=>{if(u&&i){const T=g=>m(g,i),v=g=>m(g,u);return u.addEventListener("pointerleave",T),i.addEventListener("pointerleave",v),()=>{u.removeEventListener("pointerleave",T),i.removeEventListener("pointerleave",v)}}},[u,i,m,b]),o.useEffect(()=>{if(d){const T=v=>{const g=v.target,f={x:v.clientX,y:v.clientY},C=(u==null?void 0:u.contains(g))||(i==null?void 0:i.contains(g)),P=!yt(f,d);C?b():P&&(b(),x())};return document.addEventListener("pointermove",T),()=>document.removeEventListener("pointermove",T)}},[u,i,d,x,b]),s.jsx(Ne,{...e,ref:r})}),[ut,pt]=q(L,{isInside:!1}),mt=Be("TooltipContent"),Ne=o.forwardRef((e,t)=>{const{__scopeTooltip:a,children:n,"aria-label":l,onEscapeKeyDown:r,onPointerDownOutside:d,...y}=e,u=A(R,a),x=H(a),{onClose:i}=u;return o.useEffect(()=>(document.addEventListener(G,i),()=>document.removeEventListener(G,i)),[i]),o.useEffect(()=>{if(u.trigger){const h=b=>{const m=b.target;m!=null&&m.contains(u.trigger)&&i()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[u.trigger,i]),s.jsx(Ue,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:r,onPointerDownOutside:d,onFocusOutside:h=>h.preventDefault(),onDismiss:i,children:s.jsxs(ze,{"data-state":u.stateAttribute,...x,...y,ref:t,style:{...y.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(mt,{children:n}),s.jsx(ut,{scope:a,isInside:!0,children:s.jsx(Qe,{id:u.contentId,role:"tooltip",children:l||n})})]})})});je.displayName=R;var Ie="TooltipArrow",gt=o.forwardRef((e,t)=>{const{__scopeTooltip:a,...n}=e,l=H(a);return pt(Ie,a).isInside?null:s.jsx(Ge,{...l,...n,ref:t})});gt.displayName=Ie;function ft(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 xt(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 ht(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 yt(e,t){const{x:a,y:n}=e;let l=!1;for(let r=0,d=t.length-1;r<t.length;d=r++){const y=t[r],u=t[d],x=y.x,i=y.y,h=u.x,b=u.y;i>n!=b>n&&a<(h-x)*(n-i)/(b-i)+x&&(l=!l)}return l}function bt(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],d=t[t.length-2];if((r.x-d.x)*(l.y-d.y)>=(r.y-d.y)*(l.x-d.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],d=a[a.length-2];if((r.x-d.x)*(l.y-d.y)>=(r.y-d.y)*(l.x-d.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 kt=Ce,Tt=Pe,Ct=Se,Pt=we,Ee=je;const St=kt,Q=Tt,B=Ct,O=o.forwardRef(({className:e,sideOffset:t=4,...a},n)=>s.jsx(Pt,{children:s.jsx(Ee,{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})}));O.displayName=Ee.displayName;function K(e){return e==="plugin"?"plugins":"skills"}async function wt(e){var r,d;const t=new URLSearchParams,a=K(e.type);(r=e.q)!=null&&r.trim()&&t.set("q",e.q.trim()),(d=e.tag)!=null&&d.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 F.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 jt(e){const t=K(e.type),a=await F.post(`/api/marketplace/${t}/install`,e);if(!a.ok)throw new Error(a.error.message);return a.data}async function Nt(e){const t=K(e),a=await F.get(`/api/marketplace/${t}/installed`);if(!a.ok)throw new Error(a.error.message);return a.data}async function It(e){const t=K(e.type),a=await F.post(`/api/marketplace/${t}/manage`,e);if(!a.ok)throw new Error(a.error.message);return a.data}function Et(e){return he({queryKey:["marketplace-items",e],queryFn:()=>wt(e),staleTime:15e3})}function Mt(e){return he({queryKey:["marketplace-installed",e],queryFn:()=>Nt(e),staleTime:1e4})}function Rt(){const e=ye();return be({mutationFn:t=>jt(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");$.success(t.message||a)},onError:t=>{$.error(t.message||c("marketplaceInstallFailed"))}})}function Dt(){const e=ye();return be({mutationFn:t=>It(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");$.success(t.message||a)},onError:t=>{$.error(t.message||c("marketplaceOperationFailed"))}})}const Lt=12;function Y(e){return(e??"").trim().toLowerCase()}function M(e,t){const a=Y(t);return a.length>0?`${e}:${a}`:""}function At(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 _t(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 Ot(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 $t(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 Ft(e,t,a){const n=Y(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=>Y(r)).filter(Boolean).some(r=>r.includes(n)):!0}function qt(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 Ht({name:e,fallback:t}){const a=e||t,n=a.substring(0,2).toUpperCase(),l=qt(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 Kt(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(Xe,{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(Je,{})}),s.jsxs(et,{children:[s.jsx(me,{value:"relevance",children:c("marketplaceSortRelevance")}),s.jsx(me,{value:"updated",children:c("marketplaceSortUpdated")})]})]})]})})}function ge(e){var g,f,C,P;const t=e.record,a=(t==null?void 0:t.type)==="plugin"?t:void 0,n=((g=e.item)==null?void 0:g.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=((C=e.item)==null?void 0:C.summary)??(t?c("marketplaceInstalledLocalSummary"):""),d=((P=e.item)==null?void 0:P.install.spec)??(t==null?void 0:t.spec)??"",y=(t==null?void 0:t.id)||(t==null?void 0:t.spec),u=!!y&&e.manageState.isPending&&e.manageState.targetId===y,x=!!a,i=(t==null?void 0:t.type)==="plugin"&&t.origin!=="bundled",h=(t==null?void 0:t.type)==="skill"&&t.source==="workspace",b=!!(i||h),m=t?t.enabled===!1||t.runtimeStatus==="disabled":!1,T=e.installState.isPending&&e.item&&e.installState.installingSpec===e.item.install.spec,v=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(Ht,{name:l,fallback:d||c("marketplaceTypeExtension")}),s.jsx("div",{className:"min-w-0 flex-1 flex flex-col justify-center h-full",children:s.jsxs(St,{delayDuration:400,children:[s.jsxs(Q,{children:[s.jsx(B,{asChild:!0,children:s.jsx("div",{className:"text-[14px] font-semibold text-gray-900 truncate leading-tight cursor-default",children:l})}),s.jsx(O,{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:v}),d&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-[10px] text-gray-300",children:"•"}),s.jsxs(Q,{children:[s.jsx(B,{asChild:!0,children:s.jsx("span",{className:"text-[11px] text-gray-400 truncate max-w-full font-mono cursor-default",children:d})}),s.jsx(O,{className:"max-w-[300px] text-xs font-mono break-all",children:d})]})]})]}),s.jsxs(Q,{children:[s.jsx(B,{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(O,{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:e.installState.isPending,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:T?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:u&&e.manageState.action!=="uninstall"?e.manageState.action==="enable"?c("marketplaceEnabling"):c("marketplaceDisabling"):m?c("marketplaceEnable"):c("marketplaceDisable")}),t&&b&&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:u&&e.manageState.action==="uninstall"?c("marketplaceRemoving"):c("marketplaceUninstall")})]})]})}function Ut(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 Xt(){var se,re,le,oe,ie,ce,de,ue,pe;const e=Ve(),t=Ye(),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"},[d,y]=o.useState(""),[u,x]=o.useState(""),[i,h]=o.useState("all"),[b,m]=o.useState("relevance"),[T,v]=o.useState(1);o.useEffect(()=>{const p=setTimeout(()=>{v(1),x(d.trim())},250);return()=>clearTimeout(p)},[d]),o.useEffect(()=>{v(1)},[n]);const g=Mt(n),f=Et({q:u||void 0,type:n,sort:b,page:T,pageSize:Lt}),C=Rt(),P=Dt(),{confirm:w,ConfirmDialog:j}=at(),N=o.useMemo(()=>{var p;return((p=g.data)==null?void 0:p.records)??[]},[(se=g.data)==null?void 0:se.records]),S=o.useMemo(()=>{var p;return((p=f.data)==null?void 0:p.items)??[]},[(re=f.data)==null?void 0:re.items]),Z=o.useMemo(()=>At(S),[S]),Me=o.useMemo(()=>_t(N),[N]),D=o.useMemo(()=>{const p=N.filter(k=>k.type===n).map(k=>({key:`${k.type}:${k.spec}:${k.id??""}`,record:k,item:$t(k,Z)})).filter(k=>Ft(k.record,k.item,u));return p.sort((k,I)=>{const _=k.record.installedAt?Date.parse(k.record.installedAt):Number.NaN,z=I.record.installedAt?Date.parse(I.record.installedAt):Number.NaN,Le=!Number.isNaN(_),Ae=!Number.isNaN(z);return Le&&Ae&&_!==z?z-_:k.record.spec.localeCompare(I.record.spec)}),p},[N,n,Z,u]),J=i==="installed"?D.length:((le=f.data)==null?void 0:le.total)??0,U=i==="installed"?1:((oe=f.data)==null?void 0:oe.totalPages)??0,Re=o.useMemo(()=>i==="installed"?g.isLoading?c("loading"):`${D.length} ${c(r.installedCountSuffix)}`:f.data?`${S.length} / ${J}`:c("loading"),[i,g.isLoading,D.length,f.data,S.length,J,r.installedCountSuffix]),ee={isPending:C.isPending,installingSpec:(ie=C.variables)==null?void 0:ie.spec},te={isPending:P.isPending,targetId:((ce=P.variables)==null?void 0:ce.id)||((de=P.variables)==null?void 0:de.spec),action:(ue=P.variables)==null?void 0:ue.action},De=[{id:"all",label:c(r.tabMarketplace)},{id:"installed",label:c(r.tabInstalled),count:((pe=g.data)==null?void 0:pe.total)??0}],ae=p=>{C.isPending||C.mutate({type:p.type,spec:p.install.spec,kind:p.install.kind})},ne=async(p,k)=>{if(P.isPending)return;const I=k.id||k.spec;I&&(p==="uninstall"&&!await w({title:`${c("marketplaceUninstallTitle")} ${I}?`,description:c("marketplaceUninstallDescription"),confirmLabel:c("marketplaceUninstall"),variant:"destructive"})||P.mutate({type:k.type,action:p,id:I,spec:k.spec}))};return s.jsxs(nt,{children:[s.jsx(st,{title:c(r.pageTitle),description:c(r.pageDescription)}),s.jsx(tt,{tabs:De,activeTab:i,onChange:p=>{h(p),v(1)},className:"mb-4"}),s.jsx(Kt,{scope:i,searchText:d,searchPlaceholder:c(r.searchPlaceholder),sort:b,onSearchTextChange:y,onSortChange:p=>{v(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:Re})]}),i==="all"&&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.errorLoadData),": ",f.error.message]}),i==="installed"&&g.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),": ",g.error.message]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 2xl:grid-cols-3 gap-3",children:[i==="all"&&S.map(p=>s.jsx(ge,{item:p,record:Ot(p,Me),installState:ee,manageState:te,onInstall:ae,onManage:ne},p.id)),i==="installed"&&D.map(p=>s.jsx(ge,{item:p.item,record:p.record,installState:ee,manageState:te,onInstall:ae,onManage:ne},p.key))]}),i==="all"&&!f.isLoading&&!f.isError&&S.length===0&&s.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:c(r.emptyData)}),i==="installed"&&!g.isLoading&&!g.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(Ut,{page:T,totalPages:U,busy:f.isFetching,onPrev:()=>v(p=>Math.max(1,p-1)),onNext:()=>v(p=>U>0?Math.min(U,p+1):p+1)}),s.jsx(j,{})]})}export{Xt as MarketplacePage};
@@ -1 +1 @@
1
- import{j as e,r as c,m as M,F as k,D as C,E as P}from"./vendor-Dkx07DIh.js";import{P as S,a as E,B as F}from"./page-layout-CMuYE4DA.js";import{C as b}from"./card-KMt_4CgV.js";import{u as L,a as T,b as D,I as w}from"./useConfig-Bv2DQ4BE.js";import{L as p}from"./label-C7WCjHWk.js";import{c as I,t,f as B}from"./index-CVOQiX2_.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 G(){const{data:l,isLoading:i}=L(),{data:n}=T(),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(E,{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(F,{type:"submit",disabled:o.isPending,size:"lg",children:o.isPending?e.jsx(P,{className:"h-5 w-5 animate-spin"}):t("saveChanges")})})]})]})}export{G as ModelConfig};
1
+ import{j as e,r as c,m as M,F as k,E as C,J as P}from"./vendor-Bhv7yx8z.js";import{P as S,a as E,B as F}from"./page-layout-fYkwpvEI.js";import{C as b}from"./card-D-XgwaXI.js";import{u as L,a as T,b as D,I as w}from"./useConfig-BC17j2tK.js";import{L as p}from"./label-DR4VTdER.js";import{c as I,t,f as B}from"./index-C8ImW-Sf.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 A(){const{data:l,isLoading:i}=L(),{data:n}=T(),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(E,{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(F,{type:"submit",disabled:o.isPending,size:"lg",children:o.isPending?e.jsx(P,{className:"h-5 w-5 animate-spin"}):t("saveChanges")})})]})]})}export{A as ModelConfig};
@@ -1 +1 @@
1
- import{r as v,j as e,J as I,K as R,O as V,U as z,W as k,X as U,Y as B}from"./vendor-Dkx07DIh.js";import{I as E,u as L,c as O,a as F,d as H}from"./useConfig-Bv2DQ4BE.js";import{t as s,c as S,u as W,S as G,a as J,b as X,d as Y,e as _}from"./index-CVOQiX2_.js";import{D as q,a as Q,b as Z,c as ee,d as se,e as ae}from"./dialog-CqY6jnQm.js";import{B as A,P as te,a as re}from"./page-layout-CMuYE4DA.js";import{L as P}from"./label-C7WCjHWk.js";import{h as w}from"./config-hints-CApS3K_7.js";import{T as ie}from"./tabs-custom-C5xYS25o.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-DNRpMv1A.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}=O(),{data:x}=F(),g=H(),[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(q,{open:l.open,onOpenChange:n,children:e.jsxs(Q,{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(U,{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(J,{className:"rounded-xl",children:e.jsx(X,{})}),e.jsx(Y,{children:(t.wireApiOptions||["auto","chat","responses"]).map(i=>e.jsx(_,{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}=O(),{data:m}=F(),{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
+ import{r as v,j as e,K as I,O as R,U as V,W as z,X as k,Y as U,Z as B}from"./vendor-Bhv7yx8z.js";import{I as E,u as L,c as O,a as F,d as H}from"./useConfig-BC17j2tK.js";import{t as s,c as S,u as W,S as G,a as X,b as Y,d as Z,e as _}from"./index-C8ImW-Sf.js";import{D as q,a as J,b as Q,c as ee,d as se,e as ae}from"./dialog-yW7kJ2ni.js";import{B as A,P as te,a as re}from"./page-layout-fYkwpvEI.js";import{L as P}from"./label-DR4VTdER.js";import{h as w}from"./config-hints-CApS3K_7.js";import{T as ie}from"./tabs-custom-C-Ex-MdR.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-7uv6J28y.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}=O(),{data:x}=F(),g=H(),[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(q,{open:l.open,onOpenChange:n,children:e.jsxs(J,{className:"sm:max-w-[500px]",children:[e.jsx(Q,{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(U,{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(X,{className:"rounded-xl",children:e.jsx(Y,{})}),e.jsx(Z,{children:(t.wireApiOptions||["auto","chat","responses"]).map(i=>e.jsx(_,{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}=O(),{data:m}=F(),{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,O as Y,U as Z,a8 as le,a1 as H}from"./vendor-Dkx07DIh.js";import{u as oe,a as ce,g as de,I as d}from"./useConfig-Bv2DQ4BE.js";import{P as ie,a as me,B as N}from"./page-layout-CMuYE4DA.js";import{C as O,a as B,b as M,c as R,d as $}from"./card-KMt_4CgV.js";import{S as he}from"./switch-DQmUTN4L.js";import{t,S as ee,a as ae,b as se,d as te,e as P}from"./index-CVOQiX2_.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(O,{children:[e.jsxs(B,{children:[e.jsx(M,{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(O,{children:[e.jsxs(B,{children:[e.jsx(M,{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(O,{children:[e.jsxs(B,{children:[e.jsx(M,{children:(k==null?void 0:k.label)??t("bindings")}),e.jsx(R,{children:(k==null?void 0:k.help)??t("bindingsHelp")})]}),e.jsxs($,{className:"space-y-3",children:[D.map((a,r)=>{var s,o;const n=((s=a.match.peer)==null?void 0:s.kind)??"";return e.jsxs("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[e.jsx(d,{value:a.agentId,onChange:l=>T(r,{...a,agentId:l.target.value}),placeholder:t("targetAgentIdPlaceholder")}),e.jsx(d,{value:a.match.channel,onChange:l=>T(r,{...a,match:{...a.match,channel:l.target.value}}),placeholder:t("channelPlaceholder")}),e.jsx(d,{value:a.match.accountId??"",onChange:l=>T(r,{...a,match:{...a.match,accountId:l.target.value}}),placeholder:t("accountIdOptionalPlaceholder")}),e.jsxs(ee,{value:n||"__none__",onValueChange:l=>{var m;const c=l==="__none__"?"":l;if(!c){T(r,{...a,match:{...a.match,peer:void 0}});return}T(r,{...a,match:{...a.match,peer:{kind:c,id:((m=a.match.peer)==null?void 0:m.id)??""}}})},children:[e.jsx(ae,{children:e.jsx(se,{})}),e.jsxs(te,{children:[e.jsx(P,{value:"__none__",children:t("peerKindOptional")}),e.jsx(P,{value:"direct",children:"direct"}),e.jsx(P,{value:"group",children:"group"}),e.jsx(P,{value:"channel",children:"channel"})]})]}),e.jsx(d,{value:((o=a.match.peer)==null?void 0:o.id)??"",onChange:l=>T(r,{...a,match:{...a.match,peer:n?{kind:n,id:l.target.value}:void 0}}),placeholder:t("peerIdPlaceholder")})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(N,{type:"button",variant:"outline",size:"sm",onClick:()=>b(l=>l.filter((c,m)=>m!==r)),children:[e.jsx(Y,{className:"h-4 w-4 mr-1"}),t("remove")]})})]},`${r}-${a.agentId}`)}),e.jsxs(N,{type:"button",variant:"outline",onClick:()=>b(a=>[...a,xe()]),children:[e.jsx(Z,{className:"h-4 w-4 mr-2"}),t("addBinding")]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(N,{type:"button",onClick:ne,disabled:_.isPending,children:[e.jsx(le,{className:"h-4 w-4 mr-2"}),_.isPending?t("saving"):t("saveRuntimeSettings")]})})]})}export{ye as RuntimeConfig};
1
+ import{r as p,j as e,U as Y,W as Z,a9 as le,a2 as H}from"./vendor-Bhv7yx8z.js";import{u as oe,a as ce,g as de,I as d}from"./useConfig-BC17j2tK.js";import{P as ie,a as me,B as N}from"./page-layout-fYkwpvEI.js";import{C as B,a as M,b as O,c as R,d as $}from"./card-D-XgwaXI.js";import{S as he}from"./switch-Z8BKkE23.js";import{t,S as ee,a as ae,b as se,d as te,e as P}from"./index-C8ImW-Sf.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 G,J,Q,X;const l=s.agentId.trim(),c=s.match.channel.trim(),m=((G=s.match.accountId)==null?void 0:G.trim())??"",C=(J=s.match.peer)==null?void 0:J.kind,W=((X=(Q=s.match.peer)==null?void 0:Q.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(!W)throw new Error(t("bindingPeerIdRequired").replace("{index}",String(o)));E.match.peer={kind:C,id:W}}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};
@@ -0,0 +1,2 @@
1
+ import{r as l,j as e,aa as A,ab as $,ac as K,Z as W,a4 as Y,a0 as U,ad as Z,ae as G,af as J}from"./vendor-Bhv7yx8z.js";import{u as X}from"./useConfirmDialog-Bydoiiwm.js";import{h as ee,i as se,j as te,k as ae,I as S}from"./useConfig-BC17j2tK.js";import{P as re,a as le,B as u}from"./page-layout-fYkwpvEI.js";import{t,c as i,S as ne,a as ie,b as oe,d as de,e as T,g as ce,h as xe}from"./index-C8ImW-Sf.js";import"./dialog-yW7kJ2ni.js";const g="__unknown_channel__";function me(a){return xe(a)}function j(a){const n=a.indexOf(":");return n<=0?g:a.slice(0,n).trim()||g}function C(a){return a===g?t("sessionsUnknownChannel"):a}function he({session:a,channel:n,isSelected:d,onSelect:f}){const r=C(n),b=a.label||a.key.split(":").pop()||a.key;return e.jsxs("button",{onClick:f,className:i("w-full text-left p-3.5 rounded-xl transition-all duration-200 outline-none focus:outline-none focus:ring-0 group",d?"bg-brand-50 border border-brand-100/50":"bg-transparent border border-transparent hover:bg-gray-50/80"),children:[e.jsxs("div",{className:"flex items-start justify-between mb-1.5",children:[e.jsx("div",{className:i("font-semibold truncate pr-2 flex-1 text-sm",d?"text-brand-800":"text-gray-900"),children:b}),e.jsx("div",{className:i("text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 capitalize",d?"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:i("flex items-center text-xs justify-between mt-2 font-medium",d?"text-brand-600/80":"text-gray-400"),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Z,{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";return e.jsx("div",{className:i("flex w-full mb-6",n?"justify-end":"justify-start"),children:e.jsxs("div",{className:i("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:i("font-semibold text-xs",n?"text-primary-50":"text-gray-900 capitalize"),children:a.role}),e.jsx("span",{className:i("text-[10px]",n?"text-primary-200":"text-gray-400"),children:me(a.timestamp)})]}),e.jsx("div",{className:"whitespace-pre-wrap break-words leading-relaxed text-[15px]",children:a.content})]})]})})}function ve(){var z,H,E;const[a,n]=l.useState(""),[d]=l.useState(100),[f]=l.useState(0),[r,b]=l.useState(null),[p,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:d,activeMinutes:f}),[a,d,f]),h=ee(F),x=se(r,200),y=te(),D=ae(),{confirm:_,ConfirmDialog:Q}=X(),c=l.useMemo(()=>{var s;return((s=h.data)==null?void 0:s.sessions)??[]},[(z=h.data)==null?void 0:z.sessions]),o=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===g?1:I===g?-1:m.localeCompare(I))},[c]),P=l.useMemo(()=>p==="all"?c:c.filter(s=>j(s.key)===p),[c,p]);l.useEffect(()=>{o?(v(o.label||""),N(o.preferredModel||"")):(v(""),N("")),k(!1)},[o]);const O=()=>{r&&(y.mutate({key:r,data:{label:M.trim()||null,preferredModel:L.trim()||null}}),k(!1))},R=async()=>{if(!r)return;await _({title:t("sessionsClearHistory")+"?",variant:"destructive",confirmLabel:t("sessionsClearHistory")})&&y.mutate({key:r,data:{clearHistory:!0}})},V=async()=>{if(!r)return;await _({title:t("sessionsDeleteConfirm")+"?",variant:"destructive",confirmLabel:t("sessionsDeleteConfirm")})&&D.mutate({key:r},{onSuccess:()=>b(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(u,{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(A,{className:i("h-3.5 w-3.5",h.isFetching&&"animate-spin")})})]}),e.jsxs(ne,{value:p,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(T,{value:"all",className:"rounded-lg text-xs",children:t("sessionsAllChannels")}),q.map(s=>e.jsx(T,{value:s,className:"rounded-lg text-xs truncate pr-6",children:C(s)},s))]})]}),e.jsxs("div",{className:"relative w-full",children:[e.jsx($,{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(K,{className:"w-8 h-8 mx-auto mb-2 text-gray-300"}),t("sessionsEmpty")]}):P.map(s=>e.jsx(he,{session:s,channel:j(s.key),isSelected:r===s.key,onSelect:()=>b(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||D.isPending)&&e.jsx("div",{className:"absolute top-0 left-0 w-full h-1 bg-primary/20 overflow-hidden z-20",children:e.jsx("div",{className:"h-full bg-primary animate-pulse w-1/3 rounded-r-full"})}),r&&o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shrink-0 border-b border-gray-100 bg-white px-8 py-5 z-10 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-[14px] bg-gray-50 border border-gray-100 flex items-center justify-center text-gray-400 shrink-0",children:e.jsx(W,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-1.5",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 tracking-tight",children:o.label||o.key.split(":").pop()||o.key}),e.jsx("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500 uppercase tracking-widest",children:C(j(o.key))})]}),e.jsx("div",{className:"text-xs text-gray-500 font-mono break-all line-clamp-1 opacity-70",title:r,children:r})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(u,{variant:"outline",size:"sm",onClick:()=>k(!w),className:i("h-8.5 rounded-lg shadow-none border-gray-200 transition-all text-xs font-semibold",w?"bg-gray-100 text-gray-900":"hover:bg-gray-50 hover:text-gray-900"),children:[e.jsx(Y,{className:"w-3.5 h-3.5 mr-1.5"}),t("sessionsMetadata")]}),e.jsx(u,{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(u,{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(u,{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
+ [&::-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(A,{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(K,{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{ve as SessionsConfig};
@@ -1 +1 @@
1
- import{r as d,j as s,a7 as m}from"./vendor-Dkx07DIh.js";import{c as r}from"./index-CVOQiX2_.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
+ import{r as d,j as s,a8 as m}from"./vendor-Bhv7yx8z.js";import{c as r}from"./index-C8ImW-Sf.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-Dkx07DIh.js";import{c as d}from"./index-CVOQiX2_.js";const i=s.forwardRef(({className:a,hover:e=!0,...r},o)=>t.jsx("div",{ref:o,className:d("rounded-2xl border border-gray-200/50 bg-white text-card-foreground shadow-card transition-all duration-base",e&&"hover:shadow-card-hover hover:border-gray-200",a),...r}));i.displayName="Card";const c=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("flex flex-col space-y-1.5 p-6",a),...e}));c.displayName="CardHeader";const l=s.forwardRef(({className:a,...e},r)=>t.jsx("h3",{ref:r,className:d("text-[15px] font-semibold leading-tight tracking-tight text-gray-900",a),...e}));l.displayName="CardTitle";const n=s.forwardRef(({className:a,...e},r)=>t.jsx("p",{ref:r,className:d("text-[13px] text-gray-400 leading-relaxed",a),...e}));n.displayName="CardDescription";const p=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("p-6 pt-0",a),...e}));p.displayName="CardContent";const x=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("flex items-center justify-between p-6 pt-0",a),...e}));x.displayName="CardFooter";export{i as C,c as a,l as b,n as c,p as d};
1
+ import{r as s,j as t}from"./vendor-Bhv7yx8z.js";import{c as d}from"./index-C8ImW-Sf.js";const i=s.forwardRef(({className:a,hover:e=!0,...r},o)=>t.jsx("div",{ref:o,className:d("rounded-2xl border border-gray-200/50 bg-white text-card-foreground shadow-card transition-all duration-base",e&&"hover:shadow-card-hover hover:border-gray-200",a),...r}));i.displayName="Card";const c=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("flex flex-col space-y-1.5 p-6",a),...e}));c.displayName="CardHeader";const l=s.forwardRef(({className:a,...e},r)=>t.jsx("h3",{ref:r,className:d("text-[15px] font-semibold leading-tight tracking-tight text-gray-900",a),...e}));l.displayName="CardTitle";const n=s.forwardRef(({className:a,...e},r)=>t.jsx("p",{ref:r,className:d("text-[13px] text-gray-400 leading-relaxed",a),...e}));n.displayName="CardDescription";const p=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("p-6 pt-0",a),...e}));p.displayName="CardContent";const x=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("flex items-center justify-between p-6 pt-0",a),...e}));x.displayName="CardFooter";export{i as C,c as a,l as b,n as c,p as d};
@@ -1,5 +1,5 @@
1
- import{r as i,an as C,aC as b,al as ee,j as s,ak as A,as as te,ap as D,aq as v,at as ne,aD as oe,aE as ae,aF as re,aG as se,au as ie,aH as ce,aI as le,Z as de}from"./vendor-Dkx07DIh.js";import{c as x}from"./index-CVOQiX2_.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=h(o.current);r.current=d==="mounted"?l:"none"},[d]),b(()=>{const l=o.current,g=a.current;if(g!==e){const y=r.current,p=h(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]),b(()=>{if(t){let l;const g=t.ownerDocument.defaultView??window,m=p=>{const J=h(o.current).includes(CSS.escape(p.animationName));if(p.target===t&&J&&(u("ANIMATION_END"),!a.current)){const Q=t.style.animationFillMode;t.style.animationFillMode="forwards",l=g.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=Q)})}},y=p=>{p.target===t&&(r.current=h(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 h(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":I(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 R="DialogOverlay",F=i.forwardRef((e,t)=>{const n=j(R,e.__scopeDialog),{forceMount:o=n.forceMount,...a}=e,r=f(R,e.__scopeDialog);return r.modal?s.jsx(E,{present:o||r.open,children:s.jsx(ve,{...a,ref:t})}):null});F.displayName=R;var xe=ce("DialogOverlay.RemoveScroll"),ve=i.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,a=f(R,n);return s.jsx(ae,{as:xe,allowPinchZoom:!0,shards:[a.contentRef],children:s.jsx(D.div,{"data-state":I(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":I(d.open),...c,ref:l,onDismiss:()=>d.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(he,{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",H=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))})});H.displayName=G;function I(e){return e?"open":"closed"}var z="DialogTitleWarning",[Se,B]=le(z,{contentName:N,titleName:_,docsSlug:"dialog"}),he=({titleId:e})=>{const t=B(z),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
1
+ import{r as i,ao as C,aD as b,am as ee,j as s,al as A,at as te,aq as D,ar as v,au as ne,aE as oe,aF as ae,aG as re,aH as se,av as ie,aI as ce,aJ as le,_ as de}from"./vendor-Bhv7yx8z.js";import{c as x}from"./index-C8ImW-Sf.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=h(o.current);r.current=d==="mounted"?l:"none"},[d]),b(()=>{const l=o.current,g=a.current;if(g!==e){const y=r.current,p=h(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]),b(()=>{if(t){let l;const g=t.ownerDocument.defaultView??window,m=p=>{const Z=h(o.current).includes(CSS.escape(p.animationName));if(p.target===t&&Z&&(u("ANIMATION_END"),!a.current)){const Q=t.style.animationFillMode;t.style.animationFillMode="forwards",l=g.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=Q)})}},y=p=>{p.target===t&&(r.current=h(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 h(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":I(a.open),...o,ref:r,onClick:v(e.onClick,a.onOpenToggle)})});pe.displayName=T;var _="DialogPortal",[Ne,j]=M(_,{forceMount:void 0}),S=e=>{const{__scopeDialog:t,forceMount:n,children:o,container:a}=e,r=f(_,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=_;var R="DialogOverlay",F=i.forwardRef((e,t)=>{const n=j(R,e.__scopeDialog),{forceMount:o=n.forceMount,...a}=e,r=f(R,e.__scopeDialog);return r.modal?s.jsx(E,{present:o||r.open,children:s.jsx(ve,{...a,ref:t})}):null});F.displayName=R;var xe=ce("DialogOverlay.RemoveScroll"),ve=i.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,a=f(R,n);return s.jsx(ae,{as:xe,allowPinchZoom:!0,shards:[a.contentRef],children:s.jsx(D.div,{"data-state":I(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":I(d.open),...c,ref:l,onDismiss:()=>d.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(he,{titleId:d.titleId}),s.jsx(Ce,{contentRef:u,descriptionId:d.descriptionId})]})]})}),P="DialogTitle",k=i.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,a=f(P,n);return s.jsx(D.h2,{id:a.titleId,...o,ref:t})});k.displayName=P;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",H=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))})});H.displayName=G;function I(e){return e?"open":"closed"}var z="DialogTitleWarning",[Se,B]=le(z,{contentName:N,titleName:P,docsSlug:"dialog"}),he=({titleId:e})=>{const t=B(z),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
 
5
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return i.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Re="DialogDescriptionWarning",Ce=({contentRef:e,descriptionId:t})=>{const o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${B(Re).contentName}}.`;return i.useEffect(()=>{var r;const a=(r=e.current)==null?void 0:r.getAttribute("aria-describedby");t&&a&&(document.getElementById(t)||console.warn(o))},[o,e,t]),null},Ee=w,Oe=S,V=F,q=W,Z=k,K=$,Ae=H;const Fe=Ee,Pe=Oe,X=i.forwardRef(({className:e,...t},n)=>s.jsx(V,{ref:n,className:x("fixed inset-0 z-50 bg-black/40 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));X.displayName=V.displayName;const _e=i.forwardRef(({className:e,children:t,...n},o)=>s.jsxs(Pe,{children:[s.jsx(X,{}),s.jsxs(q,{ref:o,className:x("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-gray-200/50 bg-white p-6 shadow-xl duration-base data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-2xl",e),...n,children:[t,s.jsxs(Ae,{className:"absolute right-4 top-4 rounded-lg p-1 opacity-70 ring-offset-white transition-all duration-fast hover:opacity-100 hover:bg-gray-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 disabled:pointer-events-none",children:[s.jsx(de,{className:"h-4 w-4 text-gray-500"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));_e.displayName=q.displayName;const Ie=({className:e,...t})=>s.jsx("div",{className:x("flex flex-col space-y-2 text-center sm:text-left",e),...t});Ie.displayName="DialogHeader";const be=({className:e,...t})=>s.jsx("div",{className:x("flex flex-col-reverse sm:flex-row sm:justify-end sm:gap-3",e),...t});be.displayName="DialogFooter";const Me=i.forwardRef(({className:e,...t},n)=>s.jsx(Z,{ref:n,className:x("text-lg font-semibold leading-tight tracking-tight text-gray-900",e),...t}));Me.displayName=Z.displayName;const we=i.forwardRef(({className:e,...t},n)=>s.jsx(K,{ref:n,className:x("text-sm text-gray-500 leading-relaxed",e),...t}));we.displayName=K.displayName;export{Fe as D,E as P,_e as a,Ie as b,Me as c,we as d,be as e};
5
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return i.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Re="DialogDescriptionWarning",Ce=({contentRef:e,descriptionId:t})=>{const o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${B(Re).contentName}}.`;return i.useEffect(()=>{var r;const a=(r=e.current)==null?void 0:r.getAttribute("aria-describedby");t&&a&&(document.getElementById(t)||console.warn(o))},[o,e,t]),null},Ee=w,Oe=S,V=F,q=W,J=k,K=$,Ae=H;const Fe=Ee,_e=Oe,X=i.forwardRef(({className:e,...t},n)=>s.jsx(V,{ref:n,className:x("fixed inset-0 z-50 bg-black/40 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));X.displayName=V.displayName;const Pe=i.forwardRef(({className:e,children:t,...n},o)=>s.jsxs(_e,{children:[s.jsx(X,{}),s.jsxs(q,{ref:o,className:x("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-gray-200/50 bg-white p-6 shadow-xl duration-base data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-2xl",e),...n,children:[t,s.jsxs(Ae,{className:"absolute right-4 top-4 rounded-lg p-1 opacity-70 ring-offset-white transition-all duration-fast hover:opacity-100 hover:bg-gray-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 disabled:pointer-events-none",children:[s.jsx(de,{className:"h-4 w-4 text-gray-500"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Pe.displayName=q.displayName;const Ie=({className:e,...t})=>s.jsx("div",{className:x("flex flex-col space-y-2 text-center sm:text-left",e),...t});Ie.displayName="DialogHeader";const be=({className:e,...t})=>s.jsx("div",{className:x("flex flex-col-reverse sm:flex-row sm:justify-end sm:gap-3",e),...t});be.displayName="DialogFooter";const Me=i.forwardRef(({className:e,...t},n)=>s.jsx(J,{ref:n,className:x("text-lg font-semibold leading-tight tracking-tight text-gray-900",e),...t}));Me.displayName=J.displayName;const we=i.forwardRef(({className:e,...t},n)=>s.jsx(K,{ref:n,className:x("text-sm text-gray-500 leading-relaxed",e),...t}));we.displayName=K.displayName;export{Fe as D,E as P,Pe as a,Ie as b,Me as c,we as d,be as e};