@xopcai/xopc 0.0.457 → 0.0.460
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/automation-display-DaVDNZz8.js +2 -0
- package/dist/gateway/static/root/assets/automation-task-card-CiJmJ7_h.js +2 -0
- package/dist/gateway/static/root/assets/{automations-page-BSnPWyYd.js → automations-page-CVjgENMO.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-CGPWyL0P.js +9 -0
- package/dist/gateway/static/root/assets/capabilities-page-D2hq4cgE.js +2 -0
- package/dist/gateway/static/root/assets/{chat-page-Bx_A__qB.js → chat-page-BhPw56Vc.js} +5 -5
- package/dist/gateway/static/root/assets/connectors-page-DyzDVVfz.js +1 -0
- package/dist/gateway/static/root/assets/home-page-BPPe4JXB.js +7 -0
- package/dist/gateway/static/root/assets/index-DjzrnmBA.js +11 -0
- package/dist/gateway/static/root/assets/index-YQxumvaS.css +1 -0
- package/dist/gateway/static/root/assets/note-detail-panel-BbHlfAju.js +7 -0
- package/dist/gateway/static/root/assets/{notes-page-Do0l5Ddr.js → notes-page-8w2Stfak.js} +1 -1
- package/dist/gateway/static/root/assets/personal-page-BwfyW7Hx.js +1 -0
- package/dist/gateway/static/root/assets/personal-profile-settings-CQhZjoK6.js +1 -0
- package/dist/gateway/static/root/assets/{personal-settings-panel-BppxtWBl.js → personal-settings-panel-peD05ktj.js} +1 -1
- package/dist/gateway/static/root/assets/product-preview-content-WkF2j_c-.js +1 -0
- package/dist/gateway/static/root/assets/{product-preview-modal-BUeyRD5W.js → product-preview-modal-DMHOKocl.js} +2 -2
- package/dist/gateway/static/root/assets/{project-detail-page-D3k1NzXQ.js → project-detail-page-CNFuzmRr.js} +1 -1
- package/dist/gateway/static/root/assets/route-preload-CuxNu-LB.js +2 -0
- package/dist/gateway/static/root/assets/routine-panel-CXs4PjW0.js +2 -0
- package/dist/gateway/static/root/assets/service-recommendation-list-DDlMyPvC.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-CGiZCF8z.js → settings-page-BHImcF1q.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-_5TEldtl.js +3 -0
- package/dist/gateway/static/root/assets/{work-discovery-overlay-BNZK4hQ4.js → work-discovery-overlay-UvWbDUXi.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-KwSPhukU.js → work-discovery-page-BM1HsYz6.js} +1 -1
- package/dist/gateway/static/root/index.html +10 -10
- package/dist/package.js +1 -1
- package/dist/src/storage/sqlite/conversation-repository.js +4 -1
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/automation-task-card-BjqxvYqc.js +0 -3
- package/dist/gateway/static/root/assets/automations-workspace-DIaCdxtX.js +0 -9
- package/dist/gateway/static/root/assets/calendar-clock-D-quYVPe.js +0 -1
- package/dist/gateway/static/root/assets/capabilities-page-dXDa0i5o.js +0 -2
- package/dist/gateway/static/root/assets/connectors-page-BwJHhyRb.js +0 -1
- package/dist/gateway/static/root/assets/home-page-D1sTZYAY.js +0 -3
- package/dist/gateway/static/root/assets/index-CHAVhyVb.js +0 -11
- package/dist/gateway/static/root/assets/index-CQABygtM.css +0 -1
- package/dist/gateway/static/root/assets/note-detail-panel-B1cq9sU2.js +0 -7
- package/dist/gateway/static/root/assets/personal-page-DrYh0NPE.js +0 -1
- package/dist/gateway/static/root/assets/personal-profile-settings-HMQY9lz9.js +0 -1
- package/dist/gateway/static/root/assets/product-preview-content-CUaHxyiE.js +0 -1
- package/dist/gateway/static/root/assets/route-preload-CTuS4GFj.js +0 -2
- package/dist/gateway/static/root/assets/routine-panel-9UC3NU5V.js +0 -2
- package/dist/gateway/static/root/assets/service-recommendation-list-8mVIWB38.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-CWwwumsy.js +0 -3
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i,u as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as o,l as s,n as c,o as l}from"./locale-store-Dy1EByeG.js";import{t as u}from"./messages-BAnhwALN.js";import{a as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./dist-CY7CS_D3.js";import{i as v,n as y,r as b,t as x}from"./service-recommendation-list-8mVIWB38.js";import{t as S}from"./chevron-down-ccbiQQz_.js";import{t as C}from"./chevron-right-BweFrslA.js";import{n as w,r as T,t as E}from"./popover-select-CLsphyzA.js";import{t as D}from"./circle-alert-BEjgurr2.js";import{t as O}from"./circle-check-C23XjkUj.js";import{t as k}from"./circle-pause-CN9jYH2s.js";import{a as A,i as j,n as M,r as N,t as P}from"./connector-filters-Cfcx9EA2.js";import{t as F}from"./clock-3-DnrAnuyZ.js";import{t as I}from"./database-CjjeZfRG.js";import{t as L}from"./ellipsis-0k4rZLoy.js";import{t as R}from"./external-link-DjqjBmc3.js";import{n as z}from"./secret-input-DsjfQmDn.js";import{t as B}from"./eye-CABVeTq0.js";import{t as ee}from"./key-round-DWbpyU2U.js";import{t as V}from"./loader-circle-CifKLtgG.js";import{a as H,c as U,i as W,n as te,o as G,r as ne,s as re,t as ie}from"./install-connector-dialog-DxSv1wS2.js";import{t as K}from"./plug-DKYPEgkR.js";import{t as ae}from"./plus-Q2yW6OE7.js";import{t as oe}from"./refresh-cw-BRlGaq2w.js";import{t as se}from"./save-DRDABU--.js";import{t as q}from"./server-BlHCBjiE.js";import{t as ce}from"./settings-uiTATseT.js";import{t as le}from"./store-SzD1Jvgm.js";import{t as J}from"./terminal-oKqqZdiG.js";import{t as ue}from"./trash-2-DusmjVPV.js";import{t as de}from"./wrench-DFb4r8bH.js";import{t as fe}from"./x-B_N4OPjy.js";import{t as Y}from"./cn-0WouolD0.js";import{t as pe}from"./skeleton-DzdOeGYz.js";import{i as me}from"./vendor-swr-CdRzEUwF.js";import{n as he,r as X}from"./gateway-config-swr-1Rk0LeEM.js";import{t as Z}from"./button-Cc4hUNTt.js";import{n as ge}from"./copy-to-clipboard-HOJ79TWv.js";import{n as _e}from"./interaction-BdhHBbYa.js";import{A as ve,E as ye,F as be,I as xe,L as Se,M as Ce,N as we,O as Te,P as Ee,R as De,S as Oe,_ as ke,a as Ae,c as je,d as Me,i as Ne,j as Pe,l as Fe,m as Ie,n as Le,o as Re,p as ze,r as Be,s as Ve,u as He,v as Ue,w as We,x as Ge,y as Ke,z as qe}from"./connectors-api-CTuVWwBf.js";import{s as Je}from"./form-field-width-DJw_jULe.js";import{n as Ye}from"./electron-env-DHOGevH3.js";import{t as Xe}from"./page-tabs-oeTY7z3_.js";import{t as Ze}from"./page-header-store-Bm8oxpFR.js";import{r as Qe}from"./extension-provider-BPIoHw4r.js";import{t as $e}from"./sliding-tab-list-CmcrqRzN.js";import{t as et}from"./confirm-dialog-DrA5mTQp.js";import{l as tt,m as nt,o as rt,r as it,t as at}from"./dist-ZrL34Ps4.js";import{t as ot}from"./connection-usage-guide-Cibh2lrV.js";import{t as st}from"./capability-links-MZdYfPKx.js";import{t as ct}from"./capability-icon-CmvCZOJX.js";import{n as lt,t as ut}from"./capability-header-actions-BxMYfQ8y.js";import{t as dt}from"./connector-service-page-Btz68iy8.js";import{t as ft}from"./number-input-El7Szeln.js";var Q=e(t(),1),pt=n(),$=r();function mt(e){let t=(0,pt.c)(57),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,s,c,l,u,d,f;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o){let e=n.capabilities.filter(ht),p=e.slice(0,2),m=Math.max(0,e.length-p.length),h=o.connect,g;t[11]!==n||t[12]!==o?(g=W(n,o),t[11]=n,t[12]=o,t[13]=g):g=t[13];let _=g,v=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,y;t[14]!==h||t[15]!==n||t[16]!==i?(y=e=>(0,$.jsxs)(Z,{type:`button`,variant:`secondary`,className:Y(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>i(n),children:[(0,$.jsx)(U,{className:`size-4`}),h]}),t[14]=h,t[15]=n,t[16]=i,t[17]=y):y=t[17],s=y,f=`group flex min-h-[8.75rem] flex-col rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,c=`flex min-w-0 flex-1 flex-col`;let b;t[18]===n?b=t[19]:(b=(0,$.jsx)(te,{connector:n}),t[18]=n,t[19]=b);let x;t[20]!==n||t[21]!==a?(x=a?(0,$.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-sm font-semibold text-fg hover:underline`,onClick:()=>a(n),children:n.displayName}):(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[20]=n,t[21]=a,t[22]=x):x=t[22];let S;t[23]===v?S=t[24]:(S=v?(0,$.jsx)(`span`,{className:`mt-1 inline-flex rounded-full border border-edge px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:v}):null,t[23]=v,t[24]=S);let C;t[25]!==S||t[26]!==x?(C=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[x,S]}),t[25]=S,t[26]=x,t[27]=C):C=t[27];let w;t[28]!==C||t[29]!==b?(w=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,C]}),t[28]=C,t[29]=b,t[30]=w):w=t[30];let T;t[31]!==r||t[32]!==s?(T=r?null:(0,$.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 sm:flex`,children:s()}),t[31]=r,t[32]=s,t[33]=T):T=t[33];let E;t[34]!==r||t[35]!==o.connectedBadge?(E=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(O,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[34]=r,t[35]=o.connectedBadge,t[36]=E):E=t[36];let D;t[37]!==T||t[38]!==E?(D=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[T,E]}),t[37]=T,t[38]=E,t[39]=D):D=t[39],t[40]!==w||t[41]!==D?(l=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[w,D]}),t[40]=w,t[41]=D,t[42]=l):l=t[42],t[43]===_?u=t[44]:(u=(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-6 text-fg-muted`,title:_,children:_}),t[43]=_,t[44]=u),d=p.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[p.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:o.connectorCapabilityLabels[e]??e},e)),m>0?(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,m]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];let p;t[45]!==c||t[46]!==l||t[47]!==u||t[48]!==d?(p=(0,$.jsxs)(`div`,{className:c,children:[l,u,d]}),t[45]=c,t[46]=l,t[47]=u,t[48]=d,t[49]=p):p=t[49];let m;t[50]!==r||t[51]!==s?(m=r?null:(0,$.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:s(`w-full`)}),t[50]=r,t[51]=s,t[52]=m):m=t[52];let h;return t[53]!==f||t[54]!==p||t[55]!==m?(h=(0,$.jsxs)(`div`,{className:f,children:[p,m]}),t[53]=f,t[54]=p,t[55]=m,t[56]=h):h=t[56],h}function ht(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var gt=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function _t(e,t){return t.some(t=>t.connectorId===e.id)}var vt=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function yt(){let e=(0,pt.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:Y(`size-10 shrink-0 rounded-xl`,vt)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`flex h-full min-h-[9.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:Y(`h-4 min-w-0 flex-1`,vt)}),(0,$.jsx)(`div`,{className:Y(`h-8 w-[4.5rem] shrink-0 rounded-lg`,vt)})]}),(0,$.jsx)(`div`,{className:Y(`h-3 w-full`,vt)}),(0,$.jsx)(`div`,{className:Y(`h-3 w-[88%]`,vt)})]})]})}),e[1]=n):n=e[1],n}function bt(){let e=(0,pt.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(pe,{className:`size-9 shrink-0 rounded-lg`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex min-h-[8.75rem] min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4`,"aria-hidden":!0,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(pe,{className:`h-4 w-28 max-w-full`}),(0,$.jsx)(pe,{className:`h-3 w-20 max-w-full`})]})]}),(0,$.jsx)(pe,{className:`mt-2 h-3 w-48 max-w-full`}),(0,$.jsx)(pe,{className:`ml-auto mt-auto h-3 w-16`})]}),e[1]=n):n=e[1],n}var xt=[`understand`,`act`,`reach`];function St(e){if(e.benefits?.length)return[...new Set(e.benefits)];let t=new Set(e.capabilities),n=[e.id,e.displayName,...e.tags??[]].join(` `).toLowerCase(),r=[];return(t.has(`context`)||t.has(`memory_source`)||t.has(`resources`)||e.category===`docs`||e.category===`data`||/notion|drive|document|confluence|airtable|database|knowledge|wiki/.test(n))&&r.push(`understand`),t.has(`tools`)&&r.push(`act`),(t.has(`channel`)||/slack|telegram|discord|teams|mail|message|wechat|weixin/.test(n))&&r.push(`reach`),r.length?[...new Set(r)]:[`act`]}function Ct(e){return St(e)[0]??`act`}function wt(e,t){let n=t?Ct(t):`act`,r=e.connectionStatus===`connected`||e.status===`connected`||e.usage.lastHealthStatus===`ok`,i=e.status===`not_configured`||e.status===`failed`||e.status===`degraded`||e.status===`unauthorized`||e.connectionStatus===`unauthorized`||e.connectionStatus===`error`,a=n===`understand`?e.usage.lastResourceCount:n===`act`?e.usage.lastToolCount:void 0;return{benefit:n,state:r?`ready`:i?`needs_setup`:`checking`,availableCount:a}}function Tt(e,t){return t.connectorCapabilityLabels[e]??e}function Et(e,t){if(e.runtime.type===`mcp`)return H(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.type===`cli`?e.runtime.adapterId:e.runtime.sourceKind;return H(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function Dt(e,t){return e.auth.mode===`cli`?t.connectorAuthCli:e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function Ot(e){let t=(0,pt.c)(133),{connector:n,installed:r,onClose:i,onInstall:a,t:o}=e,s;t[0]!==n||t[1]!==o?(s=W(n,o),t[0]=n,t[1]=o,t[2]=s):s=t[2];let c=s,l,u,v,y,b,x,S,C,w,T,E,D,k,A,j,M;if(t[3]!==n||t[4]!==c||t[5]!==r||t[6]!==i||t[7]!==o){let e=St(n),a;t[24]!==n.setup.config||t[25]!==n.setup.secrets?(a=[...(n.setup.secrets??[]).filter(jt),...(n.setup.config??[]).filter(At)],t[24]=n.setup.config,t[25]=n.setup.secrets,t[26]=a):a=t[26];let s=a,N=n.capabilities.filter(kt);v=_,S=!0,t[27]===i?C=t[28]:(C=e=>{e||i()},t[27]=i,t[28]=C),u=m,t[29]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(d,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[29]=x):x=t[29],l=h,t[30]===Symbol.for(`react.memo_cache_sentinel`)?(y=Y(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,42rem)] w-[min(100%-2rem,min(92vw,44rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),t[30]=y):y=t[30];let P;t[31]===n?P=t[32]:(P=(0,$.jsx)(te,{connector:n,size:`lg`}),t[31]=n,t[32]=P);let F;t[33]===n.displayName?F=t[34]:(F=(0,$.jsx)(g,{className:`text-base font-semibold text-fg`,children:n.displayName}),t[33]=n.displayName,t[34]=F);let I;t[35]!==r||t[36]!==o.connectedBadge?(I=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(O,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[35]=r,t[36]=o.connectedBadge,t[37]=I):I=t[37];let L;t[38]!==F||t[39]!==I?(L=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[F,I]}),t[38]=F,t[39]=I,t[40]=L):L=t[40];let R;t[41]===c?R=t[42]:(R=(0,$.jsx)(f,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:c}),t[41]=c,t[42]=R);let z;t[43]!==L||t[44]!==R?(z=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[L,R]}),t[43]=L,t[44]=R,t[45]=z):z=t[45];let B;t[46]!==P||t[47]!==z?(B=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[P,z]}),t[46]=P,t[47]=z,t[48]=B):B=t[48];let V;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(V=Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,_e.focusRingPanel),t[49]=V):V=t[49];let U;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(fe,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[50]=U):U=t[50];let W;t[51]===o.modalClose?W=t[52]:(W=(0,$.jsx)(p,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:V,"aria-label":o.modalClose,children:U})}),t[51]=o.modalClose,t[52]=W),t[53]!==B||t[54]!==W?(b=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-5 sm:px-6`,children:[B,W]}),t[53]=B,t[54]=W,t[55]=b):b=t[55],A=`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-5 sm:px-6`,j=e.length?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:o.connectorWhyConnect}),(0,$.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.connectorBenefitHeadings[e]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:o.connectorBenefitHints[e]})]},e))})]}):null;let G;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(ee,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[56]=G):G=t[56];let ne;t[57]===o.detailPermissions?ne=t[58]:(ne=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.detailPermissions}),t[57]=o.detailPermissions,t[58]=ne);let re;t[59]!==n||t[60]!==o?(re=Dt(n,o),t[59]=n,t[60]=o,t[61]=re):re=t[61];let ie;t[62]===re?ie=t[63]:(ie=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:re}),t[62]=re,t[63]=ie);let K;t[64]!==ne||t[65]!==ie?(K=(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-4 py-3`,children:[G,(0,$.jsxs)(`div`,{children:[ne,ie]})]}),t[64]=ne,t[65]=ie,t[66]=K):K=t[66];let ae;t[67]===o.connectorSetupTitle?ae=t[68]:(ae=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.connectorSetupTitle}),t[67]=o.connectorSetupTitle,t[68]=ae);let oe;t[69]!==s.length||t[70]!==o.connectorRequiredInputsCount||t[71]!==o.connectorSetupNone?(oe=s.length?H(o.connectorRequiredInputsCount,{count:String(s.length)}):o.connectorSetupNone,t[69]=s.length,t[70]=o.connectorRequiredInputsCount,t[71]=o.connectorSetupNone,t[72]=oe):oe=t[72];let se;t[73]===oe?se=t[74]:(se=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:oe}),t[73]=oe,t[74]=se);let ce;t[75]!==ae||t[76]!==se?(ce=(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[ae,se]}),t[75]=ae,t[76]=se,t[77]=ce):ce=t[77],t[78]!==K||t[79]!==ce?(M=(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[K,ce]}),t[78]=K,t[79]=ce,t[80]=M):M=t[80],D=`rounded-xl border border-edge bg-surface-base`,t[81]===o.connectorTechnicalDetails?k=t[82]:(k=(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:o.connectorTechnicalDetails}),t[81]=o.connectorTechnicalDetails,t[82]=k),w=`space-y-5 border-t border-edge-subtle px-4 py-4`;let le;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(q,{className:`size-3.5`,"aria-hidden":!0}),t[83]=le):le=t[83];let J;t[84]===o.connectorRuntimeTitle?J=t[85]:(J=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[le,o.connectorRuntimeTitle]}),t[84]=o.connectorRuntimeTitle,t[85]=J);let ue;t[86]!==n||t[87]!==o?(ue=Et(n,o),t[86]=n,t[87]=o,t[88]=ue):ue=t[88];let de;t[89]===ue?de=t[90]:(de=(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-subtle`,children:ue}),t[89]=ue,t[90]=de),t[91]!==J||t[92]!==de?(T=(0,$.jsxs)(`div`,{children:[J,de]}),t[91]=J,t[92]=de,t[93]=T):T=t[93],E=N.length?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:N.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:Tt(e,o)},e))}):null,t[3]=n,t[4]=c,t[5]=r,t[6]=i,t[7]=o,t[8]=l,t[9]=u,t[10]=v,t[11]=y,t[12]=b,t[13]=x,t[14]=S,t[15]=C,t[16]=w,t[17]=T,t[18]=E,t[19]=D,t[20]=k,t[21]=A,t[22]=j,t[23]=M}else l=t[8],u=t[9],v=t[10],y=t[11],b=t[12],x=t[13],S=t[14],C=t[15],w=t[16],T=t[17],E=t[18],D=t[19],k=t[20],A=t[21],j=t[22],M=t[23];let N;t[94]!==w||t[95]!==T||t[96]!==E?(N=(0,$.jsxs)(`div`,{className:w,children:[T,E]}),t[94]=w,t[95]=T,t[96]=E,t[97]=N):N=t[97];let P;t[98]!==N||t[99]!==D||t[100]!==k?(P=(0,$.jsxs)(`details`,{className:D,children:[k,N]}),t[98]=N,t[99]=D,t[100]=k,t[101]=P):P=t[101];let F;t[102]!==P||t[103]!==A||t[104]!==j||t[105]!==M?(F=(0,$.jsxs)(`div`,{className:A,children:[j,M,P]}),t[102]=P,t[103]=A,t[104]=j,t[105]=M,t[106]=F):F=t[106];let I;t[107]===o.modalClose?I=t[108]:(I=(0,$.jsx)(p,{asChild:!0,children:(0,$.jsx)(Z,{variant:`secondary`,children:o.modalClose})}),t[107]=o.modalClose,t[108]=I);let L;t[109]!==n||t[110]!==r||t[111]!==i||t[112]!==a||t[113]!==o.connect?(L=r?null:(0,$.jsxs)(Z,{variant:`primary`,onClick:()=>{a(n),i()},children:[(0,$.jsx)(U,{className:`size-4`}),o.connect]}),t[109]=n,t[110]=r,t[111]=i,t[112]=a,t[113]=o.connect,t[114]=L):L=t[114];let R;t[115]!==I||t[116]!==L?(R=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[I,L]}),t[115]=I,t[116]=L,t[117]=R):R=t[117];let z;t[118]!==l||t[119]!==y||t[120]!==b||t[121]!==F||t[122]!==R?(z=(0,$.jsxs)(l,{className:y,children:[b,F,R]}),t[118]=l,t[119]=y,t[120]=b,t[121]=F,t[122]=R,t[123]=z):z=t[123];let B;t[124]!==u||t[125]!==x||t[126]!==z?(B=(0,$.jsxs)(u,{children:[x,z]}),t[124]=u,t[125]=x,t[126]=z,t[127]=B):B=t[127];let V;return t[128]!==v||t[129]!==S||t[130]!==C||t[131]!==B?(V=(0,$.jsx)(v,{open:S,onOpenChange:C,children:B}),t[128]=v,t[129]=S,t[130]=C,t[131]=B,t[132]=V):V=t[132],V}function kt(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}function At(e){return e.required}function jt(e){return e.required}var Mt=(0,Q.memo)(function(e){let t=(0,pt.c)(45),{onRefresh:n,refreshing:r,refreshLabel:i,onBrowseCatalog:a,onAddCustomServer:o,addLabel:s,browseLabel:c,customLabel:l,serviceLabel:u,moreActionsLabel:d}=e,[f,p]=(0,Q.useState)(!1),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[highlighted]:bg-surface-hover`,_e.transition),t[0]=m):m=t[0];let h=m,g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(ae,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[1]=g):g=t[1];let _;t[2]===s?_=t[3]:(_=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:s}),t[2]=s,t[3]=_);let v;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(S,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=v):v=t[4];let y;t[5]!==s||t[6]!==_?(y=(0,$.jsx)(nt,{asChild:!0,children:(0,$.jsxs)(Z,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":s,children:[g,_,v]})}),t[5]=s,t[6]=_,t[7]=y):y=t[7];let b;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(le,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=b):b=t[8];let x;t[9]!==c||t[10]!==a?(x=(0,$.jsxs)(it,{className:h,onSelect:a,children:[b,c]}),t[9]=c,t[10]=a,t[11]=x):x=t[11];let C;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(de,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=C):C=t[12];let w;t[13]!==l||t[14]!==o?(w=(0,$.jsxs)(it,{className:h,onSelect:o,children:[C,l]}),t[13]=l,t[14]=o,t[15]=w):w=t[15];let T;t[16]!==x||t[17]!==w?(T=(0,$.jsx)(rt,{children:(0,$.jsxs)(at,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[x,w]})}),t[16]=x,t[17]=w,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==y?(E=(0,$.jsxs)(tt,{children:[y,T]}),t[19]=T,t[20]=y,t[21]=E):E=t[21];let D;t[22]===f?D=t[23]:(D=(0,$.jsx)(dt,{open:f,onOpenChange:p,hideTrigger:!0}),t[22]=f,t[23]=D);let O;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(L,{className:`size-4`,"aria-hidden":!0}),t[24]=O):O=t[24];let k;t[25]===d?k=t[26]:(k=(0,$.jsx)(nt,{asChild:!0,children:(0,$.jsx)(Z,{type:`button`,variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":d,title:d,children:O})}),t[25]=d,t[26]=k);let A;t[27]!==n||t[28]!==i||t[29]!==r?(A=n?(0,$.jsxs)(it,{className:h,disabled:r,onSelect:n,children:[r?(0,$.jsx)(V,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(oe,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,t[27]=n,t[28]=i,t[29]=r,t[30]=A):A=t[30];let j,M;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>p(!0),M=(0,$.jsx)(ce,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[31]=j,t[32]=M):(j=t[31],M=t[32]);let N;t[33]===u?N=t[34]:(N=(0,$.jsxs)(it,{className:h,onSelect:j,children:[M,u]}),t[33]=u,t[34]=N);let P;t[35]!==A||t[36]!==N?(P=(0,$.jsx)(rt,{children:(0,$.jsxs)(at,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[A,N]})}),t[35]=A,t[36]=N,t[37]=P):P=t[37];let F;t[38]!==k||t[39]!==P?(F=(0,$.jsxs)(tt,{children:[k,P]}),t[38]=k,t[39]=P,t[40]=F):F=t[40];let I;return t[41]!==E||t[42]!==D||t[43]!==F?(I=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[E,D,F]}),t[41]=E,t[42]=D,t[43]=F,t[44]=I):I=t[44],I});function Nt(e=``,t=``){return{clientKey:crypto.randomUUID(),key:e,value:t}}var Pt=/^([^:=]+)[:=](.*)$/;function Ft(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return Lt(e)}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=Pt.exec(t);r&&n.push(Nt(r[1].trim(),r[2].trim()))}return n.length>0?n:null}function It(e){let t=Object.create(null);for(let n of e){let e=n.key.trim();e&&(t[e]=n.reference??n.value)}return Object.keys(t).length>0?t:void 0}function Lt(e){if(!e||typeof e!=`object`)return[Nt()];let t=Object.entries(e).map(([e,t])=>typeof t==`object`&&t&&!Array.isArray(t)?{...Nt(e),reference:t}:Nt(e,t==null?``:String(t)));return t.length>0?t:[Nt()]}function Rt(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e.xopcConnector;return!!(t&&typeof t==`object`&&!Array.isArray(t)&&t.managed===!0)}function zt(e){let t=e.trim();if(!t)return;if(t.startsWith(`[`)){let e=JSON.parse(t);if(!Array.isArray(e)||e.some(e=>typeof e!=`string`))throw Error(`Command arguments must be a JSON array of strings.`);return e}let n=[],r=``,i=``,a=!1;for(let e=0;e<t.length;e++){let o=t[e];o===`\\`&&t[e+1]&&i!==`'`&&/[\s"'\\]/.test(t[e+1])?(r+=t[++e],a=!0):i?o===i?i=``:r+=o:o===`"`||o===`'`?(i=o,a=!0):/\s/.test(o)?a&&=(n.push(r),r=``,!1):(r+=o,a=!0)}if(i)throw Error(`Command arguments contain an unclosed quote.`);return a&&n.push(r),n}function Bt(e){let t=e.trim();if(!t)return;let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Expected a JSON object`);return n}function Vt(e){let t={...e.extra,exposure:e.exposure};if(e.displayName?.trim()?t.displayName=e.displayName.trim():delete t.displayName,delete t.command,delete t.args,delete t.env,delete t.cwd,delete t.url,delete t.headers,delete t.type,e.transport===`stdio`){t.type=`stdio`,t.command=e.command.trim();let n=zt(e.argsText);if(n&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envEntries){let n=new Set;for(let t of e.envEntries)if(!(!t.key.trim()&&!t.value&&!t.reference)){if(!t.key.trim()||n.has(t.key.trim()))throw Error(`Environment variable names must be non-empty and unique.`);n.add(t.key.trim())}let r=It(e.envEntries);r&&(t.env=r)}else e.envJson.trim()&&(t.env=Bt(e.envJson));delete t.oauth,delete t.auth}else{t.type=e.transport===`sse`?`sse`:`http`,t.url=e.url.trim();let n=It(e.headers);n&&(t.headers=n);let r={...t.oauth??{}};e.oauthClientId.trim()?r.clientId=e.oauthClientId.trim():delete r.clientId,Object.keys(r).length?t.oauth=r:delete t.oauth}return e.timeout===void 0?delete t.timeout:t.timeout=e.timeout,t}function Ht(e,t){let n=t.oauth;return{clientKey:e,id:e,displayName:typeof t.displayName==`string`?t.displayName:``,transport:typeof t.url==`string`?t.type===`sse`?`sse`:`streamable-http`:`stdio`,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?JSON.stringify(t.args):``,envJson:t.env?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:``,url:typeof t.url==`string`?t.url:``,headers:Lt(t.headers),oauthClientId:typeof n?.clientId==`string`?n.clientId:``,timeout:typeof t.timeout==`number`?t.timeout:void 0,exposure:t.exposure??`codemode`,extra:t}}function Ut(e,t){let n=`mcp`;try{n=e.transport===`stdio`?e.command.split(/[\\/]/).pop()||n:new URL(e.url).hostname}catch{}let r=n.replace(/[^a-zA-Z0-9_-]+/g,`_`).replace(/^_+|_+$/g,``)||`mcp`,i=new Set([...t].map(e=>e.replace(/-/g,`_`))),a=r;for(let e=2;i.has(a.replace(/-/g,`_`));e++)a=`${r}_${e}`;return a}function Wt(e){let t=e.trim(),n=new URL(/^[a-z][a-z\d+.-]*:/i.test(t)&&!/^[^/]+:\d+(?:[/?#]|$)/.test(t)?t:`${/^(localhost|127\.0\.0\.1)(:|\/|$)/i.test(t)?`http`:`https`}://${t}`);if(![`http:`,`https:`].includes(n.protocol)||n.username||n.password)throw Error(`Use an HTTP or HTTPS MCP address without embedded credentials.`);return n.href}function Gt(e){let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Expected a JSON object.`);let n=t.mcpServers??t.mcp?.servers??t.servers;if(n!==void 0&&(!n||typeof n!=`object`||Array.isArray(n)))throw Error(`Expected a server configuration object.`);let r=n?Object.entries(n):[[``,t]];if(!r.length)throw Error(`No MCP servers found.`);return r.map(([e,t])=>{if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Invalid MCP server configuration.`);let n=t;if(typeof n.url!=`string`&&typeof n.command!=`string`)throw Error(`The configuration needs an MCP URL or command.`);if(n.args!==void 0&&(!Array.isArray(n.args)||n.args.some(e=>typeof e!=`string`)))throw Error(`Command arguments must be strings.`);let r=Ht(e,n);return r.clientKey=crypto.randomUUID(),r.url&&=Wt(r.url),r})}function Kt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`streamable-http`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[],oauthClientId:``,timeout:void 0,exposure:`codemode`,extra:{}}}function qt(e){let t=e?.mcp?.servers??{};return{servers:Object.entries(t).filter(([,e])=>!Rt(e)).map(([e,t])=>Ht(e,t)).sort((e,t)=>e.id.localeCompare(t.id))}}function Jt(e){return Vt(e)}async function Yt(e,t){return(await l(o(`/api/mcp/servers/${encodeURIComponent(e)}/tools`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload.tools}async function Xt(e,t,n,r){return(await l(o(`/api/mcp/drafts`),{method:`POST`,signal:r,body:JSON.stringify({serverId:e.id,sourceServerId:t,expectedServer:n,server:Vt(e)})})).payload}async function Zt(e,t){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/probe`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload}async function Qt(e){await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}`),{method:`DELETE`})}async function $t(e,t=!1){let n=await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/commit`),{method:`POST`,body:JSON.stringify({enable:t})});return he(),n.payload}async function en(e){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`POST`})).payload}async function tn(e,t){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{signal:t})).payload}async function nn(e){await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`DELETE`})}async function rn(e,t){await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth/redirect`),{method:`POST`,body:JSON.stringify({url:t})})}async function an(e,t){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/tools`),{signal:t})).payload.tools}async function on(e){let t=await l(o(`/api/mcp/servers`),{signal:e});return Object.fromEntries(t.payload.servers.filter(e=>e.lastCheck&&Number.isFinite(Date.parse(e.lastCheck.checkedAt))).map(e=>[e.id,e.lastCheck]))}async function sn(e){let t=await l(o(`/api/mcp/servers/${encodeURIComponent(e.id)}`),{method:`DELETE`,body:JSON.stringify({expectedServer:e.extra})});return he(),t.payload}function cn(e){let t=(0,pt.c)(114),{serverId:n,displayName:r,returnFocusTo:i,draftId:a,t:o,onClose:s,onConfigure:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=[],t[0]=l):l=t[0];let[u,v]=(0,Q.useState)(l),[y,b]=(0,Q.useState)(!0),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(0),D=(0,Q.useRef)(!1),O;t[1]!==a||t[2]!==n||t[3]!==o.setupAccessDenied||t[4]!==o.setupConflict||t[5]!==o.setupGatewayUnauthorized||t[6]!==o.setupRateLimited||t[7]!==o.toolsLoadFailed?(O=()=>{let e=new AbortController,t=!0;return b(!0),S(``),v([]),(a?an(a,e.signal):Yt(n,e.signal)).then(e=>{t&&v(e)}).catch(e=>{let n=e?.status;t&&S(n===401?o.setupGatewayUnauthorized:n===403?o.setupAccessDenied:n===429?o.setupRateLimited:n===404||n===409?o.setupConflict:o.toolsLoadFailed)}).finally(()=>{t&&b(!1)}),()=>{t=!1,e.abort()}},t[1]=a,t[2]=n,t[3]=o.setupAccessDenied,t[4]=o.setupConflict,t[5]=o.setupGatewayUnauthorized,t[6]=o.setupRateLimited,t[7]=o.toolsLoadFailed,t[8]=O):O=t[8];let k;t[9]!==a||t[10]!==T||t[11]!==n||t[12]!==o?(k=[n,a,T,o],t[9]=a,t[10]=T,t[11]=n,t[12]=o,t[13]=k):k=t[13],(0,Q.useEffect)(O,k);let A,j,M,N,P,F,I,L,R,z,B,ee,V,H;if(t[14]!==r||t[15]!==a||t[16]!==x||t[17]!==y||t[18]!==s||t[19]!==c||t[20]!==C||t[21]!==i||t[22]!==n||t[23]!==o.exposureLabels||t[24]!==o.setupConfigure||t[25]!==o.toolDetails||t[26]!==o.toolsClearSearch||t[27]!==o.toolsDialogSearchEmpty||t[28]!==o.toolsDialogSearchPlaceholder||t[29]!==o.toolsDialogSubtitle||t[30]!==o.toolsDialogTitle||t[31]!==o.toolsEmpty||t[32]!==o.toolsLoading||t[33]!==o.toolsRetryHint||t[34]!==o.toolsSearchSummary||t[35]!==o.toolsTitle||t[36]!==u){let e=C.trim().toLowerCase(),l;if(t[51]!==n){let e;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(e=/-/g,t[53]=e):e=t[53],l=n.replace(e,`_`),t[51]=n,t[52]=l}else l=t[52];let p=`mcp__${l}__`,v=u.filter(t=>`${t.name} ${t.description}`.toLowerCase().includes(e));M=_,I=!0,t[54]===s?L=t[55]:(L=e=>{e||s()},t[54]=s,t[55]=L),j=m,t[56]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(d,{className:`fixed inset-0 z-[60] bg-scrim`}),t[56]=F):F=t[56],A=h,t[57]===i?H=t[58]:(H=e=>{(D.current||i)&&e.preventDefault(),!D.current&&i?.isConnected&&i.focus()},t[57]=i,t[58]=H),N=`fixed left-1/2 top-1/2 z-[60] flex h-[min(42rem,calc(100dvh-2rem))] w-[min(48rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`;let b;t[59]===o.toolsDialogTitle?b=t[60]:(b=(0,$.jsx)(g,{className:`font-semibold`,children:o.toolsDialogTitle}),t[59]=o.toolsDialogTitle,t[60]=b);let S;t[61]!==r||t[62]!==x||t[63]!==y||t[64]!==n||t[65]!==o.toolsDialogSubtitle||t[66]!==u.length?(S=y||x?r||n:o.toolsDialogSubtitle.replace(`{{serverId}}`,r||n).replace(`{{count}}`,String(u.length)),t[61]=r,t[62]=x,t[63]=y,t[64]=n,t[65]=o.toolsDialogSubtitle,t[66]=u.length,t[67]=S):S=t[67];let T;t[68]===S?T=t[69]:(T=(0,$.jsx)(f,{className:`mt-1 break-words text-sm text-fg-muted`,children:S}),t[68]=S,t[69]=T);let E;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>w(e.target.value),t[70]=E):E=t[70];let O;t[71]!==C||t[72]!==o.toolsDialogSearchPlaceholder?(O=(0,$.jsx)(`input`,{className:`mt-4 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,value:C,onChange:E,placeholder:o.toolsDialogSearchPlaceholder,"aria-label":o.toolsDialogSearchPlaceholder}),t[71]=C,t[72]=o.toolsDialogSearchPlaceholder,t[73]=O):O=t[73];let k=e&&!y&&!x?(0,$.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:o.toolsSearchSummary.replace(`{{visible}}`,String(v.length)).replace(`{{count}}`,String(u.length))}):null;t[74]!==b||t[75]!==T||t[76]!==O||t[77]!==k?(P=(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge p-5`,children:[b,T,O,k]}),t[74]=b,t[75]=T,t[76]=O,t[77]=k,t[78]=P):P=t[78],R=`min-h-0 flex-1 overflow-y-auto p-5`,z=y,t[79]!==o.toolsTitle||t[80]!==u.length?(B=o.toolsTitle.replace(`{{count}}`,String(u.length)),t[79]=o.toolsTitle,t[80]=u.length,t[81]=B):B=t[81],ee=!y&&!x&&u.length&&!e?(0,$.jsx)(`div`,{className:`mb-5`,children:(0,$.jsx)(ot,{target:{kind:`mcp`,id:n,name:r||n},preview:!!a,onStart:s})}):null,V=y?(0,$.jsx)(`div`,{role:`status`,"aria-label":o.toolsLoading,className:`space-y-3`,children:[0,1,2].map(un)}):x?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm text-danger`,children:x}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.toolsRetryHint}),c?(0,$.jsx)(Z,{variant:`secondary`,onClick:()=>{D.current=!0,c()},children:o.setupConfigure}):null]}):v.length?(0,$.jsx)(`div`,{className:`space-y-3`,children:v.map(e=>(0,$.jsxs)(`article`,{className:`rounded-lg border border-edge p-4`,children:[(0,$.jsx)(`h3`,{className:`break-all font-mono text-sm font-semibold text-fg`,children:e.name.startsWith(p)?e.name.slice(p.length):e.name}),e.exposure&&Object.hasOwn(o.exposureLabels,e.exposure)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o.exposureLabels[e.exposure]}):null,e.description?(0,$.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:e.description}):null,(0,$.jsxs)(`details`,{className:`mt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent-fg`,children:o.toolDetails}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-xs text-fg-muted`,children:e.name}),(0,$.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-surface-panel p-3 text-xs text-fg`,children:JSON.stringify(e.inputSchema,null,2)})]})]},e.name))}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.length?o.toolsDialogSearchEmpty:o.toolsEmpty}),e?(0,$.jsx)(Z,{variant:`secondary`,onClick:()=>w(``),children:o.toolsClearSearch}):null]}),t[14]=r,t[15]=a,t[16]=x,t[17]=y,t[18]=s,t[19]=c,t[20]=C,t[21]=i,t[22]=n,t[23]=o.exposureLabels,t[24]=o.setupConfigure,t[25]=o.toolDetails,t[26]=o.toolsClearSearch,t[27]=o.toolsDialogSearchEmpty,t[28]=o.toolsDialogSearchPlaceholder,t[29]=o.toolsDialogSubtitle,t[30]=o.toolsDialogTitle,t[31]=o.toolsEmpty,t[32]=o.toolsLoading,t[33]=o.toolsRetryHint,t[34]=o.toolsSearchSummary,t[35]=o.toolsTitle,t[36]=u,t[37]=A,t[38]=j,t[39]=M,t[40]=N,t[41]=P,t[42]=F,t[43]=I,t[44]=L,t[45]=R,t[46]=z,t[47]=B,t[48]=ee,t[49]=V,t[50]=H}else A=t[37],j=t[38],M=t[39],N=t[40],P=t[41],F=t[42],I=t[43],L=t[44],R=t[45],z=t[46],B=t[47],ee=t[48],V=t[49],H=t[50];let U;t[82]!==R||t[83]!==z||t[84]!==B||t[85]!==ee||t[86]!==V?(U=(0,$.jsxs)(`div`,{className:R,"aria-busy":z,"aria-label":B,children:[ee,V]}),t[82]=R,t[83]=z,t[84]=B,t[85]=ee,t[86]=V,t[87]=U):U=t[87];let W;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(W=()=>E(ln),t[88]=W):W=t[88];let te;t[89]!==y||t[90]!==o.refreshTools?(te=(0,$.jsx)(Z,{variant:`secondary`,disabled:y,onClick:W,children:o.refreshTools}),t[89]=y,t[90]=o.refreshTools,t[91]=te):te=t[91];let G;t[92]!==s||t[93]!==o.toolsDialogClose?(G=(0,$.jsx)(p,{asChild:!0,children:(0,$.jsx)(Z,{onClick:s,children:o.toolsDialogClose})}),t[92]=s,t[93]=o.toolsDialogClose,t[94]=G):G=t[94];let ne;t[95]!==te||t[96]!==G?(ne=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge p-4`,children:[te,G]}),t[95]=te,t[96]=G,t[97]=ne):ne=t[97];let re;t[98]!==A||t[99]!==N||t[100]!==P||t[101]!==U||t[102]!==ne||t[103]!==H?(re=(0,$.jsxs)(A,{onCloseAutoFocus:H,className:N,children:[P,U,ne]}),t[98]=A,t[99]=N,t[100]=P,t[101]=U,t[102]=ne,t[103]=H,t[104]=re):re=t[104];let ie;t[105]!==j||t[106]!==F||t[107]!==re?(ie=(0,$.jsxs)(j,{children:[F,re]}),t[105]=j,t[106]=F,t[107]=re,t[108]=ie):ie=t[108];let K;return t[109]!==M||t[110]!==I||t[111]!==L||t[112]!==ie?(K=(0,$.jsx)(M,{open:I,onOpenChange:L,children:ie}),t[109]=M,t[110]=I,t[111]=L,t[112]=ie,t[113]=K):K=t[113],K}function ln(e){return e+1}function un(e){return(0,$.jsx)(pe,{className:`h-24 w-full`},e)}function dn(e){if(e.transport===`stdio`)return e.command.trim();try{let t=new URL(e.url);return`${t.protocol}//${t.host}${t.pathname}`}catch{return e.url.trim().split(/[?#]/,1)[0].replace(/\/\/[^/]*@/,`//`)}}function fn({row:e,lastCheck:t,t:n,cs:r,onEdit:i,onRemove:a}){let o=c(e=>e.language),[s,l]=(0,Q.useState)(!1),u=(0,Q.useRef)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(``),h=e.displayName||e.id,g=dn(e),_=e.extra.enabled===!1,v=_?k:t?O:F,y=e.transport===`stdio`?J:q,b=_?n.setupDisabled:t?r.customCheckSucceeded:r.customUnchecked,x=t?new Intl.DateTimeFormat(o,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(t.checkedAt)):null;return(0,$.jsxs)(`li`,{className:`flex min-h-[8.75rem] min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(`div`,{title:n.transportLabels[e.transport],className:`flex size-9 shrink-0 items-center justify-center rounded-xl border border-edge-subtle bg-surface-inset text-fg-muted`,children:(0,$.jsx)(y,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start gap-1`,children:[(0,$.jsx)(`h3`,{className:`min-w-0 max-w-full text-sm font-semibold text-fg`,children:(0,$.jsx)(`button`,{type:`button`,onClick:i,title:h,className:`block max-w-full truncate rounded text-left hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:h})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]`,children:[(0,$.jsxs)(`span`,{title:x?r.customLastChecked.replace(`{{time}}`,x):void 0,"aria-label":x?`${b} · ${r.customLastChecked.replace(`{{time}}`,x)}`:b,className:Y(`inline-flex shrink-0 items-center gap-1`,!_&&t?`text-emerald-700 dark:text-emerald-300`:`text-fg-muted`),children:[(0,$.jsx)(v,{className:`size-3.5`,"aria-hidden":!0}),b]}),t?(0,$.jsx)(`span`,{className:`text-fg-muted`,children:r.customToolCount.replace(`{{count}}`,String(t.toolCount))}):null]})]})})]}),(0,$.jsx)(`p`,{title:g,className:`mt-2 truncate font-mono text-xs leading-5 text-fg-muted`,children:g})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`mr-auto text-[11px] text-fg-subtle`,children:n.transportLabels[e.transport]}),(0,$.jsx)(Z,{variant:`ghost`,className:`h-8 px-2 py-1 text-xs`,onClick:i,children:n.setupConfigure}),(0,$.jsx)(Z,{ref:u,variant:`secondary`,className:`h-8 px-2 py-1 text-xs shadow-none sm:shadow-none`,disabled:_,onClick:()=>l(!0),children:o===`zh`?`用法与工具`:`Usage & tools`}),(0,$.jsxs)(tt,{children:[(0,$.jsx)(nt,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,className:`size-8 p-0`,"aria-label":r.customManage.replace(`{{name}}`,h),title:r.customManage.replace(`{{name}}`,h),children:(0,$.jsx)(L,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(rt,{children:(0,$.jsx)(at,{align:`end`,sideOffset:6,className:`z-50 min-w-36 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:(0,$.jsxs)(it,{onSelect:()=>f(!0),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-danger outline-none data-[highlighted]:bg-surface-hover`,children:[(0,$.jsx)(ue,{className:`size-4`,"aria-hidden":!0}),n.removeServer]})})})]})]}),p?(0,$.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:p}):null,s?(0,$.jsx)(cn,{serverId:e.id,displayName:e.displayName,returnFocusTo:u.current,t:n,onClose:()=>l(!1),onConfigure:()=>{l(!1),i()}}):null,(0,$.jsx)(et,{open:d,title:r.removeConfirmTitle.replace(`{{name}}`,h),description:r.removeConfirmDescription,confirmLabel:n.removeServer,cancelLabel:r.modalCancel,destructive:!0,onCancel:()=>f(!1),onConfirm:()=>{f(!1),m(``),a().catch(()=>m(n.setupRemoveFailed))}})]})}function pn(e){let t=(0,pt.c)(30),{servers:n,lastChecks:r,t:i,cs:a,onAdd:o,onEdit:s,onRemove:c}=e,l;t[0]===a.customIntegrationsTitle?l=t[1]:(l=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.customIntegrationsTitle}),t[0]=a.customIntegrationsTitle,t[1]=l);let u;t[2]===n.length?u=t[3]:(u=(0,$.jsx)(`span`,{className:`rounded-md bg-surface-inset px-1.5 py-0.5 text-xs tabular-nums text-fg-muted`,children:n.length}),t[2]=n.length,t[3]=u);let d;t[4]!==l||t[5]!==u?(d=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l,u]}),t[4]=l,t[5]=u,t[6]=d):d=t[6];let f;t[7]===a.customIntegrationsHint?f=t[8]:(f=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.customIntegrationsHint}),t[7]=a.customIntegrationsHint,t[8]=f);let p;t[9]!==d||t[10]!==f?(p=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[d,f]}),t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(ae,{className:`size-3.5`,"aria-hidden":!0}),t[12]=m):m=t[12];let h;t[13]!==a.customAdd||t[14]!==o?(h=(0,$.jsxs)(Z,{variant:`secondary`,className:`shrink-0 text-xs shadow-none sm:shadow-none`,onClick:o,children:[m,a.customAdd]}),t[13]=a.customAdd,t[14]=o,t[15]=h):h=t[15];let g;t[16]!==p||t[17]!==h?(g=(0,$.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-3`,children:[p,h]}),t[16]=p,t[17]=h,t[18]=g):g=t[18];let _;t[19]!==a||t[20]!==r||t[21]!==s||t[22]!==c||t[23]!==n||t[24]!==i?(_=n.length?(0,$.jsx)(`ul`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:n.map(e=>(0,$.jsx)(fn,{row:e,lastCheck:r[e.id],t:i,cs:a,onEdit:()=>s(e),onRemove:()=>c(e)},e.clientKey))}):(0,$.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge px-5 py-8 text-center text-sm text-fg-muted`,children:a.customEmpty}),t[19]=a,t[20]=r,t[21]=s,t[22]=c,t[23]=n,t[24]=i,t[25]=_):_=t[25];let v;return t[26]!==a.customIntegrationsTitle||t[27]!==g||t[28]!==_?(v=(0,$.jsxs)(`section`,{"aria-label":a.customIntegrationsTitle,children:[g,_]}),t[26]=a.customIntegrationsTitle,t[27]=g,t[28]=_,t[29]=v):v=t[29],v}function mn(e){return e.format===`agent-plugin`&&!!e.pluginId&&(!!e.setup?.authorizations?.length||e.authorizationStatus===`required`||!!e.components?.mcp.some(e=>e.type!==`stdio`))}function hn(e){let t=(0,pt.c)(54),{extension:n,language:r,onOpen:i}=e,a;t[0]===r?a=t[1]:(a=r.startsWith(`zh`),t[0]=r,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(e,t)=>o?e:t,t[2]=o,t[3]=s);let c=s,l=n.installationState===`preparing`,u=n.activationEligible===!1,d=n.authorizationStatus===`required`,f;t[4]!==u||t[5]!==n.readiness||t[6]!==d||t[7]!==l||t[8]!==c?(f=l?c(`准备未完成`,`Setup incomplete`):u?c(`已停用`,`Disabled`):d?c(`需要授权`,`Authorization required`):n.readiness===`blocked`||n.readiness===`degraded`?c(`需要处理`,`Needs attention`):c(`已连接`,`Connected`),t[4]=u,t[5]=n.readiness,t[6]=d,t[7]=l,t[8]=c,t[9]=f):f=t[9];let p=f,m;t[10]!==u||t[11]!==d||t[12]!==l||t[13]!==c?(m=l?c(`继续安装`,`Continue setup`):!u&&d?c(`去授权`,`Connect account`):c(`查看详情`,`View details`),t[10]=u,t[11]=d,t[12]=l,t[13]=c,t[14]=m):m=t[14];let h=m,g;t[15]===n.setup?.authorizations?g=t[16]:(g=n.setup?.authorizations??[],t[15]=n.setup?.authorizations,t[16]=g);let _=g,v=_.length===1?_[0].title:n.name,y=l||!u&&(d||n.readiness===`blocked`||n.readiness===`degraded`),b=l?F:u?k:y?D:O,x=y&&`border-amber-500/25`,S;t[17]===x?S=t[18]:(S=Y(`flex min-h-[8.75rem] w-full min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4 text-left transition-colors hover:bg-surface-hover/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,x),t[17]=x,t[18]=S);let w=n.branding?.iconUrl,T;t[19]===w?T=t[20]:(T=(0,$.jsx)(ct,{iconUrl:w,fallback:K,className:`size-9`}),t[19]=w,t[20]=T);let E;t[21]===v?E=t[22]:(E=(0,$.jsx)(`span`,{className:`block truncate text-sm font-semibold text-fg`,title:v,children:v}),t[21]=v,t[22]=E);let A=y?`text-amber-700 dark:text-amber-300`:u?`text-fg-muted`:`text-emerald-700 dark:text-emerald-300`,j;t[23]===A?j=t[24]:(j=Y(`mt-1 inline-flex items-center gap-1 text-[11px]`,A),t[23]=A,t[24]=j);let M;t[25]===b?M=t[26]:(M=(0,$.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),t[25]=b,t[26]=M);let N;t[27]!==p||t[28]!==j||t[29]!==M?(N=(0,$.jsxs)(`span`,{className:j,children:[M,p]}),t[27]=p,t[28]=j,t[29]=M,t[30]=N):N=t[30];let P;t[31]!==E||t[32]!==N?(P=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[E,N]}),t[31]=E,t[32]=N,t[33]=P):P=t[33];let I;t[34]!==P||t[35]!==T?(I=(0,$.jsxs)(`span`,{className:`flex w-full min-w-0 items-start gap-3`,children:[T,P]}),t[34]=P,t[35]=T,t[36]=I):I=t[36];let L=n.name,R;t[37]===c?R=t[38]:(R=c(`由插件提供`,`Provided by plugin`),t[37]=c,t[38]=R);let z;t[39]!==n.name||t[40]!==R?(z=(0,$.jsxs)(`span`,{className:`mt-2 block w-full truncate text-xs leading-5 text-fg-muted`,title:L,children:[R,` · `,n.name]}),t[39]=n.name,t[40]=R,t[41]=z):z=t[41];let B=y?`text-accent-fg`:`text-fg-muted`,ee;t[42]===B?ee=t[43]:(ee=Y(`mt-auto flex w-full items-center justify-end gap-1 pt-2 text-xs`,B),t[42]=B,t[43]=ee);let V;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(C,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[44]=V):V=t[44];let H;t[45]!==h||t[46]!==ee?(H=(0,$.jsxs)(`span`,{className:ee,children:[h,V]}),t[45]=h,t[46]=ee,t[47]=H):H=t[47];let U;return t[48]!==i||t[49]!==I||t[50]!==z||t[51]!==H||t[52]!==S?(U=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:S,children:[I,z,H]}),t[48]=i,t[49]=I,t[50]=z,t[51]=H,t[52]=S,t[53]=U):U=t[53],U}function gn(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function _n(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?gn(t)-gn(e):e.isCurrentAuthorization?-1:1}function vn(e){let t=new Map;for(let n of e){let e=n.accountId??n.identityKey??`authorization:${n.id}`;t.set(e,[...t.get(e)??[],n])}return[...t.entries()].map(([e,t])=>{let n=[...t].sort(_n);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>_n(e.primary,t.primary))}var yn=Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Je);function bn(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function xn(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function Sn(e,t,n){return e.status===`connected`?H(n.composioHealthConnected,{count:String(t)}):e.status===`reauthorization_required`?n.composioHealthReconnect:e.status===`disconnected`?n.composioHealthDisconnected:e.errorCode===`missing_credential`?n.composioHealthMissingCredential:e.errorCode===`unauthorized`?n.composioHealthUnauthorized:e.errorCode===`forbidden`?n.composioHealthForbidden:e.errorCode===`network`?n.composioHealthNetwork:e.errorCode===`timeout`?n.composioHealthTimeout:n.composioHealthDegraded}function Cn(e,t){return e===`active`?t.composioConnectionHealthy:e===`pending`?t.composioConnectionPending:e===`expired`?t.composioConnectionExpired:e===`failed`?t.composioConnectionFailed:e===`revoked`||e===`disabled`?t.composioConnectionRevoked:t.composioConnectionUnknown}function wn(e,t,n){return e.status===`paused`?t?.scanEnabled===!1?n.connectorLearningPausedByPolicy:n.connectorLearningPausedByFailure:e.status===`queued`?n.connectorLearningQueued:e.status===`running`?n.connectorLearningRunning:e.status===`completed`?n.connectorLearningCompleted:n.connectorLearningFailed}function Tn({instance:e,t,onChanged:n}){let r=bn(e),i=c(e=>e.language)===`zh`,[a,o]=(0,Q.useState)([]),[s,l]=(0,Q.useState)([]),[u,d]=(0,Q.useState)([]),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)([]),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)([]),[S,C]=(0,Q.useState)({}),[E,k]=(0,Q.useState)(`read`),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(null),[B,U]=(0,Q.useState)(!1),[W,te]=(0,Q.useState)(!1),[G,re]=(0,Q.useState)(!1),ie=(0,Q.useRef)(0),K=(0,Q.useRef)(0),ae=(0,Q.useMemo)(()=>vn(a),[a]),se=(0,Q.useCallback)(e=>new Promise((t,n)=>{let r=window.setTimeout(()=>n(Error(i?`连接服务响应超时,请重试。`:`The connection service timed out. Please retry.`)),15e3);e.then(t,n).finally(()=>window.clearTimeout(r))}),[i]),q=(0,Q.useCallback)(async()=>{if(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)return;j(!0),N(null);let t=++ie.current;try{let e=(await Promise.allSettled([se(ke()).then(e=>{t===ie.current&&(o(e.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),U(!0))}),se(Me(r)).then(e=>{t===ie.current&&k(e)}),se(He(r)).then(e=>{t===ie.current&&(p(e.policy),h(e.agents))})])).find(e=>e.status===`rejected`);t===ie.current&&e?.status===`rejected`&&N(String(e.reason instanceof Error?e.reason.message:e.reason))}finally{t===ie.current&&j(!1)}},[e.materialized,r,se]);(0,Q.useEffect)(()=>(q(),()=>{ie.current++}),[q]);let ce=(0,Q.useCallback)(async()=>{if(!r)return;let e=++K.current;re(!0),F(!1);let t=t=>n=>{e===K.current&&t(n)},n=await Promise.allSettled([se(Ue(r)).then(t(l)),se(Ke(20)).then(t(e=>d(e.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())))),se(ze(r)).then(t(y)),se(Fe(r)).then(t(_))]);e===K.current&&(F(n.some(e=>e.status===`rejected`)),re(!1))},[r,se]);(0,Q.useEffect)(()=>(W&&ce(),()=>{K.current++}),[W,ce]),(0,Q.useEffect)(()=>{let e=!1,t=vn(a).map(e=>e.primary).filter(e=>e.supportsLearning&&e.accountId);if(t.length)return se(Ge()).then(t=>{e||x(t)}).catch(()=>{}),Promise.allSettled(t.map(async e=>[e.accountId,await se(Ie(e.accountId))])).then(t=>{e||C(Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[e.value]:[])))}),()=>{e=!0}},[a,se]);let le=(0,Q.useCallback)(async i=>{if(!r)return;let a=Ye()?null:window.open(`about:blank`,`_blank`);a&&(a.opener=null),j(!0),N(null);try{if(!Ye()&&!a)throw Error(`Allow popups to open the authorization page.`);let t=await Pe(e.connectorId,i);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(Ye()){let e=await window.electronAPI?.shell?.openExternalUrl(t.authorizationUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else a.location.href=t.authorizationUrl;let o=await qe(r,t.connectionId,12e4,t.attemptId);if(i&&o.accountId!==i)throw Error(`A different account was authorized. The original account and its task bindings were not changed.`);await Promise.all([n?.(),q()])}catch(e){N(ne(e,t))}finally{a?.close(),j(!1)}},[e.connectorId,q,n,t,r]),J=(0,Q.useCallback)(async t=>{j(!0),N(null);try{await Se(e.instanceId,{config:{...e.config??{},authConfigId:t||void 0}}),await Promise.all([n?.(),q()])}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}},[e.config,e.instanceId,q,n]),de=async e=>{let t=Ye()?null:window.open(`about:blank`,`_blank`);t&&(t.opener=null),N(null);try{let n=await je(e.id);if(n.authorizationUrl)if(Ye())await window.electronAPI?.shell?.openExternalUrl(n.authorizationUrl);else if(t)t.location.href=n.authorizationUrl;else throw Error(`Allow popups to reopen authorization.`);else t?.close(),await q()}catch(e){t?.close(),N(e instanceof Error?e.message:String(e))}},fe=(0,Q.useCallback)(async e=>{if(r){k(e),N(null);try{await Te(r,e)}catch(e){N(e instanceof Error?e.message:String(e)),await q()}}},[q,r]),me=(0,Q.useCallback)(async e=>{if(r){N(null);try{p(await xe(r,e))}catch(e){N(e instanceof Error?e.message:String(e))}}},[r]),he=(0,Q.useCallback)(e=>{if(!f)return;let t=f.allowedAgentIds.includes(e);if(t&&f.allowedAgentIds.length===1)return;let n=t?f.allowedAgentIds.filter(t=>t!==e):[...f.allowedAgentIds,e];me({allowedAgentIds:n})},[me,f]),X=(0,Q.useCallback)(async e=>{j(!0),N(null);try{await e(),await q()}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}},[q]);if(!r)return null;if(e.materialized.type===`composio`&&e.materialized.role===`credential`)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioApiKeyStored});let ge=ae.filter(e=>e.primary.status===`active`).length,_e=ge>0?t.composioAddAccount:t.composioConnectAccount,Ce=B&&ge>0,we=v?.requiresCustomAuthConfig===!0,Ae=v?.authConfigs.filter(e=>e.status===`ENABLED`&&e.isEnabledForToolRouter)??[];return(0,$.jsxs)(`div`,{className:`space-y-5`,children:[(0,$.jsxs)(`section`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:Y(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,Ce?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[Ce?(0,$.jsx)(O,{className:`size-3.5`}):(0,$.jsx)(D,{className:`size-3.5`}),Ce?t.connectionReady:B||M?t.connectionNeedsSetup:t.connectionChecking]}),B&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:H(t.composioAccountCount,{count:String(ae.length)})})]}),(0,$.jsxs)(Z,{variant:`primary`,className:`shrink-0`,disabled:A,onClick:()=>void le(),children:[A?(0,$.jsx)(V,{className:`size-4 animate-spin`}):(0,$.jsx)(ee,{className:`size-4`}),_e]})]}),M?(0,$.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center justify-between gap-2 rounded-xl border border-danger/20 bg-danger/5 px-3 py-2 text-sm text-danger`,children:[(0,$.jsx)(`p`,{children:M}),(0,$.jsx)(Z,{variant:`secondary`,disabled:A,onClick:()=>void q(),children:t.composioRetry})]}):null,g&&!Ce?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-amber-500/25 bg-amber-500/5 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:Sn(g,ge,t)}),g.recovery===`none`?null:(0,$.jsx)(Z,{variant:`secondary`,disabled:A,onClick:()=>void(g.recovery===`retry`?q():le()),children:g.recovery===`retry`?t.composioRetry:t.composioReconnectAccount})]}):null,we&&Ae.length===0?(0,$.jsx)(`p`,{className:`rounded-xl border border-amber-500/25 bg-amber-500/5 px-4 py-3 text-sm text-amber-800 dark:text-amber-200`,children:t.composioAuthConfigEmpty}):null,f?(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-start`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAccessTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:E===`read`?t.composioAccessReadHint:E===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(w,{value:E,onChange:e=>void fe(e.currentTarget.value),children:[(0,$.jsx)(T,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(T,{value:`write`,children:t.composioAccessReadWrite}),E===`admin`?(0,$.jsx)(T,{value:`admin`,children:t.composioAccessAdminCurrent}):null]})]}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm text-fg-muted`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioConfirmationPolicy}),(0,$.jsxs)(w,{value:f.confirmationPolicy,onChange:e=>void me({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(T,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(T,{value:`always`,children:t.composioConfirmAlways}),f.confirmationPolicy===`never`?(0,$.jsx)(T,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAllowedAgents}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:f.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-full border px-2.5 py-1 text-xs transition-colors`,f.allowedAgentIds.length===0?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>void me({allowedAgentIds:[]}),children:t.composioAllowedAgentsAllOption}),m.map(e=>(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-full border px-2.5 py-1 text-xs transition-colors`,f.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>he(e.id),children:e.name},e.id))]})]}),(0,$.jsxs)(`fieldset`,{className:`space-y-2 border-t border-edge-subtle p-4 text-xs text-fg-muted`,children:[(0,$.jsx)(`legend`,{children:i?`可用账号范围`:`Available accounts`}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:f.selectedAccountIds===null,disabled:A,onChange:e=>void me({selectedAccountIds:e.currentTarget.checked?null:[]})}),i?`所有账号(包括以后新增)`:`All accounts, including new ones`]}),f.selectedAccountIds!==null&&ae.map(({primary:e})=>e.accountId&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:A,checked:f.selectedAccountIds.includes(e.accountId),onChange:t=>void me({selectedAccountIds:t.currentTarget.checked?[...f.selectedAccountIds,e.accountId]:f.selectedAccountIds.filter(t=>t!==e.accountId)})}),e.alias??e.accountEmail??e.accountId]},e.accountId)),f.selectedAccountIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择账号,Agent 无法使用此应用。`:`No accounts selected. Agents cannot use this app.`})]})]})]}):null,(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.composioConnectedAccounts}),B&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:H(t.composioAccountCount,{count:String(ae.length)})})]}),(0,$.jsxs)(Z,{variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:A,onClick:()=>void q(),children:[(0,$.jsx)(oe,{className:Y(`size-3.5`,A&&`animate-spin`)}),t.refresh]})]}),ae.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:ae.map(e=>{let r=e.primary,a=b.find(e=>r.accountId?e.accountId===r.accountId:e.connectionId===r.id),o=r.accountId?S[r.accountId]:void 0;return(0,$.jsxs)(`article`,{className:`px-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start justify-between gap-3 sm:flex-row`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:r.alias??r.workspace??r.accountEmail??r.username??t.composioUnnamedAuthorization})}),(0,$.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:r.accountEmail??r.username??r.workspace??r.accountId}),r.backendLabel&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.backendLabel}),(0,$.jsx)(`p`,{className:Y(`mt-1 text-xs`,r.status===`active`?`text-emerald-700 dark:text-emerald-300`:`text-amber-700 dark:text-amber-300`),children:r.accountEnabled===!1?i?`已暂停`:`Paused`:Cn(r.status,t)}),a?(0,$.jsx)(`p`,{className:Y(`mt-1 text-xs`,a.status===`failed`?`text-red-600`:`text-fg-subtle`),children:H(t.connectorLearningStatus,{status:wn(a,o,t),count:String(a.candidatesCreated)})}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[r.status===`pending`&&(0,$.jsx)(Z,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:()=>void de(r),children:i?`继续授权`:`Continue authorization`}),r.accountId&&(0,$.jsx)(Z,{variant:`ghost`,className:`h-8 px-2.5 text-xs text-danger`,disabled:A,onClick:()=>z(r.accountId),children:i?`断开`:`Disconnect`}),r.accountId&&r.status!==`active`&&(0,$.jsx)(Z,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:A,onClick:()=>void le(r.accountId),children:t.composioReconnectAccount}),r.accountId&&(0,$.jsx)(Z,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:A,onClick:()=>void X(()=>Ee(r.accountId,{enabled:r.accountEnabled===!1})),children:r.accountEnabled===!1?i?`启用`:`Enable`:i?`暂停`:`Pause`}),r.supportsLearning&&r.status===`active`&&r.accountEnabled!==!1?(0,$.jsxs)(Z,{variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:A,onClick:()=>void X(async()=>{if(!r.accountId)throw Error(`Connector account is unavailable.`);await ve(r.accountId),await n?.()}),children:[(0,$.jsx)(oe,{className:`size-3.5`}),t.composioSyncNow]}):null]})]}),(0,$.jsxs)(`details`,{className:`mt-3 text-xs text-fg-muted`,children:[(0,$.jsx)(`summary`,{className:`w-fit cursor-pointer font-medium hover:text-fg`,children:t.composioAccountSettings}),(0,$.jsxs)(`div`,{className:`mt-3 space-y-4 rounded-lg bg-surface-panel p-3`,children:[r.accountId&&(0,$.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,$.jsx)(`legend`,{className:`mb-2 font-medium`,children:t.composioAllowedAgents}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:A,checked:r.allowedAgentIds==null,onChange:e=>void X(()=>Ee(r.accountId,{allowedAgentIds:e.currentTarget.checked?null:[]}))}),t.composioAllowedAgentsAllOption]}),r.allowedAgentIds!=null&&m.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:A,checked:r.allowedAgentIds.includes(e.id),onChange:t=>{let n=t.currentTarget.checked;X(()=>Ee(r.accountId,{allowedAgentIds:n?[...r.allowedAgentIds,e.id]:r.allowedAgentIds.filter(t=>t!==e.id)}))}}),e.name]},e.id)),r.allowedAgentIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择 Agent:任何 Agent 都不能使用此账号。`:`No agents selected: this account is unavailable to all agents.`})]}),r.supportsLearning&&o?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:o.scanEnabled,disabled:A,onChange:e=>void X(()=>De(r.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),o.scanEnabled?(0,$.jsxs)(`label`,{className:`sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(w,{className:`mt-1`,value:String(o.intervalMinutes??30),disabled:A,onChange:e=>void X(()=>De(r.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(T,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(T,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(T,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(T,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[t.composioAccountAlias,(0,$.jsx)(`input`,{className:Y(yn,`mt-1 h-8 py-1 text-xs`),defaultValue:r.alias??``,onBlur:e=>{e.currentTarget.value!==(r.alias??``)&&X(()=>be(r.id,{alias:e.currentTarget.value}))}})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:e.authorizations.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`p`,{className:`min-w-0 break-all font-mono text-fg-subtle`,children:[t.composioAuthorizationId,`: `,e.providerConnectionId]}),(0,$.jsx)(Z,{variant:`ghost`,className:`size-7 shrink-0 p-0 text-danger`,title:t.composioRevoke,disabled:A,onClick:()=>L(e.id),children:(0,$.jsx)(ue,{className:`size-3.5`})})]},e.id))}),(0,$.jsx)(`div`,{className:`flex justify-end gap-1`,children:(0,$.jsx)(Z,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:A,onClick:()=>void X(()=>Oe(r.id)),children:(0,$.jsx)(oe,{className:`size-4`})})})]})]})]},e.key)})}):A&&!B?(0,$.jsxs)(`div`,{"aria-busy":`true`,"aria-label":t.connectionChecking,className:`space-y-3`,children:[(0,$.jsx)(pe,{className:`h-16 w-full`}),(0,$.jsx)(pe,{className:`h-16 w-full`})]}):B?(0,$.jsx)(`div`,{className:`rounded-xl border border-dashed border-edge px-4 py-8 text-center`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioConnectionsEmpty})}):null]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,onToggle:e=>te(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`space-y-5 border-t border-edge-subtle px-4 py-4`,children:[G?(0,$.jsx)(pe,{"aria-label":t.connectionChecking,className:`h-16 w-full`}):null,P?(0,$.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200`,children:[t.composioDiagnosticsUnavailable,(0,$.jsx)(Z,{variant:`ghost`,disabled:G,onClick:()=>void ce(),children:t.composioRetry})]}):null,v?.mode===`byok`?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAuthConfigTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:we?t.composioAuthConfigRequiredHint:t.composioAuthConfigOptionalHint})]}),(0,$.jsx)(`a`,{className:`text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:t.composioAuthConfigManage})]}),(0,$.jsxs)(w,{className:`mt-3`,value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:A,onChange:e=>void J(e.currentTarget.value),children:[we?null:(0,$.jsx)(T,{value:``,children:t.composioAuthConfigManaged}),we&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(T,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,Ae.map(e=>(0,$.jsxs)(T,{value:e.id,children:[e.name,` · `,e.authScheme??`OAuth`]},e.id))]})]}):null,(0,$.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),(0,$.jsx)(`div`,{className:`space-y-2`,children:s.length?s.slice(0,8).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[xn(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),(0,$.jsx)(`div`,{className:`space-y-2`,children:u.length?u.slice(0,5).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})})]})]})]})]}),(0,$.jsx)(et,{open:R!==null,title:i?`断开账号`:`Disconnect account`,description:i?`停止此账号的工具使用和学习,并撤销其全部授权。已保存的数据不会删除。`:`Stop tool access and learning for this account and revoke all its authorizations. Saved data will not be deleted.`,confirmLabel:i?`断开`:`Disconnect`,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=R;z(null),e&&X(()=>Le(e))},onCancel:()=>z(null)}),(0,$.jsx)(et,{open:I!==null,title:t.composioRevoke,description:t.composioRevokeConfirm,confirmLabel:t.composioRevoke,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=I;L(null),e&&X(()=>ye(e))},onCancel:()=>L(null)})]})}var En=Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Je);function Dn(e,t){let n={};for(let r of e?.setup.config??[]){let e=t.config?.[r.key]??r.defaultValue??``;n[r.key]=typeof e==`string`?e:JSON.stringify(e,null,2)}return n}function On(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function kn({instance:e,definition:t,onClose:n,onChanged:r,t:i}){let[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(()=>Dn(t,e)),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(null),A=t?.setup.config??[],j=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&A.length>0&&(t?.setup.secrets??[]).length===0,M=e.materialized.type===`mcp`,N=e.materialized.type===`composio`,P=e.materialized.type===`memorySource`,F=t?W(t,i):null,L=(0,Q.useCallback)(async()=>{D(!0),T(null);try{let t=await we(e.instanceId);k(t),t.ok||T(t.error??t.action??i.healthStatusLabels[t.status]),await r()}catch(e){T(e instanceof Error?e.message:String(e))}finally{D(!1)}},[e.instanceId,r,i.healthStatusLabels]),R=(0,Q.useCallback)(async()=>{o(!0),T(null);try{await We(e.instanceId),await r(),n()}catch(e){T(e instanceof Error?e.message:String(e)),o(!1)}},[e.instanceId,r,n]),z=(0,Q.useCallback)(async()=>{if(!(!t||!j)){u(!0),T(null);try{let n={};for(let e of t.setup.config??[]){let t=On(e.type,S[e.key]??``);t!==void 0&&(n[e.key]=t)}await Se(e.instanceId,{config:n}),await r()}catch(e){T(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[S,t,e.instanceId,r,j]),B=(0,Q.useCallback)(async()=>{y(!0),x(null),T(null);try{let t=await Ce(e.connectorId);x(t.recordIds.length),await r()}catch(e){T(e instanceof Error?e.message:String(e))}finally{y(!1)}},[e.connectorId,r]);return(0,$.jsxs)(_,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(m,{children:[(0,$.jsx)(d,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(h,{className:Y(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,N?`h-[min(100dvh-2rem,36rem)] w-[min(100%-2rem,40rem)]`:`h-[min(100dvh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))]`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(te,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(g,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(f,{className:`mt-1 text-sm text-fg-muted`,children:F??(e.materialized.type===`mcp`?H(i.mcpServerRuntime,{serverId:e.materialized.serverId}):H(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(p,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,_e.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(fe,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[w?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:w}):null,e.enabled&&(O?O.ok:e.connectionStatus===`connected`||e.status===`connected`||e.usage.lastHealthStatus===`ok`)?(0,$.jsx)(`div`,{className:`mb-5`,children:(0,$.jsx)(ot,{target:{kind:`connector`,id:e.connectorId,name:e.displayName},onStart:n})}):null,M?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,role:`status`,children:O?.ok?H(i.toolsAvailable,{count:String(O.toolCount)}):O?i.healthStatusLabels[O.status]:e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]:i.healthNotTested}),(0,$.jsxs)(Z,{variant:`secondary`,"aria-busy":E,disabled:E||!e.enabled,onClick:()=>void L(),children:[E?(0,$.jsx)(V,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(oe,{className:`size-4`,"aria-hidden":!0}),i.test]})]}),j?A.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:En,value:S[e.key]??``,placeholder:e.placeholder,onChange:t=>C(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key)):null]}):null,N?(0,$.jsx)(Tn,{instance:e,t:i,onChanged:r}):null,P?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-surface-base p-4 text-sm`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedSourceSync}),F?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:F}):null,b===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:H(i.connectedSourceSynced,{count:String(b)})})]}),(0,$.jsxs)(Z,{disabled:v,onClick:()=>void B(),children:[v?(0,$.jsx)(V,{className:`size-4 animate-spin`}):(0,$.jsx)(I,{className:`size-4`}),i.composioSyncNow]})]}),j?(0,$.jsx)(`div`,{className:`grid gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:A.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:En,value:S[e.key]??``,placeholder:e.placeholder,onChange:t=>C(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}):null,!M&&!N&&!P?(0,$.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:(0,$.jsx)(`p`,{children:i.connectorPolicyHint})}):null,(0,$.jsxs)(`details`,{className:`mt-5 rounded-xl border border-edge`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-danger`,children:i.dangerZone}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-danger/15 px-4 py-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:i.removeConnectorHint}),(0,$.jsxs)(Z,{variant:`secondary`,className:`shrink-0 border-danger/30 text-danger hover:bg-danger/10`,disabled:a,onClick:()=>c(!0),children:[a?(0,$.jsx)(V,{className:`size-4 animate-spin`}):(0,$.jsx)(ue,{className:`size-4`}),i.remove]})]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,$.jsx)(Z,{variant:`secondary`,onClick:n,children:i.modalClose}),(M||P)&&j?(0,$.jsxs)(Z,{variant:`primary`,disabled:l,onClick:()=>void z(),children:[l?(0,$.jsx)(V,{className:`size-4 animate-spin`}):(0,$.jsx)(se,{className:`size-4`}),i.modalSave]}):null]})]})]}),(0,$.jsx)(et,{open:s,title:H(i.removeConfirmTitle,{name:e.displayName}),description:i.removeConfirmDescription,confirmLabel:i.removeConfirmAction,cancelLabel:i.modalCancel,destructive:!0,onConfirm:()=>{c(!1),R()},onCancel:()=>{a||c(!1)}})]})}function An(e){let t=(0,pt.c)(2),n;return t[0]===e?n=t[1]:(n=e.instance.materialized.type===`cli`&&e.definition?(0,$.jsx)(G,{definition:e.definition,instance:e.instance,onClose:e.onClose,onChanged:e.onChanged}):(0,$.jsx)(kn,{...e}),t[0]=e,t[1]=n),n}function jn(e){let t=(0,pt.c)(59),{instance:n,definition:r,highlighted:i,onOpenDetails:a,t:o}=e,s=i!==void 0&&i,c;t[0]!==r||t[1]!==n?(c=wt(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c.state,u;t[3]!==r||t[4]!==o?(u=r?W(r,o):null,t[3]=r,t[4]=o,t[5]=u):u=t[5];let d=u,f,p,m,h,g,_,v,y,b;if(t[6]!==l||t[7]!==r||t[8]!==s||t[9]!==n||t[10]!==a||t[11]!==o.connectionChecking||t[12]!==o.connectionNeedsSetup||t[13]!==o.connectionReady){f=l===`ready`?{label:o.connectionReady,Icon:O,className:`text-emerald-700 dark:text-emerald-300`}:l===`needs_setup`?{label:o.connectionNeedsSetup,Icon:D,className:`text-amber-700 dark:text-amber-300`}:{label:o.connectionChecking,Icon:F,className:`text-fg-muted`},b=`button`;let e=l===`needs_setup`&&`border-amber-500/25`,i=s&&`bg-accent-soft`;t[23]!==e||t[24]!==i?(p=Y(`flex min-h-[8.75rem] w-full min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4 text-left hover:bg-surface-hover/45`,_e.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,e,i),t[23]=e,t[24]=i,t[25]=p):p=t[25],t[26]!==n||t[27]!==a?(m=()=>a(n),t[26]=n,t[27]=a,t[28]=m):m=t[28],v=`flex w-full min-w-0 items-start gap-3`,t[29]===r?y=t[30]:(y=(0,$.jsx)(te,{connector:r,size:`sm`}),t[29]=r,t[30]=y),g=`min-w-0 flex-1`,t[31]===n.displayName?_=t[32]:(_=(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,title:n.displayName,children:n.displayName}),t[31]=n.displayName,t[32]=_),h=Y(`mt-1 inline-flex items-center gap-1 text-[11px]`,f.className),t[6]=l,t[7]=r,t[8]=s,t[9]=n,t[10]=a,t[11]=o.connectionChecking,t[12]=o.connectionNeedsSetup,t[13]=o.connectionReady,t[14]=f,t[15]=p,t[16]=m,t[17]=h,t[18]=g,t[19]=_,t[20]=v,t[21]=y,t[22]=b}else f=t[14],p=t[15],m=t[16],h=t[17],g=t[18],_=t[19],v=t[20],y=t[21],b=t[22];let x;t[33]===f.Icon?x=t[34]:(x=(0,$.jsx)(f.Icon,{className:`size-3.5`,"aria-hidden":!0}),t[33]=f.Icon,t[34]=x);let S;t[35]!==f.label||t[36]!==x||t[37]!==h?(S=(0,$.jsxs)(`span`,{className:h,children:[x,f.label]}),t[35]=f.label,t[36]=x,t[37]=h,t[38]=S):S=t[38];let w;t[39]!==S||t[40]!==g||t[41]!==_?(w=(0,$.jsxs)(`div`,{className:g,children:[_,S]}),t[39]=S,t[40]=g,t[41]=_,t[42]=w):w=t[42];let T;t[43]!==w||t[44]!==v||t[45]!==y?(T=(0,$.jsxs)(`div`,{className:v,children:[y,w]}),t[43]=w,t[44]=v,t[45]=y,t[46]=T):T=t[46];let E;t[47]===d?E=t[48]:(E=d?(0,$.jsx)(`p`,{className:`mt-2 w-full line-clamp-2 text-xs leading-5 text-fg-muted`,title:d,children:d}):null,t[47]=d,t[48]=E);let k;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(C,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[49]=k):k=t[49];let A;t[50]===o.installedDetails?A=t[51]:(A=(0,$.jsxs)(`span`,{className:`mt-auto flex w-full items-center justify-end gap-1 pt-2 text-xs text-fg-muted`,children:[o.installedDetails,k]}),t[50]=o.installedDetails,t[51]=A);let j;return t[52]!==p||t[53]!==m||t[54]!==T||t[55]!==E||t[56]!==A||t[57]!==b?(j=(0,$.jsxs)(`button`,{type:b,className:p,onClick:m,children:[T,E,A]}),t[52]=p,t[53]=m,t[54]=T,t[55]=E,t[56]=A,t[57]=b,t[58]=j):j=t[58],j}function Mn(e,t){return Kt()}function Nn(e){let t=e.headers.filter(e=>e.key.trim()),n=t.find(e=>e.key.toLowerCase()===`authorization`&&!e.reference&&/^Bearer\s/i.test(e.value)),r=e.extra.auth||t.some(e=>e.reference)||e.extra.oauth&&t.some(e=>e.key.toLowerCase()===`authorization`)?`existing`:e.extra.oauth?`oauth`:n?`bearer`:t.length?`headers`:`auto`;return{mode:r,token:n?.value.replace(/^Bearer\s+/i,``)??``,apiKey:``,headerName:``,customHeaders:t.length?t:[Nt()],additionalHeaders:r===`bearer`?t.filter(e=>e!==n):r===`oauth`?t:[]}}function Pn(e,t){if(e.transport===`stdio`||t.mode===`existing`)return{...e,extra:{...e.extra}};let n={...e.extra};delete n.auth,t.mode!==`oauth`&&delete n.oauth;let r=t.mode===`headers`?t.customHeaders:t.additionalHeaders;if(t.mode===`bearer`){let e=t.token.trim().replace(/^Bearer\s+/i,``);r=[...r,Nt(`Authorization`,`Bearer ${e}`)]}return t.mode===`apiKey`&&(r=[...r,Nt(t.headerName.trim(),t.apiKey.trim())]),{...e,extra:n,headers:r,oauthClientId:t.mode===`oauth`?e.oauthClientId:``}}function Fn(e){let t=new Set;return e.findIndex(e=>{let n=e.key.trim();if(!n&&!e.value&&!e.reference)return!1;if(!/^[!#$%&'*+.^_`|~\da-z-]+$/i.test(n)||/[\r\n]/.test(e.value))return!0;let r=n.toLowerCase();return t.has(r)?!0:(t.add(r),!1)})}function In(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Je)}function Ln({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,pasteFailedTitle:o,dismissLabel:s,keyPlaceholder:c,valuePlaceholder:l,headers:u,onChange:d,referenceLabel:f=`Existing credential reference`,showValueLabel:p=`Show value`,hideValueLabel:m=`Hide value`,allowPaste:h=!0}){let[g,_]=(0,Q.useState)(new Set),[v,y]=(0,Q.useState)(!1),b=(e,t)=>{d(u.map((n,r)=>r===e?{...n,...t}:n))},x=()=>{d([...u,Nt()])},S=e=>{let t=u.filter((t,n)=>n!==e);d(t.length>0?t:[Nt()])},C=async()=>{try{let e=await ge();if(!e){y(!0);return}let t=Ft(e);if(!t?.length){y(!0);return}d(t)}catch{y(!0)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:e}),t?(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),h?(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void C(),children:[(0,$.jsx)(A,{className:`size-3.5`,"aria-hidden":!0}),i]}):null]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,$.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)_auto_auto]`,children:[(0,$.jsx)(`input`,{className:Y(In(),`col-span-3 min-w-0 font-mono text-xs sm:col-span-1`),"aria-label":`${c} ${t+1}`,value:e.key,placeholder:c,onChange:e=>b(t,{key:e.target.value})}),(0,$.jsx)(`input`,{className:Y(In(),`min-w-0 font-mono text-xs`),type:g.has(e.clientKey)?`text`:`password`,autoComplete:`off`,"aria-label":`${l} ${t+1}`,readOnly:!!e.reference,value:e.reference?f:e.value,placeholder:e.reference?f:l,onChange:e=>b(t,{value:e.target.value})}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,className:`size-10 shrink-0 px-0`,disabled:!!e.reference,"aria-label":g.has(e.clientKey)?m:p,onClick:()=>_(t=>{let n=new Set(t);return n.has(e.clientKey)?n.delete(e.clientKey):n.add(e.clientKey),n}),children:g.has(e.clientKey)?(0,$.jsx)(z,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(B,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:u.length<=1&&!e.key&&!e.value,onClick:()=>S(t),"aria-label":r,children:(0,$.jsx)(ue,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})}),e.reference?(0,$.jsx)(`p`,{className:`col-span-3 break-words text-xs text-fg-muted sm:col-span-4`,children:f}):null]},e.clientKey))}),(0,$.jsx)(et,{open:v,title:o,description:a,confirmLabel:s,onConfirm:()=>y(!1),onCancel:()=>y(!1)}),(0,$.jsxs)(`button`,{type:`button`,className:Y(`self-start text-sm text-accent hover:underline`,_e.press),onClick:x,children:[`+ `,n]})]})}var Rn=Y(`w-full min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,Je);function zn(e){let t=(0,pt.c)(20),{value:n,onChange:r,label:i,t:a,required:o}=e,s=o!==void 0&&o,[c,l]=(0,Q.useState)(!1),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(Rn,`mt-1.5`),t[0]=u):u=t[0];let d=c?`text`:`password`,f;t[1]===r?f=t[2]:(f=e=>r(e.target.value),t[1]=r,t[2]=f);let p;t[3]!==s||t[4]!==d||t[5]!==f||t[6]!==n?(p=(0,$.jsx)(`input`,{className:u,type:d,value:n,required:s,autoComplete:`off`,onChange:f}),t[3]=s,t[4]=d,t[5]=f,t[6]=n,t[7]=p):p=t[7];let m;t[8]!==i||t[9]!==p?(m=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i,p]}),t[8]=i,t[9]=p,t[10]=m):m=t[10];let h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>l(Bn),t[11]=h):h=t[11];let g;t[12]===c?g=t[13]:(g=c?(0,$.jsx)(z,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(B,{className:`size-4`,"aria-hidden":!0}),t[12]=c,t[13]=g);let _=c?a.setupHideValue:a.setupShowValue,v;t[14]!==g||t[15]!==_?(v=(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,className:`gap-1.5 text-xs`,onClick:h,children:[g,_]}),t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;return t[17]!==v||t[18]!==m?(y=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[m,v]}),t[17]=v,t[18]=m,t[19]=y):y=t[19],y}function Bn(e){return!e}function Vn(e){let t=(0,pt.c)(17),{headers:n,onChange:r,t:i,additional:a,environment:o}=e,s=a!==void 0&&a,c=o!==void 0&&o,l=c?i.envLabel:s?i.setupAdditionalHeaders:i.headersLabel,u=c?i.setupAddEnv:i.addHeader,d=c?i.setupRemoveEnv:i.removeHeader,f=c?i.setupEnvName:i.headerKeyPlaceholder,p=c?i.setupEnvValue:i.headerValuePlaceholder,m=!c,h;return t[0]!==n||t[1]!==r||t[2]!==i.optionalSuffix||t[3]!==i.pasteHeaders||t[4]!==i.pasteHeadersDismiss||t[5]!==i.pasteHeadersFailed||t[6]!==i.pasteHeadersFailedTitle||t[7]!==i.setupHideValue||t[8]!==i.setupReference||t[9]!==i.setupShowValue||t[10]!==l||t[11]!==u||t[12]!==d||t[13]!==f||t[14]!==p||t[15]!==m?(h=(0,$.jsx)(Ln,{label:l,optionalLabel:i.optionalSuffix,addLabel:u,removeHeaderAria:d,pasteLabel:i.pasteHeaders,pasteFailed:i.pasteHeadersFailed,pasteFailedTitle:i.pasteHeadersFailedTitle,dismissLabel:i.pasteHeadersDismiss,keyPlaceholder:f,valuePlaceholder:p,headers:n,onChange:r,referenceLabel:i.setupReference,showValueLabel:i.setupShowValue,hideValueLabel:i.setupHideValue,allowPaste:m}),t[0]=n,t[1]=r,t[2]=i.optionalSuffix,t[3]=i.pasteHeaders,t[4]=i.pasteHeadersDismiss,t[5]=i.pasteHeadersFailed,t[6]=i.pasteHeadersFailedTitle,t[7]=i.setupHideValue,t[8]=i.setupReference,t[9]=i.setupShowValue,t[10]=l,t[11]=u,t[12]=d,t[13]=f,t[14]=p,t[15]=m,t[16]=h):h=t[16],h}function Hn(e){let t=(0,pt.c)(52),{draft:n,onChange:r,t:i,allowExisting:a}=e,o=i.setupAuthLabel,s=i.setupAuthLabel,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=Y(Rn,`mt-1.5`),t[0]=c):c=t[0];let l=n.mode,u;t[1]===r?u=t[2]:(u=e=>r({mode:e.target.value}),t[1]=r,t[2]=u);let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=[`auto`,`oauth`,`bearer`,`apiKey`,`headers`,`none`],t[3]=d):d=t[3];let f;t[4]===i.setupAuthModes?f=t[5]:(f=d.map(e=>(0,$.jsx)(T,{value:e,children:i.setupAuthModes[e]},e)),t[4]=i.setupAuthModes,t[5]=f);let p;t[6]!==a||t[7]!==n.mode||t[8]!==i.setupAuthModes?(p=a||n.mode===`existing`?(0,$.jsx)(T,{value:`existing`,children:i.setupAuthModes.existing}):null,t[6]=a,t[7]=n.mode,t[8]=i.setupAuthModes,t[9]=p):p=t[9];let m;t[10]!==n.mode||t[11]!==i.setupAuthLabel||t[12]!==u||t[13]!==f||t[14]!==p?(m=(0,$.jsxs)(w,{"aria-label":s,className:c,value:l,onChange:u,children:[f,p]}),t[10]=n.mode,t[11]=i.setupAuthLabel,t[12]=u,t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]!==i.setupAuthLabel||t[17]!==m?(h=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[o,m]}),t[16]=i.setupAuthLabel,t[17]=m,t[18]=h):h=t[18];let g;t[19]!==n.mode||t[20]!==i.setupAuthAutoHint?(g=n.mode===`auto`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupAuthAutoHint}):null,t[19]=n.mode,t[20]=i.setupAuthAutoHint,t[21]=g):g=t[21];let _;t[22]!==n.mode||t[23]!==i.setupAuthOAuthHint?(_=n.mode===`oauth`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupAuthOAuthHint}):null,t[22]=n.mode,t[23]=i.setupAuthOAuthHint,t[24]=_):_=t[24];let v;t[25]!==n.mode||t[26]!==i.setupExistingHint?(v=n.mode===`existing`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupExistingHint}):null,t[25]=n.mode,t[26]=i.setupExistingHint,t[27]=v):v=t[27];let y;t[28]!==n.mode||t[29]!==n.token||t[30]!==r||t[31]!==i?(y=n.mode===`bearer`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(zn,{value:n.token,onChange:e=>r({token:e}),label:i.setupTokenLabel,t:i,required:!0}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupTokenHint})]}):null,t[28]=n.mode,t[29]=n.token,t[30]=r,t[31]=i,t[32]=y):y=t[32];let b;t[33]!==n.apiKey||t[34]!==n.headerName||t[35]!==n.mode||t[36]!==r||t[37]!==i?(b=n.mode===`apiKey`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i.setupApiKeyHeader,(0,$.jsx)(`input`,{className:Y(Rn,`mt-1.5`),placeholder:`x-api-key`,value:n.headerName,required:!0,onChange:e=>r({headerName:e.target.value})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupApiKeyHint}),(0,$.jsx)(zn,{value:n.apiKey,onChange:e=>r({apiKey:e}),label:`API Key`,t:i,required:!0})]}):null,t[33]=n.apiKey,t[34]=n.headerName,t[35]=n.mode,t[36]=r,t[37]=i,t[38]=b):b=t[38];let x;t[39]!==n.customHeaders||t[40]!==n.mode||t[41]!==r||t[42]!==i?(x=n.mode===`headers`?(0,$.jsx)(Vn,{headers:n.customHeaders,onChange:e=>r({customHeaders:e}),t:i}):null,t[39]=n.customHeaders,t[40]=n.mode,t[41]=r,t[42]=i,t[43]=x):x=t[43];let S;return t[44]!==h||t[45]!==g||t[46]!==_||t[47]!==v||t[48]!==y||t[49]!==b||t[50]!==x?(S=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[h,g,_,v,y,b,x]}),t[44]=h,t[45]=g,t[46]=_,t[47]=v,t[48]=y,t[49]=b,t[50]=x,t[51]=S):S=t[51],S}function Un(e){let t=(0,pt.c)(8),{label:n,children:r,hint:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`span`,{children:n}),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=i?(0,$.jsx)(`span`,{className:`block text-xs font-normal text-fg-muted`,children:i}):null,t[2]=i,t[3]=o);let s;return t[4]!==r||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`label`,{className:`block space-y-1.5 text-sm font-medium text-fg`,children:[a,r,o]}),t[4]=r,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Wn({row:e,t,onUpdate:n}){let[r,i]=(0,Q.useState)(()=>Lt(e.envJson?JSON.parse(e.envJson):void 0)),[a,o]=(0,Q.useState)(!1),s=[];try{s=zt(e.argsText)??[]}catch{}let c=e=>n({argsText:JSON.stringify(e)});return(0,$.jsxs)(`div`,{"data-field":`commandOptions`,className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.argsLabel}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,onClick:()=>o(e=>!e),children:a?t.setupArgsRows:t.setupArgsPaste})]}),a?(0,$.jsx)(Un,{label:t.setupArgsPaste,hint:t.argsHint,children:(0,$.jsx)(`input`,{className:Rn,value:e.argsText,onChange:e=>n({argsText:e.target.value})})}):s.map((e,n)=>(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`input`,{className:Rn,"aria-label":`${t.argsLabel} ${n+1}`,value:e,onChange:e=>c(s.map((t,r)=>r===n?e.target.value:t))}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,"aria-label":t.setupRemoveArg,onClick:()=>c(s.filter((e,t)=>t!==n)),children:(0,$.jsx)(ue,{className:`size-4`,"aria-hidden":!0})})]},n)),a?null:(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,onClick:()=>c([...s,``]),children:[(0,$.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),t.setupAddArg]})]}),(0,$.jsx)(Vn,{environment:!0,headers:r,t,onChange:e=>{i(e),n({envEntries:e,envJson:JSON.stringify(It(e)??{})})}})]})}function Gn(e){let t=(0,pt.c)(15),{row:n,t:r,onUpdate:i,variant:a,showOAuth:o,idReadOnly:s}=e,c=a===void 0?`all`:a,l=o!==void 0&&o,u=s!==void 0&&s,d=c!==`advanced`,f=c!==`basic`,p;t[0]!==d||t[1]!==i||t[2]!==n||t[3]!==r?(p=d?(0,$.jsxs)($.Fragment,{children:[n.transport===`stdio`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Un,{label:`${r.commandLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`command`,className:Rn,value:n.command,required:!0,onChange:e=>i({command:e.target.value})})}),(0,$.jsx)(Wn,{row:n,t:r,onUpdate:i})]}):(0,$.jsx)(Un,{label:`${r.urlLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`url`,className:Rn,value:n.url,placeholder:`https://example.com/mcp`,required:!0,onChange:e=>i({url:e.target.value})})}),(0,$.jsx)(Un,{label:r.setupNameLabel,hint:r.setupNameHint,children:(0,$.jsx)(`input`,{className:Rn,value:n.displayName??``,placeholder:r.setupNamePlaceholder,onChange:e=>i({displayName:e.target.value})})})]}):null,t[0]=d,t[1]=i,t[2]=n,t[3]=r,t[4]=p):p=t[4];let m;t[5]!==f||t[6]!==u||t[7]!==i||t[8]!==n||t[9]!==l||t[10]!==r?(m=f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Un,{label:r.serverIdLabel,hint:r.setupIdHint,children:(0,$.jsx)(`input`,{className:Rn,readOnly:u,value:n.id,onChange:e=>i({id:e.target.value}),placeholder:r.serverIdPlaceholder})}),n.transport===`stdio`?(0,$.jsx)(Un,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:Rn,value:n.cwd,onChange:e=>i({cwd:e.target.value})})}):null,n.transport!==`stdio`&&l?(0,$.jsx)(Un,{label:r.oauthClientIdLabel,hint:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:Rn,value:n.oauthClientId,onChange:e=>i({oauthClientId:e.target.value})})}):null,(0,$.jsx)(Un,{label:r.exposureLabel,hint:r.setupExposureHint,children:(0,$.jsx)(w,{"aria-label":r.exposureLabel,className:Rn,value:n.exposure,onChange:e=>i({exposure:e.target.value}),children:[`codemode`,`deferred`,`direct`,`hidden`].map(e=>(0,$.jsx)(T,{value:e,children:r.exposureLabels[e]},e))})}),(0,$.jsx)(Un,{label:r.requestTimeoutLabel,children:(0,$.jsx)(ft,{allowEmpty:!0,type:`number`,min:1,className:Rn,value:n.timeout??``,placeholder:r.setupDefaultTimeout,onChange:e=>i({timeout:e.target.value?Number(e.target.value):void 0})})})]}):null,t[5]=f,t[6]=u,t[7]=i,t[8]=n,t[9]=l,t[10]=r,t[11]=m):m=t[11];let h;return t[12]!==p||t[13]!==m?(h=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[p,m]}),t[12]=p,t[13]=m,t[14]=h):h=t[14],h}function Kn(e,t){let n=e;if(n?.status===429)return t.setupRateLimited;if(n?.status===401)return t.setupGatewayUnauthorized;if(n?.status===404||n?.status===409)return t.setupConflict;if(n?.status&&n.status>=500)return t.setupGatewayCheckFailed;let r={command_missing:t.setupCommandMissing,connection_refused:t.setupConnectionRefused,host_not_found:t.setupHostNotFound,timeout:t.setupTimedOut,access_denied:t.setupAccessDenied,network:t.setupServiceNetworkFailed,tls:t.setupTlsFailed,invalid_response:t.setupInvalidResponse,not_found:t.setupEndpointNotFound,rate_limited:t.setupServiceRateLimited,configuration:t.setupInvalidConfig};if(n?.errorCode&&Object.hasOwn(r,n.errorCode))return r[n.errorCode];let i=e instanceof Error?e.message:typeof e==`string`?e:n?.error??``;return/ENOENT|command not found|executable.{0,30}not found/i.test(i)?t.setupCommandMissing:/ECONNREFUSED|connection refused/i.test(i)?t.setupConnectionRefused:/ENOTFOUND|EAI_AGAIN|could not resolve/i.test(i)?t.setupHostNotFound:/timeout|timed out/i.test(i)?t.setupTimedOut:/fetch failed|failed to fetch|network error|NetworkError/i.test(i)?n?.error===void 0?t.setupGatewayNetworkFailed:t.setupServiceNetworkFailed:/\b(?:401|403)\b|unauthorized|forbidden|permission denied/i.test(i)?t.setupAccessDenied:t.setupCheckFailed}function qn(e,t){return JSON.stringify({id:e.id,config:Jt(Pn(e,t))})}function Jn(e,t){try{return qn(e,t)}catch{return JSON.stringify({row:e,auth:t})}}function Yn(e){let{t,cs:n}=e,r=c(e=>e.language),i=(0,Q.useId)(),[a,o]=(0,Q.useState)(e.initialRow),[s,l]=(0,Q.useState)(()=>Nn(e.initialRow)),[u,p]=(0,Q.useState)(`idle`),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(),[k,A]=(0,Q.useState)(),[j,M]=(0,Q.useState)(),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(!1),[L,z]=(0,Q.useState)(``),[B,ee]=(0,Q.useState)(``),[H,U]=(0,Q.useState)([]),[W,te]=(0,Q.useState)(`0`),[G,ne]=(0,Q.useState)(0),[re,ie]=(0,Q.useState)(``),[K,ae]=(0,Q.useState)(!1),[oe,se]=(0,Q.useState)(!1),q=e.mode===`edit`,[ce,le]=(0,Q.useState)(``),J=(0,Q.useRef)(void 0),[ue]=(0,Q.useState)(()=>Jn(e.initialRow,Nn(e.initialRow))),de=(0,Q.useRef)(e.mode===`edit`?e.initialRow.id:``),pe=(0,Q.useRef)(void 0),me=(0,Q.useRef)(void 0),he=(0,Q.useRef)(void 0),X=(0,Q.useRef)(null),ge=(0,Q.useRef)(``),_e=(0,Q.useRef)(!0),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(null),be=(0,Q.useRef)(null),xe=(0,Q.useRef)(null),Se=(0,Q.useRef)(e.onSaved);Se.current=e.onSaved;let Ce=j?.state===`starting`||j?.state===`authorizing`,we=u!==`idle`||Ce,Te=ue!==Jn(a,s),Ee=a.extra.enabled===!1,De=!S&&!b&&(Te||!!L.trim());(0,Q.useEffect)(()=>(_e.current=!0,()=>{_e.current=!1,pe.current?.abort(),X.current?.close(),J.current&&Qt(J.current).catch(()=>{})}),[]),(0,Q.useEffect)(()=>{if(!De)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[De]),(0,Q.useEffect)(()=>{if(!E)return;let e=be.current?.querySelector(`[data-field="${E.field}"]`),t=e?.closest(`details`);t&&(t.open=!0);let n=e?.querySelector(`input,button,textarea`)??e;return n?.setAttribute(`aria-invalid`,`true`),n?.setAttribute(`aria-describedby`,i),E.focus!==!1&&(n??xe.current)?.focus(),()=>{n?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-describedby`)}},[E,i]),(0,Q.useEffect)(()=>{if(!j||!Ce)return;let e=new AbortController;me.current=e;let n;async function r(){try{let n=await tn(J.current,e.signal);if(e.signal.aborted||(M(n),n.authorizationUrl&&ge.current!==n.authorizationUrl&&(ge.current=n.authorizationUrl,window.electronAPI?.shell?.openExternalUrl?!(await window.electronAPI.shell.openExternalUrl(n.authorizationUrl)).ok&&!e.signal.aborted&&y(t.oauthOpenFailed):X.current&&!X.current.closed&&X.current.location.replace(n.authorizationUrl)),e.signal.aborted))return;if(n.state===`connected`){he.current=void 0,X.current?.close(),A({state:`connected`,toolCount:n.toolCount}),y(``);return}if(n.state===`error`||n.state===`cancelled`){he.current=void 0,X.current?.close(),y(n.state===`cancelled`?t.setupCancelled:t.setupAuthFailed),/client.{0,20}(id|registration)|register|registration/i.test(n.error??``)&&P(!0);return}}catch{if(e.signal.aborted)return;Oe(),X.current?.close(),y(t.setupAuthFailed);return}n=setTimeout(()=>void r(),1200)}return r(),()=>{e.abort(),clearTimeout(n)}},[j?.id,Ce,t.oauthOpenFailed,t.setupCancelled,t.setupAuthFailed]);function Oe(){pe.current?.abort(),me.current?.abort(),J.current&&Qt(J.current).catch(()=>{}),J.current=void 0,le(``),ae(!1),A(void 0),M(void 0),y(``),D(void 0)}function ke(e){o(t=>({...t,...e})),Oe()}function Ae(e){l(t=>({...t,...e})),Oe()}function je(){u===`saving`||Ce||(u===`checking`&&(Oe(),p(`idle`)),De?se(!0):e.onClose())}function Me(){try{U(Gt(L)),te(`0`),ee(``)}catch{ee(t.setupImportError),U([])}}function Ne(){let t=H[Number(W)];if(!t)return;let n={...t,id:de.current||t.id,clientKey:e.initialRow.clientKey,extra:{...t.extra,...de.current?{enabled:a.extra.enabled}:{}}};o(n),l(Nn(n)),Oe(),ne(e=>e+1),I(!1),z(``),U([])}function Pe(e){function n(e,t){return D({field:e,message:t}),!1}if(e.transport!==`stdio`){try{e.url=Wt(e.url)}catch{return n(`url`,t.setupAddressInvalid)}if(s.mode===`bearer`&&!s.token.trim().replace(/^Bearer\s*/i,``)||s.mode===`apiKey`&&(!s.apiKey.trim()||!s.headerName.trim()))return n(`auth`,t.setupCredentialRequired);if(Fn(e.headers)>=0)return n(`auth`,t.setupHeaderInvalid);if(s.mode===`oauth`&&e.headers.some(e=>e.key.trim().toLowerCase()===`authorization`))return n(`auth`,t.setupOAuthHeaderConflict);if(s.mode===`headers`&&!e.headers.some(e=>e.key.trim()&&(e.value.trim()||e.reference)))return n(`auth`,t.setupCredentialRequired)}else if(!e.command.trim())return n(`command`,t.setupCommandRequired);if(e.timeout!==void 0&&(!Number.isFinite(e.timeout)||e.timeout<=0))return n(`advanced`,t.setupInvalidConfig);try{Jt(e)}catch(r){return n(e.transport===`stdio`?`commandOptions`:`advanced`,r instanceof Error&&r.message.startsWith(`Environment`)?t.setupEnvInvalid:t.setupInvalidConfig)}return!0}async function Fe(){y(``),p(`checking`),ge.current=``,window.electronAPI?.shell?.openExternalUrl||(X.current=window.open(`about:blank`,`_blank`),X.current&&(X.current.opener=null));try{let e=await en(J.current);if(!_e.current){X.current?.close(),J.current&&Qt(J.current).catch(()=>{});return}he.current=e.id,M(e)}catch{X.current?.close(),_e.current&&y(t.setupAuthFailed)}finally{_e.current&&p(`idle`)}}async function Ie(){let r=Pn(a,s);if(!Pe(r))return;let i=e.existingCustomServers.filter(t=>t.clientKey!==e.initialRow.clientKey&&t.id!==de.current),c=new Set([...e.managedServerIds,...i.map(e=>e.id)]);if(r.id=de.current||r.id.trim()||Ut(r,c),!/^[a-zA-Z0-9_-]+$/.test(r.id)||[...c].some(e=>e.replace(/-/g,`_`)===r.id.replace(/-/g,`_`))){D({field:`advanced`,message:n.duplicateServerId});return}Oe(),p(`checking`);let l=new AbortController;pe.current=l;try{let n=await Xt(r,de.current||void 0,e.initialRow.extra,l.signal);if(!_e.current||l.signal.aborted){Qt(n.id).catch(()=>{});return}J.current=n.id,o(r),le(Jn(r,s));let i=await Zt(n.id,l.signal);if(!_e.current||l.signal.aborted)return;A(i),i.state===`error`&&y(Kn(i,t))}catch(e){_e.current&&!l.signal.aborted&&y(e.status===409?t.setupConflict:Kn(e,t))}finally{_e.current&&pe.current===l&&p(`idle`)}}async function Le(e=!1){if(!(!J.current||k?.state!==`connected`||ce!==Jn(a,s))){p(`saving`),y(``);try{let t=await $t(J.current,e);J.current=void 0,await Se.current().catch(()=>{}),t?.reloadRequired?x(!0):(e&&o(e=>({...e,extra:{...e.extra,enabled:!0}})),C(!0))}catch(e){let n=e.status;n===404||n===409?(Oe(),y(t.setupConflict)):y(t.setupSaveFailed)}finally{_e.current&&p(`idle`)}}}async function Re(){me.current?.abort();let e=J.current;he.current=void 0,M(void 0),X.current?.close(),y(t.setupCancelled),p(`checking`);try{e&&await nn(e)}catch{_e.current&&(Oe(),y(t.setupCancelled))}finally{_e.current&&p(`idle`)}}async function ze(){j?.authorizationUrl&&(window.electronAPI?.shell?.openExternalUrl?(await window.electronAPI.shell.openExternalUrl(j.authorizationUrl)).ok||y(t.oauthOpenFailed):window.open(j.authorizationUrl,`_blank`,`noopener,noreferrer`))}async function Be(){if(j)try{await rn(J.current,re),ie(``),y(``)}catch{y(t.setupRedirectInvalid)}}let Ve=!!J.current&&ce===Jn(a,s)&&(s.mode===`oauth`||s.mode===`auto`&&k?.state===`oauth_required`)&&k?.state!==`connected`,He=/^(?:https?:\/\/)?(?:localhost|127\.0\.0\.1|\[::1\])(?=[:/]|$)/i.test(a.url.trim()),Ue=H[Number(W)];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_,{open:e.open,onOpenChange:e=>{e||je()},children:(0,$.jsxs)(m,{children:[(0,$.jsx)(d,{className:`fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(h,{ref:ve,tabIndex:-1,className:`fixed left-1/2 top-1/2 z-[60] flex h-[min(44rem,calc(100dvh-2rem))] w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,onOpenAutoFocus:e=>{e.preventDefault(),ve.current?.focus()},children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge p-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(g,{className:`font-semibold`,children:S?a.displayName||a.id:e.mode===`edit`?t.setupEditTitle:t.setupTitle}),(0,$.jsx)(f,{className:`mt-1 text-sm text-fg-muted`,children:t.setupHint})]}),(0,$.jsx)(`button`,{type:`button`,disabled:u===`saving`||Ce,onClick:je,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover disabled:opacity-50`,"aria-label":n.modalClose,children:(0,$.jsx)(fe,{className:`size-5`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5`,children:[S?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-success`,children:[(0,$.jsx)(O,{className:`size-4`,"aria-hidden":!0}),Ee?t.setupDisabled:r===`zh`?`连接已保存,可以开始使用`:`Connection saved and ready to use`]}),Ee?null:(0,$.jsx)(ot,{target:{kind:`mcp`,id:a.id,name:a.displayName||a.id},onStart:e.onClose})]}):F?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>I(!1),children:t.setupImportBack}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupImportEmpty}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[t.setupImport,(0,$.jsx)(`textarea`,{className:Y(Rn,`mt-1.5 min-h-40 font-mono text-xs`),value:L,placeholder:`{"mcpServers": {"docs": {"url": "https://example.com/mcp"}}}`,onChange:e=>{z(e.target.value),U([]),ee(``)}})]}),(0,$.jsx)(Z,{variant:`secondary`,disabled:!L.trim(),onClick:Me,children:t.setupImportPreview}),B?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:B}):null,Ue?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge p-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupImportScope}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium`,children:[t.setupImportChoose,(0,$.jsx)(w,{"aria-label":t.setupImportChoose,className:Y(Rn,`mt-1.5`),value:W,onChange:e=>te(e.target.value),children:H.map((e,t)=>(0,$.jsx)(T,{value:String(t),children:e.displayName||e.id||dn(e)},t))})]}),(0,$.jsxs)(`p`,{className:`break-all text-sm text-fg-muted`,children:[Ue.transport===`stdio`?t.setupUseCommand:t.setupUseUrl,` · `,dn(Ue)]})]}):null]}):(0,$.jsxs)(`form`,{ref:be,noValidate:!0,onBlurCapture:e=>{if(e.target instanceof HTMLInputElement&&e.target.dataset.field===`url`&&a.url.trim())try{Wt(a.url)}catch{D({field:`url`,message:t.setupAddressInvalid,focus:!1})}},onSubmit:e=>{e.preventDefault(),Ie()},children:[(0,$.jsxs)(`fieldset`,{disabled:we||b,className:`min-w-0 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)($e,{className:`flex gap-1`,role:`group`,"aria-label":t.transportLabel,children:[`streamable-http`,`sse`,`stdio`].map(e=>(0,$.jsx)(Z,{type:`button`,variant:a.transport===e?`secondary`:`ghost`,"aria-pressed":a.transport===e,onClick:()=>ke({transport:e}),children:e===`stdio`?t.setupUseCommand:e===`sse`?r===`zh`?`旧版 SSE`:`Legacy SSE`:t.setupUseUrl},e))}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,onClick:()=>I(!0),children:t.setupImport})]}),(0,$.jsx)(`div`,{children:(0,$.jsx)(Gn,{row:a,t,variant:`basic`,onUpdate:ke},`${a.transport}-${G}`)}),a.transport===`stdio`?null:(0,$.jsx)(`div`,{"data-field":`auth`,children:(0,$.jsx)(Hn,{allowExisting:!!a.extra.auth||a.headers.some(e=>!!e.reference),draft:s,onChange:Ae,t})}),E?(0,$.jsx)(`p`,{id:i,ref:xe,tabIndex:-1,role:`alert`,className:`text-sm text-danger`,children:E.message}):null,(0,$.jsxs)(`details`,{"data-field":`advanced`,className:`rounded-lg border border-edge p-3`,open:N,onToggle:e=>P(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:t.setupAdvanced}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsx)(Gn,{row:a,t,variant:`advanced`,idReadOnly:q,showOAuth:s.mode===`oauth`,onUpdate:ke}),a.transport!==`stdio`&&s.mode!==`headers`&&s.mode!==`existing`?(0,$.jsx)(Vn,{additional:!0,headers:s.additionalHeaders,onChange:e=>Ae({additionalHeaders:e}),t}):null]})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:a.transport===`stdio`?t.setupCommandHostHint:He?t.setupLocalhostHint:t.setupGatewayHint}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.setupTestNotice})]}),(0,$.jsx)(`button`,{type:`submit`,hidden:!0})]}),b?(0,$.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-fg`,children:t.setupReloadRequired}):null,!S&&!F&&!b?(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,"aria-live":`polite`,children:[u===`idle`?null:(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(V,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),u===`saving`?t.setupSaving:t.setupChecking]}),u===`idle`&&q&&!Te&&!k&&!v&&!Ce?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:Ee?t.setupDisabled:e.lastCheck?t.setupLastCheck.replace(`{{count}}`,String(e.lastCheck.toolCount)):t.setupSavedUnchecked}):null,k?.state===`connected`?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-success`,children:[(0,$.jsx)(O,{className:`size-4 shrink-0`,"aria-hidden":!0}),k.toolCount?t.setupConnected.replace(`{{count}}`,String(k.toolCount)):t.setupZeroTools]}),(0,$.jsx)(ot,{preview:!0,target:{kind:`mcp`,id:a.id,name:a.displayName||a.id}}),(0,$.jsx)(Z,{ref:ye,variant:`secondary`,onClick:()=>ae(!0),children:t.viewTools})]}):null,k?.state===`token_required`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.setupNeedsAuth}):null,k?.state===`auth_unknown`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:r===`zh`?`认证方式尚未确定。请核实服务接入说明,选择 Token 或已确认支持的 OAuth。`:`Authentication is undetermined. Check the integration guide and select a Token or verified OAuth method.`}):null,k?.state===`oauth_required`&&!Ce?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupOAuthRequired}):null,Ce?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge p-4`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(V,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),t.setupAuthorizing]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[j?.authorizationUrl?(0,$.jsxs)(Z,{variant:`secondary`,onClick:()=>void ze(),children:[(0,$.jsx)(R,{className:`size-4`,"aria-hidden":!0}),t.oauthOpenAuthorization]}):null,(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>void Re(),children:t.setupCancelAuth})]}),j?.acceptsRedirect?(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent-fg`,children:t.setupRemoteFallback}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.setupRedirectHint}),(0,$.jsxs)(`label`,{className:`mt-2 block text-sm`,children:[t.setupRedirectLabel,(0,$.jsx)(`input`,{className:Rn,value:re,onChange:e=>ie(e.target.value)})]}),(0,$.jsx)(Z,{className:`mt-2`,disabled:!re.trim(),onClick:()=>void Be(),children:t.setupContinue})]}):null]}):null,v?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-1 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-danger`,children:v}),v!==t.setupSaveFailed&&u!==`saving`?(0,$.jsx)(`p`,{className:`text-fg-muted`,children:t.setupTestFailure}):null]}):null]}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge p-4`,children:[(0,$.jsx)(Z,{variant:`secondary`,disabled:u===`saving`||Ce,onClick:je,children:S||q||b?t.setupClose:n.modalCancel}),S||b?null:F?(0,$.jsx)(Z,{variant:`primary`,disabled:!Ue,onClick:Ne,children:t.setupImportApply}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{variant:k?.state===`connected`?`secondary`:`primary`,disabled:we,onClick:()=>Ve?void Fe():void Ie(),children:Ve?t.setupSignIn:t.setupTestConnection}),k?.state===`connected`&&ce===Jn(a,s)?(0,$.jsxs)($.Fragment,{children:[Ee?(0,$.jsx)(Z,{variant:`secondary`,disabled:we,onClick:()=>void Le(!0),children:t.setupEnableSave}):null,(0,$.jsx)(Z,{variant:`primary`,disabled:we,"aria-busy":we,onClick:()=>void Le(),children:q?t.setupSaveOnly:t.setupAddConnection})]}):null]})]})]})]})}),(0,$.jsx)(et,{open:oe,title:t.setupUnsavedTitle,description:t.setupUnsavedHint,confirmLabel:t.setupDiscard,cancelLabel:t.setupKeepEditing,onCancel:()=>se(!1),onConfirm:e.onClose,overlayClassName:`z-[70]`,contentClassName:`z-[70]`}),K?(0,$.jsx)(cn,{draftId:J.current,serverId:a.id,displayName:a.displayName,returnFocusTo:ye.current,t,onClose:()=>ae(!1)}):null]})}var Xn=`recommended`,Zn=`builtin`,Qn=`composio`,$n=`xopc-store`;function er(e,t=`en`){return e==="default"&&t.startsWith(`zh`)?Xn:Zn}function tr(e,t){let n=e.connectorManifest;if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=n;if(r.contractVersion!==1||r.id!==e.name)return null;let i=r.runtime,a=r.auth;if(!i||typeof i!=`object`||Array.isArray(i)||!a||typeof a!=`object`||Array.isArray(a))return null;let o=i,s=a;if(o.type!==`mcp`||typeof o.serverId!=`string`)return null;let c=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(String(r.category??``))?r.category:`custom`,l=s.mode===`oauth`?{mode:`oauth`,...typeof s.clientId==`string`?{clientId:s.clientId}:{}}:s.mode===`apiKey`?{mode:`apiKey`}:{mode:`none`},u=e.localizations?.[t===`zh`?`zh-CN`:`en`];return{id:e.name,version:e.latestVersion??`store`,displayName:u?.displayName??(typeof r.displayName==`string`?r.displayName:e.name),description:u?.description??(typeof r.description==`string`?r.description:e.description),category:c,kind:`mcp`,source:`store`,...e.branding?.iconUrl?{branding:{logoUrl:e.branding.iconUrl,source:`registry`}}:{},capabilities:Array.isArray(r.capabilities)?r.capabilities.filter(e=>typeof e==`string`):[],tags:Array.isArray(r.tags)?r.tags.filter(e=>typeof e==`string`):[`store`],auth:l,setup:r.setup&&typeof r.setup==`object`&&!Array.isArray(r.setup)?r.setup:{},runtime:{type:`mcp`,serverId:o.serverId}}}function nr(e){return v(e.map(e=>({connector:e,service:{id:e.id,source:e.source===`builtin`?`builtin-connector`:e.source===`store`?`store-connector`:`registry-connector`}})),`en`).map(e=>e.connector)}function rr(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/user-model`}function ir({embedded:e=!1,onHeaderActionChange:t}){let n=Qe().filter(mn),r=c(e=>e.language),o=u(r),l=o.connectorsSettings,d=o.mcpSettings,f=s(e=>e.conversationId),p=!!f,m=a(),[h,g]=i(),_=h.get(`understanding`)===`1`,v=rr(h.get(`returnTo`)),S=!!h.get(`returnTo`)&&!_,C=h.get(`tab`),[w,T]=(0,Q.useState)(!_&&C===`connected`?`connected`:`discover`),{data:D}=me(p&&w===`discover`&&!_?[`service-recommendations`,r]:null,()=>y(r),{revalidateOnFocus:!1}),O=(0,Q.useMemo)(()=>new Set(D?.items.filter(e=>e.service?.source===`store-plugin`).map(e=>b(e.id))??[]),[D]),k=(0,Q.useRef)(!1),[A,F]=(0,Q.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[I,L]=(0,Q.useState)(!1),[R,z]=(0,Q.useState)(!1),[B,ee]=(0,Q.useState)(1),[H,U]=(0,Q.useState)(void 0),[W,te]=(0,Q.useState)(``),[G,ne]=(0,Q.useState)(_||S?h.get(`connector`)??``:``),[K,ae]=(0,Q.useState)(er(_?`understanding`:`default`,r)),[oe,se]=(0,Q.useState)(`name`),[q,ce]=(0,Q.useState)(_?`understand`:`all`),[le,J]=(0,Q.useState)(null),[ue,de]=(0,Q.useState)(null),[fe,pe]=(0,Q.useState)(null),[he,ge]=(0,Q.useState)(null),[_e,ve]=(0,Q.useState)(null),[ye,be]=(0,Q.useState)(null),{data:xe,mutate:Se}=X(p),Ce=xe?.payload?.config,we=(0,Q.useMemo)(()=>Ce===void 0?null:qt(Ce),[Ce]),Te=we?.servers??[],Ee=A.instances.length+Te.length+n.length,[De,Oe]=(0,Q.useState)({});(0,Q.useEffect)(()=>{if(Oe({}),!p||!Ce)return;let e=new AbortController;return on(e.signal).then(t=>{e.signal.aborted||Oe(t)}).catch(()=>{}),()=>e.abort()},[p,Ce]);let ke=(0,Q.useCallback)(async()=>{if(!f){F({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}F(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([Ne(),Ae()]);F(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){F({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[f]);(0,Q.useEffect)(()=>{ke()},[ke]),(0,Q.useEffect)(()=>{k.current||A.loading||p&&!we||(T(_?`discover`:Ee>0?`connected`:`discover`),k.current=!0)},[p,Ee,we,_,A.loading]),(0,Q.useEffect)(()=>{ae(e=>e===`builtin`||e===`recommended`?er(_?`understanding`:`default`,r):e)},[r,_]);let je=(0,Q.useCallback)(e=>{k.current=!0,T(e)},[]),Me=(0,Q.useMemo)(()=>[{id:Qn,displayName:l.composioSourceName},{id:$n,displayName:l.storeSourceName}],[l.composioSourceName,l.storeSourceName]),Pe=(0,Q.useCallback)(async e=>{if(!p||K===`builtin`||K===`recommended`){F(e=>({...e,registryCatalog:[]})),ee(1),U(void 0);return}let t=G.trim(),n=Math.max(e?.page??1,1),i=e?.append??!1,a=K===`all`?Me:Me.filter(e=>e.id===K);if(a.length!==0){L(!0),i?F(e=>({...e,error:null})):(ee(1),U(void 0),F(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(a.map(async e=>{if(e.id===`composio`){let e=await Be({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let i=await Re({q:t||void 0,page:n,pageSize:24,sort:oe===`source`?`newest`:`downloads`});return{connectors:i.items.flatMap(e=>{let t=tr(e,r);return t?[t]:[]}),totalPages:i.meta.totalPages}})),o=nr(e.flatMap(e=>e.connectors)),s=Math.max(1,...e.map(e=>e.totalPages??1));ee(n),U(s),F(e=>({...e,registryCatalog:i?nr([...e.registryCatalog,...o]):o}))}catch(e){F(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{L(!1)}}},[oe,G,K,p,Me,r]);(0,Q.useEffect)(()=>{if(w!==`discover`||A.loading)return;if(K===`builtin`||K===`recommended`){F(e=>({...e,registryCatalog:[]})),ee(1),U(void 0);return}let e=window.setTimeout(()=>{Pe()},G.trim()?350:0);return()=>window.clearTimeout(e)},[G,K,Pe,A.loading,w]);let Fe=(0,Q.useMemo)(()=>new Set(A.instances.map(e=>e.connectorId)),[A.instances]),Ie=(0,Q.useMemo)(()=>new Map([...A.catalog,...A.registryCatalog].map(e=>[e.id,e])),[A.catalog,A.registryCatalog]);(0,Q.useEffect)(()=>{if(A.loading)return;let e=h.get(`connector`),t=h.get(`instance`);if(!e&&!t)return;let n=A.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)k.current=!0,te(``),pe(n.instanceId),ge(n),T(`connected`);else if(e){let t=Ie.get(e);if(!t)return;k.current=!0,ae(er(_?`understanding`:`default`,r)),ne(``),de(t),T(`discover`)}let i=new URLSearchParams(h);i.delete(`connector`),i.delete(`instance`),i.set(`tab`,n?`connected`:`discover`),g(i,{replace:!0})},[Ie,_,r,h,g,A.instances,A.loading]);let Le=(0,Q.useCallback)(async e=>{z(!0),F(e=>({...e,error:null}));try{let t=await Ve(e);J(re(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions}))}catch(e){F(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{z(!1)}},[]);(0,Q.useEffect)(()=>{let e=h.get(`storeConnector`);if(!p||!e)return;let t=new URLSearchParams(h);t.delete(`storeConnector`),g(t,{replace:!0}),Le(e)},[p,h,g,Le]);let ze=(0,Q.useMemo)(()=>new Set(A.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[A.instances]),He=(0,Q.useCallback)(async e=>{let t=await sn(e);await Se(),await ke(),t.reloadRequired&&F(e=>({...e,error:d.setupReloadRequired}))},[ke,Se,d.setupReloadRequired]),Ue=(0,Q.useCallback)(()=>{be({mode:`add`,row:Mn(Te,ze)})},[Te,ze]),We=Ze(e=>e.setPageHeader),Ge=Ze(e=>e.clearPageHeader),Ke=(0,Q.useMemo)(()=>({searchLabel:w===`connected`?l.connectedSearchPlaceholder:l.discoverSearchPlaceholder,search:(0,$.jsx)(lt,{value:w===`connected`?W:G,onChange:w===`connected`?te:ne,placeholder:w===`connected`?l.connectedSearchPlaceholder:l.discoverSearchPlaceholder}),secondary:(0,$.jsx)(Mt,{onRefresh:w===`connected`&&p?ke:void 0,refreshing:A.loading,refreshLabel:l.refreshConnections,onBrowseCatalog:()=>je(`discover`),onAddCustomServer:Ue,addLabel:l.addConnection,browseLabel:l.addFromCatalog,customLabel:l.addCustomServerAdvanced,serviceLabel:r.startsWith(`zh`)?`应用连接服务`:`Connection service`,moreActionsLabel:o.capabilitiesHub.moreActions})}),[W,l,G,p,r,ke,o.capabilitiesHub.moreActions,Ue,je,A.loading,w]);(0,Q.useLayoutEffect)(()=>e?(t?.(Ke),()=>t?.(null)):(We({startExtra:null,main:(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:l.title})}),end:(0,$.jsx)(ut,{contribution:Ke})}),()=>Ge()),[Ge,l.title,e,Ke,t,We]);let qe=(0,Q.useMemo)(()=>A.instances.map(e=>({instance:e,value:wt(e,Ie.get(e.connectorId))})),[Ie,A.instances]),Je=(0,Q.useMemo)(()=>new Map(qe.map(({instance:e,value:t})=>[e.instanceId,t])),[qe]),Ye=(0,Q.useMemo)(()=>A.instances.filter(e=>N(e,W)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Je.get(e.instanceId)?.state??`checking`,i=Je.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[W,Je,A.instances]),et=(0,Q.useMemo)(()=>Ye.filter(e=>Je.get(e.instanceId)?.state===`needs_setup`),[Je,Ye]),tt=(0,Q.useMemo)(()=>Ye.filter(e=>Je.get(e.instanceId)?.state!==`needs_setup`),[Je,Ye]),nt=(0,Q.useMemo)(()=>Te.filter(e=>P(e,W)),[W,Te]),rt=(0,Q.useMemo)(()=>{let e=W.trim().toLowerCase();return n.filter(t=>[t.name,t.description,...(t.setup?.authorizations??[]).map(e=>e.title),...(t.components?.mcp??[]).map(e=>e.name)].filter(Boolean).join(` `).toLowerCase().includes(e))},[W,n]),it=Ye.length+nt.length+rt.length,at=(0,Q.useMemo)(()=>A.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&j(e)),[A.catalog]),ot=(0,Q.useMemo)(()=>K===`recommended`?[]:K===`builtin`?at:K===`all`?nr([...at,...A.registryCatalog]):A.registryCatalog,[at,K,A.registryCatalog]),ct=(0,Q.useMemo)(()=>{let e=_?ot.filter(e=>e.understanding?.mode===`activity`):nr(ot).filter(e=>!O.has(b(e.id)));return M(q===`all`?e:e.filter(e=>St(e).includes(q)),G,oe)},[oe,G,ot,_,q,O]),dt=(0,Q.useMemo)(()=>xt.filter(e=>ot.some(t=>St(t).includes(e))),[ot]);(0,Q.useEffect)(()=>{q!==`all`&&!dt.includes(q)&&ce(`all`)},[dt,q]);let ft=w===`discover`&&K!==`builtin`&&!!(H&&B<H),pt=(0,Q.useMemo)(()=>A.instances.find(e=>e.instanceId===fe)??he,[fe,he,A.instances]),ht=(0,Q.useMemo)(()=>[{value:Xn,label:r===`zh`?`推荐服务`:`Recommended services`},{value:`all`,label:l.discoverSourceAll},{value:Zn,label:l.discoverSourceBuiltin},...Me.map(e=>({value:e.id,label:e.displayName}))],[l.discoverSourceAll,l.discoverSourceBuiltin,Me,r]),vt=[{id:`connected`,label:l.tabConnected,count:Ee},{id:`discover`,label:l.tabDiscover}];return(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:Y(`mx-auto flex w-full max-w-7xl flex-col gap-6 px-4 sm:px-6 lg:px-8`,e?`pb-7 pt-3 lg:pb-9 lg:pt-4`:`py-7 lg:py-9`),children:[p?null:(0,$.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:l.tokenHint}),_?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:l.understandingSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:l.understandingSetupHint})]}),(0,$.jsx)(Z,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>m(v),children:l.understandingSetupDone})]}):null,S?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:l.recoverySetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:l.recoverySetupHint})]}),(0,$.jsx)(Z,{type:`button`,variant:`secondary`,className:`min-h-11 shrink-0`,onClick:()=>m(v),children:l.recoverySetupDone})]}):null,(0,$.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,$.jsx)(Xe,{items:vt,activeTab:w,onChange:je,ariaLabel:l.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),A.error?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:A.error}):null,w===`connected`&&p?(0,$.jsx)(`div`,{className:`flex flex-col gap-6`,children:A.loading?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":l.loading,children:gt.slice(0,3).map(e=>(0,$.jsx)(bt,{},e))}):Ee===0?(0,$.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.connectionsEmpty}),(0,$.jsx)(Z,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>je(`discover`),children:l.addFromCatalog})]}):it===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:l.connectionsSearchEmpty}):(0,$.jsxs)(`div`,{className:`space-y-6`,children:[et.length?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:l.needsAttentionTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-amber-700 dark:text-amber-300`,children:et.length})]}),(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:et.map(e=>(0,$.jsx)(jn,{instance:e,definition:Ie.get(e.connectorId),highlighted:e.instanceId===_e,onOpenDetails:e=>{ve(null),pe(e.instanceId),ge(e)},t:l},e.instanceId))})]}):null,tt.length||rt.length?(0,$.jsx)(`section`,{children:(0,$.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[tt.map(e=>(0,$.jsx)(jn,{instance:e,definition:Ie.get(e.connectorId),highlighted:e.instanceId===_e,onOpenDetails:e=>{ve(null),pe(e.instanceId),ge(e)},t:l},e.instanceId)),rt.map(e=>(0,$.jsx)(hn,{extension:e,language:r,onOpen:()=>m(st(e.pluginId,`connections`,e.authorizationStatus===`required`))},e.id))]})}):null,nt.length||!W.trim()?(0,$.jsx)(pn,{servers:nt,lastChecks:De,t:d,cs:l,onAdd:Ue,onEdit:e=>be({mode:`edit`,row:structuredClone(e)}),onRemove:He}):null]})}):null,w===`discover`&&p?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[_?null:(0,$.jsx)($e,{className:`flex min-w-0 flex-1 basis-80 flex-wrap gap-2`,role:`group`,"aria-label":l.taskFilterAria,indicatorClassName:`rounded-lg bg-surface-active`,children:[`all`,...dt].map(e=>(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,q===e?`border-accent/40 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-pressed":q===e,onClick:()=>ce(e),children:e===`all`?l.taskAll:l.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:Y(`ml-auto grid w-full gap-2 sm:flex sm:w-auto sm:justify-end`,_?`grid-cols-1`:`grid-cols-2`),children:[_?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(E,{value:K,options:ht,placeholder:l.discoverSourceAll,allowEmpty:!1,ariaLabel:l.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:ae})}),K===`recommended`?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(E,{value:oe,options:[{value:`name`,label:l.sortName},{value:`source`,label:l.sortSource}],placeholder:l.sortName,allowEmpty:!1,ariaLabel:l.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>se(e)})})]})]}),K===`recommended`?(0,$.jsx)(x,{layout:`cards`,initialCount:6,query:G,onChanged:async()=>{await ke(),await Se()}}):(A.loading||I)&&ct.length===0?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":l.loading,children:gt.map(e=>(0,$.jsx)(yt,{},e))}):ct.length===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:l.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[I?(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":l.loading,children:(0,$.jsx)(V,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:ct.map(e=>(0,$.jsx)(mt,{connector:e,installed:Fe.has(e.id)||_t(e,A.instances),onInstall:e=>{if(e.source===`store`){Le(e.id);return}J(re(e))},onOpenDetails:e.source===`store`?void 0:de,t:l},e.id))}),ft?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(Z,{type:`button`,variant:`secondary`,disabled:I||R,onClick:()=>void Pe({page:B+1,append:!0}),children:[I?(0,$.jsx)(V,{className:`size-4 animate-spin`}):null,l.loadMore]})}):null]})]}):null]}),le?(0,$.jsx)(ie,{draft:le,onChange:J,onClose:()=>J(null),t:l,onInstalled:async e=>{await ke(),await Se(),ve(e.instanceId),je(`connected`)}}):null,ue?(0,$.jsx)(Ot,{connector:ue,installed:Fe.has(ue.id)||_t(ue,A.instances),onClose:()=>de(null),onInstall:e=>J(re(e)),t:l}):null,pt?(0,$.jsx)(An,{instance:pt,definition:Ie.get(pt.connectorId),onClose:()=>{pe(null),ge(null)},onChanged:ke,t:l,mcp:d}):null,ye?(0,$.jsx)(Yn,{open:!0,mode:ye.mode,initialRow:ye.row,lastCheck:ye.mode===`edit`?De[ye.row.id]:void 0,existingCustomServers:Te,config:Ce,managedServerIds:ze,t:d,cs:l,onClose:()=>be(null),onSaved:async()=>{await Se(),await ke(),je(`connected`)}},`${ye.mode}-${ye.row.clientKey}`):null]})})}export{ir as ConnectorsPage};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/workspace-file-preview-dialog-NffP-UXC.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js","assets/locale-store-Dy1EByeG.js","assets/messages-BAnhwALN.js","assets/use-file-preview-expanded-BXXeXnT0.js","assets/preload-helper-Czpn1I53.js","assets/chunk-KS7C4IRE-CiwuuyV8.js","assets/createLucideIcon-DPHK1VkS.js","assets/app-window-DXFNqt_0.js","assets/check-DUBLcKHA.js","assets/chevron-down-ccbiQQz_.js","assets/copy-Dv6d4Dvw.js","assets/download-Dk-ZjtO6.js","assets/ellipsis-0k4rZLoy.js","assets/external-link-DjqjBmc3.js","assets/eye-CABVeTq0.js","assets/folder-open-CyzJ19I9.js","assets/link-2-D_ZKYUW7.js","assets/loader-circle-CifKLtgG.js","assets/markdown-view-BlxIaCCQ.js","assets/dist-CY7CS_D3.js","assets/es2015-DBLcMg5B.js","assets/dist-CxGUk8J-.js","assets/file-image-CDUPkZvG.js","assets/plus-Q2yW6OE7.js","assets/x-B_N4OPjy.js","assets/cn-0WouolD0.js","assets/bundle-mjs-rHxsej31.js","assets/app-link-DImAfVs5.js","assets/product-delivery-BFfqdKLe.js","assets/schemas-CCWMleym.js","assets/local-apps-DeqzkJiF.js","assets/copy-to-clipboard-HOJ79TWv.js","assets/xml-_d7dTN2Q.js","assets/mermaid-render-oOellPHt.js","assets/markdown-view-DG8DDkEA.css","assets/message-square-plus-XP0tGdlV.js","assets/minimize-2-DtOGrlpo.js","assets/paperclip-f1HujQY1.js","assets/pencil-DmIY3Oa-.js","assets/refresh-cw-BRlGaq2w.js","assets/rotate-cw-LIg3Am9S.js","assets/save-DRDABU--.js","assets/search-DA7gz22f.js","assets/skeleton-DzdOeGYz.js","assets/constants-DpkUgykJ.js","assets/session-api-BFiIYodK.js","assets/gateway-startup-retry-D6WPS0RW.js","assets/attachment-utils-core-BIOUBrpT.js","assets/interaction-BdhHBbYa.js","assets/composer-notifications-CqV6Xj-H.js","assets/activity-store-CQHh48Zf.js","assets/app-chrome-BeB4KgOf.js","assets/electron-env-DHOGevH3.js","assets/use-async-resource-BHFGZCY2.js","assets/sliding-tab-list-CmcrqRzN.js","assets/sliding-indicator-hwz0sx3h.js","assets/workspace-api-LghfbP5g.js","assets/files-BNL4kkSB.js","assets/index.module-Cd9ENXfk.js","assets/dist-ZrL34Ps4.js","assets/dist-BuHnPloF.js","assets/floating-ui.dom-seOukHzT.js","assets/share-link-dialog-C1t_HB6f.js","assets/popover-select-CLsphyzA.js","assets/dist-GJ8-1PAx.js","assets/settings-shell-dialog-layer-BU3UuiJr.js","assets/globe-DSSGFWFn.js","assets/button-Cc4hUNTt.js","assets/copy-text-row-CpiRzq4G.js","assets/right-workspace-store-HPw7Gw0n.js","assets/phone-workspace-store-Ltrevdsx.js","assets/theme-store-BaWep_o7.js","assets/middleware-Pd0e8Igk.js","assets/file-preview-surface-i5UOFnQF.js","assets/shares-api-Dm07CnXw.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{l as a,m as o,t as s,u as c}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as l,n as u,o as d}from"./locale-store-Dy1EByeG.js";import{t as f}from"./messages-BAnhwALN.js";import{a as p,i as m,n as h,o as g,r as _,s as v,t as y}from"./dist-CY7CS_D3.js";import{t as b}from"./calendar-clock-D-quYVPe.js";import{t as x}from"./check-DUBLcKHA.js";import{t as S}from"./chevron-down-ccbiQQz_.js";import{t as C}from"./chevron-right-BweFrslA.js";import{t as w}from"./circle-alert-BEjgurr2.js";import{t as T}from"./circle-check-C23XjkUj.js";import{t as E}from"./circle-pause-CN9jYH2s.js";import{t as D}from"./clock-3-DnrAnuyZ.js";import{t as O}from"./external-link-DjqjBmc3.js";import{t as k}from"./history-DXH_9jsE.js";import{M as A,t as j}from"./markdown-view-BlxIaCCQ.js";import{t as M}from"./message-circle-Badhj-4D.js";import{t as N}from"./paperclip-f1HujQY1.js";import{t as P}from"./plus-Q2yW6OE7.js";import{t as F}from"./refresh-cw-BRlGaq2w.js";import{t as I}from"./search-DA7gz22f.js";import{t as ee}from"./settings-2-D-csvaET.js";import{t as te}from"./sparkles-DHlfQFAF.js";import{t as L}from"./x-B_N4OPjy.js";import{t as R}from"./cn-0WouolD0.js";import{t as z}from"./skeleton-DzdOeGYz.js";import{i as B,s as V}from"./capabilities-DB713nRi.js";import{i as H}from"./vendor-swr-CdRzEUwF.js";import{S as U,b as W,c as G,g as K,h as q,m as ne,n as re,s as ie,v as ae,w as oe,y as se}from"./workspace-preview-store-Do31QQH5.js";import{t as J}from"./button-Cc4hUNTt.js";import{a as Y,i as ce,o as le,s as ue}from"./dist-GJ8-1PAx.js";import{a as de,i as fe,o as pe,r as me,s as he,t as ge}from"./composer-payload-handoff-Dc43dgSg.js";import{t as _e}from"./use-realtime-voice-C7iWQuUv.js";import{t as ve}from"./page-header-store-Bm8oxpFR.js";import{t as ye}from"./automation-api-DxBmyzp0.js";import{a as be,n as xe,t as Se}from"./use-composer-attachments-CO7XLI4x.js";import{t as Ce}from"./sliding-tab-list-CmcrqRzN.js";import{n as we,r as Te}from"./voice-input-shortcut-events-CEeFBhp3.js";import{n as Ee}from"./date-formatters-DukWSVwc.js";import{a as De,i as Oe,r as ke,t as Ae}from"./routine-panel-9UC3NU5V.js";import{r as je,t as Me}from"./task-result-evidence-CSJeB9AH.js";import{n as Ne}from"./tab-completion-input-CxtEp0aP.js";var X=n(),Z=e(t(),1);function Pe(e,t,n=!1){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!0),[s,c]=(0,Z.useState)(null),l=(0,Z.useRef)(0),u=(0,Z.useCallback)(async()=>{let t=++l.current;c(null);try{let r=await(n?ne(e,!0):ne(e));t===l.current&&i(r)}catch(e){t===l.current&&c(e instanceof Error?e.message:String(e))}finally{t===l.current&&o(!1)}},[e,n]);return(0,Z.useEffect)(()=>(u(),()=>{l.current++}),[u,t]),(0,Z.useEffect)(()=>{let e,t=1/0,n=n=>{let r=Date.now()+n;r>=t||(window.clearTimeout(e),t=r,e=window.setTimeout(()=>{e=void 0,t=1/0,u()},n))},r=()=>n(100),i=()=>n(750),a=()=>{document.visibilityState===`visible`&&r()},o=[`task-changed-v2`,`task-updated`,`session-created`,`agent-run-started`,`agent-run-ended`,`automation-run-completed`,`home-advisor-updated`,`gateway-realtime-connected`,`realtime-gap`,`focus`],s=[`session-updated`,`session-transcript-updated`];return o.forEach(e=>window.addEventListener(e,r)),s.forEach(e=>window.addEventListener(e,i)),document.addEventListener(`visibilitychange`,a),()=>{o.forEach(e=>window.removeEventListener(e,r)),s.forEach(e=>window.removeEventListener(e,i)),document.removeEventListener(`visibilitychange`,a),window.clearTimeout(e)}},[u]),{home:r,loading:a,loadError:s,setLoadError:c,load:u}}var Q=r(),Fe=12e3;function Ie(e){let t=(0,X.c)(107),{variant:n,inputId:r,inputRef:i,intent:a,labels:o,attachments:s,isDragging:c,attachmentBusy:l,attachmentsFull:u,voice:d,chat:f,cancelAction:p,onIntentChange:m,onPickFiles:h,onRemoveAttachment:g,onPaste:_,onDragOver:v,onDragLeave:y,onDrop:b,onSubmit:x}=e,S=n===`inline`,C;t[0]!==s||t[1]!==a?(C=!!a.trim()||s.length>0,t[0]=s,t[1]=a,t[2]=C):C=t[2];let w=C,T=d.voiceActive&&d.phase!==`error`,E;t[3]!==x||t[4]!==d.voiceActive?(E=e=>{if(d.voiceActive){e.preventDefault();return}x(e)},t[3]=x,t[4]=d.voiceActive,t[5]=E):E=t[5];let D=S?`mx-auto mt-6 w-full overflow-hidden rounded-xl border border-edge bg-surface-base p-2 text-left shadow-surface transition-colors focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/15 sm:mt-8`:`flex min-h-0 flex-1 flex-col`,O;t[6]===D?O=t[7]:(O=R(`relative`,D),t[6]=D,t[7]=O);let k;t[8]!==S||t[9]!==c||t[10]!==o.dropFiles?(k=c?(0,Q.jsx)(`div`,{className:R(`pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-accent-soft/90 text-sm font-medium text-accent-fg backdrop-blur-[1px]`,S&&`rounded-2xl`),children:o.dropFiles}):null,t[8]=S,t[9]=c,t[10]=o.dropFiles,t[11]=k):k=t[11];let A=!S&&`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-4`,j;t[12]===A?j=t[13]:(j=R(A),t[12]=A,t[13]=j);let M=S?`sr-only`:`mb-2 shrink-0 text-sm font-medium text-fg`,P;t[14]!==r||t[15]!==o.intentLabel||t[16]!==M?(P=(0,Q.jsx)(`label`,{htmlFor:r,className:M,children:o.intentLabel}),t[14]=r,t[15]=o.intentLabel,t[16]=M,t[17]=P):P=t[17];let F;t[18]!==l||t[19]!==f||t[20]!==d.audioLevel||t[21]!==d.cancelVoiceInput||t[22]!==d.confirmVoiceInput||t[23]!==d.elapsedLabel||t[24]!==d.error||t[25]!==d.finalTranscript||t[26]!==d.partialTranscript||t[27]!==d.phase||t[28]!==d.recordedDictation||t[29]!==d.retryVoiceInput||t[30]!==d.settingsRequired||t[31]!==d.voiceActive?(F=d.voiceActive?(0,Q.jsx)(me,{phase:d.phase,elapsedLabel:d.elapsedLabel,recordedDictation:d.recordedDictation,audioLevel:d.audioLevel,partialTranscript:d.partialTranscript,finalTranscript:d.finalTranscript,error:d.error,settingsRequired:d.settingsRequired,disabled:l,chat:f,onCancel:d.cancelVoiceInput,onConfirm:d.confirmVoiceInput,onRetry:d.retryVoiceInput}):null,t[18]=l,t[19]=f,t[20]=d.audioLevel,t[21]=d.cancelVoiceInput,t[22]=d.confirmVoiceInput,t[23]=d.elapsedLabel,t[24]=d.error,t[25]=d.finalTranscript,t[26]=d.partialTranscript,t[27]=d.phase,t[28]=d.recordedDictation,t[29]=d.retryVoiceInput,t[30]=d.settingsRequired,t[31]=d.voiceActive,t[32]=F):F=t[32];let I=T&&`hidden`,ee=S?`min-h-24 bg-transparent px-3 py-2`:`min-h-32 flex-1 rounded-xl border border-edge bg-surface-base p-3 focus:border-accent focus:ring-2 focus:ring-accent/20`,L;t[33]!==I||t[34]!==ee?(L=R(`w-full resize-none text-sm font-normal leading-6 text-fg outline-none placeholder:text-fg-subtle`,I,ee),t[33]=I,t[34]=ee,t[35]=L):L=t[35];let z;t[36]===m?z=t[37]:(z=e=>m(e.target.value),t[36]=m,t[37]=z);let B=!S,V;t[38]!==r||t[39]!==i||t[40]!==a||t[41]!==o.intentPlaceholder||t[42]!==o.intentSuggestion||t[43]!==m||t[44]!==_||t[45]!==L||t[46]!==z||t[47]!==B?(V=(0,Q.jsx)(Ne,{ref:i,id:r,className:L,value:a,onChange:z,onPaste:_,suggestion:o.intentSuggestion,onAcceptSuggestion:m,onKeyDown:Le,placeholder:o.intentPlaceholder,maxLength:Fe,autoFocus:B}),t[38]=r,t[39]=i,t[40]=a,t[41]=o.intentPlaceholder,t[42]=o.intentSuggestion,t[43]=m,t[44]=_,t[45]=L,t[46]=z,t[47]=B,t[48]=V):V=t[48];let H=S?`border-b-0 bg-transparent px-3 pb-2 pt-0`:`mt-3 border-b-0 bg-transparent px-0 pb-0`,U;t[49]!==s||t[50]!==g||t[51]!==H?(U=(0,Q.jsx)(xe,{attachments:s,topPadded:!1,onRemove:g,className:H}),t[49]=s,t[50]=g,t[51]=H,t[52]=U):U=t[52];let W;t[53]!==S||t[54]!==a.length||t[55]!==o.shortcut?(W=S?null:(0,Q.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center justify-between gap-3 text-[11px] text-fg-subtle`,children:[(0,Q.jsx)(`span`,{children:o.shortcut}),(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[a.length.toLocaleString(),` / `,Fe.toLocaleString()]})]}),t[53]=S,t[54]=a.length,t[55]=o.shortcut,t[56]=W):W=t[56];let G;t[57]!==F||t[58]!==V||t[59]!==U||t[60]!==W||t[61]!==j||t[62]!==P?(G=(0,Q.jsxs)(`div`,{className:j,children:[P,F,V,U,W]}),t[57]=F,t[58]=V,t[59]=U,t[60]=W,t[61]=j,t[62]=P,t[63]=G):G=t[63];let K=S?`border-edge-subtle px-1 pt-2`:`border-edge px-5 py-4`,q;t[64]===K?q=t[65]:(q=R(`flex shrink-0 items-center gap-2 border-t`,K),t[64]=K,t[65]=q);let ne=!S&&`mr-auto`,re;t[66]===ne?re=t[67]:(re=R(`flex items-center gap-1`,ne),t[66]=ne,t[67]=re);let ie=l||u,ae;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Q.jsx)(N,{className:`size-4`,"aria-hidden":!0}),t[68]=ae):ae=t[68];let oe;t[69]!==o.attachTitle||t[70]!==h||t[71]!==ie?(oe=(0,Q.jsx)(J,{type:`button`,variant:`ghost`,className:`size-9 rounded-lg p-0`,disabled:ie,title:o.attachTitle,"aria-label":o.attachTitle,onClick:h,children:ae}),t[69]=o.attachTitle,t[70]=h,t[71]=ie,t[72]=oe):oe=t[72];let se;t[73]!==l||t[74]!==f||t[75]!==d.startVoiceInput||t[76]!==d.voiceActive?(se=d.voiceActive?null:(0,Q.jsx)(de,{disabled:l,chat:f,onStart:d.startVoiceInput}),t[73]=l,t[74]=f,t[75]=d.startVoiceInput,t[76]=d.voiceActive,t[77]=se):se=t[77];let Y;t[78]!==re||t[79]!==oe||t[80]!==se?(Y=(0,Q.jsxs)(`div`,{className:re,children:[oe,se]}),t[78]=re,t[79]=oe,t[80]=se,t[81]=Y):Y=t[81];let ce;t[82]!==p||t[83]!==S||t[84]!==o.shortcut?(ce=S?(0,Q.jsx)(`span`,{className:`hidden text-[11px] text-fg-subtle sm:inline`,children:o.shortcut}):p,t[82]=p,t[83]=S,t[84]=o.shortcut,t[85]=ce):ce=t[85];let le=S?`ml-auto h-9 rounded-lg px-3.5 text-xs`:`min-w-32`,ue=!w||l||d.voiceActive,fe=S?`size-3.5`:`size-4`,pe;t[86]===fe?pe=t[87]:(pe=(0,Q.jsx)(te,{className:fe,"aria-hidden":!0}),t[86]=fe,t[87]=pe);let he;t[88]!==o.submit||t[89]!==le||t[90]!==ue||t[91]!==pe?(he=(0,Q.jsxs)(J,{type:`submit`,variant:`primary`,className:le,disabled:ue,children:[pe,o.submit]}),t[88]=o.submit,t[89]=le,t[90]=ue,t[91]=pe,t[92]=he):he=t[92];let ge;t[93]!==q||t[94]!==Y||t[95]!==ce||t[96]!==he?(ge=(0,Q.jsxs)(`div`,{className:q,children:[Y,ce,he]}),t[93]=q,t[94]=Y,t[95]=ce,t[96]=he,t[97]=ge):ge=t[97];let _e;return t[98]!==y||t[99]!==v||t[100]!==b||t[101]!==E||t[102]!==G||t[103]!==ge||t[104]!==O||t[105]!==k?(_e=(0,Q.jsxs)(`form`,{onSubmit:E,onDragOver:v,onDragLeave:y,onDrop:b,className:O,children:[k,G,ge]}),t[98]=y,t[99]=v,t[100]=b,t[101]=E,t[102]=G,t[103]=ge,t[104]=O,t[105]=k,t[106]=_e):_e=t[106],_e}function Le(e){e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}function Re(e){let t=(0,X.c)(12),{href:n,children:r,onOpen:i}=e,o=a();if(n&&/^https?:\/\//i.test(n)){let e;return t[0]!==r||t[1]!==n?(e=(0,Q.jsx)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,className:`rounded-sm text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r}),t[0]=r,t[1]=n,t[2]=e):e=t[2],e}if(n?.startsWith(`/`)&&!n.startsWith(`//`)){let e=`${o.pathname}${o.search}`,a;t[3]!==n||t[4]!==e?(a=A(e,n),t[3]=n,t[4]=e,t[5]=a):a=t[5];let c;return t[6]!==r||t[7]!==i||t[8]!==a?(c=(0,Q.jsx)(s,{to:a,className:`rounded-sm text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:i,children:r}),t[6]=r,t[7]=i,t[8]=a,t[9]=c):c=t[9],c}let c;return t[10]===r?c=t[11]:(c=(0,Q.jsx)(`span`,{children:r}),t[10]=r,t[11]=c),c}function ze(e){let t=(0,X.c)(6),{opportunity:n,onOpen:r}=e,i=u($),a,o;if(t[0]!==i||t[1]!==r||t[2]!==n.evidence||t[3]!==n.evidencePresentation){o=Symbol.for(`react.early_return_sentinel`);bb0:{let e=f(i).projectsPage.home.advisorEvidenceCopy,t=n.evidencePresentation,s=t?.locale===i?t.groups:void 0,c=new Intl.DateTimeFormat(i===`zh`?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`}),l=t=>(0,Q.jsx)(`ul`,{className:`mt-2 space-y-3 border-l border-edge pl-3 text-xs leading-5 text-fg-muted`,children:t.map(t=>{let n=!!(t.href&&(/^https?:\/\//i.test(t.href)||t.href.startsWith(`/`)&&!t.href.startsWith(`//`)));return(0,Q.jsxs)(`li`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:[(0,Q.jsxs)(`p`,{className:`text-fg-subtle`,children:[e.sources[t.sourceType],` · `,(0,Q.jsx)(`time`,{dateTime:new Date(t.observedAt).toISOString(),children:c.format(t.observedAt)})]}),(0,Q.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap`,children:t.observation}),(0,Q.jsx)(`p`,{className:`mt-1`,children:n?(0,Q.jsx)(Re,{href:t.href,onOpen:r,children:e.openSource}):e.noSource})]},t.id)})}),u=(t,r)=>(0,Q.jsxs)(`li`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:[(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:t.summary}),(0,Q.jsxs)(`details`,{className:`mt-1`,children:[(0,Q.jsxs)(`summary`,{className:`min-h-9 cursor-pointer rounded-sm py-2 text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.originals,` · `,e.sourceCount.replace(`{{count}}`,String(t.evidenceIds.length))]}),l(n.evidence.filter(e=>t.evidenceIds.includes(e.id)))]})]},r);if(!s){o=(0,Q.jsxs)(`div`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:[(0,Q.jsx)(`p`,{children:e.unavailable}),(0,Q.jsxs)(`details`,{children:[(0,Q.jsx)(`summary`,{className:`min-h-9 cursor-pointer rounded-sm py-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:e.originals}),l(n.evidence)]})]});break bb0}a=(0,Q.jsxs)(`div`,{className:`mt-2 text-xs leading-5`,children:[(0,Q.jsx)(`p`,{className:`mb-3 text-fg-subtle`,children:e.aiNote}),(0,Q.jsx)(`ul`,{className:`space-y-3 border-l border-edge pl-3`,children:s.slice(0,3).map(u)}),s.length>3?(0,Q.jsxs)(`details`,{className:`mt-2`,children:[(0,Q.jsx)(`summary`,{className:`min-h-9 cursor-pointer rounded-sm py-2 text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:e.more.replace(`{{count}}`,String(s.length-3))}),(0,Q.jsx)(`ul`,{className:`space-y-3 border-l border-edge pl-3`,children:s.slice(3).map(u)})]}):null]})}t[0]=i,t[1]=r,t[2]=n.evidence,t[3]=n.evidencePresentation,t[4]=a,t[5]=o}else a=t[4],o=t[5];return o===Symbol.for(`react.early_return_sentinel`)?a:o}function $(e){return e.language}function Be(e){let t=(0,X.c)(4),{label:n,onClick:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}),t[0]=i):i=t[0];let a;return t[1]!==n||t[2]!==r?(a=(0,Q.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-9 items-center gap-1.5 rounded-lg px-2 text-xs font-medium text-fg-muted transition-colors duration-150 hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:r,children:[i,n]}),t[1]=n,t[2]=r,t[3]=a):a=t[3],a}function Ve(e){let t=(0,X.c)(63),{opportunity:n,copy:r,onOpenHistory:i}=e,a,o,s,c,l,u;if(t[0]!==r.aiLabel||t[1]!==r.automationAction||t[2]!==r.automationHint||t[3]!==r.history||t[4]!==r.minutes||t[5]!==r.needsSetup||t[6]!==r.why||t[7]!==i||t[8]!==n.capabilities||t[9]!==n.continuation||t[10]!==n.estimatedMinutes||t[11]!==n.outcome||t[12]!==n.rationale||t[13]!==n.title){let e=n.capabilities.filter(He),d;t[20]===r.aiLabel?d=t[21]:(d=(0,Q.jsx)(`span`,{children:r.aiLabel}),t[20]=r.aiLabel,t[21]=d);let f;t[22]!==r.minutes||t[23]!==n.estimatedMinutes?(f=n.estimatedMinutes?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),n.estimatedMinutes,` `,r.minutes]}):null,t[22]=r.minutes,t[23]=n.estimatedMinutes,t[24]=f):f=t[24];let p;t[25]!==d||t[26]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[d,f]}),t[25]=d,t[26]=f,t[27]=p):p=t[27];let m;t[28]!==r.history||t[29]!==i?(m=(0,Q.jsx)(Be,{label:r.history,onClick:i}),t[28]=r.history,t[29]=i,t[30]=m):m=t[30],t[31]!==m||t[32]!==p?(a=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[p,m]}),t[31]=m,t[32]=p,t[33]=a):a=t[33],t[34]===n.title?o=t[35]:(o=(0,Q.jsx)(`h3`,{className:`mt-3 text-xl font-semibold leading-7 tracking-tight text-fg`,children:n.title}),t[34]=n.title,t[35]=o),t[36]===n.outcome?s=t[37]:(s=(0,Q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:n.outcome}),t[36]=n.outcome,t[37]=s);let h;t[38]===r.why?h=t[39]:(h=(0,Q.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.why,`:`]}),t[38]=r.why,t[39]=h),t[40]!==n.rationale||t[41]!==h?(c=(0,Q.jsxs)(`p`,{className:`mt-4 text-sm leading-6 text-fg-muted`,children:[h,n.rationale]}),t[40]=n.rationale,t[41]=h,t[42]=c):c=t[42],t[43]!==r.automationAction||t[44]!==r.automationHint||t[45]!==n.continuation?(l=n.continuation?.kind===`automation`?(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 rounded-xl border border-edge bg-surface-subtle p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:r.automationHint}),(0,Q.jsx)(`a`,{href:`#${n.continuation.href}`,className:`inline-flex min-h-11 shrink-0 items-center rounded-lg px-3 text-xs font-medium text-accent hover:bg-accent-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.automationAction})]}):null,t[43]=r.automationAction,t[44]=r.automationHint,t[45]=n.continuation,t[46]=l):l=t[46],u=e.length>0?(0,Q.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,"aria-label":r.needsSetup,children:e.map(e=>(0,Q.jsxs)(`a`,{href:`#${e.recoveryPath??`/settings`}`,className:`rounded-full border border-accent/25 bg-accent-soft px-2.5 py-1 text-xs text-accent hover:border-accent/50`,children:[r.needsSetup,` · `,e.capability]},`${e.kind}:${e.capability}`))}):null,t[0]=r.aiLabel,t[1]=r.automationAction,t[2]=r.automationHint,t[3]=r.history,t[4]=r.minutes,t[5]=r.needsSetup,t[6]=r.why,t[7]=i,t[8]=n.capabilities,t[9]=n.continuation,t[10]=n.estimatedMinutes,t[11]=n.outcome,t[12]=n.rationale,t[13]=n.title,t[14]=a,t[15]=o,t[16]=s,t[17]=c,t[18]=l,t[19]=u}else a=t[14],o=t[15],s=t[16],c=t[17],l=t[18],u=t[19];let d;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(S,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[47]=d):d=t[47];let f;t[48]===r.evidence?f=t[49]:(f=(0,Q.jsxs)(`summary`,{className:`flex min-h-9 cursor-pointer list-none items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[r.evidence,d]}),t[48]=r.evidence,t[49]=f);let p;t[50]===n?p=t[51]:(p=(0,Q.jsx)(ze,{opportunity:n}),t[50]=n,t[51]=p);let m;t[52]!==f||t[53]!==p?(m=(0,Q.jsxs)(`details`,{className:`mt-4 group`,children:[f,p]}),t[52]=f,t[53]=p,t[54]=m):m=t[54];let h;return t[55]!==a||t[56]!==m||t[57]!==o||t[58]!==s||t[59]!==c||t[60]!==l||t[61]!==u?(h=(0,Q.jsxs)(Q.Fragment,{children:[a,o,s,c,l,u,m]}),t[55]=a,t[56]=m,t[57]=o,t[58]=s,t[59]=c,t[60]=l,t[61]=u,t[62]=h):h=t[62],h}function He(e){return e.readiness!==`ready`}function Ue(e){let t=(0,X.c)(142),{advisor:n,copy:r,busy:i,onRefresh:a,onAction:o,onFeedback:s,onClarification:c,onOpenHistory:l,preflight:u,receipt:d}=e,[f,p]=(0,Z.useState)(),m;t[0]!==n.alternatives||t[1]!==n.primary||t[2]!==n.state?(m=n.state===`ready`?[n.primary,...n.alternatives]:[],t[0]=n.alternatives,t[1]=n.primary,t[2]=n.state,t[3]=m):m=t[3];let h=m,g;t[4]!==h||t[5]!==f?(g=h.find(e=>e.id===f)??h[0],t[4]=h,t[5]=f,t[6]=g):g=t[6];let _=g,v;t[7]===h[0]?.id?v=t[8]:(v=()=>p(h[0]?.id),t[7]=h[0]?.id,t[8]=v);let y=h[0]?.id,b;if(t[9]!==n.state||t[10]!==y?(b=[n.state,y],t[9]=n.state,t[10]=y,t[11]=b):b=t[11],(0,Z.useEffect)(v,b),n.state===`disabled`)return null;if(d){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(T,{className:`size-5 shrink-0 text-success`,"aria-hidden":!0}),t[12]=e):e=t[12];let n;t[13]===d.title?n=t[14]:(n=(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:d.title}),t[13]=d.title,t[14]=n);let i;t[15]===d.detail?i=t[16]:(i=(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:d.detail}),t[15]=d.detail,t[16]=i);let a;t[17]!==n||t[18]!==i?(a=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[n,i]}),t[17]=n,t[18]=i,t[19]=a):a=t[19];let o;t[20]!==r.history||t[21]!==l?(o=(0,Q.jsx)(Be,{label:r.history,onClick:l}),t[20]=r.history,t[21]=l,t[22]=o):o=t[22];let s=`#${d.href}`,c;t[23]!==r.viewProgress||t[24]!==s?(c=(0,Q.jsx)(J,{asChild:!0,variant:`secondary`,className:`min-h-10 text-xs`,children:(0,Q.jsx)(`a`,{href:s,children:r.viewProgress})}),t[23]=r.viewProgress,t[24]=s,t[25]=c):c=t[25];let u;t[26]!==o||t[27]!==c?(u=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[o,c]}),t[26]=o,t[27]=c,t[28]=u):u=t[28];let f;return t[29]!==u||t[30]!==a?(f=(0,Q.jsx)(`section`,{className:`mt-7 rounded-2xl border border-success/25 bg-success-soft px-5 py-4`,role:`status`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[e,a,u]})}),t[29]=u,t[30]=a,t[31]=f):f=t[31],f}if(n.state===`quiet`||n.state===`refreshing`)return null;if(n.state===`clarification`){let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[32]=e):e=t[32];let a;t[33]===r.aiLabel?a=t[34]:(a=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-accent`,children:[e,r.aiLabel]}),t[33]=r.aiLabel,t[34]=a);let o;t[35]!==r.history||t[36]!==l?(o=(0,Q.jsx)(Be,{label:r.history,onClick:l}),t[35]=r.history,t[36]=l,t[37]=o):o=t[37];let s;t[38]!==a||t[39]!==o?(s=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[a,o]}),t[38]=a,t[39]=o,t[40]=s):s=t[40];let u;t[41]===n.question.question?u=t[42]:(u=(0,Q.jsx)(`h3`,{id:`home-advisor-question`,className:`mt-3 text-lg font-semibold text-fg`,children:n.question.question}),t[41]=n.question.question,t[42]=u);let d;if(t[43]!==n.question.options||t[44]!==n.question.question||t[45]!==i||t[46]!==c){let e;t[48]!==n.question.question||t[49]!==i||t[50]!==c?(e=e=>(0,Q.jsx)(J,{type:`button`,variant:`secondary`,className:`min-h-11`,disabled:i,onClick:()=>c(n.question.question,e.label),children:e.label},e.id),t[48]=n.question.question,t[49]=i,t[50]=c,t[51]=e):e=t[51],d=n.question.options.map(e),t[43]=n.question.options,t[44]=n.question.question,t[45]=i,t[46]=c,t[47]=d}else d=t[47];let f;t[52]===d?f=t[53]:(f=(0,Q.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:d}),t[52]=d,t[53]=f);let p;return t[54]!==u||t[55]!==f||t[56]!==s?(p=(0,Q.jsxs)(`section`,{className:`mt-7 rounded-2xl border border-accent/25 bg-surface-base px-5 py-5`,"aria-labelledby":`home-advisor-question`,children:[s,u,f]}),t[54]=u,t[55]=f,t[56]=s,t[57]=p):p=t[57],p}if(!_)return null;let x=u?.opportunityId===_.id?u.value:void 0,C;t[58]!==n.stale||t[59]!==r.refreshing?(C=n.stale?(0,Q.jsxs)(`p`,{className:`mb-3 inline-flex items-center gap-2 text-xs text-accent`,children:[(0,Q.jsx)(F,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.refreshing]}):null,t[58]=n.stale,t[59]=r.refreshing,t[60]=C):C=t[60];let w;t[61]!==r||t[62]!==l||t[63]!==_?(w=(0,Q.jsx)(Ve,{opportunity:_,copy:r,onOpenHistory:l}),t[61]=r,t[62]=l,t[63]=_,t[64]=w):w=t[64];let E;t[65]!==i||t[66]!==r.configure||t[67]!==r.degradedStart||t[68]!==r.setupHint||t[69]!==r.setupTitle||t[70]!==o||t[71]!==_||t[72]!==x?(E=x?.state===`needs_setup`?(0,Q.jsx)(`div`,{className:`mt-5 rounded-xl border border-accent/25 bg-accent-soft/40 p-4`,role:`alert`,"aria-live":`polite`,children:(0,Q.jsxs)(`div`,{className:`flex gap-3`,children:[(0,Q.jsx)(ee,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:r.setupTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:r.setupHint}),(0,Q.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs leading-5 text-fg-muted`,children:x.blockers.map(We)}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[x.recoveryActions.map(e=>(0,Q.jsxs)(`a`,{href:`#${e.href}`,className:`inline-flex min-h-11 items-center rounded-lg border border-accent/30 px-3 text-xs font-medium text-accent hover:bg-accent-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[r.configure,` · `,e.capability]},e.capability)),x.degradedAction?(0,Q.jsx)(J,{type:`button`,variant:`secondary`,className:`min-h-11`,disabled:i,onClick:()=>o(_,`degraded_start`),children:r.degradedStart}):null]})]})]})}):null,t[65]=i,t[66]=r.configure,t[67]=r.degradedStart,t[68]=r.setupHint,t[69]=r.setupTitle,t[70]=o,t[71]=_,t[72]=x,t[73]=E):E=t[73];let D;t[74]!==i||t[75]!==r.start||t[76]!==o||t[77]!==_?(D=_.actions.canStart?(0,Q.jsxs)(J,{type:`button`,variant:`primary`,className:`min-h-11`,disabled:i,onClick:()=>o(_,`start`),children:[(0,Q.jsx)(te,{className:`size-4`,"aria-hidden":!0}),r.start]}):null,t[74]=i,t[75]=r.start,t[76]=o,t[77]=_,t[78]=D):D=t[78];let O;t[79]!==i||t[80]!==r.discuss||t[81]!==o||t[82]!==_?(O=_.actions.canDiscuss?(0,Q.jsxs)(J,{type:`button`,variant:`secondary`,className:`min-h-11`,disabled:i,onClick:()=>o(_,`discuss`),children:[(0,Q.jsx)(M,{className:`size-4`,"aria-hidden":!0}),r.discuss]}):null,t[79]=i,t[80]=r.discuss,t[81]=o,t[82]=_,t[83]=O):O=t[83];let k;t[84]!==O||t[85]!==D?(k=(0,Q.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-2`,children:[D,O]}),t[84]=O,t[85]=D,t[86]=k):k=t[86];let A;t[87]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Q.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),t[87]=A):A=t[87];let j;t[88]===r.more?j=t[89]:(j=(0,Q.jsxs)(`summary`,{className:`inline-flex min-h-9 cursor-pointer list-none items-center gap-1.5 rounded-lg px-2 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,children:[r.more,A]}),t[88]=r.more,t[89]=j);let N;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Q.jsx)(F,{className:`size-4`,"aria-hidden":!0}),t[90]=N):N=t[90];let P;t[91]!==i||t[92]!==r.refresh||t[93]!==a?(P=(0,Q.jsxs)(J,{type:`button`,variant:`ghost`,className:`min-h-11`,disabled:i,onClick:a,title:r.refresh,children:[N,r.refresh]}),t[91]=i,t[92]=r.refresh,t[93]=a,t[94]=P):P=t[94];let I;t[95]===r.feedback?I=t[96]:(I=(0,Q.jsx)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center rounded-lg px-3 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.feedback}),t[95]=r.feedback,t[96]=I);let L;t[97]===r.alreadyDone?L=t[98]:(L=[`already_done`,r.alreadyDone],t[97]=r.alreadyDone,t[98]=L);let R;t[99]===r.irrelevant?R=t[100]:(R=[`irrelevant`,r.irrelevant],t[99]=r.irrelevant,t[100]=R);let z;t[101]===r.later?z=t[102]:(z=[`too_early`,r.later],t[101]=r.later,t[102]=z);let B;t[103]===r.sourceIncorrect?B=t[104]:(B=[`source_incorrect`,r.sourceIncorrect],t[103]=r.sourceIncorrect,t[104]=B);let V;t[105]===r.lessLikeThis?V=t[106]:(V=[`less_like_this`,r.lessLikeThis],t[105]=r.lessLikeThis,t[106]=V);let H;t[107]!==L||t[108]!==R||t[109]!==z||t[110]!==B||t[111]!==V?(H=[L,R,z,B,V],t[107]=L,t[108]=R,t[109]=z,t[110]=B,t[111]=V,t[112]=H):H=t[112];let U=H,W;t[113]!==i||t[114]!==s||t[115]!==_||t[116]!==U?(W=(0,Q.jsx)(`div`,{className:`absolute right-0 z-20 mt-1 w-44 rounded-xl border border-edge bg-surface-overlay p-1 shadow-float`,children:U.map(e=>{let[t,n]=e;return(0,Q.jsx)(`button`,{type:`button`,disabled:i,className:`min-h-10 w-full rounded-lg px-3 text-left text-sm text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>s(_,t),children:n},t)})}),t[113]=i,t[114]=s,t[115]=_,t[116]=U,t[117]=W):W=t[117];let G;t[118]!==I||t[119]!==W?(G=(0,Q.jsxs)(`details`,{className:`relative`,children:[I,W]}),t[118]=I,t[119]=W,t[120]=G):G=t[120];let K;t[121]!==P||t[122]!==G?(K=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[P,G]}),t[121]=P,t[122]=G,t[123]=K):K=t[123];let q;t[124]!==i||t[125]!==r.alternatives||t[126]!==h||t[127]!==_.id?(q=h.length>1?(0,Q.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:r.alternatives}),(0,Q.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:h.filter(e=>e.id!==_.id).map(e=>(0,Q.jsx)(`button`,{type:`button`,disabled:i,className:`min-h-10 rounded-lg border border-edge px-3 text-left text-sm text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>p(e.id),children:e.title},e.id))})]}):null,t[124]=i,t[125]=r.alternatives,t[126]=h,t[127]=_.id,t[128]=q):q=t[128];let ne;t[129]!==j||t[130]!==K||t[131]!==q?(ne=(0,Q.jsxs)(`details`,{className:`mt-1`,children:[j,K,q]}),t[129]=j,t[130]=K,t[131]=q,t[132]=ne):ne=t[132];let re;t[133]!==k||t[134]!==ne||t[135]!==C||t[136]!==w||t[137]!==E?(re=(0,Q.jsxs)(`div`,{className:`px-5 py-5 sm:px-6`,children:[C,w,E,k,ne]}),t[133]=k,t[134]=ne,t[135]=C,t[136]=w,t[137]=E,t[138]=re):re=t[138];let ie;return t[139]!==r.aiLabel||t[140]!==re?(ie=(0,Q.jsx)(`section`,{className:`mt-7 rounded-2xl border border-accent/25 bg-surface-base`,"aria-label":r.aiLabel,children:re}),t[139]=r.aiLabel,t[140]=re,t[141]=ie):ie=t[141],ie}function We(e){return(0,Q.jsx)(`li`,{children:e.message},`${e.kind}:${e.capability}`)}function Ge({observation:e,advisor:t,language:n,onUpdated:r}){let i=n===`zh`,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(``),[u,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(`once`),[h,g]=(0,Z.useState)(),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(),[T,E]=(0,Z.useState)(!1),D=t.state===`ready`?t.primary:void 0,O=D?.evidence.map(e=>/^observation:([^:]+):/.exec(e.id)?.[1]).find(Boolean),k=h?e.topics.find(e=>e.id===h):e.topics.find(e=>e.id===O)??e.topics[0],A=async e=>{if(!a){o(!0),c(``);try{await e(),r()}catch(e){c(e instanceof Error?e.message:String(e)),r()}finally{o(!1)}}},j=async t=>{let n=await d(l(`/api/home/observation/command`),{method:`POST`,body:JSON.stringify({expectedRevision:e.revision,idempotencyKey:crypto.randomUUID(),command:t})});return V.parse(n)},M=e.status===`disabled`?i?`开启长期观察`:`Start observing`:e.status===`paused`?i?`观察已暂停`:`Observation paused`:e.analyzedRevision<e.revision?i?`已接收新记录,等待分析`:`New records awaiting analysis`:i?`持续观察中 · 等待新记录`:`Observing · waiting for new records`;return(0,Q.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,"aria-label":i?`交给我`:`Let me handle it`,"aria-busy":a,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i?`交给我`:`Let me handle it`}),(0,Q.jsx)(`span`,{className:`text-xs text-fg-muted`,role:`status`,children:M})]}),(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:i?`在同一个观察会话里,积累你的工作轨迹、反馈和试做结果。`:`Work, feedback and trial outcomes stay linked in one observation session.`}),s?(0,Q.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:s}):null,h&&!k&&u?(0,Q.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[i?`此主题已不可用,未将你的输入转给其他主题。未保存的内容:`:`This topic is unavailable. Your draft was not reassigned: `,u]}):null,t.state===`quiet`&&[`model_unavailable`,`generation_failed`,`budget_exhausted`].includes(t.reason)?(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,role:`status`,children:i?`记录已保留,当前分析暂不可用。请检查模型配置或稍后重试;不会丢失反馈。`:`Records are preserved. Analysis is temporarily unavailable; check the model or retry later. Feedback is retained.`}):null,e.status===`disabled`?(0,Q.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i?`开启后回看最近 30 天已授权的私人会话,再增量处理新任务和反馈。不扫描屏幕,不自动创建定时任务。`:`Review up to 30 days of authorized private conversations, then process new work and feedback incrementally. No screen recording or recurring jobs.`}),(0,Q.jsx)(J,{disabled:a,onClick:()=>void A(async()=>{await j({kind:`start`,backfillDays:30})}),children:i?`开启观察`:`Start observation`})]}):(0,Q.jsxs)(Q.Fragment,{children:[k?(0,Q.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:k.title}):(0,Q.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:i?`暂时没有足够的线索。有完整的新任务后再判断。`:`Waiting for enough evidence from new work.`}),e.status===`active`&&D&&k&&O===k.id?(0,Q.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:D.title}),(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:D.rationale}),(0,Q.jsxs)(`details`,{className:`text-xs text-fg-muted`,children:[(0,Q.jsx)(`summary`,{children:i?`查看依据`:`Evidence`}),D.evidence.map(e=>(0,Q.jsx)(`p`,{className:`mt-2`,children:e.observation},e.id))]}),D.risk===`analysis`?(0,Q.jsx)(J,{disabled:a,onClick:()=>void A(async()=>{let t=B.parse(await d(l(`/api/home/observation/trial`),{method:`POST`,body:JSON.stringify({topicId:k.id,opportunityId:D.id,expectedRevision:e.revision,expectedOpportunityRevision:D.revision,idempotencyKey:crypto.randomUUID()})}));if(t.outcome===`task`)w(t.taskId);else throw Error(i?`请先完成相关能力配置。`:`Set up the required capabilities first.`)}),children:i?`先做一份私人草稿`:`Try a private draft`}):(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`这项建议需要读取或修改外部服务,当前仅支持讨论与私人分析试做。`:`This suggestion needs external access. Discuss its scope before proceeding.`})]}):null,k&&e.status===`active`?(0,Q.jsx)(J,{className:`mt-3`,variant:`ghost`,disabled:a,"aria-expanded":_,onClick:()=>{g(k.id),v(!_)},children:i?`补充一句 / 调整要求`:`Add feedback / refine requirements`}):null,k&&e.status===`active`?(0,Q.jsx)(J,{variant:`ghost`,disabled:a,onClick:()=>void A(async()=>{let t=await d(l(`/api/home/observation/discussion`),{method:`POST`,body:JSON.stringify({topicId:k.id,expectedRevision:e.revision,idempotencyKey:crypto.randomUUID()})});window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:t}))}),children:i?`展开聊聊`:`Discuss in chat`}):null,_&&k?(0,Q.jsxs)(`form`,{className:`mt-3 space-y-3`,onSubmit:e=>{e.preventDefault(),A(async()=>{await j({kind:`feedback`,topicId:k.id,text:u,scope:p}),f(``),v(!1),b(!0)})},children:[(0,Q.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[i?`希望我记住什么?`:`What should I remember?`,(0,Q.jsx)(`textarea`,{required:!0,maxLength:1e3,value:u,onChange:e=>f(e.target.value),className:`mt-1 min-h-24 w-full rounded-lg border border-edge bg-surface-inset p-2 text-sm text-fg`})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,role:`group`,"aria-label":i?`反馈范围`:`Feedback scope`,children:[`once`,`project`,`similar`].filter(e=>e!==`project`||k.projectId).map(e=>(0,Q.jsx)(J,{type:`button`,variant:e===p?`secondary`:`ghost`,"aria-pressed":e===p,onClick:()=>m(e),children:e===`once`?i?`仅本次`:`This trial only`:e===`project`?i?`当前项目`:`This project`:i?`长期同类任务`:`Similar future work`},e))}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`保留原话与范围。仅本次不会成为长期规则;反馈不代表执行授权。`:`Keep the original words and scope. One-off feedback is not a standing rule or authorization.`}),(0,Q.jsx)(J,{type:`submit`,disabled:a||!u.trim(),children:i?`保存反馈`:`Save feedback`})]}):null,k?.trials.length?(0,Q.jsx)(`div`,{className:`mt-3 space-y-2`,children:k.trials.map(e=>(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[e.title,` · `,e.phase,e.resolution?` / ${e.resolution}`:``]}),(0,Q.jsx)(J,{variant:`ghost`,onClick:()=>w(C===e.taskId?void 0:e.taskId),children:i?`查看试做与验收`:`Review trial`})]},e.taskId))}):null,C?(0,Q.jsx)(Oe,{taskId:C,language:n,onComplete:r}):null,k?.routine?(0,Q.jsx)(ke,{routine:k.routine,language:n,onUpdated:r}):k?.trials[0]&&[`review`,`closed`].includes(k.trials[0].phase)?(0,Q.jsx)(Ae,{topicId:k.id,trial:k.trials[0],language:n,onUpdated:r}):null,(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 border-t border-edge-subtle pt-2`,children:[(0,Q.jsx)(J,{variant:`ghost`,"aria-expanded":y,onClick:()=>b(!y),children:i?`观察记录`:`Observation journal`}),(0,Q.jsx)(J,{disabled:a,variant:`ghost`,onClick:()=>e.status===`active`?void A(async()=>{await j({kind:`pause`})}):E(!T),children:e.status===`active`?i?`暂停观察`:`Pause observation`:i?`恢复观察`:`Resume observation`})]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`观察范围:已授权的 xopc 私人会话与关联试做回执。暂停观察不影响已有自动化。`:`Scope: authorized private xopc conversations and linked trial receipts. Pausing does not stop existing automations.`}),T?(0,Q.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[`catch_up`,`new_only`].map(e=>(0,Q.jsx)(J,{disabled:a,onClick:()=>void A(async()=>{await j({kind:`resume`,mode:e}),E(!1)}),children:e===`catch_up`?i?`补看暂停期间记录`:`Catch up`:i?`仅看之后的新记录`:`New records only`},e))}):null,y?(0,Q.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.topics.map(e=>(0,Q.jsx)(J,{variant:`ghost`,"aria-pressed":k?.id===e.id,onClick:()=>{(!_||!u)&&(g(e.id),S(!1))},children:e.title},e.id))}),k?.entries.map(e=>(0,Q.jsxs)(`div`,{className:`border-l border-edge pl-3 text-xs text-fg-muted`,children:[(0,Q.jsx)(`time`,{children:new Date(e.createdAt).toLocaleString(i?`zh-CN`:`en-US`)}),(0,Q.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words`,children:e.text})]},e.id)),k?.feedback.filter(e=>e.status===`active`).map(e=>(0,Q.jsxs)(`div`,{className:`rounded-lg bg-surface-inset p-2 text-xs text-fg`,children:[(0,Q.jsx)(`p`,{children:e.text}),(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:e.scope===`once`?i?`仅本次`:`One trial`:e.scope===`project`?i?`当前项目`:`Project`:i?`长期同类任务`:`Similar work`}),(0,Q.jsx)(J,{disabled:a,variant:`ghost`,onClick:()=>void A(async()=>{await j({kind:`retract`,topicId:k.id,feedbackId:e.id})}),children:i?`撤回反馈`:`Retract`})]},e.id)),k?(0,Q.jsx)(J,{variant:`ghost`,disabled:a,onClick:()=>S(!0),children:i?`忘记并排除此主题`:`Forget and exclude topic`}):null,x&&k?(0,Q.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-edge p-3`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg`,children:i?`清除派生理解与反馈,并排除同一来源主题。原始记录、已有任务和自动化保留。`:`Clear derived records and feedback and exclude this source topic. Original records, tasks and automations remain.`}),(0,Q.jsx)(J,{disabled:a,onClick:()=>void A(async()=>{await j({kind:`forget`,topicId:k.id}),g(void 0),S(!1),f(``),v(!1),w(void 0)}),children:i?`确认忘记`:`Confirm forget`}),(0,Q.jsx)(J,{variant:`ghost`,onClick:()=>S(!1),children:i?`取消`:`Cancel`})]}):null]}):null]})]})}var Ke=new Set([`started`,`discussing`,`completed`]);function qe(){let e=(0,X.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[0,1,2].map(Je)}),e[0]=t):t=e[0],t}function Je(e){return(0,Q.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-edge-subtle p-4`,children:[(0,Q.jsx)(z,{className:`h-4 w-24 rounded`}),(0,Q.jsx)(z,{className:`h-5 w-4/5 rounded`}),(0,Q.jsx)(z,{className:`h-4 w-3/5 rounded`})]},e)}function Ye(e){let t=(0,X.c)(11),{open:n,refreshKey:r,onOpenChange:i,onReevaluate:a}=e,o=u(Xe),s=f(o).projectsPage.home,l=c(),[d,b]=(0,Z.useState)(`all`),x;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=[],t[0]=x):x=t[0];let[C,w]=(0,Z.useState)(x),[T,E]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(),N;t[1]===n?N=t[2]:(N=()=>{if(!n)return;let e=!0;return E(!0),M(void 0),q().then(t=>{e&&w(t.items)}).catch(t=>{e&&M(t instanceof Error?t.message:String(t))}).finally(()=>{e&&E(!1)}),()=>{e=!1}},t[1]=n,t[2]=N);let P;t[3]!==n||t[4]!==r?(P=[n,r],t[3]=n,t[4]=r,t[5]=P):P=t[5],(0,Z.useEffect)(N,P);let I=C.filter(e=>d===`all`||(d===`adopted`?Ke.has(e.status):!Ke.has(e.status))),ee=new Intl.DateTimeFormat(o===`zh`?`zh-CN`:`en`,{dateStyle:`medium`}),te=new Intl.DateTimeFormat(o===`zh`?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`}),R=new Map;for(let e of I){let t=ee.format(new Date(e.updatedAt));R.set(t,[...R.get(t)??[],e])}let z=[...R.entries()],B=e=>e.feedbackKind===`already_done`?s.advisorHistoryStatusCompleted:e.feedbackKind===`irrelevant`?s.advisorHistoryStatusIrrelevant:e.feedbackKind===`source_incorrect`?s.advisorHistoryStatusSourceIncorrect:e.feedbackKind===`less_like_this`?s.advisorHistoryStatusLessLikeThis:{available:s.advisorHistoryStatusAvailable,started:s.advisorHistoryStatusStarted,discussing:s.advisorHistoryStatusDiscussing,completed:s.advisorHistoryStatusCompleted,snoozed:s.advisorHistoryStatusSnoozed,dismissed:s.advisorHistoryStatusDismissed,expired:s.advisorHistoryStatusExpired,superseded:s.advisorHistoryStatusSuperseded}[e.status],V=e=>{if(e.href){i(!1),l(A(`/`,e.href));return}e.status===`discussing`&&(i(!1),l(`/chat/new?${new URLSearchParams({draft:e.opportunity.actionPrompt}).toString()}`))},H;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,Q.jsx)(p,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim`}),t[6]=H):H=t[6];let U;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Q.jsx)(k,{className:`mt-0.5 size-5 shrink-0 text-accent`,"aria-hidden":!0}),t[7]=U):U=t[7];let W;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,Q.jsx)(L,{className:`size-4`,"aria-hidden":!0}),t[8]=W):W=t[8];let G=T?(0,Q.jsx)(qe,{}):j?(0,Q.jsxs)(`div`,{className:`rounded-xl border border-danger/25 bg-danger-soft p-4 text-sm text-danger`,children:[(0,Q.jsx)(`p`,{children:s.advisorHistoryLoadFailed}),(0,Q.jsx)(J,{type:`button`,variant:`ghost`,className:`mt-2`,onClick:()=>i(!1),children:s.advisorHistoryClose})]}):z.length===0?(0,Q.jsxs)(`div`,{className:`py-16 text-center`,children:[(0,Q.jsx)(k,{className:`mx-auto size-6 text-fg-subtle`,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:s.advisorHistoryEmpty}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.advisorHistoryEmptyHint})]}):(0,Q.jsx)(`div`,{className:`space-y-6`,children:z.map(e=>{let[t,n]=e;return(0,Q.jsxs)(`section`,{"aria-label":t,children:[(0,Q.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-subtle`,children:t}),(0,Q.jsx)(`div`,{className:`space-y-2`,children:n.map(e=>{let t=!!e.href||e.status===`discussing`,n=[`snoozed`,`dismissed`,`expired`,`superseded`].includes(e.status);return(0,Q.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-base p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-accent`,children:B(e)}),(0,Q.jsx)(`h4`,{className:`mt-1.5 text-sm font-semibold leading-5 text-fg`,children:e.opportunity.title}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.opportunity.outcome})]}),(0,Q.jsx)(`time`,{className:`shrink-0 text-[11px] text-fg-subtle`,dateTime:new Date(e.updatedAt).toISOString(),children:te.format(new Date(e.updatedAt))})]}),e.snoozedUntil?(0,Q.jsxs)(`p`,{className:`mt-2 inline-flex items-center gap-1 text-xs text-fg-muted`,children:[(0,Q.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),s.advisorHistoryReturnsAt,` `,te.format(new Date(e.snoozedUntil))]}):null,(0,Q.jsxs)(`details`,{className:`group mt-3`,children:[(0,Q.jsxs)(`summary`,{className:`flex min-h-8 cursor-pointer list-none items-center gap-1 text-xs font-medium text-fg-muted hover:text-fg`,children:[s.advisorHistoryEvidence,(0,Q.jsx)(S,{className:`size-3.5 transition-transform duration-200 group-open:rotate-180 motion-reduce:transition-none`,"aria-hidden":!0})]}),(0,Q.jsx)(ze,{opportunity:e.opportunity,onOpen:()=>i(!1)})]}),t||n?(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[t?(0,Q.jsxs)(J,{type:`button`,variant:`secondary`,className:`min-h-9 text-xs`,onClick:()=>V(e),children:[(0,Q.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),e.status===`discussing`?s.advisorHistoryContinueDiscussion:s.advisorHistoryViewProgress]}):null,n?(0,Q.jsxs)(J,{type:`button`,variant:`ghost`,className:`min-h-9 text-xs`,onClick:()=>{i(!1),a()},children:[(0,Q.jsx)(F,{className:`size-3.5`,"aria-hidden":!0}),s.advisorHistoryReevaluate]}):null]}):null]},e.opportunity.id)})})]},t)})}),K;return t[9]===G?K=t[10]:(K=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:G}),t[9]=G,t[10]=K),(0,Q.jsx)(y,{open:n,onOpenChange:i,children:(0,Q.jsxs)(g,{children:[H,(0,Q.jsxs)(_,{className:`xopc-drawer-right fixed right-0 top-0 z-[90] flex size-full max-w-lg flex-col overflow-hidden border-l border-edge bg-surface-overlay shadow-popover outline-none`,"aria-describedby":`home-advisor-history-description`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start gap-3 border-b border-edge px-5 py-4`,children:[U,(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(v,{className:`text-base font-semibold text-fg`,children:s.advisorHistoryTitle}),(0,Q.jsx)(m,{id:`home-advisor-history-description`,className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.advisorHistoryDescription})]}),(0,Q.jsx)(h,{asChild:!0,children:(0,Q.jsx)(J,{type:`button`,variant:`ghost`,className:`-mr-2 size-9 shrink-0 p-0`,"aria-label":s.advisorHistoryClose,children:W})})]}),(0,Q.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle px-5 py-3`,children:(0,Q.jsx)(Ce,{className:`inline-flex rounded-lg bg-surface-inset p-1`,role:`group`,"aria-label":s.advisorHistoryFilterLabel,indicatorClassName:`rounded-md bg-surface-panel shadow-surface`,children:[[`all`,s.advisorHistoryFilterAll],[`adopted`,s.advisorHistoryFilterAdopted],[`other`,s.advisorHistoryFilterOther]].map(e=>{let[t,n]=e;return(0,Q.jsx)(`button`,{type:`button`,className:`min-h-9 rounded-md px-3 text-xs font-medium transition-colors duration-150 ${d===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`}`,"aria-pressed":d===t,onClick:()=>b(t),children:n},t)})})}),K]})]})})}function Xe(e){return e.language}function Ze(e,t){return e.replace(`{{count}}`,String(t))}function Qe(e,t){if(e.state===`disabled`)return null;if(e.state===`ready`){let n=1+e.alternatives.length;return{label:Ze(t.ready,n),detail:e.primary.title,tone:`accent`,refreshing:!!e.stale}}return e.state===`clarification`?{label:t.clarification,detail:e.question.question,tone:`accent`,refreshing:!1}:e.state===`refreshing`?{label:t.refreshing,detail:e.previous?.title??t.refreshingDetail,tone:`accent`,refreshing:!0}:e.reason===`generation_failed`?{label:t.generationFailed,detail:t.generationFailedDetail,tone:`danger`,refreshing:!1}:e.reason===`budget_exhausted`?{label:t.budgetExhausted,detail:t.budgetExhaustedDetail,tone:`warning`,refreshing:!1}:e.reason===`model_unavailable`?{label:t.modelUnavailable,detail:t.modelUnavailableDetail,tone:`warning`,refreshing:!1}:{label:t.idle,detail:t.idleDetail,tone:`neutral`,refreshing:!1}}var $e={accent:`bg-accent`,danger:`bg-danger`,neutral:`bg-fg-subtle`,warning:`bg-warning`};function et(e){let t=(0,X.c)(50),{advisor:n,busy:r,copy:i,onOpenHistory:a,onRefresh:o}=e,[s,c]=(0,Z.useState)(!1),l;t[0]!==n||t[1]!==i?(l=Qe(n,i),t[0]=n,t[1]=i,t[2]=l):l=t[2];let u=l;if(!u)return null;let d=n.state!==`refreshing`,f=n.state===`ready`?i.findAnother:i.retry,p=`${i.label}:${u.label}`,m;t[3]===u.refreshing?m=t[4]:(m=u.refreshing?(0,Q.jsx)(F,{className:`size-3.5 shrink-0 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):(0,Q.jsx)(te,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[3]=u.refreshing,t[4]=m);let h=$e[u.tone],g;t[5]===h?g=t[6]:(g=R(`size-1.5 shrink-0 rounded-full`,h),t[5]=h,t[6]=g);let _;t[7]===g?_=t[8]:(_=(0,Q.jsx)(`span`,{className:g,"aria-hidden":!0}),t[7]=g,t[8]=_);let v;t[9]!==i.label||t[10]!==u.label?(v=(0,Q.jsxs)(`span`,{className:`truncate`,children:[i.label,` · `,u.label]}),t[9]=i.label,t[10]=u.label,t[11]=v):v=t[11];let y;t[12]!==p||t[13]!==m||t[14]!==_||t[15]!==v?(y=(0,Q.jsx)(ue,{asChild:!0,children:(0,Q.jsxs)(J,{type:`button`,variant:`ghost`,className:`h-9 max-w-56 rounded-lg px-2.5`,"aria-label":p,children:[m,_,v]})}),t[12]=p,t[13]=m,t[14]=_,t[15]=v,t[16]=y):y=t[16];let b;t[17]===u.refreshing?b=t[18]:(b=(0,Q.jsx)(`span`,{className:`mt-1 flex size-7 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent`,children:u.refreshing?(0,Q.jsx)(F,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):(0,Q.jsx)(te,{className:`size-4`,"aria-hidden":!0})}),t[17]=u.refreshing,t[18]=b);let x;t[19]===u.label?x=t[20]:(x=(0,Q.jsx)(`p`,{className:`font-semibold text-fg`,children:u.label}),t[19]=u.label,t[20]=x);let S;t[21]===u.detail?S=t[22]:(S=(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:u.detail}),t[21]=u.detail,t[22]=S);let C;t[23]!==x||t[24]!==S?(C=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[x,S]}),t[23]=x,t[24]=S,t[25]=C):C=t[25];let w;t[26]!==C||t[27]!==b?(w=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[b,C]}),t[26]=C,t[27]=b,t[28]=w):w=t[28];let T;t[29]===a?T=t[30]:(T=()=>{c(!1),a()},t[29]=a,t[30]=T);let E;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Q.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}),t[31]=E):E=t[31];let D;t[32]!==i.history||t[33]!==T?(D=(0,Q.jsxs)(J,{type:`button`,variant:`ghost`,className:`h-9 rounded-lg text-xs`,onClick:T,children:[E,i.history]}),t[32]=i.history,t[33]=T,t[34]=D):D=t[34];let O;t[35]!==r||t[36]!==d||t[37]!==o||t[38]!==f?(O=d?(0,Q.jsxs)(J,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg text-xs`,disabled:r,onClick:()=>{c(!1),o()},children:[(0,Q.jsx)(F,{className:`size-3.5`,"aria-hidden":!0}),f]}):null,t[35]=r,t[36]=d,t[37]=o,t[38]=f,t[39]=O):O=t[39];let A;t[40]!==D||t[41]!==O?(A=(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center justify-end gap-1 border-t border-edge-subtle pt-3`,children:[D,O]}),t[40]=D,t[41]=O,t[42]=A):A=t[42];let j;t[43]!==w||t[44]!==A?(j=(0,Q.jsx)(Y,{children:(0,Q.jsxs)(ce,{side:`bottom`,align:`end`,sideOffset:6,className:`z-[70] w-[min(21rem,calc(100vw-1.5rem))] rounded-xl border border-edge bg-surface-overlay p-4 text-sm text-fg shadow-popover outline-none`,onOpenAutoFocus:tt,children:[w,A]})}),t[43]=w,t[44]=A,t[45]=j):j=t[45];let M;return t[46]!==s||t[47]!==j||t[48]!==y?(M=(0,Q.jsxs)(le,{open:s,onOpenChange:c,children:[y,j]}),t[46]=s,t[47]=j,t[48]=y,t[49]=M):M=t[49],M}function tt(e){return e.preventDefault()}var nt=(0,Z.lazy)(()=>i(()=>import(`./workspace-file-preview-dialog-NffP-UXC.js`).then(e=>e.n).then(e=>({default:e.WorkspaceFilePreviewPanel})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76])));function rt(e){let t=(0,X.c)(31),{item:n,language:r,primary:i,showNew:a,onOpen:o}=e,s=a!==void 0&&a,c;t[0]===r?c=t[1]:(c=f(r),t[0]=r,t[1]=c);let l=c.projectsPage.home.workbench,u;t[2]===n.title?u=t[3]:(u=(0,Q.jsx)(`p`,{className:`break-words text-sm font-semibold text-fg`,children:n.title}),t[2]=n.title,t[3]=u);let d;t[4]!==l.newDelivery||t[5]!==s?(d=s?(0,Q.jsx)(`span`,{className:`mr-2 font-medium text-accent-fg`,children:l.newDelivery}):null,t[4]=l.newDelivery,t[5]=s,t[6]=d):d=t[6];let p;t[7]===n.completedAt?p=t[8]:(p=new Date(n.completedAt).toISOString(),t[7]=n.completedAt,t[8]=p);let m;t[9]!==n.completedAt||t[10]!==r?(m=Ee(new Date(n.completedAt),r),t[9]=n.completedAt,t[10]=r,t[11]=m):m=t[11];let h;t[12]!==p||t[13]!==m?(h=(0,Q.jsx)(`time`,{dateTime:p,children:m}),t[12]=p,t[13]=m,t[14]=h):h=t[14];let g;t[15]!==d||t[16]!==h?(g=(0,Q.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[d,h]}),t[15]=d,t[16]=h,t[17]=g):g=t[17];let _;t[18]===n.summary?_=t[19]:(_=n.summary?(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-1 break-words text-xs text-fg-muted`,children:n.summary}):null,t[18]=n.summary,t[19]=_);let v;t[20]!==u||t[21]!==g||t[22]!==_?(v=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 basis-48`,children:[u,g,_]}),t[20]=u,t[21]=g,t[22]=_,t[23]=v):v=t[23];let y=i?`primary`:`secondary`,b;t[24]!==l.openDelivery||t[25]!==o||t[26]!==y?(b=(0,Q.jsx)(J,{variant:y,className:`min-h-9 shrink-0 px-2.5 text-xs shadow-none`,onClick:o,children:l.openDelivery}),t[24]=l.openDelivery,t[25]=o,t[26]=y,t[27]=b):b=t[27];let x;return t[28]!==v||t[29]!==b?(x=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-3 py-3 sm:px-4`,children:[v,b]}),t[28]=v,t[29]=b,t[30]=x):x=t[30],x}function it({view:e,items:t,language:n,onSelect:r,onClose:i,onRead:a,onOpenFull:o,onRestoreFocus:s}){let c=f(n).projectsPage.home,[l,u]=(0,Z.useState)(!1),[d,m]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),S=(0,Z.useRef)(!1),C=e&&e!==`history`?e:null,{data:w,error:T,mutate:E}=H(C?[`home-delivery`,C.id]:null,async()=>{if(!C)return;if(C.kind===`automation`){let{run:e}=await ye.getRun(C.subjectId);return{kind:`automation`,summary:e.summary}}let e=await K(C.subjectId),t=e.receipts.find(e=>`task:${e.runId}`===C.id);if(!t)throw Error(c.workbench.deliveryFailed);return{kind:`task`,detail:e,receipt:t}},{shouldRetryOnError:!1}),D=w?.kind===`task`||!!w?.summary?.trim();async function O(e){if(!S.current){S.current=!0,u(!0),m(!1);try{e.kind===`automation`&&!e.read&&await ye.markRunRead(e.subjectId),a(e)}catch{m(!0)}finally{S.current=!1,u(!1)}}}return(0,Q.jsx)(y,{open:e!==null,onOpenChange:e=>{!e&&!S.current&&(m(!1),i())},children:(0,Q.jsxs)(g,{children:[(0,Q.jsx)(p,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim`}),(0,Q.jsxs)(_,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(36rem,calc(100dvh-2rem))] w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay outline-none`,"aria-describedby":void 0,onCloseAutoFocus:e=>{e.preventDefault(),s()},children:[(0,Q.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,Q.jsx)(v,{className:`truncate text-base font-semibold text-fg`,children:C?.title??c.workbench.deliveryHistory}),(0,Q.jsx)(h,{asChild:!0,children:(0,Q.jsx)(J,{variant:`ghost`,className:`size-9 p-0`,disabled:l,"aria-label":n===`zh`?`关闭`:`Close`,children:(0,Q.jsx)(L,{className:`size-4`})})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:e===`history`?t.length?(0,Q.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:t.map(e=>(0,Q.jsx)(rt,{item:e,language:n,onOpen:()=>{m(!1),r(e)}},e.id))}):(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.workbench.deliveryEmpty}):T?(0,Q.jsxs)(`div`,{role:`alert`,className:`space-y-2 text-sm text-danger`,children:[(0,Q.jsx)(`p`,{children:c.workbench.deliveryFailed}),(0,Q.jsx)(J,{variant:`secondary`,onClick:()=>void E(),children:c.retry})]}):w?w.kind===`task`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(je,{content:w.receipt.summary,contentKey:w.receipt.runId,language:n}),(0,Q.jsx)(Me,{evidence:w.receipt.evidence,projectId:w.detail.task.projectId,conversationId:w.detail.conversation.activeConversationId??void 0,language:n,onOpenFile:x}),(0,Q.jsx)(y,{open:b!==null,onOpenChange:e=>{e||x(null)},children:(0,Q.jsxs)(g,{children:[(0,Q.jsx)(p,{className:`fixed inset-0 z-[90] bg-scrim`}),(0,Q.jsxs)(_,{className:`fixed left-1/2 top-1/2 z-[100] flex h-[min(54rem,calc(100dvh-2rem))] w-[min(72rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel outline-none`,"aria-describedby":void 0,children:[(0,Q.jsx)(v,{className:`sr-only`,children:b}),(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(z,{className:`m-4 min-h-24`}),children:(0,Q.jsx)(nt,{filePath:b,projectId:w.detail.task.projectId,conversationId:w.detail.conversation.activeConversationId,onClose:()=>x(null)})})]})]})})]}):w.kind===`automation`&&w.summary?(0,Q.jsx)(j,{content:w.summary}):(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.workbench.noSummary}):(0,Q.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Q.jsx)(z,{className:`h-5 w-2/3`}),(0,Q.jsx)(z,{className:`h-24`})]})}),C?(0,Q.jsxs)(`footer`,{className:`shrink-0 space-y-2 border-t border-edge px-4 py-3`,children:[d?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:c.workbench.readFailed}):null,(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,Q.jsx)(J,{variant:`ghost`,disabled:l,onClick:()=>o(C),children:c.workbench.openFullResult}),(0,Q.jsx)(J,{variant:`primary`,disabled:!!T||!D||l,onClick:()=>void O(C),children:c.workbench.markRead})]})]}):null]})]})})}function at(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var ot=`xopc-home-read-deliveries`;function st(){try{let e=JSON.parse(localStorage.getItem(ot)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`).slice(0,300):[]}catch{return[]}}function ct(){let e=(0,X.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsxs)(`div`,{className:`space-y-8`,"aria-busy":!0,children:[(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(z,{className:`h-10 w-3/5 rounded-xl`}),(0,Q.jsx)(z,{className:`h-5 w-4/5 rounded-lg`})]}),(0,Q.jsx)(z,{className:`h-64 rounded-2xl`}),(0,Q.jsx)(z,{className:`h-32 rounded-xl`})]}),e[0]=t):t=e[0],t}function lt(e){let t=(0,X.c)(91),{item:n,busy:r,primary:i,dueLabel:a,failureLabel:s,locale:c,onAction:l,onComplete:u,onUpdated:d}=e,[p,m]=o(),h;t[0]===n.openAction?h=t[1]:(h=n.openAction?.type===`open`?/^\/tasks\/([^/?#]+)/.exec(n.openAction.href):null,t[0]=n.openAction,t[1]=h);let g=h,_=n.primaryAction?.type===`task_review`?n.primaryAction.taskId:g?decodeURIComponent(g[1]):void 0,v;t[2]!==_||t[3]!==p?(v=_&&p.get(`reviewTask`)===_,t[2]=_,t[3]=p,t[4]=v):v=t[4];let y=!!v,b;t[5]!==_||t[6]!==p||t[7]!==m?(b=e=>{let t=new URLSearchParams(p);e&&_?t.set(`reviewTask`,_):t.delete(`reviewTask`),m(t)},t[5]=_,t[6]=p,t[7]=m,t[8]=b):b=t[8];let x=b,[S,C]=(0,Z.useState)(!1),w;t[9]===c?w=t[10]:(w=f(c),t[9]=c,t[10]=w);let T=w.projectsPage.home.workbench,E=n.primaryAction?.type===`connector_decision`,D;t[11]!==a||t[12]!==n.dueAt||t[13]!==c?(D=n.dueAt===void 0?null:`${a} ${Ee(n.dueAt,c)}`,t[11]=a,t[12]=n.dueAt,t[13]=c,t[14]=D):D=t[14];let O=D,k;t[15]!==E||t[16]!==n.summary?(k=E?n.summary.split(`
|
|
3
|
-
`)[0]:n.summary,t[15]=E,t[16]=n.summary,t[17]=k):k=t[17];let A;t[18]!==n.projectName||t[19]!==k?(A=[n.projectName,k].filter(Boolean),t[18]=n.projectName,t[19]=k,t[20]=A):A=t[20];let j=A.join(` · `),M=!!(_&&(n.primaryAction?.type===`task_review`||n.primaryAction?.type===`open`)),N;t[21]!==n.id||t[22]!==n.openAction||t[23]!==n.title||t[24]!==l?(N=n.openAction?(0,Q.jsx)(`button`,{type:`button`,className:`break-words text-left text-sm font-semibold text-fg hover:underline`,onClick:()=>l(n.openAction,n.id),children:n.title}):(0,Q.jsx)(`span`,{className:`break-words text-sm font-semibold text-fg`,children:n.title}),t[21]=n.id,t[22]=n.openAction,t[23]=n.title,t[24]=l,t[25]=N):N=t[25];let P;t[26]!==O||t[27]!==s||t[28]!==n.kind?(P=O||n.kind===`failure`?(0,Q.jsx)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-xs text-warning`,children:O??s}):null,t[26]=O,t[27]=s,t[28]=n.kind,t[29]=P):P=t[29];let F;t[30]!==N||t[31]!==P?(F=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1`,children:[N,P]}),t[30]=N,t[31]=P,t[32]=F):F=t[32];let I;t[33]===j?I=t[34]:(I=(0,Q.jsx)(`p`,{className:`mt-0.5 line-clamp-2 break-words text-xs text-fg-muted`,children:j}),t[33]=j,t[34]=I);let ee;t[35]!==F||t[36]!==I?(ee=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 basis-52`,children:[F,I]}),t[35]=F,t[36]=I,t[37]=ee):ee=t[37];let te;t[38]!==n.primaryAction?.type||t[39]!==c||t[40]!==y||t[41]!==_||t[42]!==x?(te=_&&n.primaryAction?.type===`retry_task`?(0,Q.jsx)(J,{variant:`ghost`,className:`min-h-9 px-2 text-xs`,"aria-expanded":y,onClick:()=>x(!y),children:c===`zh`?`查看结果与依据`:`View result and evidence`}):null,t[38]=n.primaryAction?.type,t[39]=c,t[40]=y,t[41]=_,t[42]=x,t[43]=te):te=t[43];let L;t[44]!==E||t[45]!==r||t[46]!==M||t[47]!==n.id||t[48]!==n.primaryAction||t[49]!==l||t[50]!==i||t[51]!==y||t[52]!==S||t[53]!==x||t[54]!==T?(L=n.primaryAction?(0,Q.jsx)(J,{type:`button`,variant:i?`primary`:`secondary`,className:`min-h-9 shrink-0 px-2.5 text-xs shadow-none`,disabled:r,"aria-expanded":E?S:M?y:void 0,onClick:()=>{E?C(dt):M?x(!y):l(n.primaryAction,n.id)},children:E?T.viewScope:n.primaryAction.label}):null,t[44]=E,t[45]=r,t[46]=M,t[47]=n.id,t[48]=n.primaryAction,t[49]=l,t[50]=i,t[51]=y,t[52]=S,t[53]=x,t[54]=T,t[55]=L):L=t[55];let R;t[56]!==te||t[57]!==L?(R=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[te,L]}),t[56]=te,t[57]=L,t[58]=R):R=t[58];let z;t[59]!==ee||t[60]!==R?(z=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[ee,R]}),t[59]=ee,t[60]=R,t[61]=z):z=t[61];let B;t[62]!==E||t[63]!==r||t[64]!==n.id||t[65]!==n.primaryAction||t[66]!==n.secondaryActions||t[67]!==n.summary||t[68]!==l||t[69]!==S?(B=E&&S?(0,Q.jsxs)(`div`,{className:`mt-3 space-y-2 rounded-lg bg-surface-inset px-3 py-2`,children:[(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-xs text-fg-muted`,children:n.summary}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(J,{variant:`primary`,disabled:r,onClick:()=>l(n.primaryAction,n.id),children:n.primaryAction?.label}),n.secondaryActions.map(e=>(0,Q.jsx)(J,{disabled:r,onClick:()=>l(e,n.id),children:e.label},e.label))]})]}):null,t[62]=E,t[63]=r,t[64]=n.id,t[65]=n.primaryAction,t[66]=n.secondaryActions,t[67]=n.summary,t[68]=l,t[69]=S,t[70]=B):B=t[70];let V;t[71]!==E||t[72]!==r||t[73]!==M||t[74]!==n.id||t[75]!==n.secondaryActions||t[76]!==l?(V=!E&&!M&&n.secondaryActions.length?(0,Q.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:n.secondaryActions.filter(ut).map(e=>(0,Q.jsx)(J,{variant:`ghost`,disabled:r,onClick:()=>l(e,n.id),children:e.label},e.label))}):null,t[71]=E,t[72]=r,t[73]=M,t[74]=n.id,t[75]=n.secondaryActions,t[76]=l,t[77]=V):V=t[77];let H;t[78]!==c||t[79]!==u||t[80]!==d||t[81]!==y||t[82]!==_||t[83]!==x?(H=y&&_?(0,Q.jsx)(Oe,{taskId:_,language:c,onUpdated:d,onComplete:()=>{x(!1),u()}},_):null,t[78]=c,t[79]=u,t[80]=d,t[81]=y,t[82]=_,t[83]=x,t[84]=H):H=t[84];let U;return t[85]!==r||t[86]!==z||t[87]!==B||t[88]!==V||t[89]!==H?(U=(0,Q.jsxs)(`article`,{className:`px-3 py-3 sm:px-4`,"aria-busy":r,children:[z,B,V,H]}),t[85]=r,t[86]=z,t[87]=B,t[88]=V,t[89]=H,t[90]=U):U=t[90],U}function ut(e){return e.type!==`open`}function dt(e){return!e}function ft(e){let t=(0,X.c)(39),{item:n,onAction:r,language:i,onUpdated:a}=e,[o,s]=(0,Z.useState)(!1),c;t[0]===n.openAction?c=t[1]:(c=n.openAction?.type===`open`?/^\/tasks\/([^/?#]+)/.exec(n.openAction.href):null,t[0]=n.openAction,t[1]=c);let l=c,u=l?decodeURIComponent(l[1]):void 0,d;t[2]!==n.backgroundState||t[3]!==n.kind?(d=n.kind===`scheduled`?(0,Q.jsx)(b,{className:`size-4`,"aria-hidden":!0}):n.backgroundState===`paused`?(0,Q.jsx)(E,{className:`size-4`,"aria-hidden":!0}):(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-fg-subtle`,"aria-hidden":!0}),t[2]=n.backgroundState,t[3]=n.kind,t[4]=d):d=t[4];let f=d,p=!n.openAction,m=u?o:void 0,h;t[5]!==n.id||t[6]!==n.openAction||t[7]!==r||t[8]!==u?(h=()=>u?s(pt):n.openAction&&r(n.openAction,n.id),t[5]=n.id,t[6]=n.openAction,t[7]=r,t[8]=u,t[9]=h):h=t[9];let g;t[10]===f?g=t[11]:(g=(0,Q.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-fg-muted`,children:f}),t[10]=f,t[11]=g);let _;t[12]===n.title?_=t[13]:(_=(0,Q.jsx)(`span`,{className:`block line-clamp-2 break-words text-sm font-medium text-fg`,children:n.title}),t[12]=n.title,t[13]=_);let v;t[14]!==n.kind||t[15]!==n.summary||t[16]!==n.updatedAt||t[17]!==i?(v=n.kind===`scheduled`?(0,Q.jsx)(`time`,{className:`block text-xs text-fg-muted`,dateTime:new Date(n.updatedAt).toISOString(),children:Ee(n.updatedAt,i)}):(0,Q.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:n.summary}),t[14]=n.kind,t[15]=n.summary,t[16]=n.updatedAt,t[17]=i,t[18]=v):v=t[18];let y;t[19]!==_||t[20]!==v?(y=(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[_,v]}),t[19]=_,t[20]=v,t[21]=y):y=t[21];let x;t[22]===n.openAction?x=t[23]:(x=n.openAction?(0,Q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-0.5 text-xs text-accent-fg`,children:[(0,Q.jsx)(`span`,{children:n.openAction.label}),(0,Q.jsx)(C,{className:`size-3.5`,"aria-hidden":!0})]}):null,t[22]=n.openAction,t[23]=x);let S;t[24]!==x||t[25]!==p||t[26]!==m||t[27]!==h||t[28]!==g||t[29]!==y?(S=(0,Q.jsxs)(`button`,{type:`button`,className:`flex min-h-11 w-full items-center gap-2 rounded-md px-1 py-2 text-left hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,disabled:p,"aria-expanded":m,onClick:h,children:[g,y,x]}),t[24]=x,t[25]=p,t[26]=m,t[27]=h,t[28]=g,t[29]=y,t[30]=S):S=t[30];let w;t[31]!==o||t[32]!==i||t[33]!==a||t[34]!==u?(w=u&&o?(0,Q.jsx)(Oe,{taskId:u,language:i,onUpdated:a,onComplete:()=>s(!1)}):null,t[31]=o,t[32]=i,t[33]=a,t[34]=u,t[35]=w):w=t[35];let T;return t[36]!==S||t[37]!==w?(T=(0,Q.jsxs)(`div`,{children:[S,w]}),t[36]=S,t[37]=w,t[38]=T):T=t[38],T}function pt(e){return!e}function mt(){let e=u(e=>e.language),t=f(e),n=t.projectsPage,r=he(e),i=c(),o=a(),s=ve(e=>e.setPageHeader),l=ve(e=>e.clearPageHeader),[d,b]=(0,Z.useState)(!1),{home:C,loading:T,loadError:E,setLoadError:D,load:O}=Pe(e,o.key,!0),k=n.home.workbench,j=(0,Z.useRef)(null),[M,N]=(0,Z.useState)(null),[F,ee]=(0,Z.useState)(st),R=(0,Z.useRef)(null),[z,B]=(0,Z.useState)(!1),[V,H]=(0,Z.useState)(!1),[K,q]=(0,Z.useState)(``),ne=(0,Z.useRef)(!1),[Y,ce]=(0,Z.useState)(),[le,ue]=(0,Z.useState)(!1),[de,me]=(0,Z.useState)(null),[ye,xe]=(0,Z.useState)(!1),[Ce,Oe]=(0,Z.useState)(),[ke,Ae]=(0,Z.useState)(!1),[je,Me]=(0,Z.useState)(0),[Ne,X]=(0,Z.useState)(),[Fe,Le]=(0,Z.useState)(),[Re,ze]=(0,Z.useState)(!1),$=Se({chat:t.chat}),Be=(0,Z.useRef)(null),Ve=_e({disabled:Re,chat:t.chat,onTranscript:e=>{q(t=>fe(t,e)),window.setTimeout(()=>Be.current?.focus(),0)}}),{phase:He,voiceActive:We,startVoiceInput:Ke,cancelVoiceInput:qe,confirmVoiceInput:Je,retryVoiceInput:Xe}=Ve;(0,Z.useEffect)(()=>{if(!Ne)return;let e=window.setTimeout(()=>X(void 0),8e3);return()=>window.clearTimeout(e)},[Ne]);let Ze=(0,Z.useCallback)(async e=>{if(!(e.length===0||Re)){ze(!0);try{await $.processFiles(e)}finally{ze(!1)}}},[Re,$.processFiles]),Qe=(0,Z.useCallback)(async e=>{let t=pe(e.clipboardData);t.length!==0&&(e.preventDefault(),await Ze(t))},[Ze]),$e=(0,Z.useCallback)(e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,$.setIsDragging(!0))},[$.setIsDragging]),tt=(0,Z.useCallback)(e=>{let t=e.relatedTarget;(!(t instanceof Node)||!e.currentTarget.contains(t))&&$.setIsDragging(!1)},[$.setIsDragging]),nt=(0,Z.useCallback)(async e=>{e.preventDefault(),$.setIsDragging(!1),await Ze(Array.from(e.dataTransfer.files))},[$.setIsDragging,Ze]),ut=(0,Z.useCallback)(e=>{e.preventDefault();let t=$.wireAttachmentsPayload(),n=t.length>0?ge(t):void 0,r=be(K,n,{projectScope:`none`});r&&(H(!1),q(``),$.clearAttachments(),i(r))},[$.clearAttachments,$.wireAttachmentsPayload,K,i]),dt=$.attachments.length>=10,pt={attachTitle:dt?at(t.chat.maxAttachmentsReached,{max:10}):`${t.chat.attachFile} (${$.attachments.length}/10)`,dropFiles:t.chat.dropFiles,intentLabel:r.intentLabel,intentPlaceholder:r.intentPlaceholder,intentSuggestion:r.intentSuggestion,shortcut:n.home.submitShortcut,submit:r.newWork},mt=(0,Z.useMemo)(()=>({label:n.home.advisorStatusLabel,ready:n.home.advisorStatusReady,clarification:n.home.advisorStatusClarification,refreshing:n.home.advisorStatusRefreshing,refreshingDetail:n.home.advisorRefreshing,idle:n.home.advisorStatusIdle,idleDetail:n.home.advisorUnavailableTitle,generationFailed:n.home.advisorStatusGenerationFailed,budgetExhausted:n.home.advisorStatusBudgetExhausted,modelUnavailable:n.home.advisorStatusModelUnavailable,generationFailedDetail:n.home.advisorGenerationFailed,budgetExhaustedDetail:n.home.advisorBudgetExhausted,modelUnavailableDetail:n.home.advisorModelUnavailable,history:n.home.advisorHistory,retry:n.home.retry,findAnother:n.home.advisorRefresh}),[n.home]),ht=(C?.recentDeliveries??[]).map(e=>F.includes(e.id)?{...e,read:!0}:e),gt=Date.now(),_t=ht.filter(e=>!e.read&&e.completedAt>=gt-10080*6e4),vt=C?.resumable??[],yt=(C?.needsUser.length??0)+(C?.attentionPolicy?.suppressedAttentionCount??0)+(C?.attentionPolicy?.suppressedDecisionCount??0),bt=new Date(gt);bt.setHours(24,0,0,0);let xt=C?.needsUser.filter(e=>e.dueAt!==void 0&&e.dueAt>=gt&&e.dueAt<bt.getTime()).length??0,St=C?.background??[],Ct=St.filter(e=>e.kind!==`scheduled`),wt=St.filter(e=>e.kind===`scheduled`),Tt=C?.advisor.state===`ready`||C?.advisor.state===`clarification`||!!Ce;(0,Z.useEffect)(()=>{if(!Ce)return;let e=window.setTimeout(()=>Oe(void 0),8e3);return()=>window.clearTimeout(e)},[Ce]);let Et=C?yt>0?`attention`:_t.length>0?`delivery`:vt.length>0||Ct.length>0||C.runningConversations?.length||Tt?`resume`:`idle`:void 0,Dt=Et===`idle`,Ot=Dt&&!V,kt=Ot||V,At=(0,Z.useRef)(Et),jt=(0,Z.useRef)(!1);(0,Z.useLayoutEffect)(()=>{let e=At.current;if(At.current=Et,!e||!Et||Et===e||(jt.current&&(jt.current=!1,document.activeElement===document.body&&j.current?.focus({preventScroll:!0})),window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches))return;let t=j.current?.animate?.([{opacity:.7,transform:`translateY(4px)`},{opacity:1,transform:`translateY(0)`}],{duration:180,easing:`ease-out`});return()=>t?.cancel()},[Et]),(0,Z.useEffect)(()=>{let e=e=>{(e.key===ot||e.key===null)&&ee(st())};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]);let Mt=(0,Z.useCallback)(e=>{ee(t=>[...new Set([e,...t])].slice(0,300));try{localStorage.setItem(ot,JSON.stringify([...new Set([e,...st()])].slice(0,300)))}catch{}},[]);(0,Z.useEffect)(()=>{!kt&&We&&qe()},[qe,kt,We]),(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail?.target;t&&t!==`chat`||!kt||Re||(e.preventDefault(),He===`recording`?Je():He===`idle`?(Be.current?.focus(),Ke()):He===`error`&&Xe())},t=e=>{let t=e.detail?.target;t&&t!==`chat`||!kt||!We||(e.preventDefault(),qe(),Be.current?.focus())};return window.addEventListener(Te,e),window.addEventListener(we,t),()=>{window.removeEventListener(Te,e),window.removeEventListener(we,t)}},[Re,qe,kt,Je,Xe,Ke,We,He]);let Nt=(0,Z.useCallback)(e=>{e||qe(),H(e)},[qe]),Pt=(0,Z.useCallback)((t,n)=>{if(t.type===`open`){i(A(`/`,t.href));return}if(t.type===`task_review`||ne.current)return;ne.current=!0,me(n);let r=C?.needsUser.findIndex(e=>e.id===n)??-1,a=r<0?void 0:{item:C?.needsUser[r],slot:r};ce(void 0),D(null),(async()=>{try{if(t.type===`retry_task`)await De(t.taskId,e),ce({...a,message:e===`zh`?`任务已重新开始,可查看执行进度。`:`Task restarted. View progress.`,href:A(`/`,`/tasks/${encodeURIComponent(t.taskId)}`)});else if(t.type===`connector_decision`)await se({kind:`connector_approval`,approvalId:t.approvalId},t.decision),ce({...a,message:e===`zh`?t.decision===`approve`?`已批准授权,任务状态将自动更新。`:`已拒绝授权。`:t.decision===`approve`?`Permission approved. Task status will update.`:`Permission denied.`});else if(t.type===`retry_run`){let n=await W({kind:t.subjectKind,runId:t.runId});ce({...a,message:e===`zh`?`已发起重试,可查看新的执行结果。`:`Retry started. Follow the new execution.`,href:n.conversationId?`/chat/${encodeURIComponent(n.conversationId)}`:`/automations?run=${encodeURIComponent(n.runId)}`})}else t.type===`acknowledge_run`&&(await ie({kind:t.subjectKind,runId:t.runId}),ce({...a,message:e===`zh`?`已确认此异常,已从待处理事项移除。`:`Issue acknowledged and removed from pending items.`}));jt.current=!0,await O()}catch(e){D(e instanceof Error?e.message:String(e))}finally{ne.current=!1,me(null)}})()},[C,e,O,i]),Ft=(0,Z.useCallback)((t,n)=>{let r=t.task.phase===`closed`&&t.task.resolution===`done`?re(t):void 0;r&&Mt(`task:${r.runId}`),jt.current=!0;let i=n?C?.needsUser.findIndex(e=>e.id===n.id):void 0;ce({item:n,slot:i,message:e===`zh`?t.task.phase===`closed`?`任务已验收完成。`:`操作已保存,任务状态已更新。`:t.task.phase===`closed`?`Task accepted.`:`Action saved. Task status updated.`,href:A(`/`,`/tasks/${encodeURIComponent(t.task.id)}`)}),O()},[C,e,O,Mt]),It=(0,Z.useCallback)(()=>{xe(!0),Oe(void 0),Le(void 0),D(null),ae(e).then(()=>O()).catch(e=>D(e instanceof Error?e.message:String(e))).finally(()=>xe(!1))},[e,O]),Lt=(0,Z.useCallback)((e,t)=>{xe(!0),D(null),G(e,t).then(async t=>{if(t.outcome===`needs_setup`){Le({opportunityId:e.id,value:t.preflight});return}if(Le(void 0),Me(e=>e+1),t.outcome===`task`){Oe({title:n.home.advisorStartedTitle,detail:at(n.home.advisorStartedDetail,{title:e.title}),href:A(`/`,t.href)}),await O();return}i(t.href)}).catch(e=>D(e instanceof Error?e.message:String(e))).finally(()=>xe(!1))},[O,i,n.home.advisorStartedDetail,n.home.advisorStartedTitle]),Rt=(0,Z.useCallback)((e,t)=>{xe(!0),Oe(void 0),Le(void 0),D(null),U(e,{kind:t,snoozedUntil:t===`too_early`?Date.now()+4320*6e4:void 0}).then(({idempotencyKey:t})=>(X({opportunityId:e.id,idempotencyKey:t}),Me(e=>e+1),O())).catch(e=>D(e instanceof Error?e.message:String(e))).finally(()=>xe(!1))},[O]),zt=(0,Z.useCallback)(()=>{if(!Ne)return;let e=Ne;X(void 0),xe(!0),D(null),oe(e.opportunityId,e.idempotencyKey).then(()=>(Me(e=>e+1),O())).catch(t=>{X(e),D(t instanceof Error?t.message:String(t))}).finally(()=>xe(!1))},[Ne,O]),Bt=(0,Z.useCallback)((e,t)=>{i(`/chat/new?${new URLSearchParams({draft:`${e}\n\n${t}`}).toString()}`)},[i]),Vt=(0,Z.useMemo)(()=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[C&&!Dt?(0,Q.jsx)(et,{advisor:C.advisor,busy:ye,copy:mt,onOpenHistory:()=>Ae(!0),onRefresh:It}):null,Dt?null:(0,Q.jsxs)(J,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:()=>H(!0),children:[(0,Q.jsx)(P,{className:`size-4`,"aria-hidden":!0}),r.newWork]})]}),[ye,mt,r.newWork,C,Dt,It]);(0,Z.useLayoutEffect)(()=>(s({startExtra:null,main:(0,Q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),end:Vt}),()=>l()),[l,Vt,s,n.title]);let Ht=e=>{R.current=document.activeElement instanceof HTMLElement?document.activeElement:null,N(e)},Ut=e=>{Mt(e.id),N(null),ce({message:k.deliverySaved}),O()},Wt=d?C?.needsUser??[]:C?.needsUser.slice(0,2)??[],Gt=yt-Wt.length,Kt=Y?.item&&!C?.needsUser.some(e=>e.id===Y.item?.id)&&(Y.slot??1/0)<2?Y.item:void 0,qt=[...Wt];Kt&&qt.splice(Y?.slot??0,0,Kt);let Jt=(C?.runningConversations??[]).map(t=>({id:t.runId,kind:`running`,title:t.title??(e===`zh`?`对话正在执行`:`Conversation in progress`),summary:k.inProgress,updatedAt:t.updatedAt,secondaryActions:[],openAction:{type:`open`,label:k.inProgress,href:`/chat/${encodeURIComponent(t.conversationId)}`}})),Yt=[...Ct,...Jt].sort((e,t)=>t.updatedAt-e.updatedAt),Xt=Et===`attention`&&!Ce&&!z,Zt=C?.advisor.state===`ready`?C.advisor.primary.title:C?.advisor.state===`clarification`?C.advisor.question.question:void 0,Qt=_t.length>0?(0,Q.jsxs)(`section`,{className:`space-y-2`,"aria-labelledby":`home-delivery-title`,children:[(0,Q.jsxs)(`div`,{className:`flex min-h-9 flex-wrap items-center justify-between gap-x-3`,children:[(0,Q.jsx)(`h2`,{id:`home-delivery-title`,className:`text-base font-semibold text-fg`,children:k.progress}),(0,Q.jsx)(J,{variant:`ghost`,className:`px-2 text-xs`,onClick:()=>Ht(`history`),children:k.deliveryHistory})]}),(0,Q.jsx)(`div`,{className:`divide-y divide-edge-subtle rounded-xl border border-edge-subtle bg-surface-panel`,children:_t.slice(0,Et===`attention`?1:3).map((t,n)=>(0,Q.jsx)(rt,{item:t,language:e,showNew:!0,primary:Et===`delivery`&&n===0,onOpen:()=>Ht(t)},t.id))})]}):null,$t=[{title:k.inProgress,items:Yt.filter(e=>!e.backgroundState&&!e.statusLabel)},{title:k.waiting,items:Yt.filter(e=>e.backgroundState===`waiting`||!e.backgroundState&&e.statusLabel)},{title:k.paused,items:Yt.filter(e=>e.backgroundState===`paused`)},{title:k.scheduled,items:wt}].filter(e=>e.items.length>0),en=Et===`attention`?1:3,tn=$t.length?(0,Q.jsxs)(`section`,{className:`min-w-0 space-y-2`,"aria-labelledby":`home-background-title`,children:[(0,Q.jsx)(`div`,{className:`flex min-h-9 items-center`,children:(0,Q.jsx)(`h2`,{id:`home-background-title`,className:`text-base font-semibold text-fg`,children:k.background})}),(0,Q.jsxs)(`div`,{className:`divide-y divide-edge-subtle rounded-xl border border-edge-subtle bg-surface-panel`,children:[$t.map(({title:t,items:n})=>(0,Q.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,Q.jsx)(`h3`,{className:`px-1 pt-1 text-xs font-medium text-fg-muted`,children:t}),(0,Q.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:(le?n:n.slice(0,en)).map(t=>(0,Q.jsx)(ft,{item:t,language:e,onAction:Pt,onUpdated:Ft},t.id))})]},t)),$t.some(({items:e})=>e.length>en)?(0,Q.jsx)(J,{variant:`ghost`,className:`w-full justify-start rounded-t-none px-4 text-xs`,"aria-expanded":le,onClick:()=>ue(e=>!e),children:e===`zh`?le?`收起`:`查看全部 ${Yt.length+wt.length} 项`:le?`Show less`:`View all ${Yt.length+wt.length} items`}):null]})]}):null,nn=yt>0||_t.length>0||vt.length>0||Tt||!!C?.observation;return(0,Q.jsxs)(`div`,{className:`@container/workbench mx-auto flex w-full min-w-0 max-w-7xl flex-1 flex-col px-4 pb-6 pt-3 sm:px-6 lg:px-8`,children:[(0,Q.jsx)(`input`,{ref:$.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{let t=e.target.files;t&&Ze(Array.from(t)),e.target.value=``}}),(0,Q.jsx)(y,{open:V,onOpenChange:Nt,children:(0,Q.jsxs)(g,{children:[(0,Q.jsx)(p,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(_,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(31rem,calc(100dvh-1.5rem))] w-[min(36rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start gap-4 border-b border-edge px-5 py-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(v,{className:`text-base font-semibold text-fg`,children:r.dialogTitle}),(0,Q.jsx)(m,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:r.dialogDescription})]}),(0,Q.jsx)(h,{asChild:!0,children:(0,Q.jsx)(J,{type:`button`,variant:`ghost`,className:`-mr-2 -mt-1 size-8 shrink-0 rounded-lg p-0`,title:n.cancel,"aria-label":n.cancel,children:(0,Q.jsx)(L,{className:`size-4`,"aria-hidden":!0})})})]}),(0,Q.jsx)(Ie,{variant:`dialog`,inputId:`new-conversation-intent`,inputRef:Be,intent:K,labels:{...pt,submit:r.submit},attachments:$.attachments,isDragging:$.isDragging,attachmentBusy:Re,attachmentsFull:dt,voice:Ve,chat:t.chat,cancelAction:(0,Q.jsx)(h,{asChild:!0,children:(0,Q.jsx)(J,{type:`button`,variant:`ghost`,children:n.cancel})}),onIntentChange:q,onPickFiles:()=>$.fileInputRef.current?.click(),onRemoveAttachment:$.removeAttachment,onPaste:e=>void Qe(e),onDragOver:$e,onDragLeave:tt,onDrop:e=>void nt(e),onSubmit:ut})]})]})}),(0,Q.jsx)(Ye,{open:ke,refreshKey:je,onOpenChange:Ae,onReevaluate:It}),E?(0,Q.jsxs)(`div`,{role:`alert`,className:`mb-6 flex items-center justify-between gap-3 rounded-xl border border-danger/25 bg-danger-soft px-4 py-3 text-sm text-danger`,children:[(0,Q.jsx)(`span`,{children:E}),(0,Q.jsx)(J,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void O(),children:n.home.retry})]}):null,(0,Q.jsx)(it,{view:M,items:ht,language:e,onSelect:N,onClose:()=>N(null),onRead:Ut,onOpenFull:e=>{N(null),i(A(`/`,e.href))},onRestoreFocus:()=>{(R.current?.isConnected?R.current:j.current)?.focus({preventScroll:!0})}}),(0,Q.jsx)(`div`,{role:`status`,children:Y?(0,Q.jsxs)(`div`,{className:`mb-3 flex w-full flex-wrap items-center justify-between gap-2 rounded-lg bg-success-soft px-3 py-1.5 text-xs text-fg`,children:[(0,Q.jsx)(`span`,{children:Y.message}),Y.href?(0,Q.jsx)(J,{variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>i(Y.href),children:e===`zh`?`查看进展与结果`:`View progress and result`}):null]}):null}),T?(0,Q.jsx)(ct,{}):C?(0,Q.jsxs)(`div`,{ref:j,tabIndex:-1,className:`flex min-h-0 w-full flex-1 flex-col gap-4 outline-none`,children:[yt===0?(0,Q.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,"aria-live":`polite`,children:k.noAttention}):null,Ot?(0,Q.jsxs)(`section`,{className:`mx-auto flex w-full max-w-[640px] flex-1 flex-col justify-center pb-12 pt-10 text-center sm:pb-20 sm:pt-16`,children:[(0,Q.jsx)(`h2`,{className:`text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:k.startTitle}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:k.startHint}),(0,Q.jsx)(Ie,{variant:`inline`,inputId:`home-conversation-intent`,inputRef:Be,intent:K,labels:{...pt,intentPlaceholder:k.startExample},attachments:$.attachments,isDragging:$.isDragging,attachmentBusy:Re,attachmentsFull:dt,voice:Ve,chat:t.chat,onIntentChange:q,onPickFiles:()=>$.fileInputRef.current?.click(),onRemoveAttachment:$.removeAttachment,onPaste:e=>void Qe(e),onDragOver:$e,onDragLeave:tt,onDrop:e=>void nt(e),onSubmit:ut}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-center gap-2`,children:[(0,Q.jsxs)(J,{variant:`ghost`,onClick:()=>window.dispatchEvent(new Event(`open-command-palette`)),children:[(0,Q.jsx)(I,{className:`size-4`,"aria-hidden":!0}),k.findWork]}),(0,Q.jsx)(J,{variant:`ghost`,onClick:()=>Ht(`history`),children:k.deliveryHistory})]})]}):null,(0,Q.jsxs)(`div`,{className:nn&&tn?`grid min-w-0 items-start gap-5 @min-[56rem]/workbench:grid-cols-[minmax(0,1fr)_minmax(17rem,0.57fr)]`:`grid min-w-0 gap-4`,children:[nn?(0,Q.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[yt>0?(0,Q.jsxs)(`section`,{className:`space-y-2`,"aria-labelledby":`home-needs-user-title`,children:[(0,Q.jsxs)(`div`,{className:`flex min-h-9 flex-wrap items-center gap-2`,children:[(0,Q.jsx)(w,{className:`size-4 text-warning`,"aria-hidden":!0}),(0,Q.jsx)(`h2`,{id:`home-needs-user-title`,className:`text-base font-semibold text-fg`,children:k.attention}),(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-inset px-1.5 py-0.5 text-xs font-medium tabular-nums text-fg-muted`,"aria-live":`polite`,"aria-label":at(n.home.attentionTitle,{count:yt}),children:yt}),xt>0?(0,Q.jsx)(`span`,{className:`text-xs text-warning`,children:at(k.dueToday,{count:xt})}):null]}),(0,Q.jsxs)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,children:[qt.map((t,i)=>t===Kt?(0,Q.jsxs)(`div`,{className:`flex min-h-16 items-center justify-between gap-3 px-4 py-3 text-sm text-fg-muted`,children:[(0,Q.jsx)(`span`,{children:t.title}),(0,Q.jsx)(x,{className:`size-4 shrink-0 text-success`,"aria-label":e===`zh`?`已处理`:`Handled`})]},t.id):(0,Q.jsx)(lt,{item:t,primary:i===0||i===1&&qt[0]===Kt,busy:de!==null,dueLabel:n.home.dueLabel,failureLabel:r.runAttention,locale:e,onAction:Pt,onComplete:()=>void O(),onUpdated:e=>Ft(e,t)},t.id)),d||Gt>0?(0,Q.jsxs)(J,{variant:`ghost`,className:`w-full justify-start rounded-t-none px-4 text-xs`,"aria-expanded":d,onClick:()=>b(e=>!e),children:[(0,Q.jsx)(S,{className:d?`size-4 rotate-180`:`size-4`,"aria-hidden":!0}),d?k.collapse:at(k.remaining,{count:Gt})]}):null]})]}):null,Qt,vt.length>0||Tt||C.observation?(0,Q.jsxs)(`section`,{className:`space-y-2`,"aria-labelledby":`home-resume-title`,children:[(0,Q.jsx)(`h2`,{id:`home-resume-title`,className:`flex min-h-9 items-center text-base font-semibold text-fg`,children:k.resume}),vt.length>0?(0,Q.jsx)(`div`,{className:`divide-y divide-edge-subtle rounded-xl border border-edge-subtle bg-surface-panel`,children:vt.slice(0,Et===`attention`?1:3).map(t=>(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 basis-48`,children:[(0,Q.jsx)(`p`,{className:`break-words text-sm font-semibold text-fg`,children:t.title}),(0,Q.jsx)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:[t.projectName,t.summary||at(k.lastActive,{time:Ee(t.updatedAt,e)})].filter(Boolean).join(` · `)})]}),(0,Q.jsx)(J,{variant:`secondary`,onClick:()=>i(A(`/`,t.href)),children:t.kind===`task`?k.continueTask:k.continueChat})]},`${t.kind}:${t.id}`))}):null,C.observation?(0,Q.jsx)(Ge,{observation:C.observation,advisor:C.advisor,language:e,onUpdated:()=>void O()}):null,!C.observation&&Zt&&Et===`attention`&&!Ce?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-lg bg-surface-inset px-3 py-1`,children:[(0,Q.jsxs)(`p`,{className:`flex min-w-0 flex-1 items-center gap-2 text-xs text-fg-muted`,children:[(0,Q.jsx)(te,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{className:`truncate`,children:[n.home.advisorStatusLabel,` · `,Zt]})]}),(0,Q.jsx)(J,{variant:`ghost`,"aria-expanded":z,onClick:()=>B(e=>!e),children:z?k.hideSuggestion:k.viewSuggestion})]}):null,!C.observation&&Tt&&!Xt?(0,Q.jsx)(Ue,{advisor:C.advisor,busy:ye,copy:{aiLabel:n.home.advisorAiLabel,why:n.home.advisorWhy,evidence:n.home.advisorEvidence,needsSetup:n.home.advisorNeedsSetup,start:n.home.advisorStart,discuss:n.home.advisorDiscuss,refresh:n.home.advisorRefresh,refreshing:n.home.advisorRefreshing,history:n.home.advisorHistory,viewProgress:n.home.advisorViewProgress,alternatives:n.home.advisorAlternatives,more:k.moreSuggestionActions,feedback:n.home.advisorFeedback,alreadyDone:n.home.advisorAlreadyDone,irrelevant:n.home.advisorIrrelevant,later:n.home.advisorLater,lessLikeThis:n.home.advisorLessLikeThis,sourceIncorrect:n.home.advisorSourceIncorrect,minutes:n.home.advisorMinutes,setupTitle:n.home.advisorSetupTitle,setupHint:n.home.advisorSetupHint,configure:n.home.advisorConfigure,degradedStart:n.home.advisorDegradedStart,automationHint:n.home.advisorAutomationHint,automationAction:n.home.advisorAutomationAction},onRefresh:It,onAction:Lt,onFeedback:Rt,onClarification:Bt,onOpenHistory:()=>Ae(!0),preflight:Fe,receipt:Ce}):null]}):null]}):null,tn]}),!Dt&&!Qt&&ht.length>0?(0,Q.jsx)(J,{variant:`ghost`,className:`self-start px-2 text-xs`,onClick:()=>Ht(`history`),children:k.deliveryHistory}):null]}):null,Ne?(0,Q.jsxs)(`div`,{role:`status`,className:`fixed bottom-5 left-1/2 z-[100] flex -translate-x-1/2 items-center gap-4 rounded-lg border border-edge bg-surface-overlay px-4 py-3 text-sm text-fg shadow-float`,children:[(0,Q.jsx)(`span`,{children:n.home.advisorFeedbackSaved}),(0,Q.jsx)(`button`,{type:`button`,className:`font-medium text-accent-fg hover:underline`,onClick:zt,children:n.home.advisorUndo})]}):null]})}export{mt as HomePage};
|